@ng-native/components 0.22.1 → 0.23.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 (138) hide show
  1. package/android/build.gradle +22 -0
  2. package/android/src/main/java/dev/ngnative/components/ContextMenuAccessibility.kt +71 -0
  3. package/android/src/main/java/dev/ngnative/components/ContextMenuGesture.kt +161 -0
  4. package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +197 -0
  5. package/android/src/main/java/dev/ngnative/components/MenuHost.kt +45 -0
  6. package/android/src/main/java/dev/ngnative/components/MenuWindowCallback.kt +76 -0
  7. package/android/src/main/java/dev/ngnative/components/MenusModule.kt +85 -0
  8. package/android/src/main/java/dev/ngnative/components/Shortcut.kt +144 -0
  9. package/android/src/main/java/dev/ngnative/components/WindowWrapper.kt +22 -0
  10. package/dist/activity-indicator.d.ts +4 -1
  11. package/dist/activity-indicator.js +6 -2
  12. package/dist/activity-indicator.js.map +1 -1
  13. package/dist/context-menu.d.ts +52 -0
  14. package/dist/context-menu.js +101 -0
  15. package/dist/context-menu.js.map +1 -0
  16. package/dist/drag-and-drop.d.ts +52 -0
  17. package/dist/drag-and-drop.js +112 -0
  18. package/dist/drag-and-drop.js.map +1 -0
  19. package/dist/gesture-backend.d.ts +32 -2
  20. package/dist/gesture-backend.js.map +1 -1
  21. package/dist/gesture-dispatch.d.ts +8 -1
  22. package/dist/gesture-dispatch.js +60 -16
  23. package/dist/gesture-dispatch.js.map +1 -1
  24. package/dist/gesture-interaction.d.ts +13 -0
  25. package/dist/gesture-interaction.js +97 -0
  26. package/dist/gesture-interaction.js.map +1 -0
  27. package/dist/gesture-tracking.d.ts +18 -0
  28. package/dist/gesture-tracking.js +28 -0
  29. package/dist/gesture-tracking.js.map +1 -0
  30. package/dist/gestures-web.d.ts +3 -1
  31. package/dist/gestures-web.js +5 -2
  32. package/dist/gestures-web.js.map +1 -1
  33. package/dist/gestures.d.ts +1 -0
  34. package/dist/gestures.js +45 -3
  35. package/dist/gestures.js.map +1 -1
  36. package/dist/image.d.ts +1 -1
  37. package/dist/index.d.ts +12 -1
  38. package/dist/index.js +12 -1
  39. package/dist/index.js.map +1 -1
  40. package/dist/interaction-observer.d.ts +11 -0
  41. package/dist/interaction-observer.js +12 -0
  42. package/dist/interaction-observer.js.map +1 -0
  43. package/dist/keyboard-avoiding-view.js +3 -3
  44. package/dist/keyboard-avoiding-view.js.map +1 -1
  45. package/dist/markdown-stream.d.ts +3 -1
  46. package/dist/markdown-stream.js +14 -2
  47. package/dist/markdown-stream.js.map +1 -1
  48. package/dist/markdown.d.ts +2 -0
  49. package/dist/markdown.js +5 -3
  50. package/dist/markdown.js.map +1 -1
  51. package/dist/menu.d.ts +71 -0
  52. package/dist/menu.js +193 -0
  53. package/dist/menu.js.map +1 -0
  54. package/dist/modal.d.ts +30 -1
  55. package/dist/modal.js +67 -6
  56. package/dist/modal.js.map +1 -1
  57. package/dist/native-button.d.ts +54 -0
  58. package/dist/native-button.js +100 -0
  59. package/dist/native-button.js.map +1 -0
  60. package/dist/native-gesture.d.ts +9 -1
  61. package/dist/native-gesture.js +32 -3
  62. package/dist/native-gesture.js.map +1 -1
  63. package/dist/native-id.d.ts +10 -0
  64. package/dist/native-id.js +70 -0
  65. package/dist/native-id.js.map +1 -0
  66. package/dist/pressable.d.ts +31 -0
  67. package/dist/pressable.js +102 -9
  68. package/dist/pressable.js.map +1 -1
  69. package/dist/safe-area-provider.js +15 -8
  70. package/dist/safe-area-provider.js.map +1 -1
  71. package/dist/scroll-view-props.d.ts +7 -1
  72. package/dist/scroll-view-props.js +54 -3
  73. package/dist/scroll-view-props.js.map +1 -1
  74. package/dist/section-list.js +2 -2
  75. package/dist/section-list.js.map +1 -1
  76. package/dist/shortcut.d.ts +21 -0
  77. package/dist/shortcut.js +34 -0
  78. package/dist/shortcut.js.map +1 -0
  79. package/dist/sidebar-item.d.ts +53 -0
  80. package/dist/sidebar-item.js +152 -0
  81. package/dist/sidebar-item.js.map +1 -0
  82. package/dist/sidebar-section.d.ts +21 -0
  83. package/dist/sidebar-section.js +74 -0
  84. package/dist/sidebar-section.js.map +1 -0
  85. package/dist/sidebar.d.ts +47 -0
  86. package/dist/sidebar.js +110 -0
  87. package/dist/sidebar.js.map +1 -0
  88. package/dist/split-view.d.ts +63 -0
  89. package/dist/split-view.js +121 -0
  90. package/dist/split-view.js.map +1 -0
  91. package/dist/switch.d.ts +9 -1
  92. package/dist/switch.js +23 -2
  93. package/dist/switch.js.map +1 -1
  94. package/dist/text-input.d.ts +8 -3
  95. package/dist/text-input.js +10 -4
  96. package/dist/text-input.js.map +1 -1
  97. package/dist/transforms.d.ts +7 -0
  98. package/dist/transforms.js +12 -3
  99. package/dist/transforms.js.map +1 -1
  100. package/dist/tray-icon.d.ts +18 -0
  101. package/dist/tray-icon.js +46 -0
  102. package/dist/tray-icon.js.map +1 -0
  103. package/dist/view-base.d.ts +42 -1
  104. package/dist/view-base.js +67 -39
  105. package/dist/view-base.js.map +1 -1
  106. package/dist/virtual-list.js +12 -1
  107. package/dist/virtual-list.js.map +1 -1
  108. package/dist/written-props.js +25 -0
  109. package/dist/written-props.js.map +1 -1
  110. package/expo-module.config.json +6 -0
  111. package/ios/NgNativeButtonComponentView.mm +132 -0
  112. package/ios/NgNativeButtonMetrics.h +28 -0
  113. package/ios/NgNativeButtonMetrics.mm +68 -0
  114. package/ios/NgNativeButtonShadowNode.h +65 -0
  115. package/ios/NgNativeButtonShadowNode.mm +40 -0
  116. package/ios/NgNativeComponents.podspec +28 -0
  117. package/ios/NgNativeDragAndDrop.mm +342 -0
  118. package/ios/NgNativeDropItems.h +29 -0
  119. package/ios/NgNativeDropItems.mm +55 -0
  120. package/ios/NgNativeMenuBuilding.h +40 -0
  121. package/ios/NgNativeMenuBuilding.mm +217 -0
  122. package/ios/NgNativeMenus.mm +320 -0
  123. package/ios/NgNativeResponderHooks.h +53 -0
  124. package/ios/NgNativeResponderHooks.mm +215 -0
  125. package/ios/NgNativeSceneKeys.h +36 -0
  126. package/ios/NgNativeSceneKeys.mm +56 -0
  127. package/ios/NgNativeSplitView.mm +433 -0
  128. package/ios/NgNativeSplitViewDelegate.h +29 -0
  129. package/ios/NgNativeSplitViewDelegate.mm +122 -0
  130. package/ios/NgNativeSplitViewShadowNodes.h +115 -0
  131. package/ios/NgNativeSplitViewShadowNodes.mm +31 -0
  132. package/ios/NgNativeUndo.mm +107 -0
  133. package/ios/NgNativeUndoSteps.h +17 -0
  134. package/ios/NgNativeUndoSteps.mm +22 -0
  135. package/ios/NgNativeViewBinder.h +54 -0
  136. package/ios/NgNativeViewBinder.mm +225 -0
  137. package/ios/NgNativeWindows.mm +1126 -0
  138. package/package.json +13 -5
package/dist/modal.js CHANGED
@@ -1,10 +1,20 @@
1
- import { Component, DestroyRef, booleanAttribute, computed, effect, inject, input, } from '@angular/core';
2
- import { Direction } from '@ng-native/device';
3
- import { HostEngine } from '@ng-native/fabric';
1
+ import { Component, DestroyRef, ElementRef, Injector, afterNextRender, booleanAttribute, computed, effect, inject, input, signal, } from '@angular/core';
2
+ import { Direction, OS } from '@ng-native/device';
3
+ import { Engine, HostEngine } from '@ng-native/fabric';
4
4
  import { optionalBoolean } from "./transforms.js";
5
5
  import { View } from "./view.js";
6
6
  import { ViewBase } from "./view-base.js";
7
7
  import * as i0 from "@angular/core";
