@elliemae/ds-shuttle 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 (188) hide show
  1. package/cjs/AnimationState.js +26 -42
  2. package/cjs/DSShuttle.js +54 -146
  3. package/cjs/SearchState.js +10 -22
  4. package/cjs/Shuttle.actions.js +65 -73
  5. package/cjs/ShuttleContainer.js +49 -77
  6. package/cjs/ShuttleImpl.js +250 -338
  7. package/cjs/ShuttleRenderer.js +121 -184
  8. package/cjs/ShuttleState.js +22 -39
  9. package/cjs/animation/animationConfig.js +56 -63
  10. package/cjs/classedComponents.js +32 -35
  11. package/cjs/components/LoadingIndicator.js +11 -12
  12. package/cjs/components/OverflowList.js +33 -29
  13. package/cjs/components/ShuttleBreadcrumb.js +26 -32
  14. package/cjs/components/ShuttleInfiniteScrollIndicator.js +17 -13
  15. package/cjs/components/ShuttleListItem/ActionButtons.js +39 -34
  16. package/cjs/components/ShuttleListItem/ShuttleListItem.js +59 -58
  17. package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +40 -61
  18. package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +35 -50
  19. package/cjs/components/ShuttleListPanel.js +11 -23
  20. package/cjs/components/ShuttleSearchBox.js +79 -102
  21. package/cjs/components/ShuttleSource.js +99 -169
  22. package/cjs/components/ShuttleTarget.js +62 -82
  23. package/cjs/components/VirtualizedItem.js +28 -22
  24. package/cjs/components/VirtualizedList.js +52 -50
  25. package/cjs/components/VirtualizedSortableList.js +25 -23
  26. package/cjs/helper.js +52 -82
  27. package/cjs/index.js +1 -60
  28. package/cjs/updateShuttleStateFromProps.js +41 -40
  29. package/cjs/utils.js +9 -9
  30. package/cjs/withProviders.js +15 -16
  31. package/esm/AnimationState.js +25 -40
  32. package/esm/DSShuttle.js +51 -143
  33. package/esm/SearchState.js +9 -20
  34. package/esm/Shuttle.actions.js +64 -71
  35. package/esm/ShuttleContainer.js +47 -75
  36. package/esm/ShuttleImpl.js +254 -334
  37. package/esm/ShuttleRenderer.js +117 -179
  38. package/esm/ShuttleState.js +17 -32
  39. package/esm/animation/animationConfig.js +56 -63
  40. package/esm/classedComponents.js +30 -33
  41. package/esm/components/LoadingIndicator.js +10 -11
  42. package/esm/components/OverflowList.js +30 -26
  43. package/esm/components/ShuttleBreadcrumb.js +23 -29
  44. package/esm/components/ShuttleInfiniteScrollIndicator.js +16 -12
  45. package/esm/components/ShuttleListItem/ActionButtons.js +38 -33
  46. package/esm/components/ShuttleListItem/ShuttleListItem.js +56 -55
  47. package/esm/components/ShuttleListItem/ShuttleSourceListItem.js +36 -56
  48. package/esm/components/ShuttleListItem/ShuttleTargetListItem.js +31 -46
  49. package/esm/components/ShuttleListPanel.js +10 -22
  50. package/esm/components/ShuttleSearchBox.js +78 -95
  51. package/esm/components/ShuttleSource.js +89 -157
  52. package/esm/components/ShuttleTarget.js +55 -75
  53. package/esm/components/VirtualizedItem.js +26 -20
  54. package/esm/components/VirtualizedList.js +48 -46
  55. package/esm/components/VirtualizedSortableList.js +21 -18
  56. package/esm/helper.js +49 -77
  57. package/esm/index.js +0 -59
  58. package/esm/updateShuttleStateFromProps.js +40 -38
  59. package/esm/utils.js +6 -4
  60. package/esm/withProviders.js +13 -15
  61. package/package.json +163 -18
  62. package/types/AnimationState.d.ts +26 -0
  63. package/types/DSShuttle.d.ts +341 -0
  64. package/types/SearchState.d.ts +22 -0
  65. package/types/Shuttle.actions.d.ts +11 -0
  66. package/types/ShuttleContainer.d.ts +3 -0
  67. package/types/ShuttleImpl.d.ts +3 -0
  68. package/types/ShuttleRenderer.d.ts +37 -0
  69. package/types/ShuttleState.d.ts +53 -0
  70. package/types/animation/animationConfig.d.ts +68 -0
  71. package/types/classedComponents.d.ts +14 -0
  72. package/types/components/LoadingIndicator.d.ts +3 -0
  73. package/types/components/OverflowList.d.ts +7 -0
  74. package/types/components/ShuttleBreadcrumb.d.ts +7 -0
  75. package/types/components/ShuttleInfiniteScrollIndicator.d.ts +5 -0
  76. package/types/components/ShuttleListItem/ActionButtons.d.ts +4 -0
  77. package/types/components/ShuttleListItem/ShuttleListItem.d.ts +14 -0
  78. package/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +13 -0
  79. package/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +13 -0
  80. package/types/components/ShuttleListPanel.d.ts +7 -0
  81. package/types/components/ShuttleSearchBox.d.ts +20 -0
  82. package/types/components/ShuttleSource.d.ts +54 -0
  83. package/types/components/ShuttleTarget.d.ts +16 -0
  84. package/types/components/VirtualizedItem.d.ts +3 -0
  85. package/types/components/VirtualizedList.d.ts +12 -0
  86. package/types/components/VirtualizedSortableList.d.ts +6 -0
  87. package/types/helper.d.ts +16 -0
  88. package/types/index.d.ts +1 -0
  89. package/types/tests/DSShuttle.events.test.d.ts +1 -0
  90. package/types/tests/DSShuttle.test.d.ts +1 -0
  91. package/types/tests/utils.d.ts +116 -0
  92. package/types/updateShuttleStateFromProps.d.ts +1 -0
  93. package/types/utils.d.ts +2 -0
  94. package/types/withProviders.d.ts +3 -0
  95. package/AnimationState/package.json +0 -10
  96. package/DSShuttle/package.json +0 -10
  97. package/SearchState/package.json +0 -10
  98. package/Shuttle.actions/package.json +0 -10
  99. package/ShuttleContainer/package.json +0 -10
  100. package/ShuttleImpl/package.json +0 -10
  101. package/ShuttleRenderer/package.json +0 -10
  102. package/ShuttleState/package.json +0 -10
  103. package/animation/animationConfig/package.json +0 -10
  104. package/cjs/AnimationState.js.map +0 -1
  105. package/cjs/DSShuttle.js.map +0 -1
  106. package/cjs/SearchState.js.map +0 -1
  107. package/cjs/Shuttle.actions.js.map +0 -1
  108. package/cjs/ShuttleContainer.js.map +0 -1
  109. package/cjs/ShuttleImpl.js.map +0 -1
  110. package/cjs/ShuttleRenderer.js.map +0 -1
  111. package/cjs/ShuttleState.js.map +0 -1
  112. package/cjs/animation/animationConfig.js.map +0 -1
  113. package/cjs/classedComponents.js.map +0 -1
  114. package/cjs/components/LoadingIndicator.js.map +0 -1
  115. package/cjs/components/OverflowList.js.map +0 -1
  116. package/cjs/components/ShuttleBreadcrumb.js.map +0 -1
  117. package/cjs/components/ShuttleInfiniteScrollIndicator.js.map +0 -1
  118. package/cjs/components/ShuttleListItem/ActionButtons.js.map +0 -1
  119. package/cjs/components/ShuttleListItem/ShuttleListItem.js.map +0 -1
  120. package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -1
  121. package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -1
  122. package/cjs/components/ShuttleListPanel.js.map +0 -1
  123. package/cjs/components/ShuttleSearchBox.js.map +0 -1
  124. package/cjs/components/ShuttleSource.js.map +0 -1
  125. package/cjs/components/ShuttleTarget.js.map +0 -1
  126. package/cjs/components/VirtualizedItem.js.map +0 -1
  127. package/cjs/components/VirtualizedList.js.map +0 -1
  128. package/cjs/components/VirtualizedSortableList.js.map +0 -1
  129. package/cjs/helper.js.map +0 -1
  130. package/cjs/index.js.map +0 -1
  131. package/cjs/tests/utils.js +0 -1112
  132. package/cjs/tests/utils.js.map +0 -1
  133. package/cjs/updateShuttleStateFromProps.js.map +0 -1
  134. package/cjs/utils.js.map +0 -1
  135. package/cjs/withProviders.js.map +0 -1
  136. package/classedComponents/package.json +0 -10
  137. package/components/LoadingIndicator/package.json +0 -10
  138. package/components/OverflowList/package.json +0 -10
  139. package/components/ShuttleBreadcrumb/package.json +0 -10
  140. package/components/ShuttleInfiniteScrollIndicator/package.json +0 -10
  141. package/components/ShuttleListItem/ActionButtons/package.json +0 -10
  142. package/components/ShuttleListItem/ShuttleListItem/package.json +0 -10
  143. package/components/ShuttleListItem/ShuttleSourceListItem/package.json +0 -10
  144. package/components/ShuttleListItem/ShuttleTargetListItem/package.json +0 -10
  145. package/components/ShuttleListPanel/package.json +0 -10
  146. package/components/ShuttleSearchBox/package.json +0 -10
  147. package/components/ShuttleSource/package.json +0 -10
  148. package/components/ShuttleTarget/package.json +0 -10
  149. package/components/VirtualizedItem/package.json +0 -10
  150. package/components/VirtualizedList/package.json +0 -10
  151. package/components/VirtualizedSortableList/package.json +0 -10
  152. package/esm/AnimationState.js.map +0 -1
  153. package/esm/DSShuttle.js.map +0 -1
  154. package/esm/SearchState.js.map +0 -1
  155. package/esm/Shuttle.actions.js.map +0 -1
  156. package/esm/ShuttleContainer.js.map +0 -1
  157. package/esm/ShuttleImpl.js.map +0 -1
  158. package/esm/ShuttleRenderer.js.map +0 -1
  159. package/esm/ShuttleState.js.map +0 -1
  160. package/esm/animation/animationConfig.js.map +0 -1
  161. package/esm/classedComponents.js.map +0 -1
  162. package/esm/components/LoadingIndicator.js.map +0 -1
  163. package/esm/components/OverflowList.js.map +0 -1
  164. package/esm/components/ShuttleBreadcrumb.js.map +0 -1
  165. package/esm/components/ShuttleInfiniteScrollIndicator.js.map +0 -1
  166. package/esm/components/ShuttleListItem/ActionButtons.js.map +0 -1
  167. package/esm/components/ShuttleListItem/ShuttleListItem.js.map +0 -1
  168. package/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -1
  169. package/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -1
  170. package/esm/components/ShuttleListPanel.js.map +0 -1
  171. package/esm/components/ShuttleSearchBox.js.map +0 -1
  172. package/esm/components/ShuttleSource.js.map +0 -1
  173. package/esm/components/ShuttleTarget.js.map +0 -1
  174. package/esm/components/VirtualizedItem.js.map +0 -1
  175. package/esm/components/VirtualizedList.js.map +0 -1
  176. package/esm/components/VirtualizedSortableList.js.map +0 -1
  177. package/esm/helper.js.map +0 -1
  178. package/esm/index.js.map +0 -1
  179. package/esm/tests/utils.js +0 -1100
  180. package/esm/tests/utils.js.map +0 -1
  181. package/esm/updateShuttleStateFromProps.js.map +0 -1
  182. package/esm/utils.js.map +0 -1
  183. package/esm/withProviders.js.map +0 -1
  184. package/helper/package.json +0 -10
  185. package/tests/utils/package.json +0 -10
  186. package/updateShuttleStateFromProps/package.json +0 -10
  187. package/utils/package.json +0 -10
  188. package/withProviders/package.json +0 -10
