UNPKG

@wix/design-system

Version:

@wix/design-system

57 lines (56 loc) 2.49 kB
"use strict"; exports.__esModule = true; exports.nestableListBaseFactory = void 0; var _dragAndDropDriverFactory = require("../utils/DragAndDrop/dragAndDropDriverFactory"); var _constants = require("../DragAndDrop/Draggable/constants"); var _constants2 = require("./constants"); var _deprecationTestkitLog = require("../utils/deprecationTestkitLog"); var nestableListBaseFactory = _ref => { var element = _ref.element; (0, _deprecationTestkitLog.deprecationTestkitLog)('nestableListBaseTestkitFactory legacy testkit is deprecated and will be removed in next major release. Please use the NestableListBaseTestkit unidriver testkit instead.'); var dragAndDropDriver = (0, _dragAndDropDriverFactory.dragAndDropDriverFactory)({ element: element.querySelector("[data-hook=\"".concat(_constants2.dataHooks.provider, "\"]")) }); return { /** checks if exists */ exists: () => !!element, /** reorder nestable list items */ reorder: _ref2 => { var dataHookFrom = _ref2.dataHookFrom, dataHookTo = _ref2.dataHookTo; dragAndDropDriver.beginDrag({ dataHook: "".concat(dataHookFrom) }); dragAndDropDriver.dragOver({ dataHook: "".concat(dataHookTo) }); dragAndDropDriver.endDrag(); }, /** change nestable list item depth */ changeItemDepth: _ref3 => { var dataHook = _ref3.dataHook, depthLevel = _ref3.depthLevel, _ref3$threshold = _ref3.threshold, threshold = _ref3$threshold === void 0 ? 30 : _ref3$threshold; return (0, _dragAndDropDriverFactory.changeItemDepth)({ dragAndDropDriver, depthLevel, threshold, dataHook: "".concat(dataHook) }); }, /** get nestable list item position */ getItemPosition: _ref4 => { var dataHook = _ref4.dataHook; var draggableItems = [...element.querySelectorAll("[".concat(_constants.dataAttributes.draggableTarget, "]"))]; return draggableItems.findIndex(item => item.querySelectorAll("[".concat(_constants.dataAttributes.draggableSource, "]"))[0].getAttribute('data-hook') === "".concat(dataHook)); }, /** get nestable list item depth */ getItemDepth: _ref5 => { var dataHook = _ref5.dataHook; return parseInt(element.querySelector("[data-hook=".concat(dataHook, "]")).getAttribute(_constants.dataAttributes.depth)); } }; }; exports.nestableListBaseFactory = nestableListBaseFactory; //# sourceMappingURL=NestableListBase.driver.js.map