8
+ /** The engine node an anchor stands for. */
9
+ function anchorNode(anchor) {
10
+ if (!anchor)
11
+ return null;
12
+ if (anchor instanceof ElementRef)
13
+ return anchor.nativeElement;
14
+ if ('nodeKind' in anchor)
15
+ return anchor;
16
+ return anchor.node ?? null;
17
+ }
8
18
  /**
9
19
  * Content presented over everything else. Commits as `ModalHostView`.
10
20
  *
@@ -55,7 +65,28 @@ export class Modal extends ViewBase {
55
65
  navigationBarTranslucent = input(undefined, { ...(ngDevMode ? { debugName: "navigationBarTranslucent" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
56
66
  /** Android: give the modal's window a hardware-accelerated surface. */
57
67
  hardwareAccelerated = input(undefined, { ...(ngDevMode ? { debugName: "hardwareAccelerated" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
68
+ /**
69
+ * The element the modal points at. With one, it shows as a popover at the element on macOS; on
70
+ * every other OS, iPadOS included, it shows as it would without one. Committed as the react tag
71
+ * of the element's view.
72
+ */
73
+ anchor = input(/* @ts-ignore */
74
+ ...(ngDevMode ? [undefined, { debugName: "anchor" }] : /* istanbul ignore next */ []));
58
75
  direction = inject(Direction);
76
+ /** Only macOS reads the anchor, so only there does the modal wait for it. */
77
+ readsAnchor = inject(OS) === 'macos';
78
+ /** For the anchor view tag, which only the engine itself hands out. */
79
+ views = inject(Engine, { optional: true });
80
+ injector = inject(Injector);
81
+ /** The anchor's view tag, committed as `anchor`, or undefined with none. */
82
+ anchorTag = signal(undefined, /* @ts-ignore */
83
+ ...(ngDevMode ? [{ debugName: "anchorTag" }] : /* istanbul ignore next */ []));
84
+ /**
85
+ * Whether the anchor's view has still to commit, which gives it its tag. On macOS the modal waits:
86
+ * the host reads the anchor as it presents, and one presented without it stays a sheet.
87
+ */
88
+ awaitingAnchor = signal(false, /* @ts-ignore */
89
+ ...(ngDevMode ? [{ debugName: "awaitingAnchor" }] : /* istanbul ignore next */ []));
59
90
  resolvedPresentationStyle = computed(() => this.presentationStyle() ?? (this.transparent() ? 'overFullScreen' : undefined), /* @ts-ignore */
60
91
  ...(ngDevMode ? [{ debugName: "resolvedPresentationStyle" }] : /* istanbul ignore next */ []));
61
92
  containerStyle = computed(() => ({
@@ -73,6 +104,7 @@ export class Modal extends ViewBase {
73
104
  onStartShouldSetResponder: () => true,
74
105
  });
75
106
  inject(DestroyRef).onDestroy(stop);
107
+ effect(() => this.followAnchor(anchorNode(this.anchor())));
76
108
  effect(() => {
77
109
  const style = this.presentationStyle();
78
110
  if (this.transparent() && style && style !== 'overFullScreen') {
@@ -80,8 +112,36 @@ export class Modal extends ViewBase {
80
112
  }
81
113
  });
82
114
  }
115
+ /**
116
+ * Commit the anchor's tag. A view not yet committed has none, so it is read again once the
117
+ * commit that makes it has happened.
118
+ */
119
+ followAnchor(node) {
120
+ if (!node) {
121
+ // The engine commits a prop that goes as null, which takes it off the native view.
122
+ this.anchorTag.set(undefined);
123
+ this.awaitingAnchor.set(false);
124
+ return;
125
+ }
126
+ const tag = this.views?.tagOf(node);
127
+ if (tag != null) {
128
+ this.anchorTag.set(tag);
129
+ this.awaitingAnchor.set(false);
130
+ return;
131
+ }
132
+ // Elsewhere nothing reads the anchor, and a modal hidden to wait for it would be dismissed.
133
+ if (this.readsAnchor)
134
+ this.awaitingAnchor.set(true);
135
+ afterNextRender(() => {
136
+ if (anchorNode(this.anchor()) !== node)
137
+ return;
138
+ this.anchorTag.set(this.views?.tagOf(node) ?? undefined);
139
+ // Once: an anchor that has still not committed is left out, and the modal shows anyway.
140
+ this.awaitingAnchor.set(false);
141
+ }, { injector: this.injector });
142
+ }
83
143
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Modal, deps: [], target: i0.ɵɵFactoryTarget.Component });
84
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: Modal, isStandalone: true, selector: "modal", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, transparent: { classPropertyName: "transparent", publicName: "transparent", isSignal: true, isRequired: false, transformFunction: null }, backdropColor: { classPropertyName: "backdropColor", publicName: "backdropColor", isSignal: true, isRequired: false, transformFunction: null }, animationType: { classPropertyName: "animationType", publicName: "animationType", isSignal: true, isRequired: false, transformFunction: null }, presentationStyle: { classPropertyName: "presentationStyle", publicName: "presentationStyle", isSignal: true, isRequired: false, transformFunction: null }, supportedOrientations: { classPropertyName: "supportedOrientations", publicName: "supportedOrientations", isSignal: true, isRequired: false, transformFunction: null }, allowSwipeDismissal: { classPropertyName: "allowSwipeDismissal", publicName: "allowSwipeDismissal", isSignal: true, isRequired: false, transformFunction: null }, statusBarTranslucent: { classPropertyName: "statusBarTranslucent", publicName: "statusBarTranslucent", isSignal: true, isRequired: false, transformFunction: null }, navigationBarTranslucent: { classPropertyName: "navigationBarTranslucent", publicName: "navigationBarTranslucent", isSignal: true, isRequired: false, transformFunction: null }, hardwareAccelerated: { classPropertyName: "hardwareAccelerated", publicName: "hardwareAccelerated", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "visible": "visible()", "transparent": "transparent()", "animationType": "animationType()", "presentationStyle": "resolvedPresentationStyle()", "supportedOrientations": "supportedOrientations()", "allowSwipeDismissal": "allowSwipeDismissal()", "statusBarTranslucent": "statusBarTranslucent()", "navigationBarTranslucent": "navigationBarTranslucent()", "hardwareAccelerated": "hardwareAccelerated()" } }, usesInheritance: true, ngImport: i0, template: `<view [style]="containerStyle()" collapsable="false"><ng-content /></view>`, isInline: true, dependencies: [{ kind: "directive", type: View, selector: "view" }] });
144
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: Modal, isStandalone: true, selector: "modal", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, transparent: { classPropertyName: "transparent", publicName: "transparent", isSignal: true, isRequired: false, transformFunction: null }, backdropColor: { classPropertyName: "backdropColor", publicName: "backdropColor", isSignal: true, isRequired: false, transformFunction: null }, animationType: { classPropertyName: "animationType", publicName: "animationType", isSignal: true, isRequired: false, transformFunction: null }, presentationStyle: { classPropertyName: "presentationStyle", publicName: "presentationStyle", isSignal: true, isRequired: false, transformFunction: null }, supportedOrientations: { classPropertyName: "supportedOrientations", publicName: "supportedOrientations", isSignal: true, isRequired: false, transformFunction: null }, allowSwipeDismissal: { classPropertyName: "allowSwipeDismissal", publicName: "allowSwipeDismissal", isSignal: true, isRequired: false, transformFunction: null }, statusBarTranslucent: { classPropertyName: "statusBarTranslucent", publicName: "statusBarTranslucent", isSignal: true, isRequired: false, transformFunction: null }, navigationBarTranslucent: { classPropertyName: "navigationBarTranslucent", publicName: "navigationBarTranslucent", isSignal: true, isRequired: false, transformFunction: null }, hardwareAccelerated: { classPropertyName: "hardwareAccelerated", publicName: "hardwareAccelerated", isSignal: true, isRequired: false, transformFunction: null }, anchor: { classPropertyName: "anchor", publicName: "anchor", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "visible": "visible() && !awaitingAnchor()", "transparent": "transparent()", "animationType": "animationType()", "presentationStyle": "resolvedPresentationStyle()", "supportedOrientations": "supportedOrientations()", "allowSwipeDismissal": "allowSwipeDismissal()", "statusBarTranslucent": "statusBarTranslucent()", "navigationBarTranslucent": "navigationBarTranslucent()", "hardwareAccelerated": "hardwareAccelerated()", "anchor": "anchorTag()" } }, usesInheritance: true, ngImport: i0, template: `<view [style]="containerStyle()" collapsable="false"><ng-content /></view>`, isInline: true, dependencies: [{ kind: "directive", type: View, selector: "view" }] });
85
145
  }
86
146
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Modal, decorators: [{
87
147
  type: Component,
@@ -90,7 +150,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
90
150
  imports: [View],
91
151
  template: `<view [style]="containerStyle()" collapsable="false"><ng-content /></view>`,
92
152
  host: {
93
- '[visible]': 'visible()',
153
+ '[visible]': 'visible() && !awaitingAnchor()',
94
154
  '[transparent]': 'transparent()',
95
155
  '[animationType]': 'animationType()',
96
156
  '[presentationStyle]': 'resolvedPresentationStyle()',
@@ -99,7 +159,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
99
159
  '[statusBarTranslucent]': 'statusBarTranslucent()',
100
160
  '[navigationBarTranslucent]': 'navigationBarTranslucent()',
101
161
  '[hardwareAccelerated]': 'hardwareAccelerated()',
162
+ '[anchor]': 'anchorTag()',
102
163
  },
103
164
  }]
