@ng-native/components 0.22.2 → 0.24.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 (139) hide show
  1. package/android/build.gradle +22 -0
  2. package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +38 -0
  3. package/android/src/main/java/dev/ngnative/components/ContextMenuAccessibility.kt +71 -0
  4. package/android/src/main/java/dev/ngnative/components/ContextMenuGesture.kt +161 -0
  5. package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +197 -0
  6. package/android/src/main/java/dev/ngnative/components/MenuHost.kt +45 -0
  7. package/android/src/main/java/dev/ngnative/components/MenuWindowCallback.kt +76 -0
  8. package/android/src/main/java/dev/ngnative/components/MenusModule.kt +85 -0
  9. package/android/src/main/java/dev/ngnative/components/Shortcut.kt +144 -0
  10. package/android/src/main/java/dev/ngnative/components/WindowWrapper.kt +22 -0
  11. package/dist/activity-indicator.d.ts +4 -1
  12. package/dist/activity-indicator.js +6 -2
  13. package/dist/activity-indicator.js.map +1 -1
  14. package/dist/context-menu.d.ts +52 -0
  15. package/dist/context-menu.js +101 -0
  16. package/dist/context-menu.js.map +1 -0
  17. package/dist/drag-and-drop.d.ts +52 -0
  18. package/dist/drag-and-drop.js +112 -0
  19. package/dist/drag-and-drop.js.map +1 -0
  20. package/dist/gesture-backend.d.ts +32 -2
  21. package/dist/gesture-backend.js.map +1 -1
  22. package/dist/gesture-dispatch.d.ts +8 -1
  23. package/dist/gesture-dispatch.js +60 -16
  24. package/dist/gesture-dispatch.js.map +1 -1
  25. package/dist/gesture-interaction.d.ts +13 -0
  26. package/dist/gesture-interaction.js +97 -0
  27. package/dist/gesture-interaction.js.map +1 -0
  28. package/dist/gesture-tracking.d.ts +18 -0
  29. package/dist/gesture-tracking.js +28 -0
  30. package/dist/gesture-tracking.js.map +1 -0
  31. package/dist/gestures-web.d.ts +3 -1
  32. package/dist/gestures-web.js +5 -2
  33. package/dist/gestures-web.js.map +1 -1
  34. package/dist/gestures.d.ts +1 -0
  35. package/dist/gestures.js +45 -3
  36. package/dist/gestures.js.map +1 -1
  37. package/dist/image.d.ts +1 -1
  38. package/dist/index.d.ts +12 -1
  39. package/dist/index.js +12 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/interaction-observer.d.ts +11 -0
  42. package/dist/interaction-observer.js +12 -0
  43. package/dist/interaction-observer.js.map +1 -0
  44. package/dist/keyboard-avoiding-view.js +3 -3
  45. package/dist/keyboard-avoiding-view.js.map +1 -1
  46. package/dist/markdown-stream.d.ts +3 -1
  47. package/dist/markdown-stream.js +14 -2
  48. package/dist/markdown-stream.js.map +1 -1
  49. package/dist/markdown.d.ts +2 -0
  50. package/dist/markdown.js +5 -3
  51. package/dist/markdown.js.map +1 -1
  52. package/dist/menu.d.ts +71 -0
  53. package/dist/menu.js +193 -0
  54. package/dist/menu.js.map +1 -0
  55. package/dist/modal.d.ts +30 -1
  56. package/dist/modal.js +67 -6
  57. package/dist/modal.js.map +1 -1
  58. package/dist/native-button.d.ts +54 -0
  59. package/dist/native-button.js +99 -0
  60. package/dist/native-button.js.map +1 -0
  61. package/dist/native-gesture.d.ts +9 -1
  62. package/dist/native-gesture.js +32 -3
  63. package/dist/native-gesture.js.map +1 -1
  64. package/dist/native-id.d.ts +10 -0
  65. package/dist/native-id.js +70 -0
  66. package/dist/native-id.js.map +1 -0
  67. package/dist/pressable.d.ts +36 -0
  68. package/dist/pressable.js +106 -10
  69. package/dist/pressable.js.map +1 -1
  70. package/dist/safe-area-provider.js +15 -8
  71. package/dist/safe-area-provider.js.map +1 -1
  72. package/dist/scroll-view-props.d.ts +7 -1
  73. package/dist/scroll-view-props.js +54 -3
  74. package/dist/scroll-view-props.js.map +1 -1
  75. package/dist/section-list.js +2 -2
  76. package/dist/section-list.js.map +1 -1
  77. package/dist/shortcut.d.ts +21 -0
  78. package/dist/shortcut.js +34 -0
  79. package/dist/shortcut.js.map +1 -0
  80. package/dist/sidebar-item.d.ts +53 -0
  81. package/dist/sidebar-item.js +152 -0
  82. package/dist/sidebar-item.js.map +1 -0
  83. package/dist/sidebar-section.d.ts +21 -0
  84. package/dist/sidebar-section.js +74 -0
  85. package/dist/sidebar-section.js.map +1 -0
  86. package/dist/sidebar.d.ts +47 -0
  87. package/dist/sidebar.js +110 -0
  88. package/dist/sidebar.js.map +1 -0
  89. package/dist/split-view.d.ts +63 -0
  90. package/dist/split-view.js +121 -0
  91. package/dist/split-view.js.map +1 -0
  92. package/dist/switch.d.ts +9 -1
  93. package/dist/switch.js +23 -2
  94. package/dist/switch.js.map +1 -1
  95. package/dist/text-input.d.ts +8 -3
  96. package/dist/text-input.js +10 -4
  97. package/dist/text-input.js.map +1 -1
  98. package/dist/transforms.d.ts +5 -0
  99. package/dist/transforms.js +7 -0
  100. package/dist/transforms.js.map +1 -1
  101. package/dist/tray-icon.d.ts +18 -0
  102. package/dist/tray-icon.js +46 -0
  103. package/dist/tray-icon.js.map +1 -0
  104. package/dist/view-base.d.ts +42 -1
  105. package/dist/view-base.js +67 -39
  106. package/dist/view-base.js.map +1 -1
  107. package/dist/virtual-list.js +12 -1
  108. package/dist/virtual-list.js.map +1 -1
  109. package/dist/written-props.js +25 -0
  110. package/dist/written-props.js.map +1 -1
  111. package/expo-module.config.json +6 -0
  112. package/ios/NgNativeButtonComponentView.mm +132 -0
  113. package/ios/NgNativeButtonMetrics.h +28 -0
  114. package/ios/NgNativeButtonMetrics.mm +68 -0
  115. package/ios/NgNativeButtonShadowNode.h +65 -0
  116. package/ios/NgNativeButtonShadowNode.mm +40 -0
  117. package/ios/NgNativeComponents.podspec +28 -0
  118. package/ios/NgNativeDragAndDrop.mm +342 -0
  119. package/ios/NgNativeDropItems.h +29 -0
  120. package/ios/NgNativeDropItems.mm +55 -0
  121. package/ios/NgNativeMenuBuilding.h +40 -0
  122. package/ios/NgNativeMenuBuilding.mm +217 -0
  123. package/ios/NgNativeMenus.mm +320 -0
  124. package/ios/NgNativeResponderHooks.h +53 -0
  125. package/ios/NgNativeResponderHooks.mm +215 -0
  126. package/ios/NgNativeSceneKeys.h +36 -0
  127. package/ios/NgNativeSceneKeys.mm +56 -0
  128. package/ios/NgNativeSplitView.mm +433 -0
  129. package/ios/NgNativeSplitViewDelegate.h +29 -0
  130. package/ios/NgNativeSplitViewDelegate.mm +122 -0
  131. package/ios/NgNativeSplitViewShadowNodes.h +115 -0
  132. package/ios/NgNativeSplitViewShadowNodes.mm +31 -0
  133. package/ios/NgNativeUndo.mm +107 -0
  134. package/ios/NgNativeUndoSteps.h +17 -0
  135. package/ios/NgNativeUndoSteps.mm +22 -0
  136. package/ios/NgNativeViewBinder.h +54 -0
  137. package/ios/NgNativeViewBinder.mm +225 -0
  138. package/ios/NgNativeWindows.mm +1126 -0
  139. package/package.json +13 -5
@@ -1,7 +1,18 @@
1
- import { Directive, computed, input } from '@angular/core';
1
+ import { DestroyRef, Directive, computed, inject, input } from '@angular/core';
2
+ import { INTERACTION_OBSERVERS, SWIPE_VELOCITY, describeElement, notifyInteraction, } from "./interaction-observer.js";
2
3
  import { optionalBoolean, optionalNumber } from "./transforms.js";
3
4
  import { ViewBase } from "./view-base.js";
4
5
  import * as i0 from "@angular/core";
6
+ /** Which way the content moved, by the axis it moved further along, or null if it did not move. */
7
+ function dragDirection(from, to) {
8
+ const dx = to.x - from.x;
9
+ const dy = to.y - from.y;
10
+ if (dx === 0 && dy === 0)
11
+ return null;
12
+ if (Math.abs(dx) > Math.abs(dy))
13
+ return dx > 0 ? 'right' : 'left';
14
+ return dy > 0 ? 'down' : 'up';
15
+ }
5
16
  /** RN's `processDecelerationRate`: the named rates, as UIKit and Android define them. */
6
17
  const DECELERATION = { normal: 0.998, fast: 0.99 };
7
18
  /**
@@ -103,7 +114,47 @@ export class ScrollViewProps extends ViewBase {
103
114
  return typeof rate === 'string' ? DECELERATION[rate] : rate;
104
115
  }, /* @ts-ignore */
105
116
  ...(ngDevMode ? [{ debugName: "resolvedDecelerationRate" }] : /* istanbul ignore next */ []));