@@ -1,13 +1,18 @@
1
- import _extends from '@babel/runtime/helpers/esm/extends';
1
+ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
2
  import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
3
- import _toConsumableArray from '@babel/runtime/helpers/esm/toConsumableArray';
4
- import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';
5
- import _createClass from '@babel/runtime/helpers/esm/createClass';
6
- import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
7
- import _inherits from '@babel/runtime/helpers/esm/inherits';
8
- import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';
9
- import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';
10
- import React, { Component } from 'react';
3
+ import 'core-js/modules/esnext.async-iterator.filter.js';
4
+ import 'core-js/modules/esnext.iterator.constructor.js';
5
+ import 'core-js/modules/esnext.iterator.filter.js';
6
+ import 'core-js/modules/esnext.async-iterator.some.js';
7
+ import 'core-js/modules/esnext.iterator.some.js';
8
+ import 'core-js/modules/esnext.async-iterator.map.js';
9
+ import 'core-js/modules/esnext.iterator.map.js';
10
+ import 'core-js/modules/web.dom-collections.iterator.js';
11
+ import 'core-js/modules/esnext.async-iterator.find.js';
12
+ import 'core-js/modules/esnext.iterator.find.js';
13
+ import 'core-js/modules/esnext.async-iterator.for-each.js';
14
+ import 'core-js/modules/esnext.iterator.for-each.js';
15
+ import { Component } from 'react';
11
16
  import { arrayMove, compose } from '@elliemae/ds-utilities';