104
- }], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], transparent: [{ type: i0.Input, args: [{ isSignal: true, alias: "transparent", required: false }] }], backdropColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdropColor", required: false }] }], animationType: [{ type: i0.Input, args: [{ isSignal: true, alias: "animationType", required: false }] }], presentationStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "presentationStyle", required: false }] }], supportedOrientations: [{ type: i0.Input, args: [{ isSignal: true, alias: "supportedOrientations", required: false }] }], allowSwipeDismissal: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowSwipeDismissal", required: false }] }], statusBarTranslucent: [{ type: i0.Input, args: [{ isSignal: true, alias: "statusBarTranslucent", required: false }] }], navigationBarTranslucent: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigationBarTranslucent", required: false }] }], hardwareAccelerated: [{ type: i0.Input, args: [{ isSignal: true, alias: "hardwareAccelerated", required: false }] }] } });
165
+ }], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }], transparent: [{ type: i0.Input, args: [{ isSignal: true, alias: "transparent", required: false }] }], backdropColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdropColor", required: false }] }], animationType: [{ type: i0.Input, args: [{ isSignal: true, alias: "animationType", required: false }] }], presentationStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "presentationStyle", required: false }] }], supportedOrientations: [{ type: i0.Input, args: [{ isSignal: true, alias: "supportedOrientations", required: false }] }], allowSwipeDismissal: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowSwipeDismissal", required: false }] }], statusBarTranslucent: [{ type: i0.Input, args: [{ isSignal: true, alias: "statusBarTranslucent", required: false }] }], navigationBarTranslucent: [{ type: i0.Input, args: [{ isSignal: true, alias: "navigationBarTranslucent", required: false }] }], hardwareAccelerated: [{ type: i0.Input, args: [{ isSignal: true, alias: "hardwareAccelerated", required: false }] }], anchor: [{ type: i0.Input, args: [{ isSignal: true, alias: "anchor", required: false }] }] } });
105
166
  //# sourceMappingURL=modal.js.map
