@ng-native/components 0.27.0 → 0.29.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 (80) hide show
  1. package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +116 -11
  2. package/android/src/main/java/dev/ngnative/components/ContextMenuPopup.kt +61 -19
  3. package/android/src/main/java/dev/ngnative/components/MenusModule.kt +22 -0
  4. package/android/src/main/java/dev/ngnative/components/Shortcut.kt +13 -4
  5. package/dist/context-menu.d.ts +14 -6
  6. package/dist/context-menu.js +30 -28
  7. package/dist/context-menu.js.map +1 -1
  8. package/dist/index.d.ts +4 -1
  9. package/dist/index.js +4 -1
  10. package/dist/index.js.map +1 -1
  11. package/dist/menu.d.ts +17 -8
  12. package/dist/menu.js +22 -36
  13. package/dist/menu.js.map +1 -1
  14. package/dist/modal.d.ts +6 -2
  15. package/dist/modal.js.map +1 -1
  16. package/dist/native-button.d.ts +31 -2
  17. package/dist/native-button.js +104 -6
  18. package/dist/native-button.js.map +1 -1
  19. package/dist/press-menu.d.ts +60 -0
  20. package/dist/press-menu.js +116 -0
  21. package/dist/press-menu.js.map +1 -0
  22. package/dist/pressable.d.ts +3 -0
  23. package/dist/pressable.js +7 -1
  24. package/dist/pressable.js.map +1 -1
  25. package/dist/reanimated.js +27 -3
  26. package/dist/reanimated.js.map +1 -1
  27. package/dist/scroll-view.d.ts +3 -1
  28. package/dist/scroll-view.js +7 -2
  29. package/dist/scroll-view.js.map +1 -1
  30. package/dist/settled-updates.d.ts +55 -0
  31. package/dist/settled-updates.js +77 -0
  32. package/dist/settled-updates.js.map +1 -0
  33. package/dist/sidebar-item.d.ts +18 -3
  34. package/dist/sidebar-item.js +29 -3
  35. package/dist/sidebar-item.js.map +1 -1
  36. package/dist/sidebar.js +4 -3
  37. package/dist/sidebar.js.map +1 -1
  38. package/dist/split-view.d.ts +23 -2
  39. package/dist/split-view.js +32 -5
  40. package/dist/split-view.js.map +1 -1
  41. package/dist/stand-ins/reanimated.d.ts +5 -0
  42. package/dist/stand-ins/reanimated.js +7 -0
  43. package/dist/stand-ins/reanimated.js.map +1 -1
  44. package/dist/sticky-headers.d.ts +19 -0
  45. package/dist/sticky-headers.js +67 -10
  46. package/dist/sticky-headers.js.map +1 -1
  47. package/dist/sticky-rows.d.ts +123 -26
  48. package/dist/sticky-rows.js +285 -71
  49. package/dist/sticky-rows.js.map +1 -1
  50. package/dist/svg-icon.d.ts +23 -0
  51. package/dist/svg-icon.js +53 -0
  52. package/dist/svg-icon.js.map +1 -0
  53. package/dist/tray-icon.d.ts +7 -1
  54. package/dist/tray-icon.js +15 -3
  55. package/dist/tray-icon.js.map +1 -1
  56. package/dist/virtual-list-sticky-level.d.ts +33 -0
  57. package/dist/virtual-list-sticky-level.js +58 -0
  58. package/dist/virtual-list-sticky-level.js.map +1 -0
  59. package/dist/virtual-list-sticky.d.ts +19 -0
  60. package/dist/virtual-list-sticky.js +13 -0
  61. package/dist/virtual-list-sticky.js.map +1 -0
  62. package/dist/virtual-list.d.ts +29 -7
  63. package/dist/virtual-list.js +127 -59
  64. package/dist/virtual-list.js.map +1 -1
  65. package/dist/worklet-style.d.ts +11 -0
  66. package/dist/worklet-style.js +15 -1
  67. package/dist/worklet-style.js.map +1 -1
  68. package/dist/worklets.d.ts +5 -1
  69. package/dist/worklets.js.map +1 -1
  70. package/dist/written-props.js +3 -0
  71. package/dist/written-props.js.map +1 -1
  72. package/ios/NgNativeButtonComponentView.mm +8 -4
  73. package/ios/NgNativeButtonMetrics.h +9 -2
  74. package/ios/NgNativeButtonMetrics.mm +33 -4
  75. package/ios/NgNativeButtonShadowNode.h +2 -0
  76. package/ios/NgNativeButtonShadowNode.mm +5 -1
  77. package/ios/NgNativeMenus.mm +42 -2
  78. package/ios/NgNativePressMenu.h +28 -0
  79. package/ios/NgNativePressMenu.mm +45 -0
  80. package/package.json +3 -3
@@ -1,6 +1,8 @@
1
- import { type Signal } from '@angular/core';
1
+ import { InjectionToken, type Signal } from '@angular/core';
2
2
  import { ViewBase } from './view-base.ts';
3
3
  import * as i0 from "@angular/core";
4
+ /** A `<sidebar>`, which provides itself as this so a split view can find it among its children. */
5
+ export declare const SIDEBAR: InjectionToken<unknown>;
4
6
  /** Whether the host draws `element`, rather than a view drawn here. */
5
7
  export declare function hostDraws(element: string): boolean;
6
8
  /**
@@ -10,6 +12,12 @@ export declare function hostDraws(element: string): boolean;
10
12
  export declare const ANDROID_EXPANDED_WIDTH = 840;
11
13
  /** Which pane a split view shows: both side by side, or one of them as a stack's top. */
12
14
  export type SplitViewShowing = 'both' | 'sidebar' | 'content';
15
+ /**
16
+ * How the desktop hosts draw a split view's content pane: `plain`, filling the space beside the
17
+ * sidebar, or `inset`, a card with rounded corners inset from its space's edges, on the sidebar's
18
+ * backdrop, which runs under the toolbar or header bar.
19
+ */
20
+ export type SplitViewContentStyle = 'plain' | 'inset';
13
21
  /** The content pane: everything in a `<split-view>` but its `<sidebar>`. */
