@elliemae/ds-query-builder 2.2.0-alpha.4 → 3.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/DSQueryBuilder.js +97 -117
- package/cjs/components/AndOrController/AndOrController.js +162 -148
- package/cjs/components/ConditionController/ConditionController.js +72 -88
- package/cjs/components/DisplayOutput/DisplayOutput.js +68 -63
- package/cjs/components/DragContainerController/DragContainerController.js +41 -61
- package/cjs/components/DragControllerRow/DragControllerRow.js +46 -50
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +32 -54
- package/cjs/components/Nestable/Nestable.js +209 -143
- package/cjs/components/Nestable/NestableItem.js +90 -98
- package/cjs/components/Nestable/actions/events.js +95 -72
- package/cjs/components/Nestable/actions/getItemOptions.js +15 -36
- package/cjs/components/Nestable/actions/getPaths.js +51 -46
- package/cjs/components/Nestable/actions/index.js +28 -42
- package/cjs/components/Nestable/actions/moveItem.js +42 -44
- package/cjs/components/Nestable/actions/paths.js +55 -48
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +23 -39
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +26 -39
- package/cjs/components/Nestable/index.js +7 -36
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +13 -36
- package/cjs/components/QueryBuilderImpl.js +202 -118
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +78 -80
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +211 -154
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +26 -39
- package/cjs/components/format/format.js +22 -48
- package/cjs/components/format/sqlFormat.js +48 -69
- package/cjs/components/format/sqlSafeFormat.js +55 -72
- package/cjs/components/format/xmlFormat.js +50 -71
- package/cjs/components/helpers/actions.js +186 -151
- package/cjs/components/helpers/constants.js +8 -36
- package/cjs/components/helpers/dependencies.js +64 -49
- package/cjs/components/helpers/selectors.js +101 -161
- package/cjs/components/helpers/store.js +104 -86
- package/cjs/components/helpers/types.js +44 -72
- package/cjs/index.js +29 -36
- package/cjs/propTypes.js +94 -102
- package/esm/DSQueryBuilder.js +72 -103
- package/esm/components/AndOrController/AndOrController.js +147 -113
- package/esm/components/ConditionController/ConditionController.js +62 -57
- package/esm/components/DisplayOutput/DisplayOutput.js +59 -31
- package/esm/components/DragContainerController/DragContainerController.js +35 -32
- package/esm/components/DragControllerRow/DragControllerRow.js +38 -21
- package/esm/components/FieldControllerRow/FieldControllerRow.js +26 -25
- package/esm/components/Nestable/Nestable.js +186 -115
- package/esm/components/Nestable/NestableItem.js +82 -69
- package/esm/components/Nestable/actions/events.js +79 -45
- package/esm/components/Nestable/actions/getItemOptions.js +11 -7
- package/esm/components/Nestable/actions/getPaths.js +43 -17
- package/esm/components/Nestable/actions/index.js +6 -13
- package/esm/components/Nestable/actions/moveItem.js +31 -13
- package/esm/components/Nestable/actions/paths.js +47 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +19 -10
- package/esm/components/Nestable/actions/tryIncreaseDepth.js +22 -10
- package/esm/components/Nestable/index.js +2 -7
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +5 -7
- package/esm/components/QueryBuilderImpl.js +187 -82
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +70 -50
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +201 -123
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +17 -10
- package/esm/components/format/format.js +17 -16
- package/esm/components/format/sqlFormat.js +43 -39
- package/esm/components/format/sqlSafeFormat.js +50 -43
- package/esm/components/format/xmlFormat.js +45 -41
- package/esm/components/helpers/actions.js +160 -123
- package/esm/components/helpers/constants.js +2 -7
- package/esm/components/helpers/dependencies.js +39 -19
- package/esm/components/helpers/selectors.js +93 -132
- package/esm/components/helpers/store.js +82 -54
- package/esm/components/helpers/types.js +33 -44
- package/esm/index.js +4 -7
- package/esm/propTypes.js +72 -55
- package/package.json +12 -12
- package/cjs/DSQueryBuilder.js.map +0 -7
- package/cjs/components/AndOrController/AndOrController.js.map +0 -7
- package/cjs/components/ConditionController/ConditionController.js.map +0 -7
- package/cjs/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/cjs/components/DragContainerController/DragContainerController.js.map +0 -7
- package/cjs/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/cjs/components/Nestable/Nestable.js.map +0 -7
- package/cjs/components/Nestable/NestableItem.js.map +0 -7
- package/cjs/components/Nestable/actions/events.js.map +0 -7
- package/cjs/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/cjs/components/Nestable/actions/getPaths.js.map +0 -7
- package/cjs/components/Nestable/actions/index.js.map +0 -7
- package/cjs/components/Nestable/actions/moveItem.js.map +0 -7
- package/cjs/components/Nestable/actions/paths.js.map +0 -7
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/cjs/components/Nestable/index.js.map +0 -7
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/cjs/components/QueryBuilderImpl.js.map +0 -7
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/cjs/components/format/format.js.map +0 -7
- package/cjs/components/format/sqlFormat.js.map +0 -7
- package/cjs/components/format/sqlSafeFormat.js.map +0 -7
- package/cjs/components/format/xmlFormat.js.map +0 -7
- package/cjs/components/helpers/actions.js.map +0 -7
- package/cjs/components/helpers/constants.js.map +0 -7
- package/cjs/components/helpers/dependencies.js.map +0 -7
- package/cjs/components/helpers/selectors.js.map +0 -7
- package/cjs/components/helpers/store.js.map +0 -7
- package/cjs/components/helpers/types.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/propTypes.js.map +0 -7
- package/esm/DSQueryBuilder.js.map +0 -7
- package/esm/components/AndOrController/AndOrController.js.map +0 -7
- package/esm/components/ConditionController/ConditionController.js.map +0 -7
- package/esm/components/DisplayOutput/DisplayOutput.js.map +0 -7
- package/esm/components/DragContainerController/DragContainerController.js.map +0 -7
- package/esm/components/DragControllerRow/DragControllerRow.js.map +0 -7
- package/esm/components/FieldControllerRow/FieldControllerRow.js.map +0 -7
- package/esm/components/Nestable/Nestable.js.map +0 -7
- package/esm/components/Nestable/NestableItem.js.map +0 -7
- package/esm/components/Nestable/actions/events.js.map +0 -7
- package/esm/components/Nestable/actions/getItemOptions.js.map +0 -7
- package/esm/components/Nestable/actions/getPaths.js.map +0 -7
- package/esm/components/Nestable/actions/index.js.map +0 -7
- package/esm/components/Nestable/actions/moveItem.js.map +0 -7
- package/esm/components/Nestable/actions/paths.js.map +0 -7
- package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +0 -7
- package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +0 -7
- package/esm/components/Nestable/index.js.map +0 -7
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +0 -7
- package/esm/components/QueryBuilderImpl.js.map +0 -7
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +0 -7
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +0 -7
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +0 -7
- package/esm/components/format/format.js.map +0 -7
- package/esm/components/format/sqlFormat.js.map +0 -7
- package/esm/components/format/sqlSafeFormat.js.map +0 -7
- package/esm/components/format/xmlFormat.js.map +0 -7
- package/esm/components/helpers/actions.js.map +0 -7
- package/esm/components/helpers/constants.js.map +0 -7
- package/esm/components/helpers/dependencies.js.map +0 -7
- package/esm/components/helpers/selectors.js.map +0 -7
- package/esm/components/helpers/store.js.map +0 -7
- package/esm/components/helpers/types.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/propTypes.js.map +0 -7
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { convertPropToCssClassName } from
|
|
4
|
-
import { DSIconColors, DSIconSizes } from
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { convertPropToCssClassName } from '@elliemae/ds-classnames';
|
|
4
|
+
import { DSIconColors, DSIconSizes } from '@elliemae/ds-icon';
|
|
5
|
+
import { GripperVertical, MoreOptionsVert } from '@elliemae/ds-icons';
|
|
6
|
+
|
|
7
|
+
var _div;
|
|
8
|
+
|
|
9
|
+
const DragContainerController = _ref => {
|
|
10
|
+
let {
|
|
11
|
+
color = DSIconColors.NEUTRAL,
|
|
12
|
+
icon: Icon = GripperVertical,
|
|
13
|
+
size = DSIconSizes.S,
|
|
14
|
+
multipleSize = false,
|
|
15
|
+
onClick
|
|
16
|
+
} = _ref;
|
|
17
|
+
const {
|
|
18
|
+
cssClassName
|
|
19
|
+
} = convertPropToCssClassName('query-builder-drag-group');
|
|
20
|
+
return /*#__PURE__*/_jsx("div", {
|
|
21
|
+
className: "".concat(cssClassName)
|
|
22
|
+
}, void 0, /*#__PURE__*/_jsx(Icon, {
|
|
23
|
+
color: color,
|
|
24
|
+
size: size
|
|
25
|
+
}), _div || (_div = /*#__PURE__*/_jsx("div", {
|
|
20
26
|
className: "separator"
|
|
21
|
-
}),
|
|
22
|
-
color,
|
|
23
|
-
onClick,
|
|
24
|
-
size
|
|
25
|
-
}), multipleSize &&
|
|
27
|
+
})), /*#__PURE__*/_jsx(MoreOptionsVert, {
|
|
28
|
+
color: color,
|
|
29
|
+
onClick: onClick,
|
|
30
|
+
size: size
|
|
31
|
+
}), multipleSize && /*#__PURE__*/_jsx(Icon, {
|
|
26
32
|
className: "additional-drag",
|
|
27
|
-
color,
|
|
28
|
-
onClick,
|
|
29
|
-
size
|
|
33
|
+
color: color,
|
|
34
|
+
onClick: onClick,
|
|
35
|
+
size: size
|
|
30
36
|
}));
|
|
31
37
|
};
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
DragContainerController_default as default
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=DragContainerController.js.map
|
|
38
|
+
|
|
39
|
+
export { DragContainerController as default };
|
|
@@ -1,22 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';
|
|
9
|
+
import 'react';
|
|
10
|
+
import { DSIconSizes } from '@elliemae/ds-icon';
|
|
11
|
+
import { GripperVertical } from '@elliemae/ds-icons';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
|
|
14
|
+
const _excluded = ["className", "color", "icon", "size"];
|
|
15
|
+
|
|
16
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
+
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
|
|
20
|
+
const DragControllerRow = _ref => {
|
|
21
|
+
let {
|
|
22
|
+
className = 'drag-controller',
|
|
23
|
+
color = ['neutral', '500'],
|
|
24
|
+
icon: Icon = GripperVertical,
|
|
25
|
+
size = DSIconSizes.M
|
|
26
|
+
} = _ref,
|
|
27
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
|
|
29
|
+
return /*#__PURE__*/jsx("div", _objectSpread(_objectSpread({
|
|
30
|
+
className: className
|
|
31
|
+
}, rest), {}, {
|
|
32
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
33
|
+
color: color,
|
|
34
|
+
size: size
|
|
35
|
+
})
|
|
36
|
+
}));
|
|
21
37
|
};
|
|
22
|
-
|
|
38
|
+
|
|
39
|
+
export { DragControllerRow as default };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'react';
|
|
3
|
+
import { DSComboBox, DSTextBox } from '@elliemae/ds-form';
|
|
4
|
+
|
|
5
|
+
const FieldControllerRow = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
className = '',
|
|
8
|
+
onChange = () => null,
|
|
9
|
+
options = [],
|
|
10
|
+
value = '',
|
|
11
|
+
type = 'DSComboBox'
|
|
12
|
+
} = _ref;
|
|
13
|
+
return /*#__PURE__*/_jsx("div", {
|
|
14
|
+
className: className
|
|
15
|
+
}, void 0, type === 'DSComboBox' && /*#__PURE__*/_jsx(DSComboBox, {
|
|
16
|
+
onChange: onChange,
|
|
17
|
+
options: options,
|
|
18
|
+
value: value
|
|
19
|
+
}), type === 'DSTextBox' && /*#__PURE__*/_jsx(DSTextBox, {
|
|
20
|
+
fluidWidth: true,
|
|
21
|
+
onChange: onChange,
|
|
22
|
+
options: options,
|
|
23
|
+
value: value
|
|
24
|
+
}));
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
export { FieldControllerRow as default };
|
|
@@ -1,71 +1,97 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
4
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
5
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import 'core-js/modules/esnext.async-iterator.find.js';
|
|
8
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
9
|
+
import 'core-js/modules/esnext.iterator.find.js';
|
|
10
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
11
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
12
|
+
import { Component } from 'react';
|
|
13
|
+
import cn from 'classnames';
|
|
14
|
+
import { listWithChildren } from '@elliemae/ds-shared/utils';
|
|
15
|
+
import { isEqualWith } from '@elliemae/ds-utilities';
|
|
16
|
+
import { tryIncreaseDepth } from './actions/tryIncreaseDepth.js';
|
|
17
|
+
import { tryDecreaseDepth } from './actions/tryDecreaseDepth.js';
|
|
18
|
+
import { moveItem } from './actions/moveItem.js';
|
|
19
|
+
import { getItemDepth, getPathById, getItemByPath, getSplicePath, getRealNextPath } from './actions/paths.js';
|
|
20
|
+
import { onDragStart, onDragEnd, onMouseMove, onMouseEnter, onToggleCollapse, onKeyDown } from './actions/events.js';
|
|
21
|
+
import { getItemOptions } from './actions/getItemOptions.js';
|
|
22
|
+
import NestableItem from './NestableItem.js';
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
27
|
+
|
|
25
28
|
const shallowCompare = (instance, nextProps, nextState) => !isEqualWith(instance.props, nextProps) || !isEqualWith(instance.state, nextState);
|
|
29
|
+
|
|
26
30
|
class Nestable extends Component {
|
|
27
31
|
constructor(props) {
|
|
28
32
|
super(props);
|
|
33
|
+
|
|
29
34
|
this.onDragStart = (e, item) => {
|
|
30
35
|
onDragStart.call(this, e, item);
|
|
31
36
|
};
|
|
37
|
+
|
|
32
38
|
this.onDragEnd = (e, isCancel) => onDragEnd.call(this, e, isCancel);
|
|
33
|
-
|
|
39
|
+
|
|
40
|
+
this.onMouseMove = e => onMouseMove.call(this, e);
|
|
41
|
+
|
|
34
42
|
this.onMouseEnter = (e, item) => onMouseEnter.call(this, e, item);
|
|
43
|
+
|
|
35
44
|
this.onToggleCollapse = (item, isGetter) => onToggleCollapse.call(this, item, isGetter);
|
|
36
|
-
|
|
45
|
+
|
|
46
|
+
this.onKeyDown = e => onKeyDown.call(this, e);
|
|
47
|
+
|
|
37
48
|
this.getDefaultItems = () => {
|
|
38
|
-
const {
|
|
49
|
+
const {
|
|
50
|
+
items
|
|
51
|
+
} = this.state;
|
|
39
52
|
return items;
|
|
40
53
|
};
|
|
41
|
-
|
|
54
|
+
|
|
55
|
+
this.getItemDepth = item => getItemDepth.call(this, item);
|
|
56
|
+
|
|
42
57
|
this.startTrackMouse = () => {
|
|
43
|
-
document.addEventListener(
|
|
44
|
-
document.addEventListener(
|
|
45
|
-
document.addEventListener(
|
|
58
|
+
document.addEventListener('mousemove', this.onMouseMove);
|
|
59
|
+
document.addEventListener('mouseup', this.onDragEnd);
|
|
60
|
+
document.addEventListener('keydown', this.onKeyDown);
|
|
46
61
|
};
|
|
62
|
+
|
|
47
63
|
this.stopTrackMouse = () => {
|
|
48
|
-
document.removeEventListener(
|
|
49
|
-
document.removeEventListener(
|
|
50
|
-
document.removeEventListener(
|
|
64
|
+
document.removeEventListener('mousemove', this.onMouseMove);
|
|
65
|
+
document.removeEventListener('mouseup', this.onDragEnd);
|
|
66
|
+
document.removeEventListener('keydown', this.onKeyDown);
|
|
51
67
|
this.elCopyStyles = null;
|
|
52
68
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const {
|
|
69
|
+
|
|
70
|
+
this.isCollapsed = item => {
|
|
71
|
+
const {
|
|
72
|
+
collapsed
|
|
73
|
+
} = this.props;
|
|
74
|
+
const {
|
|
75
|
+
collapsedGroups
|
|
76
|
+
} = this.state;
|
|
56
77
|
return !!(collapsedGroups.indexOf(item.id) > -1 ^ collapsed);
|
|
57
78
|
};
|
|
58
|
-
|
|
79
|
+
|
|
80
|
+
this.checkFilterChildren = items => items.find(current => {
|
|
59
81
|
const {
|
|
60
|
-
element: {
|
|
82
|
+
element: {
|
|
83
|
+
type
|
|
84
|
+
},
|
|
61
85
|
children
|
|
62
86
|
} = current;
|
|
63
|
-
if (type ===
|
|
64
|
-
return true;
|
|
87
|
+
if (type === 'filter' && children.length > 0) return true;
|
|
65
88
|
return this.checkFilterChildren(children);
|
|
66
89
|
});
|
|
90
|
+
|
|
67
91
|
this.dragRevert = () => {
|
|
68
|
-
const {
|
|
92
|
+
const {
|
|
93
|
+
itemsOld
|
|
94
|
+
} = this.state;
|
|
69
95
|
this.setState({
|
|
70
96
|
items: itemsOld,
|
|
71
97
|
itemsOld: null,
|
|
@@ -73,6 +99,7 @@ class Nestable extends Component {
|
|
|
73
99
|
isDirty: false
|
|
74
100
|
});
|
|
75
101
|
};
|
|
102
|
+
|
|
76
103
|
this.state = {
|
|
77
104
|
items: [],
|
|
78
105
|
itemsOld: null,
|
|
@@ -85,101 +112,163 @@ class Nestable extends Component {
|
|
|
85
112
|
this.el = null;
|
|
86
113
|
this.elCopyStyles = null;
|
|
87
114
|
this.mouse = {
|
|
88
|
-
last: {
|
|
89
|
-
|
|
115
|
+
last: {
|
|
116
|
+
x: 0
|
|
117
|
+
},
|
|
118
|
+
shift: {
|
|
119
|
+
x: 0
|
|
120
|
+
}
|
|
90
121
|
};
|
|
91
122
|
}
|
|
123
|
+
|
|
92
124
|
componentDidMount() {
|
|
93
|
-
const {
|
|
94
|
-
|
|
125
|
+
const {
|
|
126
|
+
childrenProp
|
|
127
|
+
} = this.props;
|
|
128
|
+
let {
|
|
129
|
+
items
|
|
130
|
+
} = this.props; // make sure every item has property 'children'
|
|
131
|
+
|
|
95
132
|
items = listWithChildren(items, childrenProp);
|
|
96
|
-
this.setState({
|
|
133
|
+
this.setState({
|
|
134
|
+
items
|
|
135
|
+
});
|
|
97
136
|
}
|
|
137
|
+
|
|
98
138
|
componentWillUnmount() {
|
|
99
139
|
this.stopTrackMouse();
|
|
100
140
|
}
|
|
141
|
+
|
|
101
142
|
static getDerivedStateFromProps(props, state) {
|
|
102
|
-
const {
|
|
103
|
-
|
|
104
|
-
|
|
143
|
+
const {
|
|
144
|
+
items: itemsNew,
|
|
145
|
+
childrenProp
|
|
146
|
+
} = props;
|
|
147
|
+
const {
|
|
148
|
+
stopTrackingMouse,
|
|
149
|
+
oldProps
|
|
150
|
+
} = state;
|
|
151
|
+
|
|
152
|
+
if (shallowCompare({
|
|
153
|
+
props: oldProps,
|
|
154
|
+
state: {}
|
|
155
|
+
}, props, {})) {
|
|
105
156
|
stopTrackingMouse();
|
|
106
157
|
const extra = {};
|
|
158
|
+
|
|
107
159
|
if (oldProps.collapsed !== props.collapsed) {
|
|
108
160
|
extra.collapsedGroups = [];
|
|
109
161
|
}
|
|
110
|
-
|
|
162
|
+
|
|
163
|
+
return _objectSpread({
|
|
111
164
|
items: listWithChildren(itemsNew, childrenProp),
|
|
112
165
|
dragItem: null,
|
|
113
166
|
isDirty: false,
|
|
114
|
-
oldProps: props
|
|
115
|
-
|
|
116
|
-
};
|
|
167
|
+
oldProps: props
|
|
168
|
+
}, extra);
|
|
117
169
|
}
|
|
170
|
+
|
|
118
171
|
return null;
|
|
119
172
|
}
|
|
120
|
-
|
|
173
|
+
|
|
174
|
+
getPathById(id) {
|
|
175
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
121
176
|
return getPathById.call(this, id, items);
|
|
122
177
|
}
|
|
123
|
-
|
|
178
|
+
|
|
179
|
+
getItemByPath(path) {
|
|
180
|
+
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
124
181
|
return getItemByPath.call(this, path, items);
|
|
125
182
|
}
|
|
126
|
-
|
|
183
|
+
|
|
184
|
+
getSplicePath(path) {
|
|
185
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
127
186
|
return getSplicePath.call(this, path, options);
|
|
128
187
|
}
|
|
188
|
+
|
|
129
189
|
getRealNextPath(prevPath, nextPath) {
|
|
130
190
|
return getRealNextPath.call(this, prevPath, nextPath);
|
|
131
191
|
}
|
|
192
|
+
|
|
132
193
|
getItemOptions() {
|
|
133
194
|
return getItemOptions.call(this);
|
|
134
195
|
}
|
|
196
|
+
|
|
135
197
|
dragApply() {
|
|
136
|
-
const {
|
|
137
|
-
|
|
198
|
+
const {
|
|
199
|
+
onChange
|
|
200
|
+
} = this.props;
|
|
201
|
+
const {
|
|
202
|
+
items,
|
|
203
|
+
isDirty,
|
|
204
|
+
dragItem
|
|
205
|
+
} = this.state;
|
|
138
206
|
this.setState({
|
|
139
207
|
itemsOld: null,
|
|
140
208
|
dragItem: null,
|
|
141
209
|
isDirty: false
|
|
142
210
|
});
|
|
143
|
-
if (onChange && isDirty)
|
|
144
|
-
onChange(items, dragItem);
|
|
211
|
+
if (onChange && isDirty) onChange(items, dragItem);
|
|
145
212
|
}
|
|
213
|
+
|
|
146
214
|
tryIncreaseDepth(dragItem) {
|
|
147
215
|
tryIncreaseDepth.call(this, dragItem);
|
|
148
216
|
}
|
|
217
|
+
|
|
149
218
|
tryDecreaseDepth(dragItem) {
|
|
150
219
|
tryDecreaseDepth.call(this, dragItem);
|
|
151
220
|
}
|
|
152
|
-
|
|
153
|
-
|
|
221
|
+
|
|
222
|
+
moveItem(_ref) {
|
|
223
|
+
let {
|
|
224
|
+
dragItem,
|
|
225
|
+
pathFrom,
|
|
226
|
+
pathTo
|
|
227
|
+
} = _ref;
|
|
228
|
+
let extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
229
|
+
moveItem.call(this, {
|
|
230
|
+
dragItem,
|
|
231
|
+
pathFrom,
|
|
232
|
+
pathTo
|
|
233
|
+
}, extraProps);
|
|
154
234
|
}
|
|
235
|
+
|
|
155
236
|
renderDragLayer() {
|
|
156
|
-
const {
|
|
157
|
-
|
|
158
|
-
|
|
237
|
+
const {
|
|
238
|
+
group
|
|
239
|
+
} = this.props;
|
|
240
|
+
const {
|
|
241
|
+
dragItem
|
|
242
|
+
} = this.state;
|
|
243
|
+
const el = document.querySelector(".nestable-".concat(group, " .nestable-item-").concat(dragItem.id));
|
|
159
244
|
let listStyles = {};
|
|
245
|
+
|
|
160
246
|
if (el) {
|
|
161
247
|
listStyles.width = el.clientWidth;
|
|
162
248
|
}
|
|
249
|
+
|
|
163
250
|
if (this.elCopyStyles) {
|
|
164
|
-
listStyles = {
|
|
165
|
-
...listStyles,
|
|
166
|
-
...this.elCopyStyles
|
|
167
|
-
};
|
|
251
|
+
listStyles = _objectSpread(_objectSpread({}, listStyles), this.elCopyStyles);
|
|
168
252
|
}
|
|
253
|
+
|
|
169
254
|
const options = this.getItemOptions();
|
|
170
|
-
return
|
|
255
|
+
return /*#__PURE__*/_jsx("div", {
|
|
171
256
|
className: "nestable-drag-layer"
|
|
172
|
-
},
|
|
257
|
+
}, void 0, /*#__PURE__*/_jsx("ol", {
|
|
173
258
|
className: "nestable-list",
|
|
174
259
|
style: listStyles
|
|
175
|
-
},
|
|
260
|
+
}, void 0, /*#__PURE__*/_jsx(NestableItem, {
|
|
176
261
|
isCopy: true,
|
|
177
262
|
item: dragItem,
|
|
178
|
-
options
|
|
263
|
+
options: options
|
|
179
264
|
})));
|
|
180
265
|
}
|
|
266
|
+
|
|
181
267
|
render() {
|
|
182
|
-
const {
|
|
268
|
+
const {
|
|
269
|
+
items,
|
|
270
|
+
dragItem
|
|
271
|
+
} = this.state;
|
|
183
272
|
const {
|
|
184
273
|
group,
|
|
185
274
|
isAndItem,
|
|
@@ -190,52 +279,34 @@ class Nestable extends Component {
|
|
|
190
279
|
} = this.props;
|
|
191
280
|
const options = this.getItemOptions();
|
|
192
281
|
const childLength = items.length;
|
|
193
|
-
let childClass =
|
|
194
|
-
if (childLength === 0)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
199
|
-
className: cn("nestable", `nestable-${group}`, {
|
|
200
|
-
"is-drag-active": dragItem
|
|
282
|
+
let childClass = 'single';
|
|
283
|
+
if (childLength === 0) childClass = 'empty';else if (childLength > 1) childClass = 'multiple';
|
|
284
|
+
return /*#__PURE__*/_jsx("div", {
|
|
285
|
+
className: cn('nestable', "nestable-".concat(group), {
|
|
286
|
+
'is-drag-active': dragItem
|
|
201
287
|
})
|
|
202
|
-
},
|
|
203
|
-
className:
|
|
204
|
-
}, items.map((item, i) =>
|
|
205
|
-
key: item.id,
|
|
288
|
+
}, void 0, /*#__PURE__*/_jsx("ol", {
|
|
289
|
+
className: "nestable-list nestable-group nestable-child-count-".concat(childClass)
|
|
290
|
+
}, void 0, items.map((item, i) => /*#__PURE__*/_jsx(NestableItem, {
|
|
206
291
|
index: i,
|
|
207
|
-
isAndItem,
|
|
208
|
-
isDraggableItem,
|
|
209
|
-
isOrItem,
|
|
210
|
-
item,
|
|
211
|
-
options,
|
|
212
|
-
setDraggableItems,
|
|
213
|
-
singleRow
|
|
214
|
-
}))), dragItem && this.renderDragLayer());
|
|
292
|
+
isAndItem: isAndItem,
|
|
293
|
+
isDraggableItem: isDraggableItem,
|
|
294
|
+
isOrItem: isOrItem,
|
|
295
|
+
item: item,
|
|
296
|
+
options: options,
|
|
297
|
+
setDraggableItems: setDraggableItems,
|
|
298
|
+
singleRow: singleRow
|
|
299
|
+
}, item.id))), dragItem && this.renderDragLayer());
|
|
215
300
|
}
|
|
301
|
+
|
|
216
302
|
}
|
|
303
|
+
|
|
217
304
|
Nestable.defaultProps = {
|
|
218
305
|
items: [],
|
|
219
306
|
collapsed: false,
|
|
220
307
|
group: Math.random().toString(36).slice(2),
|
|
221
|
-
childrenProp:
|
|
222
|
-
onChange: () => {
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
Nestable.propTypes = {
|
|
226
|
-
childrenProp: PropTypes.string,
|
|
227
|
-
group: PropTypes.string,
|
|
228
|
-
items: PropTypes.arrayOf(PropTypes.shape({})),
|
|
229
|
-
collapsed: PropTypes.bool,
|
|
230
|
-
onChange: PropTypes.func,
|
|
231
|
-
isAndItem: PropTypes.bool,
|
|
232
|
-
isOrItem: PropTypes.bool,
|
|
233
|
-
isDraggableItem: PropTypes.bool,
|
|
234
|
-
setDraggableItems: PropTypes.func,
|
|
235
|
-
singleRow: PropTypes.bool
|
|
236
|
-
};
|
|
237
|
-
var Nestable_default = Nestable;
|
|
238
|
-
export {
|
|
239
|
-
Nestable_default as default
|
|
308
|
+
childrenProp: 'children',
|
|
309
|
+
onChange: () => {}
|
|
240
310
|
};
|
|
241
|
-
|
|
311
|
+
|
|
312
|
+
export { Nestable as default };
|