@elliemae/ds-query-builder 3.0.0-next.1 → 3.0.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/DSQueryBuilder.js +118 -0
- package/dist/cjs/DSQueryBuilder.js.map +7 -0
- package/dist/cjs/components/AndOrController/AndOrController.js +208 -0
- package/dist/cjs/components/AndOrController/AndOrController.js.map +7 -0
- package/dist/cjs/components/ConditionController/ConditionController.js +116 -0
- package/dist/cjs/components/ConditionController/ConditionController.js.map +7 -0
- package/dist/cjs/components/DisplayOutput/DisplayOutput.js +92 -0
- package/dist/cjs/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/dist/cjs/components/DragContainerController/DragContainerController.js +65 -0
- package/dist/cjs/components/DragContainerController/DragContainerController.js.map +7 -0
- package/dist/cjs/components/DragControllerRow/DragControllerRow.js +83 -0
- package/dist/cjs/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js +55 -0
- package/dist/cjs/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/dist/cjs/components/Nestable/Nestable.js +264 -0
- package/dist/cjs/components/Nestable/Nestable.js.map +7 -0
- package/dist/cjs/components/Nestable/NestableItem.js +127 -0
- package/dist/cjs/components/Nestable/NestableItem.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/events.js +153 -0
- package/dist/cjs/components/Nestable/actions/events.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/getItemOptions.js +49 -0
- package/dist/cjs/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/getPaths.js +119 -0
- package/dist/cjs/components/Nestable/actions/getPaths.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/index.js +42 -0
- package/dist/cjs/components/Nestable/actions/index.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/moveItem.js +69 -0
- package/dist/cjs/components/Nestable/actions/moveItem.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/paths.js +119 -0
- package/dist/cjs/components/Nestable/actions/paths.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js +51 -0
- package/dist/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js +51 -0
- package/dist/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/dist/cjs/components/Nestable/index.js +36 -0
- package/dist/cjs/components/Nestable/index.js.map +7 -0
- package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js +36 -0
- package/dist/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/dist/cjs/components/QueryBuilderImpl.js +253 -0
- package/dist/cjs/components/QueryBuilderImpl.js.map +7 -0
- package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js +108 -0
- package/dist/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js +235 -0
- package/dist/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js +58 -0
- package/dist/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/dist/cjs/components/format/format.js +59 -0
- package/dist/cjs/components/format/format.js.map +7 -0
- package/dist/cjs/components/format/sqlFormat.js +94 -0
- package/dist/cjs/components/format/sqlFormat.js.map +7 -0
- package/dist/cjs/components/format/sqlSafeFormat.js +98 -0
- package/dist/cjs/components/format/sqlSafeFormat.js.map +7 -0
- package/dist/cjs/components/format/xmlFormat.js +94 -0
- package/dist/cjs/components/format/xmlFormat.js.map +7 -0
- package/dist/cjs/components/helpers/actions.js +253 -0
- package/dist/cjs/components/helpers/actions.js.map +7 -0
- package/dist/cjs/components/helpers/constants.js +39 -0
- package/dist/cjs/components/helpers/constants.js.map +7 -0
- package/dist/cjs/components/helpers/dependencies.js +69 -0
- package/dist/cjs/components/helpers/dependencies.js.map +7 -0
- package/dist/cjs/components/helpers/selectors.js +161 -0
- package/dist/cjs/components/helpers/selectors.js.map +7 -0
- package/dist/cjs/components/helpers/store.js +171 -0
- package/dist/cjs/components/helpers/store.js.map +7 -0
- package/dist/cjs/components/helpers/types.js +92 -0
- package/dist/cjs/components/helpers/types.js.map +7 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/propTypes.js +105 -0
- package/dist/cjs/propTypes.js.map +7 -0
- package/dist/esm/DSQueryBuilder.js +105 -0
- package/dist/esm/DSQueryBuilder.js.map +7 -0
- package/dist/esm/components/AndOrController/AndOrController.js +179 -0
- package/dist/esm/components/AndOrController/AndOrController.js.map +7 -0
- package/dist/esm/components/ConditionController/ConditionController.js +87 -0
- package/dist/esm/components/ConditionController/ConditionController.js.map +7 -0
- package/dist/esm/components/DisplayOutput/DisplayOutput.js +63 -0
- package/dist/esm/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/dist/esm/components/DragContainerController/DragContainerController.js +36 -0
- package/dist/esm/components/DragContainerController/DragContainerController.js.map +7 -0
- package/dist/esm/components/DragControllerRow/DragControllerRow.js +56 -0
- package/dist/esm/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/dist/esm/components/FieldControllerRow/FieldControllerRow.js +26 -0
- package/dist/esm/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/dist/esm/components/Nestable/Nestable.js +253 -0
- package/dist/esm/components/Nestable/Nestable.js.map +7 -0
- package/dist/esm/components/Nestable/NestableItem.js +100 -0
- package/dist/esm/components/Nestable/NestableItem.js.map +7 -0
- package/dist/esm/components/Nestable/actions/events.js +131 -0
- package/dist/esm/components/Nestable/actions/events.js.map +7 -0
- package/{esm → dist/esm}/components/Nestable/actions/getItemOptions.js +7 -11
- package/dist/esm/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/{esm → dist/esm}/components/Nestable/actions/getPaths.js +17 -43
- package/dist/esm/components/Nestable/actions/getPaths.js.map +7 -0
- package/dist/esm/components/Nestable/actions/index.js +13 -0
- package/dist/esm/components/Nestable/actions/index.js.map +7 -0
- package/dist/esm/components/Nestable/actions/moveItem.js +42 -0
- package/dist/esm/components/Nestable/actions/moveItem.js.map +7 -0
- package/{esm → dist/esm}/components/Nestable/actions/paths.js +19 -47
- package/dist/esm/components/Nestable/actions/paths.js.map +7 -0
- package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js +22 -0
- package/dist/esm/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/{esm → dist/esm}/components/Nestable/actions/tryIncreaseDepth.js +10 -22
- package/dist/esm/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/dist/esm/components/Nestable/index.js +7 -0
- package/dist/esm/components/Nestable/index.js.map +7 -0
- package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js +7 -0
- package/dist/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/dist/esm/components/QueryBuilderImpl.js +226 -0
- package/dist/esm/components/QueryBuilderImpl.js.map +7 -0
- package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js +81 -0
- package/dist/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js +208 -0
- package/dist/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js +31 -0
- package/dist/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/dist/esm/components/format/format.js +30 -0
- package/dist/esm/components/format/format.js.map +7 -0
- package/dist/esm/components/format/sqlFormat.js +65 -0
- package/dist/esm/components/format/sqlFormat.js.map +7 -0
- package/dist/esm/components/format/sqlSafeFormat.js +69 -0
- package/dist/esm/components/format/sqlSafeFormat.js.map +7 -0
- package/dist/esm/components/format/xmlFormat.js +65 -0
- package/dist/esm/components/format/xmlFormat.js.map +7 -0
- package/dist/esm/components/helpers/actions.js +230 -0
- package/dist/esm/components/helpers/actions.js.map +7 -0
- package/dist/esm/components/helpers/constants.js +10 -0
- package/dist/esm/components/helpers/constants.js.map +7 -0
- package/dist/esm/components/helpers/dependencies.js +40 -0
- package/dist/esm/components/helpers/dependencies.js.map +7 -0
- package/dist/esm/components/helpers/selectors.js +132 -0
- package/dist/esm/components/helpers/selectors.js.map +7 -0
- package/dist/esm/components/helpers/store.js +157 -0
- package/dist/esm/components/helpers/store.js.map +7 -0
- package/dist/esm/components/helpers/types.js +63 -0
- package/dist/esm/components/helpers/types.js.map +7 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/propTypes.js +76 -0
- package/dist/esm/propTypes.js.map +7 -0
- package/package.json +103 -94
- package/cjs/DSQueryBuilder.js +0 -98
- package/cjs/components/AndOrController/AndOrController.js +0 -222
- package/cjs/components/ConditionController/ConditionController.js +0 -100
- package/cjs/components/DisplayOutput/DisplayOutput.js +0 -93
- package/cjs/components/DragContainerController/DragContainerController.js +0 -45
- package/cjs/components/DragControllerRow/DragControllerRow.js +0 -47
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +0 -33
- package/cjs/components/Nestable/Nestable.js +0 -320
- package/cjs/components/Nestable/NestableItem.js +0 -111
- package/cjs/components/Nestable/actions/events.js +0 -166
- package/cjs/components/Nestable/actions/getItemOptions.js +0 -28
- package/cjs/components/Nestable/actions/getPaths.js +0 -124
- package/cjs/components/Nestable/actions/index.js +0 -28
- package/cjs/components/Nestable/actions/moveItem.js +0 -54
- package/cjs/components/Nestable/actions/paths.js +0 -126
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +0 -35
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +0 -38
- package/cjs/components/Nestable/index.js +0 -7
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +0 -13
- package/cjs/components/QueryBuilderImpl.js +0 -309
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +0 -90
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +0 -276
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +0 -29
- package/cjs/components/format/format.js +0 -33
- package/cjs/components/format/sqlFormat.js +0 -73
- package/cjs/components/format/sqlSafeFormat.js +0 -81
- package/cjs/components/format/xmlFormat.js +0 -73
- package/cjs/components/helpers/actions.js +0 -277
- package/cjs/components/helpers/constants.js +0 -11
- package/cjs/components/helpers/dependencies.js +0 -84
- package/cjs/components/helpers/selectors.js +0 -101
- package/cjs/components/helpers/store.js +0 -177
- package/cjs/components/helpers/types.js +0 -64
- package/cjs/index.js +0 -29
- package/cjs/propTypes.js +0 -97
- package/esm/DSQueryBuilder.js +0 -74
- package/esm/components/AndOrController/AndOrController.js +0 -213
- package/esm/components/ConditionController/ConditionController.js +0 -92
- package/esm/components/DisplayOutput/DisplayOutput.js +0 -87
- package/esm/components/DragContainerController/DragContainerController.js +0 -39
- package/esm/components/DragControllerRow/DragControllerRow.js +0 -39
- package/esm/components/FieldControllerRow/FieldControllerRow.js +0 -27
- package/esm/components/Nestable/Nestable.js +0 -312
- package/esm/components/Nestable/NestableItem.js +0 -103
- package/esm/components/Nestable/actions/events.js +0 -153
- package/esm/components/Nestable/actions/index.js +0 -6
- package/esm/components/Nestable/actions/moveItem.js +0 -45
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +0 -31
- package/esm/components/Nestable/index.js +0 -2
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +0 -5
- package/esm/components/QueryBuilderImpl.js +0 -301
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +0 -83
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +0 -268
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +0 -20
- package/esm/components/format/format.js +0 -31
- package/esm/components/format/sqlFormat.js +0 -69
- package/esm/components/format/sqlSafeFormat.js +0 -76
- package/esm/components/format/xmlFormat.js +0 -69
- package/esm/components/helpers/actions.js +0 -254
- package/esm/components/helpers/constants.js +0 -5
- package/esm/components/helpers/dependencies.js +0 -60
- package/esm/components/helpers/selectors.js +0 -93
- package/esm/components/helpers/store.js +0 -171
- package/esm/components/helpers/types.js +0 -52
- package/esm/index.js +0 -4
- package/esm/propTypes.js +0 -93
- package/types/DSQueryBuilder.d.ts +0 -211
- package/types/components/AndOrController/AndOrController.d.ts +0 -38
- package/types/components/ConditionController/ConditionController.d.ts +0 -16
- package/types/components/DisplayOutput/DisplayOutput.d.ts +0 -7
- package/types/components/DragContainerController/DragContainerController.d.ts +0 -9
- package/types/components/DragControllerRow/DragControllerRow.d.ts +0 -9
- package/types/components/FieldControllerRow/FieldControllerRow.d.ts +0 -9
- package/types/components/Nestable/Nestable.d.ts +0 -51
- package/types/components/Nestable/NestableItem.d.ts +0 -12
- package/types/components/Nestable/actions/events.d.ts +0 -6
- package/types/components/Nestable/actions/getItemOptions.d.ts +0 -11
- package/types/components/Nestable/actions/getPaths.d.ts +0 -5
- package/types/components/Nestable/actions/index.d.ts +0 -6
- package/types/components/Nestable/actions/moveItem.d.ts +0 -5
- package/types/components/Nestable/actions/paths.d.ts +0 -5
- package/types/components/Nestable/actions/tryDecreaseDepth.d.ts +0 -1
- package/types/components/Nestable/actions/tryIncreaseDepth.d.ts +0 -1
- package/types/components/Nestable/index.d.ts +0 -2
- package/types/components/QueryBuilderContext/QueryBuilderContext.d.ts +0 -2
- package/types/components/QueryBuilderImpl.d.ts +0 -49
- package/types/components/QueryBuilderItem/QueryBuilderItem.d.ts +0 -5
- package/types/components/QueryBuilderRow/QueryBuilderRow.d.ts +0 -12
- package/types/components/ToolBarAnimation/ToolBarAnimation.d.ts +0 -3
- package/types/components/format/format.d.ts +0 -26
- package/types/components/format/sqlFormat.d.ts +0 -5
- package/types/components/format/sqlSafeFormat.d.ts +0 -6
- package/types/components/format/xmlFormat.d.ts +0 -5
- package/types/components/helpers/actions.d.ts +0 -63
- package/types/components/helpers/constants.d.ts +0 -3
- package/types/components/helpers/dependencies.d.ts +0 -1
- package/types/components/helpers/selectors.d.ts +0 -20
- package/types/components/helpers/store.d.ts +0 -144
- package/types/components/helpers/types.d.ts +0 -50
- package/types/index.d.ts +0 -2
- package/types/propTypes.d.ts +0 -156
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var _jsx = require('@babel/runtime/helpers/jsx');
|
|
4
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
-
require('react');
|
|
13
|
-
var cn = require('classnames');
|
|
14
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
-
|
|
16
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
-
|
|
18
|
-
var _jsx__default = /*#__PURE__*/_interopDefaultLegacy(_jsx);
|
|
19
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
20
|
-
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
21
|
-
|
|
22
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
|
-
|
|
24
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
-
|
|
26
|
-
const NestableItem = _ref => {
|
|
27
|
-
let {
|
|
28
|
-
item,
|
|
29
|
-
isCopy,
|
|
30
|
-
options,
|
|
31
|
-
index,
|
|
32
|
-
isAndItem,
|
|
33
|
-
isOrItem,
|
|
34
|
-
isDraggableItem,
|
|
35
|
-
singleRow
|
|
36
|
-
} = _ref;
|
|
37
|
-
const {
|
|
38
|
-
dragItem,
|
|
39
|
-
renderItem,
|
|
40
|
-
handler,
|
|
41
|
-
childrenProp
|
|
42
|
-
} = options;
|
|
43
|
-
const isCollapsed = options.isCollapsed(item);
|
|
44
|
-
const isDragging = !isCopy && dragItem && dragItem.id === item.id;
|
|
45
|
-
const hasChildren = item[childrenProp] && item[childrenProp].length > 0;
|
|
46
|
-
let Handler;
|
|
47
|
-
const isOrGroup = item.element.type === 'group' && (item.element.condition === '' || item.element.condition === false);
|
|
48
|
-
const isAndGroup = item.element.type === 'group' && !(item.element.condition === '' || item.element.condition === false);
|
|
49
|
-
const itemProps = {
|
|
50
|
-
className: cn__default["default"]("nestable-item".concat(isCopy ? '-copy' : ''), "nestable-item".concat(isCopy ? '-copy' : '', "-").concat(item.id), "nestable-item-type-".concat(item.element.type), {
|
|
51
|
-
'is-or-group': isOrGroup,
|
|
52
|
-
'is-and-group': isAndGroup,
|
|
53
|
-
'is-and-filter': item.element.type === 'filter' && isAndItem,
|
|
54
|
-
'is-or-filter': item.element.type === 'filter' && isOrItem
|
|
55
|
-
}, {
|
|
56
|
-
'is-dragging': isDragging
|
|
57
|
-
})
|
|
58
|
-
};
|
|
59
|
-
let rowProps = {};
|
|
60
|
-
let handlerProps = {};
|
|
61
|
-
|
|
62
|
-
if (!isCopy) {
|
|
63
|
-
if (dragItem) {
|
|
64
|
-
rowProps = _objectSpread(_objectSpread({}, rowProps), {}, {
|
|
65
|
-
onMouseEnter: e => options.onMouseEnter(e, item)
|
|
66
|
-
});
|
|
67
|
-
} else {
|
|
68
|
-
handlerProps = _objectSpread(_objectSpread({}, handlerProps), {}, {
|
|
69
|
-
draggable: isDraggableItem !== false,
|
|
70
|
-
onDragStart: e => options.onDragStart(e, item)
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (handler) {
|
|
76
|
-
Handler = /*#__PURE__*/jsxRuntime.jsx("span", _objectSpread(_objectSpread({
|
|
77
|
-
className: "nestable-item-handler"
|
|
78
|
-
}, handlerProps), {}, {
|
|
79
|
-
children: handler
|
|
80
|
-
})); // Handler = React.cloneElement(handler, handlerProps);
|
|
81
|
-
} else {
|
|
82
|
-
rowProps = _objectSpread(_objectSpread({}, rowProps), handlerProps);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const childLength = item[childrenProp].length;
|
|
86
|
-
let childClass = 'single';
|
|
87
|
-
if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
|
|
88
|
-
return /*#__PURE__*/jsxRuntime.jsxs("li", _objectSpread(_objectSpread({}, itemProps), {}, {
|
|
89
|
-
children: [/*#__PURE__*/jsxRuntime.jsx("div", _objectSpread(_objectSpread({
|
|
90
|
-
className: "nestable-item-name nestable-item-name--".concat(item.element.type, " ")
|
|
91
|
-
}, rowProps), {}, {
|
|
92
|
-
children: renderItem({
|
|
93
|
-
item,
|
|
94
|
-
handler: Handler,
|
|
95
|
-
index
|
|
96
|
-
})
|
|
97
|
-
})), hasChildren && item.element.type === 'group' && !isCollapsed && /*#__PURE__*/_jsx__default["default"]("ol", {
|
|
98
|
-
className: "nestable-list nestable-child-count-".concat(childClass, " ")
|
|
99
|
-
}, void 0, item[childrenProp].map((currentitem, i) => /*#__PURE__*/_jsx__default["default"](NestableItem, {
|
|
100
|
-
index: i,
|
|
101
|
-
isAndItem: isAndGroup,
|
|
102
|
-
isCopy: isCopy,
|
|
103
|
-
isOrItem: isOrGroup,
|
|
104
|
-
item: currentitem,
|
|
105
|
-
options: options,
|
|
106
|
-
singleRow: singleRow
|
|
107
|
-
}, i)))]
|
|
108
|
-
}));
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
module.exports = NestableItem;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
9
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
10
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
11
|
-
var utils = require('@elliemae/ds-shared/utils');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
16
|
-
|
|
17
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
-
|
|
19
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
-
function onDragStart(e, item) {
|
|
21
|
-
if (e) {
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
e.stopPropagation();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
this.el = utils.closest(e.target, '.nestable-item');
|
|
27
|
-
this.startTrackMouse();
|
|
28
|
-
this.onMouseMove(e);
|
|
29
|
-
const {
|
|
30
|
-
items
|
|
31
|
-
} = this.state;
|
|
32
|
-
this.setState({
|
|
33
|
-
dragItem: item,
|
|
34
|
-
itemsOld: items
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
function onDragEnd(e, isCancel) {
|
|
38
|
-
if (e && e.preventDefault) e.preventDefault();
|
|
39
|
-
this.stopTrackMouse();
|
|
40
|
-
this.el = null; // check if filter has children
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
items
|
|
44
|
-
} = this.state;
|
|
45
|
-
const nestedInFilter = this.checkFilterChildren(items);
|
|
46
|
-
if (nestedInFilter) return this.dragRevert();
|
|
47
|
-
return isCancel ? this.dragRevert() : this.dragApply();
|
|
48
|
-
}
|
|
49
|
-
function onMouseMove(e) {
|
|
50
|
-
const {
|
|
51
|
-
group,
|
|
52
|
-
threshold
|
|
53
|
-
} = this.props;
|
|
54
|
-
const {
|
|
55
|
-
dragItem
|
|
56
|
-
} = this.state;
|
|
57
|
-
const {
|
|
58
|
-
clientX,
|
|
59
|
-
clientY
|
|
60
|
-
} = e;
|
|
61
|
-
const transformProps = utils.getTransformProps(clientX, clientY);
|
|
62
|
-
const elCopy = document.querySelector(".nestable-".concat(group, " .nestable-drag-layer > .nestable-list"));
|
|
63
|
-
|
|
64
|
-
if (!this.elCopyStyles) {
|
|
65
|
-
const offset = utils.getOffsetRect(this.el);
|
|
66
|
-
const scroll = utils.getTotalScroll(this.el);
|
|
67
|
-
this.elCopyStyles = _objectSpread({
|
|
68
|
-
marginTop: offset.top - clientY - scroll.top,
|
|
69
|
-
marginLeft: offset.left - clientX - scroll.left
|
|
70
|
-
}, transformProps);
|
|
71
|
-
} else {
|
|
72
|
-
this.elCopyStyles = _objectSpread(_objectSpread({}, this.elCopyStyles), transformProps);
|
|
73
|
-
|
|
74
|
-
for (const key in transformProps) {
|
|
75
|
-
if (transformProps.hasOwnProperty(key)) {
|
|
76
|
-
elCopy.style[key] = transformProps[key];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const diffX = clientX - this.mouse.last.x;
|
|
81
|
-
|
|
82
|
-
if (diffX >= 0 && this.mouse.shift.x >= 0 || diffX <= 0 && this.mouse.shift.x <= 0) {
|
|
83
|
-
this.mouse.shift.x += diffX;
|
|
84
|
-
} else {
|
|
85
|
-
this.mouse.shift.x = 0;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.mouse.last.x = clientX;
|
|
89
|
-
|
|
90
|
-
if (Math.abs(this.mouse.shift.x) > threshold) {
|
|
91
|
-
if (this.mouse.shift.x > 0) {
|
|
92
|
-
this.tryIncreaseDepth(dragItem);
|
|
93
|
-
} else {
|
|
94
|
-
this.tryDecreaseDepth(dragItem);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
this.mouse.shift.x = 0;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function onMouseEnter(e, item) {
|
|
102
|
-
if (e) {
|
|
103
|
-
e.preventDefault();
|
|
104
|
-
e.stopPropagation();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const {
|
|
108
|
-
collapsed,
|
|
109
|
-
childrenProp
|
|
110
|
-
} = this.props;
|
|
111
|
-
const {
|
|
112
|
-
dragItem
|
|
113
|
-
} = this.state;
|
|
114
|
-
if (dragItem.id === item.id) return;
|
|
115
|
-
const pathFrom = this.getPathById(dragItem.id);
|
|
116
|
-
const pathTo = this.getPathById(item.id); // if collapsed by default
|
|
117
|
-
// and move last (by count) child
|
|
118
|
-
// remove parent node from list of open nodes
|
|
119
|
-
|
|
120
|
-
let collapseProps = {};
|
|
121
|
-
|
|
122
|
-
if (collapsed && pathFrom.length > 1) {
|
|
123
|
-
const parent = this.getItemByPath(pathFrom.slice(0, -1));
|
|
124
|
-
|
|
125
|
-
if (parent[childrenProp].length === 1) {
|
|
126
|
-
collapseProps = this.onToggleCollapse(parent, true);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
this.moveItem({
|
|
131
|
-
dragItem,
|
|
132
|
-
pathFrom,
|
|
133
|
-
pathTo
|
|
134
|
-
}, collapseProps);
|
|
135
|
-
}
|
|
136
|
-
function onToggleCollapse(item, isGetter) {
|
|
137
|
-
const {
|
|
138
|
-
collapsed
|
|
139
|
-
} = this.props;
|
|
140
|
-
const {
|
|
141
|
-
collapsedGroups
|
|
142
|
-
} = this.state;
|
|
143
|
-
const isCollapsed = this.isCollapsed(item);
|
|
144
|
-
const newState = {
|
|
145
|
-
collapsedGroups: isCollapsed ^ collapsed ? collapsedGroups.filter(id => id !== item.id) : collapsedGroups.concat(item.id)
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
if (isGetter) {
|
|
149
|
-
return newState;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
return this.setState(newState);
|
|
153
|
-
}
|
|
154
|
-
function onKeyDown(e) {
|
|
155
|
-
if (e.which === 27) {
|
|
156
|
-
// ESC
|
|
157
|
-
this.onDragEnd(null, true);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
exports.onDragEnd = onDragEnd;
|
|
162
|
-
exports.onDragStart = onDragStart;
|
|
163
|
-
exports.onKeyDown = onKeyDown;
|
|
164
|
-
exports.onMouseEnter = onMouseEnter;
|
|
165
|
-
exports.onMouseMove = onMouseMove;
|
|
166
|
-
exports.onToggleCollapse = onToggleCollapse;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function getItemOptions() {
|
|
6
|
-
const {
|
|
7
|
-
renderItem,
|
|
8
|
-
renderCollapseIcon,
|
|
9
|
-
handler,
|
|
10
|
-
childrenProp
|
|
11
|
-
} = this.props;
|
|
12
|
-
const {
|
|
13
|
-
dragItem
|
|
14
|
-
} = this.state;
|
|
15
|
-
return {
|
|
16
|
-
dragItem,
|
|
17
|
-
childrenProp,
|
|
18
|
-
renderItem,
|
|
19
|
-
renderCollapseIcon,
|
|
20
|
-
handler,
|
|
21
|
-
onDragStart: this.onDragStart,
|
|
22
|
-
onMouseEnter: this.onMouseEnter,
|
|
23
|
-
isCollapsed: this.isCollapsed,
|
|
24
|
-
onToggleCollapse: this.onToggleCollapse
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
exports.getItemOptions = getItemOptions;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
-
require('core-js/modules/esnext.async-iterator.every.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.every.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
13
|
-
|
|
14
|
-
function getRealNextPath(prevPath, nextPath) {
|
|
15
|
-
const {
|
|
16
|
-
childrenProp
|
|
17
|
-
} = this.props;
|
|
18
|
-
const ppLastIndex = prevPath.length - 1;
|
|
19
|
-
const npLastIndex = nextPath.length - 1;
|
|
20
|
-
|
|
21
|
-
if (prevPath.length < nextPath.length) {
|
|
22
|
-
// move into deep
|
|
23
|
-
let wasShifted = false;
|
|
24
|
-
return nextPath.map((nextIndex, i) => {
|
|
25
|
-
if (wasShifted) {
|
|
26
|
-
return i === npLastIndex ? nextIndex + 1 : nextIndex;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (typeof prevPath[i] !== 'number') {
|
|
30
|
-
return nextIndex;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
|
|
34
|
-
wasShifted = true;
|
|
35
|
-
return nextIndex - 1;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return nextIndex;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (prevPath.length === nextPath.length) {
|
|
43
|
-
// if move bottom + move to item with children => make it a first child instead of swap
|
|
44
|
-
if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
|
|
45
|
-
const target = this.getItemByPath(nextPath);
|
|
46
|
-
|
|
47
|
-
if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
|
|
48
|
-
return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return nextPath;
|
|
54
|
-
}
|
|
55
|
-
function getPathById(id, items) {
|
|
56
|
-
const {
|
|
57
|
-
childrenProp
|
|
58
|
-
} = this.props;
|
|
59
|
-
let path = [];
|
|
60
|
-
items.every((item, i) => {
|
|
61
|
-
if (item.id === id) {
|
|
62
|
-
path.push(i);
|
|
63
|
-
} else if (item[childrenProp]) {
|
|
64
|
-
const childrenPath = this.getPathById(id, item[childrenProp]);
|
|
65
|
-
|
|
66
|
-
if (childrenPath.length) {
|
|
67
|
-
path = path.concat(i).concat(childrenPath);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return path.length === 0;
|
|
72
|
-
});
|
|
73
|
-
return path;
|
|
74
|
-
}
|
|
75
|
-
function getItemByPath(path, items) {
|
|
76
|
-
const {
|
|
77
|
-
childrenProp
|
|
78
|
-
} = this.props;
|
|
79
|
-
let item = null;
|
|
80
|
-
path.forEach(index => {
|
|
81
|
-
const list = item ? item[childrenProp] : items;
|
|
82
|
-
item = list[index];
|
|
83
|
-
});
|
|
84
|
-
return item;
|
|
85
|
-
}
|
|
86
|
-
function getItemDepth(item) {
|
|
87
|
-
const {
|
|
88
|
-
childrenProp
|
|
89
|
-
} = this.props;
|
|
90
|
-
let level = 1;
|
|
91
|
-
|
|
92
|
-
if (item[childrenProp].length > 0) {
|
|
93
|
-
const childrenDepths = item[childrenProp].map(this.getItemDepth);
|
|
94
|
-
level += Math.max(...childrenDepths);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return level;
|
|
98
|
-
}
|
|
99
|
-
function getSplicePath(path) {
|
|
100
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
101
|
-
const splicePath = {};
|
|
102
|
-
const numToRemove = options.numToRemove || 0;
|
|
103
|
-
const itemsToInsert = options.itemsToInsert || [];
|
|
104
|
-
const lastIndex = path.length - 1;
|
|
105
|
-
let currentPath = splicePath;
|
|
106
|
-
path.forEach((index, i) => {
|
|
107
|
-
if (i === lastIndex) {
|
|
108
|
-
currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
|
|
109
|
-
} else {
|
|
110
|
-
const nextPath = {};
|
|
111
|
-
currentPath[index] = {
|
|
112
|
-
[options.childrenProp]: nextPath
|
|
113
|
-
};
|
|
114
|
-
currentPath = nextPath;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return splicePath;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
exports.getItemByPath = getItemByPath;
|
|
121
|
-
exports.getItemDepth = getItemDepth;
|
|
122
|
-
exports.getPathById = getPathById;
|
|
123
|
-
exports.getRealNextPath = getRealNextPath;
|
|
124
|
-
exports.getSplicePath = getSplicePath;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var tryIncreaseDepth = require('./tryIncreaseDepth.js');
|
|
6
|
-
var tryDecreaseDepth = require('./tryDecreaseDepth.js');
|
|
7
|
-
var moveItem = require('./moveItem.js');
|
|
8
|
-
var paths = require('./paths.js');
|
|
9
|
-
var events = require('./events.js');
|
|
10
|
-
var getItemOptions = require('./getItemOptions.js');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.tryIncreaseDepth = tryIncreaseDepth.tryIncreaseDepth;
|
|
15
|
-
exports.tryDecreaseDepth = tryDecreaseDepth.tryDecreaseDepth;
|
|
16
|
-
exports.moveItem = moveItem.moveItem;
|
|
17
|
-
exports.getItemByPath = paths.getItemByPath;
|
|
18
|
-
exports.getItemDepth = paths.getItemDepth;
|
|
19
|
-
exports.getPathById = paths.getPathById;
|
|
20
|
-
exports.getRealNextPath = paths.getRealNextPath;
|
|
21
|
-
exports.getSplicePath = paths.getSplicePath;
|
|
22
|
-
exports.onDragEnd = events.onDragEnd;
|
|
23
|
-
exports.onDragStart = events.onDragStart;
|
|
24
|
-
exports.onKeyDown = events.onKeyDown;
|
|
25
|
-
exports.onMouseEnter = events.onMouseEnter;
|
|
26
|
-
exports.onMouseMove = events.onMouseMove;
|
|
27
|
-
exports.onToggleCollapse = events.onToggleCollapse;
|
|
28
|
-
exports.getItemOptions = getItemOptions.getItemOptions;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
8
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
10
|
-
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
11
|
-
var update = require('react-addons-update');
|
|
12
|
-
|
|
13
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
|
-
|
|
15
|
-
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
|
|
16
|
-
var update__default = /*#__PURE__*/_interopDefaultLegacy(update);
|
|
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__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
function moveItem(_ref) {
|
|
22
|
-
let {
|
|
23
|
-
dragItem,
|
|
24
|
-
pathFrom,
|
|
25
|
-
pathTo
|
|
26
|
-
} = _ref;
|
|
27
|
-
let extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
-
const {
|
|
29
|
-
childrenProp
|
|
30
|
-
} = this.props;
|
|
31
|
-
let {
|
|
32
|
-
items
|
|
33
|
-
} = this.state; // the remove action might affect the next position,
|
|
34
|
-
// so update next coordinates accordingly
|
|
35
|
-
|
|
36
|
-
const realPathTo = this.getRealNextPath(pathFrom, pathTo);
|
|
37
|
-
const removePath = this.getSplicePath(pathFrom, {
|
|
38
|
-
numToRemove: 1,
|
|
39
|
-
childrenProp
|
|
40
|
-
});
|
|
41
|
-
const insertPath = this.getSplicePath(realPathTo, {
|
|
42
|
-
numToRemove: 0,
|
|
43
|
-
itemsToInsert: [dragItem],
|
|
44
|
-
childrenProp
|
|
45
|
-
});
|
|
46
|
-
items = update__default["default"](items, removePath);
|
|
47
|
-
items = update__default["default"](items, insertPath);
|
|
48
|
-
this.setState(_objectSpread({
|
|
49
|
-
items,
|
|
50
|
-
isDirty: true
|
|
51
|
-
}, extraProps));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
exports.moveItem = moveItem;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
7
|
-
require('core-js/modules/esnext.async-iterator.every.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
9
|
-
require('core-js/modules/esnext.iterator.every.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
12
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
13
|
-
|
|
14
|
-
function getRealNextPath(prevPath, nextPath) {
|
|
15
|
-
const {
|
|
16
|
-
childrenProp
|
|
17
|
-
} = this.props;
|
|
18
|
-
const ppLastIndex = prevPath.length - 1;
|
|
19
|
-
const npLastIndex = nextPath.length - 1;
|
|
20
|
-
|
|
21
|
-
if (prevPath.length < nextPath.length) {
|
|
22
|
-
// move into deep
|
|
23
|
-
let wasShifted = false;
|
|
24
|
-
return nextPath.map((nextIndex, i) => {
|
|
25
|
-
if (wasShifted) {
|
|
26
|
-
return i === npLastIndex ? nextIndex + 1 : nextIndex;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (typeof prevPath[i] !== 'number') {
|
|
30
|
-
return nextIndex;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (nextPath[i] > prevPath[i] && i === ppLastIndex) {
|
|
34
|
-
wasShifted = true;
|
|
35
|
-
return nextIndex - 1;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return nextIndex;
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (prevPath.length === nextPath.length) {
|
|
43
|
-
// if move bottom + move to item with children => make it a first child instead of swap
|
|
44
|
-
if (nextPath[npLastIndex] > prevPath[npLastIndex]) {
|
|
45
|
-
const target = this.getItemByPath(nextPath);
|
|
46
|
-
|
|
47
|
-
if (target[childrenProp] && target[childrenProp].length && !this.isCollapsed(target)) {
|
|
48
|
-
return nextPath.slice(0, -1).concat(nextPath[npLastIndex] - 1).concat(0);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return nextPath;
|
|
54
|
-
}
|
|
55
|
-
function getPathById(id) {
|
|
56
|
-
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
57
|
-
const {
|
|
58
|
-
childrenProp
|
|
59
|
-
} = this.props;
|
|
60
|
-
let path = [];
|
|
61
|
-
items.every((item, i) => {
|
|
62
|
-
if (item.id === id) {
|
|
63
|
-
path.push(i);
|
|
64
|
-
} else if (item[childrenProp]) {
|
|
65
|
-
const childrenPath = this.getPathById(id, item[childrenProp]);
|
|
66
|
-
|
|
67
|
-
if (childrenPath.length) {
|
|
68
|
-
path = path.concat(i).concat(childrenPath);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return path.length === 0;
|
|
73
|
-
});
|
|
74
|
-
return path;
|
|
75
|
-
}
|
|
76
|
-
function getItemByPath(path) {
|
|
77
|
-
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
78
|
-
const {
|
|
79
|
-
childrenProp
|
|
80
|
-
} = this.props;
|
|
81
|
-
let item = null;
|
|
82
|
-
path.forEach(index => {
|
|
83
|
-
const list = item ? item[childrenProp] : items;
|
|
84
|
-
item = list[index];
|
|
85
|
-
});
|
|
86
|
-
return item;
|
|
87
|
-
}
|
|
88
|
-
function getItemDepth(item) {
|
|
89
|
-
const {
|
|
90
|
-
childrenProp
|
|
91
|
-
} = this.props;
|
|
92
|
-
let level = 1;
|
|
93
|
-
|
|
94
|
-
if (item[childrenProp].length > 0) {
|
|
95
|
-
const childrenDepths = item[childrenProp].map(this.getItemDepth);
|
|
96
|
-
level += Math.max(...childrenDepths);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return level;
|
|
100
|
-
}
|
|
101
|
-
function getSplicePath(path) {
|
|
102
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
103
|
-
const splicePath = {};
|
|
104
|
-
const numToRemove = options.numToRemove || 0;
|
|
105
|
-
const itemsToInsert = options.itemsToInsert || [];
|
|
106
|
-
const lastIndex = path.length - 1;
|
|
107
|
-
let currentPath = splicePath;
|
|
108
|
-
path.forEach((index, i) => {
|
|
109
|
-
if (i === lastIndex) {
|
|
110
|
-
currentPath.$splice = [[index, numToRemove, ...itemsToInsert]];
|
|
111
|
-
} else {
|
|
112
|
-
const nextPath = {};
|
|
113
|
-
currentPath[index] = {
|
|
114
|
-
[options.childrenProp]: nextPath
|
|
115
|
-
};
|
|
116
|
-
currentPath = nextPath;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return splicePath;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
exports.getItemByPath = getItemByPath;
|
|
123
|
-
exports.getItemDepth = getItemDepth;
|
|
124
|
-
exports.getPathById = getPathById;
|
|
125
|
-
exports.getRealNextPath = getRealNextPath;
|
|
126
|
-
exports.getSplicePath = getSplicePath;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function tryDecreaseDepth(dragItem) {
|
|
6
|
-
const {
|
|
7
|
-
childrenProp,
|
|
8
|
-
collapsed
|
|
9
|
-
} = this.props;
|
|
10
|
-
const pathFrom = this.getPathById(dragItem.id);
|
|
11
|
-
const itemIndex = pathFrom[pathFrom.length - 1]; // has parent
|
|
12
|
-
|
|
13
|
-
if (pathFrom.length > 1) {
|
|
14
|
-
const parent = this.getItemByPath(pathFrom.slice(0, -1)); // is last (by order) item in array
|
|
15
|
-
|
|
16
|
-
if (itemIndex + 1 === parent[childrenProp].length) {
|
|
17
|
-
const pathTo = pathFrom.slice(0, -1);
|
|
18
|
-
pathTo[pathTo.length - 1] += 1; // if collapsed by default and is last (by count) item in array remove this node from list of open nodes
|
|
19
|
-
|
|
20
|
-
let collapseProps = {};
|
|
21
|
-
|
|
22
|
-
if (collapsed && parent[childrenProp].length === 1) {
|
|
23
|
-
collapseProps = this.onToggleCollapse(parent, true);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
this.moveItem({
|
|
27
|
-
dragItem,
|
|
28
|
-
pathFrom,
|
|
29
|
-
pathTo
|
|
30
|
-
}, collapseProps);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.tryDecreaseDepth = tryDecreaseDepth;
|