vanilla-jui 1.4.7 → 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.
- package/README.md +10 -4
- package/dist/index.d.ts +418 -970
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -3
- package/src/components/accordion.ts +466 -346
- package/src/components/flow.ts +779 -1133
- package/src/components/form.ts +666 -509
- package/src/components/menu.ts +198 -328
- package/src/components/modal.ts +510 -747
- package/src/components/offcanvas.ts +273 -367
- package/src/components/pagination.ts +201 -375
- package/src/components/swiper.ts +689 -1107
- package/src/components/tabs.ts +467 -778
- package/src/components/toc.ts +191 -244
- package/src/core/component.ts +332 -0
- package/src/core/motion.ts +298 -0
- package/src/core/presence.ts +233 -0
- package/src/core/scheduler.ts +91 -0
- package/src/core/view.ts +31 -0
- package/src/css/accordion.css +94 -3
- package/src/css/content.css +18 -24
- package/src/css/drop.css +4 -1
- package/src/css/form.css +8 -0
- package/src/css/menu.css +10 -5
- package/src/css/modal.css +2 -1
- package/src/css/offcanvas.css +5 -17
- package/src/css/swiper.css +2 -1
- package/src/css/tabs.css +8 -17
- package/src/css/themes/default/accordion.css +0 -48
- package/src/css/themes/default/swiper.css +1 -1
- package/src/css/themes/default/tabs.css +4 -6
- package/src/css/toast.css +1 -17
- package/src/css/tooltip.css +2 -1
- package/src/index.ts +8 -2
- package/src/locales/index.ts +3 -0
- package/src/primitives/drop.ts +253 -262
- package/src/primitives/loading.ts +22 -4
- package/src/primitives/parabola.ts +123 -164
- package/src/primitives/sticky.ts +297 -0
- package/src/primitives/theme.ts +164 -222
- package/src/primitives/toast.ts +309 -284
- package/src/primitives/tooltip.ts +65 -66
- package/src/utilities/browser.ts +38 -0
- package/src/utilities/dom.ts +0 -54
- package/src/utilities/refs.ts +61 -0
- package/src/utilities/state.ts +73 -0
- package/src/utilities/timer.ts +11 -31
- package/src/validation/validator.ts +289 -389
- package/src/components/sticky.ts +0 -297
- package/src/core/Component.ts +0 -377
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,
|
|
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,6 +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
|
|
317
|
+
//#region src/core/scheduler.d.ts
|
|
318
|
+
interface ScheduledTask {
|
|
319
|
+
schedule: () => void;
|
|
320
|
+
flush: () => void;
|
|
321
|
+
cancel: () => void;
|
|
322
|
+
dispose: () => void;
|
|
323
|
+
}
|
|
324
|
+
declare function createScheduledTask(run: () => void): ScheduledTask;
|
|
325
|
+
//#endregion
|
|
326
|
+
//#region src/utilities/state.d.ts
|
|
327
|
+
interface StateSyncOptions {
|
|
328
|
+
deferInitial?: boolean;
|
|
329
|
+
flushInitial?: boolean;
|
|
330
|
+
flush?: 'microtask' | 'sync';
|
|
331
|
+
}
|
|
332
|
+
declare function getStoreVersion(value: unknown): number;
|
|
333
|
+
declare function trackStoreVersion<T>(value: T): T;
|
|
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
|
+
*/
|
|
339
|
+
declare function createStateSync<TSnapshot>(read: () => TSnapshot, sync: (snapshot: TSnapshot) => void | Promise<void>, { deferInitial, flushInitial, flush }?: StateSyncOptions): () => void;
|
|
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
|
|
319
391
|
//#region src/primitives/icons.d.ts
|
|
320
392
|
type IconPathMap = Record<string, string>;
|
|
321
393
|
type IconName = string;
|
|
@@ -358,12 +430,13 @@ declare function getRegistedIconPath(): IconPathMap;
|
|
|
358
430
|
declare function addIcons(svgPathObjects: IconPathMap): void;
|
|
359
431
|
//#endregion
|
|
360
432
|
//#region src/primitives/loading.d.ts
|
|
433
|
+
type flexPosition = 'center' | 'flex-start' | 'flex-end';
|
|
361
434
|
/**
|
|
362
435
|
* 创建通用加载状态节点
|
|
363
436
|
* 定位 absolute 撑满父元素 居中 背景模糊滤镜
|
|
364
437
|
* @returns {HTMLElement}
|
|
365
438
|
*/
|
|
366
|
-
declare function createLoading(): HTMLDivElement;
|
|
439
|
+
declare function createLoading(xDirection?: flexPosition, yDirection?: flexPosition): HTMLDivElement;
|
|
367
440
|
//#endregion
|
|
368
441
|
//#region src/primitives/popup.d.ts
|
|
369
442
|
interface PopupProps extends Record<string, unknown> {
|
|
@@ -387,50 +460,67 @@ interface DropDelay$1 {
|
|
|
387
460
|
show?: number;
|
|
388
461
|
hide?: number;
|
|
389
462
|
}
|
|
463
|
+
type DropContent = RenderableContent<DropInstance> | ((drop: DropInstance) => RenderableContent<DropInstance> | Promise<RenderableContent<DropInstance>>);
|
|
390
464
|
interface DropProps extends Record<string, unknown> {
|
|
391
465
|
name?: string | null;
|
|
392
466
|
mode?: DropMode$1;
|
|
393
467
|
position?: DropPosition$1;
|
|
394
468
|
offset?: number;
|
|
395
|
-
content?:
|
|
469
|
+
content?: DropContent;
|
|
470
|
+
cache?: boolean;
|
|
471
|
+
ttl?: number;
|
|
396
472
|
className?: DropClassNameConfig;
|
|
397
473
|
id?: string | null;
|
|
398
474
|
delay?: number | DropDelay$1;
|
|
399
475
|
hoverIntent?: boolean;
|
|
400
|
-
onShown?: ((drop: DropInstance
|
|
401
|
-
onHidden?: ((drop: DropInstance
|
|
402
|
-
}
|
|
403
|
-
interface DropDom {
|
|
404
|
-
root: HTMLElement | null;
|
|
476
|
+
onShown?: ((drop: DropInstance) => void | Promise<void>) | null;
|
|
477
|
+
onHidden?: ((drop: DropInstance) => void | Promise<void>) | null;
|
|
405
478
|
}
|
|
406
|
-
interface
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
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;
|
|
413
501
|
show(useDelay?: boolean): void;
|
|
414
502
|
hide(useDelay?: boolean): void;
|
|
415
503
|
toggle(): void;
|
|
416
504
|
destroy(): void;
|
|
417
505
|
}
|
|
418
|
-
|
|
506
|
+
/**
|
|
507
|
+
* 通用浮层组件。
|
|
508
|
+
*
|
|
509
|
+
* 可用于菜单、提示、下拉面板等场景,支持点击或 hover 触发,并自动计算视口内位置。
|
|
510
|
+
*/
|
|
511
|
+
declare function createDrop(reference: DOMReference, input?: DropProps): DropInstance;
|
|
419
512
|
//#endregion
|
|
420
513
|
//#region src/primitives/tooltip.d.ts
|
|
421
|
-
type DropInstance = ReturnType<typeof createDrop>;
|
|
514
|
+
type DropInstance$1 = ReturnType<typeof createDrop>;
|
|
422
515
|
type DropMode = 'hover' | 'click';
|
|
423
516
|
type DropPosition = 'auto' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left' | 'right';
|
|
424
517
|
interface DropDelay {
|
|
425
518
|
show?: number;
|
|
426
519
|
hide?: number;
|
|
427
520
|
}
|
|
428
|
-
interface TooltipDom {
|
|
429
|
-
root: HTMLElement | null;
|
|
430
|
-
}
|
|
431
521
|
interface TooltipInstance {
|
|
432
|
-
|
|
433
|
-
drop: DropInstance | null;
|
|
522
|
+
readonly element: HTMLElement | null;
|
|
523
|
+
readonly drop: DropInstance$1 | null;
|
|
434
524
|
show(useDelay?: boolean): void;
|
|
435
525
|
hide(useDelay?: boolean): void;
|
|
436
526
|
toggle(): void;
|
|
@@ -459,14 +549,21 @@ interface TooltipProps extends Record<string, unknown> {
|
|
|
459
549
|
offset?: number;
|
|
460
550
|
message?: string;
|
|
461
551
|
theme?: TooltipTheme;
|
|
552
|
+
cache?: boolean;
|
|
553
|
+
ttl?: number;
|
|
462
554
|
className?: TooltipClassNameConfig;
|
|
463
555
|
id?: string | null;
|
|
464
556
|
delay?: number | DropDelay;
|
|
465
557
|
hoverIntent?: boolean;
|
|
466
|
-
onShown?: ((drop: DropInstance) => void | Promise<void>) | null;
|
|
467
|
-
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;
|
|
468
560
|
}
|
|
469
|
-
|
|
561
|
+
/**
|
|
562
|
+
* Tooltip 提示组件。
|
|
563
|
+
*
|
|
564
|
+
* 基于 Drop 实现,提供更轻量的文本提示封装。
|
|
565
|
+
*/
|
|
566
|
+
declare function createTooltip(element: DOMReference, input?: TooltipProps): TooltipInstance;
|
|
470
567
|
//#endregion
|
|
471
568
|
//#region src/primitives/toast.d.ts
|
|
472
569
|
type ToastType = 'info' | 'success' | 'warning' | 'error' | 'primary';
|
|
@@ -492,6 +589,7 @@ interface ToastOptions {
|
|
|
492
589
|
className?: ToastClassNameConfig;
|
|
493
590
|
}
|
|
494
591
|
interface ToastActionProps extends ToastOptions {
|
|
592
|
+
type?: ToastType;
|
|
495
593
|
text?: {
|
|
496
594
|
close?: string;
|
|
497
595
|
action?: string;
|
|
@@ -499,32 +597,27 @@ interface ToastActionProps extends ToastOptions {
|
|
|
499
597
|
onAction?: () => void | Promise<void>;
|
|
500
598
|
onClose?: () => void | Promise<void>;
|
|
501
599
|
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
declare
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
private static getOrCreateContainer;
|
|
524
|
-
private static setTimer;
|
|
525
|
-
static clearAll(): void;
|
|
526
|
-
static destroyAll(): void;
|
|
527
|
-
}
|
|
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
|
+
};
|
|
528
621
|
//#endregion
|
|
529
622
|
//#region src/primitives/theme.d.ts
|
|
530
623
|
type ThemeConfigKey = 'mode' | 'theme' | 'radius' | 'shadow' | 'font';
|
|
@@ -603,29 +696,69 @@ interface ResolvedParabolaProps extends Record<string, unknown> {
|
|
|
603
696
|
onShow: ((parabola: ParabolaInstance) => void) | null;
|
|
604
697
|
onHidden: ((parabola: ParabolaInstance) => void) | null;
|
|
605
698
|
}
|
|
606
|
-
interface ParabolaDOM {
|
|
607
|
-
root: HTMLElement | null;
|
|
608
|
-
from: Element | null;
|
|
609
|
-
to: Element | null;
|
|
610
|
-
balls: Set<HTMLElement>;
|
|
611
|
-
}
|
|
612
699
|
interface ParabolaRuntime {
|
|
613
700
|
destroyed: boolean;
|
|
614
701
|
}
|
|
615
702
|
interface ParabolaInstance {
|
|
616
|
-
props: ResolvedParabolaProps;
|
|
617
|
-
|
|
618
|
-
runtime: ParabolaRuntime;
|
|
703
|
+
readonly props: ResolvedParabolaProps;
|
|
704
|
+
readonly element: HTMLElement | null;
|
|
705
|
+
readonly runtime: ParabolaRuntime;
|
|
619
706
|
show(): Promise<boolean>;
|
|
620
707
|
destroy(): void;
|
|
621
708
|
}
|
|
622
|
-
declare function createParabola(
|
|
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;
|
|
623
756
|
//#endregion
|
|
624
757
|
//#region src/validation/validator.d.ts
|
|
625
758
|
type ValidatorElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
626
759
|
type ValidatorMessageMap = Record<string, Partial<Record<string, string>>>;
|
|
627
760
|
type ValidatorCustomResult = boolean | string;
|
|
628
|
-
type ValidatorCustomRule = (element: ValidatorElement, validator: ValidatorInstance
|
|
761
|
+
type ValidatorCustomRule = (element: ValidatorElement, validator: ValidatorInstance) => ValidatorCustomResult;
|
|
629
762
|
interface ValidatorRule extends Record<string, unknown> {
|
|
630
763
|
required?: boolean;
|
|
631
764
|
minLength?: number;
|
|
@@ -650,15 +783,12 @@ interface ValidatorRule extends Record<string, unknown> {
|
|
|
650
783
|
interface ValidatorProps extends Record<string, unknown> {
|
|
651
784
|
rules?: Record<string, ValidatorRule>;
|
|
652
785
|
messages?: ValidatorMessageMap;
|
|
653
|
-
onSubmit?: ((validator: ValidatorInstance
|
|
786
|
+
onSubmit?: ((validator: ValidatorInstance) => void) | null;
|
|
654
787
|
}
|
|
655
788
|
interface ResolvedValidatorProps extends Record<string, unknown> {
|
|
656
789
|
rules: Record<string, ValidatorRule>;
|
|
657
790
|
messages: ValidatorMessageMap;
|
|
658
|
-
onSubmit: ((validator: ValidatorInstance
|
|
659
|
-
}
|
|
660
|
-
interface ValidatorDOM {
|
|
661
|
-
root: HTMLFormElement | null;
|
|
791
|
+
onSubmit: ((validator: ValidatorInstance) => void) | null;
|
|
662
792
|
}
|
|
663
793
|
interface ValidatorRuntime {
|
|
664
794
|
valid: boolean;
|
|
@@ -668,162 +798,77 @@ interface ValidatorRuntime {
|
|
|
668
798
|
interface ResetOptions {
|
|
669
799
|
native?: boolean;
|
|
670
800
|
}
|
|
671
|
-
interface ValidatorInstance
|
|
672
|
-
|
|
801
|
+
interface ValidatorInstance {
|
|
802
|
+
readonly element: HTMLFormElement | null;
|
|
673
803
|
props: ResolvedValidatorProps | null;
|
|
674
804
|
runtime: ValidatorRuntime;
|
|
675
805
|
validate(): boolean;
|
|
676
806
|
reset(options?: ResetOptions): void;
|
|
677
807
|
destroy(): void;
|
|
678
808
|
}
|
|
679
|
-
declare function createValidator(element: DOMReference, props?: ValidatorProps, bindEvents?: boolean): ValidatorInstance
|
|
809
|
+
declare function createValidator(element: DOMReference, props?: ValidatorProps, bindEvents?: boolean): ValidatorInstance;
|
|
680
810
|
//#endregion
|
|
681
|
-
//#region src/core/
|
|
811
|
+
//#region src/core/component.d.ts
|
|
682
812
|
type ComponentProps = Record<string, unknown>;
|
|
683
813
|
type ComponentState = Record<string, unknown>;
|
|
684
|
-
interface ComponentDOM {
|
|
685
|
-
root: Element | null;
|
|
686
|
-
[key: string]: unknown;
|
|
687
|
-
}
|
|
688
|
-
interface ComponentRuntime {
|
|
689
|
-
destroyed: boolean;
|
|
690
|
-
}
|
|
691
|
-
type ComponentCache = unknown;
|
|
692
|
-
interface ComponentReCreateOptions {
|
|
693
|
-
force?: boolean;
|
|
694
|
-
}
|
|
695
|
-
type ComponentLifecycleEvent = 'init' | 'beforeReCreate' | 'afterReCreate' | 'destroy';
|
|
696
|
-
type ComponentEventName = string;
|
|
697
|
-
type ComponentListener = (...args: unknown[]) => void;
|
|
698
|
-
type ComponentListeners = Record<ComponentLifecycleEvent, ComponentListener[]> & Record<string, ComponentListener[] | undefined>;
|
|
699
814
|
type ComponentCleanup = void | (() => void) | {
|
|
700
815
|
destroy: () => void;
|
|
701
816
|
};
|
|
702
817
|
type ComponentPluginOptions = Record<string, unknown> | undefined;
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
events: ReturnType<typeof createEventManager>;
|
|
708
|
-
plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
|
|
709
|
-
[key: string]: unknown;
|
|
818
|
+
interface ComponentRuntime {
|
|
819
|
+
built: boolean;
|
|
820
|
+
mounted: boolean;
|
|
821
|
+
destroyed: boolean;
|
|
710
822
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
dom: TDOM;
|
|
722
|
-
/** 实例缓存容器,存储组件运行时派生数据 */
|
|
723
|
-
cache: TCache;
|
|
724
|
-
/** 已安装的插件映射表 */
|
|
725
|
-
plugins: Map<ComponentPlugin<unknown>, ComponentCleanup>;
|
|
726
|
-
/** 资源清理管理器,包含事件监听器和插件的清理函数 */
|
|
727
|
-
cleanup: ComponentCleanupRegistry;
|
|
728
|
-
/** 内部事件监听器注册表,用于生命周期和自定义事件 */
|
|
729
|
-
protected _listeners: ComponentListeners;
|
|
730
|
-
/** 响应式状态存储,使用 vanilla-signal 的深层响应式 store */
|
|
731
|
-
state: TState | null;
|
|
732
|
-
/** 运行时状态标记 */
|
|
733
|
-
runtime: ComponentRuntime;
|
|
734
|
-
/**
|
|
735
|
-
* @param {Object} props - 组件初始属性配置
|
|
736
|
-
*/
|
|
737
|
-
constructor(props?: TProps);
|
|
738
|
-
/**
|
|
739
|
-
* 安装实例插件
|
|
740
|
-
* 插件可以是函数形式 plugin(instance, options) 或对象形式 { install(instance, options) }
|
|
741
|
-
* 插件应返回清理函数或清理对象,在组件销毁时自动执行
|
|
742
|
-
* @param {Function|Object} plugin - 插件函数或包含 install 方法的插件对象
|
|
743
|
-
* @param {Object} [options] - 插件配置选项
|
|
744
|
-
* @returns {Component} 返回当前实例,支持链式调用
|
|
745
|
-
*/
|
|
746
|
-
use(plugin: ComponentPlugin<this> | null | undefined, options?: ComponentPluginOptions): this;
|
|
747
|
-
/**
|
|
748
|
-
* 注册事件监听器
|
|
749
|
-
* 用于监听组件生命周期事件(init、beforeReCreate、afterReCreate、destroy)或自定义事件
|
|
750
|
-
* @param {string} event - 事件名称
|
|
751
|
-
* @param {Function} callback - 事件回调函数
|
|
752
|
-
* @returns {Component} 返回当前实例,支持链式调用
|
|
753
|
-
*/
|
|
754
|
-
on(event: ComponentEventName, callback: ComponentListener): this;
|
|
755
|
-
/**
|
|
756
|
-
* 移除事件监听器
|
|
757
|
-
* @param {string} event - 事件名称
|
|
758
|
-
* @param {Function} callback - 要移除的回调函数引用
|
|
759
|
-
* @returns {Component} 返回当前实例,支持链式调用
|
|
760
|
-
*/
|
|
761
|
-
off(event: ComponentEventName, callback: ComponentListener): this;
|
|
762
|
-
/**
|
|
763
|
-
* 安装全局插件到当前实例
|
|
764
|
-
* 遍历全局插件注册表并依次安装
|
|
765
|
-
* @private
|
|
766
|
-
*/
|
|
767
|
-
installGlobalPlugins(): void;
|
|
768
|
-
/**
|
|
769
|
-
* 注册全局插件
|
|
770
|
-
* 所有之后创建的组件实例都会自动安装此插件
|
|
771
|
-
* @static
|
|
772
|
-
* @param {string} name - 插件名称标识
|
|
773
|
-
* @param {Function|Object} plugin - 插件函数或插件对象
|
|
774
|
-
*/
|
|
775
|
-
static useGlobal(name: string | null | undefined, plugin: ComponentPlugin<Component> | null | undefined): void;
|
|
776
|
-
/**
|
|
777
|
-
* 触发指定事件,执行所有注册的监听器
|
|
778
|
-
* @param {string} event - 事件名称
|
|
779
|
-
* @param {...*} args - 传递给监听器的参数
|
|
780
|
-
* @returns {Component} 返回当前实例,支持链式调用
|
|
781
|
-
*/
|
|
782
|
-
emit(event: ComponentEventName, ...args: unknown[]): this;
|
|
783
|
-
/**
|
|
784
|
-
* 初始化组件
|
|
785
|
-
* 合并传入的属性,调用 onInit 钩子(如果存在),并触发 init 事件
|
|
786
|
-
* @param {Object} [props={}] - 初始化属性配置
|
|
787
|
-
* @returns {Component} 返回当前实例,支持链式调用
|
|
788
|
-
* @throws {Error} 如果组件已被销毁则抛出异常
|
|
789
|
-
*/
|
|
790
|
-
init(props?: Partial<TProps> | null | undefined): this;
|
|
791
|
-
/**
|
|
792
|
-
* 批量更新响应式状态
|
|
793
|
-
* 支持两种调用方式:setState(key, value) 或 setState({ key1: value1, key2: value2 })
|
|
794
|
-
* 使用 flushSync 确保状态更新的同步性和批量处理
|
|
795
|
-
* @param {string|Object} keyOrPatch - 状态键名或包含多个键值对的补丁对象
|
|
796
|
-
* @param {*} [value] - 当第一个参数为字符串时的状态值
|
|
797
|
-
* @returns {Component} 返回当前实例,支持链式调用
|
|
798
|
-
* @throws {Error} 如果组件已被销毁或参数格式不正确则抛出异常
|
|
799
|
-
*/
|
|
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;
|
|
800
833
|
setState(patch?: Partial<TState> | null): this;
|
|
801
834
|
setState<TKey extends keyof TState>(key: TKey, value: TState[TKey]): this;
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
* @param {Object} [options] - 更新选项
|
|
808
|
-
* @param {boolean} [options.force=false] - 是否强制更新(由子类处理)
|
|
809
|
-
* @returns {Component} 返回新创建的实例
|
|
810
|
-
* @throws {Error} 如果组件已被销毁则抛出异常
|
|
811
|
-
*/
|
|
812
|
-
reCreate(propsPatch?: Partial<TProps> | null | undefined, { force }?: ComponentReCreateOptions): this;
|
|
813
|
-
protected createInstance(props: TProps): this;
|
|
814
|
-
/**
|
|
815
|
-
* 销毁组件实例
|
|
816
|
-
* 执行 onDestroy 钩子,触发 destroy 事件,清理所有插件和资源
|
|
817
|
-
* 这是组件生命周期的最后一步,销毁后实例不可再使用
|
|
818
|
-
*/
|
|
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;
|
|
819
840
|
destroy(): void;
|
|
820
|
-
protected onInit?(props: TProps): void;
|
|
821
|
-
protected onReCreate?(propsPatch: Partial<TProps> | null | undefined, options: Required<ComponentReCreateOptions>): void;
|
|
822
|
-
protected normalizeStatePatch(patch: Partial<TState>): Partial<TState>;
|
|
823
|
-
protected validateStatePatch(patch: Partial<TState>): void;
|
|
824
|
-
protected afterSetState(_patch: Partial<TState>): void;
|
|
825
|
-
protected onDestroy?(): void;
|
|
826
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>;
|
|
827
872
|
//#endregion
|
|
828
873
|
//#region src/components/toc.d.ts
|
|
829
874
|
interface TocClassNames {
|
|
@@ -838,7 +883,6 @@ interface TocItem {
|
|
|
838
883
|
id: string;
|
|
839
884
|
text: string;
|
|
840
885
|
level: number;
|
|
841
|
-
element: HTMLHeadingElement;
|
|
842
886
|
}
|
|
843
887
|
interface TocCurrent {
|
|
844
888
|
index: number;
|
|
@@ -848,6 +892,7 @@ interface TocProps extends Record<string, unknown> {
|
|
|
848
892
|
target?: DOMReference;
|
|
849
893
|
headings?: string;
|
|
850
894
|
offset?: number;
|
|
895
|
+
reactive?: boolean;
|
|
851
896
|
className?: TocClassNameConfig;
|
|
852
897
|
onChange?: ((item: TocItem | null, index: number, toc: TocInstance) => void) | null;
|
|
853
898
|
}
|
|
@@ -855,6 +900,7 @@ interface ResolvedTocProps extends Record<string, unknown> {
|
|
|
855
900
|
target: DOMReference;
|
|
856
901
|
headings: string;
|
|
857
902
|
offset: number;
|
|
903
|
+
reactive: boolean;
|
|
858
904
|
className: TocClassNames;
|
|
859
905
|
onChange: ((item: TocItem | null, index: number, toc: TocInstance) => void) | null;
|
|
860
906
|
}
|
|
@@ -862,78 +908,16 @@ interface TocState extends Record<string, unknown> {
|
|
|
862
908
|
items: TocItem[];
|
|
863
909
|
current: TocCurrent;
|
|
864
910
|
}
|
|
865
|
-
interface
|
|
866
|
-
root: HTMLElement | null;
|
|
867
|
-
target: Element | null;
|
|
868
|
-
list: HTMLElement | null;
|
|
869
|
-
headings: HTMLHeadingElement[];
|
|
870
|
-
links: HTMLAnchorElement[];
|
|
871
|
-
}
|
|
872
|
-
interface TocRuntime extends ComponentRuntime {
|
|
873
|
-
built: boolean;
|
|
874
|
-
ticking: boolean;
|
|
875
|
-
}
|
|
876
|
-
type TocInstance = Component<ResolvedTocProps, TocState, TocDOM> & {
|
|
877
|
-
runtime: TocRuntime;
|
|
878
|
-
build(): TocInstance;
|
|
879
|
-
refresh(): TocInstance;
|
|
911
|
+
interface TocActions {
|
|
880
912
|
activate(index: number): TocInstance;
|
|
881
|
-
};
|
|
882
|
-
declare function createToc(props?: TocProps): TocInstance;
|
|
883
|
-
//#endregion
|
|
884
|
-
//#region src/components/sticky.d.ts
|
|
885
|
-
type StickyOverflow = 'destroy' | 'ignore';
|
|
886
|
-
interface StickyProps extends Record<string, unknown> {
|
|
887
|
-
target?: DOMReference;
|
|
888
|
-
parent?: DOMReference;
|
|
889
|
-
max?: number;
|
|
890
|
-
top?: number;
|
|
891
|
-
gap?: number;
|
|
892
|
-
overflow?: StickyOverflow;
|
|
893
|
-
onRefresh?: ((sticky: StickyInstance) => void) | null;
|
|
894
|
-
}
|
|
895
|
-
interface ResolvedStickyProps extends Record<string, unknown> {
|
|
896
|
-
target: DOMReference;
|
|
897
|
-
parent: DOMReference;
|
|
898
|
-
max: number;
|
|
899
|
-
top: number;
|
|
900
|
-
gap: number;
|
|
901
|
-
overflow: StickyOverflow;
|
|
902
|
-
onRefresh: ((sticky: StickyInstance) => void) | null;
|
|
903
|
-
}
|
|
904
|
-
interface StickyStateItem {
|
|
905
|
-
element: HTMLElement;
|
|
906
|
-
top: number;
|
|
907
|
-
}
|
|
908
|
-
interface StickyState extends Record<string, unknown> {
|
|
909
|
-
items: StickyStateItem[];
|
|
910
913
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
parent: Element | null;
|
|
914
|
-
targets: HTMLElement[];
|
|
915
|
-
}
|
|
916
|
-
interface StickyOriginalStyle {
|
|
917
|
-
element: HTMLElement;
|
|
918
|
-
originalPosition: string;
|
|
919
|
-
originalTop: string;
|
|
920
|
-
originalZIndex: string;
|
|
921
|
-
}
|
|
922
|
-
interface StickyRuntime extends ComponentRuntime {
|
|
923
|
-
built: boolean;
|
|
924
|
-
}
|
|
925
|
-
interface StickyCache {
|
|
926
|
-
originalStyles: StickyOriginalStyle[];
|
|
927
|
-
}
|
|
928
|
-
type StickyInstance = Component<ResolvedStickyProps, StickyState, StickyDOM, StickyCache> & {
|
|
929
|
-
runtime: StickyRuntime;
|
|
930
|
-
build(): StickyInstance;
|
|
931
|
-
refresh(): StickyInstance;
|
|
932
|
-
};
|
|
933
|
-
declare function createSticky(props?: StickyProps): StickyInstance;
|
|
914
|
+
type TocInstance = FunctionalComponent<ResolvedTocProps, TocState, HTMLElement, TocActions>;
|
|
915
|
+
declare function createToc(props?: TocProps): TocInstance;
|
|
934
916
|
//#endregion
|
|
935
917
|
//#region src/components/accordion.d.ts
|
|
936
918
|
type AccordionActive = number | string | Array<number | string> | null;
|
|
919
|
+
type AccordionDirection = 'vertical' | 'horizontal';
|
|
920
|
+
type AccordionContent = RenderableContent<AccordionContentContext> | ((context: AccordionContentContext) => Promise<RenderableContent<AccordionContentContext>>);
|
|
937
921
|
interface AccordionClassNames {
|
|
938
922
|
root: string;
|
|
939
923
|
header: string;
|
|
@@ -946,15 +930,18 @@ type AccordionClassNameConfig = Partial<AccordionClassNames>;
|
|
|
946
930
|
interface AccordionItem extends Record<string, unknown> {
|
|
947
931
|
name?: string;
|
|
948
932
|
title: RenderableContent<AccordionContentContext>;
|
|
949
|
-
content:
|
|
933
|
+
content: AccordionContent;
|
|
934
|
+
cache?: boolean;
|
|
935
|
+
ttl?: number;
|
|
950
936
|
}
|
|
951
937
|
interface AccordionProps extends Record<string, unknown> {
|
|
952
938
|
id?: string | null;
|
|
953
939
|
active?: AccordionActive;
|
|
954
940
|
collapsible?: boolean;
|
|
955
941
|
multiple?: boolean;
|
|
942
|
+
direction?: AccordionDirection;
|
|
956
943
|
className?: AccordionClassNameConfig;
|
|
957
|
-
|
|
944
|
+
data: AccordionItem[];
|
|
958
945
|
onChange?: ((index: number, name: string, header: HTMLElement, panel: HTMLElement, accordion: AccordionInstance) => void | Promise<void>) | null;
|
|
959
946
|
}
|
|
960
947
|
interface ResolvedAccordionProps extends Record<string, unknown> {
|
|
@@ -962,8 +949,9 @@ interface ResolvedAccordionProps extends Record<string, unknown> {
|
|
|
962
949
|
active: AccordionActive;
|
|
963
950
|
collapsible: boolean;
|
|
964
951
|
multiple: boolean;
|
|
952
|
+
direction: AccordionDirection;
|
|
965
953
|
className: AccordionClassNames;
|
|
966
|
-
|
|
954
|
+
data: AccordionItem[];
|
|
967
955
|
onChange: NonNullable<AccordionProps['onChange']> | null;
|
|
968
956
|
}
|
|
969
957
|
interface AccordionCurrent {
|
|
@@ -971,17 +959,9 @@ interface AccordionCurrent {
|
|
|
971
959
|
name: string | null;
|
|
972
960
|
}
|
|
973
961
|
interface AccordionState extends Record<string, unknown> {
|
|
974
|
-
|
|
962
|
+
data: AccordionItem[];
|
|
975
963
|
activeNames: string[];
|
|
976
|
-
|
|
977
|
-
}
|
|
978
|
-
interface AccordionDOM extends ComponentDOM {
|
|
979
|
-
root: HTMLElement | null;
|
|
980
|
-
headers: HTMLElement[];
|
|
981
|
-
panels: HTMLElement[];
|
|
982
|
-
}
|
|
983
|
-
interface AccordionRuntime extends ComponentRuntime {
|
|
984
|
-
built: boolean;
|
|
964
|
+
loading: boolean;
|
|
985
965
|
}
|
|
986
966
|
interface AccordionContentContext {
|
|
987
967
|
accordion: AccordionInstance;
|
|
@@ -990,24 +970,24 @@ interface AccordionContentContext {
|
|
|
990
970
|
type: 'title' | 'content';
|
|
991
971
|
active: boolean;
|
|
992
972
|
}
|
|
993
|
-
type AccordionInstance =
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
973
|
+
type AccordionInstance = FunctionalComponent<ResolvedAccordionProps, AccordionState, HTMLElement, AccordionActions> & {
|
|
974
|
+
readonly current: AccordionCurrent;
|
|
975
|
+
};
|
|
976
|
+
interface AccordionActions {
|
|
997
977
|
isActive(name: string): boolean;
|
|
998
978
|
getIndex(value: number | string | undefined | null): number;
|
|
999
979
|
activate(value: number | string | undefined): Promise<void>;
|
|
1000
|
-
}
|
|
980
|
+
}
|
|
1001
981
|
declare function createAccordion(props: AccordionProps): AccordionInstance;
|
|
1002
982
|
//#endregion
|
|
1003
983
|
//#region src/components/form.d.ts
|
|
1004
984
|
type FormValue = string | number | boolean;
|
|
1005
|
-
type
|
|
1006
|
-
type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
985
|
+
type FieldOption = FormValue | FormOption;
|
|
1007
986
|
type FormStyle = string | Partial<CSSStyleDeclaration> | null;
|
|
1008
987
|
type FormDataValue = FormDataEntryValue | FormDataEntryValue[];
|
|
1009
988
|
type FormDataRecord = Record<string, FormDataValue>;
|
|
1010
|
-
type
|
|
989
|
+
type FormItemType = FormControlType;
|
|
990
|
+
type FormControlType = 'checkbox' | 'custom' | 'email' | 'password' | 'radio' | 'select' | 'switch' | 'text' | 'textarea' | (string & {});
|
|
1011
991
|
interface FormClassNames {
|
|
1012
992
|
form: string;
|
|
1013
993
|
vertical: string;
|
|
@@ -1044,12 +1024,19 @@ interface FormOption {
|
|
|
1044
1024
|
checked?: boolean;
|
|
1045
1025
|
disabled?: boolean;
|
|
1046
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
|
+
}
|
|
1047
1034
|
interface FormField {
|
|
1035
|
+
[key: string]: unknown;
|
|
1048
1036
|
id?: string;
|
|
1049
1037
|
label?: RenderableContent<Form> | false;
|
|
1050
1038
|
name?: string;
|
|
1051
|
-
|
|
1052
|
-
options?: readonly FormOptionInput[];
|
|
1039
|
+
options?: readonly FieldOption[];
|
|
1053
1040
|
value?: FormDataEntryValue | boolean | readonly FormDataEntryValue[];
|
|
1054
1041
|
checked?: boolean;
|
|
1055
1042
|
required?: boolean;
|
|
@@ -1086,7 +1073,7 @@ interface FormProps extends Record<string, unknown> {
|
|
|
1086
1073
|
vertical?: boolean;
|
|
1087
1074
|
itemVertical?: boolean;
|
|
1088
1075
|
style?: FormStyle;
|
|
1089
|
-
fields?: readonly FormField[];
|
|
1076
|
+
fields?: readonly FormItem<FormField>[];
|
|
1090
1077
|
buttons?: boolean | readonly FormButton[];
|
|
1091
1078
|
className?: FormClassNameConfig;
|
|
1092
1079
|
validator?: FormValidatorConfig;
|
|
@@ -1098,7 +1085,7 @@ interface ResolvedFormProps extends Record<string, unknown> {
|
|
|
1098
1085
|
vertical: boolean;
|
|
1099
1086
|
itemVertical: boolean;
|
|
1100
1087
|
style: FormStyle;
|
|
1101
|
-
fields: FormField[];
|
|
1088
|
+
fields: FormItem<FormField>[];
|
|
1102
1089
|
buttons: FormButton[];
|
|
1103
1090
|
className: FormClassNames;
|
|
1104
1091
|
validator: FormValidatorConfig;
|
|
@@ -1109,77 +1096,22 @@ interface FormState extends ResolvedFormProps {
|
|
|
1109
1096
|
submitting: boolean;
|
|
1110
1097
|
data: FormDataRecord | null;
|
|
1111
1098
|
}
|
|
1112
|
-
interface FormDOM extends ComponentDOM {
|
|
1113
|
-
root: HTMLFormElement | null;
|
|
1114
|
-
fields: Map<string, FormControlElement>;
|
|
1115
|
-
}
|
|
1116
|
-
interface FormCache {
|
|
1117
|
-
initial: ResolvedFormProps;
|
|
1118
|
-
fieldIds: Map<string | number, string>;
|
|
1119
|
-
}
|
|
1120
|
-
interface ValidatorInstance {
|
|
1121
|
-
dom: {
|
|
1122
|
-
root: Element | null;
|
|
1123
|
-
};
|
|
1124
|
-
props: (FormValidatorConfig & {
|
|
1125
|
-
onSubmit: null;
|
|
1126
|
-
}) | null;
|
|
1127
|
-
validate: () => boolean;
|
|
1128
|
-
reset: () => void;
|
|
1129
|
-
destroy: () => void;
|
|
1130
|
-
}
|
|
1131
1099
|
interface FormControlContext {
|
|
1132
1100
|
form: Form;
|
|
1133
1101
|
field: FormField;
|
|
1134
1102
|
index: number;
|
|
1103
|
+
item: FormItem<FormField>;
|
|
1135
1104
|
}
|
|
1136
|
-
|
|
1137
|
-
state: FormState;
|
|
1138
|
-
validator: ValidatorInstance | null;
|
|
1139
|
-
cache: FormCache;
|
|
1140
|
-
constructor(input?: FormProps);
|
|
1141
|
-
get root(): HTMLFormElement | null;
|
|
1142
|
-
set root(value: HTMLFormElement | null);
|
|
1143
|
-
build(): this;
|
|
1144
|
-
view(): HTMLFormElement;
|
|
1145
|
-
fieldView(field: FormField, index: number): HTMLElement;
|
|
1146
|
-
labelView(field: FormField, id: string): HTMLLabelElement | null;
|
|
1147
|
-
controlView(field: FormField, id: string, index: number): FormControlElement | HTMLElement | Node[] | null;
|
|
1148
|
-
inputView(field: FormField, id: string): HTMLInputElement;
|
|
1149
|
-
textareaView(field: FormField, id: string): HTMLTextAreaElement;
|
|
1150
|
-
selectView(field: FormField, id: string): HTMLSelectElement;
|
|
1151
|
-
choiceGroupView(field: FormField, id: string, type: 'checkbox' | 'radio'): HTMLElement;
|
|
1152
|
-
switchView(field: FormField, id: string): HTMLLabelElement;
|
|
1153
|
-
buttonsView(): HTMLElement | null;
|
|
1154
|
-
controlProps<TExtra extends Record<string, unknown>>(field: FormField, id: string, extra: TExtra): TExtra & {
|
|
1155
|
-
name: string | undefined;
|
|
1156
|
-
id: string;
|
|
1157
|
-
placeholder: string;
|
|
1158
|
-
required: boolean;
|
|
1159
|
-
disabled: boolean;
|
|
1160
|
-
readonly: boolean;
|
|
1161
|
-
'data-form-field': string;
|
|
1162
|
-
ref: (element: FormControlElement) => void;
|
|
1163
|
-
};
|
|
1164
|
-
resolveFieldId(field: FormField, index: number): string;
|
|
1165
|
-
syncValidator(): void;
|
|
1105
|
+
interface FormActions {
|
|
1166
1106
|
validate(): boolean;
|
|
1167
|
-
reset():
|
|
1168
|
-
handleSubmit(event: Event): Promise<void>;
|
|
1169
|
-
handleReset(event: Event): void;
|
|
1170
|
-
resetValidationState(): void;
|
|
1107
|
+
reset(): Form;
|
|
1171
1108
|
collectData(): FormDataRecord;
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
isSelected(value: FormField['value'] | undefined, optionValue: FormOption['value']): boolean;
|
|
1179
|
-
isChecked(value: FormField['value'] | undefined, optionValue: FormOption['value'], checked: boolean | undefined): boolean;
|
|
1180
|
-
protected onDestroy(): void;
|
|
1181
|
-
}
|
|
1182
|
-
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;
|
|
1183
1115
|
//#endregion
|
|
1184
1116
|
//#region src/components/flow.d.ts
|
|
1185
1117
|
type FlowData = Record<string, unknown>;
|
|
@@ -1189,6 +1121,7 @@ type FlowBusyStrategy = 'ignore' | 'throw';
|
|
|
1189
1121
|
type FlowDirection = string;
|
|
1190
1122
|
type FlowSlotName = 'renderHeader' | 'renderBody' | 'renderFooter';
|
|
1191
1123
|
type FlowCleanup = () => void;
|
|
1124
|
+
type FlowTarget = string | number;
|
|
1192
1125
|
type FlowStepResult = string | {
|
|
1193
1126
|
id: string;
|
|
1194
1127
|
data?: FlowPayload;
|
|
@@ -1245,6 +1178,25 @@ interface FlowSnapshot {
|
|
|
1245
1178
|
busyAction: FlowAction | null;
|
|
1246
1179
|
error: unknown;
|
|
1247
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
|
+
}
|
|
1248
1200
|
interface FlowContext {
|
|
1249
1201
|
flow: Flow;
|
|
1250
1202
|
step: FlowStep;
|
|
@@ -1288,7 +1240,6 @@ type FlowErrorHook = (error: unknown, snapshot: FlowSnapshot, flow: Flow, previo
|
|
|
1288
1240
|
type FlowBusyHook = (action: FlowAction, snapshot: FlowSnapshot, flow: Flow) => void;
|
|
1289
1241
|
type FlowSlot = false | null | ((context: FlowRenderContext) => RenderableContent<FlowRenderContext>);
|
|
1290
1242
|
type FlowSubscriber = (snapshot: FlowSnapshot, flow: Flow, previous: FlowSnapshot | null) => void;
|
|
1291
|
-
type FlowTarget = string | number;
|
|
1292
1243
|
interface FlowText {
|
|
1293
1244
|
back: string;
|
|
1294
1245
|
next: string;
|
|
@@ -1344,208 +1295,49 @@ interface ResolvedFlowProps extends Record<string, unknown> {
|
|
|
1344
1295
|
onError: FlowErrorHook | null;
|
|
1345
1296
|
onBusy: FlowBusyHook | null;
|
|
1346
1297
|
}
|
|
1347
|
-
interface FlowState extends Record<string, unknown> {
|
|
1348
|
-
id: string;
|
|
1349
|
-
currentId: string;
|
|
1350
|
-
currentIndex: number;
|
|
1351
|
-
previousId: string | null;
|
|
1352
|
-
previousIndex: number | null;
|
|
1353
|
-
direction: FlowDirection | null;
|
|
1354
|
-
history: string[];
|
|
1355
|
-
data: FlowData;
|
|
1356
|
-
stepData: Record<string, FlowData>;
|
|
1357
|
-
loading: boolean;
|
|
1358
|
-
error: unknown;
|
|
1359
|
-
busyAction: FlowAction | null;
|
|
1360
|
-
version: number;
|
|
1361
|
-
}
|
|
1362
|
-
interface FlowDOM {
|
|
1363
|
-
root: HTMLElement | null;
|
|
1364
|
-
header: HTMLElement | null;
|
|
1365
|
-
body: HTMLElement | null;
|
|
1366
|
-
footer: HTMLElement | null;
|
|
1367
|
-
}
|
|
1368
1298
|
interface FlowRuntime {
|
|
1369
1299
|
built: boolean;
|
|
1300
|
+
mounted: boolean;
|
|
1370
1301
|
destroyed: boolean;
|
|
1371
1302
|
activeAction: FlowAction | null;
|
|
1372
1303
|
actionController: AbortController | null;
|
|
1373
1304
|
}
|
|
1374
|
-
interface
|
|
1375
|
-
direction?: FlowDirection;
|
|
1376
|
-
internal?: boolean;
|
|
1377
|
-
}
|
|
1378
|
-
interface FlowRunActionOptions {
|
|
1379
|
-
internal?: boolean;
|
|
1380
|
-
}
|
|
1381
|
-
/**
|
|
1382
|
-
* Headless 流程控制器,带可选默认 UI。
|
|
1383
|
-
*
|
|
1384
|
-
* 适合在 Modal、Offcanvas、页面表单或任意业务组件中复用 next/back/goTo、步骤缓存和生命周期。
|
|
1385
|
-
*/
|
|
1386
|
-
declare class Flow {
|
|
1387
|
-
props: ResolvedFlowProps;
|
|
1388
|
-
steps: FlowStep[];
|
|
1389
|
-
state: FlowState;
|
|
1390
|
-
dom: FlowDOM;
|
|
1391
|
-
runtime: FlowRuntime;
|
|
1392
|
-
private stepMap;
|
|
1393
|
-
private initialStepId;
|
|
1394
|
-
private initialData;
|
|
1395
|
-
private subscribers;
|
|
1396
|
-
private renderDispose;
|
|
1397
|
-
private cleanupTasks;
|
|
1398
|
-
/**
|
|
1399
|
-
* 创建 Flow 实例。
|
|
1400
|
-
* @param {FlowProps} [props={}] Flow 配置。
|
|
1401
|
-
*/
|
|
1402
|
-
constructor(props?: FlowProps);
|
|
1403
|
-
/**
|
|
1404
|
-
* 当前步骤。
|
|
1405
|
-
* @returns {FlowStep}
|
|
1406
|
-
*/
|
|
1407
|
-
get currentStep(): FlowStep;
|
|
1408
|
-
/**
|
|
1409
|
-
* 当前步骤数据。
|
|
1410
|
-
* @returns {object}
|
|
1411
|
-
*/
|
|
1412
|
-
get currentData(): FlowData;
|
|
1413
|
-
/**
|
|
1414
|
-
* 是否可以返回上一步。
|
|
1415
|
-
* @returns {boolean}
|
|
1416
|
-
*/
|
|
1417
|
-
get canBack(): boolean;
|
|
1418
|
-
/**
|
|
1419
|
-
* 是否可以前进。
|
|
1420
|
-
* @returns {boolean}
|
|
1421
|
-
*/
|
|
1422
|
-
get canNext(): boolean;
|
|
1423
|
-
/**
|
|
1424
|
-
* 是否处于最后一步。
|
|
1425
|
-
* @returns {boolean}
|
|
1426
|
-
*/
|
|
1427
|
-
get isLast(): boolean;
|
|
1428
|
-
/**
|
|
1429
|
-
* 订阅状态变化。
|
|
1430
|
-
* @param {Function} handler 订阅函数。
|
|
1431
|
-
* @returns {Function} 取消订阅函数。
|
|
1432
|
-
*/
|
|
1305
|
+
interface FlowActions {
|
|
1433
1306
|
subscribe(handler: FlowSubscriber): FlowCleanup;
|
|
1434
|
-
/**
|
|
1435
|
-
* 获取不可变快照。
|
|
1436
|
-
* @returns {object}
|
|
1437
|
-
*/
|
|
1438
1307
|
snapshot(): FlowSnapshot;
|
|
1439
|
-
/**
|
|
1440
|
-
* 构建默认 Flow UI。
|
|
1441
|
-
* @returns {Flow}
|
|
1442
|
-
*/
|
|
1443
|
-
build(): this;
|
|
1444
|
-
private teardownView;
|
|
1445
|
-
/**
|
|
1446
|
-
* 前进一步。
|
|
1447
|
-
* @param {object|null} [payload=null] 当前步骤需要缓存的数据。
|
|
1448
|
-
* @returns {Promise<object>} 切换后的快照。
|
|
1449
|
-
*/
|
|
1450
1308
|
next(payload?: FlowPayload): Promise<FlowSnapshot | null>;
|
|
1451
|
-
/**
|
|
1452
|
-
* 返回上一步。
|
|
1453
|
-
* @param {object|null} [payload=null] 当前步骤需要缓存的数据。
|
|
1454
|
-
* @returns {Promise<object>} 切换后的快照。
|
|
1455
|
-
*/
|
|
1456
1309
|
back(payload?: FlowPayload): Promise<FlowSnapshot | null>;
|
|
1457
|
-
/**
|
|
1458
|
-
* 跳转到指定步骤。
|
|
1459
|
-
* @param {string|number} target 目标步骤 id 或索引。
|
|
1460
|
-
* @param {object|null} [payload=null] 当前步骤需要缓存的数据。
|
|
1461
|
-
* @param {{direction?:string, internal?:boolean}} [options={}] 跳转选项。
|
|
1462
|
-
* @returns {Promise<object>} 切换后的快照。
|
|
1463
|
-
*/
|
|
1464
1310
|
goTo(target: FlowTarget, payload?: FlowPayload, options?: FlowGoToOptions): Promise<FlowSnapshot | null>;
|
|
1465
|
-
|
|
1466
|
-
* 合并全局数据。
|
|
1467
|
-
* @param {object} data 数据补丁。
|
|
1468
|
-
* @returns {Flow}
|
|
1469
|
-
*/
|
|
1470
|
-
setData(data: FlowPayload): this;
|
|
1471
|
-
/**
|
|
1472
|
-
* 合并指定步骤缓存数据。
|
|
1473
|
-
* @param {string} stepId 步骤 id。
|
|
1474
|
-
* @param {object|null} data 数据补丁。
|
|
1475
|
-
* @returns {Flow}
|
|
1476
|
-
*/
|
|
1311
|
+
setData(data: FlowPayload): Flow;
|
|
1477
1312
|
setStepData(stepId: string, data: FlowPayload, options?: {
|
|
1478
1313
|
silent?: boolean;
|
|
1479
|
-
}):
|
|
1480
|
-
/**
|
|
1481
|
-
* 获取指定步骤缓存数据。
|
|
1482
|
-
* @param {string} stepId 步骤 id。
|
|
1483
|
-
* @returns {object}
|
|
1484
|
-
*/
|
|
1314
|
+
}): Flow;
|
|
1485
1315
|
getStepData(stepId: string): FlowData;
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
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;
|
|
1501
1333
|
destroy(): void;
|
|
1502
|
-
private resolveInitialStepId;
|
|
1503
|
-
private validateSteps;
|
|
1504
|
-
private resolveStepIndex;
|
|
1505
|
-
private createInitialStepData;
|
|
1506
|
-
private runMoveHook;
|
|
1507
|
-
private transitionTo;
|
|
1508
|
-
private assertCanLeave;
|
|
1509
|
-
private assertCanEnter;
|
|
1510
|
-
private createContext;
|
|
1511
|
-
private runAction;
|
|
1512
|
-
private handleBusy;
|
|
1513
|
-
private abortActiveAction;
|
|
1514
|
-
private callHook;
|
|
1515
|
-
private createAbortError;
|
|
1516
|
-
private setLoading;
|
|
1517
|
-
private handleError;
|
|
1518
|
-
private emitChange;
|
|
1519
|
-
private replaceObject;
|
|
1520
|
-
private captureState;
|
|
1521
|
-
private restoreState;
|
|
1522
|
-
private addCleanup;
|
|
1523
|
-
private assertActive;
|
|
1524
|
-
private publicStep;
|
|
1525
|
-
private buildRoot;
|
|
1526
|
-
private mountView;
|
|
1527
|
-
private view;
|
|
1528
|
-
private renderSlot;
|
|
1529
|
-
private createRenderContext;
|
|
1530
|
-
private headerView;
|
|
1531
|
-
private stepsView;
|
|
1532
|
-
private bodyView;
|
|
1533
|
-
private footerView;
|
|
1534
|
-
private contentView;
|
|
1535
|
-
private stepClass;
|
|
1536
1334
|
}
|
|
1537
|
-
|
|
1538
|
-
* 创建 Flow 实例。
|
|
1539
|
-
* @param {FlowProps} props Flow 配置。
|
|
1540
|
-
* @returns {Flow}
|
|
1541
|
-
*/
|
|
1542
|
-
declare function createFlow(props?: FlowProps): Flow;
|
|
1335
|
+
declare function createFlow(input?: FlowProps): Flow;
|
|
1543
1336
|
//#endregion
|
|
1544
1337
|
//#region src/components/modal.d.ts
|
|
1545
1338
|
type ModalTextInput = Partial<ModalText> & Record<string, unknown>;
|
|
1546
|
-
type
|
|
1547
|
-
type
|
|
1548
|
-
type ModalMode = 'content' | 'form';
|
|
1339
|
+
type ModalContentResult = RenderableContent<Modal>;
|
|
1340
|
+
type ModalContent = ModalContentResult | ((modal: Modal) => ModalContentResult | Promise<ModalContentResult>);
|
|
1549
1341
|
interface ModalClassNames {
|
|
1550
1342
|
layout: string;
|
|
1551
1343
|
modal: string;
|
|
@@ -1565,8 +1357,9 @@ interface ModalText {
|
|
|
1565
1357
|
cancel: string;
|
|
1566
1358
|
}
|
|
1567
1359
|
interface ModalProps extends Record<string, unknown> {
|
|
1568
|
-
mode?: ModalMode | null;
|
|
1569
1360
|
content?: ModalContent;
|
|
1361
|
+
cache?: boolean;
|
|
1362
|
+
ttl?: number;
|
|
1570
1363
|
position?: string;
|
|
1571
1364
|
showCancel?: boolean;
|
|
1572
1365
|
showClose?: boolean;
|
|
@@ -1577,9 +1370,7 @@ interface ModalProps extends Record<string, unknown> {
|
|
|
1577
1370
|
onHide?: ((modal: Modal) => void | Promise<void>) | null;
|
|
1578
1371
|
onHidden?: ((modal: Modal) => void | Promise<void>) | null;
|
|
1579
1372
|
onConfirm?: ((modal: Modal) => void | Promise<void>) | null;
|
|
1580
|
-
onSubmit?: ((data: FormDataRecord, modal: Modal) => void | Promise<void>) | null;
|
|
1581
1373
|
onCancel?: ((modal: Modal) => void | Promise<void>) | null;
|
|
1582
|
-
fields?: readonly FormField[] | null;
|
|
1583
1374
|
header?: boolean;
|
|
1584
1375
|
footer?: boolean;
|
|
1585
1376
|
id?: string | null;
|
|
@@ -1588,8 +1379,9 @@ interface ModalProps extends Record<string, unknown> {
|
|
|
1588
1379
|
className?: ModalClassNameConfig;
|
|
1589
1380
|
}
|
|
1590
1381
|
interface ResolvedModalProps extends Record<string, unknown> {
|
|
1591
|
-
mode: ModalMode;
|
|
1592
1382
|
content: ModalContent;
|
|
1383
|
+
cache: boolean;
|
|
1384
|
+
ttl: number;
|
|
1593
1385
|
position: string;
|
|
1594
1386
|
showCancel: boolean;
|
|
1595
1387
|
showClose: boolean;
|
|
@@ -1600,9 +1392,7 @@ interface ResolvedModalProps extends Record<string, unknown> {
|
|
|
1600
1392
|
onHide: NonNullable<ModalProps['onHide']> | null;
|
|
1601
1393
|
onHidden: NonNullable<ModalProps['onHidden']> | null;
|
|
1602
1394
|
onConfirm: NonNullable<ModalProps['onConfirm']> | null;
|
|
1603
|
-
onSubmit: NonNullable<ModalProps['onSubmit']> | null;
|
|
1604
1395
|
onCancel: NonNullable<ModalProps['onCancel']> | null;
|
|
1605
|
-
fields: FormField[] | null;
|
|
1606
1396
|
header: boolean;
|
|
1607
1397
|
footer: boolean;
|
|
1608
1398
|
id: string;
|
|
@@ -1611,91 +1401,17 @@ interface ResolvedModalProps extends Record<string, unknown> {
|
|
|
1611
1401
|
className: ModalClassNames;
|
|
1612
1402
|
}
|
|
1613
1403
|
interface ModalState extends Record<string, unknown> {
|
|
1614
|
-
mode: ModalMode;
|
|
1615
1404
|
content: ModalContent;
|
|
1616
|
-
fields: FormField[] | null;
|
|
1617
1405
|
loading: boolean;
|
|
1618
1406
|
processing: boolean;
|
|
1619
1407
|
visible: boolean;
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
body: HTMLElement | null;
|
|
1628
|
-
footer: HTMLElement | null;
|
|
1629
|
-
form: FormInstance | null;
|
|
1630
|
-
formContainer: HTMLElement | null;
|
|
1631
|
-
}
|
|
1632
|
-
interface ModalRuntime extends ComponentRuntime {
|
|
1633
|
-
scrollLocked: boolean;
|
|
1634
|
-
visibleApplied: boolean;
|
|
1635
|
-
}
|
|
1636
|
-
interface ModalCache {
|
|
1637
|
-
initial: ResolvedModalProps | null;
|
|
1638
|
-
fieldIds: Map<string, string> | null;
|
|
1639
|
-
previousActiveElement: HTMLElement | null;
|
|
1640
|
-
formId: string;
|
|
1641
|
-
}
|
|
1642
|
-
interface ModalCleanupExtras {
|
|
1643
|
-
visibility?: (() => void) | null;
|
|
1644
|
-
view?: (() => void) | null;
|
|
1645
|
-
hideTimer?: ReturnType<typeof setTimeout> | null;
|
|
1646
|
-
}
|
|
1647
|
-
type ModalStatePatch = Partial<ModalState>;
|
|
1648
|
-
declare class ModalComponent extends Component<ResolvedModalProps, ModalState, ModalDOM, ModalCache> {
|
|
1649
|
-
runtime: ModalRuntime;
|
|
1650
|
-
state: ModalState;
|
|
1651
|
-
cleanup: Component['cleanup'] & ModalCleanupExtras;
|
|
1652
|
-
constructor(input?: ModalProps);
|
|
1653
|
-
protected onInit(): void;
|
|
1654
|
-
build(): this;
|
|
1655
|
-
mountView(): void;
|
|
1656
|
-
headerView(): () => (Node | null)[] | null;
|
|
1657
|
-
footerView(): () => (Node | null)[] | null;
|
|
1658
|
-
bodyView(): RenderableContent<Modal>;
|
|
1659
|
-
formView(): HTMLElement;
|
|
1660
|
-
mountForm(container: HTMLElement | null): void;
|
|
1661
|
-
createFormProps(): FormProps;
|
|
1662
|
-
destroyForm(): void;
|
|
1663
|
-
contentView(content: ModalContent): Node[];
|
|
1664
|
-
bindReactiveLoading(): void;
|
|
1665
|
-
isBusy(): boolean;
|
|
1666
|
-
bindReactiveVisibility(): void;
|
|
1667
|
-
applyVisibility(visible: boolean): void;
|
|
1668
|
-
showFromState(): void;
|
|
1669
|
-
hideFromState(): void;
|
|
1670
|
-
bindEvents(root: Element | null): void;
|
|
1671
|
-
bindOverlayCloseEvent(root: Element | null): void;
|
|
1672
|
-
bindDocumentKeyEvent(): void;
|
|
1673
|
-
bindInsideEvent(): void;
|
|
1674
|
-
clearEvents(): void;
|
|
1675
|
-
requestSubmit(): void;
|
|
1676
|
-
handleFormSubmit(formData: FormDataRecord): Promise<void>;
|
|
1677
|
-
handleConfirm(): Promise<void>;
|
|
1678
|
-
handleCancel(): Promise<void>;
|
|
1679
|
-
handleSubmit(data: FormDataRecord): Promise<void>;
|
|
1680
|
-
trapFocus(event: KeyboardEvent): void;
|
|
1681
|
-
focusFirst(): void;
|
|
1682
|
-
lockScroll(): void;
|
|
1683
|
-
unlockScroll(): void;
|
|
1684
|
-
cancelHideTimer(): void;
|
|
1685
|
-
resetAnimationStyles(): void;
|
|
1686
|
-
finishHide(onHidden: ResolvedModalProps['onHidden']): void;
|
|
1687
|
-
restoreFocus(): void;
|
|
1688
|
-
assertActive(method: string): void;
|
|
1689
|
-
protected normalizeStatePatch(patch: ModalStatePatch): ModalStatePatch;
|
|
1690
|
-
protected validateStatePatch(patch: ModalStatePatch): void;
|
|
1691
|
-
protected afterSetState(patch: ModalStatePatch): void;
|
|
1692
|
-
show(): this;
|
|
1693
|
-
hide(): this;
|
|
1694
|
-
reset(): this;
|
|
1695
|
-
protected onDestroy(): void;
|
|
1696
|
-
destroy(): this;
|
|
1697
|
-
}
|
|
1698
|
-
type Modal = ModalComponent;
|
|
1408
|
+
}
|
|
1409
|
+
interface ModalActions {
|
|
1410
|
+
show(): Modal;
|
|
1411
|
+
hide(): Modal;
|
|
1412
|
+
reset(): Modal;
|
|
1413
|
+
}
|
|
1414
|
+
type Modal = FunctionalComponent<ResolvedModalProps, ModalState, HTMLElement, ModalActions>;
|
|
1699
1415
|
declare function createModal(input?: ModalProps): Modal;
|
|
1700
1416
|
//#endregion
|
|
1701
1417
|
//#region src/components/swiper.d.ts
|
|
@@ -1716,9 +1432,6 @@ interface SwiperClassNames {
|
|
|
1716
1432
|
next: string;
|
|
1717
1433
|
active: string;
|
|
1718
1434
|
disabled: string;
|
|
1719
|
-
loading: string;
|
|
1720
|
-
loaded: string;
|
|
1721
|
-
error: string;
|
|
1722
1435
|
}
|
|
1723
1436
|
type SwiperClassNameConfig = Partial<SwiperClassNames>;
|
|
1724
1437
|
interface SwiperDataItem extends Record<string, unknown> {
|
|
@@ -1732,15 +1445,18 @@ interface SwiperDataItem extends Record<string, unknown> {
|
|
|
1732
1445
|
interface NormalizedSwiperDataItem extends SwiperDataItem {
|
|
1733
1446
|
blank: boolean;
|
|
1734
1447
|
index: number;
|
|
1448
|
+
key: string;
|
|
1735
1449
|
}
|
|
1736
1450
|
interface SwiperSlideContext {
|
|
1737
1451
|
swiper: Swiper;
|
|
1738
1452
|
item: NormalizedSwiperDataItem;
|
|
1739
1453
|
index: number;
|
|
1740
1454
|
}
|
|
1455
|
+
type SwiperDataLoader = (swiper: Swiper) => SwiperDataItem[] | Promise<SwiperDataItem[]>;
|
|
1456
|
+
type SwiperDataSource = SwiperDataItem[] | SwiperDataLoader;
|
|
1741
1457
|
interface SwiperProps extends Record<string, unknown> {
|
|
1742
1458
|
id?: string | null;
|
|
1743
|
-
data?:
|
|
1459
|
+
data?: SwiperDataSource;
|
|
1744
1460
|
loop?: boolean;
|
|
1745
1461
|
autoplay?: boolean;
|
|
1746
1462
|
delay?: number;
|
|
@@ -1757,7 +1473,7 @@ interface SwiperProps extends Record<string, unknown> {
|
|
|
1757
1473
|
}
|
|
1758
1474
|
interface ResolvedSwiperProps extends Record<string, unknown> {
|
|
1759
1475
|
id: string | null;
|
|
1760
|
-
data:
|
|
1476
|
+
data: SwiperDataSource;
|
|
1761
1477
|
loop: boolean;
|
|
1762
1478
|
autoplay: boolean;
|
|
1763
1479
|
delay: number;
|
|
@@ -1774,122 +1490,28 @@ interface ResolvedSwiperProps extends Record<string, unknown> {
|
|
|
1774
1490
|
}
|
|
1775
1491
|
interface SwiperState extends Record<string, unknown> {
|
|
1776
1492
|
data: SwiperDataItem[];
|
|
1493
|
+
loading: boolean;
|
|
1777
1494
|
index: number;
|
|
1778
1495
|
trackIndex: number;
|
|
1779
1496
|
transform: number;
|
|
1780
1497
|
animating: boolean;
|
|
1781
1498
|
width: number;
|
|
1782
1499
|
}
|
|
1783
|
-
interface
|
|
1784
|
-
root: HTMLElement | null;
|
|
1785
|
-
createdRoot: boolean;
|
|
1786
|
-
wrapper: HTMLElement | null;
|
|
1787
|
-
slides: HTMLElement[];
|
|
1788
|
-
pagination: HTMLElement | null;
|
|
1789
|
-
prevButton: HTMLButtonElement | null;
|
|
1790
|
-
nextButton: HTMLButtonElement | null;
|
|
1791
|
-
bullets: HTMLButtonElement[];
|
|
1792
|
-
createdPagination: boolean;
|
|
1793
|
-
createdPrevButton: boolean;
|
|
1794
|
-
createdNextButton: boolean;
|
|
1795
|
-
}
|
|
1796
|
-
interface SwipeLog {
|
|
1797
|
-
x: number;
|
|
1798
|
-
y: number;
|
|
1799
|
-
time: number;
|
|
1800
|
-
}
|
|
1801
|
-
interface SwiperRuntime extends ComponentRuntime {
|
|
1802
|
-
built: boolean;
|
|
1803
|
-
logs: SwipeLog[];
|
|
1804
|
-
startTarget: EventTarget | null;
|
|
1805
|
-
touching: boolean;
|
|
1806
|
-
scrolling: boolean;
|
|
1807
|
-
swiping: boolean;
|
|
1808
|
-
clickPrevented: boolean;
|
|
1809
|
-
timer: ReturnType<typeof setInterval> | null;
|
|
1810
|
-
imageCleanups: Set<() => void>;
|
|
1811
|
-
realCount: number;
|
|
1812
|
-
}
|
|
1813
|
-
interface SwiperCleanupExtras {
|
|
1814
|
-
bindings?: (() => void) | null;
|
|
1815
|
-
navBindings?: (() => void) | null;
|
|
1816
|
-
data?: (() => void) | null;
|
|
1817
|
-
}
|
|
1818
|
-
/**
|
|
1819
|
-
* 轻量轮播组件,继承 Component。
|
|
1820
|
-
*
|
|
1821
|
-
* 支持链接 slide、图片 lazyload、分页、导航、loop 和桌面/移动端拖拽滑动。
|
|
1822
|
-
* 使用 vanilla-signal 响应式管理 pagination 和 navigation 状态。
|
|
1823
|
-
*/
|
|
1824
|
-
declare class SwiperComponent extends Component<ResolvedSwiperProps, SwiperState, SwiperDOM> {
|
|
1825
|
-
props: ResolvedSwiperProps;
|
|
1826
|
-
state: SwiperState;
|
|
1827
|
-
dom: SwiperDOM;
|
|
1828
|
-
runtime: SwiperRuntime;
|
|
1829
|
-
cleanup: Component['cleanup'] & SwiperCleanupExtras;
|
|
1830
|
-
/**
|
|
1831
|
-
* 创建轮播实例。
|
|
1832
|
-
* @param {object} [props={}] Swiper 配置。
|
|
1833
|
-
*/
|
|
1834
|
-
constructor(props?: SwiperProps);
|
|
1835
|
-
/**
|
|
1836
|
-
* 构建 Swiper DOM。
|
|
1837
|
-
* @returns {Swiper} 当前实例。
|
|
1838
|
-
*/
|
|
1839
|
-
build(): this;
|
|
1840
|
-
set index(v: unknown);
|
|
1841
|
-
set trackIndex(v: unknown);
|
|
1842
|
-
set transform(v: unknown);
|
|
1843
|
-
set animating(v: unknown);
|
|
1844
|
-
set width(v: unknown);
|
|
1845
|
-
get realCount(): number;
|
|
1846
|
-
get realIndex(): number;
|
|
1847
|
-
private assertBuilt;
|
|
1848
|
-
private createDataView;
|
|
1849
|
-
private bindStateData;
|
|
1850
|
-
private syncStateData;
|
|
1851
|
-
private normalizeData;
|
|
1852
|
-
private createDataSlide;
|
|
1853
|
-
protected onInit(): void;
|
|
1854
|
-
protected onDestroy(): void;
|
|
1855
|
-
private updateSize;
|
|
1856
|
-
refresh(): this;
|
|
1857
|
-
private refreshSlides;
|
|
1858
|
-
private initLoop;
|
|
1859
|
-
private setupStyles;
|
|
1860
|
-
private reInitView;
|
|
1861
|
-
private clearPagination;
|
|
1862
|
-
private clearNavigation;
|
|
1863
|
-
private bindEvents;
|
|
1864
|
-
private onStart;
|
|
1865
|
-
private onMove;
|
|
1866
|
-
private onEnd;
|
|
1867
|
-
private resetDrag;
|
|
1868
|
-
private onTransitionEnd;
|
|
1869
|
-
private pushLog;
|
|
1870
|
-
private getDuration;
|
|
1871
|
-
private getOffset;
|
|
1872
|
-
toRealIndex(index?: number): number;
|
|
1873
|
-
trackIndexForRealIndex(index: number): number;
|
|
1874
|
-
private setTrackIndex;
|
|
1500
|
+
interface SwiperActions {
|
|
1875
1501
|
slideTo(index: number): void;
|
|
1876
|
-
slideToTrack(
|
|
1502
|
+
slideToTrack(index: number): void;
|
|
1877
1503
|
next(): void;
|
|
1878
1504
|
prev(): void;
|
|
1879
|
-
private render;
|
|
1880
|
-
private loadImages;
|
|
1881
|
-
private clearImageCleanups;
|
|
1882
|
-
private initPagination;
|
|
1883
|
-
private initNavigation;
|
|
1884
|
-
private ensureNavigation;
|
|
1885
1505
|
play(): void;
|
|
1886
1506
|
pause(): void;
|
|
1887
1507
|
resume(): void;
|
|
1888
1508
|
restartAutoplay(): void;
|
|
1889
|
-
protected normalizeStatePatch(patch: Partial<SwiperState>): Partial<SwiperState>;
|
|
1890
|
-
protected validateStatePatch(patch: Partial<SwiperState>): void;
|
|
1891
1509
|
}
|
|
1892
|
-
type
|
|
1510
|
+
type SwiperBase = FunctionalComponent<ResolvedSwiperProps, SwiperState, HTMLElement, SwiperActions>;
|
|
1511
|
+
type Swiper = SwiperBase & {
|
|
1512
|
+
readonly realCount: number;
|
|
1513
|
+
readonly realIndex: number;
|
|
1514
|
+
};
|
|
1893
1515
|
declare function createSwiper(input?: SwiperProps): Swiper;
|
|
1894
1516
|
//#endregion
|
|
1895
1517
|
//#region src/components/tabs.d.ts
|
|
@@ -1903,7 +1525,6 @@ interface TabsClassNames {
|
|
|
1903
1525
|
tab: string;
|
|
1904
1526
|
panelWrap: string;
|
|
1905
1527
|
panel: string;
|
|
1906
|
-
disabled: string;
|
|
1907
1528
|
dragging: string;
|
|
1908
1529
|
}
|
|
1909
1530
|
type TabsClassNameConfig = Partial<TabsClassNames>;
|
|
@@ -1913,15 +1534,11 @@ interface TabsPanelContext {
|
|
|
1913
1534
|
index: number;
|
|
1914
1535
|
name: string | number;
|
|
1915
1536
|
}
|
|
1916
|
-
|
|
1917
|
-
tabs: Tabs;
|
|
1918
|
-
item: TabItem;
|
|
1919
|
-
}
|
|
1920
|
-
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>>);
|
|
1921
1538
|
interface TabItem extends Record<string, unknown> {
|
|
1922
1539
|
name?: string;
|
|
1923
|
-
title: RenderableContent
|
|
1924
|
-
|
|
1540
|
+
title: Exclude<RenderableContent, (...args: never[]) => unknown>;
|
|
1541
|
+
content: TabContent;
|
|
1925
1542
|
cache?: boolean;
|
|
1926
1543
|
ttl?: number;
|
|
1927
1544
|
}
|
|
@@ -1947,92 +1564,23 @@ interface TabsState extends Record<string, unknown> {
|
|
|
1947
1564
|
data: TabItem[];
|
|
1948
1565
|
active: TabsValue;
|
|
1949
1566
|
disabled: TabsDisabled;
|
|
1950
|
-
direction: TabsDirection;
|
|
1951
|
-
current: {
|
|
1952
|
-
index: number;
|
|
1953
|
-
name: string | null;
|
|
1954
|
-
};
|
|
1955
|
-
isVertical: boolean;
|
|
1956
1567
|
draggable: boolean;
|
|
1568
|
+
dragging: boolean;
|
|
1957
1569
|
loading: boolean;
|
|
1958
1570
|
}
|
|
1959
|
-
interface
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
panels: HTMLElement[];
|
|
1963
|
-
}
|
|
1964
|
-
interface TabsPanelCacheEntry {
|
|
1965
|
-
content: RenderableContent<TabsPanelContext>;
|
|
1966
|
-
updatedAt: number;
|
|
1571
|
+
interface TabsCurrent {
|
|
1572
|
+
index: number;
|
|
1573
|
+
name: string | null;
|
|
1967
1574
|
}
|
|
1968
|
-
interface
|
|
1969
|
-
|
|
1970
|
-
cache: {
|
|
1971
|
-
panels: Map<string, TabsPanelCacheEntry>;
|
|
1972
|
-
};
|
|
1973
|
-
panelLoadId: number;
|
|
1575
|
+
interface TabsActions {
|
|
1576
|
+
activate(value: TabsValue): Promise<void>;
|
|
1974
1577
|
}
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
runtime: TabsRuntime;
|
|
1982
|
-
state: TabsState;
|
|
1983
|
-
private bindingsDispose;
|
|
1984
|
-
private stateDispose;
|
|
1985
|
-
private isDragging;
|
|
1986
|
-
private raf;
|
|
1987
|
-
private resizeRaf;
|
|
1988
|
-
private velocity;
|
|
1989
|
-
/**
|
|
1990
|
-
* @param {object} [input={}] 标签页配置。
|
|
1991
|
-
*/
|
|
1992
|
-
constructor(input?: TabsProps);
|
|
1993
|
-
protected onInit(props: ResolvedTabsProps): void;
|
|
1994
|
-
private buildRoot;
|
|
1995
|
-
private renderItems;
|
|
1996
|
-
private bindState;
|
|
1997
|
-
private syncStateView;
|
|
1998
|
-
private get disabledState();
|
|
1999
|
-
private isDisabledName;
|
|
2000
|
-
private syncCurrent;
|
|
2001
|
-
private getPanelKey;
|
|
2002
|
-
private getCachedPanel;
|
|
2003
|
-
private setCachedPanel;
|
|
2004
|
-
private renderPanelContent;
|
|
2005
|
-
private loadPanel;
|
|
2006
|
-
get activeIndex(): number;
|
|
2007
|
-
get disabledNames(): string[];
|
|
2008
|
-
private bindEvents;
|
|
2009
|
-
private unbindEvents;
|
|
2010
|
-
private assertActive;
|
|
2011
|
-
private getIndex;
|
|
2012
|
-
private activateInternal;
|
|
2013
|
-
/**
|
|
2014
|
-
* 激活指定标签。
|
|
2015
|
-
* @param {number|string} val 标签索引或名称。
|
|
2016
|
-
*/
|
|
2017
|
-
activate(val: TabsValue): Promise<void>;
|
|
2018
|
-
/**
|
|
2019
|
-
* 构建 Tabs DOM。
|
|
2020
|
-
*/
|
|
2021
|
-
build(): this;
|
|
2022
|
-
refresh(): this;
|
|
2023
|
-
private get dragContainer();
|
|
2024
|
-
private get dragInner();
|
|
2025
|
-
private initDrag;
|
|
2026
|
-
private bindDragEvents;
|
|
2027
|
-
private startInertiaScroll;
|
|
2028
|
-
private removeDragEvents;
|
|
2029
|
-
private refreshDrag;
|
|
2030
|
-
protected onDestroy(): void;
|
|
2031
|
-
private validateData;
|
|
2032
|
-
protected normalizeStatePatch(patch: Partial<TabsState>): Partial<TabsState>;
|
|
2033
|
-
protected validateStatePatch(patch: Partial<TabsState>): void;
|
|
2034
|
-
}
|
|
2035
|
-
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
|
+
};
|
|
2036
1584
|
declare function createTabs(input?: TabsProps): Tabs;
|
|
2037
1585
|
//#endregion
|
|
2038
1586
|
//#region src/components/offcanvas.d.ts
|
|
@@ -2083,53 +1631,15 @@ interface ResolvedOffcanvasProps extends Record<string, unknown> {
|
|
|
2083
1631
|
}
|
|
2084
1632
|
interface OffcanvasState extends Record<string, unknown> {
|
|
2085
1633
|
content: OffcanvasContent;
|
|
1634
|
+
resolvedContent: RenderableContent<Offcanvas>;
|
|
2086
1635
|
visible: boolean;
|
|
2087
1636
|
loading: boolean;
|
|
2088
1637
|
}
|
|
2089
|
-
interface
|
|
2090
|
-
root: HTMLElement | null;
|
|
2091
|
-
overlay: HTMLElement | null;
|
|
2092
|
-
content: HTMLElement | null;
|
|
2093
|
-
}
|
|
2094
|
-
interface OffcanvasCache {
|
|
2095
|
-
content: RenderableContent<Offcanvas>;
|
|
2096
|
-
hasContent: boolean;
|
|
2097
|
-
updatedAt: number;
|
|
2098
|
-
}
|
|
2099
|
-
interface OffcanvasRuntime extends ComponentRuntime {
|
|
2100
|
-
built: boolean;
|
|
2101
|
-
cache: OffcanvasCache;
|
|
2102
|
-
contentLoadId: number;
|
|
2103
|
-
}
|
|
2104
|
-
interface OffcanvasCleanupExtras {
|
|
2105
|
-
state?: (() => void) | null;
|
|
2106
|
-
}
|
|
2107
|
-
declare class OffcanvasComponent extends Component<ResolvedOffcanvasProps, OffcanvasState, OffcanvasDOM> {
|
|
2108
|
-
runtime: OffcanvasRuntime;
|
|
2109
|
-
state: OffcanvasState;
|
|
2110
|
-
cleanup: Component['cleanup'] & OffcanvasCleanupExtras;
|
|
2111
|
-
constructor(input?: OffcanvasProps);
|
|
2112
|
-
build(): this;
|
|
2113
|
-
private assertBuilt;
|
|
2114
|
-
private buildRoot;
|
|
2115
|
-
private buildOverlay;
|
|
2116
|
-
private buildPanel;
|
|
2117
|
-
private bindState;
|
|
2118
|
-
private syncContent;
|
|
2119
|
-
private isCacheValid;
|
|
2120
|
-
private clearContent;
|
|
2121
|
-
private renderContent;
|
|
2122
|
-
private loadContent;
|
|
2123
|
-
private bindEvents;
|
|
2124
|
-
private unbindEvents;
|
|
2125
|
-
private showPanel;
|
|
2126
|
-
private hidePanel;
|
|
1638
|
+
interface OffcanvasActions {
|
|
2127
1639
|
show(): Promise<void>;
|
|
2128
1640
|
hide(): Promise<void>;
|
|
2129
|
-
protected onDestroy(): void;
|
|
2130
|
-
protected validateStatePatch(patch: Partial<OffcanvasState>): void;
|
|
2131
1641
|
}
|
|
2132
|
-
type Offcanvas =
|
|
1642
|
+
type Offcanvas = FunctionalComponent<ResolvedOffcanvasProps, OffcanvasState, HTMLElement, OffcanvasActions>;
|
|
2133
1643
|
declare function createOffcanvas(input?: OffcanvasProps): Offcanvas;
|
|
2134
1644
|
//#endregion
|
|
2135
1645
|
//#region src/components/pagination.d.ts
|
|
@@ -2171,46 +1681,14 @@ interface PaginationState extends Record<string, unknown> {
|
|
|
2171
1681
|
total: number;
|
|
2172
1682
|
page: PaginationPage;
|
|
2173
1683
|
count: PaginationCount;
|
|
2174
|
-
pageCount: number;
|
|
2175
1684
|
locked: boolean;
|
|
2176
1685
|
}
|
|
2177
|
-
interface
|
|
2178
|
-
|
|
2179
|
-
list: HTMLElement | null;
|
|
1686
|
+
interface PaginationActions {
|
|
1687
|
+
go(page: number): Pagination;
|
|
2180
1688
|
}
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
changeId: number;
|
|
2185
|
-
}
|
|
2186
|
-
interface PaginationCleanupExtras {
|
|
2187
|
-
state?: (() => void) | null;
|
|
2188
|
-
}
|
|
2189
|
-
declare class PaginationComponent extends Component<ResolvedPaginationProps, PaginationState, PaginationDOM> {
|
|
2190
|
-
runtime: PaginationRuntime;
|
|
2191
|
-
state: PaginationState;
|
|
2192
|
-
cleanup: Component['cleanup'] & PaginationCleanupExtras;
|
|
2193
|
-
constructor(input?: PaginationProps);
|
|
2194
|
-
build(): this;
|
|
2195
|
-
go(page: number): this;
|
|
2196
|
-
private bindState;
|
|
2197
|
-
private syncState;
|
|
2198
|
-
private renderItems;
|
|
2199
|
-
private getPageItems;
|
|
2200
|
-
private isLocked;
|
|
2201
|
-
private isPrevDisabled;
|
|
2202
|
-
private isNextDisabled;
|
|
2203
|
-
private buildControlItem;
|
|
2204
|
-
private buildPageItem;
|
|
2205
|
-
private bindEvents;
|
|
2206
|
-
private unbindEvents;
|
|
2207
|
-
private unlock;
|
|
2208
|
-
private assertActive;
|
|
2209
|
-
protected normalizeStatePatch(patch: Partial<PaginationState>): Partial<PaginationState>;
|
|
2210
|
-
protected validateStatePatch(patch: Partial<PaginationState>): void;
|
|
2211
|
-
protected onDestroy(): void;
|
|
2212
|
-
}
|
|
2213
|
-
type Pagination = PaginationComponent;
|
|
1689
|
+
type Pagination = FunctionalComponent<ResolvedPaginationProps, PaginationState, HTMLElement, PaginationActions> & {
|
|
1690
|
+
readonly pageCount: number;
|
|
1691
|
+
};
|
|
2214
1692
|
declare function createPagination(input?: PaginationProps): Pagination;
|
|
2215
1693
|
//#endregion
|
|
2216
1694
|
//#region src/components/menu.d.ts
|
|
@@ -2253,39 +1731,9 @@ interface ResolvedMenuProps extends Record<string, unknown> {
|
|
|
2253
1731
|
}
|
|
2254
1732
|
interface MenuState extends Record<string, unknown> {
|
|
2255
1733
|
data: MenuItem[];
|
|
1734
|
+
activeKeys: string[];
|
|
2256
1735
|
}
|
|
2257
|
-
|
|
2258
|
-
root: HTMLElement | null;
|
|
2259
|
-
list: HTMLElement | null;
|
|
2260
|
-
}
|
|
2261
|
-
interface MenuRuntime extends ComponentRuntime {
|
|
2262
|
-
built: boolean;
|
|
2263
|
-
}
|
|
2264
|
-
interface MenuCleanupExtras {
|
|
2265
|
-
state?: (() => void) | null;
|
|
2266
|
-
}
|
|
2267
|
-
declare class MenuComponent extends Component<ResolvedMenuProps, MenuState, MenuDOM> {
|
|
2268
|
-
runtime: MenuRuntime;
|
|
2269
|
-
state: MenuState;
|
|
2270
|
-
cleanup: Component['cleanup'] & MenuCleanupExtras;
|
|
2271
|
-
constructor(input?: MenuProps);
|
|
2272
|
-
build(): this;
|
|
2273
|
-
private bindState;
|
|
2274
|
-
private renderSnapshot;
|
|
2275
|
-
private buildItem;
|
|
2276
|
-
private bindEvents;
|
|
2277
|
-
private unbindEvents;
|
|
2278
|
-
private handleMenuClick;
|
|
2279
|
-
private handleBack;
|
|
2280
|
-
private toggleActive;
|
|
2281
|
-
private clearActive;
|
|
2282
|
-
private validateData;
|
|
2283
|
-
private assertStatePatchKey;
|
|
2284
|
-
protected normalizeStatePatch(patch: Partial<MenuState>): Partial<MenuState>;
|
|
2285
|
-
protected validateStatePatch(patch: Partial<MenuState>): void;
|
|
2286
|
-
protected onDestroy(): void;
|
|
2287
|
-
}
|
|
2288
|
-
type Menu = MenuComponent;
|
|
1736
|
+
type Menu = FunctionalComponent<ResolvedMenuProps, MenuState, HTMLElement>;
|
|
2289
1737
|
declare function createMenu(input?: MenuProps): Menu;
|
|
2290
1738
|
//#endregion
|
|
2291
|
-
export { CleanupFunction,
|
|
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 };
|