package/dist/modal.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"modal.js","sourceRoot":"","sources":["../src/modal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAM1C;;;;;;;;;;;;;GAaG;AAiBH,MAAM,OAAO,KAAM,SAAQ,QAAQ;IACjC;;;;;OAKG;IACM,OAAO,GAAG,KAAK,CAAC,IAAI,+EAAI,SAAS,EAAE,gBAAgB,GAAG,CAAC;IAChE,wEAAwE;IAC/D,WAAW,GAAG,KAAK,CAAC,KAAK,mFAAI,SAAS,EAAE,gBAAgB,GAAG,CAAC;IACrE,0EAA0E;IACjE,aAAa,GAAG,KAAK;iGAAU,CAAC;IACzC,4DAA4D;IACnD,aAAa,GAAG,KAAK;iGAA6B,CAAC;IAC5D,+FAA+F;IACtF,iBAAiB,GAAG,KAAK;qGAA0B,CAAC;IAC7D,6EAA6E;IACpE,qBAAqB,GAAG,KAAK;yGAA+B,CAAC;IACtE,sFAAsF;IAC7E,mBAAmB,GAAG,KAAK,CAAC,SAAS,2FAAI,SAAS,EAAE,eAAe,GAAG,CAAC;IAChF;;;OAGG;IACM,oBAAoB,GAAG,KAAK,CAAC,SAAS,4FAAI,SAAS,EAAE,eAAe,GAAG,CAAC;IACjF;;;OAGG;IACM,wBAAwB,GAAG,KAAK,CAAC,SAAS,gGAAI,SAAS,EAAE,eAAe,GAAG,CAAC;I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CAAC,CAAC,CAAC;IACL,CAAC;uGA/DU,KAAK;2FAAL,KAAK,ohEAbN,4EAA4E,4DAD5E,IAAI;;2FAcH,KAAK;kBAhBjB,SAAS;mBAAC;oBACT,QAAQ,EAAE,OAAO;oBACjB,OAAO,EAAE,CAAC,IAAI,CAAC;oBACf,QAAQ,EAAE,4EAA4E;oBACtF,IAAI,EAAE;wBACJ,WAAW,EAAE,WAAW;wBACxB,eAAe,EAAE,eAAe;wBAChC,iBAAiB,EAAE,iBAAiB;wBACpC,qBAAqB,EAAE,6BAA6B;wBACpD,yBAAyB,EAAE,yBAAyB;wBACpD,uBAAuB,EAAE,uBAAuB;wBAChD,wBAAwB,EAAE,wBAAwB;wBAClD,4BAA4B,EAAE,4BAA4B;wBAC1D,uBAAuB,EAAE,uBAAuB;qBACjD;iBACF","sourcesContent":["import {\n Component,\n DestroyRef,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n} from '@angular/core';\nimport { Direction } from '@ng-native/device';\nimport { HostEngine } from '@ng-native/fabric';\nimport { optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport { ViewBase } from './view-base.ts';\n\nexport type ModalPresentationStyle = 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen';\nexport type ModalOrientation =\n 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right';\n\n/**\n * Content presented over everything else. Commits as `ModalHostView`.\n *\n * RN's `Modal.js` gives the native host `{position: 'absolute'}` (the engine's default for it)\n * and puts the children inside a full-bleed view carrying the backdrop colour. Without the\n * container the content has no backdrop and no layout box, so a modal renders as nothing.\n *\n * Events are element events: `(requestClose)` for the Android back button and an iOS swipe,\n * `(show)`, `(dismiss)`, and `(orientationChange)`.\n *\n * The container is pinned to the leading edge with `[side]: 0`, the same as RN's own Modal.js -\n * `left` in a left-to-right layout, `right` in a right-to-left one - so the backdrop starts from\n * the edge content actually begins at rather than always the physical left.\n */\n@Component({\n selector: 'modal',\n imports: [View],\n template: `<view [style]=\"containerStyle()\" collapsable=\"false\"><ng-content /></view>`,\n host: {\n '[visible]': 'visible()',\n '[transparent]': 'transparent()',\n '[animationType]': 'animationType()',\n '[presentationStyle]': 'resolvedPresentationStyle()',\n '[supportedOrientations]': 'supportedOrientations()',\n '[allowSwipeDismissal]': 'allowSwipeDismissal()',\n '[statusBarTranslucent]': 'statusBarTranslucent()',\n '[navigationBarTranslucent]': 'navigationBarTranslucent()',\n '[hardwareAccelerated]': 'hardwareAccelerated()',\n },\n})\nexport class Modal extends ViewBase {\n /**\n * Whether the modal is showing. Defaults to true, as in RN. While false the engine leaves the\n * native host out of the commit, as RN's Modal returns null when hidden, because the host\n * covers the screen and takes every touch whether or not it presents; on iOS a modal that was\n * showing stays until native reports its dismissal.\n */\n readonly visible = input(true, { transform: booleanAttribute });\n /** See through to the screen behind; the container gets no backdrop. */\n readonly transparent = input(false, { transform: booleanAttribute });\n /** The container's background when not transparent. Defaults to white. */\n readonly backdropColor = input<string>();\n /** How the modal appears and leaves. Defaults to `none`. */\n readonly animationType = input<'none' | 'slide' | 'fade'>();\n /** iOS: full screen, a sheet, or over the current content. `overFullScreen` if transparent. */\n readonly presentationStyle = input<ModalPresentationStyle>();\n /** iOS: which orientations the modal may rotate to. Defaults to portrait. */\n readonly supportedOrientations = input<readonly ModalOrientation[]>();\n /** iOS: let a downward swipe dismiss the modal, reported through `(requestClose)`. */\n readonly allowSwipeDismissal = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the status bar. Always on under Android edge-to-edge (Expo SDK 57), where\n * React Native ignores `false`.\n */\n readonly statusBarTranslucent = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the navigation bar. Always on under Android edge-to-edge (Expo SDK 57),\n * where React Native ignores `false`. In an app that opts out, it needs `statusBarTranslucent`.\n */\n readonly navigationBarTranslucent = input(undefined, { transform: optionalBoolean });\n /** Android: give the modal's window a hardware-accelerated surface. */\n readonly hardwareAccelerated = input(undefined, { transform: optionalBoolean });\n\n private readonly direction = inject(Direction);\n\n protected readonly resolvedPresentationStyle = computed(\n () => this.presentationStyle() ?? (this.transparent() ? 'overFullScreen' : undefined),\n );\n\n protected readonly containerStyle = computed(() => ({\n [this.direction.rtl() ? 'right' : 'left']: 0,\n top: 0,\n flex: 1,\n backgroundColor: this.transparent() ? 'transparent' : (this.backdropColor() ?? 'white'),\n }));\n\n constructor() {\n super();\n // RN's host claims any touch that reaches it, so nothing inside the modal can hand a\n // gesture to the screen underneath.\n const stop = inject(HostEngine).setResponder(this.node, {\n onStartShouldSetResponder: () => true,\n });\n inject(DestroyRef).onDestroy(stop);\n\n effect(() => {\n const style = this.presentationStyle();\n if (this.transparent() && style && style !== 'overFullScreen') {\n console.warn(\n `[angular-native] <modal> is transparent, which needs presentationStyle=\"overFullScreen\" on iOS; '${style}' will not be see-through.`,\n );\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"modal.js","sourceRoot":"","sources":["../src/modal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,QAAQ,EACR,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAM1C,4CAA4C;AAC5C,SAAS,UAAU,CAAC,MAAmB;IACrC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,MAAM,YAAY,UAAU;QAAE,OAAO,MAAM,CAAC,aAA2B,CAAC;IAC5E,IAAI,UAAU,IAAI,M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S;mBAAC;oBACT,QAAQ,EAAE,OAAO;oBACjB,OAAO,EAAE,CAAC,IAAI,CAAC;oBACf,QAAQ,EAAE,4EAA4E;oBACtF,IAAI,EAAE;wBACJ,WAAW,EAAE,gCAAgC;wBAC7C,eAAe,EAAE,eAAe;wBAChC,iBAAiB,EAAE,iBAAiB;wBACpC,qBAAqB,EAAE,6BAA6B;wBACpD,yBAAyB,EAAE,yBAAyB;wBACpD,uBAAuB,EAAE,uBAAuB;wBAChD,wBAAwB,EAAE,wBAAwB;wBAClD,4BAA4B,EAAE,4BAA4B;wBAC1D,uBAAuB,EAAE,uBAAuB;wBAChD,UAAU,EAAE,aAAa;qBAC1B;iBACF","sourcesContent":["import {\n Component,\n DestroyRef,\n ElementRef,\n Injector,\n afterNextRender,\n booleanAttribute,\n computed,\n effect,\n inject,\n input,\n signal,\n} from '@angular/core';\nimport { Direction, OS } from '@ng-native/device';\nimport { Engine, HostEngine, type EngineNode } from '@ng-native/fabric';\nimport { optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport { ViewBase } from './view-base.ts';\n\nexport type ModalPresentationStyle = 'fullScreen' | 'pageSheet' | 'formSheet' | 'overFullScreen';\n/** What `anchor` takes: an element, its `ElementRef`, or a component or directive with a `node`. */\nexport type ModalAnchor = ElementRef | EngineNode | { readonly node: unknown } | null | undefined;\n\n/** The engine node an anchor stands for. */\nfunction anchorNode(anchor: ModalAnchor): EngineNode | null {\n if (!anchor) return null;\n if (anchor instanceof ElementRef) return anchor.nativeElement as EngineNode;\n if ('nodeKind' in anchor) return anchor as EngineNode;\n return ((anchor as { node?: unknown }).node as EngineNode | undefined) ?? null;\n}\n\nexport type ModalOrientation =\n 'portrait' | 'portrait-upside-down' | 'landscape' | 'landscape-left' | 'landscape-right';\n\n/**\n * Content presented over everything else. Commits as `ModalHostView`.\n *\n * RN's `Modal.js` gives the native host `{position: 'absolute'}` (the engine's default for it)\n * and puts the children inside a full-bleed view carrying the backdrop colour. Without the\n * container the content has no backdrop and no layout box, so a modal renders as nothing.\n *\n * Events are element events: `(requestClose)` for the Android back button and an iOS swipe,\n * `(show)`, `(dismiss)`, and `(orientationChange)`.\n *\n * The container is pinned to the leading edge with `[side]: 0`, the same as RN's own Modal.js -\n * `left` in a left-to-right layout, `right` in a right-to-left one - so the backdrop starts from\n * the edge content actually begins at rather than always the physical left.\n */\n@Component({\n selector: 'modal',\n imports: [View],\n template: `<view [style]=\"containerStyle()\" collapsable=\"false\"><ng-content /></view>`,\n host: {\n '[visible]': 'visible() && !awaitingAnchor()',\n '[transparent]': 'transparent()',\n '[animationType]': 'animationType()',\n '[presentationStyle]': 'resolvedPresentationStyle()',\n '[supportedOrientations]': 'supportedOrientations()',\n '[allowSwipeDismissal]': 'allowSwipeDismissal()',\n '[statusBarTranslucent]': 'statusBarTranslucent()',\n '[navigationBarTranslucent]': 'navigationBarTranslucent()',\n '[hardwareAccelerated]': 'hardwareAccelerated()',\n '[anchor]': 'anchorTag()',\n },\n})\nexport class Modal extends ViewBase {\n /**\n * Whether the modal is showing. Defaults to true, as in RN. While false the engine leaves the\n * native host out of the commit, as RN's Modal returns null when hidden, because the host\n * covers the screen and takes every touch whether or not it presents; on iOS a modal that was\n * showing stays until native reports its dismissal.\n */\n readonly visible = input(true, { transform: booleanAttribute });\n /** See through to the screen behind; the container gets no backdrop. */\n readonly transparent = input(false, { transform: booleanAttribute });\n /** The container's background when not transparent. Defaults to white. */\n readonly backdropColor = input<string>();\n /** How the modal appears and leaves. Defaults to `none`. */\n readonly animationType = input<'none' | 'slide' | 'fade'>();\n /** iOS: full screen, a sheet, or over the current content. `overFullScreen` if transparent. */\n readonly presentationStyle = input<ModalPresentationStyle>();\n /** iOS: which orientations the modal may rotate to. Defaults to portrait. */\n readonly supportedOrientations = input<readonly ModalOrientation[]>();\n /** iOS: let a downward swipe dismiss the modal, reported through `(requestClose)`. */\n readonly allowSwipeDismissal = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the status bar. Always on under Android edge-to-edge (Expo SDK 57), where\n * React Native ignores `false`.\n */\n readonly statusBarTranslucent = input(undefined, { transform: optionalBoolean });\n /**\n * Android: draw under the navigation bar. Always on under Android edge-to-edge (Expo SDK 57),\n * where React Native ignores `false`. In an app that opts out, it needs `statusBarTranslucent`.\n */\n readonly navigationBarTranslucent = input(undefined, { transform: optionalBoolean });\n /** Android: give the modal's window a hardware-accelerated surface. */\n readonly hardwareAccelerated = input(undefined, { transform: optionalBoolean });\n\n /**\n * The element the modal points at. With one, it shows as a popover at the element on macOS; on\n * every other OS, iPadOS included, it shows as it would without one. Committed as the react tag\n * of the element's view.\n */\n readonly anchor = input<ModalAnchor>();\n\n private readonly direction = inject(Direction);\n /** Only macOS reads the anchor, so only there does the modal wait for it. */\n private readonly readsAnchor = inject(OS) === 'macos';\n /** For the anchor view tag, which only the engine itself hands out. */\n private readonly views = inject(Engine, { optional: true });\n private readonly injector = inject(Injector);\n\n /** The anchor's view tag, committed as `anchor`, or undefined with none. */\n protected readonly anchorTag = signal<number | undefined>(undefined);\n /**\n * Whether the anchor's view has still to commit, which gives it its tag. On macOS the modal waits:\n * the host reads the anchor as it presents, and one presented without it stays a sheet.\n */\n protected readonly awaitingAnchor = signal(false);\n\n protected readonly resolvedPresentationStyle = computed(\n () => this.presentationStyle() ?? (this.transparent() ? 'overFullScreen' : undefined),\n );\n\n protected readonly containerStyle = computed(() => ({\n [this.direction.rtl() ? 'right' : 'left']: 0,\n top: 0,\n flex: 1,\n backgroundColor: this.transparent() ? 'transparent' : (this.backdropColor() ?? 'white'),\n }));\n\n constructor() {\n super();\n // RN's host claims any touch that reaches it, so nothing inside the modal can hand a\n // gesture to the screen underneath.\n const stop = inject(HostEngine).setResponder(this.node, {\n onStartShouldSetResponder: () => true,\n });\n inject(DestroyRef).onDestroy(stop);\n\n effect(() => this.followAnchor(anchorNode(this.anchor())));\n\n effect(() => {\n const style = this.presentationStyle();\n if (this.transparent() && style && style !== 'overFullScreen') {\n console.warn(\n `[angular-native] <modal> is transparent, which needs presentationStyle=\"overFullScreen\" on iOS; '${style}' will not be see-through.`,\n );\n }\n });\n }\n\n /**\n * Commit the anchor's tag. A view not yet committed has none, so it is read again once the\n * commit that makes it has happened.\n */\n private followAnchor(node: EngineNode | null): void {\n if (!node) {\n // The engine commits a prop that goes as null, which takes it off the native view.\n this.anchorTag.set(undefined);\n this.awaitingAnchor.set(false);\n return;\n }\n const tag = this.views?.tagOf(node);\n if (tag != null) {\n this.anchorTag.set(tag);\n this.awaitingAnchor.set(false);\n return;\n }\n // Elsewhere nothing reads the anchor, and a modal hidden to wait for it would be dismissed.\n if (this.readsAnchor) this.awaitingAnchor.set(true);\n afterNextRender(\n () => {\n if (anchorNode(this.anchor()) !== node) return;\n this.anchorTag.set(this.views?.tagOf(node) ?? undefined);\n // Once: an anchor that has still not committed is left out, and the modal shows anyway.\n this.awaitingAnchor.set(false);\n },\n { injector: this.injector },\n );\n }\n}\n"]}
@@ -0,0 +1,54 @@
1
+ import type { ControlSize } from '@ng-native/device';
2
+ import { ControlBase } from './pressable.ts';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * What a button does in its window: on macOS, Return presses `default` and Escape presses `cancel`.
6
+ * On iOS they are styles only.
7
+ */
8
+ export type ButtonKind = 'default' | 'cancel' | 'destructive' | 'plain';
9
+ /** A button's picture, as on `<native-tab>`: an SF Symbol on Apple's OSes, a drawable on Android. */
10
+ export type ButtonIcon = {
11
+ readonly sfSymbol: string;
12
+ } | {
13
+ readonly drawable: string;
14
+ };
15
+ /**
16
+ * A platform button, its label the text inside it:
17
+ *
18
+ * <native-button kind="default" (press)="save()">Save</native-button>
19
+ *
20
+ * On macOS it is an NSButton and on iOS a UIButton, drawn by the host, which sends
21
+ * `topButtonPress` when it is clicked, tapped, or pressed by Space, and on macOS by Return (a
22
+ * `default` button) or Escape (a `cancel` one). On Android it is a view pressed through the responder, as a
23
+ * `<pressable>` is, and takes `android_ripple` as one does. The web host draws an HTML `button`.
24
+ * It is a button to assistive technology everywhere, and takes focus.
25
+ */
26
+ export declare class NativeButton extends ControlBase {
27
+ /**
28
+ * What the button does in its window. In a desktop window `default` takes Return and `cancel`
29
+ * takes Escape; elsewhere the kind is a style alone. Unset, it is a plain push button.
30
+ */
31
+ readonly kind: import("@angular/core").InputSignal<ButtonKind | undefined>;
32
+ /** AppKit's control size on macOS, and UIKit's button size on iOS. Ignored elsewhere. */
33
+ readonly controlSize: import("@angular/core").InputSignal<ControlSize | undefined>;
34
+ /** An SF Symbol beside the label, on iOS and macOS. */
35
+ readonly sfSymbol: import("@angular/core").InputSignal<string | undefined>;
36
+ /** Android: a drawable resource beside the label. */
37
+ readonly drawableName: import("@angular/core").InputSignal<string | undefined>;
38
+ /** The picture for each OS at once, as on `<native-tab>`. */
39
+ readonly icon: import("@angular/core").InputSignal<ButtonIcon | undefined>;
40
+ protected readonly symbol: import("@angular/core").Signal<string | undefined>;
41
+ protected readonly drawableResource: import("@angular/core").Signal<string | undefined>;
42
+ /** Where the host draws the button, it presses it: the responder would press it twice. */
43
+ private readonly drawnByHost;
44
+ private stopPress;
45
+ protected roleByDefault(): 'button';
46
+ protected accessibleByDefault(): boolean;
47
+ protected focusableByDefault(): boolean;
48
+ protected disabledForAccessibility(): boolean | undefined;
49
+ protected claims(): boolean;
50
+ ngOnInit(): void;
51
+ ngOnDestroy(): void;
52
+ static ɵfac: i0.ɵɵFactoryDeclaration<NativeButton, never>;
53
+ static ɵcmp: i0.ɵɵComponentDeclaration<NativeButton, "native-button", never, { "kind": { "alias": "kind"; "required": false; "isSignal": true; }; "controlSize": { "alias": "controlSize"; "required": false; "isSignal": true; }; "sfSymbol": { "alias": "sfSymbol"; "required": false; "isSignal": true; }; "drawableName": { "alias": "drawable"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
54
+ }
@@ -0,0 +1,100 @@
1
+ import { Component, computed, forwardRef, input } from '@angular/core';
2
+ import { isApplePlatform, registerViewName } from '@ng-native/fabric';
3
+ import { ControlBase, TouchableBase } from "./pressable.js";
4
+ import * as i0 from "@angular/core";
5
+ /**
6
+ * The button on Apple's OSes is the host's: NSButton on macOS and UIButton on iOS. Android has no
7
+ * platform button React Native draws, so there it is a view this component makes pressable.
8
+ */
9
+ registerViewName('native-button', { ios: 'NgNativeButton', android: 'View', macos: 'NgNativeButton' }, undefined, { textContent: 'title' });
10
+ /**
11
+ * A platform button, its label the text inside it:
12
+ *
13
+ * <native-button kind="default" (press)="save()">Save</native-button>
14
+ *
15
+ * On macOS it is an NSButton and on iOS a UIButton, drawn by the host, which sends
16
+ * `topButtonPress` when it is clicked, tapped, or pressed by Space, and on macOS by Return (a
17
+ * `default` button) or Escape (a `cancel` one). On Android it is a view pressed through the responder, as a
18
+ * `<pressable>` is, and takes `android_ripple` as one does. The web host draws an HTML `button`.
19
+ * It is a button to assistive technology everywhere, and takes focus.
20
+ */
21
+ export class NativeButton extends ControlBase {
22
+ /**
23
+ * What the button does in its window. In a desktop window `default` takes Return and `cancel`
24
+ * takes Escape; elsewhere the kind is a style alone. Unset, it is a plain push button.
25
+ */
26
+ kind = input(/* @ts-ignore */
27
+ ...(ngDevMode ? [undefined, { debugName: "kind" }] : /* istanbul ignore next */ []));
28
+ /** AppKit's control size on macOS, and UIKit's button size on iOS. Ignored elsewhere. */
29
+ controlSize = input(/* @ts-ignore */
30
+ ...(ngDevMode ? [undefined, { debugName: "controlSize" }] : /* istanbul ignore next */ []));
31
+ /** An SF Symbol beside the label, on iOS and macOS. */
32
+ sfSymbol = input(/* @ts-ignore */
33
+ ...(ngDevMode ? [undefined, { debugName: "sfSymbol" }] : /* istanbul ignore next */ []));
34
+ /** Android: a drawable resource beside the label. */
35
+ drawableName = input(undefined, { ...(ngDevMode ? { debugName: "drawableName" } : /* istanbul ignore next */ {}), alias: 'drawable' });
36
+ /** The picture for each OS at once, as on `<native-tab>`. */
37
+ icon = input(/* @ts-ignore */
38
+ ...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
39
+ symbol = computed(() => {
40
+ const icon = this.icon();
41
+ return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);
42
+ }, /* @ts-ignore */
43
+ ...(ngDevMode ? [{ debugName: "symbol" }] : /* istanbul ignore next */ []));
44
+ drawableResource = computed(() => {
45
+ const icon = this.icon();
46
+ return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);
47
+ }, /* @ts-ignore */
48
+ ...(ngDevMode ? [{ debugName: "drawableResource" }] : /* istanbul ignore next */ []));
49
+ /** Where the host draws the button, it presses it: the responder would press it twice. */
50
+ drawnByHost = isApplePlatform();
51
+ stopPress = null;
52
+ roleByDefault() {
53
+ return 'button';
54
+ }
55
+ accessibleByDefault() {
56
+ return true;
57
+ }
58
+ focusableByDefault() {
59
+ return true;
60
+ }
61
+ disabledForAccessibility() {
62
+ return this.disabled();
63
+ }
64
+ claims() {
65
+ return !this.drawnByHost && super.claims();
66
+ }
67
+ ngOnInit() {
68
+ super.ngOnInit();
69
+ if (!this.drawnByHost || this.stopPress)
70
+ return;
71
+ this.stopPress = this.engine.setEventListener(this.node, 'topButtonPress', (event) => {
72
+ if (this.pressDisabled())
73
+ return;
74
+ this.press.emit(event);
75
+ this.reportInteraction('click', event, 'click');
76
+ });
77
+ }
78
+ ngOnDestroy() {
79
+ super.ngOnDestroy();
80
+ this.stopPress?.();
81
+ }
82
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NativeButton, deps: null, target: i0.ɵɵFactoryTarget.Component });
83
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: NativeButton, isStandalone: true, selector: "native-button", inputs: { kind: { classPropertyName: "kind", publicName: "kind", isSignal: true, isRequired: false, transformFunction: null }, controlSize: { classPropertyName: "controlSize", publicName: "controlSize", isSignal: true, isRequired: false, transformFunction: null }, sfSymbol: { classPropertyName: "sfSymbol", publicName: "sfSymbol", isSignal: true, isRequired: false, transformFunction: null }, drawableName: { classPropertyName: "drawableName", publicName: "drawable", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "kind": "kind()", "controlSize": "controlSize()", "sfSymbol": "symbol()", "drawable": "drawableResource()", "enabled": "!pressDisabled()" } }, providers: [{ provide: TouchableBase, useExisting: forwardRef(() => NativeButton) }], usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true });
84
+ }
85
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NativeButton, decorators: [{
86
+ type: Component,
87
+ args: [{
88
+ selector: 'native-button',
89
+ template: '<ng-content />',
90
+ providers: [{ provide: TouchableBase, useExisting: forwardRef(() => NativeButton) }],
91
+ host: {
92
+ '[kind]': 'kind()',
93
+ '[controlSize]': 'controlSize()',
94
+ '[sfSymbol]': 'symbol()',
95
+ '[drawable]': 'drawableResource()',
96
+ '[enabled]': '!pressDisabled()',
97
+ },
98
+ }]
99
+ }], propDecorators: { kind: [{ type: i0.Input, args: [{ isSignal: true, alias: "kind", required: false }] }], controlSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlSize", required: false }] }], sfSymbol: [{ type: i0.Input, args: [{ isSignal: true, alias: "sfSymbol", required: false }] }], drawableName: [{ type: i0.Input, args: [{ isSignal: true, alias: "drawable", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }] } });
100
+ //# sourceMappingURL=native-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-button.js","sourceRoot":"","sources":["../src/native-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAiB,MAAM,mBAAmB,CAAC;A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U,CAAC,GAAG,EAAE,aAAa,CAAC,EAAE,CAAC;oBACpF,IAAI,EAAE;wBACJ,QAAQ,EAAE,QAAQ;wBAClB,eAAe,EAAE,eAAe;wBAChC,YAAY,EAAE,UAAU;wBACxB,YAAY,EAAE,oBAAoB;wBAClC,WAAW,EAAE,kBAAkB;qBAChC;iBACF","sourcesContent":["import { Component, computed, forwardRef, input } from '@angular/core';\nimport { isApplePlatform, registerViewName, type HostNode } from '@ng-native/fabric';\nimport type { ControlSize } from '@ng-native/device';\nimport { ControlBase, TouchableBase } from './pressable.ts';\n\n/**\n * What a button does in its window: on macOS, Return presses `default` and Escape presses `cancel`.\n * On iOS they are styles only.\n */\nexport type ButtonKind = 'default' | 'cancel' | 'destructive' | 'plain';\n\n/** A button's picture, as on `<native-tab>`: an SF Symbol on Apple's OSes, a drawable on Android. */\nexport type ButtonIcon = { readonly sfSymbol: string } | { readonly drawable: string };\n\n/**\n * The button on Apple's OSes is the host's: NSButton on macOS and UIButton on iOS. Android has no\n * platform button React Native draws, so there it is a view this component makes pressable.\n */\nregisterViewName(\n 'native-button',\n { ios: 'NgNativeButton', android: 'View', macos: 'NgNativeButton' },\n undefined,\n { textContent: 'title' },\n);\n\n/**\n * A platform button, its label the text inside it:\n *\n * <native-button kind=\"default\" (press)=\"save()\">Save</native-button>\n *\n * On macOS it is an NSButton and on iOS a UIButton, drawn by the host, which sends\n * `topButtonPress` when it is clicked, tapped, or pressed by Space, and on macOS by Return (a\n * `default` button) or Escape (a `cancel` one). On Android it is a view pressed through the responder, as a\n * `<pressable>` is, and takes `android_ripple` as one does. The web host draws an HTML `button`.\n * It is a button to assistive technology everywhere, and takes focus.\n */\n@Component({\n selector: 'native-button',\n template: '<ng-content />',\n providers: [{ provide: TouchableBase, useExisting: forwardRef(() => NativeButton) }],\n host: {\n '[kind]': 'kind()',\n '[controlSize]': 'controlSize()',\n '[sfSymbol]': 'symbol()',\n '[drawable]': 'drawableResource()',\n '[enabled]': '!pressDisabled()',\n },\n})\nexport class NativeButton extends ControlBase {\n /**\n * What the button does in its window. In a desktop window `default` takes Return and `cancel`\n * takes Escape; elsewhere the kind is a style alone. Unset, it is a plain push button.\n */\n readonly kind = input<ButtonKind>();\n /** AppKit's control size on macOS, and UIKit's button size on iOS. Ignored elsewhere. */\n readonly controlSize = input<ControlSize>();\n /** An SF Symbol beside the label, on iOS and macOS. */\n readonly sfSymbol = input<string>();\n /** Android: a drawable resource beside the label. */\n readonly drawableName = input<string>(undefined, { alias: 'drawable' });\n /** The picture for each OS at once, as on `<native-tab>`. */\n readonly icon = input<ButtonIcon>();\n\n protected readonly symbol = computed(() => {\n const icon = this.icon();\n return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);\n });\n\n protected readonly drawableResource = computed(() => {\n const icon = this.icon();\n return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);\n });\n\n /** Where the host draws the button, it presses it: the responder would press it twice. */\n private readonly drawnByHost = isApplePlatform();\n private stopPress: (() => void) | null = null;\n\n protected override roleByDefault(): 'button' {\n return 'button';\n }\n\n protected override accessibleByDefault(): boolean {\n return true;\n }\n\n protected override focusableByDefault(): boolean {\n return true;\n }\n\n protected override disabledForAccessibility(): boolean | undefined {\n return this.disabled();\n }\n\n protected override claims(): boolean {\n return !this.drawnByHost && super.claims();\n }\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (!this.drawnByHost || this.stopPress) return;\n this.stopPress = this.engine.setEventListener(\n this.node as HostNode,\n 'topButtonPress',\n (event) => {\n if (this.pressDisabled()) return;\n this.press.emit(event as never);\n this.reportInteraction('click', event as never, 'click');\n },\n );\n }\n\n override ngOnDestroy(): void {\n super.ngOnDestroy();\n this.stopPress?.();\n }\n}\n"]}
@@ -14,8 +14,16 @@ export declare class NativeGestureBase {
14
14
  private readonly engine;
15
15
  private readonly gestures;
16
16
  private readonly injector;
17
+ private readonly observers;
17
18
  readonly gesture: import("@angular/core").InputSignal<object>;
19
+ /**
20
+ * Whether the app's interaction observers hear this element's gestures. `false` keeps one out,
21
+ * such as a drawing surface whose every stroke is not an interaction worth recording.
22
+ */
23
+ readonly trackGesture: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
18
24
  constructor();
25
+ /** Tell the observers about a gesture of this element's that has just ended. */
26
+ private report;
19
27
  static ɵfac: i0.ɵɵFactoryDeclaration<NativeGestureBase, never>;
20
- static ɵdir: i0.ɵɵDirectiveDeclaration<NativeGestureBase, "[gesture]", never, { "gesture": { "alias": "gesture"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
28
+ static ɵdir: i0.ɵɵDirectiveDeclaration<NativeGestureBase, "[gesture]", never, { "gesture": { "alias": "gesture"; "required": true; "isSignal": true; }; "trackGesture": { "alias": "trackGesture"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
21
29
  }
@@ -15,6 +15,9 @@
15
15
  import { Directive, ElementRef, Injector, afterNextRender, effect, inject, input, } from '@angular/core';
16
16
  import { Engine } from '@ng-native/fabric';
17
17
  import { GESTURES } from "./gesture-backend.js";
18
+ import { gestureInteraction } from "./gesture-interaction.js";
19
+ import { booleanOr } from "./transforms.js";
20
+ import { INTERACTION_OBSERVERS, describeElement, notifyInteraction, textWithin, } from "./interaction-observer.js";
18
21
  import * as i0 from "@angular/core";
19
22
  /**
20
23
  * The behaviour, with the library left as a dependency so a test can drive a fake one.
@@ -31,8 +34,14 @@ export class NativeGestureBase {
31
34
  engine = inject(Engine);
32
35
  gestures = inject(GESTURES);
33
36
  injector = inject(Injector);
37
+ observers = inject(INTERACTION_OBSERVERS, { optional: true });
34
38
  gesture = input.required(/* @ts-ignore */
35
39
  ...(ngDevMode ? [{ debugName: "gesture" }] : /* istanbul ignore next */ []));
40
+ /**
41
+ * Whether the app's interaction observers hear this element's gestures. `false` keeps one out,
42
+ * such as a drawing surface whose every stroke is not an interaction worth recording.
43
+ */
44
+ trackGesture = input(true, { ...(ngDevMode ? { debugName: "trackGesture" } : /* istanbul ignore next */ {}), transform: booleanOr(true) });
36
45
  constructor() {
37
46
  // Native attaches a recogniser to a view, so there has to be one: a node has no react tag
38
47
  // until it has been committed.
@@ -42,15 +51,35 @@ export class NativeGestureBase {
42
51
  const tag = this.engine.tagOf(this.node);
43
52
  if (tag === null)
44
53
  return;
45
- onCleanup(this.gestures.attach({ tag }, gesture));
54
+ // Decided here, once per attach, so a gesture nobody observes costs nothing per event.
55
+ const observers = this.trackGesture() && this.observers?.length ? this.observers : null;
56
+ const report = observers
57
+ ? (ended) => this.report(observers, ended)
58
+ : undefined;
59
+ onCleanup(this.gestures.attach({ tag }, gesture, report));
46
60
  }, { injector: this.injector });
47
61
  });
48
62
  }
63
+ /** Tell the observers about a gesture of this element's that has just ended. */
64
+ report(observers, ended) {
65
+ const interaction = gestureInteraction(ended);
66
+ if (!interaction)
67
+ return;
68
+ const pressed = interaction.type === 'click' || interaction.type === 'long-press';
69
+ const text = pressed ? textWithin(this.node) : undefined;
70
+ notifyInteraction(observers, {
71
+ ...describeElement(this.engine, this.node),
72
+ ...interaction,
73
+ ...(text !== undefined && { text }),
74
+ source: 'touch',
75
+ timestamp: Date.now(),
76
+ });
77
+ }
49
78
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NativeGestureBase, deps: [], target: i0.ɵɵFactoryTarget.Directive });
50
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: NativeGestureBase, isStandalone: true, selector: "[gesture]", inputs: { gesture: { classPropertyName: "gesture", publicName: "gesture", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "collapsable": "false" } }, ngImport: i0 });
79
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: NativeGestureBase, isStandalone: true, selector: "[gesture]", inputs: { gesture: { classPropertyName: "gesture", publicName: "gesture", isSignal: true, isRequired: true, transformFunction: null }, trackGesture: { classPropertyName: "trackGesture", publicName: "trackGesture", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "collapsable": "false" } }, ngImport: i0 });
51
80
  }
