@elliemae/ds-shuttle 2.2.0-next.4 → 2.3.0-alpha.2

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 (148) hide show
  1. package/cjs/AnimationState.js +46 -19
  2. package/cjs/AnimationState.js.map +7 -0
  3. package/cjs/DSShuttle.js +166 -219
  4. package/cjs/DSShuttle.js.map +7 -0
  5. package/cjs/SearchState.js +44 -25
  6. package/cjs/SearchState.js.map +7 -0
  7. package/cjs/Shuttle.actions.js +87 -98
  8. package/cjs/Shuttle.actions.js.map +7 -0
  9. package/cjs/ShuttleContainer.js +56 -61
  10. package/cjs/ShuttleContainer.js.map +7 -0
  11. package/cjs/ShuttleImpl.js +109 -206
  12. package/cjs/ShuttleImpl.js.map +7 -0
  13. package/cjs/ShuttleRenderer.js +140 -135
  14. package/cjs/ShuttleRenderer.js.map +7 -0
  15. package/cjs/ShuttleState.js +57 -53
  16. package/cjs/ShuttleState.js.map +7 -0
  17. package/cjs/animation/animationConfig.js +53 -56
  18. package/cjs/animation/animationConfig.js.map +7 -0
  19. package/cjs/classedComponents.js +70 -69
  20. package/cjs/classedComponents.js.map +7 -0
  21. package/cjs/components/LoadingIndicator.js +49 -22
  22. package/cjs/components/LoadingIndicator.js.map +7 -0
  23. package/cjs/components/OverflowList.js +50 -48
  24. package/cjs/components/OverflowList.js.map +7 -0
  25. package/cjs/components/ShuttleBreadcrumb.js +52 -40
  26. package/cjs/components/ShuttleBreadcrumb.js.map +7 -0
  27. package/cjs/components/ShuttleInfiniteScrollIndicator.js +46 -37
  28. package/cjs/components/ShuttleInfiniteScrollIndicator.js.map +7 -0
  29. package/cjs/components/ShuttleListItem/ActionButtons.js +56 -51
  30. package/cjs/components/ShuttleListItem/ActionButtons.js.map +7 -0
  31. package/cjs/components/ShuttleListItem/ShuttleListItem.js +78 -80
  32. package/cjs/components/ShuttleListItem/ShuttleListItem.js.map +7 -0
  33. package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +78 -64
  34. package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +7 -0
  35. package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +72 -56
  36. package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +7 -0
  37. package/cjs/components/ShuttleListPanel.js +44 -26
  38. package/cjs/components/ShuttleListPanel.js.map +7 -0
  39. package/cjs/components/ShuttleSearchBox.js +61 -72
  40. package/cjs/components/ShuttleSearchBox.js.map +7 -0
  41. package/cjs/components/ShuttleSource.js +150 -146
  42. package/cjs/components/ShuttleSource.js.map +7 -0
  43. package/cjs/components/ShuttleTarget.js +88 -100
  44. package/cjs/components/ShuttleTarget.js.map +7 -0
  45. package/cjs/components/VirtualizedItem.js +45 -40
  46. package/cjs/components/VirtualizedItem.js.map +7 -0
  47. package/cjs/components/VirtualizedList.js +81 -86
  48. package/cjs/components/VirtualizedList.js.map +7 -0
  49. package/cjs/components/VirtualizedSortableList.js +47 -40
  50. package/cjs/components/VirtualizedSortableList.js.map +7 -0
  51. package/cjs/helper.js +69 -103
  52. package/cjs/helper.js.map +7 -0
  53. package/cjs/index.js +38 -12
  54. package/cjs/index.js.map +7 -0
  55. package/cjs/tests/utils.js +1218 -0
  56. package/cjs/tests/utils.js.map +7 -0
  57. package/cjs/updateShuttleStateFromProps.js +73 -69
  58. package/cjs/updateShuttleStateFromProps.js.map +7 -0
  59. package/cjs/utils.js +40 -42
  60. package/cjs/utils.js.map +7 -0
  61. package/cjs/withProviders.js +43 -27
  62. package/cjs/withProviders.js.map +7 -0
  63. package/esm/AnimationState.js +12 -8
  64. package/esm/AnimationState.js.map +7 -0
  65. package/esm/DSShuttle.js +126 -198
  66. package/esm/DSShuttle.js.map +7 -0
  67. package/esm/SearchState.js +15 -19
  68. package/esm/SearchState.js.map +7 -0
  69. package/esm/Shuttle.actions.js +63 -80
  70. package/esm/Shuttle.actions.js.map +7 -0
  71. package/esm/ShuttleContainer.js +34 -50
  72. package/esm/ShuttleContainer.js.map +7 -0
  73. package/esm/ShuttleImpl.js +78 -183
  74. package/esm/ShuttleImpl.js.map +7 -0
  75. package/esm/ShuttleRenderer.js +111 -128
  76. package/esm/ShuttleRenderer.js.map +7 -0
  77. package/esm/ShuttleState.js +34 -53
  78. package/esm/ShuttleState.js.map +7 -0
  79. package/esm/animation/animationConfig.js +24 -52
  80. package/esm/animation/animationConfig.js.map +7 -0
  81. package/esm/classedComponents.js +43 -51
  82. package/esm/classedComponents.js.map +7 -0
  83. package/esm/components/LoadingIndicator.js +20 -15
  84. package/esm/components/LoadingIndicator.js.map +7 -0
  85. package/esm/components/OverflowList.js +21 -41
  86. package/esm/components/OverflowList.js.map +7 -0
  87. package/esm/components/ShuttleBreadcrumb.js +23 -33
  88. package/esm/components/ShuttleBreadcrumb.js.map +7 -0
  89. package/esm/components/ShuttleInfiniteScrollIndicator.js +18 -31
  90. package/esm/components/ShuttleInfiniteScrollIndicator.js.map +7 -0
  91. package/esm/components/ShuttleListItem/ActionButtons.js +27 -39
  92. package/esm/components/ShuttleListItem/ActionButtons.js.map +7 -0
  93. package/esm/components/ShuttleListItem/ShuttleListItem.js +50 -72
  94. package/esm/components/ShuttleListItem/ShuttleListItem.js.map +7 -0
  95. package/esm/components/ShuttleListItem/ShuttleSourceListItem.js +45 -52
  96. package/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +7 -0
  97. package/esm/components/ShuttleListItem/ShuttleTargetListItem.js +42 -47
  98. package/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +7 -0
  99. package/esm/components/ShuttleListPanel.js +15 -19
  100. package/esm/components/ShuttleListPanel.js.map +7 -0
  101. package/esm/components/ShuttleSearchBox.js +32 -66
  102. package/esm/components/ShuttleSearchBox.js.map +7 -0
  103. package/esm/components/ShuttleSource.js +125 -129
  104. package/esm/components/ShuttleSource.js.map +7 -0
  105. package/esm/components/ShuttleTarget.js +68 -89
  106. package/esm/components/ShuttleTarget.js.map +7 -0
  107. package/esm/components/VirtualizedItem.js +15 -33
  108. package/esm/components/VirtualizedItem.js.map +7 -0
  109. package/esm/components/VirtualizedList.js +50 -75
  110. package/esm/components/VirtualizedList.js.map +7 -0
  111. package/esm/components/VirtualizedSortableList.js +17 -32
  112. package/esm/components/VirtualizedSortableList.js.map +7 -0
  113. package/esm/helper.js +43 -67
  114. package/esm/helper.js.map +7 -0
  115. package/esm/index.js +9 -2
  116. package/esm/index.js.map +7 -0
  117. package/esm/tests/utils.js +1189 -0
  118. package/esm/tests/utils.js.map +7 -0
  119. package/esm/updateShuttleStateFromProps.js +39 -58
  120. package/esm/updateShuttleStateFromProps.js.map +7 -0
  121. package/esm/utils.js +12 -18
  122. package/esm/utils.js.map +7 -0
  123. package/esm/withProviders.js +14 -20
  124. package/esm/withProviders.js.map +7 -0
  125. package/package.json +11 -11
  126. package/types/AnimationState.d.ts +3 -2
  127. package/types/DSShuttle.d.ts +2 -39
  128. package/types/SearchState.d.ts +3 -2
  129. package/types/ShuttleImpl.d.ts +3 -2
  130. package/types/ShuttleRenderer.d.ts +1 -0
  131. package/types/ShuttleState.d.ts +3 -2
  132. package/types/components/LoadingIndicator.d.ts +1 -0
  133. package/types/components/OverflowList.d.ts +1 -0
  134. package/types/components/ShuttleBreadcrumb.d.ts +1 -0
  135. package/types/components/ShuttleInfiniteScrollIndicator.d.ts +1 -0
  136. package/types/components/ShuttleListItem/ShuttleListItem.d.ts +1 -0
  137. package/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +1 -0
  138. package/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +1 -0
  139. package/types/components/ShuttleListPanel.d.ts +1 -0
  140. package/types/components/ShuttleSearchBox.d.ts +3 -1
  141. package/types/components/ShuttleSource.d.ts +1 -0
  142. package/types/components/ShuttleTarget.d.ts +1 -0
  143. package/types/components/VirtualizedItem.d.ts +1 -0
  144. package/types/components/VirtualizedList.d.ts +1 -0
  145. package/types/components/VirtualizedSortableList.d.ts +1 -0
  146. package/types/index.d.ts +1 -1
  147. package/types/updateShuttleStateFromProps.d.ts +3 -1
  148. package/types/withProviders.d.ts +1 -0
