react-native-sortables
Version:
Powerful Sortable Components for Flexible Content Reordering in React Native
103 lines (102 loc) • 3.5 kB
JavaScript
"use strict";
import React from "react";
/* eslint-disable react-hooks/rules-of-hooks */
/* eslint-disable react/jsx-key */
import { LayoutAnimationConfig } from 'react-native-reanimated';
import { DebugProvider } from '../../debug';
import { useWarnOnPropChange } from '../../hooks';
import { ContextProviderComposer } from '../utils';
import { AutoScrollProvider } from './AutoScrollProvider';
import { CommonValuesProvider } from './CommonValuesProvider';
import { CustomHandleProvider } from './CustomHandleProvider';
import { DragProvider } from './DragProvider';
import { LayerProvider } from './LayerProvider';
import { MeasurementsProvider } from './MeasurementsProvider';
import { useMultiZoneContext } from './MultiZoneProvider';
import { jsx as _jsx } from "react/jsx-runtime";
export default function SharedProvider({
animateScrollTo,
autoScrollActivationOffset,
autoScrollDirection,
autoScrollEnabled,
autoScrollExtrapolation,
autoScrollInterval,
autoScrollMaxOverscroll,
autoScrollMaxVelocity,
bringToFrontWhenActive,
children,
customHandle,
debug,
hapticsEnabled,
measureDebounceDelay,
onActiveItemDropped,
onDragEnd,
onDragMove,
onDragStart,
onOrderChange,
overDrag,
reorderTriggerOrigin,
scrollableRef,
sortEnabled,
...rest
}) {
const inMultiZone = !!useMultiZoneContext();
if (__DEV__) {
useWarnOnPropChange('debug', debug);
useWarnOnPropChange('customHandle', customHandle);
useWarnOnPropChange('scrollableRef', scrollableRef);
}
const providers = [
// Provider used for proper zIndex management
bringToFrontWhenActive && !inMultiZone && /*#__PURE__*/_jsx(LayerProvider, {}),
// Provider used for layout debugging (can be used only in dev mode)
__DEV__ && debug && /*#__PURE__*/_jsx(DebugProvider, {}),
/*#__PURE__*/
// Provider used for shared values between all providers below
_jsx(CommonValuesProvider, {
customHandle: customHandle,
sortEnabled: sortEnabled,
...rest
}),
/*#__PURE__*/
// Provider used for measurements of items and the container
_jsx(MeasurementsProvider, {
measureDebounceDelay: measureDebounceDelay
}),
// Provider used for auto-scrolling when dragging an item near the
// edge of the container
scrollableRef && /*#__PURE__*/_jsx(AutoScrollProvider, {
animateScrollTo: animateScrollTo,
autoScrollActivationOffset: autoScrollActivationOffset,
autoScrollDirection: autoScrollDirection,
autoScrollEnabled: autoScrollEnabled,
autoScrollExtrapolation: autoScrollExtrapolation,
autoScrollInterval: autoScrollInterval,
autoScrollMaxOverscroll: autoScrollMaxOverscroll,
autoScrollMaxVelocity: autoScrollMaxVelocity,
scrollableRef: scrollableRef
}),
// Provider used for custom handle component related values
customHandle && /*#__PURE__*/_jsx(CustomHandleProvider, {}),
/*#__PURE__*/
// Provider used for dragging and item swapping logic
_jsx(DragProvider, {
hapticsEnabled: hapticsEnabled,
overDrag: overDrag,
reorderTriggerOrigin: reorderTriggerOrigin,
onActiveItemDropped: onActiveItemDropped,
onDragEnd: onDragEnd,
onDragMove: onDragMove,
onDragStart: onDragStart,
onOrderChange: onOrderChange
})];
return /*#__PURE__*/_jsx(ContextProviderComposer, {
providers: providers,
children: /*#__PURE__*/_jsx(LayoutAnimationConfig, {
skipEntering: true,
skipExiting: true,
children: children
})
});
}
//# sourceMappingURL=SharedProvider.js.map