seam-react 0.8.0 → 0.9.1
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/Select.d.ts +37 -10
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1350 -998
- package/dist/index.js.map +1 -1
- package/dist/motion.d.ts +11 -0
- package/dist/styles.cjs +238 -20
- package/dist/styles.cjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.js +236 -18
- package/dist/styles.js.map +1 -1
- package/package.json +1 -1
package/dist/Select.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode, type RefAttributes } from "react";
|
|
2
2
|
export type SelectSize = "sm" | "md" | "lg";
|
|
3
3
|
export interface SelectOption {
|
|
4
4
|
/** 提交给 onValueChange 的稳定值。 */
|
|
@@ -7,16 +7,12 @@ export interface SelectOption {
|
|
|
7
7
|
label?: ReactNode;
|
|
8
8
|
/** 是否禁止选择该项。 */
|
|
9
9
|
disabled?: boolean;
|
|
10
|
+
/** 子选项;提供 children 的节点只作为分组节点,不提交 value。 */
|
|
11
|
+
children?: Array<SelectOption>;
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
interface SelectBaseProps extends Omit<HTMLAttributes<HTMLElement>, "children" | "value" | "onChange" | "aria-expanded" | "defaultValue"> {
|
|
12
14
|
/** 可选项;label 用于展示,value 用于提交。 */
|
|
13
15
|
options: Array<SelectOption>;
|
|
14
|
-
/** 受控选中值。 */
|
|
15
|
-
value?: string | null;
|
|
16
|
-
/** 非受控模式下的初始值。 */
|
|
17
|
-
defaultValue?: string | null;
|
|
18
|
-
/** 选中值变化时触发。 */
|
|
19
|
-
onValueChange?: (value: string) => void;
|
|
20
16
|
/** 未选择时的展示文本。 */
|
|
21
17
|
placeholder?: string;
|
|
22
18
|
/** 控件尺寸。 */
|
|
@@ -27,7 +23,38 @@ export interface SelectProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement
|
|
|
27
23
|
emptyText?: string;
|
|
28
24
|
/** 标记选择值无效,使用共享 invalid 样式。 */
|
|
29
25
|
invalid?: boolean;
|
|
26
|
+
/** 标记选项数据正在加载;请求由调用方管理。 */
|
|
27
|
+
loading?: boolean;
|
|
28
|
+
/** loading 时的提示文本。 */
|
|
29
|
+
loadingText?: string;
|
|
30
|
+
/** 是否显示一键清空按钮。 */
|
|
31
|
+
clear?: boolean;
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
export interface SelectSingleProps extends SelectBaseProps {
|
|
34
|
+
multiple?: false;
|
|
35
|
+
value?: string | null;
|
|
36
|
+
defaultValue?: string | null;
|
|
37
|
+
onValueChange?: (value: string) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface SelectMultipleProps extends SelectBaseProps {
|
|
40
|
+
multiple: true;
|
|
41
|
+
value?: ReadonlyArray<string>;
|
|
42
|
+
defaultValue?: ReadonlyArray<string>;
|
|
43
|
+
onValueChange?: (value: Array<string>) => void;
|
|
44
|
+
}
|
|
45
|
+
export type SelectProps<Multiple extends boolean = false> = SelectBaseProps & (Multiple extends true ? {
|
|
46
|
+
multiple: true;
|
|
47
|
+
value?: ReadonlyArray<string>;
|
|
48
|
+
defaultValue?: ReadonlyArray<string>;
|
|
49
|
+
onValueChange?: (value: Array<string>) => void;
|
|
50
|
+
} : {
|
|
51
|
+
multiple?: false;
|
|
52
|
+
value?: string | null;
|
|
53
|
+
defaultValue?: string | null;
|
|
54
|
+
onValueChange?: (value: string) => void;
|
|
55
|
+
});
|
|
56
|
+
declare const Select: {
|
|
57
|
+
(props: SelectSingleProps & RefAttributes<HTMLDivElement>): ReactElement | null;
|
|
58
|
+
(props: SelectMultipleProps & RefAttributes<HTMLDivElement>): ReactElement | null;
|
|
59
|
+
};
|
|
33
60
|
export { Select };
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),a=require("react"),C=require("seam-hooks"),I=require("motion/react"),V=require("react-dom");function T(...t){return t.filter(Boolean).join(" ")}const G=a.forwardRef(function({variant:e="primary",size:n="md",loading:o=!1,iconOnly:s=!1,type:l="button",className:c,children:r,...p},u){return i.jsxs("button",{...p,ref:u,type:l,className:T("uk-button",c),"data-variant":e,"data-size":n,"data-loading":o?"true":void 0,"data-icon-only":s?"true":void 0,disabled:p.disabled||o,"aria-busy":o||void 0,children:[o?i.jsx("span",{className:"uk-button__spinner","aria-hidden":"true"}):null,r]})}),ne=a.forwardRef(function({checked:e,defaultChecked:n,onCheckedChange:o,disabled:s,className:l,children:c,id:r,...p},u){const d=a.useId(),m=r??d,[f,v]=C.useControllableState({value:e,defaultValue:n??!1,onChange:o});return i.jsxs("label",{className:T("uk-checkbox",l),"data-disabled":s?"true":void 0,htmlFor:m,children:[i.jsx("input",{...p,ref:u,id:m,type:"checkbox",className:"uk-checkbox__input",checked:f,disabled:s,onChange:h=>{s||v(h.target.checked)}}),i.jsx("span",{className:"uk-checkbox__box","aria-hidden":"true",children:i.jsx("svg",{className:"uk-checkbox__check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3.2,strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M4 12.5 L9.5 18 L20 7",pathLength:1})})}),c?i.jsx("span",{className:"uk-checkbox__label",children:c}):null]})});ne.displayName="CheckBox";const H=[.23,1,.32,1],Le=[.77,0,.175,1],Q={type:"spring",bounce:0,duration:.3},Z={type:"spring",bounce:.04,duration:.38},q={type:"spring",bounce:.08,duration:.34},oe={duration:.2,ease:Le},re={duration:.12,ease:H},Me={layout:{type:"spring",bounce:0,duration:.22},opacity:{duration:.12,ease:H},scale:{duration:.12,ease:H}},M={duration:.12,ease:H},se=a.createContext(null);function U(t){const e=a.useContext(se);if(!e)throw new Error(`<${t}> must be rendered inside <Select>`);return e}const Oe=()=>()=>{},$e=()=>!0,Ae=()=>!1;function ee(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function Be(t,e,n){return n<e?e:Math.min(Math.max(t,e),n)}function He(t){return t==="bottom"?"center top":"center bottom"}function Ve({options:t,value:e,defaultValue:n=null,onValueChange:o,children:s}){const l=a.useId(),[c,r]=C.useControllableState({value:e,defaultValue:n,onChange:y=>{y!==null&&o?.(y)}}),[p,u]=a.useState(!1),d=t.findIndex(y=>y.value===c),[m,f]=a.useState(null),v=m??Math.max(d,0),h=a.useCallback(y=>{f(y)},[]),x=C.useEventCallback(y=>{const k=t[y];!k||k.disabled||(r(k.value),u(!1),f(null))}),g=a.useMemo(()=>({value:c,activeIndex:v,open:p,setOpen:u,setActiveIndex:h,commit:x,triggerId:`${l}-trigger`,contentId:`${l}-content`,options:t}),[v,l,x,c,p,t,h]);return i.jsx(se.Provider,{value:g,children:s})}function A(t,e,n,o=!0){const s=t.length;if(s===0)return-1;for(let l=1;l<=s;l+=1){const c=o?(e+n*l+s*l)%s:e+n*l;if(c<0||c>=s)break;if(!t[c]?.disabled)return c}return e}const qe=a.forwardRef(function({className:e,placeholder:n="请选择",onPointerDown:o,onKeyDown:s,...l},c){const r=U("Select.Trigger"),p=r.options.find(x=>x.value===r.value),u=l.disabled,d=a.useRef({search:"",timer:null}),m=a.useCallback(()=>{d.current.timer&&(clearTimeout(d.current.timer),d.current.timer=null),d.current.search=""},[]);a.useEffect(()=>m,[m]);const f=C.useEventCallback(x=>{const g=d.current;g.timer&&clearTimeout(g.timer),g.search+=x.toLowerCase(),g.timer=setTimeout(m,500);const y=r.options.map(j=>{const R=j.label;return(typeof R=="string"?R:j.value).toLowerCase()}),k=r.open&&r.activeIndex>=0?r.activeIndex+1:0,b=Array.from({length:y.length},(j,R)=>(k+R)%y.length),w=b.find(j=>!r.options[j]?.disabled&&y[j]?.startsWith(g.search)),E=b.find(j=>!r.options[j]?.disabled&&y[j]?.includes(g.search)),_=w??E;_!==void 0&&(r.open?r.setActiveIndex(_):r.commit(_))}),v=C.useEventCallback(x=>{u||r.setOpen(!r.open)}),h=C.useEventCallback(x=>{if(!u){if(x.key.length===1&&!x.metaKey&&!x.ctrlKey&&!x.altKey){x.preventDefault(),f(x.key);return}if(!r.open){["ArrowDown","ArrowUp","Enter"," "].includes(x.key)&&(x.preventDefault(),r.setOpen(!0),r.setActiveIndex(r.activeIndex>=0?r.activeIndex:A(r.options,-1,1)));return}if(x.key==="Escape"||x.key==="Tab"){r.setOpen(!1),x.currentTarget.focus();return}if(x.key==="Enter"||x.key===" "){x.preventDefault(),r.commit(r.activeIndex),x.currentTarget.focus();return}if(x.key==="ArrowDown"){x.preventDefault(),r.setActiveIndex(A(r.options,r.activeIndex,1));return}if(x.key==="ArrowUp"){x.preventDefault(),r.setActiveIndex(A(r.options,r.activeIndex,-1));return}if(x.key==="Home"||x.key==="End"){x.preventDefault();const g=x.key==="Home"?1:-1,y=x.key==="Home"?-1:r.options.length;r.setActiveIndex(A(r.options,y,g,!1))}}});return i.jsxs("button",{...l,ref:c,id:r.triggerId,type:"button",role:"combobox","aria-expanded":r.open,"aria-haspopup":"listbox","aria-controls":r.open?r.contentId:void 0,"aria-activedescendant":r.open&&r.options[r.activeIndex]?`${r.contentId}-option-${r.activeIndex}`:void 0,"data-size":"md",className:T("uk-select__trigger",e),onPointerDown:ee(o,v),onKeyDown:ee(s,h),children:[i.jsx("span",{className:"uk-select__value",children:p?.label??r.value??n}),i.jsx("span",{"aria-hidden":"true",className:"uk-select__chevron"})]})});function ze(t,e){const[n,o]=a.useState(null),s=a.useCallback(()=>{const l=e.current;if(!t||!l)return;const c=t.getBoundingClientRect(),r=l.getBoundingClientRect(),p=window.innerHeight-c.bottom-8,u=c.top-8,d=p>=Math.min(r.height,320)||p>=u?"bottom":"top",m=d==="bottom"?c.bottom+6:c.top-r.height-6,f=Be(c.left,8,Math.max(8,window.innerWidth-c.width-8));o({x:f,y:m,side:d})},[e,t]);return a.useLayoutEffect(()=>{if(!t)return;s(),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(s);return l?.observe(t),l?.observe(e.current??t),()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0),l?.disconnect()}},[e,t,s]),n}function Ke({emptyText:t}){const e=U("Select.Content"),n=e.triggerId,o=document.getElementById(n),s=a.useRef(null),l=I.useReducedMotion()??!1,c=I.useIsPresent(),r=ze(o,s),p=a.useSyncExternalStore(Oe,$e,Ae);if(a.useEffect(()=>{if(!e.open)return;const d=v=>{const h=v.target;h instanceof Node&&(o?.contains(h)||s.current?.contains(h)||(e.setOpen(!1),o?.focus()))};document.addEventListener("pointerdown",d,!0);const m=v=>{v.key==="Escape"&&(e.setOpen(!1),o?.focus())},f=()=>{e.setOpen(!1)};return document.addEventListener("keydown",m,!0),window.addEventListener("blur",f),()=>{document.removeEventListener("pointerdown",d,!0),document.removeEventListener("keydown",m,!0),window.removeEventListener("blur",f)}},[e,o]),!p)return null;const u=o?.closest("dialog")??document.body;return V.createPortal(i.jsx("div",{ref:s,className:"uk-select","data-side":r?.side??"bottom","data-state":c?"open":"closed","aria-hidden":c?void 0:!0,style:{left:r?`${r.x}px`:0,top:r?`${r.y}px`:0,"--uk-select-width":`${o?.offsetWidth??220}px`,visibility:r?"visible":"hidden"},children:i.jsx(I.motion.div,{className:"uk-select__surface",style:{transformOrigin:He(r?.side??"bottom")},initial:l?{opacity:0}:{opacity:0,scale:.97,y:-4},animate:l?{opacity:1}:{opacity:1,scale:1,y:0},exit:l?{opacity:0}:{opacity:0,scale:.97,y:-2},transition:l?M:oe,children:e.options.length===0?i.jsx("p",{className:"uk-select__empty",children:t}):i.jsx(I.LayoutGroup,{id:`select-${e.contentId}`,children:i.jsx("ul",{id:e.contentId,className:"uk-select__list",role:"listbox","aria-labelledby":n,children:e.options.map((d,m)=>i.jsxs("li",{id:`${e.contentId}-option-${m}`,role:"option","aria-disabled":d.disabled||void 0,"aria-selected":d.value===e.value,"data-disabled":d.disabled||void 0,"data-selected":d.value===e.value||void 0,"data-active":m===e.activeIndex||void 0,className:"uk-select__option",onPointerEnter:f=>{f.pointerType==="mouse"&&!d.disabled&&e.setActiveIndex(m)},onClick:f=>{f.stopPropagation(),e.commit(m)},children:[i.jsx(I.AnimatePresence,{initial:!1,children:m===e.activeIndex?i.jsx(I.motion.span,{className:"uk-select__option-highlight","data-slot":"select-active-highlight",layoutId:`${e.contentId}-active`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:l?{duration:0}:q}):null}),i.jsx("span",{className:"uk-select__option-label",children:d.label??d.value}),i.jsx("span",{"aria-hidden":"true",className:"uk-select__check"})]},d.value))})})})}),u)}const Fe=a.forwardRef(function({options:e,value:n,defaultValue:o,onValueChange:s,placeholder:l,size:c="md",disabled:r,invalid:p,emptyText:u="暂无可选项",className:d,...m},f){return i.jsxs(Ve,{options:e,value:n,defaultValue:o,onValueChange:s,children:[i.jsx(qe,{...m,ref:f,placeholder:l,disabled:r,"aria-invalid":p||void 0,"data-size":c,className:d}),i.jsx(Ge,{emptyText:u})]})});function Ge({emptyText:t}){const e=U("Select.Content");return i.jsx(I.AnimatePresence,{children:e.open?i.jsx(Ke,{emptyText:t},"select-layer"):null})}const Ue=a.forwardRef(function({inputSize:e="md",invalid:n=!1,className:o,"aria-invalid":s,...l},c){return i.jsx("input",{...l,ref:c,className:T("uk-input",o),"data-size":e,"aria-invalid":n?!0:s})}),Xe=a.forwardRef(function({checked:e,defaultChecked:n,onCheckedChange:o,disabled:s,className:l,children:c,id:r,...p},u){const d=a.useId(),m=r??d,f=I.useReducedMotion()??!1,v=a.useRef(!1),h=a.useRef(null),[x,g]=C.useControllableState({value:e,defaultValue:n??!1,onChange:o}),y=I.useMotionValue(x?16:0);a.useEffect(()=>{if(h.current)return;const b=I.animate(y,x?16:0,f?{duration:0}:Q);return()=>b.stop()},[x,f,y]);const k=b=>{const w=h.current;if(!(!w||w.pointerId!==b.pointerId)){if(w.moved){const E=w.samples[0],_=w.samples[w.samples.length-1],j=E&&_?Math.max(_.time-E.time,1):1,R=E&&_?(_.x-E.x)/j*1e3:0,P=Math.abs(R)>220?R>0:y.get()>=8;v.current=!0,h.current=null,g(P),I.animate(y,P?16:0,f?{duration:0}:{...Q,velocity:R}),window.setTimeout(()=>{v.current=!1},0)}else h.current=null;b.currentTarget.hasPointerCapture(b.pointerId)&&typeof b.currentTarget.releasePointerCapture=="function"&&b.currentTarget.releasePointerCapture(b.pointerId)}};return i.jsxs("label",{className:T("uk-switch",l),"data-disabled":s?"true":void 0,htmlFor:m,onClickCapture:b=>{v.current&&(b.preventDefault(),b.stopPropagation())},children:[i.jsx("input",{...p,ref:u,id:m,type:"checkbox",role:"switch",className:"uk-switch__input",checked:x,disabled:s,"aria-checked":x,onChange:b=>g(b.target.checked)}),i.jsx("span",{className:"uk-switch__track","aria-hidden":"true",onPointerDown:b=>{s||(h.current={pointerId:b.pointerId,startX:b.clientX,startValue:y.get(),moved:!1,samples:[{x:b.clientX,time:performance.now()}]},typeof b.currentTarget.setPointerCapture=="function"&&b.currentTarget.setPointerCapture(b.pointerId))},onPointerMove:b=>{const w=h.current;if(!w||w.pointerId!==b.pointerId)return;const E=b.clientX-w.startX;Math.abs(E)>4&&(w.moved=!0),w.moved&&(b.preventDefault(),y.set(Math.max(0,Math.min(16,w.startValue+E))),w.samples.push({x:b.clientX,time:performance.now()}),w.samples=w.samples.filter(_=>performance.now()-_.time<120))},onPointerUp:k,onPointerCancel:k,children:i.jsx(I.motion.span,{className:"uk-switch__thumb",style:{x:y}})}),c?i.jsx("span",{className:"uk-switch__label",children:c}):null]})}),ie=a.createContext(null);function ae(t){const e=a.useContext(ie);if(!e)throw new Error(`<${t}> must be rendered inside <Sidebar>`);return e}function K(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function We({children:t,className:e,hoverPreview:n=!0,hoverIndicator:o="rail",groupGap:s,style:l,...c}){const[r,p]=a.useState(null),u=a.useId().replace(/:/g,""),d=a.useMemo(()=>({hoveredId:r,setHoveredId:p,indicatorBaseId:u,hoverPreview:n,hoverIndicator:o}),[r,u,n,o]),m=typeof s=="number"?`${s}px`:s,f={...l,...m===void 0?{}:{"--uk-sidebar-group-gap":m}};return i.jsx(ie.Provider,{value:d,children:i.jsx(I.LayoutGroup,{id:`sidebar-${u}`,children:i.jsx("nav",{...c,className:T("uk-sidebar",e),style:f,children:t})})})}function Ye({title:t,icon:e,collapsible:n=!1,open:o,defaultOpen:s=!0,onOpenChange:l,children:c,className:r,...p}){const u=a.useId(),d=a.useId(),m=a.useId(),f=a.useRef(null),v=a.useRef(null),h=ae("Sidebar.Group"),x=e!=null,g=I.useReducedMotion()??!1,[y,k]=C.useControllableState({value:o,defaultValue:s,onChange:l}),b=n?y:!0,w=h.hoveredId===m;a.useEffect(()=>{!n||b||v.current?.contains(document.activeElement)&&f.current?.focus()},[n,b]);const E=i.jsxs(i.Fragment,{children:[x?i.jsx("span",{className:"uk-sidebar__group-icon","aria-hidden":"true",children:e}):null,i.jsx("span",{className:"uk-sidebar__group-label",children:t}),n?i.jsx("span",{className:"uk-sidebar__chevron","aria-hidden":"true",children:i.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"none",children:i.jsx("path",{d:"m6 3.8 4.2 4.2L6 12.2",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round"})})}):null]});return i.jsxs("section",{...p,className:T("uk-sidebar__group",r),"aria-labelledby":p["aria-labelledby"]??u,"data-collapsible":n?"true":"false","data-has-icon":x?"true":"false","data-state":b?"open":"closed",children:[n?i.jsxs("button",{ref:f,type:"button",className:"uk-sidebar__group-title uk-sidebar__group-trigger",id:u,"aria-controls":d,"aria-expanded":b,"data-preview":h.hoverIndicator==="background"&&w?"true":void 0,onClick:()=>k(_=>!_),onPointerEnter:_=>{h.hoverPreview&&h.hoverIndicator==="background"&&_.pointerType==="mouse"&&h.setHoveredId(m)},onPointerLeave:()=>{h.hoveredId===m&&h.setHoveredId(null)},onPointerCancel:()=>{h.hoveredId===m&&h.setHoveredId(null)},children:[i.jsx(I.AnimatePresence,{initial:!1,children:h.hoverPreview&&h.hoverIndicator==="background"&&w?i.jsx(I.motion.span,{className:"uk-sidebar__group-surface","data-kind":"hover","data-slot":"sidebar-hover-highlight",layoutId:`${h.indicatorBaseId}-hover`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:g?{duration:0}:q}):null}),E]}):i.jsx("div",{className:"uk-sidebar__group-title",id:u,children:E}),i.jsx(I.motion.div,{ref:v,className:"uk-sidebar__content",id:d,"data-state":b?"open":"closed",initial:!1,animate:{height:b?"auto":0,opacity:b?1:0},transition:g?{duration:0}:oe,inert:n&&!b,"aria-hidden":n&&!b?!0:void 0,children:i.jsx("ul",{className:"uk-sidebar__list",children:c})})]})}function Je({active:t=!1,children:e,className:n}){const o=ae("Sidebar.Item"),s=a.useId(),c=I.useReducedMotion()??!1?{duration:0}:q;if(!a.isValidElement(e))throw new Error("<Sidebar.Item> expects a single valid React element");const r=e,p=r.props,u=p.className,d=typeof u=="function"?g=>T("uk-sidebar__link",u(g),n):T("uk-sidebar__link",u,n),m=p.onPointerEnter,f=p.onPointerLeave,v=p.onPointerCancel,h=o.hoveredId===s,x=i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"uk-sidebar__rail","aria-hidden":"true"}),i.jsx(I.AnimatePresence,{initial:!1,children:o.hoverPreview&&o.hoverIndicator==="rail"&&h?i.jsx(I.motion.span,{className:"uk-sidebar__rail-indicator","data-kind":"hover","data-slot":"sidebar-hover-rail-indicator",layoutId:`${o.indicatorBaseId}-hover-rail`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx(I.AnimatePresence,{initial:!1,children:o.hoverIndicator==="rail"&&t?i.jsx(I.motion.span,{className:"uk-sidebar__rail-indicator","data-kind":"active","data-slot":"sidebar-active-rail-indicator",layoutId:`${o.indicatorBaseId}-active-rail`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx(I.AnimatePresence,{initial:!1,children:o.hoverPreview&&o.hoverIndicator==="background"&&h?i.jsx(I.motion.span,{className:"uk-sidebar__surface","data-kind":"hover","data-slot":"sidebar-hover-highlight",layoutId:`${o.indicatorBaseId}-hover`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx(I.AnimatePresence,{initial:!1,children:o.hoverIndicator==="background"&&t?i.jsx(I.motion.span,{className:"uk-sidebar__surface","data-kind":"active","data-slot":"sidebar-active-highlight",layoutId:`${o.indicatorBaseId}-active`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx("span",{className:"uk-sidebar__label",children:p.children})]});return i.jsx("li",{className:"uk-sidebar__item",children:a.cloneElement(r,{className:d,"data-active":t?"true":"false","data-preview":t||h?"true":"false","aria-current":p["aria-current"]??(t?"page":void 0),onPointerEnter:K(m,g=>{o.hoverPreview&&g.pointerType==="mouse"&&o.setHoveredId(s)}),onPointerLeave:K(f,()=>{o.hoveredId===s&&o.setHoveredId(null)}),onPointerCancel:K(v,()=>{o.hoveredId===s&&o.setHoveredId(null)})},x)})}const Qe=Object.assign(We,{Group:Ye,Item:Je}),ce=a.createContext(null);function X(t){const e=a.useContext(ce);if(!e)throw new Error(`<${t}> must be rendered inside <Tabs>`);return e}function le(t,e){return`${t}-tab-${encodeURIComponent(e)}`}function ue(t,e){return`${t}-panel-${encodeURIComponent(e)}`}function Ze({value:t,defaultValue:e,onValueChange:n,orientation:o="horizontal",className:s,children:l}){const c=a.useId(),[r,p]=C.useControllableState({value:t,defaultValue:e??"",onChange:n}),u=a.useMemo(()=>({baseId:c,value:r,setValue:p,orientation:o,indicatorId:`${c}-indicator`}),[c,r,o,p]);return i.jsx(ce.Provider,{value:u,children:i.jsx("div",{className:T("uk-tabs",s),"data-orientation":o,children:l})})}const et=a.forwardRef(function({className:e,onKeyDown:n,...o},s){const{orientation:l}=X("Tabs.List");return i.jsx("div",{...o,ref:s,role:"tablist","aria-orientation":l,tabIndex:-1,className:T("uk-tabs__list",e),onKeyDown:c=>{if(n?.(c),c.defaultPrevented)return;const p=c.target?.closest('[role="tab"]');if(!p||p.hasAttribute("disabled"))return;const u=Array.from(c.currentTarget.querySelectorAll('[role="tab"]:not([disabled])')),d=u.indexOf(p);if(d===-1)return;const m=l==="horizontal"?"ArrowRight":"ArrowDown",f=l==="horizontal"?"ArrowLeft":"ArrowUp";let v=-1;switch(c.key){case m:v=(d+1)%u.length;break;case f:v=(d-1+u.length)%u.length;break;case"Home":v=0;break;case"End":v=u.length-1;break;default:return}c.preventDefault();const h=u[v];h&&(h.focus(),h.click())}})}),tt=a.forwardRef(function({value:e,type:n="button",className:o,onClick:s,children:l,...c},r){const p=X("Tabs.Trigger"),u=p.value===e,d=I.useReducedMotion()??!1;return i.jsxs("button",{...c,ref:r,type:n,role:"tab",id:le(p.baseId,e),"aria-selected":u,"aria-controls":ue(p.baseId,e),tabIndex:u?0:-1,"data-state":u?"active":"inactive",className:T("uk-tabs__trigger",o),onClick:m=>{s?.(m),m.defaultPrevented||p.setValue(e)},children:[l,u?i.jsx(I.motion.span,{className:"uk-tabs__indicator",layoutId:p.indicatorId,"aria-hidden":"true",transition:d?{duration:0}:q}):null]})}),nt=a.forwardRef(function({value:e,className:n,...o},s){const l=X("Tabs.Content"),c=l.value===e;return i.jsx("div",{...o,ref:s,role:"tabpanel",id:ue(l.baseId,e),"aria-labelledby":le(l.baseId,e),hidden:!c,tabIndex:0,"data-state":c?"active":"inactive",className:T("uk-tabs__panel",n)})}),ot=Object.assign(Ze,{List:et,Trigger:tt,Content:nt}),de=a.createContext(null),rt=()=>()=>{},st=()=>!0,it=()=>!1;function $(t){const e=a.useContext(de);if(!e)throw new Error(`<${t}> must be rendered inside <Dialog.Root>`);return e}function fe(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function pe({children:t,open:e,defaultOpen:n,onOpenChange:o}){const s=a.useId(),[l,c]=a.useState(!1),[r,p]=a.useState(!1),[u,d]=C.useControllableState({value:e,defaultValue:n??!1,onChange:o}),m=a.useMemo(()=>({open:u,setOpen:d,triggerId:`${s}-trigger`,contentId:`${s}-content`,titleId:`${s}-title`,descriptionId:`${s}-description`,hasTitle:l,setHasTitle:c,hasDescription:r,setHasDescription:p}),[s,u,r,l,d]);return i.jsx(de.Provider,{value:m,children:t})}function at({children:t}){const e=$("Dialog.Trigger"),n=t,o=n.props.onClick;return a.cloneElement(n,{id:e.triggerId,"aria-haspopup":"dialog","aria-expanded":e.open,"aria-controls":e.open?e.contentId:void 0,onClick:fe(o,()=>{e.setOpen(!e.open)})})}function he({children:t,label:e="Close"}){const n=$("Dialog.Close");if(a.isValidElement(t)){const o=t,s=o.props.onClick;return a.cloneElement(o,{onClick:fe(s,()=>{n.setOpen(!1)})})}return i.jsx(G,{variant:"ghost",onClick:()=>n.setOpen(!1),children:e})}const me=a.forwardRef(function({className:e,...n},o){return i.jsx("header",{...n,ref:o,className:T("uk-dialog__header",e)})}),be=a.forwardRef(function({className:e,children:n,...o},s){const l=$("Dialog.Title"),c=l.setHasTitle;return a.useEffect(()=>(c(!0),()=>c(!1)),[c]),i.jsx("h2",{...o,ref:s,id:l.titleId,className:T("uk-dialog__title",e),children:n})}),xe=a.forwardRef(function({className:e,...n},o){const s=$("Dialog.Description"),l=s.setHasDescription;return a.useEffect(()=>(l(!0),()=>l(!1)),[l]),i.jsx("p",{...n,ref:o,id:s.descriptionId,className:T("uk-dialog__description",e)})}),ge=a.forwardRef(function({className:e,...n},o){return i.jsx("div",{...n,ref:o,className:T("uk-dialog__body",e)})}),ve=a.forwardRef(function({className:e,...n},o){return i.jsx("footer",{...n,ref:o,className:T("uk-dialog__footer",e)})});function ct({requestClose:t,contentId:e,titleId:n,descriptionId:o,hasTitle:s,hasDescription:l,children:c,closeOnBackdropClick:r=!0,closeOnEscape:p=!0,initialFocusRef:u,returnFocusRef:d,className:m,"aria-label":f,"aria-labelledby":v,"aria-describedby":h}){const x=a.useRef(null),g=a.useRef(null),y=I.useIsPresent(),k=I.useReducedMotion()??!1;return C.useLockBodyScroll(!0),a.useLayoutEffect(()=>{const b=x.current;b&&(g.current??(g.current=document.activeElement instanceof HTMLElement?document.activeElement:null),!b.open&&(typeof b.showModal=="function"?b.showModal():b.setAttribute("open","")))},[]),C.useFocusTrap({active:!0,containerRef:x,initialFocusRef:u,returnFocusRef:d??g}),a.useEffect(()=>{const b=x.current;if(!b)return;const w=()=>{b.open||(typeof b.showModal=="function"?b.showModal():b.setAttribute("open",""))},E=()=>{if(!p){w();return}t()},_=P=>{P.preventDefault(),p&&t()},j=P=>{p||P.key!=="Escape"||P.defaultPrevented||(P.preventDefault(),P.stopPropagation())},R=P=>{r&&P.target===b&&t()};return b.addEventListener("close",E),b.addEventListener("cancel",_),b.addEventListener("keydown",j,!0),b.addEventListener("click",R),()=>{b.removeEventListener("close",E),b.removeEventListener("cancel",_),b.removeEventListener("keydown",j,!0),b.removeEventListener("click",R)}},[r,p,t]),i.jsx("dialog",{ref:x,id:e,className:T("uk-dialog",m),closedby:p||r?"any":"none","data-state":y?"open":"closed",inert:!y,"aria-label":f,"aria-labelledby":v??(f?void 0:s?n:void 0),"aria-describedby":h??(l?o:void 0),children:i.jsx(I.motion.div,{className:"uk-dialog__panel",initial:k?{opacity:0}:{opacity:0,transform:"translateY(12px) scale(0.96)"},animate:{opacity:1,transform:"translateY(0px) scale(1)",transition:k?M:{...Z,delay:.06}},exit:k?{opacity:0,transition:M}:{opacity:0,transform:"translateY(8px) scale(0.97)",transition:Z},children:c})})}function ye({children:t,closeOnBackdropClick:e=!0,closeOnEscape:n=!0,initialFocusRef:o,returnFocusRef:s,className:l,"aria-label":c,"aria-labelledby":r,"aria-describedby":p}){const u=$("Dialog.Content"),d=C.useEventCallback(()=>{u.setOpen(!1)});return a.useSyncExternalStore(rt,st,it)?V.createPortal(i.jsx(I.MotionConfig,{reducedMotion:"user",children:i.jsx(I.AnimatePresence,{children:u.open?i.jsx(ct,{requestClose:d,contentId:u.contentId,titleId:u.titleId,descriptionId:u.descriptionId,hasTitle:u.hasTitle,hasDescription:u.hasDescription,closeOnBackdropClick:e,closeOnEscape:n,initialFocusRef:o,returnFocusRef:s,className:l,"aria-label":c,"aria-labelledby":r,"aria-describedby":p,children:t},"uk-dialog"):null})}),document.body):null}function lt({open:t,onOpenChange:e,title:n,description:o,footer:s,children:l,closeLabel:c="Close",showCloseButton:r=!0,closeOnBackdropClick:p=!0,closeOnEscape:u=!0,initialFocusRef:d,returnFocusRef:m,className:f,"aria-label":v}){return i.jsx(pe,{open:t,onOpenChange:e,children:i.jsxs(ye,{className:f,closeOnBackdropClick:p,closeOnEscape:u,initialFocusRef:d,returnFocusRef:m,"aria-label":v,children:[n||o||r?i.jsxs(me,{children:[i.jsxs("div",{className:"uk-dialog__heading",children:[n?i.jsx(be,{children:n}):null,o?i.jsx(xe,{children:o}):null]}),r?i.jsx(he,{children:i.jsx(G,{variant:"ghost",size:"sm",iconOnly:!0,"aria-label":c,className:"uk-dialog__close",children:i.jsx("svg",{viewBox:"0 0 20 20",width:"16",height:"16","aria-hidden":"true",children:i.jsx("path",{d:"M5 5l10 10M15 5L5 15",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})})})}):null]}):null,i.jsx(ge,{children:l}),s?i.jsx(ve,{children:s}):null]})})}const ut=Object.assign(lt,{Root:pe,Trigger:at,Content:ye,Header:me,Title:be,Description:xe,Body:ge,Footer:ve,Close:he});function dt(t,e){if(!(e instanceof Element))return!1;const n=e.closest('a, button, input, select, textarea, label, [contenteditable="true"], [role="button"]');return n!==null&&n!==t}const ft=a.forwardRef(function({children:e,className:n,direction:o="left",speed:s=30,pauseOnHover:l=!0,gap:c="1rem",fade:r=!0,paused:p=!1,items:u,onItemClick:d,...m},f){const v=u?u.map(g=>({key:g.key,content:g.content,data:g.data})):a.Children.toArray(e).map((g,y)=>({key:a.isValidElement(g)?g.key??null:null,content:g,data:void 0})),h=(g,y,k)=>{!d||k.defaultPrevented||dt(k.currentTarget,k.target)||d({index:y,key:g.key,data:g.data},k)},x=(g,y,k)=>{!d||k.defaultPrevented||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),d({index:y,key:g.key,data:g.data},k))};return i.jsx("div",{...m,ref:f,className:T("uk-marquee",n),"data-direction":o,"data-fade":r?"true":void 0,"data-pause-on-hover":l?"true":void 0,"data-paused":p?"true":"false",style:{...m.style,"--uk-marquee-gap":c,"--uk-marquee-duration":`${s}s`,gap:c},children:[!1,!0].map(g=>i.jsx("div",{"aria-hidden":g,className:"uk-marquee__track","data-duplicate":g?"true":void 0,inert:g&&!d,role:g?"presentation":void 0,onFocusCapture:g?y=>{y.target instanceof HTMLElement&&y.target.blur()}:void 0,children:v.map((y,k)=>i.jsx("div",{className:"uk-marquee__item","data-clickable":d?"true":void 0,...d?{role:g?void 0:"button",tabIndex:g?-1:0,onClick:b=>h(y,k,b),onKeyDown:g?void 0:b=>x(y,k,b)}:{},children:y.content},g?`duplicate-${k}`:y.key??k))},g?"duplicate":"primary"))})}),ke=a.createContext(null),Ie=()=>()=>{},we=()=>!0,Ce=()=>!1;function Te(t){const e=a.useContext(ke);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Root>`);return e}function _e(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function Ee(t,e){const n=typeof t=="string"?t.split(/\s+/).filter(Boolean):[];return Array.from(new Set([...n,e])).join(" ")}function S(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function pt({children:t,open:e,defaultOpen:n,onOpenChange:o,delayDuration:s=300,closeDelay:l=80}){const c=a.useId(),[r,p]=a.useState(null),u=a.useRef(null),d=a.useRef(null),[m,f]=C.useControllableState({value:e,defaultValue:n??!1,onChange:o}),v=a.useCallback(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),h=a.useCallback(()=>{d.current!==null&&(clearTimeout(d.current),d.current=null)},[]),x=C.useEventCallback((b=!1)=>{if(v(),h(),!m){if(b||s<=0){f(!0);return}u.current=setTimeout(()=>{u.current=null,f(!0)},s)}}),g=C.useEventCallback(()=>{if(v(),h(),!!m){if(l<=0){f(!1);return}d.current=setTimeout(()=>{d.current=null,f(!1)},l)}}),y=C.useEventCallback(()=>{v(),h(),f(!1)});a.useEffect(()=>{m?h():v()},[h,v,m]),a.useEffect(()=>()=>{v(),h()},[h,v]);const k=a.useMemo(()=>({open:m,triggerElement:r,setTriggerElement:p,contentId:c,requestOpen:x,requestClose:g,dismiss:y}),[c,m,y,g,x,r]);return i.jsx(ke.Provider,{value:k,children:t})}function ht({children:t}){const e=Te("Tooltip.Trigger"),{setTriggerElement:n}=e;if(!a.isValidElement(t))throw new Error("<Tooltip.Trigger> expects a single valid React element");const o=t,s=o.props,l=s.ref??o.ref,c=s.onPointerEnter,r=s.onPointerLeave,p=s.onFocus,u=s.onBlur,d=s.onKeyDown,m=a.useCallback(f=>{_e(l,f),n(f)},[l,n]);return a.cloneElement(o,{ref:m,"aria-describedby":e.open?Ee(s["aria-describedby"],e.contentId):s["aria-describedby"],onPointerEnter:S(c,f=>{e.requestOpen(f.pointerType==="touch")}),onPointerLeave:S(r,f=>{f.pointerType!=="touch"&&e.requestClose()}),onFocus:S(p,()=>{e.requestOpen()}),onBlur:S(u,()=>{e.requestClose()}),onKeyDown:S(d,f=>{f.key==="Escape"&&e.open&&(f.preventDefault(),f.stopPropagation(),e.dismiss())})})}function B(t,e,n){return n<e?e:Math.min(Math.max(t,e),n)}function mt(t){switch(t){case"top":return"bottom";case"right":return"left";case"bottom":return"top";case"left":return"right"}}function F(t,e,n,o,s){switch(e){case"top":return t.top-s;case"right":return n-t.right-s;case"bottom":return o-t.bottom-s;case"left":return t.left-s}}function te(t,e,n,o,s,l,c){return F(t,n,s,l,c)>=(n==="top"||n==="bottom"?e.height:e.width)+o}function bt({trigger:t,tooltip:e,side:n,align:o,sideOffset:s,collisionPadding:l,avoidCollisions:c,viewportWidth:r,viewportHeight:p}){let u=n;if(c&&!te(t,e,n,s,r,p,l)){const g=mt(n),y=te(t,e,g,s,r,p,l),k=F(t,n,r,p,l),b=F(t,g,r,p,l);(y||b>k)&&(u=g)}const d=t.left+t.width/2,m=t.top+t.height/2;let f=0,v=0;switch(u){case"top":case"bottom":f=o==="start"?t.left:o==="end"?t.right-e.width:d-e.width/2,v=u==="top"?t.top-e.height-s:t.bottom+s;break;case"left":case"right":f=u==="left"?t.left-e.width-s:t.right+s,v=o==="start"?t.top:o==="end"?t.bottom-e.height:m-e.height/2;break}c&&(f=B(f,l,r-e.width-l),v=B(v,l,p-e.height-l));const h=10,x=u==="top"||u==="bottom"?B(d-f,h,Math.max(h,e.width-h)):B(m-v,h,Math.max(h,e.height-h));return{x:f,y:v,side:u,arrowOffset:x}}function je(t,e,{side:n,align:o,sideOffset:s,collisionPadding:l,avoidCollisions:c}){const[r,p]=a.useState(null);return a.useLayoutEffect(()=>{const u=e.current;if(!u||!t)return;const d=()=>{const f=t.getBoundingClientRect(),v=u.getBoundingClientRect();p(bt({trigger:f,tooltip:v,side:n,align:o,sideOffset:s,collisionPadding:l,avoidCollisions:c,viewportWidth:window.innerWidth||document.documentElement.clientWidth,viewportHeight:window.innerHeight||document.documentElement.clientHeight}))};d(),window.addEventListener("resize",d),window.addEventListener("scroll",d,!0);const m=typeof ResizeObserver>"u"?null:new ResizeObserver(d);return m?.observe(t),m?.observe(u),()=>{window.removeEventListener("resize",d),window.removeEventListener("scroll",d,!0),m?.disconnect()}},[o,c,l,e,n,s,t]),r}function Re(t,e,n){a.useEffect(()=>{const o=c=>{const r=c.target;r instanceof Node&&(t.contains(r)||e.current?.contains(r)||n())},s=()=>{document.visibilityState==="hidden"&&n()},l=c=>{const r=c.target;c.key!=="Escape"||r instanceof Node&&t.contains(r)||n()};return document.addEventListener("pointerdown",o,!0),document.addEventListener("visibilitychange",s),document.addEventListener("keydown",l,!0),window.addEventListener("blur",n),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("visibilitychange",s),document.removeEventListener("keydown",l,!0),window.removeEventListener("blur",n)}},[n,e,t])}function Pe(t){switch(t){case"top":return"center bottom";case"bottom":return"center top";case"left":return"right center";case"right":return"left center";default:return"center"}}function xt({contentId:t,triggerElement:e,dismiss:n,children:o,className:s,style:l,side:c="top",align:r="center",sideOffset:p=8,collisionPadding:u=8,avoidCollisions:d=!0,...m}){const f=a.useRef(null),v=I.useReducedMotion()??!1,h=I.useIsPresent(),x=je(e,f,{side:c,align:r,sideOffset:p,collisionPadding:u,avoidCollisions:d});Re(e,f,n);const g=Pe(x?.side??c),y={...l,left:x?`${x.x}px`:0,top:x?`${x.y}px`:0,visibility:x?"visible":"hidden"};return i.jsx("div",{...m,ref:f,id:t,role:"tooltip","data-side":x?.side??c,"data-align":r,"data-state":h?"open":"closed","aria-hidden":h?void 0:!0,className:T("uk-tooltip",s),style:y,children:i.jsxs(I.motion.div,{className:"uk-tooltip__surface",style:{transformOrigin:g},initial:v?{opacity:0}:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:v?{opacity:0}:{opacity:0,scale:.96},transition:v?M:re,children:[i.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${x?.arrowOffset??0}px`}}),o]})})}function gt(t){const e=Te("Tooltip.Content"),o=a.useSyncExternalStore(Ie,we,Ce)&&e.triggerElement?e.triggerElement.closest("dialog")??document.body:null;return!o||!e.triggerElement?null:V.createPortal(i.jsx(I.MotionConfig,{reducedMotion:"user",children:i.jsx(I.AnimatePresence,{children:e.open?i.jsx(xt,{contentId:e.contentId,triggerElement:e.triggerElement,dismiss:e.dismiss,...t},"uk-tooltip"):null})}),o)}const Se=a.createContext(null);function vt(t){const e=a.useContext(Se);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Group>`);return e}function yt({activeValue:t,content:e,contentClassName:n,contentId:o,dismiss:s,triggerElement:l,side:c,align:r,sideOffset:p,collisionPadding:u,avoidCollisions:d}){const m=a.useRef(null),f=I.useReducedMotion()??!1,v=I.useIsPresent(),h=je(l,m,{side:c,align:r,sideOffset:p,collisionPadding:u,avoidCollisions:d});Re(l,m,s);const x={left:h?`${h.x}px`:0,top:h?`${h.y}px`:0,transformOrigin:Pe(h?.side??c),visibility:h?"visible":"hidden"};return i.jsxs(I.motion.div,{ref:m,id:o,role:"tooltip",layout:!f,layoutDependency:t,"data-side":h?.side??c,"data-align":r,"data-state":v?"open":"closed","aria-hidden":v?void 0:!0,className:T("uk-tooltip","uk-tooltip__surface","uk-tooltip--group",n),style:x,initial:f?{opacity:0}:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:f?{opacity:0}:{opacity:0,scale:.96},transition:f?{...M,layout:{duration:0}}:Me,children:[i.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${h?.arrowOffset??0}px`}}),i.jsx(I.motion.div,{className:"uk-tooltip__content",initial:{opacity:0},animate:{opacity:1},transition:f?M:re,children:e},t)]})}function kt({children:t,side:e="top",align:n="center",sideOffset:o=8,collisionPadding:s=8,avoidCollisions:l=!0,delayDuration:c=180,closeDelay:r=80,contentClassName:p}){const u=a.useId(),[d,m]=a.useState(()=>new Map),[f,v]=a.useState(!1),[h,x]=a.useState(null),g=a.useRef(null),y=a.useRef(null),k=a.useSyncExternalStore(Ie,we,Ce),b=a.useCallback(()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},[]),w=a.useCallback(()=>{y.current!==null&&(clearTimeout(y.current),y.current=null)},[]),E=C.useEventCallback((D,N=!1)=>{if(b(),w(),x(D),!f){if(N||c<=0){v(!0);return}g.current=setTimeout(()=>{g.current=null,v(!0)},c)}}),_=C.useEventCallback(()=>{if(b(),w(),!!f){if(r<=0){v(!1);return}y.current=setTimeout(()=>{y.current=null,v(!1)},r)}}),j=C.useEventCallback(()=>{b(),w(),v(!1)}),R=C.useEventCallback((D,N,O)=>{m(z=>{const Y=z.get(D);if(Y?.triggerElement===N&&Object.is(Y.content,O))return z;const J=new Map(z);return J.set(D,{triggerElement:N,content:O}),J})}),P=C.useEventCallback(D=>{m(N=>{if(!N.has(D))return N;const O=new Map(N);return O.delete(D),O})});a.useEffect(()=>()=>{b(),w()},[w,b]);const Ne=a.useMemo(()=>({open:f,activeValue:h,contentId:u,activate:E,requestClose:_,dismiss:j,register:R,unregister:P}),[E,h,u,j,f,R,_,P]),L=h?d.get(h):void 0,De=f&&!!L,W=k&&L?L.triggerElement.closest("dialog")??document.body:null;return i.jsxs(Se.Provider,{value:Ne,children:[t,W&&L?V.createPortal(i.jsx(I.MotionConfig,{reducedMotion:"user",children:i.jsx(I.AnimatePresence,{children:De?i.jsx(yt,{activeValue:h??"",content:L.content,contentClassName:p,contentId:u,dismiss:j,triggerElement:L.triggerElement,side:e,align:n,sideOffset:o,collisionPadding:s,avoidCollisions:l},"uk-tooltip-group"):null})}),W):null]})}function It({value:t,content:e,children:n}){const o=vt("Tooltip.Item"),{register:s,unregister:l}=o,[c,r]=a.useState(null);if(!a.isValidElement(n))throw new Error("<Tooltip.Item> expects a single valid React element");const p=n,u=p.props,d=u.ref??p.ref,m=u.onPointerEnter,f=u.onPointerLeave,v=u.onFocus,h=u.onBlur,x=u.onKeyDown,g=o.open&&o.activeValue===t,y=a.useCallback(k=>{_e(d,k),r(k)},[d,r]);return a.useLayoutEffect(()=>{if(c)return s(t,c,e),()=>l(t)},[e,s,c,l,t]),a.cloneElement(p,{ref:y,"aria-describedby":g?Ee(u["aria-describedby"],o.contentId):u["aria-describedby"],onPointerEnter:S(m,k=>{o.activate(t,k.pointerType==="touch")}),onPointerLeave:S(f,k=>{k.pointerType!=="touch"&&o.requestClose()}),onFocus:S(v,()=>{o.activate(t)}),onBlur:S(h,()=>{o.requestClose()}),onKeyDown:S(x,k=>{k.key==="Escape"&&g&&(k.preventDefault(),k.stopPropagation(),o.dismiss())})})}const wt={Root:pt,Trigger:ht,Content:gt,Group:kt,Item:It};exports.Button=G;exports.CheckBox=ne;exports.Dialog=ut;exports.Input=Ue;exports.Marquee=ft;exports.Select=Fe;exports.Sidebar=Qe;exports.Switch=Xe;exports.Tabs=ot;exports.Tooltip=wt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),a=require("react"),P=require("seam-hooks"),w=require("motion/react"),G=require("react-dom");function L(...t){return t.filter(Boolean).join(" ")}const Q=a.forwardRef(function({variant:e="primary",size:n="md",loading:r=!1,iconOnly:s=!1,type:l="button",className:c,children:d,...p},u){return i.jsxs("button",{...p,ref:u,type:l,className:L("uk-button",c),"data-variant":e,"data-size":n,"data-loading":r?"true":void 0,"data-icon-only":s?"true":void 0,disabled:p.disabled||r,"aria-busy":r||void 0,children:[r?i.jsx("span",{className:"uk-button__spinner","aria-hidden":"true"}):null,d]})}),ae=a.forwardRef(function({checked:e,defaultChecked:n,onCheckedChange:r,disabled:s,className:l,children:c,id:d,...p},u){const m=a.useId(),o=d??m,[h,v]=P.useControllableState({value:e,defaultValue:n??!1,onChange:r});return i.jsxs("label",{className:L("uk-checkbox",l),"data-disabled":s?"true":void 0,htmlFor:o,children:[i.jsx("input",{...p,ref:u,id:o,type:"checkbox",className:"uk-checkbox__input",checked:h,disabled:s,onChange:x=>{s||v(x.target.checked)}}),i.jsx("span",{className:"uk-checkbox__box","aria-hidden":"true",children:i.jsx("svg",{className:"uk-checkbox__check",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:3.2,strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M4 12.5 L9.5 18 L20 7",pathLength:1})})}),c?i.jsx("span",{className:"uk-checkbox__label",children:c}):null]})});ae.displayName="CheckBox";const z=[.23,1,.32,1],W=[.77,0,.175,1],ne={type:"spring",bounce:0,duration:.3},oe={type:"spring",bounce:.04,duration:.38},U={type:"spring",bounce:.08,duration:.34},ce={duration:.2,ease:W},Ve={layout:{type:"spring",bounce:.04,duration:.22},opacity:{duration:.12,ease:z},x:{type:"spring",bounce:.08,duration:.26},scaleX:{type:"spring",bounce:.08,duration:.26},scaleY:{type:"spring",bounce:.08,duration:.26}},He={layout:{duration:.16,ease:W},opacity:{duration:.16,ease:z},x:{duration:.16,ease:W}},le={duration:.12,ease:z},ze={layout:{type:"spring",bounce:0,duration:.22},opacity:{duration:.12,ease:z},scale:{duration:.12,ease:z}},H={duration:.12,ease:z},ue=a.createContext(null);function Z(t){const e=a.useContext(ue);if(!e)throw new Error(`<${t}> must be rendered inside <Select>`);return e}const qe=()=>()=>{},Ke=()=>!0,Fe=()=>!1;function re(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function de(t,e,n){return n<e?e:Math.min(Math.max(t,e),n)}function ie(t,e){const n=e?t??[]:t==null?[]:[t];return Array.from(new Set(n))}function Ge(t){return t==="bottom"?"center top":"center bottom"}function Ue(t,e=null,n=0){let r=0;function s(l,c,d){return l.flatMap(p=>{const u=p.children??[],m={option:p,index:r,parentIndex:c,depth:d,hasChildren:u.length>0};return r+=1,[m,...s(u,m.index,d+1)]})}return s(t,e,n)}function fe(t,e){for(const n of t){if(n.value===e)return n;const r=fe(n.children??[],e);if(r)return r}return null}function pe(t,e){return(t.children??[]).some(n=>e.includes(n.value)||pe(n,e))}function Xe({options:t,loading:e=!1,value:n,defaultValue:r=null,onValueChange:s,multiple:l=!1,children:c}){const d=a.useId(),p=ie(n,l),u=ie(r,l),[m,o]=P.useControllableState({value:n===void 0?void 0:p,defaultValue:u,onChange:S=>{s?.(l?S:S[0]??"")}}),[h,v]=a.useState(!1),[x,k]=a.useState(e);x!==e&&(k(e),e&&v(!1));const g=a.useMemo(()=>Ue(t),[t]),C=g.findIndex(S=>S.option.value===m[0]),[I,b]=a.useState(null),f=I??Math.max(C,0),j=a.useCallback(S=>{b(S)},[]),E=P.useEventCallback(S=>{const N=g[S],R=N?.option;e||!R||R.disabled||N?.hasChildren||(o(D=>l?D.includes(R.value)?D.filter(O=>O!==R.value):[...D,R.value]:D[0]===R.value?D:[R.value]),l||(v(!1),b(null)))}),y=P.useEventCallback(S=>{o(N=>N.filter(R=>R!==S))}),_=P.useEventCallback(()=>{o([])}),T=a.useMemo(()=>({values:m,multiple:l,activeIndex:f,open:h,setOpen:v,setActiveIndex:j,commit:E,removeValue:y,clearValues:_,triggerId:`${d}-trigger`,contentId:`${d}-content`,options:t,optionNodes:g,loading:e}),[f,d,E,l,h,t,g,e,y,_,j,m]);return i.jsx(ue.Provider,{value:T,children:c})}function K(t,e,n,r=!0){const s=t.length;if(s===0)return-1;for(let l=1;l<=s;l+=1){const c=r?(e+n*l+s*l)%s:e+n*l;if(c<0||c>=s)break;if(!t[c]?.option.disabled)return c}return e}function Y(t,e){const n=t[e];if(!n?.hasChildren)return e;for(let r=e+1;r<t.length&&(t[r]?.depth??0)>n.depth;r+=1)if(t[r]?.depth===n.depth+1&&!t[r]?.option.disabled)return r;return e}const We=a.forwardRef(function({className:e,placeholder:n="请选择",size:r="md",clear:s=!1,loadingText:l="加载中...",disabled:c,onPointerDown:d,onKeyDown:p,...u},m){const o=Z("Select.Trigger"),h=w.useReducedMotion()??!1,v=o.values.map(f=>fe(o.options,f)??{value:f,label:f}),x=v[0],k=a.useRef({search:"",timer:null}),g=a.useCallback(()=>{k.current.timer&&(clearTimeout(k.current.timer),k.current.timer=null),k.current.search=""},[]);a.useEffect(()=>g,[g]);const C=P.useEventCallback(f=>{if(o.loading)return;const j=k.current;j.timer&&clearTimeout(j.timer),j.search+=f.toLowerCase(),j.timer=setTimeout(g,500);const E=o.optionNodes.map(R=>{const D=R.option.label;return(typeof D=="string"?D:R.option.value).toLowerCase()}),y=o.open&&o.activeIndex>=0?o.activeIndex+1:0,_=Array.from({length:E.length},(R,D)=>(y+D)%E.length),T=_.find(R=>!o.optionNodes[R]?.option.disabled&&E[R]?.startsWith(j.search)),S=_.find(R=>!o.optionNodes[R]?.option.disabled&&E[R]?.includes(j.search)),N=T??S;N!==void 0&&(o.open?o.setActiveIndex(N):o.multiple||o.optionNodes[N]?.hasChildren?(o.setActiveIndex(N),o.setOpen(!0)):o.commit(N))}),I=P.useEventCallback(f=>{c||o.loading||o.setOpen(!o.open)}),b=P.useEventCallback(f=>{if(c||o.loading)return;if(f.key.length===1&&!f.metaKey&&!f.ctrlKey&&!f.altKey){f.preventDefault(),C(f.key);return}if(f.key==="Backspace"&&o.multiple){const E=o.values[o.values.length-1];E&&(f.preventDefault(),o.removeValue(E));return}if(!o.open){["ArrowDown","ArrowUp","Enter"," "].includes(f.key)&&(f.preventDefault(),o.setOpen(!0),o.loading||o.setActiveIndex(o.activeIndex>=0?o.activeIndex:K(o.optionNodes,-1,1)));return}if(f.key==="Escape"||f.key==="Tab"){o.setOpen(!1),f.currentTarget.focus();return}const j=o.optionNodes[o.activeIndex];if(f.key==="Enter"||f.key===" "){if(f.preventDefault(),j?.hasChildren){o.setActiveIndex(Y(o.optionNodes,o.activeIndex)),f.currentTarget.focus();return}o.commit(o.activeIndex),f.currentTarget.focus();return}if(f.key==="ArrowRight"&&j?.hasChildren){f.preventDefault(),o.setActiveIndex(Y(o.optionNodes,o.activeIndex));return}if(f.key==="ArrowLeft"&&j?.parentIndex!=null){f.preventDefault(),o.setActiveIndex(j.parentIndex);return}if(!o.loading){if(f.key==="ArrowDown"){f.preventDefault(),o.setActiveIndex(K(o.optionNodes,o.activeIndex,1));return}if(f.key==="ArrowUp"){f.preventDefault(),o.setActiveIndex(K(o.optionNodes,o.activeIndex,-1));return}if(f.key==="Home"||f.key==="End"){f.preventDefault();const E=f.key==="Home"?1:-1,y=f.key==="Home"?-1:o.optionNodes.length;o.setActiveIndex(K(o.optionNodes,y,E,!1))}}});return i.jsxs("div",{...u,ref:m,id:o.triggerId,role:"combobox",tabIndex:c||o.loading?-1:0,"aria-disabled":c||o.loading||void 0,"aria-expanded":o.open,"aria-busy":o.loading||void 0,"aria-haspopup":"listbox","aria-controls":o.open?o.contentId:void 0,"aria-activedescendant":o.open&&o.optionNodes[o.activeIndex]?`${o.contentId}-option-${o.activeIndex}`:void 0,"data-size":r,"data-multiple":o.multiple||void 0,"data-loading":o.loading||void 0,className:L("uk-select__trigger",e),onPointerDown:re(d,I),onKeyDown:re(p,b),children:[o.multiple?i.jsxs("span",{className:"uk-select__tags",children:[i.jsx(w.AnimatePresence,{initial:!1,children:v.map(f=>{const j=f.label??f.value,E=typeof j=="string"?j:f.value;return i.jsxs(w.motion.span,{className:"uk-select__tag","data-slot":"select-tag",layout:!0,initial:h?{opacity:0}:{opacity:0,x:12},animate:h?{opacity:1}:{opacity:1,x:0},exit:h?{opacity:0}:{opacity:0,x:4},transition:h?{duration:0}:He,children:[i.jsx("span",{className:"uk-select__tag-label",children:j}),i.jsx("button",{type:"button",className:"uk-select__tag-remove",disabled:c,"aria-label":`移除 ${E}`,onPointerDown:y=>y.stopPropagation(),onKeyDown:y=>{y.key==="Backspace"&&y.stopPropagation()},onClick:y=>{y.stopPropagation(),o.removeValue(f.value)},children:i.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:i.jsx("path",{d:"M5 5l6 6M11 5l-6 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]},f.value)})}),v.length===0?i.jsx("span",{className:"uk-select__placeholder",children:n}):null]}):i.jsx("span",{className:"uk-select__value",children:x?.label??o.values[0]??n}),i.jsxs("span",{className:"uk-select__actions",children:[s&&!c&&!o.loading&&o.values.length>0?i.jsx("button",{type:"button",className:"uk-select__clear","aria-label":"清空",onPointerDown:f=>f.stopPropagation(),onKeyDown:f=>{["Backspace"," "].includes(f.key)&&f.stopPropagation()},onClick:f=>{f.stopPropagation(),document.getElementById(o.triggerId)?.focus(),o.clearValues()},children:i.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M18 6 6 18"}),i.jsx("path",{d:"m6 6 12 12"})]})}):null,i.jsx("span",{"aria-hidden":"true",className:L("uk-select__chevron",o.loading&&"uk-select__spinner"),children:o.loading?null:i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",children:i.jsx("path",{d:"m4 6.2 4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),o.loading?i.jsx("span",{className:"uk-select__loading-status",role:"status","aria-live":"polite",children:l}):null]})});function Ye(t,e){const[n,r]=a.useState(null),s=a.useCallback(()=>{const l=e.current;if(!t||!l)return;const c=t.getBoundingClientRect(),d=l.getBoundingClientRect(),p=window.innerHeight-c.bottom-8,u=c.top-8,m=p>=Math.min(d.height,320)||p>=u?"bottom":"top",o=m==="bottom"?c.bottom+6:c.top-d.height-6,h=de(c.left,8,Math.max(8,window.innerWidth-c.width-8));r({x:h,y:o,side:m})},[e,t]);return a.useLayoutEffect(()=>{if(!t)return;s(),window.addEventListener("resize",s),window.addEventListener("scroll",s,!0);const l=typeof ResizeObserver>"u"?null:new ResizeObserver(s);return l?.observe(t),l?.observe(e.current??t),()=>{window.removeEventListener("resize",s),window.removeEventListener("scroll",s,!0),l?.disconnect()}},[e,t,s]),n}function Je({emptyText:t}){const e=Z("Select.Content"),n=e.triggerId,r=document.getElementById(n),s=a.useRef(null),l=w.useReducedMotion()??!1,c=w.useIsPresent(),d=Ye(r,s),p=a.useSyncExternalStore(qe,Ke,Fe),[u,m]=a.useState([]),[o,h]=a.useState(0),v=a.useRef(new Map),x=a.useRef(new Map),[k,g]=a.useState(e.open),[C,I]=a.useState(!1);if(k!==e.open&&(g(e.open),I(!1),e.open||(m([]),h(y=>y+1))),a.useEffect(()=>{!e.open||!d||!C||m(y=>{const _=e.optionNodes[e.activeIndex];if(!_)return y;const T=_.hasChildren?_.depth+1:_.depth,S=y.filter($=>$.level<=T);if(!_.hasChildren)return S.length===y.length?y:S;const N=v.current.get(_.index);if(!N)return S;const R=N.getBoundingClientRect(),D=224,M=R.right+D+14>window.innerWidth?R.left-D-6:R.right+6,B=de(R.top-6,8,window.innerHeight-8),V=S.find($=>$.level===T);return V?.parentIndex===_.index?V.left===M&&V.top===B?y:[...S.filter($=>$.level!==T),{...V,left:M,top:B}]:[...S.filter($=>$.level!==T),{session:o,level:T,parentIndex:_.index,left:M,top:B}]})},[e.activeIndex,e.open,e.optionNodes,o,d,C,m]),a.useEffect(()=>{if(!e.open)return;const y=S=>{const N=S.target;N instanceof Node&&(r?.contains(N)||s.current?.contains(N)||Array.from(x.current.values()).some(R=>R.contains(N))||(e.setOpen(!1),r?.focus()))};document.addEventListener("pointerdown",y,!0);const _=S=>{S.key==="Escape"&&(e.setOpen(!1),r?.focus())},T=()=>{e.setOpen(!1)};return document.addEventListener("keydown",_,!0),window.addEventListener("blur",T),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",_,!0),window.removeEventListener("blur",T)}},[e,r]),!p)return null;const b=r?.closest("dialog")??document.body,f=a.useCallback((y,_)=>{_?v.current.set(y,_):v.current.delete(y)},[]),j=y=>{const _=y.option,T=e.values.includes(_.value),S=y.index===e.activeIndex;return i.jsxs("li",{ref:N=>f(y.index,N),id:`${e.contentId}-option-${y.index}`,role:"option","aria-disabled":_.disabled||void 0,"aria-selected":T,"data-disabled":_.disabled||void 0,"data-selected":T||pe(_,e.values)||void 0,"data-active":S||void 0,"data-has-children":y.hasChildren||void 0,"data-depth":y.depth,className:"uk-select__option",onPointerEnter:N=>{N.pointerType==="mouse"&&!_.disabled&&e.setActiveIndex(y.index)},onClick:N=>{if(N.stopPropagation(),y.hasChildren){e.setActiveIndex(Y(e.optionNodes,y.index));return}e.commit(y.index)},children:[i.jsx(w.AnimatePresence,{initial:!1,children:S?i.jsx(w.motion.span,{className:"uk-select__option-highlight","data-slot":"select-active-highlight",layoutId:`${e.contentId}-active-${y.depth}`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:l?{duration:0}:U}):null}),i.jsx("span",{className:"uk-select__option-label",children:_.label??_.value}),y.hasChildren?i.jsx("span",{"aria-hidden":"true",className:"uk-select__expand",children:i.jsx("svg",{viewBox:"0 0 16 16",fill:"none",children:i.jsx("path",{d:"m6 4 4 4-4 4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}):i.jsx("span",{"aria-hidden":"true",className:"uk-select__check"})]},_.value)},E=e.open?u:[];return G.createPortal(i.jsxs(w.LayoutGroup,{id:`select-${e.contentId}`,children:[i.jsx("div",{ref:s,className:"uk-select","data-side":d?.side??"bottom","data-state":c?"open":"closed","aria-hidden":c?void 0:!0,style:{left:d?`${d.x}px`:0,top:d?`${d.y}px`:0,"--uk-select-width":`${r?.offsetWidth??220}px`,visibility:d?"visible":"hidden"},children:i.jsx(w.motion.div,{className:"uk-select__surface",style:{transformOrigin:Ge(d?.side??"bottom")},initial:l?{opacity:0}:{opacity:0,scale:.97,y:-4},animate:l?{opacity:1}:{opacity:1,scale:1,y:0},exit:l?{opacity:0}:{opacity:0,scale:.97,y:-2},transition:l?H:ce,onAnimationComplete:()=>{e.open&&I(!0)},children:e.options.length===0?i.jsx("p",{className:"uk-select__empty",children:t}):i.jsx("ul",{id:e.contentId,className:"uk-select__list",role:"listbox","aria-labelledby":n,"aria-owns":E.map(y=>`${e.contentId}-submenu-${y.level}`).join(" ")||void 0,children:e.optionNodes.filter(y=>y.depth===0).map(j)})})}),E.map(y=>{const _=e.optionNodes.filter(T=>T.parentIndex===y.parentIndex);return i.jsx(w.motion.div,{ref:T=>{T?x.current.set(y.level,T):x.current.delete(y.level)},className:"uk-select__submenu","data-select-owner":e.contentId,"data-state":c?"open":"closed",layout:!0,initial:{opacity:0,x:-34,scaleX:.18,scaleY:.36},animate:{opacity:1,x:0,scaleX:1,scaleY:1},exit:{opacity:0,x:-16,scaleX:.28,scaleY:.42},style:{left:y.left,top:y.top,transformOrigin:"left center"},transition:l?H:Ve,children:i.jsx("ul",{id:`${e.contentId}-submenu-${y.level}`,className:"uk-select__list",role:"listbox","aria-labelledby":n,children:_.map(j)})},`${y.session}-${y.level}`)})]}),b)}const Qe=a.forwardRef(function({options:e,multiple:n,value:r,defaultValue:s,onValueChange:l,placeholder:c,size:d="md",clear:p,disabled:u,invalid:m,emptyText:o="暂无可选项",loading:h=!1,loadingText:v="加载中...",className:x,...k},g){return i.jsxs(Xe,{options:e,loading:h,multiple:n,value:r,defaultValue:s,onValueChange:l,children:[i.jsx(We,{...k,ref:g,placeholder:c,size:d,clear:p,loadingText:v,disabled:u,"aria-invalid":m||void 0,"data-size":d,className:x}),i.jsx(Ze,{emptyText:o})]})});function Ze({emptyText:t}){const e=Z("Select.Content");return i.jsx(w.AnimatePresence,{children:e.open?i.jsx(Je,{emptyText:t},"select-layer"):null})}const et=a.forwardRef(function({inputSize:e="md",invalid:n=!1,className:r,"aria-invalid":s,...l},c){return i.jsx("input",{...l,ref:c,className:L("uk-input",r),"data-size":e,"aria-invalid":n?!0:s})}),tt=a.forwardRef(function({checked:e,defaultChecked:n,onCheckedChange:r,disabled:s,className:l,children:c,id:d,...p},u){const m=a.useId(),o=d??m,h=w.useReducedMotion()??!1,v=a.useRef(!1),x=a.useRef(null),[k,g]=P.useControllableState({value:e,defaultValue:n??!1,onChange:r}),C=w.useMotionValue(k?16:0);a.useEffect(()=>{if(x.current)return;const b=w.animate(C,k?16:0,h?{duration:0}:ne);return()=>b.stop()},[k,h,C]);const I=b=>{const f=x.current;if(!(!f||f.pointerId!==b.pointerId)){if(f.moved){const j=f.samples[0],E=f.samples[f.samples.length-1],y=j&&E?Math.max(E.time-j.time,1):1,_=j&&E?(E.x-j.x)/y*1e3:0,T=Math.abs(_)>220?_>0:C.get()>=8;v.current=!0,x.current=null,g(T),w.animate(C,T?16:0,h?{duration:0}:{...ne,velocity:_}),window.setTimeout(()=>{v.current=!1},0)}else x.current=null;b.currentTarget.hasPointerCapture(b.pointerId)&&typeof b.currentTarget.releasePointerCapture=="function"&&b.currentTarget.releasePointerCapture(b.pointerId)}};return i.jsxs("label",{className:L("uk-switch",l),"data-disabled":s?"true":void 0,htmlFor:o,onClickCapture:b=>{v.current&&(b.preventDefault(),b.stopPropagation())},children:[i.jsx("input",{...p,ref:u,id:o,type:"checkbox",role:"switch",className:"uk-switch__input",checked:k,disabled:s,"aria-checked":k,onChange:b=>g(b.target.checked)}),i.jsx("span",{className:"uk-switch__track","aria-hidden":"true",onPointerDown:b=>{s||(x.current={pointerId:b.pointerId,startX:b.clientX,startValue:C.get(),moved:!1,samples:[{x:b.clientX,time:performance.now()}]},typeof b.currentTarget.setPointerCapture=="function"&&b.currentTarget.setPointerCapture(b.pointerId))},onPointerMove:b=>{const f=x.current;if(!f||f.pointerId!==b.pointerId)return;const j=b.clientX-f.startX;Math.abs(j)>4&&(f.moved=!0),f.moved&&(b.preventDefault(),C.set(Math.max(0,Math.min(16,f.startValue+j))),f.samples.push({x:b.clientX,time:performance.now()}),f.samples=f.samples.filter(E=>performance.now()-E.time<120))},onPointerUp:I,onPointerCancel:I,children:i.jsx(w.motion.span,{className:"uk-switch__thumb",style:{x:C}})}),c?i.jsx("span",{className:"uk-switch__label",children:c}):null]})}),he=a.createContext(null);function me(t){const e=a.useContext(he);if(!e)throw new Error(`<${t}> must be rendered inside <Sidebar>`);return e}function X(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function nt({children:t,className:e,hoverPreview:n=!0,hoverIndicator:r="rail",groupGap:s,style:l,...c}){const[d,p]=a.useState(null),u=a.useId().replace(/:/g,""),m=a.useMemo(()=>({hoveredId:d,setHoveredId:p,indicatorBaseId:u,hoverPreview:n,hoverIndicator:r}),[d,u,n,r]),o=typeof s=="number"?`${s}px`:s,h={...l,...o===void 0?{}:{"--uk-sidebar-group-gap":o}};return i.jsx(he.Provider,{value:m,children:i.jsx(w.LayoutGroup,{id:`sidebar-${u}`,children:i.jsx("nav",{...c,className:L("uk-sidebar",e),style:h,children:t})})})}function ot({title:t,icon:e,collapsible:n=!1,open:r,defaultOpen:s=!0,onOpenChange:l,children:c,className:d,...p}){const u=a.useId(),m=a.useId(),o=a.useId(),h=a.useRef(null),v=a.useRef(null),x=me("Sidebar.Group"),k=e!=null,g=w.useReducedMotion()??!1,[C,I]=P.useControllableState({value:r,defaultValue:s,onChange:l}),b=n?C:!0,f=x.hoveredId===o;a.useEffect(()=>{!n||b||v.current?.contains(document.activeElement)&&h.current?.focus()},[n,b]);const j=i.jsxs(i.Fragment,{children:[k?i.jsx("span",{className:"uk-sidebar__group-icon","aria-hidden":"true",children:e}):null,i.jsx("span",{className:"uk-sidebar__group-label",children:t}),n?i.jsx("span",{className:"uk-sidebar__chevron","aria-hidden":"true",children:i.jsx("svg",{viewBox:"0 0 16 16",width:"12",height:"12",fill:"none",children:i.jsx("path",{d:"m6 3.8 4.2 4.2L6 12.2",stroke:"currentColor",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round"})})}):null]});return i.jsxs("section",{...p,className:L("uk-sidebar__group",d),"aria-labelledby":p["aria-labelledby"]??u,"data-collapsible":n?"true":"false","data-has-icon":k?"true":"false","data-state":b?"open":"closed",children:[n?i.jsxs("button",{ref:h,type:"button",className:"uk-sidebar__group-title uk-sidebar__group-trigger",id:u,"aria-controls":m,"aria-expanded":b,"data-preview":x.hoverIndicator==="background"&&f?"true":void 0,onClick:()=>I(E=>!E),onPointerEnter:E=>{x.hoverPreview&&x.hoverIndicator==="background"&&E.pointerType==="mouse"&&x.setHoveredId(o)},onPointerLeave:()=>{x.hoveredId===o&&x.setHoveredId(null)},onPointerCancel:()=>{x.hoveredId===o&&x.setHoveredId(null)},children:[i.jsx(w.AnimatePresence,{initial:!1,children:x.hoverPreview&&x.hoverIndicator==="background"&&f?i.jsx(w.motion.span,{className:"uk-sidebar__group-surface","data-kind":"hover","data-slot":"sidebar-hover-highlight",layoutId:`${x.indicatorBaseId}-hover`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:g?{duration:0}:U}):null}),j]}):i.jsx("div",{className:"uk-sidebar__group-title",id:u,children:j}),i.jsx(w.motion.div,{ref:v,className:"uk-sidebar__content",id:m,"data-state":b?"open":"closed",initial:!1,animate:{height:b?"auto":0,opacity:b?1:0},transition:g?{duration:0}:ce,inert:n&&!b,"aria-hidden":n&&!b?!0:void 0,children:i.jsx("ul",{className:"uk-sidebar__list",children:c})})]})}function rt({active:t=!1,children:e,className:n}){const r=me("Sidebar.Item"),s=a.useId(),c=w.useReducedMotion()??!1?{duration:0}:U;if(!a.isValidElement(e))throw new Error("<Sidebar.Item> expects a single valid React element");const d=e,p=d.props,u=p.className,m=typeof u=="function"?g=>L("uk-sidebar__link",u(g),n):L("uk-sidebar__link",u,n),o=p.onPointerEnter,h=p.onPointerLeave,v=p.onPointerCancel,x=r.hoveredId===s,k=i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"uk-sidebar__rail","aria-hidden":"true"}),i.jsx(w.AnimatePresence,{initial:!1,children:r.hoverPreview&&r.hoverIndicator==="rail"&&x?i.jsx(w.motion.span,{className:"uk-sidebar__rail-indicator","data-kind":"hover","data-slot":"sidebar-hover-rail-indicator",layoutId:`${r.indicatorBaseId}-hover-rail`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx(w.AnimatePresence,{initial:!1,children:r.hoverIndicator==="rail"&&t?i.jsx(w.motion.span,{className:"uk-sidebar__rail-indicator","data-kind":"active","data-slot":"sidebar-active-rail-indicator",layoutId:`${r.indicatorBaseId}-active-rail`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx(w.AnimatePresence,{initial:!1,children:r.hoverPreview&&r.hoverIndicator==="background"&&x?i.jsx(w.motion.span,{className:"uk-sidebar__surface","data-kind":"hover","data-slot":"sidebar-hover-highlight",layoutId:`${r.indicatorBaseId}-hover`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx(w.AnimatePresence,{initial:!1,children:r.hoverIndicator==="background"&&t?i.jsx(w.motion.span,{className:"uk-sidebar__surface","data-kind":"active","data-slot":"sidebar-active-highlight",layoutId:`${r.indicatorBaseId}-active`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:c}):null}),i.jsx("span",{className:"uk-sidebar__label",children:p.children})]});return i.jsx("li",{className:"uk-sidebar__item",children:a.cloneElement(d,{className:m,"data-active":t?"true":"false","data-preview":t||x?"true":"false","aria-current":p["aria-current"]??(t?"page":void 0),onPointerEnter:X(o,g=>{r.hoverPreview&&g.pointerType==="mouse"&&r.setHoveredId(s)}),onPointerLeave:X(h,()=>{r.hoveredId===s&&r.setHoveredId(null)}),onPointerCancel:X(v,()=>{r.hoveredId===s&&r.setHoveredId(null)})},k)})}const it=Object.assign(nt,{Group:ot,Item:rt}),xe=a.createContext(null);function ee(t){const e=a.useContext(xe);if(!e)throw new Error(`<${t}> must be rendered inside <Tabs>`);return e}function be(t,e){return`${t}-tab-${encodeURIComponent(e)}`}function ge(t,e){return`${t}-panel-${encodeURIComponent(e)}`}function st({value:t,defaultValue:e,onValueChange:n,orientation:r="horizontal",className:s,children:l}){const c=a.useId(),[d,p]=P.useControllableState({value:t,defaultValue:e??"",onChange:n}),u=a.useMemo(()=>({baseId:c,value:d,setValue:p,orientation:r,indicatorId:`${c}-indicator`}),[c,d,r,p]);return i.jsx(xe.Provider,{value:u,children:i.jsx("div",{className:L("uk-tabs",s),"data-orientation":r,children:l})})}const at=a.forwardRef(function({className:e,onKeyDown:n,...r},s){const{orientation:l}=ee("Tabs.List");return i.jsx("div",{...r,ref:s,role:"tablist","aria-orientation":l,tabIndex:-1,className:L("uk-tabs__list",e),onKeyDown:c=>{if(n?.(c),c.defaultPrevented)return;const p=c.target?.closest('[role="tab"]');if(!p||p.hasAttribute("disabled"))return;const u=Array.from(c.currentTarget.querySelectorAll('[role="tab"]:not([disabled])')),m=u.indexOf(p);if(m===-1)return;const o=l==="horizontal"?"ArrowRight":"ArrowDown",h=l==="horizontal"?"ArrowLeft":"ArrowUp";let v=-1;switch(c.key){case o:v=(m+1)%u.length;break;case h:v=(m-1+u.length)%u.length;break;case"Home":v=0;break;case"End":v=u.length-1;break;default:return}c.preventDefault();const x=u[v];x&&(x.focus(),x.click())}})}),ct=a.forwardRef(function({value:e,type:n="button",className:r,onClick:s,children:l,...c},d){const p=ee("Tabs.Trigger"),u=p.value===e,m=w.useReducedMotion()??!1;return i.jsxs("button",{...c,ref:d,type:n,role:"tab",id:be(p.baseId,e),"aria-selected":u,"aria-controls":ge(p.baseId,e),tabIndex:u?0:-1,"data-state":u?"active":"inactive",className:L("uk-tabs__trigger",r),onClick:o=>{s?.(o),o.defaultPrevented||p.setValue(e)},children:[l,u?i.jsx(w.motion.span,{className:"uk-tabs__indicator",layoutId:p.indicatorId,"aria-hidden":"true",transition:m?{duration:0}:U}):null]})}),lt=a.forwardRef(function({value:e,className:n,...r},s){const l=ee("Tabs.Content"),c=l.value===e;return i.jsx("div",{...r,ref:s,role:"tabpanel",id:ge(l.baseId,e),"aria-labelledby":be(l.baseId,e),hidden:!c,tabIndex:0,"data-state":c?"active":"inactive",className:L("uk-tabs__panel",n)})}),ut=Object.assign(st,{List:at,Trigger:ct,Content:lt}),ve=a.createContext(null),dt=()=>()=>{},ft=()=>!0,pt=()=>!1;function q(t){const e=a.useContext(ve);if(!e)throw new Error(`<${t}> must be rendered inside <Dialog.Root>`);return e}function ye(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function ke({children:t,open:e,defaultOpen:n,onOpenChange:r}){const s=a.useId(),[l,c]=a.useState(!1),[d,p]=a.useState(!1),[u,m]=P.useControllableState({value:e,defaultValue:n??!1,onChange:r}),o=a.useMemo(()=>({open:u,setOpen:m,triggerId:`${s}-trigger`,contentId:`${s}-content`,titleId:`${s}-title`,descriptionId:`${s}-description`,hasTitle:l,setHasTitle:c,hasDescription:d,setHasDescription:p}),[s,u,d,l,m]);return i.jsx(ve.Provider,{value:o,children:t})}function ht({children:t}){const e=q("Dialog.Trigger"),n=t,r=n.props.onClick;return a.cloneElement(n,{id:e.triggerId,"aria-haspopup":"dialog","aria-expanded":e.open,"aria-controls":e.open?e.contentId:void 0,onClick:ye(r,()=>{e.setOpen(!e.open)})})}function Ie({children:t,label:e="Close"}){const n=q("Dialog.Close");if(a.isValidElement(t)){const r=t,s=r.props.onClick;return a.cloneElement(r,{onClick:ye(s,()=>{n.setOpen(!1)})})}return i.jsx(Q,{variant:"ghost",onClick:()=>n.setOpen(!1),children:e})}const we=a.forwardRef(function({className:e,...n},r){return i.jsx("header",{...n,ref:r,className:L("uk-dialog__header",e)})}),Ce=a.forwardRef(function({className:e,children:n,...r},s){const l=q("Dialog.Title"),c=l.setHasTitle;return a.useEffect(()=>(c(!0),()=>c(!1)),[c]),i.jsx("h2",{...r,ref:s,id:l.titleId,className:L("uk-dialog__title",e),children:n})}),_e=a.forwardRef(function({className:e,...n},r){const s=q("Dialog.Description"),l=s.setHasDescription;return a.useEffect(()=>(l(!0),()=>l(!1)),[l]),i.jsx("p",{...n,ref:r,id:s.descriptionId,className:L("uk-dialog__description",e)})}),je=a.forwardRef(function({className:e,...n},r){return i.jsx("div",{...n,ref:r,className:L("uk-dialog__body",e)})}),Te=a.forwardRef(function({className:e,...n},r){return i.jsx("footer",{...n,ref:r,className:L("uk-dialog__footer",e)})});function mt({requestClose:t,contentId:e,titleId:n,descriptionId:r,hasTitle:s,hasDescription:l,children:c,closeOnBackdropClick:d=!0,closeOnEscape:p=!0,initialFocusRef:u,returnFocusRef:m,className:o,"aria-label":h,"aria-labelledby":v,"aria-describedby":x}){const k=a.useRef(null),g=a.useRef(null),C=w.useIsPresent(),I=w.useReducedMotion()??!1;return P.useLockBodyScroll(!0),a.useLayoutEffect(()=>{const b=k.current;b&&(g.current??(g.current=document.activeElement instanceof HTMLElement?document.activeElement:null),!b.open&&(typeof b.showModal=="function"?b.showModal():b.setAttribute("open","")))},[]),P.useFocusTrap({active:!0,containerRef:k,initialFocusRef:u,returnFocusRef:m??g}),a.useEffect(()=>{const b=k.current;if(!b)return;const f=()=>{b.open||(typeof b.showModal=="function"?b.showModal():b.setAttribute("open",""))},j=()=>{if(!p){f();return}t()},E=T=>{T.preventDefault(),p&&t()},y=T=>{p||T.key!=="Escape"||T.defaultPrevented||(T.preventDefault(),T.stopPropagation())},_=T=>{d&&T.target===b&&t()};return b.addEventListener("close",j),b.addEventListener("cancel",E),b.addEventListener("keydown",y,!0),b.addEventListener("click",_),()=>{b.removeEventListener("close",j),b.removeEventListener("cancel",E),b.removeEventListener("keydown",y,!0),b.removeEventListener("click",_)}},[d,p,t]),i.jsx("dialog",{ref:k,id:e,className:L("uk-dialog",o),closedby:p||d?"any":"none","data-state":C?"open":"closed",inert:!C,"aria-label":h,"aria-labelledby":v??(h?void 0:s?n:void 0),"aria-describedby":x??(l?r:void 0),children:i.jsx(w.motion.div,{className:"uk-dialog__panel",initial:I?{opacity:0}:{opacity:0,transform:"translateY(12px) scale(0.96)"},animate:{opacity:1,transform:"translateY(0px) scale(1)",transition:I?H:{...oe,delay:.06}},exit:I?{opacity:0,transition:H}:{opacity:0,transform:"translateY(8px) scale(0.97)",transition:oe},children:c})})}function Ee({children:t,closeOnBackdropClick:e=!0,closeOnEscape:n=!0,initialFocusRef:r,returnFocusRef:s,className:l,"aria-label":c,"aria-labelledby":d,"aria-describedby":p}){const u=q("Dialog.Content"),m=P.useEventCallback(()=>{u.setOpen(!1)});return a.useSyncExternalStore(dt,ft,pt)?G.createPortal(i.jsx(w.MotionConfig,{reducedMotion:"user",children:i.jsx(w.AnimatePresence,{children:u.open?i.jsx(mt,{requestClose:m,contentId:u.contentId,titleId:u.titleId,descriptionId:u.descriptionId,hasTitle:u.hasTitle,hasDescription:u.hasDescription,closeOnBackdropClick:e,closeOnEscape:n,initialFocusRef:r,returnFocusRef:s,className:l,"aria-label":c,"aria-labelledby":d,"aria-describedby":p,children:t},"uk-dialog"):null})}),document.body):null}function xt({open:t,onOpenChange:e,title:n,description:r,footer:s,children:l,closeLabel:c="Close",showCloseButton:d=!0,closeOnBackdropClick:p=!0,closeOnEscape:u=!0,initialFocusRef:m,returnFocusRef:o,className:h,"aria-label":v}){return i.jsx(ke,{open:t,onOpenChange:e,children:i.jsxs(Ee,{className:h,closeOnBackdropClick:p,closeOnEscape:u,initialFocusRef:m,returnFocusRef:o,"aria-label":v,children:[n||r||d?i.jsxs(we,{children:[i.jsxs("div",{className:"uk-dialog__heading",children:[n?i.jsx(Ce,{children:n}):null,r?i.jsx(_e,{children:r}):null]}),d?i.jsx(Ie,{children:i.jsx(Q,{variant:"ghost",size:"sm",iconOnly:!0,"aria-label":c,className:"uk-dialog__close",children:i.jsx("svg",{viewBox:"0 0 20 20",width:"16",height:"16","aria-hidden":"true",children:i.jsx("path",{d:"M5 5l10 10M15 5L5 15",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})})})}):null]}):null,i.jsx(je,{children:l}),s?i.jsx(Te,{children:s}):null]})})}const bt=Object.assign(xt,{Root:ke,Trigger:ht,Content:Ee,Header:we,Title:Ce,Description:_e,Body:je,Footer:Te,Close:Ie});function gt(t,e){if(!(e instanceof Element))return!1;const n=e.closest('a, button, input, select, textarea, label, [contenteditable="true"], [role="button"]');return n!==null&&n!==t}const vt=a.forwardRef(function({children:e,className:n,direction:r="left",speed:s=30,pauseOnHover:l=!0,gap:c="1rem",fade:d=!0,paused:p=!1,items:u,onItemClick:m,...o},h){const v=u?u.map(g=>({key:g.key,content:g.content,data:g.data})):a.Children.toArray(e).map((g,C)=>({key:a.isValidElement(g)?g.key??null:null,content:g,data:void 0})),x=(g,C,I)=>{!m||I.defaultPrevented||gt(I.currentTarget,I.target)||m({index:C,key:g.key,data:g.data},I)},k=(g,C,I)=>{!m||I.defaultPrevented||(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),m({index:C,key:g.key,data:g.data},I))};return i.jsx("div",{...o,ref:h,className:L("uk-marquee",n),"data-direction":r,"data-fade":d?"true":void 0,"data-pause-on-hover":l?"true":void 0,"data-paused":p?"true":"false",style:{...o.style,"--uk-marquee-gap":c,"--uk-marquee-duration":`${s}s`,gap:c},children:[!1,!0].map(g=>i.jsx("div",{"aria-hidden":g,className:"uk-marquee__track","data-duplicate":g?"true":void 0,inert:g&&!m,role:g?"presentation":void 0,onFocusCapture:g?C=>{C.target instanceof HTMLElement&&C.target.blur()}:void 0,children:v.map((C,I)=>i.jsx("div",{className:"uk-marquee__item","data-clickable":m?"true":void 0,...m?{role:g?void 0:"button",tabIndex:g?-1:0,onClick:b=>x(C,I,b),onKeyDown:g?void 0:b=>k(C,I,b)}:{},children:C.content},g?`duplicate-${I}`:C.key??I))},g?"duplicate":"primary"))})}),Ne=a.createContext(null),Se=()=>()=>{},Re=()=>!0,Pe=()=>!1;function Le(t){const e=a.useContext(Ne);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Root>`);return e}function De(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function Me(t,e){const n=typeof t=="string"?t.split(/\s+/).filter(Boolean):[];return Array.from(new Set([...n,e])).join(" ")}function A(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function yt({children:t,open:e,defaultOpen:n,onOpenChange:r,delayDuration:s=300,closeDelay:l=80}){const c=a.useId(),[d,p]=a.useState(null),u=a.useRef(null),m=a.useRef(null),[o,h]=P.useControllableState({value:e,defaultValue:n??!1,onChange:r}),v=a.useCallback(()=>{u.current!==null&&(clearTimeout(u.current),u.current=null)},[]),x=a.useCallback(()=>{m.current!==null&&(clearTimeout(m.current),m.current=null)},[]),k=P.useEventCallback((b=!1)=>{if(v(),x(),!o){if(b||s<=0){h(!0);return}u.current=setTimeout(()=>{u.current=null,h(!0)},s)}}),g=P.useEventCallback(()=>{if(v(),x(),!!o){if(l<=0){h(!1);return}m.current=setTimeout(()=>{m.current=null,h(!1)},l)}}),C=P.useEventCallback(()=>{v(),x(),h(!1)});a.useEffect(()=>{o?x():v()},[x,v,o]),a.useEffect(()=>()=>{v(),x()},[x,v]);const I=a.useMemo(()=>({open:o,triggerElement:d,setTriggerElement:p,contentId:c,requestOpen:k,requestClose:g,dismiss:C}),[c,o,C,g,k,d]);return i.jsx(Ne.Provider,{value:I,children:t})}function kt({children:t}){const e=Le("Tooltip.Trigger"),{setTriggerElement:n}=e;if(!a.isValidElement(t))throw new Error("<Tooltip.Trigger> expects a single valid React element");const r=t,s=r.props,l=s.ref??r.ref,c=s.onPointerEnter,d=s.onPointerLeave,p=s.onFocus,u=s.onBlur,m=s.onKeyDown,o=a.useCallback(h=>{De(l,h),n(h)},[l,n]);return a.cloneElement(r,{ref:o,"aria-describedby":e.open?Me(s["aria-describedby"],e.contentId):s["aria-describedby"],onPointerEnter:A(c,h=>{e.requestOpen(h.pointerType==="touch")}),onPointerLeave:A(d,h=>{h.pointerType!=="touch"&&e.requestClose()}),onFocus:A(p,()=>{e.requestOpen()}),onBlur:A(u,()=>{e.requestClose()}),onKeyDown:A(m,h=>{h.key==="Escape"&&e.open&&(h.preventDefault(),h.stopPropagation(),e.dismiss())})})}function F(t,e,n){return n<e?e:Math.min(Math.max(t,e),n)}function It(t){switch(t){case"top":return"bottom";case"right":return"left";case"bottom":return"top";case"left":return"right"}}function J(t,e,n,r,s){switch(e){case"top":return t.top-s;case"right":return n-t.right-s;case"bottom":return r-t.bottom-s;case"left":return t.left-s}}function se(t,e,n,r,s,l,c){return J(t,n,s,l,c)>=(n==="top"||n==="bottom"?e.height:e.width)+r}function wt({trigger:t,tooltip:e,side:n,align:r,sideOffset:s,collisionPadding:l,avoidCollisions:c,viewportWidth:d,viewportHeight:p}){let u=n;if(c&&!se(t,e,n,s,d,p,l)){const g=It(n),C=se(t,e,g,s,d,p,l),I=J(t,n,d,p,l),b=J(t,g,d,p,l);(C||b>I)&&(u=g)}const m=t.left+t.width/2,o=t.top+t.height/2;let h=0,v=0;switch(u){case"top":case"bottom":h=r==="start"?t.left:r==="end"?t.right-e.width:m-e.width/2,v=u==="top"?t.top-e.height-s:t.bottom+s;break;case"left":case"right":h=u==="left"?t.left-e.width-s:t.right+s,v=r==="start"?t.top:r==="end"?t.bottom-e.height:o-e.height/2;break}c&&(h=F(h,l,d-e.width-l),v=F(v,l,p-e.height-l));const x=10,k=u==="top"||u==="bottom"?F(m-h,x,Math.max(x,e.width-x)):F(o-v,x,Math.max(x,e.height-x));return{x:h,y:v,side:u,arrowOffset:k}}function Oe(t,e,{side:n,align:r,sideOffset:s,collisionPadding:l,avoidCollisions:c}){const[d,p]=a.useState(null);return a.useLayoutEffect(()=>{const u=e.current;if(!u||!t)return;const m=()=>{const h=t.getBoundingClientRect(),v=u.getBoundingClientRect();p(wt({trigger:h,tooltip:v,side:n,align:r,sideOffset:s,collisionPadding:l,avoidCollisions:c,viewportWidth:window.innerWidth||document.documentElement.clientWidth,viewportHeight:window.innerHeight||document.documentElement.clientHeight}))};m(),window.addEventListener("resize",m),window.addEventListener("scroll",m,!0);const o=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return o?.observe(t),o?.observe(u),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0),o?.disconnect()}},[r,c,l,e,n,s,t]),d}function $e(t,e,n){a.useEffect(()=>{const r=c=>{const d=c.target;d instanceof Node&&(t.contains(d)||e.current?.contains(d)||n())},s=()=>{document.visibilityState==="hidden"&&n()},l=c=>{const d=c.target;c.key!=="Escape"||d instanceof Node&&t.contains(d)||n()};return document.addEventListener("pointerdown",r,!0),document.addEventListener("visibilitychange",s),document.addEventListener("keydown",l,!0),window.addEventListener("blur",n),()=>{document.removeEventListener("pointerdown",r,!0),document.removeEventListener("visibilitychange",s),document.removeEventListener("keydown",l,!0),window.removeEventListener("blur",n)}},[n,e,t])}function Ae(t){switch(t){case"top":return"center bottom";case"bottom":return"center top";case"left":return"right center";case"right":return"left center";default:return"center"}}function Ct({contentId:t,triggerElement:e,dismiss:n,children:r,className:s,style:l,side:c="top",align:d="center",sideOffset:p=8,collisionPadding:u=8,avoidCollisions:m=!0,...o}){const h=a.useRef(null),v=w.useReducedMotion()??!1,x=w.useIsPresent(),k=Oe(e,h,{side:c,align:d,sideOffset:p,collisionPadding:u,avoidCollisions:m});$e(e,h,n);const g=Ae(k?.side??c),C={...l,left:k?`${k.x}px`:0,top:k?`${k.y}px`:0,visibility:k?"visible":"hidden"};return i.jsx("div",{...o,ref:h,id:t,role:"tooltip","data-side":k?.side??c,"data-align":d,"data-state":x?"open":"closed","aria-hidden":x?void 0:!0,className:L("uk-tooltip",s),style:C,children:i.jsxs(w.motion.div,{className:"uk-tooltip__surface",style:{transformOrigin:g},initial:v?{opacity:0}:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:v?{opacity:0}:{opacity:0,scale:.96},transition:v?H:le,children:[i.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${k?.arrowOffset??0}px`}}),r]})})}function _t(t){const e=Le("Tooltip.Content"),r=a.useSyncExternalStore(Se,Re,Pe)&&e.triggerElement?e.triggerElement.closest("dialog")??document.body:null;return!r||!e.triggerElement?null:G.createPortal(i.jsx(w.MotionConfig,{reducedMotion:"user",children:i.jsx(w.AnimatePresence,{children:e.open?i.jsx(Ct,{contentId:e.contentId,triggerElement:e.triggerElement,dismiss:e.dismiss,...t},"uk-tooltip"):null})}),r)}const Be=a.createContext(null);function jt(t){const e=a.useContext(Be);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Group>`);return e}function Tt({activeValue:t,content:e,contentClassName:n,contentId:r,dismiss:s,triggerElement:l,side:c,align:d,sideOffset:p,collisionPadding:u,avoidCollisions:m}){const o=a.useRef(null),h=w.useReducedMotion()??!1,v=w.useIsPresent(),x=Oe(l,o,{side:c,align:d,sideOffset:p,collisionPadding:u,avoidCollisions:m});$e(l,o,s);const k={left:x?`${x.x}px`:0,top:x?`${x.y}px`:0,transformOrigin:Ae(x?.side??c),visibility:x?"visible":"hidden"};return i.jsxs(w.motion.div,{ref:o,id:r,role:"tooltip",layout:!h,layoutDependency:t,"data-side":x?.side??c,"data-align":d,"data-state":v?"open":"closed","aria-hidden":v?void 0:!0,className:L("uk-tooltip","uk-tooltip__surface","uk-tooltip--group",n),style:k,initial:h?{opacity:0}:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:h?{opacity:0}:{opacity:0,scale:.96},transition:h?{...H,layout:{duration:0}}:ze,children:[i.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${x?.arrowOffset??0}px`}}),i.jsx(w.motion.div,{className:"uk-tooltip__content",initial:{opacity:0},animate:{opacity:1},transition:h?H:le,children:e},t)]})}function Et({children:t,side:e="top",align:n="center",sideOffset:r=8,collisionPadding:s=8,avoidCollisions:l=!0,delayDuration:c=180,closeDelay:d=80,contentClassName:p}){const u=a.useId(),[m,o]=a.useState(()=>new Map),[h,v]=a.useState(!1),[x,k]=a.useState(null),g=a.useRef(null),C=a.useRef(null),I=a.useSyncExternalStore(Se,Re,Pe),b=a.useCallback(()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},[]),f=a.useCallback(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null)},[]),j=P.useEventCallback((O,M=!1)=>{if(b(),f(),k(O),!h){if(M||c<=0){v(!0);return}g.current=setTimeout(()=>{g.current=null,v(!0)},c)}}),E=P.useEventCallback(()=>{if(b(),f(),!!h){if(d<=0){v(!1);return}C.current=setTimeout(()=>{C.current=null,v(!1)},d)}}),y=P.useEventCallback(()=>{b(),f(),v(!1)}),_=P.useEventCallback((O,M,B)=>{o(V=>{const $=V.get(O);if($?.triggerElement===M&&Object.is($.content,B))return V;const te=new Map(V);return te.set(O,{triggerElement:M,content:B}),te})}),T=P.useEventCallback(O=>{o(M=>{if(!M.has(O))return M;const B=new Map(M);return B.delete(O),B})});a.useEffect(()=>()=>{b(),f()},[f,b]);const S=a.useMemo(()=>({open:h,activeValue:x,contentId:u,activate:j,requestClose:E,dismiss:y,register:_,unregister:T}),[j,x,u,y,h,_,E,T]),N=x?m.get(x):void 0,R=h&&!!N,D=I&&N?N.triggerElement.closest("dialog")??document.body:null;return i.jsxs(Be.Provider,{value:S,children:[t,D&&N?G.createPortal(i.jsx(w.MotionConfig,{reducedMotion:"user",children:i.jsx(w.AnimatePresence,{children:R?i.jsx(Tt,{activeValue:x??"",content:N.content,contentClassName:p,contentId:u,dismiss:y,triggerElement:N.triggerElement,side:e,align:n,sideOffset:r,collisionPadding:s,avoidCollisions:l},"uk-tooltip-group"):null})}),D):null]})}function Nt({value:t,content:e,children:n}){const r=jt("Tooltip.Item"),{register:s,unregister:l}=r,[c,d]=a.useState(null);if(!a.isValidElement(n))throw new Error("<Tooltip.Item> expects a single valid React element");const p=n,u=p.props,m=u.ref??p.ref,o=u.onPointerEnter,h=u.onPointerLeave,v=u.onFocus,x=u.onBlur,k=u.onKeyDown,g=r.open&&r.activeValue===t,C=a.useCallback(I=>{De(m,I),d(I)},[m,d]);return a.useLayoutEffect(()=>{if(c)return s(t,c,e),()=>l(t)},[e,s,c,l,t]),a.cloneElement(p,{ref:C,"aria-describedby":g?Me(u["aria-describedby"],r.contentId):u["aria-describedby"],onPointerEnter:A(o,I=>{r.activate(t,I.pointerType==="touch")}),onPointerLeave:A(h,I=>{I.pointerType!=="touch"&&r.requestClose()}),onFocus:A(v,()=>{r.activate(t)}),onBlur:A(x,()=>{r.requestClose()}),onKeyDown:A(k,I=>{I.key==="Escape"&&g&&(I.preventDefault(),I.stopPropagation(),r.dismiss())})})}const St={Root:yt,Trigger:kt,Content:_t,Group:Et,Item:Nt};exports.Button=Q;exports.CheckBox=ae;exports.Dialog=bt;exports.Input=et;exports.Marquee=vt;exports.Select=Qe;exports.Sidebar=it;exports.Switch=tt;exports.Tabs=ut;exports.Tooltip=St;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|