52
81
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: NativeGestureBase, decorators: [{
53
82
  type: Directive,
54
83
  args: [{ selector: '[gesture]', host: { '[collapsable]': 'false' } }]
55
- }], ctorParameters: () => [], propDecorators: { gesture: [{ type: i0.Input, args: [{ isSignal: true, alias: "gesture", required: true }] }] } });
84
+ }], ctorParameters: () => [], propDecorators: { gesture: [{ type: i0.Input, args: [{ isSignal: true, alias: "gesture", required: true }] }], trackGesture: [{ type: i0.Input, args: [{ isSignal: true, alias: "trackGesture", required: false }] }] } });
56
85
  //# sourceMappingURL=native-gesture.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"native-gesture.js","sourceRoot":"","sources":["../src/native-gesture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,eAAe,EACf,MAAM,EACN,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAmB,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAoB,MAAM,sBAAsB,CAAC;;AAElE;;;;;;;;;GASG;AAEH,MAAM,OAAO,iBAAiB;IACX,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,aAA2B,CAAC;IACtD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEpC,OAAO,GAAG,KAAK,CAAC,QAAQ;gFAAe,CAAC;IAEjD;QACE,0FAA0F;QAC1F,+BAA+B;QAC/B,eAAe,CAAC,GAAG,EAAE;YACnB,MAAM,CACJ,CAAC,SAAS,EAAE,EAAE;gBACZ,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;gBAC/B,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACzC,IAAI,GAAG,KAAK,IAAI;oBAAE,OAAO;gBACzB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;YACpD,CAAC,EACD,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAC5B,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;uGAtBU,iBAAiB;2FAAjB,iBAAiB;;2FAAjB,iBAAiB;kBAD7B,SAAS;mBAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE","sourcesContent":["/**\n * A native gesture, attached to the element it sits on.\n *\n * ```html\n * <view [gesture]=\"pan\">\n * ```\n *\n * The equivalent of `GestureDetector`, which is a React component whose whole job is to hold a\n * ref, turn it into a view tag, and hand that tag to the native module. A directive already has\n * the node, and the engine already knows its tag.\n *\n * `NativeGesture` in `../gestures.ts` is the one apps import: same selector, and it supplies the\n * real library itself.\n */\nimport {\n Directive,\n ElementRef,\n Injector,\n afterNextRender,\n effect,\n inject,\n input,\n} from '@angular/core';\nimport { Engine, type EngineNode } from '@ng-native/fabric';\nimport { GESTURES, type GestureSpec } from './gesture-backend.ts';\n\n/**\n * The behaviour, with the library left as a dependency so a test can drive a fake one.\n *\n * `collapsable` is the load-bearing part of the host bindings. Native attaches a recogniser to a\n * *view*, and a view that only groups its children can be collapsed away by the renderer, leaving\n * a tag that resolves to nothing; the library retries a few times and then gives up silently, so\n * the gesture simply never fires. `GestureDetector` avoids it by cloning its child with\n * `collapsable: false`, and this is that, as a host binding. It runs after the host component's\n * own binding for the same prop, which is what makes it win.\n */\n@Directive({ selector: '[gesture]', host: { '[collapsable]': 'false' } })\nexport class NativeGestureBase {\n private readonly node = inject(ElementRef).nativeElement as EngineNode;\n private readonly engine = inject(Engine);\n private readonly gestures = inject(GESTURES);\n private readonly injector = inject(Injector);\n\n readonly gesture = input.required<GestureSpec>();\n\n constructor() {\n // Native attaches a recogniser to a view, so there has to be one: a node has no react tag\n // until it has been committed.\n afterNextRender(() => {\n effect(\n (onCleanup) => {\n const gesture = this.gesture();\n const tag = this.engine.tagOf(this.node);\n if (tag === null) return;\n onCleanup(this.gestures.attach({ tag }, gesture));\n },\n { injector: this.injector },\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"native-gesture.js","sourceRoot":"","sources":["../src/native-gesture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,eAAe,EACf,MAAM,EACN,MAAM,EACN,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,MAAM,EAAmB,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAuC,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,iBAAiB,EACjB,UAAU,GAEX,MAAM,2BAA2B,CAAC;;AAEnC;;;;;;;;;GASG;AAEH,MAAM,OAAO,iBAAiB;IACX,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,aAA2B,CAAC;IACtD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IACxB,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC5B,SAAS,GAAG,MAAM,CAAC,qBAAqB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAEtE,OAAO,GAAG,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AAC;QAClF,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,iBAAiB,CAAC,SAAS,EAAE;YAC3B,GAAG,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC;YAC1C,GAAG,WAAW;YACd,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,CAAC;YACnC,MAAM,EAAE,OAAO;YACf,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;uGAhDU,iBAAiB;2FAAjB,iBAAiB;;2FAAjB,iBAAiB;kBAD7B,SAAS;mBAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,OAAO,EAAE,EAAE","sourcesContent":["/**\n * A native gesture, attached to the element it sits on.\n *\n * ```html\n * <view [gesture]=\"pan\">\n * ```\n *\n * The equivalent of `GestureDetector`, which is a React component whose whole job is to hold a\n * ref, turn it into a view tag, and hand that tag to the native module. A directive already has\n * the node, and the engine already knows its tag.\n *\n * `NativeGesture` in `../gestures.ts` is the one apps import: same selector, and it supplies the\n * real library itself.\n */\nimport {\n Directive,\n ElementRef,\n Injector,\n afterNextRender,\n effect,\n inject,\n input,\n} from '@angular/core';\nimport { Engine, type EngineNode } from '@ng-native/fabric';\nimport { GESTURES, type EndedGesture, type GestureSpec } from './gesture-backend.ts';\nimport { gestureInteraction } from './gesture-interaction.ts';\nimport { booleanOr } from './transforms.ts';\nimport {\n INTERACTION_OBSERVERS,\n describeElement,\n notifyInteraction,\n textWithin,\n type InteractionObserver,\n} from './interaction-observer.ts';\n\n/**\n * The behaviour, with the library left as a dependency so a test can drive a fake one.\n *\n * `collapsable` is the load-bearing part of the host bindings. Native attaches a recogniser to a\n * *view*, and a view that only groups its children can be collapsed away by the renderer, leaving\n * a tag that resolves to nothing; the library retries a few times and then gives up silently, so\n * the gesture simply never fires. `GestureDetector` avoids it by cloning its child with\n * `collapsable: false`, and this is that, as a host binding. It runs after the host component's\n * own binding for the same prop, which is what makes it win.\n */\n@Directive({ selector: '[gesture]', host: { '[collapsable]': 'false' } })\nexport class NativeGestureBase {\n private readonly node = inject(ElementRef).nativeElement as EngineNode;\n private readonly engine = inject(Engine);\n private readonly gestures = inject(GESTURES);\n private readonly injector = inject(Injector);\n private readonly observers = inject(INTERACTION_OBSERVERS, { optional: true });\n\n readonly gesture = input.required<GestureSpec>();\n /**\n * Whether the app's interaction observers hear this element's gestures. `false` keeps one out,\n * such as a drawing surface whose every stroke is not an interaction worth recording.\n */\n readonly trackGesture = input(true, { transform: booleanOr(true) });\n\n constructor() {\n // Native attaches a recogniser to a view, so there has to be one: a node has no react tag\n // until it has been committed.\n afterNextRender(() => {\n effect(\n (onCleanup) => {\n const gesture = this.gesture();\n const tag = this.engine.tagOf(this.node);\n if (tag === null) return;\n // Decided here, once per attach, so a gesture nobody observes costs nothing per event.\n const observers = this.trackGesture() && this.observers?.length ? this.observers : null;\n const report = observers\n ? (ended: EndedGesture) => this.report(observers, ended)\n : undefined;\n onCleanup(this.gestures.attach({ tag }, gesture, report));\n },\n { injector: this.injector },\n );\n });\n }\n\n /** Tell the observers about a gesture of this element's that has just ended. */\n private report(observers: readonly InteractionObserver[], ended: EndedGesture): void {\n const interaction = gestureInteraction(ended);\n if (!interaction) return;\n const pressed = interaction.type === 'click' || interaction.type === 'long-press';\n const text = pressed ? textWithin(this.node) : undefined;\n notifyInteraction(observers, {\n ...describeElement(this.engine, this.node),\n ...interaction,\n ...(text !== undefined && { text }),\n source: 'touch',\n timestamp: Date.now(),\n });\n }\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { HostEngine, HostNode } from '@ng-native/fabric';
