vanilla-jui 1.4.8 → 1.5.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 (53) hide show
  1. package/README.md +10 -4
  2. package/dist/index.d.ts +402 -977
  3. package/dist/index.js +1 -1
  4. package/dist/index.umd.js +1 -1
  5. package/dist/style.css +1 -1
  6. package/package.json +3 -3
  7. package/src/components/accordion.ts +467 -349
  8. package/src/components/flow.ts +779 -1133
  9. package/src/components/form.ts +666 -509
  10. package/src/components/menu.ts +199 -326
  11. package/src/components/modal.ts +510 -747
  12. package/src/components/offcanvas.ts +281 -361
  13. package/src/components/pagination.ts +207 -374
  14. package/src/components/swiper.ts +688 -1168
  15. package/src/components/tabs.ts +468 -788
  16. package/src/components/toc.ts +191 -244
  17. package/src/core/component.ts +332 -0
  18. package/src/core/motion.ts +298 -0
  19. package/src/core/presence.ts +233 -0
  20. package/src/core/scheduler.ts +91 -0
  21. package/src/core/view.ts +31 -0
  22. package/src/css/accordion.css +94 -3
  23. package/src/css/content.css +18 -24
  24. package/src/css/drop.css +4 -1
  25. package/src/css/form.css +8 -0
  26. package/src/css/menu.css +10 -5
  27. package/src/css/modal.css +2 -1
  28. package/src/css/offcanvas.css +5 -17
  29. package/src/css/swiper.css +2 -1
  30. package/src/css/tabs.css +8 -17
  31. package/src/css/themes/default/accordion.css +0 -48
  32. package/src/css/themes/default/swiper.css +1 -1
  33. package/src/css/themes/default/tabs.css +4 -6
  34. package/src/css/toast.css +1 -17
  35. package/src/css/tooltip.css +2 -1
  36. package/src/index.ts +8 -3
  37. package/src/locales/index.ts +3 -0
  38. package/src/primitives/drop.ts +253 -262
  39. package/src/primitives/loading.ts +22 -4
  40. package/src/primitives/parabola.ts +123 -164
  41. package/src/primitives/sticky.ts +297 -0
  42. package/src/primitives/theme.ts +164 -222
  43. package/src/primitives/toast.ts +309 -284
  44. package/src/primitives/tooltip.ts +65 -66
  45. package/src/utilities/browser.ts +38 -0
  46. package/src/utilities/dom.ts +0 -54
  47. package/src/utilities/refs.ts +61 -0
  48. package/src/utilities/state.ts +73 -0
  49. package/src/utilities/timer.ts +11 -31
  50. package/src/validation/validator.ts +289 -389
  51. package/src/components/sticky.ts +0 -297
  52. package/src/core/Component.ts +0 -377
  53. package/src/utilities/scheduler.ts +0 -156
package/dist/index.d.ts CHANGED
@@ -30,6 +30,9 @@ declare function isMobile(): boolean;
30
30
  * @returns {Promise<boolean>} 是否复制成功。
31
31
  */
32
32
  declare function copy(text: unknown): Promise<boolean>;
33
+ type SupportES2022 = boolean;
34
+ declare function isModernBrowser(): SupportES2022;
35
+ declare function checkModernBrowser(): SupportES2022;
33
36
  //#endregion
34
37
  //#region src/utilities/id.d.ts
35
38
  /**
@@ -80,22 +83,6 @@ declare function isNode(value: unknown): value is Node;
80
83
  * @returns {boolean}
81
84
  */
82
85
  declare function isElement(value: unknown): value is Element;
83
- /**
84
- * 将可渲染内容归一化为 DOM 节点数组。
85
- *
86
- * 支持的输入类型:
87
- * - **Node/Element**: 包装为单元素数组
88
- * - **string**: 按 HTML 片段解析为节点数组
89
- * - **number/boolean**: 转换为文本节点
90
- * - **Array**: 递归扁平化处理
91
- * - **Function**: 调用后递归处理返回值
92
- * - **null/undefined/false/true**: 返回空数组
93
- *
94
- * @param {RenderableContent<TContext>} content 可渲染内容。
95
- * @param {TContext} [context] 传递给函数类型内容的上下文。
96
- * @returns {Node[]} 归一化后的节点数组。
97
- */
98
- declare function normalizeContentNodes<TContext = unknown>(content: RenderableContent<TContext>, context?: TContext): Node[];
99
86
  /**
100
87
  * 将 DOM 引用解析为节点列表。
101
88
  *
@@ -160,7 +147,6 @@ declare function requireContainer<TExpect extends ContainerExpect = 'element'>(c
160
147
  * @returns {boolean}
161
148
  */
162
149
  declare function isRenderableContent(value: unknown): value is RenderableContent;
163
- declare function normalizeRenderableContentNodes<TContext>(content: unknown, context: TContext): Node[] | null;
164
150
  /**
165
151
  * 根据 CSS 选择器获取第一个匹配的元素。
166
152
  * @param {string} selector CSS 选择器。
@@ -241,26 +227,38 @@ declare const restUrl: string;
241
227
  */
242
228
  declare function postJson<T = unknown>(url: string, body: unknown, options?: Omit<RequestInit, 'method' | 'body'>): Promise<T>;
243
229
  //#endregion
230
+ //#region src/core/motion.d.ts
231
+ type TransitionTarget = () => Element | null | undefined;
232
+ interface TransitionDefinition {
233
+ keyframes: Keyframe[] | PropertyIndexedKeyframes;
234
+ options?: KeyframeAnimationOptions;
235
+ respectReducedMotion?: boolean;
236
+ }
237
+ interface MotionController {
238
+ enter: (signal?: AbortSignal) => Promise<void>;
239
+ leave: (signal?: AbortSignal) => Promise<void>;
240
+ cancel: () => void;
241
+ }
242
+ interface CollapseTransitionDefinition {
243
+ axis?: 'vertical' | 'horizontal';
244
+ options?: KeyframeAnimationOptions;
245
+ fade?: boolean;
246
+ respectReducedMotion?: boolean;
247
+ }
248
+ interface CollapseMotionController extends MotionController {
249
+ setExpanded: (expanded: boolean) => void;
250
+ }
251
+ declare function createMotionGroup(...motions: readonly MotionController[]): MotionController;
252
+ declare function createTransition(target: TransitionTarget, definition: TransitionDefinition): MotionController;
253
+ declare function createCollapseTransition(target: () => HTMLElement | null | undefined, definition?: CollapseTransitionDefinition): CollapseMotionController;
254
+ //#endregion
244
255
  //#region src/utilities/object.d.ts
245
256
  declare function isPlainObject(obj: unknown): boolean;
246
257
  //#endregion
247
258
  //#region src/utilities/timer.d.ts
248
- /**
249
- * 定时器管理器
250
- */
251
259
  declare const timer: {
252
- timers: Record<string, ReturnType<typeof setTimeout>>;
253
- /**
254
- * 注册并开始一个定时器
255
- * @param {string} key - 定时器的唯一标识
256
- * @param {number} duration - 延迟执行的时间(毫秒)
257
- * @param {function} callback - 延迟执行的回调函数
258
- */
260
+ timers: Record<string, number>;
259
261
  start(key: string, duration: number, callback: () => void): void;
260
- /**
261
- * 明确注销一个定时器
262
- * @param {string} key - 需要取消的定时器唯一标识
263
- */
264
262
  cancel(key: string): void;
265
263
  };
266
264
  //#endregion
