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