2
+ /**
3
+ * Something about an element sent to a host module by its view's `nativeID`, where React Native's
4
+ * view would drop it as a prop (Android, iOS). Answers the function that sends it: `send` runs
5
+ * after the element's props are written, so a `nativeID` the app gave is there. Once sent, a
6
+ * `nativeID` the app binds, changes or takes away is followed: `send` runs again with the new one
7
+ * (the given one where the app's went), with `clear` for the old, and `clear` runs as the element
8
+ * goes. Call in an injection context.
9
+ */
10
+ export declare function byNativeId(engine: HostEngine, node: HostNode, send: (nativeID: string) => void, clear: (nativeID: string) => void): () => void;
@@ -0,0 +1,70 @@
1
+ import { DestroyRef, inject } from '@angular/core';
2
+ /** The `nativeID` each element was given here, where the app gave it none. */
3
+ const given = new WeakMap();
4
+ let named = 0;
5
+ /**
6
+ * The `nativeID` a host module finds `node`'s view by: the app's own, or one given to it here and
7
+ * kept, so every directive on the element names it alike. A view with a `nativeID` is never
8
+ * flattened away.
9
+ */
10
+ function nativeIdOf(engine, node) {
11
+ const own = node.props['nativeID'];
12
+ if (typeof own === 'string' && own)
13
+ return own;
14
+ let id = given.get(node);
15
+ if (id === undefined) {
16
+ id = `ngn-view-${++named}`;
17
+ given.set(node, id);
18
+ }
19
+ engine.setProp(node, 'nativeID', id);
20
+ return id;
21
+ }
22
+ /**
23
+ * Something about an element sent to a host module by its view's `nativeID`, where React Native's
24
+ * view would drop it as a prop (Android, iOS). Answers the function that sends it: `send` runs
25
+ * after the element's props are written, so a `nativeID` the app gave is there. Once sent, a
26
+ * `nativeID` the app binds, changes or takes away is followed: `send` runs again with the new one
27
+ * (the given one where the app's went), with `clear` for the old, and `clear` runs as the element
28
+ * goes. Call in an injection context.
29
+ */
30
+ export function byNativeId(engine, node, send, clear) {
31
+ let sentAs = null;
32
+ let destroyed = false;
33
+ let scheduled = false;
34
+ let flushing = false;
35
+ const flush = () => {
36
+ scheduled = false;
37
+ if (destroyed)
38
+ return;
39
+ flushing = true;
40
+ try {
41
+ const id = nativeIdOf(engine, node);
42
+ if (sentAs !== null && sentAs !== id)
43
+ clear(sentAs);
44
+ sentAs = id;
45
+ send(id);
46
+ }
47
+ finally {
48
+ flushing = false;
49
+ }
50
+ };
51
+ const schedule = () => {
52
+ if (scheduled || destroyed)
53
+ return;
54
+ scheduled = true;
55
+ engine.settle({ settleProps: flush });
56
+ };
57
+ // The app's own binding, which may arrive, change or go after the first send.
58
+ const unwatch = engine.watchProp(node, 'nativeID', (value) => {
59
+ if (!flushing && sentAs !== null && value !== sentAs)
60
+ schedule();
61
+ });
62
+ inject(DestroyRef).onDestroy(() => {
63
+ destroyed = true;
64
+ unwatch();
65
+ if (sentAs !== null)
66
+ clear(sentAs);
67
+ });
68
+ return schedule;
69
+ }
70
+ //# sourceMappingURL=native-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-id.js","sourceRoot":"","sources":["../src/native-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGnD,8EAA8E;AAC9E,MAAM,KAAK,GAAG,IAAI,OAAO,EAAoB,CAAC;AAC9C,IAAI,KAAK,GAAG,CAAC,CAAC;AAEd;;;;GAIG;AACH,SAAS,UAAU,CAAC,MAAkB,EAAE,IAAc;IACpD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACnC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG;QAAE,OAAO,GAAG,CAAC;IAC/C,IAAI,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACzB,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,EAAE,GAAG,YAAY,EAAE,KAAK,EAAE,CAAC;QAC3B,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;IACrC,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,MAAkB,EAClB,IAAc,EACd,IAAgC,EAChC,KAAiC;IAEjC,IAAI,MAAM,GAAkB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;AAClB,CAAC","sourcesContent":["import { DestroyRef, inject } from '@angular/core';\nimport type { HostEngine, HostNode } from '@ng-native/fabric';\n\n/** The `nativeID` each element was given here, where the app gave it none. */\nconst given = new WeakMap<HostNode, string>();\nlet named = 0;\n\n/**\n * The `nativeID` a host module finds `node`'s view by: the app's own, or one given to it here and\n * kept, so every directive on the element names it alike. A view with a `nativeID` is never\n * flattened away.\n */\nfunction nativeIdOf(engine: HostEngine, node: HostNode): string {\n const own = node.props['nativeID'];\n if (typeof own === 'string' && own) return own;\n let id = given.get(node);\n if (id === undefined) {\n id = `ngn-view-${++named}`;\n given.set(node, id);\n }\n engine.setProp(node, 'nativeID', id);\n return id;\n}\n\n/**\n * Something about an element sent to a host module by its view's `nativeID`, where React Native's\n * view would drop it as a prop (Android, iOS). Answers the function that sends it: `send` runs\n * after the element's props are written, so a `nativeID` the app gave is there. Once sent, a\n * `nativeID` the app binds, changes or takes away is followed: `send` runs again with the new one\n * (the given one where the app's went), with `clear` for the old, and `clear` runs as the element\n * goes. Call in an injection context.\n */\nexport function byNativeId(\n engine: HostEngine,\n node: HostNode,\n send: (nativeID: string) => void,\n clear: (nativeID: string) => void,\n): () => void {\n let sentAs: string | null = null;\n let destroyed = false;\n let scheduled = false;\n let flushing = false;\n const flush = () => {\n scheduled = false;\n if (destroyed) return;\n flushing = true;\n try {\n const id = nativeIdOf(engine, node);\n if (sentAs !== null && sentAs !== id) clear(sentAs);\n sentAs = id;\n send(id);\n } finally {\n flushing = false;\n }\n };\n const schedule = () => {\n if (scheduled || destroyed) return;\n scheduled = true;\n engine.settle({ settleProps: flush });\n };\n // The app's own binding, which may arrive, change or go after the first send.\n const unwatch = engine.watchProp(node, 'nativeID', (value) => {\n if (!flushing && sentAs !== null && value !== sentAs) schedule();\n });\n inject(DestroyRef).onDestroy(() => {\n destroyed = true;\n unwatch();\n if (sentAs !== null) clear(sentAs);\n });\n return schedule;\n}\n"]}
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { type Signal } from '@angular/core';
9
9
  import type { Insets, TouchEvent } from './events.ts';
