UNPKG

wix-style-react

Version:
140 lines (123 loc) 5.47 kB
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _regeneratorRuntime from "@babel/runtime/regenerator"; function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; } function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } import { dragAndDropDriverFactory } from '../../utils/DragAndDrop/dragAndDropDriverFactory'; import { baseUniDriverFactory } from '../../../test/utils/unidriver'; export var draggableUniDriverFactory = function draggableUniDriverFactory(base, body) { return _objectSpread(_objectSpread({}, baseUniDriverFactory(base, body)), {}, { /** * fire dragstart event for the provided draggable item * @param {DraggableItemDetails} itemDetails { id: string, dataHook: string } * @return {Promise<void>} */ beginDrag: function () { var _beginDrag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) { var dataHook, id; return _regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: dataHook = _ref.dataHook, id = _ref.id; _context.t0 = dragAndDropDriverFactory; _context.t1 = base; _context.next = 5; return base.getNative(); case 5: _context.t2 = _context.sent; _context.t3 = { base: _context.t1, element: _context.t2 }; return _context.abrupt("return", (0, _context.t0)(_context.t3).beginDrag({ dataHook: dataHook, id: id })); case 8: case "end": return _context.stop(); } } }, _callee); })); function beginDrag(_x) { return _beginDrag.apply(this, arguments); } return beginDrag; }(), /** * fire dragover event for the provided draggable item * @param {DraggableItemDetails} itemDetails { id: string, dataHook: string } * @return {Promise<void>} */ dragOver: function () { var _dragOver = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) { var dataHook, id; return _regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: dataHook = _ref2.dataHook, id = _ref2.id; _context2.t0 = dragAndDropDriverFactory; _context2.t1 = base; _context2.next = 5; return base.getNative(); case 5: _context2.t2 = _context2.sent; _context2.t3 = { base: _context2.t1, element: _context2.t2 }; return _context2.abrupt("return", (0, _context2.t0)(_context2.t3).dragOver({ dataHook: dataHook, id: id })); case 8: case "end": return _context2.stop(); } } }, _callee2); })); function dragOver(_x2) { return _dragOver.apply(this, arguments); } return dragOver; }(), /** * fire drop and dragend events for the provided draggable item * @param {DraggableItemDetails} itemDetails { id: string, dataHook: string } * @return {Promise<void>} */ endDrag: function () { var _endDrag = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(draggableItemDetails) { return _regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: _context3.t0 = dragAndDropDriverFactory; _context3.t1 = base; _context3.next = 4; return base.getNative(); case 4: _context3.t2 = _context3.sent; _context3.t3 = { base: _context3.t1, element: _context3.t2 }; return _context3.abrupt("return", (0, _context3.t0)(_context3.t3).endDrag(draggableItemDetails)); case 7: case "end": return _context3.stop(); } } }, _callee3); })); function endDrag(_x3) { return _endDrag.apply(this, arguments); } return endDrag; }() }); };