package/esm/DSShuttle.js CHANGED
@@ -1,213 +1,141 @@
1
- import _jsx from '@babel/runtime/helpers/esm/jsx';
2
- import 'core-js/modules/web.dom-collections.iterator.js';
3
- import 'react';
4
- import { debounce } from 'lodash';
5
- import { PropTypes, describe } from 'react-desc';
6
- import { TooltipTextProvider } from '@elliemae/ds-truncated-tooltip-text';
7
- import ShuttleImpl from './ShuttleImpl.js';
8
- export { default as utils } from './utils.js';
9
-
10
- const noop = () => {};
11
-
12
- const DSShuttle = _ref => {
13
- let {
14
- containerProps = {},
15
- idField = 'id',
16
- parentIdField = 'parent',
17
- showIcons = true,
18
- items = [],
19
- selectedItems = undefined,
20
- // if defined it becomes controlled (v1)
21
- // TODO make `nonSelectedItems` the default controlled behavior (v2)
22
- nonSelectedItems = undefined,
23
- onSearch = noop,
24
- onSearchOpen = noop,
25
- onSearchClose = noop,
26
- onDrillDown = noop,
27
- onDrillDownTarget = noop,
28
- onTargetSortEnd = noop,
29
- setGetStatus = noop,
30
- targetSortable = true,
31
- sourceEmptyMessage = 'No Items Found',
32
- sourceRootTitle = 'Category',
33
- targetEmptyMessage = 'No Items Selected',
34
- targetRootTitle = 'Selected Items',
35
- composeSourceItemProps = () => ({}),
36
- composeTargetItemProps = () => ({}),
37
- onAddToTarget = noop,
38
- onAddCheckedItems = noop,
39
- onRemoveFromTarget = noop,
40
- onRemoveAllFromTarget = noop,
41
- onChange = noop,
42
- renderSourceCounter = noop,
43
- renderTargetCounter = noop,
44
- sourceClearItemsText = 'CLEAR ALL',
45
- targetClearItemsText = 'CLEAR ALL',
46
- searchPlaceholder = 'Search field ID, name, etc.',
47
- loadingSource = false,
48
- loadingTarget = false,
49
- onGetMoreItems = () => null,
50
- hasNextPage = false,
51
- moreItemsLoading
52
- } = _ref;
53
- return /*#__PURE__*/_jsx(TooltipTextProvider, {}, void 0, /*#__PURE__*/_jsx(ShuttleImpl, {
54
- composeSourceItemProps: composeSourceItemProps,
55
- composeTargetItemProps: composeTargetItemProps,
56
- containerProps: containerProps,
57
- idField: idField,
58
- items: items,
59
- onAddCheckedItems: onAddCheckedItems,
60
- onAddToTarget: onAddToTarget,
61
- onChange: onChange,
62
- onDrillDown: onDrillDown,
63
- nonSelectedItems: nonSelectedItems,
64
- onDrillDownTarget: onDrillDownTarget,
65
- onRemoveAllFromTarget: onRemoveAllFromTarget,
66
- onRemoveFromTarget: onRemoveFromTarget,
67
- onSearch: onSearch,
68
- onSearchClose: onSearchClose,
69
- onSearchOpen: onSearchOpen,
70
- onTargetSortEnd: onTargetSortEnd,
71
- parentIdField: parentIdField,
72
- renderSourceCounter: renderSourceCounter,
73
- renderTargetCounter: renderTargetCounter,
74
- searchPlaceholder: searchPlaceholder,
75
- selectedItems: selectedItems,
76
- setGetStatus: setGetStatus,
77
- showIcons: showIcons,
78
- sourceClearItemsText: sourceClearItemsText,
79
- sourceEmptyMessage: sourceEmptyMessage,
80
- sourceRootTitle: sourceRootTitle,
81
- targetClearItemsText: targetClearItemsText,
82
- targetEmptyMessage: targetEmptyMessage,
83
- targetRootTitle: targetRootTitle,
84
- targetSortable: targetSortable,
85
- loadingSource: loadingSource,
86
- loadingTarget: loadingTarget,
87
- onGetMoreItems: debounce(function () {
88
- onGetMoreItems(...arguments);
89
- }, 500),
90
- moreItemsLoading: moreItemsLoading,
91
- hasNextPage: hasNextPage
92
- }));
1
+ import * as React from "react";
2
+ import React2 from "react";
3
+ import { debounce } from "lodash";
4
+ import { describe, PropTypes } from "react-desc";
5
+ import { TooltipTextProvider } from "@elliemae/ds-truncated-tooltip-text";
6
+ import { ShuttleImpl } from "./ShuttleImpl";
7
+ import utils from "./utils";
8
+ const noop = () => {
93
9
  };
94
-
10
+ const DSShuttle = ({
11
+ containerProps = {},
12
+ idField = "id",
13
+ parentIdField = "parent",
14
+ showIcons = true,
15
+ items = [],
16
+ selectedItems = void 0,
17
+ nonSelectedItems = void 0,
18
+ onSearch = noop,
19
+ onSearchOpen = noop,
20
+ onSearchClose = noop,
21
+ onDrillDown = noop,
22
+ onDrillDownTarget = noop,
23
+ onTargetSortEnd = noop,
24
+ setGetStatus = noop,
25
+ targetSortable = true,
26
+ sourceEmptyMessage = "No Items Found",
27
+ sourceRootTitle = "Category",
28
+ targetEmptyMessage = "No Items Selected",
29
+ targetRootTitle = "Selected Items",
30
+ composeSourceItemProps = () => ({}),
31
+ composeTargetItemProps = () => ({}),
32
+ onAddToTarget = noop,
33
+ onAddCheckedItems = noop,
34
+ onRemoveFromTarget = noop,
35
+ onRemoveAllFromTarget = noop,
36
+ onChange = noop,
37
+ renderSourceCounter = noop,
38
+ renderTargetCounter = noop,
39
+ sourceClearItemsText = "CLEAR ALL",
40
+ targetClearItemsText = "CLEAR ALL",
41
+ searchPlaceholder = "Search field ID, name, etc.",
42
+ loadingSource = false,
43
+ loadingTarget = false,
44
+ onGetMoreItems = () => null,
45
+ hasNextPage = false,
46
+ moreItemsLoading
47
+ }) => /* @__PURE__ */ React2.createElement(TooltipTextProvider, null, /* @__PURE__ */ React2.createElement(ShuttleImpl, {
48
+ composeSourceItemProps,
49
+ composeTargetItemProps,
50
+ containerProps,
51
+ idField,
52
+ items,
53
+ onAddCheckedItems,
54
+ onAddToTarget,
55
+ onChange,
56
+ onDrillDown,
57
+ nonSelectedItems,
58
+ onDrillDownTarget,
59
+ onRemoveAllFromTarget,
60
+ onRemoveFromTarget,
61
+ onSearch,
62
+ onSearchClose,
63
+ onSearchOpen,
64
+ onTargetSortEnd,
65
+ parentIdField,
66
+ renderSourceCounter,
67
+ renderTargetCounter,
68
+ searchPlaceholder,
69
+ selectedItems,
70
+ setGetStatus,
71
+ showIcons,
72
+ sourceClearItemsText,
73
+ sourceEmptyMessage,
74
+ sourceRootTitle,
75
+ targetClearItemsText,
76
+ targetEmptyMessage,
77
+ targetRootTitle,
78
+ targetSortable,
79
+ loadingSource,
80
+ loadingTarget,
81
+ onGetMoreItems: debounce((...args) => {
82
+ onGetMoreItems(...args);
83
+ }, 500),
84
+ moreItemsLoading,
85
+ hasNextPage
86
+ }));
95
87
  const props = {
96
- /** inject props to shuttle wrapper */
97
- containerProps: PropTypes.object.description('inject props to shuttle wrapper'),
98
-
99
- /** The identifier field for the item object */
100
- idField: PropTypes.string.description('The identifier field for the item object'),
101
-
102
- /** The parent identifier field for the item object */
103
- parentIdField: PropTypes.string.description('The parent identifier field for the item object'),
104
-
105
- /** Whether to show the icons or not */
106
- showIcons: PropTypes.string.description('Whether to show the icons or not'),
107
-
108
- /** List of items */
88
+ containerProps: PropTypes.object.description("inject props to shuttle wrapper"),
89
+ idField: PropTypes.string.description("The identifier field for the item object"),
90
+ parentIdField: PropTypes.string.description("The parent identifier field for the item object"),
91
+ showIcons: PropTypes.string.description("Whether to show the icons or not"),
109
92
  items: PropTypes.arrayOf(PropTypes.shape({
110
93
  disableDrillDown: PropTypes.bool,
111
94
  icon: PropTypes.element,
112
95
  name: PropTypes.string,
113
96
  readOnly: PropTypes.bool,
114
97
  description: PropTypes.string
115
- })).description('list of items'),
116
-
117
- /** Array of item ids that are selected. If passed the component behaves as controlled */
118
- selectedItems: PropTypes.arrayOf(PropTypes.string).description('Array of item ids that are selected. If passed the component behaves as controlled'),
119
-
120
- /** Array of item ids that aren't selected. Should include ALL non selected items, even those not rendered */
98
+ })).description("list of items"),
99
+ selectedItems: PropTypes.arrayOf(PropTypes.string).description("Array of item ids that are selected. If passed the component behaves as controlled"),
121
100
  nonSelectedItems: PropTypes.arrayOf(PropTypes.string).description("Array of item ids that aren't selected.. Should include ALL non selected items, even those not rendered"),
