dnd-core
Advanced tools
Comparing version 10.0.2 to 11.0.0
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = createBeginDrag; | ||
exports.createBeginDrag = createBeginDrag; | ||
@@ -52,2 +52,6 @@ var _invariant = require("@react-dnd/invariant"); | ||
if (clientOffset) { | ||
if (!getSourceClientOffset) { | ||
throw new Error('getSourceClientOffset must be defined'); | ||
} | ||
verifyGetSourceClientOffsetIsFunction(getSourceClientOffset); | ||
@@ -54,0 +58,0 @@ sourceClientOffset = getSourceClientOffset(sourceId); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = createDrop; | ||
exports.createDrop = createDrop; | ||
@@ -34,3 +34,3 @@ var _invariant = require("@react-dnd/invariant"); | ||
payload: { | ||
dropResult: _objectSpread({}, options, {}, dropResult) | ||
dropResult: _objectSpread(_objectSpread({}, options), dropResult) | ||
} | ||
@@ -37,0 +37,0 @@ }; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = createEndDrag; | ||
exports.createEndDrag = createEndDrag; | ||
@@ -19,5 +19,9 @@ var _invariant = require("@react-dnd/invariant"); | ||
var sourceId = monitor.getSourceId(); | ||
var source = registry.getSource(sourceId, true); | ||
source.endDrag(monitor, sourceId); | ||
registry.unpinSource(); | ||
if (sourceId != null) { | ||
var source = registry.getSource(sourceId, true); | ||
source.endDrag(monitor, sourceId); | ||
registry.unpinSource(); | ||
} | ||
return { | ||
@@ -24,0 +28,0 @@ type: _types.END_DRAG |
@@ -6,12 +6,10 @@ "use strict"; | ||
}); | ||
exports.default = createHover; | ||
exports.createHover = createHover; | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _matchesType = _interopRequireDefault(require("../../utils/matchesType")); | ||
var _matchesType = require("../../utils/matchesType"); | ||
var _types = require("./types"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function createHover(manager) { | ||
@@ -64,3 +62,3 @@ return function hover(targetIdsArg) { | ||
if (!(0, _matchesType.default)(targetType, draggedItemType)) { | ||
if (!(0, _matchesType.matchesType)(targetType, draggedItemType)) { | ||
targetIds.splice(i, 1); | ||
@@ -67,0 +65,0 @@ } |
@@ -6,14 +6,16 @@ "use strict"; | ||
}); | ||
var _exportNames = {}; | ||
exports.default = createDragDropActions; | ||
var _exportNames = { | ||
createDragDropActions: true | ||
}; | ||
exports.createDragDropActions = createDragDropActions; | ||
var _beginDrag = _interopRequireDefault(require("./beginDrag")); | ||
var _beginDrag = require("./beginDrag"); | ||
var _publishDragSource = _interopRequireDefault(require("./publishDragSource")); | ||
var _publishDragSource = require("./publishDragSource"); | ||
var _hover = _interopRequireDefault(require("./hover")); | ||
var _hover = require("./hover"); | ||
var _drop = _interopRequireDefault(require("./drop")); | ||
var _drop = require("./drop"); | ||
var _endDrag = _interopRequireDefault(require("./endDrag")); | ||
var _endDrag = require("./endDrag"); | ||
@@ -33,12 +35,10 @@ var _types = require("./types"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function createDragDropActions(manager) { | ||
return { | ||
beginDrag: (0, _beginDrag.default)(manager), | ||
publishDragSource: (0, _publishDragSource.default)(manager), | ||
hover: (0, _hover.default)(manager), | ||
drop: (0, _drop.default)(manager), | ||
endDrag: (0, _endDrag.default)(manager) | ||
beginDrag: (0, _beginDrag.createBeginDrag)(manager), | ||
publishDragSource: (0, _publishDragSource.createPublishDragSource)(manager), | ||
hover: (0, _hover.createHover)(manager), | ||
drop: (0, _drop.createDrop)(manager), | ||
endDrag: (0, _endDrag.createEndDrag)(manager) | ||
}; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = createPublishDragSource; | ||
exports.createPublishDragSource = createPublishDragSource; | ||
@@ -9,0 +9,0 @@ var _types = require("./types"); |
@@ -12,3 +12,3 @@ "use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -15,0 +15,0 @@ function validateSourceContract(source) { |
@@ -6,16 +6,14 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.DragDropManagerImpl = void 0; | ||
var _redux = require("redux"); | ||
var _reducers = _interopRequireDefault(require("./reducers")); | ||
var _reducers = require("./reducers"); | ||
var _dragDrop = _interopRequireDefault(require("./actions/dragDrop")); | ||
var _dragDrop = require("./actions/dragDrop"); | ||
var _DragDropMonitorImpl = _interopRequireDefault(require("./DragDropMonitorImpl")); | ||
var _DragDropMonitorImpl = require("./DragDropMonitorImpl"); | ||
var _HandlerRegistryImpl = _interopRequireDefault(require("./HandlerRegistryImpl")); | ||
var _HandlerRegistryImpl = require("./HandlerRegistryImpl"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -31,3 +29,3 @@ | ||
var reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
return (0, _redux.createStore)(_reducers.default, debugMode && reduxDevTools && reduxDevTools({ | ||
return (0, _redux.createStore)(_reducers.reduce, debugMode && reduxDevTools && reduxDevTools({ | ||
name: 'dnd-core', | ||
@@ -38,5 +36,3 @@ instanceId: 'dnd-core' | ||
var DragDropManagerImpl = | ||
/*#__PURE__*/ | ||
function () { | ||
var DragDropManagerImpl = /*#__PURE__*/function () { | ||
function DragDropManagerImpl() { | ||
@@ -69,3 +65,3 @@ var _this = this; | ||
this.store = store; | ||
this.monitor = new _DragDropMonitorImpl.default(store, new _HandlerRegistryImpl.default(store)); | ||
this.monitor = new _DragDropMonitorImpl.DragDropMonitorImpl(store, new _HandlerRegistryImpl.HandlerRegistryImpl(store)); | ||
store.subscribe(this.handleRefCountChange); | ||
@@ -115,3 +111,3 @@ } | ||
var actions = (0, _dragDrop.default)(this); | ||
var actions = (0, _dragDrop.createDragDropActions)(this); | ||
return Object.keys(actions).reduce(function (boundActions, key) { | ||
@@ -133,2 +129,2 @@ var action = actions[key]; | ||
exports.default = DragDropManagerImpl; | ||
exports.DragDropManagerImpl = DragDropManagerImpl; |
@@ -6,7 +6,7 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.DragDropMonitorImpl = void 0; | ||
var _invariant = require("@react-dnd/invariant"); | ||
var _matchesType = _interopRequireDefault(require("./utils/matchesType")); | ||
var _matchesType = require("./utils/matchesType"); | ||
@@ -17,4 +17,2 @@ var _coords = require("./utils/coords"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -26,5 +24,3 @@ | ||
var DragDropMonitorImpl = | ||
/*#__PURE__*/ | ||
function () { | ||
var DragDropMonitorImpl = /*#__PURE__*/function () { | ||
function DragDropMonitorImpl(store, registry) { | ||
@@ -122,3 +118,3 @@ _classCallCheck(this, DragDropMonitorImpl); | ||
var draggedItemType = this.getItemType(); | ||
return (0, _matchesType.default)(targetType, draggedItemType) && target.canDrop(this, targetId); | ||
return (0, _matchesType.matchesType)(targetType, draggedItemType) && target.canDrop(this, targetId); | ||
} | ||
@@ -175,3 +171,3 @@ }, { | ||
if (draggedItemType && !(0, _matchesType.default)(targetType, draggedItemType)) { | ||
if (draggedItemType && !(0, _matchesType.matchesType)(targetType, draggedItemType)) { | ||
return false; | ||
@@ -227,3 +223,3 @@ } | ||
value: function isSourcePublic() { | ||
return this.store.getState().dragOperation.isSourcePublic; | ||
return Boolean(this.store.getState().dragOperation.isSourcePublic); | ||
} | ||
@@ -260,2 +256,2 @@ }, { | ||
exports.default = DragDropMonitorImpl; | ||
exports.DragDropMonitorImpl = DragDropMonitorImpl; |
@@ -8,8 +8,6 @@ "use strict"; | ||
var _DragDropManagerImpl = _interopRequireDefault(require("./DragDropManagerImpl")); | ||
var _DragDropManagerImpl = require("./DragDropManagerImpl"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function createDragDropManager(backendFactory, globalContext, backendOptions, debugMode) { | ||
var manager = new _DragDropManagerImpl.default(debugMode); | ||
var manager = new _DragDropManagerImpl.DragDropManagerImpl(debugMode); | ||
var backend = backendFactory(manager, globalContext, backendOptions); | ||
@@ -16,0 +14,0 @@ manager.receiveBackend(backend); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = void 0; | ||
exports.HandlerRegistryImpl = void 0; | ||
@@ -13,3 +13,3 @@ var _invariant = require("@react-dnd/invariant"); | ||
var _getNextUniqueId = _interopRequireDefault(require("./utils/getNextUniqueId")); | ||
var _getNextUniqueId = require("./utils/getNextUniqueId"); | ||
@@ -22,4 +22,2 @@ var _interfaces = require("./interfaces"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -31,12 +29,16 @@ | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function getNextHandlerId(role) { | ||
var id = (0, _getNextUniqueId.default)().toString(); | ||
var id = (0, _getNextUniqueId.getNextUniqueId)().toString(); | ||
@@ -88,5 +90,3 @@ switch (role) { | ||
var HandlerRegistryImpl = | ||
/*#__PURE__*/ | ||
function () { | ||
var HandlerRegistryImpl = /*#__PURE__*/function () { | ||
function HandlerRegistryImpl(store) { | ||
@@ -220,2 +220,2 @@ _classCallCheck(this, HandlerRegistryImpl); | ||
exports.default = HandlerRegistryImpl; | ||
exports.HandlerRegistryImpl = HandlerRegistryImpl; |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = dirtyHandlerIds; | ||
exports.reduce = reduce; | ||
@@ -19,4 +19,5 @@ var _dragDrop = require("../actions/dragDrop"); | ||
function dirtyHandlerIds() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _dirtiness.NONE; | ||
function reduce() { | ||
var _state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _dirtiness.NONE; | ||
var action = arguments.length > 1 ? arguments[1] : undefined; | ||
@@ -23,0 +24,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = dragOffset; | ||
exports.reduce = reduce; | ||
@@ -25,3 +25,3 @@ var _dragDrop = require("../actions/dragDrop"); | ||
function dragOffset() { | ||
function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
@@ -45,3 +45,3 @@ var action = arguments.length > 1 ? arguments[1] : undefined; | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
clientOffset: payload.clientOffset | ||
@@ -48,0 +48,0 @@ }); |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = dragOperation; | ||
exports.reduce = reduce; | ||
@@ -31,3 +31,3 @@ var _dragDrop = require("../actions/dragDrop"); | ||
function dragOperation() { | ||
function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
@@ -39,3 +39,3 @@ var action = arguments.length > 1 ? arguments[1] : undefined; | ||
case _dragDrop.BEGIN_DRAG: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
itemType: payload.itemType, | ||
@@ -50,3 +50,3 @@ item: payload.item, | ||
case _dragDrop.PUBLISH_DRAG_SOURCE: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
isSourcePublic: true | ||
@@ -56,3 +56,3 @@ }); | ||
case _dragDrop.HOVER: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
targetIds: payload.targetIds | ||
@@ -66,3 +66,3 @@ }); | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
targetIds: (0, _js_utils.without)(state.targetIds, payload.targetId) | ||
@@ -72,3 +72,3 @@ }); | ||
case _dragDrop.DROP: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
dropResult: payload.dropResult, | ||
@@ -80,3 +80,3 @@ didDrop: true, | ||
case _dragDrop.END_DRAG: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
itemType: null, | ||
@@ -83,0 +83,0 @@ item: null, |
@@ -6,18 +6,16 @@ "use strict"; | ||
}); | ||
exports.default = reduce; | ||
exports.reduce = reduce; | ||
var _dragOffset = _interopRequireDefault(require("./dragOffset")); | ||
var _dragOffset = require("./dragOffset"); | ||
var _dragOperation = _interopRequireDefault(require("./dragOperation")); | ||
var _dragOperation = require("./dragOperation"); | ||
var _refCount = _interopRequireDefault(require("./refCount")); | ||
var _refCount = require("./refCount"); | ||
var _dirtyHandlerIds = _interopRequireDefault(require("./dirtyHandlerIds")); | ||
var _dirtyHandlerIds = require("./dirtyHandlerIds"); | ||
var _stateId = _interopRequireDefault(require("./stateId")); | ||
var _stateId = require("./stateId"); | ||
var _js_utils = require("../utils/js_utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
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; } | ||
@@ -33,13 +31,13 @@ | ||
return { | ||
dirtyHandlerIds: (0, _dirtyHandlerIds.default)(state.dirtyHandlerIds, { | ||
dirtyHandlerIds: (0, _dirtyHandlerIds.reduce)(state.dirtyHandlerIds, { | ||
type: action.type, | ||
payload: _objectSpread({}, action.payload, { | ||
payload: _objectSpread(_objectSpread({}, action.payload), {}, { | ||
prevTargetIds: (0, _js_utils.get)(state, 'dragOperation.targetIds', []) | ||
}) | ||
}), | ||
dragOffset: (0, _dragOffset.default)(state.dragOffset, action), | ||
refCount: (0, _refCount.default)(state.refCount, action), | ||
dragOperation: (0, _dragOperation.default)(state.dragOperation, action), | ||
stateId: (0, _stateId.default)(state.stateId) | ||
dragOffset: (0, _dragOffset.reduce)(state.dragOffset, action), | ||
refCount: (0, _refCount.reduce)(state.refCount, action), | ||
dragOperation: (0, _dragOperation.reduce)(state.dragOperation, action), | ||
stateId: (0, _stateId.reduce)(state.stateId) | ||
}; | ||
} |
@@ -6,7 +6,7 @@ "use strict"; | ||
}); | ||
exports.default = refCount; | ||
exports.reduce = reduce; | ||
var _registry = require("../actions/registry"); | ||
function refCount() { | ||
function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
@@ -13,0 +13,0 @@ var action = arguments.length > 1 ? arguments[1] : undefined; |
@@ -6,7 +6,7 @@ "use strict"; | ||
}); | ||
exports.default = stateId; | ||
exports.reduce = reduce; | ||
function stateId() { | ||
function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
return state + 1; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = getNextUniqueId; | ||
exports.getNextUniqueId = getNextUniqueId; | ||
var nextUniqueId = 0; | ||
@@ -9,0 +9,0 @@ |
@@ -13,3 +13,3 @@ "use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -68,3 +68,3 @@ // cheap lodash replacements | ||
var insertItem = function insertItem(item) { | ||
return map.set(item, map.has(item) ? map.get(item) + 1 : 1); | ||
map.set(item, map.has(item) ? map.get(item) + 1 : 1); | ||
}; | ||
@@ -71,0 +71,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.default = matchesType; | ||
exports.matchesType = matchesType; | ||
@@ -9,0 +9,0 @@ function matchesType(targetType, draggedItemType) { |
@@ -12,3 +12,3 @@ import { invariant } from '@react-dnd/invariant'; | ||
}; | ||
export default function createBeginDrag(manager) { | ||
export function createBeginDrag(manager) { | ||
return function beginDrag() { | ||
@@ -40,2 +40,6 @@ var sourceIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
if (clientOffset) { | ||
if (!getSourceClientOffset) { | ||
throw new Error('getSourceClientOffset must be defined'); | ||
} | ||
verifyGetSourceClientOffsetIsFunction(getSourceClientOffset); | ||
@@ -42,0 +46,0 @@ sourceClientOffset = getSourceClientOffset(sourceId); |
@@ -10,3 +10,3 @@ 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; } | ||
import { isObject } from '../../utils/js_utils'; | ||
export default function createDrop(manager) { | ||
export function createDrop(manager) { | ||
return function drop() { | ||
@@ -24,3 +24,3 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
payload: { | ||
dropResult: _objectSpread({}, options, {}, dropResult) | ||
dropResult: _objectSpread(_objectSpread({}, options), dropResult) | ||
} | ||
@@ -27,0 +27,0 @@ }; |
import { invariant } from '@react-dnd/invariant'; | ||
import { END_DRAG } from './types'; | ||
export default function createEndDrag(manager) { | ||
export function createEndDrag(manager) { | ||
return function endDrag() { | ||
@@ -9,5 +9,9 @@ var monitor = manager.getMonitor(); | ||
var sourceId = monitor.getSourceId(); | ||
var source = registry.getSource(sourceId, true); | ||
source.endDrag(monitor, sourceId); | ||
registry.unpinSource(); | ||
if (sourceId != null) { | ||
var source = registry.getSource(sourceId, true); | ||
source.endDrag(monitor, sourceId); | ||
registry.unpinSource(); | ||
} | ||
return { | ||
@@ -14,0 +18,0 @@ type: END_DRAG |
import { invariant } from '@react-dnd/invariant'; | ||
import matchesType from '../../utils/matchesType'; | ||
import { matchesType } from '../../utils/matchesType'; | ||
import { HOVER } from './types'; | ||
export default function createHover(manager) { | ||
export function createHover(manager) { | ||
return function hover(targetIdsArg) { | ||
@@ -6,0 +6,0 @@ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, |
@@ -1,8 +0,8 @@ | ||
import createBeginDrag from './beginDrag'; | ||
import createPublishDragSource from './publishDragSource'; | ||
import createHover from './hover'; | ||
import createDrop from './drop'; | ||
import createEndDrag from './endDrag'; | ||
import { createBeginDrag } from './beginDrag'; | ||
import { createPublishDragSource } from './publishDragSource'; | ||
import { createHover } from './hover'; | ||
import { createDrop } from './drop'; | ||
import { createEndDrag } from './endDrag'; | ||
export * from './types'; | ||
export default function createDragDropActions(manager) { | ||
export function createDragDropActions(manager) { | ||
return { | ||
@@ -9,0 +9,0 @@ beginDrag: createBeginDrag(manager), |
import { PUBLISH_DRAG_SOURCE } from './types'; | ||
export default function createPublishDragSource(manager) { | ||
export function createPublishDragSource(manager) { | ||
return function publishDragSource() { | ||
@@ -4,0 +4,0 @@ var monitor = manager.getMonitor(); |
@@ -1,2 +0,2 @@ | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -3,0 +3,0 @@ import { invariant } from '@react-dnd/invariant'; |
@@ -8,6 +8,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { createStore } from 'redux'; | ||
import reducer from './reducers'; | ||
import dragDropActions from './actions/dragDrop'; | ||
import DragDropMonitorImpl from './DragDropMonitorImpl'; | ||
import HandlerRegistryImpl from './HandlerRegistryImpl'; | ||
import { reduce } from './reducers'; | ||
import { createDragDropActions } from './actions/dragDrop'; | ||
import { DragDropMonitorImpl } from './DragDropMonitorImpl'; | ||
import { HandlerRegistryImpl } from './HandlerRegistryImpl'; | ||
@@ -18,3 +18,3 @@ function makeStoreInstance(debugMode) { | ||
var reduxDevTools = typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
return createStore(reducer, debugMode && reduxDevTools && reduxDevTools({ | ||
return createStore(reduce, debugMode && reduxDevTools && reduxDevTools({ | ||
name: 'dnd-core', | ||
@@ -25,5 +25,3 @@ instanceId: 'dnd-core' | ||
var DragDropManagerImpl = | ||
/*#__PURE__*/ | ||
function () { | ||
export var DragDropManagerImpl = /*#__PURE__*/function () { | ||
function DragDropManagerImpl() { | ||
@@ -101,3 +99,3 @@ var _this = this; | ||
var actions = dragDropActions(this); | ||
var actions = createDragDropActions(this); | ||
return Object.keys(actions).reduce(function (boundActions, key) { | ||
@@ -117,4 +115,2 @@ var action = actions[key]; | ||
return DragDropManagerImpl; | ||
}(); | ||
export { DragDropManagerImpl as default }; | ||
}(); |
@@ -8,9 +8,6 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
import { invariant } from '@react-dnd/invariant'; | ||
import matchesType from './utils/matchesType'; | ||
import { matchesType } from './utils/matchesType'; | ||
import { getSourceClientOffset as _getSourceClientOffset, getDifferenceFromInitialOffset as _getDifferenceFromInitialOffset } from './utils/coords'; | ||
import { areDirty } from './utils/dirtiness'; | ||
var DragDropMonitorImpl = | ||
/*#__PURE__*/ | ||
function () { | ||
export var DragDropMonitorImpl = /*#__PURE__*/function () { | ||
function DragDropMonitorImpl(store, registry) { | ||
@@ -211,3 +208,3 @@ _classCallCheck(this, DragDropMonitorImpl); | ||
value: function isSourcePublic() { | ||
return this.store.getState().dragOperation.isSourcePublic; | ||
return Boolean(this.store.getState().dragOperation.isSourcePublic); | ||
} | ||
@@ -242,4 +239,2 @@ }, { | ||
return DragDropMonitorImpl; | ||
}(); | ||
export { DragDropMonitorImpl as default }; | ||
}(); |
@@ -1,2 +0,2 @@ | ||
import DragDropManagerImpl from './DragDropManagerImpl'; | ||
import { DragDropManagerImpl } from './DragDropManagerImpl'; | ||
export function createDragDropManager(backendFactory, globalContext, backendOptions, debugMode) { | ||
@@ -3,0 +3,0 @@ var manager = new DragDropManagerImpl(debugMode); |
@@ -7,8 +7,12 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
@@ -18,3 +22,3 @@ | ||
import { addSource as _addSource, addTarget as _addTarget, removeSource as _removeSource, removeTarget as _removeTarget } from './actions/registry'; | ||
import getNextUniqueId from './utils/getNextUniqueId'; | ||
import { getNextUniqueId } from './utils/getNextUniqueId'; | ||
import { HandlerRole } from './interfaces'; | ||
@@ -72,5 +76,3 @@ import { validateSourceContract, validateTargetContract, validateType } from './contracts'; | ||
var HandlerRegistryImpl = | ||
/*#__PURE__*/ | ||
function () { | ||
export var HandlerRegistryImpl = /*#__PURE__*/function () { | ||
function HandlerRegistryImpl(store) { | ||
@@ -202,4 +204,2 @@ _classCallCheck(this, HandlerRegistryImpl); | ||
return HandlerRegistryImpl; | ||
}(); | ||
export { HandlerRegistryImpl as default }; | ||
}(); |
@@ -6,4 +6,5 @@ import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP } from '../actions/dragDrop'; | ||
import { xor } from '../utils/js_utils'; | ||
export default function dirtyHandlerIds() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NONE; | ||
export function reduce() { | ||
var _state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : NONE; | ||
var action = arguments.length > 1 ? arguments[1] : undefined; | ||
@@ -10,0 +11,0 @@ |
@@ -14,3 +14,3 @@ 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; } | ||
}; | ||
export default function dragOffset() { | ||
export function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
@@ -34,3 +34,3 @@ var action = arguments.length > 1 ? arguments[1] : undefined; | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
clientOffset: payload.clientOffset | ||
@@ -37,0 +37,0 @@ }); |
@@ -19,3 +19,3 @@ 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; } | ||
}; | ||
export default function dragOperation() { | ||
export function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; | ||
@@ -27,3 +27,3 @@ var action = arguments.length > 1 ? arguments[1] : undefined; | ||
case BEGIN_DRAG: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
itemType: payload.itemType, | ||
@@ -38,3 +38,3 @@ item: payload.item, | ||
case PUBLISH_DRAG_SOURCE: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
isSourcePublic: true | ||
@@ -44,3 +44,3 @@ }); | ||
case HOVER: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
targetIds: payload.targetIds | ||
@@ -54,3 +54,3 @@ }); | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
targetIds: without(state.targetIds, payload.targetId) | ||
@@ -60,3 +60,3 @@ }); | ||
case DROP: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
dropResult: payload.dropResult, | ||
@@ -68,3 +68,3 @@ didDrop: true, | ||
case END_DRAG: | ||
return _objectSpread({}, state, { | ||
return _objectSpread(_objectSpread({}, state), {}, { | ||
itemType: null, | ||
@@ -71,0 +71,0 @@ item: null, |
@@ -7,9 +7,9 @@ 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; } | ||
import dragOffset from './dragOffset'; | ||
import dragOperation from './dragOperation'; | ||
import refCount from './refCount'; | ||
import dirtyHandlerIds from './dirtyHandlerIds'; | ||
import stateId from './stateId'; | ||
import { reduce as dragOffset } from './dragOffset'; | ||
import { reduce as dragOperation } from './dragOperation'; | ||
import { reduce as refCount } from './refCount'; | ||
import { reduce as dirtyHandlerIds } from './dirtyHandlerIds'; | ||
import { reduce as stateId } from './stateId'; | ||
import { get } from '../utils/js_utils'; | ||
export default function reduce() { | ||
export function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
@@ -20,3 +20,3 @@ var action = arguments.length > 1 ? arguments[1] : undefined; | ||
type: action.type, | ||
payload: _objectSpread({}, action.payload, { | ||
payload: _objectSpread(_objectSpread({}, action.payload), {}, { | ||
prevTargetIds: get(state, 'dragOperation.targetIds', []) | ||
@@ -23,0 +23,0 @@ }) |
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET } from '../actions/registry'; | ||
export default function refCount() { | ||
export function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
@@ -4,0 +4,0 @@ var action = arguments.length > 1 ? arguments[1] : undefined; |
@@ -1,4 +0,4 @@ | ||
export default function stateId() { | ||
export function reduce() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0; | ||
return state + 1; | ||
} |
var nextUniqueId = 0; | ||
export default function getNextUniqueId() { | ||
export function getNextUniqueId() { | ||
return nextUniqueId++; | ||
} |
@@ -1,2 +0,2 @@ | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
@@ -51,3 +51,3 @@ // cheap lodash replacements | ||
var insertItem = function insertItem(item) { | ||
return map.set(item, map.has(item) ? map.get(item) + 1 : 1); | ||
map.set(item, map.has(item) ? map.get(item) + 1 : 1); | ||
}; | ||
@@ -54,0 +54,0 @@ |
@@ -1,2 +0,2 @@ | ||
export default function matchesType(targetType, draggedItemType) { | ||
export function matchesType(targetType, draggedItemType) { | ||
if (draggedItemType === null) { | ||
@@ -3,0 +3,0 @@ return targetType === null; |
@@ -1,2 +0,2 @@ | ||
import { Action, DragDropManager, BeginDragPayload, BeginDragOptions } from '../../interfaces'; | ||
export default function createBeginDrag(manager: DragDropManager): (sourceIds?: string[], options?: BeginDragOptions) => Action<BeginDragPayload> | undefined; | ||
import { Action, DragDropManager, BeginDragPayload, BeginDragOptions, Identifier } from '../../interfaces'; | ||
export declare function createBeginDrag(manager: DragDropManager): (sourceIds?: Identifier[], options?: BeginDragOptions) => Action<BeginDragPayload> | undefined; |
@@ -12,3 +12,3 @@ import { invariant } from '@react-dnd/invariant'; | ||
}; | ||
export default function createBeginDrag(manager) { | ||
export function createBeginDrag(manager) { | ||
return function beginDrag(sourceIds = [], options = { | ||
@@ -32,2 +32,5 @@ publishSource: true, | ||
if (clientOffset) { | ||
if (!getSourceClientOffset) { | ||
throw new Error('getSourceClientOffset must be defined'); | ||
} | ||
verifyGetSourceClientOffsetIsFunction(getSourceClientOffset); | ||
@@ -34,0 +37,0 @@ sourceClientOffset = getSourceClientOffset(sourceId); |
import { DragDropManager } from '../../interfaces'; | ||
export default function createDrop(manager: DragDropManager): (options?: {}) => void; | ||
export declare function createDrop(manager: DragDropManager): (options?: {}) => void; |
import { invariant } from '@react-dnd/invariant'; | ||
import { DROP } from './types'; | ||
import { isObject } from '../../utils/js_utils'; | ||
export default function createDrop(manager) { | ||
export function createDrop(manager) { | ||
return function drop(options = {}) { | ||
@@ -6,0 +6,0 @@ const monitor = manager.getMonitor(); |
import { DragDropManager, SentinelAction } from '../../interfaces'; | ||
export default function createEndDrag(manager: DragDropManager): () => SentinelAction; | ||
export declare function createEndDrag(manager: DragDropManager): () => SentinelAction; |
import { invariant } from '@react-dnd/invariant'; | ||
import { END_DRAG } from './types'; | ||
export default function createEndDrag(manager) { | ||
export function createEndDrag(manager) { | ||
return function endDrag() { | ||
@@ -9,5 +9,7 @@ const monitor = manager.getMonitor(); | ||
const sourceId = monitor.getSourceId(); | ||
const source = registry.getSource(sourceId, true); | ||
source.endDrag(monitor, sourceId); | ||
registry.unpinSource(); | ||
if (sourceId != null) { | ||
const source = registry.getSource(sourceId, true); | ||
source.endDrag(monitor, sourceId); | ||
registry.unpinSource(); | ||
} | ||
return { type: END_DRAG }; | ||
@@ -14,0 +16,0 @@ }; |
import { Action, DragDropManager, HoverPayload, HoverOptions } from '../../interfaces'; | ||
export default function createHover(manager: DragDropManager): (targetIdsArg: string[], { clientOffset }?: HoverOptions) => Action<HoverPayload>; | ||
export declare function createHover(manager: DragDropManager): (targetIdsArg: string[], { clientOffset }?: HoverOptions) => Action<HoverPayload>; |
import { invariant } from '@react-dnd/invariant'; | ||
import matchesType from '../../utils/matchesType'; | ||
import { matchesType } from '../../utils/matchesType'; | ||
import { HOVER } from './types'; | ||
export default function createHover(manager) { | ||
export function createHover(manager) { | ||
return function hover(targetIdsArg, { clientOffset } = {}) { | ||
@@ -6,0 +6,0 @@ verifyTargetIdsIsArray(targetIdsArg); |
@@ -1,9 +0,3 @@ | ||
import { DragDropManager } from '../../interfaces'; | ||
import { DragDropManager, DragDropActions } from '../../interfaces'; | ||
export * from './types'; | ||
export default function createDragDropActions(manager: DragDropManager): { | ||
beginDrag: (sourceIds?: string[], options?: import("../../interfaces").BeginDragOptions) => import("../../interfaces").Action<import("../../interfaces").BeginDragPayload> | undefined; | ||
publishDragSource: () => import("../../interfaces").SentinelAction | undefined; | ||
hover: (targetIdsArg: string[], { clientOffset }?: import("../../interfaces").HoverOptions) => import("../../interfaces").Action<import("../../interfaces").HoverPayload>; | ||
drop: (options?: {}) => void; | ||
endDrag: () => import("../../interfaces").SentinelAction; | ||
}; | ||
export declare function createDragDropActions(manager: DragDropManager): DragDropActions; |
@@ -1,8 +0,8 @@ | ||
import createBeginDrag from './beginDrag'; | ||
import createPublishDragSource from './publishDragSource'; | ||
import createHover from './hover'; | ||
import createDrop from './drop'; | ||
import createEndDrag from './endDrag'; | ||
import { createBeginDrag } from './beginDrag'; | ||
import { createPublishDragSource } from './publishDragSource'; | ||
import { createHover } from './hover'; | ||
import { createDrop } from './drop'; | ||
import { createEndDrag } from './endDrag'; | ||
export * from './types'; | ||
export default function createDragDropActions(manager) { | ||
export function createDragDropActions(manager) { | ||
return { | ||
@@ -9,0 +9,0 @@ beginDrag: createBeginDrag(manager), |
import { XYCoord } from '../../../interfaces'; | ||
export declare function setClientOffset(clientOffset: XYCoord | null | undefined, sourceClientOffset?: XYCoord | null | undefined): { | ||
type: string; | ||
payload: { | ||
sourceClientOffset: XYCoord | null; | ||
clientOffset: XYCoord | null; | ||
}; | ||
}; | ||
import { AnyAction } from 'redux'; | ||
export declare function setClientOffset(clientOffset: XYCoord | null | undefined, sourceClientOffset?: XYCoord | null | undefined): AnyAction; |
import { DragDropManager, SentinelAction } from '../../interfaces'; | ||
export default function createPublishDragSource(manager: DragDropManager): () => SentinelAction | undefined; | ||
export declare function createPublishDragSource(manager: DragDropManager): () => SentinelAction | undefined; |
import { PUBLISH_DRAG_SOURCE } from './types'; | ||
export default function createPublishDragSource(manager) { | ||
export function createPublishDragSource(manager) { | ||
return function publishDragSource() { | ||
@@ -4,0 +4,0 @@ const monitor = manager.getMonitor(); |
@@ -14,3 +14,3 @@ import { invariant } from '@react-dnd/invariant'; | ||
if (allowArray && Array.isArray(type)) { | ||
type.forEach(t => validateType(t, false)); | ||
type.forEach((t) => validateType(t, false)); | ||
return; | ||
@@ -17,0 +17,0 @@ } |
@@ -0,3 +1,4 @@ | ||
import { Action } from 'redux'; | ||
import { Backend, DragDropActions, DragDropMonitor, DragDropManager, HandlerRegistry } from './interfaces'; | ||
export default class DragDropManagerImpl implements DragDropManager { | ||
export declare class DragDropManagerImpl implements DragDropManager { | ||
private store; | ||
@@ -13,4 +14,4 @@ private monitor; | ||
getActions(): DragDropActions; | ||
dispatch(action: any): void; | ||
dispatch(action: Action<any>): void; | ||
private handleRefCountChange; | ||
} |
import { createStore } from 'redux'; | ||
import reducer from './reducers'; | ||
import dragDropActions from './actions/dragDrop'; | ||
import DragDropMonitorImpl from './DragDropMonitorImpl'; | ||
import HandlerRegistryImpl from './HandlerRegistryImpl'; | ||
import { reduce } from './reducers'; | ||
import { createDragDropActions } from './actions/dragDrop'; | ||
import { DragDropMonitorImpl } from './DragDropMonitorImpl'; | ||
import { HandlerRegistryImpl } from './HandlerRegistryImpl'; | ||
function makeStoreInstance(debugMode) { | ||
@@ -11,3 +11,3 @@ // TODO: if we ever make a react-native version of this, | ||
window.__REDUX_DEVTOOLS_EXTENSION__; | ||
return createStore(reducer, debugMode && | ||
return createStore(reduce, debugMode && | ||
reduxDevTools && | ||
@@ -19,3 +19,3 @@ reduxDevTools({ | ||
} | ||
export default class DragDropManagerImpl { | ||
export class DragDropManagerImpl { | ||
constructor(debugMode = false) { | ||
@@ -65,3 +65,3 @@ this.isSetUp = false; | ||
} | ||
const actions = dragDropActions(this); | ||
const actions = createDragDropActions(this); | ||
return Object.keys(actions).reduce((boundActions, key) => { | ||
@@ -68,0 +68,0 @@ const action = actions[key]; |
import { Store } from 'redux'; | ||
import { State } from './reducers'; | ||
import { DragDropMonitor, Listener, Unsubscribe, XYCoord, HandlerRegistry, Identifier } from './interfaces'; | ||
export default class DragDropMonitorImpl implements DragDropMonitor { | ||
export declare class DragDropMonitorImpl implements DragDropMonitor { | ||
private store; | ||
@@ -25,3 +25,3 @@ readonly registry: HandlerRegistry; | ||
didDrop(): boolean; | ||
isSourcePublic(): boolean | null; | ||
isSourcePublic(): boolean; | ||
getInitialClientOffset(): XYCoord | null; | ||
@@ -28,0 +28,0 @@ getInitialSourceClientOffset(): XYCoord | null; |
import { invariant } from '@react-dnd/invariant'; | ||
import matchesType from './utils/matchesType'; | ||
import { matchesType } from './utils/matchesType'; | ||
import { getSourceClientOffset, getDifferenceFromInitialOffset, } from './utils/coords'; | ||
import { areDirty } from './utils/dirtiness'; | ||
export default class DragDropMonitorImpl { | ||
export class DragDropMonitorImpl { | ||
constructor(store, registry) { | ||
@@ -135,3 +135,3 @@ this.store = store; | ||
isSourcePublic() { | ||
return this.store.getState().dragOperation.isSourcePublic; | ||
return Boolean(this.store.getState().dragOperation.isSourcePublic); | ||
} | ||
@@ -138,0 +138,0 @@ getInitialClientOffset() { |
import { DragDropManager, BackendFactory } from './interfaces'; | ||
export declare function createDragDropManager(backendFactory: BackendFactory, globalContext: any, backendOptions: any, debugMode?: boolean): DragDropManager; | ||
export declare function createDragDropManager(backendFactory: BackendFactory, globalContext: unknown, backendOptions: unknown, debugMode?: boolean): DragDropManager; |
@@ -1,2 +0,2 @@ | ||
import DragDropManagerImpl from './DragDropManagerImpl'; | ||
import { DragDropManagerImpl } from './DragDropManagerImpl'; | ||
export function createDragDropManager(backendFactory, globalContext, backendOptions, debugMode) { | ||
@@ -3,0 +3,0 @@ const manager = new DragDropManagerImpl(debugMode); |
import { Store } from 'redux'; | ||
import { State } from './reducers'; | ||
import { DragSource, DropTarget, SourceType, TargetType, Identifier, HandlerRegistry } from './interfaces'; | ||
export default class HandlerRegistryImpl implements HandlerRegistry { | ||
export declare class HandlerRegistryImpl implements HandlerRegistry { | ||
private types; | ||
@@ -6,0 +6,0 @@ private dragSources; |
import { invariant } from '@react-dnd/invariant'; | ||
import { addSource, addTarget, removeSource, removeTarget, } from './actions/registry'; | ||
import getNextUniqueId from './utils/getNextUniqueId'; | ||
import { getNextUniqueId } from './utils/getNextUniqueId'; | ||
import { HandlerRole, } from './interfaces'; | ||
@@ -40,3 +40,3 @@ import { validateSourceContract, validateTargetContract, validateType, } from './contracts'; | ||
} | ||
export default class HandlerRegistryImpl { | ||
export class HandlerRegistryImpl { | ||
constructor(store) { | ||
@@ -43,0 +43,0 @@ this.types = new Map(); |
@@ -20,2 +20,3 @@ export declare type Identifier = string | symbol; | ||
connectDropTarget(targetId: any, node?: any, options?: any): Unsubscribe; | ||
profile(): Record<string, number>; | ||
} | ||
@@ -146,4 +147,4 @@ export interface DragDropMonitor { | ||
export interface DragDropActions { | ||
beginDrag(sourceIds: Identifier[], options?: any): Action<BeginDragPayload>; | ||
publishDragSource(): SentinelAction; | ||
beginDrag(sourceIds?: Identifier[], options?: any): Action<BeginDragPayload> | undefined; | ||
publishDragSource(): SentinelAction | undefined; | ||
hover(targetIds: Identifier[], options?: any): Action<HoverPayload>; | ||
@@ -150,0 +151,0 @@ drop(options?: any): void; |
@@ -7,2 +7,2 @@ import { Action } from '../interfaces'; | ||
} | ||
export default function dirtyHandlerIds(state: State | undefined, action: Action<DirtyHandlerIdPayload>): string[]; | ||
export declare function reduce(_state: State | undefined, action: Action<DirtyHandlerIdPayload>): State; |
@@ -6,3 +6,5 @@ import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP, } from '../actions/dragDrop'; | ||
import { xor } from '../utils/js_utils'; | ||
export default function dirtyHandlerIds(state = NONE, action) { | ||
export function reduce( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_state = NONE, action) { | ||
switch (action.type) { | ||
@@ -9,0 +11,0 @@ case HOVER: |
@@ -7,5 +7,5 @@ import { XYCoord, Action } from '../interfaces'; | ||
} | ||
export default function dragOffset(state: State | undefined, action: Action<{ | ||
export declare function reduce(state: State | undefined, action: Action<{ | ||
sourceClientOffset: XYCoord; | ||
clientOffset: XYCoord; | ||
}>): State; |
@@ -8,3 +8,3 @@ import { INIT_COORDS, BEGIN_DRAG, HOVER, END_DRAG, DROP, } from '../actions/dragDrop'; | ||
}; | ||
export default function dragOffset(state = initialState, action) { | ||
export function reduce(state = initialState, action) { | ||
const { payload } = action; | ||
@@ -11,0 +11,0 @@ switch (action.type) { |
@@ -11,3 +11,3 @@ import { Identifier, Action } from '../interfaces'; | ||
} | ||
export default function dragOperation(state: State | undefined, action: Action<{ | ||
export declare function reduce(state: State | undefined, action: Action<{ | ||
itemType: Identifier | Identifier[]; | ||
@@ -14,0 +14,0 @@ item: any; |
@@ -13,3 +13,3 @@ import { BEGIN_DRAG, PUBLISH_DRAG_SOURCE, HOVER, END_DRAG, DROP, } from '../actions/dragDrop'; | ||
}; | ||
export default function dragOperation(state = initialState, action) { | ||
export function reduce(state = initialState, action) { | ||
const { payload } = action; | ||
@@ -16,0 +16,0 @@ switch (action.type) { |
@@ -6,2 +6,3 @@ import { State as DragOffsetState } from './dragOffset'; | ||
import { State as StateIdState } from './stateId'; | ||
import { Action } from 'interfaces'; | ||
export interface State { | ||
@@ -14,8 +15,2 @@ dirtyHandlerIds: DirtyHandlerIdsState; | ||
} | ||
export default function reduce(state: State | undefined, action: any): { | ||
dirtyHandlerIds: string[]; | ||
dragOffset: DragOffsetState; | ||
refCount: number; | ||
dragOperation: DragOperationState; | ||
stateId: number; | ||
}; | ||
export declare function reduce(state: State | undefined, action: Action<any>): State; |
@@ -1,8 +0,8 @@ | ||
import dragOffset from './dragOffset'; | ||
import dragOperation from './dragOperation'; | ||
import refCount from './refCount'; | ||
import dirtyHandlerIds from './dirtyHandlerIds'; | ||
import stateId from './stateId'; | ||
import { reduce as dragOffset } from './dragOffset'; | ||
import { reduce as dragOperation, } from './dragOperation'; | ||
import { reduce as refCount } from './refCount'; | ||
import { reduce as dirtyHandlerIds, } from './dirtyHandlerIds'; | ||
import { reduce as stateId } from './stateId'; | ||
import { get } from '../utils/js_utils'; | ||
export default function reduce(state = {}, action) { | ||
export function reduce(state = {}, action) { | ||
return { | ||
@@ -9,0 +9,0 @@ dirtyHandlerIds: dirtyHandlerIds(state.dirtyHandlerIds, { |
import { Action } from '../interfaces'; | ||
export declare type State = number; | ||
export default function refCount(state: number | undefined, action: Action<any>): number; | ||
export declare function reduce(state: number | undefined, action: Action<any>): State; |
import { ADD_SOURCE, ADD_TARGET, REMOVE_SOURCE, REMOVE_TARGET, } from '../actions/registry'; | ||
export default function refCount(state = 0, action) { | ||
export function reduce(state = 0, action) { | ||
switch (action.type) { | ||
@@ -4,0 +4,0 @@ case ADD_SOURCE: |
export declare type State = number; | ||
export default function stateId(state?: State): number; | ||
export declare function reduce(state?: State): State; |
@@ -1,3 +0,3 @@ | ||
export default function stateId(state = 0) { | ||
export function reduce(state = 0) { | ||
return state + 1; | ||
} |
@@ -1,1 +0,1 @@ | ||
export default function getNextUniqueId(): number; | ||
export declare function getNextUniqueId(): number; |
let nextUniqueId = 0; | ||
export default function getNextUniqueId() { | ||
export function getNextUniqueId() { | ||
return nextUniqueId++; | ||
} |
@@ -17,3 +17,3 @@ // cheap lodash replacements | ||
export function without(items, item) { | ||
return items.filter(i => i !== item); | ||
return items.filter((i) => i !== item); | ||
} | ||
@@ -41,3 +41,5 @@ /** | ||
const map = new Map(); | ||
const insertItem = (item) => map.set(item, map.has(item) ? map.get(item) + 1 : 1); | ||
const insertItem = (item) => { | ||
map.set(item, map.has(item) ? map.get(item) + 1 : 1); | ||
}; | ||
itemsA.forEach(insertItem); | ||
@@ -59,3 +61,3 @@ itemsB.forEach(insertItem); | ||
export function intersection(itemsA, itemsB) { | ||
return itemsA.filter(t => itemsB.indexOf(t) > -1); | ||
return itemsA.filter((t) => itemsB.indexOf(t) > -1); | ||
} |
import { Identifier } from '../interfaces'; | ||
export default function matchesType(targetType: Identifier | Identifier[] | null, draggedItemType: Identifier | null): boolean; | ||
export declare function matchesType(targetType: Identifier | Identifier[] | null, draggedItemType: Identifier | null): boolean; |
@@ -1,2 +0,2 @@ | ||
export default function matchesType(targetType, draggedItemType) { | ||
export function matchesType(targetType, draggedItemType) { | ||
if (draggedItemType === null) { | ||
@@ -6,4 +6,4 @@ return targetType === null; | ||
return Array.isArray(targetType) | ||
? targetType.some(t => t === draggedItemType) | ||
? targetType.some((t) => t === draggedItemType) | ||
: targetType === draggedItemType; | ||
} |
{ | ||
"name": "dnd-core", | ||
"version": "10.0.2", | ||
"version": "11.0.0", | ||
"description": "Drag and drop sans the GUI", | ||
@@ -24,3 +24,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "5d16ab043eb83d49c5b6964ce276d0a6c15210d5" | ||
"gitHead": "418cb25315323efd6c0b9e23ccc28c5607d86edb" | ||
} |
Sorry, the diff of this file is not supported yet
390933
3925