14
22
  export declare class SplitViewContent extends ViewBase {
15
23
  protected readonly split: SplitView;
@@ -36,16 +44,29 @@ export declare class SplitViewContent extends ViewBase {
36
44
  * root is the sidebar. On Android the columns wait for Material's expanded width,
37
45
  * `ANDROID_EXPANDED_WIDTH`, as its list-detail layout does. There, choosing an item shows the content, and `showSidebar()` (or
38
46
  * Android's back button) returns to the sidebar.
47
+ *
48
+ * `contentStyle="inset"` draws the content pane on macOS and Linux as a card with rounded corners,
49
+ * inset from its space's edges on the sidebar's backdrop, which runs under the toolbar. The pane's
50
+ * size, and so its layout, is the card's. iOS and Android ignore it.
39
51
  */
40
52
  export declare class SplitView extends ViewBase {
53
+ /**
54
+ * macOS and Linux: the content pane `plain`, beside the sidebar, or `inset`, a rounded card on
55
+ * the sidebar's backdrop. iOS and Android ignore it.
56
+ */
57
+ readonly contentStyle: import("@angular/core").InputSignal<SplitViewContentStyle>;
41
58
  /** Whether this split view is drawn from views here, rather than by the host. */
42
59
  readonly drawn: boolean;
43
60
  /** Whether the host is iOS's, whose split view controller pushes and pops the content. */
44
61
  private readonly stacksNatively;
62
+ /** Whether the desktop host draws this split view: on macOS and Linux. */
63
+ readonly onDesktop: boolean;
45
64
  private readonly screen;
46
65
  /** Too narrow for the panes side by side: below Material's expanded width on Android. */
47
66
  private readonly compact;
48
67
  private readonly top;
68
+ /** Its `<sidebar>`, a child of its own, as the sidebar pane takes only those. */
69
+ private readonly sidebar;
49
70
  /** Whether the panes are a stack, one at a time: at a compact width, where it is drawn. */
50
71
  readonly stacked: Signal<boolean>;
51
72
  /** Which pane is showing. Both, unless the split view is a stack. */
@@ -59,5 +80,5 @@ export declare class SplitView extends ViewBase {
59
80
  */
60
81
  showSidebar(): boolean;
61
82
  static ɵfac: i0.ɵɵFactoryDeclaration<SplitView, never>;
62
- static ɵcmp: i0.ɵɵComponentDeclaration<SplitView, "split-view", never, {}, {}, never, ["sidebar", "*"], true, never>;
83
+ static ɵcmp: i0.ɵɵComponentDeclaration<SplitView, "split-view", never, { "contentStyle": { "alias": "contentStyle"; "required": false; "isSignal": true; }; }, {}, ["sidebar"], ["sidebar", "*"], true, never>;
63
84
  }
@@ -1,4 +1,4 @@
1
- import { Component, DestroyRef, computed, inject, signal } from '@angular/core';
1
+ import { Component, DestroyRef, InjectionToken, afterNextRender, computed, contentChild, inject, input, signal, } from '@angular/core';
2
2
  import { HardwareBack, Screen, nativeSplitViews } from '@ng-native/device';
3
3
  import { nativePlatform, registerViewName, registeredViewName } from '@ng-native/fabric';
4
4
  import { ViewBase } from "./view-base.js";
@@ -23,6 +23,8 @@ registerViewName('split-view-content', {
23
23
  android: 'View',
24
24
  macos: 'NgNativeSplitContent',
25
25
  });
26
+ /** A `<sidebar>`, which provides itself as this so a split view can find it among its children. */
27
+ export const SIDEBAR = new InjectionToken('angular-native.sidebar');
26
28
  /** Whether the host draws `element`, rather than a view drawn here. */
27
29
  export function hostDraws(element) {
28
30
  return registeredViewName(element) !== 'View';
@@ -36,11 +38,14 @@ export const ANDROID_EXPANDED_WIDTH = 840;
36
38
  export class SplitViewContent extends ViewBase {
37
39
  split = inject(SplitView);
38
40
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SplitViewContent, deps: null, target: i0.ɵɵFactoryTarget.Component });
39
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: SplitViewContent, isStandalone: true, selector: "split-view-content", host: { properties: { "style.display": "split.showing() === 'sidebar' ? 'none' : undefined" } }, usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host { flex: 1; }"] });
41
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: SplitViewContent, isStandalone: true, selector: "split-view-content", host: { properties: { "style.display": "split.showing() === 'sidebar' ? 'none' : undefined", "contentStyle": "split.onDesktop ? split.contentStyle() : undefined" } }, usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true, styles: [":host { flex: 1; }"] });
40
42
  }
41
43
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SplitViewContent, decorators: [{
42
44
  type: Component,
43
- args: [{ selector: 'split-view-content', template: '<ng-content />', host: { '[style.display]': "split.showing() === 'sidebar' ? 'none' : undefined" }, styles: [":host { flex: 1; }"] }]
45
+ args: [{ selector: 'split-view-content', template: '<ng-content />', host: {
46
+ '[style.display]': "split.showing() === 'sidebar' ? 'none' : undefined",
47
+ '[contentStyle]': 'split.onDesktop ? split.contentStyle() : undefined',
48
+ }, styles: [":host { flex: 1; }"] }]
44
49
  }] });
45
50
  /**
46
51
  * A sidebar beside the app's content:
@@ -62,12 +67,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
62
67
  * root is the sidebar. On Android the columns wait for Material's expanded width,
63
68
  * `ANDROID_EXPANDED_WIDTH`, as its list-detail layout does. There, choosing an item shows the content, and `showSidebar()` (or
64
69
  * Android's back button) returns to the sidebar.
70
+ *
71
+ * `contentStyle="inset"` draws the content pane on macOS and Linux as a card with rounded corners,
72
+ * inset from its space's edges on the sidebar's backdrop, which runs under the toolbar. The pane's
73
+ * size, and so its layout, is the card's. iOS and Android ignore it.
65
74
  */
66
75
  export class SplitView extends ViewBase {
76
+ /**
77
+ * macOS and Linux: the content pane `plain`, beside the sidebar, or `inset`, a rounded card on
78
+ * the sidebar's backdrop. iOS and Android ignore it.
79
+ */
80
+ contentStyle = input('plain', /* @ts-ignore */
81
+ ...(ngDevMode ? [{ debugName: "contentStyle" }] : /* istanbul ignore next */ []));
67
82
  /** Whether this split view is drawn from views here, rather than by the host. */
68
83
  drawn = !hostDraws('split-view');
69
84
  /** Whether the host is iOS's, whose split view controller pushes and pops the content. */
70
85
  stacksNatively = !this.drawn && nativePlatform() === 'ios';
86
+ /** Whether the desktop host draws this split view: on macOS and Linux. */
87
+ onDesktop = !this.drawn && !this.stacksNatively;
71
88
  screen = inject(Screen);
72
89
  /** Too narrow for the panes side by side: below Material's expanded width on Android. */
73
90
  compact = computed(() => nativePlatform() === 'android'
@@ -76,6 +93,8 @@ export class SplitView extends ViewBase {
76
93
  ...(ngDevMode ? [{ debugName: "compact" }] : /* istanbul ignore next */ []));
77
94
  top = signal('sidebar', /* @ts-ignore */
78
95
  ...(ngDevMode ? [{ debugName: "top" }] : /* istanbul ignore next */ []));
96
+ /** Its `<sidebar>`, a child of its own, as the sidebar pane takes only those. */
97
+ sidebar = contentChild(SIDEBAR, { ...(ngDevMode ? { debugName: "sidebar" } : /* istanbul ignore next */ {}), descendants: false });
79
98
  /** Whether the panes are a stack, one at a time: at a compact width, where it is drawn. */
80
99
  stacked = computed(() => this.drawn && this.compact(), /* @ts-ignore */
81
100
  ...(ngDevMode ? [{ debugName: "stacked" }] : /* istanbul ignore next */ []));
@@ -86,6 +105,14 @@ export class SplitView extends ViewBase {
86
105
  super();
87
106
  const stop = inject(HardwareBack).handle(() => this.showSidebar());
88
107
  inject(DestroyRef).onDestroy(stop);
108
+ afterNextRender(() => {
109
+ if (this.sidebar())
110
+ return;
111
+ if (typeof ngDevMode !== 'undefined' && !ngDevMode)
112
+ return;
113
+ console.warn('[angular-native] A <split-view> has no <sidebar> of its own, so its sidebar pane is ' +
114
+ 'empty: on macOS it draws no divider. Put a <sidebar> in it as a child of its own.');
115
+ });
89
116
  }
90
117
  /** Show the content over the sidebar, where the panes are a stack. A choice in the sidebar does. */
91
118
  showContent() {
@@ -106,7 +133,7 @@ export class SplitView extends ViewBase {
106
133
  return true;
107
134
  }
108
135
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SplitView, deps: [], target: i0.ɵɵFactoryTarget.Component });
109
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: SplitView, isStandalone: true, selector: "split-view", host: { properties: { "style.flexDirection": "drawn && !stacked() ? 'row' : undefined" } }, usesInheritance: true, ngImport: i0, template: `
136
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.2.0", type: SplitView, isStandalone: true, selector: "split-view", inputs: { contentStyle: { classPropertyName: "contentStyle", publicName: "contentStyle", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.flexDirection": "drawn && !stacked() ? 'row' : undefined" } }, queries: [{ propertyName: "sidebar", first: true, predicate: SIDEBAR, isSignal: true }], usesInheritance: true, ngImport: i0, template: `
110
137
  <ng-content select="sidebar" />
111
138
  <split-view-content><ng-content /></split-view-content>
112
139
  `, isInline: true, styles: [":host { flex: 1; }"], dependencies: [{ kind: "component", type: SplitViewContent, selector: "split-view-content" }] });
@@ -117,5 +144,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
117
144
  <ng-content select="sidebar" />
118
145
  <split-view-content><ng-content /></split-view-content>
119
146
  `, host: { '[style.flexDirection]': "drawn && !stacked() ? 'row' : undefined" }, styles: [":host { flex: 1; }"] }]
