@ng-native/components 0.26.1 → 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 (65) 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/drag-and-drop.d.ts +4 -4
  8. package/dist/drag-and-drop.js +6 -6
  9. package/dist/drag-and-drop.js.map +1 -1
  10. package/dist/index.d.ts +3 -0
  11. package/dist/index.js +3 -0
  12. package/dist/index.js.map +1 -1
  13. package/dist/menu.d.ts +7 -4
  14. package/dist/menu.js +10 -4
  15. package/dist/menu.js.map +1 -1
  16. package/dist/modal.d.ts +12 -8
  17. package/dist/modal.js +8 -8
  18. package/dist/modal.js.map +1 -1
  19. package/dist/native-button.d.ts +13 -3
  20. package/dist/native-button.js +12 -5
  21. package/dist/native-button.js.map +1 -1
  22. package/dist/press-menu.d.ts +39 -0
  23. package/dist/press-menu.js +76 -0
  24. package/dist/press-menu.js.map +1 -0
  25. package/dist/pressable.d.ts +3 -0
  26. package/dist/pressable.js +6 -1
  27. package/dist/pressable.js.map +1 -1
  28. package/dist/reanimated.js +27 -3
  29. package/dist/reanimated.js.map +1 -1
  30. package/dist/safe-area-provider.js +9 -7
  31. package/dist/safe-area-provider.js.map +1 -1
  32. package/dist/settled-updates.d.ts +55 -0
  33. package/dist/settled-updates.js +77 -0
  34. package/dist/settled-updates.js.map +1 -0
  35. package/dist/sidebar-item.d.ts +19 -4
  36. package/dist/sidebar-item.js +33 -6
  37. package/dist/sidebar-item.js.map +1 -1
  38. package/dist/sidebar-section.js +3 -2
  39. package/dist/sidebar-section.js.map +1 -1
  40. package/dist/stand-ins/reanimated.d.ts +5 -0
  41. package/dist/stand-ins/reanimated.js +7 -0
  42. package/dist/stand-ins/reanimated.js.map +1 -1
  43. package/dist/sticky-rows.d.ts +120 -25
  44. package/dist/sticky-rows.js +265 -65
  45. package/dist/sticky-rows.js.map +1 -1
  46. package/dist/svg-icon.d.ts +9 -0
  47. package/dist/svg-icon.js +37 -0
  48. package/dist/svg-icon.js.map +1 -0
  49. package/dist/virtual-list-sticky-level.d.ts +39 -0
  50. package/dist/virtual-list-sticky-level.js +82 -0
  51. package/dist/virtual-list-sticky-level.js.map +1 -0
  52. package/dist/virtual-list-sticky.d.ts +19 -0
  53. package/dist/virtual-list-sticky.js +13 -0
  54. package/dist/virtual-list-sticky.js.map +1 -0
  55. package/dist/virtual-list.d.ts +6 -2
  56. package/dist/virtual-list.js +60 -43
  57. package/dist/virtual-list.js.map +1 -1
  58. package/dist/worklet-style.d.ts +11 -0
  59. package/dist/worklet-style.js +15 -1
  60. package/dist/worklet-style.js.map +1 -1
  61. package/dist/worklets.d.ts +5 -1
  62. package/dist/worklets.js.map +1 -1
  63. package/dist/written-props.js +1 -0
  64. package/dist/written-props.js.map +1 -1
  65. 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,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,UAAU,EACV,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GAEV,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,EACL,EAAE,EACF,iBAAiB,EACjB,aAAa,GAGd,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,MAAM,EACX,IAAI,CAAC,IAAI,EACT,CAAC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C,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,CAAC;iBACnF;;AAyED,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 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,gG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CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;6EAAC,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"]}
@@ -17,7 +17,7 @@ export interface DragItemValue {
17
17
  readonly url?: string;
18
18
  }