106
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ScrollViewProps, deps: null, target: i0.ɵɵFactoryTarget.Directive });
117
+ constructor() {
118
+ super();
119
+ // Scroll views are few, so unlike a press this looks once, and listens only for an app that
120
+ // asked.
121
+ const observers = inject(INTERACTION_OBSERVERS, { optional: true });
122
+ if (observers?.length)
123
+ this.reportDrags(observers);
124
+ }
125
+ /**
126
+ * One `scroll` or `swipe` per drag the user makes, as the finger lifts. A scroll made by code,
127
+ * `scrollTo` or a tap on the status bar, has no drag, so reports nothing.
128
+ */
129
+ reportDrags(observers) {
130
+ let start = null;
131
+ const begin = this.engine.setEventListener(this.node, 'topScrollBeginDrag', (event) => {
132
+ start = event.nativeEvent?.contentOffset ?? null;
133
+ });
134
+ const end = this.engine.setEventListener(this.node, 'topScrollEndDrag', (event) => {
135
+ const { contentOffset, velocity } = event.nativeEvent ?? {};
136
+ const from = start;
137
+ start = null;
138
+ if (!from || !contentOffset)
139
+ return;
140
+ const direction = dragDirection(from, contentOffset);
141
+ if (!direction)
142
+ return;
143
+ const speed = velocity ? Math.hypot(velocity.x, velocity.y) : 0;
144
+ notifyInteraction(observers, {
145
+ type: speed >= SWIPE_VELOCITY ? 'swipe' : 'scroll',
146
+ ...describeElement(this.engine, this.node),
147
+ direction,
148
+ source: 'touch',
149
+ timestamp: Date.now(),
150
+ });
151
+ });
152
+ inject(DestroyRef).onDestroy(() => {
153
+ begin();
154
+ end();
155
+ });
156
+ }
157
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ScrollViewProps, deps: [], target: i0.ɵɵFactoryTarget.Directive });
107
158
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: ScrollViewProps, isStandalone: true, inputs: { scrollEnabled: { classPropertyName: "scrollEnabled", publicName: "scrollEnabled", isSignal: true, isRequired: false, transformFunction: null }, showsHorizontalScrollIndicator: { classPropertyName: "showsHorizontalScrollIndicator", publicName: "showsHorizontalScrollIndicator", isSignal: true, isRequired: false, transformFunction: null }, showsVerticalScrollIndicator: { classPropertyName: "showsVerticalScrollIndicator", publicName: "showsVerticalScrollIndicator", isSignal: true, isRequired: false, transformFunction: null }, pagingEnabled: { classPropertyName: "pagingEnabled", publicName: "pagingEnabled", isSignal: true, isRequired: false, transformFunction: null }, decelerationRate: { classPropertyName: "decelerationRate", publicName: "decelerationRate", isSignal: true, isRequired: false, transformFunction: null }, snapToInterval: { classPropertyName: "snapToInterval", publicName: "snapToInterval", isSignal: true, isRequired: false, transformFunction: null }, snapToOffsets: { classPropertyName: "snapToOffsets", publicName: "snapToOffsets", isSignal: true, isRequired: false, transformFunction: null }, snapToAlignment: { classPropertyName: "snapToAlignment", publicName: "snapToAlignment", isSignal: true, isRequired: false, transformFunction: null }, snapToStart: { classPropertyName: "snapToStart", publicName: "snapToStart", isSignal: true, isRequired: false, transformFunction: null }, snapToEnd: { classPropertyName: "snapToEnd", publicName: "snapToEnd", isSignal: true, isRequired: false, transformFunction: null }, disableIntervalMomentum: { classPropertyName: "disableIntervalMomentum", publicName: "disableIntervalMomentum", isSignal: true, isRequired: false, transformFunction: null }, scrollEventThrottle: { classPropertyName: "scrollEventThrottle", publicName: "scrollEventThrottle", isSignal: true, isRequired: false, transformFunction: null }, contentInset: { classPropertyName: "contentInset", publicName: "contentInset", isSignal: true, isRequired: false, transformFunction: null }, scrollIndicatorInsets: { classPropertyName: "scrollIndicatorInsets", publicName: "scrollIndicatorInsets", isSignal: true, isRequired: false, transformFunction: null }, bounces: { classPropertyName: "bounces", publicName: "bounces", isSignal: true, isRequired: false, transformFunction: null }, alwaysBounceHorizontal: { classPropertyName: "alwaysBounceHorizontal", publicName: "alwaysBounceHorizontal", isSignal: true, isRequired: false, transformFunction: null }, alwaysBounceVertical: { classPropertyName: "alwaysBounceVertical", publicName: "alwaysBounceVertical", isSignal: true, isRequired: false, transformFunction: null }, bouncesZoom: { classPropertyName: "bouncesZoom", publicName: "bouncesZoom", isSignal: true, isRequired: false, transformFunction: null }, directionalLockEnabled: { classPropertyName: "directionalLockEnabled", publicName: "directionalLockEnabled", isSignal: true, isRequired: false, transformFunction: null }, canCancelContentTouches: { classPropertyName: "canCancelContentTouches", publicName: "canCancelContentTouches", isSignal: true, isRequired: false, transformFunction: null }, centerContent: { classPropertyName: "centerContent", publicName: "centerContent", isSignal: true, isRequired: false, transformFunction: null }, automaticallyAdjustContentInsets: { classPropertyName: "automaticallyAdjustContentInsets", publicName: "automaticallyAdjustContentInsets", isSignal: true, isRequired: false, transformFunction: null }, automaticallyAdjustKeyboardInsets: { classPropertyName: "automaticallyAdjustKeyboardInsets", publicName: "automaticallyAdjustKeyboardInsets", isSignal: true, isRequired: false, transformFunction: null }, automaticallyAdjustsScrollIndicatorInsets: { classPropertyName: "automaticallyAdjustsScrollIndicatorInsets", publicName: "automaticallyAdjustsScrollIndicatorInsets", isSignal: true, isRequired: false, transformFunction: null }, contentInsetAdjustmentBehavior: { classPropertyName: "contentInsetAdjustmentBehavior", publicName: "contentInsetAdjustmentBehavior", isSignal: true, isRequired: false, transformFunction: null }, pinchGestureEnabled: { classPropertyName: "pinchGestureEnabled", publicName: "pinchGestureEnabled", isSignal: true, isRequired: false, transformFunction: null }, maximumZoomScale: { classPropertyName: "maximumZoomScale", publicName: "maximumZoomScale", isSignal: true, isRequired: false, transformFunction: null }, minimumZoomScale: { classPropertyName: "minimumZoomScale", publicName: "minimumZoomScale", isSignal: true, isRequired: false, transformFunction: null }, zoomScale: { classPropertyName: "zoomScale", publicName: "zoomScale", isSignal: true, isRequired: false, transformFunction: null }, indicatorStyle: { classPropertyName: "indicatorStyle", publicName: "indicatorStyle", isSignal: true, isRequired: false, transformFunction: null }, scrollsToTop: { classPropertyName: "scrollsToTop", publicName: "scrollsToTop", isSignal: true, isRequired: false, transformFunction: null }, scrollToOverflowEnabled: { classPropertyName: "scrollToOverflowEnabled", publicName: "scrollToOverflowEnabled", isSignal: true, isRequired: false, transformFunction: null }, keyboardDismissMode: { classPropertyName: "keyboardDismissMode", publicName: "keyboardDismissMode", isSignal: true, isRequired: false, transformFunction: null }, overScrollMode: { classPropertyName: "overScrollMode", publicName: "overScrollMode", isSignal: true, isRequired: false, transformFunction: null }, persistentScrollbar: { classPropertyName: "persistentScrollbar", publicName: "persistentScrollbar", isSignal: true, isRequired: false, transformFunction: null }, fadingEdgeLength: { classPropertyName: "fadingEdgeLength", publicName: "fadingEdgeLength", isSignal: true, isRequired: false, transformFunction: null }, endFillColor: { classPropertyName: "endFillColor", publicName: "endFillColor", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "scrollEnabled": "scrollEnabled()", "showsHorizontalScrollIndicator": "showsHorizontalScrollIndicator()", "showsVerticalScrollIndicator": "showsVerticalScrollIndicator()", "pagingEnabled": "pagingEnabled()", "decelerationRate": "resolvedDecelerationRate()", "snapToInterval": "snapToInterval()", "snapToOffsets": "snapToOffsets()", "snapToAlignment": "snapToAlignment()", "snapToStart": "snapToStart()", "snapToEnd": "snapToEnd()", "disableIntervalMomentum": "disableIntervalMomentum()", "sendMomentumEvents": "true", "contentInset": "contentInset()", "scrollIndicatorInsets": "scrollIndicatorInsets()", "bounces": "bounces()", "alwaysBounceHorizontal": "resolvedAlwaysBounceHorizontal()", "alwaysBounceVertical": "resolvedAlwaysBounceVertical()", "bouncesZoom": "bouncesZoom()", "directionalLockEnabled": "directionalLockEnabled()", "canCancelContentTouches": "canCancelContentTouches()", "centerContent": "centerContent()", "automaticallyAdjustContentInsets": "automaticallyAdjustContentInsets()", "automaticallyAdjustKeyboardInsets": "automaticallyAdjustKeyboardInsets()", "automaticallyAdjustsScrollIndicatorInsets": "automaticallyAdjustsScrollIndicatorInsets()", "contentInsetAdjustmentBehavior": "contentInsetAdjustmentBehavior()", "pinchGestureEnabled": "pinchGestureEnabled()", "maximumZoomScale": "maximumZoomScale()", "minimumZoomScale": "minimumZoomScale()", "zoomScale": "zoomScale()", "indicatorStyle": "indicatorStyle()", "scrollsToTop": "scrollsToTop()", "scrollToOverflowEnabled": "scrollToOverflowEnabled()", "keyboardDismissMode": "keyboardDismissMode()", "overScrollMode": "overScrollMode()", "persistentScrollbar": "persistentScrollbar()", "fadingEdgeLength": "fadingEdgeLength()", "endFillColor": "endFillColor()" } }, usesInheritance: true, ngImport: i0 });
108
159
  }
109
160
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ScrollViewProps, decorators: [{
@@ -149,5 +200,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
149
200
  '[endFillColor]': 'endFillColor()',
150
201
  },
151
202
  }]
