@elliemae/ds-shuttle 3.0.0-next.1 → 3.0.0-next.5
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/dist/cjs/AnimationState.js +75 -0
- package/dist/cjs/AnimationState.js.map +7 -0
- package/dist/cjs/DSShuttle.js +170 -0
- package/dist/cjs/DSShuttle.js.map +7 -0
- package/dist/cjs/SearchState.js +60 -0
- package/dist/cjs/SearchState.js.map +7 -0
- package/dist/cjs/Shuttle.actions.js +136 -0
- package/dist/cjs/Shuttle.actions.js.map +7 -0
- package/dist/cjs/ShuttleContainer.js +108 -0
- package/dist/cjs/ShuttleContainer.js.map +7 -0
- package/dist/cjs/ShuttleImpl.js +242 -0
- package/dist/cjs/ShuttleImpl.js.map +7 -0
- package/dist/cjs/ShuttleRenderer.js +203 -0
- package/dist/cjs/ShuttleRenderer.js.map +7 -0
- package/dist/cjs/ShuttleState.js +84 -0
- package/dist/cjs/ShuttleState.js.map +7 -0
- package/dist/cjs/animation/animationConfig.js +78 -0
- package/dist/cjs/animation/animationConfig.js.map +7 -0
- package/dist/cjs/classedComponents.js +72 -0
- package/dist/cjs/classedComponents.js.map +7 -0
- package/dist/cjs/components/LoadingIndicator.js +52 -0
- package/dist/cjs/components/LoadingIndicator.js.map +7 -0
- package/dist/cjs/components/OverflowList.js +71 -0
- package/dist/cjs/components/OverflowList.js.map +7 -0
- package/dist/cjs/components/ShuttleBreadcrumb.js +54 -0
- package/dist/cjs/components/ShuttleBreadcrumb.js.map +7 -0
- package/dist/cjs/components/ShuttleInfiniteScrollIndicator.js +48 -0
- package/dist/cjs/components/ShuttleInfiniteScrollIndicator.js.map +7 -0
- package/dist/cjs/components/ShuttleListItem/ActionButtons.js +76 -0
- package/dist/cjs/components/ShuttleListItem/ActionButtons.js.map +7 -0
- package/dist/cjs/components/ShuttleListItem/ShuttleListItem.js +121 -0
- package/dist/cjs/components/ShuttleListItem/ShuttleListItem.js.map +7 -0
- package/dist/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +127 -0
- package/dist/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +7 -0
- package/dist/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +110 -0
- package/dist/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +7 -0
- package/dist/cjs/components/ShuttleListPanel.js +49 -0
- package/dist/cjs/components/ShuttleListPanel.js.map +7 -0
- package/dist/cjs/components/ShuttleSearchBox.js +99 -0
- package/dist/cjs/components/ShuttleSearchBox.js.map +7 -0
- package/dist/cjs/components/ShuttleSource.js +223 -0
- package/dist/cjs/components/ShuttleSource.js.map +7 -0
- package/dist/cjs/components/ShuttleTarget.js +135 -0
- package/dist/cjs/components/ShuttleTarget.js.map +7 -0
- package/dist/cjs/components/VirtualizedItem.js +65 -0
- package/dist/cjs/components/VirtualizedItem.js.map +7 -0
- package/dist/cjs/components/VirtualizedList.js +104 -0
- package/dist/cjs/components/VirtualizedList.js.map +7 -0
- package/dist/cjs/components/VirtualizedSortableList.js +77 -0
- package/dist/cjs/components/VirtualizedSortableList.js.map +7 -0
- package/dist/cjs/helper.js +99 -0
- package/dist/cjs/helper.js.map +7 -0
- package/dist/cjs/index.js +38 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/tests/utils.js +1235 -0
- package/dist/cjs/tests/utils.js.map +7 -0
- package/dist/cjs/updateShuttleStateFromProps.js +108 -0
- package/dist/cjs/updateShuttleStateFromProps.js.map +7 -0
- package/dist/cjs/utils.js +54 -0
- package/dist/cjs/utils.js.map +7 -0
- package/dist/cjs/withProviders.js +57 -0
- package/dist/cjs/withProviders.js.map +7 -0
- package/{esm → dist/esm}/AnimationState.js +12 -8
- package/dist/esm/AnimationState.js.map +7 -0
- package/dist/esm/DSShuttle.js +141 -0
- package/dist/esm/DSShuttle.js.map +7 -0
- package/dist/esm/SearchState.js +31 -0
- package/dist/esm/SearchState.js.map +7 -0
- package/dist/esm/Shuttle.actions.js +118 -0
- package/dist/esm/Shuttle.actions.js.map +7 -0
- package/dist/esm/ShuttleContainer.js +92 -0
- package/dist/esm/ShuttleContainer.js.map +7 -0
- package/dist/esm/ShuttleImpl.js +229 -0
- package/dist/esm/ShuttleImpl.js.map +7 -0
- package/dist/esm/ShuttleRenderer.js +176 -0
- package/dist/esm/ShuttleRenderer.js.map +7 -0
- package/dist/esm/ShuttleState.js +55 -0
- package/dist/esm/ShuttleState.js.map +7 -0
- package/dist/esm/animation/animationConfig.js +49 -0
- package/dist/esm/animation/animationConfig.js.map +7 -0
- package/dist/esm/classedComponents.js +43 -0
- package/dist/esm/classedComponents.js.map +7 -0
- package/dist/esm/components/LoadingIndicator.js +23 -0
- package/dist/esm/components/LoadingIndicator.js.map +7 -0
- package/dist/esm/components/OverflowList.js +44 -0
- package/dist/esm/components/OverflowList.js.map +7 -0
- package/dist/esm/components/ShuttleBreadcrumb.js +25 -0
- package/dist/esm/components/ShuttleBreadcrumb.js.map +7 -0
- package/dist/esm/components/ShuttleInfiniteScrollIndicator.js +19 -0
- package/dist/esm/components/ShuttleInfiniteScrollIndicator.js.map +7 -0
- package/dist/esm/components/ShuttleListItem/ActionButtons.js +49 -0
- package/dist/esm/components/ShuttleListItem/ActionButtons.js.map +7 -0
- package/dist/esm/components/ShuttleListItem/ShuttleListItem.js +94 -0
- package/dist/esm/components/ShuttleListItem/ShuttleListItem.js.map +7 -0
- package/dist/esm/components/ShuttleListItem/ShuttleSourceListItem.js +100 -0
- package/dist/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +7 -0
- package/dist/esm/components/ShuttleListItem/ShuttleTargetListItem.js +83 -0
- package/dist/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +7 -0
- package/dist/esm/components/ShuttleListPanel.js +20 -0
- package/dist/esm/components/ShuttleListPanel.js.map +7 -0
- package/dist/esm/components/ShuttleSearchBox.js +70 -0
- package/dist/esm/components/ShuttleSearchBox.js.map +7 -0
- package/dist/esm/components/ShuttleSource.js +208 -0
- package/dist/esm/components/ShuttleSource.js.map +7 -0
- package/dist/esm/components/ShuttleTarget.js +119 -0
- package/dist/esm/components/ShuttleTarget.js.map +7 -0
- package/dist/esm/components/VirtualizedItem.js +38 -0
- package/dist/esm/components/VirtualizedItem.js.map +7 -0
- package/dist/esm/components/VirtualizedList.js +77 -0
- package/dist/esm/components/VirtualizedList.js.map +7 -0
- package/dist/esm/components/VirtualizedSortableList.js +50 -0
- package/dist/esm/components/VirtualizedSortableList.js.map +7 -0
- package/dist/esm/helper.js +72 -0
- package/dist/esm/helper.js.map +7 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/tests/utils.js +1208 -0
- package/dist/esm/tests/utils.js.map +7 -0
- package/dist/esm/updateShuttleStateFromProps.js +81 -0
- package/dist/esm/updateShuttleStateFromProps.js.map +7 -0
- package/dist/esm/utils.js +27 -0
- package/dist/esm/utils.js.map +7 -0
- package/dist/esm/withProviders.js +30 -0
- package/dist/esm/withProviders.js.map +7 -0
- package/package.json +98 -89
- package/cjs/AnimationState.js +0 -48
- package/cjs/DSShuttle.js +0 -223
- package/cjs/SearchState.js +0 -41
- package/cjs/Shuttle.actions.js +0 -137
- package/cjs/ShuttleContainer.js +0 -87
- package/cjs/ShuttleImpl.js +0 -311
- package/cjs/ShuttleRenderer.js +0 -139
- package/cjs/ShuttleState.js +0 -80
- package/cjs/animation/animationConfig.js +0 -81
- package/cjs/classedComponents.js +0 -71
- package/cjs/components/LoadingIndicator.js +0 -25
- package/cjs/components/OverflowList.js +0 -53
- package/cjs/components/ShuttleBreadcrumb.js +0 -42
- package/cjs/components/ShuttleInfiniteScrollIndicator.js +0 -39
- package/cjs/components/ShuttleListItem/ActionButtons.js +0 -55
- package/cjs/components/ShuttleListItem/ShuttleListItem.js +0 -85
- package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +0 -76
- package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +0 -57
- package/cjs/components/ShuttleListPanel.js +0 -31
- package/cjs/components/ShuttleSearchBox.js +0 -110
- package/cjs/components/ShuttleSource.js +0 -188
- package/cjs/components/ShuttleTarget.js +0 -116
- package/cjs/components/VirtualizedItem.js +0 -46
- package/cjs/components/VirtualizedList.js +0 -93
- package/cjs/components/VirtualizedSortableList.js +0 -41
- package/cjs/helper.js +0 -117
- package/cjs/index.js +0 -12
- package/cjs/updateShuttleStateFromProps.js +0 -94
- package/cjs/utils.js +0 -43
- package/cjs/withProviders.js +0 -29
- package/esm/DSShuttle.js +0 -213
- package/esm/SearchState.js +0 -35
- package/esm/Shuttle.actions.js +0 -123
- package/esm/ShuttleContainer.js +0 -80
- package/esm/ShuttleImpl.js +0 -304
- package/esm/ShuttleRenderer.js +0 -132
- package/esm/ShuttleState.js +0 -74
- package/esm/animation/animationConfig.js +0 -77
- package/esm/classedComponents.js +0 -51
- package/esm/components/LoadingIndicator.js +0 -18
- package/esm/components/OverflowList.js +0 -46
- package/esm/components/ShuttleBreadcrumb.js +0 -35
- package/esm/components/ShuttleInfiniteScrollIndicator.js +0 -32
- package/esm/components/ShuttleListItem/ActionButtons.js +0 -43
- package/esm/components/ShuttleListItem/ShuttleListItem.js +0 -76
- package/esm/components/ShuttleListItem/ShuttleSourceListItem.js +0 -68
- package/esm/components/ShuttleListItem/ShuttleTargetListItem.js +0 -49
- package/esm/components/ShuttleListPanel.js +0 -24
- package/esm/components/ShuttleSearchBox.js +0 -104
- package/esm/components/ShuttleSource.js +0 -179
- package/esm/components/ShuttleTarget.js +0 -107
- package/esm/components/VirtualizedItem.js +0 -40
- package/esm/components/VirtualizedList.js +0 -84
- package/esm/components/VirtualizedSortableList.js +0 -34
- package/esm/helper.js +0 -78
- package/esm/index.js +0 -2
- package/esm/updateShuttleStateFromProps.js +0 -88
- package/esm/utils.js +0 -18
- package/esm/withProviders.js +0 -22
- package/types/AnimationState.d.ts +0 -26
- package/types/DSShuttle.d.ts +0 -341
- package/types/SearchState.d.ts +0 -22
- package/types/Shuttle.actions.d.ts +0 -11
- package/types/ShuttleContainer.d.ts +0 -3
- package/types/ShuttleImpl.d.ts +0 -3
- package/types/ShuttleRenderer.d.ts +0 -37
- package/types/ShuttleState.d.ts +0 -53
- package/types/animation/animationConfig.d.ts +0 -68
- package/types/classedComponents.d.ts +0 -14
- package/types/components/LoadingIndicator.d.ts +0 -3
- package/types/components/OverflowList.d.ts +0 -7
- package/types/components/ShuttleBreadcrumb.d.ts +0 -7
- package/types/components/ShuttleInfiniteScrollIndicator.d.ts +0 -5
- package/types/components/ShuttleListItem/ActionButtons.d.ts +0 -4
- package/types/components/ShuttleListItem/ShuttleListItem.d.ts +0 -14
- package/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +0 -13
- package/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +0 -13
- package/types/components/ShuttleListPanel.d.ts +0 -7
- package/types/components/ShuttleSearchBox.d.ts +0 -20
- package/types/components/ShuttleSource.d.ts +0 -54
- package/types/components/ShuttleTarget.d.ts +0 -16
- package/types/components/VirtualizedItem.d.ts +0 -3
- package/types/components/VirtualizedList.d.ts +0 -12
- package/types/components/VirtualizedSortableList.d.ts +0 -6
- package/types/helper.d.ts +0 -16
- package/types/index.d.ts +0 -1
- package/types/tests/DSShuttle.events.test.d.ts +0 -1
- package/types/tests/DSShuttle.test.d.ts +0 -1
- package/types/tests/utils.d.ts +0 -116
- package/types/updateShuttleStateFromProps.d.ts +0 -1
- package/types/utils.d.ts +0 -2
- package/types/withProviders.d.ts +0 -3
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
5
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
6
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
7
|
-
require('core-js/modules/esnext.async-iterator.find.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.find.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
12
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
13
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
14
|
-
var dsUtilities = require('@elliemae/ds-utilities');
|
|
15
|
-
var helper = require('./helper.js');
|
|
16
|
-
var Shuttle_actions = require('./Shuttle.actions.js');
|
|
17
|
-
|
|
18
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
19
|
-
|
|
20
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
|
-
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__default["default"](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; }
|
|
25
|
-
|
|
26
|
-
const mergeToPrevState = (prevState, nextState) => _objectSpread(_objectSpread(_objectSpread({}, prevState), nextState), {}, {
|
|
27
|
-
prevProps: _objectSpread(_objectSpread({}, prevState.prevProps), nextState.prevProps)
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
function compareSelectedItems(nextProps, prevProps) {
|
|
31
|
-
const {
|
|
32
|
-
selectedItems,
|
|
33
|
-
idField
|
|
34
|
-
} = nextProps;
|
|
35
|
-
return nextState => {
|
|
36
|
-
if (dsUtilities.isEqual(selectedItems, prevProps.selectedItems)) return nextState; // if we are using nonSelectedItems skip this legacy logic and paint just what's passed
|
|
37
|
-
// to nonSelectedItems (source) and selectedItems (target)
|
|
38
|
-
// TODO make controlledV2 the default behavior for controlled shuttle
|
|
39
|
-
|
|
40
|
-
if (nextProps.nonSelectedItems) return nextState;
|
|
41
|
-
const {
|
|
42
|
-
preparedItems
|
|
43
|
-
} = nextState;
|
|
44
|
-
const prevSelectedItemsHash = dsUtilities.hashArray(prevProps.selectedItems || []);
|
|
45
|
-
const itemsToMove = helper.getItemsById(selectedItems, preparedItems);
|
|
46
|
-
const actions = itemsToMove.map(item => prevSelectedItemsHash[item[idField]] ? Shuttle_actions.addToTarget(item, nextState.targetItems) : Shuttle_actions.addToTarget(item));
|
|
47
|
-
return mergeToPrevState(nextState, _objectSpread(_objectSpread({}, helper.pipe([Shuttle_actions.resetMovedItems(), ...actions])(nextState, nextProps)), {}, {
|
|
48
|
-
prevProps: _objectSpread(_objectSpread({}, nextState.prevProps), {}, {
|
|
49
|
-
selectedItems
|
|
50
|
-
})
|
|
51
|
-
}));
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function compareItems(nextProps, prevProps) {
|
|
56
|
-
const {
|
|
57
|
-
items
|
|
58
|
-
} = nextProps;
|
|
59
|
-
return nextState => {
|
|
60
|
-
const preparedItems = helper.prepareItems(items);
|
|
61
|
-
const isControlledV2 = nextProps.nonSelectedItems; // TODO make controlledV2 the default behavior for controlled shuttle
|
|
62
|
-
|
|
63
|
-
if (isControlledV2) {
|
|
64
|
-
const targetItems = nextProps.selectedItems.map(id => preparedItems.find(it => it.id === id));
|
|
65
|
-
return mergeToPrevState(nextState, {
|
|
66
|
-
preparedItems,
|
|
67
|
-
// PUI-4462 on async load and items change, the shuttle loads
|
|
68
|
-
// all children from currently selected targetItems from items prop
|
|
69
|
-
// (items prop update)
|
|
70
|
-
targetItems,
|
|
71
|
-
movedItems: targetItems,
|
|
72
|
-
prevProps: {
|
|
73
|
-
items
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (dsUtilities.isEqual(items, prevProps.items)) return nextState;
|
|
79
|
-
return mergeToPrevState(nextState, {
|
|
80
|
-
preparedItems,
|
|
81
|
-
prevProps: {
|
|
82
|
-
items
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function updateShuttleStateFromProps (nextProps, prevState) {
|
|
89
|
-
const stateReducers = [compareSelectedItems, compareItems].map(fn => fn(nextProps, prevState.prevProps));
|
|
90
|
-
const nextState = dsUtilities.compose(...stateReducers)(prevState);
|
|
91
|
-
return !dsUtilities.isEqual(nextState, prevState) ? nextState : null;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
module.exports = updateShuttleStateFromProps;
|
package/cjs/utils.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
4
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
9
|
-
var tree = require('treetabular');
|
|
10
|
-
var dsUtilities = require('@elliemae/ds-utilities');
|
|
11
|
-
var helper = require('./helper.js');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
function _interopNamespace(e) {
|
|
16
|
-
if (e && e.__esModule) return e;
|
|
17
|
-
var n = Object.create(null);
|
|
18
|
-
if (e) {
|
|
19
|
-
Object.keys(e).forEach(function (k) {
|
|
20
|
-
if (k !== 'default') {
|
|
21
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return e[k]; }
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
n["default"] = e;
|
|
30
|
-
return Object.freeze(n);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
34
|
-
var tree__namespace = /*#__PURE__*/_interopNamespace(tree);
|
|
35
|
-
|
|
36
|
-
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; }
|
|
37
|
-
|
|
38
|
-
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__default["default"](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; }
|
|
39
|
-
var utils = _objectSpread({
|
|
40
|
-
prepareItems: (items, options) => dsUtilities.compose(tree__namespace.fixOrder(options), helper.prepareItems)(items)
|
|
41
|
-
}, tree__namespace);
|
|
42
|
-
|
|
43
|
-
module.exports = utils;
|
package/cjs/withProviders.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
4
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
5
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
9
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
10
|
-
require('react');
|
|
11
|
-
var AnimationState = require('./AnimationState.js');
|
|
12
|
-
var SearchState = require('./SearchState.js');
|
|
13
|
-
var ShuttleState = require('./ShuttleState.js');
|
|
14
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
-
|
|
18
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
19
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
20
|
-
|
|
21
|
-
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; }
|
|
22
|
-
|
|
23
|
-
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__default["default"](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; }
|
|
24
|
-
|
|
25
|
-
function withProviders(Component) {
|
|
26
|
-
return props => /*#__PURE__*/_jsx__default["default"](ShuttleState.Provider, {}, void 0, /*#__PURE__*/_jsx__default["default"](AnimationState.Provider, {}, void 0, /*#__PURE__*/_jsx__default["default"](SearchState.Provider, {}, void 0, /*#__PURE__*/jsxRuntime.jsx(Component, _objectSpread({}, props)))));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = withProviders;
|
package/esm/DSShuttle.js
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
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
|
-
}));
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const props = {
|
|
96
|
-
/** inject props to shuttle wrapper */
|
|
97
|
-
containerProps: PropTypes.object.description('inject props to shuttle wrapper'),
|
|
98
|
-
|
|
99
|
-
/** The identifier field for the item object */
|
|
100
|
-
idField: PropTypes.string.description('The identifier field for the item object'),
|
|
101
|
-
|
|
102
|
-
/** The parent identifier field for the item object */
|
|
103
|
-
parentIdField: PropTypes.string.description('The parent identifier field for the item object'),
|
|
104
|
-
|
|
105
|
-
/** Whether to show the icons or not */
|
|
106
|
-
showIcons: PropTypes.string.description('Whether to show the icons or not'),
|
|
107
|
-
|
|
108
|
-
/** List of items */
|
|
109
|
-
items: PropTypes.arrayOf(PropTypes.shape({
|
|
110
|
-
disableDrillDown: PropTypes.bool,
|
|
111
|
-
icon: PropTypes.element,
|
|
112
|
-
name: PropTypes.string,
|
|
113
|
-
readOnly: PropTypes.bool,
|
|
114
|
-
description: PropTypes.string
|
|
115
|
-
})).description('list of items'),
|
|
116
|
-
|
|
117
|
-
/** Array of item ids that are selected. If passed the component behaves as controlled */
|
|
118
|
-
selectedItems: PropTypes.arrayOf(PropTypes.string).description('Array of item ids that are selected. If passed the component behaves as controlled'),
|
|
119
|
-
|
|
120
|
-
/** Array of item ids that aren't selected. Should include ALL non selected items, even those not rendered */
|
|
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"),
|
|
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") */
|
|
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") */
|
|
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")'),
|
|
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 */
|
|
178
|
-
onAddCheckedItems: PropTypes.func.description("Handler when a users moves all the 'checked' items to the target"),
|
|
179
|
-
|
|
180
|
-
/** Handler when a user removes an item from the target */
|
|
181
|
-
onRemoveFromTarget: PropTypes.func.description('Handler when a user removes an item from the target'),
|
|
182
|
-
|
|
183
|
-
/** Handler when a user removes all the items from the target */
|
|
184
|
-
onRemoveAllFromTarget: PropTypes.func.description('Handler when a user removes all the items from the target'),
|
|
185
|
-
|
|
186
|
-
/** Handler for every change on the state */
|
|
187
|
-
onChange: PropTypes.func.description('Handler for every change on the state'),
|
|
188
|
-
|
|
189
|
-
/** Function that returns an element for the source counter */
|
|
190
|
-
renderSourceCounter: PropTypes.func.description('Function that returns an element for the source counter'),
|
|
191
|
-
|
|
192
|
-
/** Function that returns an element for the target counter */
|
|
193
|
-
renderTargetCounter: PropTypes.func.description('Function that returns an element for the target counter'),
|
|
194
|
-
|
|
195
|
-
/** Source text for the clear items button */
|
|
196
|
-
sourceClearItemsText: PropTypes.string.description('Source text for the clear items button'),
|
|
197
|
-
|
|
198
|
-
/** Target text for the clear items button */
|
|
199
|
-
targetClearItemsText: PropTypes.string.description('Target text for the clear items button'),
|
|
200
|
-
|
|
201
|
-
/** Searchbox placeholder */
|
|
202
|
-
searchPlaceholder: PropTypes.string.description('Searchbox placeholder'),
|
|
203
|
-
|
|
204
|
-
/** Displays loading indicator on source section */
|
|
205
|
-
loadingSource: PropTypes.bool.description('Displays loading indicator on source section'),
|
|
206
|
-
|
|
207
|
-
/** Displays loading indicator on target section */
|
|
208
|
-
loadingTarget: PropTypes.bool.description('Displays loading indicator on target section')
|
|
209
|
-
};
|
|
210
|
-
const DSShuttleWithSchema = describe(DSShuttle);
|
|
211
|
-
DSShuttleWithSchema.propTypes = props;
|
|
212
|
-
|
|
213
|
-
export { DSShuttleWithSchema, DSShuttle as default };
|
package/esm/SearchState.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import createContainer from 'constate';
|
|
4
|
-
|
|
5
|
-
function useSearchState() {
|
|
6
|
-
const [searchTerm, setSearchTerm] = useState('');
|
|
7
|
-
const [searching, setSearchBoxVisibility] = useState(false); // todo: create a hook for Visibility behavior
|
|
8
|
-
|
|
9
|
-
function toggleSearchBox(userVisible) {
|
|
10
|
-
if (userVisible !== undefined) {
|
|
11
|
-
setSearchBoxVisibility(userVisible);
|
|
12
|
-
} else {
|
|
13
|
-
setSearchBoxVisibility(!searching);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function reset() {
|
|
18
|
-
setSearchTerm('');
|
|
19
|
-
setSearchBoxVisibility(false);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
state: {
|
|
24
|
-
searchTerm,
|
|
25
|
-
searching
|
|
26
|
-
},
|
|
27
|
-
setSearchTerm,
|
|
28
|
-
toggleSearchBox,
|
|
29
|
-
reset
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var SearchState = createContainer(useSearchState, value => [value.state]);
|
|
34
|
-
|
|
35
|
-
export { SearchState as default };
|
package/esm/Shuttle.actions.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
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; }
|
|
15
|
-
function toggleItemSelection(itemId) {
|
|
16
|
-
return state => _objectSpread(_objectSpread({}, state), {}, {
|
|
17
|
-
checkedItems: addOrRemove(state.checkedItems, itemId)
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function navigateTo(item, dest) {
|
|
21
|
-
const hierarchyType = getHierarchyTypeName(dest);
|
|
22
|
-
return state => {
|
|
23
|
-
const indexInHierarchy = state[hierarchyType].findIndex(hItem => hItem.id === item.id);
|
|
24
|
-
const hierarchy = state[hierarchyType];
|
|
25
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
26
|
-
[hierarchyType]: indexInHierarchy !== -1 ? hierarchy.slice(0, indexInHierarchy + 1) : [...hierarchy, item]
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function moveItem(item) {
|
|
31
|
-
return state => {
|
|
32
|
-
const movedItems = toggleInObject(state.movedItems, item.id, item);
|
|
33
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
34
|
-
movedItems
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
const defaultOptions = {
|
|
39
|
-
parentField: 'parent',
|
|
40
|
-
idField: 'id',
|
|
41
|
-
op: hasMoved => !hasMoved
|
|
42
|
-
}; // todo: optimize this
|
|
43
|
-
|
|
44
|
-
function getItemDeep(_ref) {
|
|
45
|
-
let {
|
|
46
|
-
collection,
|
|
47
|
-
id,
|
|
48
|
-
options
|
|
49
|
-
} = _ref;
|
|
50
|
-
|
|
51
|
-
const {
|
|
52
|
-
idField
|
|
53
|
-
} = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
54
|
-
|
|
55
|
-
const itemIndex = collection.findIndex(fItem => fItem[idField] === id); // get item with nested children
|
|
56
|
-
|
|
57
|
-
const item = collection[itemIndex];
|
|
58
|
-
const children = item !== null && item !== void 0 && item.hasChildren ? compose(utils.getChildren({
|
|
59
|
-
index: itemIndex
|
|
60
|
-
}))(collection) || [] : [];
|
|
61
|
-
return {
|
|
62
|
-
item,
|
|
63
|
-
children
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function addToTarget(itemToAdd, collection) {
|
|
68
|
-
return (state, _ref2) => {
|
|
69
|
-
let {
|
|
70
|
-
idField
|
|
71
|
-
} = _ref2;
|
|
72
|
-
const items = collection || state.preparedItems;
|
|
73
|
-
const {
|
|
74
|
-
item,
|
|
75
|
-
children
|
|
76
|
-
} = getItemDeep({
|
|
77
|
-
collection: items,
|
|
78
|
-
id: itemToAdd[idField]
|
|
79
|
-
});
|
|
80
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
81
|
-
movedItems: [...state.movedItems, item],
|
|
82
|
-
targetItems: [...state.targetItems, item, ...children]
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
} // todo: optimize this
|
|
86
|
-
|
|
87
|
-
function removeFromTarget(itemToRemove) {
|
|
88
|
-
return (state, _ref3) => {
|
|
89
|
-
let {
|
|
90
|
-
idField
|
|
91
|
-
} = _ref3;
|
|
92
|
-
let targetItems = cloneDeep(state.targetItems);
|
|
93
|
-
const itemIndex = targetItems.findIndex(fItem => fItem.id === itemToRemove.id);
|
|
94
|
-
const item = targetItems[itemIndex];
|
|
95
|
-
const children = item !== null && item !== void 0 && item.hasChildren ? compose(filterMovedItems(state.movedItems), utils.getChildren({
|
|
96
|
-
index: itemIndex
|
|
97
|
-
}))(targetItems) || [] : [];
|
|
98
|
-
targetItems.splice(itemIndex, 1);
|
|
99
|
-
|
|
100
|
-
if (item !== null && item !== void 0 && item.hasChildren && children.length) {
|
|
101
|
-
const childrenHash = hashArray(children, 'id');
|
|
102
|
-
targetItems = targetItems.filter(i => !childrenHash[i.id]);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return _objectSpread(_objectSpread({}, state), {}, {
|
|
106
|
-
movedItems: state.movedItems.filter(mItem => mItem[idField] !== itemToRemove[idField]),
|
|
107
|
-
targetItems
|
|
108
|
-
});
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function resetCheckedItems() {
|
|
112
|
-
return state => _objectSpread(_objectSpread({}, state), {}, {
|
|
113
|
-
checkedItems: []
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
function resetMovedItems() {
|
|
117
|
-
return state => _objectSpread(_objectSpread({}, state), {}, {
|
|
118
|
-
movedItems: [],
|
|
119
|
-
targetItems: []
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export { addToTarget, moveItem, navigateTo, removeFromTarget, resetCheckedItems, resetMovedItems, toggleItemSelection };
|
package/esm/ShuttleContainer.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
2
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
3
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
6
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
7
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
8
|
-
import { useContext, useMemo } from 'react';
|
|
9
|
-
import { compose, sortBy, uniqBy, values, isFunction } from '@elliemae/ds-utilities';
|
|
10
|
-
import withProviders from './withProviders.js';
|
|
11
|
-
import { filterItemsByHierarchy, getActiveIdFromHierarchy, prepareItems, getItemsById } from './helper.js';
|
|
12
|
-
import SearchState from './SearchState.js';
|
|
13
|
-
import useShuttleState from './ShuttleState.js';
|
|
14
|
-
|
|
15
|
-
const _excluded = ["state"];
|
|
16
|
-
|
|
17
|
-
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; }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
function filterItemsByTerm(items, term) {
|
|
22
|
-
return items.filter(item => item.name.toLowerCase().indexOf(String(term).toLowerCase()) !== -1 || String(item.id).indexOf(String(term).toLowerCase()) !== -1);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function ShuttleContainer(_ref) {
|
|
26
|
-
let {
|
|
27
|
-
items = [],
|
|
28
|
-
children
|
|
29
|
-
} = _ref;
|
|
30
|
-
|
|
31
|
-
const _useContext = useContext(useShuttleState.Context),
|
|
32
|
-
{
|
|
33
|
-
state: shuttleState
|
|
34
|
-
} = _useContext,
|
|
35
|
-
handlers = _objectWithoutProperties(_useContext, _excluded);
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
state: searchState
|
|
39
|
-
} = useContext(SearchState.Context);
|
|
40
|
-
|
|
41
|
-
const {
|
|
42
|
-
movedItems,
|
|
43
|
-
hierarchy,
|
|
44
|
-
hierarchyDest,
|
|
45
|
-
checkedItems,
|
|
46
|
-
searchTerm,
|
|
47
|
-
searching,
|
|
48
|
-
toggleItemSelection,
|
|
49
|
-
resetCheckedItems,
|
|
50
|
-
resetMovedItems,
|
|
51
|
-
moveCheckedItems,
|
|
52
|
-
moveItem,
|
|
53
|
-
navigate
|
|
54
|
-
} = _objectSpread(_objectSpread(_objectSpread({}, shuttleState), searchState), handlers);
|
|
55
|
-
|
|
56
|
-
const sourceItems = useMemo(() => compose(items => items.filter(item => !movedItems[item.id]), items => searchTerm && searching ? filterItemsByTerm(items, searchTerm) : items, items => filterItemsByHierarchy(items, getActiveIdFromHierarchy(hierarchy).id), items => prepareItems(items))(items), [items, searchTerm, searching, hierarchy, movedItems]);
|
|
57
|
-
const targetItems = useMemo(() => {
|
|
58
|
-
const hierarchyId = getActiveIdFromHierarchy(hierarchyDest).id;
|
|
59
|
-
return compose(items => sortBy(items, ['name']), items => hierarchyId ? filterItemsByHierarchy(items, hierarchyId).filter(item => !movedItems[item.id]) : uniqBy(values(movedItems), 'id'))(items);
|
|
60
|
-
}, [items, searching, hierarchyDest, movedItems]);
|
|
61
|
-
return isFunction(children) && children({
|
|
62
|
-
checkedItems,
|
|
63
|
-
hierarchy,
|
|
64
|
-
hierarchyDest,
|
|
65
|
-
onCheckItem: toggleItemSelection,
|
|
66
|
-
onClearCheckedItems: resetCheckedItems,
|
|
67
|
-
onClearMovedItems: resetMovedItems,
|
|
68
|
-
onMoveCheckedItems: () => moveCheckedItems(getItemsById(checkedItems, items)),
|
|
69
|
-
onMoveItemToSource: item => moveItem(item, false),
|
|
70
|
-
onMoveItemToTarget: item => moveItem(item, true),
|
|
71
|
-
onNavigateOnSourceTo: item => navigate(item, false),
|
|
72
|
-
onNavigateOnTargetTo: item => navigate(item, true),
|
|
73
|
-
sourceItems,
|
|
74
|
-
targetItems
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var ShuttleContainer$1 = withProviders(ShuttleContainer);
|
|
79
|
-
|
|
80
|
-
export { ShuttleContainer$1 as default };
|