@luanlu/mk-motion 1.0.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/README.md +120 -0
- package/dist/a11y/focus-trap.d.ts +10 -0
- package/dist/a11y/keyboard.d.ts +28 -0
- package/dist/components/alert/alert.d.ts +18 -0
- package/dist/components/avatar/avatar.d.ts +31 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +16 -0
- package/dist/components/button/button.d.ts +28 -0
- package/dist/components/card/card.d.ts +19 -0
- package/dist/components/collapse/collapse.d.ts +23 -0
- package/dist/components/dialog/dialog.d.ts +27 -0
- package/dist/components/drawer/drawer.d.ts +21 -0
- package/dist/components/empty/empty.d.ts +14 -0
- package/dist/components/form/checkbox.d.ts +27 -0
- package/dist/components/form/radio.d.ts +32 -0
- package/dist/components/form/select.d.ts +32 -0
- package/dist/components/form/slider.d.ts +31 -0
- package/dist/components/input/input.d.ts +31 -0
- package/dist/components/layout/divider.d.ts +12 -0
- package/dist/components/layout/row.d.ts +14 -0
- package/dist/components/layout/space.d.ts +13 -0
- package/dist/components/loading/loading.d.ts +8 -0
- package/dist/components/menu/menu.d.ts +30 -0
- package/dist/components/message/message.d.ts +10 -0
- package/dist/components/popover/popover.d.ts +31 -0
- package/dist/components/progress/progress.d.ts +25 -0
- package/dist/components/steps/steps.d.ts +22 -0
- package/dist/components/switch/switch.d.ts +23 -0
- package/dist/components/table/table.d.ts +47 -0
- package/dist/components/tabs/tabs.d.ts +30 -0
- package/dist/components/tag/tag.d.ts +24 -0
- package/dist/components/tooltip/tooltip.d.ts +8 -0
- package/dist/core/animator.d.ts +29 -0
- package/dist/core/timeline.d.ts +14 -0
- package/dist/core/utils.d.ts +13 -0
- package/dist/effects/glitch.d.ts +14 -0
- package/dist/effects/particle.d.ts +17 -0
- package/dist/effects/text-split.d.ts +14 -0
- package/dist/effects/wave-text.d.ts +17 -0
- package/dist/gesture/draggable.d.ts +23 -0
- package/dist/gesture/spring.d.ts +24 -0
- package/dist/index.d.ts +109 -0
- package/dist/interactive/coverflow.d.ts +24 -0
- package/dist/interactive/cursor-trail.d.ts +11 -0
- package/dist/interactive/flip-card.d.ts +18 -0
- package/dist/interactive/magnetic.d.ts +12 -0
- package/dist/micro/hover-lift.d.ts +15 -0
- package/dist/micro/ripple.d.ts +13 -0
- package/dist/mk-motion.js +3194 -0
- package/dist/mk-motion.umd.cjs +149 -0
- package/dist/motion/component-motion.d.ts +43 -0
- package/dist/presets/index.d.ts +20 -0
- package/dist/scroll/scroll-trigger.d.ts +20 -0
- package/dist/style.css +1 -0
- package/dist/text/count-up.d.ts +23 -0
- package/dist/text/typewriter.d.ts +21 -0
- package/dist/theme/theme.d.ts +28 -0
- package/dist/transitions/blur-reveal.d.ts +14 -0
- package/dist/transitions/collapse.d.ts +16 -0
- package/dist/transitions/lazy-image.d.ts +14 -0
- package/dist/transitions/list.d.ts +9 -0
- package/dist/transitions/loading.d.ts +13 -0
- package/dist/transitions/parallax.d.ts +16 -0
- package/dist/transitions/shimmer.d.ts +13 -0
- package/dist/transitions/toast.d.ts +25 -0
- package/dist/types.d.ts +4 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# MotionKit
|
|
2
|
+
|
|
3
|
+
一个轻量、现代的前端动效库,同时支持 **CSS 类动画** 和 **Web Animations API**。
|
|
4
|
+
|
|
5
|
+
## 特性
|
|
6
|
+
|
|
7
|
+
- 🎨 **15+ 预设动画**:fade、slide、zoom、bounce、flip、shake、pulse、rotate 等
|
|
8
|
+
- 🔧 **双模式**:CSS 关键帧动画 + Web Animations API
|
|
9
|
+
- 🌳 **Tree-shaking**:按需引入,不打包多余代码
|
|
10
|
+
- 📘 **TypeScript**:完整的类型定义
|
|
11
|
+
- 📦 **零依赖**:纯原生实现
|
|
12
|
+
|
|
13
|
+
## 安装
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install mk-motion
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 快速开始
|
|
20
|
+
|
|
21
|
+
### 方式一:CSS 类(推荐简单场景)
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<div class="mk-animated mk-slideInUp">Hello World</div>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
/* 自定义时长和缓动 */
|
|
29
|
+
.my-box {
|
|
30
|
+
--mk-duration: 0.8s;
|
|
31
|
+
--mk-easing: cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 方式二:JavaScript API
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
import { fadeIn, slideInUp, Animator } from 'mk-motion'
|
|
39
|
+
|
|
40
|
+
// 快捷方法
|
|
41
|
+
await fadeIn(document.querySelector('.box'))
|
|
42
|
+
await slideInUp('.box', { duration: 600, easing: 'ease-out' })
|
|
43
|
+
|
|
44
|
+
// 链式控制
|
|
45
|
+
const anim = new Animator('.box')
|
|
46
|
+
await anim.animate('bounceIn', { duration: 500 })
|
|
47
|
+
anim.reset()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 方式三:Web Animations API
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { Animator } from 'mk-motion'
|
|
54
|
+
|
|
55
|
+
const anim = new Animator('.box')
|
|
56
|
+
await anim.waa(
|
|
57
|
+
[
|
|
58
|
+
{ transform: 'scale(1)', opacity: 1 },
|
|
59
|
+
{ transform: 'scale(1.2)', opacity: 0.8 },
|
|
60
|
+
{ transform: 'scale(1)', opacity: 1 },
|
|
61
|
+
],
|
|
62
|
+
{ duration: 300, iterations: 2 }
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## 预设动画列表
|
|
67
|
+
|
|
68
|
+
| 动画 | 说明 |
|
|
69
|
+
|------|------|
|
|
70
|
+
| `fadeIn` / `fadeOut` | 淡入 / 淡出 |
|
|
71
|
+
| `slideInUp` / `slideInDown` / `slideInLeft` / `slideInRight` | 从各方向滑入 |
|
|
72
|
+
| `slideOutUp` / `slideOutDown` | 向上/下滑出 |
|
|
73
|
+
| `zoomIn` / `zoomOut` | 缩放进入 / 退出 |
|
|
74
|
+
| `bounceIn` / `bounceOut` | 弹跳进入 / 退出 |
|
|
75
|
+
| `flipInX` / `flipInY` | 3D 翻转进入 |
|
|
76
|
+
| `shake` | 左右摇晃 |
|
|
77
|
+
| `pulse` | 脉冲缩放 |
|
|
78
|
+
| `rotateIn` | 旋转进入 |
|
|
79
|
+
|
|
80
|
+
## API
|
|
81
|
+
|
|
82
|
+
### `new Animator(element)`
|
|
83
|
+
|
|
84
|
+
| 方法 | 说明 |
|
|
85
|
+
|------|------|
|
|
86
|
+
| `.animate(name, options)` | 播放 CSS 预设动画 |
|
|
87
|
+
| `.waa(keyframes, options)` | 使用 WAAPI 播放自定义关键帧 |
|
|
88
|
+
| `.stop()` | 停止当前动画 |
|
|
89
|
+
| `.reset()` | 移除所有动效类 |
|
|
90
|
+
| `.vars({ duration: '1s' })` | 设置 CSS 变量 |
|
|
91
|
+
|
|
92
|
+
### `AnimationOptions`
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
interface AnimationOptions {
|
|
96
|
+
duration?: number // 毫秒,默认 500
|
|
97
|
+
easing?: string // CSS easing,默认 'ease'
|
|
98
|
+
delay?: number // 延迟毫秒
|
|
99
|
+
iterations?: number // 次数,Infinity 为无限循环
|
|
100
|
+
direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse'
|
|
101
|
+
fill?: 'none' | 'forwards' | 'backwards' | 'both'
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 构建
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
npm install
|
|
109
|
+
npm run build
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
构建产物位于 `dist/`:
|
|
113
|
+
- `mk-motion.js` — ES Module
|
|
114
|
+
- `mk-motion.umd.cjs` — UMD(浏览器直接引用)
|
|
115
|
+
- `style.css` — 动画样式
|
|
116
|
+
- `index.d.ts` — 类型声明
|
|
117
|
+
|
|
118
|
+
## 许可证
|
|
119
|
+
|
|
120
|
+
MIT
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class FocusTrap {
|
|
2
|
+
private container;
|
|
3
|
+
private previousActiveElement;
|
|
4
|
+
private listeners;
|
|
5
|
+
constructor(container: HTMLElement);
|
|
6
|
+
activate(initialFocus?: HTMLElement): void;
|
|
7
|
+
deactivate(): void;
|
|
8
|
+
private getFocusableElements;
|
|
9
|
+
private handleKeyDown;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard navigation helpers for accessible components.
|
|
3
|
+
*/
|
|
4
|
+
export interface KeyHandler {
|
|
5
|
+
key: string;
|
|
6
|
+
handler: (e: KeyboardEvent) => void;
|
|
7
|
+
preventDefault?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Attach keyboard handlers to an element.
|
|
11
|
+
* Returns a cleanup function.
|
|
12
|
+
*/
|
|
13
|
+
export declare function onKey(el: HTMLElement, handlers: KeyHandler[]): () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Common ARIA key patterns.
|
|
16
|
+
*/
|
|
17
|
+
export declare const Keys: {
|
|
18
|
+
readonly Enter: "Enter";
|
|
19
|
+
readonly Escape: "Escape";
|
|
20
|
+
readonly Tab: "Tab";
|
|
21
|
+
readonly ArrowUp: "ArrowUp";
|
|
22
|
+
readonly ArrowDown: "ArrowDown";
|
|
23
|
+
readonly ArrowLeft: "ArrowLeft";
|
|
24
|
+
readonly ArrowRight: "ArrowRight";
|
|
25
|
+
readonly Home: "Home";
|
|
26
|
+
readonly End: "End";
|
|
27
|
+
readonly Space: " ";
|
|
28
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
export interface AlertOptions {
|
|
3
|
+
type?: 'info' | 'success' | 'warning' | 'danger';
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
closable?: boolean;
|
|
7
|
+
showIcon?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class MkAlert {
|
|
11
|
+
el: HTMLDivElement;
|
|
12
|
+
private options;
|
|
13
|
+
constructor(container: HTMLElement | string, options?: AlertOptions);
|
|
14
|
+
private buildClass;
|
|
15
|
+
close(): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare function createAlert(container: HTMLElement | string, options?: AlertOptions): MkAlert;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
export interface AvatarOptions {
|
|
3
|
+
src?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
size?: 'small' | 'default' | 'large';
|
|
6
|
+
shape?: 'circle' | 'square';
|
|
7
|
+
icon?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class MkAvatar {
|
|
10
|
+
el: HTMLDivElement;
|
|
11
|
+
private options;
|
|
12
|
+
constructor(container: HTMLElement | string, options?: AvatarOptions);
|
|
13
|
+
private buildClass;
|
|
14
|
+
private showFallback;
|
|
15
|
+
setSrc(src: string): void;
|
|
16
|
+
setText(text: string): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
19
|
+
export interface AvatarGroupOptions {
|
|
20
|
+
avatars: AvatarOptions[];
|
|
21
|
+
max?: number;
|
|
22
|
+
size?: 'small' | 'default' | 'large';
|
|
23
|
+
}
|
|
24
|
+
export declare class MkAvatarGroup {
|
|
25
|
+
el: HTMLDivElement;
|
|
26
|
+
private options;
|
|
27
|
+
constructor(container: HTMLElement | string, options: AvatarGroupOptions);
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function createAvatar(container: HTMLElement | string, options?: AvatarOptions): MkAvatar;
|
|
31
|
+
export declare function createAvatarGroup(container: HTMLElement | string, options: AvatarGroupOptions): MkAvatarGroup;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
export interface BreadcrumbItem {
|
|
3
|
+
label: string;
|
|
4
|
+
href?: string;
|
|
5
|
+
onClick?: () => void;
|
|
6
|
+
}
|
|
7
|
+
export interface BreadcrumbOptions {
|
|
8
|
+
items: BreadcrumbItem[];
|
|
9
|
+
separator?: string | HTMLElement;
|
|
10
|
+
}
|
|
11
|
+
export declare class MkBreadcrumb {
|
|
12
|
+
el: HTMLElement;
|
|
13
|
+
constructor(container: HTMLElement | string, options: BreadcrumbOptions);
|
|
14
|
+
destroy(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createBreadcrumb(container: HTMLElement | string, options: BreadcrumbOptions): MkBreadcrumb;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MotionOptions } from '../../motion/component-motion.ts';
|
|
2
|
+
|
|
3
|
+
export interface ButtonOptions {
|
|
4
|
+
type?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'text';
|
|
5
|
+
size?: 'default' | 'small' | 'large';
|
|
6
|
+
plain?: boolean;
|
|
7
|
+
round?: boolean;
|
|
8
|
+
circle?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
text?: string;
|
|
12
|
+
icon?: string;
|
|
13
|
+
onClick?: (e: MouseEvent) => void;
|
|
14
|
+
motion?: MotionOptions;
|
|
15
|
+
}
|
|
16
|
+
export declare class MkButton {
|
|
17
|
+
el: HTMLButtonElement;
|
|
18
|
+
private options;
|
|
19
|
+
private motion;
|
|
20
|
+
constructor(container: HTMLElement | string, options?: ButtonOptions);
|
|
21
|
+
private buildClass;
|
|
22
|
+
private createRipple;
|
|
23
|
+
setLoading(loading: boolean): void;
|
|
24
|
+
setDisabled(disabled: boolean): void;
|
|
25
|
+
private updateAriaDisabled;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function createButton(container: HTMLElement | string, options?: ButtonOptions): MkButton;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MotionOptions } from '../../motion/component-motion.ts';
|
|
2
|
+
|
|
3
|
+
export interface CardOptions {
|
|
4
|
+
title?: string;
|
|
5
|
+
body?: string;
|
|
6
|
+
footer?: string;
|
|
7
|
+
image?: string;
|
|
8
|
+
shadow?: 'always' | 'hover' | 'never';
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
motion?: MotionOptions;
|
|
11
|
+
}
|
|
12
|
+
export declare class MkCard {
|
|
13
|
+
el: HTMLDivElement;
|
|
14
|
+
private motion;
|
|
15
|
+
constructor(container: HTMLElement | string, options?: CardOptions);
|
|
16
|
+
setLoading(loading: boolean): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function createCard(container: HTMLElement | string, options?: CardOptions): MkCard;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
export interface CollapseItem {
|
|
3
|
+
title: string;
|
|
4
|
+
content: string | HTMLElement;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface CollapsePanelOptions {
|
|
8
|
+
items: CollapseItem[];
|
|
9
|
+
accordion?: boolean;
|
|
10
|
+
activeKeys?: number[];
|
|
11
|
+
}
|
|
12
|
+
export declare class MkCollapse {
|
|
13
|
+
el: HTMLDivElement;
|
|
14
|
+
private options;
|
|
15
|
+
private activeKeys;
|
|
16
|
+
private itemEls;
|
|
17
|
+
constructor(container: HTMLElement | string, options: CollapsePanelOptions);
|
|
18
|
+
private toggle;
|
|
19
|
+
private updateItemState;
|
|
20
|
+
setActiveKeys(keys: number[]): void;
|
|
21
|
+
destroy(): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createCollapse(container: HTMLElement | string, options: CollapsePanelOptions): MkCollapse;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
export interface DialogOptions {
|
|
3
|
+
title?: string;
|
|
4
|
+
content?: string | HTMLElement;
|
|
5
|
+
showClose?: boolean;
|
|
6
|
+
showCancel?: boolean;
|
|
7
|
+
center?: boolean;
|
|
8
|
+
cancelText?: string;
|
|
9
|
+
confirmText?: string;
|
|
10
|
+
onConfirm?: () => void;
|
|
11
|
+
onCancel?: () => void;
|
|
12
|
+
onClose?: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare class MkDialog {
|
|
15
|
+
private overlay;
|
|
16
|
+
private dialog;
|
|
17
|
+
private options;
|
|
18
|
+
private focusTrap;
|
|
19
|
+
private escapeCleanup;
|
|
20
|
+
private confirmBtn;
|
|
21
|
+
private titleId;
|
|
22
|
+
constructor(options?: DialogOptions);
|
|
23
|
+
open(): void;
|
|
24
|
+
close(): void;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function createDialog(options?: DialogOptions): MkDialog;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
export interface DrawerOptions {
|
|
3
|
+
title?: string;
|
|
4
|
+
content?: string | HTMLElement;
|
|
5
|
+
direction?: 'right' | 'left' | 'top' | 'bottom';
|
|
6
|
+
size?: number;
|
|
7
|
+
showClose?: boolean;
|
|
8
|
+
onClose?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class MkDrawer {
|
|
11
|
+
private overlay;
|
|
12
|
+
private drawer;
|
|
13
|
+
private options;
|
|
14
|
+
private focusTrap;
|
|
15
|
+
private escapeCleanup;
|
|
16
|
+
constructor(options?: DrawerOptions);
|
|
17
|
+
open(): void;
|
|
18
|
+
close(): void;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare function createDrawer(options?: DrawerOptions): MkDrawer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
export interface EmptyOptions {
|
|
3
|
+
description?: string;
|
|
4
|
+
image?: string | 'default';
|
|
5
|
+
imageStyle?: Partial<CSSStyleDeclaration>;
|
|
6
|
+
}
|
|
7
|
+
export declare class MkEmpty {
|
|
8
|
+
el: HTMLDivElement;
|
|
9
|
+
private options;
|
|
10
|
+
constructor(container: HTMLElement | string, options?: EmptyOptions);
|
|
11
|
+
setDescription(text: string): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createEmpty(container: HTMLElement | string, options?: EmptyOptions): MkEmpty;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
export interface CheckboxOptions {
|
|
3
|
+
label?: string;
|
|
4
|
+
checked?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
onChange?: (checked: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare class MkCheckbox {
|
|
9
|
+
el: HTMLLabelElement;
|
|
10
|
+
private options;
|
|
11
|
+
private _checked;
|
|
12
|
+
private _cleanupKey?;
|
|
13
|
+
constructor(container: HTMLElement | string, options?: CheckboxOptions);
|
|
14
|
+
get checked(): boolean;
|
|
15
|
+
set checked(v: boolean);
|
|
16
|
+
toggle(): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
}
|
|
19
|
+
export declare function createCheckbox(container: HTMLElement | string, options?: CheckboxOptions): MkCheckbox;
|
|
20
|
+
export declare class MkCheckboxGroup {
|
|
21
|
+
el: HTMLDivElement;
|
|
22
|
+
private checkboxes;
|
|
23
|
+
constructor(container: HTMLElement | string);
|
|
24
|
+
add(options: CheckboxOptions): MkCheckbox;
|
|
25
|
+
getValues(): boolean[];
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
export interface RadioOptions {
|
|
3
|
+
label?: string;
|
|
4
|
+
value: string | number;
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
onChange?: (value: string | number) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare class MkRadio {
|
|
10
|
+
el: HTMLLabelElement;
|
|
11
|
+
private options;
|
|
12
|
+
private _checked;
|
|
13
|
+
constructor(container: HTMLElement | string, options: RadioOptions);
|
|
14
|
+
setChecked(checked: boolean): void;
|
|
15
|
+
getValue(): string | number;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
}
|
|
18
|
+
export declare class MkRadioGroup {
|
|
19
|
+
el: HTMLDivElement;
|
|
20
|
+
private radios;
|
|
21
|
+
private _value;
|
|
22
|
+
private _cleanupKey?;
|
|
23
|
+
constructor(container: HTMLElement | string, options?: {
|
|
24
|
+
value?: string | number;
|
|
25
|
+
onChange?: (value: string | number) => void;
|
|
26
|
+
});
|
|
27
|
+
add(radioOptions: Omit<RadioOptions, 'onChange'>): MkRadio;
|
|
28
|
+
setValue(value: string | number): void;
|
|
29
|
+
getValue(): string | number | undefined;
|
|
30
|
+
private focusRadio;
|
|
31
|
+
destroy(): void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
|
|
2
|
+
export interface SelectOption {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string | number;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface SelectOptions {
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
options: SelectOption[];
|
|
10
|
+
value?: string | number;
|
|
11
|
+
onChange?: (value: string | number) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class MkSelect {
|
|
14
|
+
el: HTMLDivElement;
|
|
15
|
+
private trigger;
|
|
16
|
+
private dropdown;
|
|
17
|
+
private options;
|
|
18
|
+
private _value;
|
|
19
|
+
private isOpen;
|
|
20
|
+
private _cleanupKey?;
|
|
21
|
+
constructor(container: HTMLElement | string, options: SelectOptions);
|
|
22
|
+
private updateLabel;
|
|
23
|
+
get value(): string | number | undefined;
|
|
24
|
+
setValue(v: string | number): void;
|
|
25
|
+
private renderOptions;
|
|
26
|
+
private toggle;
|
|
27
|
+
open(): void;
|
|
28
|
+
close(): void;
|
|
29
|
+
private moveSelection;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function createSelect(container: HTMLElement | string, options: SelectOptions): MkSelect;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
export interface SliderOptions {
|
|
3
|
+
min?: number;
|
|
4
|
+
max?: number;
|
|
5
|
+
step?: number;
|
|
6
|
+
value?: number;
|
|
7
|
+
showValue?: boolean;
|
|
8
|
+
onChange?: (value: number) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare class MkSlider {
|
|
11
|
+
el: HTMLDivElement;
|
|
12
|
+
private track;
|
|
13
|
+
private fill;
|
|
14
|
+
private thumb;
|
|
15
|
+
private valueEl?;
|
|
16
|
+
private options;
|
|
17
|
+
private _value;
|
|
18
|
+
private dragging;
|
|
19
|
+
private _cleanupKey?;
|
|
20
|
+
constructor(container: HTMLElement | string, options?: SliderOptions);
|
|
21
|
+
private onStart;
|
|
22
|
+
private onMove;
|
|
23
|
+
private onEnd;
|
|
24
|
+
private updateFromPosition;
|
|
25
|
+
get value(): number;
|
|
26
|
+
set value(v: number);
|
|
27
|
+
private updateUI;
|
|
28
|
+
private updateAria;
|
|
29
|
+
private adjustValue;
|
|
30
|
+
destroy(): void;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MotionOptions } from '../../motion/component-motion.ts';
|
|
2
|
+
|
|
3
|
+
export interface InputOptions {
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
clearable?: boolean;
|
|
9
|
+
showPassword?: boolean;
|
|
10
|
+
validate?: (value: string) => string | null;
|
|
11
|
+
onInput?: (value: string) => void;
|
|
12
|
+
onEnter?: (value: string) => void;
|
|
13
|
+
motion?: MotionOptions;
|
|
14
|
+
}
|
|
15
|
+
export declare class MkInput {
|
|
16
|
+
el: HTMLDivElement;
|
|
17
|
+
input: HTMLInputElement;
|
|
18
|
+
private options;
|
|
19
|
+
private errorMsg;
|
|
20
|
+
private motion;
|
|
21
|
+
constructor(container: HTMLElement | string, options?: InputOptions);
|
|
22
|
+
get value(): string;
|
|
23
|
+
set value(v: string);
|
|
24
|
+
validate(): boolean;
|
|
25
|
+
showError(msg: string): void;
|
|
26
|
+
showSuccess(): void;
|
|
27
|
+
clearError(): void;
|
|
28
|
+
focus(): void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createInput(container: HTMLElement | string, options?: InputOptions): MkInput;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
export interface DividerOptions {
|
|
3
|
+
text?: string;
|
|
4
|
+
direction?: 'horizontal' | 'vertical';
|
|
5
|
+
dashed?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class MkDivider {
|
|
8
|
+
el: HTMLDivElement;
|
|
9
|
+
constructor(container: HTMLElement | string, options?: DividerOptions);
|
|
10
|
+
destroy(): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function createDivider(container: HTMLElement | string, options?: DividerOptions): MkDivider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
export interface RowOptions {
|
|
3
|
+
gutter?: number;
|
|
4
|
+
justify?: 'start' | 'center' | 'end' | 'space-between' | 'space-around';
|
|
5
|
+
align?: 'top' | 'middle' | 'bottom';
|
|
6
|
+
wrap?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class MkRow {
|
|
9
|
+
el: HTMLDivElement;
|
|
10
|
+
constructor(container: HTMLElement | string, options?: RowOptions);
|
|
11
|
+
addCol(span: number | 'flex', content?: string | HTMLElement, className?: string): HTMLDivElement;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createRow(container: HTMLElement | string, options?: RowOptions): MkRow;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
|
|
2
|
+
export interface SpaceOptions {
|
|
3
|
+
direction?: 'horizontal' | 'vertical';
|
|
4
|
+
size?: 'small' | 'default' | 'large';
|
|
5
|
+
wrap?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare class MkSpace {
|
|
8
|
+
el: HTMLDivElement;
|
|
9
|
+
constructor(container: HTMLElement | string, options?: SpaceOptions);
|
|
10
|
+
add(content: string | HTMLElement): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function createSpace(container: HTMLElement | string, options?: SpaceOptions): MkSpace;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
export interface LoadingOptions {
|
|
3
|
+
text?: string;
|
|
4
|
+
fullscreen?: boolean;
|
|
5
|
+
target?: HTMLElement | string;
|
|
6
|
+
}
|
|
7
|
+
export declare function showLoading(options?: LoadingOptions): () => void;
|
|
8
|
+
export declare function showFullscreenLoading(text?: string): () => void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
export interface MenuItem {
|
|
3
|
+
index: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
children?: MenuItem[];
|
|
8
|
+
}
|
|
9
|
+
export interface MenuOptions {
|
|
10
|
+
mode?: 'vertical' | 'horizontal';
|
|
11
|
+
items: MenuItem[];
|
|
12
|
+
defaultActive?: string;
|
|
13
|
+
defaultOpeneds?: string[];
|
|
14
|
+
collapse?: boolean;
|
|
15
|
+
onSelect?: (index: string) => void;
|
|
16
|
+
onOpen?: (index: string) => void;
|
|
17
|
+
onClose?: (index: string) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare class MkMenu {
|
|
20
|
+
el: HTMLElement;
|
|
21
|
+
private options;
|
|
22
|
+
private openeds;
|
|
23
|
+
private activeIndex;
|
|
24
|
+
constructor(container: HTMLElement | string, options: MenuOptions);
|
|
25
|
+
private render;
|
|
26
|
+
private renderItem;
|
|
27
|
+
private setupKeyboard;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function createMenu(container: HTMLElement | string, options: MenuOptions): MkMenu;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
export interface MessageOptions {
|
|
3
|
+
type?: 'success' | 'warning' | 'error' | 'info';
|
|
4
|
+
duration?: number;
|
|
5
|
+
closable?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function message(msg: string, options?: MessageOptions): () => void;
|
|
8
|
+
export declare function messageSuccess(msg: string, options?: Omit<MessageOptions, 'type'>): () => void;
|
|
9
|
+
export declare function messageError(msg: string, options?: Omit<MessageOptions, 'type'>): () => void;
|
|
10
|
+
export declare function messageWarning(msg: string, options?: Omit<MessageOptions, 'type'>): () => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
export interface PopoverOptions {
|
|
3
|
+
content?: string | HTMLElement;
|
|
4
|
+
title?: string;
|
|
5
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
6
|
+
trigger?: 'click' | 'hover';
|
|
7
|
+
width?: number;
|
|
8
|
+
offset?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare class MkPopover {
|
|
11
|
+
el: HTMLDivElement;
|
|
12
|
+
private options;
|
|
13
|
+
private popoverEl;
|
|
14
|
+
private arrowEl;
|
|
15
|
+
private contentEl;
|
|
16
|
+
private showTimer;
|
|
17
|
+
private hideTimer;
|
|
18
|
+
private isVisible;
|
|
19
|
+
private cleanupFns;
|
|
20
|
+
private focusTrap;
|
|
21
|
+
private escapeCleanup;
|
|
22
|
+
constructor(target: HTMLElement, options?: PopoverOptions);
|
|
23
|
+
private buildPopover;
|
|
24
|
+
private position;
|
|
25
|
+
show(): void;
|
|
26
|
+
hide(): void;
|
|
27
|
+
toggle(): void;
|
|
28
|
+
setContent(content: string | HTMLElement): void;
|
|
29
|
+
destroy(): void;
|
|
30
|
+
}
|
|
31
|
+
export declare function createPopover(target: HTMLElement, options?: PopoverOptions): MkPopover;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
export interface ProgressOptions {
|
|
3
|
+
type?: 'line' | 'circle' | 'dashboard';
|
|
4
|
+
percent?: number;
|
|
5
|
+
strokeWidth?: number;
|
|
6
|
+
color?: string;
|
|
7
|
+
status?: 'success' | 'exception' | 'active';
|
|
8
|
+
showInfo?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class MkProgress {
|
|
11
|
+
el: HTMLDivElement;
|
|
12
|
+
private options;
|
|
13
|
+
private barEl;
|
|
14
|
+
private textEl;
|
|
15
|
+
private circleSvg;
|
|
16
|
+
private circleTrack;
|
|
17
|
+
private circlePath;
|
|
18
|
+
constructor(container: HTMLElement | string, options?: ProgressOptions);
|
|
19
|
+
private buildClass;
|
|
20
|
+
private renderLine;
|
|
21
|
+
private renderCircleOrDashboard;
|
|
22
|
+
setPercent(percent: number): void;
|
|
23
|
+
destroy(): void;
|
|
24
|
+
}
|
|
25
|
+
export declare function createProgress(container: HTMLElement | string, options?: ProgressOptions): MkProgress;
|