vanilla-jui 1.3.11 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/index.d.ts +2921 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.umd.js +1 -1
  4. package/dist/style.css +1 -1
  5. package/package.json +4 -3
  6. package/src/components/accordion.ts +522 -0
  7. package/src/components/drop.ts +497 -0
  8. package/src/components/flow.ts +1579 -0
  9. package/src/components/form.ts +953 -0
  10. package/src/components/{icons.js → icons.ts} +24 -11
  11. package/src/components/menu.ts +615 -0
  12. package/src/components/{modal.js → modal.ts} +560 -237
  13. package/src/components/offcanvas.ts +457 -0
  14. package/src/components/{pagination.js → pagination.ts} +251 -76
  15. package/src/components/parabola.ts +335 -0
  16. package/src/components/{sticky.js → sticky.ts} +123 -98
  17. package/src/components/{swiper.js → swiper.ts} +510 -232
  18. package/src/components/tabs.ts +984 -0
  19. package/src/components/theme.ts +437 -0
  20. package/src/components/toast.ts +371 -0
  21. package/src/components/toc.ts +385 -0
  22. package/src/components/tooltip.ts +179 -0
  23. package/src/components/validator.ts +596 -0
  24. package/src/core/{Component.js → Component.ts} +134 -27
  25. package/src/css/accordion.css +0 -45
  26. package/src/css/animation.css +31 -1
  27. package/src/css/avatar.css +7 -33
  28. package/src/css/badge.css +11 -59
  29. package/src/css/breadcrumb.css +9 -32
  30. package/src/css/button.css +23 -224
  31. package/src/css/card.css +1 -1
  32. package/src/css/color.css +863 -1013
  33. package/src/css/color_p3.css +822 -975
  34. package/src/css/components.css +1 -0
  35. package/src/css/drop.css +7 -7
  36. package/src/css/flow.css +1 -1
  37. package/src/css/form.css +1 -1
  38. package/src/css/icon.css +7 -12
  39. package/src/css/index.css +5 -2
  40. package/src/css/loading.css +36 -20
  41. package/src/css/menu.css +1 -1
  42. package/src/css/modal.css +15 -44
  43. package/src/css/offcanvas.css +14 -40
  44. package/src/css/popup.css +4 -4
  45. package/src/css/status.css +0 -2
  46. package/src/css/swiper.css +35 -50
  47. package/src/css/tabs.css +9 -31
  48. package/src/css/tag.css +16 -77
  49. package/src/css/themes/default/accordion.css +62 -0
  50. package/src/css/themes/default/avatar.css +39 -0
  51. package/src/css/themes/default/badge.css +63 -0
  52. package/src/css/themes/default/breadcrumb.css +28 -0
  53. package/src/css/themes/default/button.css +204 -0
  54. package/src/css/themes/default/drop.css +11 -0
  55. package/src/css/themes/default/index.css +16 -0
  56. package/src/css/themes/default/loading.css +23 -0
  57. package/src/css/themes/default/modal.css +40 -0
  58. package/src/css/themes/default/offcanvas.css +13 -0
  59. package/src/css/themes/default/popup.css +7 -0
  60. package/src/css/themes/default/swiper.css +35 -0
  61. package/src/css/themes/default/tabs.css +37 -0
  62. package/src/css/themes/default/tag.css +85 -0
  63. package/src/css/themes/default/tip.css +49 -0
  64. package/src/css/themes/default/toast.css +70 -0
  65. package/src/css/themes/default/tooltip.css +14 -0
  66. package/src/css/themes/index.css +1 -0
  67. package/src/css/tip.css +20 -39
  68. package/src/css/toast.css +18 -80
  69. package/src/css/tokens.css +8 -3
  70. package/src/css/tooltip.css +10 -10
  71. package/src/index.ts +37 -0
  72. package/src/locales/{index.js → index.ts} +1 -2
  73. package/src/types.d.ts +1 -0
  74. package/src/utilities/browser.ts +131 -0
  75. package/src/utilities/cache.ts +57 -0
  76. package/src/utilities/core.ts +614 -0
  77. package/src/utilities/dom.ts +468 -0
  78. package/src/utilities/events.ts +106 -0
  79. package/src/utilities/http.ts +35 -0
  80. package/src/utilities/storage.ts +46 -0
  81. package/src/components/accordion.js +0 -373
  82. package/src/components/components.js +0 -0
  83. package/src/components/drop.js +0 -437
  84. package/src/components/flow.js +0 -1133
  85. package/src/components/form.js +0 -585
  86. package/src/components/menu.js +0 -422
  87. package/src/components/offcanvas.js +0 -332
  88. package/src/components/parabola.js +0 -295
  89. package/src/components/tabs.js +0 -746
  90. package/src/components/theme.js +0 -353
  91. package/src/components/toast.js +0 -329
  92. package/src/components/toc.js +0 -226
  93. package/src/components/tooltip.js +0 -86
  94. package/src/components/validator.js +0 -586
  95. package/src/index.js +0 -45
  96. package/src/locales/index.min.js +0 -1
  97. package/src/utilities/browser.js +0 -111
  98. package/src/utilities/cache.js +0 -159
  99. package/src/utilities/core.js +0 -502
  100. package/src/utilities/debug.js +0 -103
  101. package/src/utilities/dom.js +0 -313
  102. package/src/utilities/events.js +0 -69
  103. package/src/utilities/http.js +0 -30
  104. package/src/utilities/legacy-dom.js +0 -179
  105. package/src/utilities/storage.js +0 -46
  106. /package/src/icons/{index.js → index.ts} +0 -0
