@elliemae/ds-shuttle 2.2.0-alpha.4 → 3.0.0-next.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 +19 -46
  2. package/cjs/DSShuttle.js +219 -166
  3. package/cjs/SearchState.js +25 -44
  4. package/cjs/Shuttle.actions.js +98 -87
  5. package/cjs/ShuttleContainer.js +61 -56
  6. package/cjs/ShuttleImpl.js +206 -109
  7. package/cjs/ShuttleRenderer.js +135 -140
  8. package/cjs/ShuttleState.js +53 -57
  9. package/cjs/animation/animationConfig.js +56 -53
  10. package/cjs/classedComponents.js +69 -70
  11. package/cjs/components/LoadingIndicator.js +22 -49
  12. package/cjs/components/OverflowList.js +48 -50
  13. package/cjs/components/ShuttleBreadcrumb.js +40 -52
  14. package/cjs/components/ShuttleInfiniteScrollIndicator.js +37 -46
  15. package/cjs/components/ShuttleListItem/ActionButtons.js +51 -56
  16. package/cjs/components/ShuttleListItem/ShuttleListItem.js +80 -78
  17. package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +64 -78
  18. package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +56 -72
  19. package/cjs/components/ShuttleListPanel.js +26 -44
  20. package/cjs/components/ShuttleSearchBox.js +72 -61
  21. package/cjs/components/ShuttleSource.js +146 -150
  22. package/cjs/components/ShuttleTarget.js +100 -88
  23. package/cjs/components/VirtualizedItem.js +40 -45
  24. package/cjs/components/VirtualizedList.js +86 -81
  25. package/cjs/components/VirtualizedSortableList.js +40 -47
  26. package/cjs/helper.js +103 -69
  27. package/cjs/index.js +12 -38
  28. package/cjs/updateShuttleStateFromProps.js +69 -73
  29. package/cjs/utils.js +42 -40
  30. package/cjs/withProviders.js +27 -43
  31. package/esm/AnimationState.js +8 -12
  32. package/esm/DSShuttle.js +198 -126
  33. package/esm/SearchState.js +19 -15
  34. package/esm/Shuttle.actions.js +80 -63
  35. package/esm/ShuttleContainer.js +50 -34
  36. package/esm/ShuttleImpl.js +183 -78
  37. package/esm/ShuttleRenderer.js +128 -111
  38. package/esm/ShuttleState.js +53 -34
  39. package/esm/animation/animationConfig.js +52 -24
  40. package/esm/classedComponents.js +51 -43
  41. package/esm/components/LoadingIndicator.js +15 -20
  42. package/esm/components/OverflowList.js +41 -21
  43. package/esm/components/ShuttleBreadcrumb.js +33 -23
  44. package/esm/components/ShuttleInfiniteScrollIndicator.js +31 -18
  45. package/esm/components/ShuttleListItem/ActionButtons.js +39 -27
  46. package/esm/components/ShuttleListItem/ShuttleListItem.js +72 -50
  47. package/esm/components/ShuttleListItem/ShuttleSourceListItem.js +52 -45
  48. package/esm/components/ShuttleListItem/ShuttleTargetListItem.js +47 -42
  49. package/esm/components/ShuttleListPanel.js +19 -15
  50. package/esm/components/ShuttleSearchBox.js +66 -32
  51. package/esm/components/ShuttleSource.js +129 -125
  52. package/esm/components/ShuttleTarget.js +89 -68
  53. package/esm/components/VirtualizedItem.js +33 -15
  54. package/esm/components/VirtualizedList.js +75 -50
  55. package/esm/components/VirtualizedSortableList.js +32 -17
  56. package/esm/helper.js +67 -43
  57. package/esm/index.js +2 -9
  58. package/esm/updateShuttleStateFromProps.js +58 -39
  59. package/esm/utils.js +18 -12
  60. package/esm/withProviders.js +20 -14
  61. package/package.json +11 -11
  62. package/types/AnimationState.d.ts +2 -3
  63. package/types/DSShuttle.d.ts +1 -1
  64. package/types/SearchState.d.ts +2 -3
  65. package/types/ShuttleImpl.d.ts +2 -3
  66. package/types/ShuttleRenderer.d.ts +0 -1
  67. package/types/ShuttleState.d.ts +2 -3
  68. package/types/components/LoadingIndicator.d.ts +0 -1
  69. package/types/components/OverflowList.d.ts +0 -1
  70. package/types/components/ShuttleBreadcrumb.d.ts +0 -1
  71. package/types/components/ShuttleInfiniteScrollIndicator.d.ts +0 -1
  72. package/types/components/ShuttleListItem/ShuttleListItem.d.ts +0 -1
  73. package/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +0 -1
  74. package/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +0 -1
  75. package/types/components/ShuttleListPanel.d.ts +0 -1
  76. package/types/components/ShuttleSearchBox.d.ts +1 -3
  77. package/types/components/ShuttleSource.d.ts +0 -1
  78. package/types/components/ShuttleTarget.d.ts +0 -1
  79. package/types/components/VirtualizedItem.d.ts +0 -1
  80. package/types/components/VirtualizedList.d.ts +0 -1
  81. package/types/components/VirtualizedSortableList.d.ts +0 -1
  82. package/types/index.d.ts +1 -1
  83. package/types/updateShuttleStateFromProps.d.ts +1 -3
  84. package/types/withProviders.d.ts +0 -1
  85. package/cjs/AnimationState.js.map +0 -7
  86. package/cjs/DSShuttle.js.map +0 -7
  87. package/cjs/SearchState.js.map +0 -7
  88. package/cjs/Shuttle.actions.js.map +0 -7
  89. package/cjs/ShuttleContainer.js.map +0 -7
  90. package/cjs/ShuttleImpl.js.map +0 -7
  91. package/cjs/ShuttleRenderer.js.map +0 -7
  92. package/cjs/ShuttleState.js.map +0 -7
  93. package/cjs/animation/animationConfig.js.map +0 -7
  94. package/cjs/classedComponents.js.map +0 -7
  95. package/cjs/components/LoadingIndicator.js.map +0 -7
  96. package/cjs/components/OverflowList.js.map +0 -7
  97. package/cjs/components/ShuttleBreadcrumb.js.map +0 -7
  98. package/cjs/components/ShuttleInfiniteScrollIndicator.js.map +0 -7
  99. package/cjs/components/ShuttleListItem/ActionButtons.js.map +0 -7
  100. package/cjs/components/ShuttleListItem/ShuttleListItem.js.map +0 -7
  101. package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -7
  102. package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -7
  103. package/cjs/components/ShuttleListPanel.js.map +0 -7
  104. package/cjs/components/ShuttleSearchBox.js.map +0 -7
  105. package/cjs/components/ShuttleSource.js.map +0 -7
  106. package/cjs/components/ShuttleTarget.js.map +0 -7
  107. package/cjs/components/VirtualizedItem.js.map +0 -7
  108. package/cjs/components/VirtualizedList.js.map +0 -7
  109. package/cjs/components/VirtualizedSortableList.js.map +0 -7
  110. package/cjs/helper.js.map +0 -7
  111. package/cjs/index.js.map +0 -7
  112. package/cjs/tests/utils.js +0 -1218
  113. package/cjs/tests/utils.js.map +0 -7
  114. package/cjs/updateShuttleStateFromProps.js.map +0 -7
  115. package/cjs/utils.js.map +0 -7
  116. package/cjs/withProviders.js.map +0 -7
  117. package/esm/AnimationState.js.map +0 -7
  118. package/esm/DSShuttle.js.map +0 -7
  119. package/esm/SearchState.js.map +0 -7
  120. package/esm/Shuttle.actions.js.map +0 -7
  121. package/esm/ShuttleContainer.js.map +0 -7
  122. package/esm/ShuttleImpl.js.map +0 -7
  123. package/esm/ShuttleRenderer.js.map +0 -7
  124. package/esm/ShuttleState.js.map +0 -7
  125. package/esm/animation/animationConfig.js.map +0 -7
  126. package/esm/classedComponents.js.map +0 -7
  127. package/esm/components/LoadingIndicator.js.map +0 -7
  128. package/esm/components/OverflowList.js.map +0 -7
  129. package/esm/components/ShuttleBreadcrumb.js.map +0 -7
  130. package/esm/components/ShuttleInfiniteScrollIndicator.js.map +0 -7
  131. package/esm/components/ShuttleListItem/ActionButtons.js.map +0 -7
  132. package/esm/components/ShuttleListItem/ShuttleListItem.js.map +0 -7
  133. package/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -7
  134. package/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -7
  135. package/esm/components/ShuttleListPanel.js.map +0 -7
  136. package/esm/components/ShuttleSearchBox.js.map +0 -7
  137. package/esm/components/ShuttleSource.js.map +0 -7
  138. package/esm/components/ShuttleTarget.js.map +0 -7
  139. package/esm/components/VirtualizedItem.js.map +0 -7
  140. package/esm/components/VirtualizedList.js.map +0 -7
  141. package/esm/components/VirtualizedSortableList.js.map +0 -7
  142. package/esm/helper.js.map +0 -7
  143. package/esm/index.js.map +0 -7
  144. package/esm/tests/utils.js +0 -1189
  145. package/esm/tests/utils.js.map +0 -7
  146. package/esm/updateShuttleStateFromProps.js.map +0 -7
  147. package/esm/utils.js.map +0 -7
  148. package/esm/withProviders.js.map +0 -7
