jsbox-cview 1.6.5 → 1.6.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +4 -0
  2. package/dist/components/alert/input-alert.d.ts +22 -0
  3. package/dist/components/alert/input-alert.js +1 -2
  4. package/dist/components/alert/login-alert.d.ts +21 -0
  5. package/dist/components/alert/login-alert.js +1 -2
  6. package/dist/components/alert/plain-alert.d.ts +15 -0
  7. package/dist/components/alert/plain-alert.js +1 -2
  8. package/dist/components/alert/uialert.d.ts +29 -0
  9. package/{components/base.ts → dist/components/base.d.ts} +9 -28
  10. package/dist/components/custom-navigation-bar.d.ts +117 -0
  11. package/dist/components/custom-navigation-bar.js +7 -1
  12. package/dist/components/dialogs/dialog-sheet.d.ts +46 -0
  13. package/dist/components/dialogs/dialog-sheet.js +3 -1
  14. package/dist/components/dialogs/form-dialog.d.ts +15 -0
  15. package/dist/components/dialogs/form-dialog.js +1 -2
  16. package/dist/components/dialogs/list-dialog.d.ts +23 -0
  17. package/dist/components/dialogs/list-dialog.js +2 -3
  18. package/dist/components/dialogs/text-dialog.d.ts +13 -0
  19. package/dist/components/dialogs/text-dialog.js +1 -2
  20. package/dist/components/dynamic-contextmenu-view.d.ts +40 -0
  21. package/dist/components/dynamic-contextmenu-view.js +5 -1
  22. package/dist/components/dynamic-itemsize-matrix.d.ts +79 -0
  23. package/dist/components/dynamic-itemsize-matrix.js +18 -15
  24. package/dist/components/dynamic-itemsize-section-matrix.d.ts +115 -0
  25. package/dist/components/dynamic-itemsize-section-matrix.js +293 -0
  26. package/dist/components/dynamic-preference-listview.d.ts +63 -0
  27. package/dist/components/dynamic-preference-listview.js +25 -16
  28. package/dist/components/dynamic-rowheight-list.d.ts +38 -0
  29. package/dist/components/dynamic-rowheight-list.js +10 -3
  30. package/dist/components/enhanced-imageview.d.ts +41 -0
  31. package/dist/components/enhanced-imageview.js +1 -1
  32. package/dist/components/flowlayout.d.ts +63 -0
  33. package/dist/components/flowlayout.js +10 -13
  34. package/dist/components/image-pager.d.ts +49 -0
  35. package/dist/components/image-pager.js +6 -1
  36. package/dist/components/oc-webview.d.ts +64 -0
  37. package/dist/components/oc-webview.js +13 -5
  38. package/dist/components/page-control.d.ts +45 -0
  39. package/dist/components/page-control.js +2 -13
  40. package/dist/components/pageviewer-titlebar.d.ts +48 -0
  41. package/dist/components/pageviewer-titlebar.js +7 -13
  42. package/dist/components/pageviewer.d.ts +41 -0
  43. package/dist/components/pageviewer.js +4 -1
  44. package/dist/components/refresh-button.d.ts +25 -0
  45. package/dist/components/refresh-button.js +3 -4
  46. package/dist/components/rotating-view.d.ts +45 -0
  47. package/dist/components/rotating-view.js +10 -2
  48. package/dist/components/searchbar.d.ts +118 -0
  49. package/dist/components/searchbar.js +8 -1
  50. package/dist/components/sheet.d.ts +42 -0
  51. package/dist/components/single-views.d.ts +289 -0
  52. package/dist/components/single-views.js +11 -4
  53. package/dist/components/spinners/loading-dual-ring.d.ts +18 -0
  54. package/dist/components/spinners/loading-wedges.d.ts +15 -0
  55. package/dist/components/spinners/spinner-androidstyle.d.ts +30 -0
  56. package/dist/components/spinners/spinner-androidstyle.js +7 -1
  57. package/dist/components/static-preference-listview.d.ts +389 -0
  58. package/dist/components/static-preference-listview.js +13 -10
  59. package/dist/components/symbol-button.d.ts +39 -0
  60. package/dist/components/symbol-button.js +8 -1
  61. package/dist/components/tabbar.d.ts +140 -0
  62. package/dist/components/tabbar.js +8 -1
  63. package/dist/controller/base-controller.d.ts +125 -0
  64. package/dist/controller/base-controller.js +11 -11
  65. package/dist/controller/controller-router.d.ts +48 -0
  66. package/dist/controller/pageviewer-controller.d.ts +38 -0
  67. package/dist/controller/pageviewer-controller.js +4 -1
  68. package/dist/controller/presented-page-controller.d.ts +41 -0
  69. package/dist/controller/presented-page-controller.js +7 -9
  70. package/dist/controller/splitview-controller.d.ts +90 -0
  71. package/dist/controller/splitview-controller.js +27 -11
  72. package/dist/controller/tabbar-controller.d.ts +49 -0
  73. package/dist/controller/tabbar-controller.js +12 -15
  74. package/{index.ts → dist/index.d.ts} +2 -0
  75. package/dist/index.js +2 -0
  76. package/dist/utils/colors.d.ts +7 -0
  77. package/dist/utils/cvid.d.ts +11 -0
  78. package/dist/utils/l10n.d.ts +1 -0
  79. package/dist/utils/l10n.js +1 -2
  80. package/dist/utils/path.d.ts +8 -0
  81. package/dist/utils/path.js +8 -9
  82. package/dist/utils/rect.d.ts +38 -0
  83. package/dist/utils/rect.js +8 -9
  84. package/dist/utils/uitools.d.ts +75 -0
  85. package/dist/utils/uitools.js +6 -6
  86. package/package.json +20 -5
  87. package/.prettierignore +0 -6
  88. package/.prettierrc +0 -3
  89. package/components/alert/input-alert.ts +0 -64
  90. package/components/alert/login-alert.ts +0 -66
  91. package/components/alert/plain-alert.ts +0 -39
  92. package/components/alert/uialert.ts +0 -107
  93. package/components/custom-navigation-bar.ts +0 -579
  94. package/components/dialogs/dialog-sheet.ts +0 -111
  95. package/components/dialogs/form-dialog.ts +0 -63
  96. package/components/dialogs/list-dialog.ts +0 -119
  97. package/components/dialogs/text-dialog.ts +0 -44
  98. package/components/dynamic-contextmenu-view.ts +0 -115
  99. package/components/dynamic-itemsize-matrix.ts +0 -206
  100. package/components/dynamic-preference-listview.ts +0 -684
  101. package/components/dynamic-rowheight-list.ts +0 -77
  102. package/components/enhanced-imageview.ts +0 -132
  103. package/components/flowlayout.ts +0 -248
  104. package/components/image-pager.ts +0 -180
  105. package/components/oc-webview.ts +0 -177
  106. package/components/page-control.ts +0 -93
  107. package/components/pageviewer-titlebar.ts +0 -166
  108. package/components/pageviewer.ts +0 -125
  109. package/components/refresh-button.ts +0 -83
  110. package/components/rotating-view.ts +0 -133
  111. package/components/searchbar.ts +0 -398
  112. package/components/sheet.ts +0 -104
  113. package/components/single-views.ts +0 -956
  114. package/components/spinners/loading-dual-ring.ts +0 -97
  115. package/components/spinners/loading-wedges.ts +0 -106
  116. package/components/spinners/spinner-androidstyle.ts +0 -269
  117. package/components/static-preference-listview.ts +0 -1282
  118. package/components/symbol-button.ts +0 -108
  119. package/components/tabbar.ts +0 -453
  120. package/controller/base-controller.ts +0 -214
  121. package/controller/controller-router.ts +0 -73
  122. package/controller/pageviewer-controller.ts +0 -93
  123. package/controller/presented-page-controller.ts +0 -76
  124. package/controller/splitview-controller.ts +0 -359
  125. package/controller/tabbar-controller.ts +0 -131
  126. package/dist/test/custom-navigation-bar.js +0 -40
  127. package/dist/test/dialog-sheet.js +0 -40
  128. package/dist/test/dynamic-contextmenu-view.js +0 -66
  129. package/dist/test/dynamic-itemsize-matrix.js +0 -74
  130. package/dist/test/dynamic-preference-listview.js +0 -150
  131. package/dist/test/flowlayout.js +0 -76
  132. package/dist/test/form-dialog.js +0 -51
  133. package/dist/test/oc-webview.js +0 -195
  134. package/dist/test/pageviewer-controller.js +0 -20
  135. package/dist/test/pageviewer-titlebar.js +0 -18
  136. package/dist/test/pageviewer.js +0 -32
  137. package/dist/test/refresh-button.js +0 -26
  138. package/dist/test/searchbar.js +0 -36
  139. package/dist/test/splitview-controller.js +0 -41
  140. package/dist/test/static-preference-listview.js +0 -143
  141. package/dist/test/tabbar-controller.js +0 -48
  142. package/test/custom-navigation-bar.ts +0 -40
  143. package/test/dialog-sheet.ts +0 -40
  144. package/test/dynamic-contextmenu-view.ts +0 -67
  145. package/test/dynamic-itemsize-matrix.ts +0 -74
  146. package/test/dynamic-preference-listview.ts +0 -151
  147. package/test/flowlayout.ts +0 -79
  148. package/test/form-dialog.ts +0 -48
  149. package/test/oc-webview.ts +0 -197
  150. package/test/pageviewer-controller.ts +0 -21
  151. package/test/pageviewer-titlebar.ts +0 -18
  152. package/test/pageviewer.ts +0 -31
  153. package/test/refresh-button.ts +0 -26
  154. package/test/searchbar.ts +0 -38
  155. package/test/splitview-controller.ts +0 -42
  156. package/test/static-preference-listview.ts +0 -142
  157. package/test/tabbar-controller.ts +0 -49
  158. package/tsconfig.json +0 -122
  159. package/utils/colors.ts +0 -17
  160. package/utils/cvid.ts +0 -32
  161. package/utils/l10n.ts +0 -42
  162. package/utils/path.ts +0 -97
  163. package/utils/rect.ts +0 -90
  164. package/utils/uitools.ts +0 -122
