@nativescript-community/ui-menu 0.0.0-stage → 1.0.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/CHANGELOG.md +11 -0
- package/LICENSE +201 -0
- package/README.md +201 -2
- package/index-common.d.ts +56 -0
- package/index-common.js +18 -0
- package/index-common.js.map +1 -0
- package/index.android.d.ts +7 -0
- package/index.android.js +136 -0
- package/index.android.js.map +1 -0
- package/index.d.ts +29 -0
- package/index.ios.d.ts +11 -0
- package/index.ios.js +217 -0
- package/index.ios.js.map +1 -0
- package/package.json +49 -5
- package/platforms/android/native-api-usage.json +17 -0
- package/platforms/ios/native-api-usage.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## 1.0.0 (2026-10-18)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **menu:** add ui-menu (Material PopupMenu on Android, native UIMenu on iOS) ([d9ecf90](https://github.com/nativescript-community/ui-native-components/commit/d9ecf9052e8c8869b780e27fb1d44e1f4ef813e9))
|
|
11
|
+
* native-api-usage.json for every package on Android and iOS ([cfd7dcc](https://github.com/nativescript-community/ui-native-components/commit/cfd7dcc4b996b02319cfacee233bc56c29df70e4))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright {yyyy} {name of copyright owner}
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,202 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️-->
|
|
2
|
+
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
3
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
4
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
5
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
6
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
7
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
8
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
9
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
10
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
11
|
+
DO NOT EDIT THIS READEME DIRECTLY! Edit "bluesprint.md" instead.
|
|
12
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
13
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
14
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
15
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
16
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
17
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
18
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
19
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
20
|
+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
|
21
|
+
<h1 align="center">@nativescript-community/ui-menu</h1>
|
|
22
|
+
<p align="center">
|
|
23
|
+
<a href="https://npmcharts.com/compare/@nativescript-community/ui-menu?minimal=true"><img alt="Downloads per month" src="https://img.shields.io/npm/dm/@nativescript-community/ui-menu.svg" height="20"/></a>
|
|
24
|
+
<a href="https://www.npmjs.com/package/@nativescript-community/ui-menu"><img alt="NPM Version" src="https://img.shields.io/npm/v/@nativescript-community/ui-menu.svg" height="20"/></a>
|
|
25
|
+
</p>
|
|
2
26
|
|
|
3
|
-
|
|
27
|
+
<p align="center">
|
|
28
|
+
<b>Menus: Material PopupMenu on Android, native UIMenu (pull-down and context menus) on iOS.</b></br>
|
|
29
|
+
<sub><sub>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<br />
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
| iOS | Android |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| <img src="https://github.com/nativescript-community/ui-native-components/raw/master/images/ui-menu-ios.png" height="500" /> | <img src="https://github.com/nativescript-community/ui-native-components/raw/master/images/ui-menu-android.png" height="500" /> |
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
[](#table-of-contents)
|
|
41
|
+
|
|
42
|
+
## Table of Contents
|
|
43
|
+
|
|
44
|
+
* [Installation](#installation)
|
|
45
|
+
* [Usage](#usage)
|
|
46
|
+
* [API](#api)
|
|
47
|
+
* [Demos and Development](#demos-and-development)
|
|
48
|
+
* [Repo Setup](#repo-setup)
|
|
49
|
+
* [Build](#build)
|
|
50
|
+
* [Demos](#demos)
|
|
51
|
+
* [Contributing](#contributing)
|
|
52
|
+
* [Update repo ](#update-repo-)
|
|
53
|
+
* [Update readme ](#update-readme-)
|
|
54
|
+
* [Update doc ](#update-doc-)
|
|
55
|
+
* [Publish](#publish)
|
|
56
|
+
* [modifying submodules](#modifying-submodules)
|
|
57
|
+
* [Questions](#questions)
|
|
58
|
+
|
|
59
|
+
| Android | iOS |
|
|
60
|
+
|---|---|
|
|
61
|
+
| `PopupMenu` | `UIMenu`, `UIContextMenuInteraction` |
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
[](#installation)
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install @nativescript-community/ui-menu
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The Android components use **Material 3**: see the [repository README](https://github.com/nativescript-community/ui-native-components#installation) for the theme.
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
[](#usage)
|
|
76
|
+
|
|
77
|
+
## Usage
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { showMenu, setContextMenu } from '@nativescript-community/ui-menu';
|
|
81
|
+
|
|
82
|
+
const item = await showMenu({
|
|
83
|
+
anchor: button,
|
|
84
|
+
placement: { horizontal: 'end', vertical: 'below' },
|
|
85
|
+
items: [
|
|
86
|
+
{ id: 'copy', title: 'Copy', icon: 'sys://doc.on.doc', subtitle: 'to the clipboard' },
|
|
87
|
+
{ title: 'Share', items: [{ id: 'link', title: 'Link' }] },
|
|
88
|
+
{ separator: true },
|
|
89
|
+
{ id: 'delete', title: 'Delete', destructive: true }
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// long press
|
|
94
|
+
const remove = setContextMenu(label, { items, onSelect: (item) => {} });
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
[](#api)
|
|
99
|
+
|
|
100
|
+
## API
|
|
101
|
+
|
|
102
|
+
Menu items: `id`, `title`, `subtitle`, `icon` (resource, file, `sys://`, an ImageSource or a FormattedString), `checked`, `destructive`, `disabled`, `items` (submenu), `separator`, `onSelect`.
|
|
103
|
+
`showMenu` resolves with the selected item, or `undefined` when dismissed. `placement`: `horizontal` `start`/`center`/`end`, `vertical` `auto`/`above`/`below`.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
[](#demos-and-development)
|
|
107
|
+
|
|
108
|
+
## Demos and Development
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
### Repo Setup
|
|
112
|
+
|
|
113
|
+
The repo uses submodules. If you did not clone with ` --recursive` then you need to call
|
|
114
|
+
```
|
|
115
|
+
git submodule update --init
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The package manager used to install and link dependencies must be `pnpm` or `yarn`. `npm` wont work.
|
|
119
|
+
|
|
120
|
+
To develop and test:
|
|
121
|
+
if you use `yarn` then run `yarn`
|
|
122
|
+
if you use `pnpm` then run `pnpm i`
|
|
123
|
+
|
|
124
|
+
**Interactive Menu:**
|
|
125
|
+
|
|
126
|
+
To start the interactive menu, run `npm start` (or `yarn start` or `pnpm start`). This will list all of the commonly used scripts.
|
|
127
|
+
|
|
128
|
+
### Build
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
npm run build.all
|
|
132
|
+
```
|
|
133
|
+
WARNING: it seems `yarn build.all` wont always work (not finding binaries in `node_modules/.bin`) which is why the doc explicitly uses `npm run`
|
|
134
|
+
|
|
135
|
+
### Demos
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
npm run demo.[ng|react|svelte|vue].[ios|android]
|
|
139
|
+
|
|
140
|
+
npm run demo.svelte.ios # Example
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Demo setup is a bit special in the sense that if you want to modify/add demos you dont work directly in `demo-[ng|react|svelte|vue]`
|
|
144
|
+
Instead you work in `demo-snippets/[ng|react|svelte|vue]`
|
|
145
|
+
You can start from the `install.ts` of each flavor to see how to register new demos
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
[](#contributing)
|
|
149
|
+
|
|
150
|
+
## Contributing
|
|
151
|
+
|
|
152
|
+
### Update repo
|
|
153
|
+
|
|
154
|
+
You can update the repo files quite easily
|
|
155
|
+
|
|
156
|
+
First update the submodules
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npm run update
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Then commit the changes
|
|
163
|
+
Then update common files
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
npm run sync
|
|
167
|
+
```
|
|
168
|
+
Then you can run `yarn|pnpm`, commit changed files if any
|
|
169
|
+
|
|
170
|
+
### Update readme
|
|
171
|
+
```bash
|
|
172
|
+
npm run readme
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Update doc
|
|
176
|
+
```bash
|
|
177
|
+
npm run doc
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Publish
|
|
181
|
+
|
|
182
|
+
The publishing is completely handled by `lerna` (you can add `-- --bump major` to force a major release)
|
|
183
|
+
Simply run
|
|
184
|
+
```shell
|
|
185
|
+
npm run publish
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### modifying submodules
|
|
189
|
+
|
|
190
|
+
The repo uses https:// for submodules which means you won't be able to push directly into the submodules.
|
|
191
|
+
One easy solution is t modify `~/.gitconfig` and add
|
|
192
|
+
```
|
|
193
|
+
[url "ssh://git@github.com/"]
|
|
194
|
+
pushInsteadOf = https://github.com/
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
[](#questions)
|
|
199
|
+
|
|
200
|
+
## Questions
|
|
201
|
+
|
|
202
|
+
If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { FormattedString, ImageSource, View } from '@nativescript/core';
|
|
2
|
+
/**
|
|
3
|
+
* An entry of a menu.
|
|
4
|
+
* Use `{ separator: true }` to start a new section (a divider on Android, an inline group on iOS).
|
|
5
|
+
*/
|
|
6
|
+
export interface MenuItem {
|
|
7
|
+
/** returned when the item is selected */
|
|
8
|
+
id?: string | number;
|
|
9
|
+
title?: string;
|
|
10
|
+
/** shown below the title (iOS only) */
|
|
11
|
+
subtitle?: string;
|
|
12
|
+
/** `sys://name` (SF Symbol, iOS), `res://name` or a file path, an ImageSource, or a FormattedString (spans drawn into an icon) */
|
|
13
|
+
icon?: string | ImageSource | FormattedString;
|
|
14
|
+
/** shows a check mark when true */
|
|
15
|
+
checked?: boolean;
|
|
16
|
+
/** red item */
|
|
17
|
+
destructive?: boolean;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/** a submenu */
|
|
20
|
+
items?: MenuItem[];
|
|
21
|
+
/** starts a new section */
|
|
22
|
+
separator?: boolean;
|
|
23
|
+
/** called when the item is selected */
|
|
24
|
+
onSelect?: (item: MenuItem) => void;
|
|
25
|
+
/** free data */
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Where the menu opens relative to its anchor.
|
|
30
|
+
* Android: `vertical` above/below and `horizontal` start/end (center behaves like start). The system flips the menu when there is no room.
|
|
31
|
+
* iOS: the system chooses the side with room, the placement sets the attachment point of the menu.
|
|
32
|
+
*/
|
|
33
|
+
export interface MenuPlacement {
|
|
34
|
+
horizontal?: 'start' | 'center' | 'end';
|
|
35
|
+
vertical?: 'auto' | 'above' | 'below';
|
|
36
|
+
}
|
|
37
|
+
export interface ShowMenuOptions {
|
|
38
|
+
/** the view the menu is attached to */
|
|
39
|
+
anchor: View;
|
|
40
|
+
items: MenuItem[];
|
|
41
|
+
/** title of the menu (iOS only) */
|
|
42
|
+
title?: string;
|
|
43
|
+
/** where the menu opens, relative to the anchor */
|
|
44
|
+
placement?: MenuPlacement;
|
|
45
|
+
}
|
|
46
|
+
export interface ContextMenuOptions {
|
|
47
|
+
placement?: MenuPlacement;
|
|
48
|
+
/** the items, or a function called each time the menu opens */
|
|
49
|
+
items: MenuItem[] | (() => MenuItem[]);
|
|
50
|
+
title?: string;
|
|
51
|
+
onSelect?: (item: MenuItem) => void;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Splits the items on the separators
|
|
55
|
+
*/
|
|
56
|
+
export declare function splitSections(items: MenuItem[]): MenuItem[][];
|
package/index-common.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits the items on the separators
|
|
3
|
+
*/
|
|
4
|
+
export function splitSections(items) {
|
|
5
|
+
const sections = [[]];
|
|
6
|
+
for (const item of items) {
|
|
7
|
+
if (item.separator) {
|
|
8
|
+
if (sections[sections.length - 1].length) {
|
|
9
|
+
sections.push([]);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
sections[sections.length - 1].push(item);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return sections.filter((s) => s.length);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=index-common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-common.js","sourceRoot":"","sources":["../../src/ui-menu/index-common.ts"],"names":[],"mappings":"AAyDA;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC3C,MAAM,QAAQ,GAAiB,CAAC,EAAE,CAAC,CAAC;IACpC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;gBACvC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtB,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;IACD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FormattedString, ImageSource, View } from '@nativescript/core';
|
|
2
|
+
import { ContextMenuOptions, MenuItem, ShowMenuOptions } from './index-common';
|
|
3
|
+
export * from './index-common';
|
|
4
|
+
export declare function showMenu(options: ShowMenuOptions): Promise<MenuItem | undefined>;
|
|
5
|
+
export declare function setContextMenu(view: View, options: ContextMenuOptions): () => void;
|
|
6
|
+
/** icon of a menu / bar item as a drawable: `res://`, a file, an ImageSource or a FormattedString */
|
|
7
|
+
export declare function getNativeIcon(icon: string | ImageSource | FormattedString): android.graphics.drawable.Drawable;
|
package/index.android.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { renderFormattedTextToImageSource } from '@nativescript-community/ui-core/formatted-text';
|
|
2
|
+
import { FormattedString, GestureTypes, ImageSource, Label, Utils } from '@nativescript/core';
|
|
3
|
+
import { splitSections } from './index-common';
|
|
4
|
+
export * from './index-common';
|
|
5
|
+
// Material 3 error color
|
|
6
|
+
const DESTRUCTIVE_COLOR = android.graphics.Color.parseColor('#B3261D');
|
|
7
|
+
function getIcon(icon) {
|
|
8
|
+
if (!icon) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
let source;
|
|
12
|
+
if (icon instanceof FormattedString) {
|
|
13
|
+
source = renderFormattedTextToImageSource(icon, new Label());
|
|
14
|
+
}
|
|
15
|
+
else if (icon instanceof ImageSource) {
|
|
16
|
+
source = icon;
|
|
17
|
+
}
|
|
18
|
+
else if (icon.startsWith(Utils.RESOURCE_PREFIX)) {
|
|
19
|
+
source = ImageSource.fromResourceSync(icon.slice(Utils.RESOURCE_PREFIX.length));
|
|
20
|
+
}
|
|
21
|
+
else if (Utils.isFileOrResourcePath(icon) && !icon.startsWith(Utils.SYSTEM_PREFIX)) {
|
|
22
|
+
source = ImageSource.fromFileSync(icon);
|
|
23
|
+
}
|
|
24
|
+
return source?.android ? new android.graphics.drawable.BitmapDrawable(Utils.android.getApplicationContext().getResources(), source.android) : null;
|
|
25
|
+
}
|
|
26
|
+
function buildMenu(menu, items, registry, state) {
|
|
27
|
+
splitSections(items).forEach((section, groupId) => {
|
|
28
|
+
section.forEach((item) => {
|
|
29
|
+
const id = state.nextId++;
|
|
30
|
+
let title = item.title || '';
|
|
31
|
+
if (item.destructive || item.subtitle) {
|
|
32
|
+
// the subtitle is a smaller second line
|
|
33
|
+
const text = item.subtitle ? `${title}\n${item.subtitle}` : title;
|
|
34
|
+
const spannable = new android.text.SpannableString(text);
|
|
35
|
+
if (item.destructive) {
|
|
36
|
+
spannable.setSpan(new android.text.style.ForegroundColorSpan(DESTRUCTIVE_COLOR), 0, title.length, 0);
|
|
37
|
+
}
|
|
38
|
+
if (item.subtitle) {
|
|
39
|
+
spannable.setSpan(new android.text.style.RelativeSizeSpan(0.8), title.length + 1, text.length, 0);
|
|
40
|
+
spannable.setSpan(new android.text.style.ForegroundColorSpan(android.graphics.Color.GRAY), title.length + 1, text.length, 0);
|
|
41
|
+
}
|
|
42
|
+
title = spannable;
|
|
43
|
+
}
|
|
44
|
+
let menuItem;
|
|
45
|
+
if (item.items?.length) {
|
|
46
|
+
const subMenu = menu.addSubMenu(groupId, id, id, title);
|
|
47
|
+
buildMenu(subMenu, item.items, registry, state);
|
|
48
|
+
menuItem = subMenu.getItem();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
menuItem = menu.add(groupId, id, id, title);
|
|
52
|
+
registry.set(id, item);
|
|
53
|
+
}
|
|
54
|
+
const icon = getIcon(item.icon);
|
|
55
|
+
if (icon) {
|
|
56
|
+
menuItem.setIcon(icon);
|
|
57
|
+
}
|
|
58
|
+
if (item.checked !== undefined) {
|
|
59
|
+
menuItem.setCheckable(true);
|
|
60
|
+
menuItem.setChecked(!!item.checked);
|
|
61
|
+
}
|
|
62
|
+
menuItem.setEnabled(!item.disabled);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
try {
|
|
66
|
+
// dividers between the sections (API 28)
|
|
67
|
+
menu.setGroupDividerEnabled(true);
|
|
68
|
+
}
|
|
69
|
+
catch (error) { }
|
|
70
|
+
}
|
|
71
|
+
export function showMenu(options) {
|
|
72
|
+
return new Promise((resolve) => {
|
|
73
|
+
const anchor = options.anchor?.nativeViewProtected;
|
|
74
|
+
if (!anchor) {
|
|
75
|
+
resolve(undefined);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const PopupMenu = global.androidx.appcompat.widget.PopupMenu;
|
|
79
|
+
const placement = options.placement;
|
|
80
|
+
let popupAnchor = anchor;
|
|
81
|
+
let helper;
|
|
82
|
+
if (placement?.vertical === 'above') {
|
|
83
|
+
// the popup always opens below its anchor: a helper view above the anchor, as high as the menu, makes it open above
|
|
84
|
+
const root = anchor.getRootView();
|
|
85
|
+
const location = Array.create('int', 2);
|
|
86
|
+
anchor.getLocationInWindow(location);
|
|
87
|
+
const itemCount = options.items.filter((i) => !i.separator).length;
|
|
88
|
+
const estimatedHeight = Utils.layout.toDevicePixels(itemCount * 48 + 16);
|
|
89
|
+
helper = new android.view.View(anchor.getContext());
|
|
90
|
+
root.addView(helper, new android.widget.FrameLayout.LayoutParams(anchor.getWidth(), 1));
|
|
91
|
+
helper.setX(location[0]);
|
|
92
|
+
helper.setY(Math.max(0, location[1] - estimatedHeight));
|
|
93
|
+
popupAnchor = helper;
|
|
94
|
+
}
|
|
95
|
+
const gravity = placement?.horizontal === 'end' ? android.view.Gravity.END : android.view.Gravity.START;
|
|
96
|
+
const popup = new PopupMenu(anchor.getContext(), popupAnchor, gravity);
|
|
97
|
+
const registry = new Map();
|
|
98
|
+
buildMenu(popup.getMenu(), options.items, registry, { nextId: 1 });
|
|
99
|
+
try {
|
|
100
|
+
popup.setForceShowIcon(true);
|
|
101
|
+
}
|
|
102
|
+
catch (error) { }
|
|
103
|
+
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener({
|
|
104
|
+
onMenuItemClick(menuItem) {
|
|
105
|
+
const item = registry.get(menuItem.getItemId());
|
|
106
|
+
if (!item) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
resolve(item);
|
|
110
|
+
item.onSelect?.(item);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
// resolving twice is harmless: the click is reported before the dismissal
|
|
115
|
+
popup.setOnDismissListener(new PopupMenu.OnDismissListener({
|
|
116
|
+
onDismiss: () => {
|
|
117
|
+
helper?.getParent()?.removeView(helper);
|
|
118
|
+
resolve(undefined);
|
|
119
|
+
}
|
|
120
|
+
}));
|
|
121
|
+
popup.show();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export function setContextMenu(view, options) {
|
|
125
|
+
const handler = () => {
|
|
126
|
+
const items = typeof options.items === 'function' ? options.items() : options.items;
|
|
127
|
+
showMenu({ anchor: view, items, title: options.title, placement: options.placement }).then((item) => item && options.onSelect?.(item));
|
|
128
|
+
};
|
|
129
|
+
view.on(GestureTypes.longPress, handler);
|
|
130
|
+
return () => view.off(GestureTypes.longPress, handler);
|
|
131
|
+
}
|
|
132
|
+
/** icon of a menu / bar item as a drawable: `res://`, a file, an ImageSource or a FormattedString */
|
|
133
|
+
export function getNativeIcon(icon) {
|
|
134
|
+
return getIcon(icon);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=index.android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.android.js","sourceRoot":"","sources":["../../src/ui-menu/index.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAQ,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAiD,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9F,cAAc,gBAAgB,CAAC;AAE/B,yBAAyB;AACzB,MAAM,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAEvE,SAAS,OAAO,CAAC,IAA4C;IACzD,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,MAAmB,CAAC;IACxB,IAAI,IAAI,YAAY,eAAe,EAAE,CAAC;QAClC,MAAM,GAAG,gCAAgC,CAAC,IAAI,EAAE,IAAI,KAAK,EAAE,CAAC,CAAC;IACjE,CAAC;SAAM,IAAI,IAAI,YAAY,WAAW,EAAE,CAAC;QACrC,MAAM,GAAG,IAAI,CAAC;IAClB,CAAC;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,CAAC;QAChD,MAAM,GAAG,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACpF,CAAC;SAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;QACnF,MAAM,GAAG,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,MAAM,EAA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A4C;IACtE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Menus.
|
|
3
|
+
* Android uses the Material 3 PopupMenu. iOS uses the native UIMenu: shown from a view (iOS 17.4+, an action sheet before) or as a context menu.
|
|
4
|
+
* @module @nativescript-community/ui-menu
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { FormattedString, ImageSource, View } from '@nativescript/core';
|
|
8
|
+
import { ContextMenuOptions, MenuItem, ShowMenuOptions } from './index-common';
|
|
9
|
+
export * from './index-common';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Shows a menu attached to the `anchor` view.
|
|
13
|
+
* @returns the selected item, or undefined when the menu is dismissed
|
|
14
|
+
*/
|
|
15
|
+
export function showMenu(options: ShowMenuOptions): Promise<MenuItem | undefined>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Sets a menu shown on long press of the view (native context menu on iOS).
|
|
19
|
+
* @returns a function removing the menu
|
|
20
|
+
*/
|
|
21
|
+
export function setContextMenu(view: View, options: ContextMenuOptions): () => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* iOS only: builds a native UIMenu from the items (UIBarButtonItem / UIButton `menu`).
|
|
25
|
+
*/
|
|
26
|
+
export function createNativeMenu(items: MenuItem[], title?: string, onSelect?: (item: MenuItem) => void): any;
|
|
27
|
+
|
|
28
|
+
/** iOS only: the UIImage of an icon (`sys://`, `res://`, file, ImageSource, FormattedString) */
|
|
29
|
+
export function getNativeIcon(icon: string | ImageSource | FormattedString): any;
|
package/index.ios.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormattedString, ImageSource, View } from '@nativescript/core';
|
|
2
|
+
import { ContextMenuOptions, MenuItem, ShowMenuOptions } from './index-common';
|
|
3
|
+
export * from './index-common';
|
|
4
|
+
export declare function showMenu(options: ShowMenuOptions): Promise<MenuItem | undefined>;
|
|
5
|
+
export declare function setContextMenu(view: View, options: ContextMenuOptions): () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Builds a native UIMenu from the items, for a UIBarButtonItem / UIButton `menu`. `onSelect` is called with the picked item (its `onSelect` too).
|
|
8
|
+
*/
|
|
9
|
+
export declare function createNativeMenu(items: MenuItem[], title?: string, onSelect?: (item: MenuItem) => void): UIMenu;
|
|
10
|
+
/** icon of a menu / bar item: `sys://`, `res://`, a file, an ImageSource or a FormattedString */
|
|
11
|
+
export declare function getNativeIcon(icon: string | ImageSource | FormattedString): UIImage;
|
package/index.ios.js
ADDED
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { renderFormattedTextToImageSource } from '@nativescript-community/ui-core/formatted-text';
|
|
2
|
+
import { Application, FormattedString, ImageSource, Label, Utils } from '@nativescript/core';
|
|
3
|
+
import { splitSections } from './index-common';
|
|
4
|
+
export * from './index-common';
|
|
5
|
+
function getIcon(icon) {
|
|
6
|
+
if (!icon) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
if (icon instanceof FormattedString) {
|
|
10
|
+
return renderFormattedTextToImageSource(icon, new Label())?.ios;
|
|
11
|
+
}
|
|
12
|
+
if (icon instanceof ImageSource) {
|
|
13
|
+
return icon.ios;
|
|
14
|
+
}
|
|
15
|
+
if (icon.startsWith(Utils.SYSTEM_PREFIX)) {
|
|
16
|
+
return UIImage.systemImageNamed(icon.slice(Utils.SYSTEM_PREFIX.length));
|
|
17
|
+
}
|
|
18
|
+
const source = icon.startsWith(Utils.RESOURCE_PREFIX) ? ImageSource.fromResourceSync(icon.slice(Utils.RESOURCE_PREFIX.length)) : ImageSource.fromFileSync(icon);
|
|
19
|
+
return source?.ios;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Native UIMenu: the sections are inline groups, the submenus are nested menus
|
|
23
|
+
*/
|
|
24
|
+
function buildMenu(title, items, onPick) {
|
|
25
|
+
const sections = splitSections(items).map((section) => {
|
|
26
|
+
const elements = section.map((item) => {
|
|
27
|
+
const image = getIcon(item.icon);
|
|
28
|
+
let attributes = 0;
|
|
29
|
+
if (item.destructive) {
|
|
30
|
+
attributes |= 2 /* UIMenuElementAttributes.Destructive */;
|
|
31
|
+
}
|
|
32
|
+
if (item.disabled) {
|
|
33
|
+
attributes |= 1 /* UIMenuElementAttributes.Disabled */;
|
|
34
|
+
}
|
|
35
|
+
if (item.items?.length) {
|
|
36
|
+
const submenu = buildMenu(item.title || '', item.items, onPick);
|
|
37
|
+
return UIMenu.menuWithTitleImageIdentifierOptionsChildren(item.title || '', image, null, item.destructive ? 2 /* UIMenuOptions.Destructive */ : 0, submenu.children);
|
|
38
|
+
}
|
|
39
|
+
const action = UIAction.actionWithTitleImageIdentifierHandler(item.title || '', image, null, () => onPick(item));
|
|
40
|
+
action.attributes = attributes;
|
|
41
|
+
if (item.checked) {
|
|
42
|
+
action.state = 1 /* UIMenuElementState.On */;
|
|
43
|
+
}
|
|
44
|
+
if (item.subtitle) {
|
|
45
|
+
action.subtitle = item.subtitle;
|
|
46
|
+
}
|
|
47
|
+
return action;
|
|
48
|
+
});
|
|
49
|
+
return UIMenu.menuWithTitleImageIdentifierOptionsChildren('', null, null, 1 /* UIMenuOptions.DisplayInline */, elements);
|
|
50
|
+
});
|
|
51
|
+
return UIMenu.menuWithTitleChildren(title || '', sections);
|
|
52
|
+
}
|
|
53
|
+
var MenuButton = /** @class */ (function (_super) {
|
|
54
|
+
__extends(MenuButton, _super);
|
|
55
|
+
function MenuButton() {
|
|
56
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
57
|
+
}
|
|
58
|
+
MenuButton.prototype.menuAttachmentPointForConfiguration = function (configuration) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
var _c = this.bounds.size, width = _c.width, height = _c.height;
|
|
61
|
+
var horizontal = (_a = this.placement) === null || _a === void 0 ? void 0 : _a.horizontal;
|
|
62
|
+
var x = horizontal === 'start' ? 0 : horizontal === 'end' ? width : width / 2;
|
|
63
|
+
var y = ((_b = this.placement) === null || _b === void 0 ? void 0 : _b.vertical) === 'above' ? 0 : height;
|
|
64
|
+
return CGPointMake(x, y);
|
|
65
|
+
};
|
|
66
|
+
return MenuButton;
|
|
67
|
+
}(UIButton));
|
|
68
|
+
var MenuInteractionDelegate = /** @class */ (function (_super) {
|
|
69
|
+
__extends(MenuInteractionDelegate, _super);
|
|
70
|
+
function MenuInteractionDelegate() {
|
|
71
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
72
|
+
}
|
|
73
|
+
MenuInteractionDelegate.initWithProvider = function (provider, onEnd) {
|
|
74
|
+
var delegate = MenuInteractionDelegate.new();
|
|
75
|
+
delegate.provider = provider;
|
|
76
|
+
delegate.onEnd = onEnd;
|
|
77
|
+
return delegate;
|
|
78
|
+
};
|
|
79
|
+
MenuInteractionDelegate.prototype.contextMenuInteractionConfigurationForMenuAtLocation = function (interaction, location) {
|
|
80
|
+
var _this = this;
|
|
81
|
+
return UIContextMenuConfiguration.configurationWithIdentifierPreviewProviderActionProvider(null, null, function () { return _this.provider(); });
|
|
82
|
+
};
|
|
83
|
+
MenuInteractionDelegate.prototype.contextMenuInteractionWillEndForConfigurationAnimator = function (interaction, configuration, animator) {
|
|
84
|
+
var _this = this;
|
|
85
|
+
animator === null || animator === void 0 ? void 0 : animator.addCompletion(function () { var _a; return (_a = _this.onEnd) === null || _a === void 0 ? void 0 : _a.call(_this); });
|
|
86
|
+
};
|
|
87
|
+
MenuInteractionDelegate.ObjCProtocols = [UIContextMenuInteractionDelegate];
|
|
88
|
+
return MenuInteractionDelegate;
|
|
89
|
+
}(NSObject));
|
|
90
|
+
/**
|
|
91
|
+
* Before iOS 17.4 a menu can not be presented from the code: an action sheet shows the (flattened) items
|
|
92
|
+
*/
|
|
93
|
+
function showActionSheet(options, resolve) {
|
|
94
|
+
const sheet = UIAlertController.alertControllerWithTitleMessagePreferredStyle(options.title || null, null, 0 /* UIAlertControllerStyle.ActionSheet */);
|
|
95
|
+
const addItems = (items, prefix = '') => {
|
|
96
|
+
items.forEach((item) => {
|
|
97
|
+
if (item.separator) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (item.items?.length) {
|
|
101
|
+
addItems(item.items, `${prefix}${item.title} › `);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const style = item.destructive ? 2 /* UIAlertActionStyle.Destructive */ : 0 /* UIAlertActionStyle.Default */;
|
|
105
|
+
const action = UIAlertAction.actionWithTitleStyleHandler(prefix + (item.title || ''), style, () => {
|
|
106
|
+
resolve(item);
|
|
107
|
+
item.onSelect?.(item);
|
|
108
|
+
});
|
|
109
|
+
action.enabled = !item.disabled;
|
|
110
|
+
sheet.addAction(action);
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
addItems(options.items);
|
|
114
|
+
sheet.addAction(UIAlertAction.actionWithTitleStyleHandler('Cancel', 1 /* UIAlertActionStyle.Cancel */, () => resolve(undefined)));
|
|
115
|
+
const anchor = options.anchor.nativeViewProtected;
|
|
116
|
+
const popover = sheet.popoverPresentationController;
|
|
117
|
+
if (popover) {
|
|
118
|
+
popover.sourceView = anchor;
|
|
119
|
+
popover.sourceRect = anchor.bounds;
|
|
120
|
+
}
|
|
121
|
+
Utils.ios.getVisibleViewController(Application.ios.rootController).presentViewControllerAnimatedCompletion(sheet, true, null);
|
|
122
|
+
}
|
|
123
|
+
export function showMenu(options) {
|
|
124
|
+
return new Promise((resolve) => {
|
|
125
|
+
const anchor = options.anchor?.nativeViewProtected;
|
|
126
|
+
if (!anchor) {
|
|
127
|
+
resolve(undefined);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
// a menu can only be shown by a UIButton: an invisible one covers the anchor
|
|
131
|
+
const button = MenuButton.buttonWithType(0 /* UIButtonType.Custom */);
|
|
132
|
+
button.placement = options.placement;
|
|
133
|
+
if (typeof button.performPrimaryAction !== 'function') {
|
|
134
|
+
showActionSheet(options, resolve);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let picked = false;
|
|
138
|
+
const done = (item) => {
|
|
139
|
+
resolve(item);
|
|
140
|
+
// after the dismissal animation
|
|
141
|
+
setTimeout(() => button.removeFromSuperview(), 500);
|
|
142
|
+
};
|
|
143
|
+
const pick = (item) => {
|
|
144
|
+
picked = true;
|
|
145
|
+
done(item);
|
|
146
|
+
item.onSelect?.(item);
|
|
147
|
+
};
|
|
148
|
+
button.frame = anchor.bounds;
|
|
149
|
+
button.menu = buildMenu(options.title, options.items, pick);
|
|
150
|
+
button.showsMenuAsPrimaryAction = true;
|
|
151
|
+
anchor.addSubview(button);
|
|
152
|
+
button.performPrimaryAction();
|
|
153
|
+
// the button is highlighted while the menu is shown
|
|
154
|
+
let wasShown = false;
|
|
155
|
+
let ticks = 0;
|
|
156
|
+
const timer = setInterval(() => {
|
|
157
|
+
ticks++;
|
|
158
|
+
if (button.highlighted) {
|
|
159
|
+
wasShown = true;
|
|
160
|
+
}
|
|
161
|
+
else if (wasShown || ticks > 20) {
|
|
162
|
+
clearInterval(timer);
|
|
163
|
+
// the action handler is called after the dismissal animation
|
|
164
|
+
setTimeout(() => !picked && done(undefined), 400);
|
|
165
|
+
}
|
|
166
|
+
}, 100);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export function setContextMenu(view, options) {
|
|
170
|
+
let interaction;
|
|
171
|
+
let delegate;
|
|
172
|
+
let nativeView;
|
|
173
|
+
const attach = () => {
|
|
174
|
+
if (!view.nativeViewProtected || interaction) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
nativeView = view.nativeViewProtected;
|
|
178
|
+
delegate = MenuInteractionDelegate.initWithProvider(() => {
|
|
179
|
+
const items = typeof options.items === 'function' ? options.items() : options.items;
|
|
180
|
+
return buildMenu(options.title, items, (item) => {
|
|
181
|
+
options.onSelect?.(item);
|
|
182
|
+
item.onSelect?.(item);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
interaction = UIContextMenuInteraction.alloc().initWithDelegate(delegate);
|
|
186
|
+
nativeView.addInteraction(interaction);
|
|
187
|
+
};
|
|
188
|
+
const detach = () => {
|
|
189
|
+
if (interaction) {
|
|
190
|
+
nativeView.removeInteraction(interaction);
|
|
191
|
+
interaction = null;
|
|
192
|
+
delegate = null;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
attach();
|
|
196
|
+
view.on('loaded', attach);
|
|
197
|
+
view.on('unloaded', detach);
|
|
198
|
+
return () => {
|
|
199
|
+
view.off('loaded', attach);
|
|
200
|
+
view.off('unloaded', detach);
|
|
201
|
+
detach();
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Builds a native UIMenu from the items, for a UIBarButtonItem / UIButton `menu`. `onSelect` is called with the picked item (its `onSelect` too).
|
|
206
|
+
*/
|
|
207
|
+
export function createNativeMenu(items, title, onSelect) {
|
|
208
|
+
return buildMenu(title, items, (item) => {
|
|
209
|
+
onSelect?.(item);
|
|
210
|
+
item.onSelect?.(item);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/** icon of a menu / bar item: `sys://`, `res://`, a file, an ImageSource or a FormattedString */
|
|
214
|
+
export function getNativeIcon(icon) {
|
|
215
|
+
return getIcon(icon);
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=index.ios.js.map
|
package/index.ios.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.ios.js","sourceRoot":"","sources":["../../src/ui-menu/index.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAQ,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAgE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7G,cAAc,gBAAgB,CAAC;AAE/B,SAAS,O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,IAAI,CAAC,CAAC;QACjB,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACP,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,aAAa,CAAC,IAA4C;IACtE,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@nativescript-community/ui-menu",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Menus: Material PopupMenu on Android, native UIMenu (pull-down and context menus) on iOS.",
|
|
5
|
+
"main": "./index",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"typings": "./index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"tsc": "cpy '**/*.d.ts' '../../packages/ui-menu' --parents --cwd=../../src/ui-menu && tsc --build",
|
|
10
|
+
"readme": "readme generate -c ../../tools/readme/blueprint.json",
|
|
11
|
+
"build": "npm run tsc && npm run readme",
|
|
12
|
+
"build.watch": "npm run tsc -- -w",
|
|
13
|
+
"build.all": "npm run build",
|
|
14
|
+
"clean": "bin/rimraf ./*.d.ts ./*.js ./*.js.map ./*.tsbuildinfo ./*.mjs ./*.mjs.map ./angular ./svelte ./vue* ./react"
|
|
15
|
+
},
|
|
16
|
+
"nativescript": {
|
|
17
|
+
"platforms": {
|
|
18
|
+
"android": "6.2.0",
|
|
19
|
+
"ios": "6.2.0"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"NativeScript",
|
|
24
|
+
"JavaScript",
|
|
25
|
+
"Android",
|
|
26
|
+
"iOS"
|
|
27
|
+
],
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Martin Guillon",
|
|
30
|
+
"email": "martin@akylas.fr"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/nativescript-community/ui-native-components/issues"
|
|
34
|
+
},
|
|
35
|
+
"license": "Apache-2.0",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/nativescript-community/ui-native-components/tree/master/packages/ui-menu#readme",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/nativescript-community/ui-native-components.git",
|
|
43
|
+
"directory": "packages/ui-menu"
|
|
44
|
+
},
|
|
45
|
+
"readmeFilename": "README.md",
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@nativescript-community/ui-core": "^1.0.0"
|
|
48
|
+
},
|
|
49
|
+
"gitHead": "237dd97d2b9e0f62ea9d9810169bb800dd531f7b"
|
|
50
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"uses": [
|
|
3
|
+
"android.graphics.drawable:BitmapDrawable",
|
|
4
|
+
"android.graphics.drawable:Drawable",
|
|
5
|
+
"android.graphics:Color",
|
|
6
|
+
"android.text.style:ForegroundColorSpan",
|
|
7
|
+
"android.text.style:RelativeSizeSpan",
|
|
8
|
+
"android.text:SpannableString",
|
|
9
|
+
"android.view:Gravity",
|
|
10
|
+
"android.view:Menu",
|
|
11
|
+
"android.view:MenuItem",
|
|
12
|
+
"android.view:View",
|
|
13
|
+
"android.view:ViewGroup",
|
|
14
|
+
"android.widget:FrameLayout.LayoutParams",
|
|
15
|
+
"androidx.appcompat.widget:PopupMenu"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../../src/ui-menu/index-common.ts","../../src/ui-menu/index.android.ts","../../src/ui-menu/index.d.ts","../../src/ui-menu/index.ios.ts","../../references.d.ts","../../tools/references.d.ts","../../src/references.d.ts"],"version":"5.8.3"}
|