package/esm/DSShuttle.js CHANGED
@@ -1,141 +1,213 @@
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 = () => {
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
+ }));
9
93
  };
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
- }));
94
+
87
95
  const props = {
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"),
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 */
92
109
  items: PropTypes.arrayOf(PropTypes.shape({
93
110
  disableDrillDown: PropTypes.bool,
94
111
  icon: PropTypes.element,
95
112
  name: PropTypes.string,
96
113
  readOnly: PropTypes.bool,
97
114
  description: PropTypes.string
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"),
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 */
100
121
  nonSelectedItems: PropTypes.arrayOf(PropTypes.string).description("Array of item ids that aren't selected.. Should include ALL non selected items, even those not rendered"),
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"),
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") */
104
133
  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") */
105
136
  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")'),
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"),
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 */
119
178
  onAddCheckedItems: PropTypes.func.description("Handler when a users moves all the 'checked' items to the target"),
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")
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')
130
209
  };
131
- DSShuttle.propTypes = props;
132
210
  const DSShuttleWithSchema = describe(DSShuttle);
133
211
  DSShuttleWithSchema.propTypes = props;
134
- var DSShuttle_default = DSShuttle;
135
- export {
136
- DSShuttle,
137
- DSShuttleWithSchema,
138
- DSShuttle_default as default,
139
- utils
140
- };
141
- //# sourceMappingURL=DSShuttle.js.map
212
+
213
+ export { DSShuttleWithSchema, DSShuttle as default };
@@ -1,31 +1,35 @@
1
- import * as React from "react";
2
- import { useState } from "react";
3
- import createContainer from "constate";
1
+ import 'core-js/modules/web.dom-collections.iterator.js';
2
+ import { useState } from 'react';
3
+ import createContainer from 'constate';
4
+
4
5
  function useSearchState() {
5
- const [searchTerm, setSearchTerm] = useState("");
6
- const [searching, setSearchBoxVisibility] = useState(false);
6
+ const [searchTerm, setSearchTerm] = useState('');
7
+ const [searching, setSearchBoxVisibility] = useState(false); // todo: create a hook for Visibility behavior
8
+
7
9
  function toggleSearchBox(userVisible) {
8
- if (userVisible !== void 0) {
10
+ if (userVisible !== undefined) {
9
11
  setSearchBoxVisibility(userVisible);
10
12
  } else {
11
13
  setSearchBoxVisibility(!searching);
12
14
  }
13
15
  }
16
+
14
17
  function reset() {
15
- setSearchTerm("");
18
+ setSearchTerm('');
16
19
  setSearchBoxVisibility(false);
17
20
  }
21
+
18
22
  return {
19
- state: { searchTerm, searching },
23
+ state: {
24
+ searchTerm,
25
+ searching
26
+ },
20
27
  setSearchTerm,
21
28
  toggleSearchBox,
22
29
  reset
23
30
  };
24
31
  }
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
32
+
33
+ var SearchState = createContainer(useSearchState, value => [value.state]);
34
+
35
+ export { SearchState as default };
@@ -1,106 +1,123 @@
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";
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; }
14
15
  function toggleItemSelection(itemId) {
15
- return (state) => ({
16
- ...state,
16
+ return state => _objectSpread(_objectSpread({}, 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 {
26
- ...state,
25
+ return _objectSpread(_objectSpread({}, state), {}, {
27
26
  [hierarchyType]: indexInHierarchy !== -1 ? hierarchy.slice(0, indexInHierarchy + 1) : [...hierarchy, item]
28
- };
27
+ });
29
28
  };
30
29
  }
31
30
  function moveItem(item) {
32
- return (state) => {
31
+ return state => {
33
32
  const movedItems = toggleInObject(state.movedItems, item.id, item);
34
- return {
35
- ...state,
33
+ return _objectSpread(_objectSpread({}, state), {}, {
36
34
  movedItems
37
- };
35
+ });
38
36
  };
39
37
  }
40
38
  const defaultOptions = {
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);
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
+
48
57
  const item = collection[itemIndex];
49
- const children = item?.hasChildren ? compose(utils.getChildren({ index: itemIndex }))(collection) || [] : [];
50
- return { item, children };
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
+ };
51
65
  }
66
+
52
67
  function addToTarget(itemToAdd, collection) {
53
- return (state, { idField }) => {
68
+ return (state, _ref2) => {
69
+ let {
70
+ idField
71
+ } = _ref2;
54
72
  const items = collection || state.preparedItems;
55
- const { item, children } = getItemDeep({
73
+ const {
74
+ item,
75
+ children
76
+ } = getItemDeep({
56
77
  collection: items,
57
78
  id: itemToAdd[idField]
58
79
  });
59
- return {
60
- ...state,
80
+ return _objectSpread(_objectSpread({}, state), {}, {
61
81
  movedItems: [...state.movedItems, item],
62
82
  targetItems: [...state.targetItems, item, ...children]
63
- };
83
+ });
64
84
  };
65
- }
85
+ } // todo: optimize this
86
+
66
87
  function removeFromTarget(itemToRemove) {
67
- return (state, { idField }) => {
88
+ return (state, _ref3) => {
89
+ let {
90
+ idField
91
+ } = _ref3;
68
92
  let targetItems = cloneDeep(state.targetItems);
69
- const itemIndex = targetItems.findIndex((fItem) => fItem.id === itemToRemove.id);
93
+ const itemIndex = targetItems.findIndex(fItem => fItem.id === itemToRemove.id);
70
94
  const item = targetItems[itemIndex];
71
- const children = item?.hasChildren ? compose(filterMovedItems(state.movedItems), utils.getChildren({ index: itemIndex }))(targetItems) || [] : [];
95
+ const children = item !== null && item !== void 0 && item.hasChildren ? compose(filterMovedItems(state.movedItems), utils.getChildren({
96
+ index: itemIndex
97
+ }))(targetItems) || [] : [];
72
98
  targetItems.splice(itemIndex, 1);
73
- if (item?.hasChildren && children.length) {
74
- const childrenHash = hashArray(children, "id");
75
- targetItems = targetItems.filter((i) => !childrenHash[i.id]);
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]);
76
103
  }
77
- return {
78
- ...state,
79
- movedItems: state.movedItems.filter((mItem) => mItem[idField] !== itemToRemove[idField]),
104
+
105
+ return _objectSpread(_objectSpread({}, state), {}, {
106
+ movedItems: state.movedItems.filter(mItem => mItem[idField] !== itemToRemove[idField]),
80
107
  targetItems
81
- };
108
+ });
82
109
  };
83
110
  }
84
111
  function resetCheckedItems() {
85
- return (state) => ({
86
- ...state,
112
+ return state => _objectSpread(_objectSpread({}, state), {}, {
87
113
  checkedItems: []
88
114
  });
89
115
  }
90
116
  function resetMovedItems() {
91
- return (state) => ({
92
- ...state,
117
+ return state => _objectSpread(_objectSpread({}, state), {}, {
93
118
  movedItems: [],
94
119
  targetItems: []
95
120
  });
96
121
  }
97
- export {
98
- addToTarget,
99
- moveItem,
100
- navigateTo,
101
- removeFromTarget,
102
- resetCheckedItems,
103
- resetMovedItems,
104
- toggleItemSelection
105
- };
106
- //# sourceMappingURL=Shuttle.actions.js.map
122
+
123
+ export { addToTarget, moveItem, navigateTo, removeFromTarget, resetCheckedItems, resetMovedItems, toggleItemSelection };