@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,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 弹出位置管理器
|
|
3
|
+
* @module managers/position-manager
|
|
4
|
+
*/
|
|
5
|
+
import type { PopupPlacement, PopupPositionConfig, PopupPositionResult } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* 位置管理器类
|
|
8
|
+
* 计算键盘弹出层的位置,支持 PC 和移动端自适应
|
|
9
|
+
*/
|
|
10
|
+
export declare class PositionManager {
|
|
11
|
+
private config;
|
|
12
|
+
constructor(config?: PopupPositionConfig);
|
|
13
|
+
/**
|
|
14
|
+
* 更新配置
|
|
15
|
+
*/
|
|
16
|
+
updateConfig(config: Partial<PopupPositionConfig>): void;
|
|
17
|
+
/**
|
|
18
|
+
* 获取配置
|
|
19
|
+
*/
|
|
20
|
+
getConfig(): Readonly<Required<PopupPositionConfig>>;
|
|
21
|
+
/**
|
|
22
|
+
* 计算弹出位置
|
|
23
|
+
* @param targetElement - 目标元素(如 input)
|
|
24
|
+
* @param popupSize - 弹出层尺寸
|
|
25
|
+
* @returns 位置计算结果
|
|
26
|
+
*/
|
|
27
|
+
calculate(targetElement: HTMLElement | null, popupSize: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}): PopupPositionResult;
|
|
31
|
+
/**
|
|
32
|
+
* 计算 bottom-sheet 位置(移动端从底部滑出)
|
|
33
|
+
*/
|
|
34
|
+
private calculateBottomSheet;
|
|
35
|
+
/**
|
|
36
|
+
* 计算居中位置
|
|
37
|
+
*/
|
|
38
|
+
private calculateCentered;
|
|
39
|
+
/**
|
|
40
|
+
* 计算相对于目标元素的位置
|
|
41
|
+
*/
|
|
42
|
+
private calculateRelativeToTarget;
|
|
43
|
+
/**
|
|
44
|
+
* 获取弹出层初始样式(用于动画)
|
|
45
|
+
*/
|
|
46
|
+
getInitialStyles(placement: PopupPlacement): Partial<CSSStyleDeclaration>;
|
|
47
|
+
/**
|
|
48
|
+
* 获取弹出层最终样式(动画结束)
|
|
49
|
+
*/
|
|
50
|
+
getFinalStyles(placement: PopupPlacement): Partial<CSSStyleDeclaration>;
|
|
51
|
+
/**
|
|
52
|
+
* 获取弹出层退出样式
|
|
53
|
+
*/
|
|
54
|
+
getExitStyles(placement: PopupPlacement): Partial<CSSStyleDeclaration>;
|
|
55
|
+
/**
|
|
56
|
+
* 获取动画时长
|
|
57
|
+
*/
|
|
58
|
+
getAnimationDuration(): number;
|
|
59
|
+
/**
|
|
60
|
+
* 检查是否显示遮罩
|
|
61
|
+
*/
|
|
62
|
+
shouldShowMask(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 检查遮罩是否可点击关闭
|
|
65
|
+
*/
|
|
66
|
+
isMaskClosable(): boolean;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 创建位置管理器实例
|
|
70
|
+
*/
|
|
71
|
+
export declare function createPositionManager(config?: PopupPositionConfig): PositionManager;
|
|
72
|
+
//# sourceMappingURL=position-manager.d.ts.map
|
package/lib/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
const require_presets = require("./presets.cjs");
|
|
12
|
+
//#region src/themes/index.ts
|
|
13
|
+
const customThemes = /* @__PURE__ */ new Map();
|
|
14
|
+
let currentTheme = require_presets.defaultTheme;
|
|
15
|
+
function getTheme(name) {
|
|
16
|
+
return customThemes.get(name) || require_presets.presetThemes[name] || require_presets.defaultTheme;
|
|
17
|
+
}
|
|
18
|
+
function registerTheme(theme) {
|
|
19
|
+
customThemes.set(theme.name, theme);
|
|
20
|
+
}
|
|
21
|
+
function getAvailableThemes() {
|
|
22
|
+
return [...Object.keys(require_presets.presetThemes), ...customThemes.keys()];
|
|
23
|
+
}
|
|
24
|
+
function getAllThemes() {
|
|
25
|
+
return [...Object.values(require_presets.presetThemes), ...customThemes.values()];
|
|
26
|
+
}
|
|
27
|
+
function setCurrentTheme(name) {
|
|
28
|
+
currentTheme = getTheme(name);
|
|
29
|
+
return currentTheme;
|
|
30
|
+
}
|
|
31
|
+
function getCurrentTheme() {
|
|
32
|
+
return currentTheme;
|
|
33
|
+
}
|
|
34
|
+
function themeToCSS(theme) {
|
|
35
|
+
return {
|
|
36
|
+
"--keyboard-bg": theme.colors.background,
|
|
37
|
+
"--keyboard-key-bg": theme.colors.keyBackground,
|
|
38
|
+
"--keyboard-key-color": theme.colors.keyColor,
|
|
39
|
+
"--keyboard-key-active-bg": theme.colors.keyActiveBackground,
|
|
40
|
+
"--keyboard-fn-key-bg": theme.colors.fnKeyBackground,
|
|
41
|
+
"--keyboard-fn-key-color": theme.colors.fnKeyColor,
|
|
42
|
+
"--keyboard-fn-key-active-bg": theme.colors.fnKeyActiveBackground,
|
|
43
|
+
"--keyboard-primary-bg": theme.colors.primaryBackground,
|
|
44
|
+
"--keyboard-primary-active-bg": theme.colors.primaryActiveBackground,
|
|
45
|
+
"--keyboard-primary-color": theme.colors.primaryColor,
|
|
46
|
+
"--keyboard-key-height": `${theme.sizes.keyHeight}px`,
|
|
47
|
+
"--keyboard-key-radius": `${theme.sizes.keyRadius}px`,
|
|
48
|
+
"--keyboard-key-gap": `${theme.sizes.keyGap}px`,
|
|
49
|
+
"--keyboard-font-size": `${theme.sizes.fontSize}px`,
|
|
50
|
+
"--keyboard-fn-font-size": `${theme.sizes.fnFontSize}px`,
|
|
51
|
+
"--keyboard-padding": `${theme.sizes.padding}px`,
|
|
52
|
+
"--keyboard-key-shadow": theme.effects.keyShadow,
|
|
53
|
+
"--keyboard-transition-duration": `${theme.effects.transitionDuration}ms`,
|
|
54
|
+
"--keyboard-border-color": theme.colors.borderColor,
|
|
55
|
+
"--keyboard-divider-color": theme.colors.dividerColor
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function applyTheme(element, theme) {
|
|
59
|
+
const cssVars = themeToCSS(theme);
|
|
60
|
+
Object.entries(cssVars).forEach(([key, value]) => {
|
|
61
|
+
if (value) element.style.setProperty(key, value);
|
|
62
|
+
});
|
|
63
|
+
element.classList.remove("keyboard-theme-light", "keyboard-theme-dark");
|
|
64
|
+
element.classList.add(theme.isDark ? "keyboard-theme-dark" : "keyboard-theme-light");
|
|
65
|
+
element.dataset.theme = theme.name;
|
|
66
|
+
}
|
|
67
|
+
function generateThemeStyle(theme) {
|
|
68
|
+
const cssVars = themeToCSS(theme);
|
|
69
|
+
return Object.entries(cssVars).filter(([, value]) => value).map(([key, value]) => `${key}: ${value}`).join("; ");
|
|
70
|
+
}
|
|
71
|
+
function mergeTheme(base, overrides) {
|
|
72
|
+
return {
|
|
73
|
+
...base,
|
|
74
|
+
...overrides,
|
|
75
|
+
colors: {
|
|
76
|
+
...base.colors,
|
|
77
|
+
...overrides.colors
|
|
78
|
+
},
|
|
79
|
+
sizes: {
|
|
80
|
+
...base.sizes,
|
|
81
|
+
...overrides.sizes
|
|
82
|
+
},
|
|
83
|
+
effects: {
|
|
84
|
+
...base.effects,
|
|
85
|
+
...overrides.effects
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function createTheme(name, baseTheme, customization) {
|
|
90
|
+
const theme = mergeTheme(getTheme(baseTheme), {
|
|
91
|
+
...customization,
|
|
92
|
+
name
|
|
93
|
+
});
|
|
94
|
+
registerTheme(theme);
|
|
95
|
+
return theme;
|
|
96
|
+
}
|
|
97
|
+
//#endregion
|
|
98
|
+
exports.applyTheme = applyTheme;
|
|
99
|
+
exports.createTheme = createTheme;
|
|
100
|
+
exports.darkTheme = require_presets.darkTheme;
|
|
101
|
+
exports.defaultTheme = require_presets.defaultTheme;
|
|
102
|
+
exports.generateThemeStyle = generateThemeStyle;
|
|
103
|
+
exports.getAllThemes = getAllThemes;
|
|
104
|
+
exports.getAvailableThemes = getAvailableThemes;
|
|
105
|
+
exports.getCurrentTheme = getCurrentTheme;
|
|
106
|
+
exports.getTheme = getTheme;
|
|
107
|
+
exports.iosTheme = require_presets.iosTheme;
|
|
108
|
+
exports.materialTheme = require_presets.materialTheme;
|
|
109
|
+
exports.mergeTheme = mergeTheme;
|
|
110
|
+
exports.minimalTheme = require_presets.minimalTheme;
|
|
111
|
+
exports.miuiTheme = require_presets.miuiTheme;
|
|
112
|
+
exports.presetThemes = require_presets.presetThemes;
|
|
113
|
+
exports.registerTheme = registerTheme;
|
|
114
|
+
exports.setCurrentTheme = setCurrentTheme;
|
|
115
|
+
exports.themeToCSS = themeToCSS;
|
|
116
|
+
/*! End of @composy/keyboard-core | Powered by @composy/builder */
|
|
117
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/themes/index.ts"],"sourcesContent":["/**\n * 主题管理模块\n * @module themes\n */\n\nimport type { ThemeConfig, ThemeCSSVariables, ThemeName } from './types'\nimport { defaultTheme, presetThemes } from './presets'\n\nexport * from './types'\nexport * from './presets'\n\n/**\n * 自定义主题存储\n */\nconst customThemes: Map<string, ThemeConfig> = new Map()\n\n/**\n * 当前激活的主题\n */\nlet currentTheme: ThemeConfig = defaultTheme\n\n/**\n * 获取主题配置\n * @param name - 主题名称\n * @returns 主题配置,如果不存在则返回默认主题\n */\nexport function getTheme(name: ThemeName | string): ThemeConfig {\n return customThemes.get(name) || presetThemes[name] || defaultTheme\n}\n\n/**\n * 注册自定义主题\n * @param theme - 主题配置\n */\nexport function registerTheme(theme: ThemeConfig): void {\n customThemes.set(theme.name, theme)\n}\n\n/**\n * 获取所有可用主题\n * @returns 主题名称列表\n */\nexport function getAvailableThemes(): string[] {\n return [...Object.keys(presetThemes), ...customThemes.keys()]\n}\n\n/**\n * 获取所有主题配置\n * @returns 主题配置列表\n */\nexport function getAllThemes(): ThemeConfig[] {\n return [\n ...Object.values(presetThemes),\n ...customThemes.values(),\n ]\n}\n\n/**\n * 设置当前主题\n * @param name - 主题名称\n */\nexport function setCurrentTheme(name: ThemeName | string): ThemeConfig {\n currentTheme = getTheme(name)\n return currentTheme\n}\n\n/**\n * 获取当前主题\n */\nexport function getCurrentTheme(): ThemeConfig {\n return currentTheme\n}\n\n/**\n * 将主题配置转换为 CSS 变量\n * @param theme - 主题配置\n * @returns CSS 变量对象\n */\nexport function themeToCSS(theme: ThemeConfig): ThemeCSSVariables {\n return {\n '--keyboard-bg': theme.colors.background,\n '--keyboard-key-bg': theme.colors.keyBackground,\n '--keyboard-key-color': theme.colors.keyColor,\n '--keyboard-key-active-bg': theme.colors.keyActiveBackground,\n '--keyboard-fn-key-bg': theme.colors.fnKeyBackground,\n '--keyboard-fn-key-color': theme.colors.fnKeyColor,\n '--keyboard-fn-key-active-bg': theme.colors.fnKeyActiveBackground,\n '--keyboard-primary-bg': theme.colors.primaryBackground,\n '--keyboard-primary-active-bg': theme.colors.primaryActiveBackground,\n '--keyboard-primary-color': theme.colors.primaryColor,\n '--keyboard-key-height': `${theme.sizes.keyHeight}px`,\n '--keyboard-key-radius': `${theme.sizes.keyRadius}px`,\n '--keyboard-key-gap': `${theme.sizes.keyGap}px`,\n '--keyboard-font-size': `${theme.sizes.fontSize}px`,\n '--keyboard-fn-font-size': `${theme.sizes.fnFontSize}px`,\n '--keyboard-padding': `${theme.sizes.padding}px`,\n '--keyboard-key-shadow': theme.effects.keyShadow,\n '--keyboard-transition-duration': `${theme.effects.transitionDuration}ms`,\n '--keyboard-border-color': theme.colors.borderColor,\n '--keyboard-divider-color': theme.colors.dividerColor,\n }\n}\n\n/**\n * 将 CSS 变量应用到元素\n * @param element - 目标元素\n * @param theme - 主题配置\n */\nexport function applyTheme(element: HTMLElement, theme: ThemeConfig): void {\n const cssVars = themeToCSS(theme)\n Object.entries(cssVars).forEach(([key, value]) => {\n if (value) {\n element.style.setProperty(key, value)\n }\n })\n\n // 添加主题类名\n element.classList.remove('keyboard-theme-light', 'keyboard-theme-dark')\n element.classList.add(theme.isDark ? 'keyboard-theme-dark' : 'keyboard-theme-light')\n element.dataset.theme = theme.name\n}\n\n/**\n * 生成主题的内联样式字符串\n * @param theme - 主题配置\n * @returns 内联样式字符串\n */\nexport function generateThemeStyle(theme: ThemeConfig): string {\n const cssVars = themeToCSS(theme)\n return Object.entries(cssVars)\n .filter(([, value]) => value)\n .map(([key, value]) => `${key}: ${value}`)\n .join('; ')\n}\n\n/**\n * 合并主题配置\n * @param base - 基础主题\n * @param overrides - 覆盖配置\n * @returns 合并后的主题\n */\nexport function mergeTheme(\n base: ThemeConfig,\n overrides: Partial<ThemeConfig>,\n): ThemeConfig {\n return {\n ...base,\n ...overrides,\n colors: { ...base.colors, ...overrides.colors },\n sizes: { ...base.sizes, ...overrides.sizes },\n effects: { ...base.effects, ...overrides.effects },\n }\n}\n\n/**\n * 创建自定义主题\n * @param name - 主题名称\n * @param baseTheme - 基础主题名称\n * @param customization - 自定义配置\n */\nexport function createTheme(\n name: string,\n baseTheme: ThemeName | string,\n customization: Partial<Omit<ThemeConfig, 'name'>>,\n): ThemeConfig {\n const base = getTheme(baseTheme)\n const theme = mergeTheme(base, {\n ...customization,\n name,\n })\n registerTheme(theme)\n return theme\n}\n"],"mappings":";;;;;;;;;;;;AAcA,MAAM,+BAAyC,IAAI,IAAI;AAKvD,IAAI,eAA4B,gBAAA;AAOzB,SAAS,SAAS,MAAuC;CAC9D,OAAO,aAAa,IAAI,IAAI,KAAK,gBAAA,aAAa,SAAS,gBAAA;AACzD;AAMO,SAAS,cAAc,OAA0B;CACtD,aAAa,IAAI,MAAM,MAAM,KAAK;AACpC;AAMO,SAAS,qBAA+B;CAC7C,OAAO,CAAC,GAAG,OAAO,KAAK,gBAAA,YAAY,GAAG,GAAG,aAAa,KAAK,CAAC;AAC9D;AAMO,SAAS,eAA8B;CAC5C,OAAO,CACL,GAAG,OAAO,OAAO,gBAAA,YAAY,GAC7B,GAAG,aAAa,OAAO,CACzB;AACF;AAMO,SAAS,gBAAgB,MAAuC;CACrE,eAAe,SAAS,IAAI;CAC5B,OAAO;AACT;AAKO,SAAS,kBAA+B;CAC7C,OAAO;AACT;AAOO,SAAS,WAAW,OAAuC;CAChE,OAAO;EACL,iBAAiB,MAAM,OAAO;EAC9B,qBAAqB,MAAM,OAAO;EAClC,wBAAwB,MAAM,OAAO;EACrC,4BAA4B,MAAM,OAAO;EACzC,wBAAwB,MAAM,OAAO;EACrC,2BAA2B,MAAM,OAAO;EACxC,+BAA+B,MAAM,OAAO;EAC5C,yBAAyB,MAAM,OAAO;EACtC,gCAAgC,MAAM,OAAO;EAC7C,4BAA4B,MAAM,OAAO;EACzC,yBAAyB,GAAG,MAAM,MAAM,UAAS;EACjD,yBAAyB,GAAG,MAAM,MAAM,UAAS;EACjD,sBAAsB,GAAG,MAAM,MAAM,OAAM;EAC3C,wBAAwB,GAAG,MAAM,MAAM,SAAQ;EAC/C,2BAA2B,GAAG,MAAM,MAAM,WAAU;EACpD,sBAAsB,GAAG,MAAM,MAAM,QAAO;EAC5C,yBAAyB,MAAM,QAAQ;EACvC,kCAAkC,GAAG,MAAM,QAAQ,mBAAkB;EACrE,2BAA2B,MAAM,OAAO;EACxC,4BAA4B,MAAM,OAAO;CAC3C;AACF;AAOO,SAAS,WAAW,SAAsB,OAA0B;CACzE,MAAM,UAAU,WAAW,KAAK;CAChC,OAAO,QAAQ,OAAO,CAAA,CAAE,SAAS,CAAC,KAAK,WAAW;EAChD,IAAI,OACF,QAAQ,MAAM,YAAY,KAAK,KAAK;CAExC,CAAC;CAGD,QAAQ,UAAU,OAAO,wBAAwB,qBAAqB;CACtE,QAAQ,UAAU,IAAI,MAAM,SAAS,wBAAwB,sBAAsB;CACnF,QAAQ,QAAQ,QAAQ,MAAM;AAChC;AAOO,SAAS,mBAAmB,OAA4B;CAC7D,MAAM,UAAU,WAAW,KAAK;CAChC,OAAO,OAAO,QAAQ,OAAO,CAAA,CAC1B,QAAQ,GAAG,WAAW,KAAK,CAAA,CAC3B,KAAK,CAAC,KAAK,WAAW,GAAG,IAAG,IAAK,OAAO,CAAA,CACxC,KAAK,IAAI;AACd;AAQO,SAAS,WACd,MACA,WACa;CACb,OAAO;EACL,GAAG;EACH,GAAG;EACH,QAAQ;GAAE,GAAG,KAAK;GAAQ,GAAG,UAAU;EAAO;EAC9C,OAAO;GAAE,GAAG,KAAK;GAAO,GAAG,UAAU;EAAM;EAC3C,SAAS;GAAE,GAAG,KAAK;GAAS,GAAG,UAAU;EAAQ;CACnD;AACF;AAQO,SAAS,YACd,MACA,WACA,eACa;CAEb,MAAM,QAAQ,WADD,SAAS,SACG,GAAM;EAC7B,GAAG;EACH;CACF,CAAC;CACD,cAAc,KAAK;CACnB,OAAO;AACT"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题管理模块
|
|
3
|
+
* @module themes
|
|
4
|
+
*/
|
|
5
|
+
import type { ThemeConfig, ThemeCSSVariables, ThemeName } from './types';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './presets';
|
|
8
|
+
/**
|
|
9
|
+
* 获取主题配置
|
|
10
|
+
* @param name - 主题名称
|
|
11
|
+
* @returns 主题配置,如果不存在则返回默认主题
|
|
12
|
+
*/
|
|
13
|
+
export declare function getTheme(name: ThemeName | string): ThemeConfig;
|
|
14
|
+
/**
|
|
15
|
+
* 注册自定义主题
|
|
16
|
+
* @param theme - 主题配置
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerTheme(theme: ThemeConfig): void;
|
|
19
|
+
/**
|
|
20
|
+
* 获取所有可用主题
|
|
21
|
+
* @returns 主题名称列表
|
|
22
|
+
*/
|
|
23
|
+
export declare function getAvailableThemes(): string[];
|
|
24
|
+
/**
|
|
25
|
+
* 获取所有主题配置
|
|
26
|
+
* @returns 主题配置列表
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAllThemes(): ThemeConfig[];
|
|
29
|
+
/**
|
|
30
|
+
* 设置当前主题
|
|
31
|
+
* @param name - 主题名称
|
|
32
|
+
*/
|
|
33
|
+
export declare function setCurrentTheme(name: ThemeName | string): ThemeConfig;
|
|
34
|
+
/**
|
|
35
|
+
* 获取当前主题
|
|
36
|
+
*/
|
|
37
|
+
export declare function getCurrentTheme(): ThemeConfig;
|
|
38
|
+
/**
|
|
39
|
+
* 将主题配置转换为 CSS 变量
|
|
40
|
+
* @param theme - 主题配置
|
|
41
|
+
* @returns CSS 变量对象
|
|
42
|
+
*/
|
|
43
|
+
export declare function themeToCSS(theme: ThemeConfig): ThemeCSSVariables;
|
|
44
|
+
/**
|
|
45
|
+
* 将 CSS 变量应用到元素
|
|
46
|
+
* @param element - 目标元素
|
|
47
|
+
* @param theme - 主题配置
|
|
48
|
+
*/
|
|
49
|
+
export declare function applyTheme(element: HTMLElement, theme: ThemeConfig): void;
|
|
50
|
+
/**
|
|
51
|
+
* 生成主题的内联样式字符串
|
|
52
|
+
* @param theme - 主题配置
|
|
53
|
+
* @returns 内联样式字符串
|
|
54
|
+
*/
|
|
55
|
+
export declare function generateThemeStyle(theme: ThemeConfig): string;
|
|
56
|
+
/**
|
|
57
|
+
* 合并主题配置
|
|
58
|
+
* @param base - 基础主题
|
|
59
|
+
* @param overrides - 覆盖配置
|
|
60
|
+
* @returns 合并后的主题
|
|
61
|
+
*/
|
|
62
|
+
export declare function mergeTheme(base: ThemeConfig, overrides: Partial<ThemeConfig>): ThemeConfig;
|
|
63
|
+
/**
|
|
64
|
+
* 创建自定义主题
|
|
65
|
+
* @param name - 主题名称
|
|
66
|
+
* @param baseTheme - 基础主题名称
|
|
67
|
+
* @param customization - 自定义配置
|
|
68
|
+
*/
|
|
69
|
+
export declare function createTheme(name: string, baseTheme: ThemeName | string, customization: Partial<Omit<ThemeConfig, 'name'>>): ThemeConfig;
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,214 @@
|
|
|
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/themes/presets.ts
|
|
12
|
+
const miuiTheme = {
|
|
13
|
+
name: "miui",
|
|
14
|
+
displayName: "MIUI",
|
|
15
|
+
description: "小米风格 - 纯净简洁",
|
|
16
|
+
isDark: false,
|
|
17
|
+
colors: {
|
|
18
|
+
background: "#f5f5f5",
|
|
19
|
+
keyBackground: "#ffffff",
|
|
20
|
+
keyColor: "#1a1a1a",
|
|
21
|
+
keyActiveBackground: "#e8e8e8",
|
|
22
|
+
fnKeyBackground: "#e0e0e0",
|
|
23
|
+
fnKeyColor: "#666666",
|
|
24
|
+
fnKeyActiveBackground: "#d0d0d0",
|
|
25
|
+
primaryBackground: "#ff6700",
|
|
26
|
+
primaryActiveBackground: "#e55d00",
|
|
27
|
+
primaryColor: "#ffffff",
|
|
28
|
+
borderColor: "transparent",
|
|
29
|
+
dividerColor: "#eeeeee"
|
|
30
|
+
},
|
|
31
|
+
sizes: {
|
|
32
|
+
keyHeight: 46,
|
|
33
|
+
keyRadius: 8,
|
|
34
|
+
keyGap: 6,
|
|
35
|
+
fontSize: 18,
|
|
36
|
+
fnFontSize: 14,
|
|
37
|
+
padding: 8
|
|
38
|
+
},
|
|
39
|
+
effects: {
|
|
40
|
+
keyShadow: "none",
|
|
41
|
+
keyActiveShadow: "none",
|
|
42
|
+
keyActiveScale: .96,
|
|
43
|
+
transitionDuration: 100,
|
|
44
|
+
enableBlur: false,
|
|
45
|
+
blurAmount: 0,
|
|
46
|
+
enableRipple: false
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const iosTheme = {
|
|
50
|
+
name: "ios",
|
|
51
|
+
displayName: "iOS",
|
|
52
|
+
description: "Apple 风格 - 精致优雅",
|
|
53
|
+
isDark: false,
|
|
54
|
+
colors: {
|
|
55
|
+
background: "#d1d3d9",
|
|
56
|
+
keyBackground: "#ffffff",
|
|
57
|
+
keyColor: "#000000",
|
|
58
|
+
keyActiveBackground: "#b8bac2",
|
|
59
|
+
fnKeyBackground: "#a8aab4",
|
|
60
|
+
fnKeyColor: "#000000",
|
|
61
|
+
fnKeyActiveBackground: "#9699a3",
|
|
62
|
+
primaryBackground: "#007aff",
|
|
63
|
+
primaryActiveBackground: "#0062cc",
|
|
64
|
+
primaryColor: "#ffffff",
|
|
65
|
+
borderColor: "transparent",
|
|
66
|
+
dividerColor: "#c8cad0"
|
|
67
|
+
},
|
|
68
|
+
sizes: {
|
|
69
|
+
keyHeight: 43,
|
|
70
|
+
keyRadius: 5,
|
|
71
|
+
keyGap: 6,
|
|
72
|
+
fontSize: 22,
|
|
73
|
+
fnFontSize: 15,
|
|
74
|
+
padding: 4
|
|
75
|
+
},
|
|
76
|
+
effects: {
|
|
77
|
+
keyShadow: "0 1px 0 rgba(0,0,0,0.35)",
|
|
78
|
+
keyActiveShadow: "0 0 0 rgba(0,0,0,0)",
|
|
79
|
+
keyActiveScale: 1,
|
|
80
|
+
transitionDuration: 80,
|
|
81
|
+
enableBlur: true,
|
|
82
|
+
blurAmount: 20,
|
|
83
|
+
enableRipple: false
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
const materialTheme = {
|
|
87
|
+
name: "material",
|
|
88
|
+
displayName: "Material",
|
|
89
|
+
description: "Google 风格 - 深邃现代",
|
|
90
|
+
isDark: true,
|
|
91
|
+
colors: {
|
|
92
|
+
background: "#263238",
|
|
93
|
+
keyBackground: "#37474f",
|
|
94
|
+
keyColor: "#ffffff",
|
|
95
|
+
keyActiveBackground: "#455a64",
|
|
96
|
+
fnKeyBackground: "#455a64",
|
|
97
|
+
fnKeyColor: "#b0bec5",
|
|
98
|
+
fnKeyActiveBackground: "#546e7a",
|
|
99
|
+
primaryBackground: "#4caf50",
|
|
100
|
+
primaryActiveBackground: "#43a047",
|
|
101
|
+
primaryColor: "#ffffff",
|
|
102
|
+
borderColor: "transparent",
|
|
103
|
+
dividerColor: "#37474f"
|
|
104
|
+
},
|
|
105
|
+
sizes: {
|
|
106
|
+
keyHeight: 48,
|
|
107
|
+
keyRadius: 4,
|
|
108
|
+
keyGap: 4,
|
|
109
|
+
fontSize: 20,
|
|
110
|
+
fnFontSize: 14,
|
|
111
|
+
padding: 6
|
|
112
|
+
},
|
|
113
|
+
effects: {
|
|
114
|
+
keyShadow: "0 1px 3px rgba(0,0,0,0.2)",
|
|
115
|
+
keyActiveShadow: "0 2px 6px rgba(0,0,0,0.3)",
|
|
116
|
+
keyActiveScale: 1,
|
|
117
|
+
transitionDuration: 150,
|
|
118
|
+
enableBlur: false,
|
|
119
|
+
blurAmount: 0,
|
|
120
|
+
enableRipple: true
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const minimalTheme = {
|
|
124
|
+
name: "minimal",
|
|
125
|
+
displayName: "Minimal",
|
|
126
|
+
description: "极简风格 - 轻盈透明",
|
|
127
|
+
isDark: false,
|
|
128
|
+
colors: {
|
|
129
|
+
background: "rgba(250, 250, 250, 0.95)",
|
|
130
|
+
keyBackground: "transparent",
|
|
131
|
+
keyColor: "#333333",
|
|
132
|
+
keyActiveBackground: "rgba(0, 0, 0, 0.08)",
|
|
133
|
+
fnKeyBackground: "transparent",
|
|
134
|
+
fnKeyColor: "#888888",
|
|
135
|
+
fnKeyActiveBackground: "rgba(0, 0, 0, 0.08)",
|
|
136
|
+
primaryBackground: "#333333",
|
|
137
|
+
primaryActiveBackground: "#000000",
|
|
138
|
+
primaryColor: "#ffffff",
|
|
139
|
+
borderColor: "#eeeeee",
|
|
140
|
+
dividerColor: "#eeeeee"
|
|
141
|
+
},
|
|
142
|
+
sizes: {
|
|
143
|
+
keyHeight: 44,
|
|
144
|
+
keyRadius: 12,
|
|
145
|
+
keyGap: 8,
|
|
146
|
+
fontSize: 17,
|
|
147
|
+
fnFontSize: 13,
|
|
148
|
+
padding: 12
|
|
149
|
+
},
|
|
150
|
+
effects: {
|
|
151
|
+
keyShadow: "none",
|
|
152
|
+
keyActiveShadow: "none",
|
|
153
|
+
keyActiveScale: .92,
|
|
154
|
+
transitionDuration: 120,
|
|
155
|
+
enableBlur: true,
|
|
156
|
+
blurAmount: 30,
|
|
157
|
+
enableRipple: false
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const darkTheme = {
|
|
161
|
+
name: "dark",
|
|
162
|
+
displayName: "Dark",
|
|
163
|
+
description: "深色模式 - 护眼舒适",
|
|
164
|
+
isDark: true,
|
|
165
|
+
colors: {
|
|
166
|
+
background: "#1c1c1e",
|
|
167
|
+
keyBackground: "#3a3a3c",
|
|
168
|
+
keyColor: "#ffffff",
|
|
169
|
+
keyActiveBackground: "#4a4a4c",
|
|
170
|
+
fnKeyBackground: "#2c2c2e",
|
|
171
|
+
fnKeyColor: "#ebebf5",
|
|
172
|
+
fnKeyActiveBackground: "#3c3c3e",
|
|
173
|
+
primaryBackground: "#0a84ff",
|
|
174
|
+
primaryActiveBackground: "#0070e0",
|
|
175
|
+
primaryColor: "#ffffff",
|
|
176
|
+
borderColor: "#3a3a3c",
|
|
177
|
+
dividerColor: "#3a3a3c"
|
|
178
|
+
},
|
|
179
|
+
sizes: {
|
|
180
|
+
keyHeight: 45,
|
|
181
|
+
keyRadius: 8,
|
|
182
|
+
keyGap: 6,
|
|
183
|
+
fontSize: 18,
|
|
184
|
+
fnFontSize: 14,
|
|
185
|
+
padding: 8
|
|
186
|
+
},
|
|
187
|
+
effects: {
|
|
188
|
+
keyShadow: "0 1px 2px rgba(0,0,0,0.4)",
|
|
189
|
+
keyActiveShadow: "0 0 8px rgba(10,132,255,0.3)",
|
|
190
|
+
keyActiveScale: .97,
|
|
191
|
+
transitionDuration: 100,
|
|
192
|
+
enableBlur: true,
|
|
193
|
+
blurAmount: 20,
|
|
194
|
+
enableRipple: false
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const presetThemes = {
|
|
198
|
+
miui: miuiTheme,
|
|
199
|
+
ios: iosTheme,
|
|
200
|
+
material: materialTheme,
|
|
201
|
+
minimal: minimalTheme,
|
|
202
|
+
dark: darkTheme
|
|
203
|
+
};
|
|
204
|
+
const defaultTheme = miuiTheme;
|
|
205
|
+
//#endregion
|
|
206
|
+
exports.darkTheme = darkTheme;
|
|
207
|
+
exports.defaultTheme = defaultTheme;
|
|
208
|
+
exports.iosTheme = iosTheme;
|
|
209
|
+
exports.materialTheme = materialTheme;
|
|
210
|
+
exports.minimalTheme = minimalTheme;
|
|
211
|
+
exports.miuiTheme = miuiTheme;
|
|
212
|
+
exports.presetThemes = presetThemes;
|
|
213
|
+
/*! End of @composy/keyboard-core | Powered by @composy/builder */
|
|
214
|
+
//# sourceMappingURL=presets.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presets.cjs","names":[],"sources":["../../src/themes/presets.ts"],"sourcesContent":["/**\n * 预设主题配置\n * @module themes/presets\n */\n\nimport type { ThemeConfig } from './types'\n\n/**\n * MIUI 小米风格主题(默认)\n * 特点:纯净、扁平、简洁、无多余装饰\n */\nexport const miuiTheme: ThemeConfig = {\n name: 'miui',\n displayName: 'MIUI',\n description: '小米风格 - 纯净简洁',\n isDark: false,\n colors: {\n background: '#f5f5f5',\n keyBackground: '#ffffff',\n keyColor: '#1a1a1a',\n keyActiveBackground: '#e8e8e8',\n fnKeyBackground: '#e0e0e0',\n fnKeyColor: '#666666',\n fnKeyActiveBackground: '#d0d0d0',\n primaryBackground: '#ff6700', // 小米橙\n primaryActiveBackground: '#e55d00',\n primaryColor: '#ffffff',\n borderColor: 'transparent',\n dividerColor: '#eeeeee',\n },\n sizes: {\n keyHeight: 46,\n keyRadius: 8,\n keyGap: 6,\n fontSize: 18,\n fnFontSize: 14,\n padding: 8,\n },\n effects: {\n keyShadow: 'none',\n keyActiveShadow: 'none',\n keyActiveScale: 0.96,\n transitionDuration: 100,\n enableBlur: false,\n blurAmount: 0,\n enableRipple: false,\n },\n}\n\n/**\n * iOS 风格主题\n * 特点:毛玻璃、圆润阴影、精致\n */\nexport const iosTheme: ThemeConfig = {\n name: 'ios',\n displayName: 'iOS',\n description: 'Apple 风格 - 精致优雅',\n isDark: false,\n colors: {\n background: '#d1d3d9',\n keyBackground: '#ffffff',\n keyColor: '#000000',\n keyActiveBackground: '#b8bac2',\n fnKeyBackground: '#a8aab4',\n fnKeyColor: '#000000',\n fnKeyActiveBackground: '#9699a3',\n primaryBackground: '#007aff',\n primaryActiveBackground: '#0062cc',\n primaryColor: '#ffffff',\n borderColor: 'transparent',\n dividerColor: '#c8cad0',\n },\n sizes: {\n keyHeight: 43,\n keyRadius: 5,\n keyGap: 6,\n fontSize: 22,\n fnFontSize: 15,\n padding: 4,\n },\n effects: {\n keyShadow: '0 1px 0 rgba(0,0,0,0.35)',\n keyActiveShadow: '0 0 0 rgba(0,0,0,0)',\n keyActiveScale: 1,\n transitionDuration: 80,\n enableBlur: true,\n blurAmount: 20,\n enableRipple: false,\n },\n}\n\n/**\n * Material Design 主题\n * 特点:深色、涟漪动效、层次感\n */\nexport const materialTheme: ThemeConfig = {\n name: 'material',\n displayName: 'Material',\n description: 'Google 风格 - 深邃现代',\n isDark: true,\n colors: {\n background: '#263238',\n keyBackground: '#37474f',\n keyColor: '#ffffff',\n keyActiveBackground: '#455a64',\n fnKeyBackground: '#455a64',\n fnKeyColor: '#b0bec5',\n fnKeyActiveBackground: '#546e7a',\n primaryBackground: '#4caf50', // Material Green\n primaryActiveBackground: '#43a047',\n primaryColor: '#ffffff',\n borderColor: 'transparent',\n dividerColor: '#37474f',\n },\n sizes: {\n keyHeight: 48,\n keyRadius: 4,\n keyGap: 4,\n fontSize: 20,\n fnFontSize: 14,\n padding: 6,\n },\n effects: {\n keyShadow: '0 1px 3px rgba(0,0,0,0.2)',\n keyActiveShadow: '0 2px 6px rgba(0,0,0,0.3)',\n keyActiveScale: 1,\n transitionDuration: 150,\n enableBlur: false,\n blurAmount: 0,\n enableRipple: true,\n },\n}\n\n/**\n * 极简主题\n * 特点:无边框、超简洁、透明感\n */\nexport const minimalTheme: ThemeConfig = {\n name: 'minimal',\n displayName: 'Minimal',\n description: '极简风格 - 轻盈透明',\n isDark: false,\n colors: {\n background: 'rgba(250, 250, 250, 0.95)',\n keyBackground: 'transparent',\n keyColor: '#333333',\n keyActiveBackground: 'rgba(0, 0, 0, 0.08)',\n fnKeyBackground: 'transparent',\n fnKeyColor: '#888888',\n fnKeyActiveBackground: 'rgba(0, 0, 0, 0.08)',\n primaryBackground: '#333333',\n primaryActiveBackground: '#000000',\n primaryColor: '#ffffff',\n borderColor: '#eeeeee',\n dividerColor: '#eeeeee',\n },\n sizes: {\n keyHeight: 44,\n keyRadius: 12,\n keyGap: 8,\n fontSize: 17,\n fnFontSize: 13,\n padding: 12,\n },\n effects: {\n keyShadow: 'none',\n keyActiveShadow: 'none',\n keyActiveScale: 0.92,\n transitionDuration: 120,\n enableBlur: true,\n blurAmount: 30,\n enableRipple: false,\n },\n}\n\n/**\n * 深色主题\n * 特点:护眼、现代、高对比\n */\nexport const darkTheme: ThemeConfig = {\n name: 'dark',\n displayName: 'Dark',\n description: '深色模式 - 护眼舒适',\n isDark: true,\n colors: {\n background: '#1c1c1e',\n keyBackground: '#3a3a3c',\n keyColor: '#ffffff',\n keyActiveBackground: '#4a4a4c',\n fnKeyBackground: '#2c2c2e',\n fnKeyColor: '#ebebf5',\n fnKeyActiveBackground: '#3c3c3e',\n primaryBackground: '#0a84ff',\n primaryActiveBackground: '#0070e0',\n primaryColor: '#ffffff',\n borderColor: '#3a3a3c',\n dividerColor: '#3a3a3c',\n },\n sizes: {\n keyHeight: 45,\n keyRadius: 8,\n keyGap: 6,\n fontSize: 18,\n fnFontSize: 14,\n padding: 8,\n },\n effects: {\n keyShadow: '0 1px 2px rgba(0,0,0,0.4)',\n keyActiveShadow: '0 0 8px rgba(10,132,255,0.3)',\n keyActiveScale: 0.97,\n transitionDuration: 100,\n enableBlur: true,\n blurAmount: 20,\n enableRipple: false,\n },\n}\n\n/**\n * 所有预设主题\n */\nexport const presetThemes: Record<string, ThemeConfig> = {\n miui: miuiTheme,\n ios: iosTheme,\n material: materialTheme,\n minimal: minimalTheme,\n dark: darkTheme,\n}\n\n/**\n * 默认主题\n */\nexport const defaultTheme = miuiTheme\n"],"mappings":";;;;;;;;;;;AAWO,MAAM,YAAyB;CACpC,MAAM;CACN,aAAa;CACb,aAAa;CACb,QAAQ;CACR,QAAQ;EACN,YAAY;EACZ,eAAe;EACf,UAAU;EACV,qBAAqB;EACrB,iBAAiB;EACjB,YAAY;EACZ,uBAAuB;EACvB,mBAAmB;EACnB,yBAAyB;EACzB,cAAc;EACd,aAAa;EACb,cAAc;CAChB;CACA,OAAO;EACL,WAAW;EACX,WAAW;EACX,QAAQ;EACR,UAAU;EACV,YAAY;EACZ,SAAS;CACX;CACA,SAAS;EACP,WAAW;EACX,iBAAiB;EACjB,gBAAgB;EAChB,oBAAoB;EACpB,YAAY;EACZ,YAAY;EACZ,cAAc;CAChB;AACF;AAMO,MAAM,WAAwB;CACnC,MAAM;CACN,aAAa;CACb,aAAa;CACb,QAAQ;CACR,QAAQ;EACN,YAAY;EACZ,eAAe;EACf,UAAU;EACV,qBAAqB;EACrB,iBAAiB;EACjB,YAAY;EACZ,uBAAuB;EACvB,mBAAmB;EACnB,yBAAyB;EACzB,cAAc;EACd,aAAa;EACb,cAAc;CAChB;CACA,OAAO;EACL,WAAW;EACX,WAAW;EACX,QAAQ;EACR,UAAU;EACV,YAAY;EACZ,SAAS;CACX;CACA,SAAS;EACP,WAAW;EACX,iBAAiB;EACjB,gBAAgB;EAChB,oBAAoB;EACpB,YAAY;EACZ,YAAY;EACZ,cAAc;CAChB;AACF;AAMO,MAAM,gBAA6B;CACxC,MAAM;CACN,aAAa;CACb,aAAa;CACb,QAAQ;CACR,QAAQ;EACN,YAAY;EACZ,eAAe;EACf,UAAU;EACV,qBAAqB;EACrB,iBAAiB;EACjB,YAAY;EACZ,uBAAuB;EACvB,mBAAmB;EACnB,yBAAyB;EACzB,cAAc;EACd,aAAa;EACb,cAAc;CAChB;CACA,OAAO;EACL,WAAW;EACX,WAAW;EACX,QAAQ;EACR,UAAU;EACV,YAAY;EACZ,SAAS;CACX;CACA,SAAS;EACP,WAAW;EACX,iBAAiB;EACjB,gBAAgB;EAChB,oBAAoB;EACpB,YAAY;EACZ,YAAY;EACZ,cAAc;CAChB;AACF;AAMO,MAAM,eAA4B;CACvC,MAAM;CACN,aAAa;CACb,aAAa;CACb,QAAQ;CACR,QAAQ;EACN,YAAY;EACZ,eAAe;EACf,UAAU;EACV,qBAAqB;EACrB,iBAAiB;EACjB,YAAY;EACZ,uBAAuB;EACvB,mBAAmB;EACnB,yBAAyB;EACzB,cAAc;EACd,aAAa;EACb,cAAc;CAChB;CACA,OAAO;EACL,WAAW;EACX,WAAW;EACX,QAAQ;EACR,UAAU;EACV,YAAY;EACZ,SAAS;CACX;CACA,SAAS;EACP,WAAW;EACX,iBAAiB;EACjB,gBAAgB;EAChB,oBAAoB;EACpB,YAAY;EACZ,YAAY;EACZ,cAAc;CAChB;AACF;AAMO,MAAM,YAAyB;CACpC,MAAM;CACN,aAAa;CACb,aAAa;CACb,QAAQ;CACR,QAAQ;EACN,YAAY;EACZ,eAAe;EACf,UAAU;EACV,qBAAqB;EACrB,iBAAiB;EACjB,YAAY;EACZ,uBAAuB;EACvB,mBAAmB;EACnB,yBAAyB;EACzB,cAAc;EACd,aAAa;EACb,cAAc;CAChB;CACA,OAAO;EACL,WAAW;EACX,WAAW;EACX,QAAQ;EACR,UAAU;EACV,YAAY;EACZ,SAAS;CACX;CACA,SAAS;EACP,WAAW;EACX,iBAAiB;EACjB,gBAAgB;EAChB,oBAAoB;EACpB,YAAY;EACZ,YAAY;EACZ,cAAc;CAChB;AACF;AAKO,MAAM,eAA4C;CACvD,MAAM;CACN,KAAK;CACL,UAAU;CACV,SAAS;CACT,MAAM;AACR;AAKO,MAAM,eAAe"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 预设主题配置
|
|
3
|
+
* @module themes/presets
|
|
4
|
+
*/
|
|
5
|
+
import type { ThemeConfig } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* MIUI 小米风格主题(默认)
|
|
8
|
+
* 特点:纯净、扁平、简洁、无多余装饰
|
|
9
|
+
*/
|
|
10
|
+
export declare const miuiTheme: ThemeConfig;
|
|
11
|
+
/**
|
|
12
|
+
* iOS 风格主题
|
|
13
|
+
* 特点:毛玻璃、圆润阴影、精致
|
|
14
|
+
*/
|
|
15
|
+
export declare const iosTheme: ThemeConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Material Design 主题
|
|
18
|
+
* 特点:深色、涟漪动效、层次感
|
|
19
|
+
*/
|
|
20
|
+
export declare const materialTheme: ThemeConfig;
|
|
21
|
+
/**
|
|
22
|
+
* 极简主题
|
|
23
|
+
* 特点:无边框、超简洁、透明感
|
|
24
|
+
*/
|
|
25
|
+
export declare const minimalTheme: ThemeConfig;
|
|
26
|
+
/**
|
|
27
|
+
* 深色主题
|
|
28
|
+
* 特点:护眼、现代、高对比
|
|
29
|
+
*/
|
|
30
|
+
export declare const darkTheme: ThemeConfig;
|
|
31
|
+
/**
|
|
32
|
+
* 所有预设主题
|
|
33
|
+
*/
|
|
34
|
+
export declare const presetThemes: Record<string, ThemeConfig>;
|
|
35
|
+
/**
|
|
36
|
+
* 默认主题
|
|
37
|
+
*/
|
|
38
|
+
export declare const defaultTheme: ThemeConfig;
|
|
39
|
+
//# sourceMappingURL=presets.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,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 主题系统类型定义
|
|
3
|
+
* @module themes/types
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 预设主题名称
|
|
7
|
+
*/
|
|
8
|
+
export type ThemeName = 'miui' | 'ios' | 'material' | 'minimal' | 'dark' | 'custom';
|
|
9
|
+
/**
|
|
10
|
+
* 主题色彩配置
|
|
11
|
+
*/
|
|
12
|
+
export interface ThemeColors {
|
|
13
|
+
/** 键盘背景色 */
|
|
14
|
+
background: string;
|
|
15
|
+
/** 按键背景色 */
|
|
16
|
+
keyBackground: string;
|
|
17
|
+
/** 按键文字颜色 */
|
|
18
|
+
keyColor: string;
|
|
19
|
+
/** 按键按下背景色 */
|
|
20
|
+
keyActiveBackground: string;
|
|
21
|
+
/** 功能键背景色 */
|
|
22
|
+
fnKeyBackground: string;
|
|
23
|
+
/** 功能键文字颜色 */
|
|
24
|
+
fnKeyColor: string;
|
|
25
|
+
/** 功能键按下背景色 */
|
|
26
|
+
fnKeyActiveBackground: string;
|
|
27
|
+
/** 主色调(确认/完成键) */
|
|
28
|
+
primaryBackground: string;
|
|
29
|
+
/** 主色调按下 */
|
|
30
|
+
primaryActiveBackground: string;
|
|
31
|
+
/** 主色调文字 */
|
|
32
|
+
primaryColor: string;
|
|
33
|
+
/** 边框颜色(可选) */
|
|
34
|
+
borderColor?: string;
|
|
35
|
+
/** 分割线颜色 */
|
|
36
|
+
dividerColor?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 主题尺寸配置
|
|
40
|
+
*/
|
|
41
|
+
export interface ThemeSizes {
|
|
42
|
+
/** 按键高度 */
|
|
43
|
+
keyHeight: number;
|
|
44
|
+
/** 按键圆角 */
|
|
45
|
+
keyRadius: number;
|
|
46
|
+
/** 按键间距 */
|
|
47
|
+
keyGap: number;
|
|
48
|
+
/** 字体大小 */
|
|
49
|
+
fontSize: number;
|
|
50
|
+
/** 功能键字体大小 */
|
|
51
|
+
fnFontSize: number;
|
|
52
|
+
/** 键盘内边距 */
|
|
53
|
+
padding: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 主题效果配置
|
|
57
|
+
*/
|
|
58
|
+
export interface ThemeEffects {
|
|
59
|
+
/** 按键阴影 */
|
|
60
|
+
keyShadow: string;
|
|
61
|
+
/** 按键按下阴影 */
|
|
62
|
+
keyActiveShadow: string;
|
|
63
|
+
/** 按键按下缩放 */
|
|
64
|
+
keyActiveScale: number;
|
|
65
|
+
/** 动画时长 (ms) */
|
|
66
|
+
transitionDuration: number;
|
|
67
|
+
/** 是否启用毛玻璃效果 */
|
|
68
|
+
enableBlur: boolean;
|
|
69
|
+
/** 毛玻璃模糊度 */
|
|
70
|
+
blurAmount: number;
|
|
71
|
+
/** 是否启用涟漪效果 */
|
|
72
|
+
enableRipple: boolean;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 完整主题配置
|
|
76
|
+
*/
|
|
77
|
+
export interface ThemeConfig {
|
|
78
|
+
/** 主题名称 */
|
|
79
|
+
name: ThemeName | string;
|
|
80
|
+
/** 显示名称 */
|
|
81
|
+
displayName: string;
|
|
82
|
+
/** 主题描述 */
|
|
83
|
+
description?: string;
|
|
84
|
+
/** 色彩配置 */
|
|
85
|
+
colors: ThemeColors;
|
|
86
|
+
/** 尺寸配置 */
|
|
87
|
+
sizes: ThemeSizes;
|
|
88
|
+
/** 效果配置 */
|
|
89
|
+
effects: ThemeEffects;
|
|
90
|
+
/** 是否为深色主题 */
|
|
91
|
+
isDark: boolean;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 主题CSS变量映射
|
|
95
|
+
*/
|
|
96
|
+
export interface ThemeCSSVariables {
|
|
97
|
+
'--keyboard-bg': string;
|
|
98
|
+
'--keyboard-key-bg': string;
|
|
99
|
+
'--keyboard-key-color': string;
|
|
100
|
+
'--keyboard-key-active-bg': string;
|
|
101
|
+
'--keyboard-fn-key-bg': string;
|
|
102
|
+
'--keyboard-fn-key-color': string;
|
|
103
|
+
'--keyboard-fn-key-active-bg': string;
|
|
104
|
+
'--keyboard-primary-bg': string;
|
|
105
|
+
'--keyboard-primary-active-bg': string;
|
|
106
|
+
'--keyboard-primary-color': string;
|
|
107
|
+
'--keyboard-key-height': string;
|
|
108
|
+
'--keyboard-key-radius': string;
|
|
109
|
+
'--keyboard-key-gap': string;
|
|
110
|
+
'--keyboard-font-size': string;
|
|
111
|
+
'--keyboard-fn-font-size': string;
|
|
112
|
+
'--keyboard-padding': string;
|
|
113
|
+
'--keyboard-key-shadow': string;
|
|
114
|
+
'--keyboard-transition-duration': string;
|
|
115
|
+
'--keyboard-border-color'?: string;
|
|
116
|
+
'--keyboard-divider-color'?: string;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=types.d.ts.map
|