@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.
- package/cjs/AnimationState.js +46 -19
- package/cjs/AnimationState.js.map +7 -0
- package/cjs/DSShuttle.js +166 -219
- package/cjs/DSShuttle.js.map +7 -0
- package/cjs/SearchState.js +44 -25
- package/cjs/SearchState.js.map +7 -0
- package/cjs/Shuttle.actions.js +87 -98
- package/cjs/Shuttle.actions.js.map +7 -0
- package/cjs/ShuttleContainer.js +56 -61
- package/cjs/ShuttleContainer.js.map +7 -0
- package/cjs/ShuttleImpl.js +109 -206
- package/cjs/ShuttleImpl.js.map +7 -0
- package/cjs/ShuttleRenderer.js +140 -135
- package/cjs/ShuttleRenderer.js.map +7 -0
- package/cjs/ShuttleState.js +57 -53
- package/cjs/ShuttleState.js.map +7 -0
- package/cjs/animation/animationConfig.js +53 -56
- package/cjs/animation/animationConfig.js.map +7 -0
- package/cjs/classedComponents.js +70 -69
- package/cjs/classedComponents.js.map +7 -0
- package/cjs/components/LoadingIndicator.js +49 -22
- package/cjs/components/LoadingIndicator.js.map +7 -0
- package/cjs/components/OverflowList.js +50 -48
- package/cjs/components/OverflowList.js.map +7 -0
- package/cjs/components/ShuttleBreadcrumb.js +52 -40
- package/cjs/components/ShuttleBreadcrumb.js.map +7 -0
- package/cjs/components/ShuttleInfiniteScrollIndicator.js +46 -37
- package/cjs/components/ShuttleInfiniteScrollIndicator.js.map +7 -0
- package/cjs/components/ShuttleListItem/ActionButtons.js +56 -51
- package/cjs/components/ShuttleListItem/ActionButtons.js.map +7 -0
- package/cjs/components/ShuttleListItem/ShuttleListItem.js +78 -80
- package/cjs/components/ShuttleListItem/ShuttleListItem.js.map +7 -0
- package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +78 -64
- package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +7 -0
- package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +72 -56
- package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +7 -0
- package/cjs/components/ShuttleListPanel.js +44 -26
- package/cjs/components/ShuttleListPanel.js.map +7 -0
- package/cjs/components/ShuttleSearchBox.js +61 -72
- package/cjs/components/ShuttleSearchBox.js.map +7 -0
- package/cjs/components/ShuttleSource.js +150 -146
- package/cjs/components/ShuttleSource.js.map +7 -0
- package/cjs/components/ShuttleTarget.js +88 -100
- package/cjs/components/ShuttleTarget.js.map +7 -0
- package/cjs/components/VirtualizedItem.js +45 -40
- package/cjs/components/VirtualizedItem.js.map +7 -0
- package/cjs/components/VirtualizedList.js +81 -86
- package/cjs/components/VirtualizedList.js.map +7 -0
- package/cjs/components/VirtualizedSortableList.js +47 -40
- package/cjs/components/VirtualizedSortableList.js.map +7 -0
- package/cjs/helper.js +69 -103
- package/cjs/helper.js.map +7 -0
- package/cjs/index.js +38 -12
- package/cjs/index.js.map +7 -0
- package/cjs/tests/utils.js +1218 -0
- package/cjs/tests/utils.js.map +7 -0
- package/cjs/updateShuttleStateFromProps.js +73 -69
- package/cjs/updateShuttleStateFromProps.js.map +7 -0
- package/cjs/utils.js +40 -42
- package/cjs/utils.js.map +7 -0
- package/cjs/withProviders.js +43 -27
- package/cjs/withProviders.js.map +7 -0
- package/esm/AnimationState.js +12 -8
- package/esm/AnimationState.js.map +7 -0
- package/esm/DSShuttle.js +126 -198
- package/esm/DSShuttle.js.map +7 -0
- package/esm/SearchState.js +15 -19
- package/esm/SearchState.js.map +7 -0
- package/esm/Shuttle.actions.js +63 -80
- package/esm/Shuttle.actions.js.map +7 -0
- package/esm/ShuttleContainer.js +34 -50
- package/esm/ShuttleContainer.js.map +7 -0
- package/esm/ShuttleImpl.js +78 -183
- package/esm/ShuttleImpl.js.map +7 -0
- package/esm/ShuttleRenderer.js +111 -128
- package/esm/ShuttleRenderer.js.map +7 -0
- package/esm/ShuttleState.js +34 -53
- package/esm/ShuttleState.js.map +7 -0
- package/esm/animation/animationConfig.js +24 -52
- package/esm/animation/animationConfig.js.map +7 -0
- package/esm/classedComponents.js +43 -51
- package/esm/classedComponents.js.map +7 -0
- package/esm/components/LoadingIndicator.js +20 -15
- package/esm/components/LoadingIndicator.js.map +7 -0
- package/esm/components/OverflowList.js +21 -41
- package/esm/components/OverflowList.js.map +7 -0
- package/esm/components/ShuttleBreadcrumb.js +23 -33
- package/esm/components/ShuttleBreadcrumb.js.map +7 -0
- package/esm/components/ShuttleInfiniteScrollIndicator.js +18 -31
- package/esm/components/ShuttleInfiniteScrollIndicator.js.map +7 -0
- package/esm/components/ShuttleListItem/ActionButtons.js +27 -39
- package/esm/components/ShuttleListItem/ActionButtons.js.map +7 -0
- package/esm/components/ShuttleListItem/ShuttleListItem.js +50 -72
- package/esm/components/ShuttleListItem/ShuttleListItem.js.map +7 -0
- package/esm/components/ShuttleListItem/ShuttleSourceListItem.js +45 -52
- package/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +7 -0
- package/esm/components/ShuttleListItem/ShuttleTargetListItem.js +42 -47
- package/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +7 -0
- package/esm/components/ShuttleListPanel.js +15 -19
- package/esm/components/ShuttleListPanel.js.map +7 -0
- package/esm/components/ShuttleSearchBox.js +32 -66
- package/esm/components/ShuttleSearchBox.js.map +7 -0
- package/esm/components/ShuttleSource.js +125 -129
- package/esm/components/ShuttleSource.js.map +7 -0
- package/esm/components/ShuttleTarget.js +68 -89
- package/esm/components/ShuttleTarget.js.map +7 -0
- package/esm/components/VirtualizedItem.js +15 -33
- package/esm/components/VirtualizedItem.js.map +7 -0
- package/esm/components/VirtualizedList.js +50 -75
- package/esm/components/VirtualizedList.js.map +7 -0
- package/esm/components/VirtualizedSortableList.js +17 -32
- package/esm/components/VirtualizedSortableList.js.map +7 -0
- package/esm/helper.js +43 -67
- package/esm/helper.js.map +7 -0
- package/esm/index.js +9 -2
- package/esm/index.js.map +7 -0
- package/esm/tests/utils.js +1189 -0
- package/esm/tests/utils.js.map +7 -0
- package/esm/updateShuttleStateFromProps.js +39 -58
- package/esm/updateShuttleStateFromProps.js.map +7 -0
- package/esm/utils.js +12 -18
- package/esm/utils.js.map +7 -0
- package/esm/withProviders.js +14 -20
- package/esm/withProviders.js.map +7 -0
- package/package.json +11 -11
- package/types/AnimationState.d.ts +3 -2
- package/types/DSShuttle.d.ts +2 -39
- package/types/SearchState.d.ts +3 -2
- package/types/ShuttleImpl.d.ts +3 -2
- package/types/ShuttleRenderer.d.ts +1 -0
- package/types/ShuttleState.d.ts +3 -2
- package/types/components/LoadingIndicator.d.ts +1 -0
- package/types/components/OverflowList.d.ts +1 -0
- package/types/components/ShuttleBreadcrumb.d.ts +1 -0
- package/types/components/ShuttleInfiniteScrollIndicator.d.ts +1 -0
- package/types/components/ShuttleListItem/ShuttleListItem.d.ts +1 -0
- package/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +1 -0
- package/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +1 -0
- package/types/components/ShuttleListPanel.d.ts +1 -0
- package/types/components/ShuttleSearchBox.d.ts +3 -1
- package/types/components/ShuttleSource.d.ts +1 -0
- package/types/components/ShuttleTarget.d.ts +1 -0
- package/types/components/VirtualizedItem.d.ts +1 -0
- package/types/components/VirtualizedList.d.ts +1 -0
- package/types/components/VirtualizedSortableList.d.ts +1 -0
- package/types/index.d.ts +1 -1
- package/types/updateShuttleStateFromProps.d.ts +3 -1
- package/types/withProviders.d.ts +1 -0
package/esm/DSShuttle.js
CHANGED
|
@@ -1,213 +1,141 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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(
|
|
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
|
-
|
|
124
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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 {
|
|
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,E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KAAK,YAAY;AAAA,EAErC,qBAAqB,UAAU,KAAK,YAAY;AAAA,EAEhD,qBAAqB,UAAU,KAAK,YAAY;AAAA,EAEhD,sBAAsB,UAAU,OAAO,YAAY;AAAA,EAEnD,sBAAsB,UAAU,OAAO,YAAY;AAAA,EAEnD,mBAAmB,UAAU,OAAO,YAAY;AAAA,EAEhD,eAAe,UAAU,KAAK,YAAY;AAAA,EAE1C,eAAe,UAAU,KAAK,YAAY;AAAA;AAG5C,UAAU,YAAY;AACtB,MAAM,sBAAsB,SAAS;AACrC,oBAAoB,YAAY;AAIhC,IAAO,oBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/SearchState.js
CHANGED
|
@@ -1,35 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useState } from
|
|
3
|
-
import createContainer from
|
|
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);
|
|
8
|
-
|
|
5
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
6
|
+
const [searching, setSearchBoxVisibility] = useState(false);
|
|
9
7
|
function toggleSearchBox(userVisible) {
|
|
10
|
-
if (userVisible !==
|
|
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
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
}
|
package/esm/Shuttle.actions.js
CHANGED
|
@@ -1,123 +1,106 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 =>
|
|
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
|
|
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
|
|
34
|
+
return {
|
|
35
|
+
...state,
|
|
34
36
|
movedItems
|
|
35
|
-
}
|
|
37
|
+
};
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
const defaultOptions = {
|
|
39
|
-
parentField:
|
|
40
|
-
idField:
|
|
41
|
-
op: hasMoved => !hasMoved
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
59
|
-
|
|
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,
|
|
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
|
|
59
|
+
return {
|
|
60
|
+
...state,
|
|
81
61
|
movedItems: [...state.movedItems, item],
|
|
82
62
|
targetItems: [...state.targetItems, item, ...children]
|
|
83
|
-
}
|
|
63
|
+
};
|
|
84
64
|
};
|
|
85
|
-
}
|
|
86
|
-
|
|
65
|
+
}
|
|
87
66
|
function removeFromTarget(itemToRemove) {
|
|
88
|
-
return (state,
|
|
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
|
|
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
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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 =>
|
|
85
|
+
return (state) => ({
|
|
86
|
+
...state,
|
|
113
87
|
checkedItems: []
|
|
114
88
|
});
|
|
115
89
|
}
|
|
116
90
|
function resetMovedItems() {
|
|
117
|
-
return state =>
|
|
91
|
+
return (state) => ({
|
|
92
|
+
...state,
|
|
118
93
|
movedItems: [],
|
|
119
94
|
targetItems: []
|
|
120
95
|
});
|
|
121
96
|
}
|
|
122
|
-
|
|
123
|
-
|
|
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,OAAO,WAAW;AACxB,QAAM,WAAW,MAAM,cACnB,QAAQ,MAAM,YAAY,EAAE,OAAO,cAAc,eAAe,KAChE;AAEJ,SAAO,EAAE,MAAM;AAAA;AAGV,qBAAqB,WAAW,YAAY;AACjD,SAAO,CAAC,OAAO,EA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