UNPKG

react-sortable-hoc-rtl

Version:

Set of higher-order components to turn any list into a sortable, touch-friendly, animated list

1,619 lines (1,290 loc) 170 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(require("react"), require("react-dom")); else if(typeof define === 'function' && define.amd) define(["react", "react-dom"], factory); else if(typeof exports === 'object') exports["SortableHOC"] = factory(require("react"), require("react-dom")); else root["SortableHOC"] = factory(root["React"], root["ReactDOM"]); })(this, function(__WEBPACK_EXTERNAL_MODULE_133__, __WEBPACK_EXTERNAL_MODULE_140__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { module.exports = __webpack_require__(1); /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayMove = exports.sortableHandle = exports.sortableElement = exports.sortableContainer = exports.SortableHandle = exports.SortableElement = exports.SortableContainer = undefined; var _utils = __webpack_require__(2); Object.defineProperty(exports, 'arrayMove', { enumerable: true, get: function get() { return _utils.arrayMove; } }); var _SortableContainer2 = __webpack_require__(41); var _SortableContainer3 = _interopRequireDefault(_SortableContainer2); var _SortableElement2 = __webpack_require__(142); var _SortableElement3 = _interopRequireDefault(_SortableElement2); var _SortableHandle2 = __webpack_require__(143); var _SortableHandle3 = _interopRequireDefault(_SortableHandle2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } exports.SortableContainer = _SortableContainer3.default; exports.SortableElement = _SortableElement3.default; exports.SortableHandle = _SortableHandle3.default; exports.sortableContainer = _SortableContainer3.default; exports.sortableElement = _SortableElement3.default; exports.sortableHandle = _SortableHandle3.default; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.vendorPrefix = exports.events = undefined; var _keys = __webpack_require__(3); var _keys2 = _interopRequireDefault(_keys); exports.arrayMove = arrayMove; exports.omit = omit; exports.closest = closest; exports.limit = limit; exports.getElementMargin = getElementMargin; exports.provideDisplayName = provideDisplayName; exports.getPosition = getPosition; exports.isTouchEvent = isTouchEvent; exports.getEdgeOffset = getEdgeOffset; exports.getLockPixelOffset = getLockPixelOffset; var _invariant = __webpack_require__(39); var _invariant2 = _interopRequireDefault(_invariant); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function arrayMove(arr, previousIndex, newIndex) { var array = arr.slice(0); if (newIndex >= array.length) { var k = newIndex - array.length; while (k-- + 1) { array.push(undefined); } } array.splice(newIndex, 0, array.splice(previousIndex, 1)[0]); return array; } function omit(obj) { for (var _len = arguments.length, keysToOmit = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { keysToOmit[_key - 1] = arguments[_key]; } return (0, _keys2.default)(obj).reduce(function (acc, key) { if (keysToOmit.indexOf(key) === -1) acc[key] = obj[key]; return acc; }, {}); } var events = exports.events = { start: ['touchstart', 'mousedown'], move: ['touchmove', 'mousemove'], end: ['touchend', 'touchcancel', 'mouseup'] }; var vendorPrefix = exports.vendorPrefix = function () { if (typeof window === 'undefined' || typeof document === 'undefined') return ''; // server environment // fix for: // https://bugzilla.mozilla.org/show_bug.cgi?id=548397 // window.getComputedStyle() returns null inside an iframe with display: none // in this case return an array with a fake mozilla style in it. var styles = window.getComputedStyle(document.documentElement, '') || ['-moz-hidden-iframe']; var pre = (Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/) || styles.OLink === '' && ['', 'o'])[1]; switch (pre) { case 'ms': return 'ms'; default: return pre && pre.length ? pre[0].toUpperCase() + pre.substr(1) : ''; } }(); function closest(el, fn) { while (el) { if (fn(el)) return el; el = el.parentNode; } } function limit(min, max, value) { if (value < min) { return min; } if (value > max) { return max; } return value; } function getCSSPixelValue(stringValue) { if (stringValue.substr(-2) === 'px') { return parseFloat(stringValue); } return 0; } function getElementMargin(element) { var style = window.getComputedStyle(element); return { top: getCSSPixelValue(style.marginTop), right: getCSSPixelValue(style.marginRight), bottom: getCSSPixelValue(style.marginBottom), left: getCSSPixelValue(style.marginLeft) }; } function provideDisplayName(prefix, Component) { var componentName = Component.displayName || Component.name; return componentName ? prefix + '(' + componentName + ')' : prefix; } function getPosition(event) { if (event.touches && event.touches.length) { return { x: event.touches[0].pageX, y: event.touches[0].pageY }; } else if (event.changedTouches && event.changedTouches.length) { return { x: event.changedTouches[0].pageX, y: event.changedTouches[0].pageY }; } else { return { x: event.pageX, y: event.pageY }; } } function isTouchEvent(event) { return event.touches && event.touches.length || event.changedTouches && event.changedTouches.length; } function getEdgeOffset(node, parent) { var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : { top: 0, left: 0 }; // Get the actual offsetTop / offsetLeft value, no matter how deep the node is nested if (node) { var nodeOffset = { top: offset.top + node.offsetTop, left: offset.left + node.offsetLeft }; if (node.parentNode !== parent) { return getEdgeOffset(node.parentNode, parent, nodeOffset); } else { return nodeOffset; } } } function getLockPixelOffset(_ref) { var lockOffset = _ref.lockOffset, width = _ref.width, height = _ref.height; var offsetX = lockOffset; var offsetY = lockOffset; var unit = 'px'; if (typeof lockOffset === 'string') { var match = /^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(lockOffset); (0, _invariant2.default)(match !== null, 'lockOffset value should be a number or a string of a ' + 'number followed by "px" or "%". Given %s', lockOffset); offsetX = offsetY = parseFloat(lockOffset); unit = match[1]; } (0, _invariant2.default)(isFinite(offsetX) && isFinite(offsetY), 'lockOffset value should be a finite. Given %s', lockOffset); if (unit === '%') { offsetX = offsetX * width / 100; offsetY = offsetY * height / 100; } return { x: offsetX, y: offsetY }; } /***/ }), /* 3 */ /***/ (function(module, exports, __webpack_require__) { module.exports = { "default": __webpack_require__(4), __esModule: true }; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { __webpack_require__(5); module.exports = __webpack_require__(20).Object.keys; /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { // 19.1.2.14 Object.keys(O) var toObject = __webpack_require__(6); var $keys = __webpack_require__(8); __webpack_require__(25)('keys', function () { return function keys(it) { return $keys(toObject(it)); }; }); /***/ }), /* 6 */ /***/ (function(module, exports, __webpack_require__) { // 7.1.13 ToObject(argument) var defined = __webpack_require__(7); module.exports = function (it) { return Object(defined(it)); }; /***/ }), /* 7 */ /***/ (function(module, exports) { // 7.2.1 RequireObjectCoercible(argument) module.exports = function (it) { if (it == undefined) throw TypeError("Can't call method on " + it); return it; }; /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { // 19.1.2.14 / 15.2.3.14 Object.keys(O) var $keys = __webpack_require__(9); var enumBugKeys = __webpack_require__(24); module.exports = Object.keys || function keys(O) { return $keys(O, enumBugKeys); }; /***/ }), /* 9 */ /***/ (function(module, exports, __webpack_require__) { var has = __webpack_require__(10); var toIObject = __webpack_require__(11); var arrayIndexOf = __webpack_require__(14)(false); var IE_PROTO = __webpack_require__(18)('IE_PROTO'); module.exports = function (object, names) { var O = toIObject(object); var i = 0; var result = []; var key; for (key in O) if (key != IE_PROTO) has(O, key) && result.push(key); // Don't enum bug & hidden keys while (names.length > i) if (has(O, key = names[i++])) { ~arrayIndexOf(result, key) || result.push(key); } return result; }; /***/ }), /* 10 */ /***/ (function(module, exports) { var hasOwnProperty = {}.hasOwnProperty; module.exports = function (it, key) { return hasOwnProperty.call(it, key); }; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { // to indexed object, toObject with fallback for non-array-like ES3 strings var IObject = __webpack_require__(12); var defined = __webpack_require__(7); module.exports = function (it) { return IObject(defined(it)); }; /***/ }), /* 12 */ /***/ (function(module, exports, __webpack_require__) { // fallback for non-array-like ES3 and non-enumerable old V8 strings var cof = __webpack_require__(13); // eslint-disable-next-line no-prototype-builtins module.exports = Object('z').propertyIsEnumerable(0) ? Object : function (it) { return cof(it) == 'String' ? it.split('') : Object(it); }; /***/ }), /* 13 */ /***/ (function(module, exports) { var toString = {}.toString; module.exports = function (it) { return toString.call(it).slice(8, -1); }; /***/ }), /* 14 */ /***/ (function(module, exports, __webpack_require__) { // false -> Array#indexOf // true -> Array#includes var toIObject = __webpack_require__(11); var toLength = __webpack_require__(15); var toAbsoluteIndex = __webpack_require__(17); module.exports = function (IS_INCLUDES) { return function ($this, el, fromIndex) { var O = toIObject($this); var length = toLength(O.length); var index = toAbsoluteIndex(fromIndex, length); var value; // Array#includes uses SameValueZero equality algorithm // eslint-disable-next-line no-self-compare if (IS_INCLUDES && el != el) while (length > index) { value = O[index++]; // eslint-disable-next-line no-self-compare if (value != value) return true; // Array#indexOf ignores holes, Array#includes - not } else for (;length > index; index++) if (IS_INCLUDES || index in O) { if (O[index] === el) return IS_INCLUDES || index || 0; } return !IS_INCLUDES && -1; }; }; /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { // 7.1.15 ToLength var toInteger = __webpack_require__(16); var min = Math.min; module.exports = function (it) { return it > 0 ? min(toInteger(it), 0x1fffffffffffff) : 0; // pow(2, 53) - 1 == 9007199254740991 }; /***/ }), /* 16 */ /***/ (function(module, exports) { // 7.1.4 ToInteger var ceil = Math.ceil; var floor = Math.floor; module.exports = function (it) { return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it); }; /***/ }), /* 17 */ /***/ (function(module, exports, __webpack_require__) { var toInteger = __webpack_require__(16); var max = Math.max; var min = Math.min; module.exports = function (index, length) { index = toInteger(index); return index < 0 ? max(index + length, 0) : min(index, length); }; /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { var shared = __webpack_require__(19)('keys'); var uid = __webpack_require__(23); module.exports = function (key) { return shared[key] || (shared[key] = uid(key)); }; /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { var core = __webpack_require__(20); var global = __webpack_require__(21); var SHARED = '__core-js_shared__'; var store = global[SHARED] || (global[SHARED] = {}); (module.exports = function (key, value) { return store[key] || (store[key] = value !== undefined ? value : {}); })('versions', []).push({ version: core.version, mode: __webpack_require__(22) ? 'pure' : 'global', copyright: '© 2018 Denis Pushkarev (zloirock.ru)' }); /***/ }), /* 20 */ /***/ (function(module, exports) { var core = module.exports = { version: '2.6.1' }; if (typeof __e == 'number') __e = core; // eslint-disable-line no-undef /***/ }), /* 21 */ /***/ (function(module, exports) { // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 var global = module.exports = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self // eslint-disable-next-line no-new-func : Function('return this')(); if (typeof __g == 'number') __g = global; // eslint-disable-line no-undef /***/ }), /* 22 */ /***/ (function(module, exports) { module.exports = true; /***/ }), /* 23 */ /***/ (function(module, exports) { var id = 0; var px = Math.random(); module.exports = function (key) { return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36)); }; /***/ }), /* 24 */ /***/ (function(module, exports) { // IE 8- don't enum bug keys module.exports = ( 'constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf' ).split(','); /***/ }), /* 25 */ /***/ (function(module, exports, __webpack_require__) { // most Object methods by ES6 should accept primitives var $export = __webpack_require__(26); var core = __webpack_require__(20); var fails = __webpack_require__(35); module.exports = function (KEY, exec) { var fn = (core.Object || {})[KEY] || Object[KEY]; var exp = {}; exp[KEY] = exec(fn); $export($export.S + $export.F * fails(function () { fn(1); }), 'Object', exp); }; /***/ }), /* 26 */ /***/ (function(module, exports, __webpack_require__) { var global = __webpack_require__(21); var core = __webpack_require__(20); var ctx = __webpack_require__(27); var hide = __webpack_require__(29); var has = __webpack_require__(10); var PROTOTYPE = 'prototype'; var $export = function (type, name, source) { var IS_FORCED = type & $export.F; var IS_GLOBAL = type & $export.G; var IS_STATIC = type & $export.S; var IS_PROTO = type & $export.P; var IS_BIND = type & $export.B; var IS_WRAP = type & $export.W; var exports = IS_GLOBAL ? core : core[name] || (core[name] = {}); var expProto = exports[PROTOTYPE]; var target = IS_GLOBAL ? global : IS_STATIC ? global[name] : (global[name] || {})[PROTOTYPE]; var key, own, out; if (IS_GLOBAL) source = name; for (key in source) { // contains in native own = !IS_FORCED && target && target[key] !== undefined; if (own && has(exports, key)) continue; // export native or passed out = own ? target[key] : source[key]; // prevent global pollution for namespaces exports[key] = IS_GLOBAL && typeof target[key] != 'function' ? source[key] // bind timers to global for call from export context : IS_BIND && own ? ctx(out, global) // wrap global constructors for prevent change them in library : IS_WRAP && target[key] == out ? (function (C) { var F = function (a, b, c) { if (this instanceof C) { switch (arguments.length) { case 0: return new C(); case 1: return new C(a); case 2: return new C(a, b); } return new C(a, b, c); } return C.apply(this, arguments); }; F[PROTOTYPE] = C[PROTOTYPE]; return F; // make static versions for prototype methods })(out) : IS_PROTO && typeof out == 'function' ? ctx(Function.call, out) : out; // export proto methods to core.%CONSTRUCTOR%.methods.%NAME% if (IS_PROTO) { (exports.virtual || (exports.virtual = {}))[key] = out; // export proto methods to core.%CONSTRUCTOR%.prototype.%NAME% if (type & $export.R && expProto && !expProto[key]) hide(expProto, key, out); } } }; // type bitmap $export.F = 1; // forced $export.G = 2; // global $export.S = 4; // static $export.P = 8; // proto $export.B = 16; // bind $export.W = 32; // wrap $export.U = 64; // safe $export.R = 128; // real proto method for `library` module.exports = $export; /***/ }), /* 27 */ /***/ (function(module, exports, __webpack_require__) { // optional / simple context binding var aFunction = __webpack_require__(28); module.exports = function (fn, that, length) { aFunction(fn); if (that === undefined) return fn; switch (length) { case 1: return function (a) { return fn.call(that, a); }; case 2: return function (a, b) { return fn.call(that, a, b); }; case 3: return function (a, b, c) { return fn.call(that, a, b, c); }; } return function (/* ...args */) { return fn.apply(that, arguments); }; }; /***/ }), /* 28 */ /***/ (function(module, exports) { module.exports = function (it) { if (typeof it != 'function') throw TypeError(it + ' is not a function!'); return it; }; /***/ }), /* 29 */ /***/ (function(module, exports, __webpack_require__) { var dP = __webpack_require__(30); var createDesc = __webpack_require__(38); module.exports = __webpack_require__(34) ? function (object, key, value) { return dP.f(object, key, createDesc(1, value)); } : function (object, key, value) { object[key] = value; return object; }; /***/ }), /* 30 */ /***/ (function(module, exports, __webpack_require__) { var anObject = __webpack_require__(31); var IE8_DOM_DEFINE = __webpack_require__(33); var toPrimitive = __webpack_require__(37); var dP = Object.defineProperty; exports.f = __webpack_require__(34) ? Object.defineProperty : function defineProperty(O, P, Attributes) { anObject(O); P = toPrimitive(P, true); anObject(Attributes); if (IE8_DOM_DEFINE) try { return dP(O, P, Attributes); } catch (e) { /* empty */ } if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported!'); if ('value' in Attributes) O[P] = Attributes.value; return O; }; /***/ }), /* 31 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(32); module.exports = function (it) { if (!isObject(it)) throw TypeError(it + ' is not an object!'); return it; }; /***/ }), /* 32 */ /***/ (function(module, exports) { module.exports = function (it) { return typeof it === 'object' ? it !== null : typeof it === 'function'; }; /***/ }), /* 33 */ /***/ (function(module, exports, __webpack_require__) { module.exports = !__webpack_require__(34) && !__webpack_require__(35)(function () { return Object.defineProperty(__webpack_require__(36)('div'), 'a', { get: function () { return 7; } }).a != 7; }); /***/ }), /* 34 */ /***/ (function(module, exports, __webpack_require__) { // Thank's IE8 for his funny defineProperty module.exports = !__webpack_require__(35)(function () { return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7; }); /***/ }), /* 35 */ /***/ (function(module, exports) { module.exports = function (exec) { try { return !!exec(); } catch (e) { return true; } }; /***/ }), /* 36 */ /***/ (function(module, exports, __webpack_require__) { var isObject = __webpack_require__(32); var document = __webpack_require__(21).document; // typeof document.createElement is 'object' in old IE var is = isObject(document) && isObject(document.createElement); module.exports = function (it) { return is ? document.createElement(it) : {}; }; /***/ }), /* 37 */ /***/ (function(module, exports, __webpack_require__) { // 7.1.1 ToPrimitive(input [, PreferredType]) var isObject = __webpack_require__(32); // instead of the ES6 spec version, we didn't implement @@toPrimitive case // and the second argument - flag - preferred type is a string module.exports = function (it, S) { if (!isObject(it)) return it; var fn, val; if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; throw TypeError("Can't convert object to primitive value"); }; /***/ }), /* 38 */ /***/ (function(module, exports) { module.exports = function (bitmap, value) { return { enumerable: !(bitmap & 1), configurable: !(bitmap & 2), writable: !(bitmap & 4), value: value }; }; /***/ }), /* 39 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ 'use strict'; /** * Use invariant() to assert state which your program assumes to be true. * * Provide sprintf-style format (only %s is supported) and arguments * to provide information about what broke and what you were * expecting. * * The invariant message will be stripped in production, but the invariant * will remain to ensure logic does not differ in production. */ var invariant = function(condition, format, a, b, c, d, e, f) { if (process.env.NODE_ENV !== 'production') { if (format === undefined) { throw new Error('invariant requires an error message argument'); } } if (!condition) { var error; if (format === undefined) { error = new Error( 'Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.' ); } else { var args = [a, b, c, d, e, f]; var argIndex = 0; error = new Error( format.replace(/%s/g, function() { return args[argIndex++]; }) ); error.name = 'Invariant Violation'; } error.framesToPop = 1; // we don't care about invariant's own frame throw error; } }; module.exports = invariant; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(40))) /***/ }), /* 40 */ /***/ (function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /* 41 */ /***/ (function(module, exports, __webpack_require__) { 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends2 = __webpack_require__(42); var _extends3 = _interopRequireDefault(_extends2); var _slicedToArray2 = __webpack_require__(49); var _slicedToArray3 = _interopRequireDefault(_slicedToArray2); var _promise = __webpack_require__(74); var _promise2 = _interopRequireDefault(_promise); var _toConsumableArray2 = __webpack_require__(95); var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2); var _getPrototypeOf = __webpack_require__(100); var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); var _classCallCheck2 = __webpack_require__(103); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = __webpack_require__(104); var _createClass3 = _interopRequireDefault(_createClass2); var _possibleConstructorReturn2 = __webpack_require__(108); var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); var _inherits2 = __webpack_require__(125); var _inherits3 = _interopRequireDefault(_inherits2); exports.default = sortableContainer; var _react = __webpack_require__(133); var _react2 = _interopRequireDefault(_react); var _propTypes = __webpack_require__(134); var _propTypes2 = _interopRequireDefault(_propTypes); var _reactDom = __webpack_require__(140); var _invariant = __webpack_require__(39); var _invariant2 = _interopRequireDefault(_invariant); var _Manager = __webpack_require__(141); var _Manager2 = _interopRequireDefault(_Manager); var _utils = __webpack_require__(2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } // Export Higher Order Sortable Container Component function sortableContainer(WrappedComponent) { var _class, _temp; var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { withRef: false }; return _temp = _class = function (_Component) { (0, _inherits3.default)(_class, _Component); function _class(props) { (0, _classCallCheck3.default)(this, _class); var _this = (0, _possibleConstructorReturn3.default)(this, (_class.__proto__ || (0, _getPrototypeOf2.default)(_class)).call(this, props)); _this.handleStart = function (event) { var _this$props = _this.props, distance = _this$props.distance, shouldCancelStart = _this$props.shouldCancelStart; if (event.button === 2 || shouldCancelStart(event)) { return false; } _this._touched = true; _this._pos = (0, _utils.getPosition)(event); var node = (0, _utils.closest)(event.target, function (el) { return el.sortableInfo != null; }); if (node && node.sortableInfo && _this.nodeIsChild(node) && !_this.state.sorting) { var useDragHandle = _this.props.useDragHandle; var _node$sortableInfo = node.sortableInfo, index = _node$sortableInfo.index, collection = _node$sortableInfo.collection; if (useDragHandle && !(0, _utils.closest)(event.target, function (el) { return el.sortableHandle != null; })) return; _this.manager.active = { index: index, collection: collection }; /* * Fixes a bug in Firefox where the :active state of anchor tags * prevent subsequent 'mousemove' events from being fired * (see https://github.com/clauderic/react-sortable-hoc/issues/118) */ if (!(0, _utils.isTouchEvent)(event) && event.target.tagName.toLowerCase() === 'a') { event.preventDefault(); } if (!distance) { if (_this.props.pressDelay === 0) { _this.handlePress(event); } else { _this.pressTimer = setTimeout(function () { return _this.handlePress(event); }, _this.props.pressDelay); } } } }; _this.nodeIsChild = function (node) { return node.sortableInfo.manager === _this.manager; }; _this.handleMove = function (event) { var _this$props2 = _this.props, distance = _this$props2.distance, pressThreshold = _this$props2.pressThreshold; if (!_this.state.sorting && _this._touched) { var position = (0, _utils.getPosition)(event); var delta = _this._delta = { x: _this._pos.x - position.x, y: _this._pos.y - position.y }; var combinedDelta = Math.abs(delta.x) + Math.abs(delta.y); if (!distance && (!pressThreshold || pressThreshold && combinedDelta >= pressThreshold)) { clearTimeout(_this.cancelTimer); _this.cancelTimer = setTimeout(_this.cancel, 0); } else if (distance && combinedDelta >= distance && _this.manager.isActive()) { _this.handlePress(event); } } }; _this.handleEnd = function () { _this._touched = false; _this.cancel(); }; _this.cancel = function () { var distance = _this.props.distance; var sorting = _this.state.sorting; if (!sorting) { if (!distance) { clearTimeout(_this.pressTimer); } _this.manager.active = null; } }; _this.handlePress = function (event) { var active = _this.manager.getActive(); if (active) { var _this$props3 = _this.props, axis = _this$props3.axis, getHelperDimensions = _this$props3.getHelperDimensions, helperClass = _this$props3.helperClass, hideSortableGhost = _this$props3.hideSortableGhost, onSortStart = _this$props3.onSortStart, useWindowAsScrollContainer = _this$props3.useWindowAsScrollContainer; var node = active.node, collection = active.collection; var index = node.sortableInfo.index; var margin = (0, _utils.getElementMargin)(node); var containerBoundingRect = _this.container.getBoundingClientRect(); var dimensions = getHelperDimensions({ index: index, node: node, collection: collection }); _this.node = node; _this.margin = margin; _this.width = dimensions.width; _this.height = dimensions.height; _this.marginOffset = { x: _this.margin.left + _this.margin.right, y: Math.max(_this.margin.top, _this.margin.bottom) }; _this.boundingClientRect = node.getBoundingClientRect(); _this.containerBoundingRect = containerBoundingRect; _this.index = index; _this.newIndex = index; _this.axis = { x: axis.indexOf('x') >= 0, y: axis.indexOf('y') >= 0 }; _this.offsetEdge = (0, _utils.getEdgeOffset)(node, _this.container); _this.initialOffset = (0, _utils.getPosition)(event); _this.initialScroll = { top: _this.container.scrollTop, left: _this.container.scrollLeft }; _this.initialWindowScroll = { top: window.pageYOffset, left: window.pageXOffset }; var fields = node.querySelectorAll('input, textarea, select'); var clonedNode = node.cloneNode(true); var clonedFields = [].concat((0, _toConsumableArray3.default)(clonedNode.querySelectorAll('input, textarea, select'))); // Convert NodeList to Array clonedFields.forEach(function (field, index) { if (field.type !== 'file' && fields[index]) { field.value = fields[index].value; } }); _this.helper = _this.document.body.appendChild(clonedNode); _this.helper.style.position = 'fixed'; _this.helper.style.top = _this.boundingClientRect.top - margin.top + 'px'; _this.helper.style.left = _this.boundingClientRect.left - margin.left + 'px'; _this.helper.style.width = _this.width + 'px'; _this.helper.style.height = _this.height + 'px'; _this.helper.style.boxSizing = 'border-box'; _this.helper.style.pointerEvents = 'none'; if (hideSortableGhost) { _this.sortableGhost = node; node.style.visibility = 'hidden'; node.style.opacity = 0; } _this.minTranslate = {}; _this.maxTranslate = {}; if (_this.axis.x) { _this.minTranslate.x = (useWindowAsScrollContainer ? 0 : containerBoundingRect.left) - _this.boundingClientRect.left - _this.width / 2; _this.maxTranslate.x = (useWindowAsScrollContainer ? _this.contentWindow.innerWidth : containerBoundingRect.left + containerBoundingRect.width) - _this.boundingClientRect.left - _this.width / 2; } if (_this.axis.y) { _this.minTranslate.y = (useWindowAsScrollContainer ? 0 : containerBoundingRect.top) - _this.boundingClientRect.top - _this.height / 2; _this.maxTranslate.y = (useWindowAsScrollContainer ? _this.contentWindow.innerHeight : containerBoundingRect.top + containerBoundingRect.height) - _this.boundingClientRect.top - _this.height / 2; } if (helperClass) { var _this$helper$classLis; (_this$helper$classLis = _this.helper.classList).add.apply(_this$helper$classLis, (0, _toConsumableArray3.default)(helperClass.split(' '))); } _this.listenerNode = event.touches ? node : _this.contentWindow; _utils.events.move.forEach(function (eventName) { return _this.listenerNode.addEventListener(eventName, _this.handleSortMove, false); }); _utils.events.end.forEach(function (eventName) { return _this.listenerNode.addEventListener(eventName, _this.handleSortEnd, false); }); _this.setState({ sorting: true, sortingIndex: index }); if (onSortStart) { onSortStart({ node: node, index: index, collection: collection }, event); } } }; _this.handleSortMove = function (event) { var onSortMove = _this.props.onSortMove; event.preventDefault(); // Prevent scrolling on mobile _this.updatePosition(event); _this.animateNodes(); _this.autoscroll(); if (onSortMove) { onSortMove(event); } }; _this.handleSortEnd = function (event) { var _this$props4 = _this.props, hideSortableGhost = _this$props4.hideSortableGhost, onSortEnd = _this$props4.onSortEnd; var collection = _this.manager.active.collection; // Remove the event listeners if the node is still in the DOM if (_this.listenerNode) { _utils.events.move.forEach(function (eventName) { return _this.listenerNode.removeEventListener(eventName, _this.handleSortMove); }); _utils.events.end.forEach(function (eventName) { return _this.listenerNode.removeEventListener(eventName, _this.handleSortEnd); }); } // Remove the helper from the DOM _this.helper.parentNode.removeChild(_this.helper); if (hideSortableGhost && _this.sortableGhost) { _this.sortableGhost.style.visibility = ''; _this.sortableGhost.style.opacity = ''; } var nodes = _this.manager.refs[collection]; for (var i = 0, len = nodes.length; i < len; i++) { var node = nodes[i]; var el = node.node; // Clear the cached offsetTop / offsetLeft value node.edgeOffset = null; // Remove the transforms / transitions el.style[_utils.vendorPrefix + 'Transform'] = ''; el.style[_utils.vendorPrefix + 'TransitionDuration'] = ''; } // Stop autoscroll clearInterval(_this.autoscrollInterval); _this.autoscrollInterval = null; // Update state _this.manager.active = null; _this.setState({ sorting: false, sortingIndex: null }); if (typeof onSortEnd === 'function') { onSortEnd({ oldIndex: _this.index, newIndex: _this.newIndex, collection: collection }, event); } _this._touched = false; }; _this.autoscroll = function () { var translate = _this.translate; var direction = { x: 0, y: 0 }; var speed = { x: 1, y: 1 }; var acceleration = { x: 10, y: 10 }; if (translate.y >= _this.maxTranslate.y - _this.height / 2) { direction.y = 1; // Scroll Down speed.y = acceleration.y * Math.abs((_this.maxTranslate.y - _this.height / 2 - translate.y) / _this.height); } else if (translate.x >= _this.maxTranslate.x - _this.width / 2) { direction.x = 1; // Scroll Right speed.x = acceleration.x * Math.abs((_this.maxTranslate.x - _this.width / 2 - translate.x) / _this.width); } else if (translate.y <= _this.minTranslate.y + _this.height / 2) { direction.y = -1; // Scroll Up speed.y = acceleration.y * Math.abs((translate.y - _this.height / 2 - _this.minTranslate.y) / _this.height); } else if (translate.x <= _this.minTranslate.x + _this.width / 2) { direction.x = -1; // Scroll Left speed.x = acceleration.x * Math.abs((translate.x - _this.width / 2 - _this.minTranslate.x) / _this.width); } if (_this.autoscrollInterval) { clearInterval(_this.autoscrollInterval); _this.autoscrollInterval = null; _this.isAutoScrolling = false; } if (direction.x !== 0 || direction.y !== 0) { _this.autoscrollInterval = setInterval(function () { _this.isAutoScrolling = true; var offset = { left: 1 * speed.x * direction.x, top: 1 * speed.y * direction.y }; _this.scrollContainer.scrollTop += offset.top; _this.scrollContainer.scrollLeft += offset.left; _this.translate.x += offset.left; _this.translate.y += offset.top; _this.animateNodes(); }, 5); } }; _this.manager = new _Manager2.default(); _this.events = { start: _this.handleStart, move: _this.handleMove, end: _this.handleEnd }; (0, _invariant2.default)(!(props.distance && props.pressDelay), 'Attempted to set both `pressDelay` and `distance` on SortableContainer, you may only use one or the other, not both at the same time.'); _this.state = {}; return _this; } (0, _createClass3.default)(_class, [{ key: 'getChildContext', value: function getChildContext() { return { manager: this.manager }; } }, { key: 'componentDidMount', value: function componentDidMount() { var _this2 = this; var useWindowAsScrollContainer = this.props.useWindowAsScrollContainer; /* * Set our own default rather than using defaultProps because Jest * snapshots will serialize window, causing a RangeError * https://github.com/clauderic/react-sortable-hoc/issues/249 */ var container = this.getContainer(); _promise2.default.resolve(container).then(function (containerNode) { _this2.container = containerNode; _this2.document = _this2.container.ownerDocument || document; var contentWindow = _this2.props.contentWindow || _this2.document.defaultView || window; _this2.contentWindow = typeof contentWindow === 'function' ? contentWindow() : contentWindow; _this2.scrollContainer = useWindowAsScrollContainer ? _this2.document.scrollingElement || _this2.document.documentElement : _this2.container; var _loop = function _loop(key) { if (_this2.events.hasOwnProperty(key)) { _utils.events[key].forEach(function (eventName) { return _this2.container.addEventListener(eventName, _this2.events[key], false); }); } }; for (var key in _this2.events) { _loop(key); } }); } }, { key: 'componentWillUnmount', value: function componentWillUnmount() { var _this3 = this; if (this.container) { var _loop2 = function _loop2(key) { if (_this3.events.hasOwnProperty(key)) { _utils.events[key].forEach(function (eventName) { return _this3.container.removeEventListener(eventName, _this3.events[key]); }); } }; for (var key in this.events) { _loop2(key); } } } }, { key: 'getLockPixelOffsets', value: function getLockPixelOffsets() { var width = this.width, height = this.height; var lockOffset = this.props.lockOffset; var offsets = Array.isArray(lockOffset) ? lockOffset : [lockOffset, lockOffset]; (0, _invariant2.default)(offsets.length === 2, 'lockOffset prop of SortableContainer should be a single ' + 'value or an array of exactly two values. Given %s', lockOffset); var _offsets = (0, _slicedToArray3.default)(offsets, 2), minLockOffset = _offsets[0], maxLockOffset = _offsets[1]; return [(0, _utils.getLockPixelOffset)({ lockOffset: minLockOffset, width: width, height: height }), (0, _utils.getLockPixelOffset)({ lockOffset: maxLockOffset, width: width, height: height })]; } }, { key: 'updatePosition', value: function updatePosition(event) { var _props = this.props, lockAxis = _props.lockAxis, lockToContainerEdges = _props.lockToContainerEdges; var offset = (0, _utils.getPosition)(event); var translate = { x: offset.x - this.initialOffset.x, y: offset.y - this.initialOffset.y }; // Adjust for window scroll translate.y -= window.pageYOffset - this.initialWindowScroll.top; translate.x -= window.pageXOffset - this.initialWindowScroll.left; this.translate = translate; if (lockToContainerEdges) { var _getLockPixelOffsets = this.getLockPixelOffsets(), _getLockPixelOffsets2 = (0, _slicedToArray3.default)(_getLockPixelOffsets, 2), minLockOffset = _getLockPixelOffsets2[0], maxLockOffset = _getLockPixelOffsets2[1]; var minOffset = { x: this.width / 2 - minLockOffset.x, y: this.height / 2 - minLockOffset.y }; var maxOffset = { x: this.width / 2 - maxLockOffset.x, y: this.height / 2 - maxLockOffset.y }; translate.x = (0, _utils.limit)(this.minTranslate.x + minOffset.x, this.maxTranslate.x - maxOffset.x, translate.x); translate.y = (0, _utils.limit)(this.minTranslate.y + minOffset.y, this.maxTranslate.y - maxOffset.y, translate.y); } if (lockAxis === 'x') { translate.y = 0; } else if (lockAxis === 'y') { translate.x = 0;