seam-react 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Select.d.ts +33 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1109 -777
- package/dist/index.js.map +1 -1
- package/dist/styles.cjs +223 -2
- package/dist/styles.cjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.js +224 -3
- package/dist/styles.js.map +1 -1
- package/package.json +1 -1
package/dist/Select.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
export type SelectSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface SelectOption {
|
|
4
|
+
/** 提交给 onValueChange 的稳定值。 */
|
|
5
|
+
value: string;
|
|
6
|
+
/** 展示内容;缺省时渲染 value。 */
|
|
7
|
+
label?: ReactNode;
|
|
8
|
+
/** 是否禁止选择该项。 */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface SelectProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children" | "value" | "onChange" | "aria-expanded" | "defaultValue"> {
|
|
12
|
+
/** 可选项;label 用于展示,value 用于提交。 */
|
|
13
|
+
options: Array<SelectOption>;
|
|
14
|
+
/** 受控选中值。 */
|
|
15
|
+
value?: string | null;
|
|
16
|
+
/** 非受控模式下的初始值。 */
|
|
17
|
+
defaultValue?: string | null;
|
|
18
|
+
/** 选中值变化时触发。 */
|
|
19
|
+
onValueChange?: (value: string) => void;
|
|
20
|
+
/** 未选择时的展示文本。 */
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
/** 控件尺寸。 */
|
|
23
|
+
size?: SelectSize;
|
|
24
|
+
/** 是否禁用整个控件。 */
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
/** 列表为空时的提示文本。 */
|
|
27
|
+
emptyText?: string;
|
|
28
|
+
/** 标记选择值无效,使用共享 invalid 样式。 */
|
|
29
|
+
invalid?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Select 单控件:受控/非受控选择、键盘搜索语义由内部共享。 */
|
|
32
|
+
declare const Select: import("react").ForwardRefExoticComponent<SelectProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
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"),w=require("seam-hooks"),I=require("motion/react"),F=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:r=!1,type:l="button",className:c,children:p,...f},s){return i.jsxs("button",{...f,ref:s,type:l,className:T("uk-button",c),"data-variant":e,"data-size":n,"data-loading":o?"true":void 0,"data-icon-only":r?"true":void 0,disabled:f.disabled||o,"aria-busy":o||void 0,children:[o?i.jsx("span",{className:"uk-button__spinner","aria-hidden":"true"}):null,p]})}),Z=a.forwardRef(function({checked:e,defaultChecked:n,onCheckedChange:o,disabled:r,className:l,children:c,id:p,...f},s){const m=a.useId(),b=p??m,[h,g]=w.useControllableState({value:e,defaultValue:n??!1,onChange:o});return i.jsxs("label",{className:T("uk-checkbox",l),"data-disabled":r?"true":void 0,htmlFor:b,children:[i.jsx("input",{...f,ref:s,id:b,type:"checkbox",className:"uk-checkbox__input",checked:h,disabled:r,onChange:d=>{r||g(d.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]})});Z.displayName="CheckBox";const Re=a.forwardRef(function({inputSize:e="md",invalid:n=!1,className:o,"aria-invalid":r,...l},c){return i.jsx("input",{...l,ref:c,className:T("uk-input",o),"data-size":e,"aria-invalid":n?!0:r})}),B=[.23,1,.32,1],Pe=[.77,0,.175,1],W={type:"spring",bounce:0,duration:.3},J={type:"spring",bounce:.04,duration:.38},K={type:"spring",bounce:.08,duration:.34},Ne={duration:.2,ease:Pe},ee={duration:.12,ease:B},Se={layout:{type:"spring",bounce:0,duration:.22},opacity:{duration:.12,ease:B},scale:{duration:.12,ease:B}},O={duration:.12,ease:B},De=a.forwardRef(function({checked:e,defaultChecked:n,onCheckedChange:o,disabled:r,className:l,children:c,id:p,...f},s){const m=a.useId(),b=p??m,h=I.useReducedMotion()??!1,g=a.useRef(!1),d=a.useRef(null),[k,x]=w.useControllableState({value:e,defaultValue:n??!1,onChange:o}),v=I.useMotionValue(k?16:0);a.useEffect(()=>{if(d.current)return;const u=I.animate(v,k?16:0,h?{duration:0}:W);return()=>u.stop()},[k,h,v]);const y=u=>{const C=d.current;if(!(!C||C.pointerId!==u.pointerId)){if(C.moved){const _=C.samples[0],j=C.samples[C.samples.length-1],N=_&&j?Math.max(j.time-_.time,1):1,P=_&&j?(j.x-_.x)/N*1e3:0,E=Math.abs(P)>220?P>0:v.get()>=8;g.current=!0,d.current=null,x(E),I.animate(v,E?16:0,h?{duration:0}:{...W,velocity:P}),window.setTimeout(()=>{g.current=!1},0)}else d.current=null;u.currentTarget.hasPointerCapture(u.pointerId)&&typeof u.currentTarget.releasePointerCapture=="function"&&u.currentTarget.releasePointerCapture(u.pointerId)}};return i.jsxs("label",{className:T("uk-switch",l),"data-disabled":r?"true":void 0,htmlFor:b,onClickCapture:u=>{g.current&&(u.preventDefault(),u.stopPropagation())},children:[i.jsx("input",{...f,ref:s,id:b,type:"checkbox",role:"switch",className:"uk-switch__input",checked:k,disabled:r,"aria-checked":k,onChange:u=>x(u.target.checked)}),i.jsx("span",{className:"uk-switch__track","aria-hidden":"true",onPointerDown:u=>{r||(d.current={pointerId:u.pointerId,startX:u.clientX,startValue:v.get(),moved:!1,samples:[{x:u.clientX,time:performance.now()}]},typeof u.currentTarget.setPointerCapture=="function"&&u.currentTarget.setPointerCapture(u.pointerId))},onPointerMove:u=>{const C=d.current;if(!C||C.pointerId!==u.pointerId)return;const _=u.clientX-C.startX;Math.abs(_)>4&&(C.moved=!0),C.moved&&(u.preventDefault(),v.set(Math.max(0,Math.min(16,C.startValue+_))),C.samples.push({x:u.clientX,time:performance.now()}),C.samples=C.samples.filter(j=>performance.now()-j.time<120))},onPointerUp:y,onPointerCancel:y,children:i.jsx(I.motion.span,{className:"uk-switch__thumb",style:{x:v}})}),c?i.jsx("span",{className:"uk-switch__label",children:c}):null]})}),te=a.createContext(null);function ne(t){const e=a.useContext(te);if(!e)throw new Error(`<${t}> must be rendered inside <Sidebar>`);return e}function V(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function Le({children:t,className:e,hoverPreview:n=!0,hoverIndicator:o="rail",groupGap:r,style:l,...c}){const[p,f]=a.useState(null),s=a.useId().replace(/:/g,""),m=a.useMemo(()=>({hoveredId:p,setHoveredId:f,indicatorBaseId:s,hoverPreview:n,hoverIndicator:o}),[p,s,n,o]),b=typeof r=="number"?`${r}px`:r,h={...l,...b===void 0?{}:{"--uk-sidebar-group-gap":b}};return i.jsx(te.Provider,{value:m,children:i.jsx(I.LayoutGroup,{id:`sidebar-${s}`,children:i.jsx("nav",{...c,className:T("uk-sidebar",e),style:h,children:t})})})}function Me({title:t,icon:e,collapsible:n=!1,open:o,defaultOpen:r=!0,onOpenChange:l,children:c,className:p,...f}){const s=a.useId(),m=a.useId(),b=a.useId(),h=a.useRef(null),g=a.useRef(null),d=ne("Sidebar.Group"),k=e!=null,x=I.useReducedMotion()??!1,[v,y]=w.useControllableState({value:o,defaultValue:r,onChange:l}),u=n?v:!0,C=d.hoveredId===b;a.useEffect(()=>{!n||u||g.current?.contains(document.activeElement)&&h.current?.focus()},[n,u]);const _=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",{...f,className:T("uk-sidebar__group",p),"aria-labelledby":f["aria-labelledby"]??s,"data-collapsible":n?"true":"false","data-has-icon":k?"true":"false","data-state":u?"open":"closed",children:[n?i.jsxs("button",{ref:h,type:"button",className:"uk-sidebar__group-title uk-sidebar__group-trigger",id:s,"aria-controls":m,"aria-expanded":u,"data-preview":d.hoverIndicator==="background"&&C?"true":void 0,onClick:()=>y(j=>!j),onPointerEnter:j=>{d.hoverPreview&&d.hoverIndicator==="background"&&j.pointerType==="mouse"&&d.setHoveredId(b)},onPointerLeave:()=>{d.hoveredId===b&&d.setHoveredId(null)},onPointerCancel:()=>{d.hoveredId===b&&d.setHoveredId(null)},children:[i.jsx(I.AnimatePresence,{initial:!1,children:d.hoverPreview&&d.hoverIndicator==="background"&&C?i.jsx(I.motion.span,{className:"uk-sidebar__group-surface","data-kind":"hover","data-slot":"sidebar-hover-highlight",layoutId:`${d.indicatorBaseId}-hover`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:x?{duration:0}:K}):null}),_]}):i.jsx("div",{className:"uk-sidebar__group-title",id:s,children:_}),i.jsx(I.motion.div,{ref:g,className:"uk-sidebar__content",id:m,"data-state":u?"open":"closed",initial:!1,animate:{height:u?"auto":0,opacity:u?1:0},transition:x?{duration:0}:Ne,inert:n&&!u,"aria-hidden":n&&!u?!0:void 0,children:i.jsx("ul",{className:"uk-sidebar__list",children:c})})]})}function Oe({active:t=!1,children:e,className:n}){const o=ne("Sidebar.Item"),r=a.useId(),c=I.useReducedMotion()??!1?{duration:0}:K;if(!a.isValidElement(e))throw new Error("<Sidebar.Item> expects a single valid React element");const p=e,f=p.props,s=f.className,m=typeof s=="function"?x=>T("uk-sidebar__link",s(x),n):T("uk-sidebar__link",s,n),b=f.onPointerEnter,h=f.onPointerLeave,g=f.onPointerCancel,d=o.hoveredId===r,k=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"&&d?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"&&d?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:f.children})]});return i.jsx("li",{className:"uk-sidebar__item",children:a.cloneElement(p,{className:m,"data-active":t?"true":"false","data-preview":t||d?"true":"false","aria-current":f["aria-current"]??(t?"page":void 0),onPointerEnter:V(b,x=>{o.hoverPreview&&x.pointerType==="mouse"&&o.setHoveredId(r)}),onPointerLeave:V(h,()=>{o.hoveredId===r&&o.setHoveredId(null)}),onPointerCancel:V(g,()=>{o.hoveredId===r&&o.setHoveredId(null)})},k)})}const $e=Object.assign(Le,{Group:Me,Item:Oe}),oe=a.createContext(null);function z(t){const e=a.useContext(oe);if(!e)throw new Error(`<${t}> must be rendered inside <Tabs>`);return e}function re(t,e){return`${t}-tab-${encodeURIComponent(e)}`}function ae(t,e){return`${t}-panel-${encodeURIComponent(e)}`}function Ae({value:t,defaultValue:e,onValueChange:n,orientation:o="horizontal",className:r,children:l}){const c=a.useId(),[p,f]=w.useControllableState({value:t,defaultValue:e??"",onChange:n}),s=a.useMemo(()=>({baseId:c,value:p,setValue:f,orientation:o,indicatorId:`${c}-indicator`}),[c,p,o,f]);return i.jsx(oe.Provider,{value:s,children:i.jsx("div",{className:T("uk-tabs",r),"data-orientation":o,children:l})})}const Be=a.forwardRef(function({className:e,onKeyDown:n,...o},r){const{orientation:l}=z("Tabs.List");return i.jsx("div",{...o,ref:r,role:"tablist","aria-orientation":l,tabIndex:-1,className:T("uk-tabs__list",e),onKeyDown:c=>{if(n?.(c),c.defaultPrevented)return;const f=c.target?.closest('[role="tab"]');if(!f||f.hasAttribute("disabled"))return;const s=Array.from(c.currentTarget.querySelectorAll('[role="tab"]:not([disabled])')),m=s.indexOf(f);if(m===-1)return;const b=l==="horizontal"?"ArrowRight":"ArrowDown",h=l==="horizontal"?"ArrowLeft":"ArrowUp";let g=-1;switch(c.key){case b:g=(m+1)%s.length;break;case h:g=(m-1+s.length)%s.length;break;case"Home":g=0;break;case"End":g=s.length-1;break;default:return}c.preventDefault();const d=s[g];d&&(d.focus(),d.click())}})}),He=a.forwardRef(function({value:e,type:n="button",className:o,onClick:r,children:l,...c},p){const f=z("Tabs.Trigger"),s=f.value===e,m=I.useReducedMotion()??!1;return i.jsxs("button",{...c,ref:p,type:n,role:"tab",id:re(f.baseId,e),"aria-selected":s,"aria-controls":ae(f.baseId,e),tabIndex:s?0:-1,"data-state":s?"active":"inactive",className:T("uk-tabs__trigger",o),onClick:b=>{r?.(b),b.defaultPrevented||f.setValue(e)},children:[l,s?i.jsx(I.motion.span,{className:"uk-tabs__indicator",layoutId:f.indicatorId,"aria-hidden":"true",transition:m?{duration:0}:K}):null]})}),Ve=a.forwardRef(function({value:e,className:n,...o},r){const l=z("Tabs.Content"),c=l.value===e;return i.jsx("div",{...o,ref:r,role:"tabpanel",id:ae(l.baseId,e),"aria-labelledby":re(l.baseId,e),hidden:!c,tabIndex:0,"data-state":c?"active":"inactive",className:T("uk-tabs__panel",n)})}),qe=Object.assign(Ae,{List:Be,Trigger:He,Content:Ve}),ie=a.createContext(null),Fe=()=>()=>{},Ge=()=>!0,Ke=()=>!1;function $(t){const e=a.useContext(ie);if(!e)throw new Error(`<${t}> must be rendered inside <Dialog.Root>`);return e}function se(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function ce({children:t,open:e,defaultOpen:n,onOpenChange:o}){const r=a.useId(),[l,c]=a.useState(!1),[p,f]=a.useState(!1),[s,m]=w.useControllableState({value:e,defaultValue:n??!1,onChange:o}),b=a.useMemo(()=>({open:s,setOpen:m,triggerId:`${r}-trigger`,contentId:`${r}-content`,titleId:`${r}-title`,descriptionId:`${r}-description`,hasTitle:l,setHasTitle:c,hasDescription:p,setHasDescription:f}),[r,s,p,l,m]);return i.jsx(ie.Provider,{value:b,children:t})}function ze({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:se(o,()=>{e.setOpen(!e.open)})})}function le({children:t,label:e="Close"}){const n=$("Dialog.Close");if(a.isValidElement(t)){const o=t,r=o.props.onClick;return a.cloneElement(o,{onClick:se(r,()=>{n.setOpen(!1)})})}return i.jsx(G,{variant:"ghost",onClick:()=>n.setOpen(!1),children:e})}const ue=a.forwardRef(function({className:e,...n},o){return i.jsx("header",{...n,ref:o,className:T("uk-dialog__header",e)})}),de=a.forwardRef(function({className:e,children:n,...o},r){const l=$("Dialog.Title"),c=l.setHasTitle;return a.useEffect(()=>(c(!0),()=>c(!1)),[c]),i.jsx("h2",{...o,ref:r,id:l.titleId,className:T("uk-dialog__title",e),children:n})}),fe=a.forwardRef(function({className:e,...n},o){const r=$("Dialog.Description"),l=r.setHasDescription;return a.useEffect(()=>(l(!0),()=>l(!1)),[l]),i.jsx("p",{...n,ref:o,id:r.descriptionId,className:T("uk-dialog__description",e)})}),pe=a.forwardRef(function({className:e,...n},o){return i.jsx("div",{...n,ref:o,className:T("uk-dialog__body",e)})}),he=a.forwardRef(function({className:e,...n},o){return i.jsx("footer",{...n,ref:o,className:T("uk-dialog__footer",e)})});function Ue({requestClose:t,contentId:e,titleId:n,descriptionId:o,hasTitle:r,hasDescription:l,children:c,closeOnBackdropClick:p=!0,closeOnEscape:f=!0,initialFocusRef:s,returnFocusRef:m,className:b,"aria-label":h,"aria-labelledby":g,"aria-describedby":d}){const k=a.useRef(null),x=a.useRef(null),v=I.useIsPresent(),y=I.useReducedMotion()??!1;return w.useLockBodyScroll(!0),a.useLayoutEffect(()=>{const u=k.current;u&&(x.current??(x.current=document.activeElement instanceof HTMLElement?document.activeElement:null),!u.open&&(typeof u.showModal=="function"?u.showModal():u.setAttribute("open","")))},[]),w.useFocusTrap({active:!0,containerRef:k,initialFocusRef:s,returnFocusRef:m??x}),a.useEffect(()=>{const u=k.current;if(!u)return;const C=()=>{u.open||(typeof u.showModal=="function"?u.showModal():u.setAttribute("open",""))},_=()=>{if(!f){C();return}t()},j=E=>{E.preventDefault(),f&&t()},N=E=>{f||E.key!=="Escape"||E.defaultPrevented||(E.preventDefault(),E.stopPropagation())},P=E=>{p&&E.target===u&&t()};return u.addEventListener("close",_),u.addEventListener("cancel",j),u.addEventListener("keydown",N,!0),u.addEventListener("click",P),()=>{u.removeEventListener("close",_),u.removeEventListener("cancel",j),u.removeEventListener("keydown",N,!0),u.removeEventListener("click",P)}},[p,f,t]),i.jsx("dialog",{ref:k,id:e,className:T("uk-dialog",b),closedby:f||p?"any":"none","data-state":v?"open":"closed",inert:!v,"aria-label":h,"aria-labelledby":g??(h?void 0:r?n:void 0),"aria-describedby":d??(l?o:void 0),children:i.jsx(I.motion.div,{className:"uk-dialog__panel",initial:y?{opacity:0}:{opacity:0,transform:"translateY(12px) scale(0.96)"},animate:{opacity:1,transform:"translateY(0px) scale(1)",transition:y?O:{...J,delay:.06}},exit:y?{opacity:0,transition:O}:{opacity:0,transform:"translateY(8px) scale(0.97)",transition:J},children:c})})}function me({children:t,closeOnBackdropClick:e=!0,closeOnEscape:n=!0,initialFocusRef:o,returnFocusRef:r,className:l,"aria-label":c,"aria-labelledby":p,"aria-describedby":f}){const s=$("Dialog.Content"),m=w.useEventCallback(()=>{s.setOpen(!1)});return a.useSyncExternalStore(Fe,Ge,Ke)?F.createPortal(i.jsx(I.MotionConfig,{reducedMotion:"user",children:i.jsx(I.AnimatePresence,{children:s.open?i.jsx(Ue,{requestClose:m,contentId:s.contentId,titleId:s.titleId,descriptionId:s.descriptionId,hasTitle:s.hasTitle,hasDescription:s.hasDescription,closeOnBackdropClick:e,closeOnEscape:n,initialFocusRef:o,returnFocusRef:r,className:l,"aria-label":c,"aria-labelledby":p,"aria-describedby":f,children:t},"uk-dialog"):null})}),document.body):null}function Xe({open:t,onOpenChange:e,title:n,description:o,footer:r,children:l,closeLabel:c="Close",showCloseButton:p=!0,closeOnBackdropClick:f=!0,closeOnEscape:s=!0,initialFocusRef:m,returnFocusRef:b,className:h,"aria-label":g}){return i.jsx(ce,{open:t,onOpenChange:e,children:i.jsxs(me,{className:h,closeOnBackdropClick:f,closeOnEscape:s,initialFocusRef:m,returnFocusRef:b,"aria-label":g,children:[n||o||p?i.jsxs(ue,{children:[i.jsxs("div",{className:"uk-dialog__heading",children:[n?i.jsx(de,{children:n}):null,o?i.jsx(fe,{children:o}):null]}),p?i.jsx(le,{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(pe,{children:l}),r?i.jsx(he,{children:r}):null]})})}const Ye=Object.assign(Xe,{Root:ce,Trigger:ze,Content:me,Header:ue,Title:de,Description:fe,Body:pe,Footer:he,Close:le});function We(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 Je=a.forwardRef(function({children:e,className:n,direction:o="left",speed:r=30,pauseOnHover:l=!0,gap:c="1rem",fade:p=!0,paused:f=!1,items:s,onItemClick:m,...b},h){const g=s?s.map(x=>({key:x.key,content:x.content,data:x.data})):a.Children.toArray(e).map((x,v)=>({key:a.isValidElement(x)?x.key??null:null,content:x,data:void 0})),d=(x,v,y)=>{!m||y.defaultPrevented||We(y.currentTarget,y.target)||m({index:v,key:x.key,data:x.data},y)},k=(x,v,y)=>{!m||y.defaultPrevented||(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),m({index:v,key:x.key,data:x.data},y))};return i.jsx("div",{...b,ref:h,className:T("uk-marquee",n),"data-direction":o,"data-fade":p?"true":void 0,"data-pause-on-hover":l?"true":void 0,"data-paused":f?"true":"false",style:{...b.style,"--uk-marquee-gap":c,"--uk-marquee-duration":`${r}s`,gap:c},children:[!1,!0].map(x=>i.jsx("div",{"aria-hidden":x,className:"uk-marquee__track","data-duplicate":x?"true":void 0,inert:x&&!m,role:x?"presentation":void 0,onFocusCapture:x?v=>{v.target instanceof HTMLElement&&v.target.blur()}:void 0,children:g.map((v,y)=>i.jsx("div",{className:"uk-marquee__item","data-clickable":m?"true":void 0,...m?{role:x?void 0:"button",tabIndex:x?-1:0,onClick:u=>d(v,y,u),onKeyDown:x?void 0:u=>k(v,y,u)}:{},children:v.content},x?`duplicate-${y}`:v.key??y))},x?"duplicate":"primary"))})}),be=a.createContext(null),xe=()=>()=>{},ge=()=>!0,ye=()=>!1;function ve(t){const e=a.useContext(be);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Root>`);return e}function ke(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function Ie(t,e){const n=typeof t=="string"?t.split(/\s+/).filter(Boolean):[];return Array.from(new Set([...n,e])).join(" ")}function R(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function Qe({children:t,open:e,defaultOpen:n,onOpenChange:o,delayDuration:r=300,closeDelay:l=80}){const c=a.useId(),[p,f]=a.useState(null),s=a.useRef(null),m=a.useRef(null),[b,h]=w.useControllableState({value:e,defaultValue:n??!1,onChange:o}),g=a.useCallback(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),d=a.useCallback(()=>{m.current!==null&&(clearTimeout(m.current),m.current=null)},[]),k=w.useEventCallback((u=!1)=>{if(g(),d(),!b){if(u||r<=0){h(!0);return}s.current=setTimeout(()=>{s.current=null,h(!0)},r)}}),x=w.useEventCallback(()=>{if(g(),d(),!!b){if(l<=0){h(!1);return}m.current=setTimeout(()=>{m.current=null,h(!1)},l)}}),v=w.useEventCallback(()=>{g(),d(),h(!1)});a.useEffect(()=>{b?d():g()},[d,g,b]),a.useEffect(()=>()=>{g(),d()},[d,g]);const y=a.useMemo(()=>({open:b,triggerElement:p,setTriggerElement:f,contentId:c,requestOpen:k,requestClose:x,dismiss:v}),[c,b,v,x,k,p]);return i.jsx(be.Provider,{value:y,children:t})}function Ze({children:t}){const e=ve("Tooltip.Trigger"),{setTriggerElement:n}=e;if(!a.isValidElement(t))throw new Error("<Tooltip.Trigger> expects a single valid React element");const o=t,r=o.props,l=r.ref??o.ref,c=r.onPointerEnter,p=r.onPointerLeave,f=r.onFocus,s=r.onBlur,m=r.onKeyDown,b=a.useCallback(h=>{ke(l,h),n(h)},[l,n]);return a.cloneElement(o,{ref:b,"aria-describedby":e.open?Ie(r["aria-describedby"],e.contentId):r["aria-describedby"],onPointerEnter:R(c,h=>{e.requestOpen(h.pointerType==="touch")}),onPointerLeave:R(p,h=>{h.pointerType!=="touch"&&e.requestClose()}),onFocus:R(f,()=>{e.requestOpen()}),onBlur:R(s,()=>{e.requestClose()}),onKeyDown:R(m,h=>{h.key==="Escape"&&e.open&&(h.preventDefault(),h.stopPropagation(),e.dismiss())})})}function A(t,e,n){return n<e?e:Math.min(Math.max(t,e),n)}function et(t){switch(t){case"top":return"bottom";case"right":return"left";case"bottom":return"top";case"left":return"right"}}function q(t,e,n,o,r){switch(e){case"top":return t.top-r;case"right":return n-t.right-r;case"bottom":return o-t.bottom-r;case"left":return t.left-r}}function Q(t,e,n,o,r,l,c){return q(t,n,r,l,c)>=(n==="top"||n==="bottom"?e.height:e.width)+o}function tt({trigger:t,tooltip:e,side:n,align:o,sideOffset:r,collisionPadding:l,avoidCollisions:c,viewportWidth:p,viewportHeight:f}){let s=n;if(c&&!Q(t,e,n,r,p,f,l)){const x=et(n),v=Q(t,e,x,r,p,f,l),y=q(t,n,p,f,l),u=q(t,x,p,f,l);(v||u>y)&&(s=x)}const m=t.left+t.width/2,b=t.top+t.height/2;let h=0,g=0;switch(s){case"top":case"bottom":h=o==="start"?t.left:o==="end"?t.right-e.width:m-e.width/2,g=s==="top"?t.top-e.height-r:t.bottom+r;break;case"left":case"right":h=s==="left"?t.left-e.width-r:t.right+r,g=o==="start"?t.top:o==="end"?t.bottom-e.height:b-e.height/2;break}c&&(h=A(h,l,p-e.width-l),g=A(g,l,f-e.height-l));const d=10,k=s==="top"||s==="bottom"?A(m-h,d,Math.max(d,e.width-d)):A(b-g,d,Math.max(d,e.height-d));return{x:h,y:g,side:s,arrowOffset:k}}function Ce(t,e,{side:n,align:o,sideOffset:r,collisionPadding:l,avoidCollisions:c}){const[p,f]=a.useState(null);return a.useLayoutEffect(()=>{const s=e.current;if(!s||!t)return;const m=()=>{const h=t.getBoundingClientRect(),g=s.getBoundingClientRect();f(tt({trigger:h,tooltip:g,side:n,align:o,sideOffset:r,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 b=typeof ResizeObserver>"u"?null:new ResizeObserver(m);return b?.observe(t),b?.observe(s),()=>{window.removeEventListener("resize",m),window.removeEventListener("scroll",m,!0),b?.disconnect()}},[o,c,l,e,n,r,t]),p}function Te(t,e,n){a.useEffect(()=>{const o=c=>{const p=c.target;p instanceof Node&&(t.contains(p)||e.current?.contains(p)||n())},r=()=>{document.visibilityState==="hidden"&&n()},l=c=>{const p=c.target;c.key!=="Escape"||p instanceof Node&&t.contains(p)||n()};return document.addEventListener("pointerdown",o,!0),document.addEventListener("visibilitychange",r),document.addEventListener("keydown",l,!0),window.addEventListener("blur",n),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("visibilitychange",r),document.removeEventListener("keydown",l,!0),window.removeEventListener("blur",n)}},[n,e,t])}function we(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 nt({contentId:t,triggerElement:e,dismiss:n,children:o,className:r,style:l,side:c="top",align:p="center",sideOffset:f=8,collisionPadding:s=8,avoidCollisions:m=!0,...b}){const h=a.useRef(null),g=I.useReducedMotion()??!1,d=I.useIsPresent(),k=Ce(e,h,{side:c,align:p,sideOffset:f,collisionPadding:s,avoidCollisions:m});Te(e,h,n);const x=we(k?.side??c),v={...l,left:k?`${k.x}px`:0,top:k?`${k.y}px`:0,visibility:k?"visible":"hidden"};return i.jsx("div",{...b,ref:h,id:t,role:"tooltip","data-side":k?.side??c,"data-align":p,"data-state":d?"open":"closed","aria-hidden":d?void 0:!0,className:T("uk-tooltip",r),style:v,children:i.jsxs(I.motion.div,{className:"uk-tooltip__surface",style:{transformOrigin:x},initial:g?{opacity:0}:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:g?{opacity:0}:{opacity:0,scale:.96},transition:g?O:ee,children:[i.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${k?.arrowOffset??0}px`}}),o]})})}function ot(t){const e=ve("Tooltip.Content"),o=a.useSyncExternalStore(xe,ge,ye)&&e.triggerElement?e.triggerElement.closest("dialog")??document.body:null;return!o||!e.triggerElement?null:F.createPortal(i.jsx(I.MotionConfig,{reducedMotion:"user",children:i.jsx(I.AnimatePresence,{children:e.open?i.jsx(nt,{contentId:e.contentId,triggerElement:e.triggerElement,dismiss:e.dismiss,...t},"uk-tooltip"):null})}),o)}const _e=a.createContext(null);function rt(t){const e=a.useContext(_e);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Group>`);return e}function at({activeValue:t,content:e,contentClassName:n,contentId:o,dismiss:r,triggerElement:l,side:c,align:p,sideOffset:f,collisionPadding:s,avoidCollisions:m}){const b=a.useRef(null),h=I.useReducedMotion()??!1,g=I.useIsPresent(),d=Ce(l,b,{side:c,align:p,sideOffset:f,collisionPadding:s,avoidCollisions:m});Te(l,b,r);const k={left:d?`${d.x}px`:0,top:d?`${d.y}px`:0,transformOrigin:we(d?.side??c),visibility:d?"visible":"hidden"};return i.jsxs(I.motion.div,{ref:b,id:o,role:"tooltip",layout:!h,layoutDependency:t,"data-side":d?.side??c,"data-align":p,"data-state":g?"open":"closed","aria-hidden":g?void 0:!0,className:T("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?{...O,layout:{duration:0}}:Se,children:[i.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${d?.arrowOffset??0}px`}}),i.jsx(I.motion.div,{className:"uk-tooltip__content",initial:{opacity:0},animate:{opacity:1},transition:h?O:ee,children:e},t)]})}function it({children:t,side:e="top",align:n="center",sideOffset:o=8,collisionPadding:r=8,avoidCollisions:l=!0,delayDuration:c=180,closeDelay:p=80,contentClassName:f}){const s=a.useId(),[m,b]=a.useState(()=>new Map),[h,g]=a.useState(!1),[d,k]=a.useState(null),x=a.useRef(null),v=a.useRef(null),y=a.useSyncExternalStore(xe,ge,ye),u=a.useCallback(()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},[]),C=a.useCallback(()=>{v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),_=w.useEventCallback((D,S=!1)=>{if(u(),C(),k(D),!h){if(S||c<=0){g(!0);return}x.current=setTimeout(()=>{x.current=null,g(!0)},c)}}),j=w.useEventCallback(()=>{if(u(),C(),!!h){if(p<=0){g(!1);return}v.current=setTimeout(()=>{v.current=null,g(!1)},p)}}),N=w.useEventCallback(()=>{u(),C(),g(!1)}),P=w.useEventCallback((D,S,M)=>{b(H=>{const X=H.get(D);if(X?.triggerElement===S&&Object.is(X.content,M))return H;const Y=new Map(H);return Y.set(D,{triggerElement:S,content:M}),Y})}),E=w.useEventCallback(D=>{b(S=>{if(!S.has(D))return S;const M=new Map(S);return M.delete(D),M})});a.useEffect(()=>()=>{u(),C()},[C,u]);const je=a.useMemo(()=>({open:h,activeValue:d,contentId:s,activate:_,requestClose:j,dismiss:N,register:P,unregister:E}),[_,d,s,N,h,P,j,E]),L=d?m.get(d):void 0,Ee=h&&!!L,U=y&&L?L.triggerElement.closest("dialog")??document.body:null;return i.jsxs(_e.Provider,{value:je,children:[t,U&&L?F.createPortal(i.jsx(I.MotionConfig,{reducedMotion:"user",children:i.jsx(I.AnimatePresence,{children:Ee?i.jsx(at,{activeValue:d??"",content:L.content,contentClassName:f,contentId:s,dismiss:N,triggerElement:L.triggerElement,side:e,align:n,sideOffset:o,collisionPadding:r,avoidCollisions:l},"uk-tooltip-group"):null})}),U):null]})}function st({value:t,content:e,children:n}){const o=rt("Tooltip.Item"),{register:r,unregister:l}=o,[c,p]=a.useState(null);if(!a.isValidElement(n))throw new Error("<Tooltip.Item> expects a single valid React element");const f=n,s=f.props,m=s.ref??f.ref,b=s.onPointerEnter,h=s.onPointerLeave,g=s.onFocus,d=s.onBlur,k=s.onKeyDown,x=o.open&&o.activeValue===t,v=a.useCallback(y=>{ke(m,y),p(y)},[m,p]);return a.useLayoutEffect(()=>{if(c)return r(t,c,e),()=>l(t)},[e,r,c,l,t]),a.cloneElement(f,{ref:v,"aria-describedby":x?Ie(s["aria-describedby"],o.contentId):s["aria-describedby"],onPointerEnter:R(b,y=>{o.activate(t,y.pointerType==="touch")}),onPointerLeave:R(h,y=>{y.pointerType!=="touch"&&o.requestClose()}),onFocus:R(g,()=>{o.activate(t)}),onBlur:R(d,()=>{o.requestClose()}),onKeyDown:R(k,y=>{y.key==="Escape"&&x&&(y.preventDefault(),y.stopPropagation(),o.dismiss())})})}const ct={Root:Qe,Trigger:Ze,Content:ot,Group:it,Item:st};exports.Button=G;exports.CheckBox=Z;exports.Dialog=Ye;exports.Input=Re;exports.Marquee=Je;exports.Sidebar=$e;exports.Switch=De;exports.Tabs=qe;exports.Tooltip=ct;
|
|
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;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|