@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 +1 @@
1
- {"version":3,"file":"reanimated.js","sourceRoot":"","sources":["../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haredValue, workletStyle } from '@ng-native/components/reanimated';\n *\n * protected readonly offset = sharedValue(0);\n * protected readonly slide = workletStyle([this.offset], (offset) => {\n * 'worklet';\n * return { transform: [{ translateX: offset.value }] };\n * });\n * ```\n * ```html\n * <view [workletStyle]=\"slide\">\n * ```\n *\n * Deliberately outside the barrel: everything here reaches React Native's\n * Flow source, which Node cannot parse, and the rest of the package has to stay loadable in the\n * test suite.\n *\n * What makes this work at all is that Reanimated addresses a view by its **shadow node**, not by a\n * React instance. `getShadowNodeWrapperFromRef` digs one out of a fiber; our engine has held the\n * same object since it created the node, so there is nothing to dig for. `startMapper` and\n * `makeMutable` are public, and the whole React half of `useAnimatedStyle` - refs, effects, the\n * animated component wrapper - is what an Angular directive replaces.\n *\n * An app installs `react-native-reanimated` and `react-native-worklets` itself, and gets the\n * worklet Babel plugin from `babel-preset-expo`, which adds it as soon as the package is present.\n * Everything else an animation needs - `withTiming`, `withSpring`, `interpolate`, `Easing` - is\n * imported from `react-native-reanimated` directly: they are plain functions with no React in\n * them, and re-exporting them here would only add a name to keep in step.\n */\nimport { Directive } from '@angular/core';\nimport { makeMutable, startMapper, stopMapper } from 'react-native-reanimated';\n/**\n * `updateProps` is what every animated style in Reanimated goes through, and there is no exported\n * equivalent. It is a worklet, so it is called from ours rather than from here.\n *\n * Two things about the import. It goes through `src/` because that is where the package's own\n * `react-native` field points and Metro prefers that field: the built `lib/` copy would be a\n * second Reanimated in the bundle, with module state of its own. And it is a `require`, so that\n * these sources stay out of our type-checking program, where they fail against settings they were\n * never written for.\n */\nconst { updateProps } = require('react-native-reanimated/src/updateProps/index.ts') as {\n updateProps(descriptors: object, updates: Record<string, unknown>): void;\n};\nimport { WorkletScrollBase } from './worklet-scroll.ts';\nimport { WorkletStyleBase } from './worklet-style.ts';\nimport { WORKLETS, type MutableValue, type WorkletBackend } from './worklets.ts';\n\nexport {\n workletScroll,\n workletStyle,\n type SharedValue,\n type WorkletScrollSpec,\n type WorkletStyleSpec,\n} from './worklets.ts';\nexport { releaseOnDestroy } from './release-on-destroy.ts';\n\n/**\n * A value both runtimes can see. Reanimated's own `useSharedValue` is this plus a React ref, and\n * the ref is the half that does not apply here. Typed with the shape of Reanimated's own, so it\n * goes to `cancelAnimation` and the rest of the library as one of theirs would.\n */\nexport function sharedValue<T>(initial: T): MutableValue<T> {\n return makeMutable(initial);\n}\n\nconst backend: WorkletBackend = {\n bind: (target, style) => {\n // The shape `updateProps` takes: a `{ value }` holder of descriptors, so that the set of\n // views a style drives can change without the worklet being rebuilt. Ours never does - one\n // directive drives one node - so a plain object is enough.\n const descriptors = { value: [{ tag: target.tag, shadowNodeWrapper: target.shadowNode }] };\n const { values, updater } = style;\n const id = startMapper(() => {\n 'worklet';\n updateProps(descriptors, updater(...values));\n }, values as unknown[]);\n return () => stopMapper(id);\n },\n\n scroll: (target, spec) => {\n const { values, handler } = spec;\n // The same registration a gesture uses, on the name React Native's scroll views emit. The\n // event still reaches our own listeners: Reanimated observes it rather than consuming it.\n const id = registerEventHandler(\n (event: never) => {\n 'worklet';\n handler(event, ...values);\n },\n 'onScroll',\n target.tag,\n );\n return () => unregisterEventHandler(id);\n },\n};\n\n/**\n * Not public, and the same call Reanimated's own `WorkletEventHandler` makes. Reached through\n * `src/` for the reason `updateProps` is, and required rather than imported so that those sources\n * stay out of our type-checking program.\n */\nconst { registerEventHandler, unregisterEventHandler } =\n require('react-native-reanimated/src/core.ts') as {\n registerEventHandler(\n worklet: (event: never) => void,\n eventName: string,\n emitterReactTag: number,\n ): number;\n unregisterEventHandler(id: number): void;\n };\n\n@Directive({\n selector: '[workletStyle]',\n providers: [{ provide: WORKLETS, useValue: backend }],\n})\nexport class WorkletStyle extends WorkletStyleBase {}\n\n@Directive({\n selector: '[workletScroll]',\n providers: [{ provide: WORKLETS, useValue: backend }],\n})\nexport class WorkletScroll extends WorkletScrollBase {}\n"]}
1
+ {"version":3,"file":"reanimated.js","sourceRoot":"","sources":["../src/reanimated.ts"],"names":[],"mappings":"AAAA;;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S;mBAAC;oBACT,QAAQ,EAAE,gBAAgB;oBAC1B,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;iBACtD;;AAOD,MAAM,OAAO,aAAc,SAAQ,iBAAiB;uGAAvC,aAAa;2FAAb,aAAa,8DAFb,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;;2FAE1C,aAAa;kBAJzB,SAAS;mBAAC;oBACT,QAAQ,EAAE,iBAAiB;oBAC3B,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;iBACtD","sourcesContent":["/**\n * Reanimated, without React: a style computed on the UI thread, bound to one of our nodes.\n *\n * ```ts\n * import { WorkletStyle, sharedValue, workletStyle } from '@ng-native/components/reanimated';\n *\n * protected readonly offset = sharedValue(0);\n * protected readonly slide = workletStyle([this.offset], (offset) => {\n * 'worklet';\n * return { transform: [{ translateX: offset.value }] };\n * });\n * ```\n * ```html\n * <view [workletStyle]=\"slide\">\n * ```\n *\n * Deliberately outside the barrel: everything here reaches React Native's\n * Flow source, which Node cannot parse, and the rest of the package has to stay loadable in the\n * test suite.\n *\n * What makes this work at all is that Reanimated addresses a view by its **shadow node**, not by a\n * React instance. `getShadowNodeWrapperFromRef` digs one out of a fiber; our engine has held the\n * same object since it created the node, so there is nothing to dig for. `startMapper` and\n * `makeMutable` are public, and the whole React half of `useAnimatedStyle` - refs, effects, the\n * animated component wrapper - is what an Angular directive replaces.\n *\n * An app installs `react-native-reanimated` and `react-native-worklets` itself, and gets the\n * worklet Babel plugin from `babel-preset-expo`, which adds it as soon as the package is present.\n * Everything else an animation needs - `withTiming`, `withSpring`, `interpolate`, `Easing` - is\n * imported from `react-native-reanimated` directly: they are plain functions with no React in\n * them, and re-exporting them here would only add a name to keep in step.\n */\nimport { Directive } from '@angular/core';\nimport {\n getStaticFeatureFlag,\n makeMutable,\n startMapper,\n stopMapper,\n} from 'react-native-reanimated';\n/**\n * `updateProps` is what every animated style in Reanimated goes through, and there is no exported\n * equivalent. It is a worklet, so it is called from ours rather than from here.\n *\n * Two things about the import. It goes through `src/` because that is where the package's own\n * `react-native` field points and Metro prefers that field: the built `lib/` copy would be a\n * second Reanimated in the bundle, with module state of its own. And it is a `require`, so that\n * these sources stay out of our type-checking program, where they fail against settings they were\n * never written for.\n */\nconst { updateProps } = require('react-native-reanimated/src/updateProps/index.ts') as {\n updateProps(descriptors: object, updates: Record<string, unknown>): void;\n};\nimport { settledReader, type SettledSource, type Unprocess } from './settled-updates.ts';\nimport { WorkletScrollBase } from './worklet-scroll.ts';\nimport { WorkletStyleBase } from './worklet-style.ts';\nimport { WORKLETS, type MutableValue, type WorkletBackend } from './worklets.ts';\n\nexport {\n workletScroll,\n workletStyle,\n type SharedValue,\n type WorkletScrollSpec,\n type WorkletStyleSpec,\n} from './worklets.ts';\nexport { releaseOnDestroy } from './release-on-destroy.ts';\n\n/**\n * A value both runtimes can see. Reanimated's own `useSharedValue` is this plus a React ref, and\n * the ref is the half that does not apply here. Typed with the shape of Reanimated's own, so it\n * goes to `cancelAnimation` and the rest of the library as one of theirs would.\n */\nexport function sharedValue<T>(initial: T): MutableValue<T> {\n return makeMutable(initial);\n}\n\n/**\n * Not public: what Reanimated's own components read the settled values through, and the inverse\n * of its processing they render them with, since Reanimated keeps the values as native takes them\n * and the engine processes a style itself. Required for the reason `updateProps` is, and with no\n * extension, so that Metro picks the native file: `ReanimatedModule/index.native.ts` over the\n * browser's `index.ts`, and the collector's `.native.ts` from 4.8.\n */\nconst { ReanimatedModule } = require('react-native-reanimated/src/ReanimatedModule') as {\n ReanimatedModule: SettledSource;\n};\nconst collector = require('react-native-reanimated/src/PropsRegistryGarbageCollector') as Unprocess;\n\n/**\n * Where Reanimated hands over what its views settled on, as its own React components read it. With\n * `FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS` off it keeps no such record, and with\n * `USE_ANIMATION_BACKEND` on it applies nothing to a commit, so there is nothing to read. Nor where\n * it gives no way to turn what it hands over back into a style (before 4.7).\n */\nconst settledUpdates =\n getStaticFeatureFlag('FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS') &&\n !getStaticFeatureFlag('USE_ANIMATION_BACKEND')\n ? settledReader(ReanimatedModule, collector)\n : null;\n\nconst backend: WorkletBackend = {\n bind: (target, style, settled) => {\n // The shape `updateProps` takes: a `{ value }` holder of descriptors, so that the set of\n // views a style drives can change without the worklet being rebuilt. Ours never does - one\n // directive drives one node - so a plain object is enough.\n const descriptors = { value: [{ tag: target.tag, shadowNodeWrapper: target.shadowNode }] };\n const { values, updater } = style;\n const id = startMapper(() => {\n 'worklet';\n updateProps(descriptors, updater(...values));\n }, values as unknown[]);\n const stopSettling = settledUpdates?.watch(target.tag, settled);\n return () => {\n stopMapper(id);\n stopSettling?.();\n };\n },\n\n scroll: (target, spec) => {\n const { values, handler } = spec;\n // The same registration a gesture uses, on the name React Native's scroll views emit. The\n // event still reaches our own listeners: Reanimated observes it rather than consuming it.\n const id = registerEventHandler(\n (event: never) => {\n 'worklet';\n handler(event, ...values);\n },\n 'onScroll',\n target.tag,\n );\n return () => unregisterEventHandler(id);\n },\n};\n\n/**\n * Not public, and the same call Reanimated's own `WorkletEventHandler` makes. Reached through\n * `src/` for the reason `updateProps` is, and required rather than imported so that those sources\n * stay out of our type-checking program.\n */\nconst { registerEventHandler, unregisterEventHandler } =\n require('react-native-reanimated/src/core.ts') as {\n registerEventHandler(\n worklet: (event: never) => void,\n eventName: string,\n emitterReactTag: number,\n ): number;\n unregisterEventHandler(id: number): void;\n };\n\n@Directive({\n selector: '[workletStyle]',\n providers: [{ provide: WORKLETS, useValue: backend }],\n})\nexport class WorkletStyle extends WorkletStyleBase {}\n\n@Directive({\n selector: '[workletScroll]',\n providers: [{ provide: WORKLETS, useValue: backend }],\n})\nexport class WorkletScroll extends WorkletScrollBase {}\n"]}
@@ -65,13 +65,15 @@ export declare class ScrollView extends ScrollViewProps {
65
65
  /** The content view's size changed; the value is its new width and height. */
66
66
  readonly contentSizeChange: import("@angular/core").OutputEmitterRef<Size>;
67
67
  private readonly refreshControl;
68
+ private readonly inSheet;
68
69
  private readonly content;
69
70
  private readonly sticky;
70
71
  /** RN asks for every scroll event while anything is sticky, which is what keeps it pinned. */
71
72
  protected readonly resolvedThrottle: import("@angular/core").Signal<number | undefined>;
72
73
  /**
73
74
  * RN's `nestedScrollEnabled ?? true` for a scroll view inside Android's swipe layout: the scroll
74
- * view has to see a drag before the layout wrapped around it does, or every drag is a pull.
75
+ * view has to see a drag before the layout wrapped around it does, or every drag is a pull. A
76
+ * form sheet's drag gives way the same way, or a drag down on scrolled content moves the sheet.
75
77
  */
76
78
  protected readonly resolvedNestedScroll: import("@angular/core").Signal<boolean | undefined>;
77
79
  constructor();
@@ -1,4 +1,5 @@
1
1
  import { Component, DestroyRef, ElementRef, afterEveryRender, computed, contentChild, inject, input, output, viewChild, } from '@angular/core';
2
+ import { IN_FORM_SHEET } from '@ng-native/device';
2
3
  import { nativePlatform } from '@ng-native/fabric';
3
4
  import { dismissKeyboardOnTap } from "./keyboard-taps.js";
4
5
  import { ContentContainer } from "./content-container.js";
@@ -78,6 +79,7 @@ export class ScrollView extends ScrollViewProps {
78
79
  contentSizeChange = output();
79
80
  refreshControl = contentChild(RefreshControl, /* @ts-ignore */
80
81
  ...(ngDevMode ? [{ debugName: "refreshControl" }] : /* istanbul ignore next */ []));
82
+ inSheet = inject(IN_FORM_SHEET);
81
83
  content = viewChild.required('content', { ...(ngDevMode ? { debugName: "content" } : /* istanbul ignore next */ {}), read: ElementRef });
82
84
  sticky = new StickyHeaders(this.engine, this.node, () => !!this.horizontal());
83
85
  /** RN asks for every scroll event while anything is sticky, which is what keeps it pinned. */
@@ -85,10 +87,13 @@ export class ScrollView extends ScrollViewProps {
85
87
  ...(ngDevMode ? [{ debugName: "resolvedThrottle" }] : /* istanbul ignore next */ []));
86
88
  /**
87
89
  * RN's `nestedScrollEnabled ?? true` for a scroll view inside Android's swipe layout: the scroll
88
- * view has to see a drag before the layout wrapped around it does, or every drag is a pull.
90
+ * view has to see a drag before the layout wrapped around it does, or every drag is a pull. A
91
+ * form sheet's drag gives way the same way, or a drag down on scrolled content moves the sheet.
89
92
  */
90
93
  resolvedNestedScroll = computed(() => this.nestedScrollEnabled() ??
91
- (nativePlatform() === 'android' && this.refreshControl() ? true : undefined), /* @ts-ignore */
94
+ (nativePlatform() === 'android' && (this.inSheet || this.refreshControl())
95
+ ? true
96
+ : undefined), /* @ts-ignore */
92
97
  ...(ngDevMode ? [{ debugName: "resolvedNestedScroll" }] : /* istanbul ignore next */ []));
93
98
  constructor() {
94
99
  super();
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-view.js","sourceRoot":"","sources":["../src/scroll-view.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAA4C,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAkC,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAuCH,MAA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AAU,EAAE","sourcesContent":["import {\n Component,\n DestroyRef,\n ElementRef,\n afterEveryRender,\n computed,\n contentChild,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { type HostNode, type NativeSyntheticEvent, nativePlatform } from '@ng-native/fabric';\nimport type { Point, Rect, Size } from './events.ts';\nimport { type KeyboardShouldPersistTaps, dismissKeyboardOnTap } from './keyboard-taps.ts';\nimport { ContentContainer } from './content-container.ts';\nimport { RefreshControl } from './refresh-control.ts';\nimport { StickyHeaders } from './sticky-headers.ts';\nimport { optionalBoolean } from './transforms.ts';\nimport { ScrollViewProps } from './scroll-view-props.ts';\nimport { View } from './view.ts';\nimport { ZeroSizeWarning, checksZeroSize, written } from './zero-size-warning.ts';\n\n/**\n * A scrolling container. Commits as `RCTScrollView`, with the children inside a content view.\n *\n * The native scroll view has no `contentContainerStyle`: RN's `ScrollView.js` wraps children in\n * a content view and applies it there, which is done here. The engine gives the host RN's base\n * style (`overflow: 'scroll'` and the flex defaults); without it the content spills out of the\n * scroll view's bounds.\n *\n * `horizontal` changes two things rather than one, and both are needed. RN swaps its whole base\n * style for `baseHorizontal` - the same defaults but `flexDirection: 'row'` - and puts\n * `contentContainerHorizontal` on the content view. With the host left as a column the content\n * view is stretched to the scroll view's width instead of growing past it, so there is nothing to\n * scroll to and a sideways drag does nothing at all. It looks like a scroll view that simply has\n * too little in it.\n *\n * Keyboard policy is the other half of what `ScrollView.js` does in JavaScript. With a text\n * input focused, a tap elsewhere in the scroll view dismisses the keyboard and goes no further\n * (`keyboardShouldPersistTaps: 'never'`, the default), reaches the child first and dismisses only\n * if nothing handled it (`'handled'`), or never dismisses (`'always'`).\n *\n * `stickyHeaderIndices` pins those children of the content to the leading edge, each until the\n * next pushes it off. It is JavaScript in RN as well; see `StickyHeaders`.\n *\n * Events are element events: `(scroll)`, `(scrollBeginDrag)`, `(scrollEndDrag)`,\n * `(momentumScrollBegin)`, `(momentumScrollEnd)`, `(scrollToTop)`. `(contentSizeChange)` is an\n * output, measured from the content view's layout as RN does.\n */\n@Component({\n selector: 'scroll-view',\n exportAs: 'scrollView',\n imports: [ContentContainer, View],\n // `collapsable: false` is load-bearing, not a hint. Fabric flattens views whose props are\n // layout-only, and a content container with just padding qualifies: it gets no UIView at all.\n // Touches in its empty areas then land on the scroll view itself, which does not scroll from a\n // direct hit, so dragging anywhere the children do not cover silently does nothing. RN sets the\n // same flag on its content container for the same reason.\n //\n // A refresh control is the scroll view's own child, before the content view, as RN's\n // ScrollView.js commits it. On iOS it finds its scroll view once, when it is inserted, and\n // Fabric mounts bottom-up: inside the content view it would look before that view was in the\n // scroll view, and never attach.\n template: `\n <ng-content select=\"refresh-control\" />\n <view\n #content\n [contentContainerOf]=\"node\"\n [contentContainerClass]=\"contentContainerClass()\"\n [style]=\"contentStyle()\"\n collapsable=\"false\"\n (layout)=\"onContentLayout($event)\"\n >\n <ng-content />\n </view>\n `,\n host: {\n // The base style's direction, which `horizontal` decides. A top-level prop rather than a\n // host `[style]`, so the caller's own `[style]` still applies over it as it does in RN.\n '[flexDirection]': \"horizontal() ? 'row' : 'column'\",\n '[horizontal]': 'horizontal()',\n '[contentOffset]': 'contentOffset()',\n '[maintainVisibleContentPosition]': 'maintainVisibleContentPosition()',\n '[scrollEventThrottle]': 'resolvedThrottle()',\n '[nestedScrollEnabled]': 'resolvedNestedScroll()',\n },\n})\nexport class ScrollView extends ScrollViewProps {\n /** Styles for the view that holds the children, e.g. padding and gap. */\n readonly contentContainerStyle = input<Record<string, unknown>>();\n /**\n * Classes for the view that holds the children, matched as if the view were written in the\n * template the scroll view is. See `ContentContainer`. `contentContainerStyle` wins over it, as\n * an inline style does over a class.\n */\n readonly contentContainerClass = input<string>();\n\n /**\n * The content view's style, with the row direction a horizontal scroll view needs.\n *\n * RN's `contentContainerHorizontal`, and in the same order: the caller's own style is applied\n * over it, so a horizontal scroll view whose content really should stack in a column can still\n * say so.\n */\n protected readonly contentStyle = computed(() =>\n this.horizontal()\n ? { flexDirection: 'row', ...this.contentContainerStyle() }\n : this.contentContainerStyle(),\n );\n /** Lay children out in a row and scroll sideways. */\n readonly horizontal = input(undefined, { transform: optionalBoolean });\n /** Where the content starts, before the user scrolls. */\n readonly contentOffset = input<Point>();\n /** Keep what is on screen still when content is added above it. */\n readonly maintainVisibleContentPosition = input<{\n readonly minIndexForVisible: number;\n readonly autoscrollToTopThreshold?: number;\n }>();\n /** What a tap does with the keyboard up. See the class note. Defaults to `never`. */\n readonly keyboardShouldPersistTaps = input<KeyboardShouldPersistTaps>('never');\n /** Android: cooperate with a scrolling ancestor. */\n readonly nestedScrollEnabled = input(undefined, { transform: optionalBoolean });\n\n /** Children of the content, by position, that stick to the leading edge while it scrolls. */\n readonly stickyHeaderIndices = input<readonly number[]>([]);\n\n /** The content view's size changed; the value is its new width and height. */\n readonly contentSizeChange = output<Size>();\n\n private readonly refreshControl = contentChild(RefreshControl);\n private readonly content = viewChild.required('content', { read: ElementRef });\n private readonly sticky = new StickyHeaders(this.engine, this.node, () => !!this.horizontal());\n\n /** RN asks for every scroll event while anything is sticky, which is what keeps it pinned. */\n protected readonly resolvedThrottle = computed(() =>\n this.stickyHeaderIndices().length > 0 ? 1 : this.scrollEventThrottle(),\n );\n\n /**\n * RN's `nestedScrollEnabled ?? true` for a scroll view inside Android's swipe layout: the scroll\n * view has to see a drag before the layout wrapped around it does, or every drag is a pull.\n */\n protected readonly resolvedNestedScroll = computed(\n () =>\n this.nestedScrollEnabled() ??\n (nativePlatform() === 'android' && this.refreshControl() ? true : undefined),\n );\n\n constructor() {\n super();\n const stop = dismissKeyboardOnTap(this.engine, this.node, () =>\n this.keyboardShouldPersistTaps(),\n );\n inject(DestroyRef).onDestroy(stop);\n this.trackStickyHeaders();\n if (checksZeroSize()) this.checkZeroSize();\n }\n\n /** The content's extent along the axis, and the scroll view's own, for `checkZeroSize`. */\n private contentExtent = 0;\n private ownExtent: number | undefined;\n private zeroSize: ZeroSizeWarning | null = null;\n\n /**\n * In development only, the scroll view's own layout, to say when it stays at zero size with\n * content in it. A release build listens for nothing, so it commits no `onLayout`.\n */\n private checkZeroSize(): void {\n const warning = (this.zeroSize = new ZeroSizeWarning(\n () => written(this.node),\n () => !!this.horizontal(),\n ));\n const stop = this.engine.setEventListener(this.node, 'topLayout', (event) => {\n this.ownExtent = this.extent(\n (event as NativeSyntheticEvent<{ layout?: Size }>).nativeEvent?.layout,\n );\n warning.laidOut(this.ownExtent, this.contentExtent > 0);\n });\n inject(DestroyRef).onDestroy(() => {\n stop();\n warning.stop();\n });\n }\n\n private extent(size: Size | undefined): number {\n return (this.horizontal() ? size?.width : size?.height) ?? 0;\n }\n\n /**\n * Sticky children are found again after each pass, because a pass can add or move them, and the\n * scroll offset is listened for only while there are any.\n */\n private trackStickyHeaders(): void {\n let stopScroll: (() => void) | null = null;\n afterEveryRender(() => {\n const indices = this.stickyHeaderIndices();\n if (indices.length === 0 && !stopScroll) return;\n this.sticky.track(this.content().nativeElement as HostNode, indices);\n if (indices.length > 0 && !stopScroll) {\n stopScroll = this.engine.setEventListener(this.node, 'topScroll', (event) => {\n const offset = (event as NativeSyntheticEvent<{ contentOffset?: Point }>).nativeEvent\n ?.contentOffset;\n this.sticky.scrolled((this.horizontal() ? offset?.x : offset?.y) ?? 0);\n });\n } else if (indices.length === 0 && stopScroll) {\n stopScroll();\n stopScroll = null;\n }\n });\n inject(DestroyRef).onDestroy(() => {\n stopScroll?.();\n this.sticky.destroy();\n });\n }\n\n /** Scroll to a position. */\n scrollTo(options: { x?: number; y?: number; animated?: boolean }): void {\n const { x = 0, y = 0, animated = true } = options;\n this.engine.dispatchCommand(this.node, 'scrollTo', [x, y, animated]);\n }\n\n scrollToEnd(options: { animated?: boolean } = {}): void {\n this.engine.dispatchCommand(this.node, 'scrollToEnd', [options.animated ?? true]);\n }\n\n /** Briefly show the scroll indicators, to hint that there is more. */\n flashScrollIndicators(): void {\n this.engine.dispatchCommand(this.node, 'flashScrollIndicators');\n }\n\n /** iOS: zoom so that a rectangle of the content fills the viewport. */\n zoomToRect(rect: Rect, animated = true): void {\n this.engine.dispatchCommand(this.node, 'zoomToRect', [rect, animated]);\n }\n\n protected onContentLayout(event: NativeSyntheticEvent<{ layout?: Size }>): void {\n const layout = event.nativeEvent?.layout;\n if (layout) this.contentSizeChange.emit({ width: layout.width, height: layout.height });\n if (this.zeroSize) {\n this.contentExtent = this.extent(layout);\n if (this.ownExtent !== undefined) {\n this.zeroSize.laidOut(this.ownExtent, this.contentExtent > 0);\n }\n }\n }\n}\n"]}
1
+ {"version":3,"file":"scroll-view.js","sourceRoot":"","sources":["../src/scroll-view.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAA4C,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAkC,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;;AAElF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAuCH,MAAM,OAAO,UAAW,SAAQ,eAAe;IAC7C,yEAAyE;IAChE,qBAAqB,GAAG,KAAK;yGAA2B,CAAC;IAClE;;;;OAIG;IAC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":["import {\n Component,\n DestroyRef,\n ElementRef,\n afterEveryRender,\n computed,\n contentChild,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { IN_FORM_SHEET } from '@ng-native/device';\nimport { type HostNode, type NativeSyntheticEvent, nativePlatform } from '@ng-native/fabric';\nimport type { Point, Rect, Size } from './events.ts';\nimport { type KeyboardShouldPersistTaps, dismissKeyboardOnTap } from './keyboard-taps.ts';\nimport { ContentContainer } from './content-container.ts';\nimport { RefreshControl } from './refresh-control.ts';\nimport { StickyHeaders } from './sticky-headers.ts';\nimport { optionalBoolean } from './transforms.ts';\nimport { ScrollViewProps } from './scroll-view-props.ts';\nimport { View } from './view.ts';\nimport { ZeroSizeWarning, checksZeroSize, written } from './zero-size-warning.ts';\n\n/**\n * A scrolling container. Commits as `RCTScrollView`, with the children inside a content view.\n *\n * The native scroll view has no `contentContainerStyle`: RN's `ScrollView.js` wraps children in\n * a content view and applies it there, which is done here. The engine gives the host RN's base\n * style (`overflow: 'scroll'` and the flex defaults); without it the content spills out of the\n * scroll view's bounds.\n *\n * `horizontal` changes two things rather than one, and both are needed. RN swaps its whole base\n * style for `baseHorizontal` - the same defaults but `flexDirection: 'row'` - and puts\n * `contentContainerHorizontal` on the content view. With the host left as a column the content\n * view is stretched to the scroll view's width instead of growing past it, so there is nothing to\n * scroll to and a sideways drag does nothing at all. It looks like a scroll view that simply has\n * too little in it.\n *\n * Keyboard policy is the other half of what `ScrollView.js` does in JavaScript. With a text\n * input focused, a tap elsewhere in the scroll view dismisses the keyboard and goes no further\n * (`keyboardShouldPersistTaps: 'never'`, the default), reaches the child first and dismisses only\n * if nothing handled it (`'handled'`), or never dismisses (`'always'`).\n *\n * `stickyHeaderIndices` pins those children of the content to the leading edge, each until the\n * next pushes it off. It is JavaScript in RN as well; see `StickyHeaders`.\n *\n * Events are element events: `(scroll)`, `(scrollBeginDrag)`, `(scrollEndDrag)`,\n * `(momentumScrollBegin)`, `(momentumScrollEnd)`, `(scrollToTop)`. `(contentSizeChange)` is an\n * output, measured from the content view's layout as RN does.\n */\n@Component({\n selector: 'scroll-view',\n exportAs: 'scrollView',\n imports: [ContentContainer, View],\n // `collapsable: false` is load-bearing, not a hint. Fabric flattens views whose props are\n // layout-only, and a content container with just padding qualifies: it gets no UIView at all.\n // Touches in its empty areas then land on the scroll view itself, which does not scroll from a\n // direct hit, so dragging anywhere the children do not cover silently does nothing. RN sets the\n // same flag on its content container for the same reason.\n //\n // A refresh control is the scroll view's own child, before the content view, as RN's\n // ScrollView.js commits it. On iOS it finds its scroll view once, when it is inserted, and\n // Fabric mounts bottom-up: inside the content view it would look before that view was in the\n // scroll view, and never attach.\n template: `\n <ng-content select=\"refresh-control\" />\n <view\n #content\n [contentContainerOf]=\"node\"\n [contentContainerClass]=\"contentContainerClass()\"\n [style]=\"contentStyle()\"\n collapsable=\"false\"\n (layout)=\"onContentLayout($event)\"\n >\n <ng-content />\n </view>\n `,\n host: {\n // The base style's direction, which `horizontal` decides. A top-level prop rather than a\n // host `[style]`, so the caller's own `[style]` still applies over it as it does in RN.\n '[flexDirection]': \"horizontal() ? 'row' : 'column'\",\n '[horizontal]': 'horizontal()',\n '[contentOffset]': 'contentOffset()',\n '[maintainVisibleContentPosition]': 'maintainVisibleContentPosition()',\n '[scrollEventThrottle]': 'resolvedThrottle()',\n '[nestedScrollEnabled]': 'resolvedNestedScroll()',\n },\n})\nexport class ScrollView extends ScrollViewProps {\n /** Styles for the view that holds the children, e.g. padding and gap. */\n readonly contentContainerStyle = input<Record<string, unknown>>();\n /**\n * Classes for the view that holds the children, matched as if the view were written in the\n * template the scroll view is. See `ContentContainer`. `contentContainerStyle` wins over it, as\n * an inline style does over a class.\n */\n readonly contentContainerClass = input<string>();\n\n /**\n * The content view's style, with the row direction a horizontal scroll view needs.\n *\n * RN's `contentContainerHorizontal`, and in the same order: the caller's own style is applied\n * over it, so a horizontal scroll view whose content really should stack in a column can still\n * say so.\n */\n protected readonly contentStyle = computed(() =>\n this.horizontal()\n ? { flexDirection: 'row', ...this.contentContainerStyle() }\n : this.contentContainerStyle(),\n );\n /** Lay children out in a row and scroll sideways. */\n readonly horizontal = input(undefined, { transform: optionalBoolean });\n /** Where the content starts, before the user scrolls. */\n readonly contentOffset = input<Point>();\n /** Keep what is on screen still when content is added above it. */\n readonly maintainVisibleContentPosition = input<{\n readonly minIndexForVisible: number;\n readonly autoscrollToTopThreshold?: number;\n }>();\n /** What a tap does with the keyboard up. See the class note. Defaults to `never`. */\n readonly keyboardShouldPersistTaps = input<KeyboardShouldPersistTaps>('never');\n /** Android: cooperate with a scrolling ancestor. */\n readonly nestedScrollEnabled = input(undefined, { transform: optionalBoolean });\n\n /** Children of the content, by position, that stick to the leading edge while it scrolls. */\n readonly stickyHeaderIndices = input<readonly number[]>([]);\n\n /** The content view's size changed; the value is its new width and height. */\n readonly contentSizeChange = output<Size>();\n\n private readonly refreshControl = contentChild(RefreshControl);\n private readonly inSheet = inject(IN_FORM_SHEET);\n private readonly content = viewChild.required('content', { read: ElementRef });\n private readonly sticky = new StickyHeaders(this.engine, this.node, () => !!this.horizontal());\n\n /** RN asks for every scroll event while anything is sticky, which is what keeps it pinned. */\n protected readonly resolvedThrottle = computed(() =>\n this.stickyHeaderIndices().length > 0 ? 1 : this.scrollEventThrottle(),\n );\n\n /**\n * RN's `nestedScrollEnabled ?? true` for a scroll view inside Android's swipe layout: the scroll\n * view has to see a drag before the layout wrapped around it does, or every drag is a pull. A\n * form sheet's drag gives way the same way, or a drag down on scrolled content moves the sheet.\n */\n protected readonly resolvedNestedScroll = computed(\n () =>\n this.nestedScrollEnabled() ??\n (nativePlatform() === 'android' && (this.inSheet || this.refreshControl())\n ? true\n : undefined),\n );\n\n constructor() {\n super();\n const stop = dismissKeyboardOnTap(this.engine, this.node, () =>\n this.keyboardShouldPersistTaps(),\n );\n inject(DestroyRef).onDestroy(stop);\n this.trackStickyHeaders();\n if (checksZeroSize()) this.checkZeroSize();\n }\n\n /** The content's extent along the axis, and the scroll view's own, for `checkZeroSize`. */\n private contentExtent = 0;\n private ownExtent: number | undefined;\n private zeroSize: ZeroSizeWarning | null = null;\n\n /**\n * In development only, the scroll view's own layout, to say when it stays at zero size with\n * content in it. A release build listens for nothing, so it commits no `onLayout`.\n */\n private checkZeroSize(): void {\n const warning = (this.zeroSize = new ZeroSizeWarning(\n () => written(this.node),\n () => !!this.horizontal(),\n ));\n const stop = this.engine.setEventListener(this.node, 'topLayout', (event) => {\n this.ownExtent = this.extent(\n (event as NativeSyntheticEvent<{ layout?: Size }>).nativeEvent?.layout,\n );\n warning.laidOut(this.ownExtent, this.contentExtent > 0);\n });\n inject(DestroyRef).onDestroy(() => {\n stop();\n warning.stop();\n });\n }\n\n private extent(size: Size | undefined): number {\n return (this.horizontal() ? size?.width : size?.height) ?? 0;\n }\n\n /**\n * Sticky children are found again after each pass, because a pass can add or move them, and the\n * scroll offset is listened for only while there are any.\n */\n private trackStickyHeaders(): void {\n let stopScroll: (() => void) | null = null;\n afterEveryRender(() => {\n const indices = this.stickyHeaderIndices();\n if (indices.length === 0 && !stopScroll) return;\n this.sticky.track(this.content().nativeElement as HostNode, indices);\n if (indices.length > 0 && !stopScroll) {\n stopScroll = this.engine.setEventListener(this.node, 'topScroll', (event) => {\n const offset = (event as NativeSyntheticEvent<{ contentOffset?: Point }>).nativeEvent\n ?.contentOffset;\n this.sticky.scrolled((this.horizontal() ? offset?.x : offset?.y) ?? 0);\n });\n } else if (indices.length === 0 && stopScroll) {\n stopScroll();\n stopScroll = null;\n }\n });\n inject(DestroyRef).onDestroy(() => {\n stopScroll?.();\n this.sticky.destroy();\n });\n }\n\n /** Scroll to a position. */\n scrollTo(options: { x?: number; y?: number; animated?: boolean }): void {\n const { x = 0, y = 0, animated = true } = options;\n this.engine.dispatchCommand(this.node, 'scrollTo', [x, y, animated]);\n }\n\n scrollToEnd(options: { animated?: boolean } = {}): void {\n this.engine.dispatchCommand(this.node, 'scrollToEnd', [options.animated ?? true]);\n }\n\n /** Briefly show the scroll indicators, to hint that there is more. */\n flashScrollIndicators(): void {\n this.engine.dispatchCommand(this.node, 'flashScrollIndicators');\n }\n\n /** iOS: zoom so that a rectangle of the content fills the viewport. */\n zoomToRect(rect: Rect, animated = true): void {\n this.engine.dispatchCommand(this.node, 'zoomToRect', [rect, animated]);\n }\n\n protected onContentLayout(event: NativeSyntheticEvent<{ layout?: Size }>): void {\n const layout = event.nativeEvent?.layout;\n if (layout) this.contentSizeChange.emit({ width: layout.width, height: layout.height });\n if (this.zeroSize) {\n this.contentExtent = this.extent(layout);\n if (this.ownExtent !== undefined) {\n this.zeroSize.laidOut(this.ownExtent, this.contentExtent > 0);\n }\n }\n }\n}\n"]}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * What Reanimated's views settled on, read for the views a `[workletStyle]` drives.
3
+ *
4
+ * Reanimated keeps the values a worklet drew each view with in a registry, and applies every entry
5
+ * to each commit React Native makes, cloning the view and each ancestor. A view stays there until
6
+ * the values are in the props it is committed with. Reanimated's own React components read
7
+ * `getSettledUpdates()` every half second while any is mounted and render what it hands them; a
8
+ * view it handed over on one read and that has not moved since, it lets go on the next. Nothing
9
+ * reads it for ours, so this does, and hands each view's values to whoever commits them.
10
+ *
11
+ * Kept apart from `reanimated.ts`, which reaches React Native's Flow source, so a test can drive it.
12
+ */
13
+ /** One view's values, as Reanimated's `getSettledUpdates()` hands them over. */
14
+ export interface SettledUpdate {
15
+ readonly viewTag: number;
16
+ readonly styleProps: Readonly<Record<string, unknown>> | null;
17
+ }
18
+ export declare class SettledUpdates {
19
+ #private;
20
+ /**
21
+ * `read` is `getSettledUpdates()`, answering undefined where Reanimated has none. It is told
22
+ * which views are watched, for a Reanimated that asks, so that it lets no other view go.
23
+ */
24
+ constructor(read: (isWatched: (tag: number) => boolean) => readonly SettledUpdate[] | undefined);
25
+ /**
26
+ * Hand `listener` the values the view with `tag` settles on, each time it does. Read for while
27
+ * any view is watched. Returns the function that stops it.
28
+ */
29
+ watch(tag: number, listener: (props: Readonly<Record<string, unknown>>) => void): () => void;
30
+ private collect;
31
+ }
32
+ /** One view's settled values as Reanimated hands them over: `styleProps` in 4.7, `props` and `style` from 4.8. */
33
+ export interface RawSettled {
34
+ readonly viewTag: number;
35
+ readonly styleProps?: Record<string, unknown> | null;
36
+ readonly props?: Record<string, unknown>;
37
+ readonly style?: Record<string, unknown>;
38
+ }
39
+ /** Reanimated's module, which hands the settled values over. */
40
+ export interface SettledSource {
41
+ getSettledUpdates?(isViewRegistered?: (tag: number) => boolean): readonly RawSettled[];
42
+ }
43
+ /** Reanimated's inverse of its processing, from its garbage collector's module. */
44
+ export interface Unprocess {
45
+ /** 4.7. */
46
+ unprocessProps?(props: Record<string, unknown>): void;
47
+ /** 4.8 and later. */
48
+ unprocessSettledUpdate?(update: RawSettled): void;
49
+ }
50
+ /**
51
+ * Read settled values in the shape this Reanimated hands them over in, turned back into a style
52
+ * for the engine to process like any other. Null where there is no way to: before 4.7, which gives
53
+ * no inverse to turn them back with.
54
+ */
55
+ export declare function settledReader(source: SettledSource, unprocess: Unprocess): SettledUpdates | null;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * What Reanimated's views settled on, read for the views a `[workletStyle]` drives.
3
+ *
4
+ * Reanimated keeps the values a worklet drew each view with in a registry, and applies every entry
5
+ * to each commit React Native makes, cloning the view and each ancestor. A view stays there until
6
+ * the values are in the props it is committed with. Reanimated's own React components read
7
+ * `getSettledUpdates()` every half second while any is mounted and render what it hands them; a
8
+ * view it handed over on one read and that has not moved since, it lets go on the next. Nothing
9
+ * reads it for ours, so this does, and hands each view's values to whoever commits them.
10
+ *
11
+ * Kept apart from `reanimated.ts`, which reaches React Native's Flow source, so a test can drive it.
12
+ */
13
+ /** How often Reanimated's own components read: `FLUSH_INTERVAL_MS` in its garbage collector. */
14
+ const EVERY_MS = 500;
15
+ export class SettledUpdates {
16
+ #listeners = new Map();
17
+ #read;
18
+ #isWatched = (tag) => this.#listeners.has(tag);
19
+ #timer = null;
20
+ /**
21
+ * `read` is `getSettledUpdates()`, answering undefined where Reanimated has none. It is told
22
+ * which views are watched, for a Reanimated that asks, so that it lets no other view go.
23
+ */
24
+ constructor(read) {
25
+ this.#read = read;
26
+ }
27
+ /**
28
+ * Hand `listener` the values the view with `tag` settles on, each time it does. Read for while
29
+ * any view is watched. Returns the function that stops it.
30
+ */
31
+ watch(tag, listener) {
32
+ this.#listeners.set(tag, listener);
33
+ this.#timer ??= setInterval(() => this.collect(), EVERY_MS);
34
+ return () => {
35
+ // A view bound again keeps its tag: the newer listener stays.
36
+ if (this.#listeners.get(tag) !== listener)
37
+ return;
38
+ this.#listeners.delete(tag);
39
+ if (this.#listeners.size === 0 && this.#timer !== null) {
40
+ clearInterval(this.#timer);
41
+ this.#timer = null;
42
+ }
43
+ };
44
+ }
45
+ collect() {
46
+ for (const { viewTag, styleProps } of this.#read(this.#isWatched) ?? []) {
47
+ if (styleProps)
48
+ this.#listeners.get(viewTag)?.(styleProps);
49
+ }
50
+ }
51
+ }
52
+ /**
53
+ * Read settled values in the shape this Reanimated hands them over in, turned back into a style
54
+ * for the engine to process like any other. Null where there is no way to: before 4.7, which gives
55
+ * no inverse to turn them back with.
56
+ */
57
+ export function settledReader(source, unprocess) {
58
+ const read = source.getSettledUpdates?.bind(source);
59
+ if (!read)
60
+ return null;
61
+ const { unprocessProps, unprocessSettledUpdate } = unprocess;
62
+ if (unprocessSettledUpdate) {
63
+ // 4.8 asks which views the reader commits, and lets only those go.
64
+ return new SettledUpdates((isWatched) => read(isWatched).map((update) => {
65
+ unprocessSettledUpdate(update);
66
+ return { viewTag: update.viewTag, styleProps: { ...update.props, ...update.style } };
67
+ }));
68
+ }
69
+ if (!unprocessProps)
70
+ return null;
71
+ return new SettledUpdates(() => read().map(({ viewTag, styleProps }) => {
72
+ if (styleProps)
73
+ unprocessProps(styleProps);
74
+ return { viewTag, styleProps: styleProps ?? null };
75
+ }));
76
+ }
77
+ //# sourceMappingURL=settled-updates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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AC;YACxE,IAAI,UAAU;gBAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF;AAuBD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,MAAqB,EAAE,SAAoB;IACvE,MAAM,IAAI,GAAG,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IACvB,MAAM,EAAE,cAAc,EAAE,sBAAsB,EAAE,GAAG,SAAS,CAAC;IAC7D,IAAI,sBAAsB,EAAE,CAAC;QAC3B,mEAAmE;QACnE,OAAO,IAAI,cAAc,CAAC,CAAC,SAAS,EAAE,EAAE,CACtC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAiB,EAAE;YAC5C,sBAAsB,CAAC,MAAM,CAAC,CAAC;YAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACvF,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,cAAc;QAAE,OAAO,IAAI,CAAC;IACjC,OAAO,IAAI,cAAc,CAAC,GAAG,EAAE,CAC7B,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,EAAiB,EAAE;QACpD,IAAI,UAAU;YAAE,cAAc,CAAC,UAAU,CAAC,CAAC;QAC3C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,IAAI,IAAI,EAAE,CAAC;IACrD,CAAC,CAAC,CACH,CAAC;AACJ,CAAC","sourcesContent":["/**\n * What Reanimated's views settled on, read for the views a `[workletStyle]` drives.\n *\n * Reanimated keeps the values a worklet drew each view with in a registry, and applies every entry\n * to each commit React Native makes, cloning the view and each ancestor. A view stays there until\n * the values are in the props it is committed with. Reanimated's own React components read\n * `getSettledUpdates()` every half second while any is mounted and render what it hands them; a\n * view it handed over on one read and that has not moved since, it lets go on the next. Nothing\n * reads it for ours, so this does, and hands each view's values to whoever commits them.\n *\n * Kept apart from `reanimated.ts`, which reaches React Native's Flow source, so a test can drive it.\n */\n\n/** One view's values, as Reanimated's `getSettledUpdates()` hands them over. */\nexport interface SettledUpdate {\n readonly viewTag: number;\n readonly styleProps: Readonly<Record<string, unknown>> | null;\n}\n\n/** How often Reanimated's own components read: `FLUSH_INTERVAL_MS` in its garbage collector. */\nconst EVERY_MS = 500;\n\nexport class SettledUpdates {\n readonly #listeners = new Map<number, (props: Readonly<Record<string, unknown>>) => void>();\n readonly #read: (isWatched: (tag: number) => boolean) => readonly SettledUpdate[] | undefined;\n readonly #isWatched = (tag: number): boolean => this.#listeners.has(tag);\n #timer: ReturnType<typeof setInterval> | null = null;\n\n /**\n * `read` is `getSettledUpdates()`, answering undefined where Reanimated has none. It is told\n * which views are watched, for a Reanimated that asks, so that it lets no other view go.\n */\n constructor(read: (isWatched: (tag: number) => boolean) => readonly SettledUpdate[] | undefined) {\n this.#read = read;\n }\n\n /**\n * Hand `listener` the values the view with `tag` settles on, each time it does. Read for while\n * any view is watched. Returns the function that stops it.\n */\n watch(tag: number, listener: (props: Readonly<Record<string, unknown>>) => void): () => void {\n this.#listeners.set(tag, listener);\n this.#timer ??= setInterval(() => this.collect(), EVERY_MS);\n return () => {\n // A view bound again keeps its tag: the newer listener stays.\n if (this.#listeners.get(tag) !== listener) return;\n this.#listeners.delete(tag);\n if (this.#listeners.size === 0 && this.#timer !== null) {\n clearInterval(this.#timer);\n this.#timer = null;\n }\n };\n }\n\n private collect(): void {\n for (const { viewTag, styleProps } of this.#read(this.#isWatched) ?? []) {\n if (styleProps) this.#listeners.get(viewTag)?.(styleProps);\n }\n }\n}\n\n/** One view's settled values as Reanimated hands them over: `styleProps` in 4.7, `props` and `style` from 4.8. */\nexport interface RawSettled {\n readonly viewTag: number;\n readonly styleProps?: Record<string, unknown> | null;\n readonly props?: Record<string, unknown>;\n readonly style?: Record<string, unknown>;\n}\n\n/** Reanimated's module, which hands the settled values over. */\nexport interface SettledSource {\n getSettledUpdates?(isViewRegistered?: (tag: number) => boolean): readonly RawSettled[];\n}\n\n/** Reanimated's inverse of its processing, from its garbage collector's module. */\nexport interface Unprocess {\n /** 4.7. */\n unprocessProps?(props: Record<string, unknown>): void;\n /** 4.8 and later. */\n unprocessSettledUpdate?(update: RawSettled): void;\n}\n\n/**\n * Read settled values in the shape this Reanimated hands them over in, turned back into a style\n * for the engine to process like any other. Null where there is no way to: before 4.7, which gives\n * no inverse to turn them back with.\n */\nexport function settledReader(source: SettledSource, unprocess: Unprocess): SettledUpdates | null {\n const read = source.getSettledUpdates?.bind(source);\n if (!read) return null;\n const { unprocessProps, unprocessSettledUpdate } = unprocess;\n if (unprocessSettledUpdate) {\n // 4.8 asks which views the reader commits, and lets only those go.\n return new SettledUpdates((isWatched) =>\n read(isWatched).map((update): SettledUpdate => {\n unprocessSettledUpdate(update);\n return { viewTag: update.viewTag, styleProps: { ...update.props, ...update.style } };\n }),\n );\n }\n if (!unprocessProps) return null;\n return new SettledUpdates(() =>\n read().map(({ viewTag, styleProps }): SettledUpdate => {\n if (styleProps) unprocessProps(styleProps);\n return { viewTag, styleProps: styleProps ?? null };\n }),\n );\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { type Signal } from '@angular/core';
1
2
  import type { ButtonIcon } from './native-button.ts';
2
3
  import { ControlBase } from './pressable.ts';
3
4
  import { type SidebarRow } from './sidebar.ts';
@@ -15,6 +16,7 @@ export type SidebarItemIcon = ButtonIcon;
15
16
  *
16
17
  * Content inside the element replaces the default row of icon, label and badge: its pressables
17
18
  * take clicks, and while the row is selected its host has `data-selected` for CSS to restyle it.
19
+ * On macOS it also has `data-emphasized` while that selection is drawn in the accent colour.
18
20
  */
19
21
  export declare class SidebarItem extends ControlBase implements SidebarRow {
20
22
  private readonly sidebar;
@@ -28,15 +30,28 @@ export declare class SidebarItem extends ControlBase implements SidebarRow {
28
30
  readonly sfSymbol: import("@angular/core").InputSignal<string | undefined>;
29
31
  /** Android: a drawable resource before the label. */
30
32
  readonly drawableName: import("@angular/core").InputSignal<string | undefined>;
31
- /** The picture for each OS at once, as on `<native-tab>`. */
33
+ /**
34
+ * The picture for each OS at once, as on `<native-tab>`. On macOS and Linux it can be an icon's
35
+ * SVG markup, `[icon]="{ svg: lucideBlocks }"`, which the host draws in the row's text colour.
36
+ */
32
37
  readonly icon: import("@angular/core").InputSignal<ButtonIcon | undefined>;
33
38
  /** Whether this is the sidebar's selected item. A `path` from the router sets it by route. */
34
39
  readonly selected: import("@angular/core").ModelSignal<boolean>;
35
40
  /** The user chose this item. */
36
41
  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>;
42
+ /** On macOS, whether the source list draws the row's selection emphasized, as it last said. */
43
+ private readonly hostEmphasized;
44
+ /**
45
+ * macOS: whether the row is selected and its selection is drawn in the accent colour, while the
46
+ * window is key and the sidebar has the focus. Otherwise the selection is grey, and this is false.
47
+ * Always false on other platforms.
48
+ */
49
+ readonly emphasized: Signal<boolean>;
50
+ protected readonly symbol: Signal<string | undefined>;
51
+ protected readonly drawableResource: Signal<string | undefined>;
52
+ protected readonly svgIcon: Signal<string | undefined>;
39
53
  private stopSelect;
54
+ private stopEmphasis;
40
55
  constructor();
41
56
  protected roleByDefault(): 'button';
42
57
  protected accessibleByDefault(): boolean;
@@ -1,10 +1,11 @@
1
- import { Component, DestroyRef, computed, forwardRef, inject, input, model, output, } from '@angular/core';
1
+ import { Component, DestroyRef, computed, forwardRef, inject, input, model, output, signal, } from '@angular/core';
2
2
  import { SIDEBAR_SELECTION } from '@ng-native/device';
3
3
  import { registerViewName } from '@ng-native/fabric';
4
4
  import { ControlBase, TouchableBase } from "./pressable.js";
5
5
  import { Sidebar } from "./sidebar.js";
6
6
  import { hostDraws } from "./split-view.js";
7
7
  import { Text } from "./text.js";
8
+ import { svgIconMarkup } from "./svg-icon.js";
8
9
  import * as i0 from "@angular/core";
9
10
  /**
10
11
  * On macOS a row of the sidebar's source list, a model object the desktop host builds an
@@ -27,6 +28,7 @@ registerViewName('sidebar-item', {
27
28
  *
28
29
  * Content inside the element replaces the default row of icon, label and badge: its pressables
29
30
  * take clicks, and while the row is selected its host has `data-selected` for CSS to restyle it.
31
+ * On macOS it also has `data-emphasized` while that selection is drawn in the accent colour.
30
32
  */
31
33
  export class SidebarItem extends ControlBase {
32
34
  sidebar = inject(Sidebar, { optional: true });
@@ -42,7 +44,10 @@ export class SidebarItem extends ControlBase {
42
44
  ...(ngDevMode ? [undefined, { debugName: "sfSymbol" }] : /* istanbul ignore next */ []));
43
45
  /** Android: a drawable resource before the label. */
44
46
  drawableName = input(undefined, { ...(ngDevMode ? { debugName: "drawableName" } : /* istanbul ignore next */ {}), alias: 'drawable' });
45
- /** The picture for each OS at once, as on `<native-tab>`. */
47
+ /**
48
+ * The picture for each OS at once, as on `<native-tab>`. On macOS and Linux it can be an icon's
49
+ * SVG markup, `[icon]="{ svg: lucideBlocks }"`, which the host draws in the row's text colour.
50
+ */
46
51
  icon = input(/* @ts-ignore */
47
52
  ...(ngDevMode ? [undefined, { debugName: "icon" }] : /* istanbul ignore next */ []));
48
53
  /** Whether this is the sidebar's selected item. A `path` from the router sets it by route. */
@@ -50,6 +55,16 @@ export class SidebarItem extends ControlBase {
50
55
  ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
51
56
  /** The user chose this item. */
52
57
  select = output();
58
+ /** On macOS, whether the source list draws the row's selection emphasized, as it last said. */
59
+ hostEmphasized = signal(false, /* @ts-ignore */
60
+ ...(ngDevMode ? [{ debugName: "hostEmphasized" }] : /* istanbul ignore next */ []));
61
+ /**
62
+ * macOS: whether the row is selected and its selection is drawn in the accent colour, while the
63
+ * window is key and the sidebar has the focus. Otherwise the selection is grey, and this is false.
64
+ * Always false on other platforms.
65
+ */
66
+ emphasized = computed(() => this.selected() && this.hostEmphasized(), /* @ts-ignore */
67
+ ...(ngDevMode ? [{ debugName: "emphasized" }] : /* istanbul ignore next */ []));
53
68
  symbol = computed(() => {
54
69
  const icon = this.icon();
55
70
  return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);
@@ -60,7 +75,10 @@ export class SidebarItem extends ControlBase {
60
75
  return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);
61
76
  }, /* @ts-ignore */
62
77
  ...(ngDevMode ? [{ debugName: "drawableResource" }] : /* istanbul ignore next */ []));
78
+ svgIcon = computed(() => svgIconMarkup(this.icon(), 'sidebar-item'), /* @ts-ignore */
79
+ ...(ngDevMode ? [{ debugName: "svgIcon" }] : /* istanbul ignore next */ []));
63
80
  stopSelect = null;
81
+ stopEmphasis = null;
64
82
  constructor() {
65
83
  super();
66
84
  const remove = this.sidebar?.addRow(this);
@@ -89,10 +107,16 @@ export class SidebarItem extends ControlBase {
89
107
  if (event.target === this.node)
90
108
  this.choose();
91
109
  });
110
+ this.stopEmphasis = this.engine.setEventListener(this.node, 'topSidebarEmphasis', (event) => {
111
+ const { target, nativeEvent } = event;
112
+ if (target === this.node)
113
+ this.hostEmphasized.set(nativeEvent?.emphasized === true);
114
+ });
92
115
  }
93
116
  ngOnDestroy() {
94
117
  super.ngOnDestroy();
95
118
  this.stopSelect?.();
119
+ this.stopEmphasis?.();
96
120
  }
97
121
  /** The user chose this row: select it, deselect the rest, and say so. */
98
122
  choose() {
@@ -106,7 +130,7 @@ export class SidebarItem extends ControlBase {
106
130
  this.selected.set(false);
107
131
  }
108
132
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: SidebarItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
109
- 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: [
133
+ 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()", "svgIcon": "drawnHere ? undefined : svgIcon()", "selected": "drawnHere ? undefined : selected()", "attr.data-selected": "selected() ? '' : null", "attr.data-emphasized": "emphasized() ? '' : null", "class.sidebar-item-drawn": "drawnHere" } }, providers: [
110
134
  { provide: TouchableBase, useExisting: forwardRef(() => SidebarItem) },
111
135
  {
112
136
  provide: SIDEBAR_SELECTION,
@@ -145,8 +169,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
145
169
  '[badge]': 'drawnHere ? undefined : badge()',
146
170
  '[sfSymbol]': 'drawnHere ? undefined : symbol()',
147
171
  '[drawable]': 'drawnHere ? undefined : drawableResource()',
172
+ '[svgIcon]': 'drawnHere ? undefined : svgIcon()',
148
173
  '[selected]': 'drawnHere ? undefined : selected()',
149
174
  '[attr.data-selected]': "selected() ? '' : null",
175
+ '[attr.data-emphasized]': "emphasized() ? '' : null",
150
176
  '[class.sidebar-item-drawn]': 'drawnHere',
151
177
  }, 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 "] }]
152
178
  }], 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"] }] } });
@@ -1 +1 @@
1
- {"version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F,iDA/BS;;;;;;;;;GAST,kaAVS,IAAI;;2FA2CH,WAAW;kBA7CvB,SAAS;+BACE,cAAc,WACf,CAAC,IAAI,CAAC,YACL;;;;;;;;;GAST,aAgBU;wBACT,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE;wBACtE;4BACE,OAAO,EAAE,iBAAiB;4BAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,QAAQ;yBACjE;qBACF,QACK;wBACJ,SAAS,EAAE,iCAAiC;wBAC5C,SAAS,EAAE,iCAAiC;wBAC5C,YAAY,EAAE,kCAAkC;wBAChD,YAAY,EAAE,4CAA4C;wBAC1D,YAAY,EAAE,oCAAoC;wBAClD,sBAAsB,EAAE,wBAAwB;wBAChD,4BAA4B,EAAE,WAAW;qBAC1C","sourcesContent":["import {\n Component,\n DestroyRef,\n computed,\n forwardRef,\n inject,\n input,\n model,\n output,\n} from '@angular/core';\nimport { SIDEBAR_SELECTION } from '@ng-native/device';\nimport { registerViewName } from '@ng-native/fabric';\nimport type { ButtonIcon } from './native-button.ts';\nimport { ControlBase, TouchableBase } from './pressable.ts';\nimport { Sidebar, type SidebarRow } from './sidebar.ts';\nimport { hostDraws } from './split-view.ts';\nimport { Text } from './text.ts';\n\n/**\n * On macOS a row of the sidebar's source list, a model object the desktop host builds an\n * NSTableCellView from. An item with children is a custom row: the host puts its views in a cell\n * of its own. Elsewhere a pressable view, drawnHere here.\n */\nregisterViewName('sidebar-item', {\n ios: 'View',\n android: 'View',\n macos: 'NgNativeSidebarItem',\n});\n\n/** A sidebar item's picture, as on `<native-tab>` and `<native-button>`. */\nexport type SidebarItemIcon = ButtonIcon;\n\n/**\n * A row of the sidebar:\n *\n * <sidebar-item label=\"Inbox\" sfSymbol=\"tray\" [badge]=\"unread()\" [(selected)]=\"inbox\" />\n *\n * With `path`, from `@ng-native/router`, the route selects it, as a `<native-tab>`'s does, and\n * choosing it navigates there. Without, `[(selected)]` holds the selection. Either way choosing it\n * fires `(select)` and deselects the sidebar's other items.\n *\n * Content inside the element replaces the default row of icon, label and badge: its pressables\n * take clicks, and while the row is selected its host has `data-selected` for CSS to restyle it.\n */\n@Component({\n selector: 'sidebar-item',\n imports: [Text],\n template: `\n <ng-content>\n @if (drawnHere) {\n <text class=\"sidebar-item-label\">{{ label() }}</text>\n @if (badge()) {\n <text class=\"sidebar-item-badge\">{{ badge() }}</text>\n }\n }\n </ng-content>\n `,\n 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 `,\n providers: [\n { provide: TouchableBase, useExisting: forwardRef(() => SidebarItem) },\n {\n provide: SIDEBAR_SELECTION,\n useFactory: () => inject(forwardRef(() => SidebarItem)).selected,\n },\n ],\n host: {\n '[label]': 'drawnHere ? undefined : label()',\n '[badge]': 'drawnHere ? undefined : badge()',\n '[sfSymbol]': 'drawnHere ? undefined : symbol()',\n '[drawable]': 'drawnHere ? undefined : drawableResource()',\n '[selected]': 'drawnHere ? undefined : selected()',\n '[attr.data-selected]': \"selected() ? '' : null\",\n '[class.sidebar-item-drawn]': 'drawnHere',\n },\n})\nexport class SidebarItem extends ControlBase implements SidebarRow {\n private readonly sidebar = inject(Sidebar, { optional: true });\n /** Whether this row is drawn here rather than by the desktop host. */\n protected readonly drawnHere = !hostDraws('sidebar-item');\n\n /** The row's text, and what it is announced as. */\n readonly label = input<string>();\n /** A count or a short word at the trailing edge. */\n readonly badge = input<string | undefined, string | number | null | undefined>(undefined, {\n transform: (value) => (value == null ? undefined : String(value)),\n });\n /** An SF Symbol before the label, on macOS and iOS. */\n readonly sfSymbol = input<string>();\n /** Android: a drawable resource before the label. */\n readonly drawableName = input<string>(undefined, { alias: 'drawable' });\n /** The picture for each OS at once, as on `<native-tab>`. */\n readonly icon = input<SidebarItemIcon>();\n /** Whether this is the sidebar's selected item. A `path` from the router sets it by route. */\n readonly selected = model(false);\n /** The user chose this item. */\n readonly select = output<void>();\n\n protected readonly symbol = computed(() => {\n const icon = this.icon();\n return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);\n });\n\n protected readonly drawableResource = computed(() => {\n const icon = this.icon();\n return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);\n });\n\n private stopSelect: (() => void) | null = null;\n\n constructor() {\n super();\n const remove = this.sidebar?.addRow(this);\n if (remove) inject(DestroyRef).onDestroy(remove);\n this.press.subscribe(() => this.choose());\n }\n\n protected override roleByDefault(): 'button' {\n return 'button';\n }\n\n protected override accessibleByDefault(): boolean {\n return true;\n }\n\n protected override focusableByDefault(): boolean {\n return true;\n }\n\n /** On macOS the source list takes the click and selects the row: the responder never does. */\n protected override claims(): boolean {\n return this.drawnHere && super.claims();\n }\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (this.drawnHere || this.stopSelect) return;\n this.stopSelect = this.engine.setEventListener(this.node, 'topSidebarSelect', (event) => {\n if ((event as { target?: unknown }).target === this.node) this.choose();\n });\n }\n\n override ngOnDestroy(): void {\n super.ngOnDestroy();\n this.stopSelect?.();\n }\n\n /** The user chose this row: select it, deselect the rest, and say so. */\n choose(): void {\n if (this.pressDisabled()) return;\n this.selected.set(true);\n this.sidebar?.chose(this);\n this.select.emit();\n }\n\n deselect(): void {\n this.selected.set(false);\n }\n}\n"]}
1
+ {"version":3,"file":"sidebar-item.js","sourceRoot":"","sources":["../src/sidebar-item.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,UAAU,EACV,MAAM,EACN,KAAK,EACL,KAAK,EACL,MAAM,EACN,MAAM,GAEP,MAAM,eAAe,CAAC;AACvB,OAAO,EAA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ent":["import {\n Component,\n DestroyRef,\n computed,\n forwardRef,\n inject,\n input,\n model,\n output,\n signal,\n type Signal,\n} from '@angular/core';\nimport { SIDEBAR_SELECTION } from '@ng-native/device';\nimport { registerViewName } from '@ng-native/fabric';\nimport type { ButtonIcon } from './native-button.ts';\nimport { ControlBase, TouchableBase } from './pressable.ts';\nimport { Sidebar, type SidebarRow } from './sidebar.ts';\nimport { hostDraws } from './split-view.ts';\nimport { Text } from './text.ts';\nimport { svgIconMarkup } from './svg-icon.ts';\n\n/**\n * On macOS a row of the sidebar's source list, a model object the desktop host builds an\n * NSTableCellView from. An item with children is a custom row: the host puts its views in a cell\n * of its own. Elsewhere a pressable view, drawnHere here.\n */\nregisterViewName('sidebar-item', {\n ios: 'View',\n android: 'View',\n macos: 'NgNativeSidebarItem',\n});\n\n/** A sidebar item's picture, as on `<native-tab>` and `<native-button>`. */\nexport type SidebarItemIcon = ButtonIcon;\n\n/**\n * A row of the sidebar:\n *\n * <sidebar-item label=\"Inbox\" sfSymbol=\"tray\" [badge]=\"unread()\" [(selected)]=\"inbox\" />\n *\n * With `path`, from `@ng-native/router`, the route selects it, as a `<native-tab>`'s does, and\n * choosing it navigates there. Without, `[(selected)]` holds the selection. Either way choosing it\n * fires `(select)` and deselects the sidebar's other items.\n *\n * Content inside the element replaces the default row of icon, label and badge: its pressables\n * take clicks, and while the row is selected its host has `data-selected` for CSS to restyle it.\n * On macOS it also has `data-emphasized` while that selection is drawn in the accent colour.\n */\n@Component({\n selector: 'sidebar-item',\n imports: [Text],\n template: `\n <ng-content>\n @if (drawnHere) {\n <text class=\"sidebar-item-label\">{{ label() }}</text>\n @if (badge()) {\n <text class=\"sidebar-item-badge\">{{ badge() }}</text>\n }\n }\n </ng-content>\n `,\n 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 `,\n providers: [\n { provide: TouchableBase, useExisting: forwardRef(() => SidebarItem) },\n {\n provide: SIDEBAR_SELECTION,\n useFactory: () => inject(forwardRef(() => SidebarItem)).selected,\n },\n ],\n host: {\n '[label]': 'drawnHere ? undefined : label()',\n '[badge]': 'drawnHere ? undefined : badge()',\n '[sfSymbol]': 'drawnHere ? undefined : symbol()',\n '[drawable]': 'drawnHere ? undefined : drawableResource()',\n '[svgIcon]': 'drawnHere ? undefined : svgIcon()',\n '[selected]': 'drawnHere ? undefined : selected()',\n '[attr.data-selected]': \"selected() ? '' : null\",\n '[attr.data-emphasized]': \"emphasized() ? '' : null\",\n '[class.sidebar-item-drawn]': 'drawnHere',\n },\n})\nexport class SidebarItem extends ControlBase implements SidebarRow {\n private readonly sidebar = inject(Sidebar, { optional: true });\n /** Whether this row is drawn here rather than by the desktop host. */\n protected readonly drawnHere = !hostDraws('sidebar-item');\n\n /** The row's text, and what it is announced as. */\n readonly label = input<string>();\n /** A count or a short word at the trailing edge. */\n readonly badge = input<string | undefined, string | number | null | undefined>(undefined, {\n transform: (value) => (value == null ? undefined : String(value)),\n });\n /** An SF Symbol before the label, on macOS and iOS. */\n readonly sfSymbol = input<string>();\n /** Android: a drawable resource before the label. */\n readonly drawableName = input<string>(undefined, { alias: 'drawable' });\n /**\n * The picture for each OS at once, as on `<native-tab>`. On macOS and Linux it can be an icon's\n * SVG markup, `[icon]=\"{ svg: lucideBlocks }\"`, which the host draws in the row's text colour.\n */\n readonly icon = input<SidebarItemIcon>();\n /** Whether this is the sidebar's selected item. A `path` from the router sets it by route. */\n readonly selected = model(false);\n /** The user chose this item. */\n readonly select = output<void>();\n\n /** On macOS, whether the source list draws the row's selection emphasized, as it last said. */\n private readonly hostEmphasized = signal(false);\n /**\n * macOS: whether the row is selected and its selection is drawn in the accent colour, while the\n * window is key and the sidebar has the focus. Otherwise the selection is grey, and this is false.\n * Always false on other platforms.\n */\n readonly emphasized: Signal<boolean> = computed(() => this.selected() && this.hostEmphasized());\n\n protected readonly symbol = computed(() => {\n const icon = this.icon();\n return this.sfSymbol() ?? (icon && 'sfSymbol' in icon ? icon.sfSymbol : undefined);\n });\n\n protected readonly drawableResource = computed(() => {\n const icon = this.icon();\n return this.drawableName() ?? (icon && 'drawable' in icon ? icon.drawable : undefined);\n });\n\n protected readonly svgIcon = computed(() => svgIconMarkup(this.icon(), 'sidebar-item'));\n\n private stopSelect: (() => void) | null = null;\n private stopEmphasis: (() => void) | null = null;\n\n constructor() {\n super();\n const remove = this.sidebar?.addRow(this);\n if (remove) inject(DestroyRef).onDestroy(remove);\n this.press.subscribe(() => this.choose());\n }\n\n protected override roleByDefault(): 'button' {\n return 'button';\n }\n\n protected override accessibleByDefault(): boolean {\n return true;\n }\n\n protected override focusableByDefault(): boolean {\n return true;\n }\n\n /** On macOS the source list takes the click and selects the row: the responder never does. */\n protected override claims(): boolean {\n return this.drawnHere && super.claims();\n }\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (this.drawnHere || this.stopSelect) return;\n this.stopSelect = this.engine.setEventListener(this.node, 'topSidebarSelect', (event) => {\n if ((event as { target?: unknown }).target === this.node) this.choose();\n });\n this.stopEmphasis = this.engine.setEventListener(this.node, 'topSidebarEmphasis', (event) => {\n const { target, nativeEvent } = event as {\n target?: unknown;\n nativeEvent?: { emphasized?: unknown };\n };\n if (target === this.node) this.hostEmphasized.set(nativeEvent?.emphasized === true);\n });\n }\n\n override ngOnDestroy(): void {\n super.ngOnDestroy();\n this.stopSelect?.();\n this.stopEmphasis?.();\n }\n\n /** The user chose this row: select it, deselect the rest, and say so. */\n choose(): void {\n if (this.pressDisabled()) return;\n this.selected.set(true);\n this.sidebar?.chose(this);\n this.select.emit();\n }\n\n deselect(): void {\n this.selected.set(false);\n }\n}\n"]}
package/dist/sidebar.js CHANGED
@@ -1,8 +1,8 @@
1
- import { Component, computed, inject, input, model, } from '@angular/core';
1
+ import { Component, computed, forwardRef, inject, input, model, } from '@angular/core';
2
2
  import { nativeSplitViews } from '@ng-native/device';
3
3
  import { registerViewName } from '@ng-native/fabric';
4
4
  import { optionalNumber } from "./transforms.js";
5
- import { SplitView, hostDraws } from "./split-view.js";
5
+ import { SIDEBAR, SplitView, hostDraws } from "./split-view.js";
6
6
  import { ViewBase } from "./view-base.js";
7
7
  import * as i0 from "@angular/core";
8
8
  /**
@@ -87,12 +87,13 @@ export class Sidebar extends ViewBase {
87
87
  this.split?.showContent();
88
88
  }
89
89
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Sidebar, deps: null, target: i0.ɵɵFactoryTarget.Component });
90
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: Sidebar, isStandalone: true, selector: "sidebar", inputs: { collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, autosave: { classPropertyName: "autosave", publicName: "autosave", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { collapsed: "collapsedChange" }, host: { properties: { "collapsed": "native ? collapsed() : undefined", "paneMinWidth": "native ? minWidth() : undefined", "paneMaxWidth": "native ? maxWidth() : undefined", "autosaveName": "native ? autosave() : undefined", "style.display": "hidden() ? 'none' : undefined", "style.width": "drawnWidth()", "style.minWidth": "native ? undefined : minWidth()", "style.maxWidth": "native ? undefined : maxWidth()", "style.flex": "split?.stacked() ? 1 : undefined" } }, usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true });
90
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: Sidebar, isStandalone: true, selector: "sidebar", inputs: { collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, autosave: { classPropertyName: "autosave", publicName: "autosave", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { collapsed: "collapsedChange" }, host: { properties: { "collapsed": "native ? collapsed() : undefined", "paneMinWidth": "native ? minWidth() : undefined", "paneMaxWidth": "native ? maxWidth() : undefined", "autosaveName": "native ? autosave() : undefined", "style.display": "hidden() ? 'none' : undefined", "style.width": "drawnWidth()", "style.minWidth": "native ? undefined : minWidth()", "style.maxWidth": "native ? undefined : maxWidth()", "style.flex": "split?.stacked() ? 1 : undefined" } }, providers: [{ provide: SIDEBAR, useExisting: forwardRef(() => Sidebar) }], usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true });
91
91
  }
92
92
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: Sidebar, decorators: [{
93
93
  type: Component,
94
94
  args: [{
95
95
  selector: 'sidebar',
96
+ providers: [{ provide: SIDEBAR, useExisting: forwardRef(() => Sidebar) }],
96
97
  template: '<ng-content />',
97
98
  host: {
98
99
  '[collapsed]': 'native ? collapsed() : undefined',
@@ -1 +1 @@
1
- {"version":3,"file":"sidebar.js","sourceRoot":"","sources":["../src/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,GAGN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAg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Q,EAAE,SAAS;oBACnB,QAAQ,EAAE,gBAAgB;oBAC1B,IAAI,EAAE;wBACJ,aAAa,EAAE,kCAAkC;wBACjD,gBAAgB,EAAE,iCAAiC;wBACnD,gBAAgB,EAAE,iCAAiC;wBACnD,gBAAgB,EAAE,iCAAiC;wBACnD,iBAAiB,EAAE,+BAA+B;wBAClD,eAAe,EAAE,cAAc;wBAC/B,kBAAkB,EAAE,iCAAiC;wBACrD,kBAAkB,EAAE,iCAAiC;wBACrD,cAAc,EAAE,kCAAkC;qBACnD;iBACF","sourcesContent":["import {\n Component,\n computed,\n inject,\n input,\n model,\n type OnDestroy,\n type OnInit,\n} from '@angular/core';\nimport { nativeSplitViews } from '@ng-native/device';\nimport { registerViewName } from '@ng-native/fabric';\nimport { optionalNumber } from './transforms.ts';\nimport { SplitView, hostDraws } from './split-view.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * On macOS the sidebar pane of the desktop host's split view, and on an iPad the sidebar column of\n * a UISplitViewController: the host owns its width, and Yoga gets the pane's frame back from it.\n * Elsewhere a view, drawn here.\n */\nregisterViewName('sidebar', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSidebar' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSidebar',\n});\n\n/** The width a drawn sidebar starts at, in points, where nothing styles one. */\nconst DRAWN_WIDTH = 240;\n\n/** A selectable row of the sidebar, as the sidebar sees it. */\nexport interface SidebarRow {\n /** Deselect, because another row of the same sidebar was chosen. */\n deselect(): void;\n}\n\n/**\n * The sidebar of a `<split-view>`. Its `<sidebar-section>`s and `<sidebar-item>`s are a source\n * list on macOS, an NSOutlineView; anything else in it (a search field, a footer) is drawn and\n * styled by CSS on every OS.\n *\n * `[(collapsed)]` follows the title bar's sidebar button, View > Show Sidebar and a drag that shuts\n * it, on macOS, and the sidebar button and swipe of a UISplitViewController on an iPad. `minWidth`\n * and `maxWidth` bound a drag of the divider on macOS and the sidebar column's width on an iPad,\n * and `autosave` names where macOS keeps the width and collapsed state across launches. Drawn, a collapsed sidebar is hidden,\n * the widths bound its style, and `autosave` is ignored.\n */\n@Component({\n selector: 'sidebar',\n template: '<ng-content />',\n host: {\n '[collapsed]': 'native ? collapsed() : undefined',\n '[paneMinWidth]': 'native ? minWidth() : undefined',\n '[paneMaxWidth]': 'native ? maxWidth() : undefined',\n '[autosaveName]': 'native ? autosave() : undefined',\n '[style.display]': \"hidden() ? 'none' : undefined\",\n '[style.width]': 'drawnWidth()',\n '[style.minWidth]': 'native ? undefined : minWidth()',\n '[style.maxWidth]': 'native ? undefined : maxWidth()',\n '[style.flex]': 'split?.stacked() ? 1 : undefined',\n },\n})\nexport class Sidebar extends ViewBase implements OnInit, OnDestroy {\n protected readonly split = inject(SplitView, { optional: true });\n /** Whether the host draws this sidebar: on macOS, and on an iPad. */\n protected readonly native = hostDraws('sidebar');\n\n /** Whether the sidebar is shut. Kept in step with the user's own toggles on macOS. */\n readonly collapsed = model(false);\n /** The narrowest a drag of the divider leaves it, in points. */\n readonly minWidth = input(undefined, { transform: optionalNumber });\n /** The widest a drag of the divider leaves it, in points. */\n readonly maxWidth = input(undefined, { transform: optionalNumber });\n /** macOS: the name the width and collapsed state are kept under across launches. */\n readonly autosave = input<string>();\n\n private readonly rows = new Set<SidebarRow>();\n private stopCollapsed: (() => void) | null = null;\n\n /** Drawn, hidden while collapsed beside the content, or while a stack shows the content. */\n protected readonly hidden = computed(() => {\n if (this.native) return false;\n if (this.split?.stacked()) return this.split.showing() === 'content';\n return this.collapsed();\n });\n\n /** Drawn beside the content, a column of a set width that the app's style can override. */\n protected readonly drawnWidth = computed(() =>\n this.native || this.split?.stacked() ? undefined : DRAWN_WIDTH,\n );\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (!this.native || this.stopCollapsed) return;\n this.stopCollapsed = this.engine.setEventListener(this.node, 'topSidebarCollapse', (event) => {\n const { target, nativeEvent } = event as {\n target?: unknown;\n nativeEvent?: { collapsed?: unknown };\n };\n // A sidebar inside this one's content reports its own.\n if (target !== this.node) return;\n if (typeof nativeEvent?.collapsed === 'boolean') this.collapsed.set(nativeEvent.collapsed);\n });\n }\n\n ngOnDestroy(): void {\n this.stopCollapsed?.();\n }\n\n /** Called by a row of this sidebar as it is created; answers the call that takes it away. */\n addRow(row: SidebarRow): () => void {\n this.rows.add(row);\n return () => this.rows.delete(row);\n }\n\n /** A row was chosen: the sidebar selects one row at a time, so every other one is deselected. */\n chose(row: SidebarRow): void {\n for (const other of this.rows) if (other !== row) other.deselect();\n this.split?.showContent();\n }\n}\n"]}
1
+ {"version":3,"file":"sidebar.js","sourceRoot":"","sources":["../src/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,QAAQ,EACR,UAAU,EACV,MAAM,EACN,KAAK,EACL,KAAK,GAGN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;;AAE1C;;;;GAIG;AACH,gBAAgB,CAAC,SAAS,EAAE;IAC1B,IAAI,GAAG;QACL,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC;IACzD,CAAC;IACD,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,iBAAiB;CACzB,CAAC,CAAC;AAEH,gFAAgF;AAChF,MAAM,WAAW,GAAG,GAAG,CAAC;AAQxB;;;;;;;;;;GAUG;AAiBH,MAAM,OAAO,OAAQ,SAAQ,QAAQ;IAChB,KAAK,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IACjE,qEAAqE;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e,EAAE,cAAc;wBAC/B,kBAAkB,EAAE,iCAAiC;wBACrD,kBAAkB,EAAE,iCAAiC;wBACrD,cAAc,EAAE,kCAAkC;qBACnD;iBACF","sourcesContent":["import {\n Component,\n computed,\n forwardRef,\n inject,\n input,\n model,\n type OnDestroy,\n type OnInit,\n} from '@angular/core';\nimport { nativeSplitViews } from '@ng-native/device';\nimport { registerViewName } from '@ng-native/fabric';\nimport { optionalNumber } from './transforms.ts';\nimport { SIDEBAR, SplitView, hostDraws } from './split-view.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * On macOS the sidebar pane of the desktop host's split view, and on an iPad the sidebar column of\n * a UISplitViewController: the host owns its width, and Yoga gets the pane's frame back from it.\n * Elsewhere a view, drawn here.\n */\nregisterViewName('sidebar', {\n get ios() {\n return nativeSplitViews() ? 'NgNativeSidebar' : 'View';\n },\n android: 'View',\n macos: 'NgNativeSidebar',\n});\n\n/** The width a drawn sidebar starts at, in points, where nothing styles one. */\nconst DRAWN_WIDTH = 240;\n\n/** A selectable row of the sidebar, as the sidebar sees it. */\nexport interface SidebarRow {\n /** Deselect, because another row of the same sidebar was chosen. */\n deselect(): void;\n}\n\n/**\n * The sidebar of a `<split-view>`. Its `<sidebar-section>`s and `<sidebar-item>`s are a source\n * list on macOS, an NSOutlineView; anything else in it (a search field, a footer) is drawn and\n * styled by CSS on every OS.\n *\n * `[(collapsed)]` follows the title bar's sidebar button, View > Show Sidebar and a drag that shuts\n * it, on macOS, and the sidebar button and swipe of a UISplitViewController on an iPad. `minWidth`\n * and `maxWidth` bound a drag of the divider on macOS and the sidebar column's width on an iPad,\n * and `autosave` names where macOS keeps the width and collapsed state across launches. Drawn, a collapsed sidebar is hidden,\n * the widths bound its style, and `autosave` is ignored.\n */\n@Component({\n selector: 'sidebar',\n providers: [{ provide: SIDEBAR, useExisting: forwardRef(() => Sidebar) }],\n template: '<ng-content />',\n host: {\n '[collapsed]': 'native ? collapsed() : undefined',\n '[paneMinWidth]': 'native ? minWidth() : undefined',\n '[paneMaxWidth]': 'native ? maxWidth() : undefined',\n '[autosaveName]': 'native ? autosave() : undefined',\n '[style.display]': \"hidden() ? 'none' : undefined\",\n '[style.width]': 'drawnWidth()',\n '[style.minWidth]': 'native ? undefined : minWidth()',\n '[style.maxWidth]': 'native ? undefined : maxWidth()',\n '[style.flex]': 'split?.stacked() ? 1 : undefined',\n },\n})\nexport class Sidebar extends ViewBase implements OnInit, OnDestroy {\n protected readonly split = inject(SplitView, { optional: true });\n /** Whether the host draws this sidebar: on macOS, and on an iPad. */\n protected readonly native = hostDraws('sidebar');\n\n /** Whether the sidebar is shut. Kept in step with the user's own toggles on macOS. */\n readonly collapsed = model(false);\n /** The narrowest a drag of the divider leaves it, in points. */\n readonly minWidth = input(undefined, { transform: optionalNumber });\n /** The widest a drag of the divider leaves it, in points. */\n readonly maxWidth = input(undefined, { transform: optionalNumber });\n /** macOS: the name the width and collapsed state are kept under across launches. */\n readonly autosave = input<string>();\n\n private readonly rows = new Set<SidebarRow>();\n private stopCollapsed: (() => void) | null = null;\n\n /** Drawn, hidden while collapsed beside the content, or while a stack shows the content. */\n protected readonly hidden = computed(() => {\n if (this.native) return false;\n if (this.split?.stacked()) return this.split.showing() === 'content';\n return this.collapsed();\n });\n\n /** Drawn beside the content, a column of a set width that the app's style can override. */\n protected readonly drawnWidth = computed(() =>\n this.native || this.split?.stacked() ? undefined : DRAWN_WIDTH,\n );\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (!this.native || this.stopCollapsed) return;\n this.stopCollapsed = this.engine.setEventListener(this.node, 'topSidebarCollapse', (event) => {\n const { target, nativeEvent } = event as {\n target?: unknown;\n nativeEvent?: { collapsed?: unknown };\n };\n // A sidebar inside this one's content reports its own.\n if (target !== this.node) return;\n if (typeof nativeEvent?.collapsed === 'boolean') this.collapsed.set(nativeEvent.collapsed);\n });\n }\n\n ngOnDestroy(): void {\n this.stopCollapsed?.();\n }\n\n /** Called by a row of this sidebar as it is created; answers the call that takes it away. */\n addRow(row: SidebarRow): () => void {\n this.rows.add(row);\n return () => this.rows.delete(row);\n }\n\n /** A row was chosen: the sidebar selects one row at a time, so every other one is deselected. */\n chose(row: SidebarRow): void {\n for (const other of this.rows) if (other !== row) other.deselect();\n this.split?.showContent();\n }\n}\n"]}