ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
54 lines (53 loc) • 2.12 kB
TypeScript
import { RanElement } from '../../utils';
import { EventManager } from '../../utils/builder';
export declare class Button extends RanElement {
_btn: HTMLDivElement;
_btnContent: HTMLDivElement;
_iconElement?: HTMLElement;
_slot: HTMLSlotElement;
_shadowDom: ShadowRoot;
_events: EventManager;
debounceTimeId?: NodeJS.Timeout;
static get observedAttributes(): string[];
constructor();
get sheet(): string;
set sheet(value: string);
get disabled(): boolean | string;
set disabled(value: boolean | string | undefined | null);
get iconSize(): string;
set iconSize(value: string | undefined | null);
get icon(): string;
set icon(value: string | null);
get effect(): string;
set effect(value: string | null);
/** Visual variant: `''` (default) | `'primary'` (monochrome) | `'warning'` | `'text'`. Drives the `:host([type=...])` styles. */
get type(): string;
set type(value: string | null);
/**
* @description: 设置 button 的 icon
*/
setIcon: () => void;
mousedown: (event: MouseEvent) => void;
mouseup: () => void;
keydown: (event: KeyboardEvent) => void;
debounceMouseEvent: () => void;
handlerExternalCss: () => void;
syncA11yState: () => void;
connectedCallback(): void;
/**
* @description: FIX: 修正拼写错误 disconnectCallback -> disconnectedCallback
* 确保组件销毁时正确移除事件监听,彻底杜绝内存泄漏。
*/
disconnectedCallback(): void;
/**
* Copies the host's `aria-label` onto the element that actually carries the button role.
*
* The role lives on a div inside the shadow root, and an accessible name is normally
* taken from the slotted content — which for an icon-only button is an `<r-icon>` with no
* text. Without this there is no way to name such a button from outside, and DESIGN.md
* requires every icon-only control to have one.
*/
syncAriaLabel: () => void;
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
}
export default Button;