@ng-native/components 0.28.0 → 0.30.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.
- package/README.md +2 -2
- package/android/src/main/java/dev/ngnative/components/ColorSchemeModule.kt +116 -11
- package/dist/activity-indicator.js +3 -3
- package/dist/animated-style.js +3 -3
- package/dist/animations-web.js +3 -3
- package/dist/animations.js +3 -3
- package/dist/content-container.js +3 -3
- package/dist/context-menu.js +3 -3
- package/dist/drag-and-drop.js +6 -6
- package/dist/gestures-web.js +6 -6
- package/dist/gestures.js +6 -6
- package/dist/gradient-text.d.ts +1 -1
- package/dist/gradient-text.js +4 -4
- package/dist/gradient-text.js.map +1 -1
- package/dist/image-background.js +3 -3
- package/dist/image.js +3 -3
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/input-accessory-view.js +3 -3
- package/dist/keyboard-avoiding-view.js +3 -3
- package/dist/keyboard-dock.js +15 -15
- package/dist/markdown-blocks.d.ts +2 -1
- package/dist/markdown-blocks.js +22 -18
- package/dist/markdown-blocks.js.map +1 -1
- package/dist/markdown-columns.js +3 -3
- package/dist/markdown-stream.js +8 -5
- package/dist/markdown-stream.js.map +1 -1
- package/dist/markdown.js +5 -5
- package/dist/markdown.js.map +1 -1
- package/dist/menu.d.ts +11 -5
- package/dist/menu.js +24 -44
- package/dist/menu.js.map +1 -1
- package/dist/modal.js +8 -3
- package/dist/modal.js.map +1 -1
- package/dist/native-button.d.ts +25 -3
- package/dist/native-button.js +102 -8
- package/dist/native-button.js.map +1 -1
- package/dist/native-gesture.js +3 -3
- package/dist/native-ref.js +3 -3
- package/dist/press-menu.d.ts +38 -8
- package/dist/press-menu.js +80 -19
- package/dist/press-menu.js.map +1 -1
- package/dist/pressable.js +14 -13
- package/dist/pressable.js.map +1 -1
- package/dist/reanimated-web.js +6 -6
- package/dist/reanimated.js +6 -6
- package/dist/refresh-control.js +3 -3
- package/dist/safe-area-provider.js +3 -3
- package/dist/safe-area-view.js +3 -3
- package/dist/scroll-view-props.js +3 -3
- package/dist/scroll-view.d.ts +3 -1
- package/dist/scroll-view.js +10 -5
- package/dist/scroll-view.js.map +1 -1
- package/dist/section-list.d.ts +4 -4
- package/dist/section-list.js +37 -34
- package/dist/section-list.js.map +1 -1
- package/dist/shortcut.js +3 -3
- package/dist/sidebar-item.js +3 -3
- package/dist/sidebar-section.d.ts +12 -5
- package/dist/sidebar-section.js +32 -12
- package/dist/sidebar-section.js.map +1 -1
- package/dist/sidebar.d.ts +11 -3
- package/dist/sidebar.js +18 -8
- package/dist/sidebar.js.map +1 -1
- package/dist/split-view.d.ts +23 -2
- package/dist/split-view.js +36 -9
- package/dist/split-view.js.map +1 -1
- package/dist/stand-ins/animations.js +3 -3
- package/dist/sticky-headers.d.ts +19 -0
- package/dist/sticky-headers.js +67 -10
- package/dist/sticky-headers.js.map +1 -1
- package/dist/sticky-rows.d.ts +13 -11
- package/dist/sticky-rows.js +35 -21
- package/dist/sticky-rows.js.map +1 -1
- package/dist/svg-icon.d.ts +16 -2
- package/dist/svg-icon.js +19 -3
- package/dist/svg-icon.js.map +1 -1
- package/dist/switch.js +3 -3
- package/dist/template-slot.js +3 -3
- package/dist/text-input.js +3 -3
- package/dist/text.js +3 -3
- package/dist/touchable-opacity.js +3 -3
- package/dist/tray-icon.d.ts +7 -1
- package/dist/tray-icon.js +17 -5
- package/dist/tray-icon.js.map +1 -1
- package/dist/view-base.d.ts +18 -2
- package/dist/view-base.js +42 -10
- package/dist/view-base.js.map +1 -1
- package/dist/view.js +3 -3
- package/dist/virtual-list-layout.d.ts +5 -0
- package/dist/virtual-list-layout.js.map +1 -1
- package/dist/virtual-list-num-columns.d.ts +8 -4
- package/dist/virtual-list-num-columns.js +13 -5
- package/dist/virtual-list-num-columns.js.map +1 -1
- package/dist/virtual-list-sticky-level.d.ts +0 -6
- package/dist/virtual-list-sticky-level.js +5 -29
- package/dist/virtual-list-sticky-level.js.map +1 -1
- package/dist/virtual-list.d.ts +72 -11
- package/dist/virtual-list.js +285 -74
- package/dist/virtual-list.js.map +1 -1
- package/dist/visual-effect.d.ts +37 -0
- package/dist/visual-effect.js +60 -0
- package/dist/visual-effect.js.map +1 -0
- package/dist/worklet-scroll.js +3 -3
- package/dist/worklet-style.js +3 -3
- package/dist/written-props.js +9 -0
- package/dist/written-props.js.map +1 -1
- package/ios/NgNativeButtonComponentView.mm +8 -4
- package/ios/NgNativeButtonMetrics.h +9 -2
- package/ios/NgNativeButtonMetrics.mm +33 -4
- package/ios/NgNativeButtonShadowNode.h +2 -0
- package/ios/NgNativeButtonShadowNode.mm +5 -1
- package/ios/NgNativeComponents.podspec +2 -2
- package/ios/NgNativeKeyboardFocus.h +21 -0
- package/ios/NgNativeKeyboardFocus.mm +28 -0
- package/ios/NgNativeKeyboardFocusModule.mm +203 -0
- package/ios/NgNativeMenus.mm +62 -2
- package/ios/NgNativePressMenu.h +36 -0
- package/ios/NgNativePressMenu.mm +79 -0
- package/ios/NgNativeViewBinder.h +5 -0
- package/ios/NgNativeViewBinder.mm +31 -4
- package/package.json +6 -6
package/dist/scroll-view.js.map
CHANGED
|
@@ -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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AAE;wBACJ,yFAAyF;wBACzF,wFAAwF;wBACxF,iBAAiB,EAAE,iCAAiC;wBACpD,cAAc,EAAE,cAAc;wBAC9B,iBAAiB,EAAE,iBAAiB;wBACpC,kCAAkC,EAAE,kCAAkC;wBACtE,uBAAuB,EAAE,oBAAoB;wBAC7C,uBAAuB,EAAE,wBAAwB;qBAClD;iBACF;goCA2CgD,cAAc,kEACf,SAAS,OAAE,EAAE,IAAI,EAAE,UAAU,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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yFAAyF;wBACzF,wFAAwF;wBACxF,iBAAiB,EAAE,iCAAiC;wBACpD,cAAc,EAAE,cAAc;wBAC9B,iBAAiB,EAAE,iBAAiB;wBACpC,kCAAkC,EAAE,kCAAkC;wBACtE,uBAAuB,EAAE,oBAAoB;wBAC7C,uBAAuB,EAAE,wBAAwB;qBAClD;iBACF;goCA2CgD,cAAc,kEAEf,SAAS,OAAE,EAAE,IAAI,EAAE,UAAU,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 { 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"]}
|
package/dist/section-list.d.ts
CHANGED
|
@@ -138,10 +138,10 @@ type Height<A extends unknown[]> = number | ((...args: A) => number);
|
|
|
138
138
|
* takes them.
|
|
139
139
|
*
|
|
140
140
|
* ponytail: no `horizontal` or `inverted`, no viewability events, and no `highlighted` on a
|
|
141
|
-
* separator
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* taken.
|
|
141
|
+
* separator; sections built on `<virtual-list>` from `flattenSections` have the first three. No
|
|
142
|
+
* `keyExtractor` or `maintainVisibleContentPosition` either: rows are fixed height, so there is
|
|
143
|
+
* no measured height for a key to carry across an insert. The host is a plain view with the list
|
|
144
|
+
* filling it, where RN's host is the scroll view, so scroll-view props are not taken.
|
|
145
145
|
*/
|
|
146
146
|
export declare class SectionList<T, S extends SectionListSection<T> = SectionListSection<T>> {
|
|
147
147
|
readonly sections: import("@angular/core").InputSignal<readonly S[]>;
|
package/dist/section-list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, Directive, TemplateRef, computed, contentChild, inject, input, output, viewChild, } from '@angular/core';
|
|
1
|
+
import { Component, Directive, TemplateRef, computed, contentChild, inject, input, output, untracked, viewChild, } from '@angular/core';
|
|
2
2
|
import { isApplePlatform } from '@ng-native/fabric';
|
|
3
3
|
import { TemplateSlot } from "./template-slot.js";
|
|
4
4
|
import { numberOr, optionalBoolean } from "./transforms.js";
|
|
@@ -11,10 +11,10 @@ export class SectionHeader {
|
|
|
11
11
|
static ngTemplateContextGuard(_directive, context) {
|
|
12
12
|
return true;
|
|
13
13
|
}
|
|
14
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
15
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.
|
|
14
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
15
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.3.0", type: SectionHeader, isStandalone: true, selector: "ng-template[sectionHeader]", ngImport: i0 });
|
|
16
16
|
}
|
|
17
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
17
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionHeader, decorators: [{
|
|
18
18
|
type: Directive,
|
|
19
19
|
args: [{ selector: 'ng-template[sectionHeader]' }]
|
|
20
20
|
}] });
|
|
@@ -24,10 +24,10 @@ export class SectionFooter {
|
|
|
24
24
|
static ngTemplateContextGuard(_directive, context) {
|
|
25
25
|
return true;
|
|
26
26
|
}
|
|
27
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
28
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.
|
|
27
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
28
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.3.0", type: SectionFooter, isStandalone: true, selector: "ng-template[sectionFooter]", ngImport: i0 });
|
|
29
29
|
}
|
|
30
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionFooter, decorators: [{
|
|
31
31
|
type: Directive,
|
|
32
32
|
args: [{ selector: 'ng-template[sectionFooter]' }]
|
|
33
33
|
}] });
|
|
@@ -37,10 +37,10 @@ export class SectionItem {
|
|
|
37
37
|
static ngTemplateContextGuard(_directive, context) {
|
|
38
38
|
return true;
|
|
39
39
|
}
|
|
40
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
41
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.
|
|
40
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionItem, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
41
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.3.0", type: SectionItem, isStandalone: true, selector: "ng-template[sectionItem]", ngImport: i0 });
|
|
42
42
|
}
|
|
43
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
43
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionItem, decorators: [{
|
|
44
44
|
type: Directive,
|
|
45
45
|
args: [{ selector: 'ng-template[sectionItem]' }]
|
|
46
46
|
}] });
|
|
@@ -50,10 +50,10 @@ export class SectionSeparator {
|
|
|
50
50
|
static ngTemplateContextGuard(_directive, context) {
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
54
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.
|
|
53
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionSeparator, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
54
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.3.0", type: SectionSeparator, isStandalone: true, selector: "ng-template[sectionSeparator]", ngImport: i0 });
|
|
55
55
|
}
|
|
56
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
56
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionSeparator, decorators: [{
|
|
57
57
|
type: Directive,
|
|
58
58
|
args: [{ selector: 'ng-template[sectionSeparator]' }]
|
|
59
59
|
}] });
|
|
@@ -67,10 +67,10 @@ export class SectionEdgeSeparator {
|
|
|
67
67
|
static ngTemplateContextGuard(_directive, context) {
|
|
68
68
|
return true;
|
|
69
69
|
}
|
|
70
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
71
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.
|
|
70
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionEdgeSeparator, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
71
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.3.0", type: SectionEdgeSeparator, isStandalone: true, selector: "ng-template[sectionEdgeSeparator]", ngImport: i0 });
|
|
72
72
|
}
|
|
73
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionEdgeSeparator, decorators: [{
|
|
74
74
|
type: Directive,
|
|
75
75
|
args: [{ selector: 'ng-template[sectionEdgeSeparator]' }]
|
|
76
76
|
}] });
|
|
@@ -144,10 +144,10 @@ const measure = (height, ...args) => typeof height === 'number' ? height : heigh
|
|
|
144
144
|
* takes them.
|
|
145
145
|
*
|
|
146
146
|
* ponytail: no `horizontal` or `inverted`, no viewability events, and no `highlighted` on a
|
|
147
|
-
* separator
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* taken.
|
|
147
|
+
* separator; sections built on `<virtual-list>` from `flattenSections` have the first three. No
|
|
148
|
+
* `keyExtractor` or `maintainVisibleContentPosition` either: rows are fixed height, so there is
|
|
149
|
+
* no measured height for a key to carry across an insert. The host is a plain view with the list
|
|
150
|
+
* filling it, where RN's host is the scroll view, so scroll-view props are not taken.
|
|
151
151
|
*/
|
|
152
152
|
export class SectionList {
|
|
153
153
|
sections = input.required(/* @ts-ignore */
|
|
@@ -220,19 +220,22 @@ export class SectionList {
|
|
|
220
220
|
* with sticky headers the header's height is allowed for so the item is not hidden under it.
|
|
221
221
|
*/
|
|
222
222
|
scrollToLocation(options) {
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
index
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
223
|
+
// Untracked, as the list's own scrolls are.
|
|
224
|
+
untracked(() => {
|
|
225
|
+
const sections = this.sections();
|
|
226
|
+
let index = options.itemIndex;
|
|
227
|
+
for (let i = 0; i < options.sectionIndex; i++)
|
|
228
|
+
index += sections[i].data.length + 2;
|
|
229
|
+
let viewOffset = options.viewOffset ?? 0;
|
|
230
|
+
const section = sections[options.sectionIndex];
|
|
231
|
+
if (options.itemIndex > 0 && this.sticky() && section) {
|
|
232
|
+
viewOffset += measure(this.sectionHeaderHeight(), section);
|
|
233
|
+
}
|
|
234
|
+
this.list().scrollToIndex({ index, viewOffset, animated: options.animated });
|
|
235
|
+
});
|
|
233
236
|
}
|
|
234
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
235
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.
|
|
237
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionList, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
238
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.0", type: SectionList, isStandalone: true, selector: "section-list", inputs: { sections: { classPropertyName: "sections", publicName: "sections", isSignal: true, isRequired: true, transformFunction: null }, itemHeight: { classPropertyName: "itemHeight", publicName: "itemHeight", isSignal: true, isRequired: true, transformFunction: null }, sectionHeaderHeight: { classPropertyName: "sectionHeaderHeight", publicName: "sectionHeaderHeight", isSignal: true, isRequired: false, transformFunction: null }, sectionFooterHeight: { classPropertyName: "sectionFooterHeight", publicName: "sectionFooterHeight", isSignal: true, isRequired: false, transformFunction: null }, stickySectionHeadersEnabled: { classPropertyName: "stickySectionHeadersEnabled", publicName: "stickySectionHeadersEnabled", isSignal: true, isRequired: false, transformFunction: null }, overscan: { classPropertyName: "overscan", publicName: "overscan", isSignal: true, isRequired: false, transformFunction: null }, windowSize: { classPropertyName: "windowSize", publicName: "windowSize", isSignal: true, isRequired: false, transformFunction: null }, velocityLead: { classPropertyName: "velocityLead", publicName: "velocityLead", isSignal: true, isRequired: false, transformFunction: null }, endReachedThreshold: { classPropertyName: "endReachedThreshold", publicName: "endReachedThreshold", isSignal: true, isRequired: false, transformFunction: null }, contentPadding: { classPropertyName: "contentPadding", publicName: "contentPadding", isSignal: true, isRequired: false, transformFunction: null }, keyboardShouldPersistTaps: { classPropertyName: "keyboardShouldPersistTaps", publicName: "keyboardShouldPersistTaps", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { endReached: "endReached" }, queries: [{ propertyName: "header", first: true, predicate: SectionHeader, descendants: true, isSignal: true }, { propertyName: "footer", first: true, predicate: SectionFooter, descendants: true, isSignal: true }, { propertyName: "item", first: true, predicate: SectionItem, descendants: true, isSignal: true }, { propertyName: "separator", first: true, predicate: SectionSeparator, descendants: true, isSignal: true }, { propertyName: "edge", first: true, predicate: SectionEdgeSeparator, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "list", first: true, predicate: ["list"], descendants: true, isSignal: true }], exportAs: ["sectionList"], ngImport: i0, template: `
|
|
236
239
|
<virtual-list
|
|
237
240
|
#list
|
|
238
241
|
[items]="rows()"
|
|
@@ -299,9 +302,9 @@ export class SectionList {
|
|
|
299
302
|
}
|
|
300
303
|
<view listFooter><ng-content select="[listFooter]" /></view>
|
|
301
304
|
</virtual-list>
|
|
302
|
-
`, isInline: true, dependencies: [{ kind: "directive", type: TemplateSlot, selector: "[templateSlot]", inputs: ["templateSlot", "templateSlotContext"] }, { kind: "directive", type: View, selector: "view" }, { kind: "component", type: VirtualList, selector: "virtual-list", inputs: ["items", "itemHeight", "estimatedItemHeight", "contentPadding", "rowGap", "keyExtractor", "itemType", "maintainVisibleContentPosition", "overscan", "windowSize", "velocityLead", "endReachedThreshold", "horizontal", "inverted", "stickyIndices", "stickyHeader", "keyboardShouldPersistTaps", "itemVisiblePercentThreshold"], outputs: ["endReached", "viewableItemsChanged"], exportAs: ["virtualList"] }] });
|
|
305
|
+
`, isInline: true, dependencies: [{ kind: "directive", type: TemplateSlot, selector: "[templateSlot]", inputs: ["templateSlot", "templateSlotContext"] }, { kind: "directive", type: View, selector: "view" }, { kind: "component", type: VirtualList, selector: "virtual-list", inputs: ["items", "itemHeight", "estimatedItemHeight", "contentPadding", "rowGap", "keyExtractor", "itemType", "maintainVisibleContentPosition", "overscan", "windowSize", "velocityLead", "endReachedThreshold", "horizontal", "inverted", "stickyIndices", "stickyHeader", "keyboardShouldPersistTaps", "itemVisiblePercentThreshold"], outputs: ["endReached", "contentSizeChange", "viewableItemsChanged"], exportAs: ["virtualList"] }] });
|
|
303
306
|
}
|
|
304
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
307
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SectionList, decorators: [{
|
|
305
308
|
type: Component,
|
|
306
309
|
args: [{
|
|
307
310
|
selector: 'section-list',
|
package/dist/section-list.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"section-list.js","sourceRoot":"","sources":["../src/section-list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,MAAM,EACN,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;;AA8CzE,6EAA6E;AAE7E,MAAM,OAAO,aAAa;IACf,QAAQ,GAAG,MAAM,CAAiC,WAAW,CAAC,CAAC;IAExE,MAAM,CAAC,sBAAsB,CAC3B,UAA4B,EAC5B,OAAgB;QAEhB,OAAO,IAAI,CAAC;IACd,CAAC;uGARU,aAAa;2FAAb,aAAa;;2FAAb,aAAa;kBADzB,SAAS;mBAAC,EAAE,QAAQ,EAAE,4BAA4B,EAAE;;AAYrD,6EAA6E;AA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I,IAAI,CAAC,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;YACtD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/E,CAAC;uGA5EU,WAAW;2FAAX,WAAW,iyDAsBqC,aAAa,yFACb,aAAa,uFACd,WAAW,4FACD,gBAAgB,uFACjB,oBAAoB,yMA/F7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmET,4DApES,YAAY,4GAAE,IAAI,iDAAE,WAAW;;2FAsE9B,WAAW;kBAzEvB,SAAS;mBAAC;oBACT,QAAQ,EAAE,cAAc;oBACxB,QAAQ,EAAE,aAAa;oBACvB,OAAO,EAAE,CAAC,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC;oBAC1C,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmET;iBACF;w1CAuB4D,aAAa,wFACb,aAAa,sFACd,WAAW,2FACD,gBAAgB,sFACjB,oBAAoB,+DACb,MAAM","sourcesContent":["import {\n Component,\n Directive,\n TemplateRef,\n computed,\n contentChild,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport { isApplePlatform } from '@ng-native/fabric';\nimport { TemplateSlot } from './template-slot.ts';\nimport { numberOr, optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport type { KeyboardShouldPersistTaps } from './keyboard-taps.ts';\nimport { VirtualList, type VirtualListPadding } from './virtual-list.ts';\n\n/** A section as RN's SectionList takes it: its rows in `data`, plus whatever else it carries. */\nexport interface SectionListSection<T> {\n readonly key?: string;\n readonly title?: string;\n readonly data: readonly T[];\n}\n\n/** What a section header or footer template is given. */\nexport interface SectionContext<S> {\n readonly $implicit: S;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What an item template is given. `index` counts within the section, as `renderItem` does. */\nexport interface SectionItemContext<T, S> {\n readonly $implicit: T;\n readonly item: T;\n readonly index: number;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What a separator template is given: the items either side of it, in the same section. */\nexport interface SectionSeparatorContext<T, S> {\n readonly $implicit: T;\n readonly leadingItem: T;\n readonly trailingItem: T;\n readonly section: S;\n}\n\n/**\n * What a section separator template is given: the section, and what is either side of the edge\n * it sits at. At a section's start `leadingItem` is undefined, and at its end `trailingItem` is.\n */\nexport interface SectionEdgeSeparatorContext<T, S> {\n readonly $implicit: S;\n readonly section: S;\n readonly leadingItem: T | undefined;\n readonly leadingSection: S | undefined;\n readonly trailingItem: T | undefined;\n readonly trailingSection: S | undefined;\n}\n\n/** `<ng-template sectionHeader let-section>`: RN's `renderSectionHeader`. */\n@Directive({ selector: 'ng-template[sectionHeader]' })\nexport class SectionHeader<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionHeader<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionFooter let-section>`: RN's `renderSectionFooter`. */\n@Directive({ selector: 'ng-template[sectionFooter]' })\nexport class SectionFooter<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionFooter<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionItem let-item let-index=\"index\">`: RN's `renderItem`. */\n@Directive({ selector: 'ng-template[sectionItem]' })\nexport class SectionItem<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionItemContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionItem<T, S>,\n context: unknown,\n ): context is SectionItemContext<T, S> {\n return true;\n }\n}\n\n/** `<ng-template sectionSeparator let-leading>`: RN's `ItemSeparatorComponent`. */\n@Directive({ selector: 'ng-template[sectionSeparator]' })\nexport class SectionSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionSeparator<T, S>,\n context: unknown,\n ): context is SectionSeparatorContext<T, S> {\n return true;\n }\n}\n\n/**\n * `<ng-template sectionEdgeSeparator let-section>`: RN's `SectionSeparatorComponent`, drawn at\n * both edges of a section that has items, between its header and first item and between its\n * last item and footer.\n */\n@Directive({ selector: 'ng-template[sectionEdgeSeparator]' })\nexport class SectionEdgeSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionEdgeSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionEdgeSeparator<T, S>,\n context: unknown,\n ): context is SectionEdgeSeparatorContext<T, S> {\n return true;\n }\n}\n\n/** One row of the flattened list. */\nexport type SectionRow<T, S> =\n | {\n readonly kind: 'header' | 'footer';\n readonly context: SectionContext<S>;\n readonly separator: null;\n readonly leading: null;\n readonly trailing: null;\n }\n | {\n readonly kind: 'item';\n readonly context: SectionItemContext<T, S>;\n /** Null for a section's last item, where the section separator takes its place, as in RN. */\n readonly separator: SectionSeparatorContext<T, S> | null;\n /** The section separator before a section's first item, and null on every other. */\n readonly leading: SectionEdgeSeparatorContext<T, S> | null;\n /** The section separator after a section's last item, and null on every other. */\n readonly trailing: SectionEdgeSeparatorContext<T, S> | null;\n };\n\n/**\n * Flatten sections into the rows RN's `VirtualizedSectionList` gives its list: for each section a\n * header, its items, then a footer. The header and footer rows are there whether or not anything\n * is drawn in them, as in RN, which is what keeps `scrollToLocation`'s arithmetic the same.\n *\n * The section separators ride on the first and last item, as RN's do: `SectionSeparatorComponent`\n * is the first item's leading separator and the last item's trailing one, so an empty section has\n * none, and a last item has it in place of the item separator.\n */\nexport function flattenSections<T, S extends SectionListSection<T>>(\n sections: readonly S[],\n): SectionRow<T, S>[] {\n const rows: SectionRow<T, S>[] = [];\n const edges = { leading: null, trailing: null };\n sections.forEach((section, sectionIndex) => {\n const context = { $implicit: section, section, sectionIndex };\n rows.push({ kind: 'header', context, separator: null, ...edges });\n const data = section.data;\n const last = data.length - 1;\n const around = {\n $implicit: section,\n section,\n leadingSection: sections[sectionIndex - 1],\n trailingSection: sections[sectionIndex + 1],\n };\n data.forEach((item, index) => {\n const trailingItem = data[index + 1];\n rows.push({\n kind: 'item',\n context: { $implicit: item, item, index, section, sectionIndex },\n separator:\n index < last\n ? { $implicit: item, leadingItem: item, trailingItem: trailingItem!, section }\n : null,\n leading: index === 0 ? { ...around, leadingItem: undefined, trailingItem: item } : null,\n trailing: index === last ? { ...around, leadingItem: item, trailingItem: undefined } : null,\n });\n });\n rows.push({ kind: 'footer', context, separator: null, ...edges });\n });\n return rows;\n}\n\ntype Height<A extends unknown[]> = number | ((...args: A) => number);\n\nconst measure = <A extends unknown[]>(height: Height<A>, ...args: A): number =>\n typeof height === 'number' ? height : height(...args);\n\n/**\n * RN's SectionList: sections of items, each with a header and footer, over `<virtual-list>`.\n *\n * RN's own is a VirtualizedList over flattened rows, and so is this. Sections become one list of\n * header, item and footer rows, the rows are placed by `<virtual-list>`'s variable-height windowing,\n * and this component draws each from the caller's templates:\n *\n * ```html\n * <section-list [sections]=\"sections\" [itemHeight]=\"44\" [sectionHeaderHeight]=\"28\">\n * <ng-template sectionHeader let-section><text>{{ section.title }}</text></ng-template>\n * <ng-template sectionItem let-item><text>{{ item }}</text></ng-template>\n * <ng-template sectionSeparator><view [style]=\"line\"></view></ng-template>\n * <ng-template sectionEdgeSeparator><view [style]=\"rule\"></view></ng-template>\n * </section-list>\n * ```\n *\n * Rows are fixed height, as `getItemLayout` makes them in RN: `itemHeight`, `sectionHeaderHeight`\n * and `sectionFooterHeight` are numbers or functions. An item's height includes its separators,\n * which are drawn in the item's slot: the item separator at its bottom, only between items of the\n * same section, and the section separator at the top of a section's first item and the bottom of\n * its last, as RN's `SectionSeparatorComponent` is.\n *\n * `stickySectionHeadersEnabled` pins the current section's header until the next pushes it off.\n * It defaults to on for iOS and off for Android, as RN's does. `listHeader` and `listFooter`\n * content and a `<refresh-control>` pass through to the list.\n *\n * `contentPadding` and `keyboardShouldPersistTaps` pass through to the list as `<virtual-list>`\n * takes them.\n *\n * ponytail: no `horizontal` or `inverted`, no viewability events, and no `highlighted` on a\n * separator. No `keyExtractor` or `maintainVisibleContentPosition` either: rows are fixed height,\n * so there is no measured height for a key to carry across an insert. The host is a plain view\n * with the list filling it, where RN's host is the scroll view, so scroll-view props are not\n * taken.\n */\n@Component({\n selector: 'section-list',\n exportAs: 'sectionList',\n imports: [TemplateSlot, View, VirtualList],\n template: `\n <virtual-list\n #list\n [items]=\"rows()\"\n [itemHeight]=\"rowHeight\"\n [stickyIndices]=\"stickyRows()\"\n [overscan]=\"overscan()\"\n [windowSize]=\"windowSize()\"\n [velocityLead]=\"velocityLead()\"\n [endReachedThreshold]=\"endReachedThreshold()\"\n [contentPadding]=\"contentPadding()\"\n [keyboardShouldPersistTaps]=\"keyboardShouldPersistTaps()\"\n [style]=\"fill\"\n (endReached)=\"endReached.emit($event)\"\n >\n <ng-content select=\"refresh-control\" ngProjectAs=\"refresh-control\" />\n <view listHeader><ng-content select=\"[listHeader]\" /></view>\n <ng-content />\n @for (row of list.window(); track row.index) {\n <view [style]=\"row.style\">\n @switch (row.item.kind) {\n @case ('header') {\n @if (header(); as header) {\n <ng-container\n [templateSlot]=\"header.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('footer') {\n @if (footer(); as footer) {\n <ng-container\n [templateSlot]=\"footer.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('item') {\n @if (row.item.leading; as start) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"start\" />\n }\n }\n <view [style]=\"cell\">\n @if (item(); as item) {\n <ng-container\n [templateSlot]=\"item.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n </view>\n @if (separator(); as separator) {\n @if (row.item.separator; as gap) {\n <ng-container [templateSlot]=\"separator.template\" [templateSlotContext]=\"gap\" />\n }\n }\n @if (row.item.trailing; as end) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"end\" />\n }\n }\n }\n }\n </view>\n }\n <view listFooter><ng-content select=\"[listFooter]\" /></view>\n </virtual-list>\n `,\n})\nexport class SectionList<T, S extends SectionListSection<T> = SectionListSection<T>> {\n readonly sections = input.required<readonly S[]>();\n /** Each item's height, including every separator drawn in its slot. */\n readonly itemHeight = input.required<Height<[item: T, index: number, section: S]>>();\n readonly sectionHeaderHeight = input<Height<[section: S]>>(0);\n readonly sectionFooterHeight = input<Height<[section: S]>>(0);\n /** Pin the current section's header. Defaults to true on iOS and false on Android, as RN. */\n readonly stickySectionHeadersEnabled = input(undefined, { transform: optionalBoolean });\n readonly overscan = input(4, { transform: numberOr(4) });\n /** How many viewports of rows to render at most. See `<virtual-list>`. */\n readonly windowSize = input(5, { transform: numberOr(5) });\n /** How far past the viewport a fast scroll renders. See `<virtual-list>`. */\n readonly velocityLead = input(500, { transform: numberOr(500) });\n readonly endReachedThreshold = input(2, { transform: numberOr(2) });\n /** Space around the rows, inside the scrolling content. See `<virtual-list>`. */\n readonly contentPadding = input<VirtualListPadding>(0);\n /** What a tap in the list does while a text input has the keyboard up. See `ScrollView`. */\n readonly keyboardShouldPersistTaps = input<KeyboardShouldPersistTaps>('never');\n\n /** The end of the last section is within `endReachedThreshold`. See `<virtual-list>`. */\n readonly endReached = output<{ distanceFromEnd: number }>();\n\n protected readonly header = contentChild<SectionHeader<S>>(SectionHeader);\n protected readonly footer = contentChild<SectionFooter<S>>(SectionFooter);\n protected readonly item = contentChild<SectionItem<T, S>>(SectionItem);\n protected readonly separator = contentChild<SectionSeparator<T, S>>(SectionSeparator);\n protected readonly edge = contentChild<SectionEdgeSeparator<T, S>>(SectionEdgeSeparator);\n private readonly list = viewChild.required<VirtualList<SectionRow<T, S>>>('list');\n\n protected readonly fill = { flex: 1 };\n /** The item fills its slot between its separators, as RN's cell draws them around it. */\n protected readonly cell = { flex: 1 };\n\n protected readonly rows = computed(() => flattenSections<T, S>(this.sections()));\n\n private readonly sticky = computed(() => this.stickySectionHeadersEnabled() ?? isApplePlatform());\n\n /** The header rows, pinned in turn, when headers stick and there is a header to draw. */\n protected readonly stickyRows = computed(() => {\n if (!this.sticky() || !this.header()) return [];\n const indices: number[] = [];\n this.rows().forEach((row, index) => {\n if (row.kind === 'header') indices.push(index);\n });\n return indices;\n });\n\n protected readonly rowHeight = (row: SectionRow<T, S>): number => {\n const { section } = row.context;\n if (row.kind === 'item') {\n return measure(this.itemHeight(), row.context.item, row.context.index, section);\n }\n return row.kind === 'header'\n ? measure(this.sectionHeaderHeight(), section)\n : measure(this.sectionFooterHeight(), section);\n };\n\n /**\n * Scroll to an item, RN's way: `itemIndex` 0 is the section's header and 1 its first item, and\n * with sticky headers the header's height is allowed for so the item is not hidden under it.\n */\n scrollToLocation(options: {\n sectionIndex: number;\n itemIndex: number;\n viewOffset?: number;\n animated?: boolean;\n }): void {\n const sections = this.sections();\n let index = options.itemIndex;\n for (let i = 0; i < options.sectionIndex; i++) index += sections[i]!.data.length + 2;\n let viewOffset = options.viewOffset ?? 0;\n const section = sections[options.sectionIndex];\n if (options.itemIndex > 0 && this.sticky() && section) {\n viewOffset += measure(this.sectionHeaderHeight(), section);\n }\n this.list().scrollToIndex({ index, viewOffset, animated: options.animated });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"section-list.js","sourceRoot":"","sources":["../src/section-list.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,SAAS,EACT,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,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S;mBAAC;oBACT,QAAQ,EAAE,cAAc;oBACxB,QAAQ,EAAE,aAAa;oBACvB,OAAO,EAAE,CAAC,YAAY,EAAE,IAAI,EAAE,WAAW,CAAC;oBAC1C,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmET;iBACF;w1CAuB4D,aAAa,wFACb,aAAa,sFACd,WAAW,2FACD,gBAAgB,sFACjB,oBAAoB,+DACb,MAAM","sourcesContent":["import {\n Component,\n Directive,\n TemplateRef,\n computed,\n contentChild,\n inject,\n input,\n output,\n untracked,\n viewChild,\n} from '@angular/core';\nimport { isApplePlatform } from '@ng-native/fabric';\nimport { TemplateSlot } from './template-slot.ts';\nimport { numberOr, optionalBoolean } from './transforms.ts';\nimport { View } from './view.ts';\nimport type { KeyboardShouldPersistTaps } from './keyboard-taps.ts';\nimport { VirtualList, type VirtualListPadding } from './virtual-list.ts';\n\n/** A section as RN's SectionList takes it: its rows in `data`, plus whatever else it carries. */\nexport interface SectionListSection<T> {\n readonly key?: string;\n readonly title?: string;\n readonly data: readonly T[];\n}\n\n/** What a section header or footer template is given. */\nexport interface SectionContext<S> {\n readonly $implicit: S;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What an item template is given. `index` counts within the section, as `renderItem` does. */\nexport interface SectionItemContext<T, S> {\n readonly $implicit: T;\n readonly item: T;\n readonly index: number;\n readonly section: S;\n readonly sectionIndex: number;\n}\n\n/** What a separator template is given: the items either side of it, in the same section. */\nexport interface SectionSeparatorContext<T, S> {\n readonly $implicit: T;\n readonly leadingItem: T;\n readonly trailingItem: T;\n readonly section: S;\n}\n\n/**\n * What a section separator template is given: the section, and what is either side of the edge\n * it sits at. At a section's start `leadingItem` is undefined, and at its end `trailingItem` is.\n */\nexport interface SectionEdgeSeparatorContext<T, S> {\n readonly $implicit: S;\n readonly section: S;\n readonly leadingItem: T | undefined;\n readonly leadingSection: S | undefined;\n readonly trailingItem: T | undefined;\n readonly trailingSection: S | undefined;\n}\n\n/** `<ng-template sectionHeader let-section>`: RN's `renderSectionHeader`. */\n@Directive({ selector: 'ng-template[sectionHeader]' })\nexport class SectionHeader<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionHeader<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionFooter let-section>`: RN's `renderSectionFooter`. */\n@Directive({ selector: 'ng-template[sectionFooter]' })\nexport class SectionFooter<S = unknown> {\n readonly template = inject<TemplateRef<SectionContext<S>>>(TemplateRef);\n\n static ngTemplateContextGuard<S>(\n _directive: SectionFooter<S>,\n context: unknown,\n ): context is SectionContext<S> {\n return true;\n }\n}\n\n/** `<ng-template sectionItem let-item let-index=\"index\">`: RN's `renderItem`. */\n@Directive({ selector: 'ng-template[sectionItem]' })\nexport class SectionItem<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionItemContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionItem<T, S>,\n context: unknown,\n ): context is SectionItemContext<T, S> {\n return true;\n }\n}\n\n/** `<ng-template sectionSeparator let-leading>`: RN's `ItemSeparatorComponent`. */\n@Directive({ selector: 'ng-template[sectionSeparator]' })\nexport class SectionSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionSeparator<T, S>,\n context: unknown,\n ): context is SectionSeparatorContext<T, S> {\n return true;\n }\n}\n\n/**\n * `<ng-template sectionEdgeSeparator let-section>`: RN's `SectionSeparatorComponent`, drawn at\n * both edges of a section that has items, between its header and first item and between its\n * last item and footer.\n */\n@Directive({ selector: 'ng-template[sectionEdgeSeparator]' })\nexport class SectionEdgeSeparator<T = unknown, S = unknown> {\n readonly template = inject<TemplateRef<SectionEdgeSeparatorContext<T, S>>>(TemplateRef);\n\n static ngTemplateContextGuard<T, S>(\n _directive: SectionEdgeSeparator<T, S>,\n context: unknown,\n ): context is SectionEdgeSeparatorContext<T, S> {\n return true;\n }\n}\n\n/** One row of the flattened list. */\nexport type SectionRow<T, S> =\n | {\n readonly kind: 'header' | 'footer';\n readonly context: SectionContext<S>;\n readonly separator: null;\n readonly leading: null;\n readonly trailing: null;\n }\n | {\n readonly kind: 'item';\n readonly context: SectionItemContext<T, S>;\n /** Null for a section's last item, where the section separator takes its place, as in RN. */\n readonly separator: SectionSeparatorContext<T, S> | null;\n /** The section separator before a section's first item, and null on every other. */\n readonly leading: SectionEdgeSeparatorContext<T, S> | null;\n /** The section separator after a section's last item, and null on every other. */\n readonly trailing: SectionEdgeSeparatorContext<T, S> | null;\n };\n\n/**\n * Flatten sections into the rows RN's `VirtualizedSectionList` gives its list: for each section a\n * header, its items, then a footer. The header and footer rows are there whether or not anything\n * is drawn in them, as in RN, which is what keeps `scrollToLocation`'s arithmetic the same.\n *\n * The section separators ride on the first and last item, as RN's do: `SectionSeparatorComponent`\n * is the first item's leading separator and the last item's trailing one, so an empty section has\n * none, and a last item has it in place of the item separator.\n */\nexport function flattenSections<T, S extends SectionListSection<T>>(\n sections: readonly S[],\n): SectionRow<T, S>[] {\n const rows: SectionRow<T, S>[] = [];\n const edges = { leading: null, trailing: null };\n sections.forEach((section, sectionIndex) => {\n const context = { $implicit: section, section, sectionIndex };\n rows.push({ kind: 'header', context, separator: null, ...edges });\n const data = section.data;\n const last = data.length - 1;\n const around = {\n $implicit: section,\n section,\n leadingSection: sections[sectionIndex - 1],\n trailingSection: sections[sectionIndex + 1],\n };\n data.forEach((item, index) => {\n const trailingItem = data[index + 1];\n rows.push({\n kind: 'item',\n context: { $implicit: item, item, index, section, sectionIndex },\n separator:\n index < last\n ? { $implicit: item, leadingItem: item, trailingItem: trailingItem!, section }\n : null,\n leading: index === 0 ? { ...around, leadingItem: undefined, trailingItem: item } : null,\n trailing: index === last ? { ...around, leadingItem: item, trailingItem: undefined } : null,\n });\n });\n rows.push({ kind: 'footer', context, separator: null, ...edges });\n });\n return rows;\n}\n\ntype Height<A extends unknown[]> = number | ((...args: A) => number);\n\nconst measure = <A extends unknown[]>(height: Height<A>, ...args: A): number =>\n typeof height === 'number' ? height : height(...args);\n\n/**\n * RN's SectionList: sections of items, each with a header and footer, over `<virtual-list>`.\n *\n * RN's own is a VirtualizedList over flattened rows, and so is this. Sections become one list of\n * header, item and footer rows, the rows are placed by `<virtual-list>`'s variable-height windowing,\n * and this component draws each from the caller's templates:\n *\n * ```html\n * <section-list [sections]=\"sections\" [itemHeight]=\"44\" [sectionHeaderHeight]=\"28\">\n * <ng-template sectionHeader let-section><text>{{ section.title }}</text></ng-template>\n * <ng-template sectionItem let-item><text>{{ item }}</text></ng-template>\n * <ng-template sectionSeparator><view [style]=\"line\"></view></ng-template>\n * <ng-template sectionEdgeSeparator><view [style]=\"rule\"></view></ng-template>\n * </section-list>\n * ```\n *\n * Rows are fixed height, as `getItemLayout` makes them in RN: `itemHeight`, `sectionHeaderHeight`\n * and `sectionFooterHeight` are numbers or functions. An item's height includes its separators,\n * which are drawn in the item's slot: the item separator at its bottom, only between items of the\n * same section, and the section separator at the top of a section's first item and the bottom of\n * its last, as RN's `SectionSeparatorComponent` is.\n *\n * `stickySectionHeadersEnabled` pins the current section's header until the next pushes it off.\n * It defaults to on for iOS and off for Android, as RN's does. `listHeader` and `listFooter`\n * content and a `<refresh-control>` pass through to the list.\n *\n * `contentPadding` and `keyboardShouldPersistTaps` pass through to the list as `<virtual-list>`\n * takes them.\n *\n * ponytail: no `horizontal` or `inverted`, no viewability events, and no `highlighted` on a\n * separator; sections built on `<virtual-list>` from `flattenSections` have the first three. No\n * `keyExtractor` or `maintainVisibleContentPosition` either: rows are fixed height, so there is\n * no measured height for a key to carry across an insert. The host is a plain view with the list\n * filling it, where RN's host is the scroll view, so scroll-view props are not taken.\n */\n@Component({\n selector: 'section-list',\n exportAs: 'sectionList',\n imports: [TemplateSlot, View, VirtualList],\n template: `\n <virtual-list\n #list\n [items]=\"rows()\"\n [itemHeight]=\"rowHeight\"\n [stickyIndices]=\"stickyRows()\"\n [overscan]=\"overscan()\"\n [windowSize]=\"windowSize()\"\n [velocityLead]=\"velocityLead()\"\n [endReachedThreshold]=\"endReachedThreshold()\"\n [contentPadding]=\"contentPadding()\"\n [keyboardShouldPersistTaps]=\"keyboardShouldPersistTaps()\"\n [style]=\"fill\"\n (endReached)=\"endReached.emit($event)\"\n >\n <ng-content select=\"refresh-control\" ngProjectAs=\"refresh-control\" />\n <view listHeader><ng-content select=\"[listHeader]\" /></view>\n <ng-content />\n @for (row of list.window(); track row.index) {\n <view [style]=\"row.style\">\n @switch (row.item.kind) {\n @case ('header') {\n @if (header(); as header) {\n <ng-container\n [templateSlot]=\"header.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('footer') {\n @if (footer(); as footer) {\n <ng-container\n [templateSlot]=\"footer.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n }\n @case ('item') {\n @if (row.item.leading; as start) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"start\" />\n }\n }\n <view [style]=\"cell\">\n @if (item(); as item) {\n <ng-container\n [templateSlot]=\"item.template\"\n [templateSlotContext]=\"row.item.context\"\n />\n }\n </view>\n @if (separator(); as separator) {\n @if (row.item.separator; as gap) {\n <ng-container [templateSlot]=\"separator.template\" [templateSlotContext]=\"gap\" />\n }\n }\n @if (row.item.trailing; as end) {\n @if (edge(); as edge) {\n <ng-container [templateSlot]=\"edge.template\" [templateSlotContext]=\"end\" />\n }\n }\n }\n }\n </view>\n }\n <view listFooter><ng-content select=\"[listFooter]\" /></view>\n </virtual-list>\n `,\n})\nexport class SectionList<T, S extends SectionListSection<T> = SectionListSection<T>> {\n readonly sections = input.required<readonly S[]>();\n /** Each item's height, including every separator drawn in its slot. */\n readonly itemHeight = input.required<Height<[item: T, index: number, section: S]>>();\n readonly sectionHeaderHeight = input<Height<[section: S]>>(0);\n readonly sectionFooterHeight = input<Height<[section: S]>>(0);\n /** Pin the current section's header. Defaults to true on iOS and false on Android, as RN. */\n readonly stickySectionHeadersEnabled = input(undefined, { transform: optionalBoolean });\n readonly overscan = input(4, { transform: numberOr(4) });\n /** How many viewports of rows to render at most. See `<virtual-list>`. */\n readonly windowSize = input(5, { transform: numberOr(5) });\n /** How far past the viewport a fast scroll renders. See `<virtual-list>`. */\n readonly velocityLead = input(500, { transform: numberOr(500) });\n readonly endReachedThreshold = input(2, { transform: numberOr(2) });\n /** Space around the rows, inside the scrolling content. See `<virtual-list>`. */\n readonly contentPadding = input<VirtualListPadding>(0);\n /** What a tap in the list does while a text input has the keyboard up. See `ScrollView`. */\n readonly keyboardShouldPersistTaps = input<KeyboardShouldPersistTaps>('never');\n\n /** The end of the last section is within `endReachedThreshold`. See `<virtual-list>`. */\n readonly endReached = output<{ distanceFromEnd: number }>();\n\n protected readonly header = contentChild<SectionHeader<S>>(SectionHeader);\n protected readonly footer = contentChild<SectionFooter<S>>(SectionFooter);\n protected readonly item = contentChild<SectionItem<T, S>>(SectionItem);\n protected readonly separator = contentChild<SectionSeparator<T, S>>(SectionSeparator);\n protected readonly edge = contentChild<SectionEdgeSeparator<T, S>>(SectionEdgeSeparator);\n private readonly list = viewChild.required<VirtualList<SectionRow<T, S>>>('list');\n\n protected readonly fill = { flex: 1 };\n /** The item fills its slot between its separators, as RN's cell draws them around it. */\n protected readonly cell = { flex: 1 };\n\n protected readonly rows = computed(() => flattenSections<T, S>(this.sections()));\n\n private readonly sticky = computed(() => this.stickySectionHeadersEnabled() ?? isApplePlatform());\n\n /** The header rows, pinned in turn, when headers stick and there is a header to draw. */\n protected readonly stickyRows = computed(() => {\n if (!this.sticky() || !this.header()) return [];\n const indices: number[] = [];\n this.rows().forEach((row, index) => {\n if (row.kind === 'header') indices.push(index);\n });\n return indices;\n });\n\n protected readonly rowHeight = (row: SectionRow<T, S>): number => {\n const { section } = row.context;\n if (row.kind === 'item') {\n return measure(this.itemHeight(), row.context.item, row.context.index, section);\n }\n return row.kind === 'header'\n ? measure(this.sectionHeaderHeight(), section)\n : measure(this.sectionFooterHeight(), section);\n };\n\n /**\n * Scroll to an item, RN's way: `itemIndex` 0 is the section's header and 1 its first item, and\n * with sticky headers the header's height is allowed for so the item is not hidden under it.\n */\n scrollToLocation(options: {\n sectionIndex: number;\n itemIndex: number;\n viewOffset?: number;\n animated?: boolean;\n }): void {\n // Untracked, as the list's own scrolls are.\n untracked(() => {\n const sections = this.sections();\n let index = options.itemIndex;\n for (let i = 0; i < options.sectionIndex; i++) index += sections[i]!.data.length + 2;\n let viewOffset = options.viewOffset ?? 0;\n const section = sections[options.sectionIndex];\n if (options.itemIndex > 0 && this.sticky() && section) {\n viewOffset += measure(this.sectionHeaderHeight(), section);\n }\n this.list().scrollToIndex({ index, viewOffset, animated: options.animated });\n });\n }\n}\n"]}
|
package/dist/shortcut.js
CHANGED
|
@@ -24,10 +24,10 @@ export class Shortcut {
|
|
|
24
24
|
const stop = this.menus.addShortcut(this.shortcut, this.shortcutLabel, () => this.shortcutPress.emit());
|
|
25
25
|
this.destroyRef.onDestroy(stop);
|
|
26
26
|
}
|
|
27
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
28
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.
|
|
27
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: Shortcut, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
28
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.3.0", type: Shortcut, isStandalone: true, selector: "[shortcut]:not(menu-item)", inputs: { shortcut: { classPropertyName: "shortcut", publicName: "shortcut", isSignal: true, isRequired: true, transformFunction: null }, shortcutLabel: { classPropertyName: "shortcutLabel", publicName: "shortcutLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { shortcutPress: "shortcutPress" }, ngImport: i0 });
|
|
29
29
|
}
|
|
30
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
30
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: Shortcut, decorators: [{
|
|
31
31
|
type: Directive,
|
|
32
32
|
args: [{ selector: '[shortcut]:not(menu-item)' }]
|
|
33
33
|
}], propDecorators: { shortcut: [{ type: i0.Input, args: [{ isSignal: true, alias: "shortcut", required: true }] }], shortcutLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "shortcutLabel", required: false }] }], shortcutPress: [{ type: i0.Output, args: ["shortcutPress"] }] } });
|
package/dist/sidebar-item.js
CHANGED
|
@@ -129,8 +129,8 @@ export class SidebarItem extends ControlBase {
|
|
|
129
129
|
deselect() {
|
|
130
130
|
this.selected.set(false);
|
|
131
131
|
}
|
|
132
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
133
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.
|
|
132
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SidebarItem, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
133
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.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: [
|
|
134
134
|
{ provide: TouchableBase, useExisting: forwardRef(() => SidebarItem) },
|
|
135
135
|
{
|
|
136
136
|
provide: SIDEBAR_SELECTION,
|
|
@@ -147,7 +147,7 @@ export class SidebarItem extends ControlBase {
|
|
|
147
147
|
</ng-content>
|
|
148
148
|
`, isInline: true, styles: ["\n /* A row drawn here. On macOS the host's cell is the row, and custom content fills it. */\n :host(.sidebar-item-drawn) {\n flex-direction: row;\n align-items: center;\n gap: 8px;\n padding: 6px 12px;\n }\n .sidebar-item-label {\n flex: 1;\n }\n .sidebar-item-badge {\n opacity: 0.6;\n }\n "], dependencies: [{ kind: "directive", type: Text, selector: "text", inputs: ["numberOfLines", "ellipsizeMode", "selectable", "selectionColor", "allowFontScaling", "maxFontSizeMultiplier", "dynamicTypeRamp", "adjustsFontSizeToFit", "minimumFontScale", "lineBreakStrategyIOS", "textBreakStrategy", "dataDetectorType", "android_hyphenationFrequency", "pressable", "suppressHighlighting"], exportAs: ["text"] }] });
|
|
149
149
|
}
|
|
150
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
150
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SidebarItem, decorators: [{
|
|
151
151
|
type: Component,
|
|
152
152
|
args: [{ selector: 'sidebar-item', imports: [Text], template: `
|
|
153
153
|
<ng-content>
|
|
@@ -1,21 +1,28 @@
|
|
|
1
|
+
import { type OnDestroy, type OnInit } from '@angular/core';
|
|
1
2
|
import { ViewBase } from './view-base.ts';
|
|
2
3
|
import * as i0 from "@angular/core";
|
|
3
4
|
/**
|
|
4
5
|
* A group of `<sidebar-item>`s with an optional `title`. A `collapsible` one shows and hides its
|
|
5
6
|
* items from its title: on macOS with the source list's own disclosure, drawn by a press on the
|
|
6
|
-
* title elsewhere.
|
|
7
|
+
* title elsewhere. `[(collapsed)]` starts it folded, folds it from code and hears the user fold or
|
|
8
|
+
* open it. Selection survives the section collapsing.
|
|
7
9
|
*/
|
|
8
|
-
export declare class SidebarSection extends ViewBase {
|
|
10
|
+
export declare class SidebarSection extends ViewBase implements OnInit, OnDestroy {
|
|
9
11
|
/** Whether this section is drawn here rather than by the desktop host. */
|
|
10
12
|
protected readonly drawn: boolean;
|
|
11
|
-
/** Drawn, whether the items show: a collapsible section's title toggles it. */
|
|
12
|
-
protected readonly expanded: import("@angular/core").WritableSignal<boolean>;
|
|
13
13
|
/** The heading over the section's items. None gives an untitled group. */
|
|
14
14
|
readonly title: import("@angular/core").InputSignal<string | undefined>;
|
|
15
15
|
/** Whether the title shows and hides the section's items. */
|
|
16
16
|
readonly collapsible: import("@angular/core").InputSignalWithTransform<boolean | undefined, unknown>;
|
|
17
|
+
/** Whether a collapsible section's items are folded away. Kept in step with the user's folds. */
|
|
18
|
+
readonly collapsed: import("@angular/core").ModelSignal<boolean>;
|
|
19
|
+
private stopCollapsed;
|
|
17
20
|
/** Whether the items show: always, unless a title that can show them again hid them. */
|
|
18
21
|
protected readonly shown: import("@angular/core").Signal<boolean>;
|
|
22
|
+
ngOnInit(): void;
|
|
23
|
+
ngOnDestroy(): void;
|
|
24
|
+
/** The host's report of the user folding or opening this section. */
|
|
25
|
+
private hearFold;
|
|
19
26
|
static ɵfac: i0.ɵɵFactoryDeclaration<SidebarSection, never>;
|
|
20
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<SidebarSection, "sidebar-section", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "collapsible": { "alias": "collapsible"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
27
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SidebarSection, "sidebar-section", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; "collapsible": { "alias": "collapsible"; "required": false; "isSignal": true; }; "collapsed": { "alias": "collapsed"; "required": false; "isSignal": true; }; }, { "collapsed": "collapsedChange"; }, never, ["*"], true, never>;
|
|
21
28
|
}
|
package/dist/sidebar-section.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component, computed, input,
|
|
1
|
+
import { Component, computed, input, model } from '@angular/core';
|
|
2
2
|
import { registerViewName } from '@ng-native/fabric';
|
|
3
3
|
import { Pressable } from "./pressable.js";
|
|
4
4
|
import { hostDraws } from "./split-view.js";
|
|
@@ -18,30 +18,49 @@ registerViewName('sidebar-section', {
|
|
|
18
18
|
/**
|
|
19
19
|
* A group of `<sidebar-item>`s with an optional `title`. A `collapsible` one shows and hides its
|
|
20
20
|
* items from its title: on macOS with the source list's own disclosure, drawn by a press on the
|
|
21
|
-
* title elsewhere.
|
|
21
|
+
* title elsewhere. `[(collapsed)]` starts it folded, folds it from code and hears the user fold or
|
|
22
|
+
* open it. Selection survives the section collapsing.
|
|
22
23
|
*/
|
|
23
24
|
export class SidebarSection extends ViewBase {
|
|
24
25
|
/** Whether this section is drawn here rather than by the desktop host. */
|
|
25
26
|
drawn = !hostDraws('sidebar-section');
|
|
26
|
-
/** Drawn, whether the items show: a collapsible section's title toggles it. */
|
|
27
|
-
expanded = signal(true, /* @ts-ignore */
|
|
28
|
-
...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
29
27
|
/** The heading over the section's items. None gives an untitled group. */
|
|
30
28
|
title = input(/* @ts-ignore */
|
|
31
29
|
...(ngDevMode ? [undefined, { debugName: "title" }] : /* istanbul ignore next */ []));
|
|
32
30
|
/** Whether the title shows and hides the section's items. */
|
|
33
31
|
collapsible = input(false, { ...(ngDevMode ? { debugName: "collapsible" } : /* istanbul ignore next */ {}), transform: optionalBoolean });
|
|
32
|
+
/** Whether a collapsible section's items are folded away. Kept in step with the user's folds. */
|
|
33
|
+
collapsed = model(false, /* @ts-ignore */
|
|
34
|
+
...(ngDevMode ? [{ debugName: "collapsed" }] : /* istanbul ignore next */ []));
|
|
35
|
+
stopCollapsed = null;
|
|
34
36
|
/** Whether the items show: always, unless a title that can show them again hid them. */
|
|
35
|
-
shown = computed(() => !this.drawn || this.
|
|
37
|
+
shown = computed(() => !this.drawn || !this.collapsed() || !(this.collapsible() && this.title()), /* @ts-ignore */
|
|
36
38
|
...(ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []));
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
ngOnInit() {
|
|
40
|
+
super.ngOnInit();
|
|
41
|
+
if (this.drawn || this.stopCollapsed)
|
|
42
|
+
return;
|
|
43
|
+
this.stopCollapsed = this.engine.setEventListener(this.node, 'topSidebarSectionCollapse', (event) => this.hearFold(event));
|
|
44
|
+
}
|
|
45
|
+
ngOnDestroy() {
|
|
46
|
+
this.stopCollapsed?.();
|
|
47
|
+
}
|
|
48
|
+
/** The host's report of the user folding or opening this section. */
|
|
49
|
+
hearFold(event) {
|
|
50
|
+
const { target, nativeEvent } = event;
|
|
51
|
+
if (target !== this.node)
|
|
52
|
+
return;
|
|
53
|
+
if (typeof nativeEvent?.collapsed === 'boolean')
|
|
54
|
+
this.collapsed.set(nativeEvent.collapsed);
|
|
55
|
+
}
|
|
56
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SidebarSection, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
57
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.3.0", type: SidebarSection, isStandalone: true, selector: "sidebar-section", inputs: { title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, collapsible: { classPropertyName: "collapsible", publicName: "collapsible", isSignal: true, isRequired: false, transformFunction: null }, collapsed: { classPropertyName: "collapsed", publicName: "collapsed", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { collapsed: "collapsedChange" }, host: { properties: { "title": "drawn ? undefined : title()", "collapsible": "drawn ? undefined : collapsible()", "collapsed": "drawn ? undefined : collapsed()" } }, usesInheritance: true, ngImport: i0, template: `
|
|
39
58
|
@if (drawn && title()) {
|
|
40
59
|
<pressable
|
|
41
60
|
class="sidebar-section-title"
|
|
42
61
|
accessibilityRole="header"
|
|
43
62
|
[disabled]="!collapsible()"
|
|
44
|
-
(press)="
|
|
63
|
+
(press)="collapsed.set(!collapsed())"
|
|
45
64
|
>
|
|
46
65
|
<text>{{ title() }}</text>
|
|
47
66
|
</pressable>
|
|
@@ -51,7 +70,7 @@ export class SidebarSection extends ViewBase {
|
|
|
51
70
|
}
|
|
52
71
|
`, isInline: true, styles: ["\n .sidebar-section-title {\n padding: 8px 12px 4px;\n opacity: 0.6;\n }\n "], dependencies: [{ kind: "directive", type: Pressable, selector: "pressable", exportAs: ["pressable"] }, { kind: "directive", type: Text, selector: "text", inputs: ["numberOfLines", "ellipsizeMode", "selectable", "selectionColor", "allowFontScaling", "maxFontSizeMultiplier", "dynamicTypeRamp", "adjustsFontSizeToFit", "minimumFontScale", "lineBreakStrategyIOS", "textBreakStrategy", "dataDetectorType", "android_hyphenationFrequency", "pressable", "suppressHighlighting"], exportAs: ["text"] }] });
|
|
53
72
|
}
|
|
54
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
73
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.3.0", ngImport: i0, type: SidebarSection, decorators: [{
|
|
55
74
|
type: Component,
|
|
56
75
|
args: [{ selector: 'sidebar-section', imports: [Pressable, Text], template: `
|
|
57
76
|
@if (drawn && title()) {
|
|
@@ -59,7 +78,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
59
78
|
class="sidebar-section-title"
|
|
60
79
|
accessibilityRole="header"
|
|
61
80
|
[disabled]="!collapsible()"
|
|
62
|
-
(press)="
|
|
81
|
+
(press)="collapsed.set(!collapsed())"
|
|
63
82
|
>
|
|
64
83
|
<text>{{ title() }}</text>
|
|
65
84
|
</pressable>
|
|
@@ -70,6 +89,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImpor
|
|
|
70
89
|
`, host: {
|
|
71
90
|
'[title]': 'drawn ? undefined : title()',
|
|
72
91
|
'[collapsible]': 'drawn ? undefined : collapsible()',
|
|
92
|
+
'[collapsed]': 'drawn ? undefined : collapsed()',
|
|
73
93
|
}, styles: ["\n .sidebar-section-title {\n padding: 8px 12px 4px;\n opacity: 0.6;\n }\n "] }]
|
|
74
|
-
}], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], collapsible: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsible", required: false }] }] } });
|
|
94
|
+
}], propDecorators: { title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], collapsible: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsible", required: false }] }], collapsed: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsed", required: false }] }, { type: i0.Output, args: ["collapsedChange"] }] } });
|
|
75
95
|
//# sourceMappingURL=sidebar-section.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidebar-section.js","sourceRoot":"","sources":["../src/sidebar-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"sidebar-section.js","sourceRoot":"","sources":["../src/sidebar-section.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAA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C,MAAM,CAAC,gBAAgB,CAC/C,IAAI,CAAC,IAAI,EACT,2BAA2B,EAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAChC,CAAC;IACJ,CAAC;IAED,WAAW;QACT,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;IACzB,CAAC;IAED,qEAAqE;IAC7D,QAAQ,CAAC,KAAc;QAC7B,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,KAG/B,CAAC;QACF,IAAI,MAAM,KAAK,IAAI,CAAC,IAAI;YAAE,OAAO;QACjC,IAAI,OAAO,WAAW,EAAE,SAAS,KAAK,SAAS;YAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC7F,CAAC;uGAxCU,cAAc;2FAAd,cAAc,qsBA3Bf;;;;;;;;;;;;;;GAcT,sKAfS,SAAS,+EAAE,IAAI;;2FA4Bd,cAAc;kBA9B1B,SAAS;+BACE,iBAAiB,WAClB,CAAC,SAAS,EAAE,IAAI,CAAC,YAChB;;;;;;;;;;;;;;GAcT,QAOK;wBACJ,SAAS,EAAE,6BAA6B;wBACxC,eAAe,EAAE,mCAAmC;wBACpD,aAAa,EAAE,iCAAiC;qBACjD","sourcesContent":["import { Component, computed, input, model, type OnDestroy, type OnInit } from '@angular/core';\nimport { registerViewName } from '@ng-native/fabric';\nimport { Pressable } from './pressable.ts';\nimport { hostDraws } from './split-view.ts';\nimport { optionalBoolean } from './transforms.ts';\nimport { Text } from './text.ts';\nimport { ViewBase } from './view-base.ts';\n\n/**\n * On macOS a group of the sidebar's source list, a model object the desktop host reads its rows\n * from. Neighbouring sections in one parent are one NSOutlineView. Elsewhere a view, drawn here.\n */\nregisterViewName('sidebar-section', {\n ios: 'View',\n android: 'View',\n macos: 'NgNativeSidebarSection',\n});\n\n/**\n * A group of `<sidebar-item>`s with an optional `title`. A `collapsible` one shows and hides its\n * items from its title: on macOS with the source list's own disclosure, drawn by a press on the\n * title elsewhere. `[(collapsed)]` starts it folded, folds it from code and hears the user fold or\n * open it. Selection survives the section collapsing.\n */\n@Component({\n selector: 'sidebar-section',\n imports: [Pressable, Text],\n template: `\n @if (drawn && title()) {\n <pressable\n class=\"sidebar-section-title\"\n accessibilityRole=\"header\"\n [disabled]=\"!collapsible()\"\n (press)=\"collapsed.set(!collapsed())\"\n >\n <text>{{ title() }}</text>\n </pressable>\n }\n @if (shown()) {\n <ng-content />\n }\n `,\n styles: `\n .sidebar-section-title {\n padding: 8px 12px 4px;\n opacity: 0.6;\n }\n `,\n host: {\n '[title]': 'drawn ? undefined : title()',\n '[collapsible]': 'drawn ? undefined : collapsible()',\n '[collapsed]': 'drawn ? undefined : collapsed()',\n },\n})\nexport class SidebarSection extends ViewBase implements OnInit, OnDestroy {\n /** Whether this section is drawn here rather than by the desktop host. */\n protected readonly drawn = !hostDraws('sidebar-section');\n\n /** The heading over the section's items. None gives an untitled group. */\n readonly title = input<string>();\n /** Whether the title shows and hides the section's items. */\n readonly collapsible = input(false, { transform: optionalBoolean });\n /** Whether a collapsible section's items are folded away. Kept in step with the user's folds. */\n readonly collapsed = model(false);\n\n private stopCollapsed: (() => void) | null = null;\n\n /** Whether the items show: always, unless a title that can show them again hid them. */\n protected readonly shown = computed(\n () => !this.drawn || !this.collapsed() || !(this.collapsible() && this.title()),\n );\n\n override ngOnInit(): void {\n super.ngOnInit();\n if (this.drawn || this.stopCollapsed) return;\n this.stopCollapsed = this.engine.setEventListener(\n this.node,\n 'topSidebarSectionCollapse',\n (event) => this.hearFold(event),\n );\n }\n\n ngOnDestroy(): void {\n this.stopCollapsed?.();\n }\n\n /** The host's report of the user folding or opening this section. */\n private hearFold(event: unknown): void {\n const { target, nativeEvent } = event as {\n target?: unknown;\n nativeEvent?: { collapsed?: unknown };\n };\n if (target !== this.node) return;\n if (typeof nativeEvent?.collapsed === 'boolean') this.collapsed.set(nativeEvent.collapsed);\n }\n}\n"]}
|