122
-
123
- /** Handler on search */
124
- onSearch: PropTypes.func.description('Handler on search'),
125
-
126
- /** Handler when the searchbox is visible */
127
- onSearchOpen: PropTypes.func.description('Handler when the searchbox is visible'),
128
-
129
- /** Handler when the searchbox is not visible */
130
- onSearchClose: PropTypes.func.description('Handler when the searchbox is not visible'),
131
-
132
- /** Source handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction ("up" | "down") */
101
+ onSearch: PropTypes.func.description("Handler on search"),
102
+ onSearchOpen: PropTypes.func.description("Handler when the searchbox is visible"),
103
+ onSearchClose: PropTypes.func.description("Handler when the searchbox is not visible"),
133
104
  onDrillDown: PropTypes.func.description('Source handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction ("up" | "down")'),
134
-
135
- /** Target handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction ("up" | "down") */
136
105
  onDrillDownTarget: PropTypes.func.description('Target handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction ("up" | "down")'),
137
-
138
- /** Target handler when user stops dragging an item */
139
- onTargetSortEnd: PropTypes.func.description('Target handler when user stops dragging an item'),
140
-
141
- /** Callback function that gets more items for Infinite Scroll */
142
- onGetMoreItems: PropTypes.func.description('Callback function that gets more items for Infinite Scroll'),
143
-
144
- /** Wheter there are mor items loading for Infinite Scroll */
145
- moreItemsLoading: PropTypes.bool.description('Wheter there are mor items loading for Infinite Scroll'),
146
-
147
- /** Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems */
148
- hasNextPage: PropTypes.bool.description('Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems'),
149
-
150
- /** Function that takes as a parameter an internal getter for the state */
151
- setGetStatus: PropTypes.func.description('Function that takes as a parameter an internal getter for the state'),
152
-
153
- /** Whether the target can be sortable with DnD */
154
- targetSortable: PropTypes.bool.description('Whether the target can be sortable with DnD'),
155
-
156
- /** Handler when the searchbox is visible */
157
- sourceRootTitle: PropTypes.string.description('Handler when the searchbox is visible'),
158
-
159
- /** Source text when there is no items */
160
- sourceEmptyMessage: PropTypes.string.description('Source text when there is no items'),
161
-
162
- /** Target text when there is no items */
163
- targetEmptyMessage: PropTypes.string.description('Target text when there is no items'),
164
-
165
- /** Target text for the first hierarchy item */
166
- targetRootTitle: PropTypes.string.description('Target text for the first hierarchy item'),
167
-
168
- /** Function that allow to compose the item props in the source */
169
- composeSourceItemProps: PropTypes.func.description('Function that allow to compose the item props in the source'),
170
-
171
- /** Function that allow to compose the item props in the target */
172
- composeTargetItemProps: PropTypes.func.description('Function that allow to compose the item props in the target'),
173
-
174
- /** Handler when a users moves an item to the target */
175
- onAddToTarget: PropTypes.func.description('Handler when a users moves an item to the target'),
176
-
177
- /** Handler when a users moves all the 'checked' items to the target */
106
+ onTargetSortEnd: PropTypes.func.description("Target handler when user stops dragging an item"),
107
+ onGetMoreItems: PropTypes.func.description("Callback function that gets more items for Infinite Scroll"),
108
+ moreItemsLoading: PropTypes.bool.description("Wheter there are mor items loading for Infinite Scroll"),
109
+ hasNextPage: PropTypes.bool.description("Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems"),
110
+ setGetStatus: PropTypes.func.description("Function that takes as a parameter an internal getter for the state"),
111
+ targetSortable: PropTypes.bool.description("Whether the target can be sortable with DnD"),
112
+ sourceRootTitle: PropTypes.string.description("Handler when the searchbox is visible"),
113
+ sourceEmptyMessage: PropTypes.string.description("Source text when there is no items"),
114
+ targetEmptyMessage: PropTypes.string.description("Target text when there is no items"),
115
+ targetRootTitle: PropTypes.string.description("Target text for the first hierarchy item"),
116
+ composeSourceItemProps: PropTypes.func.description("Function that allow to compose the item props in the source"),
117
+ composeTargetItemProps: PropTypes.func.description("Function that allow to compose the item props in the target"),
118
+ onAddToTarget: PropTypes.func.description("Handler when a users moves an item to the target"),
178
119
  onAddCheckedItems: PropTypes.func.description("Handler when a users moves all the 'checked' items to the target"),
