@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.
- package/cjs/AnimationState.js +19 -46
- package/cjs/DSShuttle.js +219 -166
- package/cjs/SearchState.js +25 -44
- package/cjs/Shuttle.actions.js +98 -87
- package/cjs/ShuttleContainer.js +61 -56
- package/cjs/ShuttleImpl.js +206 -109
- package/cjs/ShuttleRenderer.js +135 -140
- package/cjs/ShuttleState.js +53 -57
- package/cjs/animation/animationConfig.js +56 -53
- package/cjs/classedComponents.js +69 -70
- package/cjs/components/LoadingIndicator.js +22 -49
- package/cjs/components/OverflowList.js +48 -50
- package/cjs/components/ShuttleBreadcrumb.js +40 -52
- package/cjs/components/ShuttleInfiniteScrollIndicator.js +37 -46
- package/cjs/components/ShuttleListItem/ActionButtons.js +51 -56
- package/cjs/components/ShuttleListItem/ShuttleListItem.js +80 -78
- package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +64 -78
- package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +56 -72
- package/cjs/components/ShuttleListPanel.js +26 -44
- package/cjs/components/ShuttleSearchBox.js +72 -61
- package/cjs/components/ShuttleSource.js +146 -150
- package/cjs/components/ShuttleTarget.js +100 -88
- package/cjs/components/VirtualizedItem.js +40 -45
- package/cjs/components/VirtualizedList.js +86 -81
- package/cjs/components/VirtualizedSortableList.js +40 -47
- package/cjs/helper.js +103 -69
- package/cjs/index.js +12 -38
- package/cjs/updateShuttleStateFromProps.js +69 -73
- package/cjs/utils.js +42 -40
- package/cjs/withProviders.js +27 -43
- package/esm/AnimationState.js +8 -12
- package/esm/DSShuttle.js +198 -126
- package/esm/SearchState.js +19 -15
- package/esm/Shuttle.actions.js +80 -63
- package/esm/ShuttleContainer.js +50 -34
- package/esm/ShuttleImpl.js +183 -78
- package/esm/ShuttleRenderer.js +128 -111
- package/esm/ShuttleState.js +53 -34
- package/esm/animation/animationConfig.js +52 -24
- package/esm/classedComponents.js +51 -43
- package/esm/components/LoadingIndicator.js +15 -20
- package/esm/components/OverflowList.js +41 -21
- package/esm/components/ShuttleBreadcrumb.js +33 -23
- package/esm/components/ShuttleInfiniteScrollIndicator.js +31 -18
- package/esm/components/ShuttleListItem/ActionButtons.js +39 -27
- package/esm/components/ShuttleListItem/ShuttleListItem.js +72 -50
- package/esm/components/ShuttleListItem/ShuttleSourceListItem.js +52 -45
- package/esm/components/ShuttleListItem/ShuttleTargetListItem.js +47 -42
- package/esm/components/ShuttleListPanel.js +19 -15
- package/esm/components/ShuttleSearchBox.js +66 -32
- package/esm/components/ShuttleSource.js +129 -125
- package/esm/components/ShuttleTarget.js +89 -68
- package/esm/components/VirtualizedItem.js +33 -15
- package/esm/components/VirtualizedList.js +75 -50
- package/esm/components/VirtualizedSortableList.js +32 -17
- package/esm/helper.js +67 -43
- package/esm/index.js +2 -9
- package/esm/updateShuttleStateFromProps.js +58 -39
- package/esm/utils.js +18 -12
- package/esm/withProviders.js +20 -14
- package/package.json +11 -11
- package/types/AnimationState.d.ts +2 -3
- package/types/DSShuttle.d.ts +1 -1
- package/types/SearchState.d.ts +2 -3
- package/types/ShuttleImpl.d.ts +2 -3
- package/types/ShuttleRenderer.d.ts +0 -1
- package/types/ShuttleState.d.ts +2 -3
- package/types/components/LoadingIndicator.d.ts +0 -1
- package/types/components/OverflowList.d.ts +0 -1
- package/types/components/ShuttleBreadcrumb.d.ts +0 -1
- package/types/components/ShuttleInfiniteScrollIndicator.d.ts +0 -1
- package/types/components/ShuttleListItem/ShuttleListItem.d.ts +0 -1
- package/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +0 -1
- package/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +0 -1
- package/types/components/ShuttleListPanel.d.ts +0 -1
- package/types/components/ShuttleSearchBox.d.ts +1 -3
- package/types/components/ShuttleSource.d.ts +0 -1
- package/types/components/ShuttleTarget.d.ts +0 -1
- package/types/components/VirtualizedItem.d.ts +0 -1
- package/types/components/VirtualizedList.d.ts +0 -1
- package/types/components/VirtualizedSortableList.d.ts +0 -1
- package/types/index.d.ts +1 -1
- package/types/updateShuttleStateFromProps.d.ts +1 -3
- package/types/withProviders.d.ts +0 -1
- package/cjs/AnimationState.js.map +0 -7
- package/cjs/DSShuttle.js.map +0 -7
- package/cjs/SearchState.js.map +0 -7
- package/cjs/Shuttle.actions.js.map +0 -7
- package/cjs/ShuttleContainer.js.map +0 -7
- package/cjs/ShuttleImpl.js.map +0 -7
- package/cjs/ShuttleRenderer.js.map +0 -7
- package/cjs/ShuttleState.js.map +0 -7
- package/cjs/animation/animationConfig.js.map +0 -7
- package/cjs/classedComponents.js.map +0 -7
- package/cjs/components/LoadingIndicator.js.map +0 -7
- package/cjs/components/OverflowList.js.map +0 -7
- package/cjs/components/ShuttleBreadcrumb.js.map +0 -7
- package/cjs/components/ShuttleInfiniteScrollIndicator.js.map +0 -7
- package/cjs/components/ShuttleListItem/ActionButtons.js.map +0 -7
- package/cjs/components/ShuttleListItem/ShuttleListItem.js.map +0 -7
- package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -7
- package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -7
- package/cjs/components/ShuttleListPanel.js.map +0 -7
- package/cjs/components/ShuttleSearchBox.js.map +0 -7
- package/cjs/components/ShuttleSource.js.map +0 -7
- package/cjs/components/ShuttleTarget.js.map +0 -7
- package/cjs/components/VirtualizedItem.js.map +0 -7
- package/cjs/components/VirtualizedList.js.map +0 -7
- package/cjs/components/VirtualizedSortableList.js.map +0 -7
- package/cjs/helper.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/tests/utils.js +0 -1218
- package/cjs/tests/utils.js.map +0 -7
- package/cjs/updateShuttleStateFromProps.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/cjs/withProviders.js.map +0 -7
- package/esm/AnimationState.js.map +0 -7
- package/esm/DSShuttle.js.map +0 -7
- package/esm/SearchState.js.map +0 -7
- package/esm/Shuttle.actions.js.map +0 -7
- package/esm/ShuttleContainer.js.map +0 -7
- package/esm/ShuttleImpl.js.map +0 -7
- package/esm/ShuttleRenderer.js.map +0 -7
- package/esm/ShuttleState.js.map +0 -7
- package/esm/animation/animationConfig.js.map +0 -7
- package/esm/classedComponents.js.map +0 -7
- package/esm/components/LoadingIndicator.js.map +0 -7
- package/esm/components/OverflowList.js.map +0 -7
- package/esm/components/ShuttleBreadcrumb.js.map +0 -7
- package/esm/components/ShuttleInfiniteScrollIndicator.js.map +0 -7
- package/esm/components/ShuttleListItem/ActionButtons.js.map +0 -7
- package/esm/components/ShuttleListItem/ShuttleListItem.js.map +0 -7
- package/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -7
- package/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -7
- package/esm/components/ShuttleListPanel.js.map +0 -7
- package/esm/components/ShuttleSearchBox.js.map +0 -7
- package/esm/components/ShuttleSource.js.map +0 -7
- package/esm/components/ShuttleTarget.js.map +0 -7
- package/esm/components/VirtualizedItem.js.map +0 -7
- package/esm/components/VirtualizedList.js.map +0 -7
- package/esm/components/VirtualizedSortableList.js.map +0 -7
- package/esm/helper.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/tests/utils.js +0 -1189
- package/esm/tests/utils.js.map +0 -7
- package/esm/updateShuttleStateFromProps.js.map +0 -7
- package/esm/utils.js.map +0 -7
- package/esm/withProviders.js.map +0 -7
package/esm/DSShuttle.js
CHANGED
|
@@ -1,141 +1,213 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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(
|
|
99
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
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 };
|
package/esm/SearchState.js
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState } from
|
|
3
|
-
import createContainer from
|
|
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 !==
|
|
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: {
|
|
23
|
+
state: {
|
|
24
|
+
searchTerm,
|
|
25
|
+
searching
|
|
26
|
+
},
|
|
20
27
|
setSearchTerm,
|
|
21
28
|
toggleSearchBox,
|
|
22
29
|
reset
|
|
23
30
|
};
|
|
24
31
|
}
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
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 };
|
package/esm/Shuttle.actions.js
CHANGED
|
@@ -1,106 +1,123 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
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
|
|
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
|
|
23
|
-
const indexInHierarchy = state[hierarchyType].findIndex(
|
|
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
|
|
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:
|
|
42
|
-
idField:
|
|
43
|
-
op:
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
|
50
|
-
|
|
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,
|
|
68
|
+
return (state, _ref2) => {
|
|
69
|
+
let {
|
|
70
|
+
idField
|
|
71
|
+
} = _ref2;
|
|
54
72
|
const items = collection || state.preparedItems;
|
|
55
|
-
const {
|
|
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,
|
|
88
|
+
return (state, _ref3) => {
|
|
89
|
+
let {
|
|
90
|
+
idField
|
|
91
|
+
} = _ref3;
|
|
68
92
|
let targetItems = cloneDeep(state.targetItems);
|
|
69
|
-
const itemIndex = targetItems.findIndex(
|
|
93
|
+
const itemIndex = targetItems.findIndex(fItem => fItem.id === itemToRemove.id);
|
|
70
94
|
const item = targetItems[itemIndex];
|
|
71
|
-
const children = item
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
movedItems: state.movedItems.filter(
|
|
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
|
|
86
|
-
...state,
|
|
112
|
+
return state => _objectSpread(_objectSpread({}, state), {}, {
|
|
87
113
|
checkedItems: []
|
|
88
114
|
});
|
|
89
115
|
}
|
|
90
116
|
function resetMovedItems() {
|
|
91
|
-
return
|
|
92
|
-
...state,
|
|
117
|
+
return state => _objectSpread(_objectSpread({}, state), {}, {
|
|
93
118
|
movedItems: [],
|
|
94
119
|
targetItems: []
|
|
95
120
|
});
|
|
96
121
|
}
|
|
97
|
-
|
|
98
|
-
|
|
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 };
|