152
- }], propDecorators: { scrollEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollEnabled", required: false }] }], showsHorizontalScrollIndicator: [{ type: i0.Input, args: [{ isSignal: true, alias: "showsHorizontalScrollIndicator", required: false }] }], showsVerticalScrollIndicator: [{ type: i0.Input, args: [{ isSignal: true, alias: "showsVerticalScrollIndicator", required: false }] }], pagingEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "pagingEnabled", required: false }] }], decelerationRate: [{ type: i0.Input, args: [{ isSignal: true, alias: "decelerationRate", required: false }] }], snapToInterval: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToInterval", required: false }] }], snapToOffsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToOffsets", required: false }] }], snapToAlignment: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToAlignment", required: false }] }], snapToStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToStart", required: false }] }], snapToEnd: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToEnd", required: false }] }], disableIntervalMomentum: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableIntervalMomentum", required: false }] }], scrollEventThrottle: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollEventThrottle", required: false }] }], contentInset: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentInset", required: false }] }], scrollIndicatorInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollIndicatorInsets", required: false }] }], bounces: [{ type: i0.Input, args: [{ isSignal: true, alias: "bounces", required: false }] }], alwaysBounceHorizontal: [{ type: i0.Input, args: [{ isSignal: true, alias: "alwaysBounceHorizontal", required: false }] }], alwaysBounceVertical: [{ type: i0.Input, args: [{ isSignal: true, alias: "alwaysBounceVertical", required: false }] }], bouncesZoom: [{ type: i0.Input, args: [{ isSignal: true, alias: "bouncesZoom", required: false }] }], directionalLockEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "directionalLockEnabled", required: false }] }], canCancelContentTouches: [{ type: i0.Input, args: [{ isSignal: true, alias: "canCancelContentTouches", required: false }] }], centerContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "centerContent", required: false }] }], automaticallyAdjustContentInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "automaticallyAdjustContentInsets", required: false }] }], automaticallyAdjustKeyboardInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "automaticallyAdjustKeyboardInsets", required: false }] }], automaticallyAdjustsScrollIndicatorInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "automaticallyAdjustsScrollIndicatorInsets", required: false }] }], contentInsetAdjustmentBehavior: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentInsetAdjustmentBehavior", required: false }] }], pinchGestureEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "pinchGestureEnabled", required: false }] }], maximumZoomScale: [{ type: i0.Input, args: [{ isSignal: true, alias: "maximumZoomScale", required: false }] }], minimumZoomScale: [{ type: i0.Input, args: [{ isSignal: true, alias: "minimumZoomScale", required: false }] }], zoomScale: [{ type: i0.Input, args: [{ isSignal: true, alias: "zoomScale", required: false }] }], indicatorStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "indicatorStyle", required: false }] }], scrollsToTop: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollsToTop", required: false }] }], scrollToOverflowEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollToOverflowEnabled", required: false }] }], keyboardDismissMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboardDismissMode", required: false }] }], overScrollMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "overScrollMode", required: false }] }], persistentScrollbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "persistentScrollbar", required: false }] }], fadingEdgeLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "fadingEdgeLength", required: false }] }], endFillColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "endFillColor", required: false }] }] } });
203
+ }], ctorParameters: () => [], propDecorators: { scrollEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollEnabled", required: false }] }], showsHorizontalScrollIndicator: [{ type: i0.Input, args: [{ isSignal: true, alias: "showsHorizontalScrollIndicator", required: false }] }], showsVerticalScrollIndicator: [{ type: i0.Input, args: [{ isSignal: true, alias: "showsVerticalScrollIndicator", required: false }] }], pagingEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "pagingEnabled", required: false }] }], decelerationRate: [{ type: i0.Input, args: [{ isSignal: true, alias: "decelerationRate", required: false }] }], snapToInterval: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToInterval", required: false }] }], snapToOffsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToOffsets", required: false }] }], snapToAlignment: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToAlignment", required: false }] }], snapToStart: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToStart", required: false }] }], snapToEnd: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToEnd", required: false }] }], disableIntervalMomentum: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableIntervalMomentum", required: false }] }], scrollEventThrottle: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollEventThrottle", required: false }] }], contentInset: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentInset", required: false }] }], scrollIndicatorInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollIndicatorInsets", required: false }] }], bounces: [{ type: i0.Input, args: [{ isSignal: true, alias: "bounces", required: false }] }], alwaysBounceHorizontal: [{ type: i0.Input, args: [{ isSignal: true, alias: "alwaysBounceHorizontal", required: false }] }], alwaysBounceVertical: [{ type: i0.Input, args: [{ isSignal: true, alias: "alwaysBounceVertical", required: false }] }], bouncesZoom: [{ type: i0.Input, args: [{ isSignal: true, alias: "bouncesZoom", required: false }] }], directionalLockEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "directionalLockEnabled", required: false }] }], canCancelContentTouches: [{ type: i0.Input, args: [{ isSignal: true, alias: "canCancelContentTouches", required: false }] }], centerContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "centerContent", required: false }] }], automaticallyAdjustContentInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "automaticallyAdjustContentInsets", required: false }] }], automaticallyAdjustKeyboardInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "automaticallyAdjustKeyboardInsets", required: false }] }], automaticallyAdjustsScrollIndicatorInsets: [{ type: i0.Input, args: [{ isSignal: true, alias: "automaticallyAdjustsScrollIndicatorInsets", required: false }] }], contentInsetAdjustmentBehavior: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentInsetAdjustmentBehavior", required: false }] }], pinchGestureEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "pinchGestureEnabled", required: false }] }], maximumZoomScale: [{ type: i0.Input, args: [{ isSignal: true, alias: "maximumZoomScale", required: false }] }], minimumZoomScale: [{ type: i0.Input, args: [{ isSignal: true, alias: "minimumZoomScale", required: false }] }], zoomScale: [{ type: i0.Input, args: [{ isSignal: true, alias: "zoomScale", required: false }] }], indicatorStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "indicatorStyle", required: false }] }], scrollsToTop: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollsToTop", required: false }] }], scrollToOverflowEnabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollToOverflowEnabled", required: false }] }], keyboardDismissMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyboardDismissMode", required: false }] }], overScrollMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "overScrollMode", required: false }] }], persistentScrollbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "persistentScrollbar", required: false }] }], fadingEdgeLength: [{ type: i0.Input, args: [{ isSignal: true, alias: "fadingEdgeLength", required: false }] }], endFillColor: [{ type: i0.Input, args: [{ isSignal: true, alias: "endFillColor", required: false }] }] } });
153
204
  //# sourceMappingURL=scroll-view-props.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-view-props.js","sourceRoot":"","sources":["../src/scroll-view-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C,yFAAyF;AACzF,MAAM,YAAY,GAA2B,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAE3E;;;;;;;GAOG;AA0CH,MAAM,OAAgB,eAAgB,SAAQ,QAAQ;IAIpD,kDAAkD;IACzC,aAAa,GAAG,KAAK,CAAC,SAAS,qFAAI,SAAS,EAAE,eAAe,GAAG,CAAC;IACjE,8BAA8B,GAAG,KAAK,CAAC,SAAS,sGAAI,SAAS,EAAE,eAAe,GAAG,CAAC;IAClF,4BAA4B,GAAG,KAAK,CAAC,SAAS,oGAAI,SAAS,EAAE,eAAe,GAAG,CAAC;IACzF,uDAAuD;IAC9C,aAAa,GAAG,KAAK,CAAC,SAAS,qFAAI,SAAS,EAAE,eAAe,GAAG,CAAC;IAC1E,wEAAwE;IAC/D,gBAAgB,GAAG,KAAK;oGAA8B,CAAC;IAChE,6CAA6C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,2BAA2B;wBACxD,iBAAiB,EAAE,iBAAiB;wBACpC,oCAAoC,EAAE,oCAAoC;wBAC1E,qCAAqC,EAAE,qCAAqC;wBAC5E,6CAA6C,EAAE,6CAA6C;wBAC5F,kCAAkC,EAAE,kCAAkC;wBACtE,uBAAuB,EAAE,uBAAuB;wBAChD,oBAAoB,EAAE,oBAAoB;wBAC1C,oBAAoB,EAAE,oBAAoB;wBAC1C,aAAa,EAAE,aAAa;wBAC5B,kBAAkB,EAAE,kBAAkB;wBACtC,gBAAgB,EAAE,gBAAgB;wBAClC,2BAA2B,EAAE,2BAA2B;wBACxD,uBAAuB,EAAE,uBAAuB;wBAChD,kBAAkB,EAAE,kBAAkB;wBACtC,uBAAuB,EAAE,uBAAuB;wBAChD,oBAAoB,EAAE,oBAAoB;wBAC1C,gBAAgB,EAAE,gBAAgB;qBACnC;iBACF","sourcesContent":["import { Directive, computed, input } from '@angular/core';\nimport type { Insets } from './events.ts';\nimport { optionalBoolean, optionalNumber } from './transforms.ts';\nimport { ViewBase } from './view-base.ts';\n\n/** RN's `processDecelerationRate`: the named rates, as UIKit and Android define them. */\nconst DECELERATION: Record<string, number> = { normal: 0.998, fast: 0.99 };\n\n/**\n * The native scroll view's own props, as typed inputs, for everything that commits as one:\n * `<scroll-view>` and `<virtual-list>`, as `FlatList` takes every `ScrollView` prop.\n *\n * Only the props that mean the same on both are here. `horizontal`, `contentOffset`,\n * `maintainVisibleContentPosition`, `nestedScrollEnabled` and the scroll event throttle each\n * mean something more to a windowed list, which declares its own.\n */\n@Directive({\n host: {\n '[scrollEnabled]': 'scrollEnabled()',\n '[showsHorizontalScrollIndicator]': 'showsHorizontalScrollIndicator()',\n '[showsVerticalScrollIndicator]': 'showsVerticalScrollIndicator()',\n '[pagingEnabled]': 'pagingEnabled()',\n '[decelerationRate]': 'resolvedDecelerationRate()',\n '[snapToInterval]': 'snapToInterval()',\n '[snapToOffsets]': 'snapToOffsets()',\n '[snapToAlignment]': 'snapToAlignment()',\n '[snapToStart]': 'snapToStart()',\n '[snapToEnd]': 'snapToEnd()',\n '[disableIntervalMomentum]': 'disableIntervalMomentum()',\n '[sendMomentumEvents]': 'true',\n '[contentInset]': 'contentInset()',\n '[scrollIndicatorInsets]': 'scrollIndicatorInsets()',\n '[bounces]': 'bounces()',\n '[alwaysBounceHorizontal]': 'resolvedAlwaysBounceHorizontal()',\n '[alwaysBounceVertical]': 'resolvedAlwaysBounceVertical()',\n '[bouncesZoom]': 'bouncesZoom()',\n '[directionalLockEnabled]': 'directionalLockEnabled()',\n '[canCancelContentTouches]': 'canCancelContentTouches()',\n '[centerContent]': 'centerContent()',\n '[automaticallyAdjustContentInsets]': 'automaticallyAdjustContentInsets()',\n '[automaticallyAdjustKeyboardInsets]': 'automaticallyAdjustKeyboardInsets()',\n '[automaticallyAdjustsScrollIndicatorInsets]': 'automaticallyAdjustsScrollIndicatorInsets()',\n '[contentInsetAdjustmentBehavior]': 'contentInsetAdjustmentBehavior()',\n '[pinchGestureEnabled]': 'pinchGestureEnabled()',\n '[maximumZoomScale]': 'maximumZoomScale()',\n '[minimumZoomScale]': 'minimumZoomScale()',\n '[zoomScale]': 'zoomScale()',\n '[indicatorStyle]': 'indicatorStyle()',\n '[scrollsToTop]': 'scrollsToTop()',\n '[scrollToOverflowEnabled]': 'scrollToOverflowEnabled()',\n '[keyboardDismissMode]': 'keyboardDismissMode()',\n '[overScrollMode]': 'overScrollMode()',\n '[persistentScrollbar]': 'persistentScrollbar()',\n '[fadingEdgeLength]': 'fadingEdgeLength()',\n '[endFillColor]': 'endFillColor()',\n },\n})\nexport abstract class ScrollViewProps extends ViewBase {\n /** Whether the content scrolls along x, which decides the axis the defaults bounce on. */\n abstract readonly horizontal: () => boolean | undefined;\n\n /** Set to false to freeze the scroll position. */\n readonly scrollEnabled = input(undefined, { transform: optionalBoolean });\n readonly showsHorizontalScrollIndicator = input(undefined, { transform: optionalBoolean });\n readonly showsVerticalScrollIndicator = input(undefined, { transform: optionalBoolean });\n /** Stop at multiples of the scroll view's own size. */\n readonly pagingEnabled = input(undefined, { transform: optionalBoolean });\n /** How quickly a fling slows: `normal`, `fast`, or a factor below 1. */\n readonly decelerationRate = input<'normal' | 'fast' | number>();\n /** Stop at multiples of this many points. */\n readonly snapToInterval = input(undefined, { transform: optionalNumber });\n /** Stop only at these offsets. */\n readonly snapToOffsets = input<readonly number[]>();\n /** Where a snap point sits in the viewport. */\n readonly snapToAlignment = input<'start' | 'center' | 'end'>();\n /** Whether the start of the content is a snap point. Defaults to true. */\n readonly snapToStart = input(undefined, { transform: optionalBoolean });\n /** Whether the end of the content is a snap point. Defaults to true. */\n readonly snapToEnd = input(undefined, { transform: optionalBoolean });\n /** With snapping, stop at the next snap point rather than flinging past several. */\n readonly disableIntervalMomentum = input(undefined, { transform: optionalBoolean });\n /** Milliseconds between `(scroll)` events; 16 or less means every frame. */\n readonly scrollEventThrottle = input(undefined, { transform: optionalNumber });\n /** iOS: padding inside the scroll view that the content can scroll into. */\n readonly contentInset = input<Insets>();\n /** iOS: insets for the scroll indicators. */\n readonly scrollIndicatorInsets = input<Insets>();\n /** iOS: rubber-band at the ends. Defaults to true. */\n readonly bounces = input(undefined, { transform: optionalBoolean });\n /** iOS: bounce sideways even when the content fits. */\n readonly alwaysBounceHorizontal = input(undefined, { transform: optionalBoolean });\n /** iOS: bounce vertically even when the content fits. */\n readonly alwaysBounceVertical = input(undefined, { transform: optionalBoolean });\n // Match React Native ScrollView's axis defaults. Passing neither prop through leaves UIKit's\n // false default in place, which makes short vertical pages feel fixed instead of rubber-banding.\n protected readonly resolvedAlwaysBounceHorizontal = computed(\n () => this.alwaysBounceHorizontal() ?? !!this.horizontal(),\n );\n protected readonly resolvedAlwaysBounceVertical = computed(\n () => this.alwaysBounceVertical() ?? !this.horizontal(),\n );\n /** iOS: rubber-band past the zoom limits. */\n readonly bouncesZoom = input(undefined, { transform: optionalBoolean });\n /** iOS: once a drag starts on one axis, ignore the other. */\n readonly directionalLockEnabled = input(undefined, { transform: optionalBoolean });\n /** iOS: whether a drag that started on a child can become a scroll. Defaults to true. */\n readonly canCancelContentTouches = input(undefined, { transform: optionalBoolean });\n /** iOS: centre content smaller than the viewport. */\n readonly centerContent = input(undefined, { transform: optionalBoolean });\n /** iOS: adjust the insets for the navigation bar and status bar automatically. */\n readonly automaticallyAdjustContentInsets = input(undefined, { transform: optionalBoolean });\n /** iOS: add a bottom inset while the keyboard is up. */\n readonly automaticallyAdjustKeyboardInsets = input(undefined, { transform: optionalBoolean });\n /** iOS: keep the indicator insets in step with the content insets. Defaults to true. */\n readonly automaticallyAdjustsScrollIndicatorInsets = input(undefined, {\n transform: optionalBoolean,\n });\n /** iOS: how the safe area affects the content insets. */\n readonly contentInsetAdjustmentBehavior = input<\n 'automatic' | 'scrollableAxes' | 'never' | 'always'\n >();\n /** iOS: allow pinch-to-zoom. Defaults to true. */\n readonly pinchGestureEnabled = input(undefined, { transform: optionalBoolean });\n readonly maximumZoomScale = input(undefined, { transform: optionalNumber });\n readonly minimumZoomScale = input(undefined, { transform: optionalNumber });\n readonly zoomScale = input(undefined, { transform: optionalNumber });\n /** iOS: the scroll indicator's colour. */\n readonly indicatorStyle = input<'default' | 'black' | 'white'>();\n /** iOS: tapping the status bar scrolls to the top. Defaults to true. */\n readonly scrollsToTop = input(undefined, { transform: optionalBoolean });\n /** iOS: allow scrolling past the content programmatically. */\n readonly scrollToOverflowEnabled = input(undefined, { transform: optionalBoolean });\n /** Dismiss the keyboard when a drag starts, or interactively as the drag moves. */\n readonly keyboardDismissMode = input<'none' | 'on-drag' | 'interactive'>();\n /** Android: the over-scroll glow. */\n readonly overScrollMode = input<'auto' | 'always' | 'never'>();\n /** Android: keep the scrollbar visible. */\n readonly persistentScrollbar = input(undefined, { transform: optionalBoolean });\n /** Android: fade the content at the edges over this many points. */\n readonly fadingEdgeLength = input(undefined, { transform: optionalNumber });\n /** Android: the colour drawn past the end of short content. */\n readonly endFillColor = input<string>();\n\n protected readonly resolvedDecelerationRate = computed(() => {\n const rate = this.decelerationRate();\n return typeof rate === 'string' ? DECELERATION[rate] : rate;\n });\n}\n"]}
