@hamsterbase/ui 0.0.0-stage → 0.2.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/components/Button/Button.d.ts +9 -0
- package/dist/components/Button/styles.d.ts +14 -0
- package/dist/components/Checkbox/Checkbox.d.ts +5 -0
- package/dist/components/Checkbox/styles.d.ts +7 -0
- package/dist/components/Divider/Divider.d.ts +13 -0
- package/dist/components/Divider/styles.d.ts +11 -0
- package/dist/components/IconButton/IconButton.d.ts +11 -0
- package/dist/components/IconButton/styles.d.ts +12 -0
- package/dist/components/ResizeHandle/ResizeHandle.d.ts +17 -0
- package/dist/components/ResizeHandle/styles.d.ts +11 -0
- package/dist/components/Toast/Toast.d.ts +17 -0
- package/dist/components/Toast/ToastStore.d.ts +33 -0
- package/dist/components/Toast/Toaster.d.ts +7 -0
- package/dist/components/Toast/styles.d.ts +15 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +499 -0
- package/dist/styles.css +967 -0
- package/dist/utils/focus.d.ts +4 -0
- package/docs/Button.md +6 -0
- package/docs/Checkbox.md +7 -0
- package/docs/Divider.md +11 -0
- package/docs/IconButton.md +7 -0
- package/docs/ResizeHandle.md +19 -0
- package/docs/Toast.md +60 -0
- package/docs/index.md +19 -0
- package/package.json +50 -4
- package/README.md +0 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { buttonStyles as styles } from './styles.js';
|
|
3
|
+
export type ButtonVariant = keyof typeof styles.variants;
|
|
4
|
+
export type ButtonSize = keyof typeof styles.sizes;
|
|
5
|
+
export interface ButtonProps extends ComponentPropsWithRef<'button'> {
|
|
6
|
+
readonly variant?: ButtonVariant;
|
|
7
|
+
readonly size?: ButtonSize;
|
|
8
|
+
}
|
|
9
|
+
export declare function Button({ variant, size, type, className, ...props }: ButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const buttonStyles: {
|
|
2
|
+
readonly Root: string;
|
|
3
|
+
readonly variants: {
|
|
4
|
+
readonly primary: "border-transparent bg-hub-primary-solid text-hub-primary-contrast enabled:hover:bg-hub-primary-solid-hover";
|
|
5
|
+
readonly secondary: "border-hub-border bg-hub-bg-panel text-hub-fg enabled:hover:bg-hub-bg-muted";
|
|
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-hover";
|
|
8
|
+
};
|
|
9
|
+
readonly sizes: {
|
|
10
|
+
readonly sm: "h-6 px-2.5 text-hub-sm";
|
|
11
|
+
readonly md: "h-7 px-3 text-hub-md";
|
|
12
|
+
readonly lg: "h-8 px-4 text-hub-md";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ComponentPropsWithRef } from 'react';
|
|
2
|
+
export interface CheckboxProps extends Omit<ComponentPropsWithRef<'input'>, 'type'> {
|
|
3
|
+
readonly indeterminate?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare function Checkbox({ indeterminate, className, ref, ...props }: CheckboxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const checkboxStyles: {
|
|
2
|
+
readonly Root: "group/checkbox relative inline-flex size-3.5 flex-none align-middle";
|
|
3
|
+
readonly Input: string;
|
|
4
|
+
readonly Surface: string;
|
|
5
|
+
readonly Check: "hidden [grid-area:1/1] group-has-[:checked:not(:indeterminate)]/checkbox:block";
|
|
6
|
+
readonly Mixed: "hidden [grid-area:1/1] group-has-[:indeterminate]/checkbox:block";
|
|
7
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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;
|
|
10
|
+
readonly inset?: number;
|
|
11
|
+
readonly length?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function Divider({ orientation, tone, edge, inset, length, className, style, ...props }: DividerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const dividerStyles: {
|
|
2
|
+
readonly Root: "pointer-events-none block flex-none";
|
|
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
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentPropsWithRef } from 'react';
|
|
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
|
+
export interface IconButtonProps extends Omit<ComponentPropsWithRef<'button'>, 'aria-label' | 'aria-pressed'> {
|
|
6
|
+
readonly 'aria-label': string;
|
|
7
|
+
readonly pressed?: boolean;
|
|
8
|
+
readonly size?: IconButtonSize;
|
|
9
|
+
readonly variant?: IconButtonVariant;
|
|
10
|
+
}
|
|
11
|
+
export declare function IconButton({ className, size, type, variant, pressed, ...props }: IconButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const iconButtonStyles: {
|
|
2
|
+
readonly Root: string;
|
|
3
|
+
readonly sizes: {
|
|
4
|
+
readonly sm: "size-6 [&_svg]:size-3.5";
|
|
5
|
+
readonly md: "size-7 [&_svg]:size-3.5";
|
|
6
|
+
readonly lg: "size-8 [&_svg]:size-4";
|
|
7
|
+
};
|
|
8
|
+
readonly variants: {
|
|
9
|
+
readonly surface: string;
|
|
10
|
+
readonly ghost: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
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'> {
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly controls: string;
|
|
7
|
+
readonly value: number;
|
|
8
|
+
readonly min: number;
|
|
9
|
+
readonly max: number;
|
|
10
|
+
readonly defaultValue?: number;
|
|
11
|
+
readonly step?: number;
|
|
12
|
+
readonly showDivider?: boolean;
|
|
13
|
+
readonly inset?: number;
|
|
14
|
+
readonly edge?: ResizeHandleEdge;
|
|
15
|
+
readonly onChange: (value: number) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function ResizeHandle({ label, controls, value, min, max, defaultValue, step, showDivider, inset, edge, onChange, className, style, ...props }: ResizeHandleProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const resizeHandleStyles: {
|
|
2
|
+
readonly Root: string;
|
|
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)]";
|
|
8
|
+
readonly Feedback: string;
|
|
9
|
+
readonly Gradient: string;
|
|
10
|
+
readonly DragShield: "fixed inset-0 z-(--hub-z-overlay) cursor-col-resize";
|
|
11
|
+
};
|
|
@@ -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
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { Button } from './components/Button/Button.js';
|
|
2
|
+
export type { ButtonProps, ButtonSize, ButtonVariant } from './components/Button/Button.js';
|
|
3
|
+
export { IconButton } from './components/IconButton/IconButton.js';
|
|
4
|
+
export type { IconButtonProps, IconButtonSize, IconButtonVariant } from './components/IconButton/IconButton.js';
|
|
5
|
+
export { Checkbox } from './components/Checkbox/Checkbox.js';
|
|
6
|
+
export type { CheckboxProps } from './components/Checkbox/Checkbox.js';
|
|
7
|
+
export { Divider } from './components/Divider/Divider.js';
|
|
8
|
+
export type { DividerEdge, DividerOrientation, DividerProps, DividerTone } from './components/Divider/Divider.js';
|
|
9
|
+
export { ResizeHandle } 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';
|