@yoopta/themes-shadcn 6.0.2 → 6.0.3
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/accordion.js +1 -1
- package/dist/applyTheme.d.ts.map +1 -1
- package/dist/carousel.js +1 -1
- package/dist/chunks/button-f335deaa.js +1 -0
- package/dist/chunks/{dropdown-menu-eb328f8d.js → dropdown-menu-36750aec.js} +3 -3
- package/dist/chunks/{hover-card-d6a71398.js → hover-card-8048e9ce.js} +1 -1
- package/dist/chunks/index-371259c9.js +1 -0
- package/dist/chunks/{index-f85dae42.js → index-5b487f4e.js} +1 -1
- package/dist/chunks/{index-ba3032f8.js → index-a77c7d53.js} +1 -1
- package/dist/chunks/{index-23db6fea.js → index-bd6363d4.js} +1 -1
- package/dist/chunks/label-35a74462.js +1 -0
- package/dist/chunks/{language-select-89735035.js → language-select-ee2698cf.js} +1 -1
- package/dist/chunks/pen-d6258303.js +7 -0
- package/dist/chunks/popover-dae0ce5f.js +1 -0
- package/dist/chunks/{scroll-area-dae47c2c.js → scroll-area-8321348a.js} +1 -1
- package/dist/chunks/{select-a8bcd8b5.js → select-a3724728.js} +1 -1
- package/dist/chunks/separator-f4e74aca.js +1 -0
- package/dist/chunks/{tabs-294764a6.js → tabs-370c3f2c.js} +1 -1
- package/dist/chunks/{tooltip-65b9c3a0.js → tooltip-5defff1d.js} +2 -2
- package/dist/code-group.js +1 -1
- package/dist/code.js +1 -1
- package/dist/divider.js +1 -1
- package/dist/embed/elements/embed/embed-inline-toolbar.d.ts.map +1 -1
- package/dist/embed.js +2 -2
- package/dist/emoji.js +1 -1
- package/dist/file/elements/file/file-inline-toolbar.d.ts.map +1 -1
- package/dist/file.js +3 -3
- package/dist/image/elements/image/image-inline-toolbar.d.ts.map +1 -1
- package/dist/image.js +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/link.js +1 -7
- package/dist/math/elements/math/math-edit.d.ts +13 -0
- package/dist/math/elements/math/math-edit.d.ts.map +1 -0
- package/dist/math/elements/math/math-element.d.ts +3 -0
- package/dist/math/elements/math/math-element.d.ts.map +1 -0
- package/dist/math/elements/math/math-preview.d.ts +10 -0
- package/dist/math/elements/math/math-preview.d.ts.map +1 -0
- package/dist/math/elements/math-block/math-block-element.d.ts +3 -0
- package/dist/math/elements/math-block/math-block-element.d.ts.map +1 -0
- package/dist/math/index.d.ts +15 -0
- package/dist/math/index.d.ts.map +1 -0
- package/dist/math.js +1 -0
- package/dist/mention.js +3 -3
- package/dist/steps.js +1 -1
- package/dist/table-of-contents/elements/table-of-contents.d.ts.map +1 -1
- package/dist/table-of-contents.js +1 -1
- package/dist/table.js +3 -3
- package/dist/tabs.js +1 -1
- package/dist/video/elements/video/video-inline-toolbar.d.ts.map +1 -1
- package/dist/video.js +2 -2
- package/package.json +21 -14
- package/dist/chunks/button-7aec29d6.js +0 -1
- package/dist/chunks/index-23c7fb16.js +0 -1
- package/dist/chunks/label-21d46c31.js +0 -1
- package/dist/chunks/popover-8e6ee2ab.js +0 -1
- package/dist/chunks/separator-219dc1f7.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./_tslib-35bb891d.js";import{jsx as r,jsxs as t,Fragment as o}from"react/jsx-runtime";import*as n from"react";import{c as l,P as i,a,u as s}from"./index-17323747.js";import{P as c}from"./index-23db6fea.js";import{u as d}from"./index-91a5b8d5.js";import{u}from"./index-70f4e709.js";import{u as p}from"./index-13505606.js";import{c as f}from"./index-056e5c06.js";import{c as h}from"./utils-3345eade.js";var v="ScrollArea",[w,b]=l(v),[m,g]=w(v),S=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,type:l="hover",dir:a,scrollHideDelay:s=600,...c}=e,[u,f]=n.useState(null),[h,v]=n.useState(null),[w,b]=n.useState(null),[g,S]=n.useState(null),[y,E]=n.useState(null),[T,C]=n.useState(0),[R,P]=n.useState(0),[_,x]=n.useState(!1),[L,D]=n.useState(!1),A=d(t,e=>f(e)),z=p(a);return r(m,{scope:o,type:l,dir:z,scrollHideDelay:s,scrollArea:u,viewport:h,onViewportChange:v,content:w,onContentChange:b,scrollbarX:g,onScrollbarXChange:S,scrollbarXEnabled:_,onScrollbarXEnabledChange:x,scrollbarY:y,onScrollbarYChange:E,scrollbarYEnabled:L,onScrollbarYEnabledChange:D,onCornerWidthChange:C,onCornerHeightChange:P,children:r(i.div,{dir:z,...c,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":T+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})});S.displayName=v;var y="ScrollAreaViewport",E=n.forwardRef((e,l)=>{const{__scopeScrollArea:a,children:s,nonce:c,...u}=e,p=g(y,a),f=n.useRef(null),h=d(l,f,p.onViewportChange);return t(o,{children:[r("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:c}),r(i.div,{"data-radix-scroll-area-viewport":"",...u,ref:h,style:{overflowX:p.scrollbarXEnabled?"scroll":"hidden",overflowY:p.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r("div",{ref:p.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});E.displayName=y;var T="ScrollAreaScrollbar",C=n.forwardRef((e,t)=>{const{forceMount:o,...l}=e,i=g(T,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:s}=i,c="horizontal"===e.orientation;return n.useEffect(()=>(c?a(!0):s(!0),()=>{c?a(!1):s(!1)}),[c,a,s]),"hover"===i.type?r(R,{...l,ref:t,forceMount:o}):"scroll"===i.type?r(P,{...l,ref:t,forceMount:o}):"auto"===i.type?r(_,{...l,ref:t,forceMount:o}):"always"===i.type?r(x,{...l,ref:t}):null});C.displayName=T;var R=n.forwardRef((e,t)=>{const{forceMount:o,...l}=e,i=g(T,e.__scopeScrollArea),[a,s]=n.useState(!1);return n.useEffect(()=>{const e=i.scrollArea;let r=0;if(e){const t=()=>{window.clearTimeout(r),s(!0)},o=()=>{r=window.setTimeout(()=>s(!1),i.scrollHideDelay)};return e.addEventListener("pointerenter",t),e.addEventListener("pointerleave",o),()=>{window.clearTimeout(r),e.removeEventListener("pointerenter",t),e.removeEventListener("pointerleave",o)}}},[i.scrollArea,i.scrollHideDelay]),r(c,{present:o||a,children:r(_,{"data-state":a?"visible":"hidden",...l,ref:t})})}),P=n.forwardRef((e,t)=>{const{forceMount:o,...l}=e,i=g(T,e.__scopeScrollArea),s="horizontal"===e.orientation,d=q(()=>p("SCROLL_END"),100),[u,p]=(f="hidden",h={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},n.useReducer((e,r)=>h[e][r]??e,f));var f,h;return n.useEffect(()=>{if("idle"===u){const e=window.setTimeout(()=>p("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[u,i.scrollHideDelay,p]),n.useEffect(()=>{const e=i.viewport,r=s?"scrollLeft":"scrollTop";if(e){let t=e[r];const o=()=>{const o=e[r];t!==o&&(p("SCROLL"),d()),t=o};return e.addEventListener("scroll",o),()=>e.removeEventListener("scroll",o)}},[i.viewport,s,p,d]),r(c,{present:o||"hidden"!==u,children:r(x,{"data-state":"hidden"===u?"hidden":"visible",...l,ref:t,onPointerEnter:a(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:a(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),_=n.forwardRef((e,t)=>{const o=g(T,e.__scopeScrollArea),{forceMount:l,...i}=e,[a,s]=n.useState(!1),d="horizontal"===e.orientation,u=q(()=>{if(o.viewport){const e=o.viewport.offsetWidth<o.viewport.scrollWidth,r=o.viewport.offsetHeight<o.viewport.scrollHeight;s(d?e:r)}},10);return $(o.viewport,u),$(o.content,u),r(c,{present:l||a,children:r(x,{"data-state":a?"visible":"hidden",...i,ref:t})})}),x=n.forwardRef((e,t)=>{const{orientation:o="vertical",...l}=e,i=g(T,e.__scopeScrollArea),a=n.useRef(null),s=n.useRef(0),[c,d]=n.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=M(c.viewport,c.content),p={...l,sizes:c,onSizesChange:d,hasThumb:Boolean(u>0&&u<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:e=>s.current=e};function f(e,r){return function(e,r,t,o="ltr"){const n=U(t),l=n/2,i=r||l,a=n-i,s=t.scrollbar.paddingStart+i,c=t.scrollbar.size-t.scrollbar.paddingEnd-a,d=t.content-t.viewport,u="ltr"===o?[0,d]:[-1*d,0];return k([s,c],u)(e)}(e,s.current,c,r)}return"horizontal"===o?r(L,{...p,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){const e=B(i.viewport.scrollLeft,c,i.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=f(e,i.dir))}}):"vertical"===o?r(D,{...p,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){const e=B(i.viewport.scrollTop,c);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=f(e))}}):null}),L=n.forwardRef((e,t)=>{const{sizes:o,onSizesChange:l,...i}=e,a=g(T,e.__scopeScrollArea),[s,c]=n.useState(),u=n.useRef(null),p=d(t,u,a.onScrollbarXChange);return n.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),r(N,{"data-orientation":"horizontal",...i,ref:p,sizes:o,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":U(o)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.x),onDragScroll:r=>e.onDragScroll(r.x),onWheelScroll:(r,t)=>{if(a.viewport){const o=a.viewport.scrollLeft+r.deltaX;e.onWheelScroll(o),F(o,t)&&r.preventDefault()}},onResize:()=>{u.current&&a.viewport&&s&&l({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:I(s.paddingLeft),paddingEnd:I(s.paddingRight)}})}})}),D=n.forwardRef((e,t)=>{const{sizes:o,onSizesChange:l,...i}=e,a=g(T,e.__scopeScrollArea),[s,c]=n.useState(),u=n.useRef(null),p=d(t,u,a.onScrollbarYChange);return n.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),r(N,{"data-orientation":"vertical",...i,ref:p,sizes:o,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":U(o)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.y),onDragScroll:r=>e.onDragScroll(r.y),onWheelScroll:(r,t)=>{if(a.viewport){const o=a.viewport.scrollTop+r.deltaY;e.onWheelScroll(o),F(o,t)&&r.preventDefault()}},onResize:()=>{u.current&&a.viewport&&s&&l({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:I(s.paddingTop),paddingEnd:I(s.paddingBottom)}})}})}),[A,z]=w(T),N=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,sizes:l,hasThumb:s,onThumbChange:c,onThumbPointerUp:p,onThumbPointerDown:f,onThumbPositionChange:h,onDragScroll:v,onWheelScroll:w,onResize:b,...m}=e,S=g(T,o),[y,E]=n.useState(null),C=d(t,e=>E(e)),R=n.useRef(null),P=n.useRef(""),_=S.viewport,x=l.content-l.viewport,L=u(w),D=u(h),z=q(b,10);function N(e){if(R.current){const r=e.clientX-R.current.left,t=e.clientY-R.current.top;v({x:r,y:t})}}return n.useEffect(()=>{const e=e=>{const r=e.target,t=y?.contains(r);t&&L(e,x)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[_,y,x,L]),n.useEffect(D,[l,D]),$(y,z),$(S.content,z),r(A,{scope:o,scrollbar:y,hasThumb:s,onThumbChange:u(c),onThumbPointerUp:u(p),onThumbPositionChange:D,onThumbPointerDown:u(f),children:r(i.div,{...m,ref:C,style:{position:"absolute",...m.style},onPointerDown:a(e.onPointerDown,e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),R.current=y.getBoundingClientRect(),P.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",S.viewport&&(S.viewport.style.scrollBehavior="auto"),N(e)}}),onPointerMove:a(e.onPointerMove,N),onPointerUp:a(e.onPointerUp,e=>{const r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=P.current,S.viewport&&(S.viewport.style.scrollBehavior=""),R.current=null})})})}),H="ScrollAreaThumb",W=n.forwardRef((e,t)=>{const{forceMount:o,...n}=e,l=z(H,e.__scopeScrollArea);return r(c,{present:o||l.hasThumb,children:r(O,{ref:t,...n})})}),O=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,style:l,...s}=e,c=g(H,o),u=z(H,o),{onThumbPositionChange:p}=u,f=d(t,e=>u.onThumbChange(e)),h=n.useRef(void 0),v=q(()=>{h.current&&(h.current(),h.current=void 0)},100);return n.useEffect(()=>{const e=c.viewport;if(e){const r=()=>{if(v(),!h.current){const r=V(e,p);h.current=r,p()}};return p(),e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[c.viewport,v,p]),r(i.div,{"data-state":u.hasThumb?"visible":"hidden",...s,ref:f,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...l},onPointerDownCapture:a(e.onPointerDownCapture,e=>{const r=e.target.getBoundingClientRect(),t=e.clientX-r.left,o=e.clientY-r.top;u.onThumbPointerDown({x:t,y:o})}),onPointerUp:a(e.onPointerUp,u.onThumbPointerUp)})});W.displayName=H;var X="ScrollAreaCorner",Y=n.forwardRef((e,t)=>{const o=g(X,e.__scopeScrollArea),n=Boolean(o.scrollbarX&&o.scrollbarY);return"scroll"!==o.type&&n?r(j,{...e,ref:t}):null});Y.displayName=X;var j=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,...l}=e,a=g(X,o),[s,c]=n.useState(0),[d,u]=n.useState(0),p=Boolean(s&&d);return $(a.scrollbarX,()=>{const e=a.scrollbarX?.offsetHeight||0;a.onCornerHeightChange(e),u(e)}),$(a.scrollbarY,()=>{const e=a.scrollbarY?.offsetWidth||0;a.onCornerWidthChange(e),c(e)}),p?r(i.div,{...l,ref:t,style:{width:s,height:d,position:"absolute",right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:0,...e.style}}):null});function I(e){return e?parseInt(e,10):0}function M(e,r){const t=e/r;return isNaN(t)?0:t}function U(e){const r=M(e.viewport,e.content),t=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-t)*r;return Math.max(o,18)}function B(e,r,t="ltr"){const o=U(r),n=r.scrollbar.paddingStart+r.scrollbar.paddingEnd,l=r.scrollbar.size-n,i=r.content-r.viewport,a=l-o,s=f(e,"ltr"===t?[0,i]:[-1*i,0]);return k([0,i],[0,a])(s)}function k(e,r){return t=>{if(e[0]===e[1]||r[0]===r[1])return r[0];const o=(r[1]-r[0])/(e[1]-e[0]);return r[0]+o*(t-e[0])}}function F(e,r){return e>0&&e<r}var V=(e,r=()=>{})=>{let t={left:e.scrollLeft,top:e.scrollTop},o=0;return function n(){const l={left:e.scrollLeft,top:e.scrollTop},i=t.left!==l.left,a=t.top!==l.top;(i||a)&&r(),t=l,o=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(o)};function q(e,r){const t=u(e),o=n.useRef(0);return n.useEffect(()=>()=>window.clearTimeout(o.current),[]),n.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(t,r)},[t,r])}function $(e,r){const t=u(r);s(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,t])}var G=S,J=E,K=Y;const Q=t=>{var{className:o,orientation:n="vertical"}=t,l=e(t,["className","orientation"]);return r(C,Object.assign({"data-slot":"scroll-area-scrollbar",orientation:n,className:h("flex touch-none p-px transition-colors select-none","vertical"===n&&"h-full w-2.5 border-l border-l-transparent","horizontal"===n&&"h-2.5 flex-col border-t border-t-transparent",o)},l,{children:r(W,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})}))},Z=o=>{var{className:n,children:l}=o,i=e(o,["className","children"]);return t(G,Object.assign({"data-slot":"scroll-area",className:h("relative",n)},i,{children:[r(J,Object.assign({"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"},{children:l})),r(Q,{}),r(K,{})]}))};export{Z as S,Q as a};
|
|
1
|
+
import{_ as e}from"./_tslib-35bb891d.js";import{jsx as r,jsxs as t,Fragment as o}from"react/jsx-runtime";import*as n from"react";import{c as l,P as i,a,u as s}from"./index-17323747.js";import{P as c}from"./index-bd6363d4.js";import{u as d}from"./index-91a5b8d5.js";import{u}from"./index-70f4e709.js";import{u as p}from"./index-13505606.js";import{c as f}from"./index-056e5c06.js";import{c as h}from"./utils-3345eade.js";var v="ScrollArea",[w,b]=l(v),[m,g]=w(v),S=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,type:l="hover",dir:a,scrollHideDelay:s=600,...c}=e,[u,f]=n.useState(null),[h,v]=n.useState(null),[w,b]=n.useState(null),[g,S]=n.useState(null),[y,E]=n.useState(null),[T,C]=n.useState(0),[R,P]=n.useState(0),[_,x]=n.useState(!1),[L,D]=n.useState(!1),A=d(t,e=>f(e)),z=p(a);return r(m,{scope:o,type:l,dir:z,scrollHideDelay:s,scrollArea:u,viewport:h,onViewportChange:v,content:w,onContentChange:b,scrollbarX:g,onScrollbarXChange:S,scrollbarXEnabled:_,onScrollbarXEnabledChange:x,scrollbarY:y,onScrollbarYChange:E,scrollbarYEnabled:L,onScrollbarYEnabledChange:D,onCornerWidthChange:C,onCornerHeightChange:P,children:r(i.div,{dir:z,...c,ref:A,style:{position:"relative","--radix-scroll-area-corner-width":T+"px","--radix-scroll-area-corner-height":R+"px",...e.style}})})});S.displayName=v;var y="ScrollAreaViewport",E=n.forwardRef((e,l)=>{const{__scopeScrollArea:a,children:s,nonce:c,...u}=e,p=g(y,a),f=n.useRef(null),h=d(l,f,p.onViewportChange);return t(o,{children:[r("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:c}),r(i.div,{"data-radix-scroll-area-viewport":"",...u,ref:h,style:{overflowX:p.scrollbarXEnabled?"scroll":"hidden",overflowY:p.scrollbarYEnabled?"scroll":"hidden",...e.style},children:r("div",{ref:p.onContentChange,style:{minWidth:"100%",display:"table"},children:s})})]})});E.displayName=y;var T="ScrollAreaScrollbar",C=n.forwardRef((e,t)=>{const{forceMount:o,...l}=e,i=g(T,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:s}=i,c="horizontal"===e.orientation;return n.useEffect(()=>(c?a(!0):s(!0),()=>{c?a(!1):s(!1)}),[c,a,s]),"hover"===i.type?r(R,{...l,ref:t,forceMount:o}):"scroll"===i.type?r(P,{...l,ref:t,forceMount:o}):"auto"===i.type?r(_,{...l,ref:t,forceMount:o}):"always"===i.type?r(x,{...l,ref:t}):null});C.displayName=T;var R=n.forwardRef((e,t)=>{const{forceMount:o,...l}=e,i=g(T,e.__scopeScrollArea),[a,s]=n.useState(!1);return n.useEffect(()=>{const e=i.scrollArea;let r=0;if(e){const t=()=>{window.clearTimeout(r),s(!0)},o=()=>{r=window.setTimeout(()=>s(!1),i.scrollHideDelay)};return e.addEventListener("pointerenter",t),e.addEventListener("pointerleave",o),()=>{window.clearTimeout(r),e.removeEventListener("pointerenter",t),e.removeEventListener("pointerleave",o)}}},[i.scrollArea,i.scrollHideDelay]),r(c,{present:o||a,children:r(_,{"data-state":a?"visible":"hidden",...l,ref:t})})}),P=n.forwardRef((e,t)=>{const{forceMount:o,...l}=e,i=g(T,e.__scopeScrollArea),s="horizontal"===e.orientation,d=q(()=>p("SCROLL_END"),100),[u,p]=(f="hidden",h={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},n.useReducer((e,r)=>h[e][r]??e,f));var f,h;return n.useEffect(()=>{if("idle"===u){const e=window.setTimeout(()=>p("HIDE"),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[u,i.scrollHideDelay,p]),n.useEffect(()=>{const e=i.viewport,r=s?"scrollLeft":"scrollTop";if(e){let t=e[r];const o=()=>{const o=e[r];t!==o&&(p("SCROLL"),d()),t=o};return e.addEventListener("scroll",o),()=>e.removeEventListener("scroll",o)}},[i.viewport,s,p,d]),r(c,{present:o||"hidden"!==u,children:r(x,{"data-state":"hidden"===u?"hidden":"visible",...l,ref:t,onPointerEnter:a(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:a(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})}),_=n.forwardRef((e,t)=>{const o=g(T,e.__scopeScrollArea),{forceMount:l,...i}=e,[a,s]=n.useState(!1),d="horizontal"===e.orientation,u=q(()=>{if(o.viewport){const e=o.viewport.offsetWidth<o.viewport.scrollWidth,r=o.viewport.offsetHeight<o.viewport.scrollHeight;s(d?e:r)}},10);return $(o.viewport,u),$(o.content,u),r(c,{present:l||a,children:r(x,{"data-state":a?"visible":"hidden",...i,ref:t})})}),x=n.forwardRef((e,t)=>{const{orientation:o="vertical",...l}=e,i=g(T,e.__scopeScrollArea),a=n.useRef(null),s=n.useRef(0),[c,d]=n.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=M(c.viewport,c.content),p={...l,sizes:c,onSizesChange:d,hasThumb:Boolean(u>0&&u<1),onThumbChange:e=>a.current=e,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:e=>s.current=e};function f(e,r){return function(e,r,t,o="ltr"){const n=U(t),l=n/2,i=r||l,a=n-i,s=t.scrollbar.paddingStart+i,c=t.scrollbar.size-t.scrollbar.paddingEnd-a,d=t.content-t.viewport,u="ltr"===o?[0,d]:[-1*d,0];return k([s,c],u)(e)}(e,s.current,c,r)}return"horizontal"===o?r(L,{...p,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){const e=B(i.viewport.scrollLeft,c,i.dir);a.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=f(e,i.dir))}}):"vertical"===o?r(D,{...p,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){const e=B(i.viewport.scrollTop,c);a.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=f(e))}}):null}),L=n.forwardRef((e,t)=>{const{sizes:o,onSizesChange:l,...i}=e,a=g(T,e.__scopeScrollArea),[s,c]=n.useState(),u=n.useRef(null),p=d(t,u,a.onScrollbarXChange);return n.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),r(N,{"data-orientation":"horizontal",...i,ref:p,sizes:o,style:{bottom:0,left:"rtl"===a.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===a.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":U(o)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.x),onDragScroll:r=>e.onDragScroll(r.x),onWheelScroll:(r,t)=>{if(a.viewport){const o=a.viewport.scrollLeft+r.deltaX;e.onWheelScroll(o),F(o,t)&&r.preventDefault()}},onResize:()=>{u.current&&a.viewport&&s&&l({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:u.current.clientWidth,paddingStart:I(s.paddingLeft),paddingEnd:I(s.paddingRight)}})}})}),D=n.forwardRef((e,t)=>{const{sizes:o,onSizesChange:l,...i}=e,a=g(T,e.__scopeScrollArea),[s,c]=n.useState(),u=n.useRef(null),p=d(t,u,a.onScrollbarYChange);return n.useEffect(()=>{u.current&&c(getComputedStyle(u.current))},[u]),r(N,{"data-orientation":"vertical",...i,ref:p,sizes:o,style:{top:0,right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":U(o)+"px",...e.style},onThumbPointerDown:r=>e.onThumbPointerDown(r.y),onDragScroll:r=>e.onDragScroll(r.y),onWheelScroll:(r,t)=>{if(a.viewport){const o=a.viewport.scrollTop+r.deltaY;e.onWheelScroll(o),F(o,t)&&r.preventDefault()}},onResize:()=>{u.current&&a.viewport&&s&&l({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:u.current.clientHeight,paddingStart:I(s.paddingTop),paddingEnd:I(s.paddingBottom)}})}})}),[A,z]=w(T),N=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,sizes:l,hasThumb:s,onThumbChange:c,onThumbPointerUp:p,onThumbPointerDown:f,onThumbPositionChange:h,onDragScroll:v,onWheelScroll:w,onResize:b,...m}=e,S=g(T,o),[y,E]=n.useState(null),C=d(t,e=>E(e)),R=n.useRef(null),P=n.useRef(""),_=S.viewport,x=l.content-l.viewport,L=u(w),D=u(h),z=q(b,10);function N(e){if(R.current){const r=e.clientX-R.current.left,t=e.clientY-R.current.top;v({x:r,y:t})}}return n.useEffect(()=>{const e=e=>{const r=e.target,t=y?.contains(r);t&&L(e,x)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})},[_,y,x,L]),n.useEffect(D,[l,D]),$(y,z),$(S.content,z),r(A,{scope:o,scrollbar:y,hasThumb:s,onThumbChange:u(c),onThumbPointerUp:u(p),onThumbPositionChange:D,onThumbPointerDown:u(f),children:r(i.div,{...m,ref:C,style:{position:"absolute",...m.style},onPointerDown:a(e.onPointerDown,e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),R.current=y.getBoundingClientRect(),P.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",S.viewport&&(S.viewport.style.scrollBehavior="auto"),N(e)}}),onPointerMove:a(e.onPointerMove,N),onPointerUp:a(e.onPointerUp,e=>{const r=e.target;r.hasPointerCapture(e.pointerId)&&r.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=P.current,S.viewport&&(S.viewport.style.scrollBehavior=""),R.current=null})})})}),H="ScrollAreaThumb",W=n.forwardRef((e,t)=>{const{forceMount:o,...n}=e,l=z(H,e.__scopeScrollArea);return r(c,{present:o||l.hasThumb,children:r(O,{ref:t,...n})})}),O=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,style:l,...s}=e,c=g(H,o),u=z(H,o),{onThumbPositionChange:p}=u,f=d(t,e=>u.onThumbChange(e)),h=n.useRef(void 0),v=q(()=>{h.current&&(h.current(),h.current=void 0)},100);return n.useEffect(()=>{const e=c.viewport;if(e){const r=()=>{if(v(),!h.current){const r=V(e,p);h.current=r,p()}};return p(),e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}},[c.viewport,v,p]),r(i.div,{"data-state":u.hasThumb?"visible":"hidden",...s,ref:f,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...l},onPointerDownCapture:a(e.onPointerDownCapture,e=>{const r=e.target.getBoundingClientRect(),t=e.clientX-r.left,o=e.clientY-r.top;u.onThumbPointerDown({x:t,y:o})}),onPointerUp:a(e.onPointerUp,u.onThumbPointerUp)})});W.displayName=H;var X="ScrollAreaCorner",Y=n.forwardRef((e,t)=>{const o=g(X,e.__scopeScrollArea),n=Boolean(o.scrollbarX&&o.scrollbarY);return"scroll"!==o.type&&n?r(j,{...e,ref:t}):null});Y.displayName=X;var j=n.forwardRef((e,t)=>{const{__scopeScrollArea:o,...l}=e,a=g(X,o),[s,c]=n.useState(0),[d,u]=n.useState(0),p=Boolean(s&&d);return $(a.scrollbarX,()=>{const e=a.scrollbarX?.offsetHeight||0;a.onCornerHeightChange(e),u(e)}),$(a.scrollbarY,()=>{const e=a.scrollbarY?.offsetWidth||0;a.onCornerWidthChange(e),c(e)}),p?r(i.div,{...l,ref:t,style:{width:s,height:d,position:"absolute",right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:0,...e.style}}):null});function I(e){return e?parseInt(e,10):0}function M(e,r){const t=e/r;return isNaN(t)?0:t}function U(e){const r=M(e.viewport,e.content),t=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-t)*r;return Math.max(o,18)}function B(e,r,t="ltr"){const o=U(r),n=r.scrollbar.paddingStart+r.scrollbar.paddingEnd,l=r.scrollbar.size-n,i=r.content-r.viewport,a=l-o,s=f(e,"ltr"===t?[0,i]:[-1*i,0]);return k([0,i],[0,a])(s)}function k(e,r){return t=>{if(e[0]===e[1]||r[0]===r[1])return r[0];const o=(r[1]-r[0])/(e[1]-e[0]);return r[0]+o*(t-e[0])}}function F(e,r){return e>0&&e<r}var V=(e,r=()=>{})=>{let t={left:e.scrollLeft,top:e.scrollTop},o=0;return function n(){const l={left:e.scrollLeft,top:e.scrollTop},i=t.left!==l.left,a=t.top!==l.top;(i||a)&&r(),t=l,o=window.requestAnimationFrame(n)}(),()=>window.cancelAnimationFrame(o)};function q(e,r){const t=u(e),o=n.useRef(0);return n.useEffect(()=>()=>window.clearTimeout(o.current),[]),n.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(t,r)},[t,r])}function $(e,r){const t=u(r);s(()=>{let r=0;if(e){const o=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(t)});return o.observe(e),()=>{window.cancelAnimationFrame(r),o.unobserve(e)}}},[e,t])}var G=S,J=E,K=Y;const Q=t=>{var{className:o,orientation:n="vertical"}=t,l=e(t,["className","orientation"]);return r(C,Object.assign({"data-slot":"scroll-area-scrollbar",orientation:n,className:h("flex touch-none p-px transition-colors select-none","vertical"===n&&"h-full w-2.5 border-l border-l-transparent","horizontal"===n&&"h-2.5 flex-col border-t border-t-transparent",o)},l,{children:r(W,{"data-slot":"scroll-area-thumb",className:"bg-border relative flex-1 rounded-full"})}))},Z=o=>{var{className:n,children:l}=o,i=e(o,["className","children"]);return t(G,Object.assign({"data-slot":"scroll-area",className:h("relative",n)},i,{children:[r(J,Object.assign({"data-slot":"scroll-area-viewport",className:"focus-visible:ring-ring/50 size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:outline-1"},{children:l})),r(Q,{}),r(K,{})]}))};export{Z as S,Q as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./_tslib-35bb891d.js";import{jsx as t,Fragment as n,jsxs as r}from"react/jsx-runtime";import*as o from"react";import*as a from"react-dom";import{c as l}from"./index-056e5c06.js";import{c as i,P as s,a as c,u as d}from"./index-17323747.js";import{c as u}from"./index-f85dae42.js";import{c as p,u as f}from"./index-91a5b8d5.js";import{u as m}from"./index-13505606.js";import{c as h,A as v,D as g,C as w,a as y,R as b,P as x}from"./index-23c7fb16.js";import{h as S,u as C,R as _,F as N}from"./Combination-575d4475.js";import{u as R}from"./index-ce60ba41.js";import{u as P}from"./index-70f4e709.js";import{u as k}from"./index-ff0e3962.js";import{V as I}from"./index-1674c2c8.js";import{c as T}from"./utils-3345eade.js";import{C as E}from"./chevron-down-28dfb290.js";import{C as D}from"./check-06bd6a78.js";import{C as O}from"./chevron-up-9a13532e.js";function j(e){const t=o.forwardRef((e,t)=>{const{children:n,...r}=e;if(o.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),a=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==o.Fragment&&(a.ref=t?p(t,e):e),o.cloneElement(n,a)}return o.Children.count(n)>1?o.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var M=Symbol("radix.slottable");function L(e){return o.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===M}function A(e){const t=o.useRef({value:e,previous:e});return o.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var V=[" ","Enter","ArrowUp","ArrowDown"],z=[" ","Enter"],H="Select",[B,W,K]=u(H),[F,U]=i(H,[K,h]),q=h(),[$,X]=F(H),[Y,Z]=F(H),G=e=>{const{__scopeSelect:n,children:a,open:l,defaultOpen:i,onOpenChange:s,value:c,defaultValue:d,onValueChange:u,dir:p,name:f,autoComplete:h,disabled:v,required:g,form:w}=e,y=q(n),[x,S]=o.useState(null),[C,_]=o.useState(null),[N,P]=o.useState(!1),I=m(p),[T,E]=k({prop:l,defaultProp:i??!1,onChange:s,caller:H}),[D,O]=k({prop:c,defaultProp:d,onChange:u,caller:H}),j=o.useRef(null),M=!x||(w||!!x.closest("form")),[L,A]=o.useState(new Set),V=Array.from(L).map(e=>e.props.value).join(";");return t(b,{...y,children:r($,{required:g,scope:n,trigger:x,onTriggerChange:S,valueNode:C,onValueNodeChange:_,valueNodeHasChildren:N,onValueNodeHasChildrenChange:P,contentId:R(),value:D,onValueChange:O,open:T,onOpenChange:E,dir:I,triggerPointerDownPosRef:j,disabled:v,children:[t(B.Provider,{scope:n,children:t(Y,{scope:e.__scopeSelect,onNativeOptionAdd:o.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:o.useCallback(e=>{A(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:a})}),M?r(Le,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:h,value:D,onChange:e=>O(e.target.value),disabled:v,form:w,children:[void 0===D?t("option",{value:""}):null,Array.from(L)]},V):null]})})};G.displayName=H;var J="SelectTrigger",Q=o.forwardRef((e,n)=>{const{__scopeSelect:r,disabled:a=!1,...l}=e,i=q(r),d=X(J,r),u=d.disabled||a,p=f(n,d.onTriggerChange),m=W(r),h=o.useRef("touch"),[g,w,y]=Ve(e=>{const t=m().filter(e=>!e.disabled),n=t.find(e=>e.value===d.value),r=ze(t,e,n);void 0!==r&&d.onValueChange(r.value)}),b=e=>{u||(d.onOpenChange(!0),y()),e&&(d.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t(v,{asChild:!0,...i,children:t(s.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":Ae(d.value)?"":void 0,...l,ref:p,onClick:c(l.onClick,e=>{e.currentTarget.focus(),"mouse"!==h.current&&b(e)}),onPointerDown:c(l.onPointerDown,e=>{h.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(b(e),e.preventDefault())}),onKeyDown:c(l.onKeyDown,e=>{const t=""!==g.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||w(e.key),t&&" "===e.key||V.includes(e.key)&&(b(),e.preventDefault())})})})});Q.displayName=J;var ee="SelectValue",te=o.forwardRef((e,r)=>{const{__scopeSelect:o,className:a,style:l,children:i,placeholder:c="",...u}=e,p=X(ee,o),{onValueNodeHasChildrenChange:m}=p,h=void 0!==i,v=f(r,p.onValueNodeChange);return d(()=>{m(h)},[m,h]),t(s.span,{...u,ref:v,style:{pointerEvents:"none"},children:Ae(p.value)?t(n,{children:c}):i})});te.displayName=ee;var ne=o.forwardRef((e,n)=>{const{__scopeSelect:r,children:o,...a}=e;return t(s.span,{"aria-hidden":!0,...a,ref:n,children:o||"▼"})});ne.displayName="SelectIcon";var re=e=>t(x,{asChild:!0,...e});re.displayName="SelectPortal";var oe="SelectContent",ae=o.forwardRef((e,n)=>{const r=X(oe,e.__scopeSelect),[l,i]=o.useState();if(d(()=>{i(new DocumentFragment)},[]),!r.open){const n=l;return n?a.createPortal(t(ie,{scope:e.__scopeSelect,children:t(B.Slot,{scope:e.__scopeSelect,children:t("div",{children:e.children})})}),n):null}return t(de,{...e,ref:n})});ae.displayName=oe;var le=10,[ie,se]=F(oe),ce=function(e){const n=j(e),r=o.forwardRef((e,r)=>{const{children:a,...l}=e,i=o.Children.toArray(a),s=i.find(L);if(s){const e=s.props.children,a=i.map(t=>t===s?o.Children.count(e)>1?o.Children.only(null):o.isValidElement(e)?e.props.children:null:t);return t(n,{...l,ref:r,children:o.isValidElement(e)?o.cloneElement(e,void 0,a):null})}return t(n,{...l,ref:r,children:a})});return r.displayName=`${e}.Slot`,r}("SelectContent.RemoveScroll"),de=o.forwardRef((e,n)=>{const{__scopeSelect:r,position:a="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:i,onPointerDownOutside:s,side:d,sideOffset:u,align:p,alignOffset:m,arrowPadding:h,collisionBoundary:v,collisionPadding:w,sticky:y,hideWhenDetached:b,avoidCollisions:x,...R}=e,P=X(oe,r),[k,I]=o.useState(null),[T,E]=o.useState(null),D=f(n,e=>I(e)),[O,j]=o.useState(null),[M,L]=o.useState(null),A=W(r),[V,z]=o.useState(!1),H=o.useRef(!1);o.useEffect(()=>{if(k)return S(k)},[k]),C();const B=o.useCallback(e=>{const[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),o=document.activeElement;for(const n of e){if(n===o)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==o)return}},[A,T]),K=o.useCallback(()=>B([O,k]),[B,O,k]);o.useEffect(()=>{V&&K()},[V,K]);const{onOpenChange:F,triggerPointerDownPosRef:U}=P;o.useEffect(()=>{if(k){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(U.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():k.contains(n.target)||F(!1),document.removeEventListener("pointermove",t),U.current=null};return null!==U.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[k,F,U]),o.useEffect(()=>{const e=()=>F(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[F]);const[q,$]=Ve(e=>{const t=A().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=ze(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),Y=o.useCallback((e,t,n)=>{const r=!H.current&&!n;(void 0!==P.value&&P.value===t||r)&&(j(e),r&&(H.current=!0))},[P.value]),Z=o.useCallback(()=>k?.focus(),[k]),G=o.useCallback((e,t,n)=>{const r=!H.current&&!n;(void 0!==P.value&&P.value===t||r)&&L(e)},[P.value]),J="popper"===a?pe:ue,Q=J===pe?{side:d,sideOffset:u,align:p,alignOffset:m,arrowPadding:h,collisionBoundary:v,collisionPadding:w,sticky:y,hideWhenDetached:b,avoidCollisions:x}:{};return t(ie,{scope:r,content:k,viewport:T,onViewportChange:E,itemRefCallback:Y,selectedItem:O,onItemLeave:Z,itemTextRefCallback:G,focusSelectedItem:K,selectedItemText:M,position:a,isPositioned:V,searchRef:q,children:t(_,{as:ce,allowPinchZoom:!0,children:t(N,{asChild:!0,trapped:P.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:c(l,e=>{P.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:t(g,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>P.onOpenChange(!1),children:t(J,{role:"listbox",id:P.contentId,"data-state":P.open?"open":"closed",dir:P.dir,onContextMenu:e=>e.preventDefault(),...R,...Q,onPlaced:()=>z(!0),ref:D,style:{display:"flex",flexDirection:"column",outline:"none",...R.style},onKeyDown:c(R.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||$(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>B(t)),e.preventDefault()}})})})})})})});de.displayName="SelectContentImpl";var ue=o.forwardRef((e,n)=>{const{__scopeSelect:r,onPlaced:a,...i}=e,c=X(oe,r),u=se(oe,r),[p,m]=o.useState(null),[h,v]=o.useState(null),g=f(n,e=>v(e)),w=W(r),y=o.useRef(!1),b=o.useRef(!0),{viewport:x,selectedItem:S,selectedItemText:C,focusSelectedItem:_}=u,N=o.useCallback(()=>{if(c.trigger&&c.valueNode&&p&&h&&x&&S&&C){const e=c.trigger.getBoundingClientRect(),t=h.getBoundingClientRect(),n=c.valueNode.getBoundingClientRect(),r=C.getBoundingClientRect();if("rtl"!==c.dir){const o=r.left-t.left,a=n.left-o,i=e.left-a,s=e.width+i,c=Math.max(s,t.width),d=window.innerWidth-le,u=l(a,[le,Math.max(le,d-c)]);p.style.minWidth=s+"px",p.style.left=u+"px"}else{const o=t.right-r.right,a=window.innerWidth-n.right-o,i=window.innerWidth-e.right-a,s=e.width+i,c=Math.max(s,t.width),d=window.innerWidth-le,u=l(a,[le,Math.max(le,d-c)]);p.style.minWidth=s+"px",p.style.right=u+"px"}const o=w(),i=window.innerHeight-2*le,s=x.scrollHeight,d=window.getComputedStyle(h),u=parseInt(d.borderTopWidth,10),f=parseInt(d.paddingTop,10),m=parseInt(d.borderBottomWidth,10),v=u+f+s+parseInt(d.paddingBottom,10)+m,g=Math.min(5*S.offsetHeight,v),b=window.getComputedStyle(x),_=parseInt(b.paddingTop,10),N=parseInt(b.paddingBottom,10),R=e.top+e.height/2-le,P=i-R,k=S.offsetHeight/2,I=u+f+(S.offsetTop+k),T=v-I;if(I<=R){const e=o.length>0&&S===o[o.length-1].ref.current;p.style.bottom="0px";const t=h.clientHeight-x.offsetTop-x.offsetHeight,n=I+Math.max(P,k+(e?N:0)+t+m);p.style.height=n+"px"}else{const e=o.length>0&&S===o[0].ref.current;p.style.top="0px";const t=Math.max(R,u+x.offsetTop+(e?_:0)+k)+T;p.style.height=t+"px",x.scrollTop=I-R+x.offsetTop}p.style.margin=`${le}px 0`,p.style.minHeight=g+"px",p.style.maxHeight=i+"px",a?.(),requestAnimationFrame(()=>y.current=!0)}},[w,c.trigger,c.valueNode,p,h,x,S,C,c.dir,a]);d(()=>N(),[N]);const[R,P]=o.useState();d(()=>{h&&P(window.getComputedStyle(h).zIndex)},[h]);const k=o.useCallback(e=>{e&&!0===b.current&&(N(),_?.(),b.current=!1)},[N,_]);return t(fe,{scope:r,contentWrapper:p,shouldExpandOnScrollRef:y,onScrollButtonChange:k,children:t("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:R},children:t(s.div,{...i,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});ue.displayName="SelectItemAlignedPosition";var pe=o.forwardRef((e,n)=>{const{__scopeSelect:r,align:o="start",collisionPadding:a=le,...l}=e,i=q(r);return t(w,{...i,...l,ref:n,align:o,collisionPadding:a,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});pe.displayName="SelectPopperPosition";var[fe,me]=F(oe,{}),he="SelectViewport",ve=o.forwardRef((e,a)=>{const{__scopeSelect:l,nonce:i,...d}=e,u=se(he,l),p=me(he,l),m=f(a,u.onViewportChange),h=o.useRef(0);return r(n,{children:[t("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),t(B.Slot,{scope:l,children:t(s.div,{"data-radix-select-viewport":"",role:"presentation",...d,ref:m,style:{position:"relative",flex:1,overflow:"hidden auto",...d.style},onScroll:c(d.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=p;if(r?.current&&n){const e=Math.abs(h.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*le,o=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),l=Math.max(o,a);if(l<r){const o=l+e,a=Math.min(r,o),i=o-a;n.style.height=a+"px","0px"===n.style.bottom&&(t.scrollTop=i>0?i:0,n.style.justifyContent="flex-end")}}}h.current=t.scrollTop})})})]})});ve.displayName=he;var ge="SelectGroup",[we,ye]=F(ge),be=o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e,a=R();return t(we,{scope:r,id:a,children:t(s.div,{role:"group","aria-labelledby":a,...o,ref:n})})});be.displayName=ge;var xe="SelectLabel";o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e,a=ye(xe,r);return t(s.div,{id:a.id,...o,ref:n})}).displayName=xe;var Se="SelectItem",[Ce,_e]=F(Se),Ne=o.forwardRef((e,n)=>{const{__scopeSelect:r,value:a,disabled:l=!1,textValue:i,...d}=e,u=X(Se,r),p=se(Se,r),m=u.value===a,[h,v]=o.useState(i??""),[g,w]=o.useState(!1),y=f(n,e=>p.itemRefCallback?.(e,a,l)),b=R(),x=o.useRef("touch"),S=()=>{l||(u.onValueChange(a),u.onOpenChange(!1))};if(""===a)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t(Ce,{scope:r,value:a,disabled:l,textId:b,isSelected:m,onItemTextChange:o.useCallback(e=>{v(t=>t||(e?.textContent??"").trim())},[]),children:t(B.ItemSlot,{scope:r,value:a,disabled:l,textValue:h,children:t(s.div,{role:"option","aria-labelledby":b,"data-highlighted":g?"":void 0,"aria-selected":m&&g,"data-state":m?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...d,ref:y,onFocus:c(d.onFocus,()=>w(!0)),onBlur:c(d.onBlur,()=>w(!1)),onClick:c(d.onClick,()=>{"mouse"!==x.current&&S()}),onPointerUp:c(d.onPointerUp,()=>{"mouse"===x.current&&S()}),onPointerDown:c(d.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:c(d.onPointerMove,e=>{x.current=e.pointerType,l?p.onItemLeave?.():"mouse"===x.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:c(d.onPointerLeave,e=>{e.currentTarget===document.activeElement&&p.onItemLeave?.()}),onKeyDown:c(d.onKeyDown,e=>{""!==p.searchRef?.current&&" "===e.key||(z.includes(e.key)&&S()," "===e.key&&e.preventDefault())})})})})});Ne.displayName=Se;var Re="SelectItemText",Pe=o.forwardRef((e,l)=>{const{__scopeSelect:i,className:c,style:u,...p}=e,m=X(Re,i),h=se(Re,i),v=_e(Re,i),g=Z(Re,i),[w,y]=o.useState(null),b=f(l,e=>y(e),v.onItemTextChange,e=>h.itemTextRefCallback?.(e,v.value,v.disabled)),x=w?.textContent,S=o.useMemo(()=>t("option",{value:v.value,disabled:v.disabled,children:x},v.value),[v.disabled,v.value,x]),{onNativeOptionAdd:C,onNativeOptionRemove:_}=g;return d(()=>(C(S),()=>_(S)),[C,_,S]),r(n,{children:[t(s.span,{id:v.textId,...p,ref:b}),v.isSelected&&m.valueNode&&!m.valueNodeHasChildren?a.createPortal(p.children,m.valueNode):null]})});Pe.displayName=Re;var ke="SelectItemIndicator",Ie=o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e;return _e(ke,r).isSelected?t(s.span,{"aria-hidden":!0,...o,ref:n}):null});Ie.displayName=ke;var Te="SelectScrollUpButton",Ee=o.forwardRef((e,n)=>{const r=se(Te,e.__scopeSelect),a=me(Te,e.__scopeSelect),[l,i]=o.useState(!1),s=f(n,a.onScrollButtonChange);return d(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;i(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),l?t(je,{...e,ref:s,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});Ee.displayName=Te;var De="SelectScrollDownButton",Oe=o.forwardRef((e,n)=>{const r=se(De,e.__scopeSelect),a=me(De,e.__scopeSelect),[l,i]=o.useState(!1),s=f(n,a.onScrollButtonChange);return d(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;i(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),l?t(je,{...e,ref:s,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});Oe.displayName=De;var je=o.forwardRef((e,n)=>{const{__scopeSelect:r,onAutoScroll:a,...l}=e,i=se("SelectScrollButton",r),u=o.useRef(null),p=W(r),f=o.useCallback(()=>{null!==u.current&&(window.clearInterval(u.current),u.current=null)},[]);return o.useEffect(()=>()=>f(),[f]),d(()=>{const e=p().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[p]),t(s.div,{"aria-hidden":!0,...l,ref:n,style:{flexShrink:0,...l.style},onPointerDown:c(l.onPointerDown,()=>{null===u.current&&(u.current=window.setInterval(a,50))}),onPointerMove:c(l.onPointerMove,()=>{i.onItemLeave?.(),null===u.current&&(u.current=window.setInterval(a,50))}),onPointerLeave:c(l.onPointerLeave,()=>{f()})})});o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e;return t(s.div,{"aria-hidden":!0,...o,ref:n})}).displayName="SelectSeparator";var Me="SelectArrow";o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e,a=q(r),l=X(Me,r),i=se(Me,r);return l.open&&"popper"===i.position?t(y,{...a,...o,ref:n}):null}).displayName=Me;var Le=o.forwardRef(({__scopeSelect:e,value:n,...r},a)=>{const l=o.useRef(null),i=f(a,l),c=A(n);return o.useEffect(()=>{const e=l.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(c!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[c,n]),t(s.select,{...r,style:{...I,...r.style},ref:i,defaultValue:n})});function Ae(e){return""===e||void 0===e}function Ve(e){const t=P(e),n=o.useRef(""),r=o.useRef(0),a=o.useCallback(e=>{const o=n.current+e;t(o),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(o)},[t]),l=o.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return o.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,l]}function ze(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let a=(l=e,i=Math.max(o,0),l.map((e,t)=>l[(i+t)%l.length]));var l,i;1===r.length&&(a=a.filter(e=>e!==n));const s=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return s!==n?s:void 0}Le.displayName="SelectBubbleInput";var He=G,Be=Q,We=te,Ke=ne,Fe=re,Ue=ae,qe=ve,$e=be,Xe=Ne,Ye=Pe,Ze=Ie,Ge=Ee,Je=Oe;const Qe=n=>{var r=e(n,[]);return t(He,Object.assign({"data-slot":"select"},r))},et=n=>{var r=e(n,[]);return t($e,Object.assign({"data-slot":"select-group"},r))},tt=n=>{var r=e(n,[]);return t(We,Object.assign({"data-slot":"select-value"},r))},nt=n=>{var{className:o,size:a="default",children:l}=n,i=e(n,["className","size","children"]);return r(Be,Object.assign({"data-slot":"select-trigger","data-size":a,className:T("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o)},i,{children:[l,t(Ke,Object.assign({asChild:!0},{children:t(E,{className:"size-4 opacity-50"})}))]}))},rt=n=>{var{className:r}=n,o=e(n,["className"]);return t(Ge,Object.assign({"data-slot":"select-scroll-up-button",className:T("flex cursor-default items-center justify-center py-1",r)},o,{children:t(O,{className:"size-4"})}))},ot=n=>{var{className:r}=n,o=e(n,["className"]);return t(Je,Object.assign({"data-slot":"select-scroll-down-button",className:T("flex cursor-default items-center justify-center py-1",r)},o,{children:t(E,{className:"size-4"})}))},at=n=>{var{className:o,children:a,position:l="item-aligned",align:i="center"}=n,s=e(n,["className","children","position","align"]);return t(Fe,{children:r(Ue,Object.assign({"data-slot":"select-content",className:T("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===l&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",o),position:l,align:i},s,{children:[t(rt,{}),t(qe,Object.assign({className:T("p-1","popper"===l&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1")},{children:a})),t(ot,{})]}))})},lt=n=>{var{className:o,children:a}=n,l=e(n,["className","children"]);return r(Xe,Object.assign({"data-slot":"select-item",className:T("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",o)},l,{children:[t("span",Object.assign({"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center"},{children:t(Ze,{children:t(D,{className:"size-4"})})})),t(Ye,{children:a})]}))};export{Qe as S,nt as a,tt as b,at as c,lt as d,et as e,A as u};
|
|
1
|
+
import{_ as e}from"./_tslib-35bb891d.js";import{jsx as t,Fragment as n,jsxs as r}from"react/jsx-runtime";import*as o from"react";import*as a from"react-dom";import{c as l}from"./index-056e5c06.js";import{c as i,P as s,a as c,u as d}from"./index-17323747.js";import{c as u}from"./index-5b487f4e.js";import{c as p,u as f}from"./index-91a5b8d5.js";import{u as m}from"./index-13505606.js";import{c as h,A as v,D as g,C as w,a as y,R as b,P as x}from"./index-371259c9.js";import{h as S,u as C,R as _,F as N}from"./Combination-575d4475.js";import{u as R}from"./index-ce60ba41.js";import{u as P}from"./index-70f4e709.js";import{u as k}from"./index-ff0e3962.js";import{V as I}from"./index-1674c2c8.js";import{c as T}from"./utils-3345eade.js";import{C as E}from"./chevron-down-28dfb290.js";import{C as D}from"./check-06bd6a78.js";import{C as O}from"./chevron-up-9a13532e.js";function j(e){const t=o.forwardRef((e,t)=>{const{children:n,...r}=e;if(o.isValidElement(n)){const e=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;if(n)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n)return e.props.ref;return e.props.ref||e.ref}(n),a=function(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...e)=>{const t=a(...e);return o(...e),t}:o&&(n[r]=o):"style"===r?n[r]={...o,...a}:"className"===r&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}(r,n.props);return n.type!==o.Fragment&&(a.ref=t?p(t,e):e),o.cloneElement(n,a)}return o.Children.count(n)>1?o.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var M=Symbol("radix.slottable");function L(e){return o.isValidElement(e)&&"function"==typeof e.type&&"__radixId"in e.type&&e.type.__radixId===M}function A(e){const t=o.useRef({value:e,previous:e});return o.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var z=[" ","Enter","ArrowUp","ArrowDown"],V=[" ","Enter"],H="Select",[B,W,K]=u(H),[F,U]=i(H,[K,h]),q=h(),[$,X]=F(H),[Y,Z]=F(H),G=e=>{const{__scopeSelect:n,children:a,open:l,defaultOpen:i,onOpenChange:s,value:c,defaultValue:d,onValueChange:u,dir:p,name:f,autoComplete:h,disabled:v,required:g,form:w}=e,y=q(n),[x,S]=o.useState(null),[C,_]=o.useState(null),[N,P]=o.useState(!1),I=m(p),[T,E]=k({prop:l,defaultProp:i??!1,onChange:s,caller:H}),[D,O]=k({prop:c,defaultProp:d,onChange:u,caller:H}),j=o.useRef(null),M=!x||(w||!!x.closest("form")),[L,A]=o.useState(new Set),z=Array.from(L).map(e=>e.props.value).join(";");return t(b,{...y,children:r($,{required:g,scope:n,trigger:x,onTriggerChange:S,valueNode:C,onValueNodeChange:_,valueNodeHasChildren:N,onValueNodeHasChildrenChange:P,contentId:R(),value:D,onValueChange:O,open:T,onOpenChange:E,dir:I,triggerPointerDownPosRef:j,disabled:v,children:[t(B.Provider,{scope:n,children:t(Y,{scope:e.__scopeSelect,onNativeOptionAdd:o.useCallback(e=>{A(t=>new Set(t).add(e))},[]),onNativeOptionRemove:o.useCallback(e=>{A(t=>{const n=new Set(t);return n.delete(e),n})},[]),children:a})}),M?r(Le,{"aria-hidden":!0,required:g,tabIndex:-1,name:f,autoComplete:h,value:D,onChange:e=>O(e.target.value),disabled:v,form:w,children:[void 0===D?t("option",{value:""}):null,Array.from(L)]},z):null]})})};G.displayName=H;var J="SelectTrigger",Q=o.forwardRef((e,n)=>{const{__scopeSelect:r,disabled:a=!1,...l}=e,i=q(r),d=X(J,r),u=d.disabled||a,p=f(n,d.onTriggerChange),m=W(r),h=o.useRef("touch"),[g,w,y]=ze(e=>{const t=m().filter(e=>!e.disabled),n=t.find(e=>e.value===d.value),r=Ve(t,e,n);void 0!==r&&d.onValueChange(r.value)}),b=e=>{u||(d.onOpenChange(!0),y()),e&&(d.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})};return t(v,{asChild:!0,...i,children:t(s.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":Ae(d.value)?"":void 0,...l,ref:p,onClick:c(l.onClick,e=>{e.currentTarget.focus(),"mouse"!==h.current&&b(e)}),onPointerDown:c(l.onPointerDown,e=>{h.current=e.pointerType;const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),0===e.button&&!1===e.ctrlKey&&"mouse"===e.pointerType&&(b(e),e.preventDefault())}),onKeyDown:c(l.onKeyDown,e=>{const t=""!==g.current;e.ctrlKey||e.altKey||e.metaKey||1!==e.key.length||w(e.key),t&&" "===e.key||z.includes(e.key)&&(b(),e.preventDefault())})})})});Q.displayName=J;var ee="SelectValue",te=o.forwardRef((e,r)=>{const{__scopeSelect:o,className:a,style:l,children:i,placeholder:c="",...u}=e,p=X(ee,o),{onValueNodeHasChildrenChange:m}=p,h=void 0!==i,v=f(r,p.onValueNodeChange);return d(()=>{m(h)},[m,h]),t(s.span,{...u,ref:v,style:{pointerEvents:"none"},children:Ae(p.value)?t(n,{children:c}):i})});te.displayName=ee;var ne=o.forwardRef((e,n)=>{const{__scopeSelect:r,children:o,...a}=e;return t(s.span,{"aria-hidden":!0,...a,ref:n,children:o||"▼"})});ne.displayName="SelectIcon";var re=e=>t(x,{asChild:!0,...e});re.displayName="SelectPortal";var oe="SelectContent",ae=o.forwardRef((e,n)=>{const r=X(oe,e.__scopeSelect),[l,i]=o.useState();if(d(()=>{i(new DocumentFragment)},[]),!r.open){const n=l;return n?a.createPortal(t(ie,{scope:e.__scopeSelect,children:t(B.Slot,{scope:e.__scopeSelect,children:t("div",{children:e.children})})}),n):null}return t(de,{...e,ref:n})});ae.displayName=oe;var le=10,[ie,se]=F(oe),ce=function(e){const n=j(e),r=o.forwardRef((e,r)=>{const{children:a,...l}=e,i=o.Children.toArray(a),s=i.find(L);if(s){const e=s.props.children,a=i.map(t=>t===s?o.Children.count(e)>1?o.Children.only(null):o.isValidElement(e)?e.props.children:null:t);return t(n,{...l,ref:r,children:o.isValidElement(e)?o.cloneElement(e,void 0,a):null})}return t(n,{...l,ref:r,children:a})});return r.displayName=`${e}.Slot`,r}("SelectContent.RemoveScroll"),de=o.forwardRef((e,n)=>{const{__scopeSelect:r,position:a="item-aligned",onCloseAutoFocus:l,onEscapeKeyDown:i,onPointerDownOutside:s,side:d,sideOffset:u,align:p,alignOffset:m,arrowPadding:h,collisionBoundary:v,collisionPadding:w,sticky:y,hideWhenDetached:b,avoidCollisions:x,...R}=e,P=X(oe,r),[k,I]=o.useState(null),[T,E]=o.useState(null),D=f(n,e=>I(e)),[O,j]=o.useState(null),[M,L]=o.useState(null),A=W(r),[z,V]=o.useState(!1),H=o.useRef(!1);o.useEffect(()=>{if(k)return S(k)},[k]),C();const B=o.useCallback(e=>{const[t,...n]=A().map(e=>e.ref.current),[r]=n.slice(-1),o=document.activeElement;for(const n of e){if(n===o)return;if(n?.scrollIntoView({block:"nearest"}),n===t&&T&&(T.scrollTop=0),n===r&&T&&(T.scrollTop=T.scrollHeight),n?.focus(),document.activeElement!==o)return}},[A,T]),K=o.useCallback(()=>B([O,k]),[B,O,k]);o.useEffect(()=>{z&&K()},[z,K]);const{onOpenChange:F,triggerPointerDownPosRef:U}=P;o.useEffect(()=>{if(k){let e={x:0,y:0};const t=t=>{e={x:Math.abs(Math.round(t.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(U.current?.y??0))}},n=n=>{e.x<=10&&e.y<=10?n.preventDefault():k.contains(n.target)||F(!1),document.removeEventListener("pointermove",t),U.current=null};return null!==U.current&&(document.addEventListener("pointermove",t),document.addEventListener("pointerup",n,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",t),document.removeEventListener("pointerup",n,{capture:!0})}}},[k,F,U]),o.useEffect(()=>{const e=()=>F(!1);return window.addEventListener("blur",e),window.addEventListener("resize",e),()=>{window.removeEventListener("blur",e),window.removeEventListener("resize",e)}},[F]);const[q,$]=ze(e=>{const t=A().filter(e=>!e.disabled),n=t.find(e=>e.ref.current===document.activeElement),r=Ve(t,e,n);r&&setTimeout(()=>r.ref.current.focus())}),Y=o.useCallback((e,t,n)=>{const r=!H.current&&!n;(void 0!==P.value&&P.value===t||r)&&(j(e),r&&(H.current=!0))},[P.value]),Z=o.useCallback(()=>k?.focus(),[k]),G=o.useCallback((e,t,n)=>{const r=!H.current&&!n;(void 0!==P.value&&P.value===t||r)&&L(e)},[P.value]),J="popper"===a?pe:ue,Q=J===pe?{side:d,sideOffset:u,align:p,alignOffset:m,arrowPadding:h,collisionBoundary:v,collisionPadding:w,sticky:y,hideWhenDetached:b,avoidCollisions:x}:{};return t(ie,{scope:r,content:k,viewport:T,onViewportChange:E,itemRefCallback:Y,selectedItem:O,onItemLeave:Z,itemTextRefCallback:G,focusSelectedItem:K,selectedItemText:M,position:a,isPositioned:z,searchRef:q,children:t(_,{as:ce,allowPinchZoom:!0,children:t(N,{asChild:!0,trapped:P.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:c(l,e=>{P.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:t(g,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>P.onOpenChange(!1),children:t(J,{role:"listbox",id:P.contentId,"data-state":P.open?"open":"closed",dir:P.dir,onContextMenu:e=>e.preventDefault(),...R,...Q,onPlaced:()=>V(!0),ref:D,style:{display:"flex",flexDirection:"column",outline:"none",...R.style},onKeyDown:c(R.onKeyDown,e=>{const t=e.ctrlKey||e.altKey||e.metaKey;if("Tab"===e.key&&e.preventDefault(),t||1!==e.key.length||$(e.key),["ArrowUp","ArrowDown","Home","End"].includes(e.key)){let t=A().filter(e=>!e.disabled).map(e=>e.ref.current);if(["ArrowUp","End"].includes(e.key)&&(t=t.slice().reverse()),["ArrowUp","ArrowDown"].includes(e.key)){const n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>B(t)),e.preventDefault()}})})})})})})});de.displayName="SelectContentImpl";var ue=o.forwardRef((e,n)=>{const{__scopeSelect:r,onPlaced:a,...i}=e,c=X(oe,r),u=se(oe,r),[p,m]=o.useState(null),[h,v]=o.useState(null),g=f(n,e=>v(e)),w=W(r),y=o.useRef(!1),b=o.useRef(!0),{viewport:x,selectedItem:S,selectedItemText:C,focusSelectedItem:_}=u,N=o.useCallback(()=>{if(c.trigger&&c.valueNode&&p&&h&&x&&S&&C){const e=c.trigger.getBoundingClientRect(),t=h.getBoundingClientRect(),n=c.valueNode.getBoundingClientRect(),r=C.getBoundingClientRect();if("rtl"!==c.dir){const o=r.left-t.left,a=n.left-o,i=e.left-a,s=e.width+i,c=Math.max(s,t.width),d=window.innerWidth-le,u=l(a,[le,Math.max(le,d-c)]);p.style.minWidth=s+"px",p.style.left=u+"px"}else{const o=t.right-r.right,a=window.innerWidth-n.right-o,i=window.innerWidth-e.right-a,s=e.width+i,c=Math.max(s,t.width),d=window.innerWidth-le,u=l(a,[le,Math.max(le,d-c)]);p.style.minWidth=s+"px",p.style.right=u+"px"}const o=w(),i=window.innerHeight-2*le,s=x.scrollHeight,d=window.getComputedStyle(h),u=parseInt(d.borderTopWidth,10),f=parseInt(d.paddingTop,10),m=parseInt(d.borderBottomWidth,10),v=u+f+s+parseInt(d.paddingBottom,10)+m,g=Math.min(5*S.offsetHeight,v),b=window.getComputedStyle(x),_=parseInt(b.paddingTop,10),N=parseInt(b.paddingBottom,10),R=e.top+e.height/2-le,P=i-R,k=S.offsetHeight/2,I=u+f+(S.offsetTop+k),T=v-I;if(I<=R){const e=o.length>0&&S===o[o.length-1].ref.current;p.style.bottom="0px";const t=h.clientHeight-x.offsetTop-x.offsetHeight,n=I+Math.max(P,k+(e?N:0)+t+m);p.style.height=n+"px"}else{const e=o.length>0&&S===o[0].ref.current;p.style.top="0px";const t=Math.max(R,u+x.offsetTop+(e?_:0)+k)+T;p.style.height=t+"px",x.scrollTop=I-R+x.offsetTop}p.style.margin=`${le}px 0`,p.style.minHeight=g+"px",p.style.maxHeight=i+"px",a?.(),requestAnimationFrame(()=>y.current=!0)}},[w,c.trigger,c.valueNode,p,h,x,S,C,c.dir,a]);d(()=>N(),[N]);const[R,P]=o.useState();d(()=>{h&&P(window.getComputedStyle(h).zIndex)},[h]);const k=o.useCallback(e=>{e&&!0===b.current&&(N(),_?.(),b.current=!1)},[N,_]);return t(fe,{scope:r,contentWrapper:p,shouldExpandOnScrollRef:y,onScrollButtonChange:k,children:t("div",{ref:m,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:R},children:t(s.div,{...i,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})});ue.displayName="SelectItemAlignedPosition";var pe=o.forwardRef((e,n)=>{const{__scopeSelect:r,align:o="start",collisionPadding:a=le,...l}=e,i=q(r);return t(w,{...i,...l,ref:n,align:o,collisionPadding:a,style:{boxSizing:"border-box",...l.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});pe.displayName="SelectPopperPosition";var[fe,me]=F(oe,{}),he="SelectViewport",ve=o.forwardRef((e,a)=>{const{__scopeSelect:l,nonce:i,...d}=e,u=se(he,l),p=me(he,l),m=f(a,u.onViewportChange),h=o.useRef(0);return r(n,{children:[t("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),t(B.Slot,{scope:l,children:t(s.div,{"data-radix-select-viewport":"",role:"presentation",...d,ref:m,style:{position:"relative",flex:1,overflow:"hidden auto",...d.style},onScroll:c(d.onScroll,e=>{const t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=p;if(r?.current&&n){const e=Math.abs(h.current-t.scrollTop);if(e>0){const r=window.innerHeight-2*le,o=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),l=Math.max(o,a);if(l<r){const o=l+e,a=Math.min(r,o),i=o-a;n.style.height=a+"px","0px"===n.style.bottom&&(t.scrollTop=i>0?i:0,n.style.justifyContent="flex-end")}}}h.current=t.scrollTop})})})]})});ve.displayName=he;var ge="SelectGroup",[we,ye]=F(ge),be=o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e,a=R();return t(we,{scope:r,id:a,children:t(s.div,{role:"group","aria-labelledby":a,...o,ref:n})})});be.displayName=ge;var xe="SelectLabel";o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e,a=ye(xe,r);return t(s.div,{id:a.id,...o,ref:n})}).displayName=xe;var Se="SelectItem",[Ce,_e]=F(Se),Ne=o.forwardRef((e,n)=>{const{__scopeSelect:r,value:a,disabled:l=!1,textValue:i,...d}=e,u=X(Se,r),p=se(Se,r),m=u.value===a,[h,v]=o.useState(i??""),[g,w]=o.useState(!1),y=f(n,e=>p.itemRefCallback?.(e,a,l)),b=R(),x=o.useRef("touch"),S=()=>{l||(u.onValueChange(a),u.onOpenChange(!1))};if(""===a)throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t(Ce,{scope:r,value:a,disabled:l,textId:b,isSelected:m,onItemTextChange:o.useCallback(e=>{v(t=>t||(e?.textContent??"").trim())},[]),children:t(B.ItemSlot,{scope:r,value:a,disabled:l,textValue:h,children:t(s.div,{role:"option","aria-labelledby":b,"data-highlighted":g?"":void 0,"aria-selected":m&&g,"data-state":m?"checked":"unchecked","aria-disabled":l||void 0,"data-disabled":l?"":void 0,tabIndex:l?void 0:-1,...d,ref:y,onFocus:c(d.onFocus,()=>w(!0)),onBlur:c(d.onBlur,()=>w(!1)),onClick:c(d.onClick,()=>{"mouse"!==x.current&&S()}),onPointerUp:c(d.onPointerUp,()=>{"mouse"===x.current&&S()}),onPointerDown:c(d.onPointerDown,e=>{x.current=e.pointerType}),onPointerMove:c(d.onPointerMove,e=>{x.current=e.pointerType,l?p.onItemLeave?.():"mouse"===x.current&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:c(d.onPointerLeave,e=>{e.currentTarget===document.activeElement&&p.onItemLeave?.()}),onKeyDown:c(d.onKeyDown,e=>{""!==p.searchRef?.current&&" "===e.key||(V.includes(e.key)&&S()," "===e.key&&e.preventDefault())})})})})});Ne.displayName=Se;var Re="SelectItemText",Pe=o.forwardRef((e,l)=>{const{__scopeSelect:i,className:c,style:u,...p}=e,m=X(Re,i),h=se(Re,i),v=_e(Re,i),g=Z(Re,i),[w,y]=o.useState(null),b=f(l,e=>y(e),v.onItemTextChange,e=>h.itemTextRefCallback?.(e,v.value,v.disabled)),x=w?.textContent,S=o.useMemo(()=>t("option",{value:v.value,disabled:v.disabled,children:x},v.value),[v.disabled,v.value,x]),{onNativeOptionAdd:C,onNativeOptionRemove:_}=g;return d(()=>(C(S),()=>_(S)),[C,_,S]),r(n,{children:[t(s.span,{id:v.textId,...p,ref:b}),v.isSelected&&m.valueNode&&!m.valueNodeHasChildren?a.createPortal(p.children,m.valueNode):null]})});Pe.displayName=Re;var ke="SelectItemIndicator",Ie=o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e;return _e(ke,r).isSelected?t(s.span,{"aria-hidden":!0,...o,ref:n}):null});Ie.displayName=ke;var Te="SelectScrollUpButton",Ee=o.forwardRef((e,n)=>{const r=se(Te,e.__scopeSelect),a=me(Te,e.__scopeSelect),[l,i]=o.useState(!1),s=f(n,a.onScrollButtonChange);return d(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollTop>0;i(e)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),l?t(je,{...e,ref:s,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop-t.offsetHeight)}}):null});Ee.displayName=Te;var De="SelectScrollDownButton",Oe=o.forwardRef((e,n)=>{const r=se(De,e.__scopeSelect),a=me(De,e.__scopeSelect),[l,i]=o.useState(!1),s=f(n,a.onScrollButtonChange);return d(()=>{if(r.viewport&&r.isPositioned){let e=function(){const e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;i(n)};const t=r.viewport;return e(),t.addEventListener("scroll",e),()=>t.removeEventListener("scroll",e)}},[r.viewport,r.isPositioned]),l?t(je,{...e,ref:s,onAutoScroll:()=>{const{viewport:e,selectedItem:t}=r;e&&t&&(e.scrollTop=e.scrollTop+t.offsetHeight)}}):null});Oe.displayName=De;var je=o.forwardRef((e,n)=>{const{__scopeSelect:r,onAutoScroll:a,...l}=e,i=se("SelectScrollButton",r),u=o.useRef(null),p=W(r),f=o.useCallback(()=>{null!==u.current&&(window.clearInterval(u.current),u.current=null)},[]);return o.useEffect(()=>()=>f(),[f]),d(()=>{const e=p().find(e=>e.ref.current===document.activeElement);e?.ref.current?.scrollIntoView({block:"nearest"})},[p]),t(s.div,{"aria-hidden":!0,...l,ref:n,style:{flexShrink:0,...l.style},onPointerDown:c(l.onPointerDown,()=>{null===u.current&&(u.current=window.setInterval(a,50))}),onPointerMove:c(l.onPointerMove,()=>{i.onItemLeave?.(),null===u.current&&(u.current=window.setInterval(a,50))}),onPointerLeave:c(l.onPointerLeave,()=>{f()})})});o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e;return t(s.div,{"aria-hidden":!0,...o,ref:n})}).displayName="SelectSeparator";var Me="SelectArrow";o.forwardRef((e,n)=>{const{__scopeSelect:r,...o}=e,a=q(r),l=X(Me,r),i=se(Me,r);return l.open&&"popper"===i.position?t(y,{...a,...o,ref:n}):null}).displayName=Me;var Le=o.forwardRef(({__scopeSelect:e,value:n,...r},a)=>{const l=o.useRef(null),i=f(a,l),c=A(n);return o.useEffect(()=>{const e=l.current;if(!e)return;const t=window.HTMLSelectElement.prototype,r=Object.getOwnPropertyDescriptor(t,"value").set;if(c!==n&&r){const t=new Event("change",{bubbles:!0});r.call(e,n),e.dispatchEvent(t)}},[c,n]),t(s.select,{...r,style:{...I,...r.style},ref:i,defaultValue:n})});function Ae(e){return""===e||void 0===e}function ze(e){const t=P(e),n=o.useRef(""),r=o.useRef(0),a=o.useCallback(e=>{const o=n.current+e;t(o),function e(t){n.current=t,window.clearTimeout(r.current),""!==t&&(r.current=window.setTimeout(()=>e(""),1e3))}(o)},[t]),l=o.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return o.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,l]}function Ve(e,t,n){const r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,o=n?e.indexOf(n):-1;let a=(l=e,i=Math.max(o,0),l.map((e,t)=>l[(i+t)%l.length]));var l,i;1===r.length&&(a=a.filter(e=>e!==n));const s=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return s!==n?s:void 0}Le.displayName="SelectBubbleInput";var He=G,Be=Q,We=te,Ke=ne,Fe=re,Ue=ae,qe=ve,$e=be,Xe=Ne,Ye=Pe,Ze=Ie,Ge=Ee,Je=Oe;const Qe=n=>{var r=e(n,[]);return t(He,Object.assign({"data-slot":"select"},r))},et=n=>{var r=e(n,[]);return t($e,Object.assign({"data-slot":"select-group"},r))},tt=n=>{var r=e(n,[]);return t(We,Object.assign({"data-slot":"select-value"},r))},nt=n=>{var{className:o,size:a="default",children:l}=n,i=e(n,["className","size","children"]);return r(Be,Object.assign({"data-slot":"select-trigger","data-size":a,className:T("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",o)},i,{children:[l,t(Ke,Object.assign({asChild:!0},{children:t(E,{className:"size-4 opacity-50"})}))]}))},rt=n=>{var{className:r}=n,o=e(n,["className"]);return t(Ge,Object.assign({"data-slot":"select-scroll-up-button",className:T("flex cursor-default items-center justify-center py-1",r)},o,{children:t(O,{className:"size-4"})}))},ot=n=>{var{className:r}=n,o=e(n,["className"]);return t(Je,Object.assign({"data-slot":"select-scroll-down-button",className:T("flex cursor-default items-center justify-center py-1",r)},o,{children:t(E,{className:"size-4"})}))},at=n=>{var{className:o,children:a,position:l="item-aligned",align:i="center"}=n,s=e(n,["className","children","position","align"]);return t(Fe,{children:r(Ue,Object.assign({"data-slot":"select-content",className:T("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md","popper"===l&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",o),position:l,align:i},s,{children:[t(rt,{}),t(qe,Object.assign({className:T("p-1","popper"===l&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1")},{children:a})),t(ot,{})]}))})},lt=n=>{var{className:o,children:a}=n,l=e(n,["className","children"]);return r(Xe,Object.assign({"data-slot":"select-item",className:T("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",o)},l,{children:[t("span",Object.assign({"data-slot":"select-item-indicator",className:"absolute right-2 flex size-3.5 items-center justify-center"},{children:t(Ze,{children:t(D,{className:"size-4"})})})),t(Ye,{children:a})]}))};export{Qe as S,nt as a,tt as b,at as c,lt as d,et as e,A as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_ as r}from"./_tslib-35bb891d.js";import{jsx as o}from"react/jsx-runtime";import*as a from"react";import"react-dom";import{c as i}from"./index-a5cba5f7.js";import{c as e}from"./utils-3345eade.js";var t=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((r,e)=>{const t=i(`Primitive.${e}`),n=a.forwardRef((r,a)=>{const{asChild:i,...n}=r,s=i?t:e;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),o(s,{...n,ref:a})});return n.displayName=`Primitive.${e}`,{...r,[e]:n}},{}),n="horizontal",s=["horizontal","vertical"],l=a.forwardRef((r,a)=>{const{decorative:i,orientation:e=n,...l}=r,d=function(r){return s.includes(r)}(e)?e:n,m=i?{role:"none"}:{"aria-orientation":"vertical"===d?d:void 0,role:"separator"};return o(t.div,{"data-orientation":d,...m,...l,ref:a})});l.displayName="Separator";var d=l;const m=a.forwardRef((a,i)=>{var{className:t,orientation:n="horizontal",decorative:s=!0}=a,l=r(a,["className","orientation","decorative"]);return o(d,Object.assign({ref:i,decorative:s,orientation:n,className:e("shrink-0 bg-border","horizontal"===n?"h-[1px] w-full":"h-full w-[1px]",t)},l))});m.displayName=d.displayName;export{m as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./_tslib-35bb891d.js";import{jsx as a}from"react/jsx-runtime";import*as t from"react";import{c as i,P as n,a as r}from"./index-17323747.js";import{c as
|
|
1
|
+
import{_ as e}from"./_tslib-35bb891d.js";import{jsx as a}from"react/jsx-runtime";import*as t from"react";import{c as i,P as n,a as r}from"./index-17323747.js";import{c as s,R as o,I as d}from"./index-a77c7d53.js";import{P as l}from"./index-bd6363d4.js";import{u as c}from"./index-13505606.js";import{u}from"./index-ff0e3962.js";import{u as f}from"./index-ce60ba41.js";import{c as m}from"./utils-3345eade.js";var b="Tabs",[p,v]=i(b,[s]),g=s(),[y,h]=p(b),N=t.forwardRef((e,t)=>{const{__scopeTabs:i,value:r,onValueChange:s,defaultValue:o,orientation:d="horizontal",dir:l,activationMode:m="automatic",...p}=e,v=c(l),[g,h]=u({prop:r,onChange:s,defaultProp:o??"",caller:b});return a(y,{scope:i,baseId:f(),value:g,onValueChange:h,orientation:d,dir:v,activationMode:m,children:a(n.div,{dir:v,"data-orientation":d,...p,ref:t})})});N.displayName=b;var x="TabsList",j=t.forwardRef((e,t)=>{const{__scopeTabs:i,loop:r=!0,...s}=e,d=h(x,i),l=g(i);return a(o,{asChild:!0,...l,orientation:d.orientation,dir:d.dir,loop:r,children:a(n.div,{role:"tablist","aria-orientation":d.orientation,...s,ref:t})})});j.displayName=x;var w="TabsTrigger",T=t.forwardRef((e,t)=>{const{__scopeTabs:i,value:s,disabled:o=!1,...l}=e,c=h(w,i),u=g(i),f=R(c.baseId,s),m=I(c.baseId,s),b=s===c.value;return a(d,{asChild:!0,...u,focusable:!o,active:b,children:a(n.button,{type:"button",role:"tab","aria-selected":b,"aria-controls":m,"data-state":b?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:f,...l,ref:t,onMouseDown:r(e.onMouseDown,e=>{o||0!==e.button||!1!==e.ctrlKey?e.preventDefault():c.onValueChange(s)}),onKeyDown:r(e.onKeyDown,e=>{[" ","Enter"].includes(e.key)&&c.onValueChange(s)}),onFocus:r(e.onFocus,()=>{const e="manual"!==c.activationMode;b||o||!e||c.onValueChange(s)})})})});T.displayName=w;var _="TabsContent",C=t.forwardRef((e,i)=>{const{__scopeTabs:r,value:s,forceMount:o,children:d,...c}=e,u=h(_,r),f=R(u.baseId,s),m=I(u.baseId,s),b=s===u.value,p=t.useRef(b);return t.useEffect(()=>{const e=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(e)},[]),a(l,{present:o||b,children:({present:t})=>a(n.div,{"data-state":b?"active":"inactive","data-orientation":u.orientation,role:"tabpanel","aria-labelledby":f,hidden:!t,id:m,tabIndex:0,...c,ref:i,style:{...e.style,animationDuration:p.current?"0s":void 0},children:t&&d})})});function R(e,a){return`${e}-trigger-${a}`}function I(e,a){return`${e}-content-${a}`}C.displayName=_;var D=j,M=T,V=C;const k=N,F=t.forwardRef((t,i)=>{var{className:n}=t,r=e(t,["className"]);return a(D,Object.assign({ref:i,className:m("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",n)},r))});F.displayName=D.displayName;const $=t.forwardRef((t,i)=>{var{className:n}=t,r=e(t,["className"]);return a(M,Object.assign({ref:i,className:m("inline-flex items-center justify-center rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",n)},r))});$.displayName=M.displayName;const K=t.forwardRef((t,i)=>{var{className:n}=t,r=e(t,["className"]);return a(V,Object.assign({ref:i,className:m("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n)},r))});K.displayName=V.displayName;export{k as T,K as a,$ as b,F as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as e}from"./createLucideIcon-8605f860.js";import*as t from"react";import{useLayoutEffect as n,useEffect as r}from"react";import{i as o,u as i,d as a,c as l,A as s,D as u,C as c,a as d,R as f,P as p}from"./index-
|
|
1
|
+
import{c as e}from"./createLucideIcon-8605f860.js";import*as t from"react";import{useLayoutEffect as n,useEffect as r}from"react";import{i as o,u as i,d as a,c as l,A as s,D as u,C as c,a as d,R as f,P as p}from"./index-371259c9.js";import*as m from"react-dom";import{_ as v}from"./_tslib-35bb891d.js";import{jsx as h,Fragment as g,jsxs as y}from"react/jsx-runtime";import{c as b,P as x,a as w}from"./index-17323747.js";import{u as E}from"./index-91a5b8d5.js";import{u as R}from"./index-ce60ba41.js";import{P as C}from"./index-bd6363d4.js";import{u as T}from"./index-ff0e3962.js";import{R as S}from"./index-1674c2c8.js";import{c as O}from"./utils-3345eade.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.294.0 - ISC
|
|
4
4
|
*
|
|
@@ -9,4 +9,4 @@ import{c as e}from"./createLucideIcon-8605f860.js";import*as t from"react";impor
|
|
|
9
9
|
* tabbable 6.4.0
|
|
10
10
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
11
11
|
*/
|
|
12
|
-
var I=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"].join(","),N="undefined"==typeof Element,D=N?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,P=!N&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},L=function(e,t){var n;void 0===t&&(t=!0);var r=null==e||null===(n=e.getAttribute)||void 0===n?void 0:n.call(e,"inert");return""===r||"true"===r||t&&e&&("function"==typeof e.closest?e.closest("[inert]"):L(e.parentNode))},M=function(e,t,n){for(var r=[],o=Array.from(e);o.length;){var i=o.shift();if(!L(i,!1))if("SLOT"===i.tagName){var a=i.assignedElements(),l=a.length?a:i.children,s=M(l,!0,n);n.flatten?r.push.apply(r,s):r.push({scopeParent:i,candidates:s})}else{D.call(i,I)&&n.filter(i)&&(t||!e.includes(i))&&r.push(i);var u=i.shadowRoot||"function"==typeof n.getShadowRoot&&n.getShadowRoot(i),c=!L(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(i));if(u&&c){var d=M(!0===u?i.children:u.children,!0,n);n.flatten?r.push.apply(r,d):r.push({scopeParent:i,candidates:d})}else o.unshift.apply(o,i.children)}}return r},A=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},_=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!A(e)?0:e.tabIndex},j=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},F=function(e){return"INPUT"===e.tagName},B=function(e){return function(e){return F(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||P(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var o=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!o||o===e}(e)},z=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},H=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("full-native"===n&&"checkVisibility"in e)return!e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});if("hidden"===getComputedStyle(e).visibility)return!0;var o=D.call(e,"details>summary:first-of-type")?e.parentElement:e;if(D.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"full-native"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return z(e)}else{if("function"==typeof r){for(var i=e;e;){var a=e.parentElement,l=P(e);if(a&&!a.shadowRoot&&!0===r(a))return z(e);e=e.assignedSlot?e.assignedSlot:a||l===e.ownerDocument?a:l.host}e=i}if(function(e){var t,n,r,o,i=e&&P(e),a=null===(t=i)||void 0===t?void 0:t.host,l=!1;if(i&&i!==e)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(a)||null!=e&&null!==(o=e.ownerDocument)&&void 0!==o&&o.contains(e));!l&&a;){var s,u,c;l=!(null===(u=a=null===(s=i=P(a))||void 0===s?void 0:s.host)||void 0===u||null===(c=u.ownerDocument)||void 0===c||!c.contains(a))}return l}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},q=function(e,t){return!(t.disabled||function(e){return F(e)&&"hidden"===e.type}(t)||H(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!D.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},U=function(e,t){return!(B(t)||_(t)<0||!q(e,t))},V=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},X=function(e){var t=[],n=[];return e.forEach(function(e,r){var o=!!e.scopeParent,i=o?e.scopeParent:e,a=function(e,t){var n=_(e);return n<0&&t&&!A(e)?0:n}(i,o),l=o?X(e.candidates):i;0===a?o?t.push.apply(t,l):t.push(i):n.push({documentOrder:r,tabIndex:a,item:e,isScope:o,content:l})}),n.sort(j).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(t)},Y=function(e,t){var n;return n=(t=t||{}).getShadowRoot?M([e],t.includeContainer,{filter:U.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:V}):function(e,t,n){if(L(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(I));return t&&D.call(e,I)&&r.unshift(e),r.filter(n)}(e,t.includeContainer,U.bind(null,t)),X(n)};const $={...t},K=$.useInsertionEffect||(e=>e());var G="undefined"!=typeof document?n:r;function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(this,arguments)}let Q=!1,W=0;const Z=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+W++;const ee=$.useId||function(){const[e,n]=t.useState(()=>Q?Z():void 0);return G(()=>{null==e&&n(Z())},[]),t.useEffect(()=>{Q=!0},[]),e};const te=t.createContext(null),ne=t.createContext(null);function re(e){return"data-floating-ui-"+e}const oe=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function ie(e,t){const n=Y(e,oe());"prev"===t&&n.reverse();const r=n.indexOf(function(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(n=n.shadowRoot)?void 0:n.activeElement);){var n;t=t.shadowRoot.activeElement}return t}((null==(o=e)?void 0:o.ownerDocument)||document));var o;return n.slice(r+1)[0]}function ae(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!function(e,t){if(!e||!t)return!1;const n=null==t.getRootNode?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&o(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}(n,r)}function le(e){Y(e,oe()).forEach(e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")})}function se(e){e.querySelectorAll("[data-tabindex]").forEach(e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")})}const ue={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0};function ce(e){"Tab"===e.key&&(e.target,clearTimeout(void 0))}const de=t.forwardRef(function(e,n){const[r,o]=t.useState();G(()=>(/apple/i.test(navigator.vendor)&&o("button"),document.addEventListener("keydown",ce),()=>{document.removeEventListener("keydown",ce)}),[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":!r||void 0,[re("focus-guard")]:"",style:ue};return t.createElement("span",J({},e,i))}),fe=t.createContext(null),pe=re("portal");function me(e){const{children:n,id:r,root:o,preserveTabOrder:i=!0}=e,l=function(e){void 0===e&&(e={});const{id:n,root:r}=e,o=ee(),i=ve(),[l,s]=t.useState(null),u=t.useRef(null);return G(()=>()=>{null==l||l.remove(),queueMicrotask(()=>{u.current=null})},[l]),G(()=>{if(!o)return;if(u.current)return;const e=n?document.getElementById(n):null;if(!e)return;const t=document.createElement("div");t.id=o,t.setAttribute(pe,""),e.appendChild(t),u.current=t,s(t)},[n,o]),G(()=>{if(null===r)return;if(!o)return;if(u.current)return;let e=r||(null==i?void 0:i.portalNode);e&&!a(e)&&(e=e.current),e=e||document.body;let t=null;n&&(t=document.createElement("div"),t.id=n,e.appendChild(t));const l=document.createElement("div");l.id=o,l.setAttribute(pe,""),e=t||e,e.appendChild(l),u.current=l,s(l)},[n,r,o,i]),l}({id:r,root:o}),[s,u]=t.useState(null),c=t.useRef(null),d=t.useRef(null),f=t.useRef(null),p=t.useRef(null),v=null==s?void 0:s.modal,h=null==s?void 0:s.open,g=!!s&&!s.modal&&s.open&&i&&!(!o&&!l);return t.useEffect(()=>{if(l&&i&&!v)return l.addEventListener("focusin",e,!0),l.addEventListener("focusout",e,!0),()=>{l.removeEventListener("focusin",e,!0),l.removeEventListener("focusout",e,!0)};function e(e){if(l&&ae(e)){("focusin"===e.type?se:le)(l)}}},[l,i,v]),t.useEffect(()=>{l&&(h||se(l))},[h,l]),t.createElement(fe.Provider,{value:t.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:f,afterInsideRef:p,portalNode:l,setFocusManagerState:u}),[i,l])},g&&l&&t.createElement(de,{"data-type":"outside",ref:c,onFocus:e=>{if(ae(e,l)){var t;null==(t=f.current)||t.focus()}else{const e=ie(document.body,"prev")||(null==s?void 0:s.refs.domReference.current);null==e||e.focus()}}}),g&&l&&t.createElement("span",{"aria-owns":l.id,style:ue}),l&&m.createPortal(n,l),g&&l&&t.createElement(de,{"data-type":"outside",ref:d,onFocus:e=>{if(ae(e,l)){var t;null==(t=p.current)||t.focus()}else{const t=ie(document.body,"next")||(null==s?void 0:s.refs.domReference.current);null==t||t.focus(),(null==s?void 0:s.closeOnFocusOut)&&(null==s||s.onOpenChange(!1,e.nativeEvent,"focus-out"))}}}))}const ve=()=>t.useContext(fe);function he(e){const{open:n=!1,onOpenChange:r,elements:o}=e,i=ee(),a=t.useRef({}),[l]=t.useState(()=>function(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach(e=>e(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,(null==(r=e.get(t))?void 0:r.filter(e=>e!==n))||[])}}}()),s=null!=((null==(u=t.useContext(te))?void 0:u.id)||null);var u;const[c,d]=t.useState(o.reference),f=function(e){const n=t.useRef(()=>{});return K(()=>{n.current=e}),t.useCallback(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return null==n.current?void 0:n.current(...t)},[])}((e,t,n)=>{a.current.openEvent=e?t:void 0,l.emit("openchange",{open:e,event:t,reason:n,nested:s}),null==r||r(e,t,n)}),p=t.useMemo(()=>({setPositionReference:d}),[]),m=t.useMemo(()=>({reference:c||o.reference||null,floating:o.floating||null,domReference:o.reference}),[c,o.reference,o.floating]);return t.useMemo(()=>({dataRef:a,open:n,onOpenChange:f,elements:m,events:l,floatingId:i,refs:p}),[n,f,m,l,i,p])}function ge(e){void 0===e&&(e={});const{nodeId:n}=e,r=he({...e,elements:{reference:null,floating:null,...e.elements}}),o=e.rootContext||r,l=o.elements,[s,u]=t.useState(null),[c,d]=t.useState(null),f=(null==l?void 0:l.domReference)||s,p=t.useRef(null),m=t.useContext(ne);G(()=>{f&&(p.current=f)},[f]);const v=i({...e,elements:{...l,...c&&{reference:c}}}),h=t.useCallback(e=>{const t=a(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;d(t),v.refs.setReference(t)},[v.refs]),g=t.useCallback(e=>{(a(e)||null===e)&&(p.current=e,u(e)),(a(v.refs.reference.current)||null===v.refs.reference.current||null!==e&&!a(e))&&v.refs.setReference(e)},[v.refs]),y=t.useMemo(()=>({...v.refs,setReference:g,setPositionReference:h,domReference:p}),[v.refs,g,h]),b=t.useMemo(()=>({...v.elements,domReference:f}),[v.elements,f]),x=t.useMemo(()=>({...v,...o,refs:y,elements:b,nodeId:n}),[v,y,b,n,o]);return G(()=>{o.dataRef.current.floatingContext=x;const e=null==m?void 0:m.nodesRef.current.find(e=>e.id===n);e&&(e.context=x)}),t.useMemo(()=>({...v,context:x,refs:y,elements:b}),[v,y,b,x])}var ye=Symbol("radix.slottable");var[be,xe]=b("Tooltip",[l]),we=l(),Ee="TooltipProvider",Re=700,Ce="tooltip.open",[Te,Se]=be(Ee),Oe=e=>{const{__scopeTooltip:n,delayDuration:r=Re,skipDelayDuration:o=300,disableHoverableContent:i=!1,children:a}=e,l=t.useRef(!0),s=t.useRef(!1),u=t.useRef(0);return t.useEffect(()=>{const e=u.current;return()=>window.clearTimeout(e)},[]),h(Te,{scope:n,isOpenDelayedRef:l,delayDuration:r,onOpen:t.useCallback(()=>{window.clearTimeout(u.current),l.current=!1},[]),onClose:t.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>l.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:t.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Oe.displayName=Ee;var ke="Tooltip",[Ie,Ne]=be(ke),De=e=>{const{__scopeTooltip:n,children:r,open:o,defaultOpen:i,onOpenChange:a,disableHoverableContent:l,delayDuration:s}=e,u=Se(ke,e.__scopeTooltip),c=we(n),[d,p]=t.useState(null),m=R(),v=t.useRef(0),g=l??u.disableHoverableContent,y=s??u.delayDuration,b=t.useRef(!1),[x,w]=T({prop:o,defaultProp:i??!1,onChange:e=>{e?(u.onOpen(),document.dispatchEvent(new CustomEvent(Ce))):u.onClose(),a?.(e)},caller:ke}),E=t.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),C=t.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,w(!0)},[w]),S=t.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w(!1)},[w]),O=t.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,w(!0),v.current=0},y)},[y,w]);return t.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),h(f,{...c,children:h(Ie,{scope:n,contentId:m,open:x,stateAttribute:E,trigger:d,onTriggerChange:p,onTriggerEnter:t.useCallback(()=>{u.isOpenDelayedRef.current?O():C()},[u.isOpenDelayedRef,O,C]),onTriggerLeave:t.useCallback(()=>{g?S():(window.clearTimeout(v.current),v.current=0)},[S,g]),onOpen:C,onClose:S,disableHoverableContent:g,children:r})})};De.displayName=ke;var Pe="TooltipTrigger",Le=t.forwardRef((e,n)=>{const{__scopeTooltip:r,...o}=e,i=Ne(Pe,r),a=Se(Pe,r),l=we(r),u=t.useRef(null),c=E(n,u,i.onTriggerChange),d=t.useRef(!1),f=t.useRef(!1),p=t.useCallback(()=>d.current=!1,[]);return t.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),h(s,{asChild:!0,...l,children:h(x.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...o,ref:c,onPointerMove:w(e.onPointerMove,e=>{"touch"!==e.pointerType&&(f.current||a.isPointerInTransitRef.current||(i.onTriggerEnter(),f.current=!0))}),onPointerLeave:w(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:w(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:w(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:w(e.onBlur,i.onClose),onClick:w(e.onClick,i.onClose)})})});Le.displayName=Pe;var Me="TooltipPortal",[Ae,_e]=be(Me,{forceMount:void 0}),je=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Ne(Me,t);return h(Ae,{scope:t,forceMount:n,children:h(C,{present:n||i.open,children:h(p,{asChild:!0,container:o,children:r})})})};je.displayName=Me;var Fe="TooltipContent",Be=t.forwardRef((e,t)=>{const n=_e(Fe,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Ne(Fe,e.__scopeTooltip);return h(C,{present:r||a.open,children:a.disableHoverableContent?h(Ve,{side:o,...i,ref:t}):h(ze,{side:o,...i,ref:t})})}),ze=t.forwardRef((e,n)=>{const r=Ne(Fe,e.__scopeTooltip),o=Se(Fe,e.__scopeTooltip),i=t.useRef(null),a=E(n,i),[l,s]=t.useState(null),{trigger:u,onClose:c}=r,d=i.current,{onPointerInTransitChange:f}=o,p=t.useCallback(()=>{s(null),f(!1)},[f]),m=t.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect())),i=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...function(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}(t.getBoundingClientRect())]);s(i),f(!0)},[f]);return t.useEffect(()=>()=>p(),[p]),t.useEffect(()=>{if(u&&d){const e=e=>m(e,d),t=e=>m(e,u);return u.addEventListener("pointerleave",e),d.addEventListener("pointerleave",t),()=>{u.removeEventListener("pointerleave",e),d.removeEventListener("pointerleave",t)}}},[u,d,m,p]),t.useEffect(()=>{if(l){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=u?.contains(t)||d?.contains(t),o=!function(e,t){const{x:n,y:r}=e;let o=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){const a=t[e],l=t[i],s=a.x,u=a.y,c=l.x,d=l.y;u>r!=d>r&&n<(c-s)*(r-u)/(d-u)+s&&(o=!o)}return o}(n,l);r?p():o&&(p(),c())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[u,d,l,c,p]),h(Ve,{...e,ref:a})}),[He,qe]=be(ke,{isInside:!1}),Ue=function(e){const t=({children:e})=>h(g,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=ye,t}("TooltipContent"),Ve=t.forwardRef((e,n)=>{const{__scopeTooltip:r,children:o,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:l,...s}=e,d=Ne(Fe,r),f=we(r),{onClose:p}=d;return t.useEffect(()=>(document.addEventListener(Ce,p),()=>document.removeEventListener(Ce,p)),[p]),t.useEffect(()=>{if(d.trigger){const e=e=>{const t=e.target;t?.contains(d.trigger)&&p()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[d.trigger,p]),h(u,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:y(c,{"data-state":d.stateAttribute,...f,...s,ref:n,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h(Ue,{children:o}),h(He,{scope:r,isInside:!0,children:h(S,{id:d.contentId,role:"tooltip",children:i||o})})]})})});Be.displayName=Fe;var Xe="TooltipArrow",Ye=t.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=we(n);return qe(Xe,n).isInside?null:h(d,{...o,...r,ref:t})});Ye.displayName=Xe;var $e=Oe,Ke=De,Ge=Le,Je=je,Qe=Be,We=Ye;const Ze=e=>{var{delayDuration:t=0}=e,n=v(e,["delayDuration"]);return h($e,Object.assign({"data-slot":"tooltip-provider",delayDuration:t},n))},et=e=>{var t=v(e,[]);return h(Ze,{children:h(Ke,Object.assign({"data-slot":"tooltip"},t))})},tt=e=>{var t=v(e,[]);return h(Ge,Object.assign({"data-slot":"tooltip-trigger"},t))},nt=e=>{var{className:t,sideOffset:n=0,children:r}=e,o=v(e,["className","sideOffset","children"]);return h(Je,{children:y(Qe,Object.assign({"data-slot":"tooltip-content",sideOffset:n,className:O("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t)},o,{children:[r,h(We,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]}))})};export{me as F,k as R,Ze as T,et as a,tt as b,nt as c,ge as u};
|
|
12
|
+
var I=["input:not([inert]):not([inert] *)","select:not([inert]):not([inert] *)","textarea:not([inert]):not([inert] *)","a[href]:not([inert]):not([inert] *)","button:not([inert]):not([inert] *)","[tabindex]:not(slot):not([inert]):not([inert] *)","audio[controls]:not([inert]):not([inert] *)","video[controls]:not([inert]):not([inert] *)",'[contenteditable]:not([contenteditable="false"]):not([inert]):not([inert] *)',"details>summary:first-of-type:not([inert]):not([inert] *)","details:not([inert]):not([inert] *)"].join(","),N="undefined"==typeof Element,D=N?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,P=!N&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},L=function(e,t){var n;void 0===t&&(t=!0);var r=null==e||null===(n=e.getAttribute)||void 0===n?void 0:n.call(e,"inert");return""===r||"true"===r||t&&e&&("function"==typeof e.closest?e.closest("[inert]"):L(e.parentNode))},M=function(e,t,n){for(var r=[],o=Array.from(e);o.length;){var i=o.shift();if(!L(i,!1))if("SLOT"===i.tagName){var a=i.assignedElements(),l=a.length?a:i.children,s=M(l,!0,n);n.flatten?r.push.apply(r,s):r.push({scopeParent:i,candidates:s})}else{D.call(i,I)&&n.filter(i)&&(t||!e.includes(i))&&r.push(i);var u=i.shadowRoot||"function"==typeof n.getShadowRoot&&n.getShadowRoot(i),c=!L(u,!1)&&(!n.shadowRootFilter||n.shadowRootFilter(i));if(u&&c){var d=M(!0===u?i.children:u.children,!0,n);n.flatten?r.push.apply(r,d):r.push({scopeParent:i,candidates:d})}else o.unshift.apply(o,i.children)}}return r},A=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},_=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!A(e)?0:e.tabIndex},j=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},F=function(e){return"INPUT"===e.tagName},z=function(e){return function(e){return F(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||P(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var o=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!o||o===e}(e)},B=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},H=function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("full-native"===n&&"checkVisibility"in e)return!e.checkVisibility({checkOpacity:!1,opacityProperty:!1,contentVisibilityAuto:!0,visibilityProperty:!0,checkVisibilityCSS:!0});if("hidden"===getComputedStyle(e).visibility)return!0;var o=D.call(e,"details>summary:first-of-type")?e.parentElement:e;if(D.call(o,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"full-native"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return B(e)}else{if("function"==typeof r){for(var i=e;e;){var a=e.parentElement,l=P(e);if(a&&!a.shadowRoot&&!0===r(a))return B(e);e=e.assignedSlot?e.assignedSlot:a||l===e.ownerDocument?a:l.host}e=i}if(function(e){var t,n,r,o,i=e&&P(e),a=null===(t=i)||void 0===t?void 0:t.host,l=!1;if(i&&i!==e)for(l=!!(null!==(n=a)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(a)||null!=e&&null!==(o=e.ownerDocument)&&void 0!==o&&o.contains(e));!l&&a;){var s,u,c;l=!(null===(u=a=null===(s=i=P(a))||void 0===s?void 0:s.host)||void 0===u||null===(c=u.ownerDocument)||void 0===c||!c.contains(a))}return l}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1},q=function(e,t){return!(t.disabled||function(e){return F(e)&&"hidden"===e.type}(t)||H(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some(function(e){return"SUMMARY"===e.tagName})}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!D.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},U=function(e,t){return!(z(t)||_(t)<0||!q(e,t))},V=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},X=function(e){var t=[],n=[];return e.forEach(function(e,r){var o=!!e.scopeParent,i=o?e.scopeParent:e,a=function(e,t){var n=_(e);return n<0&&t&&!A(e)?0:n}(i,o),l=o?X(e.candidates):i;0===a?o?t.push.apply(t,l):t.push(i):n.push({documentOrder:r,tabIndex:a,item:e,isScope:o,content:l})}),n.sort(j).reduce(function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e},[]).concat(t)},Y=function(e,t){var n;return n=(t=t||{}).getShadowRoot?M([e],t.includeContainer,{filter:U.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:V}):function(e,t,n){if(L(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(I));return t&&D.call(e,I)&&r.unshift(e),r.filter(n)}(e,t.includeContainer,U.bind(null,t)),X(n)};const $={...t},K=$.useInsertionEffect||(e=>e());var G="undefined"!=typeof document?n:r;function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(this,arguments)}let Q=!1,W=0;const Z=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+W++;const ee=$.useId||function(){const[e,n]=t.useState(()=>Q?Z():void 0);return G(()=>{null==e&&n(Z())},[]),t.useEffect(()=>{Q=!0},[]),e};const te=t.createContext(null),ne=t.createContext(null);function re(e){return"data-floating-ui-"+e}const oe=()=>({getShadowRoot:!0,displayCheck:"function"==typeof ResizeObserver&&ResizeObserver.toString().includes("[native code]")?"full":"none"});function ie(e,t){const n=Y(e,oe());"prev"===t&&n.reverse();const r=n.indexOf(function(e){let t=e.activeElement;for(;null!=(null==(n=t)||null==(n=n.shadowRoot)?void 0:n.activeElement);){var n;t=t.shadowRoot.activeElement}return t}((null==(o=e)?void 0:o.ownerDocument)||document));var o;return n.slice(r+1)[0]}function ae(e,t){const n=t||e.currentTarget,r=e.relatedTarget;return!r||!function(e,t){if(!e||!t)return!1;const n=null==t.getRootNode?void 0:t.getRootNode();if(e.contains(t))return!0;if(n&&o(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}(n,r)}function le(e){Y(e,oe()).forEach(e=>{e.dataset.tabindex=e.getAttribute("tabindex")||"",e.setAttribute("tabindex","-1")})}function se(e){e.querySelectorAll("[data-tabindex]").forEach(e=>{const t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute("tabindex",t):e.removeAttribute("tabindex")})}const ue={border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"fixed",whiteSpace:"nowrap",width:"1px",top:0,left:0};function ce(e){"Tab"===e.key&&(e.target,clearTimeout(void 0))}const de=t.forwardRef(function(e,n){const[r,o]=t.useState();G(()=>(/apple/i.test(navigator.vendor)&&o("button"),document.addEventListener("keydown",ce),()=>{document.removeEventListener("keydown",ce)}),[]);const i={ref:n,tabIndex:0,role:r,"aria-hidden":!r||void 0,[re("focus-guard")]:"",style:ue};return t.createElement("span",J({},e,i))}),fe=t.createContext(null),pe=re("portal");function me(e){const{children:n,id:r,root:o,preserveTabOrder:i=!0}=e,l=function(e){void 0===e&&(e={});const{id:n,root:r}=e,o=ee(),i=ve(),[l,s]=t.useState(null),u=t.useRef(null);return G(()=>()=>{null==l||l.remove(),queueMicrotask(()=>{u.current=null})},[l]),G(()=>{if(!o)return;if(u.current)return;const e=n?document.getElementById(n):null;if(!e)return;const t=document.createElement("div");t.id=o,t.setAttribute(pe,""),e.appendChild(t),u.current=t,s(t)},[n,o]),G(()=>{if(null===r)return;if(!o)return;if(u.current)return;let e=r||(null==i?void 0:i.portalNode);e&&!a(e)&&(e=e.current),e=e||document.body;let t=null;n&&(t=document.createElement("div"),t.id=n,e.appendChild(t));const l=document.createElement("div");l.id=o,l.setAttribute(pe,""),e=t||e,e.appendChild(l),u.current=l,s(l)},[n,r,o,i]),l}({id:r,root:o}),[s,u]=t.useState(null),c=t.useRef(null),d=t.useRef(null),f=t.useRef(null),p=t.useRef(null),v=null==s?void 0:s.modal,h=null==s?void 0:s.open,g=!!s&&!s.modal&&s.open&&i&&!(!o&&!l);return t.useEffect(()=>{if(l&&i&&!v)return l.addEventListener("focusin",e,!0),l.addEventListener("focusout",e,!0),()=>{l.removeEventListener("focusin",e,!0),l.removeEventListener("focusout",e,!0)};function e(e){if(l&&ae(e)){("focusin"===e.type?se:le)(l)}}},[l,i,v]),t.useEffect(()=>{l&&(h||se(l))},[h,l]),t.createElement(fe.Provider,{value:t.useMemo(()=>({preserveTabOrder:i,beforeOutsideRef:c,afterOutsideRef:d,beforeInsideRef:f,afterInsideRef:p,portalNode:l,setFocusManagerState:u}),[i,l])},g&&l&&t.createElement(de,{"data-type":"outside",ref:c,onFocus:e=>{if(ae(e,l)){var t;null==(t=f.current)||t.focus()}else{const e=ie(document.body,"prev")||(null==s?void 0:s.refs.domReference.current);null==e||e.focus()}}}),g&&l&&t.createElement("span",{"aria-owns":l.id,style:ue}),l&&m.createPortal(n,l),g&&l&&t.createElement(de,{"data-type":"outside",ref:d,onFocus:e=>{if(ae(e,l)){var t;null==(t=p.current)||t.focus()}else{const t=ie(document.body,"next")||(null==s?void 0:s.refs.domReference.current);null==t||t.focus(),(null==s?void 0:s.closeOnFocusOut)&&(null==s||s.onOpenChange(!1,e.nativeEvent,"focus-out"))}}}))}const ve=()=>t.useContext(fe);function he(e){const{open:n=!1,onOpenChange:r,elements:o}=e,i=ee(),a=t.useRef({}),[l]=t.useState(()=>function(){const e=new Map;return{emit(t,n){var r;null==(r=e.get(t))||r.forEach(e=>e(n))},on(t,n){e.set(t,[...e.get(t)||[],n])},off(t,n){var r;e.set(t,(null==(r=e.get(t))?void 0:r.filter(e=>e!==n))||[])}}}()),s=null!=((null==(u=t.useContext(te))?void 0:u.id)||null);var u;const[c,d]=t.useState(o.reference),f=function(e){const n=t.useRef(()=>{});return K(()=>{n.current=e}),t.useCallback(function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return null==n.current?void 0:n.current(...t)},[])}((e,t,n)=>{a.current.openEvent=e?t:void 0,l.emit("openchange",{open:e,event:t,reason:n,nested:s}),null==r||r(e,t,n)}),p=t.useMemo(()=>({setPositionReference:d}),[]),m=t.useMemo(()=>({reference:c||o.reference||null,floating:o.floating||null,domReference:o.reference}),[c,o.reference,o.floating]);return t.useMemo(()=>({dataRef:a,open:n,onOpenChange:f,elements:m,events:l,floatingId:i,refs:p}),[n,f,m,l,i,p])}function ge(e){void 0===e&&(e={});const{nodeId:n}=e,r=he({...e,elements:{reference:null,floating:null,...e.elements}}),o=e.rootContext||r,l=o.elements,[s,u]=t.useState(null),[c,d]=t.useState(null),f=(null==l?void 0:l.domReference)||s,p=t.useRef(null),m=t.useContext(ne);G(()=>{f&&(p.current=f)},[f]);const v=i({...e,elements:{...l,...c&&{reference:c}}}),h=t.useCallback(e=>{const t=a(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),contextElement:e}:e;d(t),v.refs.setReference(t)},[v.refs]),g=t.useCallback(e=>{(a(e)||null===e)&&(p.current=e,u(e)),(a(v.refs.reference.current)||null===v.refs.reference.current||null!==e&&!a(e))&&v.refs.setReference(e)},[v.refs]),y=t.useMemo(()=>({...v.refs,setReference:g,setPositionReference:h,domReference:p}),[v.refs,g,h]),b=t.useMemo(()=>({...v.elements,domReference:f}),[v.elements,f]),x=t.useMemo(()=>({...v,...o,refs:y,elements:b,nodeId:n}),[v,y,b,n,o]);return G(()=>{o.dataRef.current.floatingContext=x;const e=null==m?void 0:m.nodesRef.current.find(e=>e.id===n);e&&(e.context=x)}),t.useMemo(()=>({...v,context:x,refs:y,elements:b}),[v,y,b,x])}var ye=Symbol("radix.slottable");var[be,xe]=b("Tooltip",[l]),we=l(),Ee="TooltipProvider",Re=700,Ce="tooltip.open",[Te,Se]=be(Ee),Oe=e=>{const{__scopeTooltip:n,delayDuration:r=Re,skipDelayDuration:o=300,disableHoverableContent:i=!1,children:a}=e,l=t.useRef(!0),s=t.useRef(!1),u=t.useRef(0);return t.useEffect(()=>{const e=u.current;return()=>window.clearTimeout(e)},[]),h(Te,{scope:n,isOpenDelayedRef:l,delayDuration:r,onOpen:t.useCallback(()=>{window.clearTimeout(u.current),l.current=!1},[]),onClose:t.useCallback(()=>{window.clearTimeout(u.current),u.current=window.setTimeout(()=>l.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:t.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};Oe.displayName=Ee;var ke="Tooltip",[Ie,Ne]=be(ke),De=e=>{const{__scopeTooltip:n,children:r,open:o,defaultOpen:i,onOpenChange:a,disableHoverableContent:l,delayDuration:s}=e,u=Se(ke,e.__scopeTooltip),c=we(n),[d,p]=t.useState(null),m=R(),v=t.useRef(0),g=l??u.disableHoverableContent,y=s??u.delayDuration,b=t.useRef(!1),[x,w]=T({prop:o,defaultProp:i??!1,onChange:e=>{e?(u.onOpen(),document.dispatchEvent(new CustomEvent(Ce))):u.onClose(),a?.(e)},caller:ke}),E=t.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),C=t.useCallback(()=>{window.clearTimeout(v.current),v.current=0,b.current=!1,w(!0)},[w]),S=t.useCallback(()=>{window.clearTimeout(v.current),v.current=0,w(!1)},[w]),O=t.useCallback(()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>{b.current=!0,w(!0),v.current=0},y)},[y,w]);return t.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=0)},[]),h(f,{...c,children:h(Ie,{scope:n,contentId:m,open:x,stateAttribute:E,trigger:d,onTriggerChange:p,onTriggerEnter:t.useCallback(()=>{u.isOpenDelayedRef.current?O():C()},[u.isOpenDelayedRef,O,C]),onTriggerLeave:t.useCallback(()=>{g?S():(window.clearTimeout(v.current),v.current=0)},[S,g]),onOpen:C,onClose:S,disableHoverableContent:g,children:r})})};De.displayName=ke;var Pe="TooltipTrigger",Le=t.forwardRef((e,n)=>{const{__scopeTooltip:r,...o}=e,i=Ne(Pe,r),a=Se(Pe,r),l=we(r),u=t.useRef(null),c=E(n,u,i.onTriggerChange),d=t.useRef(!1),f=t.useRef(!1),p=t.useCallback(()=>d.current=!1,[]);return t.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),h(s,{asChild:!0,...l,children:h(x.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...o,ref:c,onPointerMove:w(e.onPointerMove,e=>{"touch"!==e.pointerType&&(f.current||a.isPointerInTransitRef.current||(i.onTriggerEnter(),f.current=!0))}),onPointerLeave:w(e.onPointerLeave,()=>{i.onTriggerLeave(),f.current=!1}),onPointerDown:w(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:w(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:w(e.onBlur,i.onClose),onClick:w(e.onClick,i.onClose)})})});Le.displayName=Pe;var Me="TooltipPortal",[Ae,_e]=be(Me,{forceMount:void 0}),je=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:o}=e,i=Ne(Me,t);return h(Ae,{scope:t,forceMount:n,children:h(C,{present:n||i.open,children:h(p,{asChild:!0,container:o,children:r})})})};je.displayName=Me;var Fe="TooltipContent",ze=t.forwardRef((e,t)=>{const n=_e(Fe,e.__scopeTooltip),{forceMount:r=n.forceMount,side:o="top",...i}=e,a=Ne(Fe,e.__scopeTooltip);return h(C,{present:r||a.open,children:a.disableHoverableContent?h(Ve,{side:o,...i,ref:t}):h(Be,{side:o,...i,ref:t})})}),Be=t.forwardRef((e,n)=>{const r=Ne(Fe,e.__scopeTooltip),o=Se(Fe,e.__scopeTooltip),i=t.useRef(null),a=E(n,i),[l,s]=t.useState(null),{trigger:u,onClose:c}=r,d=i.current,{onPointerInTransitChange:f}=o,p=t.useCallback(()=>{s(null),f(!1)},[f]),m=t.useCallback((e,t)=>{const n=e.currentTarget,r={x:e.clientX,y:e.clientY},o=function(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}(r,function(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(n,r,o,i)){case i:return"left";case o:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}(r,n.getBoundingClientRect())),i=function(e){const t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:e.y>t.y?1:0),function(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n<e.length;n++){const r=e[n];for(;t.length>=2;){const e=t[t.length-1],n=t[t.length-2];if(!((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x)))break;t.pop()}t.push(r)}t.pop();const n=[];for(let t=e.length-1;t>=0;t--){const r=e[t];for(;n.length>=2;){const e=n[n.length-1],t=n[n.length-2];if(!((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x)))break;n.pop()}n.push(r)}return n.pop(),1===t.length&&1===n.length&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}(t)}([...o,...function(e){const{top:t,right:n,bottom:r,left:o}=e;return[{x:o,y:t},{x:n,y:t},{x:n,y:r},{x:o,y:r}]}(t.getBoundingClientRect())]);s(i),f(!0)},[f]);return t.useEffect(()=>()=>p(),[p]),t.useEffect(()=>{if(u&&d){const e=e=>m(e,d),t=e=>m(e,u);return u.addEventListener("pointerleave",e),d.addEventListener("pointerleave",t),()=>{u.removeEventListener("pointerleave",e),d.removeEventListener("pointerleave",t)}}},[u,d,m,p]),t.useEffect(()=>{if(l){const e=e=>{const t=e.target,n={x:e.clientX,y:e.clientY},r=u?.contains(t)||d?.contains(t),o=!function(e,t){const{x:n,y:r}=e;let o=!1;for(let e=0,i=t.length-1;e<t.length;i=e++){const a=t[e],l=t[i],s=a.x,u=a.y,c=l.x,d=l.y;u>r!=d>r&&n<(c-s)*(r-u)/(d-u)+s&&(o=!o)}return o}(n,l);r?p():o&&(p(),c())};return document.addEventListener("pointermove",e),()=>document.removeEventListener("pointermove",e)}},[u,d,l,c,p]),h(Ve,{...e,ref:a})}),[He,qe]=be(ke,{isInside:!1}),Ue=function(e){const t=({children:e})=>h(g,{children:e});return t.displayName=`${e}.Slottable`,t.__radixId=ye,t}("TooltipContent"),Ve=t.forwardRef((e,n)=>{const{__scopeTooltip:r,children:o,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:l,...s}=e,d=Ne(Fe,r),f=we(r),{onClose:p}=d;return t.useEffect(()=>(document.addEventListener(Ce,p),()=>document.removeEventListener(Ce,p)),[p]),t.useEffect(()=>{if(d.trigger){const e=e=>{const t=e.target;t?.contains(d.trigger)&&p()};return window.addEventListener("scroll",e,{capture:!0}),()=>window.removeEventListener("scroll",e,{capture:!0})}},[d.trigger,p]),h(u,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:p,children:y(c,{"data-state":d.stateAttribute,...f,...s,ref:n,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h(Ue,{children:o}),h(He,{scope:r,isInside:!0,children:h(S,{id:d.contentId,role:"tooltip",children:i||o})})]})})});ze.displayName=Fe;var Xe="TooltipArrow",Ye=t.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,o=we(n);return qe(Xe,n).isInside?null:h(d,{...o,...r,ref:t})});Ye.displayName=Xe;var $e=Oe,Ke=De,Ge=Le,Je=je,Qe=ze,We=Ye;const Ze=e=>{var{delayDuration:t=0}=e,n=v(e,["delayDuration"]);return h($e,Object.assign({"data-slot":"tooltip-provider",delayDuration:t},n))},et=e=>{var t=v(e,[]);return h(Ze,{children:h(Ke,Object.assign({"data-slot":"tooltip"},t))})},tt=e=>{var t=v(e,[]);return h(Ge,Object.assign({"data-slot":"tooltip-trigger"},t))},nt=e=>{var{className:t,sideOffset:n=0,children:r}=e,o=v(e,["className","sideOffset","children"]);return h(Je,{children:y(Qe,Object.assign({"data-slot":"tooltip-content",sideOffset:n,className:O("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",t)},o,{children:[r,h(We,{className:"bg-foreground fill-foreground z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]"})]}))})};export{me as F,k as R,Ze as T,et as a,tt as b,nt as c,ge as u};
|
package/dist/code-group.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useMemo as t,useRef as r,useState as n}from"react";import{useYooptaEditor as i,Blocks as a,Elements as c}from"@yoopta/editor";import{Transforms as s,Element as d,Editor as l,Text as u}from"slate";import{T as g,a as p,b,c as v}from"./chunks/tabs-294764a6.js";import{a as m}from"./chunks/_tslib-35bb891d.js";import{isLanguageSupported as f,SHIKI_CODE_LANGUAGES as h,HighlightedCodeOverlay as k,CodeGroupCommands as j}from"@yoopta/code";import{C as y,c as x}from"./chunks/index-0bca29df.js";import{L as w}from"./chunks/language-select-89735035.js";import{B as O}from"./chunks/button-7aec29d6.js";import{S as N}from"./chunks/sparkles-ae42eae3.js";import{C}from"./chunks/check-06bd6a78.js";import{T}from"./chunks/trash-2-f36597ff.js";import{X as I}from"./chunks/x-9bfeb90f.js";import{S as B,a as E}from"./chunks/scroll-area-dae47c2c.js";import{P as S}from"./chunks/plus-840fe920.js";import{s as z}from"./chunks/style-inject.es-e87a8d02.js";import"./chunks/index-17323747.js";import"react-dom";import"./chunks/index-91a5b8d5.js";import"./chunks/index-ba3032f8.js";import"./chunks/index-f85dae42.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-70f4e709.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-13505606.js";import"./chunks/index-23db6fea.js";import"./chunks/utils-3345eade.js";import"./chunks/createLucideIcon-8605f860.js";import"./chunks/select-a8bcd8b5.js";import"./chunks/index-056e5c06.js";import"./chunks/index-23c7fb16.js";import"./chunks/Combination-575d4475.js";import"./chunks/index-1674c2c8.js";import"./chunks/chevron-down-28dfb290.js";import"./chunks/chevron-up-9a13532e.js";const L=e=>{var o;if(u.isText(e))return e.text;if("object"==typeof e&&null!==e&&"children"in e){const t=e.children;return null!==(o=null==t?void 0:t.map(L).join("\n"))&&void 0!==o?o:""}return""};z("[data-code-group-container] [data-state=active]{background-color:var(--code-group-tab-active-bg)!important;border-bottom-color:var(--code-group-tab-active-fg)!important;color:var(--code-group-tab-active-fg)!important}[data-code-group-container] [data-state=inactive]{background-color:var(--code-group-tab-inactive-bg)!important;color:var(--code-group-tab-inactive-fg)!important}");const F={"code-group-container":{render:o=>{var r,n;const{attributes:c,children:l,blockId:u,element:p}=o,b=i(),v=null===(r=o.element.props)||void 0===r?void 0:r.theme,m=t(()=>{var e,o,t,r,n,i,a,c,s,d,l,u,g,p,b,m,f,h,k,j,y;if("undefined"==typeof window)return{};if(!window.yShiki||!v)return{};const x=window.yShiki.getTheme(v),w=null!==(e=x.colors)&&void 0!==e?e:{},O=null!==(t=null!==(o=w["tab.activeBackground"])&&void 0!==o?o:w["editorTab.activeBackground"])&&void 0!==t?t:x.bg,N=null!==(i=null!==(n=null!==(r=w["tab.inactiveBackground"])&&void 0!==r?r:w["editorTab.inactiveBackground"])&&void 0!==n?n:w["editorGroupHeader.tabsBackground"])&&void 0!==i?i:x.bg,C=null!==(c=null!==(a=w["tab.activeForeground"])&&void 0!==a?a:w["editorTab.activeForeground"])&&void 0!==c?c:x.fg;return{"--code-group-tab-active-bg":O,"--code-group-tab-inactive-bg":N,"--code-group-tab-active-fg":C,"--code-group-tab-inactive-fg":null!==(l=null!==(d=null!==(s=w["tab.inactiveForeground"])&&void 0!==s?s:w["editorTab.inactiveForeground"])&&void 0!==d?d:w.foreground)&&void 0!==l?l:x.fg,"--code-group-tab-active-border":null!==(g=null!==(u=w["tab.activeBorder"])&&void 0!==u?u:w["editorTab.activeBorder"])&&void 0!==g?g:C,"--code-group-tab-border":null!==(m=null!==(b=null!==(p=w["tab.border"])&&void 0!==p?p:w["editorGroupHeader.border"])&&void 0!==b?b:w["editorGroup.border"])&&void 0!==m?m:"transparent","--code-group-editor-bg":null!==(f=w["editor.background"])&&void 0!==f?f:x.bg,"--code-group-editor-fg":null!==(h=w["editor.foreground"])&&void 0!==h?h:x.fg,"--code-group-editor-cursor":null!==(k=w["editorCursor.foreground"])&&void 0!==k?k:x.fg,"--code-group-button-fg":null!==(y=null!==(j=w["button.foreground"])&&void 0!==j?j:w["icon.foreground"])&&void 0!==y?y:x.fg}},[v]);return e("div",Object.assign({},c,{"data-code-group-container":!0,className:"w-full",style:m},{children:e(g,Object.assign({value:null===(n=p.props)||void 0===n?void 0:n.activeTabId,onValueChange:e=>{const o=a.getBlockSlate(b,{id:u});o&&s.setNodes(o,{props:Object.assign(Object.assign({},p.props),{activeTabId:e})},{at:[0],match:e=>d.isElement(e)&&"code-group-container"===e.type})},className:"w-full"},{children:l}))}))}},"code-group-list":{render:t=>{const{attributes:r,children:n,blockId:a}=t,c=i();return o(B,Object.assign({className:"w-full"},{children:[o(v,Object.assign({},r,{className:"w-full mt-2 relative justify-start h-8 rounded-none rounded-t-lg bg-transparent p-0 border-b border-x-0 border-t-0",style:{backgroundColor:"var(--code-group-tab-inactive-bg)",borderBottomColor:"var(--code-group-tab-border)"}},{children:[n,!c.readOnly&&e("button",Object.assign({type:"button",contentEditable:!1,onClick:e=>{c.readOnly||(e.preventDefault(),e.stopPropagation(),j.addTabItem(c,a))},className:"ml-1 flex items-center justify-center rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 p-1.5 h-7",style:{color:"var(--code-group-tab-inactive-fg)"},title:"Add tab"},{children:e(S,{className:"h-3.5 w-3.5 shrink-0"})}))]})),e(E,{orientation:"horizontal"})]}))}},"code-group-item-heading":{render:t=>{const{attributes:r,children:n,element:d,blockId:l}=t,u=i();return o(b,Object.assign({},r,{value:d.id,className:"relative group/tab flex items-center gap-1.5 px-3 h-7 rounded-none rounded-t-lg border-b-2 border-transparent whitespace-nowrap text-xs font-normal transition-colors",style:{backgroundColor:"var(--code-group-tab-inactive-bg, hsl(var(--muted)))",color:"var(--code-group-tab-inactive-fg, hsl(var(--muted-foreground)))"}},{children:[e("div",Object.assign({className:"flex-1 min-w-0"},{children:n})),!u.readOnly&&e("span",Object.assign({contentEditable:!1,onClick:()=>{if(u.readOnly)return;const e=a.getBlockSlate(u,{id:l});if(!e)return;const o=c.getElementPath(u,{blockId:l,element:d});o&&(s.select(e,o),j.deleteTabItem(u,l,{tabId:d.id}))},className:"ml-1 flex items-center justify-center rounded-sm opacity-0 group-hover/tab:opacity-100 transition-opacity hover:bg-black/10 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 p-0.5",style:{color:"inherit"},title:"Close tab"},{children:e(I,{className:"h-3 w-3 shrink-0"})}))]}))}},"code-group-content":{render:s=>{var u,g,b,v;const{attributes:I,children:B,element:E,blockId:S}=s,z=r(null),F=i(),H=null!==(g=null===(u=null==E?void 0:E.props)||void 0===u?void 0:u.language)&&void 0!==g?g:"javascript",P=t(()=>{var e,o,t;const r=a.getBlockSlate(F,{id:S});if(!r)return"github-dark";const n=null===(e=Array.from(l.nodes(r,{at:[0],match:e=>d.isElement(e)&&"code-group-container"===e.type})))||void 0===e?void 0:e[0];if(!n)return"github-dark";const[i]=n;return i&&null!==(t=null===(o=i.props)||void 0===o?void 0:o.theme)&&void 0!==t?t:"github-dark"},[F,S]),[A,D]=n(!1),[G,V]=n(!1),q=f(H),R=null!==(b=h.find(e=>e.value===H))&&void 0!==b?b:h[0];return e(p,Object.assign({},I,{value:null===(v=E.props)||void 0===v?void 0:v.referenceId,className:"rounded-b-lg mt-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"},{children:o("div",Object.assign({className:"relative group/code-group-content overflow-hidden"},{children:[o("div",Object.assign({contentEditable:!1,className:"absolute top-2 right-2 z-20 flex items-center gap-2 opacity-0 group-hover/code-group-content:opacity-100 transition-opacity",style:{backgroundColor:"var(--code-group-tab-active-bg)",padding:"4px",borderRadius:"4px"}},{children:[e(w,{value:H,options:h,onValueChange:e=>{if(F.readOnly)return;const o=c.getElementPath(F,{blockId:S,element:E});o&&c.updateElement(F,{blockId:S,type:"code-group-content",props:Object.assign(Object.assign({},E.props),{language:e}),path:o})},currentLabel:R.label,style:{color:"var(--code-group-tab-active-fg)"}}),q&&e(O,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>m(void 0,void 0,void 0,function*(){var e;if(G)return;const o=null===(e=E.props)||void 0===e?void 0:e.referenceId;if(o){V(!0);try{yield j.beautifyTab(F,S,o)}finally{V(!1)}}}),disabled:G,title:"Beautify code",style:{color:"var(--code-group-button-fg, var(--code-group-tab-active-fg))"}},{children:e(N,{className:"h-4 w-4 "+(G?"animate-pulse":"")})})),e(O,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{const e=L(E);x(e)&&(D(!0),setTimeout(()=>D(!1),1500))},title:A?"Copied!":"Copy code",style:{color:"var(--code-group-button-fg, var(--code-group-tab-active-fg))"}},{children:e(A?C:y,{className:"h-4 w-4"})})),!F.readOnly&&e(O,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;F.readOnly||j.deleteTabItem(F,S,{tabId:null===(e=E.props)||void 0===e?void 0:e.referenceId})},title:"Delete code",style:{color:"var(--code-group-button-fg, var(--code-group-tab-active-fg))"}},{children:e(T,{className:"h-4 w-4"})}))]})),o("div",Object.assign({className:"relative bg-background overflow-hidden rounded-lg",style:{backgroundColor:"var(--code-group-editor-bg)",color:"var(--code-group-editor-fg)",caretColor:"var(--code-group-editor-cursor)"}},{children:[e("div",Object.assign({ref:z,className:"absolute inset-0 p-4 font-mono text-sm whitespace-pre overflow-auto pointer-events-none z-10 select-none",style:{lineHeight:"1.6",tabSize:2},contentEditable:!1,"aria-hidden":"true"},{children:e(k,{element:E,language:H,theme:P})})),e("div",Object.assign({className:"relative p-4 font-mono text-sm whitespace-pre overflow-auto",style:{lineHeight:"1.6",tabSize:2,color:"transparent",caretColor:"var(--code-group-editor-cursor)"},onScroll:e=>{z.current&&(z.current.scrollTop=e.currentTarget.scrollTop,z.current.scrollLeft=e.currentTarget.scrollLeft)}},{children:B}))]}))]}))}))}}};export{F as CodeGroupUI};
|
|
1
|
+
import{jsx as e,jsxs as o}from"react/jsx-runtime";import{useMemo as t,useRef as r,useState as n}from"react";import{useYooptaEditor as i,Blocks as a,Elements as c}from"@yoopta/editor";import{Transforms as s,Element as d,Editor as l,Text as u}from"slate";import{T as g,a as p,b,c as v}from"./chunks/tabs-370c3f2c.js";import{a as m}from"./chunks/_tslib-35bb891d.js";import{isLanguageSupported as f,SHIKI_CODE_LANGUAGES as h,HighlightedCodeOverlay as k,CodeGroupCommands as j}from"@yoopta/code";import{C as y,c as x}from"./chunks/index-0bca29df.js";import{L as w}from"./chunks/language-select-ee2698cf.js";import{B as O}from"./chunks/button-f335deaa.js";import{S as N}from"./chunks/sparkles-ae42eae3.js";import{C}from"./chunks/check-06bd6a78.js";import{T}from"./chunks/trash-2-f36597ff.js";import{X as I}from"./chunks/x-9bfeb90f.js";import{S as B,a as E}from"./chunks/scroll-area-8321348a.js";import{P as S}from"./chunks/plus-840fe920.js";import{s as z}from"./chunks/style-inject.es-e87a8d02.js";import"./chunks/index-17323747.js";import"react-dom";import"./chunks/index-91a5b8d5.js";import"./chunks/index-a77c7d53.js";import"./chunks/index-5b487f4e.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-70f4e709.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-13505606.js";import"./chunks/index-bd6363d4.js";import"./chunks/utils-3345eade.js";import"./chunks/createLucideIcon-8605f860.js";import"./chunks/select-a3724728.js";import"./chunks/index-056e5c06.js";import"./chunks/index-371259c9.js";import"./chunks/Combination-575d4475.js";import"./chunks/index-1674c2c8.js";import"./chunks/chevron-down-28dfb290.js";import"./chunks/chevron-up-9a13532e.js";const F=e=>{var o;if(u.isText(e))return e.text;if("object"==typeof e&&null!==e&&"children"in e){const t=e.children;return null!==(o=null==t?void 0:t.map(F).join("\n"))&&void 0!==o?o:""}return""};z("[data-code-group-container] [data-state=active]{background-color:var(--code-group-tab-active-bg)!important;border-bottom-color:var(--code-group-tab-active-fg)!important;color:var(--code-group-tab-active-fg)!important}[data-code-group-container] [data-state=inactive]{background-color:var(--code-group-tab-inactive-bg)!important;color:var(--code-group-tab-inactive-fg)!important}");const L={"code-group-container":{render:o=>{var r,n;const{attributes:c,children:l,blockId:u,element:p}=o,b=i(),v=null===(r=o.element.props)||void 0===r?void 0:r.theme,m=t(()=>{var e,o,t,r,n,i,a,c,s,d,l,u,g,p,b,m,f,h,k,j,y;if("undefined"==typeof window)return{};if(!window.yShiki||!v)return{};const x=window.yShiki.getTheme(v),w=null!==(e=x.colors)&&void 0!==e?e:{},O=null!==(t=null!==(o=w["tab.activeBackground"])&&void 0!==o?o:w["editorTab.activeBackground"])&&void 0!==t?t:x.bg,N=null!==(i=null!==(n=null!==(r=w["tab.inactiveBackground"])&&void 0!==r?r:w["editorTab.inactiveBackground"])&&void 0!==n?n:w["editorGroupHeader.tabsBackground"])&&void 0!==i?i:x.bg,C=null!==(c=null!==(a=w["tab.activeForeground"])&&void 0!==a?a:w["editorTab.activeForeground"])&&void 0!==c?c:x.fg;return{"--code-group-tab-active-bg":O,"--code-group-tab-inactive-bg":N,"--code-group-tab-active-fg":C,"--code-group-tab-inactive-fg":null!==(l=null!==(d=null!==(s=w["tab.inactiveForeground"])&&void 0!==s?s:w["editorTab.inactiveForeground"])&&void 0!==d?d:w.foreground)&&void 0!==l?l:x.fg,"--code-group-tab-active-border":null!==(g=null!==(u=w["tab.activeBorder"])&&void 0!==u?u:w["editorTab.activeBorder"])&&void 0!==g?g:C,"--code-group-tab-border":null!==(m=null!==(b=null!==(p=w["tab.border"])&&void 0!==p?p:w["editorGroupHeader.border"])&&void 0!==b?b:w["editorGroup.border"])&&void 0!==m?m:"transparent","--code-group-editor-bg":null!==(f=w["editor.background"])&&void 0!==f?f:x.bg,"--code-group-editor-fg":null!==(h=w["editor.foreground"])&&void 0!==h?h:x.fg,"--code-group-editor-cursor":null!==(k=w["editorCursor.foreground"])&&void 0!==k?k:x.fg,"--code-group-button-fg":null!==(y=null!==(j=w["button.foreground"])&&void 0!==j?j:w["icon.foreground"])&&void 0!==y?y:x.fg}},[v]);return e("div",Object.assign({},c,{"data-code-group-container":!0,className:"w-full",style:m},{children:e(g,Object.assign({value:null===(n=p.props)||void 0===n?void 0:n.activeTabId,onValueChange:e=>{const o=a.getBlockSlate(b,{id:u});o&&s.setNodes(o,{props:Object.assign(Object.assign({},p.props),{activeTabId:e})},{at:[0],match:e=>d.isElement(e)&&"code-group-container"===e.type})},className:"w-full"},{children:l}))}))}},"code-group-list":{render:t=>{const{attributes:r,children:n,blockId:a}=t,c=i();return o(B,Object.assign({className:"w-full"},{children:[o(v,Object.assign({},r,{className:"w-full mt-2 relative justify-start h-8 rounded-none rounded-t-lg bg-transparent p-0 border-b border-x-0 border-t-0",style:{backgroundColor:"var(--code-group-tab-inactive-bg)",borderBottomColor:"var(--code-group-tab-border)"}},{children:[n,!c.readOnly&&e("button",Object.assign({type:"button",contentEditable:!1,onClick:e=>{c.readOnly||(e.preventDefault(),e.stopPropagation(),j.addTabItem(c,a))},className:"ml-1 flex items-center justify-center rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 p-1.5 h-7",style:{color:"var(--code-group-tab-inactive-fg)"},title:"Add tab"},{children:e(S,{className:"h-3.5 w-3.5 shrink-0"})}))]})),e(E,{orientation:"horizontal"})]}))}},"code-group-item-heading":{render:t=>{const{attributes:r,children:n,element:d,blockId:l}=t,u=i();return o(b,Object.assign({},r,{value:d.id,className:"relative group/tab flex items-center gap-1.5 px-3 h-7 rounded-none rounded-t-lg border-b-2 border-transparent whitespace-nowrap text-xs font-normal transition-colors",style:{backgroundColor:"var(--code-group-tab-inactive-bg, hsl(var(--muted)))",color:"var(--code-group-tab-inactive-fg, hsl(var(--muted-foreground)))"}},{children:[e("div",Object.assign({className:"flex-1 min-w-0"},{children:n})),!u.readOnly&&e("span",Object.assign({contentEditable:!1,onClick:()=>{if(u.readOnly)return;const e=a.getBlockSlate(u,{id:l});if(!e)return;const o=c.getElementPath(u,{blockId:l,element:d});o&&(s.select(e,o),j.deleteTabItem(u,l,{tabId:d.id}))},className:"ml-1 flex items-center justify-center rounded-sm opacity-0 group-hover/tab:opacity-100 transition-opacity hover:bg-black/10 dark:hover:bg-white/10 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 p-0.5",style:{color:"inherit"},title:"Close tab"},{children:e(I,{className:"h-3 w-3 shrink-0"})}))]}))}},"code-group-content":{render:s=>{var u,g,b,v;const{attributes:I,children:B,element:E,blockId:S}=s,z=r(null),L=i(),H=null!==(g=null===(u=null==E?void 0:E.props)||void 0===u?void 0:u.language)&&void 0!==g?g:"javascript",P=t(()=>{var e,o,t;const r=a.getBlockSlate(L,{id:S});if(!r)return"github-dark";const n=null===(e=Array.from(l.nodes(r,{at:[0],match:e=>d.isElement(e)&&"code-group-container"===e.type})))||void 0===e?void 0:e[0];if(!n)return"github-dark";const[i]=n;return i&&null!==(t=null===(o=i.props)||void 0===o?void 0:o.theme)&&void 0!==t?t:"github-dark"},[L,S]),[D,G]=n(!1),[A,V]=n(!1),q=f(H),R=null!==(b=h.find(e=>e.value===H))&&void 0!==b?b:h[0];return e(p,Object.assign({},I,{value:null===(v=E.props)||void 0===v?void 0:v.referenceId,className:"rounded-b-lg mt-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"},{children:o("div",Object.assign({className:"relative group/code-group-content overflow-hidden"},{children:[o("div",Object.assign({contentEditable:!1,className:"absolute top-2 right-2 z-20 flex items-center gap-2 opacity-0 group-hover/code-group-content:opacity-100 transition-opacity",style:{backgroundColor:"var(--code-group-tab-active-bg)",padding:"4px",borderRadius:"4px"}},{children:[e(w,{value:H,options:h,onValueChange:e=>{if(L.readOnly)return;const o=c.getElementPath(L,{blockId:S,element:E});o&&c.updateElement(L,{blockId:S,type:"code-group-content",props:Object.assign(Object.assign({},E.props),{language:e}),path:o})},currentLabel:R.label,style:{color:"var(--code-group-tab-active-fg)"}}),q&&e(O,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>m(void 0,void 0,void 0,function*(){var e;if(A)return;const o=null===(e=E.props)||void 0===e?void 0:e.referenceId;if(o){V(!0);try{yield j.beautifyTab(L,S,o)}finally{V(!1)}}}),disabled:A,title:"Beautify code",style:{color:"var(--code-group-button-fg, var(--code-group-tab-active-fg))"}},{children:e(N,{className:"h-4 w-4 "+(A?"animate-pulse":"")})})),e(O,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{const e=F(E);x(e)&&(G(!0),setTimeout(()=>G(!1),1500))},title:D?"Copied!":"Copy code",style:{color:"var(--code-group-button-fg, var(--code-group-tab-active-fg))"}},{children:e(D?C:y,{className:"h-4 w-4"})})),!L.readOnly&&e(O,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;L.readOnly||j.deleteTabItem(L,S,{tabId:null===(e=E.props)||void 0===e?void 0:e.referenceId})},title:"Delete code",style:{color:"var(--code-group-button-fg, var(--code-group-tab-active-fg))"}},{children:e(T,{className:"h-4 w-4"})}))]})),o("div",Object.assign({className:"relative bg-background overflow-hidden rounded-lg",style:{backgroundColor:"var(--code-group-editor-bg)",color:"var(--code-group-editor-fg)",caretColor:"var(--code-group-editor-cursor)"}},{children:[e("div",Object.assign({ref:z,className:"absolute inset-0 p-4 font-mono text-sm whitespace-pre overflow-auto pointer-events-none z-10 select-none",style:{lineHeight:"1.6",tabSize:2},contentEditable:!1,"aria-hidden":"true"},{children:e(k,{element:E,language:H,theme:P})})),e("div",Object.assign({className:"relative p-4 font-mono text-sm whitespace-pre overflow-auto",style:{lineHeight:"1.6",tabSize:2,color:"transparent",caretColor:"var(--code-group-editor-cursor)"},onScroll:e=>{z.current&&(z.current.scrollTop=e.currentTarget.scrollTop,z.current.scrollLeft=e.currentTarget.scrollLeft)}},{children:B}))]}))]}))}))}}};export{L as CodeGroupUI};
|
package/dist/code.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunks/_tslib-35bb891d.js";import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useRef as t,useState as n,useEffect as i,useCallback as a}from"react";import{CodeCommands as c,isLanguageSupported as l,SHIKI_CODE_LANGUAGES as d,SHIKI_CODE_THEMES as s,HighlightedCodeOverlay as u}from"@yoopta/code";import{useYooptaReadOnly as g,useYooptaEditor as b,Blocks as v,Elements as p}from"@yoopta/editor";import{c as m,C as h}from"./chunks/index-0bca29df.js";import{Editor as k,Element as f,Text as j}from"slate";import{L as C}from"./chunks/language-select-
|
|
1
|
+
import{a as o}from"./chunks/_tslib-35bb891d.js";import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useRef as t,useState as n,useEffect as i,useCallback as a}from"react";import{CodeCommands as c,isLanguageSupported as l,SHIKI_CODE_LANGUAGES as d,SHIKI_CODE_THEMES as s,HighlightedCodeOverlay as u}from"@yoopta/code";import{useYooptaReadOnly as g,useYooptaEditor as b,Blocks as v,Elements as p}from"@yoopta/editor";import{c as m,C as h}from"./chunks/index-0bca29df.js";import{Editor as k,Element as f,Text as j}from"slate";import{L as C}from"./chunks/language-select-ee2698cf.js";import{S as y,a as x,b as w,c as F,d as B}from"./chunks/select-a3724728.js";import{c as O}from"./chunks/utils-3345eade.js";import{B as N}from"./chunks/button-f335deaa.js";import{S as T}from"./chunks/sparkles-ae42eae3.js";import{C as I}from"./chunks/check-06bd6a78.js";import{T as A}from"./chunks/trash-2-f36597ff.js";import"./chunks/createLucideIcon-8605f860.js";import"react-dom";import"./chunks/index-056e5c06.js";import"./chunks/index-17323747.js";import"./chunks/index-91a5b8d5.js";import"./chunks/index-5b487f4e.js";import"./chunks/index-13505606.js";import"./chunks/index-371259c9.js";import"./chunks/index-70f4e709.js";import"./chunks/Combination-575d4475.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-1674c2c8.js";import"./chunks/chevron-down-28dfb290.js";import"./chunks/chevron-up-9a13532e.js";const z=({value:o,options:t,onValueChange:n,currentLabel:i,className:a,style:c})=>{const l=g();return e(y,Object.assign({value:o,onValueChange:n,disabled:l},{children:[r(x,Object.assign({size:"sm",className:O("h-7 gap-1.5 text-xs border-transparent hover:border-current/20",a),style:c,contentEditable:!1,onMouseDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation()},{children:r(w,Object.assign({placeholder:i},{children:i}))})),r(F,Object.assign({align:"start",position:"popper",className:"max-h-[200px]",onMouseDown:o=>o.stopPropagation(),onClick:o=>o.stopPropagation()},{children:t.map(o=>r(B,Object.assign({value:o.value,className:"text-xs"},{children:o.label}),o.value))}))]}))},E=o=>{var e;if(j.isText(o))return o.text;if("object"==typeof o&&null!==o&&"children"in o){const r=o.children;return null!==(e=null==r?void 0:r.map(E).join("\n"))&&void 0!==e?e:""}return""},L={code:{render:({attributes:g,children:j,element:y,blockId:x})=>{var w,F,B,O,L,S;const P=b(),V=null!==(F=null===(w=y.props)||void 0===w?void 0:w.language)&&void 0!==F?F:"javascript",D=null!==(O=null===(B=y.props)||void 0===B?void 0:B.theme)&&void 0!==O?O:"github-dark",H=t(null),[G,M]=n(!1),[_,q]=n(!1),[J,K]=n({background:"",foreground:"",caret:"",tabActiveBackground:"",tabInactiveBackground:"",tabActiveForeground:"",tabInactiveForeground:"",buttonForeground:"",selectBackground:"",selectForeground:"",borderColor:""});i(()=>{var o,e,r,t,n,i,a,c,l,d,s,u,g,b,v,p,m,h,k,f,j,C,y;if(window.yShiki){const x=window.yShiki.getTheme(D),w=null!==(o=x.colors)&&void 0!==o?o:{};K({background:null!==(e=w["editor.background"])&&void 0!==e?e:x.bg,foreground:null!==(r=w["editor.foreground"])&&void 0!==r?r:x.fg,caret:null!==(t=w["editorCursor.foreground"])&&void 0!==t?t:x.fg,tabActiveBackground:null!==(i=null!==(n=w["tab.activeBackground"])&&void 0!==n?n:w["editorTab.activeBackground"])&&void 0!==i?i:x.bg,tabInactiveBackground:null!==(l=null!==(c=null!==(a=w["tab.inactiveBackground"])&&void 0!==a?a:w["editorTab.inactiveBackground"])&&void 0!==c?c:w["editorGroupHeader.tabsBackground"])&&void 0!==l?l:x.bg,tabActiveForeground:null!==(s=null!==(d=w["tab.activeForeground"])&&void 0!==d?d:w["editorTab.activeForeground"])&&void 0!==s?s:x.fg,tabInactiveForeground:null!==(b=null!==(g=null!==(u=w["tab.inactiveForeground"])&&void 0!==u?u:w["editorTab.inactiveForeground"])&&void 0!==g?g:w.foreground)&&void 0!==b?b:x.fg,buttonForeground:null!==(p=null!==(v=w["button.foreground"])&&void 0!==v?v:w["icon.foreground"])&&void 0!==p?p:x.fg,selectBackground:null!==(h=null!==(m=w["dropdown.background"])&&void 0!==m?m:w["input.background"])&&void 0!==h?h:x.bg,selectForeground:null!==(f=null!==(k=w["dropdown.foreground"])&&void 0!==k?k:w["input.foreground"])&&void 0!==f?f:x.fg,borderColor:null!==(y=null!==(C=null!==(j=w["dropdown.border"])&&void 0!==j?j:w["input.border"])&&void 0!==C?C:w["editorGroup.border"])&&void 0!==y?y:"transparent"})}},[D]);const Q=a(()=>{const o=E(y);m(o)&&(M(!0),setTimeout(()=>M(!1),1500))},[y]),R=a(()=>{if(P.readOnly)return;const o=v.getBlockSlate(P,{id:x});if(!o)return;const e=p.getElementPath(P,{blockId:x,element:y});if(!e)return;const r=e?k.parent(o,e):void 0;r&&f.isElement(r[0])&&!k.isEditor(r[0])?p.deleteElement(P,{blockId:x,type:"code",path:e}):v.deleteBlock(P,{blockId:x,focus:!0})},[P,x,y]),U=a(o=>{c.updateCodeLanguage(P,x,o)},[P,x]),W=a(o=>{c.updateCodeTheme(P,x,o)},[P,x]),X=a(()=>o(void 0,void 0,void 0,function*(){if(!_){q(!0);try{yield c.beautifyCode(P,x)}finally{q(!1)}}}),[P,x,_]),Y=l(V),Z=null!==(L=d.find(o=>o.value===V))&&void 0!==L?L:d[0],$=null!==(S=s.find(o=>o.value===D))&&void 0!==S?S:s[0],oo={"--code-bg":J.background,"--code-fg":J.foreground,"--code-caret":J.caret,"--code-tab-active-bg":J.tabActiveBackground,"--code-tab-inactive-bg":J.tabInactiveBackground,"--code-tab-active-fg":J.tabActiveForeground,"--code-tab-inactive-fg":J.tabInactiveForeground,"--code-button-fg":J.buttonForeground,"--code-select-bg":J.selectBackground,"--code-select-fg":J.selectForeground,"--code-border":J.borderColor};return e("div",Object.assign({},g,{className:"relative my-2 group/code-block rounded-lg border overflow-hidden",style:Object.assign(Object.assign({},oo),{borderColor:J.borderColor||void 0,backgroundColor:J.tabInactiveBackground||void 0})},{children:[e("div",Object.assign({contentEditable:!1,className:"flex items-center justify-between px-4 py-2 border-b select-none",style:{backgroundColor:J.tabActiveBackground||void 0,borderColor:J.borderColor||void 0}},{children:[e("div",Object.assign({className:"flex items-center gap-2"},{children:[r(C,{value:V,options:d,onValueChange:o=>U(o),currentLabel:Z.label,style:{color:J.tabActiveForeground||void 0,borderColor:J.borderColor||void 0}}),r(z,{value:D,options:s,onValueChange:o=>W(o),currentLabel:$.label,style:{color:J.tabActiveForeground||void 0,borderColor:J.borderColor||void 0}})]})),e("div",Object.assign({className:"flex items-center gap-1 opacity-0 group-hover/code-block:opacity-100 transition-opacity"},{children:[Y&&r(N,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:X,disabled:_,title:"Beautify code",style:{color:J.buttonForeground||void 0}},{children:r(T,{className:"h-4 w-4 "+(_?"animate-pulse":"")})})),r(N,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:Q,title:G?"Copied!":"Copy code",style:{color:J.buttonForeground||void 0}},{children:r(G?I:h,{className:"h-4 w-4"})})),!P.readOnly&&r(N,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:R,title:"Delete code block",style:{color:J.buttonForeground||void 0}},{children:r(A,{className:"h-4 w-4"})}))]}))]})),e("div",Object.assign({className:"relative bg-background overflow-hidden",style:{backgroundColor:J.background,color:J.foreground,caretColor:J.caret}},{children:[r("div",Object.assign({ref:H,className:"absolute inset-0 p-4 font-mono text-sm whitespace-pre overflow-auto pointer-events-none z-10 select-none",style:{lineHeight:"1.6",tabSize:2},contentEditable:!1,"aria-hidden":"true"},{children:r(u,{element:y,language:V,theme:D})})),r("div",Object.assign({className:"relative p-4 font-mono text-sm whitespace-pre overflow-auto",style:{lineHeight:"1.6",tabSize:2,color:"transparent",caretColor:J.caret},onScroll:o=>{H.current&&(H.current.scrollTop=o.currentTarget.scrollTop,H.current.scrollLeft=o.currentTarget.scrollLeft)}},{children:j}))]}))]}))}}};export{L as CodeUI};
|
package/dist/divider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useYooptaEditor as o,Blocks as t,Selection as a}from"@yoopta/editor";import{useElementOptions as d,useUpdateElementProps as n,ElementOptions as l}from"@yoopta/ui/element-options";import{S as s}from"./chunks/separator-
|
|
1
|
+
import{jsxs as e,jsx as r}from"react/jsx-runtime";import{useYooptaEditor as o,Blocks as t,Selection as a}from"@yoopta/editor";import{useElementOptions as d,useUpdateElementProps as n,ElementOptions as l}from"@yoopta/ui/element-options";import{S as s}from"./chunks/separator-f4e74aca.js";import{c as i}from"./chunks/utils-3345eade.js";import"./chunks/_tslib-35bb891d.js";import"react";import"react-dom";import"./chunks/index-a5cba5f7.js";import"./chunks/index-91a5b8d5.js";const c=[{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"},{value:"gradient",label:"Gradient"}],b=["#E5E7EB","#6B7280","#1F2937","#EF4444","#F59E0B","#22C55E","#3B82F6","#8B5CF6"],u=()=>{var o,t,a,s;const{element:i}=d(),u=n(),p=i;return e(l.Content,Object.assign({side:"bottom",align:"end",sideOffset:8,className:"min-w-[180px] rounded-lg border bg-popover p-2 shadow-md"},{children:[e(l.Group,Object.assign({className:"flex flex-col gap-1"},{children:[r(l.Label,Object.assign({className:"px-2 text-xs font-medium text-muted-foreground"},{children:"Style"})),r(l.Select,{value:null!==(t=null===(o=p.props)||void 0===o?void 0:o.theme)&&void 0!==t?t:"solid",options:c,onValueChange:e=>u({theme:e}),className:"flex h-8 w-full items-center justify-between rounded-md border border-input bg-background px-3 text-sm hover:bg-accent"})]})),r(l.Separator,{className:"my-2 h-px bg-border"}),e(l.Group,Object.assign({className:"flex flex-col gap-1"},{children:[r(l.Label,Object.assign({className:"px-2 text-xs font-medium text-muted-foreground"},{children:"Color"})),r(l.ColorPicker,{value:null!==(s=null===(a=p.props)||void 0===a?void 0:a.color)&&void 0!==s?s:"#E5E7EB",onChange:e=>u({color:e}),presetColors:b,className:"flex h-8 w-full items-center gap-2 rounded-md border border-input bg-background px-3 text-sm hover:bg-accent"})]}))]}))},p=(e,r)=>{switch(e){case"dashed":return i("border-t-2 border-dashed border-b-0 border-l-0 border-r-0 bg-transparent",r?"":"border-border");case"dotted":return i("border-t-2 border-dotted border-b-0 border-l-0 border-r-0 bg-transparent",r?"":"border-border");case"gradient":return"h-[2px] bg-transparent border-0";default:return i("h-[1px]",r?"":"bg-border")}},m={divider:{render:d=>{var n,i,c;const b=o(),{attributes:m,element:g,blockId:h}=d,v=g,x=null!==(i=null===(n=v.props)||void 0===n?void 0:n.theme)&&void 0!==i?i:"solid",f=null===(c=v.props)||void 0===c?void 0:c.color;return e("div",Object.assign({},m,{contentEditable:!1,className:"group relative w-full py-3",onClick:()=>{const e=t.getBlock(b,{id:h});e&&a.setSelected(b,{at:e.meta.order})}},{children:[e(l.Root,Object.assign({blockId:h,element:g},{children:[r(l.Trigger,{className:"absolute right-0 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 transition-opacity rounded-md p-1 hover:bg-accent"}),r(u,{})]})),r(s,{orientation:"horizontal",decorative:!0,className:p(x,f),style:(()=>{if(!f)return{};switch(x){case"dashed":case"dotted":return{borderTopColor:f};case"gradient":return{background:`linear-gradient(to right, transparent, ${f}, transparent)`};default:return{backgroundColor:f}}})()}),d.children]}))}}};export{m as DividerUI};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed-inline-toolbar.d.ts","sourceRoot":"","sources":["../../../../src/embed/elements/embed/embed-inline-toolbar.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"embed-inline-toolbar.d.ts","sourceRoot":"","sources":["../../../../src/embed/elements/embed/embed-inline-toolbar.tsx"],"names":[],"mappings":";AAUA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,KAAK,uBAAuB,GAAG;IAC7B,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACzD,YAAY,EAAE,iBAAiB,CAAC;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IACtD,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,2EAO5B,uBAAuB,mDA0KzB,CAAC"}
|
package/dist/embed.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{a as e}from"./chunks/_tslib-35bb891d.js";import{jsxs as t,jsx as n,Fragment as i}from"react/jsx-runtime";import{useState as s,useLayoutEffect as r,useRef as a,useEffect as l,useCallback as o}from"react";import{
|
|
1
|
+
import{a as e}from"./chunks/_tslib-35bb891d.js";import{jsxs as t,jsx as n,Fragment as i}from"react/jsx-runtime";import{useState as s,useLayoutEffect as r,useRef as a,useEffect as l,useCallback as o}from"react";import{useYooptaEditor as c,useElementSelected as d,useBlockSelected as m,useYooptaPluginOptions as h,Elements as p,Blocks as u}from"@yoopta/editor";import{detectProvider as g,getSupportedProviders as b,isEmbedUrl as v,parseEmbedUrl as f,calculateEmbedDimensions as x}from"@yoopta/embed";import{Editor as y,Element as j}from"slate";import{B as w}from"./chunks/button-f335deaa.js";import{I as k}from"./chunks/input-b2431223.js";import{c as O}from"./chunks/utils-3345eade.js";import{L as N,A as C,a as E,b as R,R as z}from"./chunks/index-87b75648.js";import{c as I}from"./chunks/createLucideIcon-8605f860.js";import{C as U}from"./chunks/code-d31bdce0.js";import{P}from"./chunks/play-998f23d2.js";import{u as D,F as L,T as S,a as H,b as W,c as _,R as A}from"./chunks/tooltip-5defff1d.js";import{C as B,c as T}from"./chunks/index-0bca29df.js";import{S as F}from"./chunks/separator-f4e74aca.js";import{E as M}from"./chunks/external-link-1579dd7f.js";import{T as Y}from"./chunks/trash-2-f36597ff.js";import{o as $,f as q,s as V,b as G}from"./chunks/index-371259c9.js";import"react-dom";import"./chunks/index-17323747.js";import"./chunks/index-91a5b8d5.js";import"./chunks/index-ce60ba41.js";import"./chunks/index-bd6363d4.js";import"./chunks/index-ff0e3962.js";import"./chunks/index-1674c2c8.js";import"./chunks/index-a5cba5f7.js";import"./chunks/index-70f4e709.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license lucide-react v0.294.0 - ISC
|
|
4
4
|
*
|
|
5
5
|
* This source code is licensed under the ISC license.
|
|
6
6
|
* See the LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/const K=I("Map",[["polygon",{points:"3 6 9 3 15 6 21 3 21 18 15 21 9 18 3 21",key:"ok2ie8"}],["line",{x1:"9",x2:"9",y1:"3",y2:"18",key:"w34qz5"}],["line",{x1:"15",x2:"15",y1:"6",y2:"21",key:"volv9a"}]]),J=I("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),Q=e=>{switch(e){case"youtube":case"vimeo":case"dailymotion":case"wistia":case"loom":return n(D,{className:"h-3 w-3"});case"spotify":case"soundcloud":return n(J,{className:"h-3 w-3"});case"codepen":case"codesandbox":return n(U,{className:"h-3 w-3"});case"google-maps":return n(K,{className:"h-3 w-3"});default:return n(O,{className:"h-3 w-3"})}},X=({name:e,type:n})=>t("span",Object.assign({className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:[Q(n),e]})),Z=({onInsertUrl:e})=>{const[i,r]=s(""),[a,l]=s(!1),[o,c]=s(null),d=()=>{i.trim()&&(e(i.trim()),r(""),l(!1),c(null))};return t("div",Object.assign({className:"space-y-3"},{children:[t("div",Object.assign({className:"space-y-2"},{children:[n(k,{placeholder:"Paste a URL to embed (YouTube, Vimeo, Twitter, Spotify, etc.)",value:i,onChange:e=>(e=>{var t;if(r(e),e.trim()){const n=v(e.trim());if(l(n),n){const n=g(e.trim()),i=b().find(e=>e.type===n);c(null!==(t=null==i?void 0:i.name)&&void 0!==t?t:null)}else c(null)}else l(!1),c(null)})(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&a&&(e.preventDefault(),d())},className:"h-10"}),i.trim()&&n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:a?t("span",Object.assign({className:"flex items-center gap-1.5 text-green-600 dark:text-green-400"},{children:[Q(g(i.trim())),o," detected"]})):n("span",Object.assign({className:"text-destructive"},{children:"Unsupported URL. Try YouTube, Vimeo, Twitter, Spotify, Figma, CodePen, etc."}))}))]})),n(w,Object.assign({className:"w-full",onClick:d,disabled:!i.trim()||!a},{children:a?`Embed ${o}`:"Embed content"}))]}))},ee=()=>{const e=b().filter(e=>"unknown"!==e.type);return t("div",Object.assign({className:"mt-4 space-y-2"},{children:[n("p",Object.assign({className:"text-xs text-muted-foreground text-center"},{children:"Supported providers:"})),t("div",Object.assign({className:"flex flex-wrap gap-1.5 justify-center"},{children:[e.slice(0,8).map(e=>n(X,{name:e.name,type:e.type},e.type)),e.length>8&&t("span",Object.assign({className:"inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:["+",e.length-8," more"]}))]}))]}))},te=({onInsertUrl:e,className:i,attributes:s,children:r})=>t("div",Object.assign({className:N("mt-2 relative rounded-lg border bg-background overflow-hidden",i)},s,{contentEditable:!1},{children:[t("div",Object.assign({className:"p-6"},{children:[t("div",Object.assign({className:"flex flex-col items-center gap-4"},{children:[n("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:n(O,{className:"h-6 w-6 text-muted-foreground"})})),t("div",Object.assign({className:"text-center"},{children:[n("p",Object.assign({className:"text-sm font-medium"},{children:"Embed content"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Paste a URL from supported platforms"}))]}))]})),n("div",Object.assign({className:"mt-6 max-w-md mx-auto"},{children:n(Z,{onInsertUrl:e})})),n(ee,{})]})),r]})),ne=({referenceRef:e,elementProps:a,onUpdate:l,onReplace:o,onDelete:c,onCopy:d})=>{var m;const[h,p]=s(!1),[u,g]=s(!1),b=a.provider&&a.provider.type,v="alignment"in a,{refs:f,floatingStyles:y}=P({placement:"top-end",strategy:"absolute",middleware:[$(8),q({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),V({padding:10})],whileElementsMounted:G});r(()=>{const t=e.current;t&&(f.setReference(t),g(!0))},[e,f]),r(()=>{if(u){const e=requestAnimationFrame(()=>{p(!0)});return()=>cancelAnimationFrame(e)}},[u]);return u?n(L,{children:n("div",Object.assign({ref:f.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:N("pointer-events-auto","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",h?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:y},{children:t(S,Object.assign({delayDuration:0},{children:[v&&t("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"left"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"left"})},{children:n(C,{className:"h-4 w-4"})}))})),n(W,{children:"Align left"})]}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"center"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"center"})},{children:n(R,{className:"h-4 w-4"})}))})),n(W,{children:"Align center"})]}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"right"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"right"})},{children:n(E,{className:"h-4 w-4"})}))})),n(W,{children:"Align right"})]})]})),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:o},{children:n(_,{className:"h-4 w-4"})}))})),n(W,{children:"Replace"})]}),b&&(null===(m=a.provider)||void 0===m?void 0:m.url)&&t(i,{children:[t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;d?d():(null===(e=a.provider)||void 0===e?void 0:e.url)&&T(a.provider.url)}},{children:n(F,{className:"h-4 w-4"})}))})),n(W,{children:"Copy URL"})]}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;(null===(e=a.provider)||void 0===e?void 0:e.url)&&window.open(a.provider.url,"_blank")}},{children:n(M,{className:"h-4 w-4"})}))})),n(W,{children:"Open in new tab"})]})]}),n(B,{orientation:"vertical",className:"h-4"}),t(A,{children:[n(H,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:c},{children:n(Y,{className:"h-4 w-4"})}))})),n(W,{children:"Delete"})]})]}))}))}):null},ie=({blockId:i,attributes:r,children:o,elementProps:h,onUpdate:p,onDelete:u,onReplace:g,pluginOptions:b})=>{var v,f,y,x,j;const[w,k]=s(h.sizes),{isElementSelected:O}=c(),C=d({blockId:i}),R=O&&C,E=a(null),I=m(),[U,D]=s(()=>{var e,t;const n=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,i=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:n;return{maxWidth:"number"==typeof i?i:n,maxHeight:0}});l(()=>{const e=()=>{var e,t;const n=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,i=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:n;D({maxWidth:"number"==typeof i?i:n,maxHeight:0})};e();const t=new ResizeObserver(e);return I.refElement&&t.observe(I.refElement),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}},[I,b]);const P=h.provider,L=null!==(v=null==P?void 0:P.embedUrl)&&void 0!==v?v:"",S={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(f=h.alignment)&&void 0!==f?f:"center"];return t("div",Object.assign({},r,{className:N("group/embed mt-4 relative transition-all w-full flex",S)},{children:[t("div",Object.assign({className:"relative",contentEditable:!1,ref:E},{children:[n(z,Object.assign({style:{position:"relative",outline:R?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:R?"hsl(var(--primary))":"none",padding:2},onResize:(e,t,n)=>{const i=parseInt(n.style.width,10),s=parseInt(n.style.height,10);k({width:i,height:s})},onResizeStop:(e,t,n)=>{const i=parseInt(n.style.width,10),s=parseInt(n.style.height,10);p({sizes:{width:i,height:s}})},lockAspectRatio:!0,minWidth:200,minHeight:150,maxWidth:U.maxWidth-8||void 0,maxHeight:U.maxHeight||void 0,enableResizing:!!R&&{bottom:!1,bottomLeft:!1,bottomRight:!1,left:!0,right:!0,top:!1,topLeft:!1,topRight:!1},disableDragging:!0,resizeHandleStyles:{left:{width:"auto",height:"40px",left:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"},right:{width:"auto",height:"40px",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"}},resizeHandleComponent:{left:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"}),right:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"})},className:N("rounded-sm overflow-hidden")},{children:n("iframe",{title:null!==(x=null===(y=null==P?void 0:P.meta)||void 0===y?void 0:y.title)&&void 0!==x?x:`Embedded content from ${null!==(j=null==P?void 0:P.type)&&void 0!==j?j:"unknown"}`,src:L,width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,className:"w-full h-full",style:{aspectRatio:`${w.width} / ${w.height}`}})})),R&&n(ne,{referenceRef:E,elementProps:h,onUpdate:p,onReplace:g,onDelete:u,onCopy:()=>e(void 0,void 0,void 0,function*(){if(null==P?void 0:P.url)try{const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(P.url)}catch(e){}})})]})),o]}))},se={embed:{render:({element:t,attributes:i,children:s,blockId:r})=>{var a;const l=m(),c=h("Embed"),d=o(e=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),e)})},[l,r,t.props]),g=o(()=>e(void 0,void 0,void 0,function*(){const e=u.getBlockSlate(l,{id:r});if(!e)return;const n=p.getElementPath(l,{blockId:r,element:t});if(!n)return;const i=n?x.parent(e,n):void 0;i&&j.isElement(i[0])&&!x.isEditor(i[0])?p.deleteElement(l,{blockId:r,type:"embed",path:n}):u.deleteBlock(l,{blockId:r,focus:!0})}),[l,r,t]),b=o(()=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),{provider:null})})},[l,r,t.props]),v=o(t=>e(void 0,void 0,void 0,function*(){var e;const n=f(t);if(n){const t=null!==(e=null==c?void 0:c.maxWidth)&&void 0!==e?e:650,{width:i,height:s}=y(n.type,t);d({provider:n,sizes:{width:i,height:s}})}}),[d,c]),w=t;return(null===(a=w.props)||void 0===a?void 0:a.provider)?n(ie,Object.assign({blockId:r,elementId:t.id,onUpdate:d,onDelete:g,attributes:i,onReplace:b,elementProps:w.props,pluginOptions:c},{children:s})):l.readOnly?null:n(te,Object.assign({onInsertUrl:v,attributes:i},{children:s}))}}};
|
|
7
|
+
*/const K=I("Map",[["polygon",{points:"3 6 9 3 15 6 21 3 21 18 15 21 9 18 3 21",key:"ok2ie8"}],["line",{x1:"9",x2:"9",y1:"3",y2:"18",key:"w34qz5"}],["line",{x1:"15",x2:"15",y1:"6",y2:"21",key:"volv9a"}]]),J=I("Music",[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]]),Q=e=>{switch(e){case"youtube":case"vimeo":case"dailymotion":case"wistia":case"loom":return n(P,{className:"h-3 w-3"});case"spotify":case"soundcloud":return n(J,{className:"h-3 w-3"});case"codepen":case"codesandbox":return n(U,{className:"h-3 w-3"});case"google-maps":return n(K,{className:"h-3 w-3"});default:return n(N,{className:"h-3 w-3"})}},X=({name:e,type:n})=>t("span",Object.assign({className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:[Q(n),e]})),Z=({onInsertUrl:e})=>{const[i,r]=s(""),[a,l]=s(!1),[o,c]=s(null),d=()=>{i.trim()&&(e(i.trim()),r(""),l(!1),c(null))};return t("div",Object.assign({className:"space-y-3"},{children:[t("div",Object.assign({className:"space-y-2"},{children:[n(k,{placeholder:"Paste a URL to embed (YouTube, Vimeo, Twitter, Spotify, etc.)",value:i,onChange:e=>(e=>{var t;if(r(e),e.trim()){const n=v(e.trim());if(l(n),n){const n=g(e.trim()),i=b().find(e=>e.type===n);c(null!==(t=null==i?void 0:i.name)&&void 0!==t?t:null)}else c(null)}else l(!1),c(null)})(e.target.value),onKeyDown:e=>{"Enter"===e.key&&i.trim()&&a&&(e.preventDefault(),d())},className:"h-10"}),i.trim()&&n("div",Object.assign({className:"text-xs text-muted-foreground"},{children:a?t("span",Object.assign({className:"flex items-center gap-1.5 text-green-600 dark:text-green-400"},{children:[Q(g(i.trim())),o," detected"]})):n("span",Object.assign({className:"text-destructive"},{children:"Unsupported URL. Try YouTube, Vimeo, Twitter, Spotify, Figma, CodePen, etc."}))}))]})),n(w,Object.assign({className:"w-full",onClick:d,disabled:!i.trim()||!a},{children:a?`Embed ${o}`:"Embed content"}))]}))},ee=()=>{const e=b().filter(e=>"unknown"!==e.type);return t("div",Object.assign({className:"mt-4 space-y-2"},{children:[n("p",Object.assign({className:"text-xs text-muted-foreground text-center"},{children:"Supported providers:"})),t("div",Object.assign({className:"flex flex-wrap gap-1.5 justify-center"},{children:[e.slice(0,8).map(e=>n(X,{name:e.name,type:e.type},e.type)),e.length>8&&t("span",Object.assign({className:"inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium bg-muted text-muted-foreground"},{children:["+",e.length-8," more"]}))]}))]}))},te=({onInsertUrl:e,className:i,attributes:s,children:r})=>t("div",Object.assign({className:O("mt-2 relative rounded-lg border bg-background overflow-hidden",i)},s,{contentEditable:!1},{children:[t("div",Object.assign({className:"p-6"},{children:[t("div",Object.assign({className:"flex flex-col items-center gap-4"},{children:[n("div",Object.assign({className:"rounded-lg bg-muted p-3"},{children:n(N,{className:"h-6 w-6 text-muted-foreground"})})),t("div",Object.assign({className:"text-center"},{children:[n("p",Object.assign({className:"text-sm font-medium"},{children:"Embed content"})),n("p",Object.assign({className:"text-xs text-muted-foreground"},{children:"Paste a URL from supported platforms"}))]}))]})),n("div",Object.assign({className:"mt-6 max-w-md mx-auto"},{children:n(Z,{onInsertUrl:e})})),n(ee,{})]})),r]})),ne=({referenceRef:e,elementProps:a,onUpdate:l,onReplace:o,onDelete:d,onCopy:m})=>{var h;const[p,u]=s(!1),[g,b]=s(!1),v=a.provider&&a.provider.type,f="alignment"in a,x=c(),{refs:y,floatingStyles:j}=D({placement:"top-end",strategy:"absolute",middleware:[$(8),q({fallbackPlacements:["bottom-end","top-start","bottom-start"],padding:10}),V({padding:10})],whileElementsMounted:G});r(()=>{const t=e.current;t&&(y.setReference(t),b(!0))},[e,y]),r(()=>{if(g){const e=requestAnimationFrame(()=>{u(!0)});return()=>cancelAnimationFrame(e)}},[g]);return g?n(L,Object.assign({id:"embed-inline-toolbar",root:x.refElement},{children:n("div",Object.assign({ref:y.setFloating,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:e=>e.stopPropagation(),className:O("pointer-events-auto","flex items-center gap-1 rounded-lg border bg-background/95 backdrop-blur-sm p-1 shadow-lg","transition-opacity duration-200 ease-out",p?"opacity-100 translate-y-0":"opacity-0 translate-y-2"),style:j},{children:t(S,Object.assign({delayDuration:0},{children:[f&&t("div",Object.assign({className:"flex items-center gap-0.5 border-r pr-1"},{children:[t(H,{children:[n(W,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"left"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"left"})},{children:n(C,{className:"h-4 w-4"})}))})),n(_,{children:"Align left"})]}),t(H,{children:[n(W,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"center"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"center"})},{children:n(E,{className:"h-4 w-4"})}))})),n(_,{children:"Align center"})]}),t(H,{children:[n(W,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"right"===a.alignment?"secondary":"ghost",size:"icon",className:"h-7 w-7",onClick:()=>l({alignment:"right"})},{children:n(R,{className:"h-4 w-4"})}))})),n(_,{children:"Align right"})]})]})),t(H,{children:[n(W,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:o},{children:n(A,{className:"h-4 w-4"})}))})),n(_,{children:"Replace"})]}),v&&(null===(h=a.provider)||void 0===h?void 0:h.url)&&t(i,{children:[t(H,{children:[n(W,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;m?m():(null===(e=a.provider)||void 0===e?void 0:e.url)&&T(a.provider.url)}},{children:n(B,{className:"h-4 w-4"})}))})),n(_,{children:"Copy URL"})]}),t(H,{children:[n(W,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{var e;(null===(e=a.provider)||void 0===e?void 0:e.url)&&window.open(a.provider.url,"_blank")}},{children:n(M,{className:"h-4 w-4"})}))})),n(_,{children:"Open in new tab"})]})]}),n(F,{orientation:"vertical",className:"h-4"}),t(H,{children:[n(W,Object.assign({asChild:!0},{children:n(w,Object.assign({variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive hover:bg-destructive/10 hover:text-destructive",onClick:d},{children:n(Y,{className:"h-4 w-4"})}))})),n(_,{children:"Delete"})]})]}))}))})):null},ie=({blockId:i,attributes:r,children:o,elementProps:h,onUpdate:p,onDelete:u,onReplace:g,pluginOptions:b})=>{var v,f,x,y,j;const[w,k]=s(h.sizes),{isElementSelected:N}=d(),C=m({blockId:i}),E=N&&C,R=a(null),I=c(),[U,P]=s(()=>{var e,t;const n=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,i=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:n;return{maxWidth:"number"==typeof i?i:n,maxHeight:0}});l(()=>{const e=()=>{var e,t;const n=(null===(e=I.refElement)||void 0===e?void 0:e.getBoundingClientRect().width)||0,i=null!==(t=null==b?void 0:b.maxWidth)&&void 0!==t?t:n;P({maxWidth:"number"==typeof i?i:n,maxHeight:0})};e();const t=new ResizeObserver(e);return I.refElement&&t.observe(I.refElement),window.addEventListener("resize",e),()=>{t.disconnect(),window.removeEventListener("resize",e)}},[I,b]);const D=h.provider,L=null!==(v=null==D?void 0:D.embedUrl)&&void 0!==v?v:"",S={left:"justify-start",center:"justify-center",right:"justify-end"}[null!==(f=h.alignment)&&void 0!==f?f:"center"];return t("div",Object.assign({},r,{className:O("group/embed mt-4 relative transition-all w-full flex",S)},{children:[t("div",Object.assign({className:"relative",contentEditable:!1,ref:R},{children:[n(z,Object.assign({style:{position:"relative",outline:E?".125rem solid rgba(0, 0, 0, 0)":"none",outlineColor:E?"hsl(var(--primary))":"none",padding:2},onResize:(e,t,n)=>{const i=parseInt(n.style.width,10),s=parseInt(n.style.height,10);k({width:i,height:s})},onResizeStop:(e,t,n)=>{const i=parseInt(n.style.width,10),s=parseInt(n.style.height,10);p({sizes:{width:i,height:s}})},lockAspectRatio:!0,minWidth:200,minHeight:150,maxWidth:U.maxWidth-8||void 0,maxHeight:U.maxHeight||void 0,enableResizing:!!E&&{bottom:!1,bottomLeft:!1,bottomRight:!1,left:!0,right:!0,top:!1,topLeft:!1,topRight:!1},disableDragging:!0,resizeHandleStyles:{left:{width:"auto",height:"40px",left:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"},right:{width:"auto",height:"40px",right:"5px",top:"50%",transform:"translateY(-50%)",cursor:"ew-resize"}},resizeHandleComponent:{left:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"}),right:n("div",{className:"h-10 w-1.5 rounded-full bg-white border border-border shadow-[0_0_4px_rgba(0,0,0,0.3)]"})},className:O("rounded-sm overflow-hidden")},{children:n("iframe",{title:null!==(y=null===(x=null==D?void 0:D.meta)||void 0===x?void 0:x.title)&&void 0!==y?y:`Embedded content from ${null!==(j=null==D?void 0:D.type)&&void 0!==j?j:"unknown"}`,src:L,width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,className:"w-full h-full",style:{aspectRatio:`${w.width} / ${w.height}`}})})),E&&n(ne,{referenceRef:R,elementProps:h,onUpdate:p,onReplace:g,onDelete:u,onCopy:()=>e(void 0,void 0,void 0,function*(){if(null==D?void 0:D.url)try{const{default:e}=yield import("./chunks/index-0bca29df.js").then(function(e){return e.i});e(D.url)}catch(e){}})})]})),o]}))},se={embed:{render:({element:t,attributes:i,children:s,blockId:r})=>{var a;const l=c(),d=h("Embed"),m=o(e=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),e)})},[l,r,t.props]),g=o(()=>e(void 0,void 0,void 0,function*(){const e=u.getBlockSlate(l,{id:r});if(!e)return;const n=p.getElementPath(l,{blockId:r,element:t});if(!n)return;const i=n?y.parent(e,n):void 0;i&&j.isElement(i[0])&&!y.isEditor(i[0])?p.deleteElement(l,{blockId:r,type:"embed",path:n}):u.deleteBlock(l,{blockId:r,focus:!0})}),[l,r,t]),b=o(()=>{p.updateElement(l,{blockId:r,type:"embed",props:Object.assign(Object.assign({},t.props),{provider:null})})},[l,r,t.props]),v=o(t=>e(void 0,void 0,void 0,function*(){var e;const n=f(t);if(n){const t=null!==(e=null==d?void 0:d.maxWidth)&&void 0!==e?e:650,{width:i,height:s}=x(n.type,t);m({provider:n,sizes:{width:i,height:s}})}}),[m,d]),w=t;return(null===(a=w.props)||void 0===a?void 0:a.provider)?n(ie,Object.assign({blockId:r,elementId:t.id,onUpdate:m,onDelete:g,attributes:i,onReplace:b,elementProps:w.props,pluginOptions:d},{children:s})):l.readOnly?null:n(te,Object.assign({onInsertUrl:v,attributes:i},{children:s}))}}};
|
|
8
8
|
/**
|
|
9
9
|
* @license lucide-react v0.294.0 - ISC
|
|
10
10
|
*
|