@ng-native/components 0.27.0 → 0.28.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.
Files changed (57) hide show
  1. package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +61 -19
  2. package/android/src/main/java/dev/ngnative/components/MenusModule.kt +22 -0
  3. package/android/src/main/java/dev/ngnative/components/Shortcut.kt +13 -4
  4. package/dist/context-menu.d.ts +14 -6
  5. package/dist/context-menu.js +30 -28
  6. package/dist/context-menu.js.map +1 -1
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.js +3 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/menu.d.ts +7 -4
  11. package/dist/menu.js +10 -4
  12. package/dist/menu.js.map +1 -1
  13. package/dist/modal.d.ts +6 -2
  14. package/dist/modal.js.map +1 -1
  15. package/dist/native-button.d.ts +8 -1
  16. package/dist/native-button.js +5 -1
  17. package/dist/native-button.js.map +1 -1
  18. package/dist/press-menu.d.ts +39 -0
  19. package/dist/press-menu.js +76 -0
  20. package/dist/press-menu.js.map +1 -0
  21. package/dist/pressable.d.ts +3 -0
  22. package/dist/pressable.js +6 -1
  23. package/dist/pressable.js.map +1 -1
  24. package/dist/reanimated.js +27 -3
  25. package/dist/reanimated.js.map +1 -1
  26. package/dist/settled-updates.d.ts +55 -0
  27. package/dist/settled-updates.js +77 -0
  28. package/dist/settled-updates.js.map +1 -0
  29. package/dist/sidebar-item.d.ts +18 -3
  30. package/dist/sidebar-item.js +29 -3
  31. package/dist/sidebar-item.js.map +1 -1
  32. package/dist/stand-ins/reanimated.d.ts +5 -0
  33. package/dist/stand-ins/reanimated.js +7 -0
  34. package/dist/stand-ins/reanimated.js.map +1 -1
  35. package/dist/sticky-rows.d.ts +120 -25
  36. package/dist/sticky-rows.js +265 -65
  37. package/dist/sticky-rows.js.map +1 -1
  38. package/dist/svg-icon.d.ts +9 -0
  39. package/dist/svg-icon.js +37 -0
  40. package/dist/svg-icon.js.map +1 -0
  41. package/dist/virtual-list-sticky-level.d.ts +39 -0
  42. package/dist/virtual-list-sticky-level.js +82 -0
  43. package/dist/virtual-list-sticky-level.js.map +1 -0
  44. package/dist/virtual-list-sticky.d.ts +19 -0
  45. package/dist/virtual-list-sticky.js +13 -0
  46. package/dist/virtual-list-sticky.js.map +1 -0
  47. package/dist/virtual-list.d.ts +6 -2
  48. package/dist/virtual-list.js +60 -43
  49. package/dist/virtual-list.js.map +1 -1
  50. package/dist/worklet-style.d.ts +11 -0
  51. package/dist/worklet-style.js +15 -1
  52. package/dist/worklet-style.js.map +1 -1
  53. package/dist/worklets.d.ts +5 -1
  54. package/dist/worklets.js.map +1 -1
  55. package/dist/written-props.js +1 -0
  56. package/dist/written-props.js.map +1 -1
  57. package/package.json +3 -3
@@ -17,11 +17,13 @@ import android.widget.FrameLayout
17
17
  import android.widget.PopupMenu
18
18
  import com.facebook.react.bridge.Arguments
19
19
  import com.facebook.react.bridge.WritableMap
20
+ import com.facebook.react.uimanager.IllegalViewOperationException
20
21
  import com.facebook.react.uimanager.UIManagerHelper
21
22
  import com.facebook.react.uimanager.events.Event
22
23
 
