jsbox-cview 1.6.5 → 1.6.6

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 (43) hide show
  1. package/components/dynamic-itemsize-section-matrix.ts +363 -0
  2. package/dist/components/alert/input-alert.js +1 -2
  3. package/dist/components/alert/login-alert.js +1 -2
  4. package/dist/components/alert/plain-alert.js +1 -2
  5. package/dist/components/custom-navigation-bar.js +7 -1
  6. package/dist/components/dialogs/form-dialog.js +1 -2
  7. package/dist/components/dialogs/list-dialog.js +1 -2
  8. package/dist/components/dialogs/text-dialog.js +1 -2
  9. package/dist/components/dynamic-contextmenu-view.js +5 -1
  10. package/dist/components/dynamic-itemsize-matrix.js +17 -15
  11. package/dist/components/dynamic-itemsize-section-matrix.js +293 -0
  12. package/dist/components/dynamic-preference-listview.js +25 -16
  13. package/dist/components/dynamic-rowheight-list.js +10 -3
  14. package/dist/components/enhanced-imageview.js +1 -1
  15. package/dist/components/flowlayout.js +10 -13
  16. package/dist/components/image-pager.js +6 -1
  17. package/dist/components/oc-webview.js +13 -5
  18. package/dist/components/page-control.js +2 -13
  19. package/dist/components/pageviewer-titlebar.js +7 -13
  20. package/dist/components/pageviewer.js +4 -1
  21. package/dist/components/refresh-button.js +3 -4
  22. package/dist/components/rotating-view.js +10 -2
  23. package/dist/components/searchbar.js +8 -1
  24. package/dist/components/single-views.js +11 -4
  25. package/dist/components/spinners/spinner-androidstyle.js +7 -1
  26. package/dist/components/static-preference-listview.js +13 -10
  27. package/dist/components/symbol-button.js +8 -1
  28. package/dist/components/tabbar.js +8 -1
  29. package/dist/controller/pageviewer-controller.js +4 -1
  30. package/dist/controller/presented-page-controller.js +7 -9
  31. package/dist/controller/splitview-controller.js +23 -11
  32. package/dist/controller/tabbar-controller.js +13 -14
  33. package/dist/index.js +1 -0
  34. package/dist/test/dynamic-itemsize-section-matrix.js +138 -0
  35. package/dist/test/oc-webview.js +2 -2
  36. package/dist/utils/l10n.js +1 -2
  37. package/dist/utils/path.js +8 -9
  38. package/dist/utils/rect.js +8 -9
  39. package/dist/utils/uitools.js +6 -6
  40. package/index.ts +1 -0
  41. package/package.json +4 -3
  42. package/test/dynamic-itemsize-section-matrix.ts +142 -0
  43. package/tsconfig.json +1 -1
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  // 用于处理矩形的工具函数
3
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;
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;
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  // 用于UI相关的工具函数
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.setLayer = exports.layerCommonOptions = exports.absoluteFrame = exports.getTextHeight = exports.getTextWidth = exports.getWindowSize = void 0;
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/index.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./components/base";
2
2
  export * from "./components/custom-navigation-bar";
3
3
  export * from "./components/dynamic-contextmenu-view";
4
4
  export * from "./components/dynamic-itemsize-matrix";
5
+ export * from "./components/dynamic-itemsize-section-matrix";
5
6
  export * from "./components/dynamic-preference-listview";
6
7
  export * from "./components/dynamic-rowheight-list";
7
8
  export * from "./components/enhanced-imageview";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsbox-cview",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "为 JSBox 设计的微型框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,8 +10,9 @@
10
10
  "bugs": "https://github.com/Gandum2077/JSBox-CView/issues",
11
11
  "main": "dist/index.js",
12
12
  "scripts": {
13
- "test": "tsc && node ./dist/test.js",
14
- "build": "tsc"
13
+ "build:debug": "tsc && npx browserify ${npm_config_entry:-./dist/index.js} > test.js",
14
+ "build": "tsc",
15
+ "format": "prettier --write ."
15
16
  },
16
17
  "keywords": [],
17
18
  "author": "Gandum2077",
