vanilla-jui 1.4.5 → 1.4.7

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.
Files changed (103) hide show
  1. package/README.md +6 -0
  2. package/dist/index.d.ts +1273 -1896
  3. package/dist/index.js +1 -1
  4. package/dist/index.umd.js +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +21 -2
  7. package/src/components/accordion.ts +297 -216
  8. package/src/components/flow.ts +222 -258
  9. package/src/components/form.ts +44 -102
  10. package/src/components/menu.ts +268 -356
  11. package/src/components/modal.ts +181 -641
  12. package/src/components/offcanvas.ts +225 -106
  13. package/src/components/pagination.ts +296 -326
  14. package/src/components/sticky.ts +55 -54
  15. package/src/components/swiper.ts +237 -247
  16. package/src/components/tabs.ts +278 -271
  17. package/src/components/toc.ts +42 -46
  18. package/src/core/Component.ts +69 -47
  19. package/src/css/accordion.css +2 -2
  20. package/src/css/animation.css +1 -5
  21. package/src/css/avatar.css +1 -1
  22. package/src/css/badge.css +1 -1
  23. package/src/css/breadcrumb.css +9 -10
  24. package/src/css/button.css +1 -1
  25. package/src/css/card.css +2 -2
  26. package/src/css/color.css +974 -1002
  27. package/src/css/color_p3.css +974 -1004
  28. package/src/css/components.css +1 -1
  29. package/src/css/content.css +72 -63
  30. package/src/css/drop.css +1 -1
  31. package/src/css/editor.css +14 -14
  32. package/src/css/flow.css +4 -14
  33. package/src/css/font.css +5 -4
  34. package/src/css/form.css +76 -52
  35. package/src/css/gradient.css +299 -222
  36. package/src/css/icon.css +57 -57
  37. package/src/css/index.css +1 -1
  38. package/src/css/layout.css +13 -10
  39. package/src/css/loading.css +60 -12
  40. package/src/css/menu.css +262 -188
  41. package/src/css/modal.css +1 -1
  42. package/src/css/offcanvas.css +9 -13
  43. package/src/css/pagination.css +5 -1
  44. package/src/css/popup.css +1 -1
  45. package/src/css/skeleton.css +3 -2
  46. package/src/css/status.css +2 -3
  47. package/src/css/swiper.css +1 -1
  48. package/src/css/table.css +1 -1
  49. package/src/css/tabs.css +12 -11
  50. package/src/css/tag.css +1 -1
  51. package/src/css/theme-palette.css +19 -5
  52. package/src/css/themes/default/accordion.css +61 -61
  53. package/src/css/themes/default/avatar.css +54 -54
  54. package/src/css/themes/default/badge.css +62 -62
  55. package/src/css/themes/default/breadcrumb.css +23 -23
  56. package/src/css/themes/default/button.css +203 -203
  57. package/src/css/themes/default/content.css +53 -53
  58. package/src/css/themes/default/drop.css +10 -10
  59. package/src/css/themes/default/editor.css +9 -9
  60. package/src/css/themes/default/index.css +1 -1
  61. package/src/css/themes/default/loading.css +26 -20
  62. package/src/css/themes/default/menu.css +75 -11
  63. package/src/css/themes/default/modal.css +32 -36
  64. package/src/css/themes/default/pagination.css +7 -7
  65. package/src/css/themes/default/popup.css +6 -6
  66. package/src/css/themes/default/swiper.css +32 -32
  67. package/src/css/themes/default/table.css +16 -16
  68. package/src/css/themes/default/tabs.css +30 -30
  69. package/src/css/themes/default/tag.css +71 -71
  70. package/src/css/themes/default/theme-palette.css +11 -11
  71. package/src/css/themes/default/tip.css +42 -42
  72. package/src/css/themes/default/toast.css +60 -60
  73. package/src/css/themes/default/toolbar.css +23 -29
  74. package/src/css/themes/default/tooltip.css +43 -13
  75. package/src/css/themes/index.css +1 -1
  76. package/src/css/tip.css +2 -2
  77. package/src/css/toast.css +3 -3
  78. package/src/css/tokens.css +12 -17
  79. package/src/css/toolbar.css +9 -10
  80. package/src/css/tooltip.css +3 -2
  81. package/src/index.ts +22 -19
  82. package/src/{components → primitives}/drop.ts +58 -49
  83. package/src/{components → primitives}/icons.ts +1 -1
  84. package/src/primitives/loading.ts +23 -0
  85. package/src/primitives/parabola.ts +388 -0
  86. package/src/primitives/popup.ts +61 -0
  87. package/src/{components → primitives}/theme.ts +89 -57
  88. package/src/{components → primitives}/toast.ts +18 -25
  89. package/src/{components → primitives}/tooltip.ts +100 -25
  90. package/src/utilities/browser.ts +23 -49
  91. package/src/utilities/class-name.ts +5 -0
  92. package/src/utilities/dom.ts +14 -32
  93. package/src/utilities/function.ts +4 -0
  94. package/src/utilities/http.ts +7 -7
  95. package/src/utilities/id.ts +57 -0
  96. package/src/utilities/object.ts +5 -0
  97. package/src/utilities/timer.ts +38 -0
  98. package/src/utilities/types.ts +420 -0
  99. package/src/{components → validation}/validator.ts +64 -53
  100. package/src/components/parabola.ts +0 -335
  101. package/src/utilities/cache.ts +0 -57
  102. package/src/utilities/core.ts +0 -614
  103. package/src/utilities/storage.ts +0 -46
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import debounce, { DebounceSettings, DebouncedFunc } from "lodash-es/debounce.js";
2
+ import throttle, { ThrottleSettings } from "lodash-es/throttle.js";
1
3
  //#region src/utilities/browser.d.ts
2
4
  declare global {
3
5
  interface Navigator {
@@ -8,16 +10,16 @@ declare global {
8
10
  version: string;
9
11
  }>;
10
12
  platform: string;
11
- getHighEntropyValues: (hints: string[]) => Promise<any>;
13
+ getHighEntropyValues: (hints: string[]) => Promise<Record<string, unknown>>;
12
14
  };
15
+ msMaxTouchPoints?: number;
13
16
  }
14
17
  interface Window {
15
18
  opera?: string;
16
19
  }
17
20
  }
18
21
  /**
19
- * 判断当前环境是否为移动设备。
20
- * @returns {boolean}
22
+ * 采用 MDN 推荐的组合策略:特性检测优先,UA 嗅探兜底
21
23
  */
22
24
  declare function isMobile(): boolean;
23
25
  /**
@@ -29,155 +31,7 @@ declare function isMobile(): boolean;
29
31
  */
30
32
  declare function copy(text: unknown): Promise<boolean>;
31
33
  //#endregion
32
- //#region src/utilities/cache.d.ts
33
- /**
34
- * 定义可销毁服务的接口契约
35
- */
36
- interface Destroyable {
37
- destroy?: () => void;
38
- }
39
- /**
40
- * 简易服务缓存容器。
41
- * 用于按 key 缓存工厂创建的服务实例,并提供销毁能力。
42
- */
43
- declare const service: {
44
- /**
45
- * 获取服务实例。如果不存在,则通过工厂函数创建并缓存。
46
- * @template T - 期望返回的服务类型(需继承自 Destroyable)
47
- * @param {string} key - 服务的唯一标识
48
- * @param {() => T} factory - 创建服务实例的工厂函数
49
- * @returns {T} 服务实例
50
- */
51
- get<T extends Destroyable>(key: string, factory: () => T): T;
52
- /**
53
- * 销毁指定 key 的服务实例并从缓存中移除。
54
- * @param {string} key - 服务的唯一标识
55
- */
56
- destroy(key: string): void;
57
- /**
58
- * 销毁所有缓存的服务实例并清空容器。
59
- */
60
- destroyAll(): void;
61
- };
62
- //#endregion
63
- //#region src/utilities/core.d.ts
64
- type LooseRecord = Record<string, unknown>;
65
- type ValueTypeName = string;
66
- type TypeRule = ValueTypeName | readonly ValueTypeName[];
67
- type AnyFunction = (this: unknown, ...args: never[]) => unknown;
68
- type ValidateCondition = ((value: unknown) => boolean) | {
69
- test: (value: unknown) => boolean;
70
- message?: string;
71
- };
72
- interface NormalizeContext<TInput extends LooseRecord = LooseRecord> {
73
- key: string;
74
- input: TInput;
75
- options: LooseRecord;
76
- schema: ResolveSchema<TInput>;
77
- }
78
- interface ParamRule<TInput extends LooseRecord = LooseRecord> {
79
- type?: TypeRule;
80
- types?: TypeRule;
81
- required?: boolean;
82
- enum?: readonly unknown[];
83
- conditions?: ValidateCondition | readonly ValidateCondition[];
84
- validate?: (value: unknown) => boolean;
85
- message?: string;
86
- normalize?: (value: unknown, context: NormalizeContext<TInput>) => unknown;
87
- default?: unknown;
88
- factory?: boolean;
89
- [key: string]: unknown;
90
- }
91
- type ParamRuleInput<TInput extends LooseRecord = LooseRecord> = TypeRule | ParamRule<TInput>;
92
- type ResolveSchema<TInput extends LooseRecord = LooseRecord> = Record<string, ParamRuleInput<TInput>>;
93
- type ResolvedProps<TSchema extends object> = LooseRecord & { [Key in keyof TSchema]: unknown; };
94
- /**
95
- * 判断对象是否包含指定的自有属性。
96
- * @template T - 对象类型
97
- * @param obj - 待检查的对象
98
- * @param key - 属性名
99
- * @returns 如果对象包含指定自有属性则返回 true,否则返回 false
100
- */
101
- declare const hasOwn: <T extends object>(obj: T, key: PropertyKey) => key is keyof T;
102
- /**
103
- * 创建去重后的数组,并移除假值(null、undefined、false、0、NaN、空字符串)。
104
- * @template T - 数组元素类型
105
- * @param list - 待去重的数组
106
- * @returns 去重后的新数组
107
- */
108
- declare const uniq: <T>(list: readonly T[]) => T[];
109
- /**
110
- * 定时器管理器
111
- */
112
- declare const timer: {
113
- timers: Record<string, ReturnType<typeof setTimeout>>;
114
- /**
115
- * 注册并开始一个定时器
116
- * @param {string} key - 定时器的唯一标识
117
- * @param {number} duration - 延迟执行的时间(毫秒)
118
- * @param {function} callback - 延迟执行的回调函数
119
- */
120
- start(key: string, duration: number, callback: () => void): void;
121
- /**
122
- * 明确注销一个定时器
123
- * @param {string} key - 需要取消的定时器唯一标识
124
- */
125
- cancel(key: string): void;
126
- };
127
- /**
128
- * 获取值的增强类型名称。
129
- * 支持识别 null、array、HTMLElement、Node 等特殊类型。
130
- * @param val - 需要判断类型的值
131
- * @returns 类型名称(如 array、null、HTMLElement、Node、string)
132
- */
133
- declare const getType: (val: unknown) => string;
134
- /**
135
- * 判断是否为普通可构造函数(排除箭头函数和类)。
136
- * @param fn - 需要判断的值
137
- * @returns 如果是普通函数则返回 true,否则返回 false
138
- */
139
- declare const isFunction: (fn: unknown) => fn is (...args: never[]) => unknown;
140
- /**
141
- * 判断是否为类(使用 class 语法定义)。
142
- * @param fn - 需要判断的值
143
- * @returns 如果是类则返回 true,否则返回 false
144
- */
145
- declare const isClass: (fn: unknown) => fn is abstract new (...args: never[]) => unknown;
146
- /**
147
- * 判断是否为普通对象(纯对象字面量或通过 Object.create(null) 创建)。
148
- * @param value - 需要判断的值
149
- * @returns 如果是普通对象则返回 true,否则返回 false
150
- */
151
- declare function isPlainObject(value: unknown): value is Record<string, unknown>;
152
- /**
153
- * 校验单个参数。
154
- *
155
- * 支持的校验规则包括:type/types(类型)、required(必填)、enum(枚举)、
156
- * conditions(条件)、validate(自定义校验函数)、message(错误消息)。
157
- *
158
- * @template TInput - 输入对象类型
159
- * @param name - 参数名
160
- * @param value - 参数值
161
- * @param [rule] - 校验规则
162
- * @param [namespace] - 错误命名空间,用于错误消息前缀
163
- * @returns 校验通过后的原值
164
- * @throws {Error} 校验失败时抛出错误
165
- */
166
- declare function validateParam<TInput extends LooseRecord = LooseRecord>(name: string, value: unknown, rule?: ParamRuleInput<TInput>, namespace?: string): unknown;
167
- /**
168
- * 合并默认值、执行 normalize 并校验配置对象。
169
- *
170
- * schema 的每一项可同时定义:default(默认值)、factory(是否为工厂函数)、
171
- * normalize(标准化函数)和校验规则(type、required、enum 等)。
172
- *
173
- * @template TInput - 输入对象类型
174
- * @template TSchema - 配置 schema 类型
175
- * @param [input={}] - 用户传入的配置对象
176
- * @param [schema={}] - 配置 schema 定义
177
- * @param [namespace="Options"] - 错误命名空间,用于错误消息前缀
178
- * @returns 合并并校验后的配置对象
179
- */
180
- declare function resolveProps<TInput extends LooseRecord, TSchema extends ResolveSchema<TInput>>(input?: TInput | null | undefined, schema?: TSchema, namespace?: string): TInput & ResolvedProps<TSchema>;
34
+ //#region src/utilities/id.d.ts
181
35
  /**
182
36
  * 生成标准 UUID v4 字符串。
183
37
  *
@@ -197,44 +51,6 @@ declare function uuid(): string;
197
51
  * @throws {Error} 长度不在有效范围内时抛出错误
198
52
  */
199
53
  declare function randomId(length?: number): string;
200
- interface DebounceOptions {
201
- leading?: boolean;
202
- trailing?: boolean;
203
- maxWait?: number;
204
- }
205
- type DebouncedFunction<T extends AnyFunction> = {
206
- (this: ThisParameterType<T>, ...args: Parameters<T>): ReturnType<T> | undefined;
207
- cancel: () => void;
208
- flush: () => ReturnType<T> | undefined;
209
- };
210
- /**
211
- * 创建防抖函数,延迟调用 `func` 直到自上次调用以来已经过了 `wait` 毫秒。
212
- *
213
- * @template T - 要防抖的函数类型
214
- * @param func - 要防抖的函数
215
- * @param [wait=0] - 延迟时间(毫秒)
216
- * @param [options] - 防抖配置选项
217
- * @param [options.leading=false] - 是否在超时开始时调用(前沿触发)
218
- * @param [options.trailing=true] - 是否在超时结束时调用(后沿触发)
219
- * @param [options.maxWait] - 函数被延迟调用的最大时间
220
- * @returns 新的防抖函数,包含 cancel 和 flush 方法
221
- */
222
- declare function debounce<T extends AnyFunction>(func: T, wait?: number, options?: DebounceOptions): DebouncedFunction<T>;
223
- /**
224
- * 创建节流函数,确保在指定时间间隔内函数只执行一次。
225
- *
226
- * 节流原理:在连续触发事件时,函数在指定时间间隔内只会执行一次。
227
- * 适用于滚动事件、鼠标移动事件等需要限制调用频率的场景。
228
- *
229
- * @template T - 要节流的函数类型
230
- * @param func - 要节流的函数
231
- * @param [wait=0] - 时间间隔(毫秒),在此期间函数只会执行一次
232
- * @param [options] - 节流配置选项
233
- * @param [options.leading=true] - 是否在时间间隔开始时调用(前沿触发)
234
- * @param [options.trailing=true] - 是否在时间间隔结束时调用(后沿触发)
235
- * @returns 新的节流函数,包含 cancel 和 flush 方法
236
- */
237
- declare function throttle<T extends AnyFunction>(func: T, wait?: number, options?: DebounceOptions): DebouncedFunction<T>;
238
54
  //#endregion
239
55
  //#region src/utilities/dom.d.ts
240
56
  type ContainerExpect = 'node' | 'element' | 'array';
