@elliemae/ds-query-builder 1.60.0 → 2.0.0-alpha.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/cjs/DSQueryBuilder.js +58 -151
  2. package/cjs/components/AndOrController/AndOrController.js +126 -162
  3. package/cjs/components/ConditionController/ConditionController.js +40 -60
  4. package/cjs/components/DisplayOutput/DisplayOutput.js +62 -83
  5. package/cjs/components/DragContainerController/DragContainerController.js +20 -21
  6. package/cjs/components/DragControllerRow/DragControllerRow.js +33 -23
  7. package/cjs/components/FieldControllerRow/FieldControllerRow.js +14 -19
  8. package/cjs/components/Nestable/Nestable.js +243 -283
  9. package/cjs/components/Nestable/NestableItem.js +61 -52
  10. package/cjs/components/Nestable/actions/events.js +53 -35
  11. package/cjs/components/Nestable/actions/getItemOptions.js +14 -12
  12. package/cjs/components/Nestable/actions/getPaths.js +46 -38
  13. package/cjs/components/Nestable/actions/index.js +21 -26
  14. package/cjs/components/Nestable/actions/moveItem.js +26 -16
  15. package/cjs/components/Nestable/actions/paths.js +48 -40
  16. package/cjs/components/Nestable/actions/tryDecreaseDepth.js +12 -12
  17. package/cjs/components/Nestable/actions/tryIncreaseDepth.js +14 -14
  18. package/cjs/components/Nestable/index.js +2 -25
  19. package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +1 -2
  20. package/cjs/components/QueryBuilderImpl.js +216 -283
  21. package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +59 -77
  22. package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +154 -174
  23. package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +16 -11
  24. package/cjs/components/format/format.js +27 -39
  25. package/cjs/components/format/sqlFormat.js +35 -32
  26. package/cjs/components/format/sqlSafeFormat.js +38 -35
  27. package/cjs/components/format/xmlFormat.js +35 -32
  28. package/cjs/components/helpers/actions.js +108 -93
  29. package/cjs/components/helpers/constants.js +3 -4
  30. package/cjs/components/helpers/dependencies.js +36 -26
  31. package/cjs/components/helpers/selectors.js +18 -19
  32. package/cjs/components/helpers/store.js +87 -109
  33. package/cjs/components/helpers/types.js +9 -10
  34. package/cjs/index.js +19 -76
  35. package/cjs/propTypes.js +4 -5
  36. package/esm/DSQueryBuilder.js +37 -130
  37. package/esm/components/AndOrController/AndOrController.js +120 -152
  38. package/esm/components/ConditionController/ConditionController.js +37 -57
  39. package/esm/components/DisplayOutput/DisplayOutput.js +61 -76
  40. package/esm/components/DragContainerController/DragContainerController.js +20 -21
  41. package/esm/components/DragControllerRow/DragControllerRow.js +27 -17
  42. package/esm/components/FieldControllerRow/FieldControllerRow.js +13 -18
  43. package/esm/components/Nestable/Nestable.js +235 -268
  44. package/esm/components/Nestable/NestableItem.js +58 -48
  45. package/esm/components/Nestable/actions/events.js +52 -34
  46. package/esm/components/Nestable/actions/getItemOptions.js +14 -12
  47. package/esm/components/Nestable/actions/getPaths.js +46 -33
  48. package/esm/components/Nestable/actions/index.js +0 -5
  49. package/esm/components/Nestable/actions/moveItem.js +23 -13
  50. package/esm/components/Nestable/actions/paths.js +48 -35
  51. package/esm/components/Nestable/actions/tryDecreaseDepth.js +12 -12
  52. package/esm/components/Nestable/actions/tryIncreaseDepth.js +14 -14
  53. package/esm/components/Nestable/index.js +0 -23
  54. package/esm/components/QueryBuilderContext/QueryBuilderContext.js +1 -2
  55. package/esm/components/QueryBuilderImpl.js +204 -265
  56. package/esm/components/QueryBuilderItem/QueryBuilderItem.js +52 -70
  57. package/esm/components/QueryBuilderRow/QueryBuilderRow.js +149 -164
  58. package/esm/components/ToolBarAnimation/ToolBarAnimation.js +16 -10
  59. package/esm/components/format/format.js +19 -27
  60. package/esm/components/format/sqlFormat.js +34 -31
  61. package/esm/components/format/sqlSafeFormat.js +37 -34
  62. package/esm/components/format/xmlFormat.js +34 -31
  63. package/esm/components/helpers/actions.js +100 -85
  64. package/esm/components/helpers/constants.js +3 -4
  65. package/esm/components/helpers/dependencies.js +33 -21
  66. package/esm/components/helpers/selectors.js +5 -6
  67. package/esm/components/helpers/store.js +84 -104
  68. package/esm/components/helpers/types.js +9 -10
  69. package/esm/index.js +0 -57
  70. package/esm/propTypes.js +1 -2
  71. package/package.json +173 -15
  72. package/types/DSQueryBuilder.d.ts +211 -0
  73. package/types/components/AndOrController/AndOrController.d.ts +38 -0
  74. package/types/components/ConditionController/ConditionController.d.ts +16 -0
  75. package/types/components/DisplayOutput/DisplayOutput.d.ts +7 -0
  76. package/types/components/DragContainerController/DragContainerController.d.ts +9 -0
  77. package/types/components/DragControllerRow/DragControllerRow.d.ts +9 -0
  78. package/types/components/FieldControllerRow/FieldControllerRow.d.ts +9 -0
  79. package/types/components/Nestable/Nestable.d.ts +51 -0
  80. package/types/components/Nestable/NestableItem.d.ts +12 -0
  81. package/types/components/Nestable/actions/events.d.ts +6 -0
  82. package/types/components/Nestable/actions/getItemOptions.d.ts +11 -0
  83. package/types/components/Nestable/actions/getPaths.d.ts +5 -0
  84. package/types/components/Nestable/actions/index.d.ts +6 -0
  85. package/types/components/Nestable/actions/moveItem.d.ts +5 -0
  86. package/types/components/Nestable/actions/paths.d.ts +5 -0
  87. package/types/components/Nestable/actions/tryDecreaseDepth.d.ts +1 -0
  88. package/types/components/Nestable/actions/tryIncreaseDepth.d.ts +1 -0
  89. package/types/components/Nestable/index.d.ts +2 -0
  90. package/types/components/QueryBuilderContext/QueryBuilderContext.d.ts +2 -0
  91. package/types/components/QueryBuilderImpl.d.ts +49 -0
  92. package/types/components/QueryBuilderItem/QueryBuilderItem.d.ts +5 -0
  93. package/types/components/QueryBuilderRow/QueryBuilderRow.d.ts +12 -0
  94. package/types/components/ToolBarAnimation/ToolBarAnimation.d.ts +3 -0
  95. package/types/components/format/format.d.ts +26 -0
  96. package/types/components/format/sqlFormat.d.ts +5 -0
  97. package/types/components/format/sqlSafeFormat.d.ts +6 -0
  98. package/types/components/format/xmlFormat.d.ts +5 -0
  99. package/types/components/helpers/actions.d.ts +63 -0
  100. package/types/components/helpers/constants.d.ts +3 -0
  101. package/types/components/helpers/dependencies.d.ts +1 -0
  102. package/types/components/helpers/selectors.d.ts +20 -0
  103. package/types/components/helpers/store.d.ts +144 -0
  104. package/types/components/helpers/types.d.ts +50 -0
  105. package/types/index.d.ts +2 -0
  106. package/types/propTypes.d.ts +156 -0
  107. package/DSQueryBuilder/package.json +0 -10
  108. package/cjs/DSQueryBuilder.js.map +0 -1
  109. package/cjs/components/AndOrController/AndOrController.js.map +0 -1
  110. package/cjs/components/ConditionController/ConditionController.js.map +0 -1
  111. package/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -1
  112. package/cjs/components/DragContainerController/DragContainerController.js.map +0 -1
  113. package/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -1
  114. package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -1
  115. package/cjs/components/Nestable/Nestable.js.map +0 -1
  116. package/cjs/components/Nestable/NestableItem.js.map +0 -1
  117. package/cjs/components/Nestable/actions/events.js.map +0 -1
  118. package/cjs/components/Nestable/actions/getItemOptions.js.map +0 -1
  119. package/cjs/components/Nestable/actions/getPaths.js.map +0 -1
  120. package/cjs/components/Nestable/actions/index.js.map +0 -1
  121. package/cjs/components/Nestable/actions/moveItem.js.map +0 -1
  122. package/cjs/components/Nestable/actions/paths.js.map +0 -1
  123. package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -1
  124. package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -1
  125. package/cjs/components/Nestable/index.js.map +0 -1
  126. package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -1
  127. package/cjs/components/QueryBuilderImpl.js.map +0 -1
  128. package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -1
  129. package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -1
  130. package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -1
  131. package/cjs/components/format/format.js.map +0 -1
  132. package/cjs/components/format/sqlFormat.js.map +0 -1
  133. package/cjs/components/format/sqlSafeFormat.js.map +0 -1
  134. package/cjs/components/format/xmlFormat.js.map +0 -1
  135. package/cjs/components/helpers/actions.js.map +0 -1
  136. package/cjs/components/helpers/constants.js.map +0 -1
  137. package/cjs/components/helpers/dependencies.js.map +0 -1
  138. package/cjs/components/helpers/selectors.js.map +0 -1
  139. package/cjs/components/helpers/store.js.map +0 -1
  140. package/cjs/components/helpers/types.js.map +0 -1
  141. package/cjs/index.js.map +0 -1
  142. package/cjs/propTypes.js.map +0 -1
  143. package/components/AndOrController/AndOrController/package.json +0 -10
  144. package/components/ConditionController/ConditionController/package.json +0 -10
  145. package/components/DisplayOutput/DisplayOutput/package.json +0 -10
  146. package/components/DragContainerController/DragContainerController/package.json +0 -10
  147. package/components/DragControllerRow/DragControllerRow/package.json +0 -10
  148. package/components/FieldControllerRow/FieldControllerRow/package.json +0 -10
  149. package/components/Nestable/Nestable/package.json +0 -10
  150. package/components/Nestable/NestableItem/package.json +0 -10
  151. package/components/Nestable/actions/events/package.json +0 -10
  152. package/components/Nestable/actions/getItemOptions/package.json +0 -10
  153. package/components/Nestable/actions/getPaths/package.json +0 -10
  154. package/components/Nestable/actions/moveItem/package.json +0 -10
  155. package/components/Nestable/actions/package.json +0 -10
  156. package/components/Nestable/actions/paths/package.json +0 -10
  157. package/components/Nestable/actions/tryDecreaseDepth/package.json +0 -10
  158. package/components/Nestable/actions/tryIncreaseDepth/package.json +0 -10
  159. package/components/Nestable/package.json +0 -10
  160. package/components/QueryBuilderContext/QueryBuilderContext/package.json +0 -10
  161. package/components/QueryBuilderImpl/package.json +0 -10
  162. package/components/QueryBuilderItem/QueryBuilderItem/package.json +0 -10
  163. package/components/QueryBuilderRow/QueryBuilderRow/package.json +0 -10
  164. package/components/ToolBarAnimation/ToolBarAnimation/package.json +0 -10
  165. package/components/format/format/package.json +0 -10
  166. package/components/format/sqlFormat/package.json +0 -10
  167. package/components/format/sqlSafeFormat/package.json +0 -10
  168. package/components/format/xmlFormat/package.json +0 -10
  169. package/components/helpers/actions/package.json +0 -10
  170. package/components/helpers/constants/package.json +0 -10
  171. package/components/helpers/dependencies/package.json +0 -10
  172. package/components/helpers/selectors/package.json +0 -10
  173. package/components/helpers/store/package.json +0 -10
  174. package/components/helpers/types/package.json +0 -10
  175. package/esm/DSQueryBuilder.js.map +0 -1
  176. package/esm/components/AndOrController/AndOrController.js.map +0 -1
  177. package/esm/components/ConditionController/ConditionController.js.map +0 -1
  178. package/esm/components/DisplayOutput/DisplayOutput.js.map +0 -1
  179. package/esm/components/DragContainerController/DragContainerController.js.map +0 -1
  180. package/esm/components/DragControllerRow/DragControllerRow.js.map +0 -1
  181. package/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -1
  182. package/esm/components/Nestable/Nestable.js.map +0 -1
  183. package/esm/components/Nestable/NestableItem.js.map +0 -1
  184. package/esm/components/Nestable/actions/events.js.map +0 -1
  185. package/esm/components/Nestable/actions/getItemOptions.js.map +0 -1
  186. package/esm/components/Nestable/actions/getPaths.js.map +0 -1
  187. package/esm/components/Nestable/actions/index.js.map +0 -1
  188. package/esm/components/Nestable/actions/moveItem.js.map +0 -1
  189. package/esm/components/Nestable/actions/paths.js.map +0 -1
  190. package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -1
  191. package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -1
  192. package/esm/components/Nestable/index.js.map +0 -1
  193. package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -1
  194. package/esm/components/QueryBuilderImpl.js.map +0 -1
  195. package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -1
  196. package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -1
  197. package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -1
  198. package/esm/components/format/format.js.map +0 -1
  199. package/esm/components/format/sqlFormat.js.map +0 -1
  200. package/esm/components/format/sqlSafeFormat.js.map +0 -1
  201. package/esm/components/format/xmlFormat.js.map +0 -1
  202. package/esm/components/helpers/actions.js.map +0 -1
  203. package/esm/components/helpers/constants.js.map +0 -1
  204. package/esm/components/helpers/dependencies.js.map +0 -1
  205. package/esm/components/helpers/selectors.js.map +0 -1
  206. package/esm/components/helpers/store.js.map +0 -1
  207. package/esm/components/helpers/types.js.map +0 -1
  208. package/esm/index.js.map +0 -1
  209. package/esm/propTypes.js.map +0 -1
  210. package/propTypes/package.json +0 -10
