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/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,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;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // 用于自定义的国际化支持
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.l10n = void 0;
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;
@@ -1,7 +1,14 @@
1
1
  "use strict";
2
2
  // 用于处理路径的工具函数
3
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;
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;
@@ -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;
@@ -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;
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsbox-cview",
3
- "version": "1.6.5",
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
- "test": "tsc && node ./dist/test.js",
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
- "jsbox-types": "^2.0.3",
23
- "prettier": "^3.8.1"
37
+ "prettier": "^3.8.1",
38
+ "typescript": "^6.0.3"
24
39
  }
25
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
- }
@@ -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
- }