@elliemae/ds-query-builder 3.0.0-next.2 → 3.0.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/FieldControllerRow/FieldControllerRow.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\nimport { DSTextBox, DSComboBox } from '@elliemae/ds-form';\n\nconst FieldControllerRow = ({\n className = '',\n onChange = () => null,\n options = [],\n value = '',\n type = 'DSComboBox',\n}) => (\n <div className={className}>\n {type === 'DSComboBox' && <DSComboBox onChange={onChange} options={options} value={value} />}\n {type === 'DSTextBox' && <DSTextBox fluidWidth onChange={onChange} options={options} value={value} />}\n </div>\n);\nexport default FieldControllerRow;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;AAEA,MAAM,qBAAqB,CAAC;AAAA,EAC1B,YAAY;AAAA,EACZ,WAAW,MAAM;AAAA,EACjB,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,OAAO;AAAA,MAEP,qCAAC,OAAD;AAAA,EAAK;AAAA,GACF,SAAS,gBAAgB,qCAAC,YAAD;AAAA,EAAY;AAAA,EAAoB;AAAA,EAAkB;AAAA,IAC3E,SAAS,eAAe,qCAAC,WAAD;AAAA,EAAW,YAAU;AAAA,EAAC;AAAA,EAAoB;AAAA,EAAkB;AAAA;AAGzF,IAAO,6BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import React2, { Component } from "react";
|
|
19
|
+
import PropTypes from "prop-types";
|
|
20
|
+
import cn from "classnames";
|
|
21
|
+
import { listWithChildren } from "@elliemae/ds-shared/utils";
|
|
22
|
+
import { isEqualWith } from "@elliemae/ds-utilities";
|
|
23
|
+
import {
|
|
24
|
+
tryIncreaseDepth,
|
|
25
|
+
tryDecreaseDepth,
|
|
26
|
+
moveItem,
|
|
27
|
+
getItemOptions,
|
|
28
|
+
getRealNextPath,
|
|
29
|
+
getPathById,
|
|
30
|
+
getItemByPath,
|
|
31
|
+
getItemDepth,
|
|
32
|
+
getSplicePath,
|
|
33
|
+
onDragStart,
|
|
34
|
+
onDragEnd,
|
|
35
|
+
onMouseMove,
|
|
36
|
+
onMouseEnter,
|
|
37
|
+
onToggleCollapse,
|
|
38
|
+
onKeyDown
|
|
39
|
+
} from "./actions";
|
|
40
|
+
import NestableItem from "./NestableItem";
|
|
41
|
+
const shallowCompare = (instance, nextProps, nextState) => !isEqualWith(instance.props, nextProps) || !isEqualWith(instance.state, nextState);
|
|
42
|
+
class Nestable extends Component {
|
|
43
|
+
constructor(props) {
|
|
44
|
+
super(props);
|
|
45
|
+
this.onDragStart = (e, item) => {
|
|
46
|
+
onDragStart.call(this, e, item);
|
|
47
|
+
};
|
|
48
|
+
this.onDragEnd = (e, isCancel) => onDragEnd.call(this, e, isCancel);
|
|
49
|
+
this.onMouseMove = (e) => onMouseMove.call(this, e);
|
|
50
|
+
this.onMouseEnter = (e, item) => onMouseEnter.call(this, e, item);
|
|
51
|
+
this.onToggleCollapse = (item, isGetter) => onToggleCollapse.call(this, item, isGetter);
|
|
52
|
+
this.onKeyDown = (e) => onKeyDown.call(this, e);
|
|
53
|
+
this.getDefaultItems = () => {
|
|
54
|
+
const { items } = this.state;
|
|
55
|
+
return items;
|
|
56
|
+
};
|
|
57
|
+
this.getItemDepth = (item) => getItemDepth.call(this, item);
|
|
58
|
+
this.startTrackMouse = () => {
|
|
59
|
+
document.addEventListener("mousemove", this.onMouseMove);
|
|
60
|
+
document.addEventListener("mouseup", this.onDragEnd);
|
|
61
|
+
document.addEventListener("keydown", this.onKeyDown);
|
|
62
|
+
};
|
|
63
|
+
this.stopTrackMouse = () => {
|
|
64
|
+
document.removeEventListener("mousemove", this.onMouseMove);
|
|
65
|
+
document.removeEventListener("mouseup", this.onDragEnd);
|
|
66
|
+
document.removeEventListener("keydown", this.onKeyDown);
|
|
67
|
+
this.elCopyStyles = null;
|
|
68
|
+
};
|
|
69
|
+
this.isCollapsed = (item) => {
|
|
70
|
+
const { collapsed } = this.props;
|
|
71
|
+
const { collapsedGroups } = this.state;
|
|
72
|
+
return !!(collapsedGroups.indexOf(item.id) > -1 ^ collapsed);
|
|
73
|
+
};
|
|
74
|
+
this.checkFilterChildren = (items) => items.find((current) => {
|
|
75
|
+
const {
|
|
76
|
+
element: { type },
|
|
77
|
+
children
|
|
78
|
+
} = current;
|
|
79
|
+
if (type === "filter" && children.length > 0)
|
|
80
|
+
return true;
|
|
81
|
+
return this.checkFilterChildren(children);
|
|
82
|
+
});
|
|
83
|
+
this.dragRevert = () => {
|
|
84
|
+
const { itemsOld } = this.state;
|
|
85
|
+
this.setState({
|
|
86
|
+
items: itemsOld,
|
|
87
|
+
itemsOld: null,
|
|
88
|
+
dragItem: null,
|
|
89
|
+
isDirty: false
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
this.state = {
|
|
93
|
+
items: [],
|
|
94
|
+
itemsOld: null,
|
|
95
|
+
dragItem: null,
|
|
96
|
+
isDirty: false,
|
|
97
|
+
collapsedGroups: [],
|
|
98
|
+
stopTrackingMouse: this.stopTrackMouse.bind(this),
|
|
99
|
+
oldProps: props
|
|
100
|
+
};
|
|
101
|
+
this.el = null;
|
|
102
|
+
this.elCopyStyles = null;
|
|
103
|
+
this.mouse = {
|
|
104
|
+
last: { x: 0 },
|
|
105
|
+
shift: { x: 0 }
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
componentDidMount() {
|
|
109
|
+
const { childrenProp } = this.props;
|
|
110
|
+
let { items } = this.props;
|
|
111
|
+
items = listWithChildren(items, childrenProp);
|
|
112
|
+
this.setState({ items });
|
|
113
|
+
}
|
|
114
|
+
componentWillUnmount() {
|
|
115
|
+
this.stopTrackMouse();
|
|
116
|
+
}
|
|
117
|
+
static getDerivedStateFromProps(props, state) {
|
|
118
|
+
const { items: itemsNew, childrenProp } = props;
|
|
119
|
+
const { stopTrackingMouse, oldProps } = state;
|
|
120
|
+
if (shallowCompare({ props: oldProps, state: {} }, props, {})) {
|
|
121
|
+
stopTrackingMouse();
|
|
122
|
+
const extra = {};
|
|
123
|
+
if (oldProps.collapsed !== props.collapsed) {
|
|
124
|
+
extra.collapsedGroups = [];
|
|
125
|
+
}
|
|
126
|
+
return __spreadValues({
|
|
127
|
+
items: listWithChildren(itemsNew, childrenProp),
|
|
128
|
+
dragItem: null,
|
|
129
|
+
isDirty: false,
|
|
130
|
+
oldProps: props
|
|
131
|
+
}, extra);
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
getPathById(id, items = this.getDefaultItems()) {
|
|
136
|
+
return getPathById.call(this, id, items);
|
|
137
|
+
}
|
|
138
|
+
getItemByPath(path, items = this.getDefaultItems()) {
|
|
139
|
+
return getItemByPath.call(this, path, items);
|
|
140
|
+
}
|
|
141
|
+
getSplicePath(path, options = {}) {
|
|
142
|
+
return getSplicePath.call(this, path, options);
|
|
143
|
+
}
|
|
144
|
+
getRealNextPath(prevPath, nextPath) {
|
|
145
|
+
return getRealNextPath.call(this, prevPath, nextPath);
|
|
146
|
+
}
|
|
147
|
+
getItemOptions() {
|
|
148
|
+
return getItemOptions.call(this);
|
|
149
|
+
}
|
|
150
|
+
dragApply() {
|
|
151
|
+
const { onChange } = this.props;
|
|
152
|
+
const { items, isDirty, dragItem } = this.state;
|
|
153
|
+
this.setState({
|
|
154
|
+
itemsOld: null,
|
|
155
|
+
dragItem: null,
|
|
156
|
+
isDirty: false
|
|
157
|
+
});
|
|
158
|
+
if (onChange && isDirty)
|
|
159
|
+
onChange(items, dragItem);
|
|
160
|
+
}
|
|
161
|
+
tryIncreaseDepth(dragItem) {
|
|
162
|
+
tryIncreaseDepth.call(this, dragItem);
|
|
163
|
+
}
|
|
164
|
+
tryDecreaseDepth(dragItem) {
|
|
165
|
+
tryDecreaseDepth.call(this, dragItem);
|
|
166
|
+
}
|
|
167
|
+
moveItem({ dragItem, pathFrom, pathTo }, extraProps = {}) {
|
|
168
|
+
moveItem.call(this, { dragItem, pathFrom, pathTo }, extraProps);
|
|
169
|
+
}
|
|
170
|
+
renderDragLayer() {
|
|
171
|
+
const { group } = this.props;
|
|
172
|
+
const { dragItem } = this.state;
|
|
173
|
+
const el = document.querySelector(`.nestable-${group} .nestable-item-${dragItem.id}`);
|
|
174
|
+
let listStyles = {};
|
|
175
|
+
if (el) {
|
|
176
|
+
listStyles.width = el.clientWidth;
|
|
177
|
+
}
|
|
178
|
+
if (this.elCopyStyles) {
|
|
179
|
+
listStyles = __spreadValues(__spreadValues({}, listStyles), this.elCopyStyles);
|
|
180
|
+
}
|
|
181
|
+
const options = this.getItemOptions();
|
|
182
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
183
|
+
className: "nestable-drag-layer"
|
|
184
|
+
}, /* @__PURE__ */ React2.createElement("ol", {
|
|
185
|
+
className: "nestable-list",
|
|
186
|
+
style: listStyles
|
|
187
|
+
}, /* @__PURE__ */ React2.createElement(NestableItem, {
|
|
188
|
+
isCopy: true,
|
|
189
|
+
item: dragItem,
|
|
190
|
+
options
|
|
191
|
+
})));
|
|
192
|
+
}
|
|
193
|
+
render() {
|
|
194
|
+
const { items, dragItem } = this.state;
|
|
195
|
+
const {
|
|
196
|
+
group,
|
|
197
|
+
isAndItem,
|
|
198
|
+
isOrItem,
|
|
199
|
+
isDraggableItem,
|
|
200
|
+
setDraggableItems,
|
|
201
|
+
singleRow
|
|
202
|
+
} = this.props;
|
|
203
|
+
const options = this.getItemOptions();
|
|
204
|
+
const childLength = items.length;
|
|
205
|
+
let childClass = "single";
|
|
206
|
+
if (childLength === 0)
|
|
207
|
+
childClass = "empty";
|
|
208
|
+
else if (childLength > 1)
|
|
209
|
+
childClass = "multiple";
|
|
210
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
211
|
+
className: cn("nestable", `nestable-${group}`, {
|
|
212
|
+
"is-drag-active": dragItem
|
|
213
|
+
})
|
|
214
|
+
}, /* @__PURE__ */ React2.createElement("ol", {
|
|
215
|
+
className: `nestable-list nestable-group nestable-child-count-${childClass}`
|
|
216
|
+
}, items.map((item, i) => /* @__PURE__ */ React2.createElement(NestableItem, {
|
|
217
|
+
key: item.id,
|
|
218
|
+
index: i,
|
|
219
|
+
isAndItem,
|
|
220
|
+
isDraggableItem,
|
|
221
|
+
isOrItem,
|
|
222
|
+
item,
|
|
223
|
+
options,
|
|
224
|
+
setDraggableItems,
|
|
225
|
+
singleRow
|
|
226
|
+
}))), dragItem && this.renderDragLayer());
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
Nestable.defaultProps = {
|
|
230
|
+
items: [],
|
|
231
|
+
collapsed: false,
|
|
232
|
+
group: Math.random().toString(36).slice(2),
|
|
233
|
+
childrenProp: "children",
|
|
234
|
+
onChange: () => {
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
Nestable.propTypes = {
|
|
238
|
+
childrenProp: PropTypes.string,
|
|
239
|
+
group: PropTypes.string,
|
|
240
|
+
items: PropTypes.arrayOf(PropTypes.shape({})),
|
|
241
|
+
collapsed: PropTypes.bool,
|
|
242
|
+
onChange: PropTypes.func,
|
|
243
|
+
isAndItem: PropTypes.bool,
|
|
244
|
+
isOrItem: PropTypes.bool,
|
|
245
|
+
isDraggableItem: PropTypes.bool,
|
|
246
|
+
setDraggableItems: PropTypes.func,
|
|
247
|
+
singleRow: PropTypes.bool
|
|
248
|
+
};
|
|
249
|
+
var Nestable_default = Nestable;
|
|
250
|
+
export {
|
|
251
|
+
Nestable_default as default
|
|
252
|
+
};
|
|
253
|
+
//# sourceMappingURL=Nestable.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/Nestable/Nestable.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-bitwise, max-lines */\nimport React, { Component } from 'react';\nimport PropTypes from 'prop-types';\nimport cn from 'classnames';\nimport { listWithChildren } from '@elliemae/ds-shared/utils';\nimport { isEqualWith } from '@elliemae/ds-utilities';\nimport {\n tryIncreaseDepth,\n tryDecreaseDepth,\n moveItem,\n getItemOptions,\n getRealNextPath,\n getPathById,\n getItemByPath,\n getItemDepth,\n getSplicePath,\n onDragStart,\n onDragEnd,\n onMouseMove,\n onMouseEnter,\n onToggleCollapse,\n onKeyDown,\n} from './actions';\n\nimport NestableItem from './NestableItem';\n\nconst shallowCompare = (instance, nextProps, nextState) =>\n !isEqualWith(instance.props, nextProps) ||\n !isEqualWith(instance.state, nextState);\n\nclass Nestable extends Component {\n constructor(props) {\n super(props);\n this.state = {\n items: [],\n itemsOld: null,\n dragItem: null,\n isDirty: false,\n collapsedGroups: [],\n stopTrackingMouse: this.stopTrackMouse.bind(this),\n oldProps: props,\n };\n\n this.el = null;\n this.elCopyStyles = null;\n this.mouse = {\n last: { x: 0 },\n shift: { x: 0 },\n };\n }\n\n componentDidMount() {\n const { childrenProp } = this.props;\n let { items } = this.props;\n // make sure every item has property 'children'\n items = listWithChildren(items, childrenProp);\n this.setState({ items });\n }\n\n componentWillUnmount() {\n this.stopTrackMouse();\n }\n\n static getDerivedStateFromProps(props, state) {\n const { items: itemsNew, childrenProp } = props;\n const { stopTrackingMouse, oldProps } = state;\n\n if (shallowCompare({ props: oldProps, state: {} }, props, {})) {\n stopTrackingMouse();\n const extra = {};\n if (oldProps.collapsed !== props.collapsed) {\n extra.collapsedGroups = [];\n }\n return {\n items: listWithChildren(itemsNew, childrenProp),\n dragItem: null,\n isDirty: false,\n oldProps: props,\n ...extra,\n };\n }\n return null;\n }\n\n onDragStart = (e, item) => {\n onDragStart.call(this, e, item);\n };\n\n onDragEnd = (e, isCancel) => onDragEnd.call(this, e, isCancel);\n\n onMouseMove = (e) => onMouseMove.call(this, e);\n\n onMouseEnter = (e, item) => onMouseEnter.call(this, e, item);\n\n onToggleCollapse = (item, isGetter) =>\n onToggleCollapse.call(this, item, isGetter);\n\n onKeyDown = (e) => onKeyDown.call(this, e);\n\n getDefaultItems = () => {\n const { items } = this.state;\n return items;\n };\n\n getPathById(id, items = this.getDefaultItems()) {\n return getPathById.call(this, id, items);\n }\n\n getItemByPath(path, items = this.getDefaultItems()) {\n return getItemByPath.call(this, path, items);\n }\n\n getItemDepth = (item) => getItemDepth.call(this, item);\n\n getSplicePath(path, options = {}) {\n return getSplicePath.call(this, path, options);\n }\n\n getRealNextPath(prevPath, nextPath) {\n return getRealNextPath.call(this, prevPath, nextPath);\n }\n\n getItemOptions() {\n return getItemOptions.call(this);\n }\n\n startTrackMouse = () => {\n document.addEventListener('mousemove', this.onMouseMove);\n document.addEventListener('mouseup', this.onDragEnd);\n document.addEventListener('keydown', this.onKeyDown);\n };\n\n stopTrackMouse = () => {\n document.removeEventListener('mousemove', this.onMouseMove);\n document.removeEventListener('mouseup', this.onDragEnd);\n document.removeEventListener('keydown', this.onKeyDown);\n this.elCopyStyles = null;\n };\n\n isCollapsed = (item) => {\n const { collapsed } = this.props;\n const { collapsedGroups } = this.state;\n return !!((collapsedGroups.indexOf(item.id) > -1) ^ collapsed);\n };\n\n checkFilterChildren = (items) =>\n items.find((current) => {\n const {\n element: { type },\n children,\n } = current;\n if (type === 'filter' && children.length > 0) return true;\n return this.checkFilterChildren(children);\n });\n\n dragRevert = () => {\n const { itemsOld } = this.state;\n\n this.setState({\n items: itemsOld,\n itemsOld: null,\n dragItem: null,\n isDirty: false,\n });\n };\n\n dragApply() {\n const { onChange } = this.props;\n const { items, isDirty, dragItem } = this.state;\n\n this.setState({\n itemsOld: null,\n dragItem: null,\n isDirty: false,\n });\n\n if (onChange && isDirty) onChange(items, dragItem);\n }\n\n tryIncreaseDepth(dragItem) {\n tryIncreaseDepth.call(this, dragItem);\n }\n\n tryDecreaseDepth(dragItem) {\n tryDecreaseDepth.call(this, dragItem);\n }\n\n moveItem({ dragItem, pathFrom, pathTo }, extraProps = {}) {\n moveItem.call(this, { dragItem, pathFrom, pathTo }, extraProps);\n }\n\n renderDragLayer() {\n const { group } = this.props;\n const { dragItem } = this.state;\n const el = document.querySelector(\n `.nestable-${group} .nestable-item-${dragItem.id}`,\n );\n\n let listStyles = {};\n if (el) {\n listStyles.width = el.clientWidth;\n }\n if (this.elCopyStyles) {\n listStyles = {\n ...listStyles,\n ...this.elCopyStyles,\n };\n }\n\n const options = this.getItemOptions();\n\n return (\n <div className=\"nestable-drag-layer\">\n <ol className=\"nestable-list\" style={listStyles}>\n <NestableItem isCopy item={dragItem} options={options} />\n </ol>\n </div>\n );\n }\n\n render() {\n const { items, dragItem } = this.state;\n const {\n group,\n isAndItem,\n isOrItem,\n isDraggableItem,\n setDraggableItems,\n singleRow,\n } = this.props;\n const options = this.getItemOptions();\n const childLength = items.length;\n let childClass = 'single';\n if (childLength === 0) childClass = 'empty';\n else if (childLength > 1) childClass = 'multiple';\n\n return (\n <div\n className={cn('nestable', `nestable-${group}`, {\n 'is-drag-active': dragItem,\n })}\n >\n <ol\n className={`nestable-list nestable-group nestable-child-count-${childClass}`}\n >\n {items.map((item, i) => (\n <NestableItem\n key={item.id}\n index={i}\n isAndItem={isAndItem}\n isDraggableItem={isDraggableItem}\n isOrItem={isOrItem}\n item={item}\n options={options}\n setDraggableItems={setDraggableItems}\n singleRow={singleRow}\n />\n ))}\n </ol>\n {dragItem && this.renderDragLayer()}\n </div>\n );\n }\n}\n\nNestable.defaultProps = {\n items: [],\n collapsed: false,\n group: Math.random().toString(36).slice(2),\n childrenProp: 'children',\n onChange: () => {},\n};\n\nNestable.propTypes = {\n childrenProp: PropTypes.string,\n group: PropTypes.string,\n items: PropTypes.arrayOf(PropTypes.shape({})),\n collapsed: PropTypes.bool,\n onChange: PropTypes.func,\n isAndItem: PropTypes.bool,\n isOrItem: PropTypes.bool,\n isDraggableItem: PropTypes.bool,\n setDraggableItems: PropTypes.func,\n singleRow: PropTypes.bool,\n};\n\nexport default Nestable;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA;AAEA,MAAM,iBAAiB,CAAC,UAAU,WAAW,cAC3C,CAAC,YAAY,SAAS,OAAO,cAC7B,CAAC,YAAY,SAAS,OAAO;AAE/B,uBAAuB,UAAU;AAAA,EAC/B,YAAY,OAAO;AACjB,UAAM;AAoDR,uBAAc,CAAC,GAAG,SAAS;AACzB,kBAAY,KAAK,MAAM,GAAG;AAAA;AAG5B,qBAAY,CAAC,GAAG,aAAa,UAAU,KAAK,MAAM,GAAG;AAErD,uBAAc,CAAC,MAAM,YAAY,KAAK,MAAM;AAE5C,wBAAe,CAAC,GAAG,SAAS,aAAa,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AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,UAIL,YAAY,KAAK;AAAA;AAAA;AAM1B,SAAS,eAAe;AAAA,EACtB,OAAO;AAAA,EACP,WAAW;AAAA,EACX,OAAO,KAAK,SAAS,SAAS,IAAI,MAAM;AAAA,EACxC,cAAc;AAAA,EACd,UAAU,MAAM;AAAA;AAAA;AAGlB,SAAS,YAAY;AAAA,EACnB,cAAc,UAAU;AAAA,EACxB,OAAO,UAAU;AAAA,EACjB,OAAO,UAAU,QAAQ,UAAU,MAAM;AAAA,EACzC,WAAW,UAAU;AAAA,EACrB,UAAU,UAAU;AAAA,EACpB,WAAW,UAAU;AAAA,EACrB,UAAU,UAAU;AAAA,EACpB,iBAAiB,UAAU;AAAA,EAC3B,mBAAmB,UAAU;AAAA,EAC7B,WAAW,UAAU;AAAA;AAGvB,IAAO,mBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import React2 from "react";
|
|
22
|
+
import cn from "classnames";
|
|
23
|
+
const NestableItem = ({
|
|
24
|
+
item,
|
|
25
|
+
isCopy,
|
|
26
|
+
options,
|
|
27
|
+
index,
|
|
28
|
+
isAndItem,
|
|
29
|
+
isOrItem,
|
|
30
|
+
isDraggableItem,
|
|
31
|
+
singleRow
|
|
32
|
+
}) => {
|
|
33
|
+
const { dragItem, renderItem, handler, childrenProp } = options;
|
|
34
|
+
const isCollapsed = options.isCollapsed(item);
|
|
35
|
+
const isDragging = !isCopy && dragItem && dragItem.id === item.id;
|
|
36
|
+
const hasChildren = item[childrenProp] && item[childrenProp].length > 0;
|
|
37
|
+
let Handler;
|
|
38
|
+
const isOrGroup = item.element.type === "group" && (item.element.condition === "" || item.element.condition === false);
|
|
39
|
+
const isAndGroup = item.element.type === "group" && !(item.element.condition === "" || item.element.condition === false);
|
|
40
|
+
const itemProps = {
|
|
41
|
+
className: cn(`nestable-item${isCopy ? "-copy" : ""}`, `nestable-item${isCopy ? "-copy" : ""}-${item.id}`, `nestable-item-type-${item.element.type}`, {
|
|
42
|
+
"is-or-group": isOrGroup,
|
|
43
|
+
"is-and-group": isAndGroup,
|
|
44
|
+
"is-and-filter": item.element.type === "filter" && isAndItem,
|
|
45
|
+
"is-or-filter": item.element.type === "filter" && isOrItem
|
|
46
|
+
}, {
|
|
47
|
+
"is-dragging": isDragging
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
let rowProps = {};
|
|
51
|
+
let handlerProps = {};
|
|
52
|
+
if (!isCopy) {
|
|
53
|
+
if (dragItem) {
|
|
54
|
+
rowProps = __spreadProps(__spreadValues({}, rowProps), {
|
|
55
|
+
onMouseEnter: (e) => options.onMouseEnter(e, item)
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
handlerProps = __spreadProps(__spreadValues({}, handlerProps), {
|
|
59
|
+
draggable: isDraggableItem !== false,
|
|
60
|
+
onDragStart: (e) => options.onDragStart(e, item)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (handler) {
|
|
65
|
+
Handler = /* @__PURE__ */ React2.createElement("span", __spreadValues({
|
|
66
|
+
className: "nestable-item-handler"
|
|
67
|
+
}, handlerProps), handler);
|
|
68
|
+
} else {
|
|
69
|
+
rowProps = __spreadValues(__spreadValues({}, rowProps), handlerProps);
|
|
70
|
+
}
|
|
71
|
+
const childLength = item[childrenProp].length;
|
|
72
|
+
let childClass = "single";
|
|
73
|
+
if (childLength === 0)
|
|
74
|
+
childClass = "empty";
|
|
75
|
+
else if (childLength > 1)
|
|
76
|
+
childClass = "multiple";
|
|
77
|
+
return /* @__PURE__ */ React2.createElement("li", __spreadValues({}, itemProps), /* @__PURE__ */ React2.createElement("div", __spreadValues({
|
|
78
|
+
className: `nestable-item-name nestable-item-name--${item.element.type} `
|
|
79
|
+
}, rowProps), renderItem({
|
|
80
|
+
item,
|
|
81
|
+
handler: Handler,
|
|
82
|
+
index
|
|
83
|
+
})), hasChildren && item.element.type === "group" && !isCollapsed && /* @__PURE__ */ React2.createElement("ol", {
|
|
84
|
+
className: `nestable-list nestable-child-count-${childClass} `
|
|
85
|
+
}, item[childrenProp].map((currentitem, i) => /* @__PURE__ */ React2.createElement(NestableItem, {
|
|
86
|
+
key: i,
|
|
87
|
+
index: i,
|
|
88
|
+
isAndItem: isAndGroup,
|
|
89
|
+
isCopy,
|
|
90
|
+
isOrItem: isOrGroup,
|
|
91
|
+
item: currentitem,
|
|
92
|
+
options,
|
|
93
|
+
singleRow
|
|
94
|
+
}))));
|
|
95
|
+
};
|
|
96
|
+
var NestableItem_default = NestableItem;
|
|
97
|
+
export {
|
|
98
|
+
NestableItem_default as default
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=NestableItem.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/components/Nestable/NestableItem.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-statements */\nimport React from 'react';\nimport cn from 'classnames';\n\nconst NestableItem = ({\n item,\n isCopy,\n options,\n index,\n isAndItem,\n isOrItem,\n isDraggableItem,\n singleRow,\n}) => {\n const { dragItem, renderItem, handler, childrenProp } = options;\n\n const isCollapsed = options.isCollapsed(item);\n const isDragging = !isCopy && dragItem && dragItem.id === item.id;\n const hasChildren = item[childrenProp] && item[childrenProp].length > 0;\n\n let Handler;\n const isOrGroup =\n item.element.type === 'group' &&\n (item.element.condition === '' || item.element.condition === false);\n const isAndGroup =\n item.element.type === 'group' &&\n !(item.element.condition === '' || item.element.condition === false);\n\n const itemProps = {\n className: cn(\n `nestable-item${isCopy ? '-copy' : ''}`,\n `nestable-item${isCopy ? '-copy' : ''}-${item.id}`,\n `nestable-item-type-${item.element.type}`,\n {\n 'is-or-group': isOrGroup,\n 'is-and-group': isAndGroup,\n 'is-and-filter': item.element.type === 'filter' && isAndItem,\n 'is-or-filter': item.element.type === 'filter' && isOrItem,\n },\n {\n 'is-dragging': isDragging,\n },\n ),\n };\n\n let rowProps = {};\n let handlerProps = {};\n if (!isCopy) {\n if (dragItem) {\n rowProps = {\n ...rowProps,\n onMouseEnter: e => options.onMouseEnter(e, item),\n };\n } else {\n handlerProps = {\n ...handlerProps,\n draggable: isDraggableItem !== false,\n onDragStart: e => options.onDragStart(e, item),\n };\n }\n }\n\n if (handler) {\n Handler = (\n <span className=\"nestable-item-handler\" {...handlerProps}>\n {handler}\n </span>\n );\n // Handler = React.cloneElement(handler, handlerProps);\n } else {\n rowProps = {\n ...rowProps,\n ...handlerProps,\n };\n }\n\n const childLength = item[childrenProp].length;\n let childClass = 'single';\n if (childLength === 0) childClass = 'empty';\n else if (childLength > 1) childClass = 'multiple';\n\n return (\n <li {...itemProps}>\n <div\n className={`nestable-item-name nestable-item-name--${item.element.type} `}\n {...rowProps}\n >\n {renderItem({\n item,\n handler: Handler,\n index,\n })}\n </div>\n {hasChildren && item.element.type === 'group' && !isCollapsed && (\n <ol className={`nestable-list nestable-child-count-${childClass} `}>\n {item[childrenProp].map((currentitem, i) => (\n <NestableItem\n key={i}\n index={i}\n isAndItem={isAndGroup}\n isCopy={isCopy}\n isOrItem={isOrGroup}\n item={currentitem}\n options={options}\n singleRow={singleRow}\n />\n ))}\n </ol>\n )}\n </li>\n );\n};\n\nexport default NestableItem;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAEA,MAAM,eAAe,CAAC;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,MACI;AACJ,QAAM,EAAE,UAAU,YAAY,SAAS,iBAAiB;AAExD,QAAM,cAAc,QAAQ,YAAY;AACxC,QAAM,aAAa,CAAC,UAAU,YAAY,SAAS,OAAO,KAAK;AAC/D,QAAM,cAAc,KAAK,iBAAiB,KAAK,cAAc,SAAS;AAEtE,MAAI;AACJ,QAAM,YACJ,KAAK,QAAQ,SAAS,WACrB,MAAK,QAAQ,cAAc,MAAM,KAAK,QAAQ,cAAc;AAC/D,QAAM,aACJ,KAAK,QAAQ,SAAS,WACtB,CAAE,MAAK,QAAQ,cAAc,MAAM,KAAK,QAAQ,cAAc;AAEhE,QAAM,YAAY;AAAA,IAChB,WAAW,GACT,gBAAgB,SAAS,UAAU,MACnC,gBAAgB,SAAS,UAAU,MAAM,KAAK,MAC9C,sBAAsB,KAAK,QAAQ,QACnC;AAAA,MACE,eAAe;AAAA,MACf,gBAAgB;AAAA,MAChB,iBAAiB,KAAK,QAAQ,SAAS,YAAY;AAAA,MACnD,gBAAgB,KAAK,QAAQ,SAAS,YAAY;AAAA,OAEpD;AAAA,MACE,eAAe;AAAA;AAAA;AAKrB,MAAI,WAAW;AACf,MAAI,eAAe;AACnB,MAAI,CAAC,QAAQ;AACX,QAAI,UAAU;AACZ,iBAAW,iCACN,WADM;AAAA,QAET,cAAc,OAAK,QAAQ,aAAa,GAAG;AAAA;AAAA,WAExC;AACL,qBAAe,iCACV,eADU;AAAA,QAEb,WAAW,oBAAoB;AAAA,QAC/B,aAAa,OAAK,QAAQ,YAAY,GAAG;AAAA;AAAA;AAAA;AAK/C,MAAI,SAAS;AACX,cACE,qCAAC,QAAD;AAAA,MAAM,WAAU;AAAA,OAA4B,eACzC;AAAA,SAIA;AACL,eAAW,kCACN,WACA;AAAA;AAIP,QAAM,cAAc,KAAK,cAAc;AACvC,MAAI,aAAa;AACjB,MAAI,gBAAgB;AAAG,iBAAa;AAAA,WAC3B,cAAc;AAAG,iBAAa;AAEvC,SACE,qCAAC,MAAD,mBAAQ,YACN,qCAAC,OAAD;AAAA,IACE,WAAW,0CAA0C,KAAK,QAAQ;AAAA,KAC9D,WAEH,WAAW;AAAA,IACV;AAAA,IACA,SAAS;AAAA,IACT;AAAA,OAGH,eAAe,KAAK,QAAQ,SAAS,WAAW,CAAC,eAChD,qCAAC,MAAD;AAAA,IAAI,WAAW,sCAAsC;AAAA,KAClD,KAAK,cAAc,IAAI,CAAC,aAAa,MACpC,qCAAC,cAAD;AAAA,IACE,KAAK;AAAA,IACL,OAAO;AAAA,IACP,WAAW;AAAA,IACX;AAAA,IACA,UAAU;AAAA,IACV,MAAM;AAAA,IACN;AAAA,IACA;AAAA;AAAA;AASd,IAAO,uBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import {
|
|
19
|
+
closest,
|
|
20
|
+
getOffsetRect,
|
|
21
|
+
getTotalScroll,
|
|
22
|
+
getTransformProps
|
|
23
|
+
} from "@elliemae/ds-shared/utils";
|
|
24
|
+
function onDragStart(e, item) {
|
|
25
|
+
if (e) {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
e.stopPropagation();
|
|
28
|
+
}
|
|
29
|
+
this.el = closest(e.target, ".nestable-item");
|
|
30
|
+
this.startTrackMouse();
|
|
31
|
+
this.onMouseMove(e);
|
|
32
|
+
const { items } = this.state;
|
|
33
|
+
this.setState({
|
|
34
|
+
dragItem: item,
|
|
35
|
+
itemsOld: items
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function onDragEnd(e, isCancel) {
|
|
39
|
+
if (e && e.preventDefault)
|
|
40
|
+
e.preventDefault();
|
|
41
|
+
this.stopTrackMouse();
|
|
42
|
+
this.el = null;
|
|
43
|
+
const { items } = this.state;
|
|
44
|
+
const nestedInFilter = this.checkFilterChildren(items);
|
|
45
|
+
if (nestedInFilter)
|
|
46
|
+
return this.dragRevert();
|
|
47
|
+
return isCancel ? this.dragRevert() : this.dragApply();
|
|
48
|
+
}
|
|
49
|
+
function onMouseMove(e) {
|
|
50
|
+
const { group, threshold } = this.props;
|
|
51
|
+
const { dragItem } = this.state;
|
|
52
|
+
const { clientX, clientY } = e;
|
|
53
|
+
const transformProps = getTransformProps(clientX, clientY);
|
|
54
|
+
const elCopy = document.querySelector(`.nestable-${group} .nestable-drag-layer > .nestable-list`);
|
|
55
|
+
if (!this.elCopyStyles) {
|
|
56
|
+
const offset = getOffsetRect(this.el);
|
|
57
|
+
const scroll = getTotalScroll(this.el);
|
|
58
|
+
this.elCopyStyles = __spreadValues({
|
|
59
|
+
marginTop: offset.top - clientY - scroll.top,
|
|
60
|
+
marginLeft: offset.left - clientX - scroll.left
|
|
61
|
+
}, transformProps);
|
|
62
|
+
} else {
|
|
63
|
+
this.elCopyStyles = __spreadValues(__spreadValues({}, this.elCopyStyles), transformProps);
|
|
64
|
+
for (const key in transformProps) {
|
|
65
|
+
if (transformProps.hasOwnProperty(key)) {
|
|
66
|
+
elCopy.style[key] = transformProps[key];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const diffX = clientX - this.mouse.last.x;
|
|
70
|
+
if (diffX >= 0 && this.mouse.shift.x >= 0 || diffX <= 0 && this.mouse.shift.x <= 0) {
|
|
71
|
+
this.mouse.shift.x += diffX;
|
|
72
|
+
} else {
|
|
73
|
+
this.mouse.shift.x = 0;
|
|
74
|
+
}
|
|
75
|
+
this.mouse.last.x = clientX;
|
|
76
|
+
if (Math.abs(this.mouse.shift.x) > threshold) {
|
|
77
|
+
if (this.mouse.shift.x > 0) {
|
|
78
|
+
this.tryIncreaseDepth(dragItem);
|
|
79
|
+
} else {
|
|
80
|
+
this.tryDecreaseDepth(dragItem);
|
|
81
|
+
}
|
|
82
|
+
this.mouse.shift.x = 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function onMouseEnter(e, item) {
|
|
87
|
+
if (e) {
|
|
88
|
+
e.preventDefault();
|
|
89
|
+
e.stopPropagation();
|
|
90
|
+
}
|
|
91
|
+
const { collapsed, childrenProp } = this.props;
|
|
92
|
+
const { dragItem } = this.state;
|
|
93
|
+
if (dragItem.id === item.id)
|
|
94
|
+
return;
|
|
95
|
+
const pathFrom = this.getPathById(dragItem.id);
|
|
96
|
+
const pathTo = this.getPathById(item.id);
|
|
97
|
+
let collapseProps = {};
|
|
98
|
+
if (collapsed && pathFrom.length > 1) {
|
|
99
|
+
const parent = this.getItemByPath(pathFrom.slice(0, -1));
|
|
100
|
+
if (parent[childrenProp].length === 1) {
|
|
101
|
+
collapseProps = this.onToggleCollapse(parent, true);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.moveItem({ dragItem, pathFrom, pathTo }, collapseProps);
|
|
105
|
+
}
|
|
106
|
+
function onToggleCollapse(item, isGetter) {
|
|
107
|
+
const { collapsed } = this.props;
|
|
108
|
+
const { collapsedGroups } = this.state;
|
|
109
|
+
const isCollapsed = this.isCollapsed(item);
|
|
110
|
+
const newState = {
|
|
111
|
+
collapsedGroups: isCollapsed ^ collapsed ? collapsedGroups.filter((id) => id !== item.id) : collapsedGroups.concat(item.id)
|
|
112
|
+
};
|
|
113
|
+
if (isGetter) {
|
|
114
|
+
return newState;
|
|
115
|
+
}
|
|
116
|
+
return this.setState(newState);
|
|
117
|
+
}
|
|
118
|
+
function onKeyDown(e) {
|
|
119
|
+
if (e.which === 27) {
|
|
120
|
+
this.onDragEnd(null, true);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
onDragEnd,
|
|
125
|
+
onDragStart,
|
|
126
|
+
onKeyDown,
|
|
127
|
+
onMouseEnter,
|
|
128
|
+
onMouseMove,
|
|
129
|
+
onToggleCollapse
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/events.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-bitwise, no-loops/no-loops, max-lines, max-statements, no-restricted-syntax, no-prototype-builtins */\nimport {\n closest,\n getOffsetRect,\n getTotalScroll,\n getTransformProps,\n} from '@elliemae/ds-shared/utils';\n\nexport function onDragStart(e, item) {\n if (e) {\n e.preventDefault();\n e.stopPropagation();\n }\n this.el = closest(e.target, '.nestable-item');\n this.startTrackMouse();\n this.onMouseMove(e);\n const { items } = this.state;\n this.setState({\n dragItem: item,\n itemsOld: items,\n });\n}\n\nexport function onDragEnd(e, isCancel) {\n if (e && e.preventDefault) e.preventDefault();\n\n this.stopTrackMouse();\n this.el = null;\n\n // check if filter has children\n const { items } = this.state;\n const nestedInFilter = this.checkFilterChildren(items);\n if (nestedInFilter) return this.dragRevert();\n\n return isCancel ? this.dragRevert() : this.dragApply();\n}\n\nexport function onMouseMove(e) {\n const { group, threshold } = this.props;\n const { dragItem } = this.state;\n const { clientX, clientY } = e;\n const transformProps = getTransformProps(clientX, clientY);\n const elCopy = document.querySelector(\n `.nestable-${group} .nestable-drag-layer > .nestable-list`,\n );\n if (!this.elCopyStyles) {\n const offset = getOffsetRect(this.el);\n const scroll = getTotalScroll(this.el);\n\n this.elCopyStyles = {\n marginTop: offset.top - clientY - scroll.top,\n marginLeft: offset.left - clientX - scroll.left,\n ...transformProps,\n };\n } else {\n this.elCopyStyles = {\n ...this.elCopyStyles,\n ...transformProps,\n };\n for (const key in transformProps) {\n if (transformProps.hasOwnProperty(key)) {\n elCopy.style[key] = transformProps[key];\n }\n }\n const diffX = clientX - this.mouse.last.x;\n if (\n (diffX >= 0 && this.mouse.shift.x >= 0) ||\n (diffX <= 0 && this.mouse.shift.x <= 0)\n ) {\n this.mouse.shift.x += diffX;\n } else {\n this.mouse.shift.x = 0;\n }\n this.mouse.last.x = clientX;\n if (Math.abs(this.mouse.shift.x) > threshold) {\n if (this.mouse.shift.x > 0) {\n this.tryIncreaseDepth(dragItem);\n } else {\n this.tryDecreaseDepth(dragItem);\n }\n this.mouse.shift.x = 0;\n }\n }\n}\nexport function onMouseEnter(e, item) {\n if (e) {\n e.preventDefault();\n e.stopPropagation();\n }\n\n const { collapsed, childrenProp } = this.props;\n const { dragItem } = this.state;\n if (dragItem.id === item.id) return;\n\n const pathFrom = this.getPathById(dragItem.id);\n const pathTo = this.getPathById(item.id);\n\n // if collapsed by default\n // and move last (by count) child\n // remove parent node from list of open nodes\n let collapseProps = {};\n if (collapsed && pathFrom.length > 1) {\n const parent = this.getItemByPath(pathFrom.slice(0, -1));\n if (parent[childrenProp].length === 1) {\n collapseProps = this.onToggleCollapse(parent, true);\n }\n }\n\n this.moveItem({ dragItem, pathFrom, pathTo }, collapseProps);\n}\n\nexport function onToggleCollapse(item, isGetter) {\n const { collapsed } = this.props;\n const { collapsedGroups } = this.state;\n const isCollapsed = this.isCollapsed(item);\n\n const newState = {\n collapsedGroups:\n isCollapsed ^ collapsed\n ? collapsedGroups.filter(id => id !== item.id)\n : collapsedGroups.concat(item.id),\n };\n\n if (isGetter) {\n return newState;\n }\n return this.setState(newState);\n}\nexport function onKeyDown(e) {\n if (e.which === 27) {\n // ESC\n this.onDragEnd(null, true);\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;ACCA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,qBAAqB,GAAG,MAAM;AACnC,MAAI,GAAG;AACL,MAAE;AACF,MAAE;AAAA;AAEJ,OAAK,KAAK,QAAQ,EAAE,QAAQ;AAC5B,OAAK;AACL,OAAK,YAAY;AACjB,QAAM,EAAE,UAAU,KAAK;AACvB,OAAK,SAAS;AAAA,IACZ,UAAU;AAAA,IACV,UAAU;AAAA;AAAA;AAIP,mBAAmB,GAAG,UAAU;AACrC,MAAI,KAAK,EAAE;AAAgB,MAAE;AAE7B,OAAK;AACL,OAAK,KAAK;AAGV,QAAM,EAAE,UAAU,KAAK;AACvB,QAAM,iBAAiB,KAAK,oBAAoB;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AAO,KAAK;AAAI;AAE7B,QAAM,WAAW,KAAK,YAAY,SAAS;AAC3C,QAAM,SAAS,KAAK,YAAY,KAAK;AAKrC,MAAI,gBAAgB;AACpB,MAAI,aAAa,SAAS,SAAS,GAAG;AACpC,UAAM,SAAS,KAAK,cAAc,SAAS,MAAM,GAAG;AACpD,QAAI,OAAO,cAAc,WAAW,GAAG;AACrC,sBAAgB,KAAK,iBAAiB,QAAQ;AAAA;AAAA;AAIlD,OAAK,SAAS,EAAE,UAAU,UAAU,UAAU;AAAA;AAGzC,0BAA0B,MAAM,UAAU;AAC/C,QAAM,EAAE,cAAc,KAAK;AAC3B,QAAM,EAAE,oBAAoB,KAAK;AACjC,QAAM,cAAc,KAAK,YAAY;AAErC,QAAM,WAAW;AAAA,IACf,iBACE,cAAc,YACV,gBAAgB,OAAO,QAAM,OAAO,KAAK,MACzC,gBAAgB,OAAO,KAAK;AAAA;AAGpC,MAAI,UAAU;AACZ,WAAO;AAAA;AAET,SAAO,KAAK,SAAS;AAAA;AAEhB,mBAAmB,GAAG;AAC3B,MAAI,EAAE,UAAU,IAAI;AAElB,SAAK,UAAU,MAAM;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
+
import * as React from "react";
|
|
1
2
|
function getItemOptions() {
|
|
2
|
-
const {
|
|
3
|
-
|
|
4
|
-
renderCollapseIcon,
|
|
5
|
-
handler,
|
|
6
|
-
childrenProp
|
|
7
|
-
} = this.props;
|
|
8
|
-
const {
|
|
9
|
-
dragItem
|
|
10
|
-
} = this.state;
|
|
3
|
+
const { renderItem, renderCollapseIcon, handler, childrenProp } = this.props;
|
|
4
|
+
const { dragItem } = this.state;
|
|
11
5
|
return {
|
|
12
6
|
dragItem,
|
|
13
7
|
childrenProp,
|
|
@@ -20,5 +14,7 @@ function getItemOptions() {
|
|
|
20
14
|
onToggleCollapse: this.onToggleCollapse
|
|
21
15
|
};
|
|
22
16
|
}
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
export {
|
|
18
|
+
getItemOptions
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=getItemOptions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/components/Nestable/actions/getItemOptions.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export function getItemOptions() {\n const { renderItem, renderCollapseIcon, handler, childrenProp } = this.props;\n const { dragItem } = this.state;\n\n return {\n dragItem,\n childrenProp,\n renderItem,\n renderCollapseIcon,\n handler,\n\n onDragStart: this.onDragStart,\n onMouseEnter: this.onMouseEnter,\n isCollapsed: this.isCollapsed,\n onToggleCollapse: this.onToggleCollapse,\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACAO,0BAA0B;AAC/B,QAAM,EAAE,YAAY,oBAAoB,SAAS,iBAAiB,KAAK;AACvE,QAAM,EAAE,aAAa,KAAK;AAE1B,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAEA,aAAa,KAAK;AAAA,IAClB,cAAc,KAAK;AAAA,IACnB,aAAa,KAAK;AAAA,IAClB,kBAAkB,KAAK;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|