10
+ import { type InteractionType } from './interaction-observer.ts';
10
11
  import { ViewBase } from './view-base.ts';
11
12
  import * as i0 from "@angular/core";
12
13
  /** What a press handler receives: RN's `{nativeEvent}` shape, passed straight through. */
@@ -100,9 +101,18 @@ export declare abstract class TouchableBase extends ViewBase {
100
101
  private longPressed;
101
102
  /** How many `(longPress)` listeners there are; the long-press clock only runs with one. */
102
103
  private longPressListeners;
104
+ /** A `[contextMenu]` on the same element, whose menu a long press may open instead. */
105
+ private readonly contextMenu;
106
+ /**
107
+ * For `Menus`, read only where there is a `(longPress)` (see `takeLongPressFromMenus`), and for
108
+ * the interaction observers, read only once something is pressed.
109
+ */
110
+ private readonly injector;
103
111
  private pressedAt;
104
112
  private pressInTimer;
105
113
  private longPressTimer;
114
+ /** Whether a `[contextMenu]` inside this element took this press's hold, as the press began. */
115
+ private menuOwnsHold;
106
116
  private pressOutTimer;
107
117
  constructor();
108
118
  /** Called as a press starts and ends, for a subclass that shows it natively. `Text` does. */
@@ -150,6 +160,13 @@ export declare abstract class TouchableBase extends ViewBase {
150
160
  private stopHover;
151
161
  private stopClick;
152
162
  ngOnInit(): void;
163
+ /**
164
+ * Tell a host that opens a `[contextMenu]` on a long press (Android, iOS) that this view takes
165
+ * its own, so one on it opens no menu around it: the innermost handler wins, as in a native
166
+ * app. Every such view, not only one inside a menu, since a menu can be around it from another
167
+ * template. A view with its own menu still opens that.
168
+ */
169
+ private takeLongPressFromMenus;
153
170
  ngOnChanges(): void;
154
171
  /**
155
172
  * A press with no touch: Android's `performClick()`, which is what Enter, the D-pad centre and
@@ -201,8 +218,22 @@ export declare abstract class TouchableBase extends ViewBase {
201
218
  private onGrant;
202
219
  /** `pressIn`, and the long-press clock starts from here. */
203
220
  private activate;
221
+ /**
222
+ * Whether the host opens a `[contextMenu]` inside this element on this long press, from the
223
+ * pressed view out to this one, so `(longPress)` here does not also fire. The host decides at
224
+ * its own long-press timeout, which can be later than `delayLongPress`.
225
+ */
226
+ private menuTakesLongPress;
204
227
  private onMove;
205
228
  private onRelease;
229
+ /**
230
+ * Tell the app's interaction observers, if it has any, about a press that has just fired. They
231
+ * are looked up here rather than injected, because a press is rare and a lookup for every
232
+ * `<text>` on screen is not.
233
+ * Reported whether or not `(press)` has a listener: a control that does nothing when tapped is
234
+ * what an observer looking for dead taps wants to hear about.
235
+ */
236
+ protected reportInteraction(type: InteractionType, event: PressEvent, source: 'touch' | 'click'): void;
206
237
  private onTerminate;
207
238
  /** `pressOut`, no sooner than `minPressDuration` after `pressIn` and after `delayPressOut`. */
208
239
  private deactivate;