@elliemae/ds-shuttle 2.2.0-alpha.4 → 3.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/AnimationState.js +19 -46
- package/cjs/DSShuttle.js +219 -166
- package/cjs/SearchState.js +25 -44
- package/cjs/Shuttle.actions.js +98 -87
- package/cjs/ShuttleContainer.js +61 -56
- package/cjs/ShuttleImpl.js +206 -109
- package/cjs/ShuttleRenderer.js +135 -140
- package/cjs/ShuttleState.js +53 -57
- package/cjs/animation/animationConfig.js +56 -53
- package/cjs/classedComponents.js +69 -70
- package/cjs/components/LoadingIndicator.js +22 -49
- package/cjs/components/OverflowList.js +48 -50
- package/cjs/components/ShuttleBreadcrumb.js +40 -52
- package/cjs/components/ShuttleInfiniteScrollIndicator.js +37 -46
- package/cjs/components/ShuttleListItem/ActionButtons.js +51 -56
- package/cjs/components/ShuttleListItem/ShuttleListItem.js +80 -78
- package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +64 -78
- package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +56 -72
- package/cjs/components/ShuttleListPanel.js +26 -44
- package/cjs/components/ShuttleSearchBox.js +72 -61
- package/cjs/components/ShuttleSource.js +146 -150
- package/cjs/components/ShuttleTarget.js +100 -88
- package/cjs/components/VirtualizedItem.js +40 -45
- package/cjs/components/VirtualizedList.js +86 -81
- package/cjs/components/VirtualizedSortableList.js +40 -47
- package/cjs/helper.js +103 -69
- package/cjs/index.js +12 -38
- package/cjs/updateShuttleStateFromProps.js +69 -73
- package/cjs/utils.js +42 -40
- package/cjs/withProviders.js +27 -43
- package/esm/AnimationState.js +8 -12
- package/esm/DSShuttle.js +198 -126
- package/esm/SearchState.js +19 -15
- package/esm/Shuttle.actions.js +80 -63
- package/esm/ShuttleContainer.js +50 -34
- package/esm/ShuttleImpl.js +183 -78
- package/esm/ShuttleRenderer.js +128 -111
- package/esm/ShuttleState.js +53 -34
- package/esm/animation/animationConfig.js +52 -24
- package/esm/classedComponents.js +51 -43
- package/esm/components/LoadingIndicator.js +15 -20
- package/esm/components/OverflowList.js +41 -21
- package/esm/components/ShuttleBreadcrumb.js +33 -23
- package/esm/components/ShuttleInfiniteScrollIndicator.js +31 -18
- package/esm/components/ShuttleListItem/ActionButtons.js +39 -27
- package/esm/components/ShuttleListItem/ShuttleListItem.js +72 -50
- package/esm/components/ShuttleListItem/ShuttleSourceListItem.js +52 -45
- package/esm/components/ShuttleListItem/ShuttleTargetListItem.js +47 -42
- package/esm/components/ShuttleListPanel.js +19 -15
- package/esm/components/ShuttleSearchBox.js +66 -32
- package/esm/components/ShuttleSource.js +129 -125
- package/esm/components/ShuttleTarget.js +89 -68
- package/esm/components/VirtualizedItem.js +33 -15
- package/esm/components/VirtualizedList.js +75 -50
- package/esm/components/VirtualizedSortableList.js +32 -17
- package/esm/helper.js +67 -43
- package/esm/index.js +2 -9
- package/esm/updateShuttleStateFromProps.js +58 -39
- package/esm/utils.js +18 -12
- package/esm/withProviders.js +20 -14
- package/package.json +11 -11
- package/types/AnimationState.d.ts +2 -3
- package/types/DSShuttle.d.ts +1 -1
- package/types/SearchState.d.ts +2 -3
- package/types/ShuttleImpl.d.ts +2 -3
- package/types/ShuttleRenderer.d.ts +0 -1
- package/types/ShuttleState.d.ts +2 -3
- package/types/components/LoadingIndicator.d.ts +0 -1
- package/types/components/OverflowList.d.ts +0 -1
- package/types/components/ShuttleBreadcrumb.d.ts +0 -1
- package/types/components/ShuttleInfiniteScrollIndicator.d.ts +0 -1
- package/types/components/ShuttleListItem/ShuttleListItem.d.ts +0 -1
- package/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +0 -1
- package/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +0 -1
- package/types/components/ShuttleListPanel.d.ts +0 -1
- package/types/components/ShuttleSearchBox.d.ts +1 -3
- package/types/components/ShuttleSource.d.ts +0 -1
- package/types/components/ShuttleTarget.d.ts +0 -1
- package/types/components/VirtualizedItem.d.ts +0 -1
- package/types/components/VirtualizedList.d.ts +0 -1
- package/types/components/VirtualizedSortableList.d.ts +0 -1
- package/types/index.d.ts +1 -1
- package/types/updateShuttleStateFromProps.d.ts +1 -3
- package/types/withProviders.d.ts +0 -1
- package/cjs/AnimationState.js.map +0 -7
- package/cjs/DSShuttle.js.map +0 -7
- package/cjs/SearchState.js.map +0 -7
- package/cjs/Shuttle.actions.js.map +0 -7
- package/cjs/ShuttleContainer.js.map +0 -7
- package/cjs/ShuttleImpl.js.map +0 -7
- package/cjs/ShuttleRenderer.js.map +0 -7
- package/cjs/ShuttleState.js.map +0 -7
- package/cjs/animation/animationConfig.js.map +0 -7
- package/cjs/classedComponents.js.map +0 -7
- package/cjs/components/LoadingIndicator.js.map +0 -7
- package/cjs/components/OverflowList.js.map +0 -7
- package/cjs/components/ShuttleBreadcrumb.js.map +0 -7
- package/cjs/components/ShuttleInfiniteScrollIndicator.js.map +0 -7
- package/cjs/components/ShuttleListItem/ActionButtons.js.map +0 -7
- package/cjs/components/ShuttleListItem/ShuttleListItem.js.map +0 -7
- package/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -7
- package/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -7
- package/cjs/components/ShuttleListPanel.js.map +0 -7
- package/cjs/components/ShuttleSearchBox.js.map +0 -7
- package/cjs/components/ShuttleSource.js.map +0 -7
- package/cjs/components/ShuttleTarget.js.map +0 -7
- package/cjs/components/VirtualizedItem.js.map +0 -7
- package/cjs/components/VirtualizedList.js.map +0 -7
- package/cjs/components/VirtualizedSortableList.js.map +0 -7
- package/cjs/helper.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/tests/utils.js +0 -1218
- package/cjs/tests/utils.js.map +0 -7
- package/cjs/updateShuttleStateFromProps.js.map +0 -7
- package/cjs/utils.js.map +0 -7
- package/cjs/withProviders.js.map +0 -7
- package/esm/AnimationState.js.map +0 -7
- package/esm/DSShuttle.js.map +0 -7
- package/esm/SearchState.js.map +0 -7
- package/esm/Shuttle.actions.js.map +0 -7
- package/esm/ShuttleContainer.js.map +0 -7
- package/esm/ShuttleImpl.js.map +0 -7
- package/esm/ShuttleRenderer.js.map +0 -7
- package/esm/ShuttleState.js.map +0 -7
- package/esm/animation/animationConfig.js.map +0 -7
- package/esm/classedComponents.js.map +0 -7
- package/esm/components/LoadingIndicator.js.map +0 -7
- package/esm/components/OverflowList.js.map +0 -7
- package/esm/components/ShuttleBreadcrumb.js.map +0 -7
- package/esm/components/ShuttleInfiniteScrollIndicator.js.map +0 -7
- package/esm/components/ShuttleListItem/ActionButtons.js.map +0 -7
- package/esm/components/ShuttleListItem/ShuttleListItem.js.map +0 -7
- package/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +0 -7
- package/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +0 -7
- package/esm/components/ShuttleListPanel.js.map +0 -7
- package/esm/components/ShuttleSearchBox.js.map +0 -7
- package/esm/components/ShuttleSource.js.map +0 -7
- package/esm/components/ShuttleTarget.js.map +0 -7
- package/esm/components/VirtualizedItem.js.map +0 -7
- package/esm/components/VirtualizedList.js.map +0 -7
- package/esm/components/VirtualizedSortableList.js.map +0 -7
- package/esm/helper.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/tests/utils.js +0 -1189
- package/esm/tests/utils.js.map +0 -7
- package/esm/updateShuttleStateFromProps.js.map +0 -7
- package/esm/utils.js.map +0 -7
- package/esm/withProviders.js.map +0 -7
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import { memo } from 'react';
|
|
8
|
+
import { areEqual } from 'react-window';
|
|
9
|
+
|
|
10
|
+
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; }
|
|
11
|
+
|
|
12
|
+
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; }
|
|
13
|
+
const VirtualizedItem = /*#__PURE__*/memo(_ref => {
|
|
14
|
+
let {
|
|
15
|
+
data,
|
|
16
|
+
index,
|
|
17
|
+
style: virtualizedStyles,
|
|
18
|
+
showSortHandler = false
|
|
19
|
+
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
items,
|
|
22
|
+
itemRenderer,
|
|
23
|
+
isItemMoving
|
|
24
|
+
} = data;
|
|
25
|
+
const {
|
|
26
|
+
item,
|
|
27
|
+
props: animatedStyles,
|
|
28
|
+
key
|
|
29
|
+
} = items[index] || {};
|
|
30
|
+
if (!item) return null;
|
|
9
31
|
return itemRenderer({
|
|
10
32
|
index,
|
|
11
33
|
key,
|
|
12
34
|
item,
|
|
13
35
|
showSortHandler,
|
|
14
|
-
style: isItemMoving ? {
|
|
36
|
+
style: isItemMoving ? _objectSpread(_objectSpread({}, animatedStyles), virtualizedStyles) : virtualizedStyles
|
|
15
37
|
});
|
|
16
38
|
}, areEqual);
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
VirtualizedItem,
|
|
20
|
-
VirtualizedItem_default as default
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=VirtualizedItem.js.map
|
|
39
|
+
|
|
40
|
+
export { VirtualizedItem as default };
|
|
@@ -1,59 +1,84 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}) {
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import { useRef, useContext, useEffect } from 'react';
|
|
9
|
+
import { useTransition } from 'react-spring/web';
|
|
10
|
+
import { FixedSizeList } from 'react-window';
|
|
11
|
+
import InfiniteLoader from 'react-window-infinite-loader';
|
|
12
|
+
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
13
|
+
import { animationConfig } from '../animation/animationConfig.js';
|
|
14
|
+
import AnimationContext from '../AnimationState.js';
|
|
15
|
+
import VirtualizedItem from './VirtualizedItem.js';
|
|
16
|
+
import { jsx } from 'react/jsx-runtime';
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
22
|
+
function VirtualizedList(_ref) {
|
|
23
|
+
let {
|
|
24
|
+
items,
|
|
25
|
+
itemRenderer,
|
|
26
|
+
searching,
|
|
27
|
+
target = false,
|
|
28
|
+
innerRef,
|
|
29
|
+
children,
|
|
30
|
+
hasNextPage = true,
|
|
31
|
+
getMoreItems = () => {}
|
|
32
|
+
} = _ref;
|
|
21
33
|
const hasMounted = useRef(false);
|
|
22
34
|
const {
|
|
23
|
-
state: {
|
|
35
|
+
state: {
|
|
36
|
+
isMoving,
|
|
37
|
+
isMovingBack
|
|
38
|
+
},
|
|
24
39
|
reset
|
|
25
|
-
} = useContext(
|
|
40
|
+
} = useContext(AnimationContext.Context);
|
|
26
41
|
useEffect(() => {
|
|
27
42
|
hasMounted.current = true;
|
|
28
43
|
}, []);
|
|
29
|
-
const transitions = useTransition(items,
|
|
30
|
-
...animationConfig.moveItem(target),
|
|
44
|
+
const transitions = useTransition(items, item => item.id, _objectSpread(_objectSpread({}, animationConfig.moveItem(target)), {}, {
|
|
31
45
|
onDestroyed: () => reset()
|
|
32
|
-
});
|
|
46
|
+
}));
|
|
33
47
|
const itemCount = hasNextPage ? items.length + 1 : items.length;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
|
|
49
|
+
const isItemLoaded = index => !hasNextPage || index < items.length;
|
|
50
|
+
|
|
51
|
+
return /*#__PURE__*/_jsx(AutoSizer, {}, void 0, _ref2 => {
|
|
52
|
+
let {
|
|
53
|
+
height,
|
|
54
|
+
width
|
|
55
|
+
} = _ref2;
|
|
56
|
+
return /*#__PURE__*/_jsx(InfiniteLoader, {
|
|
57
|
+
isItemLoaded: isItemLoaded,
|
|
58
|
+
itemCount: itemCount,
|
|
59
|
+
loadMoreItems: getMoreItems
|
|
60
|
+
}, void 0, _ref3 => {
|
|
61
|
+
let {
|
|
62
|
+
onItemsRendered,
|
|
63
|
+
ref
|
|
64
|
+
} = _ref3;
|
|
65
|
+
return /*#__PURE__*/jsx(FixedSizeList, {
|
|
66
|
+
height: searching ? 300 : height,
|
|
67
|
+
width: width,
|
|
68
|
+
innerRef: innerRef,
|
|
69
|
+
itemCount: transitions.length,
|
|
70
|
+
itemData: {
|
|
71
|
+
items: transitions,
|
|
72
|
+
itemRenderer,
|
|
73
|
+
isItemMoving: hasMounted.current && (isMoving || isMovingBack)
|
|
74
|
+
},
|
|
75
|
+
itemSize: 35,
|
|
76
|
+
onItemsRendered: onItemsRendered,
|
|
77
|
+
ref: ref,
|
|
78
|
+
children: children || VirtualizedItem
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
53
82
|
}
|
|
54
|
-
|
|
55
|
-
export {
|
|
56
|
-
VirtualizedList,
|
|
57
|
-
VirtualizedList_default as default
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=VirtualizedList.js.map
|
|
83
|
+
|
|
84
|
+
export { VirtualizedList as default };
|
|
@@ -1,19 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
8
|
+
import 'react';
|
|
9
|
+
import { sortableContainer, sortableElement } from 'react-sortable-hoc';
|
|
10
|
+
import VirtualizedList from './VirtualizedList.js';
|
|
11
|
+
import VirtualizedItem from './VirtualizedItem.js';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
const _excluded = ["items"];
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
6
19
|
const SortableList = sortableContainer(VirtualizedList);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
items
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
|
|
21
|
+
function VirtualizedSortableList(_ref) {
|
|
22
|
+
let {
|
|
23
|
+
items
|
|
24
|
+
} = _ref,
|
|
25
|
+
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
26
|
+
|
|
27
|
+
return /*#__PURE__*/jsx(SortableList, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
28
|
+
items: items,
|
|
29
|
+
useDragHandle: true,
|
|
30
|
+
children: sortableElement(VirtualizedItem)
|
|
31
|
+
}));
|
|
13
32
|
}
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
VirtualizedSortableList,
|
|
17
|
-
VirtualizedSortableList_default as default
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=VirtualizedSortableList.js.map
|
|
33
|
+
|
|
34
|
+
export { VirtualizedSortableList as default };
|
package/esm/helper.js
CHANGED
|
@@ -1,54 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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/esnext.async-iterator.some.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
+
import 'core-js/modules/esnext.iterator.some.js';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.reduce.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.reduce.js';
|
|
11
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
12
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
13
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
14
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
15
|
+
import { omit, compose, hashArray } from '@elliemae/ds-utilities';
|
|
16
|
+
import * as tree from 'treetabular';
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
const getHierarchyTypeName = dest => !dest ? 'hierarchy' : 'hierarchyDest';
|
|
22
|
+
const checkHasChildren = (list, currentItem) => list.some(item => currentItem.id === item.parent);
|
|
23
|
+
const getActiveIdFromHierarchy = function () {
|
|
24
|
+
let hierarchy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
25
|
+
return hierarchy[hierarchy.length - 1] || {};
|
|
17
26
|
};
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
const filterItemsByHierarchy = function (list, hierarchyId) {
|
|
28
|
+
let parentField = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'parent';
|
|
29
|
+
return list.filter(item => item[parentField] === hierarchyId);
|
|
30
|
+
};
|
|
31
|
+
const getItemsById = (ids, list) => ids.reduce((acc, id) => acc.concat(list.find(item => String(item.id) === String(id))), []).filter(item => item);
|
|
32
|
+
const toggleInObject = (obj, key, value) => obj[key] ? omit(obj, [key]) : _objectSpread(_objectSpread({}, obj), {}, {
|
|
33
|
+
[key]: value
|
|
34
|
+
});
|
|
35
|
+
const isMovable = item => !item.forceNotMovable && (item.hasChildren && item.isMoveableContainer || !item.hasChildren); // utility to execute all specified actions in sequence
|
|
36
|
+
|
|
37
|
+
const pipe = actions => (initState, props) => actions.reduce((prevState, action) => action(prevState, props), initState);
|
|
38
|
+
const moveItems = _ref => {
|
|
39
|
+
let {
|
|
40
|
+
oldIndex,
|
|
41
|
+
newIndex
|
|
42
|
+
} = _ref;
|
|
43
|
+
return items => {
|
|
44
|
+
const sourceItem = items[oldIndex];
|
|
45
|
+
items.splice(oldIndex, 1);
|
|
46
|
+
items.splice(newIndex, 0, sourceItem);
|
|
47
|
+
return items;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
const prepareItems = items => compose(tree.fixOrder(), items => items.map(item => _objectSpread(_objectSpread({}, item), {}, {
|
|
51
|
+
hasChildren: checkHasChildren(items, item)
|
|
21
52
|
})))(items);
|
|
22
53
|
const defaultOptions = {
|
|
23
|
-
parentField:
|
|
24
|
-
idField:
|
|
25
|
-
op:
|
|
54
|
+
parentField: 'parent',
|
|
55
|
+
idField: 'id',
|
|
56
|
+
op: hasMoved => !hasMoved
|
|
26
57
|
};
|
|
27
58
|
function getChildrenFromParent(parentId, options) {
|
|
28
|
-
const {
|
|
29
|
-
|
|
59
|
+
const {
|
|
60
|
+
parentField
|
|
61
|
+
} = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
62
|
+
|
|
63
|
+
return items => items.filter(item => item[parentField] === parentId);
|
|
30
64
|
}
|
|
31
65
|
function filterMovedItems(movedItems, options) {
|
|
32
|
-
const {
|
|
66
|
+
const {
|
|
67
|
+
idField,
|
|
68
|
+
op: filterOp
|
|
69
|
+
} = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
70
|
+
|
|
33
71
|
const movedItemsHash = hashArray(movedItems, idField);
|
|
34
|
-
return
|
|
72
|
+
return items => items.filter(item => filterOp(!!movedItemsHash[item[idField]]));
|
|
35
73
|
}
|
|
36
74
|
function filterBySearch(term, searching) {
|
|
37
|
-
return
|
|
75
|
+
return items => searching ? items.filter(item => item.name.toLowerCase().indexOf(String(term).toLowerCase()) !== -1) : items;
|
|
38
76
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
filterBySearch,
|
|
42
|
-
filterItemsByHierarchy,
|
|
43
|
-
filterMovedItems,
|
|
44
|
-
getActiveIdFromHierarchy,
|
|
45
|
-
getChildrenFromParent,
|
|
46
|
-
getHierarchyTypeName,
|
|
47
|
-
getItemsById,
|
|
48
|
-
isMovable,
|
|
49
|
-
moveItems,
|
|
50
|
-
pipe,
|
|
51
|
-
prepareItems,
|
|
52
|
-
toggleInObject
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=helper.js.map
|
|
77
|
+
|
|
78
|
+
export { checkHasChildren, filterBySearch, filterItemsByHierarchy, filterMovedItems, getActiveIdFromHierarchy, getChildrenFromParent, getHierarchyTypeName, getItemsById, isMovable, moveItems, pipe, prepareItems, toggleInObject };
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
DSShuttle,
|
|
5
|
-
DSShuttleWithSchema,
|
|
6
|
-
default2 as default,
|
|
7
|
-
utils
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DSShuttleWithSchema, default } from './DSShuttle.js';
|
|
2
|
+
export { default as utils } from './utils.js';
|
|
@@ -1,44 +1,66 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
6
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
7
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
10
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
12
|
+
import { compose, isEqual, hashArray } from '@elliemae/ds-utilities';
|
|
13
|
+
import { getItemsById, pipe, prepareItems } from './helper.js';
|
|
14
|
+
import { addToTarget, resetMovedItems } from './Shuttle.actions.js';
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
18
|
+
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; }
|
|
19
|
+
|
|
20
|
+
const mergeToPrevState = (prevState, nextState) => _objectSpread(_objectSpread(_objectSpread({}, prevState), nextState), {}, {
|
|
21
|
+
prevProps: _objectSpread(_objectSpread({}, prevState.prevProps), nextState.prevProps)
|
|
12
22
|
});
|
|
23
|
+
|
|
13
24
|
function compareSelectedItems(nextProps, prevProps) {
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
25
|
+
const {
|
|
26
|
+
selectedItems,
|
|
27
|
+
idField
|
|
28
|
+
} = nextProps;
|
|
29
|
+
return nextState => {
|
|
30
|
+
if (isEqual(selectedItems, prevProps.selectedItems)) return nextState; // if we are using nonSelectedItems skip this legacy logic and paint just what's passed
|
|
31
|
+
// to nonSelectedItems (source) and selectedItems (target)
|
|
32
|
+
// TODO make controlledV2 the default behavior for controlled shuttle
|
|
33
|
+
|
|
34
|
+
if (nextProps.nonSelectedItems) return nextState;
|
|
35
|
+
const {
|
|
36
|
+
preparedItems
|
|
37
|
+
} = nextState;
|
|
21
38
|
const prevSelectedItemsHash = hashArray(prevProps.selectedItems || []);
|
|
22
39
|
const itemsToMove = getItemsById(selectedItems, preparedItems);
|
|
23
|
-
const actions = itemsToMove.map(
|
|
24
|
-
return mergeToPrevState(nextState, {
|
|
25
|
-
|
|
26
|
-
prevProps: {
|
|
27
|
-
...nextState.prevProps,
|
|
40
|
+
const actions = itemsToMove.map(item => prevSelectedItemsHash[item[idField]] ? addToTarget(item, nextState.targetItems) : addToTarget(item));
|
|
41
|
+
return mergeToPrevState(nextState, _objectSpread(_objectSpread({}, pipe([resetMovedItems(), ...actions])(nextState, nextProps)), {}, {
|
|
42
|
+
prevProps: _objectSpread(_objectSpread({}, nextState.prevProps), {}, {
|
|
28
43
|
selectedItems
|
|
29
|
-
}
|
|
30
|
-
});
|
|
44
|
+
})
|
|
45
|
+
}));
|
|
31
46
|
};
|
|
32
47
|
}
|
|
48
|
+
|
|
33
49
|
function compareItems(nextProps, prevProps) {
|
|
34
|
-
const {
|
|
35
|
-
|
|
50
|
+
const {
|
|
51
|
+
items
|
|
52
|
+
} = nextProps;
|
|
53
|
+
return nextState => {
|
|
36
54
|
const preparedItems = prepareItems(items);
|
|
37
|
-
const isControlledV2 = nextProps.nonSelectedItems;
|
|
55
|
+
const isControlledV2 = nextProps.nonSelectedItems; // TODO make controlledV2 the default behavior for controlled shuttle
|
|
56
|
+
|
|
38
57
|
if (isControlledV2) {
|
|
39
|
-
const targetItems = nextProps.selectedItems.map(
|
|
58
|
+
const targetItems = nextProps.selectedItems.map(id => preparedItems.find(it => it.id === id));
|
|
40
59
|
return mergeToPrevState(nextState, {
|
|
41
60
|
preparedItems,
|
|
61
|
+
// PUI-4462 on async load and items change, the shuttle loads
|
|
62
|
+
// all children from currently selected targetItems from items prop
|
|
63
|
+
// (items prop update)
|
|
42
64
|
targetItems,
|
|
43
65
|
movedItems: targetItems,
|
|
44
66
|
prevProps: {
|
|
@@ -46,8 +68,8 @@ function compareItems(nextProps, prevProps) {
|
|
|
46
68
|
}
|
|
47
69
|
});
|
|
48
70
|
}
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
|
|
72
|
+
if (isEqual(items, prevProps.items)) return nextState;
|
|
51
73
|
return mergeToPrevState(nextState, {
|
|
52
74
|
preparedItems,
|
|
53
75
|
prevProps: {
|
|
@@ -56,14 +78,11 @@ function compareItems(nextProps, prevProps) {
|
|
|
56
78
|
});
|
|
57
79
|
};
|
|
58
80
|
}
|
|
59
|
-
|
|
60
|
-
|
|
81
|
+
|
|
82
|
+
function updateShuttleStateFromProps (nextProps, prevState) {
|
|
83
|
+
const stateReducers = [compareSelectedItems, compareItems].map(fn => fn(nextProps, prevState.prevProps));
|
|
61
84
|
const nextState = compose(...stateReducers)(prevState);
|
|
62
85
|
return !isEqual(nextState, prevState) ? nextState : null;
|
|
63
86
|
}
|
|
64
|
-
|
|
65
|
-
export {
|
|
66
|
-
updateShuttleStateFromProps_default as default,
|
|
67
|
-
updateShuttleStateFromProps
|
|
68
|
-
};
|
|
69
|
-
//# sourceMappingURL=updateShuttleStateFromProps.js.map
|
|
87
|
+
|
|
88
|
+
export { updateShuttleStateFromProps as default };
|
package/esm/utils.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import * as tree from 'treetabular';
|
|
8
|
+
import { compose } from '@elliemae/ds-utilities';
|
|
9
|
+
import { prepareItems } from './helper.js';
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
var utils = _objectSpread({
|
|
15
|
+
prepareItems: (items, options) => compose(tree.fixOrder(options), prepareItems)(items)
|
|
16
|
+
}, tree);
|
|
17
|
+
|
|
18
|
+
export { utils as default };
|
package/esm/withProviders.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import 'react';
|
|
9
|
+
import AnimationContext from './AnimationState.js';
|
|
10
|
+
import SearchState from './SearchState.js';
|
|
11
|
+
import useShuttleState from './ShuttleState.js';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
|
|
16
|
+
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; }
|
|
17
|
+
|
|
6
18
|
function withProviders(Component) {
|
|
7
|
-
return
|
|
8
|
-
...props
|
|
9
|
-
}))));
|
|
19
|
+
return props => /*#__PURE__*/_jsx(useShuttleState.Provider, {}, void 0, /*#__PURE__*/_jsx(AnimationContext.Provider, {}, void 0, /*#__PURE__*/_jsx(SearchState.Provider, {}, void 0, /*#__PURE__*/jsx(Component, _objectSpread({}, props)))));
|
|
10
20
|
}
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
withProviders_default as default,
|
|
14
|
-
withProviders
|
|
15
|
-
};
|
|
16
|
-
//# sourceMappingURL=withProviders.js.map
|
|
21
|
+
|
|
22
|
+
export { withProviders as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliemae/ds-shuttle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-next.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "ICE MT - Dimsum - Shuttle",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -152,16 +152,16 @@
|
|
|
152
152
|
"build": "node ../../scripts/build/build.js"
|
|
153
153
|
},
|
|
154
154
|
"dependencies": {
|
|
155
|
-
"@elliemae/ds-basic": "
|
|
156
|
-
"@elliemae/ds-button": "
|
|
157
|
-
"@elliemae/ds-circular-progress-indicator": "
|
|
158
|
-
"@elliemae/ds-classnames": "
|
|
159
|
-
"@elliemae/ds-form": "
|
|
160
|
-
"@elliemae/ds-icons": "
|
|
161
|
-
"@elliemae/ds-indeterminate-progress-indicator": "
|
|
162
|
-
"@elliemae/ds-system": "
|
|
163
|
-
"@elliemae/ds-truncated-tooltip-text": "
|
|
164
|
-
"@elliemae/ds-utilities": "
|
|
155
|
+
"@elliemae/ds-basic": "3.0.0-next.2",
|
|
156
|
+
"@elliemae/ds-button": "3.0.0-next.2",
|
|
157
|
+
"@elliemae/ds-circular-progress-indicator": "3.0.0-next.2",
|
|
158
|
+
"@elliemae/ds-classnames": "3.0.0-next.2",
|
|
159
|
+
"@elliemae/ds-form": "3.0.0-next.2",
|
|
160
|
+
"@elliemae/ds-icons": "3.0.0-next.2",
|
|
161
|
+
"@elliemae/ds-indeterminate-progress-indicator": "3.0.0-next.2",
|
|
162
|
+
"@elliemae/ds-system": "3.0.0-next.2",
|
|
163
|
+
"@elliemae/ds-truncated-tooltip-text": "3.0.0-next.2",
|
|
164
|
+
"@elliemae/ds-utilities": "3.0.0-next.2",
|
|
165
165
|
"constate": "~1.3.2",
|
|
166
166
|
"prop-types": "~15.7.2",
|
|
167
167
|
"react-desc": "~4.1.3",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
1
|
+
declare const _default: import("constate/dist/ts/src/types").ContextHookReturn<unknown, {
|
|
2
2
|
state: {
|
|
3
3
|
isMoving: boolean;
|
|
4
4
|
isMovingBack: boolean;
|
|
@@ -23,5 +23,4 @@ declare const AnimationState: import("constate/dist/ts/src/types").ContextHookRe
|
|
|
23
23
|
isMovingBack: boolean;
|
|
24
24
|
isDrillingDown: boolean;
|
|
25
25
|
}[]]>;
|
|
26
|
-
export
|
|
27
|
-
export default AnimationState;
|
|
26
|
+
export default _default;
|
package/types/DSShuttle.d.ts
CHANGED