179
-
180
- /** Handler when a user removes an item from the target */
181
- onRemoveFromTarget: PropTypes.func.description('Handler when a user removes an item from the target'),
182
-
183
- /** Handler when a user removes all the items from the target */
184
- onRemoveAllFromTarget: PropTypes.func.description('Handler when a user removes all the items from the target'),
185
-
186
- /** Handler for every change on the state */
187
- onChange: PropTypes.func.description('Handler for every change on the state'),
188
-
189
- /** Function that returns an element for the source counter */
190
- renderSourceCounter: PropTypes.func.description('Function that returns an element for the source counter'),
191
-
192
- /** Function that returns an element for the target counter */
193
- renderTargetCounter: PropTypes.func.description('Function that returns an element for the target counter'),
194
-
195
- /** Source text for the clear items button */
196
- sourceClearItemsText: PropTypes.string.description('Source text for the clear items button'),
197
-
198
- /** Target text for the clear items button */
199
- targetClearItemsText: PropTypes.string.description('Target text for the clear items button'),
200
-
201
- /** Searchbox placeholder */
202
- searchPlaceholder: PropTypes.string.description('Searchbox placeholder'),
203
-
204
- /** Displays loading indicator on source section */
205
- loadingSource: PropTypes.bool.description('Displays loading indicator on source section'),
206
-
207
- /** Displays loading indicator on target section */
208
- loadingTarget: PropTypes.bool.description('Displays loading indicator on target section')
120
+ onRemoveFromTarget: PropTypes.func.description("Handler when a user removes an item from the target"),
121
+ onRemoveAllFromTarget: PropTypes.func.description("Handler when a user removes all the items from the target"),
122
+ onChange: PropTypes.func.description("Handler for every change on the state"),
123
+ renderSourceCounter: PropTypes.func.description("Function that returns an element for the source counter"),
124
+ renderTargetCounter: PropTypes.func.description("Function that returns an element for the target counter"),
125
+ sourceClearItemsText: PropTypes.string.description("Source text for the clear items button"),
126
+ targetClearItemsText: PropTypes.string.description("Target text for the clear items button"),
127
+ searchPlaceholder: PropTypes.string.description("Searchbox placeholder"),
128
+ loadingSource: PropTypes.bool.description("Displays loading indicator on source section"),
129
+ loadingTarget: PropTypes.bool.description("Displays loading indicator on target section")
209
130
  };