@@ -344,11 +160,7 @@ declare function requireContainer<TExpect extends ContainerExpect = 'element'>(c
344
160
  * @returns {boolean}
345
161
  */
346
162
  declare function isRenderableContent(value: unknown): value is RenderableContent;
347
- /**
348
- * 创建通用加载状态节点。
349
- * @returns {HTMLElement}
350
- */
351
- declare function createLoading(): HTMLDivElement;
163
+ declare function normalizeRenderableContentNodes<TContext>(content: unknown, context: TContext): Node[] | null;
352
164
  /**
353
165
  * 根据 CSS 选择器获取第一个匹配的元素。
354
166
  * @param {string} selector CSS 选择器。
@@ -414,6 +226,11 @@ interface IEventManager {
414
226
  declare function createEventManager(): IEventManager;
415
227
  //#endregion
416
228
  //#region src/utilities/http.d.ts
229
+ /**
230
+ * 当前站点 WordPress REST API 根地址。
231
+ * @type {string}
232
+ */
233
+ declare const restUrl: string;
417
234
  /**
418
235
  * 发送 JSON POST 请求并解析 JSON 响应。
419
236
  * @template T - 期望返回的 JSON 数据类型
@@ -423,179 +240,94 @@ declare function createEventManager(): IEventManager;
423
240
  * @returns {Promise<T>} 解析后的 JSON 响应体
424
241
  */
425
242
  declare function postJson<T = unknown>(url: string, body: unknown, options?: Omit<RequestInit, 'method' | 'body'>): Promise<T>;
426
- /**
427
- * 当前站点 WordPress REST API 根地址。
428
- * @type {string}
429
- */
430
- declare const restUrl: string;
431
243
  //#endregion
432
- //#region src/utilities/storage.d.ts
433
- declare function getCookie(name: string): string | null;
434
- declare function setCookie(name: string, value: string, seconds?: number): boolean;
435
- declare function removeCookie(name: string): boolean;
244
+ //#region src/utilities/object.d.ts
245
+ declare function isPlainObject(obj: unknown): boolean;
436
246
  //#endregion
437
- //#region src/core/Component.d.ts
438
- type ComponentProps = Record<string, unknown>;
439
- type ComponentState = Record<string, unknown>;
440
- interface ComponentDOM {
441
- root: Element | null;
442
- [key: string]: unknown;
443
- }
444
- interface ComponentRuntime {
445
- destroyed: boolean;
446
- }
447
- interface ComponentUpdateOptions {
448
- force?: boolean;
449
- }
450
- type ComponentLifecycleEvent = 'init' | 'beforeUpdate' | 'afterUpdate' | 'destroy';
451
- type ComponentEventName = string;
452
- type ComponentListener = (...args: unknown[]) => void;
453
- type ComponentListeners = Record<ComponentLifecycleEvent, ComponentListener[]> & Record<string, ComponentListener[] | undefined>;
454
- type ComponentCleanup = void | (() => void) | {
455
- destroy: () => void;
456
- };
457
- type ComponentPluginOptions = Record<string, unknown> | undefined;
458
- type ComponentPlugin<TComponent = Component> = ((instance: TComponent, options?: ComponentPluginOptions) => ComponentCleanup) | {
459
- install: (instance: TComponent, options?: ComponentPluginOptions) => ComponentCleanup;
460
- };
461
- interface ComponentCleanupRegistry {
462
- events: ReturnType<typeof createEventManager>;
463
- plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
464
- [key: string]: unknown;
465
- }
247
+ //#region src/utilities/timer.d.ts
466
248
  /**
467
- * 轻量级组件基类,集成 vanilla-signal 响应式状态和插件系统
468
- * 为所有 UI 组件提供统一的状态管理、生命周期钩子和插件支持
249
+ * 定时器管理器
469
250
  */
470
- declare class Component<TProps extends ComponentProps = ComponentProps, TState extends ComponentState = ComponentState, TDOM extends ComponentDOM = ComponentDOM> {
471
- /** 全局插件注册表,所有新创建的组件实例会自动安装这些插件 */
472
- static globalPlugins: Map<string, ComponentPlugin<Component<ComponentProps, ComponentState, ComponentDOM>>>;
473
- /** 组件属性配置对象 */
474
- props: TProps;
475
- /** DOM 引用容器,存储根元素及其他 DOM 节点引用 */
476
- dom: TDOM;
477
- /** 已安装的插件映射表 */
478
- plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
479
- /** 资源清理管理器,包含事件监听器和插件的清理函数 */
480
- cleanup: ComponentCleanupRegistry;
481
- /** 内部事件监听器注册表,用于生命周期和自定义事件 */
482
- protected _listeners: ComponentListeners;
483
- /** 响应式状态存储,使用 vanilla-signal 的深层响应式 store */
484
- state: TState | null;
485
- /** 运行时状态标记 */
486
- runtime: ComponentRuntime;
487
- /**
488
- * @param {Object} props - 组件初始属性配置
489
- */
490
- constructor(props?: TProps);
491
- /**
492
- * 获取组件的根 DOM 元素
493
- * @returns {HTMLElement|null} 根 DOM 元素或 null
494
- */
495
- get root(): Element | null;
496
- /**
497
- * 设置组件的根 DOM 元素
498
- * @param {HTMLElement} value - 要设置的根 DOM 元素
499
- */
500
- set root(value: Element | null);
501
- /**
502
- * 安装实例插件
503
- * 插件可以是函数形式 plugin(instance, options) 或对象形式 { install(instance, options) }
504
- * 插件应返回清理函数或清理对象,在组件销毁时自动执行
505
- * @param {Function|Object} plugin - 插件函数或包含 install 方法的插件对象
506
- * @param {Object} [options] - 插件配置选项
507
- * @returns {Component} 返回当前实例,支持链式调用
508
- */
509
- use(plugin: ComponentPlugin<this> | null | undefined, options?: ComponentPluginOptions): this;
510
- /**
511
- * 注册事件监听器
512
- * 用于监听组件生命周期事件(init、beforeUpdate、afterUpdate、destroy)或自定义事件
513
- * @param {string} event - 事件名称
514
- * @param {Function} callback - 事件回调函数
515
- * @returns {Component} 返回当前实例,支持链式调用
516
- */
517
- on(event: ComponentEventName, callback: ComponentListener): this;
518
- /**
519
- * 移除事件监听器
520
- * @param {string} event - 事件名称
521
- * @param {Function} callback - 要移除的回调函数引用
522
- * @returns {Component} 返回当前实例,支持链式调用
523
- */
524
- off(event: ComponentEventName, callback: ComponentListener): this;
525
- /**
526
- * 安装全局插件到当前实例
527
- * 遍历全局插件注册表并依次安装
528
- * @private
529
- */
530
- installGlobalPlugins(): void;
531
- /**
532
- * 注册全局插件
533
- * 所有之后创建的组件实例都会自动安装此插件
534
- * @static
535
- * @param {string} name - 插件名称标识
536
- * @param {Function|Object} plugin - 插件函数或插件对象
537
- */
538
- static useGlobal(name: string | null | undefined, plugin: ComponentPlugin<Component> | null | undefined): void;
539
- /**
540
- * 触发指定事件,执行所有注册的监听器
541
- * @param {string} event - 事件名称
542
- * @param {...*} args - 传递给监听器的参数
543
- * @returns {Component} 返回当前实例,支持链式调用
544
- */
545
- emit(event: ComponentEventName, ...args: unknown[]): this;
546
- /**
547
- * 初始化组件
548
- * 合并传入的属性,调用 onInit 钩子(如果存在),并触发 init 事件
549
- * @param {Object} [props={}] - 初始化属性配置
550
- * @returns {Component} 返回当前实例,支持链式调用
551
- * @throws {Error} 如果组件已被销毁则抛出异常
552
- */
553
- init(props?: Partial<TProps> | null | undefined): this;
554
- /**
555
- * 批量更新响应式状态
556
- * 支持两种调用方式:setState(key, value) 或 setState({ key1: value1, key2: value2 })
557
- * 使用 flushSync 确保状态更新的同步性和批量处理
558
- * @param {string|Object} keyOrPatch - 状态键名或包含多个键值对的补丁对象
559
- * @param {*} [value] - 当第一个参数为字符串时的状态值
560
- * @returns {Component} 返回当前实例,支持链式调用
561
- * @throws {Error} 如果组件已被销毁或参数格式不正确则抛出异常
562
- */
563
- setState(patch?: Partial<TState> | null): this;
564
- setState<TKey extends keyof TState>(key: TKey, value: TState[TKey]): this;
251
+ declare const timer: {
252
+ timers: Record<string, ReturnType<typeof setTimeout>>;
565
253
  /**
566
- * 更新组件属性和触发更新生命周期
567
- * 合并新的属性配置,触发 beforeUpdate 和 afterUpdate 事件
568
- * 子类可以重写 onUpdate 方法实现自定义更新逻辑
569
- * @param {Object} [propsPatch={}] - 要合并的属性补丁对象
570
- * @param {Object} [options] - 更新选项
571
- * @param {boolean} [options.force=false] - 是否强制更新(由子类处理)
572
- * @returns {Component} 返回当前实例,支持链式调用
573
- * @throws {Error} 如果组件已被销毁则抛出异常
254
+ * 注册并开始一个定时器
255
+ * @param {string} key - 定时器的唯一标识
256
+ * @param {number} duration - 延迟执行的时间(毫秒)
257
+ * @param {function} callback - 延迟执行的回调函数
574
258
  */
575
- update(propsPatch?: Partial<TProps> | null | undefined, { force }?: ComponentUpdateOptions): this;
259
+ start(key: string, duration: number, callback: () => void): void;
576
260
  /**
577
- * 销毁组件实例
578
- * 执行 onDestroy 钩子,触发 destroy 事件,清理所有插件和资源
579
- * 这是组件生命周期的最后一步,销毁后实例不可再使用
261
+ * 明确注销一个定时器
262
+ * @param {string} key - 需要取消的定时器唯一标识
580
263
  */
581
- destroy(): void;
582
- protected onInit?(props: TProps): void;
583
- protected onUpdate?(propsPatch: Partial<TProps> | null | undefined, options: Required<ComponentUpdateOptions>): void;
584
- protected onDestroy?(): void;
585
- }
264
+ cancel(key: string): void;
265
+ };
586
266
  //#endregion
587
- //#region src/components/icons.d.ts
588
- type IconPathMap = Record<string, string>;
589
- type IconName = string;
590
- type IconAttributeValue = string | number | boolean | null | undefined;
591
- interface IconProps {
592
- className?: IconAttributeValue;
593
- [attribute: string]: IconAttributeValue;
594
- }
595
- /**
596
- * 获取内置 SVG 图标节点。
597
- *
598
- * 返回值是 SVGElement,可直接作为 vanilla-signal jsx/html/render 的 children 使用。
267
+ //#region src/utilities/types.d.ts
268
+ type LooseRecord = Record<string, unknown>;
269
+ type ValueTypeName = string;
270
+ type TypeRule = ValueTypeName | readonly ValueTypeName[];
271
+ declare function isNilValue(value: unknown): value is null | undefined;
272
+ declare function isDomNodeValue(value: unknown): value is Node;
273
+ declare function isDomElementValue(value: unknown): value is Element;
274
+ declare function isHtmlElementValue(value: unknown): value is HTMLElement;
275
+ declare function isRenderablePrimitive(value: unknown): value is string | number | boolean;
276
+ declare function isRenderableValue(value: unknown): boolean;
277
+ declare const getType: (val: unknown) => string;
278
+ type ValidateCondition = ((value: unknown) => boolean) | {
279
+ test: (value: unknown) => boolean;
280
+ message?: string;
281
+ };
282
+ interface NormalizeContext<TInput extends LooseRecord = LooseRecord> {
283
+ key: string;
284
+ input: TInput;
285
+ options: LooseRecord;
286
+ schema: ResolveSchema<TInput>;
287
+ }
288
+ interface ParamRule<TInput extends LooseRecord = LooseRecord> {
289
+ type?: TypeRule;
290
+ types?: TypeRule;
291
+ required?: boolean;
292
+ enum?: readonly unknown[];
293
+ nonEmpty?: boolean;
294
+ minLength?: number;
295
+ maxLength?: number;
296
+ finite?: boolean;
297
+ integer?: boolean;
298
+ min?: number;
299
+ max?: number;
300
+ greaterThan?: number;
301
+ lessThan?: number;
302
+ plain?: boolean;
303
+ items?: ParamRuleInput;
304
+ shape?: ResolveSchema;
305
+ conditions?: ValidateCondition | readonly ValidateCondition[];
306
+ validate?: (value: unknown) => boolean;
307
+ message?: string;
308
+ normalize?: (value: unknown, context: NormalizeContext<TInput>) => unknown;
309
+ default?: unknown;
310
+ factory?: boolean;
311
+ [key: string]: unknown;
312
+ }
313
+ type ParamRuleInput<TInput extends LooseRecord = LooseRecord> = TypeRule | ParamRule<TInput>;
314
+ type ResolveSchema<TInput extends LooseRecord = LooseRecord> = Record<string, ParamRuleInput<TInput>>;
315
+ type ResolvedProps<TSchema extends object> = LooseRecord & { [Key in keyof TSchema]: unknown; };
316
+ declare function validateParam<TInput extends LooseRecord = LooseRecord>(name: string, value: unknown, rule?: ParamRuleInput<TInput>, namespace?: string): unknown;
317
+ declare function resolveProps<TInput extends LooseRecord, TSchema extends ResolveSchema<TInput>>(input?: TInput | null | undefined, schema?: TSchema, namespace?: string): TInput & ResolvedProps<TSchema>;
318
+ //#endregion
319
+ //#region src/primitives/icons.d.ts
320
+ type IconPathMap = Record<string, string>;
321
+ type IconName = string;
322
+ type IconAttributeValue = string | number | boolean | null | undefined;
323
+ interface IconProps {
324
+ className?: IconAttributeValue;
325
+ [attribute: string]: IconAttributeValue;
326
+ }
327
+ /**
328
+ * 获取内置 SVG 图标节点。
329
+ *
330
+ * 返回值是 SVGElement,可直接作为 vanilla-signal jsx/html/render 的 children 使用。
599
331
  * @param {string} name 图标名称。
600
332
  * @param {object} [props={}] SVG 属性。
601
333
  * @returns {SVGElement}
@@ -625,140 +357,130 @@ declare function getRegistedIconPath(): IconPathMap;
625
357
  */
626
358
  declare function addIcons(svgPathObjects: IconPathMap): void;
627
359
  //#endregion
628
- //#region src/locales/index.d.ts
629
- declare const _default: {
630
- en: {
631
- b: string;
632
- t: string;
633
- sm: string;
634
- md: string;
635
- lg: string;
636
- };
637
- zh: {
638
- b: string;
639
- t: string;
640
- Primary: string;
641
- Radius: string;
642
- Shadow: string;
643
- Font: string;
644
- Mode: string;
645
- Gray: string;
646
- Olive: string;
647
- Tomato: string;
648
- Ruby: string;
649
- Pink: string;
650
- Violet: string;
651
- Indigo: string;
652
- Blue: string;
653
- Teal: string;
654
- Grass: string;
655
- Mint: string;
656
- Lime: string;
657
- Yellow: string;
658
- Orange: string;
659
- Gold: string;
660
- None: string;
661
- sm: string;
662
- md: string;
663
- lg: string;
664
- XL: string;
665
- Round: string;
666
- Light: string;
667
- Dark: string;
668
- Auto: string;
669
- Close: string;
670
- Confirm: string;
671
- };
672
- };
360
+ //#region src/primitives/loading.d.ts
361
+ /**
362
+ * 创建通用加载状态节点
363
+ * 定位 absolute 撑满父元素 居中 背景模糊滤镜
364
+ * @returns {HTMLElement}
365
+ */
366
+ declare function createLoading(): HTMLDivElement;
673
367
  //#endregion
674
- //#region src/components/theme.d.ts
675
- type ThemeConfigKey = 'mode' | 'theme' | 'radius' | 'shadow' | 'font';
676
- interface ThemeClassNames {
677
- panel: string;
678
- closeWrap: string;
679
- closeButton: string;
680
- title: string;
681
- description: string;
368
+ //#region src/primitives/popup.d.ts
369
+ interface PopupProps extends Record<string, unknown> {
370
+ className?: string;
371
+ position?: string;
372
+ component?: string;
373
+ labelledby?: string;
374
+ content?: RenderableContent;
375
+ }
376
+ declare function createPopup(props?: PopupProps): HTMLElement;
377
+ //#endregion
378
+ //#region src/primitives/drop.d.ts
379
+ type DropMode$1 = 'hover' | 'click';
380
+ type DropPosition$1 = 'auto' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left' | 'right';
381
+ interface DropClassNames {
382
+ root: string;
682
383
  container: string;
683
- item: string;
684
- itemTitle: string;
685
- items: string;
686
- button: string;
687
- active: string;
688
- prefix: string;
689
- swatch: string;
690
- buttonText: string;
691
384
  }
692
- type ThemeClassNameConfig = Partial<ThemeClassNames>;
693
- interface ThemeOptions extends Record<string, unknown> {
694
- mode?: string;
695
- theme?: string;
696
- radius?: string;
697
- shadow?: string;
698
- font?: string;
699
- key?: string;
700
- className?: ThemeClassNameConfig;
385
+ type DropClassNameConfig = Partial<DropClassNames>;
386
+ interface DropDelay$1 {
387
+ show?: number;
388
+ hide?: number;
701
389
  }
702
- interface ThemePanelGroup {
703
- title: string;
704
- type: ThemeConfigKey;
705
- buttons: Array<[string, string]>;
390
+ interface DropProps extends Record<string, unknown> {
391
+ name?: string | null;
392
+ mode?: DropMode$1;
393
+ position?: DropPosition$1;
394
+ offset?: number;
395
+ content?: RenderableContent<DropInstance$1>;
396
+ className?: DropClassNameConfig;
397
+ id?: string | null;
398
+ delay?: number | DropDelay$1;
399
+ hoverIntent?: boolean;
400
+ onShown?: ((drop: DropInstance$1) => void | Promise<void>) | null;
401
+ onHidden?: ((drop: DropInstance$1) => void | Promise<void>) | null;
706
402
  }
707
- interface ResolvedThemeOptions {
708
- mode: string;
709
- theme: string;
710
- radius: string;
711
- shadow: string;
712
- font: string;
713
- key: string;
714
- className: ThemeClassNames;
403
+ interface DropDom {
404
+ root: HTMLElement | null;
715
405
  }
716
- interface ThemeCleanup {
717
- bindings: Set<() => void>;
718
- events: IEventManager;
406
+ interface DropInstance$1 {
407
+ target: Element | null;
408
+ props: Record<string, unknown> | null;
409
+ dom: DropDom;
410
+ isVisible: boolean;
411
+ delayShow: number;
412
+ delayHide: number;
413
+ show(useDelay?: boolean): void;
414
+ hide(useDelay?: boolean): void;
415
+ toggle(): void;
416
+ destroy(): void;
719
417
  }
720
- /**
721
- * 主题管理组件。
722
- *
723
- * 负责主题配置的实例化、主题面板交互和 Cookie 读写。实例初始化不修改 html
724
- * 类名,仅在面板点击交互时同步当前点击项对应的 html class。
725
- */
726
- declare class Theme {
727
- props: ResolvedThemeOptions;
728
- languages: typeof _default;
729
- cleanup: ThemeCleanup | null;
730
- runtime: {
731
- destroyed: boolean;
732
- };
733
- constructor(options?: ThemeOptions);
734
- private init;
735
- private translate;
736
- private loadConfig;
737
- private saveConfig;
738
- private scheme;
739
- private bindActiveButtons;
740
- private bindEvent;
741
- private unbindEvent;
742
- createPanel(containerClass?: string | null, panelConfig?: ThemePanelGroup[] | null): HTMLElement;
743
- setConfig(newConfig: ThemeOptions): void;
418
+ declare function createDrop(element: DOMReference, props?: DropProps): DropInstance$1;
419
+ //#endregion
420
+ //#region src/primitives/tooltip.d.ts
421
+ type DropInstance = ReturnType<typeof createDrop>;
422
+ type DropMode = 'hover' | 'click';
423
+ type DropPosition = 'auto' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left' | 'right';
424
+ interface DropDelay {
425
+ show?: number;
426
+ hide?: number;
427
+ }
428
+ interface TooltipDom {
429
+ root: HTMLElement | null;
430
+ }
431
+ interface TooltipInstance {
432
+ dom: TooltipDom;
433
+ drop: DropInstance | null;
434
+ show(useDelay?: boolean): void;
435
+ hide(useDelay?: boolean): void;
436
+ toggle(): void;
744
437
  destroy(): void;
745
- private defaultPanelConfig;
746
438
  }
439
+ interface TooltipClassNames {
440
+ container: string;
441
+ message: string;
442
+ ui: TooltipThemeClassNames;
443
+ }
444
+ interface TooltipThemeClassNames {
445
+ reverse: string;
446
+ primary: string;
447
+ success: string;
448
+ warning: string;
449
+ error: string;
450
+ }
451
+ type TooltipTheme = false | 'reverse' | 'primary' | 'success' | 'warning' | 'error';
452
+ type TooltipClassNameConfig = Partial<Omit<TooltipClassNames, 'ui'>> & {
453
+ ui?: Partial<TooltipThemeClassNames>;
454
+ };
455
+ interface TooltipProps extends Record<string, unknown> {
456
+ name?: string | null;
457
+ mode?: DropMode;
458
+ position?: DropPosition;
459
+ offset?: number;
460
+ message?: string;
461
+ theme?: TooltipTheme;
462
+ className?: TooltipClassNameConfig;
463
+ id?: string | null;
464
+ delay?: number | DropDelay;
465
+ hoverIntent?: boolean;
466
+ onShown?: ((drop: DropInstance) => void | Promise<void>) | null;
467
+ onHidden?: ((drop: DropInstance) => void | Promise<void>) | null;
468
+ }
469
+ declare function createTooltip(element: DOMReference, props?: TooltipProps): TooltipInstance;
747
470
  //#endregion
748
- //#region src/components/toast.d.ts
471
+ //#region src/primitives/toast.d.ts
749
472
  type ToastType = 'info' | 'success' | 'warning' | 'error' | 'primary';
750
473
  interface ToastClassNames {
751
474
  container: string;
752
475
  toast: string;
753
476
  icon: string;
754
477
  message: string;
755
- hidden: string;
756
478
  lite: string;
757
479
  action: string;
758
480
  actions: string;
759
481
  button: string;
760
- closeButton: string;
761
- actionButton: string;
482
+ closeBtn: string;
483
+ actionBtn: string;
762
484
  info: string;
763
485
  success: string;
764
486
  warning: string;
@@ -804,196 +526,106 @@ declare class Toast {
804
526
  static destroyAll(): void;
805
527
  }
806
528
  //#endregion
807
- //#region src/components/form.d.ts
808
- type FormValue = string | number | boolean;
809
- type FormOptionInput = FormValue | FormOption;
810
- type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
811
- type FormStyle = string | Partial<CSSStyleDeclaration> | null;
812
- type FormDataValue = FormDataEntryValue | FormDataEntryValue[];
813
- type FormDataRecord = Record<string, FormDataValue>;
814
- type FormContainer = Element | DocumentFragment | false | null;
815
- type FormControlType = 'checkbox' | 'custom' | 'radio' | 'select' | 'switch' | 'textarea' | (string & {});
816
- interface FormClassNames {
817
- form: string;
818
- vertical: string;
819
- horizontal: string;
820
- itemVertical: string;
821
- itemHorizontal: string;
529
+ //#region src/primitives/theme.d.ts
530
+ type ThemeConfigKey = 'mode' | 'theme' | 'radius' | 'shadow' | 'font';
531
+ interface ThemeClassNames {
532
+ panel: string;
533
+ title: string;
534
+ container: string;
822
535
  item: string;
823
- label: string;
824
- required: string;
825
- control: string;
826
- helpInvalid: string;
827
- buttons: string;
536
+ itemTitle: string;
537
+ items: string;
828
538
  button: string;
829
- input: string;
830
- textarea: string;
831
- select: string;
832
- radio: string;
833
- checkbox: string;
834
- choiceVertical: string;
835
- choiceHorizontal: string;
836
- choiceGroup: string;
837
- radioLabel: string;
838
- radioText: string;
839
- switch: string;
840
- switchDefault: string;
841
- switchSizeMd: string;
842
- switchSlider: string;
843
- }
844
- type FormClassNameConfig = Partial<FormClassNames>;
845
- interface FormOption {
846
- value?: FormValue | FormDataEntryValue | null;
847
- text?: RenderableContent<Form>;
848
- label?: RenderableContent<Form>;
849
- checked?: boolean;
850
- disabled?: boolean;
851
- }
852
- interface FormField {
853
- id?: string;
854
- label?: RenderableContent<Form> | false;
855
- name?: string;
856
- type?: FormControlType;
857
- options?: readonly FormOptionInput[];
858
- value?: FormDataEntryValue | boolean | readonly FormDataEntryValue[];
859
- checked?: boolean;
860
- required?: boolean;
861
- placeholder?: string;
862
- help?: RenderableContent<Form>;
863
- disabled?: boolean;
864
- readonly?: boolean;
865
- autocomplete?: string;
866
- multiple?: boolean;
867
- vertical?: boolean;
868
- group?: boolean;
869
- size?: string;
870
- variant?: string;
871
- className?: string;
872
- content?: RenderableContent<FormControlContext>;
539
+ active: string;
540
+ prefix: string;
541
+ swatch: string;
542
+ buttonText: string;
873
543
  }
874
- interface FormButton {
875
- type?: string;
876
- text?: RenderableContent<Form>;
877
- label?: RenderableContent<Form>;
544
+ type ThemeClassNameConfig = Partial<ThemeClassNames>;
545
+ interface ThemeOptions extends Record<string, unknown> {
546
+ mode?: string;
878
547
  theme?: string;
879
- action?: string;
880
- disabled?: boolean;
881
- className?: string;
548
+ radius?: string;
549
+ shadow?: string;
550
+ font?: string;
551
+ key?: string;
552
+ className?: ThemeClassNameConfig;
882
553
  }
883
- interface FormValidatorConfig {
884
- rules?: Record<string, Record<string, unknown>>;
885
- messages?: Record<string, Record<string, string>>;
886
- onSubmit?: (() => void) | null;
887
- [key: string]: unknown;
554
+ interface ThemePanelGroup {
555
+ title: string;
556
+ type: ThemeConfigKey;
557
+ buttons: Array<[string, string]>;
888
558
  }
889
- interface FormProps extends Record<string, unknown> {
890
- id?: string | null;
891
- vertical?: boolean;
892
- itemVertical?: boolean;
893
- style?: FormStyle;
894
- fields?: readonly FormField[];
895
- buttons?: boolean | readonly FormButton[];
896
- className?: FormClassNameConfig;
897
- validator?: FormValidatorConfig;
898
- onSubmit?: ((data: FormDataRecord, form: Form) => void | Promise<void>) | null;
899
- onReset?: ((event: Event, form: Form) => void) | null;
559
+ interface ThemeResolvedOptions {
560
+ mode: string;
561
+ theme: string;
562
+ radius: string;
563
+ shadow: string;
564
+ font: string;
565
+ key: string;
566
+ className: ThemeClassNames;
900
567
  }
901
- interface ResolvedFormProps extends Record<string, unknown> {
902
- id: string;
903
- vertical: boolean;
904
- itemVertical: boolean;
905
- style: FormStyle;
906
- fields: FormField[];
907
- buttons: FormButton[];
908
- className: FormClassNames;
909
- validator: FormValidatorConfig;
910
- onSubmit: ((data: FormDataRecord, form: Form) => void | Promise<void>) | null;
911
- onReset: ((event: Event, form: Form) => void) | null;
568
+ interface ThemeInstance {
569
+ props: ThemeResolvedOptions;
570
+ createPanel(containerClass?: string | null, panelConfig?: ThemePanelGroup[] | null): HTMLElement;
571
+ setConfig(newConfig: ThemeOptions): void;
572
+ destroy(): void;
912
573
  }
913
- interface FormState extends ResolvedFormProps {
914
- submitting: boolean;
915
- data: FormDataRecord | null;
574
+ declare function createTheme(options?: ThemeOptions): ThemeInstance;
575
+ //#endregion
576
+ //#region src/primitives/parabola.d.ts
577
+ type ParabolaDirection = 'center' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
578
+ interface ParabolaBallProps {
579
+ color: string;
580
+ size: string;
916
581
  }
917
- interface FormDOM extends ComponentDOM {
918
- root: HTMLFormElement | null;
919
- container: DOMReference | DocumentFragment;
920
- fields: Map<string, FormControlElement>;
582
+ interface ParabolaClassNames {
583
+ ball: string;
921
584
  }
922
- interface FormCache {
923
- initial: ResolvedFormProps;
924
- fieldIds: Map<string | number, string>;
585
+ type ParabolaClassNameConfig = Partial<ParabolaClassNames>;
586
+ interface ParabolaProps extends Record<string, unknown> {
587
+ ball?: ParabolaBallProps;
588
+ className?: ParabolaClassNameConfig;
589
+ from?: DOMReference;
590
+ to?: DOMReference;
591
+ direction?: ParabolaDirection;
592
+ showDelay?: number;
593
+ onShow?: ((parabola: ParabolaInstance) => void) | null;
594
+ onHidden?: ((parabola: ParabolaInstance) => void) | null;
925
595
  }
926
- interface ValidatorInstance {
927
- root: Element | null;
928
- options: FormValidatorConfig & {
929
- onSubmit: null;
930
- };
931
- validate: () => boolean;
932
- reset: () => void;
933
- destroy: () => void;
596
+ interface ResolvedParabolaProps extends Record<string, unknown> {
597
+ ball: ParabolaBallProps;
598
+ className: ParabolaClassNames;
599
+ from: DOMReference;
600
+ to: DOMReference;
601
+ direction: ParabolaDirection;
602
+ showDelay: number;
603
+ onShow: ((parabola: ParabolaInstance) => void) | null;
604
+ onHidden: ((parabola: ParabolaInstance) => void) | null;
934
605
  }
935
- interface FormControlContext {
936
- form: Form;
937
- field: FormField;
938
- index: number;
606
+ interface ParabolaDOM {
607
+ root: HTMLElement | null;
608
+ from: Element | null;
609
+ to: Element | null;
610
+ balls: Set<HTMLElement>;
939
611
  }
940
- declare class Form extends Component<ResolvedFormProps, FormState, FormDOM> {
941
- state: FormState;
942
- validator: ValidatorInstance | null;
943
- cache: FormCache;
944
- constructor(input?: FormProps, container?: DOMReference);
945
- get root(): HTMLFormElement | null;
946
- set root(value: HTMLFormElement | null);
947
- protected onInit(): void;
948
- build(container?: DOMReference): this;
949
- mount(container?: FormContainer): this;
950
- view(): HTMLFormElement;
951
- fieldView(field: FormField, index: number): HTMLElement;
952
- labelView(field: FormField, id: string): HTMLLabelElement | null;
953
- controlView(field: FormField, id: string, index: number): FormControlElement | HTMLElement | Node[] | null;
954
- inputView(field: FormField, id: string): HTMLInputElement;
955
- textareaView(field: FormField, id: string): HTMLTextAreaElement;
956
- selectView(field: FormField, id: string): HTMLSelectElement;
957
- choiceGroupView(field: FormField, id: string, type: 'checkbox' | 'radio'): HTMLElement;
958
- switchView(field: FormField, id: string): HTMLLabelElement;
959
- buttonsView(): HTMLElement | null;
960
- controlProps<TExtra extends Record<string, unknown>>(field: FormField, id: string, extra: TExtra): TExtra & {
961
- name: string | undefined;
962
- id: string;
963
- placeholder: string;
964
- required: boolean;
965
- disabled: boolean;
966
- readonly: boolean;
967
- 'data-form-field': string;
968
- ref: (element: FormControlElement) => void;
969
- };
970
- resolveFieldId(field: FormField, index: number): string;
971
- syncValidator(): void;
972
- validate(): boolean;
973
- reset(): this;
974
- handleSubmit(event: Event): Promise<void>;
975
- handleReset(event: Event): void;
976
- resetValidationState(): void;
977
- collectData(): FormDataRecord;
978
- collectFormData(form: HTMLFormElement): FormDataRecord;
979
- requestSubmit(): this;
980
- update(patch?: Partial<FormProps> | null | undefined, _options?: {}): this;
981
- setFields(fields: readonly FormField[]): this;
982
- resetFields(): this;
983
- cloneProps(props: ResolvedFormProps): ResolvedFormProps;
984
- autoComplete(type: string): string;
985
- isSelected(value: FormField['value'] | undefined, optionValue: FormOption['value']): boolean;
986
- isChecked(value: FormField['value'] | undefined, optionValue: FormOption['value'], checked: boolean | undefined): boolean;
987
- protected onDestroy(): void;
612
+ interface ParabolaRuntime {
613
+ destroyed: boolean;
614
+ }
615
+ interface ParabolaInstance {
616
+ props: ResolvedParabolaProps;
617
+ dom: ParabolaDOM;
618
+ runtime: ParabolaRuntime;
619
+ show(): Promise<boolean>;
620
+ destroy(): void;
988
621
  }
989
- declare function createForm(props?: FormProps, container?: DOMReference): Form;
622
+ declare function createParabola(props?: ParabolaProps): ParabolaInstance;
990
623
  //#endregion
991
- //#region src/components/validator.d.ts
624
+ //#region src/validation/validator.d.ts
992
625
  type ValidatorElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
993
- type ValidatorRuleName = keyof ValidatorRule | string;
994
- type ValidatorMessageMap = Record<string, Partial<Record<ValidatorRuleName, string>>>;
626
+ type ValidatorMessageMap = Record<string, Partial<Record<string, string>>>;
995
627
  type ValidatorCustomResult = boolean | string;
996
- type ValidatorCustomRule = (element: ValidatorElement, validator: Validator) => ValidatorCustomResult;
628
+ type ValidatorCustomRule = (element: ValidatorElement, validator: ValidatorInstance$1) => ValidatorCustomResult;
997
629
  interface ValidatorRule extends Record<string, unknown> {
998
630
  required?: boolean;
999
631
  minLength?: number;
@@ -1015,77 +647,183 @@ interface ValidatorRule extends Record<string, unknown> {
1015
647
  accept?: string;
1016
648
  validate?: ValidatorCustomRule;
1017
649
  }
1018
- interface ValidatorOptions extends Record<string, unknown> {
650
+ interface ValidatorProps extends Record<string, unknown> {
1019
651
  rules?: Record<string, ValidatorRule>;
1020
652
  messages?: ValidatorMessageMap;
1021
- onSubmit?: ((validator: Validator) => void) | null;
653
+ onSubmit?: ((validator: ValidatorInstance$1) => void) | null;
1022
654
  }
1023
- interface ResolvedValidatorOptions extends Record<string, unknown> {
655
+ interface ResolvedValidatorProps extends Record<string, unknown> {
1024
656
  rules: Record<string, ValidatorRule>;
1025
657
  messages: ValidatorMessageMap;
1026
- onSubmit: ((validator: Validator) => void) | null;
658
+ onSubmit: ((validator: ValidatorInstance$1) => void) | null;
659
+ }
660
+ interface ValidatorDOM {
661
+ root: HTMLFormElement | null;
1027
662
  }
1028
663
  interface ValidatorRuntime {
1029
664
  valid: boolean;
1030
665
  message: string;
1031
666
  destroyed: boolean;
1032
667
  }
1033
- interface ValidatorCleanup {
1034
- events: IEventManager;
1035
- }
1036
668
  interface ResetOptions {
1037
669
  native?: boolean;
1038
670
  }
671
+ interface ValidatorInstance$1 {
672
+ dom: ValidatorDOM;
673
+ props: ResolvedValidatorProps | null;
674
+ runtime: ValidatorRuntime;
675
+ validate(): boolean;
676
+ reset(options?: ResetOptions): void;
677
+ destroy(): void;
678
+ }
679
+ declare function createValidator(element: DOMReference, props?: ValidatorProps, bindEvents?: boolean): ValidatorInstance$1;
680
+ //#endregion
681
+ //#region src/core/Component.d.ts
682
+ type ComponentProps = Record<string, unknown>;
683
+ type ComponentState = Record<string, unknown>;
684
+ interface ComponentDOM {
685
+ root: Element | null;
686
+ [key: string]: unknown;
687
+ }
688
+ interface ComponentRuntime {
689
+ destroyed: boolean;
690
+ }
691
+ type ComponentCache = unknown;
692
+ interface ComponentReCreateOptions {
693
+ force?: boolean;
694
+ }
695
+ type ComponentLifecycleEvent = 'init' | 'beforeReCreate' | 'afterReCreate' | 'destroy';
696
+ type ComponentEventName = string;
697
+ type ComponentListener = (...args: unknown[]) => void;
698
+ type ComponentListeners = Record<ComponentLifecycleEvent, ComponentListener[]> & Record<string, ComponentListener[] | undefined>;
699
+ type ComponentCleanup = void | (() => void) | {
700
+ destroy: () => void;
701
+ };
702
+ type ComponentPluginOptions = Record<string, unknown> | undefined;
703
+ type ComponentPlugin<TComponent = Component> = ((instance: TComponent, options?: ComponentPluginOptions) => ComponentCleanup) | {
704
+ install: (instance: TComponent, options?: ComponentPluginOptions) => ComponentCleanup;
705
+ };
706
+ interface ComponentCleanupRegistry {
707
+ events: ReturnType<typeof createEventManager>;
708
+ plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
709
+ [key: string]: unknown;
710
+ }
1039
711
  /**
1040
- * 表单校验组件。
1041
- *
1042
- * 支持绑定表单 submit/reset 事件,也可以手动调用 validate/reset。
712
+ * 轻量级组件基类,集成 vanilla-signal 响应式状态和插件系统
713
+ * 为所有 UI 组件提供统一的状态管理、生命周期钩子和插件支持
1043
714
  */
1044
- declare class Validator {
1045
- root: HTMLFormElement | null;
1046
- options: ResolvedValidatorOptions | null;
1047
- runtime: ValidatorRuntime;
1048
- cleanup: ValidatorCleanup | null;
1049
- constructor(element: DOMReference, options?: ValidatorOptions, bindEvents?: boolean);
1050
- private resolveRoot;
1051
- private validateOptions;
1052
- private bindEvents;
1053
- private unbindEvents;
715
+ declare class Component<TProps extends ComponentProps = ComponentProps, TState extends ComponentState = ComponentState, TDOM extends ComponentDOM = ComponentDOM, TCache = ComponentCache> {
716
+ /** 全局插件注册表,所有新创建的组件实例会自动安装这些插件 */
717
+ static globalPlugins: Map<string, ComponentPlugin<Component<ComponentProps, ComponentState, ComponentDOM, unknown>>>;
718
+ /** 组件属性配置对象 */
719
+ props: TProps;
720
+ /** DOM 引用容器,存储根元素及其他 DOM 节点引用 */
721
+ dom: TDOM;
722
+ /** 实例缓存容器,存储组件运行时派生数据 */
723
+ cache: TCache;
724
+ /** 已安装的插件映射表 */
725
+ plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
726
+ /** 资源清理管理器,包含事件监听器和插件的清理函数 */
727
+ cleanup: ComponentCleanupRegistry;
728
+ /** 内部事件监听器注册表,用于生命周期和自定义事件 */
729
+ protected _listeners: ComponentListeners;
730
+ /** 响应式状态存储,使用 vanilla-signal 的深层响应式 store */
731
+ state: TState | null;
732
+ /** 运行时状态标记 */
733
+ runtime: ComponentRuntime;
1054
734
  /**
1055
- * 执行表单校验。
735
+ * @param {Object} props - 组件初始属性配置
1056
736
  */
1057
- validate(): boolean;
1058
- private validateRule;
1059
- private hasNativeValidationRule;
1060
- private validateRequired;
1061
- private validateMinLength;
1062
- private validateMaxLength;
1063
- private validateEmail;
1064
- private validateEqualTo;
1065
- private validateCheck;
1066
- private validateSelected;
1067
- private validateMultiple;
1068
- private validateSelectMin;
1069
- private validateSelectMax;
1070
- private validateNoSpace;
1071
- private validatePattern;
1072
- private validateFile;
1073
- private validateMinSize;
1074
- private validateMaxSize;
1075
- private validateAccept;
1076
- private validateCustom;
1077
- private showError;
1078
- private showSuccess;
737
+ constructor(props?: TProps);
738
+ /**
739
+ * 安装实例插件
740
+ * 插件可以是函数形式 plugin(instance, options) 或对象形式 { install(instance, options) }
741
+ * 插件应返回清理函数或清理对象,在组件销毁时自动执行
742
+ * @param {Function|Object} plugin - 插件函数或包含 install 方法的插件对象
743
+ * @param {Object} [options] - 插件配置选项
744
+ * @returns {Component} 返回当前实例,支持链式调用
745
+ */
746
+ use(plugin: ComponentPlugin<this> | null | undefined, options?: ComponentPluginOptions): this;
747
+ /**
748
+ * 注册事件监听器
749
+ * 用于监听组件生命周期事件(init、beforeReCreate、afterReCreate、destroy)或自定义事件
750
+ * @param {string} event - 事件名称
751
+ * @param {Function} callback - 事件回调函数
752
+ * @returns {Component} 返回当前实例,支持链式调用
753
+ */
754
+ on(event: ComponentEventName, callback: ComponentListener): this;
755
+ /**
756
+ * 移除事件监听器
757
+ * @param {string} event - 事件名称
758
+ * @param {Function} callback - 要移除的回调函数引用
759
+ * @returns {Component} 返回当前实例,支持链式调用
760
+ */
761
+ off(event: ComponentEventName, callback: ComponentListener): this;
762
+ /**
763
+ * 安装全局插件到当前实例
764
+ * 遍历全局插件注册表并依次安装
765
+ * @private
766
+ */
767
+ installGlobalPlugins(): void;
768
+ /**
769
+ * 注册全局插件
770
+ * 所有之后创建的组件实例都会自动安装此插件
771
+ * @static
772
+ * @param {string} name - 插件名称标识
773
+ * @param {Function|Object} plugin - 插件函数或插件对象
774
+ */
775
+ static useGlobal(name: string | null | undefined, plugin: ComponentPlugin<Component> | null | undefined): void;
776
+ /**
777
+ * 触发指定事件,执行所有注册的监听器
778
+ * @param {string} event - 事件名称
779
+ * @param {...*} args - 传递给监听器的参数
780
+ * @returns {Component} 返回当前实例,支持链式调用
781
+ */
782
+ emit(event: ComponentEventName, ...args: unknown[]): this;
783
+ /**
784
+ * 初始化组件
785
+ * 合并传入的属性,调用 onInit 钩子(如果存在),并触发 init 事件
786
+ * @param {Object} [props={}] - 初始化属性配置
787
+ * @returns {Component} 返回当前实例,支持链式调用
788
+ * @throws {Error} 如果组件已被销毁则抛出异常
789
+ */
790
+ init(props?: Partial<TProps> | null | undefined): this;
791
+ /**
792
+ * 批量更新响应式状态
793
+ * 支持两种调用方式:setState(key, value) 或 setState({ key1: value1, key2: value2 })
794
+ * 使用 flushSync 确保状态更新的同步性和批量处理
795
+ * @param {string|Object} keyOrPatch - 状态键名或包含多个键值对的补丁对象
796
+ * @param {*} [value] - 当第一个参数为字符串时的状态值
797
+ * @returns {Component} 返回当前实例,支持链式调用
798
+ * @throws {Error} 如果组件已被销毁或参数格式不正确则抛出异常
799
+ */
800
+ setState(patch?: Partial<TState> | null): this;
801
+ setState<TKey extends keyof TState>(key: TKey, value: TState[TKey]): this;
1079
802
  /**
1080
- * 重置表单与校验状态。
803
+ * 根据新的 props 重新创建组件实例并触发生命周期
804
+ * 合并新的属性配置,触发 beforeReCreate 和 afterReCreate 事件
805
+ * 子类可以重写 onReCreate 方法实现自定义重建前逻辑
806
+ * @param {Object} [propsPatch={}] - 要合并的属性补丁对象
807
+ * @param {Object} [options] - 更新选项
808
+ * @param {boolean} [options.force=false] - 是否强制更新(由子类处理)
809
+ * @returns {Component} 返回新创建的实例
810
+ * @throws {Error} 如果组件已被销毁则抛出异常
1081
811
  */
1082
- reset({ native }?: ResetOptions): void;
812
+ reCreate(propsPatch?: Partial<TProps> | null | undefined, { force }?: ComponentReCreateOptions): this;
813
+ protected createInstance(props: TProps): this;
1083
814
  /**
1084
- * 销毁当前校验实例。
815
+ * 销毁组件实例
816
+ * 执行 onDestroy 钩子,触发 destroy 事件,清理所有插件和资源
817
+ * 这是组件生命周期的最后一步,销毁后实例不可再使用
1085
818
  */
1086
819
  destroy(): void;
820
+ protected onInit?(props: TProps): void;
821
+ protected onReCreate?(propsPatch: Partial<TProps> | null | undefined, options: Required<ComponentReCreateOptions>): void;
822
+ protected normalizeStatePatch(patch: Partial<TState>): Partial<TState>;
823
+ protected validateStatePatch(patch: Partial<TState>): void;
824
+ protected afterSetState(_patch: Partial<TState>): void;
825
+ protected onDestroy?(): void;
1087
826
  }
1088
- declare function createValidator(element: DOMReference, options?: ValidatorOptions, bindEvents?: boolean): Validator;
1089
827
  //#endregion
1090
828
  //#region src/components/toc.d.ts
1091
829
  interface TocClassNames {
@@ -1107,20 +845,18 @@ interface TocCurrent {
1107
845
  item: TocItem | null;
1108
846
  }
1109
847
  interface TocProps extends Record<string, unknown> {
1110
- container?: DOMReference;
1111
848
  target?: DOMReference;
1112
849
  headings?: string;
1113
850
  offset?: number;
1114
851
  className?: TocClassNameConfig;
1115
- onUpdate?: ((item: TocItem | null, index: number, toc: Toc) => void) | null;
852
+ onChange?: ((item: TocItem | null, index: number, toc: TocInstance) => void) | null;
1116
853
  }
1117
854
  interface ResolvedTocProps extends Record<string, unknown> {
1118
- container: DOMReference;
1119
855
  target: DOMReference;
1120
856
  headings: string;
1121
857
  offset: number;
1122
858
  className: TocClassNames;
1123
- onUpdate: ((item: TocItem | null, index: number, toc: Toc) => void) | null;
859
+ onChange: ((item: TocItem | null, index: number, toc: TocInstance) => void) | null;
1124
860
  }
1125
861
  interface TocState extends Record<string, unknown> {
1126
862
  items: TocItem[];
@@ -1128,7 +864,6 @@ interface TocState extends Record<string, unknown> {
1128
864
  }
1129
865
  interface TocDOM extends ComponentDOM {
1130
866
  root: HTMLElement | null;
1131
- container: Element | null;
1132
867
  target: Element | null;
1133
868
  list: HTMLElement | null;
1134
869
  headings: HTMLHeadingElement[];
@@ -1138,49 +873,13 @@ interface TocRuntime extends ComponentRuntime {
1138
873
  built: boolean;
1139
874
  ticking: boolean;
1140
875
  }
1141
- /**
1142
- * 页面目录组件。
1143
- *
1144
- * 扫描内容区域内的标题,生成锚点列表,并随页面滚动更新 active 状态。
1145
- */
1146
- declare class Toc extends Component<ResolvedTocProps, TocState, TocDOM> {
876
+ type TocInstance = Component<ResolvedTocProps, TocState, TocDOM> & {
1147
877
  runtime: TocRuntime;
1148
- /**
1149
- * 创建 Toc 实例。
1150
- * @param {object} [input={}] Toc 配置。
1151
- */
1152
- constructor(input?: TocProps);
1153
- /**
1154
- * 构建 Toc DOM 和滚动监听。
1155
- * @returns {Toc} 当前实例。
1156
- */
1157
- build(): this;
1158
- private bindEvents;
1159
- private onScroll;
1160
- private onClick;
1161
- private scrollToItem;
1162
- private linkClassName;
1163
- private buildLink;
1164
- private updateActive;
1165
- private setActive;
1166
- /**
1167
- * 重新扫描标题并重建目录列表。
1168
- * @returns {Toc} 当前实例。
1169
- */
1170
- refresh(): this;
1171
- /**
1172
- * 激活并滚动到指定目录项。
1173
- * @param {number} index 目录项索引。
1174
- * @returns {Toc} 当前实例。
1175
- */
1176
- activate(index: number): this;
1177
- /**
1178
- * 销毁实例并清空渲染内容。
1179
- * @private
1180
- */
1181
- protected onDestroy(): void;
1182
- }
1183
- declare function createToc(props?: TocProps): Toc;
878
+ build(): TocInstance;
879
+ refresh(): TocInstance;
880
+ activate(index: number): TocInstance;
881
+ };
882
+ declare function createToc(props?: TocProps): TocInstance;
1184
883
  //#endregion
1185
884
  //#region src/components/sticky.d.ts
1186
885
  type StickyOverflow = 'destroy' | 'ignore';
@@ -1191,7 +890,7 @@ interface StickyProps extends Record<string, unknown> {
1191
890
  top?: number;
1192
891
  gap?: number;
1193
892
  overflow?: StickyOverflow;
1194
- onUpdate?: ((sticky: Sticky) => void) | null;
893
+ onRefresh?: ((sticky: StickyInstance) => void) | null;
1195
894
  }
1196
895
  interface ResolvedStickyProps extends Record<string, unknown> {
1197
896
  target: DOMReference;
@@ -1200,15 +899,13 @@ interface ResolvedStickyProps extends Record<string, unknown> {
1200
899
  top: number;
1201
900
  gap: number;
1202
901
  overflow: StickyOverflow;
1203
- onUpdate: ((sticky: Sticky) => void) | null;
902
+ onRefresh: ((sticky: StickyInstance) => void) | null;
1204
903
  }
1205
904
  interface StickyStateItem {
1206
905
  element: HTMLElement;
1207
906
  top: number;
1208
907
  }
1209
908
  interface StickyState extends Record<string, unknown> {
1210
- count: number;
1211
- top: number;
1212
909
  items: StickyStateItem[];
1213
910
  }
1214
911
  interface StickyDOM extends ComponentDOM {
@@ -1216,54 +913,273 @@ interface StickyDOM extends ComponentDOM {
1216
913
  parent: Element | null;
1217
914
  targets: HTMLElement[];
1218
915
  }
1219
- interface StickyRuntimeItem {
916
+ interface StickyOriginalStyle {
1220
917
  element: HTMLElement;
1221
- top: number;
1222
918
  originalPosition: string;
1223
919
  originalTop: string;
1224
920
  originalZIndex: string;
1225
921
  }
1226
922
  interface StickyRuntime extends ComponentRuntime {
1227
- active: boolean;
1228
923
  built: boolean;
1229
- ignored: boolean;
1230
- items: StickyRuntimeItem[];
1231
924
  }
1232
- /**
1233
- * Sticky 吸附组件。
1234
- *
1235
- * 用于给一个或多个元素应用 `position: sticky`,并按顺序计算 `top`
1236
- * 偏移,适合页面侧边栏中多个 widget 的堆叠吸附场景。
1237
- */
1238
- declare class Sticky extends Component<ResolvedStickyProps, StickyState, StickyDOM> {
925
+ interface StickyCache {
926
+ originalStyles: StickyOriginalStyle[];
927
+ }
928
+ type StickyInstance = Component<ResolvedStickyProps, StickyState, StickyDOM, StickyCache> & {
1239
929
  runtime: StickyRuntime;
1240
- /**
1241
- * 创建 Sticky 实例。
1242
- * @param {object} [input={}] Sticky 配置。
1243
- */
1244
- constructor(input?: StickyProps);
1245
- /**
1246
- * 构建 Sticky 行为并应用样式。
1247
- * @returns {Sticky} 当前实例。
1248
- */
930
+ build(): StickyInstance;
931
+ refresh(): StickyInstance;
932
+ };
933
+ declare function createSticky(props?: StickyProps): StickyInstance;
934
+ //#endregion
935
+ //#region src/components/accordion.d.ts
936
+ type AccordionActive = number | string | Array<number | string> | null;
937
+ interface AccordionClassNames {
938
+ root: string;
939
+ header: string;
940
+ title: string;
941
+ arrow: string;
942
+ panel: string;
943
+ content: string;
944
+ }
945
+ type AccordionClassNameConfig = Partial<AccordionClassNames>;
946
+ interface AccordionItem extends Record<string, unknown> {
947
+ name?: string;
948
+ title: RenderableContent<AccordionContentContext>;
949
+ content: RenderableContent<AccordionContentContext>;
950
+ }
951
+ interface AccordionProps extends Record<string, unknown> {
952
+ id?: string | null;
953
+ active?: AccordionActive;
954
+ collapsible?: boolean;
955
+ multiple?: boolean;
956
+ className?: AccordionClassNameConfig;
957
+ items: AccordionItem[];
958
+ onChange?: ((index: number, name: string, header: HTMLElement, panel: HTMLElement, accordion: AccordionInstance) => void | Promise<void>) | null;
959
+ }
960
+ interface ResolvedAccordionProps extends Record<string, unknown> {
961
+ id: string;
962
+ active: AccordionActive;
963
+ collapsible: boolean;
964
+ multiple: boolean;
965
+ className: AccordionClassNames;
966
+ items: AccordionItem[];
967
+ onChange: NonNullable<AccordionProps['onChange']> | null;
968
+ }
969
+ interface AccordionCurrent {
970
+ index: number | null;
971
+ name: string | null;
972
+ }
973
+ interface AccordionState extends Record<string, unknown> {
974
+ items: AccordionItem[];
975
+ activeNames: string[];
976
+ current: AccordionCurrent;
977
+ }
978
+ interface AccordionDOM extends ComponentDOM {
979
+ root: HTMLElement | null;
980
+ headers: HTMLElement[];
981
+ panels: HTMLElement[];
982
+ }
983
+ interface AccordionRuntime extends ComponentRuntime {
984
+ built: boolean;
985
+ }
986
+ interface AccordionContentContext {
987
+ accordion: AccordionInstance;
988
+ item: AccordionItem;
989
+ index: number;
990
+ type: 'title' | 'content';
991
+ active: boolean;
992
+ }
993
+ type AccordionInstance = Component<ResolvedAccordionProps, AccordionState, AccordionDOM> & {
994
+ runtime: AccordionRuntime;
995
+ state: AccordionState;
996
+ build(): AccordionInstance;
997
+ isActive(name: string): boolean;
998
+ getIndex(value: number | string | undefined | null): number;
999
+ activate(value: number | string | undefined): Promise<void>;
1000
+ };
1001
+ declare function createAccordion(props: AccordionProps): AccordionInstance;
1002
+ //#endregion
1003
+ //#region src/components/form.d.ts
1004
+ type FormValue = string | number | boolean;
1005
+ type FormOptionInput = FormValue | FormOption;
1006
+ type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
1007
+ type FormStyle = string | Partial<CSSStyleDeclaration> | null;
1008
+ type FormDataValue = FormDataEntryValue | FormDataEntryValue[];
1009
+ type FormDataRecord = Record<string, FormDataValue>;
1010
+ type FormControlType = 'checkbox' | 'custom' | 'radio' | 'select' | 'switch' | 'textarea' | (string & {});
1011
+ interface FormClassNames {
1012
+ form: string;
1013
+ vertical: string;
1014
+ horizontal: string;
1015
+ itemVertical: string;
1016
+ itemHorizontal: string;
1017
+ item: string;
1018
+ label: string;
1019
+ required: string;
1020
+ control: string;
1021
+ helpInvalid: string;
1022
+ buttons: string;
1023
+ button: string;
1024
+ input: string;
1025
+ textarea: string;
1026
+ select: string;
1027
+ radio: string;
1028
+ checkbox: string;
1029
+ choiceVertical: string;
1030
+ choiceHorizontal: string;
1031
+ choiceGroup: string;
1032
+ radioLabel: string;
1033
+ radioText: string;
1034
+ switch: string;
1035
+ switchDefault: string;
1036
+ switchSizeMd: string;
1037
+ switchSlider: string;
1038
+ }
1039
+ type FormClassNameConfig = Partial<FormClassNames>;
1040
+ interface FormOption {
1041
+ value?: FormValue | FormDataEntryValue | null;
1042
+ text?: RenderableContent<Form>;
1043
+ label?: RenderableContent<Form>;
1044
+ checked?: boolean;
1045
+ disabled?: boolean;
1046
+ }
1047
+ interface FormField {
1048
+ id?: string;
1049
+ label?: RenderableContent<Form> | false;
1050
+ name?: string;
1051
+ type?: FormControlType;
1052
+ options?: readonly FormOptionInput[];
1053
+ value?: FormDataEntryValue | boolean | readonly FormDataEntryValue[];
1054
+ checked?: boolean;
1055
+ required?: boolean;
1056
+ placeholder?: string;
1057
+ help?: RenderableContent<Form>;
1058
+ disabled?: boolean;
1059
+ readonly?: boolean;
1060
+ autocomplete?: string;
1061
+ multiple?: boolean;
1062
+ vertical?: boolean;
1063
+ group?: boolean;
1064
+ size?: string;
1065
+ variant?: string;
1066
+ className?: string;
1067
+ content?: RenderableContent<FormControlContext>;
1068
+ }
1069
+ interface FormButton {
1070
+ type?: string;
1071
+ text?: RenderableContent<Form>;
1072
+ label?: RenderableContent<Form>;
1073
+ theme?: string;
1074
+ action?: string;
1075
+ disabled?: boolean;
1076
+ className?: string;
1077
+ }
1078
+ interface FormValidatorConfig {
1079
+ rules?: Record<string, Record<string, unknown>>;
1080
+ messages?: Record<string, Record<string, string>>;
1081
+ onSubmit?: (() => void) | null;
1082
+ [key: string]: unknown;
1083
+ }
1084
+ interface FormProps extends Record<string, unknown> {
1085
+ id?: string | null;
1086
+ vertical?: boolean;
1087
+ itemVertical?: boolean;
1088
+ style?: FormStyle;
1089
+ fields?: readonly FormField[];
1090
+ buttons?: boolean | readonly FormButton[];
1091
+ className?: FormClassNameConfig;
1092
+ validator?: FormValidatorConfig;
1093
+ onSubmit?: ((data: FormDataRecord, form: Form) => void | Promise<void>) | null;
1094
+ onReset?: ((event: Event, form: Form) => void) | null;
1095
+ }
1096
+ interface ResolvedFormProps extends Record<string, unknown> {
1097
+ id: string;
1098
+ vertical: boolean;
1099
+ itemVertical: boolean;
1100
+ style: FormStyle;
1101
+ fields: FormField[];
1102
+ buttons: FormButton[];
1103
+ className: FormClassNames;
1104
+ validator: FormValidatorConfig;
1105
+ onSubmit: ((data: FormDataRecord, form: Form) => void | Promise<void>) | null;
1106
+ onReset: ((event: Event, form: Form) => void) | null;
1107
+ }
1108
+ interface FormState extends ResolvedFormProps {
1109
+ submitting: boolean;
1110
+ data: FormDataRecord | null;
1111
+ }
1112
+ interface FormDOM extends ComponentDOM {
1113
+ root: HTMLFormElement | null;
1114
+ fields: Map<string, FormControlElement>;
1115
+ }
1116
+ interface FormCache {
1117
+ initial: ResolvedFormProps;
1118
+ fieldIds: Map<string | number, string>;
1119
+ }
1120
+ interface ValidatorInstance {
1121
+ dom: {
1122
+ root: Element | null;
1123
+ };
1124
+ props: (FormValidatorConfig & {
1125
+ onSubmit: null;
1126
+ }) | null;
1127
+ validate: () => boolean;
1128
+ reset: () => void;
1129
+ destroy: () => void;
1130
+ }
1131
+ interface FormControlContext {
1132
+ form: Form;
1133
+ field: FormField;
1134
+ index: number;
1135
+ }
1136
+ declare class Form extends Component<ResolvedFormProps, FormState, FormDOM> {
1137
+ state: FormState;
1138
+ validator: ValidatorInstance | null;
1139
+ cache: FormCache;
1140
+ constructor(input?: FormProps);
1141
+ get root(): HTMLFormElement | null;
1142
+ set root(value: HTMLFormElement | null);
1249
1143
  build(): this;
1250
- private captureItems;
1251
- private resolveOverflow;
1252
- private apply;
1253
- private restore;
1254
- /**
1255
- * 重新计算当前实例内所有 sticky 元素的 top。
1256
- * @returns {Sticky} 当前实例。
1257
- */
1258
- refresh(): this;
1259
- destroy(): void;
1260
- /**
1261
- * 销毁实例并恢复被管理元素的原始样式。
1262
- * @private
1263
- */
1144
+ view(): HTMLFormElement;
1145
+ fieldView(field: FormField, index: number): HTMLElement;
1146
+ labelView(field: FormField, id: string): HTMLLabelElement | null;
1147
+ controlView(field: FormField, id: string, index: number): FormControlElement | HTMLElement | Node[] | null;
1148
+ inputView(field: FormField, id: string): HTMLInputElement;
1149
+ textareaView(field: FormField, id: string): HTMLTextAreaElement;
1150
+ selectView(field: FormField, id: string): HTMLSelectElement;
1151
+ choiceGroupView(field: FormField, id: string, type: 'checkbox' | 'radio'): HTMLElement;
1152
+ switchView(field: FormField, id: string): HTMLLabelElement;
1153
+ buttonsView(): HTMLElement | null;
1154
+ controlProps<TExtra extends Record<string, unknown>>(field: FormField, id: string, extra: TExtra): TExtra & {
1155
+ name: string | undefined;
1156
+ id: string;
1157
+ placeholder: string;
1158
+ required: boolean;
1159
+ disabled: boolean;
1160
+ readonly: boolean;
1161
+ 'data-form-field': string;
1162
+ ref: (element: FormControlElement) => void;
1163
+ };
1164
+ resolveFieldId(field: FormField, index: number): string;
1165
+ syncValidator(): void;
1166
+ validate(): boolean;
1167
+ reset(): this;
1168
+ handleSubmit(event: Event): Promise<void>;
1169
+ handleReset(event: Event): void;
1170
+ resetValidationState(): void;
1171
+ collectData(): FormDataRecord;
1172
+ collectFormData(form: HTMLFormElement): FormDataRecord;
1173
+ requestSubmit(): this;
1174
+ setFields(fields: readonly FormField[]): this;
1175
+ resetFields(): this;
1176
+ cloneProps(props: ResolvedFormProps): ResolvedFormProps;
1177
+ autoComplete(type: string): string;
1178
+ isSelected(value: FormField['value'] | undefined, optionValue: FormOption['value']): boolean;
1179
+ isChecked(value: FormField['value'] | undefined, optionValue: FormOption['value'], checked: boolean | undefined): boolean;
1264
1180
  protected onDestroy(): void;
1265
1181
  }
1266
- declare function createSticky(props?: StickyProps): Sticky;
1182
+ declare function createForm(props?: FormProps): Form;
1267
1183
  //#endregion
1268
1184
  //#region src/components/flow.d.ts
1269
1185
  type FlowData = Record<string, unknown>;
@@ -1271,7 +1187,7 @@ type FlowPayload = FlowData | null;
1271
1187
  type FlowAction = 'next' | 'back' | 'goTo' | 'finish';
1272
1188
  type FlowBusyStrategy = 'ignore' | 'throw';
1273
1189
  type FlowDirection = string;
1274
- type FlowSlotName = 'renderHeader' | 'renderSteps' | 'renderBody' | 'renderFooter';
1190
+ type FlowSlotName = 'renderHeader' | 'renderBody' | 'renderFooter';
1275
1191
  type FlowCleanup = () => void;
1276
1192
  type FlowStepResult = string | {
1277
1193
  id: string;
@@ -1280,8 +1196,6 @@ type FlowStepResult = string | {
1280
1196
  interface FlowClassNames {
1281
1197
  root: string;
1282
1198
  header: string;
1283
- title: string;
1284
- description: string;
1285
1199
  steps: string;
1286
1200
  step: string;
1287
1201
  active: string;
@@ -1292,8 +1206,6 @@ interface FlowClassNames {
1292
1206
  body: string;
1293
1207
  footer: string;
1294
1208
  button: string;
1295
- buttonGhost: string;
1296
- buttonPrimary: string;
1297
1209
  reset: string;
1298
1210
  back: string;
1299
1211
  next: string;
@@ -1302,11 +1214,9 @@ type FlowClassNameConfig = Partial<FlowClassNames>;
1302
1214
  interface FlowStep {
1303
1215
  id: string;
1304
1216
  title?: string;
1305
- description?: string;
1306
1217
  content?: RenderableContent<FlowContext>;
1307
1218
  data?: FlowData;
1308
1219
  modal?: FlowData | ((context: FlowContext) => FlowData | null) | null;
1309
- view?: FlowData;
1310
1220
  onEnter?: FlowLifecycleHook;
1311
1221
  onLeave?: FlowLifecycleHook;
1312
1222
  onNext?: FlowMoveHook;
@@ -1386,7 +1296,7 @@ interface FlowText {
1386
1296
  reset: string;
1387
1297
  [key: string]: string;
1388
1298
  }
1389
- interface FlowOptions extends Record<string, unknown> {
1299
+ interface FlowProps extends Record<string, unknown> {
1390
1300
  id?: string | null;
1391
1301
  steps?: FlowStep[];
1392
1302
  initial?: string | number | null;
@@ -1395,16 +1305,12 @@ interface FlowOptions extends Record<string, unknown> {
1395
1305
  render?: boolean;
1396
1306
  rollbackOnError?: boolean;
1397
1307
  busyStrategy?: FlowBusyStrategy;
1398
- showHeader?: boolean;
1399
- showFooter?: boolean;
1400
- showSteps?: boolean;
1401
1308
  showBack?: boolean;
1402
1309
  showNext?: boolean;
1403
1310
  showReset?: boolean;
1404
1311
  text?: Partial<FlowText>;
1405
1312
  className?: FlowClassNameConfig | string;
1406
1313
  renderHeader?: FlowSlot;
1407
- renderSteps?: FlowSlot;
1408
1314
  renderBody?: FlowSlot;
1409
1315
  renderFooter?: FlowSlot;
1410
1316
  onChange?: FlowChangeHook | null;
@@ -1414,7 +1320,7 @@ interface FlowOptions extends Record<string, unknown> {
1414
1320
  onError?: FlowErrorHook | null;
1415
1321
  onBusy?: FlowBusyHook | null;
1416
1322
  }
1417
- interface ResolvedFlowOptions extends Record<string, unknown> {
1323
+ interface ResolvedFlowProps extends Record<string, unknown> {
1418
1324
  id: string;
1419
1325
  steps: FlowStep[];
1420
1326
  initial: string | number | null;
@@ -1423,16 +1329,12 @@ interface ResolvedFlowOptions extends Record<string, unknown> {
1423
1329
  render: boolean;
1424
1330
  rollbackOnError: boolean;
1425
1331
  busyStrategy: FlowBusyStrategy;
1426
- showHeader: boolean;
1427
- showFooter: boolean;
1428
- showSteps: boolean;
1429
1332
  showBack: boolean;
1430
1333
  showNext: boolean;
1431
1334
  showReset: boolean;
1432
1335
  text: FlowText;
1433
1336
  className: FlowClassNames;
1434
1337
  renderHeader: FlowSlot;
1435
- renderSteps: FlowSlot;
1436
1338
  renderBody: FlowSlot;
1437
1339
  renderFooter: FlowSlot;
1438
1340
  onChange: FlowChangeHook | null;
@@ -1457,7 +1359,19 @@ interface FlowState extends Record<string, unknown> {
1457
1359
  busyAction: FlowAction | null;
1458
1360
  version: number;
1459
1361
  }
1460
- interface FlowGoToOptions {
1362
+ interface FlowDOM {
1363
+ root: HTMLElement | null;
1364
+ header: HTMLElement | null;
1365
+ body: HTMLElement | null;
1366
+ footer: HTMLElement | null;
1367
+ }
1368
+ interface FlowRuntime {
1369
+ built: boolean;
1370
+ destroyed: boolean;
1371
+ activeAction: FlowAction | null;
1372
+ actionController: AbortController | null;
1373
+ }
1374
+ interface FlowGoToOptions {
1461
1375
  direction?: FlowDirection;
1462
1376
  internal?: boolean;
1463
1377
  }
@@ -1470,25 +1384,22 @@ interface FlowRunActionOptions {
1470
1384
  * 适合在 Modal、Offcanvas、页面表单或任意业务组件中复用 next/back/goTo、步骤缓存和生命周期。
1471
1385
  */
1472
1386
  declare class Flow {
1473
- options: ResolvedFlowOptions;
1387
+ props: ResolvedFlowProps;
1474
1388
  steps: FlowStep[];
1475
1389
  state: FlowState;
1476
- root: HTMLElement | null;
1390
+ dom: FlowDOM;
1391
+ runtime: FlowRuntime;
1477
1392
  private stepMap;
1478
1393
  private initialStepId;
1479
1394
  private initialData;
1480
1395
  private subscribers;
1481
1396
  private renderDispose;
1482
1397
  private cleanupTasks;
1483
- private nodes;
1484
- private destroyed;
1485
- private activeAction;
1486
- private actionController;
1487
1398
  /**
1488
1399
  * 创建 Flow 实例。
1489
- * @param {FlowOptions} [options={}] Flow 配置。
1400
+ * @param {FlowProps} [props={}] Flow 配置。
1490
1401
  */
1491
- constructor(options?: FlowOptions);
1402
+ constructor(props?: FlowProps);
1492
1403
  /**
1493
1404
  * 当前步骤。
1494
1405
  * @returns {FlowStep}
@@ -1526,16 +1437,11 @@ declare class Flow {
1526
1437
  */
1527
1438
  snapshot(): FlowSnapshot;
1528
1439
  /**
1529
- * 挂载默认 Flow UI。
1530
- * @param {Element|Node|string|Array} container DOM 容器、选择器或 JSX/h 返回节点。
1531
- * @returns {Flow}
1532
- */
1533
- mount(container: DOMReference): this;
1534
- /**
1535
- * 卸载默认 UI。
1440
+ * 构建默认 Flow UI。
1536
1441
  * @returns {Flow}
1537
1442
  */
1538
- unmount(): this;
1443
+ build(): this;
1444
+ private teardownView;
1539
1445
  /**
1540
1446
  * 前进一步。
1541
1447
  * @param {object|null} [payload=null] 当前步骤需要缓存的数据。
@@ -1630,497 +1536,512 @@ declare class Flow {
1630
1536
  }
1631
1537
  /**
1632
1538
  * 创建 Flow 实例。
1633
- * @param {FlowOptions} options Flow 配置。
1539
+ * @param {FlowProps} props Flow 配置。
1634
1540
  * @returns {Flow}
1635
1541
  */
1636
- declare function createFlow(options?: FlowOptions): Flow;
1637
- //#endregion
1638
- //#region src/components/parabola.d.ts
1639
- type ParabolaDirection = 'center' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
1640
- interface ParabolaBallOptions {
1641
- color: string;
1642
- size: string;
1643
- }
1644
- interface ParabolaClassNames {
1645
- ball: string;
1646
- }
1647
- type ParabolaClassNameConfig = Partial<ParabolaClassNames>;
1648
- interface ParabolaOptions extends Record<string, unknown> {
1649
- ball?: ParabolaBallOptions;
1650
- className?: ParabolaClassNameConfig;
1651
- from?: DOMReference;
1652
- to?: DOMReference;
1653
- direction?: ParabolaDirection;
1654
- showDelay?: number;
1655
- hideDelay?: number;
1656
- onShow?: ((parabola: Parabola) => void) | null;
1657
- onHidden?: ((parabola: Parabola) => void) | null;
1658
- }
1659
- interface ResolvedParabolaOptions extends Record<string, unknown> {
1660
- ball: ParabolaBallOptions;
1661
- className: ParabolaClassNames;
1662
- from: DOMReference;
1663
- to: DOMReference;
1664
- direction: ParabolaDirection;
1665
- showDelay: number;
1666
- hideDelay: number;
1667
- onShow: ((parabola: Parabola) => void) | null;
1668
- onHidden: ((parabola: Parabola) => void) | null;
1669
- }
1670
- /**
1671
- * 抛物线动画组件。
1672
- *
1673
- * 用于实现“加入购物车”等从一个元素飞向另一个元素的小球动画。
1674
- */
1675
- declare class Parabola {
1676
- options: ResolvedParabolaOptions;
1677
- hidden: boolean;
1678
- _ball: HTMLElement | null;
1679
- _animationId: number | null;
1680
- _fromEl: Element | null;
1681
- _toEl: Element | null;
1682
- private showTimerId;
1683
- /**
1684
- * 创建抛物线动画实例。
1685
- * @param {ParabolaOptions} options 动画配置。
1686
- */
1687
- constructor(options?: ParabolaOptions);
1688
- private createBall;
1689
- private calculatePath;
1690
- private easeOutCubic;
1691
- private animate;
1692
- /**
1693
- * 开始播放动画。
1694
- * @returns {Promise<boolean>} 成功开始动画时返回 true;元素缺失或已销毁时返回 false。
1695
- */
1696
- show(): Promise<boolean>;
1697
- /**
1698
- * 销毁动画实例并清理 DOM、定时器和动画帧。
1699
- * @returns {void}
1700
- */
1701
- destroy(): void;
1702
- /**
1703
- * show 的语义化别名。
1704
- * @returns {Promise<boolean>}
1705
- */
1706
- start(): Promise<boolean>;
1707
- }
1708
- declare function createParabola(options?: ParabolaOptions): Parabola;
1542
+ declare function createFlow(props?: FlowProps): Flow;
1709
1543
  //#endregion
1710
- //#region src/components/tabs.d.ts
1711
- type TabsDirection = 'top' | 'bottom' | 'left' | 'right';
1712
- type TabsValue = number | string;
1713
- type TabsDisabled = TabsValue | TabsValue[];
1714
- interface TabsClassNames {
1715
- root: string;
1716
- top: string;
1717
- bottom: string;
1718
- left: string;
1719
- right: string;
1720
- wrap: string;
1721
- list: string;
1722
- tab: string;
1723
- panelWrap: string;
1724
- panel: string;
1725
- disabled: string;
1726
- dragging: string;
1727
- }
1728
- type TabsClassNameConfig = Partial<TabsClassNames>;
1729
- interface TabsPanelContext {
1730
- tabs: Tabs;
1731
- item: TabItem;
1732
- index: number;
1733
- name: string | number;
1734
- }
1735
- interface TabTitleContext {
1736
- tabs: Tabs;
1737
- item: TabItem;
1544
+ //#region src/components/modal.d.ts
1545
+ type ModalTextInput = Partial<ModalText> & Record<string, unknown>;
1546
+ type ModalContent = RenderableContent<Modal>;
1547
+ type FormInstance = ReturnType<typeof createForm>;
1548
+ type ModalMode = 'content' | 'form';
1549
+ interface ModalClassNames {
1550
+ layout: string;
1551
+ modal: string;
1552
+ header: string;
1553
+ body: string;
1554
+ footer: string;
1555
+ title: string;
1556
+ closeBtn: string;
1557
+ cancelBtn: string;
1558
+ confirmBtn: string;
1559
+ button: string;
1738
1560
  }
1739
- type TabPanel = RenderableContent<TabsPanelContext> | ((context: TabsPanelContext) => RenderableContent<TabsPanelContext>) | ((context: TabsPanelContext) => Promise<RenderableContent<TabsPanelContext>>);
1740
- interface TabItem extends Record<string, unknown> {
1741
- name?: string;
1742
- title: RenderableContent<TabTitleContext>;
1743
- panel: TabPanel;
1744
- cache?: boolean;
1745
- ttl?: number;
1561
+ type ModalClassNameConfig = Partial<ModalClassNames>;
1562
+ interface ModalText {
1563
+ title: string;
1564
+ confirm: string;
1565
+ cancel: string;
1746
1566
  }
1747
- interface TabsProps extends Record<string, unknown> {
1567
+ interface ModalProps extends Record<string, unknown> {
1568
+ mode?: ModalMode | null;
1569
+ content?: ModalContent;
1570
+ position?: string;
1571
+ showCancel?: boolean;
1572
+ showClose?: boolean;
1573
+ fullscreen?: boolean;
1574
+ text?: ModalTextInput;
1575
+ onShow?: ((modal: Modal) => void | Promise<void>) | null;
1576
+ onShown?: ((modal: Modal) => void | Promise<void>) | null;
1577
+ onHide?: ((modal: Modal) => void | Promise<void>) | null;
1578
+ onHidden?: ((modal: Modal) => void | Promise<void>) | null;
1579
+ onConfirm?: ((modal: Modal) => void | Promise<void>) | null;
1580
+ onSubmit?: ((data: FormDataRecord, modal: Modal) => void | Promise<void>) | null;
1581
+ onCancel?: ((modal: Modal) => void | Promise<void>) | null;
1582
+ fields?: readonly FormField[] | null;
1583
+ header?: boolean;
1584
+ footer?: boolean;
1748
1585
  id?: string | null;
1749
- direction?: TabsDirection;
1750
- active?: TabsValue;
1751
- disabled?: TabsDisabled;
1752
- onChange?: ((index: number, name: string | number, tab: HTMLElement | undefined, panel: HTMLElement | undefined) => void | Promise<void>) | null;
1753
- tabs?: TabItem[];
1754
- className?: TabsClassNameConfig;
1755
- onAdd?: ((index: number, item: TabItem, tab: HTMLElement | undefined, panel: HTMLElement | undefined) => void | Promise<void>) | null;
1756
- onRemove?: ((index: number, name: string | undefined) => void | Promise<void>) | null;
1586
+ escClose?: boolean;
1587
+ bgClose?: boolean;
1588
+ className?: ModalClassNameConfig;
1757
1589
  }
1758
- interface ResolvedTabsProps extends Record<string, unknown> {
1590
+ interface ResolvedModalProps extends Record<string, unknown> {
1591
+ mode: ModalMode;
1592
+ content: ModalContent;
1593
+ position: string;
1594
+ showCancel: boolean;
1595
+ showClose: boolean;
1596
+ fullscreen: boolean;
1597
+ text: ModalText;
1598
+ onShow: NonNullable<ModalProps['onShow']> | null;
1599
+ onShown: NonNullable<ModalProps['onShown']> | null;
1600
+ onHide: NonNullable<ModalProps['onHide']> | null;
1601
+ onHidden: NonNullable<ModalProps['onHidden']> | null;
1602
+ onConfirm: NonNullable<ModalProps['onConfirm']> | null;
1603
+ onSubmit: NonNullable<ModalProps['onSubmit']> | null;
1604
+ onCancel: NonNullable<ModalProps['onCancel']> | null;
1605
+ fields: FormField[] | null;
1606
+ header: boolean;
1607
+ footer: boolean;
1759
1608
  id: string;
1760
- direction: TabsDirection;
1761
- active: TabsValue;
1762
- disabled: TabsDisabled;
1763
- onChange: NonNullable<TabsProps['onChange']> | null;
1764
- tabs: TabItem[];
1765
- className: TabsClassNames;
1766
- onAdd: NonNullable<TabsProps['onAdd']> | null;
1767
- onRemove: NonNullable<TabsProps['onRemove']> | null;
1609
+ escClose: boolean;
1610
+ bgClose: boolean;
1611
+ className: ModalClassNames;
1768
1612
  }
1769
- interface TabsState extends Record<string, unknown> {
1770
- current: {
1771
- index: number;
1772
- name: string | null;
1773
- };
1774
- disabled: {
1775
- names: string[];
1776
- indexes: number[];
1777
- };
1778
- isVertical: boolean;
1779
- draggable: boolean;
1613
+ interface ModalState extends Record<string, unknown> {
1614
+ mode: ModalMode;
1615
+ content: ModalContent;
1616
+ fields: FormField[] | null;
1780
1617
  loading: boolean;
1618
+ processing: boolean;
1619
+ visible: boolean;
1620
+ data: FormDataRecord | null;
1621
+ extraData: FormDataRecord | null;
1781
1622
  }
1782
- interface TabsDOM extends ComponentDOM {
1623
+ interface ModalDOM extends ComponentDOM {
1783
1624
  root: HTMLElement | null;
1784
- container: Element;
1785
- tabs: HTMLElement[];
1786
- panels: HTMLElement[];
1625
+ modal: HTMLElement | null;
1626
+ header: HTMLElement | null;
1627
+ body: HTMLElement | null;
1628
+ footer: HTMLElement | null;
1629
+ form: FormInstance | null;
1630
+ formContainer: HTMLElement | null;
1787
1631
  }
1788
- interface TabsPanelCacheEntry {
1789
- content: RenderableContent<TabsPanelContext>;
1790
- updatedAt: number;
1632
+ interface ModalRuntime extends ComponentRuntime {
1633
+ scrollLocked: boolean;
1634
+ visibleApplied: boolean;
1791
1635
  }
1792
- interface TabsRuntime extends ComponentRuntime {
1793
- cache: {
1794
- panels: Map<string, TabsPanelCacheEntry>;
1795
- };
1796
- panelLoadId: number;
1636
+ interface ModalCache {
1637
+ initial: ResolvedModalProps | null;
1638
+ fieldIds: Map<string, string> | null;
1639
+ previousActiveElement: HTMLElement | null;
1640
+ formId: string;
1797
1641
  }
1798
- /**
1799
- * 标签页组件,继承 Component。
1800
- *
1801
- * DOM 创建一次,通过 createEffect 细粒度更新 class/ARIA。
1802
- */
1803
- declare class Tabs extends Component<ResolvedTabsProps, TabsState, TabsDOM> {
1804
- runtime: TabsRuntime;
1805
- state: TabsState;
1806
- private bindingsDispose;
1807
- private isDragging;
1808
- private raf;
1809
- private resizeRaf;
1810
- private velocity;
1811
- /**
1812
- * @param {Element|Node|string|Array} container 挂载容器(元素、选择器或 JSX/h 返回节点)。
1813
- * @param {object} [input={}] 标签页配置。
1814
- */
1815
- constructor(container: DOMReference, input?: TabsProps);
1816
- protected onInit(props: ResolvedTabsProps): void;
1817
- private buildRoot;
1818
- private rebuildItems;
1819
- private parseDisabled;
1820
- private createDisabledState;
1821
- private syncCurrent;
1822
- private getPanelKey;
1823
- private getCachedPanel;
1824
- private setCachedPanel;
1825
- private renderPanelContent;
1826
- private loadPanel;
1827
- get activeIndex(): number;
1828
- get disabledNames(): string[];
1829
- private bindEvents;
1830
- private unbindEvents;
1831
- private assertActive;
1832
- private getIndex;
1833
- private activateInternal;
1834
- /**
1835
- * 激活指定标签。
1836
- * @param {number|string} val 标签索引或名称。
1837
- */
1838
- activate(val: TabsValue): Promise<void>;
1839
- /**
1840
- * 将组件挂载到构造器指定的容器中。
1841
- */
1842
- build(): this;
1843
- render(): this;
1844
- /**
1845
- * 动态新增标签。
1846
- * @param {object} tabConfig 标签配置。
1847
- */
1848
- add(tabConfig: TabItem): Promise<void>;
1849
- /**
1850
- * 根据索引或名称删除标签。
1851
- * @param {number|string} val 标签索引或名称。
1852
- */
1853
- delete(val: TabsValue): Promise<void>;
1854
- /**
1855
- * 根据索引或名称禁用标签。
1856
- * @param {number|string} val 标签索引或名称。
1857
- */
1858
- disable(val: TabsValue): void;
1859
- /**
1860
- * 根据索引或名称启用标签。
1861
- * @param {number|string} val 标签索引或名称。
1862
- */
1863
- enable(val: TabsValue): void;
1864
- private resolveActiveIndex;
1865
- private syncActiveNames;
1866
- /**
1867
- * 使用新配置重新初始化状态。
1868
- * @param {object} [patch={}] 需要覆盖的配置。
1869
- */
1870
- reInit(patch?: TabsProps): Promise<void>;
1871
- private get dragContainer();
1872
- private get dragInner();
1873
- private initDrag;
1874
- private bindDragEvents;
1875
- private startInertiaScroll;
1876
- private removeDragEvents;
1877
- private refreshDrag;
1878
- protected onDestroy(): void;
1642
+ interface ModalCleanupExtras {
1643
+ visibility?: (() => void) | null;
1644
+ view?: (() => void) | null;
1645
+ hideTimer?: ReturnType<typeof setTimeout> | null;
1879
1646
  }
1880
- declare function createTabs(container: DOMReference, input?: TabsProps): Tabs;
1881
- //#endregion
1882
- //#region src/components/accordion.d.ts
1883
- type AccordionActive = number | string | Array<number | string> | null;
1884
- interface AccordionClassNames {
1885
- root: string;
1886
- header: string;
1647
+ type ModalStatePatch = Partial<ModalState>;
1648
+ declare class ModalComponent extends Component<ResolvedModalProps, ModalState, ModalDOM, ModalCache> {
1649
+ runtime: ModalRuntime;
1650
+ state: ModalState;
1651
+ cleanup: Component['cleanup'] & ModalCleanupExtras;
1652
+ constructor(input?: ModalProps);
1653
+ protected onInit(): void;
1654
+ build(): this;
1655
+ mountView(): void;
1656
+ headerView(): () => (Node | null)[] | null;
1657
+ footerView(): () => (Node | null)[] | null;
1658
+ bodyView(): RenderableContent<Modal>;
1659
+ formView(): HTMLElement;
1660
+ mountForm(container: HTMLElement | null): void;
1661
+ createFormProps(): FormProps;
1662
+ destroyForm(): void;
1663
+ contentView(content: ModalContent): Node[];
1664
+ bindReactiveLoading(): void;
1665
+ isBusy(): boolean;
1666
+ bindReactiveVisibility(): void;
1667
+ applyVisibility(visible: boolean): void;
1668
+ showFromState(): void;
1669
+ hideFromState(): void;
1670
+ bindEvents(root: Element | null): void;
1671
+ bindOverlayCloseEvent(root: Element | null): void;
1672
+ bindDocumentKeyEvent(): void;
1673
+ bindInsideEvent(): void;
1674
+ clearEvents(): void;
1675
+ requestSubmit(): void;
1676
+ handleFormSubmit(formData: FormDataRecord): Promise<void>;
1677
+ handleConfirm(): Promise<void>;
1678
+ handleCancel(): Promise<void>;
1679
+ handleSubmit(data: FormDataRecord): Promise<void>;
1680
+ trapFocus(event: KeyboardEvent): void;
1681
+ focusFirst(): void;
1682
+ lockScroll(): void;
1683
+ unlockScroll(): void;
1684
+ cancelHideTimer(): void;
1685
+ resetAnimationStyles(): void;
1686
+ finishHide(onHidden: ResolvedModalProps['onHidden']): void;
1687
+ restoreFocus(): void;
1688
+ assertActive(method: string): void;
1689
+ protected normalizeStatePatch(patch: ModalStatePatch): ModalStatePatch;
1690
+ protected validateStatePatch(patch: ModalStatePatch): void;
1691
+ protected afterSetState(patch: ModalStatePatch): void;
1692
+ show(): this;
1693
+ hide(): this;
1694
+ reset(): this;
1695
+ protected onDestroy(): void;
1696
+ destroy(): this;
1697
+ }
1698
+ type Modal = ModalComponent;
1699
+ declare function createModal(input?: ModalProps): Modal;
1700
+ //#endregion
1701
+ //#region src/components/swiper.d.ts
1702
+ interface SwiperClassNames {
1703
+ root: string;
1704
+ wrapper: string;
1705
+ slide: string;
1706
+ image: string;
1887
1707
  title: string;
1888
- arrow: string;
1889
- panel: string;
1890
- content: string;
1708
+ pagination: string;
1709
+ paginationHorizontal: string;
1710
+ paginationClickable: string;
1711
+ paginationBulletGroup: string;
1712
+ indicator: string;
1713
+ bullet: string;
1714
+ navigation: string;
1715
+ prev: string;
1716
+ next: string;
1717
+ active: string;
1718
+ disabled: string;
1719
+ loading: string;
1720
+ loaded: string;
1721
+ error: string;
1891
1722
  }
1892
- type AccordionClassNameConfig = Partial<AccordionClassNames>;
1893
- interface AccordionItem extends Record<string, unknown> {
1894
- name?: string;
1895
- title: RenderableContent<AccordionContentContext>;
1896
- content: RenderableContent<AccordionContentContext>;
1723
+ type SwiperClassNameConfig = Partial<SwiperClassNames>;
1724
+ interface SwiperDataItem extends Record<string, unknown> {
1725
+ image?: string | null;
1726
+ url?: string | null;
1727
+ title?: string | null;
1728
+ sort?: number | null;
1729
+ blank?: boolean | null;
1730
+ children?: RenderableContent<SwiperSlideContext> | null;
1897
1731
  }
1898
- interface AccordionProps extends Record<string, unknown> {
1732
+ interface NormalizedSwiperDataItem extends SwiperDataItem {
1733
+ blank: boolean;
1734
+ index: number;
1735
+ }
1736
+ interface SwiperSlideContext {
1737
+ swiper: Swiper;
1738
+ item: NormalizedSwiperDataItem;
1739
+ index: number;
1740
+ }
1741
+ interface SwiperProps extends Record<string, unknown> {
1899
1742
  id?: string | null;
1900
- active?: AccordionActive;
1901
- collapsible?: boolean;
1902
- multiple?: boolean;
1903
- className?: AccordionClassNameConfig;
1904
- items?: AccordionItem[];
1905
- onChange?: ((index: number, name: string, header: HTMLElement, panel: HTMLElement, accordion: Accordion) => void | Promise<void>) | null;
1743
+ data?: SwiperDataItem[];
1744
+ loop?: boolean;
1745
+ autoplay?: boolean;
1746
+ delay?: number;
1747
+ lazyload?: boolean;
1748
+ pagination?: boolean;
1749
+ navigation?: boolean;
1750
+ speed?: number;
1751
+ touchRatio?: number;
1752
+ touchAngle?: number;
1753
+ longSwipesMs?: number;
1754
+ longSwipesRatio?: number;
1755
+ preventClick?: boolean;
1756
+ className?: SwiperClassNameConfig;
1906
1757
  }
1907
- interface ResolvedAccordionProps extends Record<string, unknown> {
1908
- id: string;
1909
- active: AccordionActive;
1910
- collapsible: boolean;
1911
- multiple: boolean;
1912
- className: AccordionClassNames;
1913
- items: AccordionItem[];
1914
- onChange: NonNullable<AccordionProps['onChange']> | null;
1758
+ interface ResolvedSwiperProps extends Record<string, unknown> {
1759
+ id: string | null;
1760
+ data: SwiperDataItem[];
1761
+ loop: boolean;
1762
+ autoplay: boolean;
1763
+ delay: number;
1764
+ lazyload: boolean;
1765
+ pagination: boolean;
1766
+ navigation: boolean;
1767
+ speed: number;
1768
+ touchRatio: number;
1769
+ touchAngle: number;
1770
+ longSwipesMs: number;
1771
+ longSwipesRatio: number;
1772
+ preventClick: boolean;
1773
+ className: SwiperClassNames;
1915
1774
  }
1916
- interface AccordionState extends Record<string, unknown> {
1917
- activeNames: string[];
1918
- current: {
1919
- index: number | null;
1920
- name: string | null;
1921
- };
1775
+ interface SwiperState extends Record<string, unknown> {
1776
+ data: SwiperDataItem[];
1777
+ index: number;
1778
+ trackIndex: number;
1779
+ transform: number;
1780
+ animating: boolean;
1781
+ width: number;
1922
1782
  }
1923
- interface AccordionDOM extends ComponentDOM {
1783
+ interface SwiperDOM extends ComponentDOM {
1924
1784
  root: HTMLElement | null;
1925
- container: Element;
1926
- headers: HTMLElement[];
1927
- panels: HTMLElement[];
1785
+ createdRoot: boolean;
1786
+ wrapper: HTMLElement | null;
1787
+ slides: HTMLElement[];
1788
+ pagination: HTMLElement | null;
1789
+ prevButton: HTMLButtonElement | null;
1790
+ nextButton: HTMLButtonElement | null;
1791
+ bullets: HTMLButtonElement[];
1792
+ createdPagination: boolean;
1793
+ createdPrevButton: boolean;
1794
+ createdNextButton: boolean;
1928
1795
  }
1929
- interface AccordionRuntime extends ComponentRuntime {}
1930
- interface AccordionContentContext {
1931
- accordion: Accordion;
1932
- item: AccordionItem;
1933
- index: number;
1934
- type: 'title' | 'content';
1935
- active: boolean;
1796
+ interface SwipeLog {
1797
+ x: number;
1798
+ y: number;
1799
+ time: number;
1800
+ }
1801
+ interface SwiperRuntime extends ComponentRuntime {
1802
+ built: boolean;
1803
+ logs: SwipeLog[];
1804
+ startTarget: EventTarget | null;
1805
+ touching: boolean;
1806
+ scrolling: boolean;
1807
+ swiping: boolean;
1808
+ clickPrevented: boolean;
1809
+ timer: ReturnType<typeof setInterval> | null;
1810
+ imageCleanups: Set<() => void>;
1811
+ realCount: number;
1812
+ }
1813
+ interface SwiperCleanupExtras {
1814
+ bindings?: (() => void) | null;
1815
+ navBindings?: (() => void) | null;
1816
+ data?: (() => void) | null;
1936
1817
  }
1937
1818
  /**
1938
- * 轻量手风琴组件,继承 Component。
1819
+ * 轻量轮播组件,继承 Component。
1939
1820
  *
1940
- * DOM 创建一次,通过 createEffect 细粒度更新 class/ARIA。
1821
+ * 支持链接 slide、图片 lazyload、分页、导航、loop 和桌面/移动端拖拽滑动。
1822
+ * 使用 vanilla-signal 响应式管理 pagination 和 navigation 状态。
1941
1823
  */
1942
- declare class Accordion extends Component<ResolvedAccordionProps, AccordionState, AccordionDOM> {
1943
- runtime: AccordionRuntime;
1944
- state: AccordionState;
1945
- private bindingsDispose;
1946
- /**
1947
- * @param {Element|Node|string|Array} container 挂载容器(元素、选择器或 JSX/h 返回节点)。
1948
- * @param {object} [input={}] 手风琴配置。
1949
- */
1950
- constructor(container: DOMReference, input?: AccordionProps);
1951
- protected onInit(props: ResolvedAccordionProps): void;
1952
- private buildRoot;
1953
- private buildItems;
1954
- private contentView;
1955
- private resolveActiveNames;
1956
- private syncActiveNames;
1957
- private bindEvents;
1958
- private unbindEvents;
1959
- isActive(name: string): boolean;
1960
- private assertActive;
1961
- private activateItem;
1962
- getIndex(val: number | string | undefined | null): number;
1824
+ declare class SwiperComponent extends Component<ResolvedSwiperProps, SwiperState, SwiperDOM> {
1825
+ props: ResolvedSwiperProps;
1826
+ state: SwiperState;
1827
+ dom: SwiperDOM;
1828
+ runtime: SwiperRuntime;
1829
+ cleanup: Component['cleanup'] & SwiperCleanupExtras;
1963
1830
  /**
1964
- * 激活指定面板。
1965
- * @param {number|string} val 面板索引或名称。
1831
+ * 创建轮播实例。
1832
+ * @param {object} [props={}] Swiper 配置。
1966
1833
  */
1967
- active(val: number | string | undefined): Promise<void>;
1834
+ constructor(props?: SwiperProps);
1968
1835
  /**
1969
- * 将组件挂载到构造器指定的容器中。
1836
+ * 构建 Swiper DOM。
1837
+ * @returns {Swiper} 当前实例。
1970
1838
  */
1971
1839
  build(): this;
1972
- render(): this;
1973
- /**
1974
- * 动态替换全部面板条目。
1975
- * @param {AccordionItem[]} items 新面板配置。
1976
- * @param {number|string|Array<number|string>|null} [active=0] 替换后默认激活项。
1977
- */
1978
- setItems(items: AccordionItem[], active?: AccordionActive): this;
1840
+ set index(v: unknown);
1841
+ set trackIndex(v: unknown);
1842
+ set transform(v: unknown);
1843
+ set animating(v: unknown);
1844
+ set width(v: unknown);
1845
+ get realCount(): number;
1846
+ get realIndex(): number;
1847
+ private assertBuilt;
1848
+ private createDataView;
1849
+ private bindStateData;
1850
+ private syncStateData;
1851
+ private normalizeData;
1852
+ private createDataSlide;
1853
+ protected onInit(): void;
1979
1854
  protected onDestroy(): void;
1855
+ private updateSize;
1856
+ refresh(): this;
1857
+ private refreshSlides;
1858
+ private initLoop;
1859
+ private setupStyles;
1860
+ private reInitView;
1861
+ private clearPagination;
1862
+ private clearNavigation;
1863
+ private bindEvents;
1864
+ private onStart;
1865
+ private onMove;
1866
+ private onEnd;
1867
+ private resetDrag;
1868
+ private onTransitionEnd;
1869
+ private pushLog;
1870
+ private getDuration;
1871
+ private getOffset;
1872
+ toRealIndex(index?: number): number;
1873
+ trackIndexForRealIndex(index: number): number;
1874
+ private setTrackIndex;
1875
+ slideTo(index: number): void;
1876
+ slideToTrack(idx: number): void;
1877
+ next(): void;
1878
+ prev(): void;
1879
+ private render;
1880
+ private loadImages;
1881
+ private clearImageCleanups;
1882
+ private initPagination;
1883
+ private initNavigation;
1884
+ private ensureNavigation;
1885
+ play(): void;
1886
+ pause(): void;
1887
+ resume(): void;
1888
+ restartAutoplay(): void;
1889
+ protected normalizeStatePatch(patch: Partial<SwiperState>): Partial<SwiperState>;
1890
+ protected validateStatePatch(patch: Partial<SwiperState>): void;
1980
1891
  }
1981
- declare function createAccordion(container: DOMReference, input?: AccordionProps): Accordion;
1892
+ type Swiper = SwiperComponent;
1893
+ declare function createSwiper(input?: SwiperProps): Swiper;
1982
1894
  //#endregion
1983
- //#region src/components/drop.d.ts
1984
- type DropMode = 'hover' | 'click';
1985
- type DropPosition = 'auto' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left' | 'right';
1986
- interface DropClassNames {
1895
+ //#region src/components/tabs.d.ts
1896
+ type TabsDirection = 'top' | 'bottom' | 'left' | 'right';
1897
+ type TabsValue = number | string;
1898
+ type TabsDisabled = TabsValue | TabsValue[];
1899
+ interface TabsClassNames {
1987
1900
  root: string;
1988
- container: string;
1901
+ wrap: string;
1902
+ list: string;
1903
+ tab: string;
1904
+ panelWrap: string;
1905
+ panel: string;
1906
+ disabled: string;
1907
+ dragging: string;
1989
1908
  }
1990
- type DropClassNameConfig = Partial<DropClassNames>;
1991
- interface DropDelay {
1992
- show?: number;
1993
- hide?: number;
1909
+ type TabsClassNameConfig = Partial<TabsClassNames>;
1910
+ interface TabsPanelContext {
1911
+ tabs: Tabs;
1912
+ item: TabItem;
1913
+ index: number;
1914
+ name: string | number;
1994
1915
  }
1995
- interface DropProps extends Record<string, unknown> {
1996
- name?: string | null;
1997
- mode?: DropMode;
1998
- position?: DropPosition;
1999
- offset?: number;
2000
- content?: RenderableContent<Drop>;
2001
- className?: DropClassNameConfig;
1916
+ interface TabTitleContext {
1917
+ tabs: Tabs;
1918
+ item: TabItem;
1919
+ }
1920
+ type TabPanel = RenderableContent<TabsPanelContext> | ((context: TabsPanelContext) => RenderableContent<TabsPanelContext>) | ((context: TabsPanelContext) => Promise<RenderableContent<TabsPanelContext>>);
1921
+ interface TabItem extends Record<string, unknown> {
1922
+ name?: string;
1923
+ title: RenderableContent<TabTitleContext>;
1924
+ panel: TabPanel;
1925
+ cache?: boolean;
1926
+ ttl?: number;
1927
+ }
1928
+ interface TabsProps extends Record<string, unknown> {
2002
1929
  id?: string | null;
2003
- delay?: number | DropDelay;
2004
- hoverIntent?: boolean;
2005
- onShown?: ((drop: Drop) => void | Promise<void>) | null;
2006
- onHidden?: ((drop: Drop) => void | Promise<void>) | null;
1930
+ direction?: TabsDirection;
1931
+ active?: TabsValue;
1932
+ disabled?: TabsDisabled;
1933
+ onChange?: ((index: number, name: string | number, tab: HTMLElement | undefined, panel: HTMLElement | undefined) => void | Promise<void>) | null;
1934
+ data?: TabItem[];
1935
+ className?: TabsClassNameConfig;
2007
1936
  }
2008
- interface ResolvedDropProps extends Record<string, unknown> {
2009
- name: string | null;
2010
- mode: DropMode;
2011
- position: DropPosition;
2012
- offset: number;
2013
- content: RenderableContent<Drop>;
2014
- className: DropClassNames;
1937
+ interface ResolvedTabsProps extends Record<string, unknown> {
2015
1938
  id: string;
2016
- delay: number | DropDelay;
2017
- hoverIntent: boolean;
2018
- onShown: NonNullable<DropProps['onShown']> | null;
2019
- onHidden: NonNullable<DropProps['onHidden']> | null;
2020
- }
2021
- interface DropCleanup {
2022
- events: IEventManager;
1939
+ direction: TabsDirection;
1940
+ active: TabsValue;
1941
+ disabled: TabsDisabled;
1942
+ onChange: NonNullable<TabsProps['onChange']> | null;
1943
+ data: TabItem[];
1944
+ className: TabsClassNames;
2023
1945
  }
2024
- /**
2025
- * 通用浮层组件。
2026
- *
2027
- * 可用于菜单、提示、下拉面板等场景,支持点击或 hover 触发,并自动计算视口内位置。
2028
- */
2029
- declare class Drop {
2030
- target: Element | null;
2031
- props: ResolvedDropProps | null;
2032
- root: HTMLElement | null;
2033
- isVisible: boolean;
2034
- cleanup: DropCleanup | null;
2035
- delayShow: number;
2036
- delayHide: number;
2037
- private timer;
2038
- private hoverIntentData;
2039
- private lastX;
2040
- private lastY;
2041
- constructor(element: DOMReference, options?: DropProps);
2042
- private init;
2043
- private buildDrop;
2044
- private bindEvents;
2045
- private bindRootEvents;
2046
- private unbindRootEvents;
2047
- private unbindEvents;
2048
- private startHoverIntent;
2049
- private cancelHoverIntent;
2050
- private onMouseMove;
2051
- private setPosition;
2052
- private docClick;
2053
- private exec;
2054
- show(useDelay?: boolean): void;
2055
- hide(useDelay?: boolean): void;
2056
- toggle(): void;
2057
- destroy(): void;
1946
+ interface TabsState extends Record<string, unknown> {
1947
+ data: TabItem[];
1948
+ active: TabsValue;
1949
+ disabled: TabsDisabled;
1950
+ direction: TabsDirection;
1951
+ current: {
1952
+ index: number;
1953
+ name: string | null;
1954
+ };
1955
+ isVertical: boolean;
1956
+ draggable: boolean;
1957
+ loading: boolean;
2058
1958
  }
2059
- declare function createDrop(container: DOMReference, input?: DropProps): Drop;
2060
- //#endregion
2061
- //#region src/components/tooltip.d.ts
2062
- interface TooltipClassNames {
2063
- container: string;
2064
- message: string;
1959
+ interface TabsDOM extends ComponentDOM {
1960
+ root: HTMLElement | null;
1961
+ tabs: HTMLElement[];
1962
+ panels: HTMLElement[];
2065
1963
  }
2066
- type TooltipClassNameConfig = Partial<TooltipClassNames>;
2067
- interface TooltipProps extends Record<string, unknown> {
2068
- name?: string | null;
2069
- mode?: DropMode;
2070
- position?: DropPosition;
2071
- offset?: number;
2072
- message?: string;
2073
- className?: TooltipClassNameConfig;
2074
- id?: string | null;
2075
- delay?: number | DropDelay;
2076
- hoverIntent?: boolean;
2077
- onShown?: ((drop: Drop) => void | Promise<void>) | null;
2078
- onHidden?: ((drop: Drop) => void | Promise<void>) | null;
1964
+ interface TabsPanelCacheEntry {
1965
+ content: RenderableContent<TabsPanelContext>;
1966
+ updatedAt: number;
2079
1967
  }
2080
- interface ResolvedTooltipProps extends Record<string, unknown> {
2081
- name: string | null;
2082
- mode: DropMode;
2083
- position: DropPosition;
2084
- offset: number;
2085
- message: string;
2086
- className: TooltipClassNames;
2087
- id: string | null;
2088
- delay: number | DropDelay;
2089
- hoverIntent: boolean;
2090
- onShown: NonNullable<TooltipProps['onShown']> | null;
2091
- onHidden: NonNullable<TooltipProps['onHidden']> | null;
1968
+ interface TabsRuntime extends ComponentRuntime {
1969
+ built: boolean;
1970
+ cache: {
1971
+ panels: Map<string, TabsPanelCacheEntry>;
1972
+ };
1973
+ panelLoadId: number;
2092
1974
  }
2093
1975
  /**
2094
- * Tooltip 提示组件。
1976
+ * 标签页组件,继承 Component。
2095
1977
  *
2096
- * 基于 Drop 实现,提供更轻量的文本提示封装。
1978
+ * DOM 创建一次,通过 createEffect 细粒度更新 class/ARIA。
2097
1979
  */
2098
- declare class Tooltip {
2099
- drop: Drop | null;
2100
- props: ResolvedTooltipProps | null;
2101
- constructor(element: DOMReference, props?: TooltipProps);
2102
- private buildContent;
2103
- show(useDelay?: boolean): void;
2104
- hide(useDelay?: boolean): void;
2105
- toggle(): void;
2106
- destroy(): void;
1980
+ declare class TabsComponent extends Component<ResolvedTabsProps, TabsState, TabsDOM> {
1981
+ runtime: TabsRuntime;
1982
+ state: TabsState;
1983
+ private bindingsDispose;
1984
+ private stateDispose;
1985
+ private isDragging;
1986
+ private raf;
1987
+ private resizeRaf;
1988
+ private velocity;
1989
+ /**
1990
+ * @param {object} [input={}] 标签页配置。
1991
+ */
1992
+ constructor(input?: TabsProps);
1993
+ protected onInit(props: ResolvedTabsProps): void;
1994
+ private buildRoot;
1995
+ private renderItems;
1996
+ private bindState;
1997
+ private syncStateView;
1998
+ private get disabledState();
1999
+ private isDisabledName;
2000
+ private syncCurrent;
2001
+ private getPanelKey;
2002
+ private getCachedPanel;
2003
+ private setCachedPanel;
2004
+ private renderPanelContent;
2005
+ private loadPanel;
2006
+ get activeIndex(): number;
2007
+ get disabledNames(): string[];
2008
+ private bindEvents;
2009
+ private unbindEvents;
2010
+ private assertActive;
2011
+ private getIndex;
2012
+ private activateInternal;
2013
+ /**
2014
+ * 激活指定标签。
2015
+ * @param {number|string} val 标签索引或名称。
2016
+ */
2017
+ activate(val: TabsValue): Promise<void>;
2018
+ /**
2019
+ * 构建 Tabs DOM。
2020
+ */
2021
+ build(): this;
2022
+ refresh(): this;
2023
+ private get dragContainer();
2024
+ private get dragInner();
2025
+ private initDrag;
2026
+ private bindDragEvents;
2027
+ private startInertiaScroll;
2028
+ private removeDragEvents;
2029
+ private refreshDrag;
2030
+ protected onDestroy(): void;
2031
+ private validateData;
2032
+ protected normalizeStatePatch(patch: Partial<TabsState>): Partial<TabsState>;
2033
+ protected validateStatePatch(patch: Partial<TabsState>): void;
2107
2034
  }
2108
- declare function createTooltip(element: DOMReference, props?: TooltipProps): Tooltip;
2035
+ type Tabs = TabsComponent;
2036
+ declare function createTabs(input?: TabsProps): Tabs;
2109
2037
  //#endregion
2110
2038
  //#region src/components/offcanvas.d.ts
2111
2039
  type OffcanvasDirection = 'top' | 'right' | 'bottom' | 'left';
2112
- type OffcanvasAnimation = 'slide' | 'none';
2040
+ type OffcanvasAnimate = string;
2113
2041
  interface OffcanvasClassNames {
2114
2042
  root: string;
2115
2043
  overlay: string;
2116
2044
  content: string;
2117
- active: string;
2118
- top: string;
2119
- right: string;
2120
- bottom: string;
2121
- left: string;
2122
- slide: string;
2123
- none: string;
2124
2045
  }
2125
2046
  type OffcanvasClassNameConfig = Partial<OffcanvasClassNames>;
2126
2047
  type OffcanvasContent = RenderableContent<Offcanvas> | ((offcanvas: Offcanvas) => Promise<RenderableContent<Offcanvas>>);
@@ -2128,10 +2049,11 @@ interface OffcanvasProps extends Record<string, unknown> {
2128
2049
  content?: OffcanvasContent;
2129
2050
  overlay?: boolean;
2130
2051
  filter?: boolean;
2052
+ bodyOverflow?: boolean;
2131
2053
  cache?: boolean;
2132
2054
  ttl?: number;
2133
2055
  direction?: OffcanvasDirection;
2134
- animation?: OffcanvasAnimation;
2056
+ animate?: OffcanvasAnimate;
2135
2057
  bgClose?: boolean;
2136
2058
  escClose?: boolean;
2137
2059
  id?: string | null;
@@ -2145,10 +2067,11 @@ interface ResolvedOffcanvasProps extends Record<string, unknown> {
2145
2067
  content: OffcanvasContent;
2146
2068
  overlay: boolean;
2147
2069
  filter: boolean;
2070
+ bodyOverflow: boolean;
2148
2071
  cache: boolean;
2149
2072
  ttl: number;
2150
2073
  direction: OffcanvasDirection;
2151
- animation: OffcanvasAnimation;
2074
+ animate: OffcanvasAnimate;
2152
2075
  bgClose: boolean;
2153
2076
  escClose: boolean;
2154
2077
  id: string;
@@ -2159,271 +2082,55 @@ interface ResolvedOffcanvasProps extends Record<string, unknown> {
2159
2082
  onHidden: NonNullable<OffcanvasProps['onHidden']> | null;
2160
2083
  }
2161
2084
  interface OffcanvasState extends Record<string, unknown> {
2085
+ content: OffcanvasContent;
2162
2086
  visible: boolean;
2163
2087
  loading: boolean;
2164
2088
  }
2165
2089
  interface OffcanvasDOM extends ComponentDOM {
2166
2090
  root: HTMLElement | null;
2091
+ overlay: HTMLElement | null;
2167
2092
  content: HTMLElement | null;
2168
2093
  }
2169
2094
  interface OffcanvasCache {
2170
- content: RenderableContent<Offcanvas>;
2171
- hasContent: boolean;
2172
- updatedAt: number;
2173
- }
2174
- interface OffcanvasRuntime extends ComponentRuntime {
2175
- cache: OffcanvasCache;
2176
- contentLoadId: number;
2177
- }
2178
- /**
2179
- * 侧滑面板组件,继承 Component。
2180
- *
2181
- * 适用于侧边菜单、筛选面板、移动端抽屉等场景。
2182
- */
2183
- declare class Offcanvas extends Component<ResolvedOffcanvasProps, OffcanvasState, OffcanvasDOM> {
2184
- runtime: OffcanvasRuntime;
2185
- state: OffcanvasState;
2186
- _overlay: HTMLElement | null;
2187
- constructor(input?: OffcanvasProps);
2188
- protected onInit(props: ResolvedOffcanvasProps): void;
2189
- private buildOverlay;
2190
- private buildRoot;
2191
- private isCacheValid;
2192
- private renderContent;
2193
- private loadContent;
2194
- private bindEvents;
2195
- unbindEvents(): void;
2196
- private renderPanel;
2197
- private removePanel;
2198
- show(): Promise<void>;
2199
- hide(): Promise<void>;
2200
- onDestroy(): void;
2201
- }
2202
- declare function createOffcanvas(options?: OffcanvasProps): Offcanvas;
2203
- //#endregion
2204
- //#region src/components/modal.d.ts
2205
- type ModalStyle = string | Record<string, string | number | null | undefined> | null;
2206
- type ModalTextInput = Partial<ModalText> & Record<string, unknown>;
2207
- type ModalContent = RenderableContent<Modal>;
2208
- type FlowDirection$1 = 'next' | 'back';
2209
- interface ModalClassNames {
2210
- layout: string;
2211
- modal: string;
2212
- fullscreen: string;
2213
- header: string;
2214
- body: string;
2215
- footer: string;
2216
- title: string;
2217
- close: string;
2218
- cancel: string;
2219
- confirm: string;
2220
- button: string;
2221
- buttonIcon: string;
2222
- buttonGhost: string;
2223
- buttonPrimary: string;
2224
- buttonSmall: string;
2225
- formContainer: string;
2226
- }
2227
- type ModalClassNameConfig = Partial<ModalClassNames>;
2228
- interface ModalText {
2229
- title: string;
2230
- confirm: string;
2231
- cancel: string;
2232
- }
2233
- interface FlowStep$1 {
2234
- id?: string;
2235
- title?: RenderableContent<Modal>;
2236
- content?: ModalContent;
2237
- modal?: ModalFlowView | ModalFlowViewFactory;
2238
- view?: ModalFlowView | ModalFlowViewFactory;
2239
- [key: string]: unknown;
2240
- }
2241
- interface FlowSnapshot$1 {
2242
- data?: Record<string, unknown> | null;
2243
- currentData?: Record<string, unknown> | null;
2244
- currentStep?: FlowStep$1;
2245
- [key: string]: unknown;
2246
- }
2247
- interface FlowLike {
2248
- currentStep?: FlowStep$1;
2249
- next: (payload: FormDataRecord | null) => Promise<FlowSnapshot$1> | FlowSnapshot$1;
2250
- back: (payload: FormDataRecord | null) => Promise<FlowSnapshot$1> | FlowSnapshot$1;
2251
- snapshot: () => FlowSnapshot$1;
2252
- reset?: () => void;
2253
- destroy?: () => void;
2254
- }
2255
- interface ModalFlowView extends Partial<ModalProps> {
2256
- [key: string]: unknown;
2257
- }
2258
- type ModalFlowViewFactory = (context: {
2259
- flow: FlowLike;
2260
- snapshot: FlowSnapshot$1 | null;
2261
- step: FlowStep$1 | undefined;
2262
- modal: Modal;
2263
- data: Record<string, unknown> | null;
2264
- currentData: Record<string, unknown> | null;
2265
- }) => unknown;
2266
- interface ModalProps extends Record<string, unknown> {
2267
- content?: ModalContent;
2268
- position?: string;
2269
- showCancel?: boolean;
2270
- showClose?: boolean;
2271
- fullscreen?: boolean;
2272
- flow?: FlowLike | null;
2273
- text?: ModalTextInput;
2274
- onShow?: ((modal: Modal) => void | Promise<void>) | null;
2275
- onShown?: ((modal: Modal) => void | Promise<void>) | null;
2276
- onHide?: ((modal: Modal) => void | Promise<void>) | null;
2277
- onHidden?: ((modal: Modal) => void | Promise<void>) | null;
2278
- onConfirm?: ((modal: Modal) => void | Promise<void>) | null;
2279
- onSubmit?: ((data: FormDataRecord, modal: Modal) => void | Promise<void>) | null;
2280
- onCancel?: ((modal: Modal) => void | Promise<void>) | null;
2281
- fields?: readonly FormField[] | null;
2282
- header?: boolean;
2283
- footer?: boolean;
2284
- style?: ModalStyle;
2285
- id?: string | null;
2286
- escClose?: boolean;
2287
- bgClose?: boolean;
2288
- lazy?: boolean;
2289
- className?: ModalClassNameConfig;
2290
- }
2291
- interface ResolvedModalProps extends Record<string, unknown> {
2292
- content: ModalContent;
2293
- position: string;
2294
- showCancel: boolean;
2295
- showClose: boolean;
2296
- fullscreen: boolean;
2297
- flow: FlowLike | null;
2298
- text: ModalText;
2299
- onShow: NonNullable<ModalProps['onShow']> | null;
2300
- onShown: NonNullable<ModalProps['onShown']> | null;
2301
- onHide: NonNullable<ModalProps['onHide']> | null;
2302
- onHidden: NonNullable<ModalProps['onHidden']> | null;
2303
- onConfirm: NonNullable<ModalProps['onConfirm']> | null;
2304
- onSubmit: NonNullable<ModalProps['onSubmit']> | null;
2305
- onCancel: NonNullable<ModalProps['onCancel']> | null;
2306
- fields: FormField[] | null;
2307
- header: boolean;
2308
- footer: boolean;
2309
- style: ModalStyle;
2310
- id: string;
2311
- escClose: boolean;
2312
- bgClose: boolean;
2313
- lazy: boolean;
2314
- className: ModalClassNames;
2315
- }
2316
- interface ModalState extends ResolvedModalProps {
2317
- loading: boolean;
2318
- submitting: boolean;
2319
- visible: boolean;
2320
- data: FormDataRecord | null;
2321
- extraData: FormDataRecord | null;
2322
- }
2323
- interface ModalDOM extends ComponentDOM {
2324
- root: HTMLElement | null;
2325
- modal: HTMLElement | null;
2326
- header: HTMLElement | null;
2327
- body: HTMLElement | null;
2328
- footer: HTMLElement | null;
2329
- form: Form | null;
2330
- formContainer: HTMLElement | null;
2331
- }
2332
- interface ModalRuntime extends ComponentRuntime {
2333
- scrollLocked: boolean;
2334
- visibleApplied: boolean;
2335
- }
2336
- interface ModalCache {
2337
- initial: ResolvedModalProps | null;
2338
- fieldIds: Map<string, string> | null;
2339
- baseStyle: string;
2340
- previousActiveElement: HTMLElement | null;
2341
- formId: string;
2342
- }
2343
- interface ModalCleanupExtras {
2344
- visibility?: (() => void) | null;
2345
- view?: (() => void) | null;
2346
- hideTimer?: ReturnType<typeof setTimeout> | null;
2347
- }
2348
- type ModalPatch = Partial<ModalProps>;
2349
- type ModalStatePatch = Partial<ModalState>;
2350
- declare class Modal extends Component<ResolvedModalProps, ModalState, ModalDOM> {
2351
- runtime: ModalRuntime;
2352
- state: ModalState;
2353
- cleanup: Component['cleanup'] & ModalCleanupExtras;
2354
- cache: ModalCache;
2355
- constructor(input?: ModalProps);
2356
- protected onInit(): void;
2357
- buildRoot(): HTMLElement;
2358
- mountView(): void;
2359
- headerView(): () => (Node | null)[] | null;
2360
- footerView(): () => (Node | null)[] | null;
2361
- bodyView(): RenderableContent<Modal>;
2362
- formView(): HTMLElement;
2363
- mountForm(container: HTMLElement | null): void;
2364
- createFormProps(): FormProps;
2365
- destroyForm(): void;
2366
- contentView(content: ModalContent): Node[];
2367
- bindReactiveLoading(): void;
2368
- bindReactiveStyle(): void;
2369
- isFormMode(): boolean;
2370
- isBusy(): boolean;
2371
- validatePropsPatch(patch: ModalPatch, namespace?: string): void;
2372
- applyProps(patch: ModalPatch, { validate, force }?: {
2373
- validate?: boolean;
2374
- force?: boolean;
2375
- }): this;
2376
- applyStyle(element: HTMLElement, style: ModalStyle): void;
2377
- bindReactiveVisibility(): void;
2378
- applyVisibility(visible: boolean): void;
2379
- showFromState(): void;
2380
- hideFromState(): void;
2381
- bindEvents(root: Element | null): void;
2382
- bindOverlayCloseEvent(root: Element | null): void;
2383
- bindDocumentKeyEvent(): void;
2384
- bindInsideEvent(): void;
2385
- clearEvents(): void;
2386
- requestSubmit(): void;
2387
- handleFormSubmit(formData: FormDataRecord): Promise<void>;
2388
- handleNext(): Promise<void>;
2389
- handleBack(): Promise<void>;
2390
- hasFlow(): this is this & {
2391
- state: ModalState & {
2392
- flow: FlowLike;
2393
- };
2394
- };
2395
- moveFlow(direction: FlowDirection$1): Promise<void>;
2396
- createFlowPayload(): FormDataRecord | null | false;
2397
- resolveFlowModalView(flow: FlowLike, snapshot: FlowSnapshot$1 | null, step?: FlowStep$1): ModalFlowView;
2398
- syncFlowView(flow: FlowLike | null, snapshot?: FlowSnapshot$1 | null): void;
2399
- handleConfirm(): Promise<void>;
2400
- handleCancel(): Promise<void>;
2401
- handleSubmit(data: FormDataRecord): Promise<void>;
2402
- trapFocus(event: KeyboardEvent): void;
2403
- focusFirst(): void;
2404
- lockScroll(): void;
2405
- unlockScroll(): void;
2406
- cancelHideTimer(): void;
2407
- resetAnimationStyles(): void;
2408
- finishHide(onHidden: ResolvedModalProps['onHidden']): void;
2409
- restoreFocus(): void;
2410
- assertActive(method: string): void;
2411
- validateStatePatch(patch: ModalStatePatch): void;
2412
- setState(patch?: ModalStatePatch): this;
2413
- show(): this;
2414
- hide(): this;
2415
- setFields(data: readonly FormField[] | null, force?: boolean): this;
2416
- addFields(data: FormDataRecord): this;
2417
- setContent(content: ModalContent, force?: boolean): this;
2418
- update(patch?: Partial<ResolvedModalProps> | null, options?: ComponentUpdateOptions): this;
2419
- update(patch?: ModalPatch | null, force?: boolean): this;
2420
- reset(): this;
2421
- resetContent(): this;
2422
- resetFields(): this;
2095
+ content: RenderableContent<Offcanvas>;
2096
+ hasContent: boolean;
2097
+ updatedAt: number;
2098
+ }
2099
+ interface OffcanvasRuntime extends ComponentRuntime {
2100
+ built: boolean;
2101
+ cache: OffcanvasCache;
2102
+ contentLoadId: number;
2103
+ }
2104
+ interface OffcanvasCleanupExtras {
2105
+ state?: (() => void) | null;
2106
+ }
2107
+ declare class OffcanvasComponent extends Component<ResolvedOffcanvasProps, OffcanvasState, OffcanvasDOM> {
2108
+ runtime: OffcanvasRuntime;
2109
+ state: OffcanvasState;
2110
+ cleanup: Component['cleanup'] & OffcanvasCleanupExtras;
2111
+ constructor(input?: OffcanvasProps);
2112
+ build(): this;
2113
+ private assertBuilt;
2114
+ private buildRoot;
2115
+ private buildOverlay;
2116
+ private buildPanel;
2117
+ private bindState;
2118
+ private syncContent;
2119
+ private isCacheValid;
2120
+ private clearContent;
2121
+ private renderContent;
2122
+ private loadContent;
2123
+ private bindEvents;
2124
+ private unbindEvents;
2125
+ private showPanel;
2126
+ private hidePanel;
2127
+ show(): Promise<void>;
2128
+ hide(): Promise<void>;
2423
2129
  protected onDestroy(): void;
2424
- destroy(): this;
2130
+ protected validateStatePatch(patch: Partial<OffcanvasState>): void;
2425
2131
  }
2426
- declare function createModal(input?: ModalProps): Modal;
2132
+ type Offcanvas = OffcanvasComponent;
2133
+ declare function createOffcanvas(input?: OffcanvasProps): Offcanvas;
2427
2134
  //#endregion
2428
2135
  //#region src/components/pagination.d.ts
2429
2136
  interface PaginationPage {
@@ -2440,9 +2147,7 @@ interface PaginationClassNames {
2440
2147
  item: string;
2441
2148
  more: string;
2442
2149
  button: string;
2443
- buttonIcon: string;
2444
- buttonGhost: string;
2445
- active: string;
2150
+ current: string;
2446
2151
  loading: string;
2447
2152
  }
2448
2153
  type PaginationClassNameConfig = Partial<PaginationClassNames>;
@@ -2469,29 +2174,9 @@ interface PaginationState extends Record<string, unknown> {
2469
2174
  pageCount: number;
2470
2175
  locked: boolean;
2471
2176
  }
2472
- interface PageItem {
2473
- type: 'page';
2474
- key: string;
2475
- page: number;
2476
- }
2477
- interface MoreItem {
2478
- type: 'more';
2479
- key: string;
2480
- }
2481
- type PaginationItem = PageItem | MoreItem;
2482
- type PageAction = 'prev' | 'next';
2483
- type Dispose = () => void;
2484
- type EffectDispose = {
2485
- dispose: () => void;
2486
- };
2487
2177
  interface PaginationDOM extends ComponentDOM {
2488
2178
  root: HTMLElement | null;
2489
- container: Element | null;
2490
2179
  list: HTMLElement | null;
2491
- prev: HTMLElement | null;
2492
- next: HTMLElement | null;
2493
- pageNodes: HTMLElement[];
2494
- items: PaginationItem[];
2495
2180
  }
2496
2181
  interface PaginationRuntime extends ComponentRuntime {
2497
2182
  built: boolean;
@@ -2499,264 +2184,37 @@ interface PaginationRuntime extends ComponentRuntime {
2499
2184
  changeId: number;
2500
2185
  }
2501
2186
  interface PaginationCleanupExtras {
2502
- controls?: Dispose | null;
2503
- itemsEffect?: EffectDispose | null;
2187
+ state?: (() => void) | null;
2504
2188
  }
2505
- /**
2506
- * 分页组件。
2507
- *
2508
- * 构造器只验证和保存配置;调用 build() 后才挂载 DOM 和绑定交互。
2509
- */
2510
- declare class Pagination extends Component {
2511
- props: ResolvedPaginationProps;
2512
- state: PaginationState;
2513
- dom: PaginationDOM;
2189
+ declare class PaginationComponent extends Component<ResolvedPaginationProps, PaginationState, PaginationDOM> {
2514
2190
  runtime: PaginationRuntime;
2191
+ state: PaginationState;
2515
2192
  cleanup: Component['cleanup'] & PaginationCleanupExtras;
2516
- /**
2517
- * @param {Element|Node|string|Array} container 挂载容器。
2518
- * @param {object} [input={}] 分页配置。
2519
- */
2520
- constructor(container: DOMReference, input?: PaginationProps);
2521
- /**
2522
- * 构建分页 DOM 并绑定事件。
2523
- * @returns {Pagination} 当前实例。
2524
- */
2193
+ constructor(input?: PaginationProps);
2525
2194
  build(): this;
2526
- /**
2527
- * 跳转到指定页码。
2528
- * @param {number} page 新页码。
2529
- * @returns {Pagination} 当前实例。
2530
- */
2531
2195
  go(page: number): this;
2532
- /**
2533
- * 更新分页配置。
2534
- * @param {object} [newProps={}] 新配置,会与当前 props 合并。
2535
- * @returns {Pagination} 当前实例。
2536
- */
2537
- update(newProps?: PaginationProps): this;
2538
- _getPageCount(total: number, size: number): number;
2539
- _getPageItems(): PaginationItem[];
2540
- _getItemsKey(): string;
2541
- _isLocked(): boolean;
2542
- _isPrevDisabled(): boolean;
2543
- _isNextDisabled(): boolean;
2544
- _buttonClass(...extra: string[]): string;
2545
- _buildControlItem(type: PageAction): HTMLElement;
2546
- _buildPageItem(item: PaginationItem): HTMLElement;
2547
- _bindControlState(): void;
2548
- _bindPageItems(): void;
2549
- _renderPageItems(): void;
2550
- _bindEvents(): void;
2551
- _assertActive(method: string): void;
2552
- protected onDestroy(): void;
2553
- }
2554
- declare function createPagination(container: DOMReference, props?: PaginationProps): Pagination;
2555
- //#endregion
2556
- //#region src/components/swiper.d.ts
2557
- interface SwiperClassNames {
2558
- root: string;
2559
- wrapper: string;
2560
- slide: string;
2561
- image: string;
2562
- title: string;
2563
- pagination: string;
2564
- paginationHorizontal: string;
2565
- paginationClickable: string;
2566
- paginationBulletGroup: string;
2567
- indicator: string;
2568
- bullet: string;
2569
- navigation: string;
2570
- prev: string;
2571
- next: string;
2572
- active: string;
2573
- disabled: string;
2574
- loading: string;
2575
- loaded: string;
2576
- error: string;
2577
- }
2578
- type SwiperClassNameConfig = Partial<SwiperClassNames>;
2579
- interface SwiperDataItem extends Record<string, unknown> {
2580
- image?: string | null;
2581
- url?: string | null;
2582
- title?: string | null;
2583
- sort?: number | null;
2584
- blank?: boolean | null;
2585
- children?: RenderableContent<SwiperSlideContext> | null;
2586
- }
2587
- interface NormalizedSwiperDataItem extends SwiperDataItem {
2588
- blank: boolean;
2589
- index: number;
2590
- }
2591
- interface SwiperSlideContext {
2592
- swiper: Swiper;
2593
- item: NormalizedSwiperDataItem;
2594
- index: number;
2595
- }
2596
- interface SwiperOptions extends Record<string, unknown> {
2597
- data?: SwiperDataItem[] | null;
2598
- loop?: boolean;
2599
- autoplay?: boolean;
2600
- delay?: number;
2601
- lazyload?: boolean;
2602
- pagination?: boolean;
2603
- navigation?: boolean;
2604
- speed?: number;
2605
- touchRatio?: number;
2606
- touchAngle?: number;
2607
- longSwipesMs?: number;
2608
- longSwipesRatio?: number;
2609
- preventClick?: boolean;
2610
- className?: SwiperClassNameConfig;
2611
- }
2612
- interface ResolvedSwiperOptions extends Record<string, unknown> {
2613
- data: SwiperDataItem[] | null;
2614
- loop: boolean;
2615
- autoplay: boolean;
2616
- delay: number;
2617
- lazyload: boolean;
2618
- pagination: boolean;
2619
- navigation: boolean;
2620
- speed: number;
2621
- touchRatio: number;
2622
- touchAngle: number;
2623
- longSwipesMs: number;
2624
- longSwipesRatio: number;
2625
- preventClick: boolean;
2626
- className: SwiperClassNames;
2627
- }
2628
- interface SwiperState extends Record<string, unknown> {
2629
- index: number;
2630
- trackIndex: number;
2631
- transform: number;
2632
- animating: boolean;
2633
- width: number;
2634
- }
2635
- interface SwiperDOM extends ComponentDOM {
2636
- root: HTMLElement | null;
2637
- container: DOMReference;
2638
- mountTarget: Element | null;
2639
- createdRoot: boolean;
2640
- createdSlides: boolean;
2641
- wrapper: HTMLElement | null;
2642
- slides: HTMLElement[];
2643
- pagination: HTMLElement | null;
2644
- prevButton: HTMLButtonElement | null;
2645
- nextButton: HTMLButtonElement | null;
2646
- bullets: HTMLButtonElement[];
2647
- createdPagination: boolean;
2648
- createdPrevButton: boolean;
2649
- createdNextButton: boolean;
2650
- }
2651
- interface SwipeLog {
2652
- x: number;
2653
- y: number;
2654
- time: number;
2655
- }
2656
- interface SwipePoint {
2657
- pageX?: number;
2658
- pageY?: number;
2659
- clientX?: number;
2660
- clientY?: number;
2661
- }
2662
- interface SwiperRuntime extends ComponentRuntime {
2663
- logs: SwipeLog[];
2664
- startTarget: EventTarget | null;
2665
- touching: boolean;
2666
- scrolling: boolean;
2667
- swiping: boolean;
2668
- clickPrevented: boolean;
2669
- timer: ReturnType<typeof setInterval> | null;
2670
- imageCleanups: Set<() => void>;
2671
- realCount: number;
2672
- }
2673
- interface SwiperCleanupExtras {
2674
- bindings?: (() => void) | null;
2675
- navBindings?: (() => void) | null;
2676
- }
2677
- type SwiperUpdateOptions = Partial<ComponentUpdateOptions>;
2678
- type SwiperDirection = 'prev' | 'next';
2679
- /**
2680
- * 轻量轮播组件,继承 Component。
2681
- *
2682
- * 支持链接 slide、图片 lazyload、分页、导航、loop 和桌面/移动端拖拽滑动。
2683
- * 使用 vanilla-signal 响应式管理 pagination 和 navigation 状态。
2684
- */
2685
- declare class Swiper extends Component<ResolvedSwiperOptions, SwiperState, SwiperDOM> {
2686
- props: ResolvedSwiperOptions;
2687
- state: SwiperState;
2688
- dom: SwiperDOM;
2689
- runtime: SwiperRuntime;
2690
- cleanup: Component['cleanup'] & SwiperCleanupExtras;
2691
- private _built;
2692
- /**
2693
- * 创建轮播实例。
2694
- * @param {Element|Node|string|Array} container 挂载容器、选择器或 JSX/h 返回节点。
2695
- * @param {object} [options={}] Swiper 配置。
2696
- */
2697
- constructor(container: DOMReference, options?: SwiperOptions);
2698
- /**
2699
- * 构建或绑定 Swiper DOM。
2700
- * @returns {Swiper} 当前实例。
2701
- */
2702
- build(): this;
2703
- set index(v: unknown);
2704
- set trackIndex(v: unknown);
2705
- set transform(v: unknown);
2706
- set animating(v: unknown);
2707
- set width(v: unknown);
2708
- get realCount(): number;
2709
- get realIndex(): number;
2710
- assertBuilt(method: string): void;
2711
- createDataView(root: HTMLElement, data: SwiperDataItem[] | null): HTMLElement;
2712
- normalizeData(data: SwiperDataItem[] | null): NormalizedSwiperDataItem[];
2713
- createDataSlide(item: NormalizedSwiperDataItem, index: number): HTMLElement;
2714
- protected onInit(): void;
2196
+ private bindState;
2197
+ private syncState;
2198
+ private renderItems;
2199
+ private getPageItems;
2200
+ private isLocked;
2201
+ private isPrevDisabled;
2202
+ private isNextDisabled;
2203
+ private buildControlItem;
2204
+ private buildPageItem;
2205
+ private bindEvents;
2206
+ private unbindEvents;
2207
+ private unlock;
2208
+ private assertActive;
2209
+ protected normalizeStatePatch(patch: Partial<PaginationState>): Partial<PaginationState>;
2210
+ protected validateStatePatch(patch: Partial<PaginationState>): void;
2715
2211
  protected onDestroy(): void;
2716
- updateSize(): void;
2717
- refreshSlides(): void;
2718
- initLoop(): void;
2719
- setupStyles(): void;
2720
- reInitView(): void;
2721
- clearPagination(): void;
2722
- clearNavigation(): void;
2723
- bindEvents(): void;
2724
- onStart(point: SwipePoint, target?: EventTarget | null): void;
2725
- onMove(point: SwipePoint, event: Event): void;
2726
- onEnd(): void;
2727
- resetDrag(animate?: boolean): void;
2728
- onTransitionEnd(event?: Event): void;
2729
- pushLog(point: SwipePoint): void;
2730
- getDuration(): number;
2731
- getOffset(): {
2732
- x: number;
2733
- y: number;
2734
- };
2735
- toRealIndex(index?: number): number;
2736
- trackIndexForRealIndex(index: number): number;
2737
- setTrackIndex(trackIndex: number, animate?: boolean | null): void;
2738
- slideTo(index: number): void;
2739
- slideToTrack(idx: number): void;
2740
- next(): void;
2741
- prev(): void;
2742
- render(animate: boolean): void;
2743
- loadImages(): void;
2744
- clearImageCleanups(): void;
2745
- initPagination(): void;
2746
- initNavigation(): void;
2747
- ensureNavigation(direction: SwiperDirection, iconName: 'arrow-left' | 'arrow-right'): HTMLButtonElement;
2748
- play(): void;
2749
- pause(): void;
2750
- resume(): void;
2751
- restartAutoplay(): void;
2752
- update(propsPatch?: SwiperOptions | null | undefined, { force }?: SwiperUpdateOptions): this;
2753
- protected onUpdate(propsPatch?: Partial<ResolvedSwiperOptions> | null | undefined, _options?: Required<ComponentUpdateOptions>): void;
2754
- updateData(data?: SwiperDataItem[] | null): this;
2755
2212
  }
2756
- declare function createSwiper(container: DOMReference, input?: SwiperOptions): Swiper;
2213
+ type Pagination = PaginationComponent;
2214
+ declare function createPagination(input?: PaginationProps): Pagination;
2757
2215
  //#endregion
2758
2216
  //#region src/components/menu.d.ts
2759
- type MenuType = string;
2217
+ type MenuType = string | undefined;
2760
2218
  type MenuItemId = string | number;
2761
2219
  interface MenuClassNames {
2762
2220
  root: string;
@@ -2765,10 +2223,9 @@ interface MenuClassNames {
2765
2223
  hasChildren: string;
2766
2224
  link: string;
2767
2225
  subMenu: string;
2768
- back: string;
2226
+ backItem: string;
2769
2227
  active: string;
2770
- icon: string;
2771
- iconPrefix: string;
2228
+ backIcon: string;
2772
2229
  text: string;
2773
2230
  }
2774
2231
  type MenuClassNameConfig = Partial<MenuClassNames>;
@@ -2780,135 +2237,55 @@ interface MenuItem extends Record<string, unknown> {
2780
2237
  classes?: string | string[];
2781
2238
  children?: MenuItem[];
2782
2239
  }
2783
- interface MenuOptions extends Record<string, unknown> {
2240
+ interface MenuProps extends Record<string, unknown> {
2784
2241
  type?: MenuType;
2785
- id?: string;
2786
- items?: MenuItem[];
2242
+ id?: string | null;
2243
+ data?: MenuItem[];
2787
2244
  backText?: string;
2788
2245
  className?: MenuClassNameConfig;
2789
2246
  }
2790
- interface ResolvedMenuOptions extends Record<string, unknown> {
2791
- type: MenuType;
2247
+ interface ResolvedMenuProps extends Record<string, unknown> {
2248
+ type?: MenuType;
2792
2249
  id: string;
2793
- items: MenuItem[];
2250
+ data: MenuItem[];
2794
2251
  backText: string;
2795
2252
  className: MenuClassNames;
2796
2253
  }
2797
- interface MenuDOM {
2254
+ interface MenuState extends Record<string, unknown> {
2255
+ data: MenuItem[];
2256
+ }
2257
+ interface MenuDOM extends ComponentDOM {
2798
2258
  root: HTMLElement | null;
2259
+ list: HTMLElement | null;
2799
2260
  }
2800
- interface MenuCleanup {
2801
- events: IEventManager;
2802
- items?: (() => void) | null;
2261
+ interface MenuRuntime extends ComponentRuntime {
2262
+ built: boolean;
2803
2263
  }
2804
- /**
2805
- * 菜单组件。
2806
- *
2807
- * 支持绑定已有菜单 DOM,也支持通过配置动态创建移动菜单或底部菜单。
2808
- */
2809
- declare class Menu {
2810
- options: ResolvedMenuOptions | null;
2811
- dom: MenuDOM;
2812
- cleanup: MenuCleanup | null;
2813
- private _element;
2814
- private _bound;
2815
- private _destroyed;
2816
- /**
2817
- * 创建菜单实例。
2818
- * @param {MenuOptions} [options={}] 菜单配置。
2819
- * @param {Element|Node|string|Array|false} [element=false] 已有菜单节点、选择器或 JSX/h 返回节点;默认 `false` 按 items 动态创建。
2820
- */
2821
- constructor(options?: MenuOptions, element?: DOMReference);
2822
- get root(): HTMLElement | null;
2823
- /**
2824
- * 校验菜单数据。
2825
- * @private
2826
- * @param {MenuItem[]} items 菜单数据。
2827
- * @returns {void}
2828
- */
2829
- _verifyItems(items: MenuItem[]): void;
2830
- /**
2831
- * 构建菜单。
2832
- *
2833
- * element 为 false 时动态创建 DOM;否则绑定已有节点。
2834
- * @returns {Menu}
2835
- */
2264
+ interface MenuCleanupExtras {
2265
+ state?: (() => void) | null;
2266
+ }
2267
+ declare class MenuComponent extends Component<ResolvedMenuProps, MenuState, MenuDOM> {
2268
+ runtime: MenuRuntime;
2269
+ state: MenuState;
2270
+ cleanup: Component['cleanup'] & MenuCleanupExtras;
2271
+ constructor(input?: MenuProps);
2836
2272
  build(): this;
2837
- /**
2838
- * 根据 items 创建菜单根节点。
2839
- * @private
2840
- * @returns {HTMLElement}
2841
- */
2842
- _buildRoot(): HTMLElement;
2843
- /**
2844
- * 递归创建菜单项。
2845
- * @private
2846
- * @param {MenuItem} item 菜单项配置。
2847
- * @returns {HTMLElement}
2848
- */
2849
- _buildItem(item: MenuItem): HTMLElement;
2850
- /**
2851
- * 根据菜单类型绑定交互事件。
2852
- * @private
2853
- * @returns {void}
2854
- */
2855
- _bindEvents(): void;
2856
- /**
2857
- * 解绑当前菜单实例绑定的事件。
2858
- * @private
2859
- * @returns {void}
2860
- */
2861
- _unbindEvents(): void;
2862
- /**
2863
- * 清理当前构建出的 DOM 与事件,可选择保留实例引用用于重建。
2864
- * @private
2865
- * @param {object} [options={}] 清理选项。
2866
- * @param {boolean} [options.keepElement=false] 是否保留初始 element 引用。
2867
- * @returns {void}
2868
- */
2869
- _teardown({ keepElement }?: {
2870
- keepElement?: boolean;
2871
- }): void;
2872
- /**
2873
- * 处理移动端有子菜单项的进入操作。
2874
- * @private
2875
- * @param {HTMLElement} menuItem 菜单项节点。
2876
- * @returns {void}
2877
- */
2878
- _handleMenuClick(menuItem: HTMLElement): void;
2879
- /**
2880
- * 处理移动端子菜单返回操作。
2881
- * @private
2882
- * @param {Element} target 点击目标。
2883
- * @returns {void}
2884
- */
2885
- _handleBack(target: Element): void;
2886
- /**
2887
- * 切换底部菜单激活状态。
2888
- * @private
2889
- * @param {HTMLElement} menuItem 菜单项节点。
2890
- * @returns {void}
2891
- */
2892
- _toggleActive(menuItem: HTMLElement): void;
2893
- _clearActive(): void;
2894
- /**
2895
- * 替换菜单数据;动态创建的菜单会在已构建时重建 DOM。
2896
- * @param {MenuItem[]} items 新菜单数据。
2897
- * @returns {Menu}
2898
- */
2899
- setItems(items: MenuItem[]): this;
2900
- /**
2901
- * 根据 id 移除菜单项。
2902
- * @param {string|number} id 菜单项 id。
2903
- * @returns {Menu}
2904
- */
2905
- removeItem(id: MenuItemId): this;
2906
- /**
2907
- * 销毁当前菜单实例并解绑事件。
2908
- * @returns {void}
2909
- */
2910
- destroy(): void;
2273
+ private bindState;
2274
+ private renderSnapshot;
2275
+ private buildItem;
2276
+ private bindEvents;
2277
+ private unbindEvents;
2278
+ private handleMenuClick;
2279
+ private handleBack;
2280
+ private toggleActive;
2281
+ private clearActive;
2282
+ private validateData;
2283
+ private assertStatePatchKey;
2284
+ protected normalizeStatePatch(patch: Partial<MenuState>): Partial<MenuState>;
2285
+ protected validateStatePatch(patch: Partial<MenuState>): void;
2286
+ protected onDestroy(): void;
2911
2287
  }
2912
- declare function createMenu(options?: MenuOptions, element?: DOMReference): Menu;
2288
+ type Menu = MenuComponent;
2289
+ declare function createMenu(input?: MenuProps): Menu;
2913
2290
  //#endregion
2914
- export { Accordion, AccordionActive, AccordionClassNameConfig, AccordionClassNames, AccordionContentContext, AccordionItem, AccordionProps, CleanupFunction, Component, ContainerExpect, DOMReference, DebounceOptions, DebouncedFunction, Destroyable, Drop, DropClassNameConfig, DropClassNames, DropDelay, DropMode, DropPosition, DropProps, Flow, FlowAction, FlowBusyHook, FlowBusyStrategy, FlowChangeHook, FlowClassNameConfig, FlowClassNames, FlowCleanup, FlowContext, FlowData, FlowDirection, FlowErrorHook, FlowFinishHook, FlowGuardHook, FlowLifecycleHook, FlowMoveHook, FlowOptions, FlowPayload, FlowRenderContext, FlowSlot, FlowSlotName, FlowSnapshot, FlowState, FlowStep, FlowStepResult, FlowSubscriber, FlowTarget, FlowText, Form, FormButton, FormClassNameConfig, FormClassNames, FormDataRecord, FormDataValue, FormField, FormOption, FormProps, FormValidatorConfig, IEventManager, IconAttributeValue, IconName, IconPathMap, IconProps, LazyRenderCallback, LazyRenderOptions, LazyRenderTarget, Menu, MenuClassNameConfig, MenuClassNames, MenuItem, MenuItemId, MenuOptions, MenuType, Modal, ModalClassNameConfig, ModalClassNames, ModalProps, ModalText, NormalizeContext, Offcanvas, OffcanvasAnimation, OffcanvasClassNameConfig, OffcanvasClassNames, OffcanvasContent, OffcanvasDirection, OffcanvasProps, Pagination, PaginationClassNameConfig, PaginationClassNames, PaginationCount, PaginationPage, PaginationProps, Parabola, ParabolaBallOptions, ParabolaClassNameConfig, ParabolaClassNames, ParabolaDirection, ParabolaOptions, ParamRule, ParamRuleInput, PublicFlowStep, QueryContext, RenderableContent, RequireContainerResult, ResolveContainerResult, ResolveSchema, ResolvedProps, Sticky, StickyOverflow, StickyProps, StickyStateItem, Swiper, SwiperClassNameConfig, SwiperClassNames, SwiperDataItem, SwiperOptions, SwiperSlideContext, TabItem, TabPanel, TabTitleContext, Tabs, TabsClassNameConfig, TabsClassNames, TabsDirection, TabsDisabled, TabsPanelContext, TabsProps, TabsValue, Theme, ThemeClassNameConfig, ThemeClassNames, ThemeConfigKey, ThemeOptions, ThemePanelGroup, Toast, ToastActionProps, ToastClassNameConfig, ToastClassNames, ToastOptions, ToastType, Toc, TocClassNameConfig, TocClassNames, TocCurrent, TocItem, TocProps, Tooltip, TooltipClassNameConfig, TooltipClassNames, TooltipProps, ValidateCondition, Validator, ValidatorOptions, ValidatorRule, addIcons, all, copy, createAccordion, createDrop, createEventManager, createFlow, createForm, createLoading, createMenu, createModal, createOffcanvas, createPagination, createParabola, createSticky, createSwiper, createTabs, createToc, createTooltip, createValidator, debounce, getCookie, getRegistedIconPath, getType, hasOwn, icon, iconHtml, iconMarkup, isClass, isElement, isFunction, isMobile, isNode, isPlainObject, isRenderableContent, lazyRender, listen, normalizeContentNodes, postJson, q, randomId, removeCookie, requireContainer, resolveContainer, resolveElement, resolveNode, resolveNodeList, resolveProps, restUrl, service, setCookie, throttle, timer, uniq, uuid, validateParam };
2291
+ export { CleanupFunction, Component, ContainerExpect, DOMReference, type DebounceSettings, type DebouncedFunc, FlowAction, FlowBusyHook, FlowBusyStrategy, FlowChangeHook, FlowClassNameConfig, FlowClassNames, FlowCleanup, FlowContext, FlowData, FlowDirection, FlowErrorHook, FlowFinishHook, FlowGuardHook, FlowLifecycleHook, FlowMoveHook, FlowPayload, FlowProps, FlowRenderContext, FlowSlot, FlowSlotName, FlowSnapshot, FlowState, FlowStep, FlowStepResult, FlowSubscriber, FlowTarget, FlowText, FormButton, FormClassNameConfig, FormClassNames, FormDataRecord, FormDataValue, FormField, FormOption, FormProps, FormValidatorConfig, IEventManager, IconAttributeValue, IconName, IconPathMap, IconProps, LazyRenderCallback, LazyRenderOptions, LazyRenderTarget, Menu, MenuClassNameConfig, MenuClassNames, MenuItem, MenuItemId, MenuProps, MenuType, Modal, ModalClassNameConfig, ModalClassNames, ModalMode, ModalProps, ModalText, NormalizeContext, Offcanvas, OffcanvasAnimate, OffcanvasClassNameConfig, OffcanvasClassNames, OffcanvasContent, OffcanvasDirection, OffcanvasProps, Pagination, PaginationClassNameConfig, PaginationClassNames, PaginationCount, PaginationPage, PaginationProps, ParamRule, ParamRuleInput, PopupProps, PublicFlowStep, QueryContext, RenderableContent, RequireContainerResult, ResolveContainerResult, ResolveSchema, ResolvedProps, Swiper, SwiperClassNameConfig, SwiperClassNames, SwiperDataItem, SwiperProps, SwiperSlideContext, TabItem, TabPanel, TabTitleContext, Tabs, TabsClassNameConfig, TabsClassNames, TabsDirection, TabsDisabled, TabsPanelContext, TabsProps, TabsValue, ThemeClassNameConfig, ThemeClassNames, ThemeConfigKey, ThemeInstance, ThemeOptions, ThemePanelGroup, ThemeResolvedOptions, type ThrottleSettings, Toast, ToastActionProps, ToastClassNameConfig, ToastClassNames, ToastOptions, ToastType, ValidateCondition, addIcons, all, copy, createAccordion, createDrop, createEventManager, createFlow, createForm, createLoading, createMenu, createModal, createOffcanvas, createPagination, createParabola, createPopup, createSticky, createSwiper, createTabs, createTheme, createToc, createTooltip, createValidator, debounce, getRegistedIconPath, getType, icon, iconHtml, iconMarkup, isDomElementValue, isDomNodeValue, isElement, isHtmlElementValue, isMobile, isNilValue, isNode, isPlainObject, isRenderableContent, isRenderablePrimitive, isRenderableValue, lazyRender, listen, normalizeContentNodes, normalizeRenderableContentNodes, postJson, q, randomId, requireContainer, resolveContainer, resolveElement, resolveNode, resolveNodeList, resolveProps, restUrl, throttle, timer, uuid, validateParam };