jsbox-cview 1.5.25 → 1.5.26

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.
@@ -3,7 +3,7 @@ import { cvid } from "../utils/cvid";
3
3
 
4
4
  type MenuItem = {
5
5
  title: string;
6
- symbol: string;
6
+ symbol?: string;
7
7
  handler: () => void;
8
8
  destructive?: boolean;
9
9
  };
@@ -28,7 +28,7 @@ export class DynamicContextMenuView extends Base<
28
28
  UiTypes.RuntimeOptions
29
29
  > {
30
30
  private generateContextMenu: (sender: UIView) => {
31
- title: string;
31
+ title?: string;
32
32
  items: MenuItem[];
33
33
  };
34
34
  private _ocClassName: string;
@@ -44,7 +44,7 @@ export class DynamicContextMenuView extends Base<
44
44
  }: {
45
45
  classname?: string;
46
46
  generateContextMenu: (sender: UIView) => {
47
- title: string;
47
+ title?: string;
48
48
  items: MenuItem[];
49
49
  };
50
50
  props: UiTypes.BaseViewProps;
@@ -93,7 +93,7 @@ export class DynamicContextMenuView extends Base<
93
93
  title,
94
94
  items,
95
95
  }: {
96
- title: string;
96
+ title?: string;
97
97
  items: MenuItem[];
98
98
  }) {
99
99
  return $objc(
@@ -107,14 +107,14 @@ export class DynamicContextMenuView extends Base<
107
107
  "UIAction"
108
108
  ).$actionWithTitle_image_identifier_handler(
109
109
  item.title,
110
- item.symbol,
110
+ item.symbol || null,
111
111
  null,
112
112
  $block("void, UIAction *", () => item.handler())
113
113
  );
114
114
  if (item.destructive) action.$setAttributes(1 << 1);
115
115
  return action;
116
116
  });
117
- return $objc("UIMenu").$menuWithTitle_children(title, actions);
117
+ return title ? $objc("UIMenu").$menuWithTitle_children(title, actions) : $objc("UIMenu").$menuWithChildren(actions);
118
118
  })
119
119
  );
120
120
  }
@@ -51,12 +51,12 @@ class DynamicContextMenuView extends base_1.Base {
51
51
  createContextMenuConfiguration({ title, items, }) {
52
52
  return $objc("UIContextMenuConfiguration").$configurationWithIdentifier_previewProvider_actionProvider(null, null, $block("UIMenu *, NSArray *", () => {
53
53
  const actions = items.map((item) => {
54
- const action = $objc("UIAction").$actionWithTitle_image_identifier_handler(item.title, item.symbol, null, $block("void, UIAction *", () => item.handler()));
54
+ const action = $objc("UIAction").$actionWithTitle_image_identifier_handler(item.title, item.symbol || null, null, $block("void, UIAction *", () => item.handler()));
55
55
  if (item.destructive)
56
56
  action.$setAttributes(1 << 1);
57
57
  return action;
58
58
  });
59
- return $objc("UIMenu").$menuWithTitle_children(title, actions);
59
+ return title ? $objc("UIMenu").$menuWithTitle_children(title, actions) : $objc("UIMenu").$menuWithChildren(actions);
60
60
  }));
61
61
  }
62
62
  createRuntimeView() {
@@ -24,18 +24,15 @@ const menuList = [
24
24
  ],
25
25
  },
26
26
  {
27
- title: "菜单2",
28
27
  items: [
29
28
  {
30
29
  title: "变成菜单1",
31
- symbol: "plus",
32
30
  handler: () => {
33
31
  menuIndex = 0;
34
32
  },
35
33
  },
36
34
  {
37
35
  title: "变成菜单2",
38
- symbol: "plus",
39
36
  handler: () => {
40
37
  menuIndex = 1;
41
38
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsbox-cview",
3
- "version": "1.5.25",
3
+ "version": "1.5.26",
4
4
  "description": "为 JSBox 设计的微型框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,18 +23,15 @@ const menuList = [
23
23
  ],
24
24
  },
25
25
  {
26
- title: "菜单2",
27
26
  items: [
28
27
  {
29
28
  title: "变成菜单1",
30
- symbol: "plus",
31
29
  handler: () => {
32
30
  menuIndex = 0;
33
31
  },
34
32
  },
35
33
  {
36
34
  title: "变成菜单2",
37
- symbol: "plus",
38
35
  handler: () => {
39
36
  menuIndex = 1;
40
37
  },