@octane-xplat/ui 0.6.0 → 0.7.1
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 +14 -4
- package/dist/native/{Absolute.native.tsrx.js → Absolute.tsrx.js} +2 -2
- package/dist/native/{Accordion.native.tsrx.js → Accordion.tsrx.js} +3 -3
- package/dist/native/{ActivityIndicator.native.tsrx.js → ActivityIndicator.tsrx.js} +2 -2
- package/dist/native/{Alert.native.tsrx.js → Alert.tsrx.js} +3 -3
- package/dist/native/{Avatar.native.tsrx.js → Avatar.tsrx.js} +3 -3
- package/dist/native/{AvatarGroup.native.tsrx.js → AvatarGroup.tsrx.js} +3 -3
- package/dist/native/{Badge.native.tsrx.js → Badge.tsrx.js} +2 -2
- package/dist/native/{Banner.native.tsrx.js → Banner.tsrx.js} +3 -3
- package/dist/native/{Breadcrumb.native.tsrx.js → Breadcrumb.tsrx.js} +2 -2
- package/dist/native/{Button.native.tsrx.js → Button.tsrx.js} +3 -3
- package/dist/native/{Card.native.tsrx.js → Card.tsrx.js} +2 -2
- package/dist/native/{Checkbox.native.tsrx.js → Checkbox.tsrx.js} +2 -2
- package/dist/native/{CheckboxGroup.native.tsrx.js → CheckboxGroup.tsrx.js} +3 -3
- package/dist/native/{Chip.native.tsrx.js → Chip.tsrx.js} +2 -2
- package/dist/native/{Collapsible.native.tsrx.js → Collapsible.tsrx.js} +3 -3
- package/dist/native/{CommandPalette.native.tsrx.js → CommandPalette.tsrx.js} +4 -4
- package/dist/native/{ContextMenu.native.tsrx.js → ContextMenu.tsrx.js} +4 -4
- package/dist/native/{Drawer.native.tsrx.js → Drawer.tsrx.js} +2 -2
- package/dist/native/{DropdownMenu.native.tsrx.js → DropdownMenu.tsrx.js} +5 -5
- package/dist/native/{Empty.native.tsrx.js → Empty.tsrx.js} +3 -3
- package/dist/native/{FieldGroup.native.tsrx.js → FieldGroup.tsrx.js} +2 -2
- package/dist/native/{FormField.native.tsrx.js → FormField.tsrx.js} +2 -2
- package/dist/native/{Grid.native.tsrx.js → Grid.tsrx.js} +2 -2
- package/dist/native/{Heading.native.tsrx.js → Heading.tsrx.js} +3 -3
- package/dist/native/Hoverable.tsrx.js +139 -0
- package/dist/native/{Icon.native.tsrx.js → Icon.tsrx.js} +3 -3
- package/dist/native/{Image.native.tsrx.js → Image.tsrx.js} +4 -4
- package/dist/native/{InputNumber.native.tsrx.js → InputNumber.tsrx.js} +4 -4
- package/dist/native/{InputRating.native.tsrx.js → InputRating.tsrx.js} +3 -3
- package/dist/native/{InputTags.native.tsrx.js → InputTags.tsrx.js} +4 -4
- package/dist/native/{Kbd.native.tsrx.js → Kbd.tsrx.js} +2 -2
- package/dist/native/{KeyboardAvoiding.native.tsrx.js → KeyboardAvoiding.mobile.tsrx.js} +5 -3
- package/dist/native/{Link.native.tsrx.js → Link.tsrx.js} +2 -2
- package/dist/native/ListItem.tsrx.js +178 -0
- package/dist/native/Meter.tsrx.js +70 -0
- package/dist/native/{NavLink.native.tsrx.js → NavLink.tsrx.js} +3 -3
- package/dist/native/{NavigationMenu.native.tsrx.js → NavigationMenu.tsrx.js} +3 -3
- package/dist/native/{Overlay.native.tsrx.js → Overlay.tsrx.js} +2 -2
- package/dist/native/{Pagination.native.tsrx.js → Pagination.tsrx.js} +2 -2
- package/dist/native/{PinInput.native.tsrx.js → PinInput.tsrx.js} +3 -3
- package/dist/native/{Popover.native.tsrx.js → Popover.tsrx.js} +4 -4
- package/dist/native/{Pressable.native.tsrx.js → Pressable.tsrx.js} +4 -4
- package/dist/native/{ProgressGroup.native.tsrx.js → ProgressGroup.tsrx.js} +3 -3
- package/dist/native/{RadioGroup.native.tsrx.js → RadioGroup.tsrx.js} +2 -2
- package/dist/native/{RichText.native.tsrx.js → RichText.tsrx.js} +3 -3
- package/dist/native/{RouteHost.native.tsrx.js → RouteHost.mobile.tsrx.js} +13 -2
- package/dist/native/{Row.native.tsrx.js → Row.tsrx.js} +4 -4
- package/dist/native/{SafeArea.native.tsrx.js → SafeArea.tsrx.js} +9 -3
- package/dist/native/{Screen.native.tsrx.js → Screen.tsrx.js} +13 -5
- package/dist/native/{ScrollBox.native.tsrx.js → ScrollBox.tsrx.js} +2 -2
- package/dist/native/{ScrollView.native.tsrx.js → ScrollView.tsrx.js} +5 -5
- package/dist/native/{SearchInput.native.tsrx.js → SearchInput.tsrx.js} +4 -4
- package/dist/native/{SegmentedControl.native.tsrx.js → SegmentedControl.tsrx.js} +2 -2
- package/dist/native/{Select.native.tsrx.js → Select.tsrx.js} +4 -4
- package/dist/native/{Separator.native.tsrx.js → Separator.tsrx.js} +2 -2
- package/dist/native/{Sheet.native.tsrx.js → Sheet.tsrx.js} +11 -3
- package/dist/native/{Skeleton.native.tsrx.js → Skeleton.tsrx.js} +2 -2
- package/dist/native/{Slider.native.tsrx.js → Slider.tsrx.js} +5 -5
- package/dist/native/{Spacer.native.tsrx.js → Spacer.tsrx.js} +2 -2
- package/dist/native/{Stack.native.tsrx.js → Stack.tsrx.js} +2 -2
- package/dist/native/{Stepper.native.tsrx.js → Stepper.tsrx.js} +2 -2
- package/dist/native/{Switch.native.tsrx.js → Switch.tsrx.js} +2 -2
- package/dist/native/{Table.native.tsrx.js → Table.tsrx.js} +2 -2
- package/dist/native/{Tabs.native.tsrx.js → Tabs.tsrx.js} +8 -18
- package/dist/native/{Text.native.tsrx.js → Text.tsrx.js} +3 -3
- package/dist/native/{TextArea.native.tsrx.js → TextArea.tsrx.js} +3 -3
- package/dist/native/{TextInput.native.tsrx.js → TextInput.tsrx.js} +3 -3
- package/dist/native/{Timeline.native.tsrx.js → Timeline.tsrx.js} +3 -3
- package/dist/native/Tooltip.tsrx.js +131 -0
- package/dist/native/{Tree.native.tsrx.js → Tree.tsrx.js} +2 -2
- package/dist/native/{User.native.tsrx.js → User.tsrx.js} +3 -3
- package/dist/native/{View.native.tsrx.js → View.tsrx.js} +4 -4
- package/dist/native/VirtualList.tsrx.js +466 -0
- package/dist/native/{WebView.native.tsrx.js → WebView.tsrx.js} +31 -6
- package/dist/native/{aliases.native.tsrx.js → aliases.tsrx.js} +2 -2
- package/dist/native/android/BottomNavigationView.android.tsrx.js +72 -23
- package/dist/native/android/CircularProgressIndicator.android.tsrx.js +1 -1
- package/dist/native/android/DrawerLayout.android.tsrx.js +2 -1
- package/dist/native/android/MaterialDialog.android.tsrx.js +1 -1
- package/dist/native/android/MaterialSwitch.android.tsrx.js +1 -1
- package/dist/native/android/RecyclerView.android.tsrx.js +15 -3
- package/dist/native/android/SeekBar.android.tsrx.js +1 -1
- package/dist/native/android/icon.android.js +7 -0
- package/dist/native/android/index.js +3 -1
- package/dist/native/android/openModal.android.js +1 -1
- package/dist/native/{anim.native.tsrx.js → anim.tsrx.js} +1 -1
- package/dist/native/apply-native-modifiers.native.js +9 -0
- package/dist/native/{escape-props.native.js → escape-props.js} +3 -1
- package/dist/native/index.shared.js +92 -0
- package/dist/native/ios/LiquidGlass.ios.tsrx.js +2 -2
- package/dist/native/ios/LiquidGlassContainer.ios.tsrx.js +2 -2
- package/dist/native/ios/SideDrawer.ios.tsrx.js +2 -1
- package/dist/native/ios/UIActivityIndicatorView.ios.tsrx.js +1 -1
- package/dist/native/ios/UIModal.ios.tsrx.js +1 -1
- package/dist/native/ios/UISlider.ios.tsrx.js +1 -1
- package/dist/native/ios/UISwitch.ios.tsrx.js +1 -1
- package/dist/native/ios/UITabBar.ios.tsrx.js +33 -12
- package/dist/native/ios/UITableView.ios.tsrx.js +15 -3
- package/dist/native/ios/icon.ios.js +7 -0
- package/dist/native/ios/index.js +3 -1
- package/dist/native/ios/openModal.ios.js +1 -1
- package/dist/native/keyboard-inset.mobile.js +66 -0
- package/dist/native/{layout-child.native.js → layout-child.js} +1 -1
- package/dist/native/{modal-presenter.native.js → modal-presenter.mobile.js} +1 -1
- package/dist/native/modifier-factories.js +24 -0
- package/dist/native/native/index.js +3 -3
- package/dist/native/octane-client-build.json +1 -1
- package/dist/native/{pan.native.tsrx.js → pan.tsrx.js} +1 -1
- package/dist/native/{platform.native.js → platform.js} +3 -3
- package/dist/native/{platformProps.native.js → platformProps.js} +3 -1
- package/dist/native/{refresh.native.js → refresh.js} +1 -1
- package/dist/native/{root-layout.native.js → root-layout.mobile.js} +2 -2
- package/dist/native/route-host.mobile.js +2 -0
- package/dist/native/route-table.js +105 -4
- package/dist/native/{route.native.js → route.js} +49 -13
- package/dist/native/safeAreaInsets.tsrx.js +67 -0
- package/dist/native/shared.js +93 -0
- package/dist/native/{sheet-detents.native.js → sheet-detents.js} +1 -1
- package/dist/native/{sheet-service.native.js → sheet-service.js} +9 -3
- package/dist/native/{stacks.native.js → stacks.js} +1 -1
- package/dist/native/{styled.native.tsrx.js → styled.tsrx.js} +1 -1
- package/dist/native/{svg.native.js → svg.mobile.js} +2 -2
- package/dist/native/tap-to-blur.mobile.js +94 -0
- package/dist/native/{text-write.native.js → text-write.js} +1 -1
- package/dist/native/theme/{colorScheme.native.js → colorScheme.js} +2 -2
- package/dist/native/theme/{status-bar-scheme.native.js → status-bar-scheme.mobile.js} +1 -1
- package/dist/native/theme/theme-scheme.js +2 -2
- package/dist/native/{toast-anchor.native.tsrx.js → toast-anchor.tsrx.js} +3 -3
- package/dist/native/{translate.native.js → translate.js} +1 -1
- package/dist/native/ui.js +92 -90
- package/dist/native/{use-back.native.tsrx.js → use-back.tsrx.js} +2 -2
- package/dist/native/{use-store.native.tsrx.js → use-store.tsrx.js} +1 -1
- package/dist/native/{useMeasure.native.tsrx.js → useMeasure.tsrx.js} +1 -1
- package/dist/native/vendor/ui-svg/index.android.js +137 -0
- package/dist/native/vendor/ui-svg/index.common.js +10 -0
- package/dist/native/vendor/ui-svg/index.ios.js +111 -0
- package/dist/native/virtual-list-layout.js +146 -0
- package/dist/native/{windows.native.js → windows.js} +1 -1
- package/dist/web/{web/Hoverable.web.tsrx.js → Hoverable.web.tsrx.js} +7 -6
- package/dist/web/ListItem.web.tsrx.js +139 -0
- package/dist/web/SafeArea.web.tsrx.js +9 -3
- package/dist/web/Tabs.web.tsrx.js +88 -44
- package/dist/web/{web/Tooltip.web.tsrx.js → Tooltip.web.tsrx.js} +7 -6
- package/dist/web/VirtualList.web.tsrx.js +622 -0
- package/dist/web/WebView.web.tsrx.js +42 -5
- package/dist/web/octane-client-build.json +1 -1
- package/dist/web/platform.web.js +1 -1
- package/dist/web/route-table.js +105 -4
- package/dist/web/route.web.js +36 -11
- package/dist/web/ui.js +9 -8
- package/dist/web/virtual-list-layout.js +146 -0
- package/dist/web/web/index.js +2 -2
- package/package.json +51 -23
- package/platforms/android/include.gradle +8 -0
- package/platforms/android/native-api-usage.json +8 -0
- package/platforms/ios/Podfile +2 -0
- package/src/Absolute.tsrx +22 -0
- package/src/Absolute.web.tsrx +22 -0
- package/src/Accordion.macos.tsrx +50 -0
- package/src/Accordion.tsrx +50 -0
- package/src/Accordion.web.tsrx +43 -0
- package/src/ActivityIndicator.tsrx +29 -0
- package/src/ActivityIndicator.web.tsrx +14 -0
- package/src/Alert.macos.tsrx +42 -0
- package/src/Alert.tsrx +24 -0
- package/src/Alert.web.tsrx +23 -0
- package/src/Avatar.macos.tsrx +25 -0
- package/src/Avatar.tsrx +25 -0
- package/src/Avatar.web.tsrx +24 -0
- package/src/AvatarGroup.macos.tsrx +32 -0
- package/src/AvatarGroup.tsrx +32 -0
- package/src/AvatarGroup.web.tsrx +29 -0
- package/src/Badge.macos.tsrx +12 -0
- package/src/Badge.tsrx +12 -0
- package/src/Badge.web.tsrx +10 -0
- package/src/Banner.macos.tsrx +20 -0
- package/src/Banner.tsrx +20 -0
- package/src/Banner.web.tsrx +20 -0
- package/src/Breadcrumb.macos.tsrx +27 -0
- package/src/Breadcrumb.tsrx +27 -0
- package/src/Breadcrumb.web.tsrx +25 -0
- package/src/Button.tsrx +23 -0
- package/src/Button.web.tsrx +21 -0
- package/src/CameraView.macos.tsrx +6 -0
- package/src/Card.macos.tsrx +13 -0
- package/src/Card.tsrx +13 -0
- package/src/Card.web.tsrx +11 -0
- package/src/Checkbox.tsrx +23 -0
- package/src/Checkbox.web.tsrx +34 -0
- package/src/CheckboxGroup.macos.tsrx +39 -0
- package/src/CheckboxGroup.tsrx +39 -0
- package/src/CheckboxGroup.web.tsrx +38 -0
- package/src/Chip.macos.tsrx +25 -0
- package/src/Chip.tsrx +25 -0
- package/src/Chip.web.tsrx +25 -0
- package/src/Collapsible.macos.tsrx +39 -0
- package/src/Collapsible.tsrx +39 -0
- package/src/Collapsible.web.tsrx +33 -0
- package/src/CommandPalette.macos.tsrx +58 -0
- package/src/CommandPalette.tsrx +58 -0
- package/src/CommandPalette.web.tsrx +59 -0
- package/src/ContextMenu.macos.tsrx +59 -0
- package/src/ContextMenu.tsrx +59 -0
- package/src/ContextMenu.web.tsrx +69 -0
- package/src/Drawer.macos.tsrx +28 -0
- package/src/Drawer.tsrx +25 -0
- package/src/Drawer.web.tsrx +31 -0
- package/src/DropdownMenu.macos.tsrx +63 -0
- package/src/DropdownMenu.tsrx +63 -0
- package/src/DropdownMenu.web.tsrx +78 -0
- package/src/Empty.macos.tsrx +15 -0
- package/src/Empty.tsrx +15 -0
- package/src/Empty.web.tsrx +13 -0
- package/src/FieldGroup.macos.tsrx +17 -0
- package/src/FieldGroup.tsrx +17 -0
- package/src/FieldGroup.web.tsrx +17 -0
- package/src/FormField.macos.tsrx +25 -0
- package/src/FormField.tsrx +25 -0
- package/src/FormField.web.tsrx +24 -0
- package/src/Grid.tsrx +32 -0
- package/src/Grid.web.tsrx +43 -0
- package/src/Heading.macos.tsrx +8 -0
- package/src/Heading.tsrx +17 -0
- package/src/Heading.web.tsrx +15 -0
- package/src/Hoverable.mobile.tsrx +21 -0
- package/src/Hoverable.tsrx +113 -0
- package/src/Hoverable.web.tsrx +98 -0
- package/src/Icon.macos.tsrx +18 -0
- package/src/Icon.tsrx +65 -0
- package/src/Icon.web.tsrx +75 -0
- package/src/Image.macos.tsrx +12 -0
- package/src/Image.tsrx +51 -0
- package/src/Image.web.tsrx +14 -0
- package/src/InputNumber.macos.tsrx +49 -0
- package/src/InputNumber.tsrx +49 -0
- package/src/InputNumber.web.tsrx +47 -0
- package/src/InputRating.macos.tsrx +42 -0
- package/src/InputRating.tsrx +39 -0
- package/src/InputRating.web.tsrx +52 -0
- package/src/InputTags.macos.tsrx +49 -0
- package/src/InputTags.tsrx +49 -0
- package/src/InputTags.web.tsrx +49 -0
- package/src/Kbd.macos.tsrx +11 -0
- package/src/Kbd.tsrx +11 -0
- package/src/Kbd.web.tsrx +9 -0
- package/src/KeyboardAvoiding.macos.tsrx +8 -0
- package/src/KeyboardAvoiding.mobile.tsrx +63 -0
- package/src/Link.macos.tsrx +15 -0
- package/src/Link.tsrx +10 -0
- package/src/Link.web.tsrx +12 -0
- package/src/ListItem.macos.tsrx +52 -0
- package/src/ListItem.tsrx +52 -0
- package/src/ListItem.web.tsrx +50 -0
- package/src/Meter.macos.tsrx +8 -0
- package/src/Meter.tsrx +45 -0
- package/src/Meter.web.tsrx +32 -0
- package/src/NavLink.macos.tsrx +24 -0
- package/src/NavLink.tsrx +22 -0
- package/src/NavLink.web.tsrx +23 -0
- package/src/NavigationMenu.macos.tsrx +31 -0
- package/src/NavigationMenu.tsrx +28 -0
- package/src/NavigationMenu.web.tsrx +31 -0
- package/src/Overlay.macos.tsrx +11 -0
- package/src/Overlay.tsrx +84 -0
- package/src/Overlay.web.tsrx +23 -0
- package/src/Pagination.macos.tsrx +54 -0
- package/src/Pagination.tsrx +47 -0
- package/src/Pagination.web.tsrx +50 -0
- package/src/PinInput.macos.tsrx +46 -0
- package/src/PinInput.tsrx +46 -0
- package/src/PinInput.web.tsrx +45 -0
- package/src/Popover.macos.tsrx +11 -0
- package/src/Popover.tsrx +157 -0
- package/src/Popover.web.tsrx +109 -0
- package/src/Pressable.macos.tsrx +19 -0
- package/src/Pressable.tsrx +37 -0
- package/src/Pressable.web.tsrx +45 -0
- package/src/ProgressGroup.macos.tsrx +17 -0
- package/src/ProgressGroup.tsrx +17 -0
- package/src/ProgressGroup.web.tsrx +15 -0
- package/src/RadioGroup.macos.tsrx +50 -0
- package/src/RadioGroup.tsrx +34 -0
- package/src/RadioGroup.web.tsrx +43 -0
- package/src/RichText.tsrx +40 -0
- package/src/RichText.web.tsrx +24 -0
- package/src/RouteHost.macos.tsrx +18 -0
- package/src/RouteHost.mobile.tsrx +44 -0
- package/src/Row.macos.tsrx +26 -0
- package/src/Row.tsrx +27 -0
- package/src/Row.web.tsrx +27 -0
- package/src/SafeArea.macos.tsrx +8 -0
- package/src/SafeArea.tsrx +20 -0
- package/src/SafeArea.web.tsrx +24 -0
- package/src/Screen.macos.tsrx +14 -0
- package/src/Screen.tsrx +31 -0
- package/src/Screen.web.tsrx +7 -0
- package/src/ScrollBox.tsrx +8 -0
- package/src/ScrollBox.web.tsrx +7 -0
- package/src/ScrollView.macos.tsrx +19 -0
- package/src/ScrollView.tsrx +117 -0
- package/src/ScrollView.web.tsrx +109 -0
- package/src/SearchInput.tsrx +60 -0
- package/src/SearchInput.web.test.tsrx +58 -0
- package/src/SearchInput.web.tsrx +55 -0
- package/src/SegmentedControl.tsrx +43 -0
- package/src/SegmentedControl.web.test.tsrx +46 -0
- package/src/SegmentedControl.web.tsrx +51 -0
- package/src/Select.macos.tsrx +104 -0
- package/src/Select.tsrx +104 -0
- package/src/Select.web.tsrx +124 -0
- package/src/Separator.macos.tsrx +17 -0
- package/src/Separator.tsrx +17 -0
- package/src/Separator.web.tsrx +17 -0
- package/src/Sheet.macos.tsrx +15 -0
- package/src/Sheet.tsrx +122 -0
- package/src/Sheet.web.tsrx +56 -0
- package/src/Skeleton.macos.tsrx +15 -0
- package/src/Skeleton.tsrx +15 -0
- package/src/Skeleton.web.tsrx +15 -0
- package/src/Slider.tsrx +71 -0
- package/src/Slider.web.tsrx +60 -0
- package/src/Spacer.tsrx +8 -0
- package/src/Spacer.web.tsrx +6 -0
- package/src/Stack.tsrx +24 -0
- package/src/Stack.web.tsrx +22 -0
- package/src/Stepper.macos.tsrx +52 -0
- package/src/Stepper.tsrx +31 -0
- package/src/Stepper.web.tsrx +37 -0
- package/src/Switch.tsrx +21 -0
- package/src/Switch.web.tsrx +28 -0
- package/src/Table.macos.tsrx +37 -0
- package/src/Table.tsrx +37 -0
- package/src/Table.web.tsrx +37 -0
- package/src/Tabs.macos.tsrx +60 -0
- package/src/Tabs.tsrx +55 -0
- package/src/Tabs.web.tsrx +98 -0
- package/src/Text.macos.tsrx +18 -0
- package/src/Text.tsrx +62 -0
- package/src/Text.web.tsrx +31 -0
- package/src/TextArea.tsrx +65 -0
- package/src/TextArea.web.tsrx +61 -0
- package/src/TextInput.tsrx +39 -0
- package/src/TextInput.web.tsrx +28 -0
- package/src/Timeline.macos.tsrx +27 -0
- package/src/Timeline.tsrx +24 -0
- package/src/Timeline.web.tsrx +22 -0
- package/src/Tooltip.mobile.tsrx +20 -0
- package/src/Tooltip.tsrx +102 -0
- package/src/Tooltip.web.tsrx +156 -0
- package/src/Tree.macos.tsrx +45 -0
- package/src/Tree.tsrx +45 -0
- package/src/Tree.web.tsrx +52 -0
- package/src/User.macos.tsrx +24 -0
- package/src/User.tsrx +24 -0
- package/src/User.web.tsrx +24 -0
- package/src/View.macos.tsrx +29 -0
- package/src/View.tsrx +32 -0
- package/src/View.web.tsrx +33 -0
- package/src/VirtualList.macos.tsrx +335 -0
- package/src/VirtualList.tsrx +358 -0
- package/src/VirtualList.web.tsrx +313 -0
- package/src/WebView.macos.tsrx +6 -0
- package/src/WebView.tsrx +89 -0
- package/src/WebView.web.tsrx +92 -0
- package/src/aliases.macos.tsrx +18 -0
- package/src/aliases.tsrx +18 -0
- package/src/aliases.web.tsrx +17 -0
- package/src/android/BottomNavigationView.android.tsrx +170 -0
- package/src/android/CircularProgressIndicator.android.tsrx +19 -0
- package/src/android/DrawerLayout.android.tsrx +48 -0
- package/src/android/MaterialDialog.android.tsrx +62 -0
- package/src/android/MaterialSwitch.android.tsrx +18 -0
- package/src/android/RecyclerView.android.tsrx +173 -0
- package/src/android/SeekBar.android.tsrx +20 -0
- package/src/android/icon.android.ts +8 -0
- package/src/android/index.ts +37 -0
- package/src/android/openModal.android.ts +55 -0
- package/src/anim.macos.tsrx +20 -0
- package/src/anim.tsrx +65 -0
- package/src/anim.web.tsrx +55 -0
- package/src/apply-native-modifiers.native.ts +13 -0
- package/src/camera-permission.web.ts +11 -0
- package/src/child-array.ts +16 -0
- package/src/colorScheme.macos.ts +27 -0
- package/src/controls.macos.tsrx +171 -0
- package/src/cx.ts +8 -0
- package/src/escape-props.macos.ts +11 -0
- package/src/escape-props.ts +70 -0
- package/src/escape-props.web.ts +25 -0
- package/src/hosted-unsupported.macos.tsrx +9 -0
- package/src/icons.ts +60 -0
- package/src/index.linux.ts +10 -0
- package/src/index.macos.ts +106 -0
- package/src/index.mobile.ts +6 -0
- package/src/index.shared.ts +269 -0
- package/src/index.ts +1 -0
- package/src/index.web.ts +261 -0
- package/src/ios/LiquidGlass.ios.tsrx +41 -0
- package/src/ios/LiquidGlassContainer.ios.tsrx +34 -0
- package/src/ios/SideDrawer.ios.tsrx +49 -0
- package/src/ios/UIActivityIndicatorView.ios.tsrx +18 -0
- package/src/ios/UIModal.ios.tsrx +68 -0
- package/src/ios/UISlider.ios.tsrx +20 -0
- package/src/ios/UISwitch.ios.tsrx +18 -0
- package/src/ios/UITabBar.ios.tsrx +172 -0
- package/src/ios/UITableView.ios.tsrx +186 -0
- package/src/ios/icon.ios.ts +8 -0
- package/src/ios/index.ts +42 -0
- package/src/ios/openModal.ios.ts +55 -0
- package/src/keyboard-inset.mobile.ts +89 -0
- package/src/layout-child.ts +57 -0
- package/src/layout-child.web.ts +108 -0
- package/src/layout-shells.macos.tsrx +10 -0
- package/src/layout.macos.tsrx +41 -0
- package/src/macos-extras.macos.tsrx +40 -0
- package/src/meter-math.ts +6 -0
- package/src/modal-presenter.mobile.ts +24 -0
- package/src/modifier-factories.ts +20 -0
- package/src/native/index.ts +6 -0
- package/src/pan.tsrx +64 -0
- package/src/pan.web.tsrx +38 -0
- package/src/platform.macos.ts +1 -0
- package/src/platform.ts +7 -0
- package/src/platform.web.ts +6 -0
- package/src/platformProps.ts +23 -0
- package/src/platformProps.web.ts +14 -0
- package/src/popover-position.ts +62 -0
- package/src/popover.mobile.test.ts +54 -0
- package/src/props.ts +1812 -0
- package/src/references.d.ts +2 -0
- package/src/refresh-metrics.ts +11 -0
- package/src/refresh.ts +271 -0
- package/src/refresh.web.test.ts +111 -0
- package/src/refresh.web.ts +205 -0
- package/src/root-layout.mobile.ts +89 -0
- package/src/route-host.mobile.ts +1 -0
- package/src/route-table.test.ts +345 -0
- package/src/route-table.ts +585 -0
- package/src/route.macos.ts +201 -0
- package/src/route.ts +703 -0
- package/src/route.web.ts +366 -0
- package/src/safeAreaInsets.macos.tsrx +7 -0
- package/src/safeAreaInsets.tsrx +60 -0
- package/src/safeAreaInsets.web.tsrx +38 -0
- package/src/sheet-detents.ts +142 -0
- package/src/sheet-detents.web.ts +147 -0
- package/src/sheet-service.macos.ts +60 -0
- package/src/sheet-service.ts +124 -0
- package/src/sheet-service.web.ts +64 -0
- package/src/sheet-snap.test.ts +46 -0
- package/src/sheet-snap.ts +66 -0
- package/src/stacks.macos.ts +13 -0
- package/src/stacks.ts +44 -0
- package/src/stacks.web.ts +9 -0
- package/src/store.mobile.test.ts +149 -0
- package/src/store.ts +39 -0
- package/src/store.web.test.tsrx +58 -0
- package/src/styled.macos.tsrx +23 -0
- package/src/styled.test.ts +40 -0
- package/src/styled.tsrx +36 -0
- package/src/styled.web.tsrx +23 -0
- package/src/surfaces.macos.tsrx +27 -0
- package/src/svg.mobile.ts +76 -0
- package/src/tap-to-blur.mobile.ts +108 -0
- package/src/text-controls.macos.tsrx +11 -0
- package/src/text-write.ts +28 -0
- package/src/text-write.web.ts +13 -0
- package/src/theme/colorScheme.linux.ts +52 -0
- package/src/theme/colorScheme.ts +26 -0
- package/src/theme/colorScheme.web.ts +20 -0
- package/src/theme/status-bar-scheme.mobile.ts +39 -0
- package/src/theme/theme-scheme.macos.ts +50 -0
- package/src/theme/theme-scheme.ts +66 -0
- package/src/theme/tokens.css +44 -22
- package/src/toast-anchor.macos.tsrx +3 -0
- package/src/toast-anchor.tsrx +122 -0
- package/src/toast-anchor.web.tsrx +92 -0
- package/src/toast.tsrx +90 -0
- package/src/toast.web.tsrx +50 -0
- package/src/transform.web.ts +52 -0
- package/src/translate.macos.ts +5 -0
- package/src/translate.ts +13 -0
- package/src/translate.web.ts +15 -0
- package/src/tsconfig.json +8 -0
- package/src/unsupported.macos.tsrx +5 -0
- package/src/use-back.tsrx +11 -0
- package/src/use-back.web.tsrx +12 -0
- package/src/use-store.tsrx +18 -0
- package/src/use-store.web.tsrx +18 -0
- package/src/useMeasure.macos.tsrx +23 -0
- package/src/useMeasure.tsrx +66 -0
- package/src/useMeasure.web.tsrx +39 -0
- package/src/useStore.macos.tsrx +6 -0
- package/src/vendor/ui-svg/LICENSE +201 -0
- package/src/vendor/ui-svg/index.android.ts +189 -0
- package/src/vendor/ui-svg/index.common.ts +19 -0
- package/src/vendor/ui-svg/index.ios.ts +147 -0
- package/src/vendor/ui-svg/index.ts +1 -0
- package/src/vendor/ui-svg/typings/SVGKit.d.ts +2862 -0
- package/src/vendor/ui-svg/typings/android.d.ts +1483 -0
- package/src/vendor/ui-svg/typings/ios.d.ts +1511 -0
- package/src/virtual-list-layout.test.ts +81 -0
- package/src/virtual-list-layout.ts +246 -0
- package/src/web/index.ts +11 -0
- package/src/windows.linux.ts +59 -0
- package/src/windows.macos.ts +10 -0
- package/src/windows.ts +7 -0
- package/src/windows.web.ts +6 -0
- package/types/generated/.tsrx-typegen-manifest.json +249 -0
- package/types/generated/Absolute.d.ts +3 -0
- package/types/generated/Absolute.web.d.ts +3 -0
- package/types/generated/Accordion.d.ts +5 -0
- package/types/generated/Accordion.web.d.ts +5 -0
- package/types/generated/ActivityIndicator.d.ts +7 -0
- package/types/generated/ActivityIndicator.web.d.ts +3 -0
- package/types/generated/Alert.d.ts +4 -0
- package/types/generated/Alert.web.d.ts +5 -0
- package/types/generated/Avatar.d.ts +6 -0
- package/types/generated/Avatar.web.d.ts +7 -0
- package/types/generated/AvatarGroup.d.ts +6 -0
- package/types/generated/AvatarGroup.web.d.ts +6 -0
- package/types/generated/Badge.d.ts +5 -0
- package/types/generated/Badge.web.d.ts +5 -0
- package/types/generated/Banner.d.ts +4 -0
- package/types/generated/Banner.web.d.ts +4 -0
- package/types/generated/Breadcrumb.d.ts +4 -0
- package/types/generated/Breadcrumb.web.d.ts +5 -0
- package/types/generated/Button.d.ts +6 -0
- package/types/generated/Button.web.d.ts +6 -0
- package/types/generated/Card.d.ts +4 -0
- package/types/generated/Card.web.d.ts +4 -0
- package/types/generated/Checkbox.d.ts +5 -0
- package/types/generated/Checkbox.web.d.ts +6 -0
- package/types/generated/CheckboxGroup.d.ts +3 -0
- package/types/generated/CheckboxGroup.web.d.ts +3 -0
- package/types/generated/Chip.d.ts +5 -0
- package/types/generated/Chip.web.d.ts +5 -0
- package/types/generated/Collapsible.d.ts +5 -0
- package/types/generated/Collapsible.web.d.ts +5 -0
- package/types/generated/CommandPalette.d.ts +4 -0
- package/types/generated/CommandPalette.web.d.ts +4 -0
- package/types/generated/ContextMenu.d.ts +5 -0
- package/types/generated/ContextMenu.web.d.ts +4 -0
- package/types/generated/Drawer.d.ts +7 -0
- package/types/generated/Drawer.web.d.ts +7 -0
- package/types/generated/DropdownMenu.d.ts +5 -0
- package/types/generated/DropdownMenu.web.d.ts +5 -0
- package/types/generated/Empty.d.ts +4 -0
- package/types/generated/Empty.web.d.ts +4 -0
- package/types/generated/FieldGroup.d.ts +4 -0
- package/types/generated/FieldGroup.web.d.ts +4 -0
- package/types/generated/FormField.d.ts +5 -0
- package/types/generated/FormField.web.d.ts +5 -0
- package/types/generated/Grid.d.ts +3 -0
- package/types/generated/Grid.web.d.ts +3 -0
- package/types/generated/Heading.d.ts +2 -0
- package/types/generated/Heading.web.d.ts +2 -0
- package/types/generated/Hoverable.d.ts +10 -0
- package/types/generated/Hoverable.web.d.ts +9 -0
- package/types/generated/Icon.d.ts +3 -0
- package/types/generated/Icon.web.d.ts +3 -0
- package/types/generated/Image.d.ts +7 -0
- package/types/generated/Image.web.d.ts +3 -0
- package/types/generated/InputNumber.d.ts +5 -0
- package/types/generated/InputNumber.web.d.ts +5 -0
- package/types/generated/InputRating.d.ts +4 -0
- package/types/generated/InputRating.web.d.ts +4 -0
- package/types/generated/InputTags.d.ts +4 -0
- package/types/generated/InputTags.web.d.ts +5 -0
- package/types/generated/Kbd.d.ts +4 -0
- package/types/generated/Kbd.web.d.ts +4 -0
- package/types/generated/KeyboardAvoiding.mobile.d.ts +2 -0
- package/types/generated/Link.d.ts +2 -0
- package/types/generated/Link.web.d.ts +3 -0
- package/types/generated/ListItem.d.ts +3 -0
- package/types/generated/ListItem.web.d.ts +3 -0
- package/types/generated/Meter.d.ts +3 -0
- package/types/generated/Meter.web.d.ts +3 -0
- package/types/generated/NavLink.d.ts +3 -0
- package/types/generated/NavLink.web.d.ts +3 -0
- package/types/generated/NavigationMenu.d.ts +4 -0
- package/types/generated/NavigationMenu.web.d.ts +5 -0
- package/types/generated/Overlay.d.ts +3 -0
- package/types/generated/Overlay.web.d.ts +3 -0
- package/types/generated/Pagination.d.ts +4 -0
- package/types/generated/Pagination.web.d.ts +5 -0
- package/types/generated/PinInput.d.ts +4 -0
- package/types/generated/PinInput.web.d.ts +4 -0
- package/types/generated/Popover.d.ts +6 -0
- package/types/generated/Popover.web.d.ts +3 -0
- package/types/generated/Pressable.d.ts +6 -0
- package/types/generated/Pressable.web.d.ts +2 -0
- package/types/generated/ProgressGroup.d.ts +3 -0
- package/types/generated/ProgressGroup.web.d.ts +4 -0
- package/types/generated/RadioGroup.d.ts +5 -0
- package/types/generated/RadioGroup.web.d.ts +5 -0
- package/types/generated/RichText.d.ts +7 -0
- package/types/generated/RichText.web.d.ts +3 -0
- package/types/generated/RouteHost.mobile.d.ts +14 -0
- package/types/generated/Row.d.ts +2 -0
- package/types/generated/Row.web.d.ts +2 -0
- package/types/generated/SafeArea.d.ts +2 -0
- package/types/generated/SafeArea.web.d.ts +3 -0
- package/types/generated/Screen.d.ts +3 -0
- package/types/generated/Screen.web.d.ts +3 -0
- package/types/generated/ScrollBox.d.ts +3 -0
- package/types/generated/ScrollBox.web.d.ts +3 -0
- package/types/generated/ScrollView.d.ts +7 -0
- package/types/generated/ScrollView.web.d.ts +6 -0
- package/types/generated/SearchInput.d.ts +7 -0
- package/types/generated/SearchInput.web.d.ts +6 -0
- package/types/generated/SegmentedControl.d.ts +7 -0
- package/types/generated/SegmentedControl.web.d.ts +6 -0
- package/types/generated/Select.d.ts +6 -0
- package/types/generated/Select.web.d.ts +6 -0
- package/types/generated/Separator.d.ts +5 -0
- package/types/generated/Separator.web.d.ts +5 -0
- package/types/generated/Sheet.d.ts +5 -0
- package/types/generated/Sheet.web.d.ts +7 -0
- package/types/generated/Skeleton.d.ts +5 -0
- package/types/generated/Skeleton.web.d.ts +6 -0
- package/types/generated/Slider.d.ts +6 -0
- package/types/generated/Slider.web.d.ts +6 -0
- package/types/generated/Spacer.d.ts +3 -0
- package/types/generated/Spacer.web.d.ts +3 -0
- package/types/generated/Stack.d.ts +3 -0
- package/types/generated/Stack.web.d.ts +3 -0
- package/types/generated/Stepper.d.ts +4 -0
- package/types/generated/Stepper.web.d.ts +5 -0
- package/types/generated/Switch.d.ts +7 -0
- package/types/generated/Switch.web.d.ts +6 -0
- package/types/generated/Table.d.ts +4 -0
- package/types/generated/Table.web.d.ts +5 -0
- package/types/generated/Tabs.d.ts +10 -0
- package/types/generated/Tabs.web.d.ts +6 -0
- package/types/generated/Text.d.ts +2 -0
- package/types/generated/Text.web.d.ts +2 -0
- package/types/generated/TextArea.d.ts +8 -0
- package/types/generated/TextArea.web.d.ts +9 -0
- package/types/generated/TextInput.d.ts +9 -0
- package/types/generated/TextInput.web.d.ts +2 -0
- package/types/generated/Timeline.d.ts +3 -0
- package/types/generated/Timeline.web.d.ts +4 -0
- package/types/generated/Tooltip.d.ts +9 -0
- package/types/generated/Tooltip.web.d.ts +12 -0
- package/types/generated/Tree.d.ts +4 -0
- package/types/generated/Tree.web.d.ts +4 -0
- package/types/generated/User.d.ts +5 -0
- package/types/generated/User.web.d.ts +5 -0
- package/types/generated/View.d.ts +7 -0
- package/types/generated/View.web.d.ts +7 -0
- package/types/generated/VirtualList.d.ts +5 -0
- package/types/generated/VirtualList.web.d.ts +4 -0
- package/types/generated/WebView.d.ts +11 -0
- package/types/generated/WebView.web.d.ts +5 -0
- package/types/generated/aliases.d.ts +7 -0
- package/types/generated/aliases.web.d.ts +7 -0
- package/types/generated/android/BottomNavigationView.android.d.ts +9 -0
- package/types/generated/android/CircularProgressIndicator.android.d.ts +6 -0
- package/types/generated/android/DrawerLayout.android.d.ts +12 -0
- package/types/generated/android/MaterialDialog.android.d.ts +8 -0
- package/types/generated/android/MaterialSwitch.android.d.ts +6 -0
- package/types/generated/android/RecyclerView.android.d.ts +14 -0
- package/types/generated/android/SeekBar.android.d.ts +5 -0
- package/types/generated/android/icon.android.d.ts +5 -0
- package/types/generated/android/index.d.ts +12 -0
- package/types/generated/android/openModal.android.d.ts +4 -0
- package/types/generated/anim.d.ts +10 -0
- package/types/generated/anim.web.d.ts +3 -0
- package/types/generated/apply-native-modifiers.native.d.ts +3 -0
- package/types/generated/child-array.d.ts +3 -0
- package/types/generated/cx.d.ts +6 -0
- package/types/generated/escape-props.d.ts +16 -0
- package/types/generated/icons.d.ts +5 -0
- package/types/generated/index.d.ts +1 -0
- package/types/generated/index.linux.d.ts +5 -0
- package/types/generated/index.mobile.d.ts +4 -0
- package/types/generated/index.shared.d.ts +111 -0
- package/types/generated/index.web.d.ts +111 -0
- package/types/generated/ios/LiquidGlass.ios.d.ts +12 -0
- package/types/generated/ios/LiquidGlassContainer.ios.d.ts +13 -0
- package/types/generated/ios/SideDrawer.ios.d.ts +12 -0
- package/types/generated/ios/UIActivityIndicatorView.ios.d.ts +5 -0
- package/types/generated/ios/UIModal.ios.d.ts +7 -0
- package/types/generated/ios/UISlider.ios.d.ts +5 -0
- package/types/generated/ios/UISwitch.ios.d.ts +6 -0
- package/types/generated/ios/UITabBar.ios.d.ts +7 -0
- package/types/generated/ios/UITableView.ios.d.ts +14 -0
- package/types/generated/ios/icon.ios.d.ts +5 -0
- package/types/generated/ios/index.d.ts +14 -0
- package/types/generated/ios/openModal.ios.d.ts +4 -0
- package/types/generated/keyboard-inset.mobile.d.ts +10 -0
- package/types/generated/layout-child.d.ts +6 -0
- package/types/generated/layout-child.web.d.ts +15 -0
- package/types/generated/meter-math.d.ts +6 -0
- package/types/generated/modal-presenter.mobile.d.ts +14 -0
- package/types/generated/modifier-factories.d.ts +15 -0
- package/types/generated/native/index.d.ts +3 -0
- package/types/generated/pan.d.ts +2 -0
- package/types/generated/pan.web.d.ts +9 -0
- package/types/generated/platform.d.ts +7 -0
- package/types/generated/platform.web.d.ts +6 -0
- package/types/generated/platformProps.d.ts +7 -0
- package/types/generated/platformProps.web.d.ts +2 -0
- package/types/generated/popover-position.d.ts +14 -0
- package/types/{props.d.ts → generated/props.d.ts} +127 -133
- package/types/generated/refresh-metrics.d.ts +8 -0
- package/types/generated/refresh.d.ts +42 -0
- package/types/generated/refresh.web.d.ts +23 -0
- package/types/generated/root-layout.mobile.d.ts +22 -0
- package/types/generated/route-host.mobile.d.ts +1 -0
- package/types/generated/route-table.d.ts +90 -0
- package/types/generated/route.d.ts +74 -0
- package/types/generated/route.web.d.ts +67 -0
- package/types/generated/safeAreaInsets.d.ts +8 -0
- package/types/generated/safeAreaInsets.web.d.ts +8 -0
- package/types/generated/sheet-detents.d.ts +23 -0
- package/types/generated/sheet-detents.web.d.ts +13 -0
- package/types/generated/sheet-service.d.ts +11 -0
- package/types/generated/sheet-service.web.d.ts +6 -0
- package/types/generated/sheet-snap.d.ts +18 -0
- package/types/generated/stacks.d.ts +9 -0
- package/types/generated/stacks.web.d.ts +4 -0
- package/types/generated/store.d.ts +14 -0
- package/types/generated/styled.d.ts +20 -0
- package/types/generated/styled.web.d.ts +10 -0
- package/types/generated/svg.mobile.d.ts +23 -0
- package/types/generated/tap-to-blur.mobile.d.ts +16 -0
- package/types/generated/text-write.d.ts +9 -0
- package/types/generated/theme/colorScheme.d.ts +6 -0
- package/types/generated/theme/colorScheme.linux.d.ts +5 -0
- package/types/generated/theme/colorScheme.web.d.ts +5 -0
- package/types/generated/theme/status-bar-scheme.mobile.d.ts +1 -0
- package/types/generated/theme/theme-scheme.d.ts +20 -0
- package/types/generated/toast-anchor.d.ts +4 -0
- package/types/generated/toast-anchor.web.d.ts +4 -0
- package/types/generated/transform.web.d.ts +8 -0
- package/types/generated/translate.d.ts +5 -0
- package/types/generated/translate.web.d.ts +6 -0
- package/types/generated/use-back.d.ts +6 -0
- package/types/generated/use-back.web.d.ts +7 -0
- package/types/generated/use-store.d.ts +9 -0
- package/types/generated/use-store.web.d.ts +9 -0
- package/types/generated/useMeasure.d.ts +3 -0
- package/types/generated/useMeasure.web.d.ts +3 -0
- package/types/generated/vendor/ui-svg/index.common.d.ts +7 -0
- package/types/generated/vendor/ui-svg/index.d.ts +1 -0
- package/types/generated/vendor/ui-svg/index.ios.d.ts +13 -0
- package/types/generated/virtual-list-layout.d.ts +44 -0
- package/types/generated/web/index.d.ts +3 -0
- package/types/generated/windows.d.ts +3 -0
- package/types/generated/windows.linux.d.ts +15 -0
- package/types/generated/windows.web.d.ts +3 -0
- package/types/index.macos.d.ts +142 -0
- package/dist/native/CameraView.native.tsrx.js +0 -165
- package/dist/native/Meter.native.tsrx.js +0 -92
- package/dist/native/Pager.native.tsrx.js +0 -282
- package/dist/native/Video.native.tsrx.js +0 -248
- package/dist/native/camera-permission.native.js +0 -47
- package/dist/native/safeAreaInsets.native.tsrx.js +0 -35
- package/dist/native/video-chrome.native.tsrx.js +0 -365
- package/dist/web/CameraView.web.tsrx.js +0 -310
- package/dist/web/Pager.web.tsrx.js +0 -337
- package/dist/web/Video.web.tsrx.js +0 -400
- package/dist/web/video-chrome.web.tsrx.js +0 -207
- package/types/android.d.ts +0 -53
- package/types/index.d.ts +0 -273
- package/types/index.native.d.ts +0 -273
- package/types/index.web.d.ts +0 -272
- package/types/ios.d.ts +0 -59
- package/types/native.d.ts +0 -5
- package/types/web.d.ts +0 -17
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/** @jsxImportSource @xplat/macos/renderer */
|
|
2
|
+
import { useMemo, useRef, useState } from 'octane'
|
|
3
|
+
import type { VirtualListProps } from './props'
|
|
4
|
+
import { cx } from './cx'
|
|
5
|
+
import {
|
|
6
|
+
VirtualListSizeIndex,
|
|
7
|
+
createVirtualListEntries,
|
|
8
|
+
estimateVirtualListSizes,
|
|
9
|
+
virtualListMeasurementKey,
|
|
10
|
+
virtualListRange,
|
|
11
|
+
type VirtualListEntry,
|
|
12
|
+
} from './virtual-list-layout'
|
|
13
|
+
|
|
14
|
+
type AppKitScrollEvent = { verticalOffset: number; viewportHeight: number; contentHeight: number }
|
|
15
|
+
type AppKitLayoutEvent = { object: any; width: number; height: number }
|
|
16
|
+
|
|
17
|
+
const sameSize = (a: number, b: number) => Math.abs(a - b) < 0.5
|
|
18
|
+
|
|
19
|
+
/** Scrolls an AppKit scrollview to a top-down (scrollTop-style) offset. The
|
|
20
|
+
* documentView (a vertical NSStackView) is normally flipped so clip origin y
|
|
21
|
+
* already counts from the top; the isFlipped check keeps non-flipped
|
|
22
|
+
* documents correct too. */
|
|
23
|
+
function scrollViewSetTop(scroll: any, top: number): void {
|
|
24
|
+
const clip = scroll?.contentView
|
|
25
|
+
const doc = scroll?.documentView
|
|
26
|
+
if (!clip) {return}
|
|
27
|
+
const docHeight = Number(doc?.frame?.size?.height ?? 0)
|
|
28
|
+
const clipHeight = Number(clip.bounds?.size?.height ?? 0)
|
|
29
|
+
const flip = typeof doc?.isFlipped === 'function' ? doc.isFlipped() : doc?.isFlipped
|
|
30
|
+
const flipped = flip === true || Number(flip) === 1
|
|
31
|
+
const y = Math.max(0, flipped ? top : docHeight - clipHeight - top)
|
|
32
|
+
clip.scrollToPoint({ x: 0, y })
|
|
33
|
+
scroll.reflectScrolledClipView(clip)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function scrollViewOffset(scroll: any): number {
|
|
37
|
+
const clip = scroll?.contentView
|
|
38
|
+
const doc = scroll?.documentView
|
|
39
|
+
if (!clip) {return 0}
|
|
40
|
+
const docHeight = Number(doc?.frame?.size?.height ?? 0)
|
|
41
|
+
const clipHeight = Number(clip.bounds?.size?.height ?? 0)
|
|
42
|
+
const originY = Number(clip.bounds?.origin?.y ?? 0)
|
|
43
|
+
const flip = typeof doc?.isFlipped === 'function' ? doc.isFlipped() : doc?.isFlipped
|
|
44
|
+
const flipped = flip === true || Number(flip) === 1
|
|
45
|
+
return flipped ? originY : docHeight - clipHeight - originY
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function scrollViewViewport(scroll: any): { width: number; height: number } {
|
|
49
|
+
const bounds = scroll?.contentView?.bounds
|
|
50
|
+
return {
|
|
51
|
+
width: Number(bounds?.size?.width ?? 0),
|
|
52
|
+
height: Number(bounds?.size?.height ?? 0),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Windowed vertical virtualization for the AppKit host. Rows outside the
|
|
57
|
+
* visible window + one viewport of overscan stay unmounted; row heights are
|
|
58
|
+
* measured through `onLayoutChanged` frame notifications and prefix-summed
|
|
59
|
+
* by the shared VirtualListSizeIndex. */
|
|
60
|
+
export function VirtualList<T = any>(props: VirtualListProps<T>) @{
|
|
61
|
+
const entries = useMemo(
|
|
62
|
+
() => createVirtualListEntries(props.items, props.keyExtractor, props.getItemType),
|
|
63
|
+
[props.items, props.keyExtractor, props.getItemType],
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
const [windowVersion, setWindowVersion] = useState(0)
|
|
67
|
+
const sizeIndexRef = useRef(new VirtualListSizeIndex())
|
|
68
|
+
const sizeCacheRef = useRef(new Map<string, { width: number; height: number }>())
|
|
69
|
+
const entriesRef = useRef<VirtualListEntry<T>[]>([])
|
|
70
|
+
const indexByRowKeyRef = useRef(new Map<string, number>())
|
|
71
|
+
const scrollRef = useRef<any>(null)
|
|
72
|
+
const scrollOffsetRef = useRef(0)
|
|
73
|
+
const viewportHeightRef = useRef(0)
|
|
74
|
+
const viewportWidthRef = useRef(0)
|
|
75
|
+
const headerHeightRef = useRef(0)
|
|
76
|
+
const rangeRef = useRef({ start: -1, end: -1, top: -1, bottom: -1 })
|
|
77
|
+
const anchorRestoreTimerRef = useRef<any>(null)
|
|
78
|
+
const anchorRestoreScheduledRef = useRef(false)
|
|
79
|
+
const queuedAnchorRef = useRef<{ rowKey: string; within: number } | null>(null)
|
|
80
|
+
const estimateAnchorRef = useRef<{ rowKey: string; within: number } | null>(null)
|
|
81
|
+
const estimateTimerRef = useRef<any>(null)
|
|
82
|
+
const pendingRowMeasureRef = useRef(new Map<string, number>())
|
|
83
|
+
const hasSeparator = Boolean(props.renderSeparator)
|
|
84
|
+
const hasSeparatorRef = useRef(hasSeparator)
|
|
85
|
+
hasSeparatorRef.current = hasSeparator
|
|
86
|
+
|
|
87
|
+
function rebuildLayout(nextEntries: VirtualListEntry<T>[], width: number) {
|
|
88
|
+
entriesRef.current = nextEntries
|
|
89
|
+
const indexByKey = new Map<string, number>()
|
|
90
|
+
const activeMeasurements = new Set<string>()
|
|
91
|
+
|
|
92
|
+
for (const entry of nextEntries) {
|
|
93
|
+
indexByKey.set(entry.rowKey, entry.index)
|
|
94
|
+
activeMeasurements.add(
|
|
95
|
+
virtualListMeasurementKey(
|
|
96
|
+
entry.rowKey,
|
|
97
|
+
hasSeparatorRef.current && entry.index < nextEntries.length - 1,
|
|
98
|
+
),
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
for (const cacheKey of sizeCacheRef.current.keys()) {
|
|
103
|
+
if (!activeMeasurements.has(cacheKey)) sizeCacheRef.current.delete(cacheKey)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
indexByRowKeyRef.current = indexByKey
|
|
107
|
+
sizeIndexRef.current.reset(
|
|
108
|
+
estimateVirtualListSizes(nextEntries, hasSeparatorRef.current, width, sizeCacheRef.current),
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (entries !== entriesRef.current) {
|
|
113
|
+
rebuildLayout(entries, viewportWidthRef.current)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function currentRange() {
|
|
117
|
+
const listOffset = Math.max(0, scrollOffsetRef.current - headerHeightRef.current)
|
|
118
|
+
return virtualListRange(
|
|
119
|
+
sizeIndexRef.current,
|
|
120
|
+
listOffset,
|
|
121
|
+
viewportHeightRef.current,
|
|
122
|
+
viewportHeightRef.current,
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function refreshWindow() {
|
|
127
|
+
const next = currentRange()
|
|
128
|
+
const previous = rangeRef.current
|
|
129
|
+
if (
|
|
130
|
+
next.start !== previous.start ||
|
|
131
|
+
next.end !== previous.end ||
|
|
132
|
+
!sameSize(next.top, previous.top) ||
|
|
133
|
+
!sameSize(next.bottom, previous.bottom)
|
|
134
|
+
) {
|
|
135
|
+
rangeRef.current = next
|
|
136
|
+
setWindowVersion((version) => version + 1)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function captureAnchor(): { rowKey: string; within: number } | null {
|
|
141
|
+
const listOffset = scrollOffsetRef.current - headerHeightRef.current
|
|
142
|
+
if (listOffset < 0 || entriesRef.current.length === 0) {return null}
|
|
143
|
+
const index = sizeIndexRef.current.indexAt(listOffset)
|
|
144
|
+
const entry = entriesRef.current[index]
|
|
145
|
+
if (!entry) {return null}
|
|
146
|
+
return { rowKey: entry.rowKey, within: listOffset - sizeIndexRef.current.prefix(index) }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function restoreAnchor(anchor: { rowKey: string; within: number } | null) {
|
|
150
|
+
if (!anchor) {return}
|
|
151
|
+
queuedAnchorRef.current = anchor
|
|
152
|
+
if (anchorRestoreScheduledRef.current) {return}
|
|
153
|
+
const scroll = scrollRef.current
|
|
154
|
+
if (!scroll) {return}
|
|
155
|
+
|
|
156
|
+
anchorRestoreScheduledRef.current = true
|
|
157
|
+
const timer = setTimeout(() => {
|
|
158
|
+
if (anchorRestoreTimerRef.current !== timer) {return}
|
|
159
|
+
anchorRestoreTimerRef.current = null
|
|
160
|
+
anchorRestoreScheduledRef.current = false
|
|
161
|
+
if (scrollRef.current !== scroll) {return}
|
|
162
|
+
const queued = queuedAnchorRef.current
|
|
163
|
+
queuedAnchorRef.current = null
|
|
164
|
+
if (!queued) {return}
|
|
165
|
+
const index = indexByRowKeyRef.current.get(queued.rowKey)
|
|
166
|
+
if (index === undefined) {return}
|
|
167
|
+
const nextOffset = Math.max(
|
|
168
|
+
0,
|
|
169
|
+
headerHeightRef.current + sizeIndexRef.current.prefix(index) + queued.within,
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
if (sameSize(nextOffset, scrollViewOffset(scroll))) {return}
|
|
173
|
+
scrollViewSetTop(scroll, nextOffset)
|
|
174
|
+
}, 0)
|
|
175
|
+
|
|
176
|
+
anchorRestoreTimerRef.current = timer
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function scheduleEstimateRebuild(anchor: { rowKey: string; within: number } | null) {
|
|
180
|
+
if (anchor) {estimateAnchorRef.current = anchor}
|
|
181
|
+
if (estimateTimerRef.current) {return}
|
|
182
|
+
// Debounce: each rebuild rescales every unmeasured prefix, so one
|
|
183
|
+
// rebuild per measurement burst — not per row — keeps the AppKit
|
|
184
|
+
// relayout/anchor cycle count bounded while samples accumulate.
|
|
185
|
+
estimateTimerRef.current = setTimeout(() => {
|
|
186
|
+
estimateTimerRef.current = null
|
|
187
|
+
const scheduledAnchor = estimateAnchorRef.current
|
|
188
|
+
estimateAnchorRef.current = null
|
|
189
|
+
rebuildLayout(entriesRef.current, viewportWidthRef.current)
|
|
190
|
+
restoreAnchor(scheduledAnchor)
|
|
191
|
+
refreshWindow()
|
|
192
|
+
}, 120)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function recordRowSize(rowKey: string, width: number, height: number) {
|
|
196
|
+
if (!Number.isFinite(height) || height < 0) {return}
|
|
197
|
+
const index = indexByRowKeyRef.current.get(rowKey)
|
|
198
|
+
if (index === undefined) {return}
|
|
199
|
+
const entry = entriesRef.current[index]
|
|
200
|
+
if (!entry) {return}
|
|
201
|
+
|
|
202
|
+
const hasRowSeparator = hasSeparatorRef.current && index < entriesRef.current.length - 1
|
|
203
|
+
const cacheKey = virtualListMeasurementKey(rowKey, hasRowSeparator)
|
|
204
|
+
const cached = sizeCacheRef.current.get(cacheKey)
|
|
205
|
+
// NSViewFrameDidChangeNotification fires on origin moves too, not just
|
|
206
|
+
// resizes — spacer shifts move every mounted row and would otherwise
|
|
207
|
+
// re-run this whole path (and reschedule estimate rebuilds) forever.
|
|
208
|
+
if (cached && sameSize(cached.height, height) && sameSize(cached.width, width)) {return}
|
|
209
|
+
|
|
210
|
+
const anchor = queuedAnchorRef.current ?? captureAnchor()
|
|
211
|
+
sizeCacheRef.current.set(cacheKey, { width, height })
|
|
212
|
+
|
|
213
|
+
const delta = sizeIndexRef.current.set(index, height)
|
|
214
|
+
if (Math.abs(delta) >= 0.5) {
|
|
215
|
+
const anchorIndex = anchor ? indexByRowKeyRef.current.get(anchor.rowKey) : undefined
|
|
216
|
+
if (anchor && anchorIndex !== undefined && index < anchorIndex) {restoreAnchor(anchor)}
|
|
217
|
+
refreshWindow()
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
scheduleEstimateRebuild(anchor)
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function syncViewport() {
|
|
224
|
+
const scroll = scrollRef.current
|
|
225
|
+
if (!scroll) {return}
|
|
226
|
+
const size = scrollViewViewport(scroll)
|
|
227
|
+
const widthChanged = !sameSize(size.width, viewportWidthRef.current)
|
|
228
|
+
viewportHeightRef.current = size.height
|
|
229
|
+
if (widthChanged) {
|
|
230
|
+
const anchor = captureAnchor()
|
|
231
|
+
viewportWidthRef.current = size.width
|
|
232
|
+
rebuildLayout(entriesRef.current, size.width)
|
|
233
|
+
restoreAnchor(anchor)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
refreshWindow()
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function onScroll(event: AppKitScrollEvent) {
|
|
240
|
+
// The event's verticalOffset is the raw clip bounds origin — bottom-up
|
|
241
|
+
// on a non-flipped document — so derive the top-down offset ourselves.
|
|
242
|
+
const scroll = scrollRef.current
|
|
243
|
+
scrollOffsetRef.current = scroll ? scrollViewOffset(scroll) : Number(event?.verticalOffset ?? 0)
|
|
244
|
+
viewportHeightRef.current = Number(event?.viewportHeight ?? viewportHeightRef.current)
|
|
245
|
+
refreshWindow()
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function onScrollViewLayout() {
|
|
249
|
+
syncViewport()
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function onHeaderLayout(event: AppKitLayoutEvent) {
|
|
253
|
+
const height = Number(event?.height ?? 0)
|
|
254
|
+
if (sameSize(height, headerHeightRef.current)) {return}
|
|
255
|
+
const anchor = captureAnchor()
|
|
256
|
+
headerHeightRef.current = height
|
|
257
|
+
restoreAnchor(anchor)
|
|
258
|
+
refreshWindow()
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function onRowLayout(entry: VirtualListEntry<T>, event: AppKitLayoutEvent) {
|
|
262
|
+
const view = event?.object
|
|
263
|
+
if (!view) {return}
|
|
264
|
+
// Frame notifications arrive mid-layout: a row can report h=0 (or a
|
|
265
|
+
// stack-stretched transient) before its final size is known, and rows
|
|
266
|
+
// unmounted before the second pass would keep the bogus measurement.
|
|
267
|
+
// Read the frame on the next tick instead, once layout has settled.
|
|
268
|
+
const coalesced = (pendingRowMeasureRef.current.get(entry.rowKey) ?? 0) + 1
|
|
269
|
+
pendingRowMeasureRef.current.set(entry.rowKey, coalesced)
|
|
270
|
+
setTimeout(() => {
|
|
271
|
+
if (pendingRowMeasureRef.current.get(entry.rowKey) !== coalesced) {return}
|
|
272
|
+
pendingRowMeasureRef.current.delete(entry.rowKey)
|
|
273
|
+
if (!view.superview) {return}
|
|
274
|
+
const size = view.frame?.size ?? view.bounds?.size
|
|
275
|
+
recordRowSize(entry.rowKey, Number(size?.width ?? 0), Number(size?.height ?? 0))
|
|
276
|
+
}, 0)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const range = currentRange()
|
|
280
|
+
rangeRef.current = range
|
|
281
|
+
void windowVersion
|
|
282
|
+
const visibleEntries = entries.slice(range.start, range.end)
|
|
283
|
+
|
|
284
|
+
<scrollview
|
|
285
|
+
ref={(view: any) => {
|
|
286
|
+
scrollRef.current = view
|
|
287
|
+
if (view) {setTimeout(() => syncViewport(), 0)}
|
|
288
|
+
}}
|
|
289
|
+
id={props.id}
|
|
290
|
+
className={cx('vx-virtual-list', props.className)}
|
|
291
|
+
style={props.style}
|
|
292
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
293
|
+
onScroll={onScroll}
|
|
294
|
+
onLayoutChanged={onScrollViewLayout}
|
|
295
|
+
>
|
|
296
|
+
<flexboxlayout flexDirection="column">
|
|
297
|
+
@if (props.renderHeader) {
|
|
298
|
+
<flexboxlayout
|
|
299
|
+
className="vx-virtual-list-header"
|
|
300
|
+
flexDirection="column"
|
|
301
|
+
onLayoutChanged={onHeaderLayout}
|
|
302
|
+
>
|
|
303
|
+
{props.renderHeader()}
|
|
304
|
+
</flexboxlayout>
|
|
305
|
+
}
|
|
306
|
+
@if (entries.length === 0) {
|
|
307
|
+
@if (props.renderEmpty) {
|
|
308
|
+
<flexboxlayout className="vx-virtual-list-empty" flexDirection="column">
|
|
309
|
+
{props.renderEmpty()}
|
|
310
|
+
</flexboxlayout>
|
|
311
|
+
}
|
|
312
|
+
} @else {
|
|
313
|
+
<flexboxlayout flexDirection="column">
|
|
314
|
+
<flexboxlayout className="vx-virtual-list-spacer" style={{ height: range.top }} />
|
|
315
|
+
@for (const entry of visibleEntries; key entry.rowKey) {
|
|
316
|
+
<flexboxlayout
|
|
317
|
+
flexDirection="column"
|
|
318
|
+
className="vx-virtual-list-row"
|
|
319
|
+
onLayoutChanged={(event: AppKitLayoutEvent) => onRowLayout(entry, event)}
|
|
320
|
+
>
|
|
321
|
+
{props.renderItem(entry.item, entry.index)}
|
|
322
|
+
{hasSeparator && entry.index < entries.length - 1 ? props.renderSeparator?.() : null}
|
|
323
|
+
</flexboxlayout>
|
|
324
|
+
}
|
|
325
|
+
<flexboxlayout className="vx-virtual-list-spacer" style={{ height: range.bottom }} />
|
|
326
|
+
</flexboxlayout>
|
|
327
|
+
}
|
|
328
|
+
@if (props.renderFooter) {
|
|
329
|
+
<flexboxlayout className="vx-virtual-list-footer" flexDirection="column">
|
|
330
|
+
{props.renderFooter()}
|
|
331
|
+
</flexboxlayout>
|
|
332
|
+
}
|
|
333
|
+
</flexboxlayout>
|
|
334
|
+
</scrollview>;
|
|
335
|
+
}
|
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
/** @jsxImportSource @nativescript-community/octane */
|
|
2
|
+
import { useMemo, useRef, useState } from 'octane'
|
|
3
|
+
import type { VirtualListProps } from './props'
|
|
4
|
+
import {
|
|
5
|
+
createVirtualListEntries,
|
|
6
|
+
estimateVirtualListSizes,
|
|
7
|
+
virtualListMeasurementKey,
|
|
8
|
+
virtualListRange,
|
|
9
|
+
VirtualListSizeIndex,
|
|
10
|
+
type VirtualListEntry,
|
|
11
|
+
type VirtualListSizeRecord,
|
|
12
|
+
} from './virtual-list-layout'
|
|
13
|
+
import { cx } from './cx'
|
|
14
|
+
import { applyEscapeProps, nativeAccessibilityRole, nativeAccessibilityState } from './escape-props'
|
|
15
|
+
import { layoutChildProps } from './layout-child'
|
|
16
|
+
|
|
17
|
+
function sameSize(a: number, b: number) {
|
|
18
|
+
return Math.abs(a - b) < 0.5
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface VirtualListAnchor {
|
|
22
|
+
rowKey: string
|
|
23
|
+
index: number
|
|
24
|
+
within: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Shared vertical virtualization over NativeScript ScrollView. Off-window
|
|
28
|
+
* rows unmount; measured row-height changes above the visible anchor adjust
|
|
29
|
+
* the native scroll offset after layout. */
|
|
30
|
+
export function VirtualList<T = any>(props: VirtualListProps<T>) @{
|
|
31
|
+
const entries = useMemo(
|
|
32
|
+
() => createVirtualListEntries(props.items, props.keyExtractor, props.getItemType),
|
|
33
|
+
[props.items, props.keyExtractor, props.getItemType],
|
|
34
|
+
)
|
|
35
|
+
const [windowVersion, setWindowVersion] = useState(0)
|
|
36
|
+
const sizeIndexRef = useRef(new VirtualListSizeIndex())
|
|
37
|
+
const sizeCacheRef = useRef(new Map<string, VirtualListSizeRecord>())
|
|
38
|
+
const entriesRef = useRef<VirtualListEntry<T>[]>([])
|
|
39
|
+
const indexByRowKeyRef = useRef(new Map<string, number>())
|
|
40
|
+
const scrollRef = useRef<any>(null)
|
|
41
|
+
const scrollOffsetRef = useRef(0)
|
|
42
|
+
const viewportHeightRef = useRef(0)
|
|
43
|
+
const viewportWidthRef = useRef(0)
|
|
44
|
+
const headerHeightRef = useRef(0)
|
|
45
|
+
const estimateScheduledRef = useRef(false)
|
|
46
|
+
const estimateAnchorRef = useRef<VirtualListAnchor | null>(null)
|
|
47
|
+
const rangeRef = useRef({ start: -1, end: -1, top: -1, bottom: -1 })
|
|
48
|
+
const pendingAnchorRef = useRef<VirtualListAnchor | null>(null)
|
|
49
|
+
const pendingAnchorRowsRef = useRef(new Set<string>())
|
|
50
|
+
const queuedAnchorRestoreRef = useRef<VirtualListAnchor | null>(null)
|
|
51
|
+
const anchorRestoreScheduledRef = useRef(false)
|
|
52
|
+
const anchorRestoreTimerRef = useRef<any>(null)
|
|
53
|
+
const hasSeparator = Boolean(props.renderSeparator)
|
|
54
|
+
const hasSeparatorRef = useRef(hasSeparator)
|
|
55
|
+
hasSeparatorRef.current = hasSeparator
|
|
56
|
+
|
|
57
|
+
function rebuildLayout(nextEntries: VirtualListEntry<T>[], width: number) {
|
|
58
|
+
entriesRef.current = nextEntries
|
|
59
|
+
const indexByKey = new Map<string, number>()
|
|
60
|
+
const activeMeasurements = new Set<string>()
|
|
61
|
+
|
|
62
|
+
for (const entry of nextEntries) {
|
|
63
|
+
indexByKey.set(entry.rowKey, entry.index)
|
|
64
|
+
const cacheKey = virtualListMeasurementKey(
|
|
65
|
+
entry.rowKey,
|
|
66
|
+
hasSeparatorRef.current && entry.index < nextEntries.length - 1,
|
|
67
|
+
)
|
|
68
|
+
activeMeasurements.add(cacheKey)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (const cacheKey of sizeCacheRef.current.keys()) {
|
|
72
|
+
if (!activeMeasurements.has(cacheKey)) sizeCacheRef.current.delete(cacheKey)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
indexByRowKeyRef.current = indexByKey
|
|
76
|
+
sizeIndexRef.current.reset(
|
|
77
|
+
estimateVirtualListSizes(nextEntries, hasSeparatorRef.current, width, sizeCacheRef.current),
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (entries !== entriesRef.current) {
|
|
82
|
+
const anchor = captureCurrentAnchor()
|
|
83
|
+
const previousByKey = new Map(entriesRef.current.map((entry) => [entry.rowKey, entry]))
|
|
84
|
+
const changedRows = entries.filter((entry) => previousByKey.get(entry.rowKey)?.item !== entry.item)
|
|
85
|
+
const previousRange = rangeRef.current
|
|
86
|
+
rebuildLayout(entries, viewportWidthRef.current)
|
|
87
|
+
const anchorIndex = anchor ? indexByRowKeyRef.current.get(anchor.rowKey) : undefined
|
|
88
|
+
const pendingRows = new Set(
|
|
89
|
+
changedRows
|
|
90
|
+
.filter(
|
|
91
|
+
(entry) =>
|
|
92
|
+
anchorIndex !== undefined &&
|
|
93
|
+
entry.index < anchorIndex &&
|
|
94
|
+
entry.index >= previousRange.start &&
|
|
95
|
+
entry.index < previousRange.end,
|
|
96
|
+
)
|
|
97
|
+
.map((entry) => entry.rowKey),
|
|
98
|
+
)
|
|
99
|
+
pendingAnchorRef.current = pendingRows.size > 0 ? anchor : null
|
|
100
|
+
pendingAnchorRowsRef.current = pendingRows
|
|
101
|
+
|
|
102
|
+
if (anchor) restoreAnchor(anchor)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function currentRange() {
|
|
106
|
+
const listOffset = Math.max(0, scrollOffsetRef.current - headerHeightRef.current)
|
|
107
|
+
return virtualListRange(
|
|
108
|
+
sizeIndexRef.current,
|
|
109
|
+
listOffset,
|
|
110
|
+
viewportHeightRef.current,
|
|
111
|
+
viewportHeightRef.current,
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function refreshWindow() {
|
|
116
|
+
const next = currentRange()
|
|
117
|
+
const previous = rangeRef.current
|
|
118
|
+
if (
|
|
119
|
+
next.start !== previous.start ||
|
|
120
|
+
next.end !== previous.end ||
|
|
121
|
+
!sameSize(next.top, previous.top) ||
|
|
122
|
+
!sameSize(next.bottom, previous.bottom)
|
|
123
|
+
) {
|
|
124
|
+
rangeRef.current = next
|
|
125
|
+
setWindowVersion((version) => version + 1)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function captureAnchor(): VirtualListAnchor | null {
|
|
130
|
+
const listOffset = scrollOffsetRef.current - headerHeightRef.current
|
|
131
|
+
if (listOffset < 0 || entriesRef.current.length === 0) return null
|
|
132
|
+
|
|
133
|
+
const index = sizeIndexRef.current.indexAt(listOffset)
|
|
134
|
+
const entry = entriesRef.current[index]
|
|
135
|
+
if (!entry) return null
|
|
136
|
+
return {
|
|
137
|
+
rowKey: entry.rowKey,
|
|
138
|
+
index,
|
|
139
|
+
within: listOffset - sizeIndexRef.current.prefix(index),
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function captureCurrentAnchor() {
|
|
144
|
+
const nativeOffset = Number(scrollRef.current?.verticalOffset)
|
|
145
|
+
if (Number.isFinite(nativeOffset)) scrollOffsetRef.current = nativeOffset
|
|
146
|
+
return captureAnchor()
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function restoreAnchor(anchor: VirtualListAnchor | null) {
|
|
150
|
+
if (!anchor) return
|
|
151
|
+
queuedAnchorRestoreRef.current = anchor
|
|
152
|
+
if (anchorRestoreScheduledRef.current) return
|
|
153
|
+
const view = scrollRef.current
|
|
154
|
+
if (!view) return
|
|
155
|
+
|
|
156
|
+
anchorRestoreScheduledRef.current = true
|
|
157
|
+
const timer = setTimeout(() => {
|
|
158
|
+
if (anchorRestoreTimerRef.current !== timer) return
|
|
159
|
+
anchorRestoreTimerRef.current = null
|
|
160
|
+
anchorRestoreScheduledRef.current = false
|
|
161
|
+
if (scrollRef.current !== view) return
|
|
162
|
+
|
|
163
|
+
const queuedAnchor = queuedAnchorRestoreRef.current
|
|
164
|
+
queuedAnchorRestoreRef.current = null
|
|
165
|
+
if (!queuedAnchor) return
|
|
166
|
+
const index = indexByRowKeyRef.current.get(queuedAnchor.rowKey)
|
|
167
|
+
if (index === undefined) return
|
|
168
|
+
|
|
169
|
+
const nextOffset = Math.max(
|
|
170
|
+
0,
|
|
171
|
+
headerHeightRef.current + sizeIndexRef.current.prefix(index) + queuedAnchor.within,
|
|
172
|
+
)
|
|
173
|
+
const nativeOffset = Number(view.verticalOffset)
|
|
174
|
+
if (sameSize(nextOffset, nativeOffset)) {
|
|
175
|
+
scrollOffsetRef.current = nativeOffset
|
|
176
|
+
return
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
scrollOffsetRef.current = nextOffset
|
|
180
|
+
const nativeView = view.nativeViewProtected
|
|
181
|
+
const makePoint = (globalThis as any).CGPointMake
|
|
182
|
+
if (typeof nativeView?.setContentOffsetAnimated === 'function' && typeof makePoint === 'function') {
|
|
183
|
+
const current = nativeView.contentOffset
|
|
184
|
+
nativeView.setContentOffsetAnimated(makePoint(current.x, nextOffset), false)
|
|
185
|
+
} else if (typeof view.scrollToVerticalOffset === 'function') {
|
|
186
|
+
view.scrollToVerticalOffset(nextOffset, false)
|
|
187
|
+
}
|
|
188
|
+
}, 0)
|
|
189
|
+
anchorRestoreTimerRef.current = timer
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function cancelAnchorRestore() {
|
|
193
|
+
if (anchorRestoreTimerRef.current != null) clearTimeout(anchorRestoreTimerRef.current)
|
|
194
|
+
anchorRestoreTimerRef.current = null
|
|
195
|
+
anchorRestoreScheduledRef.current = false
|
|
196
|
+
queuedAnchorRestoreRef.current = null
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function scheduleEstimateRebuild(anchor: VirtualListAnchor | null) {
|
|
200
|
+
if (estimateScheduledRef.current) return
|
|
201
|
+
estimateScheduledRef.current = true
|
|
202
|
+
estimateAnchorRef.current = anchor
|
|
203
|
+
Promise.resolve().then(() => {
|
|
204
|
+
estimateScheduledRef.current = false
|
|
205
|
+
const scheduledAnchor = estimateAnchorRef.current
|
|
206
|
+
estimateAnchorRef.current = null
|
|
207
|
+
rebuildLayout(entriesRef.current, viewportWidthRef.current)
|
|
208
|
+
restoreAnchor(scheduledAnchor)
|
|
209
|
+
refreshWindow()
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function recordRowSize(rowKey: string, width: number, height: number) {
|
|
214
|
+
if (!Number.isFinite(height) || height < 0) return
|
|
215
|
+
const index = indexByRowKeyRef.current.get(rowKey)
|
|
216
|
+
if (index === undefined) return
|
|
217
|
+
const entry = entriesRef.current[index]
|
|
218
|
+
if (!entry) return
|
|
219
|
+
|
|
220
|
+
const hasRowSeparator = hasSeparatorRef.current && index < entriesRef.current.length - 1
|
|
221
|
+
const cacheKey = virtualListMeasurementKey(rowKey, hasRowSeparator)
|
|
222
|
+
const pendingAnchor = pendingAnchorRowsRef.current.has(rowKey) ? pendingAnchorRef.current : null
|
|
223
|
+
const anchor = pendingAnchor ?? queuedAnchorRestoreRef.current ?? captureCurrentAnchor()
|
|
224
|
+
sizeCacheRef.current.set(cacheKey, { width, height })
|
|
225
|
+
const delta = sizeIndexRef.current.set(index, height)
|
|
226
|
+
if (Math.abs(delta) >= 0.5) {
|
|
227
|
+
const anchorIndex = anchor ? indexByRowKeyRef.current.get(anchor.rowKey) : undefined
|
|
228
|
+
if (anchor && anchorIndex !== undefined && index < anchorIndex) restoreAnchor(anchor)
|
|
229
|
+
refreshWindow()
|
|
230
|
+
scheduleEstimateRebuild(anchor)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (pendingAnchor) {
|
|
234
|
+
pendingAnchorRowsRef.current.delete(rowKey)
|
|
235
|
+
if (pendingAnchorRowsRef.current.size === 0) pendingAnchorRef.current = null
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function syncViewport(view = scrollRef.current) {
|
|
240
|
+
if (!view) return
|
|
241
|
+
const size = view.getActualSize?.()
|
|
242
|
+
if (!size) return
|
|
243
|
+
|
|
244
|
+
const widthChanged = !sameSize(size.width, viewportWidthRef.current)
|
|
245
|
+
viewportHeightRef.current = size.height
|
|
246
|
+
if (widthChanged) {
|
|
247
|
+
const anchor = captureAnchor()
|
|
248
|
+
viewportWidthRef.current = size.width
|
|
249
|
+
rebuildLayout(entriesRef.current, size.width)
|
|
250
|
+
restoreAnchor(anchor)
|
|
251
|
+
}
|
|
252
|
+
refreshWindow()
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function onScroll(event: any) {
|
|
256
|
+
const view = event.object ?? scrollRef.current
|
|
257
|
+
const nextOffset = Number(view?.verticalOffset ?? 0)
|
|
258
|
+
const queuedAnchor = queuedAnchorRestoreRef.current
|
|
259
|
+
if (queuedAnchor && Math.abs(nextOffset - scrollOffsetRef.current) > viewportHeightRef.current) {
|
|
260
|
+
const anchorIndex = indexByRowKeyRef.current.get(queuedAnchor.rowKey)
|
|
261
|
+
const nextIndex = sizeIndexRef.current.indexAt(
|
|
262
|
+
Math.max(0, nextOffset - headerHeightRef.current),
|
|
263
|
+
)
|
|
264
|
+
if (anchorIndex !== undefined && Math.abs(nextIndex - anchorIndex) > 1) cancelAnchorRestore()
|
|
265
|
+
}
|
|
266
|
+
scrollOffsetRef.current = nextOffset
|
|
267
|
+
refreshWindow()
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function onHeaderLayout(event: any) {
|
|
271
|
+
const height = Number(event.object?.getActualSize?.().height ?? 0)
|
|
272
|
+
if (sameSize(height, headerHeightRef.current)) return
|
|
273
|
+
const anchor = captureAnchor()
|
|
274
|
+
headerHeightRef.current = height
|
|
275
|
+
restoreAnchor(anchor)
|
|
276
|
+
refreshWindow()
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
function onRowLayout(entry: VirtualListEntry<T>, event: any) {
|
|
280
|
+
const size = event.object?.getActualSize?.()
|
|
281
|
+
if (size) recordRowSize(entry.rowKey, size.width, size.height)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const range = currentRange()
|
|
285
|
+
rangeRef.current = range
|
|
286
|
+
void windowVersion
|
|
287
|
+
const visibleEntries = entries.slice(range.start, range.end)
|
|
288
|
+
const style = { ...props.style, minHeight: props.style?.minHeight ?? 0 }
|
|
289
|
+
|
|
290
|
+
<scrollview
|
|
291
|
+
ref={(view: any) => {
|
|
292
|
+
scrollRef.current = view
|
|
293
|
+
if (view) applyEscapeProps(view, props)
|
|
294
|
+
}}
|
|
295
|
+
id={props.id}
|
|
296
|
+
{...layoutChildProps(props)}
|
|
297
|
+
className={cx('vx-virtual-list', props.className)}
|
|
298
|
+
style={style}
|
|
299
|
+
orientation="vertical"
|
|
300
|
+
accessible={props.accessible}
|
|
301
|
+
accessibilityLabel={props.accessibilityLabel}
|
|
302
|
+
accessibilityRole={nativeAccessibilityRole(props.accessibilityRole) as any}
|
|
303
|
+
accessibilityHint={props.accessibilityHint}
|
|
304
|
+
accessibilityValue={props.accessibilityValue}
|
|
305
|
+
accessibilityState={nativeAccessibilityState(props.accessibilityState) as any}
|
|
306
|
+
accessibilityLiveRegion={props.accessibilityLiveRegion as any}
|
|
307
|
+
onLoaded={(event: any) => syncViewport(event.object)}
|
|
308
|
+
onLayoutChanged={(event: any) => syncViewport(event.object)}
|
|
309
|
+
onScroll={onScroll}
|
|
310
|
+
>
|
|
311
|
+
<flexboxlayout flexDirection="column" className={cx('vx-virtual-list-content')}>
|
|
312
|
+
{props.renderHeader ? (
|
|
313
|
+
<flexboxlayout
|
|
314
|
+
flexDirection="column"
|
|
315
|
+
className="vx-virtual-list-header"
|
|
316
|
+
flexShrink={0}
|
|
317
|
+
onLayoutChanged={onHeaderLayout}
|
|
318
|
+
>
|
|
319
|
+
{props.renderHeader()}
|
|
320
|
+
</flexboxlayout>
|
|
321
|
+
) : null}
|
|
322
|
+
{entries.length === 0 ? (
|
|
323
|
+
props.renderEmpty ? (
|
|
324
|
+
<flexboxlayout flexDirection="column" className="vx-virtual-list-empty">
|
|
325
|
+
{props.renderEmpty()}
|
|
326
|
+
</flexboxlayout>
|
|
327
|
+
) : null
|
|
328
|
+
) : (
|
|
329
|
+
<>
|
|
330
|
+
<flexboxlayout className="vx-virtual-list-spacer" style={{ height: range.top, flexShrink: 0 }} />
|
|
331
|
+
@for (const entry of visibleEntries; key entry.rowKey) {
|
|
332
|
+
<flexboxlayout
|
|
333
|
+
flexDirection="column"
|
|
334
|
+
className="vx-virtual-list-row"
|
|
335
|
+
style={{ flexShrink: 0 }}
|
|
336
|
+
onLayoutChanged={(event: any) => onRowLayout(entry, event)}
|
|
337
|
+
>
|
|
338
|
+
<flexboxlayout flexDirection="column" className="vx-virtual-list-item">
|
|
339
|
+
{props.renderItem(entry.item, entry.index)}
|
|
340
|
+
</flexboxlayout>
|
|
341
|
+
{hasSeparator && entry.index < entries.length - 1 ? (
|
|
342
|
+
<flexboxlayout flexDirection="column" className="vx-virtual-list-separator">
|
|
343
|
+
{props.renderSeparator?.()}
|
|
344
|
+
</flexboxlayout>
|
|
345
|
+
) : null}
|
|
346
|
+
</flexboxlayout>
|
|
347
|
+
}
|
|
348
|
+
<flexboxlayout className="vx-virtual-list-spacer" style={{ height: range.bottom, flexShrink: 0 }} />
|
|
349
|
+
</>
|
|
350
|
+
)}
|
|
351
|
+
{props.renderFooter ? (
|
|
352
|
+
<flexboxlayout flexDirection="column" className="vx-virtual-list-footer" flexShrink={0}>
|
|
353
|
+
{props.renderFooter()}
|
|
354
|
+
</flexboxlayout>
|
|
355
|
+
) : null}
|
|
356
|
+
</flexboxlayout>
|
|
357
|
+
</scrollview>
|
|
358
|
+
}
|