@hamsterbase/ui 0.1.0 → 0.3.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.
Files changed (35) hide show
  1. package/dist/components/Button/Button.d.ts +5 -3
  2. package/dist/components/Button/styles.d.ts +3 -3
  3. package/dist/components/Checkbox/Checkbox.d.ts +3 -3
  4. package/dist/components/Divider/Divider.d.ts +10 -6
  5. package/dist/components/Divider/styles.d.ts +8 -4
  6. package/dist/components/IconButton/IconButton.d.ts +7 -7
  7. package/dist/components/IconButton/styles.d.ts +3 -3
  8. package/dist/components/ResizeHandle/ResizeHandle.d.ts +7 -4
  9. package/dist/components/ResizeHandle/styles.d.ts +6 -4
  10. package/dist/components/Select/Select.d.ts +17 -0
  11. package/dist/components/Select/layout.d.ts +39 -0
  12. package/dist/components/Select/styles.d.ts +26 -0
  13. package/dist/components/Select/useScrollAffordance.d.ts +12 -0
  14. package/dist/components/Select/useSelectValue.d.ts +15 -0
  15. package/dist/components/Toast/Toast.d.ts +17 -0
  16. package/dist/components/Toast/ToastStore.d.ts +33 -0
  17. package/dist/components/Toast/Toaster.d.ts +7 -0
  18. package/dist/components/Toast/styles.d.ts +15 -0
  19. package/dist/components/Tooltip/Tooltip.d.ts +10 -0
  20. package/dist/components/Tooltip/coordinator.d.ts +79 -0
  21. package/dist/components/Tooltip/layout.d.ts +28 -0
  22. package/dist/components/Tooltip/styles.d.ts +6 -0
  23. package/dist/index.d.ts +13 -3
  24. package/dist/index.js +1265 -58
  25. package/dist/styles.css +776 -115
  26. package/dist/utils/css.d.ts +6 -0
  27. package/dist/utils/focus.d.ts +4 -0
  28. package/docs/Checkbox.md +2 -0
  29. package/docs/IconButton.md +1 -1
  30. package/docs/ResizeHandle.md +2 -1
  31. package/docs/Select.md +20 -0
  32. package/docs/Toast.md +60 -0
  33. package/docs/Tooltip.md +20 -0
  34. package/docs/index.md +3 -0
  35. package/package.json +10 -8
@@ -1,7 +1,9 @@
1
1
  import type { ComponentPropsWithRef } from 'react';
2
- import { buttonStyles } from './styles.js';
2
+ import { buttonStyles as styles } from './styles.js';
3
+ export type ButtonVariant = keyof typeof styles.variants;
4
+ export type ButtonSize = keyof typeof styles.sizes;
3
5
  export interface ButtonProps extends ComponentPropsWithRef<'button'> {
4
- variant?: keyof typeof buttonStyles.variants;
5
- size?: keyof typeof buttonStyles.sizes;
6
+ readonly variant?: ButtonVariant;
7
+ readonly size?: ButtonSize;
6
8
  }
7
9
  export declare function Button({ variant, size, type, className, ...props }: ButtonProps): import("react").JSX.Element;
