@ibiz-template-plugin/ibiz-file-previewer 0.0.24 → 0.0.26
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/dist/index.es.js +331 -15
- package/dist/index.legacy.js +1 -1
- package/dist/polyfills.legacy.js +1 -1
- package/dist/types/src/const/type.d.ts +2 -0
- package/dist/types/src/controller/file-preview-item/file-preview-image-controller.d.ts +1 -1
- package/dist/types/src/controller/file-preview-item/file-preview-image-group-controller.d.ts +9 -2
- package/dist/types/src/controller/file-preview-item/file-preview-item-controller.d.ts +10 -1
- package/dist/types/src/controller/file-preview-shell-controller.d.ts +12 -0
- package/dist/types/src/interface/i-file-preview-item-controller.d.ts +9 -0
- package/dist/types/src/interface/i-file-preview-item-events.d.ts +9 -0
- package/dist/types/src/interface/i-file-preview-shell-controller.d.ts +5 -0
- package/dist/types/src/interface/i-file-previewer-option.d.ts +7 -0
- package/dist/types/src/interface/index.d.ts +1 -0
- package/dist/types/src/util/event-emitter.d.ts +31 -0
- package/dist/types/src/util/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ import { FilePreviewItemController } from './file-preview-item-controller';
|
|
|
4
4
|
/**
|
|
5
5
|
* 图片预览控制器
|
|
6
6
|
*/
|
|
7
|
-
export declare class FilePreviewImageController<S extends IFilePreviewImageState = IFilePreviewImageState> extends FilePreviewItemController<S> {
|
|
7
|
+
export declare class FilePreviewImageController<S extends IFilePreviewImageState = IFilePreviewImageState, E extends Record<string, any> = Record<string, any>> extends FilePreviewItemController<S, E> {
|
|
8
8
|
protected initState(): void;
|
|
9
9
|
/**
|
|
10
10
|
* 获取内容
|
package/dist/types/src/controller/file-preview-item/file-preview-image-group-controller.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IFilePreviewImageGroupState } from '../../interface';
|
|
1
|
+
import { IFilePreviewImageGroupEvents, IFilePreviewImageGroupState } from '../../interface';
|
|
2
2
|
import { FilePreviewImageController } from './file-preview-image-controller';
|
|
3
3
|
/**
|
|
4
4
|
* 图片组预览
|
|
5
5
|
*/
|
|
6
|
-
export declare class FilePreviewImageGroupController<S extends IFilePreviewImageGroupState = IFilePreviewImageGroupState> extends FilePreviewImageController<S> {
|
|
6
|
+
export declare class FilePreviewImageGroupController<S extends IFilePreviewImageGroupState = IFilePreviewImageGroupState, E extends Record<string, any> = IFilePreviewImageGroupEvents> extends FilePreviewImageController<S, E> {
|
|
7
7
|
protected initState(): void;
|
|
8
8
|
/**
|
|
9
9
|
* 获取内容
|
|
@@ -13,6 +13,13 @@ export declare class FilePreviewImageGroupController<S extends IFilePreviewImage
|
|
|
13
13
|
* 切换缩略图面板
|
|
14
14
|
*/
|
|
15
15
|
switchThumbnailPanel(): void;
|
|
16
|
+
/**
|
|
17
|
+
* 跳转至指定页(0-based)
|
|
18
|
+
* - 越界或内容未加载时静默忽略
|
|
19
|
+
* - 同步更新 currentPage,并派发 goToPage 事件由组件执行滚动
|
|
20
|
+
* @param page 目标页索引
|
|
21
|
+
*/
|
|
22
|
+
goToPage(page: number): void;
|
|
16
23
|
/**
|
|
17
24
|
* 处理旋转角度改变
|
|
18
25
|
* @param value
|
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
import { Signal } from '@preact/signals';
|
|
2
2
|
import { IFilePreviewItemState, IFilePreviewItemController, IFilePreviewShellController } from '../../interface';
|
|
3
|
+
import { EventEmitter } from '../../util';
|
|
3
4
|
/**
|
|
4
5
|
* 文件预览项控制器
|
|
5
6
|
*/
|
|
6
|
-
export declare class FilePreviewItemController<S extends IFilePreviewItemState = IFilePreviewItemState> implements IFilePreviewItemController {
|
|
7
|
+
export declare class FilePreviewItemController<S extends IFilePreviewItemState = IFilePreviewItemState, E extends Record<string, any> = Record<string, any>> implements IFilePreviewItemController {
|
|
7
8
|
filePreviewShell: IFilePreviewShellController;
|
|
8
9
|
/**
|
|
9
10
|
* 状态
|
|
10
11
|
*/
|
|
11
12
|
state: Signal<S>;
|
|
13
|
+
/**
|
|
14
|
+
* 事件对象,用于向组件派发瞬时动作事件
|
|
15
|
+
*/
|
|
16
|
+
events: EventEmitter<E>;
|
|
12
17
|
/**
|
|
13
18
|
* 构造函数
|
|
14
19
|
* @param filePreviewShell
|
|
15
20
|
*/
|
|
16
21
|
constructor(filePreviewShell: IFilePreviewShellController);
|
|
22
|
+
/**
|
|
23
|
+
* 工具栏容器唯一 id(代理自 shell controller)
|
|
24
|
+
*/
|
|
25
|
+
get controlsId(): string;
|
|
17
26
|
/**
|
|
18
27
|
* 更新状态
|
|
19
28
|
* - 所有的状态更新必须调用该方法,以便界面响应
|
|
@@ -18,6 +18,11 @@ export declare class FilePreviewShellController implements IFilePreviewShellCont
|
|
|
18
18
|
* 文件预览控制器
|
|
19
19
|
*/
|
|
20
20
|
preViewController: IFilePreviewItemController | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* 当前实例工具栏容器唯一 id(不带 #)
|
|
23
|
+
* - 构造时确定,生命周期内不变
|
|
24
|
+
*/
|
|
25
|
+
readonly controlsId: string;
|
|
21
26
|
/**
|
|
22
27
|
* 文件预览器状态对象
|
|
23
28
|
*/
|
|
@@ -94,4 +99,11 @@ export declare class FilePreviewShellController implements IFilePreviewShellCont
|
|
|
94
99
|
* @param engineType
|
|
95
100
|
*/
|
|
96
101
|
switchEngineType(engineType: EngineType): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* 跳转至目标页
|
|
104
|
+
* - 仅对图片组场景生效,其它场景忽略
|
|
105
|
+
* - 页码为 0-based
|
|
106
|
+
* @param page 目标页索引
|
|
107
|
+
*/
|
|
108
|
+
goToPage(page: number): void;
|
|
97
109
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'preact';
|
|
2
2
|
import { FileType, ImageMode } from '../const';
|
|
3
|
+
import { EventEmitter } from '../util';
|
|
3
4
|
import { IFilePreviewShellController } from './i-file-preview-shell-controller';
|
|
4
5
|
/**
|
|
5
6
|
* 文件预览项状态
|
|
@@ -84,6 +85,14 @@ export interface IFilePreviewItemController {
|
|
|
84
85
|
* 状态
|
|
85
86
|
*/
|
|
86
87
|
state: Record<string, any>;
|
|
88
|
+
/**
|
|
89
|
+
* 当前实例工具栏容器唯一 id(不带 #),由 shell controller 提供
|
|
90
|
+
*/
|
|
91
|
+
controlsId: string;
|
|
92
|
+
/**
|
|
93
|
+
* 事件对象,用于控制器向组件派发瞬时动作事件
|
|
94
|
+
*/
|
|
95
|
+
events: EventEmitter;
|
|
87
96
|
/**
|
|
88
97
|
* 初始化
|
|
89
98
|
*/
|
|
@@ -49,6 +49,11 @@ export interface IFilePreviewShellState {
|
|
|
49
49
|
* 文件预览壳控制器接口
|
|
50
50
|
*/
|
|
51
51
|
export interface IFilePreviewShellController {
|
|
52
|
+
/**
|
|
53
|
+
* 当前实例工具栏容器的唯一 DOM id(不带 #)
|
|
54
|
+
* - 供 shell 渲染容器 id,item 组件 Teleport 时拼接为选择器
|
|
55
|
+
*/
|
|
56
|
+
controlsId: string;
|
|
52
57
|
/**
|
|
53
58
|
* 更新视图
|
|
54
59
|
* @param data
|
|
@@ -123,6 +123,13 @@ export interface IFilePreviewerOption {
|
|
|
123
123
|
* @param type
|
|
124
124
|
*/
|
|
125
125
|
actionSuccessCallBack(type: string): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* 预览初始化完成回调
|
|
128
|
+
* - item 组件挂载完成、预览就绪时触发
|
|
129
|
+
* - 每次 updateView 或 switchEngineType 后的预览就绪都会触发
|
|
130
|
+
* - 需要当前预览详情时,在回调内调用 shellController.getState() 获取
|
|
131
|
+
*/
|
|
132
|
+
onInitialized?: () => void;
|
|
126
133
|
}
|
|
127
134
|
/**
|
|
128
135
|
* 文件预览组件配置项
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { IFilePreviewerData, IFilePreviewerOption, } from './i-file-previewer-option';
|
|
2
2
|
export type { IFilePreviewShellState, IFilePreviewShellController, } from './i-file-preview-shell-controller';
|
|
3
3
|
export type { PreviewItemComponent, IFilePreviewItemState, IFilePreviewImageState, IFilePreviewImageGroupState, IFilePreviewItemController, IFilePreviewItemConstructor, } from './i-file-preview-item-controller';
|
|
4
|
+
export type { IFilePreviewImageGroupEvents } from './i-file-preview-item-events';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事件处理函数
|
|
3
|
+
*/
|
|
4
|
+
type EventHandler<T = any> = (payload: T) => void;
|
|
5
|
+
/**
|
|
6
|
+
* 极简类型安全事件发射器
|
|
7
|
+
* - on 返回 unsubscribe 函数,便于在 useEffect 中直接 return 清理
|
|
8
|
+
*/
|
|
9
|
+
export declare class EventEmitter<E extends Record<string, any> = Record<string, any>> {
|
|
10
|
+
private handlers;
|
|
11
|
+
/**
|
|
12
|
+
* 订阅事件
|
|
13
|
+
* @param event 事件名
|
|
14
|
+
* @param handler 处理函数
|
|
15
|
+
* @returns 取消订阅函数
|
|
16
|
+
*/
|
|
17
|
+
on<K extends keyof E>(event: K, handler: EventHandler<E[K]>): () => void;
|
|
18
|
+
/**
|
|
19
|
+
* 取消订阅事件
|
|
20
|
+
* @param event 事件名
|
|
21
|
+
* @param handler 处理函数
|
|
22
|
+
*/
|
|
23
|
+
off<K extends keyof E>(event: K, handler: EventHandler<E[K]>): void;
|
|
24
|
+
/**
|
|
25
|
+
* 派发事件
|
|
26
|
+
* @param event 事件名
|
|
27
|
+
* @param payload 载荷
|
|
28
|
+
*/
|
|
29
|
+
emit<K extends keyof E>(event: K, payload: E[K]): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|