jsbox-cview 1.6.6 → 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 (136) hide show
  1. package/README.md +4 -0
  2. package/dist/components/alert/input-alert.d.ts +22 -0
  3. package/dist/components/alert/login-alert.d.ts +21 -0
  4. package/dist/components/alert/plain-alert.d.ts +15 -0
  5. package/dist/components/alert/uialert.d.ts +29 -0
  6. package/{components/base.ts → dist/components/base.d.ts} +9 -28
  7. package/dist/components/custom-navigation-bar.d.ts +117 -0
  8. package/dist/components/dialogs/dialog-sheet.d.ts +46 -0
  9. package/dist/components/dialogs/dialog-sheet.js +3 -1
  10. package/dist/components/dialogs/form-dialog.d.ts +15 -0
  11. package/dist/components/dialogs/list-dialog.d.ts +23 -0
  12. package/dist/components/dialogs/list-dialog.js +1 -1
  13. package/dist/components/dialogs/text-dialog.d.ts +13 -0
  14. package/dist/components/dynamic-contextmenu-view.d.ts +40 -0
  15. package/dist/components/dynamic-itemsize-matrix.d.ts +79 -0
  16. package/dist/components/dynamic-itemsize-matrix.js +1 -0
  17. package/dist/components/dynamic-itemsize-section-matrix.d.ts +115 -0
  18. package/dist/components/dynamic-preference-listview.d.ts +63 -0
  19. package/dist/components/dynamic-rowheight-list.d.ts +38 -0
  20. package/dist/components/enhanced-imageview.d.ts +41 -0
  21. package/dist/components/flowlayout.d.ts +63 -0
  22. package/dist/components/image-pager.d.ts +49 -0
  23. package/dist/components/oc-webview.d.ts +64 -0
  24. package/dist/components/page-control.d.ts +45 -0
  25. package/dist/components/pageviewer-titlebar.d.ts +48 -0
  26. package/dist/components/pageviewer.d.ts +41 -0
  27. package/dist/components/refresh-button.d.ts +25 -0
  28. package/dist/components/rotating-view.d.ts +45 -0
  29. package/dist/components/searchbar.d.ts +118 -0
  30. package/dist/components/sheet.d.ts +42 -0
  31. package/dist/components/single-views.d.ts +289 -0
  32. package/dist/components/spinners/loading-dual-ring.d.ts +18 -0
  33. package/dist/components/spinners/loading-wedges.d.ts +15 -0
  34. package/dist/components/spinners/spinner-androidstyle.d.ts +30 -0
  35. package/dist/components/static-preference-listview.d.ts +389 -0
  36. package/dist/components/symbol-button.d.ts +39 -0
  37. package/dist/components/tabbar.d.ts +140 -0
  38. package/dist/controller/base-controller.d.ts +125 -0
  39. package/dist/controller/base-controller.js +11 -11
  40. package/dist/controller/controller-router.d.ts +48 -0
  41. package/dist/controller/pageviewer-controller.d.ts +38 -0
  42. package/dist/controller/presented-page-controller.d.ts +41 -0
  43. package/dist/controller/splitview-controller.d.ts +90 -0
  44. package/dist/controller/splitview-controller.js +4 -0
  45. package/dist/controller/tabbar-controller.d.ts +49 -0
  46. package/dist/controller/tabbar-controller.js +0 -2
  47. package/{index.ts → dist/index.d.ts} +1 -0
  48. package/dist/index.js +1 -0
  49. package/dist/utils/colors.d.ts +7 -0
  50. package/dist/utils/cvid.d.ts +11 -0
  51. package/dist/utils/l10n.d.ts +1 -0
  52. package/dist/utils/path.d.ts +8 -0
  53. package/dist/utils/rect.d.ts +38 -0
  54. package/dist/utils/uitools.d.ts +75 -0
  55. package/package.json +20 -6
  56. package/.prettierignore +0 -6
  57. package/.prettierrc +0 -3
  58. package/components/alert/input-alert.ts +0 -64
  59. package/components/alert/login-alert.ts +0 -66
  60. package/components/alert/plain-alert.ts +0 -39
  61. package/components/alert/uialert.ts +0 -107
  62. package/components/custom-navigation-bar.ts +0 -579
  63. package/components/dialogs/dialog-sheet.ts +0 -111
  64. package/components/dialogs/form-dialog.ts +0 -63
  65. package/components/dialogs/list-dialog.ts +0 -119
  66. package/components/dialogs/text-dialog.ts +0 -44
  67. package/components/dynamic-contextmenu-view.ts +0 -115
  68. package/components/dynamic-itemsize-matrix.ts +0 -206
  69. package/components/dynamic-itemsize-section-matrix.ts +0 -363
  70. package/components/dynamic-preference-listview.ts +0 -684
  71. package/components/dynamic-rowheight-list.ts +0 -77
  72. package/components/enhanced-imageview.ts +0 -132
  73. package/components/flowlayout.ts +0 -248
  74. package/components/image-pager.ts +0 -180
  75. package/components/oc-webview.ts +0 -177
  76. package/components/page-control.ts +0 -93
  77. package/components/pageviewer-titlebar.ts +0 -166
  78. package/components/pageviewer.ts +0 -125
  79. package/components/refresh-button.ts +0 -83
  80. package/components/rotating-view.ts +0 -133
  81. package/components/searchbar.ts +0 -398
  82. package/components/sheet.ts +0 -104
  83. package/components/single-views.ts +0 -956
  84. package/components/spinners/loading-dual-ring.ts +0 -97
  85. package/components/spinners/loading-wedges.ts +0 -106
  86. package/components/spinners/spinner-androidstyle.ts +0 -269
  87. package/components/static-preference-listview.ts +0 -1282
  88. package/components/symbol-button.ts +0 -108
  89. package/components/tabbar.ts +0 -453
  90. package/controller/base-controller.ts +0 -214
  91. package/controller/controller-router.ts +0 -73
  92. package/controller/pageviewer-controller.ts +0 -93
  93. package/controller/presented-page-controller.ts +0 -76
  94. package/controller/splitview-controller.ts +0 -359
  95. package/controller/tabbar-controller.ts +0 -131
  96. package/dist/test/custom-navigation-bar.js +0 -40
  97. package/dist/test/dialog-sheet.js +0 -40
  98. package/dist/test/dynamic-contextmenu-view.js +0 -66
  99. package/dist/test/dynamic-itemsize-matrix.js +0 -74
  100. package/dist/test/dynamic-itemsize-section-matrix.js +0 -138
  101. package/dist/test/dynamic-preference-listview.js +0 -150
  102. package/dist/test/flowlayout.js +0 -76
  103. package/dist/test/form-dialog.js +0 -51
  104. package/dist/test/oc-webview.js +0 -195
  105. package/dist/test/pageviewer-controller.js +0 -20
  106. package/dist/test/pageviewer-titlebar.js +0 -18
  107. package/dist/test/pageviewer.js +0 -32
  108. package/dist/test/refresh-button.js +0 -26
  109. package/dist/test/searchbar.js +0 -36
  110. package/dist/test/splitview-controller.js +0 -41
  111. package/dist/test/static-preference-listview.js +0 -143
  112. package/dist/test/tabbar-controller.js +0 -48
  113. package/test/custom-navigation-bar.ts +0 -40
  114. package/test/dialog-sheet.ts +0 -40
  115. package/test/dynamic-contextmenu-view.ts +0 -67
  116. package/test/dynamic-itemsize-matrix.ts +0 -74
  117. package/test/dynamic-itemsize-section-matrix.ts +0 -142
  118. package/test/dynamic-preference-listview.ts +0 -151
  119. package/test/flowlayout.ts +0 -79
  120. package/test/form-dialog.ts +0 -48
  121. package/test/oc-webview.ts +0 -197
  122. package/test/pageviewer-controller.ts +0 -21
  123. package/test/pageviewer-titlebar.ts +0 -18
  124. package/test/pageviewer.ts +0 -31
  125. package/test/refresh-button.ts +0 -26
  126. package/test/searchbar.ts +0 -38
  127. package/test/splitview-controller.ts +0 -42
  128. package/test/static-preference-listview.ts +0 -142
  129. package/test/tabbar-controller.ts +0 -49
  130. package/tsconfig.json +0 -122
  131. package/utils/colors.ts +0 -17
  132. package/utils/cvid.ts +0 -32
  133. package/utils/l10n.ts +0 -42
  134. package/utils/path.ts +0 -97
  135. package/utils/rect.ts +0 -90
  136. package/utils/uitools.ts +0 -122
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseController = exports.ControllerRootView = void 0;
3
+ exports.BaseController = exports.ControllerRootView = exports.controllerStatus = void 0;
4
4
  const base_1 = require("../components/base");