@@ -316,24 +314,80 @@ type ResolvedProps<TSchema extends object> = LooseRecord & { [Key in keyof TSche
316
314
  declare function validateParam<TInput extends LooseRecord = LooseRecord>(name: string, value: unknown, rule?: ParamRuleInput<TInput>, namespace?: string): unknown;
317
315
  declare function resolveProps<TInput extends LooseRecord, TSchema extends ResolveSchema<TInput>>(input?: TInput | null | undefined, schema?: TSchema, namespace?: string): TInput & ResolvedProps<TSchema>;
318
316
  //#endregion
319
- //#region src/utilities/scheduler.d.ts
317
+ //#region src/core/scheduler.d.ts
320
318
  interface ScheduledTask {
321
319
  schedule: () => void;
322
320
  flush: () => void;
323
321
  cancel: () => void;
324
322
  dispose: () => void;
325
323
  }
324
+ declare function createScheduledTask(run: () => void): ScheduledTask;
325
+ //#endregion
326
+ //#region src/utilities/state.d.ts
326
327
  interface StateSyncOptions {
327
328
  deferInitial?: boolean;
328
329
  flushInitial?: boolean;
329
330
  flush?: 'microtask' | 'sync';
330
331
  }
331
- declare function createScheduledTask(run: () => void): ScheduledTask;
332
332
  declare function getStoreVersion(value: unknown): number;
333
333
  declare function trackStoreVersion<T>(value: T): T;
334
334
  declare function stateSnapshot<T>(value: T): T;
335
+ /**
336
+ * Bridges reactive state to an expensive imperative effect. Declarative view
337
+ * bindings should depend on state directly instead of using this helper.
338
+ */
335
339
  declare function createStateSync<TSnapshot>(read: () => TSnapshot, sync: (snapshot: TSnapshot) => void | Promise<void>, { deferInitial, flushInitial, flush }?: StateSyncOptions): () => void;
336
340
  //#endregion
341
+ //#region src/utilities/refs.d.ts
342
+ interface ElementRef<TElement extends Element> {
343
+ readonly current: TElement | null;
344
+ set: (element: TElement) => void;
345
+ clear: () => void;
346
+ }
347
+ declare function createElementRef<TElement extends Element>(): ElementRef<TElement>;
348
+ interface KeyedElementRefs<TKey, TElement extends Element> {
349
+ readonly elements: ReadonlyMap<TKey, TElement>;
350
+ get: (key: TKey) => TElement | undefined;
351
+ bind: (key: TKey) => (element: TElement) => void;
352
+ delete: (key: TKey) => void;
353
+ clear: () => void;
354
+ }
355
+ declare function createKeyedElementRefs<TKey, TElement extends Element>(): KeyedElementRefs<TKey, TElement>;
356
+ //#endregion
357
+ //#region src/core/view.d.ts
358
+ interface OwnedView<TElement extends Element> {
359
+ element: TElement;
360
+ dispose: () => void;
361
+ }
362
+ interface OwnedViewOptions {
363
+ removeOnDispose?: boolean;
364
+ }
365
+ /**
366
+ * Creates one stable view inside a vanilla-signal owner.
367
+ * Reactive accessors declared by the factory retain the owner, while the
368
+ * factory itself is not turned into a replaceable dynamic region.
369
+ */
370
+ declare function createOwnedView<TElement extends Element>(factory: () => TElement, options?: OwnedViewOptions): OwnedView<TElement>;
371
+ //#endregion
372
+ //#region src/core/presence.d.ts
373
+ type PresencePhase = 'hidden' | 'entering' | 'visible' | 'leaving';
374
+ interface PresenceOptions {
375
+ elements: () => readonly (Element | null | undefined)[];
376
+ mount: () => void;
377
+ activate: () => void;
378
+ deactivate: () => void;
379
+ unmount: () => void;
380
+ motion?: MotionController;
381
+ }
382
+ interface PresenceController {
383
+ readonly phase: PresencePhase;
384
+ enter: () => Promise<boolean>;
385
+ leave: () => Promise<boolean>;
386
+ cancel: () => void;
387
+ }
388
+ declare function waitForMotion(elements: readonly Element[], signal?: AbortSignal): Promise<void>;
389
+ declare function createPresence(options: PresenceOptions): PresenceController;
390
+ //#endregion
337
391
  //#region src/primitives/icons.d.ts
338
392
  type IconPathMap = Record<string, string>;
339
393
  type IconName = string;
@@ -376,12 +430,13 @@ declare function getRegistedIconPath(): IconPathMap;
376
430
  declare function addIcons(svgPathObjects: IconPathMap): void;
377
431
  //#endregion
378
432
  //#region src/primitives/loading.d.ts
433
+ type flexPosition = 'center' | 'flex-start' | 'flex-end';
379
434
  /**
380
435
  * 创建通用加载状态节点
381
436
  * 定位 absolute 撑满父元素 居中 背景模糊滤镜
382
437
  * @returns {HTMLElement}
383
438
  */
384
- declare function createLoading(): HTMLDivElement;
439
+ declare function createLoading(xDirection?: flexPosition, yDirection?: flexPosition): HTMLDivElement;
385
440
  //#endregion
386
441
  //#region src/primitives/popup.d.ts
387
442
  interface PopupProps extends Record<string, unknown> {
@@ -405,50 +460,67 @@ interface DropDelay$1 {
405
460
  show?: number;
406
461
  hide?: number;
407
462
  }
463
+ type DropContent = RenderableContent<DropInstance> | ((drop: DropInstance) => RenderableContent<DropInstance> | Promise<RenderableContent<DropInstance>>);
408
464
  interface DropProps extends Record<string, unknown> {
409
465
  name?: string | null;
410
466
  mode?: DropMode$1;
411
467
  position?: DropPosition$1;
412
468
  offset?: number;
413
- content?: RenderableContent<DropInstance$1>;
469
+ content?: DropContent;
470
+ cache?: boolean;
471
+ ttl?: number;
414
472
  className?: DropClassNameConfig;
415
473
  id?: string | null;
416
474
  delay?: number | DropDelay$1;
417
475
  hoverIntent?: boolean;
418
- onShown?: ((drop: DropInstance$1) => void | Promise<void>) | null;
419
- onHidden?: ((drop: DropInstance$1) => void | Promise<void>) | null;
420
- }
421
- interface DropDom {
422
- root: HTMLElement | null;
476
+ onShown?: ((drop: DropInstance) => void | Promise<void>) | null;
477
+ onHidden?: ((drop: DropInstance) => void | Promise<void>) | null;
423
478
  }
424
- interface DropInstance$1 {
425
- target: Element | null;
426
- props: Record<string, unknown> | null;
427
- dom: DropDom;
428
- isVisible: boolean;
429
- delayShow: number;
430
- delayHide: number;
479
+ interface ResolvedDropProps extends Record<string, unknown> {
480
+ name: string | null;
481
+ mode: DropMode$1;
482
+ position: DropPosition$1;
483
+ offset: number;
484
+ content: DropContent;
485
+ cache: boolean;
486
+ ttl: number;
487
+ className: DropClassNames;
488
+ id: string;
489
+ delay: number | DropDelay$1;
490
+ hoverIntent: boolean;
491
+ onShown: NonNullable<DropProps['onShown']> | null;
492
+ onHidden: NonNullable<DropProps['onHidden']> | null;
493
+ }
494
+ interface DropInstance {
495
+ readonly target: Element | null;
496
+ readonly props: ResolvedDropProps;
497
+ readonly element: HTMLElement | null;
498
+ readonly isVisible: boolean;
499
+ readonly delayShow: number;
500
+ readonly delayHide: number;
431
501
  show(useDelay?: boolean): void;
432
502
  hide(useDelay?: boolean): void;
433
503
  toggle(): void;
434
504
  destroy(): void;
435
505
  }
436
- declare function createDrop(element: DOMReference, props?: DropProps): DropInstance$1;
506
+ /**
507
+ * 通用浮层组件。
508
+ *
509
+ * 可用于菜单、提示、下拉面板等场景,支持点击或 hover 触发,并自动计算视口内位置。
510
+ */
511
+ declare function createDrop(reference: DOMReference, input?: DropProps): DropInstance;
437
512
  //#endregion
438
513
  //#region src/primitives/tooltip.d.ts
439
- type DropInstance = ReturnType<typeof createDrop>;
514
+ type DropInstance$1 = ReturnType<typeof createDrop>;
440
515
  type DropMode = 'hover' | 'click';
441
516
  type DropPosition = 'auto' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left' | 'right';
442
517
  interface DropDelay {
443
518
  show?: number;
444
519
  hide?: number;
445
520
  }
446
- interface TooltipDom {
447
- root: HTMLElement | null;
448
- }
449
521
  interface TooltipInstance {
450
- dom: TooltipDom;
451
- drop: DropInstance | null;
522
+ readonly element: HTMLElement | null;
523
+ readonly drop: DropInstance$1 | null;
452
524
  show(useDelay?: boolean): void;
453
525
  hide(useDelay?: boolean): void;
454
526
  toggle(): void;
@@ -477,14 +549,21 @@ interface TooltipProps extends Record<string, unknown> {
477
549
  offset?: number;
478
550
  message?: string;
479
551
  theme?: TooltipTheme;
552
+ cache?: boolean;
553
+ ttl?: number;
480
554
  className?: TooltipClassNameConfig;
481
555
  id?: string | null;
482
556
  delay?: number | DropDelay;
483
557
  hoverIntent?: boolean;
484
- onShown?: ((drop: DropInstance) => void | Promise<void>) | null;
485
- onHidden?: ((drop: DropInstance) => void | Promise<void>) | null;
558
+ onShown?: ((drop: DropInstance$1) => void | Promise<void>) | null;
559
+ onHidden?: ((drop: DropInstance$1) => void | Promise<void>) | null;
486
560
  }
487
- declare function createTooltip(element: DOMReference, props?: TooltipProps): TooltipInstance;
561
+ /**
562
+ * Tooltip 提示组件。
563
+ *
564
+ * 基于 Drop 实现,提供更轻量的文本提示封装。
565
+ */
566
+ declare function createTooltip(element: DOMReference, input?: TooltipProps): TooltipInstance;
488
567
  //#endregion
489
568
  //#region src/primitives/toast.d.ts
490
569
  type ToastType = 'info' | 'success' | 'warning' | 'error' | 'primary';
@@ -510,6 +589,7 @@ interface ToastOptions {
510
589
  className?: ToastClassNameConfig;
511
590
  }
512
591
  interface ToastActionProps extends ToastOptions {
592
+ type?: ToastType;
513
593
  text?: {
514
594
  close?: string;
515
595
  action?: string;
@@ -517,32 +597,27 @@ interface ToastActionProps extends ToastOptions {
517
597
  onAction?: () => void | Promise<void>;
518
598
  onClose?: () => void | Promise<void>;
519
599
  }
520
- /**
521
- * Toast 消息提示工具。
522
- *
523
- * 以静态方法方式使用,支持多类型堆叠消息和单实例轻提示。
524
- */
525
- declare class Toast {
526
- static timers: Set<string>;
527
- static disposers: Map<HTMLElement, () => void>;
528
- private static classNames;
529
- private static options;
530
- static configure(options?: ToastOptions): ToastOptions;
531
- private static resolveClassNames;
532
- static show(message?: string, duration?: number, type?: ToastType, options?: ToastOptions): HTMLElement;
533
- static success(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
534
- static info(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
535
- static primary(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
536
- static warning(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
537
- static error(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
538
- static hide(toast: HTMLElement | null | undefined): void;
539
- static lite(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
540
- static action(message?: string, props?: ToastActionProps): HTMLElement;
541
- private static getOrCreateContainer;
542
- private static setTimer;
543
- static clearAll(): void;
544
- static destroyAll(): void;
545
- }
600
+ declare function hide(toast: HTMLElement | null | undefined): void;
601
+ declare function show(message?: string, duration?: number, type?: ToastType, options?: ToastOptions): HTMLElement;
602
+ declare function lite(message?: string, duration?: number, options?: ToastOptions): HTMLElement;
603
+ declare function action(message?: string, props?: ToastActionProps): HTMLElement;
604
+ declare function clearAll(): void;
605
+ declare const Toast: {
606
+ timers: Set<string>;
607
+ disposers: Map<HTMLElement, () => void>;
608
+ configure(options?: ToastOptions): ToastOptions;
609
+ show: typeof show;
610
+ success: (message?: string, duration?: number, options?: ToastOptions) => HTMLElement;
611
+ info: (message?: string, duration?: number, options?: ToastOptions) => HTMLElement;
612
+ primary: (message?: string, duration?: number, options?: ToastOptions) => HTMLElement;
613
+ warning: (message?: string, duration?: number, options?: ToastOptions) => HTMLElement;
614
+ error: (message?: string, duration?: number, options?: ToastOptions) => HTMLElement;
615
+ hide: typeof hide;
616
+ lite: typeof lite;
617
+ action: typeof action;
618
+ clearAll: typeof clearAll;
619
+ destroyAll: typeof clearAll;
620
+ };
546
621
  //#endregion
547
622
  //#region src/primitives/theme.d.ts
548
623
  type ThemeConfigKey = 'mode' | 'theme' | 'radius' | 'shadow' | 'font';
@@ -621,29 +696,69 @@ interface ResolvedParabolaProps extends Record<string, unknown> {
621
696
  onShow: ((parabola: ParabolaInstance) => void) | null;
622
697
  onHidden: ((parabola: ParabolaInstance) => void) | null;
623
698
  }
624
- interface ParabolaDOM {
625
- root: HTMLElement | null;
626
- from: Element | null;
627
- to: Element | null;
628
- balls: Set<HTMLElement>;
629
- }
630
699
  interface ParabolaRuntime {
631
700
  destroyed: boolean;
632
701
  }
633
702
  interface ParabolaInstance {
634
- props: ResolvedParabolaProps;
635
- dom: ParabolaDOM;
636
- runtime: ParabolaRuntime;
703
+ readonly props: ResolvedParabolaProps;
704
+ readonly element: HTMLElement | null;
705
+ readonly runtime: ParabolaRuntime;
637
706
  show(): Promise<boolean>;
638
707
  destroy(): void;
639
708
  }
640
- declare function createParabola(props?: ParabolaProps): ParabolaInstance;
709
+ declare function createParabola(input?: ParabolaProps): ParabolaInstance;
710
+ //#endregion
711
+ //#region src/primitives/sticky.d.ts
712
+ type StickyOverflow = 'destroy' | 'ignore';
713
+ interface StickyProps extends Record<string, unknown> {
714
+ target?: DOMReference;
715
+ parent?: DOMReference;
716
+ max?: number;
717
+ top?: number;
718
+ gap?: number;
719
+ overflow?: StickyOverflow;
720
+ reactive?: boolean;
721
+ onReBuild?: ((sticky: StickyInstance) => void) | null;
722
+ }
723
+ interface ResolvedStickyProps extends Record<string, unknown> {
724
+ target: DOMReference;
725
+ parent: DOMReference;
726
+ max: number;
727
+ top: number;
728
+ gap: number;
729
+ overflow: StickyOverflow;
730
+ reactive: boolean;
731
+ onReBuild: ((sticky: StickyInstance) => void) | null;
732
+ }
733
+ interface StickyStateItem {
734
+ key: string;
735
+ index: number;
736
+ top: number;
737
+ }
738
+ interface StickyState extends Record<string, unknown> {
739
+ items: StickyStateItem[];
740
+ }
741
+ interface StickyRuntime {
742
+ built: boolean;
743
+ destroyed: boolean;
744
+ reBuilding: boolean;
745
+ reBuildFrameId: number;
746
+ }
747
+ interface StickyInstance {
748
+ readonly props: ResolvedStickyProps;
749
+ readonly state: StickyState;
750
+ readonly runtime: StickyRuntime;
751
+ build(): StickyInstance;
752
+ reBuild(): StickyInstance;
753
+ destroy(): void;
754
+ }
755
+ declare function createSticky(props?: StickyProps): StickyInstance;
641
756
  //#endregion
642
757
  //#region src/validation/validator.d.ts
643
758
  type ValidatorElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
644
759
  type ValidatorMessageMap = Record<string, Partial<Record<string, string>>>;
645
760
  type ValidatorCustomResult = boolean | string;
646
- type ValidatorCustomRule = (element: ValidatorElement, validator: ValidatorInstance$1) => ValidatorCustomResult;
761
+ type ValidatorCustomRule = (element: ValidatorElement, validator: ValidatorInstance) => ValidatorCustomResult;
647
762
  interface ValidatorRule extends Record<string, unknown> {
648
763
  required?: boolean;
649
764
  minLength?: number;
@@ -668,15 +783,12 @@ interface ValidatorRule extends Record<string, unknown> {
668
783
  interface ValidatorProps extends Record<string, unknown> {
669
784
  rules?: Record<string, ValidatorRule>;
670
785
  messages?: ValidatorMessageMap;
671
- onSubmit?: ((validator: ValidatorInstance$1) => void) | null;
786
+ onSubmit?: ((validator: ValidatorInstance) => void) | null;
672
787
  }
673
788
  interface ResolvedValidatorProps extends Record<string, unknown> {
674
789
  rules: Record<string, ValidatorRule>;
675
790
  messages: ValidatorMessageMap;
676
- onSubmit: ((validator: ValidatorInstance$1) => void) | null;
677
- }
678
- interface ValidatorDOM {
679
- root: HTMLFormElement | null;
791
+ onSubmit: ((validator: ValidatorInstance) => void) | null;
680
792
  }
681
793
  interface ValidatorRuntime {
682
794
  valid: boolean;
@@ -686,162 +798,77 @@ interface ValidatorRuntime {
686
798
  interface ResetOptions {
687
799
  native?: boolean;
688
800
  }
689
- interface ValidatorInstance$1 {
690
- dom: ValidatorDOM;
801
+ interface ValidatorInstance {
802
+ readonly element: HTMLFormElement | null;
691
803
  props: ResolvedValidatorProps | null;
692
804
  runtime: ValidatorRuntime;
693
805
  validate(): boolean;
694
806
  reset(options?: ResetOptions): void;
695
807
  destroy(): void;
696
808
  }
697
- declare function createValidator(element: DOMReference, props?: ValidatorProps, bindEvents?: boolean): ValidatorInstance$1;
809
+ declare function createValidator(element: DOMReference, props?: ValidatorProps, bindEvents?: boolean): ValidatorInstance;
698
810
  //#endregion
699
- //#region src/core/Component.d.ts
811
+ //#region src/core/component.d.ts
700
812
  type ComponentProps = Record<string, unknown>;
701
813
  type ComponentState = Record<string, unknown>;
702
- interface ComponentDOM {
703
- root: Element | null;
704
- [key: string]: unknown;
705
- }
706
- interface ComponentRuntime {
707
- destroyed: boolean;
708
- }
709
- type ComponentCache = unknown;
710
- interface ComponentReCreateOptions {
711
- force?: boolean;
712
- }
713
- type ComponentLifecycleEvent = 'init' | 'beforeReCreate' | 'afterReCreate' | 'destroy';
714
- type ComponentEventName = string;
715
- type ComponentListener = (...args: unknown[]) => void;
716
- type ComponentListeners = Record<ComponentLifecycleEvent, ComponentListener[]> & Record<string, ComponentListener[] | undefined>;
717
814
  type ComponentCleanup = void | (() => void) | {
718
815
  destroy: () => void;
719
816
  };
720
817
  type ComponentPluginOptions = Record<string, unknown> | undefined;
721
- type ComponentPlugin<TComponent = Component> = ((instance: TComponent, options?: ComponentPluginOptions) => ComponentCleanup) | {
722
- install: (instance: TComponent, options?: ComponentPluginOptions) => ComponentCleanup;
723
- };
724
- interface ComponentCleanupRegistry {
725
- events: ReturnType<typeof createEventManager>;
726
- plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
727
- [key: string]: unknown;
818
+ interface ComponentRuntime {
819
+ built: boolean;
820
+ mounted: boolean;
821
+ destroyed: boolean;
728
822
  }
729
- /**
730
- * 轻量级组件基类,集成 vanilla-signal 响应式状态和插件系统
731
- * 为所有 UI 组件提供统一的状态管理、生命周期钩子和插件支持
732
- */
733
- declare class Component<TProps extends ComponentProps = ComponentProps, TState extends ComponentState = ComponentState, TDOM extends ComponentDOM = ComponentDOM, TCache = ComponentCache> {
734
- /** 全局插件注册表,所有新创建的组件实例会自动安装这些插件 */
735
- static globalPlugins: Map<string, ComponentPlugin<Component<ComponentProps, ComponentState, ComponentDOM, unknown>>>;
736
- /** 组件属性配置对象 */
737
- props: TProps;
738
- /** DOM 引用容器,存储根元素及其他 DOM 节点引用 */
739
- dom: TDOM;
740
- /** 实例缓存容器,存储组件运行时派生数据 */
741
- cache: TCache;
742
- /** 已安装的插件映射表 */
743
- plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
744
- /** 资源清理管理器,包含事件监听器和插件的清理函数 */
745
- cleanup: ComponentCleanupRegistry;
746
- /** 内部事件监听器注册表,用于生命周期和自定义事件 */
747
- protected _listeners: ComponentListeners;
748
- /** 响应式状态存储,使用 vanilla-signal 的深层响应式 store */
749
- state: TState | null;
750
- /** 运行时状态标记 */
751
- runtime: ComponentRuntime;
752
- /**
753
- * @param {Object} props - 组件初始属性配置
754
- */
755
- constructor(props?: TProps);
756
- /**
757
- * 安装实例插件
758
- * 插件可以是函数形式 plugin(instance, options) 或对象形式 { install(instance, options) }
759
- * 插件应返回清理函数或清理对象,在组件销毁时自动执行
760
- * @param {Function|Object} plugin - 插件函数或包含 install 方法的插件对象
761
- * @param {Object} [options] - 插件配置选项
762
- * @returns {Component} 返回当前实例,支持链式调用
763
- */
764
- use(plugin: ComponentPlugin<this> | null | undefined, options?: ComponentPluginOptions): this;
765
- /**
766
- * 注册事件监听器
767
- * 用于监听组件生命周期事件(init、beforeReCreate、afterReCreate、destroy)或自定义事件
768
- * @param {string} event - 事件名称
769
- * @param {Function} callback - 事件回调函数
770
- * @returns {Component} 返回当前实例,支持链式调用
771
- */
772
- on(event: ComponentEventName, callback: ComponentListener): this;
773
- /**
774
- * 移除事件监听器
775
- * @param {string} event - 事件名称
776
- * @param {Function} callback - 要移除的回调函数引用
777
- * @returns {Component} 返回当前实例,支持链式调用
778
- */
779
- off(event: ComponentEventName, callback: ComponentListener): this;
780
- /**
781
- * 安装全局插件到当前实例
782
- * 遍历全局插件注册表并依次安装
783
- * @private
784
- */
785
- installGlobalPlugins(): void;
786
- /**
787
- * 注册全局插件
788
- * 所有之后创建的组件实例都会自动安装此插件
789
- * @static
790
- * @param {string} name - 插件名称标识
791
- * @param {Function|Object} plugin - 插件函数或插件对象
792
- */
793
- static useGlobal(name: string | null | undefined, plugin: ComponentPlugin<Component> | null | undefined): void;
794
- /**
795
- * 触发指定事件,执行所有注册的监听器
796
- * @param {string} event - 事件名称
797
- * @param {...*} args - 传递给监听器的参数
798
- * @returns {Component} 返回当前实例,支持链式调用
799
- */
800
- emit(event: ComponentEventName, ...args: unknown[]): this;
801
- /**
802
- * 初始化组件
803
- * 合并传入的属性,调用 onInit 钩子(如果存在),并触发 init 事件
804
- * @param {Object} [props={}] - 初始化属性配置
805
- * @returns {Component} 返回当前实例,支持链式调用
806
- * @throws {Error} 如果组件已被销毁则抛出异常
807
- */
808
- init(props?: Partial<TProps> | null | undefined): this;
809
- /**
810
- * 批量更新响应式状态
811
- * 支持两种调用方式:setState(key, value) 或 setState({ key1: value1, key2: value2 })
812
- * 使用 flushSync 确保状态更新的同步性和批量处理
813
- * @param {string|Object} keyOrPatch - 状态键名或包含多个键值对的补丁对象
814
- * @param {*} [value] - 当第一个参数为字符串时的状态值
815
- * @returns {Component} 返回当前实例,支持链式调用
816
- * @throws {Error} 如果组件已被销毁或参数格式不正确则抛出异常
817
- */
823
+ type ComponentLifecycleEvent = 'build' | 'mount' | 'unmount' | 'destroy';
824
+ type ComponentListener = (...args: unknown[]) => void;
825
+ interface ComponentController<TProps extends ComponentProps = ComponentProps, TState extends ComponentState = ComponentState, TElement extends Element = HTMLElement> {
826
+ readonly props: TProps;
827
+ readonly state: TState;
828
+ readonly runtime: ComponentRuntime;
829
+ readonly element: TElement | null;
830
+ build(): this;
831
+ mount(container: Element | DocumentFragment): this;
832
+ unmount(): this;
818
833
  setState(patch?: Partial<TState> | null): this;
819
834
  setState<TKey extends keyof TState>(key: TKey, value: TState[TKey]): this;
820
- /**
821
- * 根据新的 props 重新创建组件实例并触发生命周期
822
- * 合并新的属性配置,触发 beforeReCreate 和 afterReCreate 事件
823
- * 子类可以重写 onReCreate 方法实现自定义重建前逻辑
824
- * @param {Object} [propsPatch={}] - 要合并的属性补丁对象
825
- * @param {Object} [options] - 更新选项
826
- * @param {boolean} [options.force=false] - 是否强制更新(由子类处理)
827
- * @returns {Component} 返回新创建的实例
828
- * @throws {Error} 如果组件已被销毁则抛出异常
829
- */
830
- reCreate(propsPatch?: Partial<TProps> | null | undefined, { force }?: ComponentReCreateOptions): this;
831
- protected createInstance(props: TProps): this;
832
- /**
833
- * 销毁组件实例
834
- * 执行 onDestroy 钩子,触发 destroy 事件,清理所有插件和资源
835
- * 这是组件生命周期的最后一步,销毁后实例不可再使用
836
- */
835
+ own(cleanup: ComponentCleanup): this;
836
+ use(plugin: ComponentPlugin<this> | null | undefined, options?: ComponentPluginOptions): this;
837
+ on(event: string, listener: ComponentListener): this;
838
+ off(event: string, listener: ComponentListener): this;
839
+ emit(event: string, ...args: unknown[]): this;
837
840
  destroy(): void;
838
- protected onInit?(props: TProps): void;
839
- protected onReCreate?(propsPatch: Partial<TProps> | null | undefined, options: Required<ComponentReCreateOptions>): void;
840
- protected normalizeStatePatch(patch: Partial<TState>): Partial<TState>;
841
- protected validateStatePatch(patch: Partial<TState>): void;
842
- protected afterSetState(_patch: Partial<TState>): void;
843
- protected onDestroy?(): void;
844
841
  }
842
+ type ComponentPlugin<TComponent = ComponentController> = ((component: TComponent, options?: ComponentPluginOptions) => ComponentCleanup) | {
843
+ install: (component: TComponent, options?: ComponentPluginOptions) => ComponentCleanup;
844
+ };
845
+ interface ComponentContext<TProps extends ComponentProps, TState extends ComponentState, TElement extends Element> {
846
+ readonly props: TProps;
847
+ readonly state: TState;
848
+ readonly runtime: ComponentRuntime;
849
+ readonly element: TElement | null;
850
+ own: (cleanup: ComponentCleanup) => void;
851
+ assertActive: (operation: string) => void;
852
+ emit: (event: string, ...args: unknown[]) => void;
853
+ }
854
+ interface ComponentDefinition<TProps extends ComponentProps, TState extends ComponentState, TElement extends Element, TActions extends object> {
855
+ name: string;
856
+ ownsElement?: boolean;
857
+ props: TProps;
858
+ state: TState;
859
+ view: (context: ComponentContext<TProps, TState, TElement>) => TElement;
860
+ actions?: TActions;
861
+ normalizeStatePatch?: (patch: Partial<TState>) => Partial<TState>;
862
+ validateStatePatch?: (patch: Partial<TState>, state: TState) => void;
863
+ onBuild?: (context: ComponentContext<TProps, TState, TElement>) => void;
864
+ onMount?: (context: ComponentContext<TProps, TState, TElement>) => void;
865
+ onUnmount?: (context: ComponentContext<TProps, TState, TElement>) => void;
866
+ onDestroy?: (context: ComponentContext<TProps, TState, TElement>) => void;
867
+ }
868
+ type FunctionalComponent<TProps extends ComponentProps, TState extends ComponentState, TElement extends Element, TActions extends object = object> = ComponentController<TProps, TState, TElement> & TActions;
869
+ declare function useComponentPlugin(name: string, plugin: ComponentPlugin | null | undefined): void;
870
+ declare function removeComponentPlugin(name: string): void;
871
+ declare function defineComponent<TProps extends ComponentProps, TState extends ComponentState, TElement extends Element, TActions extends object = object>(definition: ComponentDefinition<TProps, TState, TElement, TActions>): FunctionalComponent<TProps, TState, TElement, TActions>;
845
872
  //#endregion
846
873
  //#region src/components/toc.d.ts
847
874
  interface TocClassNames {
@@ -856,7 +883,6 @@ interface TocItem {
856
883
  id: string;
857
884
  text: string;
858
885
  level: number;
859
- element: HTMLHeadingElement;
860
886
  }
861
887
  interface TocCurrent {
862
888
  index: number;
@@ -866,6 +892,7 @@ interface TocProps extends Record<string, unknown> {
866
892
  target?: DOMReference;
867
893
  headings?: string;
868
894
  offset?: number;
895
+ reactive?: boolean;
869
896
  className?: TocClassNameConfig;
870
897
  onChange?: ((item: TocItem | null, index: number, toc: TocInstance) => void) | null;
871
898
  }
@@ -873,6 +900,7 @@ interface ResolvedTocProps extends Record<string, unknown> {
873
900
  target: DOMReference;
874
901
  headings: string;
875
902
  offset: number;
903
+ reactive: boolean;
876
904
  className: TocClassNames;
877
905
  onChange: ((item: TocItem | null, index: number, toc: TocInstance) => void) | null;
878
906
  }
@@ -880,78 +908,16 @@ interface TocState extends Record<string, unknown> {
880
908
  items: TocItem[];
881
909
  current: TocCurrent;
882
910
  }
883
- interface TocDOM extends ComponentDOM {
884
- root: HTMLElement | null;
885
- target: Element | null;
886
- list: HTMLElement | null;
887
- headings: HTMLHeadingElement[];
888
- links: HTMLAnchorElement[];
889
- }
890
- interface TocRuntime extends ComponentRuntime {
891
- built: boolean;
892
- ticking: boolean;
893
- }
894
- type TocInstance = Component<ResolvedTocProps, TocState, TocDOM> & {
895
- runtime: TocRuntime;
896
- build(): TocInstance;
897
- refresh(): TocInstance;
911
+ interface TocActions {
898
912
  activate(index: number): TocInstance;
899
- };
900
- declare function createToc(props?: TocProps): TocInstance;
901
- //#endregion
902
- //#region src/components/sticky.d.ts
903
- type StickyOverflow = 'destroy' | 'ignore';
904
- interface StickyProps extends Record<string, unknown> {
905
- target?: DOMReference;
906
- parent?: DOMReference;
907
- max?: number;
908
- top?: number;
909
- gap?: number;
910
- overflow?: StickyOverflow;
911
- onRefresh?: ((sticky: StickyInstance) => void) | null;
912
913
  }
913
- interface ResolvedStickyProps extends Record<string, unknown> {
914
- target: DOMReference;
915
- parent: DOMReference;
916
- max: number;
917
- top: number;
918
- gap: number;
919
- overflow: StickyOverflow;
920
- onRefresh: ((sticky: StickyInstance) => void) | null;
921
- }
922
- interface StickyStateItem {
923
- element: HTMLElement;
924
- top: number;
925
- }
926
- interface StickyState extends Record<string, unknown> {
927
- items: StickyStateItem[];
928
- }
929
- interface StickyDOM extends ComponentDOM {
930
- root: Element | null;
931
- parent: Element | null;
932
- targets: HTMLElement[];
933
- }
934
- interface StickyOriginalStyle {
935
- element: HTMLElement;
936
- originalPosition: string;
937
- originalTop: string;
938
- originalZIndex: string;
939
- }
940
- interface StickyRuntime extends ComponentRuntime {
941
- built: boolean;
942
- }
943
- interface StickyCache {
944
- originalStyles: StickyOriginalStyle[];
945
- }
946
- type StickyInstance = Component<ResolvedStickyProps, StickyState, StickyDOM, StickyCache> & {
947
- runtime: StickyRuntime;
948
- build(): StickyInstance;
949
- refresh(): StickyInstance;
950
- };
951
- declare function createSticky(props?: StickyProps): StickyInstance;
914
+ type TocInstance = FunctionalComponent<ResolvedTocProps, TocState, HTMLElement, TocActions>;
915
+ declare function createToc(props?: TocProps): TocInstance;
952
916
  //#endregion
953
917
  //#region src/components/accordion.d.ts
954
918
  type AccordionActive = number | string | Array<number | string> | null;
919
+ type AccordionDirection = 'vertical' | 'horizontal';
920
+ type AccordionContent = RenderableContent<AccordionContentContext> | ((context: AccordionContentContext) => Promise<RenderableContent<AccordionContentContext>>);
955
921
  interface AccordionClassNames {
956
922
  root: string;
957
923
  header: string;
@@ -964,15 +930,18 @@ type AccordionClassNameConfig = Partial<AccordionClassNames>;
964
930
  interface AccordionItem extends Record<string, unknown> {
965
931
  name?: string;
966
932
  title: RenderableContent<AccordionContentContext>;
967
- content: RenderableContent<AccordionContentContext>;
933
+ content: AccordionContent;
934
+ cache?: boolean;
935
+ ttl?: number;
968
936
  }
969
937
  interface AccordionProps extends Record<string, unknown> {
970
938
  id?: string | null;
971
939
  active?: AccordionActive;
972
940
  collapsible?: boolean;
973
941
  multiple?: boolean;
942
+ direction?: AccordionDirection;
974
943
  className?: AccordionClassNameConfig;
975
- items: AccordionItem[];
944
+ data: AccordionItem[];
976
945
  onChange?: ((index: number, name: string, header: HTMLElement, panel: HTMLElement, accordion: AccordionInstance) => void | Promise<void>) | null;
977
946
  }
978
947
  interface ResolvedAccordionProps extends Record<string, unknown> {
@@ -980,8 +949,9 @@ interface ResolvedAccordionProps extends Record<string, unknown> {
980
949
  active: AccordionActive;
981
950
  collapsible: boolean;
982
951
  multiple: boolean;
952
+ direction: AccordionDirection;
983
953
  className: AccordionClassNames;
984
- items: AccordionItem[];
954
+ data: AccordionItem[];
985
955
  onChange: NonNullable<AccordionProps['onChange']> | null;
986
956
  }
987
957
  interface AccordionCurrent {
@@ -989,17 +959,9 @@ interface AccordionCurrent {
989
959
  name: string | null;
990
960
  }
991
961
  interface AccordionState extends Record<string, unknown> {
992
- items: AccordionItem[];
962
+ data: AccordionItem[];
993
963
  activeNames: string[];
994
- current: AccordionCurrent;
995
- }
996
- interface AccordionDOM extends ComponentDOM {
997
- root: HTMLElement | null;
998
- headers: HTMLElement[];
999
- panels: HTMLElement[];
1000
- }
1001
- interface AccordionRuntime extends ComponentRuntime {
1002
- built: boolean;
964
+ loading: boolean;
1003
965
  }
1004
966
  interface AccordionContentContext {
1005
967
  accordion: AccordionInstance;
@@ -1008,24 +970,24 @@ interface AccordionContentContext {
1008
970
  type: 'title' | 'content';
1009
971
  active: boolean;
1010
972
  }
1011
- type AccordionInstance = Component<ResolvedAccordionProps, AccordionState, AccordionDOM> & {
1012
- runtime: AccordionRuntime;
1013
- state: AccordionState;
1014
- build(): AccordionInstance;
973
+ type AccordionInstance = FunctionalComponent<ResolvedAccordionProps, AccordionState, HTMLElement, AccordionActions> & {
974
+ readonly current: AccordionCurrent;
975
+ };
976
+ interface AccordionActions {
1015
977
  isActive(name: string): boolean;
1016
978
  getIndex(value: number | string | undefined | null): number;
1017
979
  activate(value: number | string | undefined): Promise<void>;
1018
- };
980
+ }
1019
981
  declare function createAccordion(props: AccordionProps): AccordionInstance;
1020
982
  //#endregion
1021
983
  //#region src/components/form.d.ts
1022
984
  type FormValue = string | number | boolean;
1023
- type FormOptionInput = FormValue | FormOption;
1024
- type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
985
+ type FieldOption = FormValue | FormOption;
1025
986
  type FormStyle = string | Partial<CSSStyleDeclaration> | null;
1026
987
  type FormDataValue = FormDataEntryValue | FormDataEntryValue[];
1027
988
  type FormDataRecord = Record<string, FormDataValue>;
1028
- type FormControlType = 'checkbox' | 'custom' | 'radio' | 'select' | 'switch' | 'textarea' | (string & {});
989
+ type FormItemType = FormControlType;
990
+ type FormControlType = 'checkbox' | 'custom' | 'email' | 'password' | 'radio' | 'select' | 'switch' | 'text' | 'textarea' | (string & {});
1029
991
  interface FormClassNames {
1030
992
  form: string;
1031
993
  vertical: string;
@@ -1062,12 +1024,19 @@ interface FormOption {
1062
1024
  checked?: boolean;
1063
1025
  disabled?: boolean;
1064
1026
  }
1027
+ type FormItemNext = (current: FormItem, acients: FormItem[]) => FormItem | null;
1028
+ interface FormItem<TPayload = FormField> {
1029
+ id?: string;
1030
+ type: FormItemType;
1031
+ payload: TPayload;
1032
+ next?: FormItemNext | null;
1033
+ }
1065
1034
  interface FormField {
1035
+ [key: string]: unknown;
1066
1036
  id?: string;
1067
1037
  label?: RenderableContent<Form> | false;
1068
1038
  name?: string;
1069
- type?: FormControlType;
1070
- options?: readonly FormOptionInput[];
1039
+ options?: readonly FieldOption[];
1071
1040
  value?: FormDataEntryValue | boolean | readonly FormDataEntryValue[];
1072
1041
  checked?: boolean;
1073
1042
  required?: boolean;
@@ -1104,7 +1073,7 @@ interface FormProps extends Record<string, unknown> {
1104
1073
  vertical?: boolean;
1105
1074
  itemVertical?: boolean;
1106
1075
  style?: FormStyle;
1107
- fields?: readonly FormField[];
1076
+ fields?: readonly FormItem<FormField>[];
1108
1077
  buttons?: boolean | readonly FormButton[];
1109
1078
  className?: FormClassNameConfig;
1110
1079
  validator?: FormValidatorConfig;
@@ -1116,7 +1085,7 @@ interface ResolvedFormProps extends Record<string, unknown> {
1116
1085
  vertical: boolean;
1117
1086
  itemVertical: boolean;
1118
1087
  style: FormStyle;
1119
- fields: FormField[];
1088
+ fields: FormItem<FormField>[];
1120
1089
  buttons: FormButton[];
1121
1090
  className: FormClassNames;
1122
1091
  validator: FormValidatorConfig;
@@ -1127,77 +1096,22 @@ interface FormState extends ResolvedFormProps {
1127
1096
  submitting: boolean;
1128
1097
  data: FormDataRecord | null;
1129
1098
  }
1130
- interface FormDOM extends ComponentDOM {
1131
- root: HTMLFormElement | null;
1132
- fields: Map<string, FormControlElement>;
1133
- }
1134
- interface FormCache {
1135
- initial: ResolvedFormProps;
1136
- fieldIds: Map<string | number, string>;
1137
- }
1138
- interface ValidatorInstance {
1139
- dom: {
1140
- root: Element | null;
1141
- };
1142
- props: (FormValidatorConfig & {
1143
- onSubmit: null;
1144
- }) | null;
1145
- validate: () => boolean;
1146
- reset: () => void;
1147
- destroy: () => void;
1148
- }
1149
1099
  interface FormControlContext {
1150
1100
  form: Form;
1151
1101
  field: FormField;
1152
1102
  index: number;
1103
+ item: FormItem<FormField>;
1153
1104
  }
1154
- declare class Form extends Component<ResolvedFormProps, FormState, FormDOM> {
1155
- state: FormState;
1156
- validator: ValidatorInstance | null;
1157
- cache: FormCache;
1158
- constructor(input?: FormProps);
1159
- get root(): HTMLFormElement | null;
1160
- set root(value: HTMLFormElement | null);
1161
- build(): this;
1162
- view(): HTMLFormElement;
1163
- fieldView(field: FormField, index: number): HTMLElement;
1164
- labelView(field: FormField, id: string): HTMLLabelElement | null;
1165
- controlView(field: FormField, id: string, index: number): FormControlElement | HTMLElement | Node[] | null;
1166
- inputView(field: FormField, id: string): HTMLInputElement;
1167
- textareaView(field: FormField, id: string): HTMLTextAreaElement;
1168
- selectView(field: FormField, id: string): HTMLSelectElement;
1169
- choiceGroupView(field: FormField, id: string, type: 'checkbox' | 'radio'): HTMLElement;
1170
- switchView(field: FormField, id: string): HTMLLabelElement;
1171
- buttonsView(): HTMLElement | null;
1172
- controlProps<TExtra extends Record<string, unknown>>(field: FormField, id: string, extra: TExtra): TExtra & {
1173
- name: string | undefined;
1174
- id: string;
1175
- placeholder: string;
1176
- required: boolean;
1177
- disabled: boolean;
1178
- readonly: boolean;
1179
- 'data-form-field': string;
1180
- ref: (element: FormControlElement) => void;
1181
- };
1182
- resolveFieldId(field: FormField, index: number): string;
1183
- syncValidator(): void;
1105
+ interface FormActions {
1184
1106
  validate(): boolean;
1185
- reset(): this;
1186
- handleSubmit(event: Event): Promise<void>;
1187
- handleReset(event: Event): void;
1188
- resetValidationState(): void;
1107
+ reset(): Form;
1189
1108
  collectData(): FormDataRecord;
1190
- collectFormData(form: HTMLFormElement): FormDataRecord;
1191
- requestSubmit(): this;
1192
- setFields(fields: readonly FormField[]): this;
1193
- resetFields(): this;
1194
- cloneProps(props: ResolvedFormProps): ResolvedFormProps;
1195
- autoComplete(type: string): string;
1196
- isSelected(value: FormField['value'] | undefined, optionValue: FormOption['value']): boolean;
1197
- isChecked(value: FormField['value'] | undefined, optionValue: FormOption['value'], checked: boolean | undefined): boolean;
1198
- protected onDestroy(): void;
1199
- }
1200
- declare function createForm(props?: FormProps): Form;
1109
+ requestSubmit(): Form;
1110
+ setFields(fields: readonly FormItem<FormField>[]): Form;
1111
+ resetFields(): Form;
1112
+ }
1113
+ type Form = FunctionalComponent<ResolvedFormProps, FormState, HTMLFormElement, FormActions>;
1114
+ declare function createForm(input?: FormProps): Form;
1201
1115
  //#endregion
1202
1116
  //#region src/components/flow.d.ts
1203
1117
  type FlowData = Record<string, unknown>;
@@ -1207,6 +1121,7 @@ type FlowBusyStrategy = 'ignore' | 'throw';
1207
1121
  type FlowDirection = string;
1208
1122
  type FlowSlotName = 'renderHeader' | 'renderBody' | 'renderFooter';
1209
1123
  type FlowCleanup = () => void;
1124
+ type FlowTarget = string | number;
1210
1125
  type FlowStepResult = string | {
1211
1126
  id: string;
1212
1127
  data?: FlowPayload;
@@ -1263,6 +1178,25 @@ interface FlowSnapshot {
1263
1178
  busyAction: FlowAction | null;
1264
1179
  error: unknown;
1265
1180
  }
1181
+ interface FlowState extends Record<string, unknown> {
1182
+ id: string;
1183
+ currentId: string;
1184
+ currentIndex: number;
1185
+ previousId: string | null;
1186
+ previousIndex: number | null;
1187
+ direction: FlowDirection | null;
1188
+ history: string[];
1189
+ data: FlowData;
1190
+ stepData: Record<string, FlowData>;
1191
+ loading: boolean;
1192
+ error: unknown;
1193
+ busyAction: FlowAction | null;
1194
+ version: number;
1195
+ }
1196
+ interface FlowGoToOptions {
1197
+ direction?: FlowDirection;
1198
+ internal?: boolean;
1199
+ }
1266
1200
  interface FlowContext {
1267
1201
  flow: Flow;
1268
1202
  step: FlowStep;
@@ -1306,7 +1240,6 @@ type FlowErrorHook = (error: unknown, snapshot: FlowSnapshot, flow: Flow, previo
1306
1240
  type FlowBusyHook = (action: FlowAction, snapshot: FlowSnapshot, flow: Flow) => void;
1307
1241
  type FlowSlot = false | null | ((context: FlowRenderContext) => RenderableContent<FlowRenderContext>);
1308
1242
  type FlowSubscriber = (snapshot: FlowSnapshot, flow: Flow, previous: FlowSnapshot | null) => void;
1309
- type FlowTarget = string | number;
1310
1243
  interface FlowText {
1311
1244
  back: string;
1312
1245
  next: string;
@@ -1362,208 +1295,49 @@ interface ResolvedFlowProps extends Record<string, unknown> {
1362
1295
  onError: FlowErrorHook | null;
1363
1296
  onBusy: FlowBusyHook | null;
1364
1297
  }
1365
- interface FlowState extends Record<string, unknown> {
1366
- id: string;
1367
- currentId: string;
1368
- currentIndex: number;
1369
- previousId: string | null;
1370
- previousIndex: number | null;
1371
- direction: FlowDirection | null;
1372
- history: string[];
1373
- data: FlowData;
1374
- stepData: Record<string, FlowData>;
1375
- loading: boolean;
1376
- error: unknown;
1377
- busyAction: FlowAction | null;
1378
- version: number;
1379
- }
1380
- interface FlowDOM {
1381
- root: HTMLElement | null;
1382
- header: HTMLElement | null;
1383
- body: HTMLElement | null;
1384
- footer: HTMLElement | null;
1385
- }
1386
1298
  interface FlowRuntime {
1387
1299
  built: boolean;
1300
+ mounted: boolean;
1388
1301
  destroyed: boolean;
1389
1302
  activeAction: FlowAction | null;
1390
1303
  actionController: AbortController | null;
1391
1304
  }
1392
- interface FlowGoToOptions {
1393
- direction?: FlowDirection;
1394
- internal?: boolean;
1395
- }
1396
- interface FlowRunActionOptions {
1397
- internal?: boolean;
1398
- }
1399
- /**
1400
- * Headless 流程控制器,带可选默认 UI。
1401
- *
1402
- * 适合在 Modal、Offcanvas、页面表单或任意业务组件中复用 next/back/goTo、步骤缓存和生命周期。
1403
- */
1404
- declare class Flow {
1405
- props: ResolvedFlowProps;
1406
- steps: FlowStep[];
1407
- state: FlowState;
1408
- dom: FlowDOM;
1409
- runtime: FlowRuntime;
1410
- private stepMap;
1411
- private initialStepId;
1412
- private initialData;
1413
- private subscribers;
1414
- private renderDispose;
1415
- private cleanupTasks;
1416
- /**
1417
- * 创建 Flow 实例。
1418
- * @param {FlowProps} [props={}] Flow 配置。
1419
- */
1420
- constructor(props?: FlowProps);
1421
- /**
1422
- * 当前步骤。
1423
- * @returns {FlowStep}
1424
- */
1425
- get currentStep(): FlowStep;
1426
- /**
1427
- * 当前步骤数据。
1428
- * @returns {object}
1429
- */
1430
- get currentData(): FlowData;
1431
- /**
1432
- * 是否可以返回上一步。
1433
- * @returns {boolean}
1434
- */
1435
- get canBack(): boolean;
1436
- /**
1437
- * 是否可以前进。
1438
- * @returns {boolean}
1439
- */
1440
- get canNext(): boolean;
1441
- /**
1442
- * 是否处于最后一步。
1443
- * @returns {boolean}
1444
- */
1445
- get isLast(): boolean;
1446
- /**
1447
- * 订阅状态变化。
1448
- * @param {Function} handler 订阅函数。
1449
- * @returns {Function} 取消订阅函数。
1450
- */
1305
+ interface FlowActions {
1451
1306
  subscribe(handler: FlowSubscriber): FlowCleanup;
1452
- /**
1453
- * 获取不可变快照。
1454
- * @returns {object}
1455
- */
1456
1307
  snapshot(): FlowSnapshot;
1457
- /**
1458
- * 构建默认 Flow UI。
1459
- * @returns {Flow}
1460
- */
1461
- build(): this;
1462
- private teardownView;
1463
- /**
1464
- * 前进一步。
1465
- * @param {object|null} [payload=null] 当前步骤需要缓存的数据。
1466
- * @returns {Promise<object>} 切换后的快照。
1467
- */
1468
1308
  next(payload?: FlowPayload): Promise<FlowSnapshot | null>;
1469
- /**
1470
- * 返回上一步。
1471
- * @param {object|null} [payload=null] 当前步骤需要缓存的数据。
1472
- * @returns {Promise<object>} 切换后的快照。
1473
- */
1474
1309
  back(payload?: FlowPayload): Promise<FlowSnapshot | null>;
1475
- /**
1476
- * 跳转到指定步骤。
1477
- * @param {string|number} target 目标步骤 id 或索引。
1478
- * @param {object|null} [payload=null] 当前步骤需要缓存的数据。
1479
- * @param {{direction?:string, internal?:boolean}} [options={}] 跳转选项。
1480
- * @returns {Promise<object>} 切换后的快照。
1481
- */
1482
1310
  goTo(target: FlowTarget, payload?: FlowPayload, options?: FlowGoToOptions): Promise<FlowSnapshot | null>;
1483
- /**
1484
- * 合并全局数据。
1485
- * @param {object} data 数据补丁。
1486
- * @returns {Flow}
1487
- */
1488
- setData(data: FlowPayload): this;
1489
- /**
1490
- * 合并指定步骤缓存数据。
1491
- * @param {string} stepId 步骤 id。
1492
- * @param {object|null} data 数据补丁。
1493
- * @returns {Flow}
1494
- */
1311
+ setData(data: FlowPayload): Flow;
1495
1312
  setStepData(stepId: string, data: FlowPayload, options?: {
1496
1313
  silent?: boolean;
1497
- }): this;
1498
- /**
1499
- * 获取指定步骤缓存数据。
1500
- * @param {string} stepId 步骤 id。
1501
- * @returns {object}
1502
- */
1314
+ }): Flow;
1503
1315
  getStepData(stepId: string): FlowData;
1504
- /**
1505
- * 重置流程。
1506
- * @returns {Flow}
1507
- */
1508
- reset(): this;
1509
- /**
1510
- * 完成流程。
1511
- * @param {object|null} [payload=null] 最后一步需要缓存的数据。
1512
- * @returns {Promise<object>} 当前快照。
1513
- */
1514
- finish(payload?: FlowPayload, options?: FlowRunActionOptions): Promise<FlowSnapshot | null>;
1515
- /**
1516
- * 销毁 Flow 实例。
1517
- * @returns {void}
1518
- */
1316
+ reset(): Flow;
1317
+ finish(payload?: FlowPayload): Promise<FlowSnapshot | null>;
1318
+ }
1319
+ interface Flow extends FlowActions {
1320
+ readonly props: ResolvedFlowProps;
1321
+ readonly steps: FlowStep[];
1322
+ readonly state: FlowState;
1323
+ readonly runtime: FlowRuntime;
1324
+ readonly element: HTMLElement | null;
1325
+ readonly currentStep: FlowStep;
1326
+ readonly currentData: FlowData;
1327
+ readonly canBack: boolean;
1328
+ readonly canNext: boolean;
1329
+ readonly isLast: boolean;
1330
+ build(): this;
1331
+ mount(container: Element | DocumentFragment): this;
1332
+ unmount(): this;
1519
1333
  destroy(): void;
1520
- private resolveInitialStepId;
1521
- private validateSteps;
1522
- private resolveStepIndex;
1523
- private createInitialStepData;
1524
- private runMoveHook;
1525
- private transitionTo;
1526
- private assertCanLeave;
1527
- private assertCanEnter;
1528
- private createContext;
1529
- private runAction;
1530
- private handleBusy;
1531
- private abortActiveAction;
1532
- private callHook;
1533
- private createAbortError;
1534
- private setLoading;
1535
- private handleError;
1536
- private emitChange;
1537
- private replaceObject;
1538
- private captureState;
1539
- private restoreState;
1540
- private addCleanup;
1541
- private assertActive;
1542
- private publicStep;
1543
- private buildRoot;
1544
- private mountView;
1545
- private view;
1546
- private renderSlot;
1547
- private createRenderContext;
1548
- private headerView;
1549
- private stepsView;
1550
- private bodyView;
1551
- private footerView;
1552
- private contentView;
1553
- private stepClass;
1554
1334
  }
1555
- /**
1556
- * 创建 Flow 实例。
1557
- * @param {FlowProps} props Flow 配置。
1558
- * @returns {Flow}
1559
- */
1560
- declare function createFlow(props?: FlowProps): Flow;
1335
+ declare function createFlow(input?: FlowProps): Flow;
1561
1336
  //#endregion
1562
1337
  //#region src/components/modal.d.ts
1563
1338
  type ModalTextInput = Partial<ModalText> & Record<string, unknown>;
1564
- type ModalContent = RenderableContent<Modal>;
1565
- type FormInstance = ReturnType<typeof createForm>;
1566
- type ModalMode = 'content' | 'form';
1339
+ type ModalContentResult = RenderableContent<Modal>;
1340
+ type ModalContent = ModalContentResult | ((modal: Modal) => ModalContentResult | Promise<ModalContentResult>);
1567
1341
  interface ModalClassNames {
1568
1342
  layout: string;
1569
1343
  modal: string;
@@ -1583,8 +1357,9 @@ interface ModalText {
1583
1357
  cancel: string;
1584
1358
  }
1585
1359
  interface ModalProps extends Record<string, unknown> {
1586
- mode?: ModalMode | null;
1587
1360
  content?: ModalContent;
1361
+ cache?: boolean;
1362
+ ttl?: number;
1588
1363
  position?: string;
1589
1364
  showCancel?: boolean;
1590
1365
  showClose?: boolean;
@@ -1595,9 +1370,7 @@ interface ModalProps extends Record<string, unknown> {
1595
1370
  onHide?: ((modal: Modal) => void | Promise<void>) | null;
1596
1371
  onHidden?: ((modal: Modal) => void | Promise<void>) | null;
1597
1372
  onConfirm?: ((modal: Modal) => void | Promise<void>) | null;
1598
- onSubmit?: ((data: FormDataRecord, modal: Modal) => void | Promise<void>) | null;
1599
1373
  onCancel?: ((modal: Modal) => void | Promise<void>) | null;
1600
- fields?: readonly FormField[] | null;
1601
1374
  header?: boolean;
1602
1375
  footer?: boolean;
1603
1376
  id?: string | null;
@@ -1606,8 +1379,9 @@ interface ModalProps extends Record<string, unknown> {
1606
1379
  className?: ModalClassNameConfig;
1607
1380
  }
1608
1381
  interface ResolvedModalProps extends Record<string, unknown> {
1609
- mode: ModalMode;
1610
1382
  content: ModalContent;
1383
+ cache: boolean;
1384
+ ttl: number;
1611
1385
  position: string;
1612
1386
  showCancel: boolean;
1613
1387
  showClose: boolean;
@@ -1618,9 +1392,7 @@ interface ResolvedModalProps extends Record<string, unknown> {
1618
1392
  onHide: NonNullable<ModalProps['onHide']> | null;
1619
1393
  onHidden: NonNullable<ModalProps['onHidden']> | null;
1620
1394
  onConfirm: NonNullable<ModalProps['onConfirm']> | null;
1621
- onSubmit: NonNullable<ModalProps['onSubmit']> | null;
1622
1395
  onCancel: NonNullable<ModalProps['onCancel']> | null;
1623
- fields: FormField[] | null;
1624
1396
  header: boolean;
1625
1397
  footer: boolean;
1626
1398
  id: string;
@@ -1629,91 +1401,17 @@ interface ResolvedModalProps extends Record<string, unknown> {
1629
1401
  className: ModalClassNames;
1630
1402
  }
1631
1403
  interface ModalState extends Record<string, unknown> {
1632
- mode: ModalMode;
1633
1404
  content: ModalContent;
1634
- fields: FormField[] | null;
1635
1405
  loading: boolean;
1636
1406
  processing: boolean;
1637
1407
  visible: boolean;
1638
- data: FormDataRecord | null;
1639
- extraData: FormDataRecord | null;
1640
- }
1641
- interface ModalDOM extends ComponentDOM {
1642
- root: HTMLElement | null;
1643
- modal: HTMLElement | null;
1644
- header: HTMLElement | null;
1645
- body: HTMLElement | null;
1646
- footer: HTMLElement | null;
1647
- form: FormInstance | null;
1648
- formContainer: HTMLElement | null;
1649
- }
1650
- interface ModalRuntime extends ComponentRuntime {
1651
- scrollLocked: boolean;
1652
- visibleApplied: boolean;
1653
- }
1654
- interface ModalCache {
1655
- initial: ResolvedModalProps | null;
1656
- fieldIds: Map<string, string> | null;
1657
- previousActiveElement: HTMLElement | null;
1658
- formId: string;
1659
- }
1660
- interface ModalCleanupExtras {
1661
- visibility?: (() => void) | null;
1662
- view?: (() => void) | null;
1663
- hideTimer?: ReturnType<typeof setTimeout> | null;
1664
- }
1665
- type ModalStatePatch = Partial<ModalState>;
1666
- declare class ModalComponent extends Component<ResolvedModalProps, ModalState, ModalDOM, ModalCache> {
1667
- runtime: ModalRuntime;
1668
- state: ModalState;
1669
- cleanup: Component['cleanup'] & ModalCleanupExtras;
1670
- constructor(input?: ModalProps);
1671
- protected onInit(): void;
1672
- build(): this;
1673
- mountView(): void;
1674
- headerView(): () => (Node | null)[] | null;
1675
- footerView(): () => (Node | null)[] | null;
1676
- bodyView(): RenderableContent<Modal>;
1677
- formView(): HTMLElement;
1678
- mountForm(container: HTMLElement | null): void;
1679
- createFormProps(): FormProps;
1680
- destroyForm(): void;
1681
- contentView(content: ModalContent): Node[];
1682
- bindReactiveLoading(): void;
1683
- isBusy(): boolean;
1684
- bindReactiveVisibility(): void;
1685
- applyVisibility(visible: boolean): void;
1686
- showFromState(): void;
1687
- hideFromState(): void;
1688
- bindEvents(root: Element | null): void;
1689
- bindOverlayCloseEvent(root: Element | null): void;
1690
- bindDocumentKeyEvent(): void;
1691
- bindInsideEvent(): void;
1692
- clearEvents(): void;
1693
- requestSubmit(): void;
1694
- handleFormSubmit(formData: FormDataRecord): Promise<void>;
1695
- handleConfirm(): Promise<void>;
1696
- handleCancel(): Promise<void>;
1697
- handleSubmit(data: FormDataRecord): Promise<void>;
1698
- trapFocus(event: KeyboardEvent): void;
1699
- focusFirst(): void;
1700
- lockScroll(): void;
1701
- unlockScroll(): void;
1702
- cancelHideTimer(): void;
1703
- resetAnimationStyles(): void;
1704
- finishHide(onHidden: ResolvedModalProps['onHidden']): void;
1705
- restoreFocus(): void;
1706
- assertActive(method: string): void;
1707
- protected normalizeStatePatch(patch: ModalStatePatch): ModalStatePatch;
1708
- protected validateStatePatch(patch: ModalStatePatch): void;
1709
- protected afterSetState(patch: ModalStatePatch): void;
1710
- show(): this;
1711
- hide(): this;
1712
- reset(): this;
1713
- protected onDestroy(): void;
1714
- destroy(): this;
1715
- }
1716
- type Modal = ModalComponent;
1408
+ }
1409
+ interface ModalActions {
1410
+ show(): Modal;
1411
+ hide(): Modal;
1412
+ reset(): Modal;
1413
+ }
1414
+ type Modal = FunctionalComponent<ResolvedModalProps, ModalState, HTMLElement, ModalActions>;
1717
1415
  declare function createModal(input?: ModalProps): Modal;
1718
1416
  //#endregion
1719
1417
  //#region src/components/swiper.d.ts
@@ -1734,9 +1432,6 @@ interface SwiperClassNames {
1734
1432
  next: string;
1735
1433
  active: string;
1736
1434
  disabled: string;
1737
- loading: string;
1738
- loaded: string;
1739
- error: string;
1740
1435
  }
1741
1436
  type SwiperClassNameConfig = Partial<SwiperClassNames>;
1742
1437
  interface SwiperDataItem extends Record<string, unknown> {
@@ -1750,15 +1445,18 @@ interface SwiperDataItem extends Record<string, unknown> {
1750
1445
  interface NormalizedSwiperDataItem extends SwiperDataItem {
1751
1446
  blank: boolean;
1752
1447
  index: number;
1448
+ key: string;
1753
1449
  }
1754
1450
  interface SwiperSlideContext {
1755
1451
  swiper: Swiper;
1756
1452
  item: NormalizedSwiperDataItem;
1757
1453
  index: number;
1758
1454
  }
1455
+ type SwiperDataLoader = (swiper: Swiper) => SwiperDataItem[] | Promise<SwiperDataItem[]>;
1456
+ type SwiperDataSource = SwiperDataItem[] | SwiperDataLoader;
1759
1457
  interface SwiperProps extends Record<string, unknown> {
1760
1458
  id?: string | null;
1761
- data?: SwiperDataItem[];
1459
+ data?: SwiperDataSource;
1762
1460
  loop?: boolean;
1763
1461
  autoplay?: boolean;
1764
1462
  delay?: number;
@@ -1775,7 +1473,7 @@ interface SwiperProps extends Record<string, unknown> {
1775
1473
  }
1776
1474
  interface ResolvedSwiperProps extends Record<string, unknown> {
1777
1475
  id: string | null;
1778
- data: SwiperDataItem[];
1476
+ data: SwiperDataSource;
1779
1477
  loop: boolean;
1780
1478
  autoplay: boolean;
1781
1479
  delay: number;
@@ -1792,127 +1490,28 @@ interface ResolvedSwiperProps extends Record<string, unknown> {
1792
1490
  }
1793
1491
  interface SwiperState extends Record<string, unknown> {
1794
1492
  data: SwiperDataItem[];
1493
+ loading: boolean;
1795
1494
  index: number;
1796
1495
  trackIndex: number;
1797
1496
  transform: number;
1798
1497
  animating: boolean;
1799
1498
  width: number;
1800
1499
  }
1801
- interface SwiperDOM extends ComponentDOM {
1802
- root: HTMLElement | null;
1803
- createdRoot: boolean;
1804
- wrapper: HTMLElement | null;
1805
- slides: HTMLElement[];
1806
- pagination: HTMLElement | null;
1807
- prevButton: HTMLButtonElement | null;
1808
- nextButton: HTMLButtonElement | null;
1809
- bullets: HTMLButtonElement[];
1810
- createdPagination: boolean;
1811
- createdPrevButton: boolean;
1812
- createdNextButton: boolean;
1813
- }
1814
- interface SwipeLog {
1815
- x: number;
1816
- y: number;
1817
- time: number;
1818
- }
1819
- interface SwiperRuntime extends ComponentRuntime {
1820
- built: boolean;
1821
- logs: SwipeLog[];
1822
- startTarget: EventTarget | null;
1823
- touching: boolean;
1824
- scrolling: boolean;
1825
- swiping: boolean;
1826
- clickPrevented: boolean;
1827
- timer: ReturnType<typeof setInterval> | null;
1828
- mountRefreshId: number | null;
1829
- imageCleanups: Set<() => void>;
1830
- realCount: number;
1831
- }
1832
- interface SwiperCleanupExtras {
1833
- bindings?: (() => void) | null;
1834
- navBindings?: (() => void) | null;
1835
- data?: (() => void) | null;
1836
- }
1837
- /**
1838
- * 轻量轮播组件,继承 Component。
1839
- *
1840
- * 支持链接 slide、图片 lazyload、分页、导航、loop 和桌面/移动端拖拽滑动。
1841
- * 使用 vanilla-signal 响应式管理 pagination 和 navigation 状态。
1842
- */
1843
- declare class SwiperComponent extends Component<ResolvedSwiperProps, SwiperState, SwiperDOM> {
1844
- props: ResolvedSwiperProps;
1845
- state: SwiperState;
1846
- dom: SwiperDOM;
1847
- runtime: SwiperRuntime;
1848
- cleanup: Component['cleanup'] & SwiperCleanupExtras;
1849
- /**
1850
- * 创建轮播实例。
1851
- * @param {object} [props={}] Swiper 配置。
1852
- */
1853
- constructor(props?: SwiperProps);
1854
- /**
1855
- * 构建 Swiper DOM。
1856
- * @returns {Swiper} 当前实例。
1857
- */
1858
- build(): this;
1859
- set index(v: unknown);
1860
- set trackIndex(v: unknown);
1861
- set transform(v: unknown);
1862
- set animating(v: unknown);
1863
- set width(v: unknown);
1864
- get realCount(): number;
1865
- get realIndex(): number;
1866
- private assertBuilt;
1867
- private createDataView;
1868
- private bindStateData;
1869
- private syncStateData;
1870
- private normalizeData;
1871
- private createDataSlide;
1872
- protected onInit(): void;
1873
- protected onDestroy(): void;
1874
- private updateSize;
1875
- refresh(): this;
1876
- private hasLayout;
1877
- private syncLayout;
1878
- private queueMountRefresh;
1879
- private cancelMountRefresh;
1880
- private refreshSlides;
1881
- private initLoop;
1882
- private setupStyles;
1883
- private reInitView;
1884
- private clearPagination;
1885
- private clearNavigation;
1886
- private bindEvents;
1887
- private onStart;
1888
- private onMove;
1889
- private onEnd;
1890
- private resetDrag;
1891
- private onTransitionEnd;
1892
- private pushLog;
1893
- private getDuration;
1894
- private getOffset;
1895
- toRealIndex(index?: number): number;
1896
- trackIndexForRealIndex(index: number): number;
1897
- private setTrackIndex;
1500
+ interface SwiperActions {
1898
1501
  slideTo(index: number): void;
1899
- slideToTrack(idx: number): void;
1502
+ slideToTrack(index: number): void;
1900
1503
  next(): void;
1901
1504
  prev(): void;
1902
- private render;
1903
- private loadImages;
1904
- private clearImageCleanups;
1905
- private initPagination;
1906
- private initNavigation;
1907
- private ensureNavigation;
1908
1505
  play(): void;
1909
1506
  pause(): void;
1910
1507
  resume(): void;
1911
1508
  restartAutoplay(): void;
1912
- protected normalizeStatePatch(patch: Partial<SwiperState>): Partial<SwiperState>;
1913
- protected validateStatePatch(patch: Partial<SwiperState>): void;
1914
1509
  }
1915
- type Swiper = SwiperComponent;
1510
+ type SwiperBase = FunctionalComponent<ResolvedSwiperProps, SwiperState, HTMLElement, SwiperActions>;
1511
+ type Swiper = SwiperBase & {
1512
+ readonly realCount: number;
1513
+ readonly realIndex: number;
1514
+ };
1916
1515
  declare function createSwiper(input?: SwiperProps): Swiper;
1917
1516
  //#endregion
1918
1517
  //#region src/components/tabs.d.ts
@@ -1926,7 +1525,6 @@ interface TabsClassNames {
1926
1525
  tab: string;
1927
1526
  panelWrap: string;
1928
1527
  panel: string;
1929
- disabled: string;
1930
1528
  dragging: string;
1931
1529
  }
1932
1530
  type TabsClassNameConfig = Partial<TabsClassNames>;
@@ -1936,15 +1534,11 @@ interface TabsPanelContext {
1936
1534
  index: number;
1937
1535
  name: string | number;
1938
1536
  }
1939
- interface TabTitleContext {
1940
- tabs: Tabs;
1941
- item: TabItem;
1942
- }
1943
- type TabPanel = RenderableContent<TabsPanelContext> | ((context: TabsPanelContext) => RenderableContent<TabsPanelContext>) | ((context: TabsPanelContext) => Promise<RenderableContent<TabsPanelContext>>);
1537
+ type TabContent = RenderableContent<TabsPanelContext> | ((context: TabsPanelContext) => RenderableContent<TabsPanelContext>) | ((context: TabsPanelContext) => Promise<RenderableContent<TabsPanelContext>>);
1944
1538
  interface TabItem extends Record<string, unknown> {
1945
1539
  name?: string;
1946
- title: RenderableContent<TabTitleContext>;
1947
- panel: TabPanel;
1540
+ title: Exclude<RenderableContent, (...args: never[]) => unknown>;
1541
+ content: TabContent;
1948
1542
  cache?: boolean;
1949
1543
  ttl?: number;
1950
1544
  }
@@ -1970,92 +1564,23 @@ interface TabsState extends Record<string, unknown> {
1970
1564
  data: TabItem[];
1971
1565
  active: TabsValue;
1972
1566
  disabled: TabsDisabled;
1973
- direction: TabsDirection;
1974
- current: {
1975
- index: number;
1976
- name: string | null;
1977
- };
1978
- isVertical: boolean;
1979
1567
  draggable: boolean;
1568
+ dragging: boolean;
1980
1569
  loading: boolean;
1981
1570
  }
1982
- interface TabsDOM extends ComponentDOM {
1983
- root: HTMLElement | null;
1984
- tabs: HTMLElement[];
1985
- panels: HTMLElement[];
1986
- }
1987
- interface TabsPanelCacheEntry {
1988
- content: RenderableContent<TabsPanelContext>;
1989
- updatedAt: number;
1571
+ interface TabsCurrent {
1572
+ index: number;
1573
+ name: string | null;
1990
1574
  }
1991
- interface TabsRuntime extends ComponentRuntime {
1992
- built: boolean;
1993
- cache: {
1994
- panels: Map<string, TabsPanelCacheEntry>;
1995
- };
1996
- panelLoadId: number;
1575
+ interface TabsActions {
1576
+ activate(value: TabsValue): Promise<void>;
1997
1577
  }
1998
- /**
1999
- * 标签页组件,继承 Component。
2000
- *
2001
- * DOM 创建一次,通过 createEffect 细粒度更新 class/ARIA。
2002
- */
2003
- declare class TabsComponent extends Component<ResolvedTabsProps, TabsState, TabsDOM> {
2004
- runtime: TabsRuntime;
2005
- state: TabsState;
2006
- private bindingsDispose;
2007
- private stateDispose;
2008
- private isDragging;
2009
- private raf;
2010
- private resizeRaf;
2011
- private velocity;
2012
- /**
2013
- * @param {object} [input={}] 标签页配置。
2014
- */
2015
- constructor(input?: TabsProps);
2016
- protected onInit(props: ResolvedTabsProps): void;
2017
- private buildRoot;
2018
- private renderItems;
2019
- private bindState;
2020
- private syncStateView;
2021
- private get disabledState();
2022
- private isDisabledName;
2023
- private syncCurrent;
2024
- private getPanelKey;
2025
- private getCachedPanel;
2026
- private setCachedPanel;
2027
- private renderPanelContent;
2028
- private loadPanel;
2029
- get activeIndex(): number;
2030
- get disabledNames(): string[];
2031
- private bindEvents;
2032
- private unbindEvents;
2033
- private assertActive;
2034
- private getIndex;
2035
- private activateInternal;
2036
- /**
2037
- * 激活指定标签。
2038
- * @param {number|string} val 标签索引或名称。
2039
- */
2040
- activate(val: TabsValue): Promise<void>;
2041
- /**
2042
- * 构建 Tabs DOM。
2043
- */
2044
- build(): this;
2045
- refresh(): this;
2046
- private get dragContainer();
2047
- private get dragInner();
2048
- private initDrag;
2049
- private bindDragEvents;
2050
- private startInertiaScroll;
2051
- private removeDragEvents;
2052
- private refreshDrag;
2053
- protected onDestroy(): void;
2054
- private validateData;
2055
- protected normalizeStatePatch(patch: Partial<TabsState>): Partial<TabsState>;
2056
- protected validateStatePatch(patch: Partial<TabsState>): void;
2057
- }
2058
- type Tabs = TabsComponent;
1578
+ type TabsBase = FunctionalComponent<ResolvedTabsProps, TabsState, HTMLElement, TabsActions>;
1579
+ type Tabs = TabsBase & {
1580
+ readonly current: TabsCurrent;
1581
+ readonly activeIndex: number;
1582
+ readonly disabledNames: string[];
1583
+ };
2059
1584
  declare function createTabs(input?: TabsProps): Tabs;
2060
1585
  //#endregion
2061
1586
  //#region src/components/offcanvas.d.ts
@@ -2106,53 +1631,15 @@ interface ResolvedOffcanvasProps extends Record<string, unknown> {
2106
1631
  }
2107
1632
  interface OffcanvasState extends Record<string, unknown> {
2108
1633
  content: OffcanvasContent;
1634
+ resolvedContent: RenderableContent<Offcanvas>;
2109
1635
  visible: boolean;
2110
1636
  loading: boolean;
2111
1637
  }
2112
- interface OffcanvasDOM extends ComponentDOM {
2113
- root: HTMLElement | null;
2114
- overlay: HTMLElement | null;
2115
- content: HTMLElement | null;
2116
- }
2117
- interface OffcanvasCache {
2118
- content: RenderableContent<Offcanvas>;
2119
- hasContent: boolean;
2120
- updatedAt: number;
2121
- }
2122
- interface OffcanvasRuntime extends ComponentRuntime {
2123
- built: boolean;
2124
- cache: OffcanvasCache;
2125
- contentLoadId: number;
2126
- }
2127
- interface OffcanvasCleanupExtras {
2128
- state?: (() => void) | null;
2129
- }
2130
- declare class OffcanvasComponent extends Component<ResolvedOffcanvasProps, OffcanvasState, OffcanvasDOM> {
2131
- runtime: OffcanvasRuntime;
2132
- state: OffcanvasState;
2133
- cleanup: Component['cleanup'] & OffcanvasCleanupExtras;
2134
- constructor(input?: OffcanvasProps);
2135
- build(): this;
2136
- private assertBuilt;
2137
- private buildRoot;
2138
- private buildOverlay;
2139
- private buildPanel;
2140
- private bindState;
2141
- private syncContent;
2142
- private isCacheValid;
2143
- private clearContent;
2144
- private renderContent;
2145
- private loadContent;
2146
- private bindEvents;
2147
- private unbindEvents;
2148
- private showPanel;
2149
- private hidePanel;
1638
+ interface OffcanvasActions {
2150
1639
  show(): Promise<void>;
2151
1640
  hide(): Promise<void>;
2152
- protected onDestroy(): void;
2153
- protected validateStatePatch(patch: Partial<OffcanvasState>): void;
2154
1641
  }
2155
- type Offcanvas = OffcanvasComponent;
1642
+ type Offcanvas = FunctionalComponent<ResolvedOffcanvasProps, OffcanvasState, HTMLElement, OffcanvasActions>;
2156
1643
  declare function createOffcanvas(input?: OffcanvasProps): Offcanvas;
2157
1644
  //#endregion
2158
1645
  //#region src/components/pagination.d.ts
@@ -2194,46 +1681,14 @@ interface PaginationState extends Record<string, unknown> {
2194
1681
  total: number;
2195
1682
  page: PaginationPage;
2196
1683
  count: PaginationCount;
2197
- pageCount: number;
2198
1684
  locked: boolean;
2199
1685
  }
2200
- interface PaginationDOM extends ComponentDOM {
2201
- root: HTMLElement | null;
2202
- list: HTMLElement | null;
1686
+ interface PaginationActions {
1687
+ go(page: number): Pagination;
2203
1688
  }
2204
- interface PaginationRuntime extends ComponentRuntime {
2205
- built: boolean;
2206
- itemsKey: string;
2207
- changeId: number;
2208
- }
2209
- interface PaginationCleanupExtras {
2210
- state?: (() => void) | null;
2211
- }
2212
- declare class PaginationComponent extends Component<ResolvedPaginationProps, PaginationState, PaginationDOM> {
2213
- runtime: PaginationRuntime;
2214
- state: PaginationState;
2215
- cleanup: Component['cleanup'] & PaginationCleanupExtras;
2216
- constructor(input?: PaginationProps);
2217
- build(): this;
2218
- go(page: number): this;
2219
- private bindState;
2220
- private syncState;
2221
- private renderItems;
2222
- private getPageItems;
2223
- private isLocked;
2224
- private isPrevDisabled;
2225
- private isNextDisabled;
2226
- private buildControlItem;
2227
- private buildPageItem;
2228
- private bindEvents;
2229
- private unbindEvents;
2230
- private unlock;
2231
- private assertActive;
2232
- protected normalizeStatePatch(patch: Partial<PaginationState>): Partial<PaginationState>;
2233
- protected validateStatePatch(patch: Partial<PaginationState>): void;
2234
- protected onDestroy(): void;
2235
- }
2236
- type Pagination = PaginationComponent;
1689
+ type Pagination = FunctionalComponent<ResolvedPaginationProps, PaginationState, HTMLElement, PaginationActions> & {
1690
+ readonly pageCount: number;
1691
+ };
2237
1692
  declare function createPagination(input?: PaginationProps): Pagination;
2238
1693
  //#endregion
2239
1694
  //#region src/components/menu.d.ts
@@ -2276,39 +1731,9 @@ interface ResolvedMenuProps extends Record<string, unknown> {
2276
1731
  }
2277
1732
  interface MenuState extends Record<string, unknown> {
2278
1733
  data: MenuItem[];
1734
+ activeKeys: string[];
2279
1735
  }
2280
- interface MenuDOM extends ComponentDOM {
2281
- root: HTMLElement | null;
2282
- list: HTMLElement | null;
2283
- }
2284
- interface MenuRuntime extends ComponentRuntime {
2285
- built: boolean;
2286
- }
2287
- interface MenuCleanupExtras {
2288
- state?: (() => void) | null;
2289
- }
2290
- declare class MenuComponent extends Component<ResolvedMenuProps, MenuState, MenuDOM> {
2291
- runtime: MenuRuntime;
2292
- state: MenuState;
2293
- cleanup: Component['cleanup'] & MenuCleanupExtras;
2294
- constructor(input?: MenuProps);
2295
- build(): this;
2296
- private bindState;
2297
- private renderSnapshot;
2298
- private buildItem;
2299
- private bindEvents;
2300
- private unbindEvents;
2301
- private handleMenuClick;
2302
- private handleBack;
2303
- private toggleActive;
2304
- private clearActive;
2305
- private validateData;
2306
- private assertStatePatchKey;
2307
- protected normalizeStatePatch(patch: Partial<MenuState>): Partial<MenuState>;
2308
- protected validateStatePatch(patch: Partial<MenuState>): void;
2309
- protected onDestroy(): void;
2310
- }
2311
- type Menu = MenuComponent;
1736
+ type Menu = FunctionalComponent<ResolvedMenuProps, MenuState, HTMLElement>;
2312
1737
  declare function createMenu(input?: MenuProps): Menu;
2313
1738
  //#endregion
2314
- export { CleanupFunction, Component, ContainerExpect, DOMReference, type DebounceSettings, type DebouncedFunc, FlowAction, FlowBusyHook, FlowBusyStrategy, FlowChangeHook, FlowClassNameConfig, FlowClassNames, FlowCleanup, FlowContext, FlowData, FlowDirection, FlowErrorHook, FlowFinishHook, FlowGuardHook, FlowLifecycleHook, FlowMoveHook, FlowPayload, FlowProps, FlowRenderContext, FlowSlot, FlowSlotName, FlowSnapshot, FlowState, FlowStep, FlowStepResult, FlowSubscriber, FlowTarget, FlowText, FormButton, FormClassNameConfig, FormClassNames, FormDataRecord, FormDataValue, FormField, FormOption, FormProps, FormValidatorConfig, IEventManager, IconAttributeValue, IconName, IconPathMap, IconProps, LazyRenderCallback, LazyRenderOptions, LazyRenderTarget, Menu, MenuClassNameConfig, MenuClassNames, MenuItem, MenuItemId, MenuProps, MenuType, Modal, ModalClassNameConfig, ModalClassNames, ModalMode, ModalProps, ModalText, NormalizeContext, Offcanvas, OffcanvasAnimate, OffcanvasClassNameConfig, OffcanvasClassNames, OffcanvasContent, OffcanvasDirection, OffcanvasProps, Pagination, PaginationClassNameConfig, PaginationClassNames, PaginationCount, PaginationPage, PaginationProps, ParamRule, ParamRuleInput, PopupProps, PublicFlowStep, QueryContext, RenderableContent, RequireContainerResult, ResolveContainerResult, ResolveSchema, ResolvedProps, Swiper, SwiperClassNameConfig, SwiperClassNames, SwiperDataItem, SwiperProps, SwiperSlideContext, TabItem, TabPanel, TabTitleContext, Tabs, TabsClassNameConfig, TabsClassNames, TabsDirection, TabsDisabled, TabsPanelContext, TabsProps, TabsValue, ThemeClassNameConfig, ThemeClassNames, ThemeConfigKey, ThemeInstance, ThemeOptions, ThemePanelGroup, ThemeResolvedOptions, type ThrottleSettings, Toast, ToastActionProps, ToastClassNameConfig, ToastClassNames, ToastOptions, ToastType, ValidateCondition, addIcons, all, copy, createAccordion, createDrop, createEventManager, createFlow, createForm, createLoading, createMenu, createModal, createOffcanvas, createPagination, createParabola, createPopup, createScheduledTask, createStateSync, createSticky, createSwiper, createTabs, createTheme, createToc, createTooltip, createValidator, debounce, getRegistedIconPath, getStoreVersion, getType, icon, iconHtml, iconMarkup, isDomElementValue, isDomNodeValue, isElement, isHtmlElementValue, isMobile, isNilValue, isNode, isPlainObject, isRenderableContent, isRenderablePrimitive, isRenderableValue, lazyRender, listen, normalizeContentNodes, normalizeRenderableContentNodes, postJson, q, randomId, requireContainer, resolveContainer, resolveElement, resolveNode, resolveNodeList, resolveProps, restUrl, stateSnapshot, throttle, timer, trackStoreVersion, uuid, validateParam };
1739
+ export { CleanupFunction, CollapseMotionController, CollapseTransitionDefinition, ComponentCleanup, ComponentContext, ComponentController, ComponentDefinition, ComponentLifecycleEvent, ComponentListener, ComponentPlugin, ComponentPluginOptions, ComponentProps, ComponentRuntime, ComponentState, ContainerExpect, DOMReference, type DebounceSettings, type DebouncedFunc, DropInstance, ElementRef, FieldOption, Flow, FlowAction, FlowBusyHook, FlowBusyStrategy, FlowChangeHook, FlowClassNameConfig, FlowClassNames, FlowCleanup, FlowContext, FlowData, FlowDirection, FlowErrorHook, FlowFinishHook, FlowGoToOptions, FlowGuardHook, FlowLifecycleHook, FlowMoveHook, FlowPayload, FlowProps, FlowRenderContext, FlowSlot, FlowSlotName, FlowSnapshot, FlowState, FlowStep, FlowStepResult, FlowSubscriber, FlowTarget, FlowText, Form, FormButton, FormClassNameConfig, FormClassNames, FormDataRecord, FormDataValue, FormField, FormItem, FormItemNext, FormItemType, FormOption, FormProps, FormValidatorConfig, FunctionalComponent, IEventManager, IconAttributeValue, IconName, IconPathMap, IconProps, KeyedElementRefs, LazyRenderCallback, LazyRenderOptions, LazyRenderTarget, Menu, MenuClassNameConfig, MenuClassNames, MenuItem, MenuItemId, MenuProps, MenuType, Modal, ModalClassNameConfig, ModalClassNames, ModalProps, ModalText, MotionController, NormalizeContext, Offcanvas, OffcanvasAnimate, OffcanvasClassNameConfig, OffcanvasClassNames, OffcanvasContent, OffcanvasDirection, OffcanvasProps, OwnedView, OwnedViewOptions, Pagination, PaginationClassNameConfig, PaginationClassNames, PaginationCount, PaginationPage, PaginationProps, ParabolaInstance, ParamRule, ParamRuleInput, PopupProps, PresenceController, PresenceOptions, PresencePhase, PublicFlowStep, QueryContext, RenderableContent, RequireContainerResult, ResolveContainerResult, ResolveSchema, ResolvedProps, StateSyncOptions, SupportES2022, Swiper, SwiperClassNameConfig, SwiperClassNames, SwiperDataItem, SwiperDataLoader, SwiperDataSource, SwiperProps, SwiperSlideContext, TabContent, TabItem, Tabs, TabsClassNameConfig, TabsClassNames, TabsDirection, TabsDisabled, TabsPanelContext, TabsProps, TabsValue, ThemeClassNameConfig, ThemeClassNames, ThemeConfigKey, ThemeInstance, ThemeOptions, ThemePanelGroup, ThemeResolvedOptions, type ThrottleSettings, Toast, ToastActionProps, ToastClassNameConfig, ToastClassNames, ToastOptions, ToastType, TocCurrent, TocItem, TooltipInstance, TransitionDefinition, TransitionTarget, ValidateCondition, ValidatorInstance, addIcons, all, checkModernBrowser, copy, createAccordion, createCollapseTransition, createDrop, createElementRef, createEventManager, createFlow, createForm, createKeyedElementRefs, createLoading, createMenu, createModal, createMotionGroup, createOffcanvas, createOwnedView, createPagination, createParabola, createPopup, createPresence, createScheduledTask, createStateSync, createSticky, createSwiper, createTabs, createTheme, createToc, createTooltip, createTransition, createValidator, debounce, defineComponent, flexPosition, getRegistedIconPath, getStoreVersion, getType, icon, iconHtml, iconMarkup, isDomElementValue, isDomNodeValue, isElement, isHtmlElementValue, isMobile, isModernBrowser, isNilValue, isNode, isPlainObject, isRenderableContent, isRenderablePrimitive, isRenderableValue, lazyRender, listen, postJson, q, randomId, removeComponentPlugin, requireContainer, resolveContainer, resolveElement, resolveNode, resolveNodeList, resolveProps, restUrl, stateSnapshot, throttle, timer, trackStoreVersion, useComponentPlugin, uuid, validateParam, waitForMotion };