12
17
  import withProviders from './withProviders.js';
13
18
  import { navigateTo, resetCheckedItems, resetMovedItems, addToTarget, removeFromTarget, toggleItemSelection } from './Shuttle.actions.js';
@@ -15,70 +20,26 @@ import { pipe, getItemsById, getActiveIdFromHierarchy, filterBySearch, filterMov
15
20
  import ShuttleRenderer from './ShuttleRenderer.js';
16
21
  import SearchState from './SearchState.js';
17
22
  import updateShuttleStateFromProps from './updateShuttleStateFromProps.js';
18
- import './AnimationState.js';
19
- import '@babel/runtime/helpers/esm/slicedToArray';
20
- import 'constate';
21
- import './ShuttleState.js';
22
- import '@babel/runtime/helpers/esm/defineProperty';
23
- import 'treetabular';
24
- import './utils.js';
25
- import './components/ShuttleSource.js';
26
- import 'prop-types';
27
- import '@elliemae/ds-icons';
28
- import '@elliemae/ds-button';
29
- import './components/ShuttleSearchBox.js';
30
- import '@elliemae/ds-classnames';
31
- import '@elliemae/ds-form';
32
- import './components/ShuttleInfiniteScrollIndicator.js';
33
- import '@elliemae/ds-indeterminate-progress-indicator';
34
- import './components/ShuttleListItem/ShuttleSourceListItem.js';
35
- import './components/ShuttleListItem/ActionButtons.js';
36
- import './components/ShuttleListItem/ShuttleListItem.js';
37
- import 'react-spring/web.cjs';
38
- import '@elliemae/ds-truncated-tooltip-text';
39
- import 'react-sortable-hoc';
40
- import './classedComponents.js';
41
- import './components/ShuttleBreadcrumb.js';
42
- import '@elliemae/ds-breadcrumb';
43
- import './animation/animationConfig.js';
44
- import './components/OverflowList.js';
45
- import './components/ShuttleListPanel.js';
46
- import './components/VirtualizedList.js';
47
- import 'react-window';
48
- import 'react-window-infinite-loader';
49
- import 'react-virtualized-auto-sizer';
50
- import './components/VirtualizedItem.js';
51
- import './components/VirtualizedSortableList.js';
52
- import './components/LoadingIndicator.js';
53
- import '@elliemae/ds-circular-progress-indicator';
54
- import 'styled-components';
55
- import './components/ShuttleTarget.js';
56
- import './components/ShuttleListItem/ShuttleTargetListItem.js';
57
-
58
- var _excluded = ["idField", "nonSelectedItems", "moreItemsLoading"];
59
-
60
- 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); }; }
61
-
62
- 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; } }
63
-
64
- var ShuttleImpl = /*#__PURE__*/function (_Component) {
65
- _inherits(ShuttleImpl, _Component);
66
-
67
- var _super = _createSuper(ShuttleImpl);
68
-
69
- function ShuttleImpl(props) {
70
- var _this;
71
-
72
- _classCallCheck(this, ShuttleImpl);
73
-
74
- _this = _super.call(this, props);
75
-
76
- _this.getState = function () {
77
- var movedItems = _this.state.movedItems;
23
+ import { jsx } from 'react/jsx-runtime';
24
+
25
+ const _excluded = ["idField", "nonSelectedItems", "moreItemsLoading"];
26
+
27
+ 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; }
28
+
29
+ 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; }
30
+
31
+ class ShuttleImpl extends Component {
32
+ constructor(props) {
33
+ super(props);
34
+
35
+ this.getState = () => {
36
+ const {
37
+ movedItems
38
+ } = this.state;
78
39
  return Object.keys(movedItems);
79
40
  };
80
41
 
81
- _this.state = {
42
+ this.state = {
82
43
  prevProps: {},
83
44
  preparedItems: [],
84
45
  checkedItems: [],
@@ -96,289 +57,248 @@ var ShuttleImpl = /*#__PURE__*/function (_Component) {
96
57
  sourceItems: [],
97
58
  targetItems: []
98
59
  };
99
- _this.toggleItemSelection = _this.toggleItemSelection.bind(_assertThisInitialized(_this));
100
- _this.resetCheckedItems = _this.resetCheckedItems.bind(_assertThisInitialized(_this));
101
- _this.resetMovedItems = _this.resetMovedItems.bind(_assertThisInitialized(_this));
102
- _this.moveCheckedItems = _this.moveCheckedItems.bind(_assertThisInitialized(_this));
103
- _this.handleTargetSortEnd = _this.handleTargetSortEnd.bind(_assertThisInitialized(_this));
104
- return _this;
60
+ this.toggleItemSelection = this.toggleItemSelection.bind(this);
61
+ this.resetCheckedItems = this.resetCheckedItems.bind(this);
62
+ this.resetMovedItems = this.resetMovedItems.bind(this);
63
+ this.moveCheckedItems = this.moveCheckedItems.bind(this);
64
+ this.handleTargetSortEnd = this.handleTargetSortEnd.bind(this);
105
65
  }
106
66
 
107
- _createClass(ShuttleImpl, [{
108
- key: "componentDidMount",
109
- value: function componentDidMount() {
110
- var setGetStatus = this.props.setGetStatus;
111
- setGetStatus(this.getState);
112
- }
113
- }, {
114
- key: "handleChange",
115
- value: function handleChange() {
116
- var onChange = this.props.onChange;
117
- var movedItems = this.state.movedItems;
118
- onChange(Object.keys(movedItems));
119
- }
120
- }, {
121
- key: "navigate",
122
- value: function navigate(item, dest, direction) {
123
- var _this$props = this.props,
124
- onDrillDown = _this$props.onDrillDown,
125
- onDrillDownTarget = _this$props.onDrillDownTarget;
126
- if (!dest) onDrillDown(item, direction);
127
- if (dest) onDrillDownTarget(item, direction);
128
- var resetSearchState = this.context.reset;
129
- resetSearchState();
130
- this.setState(pipe([navigateTo(item, dest), resetCheckedItems()]));
131
- }
132
- }, {
133
- key: "resetCheckedItems",
134
- value: function resetCheckedItems$1() {
135
- this.setState(resetCheckedItems());
136
- }
137
- }, {
138
- key: "resetMovedItems",
139
- value: function resetMovedItems$1() {
140
- var _this2 = this;
141
-
142
- var _this$props2 = this.props,
143
- selectedItems = _this$props2.selectedItems,
144
- onRemoveAllFromTarget = _this$props2.onRemoveAllFromTarget;
145
-
146
- if (!selectedItems) {
147
- this.setState(pipe([navigateTo({
148
- id: null
149
- }, true), resetMovedItems()]), function () {
150
- _this2.handleChange();
151
- });
152
- } else {
153
- this.setState(pipe([navigateTo({
154
- id: null
155
- }, true)]));
156
- }
67
+ static getDerivedStateFromProps(nextProps, prevState) {
68
+ return updateShuttleStateFromProps(nextProps, prevState);
69
+ }
157
70
 
158
- onRemoveAllFromTarget();
159
- }
160
- }, {
161
- key: "addToTarget",
162
- value: function addToTarget$1(item) {
163
- var _this3 = this;
164
-
165
- var _this$props3 = this.props,
166
- selectedItems = _this$props3.selectedItems,
167
- onAddToTarget = _this$props3.onAddToTarget;
168
-
169
- if (!selectedItems) {
170
- this.setState(pipe([addToTarget(item), resetCheckedItems()]), function () {
171
- _this3.handleChange();
172
- });
173
- }
71
+ componentDidMount() {
72
+ const {
73
+ setGetStatus
74
+ } = this.props;
75
+ setGetStatus(this.getState);
76
+ }
174
77
 
175
- onAddToTarget(item);
176
- }
177
- }, {
178
- key: "removeFromTarget",
179
- value: function removeFromTarget$1(item) {
180
- var _this4 = this;
181
-
182
- var _this$props4 = this.props,
183
- selectedItems = _this$props4.selectedItems,
184
- onRemoveFromTarget = _this$props4.onRemoveFromTarget;
185
-
186
- if (!selectedItems) {
187
- this.setState(pipe([removeFromTarget(item)]), function () {
188
- _this4.handleChange();
189
- });
190
- }
78
+ handleChange() {
79
+ const {
80
+ onChange
81
+ } = this.props;
82
+ const {
83
+ movedItems
84
+ } = this.state;
85
+ onChange(Object.keys(movedItems));
86
+ }
191
87
 
192
- onRemoveFromTarget(item);
193
- }
194
- }, {
195
- key: "toggleItemSelection",
196
- value: function toggleItemSelection$1(item) {
197
- this.setState(toggleItemSelection(item.id));
198
- }
199
- }, {
200
- key: "moveCheckedItems",
201
- value: function moveCheckedItems() {
202
- var _this5 = this;
203
-
204
- var _this$props5 = this.props,
205
- onAddCheckedItems = _this$props5.onAddCheckedItems,
206
- selectedItems = _this$props5.selectedItems,
207
- nonSelectedItems = _this$props5.nonSelectedItems;
208
- var _this$state = this.state,
209
- checkedItems = _this$state.checkedItems,
210
- preparedItems = _this$state.preparedItems;
211
- var isControlledV2 = !!selectedItems && !!nonSelectedItems;
212
- var checked = isControlledV2 ? nonSelectedItems.filter(function (item) {
213
- return checkedItems.some(function (check) {
214
- return check === item;
215
- });
216
- }) : checkedItems;
217
- var items = getItemsById(checked, preparedItems);
218
- var actions = !selectedItems ? items.map(function (item) {
219
- return addToTarget(item);
220
- }) : [];
221
- this.setState(pipe([].concat(_toConsumableArray(actions), [resetCheckedItems()])), function () {
222
- _this5.handleChange();
88
+ navigate(item, dest, direction) {
89
+ const {
90
+ onDrillDown,
91
+ onDrillDownTarget
92
+ } = this.props;
93
+ if (!dest) onDrillDown(item, direction);
94
+ if (dest) onDrillDownTarget(item, direction);
95
+ const {
96
+ reset: resetSearchState
97
+ } = this.context;
98
+ resetSearchState();
99
+ this.setState(pipe([navigateTo(item, dest), resetCheckedItems()]));
100
+ }
101
+
102
+ resetCheckedItems() {
103
+ this.setState(resetCheckedItems());
104
+ }
105
+
106
+ resetMovedItems() {
107
+ const {
108
+ selectedItems,
109
+ onRemoveAllFromTarget
110
+ } = this.props;
111
+
112
+ if (!selectedItems) {
113
+ this.setState(pipe([navigateTo({
114
+ id: null
115
+ }, true), resetMovedItems()]), () => {
116
+ this.handleChange();
223
117
  });
224
- onAddCheckedItems(items);
118
+ } else {
119
+ this.setState(pipe([navigateTo({
120
+ id: null
121
+ }, true)]));
225
122
  }
226
- }, {
227
- key: "handleTargetSortEnd",
228
- value: function handleTargetSortEnd(_ref) {
229
- var sourceItem = _ref.sourceItem,
230
- targetItem = _ref.targetItem;
231
- var _this$props6 = this.props,
232
- idField = _this$props6.idField,
233
- onTargetSortEnd = _this$props6.onTargetSortEnd;
234
- var _this$state2 = this.state,
235
- targetItems = _this$state2.targetItems,
236
- hierarchyDest = _this$state2.hierarchyDest,
237
- movedItems = _this$state2.movedItems;
238
- var hierarchyId = getActiveIdFromHierarchy(hierarchyDest).id;
239
- var collection = !hierarchyId ? movedItems : targetItems;
240
- var oldIndex = collection.findIndex(function (tItem) {
241
- return tItem[idField] === sourceItem[idField];
242
- });
243
- var newIndex = collection.findIndex(function (tItem) {
244
- return tItem[idField] === targetItem[idField];
245
- });
246
- var sortedMovedItems = !hierarchyId ? arrayMove(movedItems, oldIndex, newIndex) : movedItems;
247
- var sortedItems = hierarchyId ? arrayMove(targetItems, oldIndex, newIndex) : targetItems;
248
- this.setState({
249
- targetItems: sortedItems,
250
- movedItems: sortedMovedItems
123
+
124
+ onRemoveAllFromTarget();
125
+ }
126
+
127
+ addToTarget(item) {
128
+ const {
129
+ selectedItems,
130
+ onAddToTarget
131
+ } = this.props;
132
+
133
+ if (!selectedItems) {
134
+ this.setState(pipe([addToTarget(item), resetCheckedItems()]), () => {
135
+ this.handleChange();
251
136
  });
252
- onTargetSortEnd({
253
- sourceItem: sourceItem,
254
- targetItem: targetItem
137
+ }
138
+
139
+ onAddToTarget(item);
140
+ }
141
+
142
+ removeFromTarget(item) {
143
+ const {
144
+ selectedItems,
145
+ onRemoveFromTarget
146
+ } = this.props;
147
+
148
+ if (!selectedItems) {
149
+ this.setState(pipe([removeFromTarget(item)]), () => {
150
+ this.handleChange();
255
151
  });
256
152
  }
257
- }, {
258
- key: "render",
259
- value: function render() {
260
- var _this6 = this;
261
-
262
- var _this$props7 = this.props;
263
- _this$props7.idField;
264
- var nonSelectedItems = _this$props7.nonSelectedItems,
265
- moreItemsLoading = _this$props7.moreItemsLoading,
266
- rest = _objectWithoutProperties(_this$props7, _excluded);
267
-
268
- var _this$state3 = this.state,
269
- hierarchy = _this$state3.hierarchy,
270
- hierarchyDest = _this$state3.hierarchyDest,
271
- checkedItems = _this$state3.checkedItems,
272
- movedItems = _this$state3.movedItems,
273
- items = _this$state3.preparedItems,
274
- targetItems = _this$state3.targetItems;
275
- var _this$context$state = this.context.state,
276
- searchTerm = _this$context$state.searchTerm,
277
- searching = _this$context$state.searching;
278
-
279
- var handleControlledSourceItms = function handleControlledSourceItms() {
280
- var _getActiveIdFromHiera = getActiveIdFromHierarchy(hierarchy),
281
- id = _getActiveIdFromHiera.id;
282
-
283
- if (id) {
284
- return filterBySearch(searchTerm, searching)(getChildrenFromParent(id)(nonSelectedItems.map(function (it) {
285
- return items.find(function (itt) {
286
- return itt.id === it;
287
- });
288
- })));
289
- }
290
-
291
- return filterBySearch(searchTerm, searching)(items.filter(function (it) {
292
- return nonSelectedItems.some(function (itt) {
293
- return itt === it.id && !nonSelectedItems.some(function (ittt) {
294
- return ittt === it.parent;
295
- });
296
- });
297
- }));
298
- };
299
-
300
- var composedSourceItems; // controlled V2 TODO make it default controlled behavior
301
-
302
- if (nonSelectedItems) {
303
- composedSourceItems = handleControlledSourceItms();
304
- } else {
305
- composedSourceItems = compose(filterBySearch(searchTerm, searching), filterMovedItems(movedItems), getChildrenFromParent(getActiveIdFromHierarchy(hierarchy).id))(items);
153
+
154
+ onRemoveFromTarget(item);
155
+ }
156
+
157
+ toggleItemSelection(item) {
158
+ this.setState(toggleItemSelection(item.id));
159
+ }
160
+
161
+ moveCheckedItems() {
162
+ const {
163
+ onAddCheckedItems,
164
+ selectedItems,
165
+ nonSelectedItems
166
+ } = this.props;
167
+ const {
168
+ checkedItems,
169
+ preparedItems
170
+ } = this.state;
171
+ const isControlledV2 = !!selectedItems && !!nonSelectedItems;
172
+ const checked = isControlledV2 ? nonSelectedItems.filter(item => checkedItems.some(check => check === item)) : checkedItems;
173
+ const items = getItemsById(checked, preparedItems);
174
+ const actions = !selectedItems ? items.map(item => addToTarget(item)) : [];
175
+ this.setState(pipe([...actions, resetCheckedItems()]), () => {
176
+ this.handleChange();
177
+ });
178
+ onAddCheckedItems(items);
179
+ }
180
+
181
+ handleTargetSortEnd(_ref) {
182
+ let {
183
+ sourceItem,
184
+ targetItem
185
+ } = _ref;
186
+ const {
187
+ idField,
188
+ onTargetSortEnd
189
+ } = this.props;
190
+ const {
191
+ targetItems,
192
+ hierarchyDest,
193
+ movedItems
194
+ } = this.state;
195
+ const hierarchyId = getActiveIdFromHierarchy(hierarchyDest).id;
196
+ const collection = !hierarchyId ? movedItems : targetItems;
197
+ const oldIndex = collection.findIndex(tItem => tItem[idField] === sourceItem[idField]);
198
+ const newIndex = collection.findIndex(tItem => tItem[idField] === targetItem[idField]);
199
+ const sortedMovedItems = !hierarchyId ? arrayMove(movedItems, oldIndex, newIndex) : movedItems;
200
+ const sortedItems = hierarchyId ? arrayMove(targetItems, oldIndex, newIndex) : targetItems;
201
+ this.setState({
202
+ targetItems: sortedItems,
203
+ movedItems: sortedMovedItems
204
+ });
205
+ onTargetSortEnd({
206
+ sourceItem,
207
+ targetItem
208
+ });
209
+ }
210
+
211
+ render() {
212
+ const _this$props = this.props,
213
+ {
214
+ idField,
215
+ nonSelectedItems,
216
+ moreItemsLoading
217
+ } = _this$props,
218
+ rest = _objectWithoutProperties(_this$props, _excluded);
219
+
220
+ const {
221
+ hierarchy,
222
+ hierarchyDest,
223
+ checkedItems,
224
+ movedItems,
225
+ preparedItems: items,
226
+ targetItems
227
+ } = this.state;
228
+ const {
229
+ state: {
230
+ searchTerm,
231
+ searching
306
232
  }
233
+ } = this.context;
234
+
235
+ const handleControlledSourceItms = () => {
236
+ const {
237
+ id
238
+ } = getActiveIdFromHierarchy(hierarchy);
307
239
 
308
- var handleControlledTargetItms = function handleControlledTargetItms() {
309
- var _getActiveIdFromHiera2 = getActiveIdFromHierarchy(hierarchyDest),
310
- id = _getActiveIdFromHiera2.id;
311
-
312
- if (id) {
313
- return getChildrenFromParent(getActiveIdFromHierarchy(hierarchyDest).id)(_this6.props.selectedItems.map(function (it) {
314
- return items.find(function (itt) {
315
- return itt.id === it;
316
- });
317
- }));
318
- }
319
-
320
- return targetItems.filter(function (it) {
321
- return _this6.props.selectedItems.some(function (itt) {
322
- return itt === it.id && !_this6.props.selectedItems.some(function (ittt) {
323
- return ittt === it.parent;
324
- });
325
- });
326
- });
327
- };
328
-
329
- var composedTargetItems; // controlled V2 TODO make it default controlled behavior
330
-
331
- if (nonSelectedItems) {
332
- composedTargetItems = handleControlledTargetItms();
333
- } else {
334
- composedTargetItems = compose(function (tItems) {
335
- var hierarchyId = getActiveIdFromHierarchy(hierarchyDest).id;
336
- return hierarchyId ? compose(filterMovedItems(movedItems), getChildrenFromParent(hierarchyId))(tItems) : movedItems;
337
- })(targetItems);
240
+ if (id) {
241
+ return filterBySearch(searchTerm, searching)(getChildrenFromParent(id)(nonSelectedItems.map(it => items.find(itt => itt.id === it))));
338
242
  }
339
243
 
340
- return /*#__PURE__*/React.createElement(ShuttleRenderer, _extends({}, rest, {
341
- moreItemsLoading: moreItemsLoading,
342
- checkedItems: checkedItems,
343
- hierarchy: hierarchy,
344
- hierarchyDest: hierarchyDest,
345
- onCheckItem: this.toggleItemSelection,
346
- onClearCheckedItems: this.resetCheckedItems,
347
- onClearMovedItems: this.resetMovedItems,
348
- onItemCheck: this.toggleItemSelection,
349
- onMoveCheckedItems: this.moveCheckedItems,
350
- onMoveItemToSource: function onMoveItemToSource(item) {
351
- return _this6.removeFromTarget(item, false);
352
- },
353
- onMoveItemToTarget: function onMoveItemToTarget(item) {
354
- return _this6.addToTarget(item, true);
355
- },
356
- onNavigateOnSourceTo: function onNavigateOnSourceTo(item, direction) {
357
- return _this6.navigate(item, false, direction);
358
- },
359
- onNavigateOnTargetTo: function onNavigateOnTargetTo(item, direction) {
360
- return _this6.navigate(item, true, direction);
361
- },
362
- onSourceSortEnd: function onSourceSortEnd() {
363
- return null;
364
- },
365
- onTargetSortEnd: this.handleTargetSortEnd,
366
- sourceItems: composedSourceItems,
367
- targetItems: composedTargetItems
368
- }));
244
+ return filterBySearch(searchTerm, searching)(items.filter(it => nonSelectedItems.some(itt => itt === it.id && !nonSelectedItems.some(ittt => ittt === it.parent))));
245
+ };
246
+
247
+ let composedSourceItems; // controlled V2 TODO make it default controlled behavior
248
+
249
+ if (nonSelectedItems) {
250
+ composedSourceItems = handleControlledSourceItms();
251
+ } else {
252
+ composedSourceItems = compose(filterBySearch(searchTerm, searching), filterMovedItems(movedItems), getChildrenFromParent(getActiveIdFromHierarchy(hierarchy).id))(items);
369
253
  }
370
- }], [{
371
- key: "getDerivedStateFromProps",
372
- value: function getDerivedStateFromProps(nextProps, prevState) {
373
- return updateShuttleStateFromProps(nextProps, prevState);
254
+
255
+ const handleControlledTargetItms = () => {
256
+ const {
257
+ id
258
+ } = getActiveIdFromHierarchy(hierarchyDest);
259
+
260
+ if (id) {
261
+ return getChildrenFromParent(getActiveIdFromHierarchy(hierarchyDest).id)(this.props.selectedItems.map(it => items.find(itt => itt.id === it)));
262
+ }
263
+
264
+ return targetItems.filter(it => this.props.selectedItems.some(itt => itt === it.id && !this.props.selectedItems.some(ittt => ittt === it.parent)));
265
+ };
266
+
267
+ let composedTargetItems; // controlled V2 TODO make it default controlled behavior
268
+
269
+ if (nonSelectedItems) {
270
+ composedTargetItems = handleControlledTargetItms();
271
+ } else {
272
+ composedTargetItems = compose(tItems => {
273
+ const hierarchyId = getActiveIdFromHierarchy(hierarchyDest).id;
274
+ return hierarchyId ? compose(filterMovedItems(movedItems), getChildrenFromParent(hierarchyId))(tItems) : movedItems;
275
+ })(targetItems);
374
276
  }
375
- }]);
376
277
 
377
- return ShuttleImpl;
378
- }(Component);
278
+ return /*#__PURE__*/jsx(ShuttleRenderer, _objectSpread(_objectSpread({}, rest), {}, {
279
+ moreItemsLoading: moreItemsLoading,
280
+ checkedItems: checkedItems,
281
+ hierarchy: hierarchy,
282
+ hierarchyDest: hierarchyDest,
283
+ onCheckItem: this.toggleItemSelection,
284
+ onClearCheckedItems: this.resetCheckedItems,
285
+ onClearMovedItems: this.resetMovedItems,
286
+ onItemCheck: this.toggleItemSelection,
287
+ onMoveCheckedItems: this.moveCheckedItems,
288
+ onMoveItemToSource: item => this.removeFromTarget(item, false),
289
+ onMoveItemToTarget: item => this.addToTarget(item, true),
290
+ onNavigateOnSourceTo: (item, direction) => this.navigate(item, false, direction),
291
+ onNavigateOnTargetTo: (item, direction) => this.navigate(item, true, direction),
292
+ onSourceSortEnd: () => null,
293
+ onTargetSortEnd: this.handleTargetSortEnd,
294
+ sourceItems: composedSourceItems,
295
+ targetItems: composedTargetItems
296
+ }));
297
+ }
298
+
299
+ }
379
300
 
380
301
  ShuttleImpl.contextType = SearchState.Context;
381
302
  var ShuttleImpl$1 = withProviders(ShuttleImpl);
382
303
 
383
304
  export { ShuttleImpl$1 as default };
384
- //# sourceMappingURL=ShuttleImpl.js.map