5
5
  const single_views_1 = require("../components/single-views");
6
6
  const cvid_1 = require("../utils/cvid");
@@ -14,7 +14,7 @@ const controller_router_1 = require("./controller-router");
14
14
  * - removed = 4 根视图被移除
15
15
  * 其中只有 2 和 3 可以相互转化,其他不可以
16
16
  */
17
- const controllerStatus = {
17
+ exports.controllerStatus = {
18
18
  created: 0,
19
19
  loaded: 1,
20
20
  appeared: 2,
@@ -102,7 +102,7 @@ class BaseController {
102
102
  this._props = props || {};
103
103
  this._events = events;
104
104
  this.id = this._props.id || cvid_1.cvid.newId;
105
- this._status = controllerStatus.created; // status使用额外的get来使其只读
105
+ this._status = exports.controllerStatus.created; // status使用额外的get来使其只读
106
106
  this.rootView = new ControllerRootView({
107
107
  props: {
108
108
  bgcolor: this._props.bgcolor || $color("primarySurface"),
@@ -116,38 +116,38 @@ class BaseController {
116
116
  }
117
117
  load() {
118
118
  // 只有status为created才可以运行
119
- if (this._status !== controllerStatus.created)
119
+ if (this._status !== exports.controllerStatus.created)
120
120
  return;
121
- this._status = controllerStatus.loaded;
121
+ this._status = exports.controllerStatus.loaded;
122
122
  if (this._events.didLoad)
123
123
  this._events.didLoad(this);
124
124
  controller_router_1.router.add(this);
125
125
  }
126
126
  appear() {
127
127
  // 只有status为loaded或者disappeared,才可以运行
128
- if (this._status !== controllerStatus.loaded && this._status !== controllerStatus.disappeared)
128
+ if (this._status !== exports.controllerStatus.loaded && this._status !== exports.controllerStatus.disappeared)
129
129
  return;
130
130
  if (this._events.didAppear)
131
131
  this._events.didAppear(this);
132
- this._status = controllerStatus.appeared;
132
+ this._status = exports.controllerStatus.appeared;
133
133
  }
134
134
  disappear() {
135
135
  // 只有status为loaded或者appeared,才可以运行
136
- if (this._status !== controllerStatus.loaded && this._status !== controllerStatus.appeared)
136
+ if (this._status !== exports.controllerStatus.loaded && this._status !== exports.controllerStatus.appeared)
137
137
  return;
138
138
  if (this._events.didDisappear)
139
139
  this._events.didDisappear(this);
140
- this._status = controllerStatus.disappeared;
140
+ this._status = exports.controllerStatus.disappeared;
141
141
  }
142
142
  // 此方法不能用于移除rootView,其作用是将控制器从Router中移除,并触发didRemove事件
143
143
  remove() {
144
144
  // 如果已经移除,不可以再次运行
145
- if (this._status === controllerStatus.removed)
145
+ if (this._status === exports.controllerStatus.removed)
146
146
  return;
147
147
  if (this._events.didRemove)
148
148
  this._events.didRemove(this);
149
149
  controller_router_1.router.delete(this);
150
- this._status = controllerStatus.removed;
150
+ this._status = exports.controllerStatus.removed;
151
151
  }
152
152
  uirender(props) {
153
153
  controller_router_1.router.root = this;
@@ -0,0 +1,48 @@
1
+ import { BaseController } from "./base-controller";
2
+ /**
3
+ * 控制器的路由器,用于管理控制器的集合和操作。
4
+ *
5
+ * ## 属性
6
+ * - `root`:根控制器。
7
+ * - `appeared`:状态为appeared的控制器列表。
8
+ * - `controllerSet`:控制器集合。
9
+ *
10
+ * ## 方法
11
+ * - `add(controller: BaseController)`:添加控制器到路由器中。
12
+ * - `delete(controller: BaseController)`:从路由器中删除控制器。
13
+ * - `get(id: string)`:根据控制器的ID获取控制器。
14
+ *
15
+ */
16
+ declare class Router {
17
+ private _set;
18
+ root?: BaseController;
19
+ constructor();
20
+ /**
21
+ * 添加控制器到路由器中。
22
+ * @param controller 要添加的控制器。
23
+ */
24
+ add(controller: BaseController): void;
25
+ /**
26
+ * 从路由器中删除控制器。
27
+ * @param controller 要删除的控制器。
28
+ */
29
+ delete(controller: BaseController): void;
30
+ /**
31
+ * 根据控制器的ID获取控制器。
32
+ * @param id 控制器的ID。
33
+ * @returns 匹配的控制器,如果找不到则返回undefined。
34
+ */
35
+ get(id: string): BaseController | undefined;
36
+ /**
37
+ * 获取状态为appeared的控制器集合。
38
+ * @returns 控制器集合。
39
+ */
40
+ get appeared(): BaseController[];
41
+ /**
42
+ * 获取控制器集合。
43
+ * @returns 控制器集合。
44
+ */
45
+ get controllerSet(): Set<BaseController>;
46
+ }
47
+ export declare const router: Router;
48
+ export {};
@@ -0,0 +1,38 @@
1
+ import { BaseController, BaseControllerProps, BaseControllerEvents } from "./base-controller";
2
+ import { PageViewer } from "../components/pageviewer";
3
+ import { PageViewerTitleBar } from "../components/pageviewer-titlebar";
4
+ import { CustomNavigationBar, NavigationBarProps } from "../components/custom-navigation-bar";
5
+ interface PageViewerControllerProps extends BaseControllerProps {
6
+ items: {
7
+ controller: BaseController;
8
+ title: string;
9
+ }[];
10
+ navBarProps?: Partial<NavigationBarProps>;
11
+ index?: number;
12
+ }
13
+ /**
14
+ * # CView PageViewer Controller
15
+ *
16
+ * 一个可以左右滑动翻页的控制器。
17
+ *
18
+ * Props:
19
+ *
20
+ * - items: { controller: Controller, title: string }[]
21
+ * - navBarProps: {} 可用于 navBar 的其他属性,不包括 title 和 titleView
22
+ */
23
+ export declare class PageViewerController extends BaseController {
24
+ protected _props: PageViewerControllerProps;
25
+ cviews: {
26
+ pageviewer: PageViewer;
27
+ titlebar: PageViewerTitleBar;
28
+ navbar: CustomNavigationBar;
29
+ };
30
+ constructor({ props, layout, events, }: {
31
+ props: PageViewerControllerProps;
32
+ layout?: (make: MASConstraintMaker, view: UIView) => void;
33
+ events?: BaseControllerEvents;
34
+ });
35
+ get index(): number;
36
+ set index(num: number);
37
+ }
38
+ export {};
@@ -0,0 +1,41 @@
1
+ import { BaseController, BaseControllerProps, BaseControllerEvents } from "./base-controller";
2
+ interface PresentedPageControllerProps extends BaseControllerProps {
3
+ presentMode?: number;
4
+ animated?: boolean;
5
+ interactiveDismissalDisabled?: boolean;
6
+ }
7
+ interface PresentedPageControllerEvents extends BaseControllerEvents {
8
+ dismissed?: (controller: PresentedPageController) => void;
9
+ }
10
+ /** # CView PresentedPageController
11
+ *
12
+ * ## Props
13
+ *
14
+ * - presentMode?: number = 1
15
+ * - animated?: boolean = true
16
+ * - interactiveDismissalDisabled?: boolean = false
17
+ * - bgcolor?: UIColor = $color("secondarySurface")
18
+ *
19
+ * ## 专用事件
20
+ *
21
+ * - dismissed: function 退出时的回调
22
+ *
23
+ * ## 专用方法
24
+ *
25
+ * - present() 在 `sheet.present()` 之后会先后执行 `load()` 和 `appear()`
26
+ * - dismiss()
27
+ *
28
+ * ## 布局
29
+ * 此控制器的 layout 必定为 `$layout.fill`,无需自行设定
30
+ */
31
+ export declare class PresentedPageController extends BaseController {
32
+ private _sheet;
33
+ constructor({ props, layout, events, }?: {
34
+ props?: Partial<PresentedPageControllerProps>;
35
+ layout?: (make: MASConstraintMaker, view: UIView) => void;
36
+ events?: PresentedPageControllerEvents;
37
+ });
38
+ present(): void;
39
+ dismiss(): void;
40
+ }
41
+ export {};
@@ -0,0 +1,90 @@
1
+ import { BaseController, BaseControllerProps, BaseControllerEvents } from "./base-controller";
2
+ import { Base } from "../components/base";
3
+ import { ContentView } from "../components/single-views";
4
+ declare class SecondaryView extends Base<UIView, UiTypes.ViewOptions> {
5
+ _props: UiTypes.ViewProps;
6
+ _layouts: {
7
+ hidden: (make: MASConstraintMaker, view: AllUIView) => void;
8
+ shown: (make: MASConstraintMaker, view: AllUIView) => void;
9
+ };
10
+ line: ContentView;
11
+ _defineView: () => UiTypes.ViewOptions;
12
+ constructor({ props, layout, views, }: {
13
+ props?: UiTypes.ViewProps;
14
+ layout?: (make: MASConstraintMaker, view: UIView) => void;
15
+ views?: UiTypes.AllViewOptions[];
16
+ });
17
+ add(view: UiTypes.AllViewOptions | Base<any, any>): void;
18
+ show(): void;
19
+ hide(): void;
20
+ }
21
+ declare class MaskView extends Base<UIView, UiTypes.ViewOptions> {
22
+ _props: {
23
+ bgcolor: UIColor;
24
+ dismissHandler?: () => void;
25
+ };
26
+ _shown: boolean;
27
+ _dismissEvent: () => void;
28
+ _gestureObject: any;
29
+ _defineView: () => UiTypes.ViewOptions;
30
+ constructor({ props, layout, }: {
31
+ props: {
32
+ bgcolor?: UIColor;
33
+ dismissHandler?: () => void;
34
+ };
35
+ layout?: (make: MASConstraintMaker, view: UIView) => void;
36
+ });
37
+ _addGesture(view: UIView, event: () => void): void;
38
+ releaseGestureObject(): void;
39
+ show(): void;
40
+ hide(): void;
41
+ }
42
+ interface SplitViewControllerProps extends BaseControllerProps {
43
+ items: {
44
+ controller: BaseController;
45
+ bgcolor: UIColor;
46
+ }[];
47
+ }
48
+ /** # CView SplitView Controller
49
+ *
50
+ * 实现左右分栏布局的控制器, 本身不提供除了分割线以外的视觉效果
51
+ *
52
+ * 此控制器加载后,会禁用原本的ScreenEdgePanGesture,此控制器应该作为根控制器使用
53
+ *
54
+ * @param options.props.items: { controller: Controller, bgcolor: UIColor }[]
55
+ * 其中第一个放在主视图上, 第二个放在次视图上
56
+ *
57
+ * @property sideBarShown: boolean = false 侧栏是否显示
58
+ * @property canShowSidebar: boolean = true 是否启动显示侧栏的动作
59
+ * (若为false,依然可以用sideBarShown来控制侧栏的显示)
60
+ */
61
+ export declare class SplitViewController extends BaseController {
62
+ private _screenEdgePanGestureObject;
63
+ private _sideBarShown;
64
+ private _canShowSidebar;
65
+ private _primaryController;
66
+ private _secondaryController;
67
+ cviews: {
68
+ primaryView: ContentView;
69
+ secondaryView: SecondaryView;
70
+ maskView: MaskView;
71
+ };
72
+ constructor({ props, layout, events, }: {
73
+ props: SplitViewControllerProps;
74
+ layout?: (make: MASConstraintMaker, view: UIView) => void;
75
+ events?: BaseControllerEvents;
76
+ });
77
+ load(): void;
78
+ remove(): void;
79
+ uirender(): void;
80
+ uipush(): void;
81
+ _defineGestureObject(event: () => void): any;
82
+ _renewScreenEdgePanGesture(): void;
83
+ _showSideBar(): void;
84
+ _hideSideBar(): void;
85
+ get sideBarShown(): boolean;
86
+ set sideBarShown(bool: boolean);
87
+ get canShowSidebar(): boolean;
88
+ set canShowSidebar(bool: boolean);
89
+ }
90
+ export {};
@@ -207,10 +207,14 @@ class SplitViewController extends base_controller_1.BaseController {
207
207
  this.rootView.views = [this.cviews.secondaryView, this.cviews.primaryView];
208
208
  }
209
209
  load() {
210
+ if (this.status !== base_controller_1.controllerStatus.created)
211
+ return;
210
212
  super.load();
211
213
  this._renewScreenEdgePanGesture();
212
214
  }
213
215
  remove() {
216
+ if (this.status === base_controller_1.controllerStatus.removed)
217
+ return;
214
218
  $objc_release(this._screenEdgePanGestureObject);
215
219
  this.cviews.maskView.releaseGestureObject();
216
220
  super.remove();
@@ -0,0 +1,49 @@
1
+ import { BaseController, BaseControllerProps, BaseControllerEvents } from "./base-controller";
2
+ import { ContentView } from "../components/single-views";
3
+ import { TabBar } from "../components/tabbar";
4
+ interface TabBarControllerProps extends BaseControllerProps {
5
+ items: {
6
+ title?: string;
7
+ symbol?: string;
8
+ image?: UIImage;
9
+ tintColor?: UIColor;
10
+ bgcolor?: UIColor;
11
+ controller: BaseController;
12
+ }[];
13
+ index?: number;
14
+ }
15
+ interface TabBarControllerEvents extends BaseControllerEvents {
16
+ changed?: (controller: TabBarController, index: number) => void;
17
+ doubleTapped?: (controller: TabBarController, index: number) => void;
18
+ }
19
+ /**
20
+ * # CView TabBar Controller
21
+ *
22
+ * TabBarController 是一个 PagingController
23
+ *
24
+ * ## 属性
25
+ *
26
+ * - items: {title?: string,
27
+ * symbol?: string,
28
+ * image?: UIImage,
29
+ * tintColor?: UIColor,
30
+ * bgcolor?: UIColor,
31
+ * controller: Controller}[]
32
+ * - index: number = 0
33
+ */
34
+ export declare class TabBarController extends BaseController {
35
+ _props: TabBarControllerProps;
36
+ cviews: {
37
+ tabbar: TabBar;
38
+ pageContentView: ContentView;
39
+ };
40
+ pages: ContentView[];
41
+ constructor({ props, layout, events, }: {
42
+ props: TabBarControllerProps;
43
+ layout?: (make: MASConstraintMaker, view: UIView) => void;
44
+ events?: TabBarControllerEvents;
45
+ });
46
+ set index(num: number);
47
+ get index(): number;
48
+ }
49
+ export {};
@@ -52,8 +52,6 @@ class TabBarController extends base_controller_1.BaseController {
52
52
  events: {
53
53
  changed: (cview, index) => {
54
54
  this.index = index;
55
- this._props.items.find((item) => item.controller.status === 2)?.controller.disappear();
56
- this._props.items[index].controller.appear();
57
55
  events.changed?.(this, index);
58
56
  },
59
57
  doubleTapped: (cview, index) => {
@@ -1,3 +1,4 @@
1
+ /// <reference types="jsbox-types" preserve="true" />
1
2
  export * from "./components/base";
2
3
  export * from "./components/custom-navigation-bar";
3
4
  export * from "./components/dynamic-contextmenu-view";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /// <reference types="jsbox-types" preserve="true" />
2
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
4
  if (k2 === undefined) k2 = k;
4
5
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -0,0 +1,7 @@
1
+ export declare const sheetNavBarColor: UIColor;
2
+ export declare const footBarDefaultSegmentColor: UIColor;
3
+ export declare const searchBarSymbolColor: UIColor;
4
+ export declare const searchBarBgcolor: UIColor;
5
+ export declare const gold: UIColor;
6
+ export declare const sectionHeaderColor: UIColor;
7
+ export declare const sliderMaxColor: UIColor;
@@ -0,0 +1,11 @@
1
+ declare class CVID {
2
+ _prefix: string;
3
+ _index: number;
4
+ constructor({ prefix, startIndex }?: {
5
+ prefix?: string | undefined;
6
+ startIndex?: number | undefined;
7
+ });
8
+ get newId(): string;
9
+ }
10
+ export declare const cvid: CVID;
11
+ export {};
@@ -0,0 +1 @@
1
+ export declare function l10n(key: string): string;
@@ -0,0 +1,8 @@
1
+ export declare function split(path: string): [string, string];
2
+ export declare function dirname(path: string): string;
3
+ export declare function basename(path: string): string;
4
+ export declare function extname(path: string): string;
5
+ export declare function join(...args: string[]): string;
6
+ export declare function getCreationDate(path: string): number;
7
+ export declare function getModificationDate(path: string): number;
8
+ export declare function getFileSize(path: string): number;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * When called without arguments, return the center of the rectangle.
3
+ * When a Point is passed as an argument, the rectangle’s x and y values
4
+ * are adjusted, so that the new center of the rectangle is p.
5
+ */
6
+ export declare function center(rect: JBRect, point?: JBPoint): JBPoint;
7
+ /**
8
+ * Return true if the given point lies within the bounds of the rectangle,
9
+ * false otherwise.
10
+ */
11
+ export declare function containsPoint(rect: JBRect, point: JBPoint): boolean;
12
+ /**
13
+ * Return true if the given rectangle lies entirely within the bounds of
14
+ * this rectangle, false otherwise.
15
+ */
16
+ export declare function containsRect(rect: JBRect, otherRect: JBRect): boolean;
17
+ /**
18
+ * Return true if this rectangle intersects with the other rectangle,
19
+ * false otherwise.
20
+ */
21
+ export declare function intersects(rect: JBRect, otherRect: JBRect): boolean;
22
+ /**
23
+ * Return a $rect that corresponds to the intersection of this rectangle with
24
+ * the other one.
25
+ */
26
+ export declare function intersection(rect: JBRect, otherRect: JBRect): JBRect;
27
+ /**
28
+ * Return the smallest $rect that encloses both rectangles.
29
+ */
30
+ export declare function union(rect: JBRect, otherRect: JBRect): JBRect;
31
+ /**
32
+ * Equivalent to $rect(r.x + x, r.y + y, r.w, r.h)
33
+ */
34
+ export declare function translate(rect: JBRect, point: JBPoint): JBRect;
35
+ /**
36
+ * Return a $rect that is adjusted by the given edge insets.
37
+ */
38
+ export declare function inset(rect: JBRect, insets: JBInsets): JBRect;
@@ -0,0 +1,75 @@
1
+ /**
2
+ * 立即获得window size
3
+ */
4
+ export declare function getWindowSize(): JBSize;
5
+ /**
6
+ * 获取单行字符串应有的宽度
7
+ * 默认额外添加3 inset
8
+ */
9
+ export declare function getTextWidth(text: string, { font, inset }?: {
10
+ font?: UIFont | undefined;
11
+ inset?: number | undefined;
12
+ }): number;
13
+ /**
14
+ * 获取字符串指定宽度后应有的高度
15
+ * 默认额外添加3 inset
16
+ */
17
+ export declare function getTextHeight(text: string, { width, font, inset, lineSpacing }?: {
18
+ width?: number | undefined;
19
+ font?: UIFont | undefined;
20
+ inset?: number | undefined;
21
+ lineSpacing?: number | undefined;
22
+ }): number;
23
+ /**
24
+ * 计算某个view在某个上级view(若不指定则为UIWindow)上的绝对frame
25
+ * 此方法不考虑旋转变形等特殊情况
26
+ */
27
+ export declare function absoluteFrame(view: AllUIView, endView?: AllUIView): JBRect;
28
+ export declare const layerCommonOptions: {
29
+ none: {
30
+ cornerRadius: number;
31
+ shadowRadius: number;
32
+ shadowOpacity: number;
33
+ shadowOffset: JBSize;
34
+ shadowColor: UIColor;
35
+ };
36
+ roundedShadow: {
37
+ cornerRadius: number;
38
+ shadowRadius: number;
39
+ shadowOpacity: number;
40
+ shadowOffset: JBSize;
41
+ shadowColor: UIColor;
42
+ };
43
+ textShadow: {
44
+ cornerRadius: number;
45
+ shadowRadius: number;
46
+ shadowOpacity: number;
47
+ shadowOffset: JBSize;
48
+ shadowColor: UIColor;
49
+ };
50
+ circleViewShadow: {
51
+ cornerRadius: number;
52
+ shadowRadius: number;
53
+ shadowOpacity: number;
54
+ shadowOffset: JBSize;
55
+ shadowColor: UIColor;
56
+ };
57
+ toastShadows: {
58
+ cornerRadius: number;
59
+ shadowRadius: number;
60
+ shadowOpacity: number;
61
+ shadowOffset: JBSize;
62
+ shadowColor: UIColor;
63
+ };
64
+ };
65
+ /**
66
+ * 在layout中使用
67
+ * 所应用的view不可以指定radius和clipTobounds,否则无效
68
+ */
69
+ export declare function setLayer(view: AllUIView, { cornerRadius, shadowRadius, shadowOpacity, shadowOffset, shadowColor, }?: {
70
+ cornerRadius?: number | undefined;
71
+ shadowRadius?: number | undefined;
72
+ shadowOpacity?: number | undefined;
73
+ shadowOffset?: JBSize | undefined;
74
+ shadowColor?: UIColor | undefined;
75
+ }): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsbox-cview",
3
- "version": "1.6.6",
3
+ "version": "1.6.7",
4
4
  "description": "为 JSBox 设计的微型框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,18 +9,32 @@
9
9
  "homepage": "https://github.com/Gandum2077/JSBox-CView",
10
10
  "bugs": "https://github.com/Gandum2077/JSBox-CView/issues",
11
11
  "main": "dist/index.js",
12
+ "types": "dist/index.d.ts",
13
+ "files": [
14
+ "dist/index.js",
15
+ "dist/index.d.ts",
16
+ "dist/components",
17
+ "dist/controller",
18
+ "dist/utils",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
12
22
  "scripts": {
13
- "build:debug": "tsc && npx browserify ${npm_config_entry:-./dist/index.js} > test.js",
14
- "build": "tsc",
15
- "format": "prettier --write ."
23
+ "build:debug": "tsc --outDir ./dist-debug && npx browserify ${npm_config_entry:-./dist-debug/index.js} > test.js",
24
+ "build": "tsc -p tsconfig.build.json",
25
+ "format": "prettier --write .",
26
+ "prepack": "npm run build"
16
27
  },
17
28
  "keywords": [],
18
29
  "author": "Gandum2077",
19
30
  "license": "MIT",
31
+ "dependencies": {
32
+ "jsbox-types": "^2.0.3"
33
+ },
20
34
  "devDependencies": {
21
35
  "@types/node": "^20.11.17",
22
36
  "browserify": "^17.0.1",
23
- "jsbox-types": "^2.0.3",
24
- "prettier": "^3.8.1"
37
+ "prettier": "^3.8.1",
38
+ "typescript": "^6.0.3"
25
39
  }
26
40
  }
package/.prettierignore DELETED
@@ -1,6 +0,0 @@
1
- node_modules
2
- dist
3
- build
4
- coverage
5
- package-lock.json
6
- tsconfig.json
package/.prettierrc DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "printWidth": 120
3
- }
@@ -1,64 +0,0 @@
1
- import { UIAlertActionStyle, UIAlertControllerStyle, UIAlertAction, UIAlertController } from "./uialert";
2
-
3
- import { l10n } from "../../utils/l10n";
4
-
5
- /**
6
- * 显示一个输入框提示
7
- *
8
- * @param title 标题
9
- * @param message 内容
10
- * @param text 输入框默认文字
11
- * @param placeholder 输入框占位符
12
- * @param type 输入框类型
13
- * @param secure 是否安全输入
14
- * @param cancelText 取消按钮文字
15
- * @param confirmText 确认按钮文字
16
- */
17
- export function inputAlert({
18
- title = "",
19
- message = "",
20
- text = "",
21
- placeholder,
22
- type = 0,
23
- secure = false,
24
- cancelText = l10n("CANCEL"),
25
- confirmText = l10n("OK"),
26
- }: {
27
- title?: string;
28
- message?: string;
29
- text?: string;
30
- placeholder?: string;
31
- type?: number;
32
- secure?: boolean;
33
- cancelText?: string;
34
- confirmText?: string;
35
- }): Promise<string> {
36
- return new Promise((resolve, reject) => {
37
- const alertVC = new UIAlertController(title, message, UIAlertControllerStyle.Alert);
38
- alertVC.addTextField({
39
- placeholder,
40
- text,
41
- type,
42
- secure,
43
- events: {
44
- shouldReturn: () => {
45
- const input = alertVC.getText(0);
46
- const isValid = input.length > 0;
47
- return isValid;
48
- },
49
- },
50
- });
51
-
52
- alertVC.addAction(new UIAlertAction(cancelText, UIAlertActionStyle.Destructive, cancelEvent));
53
- alertVC.addAction(new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent));
54
- alertVC.present();
55
-
56
- function confirmEvent() {
57
- const input: string = alertVC.getText(0);
58
- resolve(input);
59
- }
60
- function cancelEvent() {
61
- reject("cancel");
62
- }
63
- });
64
- }