jsbox-cview 1.6.6 → 1.6.8
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 +4 -0
- package/dist/components/alert/input-alert.d.ts +22 -0
- package/dist/components/alert/login-alert.d.ts +21 -0
- package/dist/components/alert/plain-alert.d.ts +15 -0
- package/dist/components/alert/uialert.d.ts +29 -0
- package/{components/base.ts → dist/components/base.d.ts} +9 -28
- package/dist/components/custom-navigation-bar.d.ts +117 -0
- package/dist/components/dialogs/dialog-sheet.d.ts +46 -0
- package/dist/components/dialogs/dialog-sheet.js +4 -2
- package/dist/components/dialogs/form-dialog.d.ts +15 -0
- package/dist/components/dialogs/list-dialog.d.ts +23 -0
- package/dist/components/dialogs/list-dialog.js +1 -1
- package/dist/components/dialogs/text-dialog.d.ts +13 -0
- package/dist/components/dynamic-contextmenu-view.d.ts +40 -0
- package/dist/components/dynamic-itemsize-matrix.d.ts +79 -0
- package/dist/components/dynamic-itemsize-matrix.js +1 -0
- package/dist/components/dynamic-itemsize-section-matrix.d.ts +115 -0
- package/dist/components/dynamic-preference-listview.d.ts +63 -0
- package/dist/components/dynamic-rowheight-list.d.ts +38 -0
- package/dist/components/enhanced-imageview.d.ts +41 -0
- package/dist/components/flowlayout.d.ts +63 -0
- package/dist/components/image-pager.d.ts +49 -0
- package/dist/components/oc-webview.d.ts +64 -0
- package/dist/components/page-control.d.ts +45 -0
- package/dist/components/pageviewer-titlebar.d.ts +48 -0
- package/dist/components/pageviewer.d.ts +41 -0
- package/dist/components/pageviewer.js +12 -3
- package/dist/components/refresh-button.d.ts +25 -0
- package/dist/components/rotating-view.d.ts +45 -0
- package/dist/components/searchbar.d.ts +118 -0
- package/dist/components/sheet.d.ts +42 -0
- package/dist/components/single-views.d.ts +289 -0
- package/dist/components/spinners/loading-dual-ring.d.ts +18 -0
- package/dist/components/spinners/loading-wedges.d.ts +15 -0
- package/dist/components/spinners/spinner-androidstyle.d.ts +30 -0
- package/dist/components/static-preference-listview.d.ts +389 -0
- package/dist/components/symbol-button.d.ts +39 -0
- package/dist/components/tabbar.d.ts +140 -0
- package/dist/controller/base-controller.d.ts +108 -0
- package/dist/controller/base-controller.js +10 -25
- package/dist/controller/controller-router.d.ts +48 -0
- package/dist/controller/controller-router.js +2 -1
- package/dist/controller/controller-status.d.ts +16 -0
- package/dist/controller/controller-status.js +19 -0
- package/dist/controller/pageviewer-controller.d.ts +38 -0
- package/dist/controller/pageviewer-controller.js +32 -3
- package/dist/controller/presented-page-controller.d.ts +41 -0
- package/dist/controller/splitview-controller.d.ts +90 -0
- package/dist/controller/splitview-controller.js +5 -0
- package/dist/controller/tabbar-controller.d.ts +49 -0
- package/dist/controller/tabbar-controller.js +2 -3
- package/{index.ts → dist/index.d.ts} +2 -0
- package/dist/index.js +2 -0
- package/dist/utils/colors.d.ts +7 -0
- package/dist/utils/cvid.d.ts +11 -0
- package/dist/utils/l10n.d.ts +1 -0
- package/dist/utils/path.d.ts +8 -0
- package/dist/utils/rect.d.ts +38 -0
- package/dist/utils/uitools.d.ts +75 -0
- package/package.json +20 -6
- package/.prettierignore +0 -6
- package/.prettierrc +0 -3
- package/components/alert/input-alert.ts +0 -64
- package/components/alert/login-alert.ts +0 -66
- package/components/alert/plain-alert.ts +0 -39
- package/components/alert/uialert.ts +0 -107
- package/components/custom-navigation-bar.ts +0 -579
- package/components/dialogs/dialog-sheet.ts +0 -111
- package/components/dialogs/form-dialog.ts +0 -63
- package/components/dialogs/list-dialog.ts +0 -119
- package/components/dialogs/text-dialog.ts +0 -44
- package/components/dynamic-contextmenu-view.ts +0 -115
- package/components/dynamic-itemsize-matrix.ts +0 -206
- package/components/dynamic-itemsize-section-matrix.ts +0 -363
- package/components/dynamic-preference-listview.ts +0 -684
- package/components/dynamic-rowheight-list.ts +0 -77
- package/components/enhanced-imageview.ts +0 -132
- package/components/flowlayout.ts +0 -248
- package/components/image-pager.ts +0 -180
- package/components/oc-webview.ts +0 -177
- package/components/page-control.ts +0 -93
- package/components/pageviewer-titlebar.ts +0 -166
- package/components/pageviewer.ts +0 -125
- package/components/refresh-button.ts +0 -83
- package/components/rotating-view.ts +0 -133
- package/components/searchbar.ts +0 -398
- package/components/sheet.ts +0 -104
- package/components/single-views.ts +0 -956
- package/components/spinners/loading-dual-ring.ts +0 -97
- package/components/spinners/loading-wedges.ts +0 -106
- package/components/spinners/spinner-androidstyle.ts +0 -269
- package/components/static-preference-listview.ts +0 -1282
- package/components/symbol-button.ts +0 -108
- package/components/tabbar.ts +0 -453
- package/controller/base-controller.ts +0 -214
- package/controller/controller-router.ts +0 -73
- package/controller/pageviewer-controller.ts +0 -93
- package/controller/presented-page-controller.ts +0 -76
- package/controller/splitview-controller.ts +0 -359
- package/controller/tabbar-controller.ts +0 -131
- package/dist/test/custom-navigation-bar.js +0 -40
- package/dist/test/dialog-sheet.js +0 -40
- package/dist/test/dynamic-contextmenu-view.js +0 -66
- package/dist/test/dynamic-itemsize-matrix.js +0 -74
- package/dist/test/dynamic-itemsize-section-matrix.js +0 -138
- package/dist/test/dynamic-preference-listview.js +0 -150
- package/dist/test/flowlayout.js +0 -76
- package/dist/test/form-dialog.js +0 -51
- package/dist/test/oc-webview.js +0 -195
- package/dist/test/pageviewer-controller.js +0 -20
- package/dist/test/pageviewer-titlebar.js +0 -18
- package/dist/test/pageviewer.js +0 -32
- package/dist/test/refresh-button.js +0 -26
- package/dist/test/searchbar.js +0 -36
- package/dist/test/splitview-controller.js +0 -41
- package/dist/test/static-preference-listview.js +0 -143
- package/dist/test/tabbar-controller.js +0 -48
- package/test/custom-navigation-bar.ts +0 -40
- package/test/dialog-sheet.ts +0 -40
- package/test/dynamic-contextmenu-view.ts +0 -67
- package/test/dynamic-itemsize-matrix.ts +0 -74
- package/test/dynamic-itemsize-section-matrix.ts +0 -142
- package/test/dynamic-preference-listview.ts +0 -151
- package/test/flowlayout.ts +0 -79
- package/test/form-dialog.ts +0 -48
- package/test/oc-webview.ts +0 -197
- package/test/pageviewer-controller.ts +0 -21
- package/test/pageviewer-titlebar.ts +0 -18
- package/test/pageviewer.ts +0 -31
- package/test/refresh-button.ts +0 -26
- package/test/searchbar.ts +0 -38
- package/test/splitview-controller.ts +0 -42
- package/test/static-preference-listview.ts +0 -142
- package/test/tabbar-controller.ts +0 -49
- package/tsconfig.json +0 -122
- package/utils/colors.ts +0 -17
- package/utils/cvid.ts +0 -32
- package/utils/l10n.ts +0 -42
- package/utils/path.ts +0 -97
- package/utils/rect.ts +0 -90
- package/utils/uitools.ts +0 -122
package/README.md
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 显示一个输入框提示
|
|
3
|
+
*
|
|
4
|
+
* @param title 标题
|
|
5
|
+
* @param message 内容
|
|
6
|
+
* @param text 输入框默认文字
|
|
7
|
+
* @param placeholder 输入框占位符
|
|
8
|
+
* @param type 输入框类型
|
|
9
|
+
* @param secure 是否安全输入
|
|
10
|
+
* @param cancelText 取消按钮文字
|
|
11
|
+
* @param confirmText 确认按钮文字
|
|
12
|
+
*/
|
|
13
|
+
export declare function inputAlert({ title, message, text, placeholder, type, secure, cancelText, confirmText, }: {
|
|
14
|
+
title?: string;
|
|
15
|
+
message?: string;
|
|
16
|
+
text?: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
type?: number;
|
|
19
|
+
secure?: boolean;
|
|
20
|
+
cancelText?: string;
|
|
21
|
+
confirmText?: string;
|
|
22
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 显示一个登录输入框提示
|
|
3
|
+
*
|
|
4
|
+
* @param title 标题
|
|
5
|
+
* @param message 内容
|
|
6
|
+
* @param placeholder1 输入框1的占位符
|
|
7
|
+
* @param placeholder2 输入框2的占位符
|
|
8
|
+
* @param cancelText 取消按钮文字
|
|
9
|
+
* @param confirmText 确认按钮文字
|
|
10
|
+
*/
|
|
11
|
+
export declare function loginAlert({ title, message, placeholder1, placeholder2, cancelText, confirmText, }?: {
|
|
12
|
+
title?: string;
|
|
13
|
+
message?: string;
|
|
14
|
+
placeholder1?: string;
|
|
15
|
+
placeholder2?: string;
|
|
16
|
+
cancelText?: string;
|
|
17
|
+
confirmText?: string;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
username: string;
|
|
20
|
+
password: string;
|
|
21
|
+
}>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 显示一个文字提示
|
|
3
|
+
*
|
|
4
|
+
* @param title 标题
|
|
5
|
+
* @param message 内容
|
|
6
|
+
* @param cancelText 取消按钮文字
|
|
7
|
+
* @param confirmText 确认按钮文字
|
|
8
|
+
* @returns Promise
|
|
9
|
+
*/
|
|
10
|
+
export declare function plainAlert({ title, message, cancelText, confirmText, }?: {
|
|
11
|
+
title?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
cancelText?: string;
|
|
14
|
+
confirmText?: string;
|
|
15
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const UIAlertActionStyle: {
|
|
2
|
+
Default: number;
|
|
3
|
+
Cancel: number;
|
|
4
|
+
Destructive: number;
|
|
5
|
+
};
|
|
6
|
+
export declare const UIAlertControllerStyle: {
|
|
7
|
+
ActionSheet: number;
|
|
8
|
+
Alert: number;
|
|
9
|
+
};
|
|
10
|
+
export declare class UIAlertAction {
|
|
11
|
+
title: string;
|
|
12
|
+
style: number;
|
|
13
|
+
instance: any;
|
|
14
|
+
constructor(title: string, style: number | undefined, handler: Function);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Alert的基础类
|
|
18
|
+
*/
|
|
19
|
+
export declare class UIAlertController {
|
|
20
|
+
title: string;
|
|
21
|
+
message: string;
|
|
22
|
+
style: number;
|
|
23
|
+
instance: any;
|
|
24
|
+
constructor(title: string, message: string, style?: number);
|
|
25
|
+
addAction(action: UIAlertAction): void;
|
|
26
|
+
addTextField(options: any): void;
|
|
27
|
+
getText(index: number): any;
|
|
28
|
+
present(): void;
|
|
29
|
+
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { cvid } from "../utils/cvid";
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
*
|
|
5
3
|
* 组件 Base 基类,用于创建自定义组件。CView 的所有子类都应该继承自 Base。
|
|
@@ -18,30 +16,13 @@ import { cvid } from "../utils/cvid";
|
|
|
18
16
|
* - 通过组件化的方式,将JSBox view的定义和实例绑定,使用起来更加方便
|
|
19
17
|
* - 可以便利地创建自定义组件
|
|
20
18
|
*/
|
|
21
|
-
export abstract class Base<T extends AllUIView, R extends UiTypes.AllViewOptions> {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
get definition() {
|
|
32
|
-
return this._defineView();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
get view() {
|
|
36
|
-
if (!this._view) this._view = $(this.id) as T;
|
|
37
|
-
return this._view;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
add(view: UiTypes.AllViewOptions | Base<any, any>) {
|
|
41
|
-
if (view instanceof Base) {
|
|
42
|
-
this.view.add(view.definition);
|
|
43
|
-
} else {
|
|
44
|
-
this.view.add(view);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
19
|
+
export declare abstract class Base<T extends AllUIView, R extends UiTypes.AllViewOptions> {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
private _view?;
|
|
22
|
+
abstract _defineView: () => R;
|
|
23
|
+
_layout?: (make: MASConstraintMaker, view: T) => void;
|
|
24
|
+
constructor();
|
|
25
|
+
get definition(): R;
|
|
26
|
+
get view(): T;
|
|
27
|
+
add(view: UiTypes.AllViewOptions | Base<any, any>): void;
|
|
47
28
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Base } from "./base";
|
|
2
|
+
import { ContentView, Label, Button, Blur } from "./single-views";
|
|
3
|
+
export interface NavigationBarProps {
|
|
4
|
+
style: number;
|
|
5
|
+
title?: string;
|
|
6
|
+
titleView?: Base<any, any>;
|
|
7
|
+
popButtonEnabled?: boolean;
|
|
8
|
+
popButtonTitle?: string;
|
|
9
|
+
popToRootEnabled?: boolean;
|
|
10
|
+
leftBarButtonItems: BarButtonItem[];
|
|
11
|
+
rightBarButtonItems: BarButtonItem[];
|
|
12
|
+
toolView?: Base<any, any>;
|
|
13
|
+
tintColor: UIColor;
|
|
14
|
+
bgcolor?: UIColor;
|
|
15
|
+
}
|
|
16
|
+
interface BarButtonItem {
|
|
17
|
+
cview?: Base<any, any>;
|
|
18
|
+
width?: number;
|
|
19
|
+
title?: string;
|
|
20
|
+
symbol?: string;
|
|
21
|
+
image?: UIImage;
|
|
22
|
+
tintColor?: UIColor;
|
|
23
|
+
handler?: (sender: UIButtonView) => void;
|
|
24
|
+
}
|
|
25
|
+
interface NavigationBarEvents {
|
|
26
|
+
hidden?: (cview: CustomNavigationBar) => void;
|
|
27
|
+
minimized?: (cview: CustomNavigationBar) => void;
|
|
28
|
+
restored?: (cview: CustomNavigationBar) => void;
|
|
29
|
+
expanded?: (cview: CustomNavigationBar) => void;
|
|
30
|
+
popHandler?: (cview: CustomNavigationBar) => void;
|
|
31
|
+
popToRootHandler?: (cview: CustomNavigationBar) => void;
|
|
32
|
+
titleTapped?: (cview: CustomNavigationBar) => void;
|
|
33
|
+
}
|
|
34
|
+
interface NavigationBarCViews {
|
|
35
|
+
leftItemView?: ContentView | Button;
|
|
36
|
+
rightItemView?: ContentView;
|
|
37
|
+
titleViewWrapper?: ContentView | Label;
|
|
38
|
+
contentView?: ContentView;
|
|
39
|
+
toolViewWrapper?: ContentView;
|
|
40
|
+
bgview?: ContentView | Blur;
|
|
41
|
+
separator?: ContentView;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* # CView Custom NavigationBar
|
|
45
|
+
*
|
|
46
|
+
* 仿制 navBar
|
|
47
|
+
*
|
|
48
|
+
* ## features:
|
|
49
|
+
*
|
|
50
|
+
* - 拥有隐藏、最小化、普通、扩展四种布局方式
|
|
51
|
+
* - 隐藏: 什么都不显示
|
|
52
|
+
* - 最小化: safeAreaHeight 为 25, 只显示 titleView, 若用 title, font 为\$font(14)
|
|
53
|
+
* - 普通: safeAreaHeight 为 50, 显示 titleView, leftBarButtonItems 或 popButton,
|
|
54
|
+
* rightBarButtonItems, 若用 title, font 为\$font("bold", 17)
|
|
55
|
+
* - 扩展: safeAreaHeight 为 100, 除上面的之外, 再显示一个 toolView
|
|
56
|
+
* - 自动适应全面屏和非全面屏
|
|
57
|
+
*
|
|
58
|
+
* ## Arguments
|
|
59
|
+
*
|
|
60
|
+
* props:
|
|
61
|
+
*
|
|
62
|
+
* - 读写 style: number 0, 1, 2, 3,指定布局
|
|
63
|
+
* - 读写 title: string 但必须使用此种方案才可以在生成后写入,自动创建 Label 作为 titleView
|
|
64
|
+
* - titleView: cview 自定义的 titleView
|
|
65
|
+
* - popButtonEnabled: boolean 返回上一级的按钮,若为 true,则 leftBarButtonItems 忽略
|
|
66
|
+
* - popButtonTitle: string 返回上一级的按钮标题
|
|
67
|
+
* - popToRootEnabled: boolean popButton 是否可以长按返回到顶级
|
|
68
|
+
* - leftBarButtonItems: cview[]
|
|
69
|
+
* | {symbol: string, handler: () => void, tintColor?: UIColor}[]
|
|
70
|
+
* | {title: string, handler: () => void, tintColor?: UIColor}[]
|
|
71
|
+
* | {image: UIImage, handler: () => void, tintColor?: UIColor}[]
|
|
72
|
+
* 如果用的是 cview,其布局将被重新指定,即不需要(也不能)指定布局。
|
|
73
|
+
* 可以通过 cview.width 来指定应有的宽度,如果没有此属性,则宽度为 50
|
|
74
|
+
* 建议最多放两个
|
|
75
|
+
* - rightBarButtonItems 定义同上,建议最多放两个
|
|
76
|
+
* - toolView: cview 在 expanded 模式下才会显现的
|
|
77
|
+
* - tintColor: UIColor 这将作用于 title, popButton, 自动创建的 barButton
|
|
78
|
+
* - bgcolor: UIColor 如不设置,则自动使用 blur(style 10),如果设置则没有 blur 效果
|
|
79
|
+
*
|
|
80
|
+
* events:
|
|
81
|
+
*
|
|
82
|
+
* - hidden: cview => void hide()时执行
|
|
83
|
+
* - minimized: cview => void minimize()时执行
|
|
84
|
+
* - restored: cview => void restore()时执行
|
|
85
|
+
* - expanded: cview => void expand()时执行
|
|
86
|
+
* - popHandler: cview => void 返回上一级时执行,需要popButtonEnabled
|
|
87
|
+
* - popToRootHandler: cview => void 返回顶级时执行,需要popButtonEnabled和popToRootEnabled
|
|
88
|
+
* - titleTapped: cview => void 点击标题时执行,需要使用title
|
|
89
|
+
*
|
|
90
|
+
* methods:
|
|
91
|
+
*
|
|
92
|
+
* - hide() 隐藏布局
|
|
93
|
+
* - minimize() 最小化布局
|
|
94
|
+
* - restore() 普通布局
|
|
95
|
+
* - expand() 扩展布局
|
|
96
|
+
*/
|
|
97
|
+
export declare class CustomNavigationBar extends Base<UIView | UIBlurView, UiTypes.ViewOptions | UiTypes.BlurOptions> {
|
|
98
|
+
_props: NavigationBarProps;
|
|
99
|
+
_events: NavigationBarEvents;
|
|
100
|
+
cviews: Required<NavigationBarCViews>;
|
|
101
|
+
_defineView: () => UiTypes.ViewOptions | UiTypes.BlurOptions;
|
|
102
|
+
constructor({ props, events, }?: {
|
|
103
|
+
props?: Partial<NavigationBarProps>;
|
|
104
|
+
events?: NavigationBarEvents;
|
|
105
|
+
});
|
|
106
|
+
private _calculateItemViewWidth;
|
|
107
|
+
private _createCviewsOnItemView;
|
|
108
|
+
get title(): string;
|
|
109
|
+
set title(title: string);
|
|
110
|
+
hide(animated?: boolean): void;
|
|
111
|
+
minimize(animated?: boolean): void;
|
|
112
|
+
restore(animated?: boolean): void;
|
|
113
|
+
expand(animated?: boolean): void;
|
|
114
|
+
get style(): number;
|
|
115
|
+
set style(num: number);
|
|
116
|
+
}
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Sheet } from "../sheet";
|
|
2
|
+
import { ContentView } from "../single-views";
|
|
3
|
+
import { Base } from "../base";
|
|
4
|
+
/**
|
|
5
|
+
* dialog所需要的sheet
|
|
6
|
+
*
|
|
7
|
+
* @param title 标题
|
|
8
|
+
* @param cview 内容视图
|
|
9
|
+
* @param doneHandler 完成时的回调
|
|
10
|
+
* @param presentMode 显示模式
|
|
11
|
+
* @param bgcolor 背景颜色
|
|
12
|
+
* @param doneButtonHidden 是否隐藏完成按钮, 默认为false,如果隐藏则需要自行实现完成逻辑
|
|
13
|
+
* @param doneButtonValidator 完成按钮验证器,返回true则执行完成逻辑,返回false则不执行
|
|
14
|
+
* @param doneButtonTitle 完成按钮标题,默认为"完成"
|
|
15
|
+
*/
|
|
16
|
+
export declare class DialogSheet extends Sheet<ContentView, UIView, UiTypes.ViewOptions> {
|
|
17
|
+
_props: {
|
|
18
|
+
title: string;
|
|
19
|
+
cview: Base<any, any>;
|
|
20
|
+
doneHandler?: () => any;
|
|
21
|
+
presentMode?: number;
|
|
22
|
+
bgcolor?: UIColor;
|
|
23
|
+
doneButtonHidden?: boolean;
|
|
24
|
+
doneButtonValidator?: () => boolean;
|
|
25
|
+
doneButtonTitle?: string;
|
|
26
|
+
};
|
|
27
|
+
_done: boolean;
|
|
28
|
+
private _navbar?;
|
|
29
|
+
resolve?: (value: any) => void;
|
|
30
|
+
reject?: (reason: any) => void;
|
|
31
|
+
constructor(props: {
|
|
32
|
+
title: string;
|
|
33
|
+
cview: Base<any, any>;
|
|
34
|
+
doneHandler?: () => any;
|
|
35
|
+
presentMode?: number;
|
|
36
|
+
bgcolor?: UIColor;
|
|
37
|
+
doneButtonHidden?: boolean;
|
|
38
|
+
doneButtonValidator?: () => boolean;
|
|
39
|
+
doneButtonTitle?: string;
|
|
40
|
+
});
|
|
41
|
+
promisify(resolve: (value: any) => void, reject: (reason: any) => void): void;
|
|
42
|
+
present(): void;
|
|
43
|
+
done(): void;
|
|
44
|
+
get title(): string;
|
|
45
|
+
set title(title: string);
|
|
46
|
+
}
|
|
@@ -20,7 +20,7 @@ const single_views_1 = require("../single-views");
|
|
|
20
20
|
class DialogSheet extends sheet_1.Sheet {
|
|
21
21
|
constructor(props) {
|
|
22
22
|
super({
|
|
23
|
-
presentMode: props.presentMode
|
|
23
|
+
presentMode: props.presentMode ?? ($device.isIpad ? 2 : 1),
|
|
24
24
|
bgcolor: props.bgcolor,
|
|
25
25
|
});
|
|
26
26
|
this._props = props;
|
|
@@ -53,7 +53,9 @@ class DialogSheet extends sheet_1.Sheet {
|
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
else {
|
|
57
|
+
this.done();
|
|
58
|
+
}
|
|
57
59
|
},
|
|
58
60
|
},
|
|
59
61
|
],
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PreferenceSection } from "../static-preference-listview";
|
|
2
|
+
/**
|
|
3
|
+
* 显示一个表单
|
|
4
|
+
* @param sections 表单分组, 请参考`PreferenceListView`中的`PreferenceSection`
|
|
5
|
+
* @param title 标题
|
|
6
|
+
*/
|
|
7
|
+
export declare function formDialog({ sections, title, checkHandler, }: {
|
|
8
|
+
sections: PreferenceSection[];
|
|
9
|
+
title: string;
|
|
10
|
+
checkHandler?: (values: {
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}) => boolean;
|
|
13
|
+
}): Promise<{
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 显示一个列表以供选择
|
|
3
|
+
*
|
|
4
|
+
* @param items 选项
|
|
5
|
+
* @param multiSelectEnabled 是否允许多选
|
|
6
|
+
* @param value 默认选中的选项
|
|
7
|
+
* @param values 默认选中的选项, 配合multiSelectEnabled使用
|
|
8
|
+
* @param title 标题
|
|
9
|
+
*/
|
|
10
|
+
export declare function listDialog({ items, multiSelectEnabled, value, values, title, }: {
|
|
11
|
+
items: string[];
|
|
12
|
+
multiSelectEnabled: true;
|
|
13
|
+
value?: never;
|
|
14
|
+
values?: number[];
|
|
15
|
+
title: string;
|
|
16
|
+
}): Promise<number[]>;
|
|
17
|
+
export declare function listDialog({ items, multiSelectEnabled, value, values, title, }: {
|
|
18
|
+
items: string[];
|
|
19
|
+
multiSelectEnabled?: false | undefined;
|
|
20
|
+
value?: number;
|
|
21
|
+
values?: never;
|
|
22
|
+
title: string;
|
|
23
|
+
}): Promise<number>;
|
|
@@ -4,7 +4,7 @@ exports.listDialog = listDialog;
|
|
|
4
4
|
const dialog_sheet_1 = require("./dialog-sheet");
|
|
5
5
|
const single_views_1 = require("../single-views");
|
|
6
6
|
function listDialog({ items, multiSelectEnabled, value, values = [], title, }) {
|
|
7
|
-
if (value)
|
|
7
|
+
if (value !== undefined)
|
|
8
8
|
values = [value];
|
|
9
9
|
const listView = new single_views_1.List({
|
|
10
10
|
props: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 返回一个Promise用于输入文本
|
|
3
|
+
* @param title 标题
|
|
4
|
+
* @param text 初始文本
|
|
5
|
+
* @param placeholder 占位符
|
|
6
|
+
* @param editable 是否可编辑
|
|
7
|
+
*/
|
|
8
|
+
export declare function textDialog({ title, text, placeholder, editable, }: {
|
|
9
|
+
title: string;
|
|
10
|
+
text?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
editable?: boolean;
|
|
13
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Base } from "./base";
|
|
2
|
+
type MenuItem = {
|
|
3
|
+
title: string;
|
|
4
|
+
symbol?: string;
|
|
5
|
+
handler: () => void;
|
|
6
|
+
destructive?: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 动态上下文菜单视图,此视图是为了弥补JSBox中无法动态调整上下文菜单的缺陷而设计的。
|
|
10
|
+
*
|
|
11
|
+
* 此视图除了一般UIView的props, layout, events, views四个参数外,还有必须的特殊参数:
|
|
12
|
+
* 1. classname?: string OC类名,如果不指定则会自动生成一个唯一的类名。
|
|
13
|
+
* 如果有不同的DynamicContextMenuView实例使用相同的OC类,
|
|
14
|
+
* 那么无法确定弹出的contextMenu是绑定了哪个实例。
|
|
15
|
+
* 换言之,实例A弹出的Menu可能是绑定的实例B。
|
|
16
|
+
* 如果这样做,必须使用下面generateContextMenu的sender参数来定位。
|
|
17
|
+
* 2. generateContextMenu: (sender: UIView) => { title: string; items: MenuItem[]; }
|
|
18
|
+
* 生成上下文菜单的回调函数。
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export declare class DynamicContextMenuView extends Base<UIView, UiTypes.RuntimeOptions> {
|
|
22
|
+
private generateContextMenu;
|
|
23
|
+
private _ocClassName;
|
|
24
|
+
_defineView: () => UiTypes.RuntimeOptions;
|
|
25
|
+
constructor({ classname, generateContextMenu, props, layout, events, views, }: {
|
|
26
|
+
classname?: string;
|
|
27
|
+
generateContextMenu: (sender: UIView) => {
|
|
28
|
+
title?: string;
|
|
29
|
+
items: MenuItem[];
|
|
30
|
+
};
|
|
31
|
+
props: UiTypes.ViewProps;
|
|
32
|
+
layout?: (make: MASConstraintMaker, view: UIView) => void;
|
|
33
|
+
events?: UiTypes.BaseViewEvents;
|
|
34
|
+
views?: UiTypes.AllViewOptions[];
|
|
35
|
+
});
|
|
36
|
+
private defineOCClass;
|
|
37
|
+
private createContextMenuConfiguration;
|
|
38
|
+
private createRuntimeView;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Base } from "./base";
|
|
2
|
+
import { Matrix } from "./single-views";
|
|
3
|
+
interface DynamicItemSizeMatrixEvents extends UiTypes.MatrixEvents {
|
|
4
|
+
itemHeight?: (width: number) => number;
|
|
5
|
+
heightChanged?: (sender: DynamicItemSizeMatrix, height: number) => void;
|
|
6
|
+
}
|
|
7
|
+
interface DynamicItemSizeMatrixPropsPartial extends UiTypes.MatrixProps {
|
|
8
|
+
fixedItemHeight?: number;
|
|
9
|
+
minItemWidth?: number;
|
|
10
|
+
maxColumns?: number;
|
|
11
|
+
spacing?: number;
|
|
12
|
+
dynamicHeightEnabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* # CView Dynamic ItemSize Matrix
|
|
16
|
+
*
|
|
17
|
+
* 此组件是为了解决让 Matrix 的 ItemSize 跟随重新布局而动态变化的问题
|
|
18
|
+
*
|
|
19
|
+
* 动态的改变自己的 itemSize,从而使得 spacing 被优先满足。
|
|
20
|
+
* 思路为在 matrix 上层套一个 superView,在旋转的时候 superView 会调用 matrix.relayout()
|
|
21
|
+
* 和 matrix.reload(),从而触发 itemSize 事件
|
|
22
|
+
*
|
|
23
|
+
* 此视图的高度可以自动调整,需要 dynamicHeightEnabled 设为 true,且 layout 中要有关于 height 的约束
|
|
24
|
+
*
|
|
25
|
+
* 其排布逻辑是这样的:
|
|
26
|
+
*
|
|
27
|
+
* 1. 由 minItemWidth,spacing,maxColumns 这三个参数决定 cloumns,
|
|
28
|
+
* 并结合 totalWidth 确定 itemSize.width
|
|
29
|
+
* 2. 确定 itemHeight 有两种方法:
|
|
30
|
+
* - fixedItemHeight 固定高度,优先级第二
|
|
31
|
+
* - event: itemHeight(width) => height 通过 width 动态计算,优先级最高
|
|
32
|
+
* 3. 如果 minItemWidth 比 totalWidth - 2 * spacing 还要小,那么 itemSize.width
|
|
33
|
+
* 会被设定为 totalWidth - 2 * spacing,以保证item不会超出边框
|
|
34
|
+
*
|
|
35
|
+
* props:
|
|
36
|
+
*
|
|
37
|
+
* 可以使用 matrix 的全部属性
|
|
38
|
+
*
|
|
39
|
+
* 特殊属性:
|
|
40
|
+
*
|
|
41
|
+
* - fixedItemHeight 固定 itemSize 高度
|
|
42
|
+
* - minItemWidth 最小的 itemSize 宽度
|
|
43
|
+
* - maxColumns 最大列数
|
|
44
|
+
* - spacing
|
|
45
|
+
* - dynamicHeightEnabled 此项为 true,那么 scrollEnabled 自动设为 false,且高度可以自动调整
|
|
46
|
+
*
|
|
47
|
+
* events:
|
|
48
|
+
*
|
|
49
|
+
* 可以使用 matrix 除 itemSize 以外的全部事件
|
|
50
|
+
*
|
|
51
|
+
* 其他特殊事件:
|
|
52
|
+
*
|
|
53
|
+
* - itemHeight: width => height 通过 itemWidth 动态计算 itemHeight
|
|
54
|
+
*
|
|
55
|
+
*
|
|
56
|
+
* 方法:
|
|
57
|
+
* - heightToWidth(width) 计算特定width时的应有的高度
|
|
58
|
+
*/
|
|
59
|
+
export declare class DynamicItemSizeMatrix extends Base<UIView, UiTypes.ViewOptions> {
|
|
60
|
+
private _props;
|
|
61
|
+
private _events;
|
|
62
|
+
private _itemSizeWidth;
|
|
63
|
+
private _itemSizeHeight;
|
|
64
|
+
private _totalWidth;
|
|
65
|
+
private _columns;
|
|
66
|
+
matrix: Matrix;
|
|
67
|
+
_defineView: () => UiTypes.ViewOptions;
|
|
68
|
+
constructor({ props, layout, events, }: {
|
|
69
|
+
props: DynamicItemSizeMatrixPropsPartial;
|
|
70
|
+
layout: (make: MASConstraintMaker, view: UIView) => void;
|
|
71
|
+
events: DynamicItemSizeMatrixEvents;
|
|
72
|
+
});
|
|
73
|
+
heightToWidth(width: number): number;
|
|
74
|
+
get data(): any;
|
|
75
|
+
set data(data: any);
|
|
76
|
+
get columns(): number;
|
|
77
|
+
get itemSize(): JBSize;
|
|
78
|
+
}
|
|
79
|
+
export {};
|
|
@@ -104,6 +104,7 @@ class DynamicItemSizeMatrix extends base_1.Base {
|
|
|
104
104
|
sender.relayout();
|
|
105
105
|
if (sender.frame.width === this._totalWidth)
|
|
106
106
|
return;
|
|
107
|
+
this._totalWidth = sender.frame.width;
|
|
107
108
|
const { columns, itemSizeWidth } = _getColumnsAndItemSizeWidth(sender.frame.width, this._props.minItemWidth, this._props.maxColumns, this._props.spacing);
|
|
108
109
|
this._columns = columns;
|
|
109
110
|
this._itemSizeWidth = itemSizeWidth;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Base } from "./base";
|
|
2
|
+
import { Matrix } from "./single-views";
|
|
3
|
+
export interface DynamicItemSizeSectionMatrixSection {
|
|
4
|
+
title: string;
|
|
5
|
+
items: Record<string, unknown>[];
|
|
6
|
+
}
|
|
7
|
+
export interface DynamicItemSizeSectionMatrixProps extends Omit<UiTypes.MatrixProps, "data" | "itemSize" | "autoItemSize" | "estimatedItemSize" | "columns" | "square" | "waterfall" | "reorder" | "menu"> {
|
|
8
|
+
data?: DynamicItemSizeSectionMatrixSection[];
|
|
9
|
+
fixedItemHeight?: number;
|
|
10
|
+
minItemWidth?: number;
|
|
11
|
+
maxColumns?: number;
|
|
12
|
+
spacing?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface DynamicItemSizeSectionMatrixEvents extends Omit<UiTypes.MatrixEvents, "itemSize" | "reorderBegan" | "reorderMoved" | "canMoveItem" | "reorderFinished"> {
|
|
15
|
+
itemHeight?: (width: number) => number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* # CView Dynamic ItemSize Section Matrix
|
|
19
|
+
*
|
|
20
|
+
* 此组件是为了在 Dynamic ItemSize Matrix 的基础上添加 SectionTitle
|
|
21
|
+
*
|
|
22
|
+
* - 使用此组件必须在每个section中添加title,如果title为空字符串,依然添加高度35的空格(包含spacing)
|
|
23
|
+
* - sectionTitle的字体为font(13),左右边距为16(不含spacing),即总宽度为 totalWidth - 2 * spacing - 32
|
|
24
|
+
* - 由于它必然和底下的item会有spacing,所以不建议spacing设的太大,那样会很违和
|
|
25
|
+
* - sectionTitle会使得section之间的间隔增加自身的高度
|
|
26
|
+
* - matrix事件会自动调整indexPath,包括didSelect、didLongPress、forEachItem
|
|
27
|
+
* - matrix的方法都在该组件中重新实现,自动调整indexPath
|
|
28
|
+
* - 不支持matrix原有的重新排序、自动大小功能,为防止sectionTitle暴露,也不支持menu
|
|
29
|
+
* - 不支持Dynamic ItemSize Matrix的dynamicHeightEnabled、heightToWidth
|
|
30
|
+
*
|
|
31
|
+
* ## 动态调整 itemSize
|
|
32
|
+
*
|
|
33
|
+
* 动态的改变自己的 itemSize,从而使得 spacing 被优先满足。
|
|
34
|
+
* 思路为在 matrix 上层套一个 superView,在旋转的时候 superView 会调用 matrix.relayout()
|
|
35
|
+
* 和 matrix.reload(),从而触发 itemSize 事件
|
|
36
|
+
*
|
|
37
|
+
* 其排布逻辑是这样的:
|
|
38
|
+
*
|
|
39
|
+
* 1. 由 minItemWidth,spacing,maxColumns 这三个参数决定 cloumns,
|
|
40
|
+
* 并结合 totalWidth 确定 itemSize.width
|
|
41
|
+
* 2. 确定 itemHeight 有两种方法:
|
|
42
|
+
* - fixedItemHeight 固定高度,优先级第二
|
|
43
|
+
* - event: itemHeight(width) => height 通过 width 动态计算,优先级最高
|
|
44
|
+
* 3. 如果 minItemWidth 比 totalWidth - 2 * spacing 还要小,那么 itemSize.width
|
|
45
|
+
* 会被设定为 totalWidth - 2 * spacing,以保证item不会超出边框
|
|
46
|
+
*
|
|
47
|
+
* ## props:
|
|
48
|
+
*
|
|
49
|
+
* 可以使用 matrix 的全部属性。
|
|
50
|
+
*
|
|
51
|
+
* 但data的类型调整为:
|
|
52
|
+
* { title: string; items: Record<string, unknown>[] }
|
|
53
|
+
*
|
|
54
|
+
* 特殊属性:
|
|
55
|
+
*
|
|
56
|
+
* - fixedItemHeight 固定 itemSize 高度
|
|
57
|
+
* - minItemWidth 最小的 itemSize 宽度
|
|
58
|
+
* - maxColumns 最大列数
|
|
59
|
+
* - spacing
|
|
60
|
+
*
|
|
61
|
+
* events:
|
|
62
|
+
*
|
|
63
|
+
* 可以使用 matrix 除 itemSize 以外的全部事件
|
|
64
|
+
*
|
|
65
|
+
* 其他特殊事件:
|
|
66
|
+
*
|
|
67
|
+
* - itemHeight: width => height 通过 itemWidth 动态计算 itemHeight
|
|
68
|
+
*
|
|
69
|
+
*
|
|
70
|
+
* 方法:
|
|
71
|
+
* - get data
|
|
72
|
+
* - set data
|
|
73
|
+
* - reload(): void;
|
|
74
|
+
* - object(indexPath: NSIndexPath): any;
|
|
75
|
+
* - insert(args: { indexPath: NSIndexPath;value: any; } ): void;
|
|
76
|
+
* - delete(indexPathOrIndex: NSIndexPath | number): void;
|
|
77
|
+
* - cell(indexPath: NSIndexPath): AllUIView;
|
|
78
|
+
* - scrollTo(args: { indexPath: NSIndexPath; animated?: boolean }): void;
|
|
79
|
+
*/
|
|
80
|
+
export declare class DynamicItemSizeSectionMatrix extends Base<UIView, UiTypes.ViewOptions> {
|
|
81
|
+
_defineView: () => UiTypes.ViewOptions;
|
|
82
|
+
private _props;
|
|
83
|
+
private _data;
|
|
84
|
+
private _events;
|
|
85
|
+
private _itemSizeWidth;
|
|
86
|
+
private _itemSizeHeight;
|
|
87
|
+
private _totalWidth;
|
|
88
|
+
private _columns;
|
|
89
|
+
private _fixedItemHeight;
|
|
90
|
+
private _minItemWidth;
|
|
91
|
+
private _maxColumns;
|
|
92
|
+
private _spacing;
|
|
93
|
+
matrix: Matrix;
|
|
94
|
+
constructor({ props, layout, events, }: {
|
|
95
|
+
props: DynamicItemSizeSectionMatrixProps;
|
|
96
|
+
layout: (make: MASConstraintMaker, view: UIView) => void;
|
|
97
|
+
events: DynamicItemSizeSectionMatrixEvents;
|
|
98
|
+
});
|
|
99
|
+
private _mapData;
|
|
100
|
+
private _mapTemplate;
|
|
101
|
+
get data(): DynamicItemSizeSectionMatrixSection[];
|
|
102
|
+
set data(data: DynamicItemSizeSectionMatrixSection[]);
|
|
103
|
+
reload(): void;
|
|
104
|
+
object(indexPath: NSIndexPath): Record<string, unknown>;
|
|
105
|
+
insert({ indexPath, value }: {
|
|
106
|
+
indexPath: NSIndexPath;
|
|
107
|
+
value: any;
|
|
108
|
+
}): void;
|
|
109
|
+
delete(indexPath: NSIndexPath): void;
|
|
110
|
+
cell(indexPath: NSIndexPath): AllUIView;
|
|
111
|
+
scrollTo({ indexPath, animated }: {
|
|
112
|
+
indexPath: NSIndexPath;
|
|
113
|
+
animated?: boolean;
|
|
114
|
+
}): void;
|
|
115
|
+
}
|