UNPKG

wix-style-react

Version:
56 lines 2.41 kB
import { dragAndDropDriverFactory, changeItemDepth, } from '../utils/DragAndDrop/dragAndDropDriverFactory'; import { baseUniDriverFactory, findByHook, } from '../test-utils/utils/unidriver'; import { dataHooks } from './constants'; export const nestableListBaseUniDriverFactory = (base, body) => { const dndProviderBase = findByHook(base, dataHooks.provider); return { ...baseUniDriverFactory(dndProviderBase, body), /** * reorder nestable list items by data-hook * @param {ReorderDataHooks} dataHooks { from: string, to: string } * @return {Promise<void>} */ reorder: async ({ dataHookFrom, dataHookTo }) => { const baseEl = await dndProviderBase.getNative(); const dragAndDropDriver = dragAndDropDriverFactory({ base: dndProviderBase, element: baseEl, }); await dragAndDropDriver.beginDrag({ dataHook: dataHookFrom }); await dragAndDropDriver.dragOver({ dataHook: dataHookTo }); await dragAndDropDriver.endDrag({ dataHook: dataHookTo }); }, /** * change nestable list item depth * @param {NestableItemDetails} nestableItemDetails { dataHook: string, depthLevel: number, threshold?: number } * @return {Promise<void>} */ changeItemDepth: async ({ dataHook, depthLevel, threshold = 30 }) => changeItemDepth({ dataHook, depthLevel, threshold, dragAndDropDriver: dragAndDropDriverFactory({ base: dndProviderBase, element: await dndProviderBase.getNative(), }), }), /** * get nestable list item position * @param itemDetails { dataHook: string } * @return {Promise<void>} */ getItemPosition: async ({ dataHook }) => dragAndDropDriverFactory({ base: dndProviderBase }).getItemPosition({ dataHook, }), /** * get nestable list item depth * @param itemDetails { dataHook: string } * @return {Promise<void>} */ getItemDepth: async ({ dataHook }) => dragAndDropDriverFactory({ base: dndProviderBase }).getItemDepth({ dataHook, }), }; }; export default nestableListBaseUniDriverFactory; //# sourceMappingURL=NestableListBase.uni.driver.js.map