@@ -1,12 +1,15 @@
1
+ import 'core-js/modules/esnext.async-iterator.filter.js';
2
+ import 'core-js/modules/esnext.iterator.filter.js';
3
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
4
+ import 'core-js/modules/esnext.iterator.for-each.js';
5
+ import _jsx from '@babel/runtime/helpers/esm/jsx';
1
6
  import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
- import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
3
- import _createClass from '@babel/runtime/helpers/esm/createClass';
4
- import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
5
- import _inherits from '@babel/runtime/helpers/esm/inherits';
6
- import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
7
- import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
8
- import React, { Component } from 'react';
9
- import PropTypes from 'prop-types';
7
+ import 'core-js/modules/esnext.async-iterator.find.js';
8
+ import 'core-js/modules/esnext.iterator.constructor.js';
9
+ import 'core-js/modules/esnext.iterator.find.js';
10
+ import 'core-js/modules/esnext.async-iterator.map.js';
11
+ import 'core-js/modules/esnext.iterator.map.js';
12
+ import { Component } from 'react';
10
13
  import cn from 'classnames';
11
14
  import { listWithChildren } from '@elliemae/ds-shared/utils';
12
15
  import { isEqualWith } from '@elliemae/ds-utilities';
@@ -17,99 +20,79 @@ import { getItemDepth, getPathById, getItemByPath, getSplicePath, getRealNextPat
17
20
  import { onDragStart, onDragEnd, onMouseMove, onMouseEnter, onToggleCollapse, onKeyDown } from './actions/events.js';
18
21
  import { getItemOptions } from './actions/getItemOptions.js';
19
22
  import NestableItem from './NestableItem.js';
20
- import 'react-addons-update';
21
- import '@babel/runtime/helpers/esm/toConsumableArray';
22
- import '@babel/runtime/helpers/esm/extends';
23
23
 
24
24
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
25
25
 
26
26
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
27
27
 
28
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
28
+ const shallowCompare = (instance, nextProps, nextState) => !isEqualWith(instance.props, nextProps) || !isEqualWith(instance.state, nextState);
29
29
 
30
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
30
+ class Nestable extends Component {
31
+ constructor(props) {
32
+ super(props);
31
33
 
32
- var shallowCompare = function shallowCompare(instance, nextProps, nextState) {
33
- return !isEqualWith(instance.props, nextProps) || !isEqualWith(instance.state, nextState);
34
- };
35
-
36
- var Nestable = /*#__PURE__*/function (_Component) {
37
- _inherits(Nestable, _Component);
38
-
39
- var _super = _createSuper(Nestable);
40
-
41
- function Nestable(props) {
42
- var _this;
43
-
44
- _classCallCheck(this, Nestable);
45
-
46
- _this = _super.call(this, props);
47
-
48
- _this.onDragStart = function (e, item) {
49
- onDragStart.call(_assertThisInitialized(_this), e, item);
34
+ this.onDragStart = (e, item) => {
35
+ onDragStart.call(this, e, item);
50
36
  };
51
37
 
52
- _this.onDragEnd = function (e, isCancel) {
53
- return onDragEnd.call(_assertThisInitialized(_this), e, isCancel);
54
- };
38
+ this.onDragEnd = (e, isCancel) => onDragEnd.call(this, e, isCancel);
55
39
 
56
- _this.onMouseMove = function (e) {
57
- return onMouseMove.call(_assertThisInitialized(_this), e);
58
- };
40
+ this.onMouseMove = e => onMouseMove.call(this, e);
59
41
 
60
- _this.onMouseEnter = function (e, item) {
61
- return onMouseEnter.call(_assertThisInitialized(_this), e, item);
62
- };
42
+ this.onMouseEnter = (e, item) => onMouseEnter.call(this, e, item);
63
43
 
64
- _this.onToggleCollapse = function (item, isGetter) {
65
- return onToggleCollapse.call(_assertThisInitialized(_this), item, isGetter);
66
- };
44
+ this.onToggleCollapse = (item, isGetter) => onToggleCollapse.call(this, item, isGetter);
67
45
 
68
- _this.onKeyDown = function (e) {
69
- return onKeyDown.call(_assertThisInitialized(_this), e);
70
- };
46
+ this.onKeyDown = e => onKeyDown.call(this, e);
71
47
 
72
- _this.getDefaultItems = function () {
73
- var items = _this.state.items;
48
+ this.getDefaultItems = () => {
49
+ const {
50
+ items
51
+ } = this.state;
74
52
  return items;
75
53
  };
76
54
 
77
- _this.getItemDepth = function (item) {
78
- return getItemDepth.call(_assertThisInitialized(_this), item);
79
- };
55
+ this.getItemDepth = item => getItemDepth.call(this, item);
80
56
 
81
- _this.startTrackMouse = function () {
82
- document.addEventListener('mousemove', _this.onMouseMove);
83
- document.addEventListener('mouseup', _this.onDragEnd);
84
- document.addEventListener('keydown', _this.onKeyDown);
57
+ this.startTrackMouse = () => {
58
+ document.addEventListener('mousemove', this.onMouseMove);
59
+ document.addEventListener('mouseup', this.onDragEnd);
60
+ document.addEventListener('keydown', this.onKeyDown);
85
61
  };
86
62
 
87
- _this.stopTrackMouse = function () {
88
- document.removeEventListener('mousemove', _this.onMouseMove);
89
- document.removeEventListener('mouseup', _this.onDragEnd);
90
- document.removeEventListener('keydown', _this.onKeyDown);
91
- _this.elCopyStyles = null;
63
+ this.stopTrackMouse = () => {
64
+ document.removeEventListener('mousemove', this.onMouseMove);
65
+ document.removeEventListener('mouseup', this.onDragEnd);
66
+ document.removeEventListener('keydown', this.onKeyDown);
67
+ this.elCopyStyles = null;
92
68
  };
93
69
 
94
- _this.isCollapsed = function (item) {
95
- var collapsed = _this.props.collapsed;
96
- var collapsedGroups = _this.state.collapsedGroups;
70
+ this.isCollapsed = item => {
71
+ const {
72
+ collapsed
73
+ } = this.props;
74
+ const {
75
+ collapsedGroups
76
+ } = this.state;
97
77
  return !!(collapsedGroups.indexOf(item.id) > -1 ^ collapsed);
98
78
  };
99
79
 
100
- _this.checkFilterChildren = function (items) {
101
- return items.find(function (current) {
102
- var type = current.element.type,
103
- children = current.children;
104
- if (type === 'filter' && children.length > 0) return true;
105
- return _this.checkFilterChildren(children);
106
- });
107
- };
108
-
109
- _this.dragRevert = function () {
110
- var itemsOld = _this.state.itemsOld;
111
-
112
- _this.setState({
80
+ this.checkFilterChildren = items => items.find(current => {
81
+ const {
82
+ element: {
83
+ type
84
+ },
85
+ children
86
+ } = current;
87
+ if (type === 'filter' && children.length > 0) return true;
88
+ return this.checkFilterChildren(children);
89
+ });
90
+
91
+ this.dragRevert = () => {
92
+ const {
93
+ itemsOld
94
+ } = this.state;
95
+ this.setState({
113
96
  items: itemsOld,
114
97
  itemsOld: null,
115
98
  dragItem: null,
@@ -117,18 +100,18 @@ var Nestable = /*#__PURE__*/function (_Component) {
117
100
  });
118
101
  };
119
102
 
120
- _this.state = {
103
+ this.state = {
121
104
  items: [],
122
105
  itemsOld: null,
123
106
  dragItem: null,
124
107
  isDirty: false,
125
108
  collapsedGroups: [],
126
- stopTrackingMouse: _this.stopTrackMouse.bind(_assertThisInitialized(_this)),
109
+ stopTrackingMouse: this.stopTrackMouse.bind(this),
127
110
  oldProps: props
128
111
  };
129
- _this.el = null;
130
- _this.elCopyStyles = null;
131
- _this.mouse = {
112
+ this.el = null;
113
+ this.elCopyStyles = null;
114
+ this.mouse = {
132
115
  last: {
133
116
  x: 0
134
117
  },
@@ -136,210 +119,194 @@ var Nestable = /*#__PURE__*/function (_Component) {
136
119
  x: 0
137
120
  }
138
121
  };
139
- return _this;
140
122
  }
141
123
 
142
- _createClass(Nestable, [{
143
- key: "componentDidMount",
144
- value: function componentDidMount() {
145
- var childrenProp = this.props.childrenProp;
146
- var items = this.props.items; // make sure every item has property 'children'
124
+ componentDidMount() {
125
+ const {
126
+ childrenProp
127
+ } = this.props;
128
+ let {
129
+ items
130
+ } = this.props; // make sure every item has property 'children'
131
+
132
+ items = listWithChildren(items, childrenProp);
133
+ this.setState({
134
+ items
135
+ });
136
+ }
147
137
 
148
- items = listWithChildren(items, childrenProp);
149
- this.setState({
150
- items: items
151
- });
152
- }
153
- }, {
154
- key: "componentWillUnmount",
155
- value: function componentWillUnmount() {
156
- this.stopTrackMouse();
157
- }
158
- }, {
159
- key: "getPathById",
160
- value: function getPathById$1(id) {
161
- var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
162
- return getPathById.call(this, id, items);
163
- }
164
- }, {
165
- key: "getItemByPath",
166
- value: function getItemByPath$1(path) {
167
- var items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
168
- return getItemByPath.call(this, path, items);
169
- }
170
- }, {
171
- key: "getSplicePath",
172
- value: function getSplicePath$1(path) {
173
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
174
- return getSplicePath.call(this, path, options);
175
- }
176
- }, {
177
- key: "getRealNextPath",
178
- value: function getRealNextPath$1(prevPath, nextPath) {
179
- return getRealNextPath.call(this, prevPath, nextPath);
180
- }
181
- }, {
182
- key: "getItemOptions",
183
- value: function getItemOptions$1() {
184
- return getItemOptions.call(this);
185
- }
186
- }, {
187
- key: "dragApply",
188
- value: function dragApply() {
189
- var onChange = this.props.onChange;
190
- var _this$state = this.state,
191
- items = _this$state.items,
192
- isDirty = _this$state.isDirty,
193
- dragItem = _this$state.dragItem;
194
- this.setState({
195
- itemsOld: null,
196
- dragItem: null,
197
- isDirty: false
198
- });
199
- if (onChange && isDirty) onChange(items, dragItem);
200
- }
201
- }, {
202
- key: "tryIncreaseDepth",
203
- value: function tryIncreaseDepth$1(dragItem) {
204
- tryIncreaseDepth.call(this, dragItem);
205
- }
206
- }, {
207
- key: "tryDecreaseDepth",
208
- value: function tryDecreaseDepth$1(dragItem) {
209
- tryDecreaseDepth.call(this, dragItem);
210
- }
211
- }, {
212
- key: "moveItem",
213
- value: function moveItem$1(_ref) {
214
- var dragItem = _ref.dragItem,
215
- pathFrom = _ref.pathFrom,
216
- pathTo = _ref.pathTo;
217
- var extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
218
-
219
- moveItem.call(this, {
220
- dragItem: dragItem,
221
- pathFrom: pathFrom,
222
- pathTo: pathTo
223
- }, extraProps);
224
- }
225
- }, {
226
- key: "renderDragLayer",
227
- value: function renderDragLayer() {
228
- var group = this.props.group;
229
- var dragItem = this.state.dragItem;
230
- var el = document.querySelector(".nestable-".concat(group, " .nestable-item-").concat(dragItem.id));
231
- var listStyles = {};
232
-
233
- if (el) {
234
- listStyles.width = el.clientWidth;
235
- }
138
+ componentWillUnmount() {
139
+ this.stopTrackMouse();
140
+ }
236
141
 
237
- if (this.elCopyStyles) {
238
- listStyles = _objectSpread(_objectSpread({}, listStyles), this.elCopyStyles);
142
+ static getDerivedStateFromProps(props, state) {
143
+ const {
144
+ items: itemsNew,
145
+ childrenProp
146
+ } = props;
147
+ const {
148
+ stopTrackingMouse,
149
+ oldProps
150
+ } = state;
151
+
152
+ if (shallowCompare({
153
+ props: oldProps,
154
+ state: {}
155
+ }, props, {})) {
156
+ stopTrackingMouse();
157
+ const extra = {};
158
+
159
+ if (oldProps.collapsed !== props.collapsed) {
160
+ extra.collapsedGroups = [];
239
161
  }
240
162
 
241
- var options = this.getItemOptions();
242
- return /*#__PURE__*/React.createElement("div", {
243
- className: "nestable-drag-layer"
244
- }, /*#__PURE__*/React.createElement("ol", {
245
- className: "nestable-list",
246
- style: listStyles
247
- }, /*#__PURE__*/React.createElement(NestableItem, {
248
- isCopy: true,
249
- item: dragItem,
250
- options: options
251
- })));
163
+ return _objectSpread({
164
+ items: listWithChildren(itemsNew, childrenProp),
165
+ dragItem: null,
166
+ isDirty: false,
167
+ oldProps: props
168
+ }, extra);
252
169
  }
253
- }, {
254
- key: "render",
255
- value: function render() {
256
- var _this$state2 = this.state,
257
- items = _this$state2.items,
258
- dragItem = _this$state2.dragItem;
259
- var _this$props = this.props,
260
- group = _this$props.group,
261
- isAndItem = _this$props.isAndItem,
262
- isOrItem = _this$props.isOrItem,
263
- isDraggableItem = _this$props.isDraggableItem,
264
- setDraggableItems = _this$props.setDraggableItems,
265
- singleRow = _this$props.singleRow;
266
- var options = this.getItemOptions();
267
- var childLength = items.length;
268
- var childClass = 'single';
269
- if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
270
- return /*#__PURE__*/React.createElement("div", {
271
- className: cn('nestable', "nestable-".concat(group), {
272
- 'is-drag-active': dragItem
273
- })
274
- }, /*#__PURE__*/React.createElement("ol", {
275
- className: "nestable-list nestable-group nestable-child-count-".concat(childClass)
276
- }, items.map(function (item, i) {
277
- return /*#__PURE__*/React.createElement(NestableItem, {
278
- key: item.id,
279
- index: i,
280
- isAndItem: isAndItem,
281
- isDraggableItem: isDraggableItem,
282
- isOrItem: isOrItem,
283
- item: item,
284
- options: options,
285
- setDraggableItems: setDraggableItems,
286
- singleRow: singleRow
287
- });
288
- })), dragItem && this.renderDragLayer());
170
+
171
+ return null;
172
+ }
173
+
174
+ getPathById(id) {
175
+ let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
176
+ return getPathById.call(this, id, items);
177
+ }
178
+
179
+ getItemByPath(path) {
180
+ let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
181
+ return getItemByPath.call(this, path, items);
182
+ }
183
+
184
+ getSplicePath(path) {
185
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
186
+ return getSplicePath.call(this, path, options);
187
+ }
188
+
189
+ getRealNextPath(prevPath, nextPath) {
190
+ return getRealNextPath.call(this, prevPath, nextPath);
191
+ }
192
+
193
+ getItemOptions() {
194
+ return getItemOptions.call(this);
195
+ }
196
+
197
+ dragApply() {
198
+ const {
199
+ onChange
200
+ } = this.props;
201
+ const {
202
+ items,
203
+ isDirty,
204
+ dragItem
205
+ } = this.state;
206
+ this.setState({
207
+ itemsOld: null,
208
+ dragItem: null,
209
+ isDirty: false
210
+ });
211
+ if (onChange && isDirty) onChange(items, dragItem);
212
+ }
213
+
214
+ tryIncreaseDepth(dragItem) {
215
+ tryIncreaseDepth.call(this, dragItem);
216
+ }
217
+
218
+ tryDecreaseDepth(dragItem) {
219
+ tryDecreaseDepth.call(this, dragItem);
220
+ }
221
+
222
+ moveItem(_ref) {
223
+ let {
224
+ dragItem,
225
+ pathFrom,
226
+ pathTo
227
+ } = _ref;
228
+ let extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
229
+ moveItem.call(this, {
230
+ dragItem,
231
+ pathFrom,
232
+ pathTo
233
+ }, extraProps);
234
+ }
235
+
236
+ renderDragLayer() {
237
+ const {
238
+ group
239
+ } = this.props;
240
+ const {
241
+ dragItem
242
+ } = this.state;
243
+ const el = document.querySelector(".nestable-".concat(group, " .nestable-item-").concat(dragItem.id));
244
+ let listStyles = {};
245
+
246
+ if (el) {
247
+ listStyles.width = el.clientWidth;
289
248
  }
290
- }], [{
291
- key: "getDerivedStateFromProps",
292
- value: function getDerivedStateFromProps(props, state) {
293
- var itemsNew = props.items,
294
- childrenProp = props.childrenProp;
295
- var stopTrackingMouse = state.stopTrackingMouse,
296
- oldProps = state.oldProps;
297
-
298
- if (shallowCompare({
299
- props: oldProps,
300
- state: {}
301
- }, props, {})) {
302
- stopTrackingMouse();
303
- var extra = {};
304
-
305
- if (oldProps.collapsed !== props.collapsed) {
306
- extra.collapsedGroups = [];
307
- }
308
-
309
- return _objectSpread({
310
- items: listWithChildren(itemsNew, childrenProp),
311
- dragItem: null,
312
- isDirty: false,
313
- oldProps: props
314
- }, extra);
315
- }
316
249
 
317
- return null;
250
+ if (this.elCopyStyles) {
251
+ listStyles = _objectSpread(_objectSpread({}, listStyles), this.elCopyStyles);
318
252
  }
319
- }]);
320
253
 
321
- return Nestable;
322
- }(Component);
254
+ const options = this.getItemOptions();
255
+ return /*#__PURE__*/_jsx("div", {
256
+ className: "nestable-drag-layer"
257
+ }, void 0, /*#__PURE__*/_jsx("ol", {
258
+ className: "nestable-list",
259
+ style: listStyles
260
+ }, void 0, /*#__PURE__*/_jsx(NestableItem, {
261
+ isCopy: true,
262
+ item: dragItem,
263
+ options: options
264
+ })));
265
+ }
266
+
267
+ render() {
268
+ const {
269
+ items,
270
+ dragItem
271
+ } = this.state;
272
+ const {
273
+ group,
274
+ isAndItem,
275
+ isOrItem,
276
+ isDraggableItem,
277
+ setDraggableItems,
278
+ singleRow
279
+ } = this.props;
280
+ const options = this.getItemOptions();
281
+ const childLength = items.length;
282
+ let childClass = 'single';
283
+ if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
284
+ return /*#__PURE__*/_jsx("div", {
285
+ className: cn('nestable', "nestable-".concat(group), {
286
+ 'is-drag-active': dragItem
287
+ })
288
+ }, void 0, /*#__PURE__*/_jsx("ol", {
289
+ className: "nestable-list nestable-group nestable-child-count-".concat(childClass)
290
+ }, void 0, items.map((item, i) => /*#__PURE__*/_jsx(NestableItem, {
291
+ index: i,
292
+ isAndItem: isAndItem,
293
+ isDraggableItem: isDraggableItem,
294
+ isOrItem: isOrItem,
295
+ item: item,
296
+ options: options,
297
+ setDraggableItems: setDraggableItems,
298
+ singleRow: singleRow
299
+ }, item.id))), dragItem && this.renderDragLayer());
300
+ }
301
+
302
+ }
323
303
 
324
304
  Nestable.defaultProps = {
325
305
  items: [],
326
306
  collapsed: false,
327
307
  group: Math.random().toString(36).slice(2),
328
308
  childrenProp: 'children',
329
- onChange: function onChange() {}
330
- };
331
- Nestable.propTypes = {
332
- childrenProp: PropTypes.string,
333
- group: PropTypes.string,
334
- items: PropTypes.arrayOf(PropTypes.shape({})),
335
- collapsed: PropTypes.bool,
336
- onChange: PropTypes.func,
337
- isAndItem: PropTypes.bool,
338
- isOrItem: PropTypes.bool,
339
- isDraggableItem: PropTypes.bool,
340
- setDraggableItems: PropTypes.func,
341
- singleRow: PropTypes.bool
309
+ onChange: () => {}
342
310
  };
343
311
 
344
312
  export { Nestable as default };
345
- //# sourceMappingURL=Nestable.js.map