@@ -0,0 +1,2921 @@
1
+ //#region src/utilities/browser.d.ts
2
+ declare global {
3
+ interface Navigator {
4
+ userAgentData?: {
5
+ mobile: boolean;
6
+ brands: Array<{
7
+ brand: string;
8
+ version: string;
9
+ }>;
10
+ platform: string;
11
+ getHighEntropyValues: (hints: string[]) => Promise<any>;
12
+ };
13
+ }
14
+ interface Window {
15
+ opera?: string;
16
+ }
17
+ }
18
+ /**
19
+ * 判断当前环境是否为移动设备。
20
+ * @returns {boolean}
21
+ */
22
+ declare function isMobile(): boolean;
23
+ /**
24
+ * 复制文本到剪贴板。
25
+ *
26
+ * 优先使用 Clipboard API,不可用时降级到 textarea + execCommand。
27
+ * @param {unknown} text 需要复制的文本(接受任意类型,内部会安全转换为字符串)。
28
+ * @returns {Promise<boolean>} 是否复制成功。
29
+ */
30
+ declare function copy(text: unknown): Promise<boolean>;
31
+ //#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>;
181
+ /**
182
+ * 生成标准 UUID v4 字符串。
183
+ *
184
+ * 优先使用浏览器原生的 crypto.randomUUID(),
185
+ * 不支持时使用 polyfill 实现。
186
+ *
187
+ * @returns UUID v4 字符串(如 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
188
+ */
189
+ declare function uuid(): string;
190
+ /**
191
+ * 生成适合 DOM id 的随机字符串。
192
+ *
193
+ * 使用安全的随机数生成器,生成的字符串适合作为 HTML 元素的 id 属性。
194
+ *
195
+ * @param [length=8] - 字符串长度,范围 1 到 87381
196
+ * @returns 随机字符串
197
+ * @throws {Error} 长度不在有效范围内时抛出错误
198
+ */
199
+ 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
+ //#endregion
239
+ //#region src/utilities/dom.d.ts
240
+ type ContainerExpect = 'node' | 'element' | 'array';
241
+ type ResolveContainerResult<TExpect extends ContainerExpect = 'element'> = TExpect extends 'array' ? Node[] : TExpect extends 'node' ? Node : Element;
242
+ type RequireContainerResult<TExpect extends ContainerExpect = 'element'> = NonNullable<ResolveContainerResult<TExpect>>;
243
+ type DOMReference = Node | string | readonly DOMReference[] | false | null | undefined;
244
+ type QueryContext = Document | DocumentFragment | Element;
245
+ type CleanupFunction = () => void;
246
+ type LazyRenderTarget = string | Element;
247
+ type LazyRenderCallback = () => void;
248
+ type RenderableContent<TContext = unknown> = Node | string | number | boolean | null | undefined | readonly RenderableContent<TContext>[] | ((context: TContext) => RenderableContent<TContext>);
249
+ interface LazyRenderOptions {
250
+ threshold?: number | number[];
251
+ rootMargin?: string;
252
+ root?: Element | Document | null;
253
+ waitForDOM?: boolean;
254
+ }
255
+ /**
256
+ * 判断是否为 DOM Node。
257
+ * @param {*} value 需要判断的值。
258
+ * @returns {boolean}
259
+ */
260
+ declare function isNode(value: unknown): value is Node;
261
+ /**
262
+ * 判断是否为 DOM Element。
263
+ * @param {*} value 需要判断的值。
264
+ * @returns {boolean}
265
+ */
266
+ declare function isElement(value: unknown): value is Element;
267
+ /**
268
+ * 将可渲染内容归一化为 DOM 节点数组。
269
+ *
270
+ * 支持的输入类型:
271
+ * - **Node/Element**: 包装为单元素数组
272
+ * - **string**: 按 HTML 片段解析为节点数组
273
+ * - **number/boolean**: 转换为文本节点
274
+ * - **Array**: 递归扁平化处理
275
+ * - **Function**: 调用后递归处理返回值
276
+ * - **null/undefined/false/true**: 返回空数组
277
+ *
278
+ * @param {RenderableContent<TContext>} content 可渲染内容。
279
+ * @param {TContext} [context] 传递给函数类型内容的上下文。
280
+ * @returns {Node[]} 归一化后的节点数组。
281
+ */
282
+ declare function normalizeContentNodes<TContext = unknown>(content: RenderableContent<TContext>, context?: TContext): Node[];
283
+ /**
284
+ * 将 DOM 引用解析为节点列表。
285
+ *
286
+ * 支持的输入类型:
287
+ * - **Node**: 包装为单元素数组,如 `document.body`
288
+ * - **Element**: 包装为单元素数组,如 `div`
289
+ * - **string**: CSS 选择器,如 `'div'`, `'.class'`, `'#id'`
290
+ * - **Array**: 扁平化为节点数组,如 `[el1, [el2, el3]]`
291
+ * - **false/null/undefined**: 返回 null
292
+ *
293
+ * @param {Element|Node|string|Array|false|null|undefined} ref 元素引用、选择器、节点或空值。
294
+ * @returns {Node[]|null}
295
+ */
296
+ declare function resolveNodeList(ref: DOMReference): Node[] | null;
297
+ /**
298
+ * 将 DOM 引用解析为节点。
299
+ *
300
+ * 支持的输入类型:
301
+ * - **Node/Element**: 直接返回,如 `document.body`, `div`
302
+ * - **string**: CSS 选择器,如 `'div'`, `'.class'`, `'#id'`
303
+ * - **Array**: 返回第一个节点,如 `[el1, el2]`
304
+ * - **false/null/undefined**: 返回 null
305
+ *
306
+ * @param {Element|Node|string|Array|false|null|undefined} ref 元素引用、选择器、节点或空值。
307
+ * @returns {Node|null}
308
+ */
309
+ declare function resolveNode(ref: DOMReference): Node | null;
310
+ /**
311
+ * 将 DOM 引用解析为元素。
312
+ *
313
+ * 支持的输入类型:
314
+ * - **Element**: 直接返回,如 `document.querySelector('#app')`
315
+ * - **string**: CSS 选择器,如 `'div'`, `'.class'`, `'#id'`
316
+ * - **Array**: 返回第一个 Element,如 `[el1, el2]`
317
+ * - **false/null/undefined**: 返回 null
318
+ *
319
+ * @param {Element|Node|string|Array|false|null|undefined} ref 元素引用、选择器、节点或空值。
320
+ * @returns {Element|null}
321
+ */
322
+ declare function resolveElement(ref: DOMReference): Element | null;
323
+ /**
324
+ * 统一解析容器引用。
325
+ *
326
+ * @param {Element|Node|string|Array|false|null|undefined} container 容器引用、选择器、节点或数组。
327
+ * @param {string} [namespace='Component'] 错误命名空间。
328
+ * @param {'node'|'element'|'array'} [expect='element'] 期望返回类型。
329
+ * @returns {Node|Element|Node[]|null}
330
+ */
331
+ declare function resolveContainer<TExpect extends ContainerExpect = 'element'>(container: DOMReference, namespace?: string, expect?: TExpect): ResolveContainerResult<TExpect> | null;
332
+ /**
333
+ * 强制解析容器并要求返回值存在。
334
+ *
335
+ * @param {Element|Node|string|Array|false|null|undefined} container 容器引用、选择器、节点或数组。
336
+ * @param {string} [namespace='Component'] 错误命名空间。
337
+ * @param {'node'|'element'|'array'} [expect='element'] 期望返回类型。
338
+ * @returns {Node|Element|Node[]}
339
+ */
340
+ declare function requireContainer<TExpect extends ContainerExpect = 'element'>(container: DOMReference, namespace?: string, expect?: TExpect): RequireContainerResult<TExpect>;
341
+ /**
342
+ * 判断是否为组件可渲染内容。
343
+ * @param {*} value 需要判断的值。
344
+ * @returns {boolean}
345
+ */
346
+ declare function isRenderableContent(value: unknown): value is RenderableContent;
347
+ /**
348
+ * 创建通用加载状态节点。
349
+ * @returns {HTMLElement}
350
+ */
351
+ declare function createLoading(): HTMLDivElement;
352
+ /**
353
+ * 根据 CSS 选择器获取第一个匹配的元素。
354
+ * @param {string} selector CSS 选择器。
355
+ * @param {Document|Element} [context=document] 查询范围。
356
+ * @returns {Element|null}
357
+ */
358
+ declare function q<TElement extends Element = Element>(selector: string, context?: QueryContext): TElement | null;
359
+ /**
360
+ * 根据 CSS 选择器获取所有匹配的元素。
361
+ * @param {string} selector CSS 选择器。
362
+ * @param {Document|Element} [context=document] 查询范围。
363
+ * @returns {Element[]}
364
+ */
365
+ declare function all<TElement extends Element = Element>(selector: string, context?: QueryContext): TElement[];
366
+ /**
367
+ * 当目标元素进入可视区域时执行渲染回调,仅执行一次后自动清理。
368
+ *
369
+ * 支持选择器字符串或 Element。目标尚未挂载时默认等待 DOM 变化;不支持
370
+ * IntersectionObserver 时会立即执行回调,保证降级环境也能渲染。
371
+ * @param {string|Element} target CSS 选择器或 DOM 元素。
372
+ * @param {Function} renderCallback 渲染回调函数,仅执行一次。
373
+ * @param {Object} [options] 配置项。
374
+ * @returns {Function} 停止观察的清理函数。
375
+ */
376
+ declare function lazyRender(target: LazyRenderTarget, renderCallback: LazyRenderCallback, options?: LazyRenderOptions): CleanupFunction;
377
+ //#endregion
378
+ //#region src/utilities/events.d.ts
379
+ /**
380
+ * 绑定 DOM 事件并返回一次性解绑函数。
381
+ *
382
+ * @template T - 事件目标类型(如 HTMLElement, Window 等)
383
+ * @template K - 事件类型字符串(如 'click', 'scroll')
384
+ * @param {T} target - 事件目标。
385
+ * @param {K} type - 事件类型。
386
+ * @param {(this: T, ev: HTMLElementEventMap[K extends keyof HTMLElementEventMap ? K : never]) => any} handler - 事件处理器。
387
+ * @param {boolean | AddEventListenerOptions} [options] - 事件选项。
388
+ * @returns {() => void} 解绑函数,可重复调用。
389
+ */
390
+ declare function listen<T extends EventTarget, K extends string>(target: T, type: K, handler: (this: T, ev: Event) => any, options?: boolean | AddEventListenerOptions): () => void;
391
+ /**
392
+ * 事件管理器实例的接口定义
393
+ */
394
+ interface IEventManager {
395
+ /**
396
+ * 绑定事件并自动记录解绑函数。
397
+ * 同一个 key 重复绑定时会先解绑旧事件,避免组件重渲染时重复监听。
398
+ */
399
+ on<T extends EventTarget, K extends string>(key: string, target: T, type: K, handler: (this: T, ev: Event) => any, options?: boolean | AddEventListenerOptions): () => void;
400
+ /** 根据 key 解绑特定事件 */
401
+ off(key: string): boolean;
402
+ /** 清除所有已绑定的事件 */
403
+ clear(): void;
404
+ /** 获取当前绑定的事件数量 */
405
+ size(): number;
406
+ }
407
+ /**
408
+ * 创建实例级事件管理器。
409
+ *
410
+ * - `on()` 绑定事件并自动记录解绑函数。
411
+ * - 同一个 key 重复绑定时会先解绑旧事件,避免组件重渲染时重复监听。
412
+ * - `off(key)` 和 `clear()` 用于跨作用域精确释放。
413
+ */
414
+ declare function createEventManager(): IEventManager;
415
+ //#endregion
416
+ //#region src/utilities/http.d.ts
417
+ /**
418
+ * 发送 JSON POST 请求并解析 JSON 响应。
419
+ * @template T - 期望返回的 JSON 数据类型
420
+ * @param {string} url - 请求地址
421
+ * @param {unknown} body - 请求体,会被 JSON.stringify
422
+ * @param {RequestInit} [options] - 透传给 fetch 的请求配置(排除 method 和 body)
423
+ * @returns {Promise<T>} 解析后的 JSON 响应体
424
+ */
425
+ 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
+ //#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;
436
+ //#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
+ }
466
+ /**
467
+ * 轻量级组件基类,集成 vanilla-signal 响应式状态和插件系统
468
+ * 为所有 UI 组件提供统一的状态管理、生命周期钩子和插件支持
469
+ */
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;
565
+ /**
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} 如果组件已被销毁则抛出异常
574
+ */
575
+ update(propsPatch?: Partial<TProps> | null | undefined, { force }?: ComponentUpdateOptions): this;
576
+ /**
577
+ * 销毁组件实例
578
+ * 执行 onDestroy 钩子,触发 destroy 事件,清理所有插件和资源
579
+ * 这是组件生命周期的最后一步,销毁后实例不可再使用
580
+ */
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
+ }
586
+ //#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 使用。
599
+ * @param {string} name 图标名称。
600
+ * @param {object} [props={}] SVG 属性。
601
+ * @returns {SVGElement}
602
+ * @throws {Error} 图标不存在或非 DOM 环境时抛出。
603
+ */
604
+ declare function icon(name: IconName, props?: IconProps): SVGElement;
605
+ /**
606
+ * 获取完整 SVG 字符串。
607
+ *
608
+ * 仅在必须拼接字符串或写入 innerHTML 时使用;响应式渲染优先使用 icon(name)。
609
+ * @param {string} name 图标名称。
610
+ * @returns {string}
611
+ */
612
+ declare function iconHtml(name: IconName): string;
613
+ declare const iconMarkup: typeof iconHtml;
614
+ /**
615
+ * 获取当前已注册图标的 path 片段浅拷贝。
616
+ * @returns {Record<string, string>}
617
+ */
618
+ declare function getRegistedIconPath(): IconPathMap;
619
+ /**
620
+ * 批量注册自定义图标。
621
+ *
622
+ * 传入值应为 SVG path 片段,不需要包含外层 svg。
623
+ * @param {Record<string, string>} svgPathObjects 图标名称到 SVG path 的映射。
624
+ * @returns {void}
625
+ */
626
+ declare function addIcons(svgPathObjects: IconPathMap): void;
627
+ //#endregion
628
+ //#region src/locales/index.d.ts
629
+ declare const _default: {
630
+ en: {
631
+ b: string;
632
+ t: string;
633
+ d: string;
634
+ sm: string;
635
+ md: string;
636
+ lg: string;
637
+ };
638
+ zh: {
639
+ b: string;
640
+ t: string;
641
+ d: string;
642
+ Theme: string;
643
+ Radius: string;
644
+ Shadow: string;
645
+ Font: string;
646
+ Mode: string;
647
+ Gray: string;
648
+ Olive: string;
649
+ Tomato: string;
650
+ Ruby: string;
651
+ Pink: string;
652
+ Violet: string;
653
+ Indigo: string;
654
+ Blue: string;
655
+ Teal: string;
656
+ Grass: string;
657
+ Mint: string;
658
+ Lime: string;
659
+ Yellow: string;
660
+ Orange: string;
661
+ Gold: string;
662
+ None: string;
663
+ sm: string;
664
+ md: string;
665
+ lg: string;
666
+ XL: string;
667
+ Round: string;
668
+ Light: string;
669
+ Dark: string;
670
+ Auto: string;
671
+ };
672
+ };
673
+ //#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;
682
+ 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
+ }
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;
701
+ }
702
+ interface ThemePanelGroup {
703
+ title: string;
704
+ type: ThemeConfigKey;
705
+ buttons: Array<[string, string]>;
706
+ }
707
+ interface ResolvedThemeOptions {
708
+ mode: string;
709
+ theme: string;
710
+ radius: string;
711
+ shadow: string;
712
+ font: string;
713
+ key: string;
714
+ className: ThemeClassNames;
715
+ }
716
+ interface ThemeCleanup {
717
+ bindings: Set<() => void>;
718
+ events: IEventManager;
719
+ }
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;
744
+ destroy(): void;
745
+ private defaultPanelConfig;
746
+ }
747
+ //#endregion
748
+ //#region src/components/toast.d.ts
749
+ type ToastType = 'info' | 'success' | 'warning' | 'error' | 'primary';
750
+ interface ToastClassNames {
751
+ container: string;
752
+ toast: string;
753
+ icon: string;
754
+ message: string;
755
+ shown: string;
756
+ hidden: string;
757
+ lite: string;
758
+ action: string;
759
+ actions: string;
760
+ button: string;
761
+ cancelButton: string;
762
+ actionButton: string;
763
+ info: string;
764
+ success: string;
765
+ warning: string;
766
+ error: string;
767
+ primary: string;
768
+ }
769
+ type ToastClassNameConfig = Partial<ToastClassNames>;
770
+ interface ToastOptions {
771
+ className?: ToastClassNameConfig;
772
+ }
773
+ interface ToastActionProps extends ToastOptions {
774
+ text?: {
775
+ cancel?: string;
776
+ action?: string;
777
+ };
778
+ onAction?: () => void | Promise<void>;
779
+ }
780
+ /**
781
+ * Toast 消息提示工具。
782
+ *
783
+ * 以静态方法方式使用,支持多类型堆叠消息和单实例轻提示。
784
+ */
785
+ declare class Toast {
786
+ static timers: Set<string>;
787
+ static disposers: Map<HTMLElement, () => void>;
788
+ private static classNames;
789
+ private static options;
790
+ static configure(options?: ToastOptions): ToastOptions;
791
+ private static resolveClassNames;
792
+ static show(message?: string, duration?: number, type?: ToastType, options?: ToastOptions): HTMLElement;
793
+ static success(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
794
+ static info(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
795
+ static primary(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
796
+ static warning(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
797
+ static error(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
798
+ static hide(toast: HTMLElement | null | undefined): void;
799
+ static lite(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
800
+ static action(message?: string, props?: ToastActionProps): HTMLElement;
801
+ private static getOrCreateContainer;
802
+ private static setTimer;
803
+ static clearAll(): void;
804
+ static destroyAll(): void;
805
+ }
806
+ //#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;
822
+ item: string;
823
+ label: string;
824
+ required: string;
825
+ control: string;
826
+ helpInvalid: string;
827
+ buttons: string;
828
+ 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>;
873
+ }
874
+ interface FormButton {
875
+ type?: string;
876
+ text?: RenderableContent<Form>;
877
+ label?: RenderableContent<Form>;
878
+ theme?: string;
879
+ action?: string;
880
+ disabled?: boolean;
881
+ className?: string;
882
+ }
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;
888
+ }
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;
900
+ }
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;
912
+ }
913
+ interface FormState extends ResolvedFormProps {
914
+ submitting: boolean;
915
+ data: FormDataRecord | null;
916
+ }
917
+ interface FormDOM extends ComponentDOM {
918
+ root: HTMLFormElement | null;
919
+ container: DOMReference | DocumentFragment;
920
+ fields: Map<string, FormControlElement>;
921
+ }
922
+ interface FormCache {
923
+ initial: ResolvedFormProps;
924
+ fieldIds: Map<string | number, string>;
925
+ }
926
+ interface ValidatorInstance {
927
+ root: Element | null;
928
+ options: FormValidatorConfig & {
929
+ onSubmit: null;
930
+ };
931
+ validate: () => boolean;
932
+ reset: () => void;
933
+ destroy: () => void;
934
+ }
935
+ interface FormControlContext {
936
+ form: Form;
937
+ field: FormField;
938
+ index: number;
939
+ }
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;
988
+ }
989
+ declare function createForm(props?: FormProps, container?: DOMReference): Form;
990
+ //#endregion
991
+ //#region src/components/validator.d.ts
992
+ type ValidatorElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
993
+ type ValidatorRuleName = keyof ValidatorRule | string;
994
+ type ValidatorMessageMap = Record<string, Partial<Record<ValidatorRuleName, string>>>;
995
+ type ValidatorCustomResult = boolean | string;
996
+ type ValidatorCustomRule = (element: ValidatorElement, validator: Validator) => ValidatorCustomResult;
997
+ interface ValidatorRule extends Record<string, unknown> {
998
+ required?: boolean;
999
+ minLength?: number;
1000
+ maxLength?: number;
1001
+ equalTo?: string;
1002
+ email?: boolean;
1003
+ checked?: boolean;
1004
+ selected?: boolean;
1005
+ multiple?: boolean;
1006
+ min?: number;
1007
+ max?: number;
1008
+ noSpace?: boolean;
1009
+ noChinese?: boolean;
1010
+ noSpecial?: boolean;
1011
+ pattern?: string | RegExp;
1012
+ file?: boolean;
1013
+ minSize?: number;
1014
+ maxSize?: number;
1015
+ accept?: string;
1016
+ validate?: ValidatorCustomRule;
1017
+ }
1018
+ interface ValidatorOptions extends Record<string, unknown> {
1019
+ rules?: Record<string, ValidatorRule>;
1020
+ messages?: ValidatorMessageMap;
1021
+ onSubmit?: ((validator: Validator) => void) | null;
1022
+ }
1023
+ interface ResolvedValidatorOptions extends Record<string, unknown> {
1024
+ rules: Record<string, ValidatorRule>;
1025
+ messages: ValidatorMessageMap;
1026
+ onSubmit: ((validator: Validator) => void) | null;
1027
+ }
1028
+ interface ValidatorRuntime {
1029
+ valid: boolean;
1030
+ message: string;
1031
+ destroyed: boolean;
1032
+ }
1033
+ interface ValidatorCleanup {
1034
+ events: IEventManager;
1035
+ }
1036
+ interface ResetOptions {
1037
+ native?: boolean;
1038
+ }
1039
+ /**
1040
+ * 表单校验组件。
1041
+ *
1042
+ * 支持绑定表单 submit/reset 事件,也可以手动调用 validate/reset。
1043
+ */
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;
1054
+ /**
1055
+ * 执行表单校验。
1056
+ */
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;
1079
+ /**
1080
+ * 重置表单与校验状态。
1081
+ */
1082
+ reset({ native }?: ResetOptions): void;
1083
+ /**
1084
+ * 销毁当前校验实例。
1085
+ */
1086
+ destroy(): void;
1087
+ }
1088
+ declare function createValidator(element: DOMReference, options?: ValidatorOptions, bindEvents?: boolean): Validator;
1089
+ //#endregion
1090
+ //#region src/components/toc.d.ts
1091
+ interface TocClassNames {
1092
+ toc: string;
1093
+ list: string;
1094
+ link: string;
1095
+ active: string;
1096
+ levelPrefix: string;
1097
+ }
1098
+ type TocClassNameConfig = Partial<TocClassNames>;
1099
+ interface TocItem {
1100
+ id: string;
1101
+ text: string;
1102
+ level: number;
1103
+ element: HTMLHeadingElement;
1104
+ }
1105
+ interface TocCurrent {
1106
+ index: number;
1107
+ item: TocItem | null;
1108
+ }
1109
+ interface TocProps extends Record<string, unknown> {
1110
+ container?: DOMReference;
1111
+ target?: DOMReference;
1112
+ headings?: string;
1113
+ offset?: number;
1114
+ className?: TocClassNameConfig;
1115
+ onUpdate?: ((item: TocItem | null, index: number, toc: Toc) => void) | null;
1116
+ }
1117
+ interface ResolvedTocProps extends Record<string, unknown> {
1118
+ container: DOMReference;
1119
+ target: DOMReference;
1120
+ headings: string;
1121
+ offset: number;
1122
+ className: TocClassNames;
1123
+ onUpdate: ((item: TocItem | null, index: number, toc: Toc) => void) | null;
1124
+ }
1125
+ interface TocState extends Record<string, unknown> {
1126
+ items: TocItem[];
1127
+ current: TocCurrent;
1128
+ }
1129
+ interface TocDOM extends ComponentDOM {
1130
+ root: HTMLElement | null;
1131
+ container: Element | null;
1132
+ target: Element | null;
1133
+ list: HTMLElement | null;
1134
+ headings: HTMLHeadingElement[];
1135
+ links: HTMLAnchorElement[];
1136
+ }
1137
+ interface TocRuntime extends ComponentRuntime {
1138
+ built: boolean;
1139
+ ticking: boolean;
1140
+ }
1141
+ /**
1142
+ * 页面目录组件。
1143
+ *
1144
+ * 扫描内容区域内的标题,生成锚点列表,并随页面滚动更新 active 状态。
1145
+ */
1146
+ declare class Toc extends Component<ResolvedTocProps, TocState, TocDOM> {
1147
+ 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;
1184
+ //#endregion
1185
+ //#region src/components/sticky.d.ts
1186
+ type StickyOverflow = 'destroy' | 'ignore';
1187
+ interface StickyProps extends Record<string, unknown> {
1188
+ target?: DOMReference;
1189
+ parent?: DOMReference;
1190
+ max?: number;
1191
+ top?: number;
1192
+ gap?: number;
1193
+ overflow?: StickyOverflow;
1194
+ onUpdate?: ((sticky: Sticky) => void) | null;
1195
+ }
1196
+ interface ResolvedStickyProps extends Record<string, unknown> {
1197
+ target: DOMReference;
1198
+ parent: DOMReference;
1199
+ max: number;
1200
+ top: number;
1201
+ gap: number;
1202
+ overflow: StickyOverflow;
1203
+ onUpdate: ((sticky: Sticky) => void) | null;
1204
+ }
1205
+ interface StickyStateItem {
1206
+ element: HTMLElement;
1207
+ top: number;
1208
+ }
1209
+ interface StickyState extends Record<string, unknown> {
1210
+ count: number;
1211
+ top: number;
1212
+ items: StickyStateItem[];
1213
+ }
1214
+ interface StickyDOM extends ComponentDOM {
1215
+ root: Element | null;
1216
+ parent: Element | null;
1217
+ targets: HTMLElement[];
1218
+ }
1219
+ interface StickyRuntimeItem {
1220
+ element: HTMLElement;
1221
+ top: number;
1222
+ originalPosition: string;
1223
+ originalTop: string;
1224
+ originalZIndex: string;
1225
+ }
1226
+ interface StickyRuntime extends ComponentRuntime {
1227
+ active: boolean;
1228
+ built: boolean;
1229
+ ignored: boolean;
1230
+ items: StickyRuntimeItem[];
1231
+ }
1232
+ /**
1233
+ * Sticky 吸附组件。
1234
+ *
1235
+ * 用于给一个或多个元素应用 `position: sticky`,并按顺序计算 `top`
1236
+ * 偏移,适合页面侧边栏中多个 widget 的堆叠吸附场景。
1237
+ */
1238
+ declare class Sticky extends Component<ResolvedStickyProps, StickyState, StickyDOM> {
1239
+ runtime: StickyRuntime;
1240
+ /**
1241
+ * 创建 Sticky 实例。
1242
+ * @param {object} [input={}] Sticky 配置。
1243
+ */
1244
+ constructor(input?: StickyProps);
1245
+ /**
1246
+ * 构建 Sticky 行为并应用样式。
1247
+ * @returns {Sticky} 当前实例。
1248
+ */
1249
+ 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
+ */
1264
+ protected onDestroy(): void;
1265
+ }
1266
+ declare function createSticky(props?: StickyProps): Sticky;
1267
+ //#endregion
1268
+ //#region src/components/flow.d.ts
1269
+ type FlowData = Record<string, unknown>;
1270
+ type FlowPayload = FlowData | null;
1271
+ type FlowAction = 'next' | 'back' | 'goTo' | 'finish';
1272
+ type FlowBusyStrategy = 'ignore' | 'throw';
1273
+ type FlowDirection = string;
1274
+ type FlowSlotName = 'renderHeader' | 'renderSteps' | 'renderBody' | 'renderFooter';
1275
+ type FlowCleanup = () => void;
1276
+ type FlowStepResult = string | {
1277
+ id: string;
1278
+ data?: FlowPayload;
1279
+ };
1280
+ interface FlowClassNames {
1281
+ root: string;
1282
+ header: string;
1283
+ title: string;
1284
+ description: string;
1285
+ steps: string;
1286
+ step: string;
1287
+ active: string;
1288
+ complete: string;
1289
+ stepButton: string;
1290
+ stepIndex: string;
1291
+ stepTitle: string;
1292
+ body: string;
1293
+ footer: string;
1294
+ button: string;
1295
+ buttonGhost: string;
1296
+ buttonPrimary: string;
1297
+ reset: string;
1298
+ back: string;
1299
+ next: string;
1300
+ }
1301
+ type FlowClassNameConfig = Partial<FlowClassNames>;
1302
+ interface FlowStep {
1303
+ id: string;
1304
+ title?: string;
1305
+ description?: string;
1306
+ content?: RenderableContent<FlowContext>;
1307
+ data?: FlowData;
1308
+ modal?: FlowData | ((context: FlowContext) => FlowData | null) | null;
1309
+ view?: FlowData;
1310
+ onEnter?: FlowLifecycleHook;
1311
+ onLeave?: FlowLifecycleHook;
1312
+ onNext?: FlowMoveHook;
1313
+ onBack?: FlowMoveHook;
1314
+ canEnter?: FlowGuardHook;
1315
+ canLeave?: FlowGuardHook;
1316
+ [key: string]: unknown;
1317
+ }
1318
+ type PublicFlowStep = Omit<FlowStep, 'onEnter' | 'onLeave' | 'onNext' | 'onBack' | 'canEnter' | 'canLeave'>;
1319
+ interface FlowSnapshot {
1320
+ id: string;
1321
+ currentId: string;
1322
+ currentIndex: number;
1323
+ previousId: string | null;
1324
+ previousIndex: number | null;
1325
+ direction: FlowDirection | null;
1326
+ history: string[];
1327
+ data: FlowData;
1328
+ stepData: Record<string, FlowData>;
1329
+ currentData: FlowData;
1330
+ currentStep: PublicFlowStep | null;
1331
+ canBack: boolean;
1332
+ canNext: boolean;
1333
+ isLast: boolean;
1334
+ loading: boolean;
1335
+ busyAction: FlowAction | null;
1336
+ error: unknown;
1337
+ }
1338
+ interface FlowContext {
1339
+ flow: Flow;
1340
+ step: FlowStep;
1341
+ state: FlowState;
1342
+ signal: AbortSignal | null;
1343
+ snapshot: FlowSnapshot;
1344
+ data: FlowData;
1345
+ currentData: FlowData;
1346
+ payload?: FlowPayload;
1347
+ direction?: FlowDirection;
1348
+ fromId?: string | null;
1349
+ targetId?: string | null;
1350
+ setData: (data: FlowPayload) => Flow;
1351
+ setStepData: (stepId: string, data: FlowPayload) => Flow;
1352
+ getStepData: (stepId: string) => FlowData;
1353
+ next: (payload?: FlowPayload) => Promise<FlowSnapshot | null>;
1354
+ back: (payload?: FlowPayload) => Promise<FlowSnapshot | null>;
1355
+ goTo: (target: FlowTarget, payload?: FlowPayload, options?: FlowGoToOptions) => Promise<FlowSnapshot | null>;
1356
+ addCleanup: (cleanup: FlowCleanup) => FlowCleanup;
1357
+ }
1358
+ interface FlowRenderContext {
1359
+ flow: Flow;
1360
+ snapshot: FlowSnapshot;
1361
+ state: FlowState;
1362
+ steps: (PublicFlowStep | null)[];
1363
+ currentStep: PublicFlowStep | null;
1364
+ currentData: FlowData;
1365
+ data: FlowData;
1366
+ fallback: () => RenderableContent<FlowRenderContext>;
1367
+ next: (payload?: FlowPayload) => Promise<FlowSnapshot | null>;
1368
+ back: (payload?: FlowPayload) => Promise<FlowSnapshot | null>;
1369
+ goTo: (target: FlowTarget, payload?: FlowPayload, options?: FlowGoToOptions) => Promise<FlowSnapshot | null>;
1370
+ reset: () => Flow;
1371
+ }
1372
+ type FlowLifecycleHook = (context: FlowContext) => void | Promise<void>;
1373
+ type FlowGuardHook = (context: FlowContext) => boolean | void | Promise<boolean | void>;
1374
+ type FlowMoveHook = (context: FlowContext) => FlowStepResult | FlowPayload | void | Promise<FlowStepResult | FlowPayload | void>;
1375
+ type FlowFinishHook = (snapshot: FlowSnapshot, flow: Flow) => void | Promise<void>;
1376
+ type FlowChangeHook = (snapshot: FlowSnapshot, flow: Flow, previous: FlowSnapshot | null) => void;
1377
+ type FlowErrorHook = (error: unknown, snapshot: FlowSnapshot, flow: Flow, previous: FlowSnapshot | null) => void;
1378
+ type FlowBusyHook = (action: FlowAction, snapshot: FlowSnapshot, flow: Flow) => void;
1379
+ type FlowSlot = false | null | ((context: FlowRenderContext) => RenderableContent<FlowRenderContext>);
1380
+ type FlowSubscriber = (snapshot: FlowSnapshot, flow: Flow, previous: FlowSnapshot | null) => void;
1381
+ type FlowTarget = string | number;
1382
+ interface FlowText {
1383
+ back: string;
1384
+ next: string;
1385
+ finish: string;
1386
+ reset: string;
1387
+ [key: string]: string;
1388
+ }
1389
+ interface FlowOptions extends Record<string, unknown> {
1390
+ id?: string | null;
1391
+ steps?: FlowStep[];
1392
+ initial?: string | number | null;
1393
+ cache?: boolean;
1394
+ linear?: boolean;
1395
+ render?: boolean;
1396
+ rollbackOnError?: boolean;
1397
+ busyStrategy?: FlowBusyStrategy;
1398
+ showHeader?: boolean;
1399
+ showFooter?: boolean;
1400
+ showSteps?: boolean;
1401
+ showBack?: boolean;
1402
+ showNext?: boolean;
1403
+ showReset?: boolean;
1404
+ text?: Partial<FlowText>;
1405
+ className?: FlowClassNameConfig | string;
1406
+ renderHeader?: FlowSlot;
1407
+ renderSteps?: FlowSlot;
1408
+ renderBody?: FlowSlot;
1409
+ renderFooter?: FlowSlot;
1410
+ onChange?: FlowChangeHook | null;
1411
+ onNext?: FlowMoveHook | null;
1412
+ onBack?: FlowMoveHook | null;
1413
+ onFinish?: FlowFinishHook | null;
1414
+ onError?: FlowErrorHook | null;
1415
+ onBusy?: FlowBusyHook | null;
1416
+ }
1417
+ interface ResolvedFlowOptions extends Record<string, unknown> {
1418
+ id: string;
1419
+ steps: FlowStep[];
1420
+ initial: string | number | null;
1421
+ cache: boolean;
1422
+ linear: boolean;
1423
+ render: boolean;
1424
+ rollbackOnError: boolean;
1425
+ busyStrategy: FlowBusyStrategy;
1426
+ showHeader: boolean;
1427
+ showFooter: boolean;
1428
+ showSteps: boolean;
1429
+ showBack: boolean;
1430
+ showNext: boolean;
1431
+ showReset: boolean;
1432
+ text: FlowText;
1433
+ className: FlowClassNames;
1434
+ renderHeader: FlowSlot;
1435
+ renderSteps: FlowSlot;
1436
+ renderBody: FlowSlot;
1437
+ renderFooter: FlowSlot;
1438
+ onChange: FlowChangeHook | null;
1439
+ onNext: FlowMoveHook | null;
1440
+ onBack: FlowMoveHook | null;
1441
+ onFinish: FlowFinishHook | null;
1442
+ onError: FlowErrorHook | null;
1443
+ onBusy: FlowBusyHook | null;
1444
+ }
1445
+ interface FlowState extends Record<string, unknown> {
1446
+ id: string;
1447
+ currentId: string;
1448
+ currentIndex: number;
1449
+ previousId: string | null;
1450
+ previousIndex: number | null;
1451
+ direction: FlowDirection | null;
1452
+ history: string[];
1453
+ data: FlowData;
1454
+ stepData: Record<string, FlowData>;
1455
+ loading: boolean;
1456
+ error: unknown;
1457
+ busyAction: FlowAction | null;
1458
+ version: number;
1459
+ }
1460
+ interface FlowGoToOptions {
1461
+ direction?: FlowDirection;
1462
+ internal?: boolean;
1463
+ }
1464
+ interface FlowRunActionOptions {
1465
+ internal?: boolean;
1466
+ }
1467
+ /**
1468
+ * Headless 流程控制器,带可选默认 UI。
1469
+ *
1470
+ * 适合在 Modal、Offcanvas、页面表单或任意业务组件中复用 next/back/goTo、步骤缓存和生命周期。
1471
+ */
1472
+ declare class Flow {
1473
+ options: ResolvedFlowOptions;
1474
+ steps: FlowStep[];
1475
+ state: FlowState;
1476
+ root: HTMLElement | null;
1477
+ private stepMap;
1478
+ private initialStepId;
1479
+ private initialData;
1480
+ private subscribers;
1481
+ private renderDispose;
1482
+ private cleanupTasks;
1483
+ private nodes;
1484
+ private destroyed;
1485
+ private activeAction;
1486
+ private actionController;
1487
+ /**
1488
+ * 创建 Flow 实例。
1489
+ * @param {FlowOptions} [options={}] Flow 配置。
1490
+ */
1491
+ constructor(options?: FlowOptions);
1492
+ /**
1493
+ * 当前步骤。
1494
+ * @returns {FlowStep}
1495
+ */
1496
+ get currentStep(): FlowStep;
1497
+ /**
1498
+ * 当前步骤数据。
1499
+ * @returns {object}
1500
+ */
1501
+ get currentData(): FlowData;
1502
+ /**
1503
+ * 是否可以返回上一步。
1504
+ * @returns {boolean}
1505
+ */
1506
+ get canBack(): boolean;
1507
+ /**
1508
+ * 是否可以前进。
1509
+ * @returns {boolean}
1510
+ */
1511
+ get canNext(): boolean;
1512
+ /**
1513
+ * 是否处于最后一步。
1514
+ * @returns {boolean}
1515
+ */
1516
+ get isLast(): boolean;
1517
+ /**
1518
+ * 订阅状态变化。
1519
+ * @param {Function} handler 订阅函数。
1520
+ * @returns {Function} 取消订阅函数。
1521
+ */
1522
+ subscribe(handler: FlowSubscriber): FlowCleanup;
1523
+ /**
1524
+ * 获取不可变快照。
1525
+ * @returns {object}
1526
+ */
1527
+ snapshot(): FlowSnapshot;
1528
+ /**
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。
1536
+ * @returns {Flow}
1537
+ */
1538
+ unmount(): this;
1539
+ /**
1540
+ * 前进一步。
1541
+ * @param {object|null} [payload=null] 当前步骤需要缓存的数据。
1542
+ * @returns {Promise<object>} 切换后的快照。
1543
+ */
1544
+ next(payload?: FlowPayload): Promise<FlowSnapshot | null>;
1545
+ /**
1546
+ * 返回上一步。
1547
+ * @param {object|null} [payload=null] 当前步骤需要缓存的数据。
1548
+ * @returns {Promise<object>} 切换后的快照。
1549
+ */
1550
+ back(payload?: FlowPayload): Promise<FlowSnapshot | null>;
1551
+ /**
1552
+ * 跳转到指定步骤。
1553
+ * @param {string|number} target 目标步骤 id 或索引。
1554
+ * @param {object|null} [payload=null] 当前步骤需要缓存的数据。
1555
+ * @param {{direction?:string, internal?:boolean}} [options={}] 跳转选项。
1556
+ * @returns {Promise<object>} 切换后的快照。
1557
+ */
1558
+ goTo(target: FlowTarget, payload?: FlowPayload, options?: FlowGoToOptions): Promise<FlowSnapshot | null>;
1559
+ /**
1560
+ * 合并全局数据。
1561
+ * @param {object} data 数据补丁。
1562
+ * @returns {Flow}
1563
+ */
1564
+ setData(data: FlowPayload): this;
1565
+ /**
1566
+ * 合并指定步骤缓存数据。
1567
+ * @param {string} stepId 步骤 id。
1568
+ * @param {object|null} data 数据补丁。
1569
+ * @returns {Flow}
1570
+ */
1571
+ setStepData(stepId: string, data: FlowPayload, options?: {
1572
+ silent?: boolean;
1573
+ }): this;
1574
+ /**
1575
+ * 获取指定步骤缓存数据。
1576
+ * @param {string} stepId 步骤 id。
1577
+ * @returns {object}
1578
+ */
1579
+ getStepData(stepId: string): FlowData;
1580
+ /**
1581
+ * 重置流程。
1582
+ * @returns {Flow}
1583
+ */
1584
+ reset(): this;
1585
+ /**
1586
+ * 完成流程。
1587
+ * @param {object|null} [payload=null] 最后一步需要缓存的数据。
1588
+ * @returns {Promise<object>} 当前快照。
1589
+ */
1590
+ finish(payload?: FlowPayload, options?: FlowRunActionOptions): Promise<FlowSnapshot | null>;
1591
+ /**
1592
+ * 销毁 Flow 实例。
1593
+ * @returns {void}
1594
+ */
1595
+ destroy(): void;
1596
+ private resolveInitialStepId;
1597
+ private validateSteps;
1598
+ private resolveStepIndex;
1599
+ private createInitialStepData;
1600
+ private runMoveHook;
1601
+ private transitionTo;
1602
+ private assertCanLeave;
1603
+ private assertCanEnter;
1604
+ private createContext;
1605
+ private runAction;
1606
+ private handleBusy;
1607
+ private abortActiveAction;
1608
+ private callHook;
1609
+ private createAbortError;
1610
+ private setLoading;
1611
+ private handleError;
1612
+ private emitChange;
1613
+ private replaceObject;
1614
+ private captureState;
1615
+ private restoreState;
1616
+ private addCleanup;
1617
+ private assertActive;
1618
+ private publicStep;
1619
+ private buildRoot;
1620
+ private mountView;
1621
+ private view;
1622
+ private renderSlot;
1623
+ private createRenderContext;
1624
+ private headerView;
1625
+ private stepsView;
1626
+ private bodyView;
1627
+ private footerView;
1628
+ private contentView;
1629
+ private stepClass;
1630
+ }
1631
+ /**
1632
+ * 创建 Flow 实例。
1633
+ * @param {FlowOptions} options Flow 配置。
1634
+ * @returns {Flow}
1635
+ */
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;
1709
+ //#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
+ active: string;
1726
+ disabled: string;
1727
+ dragging: string;
1728
+ }
1729
+ type TabsClassNameConfig = Partial<TabsClassNames>;
1730
+ interface TabsPanelContext {
1731
+ tabs: Tabs;
1732
+ item: TabItem;
1733
+ index: number;
1734
+ name: string | number;
1735
+ }
1736
+ interface TabTitleContext {
1737
+ tabs: Tabs;
1738
+ item: TabItem;
1739
+ }
1740
+ type TabPanel = RenderableContent<TabsPanelContext> | ((context: TabsPanelContext) => RenderableContent<TabsPanelContext>) | ((context: TabsPanelContext) => Promise<RenderableContent<TabsPanelContext>>);
1741
+ interface TabItem extends Record<string, unknown> {
1742
+ name?: string;
1743
+ title: RenderableContent<TabTitleContext>;
1744
+ panel: TabPanel;
1745
+ cache?: boolean;
1746
+ ttl?: number;
1747
+ }
1748
+ interface TabsProps extends Record<string, unknown> {
1749
+ id?: string | null;
1750
+ direction?: TabsDirection;
1751
+ active?: TabsValue;
1752
+ disabled?: TabsDisabled;
1753
+ onChange?: ((index: number, name: string | number, tab: HTMLElement | undefined, panel: HTMLElement | undefined) => void | Promise<void>) | null;
1754
+ tabs?: TabItem[];
1755
+ className?: TabsClassNameConfig;
1756
+ onAdd?: ((index: number, item: TabItem, tab: HTMLElement | undefined, panel: HTMLElement | undefined) => void | Promise<void>) | null;
1757
+ onRemove?: ((index: number, name: string | undefined) => void | Promise<void>) | null;
1758
+ }
1759
+ interface ResolvedTabsProps extends Record<string, unknown> {
1760
+ id: string;
1761
+ direction: TabsDirection;
1762
+ active: TabsValue;
1763
+ disabled: TabsDisabled;
1764
+ onChange: NonNullable<TabsProps['onChange']> | null;
1765
+ tabs: TabItem[];
1766
+ className: TabsClassNames;
1767
+ onAdd: NonNullable<TabsProps['onAdd']> | null;
1768
+ onRemove: NonNullable<TabsProps['onRemove']> | null;
1769
+ }
1770
+ interface TabsState extends Record<string, unknown> {
1771
+ current: {
1772
+ index: number;
1773
+ name: string | null;
1774
+ };
1775
+ disabled: {
1776
+ names: string[];
1777
+ indexes: number[];
1778
+ };
1779
+ isVertical: boolean;
1780
+ draggable: boolean;
1781
+ loading: boolean;
1782
+ }
1783
+ interface TabsDOM extends ComponentDOM {
1784
+ root: HTMLElement | null;
1785
+ container: Element;
1786
+ tabs: HTMLElement[];
1787
+ panels: HTMLElement[];
1788
+ }
1789
+ interface TabsPanelCacheEntry {
1790
+ content: RenderableContent<TabsPanelContext>;
1791
+ updatedAt: number;
1792
+ }
1793
+ interface TabsRuntime extends ComponentRuntime {
1794
+ cache: {
1795
+ panels: Map<string, TabsPanelCacheEntry>;
1796
+ };
1797
+ panelLoadId: number;
1798
+ }
1799
+ /**
1800
+ * 标签页组件,继承 Component。
1801
+ *
1802
+ * DOM 创建一次,通过 createEffect 细粒度更新 class/ARIA。
1803
+ */
1804
+ declare class Tabs extends Component<ResolvedTabsProps, TabsState, TabsDOM> {
1805
+ runtime: TabsRuntime;
1806
+ state: TabsState;
1807
+ private bindingsDispose;
1808
+ private isDragging;
1809
+ private raf;
1810
+ private resizeRaf;
1811
+ private velocity;
1812
+ /**
1813
+ * @param {Element|Node|string|Array} container 挂载容器(元素、选择器或 JSX/h 返回节点)。
1814
+ * @param {object} [input={}] 标签页配置。
1815
+ */
1816
+ constructor(container: DOMReference, input?: TabsProps);
1817
+ protected onInit(props: ResolvedTabsProps): void;
1818
+ private buildRoot;
1819
+ private rebuildItems;
1820
+ private parseDisabled;
1821
+ private createDisabledState;
1822
+ private syncCurrent;
1823
+ private getPanelKey;
1824
+ private getCachedPanel;
1825
+ private setCachedPanel;
1826
+ private renderPanelContent;
1827
+ private loadPanel;
1828
+ get activeIndex(): number;
1829
+ get disabledNames(): string[];
1830
+ private bindEvents;
1831
+ private unbindEvents;
1832
+ private assertActive;
1833
+ private getIndex;
1834
+ private activateInternal;
1835
+ /**
1836
+ * 激活指定标签。
1837
+ * @param {number|string} val 标签索引或名称。
1838
+ */
1839
+ activate(val: TabsValue): Promise<void>;
1840
+ /**
1841
+ * 将组件挂载到构造器指定的容器中。
1842
+ */
1843
+ build(): this;
1844
+ render(): this;
1845
+ /**
1846
+ * 动态新增标签。
1847
+ * @param {object} tabConfig 标签配置。
1848
+ */
1849
+ add(tabConfig: TabItem): Promise<void>;
1850
+ /**
1851
+ * 根据索引或名称删除标签。
1852
+ * @param {number|string} val 标签索引或名称。
1853
+ */
1854
+ delete(val: TabsValue): Promise<void>;
1855
+ /**
1856
+ * 根据索引或名称禁用标签。
1857
+ * @param {number|string} val 标签索引或名称。
1858
+ */
1859
+ disable(val: TabsValue): void;
1860
+ /**
1861
+ * 根据索引或名称启用标签。
1862
+ * @param {number|string} val 标签索引或名称。
1863
+ */
1864
+ enable(val: TabsValue): void;
1865
+ private resolveActiveIndex;
1866
+ private syncActiveNames;
1867
+ /**
1868
+ * 使用新配置重新初始化状态。
1869
+ * @param {object} [patch={}] 需要覆盖的配置。
1870
+ */
1871
+ reInit(patch?: TabsProps): Promise<void>;
1872
+ private get dragContainer();
1873
+ private get dragInner();
1874
+ private initDrag;
1875
+ private bindDragEvents;
1876
+ private startInertiaScroll;
1877
+ private removeDragEvents;
1878
+ private refreshDrag;
1879
+ protected onDestroy(): void;
1880
+ }
1881
+ declare function createTabs(container: DOMReference, input?: TabsProps): Tabs;
1882
+ //#endregion
1883
+ //#region src/components/accordion.d.ts
1884
+ type AccordionActive = number | string | Array<number | string> | null;
1885
+ interface AccordionClassNames {
1886
+ root: string;
1887
+ header: string;
1888
+ title: string;
1889
+ arrow: string;
1890
+ panel: string;
1891
+ content: string;
1892
+ active: string;
1893
+ }
1894
+ type AccordionClassNameConfig = Partial<AccordionClassNames>;
1895
+ interface AccordionItem extends Record<string, unknown> {
1896
+ name?: string;
1897
+ title: RenderableContent<AccordionContentContext>;
1898
+ content: RenderableContent<AccordionContentContext>;
1899
+ }
1900
+ interface AccordionProps extends Record<string, unknown> {
1901
+ id?: string | null;
1902
+ active?: AccordionActive;
1903
+ collapsible?: boolean;
1904
+ multiple?: boolean;
1905
+ className?: AccordionClassNameConfig;
1906
+ items?: AccordionItem[];
1907
+ onChange?: ((index: number, name: string, header: HTMLElement, panel: HTMLElement, accordion: Accordion) => void | Promise<void>) | null;
1908
+ }
1909
+ interface ResolvedAccordionProps extends Record<string, unknown> {
1910
+ id: string;
1911
+ active: AccordionActive;
1912
+ collapsible: boolean;
1913
+ multiple: boolean;
1914
+ className: AccordionClassNames;
1915
+ items: AccordionItem[];
1916
+ onChange: NonNullable<AccordionProps['onChange']> | null;
1917
+ }
1918
+ interface AccordionState extends Record<string, unknown> {
1919
+ activeNames: string[];
1920
+ current: {
1921
+ index: number | null;
1922
+ name: string | null;
1923
+ };
1924
+ }
1925
+ interface AccordionDOM extends ComponentDOM {
1926
+ root: HTMLElement | null;
1927
+ container: Element;
1928
+ headers: HTMLElement[];
1929
+ panels: HTMLElement[];
1930
+ }
1931
+ interface AccordionRuntime extends ComponentRuntime {}
1932
+ interface AccordionContentContext {
1933
+ accordion: Accordion;
1934
+ item: AccordionItem;
1935
+ index: number;
1936
+ type: 'title' | 'content';
1937
+ active: boolean;
1938
+ }
1939
+ /**
1940
+ * 轻量手风琴组件,继承 Component。
1941
+ *
1942
+ * DOM 创建一次,通过 createEffect 细粒度更新 class/ARIA。
1943
+ */
1944
+ declare class Accordion extends Component<ResolvedAccordionProps, AccordionState, AccordionDOM> {
1945
+ runtime: AccordionRuntime;
1946
+ state: AccordionState;
1947
+ private bindingsDispose;
1948
+ /**
1949
+ * @param {Element|Node|string|Array} container 挂载容器(元素、选择器或 JSX/h 返回节点)。
1950
+ * @param {object} [input={}] 手风琴配置。
1951
+ */
1952
+ constructor(container: DOMReference, input?: AccordionProps);
1953
+ protected onInit(props: ResolvedAccordionProps): void;
1954
+ private buildRoot;
1955
+ private buildItems;
1956
+ private contentView;
1957
+ private resolveActiveNames;
1958
+ private syncActiveNames;
1959
+ private bindEvents;
1960
+ private unbindEvents;
1961
+ isActive(name: string): boolean;
1962
+ private assertActive;
1963
+ private activateItem;
1964
+ getIndex(val: number | string | undefined | null): number;
1965
+ /**
1966
+ * 激活指定面板。
1967
+ * @param {number|string} val 面板索引或名称。
1968
+ */
1969
+ active(val: number | string | undefined): Promise<void>;
1970
+ /**
1971
+ * 将组件挂载到构造器指定的容器中。
1972
+ */
1973
+ build(): this;
1974
+ render(): this;
1975
+ /**
1976
+ * 动态替换全部面板条目。
1977
+ * @param {AccordionItem[]} items 新面板配置。
1978
+ * @param {number|string|Array<number|string>|null} [active=0] 替换后默认激活项。
1979
+ */
1980
+ setItems(items: AccordionItem[], active?: AccordionActive): this;
1981
+ protected onDestroy(): void;
1982
+ }
1983
+ declare function createAccordion(container: DOMReference, input?: AccordionProps): Accordion;
1984
+ //#endregion
1985
+ //#region src/components/drop.d.ts
1986
+ type DropMode = 'hover' | 'click';
1987
+ type DropPosition = 'auto' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left' | 'right';
1988
+ interface DropClassNames {
1989
+ root: string;
1990
+ container: string;
1991
+ active: string;
1992
+ }
1993
+ type DropClassNameConfig = Partial<DropClassNames>;
1994
+ interface DropDelay {
1995
+ show?: number;
1996
+ hide?: number;
1997
+ }
1998
+ interface DropProps extends Record<string, unknown> {
1999
+ name?: string | null;
2000
+ mode?: DropMode;
2001
+ position?: DropPosition;
2002
+ offset?: number;
2003
+ content?: RenderableContent<Drop>;
2004
+ className?: DropClassNameConfig;
2005
+ id?: string | null;
2006
+ containerClassName?: string | null;
2007
+ delay?: number | DropDelay;
2008
+ hoverIntent?: boolean;
2009
+ onShown?: ((drop: Drop) => void | Promise<void>) | null;
2010
+ onHidden?: ((drop: Drop) => void | Promise<void>) | null;
2011
+ }
2012
+ interface ResolvedDropProps extends Record<string, unknown> {
2013
+ name: string | null;
2014
+ mode: DropMode;
2015
+ position: DropPosition;
2016
+ offset: number;
2017
+ content: RenderableContent<Drop>;
2018
+ className: DropClassNames;
2019
+ id: string;
2020
+ containerClassName: string | null;
2021
+ delay: number | DropDelay;
2022
+ hoverIntent: boolean;
2023
+ onShown: NonNullable<DropProps['onShown']> | null;
2024
+ onHidden: NonNullable<DropProps['onHidden']> | null;
2025
+ }
2026
+ interface DropCleanup {
2027
+ events: IEventManager;
2028
+ }
2029
+ /**
2030
+ * 通用浮层组件。
2031
+ *
2032
+ * 可用于菜单、提示、下拉面板等场景,支持点击或 hover 触发,并自动计算视口内位置。
2033
+ */
2034
+ declare class Drop {
2035
+ target: Element | null;
2036
+ props: ResolvedDropProps | null;
2037
+ root: HTMLElement | null;
2038
+ isVisible: boolean;
2039
+ cleanup: DropCleanup | null;
2040
+ delayShow: number;
2041
+ delayHide: number;
2042
+ private timer;
2043
+ private hoverIntentData;
2044
+ private lastX;
2045
+ private lastY;
2046
+ constructor(element: DOMReference, options?: DropProps);
2047
+ private init;
2048
+ private buildDrop;
2049
+ private bindEvents;
2050
+ private bindRootEvents;
2051
+ private unbindRootEvents;
2052
+ private unbindEvents;
2053
+ private startHoverIntent;
2054
+ private cancelHoverIntent;
2055
+ private onMouseMove;
2056
+ private setPosition;
2057
+ private docClick;
2058
+ private exec;
2059
+ show(useDelay?: boolean): void;
2060
+ hide(useDelay?: boolean): void;
2061
+ toggle(): void;
2062
+ destroy(): void;
2063
+ }
2064
+ declare function createDrop(container: DOMReference, input?: DropProps): Drop;
2065
+ //#endregion
2066
+ //#region src/components/tooltip.d.ts
2067
+ interface TooltipClassNames {
2068
+ root: string;
2069
+ message: string;
2070
+ }
2071
+ type TooltipClassNameConfig = Partial<TooltipClassNames>;
2072
+ interface TooltipProps extends Record<string, unknown> {
2073
+ name?: string | null;
2074
+ mode?: DropMode;
2075
+ position?: DropPosition;
2076
+ offset?: number;
2077
+ message?: string;
2078
+ className?: TooltipClassNameConfig;
2079
+ dropClassName?: DropClassNameConfig;
2080
+ id?: string | null;
2081
+ delay?: number | DropDelay;
2082
+ hoverIntent?: boolean;
2083
+ onShown?: ((drop: Drop) => void | Promise<void>) | null;
2084
+ onHidden?: ((drop: Drop) => void | Promise<void>) | null;
2085
+ }
2086
+ interface ResolvedTooltipProps extends Record<string, unknown> {
2087
+ name: string | null;
2088
+ mode: DropMode;
2089
+ position: DropPosition;
2090
+ offset: number;
2091
+ message: string;
2092
+ className: TooltipClassNames;
2093
+ dropClassName: DropClassNameConfig;
2094
+ id: string | null;
2095
+ delay: number | DropDelay;
2096
+ hoverIntent: boolean;
2097
+ onShown: NonNullable<TooltipProps['onShown']> | null;
2098
+ onHidden: NonNullable<TooltipProps['onHidden']> | null;
2099
+ }
2100
+ /**
2101
+ * Tooltip 提示组件。
2102
+ *
2103
+ * 基于 Drop 实现,提供更轻量的文本提示封装。
2104
+ */
2105
+ declare class Tooltip {
2106
+ drop: Drop | null;
2107
+ props: ResolvedTooltipProps | null;
2108
+ constructor(element: DOMReference, props?: TooltipProps);
2109
+ private buildContent;
2110
+ show(useDelay?: boolean): void;
2111
+ hide(useDelay?: boolean): void;
2112
+ toggle(): void;
2113
+ destroy(): void;
2114
+ }
2115
+ declare function createTooltip(element: DOMReference, props?: TooltipProps): Tooltip;
2116
+ //#endregion
2117
+ //#region src/components/offcanvas.d.ts
2118
+ type OffcanvasDirection = 'top' | 'right' | 'bottom' | 'left';
2119
+ type OffcanvasAnimation = 'slide' | 'none';
2120
+ interface OffcanvasClassNames {
2121
+ root: string;
2122
+ overlay: string;
2123
+ content: string;
2124
+ active: string;
2125
+ top: string;
2126
+ right: string;
2127
+ bottom: string;
2128
+ left: string;
2129
+ slide: string;
2130
+ none: string;
2131
+ }
2132
+ type OffcanvasClassNameConfig = Partial<OffcanvasClassNames>;
2133
+ type OffcanvasContent = RenderableContent<Offcanvas> | ((offcanvas: Offcanvas) => Promise<RenderableContent<Offcanvas>>);
2134
+ interface OffcanvasProps extends Record<string, unknown> {
2135
+ content?: OffcanvasContent;
2136
+ overlay?: boolean;
2137
+ filter?: boolean;
2138
+ cache?: boolean;
2139
+ ttl?: number;
2140
+ direction?: OffcanvasDirection;
2141
+ animation?: OffcanvasAnimation;
2142
+ bgClose?: boolean;
2143
+ escClose?: boolean;
2144
+ id?: string | null;
2145
+ className?: OffcanvasClassNameConfig;
2146
+ onShow?: ((offcanvas: Offcanvas) => void | Promise<void>) | null;
2147
+ onShown?: ((offcanvas: Offcanvas) => void | Promise<void>) | null;
2148
+ onHide?: ((offcanvas: Offcanvas) => void | Promise<void>) | null;
2149
+ onHidden?: ((offcanvas: Offcanvas) => void | Promise<void>) | null;
2150
+ }
2151
+ interface ResolvedOffcanvasProps extends Record<string, unknown> {
2152
+ content: OffcanvasContent;
2153
+ overlay: boolean;
2154
+ filter: boolean;
2155
+ cache: boolean;
2156
+ ttl: number;
2157
+ direction: OffcanvasDirection;
2158
+ animation: OffcanvasAnimation;
2159
+ bgClose: boolean;
2160
+ escClose: boolean;
2161
+ id: string;
2162
+ className: OffcanvasClassNames;
2163
+ onShow: NonNullable<OffcanvasProps['onShow']> | null;
2164
+ onShown: NonNullable<OffcanvasProps['onShown']> | null;
2165
+ onHide: NonNullable<OffcanvasProps['onHide']> | null;
2166
+ onHidden: NonNullable<OffcanvasProps['onHidden']> | null;
2167
+ }
2168
+ interface OffcanvasState extends Record<string, unknown> {
2169
+ visible: boolean;
2170
+ loading: boolean;
2171
+ }
2172
+ interface OffcanvasDOM extends ComponentDOM {
2173
+ root: HTMLElement | null;
2174
+ content: HTMLElement | null;
2175
+ }
2176
+ interface OffcanvasCache {
2177
+ content: RenderableContent<Offcanvas>;
2178
+ hasContent: boolean;
2179
+ updatedAt: number;
2180
+ }
2181
+ interface OffcanvasRuntime extends ComponentRuntime {
2182
+ cache: OffcanvasCache;
2183
+ contentLoadId: number;
2184
+ }
2185
+ /**
2186
+ * 侧滑面板组件,继承 Component。
2187
+ *
2188
+ * 适用于侧边菜单、筛选面板、移动端抽屉等场景。
2189
+ */
2190
+ declare class Offcanvas extends Component<ResolvedOffcanvasProps, OffcanvasState, OffcanvasDOM> {
2191
+ runtime: OffcanvasRuntime;
2192
+ state: OffcanvasState;
2193
+ _overlay: HTMLElement | null;
2194
+ constructor(input?: OffcanvasProps);
2195
+ protected onInit(props: ResolvedOffcanvasProps): void;
2196
+ private buildOverlay;
2197
+ private buildRoot;
2198
+ private isCacheValid;
2199
+ private renderContent;
2200
+ private loadContent;
2201
+ private bindEvents;
2202
+ unbindEvents(): void;
2203
+ private renderPanel;
2204
+ private removePanel;
2205
+ show(): Promise<void>;
2206
+ hide(): Promise<void>;
2207
+ onDestroy(): void;
2208
+ }
2209
+ declare function createOffcanvas(options?: OffcanvasProps): Offcanvas;
2210
+ //#endregion
2211
+ //#region src/components/modal.d.ts
2212
+ type ModalStyle = string | Record<string, string | number | null | undefined> | null;
2213
+ type ModalTextInput = Partial<ModalText> & Record<string, unknown>;
2214
+ type ModalContent = RenderableContent<Modal>;
2215
+ type FlowDirection$1 = 'next' | 'back';
2216
+ interface ModalClassNames {
2217
+ layout: string;
2218
+ modal: string;
2219
+ fullscreen: string;
2220
+ header: string;
2221
+ body: string;
2222
+ footer: string;
2223
+ title: string;
2224
+ close: string;
2225
+ cancel: string;
2226
+ confirm: string;
2227
+ button: string;
2228
+ buttonIcon: string;
2229
+ buttonGhost: string;
2230
+ buttonPrimary: string;
2231
+ buttonSmall: string;
2232
+ formContainer: string;
2233
+ }
2234
+ type ModalClassNameConfig = Partial<ModalClassNames>;
2235
+ interface ModalText {
2236
+ title: string;
2237
+ confirm: string;
2238
+ cancel: string;
2239
+ }
2240
+ interface FlowStep$1 {
2241
+ id?: string;
2242
+ title?: RenderableContent<Modal>;
2243
+ content?: ModalContent;
2244
+ modal?: ModalFlowView | ModalFlowViewFactory;
2245
+ view?: ModalFlowView | ModalFlowViewFactory;
2246
+ [key: string]: unknown;
2247
+ }
2248
+ interface FlowSnapshot$1 {
2249
+ data?: Record<string, unknown> | null;
2250
+ currentData?: Record<string, unknown> | null;
2251
+ currentStep?: FlowStep$1;
2252
+ [key: string]: unknown;
2253
+ }
2254
+ interface FlowLike {
2255
+ currentStep?: FlowStep$1;
2256
+ next: (payload: FormDataRecord | null) => Promise<FlowSnapshot$1> | FlowSnapshot$1;
2257
+ back: (payload: FormDataRecord | null) => Promise<FlowSnapshot$1> | FlowSnapshot$1;
2258
+ snapshot: () => FlowSnapshot$1;
2259
+ reset?: () => void;
2260
+ destroy?: () => void;
2261
+ }
2262
+ interface ModalFlowView extends Partial<ModalProps> {
2263
+ [key: string]: unknown;
2264
+ }
2265
+ type ModalFlowViewFactory = (context: {
2266
+ flow: FlowLike;
2267
+ snapshot: FlowSnapshot$1 | null;
2268
+ step: FlowStep$1 | undefined;
2269
+ modal: Modal;
2270
+ data: Record<string, unknown> | null;
2271
+ currentData: Record<string, unknown> | null;
2272
+ }) => unknown;
2273
+ interface ModalProps extends Record<string, unknown> {
2274
+ content?: ModalContent;
2275
+ position?: string;
2276
+ showCancel?: boolean;
2277
+ showClose?: boolean;
2278
+ fullscreen?: boolean;
2279
+ flow?: FlowLike | null;
2280
+ text?: ModalTextInput;
2281
+ onShow?: ((modal: Modal) => void | Promise<void>) | null;
2282
+ onShown?: ((modal: Modal) => void | Promise<void>) | null;
2283
+ onHide?: ((modal: Modal) => void | Promise<void>) | null;
2284
+ onHidden?: ((modal: Modal) => void | Promise<void>) | null;
2285
+ onConfirm?: ((modal: Modal) => void | Promise<void>) | null;
2286
+ onSubmit?: ((data: FormDataRecord, modal: Modal) => void | Promise<void>) | null;
2287
+ onCancel?: ((modal: Modal) => void | Promise<void>) | null;
2288
+ fields?: readonly FormField[] | null;
2289
+ header?: boolean;
2290
+ footer?: boolean;
2291
+ style?: ModalStyle;
2292
+ id?: string | null;
2293
+ escClose?: boolean;
2294
+ bgClose?: boolean;
2295
+ lazy?: boolean;
2296
+ className?: ModalClassNameConfig;
2297
+ }
2298
+ interface ResolvedModalProps extends Record<string, unknown> {
2299
+ content: ModalContent;
2300
+ position: string;
2301
+ showCancel: boolean;
2302
+ showClose: boolean;
2303
+ fullscreen: boolean;
2304
+ flow: FlowLike | null;
2305
+ text: ModalText;
2306
+ onShow: NonNullable<ModalProps['onShow']> | null;
2307
+ onShown: NonNullable<ModalProps['onShown']> | null;
2308
+ onHide: NonNullable<ModalProps['onHide']> | null;
2309
+ onHidden: NonNullable<ModalProps['onHidden']> | null;
2310
+ onConfirm: NonNullable<ModalProps['onConfirm']> | null;
2311
+ onSubmit: NonNullable<ModalProps['onSubmit']> | null;
2312
+ onCancel: NonNullable<ModalProps['onCancel']> | null;
2313
+ fields: FormField[] | null;
2314
+ header: boolean;
2315
+ footer: boolean;
2316
+ style: ModalStyle;
2317
+ id: string;
2318
+ escClose: boolean;
2319
+ bgClose: boolean;
2320
+ lazy: boolean;
2321
+ className: ModalClassNames;
2322
+ }
2323
+ interface ModalState extends ResolvedModalProps {
2324
+ loading: boolean;
2325
+ submitting: boolean;
2326
+ visible: boolean;
2327
+ data: FormDataRecord | null;
2328
+ extraData: FormDataRecord | null;
2329
+ }
2330
+ interface ModalDOM extends ComponentDOM {
2331
+ root: HTMLElement | null;
2332
+ modal: HTMLElement | null;
2333
+ header: HTMLElement | null;
2334
+ body: HTMLElement | null;
2335
+ footer: HTMLElement | null;
2336
+ form: Form | null;
2337
+ formContainer: HTMLElement | null;
2338
+ }
2339
+ interface ModalRuntime extends ComponentRuntime {
2340
+ scrollLocked: boolean;
2341
+ visibleApplied: boolean;
2342
+ }
2343
+ interface ModalCache {
2344
+ initial: ResolvedModalProps | null;
2345
+ fieldIds: Map<string, string> | null;
2346
+ baseStyle: string;
2347
+ previousActiveElement: HTMLElement | null;
2348
+ formId: string;
2349
+ }
2350
+ interface ModalCleanupExtras {
2351
+ visibility?: (() => void) | null;
2352
+ view?: (() => void) | null;
2353
+ hideTimer?: ReturnType<typeof setTimeout> | null;
2354
+ }
2355
+ type ModalPatch = Partial<ModalProps>;
2356
+ type ModalStatePatch = Partial<ModalState>;
2357
+ declare class Modal extends Component<ResolvedModalProps, ModalState, ModalDOM> {
2358
+ runtime: ModalRuntime;
2359
+ state: ModalState;
2360
+ cleanup: Component['cleanup'] & ModalCleanupExtras;
2361
+ cache: ModalCache;
2362
+ constructor(input?: ModalProps);
2363
+ protected onInit(): void;
2364
+ buildRoot(): HTMLElement;
2365
+ mountView(): void;
2366
+ headerView(): () => (Node | null)[] | null;
2367
+ footerView(): () => (Node | null)[] | null;
2368
+ bodyView(): RenderableContent<Modal>;
2369
+ formView(): HTMLElement;
2370
+ mountForm(container: HTMLElement | null): void;
2371
+ createFormProps(): FormProps;
2372
+ destroyForm(): void;
2373
+ contentView(content: ModalContent): Node[];
2374
+ bindReactiveLoading(): void;
2375
+ bindReactiveStyle(): void;
2376
+ isFormMode(): boolean;
2377
+ isBusy(): boolean;
2378
+ validatePropsPatch(patch: ModalPatch, namespace?: string): void;
2379
+ applyProps(patch: ModalPatch, { validate, force }?: {
2380
+ validate?: boolean;
2381
+ force?: boolean;
2382
+ }): this;
2383
+ applyStyle(element: HTMLElement, style: ModalStyle): void;
2384
+ bindReactiveVisibility(): void;
2385
+ applyVisibility(visible: boolean): void;
2386
+ showFromState(): void;
2387
+ hideFromState(): void;
2388
+ bindEvents(root: Element | null): void;
2389
+ bindOverlayCloseEvent(root: Element | null): void;
2390
+ bindDocumentKeyEvent(): void;
2391
+ bindInsideEvent(): void;
2392
+ clearEvents(): void;
2393
+ requestSubmit(): void;
2394
+ handleFormSubmit(formData: FormDataRecord): Promise<void>;
2395
+ handleNext(): Promise<void>;
2396
+ handleBack(): Promise<void>;
2397
+ hasFlow(): this is this & {
2398
+ state: ModalState & {
2399
+ flow: FlowLike;
2400
+ };
2401
+ };
2402
+ moveFlow(direction: FlowDirection$1): Promise<void>;
2403
+ createFlowPayload(): FormDataRecord | null | false;
2404
+ resolveFlowModalView(flow: FlowLike, snapshot: FlowSnapshot$1 | null, step?: FlowStep$1): ModalFlowView;
2405
+ syncFlowView(flow: FlowLike | null, snapshot?: FlowSnapshot$1 | null): void;
2406
+ handleConfirm(): Promise<void>;
2407
+ handleCancel(): Promise<void>;
2408
+ handleSubmit(data: FormDataRecord): Promise<void>;
2409
+ trapFocus(event: KeyboardEvent): void;
2410
+ focusFirst(): void;
2411
+ lockScroll(): void;
2412
+ unlockScroll(): void;
2413
+ cancelHideTimer(): void;
2414
+ resetAnimationStyles(): void;
2415
+ finishHide(onHidden: ResolvedModalProps['onHidden']): void;
2416
+ restoreFocus(): void;
2417
+ assertActive(method: string): void;
2418
+ validateStatePatch(patch: ModalStatePatch): void;
2419
+ setState(patch?: ModalStatePatch): this;
2420
+ show(): this;
2421
+ hide(): this;
2422
+ setFields(data: readonly FormField[] | null, force?: boolean): this;
2423
+ addFields(data: FormDataRecord): this;
2424
+ setContent(content: ModalContent, force?: boolean): this;
2425
+ update(patch?: Partial<ResolvedModalProps> | null, options?: ComponentUpdateOptions): this;
2426
+ update(patch?: ModalPatch | null, force?: boolean): this;
2427
+ reset(): this;
2428
+ resetContent(): this;
2429
+ resetFields(): this;
2430
+ protected onDestroy(): void;
2431
+ destroy(): this;
2432
+ }
2433
+ declare function createModal(input?: ModalProps): Modal;
2434
+ //#endregion
2435
+ //#region src/components/pagination.d.ts
2436
+ interface PaginationPage {
2437
+ size: number;
2438
+ current: number;
2439
+ }
2440
+ interface PaginationCount {
2441
+ sibling: number;
2442
+ boundary: number;
2443
+ }
2444
+ interface PaginationClassNames {
2445
+ root: string;
2446
+ list: string;
2447
+ item: string;
2448
+ more: string;
2449
+ button: string;
2450
+ buttonIcon: string;
2451
+ buttonGhost: string;
2452
+ active: string;
2453
+ loading: string;
2454
+ }
2455
+ type PaginationClassNameConfig = Partial<PaginationClassNames>;
2456
+ interface PaginationProps extends Record<string, unknown> {
2457
+ total?: number;
2458
+ page?: Partial<PaginationPage>;
2459
+ count?: Partial<PaginationCount>;
2460
+ lock?: boolean;
2461
+ onChange?: ((page: number, instance: Pagination) => void | Promise<unknown>) | null;
2462
+ className?: PaginationClassNameConfig;
2463
+ }
2464
+ interface ResolvedPaginationProps extends Record<string, unknown> {
2465
+ total: number;
2466
+ page: PaginationPage;
2467
+ count: PaginationCount;
2468
+ lock: boolean;
2469
+ onChange: NonNullable<PaginationProps['onChange']> | null;
2470
+ className: PaginationClassNames;
2471
+ }
2472
+ interface PaginationState extends Record<string, unknown> {
2473
+ total: number;
2474
+ page: PaginationPage;
2475
+ count: PaginationCount;
2476
+ pageCount: number;
2477
+ locked: boolean;
2478
+ }
2479
+ interface PageItem {
2480
+ type: 'page';
2481
+ key: string;
2482
+ page: number;
2483
+ }
2484
+ interface MoreItem {
2485
+ type: 'more';
2486
+ key: string;
2487
+ }
2488
+ type PaginationItem = PageItem | MoreItem;
2489
+ type PageAction = 'prev' | 'next';
2490
+ type Dispose = () => void;
2491
+ type EffectDispose = {
2492
+ dispose: () => void;
2493
+ };
2494
+ interface PaginationDOM extends ComponentDOM {
2495
+ root: HTMLElement | null;
2496
+ container: Element | null;
2497
+ list: HTMLElement | null;
2498
+ prev: HTMLElement | null;
2499
+ next: HTMLElement | null;
2500
+ pageNodes: HTMLElement[];
2501
+ items: PaginationItem[];
2502
+ }
2503
+ interface PaginationRuntime extends ComponentRuntime {
2504
+ built: boolean;
2505
+ itemsKey: string;
2506
+ changeId: number;
2507
+ }
2508
+ interface PaginationCleanupExtras {
2509
+ controls?: Dispose | null;
2510
+ itemsEffect?: EffectDispose | null;
2511
+ }
2512
+ /**
2513
+ * 分页组件。
2514
+ *
2515
+ * 构造器只验证和保存配置;调用 build() 后才挂载 DOM 和绑定交互。
2516
+ */
2517
+ declare class Pagination extends Component {
2518
+ props: ResolvedPaginationProps;
2519
+ state: PaginationState;
2520
+ dom: PaginationDOM;
2521
+ runtime: PaginationRuntime;
2522
+ cleanup: Component['cleanup'] & PaginationCleanupExtras;
2523
+ /**
2524
+ * @param {Element|Node|string|Array} container 挂载容器。
2525
+ * @param {object} [input={}] 分页配置。
2526
+ */
2527
+ constructor(container: DOMReference, input?: PaginationProps);
2528
+ /**
2529
+ * 构建分页 DOM 并绑定事件。
2530
+ * @returns {Pagination} 当前实例。
2531
+ */
2532
+ build(): this;
2533
+ /**
2534
+ * 跳转到指定页码。
2535
+ * @param {number} page 新页码。
2536
+ * @returns {Pagination} 当前实例。
2537
+ */
2538
+ go(page: number): this;
2539
+ /**
2540
+ * 更新分页配置。
2541
+ * @param {object} [newProps={}] 新配置,会与当前 props 合并。
2542
+ * @returns {Pagination} 当前实例。
2543
+ */
2544
+ update(newProps?: PaginationProps): this;
2545
+ _getPageCount(total: number, size: number): number;
2546
+ _getPageItems(): PaginationItem[];
2547
+ _getItemsKey(): string;
2548
+ _isLocked(): boolean;
2549
+ _isPrevDisabled(): boolean;
2550
+ _isNextDisabled(): boolean;
2551
+ _buttonClass(...extra: string[]): string;
2552
+ _buildControlItem(type: PageAction): HTMLElement;
2553
+ _buildPageItem(item: PaginationItem): HTMLElement;
2554
+ _bindControlState(): void;
2555
+ _bindPageItems(): void;
2556
+ _renderPageItems(): void;
2557
+ _bindEvents(): void;
2558
+ _assertActive(method: string): void;
2559
+ protected onDestroy(): void;
2560
+ }
2561
+ declare function createPagination(container: DOMReference, props?: PaginationProps): Pagination;
2562
+ //#endregion
2563
+ //#region src/components/swiper.d.ts
2564
+ interface SwiperClassNames {
2565
+ root: string;
2566
+ wrapper: string;
2567
+ slide: string;
2568
+ image: string;
2569
+ title: string;
2570
+ pagination: string;
2571
+ paginationHorizontal: string;
2572
+ paginationClickable: string;
2573
+ paginationBulletGroup: string;
2574
+ indicator: string;
2575
+ bullet: string;
2576
+ navigation: string;
2577
+ prev: string;
2578
+ next: string;
2579
+ active: string;
2580
+ disabled: string;
2581
+ loading: string;
2582
+ loaded: string;
2583
+ error: string;
2584
+ }
2585
+ type SwiperClassNameConfig = Partial<SwiperClassNames>;
2586
+ interface SwiperDataItem extends Record<string, unknown> {
2587
+ image?: string | null;
2588
+ url?: string | null;
2589
+ title?: string | null;
2590
+ sort?: number | null;
2591
+ blank?: boolean | null;
2592
+ children?: RenderableContent<SwiperSlideContext> | null;
2593
+ }
2594
+ interface NormalizedSwiperDataItem extends SwiperDataItem {
2595
+ blank: boolean;
2596
+ index: number;
2597
+ }
2598
+ interface SwiperSlideContext {
2599
+ swiper: Swiper;
2600
+ item: NormalizedSwiperDataItem;
2601
+ index: number;
2602
+ }
2603
+ interface SwiperOptions extends Record<string, unknown> {
2604
+ data?: SwiperDataItem[] | null;
2605
+ loop?: boolean;
2606
+ autoplay?: boolean;
2607
+ delay?: number;
2608
+ lazyload?: boolean;
2609
+ pagination?: boolean;
2610
+ navigation?: boolean;
2611
+ speed?: number;
2612
+ touchRatio?: number;
2613
+ touchAngle?: number;
2614
+ longSwipesMs?: number;
2615
+ longSwipesRatio?: number;
2616
+ preventClick?: boolean;
2617
+ className?: SwiperClassNameConfig;
2618
+ }
2619
+ interface ResolvedSwiperOptions extends Record<string, unknown> {
2620
+ data: SwiperDataItem[] | null;
2621
+ loop: boolean;
2622
+ autoplay: boolean;
2623
+ delay: number;
2624
+ lazyload: boolean;
2625
+ pagination: boolean;
2626
+ navigation: boolean;
2627
+ speed: number;
2628
+ touchRatio: number;
2629
+ touchAngle: number;
2630
+ longSwipesMs: number;
2631
+ longSwipesRatio: number;
2632
+ preventClick: boolean;
2633
+ className: SwiperClassNames;
2634
+ }
2635
+ interface SwiperState extends Record<string, unknown> {
2636
+ index: number;
2637
+ trackIndex: number;
2638
+ transform: number;
2639
+ animating: boolean;
2640
+ width: number;
2641
+ }
2642
+ interface SwiperDOM extends ComponentDOM {
2643
+ root: HTMLElement | null;
2644
+ container: DOMReference;
2645
+ mountTarget: Element | null;
2646
+ createdRoot: boolean;
2647
+ createdSlides: boolean;
2648
+ wrapper: HTMLElement | null;
2649
+ slides: HTMLElement[];
2650
+ pagination: HTMLElement | null;
2651
+ prevButton: HTMLButtonElement | null;
2652
+ nextButton: HTMLButtonElement | null;
2653
+ bullets: HTMLButtonElement[];
2654
+ createdPagination: boolean;
2655
+ createdPrevButton: boolean;
2656
+ createdNextButton: boolean;
2657
+ }
2658
+ interface SwipeLog {
2659
+ x: number;
2660
+ y: number;
2661
+ time: number;
2662
+ }
2663
+ interface SwipePoint {
2664
+ pageX?: number;
2665
+ pageY?: number;
2666
+ clientX?: number;
2667
+ clientY?: number;
2668
+ }
2669
+ interface SwiperRuntime extends ComponentRuntime {
2670
+ logs: SwipeLog[];
2671
+ startTarget: EventTarget | null;
2672
+ touching: boolean;
2673
+ scrolling: boolean;
2674
+ swiping: boolean;
2675
+ clickPrevented: boolean;
2676
+ timer: ReturnType<typeof setInterval> | null;
2677
+ imageCleanups: Set<() => void>;
2678
+ realCount: number;
2679
+ }
2680
+ interface SwiperCleanupExtras {
2681
+ bindings?: (() => void) | null;
2682
+ navBindings?: (() => void) | null;
2683
+ }
2684
+ type SwiperUpdateOptions = Partial<ComponentUpdateOptions>;
2685
+ type SwiperDirection = 'prev' | 'next';
2686
+ /**
2687
+ * 轻量轮播组件,继承 Component。
2688
+ *
2689
+ * 支持链接 slide、图片 lazyload、分页、导航、loop 和桌面/移动端拖拽滑动。
2690
+ * 使用 vanilla-signal 响应式管理 pagination 和 navigation 状态。
2691
+ */
2692
+ declare class Swiper extends Component<ResolvedSwiperOptions, SwiperState, SwiperDOM> {
2693
+ props: ResolvedSwiperOptions;
2694
+ state: SwiperState;
2695
+ dom: SwiperDOM;
2696
+ runtime: SwiperRuntime;
2697
+ cleanup: Component['cleanup'] & SwiperCleanupExtras;
2698
+ private _built;
2699
+ /**
2700
+ * 创建轮播实例。
2701
+ * @param {Element|Node|string|Array} container 挂载容器、选择器或 JSX/h 返回节点。
2702
+ * @param {object} [options={}] Swiper 配置。
2703
+ */
2704
+ constructor(container: DOMReference, options?: SwiperOptions);
2705
+ /**
2706
+ * 构建或绑定 Swiper DOM。
2707
+ * @returns {Swiper} 当前实例。
2708
+ */
2709
+ build(): this;
2710
+ set index(v: unknown);
2711
+ set trackIndex(v: unknown);
2712
+ set transform(v: unknown);
2713
+ set animating(v: unknown);
2714
+ set width(v: unknown);
2715
+ get realCount(): number;
2716
+ get realIndex(): number;
2717
+ assertBuilt(method: string): void;
2718
+ createDataView(root: HTMLElement, data: SwiperDataItem[] | null): HTMLElement;
2719
+ normalizeData(data: SwiperDataItem[] | null): NormalizedSwiperDataItem[];
2720
+ createDataSlide(item: NormalizedSwiperDataItem, index: number): HTMLElement;
2721
+ protected onInit(): void;
2722
+ protected onDestroy(): void;
2723
+ updateSize(): void;
2724
+ refreshSlides(): void;
2725
+ initLoop(): void;
2726
+ setupStyles(): void;
2727
+ reInitView(): void;
2728
+ clearPagination(): void;
2729
+ clearNavigation(): void;
2730
+ bindEvents(): void;
2731
+ onStart(point: SwipePoint, target?: EventTarget | null): void;
2732
+ onMove(point: SwipePoint, event: Event): void;
2733
+ onEnd(): void;
2734
+ resetDrag(animate?: boolean): void;
2735
+ onTransitionEnd(event?: Event): void;
2736
+ pushLog(point: SwipePoint): void;
2737
+ getDuration(): number;
2738
+ getOffset(): {
2739
+ x: number;
2740
+ y: number;
2741
+ };
2742
+ toRealIndex(index?: number): number;
2743
+ trackIndexForRealIndex(index: number): number;
2744
+ setTrackIndex(trackIndex: number, animate?: boolean | null): void;
2745
+ slideTo(index: number): void;
2746
+ slideToTrack(idx: number): void;
2747
+ next(): void;
2748
+ prev(): void;
2749
+ render(animate: boolean): void;
2750
+ loadImages(): void;
2751
+ clearImageCleanups(): void;
2752
+ initPagination(): void;
2753
+ initNavigation(): void;
2754
+ ensureNavigation(direction: SwiperDirection, iconName: 'arrow-left' | 'arrow-right'): HTMLButtonElement;
2755
+ play(): void;
2756
+ pause(): void;
2757
+ resume(): void;
2758
+ restartAutoplay(): void;
2759
+ update(propsPatch?: SwiperOptions | null | undefined, { force }?: SwiperUpdateOptions): this;
2760
+ protected onUpdate(propsPatch?: Partial<ResolvedSwiperOptions> | null | undefined, _options?: Required<ComponentUpdateOptions>): void;
2761
+ updateData(data?: SwiperDataItem[] | null): this;
2762
+ }
2763
+ declare function createSwiper(container: DOMReference, input?: SwiperOptions): Swiper;
2764
+ //#endregion
2765
+ //#region src/components/menu.d.ts
2766
+ type MenuType = string;
2767
+ type MenuItemId = string | number;
2768
+ interface MenuClassNames {
2769
+ root: string;
2770
+ list: string;
2771
+ item: string;
2772
+ hasChildren: string;
2773
+ link: string;
2774
+ subMenu: string;
2775
+ back: string;
2776
+ active: string;
2777
+ icon: string;
2778
+ iconPrefix: string;
2779
+ text: string;
2780
+ }
2781
+ type MenuClassNameConfig = Partial<MenuClassNames>;
2782
+ interface MenuItem extends Record<string, unknown> {
2783
+ id?: MenuItemId;
2784
+ title: string | number;
2785
+ url?: string;
2786
+ target?: string;
2787
+ classes?: string[];
2788
+ children?: MenuItem[];
2789
+ }
2790
+ interface MenuOptions extends Record<string, unknown> {
2791
+ type?: MenuType;
2792
+ id?: string;
2793
+ items?: MenuItem[];
2794
+ backText?: string;
2795
+ className?: MenuClassNameConfig;
2796
+ }
2797
+ interface ResolvedMenuOptions extends Record<string, unknown> {
2798
+ type: MenuType;
2799
+ id: string;
2800
+ items: MenuItem[];
2801
+ backText: string;
2802
+ className: MenuClassNames;
2803
+ }
2804
+ interface MenuDOM {
2805
+ root: HTMLElement | null;
2806
+ }
2807
+ interface MenuCleanup {
2808
+ events: IEventManager;
2809
+ items?: (() => void) | null;
2810
+ }
2811
+ /**
2812
+ * 菜单组件。
2813
+ *
2814
+ * 支持绑定已有菜单 DOM,也支持通过配置动态创建移动菜单或底部菜单。
2815
+ */
2816
+ declare class Menu {
2817
+ options: ResolvedMenuOptions | null;
2818
+ dom: MenuDOM;
2819
+ cleanup: MenuCleanup | null;
2820
+ private _element;
2821
+ private _bound;
2822
+ private _destroyed;
2823
+ /**
2824
+ * 创建菜单实例。
2825
+ * @param {MenuOptions} [options={}] 菜单配置。
2826
+ * @param {Element|Node|string|Array|false} [element=false] 已有菜单节点、选择器或 JSX/h 返回节点;默认 `false` 按 items 动态创建。
2827
+ */
2828
+ constructor(options?: MenuOptions, element?: DOMReference);
2829
+ get root(): HTMLElement | null;
2830
+ /**
2831
+ * 校验菜单数据。
2832
+ * @private
2833
+ * @param {MenuItem[]} items 菜单数据。
2834
+ * @returns {void}
2835
+ */
2836
+ _verifyItems(items: MenuItem[]): void;
2837
+ /**
2838
+ * 构建菜单。
2839
+ *
2840
+ * element 为 false 时动态创建 DOM;否则绑定已有节点。
2841
+ * @returns {Menu}
2842
+ */
2843
+ build(): this;
2844
+ /**
2845
+ * 根据 items 创建菜单根节点。
2846
+ * @private
2847
+ * @returns {HTMLElement}
2848
+ */
2849
+ _buildRoot(): HTMLElement;
2850
+ /**
2851
+ * 递归创建菜单项。
2852
+ * @private
2853
+ * @param {MenuItem} item 菜单项配置。
2854
+ * @returns {HTMLElement}
2855
+ */
2856
+ _buildItem(item: MenuItem): HTMLElement;
2857
+ /**
2858
+ * 根据菜单类型绑定交互事件。
2859
+ * @private
2860
+ * @returns {void}
2861
+ */
2862
+ _bindEvents(): void;
2863
+ /**
2864
+ * 解绑当前菜单实例绑定的事件。
2865
+ * @private
2866
+ * @returns {void}
2867
+ */
2868
+ _unbindEvents(): void;
2869
+ /**
2870
+ * 清理当前构建出的 DOM 与事件,可选择保留实例引用用于重建。
2871
+ * @private
2872
+ * @param {object} [options={}] 清理选项。
2873
+ * @param {boolean} [options.keepElement=false] 是否保留初始 element 引用。
2874
+ * @returns {void}
2875
+ */
2876
+ _teardown({ keepElement }?: {
2877
+ keepElement?: boolean;
2878
+ }): void;
2879
+ /**
2880
+ * 处理移动端有子菜单项的进入操作。
2881
+ * @private
2882
+ * @param {HTMLElement} menuItem 菜单项节点。
2883
+ * @returns {void}
2884
+ */
2885
+ _handleMenuClick(menuItem: HTMLElement): void;
2886
+ /**
2887
+ * 处理移动端子菜单返回操作。
2888
+ * @private
2889
+ * @param {Element} target 点击目标。
2890
+ * @returns {void}
2891
+ */
2892
+ _handleBack(target: Element): void;
2893
+ /**
2894
+ * 切换底部菜单激活状态。
2895
+ * @private
2896
+ * @param {HTMLElement} menuItem 菜单项节点。
2897
+ * @returns {void}
2898
+ */
2899
+ _toggleActive(menuItem: HTMLElement): void;
2900
+ _clearActive(): void;
2901
+ /**
2902
+ * 替换菜单数据;动态创建的菜单会在已构建时重建 DOM。
2903
+ * @param {MenuItem[]} items 新菜单数据。
2904
+ * @returns {Menu}
2905
+ */
2906
+ setItems(items: MenuItem[]): this;
2907
+ /**
2908
+ * 根据 id 移除菜单项。
2909
+ * @param {string|number} id 菜单项 id。
2910
+ * @returns {Menu}
2911
+ */
2912
+ removeItem(id: MenuItemId): this;
2913
+ /**
2914
+ * 销毁当前菜单实例并解绑事件。
2915
+ * @returns {void}
2916
+ */
2917
+ destroy(): void;
2918
+ }
2919
+ declare function createMenu(options?: MenuOptions, element?: DOMReference): Menu;
2920
+ //#endregion
2921
+ 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 };