@elliemae/ds-shuttle 3.15.0 → 3.16.0-next.10
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 +1 -3
- package/dist/cjs/AnimationState.js.map +2 -2
- package/dist/cjs/DSShuttle.js +46 -46
- package/dist/cjs/DSShuttle.js.map +2 -2
- package/dist/cjs/SearchState.js.map +2 -2
- package/dist/cjs/Shuttle.actions.js +6 -15
- package/dist/cjs/Shuttle.actions.js.map +3 -3
- package/dist/cjs/ShuttleContainer.js +6 -10
- package/dist/cjs/ShuttleContainer.js.map +2 -2
- package/dist/cjs/ShuttleImpl.js +26 -55
- package/dist/cjs/ShuttleImpl.js.map +2 -2
- package/dist/cjs/ShuttleRenderer.js +11 -19
- package/dist/cjs/ShuttleRenderer.js.map +2 -2
- package/dist/cjs/ShuttleState.js +4 -8
- package/dist/cjs/ShuttleState.js.map +2 -2
- package/dist/cjs/animation/animationConfig.js.map +2 -2
- package/dist/cjs/classedComponents.js +2 -2
- package/dist/cjs/classedComponents.js.map +1 -1
- package/dist/cjs/components/OverflowList.js +2 -2
- package/dist/cjs/components/OverflowList.js.map +1 -1
- package/dist/cjs/components/ShuttleBreadcrumb.js +3 -3
- package/dist/cjs/components/ShuttleBreadcrumb.js.map +2 -2
- package/dist/cjs/components/ShuttleListItem/ShuttleListItem.js +4 -4
- package/dist/cjs/components/ShuttleListItem/ShuttleListItem.js.map +2 -2
- package/dist/cjs/components/ShuttleListItem/ShuttleSourceListItem.js +7 -9
- package/dist/cjs/components/ShuttleListItem/ShuttleSourceListItem.js.map +2 -2
- package/dist/cjs/components/ShuttleListItem/ShuttleTargetListItem.js +6 -8
- package/dist/cjs/components/ShuttleListItem/ShuttleTargetListItem.js.map +2 -2
- package/dist/cjs/components/ShuttleListPanel.js +2 -4
- package/dist/cjs/components/ShuttleListPanel.js.map +2 -2
- package/dist/cjs/components/ShuttleSource.js +14 -14
- package/dist/cjs/components/ShuttleSource.js.map +2 -2
- package/dist/cjs/components/ShuttleTarget.js +10 -10
- package/dist/cjs/components/ShuttleTarget.js.map +2 -2
- package/dist/cjs/components/VirtualizedItem.js +13 -16
- package/dist/cjs/components/VirtualizedItem.js.map +2 -2
- package/dist/cjs/components/VirtualizedList.js +22 -30
- package/dist/cjs/components/VirtualizedList.js.map +2 -2
- package/dist/cjs/components/VirtualizedSortableList.js +3 -5
- package/dist/cjs/components/VirtualizedSortableList.js.map +2 -2
- package/dist/cjs/helper.js.map +2 -2
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +7 -0
- package/dist/cjs/tests/utils.js +1 -3
- package/dist/cjs/tests/utils.js.map +2 -2
- package/dist/cjs/updateShuttleStateFromProps.js +6 -10
- package/dist/cjs/updateShuttleStateFromProps.js.map +2 -2
- package/dist/cjs/utils.js +1 -1
- package/dist/cjs/utils.js.map +2 -2
- package/dist/cjs/withProviders.js +6 -4
- package/dist/cjs/withProviders.js.map +2 -2
- package/dist/esm/AnimationState.js +1 -3
- package/dist/esm/AnimationState.js.map +2 -2
- package/dist/esm/DSShuttle.js +3 -3
- package/dist/esm/DSShuttle.js.map +1 -1
- package/dist/esm/SearchState.js.map +2 -2
- package/dist/esm/Shuttle.actions.js +7 -25
- package/dist/esm/Shuttle.actions.js.map +3 -3
- package/dist/esm/ShuttleContainer.js +7 -22
- package/dist/esm/ShuttleContainer.js.map +2 -2
- package/dist/esm/ShuttleImpl.js +18 -47
- package/dist/esm/ShuttleImpl.js.map +2 -2
- package/dist/esm/ShuttleRenderer.js +11 -19
- package/dist/esm/ShuttleRenderer.js.map +2 -2
- package/dist/esm/ShuttleState.js +4 -8
- package/dist/esm/ShuttleState.js.map +2 -2
- package/dist/esm/animation/animationConfig.js.map +2 -2
- package/dist/esm/classedComponents.js +2 -2
- package/dist/esm/classedComponents.js.map +1 -1
- package/dist/esm/components/OverflowList.js +2 -2
- package/dist/esm/components/OverflowList.js.map +1 -1
- package/dist/esm/components/ShuttleBreadcrumb.js +3 -3
- package/dist/esm/components/ShuttleBreadcrumb.js.map +2 -2
- package/dist/esm/components/ShuttleListItem/ShuttleListItem.js +4 -4
- package/dist/esm/components/ShuttleListItem/ShuttleListItem.js.map +2 -2
- package/dist/esm/components/ShuttleListItem/ShuttleSourceListItem.js +7 -9
- package/dist/esm/components/ShuttleListItem/ShuttleSourceListItem.js.map +2 -2
- package/dist/esm/components/ShuttleListItem/ShuttleTargetListItem.js +6 -8
- package/dist/esm/components/ShuttleListItem/ShuttleTargetListItem.js.map +2 -2
- package/dist/esm/components/ShuttleListPanel.js +2 -4
- package/dist/esm/components/ShuttleListPanel.js.map +2 -2
- package/dist/esm/components/ShuttleSource.js +14 -14
- package/dist/esm/components/ShuttleSource.js.map +2 -2
- package/dist/esm/components/ShuttleTarget.js +10 -10
- package/dist/esm/components/ShuttleTarget.js.map +2 -2
- package/dist/esm/components/VirtualizedItem.js +13 -16
- package/dist/esm/components/VirtualizedItem.js.map +2 -2
- package/dist/esm/components/VirtualizedList.js +22 -30
- package/dist/esm/components/VirtualizedList.js.map +2 -2
- package/dist/esm/components/VirtualizedSortableList.js +3 -5
- package/dist/esm/components/VirtualizedSortableList.js.map +2 -2
- package/dist/esm/helper.js.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +7 -0
- package/dist/esm/tests/utils.js +1 -3
- package/dist/esm/tests/utils.js.map +2 -2
- package/dist/esm/updateShuttleStateFromProps.js +4 -8
- package/dist/esm/updateShuttleStateFromProps.js.map +2 -2
- package/dist/esm/utils.js +1 -1
- package/dist/esm/utils.js.map +2 -2
- package/dist/esm/withProviders.js +6 -4
- package/dist/esm/withProviders.js.map +2 -2
- package/dist/types/DSShuttle.d.ts +38 -38
- package/dist/types/Shuttle.actions.d.ts +7 -7
- package/dist/types/ShuttleRenderer.d.ts +2 -2
- package/dist/types/ShuttleState.d.ts +1 -1
- package/dist/types/components/ShuttleBreadcrumb.d.ts +2 -2
- package/dist/types/components/ShuttleListItem/ShuttleListItem.d.ts +2 -2
- package/dist/types/components/ShuttleListItem/ShuttleSourceListItem.d.ts +2 -2
- package/dist/types/components/ShuttleListItem/ShuttleTargetListItem.d.ts +2 -2
- package/dist/types/components/ShuttleListPanel.d.ts +2 -2
- package/dist/types/components/ShuttleSource.d.ts +27 -28
- package/dist/types/components/ShuttleTarget.d.ts +2 -2
- package/dist/types/components/VirtualizedList.d.ts +2 -2
- package/dist/types/components/VirtualizedSortableList.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +15 -14
|
@@ -77,8 +77,6 @@ function useShuttleAnimationState() {
|
|
|
77
77
|
reset
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
const AnimationState = (0, import_constate.default)(useShuttleAnimationState, (value) => [
|
|
81
|
-
value.state
|
|
82
|
-
]);
|
|
80
|
+
const AnimationState = (0, import_constate.default)(useShuttleAnimationState, (value) => [value.state]);
|
|
83
81
|
var AnimationState_default = AnimationState;
|
|
84
82
|
//# sourceMappingURL=AnimationState.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/AnimationState.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useState } from 'react';\nimport createContainer from 'constate';\n\nfunction useShuttleAnimationState() {\n const [animationState, setAnimationState] = useState({\n isMoving: false,\n isMovingBack: false,\n isDrillingDown: false,\n });\n const reset = useCallback(\n () =>\n setAnimationState({\n isMoving: false,\n isMovingBack: false,\n isDrillingDown: false,\n }),\n [],\n );\n const move = useCallback(\n () =>\n setAnimationState({\n isMovingBack: false,\n isMoving: true,\n isDrillingDown: false,\n }),\n [],\n );\n\n const moveBack = useCallback(\n () =>\n setAnimationState({\n isMovingBack: true,\n isMoving: false,\n isDrillingDown: false,\n }),\n [],\n );\n\n const drilldown = useCallback(\n () =>\n setAnimationState({\n isMovingBack: false,\n isMoving: false,\n isDrillingDown: true,\n }),\n [],\n );\n\n return {\n state: animationState,\n setIsMoving: move,\n setIsMovingBack: moveBack,\n setIsDrillingDown: drilldown,\n reset,\n };\n}\n\nconst AnimationState = createContainer(useShuttleAnimationState, value => [
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAsC;AACtC,sBAA4B;AAE5B,SAAS,2BAA2B;AAClC,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAAS;AAAA,IACnD,UAAU;AAAA,IACV,cAAc;AAAA,IACd,gBAAgB;AAAA,EAClB,CAAC;AACD,QAAM,YAAQ;AAAA,IACZ,MACE,kBAAkB;AAAA,MAChB,UAAU;AAAA,MACV,cAAc;AAAA,MACd,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACA,QAAM,WAAO;AAAA,IACX,MACE,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,UAAU;AAAA,MACV,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,QAAM,eAAW;AAAA,IACf,MACE,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,UAAU;AAAA,MACV,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,QAAM,gBAAY;AAAA,IAChB,MACE,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,UAAU;AAAA,MACV,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;AAEA,MAAM,qBAAiB,gBAAAA,SAAgB,0BAA0B,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useState } from 'react';\nimport createContainer from 'constate';\n\nfunction useShuttleAnimationState() {\n const [animationState, setAnimationState] = useState({\n isMoving: false,\n isMovingBack: false,\n isDrillingDown: false,\n });\n const reset = useCallback(\n () =>\n setAnimationState({\n isMoving: false,\n isMovingBack: false,\n isDrillingDown: false,\n }),\n [],\n );\n const move = useCallback(\n () =>\n setAnimationState({\n isMovingBack: false,\n isMoving: true,\n isDrillingDown: false,\n }),\n [],\n );\n\n const moveBack = useCallback(\n () =>\n setAnimationState({\n isMovingBack: true,\n isMoving: false,\n isDrillingDown: false,\n }),\n [],\n );\n\n const drilldown = useCallback(\n () =>\n setAnimationState({\n isMovingBack: false,\n isMoving: false,\n isDrillingDown: true,\n }),\n [],\n );\n\n return {\n state: animationState,\n setIsMoving: move,\n setIsMovingBack: moveBack,\n setIsDrillingDown: drilldown,\n reset,\n };\n}\n\nconst AnimationState = createContainer(useShuttleAnimationState, (value) => [value.state]);\n\nexport { AnimationState };\nexport default AnimationState;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAsC;AACtC,sBAA4B;AAE5B,SAAS,2BAA2B;AAClC,QAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAAS;AAAA,IACnD,UAAU;AAAA,IACV,cAAc;AAAA,IACd,gBAAgB;AAAA,EAClB,CAAC;AACD,QAAM,YAAQ;AAAA,IACZ,MACE,kBAAkB;AAAA,MAChB,UAAU;AAAA,MACV,cAAc;AAAA,MACd,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACA,QAAM,WAAO;AAAA,IACX,MACE,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,UAAU;AAAA,MACV,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,QAAM,eAAW;AAAA,IACf,MACE,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,UAAU;AAAA,MACV,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,QAAM,gBAAY;AAAA,IAChB,MACE,kBAAkB;AAAA,MAChB,cAAc;AAAA,MACd,UAAU;AAAA,MACV,gBAAgB;AAAA,IAClB,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,OAAO;AAAA,IACP,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;AAEA,MAAM,qBAAiB,gBAAAA,SAAgB,0BAA0B,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;AAGzF,IAAO,yBAAQ;",
|
|
6
6
|
"names": ["createContainer"]
|
|
7
7
|
}
|
package/dist/cjs/DSShuttle.js
CHANGED
|
@@ -33,10 +33,10 @@ module.exports = __toCommonJS(DSShuttle_exports);
|
|
|
33
33
|
var React = __toESM(require("react"));
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
35
|
var import_lodash = require("lodash");
|
|
36
|
-
var
|
|
36
|
+
var import_ds_props_helpers = require("@elliemae/ds-props-helpers");
|
|
37
37
|
var import_ds_truncated_tooltip_text = require("@elliemae/ds-truncated-tooltip-text");
|
|
38
|
-
var import_ShuttleImpl = require("./ShuttleImpl");
|
|
39
|
-
var import_utils = __toESM(require("./utils"));
|
|
38
|
+
var import_ShuttleImpl = require("./ShuttleImpl.js");
|
|
39
|
+
var import_utils = __toESM(require("./utils.js"));
|
|
40
40
|
const noop = () => {
|
|
41
41
|
};
|
|
42
42
|
const DSShuttle = ({
|
|
@@ -120,64 +120,64 @@ const DSShuttle = ({
|
|
|
120
120
|
}
|
|
121
121
|
) });
|
|
122
122
|
const props = {
|
|
123
|
-
containerProps:
|
|
124
|
-
idField:
|
|
125
|
-
parentIdField:
|
|
126
|
-
showIcons:
|
|
127
|
-
items:
|
|
128
|
-
|
|
129
|
-
disableDrillDown:
|
|
130
|
-
icon:
|
|
131
|
-
name:
|
|
132
|
-
readOnly:
|
|
133
|
-
description:
|
|
123
|
+
containerProps: import_ds_props_helpers.PropTypes.object.description("inject props to shuttle wrapper"),
|
|
124
|
+
idField: import_ds_props_helpers.PropTypes.string.description("The identifier field for the item object"),
|
|
125
|
+
parentIdField: import_ds_props_helpers.PropTypes.string.description("The parent identifier field for the item object"),
|
|
126
|
+
showIcons: import_ds_props_helpers.PropTypes.string.description("Whether to show the icons or not"),
|
|
127
|
+
items: import_ds_props_helpers.PropTypes.arrayOf(
|
|
128
|
+
import_ds_props_helpers.PropTypes.shape({
|
|
129
|
+
disableDrillDown: import_ds_props_helpers.PropTypes.bool,
|
|
130
|
+
icon: import_ds_props_helpers.PropTypes.element,
|
|
131
|
+
name: import_ds_props_helpers.PropTypes.string,
|
|
132
|
+
readOnly: import_ds_props_helpers.PropTypes.bool,
|
|
133
|
+
description: import_ds_props_helpers.PropTypes.string
|
|
134
134
|
})
|
|
135
135
|
).description("list of items"),
|
|
136
|
-
selectedItems:
|
|
136
|
+
selectedItems: import_ds_props_helpers.PropTypes.arrayOf(import_ds_props_helpers.PropTypes.string).description(
|
|
137
137
|
"Array of item ids that are selected. If passed the component behaves as controlled"
|
|
138
138
|
),
|
|
139
|
-
nonSelectedItems:
|
|
139
|
+
nonSelectedItems: import_ds_props_helpers.PropTypes.arrayOf(import_ds_props_helpers.PropTypes.string).description(
|
|
140
140
|
"Array of item ids that aren't selected.. Should include ALL non selected items, even those not rendered"
|
|
141
141
|
),
|
|
142
|
-
onSearch:
|
|
143
|
-
onSearchOpen:
|
|
144
|
-
onSearchClose:
|
|
145
|
-
onDrillDown:
|
|
142
|
+
onSearch: import_ds_props_helpers.PropTypes.func.description("Handler on search"),
|
|
143
|
+
onSearchOpen: import_ds_props_helpers.PropTypes.func.description("Handler when the searchbox is visible"),
|
|
144
|
+
onSearchClose: import_ds_props_helpers.PropTypes.func.description("Handler when the searchbox is not visible"),
|
|
145
|
+
onDrillDown: import_ds_props_helpers.PropTypes.func.description(
|
|
146
146
|
'Source handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction ("up" | "down")'
|
|
147
147
|
),
|
|
148
|
-
onDrillDownTarget:
|
|
148
|
+
onDrillDownTarget: import_ds_props_helpers.PropTypes.func.description(
|
|
149
149
|
'Target handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction ("up" | "down")'
|
|
150
150
|
),
|
|
151
|
-
onTargetSortEnd:
|
|
152
|
-
onGetMoreItems:
|
|
153
|
-
moreItemsLoading:
|
|
154
|
-
hasNextPage:
|
|
151
|
+
onTargetSortEnd: import_ds_props_helpers.PropTypes.func.description("Target handler when user stops dragging an item"),
|
|
152
|
+
onGetMoreItems: import_ds_props_helpers.PropTypes.func.description("Callback function that gets more items for Infinite Scroll"),
|
|
153
|
+
moreItemsLoading: import_ds_props_helpers.PropTypes.bool.description("Wheter there are mor items loading for Infinite Scroll"),
|
|
154
|
+
hasNextPage: import_ds_props_helpers.PropTypes.bool.description(
|
|
155
155
|
"Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems"
|
|
156
156
|
),
|
|
157
|
-
setGetStatus:
|
|
158
|
-
targetSortable:
|
|
159
|
-
sourceRootTitle:
|
|
160
|
-
sourceEmptyMessage:
|
|
161
|
-
targetEmptyMessage:
|
|
162
|
-
targetRootTitle:
|
|
163
|
-
composeSourceItemProps:
|
|
164
|
-
composeTargetItemProps:
|
|
165
|
-
onAddToTarget:
|
|
166
|
-
onAddCheckedItems:
|
|
167
|
-
onRemoveFromTarget:
|
|
168
|
-
onRemoveAllFromTarget:
|
|
169
|
-
onChange:
|
|
170
|
-
renderSourceCounter:
|
|
171
|
-
renderTargetCounter:
|
|
172
|
-
sourceClearItemsText:
|
|
173
|
-
targetClearItemsText:
|
|
174
|
-
searchPlaceholder:
|
|
175
|
-
loadingSource:
|
|
176
|
-
loadingTarget:
|
|
157
|
+
setGetStatus: import_ds_props_helpers.PropTypes.func.description("Function that takes as a parameter an internal getter for the state"),
|
|
158
|
+
targetSortable: import_ds_props_helpers.PropTypes.bool.description("Whether the target can be sortable with DnD"),
|
|
159
|
+
sourceRootTitle: import_ds_props_helpers.PropTypes.string.description("Handler when the searchbox is visible"),
|
|
160
|
+
sourceEmptyMessage: import_ds_props_helpers.PropTypes.string.description("Source text when there is no items"),
|
|
161
|
+
targetEmptyMessage: import_ds_props_helpers.PropTypes.string.description("Target text when there is no items"),
|
|
162
|
+
targetRootTitle: import_ds_props_helpers.PropTypes.string.description("Target text for the first hierarchy item"),
|
|
163
|
+
composeSourceItemProps: import_ds_props_helpers.PropTypes.func.description("Function that allow to compose the item props in the source"),
|
|
164
|
+
composeTargetItemProps: import_ds_props_helpers.PropTypes.func.description("Function that allow to compose the item props in the target"),
|
|
165
|
+
onAddToTarget: import_ds_props_helpers.PropTypes.func.description("Handler when a users moves an item to the target"),
|
|
166
|
+
onAddCheckedItems: import_ds_props_helpers.PropTypes.func.description("Handler when a users moves all the 'checked' items to the target"),
|
|
167
|
+
onRemoveFromTarget: import_ds_props_helpers.PropTypes.func.description("Handler when a user removes an item from the target"),
|
|
168
|
+
onRemoveAllFromTarget: import_ds_props_helpers.PropTypes.func.description("Handler when a user removes all the items from the target"),
|
|
169
|
+
onChange: import_ds_props_helpers.PropTypes.func.description("Handler for every change on the state"),
|
|
170
|
+
renderSourceCounter: import_ds_props_helpers.PropTypes.func.description("Function that returns an element for the source counter"),
|
|
171
|
+
renderTargetCounter: import_ds_props_helpers.PropTypes.func.description("Function that returns an element for the target counter"),
|
|
172
|
+
sourceClearItemsText: import_ds_props_helpers.PropTypes.string.description("Source text for the clear items button"),
|
|
173
|
+
targetClearItemsText: import_ds_props_helpers.PropTypes.string.description("Target text for the clear items button"),
|
|
174
|
+
searchPlaceholder: import_ds_props_helpers.PropTypes.string.description("Searchbox placeholder"),
|
|
175
|
+
loadingSource: import_ds_props_helpers.PropTypes.bool.description("Displays loading indicator on source section"),
|
|
176
|
+
loadingTarget: import_ds_props_helpers.PropTypes.bool.description("Displays loading indicator on target section")
|
|
177
177
|
};
|
|
178
178
|
DSShuttle.propTypes = props;
|
|
179
179
|
DSShuttle.displayName = "DSShuttle";
|
|
180
|
-
const DSShuttleWithSchema = (0,
|
|
180
|
+
const DSShuttleWithSchema = (0, import_ds_props_helpers.describe)(DSShuttle);
|
|
181
181
|
DSShuttleWithSchema.propTypes = props;
|
|
182
182
|
var DSShuttle_default = DSShuttle;
|
|
183
183
|
//# sourceMappingURL=DSShuttle.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DSShuttle.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable max-lines */\nimport React from 'react';\nimport { debounce } from 'lodash';\nimport { describe, PropTypes } from '@elliemae/ds-
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA;AAAA;ACAA,YAAuB;ADkDnB;AAhDJ,oBAAyB;AACzB,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable max-lines */\nimport React from 'react';\nimport { debounce } from 'lodash';\nimport { describe, PropTypes } from '@elliemae/ds-props-helpers';\nimport { TooltipTextProvider } from '@elliemae/ds-truncated-tooltip-text';\nimport { ShuttleImpl } from './ShuttleImpl.js';\nimport utils from './utils.js';\n\nconst noop = () => {};\n\nconst DSShuttle = ({\n containerProps = {},\n idField = 'id',\n parentIdField = 'parent',\n showIcons = true,\n items = [],\n selectedItems = undefined, // if defined it becomes controlled (v1)\n // TODO make `nonSelectedItems` the default controlled behavior (v2)\n nonSelectedItems = undefined,\n onSearch = noop,\n onSearchOpen = noop,\n onSearchClose = noop,\n onDrillDown = noop,\n onDrillDownTarget = noop,\n onTargetSortEnd = noop,\n setGetStatus = noop,\n targetSortable = true,\n sourceEmptyMessage = 'No Items Found',\n sourceRootTitle = 'Category',\n targetEmptyMessage = 'No Items Selected',\n targetRootTitle = 'Selected Items',\n composeSourceItemProps = () => ({}),\n composeTargetItemProps = () => ({}),\n onAddToTarget = noop,\n onAddCheckedItems = noop,\n onRemoveFromTarget = noop,\n onRemoveAllFromTarget = noop,\n onChange = noop,\n renderSourceCounter = noop,\n renderTargetCounter = noop,\n sourceClearItemsText = 'CLEAR ALL',\n targetClearItemsText = 'CLEAR ALL',\n searchPlaceholder = 'Search field ID, name, etc.',\n loadingSource = false,\n loadingTarget = false,\n onGetMoreItems = () => null,\n hasNextPage = false,\n moreItemsLoading,\n}) => (\n <TooltipTextProvider>\n <ShuttleImpl\n composeSourceItemProps={composeSourceItemProps}\n composeTargetItemProps={composeTargetItemProps}\n containerProps={containerProps}\n idField={idField}\n items={items}\n onAddCheckedItems={onAddCheckedItems}\n onAddToTarget={onAddToTarget}\n onChange={onChange}\n onDrillDown={onDrillDown}\n nonSelectedItems={nonSelectedItems}\n onDrillDownTarget={onDrillDownTarget}\n onRemoveAllFromTarget={onRemoveAllFromTarget}\n onRemoveFromTarget={onRemoveFromTarget}\n onSearch={onSearch}\n onSearchClose={onSearchClose}\n onSearchOpen={onSearchOpen}\n onTargetSortEnd={onTargetSortEnd}\n parentIdField={parentIdField}\n renderSourceCounter={renderSourceCounter}\n renderTargetCounter={renderTargetCounter}\n searchPlaceholder={searchPlaceholder}\n selectedItems={selectedItems}\n setGetStatus={setGetStatus}\n showIcons={showIcons}\n sourceClearItemsText={sourceClearItemsText}\n sourceEmptyMessage={sourceEmptyMessage}\n sourceRootTitle={sourceRootTitle}\n targetClearItemsText={targetClearItemsText}\n targetEmptyMessage={targetEmptyMessage}\n targetRootTitle={targetRootTitle}\n targetSortable={targetSortable}\n loadingSource={loadingSource}\n loadingTarget={loadingTarget}\n onGetMoreItems={debounce((...args) => {\n onGetMoreItems(...args);\n }, 500)}\n moreItemsLoading={moreItemsLoading}\n hasNextPage={hasNextPage}\n />\n </TooltipTextProvider>\n);\n\nconst props = {\n /** inject props to shuttle wrapper */\n containerProps: PropTypes.object.description('inject props to shuttle wrapper'),\n /** The identifier field for the item object */\n idField: PropTypes.string.description('The identifier field for the item object'),\n /** The parent identifier field for the item object */\n parentIdField: PropTypes.string.description('The parent identifier field for the item object'),\n /** Whether to show the icons or not */\n showIcons: PropTypes.string.description('Whether to show the icons or not'),\n /** List of items */\n items: PropTypes.arrayOf(\n PropTypes.shape({\n disableDrillDown: PropTypes.bool,\n icon: PropTypes.element,\n name: PropTypes.string,\n readOnly: PropTypes.bool,\n description: PropTypes.string,\n }),\n ).description('list of items'),\n /** Array of item ids that are selected. If passed the component behaves as controlled */\n selectedItems: PropTypes.arrayOf(PropTypes.string).description(\n 'Array of item ids that are selected. If passed the component behaves as controlled',\n ),\n /** Array of item ids that aren't selected. Should include ALL non selected items, even those not rendered */\n nonSelectedItems: PropTypes.arrayOf(PropTypes.string).description(\n \"Array of item ids that aren't selected.. Should include ALL non selected items, even those not rendered\",\n ),\n /** Handler on search */\n onSearch: PropTypes.func.description('Handler on search'),\n /** Handler when the searchbox is visible */\n onSearchOpen: PropTypes.func.description('Handler when the searchbox is visible'),\n /** Handler when the searchbox is not visible */\n onSearchClose: PropTypes.func.description('Handler when the searchbox is not visible'),\n /** Source handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\") */\n onDrillDown: PropTypes.func.description(\n 'Source handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\")',\n ),\n /** Target handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\") */\n onDrillDownTarget: PropTypes.func.description(\n 'Target handler when a user navigates to a level down on the nested structure. First param: item drilled. Second param: direction (\"up\" | \"down\")',\n ),\n /** Target handler when user stops dragging an item */\n onTargetSortEnd: PropTypes.func.description('Target handler when user stops dragging an item'),\n /** Callback function that gets more items for Infinite Scroll */\n onGetMoreItems: PropTypes.func.description('Callback function that gets more items for Infinite Scroll'),\n /** Wheter there are mor items loading for Infinite Scroll */\n moreItemsLoading: PropTypes.bool.description('Wheter there are mor items loading for Infinite Scroll'),\n /** Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems */\n hasNextPage: PropTypes.bool.description(\n 'Wheter there is a next page for Infinite Scroll, controls when to trigger onGetMoreItems',\n ),\n /** Function that takes as a parameter an internal getter for the state */\n setGetStatus: PropTypes.func.description('Function that takes as a parameter an internal getter for the state'),\n /** Whether the target can be sortable with DnD */\n targetSortable: PropTypes.bool.description('Whether the target can be sortable with DnD'),\n /** Handler when the searchbox is visible */\n sourceRootTitle: PropTypes.string.description('Handler when the searchbox is visible'),\n /** Source text when there is no items */\n sourceEmptyMessage: PropTypes.string.description('Source text when there is no items'),\n /** Target text when there is no items */\n targetEmptyMessage: PropTypes.string.description('Target text when there is no items'),\n /** Target text for the first hierarchy item */\n targetRootTitle: PropTypes.string.description('Target text for the first hierarchy item'),\n /** Function that allow to compose the item props in the source */\n composeSourceItemProps: PropTypes.func.description('Function that allow to compose the item props in the source'),\n /** Function that allow to compose the item props in the target */\n composeTargetItemProps: PropTypes.func.description('Function that allow to compose the item props in the target'),\n /** Handler when a users moves an item to the target */\n onAddToTarget: PropTypes.func.description('Handler when a users moves an item to the target'),\n /** Handler when a users moves all the 'checked' items to the target */\n onAddCheckedItems: PropTypes.func.description(\"Handler when a users moves all the 'checked' items to the target\"),\n /** Handler when a user removes an item from the target */\n onRemoveFromTarget: PropTypes.func.description('Handler when a user removes an item from the target'),\n /** Handler when a user removes all the items from the target */\n onRemoveAllFromTarget: PropTypes.func.description('Handler when a user removes all the items from the target'),\n /** Handler for every change on the state */\n onChange: PropTypes.func.description('Handler for every change on the state'),\n /** Function that returns an element for the source counter */\n renderSourceCounter: PropTypes.func.description('Function that returns an element for the source counter'),\n /** Function that returns an element for the target counter */\n renderTargetCounter: PropTypes.func.description('Function that returns an element for the target counter'),\n /** Source text for the clear items button */\n sourceClearItemsText: PropTypes.string.description('Source text for the clear items button'),\n /** Target text for the clear items button */\n targetClearItemsText: PropTypes.string.description('Target text for the clear items button'),\n /** Searchbox placeholder */\n searchPlaceholder: PropTypes.string.description('Searchbox placeholder'),\n /** Displays loading indicator on source section */\n loadingSource: PropTypes.bool.description('Displays loading indicator on source section'),\n /** Displays loading indicator on target section */\n loadingTarget: PropTypes.bool.description('Displays loading indicator on target section'),\n};\n\nDSShuttle.propTypes = props;\nDSShuttle.displayName = 'DSShuttle';\nconst DSShuttleWithSchema = describe(DSShuttle);\nDSShuttleWithSchema.propTypes = props;\n\nexport { utils, DSShuttleWithSchema, DSShuttle };\n\nexport default DSShuttle;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA;AAAA;ACAA,YAAuB;ADkDnB;AAhDJ,oBAAyB;AACzB,8BAAoC;AACpC,uCAAoC;AACpC,yBAA4B;AAC5B,mBAAkB;AAElB,MAAM,OAAO,MAAM;AAAC;AAEpB,MAAM,YAAY,CAAC;AAAA,EACjB,iBAAiB,CAAC;AAAA,EAClB,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,YAAY;AAAA,EACZ,QAAQ,CAAC;AAAA,EACT,gBAAgB;AAAA,EAEhB,mBAAmB;AAAA,EACnB,WAAW;AAAA,EACX,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,yBAAyB,OAAO,CAAC;AAAA,EACjC,yBAAyB,OAAO,CAAC;AAAA,EACjC,gBAAgB;AAAA,EAChB,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,wBAAwB;AAAA,EACxB,WAAW;AAAA,EACX,sBAAsB;AAAA,E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A,EAEzG,sBAAsB,kCAAU,OAAO,YAAY,wCAAwC;AAAA,EAE3F,sBAAsB,kCAAU,OAAO,YAAY,wCAAwC;AAAA,EAE3F,mBAAmB,kCAAU,OAAO,YAAY,uBAAuB;AAAA,EAEvE,eAAe,kCAAU,KAAK,YAAY,8CAA8C;AAAA,EAExF,eAAe,kCAAU,KAAK,YAAY,8CAA8C;AAC1F;AAEA,UAAU,YAAY;AACtB,UAAU,cAAc;AACxB,MAAM,0BAAsB,kCAAS,SAAS;AAC9C,oBAAoB,YAAY;AAIhC,IAAO,oBAAQ;",
|
|
6
6
|
"names": ["utils"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SearchState.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["import { useState } from 'react';\nimport createContainer from 'constate';\n\nfunction useSearchState() {\n const [searchTerm, setSearchTerm] = useState('');\n const [searching, setSearchBoxVisibility] = useState(false); // todo: create a hook for Visibility behavior\n\n function toggleSearchBox(userVisible) {\n if (userVisible !== undefined) {\n setSearchBoxVisibility(userVisible);\n } else {\n setSearchBoxVisibility(!searching);\n }\n }\n\n function reset() {\n setSearchTerm('');\n setSearchBoxVisibility(false);\n }\n\n return {\n state: { searchTerm, searching },\n setSearchTerm,\n toggleSearchBox,\n reset,\n };\n}\n\nconst SearchState = createContainer(useSearchState, value => [value.state]);\nexport { SearchState };\nexport default SearchState;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyB;AACzB,sBAA4B;AAE5B,SAAS,iBAAiB;AACxB,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,EAAE;AAC/C,QAAM,CAAC,WAAW,sBAAsB,QAAI,uBAAS,KAAK;AAE1D,WAAS,gBAAgB,aAAa;AACpC,QAAI,gBAAgB,QAAW;AAC7B,6BAAuB,WAAW;AAAA,IACpC,OAAO;AACL,6BAAuB,CAAC,SAAS;AAAA,IACnC;AAAA,EACF;AAEA,WAAS,QAAQ;AACf,kBAAc,EAAE;AAChB,2BAAuB,KAAK;AAAA,EAC9B;AAEA,SAAO;AAAA,IACL,OAAO,EAAE,YAAY,UAAU;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,kBAAc,gBAAAA,SAAgB,gBAAgB,
|
|
4
|
+
"sourcesContent": ["import { useState } from 'react';\nimport createContainer from 'constate';\n\nfunction useSearchState() {\n const [searchTerm, setSearchTerm] = useState('');\n const [searching, setSearchBoxVisibility] = useState(false); // todo: create a hook for Visibility behavior\n\n function toggleSearchBox(userVisible) {\n if (userVisible !== undefined) {\n setSearchBoxVisibility(userVisible);\n } else {\n setSearchBoxVisibility(!searching);\n }\n }\n\n function reset() {\n setSearchTerm('');\n setSearchBoxVisibility(false);\n }\n\n return {\n state: { searchTerm, searching },\n setSearchTerm,\n toggleSearchBox,\n reset,\n };\n}\n\nconst SearchState = createContainer(useSearchState, (value) => [value.state]);\nexport { SearchState };\nexport default SearchState;\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,mBAAyB;AACzB,sBAA4B;AAE5B,SAAS,iBAAiB;AACxB,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,EAAE;AAC/C,QAAM,CAAC,WAAW,sBAAsB,QAAI,uBAAS,KAAK;AAE1D,WAAS,gBAAgB,aAAa;AACpC,QAAI,gBAAgB,QAAW;AAC7B,6BAAuB,WAAW;AAAA,IACpC,OAAO;AACL,6BAAuB,CAAC,SAAS;AAAA,IACnC;AAAA,EACF;AAEA,WAAS,QAAQ;AACf,kBAAc,EAAE;AAChB,2BAAuB,KAAK;AAAA,EAC9B;AAEA,SAAO;AAAA,IACL,OAAO,EAAE,YAAY,UAAU;AAAA,IAC/B;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEA,MAAM,kBAAc,gBAAAA,SAAgB,gBAAgB,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;AAE5E,IAAO,sBAAQ;",
|
|
6
6
|
"names": ["createContainer"]
|
|
7
7
|
}
|
|
@@ -35,8 +35,8 @@ __export(Shuttle_actions_exports, {
|
|
|
35
35
|
module.exports = __toCommonJS(Shuttle_actions_exports);
|
|
36
36
|
var React = __toESM(require("react"));
|
|
37
37
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
38
|
-
var import_helper = require("./helper");
|
|
39
|
-
var import_utils = __toESM(require("./utils"));
|
|
38
|
+
var import_helper = require("./helper.js");
|
|
39
|
+
var import_utils = __toESM(require("./utils.js"));
|
|
40
40
|
function toggleItemSelection(itemId) {
|
|
41
41
|
return (state) => ({
|
|
42
42
|
...state,
|
|
@@ -46,9 +46,7 @@ function toggleItemSelection(itemId) {
|
|
|
46
46
|
function navigateTo(item, dest) {
|
|
47
47
|
const hierarchyType = (0, import_helper.getHierarchyTypeName)(dest);
|
|
48
48
|
return (state) => {
|
|
49
|
-
const indexInHierarchy = state[hierarchyType].findIndex(
|
|
50
|
-
(hItem) => hItem.id === item.id
|
|
51
|
-
);
|
|
49
|
+
const indexInHierarchy = state[hierarchyType].findIndex((hItem) => hItem.id === item.id);
|
|
52
50
|
const hierarchy = state[hierarchyType];
|
|
53
51
|
return {
|
|
54
52
|
...state,
|
|
@@ -94,14 +92,9 @@ function addToTarget(itemToAdd, collection) {
|
|
|
94
92
|
function removeFromTarget(itemToRemove) {
|
|
95
93
|
return (state, { idField }) => {
|
|
96
94
|
let targetItems = (0, import_ds_utilities.cloneDeep)(state.targetItems);
|
|
97
|
-
const itemIndex = targetItems.findIndex(
|
|
98
|
-
(fItem) => fItem.id === itemToRemove.id
|
|
99
|
-
);
|
|
95
|
+
const itemIndex = targetItems.findIndex((fItem) => fItem.id === itemToRemove.id);
|
|
100
96
|
const item = targetItems[itemIndex];
|
|
101
|
-
const children = item?.hasChildren ? (0, import_ds_utilities.compose)(
|
|
102
|
-
(0, import_helper.filterMovedItems)(state.movedItems),
|
|
103
|
-
import_utils.default.getChildren({ index: itemIndex })
|
|
104
|
-
)(targetItems) || [] : [];
|
|
97
|
+
const children = item?.hasChildren ? (0, import_ds_utilities.compose)((0, import_helper.filterMovedItems)(state.movedItems), import_utils.default.getChildren({ index: itemIndex }))(targetItems) || [] : [];
|
|
105
98
|
targetItems.splice(itemIndex, 1);
|
|
106
99
|
if (item?.hasChildren && children.length) {
|
|
107
100
|
const childrenHash = (0, import_ds_utilities.hashArray)(children, "id");
|
|
@@ -109,9 +102,7 @@ function removeFromTarget(itemToRemove) {
|
|
|
109
102
|
}
|
|
110
103
|
return {
|
|
111
104
|
...state,
|
|
112
|
-
movedItems: state.movedItems.filter(
|
|
113
|
-
(mItem) => mItem[idField] !== itemToRemove[idField]
|
|
114
|
-
),
|
|
105
|
+
movedItems: state.movedItems.filter((mItem) => mItem[idField] !== itemToRemove[idField]),
|
|
115
106
|
targetItems
|
|
116
107
|
};
|
|
117
108
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/Shuttle.actions.
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,
|
|
3
|
+
"sources": ["../../src/Shuttle.actions.ts", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
+
"sourcesContent": ["import { addOrRemove, cloneDeep, hashArray, compose } from '@elliemae/ds-utilities';\nimport { getHierarchyTypeName, toggleInObject, filterMovedItems } from './helper.js';\nimport utils from './utils.js';\n\nexport function toggleItemSelection(itemId) {\n return (state) => ({\n ...state,\n checkedItems: addOrRemove(state.checkedItems, itemId),\n });\n}\nexport function navigateTo(item, dest) {\n const hierarchyType = getHierarchyTypeName(dest);\n return (state) => {\n const indexInHierarchy = state[hierarchyType].findIndex((hItem) => hItem.id === item.id);\n const hierarchy = state[hierarchyType];\n return {\n ...state,\n [hierarchyType]: indexInHierarchy !== -1 ? hierarchy.slice(0, indexInHierarchy + 1) : [...hierarchy, item],\n };\n };\n}\nexport function moveItem(item) {\n return (state) => {\n const movedItems = toggleInObject(state.movedItems, item.id, item);\n return {\n ...state,\n movedItems,\n };\n };\n}\n\nconst defaultOptions = {\n parentField: 'parent',\n idField: 'id',\n op: (hasMoved) => !hasMoved,\n};\n\n// todo: optimize this\nfunction getItemDeep({ collection, id, options }) {\n const { idField } = { ...defaultOptions, ...options };\n const itemIndex = collection.findIndex((fItem) => fItem[idField] === id);\n\n // get item with nested children\n const item = collection[itemIndex];\n const children = item?.hasChildren ? compose(utils.getChildren({ index: itemIndex }))(collection) || [] : [];\n\n return { item, children };\n}\n\nexport function addToTarget(itemToAdd, collection) {\n return (state, { idField }) => {\n const items = collection || state.preparedItems;\n\n const { item, children } = getItemDeep({\n collection: items,\n id: itemToAdd[idField],\n });\n\n return {\n ...state,\n movedItems: [...state.movedItems, item],\n targetItems: [...state.targetItems, item, ...children],\n };\n };\n}\n\n// todo: optimize this\nexport function removeFromTarget(itemToRemove) {\n return (state, { idField }) => {\n let targetItems = cloneDeep(state.targetItems);\n\n const itemIndex = targetItems.findIndex((fItem) => fItem.id === itemToRemove.id);\n\n const item = targetItems[itemIndex];\n const children = item?.hasChildren\n ? compose(filterMovedItems(state.movedItems), utils.getChildren({ index: itemIndex }))(targetItems) || []\n : [];\n\n targetItems.splice(itemIndex, 1);\n if (item?.hasChildren && children.length) {\n const childrenHash = hashArray(children, 'id');\n targetItems = targetItems.filter((i) => !childrenHash[i.id]);\n }\n\n return {\n ...state,\n movedItems: state.movedItems.filter((mItem) => mItem[idField] !== itemToRemove[idField]),\n targetItems,\n };\n };\n}\n\nexport function resetCheckedItems() {\n return (state) => ({\n ...state,\n checkedItems: [],\n });\n}\nexport function resetMovedItems() {\n return (state) => ({\n ...state,\n movedItems: [],\n targetItems: [],\n });\n}\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,0BAA2D;AAC3D,oBAAuE;AACvE,mBAAkB;AAEX,SAAS,oBAAoB,QAAQ;AAC1C,SAAO,CAAC,WAAW;AAAA,IACjB,GAAG;AAAA,IACH,kBAAc,iCAAY,MAAM,cAAc,MAAM;AAAA,EACtD;AACF;AACO,SAAS,WAAW,MAAM,MAAM;AACrC,QAAM,oBAAgB,oCAAqB,IAAI;AAC/C,SAAO,CAAC,UAAU;AAChB,UAAM,mBAAmB,MAAM,eAAe,UAAU,CAAC,UAAU,MAAM,OAAO,KAAK,EAAE;AACvF,UAAM,YAAY,MAAM;AACxB,WAAO;AAAA,MACL,GAAG;AAAA,MACH,CAAC,gBAAgB,qBAAqB,KAAK,UAAU,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,GAAG,WAAW,IAAI;AAAA,IAC3G;AAAA,EACF;AACF;AACO,SAAS,SAAS,MAAM;AAC7B,SAAO,CAAC,UAAU;AAChB,UAAM,iBAAa,8BAAe,MAAM,YAAY,KAAK,IAAI,IAAI;AACjE,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;AAEA,MAAM,iBAAiB;AAAA,EACrB,aAAa;AAAA,EACb,SAAS;AAAA,EACT,IAAI,CAAC,aAAa,CAAC;AACrB;AAGA,SAAS,YAAY,EAAE,YAAY,IAAI,QAAQ,GAAG;AAChD,QAAM,EAAE,QAAQ,IAAI,EAAE,GAAG,gBAAgB,GA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O,CAAC,UAAU,MAAM,aAAa,aAAa,QAAQ;AAAA,MACvF;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,oBAAoB;AAClC,SAAO,CAAC,WAAW;AAAA,IACjB,GAAG;AAAA,IACH,cAAc,CAAC;AAAA,EACjB;AACF;AACO,SAAS,kBAAkB;AAChC,SAAO,CAAC,WAAW;AAAA,IACjB,GAAG;AAAA,IACH,YAAY,CAAC;AAAA,IACb,aAAa,CAAC;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": ["utils"]
|
|
7
7
|
}
|
|
@@ -30,19 +30,17 @@ module.exports = __toCommonJS(ShuttleContainer_exports);
|
|
|
30
30
|
var React = __toESM(require("react"));
|
|
31
31
|
var import_react = require("react");
|
|
32
32
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
33
|
-
var import_withProviders = require("./withProviders");
|
|
34
|
-
var import_helper = require("./helper");
|
|
35
|
-
var import_SearchState = require("./SearchState");
|
|
36
|
-
var import_ShuttleState = require("./ShuttleState");
|
|
33
|
+
var import_withProviders = require("./withProviders.js");
|
|
34
|
+
var import_helper = require("./helper.js");
|
|
35
|
+
var import_SearchState = require("./SearchState.js");
|
|
36
|
+
var import_ShuttleState = require("./ShuttleState.js");
|
|
37
37
|
function filterItemsByTerm(items, term) {
|
|
38
38
|
return items.filter(
|
|
39
39
|
(item) => item.name.toLowerCase().indexOf(String(term).toLowerCase()) !== -1 || String(item.id).indexOf(String(term).toLowerCase()) !== -1
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
function ShuttleContainer({ items = [], children }) {
|
|
43
|
-
const { state: shuttleState, ...handlers } = (0, import_react.useContext)(
|
|
44
|
-
import_ShuttleState.ShuttleState.Context
|
|
45
|
-
);
|
|
43
|
+
const { state: shuttleState, ...handlers } = (0, import_react.useContext)(import_ShuttleState.ShuttleState.Context);
|
|
46
44
|
const { state: searchState } = (0, import_react.useContext)(import_SearchState.SearchState.Context);
|
|
47
45
|
const {
|
|
48
46
|
movedItems,
|
|
@@ -71,9 +69,7 @@ function ShuttleContainer({ items = [], children }) {
|
|
|
71
69
|
const hierarchyId = (0, import_helper.getActiveIdFromHierarchy)(hierarchyDest).id;
|
|
72
70
|
return (0, import_ds_utilities.compose)(
|
|
73
71
|
(items2) => (0, import_ds_utilities.sortBy)(items2, ["name"]),
|
|
74
|
-
(items2) => hierarchyId ? (0, import_helper.filterItemsByHierarchy)(items2, hierarchyId).filter(
|
|
75
|
-
(item) => !movedItems[item.id]
|
|
76
|
-
) : (0, import_ds_utilities.uniqBy)((0, import_ds_utilities.values)(movedItems), "id")
|
|
72
|
+
(items2) => hierarchyId ? (0, import_helper.filterItemsByHierarchy)(items2, hierarchyId).filter((item) => !movedItems[item.id]) : (0, import_ds_utilities.uniqBy)((0, import_ds_utilities.values)(movedItems), "id")
|
|
77
73
|
)(items);
|
|
78
74
|
}, [items, searching, hierarchyDest, movedItems]);
|
|
79
75
|
return (0, import_ds_utilities.isFunction)(children) && children({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ShuttleContainer.tsx", "../../../../scripts/build/transpile/react-shim.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable no-shadow */\nimport { useContext, useMemo } from 'react';\nimport {
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,mBAAoC;AACpC,
|
|
4
|
+
"sourcesContent": ["/* eslint-disable no-shadow */\nimport { useContext, useMemo } from 'react';\nimport { isFunction, compose, uniqBy, values, sortBy } from '@elliemae/ds-utilities';\nimport { withProviders } from './withProviders.js';\nimport { prepareItems, getActiveIdFromHierarchy, filterItemsByHierarchy, getItemsById } from './helper.js';\nimport { SearchState } from './SearchState.js';\nimport { ShuttleState } from './ShuttleState.js';\n\nfunction filterItemsByTerm(items, term) {\n return items.filter(\n (item) =>\n item.name.toLowerCase().indexOf(String(term).toLowerCase()) !== -1 ||\n String(item.id).indexOf(String(term).toLowerCase()) !== -1,\n );\n}\n\nfunction ShuttleContainer({ items = [], children }) {\n const { state: shuttleState, ...handlers } = useContext(ShuttleState.Context);\n const { state: searchState } = useContext(SearchState.Context);\n const {\n movedItems,\n hierarchy,\n hierarchyDest,\n checkedItems,\n searchTerm,\n searching,\n toggleItemSelection,\n resetCheckedItems,\n resetMovedItems,\n moveCheckedItems,\n moveItem,\n navigate,\n } = { ...shuttleState, ...searchState, ...handlers };\n\n const sourceItems = useMemo(\n () =>\n compose(\n (items) => items.filter((item) => !movedItems[item.id]),\n (items) => (searchTerm && searching ? filterItemsByTerm(items, searchTerm) : items),\n (items) => filterItemsByHierarchy(items, getActiveIdFromHierarchy(hierarchy).id),\n (items) => prepareItems(items),\n )(items),\n [items, searchTerm, searching, hierarchy, movedItems],\n );\n\n const targetItems = useMemo(() => {\n const hierarchyId = getActiveIdFromHierarchy(hierarchyDest).id;\n return compose(\n (items) => sortBy(items, ['name']),\n (items) =>\n hierarchyId\n ? filterItemsByHierarchy(items, hierarchyId).filter((item) => !movedItems[item.id])\n : uniqBy(values(movedItems), 'id'),\n )(items);\n }, [items, searching, hierarchyDest, movedItems]);\n\n return (\n isFunction(children) &&\n children({\n checkedItems,\n hierarchy,\n hierarchyDest,\n onCheckItem: toggleItemSelection,\n onClearCheckedItems: resetCheckedItems,\n onClearMovedItems: resetMovedItems,\n onMoveCheckedItems: () => moveCheckedItems(getItemsById(checkedItems, items)),\n onMoveItemToSource: (item) => moveItem(item, false),\n onMoveItemToTarget: (item) => moveItem(item, true),\n onNavigateOnSourceTo: (item) => navigate(item, false),\n onNavigateOnTargetTo: (item) => navigate(item, true),\n sourceItems,\n targetItems,\n })\n );\n}\n\nexport default withProviders(ShuttleContainer);\n", "import * as React from 'react';\nexport { React };\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAu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AACA,WACC,kBACI,sCAAuBA,QAAO,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,WAAW,KAAK,GAAG,QAChF,gCAAO,4BAAO,UAAU,GAAG,IAAI;AAAA,IACvC,EAAE,KAAK;AAAA,EACT,GAAG,CAAC,OAAO,WAAW,eAAe,UAAU,CAAC;AAEhD,aACE,gCAAW,QAAQ,KACnB,SAAS;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,qBAAqB;AAAA,IACrB,mBAAmB;AAAA,IACnB,oBAAoB,MAAM,qBAAiB,4BAAa,cAAc,KAAK,CAAC;AAAA,IAC5E,oBAAoB,CAAC,SAAS,SAAS,MAAM,KAAK;AAAA,IAClD,oBAAoB,CAAC,SAAS,SAAS,MAAM,IAAI;AAAA,IACjD,sBAAsB,CAAC,SAAS,SAAS,MAAM,KAAK;AAAA,IACpD,sBAAsB,CAAC,SAAS,SAAS,MAAM,IAAI;AAAA,IACnD;AAAA,IACA;AAAA,EACF,CAAC;AAEL;AAEA,IAAO,+BAAQ,oCAAc,gBAAgB;",
|
|
6
6
|
"names": ["items"]
|
|
7
7
|
}
|
package/dist/cjs/ShuttleImpl.js
CHANGED
|
@@ -32,12 +32,12 @@ var React = __toESM(require("react"));
|
|
|
32
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
33
|
var import_react = require("react");
|
|
34
34
|
var import_ds_utilities = require("@elliemae/ds-utilities");
|
|
35
|
-
var import_withProviders = require("./withProviders");
|
|
36
|
-
var
|
|
37
|
-
var import_helper = require("./helper");
|
|
38
|
-
var import_ShuttleRenderer = require("./ShuttleRenderer");
|
|
39
|
-
var import_SearchState = require("./SearchState");
|
|
40
|
-
var import_updateShuttleStateFromProps = require("./updateShuttleStateFromProps");
|
|
35
|
+
var import_withProviders = require("./withProviders.js");
|
|
36
|
+
var import_Shuttle_actions = require("./Shuttle.actions.js");
|
|
37
|
+
var import_helper = require("./helper.js");
|
|
38
|
+
var import_ShuttleRenderer = require("./ShuttleRenderer.js");
|
|
39
|
+
var import_SearchState = require("./SearchState.js");
|
|
40
|
+
var import_updateShuttleStateFromProps = require("./updateShuttleStateFromProps.js");
|
|
41
41
|
class ShuttleImpl extends import_react.Component {
|
|
42
42
|
constructor(props) {
|
|
43
43
|
super(props);
|
|
@@ -58,29 +58,26 @@ class ShuttleImpl extends import_react.Component {
|
|
|
58
58
|
onDrillDownTarget(item, direction);
|
|
59
59
|
const { reset: resetSearchState } = this.context;
|
|
60
60
|
resetSearchState();
|
|
61
|
-
this.setState((0, import_helper.pipe)([(0,
|
|
61
|
+
this.setState((0, import_helper.pipe)([(0, import_Shuttle_actions.navigateTo)(item, dest), (0, import_Shuttle_actions.resetCheckedItems)()]));
|
|
62
62
|
};
|
|
63
63
|
this.resetCheckedItems = () => {
|
|
64
|
-
this.setState((0,
|
|
64
|
+
this.setState((0, import_Shuttle_actions.resetCheckedItems)());
|
|
65
65
|
};
|
|
66
66
|
this.resetMovedItems = () => {
|
|
67
67
|
const { selectedItems, onRemoveAllFromTarget } = this.props;
|
|
68
68
|
if (!selectedItems) {
|
|
69
|
-
this.setState(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.handleChange();
|
|
73
|
-
}
|
|
74
|
-
);
|
|
69
|
+
this.setState((0, import_helper.pipe)([(0, import_Shuttle_actions.navigateTo)({ id: null }, true), (0, import_Shuttle_actions.resetMovedItems)()]), () => {
|
|
70
|
+
this.handleChange();
|
|
71
|
+
});
|
|
75
72
|
} else {
|
|
76
|
-
this.setState((0, import_helper.pipe)([(0,
|
|
73
|
+
this.setState((0, import_helper.pipe)([(0, import_Shuttle_actions.navigateTo)({ id: null }, true)]));
|
|
77
74
|
}
|
|
78
75
|
onRemoveAllFromTarget();
|
|
79
76
|
};
|
|
80
77
|
this.addToTarget = (item) => {
|
|
81
78
|
const { selectedItems, onAddToTarget } = this.props;
|
|
82
79
|
if (!selectedItems) {
|
|
83
|
-
this.setState((0, import_helper.pipe)([(0,
|
|
80
|
+
this.setState((0, import_helper.pipe)([(0, import_Shuttle_actions.addToTarget)(item), (0, import_Shuttle_actions.resetCheckedItems)()]), () => {
|
|
84
81
|
this.handleChange();
|
|
85
82
|
});
|
|
86
83
|
}
|
|
@@ -89,25 +86,23 @@ class ShuttleImpl extends import_react.Component {
|
|
|
89
86
|
this.removeFromTarget = (item) => {
|
|
90
87
|
const { selectedItems, onRemoveFromTarget } = this.props;
|
|
91
88
|
if (!selectedItems) {
|
|
92
|
-
this.setState((0, import_helper.pipe)([(0,
|
|
89
|
+
this.setState((0, import_helper.pipe)([(0, import_Shuttle_actions.removeFromTarget)(item)]), () => {
|
|
93
90
|
this.handleChange();
|
|
94
91
|
});
|
|
95
92
|
}
|
|
96
93
|
onRemoveFromTarget(item);
|
|
97
94
|
};
|
|
98
95
|
this.toggleItemSelection = (item) => {
|
|
99
|
-
this.setState((0,
|
|
96
|
+
this.setState((0, import_Shuttle_actions.toggleItemSelection)(item.id));
|
|
100
97
|
};
|
|
101
98
|
this.moveCheckedItems = () => {
|
|
102
99
|
const { onAddCheckedItems, selectedItems, nonSelectedItems } = this.props;
|
|
103
100
|
const { checkedItems, preparedItems } = this.state;
|
|
104
101
|
const isControlledV2 = !!selectedItems && !!nonSelectedItems;
|
|
105
|
-
const checked = isControlledV2 ? nonSelectedItems.filter(
|
|
106
|
-
(item) => checkedItems.some((check) => check === item)
|
|
107
|
-
) : checkedItems;
|
|
102
|
+
const checked = isControlledV2 ? nonSelectedItems.filter((item) => checkedItems.some((check) => check === item)) : checkedItems;
|
|
108
103
|
const items = (0, import_helper.getItemsById)(checked, preparedItems);
|
|
109
|
-
const actions = !selectedItems ? items.map((item) => (0,
|
|
110
|
-
this.setState((0, import_helper.pipe)([...actions, (0,
|
|
104
|
+
const actions = !selectedItems ? items.map((item) => (0, import_Shuttle_actions.addToTarget)(item)) : [];
|
|
105
|
+
this.setState((0, import_helper.pipe)([...actions, (0, import_Shuttle_actions.resetCheckedItems)()]), () => {
|
|
111
106
|
this.handleChange();
|
|
112
107
|
});
|
|
113
108
|
onAddCheckedItems(items);
|
|
@@ -117,12 +112,8 @@ class ShuttleImpl extends import_react.Component {
|
|
|
117
112
|
const { targetItems, hierarchyDest, movedItems } = this.state;
|
|
118
113
|
const hierarchyId = (0, import_helper.getActiveIdFromHierarchy)(hierarchyDest).id;
|
|
119
114
|
const collection = !hierarchyId ? movedItems : targetItems;
|
|
120
|
-
const oldIndex = collection.findIndex(
|
|
121
|
-
|
|
122
|
-
);
|
|
123
|
-
const newIndex = collection.findIndex(
|
|
124
|
-
(tItem) => tItem[idField] === targetItem[idField]
|
|
125
|
-
);
|
|
115
|
+
const oldIndex = collection.findIndex((tItem) => tItem[idField] === sourceItem[idField]);
|
|
116
|
+
const newIndex = collection.findIndex((tItem) => tItem[idField] === targetItem[idField]);
|
|
126
117
|
const sortedMovedItems = !hierarchyId ? (0, import_ds_utilities.arrayMove)(movedItems, oldIndex, newIndex) : movedItems;
|
|
127
118
|
const sortedItems = hierarchyId ? (0, import_ds_utilities.arrayMove)(targetItems, oldIndex, newIndex) : targetItems;
|
|
128
119
|
this.setState({
|
|
@@ -151,14 +142,7 @@ class ShuttleImpl extends import_react.Component {
|
|
|
151
142
|
}
|
|
152
143
|
render() {
|
|
153
144
|
const { idField, nonSelectedItems, moreItemsLoading, ...rest } = this.props;
|
|
154
|
-
const {
|
|
155
|
-
hierarchy,
|
|
156
|
-
hierarchyDest,
|
|
157
|
-
checkedItems,
|
|
158
|
-
movedItems,
|
|
159
|
-
preparedItems: items,
|
|
160
|
-
targetItems
|
|
161
|
-
} = this.state;
|
|
145
|
+
const { hierarchy, hierarchyDest, checkedItems, movedItems, preparedItems: items, targetItems } = this.state;
|
|
162
146
|
const {
|
|
163
147
|
state: { searchTerm, searching }
|
|
164
148
|
} = this.context;
|
|
@@ -168,20 +152,14 @@ class ShuttleImpl extends import_react.Component {
|
|
|
168
152
|
return (0, import_helper.filterBySearch)(
|
|
169
153
|
searchTerm,
|
|
170
154
|
searching
|
|
171
|
-
)(
|
|
172
|
-
(0, import_helper.getChildrenFromParent)(id)(
|
|
173
|
-
nonSelectedItems.map((it) => items.find((itt) => itt.id === it))
|
|
174
|
-
)
|
|
175
|
-
);
|
|
155
|
+
)((0, import_helper.getChildrenFromParent)(id)(nonSelectedItems.map((it) => items.find((itt) => itt.id === it))));
|
|
176
156
|
}
|
|
177
157
|
return (0, import_helper.filterBySearch)(
|
|
178
158
|
searchTerm,
|
|
179
159
|
searching
|
|
180
160
|
)(
|
|
181
161
|
items.filter(
|
|
182
|
-
(it) => nonSelectedItems.some(
|
|
183
|
-
(itt) => itt === it.id && !nonSelectedItems.some((ittt) => ittt === it.parent)
|
|
184
|
-
)
|
|
162
|
+
(it) => nonSelectedItems.some((itt) => itt === it.id && !nonSelectedItems.some((ittt) => ittt === it.parent))
|
|
185
163
|
)
|
|
186
164
|
);
|
|
187
165
|
};
|
|
@@ -198,12 +176,8 @@ class ShuttleImpl extends import_react.Component {
|
|
|
198
176
|
const handleControlledTargetItms = () => {
|
|
199
177
|
const { id } = (0, import_helper.getActiveIdFromHierarchy)(hierarchyDest);
|
|
200
178
|
if (id) {
|
|
201
|
-
return (0, import_helper.getChildrenFromParent)(
|
|
202
|
-
(
|
|
203
|
-
)(
|
|
204
|
-
this.props.selectedItems.map(
|
|
205
|
-
(it) => items.find((itt) => itt.id === it)
|
|
206
|
-
)
|
|
179
|
+
return (0, import_helper.getChildrenFromParent)((0, import_helper.getActiveIdFromHierarchy)(hierarchyDest).id)(
|
|
180
|
+
this.props.selectedItems.map((it) => items.find((itt) => itt.id === it))
|
|
207
181
|
);
|
|
208
182
|
}
|
|
209
183
|
return targetItems.filter(
|
|
@@ -218,10 +192,7 @@ class ShuttleImpl extends import_react.Component {
|
|
|
218
192
|
} else {
|
|
219
193
|
composedTargetItems = (0, import_ds_utilities.compose)((tItems) => {
|
|
220
194
|
const hierarchyId = (0, import_helper.getActiveIdFromHierarchy)(hierarchyDest).id;
|
|
221
|
-
return hierarchyId ? (0, import_ds_utilities.compose)(
|
|
222
|
-
(0, import_helper.filterMovedItems)(movedItems),
|
|
223
|
-
(0, import_helper.getChildrenFromParent)(hierarchyId)
|
|
224
|
-
)(tItems) : movedItems;
|
|
195
|
+
return hierarchyId ? (0, import_ds_utilities.compose)((0, import_helper.filterMovedItems)(movedItems), (0, import_helper.getChildrenFromParent)(hierarchyId))(tItems) : movedItems;
|
|
225
196
|
})(targetItems);
|
|
226
197
|
}
|
|
227
198
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|