1
+ {"version":3,"file":"scroll-view-props.js","sourceRoot":"","sources":["../src/scroll-view-props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAG/E,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,iBAAiB,GAGlB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAO1C,mGAAmG;AACnG,SAAS,aAAa,CACpB,IAA8B,EAC9B,EAA4B;IAE5B,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACzB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IACzB,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IAClE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AAChC,CAAC;AAED,yFAAyF;AACzF,MAAM,YAAY,GAA2B,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAE3E;;;;;;;GAOG;AA0CH,MAAM,OAAgB,eAAgB,SAAQ,QAAQ;IAIpD,kDAAkD;IACzC,aAAa,GAAG,KAAK,CAAC,SAAS,qFAAI,SAAS,E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ef, Directive, computed, inject, input } from '@angular/core';\nimport type { NativeSyntheticEvent } from '@ng-native/fabric';\nimport type { Insets } from './events.ts';\nimport {\n INTERACTION_OBSERVERS,\n SWIPE_VELOCITY,\n describeElement,\n notifyInteraction,\n type InteractionDirection,\n type InteractionObserver,\n} from './interaction-observer.ts';\nimport { optionalBoolean, optionalNumber } from './transforms.ts';\nimport { ViewBase } from './view-base.ts';\n\ntype DragEvent = NativeSyntheticEvent<{\n contentOffset?: { x: number; y: number };\n velocity?: { x: number; y: number };\n}>;\n\n/** Which way the content moved, by the axis it moved further along, or null if it did not move. */\nfunction dragDirection(\n from: { x: number; y: number },\n to: { x: number; y: number },\n): InteractionDirection | null {\n const dx = to.x - from.x;\n const dy = to.y - from.y;\n if (dx === 0 && dy === 0) return null;\n if (Math.abs(dx) > Math.abs(dy)) return dx > 0 ? 'right' : 'left';\n return dy > 0 ? 'down' : 'up';\n}\n\n/** RN's `processDecelerationRate`: the named rates, as UIKit and Android define them. */\nconst DECELERATION: Record<string, number> = { normal: 0.998, fast: 0.99 };\n\n/**\n * The native scroll view's own props, as typed inputs, for everything that commits as one:\n * `<scroll-view>` and `<virtual-list>`, as `FlatList` takes every `ScrollView` prop.\n *\n * Only the props that mean the same on both are here. `horizontal`, `contentOffset`,\n * `maintainVisibleContentPosition`, `nestedScrollEnabled` and the scroll event throttle each\n * mean something more to a windowed list, which declares its own.\n */\n@Directive({\n host: {\n '[scrollEnabled]': 'scrollEnabled()',\n '[showsHorizontalScrollIndicator]': 'showsHorizontalScrollIndicator()',\n '[showsVerticalScrollIndicator]': 'showsVerticalScrollIndicator()',\n '[pagingEnabled]': 'pagingEnabled()',\n '[decelerationRate]': 'resolvedDecelerationRate()',\n '[snapToInterval]': 'snapToInterval()',\n '[snapToOffsets]': 'snapToOffsets()',\n '[snapToAlignment]': 'snapToAlignment()',\n '[snapToStart]': 'snapToStart()',\n '[snapToEnd]': 'snapToEnd()',\n '[disableIntervalMomentum]': 'disableIntervalMomentum()',\n '[sendMomentumEvents]': 'true',\n '[contentInset]': 'contentInset()',\n '[scrollIndicatorInsets]': 'scrollIndicatorInsets()',\n '[bounces]': 'bounces()',\n '[alwaysBounceHorizontal]': 'resolvedAlwaysBounceHorizontal()',\n '[alwaysBounceVertical]': 'resolvedAlwaysBounceVertical()',\n '[bouncesZoom]': 'bouncesZoom()',\n '[directionalLockEnabled]': 'directionalLockEnabled()',\n '[canCancelContentTouches]': 'canCancelContentTouches()',\n '[centerContent]': 'centerContent()',\n '[automaticallyAdjustContentInsets]': 'automaticallyAdjustContentInsets()',\n '[automaticallyAdjustKeyboardInsets]': 'automaticallyAdjustKeyboardInsets()',\n '[automaticallyAdjustsScrollIndicatorInsets]': 'automaticallyAdjustsScrollIndicatorInsets()',\n '[contentInsetAdjustmentBehavior]': 'contentInsetAdjustmentBehavior()',\n '[pinchGestureEnabled]': 'pinchGestureEnabled()',\n '[maximumZoomScale]': 'maximumZoomScale()',\n '[minimumZoomScale]': 'minimumZoomScale()',\n '[zoomScale]': 'zoomScale()',\n '[indicatorStyle]': 'indicatorStyle()',\n '[scrollsToTop]': 'scrollsToTop()',\n '[scrollToOverflowEnabled]': 'scrollToOverflowEnabled()',\n '[keyboardDismissMode]': 'keyboardDismissMode()',\n '[overScrollMode]': 'overScrollMode()',\n '[persistentScrollbar]': 'persistentScrollbar()',\n '[fadingEdgeLength]': 'fadingEdgeLength()',\n '[endFillColor]': 'endFillColor()',\n },\n})\nexport abstract class ScrollViewProps extends ViewBase {\n /** Whether the content scrolls along x, which decides the axis the defaults bounce on. */\n abstract readonly horizontal: () => boolean | undefined;\n\n /** Set to false to freeze the scroll position. */\n readonly scrollEnabled = input(undefined, { transform: optionalBoolean });\n readonly showsHorizontalScrollIndicator = input(undefined, { transform: optionalBoolean });\n readonly showsVerticalScrollIndicator = input(undefined, { transform: optionalBoolean });\n /** Stop at multiples of the scroll view's own size. */\n readonly pagingEnabled = input(undefined, { transform: optionalBoolean });\n /** How quickly a fling slows: `normal`, `fast`, or a factor below 1. */\n readonly decelerationRate = input<'normal' | 'fast' | number>();\n /** Stop at multiples of this many points. */\n readonly snapToInterval = input(undefined, { transform: optionalNumber });\n /** Stop only at these offsets. */\n readonly snapToOffsets = input<readonly number[]>();\n /** Where a snap point sits in the viewport. */\n readonly snapToAlignment = input<'start' | 'center' | 'end'>();\n /** Whether the start of the content is a snap point. Defaults to true. */\n readonly snapToStart = input(undefined, { transform: optionalBoolean });\n /** Whether the end of the content is a snap point. Defaults to true. */\n readonly snapToEnd = input(undefined, { transform: optionalBoolean });\n /** With snapping, stop at the next snap point rather than flinging past several. */\n readonly disableIntervalMomentum = input(undefined, { transform: optionalBoolean });\n /** Milliseconds between `(scroll)` events; 16 or less means every frame. */\n readonly scrollEventThrottle = input(undefined, { transform: optionalNumber });\n /** iOS: padding inside the scroll view that the content can scroll into. */\n readonly contentInset = input<Insets>();\n /** iOS: insets for the scroll indicators. */\n readonly scrollIndicatorInsets = input<Insets>();\n /** iOS: rubber-band at the ends. Defaults to true. */\n readonly bounces = input(undefined, { transform: optionalBoolean });\n /** iOS: bounce sideways even when the content fits. */\n readonly alwaysBounceHorizontal = input(undefined, { transform: optionalBoolean });\n /** iOS: bounce vertically even when the content fits. */\n readonly alwaysBounceVertical = input(undefined, { transform: optionalBoolean });\n // Match React Native ScrollView's axis defaults. Passing neither prop through leaves UIKit's\n // false default in place, which makes short vertical pages feel fixed instead of rubber-banding.\n protected readonly resolvedAlwaysBounceHorizontal = computed(\n () => this.alwaysBounceHorizontal() ?? !!this.horizontal(),\n );\n protected readonly resolvedAlwaysBounceVertical = computed(\n () => this.alwaysBounceVertical() ?? !this.horizontal(),\n );\n /** iOS: rubber-band past the zoom limits. */\n readonly bouncesZoom = input(undefined, { transform: optionalBoolean });\n /** iOS: once a drag starts on one axis, ignore the other. */\n readonly directionalLockEnabled = input(undefined, { transform: optionalBoolean });\n /** iOS: whether a drag that started on a child can become a scroll. Defaults to true. */\n readonly canCancelContentTouches = input(undefined, { transform: optionalBoolean });\n /** iOS: centre content smaller than the viewport. */\n readonly centerContent = input(undefined, { transform: optionalBoolean });\n /** iOS: adjust the insets for the navigation bar and status bar automatically. */\n readonly automaticallyAdjustContentInsets = input(undefined, { transform: optionalBoolean });\n /** iOS: add a bottom inset while the keyboard is up. */\n readonly automaticallyAdjustKeyboardInsets = input(undefined, { transform: optionalBoolean });\n /** iOS: keep the indicator insets in step with the content insets. Defaults to true. */\n readonly automaticallyAdjustsScrollIndicatorInsets = input(undefined, {\n transform: optionalBoolean,\n });\n /** iOS: how the safe area affects the content insets. */\n readonly contentInsetAdjustmentBehavior = input<\n 'automatic' | 'scrollableAxes' | 'never' | 'always'\n >();\n /** iOS: allow pinch-to-zoom. Defaults to true. */\n readonly pinchGestureEnabled = input(undefined, { transform: optionalBoolean });\n readonly maximumZoomScale = input(undefined, { transform: optionalNumber });\n readonly minimumZoomScale = input(undefined, { transform: optionalNumber });\n readonly zoomScale = input(undefined, { transform: optionalNumber });\n /** iOS: the scroll indicator's colour. */\n readonly indicatorStyle = input<'default' | 'black' | 'white'>();\n /** iOS: tapping the status bar scrolls to the top. Defaults to true. */\n readonly scrollsToTop = input(undefined, { transform: optionalBoolean });\n /** iOS: allow scrolling past the content programmatically. */\n readonly scrollToOverflowEnabled = input(undefined, { transform: optionalBoolean });\n /** Dismiss the keyboard when a drag starts, or interactively as the drag moves. */\n readonly keyboardDismissMode = input<'none' | 'on-drag' | 'interactive'>();\n /** Android: the over-scroll glow. */\n readonly overScrollMode = input<'auto' | 'always' | 'never'>();\n /** Android: keep the scrollbar visible. */\n readonly persistentScrollbar = input(undefined, { transform: optionalBoolean });\n /** Android: fade the content at the edges over this many points. */\n readonly fadingEdgeLength = input(undefined, { transform: optionalNumber });\n /** Android: the colour drawn past the end of short content. */\n readonly endFillColor = input<string>();\n\n protected readonly resolvedDecelerationRate = computed(() => {\n const rate = this.decelerationRate();\n return typeof rate === 'string' ? DECELERATION[rate] : rate;\n });\n\n constructor() {\n super();\n // Scroll views are few, so unlike a press this looks once, and listens only for an app that\n // asked.\n const observers = inject(INTERACTION_OBSERVERS, { optional: true });\n if (observers?.length) this.reportDrags(observers);\n }\n\n /**\n * One `scroll` or `swipe` per drag the user makes, as the finger lifts. A scroll made by code,\n * `scrollTo` or a tap on the status bar, has no drag, so reports nothing.\n */\n private reportDrags(observers: readonly InteractionObserver[]): void {\n let start: { x: number; y: number } | null = null;\n const begin = this.engine.setEventListener(this.node, 'topScrollBeginDrag', (event) => {\n start = (event as DragEvent).nativeEvent?.contentOffset ?? null;\n });\n const end = this.engine.setEventListener(this.node, 'topScrollEndDrag', (event) => {\n const { contentOffset, velocity } = (event as DragEvent).nativeEvent ?? {};\n const from = start;\n start = null;\n if (!from || !contentOffset) return;\n const direction = dragDirection(from, contentOffset);\n if (!direction) return;\n const speed = velocity ? Math.hypot(velocity.x, velocity.y) : 0;\n notifyInteraction(observers, {\n type: speed >= SWIPE_VELOCITY ? 'swipe' : 'scroll',\n ...describeElement(this.engine, this.node),\n direction,\n source: 'touch',\n timestamp: Date.now(),\n });\n });\n inject(DestroyRef).onDestroy(() => {\n begin();\n end();\n });\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { Component, Directive, TemplateRef, computed, contentChild, inject, input, output, viewChild, } from '@angular/core';
2
- import { nativePlatform } from '@ng-native/fabric';
2
+ import { isApplePlatform } from '@ng-native/fabric';
3
3
  import { TemplateSlot } from "./template-slot.js";
4
4
  import { numberOr, optionalBoolean } from "./transforms.js";
5
5
  import { View } from "./view.js";
@@ -188,7 +188,7 @@ export class SectionList {
188
188
  cell = { flex: 1 };
189
189
  rows = computed(() => flattenSections(this.sections()), /* @ts-ignore */
190
190
  ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
191
- sticky = computed(() => this.stickySectionHeadersEnabled() ?? nativePlatform() === 'ios', /* @ts-ignore */
191
+ sticky = computed(() => this.stickySectionHeadersEnabled() ?? isApplePlatform(), /* @ts-ignore */
192
192
  ...(ngDevMode ? [{ debugName: "sticky" }] : /* istanbul ignore next */ []));
193
193
  /** The header rows, pinned in turn, when headers stick and there is a header to draw. */
194
194
  stickyRows = computed(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"section-list.js","sourceRoot":"","sources":["../src/section-list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;;AA8CzE,6EAA6E;AAE7E,MAAM,OAAO,aAAa;IACf,QAAQ,GAAG,MAAM,CAAiC,WAAW,CAAC,CAAC;IAExE,MAAM,CAAC,sBAAsB,CAC3B,UAA4B,EAC5B,OAAgB;QAEhB,OAAO,IAAI,CAAC;IACd,CAAC;uGARU,aAAa;2FAAb,aAAa;;2FAAb,aAAa;kBADzB,SAAS;mBAAC,EAAE,QAAQ,EAAE,4BAA4B,EAAE;;AAYrD,6EAA6E;AAE7E,MAAM,OAAO,aAAa;IACf,QAAQ,GAAG,MAAM,CAAiC,WAAW,CAAC,CAAC;IAExE,MAAM,CAAC,sBAAsB,CAC3B,UAA4B,EAC5B,OAAgB;QAEhB,OAAO,IAAI,CAAC;IACd,CAAC;uGARU,aAAa;2FAAb,aAAa;;2FAAb,aAAa;kBADzB,SAAS;mBAAC,EAAE,QAAQ,EAAE,4BAA4B,EAAE;;AAYrD,iFAAiF;AAEjF,MAAM,OAAO,WAAW;IACb,QAAQ,GAAG,MAAM,CAAwC,WAAW,CAAC,CAAC;I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C;oBACT,QAAQ,EAAE,cAAc;oBACxB,QAAQ,EAAE,aAAa;oBACvB,OAAO,EAAE,CAAC,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC;oBAC1C,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiET;iBACF;4oCAmB4D,aAAa,wFACb,aAAa,sFACd,WAAW,2FACD,gBAAgB,sFACjB,oBAAoB,+DACb,MAAM","sourcesContent":["import {\n Component,\n Directive,\n TemplateRef,\n computed,\n contentChild,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { nativePlatform } from '@ng-native/fabric';\nimport { TemplateSlot } from './template-slot.ts';\nimport { numberOr, optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport type { KeyboardShouldPersistTaps } from './keyboard-taps.ts';\nimport { VirtualList, type VirtualListPadding } from './virtual-list.ts';\n\n/** A section as RN's SectionList takes it: its rows in `data`, plus whatever else it carries. */\nexport interface SectionListSection<T> {\n readonly key?: string;\n readonly title?: string;\n readonly data: readonly T[];\n}\n\n/** What a section header or footer template is given. */\nexport interface SectionContext<S> {\n readonly $implicit: S;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What an item template is given. `index` counts within the section, as `renderItem` does. */\nexport interface SectionItemContext<T, S> {\n readonly $implicit: T;\n readonly item: T;\n readonly index: number;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What a separator template is given: the items either side of it, in the same section. */\nexport interface SectionSeparatorContext<T, S> {\n readonly $implicit: T;\n readonly leadingItem: T;\n readonly trailingItem: T;\n readonly section: S;\n}\n\n/**\n * What a section separator template is given: the section, and what is either side of the edge\n * it sits at. At a section's start `leadingItem` is undefined, and at its end `trailingItem` is.\n */\nexport interface SectionEdgeSeparatorContext<T, S> {\n readonly $implicit: S;\n readonly section: S;\n readonly leadingItem: T | undefined;\n readonly leadingSection: S | undefined;\n readonly trailingItem: T | undefined;\n readonly trailingSection: S | undefined;\n}\n\n/** `<ng-template sectionHeader let-section>`: RN's `renderSectionHeader`. */\n@Directive({ selector: 'ng-template[sectionHeader]' })\nexport class SectionHeader<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionHeader<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionFooter let-section>`: RN's `renderSectionFooter`. */\n@Directive({ selector: 'ng-template[sectionFooter]' })\nexport class SectionFooter<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionFooter<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionItem let-item let-index=\"index\">`: RN's `renderItem`. */\n@Directive({ selector: 'ng-template[sectionItem]' })\nexport class SectionItem<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionItemContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionItem<T, S>,\n context: unknown,\n ): context is SectionItemContext<T, S> {\n return true;\n }\n}\n\n/** `<ng-template sectionSeparator let-leading>`: RN's `ItemSeparatorComponent`. */\n@Directive({ selector: 'ng-template[sectionSeparator]' })\nexport class SectionSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionSeparator<T, S>,\n context: unknown,\n ): context is SectionSeparatorContext<T, S> {\n return true;\n }\n}\n\n/**\n * `<ng-template sectionEdgeSeparator let-section>`: RN's `SectionSeparatorComponent`, drawn at\n * both edges of a section that has items, between its header and first item and between its\n * last item and footer.\n */\n@Directive({ selector: 'ng-template[sectionEdgeSeparator]' })\nexport class SectionEdgeSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionEdgeSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionEdgeSeparator<T, S>,\n context: unknown,\n ): context is SectionEdgeSeparatorContext<T, S> {\n return true;\n }\n}\n\n/** One row of the flattened list. */\nexport type SectionRow<T, S> =\n | {\n readonly kind: 'header' | 'footer';\n readonly context: SectionContext<S>;\n readonly separator: null;\n readonly leading: null;\n readonly trailing: null;\n }\n | {\n readonly kind: 'item';\n readonly context: SectionItemContext<T, S>;\n /** Null for a section's last item, where the section separator takes its place, as in RN. */\n readonly separator: SectionSeparatorContext<T, S> | null;\n /** The section separator before a section's first item, and null on every other. */\n readonly leading: SectionEdgeSeparatorContext<T, S> | null;\n /** The section separator after a section's last item, and null on every other. */\n readonly trailing: SectionEdgeSeparatorContext<T, S> | null;\n };\n\n/**\n * Flatten sections into the rows RN's `VirtualizedSectionList` gives its list: for each section a\n * header, its items, then a footer. The header and footer rows are there whether or not anything\n * is drawn in them, as in RN, which is what keeps `scrollToLocation`'s arithmetic the same.\n *\n * The section separators ride on the first and last item, as RN's do: `SectionSeparatorComponent`\n * is the first item's leading separator and the last item's trailing one, so an empty section has\n * none, and a last item has it in place of the item separator.\n */\nexport function flattenSections<T, S extends SectionListSection<T>>(\n sections: readonly S[],\n): SectionRow<T, S>[] {\n const rows: SectionRow<T, S>[] = [];\n const edges = { leading: null, trailing: null };\n sections.forEach((section, sectionIndex) => {\n const context = { $implicit: section, section, sectionIndex };\n rows.push({ kind: 'header', context, separator: null, ...edges });\n const data = section.data;\n const last = data.length - 1;\n const around = {\n $implicit: section,\n section,\n leadingSection: sections[sectionIndex - 1],\n trailingSection: sections[sectionIndex + 1],\n };\n data.forEach((item, index) => {\n const trailingItem = data[index + 1];\n rows.push({\n kind: 'item',\n context: { $implicit: item, item, index, section, sectionIndex },\n separator:\n index < last\n ? { $implicit: item, leadingItem: item, trailingItem: trailingItem!, section }\n : null,\n leading: index === 0 ? { ...around, leadingItem: undefined, trailingItem: item } : null,\n trailing: index === last ? { ...around, leadingItem: item, trailingItem: undefined } : null,\n });\n });\n rows.push({ kind: 'footer', context, separator: null, ...edges });\n });\n return rows;\n}\n\ntype Height<A extends unknown[]> = number | ((...args: A) => number);\n\nconst measure = <A extends unknown[]>(height: Height<A>, ...args: A): number =>\n typeof height === 'number' ? height : height(...args);\n\n/**\n * RN's SectionList: sections of items, each with a header and footer, over `<virtual-list>`.\n *\n * RN's own is a VirtualizedList over flattened rows, and so is this. Sections become one list of\n * header, item and footer rows, the rows are placed by `<virtual-list>`'s variable-height windowing,\n * and this component draws each from the caller's templates:\n *\n * ```html\n * <section-list [sections]=\"sections\" [itemHeight]=\"44\" [sectionHeaderHeight]=\"28\">\n * <ng-template sectionHeader let-section><text>{{ section.title }}</text></ng-template>\n * <ng-template sectionItem let-item><text>{{ item }}</text></ng-template>\n * <ng-template sectionSeparator><view [style]=\"line\"></view></ng-template>\n * <ng-template sectionEdgeSeparator><view [style]=\"rule\"></view></ng-template>\n * </section-list>\n * ```\n *\n * Rows are fixed height, as `getItemLayout` makes them in RN: `itemHeight`, `sectionHeaderHeight`\n * and `sectionFooterHeight` are numbers or functions. An item's height includes its separators,\n * which are drawn in the item's slot: the item separator at its bottom, only between items of the\n * same section, and the section separator at the top of a section's first item and the bottom of\n * its last, as RN's `SectionSeparatorComponent` is.\n *\n * `stickySectionHeadersEnabled` pins the current section's header until the next pushes it off.\n * It defaults to on for iOS and off for Android, as RN's does. `listHeader` and `listFooter`\n * content and a `<refresh-control>` pass through to the list.\n *\n * `contentPadding` and `keyboardShouldPersistTaps` pass through to the list as `<virtual-list>`\n * takes them.\n *\n * ponytail: no `horizontal` or `inverted`, no viewability events, and no `highlighted` on a\n * separator. No `keyExtractor` or `maintainVisibleContentPosition` either: rows are fixed height,\n * so there is no measured height for a key to carry across an insert. The host is a plain view\n * with the list filling it, where RN's host is the scroll view, so scroll-view props are not\n * taken.\n */\n@Component({\n selector: 'section-list',\n exportAs: 'sectionList',\n imports: [TemplateSlot, View, VirtualList],\n template: `\n <virtual-list\n #list\n [items]=\"rows()\"\n [itemHeight]=\"rowHeight\"\n [stickyIndices]=\"stickyRows()\"\n [overscan]=\"overscan()\"\n [endReachedThreshold]=\"endReachedThreshold()\"\n [contentPadding]=\"contentPadding()\"\n [keyboardShouldPersistTaps]=\"keyboardShouldPersistTaps()\"\n [style]=\"fill\"\n (endReached)=\"endReached.emit($event)\"\n >\n <ng-content select=\"refresh-control\" ngProjectAs=\"refresh-control\" />\n <view listHeader><ng-content select=\"[listHeader]\" /></view>\n <ng-content />\n @for (row of list.window(); track row.index) {\n <view [style]=\"row.style\">\n @switch (row.item.kind) {\n @case ('header') {\n @if (header(); as header) {\n <ng-container\n [templateSlot]=\"header.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('footer') {\n @if (footer(); as footer) {\n <ng-container\n [templateSlot]=\"footer.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('item') {\n @if (row.item.leading; as start) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"start\" />\n }\n }\n <view [style]=\"cell\">\n @if (item(); as item) {\n <ng-container\n [templateSlot]=\"item.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n </view>\n @if (separator(); as separator) {\n @if (row.item.separator; as gap) {\n <ng-container [templateSlot]=\"separator.template\" [templateSlotContext]=\"gap\" />\n }\n }\n @if (row.item.trailing; as end) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"end\" />\n }\n }\n }\n }\n </view>\n }\n <view listFooter><ng-content select=\"[listFooter]\" /></view>\n </virtual-list>\n `,\n})\nexport class SectionList<T, S extends SectionListSection<T> = SectionListSection<T>> {\n readonly sections = input.required<readonly S[]>();\n /** Each item's height, including every separator drawn in its slot. */\n readonly itemHeight = input.required<Height<[item: T, index: number, section: S]>>();\n readonly sectionHeaderHeight = input<Height<[section: S]>>(0);\n readonly sectionFooterHeight = input<Height<[section: S]>>(0);\n /** Pin the current section's header. Defaults to true on iOS and false on Android, as RN. */\n readonly stickySectionHeadersEnabled = input(undefined, { transform: optionalBoolean });\n readonly overscan = input(4, { transform: numberOr(4) });\n readonly endReachedThreshold = input(2, { transform: numberOr(2) });\n /** Space around the rows, inside the scrolling content. See `<virtual-list>`. */\n readonly contentPadding = input<VirtualListPadding>(0);\n /** What a tap in the list does while a text input has the keyboard up. See `ScrollView`. */\n readonly keyboardShouldPersistTaps = input<KeyboardShouldPersistTaps>('never');\n\n /** The end of the last section is within `endReachedThreshold`. See `<virtual-list>`. */\n readonly endReached = output<{ distanceFromEnd: number }>();\n\n protected readonly header = contentChild<SectionHeader<S>>(SectionHeader);\n protected readonly footer = contentChild<SectionFooter<S>>(SectionFooter);\n protected readonly item = contentChild<SectionItem<T, S>>(SectionItem);\n protected readonly separator = contentChild<SectionSeparator<T, S>>(SectionSeparator);\n protected readonly edge = contentChild<SectionEdgeSeparator<T, S>>(SectionEdgeSeparator);\n private readonly list = viewChild.required<VirtualList<SectionRow<T, S>>>('list');\n\n protected readonly fill = { flex: 1 };\n /** The item fills its slot between its separators, as RN's cell draws them around it. */\n protected readonly cell = { flex: 1 };\n\n protected readonly rows = computed(() => flattenSections<T, S>(this.sections()));\n\n private readonly sticky = computed(\n () => this.stickySectionHeadersEnabled() ?? nativePlatform() === 'ios',\n );\n\n /** The header rows, pinned in turn, when headers stick and there is a header to draw. */\n protected readonly stickyRows = computed(() => {\n if (!this.sticky() || !this.header()) return [];\n const indices: number[] = [];\n this.rows().forEach((row, index) => {\n if (row.kind === 'header') indices.push(index);\n });\n return indices;\n });\n\n protected readonly rowHeight = (row: SectionRow<T, S>): number => {\n const { section } = row.context;\n if (row.kind === 'item') {\n return measure(this.itemHeight(), row.context.item, row.context.index, section);\n }\n return row.kind === 'header'\n ? measure(this.sectionHeaderHeight(), section)\n : measure(this.sectionFooterHeight(), section);\n };\n\n /**\n * Scroll to an item, RN's way: `itemIndex` 0 is the section's header and 1 its first item, and\n * with sticky headers the header's height is allowed for so the item is not hidden under it.\n */\n scrollToLocation(options: {\n sectionIndex: number;\n itemIndex: number;\n viewOffset?: number;\n animated?: boolean;\n }): void {\n const sections = this.sections();\n let index = options.itemIndex;\n for (let i = 0; i < options.sectionIndex; i++) index += sections[i]!.data.length + 2;\n let viewOffset = options.viewOffset ?? 0;\n const section = sections[options.sectionIndex];\n if (options.itemIndex > 0 && this.sticky() && section) {\n viewOffset += measure(this.sectionHeaderHeight(), section);\n }\n this.list().scrollToIndex({ index, viewOffset, animated: options.animated });\n }\n}\n"]}
1
+ {"version":3,"file":"section-list.js","sourceRoot":"","sources":["../src/section-list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;;AA8CzE,6EAA6E;AAE7E,MAAM,OAAO,aAAa;IACf,QAAQ,GAAG,MAAM,CAAiC,WAAW,CAAC,CAAC;IAExE,MAAM,CAAC,sBAAsB,CAC3B,UAA4B,EAC5B,OAAgB;QAEhB,OAAO,IAAI,CAAC;IACd,CAAC;uGARU,aAAa;2FAAb,aAAa;;2FAAb,aAAa;kBADzB,SAAS;mBAAC,EAAE,QAAQ,EAAE,4BAA4B,EAAE;;AAYrD,6EAA6E;AAE7E,MAAM,OAAO,aAAa;IACf,QAAQ,GAAG,MAAM,CAAiC,WAAW,CAAC,CAAC;IAExE,MAAM,CAAC,sBAAsB,CAC3B,UAA4B,EAC5B,OAAgB;QAEh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WAAW,4FACD,gBAAgB,uFACjB,oBAAoB,yMAzF7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiET,4DAlES,YAAY,4GAAE,IAAI,iDAAE,WAAW;;2FAoE9B,WAAW;kBAvEvB,SAAS;mBAAC;oBACT,QAAQ,EAAE,cAAc;oBACxB,QAAQ,EAAE,aAAa;oBACvB,OAAO,EAAE,CAAC,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC;oBAC1C,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiET;iBACF;4oCAmB4D,aAAa,wFACb,aAAa,sFACd,WAAW,2FACD,gBAAgB,sFACjB,oBAAoB,+DACb,MAAM","sourcesContent":["import {\n Component,\n Directive,\n TemplateRef,\n computed,\n contentChild,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { isApplePlatform } from '@ng-native/fabric';\nimport { TemplateSlot } from './template-slot.ts';\nimport { numberOr, optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport type { KeyboardShouldPersistTaps } from './keyboard-taps.ts';\nimport { VirtualList, type VirtualListPadding } from './virtual-list.ts';\n\n/** A section as RN's SectionList takes it: its rows in `data`, plus whatever else it carries. */\nexport interface SectionListSection<T> {\n readonly key?: string;\n readonly title?: string;\n readonly data: readonly T[];\n}\n\n/** What a section header or footer template is given. */\nexport interface SectionContext<S> {\n readonly $implicit: S;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What an item template is given. `index` counts within the section, as `renderItem` does. */\nexport interface SectionItemContext<T, S> {\n readonly $implicit: T;\n readonly item: T;\n readonly index: number;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What a separator template is given: the items either side of it, in the same section. */\nexport interface SectionSeparatorContext<T, S> {\n readonly $implicit: T;\n readonly leadingItem: T;\n readonly trailingItem: T;\n readonly section: S;\n}\n\n/**\n * What a section separator template is given: the section, and what is either side of the edge\n * it sits at. At a section's start `leadingItem` is undefined, and at its end `trailingItem` is.\n */\nexport interface SectionEdgeSeparatorContext<T, S> {\n readonly $implicit: S;\n readonly section: S;\n readonly leadingItem: T | undefined;\n readonly leadingSection: S | undefined;\n readonly trailingItem: T | undefined;\n readonly trailingSection: S | undefined;\n}\n\n/** `<ng-template sectionHeader let-section>`: RN's `renderSectionHeader`. */\n@Directive({ selector: 'ng-template[sectionHeader]' })\nexport class SectionHeader<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionHeader<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionFooter let-section>`: RN's `renderSectionFooter`. */\n@Directive({ selector: 'ng-template[sectionFooter]' })\nexport class SectionFooter<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionFooter<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionItem let-item let-index=\"index\">`: RN's `renderItem`. */\n@Directive({ selector: 'ng-template[sectionItem]' })\nexport class SectionItem<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionItemContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionItem<T, S>,\n context: unknown,\n ): context is SectionItemContext<T, S> {\n return true;\n }\n}\n\n/** `<ng-template sectionSeparator let-leading>`: RN's `ItemSeparatorComponent`. */\n@Directive({ selector: 'ng-template[sectionSeparator]' })\nexport class SectionSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionSeparator<T, S>,\n context: unknown,\n ): context is SectionSeparatorContext<T, S> {\n return true;\n }\n}\n\n/**\n * `<ng-template sectionEdgeSeparator let-section>`: RN's `SectionSeparatorComponent`, drawn at\n * both edges of a section that has items, between its header and first item and between its\n * last item and footer.\n */\n@Directive({ selector: 'ng-template[sectionEdgeSeparator]' })\nexport class SectionEdgeSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionEdgeSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionEdgeSeparator<T, S>,\n context: unknown,\n ): context is SectionEdgeSeparatorContext<T, S> {\n return true;\n }\n}\n\n/** One row of the flattened list. */\nexport type SectionRow<T, S> =\n | {\n readonly kind: 'header' | 'footer';\n readonly context: SectionContext<S>;\n readonly separator: null;\n readonly leading: null;\n readonly trailing: null;\n }\n | {\n readonly kind: 'item';\n readonly context: SectionItemContext<T, S>;\n /** Null for a section's last item, where the section separator takes its place, as in RN. */\n readonly separator: SectionSeparatorContext<T, S> | null;\n /** The section separator before a section's first item, and null on every other. */\n readonly leading: SectionEdgeSeparatorContext<T, S> | null;\n /** The section separator after a section's last item, and null on every other. */\n readonly trailing: SectionEdgeSeparatorContext<T, S> | null;\n };\n\n/**\n * Flatten sections into the rows RN's `VirtualizedSectionList` gives its list: for each section a\n * header, its items, then a footer. The header and footer rows are there whether or not anything\n * is drawn in them, as in RN, which is what keeps `scrollToLocation`'s arithmetic the same.\n *\n * The section separators ride on the first and last item, as RN's do: `SectionSeparatorComponent`\n * is the first item's leading separator and the last item's trailing one, so an empty section has\n * none, and a last item has it in place of the item separator.\n */\nexport function flattenSections<T, S extends SectionListSection<T>>(\n sections: readonly S[],\n): SectionRow<T, S>[] {\n const rows: SectionRow<T, S>[] = [];\n const edges = { leading: null, trailing: null };\n sections.forEach((section, sectionIndex) => {\n const context = { $implicit: section, section, sectionIndex };\n rows.push({ kind: 'header', context, separator: null, ...edges });\n const data = section.data;\n const last = data.length - 1;\n const around = {\n $implicit: section,\n section,\n leadingSection: sections[sectionIndex - 1],\n trailingSection: sections[sectionIndex + 1],\n };\n data.forEach((item, index) => {\n const trailingItem = data[index + 1];\n rows.push({\n kind: 'item',\n context: { $implicit: item, item, index, section, sectionIndex },\n separator:\n index < last\n ? { $implicit: item, leadingItem: item, trailingItem: trailingItem!, section }\n : null,\n leading: index === 0 ? { ...around, leadingItem: undefined, trailingItem: item } : null,\n trailing: index === last ? { ...around, leadingItem: item, trailingItem: undefined } : null,\n });\n });\n rows.push({ kind: 'footer', context, separator: null, ...edges });\n });\n return rows;\n}\n\ntype Height<A extends unknown[]> = number | ((...args: A) => number);\n\nconst measure = <A extends unknown[]>(height: Height<A>, ...args: A): number =>\n typeof height === 'number' ? height : height(...args);\n\n/**\n * RN's SectionList: sections of items, each with a header and footer, over `<virtual-list>`.\n *\n * RN's own is a VirtualizedList over flattened rows, and so is this. Sections become one list of\n * header, item and footer rows, the rows are placed by `<virtual-list>`'s variable-height windowing,\n * and this component draws each from the caller's templates:\n *\n * ```html\n * <section-list [sections]=\"sections\" [itemHeight]=\"44\" [sectionHeaderHeight]=\"28\">\n * <ng-template sectionHeader let-section><text>{{ section.title }}</text></ng-template>\n * <ng-template sectionItem let-item><text>{{ item }}</text></ng-template>\n * <ng-template sectionSeparator><view [style]=\"line\"></view></ng-template>\n * <ng-template sectionEdgeSeparator><view [style]=\"rule\"></view></ng-template>\n * </section-list>\n * ```\n *\n * Rows are fixed height, as `getItemLayout` makes them in RN: `itemHeight`, `sectionHeaderHeight`\n * and `sectionFooterHeight` are numbers or functions. An item's height includes its separators,\n * which are drawn in the item's slot: the item separator at its bottom, only between items of the\n * same section, and the section separator at the top of a section's first item and the bottom of\n * its last, as RN's `SectionSeparatorComponent` is.\n *\n * `stickySectionHeadersEnabled` pins the current section's header until the next pushes it off.\n * It defaults to on for iOS and off for Android, as RN's does. `listHeader` and `listFooter`\n * content and a `<refresh-control>` pass through to the list.\n *\n * `contentPadding` and `keyboardShouldPersistTaps` pass through to the list as `<virtual-list>`\n * takes them.\n *\n * ponytail: no `horizontal` or `inverted`, no viewability events, and no `highlighted` on a\n * separator. No `keyExtractor` or `maintainVisibleContentPosition` either: rows are fixed height,\n * so there is no measured height for a key to carry across an insert. The host is a plain view\n * with the list filling it, where RN's host is the scroll view, so scroll-view props are not\n * taken.\n */\n@Component({\n selector: 'section-list',\n exportAs: 'sectionList',\n imports: [TemplateSlot, View, VirtualList],\n template: `\n <virtual-list\n #list\n [items]=\"rows()\"\n [itemHeight]=\"rowHeight\"\n [stickyIndices]=\"stickyRows()\"\n [overscan]=\"overscan()\"\n [endReachedThreshold]=\"endReachedThreshold()\"\n [contentPadding]=\"contentPadding()\"\n [keyboardShouldPersistTaps]=\"keyboardShouldPersistTaps()\"\n [style]=\"fill\"\n (endReached)=\"endReached.emit($event)\"\n >\n <ng-content select=\"refresh-control\" ngProjectAs=\"refresh-control\" />\n <view listHeader><ng-content select=\"[listHeader]\" /></view>\n <ng-content />\n @for (row of list.window(); track row.index) {\n <view [style]=\"row.style\">\n @switch (row.item.kind) {\n @case ('header') {\n @if (header(); as header) {\n <ng-container\n [templateSlot]=\"header.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('footer') {\n @if (footer(); as footer) {\n <ng-container\n [templateSlot]=\"footer.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('item') {\n @if (row.item.leading; as start) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"start\" />\n }\n }\n <view [style]=\"cell\">\n @if (item(); as item) {\n <ng-container\n [templateSlot]=\"item.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n </view>\n @if (separator(); as separator) {\n @if (row.item.separator; as gap) {\n <ng-container [templateSlot]=\"separator.template\" [templateSlotContext]=\"gap\" />\n }\n }\n @if (row.item.trailing; as end) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"end\" />\n }\n }\n }\n }\n </view>\n }\n <view listFooter><ng-content select=\"[listFooter]\" /></view>\n </virtual-list>\n `,\n})\nexport class SectionList<T, S extends SectionListSection<T> = SectionListSection<T>> {\n readonly sections = input.required<readonly S[]>();\n /** Each item's height, including every separator drawn in its slot. */\n readonly itemHeight = input.required<Height<[item: T, index: number, section: S]>>();\n readonly sectionHeaderHeight = input<Height<[section: S]>>(0);\n readonly sectionFooterHeight = input<Height<[section: S]>>(0);\n /** Pin the current section's header. Defaults to true on iOS and false on Android, as RN. */\n readonly stickySectionHeadersEnabled = input(undefined, { transform: optionalBoolean });\n readonly overscan = input(4, { transform: numberOr(4) });\n readonly endReachedThreshold = input(2, { transform: numberOr(2) });\n /** Space around the rows, inside the scrolling content. See `<virtual-list>`. */\n readonly contentPadding = input<VirtualListPadding>(0);\n /** What a tap in the list does while a text input has the keyboard up. See `ScrollView`. */\n readonly keyboardShouldPersistTaps = input<KeyboardShouldPersistTaps>('never');\n\n /** The end of the last section is within `endReachedThreshold`. See `<virtual-list>`. */\n readonly endReached = output<{ distanceFromEnd: number }>();\n\n protected readonly header = contentChild<SectionHeader<S>>(SectionHeader);\n protected readonly footer = contentChild<SectionFooter<S>>(SectionFooter);\n protected readonly item = contentChild<SectionItem<T, S>>(SectionItem);\n protected readonly separator = contentChild<SectionSeparator<T, S>>(SectionSeparator);\n protected readonly edge = contentChild<SectionEdgeSeparator<T, S>>(SectionEdgeSeparator);\n private readonly list = viewChild.required<VirtualList<SectionRow<T, S>>>('list');\n\n protected readonly fill = { flex: 1 };\n /** The item fills its slot between its separators, as RN's cell draws them around it. */\n protected readonly cell = { flex: 1 };\n\n protected readonly rows = computed(() => flattenSections<T, S>(this.sections()));\n\n private readonly sticky = computed(() => this.stickySectionHeadersEnabled() ?? isApplePlatform());\n\n /** The header rows, pinned in turn, when headers stick and there is a header to draw. */\n protected readonly stickyRows = computed(() => {\n if (!this.sticky() || !this.header()) return [];\n const indices: number[] = [];\n this.rows().forEach((row, index) => {\n if (row.kind === 'header') indices.push(index);\n });\n return indices;\n });\n\n protected readonly rowHeight = (row: SectionRow<T, S>): number => {\n const { section } = row.context;\n if (row.kind === 'item') {\n return measure(this.itemHeight(), row.context.item, row.context.index, section);\n }\n return row.kind === 'header'\n ? measure(this.sectionHeaderHeight(), section)\n : measure(this.sectionFooterHeight(), section);\n };\n\n /**\n * Scroll to an item, RN's way: `itemIndex` 0 is the section's header and 1 its first item, and\n * with sticky headers the header's height is allowed for so the item is not hidden under it.\n */\n scrollToLocation(options: {\n sectionIndex: number;\n itemIndex: number;\n viewOffset?: number;\n animated?: boolean;\n }): void {\n const sections = this.sections();\n let index = options.itemIndex;\n for (let i = 0; i < options.sectionIndex; i++) index += sections[i]!.data.length + 2;\n let viewOffset = options.viewOffset ?? 0;\n const section = sections[options.sectionIndex];\n if (options.itemIndex > 0 && this.sticky() && section) {\n viewOffset += measure(this.sectionHeaderHeight(), section);\n }\n this.list().scrollToIndex({ index, viewOffset, animated: options.animated });\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { type OnInit } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ /**
4
+ * A keyboard shortcut anywhere in the app, while the element is there: `shortcut="mod+k"` fires
5
+ * `(shortcutPress)`. `mod` is Cmd on Apple's OSes and Ctrl on Android. On iPhone and Android it
6
+ * works from a hardware keyboard, and Android lists it in the Keyboard Shortcuts helper under
7
+ * `shortcutLabel`. The editing keys (mod+z, x, c, v and a) go to a focused text input first.
8
+ */
9
+ export declare class Shortcut implements OnInit {
10
+ readonly shortcut: import("@angular/core").InputSignal<string>;
11
+ /** What Android's Keyboard Shortcuts helper lists it as. */
12
+ readonly shortcutLabel: import("@angular/core").InputSignal<string>;
13
+ readonly shortcutPress: import("@angular/core").OutputEmitterRef<void>;
14
+ private readonly menus;
15
+ private readonly destroyRef;
16
+ /** Once the inputs are set: a bound `[shortcut]` has no value while the constructor runs. */
17
+ ngOnInit(): void;
18
+ private register;
19
+ static ɵfac: i0.ɵɵFactoryDeclaration<Shortcut, never>;
20
+ static ɵdir: i0.ɵɵDirectiveDeclaration<Shortcut, "[shortcut]:not(menu-item)", never, { "shortcut": { "alias": "shortcut"; "required": true; "isSignal": true; }; "shortcutLabel": { "alias": "shortcutLabel"; "required": false; "isSignal": true; }; }, { "shortcutPress": "shortcutPress"; }, never, never, true, never>;
21
+ }
@@ -0,0 +1,34 @@
1
+ import { DestroyRef, Directive, inject, input, output } from '@angular/core';
2
+ import { Menus } from '@ng-native/device';
3
+ import * as i0 from "@angular/core";
4
+ /**
5
+ * A keyboard shortcut anywhere in the app, while the element is there: `shortcut="mod+k"` fires
6
+ * `(shortcutPress)`. `mod` is Cmd on Apple's OSes and Ctrl on Android. On iPhone and Android it
7
+ * works from a hardware keyboard, and Android lists it in the Keyboard Shortcuts helper under
8
+ * `shortcutLabel`. The editing keys (mod+z, x, c, v and a) go to a focused text input first.
9
+ */
10
+ export class Shortcut {
11
+ shortcut = input.required(/* @ts-ignore */
12
+ ...(ngDevMode ? [{ debugName: "shortcut" }] : /* istanbul ignore next */ []));
13
+ /** What Android's Keyboard Shortcuts helper lists it as. */
14
+ shortcutLabel = input('', /* @ts-ignore */
15
+ ...(ngDevMode ? [{ debugName: "shortcutLabel" }] : /* istanbul ignore next */ []));
16
+ shortcutPress = output();
17
+ menus = inject(Menus);
18
+ destroyRef = inject(DestroyRef);
19
+ /** Once the inputs are set: a bound `[shortcut]` has no value while the constructor runs. */
20
+ ngOnInit() {
21
+ this.register();
22
+ }
23
+ register() {
24
+ const stop = this.menus.addShortcut(this.shortcut, this.shortcutLabel, () => this.shortcutPress.emit());
25
+ this.destroyRef.onDestroy(stop);
26
+ }
27
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Shortcut, deps: [], target: i0.ɵɵFactoryTarget.Directive });
28
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: Shortcut, isStandalone: true, selector: "[shortcut]:not(menu-item)", inputs: { shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: true, transformFunction: null }, shortcutLabel: { classPropertyName: "shortcutLabel", publicName: "shortcutLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { shortcutPress: "shortcutPress" }, ngImport: i0 });
29
+ }
30
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Shortcut, decorators: [{
31
+ type: Directive,
32
+ args: [{ selector: '[shortcut]:not(menu-item)' }]
33
+ }], propDecorators: { shortcut: [{ type: i0.Input, args: [{ isSignal: true, alias: "shortcut", required: true }] }], shortcutLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "shortcutLabel", required: false }] }], shortcutPress: [{ type: i0.Output, args: ["shortcutPress"] }] } });
34
+ //# sourceMappingURL=shortcut.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcut.js","sourceRoot":"","sources":["../src/shortcut.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;;AAE1C;;;;;GAKG;AAEH,MAAM,OAAO,QAAQ;IACV,QAAQ,GAAG,KAAK,CAAC,QAAQ;iFAAU,CAAC;IAC7C,4DAA4D;IACnD,aAAa,GAAG,KAAK,CAAC,EAAE;sFAAC,CAAC;IAC1B,aAAa,GAAG,MAAM,EAAQ,CAAC;IAEvB,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACtB,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IAEjD,6FAA6F;IAC7F,QAAQ;QACN,IAAI,CAAC,QAAQ,EAAE,CAAC;IAClB,CAAC;IAEO,QAAQ;QACd,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE,CAC1E,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAC1B,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;uGAnBU,QAAQ;2FAAR,QAAQ;;2FAAR,QAAQ;kBADpB,SAAS;mBAAC,EAAE,QAAQ,EAAE,2BAA2B,EAAE","sourcesContent":["import { DestroyRef, Directive, inject, input, output, type OnInit } from '@angular/core';\nimport { Menus } from '@ng-native/device';\n\n/**\n * A keyboard shortcut anywhere in the app, while the element is there: `shortcut=\"mod+k\"` fires\n * `(shortcutPress)`. `mod` is Cmd on Apple's OSes and Ctrl on Android. On iPhone and Android it\n * works from a hardware keyboard, and Android lists it in the Keyboard Shortcuts helper under\n * `shortcutLabel`. The editing keys (mod+z, x, c, v and a) go to a focused text input first.\n */\n@Directive({ selector: '[shortcut]:not(menu-item)' })\nexport class Shortcut implements OnInit {\n readonly shortcut = input.required<string>();\n /** What Android's Keyboard Shortcuts helper lists it as. */\n readonly shortcutLabel = input('');\n readonly shortcutPress = output<void>();\n\n private readonly menus = inject(Menus);\n private readonly destroyRef = inject(DestroyRef);\n\n /** Once the inputs are set: a bound `[shortcut]` has no value while the constructor runs. */\n ngOnInit(): void {\n this.register();\n }\n\n private register(): void {\n const stop = this.menus.addShortcut(this.shortcut, this.shortcutLabel, () =>\n this.shortcutPress.emit(),\n );\n this.destroyRef.onDestroy(stop);\n }\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import type { ButtonIcon } from './native-button.ts';
2
+ import { ControlBase } from './pressable.ts';
3
+ import { type SidebarRow } from './sidebar.ts';
4
+ import * as i0 from "@angular/core";
5
+ /** A sidebar item's picture, as on `<native-tab>` and `<native-button>`. */
6
+ export type SidebarItemIcon = ButtonIcon;
7
+ /**
8
+ * A row of the sidebar:
9
+ *
10
+ * <sidebar-item label="Inbox" sfSymbol="tray" [badge]="unread()" [(selected)]="inbox" />
11
+ *
12
+ * With `path`, from `@ng-native/router`, the route selects it, as a `<native-tab>`'s does, and
13
+ * choosing it navigates there. Without, `[(selected)]` holds the selection. Either way choosing it
14
+ * fires `(select)` and deselects the sidebar's other items.
15
+ *
16
+ * Content inside the element replaces the default row of icon, label and badge: its pressables
17
+ * take clicks, and while the row is selected its host has `data-selected` for CSS to restyle it.
18
+ */
19
+ export declare class SidebarItem extends ControlBase implements SidebarRow {
20
+ private readonly sidebar;
21
+ /** Whether this row is drawnHere here rather than by the desktop host. */
22
+ protected readonly drawnHere: boolean;
23
+ /** The row's text, and what it is announced as. */
24
+ readonly label: import("@angular/core").InputSignal<string | undefined>;
25
+ /** A count or a short word at the trailing edge. */
26
+ readonly badge: import("@angular/core").InputSignalWithTransform<string | undefined, string | number | null | undefined>;
27
+ /** An SF Symbol before the label, on macOS and iOS. */
28
+ readonly sfSymbol: import("@angular/core").InputSignal<string | undefined>;
29
+ /** Android: a drawable resource before the label. */
30
+ readonly drawableName: import("@angular/core").InputSignal<string | undefined>;
31
+ /** The picture for each OS at once, as on `<native-tab>`. */
32
+ readonly icon: import("@angular/core").InputSignal<ButtonIcon | undefined>;
33
+ /** Whether this is the sidebar's selected item. A `path` from the router sets it by route. */
34
+ readonly selected: import("@angular/core").ModelSignal<boolean>;
35
+ /** The user chose this item. */
36
+ readonly select: import("@angular/core").OutputEmitterRef<void>;
37
+ protected readonly symbol: import("@angular/core").Signal<string | undefined>;
38
+ protected readonly drawableResource: import("@angular/core").Signal<string | undefined>;
39
+ private stopSelect;
40
+ constructor();
41
+ protected roleByDefault(): 'button';
42
+ protected accessibleByDefault(): boolean;
43
+ protected focusableByDefault(): boolean;
44
+ /** On macOS the source list takes the click and selects the row: the responder never does. */
45
+ protected claims(): boolean;
46
+ ngOnInit(): void;
47
+ ngOnDestroy(): void;
48
+ /** The user chose this row: select it, deselect the rest, and say so. */
49
+ choose(): void;
50
+ deselect(): void;
51
+ static ɵfac: i0.ɵɵFactoryDeclaration<SidebarItem, never>;
52
+ static ɵcmp: i0.ɵɵComponentDeclaration<SidebarItem, "sidebar-item", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "badge": { "alias": "badge"; "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; }; "selected": { "alias": "selected"; "required": false; "isSignal": true; }; }, { "selected": "selectedChange"; "select": "select"; }, never, ["*"], true, never>;
53
+ }
@@ -0,0 +1,152 @@
1
+ import { Component, DestroyRef, computed, forwardRef, inject, input, model, output, } from '@angular/core';
2
+ import { SIDEBAR_SELECTION } from '@ng-native/device';
3
+ import { nativePlatform, registerViewName } from '@ng-native/fabric';
4
+ import { ControlBase, TouchableBase } from "./pressable.js";
5
+ import { Sidebar } from "./sidebar.js";
6
+ import { Text } from "./text.js";
7
+ import * as i0 from "@angular/core";
8
+ /**
9
+ * On macOS a row of the sidebar's source list, a model object the desktop host builds an
10
+ * NSTableCellView from. An item with children is a custom row: the host puts its views in a cell
11
+ * of its own. Elsewhere a pressable view, drawnHere here.
12
+ */
13
+ registerViewName('sidebar-item', {
14
+ ios: 'View',
15
+ android: 'View',
16
+ macos: 'NgNativeSidebarItem',
17
+ });
18
+ /**
19
+ * A row of the sidebar:
20
+ *
21
+ * <sidebar-item label="Inbox" sfSymbol="tray" [badge]="unread()" [(selected)]="inbox" />
22
+ *
23
+ * With `path`, from `@ng-native/router`, the route selects it, as a `<native-tab>`'s does, and
24
+ * choosing it navigates there. Without, `[(selected)]` holds the selection. Either way choosing it
25
+ * fires `(select)` and deselects the sidebar's other items.
26
+ *
27
+ * Content inside the element replaces the default row of icon, label and badge: its pressables
28
+ * take clicks, and while the row is selected its host has `data-selected` for CSS to restyle it.
29
+ */
30
+ export class SidebarItem extends ControlBase {
31
+ sidebar = inject(Sidebar, { optional: true });
32
+ /** Whether this row is drawnHere here rather than by the desktop host. */
33
+ drawnHere = nativePlatform() !== 'macos';
34
+ /** The row's text, and what it is announced as. */
35
+ label = input(/* @ts-ignore */
36
+ ...(ngDevMode ? [undefined, { debugName: "label" }] : /* istanbul ignore next */ []));
37
+ /** A count or a short word at the trailing edge. */
38
+ badge = input(undefined, { ...(ngDevMode ? { debugName: "badge" } : /* istanbul ignore next */ {}), transform: (value) => (value == null ? undefined : String(value)) });
39
+ /** An SF Symbol before the label, on macOS and iOS. */
40
+ sfSymbol = input(/* @ts-ignore */
41
+ ...(ngDevMode ? [undefined, { debugName: "sfSymbol" }] : /* istanbul ignore next */ []));
42
+ /** Android: a drawable resource before the label. */
43
+ drawableName = input(undefined, { ...(ngDevMode ? { debugName: "drawableName" } : /* istanbul ignore next */ {}), alias: 'drawable' });
44
+ /** The picture for each OS at once, as on `<native-tab>`. */
45
+ icon = input(/* @ts-ignore */
46
+ ...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
47
+ /** Whether this is the sidebar's selected item. A `path` from the router sets it by route. */
48
+ selected = model(false, /* @ts-ignore */
49
+ ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
50
+ /** The user chose this item. */
51
+ select = output();
52
+ symbol = computed(() => {
53
+ const icon = this.icon();
54
+ return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);
55
+ }, /* @ts-ignore */
56
+ ...(ngDevMode ? [{ debugName: "symbol" }] : /* istanbul ignore next */ []));
57
+ drawableResource = computed(() => {
58
+ const icon = this.icon();
59
+ return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);
60
+ }, /* @ts-ignore */
61
+ ...(ngDevMode ? [{ debugName: "drawableResource" }] : /* istanbul ignore next */ []));
62
+ stopSelect = null;
63
+ constructor() {
64
+ super();
65
+ const remove = this.sidebar?.addRow(this);
66
+ if (remove)
67
+ inject(DestroyRef).onDestroy(remove);
68
+ this.press.subscribe(() => this.choose());
69
+ }
70
+ roleByDefault() {
71
+ return 'button';
72
+ }
73
+ accessibleByDefault() {
74
+ return true;
75
+ }
76
+ focusableByDefault() {
77
+ return true;
78
+ }
79
+ /** On macOS the source list takes the click and selects the row: the responder never does. */
80
+ claims() {
81
+ return this.drawnHere && super.claims();
82
+ }
83
+ ngOnInit() {
84
+ super.ngOnInit();
85
+ if (this.drawnHere || this.stopSelect)
86
+ return;
87
+ this.stopSelect = this.engine.setEventListener(this.node, 'topSidebarSelect', (event) => {
88
+ if (event.target === this.node)
89
+ this.choose();
90
+ });
91
+ }
92
+ ngOnDestroy() {
93
+ super.ngOnDestroy();
94
+ this.stopSelect?.();
95
+ }
96
+ /** The user chose this row: select it, deselect the rest, and say so. */
97
+ choose() {
98
+ if (this.pressDisabled())
99
+ return;
100
+ this.selected.set(true);
101
+ this.sidebar?.chose(this);
102
+ this.select.emit();
103
+ }
104
+ deselect() {
105
+ this.selected.set(false);
106
+ }
107
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SidebarItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
108
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: SidebarItem, isStandalone: true, selector: "sidebar-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, badge: { classPropertyName: "badge", publicName: "badge", 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 }, selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selectedChange", select: "select" }, host: { properties: { "label": "drawnHere ? undefined : label()", "badge": "drawnHere ? undefined : badge()", "sfSymbol": "drawnHere ? undefined : symbol()", "drawable": "drawnHere ? undefined : drawableResource()", "selected": "drawnHere ? undefined : selected()", "attr.data-selected": "selected() ? '' : null", "class.sidebar-item-drawn": "drawnHere" } }, providers: [
109
+ { provide: TouchableBase, useExisting: forwardRef(() => SidebarItem) },
110
+ {
111
+ provide: SIDEBAR_SELECTION,
112
+ useFactory: () => inject(forwardRef(() => SidebarItem)).selected,
113
+ },
114
+ ], usesInheritance: true, ngImport: i0, template: `
115
+ <ng-content>
116
+ @if (drawnHere) {
117
+ <text class="sidebar-item-label">{{ label() }}</text>
118
+ @if (badge()) {
119
+ <text class="sidebar-item-badge">{{ badge() }}</text>
120
+ }
121
+ }
122
+ </ng-content>
123
+ `, isInline: true, styles: ["\n /* A row drawn here. On macOS the host's cell is the row, and custom content fills it. */\n :host(.sidebar-item-drawn) {\n flex-direction: row;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n }\n .sidebar-item-label {\n flex: 1;\n }\n .sidebar-item-badge {\n opacity: 0.6;\n }\n "], dependencies: [{ kind: "directive", type: Text, selector: "text", inputs: ["numberOfLines", "ellipsizeMode", "selectable", "selectionColor", "allowFontScaling", "maxFontSizeMultiplier", "dynamicTypeRamp", "adjustsFontSizeToFit", "minimumFontScale", "lineBreakStrategyIOS", "textBreakStrategy", "dataDetectorType", "android_hyphenationFrequency", "pressable", "suppressHighlighting"], exportAs: ["text"] }] });
124
+ }
125
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SidebarItem, decorators: [{
126
+ type: Component,
127
+ args: [{ selector: 'sidebar-item', imports: [Text], template: `
128
+ <ng-content>
129
+ @if (drawnHere) {
130
+ <text class="sidebar-item-label">{{ label() }}</text>
131
+ @if (badge()) {
132
+ <text class="sidebar-item-badge">{{ badge() }}</text>
133
+ }
134
+ }
135
+ </ng-content>
136
+ `, providers: [
137
+ { provide: TouchableBase, useExisting: forwardRef(() => SidebarItem) },
138
+ {
139
+ provide: SIDEBAR_SELECTION,
140
+ useFactory: () => inject(forwardRef(() => SidebarItem)).selected,
141
+ },
142
+ ], host: {
143
+ '[label]': 'drawnHere ? undefined : label()',
144
+ '[badge]': 'drawnHere ? undefined : badge()',
145
+ '[sfSymbol]': 'drawnHere ? undefined : symbol()',
146
+ '[drawable]': 'drawnHere ? undefined : drawableResource()',
147
+ '[selected]': 'drawnHere ? undefined : selected()',
148
+ '[attr.data-selected]': "selected() ? '' : null",
149
+ '[class.sidebar-item-drawn]': 'drawnHere',
150
+ }, styles: ["\n /* A row drawn here. On macOS the host's cell is the row, and custom content fills it. */\n :host(.sidebar-item-drawn) {\n flex-direction: row;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n }\n .sidebar-item-label {\n flex: 1;\n }\n .sidebar-item-badge {\n opacity: 0.6;\n }\n "] }]
151
+ }], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], badge: [{ type: i0.Input, args: [{ isSignal: true, alias: "badge", 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 }] }], selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }, { type: i0.Output, args: ["selectedChange"] }], select: [{ type: i0.Output, args: ["select"] }] } });
152
+ //# sourceMappingURL=sidebar-item.js.map