@@ -0,0 +1,142 @@
1
+ import {
2
+ DynamicItemSizeSectionMatrix,
3
+ DynamicItemSizeSectionMatrixSection,
4
+ } from "../components/dynamic-itemsize-section-matrix";
5
+
6
+ const makeItem = (sectionName: string, index: number) => {
7
+ return {
8
+ symbol: { symbol: index % 2 === 0 ? "sparkles" : "square.grid.2x2" },
9
+ title: { text: `${sectionName} ${index}` },
10
+ subtitle: { text: `Item index ${index}` },
11
+ badge: { text: `${index}` },
12
+ };
13
+ };
14
+
15
+ const sections: DynamicItemSizeSectionMatrixSection[] = [
16
+ {
17
+ title: "Pinned",
18
+ items: [makeItem("Pinned", 1), makeItem("Pinned", 2), makeItem("Pinned", 3)],
19
+ },
20
+ {
21
+ title: "Long Section Title To Verify The Custom Title Cell Uses Dynamic Height\nLine 2\nLine 3",
22
+ items: [makeItem("Recent", 1), makeItem("Recent", 2), makeItem("Recent", 3), makeItem("Recent", 4)],
23
+ },
24
+ {
25
+ title: "",
26
+ items: [makeItem("Untitled", 1), makeItem("Untitled", 2)],
27
+ },
28
+ ];
29
+
30
+ const matrix = new DynamicItemSizeSectionMatrix({
31
+ props: {
32
+ spacing: 8,
33
+ minItemWidth: $device.isIpad ? 180 : 142,
34
+ maxColumns: $device.isIpad ? 4 : 2,
35
+ data: sections,
36
+ template: {
37
+ views: [
38
+ {
39
+ type: "view",
40
+ props: {
41
+ bgcolor: $color("yellow"),
42
+ cornerRadius: 8,
43
+ },
44
+ layout: $layout.fill,
45
+ views: [
46
+ {
47
+ type: "image",
48
+ props: {
49
+ id: "symbol",
50
+ contentMode: $contentMode.scaleAspectFit,
51
+ tintColor: $color("tint"),
52
+ },
53
+ layout: (make, view) => {
54
+ make.left.top.inset(12);
55
+ make.size.equalTo($size(32, 32));
56
+ },
57
+ },
58
+ {
59
+ type: "label",
60
+ props: {
61
+ id: "badge",
62
+ align: $align.center,
63
+ font: $font(12),
64
+ textColor: $color("white"),
65
+ bgcolor: $color("tint"),
66
+ cornerRadius: 10,
67
+ },
68
+ layout: (make, view) => {
69
+ make.top.right.inset(12);
70
+ make.size.equalTo($size(28, 20));
71
+ },
72
+ },
73
+ {
74
+ type: "label",
75
+ props: {
76
+ id: "title",
77
+ font: $font("bold", 15),
78
+ textColor: $color("primaryText"),
79
+ },
80
+ layout: (make, view) => {
81
+ make.left.right.inset(12);
82
+ make.top.equalTo(view.prev.prev.bottom).offset(10);
83
+ make.height.equalTo(20);
84
+ },
85
+ },
86
+ {
87
+ type: "label",
88
+ props: {
89
+ id: "subtitle",
90
+ font: $font(12),
91
+ textColor: $color("secondaryText"),
92
+ },
93
+ layout: (make, view) => {
94
+ make.left.right.inset(12);
95
+ make.top.equalTo(view.prev.bottom).offset(4);
96
+ make.bottom.inset(12);
97
+ },
98
+ },
99
+ ],
100
+ },
101
+ ],
102
+ },
103
+ },
104
+ layout: $layout.fill,
105
+ events: {
106
+ itemHeight: (width) => Math.max(112, width * 0.72),
107
+ didSelect: (sender, indexPath, data) => {
108
+ const section = matrix.data[indexPath.section];
109
+ const title = (data.title as { text: string }).text;
110
+ $ui.toast(`${section.title || "Untitled"} / ${title}`);
111
+ },
112
+ didLongPress: (sender, indexPath, data) => {
113
+ const title = (data.title as { text: string }).text;
114
+ $ui.alert(`Long pressed ${title}`);
115
+ },
116
+ },
117
+ });
118
+
119
+ $ui.render({
120
+ props: {
121
+ navButtons: [
122
+ {
123
+ symbol: "plus",
124
+ handler: () => {
125
+ const nextIndex = matrix.data[0].items.length + 1;
126
+ matrix.insert({
127
+ indexPath: $indexPath(0, matrix.data[0].items.length),
128
+ value: makeItem("Pinned", nextIndex),
129
+ });
130
+ },
131
+ },
132
+ {
133
+ symbol: "trash",
134
+ handler: () => {
135
+ if (matrix.data[0].items.length === 0) return;
136
+ matrix.delete($indexPath(0, matrix.data[0].items.length - 1));
137
+ },
138
+ },
139
+ ],
140
+ },
141
+ views: [matrix.definition],
142
+ });
package/tsconfig.json CHANGED
@@ -11,7 +11,7 @@
11
11
  // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
12
 
13
13
  /* Language and Environment */
14
- "target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
14
+ "target": "es2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
15
  // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
16
  // "jsx": "preserve", /* Specify what JSX code is generated. */
17
17
  // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */