@elliemae/ds-query-builder 2.2.0-next.6 → 2.3.0-alpha.1

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 (142) hide show
  1. package/cjs/DSQueryBuilder.js +117 -97
  2. package/cjs/DSQueryBuilder.js.map +7 -0
  3. package/cjs/components/AndOrController/AndOrController.js +148 -162
  4. package/cjs/components/AndOrController/AndOrController.js.map +7 -0
  5. package/cjs/components/ConditionController/ConditionController.js +88 -72
  6. package/cjs/components/ConditionController/ConditionController.js.map +7 -0
  7. package/cjs/components/DisplayOutput/DisplayOutput.js +63 -68
  8. package/cjs/components/DisplayOutput/DisplayOutput.js.map +7 -0
  9. package/cjs/components/DragContainerController/DragContainerController.js +61 -41
  10. package/cjs/components/DragContainerController/DragContainerController.js.map +7 -0
  11. package/cjs/components/DragControllerRow/DragControllerRow.js +50 -46
  12. package/cjs/components/DragControllerRow/DragControllerRow.js.map +7 -0
  13. package/cjs/components/FieldControllerRow/FieldControllerRow.js +54 -32
  14. package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
  15. package/cjs/components/Nestable/Nestable.js +143 -209
  16. package/cjs/components/Nestable/Nestable.js.map +7 -0
  17. package/cjs/components/Nestable/NestableItem.js +98 -90
  18. package/cjs/components/Nestable/NestableItem.js.map +7 -0
  19. package/cjs/components/Nestable/actions/events.js +72 -95
  20. package/cjs/components/Nestable/actions/events.js.map +7 -0
  21. package/cjs/components/Nestable/actions/getItemOptions.js +36 -15
  22. package/cjs/components/Nestable/actions/getItemOptions.js.map +7 -0
  23. package/cjs/components/Nestable/actions/getPaths.js +46 -51
  24. package/cjs/components/Nestable/actions/getPaths.js.map +7 -0
  25. package/cjs/components/Nestable/actions/index.js +42 -28
  26. package/cjs/components/Nestable/actions/index.js.map +7 -0
  27. package/cjs/components/Nestable/actions/moveItem.js +44 -42
  28. package/cjs/components/Nestable/actions/moveItem.js.map +7 -0
  29. package/cjs/components/Nestable/actions/paths.js +48 -55
  30. package/cjs/components/Nestable/actions/paths.js.map +7 -0
  31. package/cjs/components/Nestable/actions/tryDecreaseDepth.js +39 -23
  32. package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
  33. package/cjs/components/Nestable/actions/tryIncreaseDepth.js +39 -26
  34. package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
  35. package/cjs/components/Nestable/index.js +36 -7
  36. package/cjs/components/Nestable/index.js.map +7 -0
  37. package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +36 -13
  38. package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
  39. package/cjs/components/QueryBuilderImpl.js +118 -202
  40. package/cjs/components/QueryBuilderImpl.js.map +7 -0
  41. package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +80 -78
  42. package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
  43. package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +154 -211
  44. package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
  45. package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +39 -26
  46. package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
  47. package/cjs/components/format/format.js +48 -22
  48. package/cjs/components/format/format.js.map +7 -0
  49. package/cjs/components/format/sqlFormat.js +69 -48
  50. package/cjs/components/format/sqlFormat.js.map +7 -0
  51. package/cjs/components/format/sqlSafeFormat.js +72 -55
  52. package/cjs/components/format/sqlSafeFormat.js.map +7 -0
  53. package/cjs/components/format/xmlFormat.js +71 -50
  54. package/cjs/components/format/xmlFormat.js.map +7 -0
  55. package/cjs/components/helpers/actions.js +151 -186
  56. package/cjs/components/helpers/actions.js.map +7 -0
  57. package/cjs/components/helpers/constants.js +36 -8
  58. package/cjs/components/helpers/constants.js.map +7 -0
  59. package/cjs/components/helpers/dependencies.js +49 -64
  60. package/cjs/components/helpers/dependencies.js.map +7 -0
  61. package/cjs/components/helpers/selectors.js +161 -101
  62. package/cjs/components/helpers/selectors.js.map +7 -0
  63. package/cjs/components/helpers/store.js +86 -104
  64. package/cjs/components/helpers/store.js.map +7 -0
  65. package/cjs/components/helpers/types.js +72 -44
  66. package/cjs/components/helpers/types.js.map +7 -0
  67. package/cjs/index.js +36 -29
  68. package/cjs/index.js.map +7 -0
  69. package/cjs/propTypes.js +102 -94
  70. package/cjs/propTypes.js.map +7 -0
  71. package/esm/DSQueryBuilder.js +103 -72
  72. package/esm/DSQueryBuilder.js.map +7 -0
  73. package/esm/components/AndOrController/AndOrController.js +113 -147
  74. package/esm/components/AndOrController/AndOrController.js.map +7 -0
  75. package/esm/components/ConditionController/ConditionController.js +57 -62
  76. package/esm/components/ConditionController/ConditionController.js.map +7 -0
  77. package/esm/components/DisplayOutput/DisplayOutput.js +31 -59
  78. package/esm/components/DisplayOutput/DisplayOutput.js.map +7 -0
  79. package/esm/components/DragContainerController/DragContainerController.js +32 -35
  80. package/esm/components/DragContainerController/DragContainerController.js.map +7 -0
  81. package/esm/components/DragControllerRow/DragControllerRow.js +21 -38
  82. package/esm/components/DragControllerRow/DragControllerRow.js.map +7 -0
  83. package/esm/components/FieldControllerRow/FieldControllerRow.js +25 -26
  84. package/esm/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
  85. package/esm/components/Nestable/Nestable.js +115 -186
  86. package/esm/components/Nestable/Nestable.js.map +7 -0
  87. package/esm/components/Nestable/NestableItem.js +69 -82
  88. package/esm/components/Nestable/NestableItem.js.map +7 -0
  89. package/esm/components/Nestable/actions/events.js +45 -79
  90. package/esm/components/Nestable/actions/events.js.map +7 -0
  91. package/esm/components/Nestable/actions/getItemOptions.js +7 -11
  92. package/esm/components/Nestable/actions/getItemOptions.js.map +7 -0
  93. package/esm/components/Nestable/actions/getPaths.js +17 -43
  94. package/esm/components/Nestable/actions/getPaths.js.map +7 -0
  95. package/esm/components/Nestable/actions/index.js +13 -6
  96. package/esm/components/Nestable/actions/index.js.map +7 -0
  97. package/esm/components/Nestable/actions/moveItem.js +13 -31
  98. package/esm/components/Nestable/actions/moveItem.js.map +7 -0
  99. package/esm/components/Nestable/actions/paths.js +19 -47
  100. package/esm/components/Nestable/actions/paths.js.map +7 -0
  101. package/esm/components/Nestable/actions/tryDecreaseDepth.js +10 -19
  102. package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
  103. package/esm/components/Nestable/actions/tryIncreaseDepth.js +10 -22
  104. package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
  105. package/esm/components/Nestable/index.js +7 -2
  106. package/esm/components/Nestable/index.js.map +7 -0
  107. package/esm/components/QueryBuilderContext/QueryBuilderContext.js +7 -5
  108. package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
  109. package/esm/components/QueryBuilderImpl.js +82 -187
  110. package/esm/components/QueryBuilderImpl.js.map +7 -0
  111. package/esm/components/QueryBuilderItem/QueryBuilderItem.js +50 -70
  112. package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
  113. package/esm/components/QueryBuilderRow/QueryBuilderRow.js +123 -201
  114. package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
  115. package/esm/components/ToolBarAnimation/ToolBarAnimation.js +10 -17
  116. package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
  117. package/esm/components/format/format.js +16 -17
  118. package/esm/components/format/format.js.map +7 -0
  119. package/esm/components/format/sqlFormat.js +39 -43
  120. package/esm/components/format/sqlFormat.js.map +7 -0
  121. package/esm/components/format/sqlSafeFormat.js +43 -50
  122. package/esm/components/format/sqlSafeFormat.js.map +7 -0
  123. package/esm/components/format/xmlFormat.js +41 -45
  124. package/esm/components/format/xmlFormat.js.map +7 -0
  125. package/esm/components/helpers/actions.js +123 -160
  126. package/esm/components/helpers/actions.js.map +7 -0
  127. package/esm/components/helpers/constants.js +7 -2
  128. package/esm/components/helpers/constants.js.map +7 -0
  129. package/esm/components/helpers/dependencies.js +19 -39
  130. package/esm/components/helpers/dependencies.js.map +7 -0
  131. package/esm/components/helpers/selectors.js +132 -93
  132. package/esm/components/helpers/selectors.js.map +7 -0
  133. package/esm/components/helpers/store.js +54 -82
  134. package/esm/components/helpers/store.js.map +7 -0
  135. package/esm/components/helpers/types.js +44 -33
  136. package/esm/components/helpers/types.js.map +7 -0
  137. package/esm/index.js +7 -4
  138. package/esm/index.js.map +7 -0
  139. package/esm/propTypes.js +55 -72
  140. package/esm/propTypes.js.map +7 -0
  141. package/package.json +12 -12
  142. package/types/DSQueryBuilder.d.ts +1 -32
@@ -1,91 +1,72 @@
1
- import 'core-js/modules/esnext.async-iterator.for-each.js';
2
- import 'core-js/modules/esnext.iterator.for-each.js';
3
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
4
- import 'core-js/modules/esnext.async-iterator.filter.js';
5
- import 'core-js/modules/esnext.iterator.constructor.js';
6
- import 'core-js/modules/esnext.iterator.filter.js';
7
- import { closest, getTransformProps, getOffsetRect, getTotalScroll } from '@elliemae/ds-shared/utils';
8
-
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
-
11
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1
+ import * as React from "react";
2
+ import {
3
+ closest,
4
+ getOffsetRect,
5
+ getTotalScroll,
6
+ getTransformProps
7
+ } from "@elliemae/ds-shared/utils";
12
8
  function onDragStart(e, item) {
13
9
  if (e) {
14
10
  e.preventDefault();
15
11
  e.stopPropagation();
16
12
  }
17
-
18
- this.el = closest(e.target, '.nestable-item');
13
+ this.el = closest(e.target, ".nestable-item");
19
14
  this.startTrackMouse();
20
15
  this.onMouseMove(e);
21
- const {
22
- items
23
- } = this.state;
16
+ const { items } = this.state;
24
17
  this.setState({
25
18
  dragItem: item,
26
19
  itemsOld: items
27
20
  });
28
21
  }
29
22
  function onDragEnd(e, isCancel) {
30
- if (e && e.preventDefault) e.preventDefault();
23
+ if (e && e.preventDefault)
24
+ e.preventDefault();
31
25
  this.stopTrackMouse();
32
- this.el = null; // check if filter has children
33
-
34
- const {
35
- items
36
- } = this.state;
26
+ this.el = null;
27
+ const { items } = this.state;
37
28
  const nestedInFilter = this.checkFilterChildren(items);
38
- if (nestedInFilter) return this.dragRevert();
29
+ if (nestedInFilter)
30
+ return this.dragRevert();
39
31
  return isCancel ? this.dragRevert() : this.dragApply();
40
32
  }
41
33
  function onMouseMove(e) {
42
- const {
43
- group,
44
- threshold
45
- } = this.props;
46
- const {
47
- dragItem
48
- } = this.state;
49
- const {
50
- clientX,
51
- clientY
52
- } = e;
34
+ const { group, threshold } = this.props;
35
+ const { dragItem } = this.state;
36
+ const { clientX, clientY } = e;
53
37
  const transformProps = getTransformProps(clientX, clientY);
54
- const elCopy = document.querySelector(".nestable-".concat(group, " .nestable-drag-layer > .nestable-list"));
55
-
38
+ const elCopy = document.querySelector(`.nestable-${group} .nestable-drag-layer > .nestable-list`);
56
39
  if (!this.elCopyStyles) {
57
40
  const offset = getOffsetRect(this.el);
58
41
  const scroll = getTotalScroll(this.el);
59
- this.elCopyStyles = _objectSpread({
42
+ this.elCopyStyles = {
60
43
  marginTop: offset.top - clientY - scroll.top,
61
- marginLeft: offset.left - clientX - scroll.left
62
- }, transformProps);
44
+ marginLeft: offset.left - clientX - scroll.left,
45
+ ...transformProps
46
+ };
63
47
  } else {
64
- this.elCopyStyles = _objectSpread(_objectSpread({}, this.elCopyStyles), transformProps);
65
-
48
+ this.elCopyStyles = {
49
+ ...this.elCopyStyles,
50
+ ...transformProps
51
+ };
66
52
  for (const key in transformProps) {
67
53
  if (transformProps.hasOwnProperty(key)) {
68
54
  elCopy.style[key] = transformProps[key];
69
55
  }
70
56
  }
71
-
72
57
  const diffX = clientX - this.mouse.last.x;
73
-
74
58
  if (diffX >= 0 && this.mouse.shift.x >= 0 || diffX <= 0 && this.mouse.shift.x <= 0) {
75
59
  this.mouse.shift.x += diffX;
76
60
  } else {
77
61
  this.mouse.shift.x = 0;
78
62
  }
79
-
80
63
  this.mouse.last.x = clientX;
81
-
82
64
  if (Math.abs(this.mouse.shift.x) > threshold) {
83
65
  if (this.mouse.shift.x > 0) {
84
66
  this.tryIncreaseDepth(dragItem);
85
67
  } else {
86
68
  this.tryDecreaseDepth(dragItem);
87
69
  }
88
-
89
70
  this.mouse.shift.x = 0;
90
71
  }
91
72
  }
@@ -95,59 +76,44 @@ function onMouseEnter(e, item) {
95
76
  e.preventDefault();
96
77
  e.stopPropagation();
97
78
  }
98
-
99
- const {
100
- collapsed,
101
- childrenProp
102
- } = this.props;
103
- const {
104
- dragItem
105
- } = this.state;
106
- if (dragItem.id === item.id) return;
79
+ const { collapsed, childrenProp } = this.props;
80
+ const { dragItem } = this.state;
81
+ if (dragItem.id === item.id)
82
+ return;
107
83
  const pathFrom = this.getPathById(dragItem.id);
108
- const pathTo = this.getPathById(item.id); // if collapsed by default
109
- // and move last (by count) child
110
- // remove parent node from list of open nodes
111
-
84
+ const pathTo = this.getPathById(item.id);
112
85
  let collapseProps = {};
113
-
114
86
  if (collapsed && pathFrom.length > 1) {
115
87
  const parent = this.getItemByPath(pathFrom.slice(0, -1));
116
-
117
88
  if (parent[childrenProp].length === 1) {
118
89
  collapseProps = this.onToggleCollapse(parent, true);
119
90
  }
120
91
  }
121
-
122
- this.moveItem({
123
- dragItem,
124
- pathFrom,
125
- pathTo
126
- }, collapseProps);
92
+ this.moveItem({ dragItem, pathFrom, pathTo }, collapseProps);
127
93
  }
128
94
  function onToggleCollapse(item, isGetter) {
129
- const {
130
- collapsed
131
- } = this.props;
132
- const {
133
- collapsedGroups
134
- } = this.state;
95
+ const { collapsed } = this.props;
96
+ const { collapsedGroups } = this.state;
135
97
  const isCollapsed = this.isCollapsed(item);
136
98
  const newState = {
137
- collapsedGroups: isCollapsed ^ collapsed ? collapsedGroups.filter(id => id !== item.id) : collapsedGroups.concat(item.id)
99
+ collapsedGroups: isCollapsed ^ collapsed ? collapsedGroups.filter((id) => id !== item.id) : collapsedGroups.concat(item.id)
138
100
  };
139
-
140
101
  if (isGetter) {
141
102
  return newState;
142
103
  }
143
-
144
104
  return this.setState(newState);
145
105
  }
146
106
  function onKeyDown(e) {
147
107
  if (e.which === 27) {
148
- // ESC
149
108
  this.onDragEnd(null, true);
150
109
  }
151
110
  }
152
-
153
- export { onDragEnd, onDragStart, onKeyDown, onMouseEnter, onMouseMove, onToggleCollapse };
111
+ export {
112
+ onDragEnd,
113
+ onDragStart,
114
+ onKeyDown,
115
+ onMouseEnter,
116
+ onMouseMove,
117
+ onToggleCollapse
118
+ };
119
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/events.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-bitwise, no-loops/no-loops, max-lines, max-statements, no-restricted-syntax, no-prototype-builtins */\nimport {\n closest,\n getOffsetRect,\n getTotalScroll,\n getTransformProps,\n} from '@elliemae/ds-shared/utils';\n\nexport function onDragStart(e, item) {\n if (e) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.el = closest(e.target, '.nestable-item');\n this.startTrackMouse();\n this.onMouseMove(e);\n const { items } = this.state;\n this.setState({\n dragItem: item,\n itemsOld: items,\n });\n}\n\nexport function onDragEnd(e, isCancel) {\n if (e && e.preventDefault) e.preventDefault();\n\n this.stopTrackMouse();\n this.el = null;\n\n // check if filter has children\n const { items } = this.state;\n const nestedInFilter = this.checkFilterChildren(items);\n if (nestedInFilter) return this.dragRevert();\n\n return isCancel ? this.dragRevert() : this.dragApply();\n}\n\nexport function onMouseMove(e) {\n const { group, threshold } = this.props;\n const { dragItem } = this.state;\n const { clientX, clientY } = e;\n const transformProps = getTransformProps(clientX, clientY);\n const elCopy = document.querySelector(\n `.nestable-${group} .nestable-drag-layer > .nestable-list`,\n );\n if (!this.elCopyStyles) {\n const offset = getOffsetRect(this.el);\n const scroll = getTotalScroll(this.el);\n\n this.elCopyStyles = {\n marginTop: offset.top - clientY - scroll.top,\n marginLeft: offset.left - clientX - scroll.left,\n ...transformProps,\n };\n } else {\n this.elCopyStyles = {\n ...this.elCopyStyles,\n ...transformProps,\n };\n for (const key in transformProps) {\n if (transformProps.hasOwnProperty(key)) {\n elCopy.style[key] = transformProps[key];\n }\n }\n const diffX = clientX - this.mouse.last.x;\n if (\n (diffX >= 0 && this.mouse.shift.x >= 0) ||\n (diffX <= 0 && this.mouse.shift.x <= 0)\n ) {\n this.mouse.shift.x += diffX;\n } else {\n this.mouse.shift.x = 0;\n }\n this.mouse.last.x = clientX;\n if (Math.abs(this.mouse.shift.x) > threshold) {\n if (this.mouse.shift.x > 0) {\n this.tryIncreaseDepth(dragItem);\n } else {\n this.tryDecreaseDepth(dragItem);\n }\n this.mouse.shift.x = 0;\n }\n }\n}\nexport function onMouseEnter(e, item) {\n if (e) {\n e.preventDefault();\n e.stopPropagation();\n }\n\n const { collapsed, childrenProp } = this.props;\n const { dragItem } = this.state;\n if (dragItem.id === item.id) return;\n\n const pathFrom = this.getPathById(dragItem.id);\n const pathTo = this.getPathById(item.id);\n\n // if collapsed by default\n // and move last (by count) child\n // remove parent node from list of open nodes\n let collapseProps = {};\n if (collapsed && pathFrom.length > 1) {\n const parent = this.getItemByPath(pathFrom.slice(0, -1));\n if (parent[childrenProp].length === 1) {\n collapseProps = this.onToggleCollapse(parent, true);\n }\n }\n\n this.moveItem({ dragItem, pathFrom, pathTo }, collapseProps);\n}\n\nexport function onToggleCollapse(item, isGetter) {\n const { collapsed } = this.props;\n const { collapsedGroups } = this.state;\n const isCollapsed = this.isCollapsed(item);\n\n const newState = {\n collapsedGroups:\n isCollapsed ^ collapsed\n ? collapsedGroups.filter(id => id !== item.id)\n : collapsedGroups.concat(item.id),\n };\n\n if (isGetter) {\n return newState;\n }\n return this.setState(newState);\n}\nexport function onKeyDown(e) {\n if (e.which === 27) {\n // ESC\n this.onDragEnd(null, true);\n }\n}\n"],
5
+ "mappings": "AAAA;ACCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,qBAAqB,GAAG,MAAM;AACnC,MAAI,GAAG;AACL,MAAE;AACF,MAAE;AAAA;AAEJ,OAAK,KAAK,QAAQ,EAAE,QAAQ;AAC5B,OAAK;AACL,OAAK,YAAY;AACjB,QAAM,EAAE,UAAU,KAAK;AACvB,OAAK,SAAS;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA;AAAA;AAIP,mBAAmB,GAAG,UAAU;AACrC,MAAI,KAAK,EAAE;AAAgB,MAAE;AAE7B,OAAK;AACL,OAAK,KAAK;AAGV,QAAM,EAAE,UAAU,KAAK;AACvB,QAAM,iBAAiB,KAAK,oBAAoB;AAChD,MAAI;AAAgB,WAAO,KAAK;AAEhC,SAAO,WAAW,KAAK,eAAe,KAAK;AAAA;AAGtC,qBAAqB,GAAG;AAC7B,QAAM,EAAE,OAAO,cAAc,KAAK;AAClC,QAAM,EAAE,aAAa,KAAK;AAC1B,QAAM,EAAE,SAAS,YAAY;AAC7B,QAAM,iBAAiB,kBAAkB,SAAS;AAClD,QAAM,SAAS,SAAS,cACtB,aAAa;AAEf,MAAI,CAAC,KAAK,cAAc;AACtB,UAAM,SAAS,cAAc,KAAK;AAClC,UAAM,SAAS,eAAe,KAAK;AAEnC,SAAK,eAAe;AAAA,MAClB,WAAW,OAAO,MAAM,UAAU,OAAO;AAAA,MACzC,YAAY,OAAO,OAAO,UAAU,OAA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cAAc,KAAK,YAAY;AAErC,QAAM,WAAW;AAAA,IACf,iBACE,cAAc,YACV,gBAAgB,OAAO,QAAM,OAAO,KAAK,MACzC,gBAAgB,OAAO,KAAK;AAAA;AAGpC,MAAI,UAAU;AACZ,WAAO;AAAA;AAET,SAAO,KAAK,SAAS;AAAA;AAEhB,mBAAmB,GAAG;AAC3B,MAAI,EAAE,UAAU,IAAI;AAElB,SAAK,UAAU,MAAM;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,13 +1,7 @@
1
+ import * as React from "react";
1
2
  function getItemOptions() {
2
- const {
3
- renderItem,
4
- renderCollapseIcon,
5
- handler,
6
- childrenProp
7
- } = this.props;
8
- const {
9
- dragItem
10
- } = this.state;
3
+ const { renderItem, renderCollapseIcon, handler, childrenProp } = this.props;
4
+ const { dragItem } = this.state;
11
5
  return {
12
6
  dragItem,
13
7
  childrenProp,
@@ -20,5 +14,7 @@ function getItemOptions() {
20
14
  onToggleCollapse: this.onToggleCollapse
21
15
  };
22
16
  }
23
-
24
- export { getItemOptions };
17
+ export {
18
+ getItemOptions
19
+ };
20
+ //# sourceMappingURL=getItemOptions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/getItemOptions.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export function getItemOptions() {\n const { renderItem, renderCollapseIcon, handler, childrenProp } = this.props;\n const { dragItem } = this.state;\n\n return {\n dragItem,\n childrenProp,\n renderItem,\n renderCollapseIcon,\n handler,\n\n onDragStart: this.onDragStart,\n onMouseEnter: this.onMouseEnter,\n isCollapsed: this.isCollapsed,\n onToggleCollapse: this.onToggleCollapse,\n };\n}\n"],
5
+ "mappings": "AAAA;ACAO,0BAA0B;AAC/B,QAAM,EAAE,YAAY,oBAAoB,SAAS,iBAAiB,KAAK;AACvE,QAAM,EAAE,aAAa,KAAK;AAE1B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA,aAAa,KAAK;AAAA,IAClB,cAAc,KAAK;AAAA,IACnB,aAAa,KAAK;AAAA,IAClB,kBAAkB,KAAK;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,99 +1,69 @@
1
- import 'core-js/modules/esnext.async-iterator.map.js';
2
- import 'core-js/modules/esnext.iterator.map.js';
3
- import 'core-js/modules/esnext.async-iterator.every.js';
4
- import 'core-js/modules/esnext.iterator.constructor.js';
5
- import 'core-js/modules/esnext.iterator.every.js';
6
- import 'core-js/modules/esnext.async-iterator.for-each.js';
7
- import 'core-js/modules/esnext.iterator.for-each.js';
8
- import 'core-js/modules/web.dom-collections.iterator.js';
9
-
1
+ import * as React from "react";
10
2
  function getRealNextPath(prevPath, nextPath) {
11
- const {
12
- childrenProp
13
- } = this.props;
3
+ const { childrenProp } = this.props;
14
4
  const ppLastIndex = prevPath.length - 1;
15
5
  const npLastIndex = nextPath.length - 1;
16
-
17
6
  if (prevPath.length < nextPath.length) {
18
- // move into deep
19
7
  let wasShifted = false;
20
8
  return nextPath.map((nextIndex, i) => {
21
9
  if (wasShifted) {
22
10
  return i === npLastIndex ? nextIndex + 1 : nextIndex;
23
11
  }
24
-
25
- if (typeof prevPath[i] !== 'number') {
12
+ if (typeof prevPath[i] !== "number") {
26
13
  return nextIndex;
27
14
  }
28
-
29
15
  if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
30
16
  wasShifted = true;
31
17
  return nextIndex - 1;
32
18
  }
33
-
34
19
  return nextIndex;
35
20
  });
36
21
  }
37
-
38
22
  if (prevPath.length === nextPath.length) {
39
- // if move bottom + move to item with children => make it a first child instead of swap
40
23
  if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
41
24
  const target = this.getItemByPath(nextPath);
42
-
43
25
  if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
44
26
  return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
45
27
  }
46
28
  }
47
29
  }
48
-
49
30
  return nextPath;
50
31
  }
51
32
  function getPathById(id, items) {
52
- const {
53
- childrenProp
54
- } = this.props;
33
+ const { childrenProp } = this.props;
55
34
  let path = [];
56
35
  items.every((item, i) => {
57
36
  if (item.id === id) {
58
37
  path.push(i);
59
38
  } else if (item[childrenProp]) {
60
39
  const childrenPath = this.getPathById(id, item[childrenProp]);
61
-
62
40
  if (childrenPath.length) {
63
41
  path = path.concat(i).concat(childrenPath);
64
42
  }
65
43
  }
66
-
67
44
  return path.length === 0;
68
45
  });
69
46
  return path;
70
47
  }
71
48
  function getItemByPath(path, items) {
72
- const {
73
- childrenProp
74
- } = this.props;
49
+ const { childrenProp } = this.props;
75
50
  let item = null;
76
- path.forEach(index => {
51
+ path.forEach((index) => {
77
52
  const list = item ? item[childrenProp] : items;
78
53
  item = list[index];
79
54
  });
80
55
  return item;
81
56
  }
82
57
  function getItemDepth(item) {
83
- const {
84
- childrenProp
85
- } = this.props;
58
+ const { childrenProp } = this.props;
86
59
  let level = 1;
87
-
88
60
  if (item[childrenProp].length > 0) {
89
61
  const childrenDepths = item[childrenProp].map(this.getItemDepth);
90
62
  level += Math.max(...childrenDepths);
91
63
  }
92
-
93
64
  return level;
94
65
  }
95
- function getSplicePath(path) {
96
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
66
+ function getSplicePath(path, options = {}) {
97
67
  const splicePath = {};
98
68
  const numToRemove = options.numToRemove || 0;
99
69
  const itemsToInsert = options.itemsToInsert || [];
@@ -104,13 +74,17 @@ function getSplicePath(path) {
104
74
  currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
105
75
  } else {
106
76
  const nextPath = {};
107
- currentPath[index] = {
108
- [options.childrenProp]: nextPath
109
- };
77
+ currentPath[index] = { [options.childrenProp]: nextPath };
110
78
  currentPath = nextPath;
111
79
  }
112
80
  });
113
81
  return splicePath;
114
82
  }
115
-
116
- export { getItemByPath, getItemDepth, getPathById, getRealNextPath, getSplicePath };
83
+ export {
84
+ getItemByPath,
85
+ getItemDepth,
86
+ getPathById,
87
+ getRealNextPath,
88
+ getSplicePath
89
+ };
90
+ //# sourceMappingURL=getPaths.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/getPaths.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export function getRealNextPath(prevPath, nextPath) {\n const { childrenProp } = this.props;\n const ppLastIndex = prevPath.length - 1;\n const npLastIndex = nextPath.length - 1;\n\n if (prevPath.length < nextPath.length) {\n // move into deep\n let wasShifted = false;\n\n return nextPath.map((nextIndex, i) => {\n if (wasShifted) {\n return i === npLastIndex ? nextIndex + 1 : nextIndex;\n }\n\n if (typeof prevPath[i] !== 'number') {\n return nextIndex;\n }\n\n if (nextPath[i] > prevPath[i] && i === ppLastIndex) {\n wasShifted = true;\n return nextIndex - 1;\n }\n\n return nextIndex;\n });\n }\n\n if (prevPath.length === nextPath.length) {\n // if move bottom + move to item with children => make it a first child instead of swap\n if (nextPath[npLastIndex] > prevPath[npLastIndex]) {\n const target = this.getItemByPath(nextPath);\n\n if (\n target[childrenProp] &&\n target[childrenProp].length &&\n !this.isCollapsed(target)\n ) {\n return nextPath\n .slice(0, -1)\n .concat(nextPath[npLastIndex] - 1)\n .concat(0);\n }\n }\n }\n\n return nextPath;\n}\n\nexport function getPathById(id, items) {\n const { childrenProp } = this.props;\n let path = [];\n\n items.every((item, i) => {\n if (item.id === id) {\n path.push(i);\n } else if (item[childrenProp]) {\n const childrenPath = this.getPathById(id, item[childrenProp]);\n\n if (childrenPath.length) {\n path = path.concat(i).concat(childrenPath);\n }\n }\n\n return path.length === 0;\n });\n\n return path;\n}\n\nexport function getItemByPath(path, items) {\n const { childrenProp } = this.props;\n let item = null;\n\n path.forEach(index => {\n const list = item ? item[childrenProp] : items;\n item = list[index];\n });\n\n return item;\n}\nexport function getItemDepth(item) {\n const { childrenProp } = this.props;\n let level = 1;\n\n if (item[childrenProp].length > 0) {\n const childrenDepths = item[childrenProp].map(this.getItemDepth);\n level += Math.max(...childrenDepths);\n }\n\n return level;\n}\nexport function getSplicePath(path, options = {}) {\n const splicePath = {};\n const numToRemove = options.numToRemove || 0;\n const itemsToInsert = options.itemsToInsert || [];\n const lastIndex = path.length - 1;\n let currentPath = splicePath;\n\n path.forEach((index, i) => {\n if (i === lastIndex) {\n currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];\n } else {\n const nextPath = {};\n currentPath[index] = { [options.childrenProp]: nextPath };\n currentPath = nextPath;\n }\n });\n\n return splicePath;\n}\n"],
5
+ "mappings": "AAAA;ACAO,yBAAyB,UAAU,UAAU;AAClD,QAAM,EAAE,iBAAiB,KAAK;AAC9B,QAAM,cAAc,SAAS,SAAS;AACtC,QAAM,cAAc,SAAS,SAAS;AAEtC,MAAI,SAAS,SAAS,SAAS,QAAQ;AAErC,QAAI,aAAa;AAEjB,WAAO,SAAS,IAAI,CAAC,WAAW,MAAM;AACpC,UAAI,YAAY;AACd,eAAO,MAAM,cAAc,YAAY,IAAI;AAAA;AAG7C,UAAI,OAAO,SAAS,OAAO,UAAU;AACnC,eAAO;AAAA;AAGT,UAAI,SAAS,KAAK,SAAS,MAAM,MAAM,aAAa;AAClD,qBAAa;AACb,eAAO,YAAY;AAAA;AAGrB,aAAO;AAAA;AAAA;AAIX,MAAI,SAAS,WAAW,SAAS,QAAQ;AAEvC,QAAI,SAAS,eAAe,SAAS,cAAc;AACjD,YAAM,SAAS,KAAK,cAAc;AAElC,UACE,OAAO,iBACP,OAAO,cAAc,UACrB,CAAC,KAAK,YAAY,SAClB;AACA,eAAO,SACJ,MAAM,GAAG,IACT,OAAO,SAAS,eAAe,GAC/B,OAAO;AAAA;AAAA;AAAA;AAKhB,SAAO;AAAA;AAGF,qBAAqB,IAAI,OAAO;AACrC,QAAM,EAAE,iBAAiB,KAAK;AAC9B,MAAI,OAAO;AAEX,QAAM,MAAM,CAAC,MAAM,MAAM;AACvB,QAAI,KAAK,OAAO,IAAI;AAClB,WAAK,KAAK;AAAA,eACD,KAAK,eAAe;AAC7B,YAAM,eAAe,KAAK,YAAY,IAAI,KAAK;AAE/C,UAAI,aAAa,QAAQ;AACvB,eAAO,KAAK,OAAO,GAAG,OAAO;AAAA;AAAA;AAIjC,WAAO,KAAK,WAAW;AAAA;AAGzB,SAAO;AAAA;AAGF,uBAAuB,MAAM,OAAO;AACzC,QAAM,EAAE,iBAAiB,KAAK;AAC9B,MAAI,OAAO;AAEX,OAAK,QAAQ,WAAS;AACpB,UAAM,OAAO,OAAO,KAAK,gBAAgB;AACzC,WAAO,KAAK;AAAA;AAGd,SAAO;AAAA;AAEF,sBAAsB,MAAM;AACjC,QAAM,EAAE,iBAAiB,KAAK;AAC9B,MAAI,QAAQ;AAEZ,MAAI,KAAK,cAAc,SAAS,GAAG;AACjC,UAAM,iBAAiB,KAAK,cAAc,IAAI,KAAK;AACnD,aAAS,KAAK,IAAI,GAAG;AAAA;AAGvB,SAAO;AAAA;AAEF,uBAAuB,MAAM,UAAU,IAAI;AAChD,QAAM,aAAa;AACnB,QAAM,cAAc,QAAQ,eAAe;AAC3C,QAAM,gBAAgB,QAAQ,iBAAiB;AAC/C,QAAM,YAAY,KAAK,SAAS;AAChC,MAAI,cAAc;AAElB,OAAK,QAAQ,CAAC,OAAO,MAAM;AACzB,QAAI,MAAM,WAAW;AACnB,kBAAY,UAAU,CAAC,CAAC,OAAO,aAAa,GAAG;AAAA,WAC1C;AACL,YAAM,WAAW;AACjB,kBAAY,SAAS,GAAG,QAAQ,eAAe;AAC/C,oBAAc;AAAA;AAAA;AAIlB,SAAO;AAAA;",
6
+ "names": []
7
+ }
@@ -1,6 +1,13 @@
1
- export { tryIncreaseDepth } from './tryIncreaseDepth.js';
2
- export { tryDecreaseDepth } from './tryDecreaseDepth.js';
3
- export { moveItem } from './moveItem.js';
4
- export { getItemByPath, getItemDepth, getPathById, getRealNextPath, getSplicePath } from './paths.js';
5
- export { onDragEnd, onDragStart, onKeyDown, onMouseEnter, onMouseMove, onToggleCollapse } from './events.js';
6
- export { getItemOptions } from './getItemOptions.js';
1
+ import * as React from "react";
2
+ import { tryIncreaseDepth } from "./tryIncreaseDepth";
3
+ import { tryDecreaseDepth } from "./tryDecreaseDepth";
4
+ import { moveItem } from "./moveItem";
5
+ export * from "./paths";
6
+ export * from "./events";
7
+ export * from "./getItemOptions";
8
+ export {
9
+ moveItem,
10
+ tryDecreaseDepth,
11
+ tryIncreaseDepth
12
+ };
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/index.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export { tryIncreaseDepth } from './tryIncreaseDepth';\nexport { tryDecreaseDepth } from './tryDecreaseDepth';\nexport { moveItem } from './moveItem';\nexport * from './paths';\nexport * from './events';\nexport * from './getItemOptions';\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AACA;AACA;AACA;AACA;",
6
+ "names": []
7
+ }
@@ -1,29 +1,8 @@
1
- import 'core-js/modules/esnext.async-iterator.filter.js';
2
- import 'core-js/modules/esnext.iterator.constructor.js';
3
- import 'core-js/modules/esnext.iterator.filter.js';
4
- import 'core-js/modules/esnext.async-iterator.for-each.js';
5
- import 'core-js/modules/esnext.iterator.for-each.js';
6
- import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
7
- import update from 'react-addons-update';
8
-
9
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
-
11
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
- function moveItem(_ref) {
13
- let {
14
- dragItem,
15
- pathFrom,
16
- pathTo
17
- } = _ref;
18
- let extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
- const {
20
- childrenProp
21
- } = this.props;
22
- let {
23
- items
24
- } = this.state; // the remove action might affect the next position,
25
- // so update next coordinates accordingly
26
-
1
+ import * as React from "react";
2
+ import update from "react-addons-update";
3
+ function moveItem({ dragItem, pathFrom, pathTo }, extraProps = {}) {
4
+ const { childrenProp } = this.props;
5
+ let { items } = this.state;
27
6
  const realPathTo = this.getRealNextPath(pathFrom, pathTo);
28
7
  const removePath = this.getSplicePath(pathFrom, {
29
8
  numToRemove: 1,
@@ -36,10 +15,13 @@ function moveItem(_ref) {
36
15
  });
37
16
  items = update(items, removePath);
38
17
  items = update(items, insertPath);
39
- this.setState(_objectSpread({
18
+ this.setState({
40
19
  items,
41
- isDirty: true
42
- }, extraProps));
20
+ isDirty: true,
21
+ ...extraProps
22
+ });
43
23
  }
44
-
45
- export { moveItem };
24
+ export {
25
+ moveItem
26
+ };
27
+ //# sourceMappingURL=moveItem.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/moveItem.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import update from 'react-addons-update';\n\nexport function moveItem({ dragItem, pathFrom, pathTo }, extraProps = {}) {\n const { childrenProp } = this.props;\n let { items } = this.state;\n\n // the remove action might affect the next position,\n // so update next coordinates accordingly\n const realPathTo = this.getRealNextPath(pathFrom, pathTo);\n\n const removePath = this.getSplicePath(pathFrom, {\n numToRemove: 1,\n childrenProp,\n });\n\n const insertPath = this.getSplicePath(realPathTo, {\n numToRemove: 0,\n itemsToInsert: [dragItem],\n childrenProp,\n });\n\n items = update(items, removePath);\n items = update(items, insertPath);\n\n this.setState({\n items,\n isDirty: true,\n ...extraProps,\n });\n}\n"],
5
+ "mappings": "AAAA;ACAA;AAEO,kBAAkB,EAAE,UAAU,UAAU,UAAU,aAAa,IAAI;AACxE,QAAM,EAAE,iBAAiB,KAAK;AAC9B,MAAI,EAAE,UAAU,KAAK;AAIrB,QAAM,aAAa,KAAK,gBAAgB,UAAU;AAElD,QAAM,aAAa,KAAK,cAAc,UAAU;AAAA,IAC9C,aAAa;AAAA,IACb;AAAA;AAGF,QAAM,aAAa,KAAK,cAAc,YAAY;AAAA,IAChD,aAAa;AAAA,IACb,eAAe,CAAC;AAAA,IAChB;AAAA;AAGF,UAAQ,OAAO,OAAO;AACtB,UAAQ,OAAO,OAAO;AAEtB,OAAK,SAAS;AAAA,IACZ;AAAA,IACA,SAAS;AAAA,OACN;AAAA;AAAA;",
6
+ "names": []
7
+ }
@@ -1,101 +1,69 @@
1
- import 'core-js/modules/esnext.async-iterator.map.js';
2
- import 'core-js/modules/esnext.iterator.map.js';
3
- import 'core-js/modules/esnext.async-iterator.every.js';
4
- import 'core-js/modules/esnext.iterator.constructor.js';
5
- import 'core-js/modules/esnext.iterator.every.js';
6
- import 'core-js/modules/esnext.async-iterator.for-each.js';
7
- import 'core-js/modules/esnext.iterator.for-each.js';
8
- import 'core-js/modules/web.dom-collections.iterator.js';
9
-
1
+ import * as React from "react";
10
2
  function getRealNextPath(prevPath, nextPath) {
11
- const {
12
- childrenProp
13
- } = this.props;
3
+ const { childrenProp } = this.props;
14
4
  const ppLastIndex = prevPath.length - 1;
15
5
  const npLastIndex = nextPath.length - 1;
16
-
17
6
  if (prevPath.length < nextPath.length) {
18
- // move into deep
19
7
  let wasShifted = false;
20
8
  return nextPath.map((nextIndex, i) => {
21
9
  if (wasShifted) {
22
10
  return i === npLastIndex ? nextIndex + 1 : nextIndex;
23
11
  }
24
-
25
- if (typeof prevPath[i] !== 'number') {
12
+ if (typeof prevPath[i] !== "number") {
26
13
  return nextIndex;
27
14
  }
28
-
29
15
  if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
30
16
  wasShifted = true;
31
17
  return nextIndex - 1;
32
18
  }
33
-
34
19
  return nextIndex;
35
20
  });
36
21
  }
37
-
38
22
  if (prevPath.length === nextPath.length) {
39
- // if move bottom + move to item with children => make it a first child instead of swap
40
23
  if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
41
24
  const target = this.getItemByPath(nextPath);
42
-
43
25
  if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
44
26
  return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
45
27
  }
46
28
  }
47
29
  }
48
-
49
30
  return nextPath;
50
31
  }
51
- function getPathById(id) {
52
- let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
53
- const {
54
- childrenProp
55
- } = this.props;
32
+ function getPathById(id, items = this.getDefaultItems()) {
33
+ const { childrenProp } = this.props;
56
34
  let path = [];
57
35
  items.every((item, i) => {
58
36
  if (item.id === id) {
59
37
  path.push(i);
60
38
  } else if (item[childrenProp]) {
61
39
  const childrenPath = this.getPathById(id, item[childrenProp]);
62
-
63
40
  if (childrenPath.length) {
64
41
  path = path.concat(i).concat(childrenPath);
65
42
  }
66
43
  }
67
-
68
44
  return path.length === 0;
69
45
  });
70
46
  return path;
71
47
  }
72
- function getItemByPath(path) {
73
- let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
74
- const {
75
- childrenProp
76
- } = this.props;
48
+ function getItemByPath(path, items = this.getDefaultItems()) {
49
+ const { childrenProp } = this.props;
77
50
  let item = null;
78
- path.forEach(index => {
51
+ path.forEach((index) => {
79
52
  const list = item ? item[childrenProp] : items;
80
53
  item = list[index];
81
54
  });
82
55
  return item;
83
56
  }
84
57
  function getItemDepth(item) {
85
- const {
86
- childrenProp
87
- } = this.props;
58
+ const { childrenProp } = this.props;
88
59
  let level = 1;
89
-
90
60
  if (item[childrenProp].length > 0) {
91
61
  const childrenDepths = item[childrenProp].map(this.getItemDepth);
92
62
  level += Math.max(...childrenDepths);
93
63
  }
94
-
95
64
  return level;
96
65
  }
97
- function getSplicePath(path) {
98
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
66
+ function getSplicePath(path, options = {}) {
99
67
  const splicePath = {};
100
68
  const numToRemove = options.numToRemove || 0;
101
69
  const itemsToInsert = options.itemsToInsert || [];
@@ -106,13 +74,17 @@ function getSplicePath(path) {
106
74
  currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
107
75
  } else {
108
76
  const nextPath = {};
109
- currentPath[index] = {
110
- [options.childrenProp]: nextPath
111
- };
77
+ currentPath[index] = { [options.childrenProp]: nextPath };
112
78
  currentPath = nextPath;
113
79
  }
114
80
  });
115
81
  return splicePath;
116
82
  }
117
-
118
- export { getItemByPath, getItemDepth, getPathById, getRealNextPath, getSplicePath };
83
+ export {
84
+ getItemByPath,
85
+ getItemDepth,
86
+ getPathById,
87
+ getRealNextPath,
88
+ getSplicePath
89
+ };
90
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/paths.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export function getRealNextPath(prevPath, nextPath) {\n const { childrenProp } = this.props;\n const ppLastIndex = prevPath.length - 1;\n const npLastIndex = nextPath.length - 1;\n\n if (prevPath.length < nextPath.length) {\n // move into deep\n let wasShifted = false;\n\n return nextPath.map((nextIndex, i) => {\n if (wasShifted) {\n return i === npLastIndex ? nextIndex + 1 : nextIndex;\n }\n\n if (typeof prevPath[i] !== 'number') {\n return nextIndex;\n }\n\n if (nextPath[i] > prevPath[i] && i === ppLastIndex) {\n wasShifted = true;\n return nextIndex - 1;\n }\n\n return nextIndex;\n });\n }\n\n if (prevPath.length === nextPath.length) {\n // if move bottom + move to item with children => make it a first child instead of swap\n if (nextPath[npLastIndex] > prevPath[npLastIndex]) {\n const target = this.getItemByPath(nextPath);\n\n if (\n target[childrenProp] &&\n target[childrenProp].length &&\n !this.isCollapsed(target)\n ) {\n return nextPath\n .slice(0, -1)\n .concat(nextPath[npLastIndex] - 1)\n .concat(0);\n }\n }\n }\n\n return nextPath;\n}\n\nexport function getPathById(id, items = this.getDefaultItems()) {\n const { childrenProp } = this.props;\n let path = [];\n\n items.every((item, i) => {\n if (item.id === id) {\n path.push(i);\n } else if (item[childrenProp]) {\n const childrenPath = this.getPathById(id, item[childrenProp]);\n\n if (childrenPath.length) {\n path = path.concat(i).concat(childrenPath);\n }\n }\n\n return path.length === 0;\n });\n\n return path;\n}\n\nexport function getItemByPath(path, items = this.getDefaultItems()) {\n const { childrenProp } = this.props;\n let item = null;\n\n path.forEach(index => {\n const list = item ? item[childrenProp] : items;\n item = list[index];\n });\n\n return item;\n}\n\nexport function getItemDepth(item) {\n const { childrenProp } = this.props;\n let level = 1;\n\n if (item[childrenProp].length > 0) {\n const childrenDepths = item[childrenProp].map(this.getItemDepth);\n level += Math.max(...childrenDepths);\n }\n\n return level;\n}\n\nexport function getSplicePath(path, options = {}) {\n const splicePath = {};\n const numToRemove = options.numToRemove || 0;\n const itemsToInsert = options.itemsToInsert || [];\n const lastIndex = path.length - 1;\n let currentPath = splicePath;\n\n path.forEach((index, i) => {\n if (i === lastIndex) {\n currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];\n } else {\n const nextPath = {};\n currentPath[index] = { [options.childrenProp]: nextPath };\n currentPath = nextPath;\n }\n });\n\n return splicePath;\n}\n"],
5
+ "mappings": "AAAA;ACAO,yBAAyB,UAAU,UAAU;AAClD,QAAM,EAAE,iBAAiB,KAAK;AAC9B,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