120
- }], ctorParameters: () => [] });
147
+ }], ctorParameters: () => [], propDecorators: { contentStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentStyle", required: false }] }], sidebar: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SIDEBAR), { ...{ descendants: false }, isSignal: true }] }] } });
121
148
  //# sourceMappingURL=split-view.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"split-view.js","sourceRoot":"","sources":["../src/split-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;;;GAKG;AACH,gBAAgB,CAAC,YAAY,EAAE;IAC7B,IAAI,GAAG;QACL,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3D,CAAC;IACD,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,mBAAmB;CAC3B,CAAC,CAAC;AACH,gBAAgB,CAAC,oBAAoB,EAAE;IACrC,IAAI,GAAG;QACL,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,MAAM,CAAC;IAC9D,CAAC;IACD,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,sBAAsB;CAC9B,CAAC,CAAC;AAEH,uEAAuE;AACvE,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,kBAAkB,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,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AAC,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IAED,oGAAoG;IACpG,WAAW;QACT,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACjF,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,IAAI,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC/E,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC/C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;uGA3CU,SAAS;2FAAT,SAAS,yLAPV;;;GAGT,4FA/BU,gBAAgB;;2FAmChB,SAAS;kBAVrB,SAAS;+BACE,YAAY,WACb,CAAC,gBAAgB,CAAC,YACjB;;;GAGT,QAEK,EAAE,uBAAuB,EAAE,yCAAyC,EAAE","sourcesContent":["import { Component, DestroyRef, computed, inject, signal, type Signal } from '@angular/core';\nimport { HardwareBack, Screen, nativeSplitViews } from '@ng-native/device';\nimport { nativePlatform, registerViewName, registeredViewName } from '@ng-native/fabric';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * The host draws a split view on macOS: an NSSplitViewController for the first one in a window, a\n * plain NSSplitView for any other. On an iPad with the components pod it is a\n * UISplitViewController (`nativeSplitViews()`). Everywhere else it is drawn here, from views: two\n * columns, or at a compact width a stack whose root is the sidebar.\n */\nregisterViewName('split-view', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSplitView' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSplitView',\n});\nregisterViewName('split-view-content', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSplitContent' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSplitContent',\n});\n\n/** Whether the host draws `element`, rather than a view drawn here. */\nexport function hostDraws(element: string): boolean {\n return registeredViewName(element) !== 'View';\n}\n\n/**\n * Material's expanded window width, in dp: from it Android's list-detail layout shows the list\n * pane beside the content, and below it one pane at a time.\n */\nexport const ANDROID_EXPANDED_WIDTH = 840;\n\n/** Which pane a split view shows: both side by side, or one of them as a stack's top. */\nexport type SplitViewShowing = 'both' | 'sidebar' | 'content';\n\n/** The content pane: everything in a `<split-view>` but its `<sidebar>`. */\n@Component({\n selector: 'split-view-content',\n template: '<ng-content />',\n host: { '[style.display]': \"split.showing() === 'sidebar' ? 'none' : undefined\" },\n styles: ':host { flex: 1; }',\n})\nexport class SplitViewContent extends ViewBase {\n protected readonly split = inject(SplitView);\n}\n\n/**\n * A sidebar beside the app's content:\n *\n * <split-view>\n * <sidebar [(collapsed)]=\"hidden\">\n * <sidebar-section title=\"Library\">\n * <sidebar-item path=\"songs\" label=\"Songs\" sfSymbol=\"music.note\" />\n * </sidebar-section>\n * </sidebar>\n * <router-outlet />\n * </split-view>\n *\n * On macOS the first one in a window becomes its NSSplitViewController, with the full-height\n * sidebar and the toolbar's sidebar button; a nested or second one is a plain NSSplitView. On an\n * iPad it is a UISplitViewController, whose sidebar column holds the sidebar's rows drawn here,\n * and which collapses into a stack itself at a compact width (Slide Over, a narrow Split View),\n * the sidebar its root. On an iPhone and Android it is drawn: two columns, and at a compact width (`Screen.compact`) a stack whose\n * root is the sidebar. On Android the columns wait for Material's expanded width,\n * `ANDROID_EXPANDED_WIDTH`, as its list-detail layout does. There, choosing an item shows the content, and `showSidebar()` (or\n * Android's back button) returns to the sidebar.\n */\n@Component({\n selector: 'split-view',\n imports: [SplitViewContent],\n template: `\n <ng-content select=\"sidebar\" />\n <split-view-content><ng-content /></split-view-content>\n `,\n styles: ':host { flex: 1; }',\n host: { '[style.flexDirection]': \"drawn && !stacked() ? 'row' : undefined\" },\n})\nexport class SplitView extends ViewBase {\n /** Whether this split view is drawn from views here, rather than by the host. */\n readonly drawn = !hostDraws('split-view');\n /** Whether the host is iOS's, whose split view controller pushes and pops the content. */\n private readonly stacksNatively = !this.drawn && nativePlatform() === 'ios';\n private readonly screen = inject(Screen);\n /** Too narrow for the panes side by side: below Material's expanded width on Android. */\n private readonly compact = computed(() =>\n nativePlatform() === 'android'\n ? this.screen.window().width < ANDROID_EXPANDED_WIDTH\n : this.screen.compact(),\n );\n private readonly top = signal<'sidebar' | 'content'>('sidebar');\n\n /** Whether the panes are a stack, one at a time: at a compact width, where it is drawn. */\n readonly stacked: Signal<boolean> = computed(() => this.drawn && this.compact());\n\n /** Which pane is showing. Both, unless the split view is a stack. */\n readonly showing: Signal<SplitViewShowing> = computed(() =>\n this.stacked() ? this.top() : 'both',\n );\n\n constructor() {\n super();\n const stop = inject(HardwareBack).handle(() => this.showSidebar());\n inject(DestroyRef).onDestroy(stop);\n }\n\n /** Show the content over the sidebar, where the panes are a stack. A choice in the sidebar does. */\n showContent(): void {\n this.top.set('content');\n if (this.stacksNatively) this.engine.dispatchCommand(this.node, 'showContent');\n }\n\n /**\n * Go back to the sidebar, where the panes are a stack and the content is in front. Whether it\n * did, so Android's back button leaves the app from the sidebar.\n */\n showSidebar(): boolean {\n if (this.stacksNatively) this.engine.dispatchCommand(this.node, 'showSidebar');\n if (this.showing() !== 'content') return false;\n this.top.set('sidebar');\n return true;\n }\n}\n"]}
1
+ {"version":3,"file":"split-view.js","sourceRoot":"","sources":["../src/split-view.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,cAAc,EACd,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,gBAA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,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,eAAe,CAAC,GAAG,EAAE;YACnB,IAAI,IAAI,CAAC,OAAO,EAAE;gBAAE,OAAO;YAC3B,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS;gBAAE,OAAO;YAC3D,OAAO,CAAC,IAAI,CACV,sFAAsF;gBACpF,mFAAmF,CACtF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,oGAAoG;IACpG,WAAW;QACT,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACjF,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,IAAI,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC/E,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC/C,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;uGA7DU,SAAS;2FAAT,SAAS,gWAsBoB,OAAO,oEA7BrC;;;GAGT,4FAnCU,gBAAgB;;2FAuChB,SAAS;kBAVrB,SAAS;+BACE,YAAY,WACb,CAAC,gBAAgB,CAAC,YACjB;;;GAGT,QAEK,EAAE,uBAAuB,EAAE,yCAAyC,EAAE;8NAwBpC,OAAO,QAAE,EAAE,WAAW,EAAE,KAAK,EAAE","sourcesContent":["import {\n Component,\n DestroyRef,\n InjectionToken,\n afterNextRender,\n computed,\n contentChild,\n inject,\n input,\n signal,\n type Signal,\n} from '@angular/core';\nimport { HardwareBack, Screen, nativeSplitViews } from '@ng-native/device';\nimport { nativePlatform, registerViewName, registeredViewName } from '@ng-native/fabric';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * The host draws a split view on macOS: an NSSplitViewController for the first one in a window, a\n * plain NSSplitView for any other. On an iPad with the components pod it is a\n * UISplitViewController (`nativeSplitViews()`). Everywhere else it is drawn here, from views: two\n * columns, or at a compact width a stack whose root is the sidebar.\n */\nregisterViewName('split-view', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSplitView' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSplitView',\n});\nregisterViewName('split-view-content', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSplitContent' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSplitContent',\n});\n\ndeclare const ngDevMode: unknown;\n\n/** A `<sidebar>`, which provides itself as this so a split view can find it among its children. */\nexport const SIDEBAR = new InjectionToken<unknown>('angular-native.sidebar');\n\n/** Whether the host draws `element`, rather than a view drawn here. */\nexport function hostDraws(element: string): boolean {\n return registeredViewName(element) !== 'View';\n}\n\n/**\n * Material's expanded window width, in dp: from it Android's list-detail layout shows the list\n * pane beside the content, and below it one pane at a time.\n */\nexport const ANDROID_EXPANDED_WIDTH = 840;\n\n/** Which pane a split view shows: both side by side, or one of them as a stack's top. */\nexport type SplitViewShowing = 'both' | 'sidebar' | 'content';\n\n/**\n * How the desktop hosts draw a split view's content pane: `plain`, filling the space beside the\n * sidebar, or `inset`, a card with rounded corners inset from its space's edges, on the sidebar's\n * backdrop, which runs under the toolbar or header bar.\n */\nexport type SplitViewContentStyle = 'plain' | 'inset';\n\n/** The content pane: everything in a `<split-view>` but its `<sidebar>`. */\n@Component({\n selector: 'split-view-content',\n template: '<ng-content />',\n host: {\n '[style.display]': \"split.showing() === 'sidebar' ? 'none' : undefined\",\n '[contentStyle]': 'split.onDesktop ? split.contentStyle() : undefined',\n },\n styles: ':host { flex: 1; }',\n})\nexport class SplitViewContent extends ViewBase {\n protected readonly split = inject(SplitView);\n}\n\n/**\n * A sidebar beside the app's content:\n *\n * <split-view>\n * <sidebar [(collapsed)]=\"hidden\">\n * <sidebar-section title=\"Library\">\n * <sidebar-item path=\"songs\" label=\"Songs\" sfSymbol=\"music.note\" />\n * </sidebar-section>\n * </sidebar>\n * <router-outlet />\n * </split-view>\n *\n * On macOS the first one in a window becomes its NSSplitViewController, with the full-height\n * sidebar and the toolbar's sidebar button; a nested or second one is a plain NSSplitView. On an\n * iPad it is a UISplitViewController, whose sidebar column holds the sidebar's rows drawn here,\n * and which collapses into a stack itself at a compact width (Slide Over, a narrow Split View),\n * the sidebar its root. On an iPhone and Android it is drawn: two columns, and at a compact width (`Screen.compact`) a stack whose\n * root is the sidebar. On Android the columns wait for Material's expanded width,\n * `ANDROID_EXPANDED_WIDTH`, as its list-detail layout does. There, choosing an item shows the content, and `showSidebar()` (or\n * Android's back button) returns to the sidebar.\n *\n * `contentStyle=\"inset\"` draws the content pane on macOS and Linux as a card with rounded corners,\n * inset from its space's edges on the sidebar's backdrop, which runs under the toolbar. The pane's\n * size, and so its layout, is the card's. iOS and Android ignore it.\n */\n@Component({\n selector: 'split-view',\n imports: [SplitViewContent],\n template: `\n <ng-content select=\"sidebar\" />\n <split-view-content><ng-content /></split-view-content>\n `,\n styles: ':host { flex: 1; }',\n host: { '[style.flexDirection]': \"drawn && !stacked() ? 'row' : undefined\" },\n})\nexport class SplitView extends ViewBase {\n /**\n * macOS and Linux: the content pane `plain`, beside the sidebar, or `inset`, a rounded card on\n * the sidebar's backdrop. iOS and Android ignore it.\n */\n readonly contentStyle = input<SplitViewContentStyle>('plain');\n\n /** Whether this split view is drawn from views here, rather than by the host. */\n readonly drawn = !hostDraws('split-view');\n /** Whether the host is iOS's, whose split view controller pushes and pops the content. */\n private readonly stacksNatively = !this.drawn && nativePlatform() === 'ios';\n /** Whether the desktop host draws this split view: on macOS and Linux. */\n readonly onDesktop = !this.drawn && !this.stacksNatively;\n private readonly screen = inject(Screen);\n /** Too narrow for the panes side by side: below Material's expanded width on Android. */\n private readonly compact = computed(() =>\n nativePlatform() === 'android'\n ? this.screen.window().width < ANDROID_EXPANDED_WIDTH\n : this.screen.compact(),\n );\n private readonly top = signal<'sidebar' | 'content'>('sidebar');\n /** Its `<sidebar>`, a child of its own, as the sidebar pane takes only those. */\n private readonly sidebar = contentChild(SIDEBAR, { descendants: false });\n\n /** Whether the panes are a stack, one at a time: at a compact width, where it is drawn. */\n readonly stacked: Signal<boolean> = computed(() => this.drawn && this.compact());\n\n /** Which pane is showing. Both, unless the split view is a stack. */\n readonly showing: Signal<SplitViewShowing> = computed(() =>\n this.stacked() ? this.top() : 'both',\n );\n\n constructor() {\n super();\n const stop = inject(HardwareBack).handle(() => this.showSidebar());\n inject(DestroyRef).onDestroy(stop);\n afterNextRender(() => {\n if (this.sidebar()) return;\n if (typeof ngDevMode !== 'undefined' && !ngDevMode) return;\n console.warn(\n '[angular-native] A <split-view> has no <sidebar> of its own, so its sidebar pane is ' +\n 'empty: on macOS it draws no divider. Put a <sidebar> in it as a child of its own.',\n );\n });\n }\n\n /** Show the content over the sidebar, where the panes are a stack. A choice in the sidebar does. */\n showContent(): void {\n this.top.set('content');\n if (this.stacksNatively) this.engine.dispatchCommand(this.node, 'showContent');\n }\n\n /**\n * Go back to the sidebar, where the panes are a stack and the content is in front. Whether it\n * did, so Android's back button leaves the app from the sidebar.\n */\n showSidebar(): boolean {\n if (this.stacksNatively) this.engine.dispatchCommand(this.node, 'showSidebar');\n if (this.showing() !== 'content') return false;\n this.top.set('sidebar');\n return true;\n }\n}\n"]}
@@ -25,6 +25,11 @@ export declare function cancelAnimation(_value: unknown): void;
25
25
  /** What `@ng-native/components/reanimated` itself starts a style with; nothing runs it here. */
26
26
  export declare function startMapper(_worklet: () => void, _inputs?: unknown[]): number;
27
27
  export declare function stopMapper(_id: number): void;
28
+ /**
29
+ * What `@ng-native/components/reanimated` asks before it reads the values Reanimated's views
30
+ * settled on. Off: with no UI thread there are none to read.
31
+ */
32
+ export declare function getStaticFeatureFlag(_name: string): boolean;
28
33
  export declare const Extrapolation: {
29
34
  readonly IDENTITY: "identity";
30
35
  readonly CLAMP: "clamp";
@@ -39,6 +39,13 @@ export function startMapper(_worklet, _inputs) {
39
39
  return 0;
40
40
  }
41
41
  export function stopMapper(_id) { }
42
+ /**
43
+ * What `@ng-native/components/reanimated` asks before it reads the values Reanimated's views
44
+ * settled on. Off: with no UI thread there are none to read.
45
+ */
46
+ export function getStaticFeatureFlag(_name) {
47
+ return false;
48
+ }
42
49
  export const Extrapolation = { IDENTITY: 'identity', CLAMP: 'clamp', EXTEND: 'extend' };
43
50
  /** Past an end of the input range: the end's output, the input itself, or `undefined` to extend. */
44
51
  function beyond(x, output, how) {
@@ -1 +1 @@
1
- {"version":3,"file":"reanimated.js","sourceRoot":"","sources":["../../src/stand-ins/reanimated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKlE,MAAM,MAAM,GAAG,CAAI,EAAK,EAAE,QAAc,EAAK,EAAE;IAC7C,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,UAAU,UAAU,CAAI,EAAK,EAAE,OAAgB,EAAE,QAAe;IACpE,OAAO,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,EAAK,EAAE,OAAgB,EAAE,QAAe;IACpE,OAAO,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAA8B,EAAE,QAAe;IACvE,OAAO,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,MAAc,EAAE,SAAY;IACvD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,GAAG,UAAe;IAChD,OAAO,U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AAO,EAAE,KAAK;IACd,IAAI,EAAE,KAAK;IACX,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,KAAK;IACf,EAAE,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;IAC7C,GAAG,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;IAC9C,KAAK,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;CACjD,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAW,CAAC;AAE5F,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/**\n * `react-native-reanimated` where there is no UI-thread runtime: a browser build and a test, which\n * resolve the library here (`ngNativeWeb()` and `@ng-native/testing`).\n *\n * An animation finishes the moment it is assigned: `withTiming(100)` is `100`, and its callback\n * is called with `true` at once, so the value is where the animation ends and what ends it runs.\n * `interpolate` and `Extrapolation` are the library's own arithmetic; `Easing` curves are the\n * identity, since nothing is ever between an animation's ends.\n *\n * ponytail: the functions apps call from components, not the React hooks; add one when an app\n * imports it.\n */\nexport { sharedValue as makeMutable } from '../reanimated-web.ts';\nexport type { MutableValue as SharedValue } from '../worklets.ts';\n\ntype Done = ((finished?: boolean) => void) | undefined;\n\nconst settle = <T>(to: T, callback: Done): T => {\n callback?.(true);\n return to;\n};\n\nexport function withTiming<T>(to: T, _config?: object, callback?: Done): T {\n return settle(to, callback);\n}\n\nexport function withSpring<T>(to: T, _config?: object, callback?: Done): T {\n return settle(to, callback);\n}\n\nexport function withDecay(_config: { velocity?: number }, callback?: Done): number {\n return settle(0, callback);\n}\n\nexport function withDelay<T>(_delay: number, animation: T): T {\n return animation;\n}\n\nexport function withSequence<T>(...animations: T[]): T {\n return animations[animations.length - 1]!;\n}\n\nexport function withRepeat<T>(\n animation: T,\n _times?: number,\n _reverse?: boolean,\n callback?: Done,\n): T {\n return settle(animation, callback);\n}\n\nexport function cancelAnimation(_value: unknown): void {}\n\n/** What `@ng-native/components/reanimated` itself starts a style with; nothing runs it here. */\nexport function startMapper(_worklet: () => void, _inputs?: unknown[]): number {\n return 0;\n}\n\nexport function stopMapper(_id: number): void {}\n\nexport const Extrapolation = { IDENTITY: 'identity', CLAMP: 'clamp', EXTEND: 'extend' } as const;\ntype Extrapolate = (typeof Extrapolation)[keyof typeof Extrapolation];\n\n/** Past an end of the input range: the end's output, the input itself, or `undefined` to extend. */\nfunction beyond(x: number, output: number, how: Extrapolate | undefined): number | undefined {\n if (how === 'clamp') return output;\n if (how === 'identity') return x;\n return undefined;\n}\n\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n extrapolate?: Extrapolate | { extrapolateLeft?: Extrapolate; extrapolateRight?: Extrapolate },\n): number {\n const left = typeof extrapolate === 'object' ? extrapolate.extrapolateLeft : extrapolate;\n const right = typeof extrapolate === 'object' ? extrapolate.extrapolateRight : extrapolate;\n const last = input.length - 1;\n const outside =\n x < input[0]!\n ? beyond(x, output[0]!, left)\n : x > input[last]!\n ? beyond(x, output[last]!, right)\n : undefined;\n if (outside !== undefined) return outside;\n let i = 0;\n while (i < last - 1 && x > input[i + 1]!) i++;\n const [a, b, p, q] = [input[i]!, input[i + 1]!, output[i]!, output[i + 1]!];\n return b === a ? p : p + ((x - a) / (b - a)) * (q - p);\n}\n\nconst identity = (t: number) => t;\nconst curve = () => identity;\nexport const Easing = {\n linear: identity,\n ease: identity,\n quad: identity,\n cubic: identity,\n sin: identity,\n circle: identity,\n exp: identity,\n bounce: identity,\n poly: curve,\n elastic: curve,\n back: curve,\n bezier: curve,\n bezierFn: curve,\n in: (easing: (t: number) => number) => easing,\n out: (easing: (t: number) => number) => easing,\n inOut: (easing: (t: number) => number) => easing,\n};\n\nexport const ReduceMotion = { System: 'system', Always: 'always', Never: 'never' } as const;\n\nexport function runOnJS<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n\nexport function runOnUI<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n"]}
1
+ {"version":3,"file":"reanimated.js","sourceRoot":"","sources":["../../src/stand-ins/reanimated.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,WAAW,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKlE,MAAM,MAAM,GAAG,CAAI,EAAK,EAAE,QAAc,EAAK,EAAE;IAC7C,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC;IACjB,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF,MAAM,UAAU,UAAU,CAAI,EAAK,EAAE,OAAgB,EAAE,QAAe;IACpE,OAAO,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,UAAU,CAAI,EAAK,EAAE,OAAgB,EAAE,QAAe;IACpE,OAAO,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAA8B,EAAE,QAAe;IACvE,OAAO,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,SAAS,CAAI,MAAc,EAAE,SAAY;IACvD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,YAAY,CAAI,GAAG,UAAe;IAChD,OAAO,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,SAAY,EACZ,MAAe,EACf,QAAkB,EAClB,QAAe;IAEf,OAAO,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,eAAe,CAA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C,GAAG,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;IAC9C,KAAK,EAAE,CAAC,MAA6B,EAAE,EAAE,CAAC,MAAM;CACjD,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAW,CAAC;AAE5F,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,OAAO,CAAyB,EAAqB;IACnE,OAAO,EAAE,CAAC;AACZ,CAAC","sourcesContent":["/**\n * `react-native-reanimated` where there is no UI-thread runtime: a browser build and a test, which\n * resolve the library here (`ngNativeWeb()` and `@ng-native/testing`).\n *\n * An animation finishes the moment it is assigned: `withTiming(100)` is `100`, and its callback\n * is called with `true` at once, so the value is where the animation ends and what ends it runs.\n * `interpolate` and `Extrapolation` are the library's own arithmetic; `Easing` curves are the\n * identity, since nothing is ever between an animation's ends.\n *\n * ponytail: the functions apps call from components, not the React hooks; add one when an app\n * imports it.\n */\nexport { sharedValue as makeMutable } from '../reanimated-web.ts';\nexport type { MutableValue as SharedValue } from '../worklets.ts';\n\ntype Done = ((finished?: boolean) => void) | undefined;\n\nconst settle = <T>(to: T, callback: Done): T => {\n callback?.(true);\n return to;\n};\n\nexport function withTiming<T>(to: T, _config?: object, callback?: Done): T {\n return settle(to, callback);\n}\n\nexport function withSpring<T>(to: T, _config?: object, callback?: Done): T {\n return settle(to, callback);\n}\n\nexport function withDecay(_config: { velocity?: number }, callback?: Done): number {\n return settle(0, callback);\n}\n\nexport function withDelay<T>(_delay: number, animation: T): T {\n return animation;\n}\n\nexport function withSequence<T>(...animations: T[]): T {\n return animations[animations.length - 1]!;\n}\n\nexport function withRepeat<T>(\n animation: T,\n _times?: number,\n _reverse?: boolean,\n callback?: Done,\n): T {\n return settle(animation, callback);\n}\n\nexport function cancelAnimation(_value: unknown): void {}\n\n/** What `@ng-native/components/reanimated` itself starts a style with; nothing runs it here. */\nexport function startMapper(_worklet: () => void, _inputs?: unknown[]): number {\n return 0;\n}\n\nexport function stopMapper(_id: number): void {}\n\n/**\n * What `@ng-native/components/reanimated` asks before it reads the values Reanimated's views\n * settled on. Off: with no UI thread there are none to read.\n */\nexport function getStaticFeatureFlag(_name: string): boolean {\n return false;\n}\n\nexport const Extrapolation = { IDENTITY: 'identity', CLAMP: 'clamp', EXTEND: 'extend' } as const;\ntype Extrapolate = (typeof Extrapolation)[keyof typeof Extrapolation];\n\n/** Past an end of the input range: the end's output, the input itself, or `undefined` to extend. */\nfunction beyond(x: number, output: number, how: Extrapolate | undefined): number | undefined {\n if (how === 'clamp') return output;\n if (how === 'identity') return x;\n return undefined;\n}\n\nexport function interpolate(\n x: number,\n input: readonly number[],\n output: readonly number[],\n extrapolate?: Extrapolate | { extrapolateLeft?: Extrapolate; extrapolateRight?: Extrapolate },\n): number {\n const left = typeof extrapolate === 'object' ? extrapolate.extrapolateLeft : extrapolate;\n const right = typeof extrapolate === 'object' ? extrapolate.extrapolateRight : extrapolate;\n const last = input.length - 1;\n const outside =\n x < input[0]!\n ? beyond(x, output[0]!, left)\n : x > input[last]!\n ? beyond(x, output[last]!, right)\n : undefined;\n if (outside !== undefined) return outside;\n let i = 0;\n while (i < last - 1 && x > input[i + 1]!) i++;\n const [a, b, p, q] = [input[i]!, input[i + 1]!, output[i]!, output[i + 1]!];\n return b === a ? p : p + ((x - a) / (b - a)) * (q - p);\n}\n\nconst identity = (t: number) => t;\nconst curve = () => identity;\nexport const Easing = {\n linear: identity,\n ease: identity,\n quad: identity,\n cubic: identity,\n sin: identity,\n circle: identity,\n exp: identity,\n bounce: identity,\n poly: curve,\n elastic: curve,\n back: curve,\n bezier: curve,\n bezierFn: curve,\n in: (easing: (t: number) => number) => easing,\n out: (easing: (t: number) => number) => easing,\n inOut: (easing: (t: number) => number) => easing,\n};\n\nexport const ReduceMotion = { System: 'system', Always: 'always', Never: 'never' } as const;\n\nexport function runOnJS<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n\nexport function runOnUI<A extends unknown[], R>(fn: (...args: A) => R): (...args: A) => R {\n return fn;\n}\n"]}
@@ -30,9 +30,14 @@ export declare class StickyHeaders {
30
30
  private readonly listening;
31
31
  /** The translation last written per header, so an unchanged one is not written again. */
32
32
  private readonly written;
33
+ /** Each header's native drive, with the axis and range it moves along. */
33
34
  private readonly drives;
34
35
  private settleTimer;
36
+ /** Where native last said the scroll view was, and along which axis: none until it has. */
35
37
  private offset;
38
+ private offsetAxis;
39
+ /** Whether scrolling has paused: no scroll event is coming to draw a drive native is given. */
40
+ private resting;
36
41
  constructor(engine: HostEngine, scroll: HostNode, horizontal: () => boolean);
37
42
  private readonly scroll;
38
43
  /** Find the sticky children again, after a pass that may have changed them. */
@@ -40,7 +45,21 @@ export declare class StickyHeaders {
40
45
  scrolled(offset: number): void;
41
46
  destroy(): void;
42
47
  private measured;
48
+ /**
49
+ * Where a child is in the content now, for one that turns sticky after it was laid out: native
50
+ * sends a layout event only when a view's layout changes, so none comes for it. RN's ScrollView
51
+ * gets one by wrapping the child in a new view. Measured against the content view, both in the
52
+ * window, as native answers; a child not committed yet is measured by its layout event instead.
53
+ */
54
+ private measureNow;
43
55
  private release;
56
+ private axis;
57
+ /**
58
+ * Hand a header to native to move along the scroll view's axis, made again when the axis changes.
59
+ * A drive made, or given a new range, at rest has no scroll event coming to draw it, so native is
60
+ * told where it last said the scroll view was, unless that was along the other axis. Mid-scroll
61
+ * the next event draws it.
62
+ */
44
63
  private drive;
45
64
  /** `ScrollViewStickyHeader`'s interpolation, as plain arithmetic. */
46
65
  private apply;
@@ -1,4 +1,4 @@
1
- import { pinnedRange } from '@ng-native/fabric';
1
+ import { pinnedRange, } from '@ng-native/fabric';
2
2
  /**
3
3
  * How long scrolling has to pause before a natively moved header's translate is written, so the
4
4
  * shadow tree, which a touch is hit-tested against, catches up with where native drew it. RN's
@@ -30,9 +30,14 @@ export class StickyHeaders {
30
30
  listening = new Map();
31
31
  /** The translation last written per header, so an unchanged one is not written again. */
32
32
  written = new Map();
33
+ /** Each header's native drive, with the axis and range it moves along. */
33
34
  drives = new Map();
34
35
  settleTimer;
36
+ /** Where native last said the scroll view was, and along which axis: none until it has. */
35
37
  offset = 0;
38
+ offsetAxis = null;
39
+ /** Whether scrolling has paused: no scroll event is coming to draw a drive native is given. */
40
+ resting = true;
36
41
  constructor(engine, scroll, horizontal) {
37
42
  this.engine = engine;
38
43
  this.scroll = scroll;
@@ -52,16 +57,26 @@ export class StickyHeaders {
52
57
  continue;
53
58
  this.engine.setProp(node, 'zIndex', 10);
54
59
  this.listening.set(node, this.engine.setEventListener(node, 'topLayout', (event) => this.measured(node, event)));
60
+ if (content)
61
+ this.measureNow(node, content);
55
62
  }
63
+ // With nothing sticky nothing hears the scroll view, so where it was last heard goes stale.
64
+ if (headers.length === 0)
65
+ this.offsetAxis = null;
56
66
  this.headers = headers;
57
67
  this.apply();
58
68
  }
59
69
  scrolled(offset) {
60
70
  this.offset = offset;
71
+ this.offsetAxis = this.axis();
61
72
  if (!this.engine.drivesScroll)
62
73
  return this.apply();
74
+ this.resting = false;
63
75
  clearTimeout(this.settleTimer);
64
- this.settleTimer = setTimeout(() => this.apply(), STICKY_SETTLE_MS);
76
+ this.settleTimer = setTimeout(() => {
77
+ this.resting = true;
78
+ this.apply();
79
+ }, STICKY_SETTLE_MS);
65
80
  }
66
81
  destroy() {
67
82
  clearTimeout(this.settleTimer);
@@ -80,31 +95,73 @@ export class StickyHeaders {
80
95
  });
81
96
  this.apply();
82
97
  }
98
+ /**
99
+ * Where a child is in the content now, for one that turns sticky after it was laid out: native
100
+ * sends a layout event only when a view's layout changes, so none comes for it. RN's ScrollView
101
+ * gets one by wrapping the child in a new view. Measured against the content view, both in the
102
+ * window, as native answers; a child not committed yet is measured by its layout event instead.
103
+ */
104
+ measureNow(node, content) {
105
+ let own;
106
+ let box;
107
+ const both = () => {
108
+ if (!own || !box || this.extents.has(node) || !this.listening.has(node))
109
+ return;
110
+ const horizontal = this.horizontal();
111
+ this.extents.set(node, {
112
+ start: horizontal ? own.x - box.x : own.y - box.y,
113
+ size: horizontal ? own.width : own.height,
114
+ });
115
+ this.apply();
116
+ };
117
+ this.engine.measure(node, (frame) => ((own = frame), both()));
118
+ this.engine.measure(content, (frame) => ((box = frame), both()));
119
+ }
83
120
  release(node) {
84
121
  this.listening.get(node)?.();
85
122
  this.listening.delete(node);
86
123
  this.extents.delete(node);
87
124
  this.written.delete(node);
88
- this.drives.get(node)?.stop();
125
+ this.drives.get(node)?.drive.stop();
89
126
  this.drives.delete(node);
90
127
  this.engine.setProp(node, 'zIndex', undefined);
91
128
  this.engine.setProp(node, 'transform', undefined);
92
129
  }
130
+ axis() {
131
+ return this.horizontal() ? 'x' : 'y';
132
+ }
133
+ /**
134
+ * Hand a header to native to move along the scroll view's axis, made again when the axis changes.
135
+ * A drive made, or given a new range, at rest has no scroll event coming to draw it, so native is
136
+ * told where it last said the scroll view was, unless that was along the other axis. Mid-scroll
137
+ * the next event draws it.
138
+ */
93
139
  drive(node, start, stop) {
94
140
  if (!this.engine.drivesScroll)
95
141
  return;
96
142
  const range = pinnedRange(start, stop);
97
- const drive = this.drives.get(node);
143
+ const key = JSON.stringify(range);
144
+ const axis = this.axis();
145
+ const held = this.drives.get(node);
146
+ // Not a position native never gave: 0 would move every view on this scroll view's offset.
147
+ const from = this.resting && this.offsetAxis === axis ? this.offset : undefined;
148
+ if (held?.axis === axis) {
149
+ if (held.range === key)
150
+ return held.drive.update(range);
151
+ held.range = key;
152
+ return held.drive.update(range, from);
153
+ }
154
+ held?.drive.stop();
155
+ this.drives.delete(node);
156
+ const drive = this.engine.driveByScroll(node, this.scroll, axis, range, [], from);
98
157
  if (drive)
99
- return drive.update(range);
100
- const axis = this.horizontal() ? 'x' : 'y';
101
- const next = this.engine.driveByScroll(node, this.scroll, axis, range);
102
- if (next)
103
- this.drives.set(node, next);
158
+ this.drives.set(node, { drive, axis, range: key });
104
159
  }
105
160
  /** `ScrollViewStickyHeader`'s interpolation, as plain arithmetic. */
106
161
  apply() {
107
162
  const key = this.horizontal() ? 'translateX' : 'translateY';
163
+ // What native said along the other axis says nothing of this one.
164
+ const offset = this.offsetAxis === this.axis() ? this.offset : 0;
108
165
  this.headers.forEach((node, at) => {
109
166
  const own = this.extents.get(node);
110
167
  if (!own)
@@ -112,7 +169,7 @@ export class StickyHeaders {
112
169
  const next = this.extents.get(this.headers[at + 1]);
113
170
  const stop = next ? next.start - own.size : Infinity;
114
171
  this.drive(node, own.start, stop);
115
- const shift = Math.min(Math.max(0, this.offset - own.start), Math.max(0, stop - own.start));
172
+ const shift = Math.min(Math.max(0, offset - own.start), Math.max(0, stop - own.start));
116
173
  if (this.written.get(node) === shift)
117
174
  return;
118
175
  this.written.set(node, shift);
@@ -1 +1 @@
1
- {"version":3,"file":"sticky-headers.js","sourceRoot":"","sources":["../src/sticky-headers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoD,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOlG;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAMnC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,aAAa;IACP,MAAM,CAAa;IACnB,UAAU,CAAgB;IACnC,OAAO,GAAe,EAAE,CAAC;IAChB,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,SAAS,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC7D,yFAAyF;IACxE,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtC,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IACnD,WAAW,CAA4C;IACvD,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,MAAkB,EAAE,MAAgB,EAAE,UAAyB;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM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G,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,GAAG;gBAAE,OAAO;YACjB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,CAAE,CAAC,CAAC;YACrD,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;YACrD,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YAClC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YAC5F,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK;gBAAE,OAAO;YAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { type HostEngine, type HostNode, type ScrollDrive, pinnedRange } from '@ng-native/fabric';\n\ninterface Extent {\n readonly start: number;\n readonly size: number;\n}\n\n/**\n * How long scrolling has to pause before a natively moved header's translate is written, so the\n * shadow tree, which a touch is hit-tested against, catches up with where native drew it. RN's\n * `ScrollViewStickyHeader` debounces the same write, by 64 ms on iOS.\n */\nexport const STICKY_SETTLE_MS = 64;\n\ntype LayoutEvent = {\n nativeEvent?: { layout?: { x?: number; y?: number; width?: number; height?: number } };\n};\n\n/**\n * `stickyHeaderIndices` for `<scroll-view>`, done the way RN's `ScrollView.js` does it.\n *\n * There is no native prop for it on either platform. RN wraps each sticky child in\n * `ScrollViewStickyHeader`, which translates it by the scroll offset past its own position and\n * stops where the next sticky child would push it off. The same sums run here, over the content\n * view's element children: control-flow anchors are not children in RN's sense and are skipped,\n * so an index counts what is committed.\n *\n * Each sticky child's position comes from its own layout event, and the translation is written\n * as its `transform` prop, with RN's `zIndex: 10` so it draws over the content scrolling under\n * it. A style of the caller's own that sets either wins, as it would in RN.\n *\n * Where the host can, native moves each one on every frame the scroll view moves, as RN's\n * animated interpolation does, and the translation is written only once scrolling pauses: a\n * translate written from each scroll event lands late, and on a fast fling the header shudders.\n */\nexport class StickyHeaders {\n private readonly engine: HostEngine;\n private readonly horizontal: () => boolean;\n private headers: HostNode[] = [];\n private readonly extents = new Map<HostNode, Extent>();\n private readonly listening = new Map<HostNode, () => void>();\n /** The translation last written per header, so an unchanged one is not written again. */\n private readonly written = new Map<HostNode, number>();\n private readonly drives = new Map<HostNode, ScrollDrive>();\n private settleTimer: ReturnType<typeof setTimeout> | undefined;\n private offset = 0;\n\n constructor(engine: HostEngine, scroll: HostNode, horizontal: () => boolean) {\n this.engine = engine;\n this.scroll = scroll;\n this.horizontal = horizontal;\n }\n\n private readonly scroll: HostNode;\n\n /** Find the sticky children again, after a pass that may have changed them. */\n track(content: HostNode | undefined, indices: readonly number[]): void {\n const children = (content?.childList ?? []).filter((child) => child.nodeKind === 'element');\n const headers = indices.flatMap((index) => children[index] ?? []);\n for (const node of this.headers) {\n if (!headers.includes(node)) this.release(node);\n }\n for (const node of headers) {\n if (this.listening.has(node)) continue;\n this.engine.setProp(node, 'zIndex', 10);\n this.listening.set(\n node,\n this.engine.setEventListener(node, 'topLayout', (event) => this.measured(node, event)),\n );\n }\n this.headers = headers;\n this.apply();\n }\n\n scrolled(offset: number): void {\n this.offset = offset;\n if (!this.engine.drivesScroll) return this.apply();\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => this.apply(), STICKY_SETTLE_MS);\n }\n\n destroy(): void {\n clearTimeout(this.settleTimer);\n for (const node of this.headers) this.release(node);\n this.headers = [];\n }\n\n private measured(node: HostNode, event: unknown): void {\n const layout = (event as LayoutEvent).nativeEvent?.layout;\n if (!layout) return;\n const horizontal = this.horizontal();\n this.extents.set(node, {\n start: (horizontal ? layout.x : layout.y) ?? 0,\n size: (horizontal ? layout.width : layout.height) ?? 0,\n });\n this.apply();\n }\n\n private release(node: HostNode): void {\n this.listening.get(node)?.();\n this.listening.delete(node);\n this.extents.delete(node);\n this.written.delete(node);\n this.drives.get(node)?.stop();\n this.drives.delete(node);\n this.engine.setProp(node, 'zIndex', undefined);\n this.engine.setProp(node, 'transform', undefined);\n }\n\n private drive(node: HostNode, start: number, stop: number): void {\n if (!this.engine.drivesScroll) return;\n const range = pinnedRange(start, stop);\n const drive = this.drives.get(node);\n if (drive) return drive.update(range);\n const axis = this.horizontal() ? 'x' : 'y';\n const next = this.engine.driveByScroll(node, this.scroll, axis, range);\n if (next) this.drives.set(node, next);\n }\n\n /** `ScrollViewStickyHeader`'s interpolation, as plain arithmetic. */\n private apply(): void {\n const key = this.horizontal() ? 'translateX' : 'translateY';\n this.headers.forEach((node, at) => {\n const own = this.extents.get(node);\n if (!own) return;\n const next = this.extents.get(this.headers[at + 1]!);\n const stop = next ? next.start - own.size : Infinity;\n this.drive(node, own.start, stop);\n const shift = Math.min(Math.max(0, this.offset - own.start), Math.max(0, stop - own.start));\n if (this.written.get(node) === shift) return;\n this.written.set(node, shift);\n this.engine.setProp(node, 'transform', shift > 0 ? [{ [key]: shift }] : undefined);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"sticky-headers.js","sourceRoot":"","sources":["../src/sticky-headers.ts"],"names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AE,OAAO;YAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC9B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACrF,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import {\n type HostEngine,\n type HostNode,\n type ScrollDrive,\n type WindowFrame,\n pinnedRange,\n} from '@ng-native/fabric';\n\ninterface Extent {\n readonly start: number;\n readonly size: number;\n}\n\n/**\n * How long scrolling has to pause before a natively moved header's translate is written, so the\n * shadow tree, which a touch is hit-tested against, catches up with where native drew it. RN's\n * `ScrollViewStickyHeader` debounces the same write, by 64 ms on iOS.\n */\nexport const STICKY_SETTLE_MS = 64;\n\ntype LayoutEvent = {\n nativeEvent?: { layout?: { x?: number; y?: number; width?: number; height?: number } };\n};\n\n/**\n * `stickyHeaderIndices` for `<scroll-view>`, done the way RN's `ScrollView.js` does it.\n *\n * There is no native prop for it on either platform. RN wraps each sticky child in\n * `ScrollViewStickyHeader`, which translates it by the scroll offset past its own position and\n * stops where the next sticky child would push it off. The same sums run here, over the content\n * view's element children: control-flow anchors are not children in RN's sense and are skipped,\n * so an index counts what is committed.\n *\n * Each sticky child's position comes from its own layout event, and the translation is written\n * as its `transform` prop, with RN's `zIndex: 10` so it draws over the content scrolling under\n * it. A style of the caller's own that sets either wins, as it would in RN.\n *\n * Where the host can, native moves each one on every frame the scroll view moves, as RN's\n * animated interpolation does, and the translation is written only once scrolling pauses: a\n * translate written from each scroll event lands late, and on a fast fling the header shudders.\n */\nexport class StickyHeaders {\n private readonly engine: HostEngine;\n private readonly horizontal: () => boolean;\n private headers: HostNode[] = [];\n private readonly extents = new Map<HostNode, Extent>();\n private readonly listening = new Map<HostNode, () => void>();\n /** The translation last written per header, so an unchanged one is not written again. */\n private readonly written = new Map<HostNode, number>();\n /** Each header's native drive, with the axis and range it moves along. */\n private readonly drives = new Map<\n HostNode,\n { drive: ScrollDrive; axis: 'x' | 'y'; range: string }\n >();\n private settleTimer: ReturnType<typeof setTimeout> | undefined;\n /** Where native last said the scroll view was, and along which axis: none until it has. */\n private offset = 0;\n private offsetAxis: 'x' | 'y' | null = null;\n /** Whether scrolling has paused: no scroll event is coming to draw a drive native is given. */\n private resting = true;\n\n constructor(engine: HostEngine, scroll: HostNode, horizontal: () => boolean) {\n this.engine = engine;\n this.scroll = scroll;\n this.horizontal = horizontal;\n }\n\n private readonly scroll: HostNode;\n\n /** Find the sticky children again, after a pass that may have changed them. */\n track(content: HostNode | undefined, indices: readonly number[]): void {\n const children = (content?.childList ?? []).filter((child) => child.nodeKind === 'element');\n const headers = indices.flatMap((index) => children[index] ?? []);\n for (const node of this.headers) {\n if (!headers.includes(node)) this.release(node);\n }\n for (const node of headers) {\n if (this.listening.has(node)) continue;\n this.engine.setProp(node, 'zIndex', 10);\n this.listening.set(\n node,\n this.engine.setEventListener(node, 'topLayout', (event) => this.measured(node, event)),\n );\n if (content) this.measureNow(node, content);\n }\n // With nothing sticky nothing hears the scroll view, so where it was last heard goes stale.\n if (headers.length === 0) this.offsetAxis = null;\n this.headers = headers;\n this.apply();\n }\n\n scrolled(offset: number): void {\n this.offset = offset;\n this.offsetAxis = this.axis();\n if (!this.engine.drivesScroll) return this.apply();\n this.resting = false;\n clearTimeout(this.settleTimer);\n this.settleTimer = setTimeout(() => {\n this.resting = true;\n this.apply();\n }, STICKY_SETTLE_MS);\n }\n\n destroy(): void {\n clearTimeout(this.settleTimer);\n for (const node of this.headers) this.release(node);\n this.headers = [];\n }\n\n private measured(node: HostNode, event: unknown): void {\n const layout = (event as LayoutEvent).nativeEvent?.layout;\n if (!layout) return;\n const horizontal = this.horizontal();\n this.extents.set(node, {\n start: (horizontal ? layout.x : layout.y) ?? 0,\n size: (horizontal ? layout.width : layout.height) ?? 0,\n });\n this.apply();\n }\n\n /**\n * Where a child is in the content now, for one that turns sticky after it was laid out: native\n * sends a layout event only when a view's layout changes, so none comes for it. RN's ScrollView\n * gets one by wrapping the child in a new view. Measured against the content view, both in the\n * window, as native answers; a child not committed yet is measured by its layout event instead.\n */\n private measureNow(node: HostNode, content: HostNode): void {\n let own: WindowFrame | undefined;\n let box: WindowFrame | undefined;\n const both = () => {\n if (!own || !box || this.extents.has(node) || !this.listening.has(node)) return;\n const horizontal = this.horizontal();\n this.extents.set(node, {\n start: horizontal ? own.x - box.x : own.y - box.y,\n size: horizontal ? own.width : own.height,\n });\n this.apply();\n };\n this.engine.measure(node, (frame) => ((own = frame), both()));\n this.engine.measure(content, (frame) => ((box = frame), both()));\n }\n\n private release(node: HostNode): void {\n this.listening.get(node)?.();\n this.listening.delete(node);\n this.extents.delete(node);\n this.written.delete(node);\n this.drives.get(node)?.drive.stop();\n this.drives.delete(node);\n this.engine.setProp(node, 'zIndex', undefined);\n this.engine.setProp(node, 'transform', undefined);\n }\n\n private axis(): 'x' | 'y' {\n return this.horizontal() ? 'x' : 'y';\n }\n\n /**\n * Hand a header to native to move along the scroll view's axis, made again when the axis changes.\n * A drive made, or given a new range, at rest has no scroll event coming to draw it, so native is\n * told where it last said the scroll view was, unless that was along the other axis. Mid-scroll\n * the next event draws it.\n */\n private drive(node: HostNode, start: number, stop: number): void {\n if (!this.engine.drivesScroll) return;\n const range = pinnedRange(start, stop);\n const key = JSON.stringify(range);\n const axis = this.axis();\n const held = this.drives.get(node);\n // Not a position native never gave: 0 would move every view on this scroll view's offset.\n const from = this.resting && this.offsetAxis === axis ? this.offset : undefined;\n if (held?.axis === axis) {\n if (held.range === key) return held.drive.update(range);\n held.range = key;\n return held.drive.update(range, from);\n }\n held?.drive.stop();\n this.drives.delete(node);\n const drive = this.engine.driveByScroll(node, this.scroll, axis, range, [], from);\n if (drive) this.drives.set(node, { drive, axis, range: key });\n }\n\n /** `ScrollViewStickyHeader`'s interpolation, as plain arithmetic. */\n private apply(): void {\n const key = this.horizontal() ? 'translateX' : 'translateY';\n // What native said along the other axis says nothing of this one.\n const offset = this.offsetAxis === this.axis() ? this.offset : 0;\n this.headers.forEach((node, at) => {\n const own = this.extents.get(node);\n if (!own) return;\n const next = this.extents.get(this.headers[at + 1]!);\n const stop = next ? next.start - own.size : Infinity;\n this.drive(node, own.start, stop);\n const shift = Math.min(Math.max(0, offset - own.start), Math.max(0, stop - own.start));\n if (this.written.get(node) === shift) return;\n this.written.set(node, shift);\n this.engine.setProp(node, 'transform', shift > 0 ? [{ [key]: shift }] : undefined);\n });\n }\n}\n"]}