@@ -1,10 +1,10 @@
1
1
  export declare const buttonStyles: {
2
- readonly base: string;
2
+ readonly Root: string;
3
3
  readonly variants: {
4
- readonly primary: "border-transparent bg-hub-primary-solid text-hub-primary-contrast enabled:hover:bg-hub-primary-solid/90";
4
+ readonly primary: "border-transparent bg-hub-primary-solid text-hub-primary-contrast enabled:hover:bg-hub-primary-solid-hover";
5
5
  readonly secondary: "border-hub-border bg-hub-bg-panel text-hub-fg enabled:hover:bg-hub-bg-muted";
6
6
  readonly ghost: "border-transparent bg-transparent text-hub-fg enabled:hover:bg-hub-bg-muted";
7
- readonly danger: "border-transparent bg-hub-error-solid text-hub-error-contrast enabled:hover:bg-hub-error-solid/90";
7
+ readonly danger: "border-transparent bg-hub-error-solid text-hub-error-contrast enabled:hover:bg-hub-error-solid-hover";
8
8
  };
9
9
  readonly sizes: {
10
10
  readonly sm: "h-6 px-2.5 text-hub-sm";
@@ -1,5 +1,5 @@
1
- import { type InputHTMLAttributes } from 'react';
2
- export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ export interface CheckboxProps extends Omit<ComponentPropsWithRef<'input'>, 'type'> {
3
3
  readonly indeterminate?: boolean;
4
4
  }
5
- export declare const Checkbox: import("react").ForwardRefExoticComponent<CheckboxProps & import("react").RefAttributes<HTMLInputElement>>;
5
+ export declare function Checkbox({ indeterminate, className, ref, ...props }: CheckboxProps): import("react").JSX.Element;
@@ -1,9 +1,13 @@
1
- import { type HTMLAttributes } from 'react';
2
- export interface DividerProps extends Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {
3
- readonly orientation?: 'horizontal' | 'vertical';
4
- readonly tone?: 'default' | 'subtle';
5
- readonly edge?: 'top' | 'bottom' | 'left' | 'right';
1
+ import type { ComponentPropsWithRef } from 'react';
2
+ import { dividerStyles as styles } from './styles.js';
3
+ export type DividerOrientation = keyof typeof styles.orientations;
4
+ export type DividerTone = keyof typeof styles.tones;
5
+ export type DividerEdge = 'top' | 'bottom' | 'left' | 'right';
6
+ export interface DividerProps extends Omit<ComponentPropsWithRef<'span'>, 'children'> {
7
+ readonly orientation?: DividerOrientation;
8
+ readonly tone?: DividerTone;
9
+ readonly edge?: DividerEdge;
6
10
  readonly inset?: number;
7
11
  readonly length?: number;
8
12
  }
9
- export declare const Divider: import("react").ForwardRefExoticComponent<DividerProps & import("react").RefAttributes<HTMLSpanElement>>;
13
+ export declare function Divider({ orientation, tone, edge, inset, length, className, style, ...props }: DividerProps): import("react").JSX.Element;
@@ -1,7 +1,11 @@
1
1
  export declare const dividerStyles: {
2
2
  readonly Root: "pointer-events-none block flex-none";
3
- readonly horizontal: "h-[0.5px] w-full";
4
- readonly vertical: "w-[0.5px] self-stretch";
5
- readonly default: "bg-hub-border";
6
- readonly subtle: "bg-hub-border/50";
3
+ readonly orientations: {
4
+ readonly horizontal: "h-(--hub-hairline) w-full";
5
+ readonly vertical: "w-(--hub-hairline) self-stretch";
6
+ };
7
+ readonly tones: {
8
+ readonly default: "bg-hub-border";
9
+ readonly subtle: "bg-hub-border-subtle";
10
+ };
7
11
  };
@@ -1,11 +1,11 @@
1
1
  import type { ComponentPropsWithRef } from 'react';
2
- import { iconButtonStyles } from './styles.js';
3
- export type IconButtonSize = keyof typeof iconButtonStyles.sizes;
4
- export type IconButtonVariant = keyof typeof iconButtonStyles.variants;
2
+ import { iconButtonStyles as styles } from './styles.js';
3
+ export type IconButtonSize = keyof typeof styles.sizes;
4
+ export type IconButtonVariant = keyof typeof styles.variants;
5
5
  export interface IconButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-label' | 'aria-pressed'> {
6
- 'aria-label': string;
7
- pressed?: boolean;
8
- size?: IconButtonSize;
9
- variant?: IconButtonVariant;
6
+ readonly 'aria-label': string;
7
+ readonly pressed?: boolean;
8
+ readonly size?: IconButtonSize;
9
+ readonly variant?: IconButtonVariant;
10
10
  }
11
11
  export declare function IconButton({ className, size, type, variant, pressed, ...props }: IconButtonProps): import("react").JSX.Element;
@@ -1,12 +1,12 @@
1
1
  export declare const iconButtonStyles: {
2
- readonly base: string;
2
+ readonly Root: string;
3
3
  readonly sizes: {
4
4
  readonly sm: "size-6 [&_svg]:size-3.5";
5
5
  readonly md: "size-7 [&_svg]:size-3.5";
6
6
  readonly lg: "size-8 [&_svg]:size-4";
7
7
  };
8
8
  readonly variants: {
9
- readonly primary: string;
10
- readonly secondary: string;
9
+ readonly surface: string;
10
+ readonly ghost: string;
11
11
  };
12
12
  };
@@ -1,14 +1,17 @@
1
- import { type HTMLAttributes } from 'react';
2
- export interface ResizeHandleProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange' | 'defaultValue' | 'onDoubleClick' | 'onKeyDown' | 'onPointerEnter' | 'onPointerDown' | 'onPointerMove' | 'onPointerUp' | 'onLostPointerCapture' | 'onPointerCancel'> {
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import { resizeHandleStyles as styles } from './styles.js';
3
+ export type ResizeHandleEdge = keyof typeof styles.edges;
4
+ export interface ResizeHandleProps extends Omit<ComponentPropsWithRef<'div'>, 'children' | 'onChange' | 'defaultValue' | 'onDoubleClick' | 'onKeyDown' | 'onPointerEnter' | 'onPointerDown' | 'onPointerMove' | 'onPointerUp' | 'onLostPointerCapture' | 'onPointerCancel'> {
3
5
  readonly label: string;
4
6
  readonly controls: string;
5
7
  readonly value: number;
6
8
  readonly min: number;
7
9
  readonly max: number;
8
10
  readonly defaultValue?: number;
11
+ readonly step?: number;
9
12
  readonly showDivider?: boolean;
10
13
  readonly inset?: number;
11
- readonly edge?: 'left' | 'right';
14
+ readonly edge?: ResizeHandleEdge;
12
15
  readonly onChange: (value: number) => void;
13
16
  }
14
- export declare const ResizeHandle: import("react").ForwardRefExoticComponent<ResizeHandleProps & import("react").RefAttributes<HTMLDivElement>>;
17
+ export declare function ResizeHandle({ label, controls, value, min, max, defaultValue, step, showDivider, inset, edge, onChange, className, style, ...props }: ResizeHandleProps): import("react").JSX.Element;
@@ -1,9 +1,11 @@
1
1
  export declare const resizeHandleStyles: {
2
2
  readonly Root: string;
3
- readonly left: "left-[-3.5px]";
4
- readonly right: "right-[-3.5px]";
5
- readonly Line: "pointer-events-none absolute inset-y-0 left-[3px]";
3
+ readonly edges: {
4
+ readonly left: "left-[calc(var(--hub-hit-area)_/_-2)]";
5
+ readonly right: "right-[calc(var(--hub-hit-area)_/_-2)]";
6
+ };
7
+ readonly Line: "pointer-events-none absolute inset-y-0 left-[calc((var(--hub-hit-area)_-_1px)_/_2)]";
6
8
  readonly Feedback: string;
7
9
  readonly Gradient: string;
8
- readonly DragShield: "fixed inset-0 z-40 cursor-col-resize";
10
+ readonly DragShield: "fixed inset-0 z-(--hub-z-overlay) cursor-col-resize";
9
11
  };
@@ -0,0 +1,17 @@
1
+ import { type ComponentPropsWithoutRef, type ReactNode } from 'react';
2
+ export interface SelectOption {
3
+ readonly value: string;
4
+ readonly label: string;
5
+ readonly icon?: ReactNode;
6
+ readonly disabled?: boolean;
7
+ }
8
+ export interface SelectProps extends Omit<ComponentPropsWithoutRef<'button'>, 'value' | 'defaultValue' | 'onChange' | 'children' | 'size'> {
9
+ readonly options: readonly SelectOption[];
10
+ readonly value?: string;
11
+ readonly defaultValue?: string;
12
+ readonly onValueChange?: (value: string) => void;
13
+ readonly size?: 'small' | 'default';
14
+ readonly placeholder?: string;
15
+ readonly name?: string;
16
+ }
17
+ export declare function Select({ options, value, defaultValue, onValueChange, size, placeholder, name, disabled, className, onKeyDown, onClick, ...props }: SelectProps): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ export type MenuPlacement = 'aligned' | 'below' | 'above';
2
+ /** 菜单定位用到的样式 token(px)。 */
3
+ export interface MenuMetrics {
4
+ readonly gutter: number;
5
+ readonly maxHeight: number;
6
+ readonly affordance: number;
7
+ }
8
+ export interface MenuLayoutInput {
9
+ readonly trigger: Pick<DOMRect, 'top' | 'bottom' | 'left' | 'width' | 'height'>;
10
+ readonly viewport: {
11
+ readonly width: number;
12
+ readonly height: number;
13
+ };
14
+ readonly metrics: MenuMetrics;
15
+ /** 菜单按内容撑开时的宽度。 */
16
+ readonly panelWidth: number;
17
+ /** 菜单自身边框占用的高度(菜单高度减去列表高度)。 */
18
+ readonly borderHeight: number;
19
+ /** 列表内容总高度(含内边距)。 */
20
+ readonly contentHeight: number;
21
+ /** 初始高亮行在列表内的位置;没有可用选项时为 undefined。 */
22
+ readonly row?: {
23
+ readonly top: number;
24
+ readonly height: number;
25
+ readonly hasNext: boolean;
26
+ };
27
+ }
28
+ export interface MenuLayout {
29
+ readonly placement: MenuPlacement;
30
+ readonly top: number;
31
+ readonly left: number;
32
+ readonly width: number;
33
+ /** 列表的 max-height。 */
34
+ readonly maxHeight: number;
35
+ readonly scrollTop: number;
36
+ }
37
+ export declare function readMenuMetrics(panel: Element): MenuMetrics;
38
+ /** 根据测量值计算菜单位置:优先让初始行与触发器对齐,贴近视口边缘时改为向下或向上展开。 */
39
+ export declare function computeMenuLayout({ trigger, viewport, metrics, panelWidth, borderHeight, contentHeight, row }: MenuLayoutInput): MenuLayout;
@@ -0,0 +1,26 @@
1
+ export declare const selectStyles: {
2
+ readonly Root: "inline-flex min-w-0 align-middle";
3
+ readonly Trigger: string;
4
+ readonly Size: {
5
+ readonly small: "h-(--hub-control-height-sm) text-hub-sm";
6
+ readonly default: "h-(--hub-control-height-md) text-hub-md";
7
+ };
8
+ readonly Font: {
9
+ readonly small: "text-hub-sm";
10
+ readonly default: "text-hub-md";
11
+ };
12
+ readonly Row: {
13
+ readonly small: "h-(--hub-control-height-sm)";
14
+ readonly default: "h-(--hub-row-height-md)";
15
+ };
16
+ readonly Label: "min-w-0 flex-1 truncate text-left";
17
+ readonly Icon: "inline-flex shrink-0 items-center justify-center";
18
+ readonly Chevron: "h-2 w-2.5 shrink-0 text-hub-fg-muted";
19
+ readonly Check: "size-4 shrink-0 text-hub-fg-muted";
20
+ readonly Popup: string;
21
+ readonly List: "relative box-border overflow-y-auto overscroll-contain p-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden";
22
+ readonly Option: string;
23
+ readonly Scroll: string;
24
+ readonly ScrollTop: "top-0 bg-linear-to-b from-hub-bg-panel via-hub-bg-panel/90 to-hub-bg-panel/50";
25
+ readonly ScrollBottom: "bottom-0 bg-linear-to-t from-hub-bg-panel via-hub-bg-panel/90 to-hub-bg-panel/50";
26
+ };
@@ -0,0 +1,12 @@
1
+ import { type RefObject } from 'react';
2
+ export type ScrollSide = 'top' | 'bottom';
3
+ /** 列表两端的滚动提示:是否还有被裁剪的内容,以及悬停提示时的连续滚动。 */
4
+ export declare function useScrollAffordance(list: RefObject<HTMLElement | null>): {
5
+ edges: {
6
+ top: boolean;
7
+ bottom: boolean;
8
+ };
9
+ update: () => void;
10
+ start: (side: ScrollSide) => void;
11
+ stop: () => void;
12
+ };
@@ -0,0 +1,15 @@
1
+ import { type RefObject } from 'react';
2
+ interface Options {
3
+ readonly value: string | undefined;
4
+ readonly defaultValue: string | undefined;
5
+ readonly onValueChange: ((value: string) => void) | undefined;
6
+ readonly trigger: RefObject<HTMLButtonElement | null>;
7
+ /** 触发器的 `form` 属性;变化时重新查找所属表单。 */
8
+ readonly form: string | undefined;
9
+ }
10
+ /** 受控 / 非受控的选中值;非受控时随所属表单重置恢复 defaultValue。 */
11
+ export declare function useSelectValue({ value, defaultValue, onValueChange, trigger, form }: Options): {
12
+ current: string;
13
+ commit: (next: string) => void;
14
+ };
15
+ export {};
@@ -0,0 +1,17 @@
1
+ import { type ComponentPropsWithRef, type ReactNode } from 'react';
2
+ export type ToastVariant = 'info' | 'success' | 'error';
3
+ export interface ToastAction {
4
+ readonly label: ReactNode;
5
+ readonly onClick: () => void | Promise<void>;
6
+ }
7
+ export interface ToastProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
8
+ readonly message: ReactNode;
9
+ readonly description?: ReactNode;
10
+ readonly variant?: ToastVariant;
11
+ readonly action?: ToastAction;
12
+ readonly duration?: number;
13
+ readonly revision?: number;
14
+ readonly closeLabel: string;
15
+ readonly onDismiss: () => void;
16
+ }
17
+ export declare function Toast({ message, description, variant, action, duration, revision, closeLabel, onDismiss, className, onMouseEnter, onMouseLeave, onFocus, onBlur, ...props }: ToastProps): import("react").JSX.Element;
@@ -0,0 +1,33 @@
1
+ import type { ToastAction, ToastVariant } from './Toast.js';
2
+ export interface ToastOptions {
3
+ readonly message: string;
4
+ readonly description?: string;
5
+ readonly variant?: ToastVariant;
6
+ readonly duration?: number;
7
+ readonly action?: ToastAction;
8
+ readonly onClose?: () => void;
9
+ }
10
+ export interface ToastItem {
11
+ readonly id: string;
12
+ readonly options: ToastOptions;
13
+ /** 相同内容再次出现时递增,Toast 据此重新计时并强调。 */
14
+ readonly revision: number;
15
+ }
16
+ export interface ToastStoreOptions {
17
+ /** 同时展示的最大条数,超出时移除最早的一条。 */
18
+ readonly max?: number;
19
+ }
20
+ /** Toast 的状态容器,不依赖 React;由应用创建并交给 Toaster 渲染。 */
21
+ export declare class ToastStore {
22
+ private items;
23
+ private readonly listeners;
24
+ private readonly max;
25
+ private nextId;
26
+ constructor(options?: ToastStoreOptions);
27
+ readonly subscribe: (listener: () => void) => () => void;
28
+ readonly getSnapshot: () => readonly ToastItem[];
29
+ show(options: ToastOptions): string;
30
+ /** 不传 id 时关闭全部。 */
31
+ dismiss(id?: string): void;
32
+ private commit;
33
+ }
@@ -0,0 +1,7 @@
1
+ import { type ComponentPropsWithRef } from 'react';
2
+ import type { ToastStore } from './ToastStore.js';
3
+ export interface ToasterProps extends Omit<ComponentPropsWithRef<'div'>, 'children'> {
4
+ readonly store: ToastStore;
5
+ readonly closeLabel: string;
6
+ }
7
+ export declare function Toaster({ store, closeLabel, className, ...props }: ToasterProps): import("react").JSX.Element | null;
@@ -0,0 +1,15 @@
1
+ export declare const toastStyles: {
2
+ readonly Viewport: string;
3
+ readonly Root: string;
4
+ readonly Card: string;
5
+ readonly icons: {
6
+ readonly info: "size-4 shrink-0 text-hub-fg-muted";
7
+ readonly success: string;
8
+ readonly error: "size-4 shrink-0 text-hub-error-solid";
9
+ };
10
+ readonly Content: "min-w-0 flex-1 break-words";
11
+ readonly Message: "font-medium";
12
+ readonly Description: "mt-2 line-clamp-2 leading-5 text-hub-fg-muted";
13
+ readonly Action: string;
14
+ readonly Close: "-m-1";
15
+ };
@@ -0,0 +1,10 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ export interface TooltipProps {
3
+ readonly children: ReactElement;
4
+ readonly content: ReactNode;
5
+ readonly shortcut?: readonly string[];
6
+ readonly side?: 'top' | 'right' | 'bottom' | 'left';
7
+ readonly align?: 'start' | 'center' | 'end';
8
+ readonly disabled?: boolean;
9
+ }
10
+ export declare function Tooltip({ children, content, shortcut, side, align, disabled }: TooltipProps): import("react").JSX.Element;
@@ -0,0 +1,79 @@
1
+ /** 组件实例提供给协调器的回调。 */
2
+ export interface TooltipHost {
3
+ readonly trigger: () => Element | null;
4
+ readonly onOpenChange: (open: boolean) => void;
5
+ /** 当前按键状态变化;只通知正在显示的实例。 */
6
+ readonly onKeysChange: () => void;
7
+ /** 重新定位;触发器已离开视口时返回 false。 */
8
+ readonly reposition: () => boolean;
9
+ }
10
+ /** 一个 Tooltip 实例在协调器中的状态:显示条件和自身的定时器。 */
11
+ export declare class TooltipHandle {
12
+ private readonly coordinator;
13
+ readonly host: TooltipHost;
14
+ hover: boolean;
15
+ popupHover: boolean;
16
+ focus: boolean;
17
+ shortcut: boolean;
18
+ disabled: boolean;
19
+ openTimer: number | undefined;
20
+ closeTimer: number | undefined;
21
+ constructor(coordinator: TooltipCoordinator, host: TooltipHost);
22
+ get wanted(): boolean;
23
+ delay(name: string): number;
24
+ clearClose(): void;
25
+ enter(): void;
26
+ leave(): void;
27
+ popupEnter(): void;
28
+ popupLeave(): void;
29
+ focusIn(): void;
30
+ focusOut(): void;
31
+ /** 关闭并清除显示条件;之后需要新的进入或聚焦动作才会再次显示。 */
32
+ dismiss(): void;
33
+ setDisabled(disabled: boolean): void;
34
+ setShortcut(shortcut: boolean): void;
35
+ isPressed(label: string): boolean;
36
+ dispose(): void;
37
+ }
38
+ /** 同一文档内所有 Tooltip 共享的开关、免等待和按键状态。 */
39
+ declare class TooltipCoordinator {
40
+ private readonly document;
41
+ private readonly onEmpty;
42
+ private readonly handles;
43
+ private visible;
44
+ private pending;
45
+ /** 免等待截止时间(performance.now 时间戳)。 */
46
+ private skipUntil;
47
+ private shortcuts;
48
+ private modifiers;
49
+ /** 按下的普通键:event.code 到 keydown 时的逻辑键,释放时按 code 找回。 */
50
+ private readonly keys;
51
+ private composing;
52
+ constructor(document: Document, onEmpty: () => void);
53
+ register(host: TooltipHost): TooltipHandle;
54
+ unregister(handle: TooltipHandle): void;
55
+ /** 请求显示:已有提示显示或处于免等待时间内立即切换,否则从头等待。 */
56
+ request(handle: TooltipHandle, immediate: boolean): void;
57
+ /** 某个显示条件消失:全部消失后才关闭;鼠标离开时留出缓冲,便于移到提示内容上。 */
58
+ release(handle: TooltipHandle, buffered: boolean): void;
59
+ dismiss(handle: TooltipHandle): void;
60
+ countShortcut(change: number): void;
61
+ isPressed(label: string): boolean;
62
+ private show;
63
+ private hide;
64
+ private cancelPending;
65
+ private dismissAll;
66
+ private keyState;
67
+ private clearKeys;
68
+ private readonly onKey;
69
+ private readonly onComposition;
70
+ /** 触发器随滚动移动时关闭;由键盘焦点保持的提示改为跟随,否则 Tab 到视口外的触发器会立刻被关掉。 */
71
+ private readonly onScroll;
72
+ private readonly onResize;
73
+ /** 窗口失焦或页面隐藏:之后收不到按键释放和鼠标离开,全部状态归零。 */
74
+ private readonly onInactive;
75
+ private listen;
76
+ }
77
+ /** 在触发器所在文档的协调器中注册一个实例;协调器按需创建,最后一个实例注销后移除。 */
78
+ export declare function registerTooltip(document: Document, host: TooltipHost): TooltipHandle;
79
+ export {};
@@ -0,0 +1,28 @@
1
+ export type TooltipSide = 'top' | 'right' | 'bottom' | 'left';
2
+ export type TooltipAlign = 'start' | 'center' | 'end';
3
+ export interface TooltipLayoutInput {
4
+ readonly trigger: Pick<DOMRect, 'top' | 'bottom' | 'left' | 'right' | 'width' | 'height'>;
5
+ /** 浮层可见部分的尺寸(不含外边距)。 */
6
+ readonly panel: {
7
+ readonly width: number;
8
+ readonly height: number;
9
+ };
10
+ /** 浮层的外边距:既是与触发器的间距,也是与视口边缘的最小间距。 */
11
+ readonly margin: number;
12
+ readonly viewport: {
13
+ readonly width: number;
14
+ readonly height: number;
15
+ };
16
+ readonly side: TooltipSide;
17
+ readonly align: TooltipAlign;
18
+ readonly rtl: boolean;
19
+ }
20
+ export interface TooltipLayout {
21
+ /** 实际显示的方向。 */
22
+ readonly side: TooltipSide;
23
+ /** 浮层外边距盒左上角的位置,直接写入 fixed 定位的 top 和 left。 */
24
+ readonly top: number;
25
+ readonly left: number;
26
+ }
27
+ /** 优先使用 side 和 align;主方向放不下且反方向更宽裕时翻转,最后把位置约束在视口内。 */
28
+ export declare function computeTooltipLayout({ trigger, panel, margin, viewport, side, align, rtl }: TooltipLayoutInput): TooltipLayout;
@@ -0,0 +1,6 @@
1
+ export declare const tooltipStyles: {
2
+ readonly Popup: string;
3
+ readonly Content: "min-w-0 whitespace-normal wrap-anywhere";
4
+ readonly Keys: "-mr-0.5 inline-flex shrink-0 items-center gap-0.5";
5
+ readonly Kbd: string;
6
+ };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,20 @@
1
1
  export { Button } from './components/Button/Button.js';
2
- export type { ButtonProps } from './components/Button/Button.js';
2
+ export type { ButtonProps, ButtonSize, ButtonVariant } from './components/Button/Button.js';
3
3
  export { IconButton } from './components/IconButton/IconButton.js';
4
4
  export type { IconButtonProps, IconButtonSize, IconButtonVariant } from './components/IconButton/IconButton.js';
5
5
  export { Checkbox } from './components/Checkbox/Checkbox.js';
6
6
  export type { CheckboxProps } from './components/Checkbox/Checkbox.js';
7
7
  export { Divider } from './components/Divider/Divider.js';
8
- export type { DividerProps } from './components/Divider/Divider.js';
8
+ export type { DividerEdge, DividerOrientation, DividerProps, DividerTone } from './components/Divider/Divider.js';
9
9
  export { ResizeHandle } from './components/ResizeHandle/ResizeHandle.js';
10
- export type { ResizeHandleProps } from './components/ResizeHandle/ResizeHandle.js';
10
+ export type { ResizeHandleEdge, ResizeHandleProps } from './components/ResizeHandle/ResizeHandle.js';
11
+ export { Toast } from './components/Toast/Toast.js';
12
+ export type { ToastAction, ToastProps, ToastVariant } from './components/Toast/Toast.js';
13
+ export { Toaster } from './components/Toast/Toaster.js';
14
+ export type { ToasterProps } from './components/Toast/Toaster.js';
15
+ export { ToastStore } from './components/Toast/ToastStore.js';
16
+ export type { ToastItem, ToastOptions, ToastStoreOptions } from './components/Toast/ToastStore.js';
17
+ export { Select } from './components/Select/Select.js';
18
+ export type { SelectProps, SelectOption } from './components/Select/Select.js';
19
+ export { Tooltip } from './components/Tooltip/Tooltip.js';
20
+ export type { TooltipProps } from './components/Tooltip/Tooltip.js';