react-native-sortables
Version:
Powerful Sortable Components for Flexible Content Reordering in React Native
90 lines (89 loc) • 2.97 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 { AutoScrollProvider, CommonValuesProvider, CustomHandleProvider, DragProvider, LayerProvider, MeasurementsProvider, useMultiZoneContext } from './shared';
import { ContextProviderComposer } from './utils';
import { jsx as _jsx } from "react/jsx-runtime";
export default function SharedProvider({
autoScrollActivationOffset,
autoScrollDirection,
autoScrollEnabled,
autoScrollSpeed,
bringToFrontWhenActive,
children,
customHandle,
debug,
hapticsEnabled,
itemKeys,
maxScrollToOverflowOffset,
onActiveItemDropped,
onDragEnd,
onDragMove,
onDragStart,
onOrderChange,
overDrag,
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,
itemKeys: itemKeys,
sortEnabled: sortEnabled,
...rest
}),
/*#__PURE__*/
// Provider used for measurements of items and the container
_jsx(MeasurementsProvider, {
itemsCount: itemKeys.length
}),
// Provider used for auto-scrolling when dragging an item near the
// edge of the container
scrollableRef && /*#__PURE__*/_jsx(AutoScrollProvider, {
autoScrollActivationOffset: autoScrollActivationOffset,
autoScrollDirection: autoScrollDirection,
autoScrollEnabled: autoScrollEnabled,
autoScrollSpeed: autoScrollSpeed,
maxScrollToOverflowOffset: maxScrollToOverflowOffset,
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,
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