UNPKG

react-native-sortables

Version:

Powerful Sortable Components for Flexible Content Reordering in React Native

48 lines (46 loc) 1.19 kB
"use strict"; import React from "react"; import { useCallback } from 'react'; import { StyleSheet } from 'react-native'; import Animated, { useAnimatedStyle } from 'react-native-reanimated'; import { useMutableValue } from '../../integrations/reanimated'; import { createProvider } from '../utils'; import { jsx as _jsx } from "react/jsx-runtime"; const { LayerProvider, useLayerContext } = createProvider('Layer', { guarded: false })(({ children, disabled }) => { const { updateLayer: updateParentLayer } = useLayerContext() ?? {}; const zIndex = useMutableValue(0); const updateLayer = useCallback(state => { 'worklet'; zIndex.value = state; updateParentLayer?.(state); }, [zIndex, updateParentLayer]); const animatedStyle = useAnimatedStyle(() => ({ zIndex: disabled ? 0 : zIndex.value })); return { children: /*#__PURE__*/_jsx(Animated.View, { style: [styles.container, animatedStyle], children: children }), value: { updateLayer } }; }); const styles = StyleSheet.create({ container: { minWidth: '100%' } }); export { LayerProvider, useLayerContext }; //# sourceMappingURL=LayerProvider.js.map