@elliemae/ds-shuttle 2.2.0 → 2.3.0-alpha.3
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 +1 -1
- 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
|
@@ -1,107 +1,86 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
composeTargetItemProps = () => ({}),
|
|
39
|
-
targetSortable = false,
|
|
40
|
-
onSortEnd = noop,
|
|
41
|
-
targetClearItemsText = 'CLEAR ALL',
|
|
42
|
-
renderTargetCounter = amount => "".concat(amount, " items"),
|
|
43
|
-
loading = false
|
|
44
|
-
} = _ref;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useContext } from "react";
|
|
3
|
+
import { DSButton } from "@elliemae/ds-button";
|
|
4
|
+
import {
|
|
5
|
+
EmptyMessage,
|
|
6
|
+
Overflow,
|
|
7
|
+
ShuttleFooter,
|
|
8
|
+
ShuttleFooterActions,
|
|
9
|
+
ShuttleFooterCounter,
|
|
10
|
+
ShuttleHeader,
|
|
11
|
+
ShuttleHeaderBreadcrumb,
|
|
12
|
+
ShuttleList,
|
|
13
|
+
ShuttleWrapper,
|
|
14
|
+
LoadingList
|
|
15
|
+
} from "../classedComponents";
|
|
16
|
+
import { getActiveIdFromHierarchy } from "../helper";
|
|
17
|
+
import { AnimationState } from "../AnimationState";
|
|
18
|
+
import { VirtualizedList } from "./VirtualizedList";
|
|
19
|
+
import { ShuttleTargetListItem } from "./ShuttleListItem/ShuttleTargetListItem";
|
|
20
|
+
import { VirtualizedSortableList } from "./VirtualizedSortableList";
|
|
21
|
+
import { LoadingIndicator } from "./LoadingIndicator";
|
|
22
|
+
const noop = () => {
|
|
23
|
+
};
|
|
24
|
+
function ShuttleTarget({
|
|
25
|
+
items = [],
|
|
26
|
+
hierarchy = [],
|
|
27
|
+
onNavigateTo = noop,
|
|
28
|
+
onMoveItem = noop,
|
|
29
|
+
onClearMovedItems = noop,
|
|
30
|
+
emptyMessage = "No items selected",
|
|
31
|
+
composeTargetItemProps = () => ({}),
|
|
32
|
+
targetSortable = false,
|
|
33
|
+
onSortEnd = noop,
|
|
34
|
+
targetClearItemsText = "CLEAR ALL",
|
|
35
|
+
renderTargetCounter = (amount) => `${amount} items`,
|
|
36
|
+
loading = false
|
|
37
|
+
}) {
|
|
45
38
|
const {
|
|
46
|
-
state: {
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
} = useContext(AnimationContext.Context);
|
|
39
|
+
state: { isMoving = false }
|
|
40
|
+
} = useContext(AnimationState.Context);
|
|
50
41
|
const isEmpty = !items.length;
|
|
51
|
-
const emptyContent = loading ?
|
|
42
|
+
const emptyContent = loading ? /* @__PURE__ */ React2.createElement(LoadingIndicator, null) : /* @__PURE__ */ React2.createElement(EmptyMessage, null, emptyMessage);
|
|
52
43
|
const ComponentList = targetSortable ? VirtualizedSortableList : VirtualizedList;
|
|
53
|
-
|
|
54
|
-
const handleSortEnd = _ref2 => {
|
|
55
|
-
let {
|
|
56
|
-
oldIndex,
|
|
57
|
-
newIndex
|
|
58
|
-
} = _ref2;
|
|
44
|
+
const handleSortEnd = ({ oldIndex, newIndex }) => {
|
|
59
45
|
onSortEnd({
|
|
60
46
|
sourceItem: items[oldIndex],
|
|
61
47
|
targetItem: items[newIndex]
|
|
62
48
|
});
|
|
63
49
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
showPulse: isMoving
|
|
71
|
-
}
|
|
72
|
-
}, void 0, !loading && !isEmpty ? /*#__PURE__*/_jsx(Overflow, {
|
|
50
|
+
return /* @__PURE__ */ React2.createElement(ShuttleWrapper, null, /* @__PURE__ */ React2.createElement(ShuttleHeader, null, /* @__PURE__ */ React2.createElement(ShuttleHeaderBreadcrumb, {
|
|
51
|
+
hierarchy,
|
|
52
|
+
onNavigateTo
|
|
53
|
+
})), /* @__PURE__ */ React2.createElement(ShuttleList, {
|
|
54
|
+
classProps: { showPulse: isMoving }
|
|
55
|
+
}, !loading && !isEmpty ? /* @__PURE__ */ React2.createElement(Overflow, {
|
|
73
56
|
activeHierarchy: getActiveIdFromHierarchy(hierarchy).id,
|
|
74
57
|
classProps: {
|
|
75
58
|
empty: !items.length
|
|
76
59
|
}
|
|
77
|
-
},
|
|
78
|
-
itemRenderer:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
onMoveToSource: onMoveItem,
|
|
90
|
-
onNavigateOnTargetTo: onNavigateTo,
|
|
91
|
-
showSortHandler: targetSortable
|
|
92
|
-
}));
|
|
93
|
-
},
|
|
94
|
-
items: items,
|
|
60
|
+
}, /* @__PURE__ */ React2.createElement(ComponentList, {
|
|
61
|
+
itemRenderer: ({ item, ...rest }) => /* @__PURE__ */ React2.createElement(ShuttleTargetListItem, {
|
|
62
|
+
"data-testid": "target-list-item",
|
|
63
|
+
...rest,
|
|
64
|
+
...composeTargetItemProps(item, rest),
|
|
65
|
+
isRoot: !getActiveIdFromHierarchy(hierarchy).id,
|
|
66
|
+
item,
|
|
67
|
+
onMoveToSource: onMoveItem,
|
|
68
|
+
onNavigateOnTargetTo: onNavigateTo,
|
|
69
|
+
showSortHandler: targetSortable
|
|
70
|
+
}),
|
|
71
|
+
items,
|
|
95
72
|
onSortEnd: handleSortEnd,
|
|
96
73
|
target: true
|
|
97
|
-
})) :
|
|
98
|
-
containerProps: {
|
|
99
|
-
'data-testid': 'shuttle-clear-all-target'
|
|
100
|
-
},
|
|
74
|
+
})) : /* @__PURE__ */ React2.createElement(LoadingList, null, emptyContent)), /* @__PURE__ */ React2.createElement(ShuttleFooter, null, /* @__PURE__ */ React2.createElement(ShuttleFooterActions, null, !!items.length && /* @__PURE__ */ React2.createElement(DSButton, {
|
|
75
|
+
containerProps: { "data-testid": "shuttle-clear-all-target" },
|
|
101
76
|
buttonType: "link",
|
|
102
77
|
labelText: targetClearItemsText,
|
|
103
78
|
onClick: onClearMovedItems
|
|
104
|
-
})),
|
|
79
|
+
})), /* @__PURE__ */ React2.createElement(ShuttleFooterCounter, null, renderTargetCounter(items.length))));
|
|
105
80
|
}
|
|
106
|
-
|
|
107
|
-
export {
|
|
81
|
+
var ShuttleTarget_default = ShuttleTarget;
|
|
82
|
+
export {
|
|
83
|
+
ShuttleTarget,
|
|
84
|
+
ShuttleTarget_default as default
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=ShuttleTarget.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/ShuttleTarget.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React, { useContext } from 'react';\nimport { DSButton } from '@elliemae/ds-button';\n\nimport {\n EmptyMessage,\n Overflow,\n ShuttleFooter,\n ShuttleFooterActions,\n ShuttleFooterCounter,\n ShuttleHeader,\n ShuttleHeaderBreadcrumb,\n ShuttleList,\n ShuttleWrapper,\n LoadingList,\n} from '../classedComponents';\nimport { getActiveIdFromHierarchy } from '../helper';\nimport { AnimationState } from '../AnimationState';\nimport { VirtualizedList } from './VirtualizedList';\nimport { ShuttleTargetListItem } from './ShuttleListItem/ShuttleTargetListItem';\nimport { VirtualizedSortableList } from './VirtualizedSortableList';\nimport { LoadingIndicator } from './LoadingIndicator';\n\nconst noop = () => {};\n\nfunction ShuttleTarget({\n items = [],\n hierarchy = [],\n onNavigateTo = noop,\n onMoveItem = noop,\n onClearMovedItems = noop,\n emptyMessage = 'No items selected',\n composeTargetItemProps = () => ({}),\n targetSortable = false,\n onSortEnd = noop,\n targetClearItemsText = 'CLEAR ALL',\n renderTargetCounter = (amount) => `${amount} items`,\n loading = false,\n}) {\n const {\n state: { isMoving = false },\n } = useContext(AnimationState.Context);\n const isEmpty = !items.length;\n const emptyContent = loading ? <LoadingIndicator /> : <EmptyMessage>{emptyMessage}</EmptyMessage>;\n\n const ComponentList = targetSortable ? VirtualizedSortableList : VirtualizedList;\n\n const handleSortEnd = ({ oldIndex, newIndex }) => {\n onSortEnd({\n sourceItem: items[oldIndex],\n targetItem: items[newIndex],\n });\n };\n\n return (\n <ShuttleWrapper>\n <ShuttleHeader>\n <ShuttleHeaderBreadcrumb hierarchy={hierarchy} onNavigateTo={onNavigateTo} />\n </ShuttleHeader>\n <ShuttleList classProps={{ showPulse: isMoving }}>\n {!loading && !isEmpty ? (\n <Overflow\n activeHierarchy={getActiveIdFromHierarchy(hierarchy).id}\n classProps={{\n empty: !items.length,\n }}\n >\n <ComponentList\n itemRenderer={({ item, ...rest }) => (\n <ShuttleTargetListItem\n data-testid=\"target-list-item\"\n {...rest}\n {...composeTargetItemProps(item, rest)}\n isRoot={!getActiveIdFromHierarchy(hierarchy).id}\n item={item}\n onMoveToSource={onMoveItem}\n onNavigateOnTargetTo={onNavigateTo}\n showSortHandler={targetSortable}\n />\n )}\n items={items}\n onSortEnd={handleSortEnd}\n target\n />\n </Overflow>\n ) : (\n <LoadingList>{emptyContent}</LoadingList>\n )}\n </ShuttleList>\n <ShuttleFooter>\n <ShuttleFooterActions>\n {!!items.length && (\n <DSButton\n containerProps={{ 'data-testid': 'shuttle-clear-all-target' }}\n buttonType=\"link\"\n labelText={targetClearItemsText}\n onClick={onClearMovedItems}\n />\n )}\n </ShuttleFooterActions>\n <ShuttleFooterCounter>{renderTargetCounter(items.length)}</ShuttleFooterCounter>\n </ShuttleFooter>\n </ShuttleWrapper>\n );\n}\n\nexport { ShuttleTarget };\nexport default ShuttleTarget;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA;AACA;AACA;AACA;AACA;AACA;AAEA,MAAM,OAAO,MAAM;AAAA;AAEnB,uBAAuB;AAAA,EACrB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,eAAe;AAAA,EACf,yBAAyB,MAAO;AAAA,EAChC,iBAAiB;AAAA,EACjB,YAAY;AAAA,EACZ,uBAAuB;AAAA,EACvB,sBAAsB,CAAC,WAAW,GAAG;AAAA,EACrC,UAAU;AAAA,GACT;AACD,QAAM;AAAA,IACJ,OAAO,EAAE,WAAW;AAAA,MAClB,WAAW,eAAe;AAC9B,QAAM,UAAU,CAAC,MAAM;AACvB,QAAM,eAAe,UAAU,qCAAC,kBAAD,QAAuB,qCAAC,cAAD,MAAe;AAErE,QAAM,gBAAgB,iBAAiB,0BAA0B;AAEjE,QAAM,gBAAgB,CAAC,EAAE,UAAU,eAAe;AAChD,cAAU;AAAA,MACR,YAAY,MAAM;AAAA,MAClB,YAAY,MAAM;AAAA;AAAA;AAItB,SACE,qCAAC,gBAAD,MACE,qCAAC,eAAD,MACE,qCAAC,yBAAD;AAAA,IAAyB;AAAA,IAAsB;AAAA,OAEjD,qCAAC,aAAD;AAAA,IAAa,YAAY,EAAE,WAAW;AAAA,KACnC,CAAC,WAAW,CAAC,UACZ,qCAAC,UAAD;AAAA,IACE,iBAAiB,yBAAyB,WAAW;AAAA,IACrD,YAAY;AAAA,MACV,OAAO,CAAC,MAAM;AAAA;AAAA,KAGhB,qCAAC,eAAD;AAAA,IACE,cAAc,CAAC,EAAE,SAAS,WACxB,qCAAC,uBAAD;AAAA,MACE,eAAY;AAAA,SACR;AAAA,SACA,uBAAuB,MAAM;AAAA,MACjC,QAAQ,CAAC,yBAAyB,WAAW;AAAA,MAC7C;AAAA,MACA,gBAAgB;AAAA,MAChB,sBAAsB;AAAA,MACtB,iBAAiB;AAAA;AAAA,IAGrB;AAAA,IACA,WAAW;AAAA,IACX,QAAM;AAAA,QAIV,qCAAC,aAAD,MAAc,gBAGlB,qCAAC,eAAD,MACE,qCAAC,sBAAD,MACG,CAAC,CAAC,MAAM,UACP,qCAAC,UAAD;AAAA,IACE,gBAAgB,EAAE,eAAe;AAAA,IACjC,YAAW;AAAA,IACX,WAAW;AAAA,IACX,SAAS;AAAA,OAIf,qCAAC,sBAAD,MAAuB,oBAAoB,MAAM;AAAA;AAOzD,IAAO,wBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,40 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { memo } from "react";
|
|
3
|
+
import { areEqual } from "react-window";
|
|
4
|
+
const VirtualizedItem = memo(({ data, index, style: virtualizedStyles, showSortHandler = false }) => {
|
|
5
|
+
const { items, itemRenderer, isItemMoving } = data;
|
|
6
|
+
const { item, props: animatedStyles, key } = items[index] || {};
|
|
7
|
+
if (!item)
|
|
8
|
+
return null;
|
|
31
9
|
return itemRenderer({
|
|
32
10
|
index,
|
|
33
11
|
key,
|
|
34
12
|
item,
|
|
35
13
|
showSortHandler,
|
|
36
|
-
style: isItemMoving ?
|
|
14
|
+
style: isItemMoving ? { ...animatedStyles, ...virtualizedStyles } : virtualizedStyles
|
|
37
15
|
});
|
|
38
16
|
}, areEqual);
|
|
39
|
-
|
|
40
|
-
export {
|
|
17
|
+
var VirtualizedItem_default = VirtualizedItem;
|
|
18
|
+
export {
|
|
19
|
+
VirtualizedItem,
|
|
20
|
+
VirtualizedItem_default as default
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=VirtualizedItem.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/VirtualizedItem.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { memo } from 'react';\nimport { areEqual } from 'react-window';\n\nconst VirtualizedItem = memo(\n ({ data, index, style: virtualizedStyles, showSortHandler = false }) => {\n const { items, itemRenderer, isItemMoving } = data;\n const { item, props: animatedStyles, key } = items[index] || {};\n if (!item) return null;\n return itemRenderer({\n index,\n key,\n item,\n showSortHandler,\n style: isItemMoving\n ? { ...animatedStyles, ...virtualizedStyles }\n : virtualizedStyles,\n });\n },\n areEqual,\n);\n\nexport { VirtualizedItem };\nexport default VirtualizedItem;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEA,MAAM,kBAAkB,KACtB,CAAC,EAAE,MAAM,OAAO,OAAO,mBAAmB,kBAAkB,YAAY;AACtE,QAAM,EAAE,OAAO,cAAc,iBAAiB;AAC9C,QAAM,EAAE,MAAM,OAAO,gBAAgB,QAAQ,MAAM,UAAU;AAC7D,MAAI,CAAC;AAAM,WAAO;AAClB,SAAO,aAAa;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO,eACH,KAAK,mBAAmB,sBACxB;AAAA;AAAA,GAGR;AAIF,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,84 +1,59 @@
|
|
|
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
|
-
|
|
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;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { useContext, useEffect, useRef } from "react";
|
|
3
|
+
import { useTransition } from "react-spring/web";
|
|
4
|
+
import { FixedSizeList as List } from "react-window";
|
|
5
|
+
import InfiniteLoader from "react-window-infinite-loader";
|
|
6
|
+
import AutoSizer from "react-virtualized-auto-sizer";
|
|
7
|
+
import { animationConfig } from "../animation/animationConfig";
|
|
8
|
+
import { AnimationState } from "../AnimationState";
|
|
9
|
+
import { VirtualizedItem } from "./VirtualizedItem";
|
|
10
|
+
function VirtualizedList({
|
|
11
|
+
items,
|
|
12
|
+
itemRenderer,
|
|
13
|
+
searching,
|
|
14
|
+
target = false,
|
|
15
|
+
innerRef,
|
|
16
|
+
children,
|
|
17
|
+
hasNextPage = true,
|
|
18
|
+
getMoreItems = () => {
|
|
19
|
+
}
|
|
20
|
+
}) {
|
|
33
21
|
const hasMounted = useRef(false);
|
|
34
22
|
const {
|
|
35
|
-
state: {
|
|
36
|
-
isMoving,
|
|
37
|
-
isMovingBack
|
|
38
|
-
},
|
|
23
|
+
state: { isMoving, isMovingBack },
|
|
39
24
|
reset
|
|
40
|
-
} = useContext(
|
|
25
|
+
} = useContext(AnimationState.Context);
|
|
41
26
|
useEffect(() => {
|
|
42
27
|
hasMounted.current = true;
|
|
43
28
|
}, []);
|
|
44
|
-
const transitions = useTransition(items, item => item.id,
|
|
29
|
+
const transitions = useTransition(items, (item) => item.id, {
|
|
30
|
+
...animationConfig.moveItem(target),
|
|
45
31
|
onDestroyed: () => reset()
|
|
46
|
-
}));
|
|
47
|
-
const itemCount = hasNextPage ? items.length + 1 : items.length;
|
|
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
32
|
});
|
|
33
|
+
const itemCount = hasNextPage ? items.length + 1 : items.length;
|
|
34
|
+
const isItemLoaded = (index) => !hasNextPage || index < items.length;
|
|
35
|
+
return /* @__PURE__ */ React2.createElement(AutoSizer, null, ({ height, width }) => /* @__PURE__ */ React2.createElement(InfiniteLoader, {
|
|
36
|
+
isItemLoaded,
|
|
37
|
+
itemCount,
|
|
38
|
+
loadMoreItems: getMoreItems
|
|
39
|
+
}, ({ onItemsRendered, ref }) => /* @__PURE__ */ React2.createElement(List, {
|
|
40
|
+
height: searching ? 300 : height,
|
|
41
|
+
width,
|
|
42
|
+
innerRef,
|
|
43
|
+
itemCount: transitions.length,
|
|
44
|
+
itemData: {
|
|
45
|
+
items: transitions,
|
|
46
|
+
itemRenderer,
|
|
47
|
+
isItemMoving: hasMounted.current && (isMoving || isMovingBack)
|
|
48
|
+
},
|
|
49
|
+
itemSize: 35,
|
|
50
|
+
onItemsRendered,
|
|
51
|
+
ref
|
|
52
|
+
}, children || VirtualizedItem)));
|
|
82
53
|
}
|
|
83
|
-
|
|
84
|
-
export {
|
|
54
|
+
var VirtualizedList_default = VirtualizedList;
|
|
55
|
+
export {
|
|
56
|
+
VirtualizedList,
|
|
57
|
+
VirtualizedList_default as default
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=VirtualizedList.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/VirtualizedList.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React, { useContext, useEffect, useRef } from 'react';\nimport { useTransition } from 'react-spring/web';\nimport { FixedSizeList as List } from 'react-window';\nimport InfiniteLoader from 'react-window-infinite-loader';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { animationConfig } from '../animation/animationConfig';\nimport { AnimationState } from '../AnimationState';\nimport { VirtualizedItem } from './VirtualizedItem';\n\nfunction VirtualizedList({\n items,\n itemRenderer,\n searching,\n target = false,\n innerRef,\n children,\n hasNextPage = true,\n getMoreItems = () => {},\n}) {\n const hasMounted = useRef(false);\n const {\n state: { isMoving, isMovingBack },\n reset,\n } = useContext(AnimationState.Context);\n\n useEffect(() => {\n hasMounted.current = true;\n }, []);\n\n const transitions = useTransition(items, (item) => item.id, {\n ...animationConfig.moveItem(target),\n onDestroyed: () => reset(),\n });\n\n const itemCount = hasNextPage ? items.length + 1 : items.length;\n\n const isItemLoaded = (index) => !hasNextPage || index < items.length;\n\n return (\n <AutoSizer>\n {({ height, width }) => (\n <InfiniteLoader\n isItemLoaded={isItemLoaded}\n itemCount={itemCount}\n loadMoreItems={getMoreItems}\n >\n {({ onItemsRendered, ref }) => (\n <List\n height={searching ? 300 : height}\n width={width}\n innerRef={innerRef}\n itemCount={transitions.length}\n itemData={{\n items: transitions,\n itemRenderer,\n isItemMoving: hasMounted.current && (isMoving || isMovingBack),\n }}\n itemSize={35}\n onItemsRendered={onItemsRendered}\n ref={ref}\n >\n {children || VirtualizedItem}\n </List>\n )}\n </InfiniteLoader>\n )}\n </AutoSizer>\n );\n}\n\nexport { VirtualizedList };\nexport default VirtualizedList;\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,yBAAyB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA;AAAA,EACA,cAAc;AAAA,EACd,eAAe,MAAM;AAAA;AAAA,GACpB;AACD,QAAM,aAAa,OAAO;AAC1B,QAAM;AAAA,IACJ,OAAO,EAAE,UAAU;AAAA,IACnB;AAAA,MACE,WAAW,eAAe;AAE9B,YAAU,MAAM;AACd,eAAW,UAAU;AAAA,KACpB;AAEH,QAAM,cAAc,cAAc,OAAO,CAAC,SAAS,KAAK,IAAI;AAAA,OACvD,gBAAgB,SAAS;AAAA,IAC5B,aAAa,MAAM;AAAA;AAGrB,QAAM,YAAY,cAAc,MAAM,SAAS,IAAI,MAAM;AAEzD,QAAM,eAAe,CAAC,UAAU,CAAC,eAAe,QAAQ,MAAM;AAE9D,SACE,qCAAC,WAAD,MACG,CAAC,EAAE,QAAQ,YACV,qCAAC,gBAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA,eAAe;AAAA,KAEd,CAAC,EAAE,iBAAiB,UACnB,qCAAC,MAAD;AAAA,IACE,QAAQ,YAAY,MAAM;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,WAAW,YAAY;AAAA,IACvB,UAAU;AAAA,MACR,OAAO;AAAA,MACP;AAAA,MACA,cAAc,WAAW,WAAY,aAAY;AAAA;AAAA,IAEnD,UAAU;AAAA,IACV;AAAA,IACA;AAAA,KAEC,YAAY;AAAA;AAU3B,IAAO,0BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,34 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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; }
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import { sortableElement, sortableContainer } from "react-sortable-hoc";
|
|
4
|
+
import { VirtualizedList } from "./VirtualizedList";
|
|
5
|
+
import { VirtualizedItem } from "./VirtualizedItem";
|
|
19
6
|
const SortableList = sortableContainer(VirtualizedList);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
items
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return /*#__PURE__*/jsx(SortableList, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
28
|
-
items: items,
|
|
29
|
-
useDragHandle: true,
|
|
30
|
-
children: sortableElement(VirtualizedItem)
|
|
31
|
-
}));
|
|
7
|
+
function VirtualizedSortableList({ items, ...otherProps }) {
|
|
8
|
+
return /* @__PURE__ */ React2.createElement(SortableList, {
|
|
9
|
+
...otherProps,
|
|
10
|
+
items,
|
|
11
|
+
useDragHandle: true
|
|
12
|
+
}, sortableElement(VirtualizedItem));
|
|
32
13
|
}
|
|
33
|
-
|
|
34
|
-
export {
|
|
14
|
+
var VirtualizedSortableList_default = VirtualizedSortableList;
|
|
15
|
+
export {
|
|
16
|
+
VirtualizedSortableList,
|
|
17
|
+
VirtualizedSortableList_default as default
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=VirtualizedSortableList.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../../src/components/VirtualizedSortableList.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { sortableElement, sortableContainer } from 'react-sortable-hoc';\nimport { VirtualizedList } from './VirtualizedList';\nimport { VirtualizedItem } from './VirtualizedItem';\n\nconst SortableList = sortableContainer(VirtualizedList);\n\nfunction VirtualizedSortableList({ items, ...otherProps }) {\n return (\n <SortableList {...otherProps} items={items} useDragHandle>\n {sortableElement(VirtualizedItem)}\n </SortableList>\n );\n}\n\nexport { VirtualizedSortableList };\nexport default VirtualizedSortableList;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AACA;AACA;AAEA,MAAM,eAAe,kBAAkB;AAEvC,iCAAiC,EAAE,UAAU,cAAc;AACzD,SACE,qCAAC,cAAD;AAAA,OAAkB;AAAA,IAAY;AAAA,IAAc,eAAa;AAAA,KACtD,gBAAgB;AAAA;AAMvB,IAAO,kCAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/helper.js
CHANGED
|
@@ -1,78 +1,54 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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] || {};
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { omit, compose, hashArray } from "@elliemae/ds-utilities";
|
|
3
|
+
import * as tree from "treetabular";
|
|
4
|
+
const getHierarchyTypeName = (dest) => !dest ? "hierarchy" : "hierarchyDest";
|
|
5
|
+
const checkHasChildren = (list, currentItem) => list.some((item) => currentItem.id === item.parent);
|
|
6
|
+
const getActiveIdFromHierarchy = (hierarchy = []) => hierarchy[hierarchy.length - 1] || {};
|
|
7
|
+
const filterItemsByHierarchy = (list, hierarchyId, parentField = "parent") => list.filter((item) => item[parentField] === hierarchyId);
|
|
8
|
+
const getItemsById = (ids, list) => ids.reduce((acc, id) => acc.concat(list.find((item) => String(item.id) === String(id))), []).filter((item) => item);
|
|
9
|
+
const toggleInObject = (obj, key, value) => obj[key] ? omit(obj, [key]) : { ...obj, [key]: value };
|
|
10
|
+
const isMovable = (item) => !item.forceNotMovable && (item.hasChildren && item.isMoveableContainer || !item.hasChildren);
|
|
11
|
+
const pipe = (actions) => (initState, props) => actions.reduce((prevState, action) => action(prevState, props), initState);
|
|
12
|
+
const moveItems = ({ oldIndex, newIndex }) => (items) => {
|
|
13
|
+
const sourceItem = items[oldIndex];
|
|
14
|
+
items.splice(oldIndex, 1);
|
|
15
|
+
items.splice(newIndex, 0, sourceItem);
|
|
16
|
+
return items;
|
|
26
17
|
};
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
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)
|
|
18
|
+
const prepareItems = (items) => compose(tree.fixOrder(), (items2) => items2.map((item) => ({
|
|
19
|
+
...item,
|
|
20
|
+
hasChildren: checkHasChildren(items2, item)
|
|
52
21
|
})))(items);
|
|
53
22
|
const defaultOptions = {
|
|
54
|
-
parentField:
|
|
55
|
-
idField:
|
|
56
|
-
op: hasMoved => !hasMoved
|
|
23
|
+
parentField: "parent",
|
|
24
|
+
idField: "id",
|
|
25
|
+
op: (hasMoved) => !hasMoved
|
|
57
26
|
};
|
|
58
27
|
function getChildrenFromParent(parentId, options) {
|
|
59
|
-
const {
|
|
60
|
-
|
|
61
|
-
} = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
62
|
-
|
|
63
|
-
return items => items.filter(item => item[parentField] === parentId);
|
|
28
|
+
const { parentField } = { ...defaultOptions, ...options };
|
|
29
|
+
return (items) => items.filter((item) => item[parentField] === parentId);
|
|
64
30
|
}
|
|
65
31
|
function filterMovedItems(movedItems, options) {
|
|
66
|
-
const {
|
|
67
|
-
idField,
|
|
68
|
-
op: filterOp
|
|
69
|
-
} = _objectSpread(_objectSpread({}, defaultOptions), options);
|
|
70
|
-
|
|
32
|
+
const { idField, op: filterOp } = { ...defaultOptions, ...options };
|
|
71
33
|
const movedItemsHash = hashArray(movedItems, idField);
|
|
72
|
-
return items => items.filter(item => filterOp(!!movedItemsHash[item[idField]]));
|
|
34
|
+
return (items) => items.filter((item) => filterOp(!!movedItemsHash[item[idField]]));
|
|
73
35
|
}
|
|
74
36
|
function filterBySearch(term, searching) {
|
|
75
|
-
return items => searching ? items.filter(item => item.name.toLowerCase().indexOf(String(term).toLowerCase()) !== -1) : items;
|
|
37
|
+
return (items) => searching ? items.filter((item) => item.name.toLowerCase().indexOf(String(term).toLowerCase()) !== -1) : items;
|
|
76
38
|
}
|
|
77
|
-
|
|
78
|
-
|
|
39
|
+
export {
|
|
40
|
+
checkHasChildren,
|
|
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
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/helper.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable prettier/prettier */\n/* eslint-disable no-shadow,no-plusplus */\nimport { omit, compose, hashArray } from '@elliemae/ds-utilities';\nimport * as tree from 'treetabular';\n\nexport const getHierarchyTypeName = (dest) =>\n !dest ? 'hierarchy' : 'hierarchyDest';\nexport const checkHasChildren = (list, currentItem) =>\n list.some((item) => currentItem.id === item.parent);\nexport const getActiveIdFromHierarchy = (hierarchy = []) =>\n hierarchy[hierarchy.length - 1] || {};\n\nexport const filterItemsByHierarchy = (\n list,\n hierarchyId,\n parentField = 'parent',\n) => list.filter((item) => item[parentField] === hierarchyId);\nexport const getItemsById = (ids, list) =>\n ids\n .reduce(\n (acc, id) =>\n acc.concat(list.find((item) => String(item.id) === String(id))),\n [],\n )\n .filter((item) => item);\nexport const toggleInObject = (obj, key, value) =>\n obj[key] ? omit(obj, [key]) : { ...obj, [key]: value };\nexport const isMovable = (item) =>\n !item.forceNotMovable &&\n ((item.hasChildren && item.isMoveableContainer) || !item.hasChildren);\n// utility to execute all specified actions in sequence\nexport const pipe = (actions) => (initState, props) =>\n actions.reduce((prevState, action) => action(prevState, props), initState);\n\nexport const moveItems = ({ oldIndex, newIndex }) => (items) => {\n const sourceItem = items[oldIndex];\n items.splice(oldIndex, 1);\n items.splice(newIndex, 0, sourceItem);\n return items;\n};\n\nexport const prepareItems = (items) =>\n compose(tree.fixOrder(), (items) =>\n items.map((item) => ({\n ...item,\n hasChildren: checkHasChildren(items, item),\n })),\n )(items);\n\nconst defaultOptions = {\n parentField: 'parent',\n idField: 'id',\n op: (hasMoved) => !hasMoved,\n};\n\nexport function getChildrenFromParent(parentId, options) {\n const { parentField } = { ...defaultOptions, ...options };\n return (items) => items.filter((item) => item[parentField] === parentId);\n}\n\nexport function filterMovedItems(movedItems, options) {\n const { idField, op: filterOp } = { ...defaultOptions, ...options };\n const movedItemsHash = hashArray(movedItems, idField);\n return (items) =>\n items.filter((item) => filterOp(!!movedItemsHash[item[idField]]));\n}\n\nexport function filterBySearch(term, searching) {\n return (items) =>\n searching\n ? items.filter(\n (item) =>\n item.name.toLowerCase().indexOf(String(term).toLowerCase()) !== -1,\n )\n : items;\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACEA;AACA;AAEO,MAAM,uBAAuB,CAAC,SACnC,CAAC,OAAO,cAAc;AACjB,MAAM,mBAAmB,CAAC,MAAM,gBACrC,KAAK,KAAK,CAAC,SAAS,YAAY,OAAO,KAAK;AACvC,MAAM,2BAA2B,CAAC,YAAY,OACnD,UAAU,UAAU,SAAS,MAAM;AAE9B,MAAM,yBAAyB,CACpC,MACA,aACA,cAAc,aACX,KAAK,OAAO,CAAC,SAAS,KAAK,iBAAiB;AAC1C,MAAM,eAAe,CAAC,KAAK,SAChC,IACG,OACC,CAAC,KAAK,OACJ,IAAI,OAAO,KAAK,KAAK,CAAC,SAAS,OAAO,KAAK,QAAQ,OAAO,OAC5D,IAED,OAAO,CAAC,SAAS;AACf,MAAM,iBAAiB,CAAC,KAAK,KAAK,UACvC,IAAI,OAAO,KAAK,KAAK,CAAC,QAAQ,KAAK,MAAM,MAAM;AAC1C,MAAM,YAAY,CAAC,SACxB,CAAC,KAAK,mBACJ,MAAK,eAAe,KAAK,uBAAwB,CAAC,KAAK;AAEpD,MAAM,OAAO,CAAC,YAAY,CAAC,WAAW,UAC3C,QAAQ,OAAO,CAAC,WAAW,WAAW,OAAO,WAAW,QAAQ;AAE3D,MAAM,YAAY,CAAC,EAAE,UAAU,eAAe,CAAC,UAAU;AAC9D,QAAM,aAAa,MAAM;AACzB,QAAM,OAAO,UAAU;AACvB,QAAM,OAAO,UAAU,GAAG;AAC1B,SAAO;AAAA;AAGF,MAAM,eAAe,CAAC,UAC3B,QAAQ,KAAK,YAAY,CAAC,WACxB,OAAM,IAAI,CAAC,SAAU;AAAA,KAChB;AAAA,EACH,aAAa,iBAAiB,QAAO;AAAA,KAEvC;AAEJ,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,SAAS;AAAA,EACT,IAAI,CAAC,aAAa,CAAC;AAAA;AAGd,+BAA+B,UAAU,SAAS;AACvD,QAAM,EAAE,gBAAgB,KAAK,mBAAmB;AAChD,SAAO,CAAC,UAAU,MAAM,OAAO,CAAC,SAAS,KAAK,iBAAiB;AAAA;AAG1D,0BAA0B,YAAY,SAAS;AACpD,QAAM,EAAE,SAAS,IAAI,aAAa,KAAK,mBAAmB;AAC1D,QAAM,iBAAiB,UAAU,YAAY;AAC7C,SAAO,CAAC,UACN,MAAM,OAAO,CAAC,SAAS,SAAS,CAAC,CAAC,eAAe,KAAK;AAAA;AAGnD,wBAAwB,MAAM,WAAW;AAC9C,SAAO,CAAC,UACN,YACI,MAAM,OACJ,CAAC,SACC,KAAK,KAAK,cAAc,QAAQ,OAAO,MAAM,mBAAmB,MAEpE;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/esm/index.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { default as default2, utils, DSShuttleWithSchema, DSShuttle } from "./DSShuttle";
|
|
3
|
+
export {
|
|
4
|
+
DSShuttle,
|
|
5
|
+
DSShuttleWithSchema,
|
|
6
|
+
default2 as default,
|
|
7
|
+
utils
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|