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.
- package/README.md +4 -0
- package/dist/components/alert/input-alert.d.ts +22 -0
- package/dist/components/alert/input-alert.js +1 -2
- package/dist/components/alert/login-alert.d.ts +21 -0
- package/dist/components/alert/login-alert.js +1 -2
- package/dist/components/alert/plain-alert.d.ts +15 -0
- package/dist/components/alert/plain-alert.js +1 -2
- 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/custom-navigation-bar.js +7 -1
- package/dist/components/dialogs/dialog-sheet.d.ts +46 -0
- package/dist/components/dialogs/dialog-sheet.js +3 -1
- package/dist/components/dialogs/form-dialog.d.ts +15 -0
- package/dist/components/dialogs/form-dialog.js +1 -2
- package/dist/components/dialogs/list-dialog.d.ts +23 -0
- package/dist/components/dialogs/list-dialog.js +2 -3
- package/dist/components/dialogs/text-dialog.d.ts +13 -0
- package/dist/components/dialogs/text-dialog.js +1 -2
- package/dist/components/dynamic-contextmenu-view.d.ts +40 -0
- package/dist/components/dynamic-contextmenu-view.js +5 -1
- package/dist/components/dynamic-itemsize-matrix.d.ts +79 -0
- package/dist/components/dynamic-itemsize-matrix.js +18 -15
- package/dist/components/dynamic-itemsize-section-matrix.d.ts +115 -0
- package/dist/components/dynamic-itemsize-section-matrix.js +293 -0
- package/dist/components/dynamic-preference-listview.d.ts +63 -0
- package/dist/components/dynamic-preference-listview.js +25 -16
- package/dist/components/dynamic-rowheight-list.d.ts +38 -0
- package/dist/components/dynamic-rowheight-list.js +10 -3
- package/dist/components/enhanced-imageview.d.ts +41 -0
- package/dist/components/enhanced-imageview.js +1 -1
- package/dist/components/flowlayout.d.ts +63 -0
- package/dist/components/flowlayout.js +10 -13
- package/dist/components/image-pager.d.ts +49 -0
- package/dist/components/image-pager.js +6 -1
- package/dist/components/oc-webview.d.ts +64 -0
- package/dist/components/oc-webview.js +13 -5
- package/dist/components/page-control.d.ts +45 -0
- package/dist/components/page-control.js +2 -13
- package/dist/components/pageviewer-titlebar.d.ts +48 -0
- package/dist/components/pageviewer-titlebar.js +7 -13
- package/dist/components/pageviewer.d.ts +41 -0
- package/dist/components/pageviewer.js +4 -1
- package/dist/components/refresh-button.d.ts +25 -0
- package/dist/components/refresh-button.js +3 -4
- package/dist/components/rotating-view.d.ts +45 -0
- package/dist/components/rotating-view.js +10 -2
- package/dist/components/searchbar.d.ts +118 -0
- package/dist/components/searchbar.js +8 -1
- package/dist/components/sheet.d.ts +42 -0
- package/dist/components/single-views.d.ts +289 -0
- package/dist/components/single-views.js +11 -4
- 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/spinners/spinner-androidstyle.js +7 -1
- package/dist/components/static-preference-listview.d.ts +389 -0
- package/dist/components/static-preference-listview.js +13 -10
- package/dist/components/symbol-button.d.ts +39 -0
- package/dist/components/symbol-button.js +8 -1
- package/dist/components/tabbar.d.ts +140 -0
- package/dist/components/tabbar.js +8 -1
- package/dist/controller/base-controller.d.ts +125 -0
- package/dist/controller/base-controller.js +11 -11
- package/dist/controller/controller-router.d.ts +48 -0
- package/dist/controller/pageviewer-controller.d.ts +38 -0
- package/dist/controller/pageviewer-controller.js +4 -1
- package/dist/controller/presented-page-controller.d.ts +41 -0
- package/dist/controller/presented-page-controller.js +7 -9
- package/dist/controller/splitview-controller.d.ts +90 -0
- package/dist/controller/splitview-controller.js +27 -11
- package/dist/controller/tabbar-controller.d.ts +49 -0
- package/dist/controller/tabbar-controller.js +12 -15
- 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/l10n.js +1 -2
- package/dist/utils/path.d.ts +8 -0
- package/dist/utils/path.js +8 -9
- package/dist/utils/rect.d.ts +38 -0
- package/dist/utils/rect.js +8 -9
- package/dist/utils/uitools.d.ts +75 -0
- package/dist/utils/uitools.js +6 -6
- package/package.json +20 -5
- 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-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-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-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/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);
|
|
@@ -18,6 +19,7 @@ __exportStar(require("./components/base"), exports);
|
|
|
18
19
|
__exportStar(require("./components/custom-navigation-bar"), exports);
|
|
19
20
|
__exportStar(require("./components/dynamic-contextmenu-view"), exports);
|
|
20
21
|
__exportStar(require("./components/dynamic-itemsize-matrix"), exports);
|
|
22
|
+
__exportStar(require("./components/dynamic-itemsize-section-matrix"), exports);
|
|
21
23
|
__exportStar(require("./components/dynamic-preference-listview"), exports);
|
|
22
24
|
__exportStar(require("./components/dynamic-rowheight-list"), exports);
|
|
23
25
|
__exportStar(require("./components/enhanced-imageview"), exports);
|
|
@@ -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 @@
|
|
|
1
|
+
export declare function l10n(key: string): string;
|
package/dist/utils/l10n.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// 用于自定义的国际化支持
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.l10n =
|
|
4
|
+
exports.l10n = l10n;
|
|
5
5
|
const language = $device.info.language;
|
|
6
6
|
const strings = {
|
|
7
7
|
"zh-Hans": {
|
|
@@ -41,4 +41,3 @@ function l10n(key) {
|
|
|
41
41
|
const value = strings[language][key];
|
|
42
42
|
return value || key;
|
|
43
43
|
}
|
|
44
|
-
exports.l10n = l10n;
|
|
@@ -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;
|
package/dist/utils/path.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// 用于处理路径的工具函数
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.split = split;
|
|
5
|
+
exports.dirname = dirname;
|
|
6
|
+
exports.basename = basename;
|
|
7
|
+
exports.extname = extname;
|
|
8
|
+
exports.join = join;
|
|
9
|
+
exports.getCreationDate = getCreationDate;
|
|
10
|
+
exports.getModificationDate = getModificationDate;
|
|
11
|
+
exports.getFileSize = getFileSize;
|
|
5
12
|
function _splitProtocol(path) {
|
|
6
13
|
const regex = /^\w+:\/\//;
|
|
7
14
|
const result = regex.exec(path);
|
|
@@ -37,15 +44,12 @@ function split(path) {
|
|
|
37
44
|
return [protocol + remainingPath.slice(0, lastIndex), remainingPath.slice(lastIndex + 1)];
|
|
38
45
|
}
|
|
39
46
|
}
|
|
40
|
-
exports.split = split;
|
|
41
47
|
function dirname(path) {
|
|
42
48
|
return split(path)[0];
|
|
43
49
|
}
|
|
44
|
-
exports.dirname = dirname;
|
|
45
50
|
function basename(path) {
|
|
46
51
|
return split(path)[1];
|
|
47
52
|
}
|
|
48
|
-
exports.basename = basename;
|
|
49
53
|
function extname(path) {
|
|
50
54
|
const _basename = basename(path);
|
|
51
55
|
if (!_basename)
|
|
@@ -58,7 +62,6 @@ function extname(path) {
|
|
|
58
62
|
return "." + components.slice(-1)[0];
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
|
-
exports.extname = extname;
|
|
62
65
|
// 拼接目录
|
|
63
66
|
function join(...args) {
|
|
64
67
|
return args
|
|
@@ -73,7 +76,6 @@ function join(...args) {
|
|
|
73
76
|
.filter((x) => x.length)
|
|
74
77
|
.join("/");
|
|
75
78
|
}
|
|
76
|
-
exports.join = join;
|
|
77
79
|
function _getAttributes(path) {
|
|
78
80
|
if (!$file.exists(path))
|
|
79
81
|
throw new Error("invalid path");
|
|
@@ -89,16 +91,13 @@ function getCreationDate(path) {
|
|
|
89
91
|
return 0;
|
|
90
92
|
return NSFileCreationDate.getTime();
|
|
91
93
|
}
|
|
92
|
-
exports.getCreationDate = getCreationDate;
|
|
93
94
|
function getModificationDate(path) {
|
|
94
95
|
const { NSFileModificationDate } = _getAttributes(path);
|
|
95
96
|
if (!NSFileModificationDate)
|
|
96
97
|
return 0;
|
|
97
98
|
return NSFileModificationDate.getTime();
|
|
98
99
|
}
|
|
99
|
-
exports.getModificationDate = getModificationDate;
|
|
100
100
|
function getFileSize(path) {
|
|
101
101
|
const { NSFileSize } = _getAttributes(path);
|
|
102
102
|
return NSFileSize || 0;
|
|
103
103
|
}
|
|
104
|
-
exports.getFileSize = getFileSize;
|
|
@@ -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;
|
package/dist/utils/rect.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// 用于处理矩形的工具函数
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.center = center;
|
|
5
|
+
exports.containsPoint = containsPoint;
|
|
6
|
+
exports.containsRect = containsRect;
|
|
7
|
+
exports.intersects = intersects;
|
|
8
|
+
exports.intersection = intersection;
|
|
9
|
+
exports.union = union;
|
|
10
|
+
exports.translate = translate;
|
|
11
|
+
exports.inset = inset;
|
|
5
12
|
/**
|
|
6
13
|
* When called without arguments, return the center of the rectangle.
|
|
7
14
|
* When a Point is passed as an argument, the rectangle’s x and y values
|
|
@@ -16,7 +23,6 @@ function center(rect, point) {
|
|
|
16
23
|
rect.y = py - h / 2;
|
|
17
24
|
return point;
|
|
18
25
|
}
|
|
19
|
-
exports.center = center;
|
|
20
26
|
/**
|
|
21
27
|
* Return true if the given point lies within the bounds of the rectangle,
|
|
22
28
|
* false otherwise.
|
|
@@ -26,7 +32,6 @@ function containsPoint(rect, point) {
|
|
|
26
32
|
const { x: px, y: py } = point;
|
|
27
33
|
return x <= px && px <= x + w && y <= py && py <= y + h;
|
|
28
34
|
}
|
|
29
|
-
exports.containsPoint = containsPoint;
|
|
30
35
|
/**
|
|
31
36
|
* Return true if the given rectangle lies entirely within the bounds of
|
|
32
37
|
* this rectangle, false otherwise.
|
|
@@ -36,7 +41,6 @@ function containsRect(rect, otherRect) {
|
|
|
36
41
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
37
42
|
return x <= x1 && y <= y1 && x1 + w1 <= x + w && y1 + h1 <= y + h;
|
|
38
43
|
}
|
|
39
|
-
exports.containsRect = containsRect;
|
|
40
44
|
/**
|
|
41
45
|
* Return true if this rectangle intersects with the other rectangle,
|
|
42
46
|
* false otherwise.
|
|
@@ -46,7 +50,6 @@ function intersects(rect, otherRect) {
|
|
|
46
50
|
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
47
51
|
return x < x1 + w1 && x1 < x + w && y < y1 + h1 && y1 < y + h;
|
|
48
52
|
}
|
|
49
|
-
exports.intersects = intersects;
|
|
50
53
|
/**
|
|
51
54
|
* Return a $rect that corresponds to the intersection of this rectangle with
|
|
52
55
|
* the other one.
|
|
@@ -60,7 +63,6 @@ function intersection(rect, otherRect) {
|
|
|
60
63
|
const nh = Math.min(y + h, y1 + h1) - ny;
|
|
61
64
|
return $rect(nx, ny, nw, nh);
|
|
62
65
|
}
|
|
63
|
-
exports.intersection = intersection;
|
|
64
66
|
/**
|
|
65
67
|
* Return the smallest $rect that encloses both rectangles.
|
|
66
68
|
*/
|
|
@@ -73,7 +75,6 @@ function union(rect, otherRect) {
|
|
|
73
75
|
const nh = Math.max(y + h, y1 + h1) - ny;
|
|
74
76
|
return $rect(nx, ny, nw, nh);
|
|
75
77
|
}
|
|
76
|
-
exports.union = union;
|
|
77
78
|
/**
|
|
78
79
|
* Equivalent to $rect(r.x + x, r.y + y, r.w, r.h)
|
|
79
80
|
*/
|
|
@@ -82,7 +83,6 @@ function translate(rect, point) {
|
|
|
82
83
|
const { x: x1, y: y1 } = point;
|
|
83
84
|
return $rect(x + x1, y + y1, width, height);
|
|
84
85
|
}
|
|
85
|
-
exports.translate = translate;
|
|
86
86
|
/**
|
|
87
87
|
* Return a $rect that is adjusted by the given edge insets.
|
|
88
88
|
*/
|
|
@@ -91,4 +91,3 @@ function inset(rect, insets) {
|
|
|
91
91
|
const { top, left, bottom, right } = insets;
|
|
92
92
|
return $rect(x + left, y + top, width - left - right, height - top - bottom);
|
|
93
93
|
}
|
|
94
|
-
exports.inset = inset;
|
|
@@ -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/dist/utils/uitools.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// 用于UI相关的工具函数
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.layerCommonOptions = void 0;
|
|
5
|
+
exports.getWindowSize = getWindowSize;
|
|
6
|
+
exports.getTextWidth = getTextWidth;
|
|
7
|
+
exports.getTextHeight = getTextHeight;
|
|
8
|
+
exports.absoluteFrame = absoluteFrame;
|
|
9
|
+
exports.setLayer = setLayer;
|
|
5
10
|
/**
|
|
6
11
|
* 立即获得window size
|
|
7
12
|
*/
|
|
@@ -9,7 +14,6 @@ function getWindowSize() {
|
|
|
9
14
|
const window = $objc("UIWindow").$keyWindow().jsValue();
|
|
10
15
|
return window.size;
|
|
11
16
|
}
|
|
12
|
-
exports.getWindowSize = getWindowSize;
|
|
13
17
|
/**
|
|
14
18
|
* 获取单行字符串应有的宽度
|
|
15
19
|
* 默认额外添加3 inset
|
|
@@ -22,7 +26,6 @@ function getTextWidth(text, { font = $font(17), inset = 3 } = {}) {
|
|
|
22
26
|
lineSpacing: 0,
|
|
23
27
|
}).width) + inset);
|
|
24
28
|
}
|
|
25
|
-
exports.getTextWidth = getTextWidth;
|
|
26
29
|
/**
|
|
27
30
|
* 获取字符串指定宽度后应有的高度
|
|
28
31
|
* 默认额外添加3 inset
|
|
@@ -35,7 +38,6 @@ function getTextHeight(text, { width = 300, font = $font(17), inset = 3, lineSpa
|
|
|
35
38
|
lineSpacing,
|
|
36
39
|
}).height) + inset);
|
|
37
40
|
}
|
|
38
|
-
exports.getTextHeight = getTextHeight;
|
|
39
41
|
/**
|
|
40
42
|
* 计算某个view在某个上级view(若不指定则为UIWindow)上的绝对frame
|
|
41
43
|
* 此方法不考虑旋转变形等特殊情况
|
|
@@ -52,7 +54,6 @@ function absoluteFrame(view, endView) {
|
|
|
52
54
|
}
|
|
53
55
|
return frame;
|
|
54
56
|
}
|
|
55
|
-
exports.absoluteFrame = absoluteFrame;
|
|
56
57
|
exports.layerCommonOptions = {
|
|
57
58
|
none: {
|
|
58
59
|
cornerRadius: 0,
|
|
@@ -102,4 +103,3 @@ function setLayer(view, { cornerRadius = 0, shadowRadius = 0, shadowOpacity = 0,
|
|
|
102
103
|
layer.invoke("setShadowOffset", shadowOffset);
|
|
103
104
|
layer.invoke("setShadowColor", shadowColor.ocValue().invoke("CGColor"));
|
|
104
105
|
}
|
|
105
|
-
exports.setLayer = setLayer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsbox-cview",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.7",
|
|
4
4
|
"description": "为 JSBox 设计的微型框架",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,17 +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
|
-
"
|
|
14
|
-
"build": "tsc"
|
|
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"
|
|
15
27
|
},
|
|
16
28
|
"keywords": [],
|
|
17
29
|
"author": "Gandum2077",
|
|
18
30
|
"license": "MIT",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"jsbox-types": "^2.0.3"
|
|
33
|
+
},
|
|
19
34
|
"devDependencies": {
|
|
20
35
|
"@types/node": "^20.11.17",
|
|
21
36
|
"browserify": "^17.0.1",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
37
|
+
"prettier": "^3.8.1",
|
|
38
|
+
"typescript": "^6.0.3"
|
|
24
39
|
}
|
|
25
40
|
}
|
package/.prettierignore
DELETED
package/.prettierrc
DELETED
|
@@ -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
|
-
}
|
|
@@ -1,66 +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 placeholder1 输入框1的占位符
|
|
11
|
-
* @param placeholder2 输入框2的占位符
|
|
12
|
-
* @param cancelText 取消按钮文字
|
|
13
|
-
* @param confirmText 确认按钮文字
|
|
14
|
-
*/
|
|
15
|
-
export function loginAlert({
|
|
16
|
-
title = "",
|
|
17
|
-
message = "",
|
|
18
|
-
placeholder1 = "",
|
|
19
|
-
placeholder2 = "",
|
|
20
|
-
cancelText = l10n("CANCEL"),
|
|
21
|
-
confirmText = l10n("OK"),
|
|
22
|
-
}: {
|
|
23
|
-
title?: string;
|
|
24
|
-
message?: string;
|
|
25
|
-
placeholder1?: string;
|
|
26
|
-
placeholder2?: string;
|
|
27
|
-
cancelText?: string;
|
|
28
|
-
confirmText?: string;
|
|
29
|
-
} = {}): Promise<{ username: string; password: string }> {
|
|
30
|
-
return new Promise((resolve, reject) => {
|
|
31
|
-
const alertVC = new UIAlertController(title, message, UIAlertControllerStyle.Alert);
|
|
32
|
-
|
|
33
|
-
alertVC.addTextField({
|
|
34
|
-
placeholder: placeholder1,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
alertVC.addTextField({
|
|
38
|
-
placeholder: placeholder2,
|
|
39
|
-
secure: true,
|
|
40
|
-
events: {
|
|
41
|
-
shouldReturn: () => {
|
|
42
|
-
const username = alertVC.getText(0);
|
|
43
|
-
const password = alertVC.getText(1);
|
|
44
|
-
const isValid = username.length > 0 && password.length > 0;
|
|
45
|
-
return isValid;
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
alertVC.addAction(new UIAlertAction(cancelText, UIAlertActionStyle.Destructive, cancelEvent));
|
|
51
|
-
alertVC.addAction(new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent));
|
|
52
|
-
alertVC.present();
|
|
53
|
-
|
|
54
|
-
function confirmEvent() {
|
|
55
|
-
const username = alertVC.getText(0);
|
|
56
|
-
const password = alertVC.getText(1);
|
|
57
|
-
resolve({
|
|
58
|
-
username,
|
|
59
|
-
password,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function cancelEvent() {
|
|
63
|
-
reject("cancel");
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
@@ -1,39 +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 cancelText 取消按钮文字
|
|
11
|
-
* @param confirmText 确认按钮文字
|
|
12
|
-
* @returns Promise
|
|
13
|
-
*/
|
|
14
|
-
export function plainAlert({
|
|
15
|
-
title = "",
|
|
16
|
-
message = "",
|
|
17
|
-
cancelText = l10n("CANCEL"),
|
|
18
|
-
confirmText = l10n("OK"),
|
|
19
|
-
}: {
|
|
20
|
-
title?: string;
|
|
21
|
-
message?: string;
|
|
22
|
-
cancelText?: string;
|
|
23
|
-
confirmText?: string;
|
|
24
|
-
} = {}): Promise<string> {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
const alertVC = new UIAlertController(title, message, UIAlertControllerStyle.Alert);
|
|
27
|
-
|
|
28
|
-
alertVC.addAction(new UIAlertAction(cancelText, UIAlertActionStyle.Destructive, cancelEvent));
|
|
29
|
-
alertVC.addAction(new UIAlertAction(confirmText, UIAlertActionStyle.Default, confirmEvent));
|
|
30
|
-
alertVC.present();
|
|
31
|
-
|
|
32
|
-
function confirmEvent() {
|
|
33
|
-
resolve("ok");
|
|
34
|
-
}
|
|
35
|
-
function cancelEvent() {
|
|
36
|
-
reject("cancel");
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|