@elliemae/ds-query-builder 2.1.1-rc.1 → 2.2.0-alpha.4
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 +117 -97
- package/cjs/DSQueryBuilder.js.map +7 -0
- package/cjs/components/AndOrController/AndOrController.js +148 -162
- package/cjs/components/AndOrController/AndOrController.js.map +7 -0
- package/cjs/components/ConditionController/ConditionController.js +88 -72
- package/cjs/components/ConditionController/ConditionController.js.map +7 -0
- package/cjs/components/DisplayOutput/DisplayOutput.js +61 -62
- package/cjs/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/cjs/components/DragContainerController/DragContainerController.js +61 -41
- package/cjs/components/DragContainerController/DragContainerController.js.map +7 -0
- package/cjs/components/DragControllerRow/DragControllerRow.js +50 -46
- package/cjs/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/cjs/components/FieldControllerRow/FieldControllerRow.js +54 -32
- package/cjs/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/cjs/components/Nestable/Nestable.js +143 -209
- package/cjs/components/Nestable/Nestable.js.map +7 -0
- package/cjs/components/Nestable/NestableItem.js +98 -90
- package/cjs/components/Nestable/NestableItem.js.map +7 -0
- package/cjs/components/Nestable/actions/events.js +72 -95
- package/cjs/components/Nestable/actions/events.js.map +7 -0
- package/cjs/components/Nestable/actions/getItemOptions.js +36 -15
- package/cjs/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/cjs/components/Nestable/actions/getPaths.js +46 -51
- package/cjs/components/Nestable/actions/getPaths.js.map +7 -0
- package/cjs/components/Nestable/actions/index.js +42 -28
- package/cjs/components/Nestable/actions/index.js.map +7 -0
- package/cjs/components/Nestable/actions/moveItem.js +44 -42
- package/cjs/components/Nestable/actions/moveItem.js.map +7 -0
- package/cjs/components/Nestable/actions/paths.js +48 -55
- package/cjs/components/Nestable/actions/paths.js.map +7 -0
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js +39 -23
- package/cjs/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js +39 -26
- package/cjs/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/cjs/components/Nestable/index.js +36 -7
- package/cjs/components/Nestable/index.js.map +7 -0
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js +36 -13
- package/cjs/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/cjs/components/QueryBuilderImpl.js +118 -202
- package/cjs/components/QueryBuilderImpl.js.map +7 -0
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js +80 -78
- package/cjs/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js +154 -211
- package/cjs/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js +39 -26
- package/cjs/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/cjs/components/format/format.js +48 -22
- package/cjs/components/format/format.js.map +7 -0
- package/cjs/components/format/sqlFormat.js +69 -48
- package/cjs/components/format/sqlFormat.js.map +7 -0
- package/cjs/components/format/sqlSafeFormat.js +72 -55
- package/cjs/components/format/sqlSafeFormat.js.map +7 -0
- package/cjs/components/format/xmlFormat.js +71 -50
- package/cjs/components/format/xmlFormat.js.map +7 -0
- package/cjs/components/helpers/actions.js +151 -186
- package/cjs/components/helpers/actions.js.map +7 -0
- package/cjs/components/helpers/constants.js +36 -8
- package/cjs/components/helpers/constants.js.map +7 -0
- package/cjs/components/helpers/dependencies.js +49 -64
- package/cjs/components/helpers/dependencies.js.map +7 -0
- package/cjs/components/helpers/selectors.js +161 -101
- package/cjs/components/helpers/selectors.js.map +7 -0
- package/cjs/components/helpers/store.js +86 -104
- package/cjs/components/helpers/store.js.map +7 -0
- package/cjs/components/helpers/types.js +72 -44
- package/cjs/components/helpers/types.js.map +7 -0
- package/cjs/index.js +36 -29
- package/cjs/index.js.map +7 -0
- package/cjs/propTypes.js +102 -94
- package/cjs/propTypes.js.map +7 -0
- package/esm/DSQueryBuilder.js +103 -72
- package/esm/DSQueryBuilder.js.map +7 -0
- package/esm/components/AndOrController/AndOrController.js +113 -147
- package/esm/components/AndOrController/AndOrController.js.map +7 -0
- package/esm/components/ConditionController/ConditionController.js +57 -62
- package/esm/components/ConditionController/ConditionController.js.map +7 -0
- package/esm/components/DisplayOutput/DisplayOutput.js +29 -53
- package/esm/components/DisplayOutput/DisplayOutput.js.map +7 -0
- package/esm/components/DragContainerController/DragContainerController.js +32 -35
- package/esm/components/DragContainerController/DragContainerController.js.map +7 -0
- package/esm/components/DragControllerRow/DragControllerRow.js +21 -38
- package/esm/components/DragControllerRow/DragControllerRow.js.map +7 -0
- package/esm/components/FieldControllerRow/FieldControllerRow.js +25 -26
- package/esm/components/FieldControllerRow/FieldControllerRow.js.map +7 -0
- package/esm/components/Nestable/Nestable.js +115 -186
- package/esm/components/Nestable/Nestable.js.map +7 -0
- package/esm/components/Nestable/NestableItem.js +69 -82
- package/esm/components/Nestable/NestableItem.js.map +7 -0
- package/esm/components/Nestable/actions/events.js +45 -79
- package/esm/components/Nestable/actions/events.js.map +7 -0
- package/esm/components/Nestable/actions/getItemOptions.js +7 -11
- package/esm/components/Nestable/actions/getItemOptions.js.map +7 -0
- package/esm/components/Nestable/actions/getPaths.js +17 -43
- package/esm/components/Nestable/actions/getPaths.js.map +7 -0
- package/esm/components/Nestable/actions/index.js +13 -6
- package/esm/components/Nestable/actions/index.js.map +7 -0
- package/esm/components/Nestable/actions/moveItem.js +13 -31
- package/esm/components/Nestable/actions/moveItem.js.map +7 -0
- package/esm/components/Nestable/actions/paths.js +19 -47
- package/esm/components/Nestable/actions/paths.js.map +7 -0
- package/esm/components/Nestable/actions/tryDecreaseDepth.js +10 -19
- package/esm/components/Nestable/actions/tryDecreaseDepth.js.map +7 -0
- package/esm/components/Nestable/actions/tryIncreaseDepth.js +10 -22
- package/esm/components/Nestable/actions/tryIncreaseDepth.js.map +7 -0
- package/esm/components/Nestable/index.js +7 -2
- package/esm/components/Nestable/index.js.map +7 -0
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js +7 -5
- package/esm/components/QueryBuilderContext/QueryBuilderContext.js.map +7 -0
- package/esm/components/QueryBuilderImpl.js +82 -187
- package/esm/components/QueryBuilderImpl.js.map +7 -0
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js +50 -70
- package/esm/components/QueryBuilderItem/QueryBuilderItem.js.map +7 -0
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js +123 -201
- package/esm/components/QueryBuilderRow/QueryBuilderRow.js.map +7 -0
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js +10 -17
- package/esm/components/ToolBarAnimation/ToolBarAnimation.js.map +7 -0
- package/esm/components/format/format.js +16 -17
- package/esm/components/format/format.js.map +7 -0
- package/esm/components/format/sqlFormat.js +39 -43
- package/esm/components/format/sqlFormat.js.map +7 -0
- package/esm/components/format/sqlSafeFormat.js +43 -50
- package/esm/components/format/sqlSafeFormat.js.map +7 -0
- package/esm/components/format/xmlFormat.js +41 -45
- package/esm/components/format/xmlFormat.js.map +7 -0
- package/esm/components/helpers/actions.js +123 -160
- package/esm/components/helpers/actions.js.map +7 -0
- package/esm/components/helpers/constants.js +7 -2
- package/esm/components/helpers/constants.js.map +7 -0
- package/esm/components/helpers/dependencies.js +19 -39
- package/esm/components/helpers/dependencies.js.map +7 -0
- package/esm/components/helpers/selectors.js +132 -93
- package/esm/components/helpers/selectors.js.map +7 -0
- package/esm/components/helpers/store.js +54 -82
- package/esm/components/helpers/store.js.map +7 -0
- package/esm/components/helpers/types.js +44 -33
- package/esm/components/helpers/types.js.map +7 -0
- package/esm/index.js +7 -4
- package/esm/index.js.map +7 -0
- package/esm/propTypes.js +55 -72
- package/esm/propTypes.js.map +7 -0
- package/package.json +12 -12
|
@@ -1,97 +1,71 @@
|
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2, { Component } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import cn from "classnames";
|
|
5
|
+
import { listWithChildren } from "@elliemae/ds-shared/utils";
|
|
6
|
+
import { isEqualWith } from "@elliemae/ds-utilities";
|
|
7
|
+
import {
|
|
8
|
+
tryIncreaseDepth,
|
|
9
|
+
tryDecreaseDepth,
|
|
10
|
+
moveItem,
|
|
11
|
+
getItemOptions,
|
|
12
|
+
getRealNextPath,
|
|
13
|
+
getPathById,
|
|
14
|
+
getItemByPath,
|
|
15
|
+
getItemDepth,
|
|
16
|
+
getSplicePath,
|
|
17
|
+
onDragStart,
|
|
18
|
+
onDragEnd,
|
|
19
|
+
onMouseMove,
|
|
20
|
+
onMouseEnter,
|
|
21
|
+
onToggleCollapse,
|
|
22
|
+
onKeyDown
|
|
23
|
+
} from "./actions";
|
|
24
|
+
import NestableItem from "./NestableItem";
|
|
28
25
|
const shallowCompare = (instance, nextProps, nextState) => !isEqualWith(instance.props, nextProps) || !isEqualWith(instance.state, nextState);
|
|
29
|
-
|
|
30
26
|
class Nestable extends Component {
|
|
31
27
|
constructor(props) {
|
|
32
28
|
super(props);
|
|
33
|
-
|
|
34
29
|
this.onDragStart = (e, item) => {
|
|
35
30
|
onDragStart.call(this, e, item);
|
|
36
31
|
};
|
|
37
|
-
|
|
38
32
|
this.onDragEnd = (e, isCancel) => onDragEnd.call(this, e, isCancel);
|
|
39
|
-
|
|
40
|
-
this.onMouseMove = e => onMouseMove.call(this, e);
|
|
41
|
-
|
|
33
|
+
this.onMouseMove = (e) => onMouseMove.call(this, e);
|
|
42
34
|
this.onMouseEnter = (e, item) => onMouseEnter.call(this, e, item);
|
|
43
|
-
|
|
44
35
|
this.onToggleCollapse = (item, isGetter) => onToggleCollapse.call(this, item, isGetter);
|
|
45
|
-
|
|
46
|
-
this.onKeyDown = e => onKeyDown.call(this, e);
|
|
47
|
-
|
|
36
|
+
this.onKeyDown = (e) => onKeyDown.call(this, e);
|
|
48
37
|
this.getDefaultItems = () => {
|
|
49
|
-
const {
|
|
50
|
-
items
|
|
51
|
-
} = this.state;
|
|
38
|
+
const { items } = this.state;
|
|
52
39
|
return items;
|
|
53
40
|
};
|
|
54
|
-
|
|
55
|
-
this.getItemDepth = item => getItemDepth.call(this, item);
|
|
56
|
-
|
|
41
|
+
this.getItemDepth = (item) => getItemDepth.call(this, item);
|
|
57
42
|
this.startTrackMouse = () => {
|
|
58
|
-
document.addEventListener(
|
|
59
|
-
document.addEventListener(
|
|
60
|
-
document.addEventListener(
|
|
43
|
+
document.addEventListener("mousemove", this.onMouseMove);
|
|
44
|
+
document.addEventListener("mouseup", this.onDragEnd);
|
|
45
|
+
document.addEventListener("keydown", this.onKeyDown);
|
|
61
46
|
};
|
|
62
|
-
|
|
63
47
|
this.stopTrackMouse = () => {
|
|
64
|
-
document.removeEventListener(
|
|
65
|
-
document.removeEventListener(
|
|
66
|
-
document.removeEventListener(
|
|
48
|
+
document.removeEventListener("mousemove", this.onMouseMove);
|
|
49
|
+
document.removeEventListener("mouseup", this.onDragEnd);
|
|
50
|
+
document.removeEventListener("keydown", this.onKeyDown);
|
|
67
51
|
this.elCopyStyles = null;
|
|
68
52
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const {
|
|
72
|
-
collapsed
|
|
73
|
-
} = this.props;
|
|
74
|
-
const {
|
|
75
|
-
collapsedGroups
|
|
76
|
-
} = this.state;
|
|
53
|
+
this.isCollapsed = (item) => {
|
|
54
|
+
const { collapsed } = this.props;
|
|
55
|
+
const { collapsedGroups } = this.state;
|
|
77
56
|
return !!(collapsedGroups.indexOf(item.id) > -1 ^ collapsed);
|
|
78
57
|
};
|
|
79
|
-
|
|
80
|
-
this.checkFilterChildren = items => items.find(current => {
|
|
58
|
+
this.checkFilterChildren = (items) => items.find((current) => {
|
|
81
59
|
const {
|
|
82
|
-
element: {
|
|
83
|
-
type
|
|
84
|
-
},
|
|
60
|
+
element: { type },
|
|
85
61
|
children
|
|
86
62
|
} = current;
|
|
87
|
-
if (type ===
|
|
63
|
+
if (type === "filter" && children.length > 0)
|
|
64
|
+
return true;
|
|
88
65
|
return this.checkFilterChildren(children);
|
|
89
66
|
});
|
|
90
|
-
|
|
91
67
|
this.dragRevert = () => {
|
|
92
|
-
const {
|
|
93
|
-
itemsOld
|
|
94
|
-
} = this.state;
|
|
68
|
+
const { itemsOld } = this.state;
|
|
95
69
|
this.setState({
|
|
96
70
|
items: itemsOld,
|
|
97
71
|
itemsOld: null,
|
|
@@ -99,7 +73,6 @@ class Nestable extends Component {
|
|
|
99
73
|
isDirty: false
|
|
100
74
|
});
|
|
101
75
|
};
|
|
102
|
-
|
|
103
76
|
this.state = {
|
|
104
77
|
items: [],
|
|
105
78
|
itemsOld: null,
|
|
@@ -112,163 +85,101 @@ class Nestable extends Component {
|
|
|
112
85
|
this.el = null;
|
|
113
86
|
this.elCopyStyles = null;
|
|
114
87
|
this.mouse = {
|
|
115
|
-
last: {
|
|
116
|
-
|
|
117
|
-
},
|
|
118
|
-
shift: {
|
|
119
|
-
x: 0
|
|
120
|
-
}
|
|
88
|
+
last: { x: 0 },
|
|
89
|
+
shift: { x: 0 }
|
|
121
90
|
};
|
|
122
91
|
}
|
|
123
|
-
|
|
124
92
|
componentDidMount() {
|
|
125
|
-
const {
|
|
126
|
-
|
|
127
|
-
} = this.props;
|
|
128
|
-
let {
|
|
129
|
-
items
|
|
130
|
-
} = this.props; // make sure every item has property 'children'
|
|
131
|
-
|
|
93
|
+
const { childrenProp } = this.props;
|
|
94
|
+
let { items } = this.props;
|
|
132
95
|
items = listWithChildren(items, childrenProp);
|
|
133
|
-
this.setState({
|
|
134
|
-
items
|
|
135
|
-
});
|
|
96
|
+
this.setState({ items });
|
|
136
97
|
}
|
|
137
|
-
|
|
138
98
|
componentWillUnmount() {
|
|
139
99
|
this.stopTrackMouse();
|
|
140
100
|
}
|
|
141
|
-
|
|
142
101
|
static getDerivedStateFromProps(props, state) {
|
|
143
|
-
const {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
} = props;
|
|
147
|
-
const {
|
|
148
|
-
stopTrackingMouse,
|
|
149
|
-
oldProps
|
|
150
|
-
} = state;
|
|
151
|
-
|
|
152
|
-
if (shallowCompare({
|
|
153
|
-
props: oldProps,
|
|
154
|
-
state: {}
|
|
155
|
-
}, props, {})) {
|
|
102
|
+
const { items: itemsNew, childrenProp } = props;
|
|
103
|
+
const { stopTrackingMouse, oldProps } = state;
|
|
104
|
+
if (shallowCompare({ props: oldProps, state: {} }, props, {})) {
|
|
156
105
|
stopTrackingMouse();
|
|
157
106
|
const extra = {};
|
|
158
|
-
|
|
159
107
|
if (oldProps.collapsed !== props.collapsed) {
|
|
160
108
|
extra.collapsedGroups = [];
|
|
161
109
|
}
|
|
162
|
-
|
|
163
|
-
return _objectSpread({
|
|
110
|
+
return {
|
|
164
111
|
items: listWithChildren(itemsNew, childrenProp),
|
|
165
112
|
dragItem: null,
|
|
166
113
|
isDirty: false,
|
|
167
|
-
oldProps: props
|
|
168
|
-
|
|
114
|
+
oldProps: props,
|
|
115
|
+
...extra
|
|
116
|
+
};
|
|
169
117
|
}
|
|
170
|
-
|
|
171
118
|
return null;
|
|
172
119
|
}
|
|
173
|
-
|
|
174
|
-
getPathById(id) {
|
|
175
|
-
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
120
|
+
getPathById(id, items = this.getDefaultItems()) {
|
|
176
121
|
return getPathById.call(this, id, items);
|
|
177
122
|
}
|
|
178
|
-
|
|
179
|
-
getItemByPath(path) {
|
|
180
|
-
let items = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.getDefaultItems();
|
|
123
|
+
getItemByPath(path, items = this.getDefaultItems()) {
|
|
181
124
|
return getItemByPath.call(this, path, items);
|
|
182
125
|
}
|
|
183
|
-
|
|
184
|
-
getSplicePath(path) {
|
|
185
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
126
|
+
getSplicePath(path, options = {}) {
|
|
186
127
|
return getSplicePath.call(this, path, options);
|
|
187
128
|
}
|
|
188
|
-
|
|
189
129
|
getRealNextPath(prevPath, nextPath) {
|
|
190
130
|
return getRealNextPath.call(this, prevPath, nextPath);
|
|
191
131
|
}
|
|
192
|
-
|
|
193
132
|
getItemOptions() {
|
|
194
133
|
return getItemOptions.call(this);
|
|
195
134
|
}
|
|
196
|
-
|
|
197
135
|
dragApply() {
|
|
198
|
-
const {
|
|
199
|
-
|
|
200
|
-
} = this.props;
|
|
201
|
-
const {
|
|
202
|
-
items,
|
|
203
|
-
isDirty,
|
|
204
|
-
dragItem
|
|
205
|
-
} = this.state;
|
|
136
|
+
const { onChange } = this.props;
|
|
137
|
+
const { items, isDirty, dragItem } = this.state;
|
|
206
138
|
this.setState({
|
|
207
139
|
itemsOld: null,
|
|
208
140
|
dragItem: null,
|
|
209
141
|
isDirty: false
|
|
210
142
|
});
|
|
211
|
-
if (onChange && isDirty)
|
|
143
|
+
if (onChange && isDirty)
|
|
144
|
+
onChange(items, dragItem);
|
|
212
145
|
}
|
|
213
|
-
|
|
214
146
|
tryIncreaseDepth(dragItem) {
|
|
215
147
|
tryIncreaseDepth.call(this, dragItem);
|
|
216
148
|
}
|
|
217
|
-
|
|
218
149
|
tryDecreaseDepth(dragItem) {
|
|
219
150
|
tryDecreaseDepth.call(this, dragItem);
|
|
220
151
|
}
|
|
221
|
-
|
|
222
|
-
|
|
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);
|
|
152
|
+
moveItem({ dragItem, pathFrom, pathTo }, extraProps = {}) {
|
|
153
|
+
moveItem.call(this, { dragItem, pathFrom, pathTo }, extraProps);
|
|
234
154
|
}
|
|
235
|
-
|
|
236
155
|
renderDragLayer() {
|
|
237
|
-
const {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const {
|
|
241
|
-
dragItem
|
|
242
|
-
} = this.state;
|
|
243
|
-
const el = document.querySelector(".nestable-".concat(group, " .nestable-item-").concat(dragItem.id));
|
|
156
|
+
const { group } = this.props;
|
|
157
|
+
const { dragItem } = this.state;
|
|
158
|
+
const el = document.querySelector(`.nestable-${group} .nestable-item-${dragItem.id}`);
|
|
244
159
|
let listStyles = {};
|
|
245
|
-
|
|
246
160
|
if (el) {
|
|
247
161
|
listStyles.width = el.clientWidth;
|
|
248
162
|
}
|
|
249
|
-
|
|
250
163
|
if (this.elCopyStyles) {
|
|
251
|
-
listStyles =
|
|
164
|
+
listStyles = {
|
|
165
|
+
...listStyles,
|
|
166
|
+
...this.elCopyStyles
|
|
167
|
+
};
|
|
252
168
|
}
|
|
253
|
-
|
|
254
169
|
const options = this.getItemOptions();
|
|
255
|
-
return
|
|
170
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
256
171
|
className: "nestable-drag-layer"
|
|
257
|
-
},
|
|
172
|
+
}, /* @__PURE__ */ React2.createElement("ol", {
|
|
258
173
|
className: "nestable-list",
|
|
259
174
|
style: listStyles
|
|
260
|
-
},
|
|
175
|
+
}, /* @__PURE__ */ React2.createElement(NestableItem, {
|
|
261
176
|
isCopy: true,
|
|
262
177
|
item: dragItem,
|
|
263
|
-
options
|
|
178
|
+
options
|
|
264
179
|
})));
|
|
265
180
|
}
|
|
266
|
-
|
|
267
181
|
render() {
|
|
268
|
-
const {
|
|
269
|
-
items,
|
|
270
|
-
dragItem
|
|
271
|
-
} = this.state;
|
|
182
|
+
const { items, dragItem } = this.state;
|
|
272
183
|
const {
|
|
273
184
|
group,
|
|
274
185
|
isAndItem,
|
|
@@ -279,34 +190,52 @@ class Nestable extends Component {
|
|
|
279
190
|
} = this.props;
|
|
280
191
|
const options = this.getItemOptions();
|
|
281
192
|
const childLength = items.length;
|
|
282
|
-
let childClass =
|
|
283
|
-
if (childLength === 0)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
193
|
+
let childClass = "single";
|
|
194
|
+
if (childLength === 0)
|
|
195
|
+
childClass = "empty";
|
|
196
|
+
else if (childLength > 1)
|
|
197
|
+
childClass = "multiple";
|
|
198
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
199
|
+
className: cn("nestable", `nestable-${group}`, {
|
|
200
|
+
"is-drag-active": dragItem
|
|
287
201
|
})
|
|
288
|
-
},
|
|
289
|
-
className:
|
|
290
|
-
},
|
|
202
|
+
}, /* @__PURE__ */ React2.createElement("ol", {
|
|
203
|
+
className: `nestable-list nestable-group nestable-child-count-${childClass}`
|
|
204
|
+
}, items.map((item, i) => /* @__PURE__ */ React2.createElement(NestableItem, {
|
|
205
|
+
key: item.id,
|
|
291
206
|
index: i,
|
|
292
|
-
isAndItem
|
|
293
|
-
isDraggableItem
|
|
294
|
-
isOrItem
|
|
295
|
-
item
|
|
296
|
-
options
|
|
297
|
-
setDraggableItems
|
|
298
|
-
singleRow
|
|
299
|
-
}
|
|
207
|
+
isAndItem,
|
|
208
|
+
isDraggableItem,
|
|
209
|
+
isOrItem,
|
|
210
|
+
item,
|
|
211
|
+
options,
|
|
212
|
+
setDraggableItems,
|
|
213
|
+
singleRow
|
|
214
|
+
}))), dragItem && this.renderDragLayer());
|
|
300
215
|
}
|
|
301
|
-
|
|
302
216
|
}
|
|
303
|
-
|
|
304
217
|
Nestable.defaultProps = {
|
|
305
218
|
items: [],
|
|
306
219
|
collapsed: false,
|
|
307
220
|
group: Math.random().toString(36).slice(2),
|
|
308
|
-
childrenProp:
|
|
309
|
-
onChange: () => {
|
|
221
|
+
childrenProp: "children",
|
|
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
|
|
310
240
|
};
|
|
311
|
-
|
|
312
|
-
export { Nestable as default };
|
|
241
|
+
//# 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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
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
|
-
const NestableItem = _ref => {
|
|
19
|
-
let {
|
|
20
|
-
item,
|
|
21
|
-
isCopy,
|
|
22
|
-
options,
|
|
23
|
-
index,
|
|
24
|
-
isAndItem,
|
|
25
|
-
isOrItem,
|
|
26
|
-
isDraggableItem,
|
|
27
|
-
singleRow
|
|
28
|
-
} = _ref;
|
|
29
|
-
const {
|
|
30
|
-
dragItem,
|
|
31
|
-
renderItem,
|
|
32
|
-
handler,
|
|
33
|
-
childrenProp
|
|
34
|
-
} = options;
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import React2 from "react";
|
|
3
|
+
import cn from "classnames";
|
|
4
|
+
const NestableItem = ({
|
|
5
|
+
item,
|
|
6
|
+
isCopy,
|
|
7
|
+
options,
|
|
8
|
+
index,
|
|
9
|
+
isAndItem,
|
|
10
|
+
isOrItem,
|
|
11
|
+
isDraggableItem,
|
|
12
|
+
singleRow
|
|
13
|
+
}) => {
|
|
14
|
+
const { dragItem, renderItem, handler, childrenProp } = options;
|
|
35
15
|
const isCollapsed = options.isCollapsed(item);
|
|
36
16
|
const isDragging = !isCopy && dragItem && dragItem.id === item.id;
|
|
37
17
|
const hasChildren = item[childrenProp] && item[childrenProp].length > 0;
|
|
38
18
|
let Handler;
|
|
39
|
-
const isOrGroup = item.element.type ===
|
|
40
|
-
const isAndGroup = item.element.type ===
|
|
19
|
+
const isOrGroup = item.element.type === "group" && (item.element.condition === "" || item.element.condition === false);
|
|
20
|
+
const isAndGroup = item.element.type === "group" && !(item.element.condition === "" || item.element.condition === false);
|
|
41
21
|
const itemProps = {
|
|
42
|
-
className: cn(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
className: cn(`nestable-item${isCopy ? "-copy" : ""}`, `nestable-item${isCopy ? "-copy" : ""}-${item.id}`, `nestable-item-type-${item.element.type}`, {
|
|
23
|
+
"is-or-group": isOrGroup,
|
|
24
|
+
"is-and-group": isAndGroup,
|
|
25
|
+
"is-and-filter": item.element.type === "filter" && isAndItem,
|
|
26
|
+
"is-or-filter": item.element.type === "filter" && isOrItem
|
|
47
27
|
}, {
|
|
48
|
-
|
|
28
|
+
"is-dragging": isDragging
|
|
49
29
|
})
|
|
50
30
|
};
|
|
51
31
|
let rowProps = {};
|
|
52
32
|
let handlerProps = {};
|
|
53
|
-
|
|
54
33
|
if (!isCopy) {
|
|
55
34
|
if (dragItem) {
|
|
56
|
-
rowProps =
|
|
57
|
-
|
|
58
|
-
|
|
35
|
+
rowProps = {
|
|
36
|
+
...rowProps,
|
|
37
|
+
onMouseEnter: (e) => options.onMouseEnter(e, item)
|
|
38
|
+
};
|
|
59
39
|
} else {
|
|
60
|
-
handlerProps =
|
|
40
|
+
handlerProps = {
|
|
41
|
+
...handlerProps,
|
|
61
42
|
draggable: isDraggableItem !== false,
|
|
62
|
-
onDragStart: e => options.onDragStart(e, item)
|
|
63
|
-
}
|
|
43
|
+
onDragStart: (e) => options.onDragStart(e, item)
|
|
44
|
+
};
|
|
64
45
|
}
|
|
65
46
|
}
|
|
66
|
-
|
|
67
47
|
if (handler) {
|
|
68
|
-
Handler =
|
|
69
|
-
className: "nestable-item-handler"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})); // Handler = React.cloneElement(handler, handlerProps);
|
|
48
|
+
Handler = /* @__PURE__ */ React2.createElement("span", {
|
|
49
|
+
className: "nestable-item-handler",
|
|
50
|
+
...handlerProps
|
|
51
|
+
}, handler);
|
|
73
52
|
} else {
|
|
74
|
-
rowProps =
|
|
53
|
+
rowProps = {
|
|
54
|
+
...rowProps,
|
|
55
|
+
...handlerProps
|
|
56
|
+
};
|
|
75
57
|
}
|
|
76
|
-
|
|
77
58
|
const childLength = item[childrenProp].length;
|
|
78
|
-
let childClass =
|
|
79
|
-
if (childLength === 0)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
59
|
+
let childClass = "single";
|
|
60
|
+
if (childLength === 0)
|
|
61
|
+
childClass = "empty";
|
|
62
|
+
else if (childLength > 1)
|
|
63
|
+
childClass = "multiple";
|
|
64
|
+
return /* @__PURE__ */ React2.createElement("li", {
|
|
65
|
+
...itemProps
|
|
66
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
67
|
+
className: `nestable-item-name nestable-item-name--${item.element.type} `,
|
|
68
|
+
...rowProps
|
|
69
|
+
}, renderItem({
|
|
70
|
+
item,
|
|
71
|
+
handler: Handler,
|
|
72
|
+
index
|
|
73
|
+
})), hasChildren && item.element.type === "group" && !isCollapsed && /* @__PURE__ */ React2.createElement("ol", {
|
|
74
|
+
className: `nestable-list nestable-child-count-${childClass} `
|
|
75
|
+
}, item[childrenProp].map((currentitem, i) => /* @__PURE__ */ React2.createElement(NestableItem, {
|
|
76
|
+
key: i,
|
|
77
|
+
index: i,
|
|
78
|
+
isAndItem: isAndGroup,
|
|
79
|
+
isCopy,
|
|
80
|
+
isOrItem: isOrGroup,
|
|
81
|
+
item: currentitem,
|
|
82
|
+
options,
|
|
83
|
+
singleRow
|
|
84
|
+
}))));
|
|
85
|
+
};
|
|
86
|
+
var NestableItem_default = NestableItem;
|
|
87
|
+
export {
|
|
88
|
+
NestableItem_default as default
|
|
101
89
|
};
|
|
102
|
-
|
|
103
|
-
export { NestableItem as default };
|
|
90
|
+
//# 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,gB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