19
19
  /**
20
- * Files, text and urls dragged onto a view, on macOS and iPadOS: `(fileDragEnter)` as a drag
20
+ * Files, text and urls dragged onto a view, on macOS, Linux and iPadOS: `(fileDragEnter)` as a drag
21
21
  * comes over it, `(fileDragLeave)` as it goes off without dropping, and `(fileDrop)` when it is
22
22
  * dropped. Each carries a `FileDropEvent`. On iPhone, Android and the web host nothing fires.
23
23
  *
@@ -36,9 +36,9 @@ export declare class FileDrop {
36
36
  static ɵdir: i0.ɵɵDirectiveDeclaration<FileDrop, "[fileDrop],[fileDragEnter],[fileDragLeave]", never, {}, { "fileDragEnter": "fileDragEnter"; "fileDragLeave": "fileDragLeave"; "fileDrop": "fileDrop"; }, never, never, true, never>;
37
37
  }
38
38
  /**
39
- * A view that can be dragged out, on macOS and iPadOS: to Finder, another app, or a `(fileDrop)`
40
- * view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of them; null for
41
- * none. A mouse drag starts it on macOS and a long press on iPadOS.
39
+ * A view that can be dragged out, on macOS, Linux and iPadOS: to a file manager, another app, or a
40
+ * `(fileDrop)` view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of
41
+ * them; null for none. A mouse drag starts it on macOS and Linux, and a long press on iPadOS.
42
42
  *
43
43
  * The host contract: the view takes a `dragItem` prop of `{ files, text, url }`, with each file
44
44
  * as a `file://` url and the others a string or null, or null to take it away. On iOS the item
@@ -3,15 +3,15 @@ import { DragAndDrop, OS } from '@ng-native/device';
3
3
  import { HostEngine } from '@ng-native/fabric';
4
4
  import { byNativeId } from "./native-id.js";
5
5
  import * as i0 from "@angular/core";
6
- /** Drag and drop exists on macOS and iPadOS; iPhone's host ignores both props. */
7
- const takesDrags = (os) => os === 'macos' || os === 'ios';
6
+ /** Drag and drop exists on macOS, Linux and iPadOS; iPhone's host ignores both props. */
7
+ const takesDrags = (os) => os === 'macos' || os === 'linux' || os === 'ios';
8
8
  /** iOS's host module, which takes both by the view's `nativeID`, where the app has it. */
9
9
  function moduleOnIos(os) {
10
10
  const module = inject(DragAndDrop);
11
11
  return os === 'ios' && module.available() ? module : null;
12
12
  }
