seam-react 0.6.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/CheckBox.d.ts +18 -0
- package/dist/Marquee.d.ts +17 -3
- 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 +5 -1
- package/dist/index.js +1149 -717
- package/dist/index.js.map +1 -1
- package/dist/styles.cjs +335 -3
- package/dist/styles.cjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.js +336 -4
- package/dist/styles.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ForwardRefExoticComponent, type InputHTMLAttributes, type ReactNode, type RefAttributes } from "react";
|
|
2
|
+
export interface CheckBoxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "checked" | "defaultChecked" | "onChange"> {
|
|
3
|
+
/** 受控选中状态。传入即进入受控模式。 */
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
/** 非受控模式下的初始状态。 */
|
|
6
|
+
defaultChecked?: boolean;
|
|
7
|
+
/** 状态变化回调,受控与非受控都会触发。 */
|
|
8
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
9
|
+
/** 显示在复选框右侧的标签文本。 */
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 复选框。
|
|
14
|
+
*
|
|
15
|
+
* 保留原生 checkbox 的表单、键盘和读屏语义;方框内的对勾用 SVG 描边
|
|
16
|
+
* 展示状态转换,按压时的轻微缩放提供即时的触觉反馈。
|
|
17
|
+
*/
|
|
18
|
+
export declare const CheckBox: ForwardRefExoticComponent<CheckBoxProps & RefAttributes<HTMLInputElement>>;
|
package/dist/Marquee.d.ts
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type HTMLAttributes, type RefAttributes } from "react";
|
|
2
2
|
export type MarqueeDirection = "left" | "right" | "up" | "down";
|
|
3
|
-
export
|
|
3
|
+
export type MarqueeItemClickEvent = MouseEvent<HTMLDivElement> | KeyboardEvent<HTMLDivElement>;
|
|
4
|
+
export interface MarqueeItem<TData = unknown> {
|
|
5
|
+
key: string;
|
|
6
|
+
content: ReactNode;
|
|
7
|
+
data?: TData;
|
|
8
|
+
}
|
|
9
|
+
export interface MarqueeItemDetail<TData = unknown> {
|
|
10
|
+
index: number;
|
|
11
|
+
key: string | null;
|
|
12
|
+
data: TData | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface MarqueeProps<TData = unknown> extends HTMLAttributes<HTMLDivElement> {
|
|
4
15
|
direction?: MarqueeDirection;
|
|
5
16
|
speed?: number;
|
|
6
17
|
pauseOnHover?: boolean;
|
|
7
18
|
gap?: string;
|
|
8
19
|
fade?: boolean;
|
|
20
|
+
paused?: boolean;
|
|
21
|
+
items?: ReadonlyArray<MarqueeItem<TData>>;
|
|
22
|
+
onItemClick?: (item: MarqueeItemDetail<TData>, event: MarqueeItemClickEvent) => void;
|
|
9
23
|
}
|
|
10
|
-
declare const Marquee:
|
|
24
|
+
declare const Marquee: <TData = unknown>(props: MarqueeProps<TData> & RefAttributes<HTMLDivElement>) => ReactElement | null;
|
|
11
25
|
export { Marquee };
|
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 a=require("react/jsx-runtime"),i=require("react"),x=require("motion/react"),F=require("react-dom"),E=require("seam-hooks");function T(...t){return t.filter(Boolean).join(" ")}const G=i.forwardRef(function({variant:e="primary",size:n="md",loading:o=!1,iconOnly:r=!1,type:l="button",className:c,children:f,...u},s){return a.jsxs("button",{...u,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:u.disabled||o,"aria-busy":o||void 0,children:[o?a.jsx("span",{className:"uk-button__spinner","aria-hidden":"true"}):null,f]})}),je=i.forwardRef(function({inputSize:e="md",invalid:n=!1,className:o,"aria-invalid":r,...l},c){return a.jsx("input",{...l,ref:c,className:T("uk-input",o),"data-size":e,"aria-invalid":n?!0:r})}),B=[.23,1,.32,1],Re=[.77,0,.175,1],W={type:"spring",bounce:0,duration:.3},J={type:"spring",bounce:.04,duration:.38},z={type:"spring",bounce:.08,duration:.34},Pe={duration:.2,ease:Re},Z={duration:.12,ease:B},Ne={layout:{type:"spring",bounce:0,duration:.22},opacity:{duration:.12,ease:B},scale:{duration:.12,ease:B}},O={duration:.12,ease:B},Se=i.forwardRef(function({checked:e,defaultChecked:n,onCheckedChange:o,disabled:r,className:l,children:c,id:f,...u},s){const b=i.useId(),m=f??b,h=x.useReducedMotion()??!1,g=i.useRef(!1),p=i.useRef(null),[y,v]=E.useControllableState({value:e,defaultValue:n??!1,onChange:o}),k=x.useMotionValue(y?16:0);i.useEffect(()=>{if(p.current)return;const d=x.animate(k,y?16:0,h?{duration:0}:W);return()=>d.stop()},[y,h,k]);const C=d=>{const I=p.current;if(!(!I||I.pointerId!==d.pointerId)){if(I.moved){const w=I.samples[0],_=I.samples[I.samples.length-1],N=w&&_?Math.max(_.time-w.time,1):1,P=w&&_?(_.x-w.x)/N*1e3:0,j=Math.abs(P)>220?P>0:k.get()>=8;g.current=!0,p.current=null,v(j),x.animate(k,j?16:0,h?{duration:0}:{...W,velocity:P}),window.setTimeout(()=>{g.current=!1},0)}else p.current=null;d.currentTarget.hasPointerCapture(d.pointerId)&&typeof d.currentTarget.releasePointerCapture=="function"&&d.currentTarget.releasePointerCapture(d.pointerId)}};return a.jsxs("label",{className:T("uk-switch",l),"data-disabled":r?"true":void 0,htmlFor:m,onClickCapture:d=>{g.current&&(d.preventDefault(),d.stopPropagation())},children:[a.jsx("input",{...u,ref:s,id:m,type:"checkbox",role:"switch",className:"uk-switch__input",checked:y,disabled:r,"aria-checked":y,onChange:d=>v(d.target.checked)}),a.jsx("span",{className:"uk-switch__track","aria-hidden":"true",onPointerDown:d=>{r||(p.current={pointerId:d.pointerId,startX:d.clientX,startValue:k.get(),moved:!1,samples:[{x:d.clientX,time:performance.now()}]},typeof d.currentTarget.setPointerCapture=="function"&&d.currentTarget.setPointerCapture(d.pointerId))},onPointerMove:d=>{const I=p.current;if(!I||I.pointerId!==d.pointerId)return;const w=d.clientX-I.startX;Math.abs(w)>4&&(I.moved=!0),I.moved&&(d.preventDefault(),k.set(Math.max(0,Math.min(16,I.startValue+w))),I.samples.push({x:d.clientX,time:performance.now()}),I.samples=I.samples.filter(_=>performance.now()-_.time<120))},onPointerUp:C,onPointerCancel:C,children:a.jsx(x.motion.span,{className:"uk-switch__thumb",style:{x:k}})}),c?a.jsx("span",{className:"uk-switch__label",children:c}):null]})}),ee=i.createContext(null);function te(t){const e=i.useContext(ee);if(!e)throw new Error(`<${t}> must be rendered inside <Sidebar>`);return e}function q(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function De({children:t,className:e,hoverPreview:n=!0,hoverIndicator:o="rail",groupGap:r,style:l,...c}){const[f,u]=i.useState(null),s=i.useId().replace(/:/g,""),b=i.useMemo(()=>({hoveredId:f,setHoveredId:u,indicatorBaseId:s,hoverPreview:n,hoverIndicator:o}),[f,s,n,o]),m=typeof r=="number"?`${r}px`:r,h={...l,...m===void 0?{}:{"--uk-sidebar-group-gap":m}};return a.jsx(ee.Provider,{value:b,children:a.jsx(x.LayoutGroup,{id:`sidebar-${s}`,children:a.jsx("nav",{...c,className:T("uk-sidebar",e),style:h,children:t})})})}function Le({title:t,icon:e,collapsible:n=!1,open:o,defaultOpen:r=!0,onOpenChange:l,children:c,className:f,...u}){const s=i.useId(),b=i.useId(),m=i.useId(),h=i.useRef(null),g=i.useRef(null),p=te("Sidebar.Group"),y=e!=null,v=x.useReducedMotion()??!1,[k,C]=E.useControllableState({value:o,defaultValue:r,onChange:l}),d=n?k:!0,I=p.hoveredId===m;i.useEffect(()=>{!n||d||g.current?.contains(document.activeElement)&&h.current?.focus()},[n,d]);const w=a.jsxs(a.Fragment,{children:[y?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",{...u,className:T("uk-sidebar__group",f),"aria-labelledby":u["aria-labelledby"]??s,"data-collapsible":n?"true":"false","data-has-icon":y?"true":"false","data-state":d?"open":"closed",children:[n?a.jsxs("button",{ref:h,type:"button",className:"uk-sidebar__group-title uk-sidebar__group-trigger",id:s,"aria-controls":b,"aria-expanded":d,"data-preview":p.hoverIndicator==="background"&&I?"true":void 0,onClick:()=>C(_=>!_),onPointerEnter:_=>{p.hoverPreview&&p.hoverIndicator==="background"&&_.pointerType==="mouse"&&p.setHoveredId(m)},onPointerLeave:()=>{p.hoveredId===m&&p.setHoveredId(null)},onPointerCancel:()=>{p.hoveredId===m&&p.setHoveredId(null)},children:[a.jsx(x.AnimatePresence,{initial:!1,children:p.hoverPreview&&p.hoverIndicator==="background"&&I?a.jsx(x.motion.span,{className:"uk-sidebar__group-surface","data-kind":"hover","data-slot":"sidebar-hover-highlight",layoutId:`${p.indicatorBaseId}-hover`,"aria-hidden":"true",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:v?{duration:0}:z}):null}),w]}):a.jsx("div",{className:"uk-sidebar__group-title",id:s,children:w}),a.jsx(x.motion.div,{ref:g,className:"uk-sidebar__content",id:b,"data-state":d?"open":"closed",initial:!1,animate:{height:d?"auto":0,opacity:d?1:0},transition:v?{duration:0}:Pe,inert:n&&!d,"aria-hidden":n&&!d?!0:void 0,children:a.jsx("ul",{className:"uk-sidebar__list",children:c})})]})}function Me({active:t=!1,children:e,className:n}){const o=te("Sidebar.Item"),r=i.useId(),c=x.useReducedMotion()??!1?{duration:0}:z;if(!i.isValidElement(e))throw new Error("<Sidebar.Item> expects a single valid React element");const f=e,u=f.props,s=u.className,b=typeof s=="function"?v=>T("uk-sidebar__link",s(v),n):T("uk-sidebar__link",s,n),m=u.onPointerEnter,h=u.onPointerLeave,g=u.onPointerCancel,p=o.hoveredId===r,y=a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"uk-sidebar__rail","aria-hidden":"true"}),a.jsx(x.AnimatePresence,{initial:!1,children:o.hoverPreview&&o.hoverIndicator==="rail"&&p?a.jsx(x.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}),a.jsx(x.AnimatePresence,{initial:!1,children:o.hoverIndicator==="rail"&&t?a.jsx(x.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}),a.jsx(x.AnimatePresence,{initial:!1,children:o.hoverPreview&&o.hoverIndicator==="background"&&p?a.jsx(x.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}),a.jsx(x.AnimatePresence,{initial:!1,children:o.hoverIndicator==="background"&&t?a.jsx(x.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}),a.jsx("span",{className:"uk-sidebar__label",children:u.children})]});return a.jsx("li",{className:"uk-sidebar__item",children:i.cloneElement(f,{className:b,"data-active":t?"true":"false","data-preview":t||p?"true":"false","aria-current":u["aria-current"]??(t?"page":void 0),onPointerEnter:q(m,v=>{o.hoverPreview&&v.pointerType==="mouse"&&o.setHoveredId(r)}),onPointerLeave:q(h,()=>{o.hoveredId===r&&o.setHoveredId(null)}),onPointerCancel:q(g,()=>{o.hoveredId===r&&o.setHoveredId(null)})},y)})}const Oe=Object.assign(De,{Group:Le,Item:Me}),ne=i.createContext(null);function K(t){const e=i.useContext(ne);if(!e)throw new Error(`<${t}> must be rendered inside <Tabs>`);return e}function oe(t,e){return`${t}-tab-${encodeURIComponent(e)}`}function re(t,e){return`${t}-panel-${encodeURIComponent(e)}`}function $e({value:t,defaultValue:e,onValueChange:n,orientation:o="horizontal",className:r,children:l}){const c=i.useId(),[f,u]=E.useControllableState({value:t,defaultValue:e??"",onChange:n}),s=i.useMemo(()=>({baseId:c,value:f,setValue:u,orientation:o,indicatorId:`${c}-indicator`}),[c,f,o,u]);return a.jsx(ne.Provider,{value:s,children:a.jsx("div",{className:T("uk-tabs",r),"data-orientation":o,children:l})})}const Ae=i.forwardRef(function({className:e,onKeyDown:n,...o},r){const{orientation:l}=K("Tabs.List");return a.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 u=c.target?.closest('[role="tab"]');if(!u||u.hasAttribute("disabled"))return;const s=Array.from(c.currentTarget.querySelectorAll('[role="tab"]:not([disabled])')),b=s.indexOf(u);if(b===-1)return;const m=l==="horizontal"?"ArrowRight":"ArrowDown",h=l==="horizontal"?"ArrowLeft":"ArrowUp";let g=-1;switch(c.key){case m:g=(b+1)%s.length;break;case h:g=(b-1+s.length)%s.length;break;case"Home":g=0;break;case"End":g=s.length-1;break;default:return}c.preventDefault();const p=s[g];p&&(p.focus(),p.click())}})}),Be=i.forwardRef(function({value:e,type:n="button",className:o,onClick:r,children:l,...c},f){const u=K("Tabs.Trigger"),s=u.value===e,b=x.useReducedMotion()??!1;return a.jsxs("button",{...c,ref:f,type:n,role:"tab",id:oe(u.baseId,e),"aria-selected":s,"aria-controls":re(u.baseId,e),tabIndex:s?0:-1,"data-state":s?"active":"inactive",className:T("uk-tabs__trigger",o),onClick:m=>{r?.(m),m.defaultPrevented||u.setValue(e)},children:[l,s?a.jsx(x.motion.span,{className:"uk-tabs__indicator",layoutId:u.indicatorId,"aria-hidden":"true",transition:b?{duration:0}:z}):null]})}),He=i.forwardRef(function({value:e,className:n,...o},r){const l=K("Tabs.Content"),c=l.value===e;return a.jsx("div",{...o,ref:r,role:"tabpanel",id:re(l.baseId,e),"aria-labelledby":oe(l.baseId,e),hidden:!c,tabIndex:0,"data-state":c?"active":"inactive",className:T("uk-tabs__panel",n)})}),qe=Object.assign($e,{List:Ae,Trigger:Be,Content:He}),ie=i.createContext(null),Ve=()=>()=>{},Fe=()=>!0,Ge=()=>!1;function $(t){const e=i.useContext(ie);if(!e)throw new Error(`<${t}> must be rendered inside <Dialog.Root>`);return e}function ae(t,e){return n=>{t?.(n),n.defaultPrevented||e(n)}}function se({children:t,open:e,defaultOpen:n,onOpenChange:o}){const r=i.useId(),[l,c]=i.useState(!1),[f,u]=i.useState(!1),[s,b]=E.useControllableState({value:e,defaultValue:n??!1,onChange:o}),m=i.useMemo(()=>({open:s,setOpen:b,triggerId:`${r}-trigger`,contentId:`${r}-content`,titleId:`${r}-title`,descriptionId:`${r}-description`,hasTitle:l,setHasTitle:c,hasDescription:f,setHasDescription:u}),[r,s,f,l,b]);return a.jsx(ie.Provider,{value:m,children:t})}function ze({children:t}){const e=$("Dialog.Trigger"),n=t,o=n.props.onClick;return i.cloneElement(n,{id:e.triggerId,"aria-haspopup":"dialog","aria-expanded":e.open,"aria-controls":e.open?e.contentId:void 0,onClick:ae(o,()=>{e.setOpen(!e.open)})})}function ce({children:t,label:e="Close"}){const n=$("Dialog.Close");if(i.isValidElement(t)){const o=t,r=o.props.onClick;return i.cloneElement(o,{onClick:ae(r,()=>{n.setOpen(!1)})})}return a.jsx(G,{variant:"ghost",onClick:()=>n.setOpen(!1),children:e})}const le=i.forwardRef(function({className:e,...n},o){return a.jsx("header",{...n,ref:o,className:T("uk-dialog__header",e)})}),ue=i.forwardRef(function({className:e,children:n,...o},r){const l=$("Dialog.Title"),c=l.setHasTitle;return i.useEffect(()=>(c(!0),()=>c(!1)),[c]),a.jsx("h2",{...o,ref:r,id:l.titleId,className:T("uk-dialog__title",e),children:n})}),de=i.forwardRef(function({className:e,...n},o){const r=$("Dialog.Description"),l=r.setHasDescription;return i.useEffect(()=>(l(!0),()=>l(!1)),[l]),a.jsx("p",{...n,ref:o,id:r.descriptionId,className:T("uk-dialog__description",e)})}),fe=i.forwardRef(function({className:e,...n},o){return a.jsx("div",{...n,ref:o,className:T("uk-dialog__body",e)})}),pe=i.forwardRef(function({className:e,...n},o){return a.jsx("footer",{...n,ref:o,className:T("uk-dialog__footer",e)})});function Ke({requestClose:t,contentId:e,titleId:n,descriptionId:o,hasTitle:r,hasDescription:l,children:c,closeOnBackdropClick:f=!0,closeOnEscape:u=!0,initialFocusRef:s,returnFocusRef:b,className:m,"aria-label":h,"aria-labelledby":g,"aria-describedby":p}){const y=i.useRef(null),v=i.useRef(null),k=x.useIsPresent(),C=x.useReducedMotion()??!1;return E.useLockBodyScroll(!0),i.useLayoutEffect(()=>{const d=y.current;d&&(v.current??(v.current=document.activeElement instanceof HTMLElement?document.activeElement:null),!d.open&&(typeof d.showModal=="function"?d.showModal():d.setAttribute("open","")))},[]),E.useFocusTrap({active:!0,containerRef:y,initialFocusRef:s,returnFocusRef:b??v}),i.useEffect(()=>{const d=y.current;if(!d)return;const I=()=>{d.open||(typeof d.showModal=="function"?d.showModal():d.setAttribute("open",""))},w=()=>{if(!u){I();return}t()},_=j=>{j.preventDefault(),u&&t()},N=j=>{u||j.key!=="Escape"||j.defaultPrevented||(j.preventDefault(),j.stopPropagation())},P=j=>{f&&j.target===d&&t()};return d.addEventListener("close",w),d.addEventListener("cancel",_),d.addEventListener("keydown",N,!0),d.addEventListener("click",P),()=>{d.removeEventListener("close",w),d.removeEventListener("cancel",_),d.removeEventListener("keydown",N,!0),d.removeEventListener("click",P)}},[f,u,t]),a.jsx("dialog",{ref:y,id:e,className:T("uk-dialog",m),closedby:u||f?"any":"none","data-state":k?"open":"closed",inert:!k,"aria-label":h,"aria-labelledby":g??(h?void 0:r?n:void 0),"aria-describedby":p??(l?o:void 0),children:a.jsx(x.motion.div,{className:"uk-dialog__panel",initial:C?{opacity:0}:{opacity:0,transform:"translateY(12px) scale(0.96)"},animate:{opacity:1,transform:"translateY(0px) scale(1)",transition:C?O:{...J,delay:.06}},exit:C?{opacity:0,transition:O}:{opacity:0,transform:"translateY(8px) scale(0.97)",transition:J},children:c})})}function he({children:t,closeOnBackdropClick:e=!0,closeOnEscape:n=!0,initialFocusRef:o,returnFocusRef:r,className:l,"aria-label":c,"aria-labelledby":f,"aria-describedby":u}){const s=$("Dialog.Content"),b=E.useEventCallback(()=>{s.setOpen(!1)});return i.useSyncExternalStore(Ve,Fe,Ge)?F.createPortal(a.jsx(x.MotionConfig,{reducedMotion:"user",children:a.jsx(x.AnimatePresence,{children:s.open?a.jsx(Ke,{requestClose:b,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":f,"aria-describedby":u,children:t},"uk-dialog"):null})}),document.body):null}function Ue({open:t,onOpenChange:e,title:n,description:o,footer:r,children:l,closeLabel:c="Close",showCloseButton:f=!0,closeOnBackdropClick:u=!0,closeOnEscape:s=!0,initialFocusRef:b,returnFocusRef:m,className:h,"aria-label":g}){return a.jsx(se,{open:t,onOpenChange:e,children:a.jsxs(he,{className:h,closeOnBackdropClick:u,closeOnEscape:s,initialFocusRef:b,returnFocusRef:m,"aria-label":g,children:[n||o||f?a.jsxs(le,{children:[a.jsxs("div",{className:"uk-dialog__heading",children:[n?a.jsx(ue,{children:n}):null,o?a.jsx(de,{children:o}):null]}),f?a.jsx(ce,{children:a.jsx(G,{variant:"ghost",size:"sm",iconOnly:!0,"aria-label":c,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(fe,{children:l}),r?a.jsx(pe,{children:r}):null]})})}const Xe=Object.assign(Ue,{Root:se,Trigger:ze,Content:he,Header:le,Title:ue,Description:de,Body:fe,Footer:pe,Close:ce}),Ye=i.forwardRef(function({children:e,className:n,direction:o="left",speed:r=30,pauseOnHover:l=!0,gap:c="1rem",fade:f=!0,...u},s){const b=i.Children.toArray(e);return a.jsx("div",{...u,ref:s,className:T("uk-marquee",n),"data-direction":o,"data-fade":f?"true":void 0,"data-pause-on-hover":l?"true":void 0,style:{...u.style,"--uk-marquee-gap":c,"--uk-marquee-duration":`${r}s`,gap:c},children:[!1,!0].map(m=>a.jsx("div",{"aria-hidden":m,className:"uk-marquee__track","data-duplicate":m?"true":void 0,inert:m,children:b.map((h,g)=>a.jsx("div",{className:"uk-marquee__item",children:h},g))},m?"duplicate":"primary"))})}),me=i.createContext(null),be=()=>()=>{},ge=()=>!0,xe=()=>!1;function ye(t){const e=i.useContext(me);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Root>`);return e}function ve(t,e){typeof t=="function"?t(e):t&&(t.current=e)}function ke(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 We({children:t,open:e,defaultOpen:n,onOpenChange:o,delayDuration:r=300,closeDelay:l=80}){const c=i.useId(),[f,u]=i.useState(null),s=i.useRef(null),b=i.useRef(null),[m,h]=E.useControllableState({value:e,defaultValue:n??!1,onChange:o}),g=i.useCallback(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),p=i.useCallback(()=>{b.current!==null&&(clearTimeout(b.current),b.current=null)},[]),y=E.useEventCallback((d=!1)=>{if(g(),p(),!m){if(d||r<=0){h(!0);return}s.current=setTimeout(()=>{s.current=null,h(!0)},r)}}),v=E.useEventCallback(()=>{if(g(),p(),!!m){if(l<=0){h(!1);return}b.current=setTimeout(()=>{b.current=null,h(!1)},l)}}),k=E.useEventCallback(()=>{g(),p(),h(!1)});i.useEffect(()=>{m?p():g()},[p,g,m]),i.useEffect(()=>()=>{g(),p()},[p,g]);const C=i.useMemo(()=>({open:m,triggerElement:f,setTriggerElement:u,contentId:c,requestOpen:y,requestClose:v,dismiss:k}),[c,m,k,v,y,f]);return a.jsx(me.Provider,{value:C,children:t})}function Je({children:t}){const e=ye("Tooltip.Trigger"),{setTriggerElement:n}=e;if(!i.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,f=r.onPointerLeave,u=r.onFocus,s=r.onBlur,b=r.onKeyDown,m=i.useCallback(h=>{ve(l,h),n(h)},[l,n]);return i.cloneElement(o,{ref:m,"aria-describedby":e.open?ke(r["aria-describedby"],e.contentId):r["aria-describedby"],onPointerEnter:R(c,h=>{e.requestOpen(h.pointerType==="touch")}),onPointerLeave:R(f,h=>{h.pointerType!=="touch"&&e.requestClose()}),onFocus:R(u,()=>{e.requestOpen()}),onBlur:R(s,()=>{e.requestClose()}),onKeyDown:R(b,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 Qe(t){switch(t){case"top":return"bottom";case"right":return"left";case"bottom":return"top";case"left":return"right"}}function V(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 V(t,n,r,l,c)>=(n==="top"||n==="bottom"?e.height:e.width)+o}function Ze({trigger:t,tooltip:e,side:n,align:o,sideOffset:r,collisionPadding:l,avoidCollisions:c,viewportWidth:f,viewportHeight:u}){let s=n;if(c&&!Q(t,e,n,r,f,u,l)){const v=Qe(n),k=Q(t,e,v,r,f,u,l),C=V(t,n,f,u,l),d=V(t,v,f,u,l);(k||d>C)&&(s=v)}const b=t.left+t.width/2,m=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:b-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:m-e.height/2;break}c&&(h=A(h,l,f-e.width-l),g=A(g,l,u-e.height-l));const p=10,y=s==="top"||s==="bottom"?A(b-h,p,Math.max(p,e.width-p)):A(m-g,p,Math.max(p,e.height-p));return{x:h,y:g,side:s,arrowOffset:y}}function Ie(t,e,{side:n,align:o,sideOffset:r,collisionPadding:l,avoidCollisions:c}){const[f,u]=i.useState(null);return i.useLayoutEffect(()=>{const s=e.current;if(!s||!t)return;const b=()=>{const h=t.getBoundingClientRect(),g=s.getBoundingClientRect();u(Ze({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}))};b(),window.addEventListener("resize",b),window.addEventListener("scroll",b,!0);const m=typeof ResizeObserver>"u"?null:new ResizeObserver(b);return m?.observe(t),m?.observe(s),()=>{window.removeEventListener("resize",b),window.removeEventListener("scroll",b,!0),m?.disconnect()}},[o,c,l,e,n,r,t]),f}function Ce(t,e,n){i.useEffect(()=>{const o=c=>{const f=c.target;f instanceof Node&&(t.contains(f)||e.current?.contains(f)||n())},r=()=>{document.visibilityState==="hidden"&&n()},l=c=>{const f=c.target;c.key!=="Escape"||f instanceof Node&&t.contains(f)||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 Te(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 et({contentId:t,triggerElement:e,dismiss:n,children:o,className:r,style:l,side:c="top",align:f="center",sideOffset:u=8,collisionPadding:s=8,avoidCollisions:b=!0,...m}){const h=i.useRef(null),g=x.useReducedMotion()??!1,p=x.useIsPresent(),y=Ie(e,h,{side:c,align:f,sideOffset:u,collisionPadding:s,avoidCollisions:b});Ce(e,h,n);const v=Te(y?.side??c),k={...l,left:y?`${y.x}px`:0,top:y?`${y.y}px`:0,visibility:y?"visible":"hidden"};return a.jsx("div",{...m,ref:h,id:t,role:"tooltip","data-side":y?.side??c,"data-align":f,"data-state":p?"open":"closed","aria-hidden":p?void 0:!0,className:T("uk-tooltip",r),style:k,children:a.jsxs(x.motion.div,{className:"uk-tooltip__surface",style:{transformOrigin:v},initial:g?{opacity:0}:{opacity:0,scale:.96},animate:{opacity:1,scale:1},exit:g?{opacity:0}:{opacity:0,scale:.96},transition:g?O:Z,children:[a.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${y?.arrowOffset??0}px`}}),o]})})}function tt(t){const e=ye("Tooltip.Content"),o=i.useSyncExternalStore(be,ge,xe)&&e.triggerElement?e.triggerElement.closest("dialog")??document.body:null;return!o||!e.triggerElement?null:F.createPortal(a.jsx(x.MotionConfig,{reducedMotion:"user",children:a.jsx(x.AnimatePresence,{children:e.open?a.jsx(et,{contentId:e.contentId,triggerElement:e.triggerElement,dismiss:e.dismiss,...t},"uk-tooltip"):null})}),o)}const we=i.createContext(null);function nt(t){const e=i.useContext(we);if(!e)throw new Error(`<${t}> must be rendered inside <Tooltip.Group>`);return e}function ot({activeValue:t,content:e,contentClassName:n,contentId:o,dismiss:r,triggerElement:l,side:c,align:f,sideOffset:u,collisionPadding:s,avoidCollisions:b}){const m=i.useRef(null),h=x.useReducedMotion()??!1,g=x.useIsPresent(),p=Ie(l,m,{side:c,align:f,sideOffset:u,collisionPadding:s,avoidCollisions:b});Ce(l,m,r);const y={left:p?`${p.x}px`:0,top:p?`${p.y}px`:0,transformOrigin:Te(p?.side??c),visibility:p?"visible":"hidden"};return a.jsxs(x.motion.div,{ref:m,id:o,role:"tooltip",layout:!h,layoutDependency:t,"data-side":p?.side??c,"data-align":f,"data-state":g?"open":"closed","aria-hidden":g?void 0:!0,className:T("uk-tooltip","uk-tooltip__surface","uk-tooltip--group",n),style:y,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}}:Ne,children:[a.jsx("span",{className:"uk-tooltip__arrow","aria-hidden":"true",style:{"--uk-tooltip-arrow-offset":`${p?.arrowOffset??0}px`}}),a.jsx(x.motion.div,{className:"uk-tooltip__content",initial:{opacity:0},animate:{opacity:1},transition:h?O:Z,children:e},t)]})}function rt({children:t,side:e="top",align:n="center",sideOffset:o=8,collisionPadding:r=8,avoidCollisions:l=!0,delayDuration:c=180,closeDelay:f=80,contentClassName:u}){const s=i.useId(),[b,m]=i.useState(()=>new Map),[h,g]=i.useState(!1),[p,y]=i.useState(null),v=i.useRef(null),k=i.useRef(null),C=i.useSyncExternalStore(be,ge,xe),d=i.useCallback(()=>{v.current!==null&&(clearTimeout(v.current),v.current=null)},[]),I=i.useCallback(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null)},[]),w=E.useEventCallback((D,S=!1)=>{if(d(),I(),y(D),!h){if(S||c<=0){g(!0);return}v.current=setTimeout(()=>{v.current=null,g(!0)},c)}}),_=E.useEventCallback(()=>{if(d(),I(),!!h){if(f<=0){g(!1);return}k.current=setTimeout(()=>{k.current=null,g(!1)},f)}}),N=E.useEventCallback(()=>{d(),I(),g(!1)}),P=E.useEventCallback((D,S,M)=>{m(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})}),j=E.useEventCallback(D=>{m(S=>{if(!S.has(D))return S;const M=new Map(S);return M.delete(D),M})});i.useEffect(()=>()=>{d(),I()},[I,d]);const _e=i.useMemo(()=>({open:h,activeValue:p,contentId:s,activate:w,requestClose:_,dismiss:N,register:P,unregister:j}),[w,p,s,N,h,P,_,j]),L=p?b.get(p):void 0,Ee=h&&!!L,U=C&&L?L.triggerElement.closest("dialog")??document.body:null;return a.jsxs(we.Provider,{value:_e,children:[t,U&&L?F.createPortal(a.jsx(x.MotionConfig,{reducedMotion:"user",children:a.jsx(x.AnimatePresence,{children:Ee?a.jsx(ot,{activeValue:p??"",content:L.content,contentClassName:u,contentId:s,dismiss:N,triggerElement:L.triggerElement,side:e,align:n,sideOffset:o,collisionPadding:r,avoidCollisions:l},"uk-tooltip-group"):null})}),U):null]})}function it({value:t,content:e,children:n}){const o=nt("Tooltip.Item"),{register:r,unregister:l}=o,[c,f]=i.useState(null);if(!i.isValidElement(n))throw new Error("<Tooltip.Item> expects a single valid React element");const u=n,s=u.props,b=s.ref??u.ref,m=s.onPointerEnter,h=s.onPointerLeave,g=s.onFocus,p=s.onBlur,y=s.onKeyDown,v=o.open&&o.activeValue===t,k=i.useCallback(C=>{ve(b,C),f(C)},[b,f]);return i.useLayoutEffect(()=>{if(c)return r(t,c,e),()=>l(t)},[e,r,c,l,t]),i.cloneElement(u,{ref:k,"aria-describedby":v?ke(s["aria-describedby"],o.contentId):s["aria-describedby"],onPointerEnter:R(m,C=>{o.activate(t,C.pointerType==="touch")}),onPointerLeave:R(h,C=>{C.pointerType!=="touch"&&o.requestClose()}),onFocus:R(g,()=>{o.activate(t)}),onBlur:R(p,()=>{o.requestClose()}),onKeyDown:R(y,C=>{C.key==="Escape"&&v&&(C.preventDefault(),C.stopPropagation(),o.dismiss())})})}const at={Root:We,Trigger:Je,Content:tt,Group:rt,Item:it};exports.Button=G;exports.Dialog=Xe;exports.Input=je;exports.Marquee=Ye;exports.Sidebar=Oe;exports.Switch=Se;exports.Tabs=qe;exports.Tooltip=at;
|
|
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
|