package/README.md CHANGED
@@ -17,3 +17,7 @@ CView 的视图组件是非侵入式的。换言之,你可以全部使用 CVie
17
17
 
18
18
  View 组件是收敛的,而 Controller 负责页面的构成和更新。
19
19
  它可以实现一些常用的页面构建形式,比如底部 Tab 分页,左侧滑动分页,弹出式页面等。
20
+
21
+ ## 示例
22
+
23
+ 可运行示例及使用说明见 [`examples`](./examples/README.md)。
@@ -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>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.inputAlert = void 0;
3
+ exports.inputAlert = inputAlert;
4
4
  const uialert_1 = require("./uialert");
5
5
  const l10n_1 = require("../../utils/l10n");
6
6
  /**
@@ -43,4 +43,3 @@ function inputAlert({ title = "", message = "", text = "", placeholder, type = 0
43
43
  }
44
44
  });
45
45
  }
46
- exports.inputAlert = inputAlert;
@@ -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
+ }>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loginAlert = void 0;
3
+ exports.loginAlert = loginAlert;
4
4
  const uialert_1 = require("./uialert");
5
5
  const l10n_1 = require("../../utils/l10n");
6
6
  /**
@@ -47,4 +47,3 @@ function loginAlert({ title = "", message = "", placeholder1 = "", placeholder2
47
47
  }
48
48
  });
49
49
  }
50
- exports.loginAlert = loginAlert;
@@ -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>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.plainAlert = void 0;
3
+ exports.plainAlert = plainAlert;
4
4
  const uialert_1 = require("./uialert");
5
5
  const l10n_1 = require("../../utils/l10n");
6
6
  /**
@@ -26,4 +26,3 @@ function plainAlert({ title = "", message = "", cancelText = (0, l10n_1.l10n)("C
26
26
  }
27
27
  });
28
28
  }
29
- exports.plainAlert = plainAlert;
@@ -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
- readonly id: string;
23
- private _view?: T;
24
- abstract _defineView: () => R;
25
- _layout?: (make: MASConstraintMaker, view: T) => void;
26
-
27
- constructor() {
28
- this.id = cvid.newId;
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 {};
@@ -86,7 +86,13 @@ const navBarLayouts = [
86
86
  class CustomNavigationBar extends base_1.Base {
87
87
  constructor({ props = {}, events = {}, } = {}) {
88
88
  super();
89
- this._props = Object.assign({ leftBarButtonItems: [], rightBarButtonItems: [], style: navBarStyles.normal, tintColor: $color("primaryText") }, props);
89
+ this._props = {
90
+ leftBarButtonItems: [],
91
+ rightBarButtonItems: [],
92
+ style: navBarStyles.normal,
93
+ tintColor: $color("primaryText"),
94
+ ...props,
95
+ };
90
96
  this._events = events;
91
97
  this.cviews = {};
92
98
  this._defineView = () => {
@@ -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
+ }
@@ -53,7 +53,9 @@ class DialogSheet extends sheet_1.Sheet {
53
53
  return;
54
54
  }
55
55
  }
56
- this.done();
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
+ }>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formDialog = void 0;
3
+ exports.formDialog = formDialog;
4
4
  const static_preference_listview_1 = require("../static-preference-listview");
5
5
  const dialog_sheet_1 = require("./dialog-sheet");
6
6
  class DialogSheetForm extends dialog_sheet_1.DialogSheet {
@@ -38,4 +38,3 @@ function formDialog({ sections, title, checkHandler, }) {
38
38
  sheet.present();
39
39
  });
40
40
  }
41
- exports.formDialog = formDialog;
@@ -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>;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listDialog = void 0;
3
+ 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: {
@@ -76,4 +76,3 @@ function listDialog({ items, multiSelectEnabled, value, values = [], title, }) {
76
76
  sheet.present();
77
77
  });
78
78
  }
79
- exports.listDialog = listDialog;
@@ -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>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textDialog = void 0;
3
+ exports.textDialog = textDialog;
4
4
  const single_views_1 = require("../single-views");
5
5
  const dialog_sheet_1 = require("./dialog-sheet");
6
6
  /**
@@ -34,4 +34,3 @@ function textDialog({ title, text = "", placeholder = "", editable = true, }) {
34
34
  sheet.present();
35
35
  });
36
36
  }
37
- exports.textDialog = textDialog;
@@ -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 {};
@@ -26,7 +26,11 @@ class DynamicContextMenuView extends base_1.Base {
26
26
  this._defineView = () => {
27
27
  return {
28
28
  type: "runtime",
29
- props: Object.assign(Object.assign({}, props), { id: this.id, view: runtimeView }),
29
+ props: {
30
+ ...props,
31
+ id: this.id,
32
+ view: runtimeView,
33
+ },
30
34
  layout,
31
35
  events,
32
36
  views,
@@ -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 {};
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.DynamicItemSizeMatrix = void 0;
15
4
  const base_1 = require("./base");
@@ -78,16 +67,29 @@ class DynamicItemSizeMatrix extends base_1.Base {
78
67
  super();
79
68
  this._totalWidth = 0;
80
69
  this._columns = 1;
81
- this._props = Object.assign({ fixedItemHeight: 40, minItemWidth: 96, maxColumns: 5, spacing: 6, dynamicHeightEnabled: false }, props);
70
+ this._props = {
71
+ fixedItemHeight: 40,
72
+ minItemWidth: 96,
73
+ maxColumns: 5,
74
+ spacing: 6,
75
+ dynamicHeightEnabled: false,
76
+ ...props,
77
+ };
82
78
  this._events = events;
83
- const _a = this._events, { itemHeight, heightChanged } = _a, rest = __rest(_a, ["itemHeight", "heightChanged"]);
79
+ const { itemHeight, heightChanged, ...rest } = this._events;
84
80
  const _matrixEvents = rest;
85
81
  this._itemSizeWidth = 0;
86
82
  this._itemSizeHeight = 0;
87
83
  this.matrix = new single_views_1.Matrix({
88
- props: Object.assign(Object.assign({}, this._props), { scrollEnabled: !this._props.dynamicHeightEnabled }),
84
+ props: {
85
+ ...this._props,
86
+ scrollEnabled: !this._props.dynamicHeightEnabled,
87
+ },
89
88
  layout: $layout.fill,
90
- events: Object.assign(Object.assign({}, _matrixEvents), { itemSize: (sender) => $size(this._itemSizeWidth, this._itemSizeHeight) }),
89
+ events: {
90
+ ..._matrixEvents,
91
+ itemSize: (sender) => $size(this._itemSizeWidth, this._itemSizeHeight),
92
+ },
91
93
  });
92
94
  this._defineView = () => {
93
95
  return {
@@ -102,6 +104,7 @@ class DynamicItemSizeMatrix extends base_1.Base {
102
104
  sender.relayout();
103
105
  if (sender.frame.width === this._totalWidth)
104
106
  return;
107
+ this._totalWidth = sender.frame.width;
105
108
  const { columns, itemSizeWidth } = _getColumnsAndItemSizeWidth(sender.frame.width, this._props.minItemWidth, this._props.maxColumns, this._props.spacing);
106
109
  this._columns = columns;
107
110
  this._itemSizeWidth = itemSizeWidth;