23
24
  /**
24
- * A `[contextMenu]` drawn as a PopupMenu at a point in the window, from the entries
25
+ * A `[contextMenu]` drawn as a PopupMenu at a point in the window, or a `<pressable>`'s `[menu]`
26
+ * drawn below its view (`showUnder`), from the entries
25
27
  * `serializeMenu` makes: labels, separators (dividers between groups, Android 9 and later),
26
28
  * submenus, inline sections, checked, disabled and destructive items, and `icon` as a drawable
27
29
  * resource's name. A PopupMenu row has no second line or tooltip, so `subtitle` is not shown.
@@ -77,13 +79,65 @@ internal object ContextMenuPopup {
77
79
  topMargin = (y - at[1]).toInt()
78
80
  },
79
81
  )
80
- val popup = PopupMenu(activity, anchor, Gravity.NO_GRAVITY)
81
- val ids = HashMap<Int, String>()
82
- fill(activity, popup.menu, entries, ids, destructiveColour(isLight(activity)))
83
- if (popup.menu.size() == 0) {
82
+ // Later, not while the view tree may be detaching its children.
83
+ val (popup, done) = popup(activity, anchor, Gravity.NO_GRAVITY, view, entries) {
84
+ main.post { content.removeView(anchor) }
85
+ } ?: run {
84
86
  content.removeView(anchor)
85
87
  return false
86
88
  }
89
+ // The anchor has no place until it is laid out, so the menu waits for that.
90
+ anchor.addOnLayoutChangeListener(
91
+ object : View.OnLayoutChangeListener {
92
+ override fun onLayoutChange(
93
+ v: View, l: Int, t: Int, r: Int, b: Int, ol: Int, ot: Int, or: Int, ob: Int,
94
+ ) {
95
+ anchor.removeOnLayoutChangeListener(this)
96
+ if (anchor.isAttachedToWindow && view.isAttachedToWindow) popup.show() else done()
97
+ }
98
+ },
99
+ )
100
+ return true
101
+ }
102
+
103
+ /**
104
+ * The view `resolve` finds for `tag`, or none where it has none, as for a view gone since the
105
+ * press: React Native's `resolveView` throws for a tag it has no view for.
106
+ */
107
+ fun viewFor(tag: Int, resolve: (Int) -> View?): View? =
108
+ try {
109
+ resolve(tag)
110
+ } catch (_: IllegalViewOperationException) {
111
+ null
112
+ }
113
+
114
+ /**
115
+ * Show `entries` below `view`, from its leading edge, as a `<pressable>`'s `[menu]` opens on a
116
+ * press. Whether there was a menu: none for a view not attached to `activity`'s window.
117
+ */
118
+ fun showUnder(activity: Activity, view: View, entries: List<Map<String, Any?>>): Boolean {
119
+ if (!view.isAttachedToWindow) return false
120
+ val (popup, _) = popup(activity, view, Gravity.START, view, entries) {} ?: return false
121
+ popup.show()
122
+ return true
123
+ }
124
+
125
+ /**
126
+ * A PopupMenu of `entries` at `anchor`, whose choice goes to `view`, and the function that lets
127
+ * go of it, which runs `release` too and runs as it is dismissed. Null where it shows no item.
128
+ */
129
+ private fun popup(
130
+ activity: Activity,
131
+ anchor: View,
132
+ gravity: Int,
133
+ view: View,
134
+ entries: List<Map<String, Any?>>,
135
+ release: () -> Unit,
136
+ ): Pair<PopupMenu, () -> Unit>? {
137
+ val popup = PopupMenu(activity, anchor, gravity)
138
+ val ids = HashMap<Int, String>()
139
+ fill(activity, popup.menu, entries, ids, destructiveColour(isLight(activity)))
140
+ if (popup.menu.size() == 0) return null
87
141
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) popup.setForceShowIcon(true)
88
142
  popup.setOnMenuItemClickListener { item ->
89
143
  val id = ids[item.itemId] ?: return@setOnMenuItemClickListener false
@@ -94,24 +148,12 @@ internal object ContextMenuPopup {
94
148
  // A submenu open in its own popup goes too.
95
149
  val gone = closingOnDetach(popup.menu, popup::dismiss)
96
150
  view.addOnAttachStateChangeListener(gone)
97
- // Later, not while the view tree may be detaching its children.
98
151
  val done = {
99
152
  view.removeOnAttachStateChangeListener(gone)
100
- main.post { content.removeView(anchor) }
153
+ release()
101
154
  }
102
155
  popup.setOnDismissListener { done() }
103
- // The anchor has no place until it is laid out, so the menu waits for that.
104
- anchor.addOnLayoutChangeListener(
105
- object : View.OnLayoutChangeListener {
106
- override fun onLayoutChange(
107
- v: View, l: Int, t: Int, r: Int, b: Int, ol: Int, ot: Int, or: Int, ob: Int,
108
- ) {
109
- anchor.removeOnLayoutChangeListener(this)
110
- if (anchor.isAttachedToWindow && view.isAttachedToWindow) popup.show() else done()
111
- }
112
- },
113
- )
114
- return true
156
+ return popup to done
115
157
  }
116
158
 
117
159
  /**
@@ -2,6 +2,8 @@ package dev.ngnative.components
2
2
 
3
3
  import android.os.Handler
4
4
  import android.os.Looper
5
+ import com.facebook.react.bridge.ReactContext
6
+ import com.facebook.react.uimanager.UIManagerHelper
5
7
  import expo.modules.kotlin.modules.Module
6
8
  import expo.modules.kotlin.modules.ModuleDefinition
7
9
 
@@ -18,6 +20,10 @@ import expo.modules.kotlin.modules.ModuleDefinition
18
20
  * as a PopupMenu at the press point, and so does the view's long-press accessibility action.
19
21
  * `setTakesLongPress` names views inside one that take a long press themselves, where a long press
20
22
  * opens no menu.
23
+ *
24
+ * `popUpMenu` draws a `<pressable>`'s `[menu]` below the view with that tag now, on a press, in
25
+ * whichever window the view is in: the activity's, or a `<modal>`'s dialog. Either menu sends the
26
+ * item chosen to its view as `topContextMenuSelect`.
21
27
  */
22
28
  class MenusModule : Module() {
23
29
  private val main = Handler(Looper.getMainLooper())
@@ -59,6 +65,10 @@ class MenusModule : Module() {
59
65
  }
60
66
  }
61
67
 
68
+ Function("popUpMenu") { tag: Int, entries: List<Map<String, Any?>> ->
69
+ main.post { popUpMenu(tag, entries) }
70
+ }
71
+
62
72
  // On the main thread, in order with the old module's `OnDestroy` and every call after.
63
73
  OnCreate {
64
74
  main.post { MenuHost.attach(sender) }
@@ -78,6 +88,18 @@ class MenusModule : Module() {
78
88
  }
79
89
  }
80
90
 
91
+ /**
92
+ * Show `entries` below the view with `tag`. React Native's UIManager finds it by its tag in any
93
+ * window, a `<modal>`'s dialog among them, where a search of the activity's window would not.
94
+ */
95
+ private fun popUpMenu(tag: Int, entries: List<Map<String, Any?>>) {
96
+ val activity = appContext.currentActivity ?: return
97
+ val context = appContext.reactContext as? ReactContext ?: return
98
+ val view = ContextMenuPopup.viewFor(tag) { UIManagerHelper.getUIManagerForReactTag(context, it)?.resolveView(it) } ?: return
99
+ ContextMenuPopup.showUnder(activity, view, entries)
100
+ }
101
+
102
+
81
103
  private fun watchActivity() {
82
104
  val activity = appContext.currentActivity ?: return
83
105
  main.post { MenuWindowCallback.install(activity) }
@@ -1,5 +1,6 @@
1
1
  package dev.ngnative.components
2
2
 
3
+ import android.os.Build
3
4
  import android.view.KeyEvent
4
5
  import android.view.KeyboardShortcutGroup
5
6
  import android.view.KeyboardShortcutInfo
@@ -64,8 +65,15 @@ internal class Shortcut(
64
65
  return KeyboardShortcutInfo(label, helperChar() ?: return null, modifiers)
65
66
  }
66
67
 
67
- /** The key code of a key `KeyboardEvent.key` names with a word, or null. */
68
- fun keyCode(): Int? = NAMED.entries.firstOrNull { it.value.equals(normalKey, true) }?.key
68
+ /**
69
+ * The key code of a key `KeyboardEvent.key` names with a word, or null. Null for F13 to F20
70
+ * before Android 16, whose helper rejects a key code past the last one the OS knows.
71
+ */
72
+ fun keyCode(sdk: Int = Build.VERSION.SDK_INT): Int? {
73
+ val code = NAMED.entries.firstOrNull { it.value.equals(normalKey, true) }?.key ?: return null
74
+ val unknown = code in KeyEvent.KEYCODE_F13..KeyEvent.KEYCODE_F20 && sdk < Build.VERSION_CODES.BAKLAVA
75
+ return if (unknown) null else code
76
+ }
69
77
 
70
78
  /** The character the helper shows for a key with no key code, or null for a word it lacks. */
71
79
  fun helperChar(): Char? = normalKey.singleOrNull()?.uppercaseChar()
@@ -89,8 +97,8 @@ internal class Shortcut(
89
97
  }
90
98
 
91
99
  /**
92
- * The keys `KeyboardEvent.key` names with a word, by their key code. Android has no key past
93
- * F12, so a shortcut on F13 and up never fires here and the helper does not list it.
100
+ * The keys `KeyboardEvent.key` names with a word, by their key code. F13 to F20 have key codes
101
+ * from Android 16 (API 36); an older Android sends none for them.
94
102
  */
95
103
  private val NAMED: Map<Int, String> = buildMap {
96
104
  put(KeyEvent.KEYCODE_DPAD_LEFT, "ArrowLeft")
@@ -113,6 +121,7 @@ internal class Shortcut(
113
121
  put(KeyEvent.KEYCODE_SCROLL_LOCK, "ScrollLock")
114
122
  put(KeyEvent.KEYCODE_MENU, "ContextMenu")
115
123
  for (n in 1..12) put(KeyEvent.KEYCODE_F1 + n - 1, "F$n")
124
+ for (n in 13..20) put(KeyEvent.KEYCODE_F13 + n - 13, "F$n")
116
125
  }
117
126
 
118
127
  /** The key `event` is, as `KeyboardEvent.key` names it, ignoring Shift: `k`, `,`, `Enter`. */
@@ -1,4 +1,5 @@
1
- import { InjectionToken, type TemplateRef } from '@angular/core';
1
+ import { InjectionToken, Injector, type Signal, type TemplateRef } from '@angular/core';
2
+ import { type NativeMenuEntry, type ShortcutOs } from '@ng-native/device';
2
3
  import * as i0 from "@angular/core";
3
4
  /**
4
5
  * The `[contextMenu]` on an element, for `<pressable>`: where a long press opens the menu,
@@ -32,9 +33,7 @@ export declare class ContextMenu {
32
33
  /** Android's and iOS's hosts, which take the menu by `nativeID` and draw it on a long press. */
33
34
  private readonly byNativeId;
34
35
  private readonly sender;
35
- private readonly built;
36
36
  private readonly menu;
37
- /** The entries to send, or null where they show no item: only separators and empty sections. */
38
37
  private readonly sent;
39
38
  constructor();
40
39
  /** Whether a long press opens this menu now, so `(longPress)` does not also fire. */
@@ -44,9 +43,18 @@ export declare class ContextMenu {
44
43
  * name, and runs as the view's own `topContextMenuSelect` would.
45
44
  */
46
45
  private sendByNativeId;
47
- private choose;
48
- /** Make the template's items, which register with the menu this element sends. */
49
- private build;
50
46
  static ɵfac: i0.ɵɵFactoryDeclaration<ContextMenu, never>;
51
47
  static ɵdir: i0.ɵɵDirectiveDeclaration<ContextMenu, "[contextMenu]", never, { "contextMenu": { "alias": "contextMenu"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
52
48
  }
49
+ /** A menu written as a template of `<menu-item>`s, as `templateMenu` makes it. */
50
+ export interface TemplateMenu {
51
+ /** The entries to send, or null where they show no item: only separators and empty sections. */
52
+ readonly sent: Signal<NativeMenuEntry[] | null>;
53
+ /** Run the item with `id`, as the menu is now: nothing for an id it no longer has. */
54
+ choose(id: string): void;
55
+ }
56
+ /**
57
+ * The menu `template` holds, its items made in `injector` and remade as the template changes, and
58
+ * destroyed with it. Called in an injection context.
59
+ */
60
+ export declare function templateMenu(template: () => TemplateRef<unknown> | null, injector: Injector, os: ShortcutOs): TemplateMenu;
@@ -36,18 +36,9 @@ export class ContextMenu {
36
36
  sender = this.byNativeId
37
37
  ? byNativeId(this.engine, this.node, (nativeID) => this.sendByNativeId(nativeID), (nativeID) => this.menus.setContextMenu(nativeID, null))
38
38
  : null;
39
- built = signal(null, /* @ts-ignore */
40
- ...(ngDevMode ? [{ debugName: "built" }] : /* istanbul ignore next */ []));
41
- menu = computed(() => serializeMenu(this.built()?.model.entries() ?? [], this.os), /* @ts-ignore */
42
- ...(ngDevMode ? [{ debugName: "menu" }] : /* istanbul ignore next */ []));
43
- /** The entries to send, or null where they show no item: only separators and empty sections. */
44
- sent = computed(() => {
45
- const { entries } = this.menu();
46
- return showsAnItem(entries) ? entries : null;
47
- }, /* @ts-ignore */
48
- ...(ngDevMode ? [{ debugName: "sent" }] : /* istanbul ignore next */ []));
39
+ menu = templateMenu(() => this.contextMenu() ?? null, this.injector, this.os);
40
+ sent = this.menu.sent;
49
41
  constructor() {
50
- effect(() => this.build(this.contextMenu() ?? null));
51
42
  effect(() => {
52
43
  this.engine.setProp(this.node, 'contextMenu', this.sent());
53
44
  this.sender?.();
@@ -55,12 +46,9 @@ export class ContextMenu {
55
46
  const stop = this.engine.setEventListener(this.node, 'topContextMenuSelect', (event) => {
56
47
  const id = event.nativeEvent?.id;
57
48
  if (id !== undefined)
58
- this.choose(id);
59
- });
60
- inject(DestroyRef).onDestroy(() => {
61
- stop();
62
- this.build(null);
49
+ this.menu.choose(id);
63
50
  });
51
+ inject(DestroyRef).onDestroy(stop);
64
52
  }
65
53
  /** Whether a long press opens this menu now, so `(longPress)` does not also fire. */
66
54
  takesLongPress() {
@@ -71,18 +59,7 @@ export class ContextMenu {
71
59
  * name, and runs as the view's own `topContextMenuSelect` would.
72
60
  */
73
61
  sendByNativeId(nativeID) {
74
- this.menus.setContextMenu(nativeID, untracked(this.sent), (id) => this.choose(id));
75
- }
76
- choose(id) {
77
- this.menu().actions.get(id)?.();
78
- }
79
- /** Make the template's items, which register with the menu this element sends. */
80
- build(template) {
81
- // Read and written outside the effect that calls this, which would otherwise run again.
82
- untracked(() => {
83
- this.built()?.destroy();
84
- this.built.set(template ? buildMenuTemplate(template, this.injector) : null);
85
- });
62
+ this.menus.setContextMenu(nativeID, untracked(this.sent), (id) => this.menu.choose(id));
86
63
  }
87
64
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ContextMenu, deps: [], target: i0.ɵɵFactoryTarget.Directive });
88
65
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: ContextMenu, isStandalone: true, selector: "[contextMenu]", inputs: { contextMenu: { classPropertyName: "contextMenu", publicName: "contextMenu", isSignal: true, isRequired: false, transformFunction: null } }, providers: [{ provide: CONTEXT_MENU, useExisting: forwardRef(() => ContextMenu) }], ngImport: i0 });
@@ -94,6 +71,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
94
71
  providers: [{ provide: CONTEXT_MENU, useExisting: forwardRef(() => ContextMenu) }],
95
72
  }]
96
73
  }], ctorParameters: () => [], propDecorators: { contextMenu: [{ type: i0.Input, args: [{ isSignal: true, alias: "contextMenu", required: false }] }] } });
74
+ /**
75
+ * The menu `template` holds, its items made in `injector` and remade as the template changes, and
76
+ * destroyed with it. Called in an injection context.
77
+ */
78
+ export function templateMenu(template, injector, os) {
79
+ const built = signal(null, /* @ts-ignore */
80
+ ...(ngDevMode ? [{ debugName: "built" }] : /* istanbul ignore next */ []));
81
+ const build = (next) =>
82
+ // Read and written outside the effect that calls this, which would otherwise run again.
83
+ untracked(() => {
84
+ built()?.destroy();
85
+ built.set(next ? buildMenuTemplate(next, injector) : null);
86
+ });
87
+ effect(() => build(template()));
88
+ inject(DestroyRef).onDestroy(() => build(null));
89
+ const menu = computed(() => serializeMenu(built()?.model.entries() ?? [], os), /* @ts-ignore */
90
+ ...(ngDevMode ? [{ debugName: "menu" }] : /* istanbul ignore next */ []));
91
+ return {
92
+ sent: computed(() => {
93
+ const { entries } = menu();
94
+ return showsAnItem(entries) ? entries : null;
95
+ }),
96
+ choose: (id) => untracked(menu).actions.get(id)?.(),
97
+ };
98
+ }
97
99
  /** Whether `entries` show an item: one that is not a separator, nor a section with none. */
98
100
  function showsAnItem(entries) {
99
101
  return entries.some((entry) => !('separator' in entry) && (!entry.inline || showsAnItem(entry.items ?? [])));
@@ -1 +1 @@
1
- {"version":3,"file":"context-menu.js","sourceRoot":"","sources":["../src/context-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACd,QAA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C,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CACxF,CAAC;AACJ,CAAC","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n InjectionToken,\n Injector,\n computed,\n effect,\n forwardRef,\n inject,\n input,\n signal,\n untracked,\n type TemplateRef,\n} from '@angular/core';\nimport {\n Menus,\n OS,\n buildMenuTemplate,\n serializeMenu,\n type MenuTemplate,\n type NativeMenuEntry,\n} from '@ng-native/device';\nimport { HostEngine, type HostNode } from '@ng-native/fabric';\nimport { byNativeId } from './native-id.ts';\n\n/**\n * The `[contextMenu]` on an element, for `<pressable>`: where a long press opens the menu,\n * `(longPress)` does not also fire.\n */\nexport const CONTEXT_MENU = new InjectionToken<{ takesLongPress(): boolean }>(\n 'angular-native.contextMenu',\n);\n\n/**\n * A context menu on an element: `[contextMenu]=\"menu\"`, with `<ng-template #menu>` holding\n * `<menu-item>`s. A right-click opens it on macOS. On Android a long press or a right-click opens\n * it as a PopupMenu at the press point, and on iOS and iPadOS a long press, or a secondary click\n * from an iPad pointer, opens it through UIContextMenuInteraction. On Android and iOS that takes\n * the `NgNativeMenus` module, which Expo Go lacks, and where it is there `(longPress)` does not\n * also fire. On Android a `(longPress)` on a view inside the element keeps its long press, which\n * then opens no menu: the innermost handler wins.\n *\n * The host contract: the view takes a `contextMenu` prop, the menu as `serializeMenu` makes it\n * (null to take it away), and sends `topContextMenuSelect` with the chosen item's `id`. React\n * Native's Android and iOS views drop a prop they do not know, so there the menu goes through\n * `Menus.setContextMenu` by the view's `nativeID`, and an element without one is given one. iOS's\n * module sends the choice, which reaches the element as `topContextMenuSelect`.\n */\n@Directive({\n selector: '[contextMenu]',\n providers: [{ provide: CONTEXT_MENU, useExisting: forwardRef(() => ContextMenu) }],\n})\nexport class ContextMenu {\n readonly contextMenu = input<TemplateRef<unknown> | null>();\n\n private readonly node = inject(ElementRef).nativeElement as HostNode;\n private readonly engine = inject(HostEngine);\n private readonly injector = inject(Injector);\n private readonly os = inject(OS);\n private readonly menus = inject(Menus);\n /** Android's and iOS's hosts, which take the menu by `nativeID` and draw it on a long press. */\n private readonly byNativeId =\n (this.os === 'android' || this.os === 'ios') && this.menus.contextMenuByNativeId;\n private readonly sender = this.byNativeId\n ? byNativeId(\n this.engine,\n this.node,\n (nativeID) => this.sendByNativeId(nativeID),\n (nativeID) => this.menus.setContextMenu(nativeID, null),\n )\n : null;\n private readonly built = signal<MenuTemplate | null>(null);\n private readonly menu = computed(() =>\n serializeMenu(this.built()?.model.entries() ?? [], this.os),\n );\n /** The entries to send, or null where they show no item: only separators and empty sections. */\n private readonly sent = computed(() => {\n const { entries } = this.menu();\n return showsAnItem(entries) ? entries : null;\n });\n\n constructor() {\n effect(() => this.build(this.contextMenu() ?? null));\n effect(() => {\n this.engine.setProp(this.node, 'contextMenu', this.sent());\n this.sender?.();\n });\n const stop = this.engine.setEventListener(this.node, 'topContextMenuSelect', (event) => {\n const id = (event as { nativeEvent?: { id?: string } }).nativeEvent?.id;\n if (id !== undefined) this.choose(id);\n });\n inject(DestroyRef).onDestroy(() => {\n stop();\n this.build(null);\n });\n }\n\n /** Whether a long press opens this menu now, so `(longPress)` does not also fire. */\n takesLongPress(): boolean {\n return this.byNativeId && this.sent() !== null;\n }\n\n /**\n * Send the menu to the host under the view's `nativeID`. On iOS the choice comes back by that\n * name, and runs as the view's own `topContextMenuSelect` would.\n */\n private sendByNativeId(nativeID: string): void {\n this.menus.setContextMenu(nativeID, untracked(this.sent), (id) => this.choose(id));\n }\n\n private choose(id: string): void {\n this.menu().actions.get(id)?.();\n }\n\n /** Make the template's items, which register with the menu this element sends. */\n private build(template: TemplateRef<unknown> | null): void {\n // Read and written outside the effect that calls this, which would otherwise run again.\n untracked(() => {\n this.built()?.destroy();\n this.built.set(template ? buildMenuTemplate(template, this.injector) : null);\n });\n }\n}\n\n/** Whether `entries` show an item: one that is not a separator, nor a section with none. */\nfunction showsAnItem(entries: readonly NativeMenuEntry[]): boolean {\n return entries.some(\n (entry) => !('separator' in entry) && (!entry.inline || showsAnItem(entry.items ?? [])),\n );\n}\n"]}
1
+ {"version":3,"file":"context-menu.js","sourceRoot":"","sources":["../src/context-menu.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GAGV,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,EACL,EAAE,EACF,iBAAiB,EACjB,aAAa,GAId,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,cAAc,CAC5C,4BAA4B,CAC7B,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AAKH,MAAM,OAAO,WAAW;IACb,WAAW,GAAG,KAAK;+FAA+B,CAAC;IAE3C,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,aAAyB,CAAC;IACpD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAC5B,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAChB,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,gGAAgG;IAC/E,UAAU,GACzB,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,KAAK,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,qBAAqB,CAAC;IAClE,MAAM,GAAG,IAAI,CAAC,UAAU;QACvC,CAAC,CAAC,UAAU,CACR,IAAI,CAAC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,CAAC;IAC/E,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE;YAClB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;YAC3B,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;QAC/C,CAAC,CAAC;QACF,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;KACpD,CAAC;AACJ,CAAC;AAED,4FAA4F;AAC5F,SAAS,WAAW,CAAC,OAAmC;IACtD,OAAO,OAAO,CAAC,IAAI,CACjB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,IAAI,WAAW,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CACxF,CAAC;AACJ,CAAC","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n InjectionToken,\n Injector,\n computed,\n effect,\n forwardRef,\n inject,\n input,\n signal,\n untracked,\n type Signal,\n type TemplateRef,\n} from '@angular/core';\nimport {\n Menus,\n OS,\n buildMenuTemplate,\n serializeMenu,\n type MenuTemplate,\n type NativeMenuEntry,\n type ShortcutOs,\n} from '@ng-native/device';\nimport { HostEngine, type HostNode } from '@ng-native/fabric';\nimport { byNativeId } from './native-id.ts';\n\n/**\n * The `[contextMenu]` on an element, for `<pressable>`: where a long press opens the menu,\n * `(longPress)` does not also fire.\n */\nexport const CONTEXT_MENU = new InjectionToken<{ takesLongPress(): boolean }>(\n 'angular-native.contextMenu',\n);\n\n/**\n * A context menu on an element: `[contextMenu]=\"menu\"`, with `<ng-template #menu>` holding\n * `<menu-item>`s. A right-click opens it on macOS. On Android a long press or a right-click opens\n * it as a PopupMenu at the press point, and on iOS and iPadOS a long press, or a secondary click\n * from an iPad pointer, opens it through UIContextMenuInteraction. On Android and iOS that takes\n * the `NgNativeMenus` module, which Expo Go lacks, and where it is there `(longPress)` does not\n * also fire. On Android a `(longPress)` on a view inside the element keeps its long press, which\n * then opens no menu: the innermost handler wins.\n *\n * The host contract: the view takes a `contextMenu` prop, the menu as `serializeMenu` makes it\n * (null to take it away), and sends `topContextMenuSelect` with the chosen item's `id`. React\n * Native's Android and iOS views drop a prop they do not know, so there the menu goes through\n * `Menus.setContextMenu` by the view's `nativeID`, and an element without one is given one. iOS's\n * module sends the choice, which reaches the element as `topContextMenuSelect`.\n */\n@Directive({\n selector: '[contextMenu]',\n providers: [{ provide: CONTEXT_MENU, useExisting: forwardRef(() => ContextMenu) }],\n})\nexport class ContextMenu {\n readonly contextMenu = input<TemplateRef<unknown> | null>();\n\n private readonly node = inject(ElementRef).nativeElement as HostNode;\n private readonly engine = inject(HostEngine);\n private readonly injector = inject(Injector);\n private readonly os = inject(OS);\n private readonly menus = inject(Menus);\n /** Android's and iOS's hosts, which take the menu by `nativeID` and draw it on a long press. */\n private readonly byNativeId =\n (this.os === 'android' || this.os === 'ios') && this.menus.contextMenuByNativeId;\n private readonly sender = this.byNativeId\n ? byNativeId(\n this.engine,\n this.node,\n (nativeID) => this.sendByNativeId(nativeID),\n (nativeID) => this.menus.setContextMenu(nativeID, null),\n )\n : null;\n private readonly menu = templateMenu(() => this.contextMenu() ?? null, this.injector, this.os);\n private readonly sent = this.menu.sent;\n\n constructor() {\n effect(() => {\n this.engine.setProp(this.node, 'contextMenu', this.sent());\n this.sender?.();\n });\n const stop = this.engine.setEventListener(this.node, 'topContextMenuSelect', (event) => {\n const id = (event as { nativeEvent?: { id?: string } }).nativeEvent?.id;\n if (id !== undefined) this.menu.choose(id);\n });\n inject(DestroyRef).onDestroy(stop);\n }\n\n /** Whether a long press opens this menu now, so `(longPress)` does not also fire. */\n takesLongPress(): boolean {\n return this.byNativeId && this.sent() !== null;\n }\n\n /**\n * Send the menu to the host under the view's `nativeID`. On iOS the choice comes back by that\n * name, and runs as the view's own `topContextMenuSelect` would.\n */\n private sendByNativeId(nativeID: string): void {\n this.menus.setContextMenu(nativeID, untracked(this.sent), (id) => this.menu.choose(id));\n }\n}\n\n/** A menu written as a template of `<menu-item>`s, as `templateMenu` makes it. */\nexport interface TemplateMenu {\n /** The entries to send, or null where they show no item: only separators and empty sections. */\n readonly sent: Signal<NativeMenuEntry[] | null>;\n /** Run the item with `id`, as the menu is now: nothing for an id it no longer has. */\n choose(id: string): void;\n}\n\n/**\n * The menu `template` holds, its items made in `injector` and remade as the template changes, and\n * destroyed with it. Called in an injection context.\n */\nexport function templateMenu(\n template: () => TemplateRef<unknown> | null,\n injector: Injector,\n os: ShortcutOs,\n): TemplateMenu {\n const built = signal<MenuTemplate | null>(null);\n const build = (next: TemplateRef<unknown> | null) =>\n // Read and written outside the effect that calls this, which would otherwise run again.\n untracked(() => {\n built()?.destroy();\n built.set(next ? buildMenuTemplate(next, injector) : null);\n });\n effect(() => build(template()));\n inject(DestroyRef).onDestroy(() => build(null));\n const menu = computed(() => serializeMenu(built()?.model.entries() ?? [], os));\n return {\n sent: computed(() => {\n const { entries } = menu();\n return showsAnItem(entries) ? entries : null;\n }),\n choose: (id) => untracked(menu).actions.get(id)?.(),\n };\n}\n\n/** Whether `entries` show an item: one that is not a separator, nor a section with none. */\nfunction showsAnItem(entries: readonly NativeMenuEntry[]): boolean {\n return entries.some(\n (entry) => !('separator' in entry) && (!entry.inline || showsAnItem(entry.items ?? [])),\n );\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export { KeyboardAvoidingView, type KeyboardAvoidingBehavior } from './keyboard-
19
19
  export { Modal, type ModalAnchor, type ModalOrientation, type ModalPresentationStyle, } from './modal.ts';
20
20
  export { MenuBar, MenuGroup, MenuItem, MenuSeparator, treeOrder } from './menu.ts';
21
21
  export { CONTEXT_MENU, ContextMenu } from './context-menu.ts';
22
+ export { PRESS_MENU, PressMenu } from './press-menu.ts';
22
23
  export { Shortcut } from './shortcut.ts';
23
24
  export { DragItem, FileDrop, type DragItemValue, type DroppedFile, type FileDropEvent, } from './drag-and-drop.ts';
24
25
  export { TrayIcon } from './tray-icon.ts';
@@ -48,6 +49,8 @@ export { ViewBase, ViewBehavior, contributeAccessibility, type AccessibilityActi
48
49
  export { VirtualList, VirtualListRow, VirtualListSeparator, type VirtualItemHeight, type VirtualListSeparatorContext, type VirtualListPadding, type VirtualListVisiblePosition, type VirtualRow, } from './virtual-list.ts';
49
50
  export { VIRTUAL_LIST_LAYOUT, type VirtualListLayout } from './virtual-list-layout.ts';
50
51
  export { VirtualListNumColumns } from './virtual-list-num-columns.ts';
52
+ export { VIRTUAL_LIST_STICKY, type VirtualListSticky } from './virtual-list-sticky.ts';
53
+ export { VirtualListStickyLevel } from './virtual-list-sticky-level.ts';
51
54
  export { type GestureBackend, type GestureSpec, type GestureTarget } from './gesture-backend.ts';
52
55
  export { workletScroll, workletStyle, type SharedValue, type WorkletBackend, type WorkletScrollSpec, type WorkletStyleSpec, type WorkletTarget, } from './worklets.ts';
53
56
  export { releaseOnDestroy } from './release-on-destroy.ts';
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ export { KeyboardAvoidingView } from "./keyboard-avoiding-view.js";
19
19
  export { Modal, } from "./modal.js";
20
20
  export { MenuBar, MenuGroup, MenuItem, MenuSeparator, treeOrder } from "./menu.js";
21
21
  export { CONTEXT_MENU, ContextMenu } from "./context-menu.js";
22
+ export { PRESS_MENU, PressMenu } from "./press-menu.js";
22
23
  export { Shortcut } from "./shortcut.js";
23
24
  export { DragItem, FileDrop, } from "./drag-and-drop.js";
24
25
  export { TrayIcon } from "./tray-icon.js";
@@ -48,6 +49,8 @@ export { ViewBase, ViewBehavior, contributeAccessibility, } from "./view-base.js
48
49
  export { VirtualList, VirtualListRow, VirtualListSeparator, } from "./virtual-list.js";
49
50
  export { VIRTUAL_LIST_LAYOUT } from "./virtual-list-layout.js";
50
51
  export { VirtualListNumColumns } from "./virtual-list-num-columns.js";
52
+ export { VIRTUAL_LIST_STICKY } from "./virtual-list-sticky.js";
53
+ export { VirtualListStickyLevel } from "./virtual-list-sticky-level.js";
51
54
  export {} from "./gesture-backend.js";
52
55
  export { workletScroll, workletStyle, } from "./worklets.js";
53
56
  export { releaseOnDestroy } from "./release-on-destroy.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAmD,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAwCN,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAA+D,MAAM,YAAY,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,yBAAyB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAiC,MAAM,6BAA6B,CAAC;AAClG,OAAO,EACL,KAAK,GAIN,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,QAAQ,EACR,QAAQ,GAIT,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAyB,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,OAAO,EAAm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,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,GAMrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,mBAAmB,EAA0B,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAA6D,MAAM,sBAAsB,CAAC;AACjG,OAAO,EACL,aAAa,EACb,YAAY,GAMb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * The host primitives, and the platform-capability tokens they inject.\n *\n * Every element a template renders natively is a component here and must be imported by the\n * component whose template uses it, as any Angular component must. A template that uses one\n * without importing it compiles, renders a plain view, and is reported in dev builds.\n *\n * Importing this barrel evaluates decorators, so anything a Node test needs at runtime has to\n * be reached as a source file instead - see the note in `packages/integration-tests/compile.ts`.\n */\nexport { ActivityIndicator } from './activity-indicator.ts';\nexport { type AnimatedPropsHandle, type AnimationBackend } from './animation.ts';\nexport {\n type AccessibilityActionEvent,\n type AccessibilityActionPayload,\n type ContentSizeChangeEvent,\n type ImageErrorEvent,\n type ImageErrorPayload,\n type ImageLoadEvent,\n type ImageLoadPayload,\n type ImageProgressEvent,\n type ImageProgressPayload,\n type Insets,\n type KeyPressEvent,\n type KeyPressPayload,\n type LayoutEvent,\n type LayoutPayload,\n type OrientationChangeEvent,\n type OrientationChangePayload,\n type Point,\n type Rect,\n type ScrollEvent,\n type ScrollPayload,\n type SelectionChangeEvent,\n type SelectionChangePayload,\n type Size,\n type SwitchChangeEvent,\n type SwitchChangePayload,\n type TextInputChangeEvent,\n type TextInputChangePayload,\n type TextInputContentSizeEvent,\n type TextInputContentSizePayload,\n type TextInputEditingEvent,\n type TextInputFocusEvent,\n type TextInputFocusPayload,\n type TextInputScrollEvent,\n type TextInputScrollPayload,\n type TextLayoutEvent,\n type TextLayoutLine,\n type TextLayoutPayload,\n type TouchEvent,\n type TouchEventPayload,\n} from './events.ts';\nexport { Image, type ImageResizeMode, type ImageSource, type ImageURISource } from './image.ts';\nexport { ImageBackground } from './image-background.ts';\nexport { InputAccessoryView } from './input-accessory-view.ts';\nexport {\n KEYBOARD_CONTROLLER,\n KeyboardDock,\n KeyboardLift,\n provideKeyboardController,\n} from './keyboard-dock.ts';\nexport { KeyboardAvoidingView, type KeyboardAvoidingBehavior } from './keyboard-avoiding-view.ts';\nexport {\n Modal,\n type ModalAnchor,\n type ModalOrientation,\n type ModalPresentationStyle,\n} from './modal.ts';\nexport { MenuBar, MenuGroup, MenuItem, MenuSeparator, treeOrder } from './menu.ts';\nexport { CONTEXT_MENU, ContextMenu } from './context-menu.ts';\nexport { Shortcut } from './shortcut.ts';\nexport {\n DragItem,\n FileDrop,\n type DragItemValue,\n type DroppedFile,\n type FileDropEvent,\n} from './drag-and-drop.ts';\nexport { TrayIcon } from './tray-icon.ts';\nexport { SplitView, SplitViewContent, type SplitViewShowing } from './split-view.ts';\nexport { Sidebar, type SidebarRow } from './sidebar.ts';\nexport { SidebarSection } from './sidebar-section.ts';\nexport { SidebarItem, type SidebarItemIcon } from './sidebar-item.ts';\nexport { NativeButton, type ButtonIcon, type ButtonKind } from './native-button.ts';\nexport { NativeRef } from './native-ref.ts';\nexport {\n ControlBase,\n PressBehavior,\n Pressable,\n TouchableBase,\n type AndroidRipple,\n type PressEvent,\n} from './pressable.ts';\nexport {\n INTERACTION_OBSERVERS,\n SWIPE_VELOCITY,\n provideInteractionObserver,\n type InteractionDirection,\n type InteractionEvent,\n type InteractionGesture,\n type InteractionObserver,\n type InteractionType,\n} from './interaction-observer.ts';\nexport { RefreshControl } from './refresh-control.ts';\nexport { GradientText } from './gradient-text.ts';\nexport { type SafeAreaEdge, type SafeAreaEdges } from './safe-area.ts';\nexport { SafeAreaProvider } from './safe-area-provider.ts';\nexport { SafeAreaView, type SafeAreaEdgeMode } from './safe-area-view.ts';\nexport { type KeyboardShouldPersistTaps } from './keyboard-taps.ts';\nexport { ScrollView } from './scroll-view.ts';\nexport {\n SectionEdgeSeparator,\n SectionFooter,\n SectionHeader,\n SectionItem,\n SectionList,\n SectionSeparator,\n type SectionContext,\n type SectionEdgeSeparatorContext,\n type SectionItemContext,\n type SectionListSection,\n type SectionRow,\n type SectionSeparatorContext,\n} from './section-list.ts';\nexport { Switch } from './switch.ts';\nexport { Text, type DynamicTypeRamp, type EllipsizeMode } from './text.ts';\nexport {\n TextInput,\n type KeyboardType,\n type ReturnKeyType,\n type SubmitBehavior,\n} from './text-input.ts';\nexport { TouchableOpacity } from './touchable-opacity.ts';\nexport { optionalBoolean, optionalNumber } from './transforms.ts';\nexport { View } from './view.ts';\nexport {\n ViewBase,\n ViewBehavior,\n contributeAccessibility,\n type AccessibilityAction,\n type AccessibilityContribution,\n type AccessibilityLiveRegion,\n type AccessibilityRole,\n type Role,\n type AccessibilityState,\n type AccessibilityValue,\n type AndroidDrawable,\n type ImportantForAccessibility,\n type PointerEvents,\n} from './view-base.ts';\nexport {\n VirtualList,\n VirtualListRow,\n VirtualListSeparator,\n type VirtualItemHeight,\n type VirtualListSeparatorContext,\n type VirtualListPadding,\n type VirtualListVisiblePosition,\n type VirtualRow,\n} from './virtual-list.ts';\nexport { VIRTUAL_LIST_LAYOUT, type VirtualListLayout } from './virtual-list-layout.ts';\nexport { VirtualListNumColumns } from './virtual-list-num-columns.ts';\nexport { type GestureBackend, type GestureSpec, type GestureTarget } from './gesture-backend.ts';\nexport {\n workletScroll,\n workletStyle,\n type SharedValue,\n type WorkletBackend,\n type WorkletScrollSpec,\n type WorkletStyleSpec,\n type WorkletTarget,\n} from './worklets.ts';\nexport { releaseOnDestroy } from './release-on-destroy.ts';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAmD,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAwCN,MAAM,a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OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * The host primitives, and the platform-capability tokens they inject.\n *\n * Every element a template renders natively is a component here and must be imported by the\n * component whose template uses it, as any Angular component must. A template that uses one\n * without importing it compiles, renders a plain view, and is reported in dev builds.\n *\n * Importing this barrel evaluates decorators, so anything a Node test needs at runtime has to\n * be reached as a source file instead - see the note in `packages/integration-tests/compile.ts`.\n */\nexport { ActivityIndicator } from './activity-indicator.ts';\nexport { type AnimatedPropsHandle, type AnimationBackend } from './animation.ts';\nexport {\n type AccessibilityActionEvent,\n type AccessibilityActionPayload,\n type ContentSizeChangeEvent,\n type ImageErrorEvent,\n type ImageErrorPayload,\n type ImageLoadEvent,\n type ImageLoadPayload,\n type ImageProgressEvent,\n type ImageProgressPayload,\n type Insets,\n type KeyPressEvent,\n type KeyPressPayload,\n type LayoutEvent,\n type LayoutPayload,\n type OrientationChangeEvent,\n type OrientationChangePayload,\n type Point,\n type Rect,\n type ScrollEvent,\n type ScrollPayload,\n type SelectionChangeEvent,\n type SelectionChangePayload,\n type Size,\n type SwitchChangeEvent,\n type SwitchChangePayload,\n type TextInputChangeEvent,\n type TextInputChangePayload,\n type TextInputContentSizeEvent,\n type TextInputContentSizePayload,\n type TextInputEditingEvent,\n type TextInputFocusEvent,\n type TextInputFocusPayload,\n type TextInputScrollEvent,\n type TextInputScrollPayload,\n type TextLayoutEvent,\n type TextLayoutLine,\n type TextLayoutPayload,\n type TouchEvent,\n type TouchEventPayload,\n} from './events.ts';\nexport { Image, type ImageResizeMode, type ImageSource, type ImageURISource } from './image.ts';\nexport { ImageBackground } from './image-background.ts';\nexport { InputAccessoryView } from './input-accessory-view.ts';\nexport {\n KEYBOARD_CONTROLLER,\n KeyboardDock,\n KeyboardLift,\n provideKeyboardController,\n} from './keyboard-dock.ts';\nexport { KeyboardAvoidingView, type KeyboardAvoidingBehavior } from './keyboard-avoiding-view.ts';\nexport {\n Modal,\n type ModalAnchor,\n type ModalOrientation,\n type ModalPresentationStyle,\n} from './modal.ts';\nexport { MenuBar, MenuGroup, MenuItem, MenuSeparator, treeOrder } from './menu.ts';\nexport { CONTEXT_MENU, ContextMenu } from './context-menu.ts';\nexport { PRESS_MENU, PressMenu } from './press-menu.ts';\nexport { Shortcut } from './shortcut.ts';\nexport {\n DragItem,\n FileDrop,\n type DragItemValue,\n type DroppedFile,\n type FileDropEvent,\n} from './drag-and-drop.ts';\nexport { TrayIcon } from './tray-icon.ts';\nexport { SplitView, SplitViewContent, type SplitViewShowing } from './split-view.ts';\nexport { Sidebar, type SidebarRow } from './sidebar.ts';\nexport { SidebarSection } from './sidebar-section.ts';\nexport { SidebarItem, type SidebarItemIcon } from './sidebar-item.ts';\nexport { NativeButton, type ButtonIcon, type ButtonKind } from './native-button.ts';\nexport { NativeRef } from './native-ref.ts';\nexport {\n ControlBase,\n PressBehavior,\n Pressable,\n TouchableBase,\n type AndroidRipple,\n type PressEvent,\n} from './pressable.ts';\nexport {\n INTERACTION_OBSERVERS,\n SWIPE_VELOCITY,\n provideInteractionObserver,\n type InteractionDirection,\n type InteractionEvent,\n type InteractionGesture,\n type InteractionObserver,\n type InteractionType,\n} from './interaction-observer.ts';\nexport { RefreshControl } from './refresh-control.ts';\nexport { GradientText } from './gradient-text.ts';\nexport { type SafeAreaEdge, type SafeAreaEdges } from './safe-area.ts';\nexport { SafeAreaProvider } from './safe-area-provider.ts';\nexport { SafeAreaView, type SafeAreaEdgeMode } from './safe-area-view.ts';\nexport { type KeyboardShouldPersistTaps } from './keyboard-taps.ts';\nexport { ScrollView } from './scroll-view.ts';\nexport {\n SectionEdgeSeparator,\n SectionFooter,\n SectionHeader,\n SectionItem,\n SectionList,\n SectionSeparator,\n type SectionContext,\n type SectionEdgeSeparatorContext,\n type SectionItemContext,\n type SectionListSection,\n type SectionRow,\n type SectionSeparatorContext,\n} from './section-list.ts';\nexport { Switch } from './switch.ts';\nexport { Text, type DynamicTypeRamp, type EllipsizeMode } from './text.ts';\nexport {\n TextInput,\n type KeyboardType,\n type ReturnKeyType,\n type SubmitBehavior,\n} from './text-input.ts';\nexport { TouchableOpacity } from './touchable-opacity.ts';\nexport { optionalBoolean, optionalNumber } from './transforms.ts';\nexport { View } from './view.ts';\nexport {\n ViewBase,\n ViewBehavior,\n contributeAccessibility,\n type AccessibilityAction,\n type AccessibilityContribution,\n type AccessibilityLiveRegion,\n type AccessibilityRole,\n type Role,\n type AccessibilityState,\n type AccessibilityValue,\n type AndroidDrawable,\n type ImportantForAccessibility,\n type PointerEvents,\n} from './view-base.ts';\nexport {\n VirtualList,\n VirtualListRow,\n VirtualListSeparator,\n type VirtualItemHeight,\n type VirtualListSeparatorContext,\n type VirtualListPadding,\n type VirtualListVisiblePosition,\n type VirtualRow,\n} from './virtual-list.ts';\nexport { VIRTUAL_LIST_LAYOUT, type VirtualListLayout } from './virtual-list-layout.ts';\nexport { VirtualListNumColumns } from './virtual-list-num-columns.ts';\nexport { VIRTUAL_LIST_STICKY, type VirtualListSticky } from './virtual-list-sticky.ts';\nexport { VirtualListStickyLevel } from './virtual-list-sticky-level.ts';\nexport { type GestureBackend, type GestureSpec, type GestureTarget } from './gesture-backend.ts';\nexport {\n workletScroll,\n workletStyle,\n type SharedValue,\n type WorkletBackend,\n type WorkletScrollSpec,\n type WorkletStyleSpec,\n type WorkletTarget,\n} from './worklets.ts';\nexport { releaseOnDestroy } from './release-on-destroy.ts';\n"]}
package/dist/menu.d.ts CHANGED
@@ -4,15 +4,16 @@
4
4
  * `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a
5
5
  * `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.
6
6
  */
7
- import { type OutputEmitterRef } from '@angular/core';
7
+ import { type OnChanges, type OutputEmitterRef, type SimpleChanges } from '@angular/core';
8
8
  import { type MenuGroupRole, type MenuRole } from '@ng-native/device';
9
9
  import * as i0 from "@angular/core";
10
10
  export { menuModelInTreeOrder, treeOrder } from '@ng-native/device';
11
11
  /**
12
- * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An
13
- * item with a `menuRole` and no `(select)` does what the OS does for that role.
12
+ * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. A
13
+ * one-way `[checked]` stays as the app binds it, so a menu of choices checks the one the app keeps.
14
+ * An item with a `menuRole` and no `(select)` does what the OS does for that role.
14
15
  */
15
- export declare class MenuItem {
16
+ export declare class MenuItem implements OnChanges {
16
17
  readonly label: import("@angular/core").InputSignal<string>;
17
18
  /** What the item is for, where the OS has a standard one: it replaces that default. */
18
19
  readonly menuRole: import("@angular/core").InputSignal<MenuRole | undefined>;
@@ -21,6 +22,7 @@ export declare class MenuItem {
21
22
  readonly disabled: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
22
23
  /** A check mark. Bound two-way, it toggles as the item is chosen. */
23
24
  readonly checked: import("@angular/core").ModelSignal<boolean | undefined>;
25
+ private readonly checkedModel;
24
26
  readonly destructive: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
25
27
  readonly subtitle: import("@angular/core").InputSignal<string | undefined>;
26
28
  /** An SF Symbol, on Apple's OSes. */
@@ -30,6 +32,7 @@ export declare class MenuItem {
30
32
  readonly select: OutputEmitterRef<void>;
31
33
  private readonly handled;
32
34
  constructor();
35
+ ngOnChanges(changes: SimpleChanges): void;
33
36
  /** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */
34
37
  private readonly choose;
35
38
  static ɵfac: i0.ɵɵFactoryDeclaration<MenuItem, never>;
package/dist/menu.js CHANGED
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import { Component, DestroyRef, ElementRef, booleanAttribute, computed, inject, input, model, output, signal, } from '@angular/core';
8
8
  import { MENU_MODEL, Menus, menuModelInTreeOrder, } from '@ng-native/device';
9
+ import { ControlledModel } from "./controlled-model.js";
9
10
  import * as i0 from "@angular/core";
10
11
  export { menuModelInTreeOrder, treeOrder } from '@ng-native/device';
11
12
  /** Register `entry` with the menu the element is written in, and take it out as it goes. */
@@ -44,8 +45,9 @@ function listened(emitter) {
44
45
  return computed(() => listeners() > 0);
45
46
  }
46
47
  /**
47
- * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An
48
- * item with a `menuRole` and no `(select)` does what the OS does for that role.
48
+ * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. A
49
+ * one-way `[checked]` stays as the app binds it, so a menu of choices checks the one the app keeps.
50
+ * An item with a `menuRole` and no `(select)` does what the OS does for that role.
49
51
  */
50
52
  export class MenuItem {
51
53
  label = input('', /* @ts-ignore */
@@ -60,6 +62,7 @@ export class MenuItem {
60
62
  /** A check mark. Bound two-way, it toggles as the item is chosen. */
61
63
  checked = model(undefined, /* @ts-ignore */
62
64
  ...(ngDevMode ? [{ debugName: "checked" }] : /* istanbul ignore next */ []));
65
+ checkedModel = new ControlledModel(this.checked, 'checked');
63
66
  destructive = input(false, { ...(ngDevMode ? { debugName: "destructive" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
64
67
  subtitle = input(/* @ts-ignore */
65
68
  ...(ngDevMode ? [undefined, { debugName: "subtitle" }] : /* istanbul ignore next */ []));
@@ -91,17 +94,20 @@ export class MenuItem {
91
94
  };
92
95
  }), 'menu-item');
93
96
  }
97
+ ngOnChanges(changes) {
98
+ this.checkedModel.noteChanges(changes);
99
+ }
94
100
  /** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */
95
101
  choose = () => {
96
102
  if (this.disabled())
97
103
  return;
98
104
  const checked = this.checked();
99
105
  if (checked !== undefined)
100
- this.checked.set(!checked);
106
+ this.checkedModel.propose(!checked);
101
107
  this.select.emit();
102
108
  };
103
109
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
104
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: MenuItem, isStandalone: true, selector: "menu-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, menuRole: { classPropertyName: "menuRole", publicName: "menuRole", isSignal: true, isRequired: false, transformFunction: null }, shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, destructive: { classPropertyName: "destructive", publicName: "destructive", isSignal: true, isRequired: false, transformFunction: null }, subtitle: { classPropertyName: "subtitle", publicName: "subtitle", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", select: "select" }, host: { properties: { "style.display": "\"none\"" } }, ngImport: i0, template: '', isInline: true });
110
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: MenuItem, isStandalone: true, selector: "menu-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, menuRole: { classPropertyName: "menuRole", publicName: "menuRole", isSignal: true, isRequired: false, transformFunction: null }, shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, checked: { classPropertyName: "checked", publicName: "checked", isSignal: true, isRequired: false, transformFunction: null }, destructive: { classPropertyName: "destructive", publicName: "destructive", isSignal: true, isRequired: false, transformFunction: null }, subtitle: { classPropertyName: "subtitle", publicName: "subtitle", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { checked: "checkedChange", select: "select" }, host: { properties: { "style.display": "\"none\"" } }, usesOnChanges: true, ngImport: i0, template: '', isInline: true });
105
111
  }
106
112
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MenuItem, decorators: [{
107
113
  type: Component,
package/dist/menu.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,GAGP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,KAAK,EACL,oBAAoB,GAIrB,MAAM,mBAAmB,CAAC;;AAG3B,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpE,4FAA4F;AAC5F,SAAS,UAAU,CAAC,KAAwB,EAAE,OAAe;IAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,IAAI,CACV,qBAAqB,OAAO,mDAAmD;YAC7E,oFAAoF,CACvF,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,aAA2B,CAAC;IAC5D,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,SAAS,QAAQ,CAAC,OAA+B;IAC/C,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC;kFAAC,CAAC;I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;;GAKG;AAOH,MAAM,OAAO,OAAO;IAClB;QACE,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,CAAC;uGAJU,OAAO;2FAAP,OAAO,8GAFP,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,OAAO;kBANnB,SAAS;mBAAC;oBACT,QAAQ,EAAE,UAAU;oBACpB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE","sourcesContent":["/**\n * Menus written as elements: `<menu-bar>`, `<menu-group>`, `<menu-item>` and `<menu-separator>`.\n * They draw nothing themselves. Each item registers itself with the menu it is written in, through\n * `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a\n * `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.\n */\nimport {\n Component,\n DestroyRef,\n ElementRef,\n booleanAttribute,\n computed,\n inject,\n input,\n model,\n output,\n signal,\n type OutputEmitterRef,\n type Signal,\n} from '@angular/core';\nimport {\n MENU_MODEL,\n Menus,\n menuModelInTreeOrder,\n type MenuEntry,\n type MenuGroupRole,\n type MenuRole,\n} from '@ng-native/device';\nimport type { EngineNode } from '@ng-native/fabric';\n\nexport { menuModelInTreeOrder, treeOrder } from '@ng-native/device';\n\n/** Register `entry` with the menu the element is written in, and take it out as it goes. */\nfunction registerIn(entry: Signal<MenuEntry>, element: string): void {\n const menu = inject(MENU_MODEL, { optional: true, skipSelf: true });\n if (!menu) {\n console.warn(\n `[angular-native] <${element}> is outside a menu: write it in a <menu-bar>, a ` +\n '<menu-group>, or a template given to [contextMenu] or <native-header-item [menu]>.',\n );\n return;\n }\n const node = inject(ElementRef).nativeElement as EngineNode;\n inject(DestroyRef).onDestroy(menu.register(entry, node));\n}\n\n/**\n * Count an output's listeners, so an item knows whether the app handles it: as a signal, so the\n * menu follows a listener added or removed after it was first sent.\n */\nfunction listened(emitter: OutputEmitterRef<void>): Signal<boolean> {\n const listeners = signal(0);\n const subscribe = emitter.subscribe.bind(emitter);\n emitter.subscribe = (callback) => {\n listeners.update((count) => count + 1);\n const subscription = subscribe(callback);\n let stopped = false;\n return {\n unsubscribe: () => {\n if (stopped) return;\n stopped = true;\n listeners.update((count) => count - 1);\n subscription.unsubscribe();\n },\n };\n };\n return computed(() => listeners() > 0);\n}\n\n/**\n * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. An\n * item with a `menuRole` and no `(select)` does what the OS does for that role.\n */\n@Component({\n selector: 'menu-item',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuItem {\n readonly label = input('');\n /** What the item is for, where the OS has a standard one: it replaces that default. */\n readonly menuRole = input<MenuRole>();\n /** `mod+s`: Cmd on Apple's OSes, Ctrl on Android. */\n readonly shortcut = input<string>();\n readonly disabled = input(false, { transform: booleanAttribute });\n /** A check mark. Bound two-way, it toggles as the item is chosen. */\n readonly checked = model<boolean | undefined>(undefined);\n readonly destructive = input(false, { transform: booleanAttribute });\n readonly subtitle = input<string>();\n /** An SF Symbol, on Apple's OSes. */\n readonly sfSymbol = input<string>();\n /** A drawable resource's name, on Android. */\n readonly icon = input<string>();\n readonly select = output<void>();\n\n private readonly handled = listened(this.select);\n\n constructor() {\n registerIn(\n computed(() => {\n const checked = this.checked();\n const role = this.menuRole();\n // An item with a role and no handler is the OS's: no `select`, so the host does it.\n const own = !role || this.handled() || checked !== undefined;\n return {\n label: this.label(),\n ...(role && { menuRole: role }),\n ...(this.shortcut() && { shortcut: this.shortcut() }),\n ...(this.disabled() && { disabled: true }),\n ...(checked !== undefined && { checked }),\n ...(this.destructive() && { destructive: true }),\n ...(this.subtitle() && { subtitle: this.subtitle() }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(own && { select: this.choose }),\n };\n }),\n 'menu-item',\n );\n }\n\n /** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */\n private readonly choose = (): void => {\n if (this.disabled()) return;\n const checked = this.checked();\n if (checked !== undefined) this.checked.set(!checked);\n this.select.emit();\n };\n}\n\n/** A line between items. */\n@Component({\n selector: 'menu-separator',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuSeparator {\n constructor() {\n registerIn(\n computed(() => ({ separator: true }) as const),\n 'menu-separator',\n );\n }\n}\n\n/**\n * A submenu, a section of the menu it is in (`inline`), or in a `<menu-bar>` a menu of the bar. In\n * a bar, a `menuRole` of `app`, `file`, `edit`, `view`, `window` or `help` adds its items to that\n * standard menu.\n */\n@Component({\n selector: 'menu-group',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuGroup {\n readonly label = input('');\n readonly menuRole = input<MenuGroupRole>();\n readonly inline = input(false, { transform: booleanAttribute });\n readonly sfSymbol = input<string>();\n readonly icon = input<string>();\n readonly destructive = input(false, { transform: booleanAttribute });\n\n private readonly own = inject(MENU_MODEL, { self: true });\n\n constructor() {\n registerIn(\n computed(() => ({\n label: this.label(),\n items: this.own.entries(),\n ...(this.menuRole() && { group: this.menuRole() }),\n ...(this.inline() && { inline: true }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(this.destructive() && { destructive: true }),\n })),\n 'menu-group',\n );\n }\n}\n\n/**\n * The app's menus in the menu bar, merged with the menus every desktop app has: App, Edit, View,\n * Window and Help. On macOS and iPadOS it is the menu bar. On iPhone and Android nothing is drawn,\n * and the items' shortcuts work from a hardware keyboard. It can be anywhere in the app, and\n * follows what its items say for as long as it is there.\n */\n@Component({\n selector: 'menu-bar',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuBar {\n constructor() {\n const own = inject(MENU_MODEL, { self: true });\n inject(DestroyRef).onDestroy(inject(Menus).addMenuBar(own.entries));\n }\n}\n"]}
1
+ {"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,GAKP,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,KAAK,EACL,oBAAoB,GAIrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;;AAExD,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEpE,4FAA4F;AAC5F,SAAS,UAAU,CAAC,KAAwB,EAAE,OAAe;IAC3D,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,IAAI,CACV,qBAAqB,OAAO,mDAAmD;YAC7E,oFAAoF,CACvF,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,aAA2B,CAAC;IAC5D,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC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,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,SAAS;kBANrB,SAAS;mBAAC;oBACT,QAAQ,EAAE,YAAY;oBACtB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE;;AA2BD;;;;;GAKG;AAOH,MAAM,OAAO,OAAO;IAClB;QACE,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,CAAC;uGAJU,OAAO;2FAAP,OAAO,8GAFP,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC,0BAF5D,gBAAgB;;2FAIf,OAAO;kBANnB,SAAS;mBAAC;oBACT,QAAQ,EAAE,UAAU;oBACpB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE,EAAE,iBAAiB,EAAE,QAAQ,EAAE;oBACrC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,CAAC;iBACvE","sourcesContent":["/**\n * Menus written as elements: `<menu-bar>`, `<menu-group>`, `<menu-item>` and `<menu-separator>`.\n * They draw nothing themselves. Each item registers itself with the menu it is written in, through\n * `MENU_MODEL`, and the menu's owner draws it: `Menus` sends a `<menu-bar>` to the host, and a\n * `[contextMenu]` or a `<native-header-item [menu]>` reads a template of items.\n */\nimport {\n Component,\n DestroyRef,\n ElementRef,\n booleanAttribute,\n computed,\n inject,\n input,\n model,\n output,\n signal,\n type OnChanges,\n type OutputEmitterRef,\n type Signal,\n type SimpleChanges,\n} from '@angular/core';\nimport {\n MENU_MODEL,\n Menus,\n menuModelInTreeOrder,\n type MenuEntry,\n type MenuGroupRole,\n type MenuRole,\n} from '@ng-native/device';\nimport type { EngineNode } from '@ng-native/fabric';\nimport { ControlledModel } from './controlled-model.ts';\n\nexport { menuModelInTreeOrder, treeOrder } from '@ng-native/device';\n\n/** Register `entry` with the menu the element is written in, and take it out as it goes. */\nfunction registerIn(entry: Signal<MenuEntry>, element: string): void {\n const menu = inject(MENU_MODEL, { optional: true, skipSelf: true });\n if (!menu) {\n console.warn(\n `[angular-native] <${element}> is outside a menu: write it in a <menu-bar>, a ` +\n '<menu-group>, or a template given to [contextMenu] or <native-header-item [menu]>.',\n );\n return;\n }\n const node = inject(ElementRef).nativeElement as EngineNode;\n inject(DestroyRef).onDestroy(menu.register(entry, node));\n}\n\n/**\n * Count an output's listeners, so an item knows whether the app handles it: as a signal, so the\n * menu follows a listener added or removed after it was first sent.\n */\nfunction listened(emitter: OutputEmitterRef<void>): Signal<boolean> {\n const listeners = signal(0);\n const subscribe = emitter.subscribe.bind(emitter);\n emitter.subscribe = (callback) => {\n listeners.update((count) => count + 1);\n const subscription = subscribe(callback);\n let stopped = false;\n return {\n unsubscribe: () => {\n if (stopped) return;\n stopped = true;\n listeners.update((count) => count - 1);\n subscription.unsubscribe();\n },\n };\n };\n return computed(() => listeners() > 0);\n}\n\n/**\n * One item of a menu. `(select)` fires when it is chosen, and a `[(checked)]` item toggles. A\n * one-way `[checked]` stays as the app binds it, so a menu of choices checks the one the app keeps.\n * An item with a `menuRole` and no `(select)` does what the OS does for that role.\n */\n@Component({\n selector: 'menu-item',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuItem implements OnChanges {\n readonly label = input('');\n /** What the item is for, where the OS has a standard one: it replaces that default. */\n readonly menuRole = input<MenuRole>();\n /** `mod+s`: Cmd on Apple's OSes, Ctrl on Android. */\n readonly shortcut = input<string>();\n readonly disabled = input(false, { transform: booleanAttribute });\n /** A check mark. Bound two-way, it toggles as the item is chosen. */\n readonly checked = model<boolean | undefined>(undefined);\n private readonly checkedModel = new ControlledModel(this.checked, 'checked');\n readonly destructive = input(false, { transform: booleanAttribute });\n readonly subtitle = input<string>();\n /** An SF Symbol, on Apple's OSes. */\n readonly sfSymbol = input<string>();\n /** A drawable resource's name, on Android. */\n readonly icon = input<string>();\n readonly select = output<void>();\n\n private readonly handled = listened(this.select);\n\n constructor() {\n registerIn(\n computed(() => {\n const checked = this.checked();\n const role = this.menuRole();\n // An item with a role and no handler is the OS's: no `select`, so the host does it.\n const own = !role || this.handled() || checked !== undefined;\n return {\n label: this.label(),\n ...(role && { menuRole: role }),\n ...(this.shortcut() && { shortcut: this.shortcut() }),\n ...(this.disabled() && { disabled: true }),\n ...(checked !== undefined && { checked }),\n ...(this.destructive() && { destructive: true }),\n ...(this.subtitle() && { subtitle: this.subtitle() }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(own && { select: this.choose }),\n };\n }),\n 'menu-item',\n );\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n this.checkedModel.noteChanges(changes);\n }\n\n /** One handler for the item's life: the id a host reports a choice by. See `menuActionId`. */\n private readonly choose = (): void => {\n if (this.disabled()) return;\n const checked = this.checked();\n if (checked !== undefined) this.checkedModel.propose(!checked);\n this.select.emit();\n };\n}\n\n/** A line between items. */\n@Component({\n selector: 'menu-separator',\n template: '',\n host: { '[style.display]': '\"none\"' },\n})\nexport class MenuSeparator {\n constructor() {\n registerIn(\n computed(() => ({ separator: true }) as const),\n 'menu-separator',\n );\n }\n}\n\n/**\n * A submenu, a section of the menu it is in (`inline`), or in a `<menu-bar>` a menu of the bar. In\n * a bar, a `menuRole` of `app`, `file`, `edit`, `view`, `window` or `help` adds its items to that\n * standard menu.\n */\n@Component({\n selector: 'menu-group',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuGroup {\n readonly label = input('');\n readonly menuRole = input<MenuGroupRole>();\n readonly inline = input(false, { transform: booleanAttribute });\n readonly sfSymbol = input<string>();\n readonly icon = input<string>();\n readonly destructive = input(false, { transform: booleanAttribute });\n\n private readonly own = inject(MENU_MODEL, { self: true });\n\n constructor() {\n registerIn(\n computed(() => ({\n label: this.label(),\n items: this.own.entries(),\n ...(this.menuRole() && { group: this.menuRole() }),\n ...(this.inline() && { inline: true }),\n ...(this.sfSymbol() && { sfSymbol: this.sfSymbol() }),\n ...(this.icon() && { icon: this.icon() }),\n ...(this.destructive() && { destructive: true }),\n })),\n 'menu-group',\n );\n }\n}\n\n/**\n * The app's menus in the menu bar, merged with the menus every desktop app has: App, Edit, View,\n * Window and Help. On macOS and iPadOS it is the menu bar. On iPhone and Android nothing is drawn,\n * and the items' shortcuts work from a hardware keyboard. It can be anywhere in the app, and\n * follows what its items say for as long as it is there.\n */\n@Component({\n selector: 'menu-bar',\n template: '<ng-content />',\n host: { '[style.display]': '\"none\"' },\n providers: [{ provide: MENU_MODEL, useFactory: menuModelInTreeOrder }],\n})\nexport class MenuBar {\n constructor() {\n const own = inject(MENU_MODEL, { self: true });\n inject(DestroyRef).onDestroy(inject(Menus).addMenuBar(own.entries));\n }\n}\n"]}