131
+ DSShuttle.propTypes = props;
210
132
  const DSShuttleWithSchema = describe(DSShuttle);
211
133
  DSShuttleWithSchema.propTypes = props;
212
-
213
- export { DSShuttleWithSchema, DSShuttle as default };
134
+ var DSShuttle_default = DSShuttle;
135
+ export {
136
+ DSShuttle,
137
+ DSShuttleWithSchema,
138
+ DSShuttle_default as default,
139
+ utils
140
+ };
141
+ //# sourceMappingURL=DSShuttle.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/DSShuttle.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-lines */\nimport React from 'react';\nimport { debounce } from 'lodash';\nimport { describe, PropTypes } from 'react-desc';\nimport { TooltipTextProvider } from '@elliemae/ds-truncated-tooltip-text';\nimport { ShuttleImpl } from './ShuttleImpl';\nimport utils from './utils';\n\nconst noop = () => {};\n\nconst DSShuttle = ({\n containerProps = {},\n idField = 'id',\n parentIdField = 'parent',\n showIcons = true,\n items = [],\n selectedItems = undefined, // if defined it becomes controlled (v1)\n // TODO make `nonSelectedItems` the default controlled behavior (v2)\n nonSelectedItems = undefined,\n onSearch = noop,\n onSearchOpen = noop,\n onSearchClose = noop,\n onDrillDown = noop,\n onDrillDownTarget = noop,\n onTargetSortEnd = noop,\n setGetStatus = noop,\n targetSortable = true,\n sourceEmptyMessage = 'No Items Found',\n sourceRootTitle = 'Category',\n targetEmptyMessage = 'No Items Selected',\n targetRootTitle = 'Selected Items',\n composeSourceItemProps = () => ({}),\n composeTargetItemProps = () => ({}),\n onAddToTarget = noop,\n onAddCheckedItems = noop,\n onRemoveFromTarget = noop,\n onRemoveAllFromTarget = noop,\n onChange = noop,\n renderSourceCounter = noop,\n renderTargetCounter = noop,\n sourceClearItemsText = 'CLEAR ALL',\n targetClearItemsText = 'CLEAR ALL',\n searchPlaceholder = 'Search field ID, name, etc.',\n loadingSource = false,\n loadingTarget = false,\n onGetMoreItems = () => null,\n hasNextPage = false,\n moreItemsLoading,\n}) => (\n <TooltipTextProvider>\n <ShuttleImpl\n composeSourceItemProps={composeSourceItemProps}\n composeTargetItemProps={composeTargetItemProps}\n containerProps={containerProps}\n idField={idField}\n items={items}\n onAddCheckedItems={onAddCheckedItems}\n onAddToTarget={onAddToTarget}\n onChange={onChange}\n onDrillDown={onDrillDown}\n nonSelectedItems={nonSelectedItems}\n onDrillDownTarget={onDrillDownTarget}\n onRemoveAllFromTarget={onRemoveAllFromTarget}\n onRemoveFromTarget={onRemoveFromTarget}\n onSearch={onSearch}\n onSearchClose={onSearchClose}\n onSearchOpen={onSearchOpen}\n onTargetSortEnd={onTargetSortEnd}\n parentIdField={parentIdField}\n renderSourceCounter={renderSourceCounter}\n renderTargetCounter={renderTargetCounter}\n searchPlaceholder={searchPlaceholder}\n selectedItems={selectedItems}\n setGetStatus={setGetStatus}\n showIcons={showIcons}\n sourceClearItemsText={sourceClearItemsText}\n sourceEmptyMessage={sourceEmptyMessage}\n sourceRootTitle={sourceRootTitle}\n targetClearItemsText={targetClearItemsText}\n targetEmptyMessage={targetEmptyMessage}\n targetRootTitle={targetRootTitle}\n targetSortable={targetSortable}\n loadingSource={loadingSource}\n loadingTarget={loadingTarget}\n onGetMoreItems={debounce((...args) => {\n onGetMoreItems(...args);\n }, 500)}\n moreItemsLoading={moreItemsLoading}\n hasNextPage={hasNextPage}\n />\n </TooltipTextProvider>\n);\n\nconst props = {\n /** inject props to shuttle wrapper */\n containerProps: PropTypes.object.description('inject props to shuttle wrapper'),\n /** The identifier field for the item object */\n idField: PropTypes.string.description('The identifier field for the item object'),\n /** The parent identifier field for the item object */\n parentIdField: PropTypes.string.description('The parent identifier field for the item object'),\n /** Whether to show the icons or not */\n showIcons: PropTypes.string.description('Whether to show the icons or not'),\n /** List of items */\n items: PropTypes.arrayOf(\n PropTypes.shape({\n disableDrillDown: PropTypes.bool,\n icon: PropTypes.element,\n name: PropTypes.string,\n readOnly: PropTypes.bool,\n description: PropTypes.string,\n }),\n ).description('list of items'),\n /** Array of item ids that are selected. If passed the component behaves as controlled */\n selectedItems: PropTypes.arrayOf(PropTypes.string).description(\n 'Array of item ids that are selected. If passed the component behaves as controlled',\n ),\n /** Array of item ids that aren't selected. Should include ALL non selected items, even those not rendered */\n nonSelectedItems: PropTypes.arrayOf(PropTypes.string).description(\n \"Array of item ids that aren't selected.. Should include ALL non selected items, even those not rendered\",\n ),\n /** Handler on search */\n onSearch: PropTypes.func.description('Handler on search'),\n /** Handler when the searchbox is visible */\n onSearchOpen: PropTypes.func.description('Handler when the searchbox is visible'),\n /** Handler when the searchbox is not visible */\n onSearchClose: PropTypes.func.description('Handler when the searchbox is not visible'),\n /** Source handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\") */\n onDrillDown: PropTypes.func.description(\n 'Source handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\")',\n ),\n /** Target handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\") */\n onDrillDownTarget: PropTypes.func.description(\n 'Target handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\")',\n ),\n /** Target handler when user stops dragging an item */\n onTargetSortEnd: PropTypes.func.description('Target handler when user stops dragging an item'),\n /** Callback function that gets more items for Infinite Scroll */\n onGetMoreItems: PropTypes.func.description('Callback function that gets more items for Infinite Scroll'),\n /** Wheter there are mor items loading for Infinite Scroll */\n moreItemsLoading: PropTypes.bool.description('Wheter there are mor items loading for Infinite Scroll'),\n /** Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems */\n hasNextPage: PropTypes.bool.description(\n 'Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems',\n ),\n /** Function that takes as a parameter an internal getter for the state */\n setGetStatus: PropTypes.func.description('Function that takes as a parameter an internal getter for the state'),\n /** Whether the target can be sortable with DnD */\n targetSortable: PropTypes.bool.description('Whether the target can be sortable with DnD'),\n /** Handler when the searchbox is visible */\n sourceRootTitle: PropTypes.string.description('Handler when the searchbox is visible'),\n /** Source text when there is no items */\n sourceEmptyMessage: PropTypes.string.description('Source text when there is no items'),\n /** Target text when there is no items */\n targetEmptyMessage: PropTypes.string.description('Target text when there is no items'),\n /** Target text for the first hierarchy item */\n targetRootTitle: PropTypes.string.description('Target text for the first hierarchy item'),\n /** Function that allow to compose the item props in the source */\n composeSourceItemProps: PropTypes.func.description('Function that allow to compose the item props in the source'),\n /** Function that allow to compose the item props in the target */\n composeTargetItemProps: PropTypes.func.description('Function that allow to compose the item props in the target'),\n /** Handler when a users moves an item to the target */\n onAddToTarget: PropTypes.func.description('Handler when a users moves an item to the target'),\n /** Handler when a users moves all the 'checked' items to the target */\n onAddCheckedItems: PropTypes.func.description(\"Handler when a users moves all the 'checked' items to the target\"),\n /** Handler when a user removes an item from the target */\n onRemoveFromTarget: PropTypes.func.description('Handler when a user removes an item from the target'),\n /** Handler when a user removes all the items from the target */\n onRemoveAllFromTarget: PropTypes.func.description('Handler when a user removes all the items from the target'),\n /** Handler for every change on the state */\n onChange: PropTypes.func.description('Handler for every change on the state'),\n /** Function that returns an element for the source counter */\n renderSourceCounter: PropTypes.func.description('Function that returns an element for the source counter'),\n /** Function that returns an element for the target counter */\n renderTargetCounter: PropTypes.func.description('Function that returns an element for the target counter'),\n /** Source text for the clear items button */\n sourceClearItemsText: PropTypes.string.description('Source text for the clear items button'),\n /** Target text for the clear items button */\n targetClearItemsText: PropTypes.string.description('Target text for the clear items button'),\n /** Searchbox placeholder */\n searchPlaceholder: PropTypes.string.description('Searchbox placeholder'),\n /** Displays loading indicator on source section */\n loadingSource: PropTypes.bool.description('Displays loading indicator on source section'),\n /** Displays loading indicator on target section */\n loadingTarget: PropTypes.bool.description('Displays loading indicator on target section'),\n};\n\nDSShuttle.propTypes = props;\nconst DSShuttleWithSchema = describe(DSShuttle);\nDSShuttleWithSchema.propTypes = props;\n\nexport { utils, DSShuttleWithSchema, DSShuttle };\n\nexport default DSShuttle;\n"],
5
+ "mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,OAAO,MAAM;AAAA;AAEnB,MAAM,YAAY,CAAC;AAAA,EACjB,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAEhB,mBAAmB;AAAA,EACnB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,iBAAi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AK,YAAY;AAAA,EAE1C,eAAe,UAAU,KAAK,YAAY;AAAA;AAG5C,UAAU,YAAY;AACtB,MAAM,sBAAsB,SAAS;AACrC,oBAAoB,YAAY;AAIhC,IAAO,oBAAQ;",
6
+ "names": []
7
+ }
@@ -1,35 +1,31 @@
1
- import 'core-js/modules/web.dom-collections.iterator.js';
2
- import { useState } from 'react';
3
- import createContainer from 'constate';
4
-
1
+ import * as React from "react";
2
+ import { useState } from "react";
3
+ import createContainer from "constate";
5
4
  function useSearchState() {
6
- const [searchTerm, setSearchTerm] = useState('');
7
- const [searching, setSearchBoxVisibility] = useState(false); // todo: create a hook for Visibility behavior
8
-
5
+ const [searchTerm, setSearchTerm] = useState("");
6
+ const [searching, setSearchBoxVisibility] = useState(false);
9
7
  function toggleSearchBox(userVisible) {
10
- if (userVisible !== undefined) {
8
+ if (userVisible !== void 0) {
11
9
  setSearchBoxVisibility(userVisible);
12
10
  } else {
13
11
  setSearchBoxVisibility(!searching);
14
12
  }
15
13
  }
16
-
17
14
  function reset() {
18
- setSearchTerm('');
15
+ setSearchTerm("");
19
16
  setSearchBoxVisibility(false);
20
17
  }
21
-
22
18
  return {
23
- state: {
24
- searchTerm,
25
- searching
26
- },
19
+ state: { searchTerm, searching },
27
20
  setSearchTerm,
28
21
  toggleSearchBox,
29
22
  reset
30
23
  };
31
24
  }
32
-
33
- var SearchState = createContainer(useSearchState, value => [value.state]);
34
-
35
- export { SearchState as default };
25
+ const SearchState = createContainer(useSearchState, (value) => [value.state]);
26
+ var SearchState_default = SearchState;
27
+ export {
28
+ SearchState,
29
+ SearchState_default as default
30
+ };
31
+ //# sourceMappingURL=SearchState.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/SearchState.tsx"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useState } from 'react';\nimport createContainer from 'constate';\n\nfunction useSearchState() {\n const [searchTerm, setSearchTerm] = useState('');\n const [searching, setSearchBoxVisibility] = useState(false); // todo: create a hook for Visibility behavior\n\n function toggleSearchBox(userVisible) {\n if (userVisible !== undefined) {\n setSearchBoxVisibility(userVisible);\n } else {\n setSearchBoxVisibility(!searching);\n }\n }\n\n function reset() {\n setSearchTerm('');\n setSearchBoxVisibility(false);\n }\n\n return {\n state: { searchTerm, searching },\n setSearchTerm,\n toggleSearchBox,\n reset,\n };\n}\n\nconst SearchState = createContainer(useSearchState, value => [value.state]);\nexport { SearchState };\nexport default SearchState;\n"],
5
+ "mappings": "AAAA;ACAA;AACA;AAEA,0BAA0B;AACxB,QAAM,CAAC,YAAY,iBAAiB,SAAS;AAC7C,QAAM,CAAC,WAAW,0BAA0B,SAAS;AAErD,2BAAyB,aAAa;AACpC,QAAI,gBAAgB,QAAW;AAC7B,6BAAuB;AAAA,WAClB;AACL,6BAAuB,CAAC;AAAA;AAAA;AAI5B,mBAAiB;AACf,kBAAc;AACd,2BAAuB;AAAA;AAGzB,SAAO;AAAA,IACL,OAAO,EAAE,YAAY;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA;AAAA;AAIJ,MAAM,cAAc,gBAAgB,gBAAgB,WAAS,CAAC,MAAM;AAEpE,IAAO,sBAAQ;",
6
+ "names": []
7
+ }
@@ -1,123 +1,106 @@
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/web.dom-collections.iterator.js';
5
- import 'core-js/modules/esnext.async-iterator.filter.js';
6
- import 'core-js/modules/esnext.iterator.constructor.js';
7
- import 'core-js/modules/esnext.iterator.filter.js';
8
- import { addOrRemove, cloneDeep, compose, hashArray } from '@elliemae/ds-utilities';
9
- import { toggleInObject, filterMovedItems, getHierarchyTypeName } from './helper.js';
10
- import utils from './utils.js';
11
-
12
- 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; }
13
-
14
- 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
+ addOrRemove,
4
+ cloneDeep,
5
+ hashArray,
6
+ compose
7
+ } from "@elliemae/ds-utilities";
8
+ import {
9
+ getHierarchyTypeName,
10
+ toggleInObject,
11
+ filterMovedItems
12
+ } from "./helper";
13
+ import utils from "./utils";
15
14
  function toggleItemSelection(itemId) {
16
- return state => _objectSpread(_objectSpread({}, state), {}, {
15
+ return (state) => ({
16
+ ...state,
17
17
  checkedItems: addOrRemove(state.checkedItems, itemId)
18
18
  });
19
19
  }
20
20
  function navigateTo(item, dest) {
21
21
  const hierarchyType = getHierarchyTypeName(dest);
22
- return state => {
23
- const indexInHierarchy = state[hierarchyType].findIndex(hItem => hItem.id === item.id);
22
+ return (state) => {
23
+ const indexInHierarchy = state[hierarchyType].findIndex((hItem) => hItem.id === item.id);
24
24
  const hierarchy = state[hierarchyType];
25
- return _objectSpread(_objectSpread({}, state), {}, {
25
+ return {
26
+ ...state,
26
27
  [hierarchyType]: indexInHierarchy !== -1 ? hierarchy.slice(0, indexInHierarchy + 1) : [...hierarchy, item]
27
- });
28
+ };
28
29
  };
29
30
  }
30
31
  function moveItem(item) {
31
- return state => {
32
+ return (state) => {
32
33
  const movedItems = toggleInObject(state.movedItems, item.id, item);
33
- return _objectSpread(_objectSpread({}, state), {}, {
34
+ return {
35
+ ...state,
34
36
  movedItems
35
- });
37
+ };
36
38
  };
37
39
  }
38
40
  const defaultOptions = {
39
- parentField: 'parent',
40
- idField: 'id',
41
- op: hasMoved => !hasMoved
42
- }; // todo: optimize this
43
-
44
- function getItemDeep(_ref) {
45
- let {
46
- collection,
47
- id,
48
- options
49
- } = _ref;
50
-
51
- const {
52
- idField
53
- } = _objectSpread(_objectSpread({}, defaultOptions), options);
54
-
55
- const itemIndex = collection.findIndex(fItem => fItem[idField] === id); // get item with nested children
56
-
41
+ parentField: "parent",
42
+ idField: "id",
43
+ op: (hasMoved) => !hasMoved
44
+ };
45
+ function getItemDeep({ collection, id, options }) {
46
+ const { idField } = { ...defaultOptions, ...options };
47
+ const itemIndex = collection.findIndex((fItem) => fItem[idField] === id);
57
48
  const item = collection[itemIndex];
58
- const children = item !== null && item !== void 0 && item.hasChildren ? compose(utils.getChildren({
59
- index: itemIndex
60
- }))(collection) || [] : [];
61
- return {
62
- item,
63
- children
64
- };
49
+ const children = item?.hasChildren ? compose(utils.getChildren({ index: itemIndex }))(collection) || [] : [];
50
+ return { item, children };
65
51
  }
66
-
67
52
  function addToTarget(itemToAdd, collection) {
68
- return (state, _ref2) => {
69
- let {
70
- idField
71
- } = _ref2;
53
+ return (state, { idField }) => {
72
54
  const items = collection || state.preparedItems;
73
- const {
74
- item,
75
- children
76
- } = getItemDeep({
55
+ const { item, children } = getItemDeep({
77
56
  collection: items,
78
57
  id: itemToAdd[idField]
79
58
  });
80
- return _objectSpread(_objectSpread({}, state), {}, {
59
+ return {
60
+ ...state,
81
61
  movedItems: [...state.movedItems, item],
82
62
  targetItems: [...state.targetItems, item, ...children]
83
- });
63
+ };
84
64
  };
85
- } // todo: optimize this
86
-
65
+ }
87
66
  function removeFromTarget(itemToRemove) {
88
- return (state, _ref3) => {
89
- let {
90
- idField
91
- } = _ref3;
67
+ return (state, { idField }) => {
92
68
  let targetItems = cloneDeep(state.targetItems);
93
- const itemIndex = targetItems.findIndex(fItem => fItem.id === itemToRemove.id);
69
+ const itemIndex = targetItems.findIndex((fItem) => fItem.id === itemToRemove.id);
94
70
  const item = targetItems[itemIndex];
95
- const children = item !== null && item !== void 0 && item.hasChildren ? compose(filterMovedItems(state.movedItems), utils.getChildren({
96
- index: itemIndex
97
- }))(targetItems) || [] : [];
71
+ const children = item?.hasChildren ? compose(filterMovedItems(state.movedItems), utils.getChildren({ index: itemIndex }))(targetItems) || [] : [];
98
72
  targetItems.splice(itemIndex, 1);
99
-
100
- if (item !== null && item !== void 0 && item.hasChildren && children.length) {
101
- const childrenHash = hashArray(children, 'id');
102
- targetItems = targetItems.filter(i => !childrenHash[i.id]);
73
+ if (item?.hasChildren && children.length) {
74
+ const childrenHash = hashArray(children, "id");
75
+ targetItems = targetItems.filter((i) => !childrenHash[i.id]);
103
76
  }
104
-
105
- return _objectSpread(_objectSpread({}, state), {}, {
106
- movedItems: state.movedItems.filter(mItem => mItem[idField] !== itemToRemove[idField]),
77
+ return {
78
+ ...state,
79
+ movedItems: state.movedItems.filter((mItem) => mItem[idField] !== itemToRemove[idField]),
107
80
  targetItems
108
- });
81
+ };
109
82
  };
110
83
  }
111
84
  function resetCheckedItems() {
112
- return state => _objectSpread(_objectSpread({}, state), {}, {
85
+ return (state) => ({
86
+ ...state,
113
87
  checkedItems: []
114
88
  });
115
89
  }
116
90
  function resetMovedItems() {
117
- return state => _objectSpread(_objectSpread({}, state), {}, {
91
+ return (state) => ({
92
+ ...state,
118
93
  movedItems: [],
119
94
  targetItems: []
120
95
  });
121
96
  }
122
-
123
- export { addToTarget, moveItem, navigateTo, removeFromTarget, resetCheckedItems, resetMovedItems, toggleItemSelection };
97
+ export {
98
+ addToTarget,
99
+ moveItem,
100
+ navigateTo,
101
+ removeFromTarget,
102
+ resetCheckedItems,
103
+ resetMovedItems,
104
+ toggleItemSelection
105
+ };
106
+ //# sourceMappingURL=Shuttle.actions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/Shuttle.actions.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import {\n addOrRemove,\n cloneDeep,\n hashArray,\n compose,\n} from '@elliemae/ds-utilities';\nimport {\n getHierarchyTypeName,\n toggleInObject,\n filterMovedItems,\n} from './helper';\n\nimport utils from './utils';\n\nexport function toggleItemSelection(itemId) {\n return state => ({\n ...state,\n checkedItems: addOrRemove(state.checkedItems, itemId),\n });\n}\nexport function navigateTo(item, dest) {\n const hierarchyType = getHierarchyTypeName(dest);\n return state => {\n const indexInHierarchy = state[hierarchyType].findIndex(\n hItem => hItem.id === item.id,\n );\n const hierarchy = state[hierarchyType];\n return {\n ...state,\n [hierarchyType]:\n indexInHierarchy !== -1\n ? hierarchy.slice(0, indexInHierarchy + 1)\n : [...hierarchy, item],\n };\n };\n}\nexport function moveItem(item) {\n return state => {\n const movedItems = toggleInObject(state.movedItems, item.id, item);\n return {\n ...state,\n movedItems,\n };\n };\n}\n\nconst defaultOptions = {\n parentField: 'parent',\n idField: 'id',\n op: hasMoved => !hasMoved,\n};\n\n// todo: optimize this\nfunction getItemDeep({ collection, id, options }) {\n const { idField } = { ...defaultOptions, ...options };\n const itemIndex = collection.findIndex(fItem => fItem[idField] === id);\n\n // get item with nested children\n const item = collection[itemIndex];\n const children = item?.hasChildren\n ? compose(utils.getChildren({ index: itemIndex }))(collection) || []\n : [];\n\n return { item, children };\n}\n\nexport function addToTarget(itemToAdd, collection) {\n return (state, { idField }) => {\n const items = collection || state.preparedItems;\n\n const { item, children } = getItemDeep({\n collection: items,\n id: itemToAdd[idField],\n });\n\n return {\n ...state,\n movedItems: [...state.movedItems, item],\n targetItems: [...state.targetItems, item, ...children],\n };\n };\n}\n\n// todo: optimize this\nexport function removeFromTarget(itemToRemove) {\n return (state, { idField }) => {\n let targetItems = cloneDeep(state.targetItems);\n\n const itemIndex = targetItems.findIndex(\n fItem => fItem.id === itemToRemove.id,\n );\n\n const item = targetItems[itemIndex];\n const children = item?.hasChildren\n ? compose(\n filterMovedItems(state.movedItems),\n utils.getChildren({ index: itemIndex }),\n )(targetItems) || []\n : [];\n\n targetItems.splice(itemIndex, 1);\n if (item?.hasChildren && children.length) {\n const childrenHash = hashArray(children, 'id');\n targetItems = targetItems.filter(i => !childrenHash[i.id]);\n }\n\n return {\n ...state,\n movedItems: state.movedItems.filter(\n mItem => mItem[idField] !== itemToRemove[idField],\n ),\n targetItems,\n };\n };\n}\n\nexport function resetCheckedItems() {\n return state => ({\n ...state,\n checkedItems: [],\n });\n}\nexport function resetMovedItems() {\n return state => ({\n ...state,\n movedItems: [],\n targetItems: [],\n });\n}\n"],
5
+ "mappings": "AAAA;ACAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA;AAAA;AAAA;AAAA;AAAA;AAMA;AAEO,6BAA6B,QAAQ;AAC1C,SAAO,WAAU;AAAA,OACZ;AAAA,IACH,cAAc,YAAY,MAAM,cAAc;AAAA;AAAA;AAG3C,oBAAoB,MAAM,MAAM;AACrC,QAAM,gBAAgB,qBAAqB;AAC3C,SAAO,WAAS;AACd,UAAM,mBAAmB,MAAM,eAAe,UAC5C,WAAS,MAAM,OAAO,KAAK;AAE7B,UAAM,YAAY,MAAM;AACxB,WAAO;AAAA,SACF;AAAA,OACF,gBACC,qBAAqB,KACjB,UAAU,MAAM,GAAG,mBAAmB,KACtC,CAAC,GAAG,WAAW;AAAA;AAAA;AAAA;AAIpB,kBAAkB,MAAM;AAC7B,SAAO,WAAS;AACd,UAAM,aAAa,eAAe,MAAM,YAAY,KAAK,IAAI;AAC7D,WAAO;AAAA,SACF;AAAA,MACH;AAAA;AAAA;AAAA;AAKN,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,SAAS;AAAA,EACT,IAAI,cAAY,CAAC;AAAA;AAInB,qBAAqB,EAAE,YAAY,IAAI,WAAW;AAChD,QAAM,EAAE,YAAY,KAAK,mBAAmB;AAC5C,QAAM,YAAY,WAAW,UAAU,WAAS,MAAM,aAAa;AAGnE,QAAM,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