easy-file-system 1.5.5 → 1.5.7
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/example.js +2483 -1325
- package/lib/button/name.js +35 -1
- package/lib/constants.js +13 -4
- package/lib/div/item/entry/directoryName.js +19 -10
- package/lib/div/item/entry/fileName.js +17 -9
- package/lib/div/item/entry.js +8 -1
- package/lib/eventTypes.js +7 -2
- package/lib/example/view/button/editSelected.js +157 -0
- package/lib/example/view/explorer/first.js +158 -0
- package/lib/example/view/explorer/second.js +160 -0
- package/lib/example/view/rubbishBin.js +111 -0
- package/lib/example/view.js +71 -45
- package/lib/explorer.js +10 -83
- package/lib/index.js +7 -3
- package/lib/input/name.js +300 -0
- package/lib/item/entry/drag/directoryName.js +8 -6
- package/lib/item/entry/drag/fileName.js +10 -8
- package/lib/item/entry/drag.js +57 -15
- package/lib/keyCodes.js +22 -0
- package/lib/list/entries.js +16 -2
- package/lib/mixins/event.js +99 -0
- package/lib/styles.js +1 -5
- package/package.json +1 -1
- package/src/button/name.js +34 -0
- package/src/constants.js +1 -0
- package/src/div/item/entry/directoryName.js +23 -16
- package/src/div/item/entry/fileName.js +20 -14
- package/src/div/item/entry.js +7 -0
- package/src/eventTypes.js +3 -1
- package/src/example/view/button/editSelected.js +23 -0
- package/src/example/view/explorer/first.js +18 -0
- package/src/example/view/explorer/second.js +18 -0
- package/src/example/view/rubbishBin.js +9 -0
- package/src/example/view.js +53 -41
- package/src/explorer.js +9 -89
- package/src/index.js +1 -0
- package/src/input/name.js +90 -0
- package/src/item/entry/drag/directoryName.js +5 -4
- package/src/item/entry/drag/fileName.js +10 -6
- package/src/item/entry/drag.js +77 -23
- package/src/keyCodes.js +4 -0
- package/src/list/entries.js +16 -0
- package/src/mixins/event.js +140 -0
- package/src/styles.js +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style"; ///
|
|
4
|
+
|
|
5
|
+
import { Button } from "easy";
|
|
6
|
+
|
|
7
|
+
class EditSelectedButton extends Button {
|
|
8
|
+
childElements() {
|
|
9
|
+
return "Edit selected";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static defaultProperties = {
|
|
13
|
+
className: "edit-selected"
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default withStyle(EditSelectedButton)`
|
|
18
|
+
|
|
19
|
+
border: 1px solid black;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
padding: 1rem;
|
|
22
|
+
|
|
23
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Explorer } from "../../../index"; ///
|
|
4
|
+
|
|
5
|
+
export default class FirstExplorer extends Explorer {
|
|
6
|
+
initialise() {
|
|
7
|
+
super.initialise();
|
|
8
|
+
|
|
9
|
+
this.addFilePath("directory1/file1.txt");
|
|
10
|
+
this.addFilePath("directory1/file2.txt");
|
|
11
|
+
this.addFilePath("directory1/file3.txt");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
static defaultProperties = {
|
|
15
|
+
className: "first",
|
|
16
|
+
reference: "first-explorer"
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Explorer } from "../../../index"; ///
|
|
4
|
+
|
|
5
|
+
export default class SecondExplorer extends Explorer {
|
|
6
|
+
initialise() {
|
|
7
|
+
super.initialise();
|
|
8
|
+
|
|
9
|
+
this.addFilePath("directory2/file4.txt");
|
|
10
|
+
this.addFilePath("directory2/directory3/file5.txt");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static defaultProperties = {
|
|
14
|
+
className: "first",
|
|
15
|
+
reference: "second-explorer",
|
|
16
|
+
ignoredReferences: [ "first-explorer" ]
|
|
17
|
+
};
|
|
18
|
+
}
|
package/src/example/view.js
CHANGED
|
@@ -1,46 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Element } from "easy";
|
|
4
|
+
import { arrayUtilities } from "necessary";
|
|
4
5
|
|
|
5
|
-
import
|
|
6
|
+
import RubbishBin from "./view/rubbishBin";
|
|
7
|
+
import FirstExplorer from "./view/explorer/first";
|
|
8
|
+
import SecondExplorer from "./view/explorer/second";
|
|
9
|
+
import EditSelectedButton from "./view/button/editSelected";
|
|
10
|
+
|
|
11
|
+
const { first, second } = arrayUtilities;
|
|
6
12
|
|
|
7
13
|
export default class View extends Element {
|
|
8
|
-
|
|
9
|
-
|
|
14
|
+
clickHandler = (event, element) => {
|
|
15
|
+
const firstExplorer = this.getFirstExplorer(),
|
|
16
|
+
secondExplorer = this.getSecondExplorer();
|
|
10
17
|
|
|
11
|
-
|
|
18
|
+
firstExplorer.editSelectedPath();
|
|
19
|
+
secondExplorer.editSelectedPath();
|
|
20
|
+
}
|
|
12
21
|
|
|
13
|
-
|
|
14
|
-
|
|
22
|
+
openHandler = (filePath) => {
|
|
23
|
+
console.log("open", filePath)
|
|
24
|
+
}
|
|
15
25
|
|
|
16
|
-
|
|
26
|
+
moveHandler = (pathMaps, done) => {
|
|
27
|
+
console.log("move", JSON.stringify(pathMaps, null, " "))
|
|
17
28
|
|
|
18
|
-
|
|
29
|
+
done();
|
|
30
|
+
}
|
|
19
31
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
explorer1.addFilePath("directory1/file3.txt");
|
|
32
|
+
removeHandler = (pathMaps, done) => {
|
|
33
|
+
console.log("remove", JSON.stringify(pathMaps, null, " "))
|
|
23
34
|
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
done();
|
|
36
|
+
}
|
|
26
37
|
|
|
27
|
-
|
|
38
|
+
pathChangeHandler = (path, callback) => {
|
|
39
|
+
const success = true;
|
|
28
40
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
41
|
+
callback(success);
|
|
42
|
+
}
|
|
32
43
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
44
|
+
getExplorers() {
|
|
45
|
+
const explorerDivChildElements = this.getChildElements("div.explorer"),
|
|
46
|
+
explorers = explorerDivChildElements; ///
|
|
36
47
|
|
|
37
|
-
return
|
|
48
|
+
return explorers;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
getFirstExplorer() {
|
|
52
|
+
const explorers = this.getExplorers(),
|
|
53
|
+
firstExplorer = first(explorers);
|
|
38
54
|
|
|
39
|
-
|
|
55
|
+
return firstExplorer;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
getSecondExplorer() {
|
|
59
|
+
const explorers = this.getExplorers(),
|
|
60
|
+
secondExplorer = second(explorers);
|
|
40
61
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
return secondExplorer;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
childElements() {
|
|
66
|
+
return ([
|
|
67
|
+
|
|
68
|
+
<RubbishBin onRemove={this.removeHandler} />,
|
|
69
|
+
<FirstExplorer onMove={this.moveHandler} onOpen={this.openHandler} onPathChange={this.pathChangeHandler} />,
|
|
70
|
+
<SecondExplorer onMove={this.moveHandler} onOpen={this.openHandler} onPathChange={this.pathChangeHandler} />,
|
|
71
|
+
<EditSelectedButton onClick={this.clickHandler} />
|
|
44
72
|
|
|
45
73
|
]);
|
|
46
74
|
}
|
|
@@ -51,19 +79,3 @@ export default class View extends Element {
|
|
|
51
79
|
className: "view"
|
|
52
80
|
};
|
|
53
81
|
}
|
|
54
|
-
|
|
55
|
-
function openHandler(filePath) {
|
|
56
|
-
console.log("open", filePath)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function moveHandler(pathMaps, done) {
|
|
60
|
-
console.log("move", JSON.stringify(pathMaps, null, " "))
|
|
61
|
-
|
|
62
|
-
done();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function removeHandler(pathMaps, done) {
|
|
66
|
-
console.log("remove", JSON.stringify(pathMaps, null, " "))
|
|
67
|
-
|
|
68
|
-
done();
|
|
69
|
-
}
|
package/src/explorer.js
CHANGED
|
@@ -4,8 +4,8 @@ import withStyle from "easy-with-style"; ///
|
|
|
4
4
|
|
|
5
5
|
import { Element } from "easy";
|
|
6
6
|
import { dropMixins } from "easy-drag-and-drop";
|
|
7
|
-
import { asynchronousUtilities } from "necessary";
|
|
8
7
|
|
|
8
|
+
import eventMixins from "./mixins/event";
|
|
9
9
|
import EntriesList from "./list/entries";
|
|
10
10
|
import DragEntryItem from "./item/entry/drag";
|
|
11
11
|
import FileNameDragEntryItem from "./item/entry/drag/fileName";
|
|
@@ -14,12 +14,9 @@ import DirectoryNameDragEntryItem from "./item/entry/drag/directoryName";
|
|
|
14
14
|
import DirectoryNameMarkerEntryItem from "./item/entry/marker/directoryName";
|
|
15
15
|
|
|
16
16
|
import { explorerPadding } from "./styles";
|
|
17
|
-
import { OPEN_EVENT_TYPE, MOVE_EVENT_TYPE, SELECT_EVENT_TYPE } from "./eventTypes";
|
|
18
17
|
import { FILE_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "./entryTypes";
|
|
19
18
|
import { sourceEntryPathFromDragEntryItemPath, targetEntryPathFromMarkerEntryItemPath } from "./utilities/pathMap";
|
|
20
19
|
|
|
21
|
-
const { forEach } = asynchronousUtilities;
|
|
22
|
-
|
|
23
20
|
class Explorer extends Element {
|
|
24
21
|
constructor(selector, mounted) {
|
|
25
22
|
super(selector);
|
|
@@ -157,48 +154,6 @@ class Explorer extends Element {
|
|
|
157
154
|
return DirectoryNameMarkerEntryItem;
|
|
158
155
|
}
|
|
159
156
|
|
|
160
|
-
onMove(moveHandler, element) {
|
|
161
|
-
const eventType = MOVE_EVENT_TYPE,
|
|
162
|
-
handler = moveHandler; ///
|
|
163
|
-
|
|
164
|
-
this.addEventListener(eventType, handler, element);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
offMove(moveHandler, element) {
|
|
168
|
-
const eventType = MOVE_EVENT_TYPE,
|
|
169
|
-
handler = moveHandler; ///
|
|
170
|
-
|
|
171
|
-
this.removeEventListener(eventType, handler, element);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
onOpen(openHandler, element) {
|
|
175
|
-
const eventType = OPEN_EVENT_TYPE,
|
|
176
|
-
handler = openHandler; ///
|
|
177
|
-
|
|
178
|
-
this.addEventListener(eventType, handler, element);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
offOpen(openHandler, element) {
|
|
182
|
-
const eventType = OPEN_EVENT_TYPE,
|
|
183
|
-
handler = openHandler; ///
|
|
184
|
-
|
|
185
|
-
this.removeEventListener(eventType, handler, element);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
onSelect(selectHandler, element) {
|
|
189
|
-
const eventType = SELECT_EVENT_TYPE,
|
|
190
|
-
handler = selectHandler; ///
|
|
191
|
-
|
|
192
|
-
this.addEventListener(eventType, handler, element);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
offSelect(selectHandler, element) {
|
|
196
|
-
const eventType = SELECT_EVENT_TYPE,
|
|
197
|
-
handler = selectHandler; ///
|
|
198
|
-
|
|
199
|
-
this.removeEventListener(eventType, handler, element);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
157
|
retrievePaths(type) {
|
|
203
158
|
const dragEntryItems = this.retrieveDragEntryItems(),
|
|
204
159
|
paths = dragEntryItems.reduce((paths, dragEntryItem) => {
|
|
@@ -241,20 +196,21 @@ class Explorer extends Element {
|
|
|
241
196
|
}
|
|
242
197
|
|
|
243
198
|
selectDragEntryItem(dragEntryItem) {
|
|
244
|
-
const path = dragEntryItem.getPath()
|
|
245
|
-
selected = dragEntryItem.isSelected();
|
|
199
|
+
const path = dragEntryItem.getPath();
|
|
246
200
|
|
|
247
|
-
|
|
201
|
+
let selected = dragEntryItem.isSelected();
|
|
248
202
|
|
|
249
203
|
if (selected) {
|
|
250
204
|
dragEntryItem.deselect();
|
|
205
|
+
} else {
|
|
206
|
+
this.deselectAllPaths();
|
|
251
207
|
|
|
252
|
-
|
|
208
|
+
this.selectPath(path);
|
|
253
209
|
}
|
|
254
210
|
|
|
255
|
-
|
|
211
|
+
selected = !selected; ///
|
|
256
212
|
|
|
257
|
-
this.
|
|
213
|
+
this.callSelectHandlers(path, selected);
|
|
258
214
|
}
|
|
259
215
|
|
|
260
216
|
dropDragEntryItem(dragEntryItem, done) {
|
|
@@ -358,43 +314,6 @@ class Explorer extends Element {
|
|
|
358
314
|
this.addDirectoryPath(directoryPath, collapsed);
|
|
359
315
|
}
|
|
360
316
|
|
|
361
|
-
callMoveHandlersAsync(pathMaps, done) {
|
|
362
|
-
const eventType = MOVE_EVENT_TYPE,
|
|
363
|
-
eventListeners = this.findEventListeners(eventType);
|
|
364
|
-
|
|
365
|
-
forEach(eventListeners, (eventListener, next) => {
|
|
366
|
-
const { handler, element } = eventListener,
|
|
367
|
-
moveHandler = handler, ///
|
|
368
|
-
done = next; ///
|
|
369
|
-
|
|
370
|
-
moveHandler.call(element, pathMaps, done);
|
|
371
|
-
}, done);
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
callSelectHandlers(path, selected) {
|
|
375
|
-
const eventType = SELECT_EVENT_TYPE,
|
|
376
|
-
eventListeners = this.findEventListeners(eventType);
|
|
377
|
-
|
|
378
|
-
eventListeners.forEach((eventListener) => {
|
|
379
|
-
const { handler, element } = eventListener,
|
|
380
|
-
selectHandler = handler; ///
|
|
381
|
-
|
|
382
|
-
selectHandler.call(element, path, selected, this); ///
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
callOpenHandlers(filePath) {
|
|
387
|
-
const eventType = OPEN_EVENT_TYPE,
|
|
388
|
-
eventListeners = this.findEventListeners(eventType);
|
|
389
|
-
|
|
390
|
-
eventListeners.forEach((eventListener) => {
|
|
391
|
-
const { handler, element } = eventListener,
|
|
392
|
-
openHandler = handler; ///
|
|
393
|
-
|
|
394
|
-
openHandler.call(element, filePath, this); ///
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
|
|
398
317
|
didMount() {
|
|
399
318
|
const { onMove, onOpen, onSelect } = this.properties,
|
|
400
319
|
moveHandler = onMove, ///
|
|
@@ -496,6 +415,7 @@ class Explorer extends Element {
|
|
|
496
415
|
}
|
|
497
416
|
|
|
498
417
|
Object.assign(Explorer.prototype, dropMixins);
|
|
418
|
+
Object.assign(Explorer.prototype, eventMixins);
|
|
499
419
|
|
|
500
420
|
export default withStyle(Explorer)`
|
|
501
421
|
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { default as RubbishBin } from "./rubbishBin";
|
|
|
5
5
|
|
|
6
6
|
export { default as eventTypes } from "./eventTypes";
|
|
7
7
|
|
|
8
|
+
export { default as NameInput } from "./input/name";
|
|
8
9
|
export { default as NameButton } from "./button/name";
|
|
9
10
|
export { default as EntriesList } from "./list/entries";
|
|
10
11
|
export { default as ToggleButton } from "./button/toggle";
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import withStyle from "easy-with-style"; ///
|
|
4
|
+
|
|
5
|
+
import { Element } from "easy";
|
|
6
|
+
import { INLINE_BLOCK } from "../constants";
|
|
7
|
+
import { ENTER_KEY_CODE, ESCAPE_KEY_CODE } from "../keyCodes";
|
|
8
|
+
|
|
9
|
+
class NameInput extends Element {
|
|
10
|
+
keyDownHandler = (event, element) => {
|
|
11
|
+
const { keyCode } = event;
|
|
12
|
+
|
|
13
|
+
if (keyCode === ENTER_KEY_CODE) {
|
|
14
|
+
const { onChange } = this.properties,
|
|
15
|
+
changeHandler = onChange, ///
|
|
16
|
+
html = this.html(),
|
|
17
|
+
name = html; ///
|
|
18
|
+
|
|
19
|
+
changeHandler(name);
|
|
20
|
+
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (keyCode === ESCAPE_KEY_CODE) {
|
|
25
|
+
const { onCancel } = this.properties,
|
|
26
|
+
cancelHandler = onCancel; ///
|
|
27
|
+
|
|
28
|
+
cancelHandler();
|
|
29
|
+
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setName(name) {
|
|
35
|
+
const html = name; ///
|
|
36
|
+
|
|
37
|
+
this.html(html);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
show() {
|
|
41
|
+
const display = INLINE_BLOCK;
|
|
42
|
+
|
|
43
|
+
this.display(display);
|
|
44
|
+
|
|
45
|
+
this.focus();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
hide() {
|
|
49
|
+
super.hide();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
didMount() {
|
|
53
|
+
this.onKeyDown(this.keyDownHandler);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
willUnmount() {
|
|
57
|
+
this.offKeyDown(this.keyDownHandler);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
parentContext() {
|
|
61
|
+
const showNameInput = this.show.bind(this), ///
|
|
62
|
+
hideNameInput = this.hide.bind(this), ///
|
|
63
|
+
setNameInputName = this.setName.bind(this); ///
|
|
64
|
+
|
|
65
|
+
return ({
|
|
66
|
+
showNameInput,
|
|
67
|
+
hideNameInput,
|
|
68
|
+
setNameInputName
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static tagName = "span"; ///
|
|
73
|
+
|
|
74
|
+
static ignoredProperties = [
|
|
75
|
+
"onChange",
|
|
76
|
+
"onCancel"
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
static defaultProperties = {
|
|
80
|
+
role: "textbox",
|
|
81
|
+
className: "name",
|
|
82
|
+
contentEditable: "true"
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default withStyle(NameInput)`
|
|
87
|
+
|
|
88
|
+
display: inline-block;
|
|
89
|
+
|
|
90
|
+
`;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { dropMixins } from "easy-drag-and-drop";
|
|
4
4
|
|
|
5
|
-
import NameButton from "../../../button/name";
|
|
6
5
|
import ToggleButton from "../../../button/toggle";
|
|
7
6
|
import DragEntryItem from "../../../item/entry/drag";
|
|
8
7
|
import DirectoryNameSVG from "../../../svg/directoryName";
|
|
@@ -189,7 +188,7 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
189
188
|
|
|
190
189
|
childElements() {
|
|
191
190
|
const { name } = this.properties,
|
|
192
|
-
{ NameButton, ToggleButton, DirectoryNameSVG } = this.constructor,
|
|
191
|
+
{ NameInput, NameButton, ToggleButton, DirectoryNameSVG } = this.constructor,
|
|
193
192
|
explorer = this.getExplorer(),
|
|
194
193
|
EntriesList = explorer.getEntriesList();
|
|
195
194
|
|
|
@@ -197,17 +196,19 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
197
196
|
|
|
198
197
|
<DirectoryNameEntryItemDiv name={name}
|
|
199
198
|
explorer={explorer}
|
|
199
|
+
NameInput={NameInput}
|
|
200
200
|
NameButton={NameButton}
|
|
201
201
|
ToggleButton={ToggleButton}
|
|
202
202
|
DirectoryNameSVG={DirectoryNameSVG}
|
|
203
|
+
onNameChange={this.nameChangeHandler}
|
|
204
|
+
onNameCancel={this.nameCancelHandler}
|
|
205
|
+
onSVGButtonClick={this.svgButtonClickHandler}
|
|
203
206
|
/>,
|
|
204
207
|
<EntriesList explorer={explorer} />
|
|
205
208
|
|
|
206
209
|
]);
|
|
207
210
|
}
|
|
208
211
|
|
|
209
|
-
static NameButton = NameButton;
|
|
210
|
-
|
|
211
212
|
static ToggleButton = ToggleButton;
|
|
212
213
|
|
|
213
214
|
static DirectoryNameSVG = DirectoryNameSVG;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import NameButton from "../../../button/name";
|
|
4
3
|
import FileNameSVG from "../../../svg/fileName";
|
|
5
4
|
import DragEntryItem from "../../../item/entry/drag";
|
|
6
5
|
import FileNameEntryItemDiv from "../../../div/item/entry/fileName";
|
|
@@ -58,18 +57,23 @@ export default class FileNameDragEntryItem extends DragEntryItem {
|
|
|
58
57
|
|
|
59
58
|
childElements() {
|
|
60
59
|
const { name } = this.properties,
|
|
61
|
-
{ NameButton, FileNameSVG } = this.constructor,
|
|
60
|
+
{ NameInput, NameButton, FileNameSVG } = this.constructor,
|
|
62
61
|
explorer = this.getExplorer();
|
|
63
62
|
|
|
64
63
|
return (
|
|
65
64
|
|
|
66
|
-
<FileNameEntryItemDiv name={name}
|
|
67
|
-
|
|
65
|
+
<FileNameEntryItemDiv name={name}
|
|
66
|
+
explorer={explorer}
|
|
67
|
+
NameInput={NameInput}
|
|
68
|
+
NameButton={NameButton}
|
|
69
|
+
FileNameSVG={FileNameSVG}
|
|
70
|
+
onNameChange={this.nameChangeHandler}
|
|
71
|
+
onNameCancel={this.nameCancelHandler}
|
|
72
|
+
onSVGButtonClick={this.svgButtonClickHandler}
|
|
73
|
+
/>
|
|
68
74
|
);
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
static NameButton = NameButton;
|
|
72
|
-
|
|
73
77
|
static FileNameSVG = FileNameSVG;
|
|
74
78
|
|
|
75
79
|
static type = FILE_NAME_DRAG_ENTRY_TYPE;
|
package/src/item/entry/drag.js
CHANGED
|
@@ -5,11 +5,36 @@ import withStyle from "easy-with-style"; ///
|
|
|
5
5
|
import { dragMixins } from "easy-drag-and-drop";
|
|
6
6
|
|
|
7
7
|
import EntryItem from "../../item/entry";
|
|
8
|
+
import NameInput from "../../input/name";
|
|
9
|
+
import NameButton from "../../button/name";
|
|
8
10
|
|
|
9
|
-
import { dragEntryItemFontSize } from "../../styles";
|
|
10
11
|
import { adjustSourceEntryPath, adjustTargetEntryPath } from "../../utilities/pathMap";
|
|
11
12
|
|
|
12
13
|
class DragEntryItem extends EntryItem {
|
|
14
|
+
svgButtonClickHandler = (event, element) => {
|
|
15
|
+
const explorer = this.getExplorer(),
|
|
16
|
+
dragEntryItem = this; ///
|
|
17
|
+
|
|
18
|
+
explorer.selectDragEntryItem(dragEntryItem);
|
|
19
|
+
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
nameChangeHandler = (name) => {
|
|
24
|
+
const path = this.getPath(),
|
|
25
|
+
explorer = this.getExplorer();
|
|
26
|
+
|
|
27
|
+
explorer.callPathChangeHandlersAsync(path, (success) => {
|
|
28
|
+
success ?
|
|
29
|
+
this.update(name) :
|
|
30
|
+
this.cancel();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
nameCancelHandler = () => {
|
|
35
|
+
this.cancel();
|
|
36
|
+
}
|
|
37
|
+
|
|
13
38
|
startDragHandler = (element) => {
|
|
14
39
|
const path = this.getPath(),
|
|
15
40
|
type = this.getType(),
|
|
@@ -49,35 +74,35 @@ class DragEntryItem extends EntryItem {
|
|
|
49
74
|
return markerEntryItem;
|
|
50
75
|
}
|
|
51
76
|
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
getPathMaps(sourceEntryPath, targetEntryPath) {
|
|
78
|
+
let pathMaps = [];
|
|
54
79
|
|
|
55
|
-
|
|
56
|
-
}
|
|
80
|
+
this.retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps);
|
|
57
81
|
|
|
58
|
-
|
|
59
|
-
const name = this.getName();
|
|
82
|
+
pathMaps.reverse();
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
|
|
84
|
+
return pathMaps;
|
|
85
|
+
}
|
|
63
86
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
targetEntryPath
|
|
67
|
-
};
|
|
87
|
+
getPathMap(sourceEntryPath, targetEntryPath) {
|
|
88
|
+
const name = this.getName();
|
|
68
89
|
|
|
69
|
-
|
|
70
|
-
|
|
90
|
+
sourceEntryPath = adjustSourceEntryPath(sourceEntryPath, name); ///
|
|
91
|
+
targetEntryPath = adjustTargetEntryPath(targetEntryPath, name); ///
|
|
71
92
|
|
|
72
|
-
|
|
73
|
-
|
|
93
|
+
const pathMap = {
|
|
94
|
+
sourceEntryPath,
|
|
95
|
+
targetEntryPath
|
|
96
|
+
};
|
|
74
97
|
|
|
75
|
-
|
|
98
|
+
return pathMap;
|
|
99
|
+
}
|
|
76
100
|
|
|
77
|
-
|
|
101
|
+
isSelected() {
|
|
102
|
+
const selected = this.hasClass("selected"); ///
|
|
78
103
|
|
|
79
|
-
|
|
80
|
-
|
|
104
|
+
return selected;
|
|
105
|
+
}
|
|
81
106
|
|
|
82
107
|
deselect() {
|
|
83
108
|
this.removeClass("selected");
|
|
@@ -87,7 +112,33 @@ class DragEntryItem extends EntryItem {
|
|
|
87
112
|
this.addClass("selected");
|
|
88
113
|
}
|
|
89
114
|
|
|
115
|
+
edit() {
|
|
116
|
+
this.hideNameButton();
|
|
117
|
+
this.showNameInput();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
cancel() {
|
|
121
|
+
const nameButtonName = this.getNameButtonName(),
|
|
122
|
+
nameInputName = nameButtonName; ///
|
|
123
|
+
|
|
124
|
+
this.setNameInputName(nameInputName);
|
|
125
|
+
|
|
126
|
+
this.showNameButton();
|
|
127
|
+
this.hideNameInput();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
update(name) {
|
|
131
|
+
const nameButtonName = name; ///
|
|
132
|
+
|
|
133
|
+
this.setNameButtonName(nameButtonName);
|
|
134
|
+
|
|
135
|
+
this.showNameButton();
|
|
136
|
+
this.hideNameInput();
|
|
137
|
+
}
|
|
138
|
+
|
|
90
139
|
didMount() {
|
|
140
|
+
this.hideNameInput();
|
|
141
|
+
|
|
91
142
|
this.onStartDrag(this.startDragHandler);
|
|
92
143
|
|
|
93
144
|
this.onStopDrag(this.stopDragHandler);
|
|
@@ -119,7 +170,11 @@ class DragEntryItem extends EntryItem {
|
|
|
119
170
|
this.assignContext();
|
|
120
171
|
}
|
|
121
172
|
|
|
122
|
-
|
|
173
|
+
static NameInput = NameInput;
|
|
174
|
+
|
|
175
|
+
static NameButton = NameButton;
|
|
176
|
+
|
|
177
|
+
static defaultProperties = {
|
|
123
178
|
className: "drag"
|
|
124
179
|
};
|
|
125
180
|
}
|
|
@@ -128,7 +183,6 @@ Object.assign(EntryItem.prototype, dragMixins);
|
|
|
128
183
|
|
|
129
184
|
export default withStyle(DragEntryItem)`
|
|
130
185
|
|
|
131
|
-
font-size: ${dragEntryItemFontSize};
|
|
132
186
|
user-select: none;
|
|
133
187
|
|
|
134
188
|
font-weight: normal;
|
package/src/keyCodes.js
ADDED