13
13
  /**
14
- * Files, text and urls dragged onto a view, on macOS and iPadOS: `(fileDragEnter)` as a drag
14
+ * Files, text and urls dragged onto a view, on macOS, Linux and iPadOS: `(fileDragEnter)` as a drag
15
15
  * comes over it, `(fileDragLeave)` as it goes off without dropping, and `(fileDrop)` when it is
16
16
  * dropped. Each carries a `FileDropEvent`. On iPhone, Android and the web host nothing fires.
17
17
  *
@@ -55,9 +55,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
55
55
  args: [{ selector: '[fileDrop],[fileDragEnter],[fileDragLeave]' }]
56
56
  }], ctorParameters: () => [], propDecorators: { fileDragEnter: [{ type: i0.Output, args: ["fileDragEnter"] }], fileDragLeave: [{ type: i0.Output, args: ["fileDragLeave"] }], fileDrop: [{ type: i0.Output, args: ["fileDrop"] }] } });
57
57
  /**
58
- * A view that can be dragged out, on macOS and iPadOS: to Finder, another app, or a `(fileDrop)`
59
- * view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of them; null for
60
- * none. A mouse drag starts it on macOS and a long press on iPadOS.
58
+ * A view that can be dragged out, on macOS, Linux and iPadOS: to a file manager, another app, or a
59
+ * `(fileDrop)` view. `[dragItem]="{ files: [path] }"`, `{ text }` or `{ url }`, or several of
60
+ * them; null for none. A mouse drag starts it on macOS and Linux, and a long press on iPadOS.
61
61
  *
62
62
  * The host contract: the view takes a `dragItem` prop of `{ files, text, url }`, with each file
63
63
  * as a `file://` url and the others a string or null, or null to take it away. On iOS the item
@@ -1 +1 @@
1
- {"version":3,"file":"drag-and-drop.js","sourceRoot":"","sources":["../src/drag-and-drop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC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tB,CAAC;AACJ,CAAC;AAED,qDAAqD;AACrD,SAAS,OAAO,CAAC,IAAY;IAC3B,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,UAAU,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,MAAM,CAAC,OAAgB;IAC9B,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,EAAE,CAA2B,CAAC;IACzD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;AAC3F,CAAC","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n effect,\n inject,\n input,\n output,\n untracked,\n} from '@angular/core';\nimport { DragAndDrop, OS, type NativeDragItem } from '@ng-native/device';\nimport { HostEngine, type HostNode } from '@ng-native/fabric';\nimport { byNativeId } from './native-id.ts';\n\n/** A file dragged onto a view: its `file://` url and its name. */\nexport interface DroppedFile {\n readonly uri: string;\n readonly name: string;\n}\n\n/** What is dragged onto a view: files, plain text, and urls that are not files. */\nexport interface FileDropEvent {\n readonly files: readonly DroppedFile[];\n readonly text: string | null;\n readonly urls: readonly string[];\n}\n\n/** What a `[dragItem]` view offers when it is dragged out. Files are paths or `file://` urls. */\nexport interface DragItemValue {\n readonly files?: readonly string[];\n readonly text?: string;\n readonly url?: string;\n}\n\n/** Drag and drop exists on macOS and iPadOS; iPhone's host ignores both props. */\nconst takesDrags = (os: string): boolean => os === 'macos' || os === 'ios';\n\n/** iOS's host module, which takes both by the view's `nativeID`, where the app has it. */\nfunction moduleOnIos(os: string): DragAndDrop | null {\n const module = inject(DragAndDrop);\n return os === 'ios' && module.available() ? module : null;\n}\n\n/**\n * Files, text and urls dragged onto a view, on macOS and iPadOS: `(fileDragEnter)` as a drag\n * comes over it, `(fileDragLeave)` as it goes off without dropping, and `(fileDrop)` when it is\n * dropped. Each carries a `FileDropEvent`. On iPhone, Android and the web host nothing fires.\n *\n * The host contract: the view takes a `fileDrop` prop of `true`, and sends `topDropEnter`,\n * `topDropLeave` and `topDropPerform` with `{ files, text, urls }`. Those names differ from the\n * outputs', which a binding also listens for, so each output fires once. On iOS, where React\n * Native's view reads no such prop, the view goes to `DragAndDrop` by its `nativeID` instead, and\n * the same events come back from its module (iPadOS; a development build, not Expo Go).\n */\n@Directive({ selector: '[fileDrop],[fileDragEnter],[fileDragLeave]' })\nexport class FileDrop {\n readonly fileDragEnter = output<FileDropEvent>();\n readonly fileDragLeave = output<void>();\n readonly fileDrop = output<FileDropEvent>();\n\n constructor() {\n const os = inject(OS);\n if (!takesDrags(os)) return;\n const node = inject(ElementRef).nativeElement as HostNode;\n const engine = inject(HostEngine);\n engine.setProp(node, 'fileDrop', true);\n const hear = (type: string, native: unknown) => {\n if (type === 'topDropEnter' || type === 'dropEnter') this.fileDragEnter.emit(dropOf(native));\n else if (type === 'topDropLeave' || type === 'dropLeave') this.fileDragLeave.emit();\n else this.fileDrop.emit(dropOf(native));\n };\n const stops = ['topDropEnter', 'topDropLeave', 'topDropPerform'].map((type) =>\n engine.setEventListener(node, type, (event) =>\n hear(type, (event as { nativeEvent?: unknown }).nativeEvent),\n ),\n );\n inject(DestroyRef).onDestroy(() => stops.forEach((stop) => stop()));\n const module = moduleOnIos(os);\n if (module) {\n byNativeId(\n engine,\n node,\n (nativeID) => module.setFileDrop(nativeID, (event) => hear(event.type, event)),\n (nativeID) => module.setFileDrop(nativeID, null),\n )();\n }\n }\n}\n\n/**\n * A view that can be dragged out, on macOS and iPadOS: to Finder, another app, or a `(fileDrop)`\n * view. `[dragItem]=\"{ files: [path] }\"`, `{ text }` or `{ url }`, or several of them; null for\n * none. A mouse drag starts it on macOS and a long press on iPadOS.\n *\n * The host contract: the view takes a `dragItem` prop of `{ files, text, url }`, with each file\n * as a `file://` url and the others a string or null, or null to take it away. On iOS the item\n * goes to `DragAndDrop` by the view's `nativeID` too.\n */\n@Directive({ selector: '[dragItem]' })\nexport class DragItem {\n readonly dragItem = input<DragItemValue | null>();\n\n constructor() {\n const os = inject(OS);\n if (!takesDrags(os)) return;\n const node = inject(ElementRef).nativeElement as HostNode;\n const engine = inject(HostEngine);\n const module = moduleOnIos(os);\n const offered = () => {\n const item = untracked(this.dragItem);\n return item ? committedItem(item) : null;\n };\n const send =\n module &&\n byNativeId(\n engine,\n node,\n (nativeID) => module.setDragItem(nativeID, offered()),\n (nativeID) => module.setDragItem(nativeID, null),\n );\n effect(() => {\n this.dragItem();\n engine.setProp(node, 'dragItem', offered());\n send?.();\n });\n }\n}\n\nfunction committedItem(item: DragItemValue): NativeDragItem {\n return {\n files: (item.files ?? []).map(fileUrl),\n text: item.text ?? null,\n url: item.url ?? null,\n };\n}\n\n/** A path as a `file://` url, and a url as it is. */\nfunction fileUrl(file: string): string {\n if (/^[a-z][a-z0-9+.-]*:/i.test(file)) return file;\n return `file://${file.split('/').map(encodeURIComponent).join('/')}`;\n}\n\nfunction dropOf(payload: unknown): FileDropEvent {\n const native = (payload ?? {}) as Partial<FileDropEvent>;\n return { files: native.files ?? [], text: native.text ?? null, urls: native.urls ?? [] };\n}\n"]}
1
+ {"version":3,"file":"drag-and-drop.js","sourceRoot":"","sources":["../src/drag-and-drop.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,UAAU,EACV,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,EAAE,EAAuB,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB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AC;IACnD,OAAO,UAAU,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AACvE,CAAC;AAED,SAAS,MAAM,CAAC,OAAgB;IAC9B,MAAM,MAAM,GAAG,CAAC,OAAO,IAAI,EAAE,CAA2B,CAAC;IACzD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;AAC3F,CAAC","sourcesContent":["import {\n DestroyRef,\n Directive,\n ElementRef,\n effect,\n inject,\n input,\n output,\n untracked,\n} from '@angular/core';\nimport { DragAndDrop, OS, type NativeDragItem } from '@ng-native/device';\nimport { HostEngine, type HostNode } from '@ng-native/fabric';\nimport { byNativeId } from './native-id.ts';\n\n/** A file dragged onto a view: its `file://` url and its name. */\nexport interface DroppedFile {\n readonly uri: string;\n readonly name: string;\n}\n\n/** What is dragged onto a view: files, plain text, and urls that are not files. */\nexport interface FileDropEvent {\n readonly files: readonly DroppedFile[];\n readonly text: string | null;\n readonly urls: readonly string[];\n}\n\n/** What a `[dragItem]` view offers when it is dragged out. Files are paths or `file://` urls. */\nexport interface DragItemValue {\n readonly files?: readonly string[];\n readonly text?: string;\n readonly url?: string;\n}\n\n/** Drag and drop exists on macOS, Linux and iPadOS; iPhone's host ignores both props. */\nconst takesDrags = (os: string): boolean => os === 'macos' || os === 'linux' || os === 'ios';\n\n/** iOS's host module, which takes both by the view's `nativeID`, where the app has it. */\nfunction moduleOnIos(os: string): DragAndDrop | null {\n const module = inject(DragAndDrop);\n return os === 'ios' && module.available() ? module : null;\n}\n\n/**\n * Files, text and urls dragged onto a view, on macOS, Linux and iPadOS: `(fileDragEnter)` as a drag\n * comes over it, `(fileDragLeave)` as it goes off without dropping, and `(fileDrop)` when it is\n * dropped. Each carries a `FileDropEvent`. On iPhone, Android and the web host nothing fires.\n *\n * The host contract: the view takes a `fileDrop` prop of `true`, and sends `topDropEnter`,\n * `topDropLeave` and `topDropPerform` with `{ files, text, urls }`. Those names differ from the\n * outputs', which a binding also listens for, so each output fires once. On iOS, where React\n * Native's view reads no such prop, the view goes to `DragAndDrop` by its `nativeID` instead, and\n * the same events come back from its module (iPadOS; a development build, not Expo Go).\n */\n@Directive({ selector: '[fileDrop],[fileDragEnter],[fileDragLeave]' })\nexport class FileDrop {\n readonly fileDragEnter = output<FileDropEvent>();\n readonly fileDragLeave = output<void>();\n readonly fileDrop = output<FileDropEvent>();\n\n constructor() {\n const os = inject(OS);\n if (!takesDrags(os)) return;\n const node = inject(ElementRef).nativeElement as HostNode;\n const engine = inject(HostEngine);\n engine.setProp(node, 'fileDrop', true);\n const hear = (type: string, native: unknown) => {\n if (type === 'topDropEnter' || type === 'dropEnter') this.fileDragEnter.emit(dropOf(native));\n else if (type === 'topDropLeave' || type === 'dropLeave') this.fileDragLeave.emit();\n else this.fileDrop.emit(dropOf(native));\n };\n const stops = ['topDropEnter', 'topDropLeave', 'topDropPerform'].map((type) =>\n engine.setEventListener(node, type, (event) =>\n hear(type, (event as { nativeEvent?: unknown }).nativeEvent),\n ),\n );\n inject(DestroyRef).onDestroy(() => stops.forEach((stop) => stop()));\n const module = moduleOnIos(os);\n if (module) {\n byNativeId(\n engine,\n node,\n (nativeID) => module.setFileDrop(nativeID, (event) => hear(event.type, event)),\n (nativeID) => module.setFileDrop(nativeID, null),\n )();\n }\n }\n}\n\n/**\n * A view that can be dragged out, on macOS, Linux and iPadOS: to a file manager, another app, or a\n * `(fileDrop)` view. `[dragItem]=\"{ files: [path] }\"`, `{ text }` or `{ url }`, or several of\n * them; null for none. A mouse drag starts it on macOS and Linux, and a long press on iPadOS.\n *\n * The host contract: the view takes a `dragItem` prop of `{ files, text, url }`, with each file\n * as a `file://` url and the others a string or null, or null to take it away. On iOS the item\n * goes to `DragAndDrop` by the view's `nativeID` too.\n */\n@Directive({ selector: '[dragItem]' })\nexport class DragItem {\n readonly dragItem = input<DragItemValue | null>();\n\n constructor() {\n const os = inject(OS);\n if (!takesDrags(os)) return;\n const node = inject(ElementRef).nativeElement as HostNode;\n const engine = inject(HostEngine);\n const module = moduleOnIos(os);\n const offered = () => {\n const item = untracked(this.dragItem);\n return item ? committedItem(item) : null;\n };\n const send =\n module &&\n byNativeId(\n engine,\n node,\n (nativeID) => module.setDragItem(nativeID, offered()),\n (nativeID) => module.setDragItem(nativeID, null),\n );\n effect(() => {\n this.dragItem();\n engine.setProp(node, 'dragItem', offered());\n send?.();\n });\n }\n}\n\nfunction committedItem(item: DragItemValue): NativeDragItem {\n return {\n files: (item.files ?? []).map(fileUrl),\n text: item.text ?? null,\n url: item.url ?? null,\n };\n}\n\n/** A path as a `file://` url, and a url as it is. */\nfunction fileUrl(file: string): string {\n if (/^[a-z][a-z0-9+.-]*:/i.test(file)) return file;\n return `file://${file.split('/').map(encodeURIComponent).join('/')}`;\n}\n\nfunction dropOf(payload: unknown): FileDropEvent {\n const native = (payload ?? {}) as Partial<FileDropEvent>;\n return { files: native.files ?? [], text: native.text ?? null, urls: native.urls ?? [] };\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,EAAmB,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAwB,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAoC,MAAM,oBAAoB,CAAC;AACpF,OAAO,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AO,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,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,mBAA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AAC;AAC3D,OAAO,EAAE,YAAY,EAAyB,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAkC,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,GAOjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAA4C,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,SAAS,GAIV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,uBAAuB,GAWxB,MAAM,gBAAgB,CAAC;AACxB,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,EAAE,mBAAmB,EAA0B,MAAM,0BAA0B,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,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 { 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>;