jsbox-cview 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/alert/input-alert.js +39 -0
- package/dist/components/alert/login-alert.js +45 -0
- package/dist/components/alert/plain-alert.js +25 -0
- package/dist/components/alert/uialert.js +89 -0
- package/dist/components/artificial-flowlayout.js +258 -0
- package/dist/components/base.js +43 -0
- package/dist/components/custom-navigation-bar.js +519 -0
- package/dist/components/dialogs/dialog-sheet.js +67 -0
- package/dist/components/dialogs/form-dialog.js +24 -0
- package/dist/components/dialogs/list-dialog.js +87 -0
- package/dist/components/dialogs/text-dialog.js +31 -0
- package/dist/components/dynamic-itemsize-matrix.js +129 -0
- package/dist/components/dynamic-preference-listview.js +557 -0
- package/dist/components/dynamic-rowheight-list.js +44 -0
- package/dist/components/enhanced-imageview.js +114 -0
- package/dist/components/image-pager.js +157 -0
- package/dist/components/page-control.js +76 -0
- package/dist/components/pageviewer-titlebar.js +143 -0
- package/dist/components/pageviewer.js +96 -0
- package/dist/components/rotating-view.js +102 -0
- package/dist/components/searchbar.js +322 -0
- package/dist/components/sheet.js +82 -0
- package/dist/components/single-views.js +429 -0
- package/dist/components/spinners/loading-double-rings.js +104 -0
- package/dist/components/spinners/loading-dual-ring.js +82 -0
- package/dist/components/spinners/loading-wedges.js +104 -0
- package/dist/components/spinners/spinner-androidstyle.js +248 -0
- package/dist/components/static-preference-listview.js +798 -0
- package/dist/components/symbol-button.js +79 -0
- package/dist/components/tabbar.js +357 -0
- package/dist/controller/base-controller.js +178 -0
- package/dist/controller/controller-router.js +68 -0
- package/dist/controller/pageviewer-controller.js +63 -0
- package/dist/controller/presented-page-controller.js +48 -0
- package/dist/controller/splitview-controller.js +252 -0
- package/dist/controller/tabbar-controller.js +74 -0
- package/dist/index.js +58 -0
- package/dist/test.js +1 -0
- package/dist/utils/colors.js +15 -0
- package/dist/utils/cvid.js +28 -0
- package/dist/utils/l10n.js +44 -0
- package/dist/utils/path.js +107 -0
- package/dist/utils/rect.js +72 -0
- package/dist/utils/uitools.js +95 -0
- package/index.ts +42 -0
- package/package.json +4 -3
- package/tsconfig.json +5 -3
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 用于处理路径的工具函数
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getFileSize = exports.getModificationDate = exports.getCreationDate = exports.join = exports.extname = exports.basename = exports.dirname = exports.split = void 0;
|
|
5
|
+
function _splitProtocol(path) {
|
|
6
|
+
const regex = /^\w+:\/\//;
|
|
7
|
+
const result = regex.exec(path);
|
|
8
|
+
if (result) {
|
|
9
|
+
const protocol = result[0];
|
|
10
|
+
return [protocol, path.slice(protocol.length)];
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return ["", path];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// 正规化
|
|
17
|
+
function _normalize(path) {
|
|
18
|
+
if (!path)
|
|
19
|
+
return "";
|
|
20
|
+
path = path.trim();
|
|
21
|
+
if (!path)
|
|
22
|
+
return "";
|
|
23
|
+
const [protocol, remainingPath] = _splitProtocol(path);
|
|
24
|
+
return protocol + remainingPath.replace(/\/{2,}/g, "/");
|
|
25
|
+
}
|
|
26
|
+
function split(path) {
|
|
27
|
+
path = _normalize(path);
|
|
28
|
+
const [protocol, remainingPath] = _splitProtocol(path);
|
|
29
|
+
const lastIndex = remainingPath.lastIndexOf("/");
|
|
30
|
+
if (lastIndex === -1) {
|
|
31
|
+
return [protocol, remainingPath];
|
|
32
|
+
}
|
|
33
|
+
else if (lastIndex === 0) {
|
|
34
|
+
return [protocol + "/", remainingPath.slice(1)];
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return [
|
|
38
|
+
protocol + remainingPath.slice(0, lastIndex),
|
|
39
|
+
remainingPath.slice(lastIndex + 1)
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.split = split;
|
|
44
|
+
function dirname(path) {
|
|
45
|
+
return split(path)[0];
|
|
46
|
+
}
|
|
47
|
+
exports.dirname = dirname;
|
|
48
|
+
function basename(path) {
|
|
49
|
+
return split(path)[1];
|
|
50
|
+
}
|
|
51
|
+
exports.basename = basename;
|
|
52
|
+
function extname(path) {
|
|
53
|
+
const _basename = basename(path);
|
|
54
|
+
if (!_basename)
|
|
55
|
+
return "";
|
|
56
|
+
const components = _basename.split(".");
|
|
57
|
+
if (components.length === 1) {
|
|
58
|
+
return "";
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
return "." + components.slice(-1)[0];
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.extname = extname;
|
|
65
|
+
// 拼接目录
|
|
66
|
+
function join(...args) {
|
|
67
|
+
return args
|
|
68
|
+
.map((part, i) => {
|
|
69
|
+
if (i === 0) {
|
|
70
|
+
return part.trim().replace(/[/]*$/g, "");
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return part.trim().replace(/(^[/]*|[/]*$)/g, "");
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.filter(x => x.length)
|
|
77
|
+
.join("/");
|
|
78
|
+
}
|
|
79
|
+
exports.join = join;
|
|
80
|
+
function _getAttributes(path) {
|
|
81
|
+
if (!$file.exists(path))
|
|
82
|
+
throw new Error("invalid path");
|
|
83
|
+
path = $file.absolutePath(path);
|
|
84
|
+
const attributesOfItemAtPath = $objc("NSFileManager")
|
|
85
|
+
.invoke("defaultManager")
|
|
86
|
+
.invoke("attributesOfItemAtPath:error", path, null);
|
|
87
|
+
return attributesOfItemAtPath.jsValue();
|
|
88
|
+
}
|
|
89
|
+
function getCreationDate(path) {
|
|
90
|
+
const { NSFileCreationDate } = _getAttributes(path);
|
|
91
|
+
if (!NSFileCreationDate)
|
|
92
|
+
return 0;
|
|
93
|
+
return NSFileCreationDate.getTime();
|
|
94
|
+
}
|
|
95
|
+
exports.getCreationDate = getCreationDate;
|
|
96
|
+
function getModificationDate(path) {
|
|
97
|
+
const { NSFileModificationDate } = _getAttributes(path);
|
|
98
|
+
if (!NSFileModificationDate)
|
|
99
|
+
return 0;
|
|
100
|
+
return NSFileModificationDate.getTime();
|
|
101
|
+
}
|
|
102
|
+
exports.getModificationDate = getModificationDate;
|
|
103
|
+
function getFileSize(path) {
|
|
104
|
+
const { NSFileSize } = _getAttributes(path);
|
|
105
|
+
return NSFileSize || 0;
|
|
106
|
+
}
|
|
107
|
+
exports.getFileSize = getFileSize;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 用于处理矩形的工具函数
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.inset = exports.translate = exports.union = exports.intersection = exports.intersects = exports.containsRect = exports.containsPoint = exports.center = void 0;
|
|
5
|
+
// When called without arguments, return the center of the rectangle. When a Point is passed as an argument, the rectangle’s x and y values are adjusted, so that the new center of the rectangle is p.
|
|
6
|
+
function center(rect, point) {
|
|
7
|
+
const { x = 0, y = 0, width: w, height: h } = rect;
|
|
8
|
+
if (!point)
|
|
9
|
+
return $point(x + w / 2, y + h / 2);
|
|
10
|
+
const { x: px, y: py } = point;
|
|
11
|
+
rect.x = px - w / 2;
|
|
12
|
+
rect.y = py - h / 2;
|
|
13
|
+
return point;
|
|
14
|
+
}
|
|
15
|
+
exports.center = center;
|
|
16
|
+
// Return true if the given point lies within the bounds of the rectangle, false otherwise.
|
|
17
|
+
function containsPoint(rect, point) {
|
|
18
|
+
const { x, y, width: w, height: h } = rect;
|
|
19
|
+
const { x: px, y: py } = point;
|
|
20
|
+
return x <= px && px <= x + w && y <= py && py <= y + h;
|
|
21
|
+
}
|
|
22
|
+
exports.containsPoint = containsPoint;
|
|
23
|
+
// Return true if the given rectangle lies entirely within the bounds of this rectangle, false otherwise.
|
|
24
|
+
function containsRect(rect, otherRect) {
|
|
25
|
+
const { x, y, width: w, height: h } = rect;
|
|
26
|
+
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
27
|
+
return x <= x1 && y <= y1 && x1 + w1 <= x + w && y1 + h1 <= y + h;
|
|
28
|
+
}
|
|
29
|
+
exports.containsRect = containsRect;
|
|
30
|
+
// Return true if this rectangle intersects with the other rectangle, false otherwise.
|
|
31
|
+
function intersects(rect, otherRect) {
|
|
32
|
+
const { x, y, width: w, height: h } = rect;
|
|
33
|
+
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
34
|
+
return x < x1 + w1 && x1 < x + w && y < y1 + h1 && y1 < y + h;
|
|
35
|
+
}
|
|
36
|
+
exports.intersects = intersects;
|
|
37
|
+
// Return a $rect that corresponds to the intersection of this rectangle with the other one.
|
|
38
|
+
function intersection(rect, otherRect) {
|
|
39
|
+
const { x, y, width: w, height: h } = rect;
|
|
40
|
+
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
41
|
+
const nx = Math.max(x, x1);
|
|
42
|
+
const nw = Math.min(x + w, x1 + w1) - nx;
|
|
43
|
+
const ny = Math.max(y, y1);
|
|
44
|
+
const nh = Math.min(y + h, y1 + h1) - ny;
|
|
45
|
+
return $rect(nx, ny, nw, nh);
|
|
46
|
+
}
|
|
47
|
+
exports.intersection = intersection;
|
|
48
|
+
// Return the smallest $rect that encloses both rectangles.
|
|
49
|
+
function union(rect, otherRect) {
|
|
50
|
+
const { x, y, width: w, height: h } = rect;
|
|
51
|
+
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
52
|
+
const nx = Math.min(x, x1);
|
|
53
|
+
const nw = Math.max(x + w, x1 + w1) - nx;
|
|
54
|
+
const ny = Math.min(y, y1);
|
|
55
|
+
const nh = Math.max(y + h, y1 + h1) - ny;
|
|
56
|
+
return $rect(nx, ny, nw, nh);
|
|
57
|
+
}
|
|
58
|
+
exports.union = union;
|
|
59
|
+
// Equivalent to $rect(r.x + x, r.y + y, r.w, r.h)
|
|
60
|
+
function translate(rect, point) {
|
|
61
|
+
const { x, y, width, height } = rect;
|
|
62
|
+
const { x: x1, y: y1 } = point;
|
|
63
|
+
return $rect(x + x1, y + y1, width, height);
|
|
64
|
+
}
|
|
65
|
+
exports.translate = translate;
|
|
66
|
+
// Return a $rect that is adjusted by the given edge insets.
|
|
67
|
+
function inset(rect, insets) {
|
|
68
|
+
const { x, y, width, height } = rect;
|
|
69
|
+
const { top, left, bottom, right } = insets;
|
|
70
|
+
return $rect(x + left, y + top, width - left - right, height - top - bottom);
|
|
71
|
+
}
|
|
72
|
+
exports.inset = inset;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// 用于UI相关的工具函数
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.setLayer = exports.layerCommonOptions = exports.absoluteFrame = exports.getTextHeight = exports.getTextWidth = exports.getWindowSize = void 0;
|
|
5
|
+
// 立即获得window size
|
|
6
|
+
function getWindowSize() {
|
|
7
|
+
const window = $objc("UIWindow").$keyWindow().jsValue();
|
|
8
|
+
return window.size;
|
|
9
|
+
}
|
|
10
|
+
exports.getWindowSize = getWindowSize;
|
|
11
|
+
// 获取单行字符串应有的宽度
|
|
12
|
+
// 默认额外添加3 inset
|
|
13
|
+
function getTextWidth(text, { font = $font(17), inset = 3 } = {}) {
|
|
14
|
+
return (Math.ceil($text.sizeThatFits({
|
|
15
|
+
text,
|
|
16
|
+
width: 10000,
|
|
17
|
+
font,
|
|
18
|
+
lineSpacing: 0
|
|
19
|
+
}).width) + inset);
|
|
20
|
+
}
|
|
21
|
+
exports.getTextWidth = getTextWidth;
|
|
22
|
+
// 获取字符串指定宽度后应有的高度
|
|
23
|
+
// 默认额外添加3 inset
|
|
24
|
+
function getTextHeight(text, { width = 300, font = $font(17), inset = 3 } = {}) {
|
|
25
|
+
return (Math.ceil($text.sizeThatFits({
|
|
26
|
+
text,
|
|
27
|
+
width,
|
|
28
|
+
font,
|
|
29
|
+
lineSpacing: 0
|
|
30
|
+
}).height) + inset);
|
|
31
|
+
}
|
|
32
|
+
exports.getTextHeight = getTextHeight;
|
|
33
|
+
// 计算某个view在某个上级view(若不指定则为UIWindow)上的绝对frame
|
|
34
|
+
// 此方法不考虑旋转变形等特殊情况
|
|
35
|
+
function absoluteFrame(view, endView) {
|
|
36
|
+
const frame = view.frame;
|
|
37
|
+
let superView = view.super;
|
|
38
|
+
while (superView) {
|
|
39
|
+
frame.x += superView.frame.x - superView.bounds.x;
|
|
40
|
+
frame.y += superView.frame.y - superView.bounds.y;
|
|
41
|
+
if (endView && superView === endView)
|
|
42
|
+
break;
|
|
43
|
+
superView = superView.super;
|
|
44
|
+
}
|
|
45
|
+
return frame;
|
|
46
|
+
}
|
|
47
|
+
exports.absoluteFrame = absoluteFrame;
|
|
48
|
+
exports.layerCommonOptions = {
|
|
49
|
+
none: {
|
|
50
|
+
cornerRadius: 0,
|
|
51
|
+
shadowRadius: 0,
|
|
52
|
+
shadowOpacity: 0,
|
|
53
|
+
shadowOffset: $size(0, 0),
|
|
54
|
+
shadowColor: $color("clear")
|
|
55
|
+
},
|
|
56
|
+
roundedShadow: {
|
|
57
|
+
cornerRadius: 12,
|
|
58
|
+
shadowRadius: 10,
|
|
59
|
+
shadowOpacity: 1,
|
|
60
|
+
shadowOffset: $size(0, 0),
|
|
61
|
+
shadowColor: $color("black")
|
|
62
|
+
},
|
|
63
|
+
textShadow: {
|
|
64
|
+
cornerRadius: 0,
|
|
65
|
+
shadowRadius: 1.2,
|
|
66
|
+
shadowOpacity: 1,
|
|
67
|
+
shadowOffset: $size(0, 1),
|
|
68
|
+
shadowColor: $color("black")
|
|
69
|
+
},
|
|
70
|
+
circleViewShadow: {
|
|
71
|
+
cornerRadius: 25,
|
|
72
|
+
shadowRadius: 3,
|
|
73
|
+
shadowOpacity: 0.6,
|
|
74
|
+
shadowOffset: $size(0, 3),
|
|
75
|
+
shadowColor: $color("black")
|
|
76
|
+
},
|
|
77
|
+
toastShadows: {
|
|
78
|
+
cornerRadius: 15,
|
|
79
|
+
shadowRadius: 8,
|
|
80
|
+
shadowOpacity: 0.35,
|
|
81
|
+
shadowOffset: $size(0, 0),
|
|
82
|
+
shadowColor: $color("black")
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
// 在layout中使用
|
|
86
|
+
// 所应用的view不可以指定radius和clipTobounds,否则无效
|
|
87
|
+
function setLayer(view, { cornerRadius = 0, shadowRadius = 0, shadowOpacity = 0, shadowOffset = $size(0, 0), shadowColor = $color("clear") } = {}) {
|
|
88
|
+
const layer = view.ocValue().invoke("layer");
|
|
89
|
+
layer.invoke("setCornerRadius", cornerRadius);
|
|
90
|
+
layer.invoke("setShadowRadius", shadowRadius);
|
|
91
|
+
layer.invoke("setShadowOpacity", shadowOpacity);
|
|
92
|
+
layer.invoke("setShadowOffset", shadowOffset);
|
|
93
|
+
layer.invoke("setShadowColor", shadowColor.ocValue().invoke("CGColor"));
|
|
94
|
+
}
|
|
95
|
+
exports.setLayer = setLayer;
|
package/index.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export * from './components/artificial-flowlayout';
|
|
2
|
+
export * from './components/base';
|
|
3
|
+
export * from './components/custom-navigation-bar';
|
|
4
|
+
export * from './components/dynamic-itemsize-matrix';
|
|
5
|
+
export * from './components/dynamic-preference-listview';
|
|
6
|
+
export * from './components/dynamic-rowheight-list';
|
|
7
|
+
export * from './components/enhanced-imageview';
|
|
8
|
+
export * from './components/image-pager';
|
|
9
|
+
export * from './components/page-control';
|
|
10
|
+
export * from './components/pageviewer-titlebar';
|
|
11
|
+
export * from './components/pageviewer';
|
|
12
|
+
export * from './components/rotating-view';
|
|
13
|
+
export * from './components/searchbar';
|
|
14
|
+
export * from './components/sheet';
|
|
15
|
+
export * from './components/single-views';
|
|
16
|
+
export * from './components/static-preference-listview';
|
|
17
|
+
export * from './components/symbol-button';
|
|
18
|
+
export * from './components/tabbar';
|
|
19
|
+
export * from './controller/base-controller';
|
|
20
|
+
export * from './controller/controller-router';
|
|
21
|
+
export * from './controller/pageviewer-controller';
|
|
22
|
+
export * from './controller/presented-page-controller';
|
|
23
|
+
export * from './controller/splitview-controller';
|
|
24
|
+
export * from './controller/tabbar-controller';
|
|
25
|
+
export * from './utils/colors';
|
|
26
|
+
export * from './utils/cvid';
|
|
27
|
+
export * from './utils/l10n';
|
|
28
|
+
export * from './utils/path';
|
|
29
|
+
export * from './utils/rect';
|
|
30
|
+
export * from './utils/uitools';
|
|
31
|
+
export * from './components/alert/input-alert';
|
|
32
|
+
export * from './components/alert/login-alert';
|
|
33
|
+
export * from './components/alert/plain-alert';
|
|
34
|
+
export * from './components/alert/uialert';
|
|
35
|
+
export * from './components/dialogs/dialog-sheet';
|
|
36
|
+
export * from './components/dialogs/form-dialog';
|
|
37
|
+
export * from './components/dialogs/list-dialog';
|
|
38
|
+
export * from './components/dialogs/text-dialog';
|
|
39
|
+
export * from './components/spinners/loading-double-rings';
|
|
40
|
+
export * from './components/spinners/loading-dual-ring';
|
|
41
|
+
export * from './components/spinners/loading-wedges';
|
|
42
|
+
export * from './components/spinners/spinner-androidstyle';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsbox-cview",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "为 JSBox 设计的微型框架",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
},
|
|
9
9
|
"homepage": "https://github.com/Gandum2077/JSBox-CView",
|
|
10
10
|
"bugs": "https://github.com/Gandum2077/JSBox-CView/issues",
|
|
11
|
-
"main": "index.js",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "tsc && node test.js",
|
|
13
|
+
"test": "tsc && node ./dist/test.js",
|
|
14
14
|
"build": "tsc"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [],
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^20.11.17",
|
|
21
|
+
"ctix": "^2.3.0",
|
|
21
22
|
"jsbox-types": "^1.0.19"
|
|
22
23
|
}
|
|
23
24
|
}
|
package/tsconfig.json
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
56
|
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
57
|
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
"outDir": "./
|
|
58
|
+
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
59
59
|
// "removeComments": true, /* Disable emitting comments. */
|
|
60
60
|
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
61
|
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
@@ -110,12 +110,14 @@
|
|
|
110
110
|
"node_modules/jsbox-types/*.d.ts",
|
|
111
111
|
"node_modules/jsbox-types/*/*.d.ts",
|
|
112
112
|
"test.ts",
|
|
113
|
+
"index.ts",
|
|
113
114
|
"utils/*.ts",
|
|
114
115
|
"components/*.ts",
|
|
115
116
|
"components/*/*.ts",
|
|
116
|
-
"controller/*.ts"
|
|
117
|
+
"controller/*.ts"
|
|
117
118
|
],
|
|
118
119
|
"files": [
|
|
119
|
-
"test.ts"
|
|
120
|
+
"test.ts",
|
|
121
|
+
"index.ts"
|
|
120
122
|
]
|
|
121
123
|
}
|