@composy/keyboard-core 0.0.1
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 +37 -0
- package/dist/index.js +3605 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.js +1 -0
- package/es/icons.d.ts +58 -0
- package/es/icons.d.ts.map +1 -0
- package/es/icons.js +34 -0
- package/es/icons.js.map +1 -0
- package/es/index.d.ts +12 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +36 -0
- package/es/layouts/amount.d.ts +14 -0
- package/es/layouts/amount.d.ts.map +1 -0
- package/es/layouts/amount.js +175 -0
- package/es/layouts/amount.js.map +1 -0
- package/es/layouts/bankcard.d.ts +15 -0
- package/es/layouts/bankcard.d.ts.map +1 -0
- package/es/layouts/bankcard.js +99 -0
- package/es/layouts/bankcard.js.map +1 -0
- package/es/layouts/email.d.ts +11 -0
- package/es/layouts/email.d.ts.map +1 -0
- package/es/layouts/email.js +126 -0
- package/es/layouts/email.js.map +1 -0
- package/es/layouts/idcard.d.ts +16 -0
- package/es/layouts/idcard.d.ts.map +1 -0
- package/es/layouts/idcard.js +99 -0
- package/es/layouts/idcard.js.map +1 -0
- package/es/layouts/index.d.ts +54 -0
- package/es/layouts/index.d.ts.map +1 -0
- package/es/layouts/index.js +78 -0
- package/es/layouts/index.js.map +1 -0
- package/es/layouts/license-plate.d.ts +35 -0
- package/es/layouts/license-plate.d.ts.map +1 -0
- package/es/layouts/license-plate.js +290 -0
- package/es/layouts/license-plate.js.map +1 -0
- package/es/layouts/number.d.ts +14 -0
- package/es/layouts/number.d.ts.map +1 -0
- package/es/layouts/number.js +168 -0
- package/es/layouts/number.js.map +1 -0
- package/es/layouts/phone.d.ts +15 -0
- package/es/layouts/phone.d.ts.map +1 -0
- package/es/layouts/phone.js +175 -0
- package/es/layouts/phone.js.map +1 -0
- package/es/layouts/punct.d.ts +7 -0
- package/es/layouts/punct.d.ts.map +1 -0
- package/es/layouts/punct.js +112 -0
- package/es/layouts/punct.js.map +1 -0
- package/es/layouts/qwerty.d.ts +10 -0
- package/es/layouts/qwerty.d.ts.map +1 -0
- package/es/layouts/qwerty.js +116 -0
- package/es/layouts/qwerty.js.map +1 -0
- package/es/layouts/search.d.ts +7 -0
- package/es/layouts/search.d.ts.map +1 -0
- package/es/layouts/search.js +101 -0
- package/es/layouts/search.js.map +1 -0
- package/es/layouts/symbol.d.ts +14 -0
- package/es/layouts/symbol.d.ts.map +1 -0
- package/es/layouts/symbol.js +194 -0
- package/es/layouts/symbol.js.map +1 -0
- package/es/layouts/url.d.ts +7 -0
- package/es/layouts/url.d.ts.map +1 -0
- package/es/layouts/url.js +99 -0
- package/es/layouts/url.js.map +1 -0
- package/es/layouts/verifycode.d.ts +15 -0
- package/es/layouts/verifycode.d.ts.map +1 -0
- package/es/layouts/verifycode.js +100 -0
- package/es/layouts/verifycode.js.map +1 -0
- package/es/managers/index.d.ts +8 -0
- package/es/managers/index.d.ts.map +1 -0
- package/es/managers/index.js +14 -0
- package/es/managers/keyboard-manager.d.ts +130 -0
- package/es/managers/keyboard-manager.d.ts.map +1 -0
- package/es/managers/keyboard-manager.js +374 -0
- package/es/managers/keyboard-manager.js.map +1 -0
- package/es/managers/keyboard-renderer.d.ts +115 -0
- package/es/managers/keyboard-renderer.d.ts.map +1 -0
- package/es/managers/keyboard-renderer.js +283 -0
- package/es/managers/keyboard-renderer.js.map +1 -0
- package/es/managers/position-manager.d.ts +72 -0
- package/es/managers/position-manager.d.ts.map +1 -0
- package/es/managers/position-manager.js +199 -0
- package/es/managers/position-manager.js.map +1 -0
- package/es/themes/index.d.ts +70 -0
- package/es/themes/index.d.ts.map +1 -0
- package/es/themes/index.js +99 -0
- package/es/themes/index.js.map +1 -0
- package/es/themes/presets.d.ts +39 -0
- package/es/themes/presets.d.ts.map +1 -0
- package/es/themes/presets.js +207 -0
- package/es/themes/presets.js.map +1 -0
- package/es/themes/types.d.ts +118 -0
- package/es/themes/types.d.ts.map +1 -0
- package/es/themes/types.js +10 -0
- package/es/types/index.d.ts +7 -0
- package/es/types/index.d.ts.map +1 -0
- package/es/types/index.js +10 -0
- package/es/types/keyboard.d.ts +253 -0
- package/es/types/keyboard.d.ts.map +1 -0
- package/es/types/keyboard.js +10 -0
- package/es/types/position.d.ts +139 -0
- package/es/types/position.d.ts.map +1 -0
- package/es/types/position.js +10 -0
- package/es/utils/device.d.ts +45 -0
- package/es/utils/device.d.ts.map +1 -0
- package/es/utils/device.js +111 -0
- package/es/utils/device.js.map +1 -0
- package/es/utils/dom.d.ts +69 -0
- package/es/utils/dom.d.ts.map +1 -0
- package/es/utils/dom.js +134 -0
- package/es/utils/dom.js.map +1 -0
- package/es/utils/event-emitter.d.ts +52 -0
- package/es/utils/event-emitter.d.ts.map +1 -0
- package/es/utils/event-emitter.js +99 -0
- package/es/utils/event-emitter.js.map +1 -0
- package/es/utils/formatters.d.ts +51 -0
- package/es/utils/formatters.d.ts.map +1 -0
- package/es/utils/formatters.js +57 -0
- package/es/utils/formatters.js.map +1 -0
- package/es/utils/index.d.ts +10 -0
- package/es/utils/index.d.ts.map +1 -0
- package/es/utils/index.js +16 -0
- package/es/utils/random.d.ts +71 -0
- package/es/utils/random.d.ts.map +1 -0
- package/es/utils/random.js +292 -0
- package/es/utils/random.js.map +1 -0
- package/esm/icons.d.ts +58 -0
- package/esm/icons.d.ts.map +1 -0
- package/esm/icons.js +34 -0
- package/esm/icons.js.map +1 -0
- package/esm/index.d.ts +12 -0
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js +37 -0
- package/esm/layouts/amount.d.ts +14 -0
- package/esm/layouts/amount.d.ts.map +1 -0
- package/esm/layouts/amount.js +175 -0
- package/esm/layouts/amount.js.map +1 -0
- package/esm/layouts/bankcard.d.ts +15 -0
- package/esm/layouts/bankcard.d.ts.map +1 -0
- package/esm/layouts/bankcard.js +99 -0
- package/esm/layouts/bankcard.js.map +1 -0
- package/esm/layouts/email.d.ts +11 -0
- package/esm/layouts/email.d.ts.map +1 -0
- package/esm/layouts/email.js +126 -0
- package/esm/layouts/email.js.map +1 -0
- package/esm/layouts/idcard.d.ts +16 -0
- package/esm/layouts/idcard.d.ts.map +1 -0
- package/esm/layouts/idcard.js +99 -0
- package/esm/layouts/idcard.js.map +1 -0
- package/esm/layouts/index.d.ts +54 -0
- package/esm/layouts/index.d.ts.map +1 -0
- package/esm/layouts/index.js +78 -0
- package/esm/layouts/index.js.map +1 -0
- package/esm/layouts/license-plate.d.ts +35 -0
- package/esm/layouts/license-plate.d.ts.map +1 -0
- package/esm/layouts/license-plate.js +290 -0
- package/esm/layouts/license-plate.js.map +1 -0
- package/esm/layouts/number.d.ts +14 -0
- package/esm/layouts/number.d.ts.map +1 -0
- package/esm/layouts/number.js +168 -0
- package/esm/layouts/number.js.map +1 -0
- package/esm/layouts/phone.d.ts +15 -0
- package/esm/layouts/phone.d.ts.map +1 -0
- package/esm/layouts/phone.js +175 -0
- package/esm/layouts/phone.js.map +1 -0
- package/esm/layouts/punct.d.ts +7 -0
- package/esm/layouts/punct.d.ts.map +1 -0
- package/esm/layouts/punct.js +112 -0
- package/esm/layouts/punct.js.map +1 -0
- package/esm/layouts/qwerty.d.ts +10 -0
- package/esm/layouts/qwerty.d.ts.map +1 -0
- package/esm/layouts/qwerty.js +116 -0
- package/esm/layouts/qwerty.js.map +1 -0
- package/esm/layouts/search.d.ts +7 -0
- package/esm/layouts/search.d.ts.map +1 -0
- package/esm/layouts/search.js +101 -0
- package/esm/layouts/search.js.map +1 -0
- package/esm/layouts/symbol.d.ts +14 -0
- package/esm/layouts/symbol.d.ts.map +1 -0
- package/esm/layouts/symbol.js +194 -0
- package/esm/layouts/symbol.js.map +1 -0
- package/esm/layouts/url.d.ts +7 -0
- package/esm/layouts/url.d.ts.map +1 -0
- package/esm/layouts/url.js +99 -0
- package/esm/layouts/url.js.map +1 -0
- package/esm/layouts/verifycode.d.ts +15 -0
- package/esm/layouts/verifycode.d.ts.map +1 -0
- package/esm/layouts/verifycode.js +100 -0
- package/esm/layouts/verifycode.js.map +1 -0
- package/esm/managers/index.d.ts +8 -0
- package/esm/managers/index.d.ts.map +1 -0
- package/esm/managers/index.js +14 -0
- package/esm/managers/keyboard-manager.d.ts +130 -0
- package/esm/managers/keyboard-manager.d.ts.map +1 -0
- package/esm/managers/keyboard-manager.js +374 -0
- package/esm/managers/keyboard-manager.js.map +1 -0
- package/esm/managers/keyboard-renderer.d.ts +115 -0
- package/esm/managers/keyboard-renderer.d.ts.map +1 -0
- package/esm/managers/keyboard-renderer.js +283 -0
- package/esm/managers/keyboard-renderer.js.map +1 -0
- package/esm/managers/position-manager.d.ts +72 -0
- package/esm/managers/position-manager.d.ts.map +1 -0
- package/esm/managers/position-manager.js +199 -0
- package/esm/managers/position-manager.js.map +1 -0
- package/esm/themes/index.d.ts +70 -0
- package/esm/themes/index.d.ts.map +1 -0
- package/esm/themes/index.js +99 -0
- package/esm/themes/index.js.map +1 -0
- package/esm/themes/presets.d.ts +39 -0
- package/esm/themes/presets.d.ts.map +1 -0
- package/esm/themes/presets.js +207 -0
- package/esm/themes/presets.js.map +1 -0
- package/esm/themes/types.d.ts +118 -0
- package/esm/themes/types.d.ts.map +1 -0
- package/esm/themes/types.js +10 -0
- package/esm/types/index.d.ts +7 -0
- package/esm/types/index.d.ts.map +1 -0
- package/esm/types/index.js +10 -0
- package/esm/types/keyboard.d.ts +253 -0
- package/esm/types/keyboard.d.ts.map +1 -0
- package/esm/types/keyboard.js +10 -0
- package/esm/types/position.d.ts +139 -0
- package/esm/types/position.d.ts.map +1 -0
- package/esm/types/position.js +10 -0
- package/esm/utils/device.d.ts +45 -0
- package/esm/utils/device.d.ts.map +1 -0
- package/esm/utils/device.js +111 -0
- package/esm/utils/device.js.map +1 -0
- package/esm/utils/dom.d.ts +69 -0
- package/esm/utils/dom.d.ts.map +1 -0
- package/esm/utils/dom.js +134 -0
- package/esm/utils/dom.js.map +1 -0
- package/esm/utils/event-emitter.d.ts +52 -0
- package/esm/utils/event-emitter.d.ts.map +1 -0
- package/esm/utils/event-emitter.js +99 -0
- package/esm/utils/event-emitter.js.map +1 -0
- package/esm/utils/formatters.d.ts +51 -0
- package/esm/utils/formatters.d.ts.map +1 -0
- package/esm/utils/formatters.js +57 -0
- package/esm/utils/formatters.js.map +1 -0
- package/esm/utils/index.d.ts +10 -0
- package/esm/utils/index.d.ts.map +1 -0
- package/esm/utils/index.js +16 -0
- package/esm/utils/random.d.ts +71 -0
- package/esm/utils/random.d.ts.map +1 -0
- package/esm/utils/random.js +292 -0
- package/esm/utils/random.js.map +1 -0
- package/lib/icons.cjs +44 -0
- package/lib/icons.cjs.map +1 -0
- package/lib/icons.d.ts +58 -0
- package/lib/index.cjs +141 -0
- package/lib/index.d.ts +12 -0
- package/lib/layouts/amount.cjs +177 -0
- package/lib/layouts/amount.cjs.map +1 -0
- package/lib/layouts/amount.d.ts +14 -0
- package/lib/layouts/bankcard.cjs +100 -0
- package/lib/layouts/bankcard.cjs.map +1 -0
- package/lib/layouts/bankcard.d.ts +15 -0
- package/lib/layouts/email.cjs +128 -0
- package/lib/layouts/email.cjs.map +1 -0
- package/lib/layouts/email.d.ts +11 -0
- package/lib/layouts/idcard.cjs +100 -0
- package/lib/layouts/idcard.cjs.map +1 -0
- package/lib/layouts/idcard.d.ts +16 -0
- package/lib/layouts/index.cjs +107 -0
- package/lib/layouts/index.cjs.map +1 -0
- package/lib/layouts/index.d.ts +54 -0
- package/lib/layouts/license-plate.cjs +296 -0
- package/lib/layouts/license-plate.cjs.map +1 -0
- package/lib/layouts/license-plate.d.ts +35 -0
- package/lib/layouts/number.cjs +170 -0
- package/lib/layouts/number.cjs.map +1 -0
- package/lib/layouts/number.d.ts +14 -0
- package/lib/layouts/phone.cjs +177 -0
- package/lib/layouts/phone.cjs.map +1 -0
- package/lib/layouts/phone.d.ts +15 -0
- package/lib/layouts/punct.cjs +113 -0
- package/lib/layouts/punct.cjs.map +1 -0
- package/lib/layouts/punct.d.ts +7 -0
- package/lib/layouts/qwerty.cjs +117 -0
- package/lib/layouts/qwerty.cjs.map +1 -0
- package/lib/layouts/qwerty.d.ts +10 -0
- package/lib/layouts/search.cjs +102 -0
- package/lib/layouts/search.cjs.map +1 -0
- package/lib/layouts/search.d.ts +7 -0
- package/lib/layouts/symbol.cjs +196 -0
- package/lib/layouts/symbol.cjs.map +1 -0
- package/lib/layouts/symbol.d.ts +14 -0
- package/lib/layouts/url.cjs +100 -0
- package/lib/layouts/url.cjs.map +1 -0
- package/lib/layouts/url.d.ts +7 -0
- package/lib/layouts/verifycode.cjs +101 -0
- package/lib/layouts/verifycode.cjs.map +1 -0
- package/lib/layouts/verifycode.d.ts +15 -0
- package/lib/managers/index.cjs +20 -0
- package/lib/managers/index.d.ts +8 -0
- package/lib/managers/keyboard-manager.cjs +376 -0
- package/lib/managers/keyboard-manager.cjs.map +1 -0
- package/lib/managers/keyboard-manager.d.ts +130 -0
- package/lib/managers/keyboard-renderer.cjs +285 -0
- package/lib/managers/keyboard-renderer.cjs.map +1 -0
- package/lib/managers/keyboard-renderer.d.ts +115 -0
- package/lib/managers/position-manager.cjs +201 -0
- package/lib/managers/position-manager.cjs.map +1 -0
- package/lib/managers/position-manager.d.ts +72 -0
- package/lib/package.json +3 -0
- package/lib/themes/index.cjs +117 -0
- package/lib/themes/index.cjs.map +1 -0
- package/lib/themes/index.d.ts +70 -0
- package/lib/themes/presets.cjs +214 -0
- package/lib/themes/presets.cjs.map +1 -0
- package/lib/themes/presets.d.ts +39 -0
- package/lib/themes/types.cjs +11 -0
- package/lib/themes/types.d.ts +118 -0
- package/lib/types/index.cjs +11 -0
- package/lib/types/index.d.ts +7 -0
- package/lib/types/keyboard.cjs +11 -0
- package/lib/types/keyboard.d.ts +253 -0
- package/lib/types/position.cjs +11 -0
- package/lib/types/position.d.ts +139 -0
- package/lib/utils/device.cjs +120 -0
- package/lib/utils/device.cjs.map +1 -0
- package/lib/utils/device.d.ts +45 -0
- package/lib/utils/dom.cjs +148 -0
- package/lib/utils/dom.cjs.map +1 -0
- package/lib/utils/dom.d.ts +69 -0
- package/lib/utils/event-emitter.cjs +100 -0
- package/lib/utils/event-emitter.cjs.map +1 -0
- package/lib/utils/event-emitter.d.ts +52 -0
- package/lib/utils/formatters.cjs +66 -0
- package/lib/utils/formatters.cjs.map +1 -0
- package/lib/utils/formatters.d.ts +51 -0
- package/lib/utils/index.cjs +58 -0
- package/lib/utils/index.d.ts +10 -0
- package/lib/utils/random.cjs +301 -0
- package/lib/utils/random.cjs.map +1 -0
- package/lib/utils/random.d.ts +71 -0
- package/package.json +121 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/keyboard-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:33:29 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
/*! End of @composy/keyboard-core | Powered by @composy/builder */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/keyboard-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:33:29 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
/*! End of @composy/keyboard-core | Powered by @composy/builder */
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 键盘类型定义
|
|
3
|
+
* @module types/keyboard
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 键盘类型
|
|
7
|
+
*/
|
|
8
|
+
export type KeyboardType = 'qwerty' | 'number' | 'integer' | 'symbol' | 'license-plate' | 'license-plate-province' | 'license-plate-alphanumeric' | 'license-plate-letter' | 'punct' | 'punct-en' | 'idcard' | 'phone' | 'phone-simple' | 'amount' | 'amount-simple' | 'bankcard' | 'verifycode' | 'email' | 'url' | 'search' | 'custom';
|
|
9
|
+
/**
|
|
10
|
+
* 按键类型
|
|
11
|
+
*/
|
|
12
|
+
export type KeyType = 'char' | 'backspace' | 'shift' | 'space' | 'enter' | 'tab' | 'close' | 'clear' | 'done' | 'custom';
|
|
13
|
+
/**
|
|
14
|
+
* 按键定义
|
|
15
|
+
*/
|
|
16
|
+
export interface KeyDefinition {
|
|
17
|
+
/**
|
|
18
|
+
* 按键唯一标识
|
|
19
|
+
*/
|
|
20
|
+
id: string;
|
|
21
|
+
/**
|
|
22
|
+
* 按键类型
|
|
23
|
+
*/
|
|
24
|
+
type: KeyType;
|
|
25
|
+
/**
|
|
26
|
+
* 显示的文本(支持小写/大写状态)
|
|
27
|
+
*/
|
|
28
|
+
label: string | {
|
|
29
|
+
lower: string;
|
|
30
|
+
upper: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 按键输出的值(支持小写/大写状态)
|
|
34
|
+
*/
|
|
35
|
+
value?: string | {
|
|
36
|
+
lower: string;
|
|
37
|
+
upper: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* 按键宽度(相对单位,默认 1)
|
|
41
|
+
*/
|
|
42
|
+
width?: number;
|
|
43
|
+
/**
|
|
44
|
+
* 是否禁用
|
|
45
|
+
*/
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 自定义类名
|
|
49
|
+
*/
|
|
50
|
+
className?: string;
|
|
51
|
+
/**
|
|
52
|
+
* 自定义图标(用于功能键)
|
|
53
|
+
*/
|
|
54
|
+
icon?: string;
|
|
55
|
+
/**
|
|
56
|
+
* 下拉选项(点击按键时弹出选项列表)
|
|
57
|
+
*/
|
|
58
|
+
options?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* 自定义数据
|
|
61
|
+
*/
|
|
62
|
+
data?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 键盘行定义
|
|
66
|
+
*/
|
|
67
|
+
export interface KeyboardRow {
|
|
68
|
+
/**
|
|
69
|
+
* 行内按键列表
|
|
70
|
+
*/
|
|
71
|
+
keys: KeyDefinition[];
|
|
72
|
+
/**
|
|
73
|
+
* 行自定义类名
|
|
74
|
+
*/
|
|
75
|
+
className?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 键盘配置
|
|
79
|
+
*/
|
|
80
|
+
export interface KeyboardConfig {
|
|
81
|
+
/**
|
|
82
|
+
* 键盘类型
|
|
83
|
+
*/
|
|
84
|
+
type: KeyboardType;
|
|
85
|
+
/**
|
|
86
|
+
* 键盘名称
|
|
87
|
+
*/
|
|
88
|
+
name: string;
|
|
89
|
+
/**
|
|
90
|
+
* 键盘布局(行列结构)
|
|
91
|
+
*/
|
|
92
|
+
rows: KeyboardRow[];
|
|
93
|
+
/**
|
|
94
|
+
* 是否支持大小写切换
|
|
95
|
+
*/
|
|
96
|
+
supportShift?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 默认大小写状态
|
|
99
|
+
*/
|
|
100
|
+
defaultUpperCase?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* 是否支持切换到其他键盘
|
|
103
|
+
*/
|
|
104
|
+
switchable?: KeyboardType[];
|
|
105
|
+
/**
|
|
106
|
+
* 自定义数据
|
|
107
|
+
*/
|
|
108
|
+
data?: Record<string, unknown>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* 键盘状态
|
|
112
|
+
*/
|
|
113
|
+
export interface KeyboardState {
|
|
114
|
+
/**
|
|
115
|
+
* 是否可见
|
|
116
|
+
*/
|
|
117
|
+
visible: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* 当前键盘类型
|
|
120
|
+
*/
|
|
121
|
+
type: KeyboardType;
|
|
122
|
+
/**
|
|
123
|
+
* 是否大写状态
|
|
124
|
+
*/
|
|
125
|
+
isUpperCase: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* 当前输入值
|
|
128
|
+
*/
|
|
129
|
+
value: string;
|
|
130
|
+
/**
|
|
131
|
+
* 光标位置
|
|
132
|
+
*/
|
|
133
|
+
cursorPosition: number;
|
|
134
|
+
/**
|
|
135
|
+
* 最大长度限制
|
|
136
|
+
*/
|
|
137
|
+
maxLength?: number;
|
|
138
|
+
/**
|
|
139
|
+
* 当前绑定的输入框元素
|
|
140
|
+
*/
|
|
141
|
+
inputElement?: HTMLInputElement | HTMLTextAreaElement | null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 键盘事件映射
|
|
145
|
+
*/
|
|
146
|
+
export interface KeyboardEventMap {
|
|
147
|
+
[key: string]: unknown;
|
|
148
|
+
/**
|
|
149
|
+
* 按键按下
|
|
150
|
+
*/
|
|
151
|
+
keypress: {
|
|
152
|
+
key: KeyDefinition;
|
|
153
|
+
value: string;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* 输入值变化
|
|
157
|
+
*/
|
|
158
|
+
input: {
|
|
159
|
+
value: string;
|
|
160
|
+
key: KeyDefinition;
|
|
161
|
+
};
|
|
162
|
+
/**
|
|
163
|
+
* 退格
|
|
164
|
+
*/
|
|
165
|
+
backspace: {
|
|
166
|
+
deletedChar: string;
|
|
167
|
+
value: string;
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* 清空
|
|
171
|
+
*/
|
|
172
|
+
clear: {
|
|
173
|
+
previousValue: string;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* 确认/完成
|
|
177
|
+
*/
|
|
178
|
+
confirm: {
|
|
179
|
+
value: string;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* 键盘显示
|
|
183
|
+
*/
|
|
184
|
+
show: {
|
|
185
|
+
type: KeyboardType;
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* 键盘隐藏
|
|
189
|
+
*/
|
|
190
|
+
hide: {
|
|
191
|
+
type: KeyboardType;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* 键盘类型切换
|
|
195
|
+
*/
|
|
196
|
+
switch: {
|
|
197
|
+
from: KeyboardType;
|
|
198
|
+
to: KeyboardType;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* 大小写切换
|
|
202
|
+
*/
|
|
203
|
+
shift: {
|
|
204
|
+
isUpperCase: boolean;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* 状态变化
|
|
208
|
+
*/
|
|
209
|
+
stateChange: KeyboardState;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* 键盘选项
|
|
213
|
+
*/
|
|
214
|
+
export interface KeyboardOptions {
|
|
215
|
+
/**
|
|
216
|
+
* 初始键盘类型
|
|
217
|
+
* @default 'qwerty'
|
|
218
|
+
*/
|
|
219
|
+
type?: KeyboardType;
|
|
220
|
+
/**
|
|
221
|
+
* 初始值
|
|
222
|
+
*/
|
|
223
|
+
value?: string;
|
|
224
|
+
/**
|
|
225
|
+
* 最大输入长度
|
|
226
|
+
*/
|
|
227
|
+
maxLength?: number;
|
|
228
|
+
/**
|
|
229
|
+
* 是否默认大写
|
|
230
|
+
* @default false
|
|
231
|
+
*/
|
|
232
|
+
defaultUpperCase?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* 点击外部是否关闭键盘
|
|
235
|
+
* @default true
|
|
236
|
+
*/
|
|
237
|
+
closeOnClickOutside?: boolean;
|
|
238
|
+
/**
|
|
239
|
+
* 按键声音
|
|
240
|
+
* @default false
|
|
241
|
+
*/
|
|
242
|
+
enableSound?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* 按键震动(移动端)
|
|
245
|
+
* @default true
|
|
246
|
+
*/
|
|
247
|
+
enableVibrate?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* 自定义键盘布局
|
|
250
|
+
*/
|
|
251
|
+
customLayouts?: Record<string, KeyboardConfig>;
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=keyboard.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/keyboard-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:33:29 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
/*! End of @composy/keyboard-core | Powered by @composy/builder */
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 弹出位置类型定义
|
|
3
|
+
* @module types/position
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 设备类型
|
|
7
|
+
*/
|
|
8
|
+
export type DeviceType = 'mobile' | 'desktop';
|
|
9
|
+
/**
|
|
10
|
+
* 弹出位置
|
|
11
|
+
*/
|
|
12
|
+
export type PopupPlacement = 'bottom' | 'top' | 'bottom-sheet';
|
|
13
|
+
/**
|
|
14
|
+
* 位置坐标
|
|
15
|
+
*/
|
|
16
|
+
export interface Position {
|
|
17
|
+
x: number;
|
|
18
|
+
y: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 尺寸
|
|
22
|
+
*/
|
|
23
|
+
export interface Size {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 边界矩形
|
|
29
|
+
*/
|
|
30
|
+
export interface BoundingRect extends Position, Size {
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 弹出层位置配置
|
|
34
|
+
*/
|
|
35
|
+
export interface PopupPositionConfig {
|
|
36
|
+
/**
|
|
37
|
+
* 偏移量
|
|
38
|
+
*/
|
|
39
|
+
offset?: {
|
|
40
|
+
x?: number;
|
|
41
|
+
y?: number;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* 是否自动调整位置以适应视口
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
autoAdjust?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* 与视口边缘的最小距离
|
|
50
|
+
* @default 8
|
|
51
|
+
*/
|
|
52
|
+
viewportPadding?: number;
|
|
53
|
+
/**
|
|
54
|
+
* PC 端弹出位置
|
|
55
|
+
* @default 'bottom'
|
|
56
|
+
*/
|
|
57
|
+
desktopPlacement?: Exclude<PopupPlacement, 'bottom-sheet'>;
|
|
58
|
+
/**
|
|
59
|
+
* 移动端弹出位置
|
|
60
|
+
* @default 'bottom-sheet'
|
|
61
|
+
*/
|
|
62
|
+
mobilePlacement?: PopupPlacement;
|
|
63
|
+
/**
|
|
64
|
+
* 是否显示遮罩层(移动端)
|
|
65
|
+
* @default true
|
|
66
|
+
*/
|
|
67
|
+
showMask?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* 遮罩层点击关闭
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
maskClosable?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* 动画时长(毫秒)
|
|
75
|
+
* @default 300
|
|
76
|
+
*/
|
|
77
|
+
animationDuration?: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* 弹出层计算结果
|
|
81
|
+
*/
|
|
82
|
+
export interface PopupPositionResult {
|
|
83
|
+
/**
|
|
84
|
+
* 计算后的位置
|
|
85
|
+
*/
|
|
86
|
+
position: Position;
|
|
87
|
+
/**
|
|
88
|
+
* 实际使用的弹出位置
|
|
89
|
+
*/
|
|
90
|
+
placement: PopupPlacement;
|
|
91
|
+
/**
|
|
92
|
+
* 是否需要翻转位置
|
|
93
|
+
*/
|
|
94
|
+
flipped: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* 最大可用高度
|
|
97
|
+
*/
|
|
98
|
+
maxHeight?: number;
|
|
99
|
+
/**
|
|
100
|
+
* 最大可用宽度
|
|
101
|
+
*/
|
|
102
|
+
maxWidth?: number;
|
|
103
|
+
/**
|
|
104
|
+
* CSS transform 样式
|
|
105
|
+
*/
|
|
106
|
+
transform?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 视口信息
|
|
110
|
+
*/
|
|
111
|
+
export interface ViewportInfo {
|
|
112
|
+
/**
|
|
113
|
+
* 视口宽度
|
|
114
|
+
*/
|
|
115
|
+
width: number;
|
|
116
|
+
/**
|
|
117
|
+
* 视口高度
|
|
118
|
+
*/
|
|
119
|
+
height: number;
|
|
120
|
+
/**
|
|
121
|
+
* 滚动位置
|
|
122
|
+
*/
|
|
123
|
+
scrollX: number;
|
|
124
|
+
scrollY: number;
|
|
125
|
+
/**
|
|
126
|
+
* 是否为移动设备
|
|
127
|
+
*/
|
|
128
|
+
isMobile: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* 安全区域(针对刘海屏等)
|
|
131
|
+
*/
|
|
132
|
+
safeArea?: {
|
|
133
|
+
top: number;
|
|
134
|
+
right: number;
|
|
135
|
+
bottom: number;
|
|
136
|
+
left: number;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ***********************************
|
|
3
|
+
* @composy/keyboard-core v0.0.1 *
|
|
4
|
+
* Built with rollup *
|
|
5
|
+
* Build time: 2024-08-17 11:33:29 *
|
|
6
|
+
* Build mode: production *
|
|
7
|
+
* Minified: No *
|
|
8
|
+
* ***********************************
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
//#region src/utils/device.ts
|
|
12
|
+
const MOBILE_UA_REGEX = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
|
|
13
|
+
let cachedIsTouchDevice = null;
|
|
14
|
+
function isTouchDevice() {
|
|
15
|
+
if (cachedIsTouchDevice !== null) return cachedIsTouchDevice;
|
|
16
|
+
if (typeof window === "undefined") {
|
|
17
|
+
cachedIsTouchDevice = false;
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
cachedIsTouchDevice = "ontouchstart" in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
|
|
21
|
+
return cachedIsTouchDevice;
|
|
22
|
+
}
|
|
23
|
+
function isMobileUA() {
|
|
24
|
+
if (typeof navigator === "undefined") return false;
|
|
25
|
+
return MOBILE_UA_REGEX.test(navigator.userAgent);
|
|
26
|
+
}
|
|
27
|
+
function isMobile() {
|
|
28
|
+
if (typeof window === "undefined") return false;
|
|
29
|
+
if (isMobileUA()) return true;
|
|
30
|
+
if ((window.innerWidth || document.documentElement.clientWidth) <= 768) return true;
|
|
31
|
+
return isTouchDevice();
|
|
32
|
+
}
|
|
33
|
+
function getDeviceType() {
|
|
34
|
+
return isMobile() ? "mobile" : "desktop";
|
|
35
|
+
}
|
|
36
|
+
function getViewportInfo() {
|
|
37
|
+
if (typeof window === "undefined") return {
|
|
38
|
+
width: 0,
|
|
39
|
+
height: 0,
|
|
40
|
+
scrollX: 0,
|
|
41
|
+
scrollY: 0,
|
|
42
|
+
isMobile: false
|
|
43
|
+
};
|
|
44
|
+
const width = window.innerWidth || document.documentElement.clientWidth;
|
|
45
|
+
const height = window.innerHeight || document.documentElement.clientHeight;
|
|
46
|
+
const safeArea = getSafeAreaInsets();
|
|
47
|
+
return {
|
|
48
|
+
width,
|
|
49
|
+
height,
|
|
50
|
+
scrollX: window.scrollX || window.pageXOffset,
|
|
51
|
+
scrollY: window.scrollY || window.pageYOffset,
|
|
52
|
+
isMobile: isMobile(),
|
|
53
|
+
safeArea
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function getSafeAreaInsets() {
|
|
57
|
+
if (typeof window === "undefined" || typeof CSS === "undefined" || !CSS.supports) return {
|
|
58
|
+
top: 0,
|
|
59
|
+
right: 0,
|
|
60
|
+
bottom: 0,
|
|
61
|
+
left: 0
|
|
62
|
+
};
|
|
63
|
+
if (!CSS.supports("padding-top", "env(safe-area-inset-top)")) return {
|
|
64
|
+
top: 0,
|
|
65
|
+
right: 0,
|
|
66
|
+
bottom: 0,
|
|
67
|
+
left: 0
|
|
68
|
+
};
|
|
69
|
+
const div = document.createElement("div");
|
|
70
|
+
div.style.cssText = `
|
|
71
|
+
position: fixed;
|
|
72
|
+
top: env(safe-area-inset-top);
|
|
73
|
+
right: env(safe-area-inset-right);
|
|
74
|
+
bottom: env(safe-area-inset-bottom);
|
|
75
|
+
left: env(safe-area-inset-left);
|
|
76
|
+
pointer-events: none;
|
|
77
|
+
visibility: hidden;
|
|
78
|
+
`;
|
|
79
|
+
document.body.appendChild(div);
|
|
80
|
+
const computed = getComputedStyle(div);
|
|
81
|
+
const safeArea = {
|
|
82
|
+
top: Number.parseFloat(computed.top) || 0,
|
|
83
|
+
right: Number.parseFloat(computed.right) || 0,
|
|
84
|
+
bottom: Number.parseFloat(computed.bottom) || 0,
|
|
85
|
+
left: Number.parseFloat(computed.left) || 0
|
|
86
|
+
};
|
|
87
|
+
document.body.removeChild(div);
|
|
88
|
+
return safeArea;
|
|
89
|
+
}
|
|
90
|
+
function supportsVibrate() {
|
|
91
|
+
return typeof navigator !== "undefined" && "vibrate" in navigator;
|
|
92
|
+
}
|
|
93
|
+
function vibrate(pattern = 10) {
|
|
94
|
+
if (supportsVibrate()) return navigator.vibrate(pattern);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
function onViewportChange(callback) {
|
|
98
|
+
if (typeof window === "undefined") return () => {};
|
|
99
|
+
const handler = () => {
|
|
100
|
+
callback(getViewportInfo());
|
|
101
|
+
};
|
|
102
|
+
window.addEventListener("resize", handler);
|
|
103
|
+
window.addEventListener("orientationchange", handler);
|
|
104
|
+
return () => {
|
|
105
|
+
window.removeEventListener("resize", handler);
|
|
106
|
+
window.removeEventListener("orientationchange", handler);
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
exports.getDeviceType = getDeviceType;
|
|
111
|
+
exports.getSafeAreaInsets = getSafeAreaInsets;
|
|
112
|
+
exports.getViewportInfo = getViewportInfo;
|
|
113
|
+
exports.isMobile = isMobile;
|
|
114
|
+
exports.isMobileUA = isMobileUA;
|
|
115
|
+
exports.isTouchDevice = isTouchDevice;
|
|
116
|
+
exports.onViewportChange = onViewportChange;
|
|
117
|
+
exports.supportsVibrate = supportsVibrate;
|
|
118
|
+
exports.vibrate = vibrate;
|
|
119
|
+
/*! End of @composy/keyboard-core | Powered by @composy/builder */
|
|
120
|
+
//# sourceMappingURL=device.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"device.cjs","names":[],"sources":["../../src/utils/device.ts"],"sourcesContent":["/**\n * 设备检测工具\n * @module utils/device\n */\n\nimport type { DeviceType, ViewportInfo } from '../types'\n\n/**\n * 移动设备 UA 正则\n */\nconst MOBILE_UA_REGEX = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i\n\n/**\n * 触摸设备检测缓存\n */\nlet cachedIsTouchDevice: boolean | null = null\n\n/**\n * 检测是否为触摸设备\n */\nexport function isTouchDevice(): boolean {\n if (cachedIsTouchDevice !== null) {\n return cachedIsTouchDevice\n }\n\n if (typeof window === 'undefined') {\n cachedIsTouchDevice = false\n return false\n }\n\n cachedIsTouchDevice = (\n 'ontouchstart' in window\n || navigator.maxTouchPoints > 0\n // @ts-expect-error - msMaxTouchPoints is IE specific\n || navigator.msMaxTouchPoints > 0\n )\n\n return cachedIsTouchDevice\n}\n\n/**\n * 检测是否为移动设备(基于 UA)\n */\nexport function isMobileUA(): boolean {\n if (typeof navigator === 'undefined') {\n return false\n }\n return MOBILE_UA_REGEX.test(navigator.userAgent)\n}\n\n/**\n * 检测是否为移动设备(综合判断)\n */\nexport function isMobile(): boolean {\n if (typeof window === 'undefined') {\n return false\n }\n\n // 优先使用 UA 判断\n if (isMobileUA()) {\n return true\n }\n\n // 其次使用屏幕宽度判断\n const screenWidth = window.innerWidth || document.documentElement.clientWidth\n if (screenWidth <= 768) {\n return true\n }\n\n // 最后使用触摸检测\n return isTouchDevice()\n}\n\n/**\n * 获取设备类型\n */\nexport function getDeviceType(): DeviceType {\n return isMobile() ? 'mobile' : 'desktop'\n}\n\n/**\n * 获取视口信息\n */\nexport function getViewportInfo(): ViewportInfo {\n if (typeof window === 'undefined') {\n return {\n width: 0,\n height: 0,\n scrollX: 0,\n scrollY: 0,\n isMobile: false,\n }\n }\n\n const width = window.innerWidth || document.documentElement.clientWidth\n const height = window.innerHeight || document.documentElement.clientHeight\n\n // 获取安全区域(iOS 刘海屏等)\n const safeArea = getSafeAreaInsets()\n\n return {\n width,\n height,\n scrollX: window.scrollX || window.pageXOffset,\n scrollY: window.scrollY || window.pageYOffset,\n isMobile: isMobile(),\n safeArea,\n }\n}\n\n/**\n * 获取安全区域边距\n */\nexport function getSafeAreaInsets(): ViewportInfo['safeArea'] {\n if (typeof window === 'undefined' || typeof CSS === 'undefined' || !CSS.supports) {\n return { top: 0, right: 0, bottom: 0, left: 0 }\n }\n\n // 检查是否支持 env() 函数\n if (!CSS.supports('padding-top', 'env(safe-area-inset-top)')) {\n return { top: 0, right: 0, bottom: 0, left: 0 }\n }\n\n // 创建临时元素获取安全区域值\n const div = document.createElement('div')\n div.style.cssText = `\n position: fixed;\n top: env(safe-area-inset-top);\n right: env(safe-area-inset-right);\n bottom: env(safe-area-inset-bottom);\n left: env(safe-area-inset-left);\n pointer-events: none;\n visibility: hidden;\n `\n document.body.appendChild(div)\n\n const computed = getComputedStyle(div)\n const safeArea = {\n top: Number.parseFloat(computed.top) || 0,\n right: Number.parseFloat(computed.right) || 0,\n bottom: Number.parseFloat(computed.bottom) || 0,\n left: Number.parseFloat(computed.left) || 0,\n }\n\n document.body.removeChild(div)\n return safeArea\n}\n\n/**\n * 检测是否支持震动 API\n */\nexport function supportsVibrate(): boolean {\n return typeof navigator !== 'undefined' && 'vibrate' in navigator\n}\n\n/**\n * 触发震动反馈\n * @param pattern - 震动模式(毫秒)\n */\nexport function vibrate(pattern: number | number[] = 10): boolean {\n if (supportsVibrate()) {\n return navigator.vibrate(pattern)\n }\n return false\n}\n\n/**\n * 监听视口变化\n * @param callback - 回调函数\n * @returns 取消监听函数\n */\nexport function onViewportChange(callback: (info: ViewportInfo) => void): () => void {\n if (typeof window === 'undefined') {\n return () => {}\n }\n\n const handler = () => {\n callback(getViewportInfo())\n }\n\n window.addEventListener('resize', handler)\n window.addEventListener('orientationchange', handler)\n\n return () => {\n window.removeEventListener('resize', handler)\n window.removeEventListener('orientationchange', handler)\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,MAAM,kBAAkB;AAKxB,IAAI,sBAAsC;AAKnC,SAAS,gBAAyB;CACvC,IAAI,wBAAwB,MAC1B,OAAO;CAGT,IAAI,OAAO,WAAW,aAAa;EACjC,sBAAsB;EACtB,OAAO;CACT;CAEA,sBACE,kBAAkB,UACf,UAAU,iBAAiB,KAE3B,UAAU,mBAAmB;CAGlC,OAAO;AACT;AAKO,SAAS,aAAsB;CACpC,IAAI,OAAO,cAAc,aACvB,OAAO;CAET,OAAO,gBAAgB,KAAK,UAAU,SAAS;AACjD;AAKO,SAAS,WAAoB;CAClC,IAAI,OAAO,WAAW,aACpB,OAAO;CAIT,IAAI,WAAW,GACb,OAAO;CAKT,KADoB,OAAO,cAAc,SAAS,gBAAgB,gBAC/C,KACjB,OAAO;CAIT,OAAO,cAAc;AACvB;AAKO,SAAS,gBAA4B;CAC1C,OAAO,SAAS,IAAI,WAAW;AACjC;AAKO,SAAS,kBAAgC;CAC9C,IAAI,OAAO,WAAW,aACpB,OAAO;EACL,OAAO;EACP,QAAQ;EACR,SAAS;EACT,SAAS;EACT,UAAU;CACZ;CAGF,MAAM,QAAQ,OAAO,cAAc,SAAS,gBAAgB;CAC5D,MAAM,SAAS,OAAO,eAAe,SAAS,gBAAgB;CAG9D,MAAM,WAAW,kBAAkB;CAEnC,OAAO;EACL;EACA;EACA,SAAS,OAAO,WAAW,OAAO;EAClC,SAAS,OAAO,WAAW,OAAO;EAClC,UAAU,SAAS;EACnB;CACF;AACF;AAKO,SAAS,oBAA8C;CAC5D,IAAI,OAAO,WAAW,eAAe,OAAO,QAAQ,eAAe,CAAC,IAAI,UACtE,OAAO;EAAE,KAAK;EAAG,OAAO;EAAG,QAAQ;EAAG,MAAM;CAAE;CAIhD,IAAI,CAAC,IAAI,SAAS,eAAe,0BAA0B,GACzD,OAAO;EAAE,KAAK;EAAG,OAAO;EAAG,QAAQ;EAAG,MAAM;CAAE;CAIhD,MAAM,MAAM,SAAS,cAAc,KAAK;CACxC,IAAI,MAAM,UAAU;;;;;;;;;CASpB,SAAS,KAAK,YAAY,GAAG;CAE7B,MAAM,WAAW,iBAAiB,GAAG;CACrC,MAAM,WAAW;EACf,KAAK,OAAO,WAAW,SAAS,GAAG,KAAK;EACxC,OAAO,OAAO,WAAW,SAAS,KAAK,KAAK;EAC5C,QAAQ,OAAO,WAAW,SAAS,MAAM,KAAK;EAC9C,MAAM,OAAO,WAAW,SAAS,IAAI,KAAK;CAC5C;CAEA,SAAS,KAAK,YAAY,GAAG;CAC7B,OAAO;AACT;AAKO,SAAS,kBAA2B;CACzC,OAAO,OAAO,cAAc,eAAe,aAAa;AAC1D;AAMO,SAAS,QAAQ,UAA6B,IAAa;CAChE,IAAI,gBAAgB,GAClB,OAAO,UAAU,QAAQ,OAAO;CAElC,OAAO;AACT;AAOO,SAAS,iBAAiB,UAAoD;CACnF,IAAI,OAAO,WAAW,aACpB,aAAa,CAAC;CAGhB,MAAM,gBAAgB;EACpB,SAAS,gBAAgB,CAAC;CAC5B;CAEA,OAAO,iBAAiB,UAAU,OAAO;CACzC,OAAO,iBAAiB,qBAAqB,OAAO;CAEpD,aAAa;EACX,OAAO,oBAAoB,UAAU,OAAO;EAC5C,OAAO,oBAAoB,qBAAqB,OAAO;CACzD;AACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 设备检测工具
|
|
3
|
+
* @module utils/device
|
|
4
|
+
*/
|
|
5
|
+
import type { DeviceType, ViewportInfo } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* 检测是否为触摸设备
|
|
8
|
+
*/
|
|
9
|
+
export declare function isTouchDevice(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* 检测是否为移动设备(基于 UA)
|
|
12
|
+
*/
|
|
13
|
+
export declare function isMobileUA(): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* 检测是否为移动设备(综合判断)
|
|
16
|
+
*/
|
|
17
|
+
export declare function isMobile(): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* 获取设备类型
|
|
20
|
+
*/
|
|
21
|
+
export declare function getDeviceType(): DeviceType;
|
|
22
|
+
/**
|
|
23
|
+
* 获取视口信息
|
|
24
|
+
*/
|
|
25
|
+
export declare function getViewportInfo(): ViewportInfo;
|
|
26
|
+
/**
|
|
27
|
+
* 获取安全区域边距
|
|
28
|
+
*/
|
|
29
|
+
export declare function getSafeAreaInsets(): ViewportInfo['safeArea'];
|
|
30
|
+
/**
|
|
31
|
+
* 检测是否支持震动 API
|
|
32
|
+
*/
|
|
33
|
+
export declare function supportsVibrate(): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* 触发震动反馈
|
|
36
|
+
* @param pattern - 震动模式(毫秒)
|
|
37
|
+
*/
|
|
38
|
+
export declare function vibrate(pattern?: number | number[]): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 监听视口变化
|
|
41
|
+
* @param callback - 回调函数
|
|
42
|
+
* @returns 取消监听函数
|
|
43
|
+
*/
|
|
44
|
+
export declare function onViewportChange(callback: (info: ViewportInfo) => void): () => void;
|
|
45
|
+
//# sourceMappingURL=device.d.ts.map
|