react-draggable.js 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("react-dom"), require("react"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["react-dom", "react"], factory);
  6. else if(typeof exports === 'object')
  7. exports["ReactDraggable"] = factory(require("react-dom"), require("react"));
  8. else
  9. root["ReactDraggable"] = factory(root["ReactDOM"], root["React"]);
  10. })(this, function(__WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_6__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 12);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports, __webpack_require__) {
  79. "use strict";
  80. Object.defineProperty(exports, "__esModule", {
  81. value: true
  82. });
  83. exports.findInArray = findInArray;
  84. exports.isFunction = isFunction;
  85. exports.isNum = isNum;
  86. exports.int = int;
  87. exports.dontSetMe = dontSetMe;
  88. // @credits https://gist.github.com/rogozhnikoff/a43cfed27c41e4e68cdc
  89. function findInArray(array /*: Array<any> | TouchList*/, callback /*: Function*/) /*: any*/ {
  90. for (var i = 0, length = array.length; i < length; i++) {
  91. if (callback.apply(callback, [array[i], i, array])) return array[i];
  92. }
  93. }
  94. function isFunction(func /*: any*/) /*: boolean*/ {
  95. return typeof func === 'function' || Object.prototype.toString.call(func) === '[object Function]';
  96. }
  97. function isNum(num /*: any*/) /*: boolean*/ {
  98. return typeof num === 'number' && !isNaN(num);
  99. }
  100. function int(a /*: string*/) /*: number*/ {
  101. return parseInt(a, 10);
  102. }
  103. function dontSetMe(props /*: Object*/, propName /*: string*/, componentName /*: string*/) {
  104. if (props[propName]) {
  105. return new Error('Invalid prop ' + propName + ' passed to ' + componentName + ' - do not set this, set it on the child.');
  106. }
  107. }
  108. /***/ }),
  109. /* 1 */
  110. /***/ (function(module, exports, __webpack_require__) {
  111. "use strict";
  112. /**
  113. * Copyright (c) 2013-present, Facebook, Inc.
  114. * All rights reserved.
  115. *
  116. * This source code is licensed under the BSD-style license found in the
  117. * LICENSE file in the root directory of this source tree. An additional grant
  118. * of patent rights can be found in the PATENTS file in the same directory.
  119. *
  120. *
  121. */
  122. function makeEmptyFunction(arg) {
  123. return function () {
  124. return arg;
  125. };
  126. }
  127. /**
  128. * This function accepts and discards inputs; it has no side effects. This is
  129. * primarily useful idiomatically for overridable function endpoints which
  130. * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
  131. */
  132. var emptyFunction = function emptyFunction() {};
  133. emptyFunction.thatReturns = makeEmptyFunction;
  134. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  135. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  136. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  137. emptyFunction.thatReturnsThis = function () {
  138. return this;
  139. };
  140. emptyFunction.thatReturnsArgument = function (arg) {
  141. return arg;
  142. };
  143. module.exports = emptyFunction;
  144. /***/ }),
  145. /* 2 */
  146. /***/ (function(module, exports, __webpack_require__) {
  147. "use strict";
  148. /**
  149. * Copyright (c) 2013-present, Facebook, Inc.
  150. * All rights reserved.
  151. *
  152. * This source code is licensed under the BSD-style license found in the
  153. * LICENSE file in the root directory of this source tree. An additional grant
  154. * of patent rights can be found in the PATENTS file in the same directory.
  155. *
  156. */
  157. /**
  158. * Use invariant() to assert state which your program assumes to be true.
  159. *
  160. * Provide sprintf-style format (only %s is supported) and arguments
  161. * to provide information about what broke and what you were
  162. * expecting.
  163. *
  164. * The invariant message will be stripped in production, but the invariant
  165. * will remain to ensure logic does not differ in production.
  166. */
  167. var validateFormat = function validateFormat(format) {};
  168. if (Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production') {
  169. validateFormat = function validateFormat(format) {
  170. if (format === undefined) {
  171. throw new Error('invariant requires an error message argument');
  172. }
  173. };
  174. }
  175. function invariant(condition, format, a, b, c, d, e, f) {
  176. validateFormat(format);
  177. if (!condition) {
  178. var error;
  179. if (format === undefined) {
  180. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  181. } else {
  182. var args = [a, b, c, d, e, f];
  183. var argIndex = 0;
  184. error = new Error(format.replace(/%s/g, function () {
  185. return args[argIndex++];
  186. }));
  187. error.name = 'Invariant Violation';
  188. }
  189. error.framesToPop = 1; // we don't care about invariant's own frame
  190. throw error;
  191. }
  192. }
  193. module.exports = invariant;
  194. /***/ }),
  195. /* 3 */
  196. /***/ (function(module, exports, __webpack_require__) {
  197. "use strict";
  198. /**
  199. * Copyright 2013-present, Facebook, Inc.
  200. * All rights reserved.
  201. *
  202. * This source code is licensed under the BSD-style license found in the
  203. * LICENSE file in the root directory of this source tree. An additional grant
  204. * of patent rights can be found in the PATENTS file in the same directory.
  205. */
  206. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  207. module.exports = ReactPropTypesSecret;
  208. /***/ }),
  209. /* 4 */
  210. /***/ (function(module, exports) {
  211. module.exports = __WEBPACK_EXTERNAL_MODULE_4__;
  212. /***/ }),
  213. /* 5 */
  214. /***/ (function(module, exports, __webpack_require__) {
  215. "use strict";
  216. Object.defineProperty(exports, "__esModule", {
  217. value: true
  218. });
  219. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  220. exports.matchesSelector = matchesSelector;
  221. exports.matchesSelectorAndParentsTo = matchesSelectorAndParentsTo;
  222. exports.addEvent = addEvent;
  223. exports.removeEvent = removeEvent;
  224. exports.outerHeight = outerHeight;
  225. exports.outerWidth = outerWidth;
  226. exports.innerHeight = innerHeight;
  227. exports.innerWidth = innerWidth;
  228. exports.offsetXYFromParent = offsetXYFromParent;
  229. exports.createCSSTransform = createCSSTransform;
  230. exports.createSVGTransform = createSVGTransform;
  231. exports.getTouch = getTouch;
  232. exports.getTouchIdentifier = getTouchIdentifier;
  233. exports.addUserSelectStyles = addUserSelectStyles;
  234. exports.removeUserSelectStyles = removeUserSelectStyles;
  235. exports.styleHacks = styleHacks;
  236. exports.addClassName = addClassName;
  237. exports.removeClassName = removeClassName;
  238. var _shims = __webpack_require__(0);
  239. var _getPrefix = __webpack_require__(18);
  240. var _getPrefix2 = _interopRequireDefault(_getPrefix);
  241. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  242. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  243. /*:: import type {ControlPosition, MouseTouchEvent} from './types';*/
  244. var matchesSelectorFunc = '';
  245. function matchesSelector(el /*: Node*/, selector /*: string*/) /*: boolean*/ {
  246. if (!matchesSelectorFunc) {
  247. matchesSelectorFunc = (0, _shims.findInArray)(['matches', 'webkitMatchesSelector', 'mozMatchesSelector', 'msMatchesSelector', 'oMatchesSelector'], function (method) {
  248. // $FlowIgnore: Doesn't think elements are indexable
  249. return (0, _shims.isFunction)(el[method]);
  250. });
  251. }
  252. // $FlowIgnore: Doesn't think elements are indexable
  253. return el[matchesSelectorFunc].call(el, selector);
  254. }
  255. // Works up the tree to the draggable itself attempting to match selector.
  256. function matchesSelectorAndParentsTo(el /*: Node*/, selector /*: string*/, baseNode /*: Node*/) /*: boolean*/ {
  257. var node = el;
  258. do {
  259. if (matchesSelector(node, selector)) return true;
  260. if (node === baseNode) return false;
  261. node = node.parentNode;
  262. } while (node);
  263. return false;
  264. }
  265. function addEvent(el /*: ?Node*/, event /*: string*/, handler /*: Function*/) /*: void*/ {
  266. if (!el) {
  267. return;
  268. }
  269. if (el.attachEvent) {
  270. el.attachEvent('on' + event, handler);
  271. } else if (el.addEventListener) {
  272. el.addEventListener(event, handler, true);
  273. } else {
  274. // $FlowIgnore: Doesn't think elements are indexable
  275. el['on' + event] = handler;
  276. }
  277. }
  278. function removeEvent(el /*: ?Node*/, event /*: string*/, handler /*: Function*/) /*: void*/ {
  279. if (!el) {
  280. return;
  281. }
  282. if (el.detachEvent) {
  283. el.detachEvent('on' + event, handler);
  284. } else if (el.removeEventListener) {
  285. el.removeEventListener(event, handler, true);
  286. } else {
  287. // $FlowIgnore: Doesn't think elements are indexable
  288. el['on' + event] = null;
  289. }
  290. }
  291. function outerHeight(node /*: HTMLElement*/) /*: number*/ {
  292. // This is deliberately excluding margin for our calculations, since we are using
  293. // offsetTop which is including margin. See getBoundPosition
  294. var height = node.clientHeight;
  295. var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
  296. height += (0, _shims.int)(computedStyle.borderTopWidth);
  297. height += (0, _shims.int)(computedStyle.borderBottomWidth);
  298. return height;
  299. }
  300. function outerWidth(node /*: HTMLElement*/) /*: number*/ {
  301. // This is deliberately excluding margin for our calculations, since we are using
  302. // offsetLeft which is including margin. See getBoundPosition
  303. var width = node.clientWidth;
  304. var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
  305. width += (0, _shims.int)(computedStyle.borderLeftWidth);
  306. width += (0, _shims.int)(computedStyle.borderRightWidth);
  307. return width;
  308. }
  309. function innerHeight(node /*: HTMLElement*/) /*: number*/ {
  310. var height = node.clientHeight;
  311. var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
  312. height -= (0, _shims.int)(computedStyle.paddingTop);
  313. height -= (0, _shims.int)(computedStyle.paddingBottom);
  314. return height;
  315. }
  316. function innerWidth(node /*: HTMLElement*/) /*: number*/ {
  317. var width = node.clientWidth;
  318. var computedStyle = node.ownerDocument.defaultView.getComputedStyle(node);
  319. width -= (0, _shims.int)(computedStyle.paddingLeft);
  320. width -= (0, _shims.int)(computedStyle.paddingRight);
  321. return width;
  322. }
  323. // Get from offsetParent
  324. function offsetXYFromParent(evt /*: {clientX: number, clientY: number}*/, offsetParent /*: HTMLElement*/) /*: ControlPosition*/ {
  325. var isBody = offsetParent === offsetParent.ownerDocument.body;
  326. var offsetParentRect = isBody ? { left: 0, top: 0 } : offsetParent.getBoundingClientRect();
  327. var x = evt.clientX + offsetParent.scrollLeft - offsetParentRect.left;
  328. var y = evt.clientY + offsetParent.scrollTop - offsetParentRect.top;
  329. return { x: x, y: y };
  330. }
  331. function createCSSTransform(_ref) /*: Object*/ {
  332. var x = _ref.x,
  333. y = _ref.y;
  334. // Replace unitless items with px
  335. return _defineProperty({}, (0, _getPrefix.browserPrefixToKey)('transform', _getPrefix2.default), 'translate(' + x + 'px,' + y + 'px)');
  336. }
  337. function createSVGTransform(_ref3) /*: string*/ {
  338. var x = _ref3.x,
  339. y = _ref3.y;
  340. return 'translate(' + x + ',' + y + ')';
  341. }
  342. function getTouch(e /*: MouseTouchEvent*/, identifier /*: number*/) /*: ?{clientX: number, clientY: number}*/ {
  343. return e.targetTouches && (0, _shims.findInArray)(e.targetTouches, function (t) {
  344. return identifier === t.identifier;
  345. }) || e.changedTouches && (0, _shims.findInArray)(e.changedTouches, function (t) {
  346. return identifier === t.identifier;
  347. });
  348. }
  349. function getTouchIdentifier(e /*: MouseTouchEvent*/) /*: ?number*/ {
  350. if (e.targetTouches && e.targetTouches[0]) return e.targetTouches[0].identifier;
  351. if (e.changedTouches && e.changedTouches[0]) return e.changedTouches[0].identifier;
  352. }
  353. // User-select Hacks:
  354. //
  355. // Useful for preventing blue highlights all over everything when dragging.
  356. // Note we're passing `document` b/c we could be iframed
  357. function addUserSelectStyles(doc /*: Document*/) {
  358. var styleEl = doc.getElementById('react-draggable-style-el');
  359. if (!styleEl) {
  360. styleEl = doc.createElement('style');
  361. styleEl.type = 'text/css';
  362. styleEl.id = 'react-draggable-style-el';
  363. styleEl.innerHTML = '.react-draggable-transparent-selection *::-moz-selection {background: transparent;}\n';
  364. styleEl.innerHTML += '.react-draggable-transparent-selection *::selection {background: transparent;}\n';
  365. doc.getElementsByTagName('head')[0].appendChild(styleEl);
  366. }
  367. if (doc.body) addClassName(doc.body, 'react-draggable-transparent-selection');
  368. }
  369. function removeUserSelectStyles(doc /*: Document*/) {
  370. if (doc.body) removeClassName(doc.body, 'react-draggable-transparent-selection');
  371. window.getSelection().removeAllRanges(); // remove selection caused by scroll
  372. }
  373. function styleHacks() /*: Object*/ {
  374. var childStyle /*: Object*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  375. // Workaround IE pointer events; see #51
  376. // https://github.com/mzabriskie/react-draggable/issues/51#issuecomment-103488278
  377. return _extends({
  378. touchAction: 'none'
  379. }, childStyle);
  380. }
  381. function addClassName(el /*: HTMLElement*/, className /*: string*/) {
  382. if (el.classList) {
  383. el.classList.add(className);
  384. } else {
  385. if (!el.className.match(new RegExp('(?:^|\\s)' + className + '(?!\\S)'))) {
  386. el.className += ' ' + className;
  387. }
  388. }
  389. }
  390. function removeClassName(el /*: HTMLElement*/, className /*: string*/) {
  391. if (el.classList) {
  392. el.classList.remove(className);
  393. } else {
  394. el.className = el.className.replace(new RegExp('(?:^|\\s)' + className + '(?!\\S)', 'g'), '');
  395. }
  396. }
  397. /***/ }),
  398. /* 6 */
  399. /***/ (function(module, exports) {
  400. module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
  401. /***/ }),
  402. /* 7 */
  403. /***/ (function(module, exports, __webpack_require__) {
  404. /**
  405. * Copyright 2013-present, Facebook, Inc.
  406. * All rights reserved.
  407. *
  408. * This source code is licensed under the BSD-style license found in the
  409. * LICENSE file in the root directory of this source tree. An additional grant
  410. * of patent rights can be found in the PATENTS file in the same directory.
  411. */
  412. if (Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production') {
  413. var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
  414. Symbol.for &&
  415. Symbol.for('react.element')) ||
  416. 0xeac7;
  417. var isValidElement = function(object) {
  418. return typeof object === 'object' &&
  419. object !== null &&
  420. object.$$typeof === REACT_ELEMENT_TYPE;
  421. };
  422. // By explicitly using `prop-types` you are opting into new development behavior.
  423. // http://fb.me/prop-types-in-prod
  424. var throwOnDirectAccess = true;
  425. module.exports = __webpack_require__(14)(isValidElement, throwOnDirectAccess);
  426. } else {
  427. // By explicitly using `prop-types` you are opting into new production behavior.
  428. // http://fb.me/prop-types-in-prod
  429. module.exports = __webpack_require__(16)();
  430. }
  431. /***/ }),
  432. /* 8 */
  433. /***/ (function(module, exports, __webpack_require__) {
  434. "use strict";
  435. /**
  436. * Copyright 2014-2015, Facebook, Inc.
  437. * All rights reserved.
  438. *
  439. * This source code is licensed under the BSD-style license found in the
  440. * LICENSE file in the root directory of this source tree. An additional grant
  441. * of patent rights can be found in the PATENTS file in the same directory.
  442. *
  443. */
  444. var emptyFunction = __webpack_require__(1);
  445. /**
  446. * Similar to invariant but only logs a warning if the condition is not met.
  447. * This can be used to log issues in development environments in critical
  448. * paths. Removing the logging code for production environments will keep the
  449. * same logic and follow the same code paths.
  450. */
  451. var warning = emptyFunction;
  452. if (Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production') {
  453. var printWarning = function printWarning(format) {
  454. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  455. args[_key - 1] = arguments[_key];
  456. }
  457. var argIndex = 0;
  458. var message = 'Warning: ' + format.replace(/%s/g, function () {
  459. return args[argIndex++];
  460. });
  461. if (typeof console !== 'undefined') {
  462. console.error(message);
  463. }
  464. try {
  465. // --- Welcome to debugging React ---
  466. // This error was thrown as a convenience so that you can use this stack
  467. // to find the callsite that caused this warning to fire.
  468. throw new Error(message);
  469. } catch (x) {}
  470. };
  471. warning = function warning(condition, format) {
  472. if (format === undefined) {
  473. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  474. }
  475. if (format.indexOf('Failed Composite propType: ') === 0) {
  476. return; // Ignore CompositeComponent proptype check.
  477. }
  478. if (!condition) {
  479. for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
  480. args[_key2 - 2] = arguments[_key2];
  481. }
  482. printWarning.apply(undefined, [format].concat(args));
  483. }
  484. };
  485. }
  486. module.exports = warning;
  487. /***/ }),
  488. /* 9 */
  489. /***/ (function(module, exports, __webpack_require__) {
  490. "use strict";
  491. Object.defineProperty(exports, "__esModule", {
  492. value: true
  493. });
  494. exports.getBoundPosition = getBoundPosition;
  495. exports.snapToGrid = snapToGrid;
  496. exports.canDragX = canDragX;
  497. exports.canDragY = canDragY;
  498. exports.getControlPosition = getControlPosition;
  499. exports.createCoreData = createCoreData;
  500. exports.createDraggableData = createDraggableData;
  501. var _shims = __webpack_require__(0);
  502. var _reactDom = __webpack_require__(4);
  503. var _reactDom2 = _interopRequireDefault(_reactDom);
  504. var _domFns = __webpack_require__(5);
  505. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  506. /*:: import type Draggable from '../Draggable';*/
  507. /*:: import type {Bounds, ControlPosition, DraggableData, MouseTouchEvent} from './types';*/
  508. /*:: import type DraggableCore from '../DraggableCore';*/
  509. function getBoundPosition(draggable /*: Draggable*/, x /*: number*/, y /*: number*/) /*: [number, number]*/ {
  510. // If no bounds, short-circuit and move on
  511. if (!draggable.props.bounds) return [x, y];
  512. // Clone new bounds
  513. var bounds = draggable.props.bounds;
  514. bounds = typeof bounds === 'string' ? bounds : cloneBounds(bounds);
  515. var node = findDOMNode(draggable);
  516. if (typeof bounds === 'string') {
  517. var ownerDocument = node.ownerDocument;
  518. var ownerWindow = ownerDocument.defaultView;
  519. var boundNode = void 0;
  520. if (bounds === 'parent') {
  521. boundNode = node.parentNode;
  522. } else {
  523. boundNode = ownerDocument.querySelector(bounds);
  524. }
  525. if (!(boundNode instanceof HTMLElement)) {
  526. throw new Error('Bounds selector "' + bounds + '" could not find an element.');
  527. }
  528. var nodeStyle = ownerWindow.getComputedStyle(node);
  529. var boundNodeStyle = ownerWindow.getComputedStyle(boundNode);
  530. // Compute bounds. This is a pain with padding and offsets but this gets it exactly right.
  531. bounds = {
  532. left: -node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingLeft) + (0, _shims.int)(nodeStyle.marginLeft),
  533. top: -node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingTop) + (0, _shims.int)(nodeStyle.marginTop),
  534. right: (0, _domFns.innerWidth)(boundNode) - (0, _domFns.outerWidth)(node) - node.offsetLeft + (0, _shims.int)(boundNodeStyle.paddingRight) - (0, _shims.int)(nodeStyle.marginRight),
  535. bottom: (0, _domFns.innerHeight)(boundNode) - (0, _domFns.outerHeight)(node) - node.offsetTop + (0, _shims.int)(boundNodeStyle.paddingBottom) - (0, _shims.int)(nodeStyle.marginBottom)
  536. };
  537. }
  538. // Keep x and y below right and bottom limits...
  539. if ((0, _shims.isNum)(bounds.right)) x = Math.min(x, bounds.right);
  540. if ((0, _shims.isNum)(bounds.bottom)) y = Math.min(y, bounds.bottom);
  541. // But above left and top limits.
  542. if ((0, _shims.isNum)(bounds.left)) x = Math.max(x, bounds.left);
  543. if ((0, _shims.isNum)(bounds.top)) y = Math.max(y, bounds.top);
  544. return [x, y];
  545. }
  546. function snapToGrid(grid /*: [number, number]*/, pendingX /*: number*/, pendingY /*: number*/) /*: [number, number]*/ {
  547. var x = Math.round(pendingX / grid[0]) * grid[0];
  548. var y = Math.round(pendingY / grid[1]) * grid[1];
  549. return [x, y];
  550. }
  551. function canDragX(draggable /*: Draggable*/) /*: boolean*/ {
  552. return draggable.props.axis === 'both' || draggable.props.axis === 'x';
  553. }
  554. function canDragY(draggable /*: Draggable*/) /*: boolean*/ {
  555. return draggable.props.axis === 'both' || draggable.props.axis === 'y';
  556. }
  557. // Get {x, y} positions from event.
  558. function getControlPosition(e /*: MouseTouchEvent*/, touchIdentifier /*: ?number*/, draggableCore /*: DraggableCore*/) /*: ?ControlPosition*/ {
  559. var touchObj = typeof touchIdentifier === 'number' ? (0, _domFns.getTouch)(e, touchIdentifier) : null;
  560. if (typeof touchIdentifier === 'number' && !touchObj) return null; // not the right touch
  561. var node = findDOMNode(draggableCore);
  562. // User can provide an offsetParent if desired.
  563. var offsetParent = draggableCore.props.offsetParent || node.offsetParent || node.ownerDocument.body;
  564. return (0, _domFns.offsetXYFromParent)(touchObj || e, offsetParent);
  565. }
  566. // Create an data object exposed by <DraggableCore>'s events
  567. function createCoreData(draggable /*: DraggableCore*/, x /*: number*/, y /*: number*/) /*: DraggableData*/ {
  568. var state = draggable.state;
  569. var isStart = !(0, _shims.isNum)(state.lastX);
  570. var node = findDOMNode(draggable);
  571. if (isStart) {
  572. // If this is our first move, use the x and y as last coords.
  573. return {
  574. node: node,
  575. deltaX: 0, deltaY: 0,
  576. lastX: x, lastY: y,
  577. x: x, y: y
  578. };
  579. } else {
  580. // Otherwise calculate proper values.
  581. return {
  582. node: node,
  583. deltaX: x - state.lastX, deltaY: y - state.lastY,
  584. lastX: state.lastX, lastY: state.lastY,
  585. x: x, y: y
  586. };
  587. }
  588. }
  589. // Create an data exposed by <Draggable>'s events
  590. function createDraggableData(draggable /*: Draggable*/, coreData /*: DraggableData*/) /*: DraggableData*/ {
  591. return {
  592. node: coreData.node,
  593. x: draggable.state.x + coreData.deltaX,
  594. y: draggable.state.y + coreData.deltaY,
  595. deltaX: coreData.deltaX,
  596. deltaY: coreData.deltaY,
  597. lastX: draggable.state.x,
  598. lastY: draggable.state.y
  599. };
  600. }
  601. // A lot faster than stringify/parse
  602. function cloneBounds(bounds /*: Bounds*/) /*: Bounds*/ {
  603. return {
  604. left: bounds.left,
  605. top: bounds.top,
  606. right: bounds.right,
  607. bottom: bounds.bottom
  608. };
  609. }
  610. function findDOMNode(draggable /*: Draggable | DraggableCore*/) /*: HTMLElement*/ {
  611. var node = _reactDom2.default.findDOMNode(draggable);
  612. if (!node) {
  613. throw new Error('<DraggableCore>: Unmounted during event!');
  614. }
  615. // $FlowIgnore we can't assert on HTMLElement due to tests... FIXME
  616. return node;
  617. }
  618. /***/ }),
  619. /* 10 */
  620. /***/ (function(module, exports, __webpack_require__) {
  621. "use strict";
  622. /* WEBPACK VAR INJECTION */(function(process) {
  623. Object.defineProperty(exports, "__esModule", {
  624. value: true
  625. });
  626. var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  627. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  628. var _react = __webpack_require__(6);
  629. var _react2 = _interopRequireDefault(_react);
  630. var _propTypes = __webpack_require__(7);
  631. var _propTypes2 = _interopRequireDefault(_propTypes);
  632. var _reactDom = __webpack_require__(4);
  633. var _reactDom2 = _interopRequireDefault(_reactDom);
  634. var _domFns = __webpack_require__(5);
  635. var _positionFns = __webpack_require__(9);
  636. var _shims = __webpack_require__(0);
  637. var _log = __webpack_require__(11);
  638. var _log2 = _interopRequireDefault(_log);
  639. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  640. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  641. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  642. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  643. /*:: import type {EventHandler, MouseTouchEvent} from './utils/types';*/
  644. // Simple abstraction for dragging events names.
  645. /*:: import type {Element as ReactElement} from 'react';*/
  646. var eventsFor = {
  647. touch: {
  648. start: 'touchstart',
  649. move: 'touchmove',
  650. stop: 'touchend'
  651. },
  652. mouse: {
  653. start: 'mousedown',
  654. move: 'mousemove',
  655. stop: 'mouseup'
  656. }
  657. };
  658. // Default to mouse events.
  659. var dragEventFor = eventsFor.mouse;
  660. /*:: type DraggableCoreState = {
  661. dragging: boolean,
  662. lastX: number,
  663. lastY: number,
  664. touchIdentifier: ?number
  665. };*/
  666. /*:: export type DraggableBounds = {
  667. left: number,
  668. right: number,
  669. top: number,
  670. bottom: number,
  671. };*/
  672. /*:: export type DraggableData = {
  673. node: HTMLElement,
  674. x: number, y: number,
  675. deltaX: number, deltaY: number,
  676. lastX: number, lastY: number,
  677. };*/
  678. /*:: export type DraggableEventHandler = (e: MouseEvent, data: DraggableData) => void;*/
  679. /*:: export type ControlPosition = {x: number, y: number};*/
  680. //
  681. // Define <DraggableCore>.
  682. //
  683. // <DraggableCore> is for advanced usage of <Draggable>. It maintains minimal internal state so it can
  684. // work well with libraries that require more control over the element.
  685. //
  686. /*:: export type DraggableCoreProps = {
  687. allowAnyClick: boolean,
  688. cancel: string,
  689. children: ReactElement<any>,
  690. disabled: boolean,
  691. enableUserSelectHack: boolean,
  692. offsetParent: HTMLElement,
  693. grid: [number, number],
  694. handle: string,
  695. onStart: DraggableEventHandler,
  696. onDrag: DraggableEventHandler,
  697. onStop: DraggableEventHandler,
  698. onMouseDown: (e: MouseEvent) => void,
  699. };*/
  700. var DraggableCore = function (_React$Component) {
  701. _inherits(DraggableCore, _React$Component);
  702. function DraggableCore() {
  703. var _ref;
  704. var _temp, _this, _ret;
  705. _classCallCheck(this, DraggableCore);
  706. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  707. args[_key] = arguments[_key];
  708. }
  709. return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = DraggableCore.__proto__ || Object.getPrototypeOf(DraggableCore)).call.apply(_ref, [this].concat(args))), _this), _this.state = {
  710. dragging: false,
  711. // Used while dragging to determine deltas.
  712. lastX: NaN, lastY: NaN,
  713. touchIdentifier: null
  714. }, _this.handleDragStart = function (e) {
  715. // Make it possible to attach event handlers on top of this one.
  716. _this.props.onMouseDown(e);
  717. // Only accept left-clicks.
  718. if (!_this.props.allowAnyClick && typeof e.button === 'number' && e.button !== 0) return false;
  719. // Get nodes. Be sure to grab relative document (could be iframed)
  720. var thisNode = _reactDom2.default.findDOMNode(_this);
  721. if (!thisNode || !thisNode.ownerDocument || !thisNode.ownerDocument.body) {
  722. throw new Error('<DraggableCore> not mounted on DragStart!');
  723. }
  724. var ownerDocument = thisNode.ownerDocument;
  725. // Short circuit if handle or cancel prop was provided and selector doesn't match.
  726. if (_this.props.disabled || !(e.target instanceof ownerDocument.defaultView.Node) || _this.props.handle && !(0, _domFns.matchesSelectorAndParentsTo)(e.target, _this.props.handle, thisNode) || _this.props.cancel && (0, _domFns.matchesSelectorAndParentsTo)(e.target, _this.props.cancel, thisNode)) {
  727. return;
  728. }
  729. // Set touch identifier in component state if this is a touch event. This allows us to
  730. // distinguish between individual touches on multitouch screens by identifying which
  731. // touchpoint was set to this element.
  732. var touchIdentifier = (0, _domFns.getTouchIdentifier)(e);
  733. _this.setState({ touchIdentifier: touchIdentifier });
  734. // Get the current drag point from the event. This is used as the offset.
  735. var position = (0, _positionFns.getControlPosition)(e, touchIdentifier, _this);
  736. if (position == null) return; // not possible but satisfies flow
  737. var x = position.x,
  738. y = position.y;
  739. // Create an event object with all the data parents need to make a decision here.
  740. var coreEvent = (0, _positionFns.createCoreData)(_this, x, y);
  741. (0, _log2.default)('DraggableCore: handleDragStart: %j', coreEvent);
  742. // Call event handler. If it returns explicit false, cancel.
  743. (0, _log2.default)('calling', _this.props.onStart);
  744. var shouldUpdate = _this.props.onStart(e, coreEvent);
  745. if (shouldUpdate === false) return;
  746. // Add a style to the body to disable user-select. This prevents text from
  747. // being selected all over the page.
  748. if (_this.props.enableUserSelectHack) (0, _domFns.addUserSelectStyles)(ownerDocument);
  749. // Initiate dragging. Set the current x and y as offsets
  750. // so we know how much we've moved during the drag. This allows us
  751. // to drag elements around even if they have been moved, without issue.
  752. _this.setState({
  753. dragging: true,
  754. lastX: x,
  755. lastY: y
  756. });
  757. // Add events to the document directly so we catch when the user's mouse/touch moves outside of
  758. // this element. We use different events depending on whether or not we have detected that this
  759. // is a touch-capable device.
  760. (0, _domFns.addEvent)(ownerDocument, dragEventFor.move, _this.handleDrag);
  761. (0, _domFns.addEvent)(ownerDocument, dragEventFor.stop, _this.handleDragStop);
  762. }, _this.handleDrag = function (e) {
  763. // Prevent scrolling on mobile devices, like ipad/iphone.
  764. if (e.type === 'touchmove') e.preventDefault();
  765. // Get the current drag point from the event. This is used as the offset.
  766. var position = (0, _positionFns.getControlPosition)(e, _this.state.touchIdentifier, _this);
  767. if (position == null) return;
  768. var x = position.x,
  769. y = position.y;
  770. // Snap to grid if prop has been provided
  771. if (Array.isArray(_this.props.grid)) {
  772. var _deltaX = x - _this.state.lastX,
  773. _deltaY = y - _this.state.lastY;
  774. var _snapToGrid = (0, _positionFns.snapToGrid)(_this.props.grid, _deltaX, _deltaY);
  775. var _snapToGrid2 = _slicedToArray(_snapToGrid, 2);
  776. _deltaX = _snapToGrid2[0];
  777. _deltaY = _snapToGrid2[1];
  778. if (!_deltaX && !_deltaY) return; // skip useless drag
  779. x = _this.state.lastX + _deltaX, y = _this.state.lastY + _deltaY;
  780. }
  781. var coreEvent = (0, _positionFns.createCoreData)(_this, x, y);
  782. (0, _log2.default)('DraggableCore: handleDrag: %j', coreEvent);
  783. // Call event handler. If it returns explicit false, trigger end.
  784. var shouldUpdate = _this.props.onDrag(e, coreEvent);
  785. if (shouldUpdate === false) {
  786. try {
  787. // $FlowIgnore
  788. _this.handleDragStop(new MouseEvent('mouseup'));
  789. } catch (err) {
  790. // Old browsers
  791. var event = ((document.createEvent('MouseEvents') /*: any*/) /*: MouseTouchEvent*/);
  792. // I see why this insanity was deprecated
  793. // $FlowIgnore
  794. event.initMouseEvent('mouseup', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  795. _this.handleDragStop(event);
  796. }
  797. return;
  798. }
  799. _this.setState({
  800. lastX: x,
  801. lastY: y
  802. });
  803. }, _this.handleDragStop = function (e) {
  804. if (!_this.state.dragging) return;
  805. var position = (0, _positionFns.getControlPosition)(e, _this.state.touchIdentifier, _this);
  806. if (position == null) return;
  807. var x = position.x,
  808. y = position.y;
  809. var coreEvent = (0, _positionFns.createCoreData)(_this, x, y);
  810. var thisNode = _reactDom2.default.findDOMNode(_this);
  811. if (thisNode) {
  812. // Remove user-select hack
  813. if (_this.props.enableUserSelectHack) (0, _domFns.removeUserSelectStyles)(thisNode.ownerDocument);
  814. }
  815. (0, _log2.default)('DraggableCore: handleDragStop: %j', coreEvent);
  816. // Reset the el.
  817. _this.setState({
  818. dragging: false,
  819. lastX: NaN,
  820. lastY: NaN
  821. });
  822. // Call event handler
  823. _this.props.onStop(e, coreEvent);
  824. if (thisNode) {
  825. // Remove event handlers
  826. (0, _log2.default)('DraggableCore: Removing handlers');
  827. (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.move, _this.handleDrag);
  828. (0, _domFns.removeEvent)(thisNode.ownerDocument, dragEventFor.stop, _this.handleDragStop);
  829. }
  830. }, _this.onMouseDown = function (e) {
  831. dragEventFor = eventsFor.mouse; // on touchscreen laptops we could switch back to mouse
  832. return _this.handleDragStart(e);
  833. }, _this.onMouseUp = function (e) {
  834. dragEventFor = eventsFor.mouse;
  835. return _this.handleDragStop(e);
  836. }, _this.onTouchStart = function (e) {
  837. // We're on a touch device now, so change the event handlers
  838. dragEventFor = eventsFor.touch;
  839. return _this.handleDragStart(e);
  840. }, _this.onTouchEnd = function (e) {
  841. // We're on a touch device now, so change the event handlers
  842. dragEventFor = eventsFor.touch;
  843. return _this.handleDragStop(e);
  844. }, _temp), _possibleConstructorReturn(_this, _ret);
  845. }
  846. _createClass(DraggableCore, [{
  847. key: 'componentWillUnmount',
  848. value: function componentWillUnmount() {
  849. // Remove any leftover event handlers. Remove both touch and mouse handlers in case
  850. // some browser quirk caused a touch event to fire during a mouse move, or vice versa.
  851. var thisNode = _reactDom2.default.findDOMNode(this);
  852. if (thisNode) {
  853. var ownerDocument = thisNode.ownerDocument;
  854. (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.move, this.handleDrag);
  855. (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.move, this.handleDrag);
  856. (0, _domFns.removeEvent)(ownerDocument, eventsFor.mouse.stop, this.handleDragStop);
  857. (0, _domFns.removeEvent)(ownerDocument, eventsFor.touch.stop, this.handleDragStop);
  858. if (this.props.enableUserSelectHack) (0, _domFns.removeUserSelectStyles)(ownerDocument);
  859. }
  860. }
  861. // Same as onMouseDown (start drag), but now consider this a touch device.
  862. }, {
  863. key: 'render',
  864. value: function render() {
  865. // Reuse the child provided
  866. // This makes it flexible to use whatever element is wanted (div, ul, etc)
  867. return _react2.default.cloneElement(_react2.default.Children.only(this.props.children), {
  868. style: (0, _domFns.styleHacks)(this.props.children.props.style),
  869. // Note: mouseMove handler is attached to document so it will still function
  870. // when the user drags quickly and leaves the bounds of the element.
  871. onMouseDown: this.onMouseDown,
  872. onTouchStart: this.onTouchStart,
  873. onMouseUp: this.onMouseUp,
  874. onTouchEnd: this.onTouchEnd
  875. });
  876. }
  877. }]);
  878. return DraggableCore;
  879. }(_react2.default.Component);
  880. DraggableCore.displayName = 'DraggableCore';
  881. DraggableCore.propTypes = {
  882. /**
  883. * `allowAnyClick` allows dragging using any mouse button.
  884. * By default, we only accept the left button.
  885. *
  886. * Defaults to `false`.
  887. */
  888. allowAnyClick: _propTypes2.default.bool,
  889. /**
  890. * `disabled`, if true, stops the <Draggable> from dragging. All handlers,
  891. * with the exception of `onMouseDown`, will not fire.
  892. */
  893. disabled: _propTypes2.default.bool,
  894. /**
  895. * By default, we add 'user-select:none' attributes to the document body
  896. * to prevent ugly text selection during drag. If this is causing problems
  897. * for your app, set this to `false`.
  898. */
  899. enableUserSelectHack: _propTypes2.default.bool,
  900. /**
  901. * `offsetParent`, if set, uses the passed DOM node to compute drag offsets
  902. * instead of using the parent node.
  903. */
  904. offsetParent: function offsetParent(props, propName) {
  905. if (process.browser && props[propName] && props[propName].nodeType !== 1) {
  906. throw new Error('Draggable\'s offsetParent must be a DOM Node.');
  907. }
  908. },
  909. /**
  910. * `grid` specifies the x and y that dragging should snap to.
  911. */
  912. grid: _propTypes2.default.arrayOf(_propTypes2.default.number),
  913. /**
  914. * `handle` specifies a selector to be used as the handle that initiates drag.
  915. *
  916. * Example:
  917. *
  918. * ```jsx
  919. * let App = React.createClass({
  920. * render: function () {
  921. * return (
  922. * <Draggable handle=".handle">
  923. * <div>
  924. * <div className="handle">Click me to drag</div>
  925. * <div>This is some other content</div>
  926. * </div>
  927. * </Draggable>
  928. * );
  929. * }
  930. * });
  931. * ```
  932. */
  933. handle: _propTypes2.default.string,
  934. /**
  935. * `cancel` specifies a selector to be used to prevent drag initialization.
  936. *
  937. * Example:
  938. *
  939. * ```jsx
  940. * let App = React.createClass({
  941. * render: function () {
  942. * return(
  943. * <Draggable cancel=".cancel">
  944. * <div>
  945. * <div className="cancel">You can't drag from here</div>
  946. * <div>Dragging here works fine</div>
  947. * </div>
  948. * </Draggable>
  949. * );
  950. * }
  951. * });
  952. * ```
  953. */
  954. cancel: _propTypes2.default.string,
  955. /**
  956. * Called when dragging starts.
  957. * If this function returns the boolean false, dragging will be canceled.
  958. */
  959. onStart: _propTypes2.default.func,
  960. /**
  961. * Called while dragging.
  962. * If this function returns the boolean false, dragging will be canceled.
  963. */
  964. onDrag: _propTypes2.default.func,
  965. /**
  966. * Called when dragging stops.
  967. * If this function returns the boolean false, the drag will remain active.
  968. */
  969. onStop: _propTypes2.default.func,
  970. /**
  971. * A workaround option which can be passed if onMouseDown needs to be accessed,
  972. * since it'll always be blocked (as there is internal use of onMouseDown)
  973. */
  974. onMouseDown: _propTypes2.default.func,
  975. /**
  976. * These properties should be defined on the child, not here.
  977. */
  978. className: _shims.dontSetMe,
  979. style: _shims.dontSetMe,
  980. transform: _shims.dontSetMe
  981. };
  982. DraggableCore.defaultProps = {
  983. allowAnyClick: false, // by default only accept left click
  984. cancel: null,
  985. disabled: false,
  986. enableUserSelectHack: true,
  987. offsetParent: null,
  988. handle: null,
  989. grid: null,
  990. transform: null,
  991. onStart: function onStart() {},
  992. onDrag: function onDrag() {},
  993. onStop: function onStop() {},
  994. onMouseDown: function onMouseDown() {}
  995. };
  996. exports.default = DraggableCore;
  997. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(19)))
  998. /***/ }),
  999. /* 11 */
  1000. /***/ (function(module, exports, __webpack_require__) {
  1001. "use strict";
  1002. Object.defineProperty(exports, "__esModule", {
  1003. value: true
  1004. });
  1005. exports.default = log;
  1006. /*eslint no-console:0*/
  1007. function log() {
  1008. var _console;
  1009. if (undefined) (_console = console).log.apply(_console, arguments);
  1010. }
  1011. /***/ }),
  1012. /* 12 */
  1013. /***/ (function(module, exports, __webpack_require__) {
  1014. "use strict";
  1015. var Draggable = __webpack_require__(13).default;
  1016. // Previous versions of this lib exported <Draggable> as the root export. As to not break
  1017. // them, or TypeScript, we export *both* as the root and as 'default'.
  1018. // See https://github.com/mzabriskie/react-draggable/pull/254
  1019. // and https://github.com/mzabriskie/react-draggable/issues/266
  1020. module.exports = Draggable;
  1021. module.exports.default = Draggable;
  1022. module.exports.DraggableCore = __webpack_require__(10).default;
  1023. /***/ }),
  1024. /* 13 */
  1025. /***/ (function(module, exports, __webpack_require__) {
  1026. "use strict";
  1027. Object.defineProperty(exports, "__esModule", {
  1028. value: true
  1029. });
  1030. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  1031. var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
  1032. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1033. var _react = __webpack_require__(6);
  1034. var _react2 = _interopRequireDefault(_react);
  1035. var _propTypes = __webpack_require__(7);
  1036. var _propTypes2 = _interopRequireDefault(_propTypes);
  1037. var _reactDom = __webpack_require__(4);
  1038. var _reactDom2 = _interopRequireDefault(_reactDom);
  1039. var _classnames = __webpack_require__(17);
  1040. var _classnames2 = _interopRequireDefault(_classnames);
  1041. var _domFns = __webpack_require__(5);
  1042. var _positionFns = __webpack_require__(9);
  1043. var _shims = __webpack_require__(0);
  1044. var _DraggableCore = __webpack_require__(10);
  1045. var _DraggableCore2 = _interopRequireDefault(_DraggableCore);
  1046. var _log = __webpack_require__(11);
  1047. var _log2 = _interopRequireDefault(_log);
  1048. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  1049. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  1050. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1051. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1052. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1053. /*:: import type {ControlPosition, DraggableBounds, DraggableCoreProps} from './DraggableCore';*/
  1054. /*:: import type {DraggableEventHandler} from './utils/types';*/
  1055. /*:: import type {Element as ReactElement} from 'react';*/
  1056. /*:: type DraggableState = {
  1057. dragging: boolean,
  1058. dragged: boolean,
  1059. x: number, y: number,
  1060. slackX: number, slackY: number,
  1061. isElementSVG: boolean
  1062. };*/
  1063. //
  1064. // Define <Draggable>
  1065. //
  1066. /*:: export type DraggableProps = {
  1067. ...$Exact<DraggableCoreProps>,
  1068. axis: 'both' | 'x' | 'y' | 'none',
  1069. bounds: DraggableBounds | string | false,
  1070. defaultClassName: string,
  1071. defaultClassNameDragging: string,
  1072. defaultClassNameDragged: string,
  1073. defaultPosition: ControlPosition,
  1074. position: ControlPosition,
  1075. };*/
  1076. var Draggable = function (_React$Component) {
  1077. _inherits(Draggable, _React$Component);
  1078. function Draggable(props /*: DraggableProps*/) {
  1079. _classCallCheck(this, Draggable);
  1080. var _this = _possibleConstructorReturn(this, (Draggable.__proto__ || Object.getPrototypeOf(Draggable)).call(this, props));
  1081. _this.onDragStart = function (e, coreData) {
  1082. (0, _log2.default)('Draggable: onDragStart: %j', coreData);
  1083. // Short-circuit if user's callback killed it.
  1084. var shouldStart = _this.props.onStart(e, (0, _positionFns.createDraggableData)(_this, coreData));
  1085. // Kills start event on core as well, so move handlers are never bound.
  1086. if (shouldStart === false) return false;
  1087. _this.setState({ dragging: true, dragged: true });
  1088. };
  1089. _this.onDrag = function (e, coreData) {
  1090. if (!_this.state.dragging) return false;
  1091. (0, _log2.default)('Draggable: onDrag: %j', coreData);
  1092. var uiData = (0, _positionFns.createDraggableData)(_this, coreData);
  1093. var newState /*: $Shape<DraggableState>*/ = {
  1094. x: uiData.x,
  1095. y: uiData.y
  1096. };
  1097. // Keep within bounds.
  1098. if (_this.props.bounds) {
  1099. // Save original x and y.
  1100. var _x = newState.x,
  1101. _y = newState.y;
  1102. // Add slack to the values used to calculate bound position. This will ensure that if
  1103. // we start removing slack, the element won't react to it right away until it's been
  1104. // completely removed.
  1105. newState.x += _this.state.slackX;
  1106. newState.y += _this.state.slackY;
  1107. // Get bound position. This will ceil/floor the x and y within the boundaries.
  1108. // $FlowBug
  1109. // Recalculate slack by noting how much was shaved by the boundPosition handler.
  1110. var _getBoundPosition = (0, _positionFns.getBoundPosition)(_this, newState.x, newState.y);
  1111. var _getBoundPosition2 = _slicedToArray(_getBoundPosition, 2);
  1112. newState.x = _getBoundPosition2[0];
  1113. newState.y = _getBoundPosition2[1];
  1114. newState.slackX = _this.state.slackX + (_x - newState.x);
  1115. newState.slackY = _this.state.slackY + (_y - newState.y);
  1116. // Update the event we fire to reflect what really happened after bounds took effect.
  1117. uiData.x = newState.x;
  1118. uiData.y = newState.y;
  1119. uiData.deltaX = newState.x - _this.state.x;
  1120. uiData.deltaY = newState.y - _this.state.y;
  1121. }
  1122. // Short-circuit if user's callback killed it.
  1123. var shouldUpdate = _this.props.onDrag(e, uiData);
  1124. if (shouldUpdate === false) return false;
  1125. _this.setState(newState);
  1126. };
  1127. _this.onDragStop = function (e, coreData) {
  1128. if (!_this.state.dragging) return false;
  1129. // Short-circuit if user's callback killed it.
  1130. var shouldStop = _this.props.onStop(e, (0, _positionFns.createDraggableData)(_this, coreData));
  1131. if (shouldStop === false) return false;
  1132. (0, _log2.default)('Draggable: onDragStop: %j', coreData);
  1133. var newState /*: $Shape<DraggableState>*/ = {
  1134. dragging: false,
  1135. slackX: 0,
  1136. slackY: 0
  1137. };
  1138. // If this is a controlled component, the result of this operation will be to
  1139. // revert back to the old position. We expect a handler on `onDragStop`, at the least.
  1140. var controlled = Boolean(_this.props.position);
  1141. if (controlled) {
  1142. var _this$props$position = _this.props.position,
  1143. _x2 = _this$props$position.x,
  1144. _y2 = _this$props$position.y;
  1145. newState.x = _x2;
  1146. newState.y = _y2;
  1147. }
  1148. _this.setState(newState);
  1149. };
  1150. _this.state = {
  1151. // Whether or not we are currently dragging.
  1152. dragging: false,
  1153. // Whether or not we have been dragged before.
  1154. dragged: false,
  1155. // Current transform x and y.
  1156. x: props.position ? props.position.x : props.defaultPosition.x,
  1157. y: props.position ? props.position.y : props.defaultPosition.y,
  1158. // Used for compensating for out-of-bounds drags
  1159. slackX: 0, slackY: 0,
  1160. // Can only determine if SVG after mounting
  1161. isElementSVG: false
  1162. };
  1163. return _this;
  1164. }
  1165. _createClass(Draggable, [{
  1166. key: 'componentWillMount',
  1167. value: function componentWillMount() {
  1168. if (this.props.position && !(this.props.onDrag || this.props.onStop)) {
  1169. // eslint-disable-next-line
  1170. console.warn('A `position` was applied to this <Draggable>, without drag handlers. This will make this ' + 'component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the ' + '`position` of this element.');
  1171. }
  1172. }
  1173. }, {
  1174. key: 'componentDidMount',
  1175. value: function componentDidMount() {
  1176. // Check to see if the element passed is an instanceof SVGElement
  1177. if (typeof window.SVGElement !== 'undefined' && _reactDom2.default.findDOMNode(this) instanceof window.SVGElement) {
  1178. this.setState({ isElementSVG: true });
  1179. }
  1180. }
  1181. }, {
  1182. key: 'componentWillReceiveProps',
  1183. value: function componentWillReceiveProps(nextProps /*: Object*/) {
  1184. // Set x/y if position has changed
  1185. if (nextProps.position && (!this.props.position || nextProps.position.x !== this.props.position.x || nextProps.position.y !== this.props.position.y)) {
  1186. this.setState({ x: nextProps.position.x, y: nextProps.position.y });
  1187. }
  1188. }
  1189. }, {
  1190. key: 'componentWillUnmount',
  1191. value: function componentWillUnmount() {
  1192. this.setState({ dragging: false }); // prevents invariant if unmounted while dragging
  1193. }
  1194. }, {
  1195. key: 'render',
  1196. value: function render() /*: ReactElement<any>*/ {
  1197. var _classNames;
  1198. var style = {},
  1199. svgTransform = null;
  1200. // If this is controlled, we don't want to move it - unless it's dragging.
  1201. var controlled = Boolean(this.props.position);
  1202. var draggable = !controlled || this.state.dragging;
  1203. var position = this.props.position || this.props.defaultPosition;
  1204. var transformOpts = {
  1205. // Set left if horizontal drag is enabled
  1206. x: (0, _positionFns.canDragX)(this) && draggable ? this.state.x : position.x,
  1207. // Set top if vertical drag is enabled
  1208. y: (0, _positionFns.canDragY)(this) && draggable ? this.state.y : position.y
  1209. };
  1210. // If this element was SVG, we use the `transform` attribute.
  1211. if (this.state.isElementSVG) {
  1212. svgTransform = (0, _domFns.createSVGTransform)(transformOpts);
  1213. } else {
  1214. // Add a CSS transform to move the element around. This allows us to move the element around
  1215. // without worrying about whether or not it is relatively or absolutely positioned.
  1216. // If the item you are dragging already has a transform set, wrap it in a <span> so <Draggable>
  1217. // has a clean slate.
  1218. style = (0, _domFns.createCSSTransform)(transformOpts);
  1219. }
  1220. var _props = this.props,
  1221. defaultClassName = _props.defaultClassName,
  1222. defaultClassNameDragging = _props.defaultClassNameDragging,
  1223. defaultClassNameDragged = _props.defaultClassNameDragged;
  1224. // Mark with class while dragging
  1225. var className = (0, _classnames2.default)(this.props.children.props.className || '', defaultClassName, (_classNames = {}, _defineProperty(_classNames, defaultClassNameDragging, this.state.dragging), _defineProperty(_classNames, defaultClassNameDragged, this.state.dragged), _classNames));
  1226. // Reuse the child provided
  1227. // This makes it flexible to use whatever element is wanted (div, ul, etc)
  1228. return _react2.default.createElement(
  1229. _DraggableCore2.default,
  1230. _extends({}, this.props, { onStart: this.onDragStart, onDrag: this.onDrag, onStop: this.onDragStop }),
  1231. _react2.default.cloneElement(_react2.default.Children.only(this.props.children), {
  1232. className: className,
  1233. style: _extends({}, this.props.children.props.style, style),
  1234. transform: svgTransform
  1235. })
  1236. );
  1237. }
  1238. }]);
  1239. return Draggable;
  1240. }(_react2.default.Component);
  1241. Draggable.displayName = 'Draggable';
  1242. Draggable.propTypes = _extends({}, _DraggableCore2.default.propTypes, {
  1243. /**
  1244. * `axis` determines which axis the draggable can move.
  1245. *
  1246. * Note that all callbacks will still return data as normal. This only
  1247. * controls flushing to the DOM.
  1248. *
  1249. * 'both' allows movement horizontally and vertically.
  1250. * 'x' limits movement to horizontal axis.
  1251. * 'y' limits movement to vertical axis.
  1252. * 'none' limits all movement.
  1253. *
  1254. * Defaults to 'both'.
  1255. */
  1256. axis: _propTypes2.default.oneOf(['both', 'x', 'y', 'none']),
  1257. /**
  1258. * `bounds` determines the range of movement available to the element.
  1259. * Available values are:
  1260. *
  1261. * 'parent' restricts movement within the Draggable's parent node.
  1262. *
  1263. * Alternatively, pass an object with the following properties, all of which are optional:
  1264. *
  1265. * {left: LEFT_BOUND, right: RIGHT_BOUND, bottom: BOTTOM_BOUND, top: TOP_BOUND}
  1266. *
  1267. * All values are in px.
  1268. *
  1269. * Example:
  1270. *
  1271. * ```jsx
  1272. * let App = React.createClass({
  1273. * render: function () {
  1274. * return (
  1275. * <Draggable bounds={{right: 300, bottom: 300}}>
  1276. * <div>Content</div>
  1277. * </Draggable>
  1278. * );
  1279. * }
  1280. * });
  1281. * ```
  1282. */
  1283. bounds: _propTypes2.default.oneOfType([_propTypes2.default.shape({
  1284. left: _propTypes2.default.number,
  1285. right: _propTypes2.default.number,
  1286. top: _propTypes2.default.number,
  1287. bottom: _propTypes2.default.number
  1288. }), _propTypes2.default.string, _propTypes2.default.oneOf([false])]),
  1289. defaultClassName: _propTypes2.default.string,
  1290. defaultClassNameDragging: _propTypes2.default.string,
  1291. defaultClassNameDragged: _propTypes2.default.string,
  1292. /**
  1293. * `defaultPosition` specifies the x and y that the dragged item should start at
  1294. *
  1295. * Example:
  1296. *
  1297. * ```jsx
  1298. * let App = React.createClass({
  1299. * render: function () {
  1300. * return (
  1301. * <Draggable defaultPosition={{x: 25, y: 25}}>
  1302. * <div>I start with transformX: 25px and transformY: 25px;</div>
  1303. * </Draggable>
  1304. * );
  1305. * }
  1306. * });
  1307. * ```
  1308. */
  1309. defaultPosition: _propTypes2.default.shape({
  1310. x: _propTypes2.default.number,
  1311. y: _propTypes2.default.number
  1312. }),
  1313. /**
  1314. * `position`, if present, defines the current position of the element.
  1315. *
  1316. * This is similar to how form elements in React work - if no `position` is supplied, the component
  1317. * is uncontrolled.
  1318. *
  1319. * Example:
  1320. *
  1321. * ```jsx
  1322. * let App = React.createClass({
  1323. * render: function () {
  1324. * return (
  1325. * <Draggable position={{x: 25, y: 25}}>
  1326. * <div>I start with transformX: 25px and transformY: 25px;</div>
  1327. * </Draggable>
  1328. * );
  1329. * }
  1330. * });
  1331. * ```
  1332. */
  1333. position: _propTypes2.default.shape({
  1334. x: _propTypes2.default.number,
  1335. y: _propTypes2.default.number
  1336. }),
  1337. /**
  1338. * These properties should be defined on the child, not here.
  1339. */
  1340. className: _shims.dontSetMe,
  1341. style: _shims.dontSetMe,
  1342. transform: _shims.dontSetMe
  1343. });
  1344. Draggable.defaultProps = _extends({}, _DraggableCore2.default.defaultProps, {
  1345. axis: 'both',
  1346. bounds: false,
  1347. defaultClassName: 'react-draggable',
  1348. defaultClassNameDragging: 'react-draggable-dragging',
  1349. defaultClassNameDragged: 'react-draggable-dragged',
  1350. defaultPosition: { x: 0, y: 0 },
  1351. position: null
  1352. });
  1353. exports.default = Draggable;
  1354. /***/ }),
  1355. /* 14 */
  1356. /***/ (function(module, exports, __webpack_require__) {
  1357. "use strict";
  1358. /**
  1359. * Copyright 2013-present, Facebook, Inc.
  1360. * All rights reserved.
  1361. *
  1362. * This source code is licensed under the BSD-style license found in the
  1363. * LICENSE file in the root directory of this source tree. An additional grant
  1364. * of patent rights can be found in the PATENTS file in the same directory.
  1365. */
  1366. var emptyFunction = __webpack_require__(1);
  1367. var invariant = __webpack_require__(2);
  1368. var warning = __webpack_require__(8);
  1369. var ReactPropTypesSecret = __webpack_require__(3);
  1370. var checkPropTypes = __webpack_require__(15);
  1371. module.exports = function(isValidElement, throwOnDirectAccess) {
  1372. /* global Symbol */
  1373. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  1374. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  1375. /**
  1376. * Returns the iterator method function contained on the iterable object.
  1377. *
  1378. * Be sure to invoke the function with the iterable as context:
  1379. *
  1380. * var iteratorFn = getIteratorFn(myIterable);
  1381. * if (iteratorFn) {
  1382. * var iterator = iteratorFn.call(myIterable);
  1383. * ...
  1384. * }
  1385. *
  1386. * @param {?object} maybeIterable
  1387. * @return {?function}
  1388. */
  1389. function getIteratorFn(maybeIterable) {
  1390. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  1391. if (typeof iteratorFn === 'function') {
  1392. return iteratorFn;
  1393. }
  1394. }
  1395. /**
  1396. * Collection of methods that allow declaration and validation of props that are
  1397. * supplied to React components. Example usage:
  1398. *
  1399. * var Props = require('ReactPropTypes');
  1400. * var MyArticle = React.createClass({
  1401. * propTypes: {
  1402. * // An optional string prop named "description".
  1403. * description: Props.string,
  1404. *
  1405. * // A required enum prop named "category".
  1406. * category: Props.oneOf(['News','Photos']).isRequired,
  1407. *
  1408. * // A prop named "dialog" that requires an instance of Dialog.
  1409. * dialog: Props.instanceOf(Dialog).isRequired
  1410. * },
  1411. * render: function() { ... }
  1412. * });
  1413. *
  1414. * A more formal specification of how these methods are used:
  1415. *
  1416. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  1417. * decl := ReactPropTypes.{type}(.isRequired)?
  1418. *
  1419. * Each and every declaration produces a function with the same signature. This
  1420. * allows the creation of custom validation functions. For example:
  1421. *
  1422. * var MyLink = React.createClass({
  1423. * propTypes: {
  1424. * // An optional string or URI prop named "href".
  1425. * href: function(props, propName, componentName) {
  1426. * var propValue = props[propName];
  1427. * if (propValue != null && typeof propValue !== 'string' &&
  1428. * !(propValue instanceof URI)) {
  1429. * return new Error(
  1430. * 'Expected a string or an URI for ' + propName + ' in ' +
  1431. * componentName
  1432. * );
  1433. * }
  1434. * }
  1435. * },
  1436. * render: function() {...}
  1437. * });
  1438. *
  1439. * @internal
  1440. */
  1441. var ANONYMOUS = '<<anonymous>>';
  1442. // Important!
  1443. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  1444. var ReactPropTypes = {
  1445. array: createPrimitiveTypeChecker('array'),
  1446. bool: createPrimitiveTypeChecker('boolean'),
  1447. func: createPrimitiveTypeChecker('function'),
  1448. number: createPrimitiveTypeChecker('number'),
  1449. object: createPrimitiveTypeChecker('object'),
  1450. string: createPrimitiveTypeChecker('string'),
  1451. symbol: createPrimitiveTypeChecker('symbol'),
  1452. any: createAnyTypeChecker(),
  1453. arrayOf: createArrayOfTypeChecker,
  1454. element: createElementTypeChecker(),
  1455. instanceOf: createInstanceTypeChecker,
  1456. node: createNodeChecker(),
  1457. objectOf: createObjectOfTypeChecker,
  1458. oneOf: createEnumTypeChecker,
  1459. oneOfType: createUnionTypeChecker,
  1460. shape: createShapeTypeChecker
  1461. };
  1462. /**
  1463. * inlined Object.is polyfill to avoid requiring consumers ship their own
  1464. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  1465. */
  1466. /*eslint-disable no-self-compare*/
  1467. function is(x, y) {
  1468. // SameValue algorithm
  1469. if (x === y) {
  1470. // Steps 1-5, 7-10
  1471. // Steps 6.b-6.e: +0 != -0
  1472. return x !== 0 || 1 / x === 1 / y;
  1473. } else {
  1474. // Step 6.a: NaN == NaN
  1475. return x !== x && y !== y;
  1476. }
  1477. }
  1478. /*eslint-enable no-self-compare*/
  1479. /**
  1480. * We use an Error-like object for backward compatibility as people may call
  1481. * PropTypes directly and inspect their output. However, we don't use real
  1482. * Errors anymore. We don't inspect their stack anyway, and creating them
  1483. * is prohibitively expensive if they are created too often, such as what
  1484. * happens in oneOfType() for any type before the one that matched.
  1485. */
  1486. function PropTypeError(message) {
  1487. this.message = message;
  1488. this.stack = '';
  1489. }
  1490. // Make `instanceof Error` still work for returned errors.
  1491. PropTypeError.prototype = Error.prototype;
  1492. function createChainableTypeChecker(validate) {
  1493. if (Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production') {
  1494. var manualPropTypeCallCache = {};
  1495. var manualPropTypeWarningCount = 0;
  1496. }
  1497. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  1498. componentName = componentName || ANONYMOUS;
  1499. propFullName = propFullName || propName;
  1500. if (secret !== ReactPropTypesSecret) {
  1501. if (throwOnDirectAccess) {
  1502. // New behavior only for users of `prop-types` package
  1503. invariant(
  1504. false,
  1505. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  1506. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  1507. 'Read more at http://fb.me/use-check-prop-types'
  1508. );
  1509. } else if (Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production' && typeof console !== 'undefined') {
  1510. // Old behavior for people using React.PropTypes
  1511. var cacheKey = componentName + ':' + propName;
  1512. if (
  1513. !manualPropTypeCallCache[cacheKey] &&
  1514. // Avoid spamming the console because they are often not actionable except for lib authors
  1515. manualPropTypeWarningCount < 3
  1516. ) {
  1517. warning(
  1518. false,
  1519. 'You are manually calling a React.PropTypes validation ' +
  1520. 'function for the `%s` prop on `%s`. This is deprecated ' +
  1521. 'and will throw in the standalone `prop-types` package. ' +
  1522. 'You may be seeing this warning due to a third-party PropTypes ' +
  1523. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.',
  1524. propFullName,
  1525. componentName
  1526. );
  1527. manualPropTypeCallCache[cacheKey] = true;
  1528. manualPropTypeWarningCount++;
  1529. }
  1530. }
  1531. }
  1532. if (props[propName] == null) {
  1533. if (isRequired) {
  1534. if (props[propName] === null) {
  1535. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  1536. }
  1537. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  1538. }
  1539. return null;
  1540. } else {
  1541. return validate(props, propName, componentName, location, propFullName);
  1542. }
  1543. }
  1544. var chainedCheckType = checkType.bind(null, false);
  1545. chainedCheckType.isRequired = checkType.bind(null, true);
  1546. return chainedCheckType;
  1547. }
  1548. function createPrimitiveTypeChecker(expectedType) {
  1549. function validate(props, propName, componentName, location, propFullName, secret) {
  1550. var propValue = props[propName];
  1551. var propType = getPropType(propValue);
  1552. if (propType !== expectedType) {
  1553. // `propValue` being instance of, say, date/regexp, pass the 'object'
  1554. // check, but we can offer a more precise error message here rather than
  1555. // 'of type `object`'.
  1556. var preciseType = getPreciseType(propValue);
  1557. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  1558. }
  1559. return null;
  1560. }
  1561. return createChainableTypeChecker(validate);
  1562. }
  1563. function createAnyTypeChecker() {
  1564. return createChainableTypeChecker(emptyFunction.thatReturnsNull);
  1565. }
  1566. function createArrayOfTypeChecker(typeChecker) {
  1567. function validate(props, propName, componentName, location, propFullName) {
  1568. if (typeof typeChecker !== 'function') {
  1569. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  1570. }
  1571. var propValue = props[propName];
  1572. if (!Array.isArray(propValue)) {
  1573. var propType = getPropType(propValue);
  1574. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  1575. }
  1576. for (var i = 0; i < propValue.length; i++) {
  1577. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret);
  1578. if (error instanceof Error) {
  1579. return error;
  1580. }
  1581. }
  1582. return null;
  1583. }
  1584. return createChainableTypeChecker(validate);
  1585. }
  1586. function createElementTypeChecker() {
  1587. function validate(props, propName, componentName, location, propFullName) {
  1588. var propValue = props[propName];
  1589. if (!isValidElement(propValue)) {
  1590. var propType = getPropType(propValue);
  1591. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  1592. }
  1593. return null;
  1594. }
  1595. return createChainableTypeChecker(validate);
  1596. }
  1597. function createInstanceTypeChecker(expectedClass) {
  1598. function validate(props, propName, componentName, location, propFullName) {
  1599. if (!(props[propName] instanceof expectedClass)) {
  1600. var expectedClassName = expectedClass.name || ANONYMOUS;
  1601. var actualClassName = getClassName(props[propName]);
  1602. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  1603. }
  1604. return null;
  1605. }
  1606. return createChainableTypeChecker(validate);
  1607. }
  1608. function createEnumTypeChecker(expectedValues) {
  1609. if (!Array.isArray(expectedValues)) {
  1610. Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0;
  1611. return emptyFunction.thatReturnsNull;
  1612. }
  1613. function validate(props, propName, componentName, location, propFullName) {
  1614. var propValue = props[propName];
  1615. for (var i = 0; i < expectedValues.length; i++) {
  1616. if (is(propValue, expectedValues[i])) {
  1617. return null;
  1618. }
  1619. }
  1620. var valuesString = JSON.stringify(expectedValues);
  1621. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  1622. }
  1623. return createChainableTypeChecker(validate);
  1624. }
  1625. function createObjectOfTypeChecker(typeChecker) {
  1626. function validate(props, propName, componentName, location, propFullName) {
  1627. if (typeof typeChecker !== 'function') {
  1628. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  1629. }
  1630. var propValue = props[propName];
  1631. var propType = getPropType(propValue);
  1632. if (propType !== 'object') {
  1633. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  1634. }
  1635. for (var key in propValue) {
  1636. if (propValue.hasOwnProperty(key)) {
  1637. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  1638. if (error instanceof Error) {
  1639. return error;
  1640. }
  1641. }
  1642. }
  1643. return null;
  1644. }
  1645. return createChainableTypeChecker(validate);
  1646. }
  1647. function createUnionTypeChecker(arrayOfTypeCheckers) {
  1648. if (!Array.isArray(arrayOfTypeCheckers)) {
  1649. Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
  1650. return emptyFunction.thatReturnsNull;
  1651. }
  1652. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  1653. var checker = arrayOfTypeCheckers[i];
  1654. if (typeof checker !== 'function') {
  1655. warning(
  1656. false,
  1657. 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' +
  1658. 'received %s at index %s.',
  1659. getPostfixForTypeWarning(checker),
  1660. i
  1661. );
  1662. return emptyFunction.thatReturnsNull;
  1663. }
  1664. }
  1665. function validate(props, propName, componentName, location, propFullName) {
  1666. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  1667. var checker = arrayOfTypeCheckers[i];
  1668. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
  1669. return null;
  1670. }
  1671. }
  1672. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  1673. }
  1674. return createChainableTypeChecker(validate);
  1675. }
  1676. function createNodeChecker() {
  1677. function validate(props, propName, componentName, location, propFullName) {
  1678. if (!isNode(props[propName])) {
  1679. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  1680. }
  1681. return null;
  1682. }
  1683. return createChainableTypeChecker(validate);
  1684. }
  1685. function createShapeTypeChecker(shapeTypes) {
  1686. function validate(props, propName, componentName, location, propFullName) {
  1687. var propValue = props[propName];
  1688. var propType = getPropType(propValue);
  1689. if (propType !== 'object') {
  1690. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  1691. }
  1692. for (var key in shapeTypes) {
  1693. var checker = shapeTypes[key];
  1694. if (!checker) {
  1695. continue;
  1696. }
  1697. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret);
  1698. if (error) {
  1699. return error;
  1700. }
  1701. }
  1702. return null;
  1703. }
  1704. return createChainableTypeChecker(validate);
  1705. }
  1706. function isNode(propValue) {
  1707. switch (typeof propValue) {
  1708. case 'number':
  1709. case 'string':
  1710. case 'undefined':
  1711. return true;
  1712. case 'boolean':
  1713. return !propValue;
  1714. case 'object':
  1715. if (Array.isArray(propValue)) {
  1716. return propValue.every(isNode);
  1717. }
  1718. if (propValue === null || isValidElement(propValue)) {
  1719. return true;
  1720. }
  1721. var iteratorFn = getIteratorFn(propValue);
  1722. if (iteratorFn) {
  1723. var iterator = iteratorFn.call(propValue);
  1724. var step;
  1725. if (iteratorFn !== propValue.entries) {
  1726. while (!(step = iterator.next()).done) {
  1727. if (!isNode(step.value)) {
  1728. return false;
  1729. }
  1730. }
  1731. } else {
  1732. // Iterator will provide entry [k,v] tuples rather than values.
  1733. while (!(step = iterator.next()).done) {
  1734. var entry = step.value;
  1735. if (entry) {
  1736. if (!isNode(entry[1])) {
  1737. return false;
  1738. }
  1739. }
  1740. }
  1741. }
  1742. } else {
  1743. return false;
  1744. }
  1745. return true;
  1746. default:
  1747. return false;
  1748. }
  1749. }
  1750. function isSymbol(propType, propValue) {
  1751. // Native Symbol.
  1752. if (propType === 'symbol') {
  1753. return true;
  1754. }
  1755. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  1756. if (propValue['@@toStringTag'] === 'Symbol') {
  1757. return true;
  1758. }
  1759. // Fallback for non-spec compliant Symbols which are polyfilled.
  1760. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  1761. return true;
  1762. }
  1763. return false;
  1764. }
  1765. // Equivalent of `typeof` but with special handling for array and regexp.
  1766. function getPropType(propValue) {
  1767. var propType = typeof propValue;
  1768. if (Array.isArray(propValue)) {
  1769. return 'array';
  1770. }
  1771. if (propValue instanceof RegExp) {
  1772. // Old webkits (at least until Android 4.0) return 'function' rather than
  1773. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  1774. // passes PropTypes.object.
  1775. return 'object';
  1776. }
  1777. if (isSymbol(propType, propValue)) {
  1778. return 'symbol';
  1779. }
  1780. return propType;
  1781. }
  1782. // This handles more types than `getPropType`. Only used for error messages.
  1783. // See `createPrimitiveTypeChecker`.
  1784. function getPreciseType(propValue) {
  1785. if (typeof propValue === 'undefined' || propValue === null) {
  1786. return '' + propValue;
  1787. }
  1788. var propType = getPropType(propValue);
  1789. if (propType === 'object') {
  1790. if (propValue instanceof Date) {
  1791. return 'date';
  1792. } else if (propValue instanceof RegExp) {
  1793. return 'regexp';
  1794. }
  1795. }
  1796. return propType;
  1797. }
  1798. // Returns a string that is postfixed to a warning about an invalid type.
  1799. // For example, "undefined" or "of type array"
  1800. function getPostfixForTypeWarning(value) {
  1801. var type = getPreciseType(value);
  1802. switch (type) {
  1803. case 'array':
  1804. case 'object':
  1805. return 'an ' + type;
  1806. case 'boolean':
  1807. case 'date':
  1808. case 'regexp':
  1809. return 'a ' + type;
  1810. default:
  1811. return type;
  1812. }
  1813. }
  1814. // Returns class name of the object, if any.
  1815. function getClassName(propValue) {
  1816. if (!propValue.constructor || !propValue.constructor.name) {
  1817. return ANONYMOUS;
  1818. }
  1819. return propValue.constructor.name;
  1820. }
  1821. ReactPropTypes.checkPropTypes = checkPropTypes;
  1822. ReactPropTypes.PropTypes = ReactPropTypes;
  1823. return ReactPropTypes;
  1824. };
  1825. /***/ }),
  1826. /* 15 */
  1827. /***/ (function(module, exports, __webpack_require__) {
  1828. "use strict";
  1829. /**
  1830. * Copyright 2013-present, Facebook, Inc.
  1831. * All rights reserved.
  1832. *
  1833. * This source code is licensed under the BSD-style license found in the
  1834. * LICENSE file in the root directory of this source tree. An additional grant
  1835. * of patent rights can be found in the PATENTS file in the same directory.
  1836. */
  1837. if (Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production') {
  1838. var invariant = __webpack_require__(2);
  1839. var warning = __webpack_require__(8);
  1840. var ReactPropTypesSecret = __webpack_require__(3);
  1841. var loggedTypeFailures = {};
  1842. }
  1843. /**
  1844. * Assert that the values match with the type specs.
  1845. * Error messages are memorized and will only be shown once.
  1846. *
  1847. * @param {object} typeSpecs Map of name to a ReactPropType
  1848. * @param {object} values Runtime values that need to be type-checked
  1849. * @param {string} location e.g. "prop", "context", "child context"
  1850. * @param {string} componentName Name of the component for error messages.
  1851. * @param {?Function} getStack Returns the component stack.
  1852. * @private
  1853. */
  1854. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  1855. if (Object({"DRAGGABLE_DEBUG":undefined}).NODE_ENV !== 'production') {
  1856. for (var typeSpecName in typeSpecs) {
  1857. if (typeSpecs.hasOwnProperty(typeSpecName)) {
  1858. var error;
  1859. // Prop type validation may throw. In case they do, we don't want to
  1860. // fail the render phase where it didn't fail before. So we log it.
  1861. // After these have been cleaned up, we'll let them throw.
  1862. try {
  1863. // This is intentionally an invariant that gets caught. It's the same
  1864. // behavior as without this statement except with a better message.
  1865. invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName);
  1866. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
  1867. } catch (ex) {
  1868. error = ex;
  1869. }
  1870. warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error);
  1871. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  1872. // Only monitor this failure once because there tends to be a lot of the
  1873. // same error.
  1874. loggedTypeFailures[error.message] = true;
  1875. var stack = getStack ? getStack() : '';
  1876. warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : '');
  1877. }
  1878. }
  1879. }
  1880. }
  1881. }
  1882. module.exports = checkPropTypes;
  1883. /***/ }),
  1884. /* 16 */
  1885. /***/ (function(module, exports, __webpack_require__) {
  1886. "use strict";
  1887. /**
  1888. * Copyright 2013-present, Facebook, Inc.
  1889. * All rights reserved.
  1890. *
  1891. * This source code is licensed under the BSD-style license found in the
  1892. * LICENSE file in the root directory of this source tree. An additional grant
  1893. * of patent rights can be found in the PATENTS file in the same directory.
  1894. */
  1895. var emptyFunction = __webpack_require__(1);
  1896. var invariant = __webpack_require__(2);
  1897. var ReactPropTypesSecret = __webpack_require__(3);
  1898. module.exports = function() {
  1899. function shim(props, propName, componentName, location, propFullName, secret) {
  1900. if (secret === ReactPropTypesSecret) {
  1901. // It is still safe when called from React.
  1902. return;
  1903. }
  1904. invariant(
  1905. false,
  1906. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  1907. 'Use PropTypes.checkPropTypes() to call them. ' +
  1908. 'Read more at http://fb.me/use-check-prop-types'
  1909. );
  1910. };
  1911. shim.isRequired = shim;
  1912. function getShim() {
  1913. return shim;
  1914. };
  1915. // Important!
  1916. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  1917. var ReactPropTypes = {
  1918. array: shim,
  1919. bool: shim,
  1920. func: shim,
  1921. number: shim,
  1922. object: shim,
  1923. string: shim,
  1924. symbol: shim,
  1925. any: shim,
  1926. arrayOf: getShim,
  1927. element: shim,
  1928. instanceOf: getShim,
  1929. node: shim,
  1930. objectOf: getShim,
  1931. oneOf: getShim,
  1932. oneOfType: getShim,
  1933. shape: getShim
  1934. };
  1935. ReactPropTypes.checkPropTypes = emptyFunction;
  1936. ReactPropTypes.PropTypes = ReactPropTypes;
  1937. return ReactPropTypes;
  1938. };
  1939. /***/ }),
  1940. /* 17 */
  1941. /***/ (function(module, exports, __webpack_require__) {
  1942. var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
  1943. Copyright (c) 2016 Jed Watson.
  1944. Licensed under the MIT License (MIT), see
  1945. http://jedwatson.github.io/classnames
  1946. */
  1947. /* global define */
  1948. (function () {
  1949. 'use strict';
  1950. var hasOwn = {}.hasOwnProperty;
  1951. function classNames () {
  1952. var classes = [];
  1953. for (var i = 0; i < arguments.length; i++) {
  1954. var arg = arguments[i];
  1955. if (!arg) continue;
  1956. var argType = typeof arg;
  1957. if (argType === 'string' || argType === 'number') {
  1958. classes.push(arg);
  1959. } else if (Array.isArray(arg)) {
  1960. classes.push(classNames.apply(null, arg));
  1961. } else if (argType === 'object') {
  1962. for (var key in arg) {
  1963. if (hasOwn.call(arg, key) && arg[key]) {
  1964. classes.push(key);
  1965. }
  1966. }
  1967. }
  1968. }
  1969. return classes.join(' ');
  1970. }
  1971. if (typeof module !== 'undefined' && module.exports) {
  1972. module.exports = classNames;
  1973. } else if (true) {
  1974. // register as 'classnames', consistent with npm package name
  1975. !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function () {
  1976. return classNames;
  1977. }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
  1978. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  1979. } else {
  1980. window.classNames = classNames;
  1981. }
  1982. }());
  1983. /***/ }),
  1984. /* 18 */
  1985. /***/ (function(module, exports, __webpack_require__) {
  1986. "use strict";
  1987. Object.defineProperty(exports, "__esModule", {
  1988. value: true
  1989. });
  1990. exports.getPrefix = getPrefix;
  1991. exports.browserPrefixToKey = browserPrefixToKey;
  1992. exports.browserPrefixToStyle = browserPrefixToStyle;
  1993. var prefixes = ['Moz', 'Webkit', 'O', 'ms'];
  1994. function getPrefix() /*: string*/ {
  1995. var prop /*: string*/ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'transform';
  1996. // Checking specifically for 'window.document' is for pseudo-browser server-side
  1997. // environments that define 'window' as the global context.
  1998. // E.g. React-rails (see https://github.com/reactjs/react-rails/pull/84)
  1999. if (typeof window === 'undefined' || typeof window.document === 'undefined') return '';
  2000. var style = window.document.documentElement.style;
  2001. if (prop in style) return '';
  2002. for (var i = 0; i < prefixes.length; i++) {
  2003. if (browserPrefixToKey(prop, prefixes[i]) in style) return prefixes[i];
  2004. }
  2005. return '';
  2006. }
  2007. function browserPrefixToKey(prop /*: string*/, prefix /*: string*/) /*: string*/ {
  2008. return prefix ? '' + prefix + kebabToTitleCase(prop) : prop;
  2009. }
  2010. function browserPrefixToStyle(prop /*: string*/, prefix /*: string*/) /*: string*/ {
  2011. return prefix ? '-' + prefix.toLowerCase() + '-' + prop : prop;
  2012. }
  2013. function kebabToTitleCase(str /*: string*/) /*: string*/ {
  2014. var out = '';
  2015. var shouldCapitalize = true;
  2016. for (var i = 0; i < str.length; i++) {
  2017. if (shouldCapitalize) {
  2018. out += str[i].toUpperCase();
  2019. shouldCapitalize = false;
  2020. } else if (str[i] === '-') {
  2021. shouldCapitalize = true;
  2022. } else {
  2023. out += str[i];
  2024. }
  2025. }
  2026. return out;
  2027. }
  2028. // Default export is the prefix itself, like 'Moz', 'Webkit', etc
  2029. // Note that you may have to re-test for certain things; for instance, Chrome 50
  2030. // can handle unprefixed `transform`, but not unprefixed `user-select`
  2031. exports.default = getPrefix();
  2032. /***/ }),
  2033. /* 19 */
  2034. /***/ (function(module, exports) {
  2035. // shim for using process in browser
  2036. var process = module.exports = {};
  2037. // cached from whatever global is present so that test runners that stub it
  2038. // don't break things. But we need to wrap it in a try catch in case it is
  2039. // wrapped in strict mode code which doesn't define any globals. It's inside a
  2040. // function because try/catches deoptimize in certain engines.
  2041. var cachedSetTimeout;
  2042. var cachedClearTimeout;
  2043. function defaultSetTimout() {
  2044. throw new Error('setTimeout has not been defined');
  2045. }
  2046. function defaultClearTimeout () {
  2047. throw new Error('clearTimeout has not been defined');
  2048. }
  2049. (function () {
  2050. try {
  2051. if (typeof setTimeout === 'function') {
  2052. cachedSetTimeout = setTimeout;
  2053. } else {
  2054. cachedSetTimeout = defaultSetTimout;
  2055. }
  2056. } catch (e) {
  2057. cachedSetTimeout = defaultSetTimout;
  2058. }
  2059. try {
  2060. if (typeof clearTimeout === 'function') {
  2061. cachedClearTimeout = clearTimeout;
  2062. } else {
  2063. cachedClearTimeout = defaultClearTimeout;
  2064. }
  2065. } catch (e) {
  2066. cachedClearTimeout = defaultClearTimeout;
  2067. }
  2068. } ())
  2069. function runTimeout(fun) {
  2070. if (cachedSetTimeout === setTimeout) {
  2071. //normal enviroments in sane situations
  2072. return setTimeout(fun, 0);
  2073. }
  2074. // if setTimeout wasn't available but was latter defined
  2075. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  2076. cachedSetTimeout = setTimeout;
  2077. return setTimeout(fun, 0);
  2078. }
  2079. try {
  2080. // when when somebody has screwed with setTimeout but no I.E. maddness
  2081. return cachedSetTimeout(fun, 0);
  2082. } catch(e){
  2083. try {
  2084. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2085. return cachedSetTimeout.call(null, fun, 0);
  2086. } catch(e){
  2087. // 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
  2088. return cachedSetTimeout.call(this, fun, 0);
  2089. }
  2090. }
  2091. }
  2092. function runClearTimeout(marker) {
  2093. if (cachedClearTimeout === clearTimeout) {
  2094. //normal enviroments in sane situations
  2095. return clearTimeout(marker);
  2096. }
  2097. // if clearTimeout wasn't available but was latter defined
  2098. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  2099. cachedClearTimeout = clearTimeout;
  2100. return clearTimeout(marker);
  2101. }
  2102. try {
  2103. // when when somebody has screwed with setTimeout but no I.E. maddness
  2104. return cachedClearTimeout(marker);
  2105. } catch (e){
  2106. try {
  2107. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  2108. return cachedClearTimeout.call(null, marker);
  2109. } catch (e){
  2110. // 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.
  2111. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  2112. return cachedClearTimeout.call(this, marker);
  2113. }
  2114. }
  2115. }
  2116. var queue = [];
  2117. var draining = false;
  2118. var currentQueue;
  2119. var queueIndex = -1;
  2120. function cleanUpNextTick() {
  2121. if (!draining || !currentQueue) {
  2122. return;
  2123. }
  2124. draining = false;
  2125. if (currentQueue.length) {
  2126. queue = currentQueue.concat(queue);
  2127. } else {
  2128. queueIndex = -1;
  2129. }
  2130. if (queue.length) {
  2131. drainQueue();
  2132. }
  2133. }
  2134. function drainQueue() {
  2135. if (draining) {
  2136. return;
  2137. }
  2138. var timeout = runTimeout(cleanUpNextTick);
  2139. draining = true;
  2140. var len = queue.length;
  2141. while(len) {
  2142. currentQueue = queue;
  2143. queue = [];
  2144. while (++queueIndex < len) {
  2145. if (currentQueue) {
  2146. currentQueue[queueIndex].run();
  2147. }
  2148. }
  2149. queueIndex = -1;
  2150. len = queue.length;
  2151. }
  2152. currentQueue = null;
  2153. draining = false;
  2154. runClearTimeout(timeout);
  2155. }
  2156. process.nextTick = function (fun) {
  2157. var args = new Array(arguments.length - 1);
  2158. if (arguments.length > 1) {
  2159. for (var i = 1; i < arguments.length; i++) {
  2160. args[i - 1] = arguments[i];
  2161. }
  2162. }
  2163. queue.push(new Item(fun, args));
  2164. if (queue.length === 1 && !draining) {
  2165. runTimeout(drainQueue);
  2166. }
  2167. };
  2168. // v8 likes predictible objects
  2169. function Item(fun, array) {
  2170. this.fun = fun;
  2171. this.array = array;
  2172. }
  2173. Item.prototype.run = function () {
  2174. this.fun.apply(null, this.array);
  2175. };
  2176. process.title = 'browser';
  2177. process.browser = true;
  2178. process.env = {};
  2179. process.argv = [];
  2180. process.version = ''; // empty string to avoid regexp issues
  2181. process.versions = {};
  2182. function noop() {}
  2183. process.on = noop;
  2184. process.addListener = noop;
  2185. process.once = noop;
  2186. process.off = noop;
  2187. process.removeListener = noop;
  2188. process.removeAllListeners = noop;
  2189. process.emit = noop;
  2190. process.prependListener = noop;
  2191. process.prependOnceListener = noop;
  2192. process.listeners = function (name) { return [] }
  2193. process.binding = function (name) {
  2194. throw new Error('process.binding is not supported');
  2195. };
  2196. process.cwd = function () { return '/' };
  2197. process.chdir = function (dir) {
  2198. throw new Error('process.chdir is not supported');
  2199. };
  2200. process.umask = function() { return 0; };
  2201. /***/ })
  2202. /******/ ]);
  2203. });
  2204. //# sourceMappingURL=react-draggable.js.map