easy-file-system 2.1.145 → 2.1.148
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 +535 -640
- package/lib/customEventTypes.js +46 -0
- package/lib/example/view.js +19 -19
- package/lib/explorer.js +21 -32
- package/lib/index.js +1 -5
- package/lib/item/entry/drag/directoryName.js +7 -7
- package/lib/item/entry/drag.js +13 -13
- package/lib/list/entries.js +6 -3
- package/lib/mixins/explorer.js +50 -102
- package/lib/mixins/nameSpan.js +18 -34
- package/lib/mixins/rubbishBin.js +10 -20
- package/lib/rubbishBin.js +10 -13
- package/lib/span/name.js +11 -8
- package/package.json +4 -3
- package/src/customEventTypes.js +10 -0
- package/src/example/view.js +18 -18
- package/src/explorer.js +31 -52
- package/src/index.js +0 -2
- package/src/item/entry/drag/directoryName.js +6 -6
- package/src/item/entry/drag.js +12 -12
- package/src/list/entries.js +8 -3
- package/src/mixins/explorer.js +66 -147
- package/src/mixins/nameSpan.js +21 -47
- package/src/mixins/rubbishBin.js +11 -29
- package/src/rubbishBin.js +10 -18
- package/src/span/name.js +15 -10
- package/lib/eventTypes.js +0 -59
- package/src/eventTypes.js +0 -21
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easy-file-system",
|
|
3
3
|
"author": "James Smith",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.148",
|
|
5
5
|
"license": "MIT, Anti-996",
|
|
6
6
|
"homepage": "https://github.com/djalbat/easy-file-system",
|
|
7
7
|
"description": "A file system explorer and a rubbish bin.",
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
"url": "https://github.com/djalbat/easy-file-system"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"easy": "^15.1.
|
|
14
|
-
"easy-drag-and-drop": "^1.3.
|
|
13
|
+
"easy": "^15.1.10",
|
|
14
|
+
"easy-drag-and-drop": "^1.3.84",
|
|
15
|
+
"easy-layout": "^6.0.85",
|
|
15
16
|
"easy-with-style": "^3.0.273",
|
|
16
17
|
"necessary": "^13.1.4"
|
|
17
18
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const OPEN_CUSTOM_EVENT_TYPE = "open-custom";
|
|
4
|
+
export const MOVE_CUSTOM_EVENT_TYPE = "move-custom";
|
|
5
|
+
export const CHANGE_CUSTOM_EVENT_TYPE = "change-custom";
|
|
6
|
+
export const CANCEL_CUSTOM_EVENT_TYPE = "cancel-custom";
|
|
7
|
+
export const SELECT_CUSTOM_EVENT_TYPE = "select-custom";
|
|
8
|
+
export const RENAME_CUSTOM_EVENT_TYPE = "rename-custom";
|
|
9
|
+
export const REMOVE_CUSTOM_EVENT_TYPE = "remove-custom";
|
|
10
|
+
export const CREATE_CUSTOM_EVENT_TYPE = "create-custom";
|
package/src/example/view.js
CHANGED
|
@@ -35,35 +35,35 @@ export default class View extends Element {
|
|
|
35
35
|
firstExplorer.renameSelectedPath();
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
openCustomHandler = (filePath, explorer) => {
|
|
39
39
|
console.log("open", filePath)
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
moveCustomHandler = (pathMaps, explorer, element, done) => {
|
|
43
43
|
console.log("move", JSON.stringify(pathMaps, null, " "))
|
|
44
44
|
|
|
45
45
|
done();
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
removeCustomHandler = (pathMaps, explorer, element, done) => {
|
|
49
49
|
console.log("remove", JSON.stringify(pathMaps, null, " "))
|
|
50
50
|
|
|
51
51
|
done();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
renameCustomHandler = (pathMaps, explorer, element, done) => {
|
|
55
55
|
console.log("rename", JSON.stringify(pathMaps, null, " "))
|
|
56
56
|
|
|
57
57
|
done();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
createCustomHandler = (pathMaps, explorer, element, done) => {
|
|
61
61
|
console.log("create", JSON.stringify(pathMaps, null, " "))
|
|
62
62
|
|
|
63
63
|
done();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
selectCustomHandler = (path, selected, readOnly, explorer) => {
|
|
67
67
|
console.log("select", path, selected, readOnly)
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -91,19 +91,19 @@ export default class View extends Element {
|
|
|
91
91
|
childElements() {
|
|
92
92
|
return ([
|
|
93
93
|
|
|
94
|
-
<RubbishBin
|
|
95
|
-
<FirstExplorer
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
<RubbishBin onCustomRemove={this.removeCustomHandler} />,
|
|
95
|
+
<FirstExplorer onCustomOpen={this.openCustomHandler}
|
|
96
|
+
onCustomMove={this.moveCustomHandler}
|
|
97
|
+
onCustomRemove={this.removeCustomHandler}
|
|
98
|
+
onCustomRename={this.renameCustomHandler}
|
|
99
|
+
onCustomCreate={this.createCustomHandler}
|
|
100
|
+
onCustomSelect={this.selectCustomHandler}
|
|
101
101
|
/>,
|
|
102
|
-
<SecondExplorer
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
<SecondExplorer onCustomOpen={this.openCustomHandler}
|
|
103
|
+
onCustomMove={this.moveCustomHandler}
|
|
104
|
+
onCustomRename={this.renameCustomHandler}
|
|
105
|
+
onCustomRemove={this.removeCustomHandler}
|
|
106
|
+
onCustomCreate={this.createCustomHandler}
|
|
107
107
|
/>,
|
|
108
108
|
<Button onClick={this.renameSelectedButtonClickHandler}>
|
|
109
109
|
Rename selected path
|
package/src/explorer.js
CHANGED
|
@@ -18,11 +18,17 @@ import { explorerPadding } from "./styles";
|
|
|
18
18
|
import { PERIOD, DOUBLE_CLICK_DELAY } from "./constants";
|
|
19
19
|
import { FILE_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "./entryTypes";
|
|
20
20
|
import { sourceEntryPathFromEntryItem, targetEntryPathFromEntryItem } from "./utilities/pathMap";
|
|
21
|
+
import { MOVE_CUSTOM_EVENT_TYPE,
|
|
22
|
+
OPEN_CUSTOM_EVENT_TYPE,
|
|
23
|
+
REMOVE_CUSTOM_EVENT_TYPE,
|
|
24
|
+
RENAME_CUSTOM_EVENT_TYPE,
|
|
25
|
+
SELECT_CUSTOM_EVENT_TYPE,
|
|
26
|
+
CREATE_CUSTOM_EVENT_TYPE } from "./customEventTypes";
|
|
21
27
|
|
|
22
28
|
const { concatenatePaths, pathWithoutBottommostNameFromPath } = pathUtilities;
|
|
23
29
|
|
|
24
30
|
class Explorer extends Element {
|
|
25
|
-
|
|
31
|
+
dragOverCustomHandler = (dragElement, element) => {
|
|
26
32
|
const dragEntryItem = dragElement, ///
|
|
27
33
|
markerEntryItem = this.retrieveMarkerEntryItem(),
|
|
28
34
|
dragEntryItemName = dragEntryItem.getName();
|
|
@@ -45,7 +51,7 @@ class Explorer extends Element {
|
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
dropCustomHandler = (dragElement, aborted, element, done) => {
|
|
49
55
|
const markerEntryItem = this.retrieveMarkerEntryItem(),
|
|
50
56
|
markerEntryItemExplorer = markerEntryItem.getExplorer();
|
|
51
57
|
|
|
@@ -285,9 +291,10 @@ class Explorer extends Element {
|
|
|
285
291
|
|
|
286
292
|
const fileNameDragEntryItemPath = fileNameDragEntryItem.getPath(),
|
|
287
293
|
filePath = fileNameDragEntryItemPath, ///
|
|
288
|
-
explorer = fileNameDragEntryItem.getExplorer()
|
|
294
|
+
explorer = fileNameDragEntryItem.getExplorer(),
|
|
295
|
+
customEventType = OPEN_CUSTOM_EVENT_TYPE;
|
|
289
296
|
|
|
290
|
-
this.
|
|
297
|
+
this.callCustomHandlers(customEventType, filePath, explorer);
|
|
291
298
|
}
|
|
292
299
|
|
|
293
300
|
selectOrDeselectDragEntryItem(dragEntryItem) {
|
|
@@ -312,9 +319,10 @@ class Explorer extends Element {
|
|
|
312
319
|
selected = !selected; ///
|
|
313
320
|
|
|
314
321
|
const readOnly = dragEntryItem.isReadOnly(),
|
|
315
|
-
explorer = dragEntryItem.getExplorer()
|
|
322
|
+
explorer = dragEntryItem.getExplorer(),
|
|
323
|
+
customEventType = SELECT_CUSTOM_EVENT_TYPE;
|
|
316
324
|
|
|
317
|
-
this.
|
|
325
|
+
this.callCustomHandlers(customEventType, path, selected, readOnly, explorer);
|
|
318
326
|
|
|
319
327
|
return selected;
|
|
320
328
|
}
|
|
@@ -382,7 +390,9 @@ class Explorer extends Element {
|
|
|
382
390
|
}
|
|
383
391
|
|
|
384
392
|
renameDragEntryItems(pathMaps, explorer, done) {
|
|
385
|
-
|
|
393
|
+
const customEventType = RENAME_CUSTOM_EVENT_TYPE;
|
|
394
|
+
|
|
395
|
+
this.callCustomHandlersAsync(customEventType, pathMaps, explorer, () => {
|
|
386
396
|
pathMaps.forEach((pathMap) => {
|
|
387
397
|
this.removeDragEntryItem(pathMap, explorer);
|
|
388
398
|
});
|
|
@@ -396,7 +406,9 @@ class Explorer extends Element {
|
|
|
396
406
|
}
|
|
397
407
|
|
|
398
408
|
moveDragEntryItems(pathMaps, explorer, done) {
|
|
399
|
-
|
|
409
|
+
const customEventType = MOVE_CUSTOM_EVENT_TYPE;
|
|
410
|
+
|
|
411
|
+
this.callCustomHandlersAsync(customEventType, pathMaps, explorer, () => {
|
|
400
412
|
pathMaps.forEach((pathMap) => {
|
|
401
413
|
this.removeDragEntryItem(pathMap, explorer);
|
|
402
414
|
});
|
|
@@ -410,7 +422,9 @@ class Explorer extends Element {
|
|
|
410
422
|
}
|
|
411
423
|
|
|
412
424
|
removeDragEntryItems(pathMaps, explorer, done) {
|
|
413
|
-
|
|
425
|
+
const customEventType = REMOVE_CUSTOM_EVENT_TYPE;
|
|
426
|
+
|
|
427
|
+
this.callCustomHandlersAsync(customEventType, pathMaps, explorer, () => {
|
|
414
428
|
pathMaps.forEach((pathMap) => {
|
|
415
429
|
this.removeDragEntryItem(pathMap, explorer);
|
|
416
430
|
});
|
|
@@ -424,7 +438,9 @@ class Explorer extends Element {
|
|
|
424
438
|
}
|
|
425
439
|
|
|
426
440
|
createDragEntryItems(pathMaps, explorer, done) {
|
|
427
|
-
|
|
441
|
+
const customEventType = CREATE_CUSTOM_EVENT_TYPE;
|
|
442
|
+
|
|
443
|
+
this.callCustomHandlersAsync(customEventType, pathMaps, explorer, () => {
|
|
428
444
|
pathMaps.forEach((pathMap) => {
|
|
429
445
|
this.removeDragEntryItem(pathMap, explorer);
|
|
430
446
|
});
|
|
@@ -558,30 +574,15 @@ class Explorer extends Element {
|
|
|
558
574
|
}
|
|
559
575
|
|
|
560
576
|
didMount() {
|
|
561
|
-
const {
|
|
562
|
-
moveHandler = onMove, ///
|
|
563
|
-
openHandler = onOpen, ///
|
|
564
|
-
createHandler = onCreate, ///
|
|
565
|
-
renameHandler = onRename, ///
|
|
566
|
-
selectHandler = onSelect; ///
|
|
577
|
+
const { singleClick = false } = this.properties;
|
|
567
578
|
|
|
568
579
|
this.setSingleClick(singleClick);
|
|
569
580
|
|
|
570
581
|
this.enableDrop();
|
|
571
582
|
|
|
572
|
-
this.
|
|
573
|
-
|
|
574
|
-
this.onDrop(this.dropHandler);
|
|
575
|
-
|
|
576
|
-
moveHandler && this.onMove(moveHandler);
|
|
577
|
-
|
|
578
|
-
openHandler && this.onOpen(openHandler);
|
|
579
|
-
|
|
580
|
-
createHandler && this.onCreate(createHandler);
|
|
583
|
+
this.onCustomDragOver(this.dragOverCustomHandler);
|
|
581
584
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
selectHandler && this.onSelect(selectHandler);
|
|
585
|
+
this.onCustomDrop(this.dropCustomHandler);
|
|
585
586
|
|
|
586
587
|
const mounted = true;
|
|
587
588
|
|
|
@@ -589,28 +590,11 @@ class Explorer extends Element {
|
|
|
589
590
|
}
|
|
590
591
|
|
|
591
592
|
willUnmount() {
|
|
592
|
-
const { onMove, onOpen, onSelect, onCreate, onRename } = this.properties,
|
|
593
|
-
moveHandler = onMove, ///
|
|
594
|
-
openHandler = onOpen, ///
|
|
595
|
-
createHandler = onCreate, ///
|
|
596
|
-
renameHandler = onRename, ///
|
|
597
|
-
selectHandler = onSelect; ///
|
|
598
|
-
|
|
599
593
|
this.disableDrop();
|
|
600
594
|
|
|
601
|
-
this.
|
|
602
|
-
|
|
603
|
-
this.offDrop(this.dropHandler);
|
|
604
|
-
|
|
605
|
-
moveHandler && this.offMove(moveHandler);
|
|
606
|
-
|
|
607
|
-
openHandler && this.offOpen(openHandler);
|
|
608
|
-
|
|
609
|
-
createHandler && this.offCreate(createHandler);
|
|
610
|
-
|
|
611
|
-
renameHandler && this.offRename(renameHandler);
|
|
595
|
+
this.offCustomDragOver(this.dragOverCustomHandler);
|
|
612
596
|
|
|
613
|
-
|
|
597
|
+
this.offCustomDrop(this.dropCustomHandler);
|
|
614
598
|
|
|
615
599
|
const mounted = false;
|
|
616
600
|
|
|
@@ -662,11 +646,6 @@ class Explorer extends Element {
|
|
|
662
646
|
static tagName = "div";
|
|
663
647
|
|
|
664
648
|
static ignoredProperties = [
|
|
665
|
-
"onMove",
|
|
666
|
-
"onOpen",
|
|
667
|
-
"onRename",
|
|
668
|
-
"onSelect",
|
|
669
|
-
"onCreate",
|
|
670
649
|
"reference",
|
|
671
650
|
"references",
|
|
672
651
|
"singleClick"
|
package/src/index.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
export { default as Explorer } from "./explorer";
|
|
4
4
|
export { default as RubbishBin } from "./rubbishBin";
|
|
5
5
|
|
|
6
|
-
export { default as eventTypes } from "./eventTypes";
|
|
7
|
-
|
|
8
6
|
export { default as NameSpan } from "./span/name";
|
|
9
7
|
export { default as EntriesList } from "./list/entries";
|
|
10
8
|
export { default as ToggleButton } from "./button/toggle";
|
|
@@ -14,7 +14,7 @@ import { FILE_NAME_DRAG_ENTRY_TYPE, FILE_NAME_MARKER_ENTRY_TYPE, DIRECTORY_NAME_
|
|
|
14
14
|
const { concatenatePaths } = pathUtilities;
|
|
15
15
|
|
|
16
16
|
export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
17
|
-
|
|
17
|
+
dragOverCustomHandler = (dragElement, element) => {
|
|
18
18
|
const collapsed = this.isCollapsed();
|
|
19
19
|
|
|
20
20
|
if (collapsed) {
|
|
@@ -45,7 +45,7 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
dropCustomHandler = (dragElement, aborted, element, done) => {
|
|
49
49
|
const dragEntryItem = dragElement, ///
|
|
50
50
|
markerEntryItem = this.retrieveMarkerEntryItem(),
|
|
51
51
|
markerEntryItemExplorer = markerEntryItem.getExplorer();
|
|
@@ -172,9 +172,9 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
172
172
|
|
|
173
173
|
this.enableDrop();
|
|
174
174
|
|
|
175
|
-
this.
|
|
175
|
+
this.onCustomDrop(this.dropCustomHandler);
|
|
176
176
|
|
|
177
|
-
this.
|
|
177
|
+
this.onCustomDragOver(this.dragOverCustomHandler);
|
|
178
178
|
|
|
179
179
|
super.didMount();
|
|
180
180
|
}
|
|
@@ -182,9 +182,9 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
182
182
|
willUnmount() {
|
|
183
183
|
this.disableDrop();
|
|
184
184
|
|
|
185
|
-
this.
|
|
185
|
+
this.offCustomDrop(this.dropCustomHandler);
|
|
186
186
|
|
|
187
|
-
this.
|
|
187
|
+
this.offCustomDragOver(this.dragOverCustomHandler);
|
|
188
188
|
|
|
189
189
|
super.willUnmount();
|
|
190
190
|
}
|
package/src/item/entry/drag.js
CHANGED
|
@@ -12,7 +12,7 @@ import { DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "../../entryTypes";
|
|
|
12
12
|
import { adjustSourceEntryPath, adjustTargetEntryPath } from "../../utilities/pathMap";
|
|
13
13
|
|
|
14
14
|
class DragEntryItem extends EntryItem {
|
|
15
|
-
|
|
15
|
+
nameSpanChangeCustomHandler = (event, element) => {
|
|
16
16
|
const created = this.isCreated(),
|
|
17
17
|
explorer = this.getExplorer(),
|
|
18
18
|
nameSpanName = this.getNameSpanName();
|
|
@@ -40,7 +40,7 @@ class DragEntryItem extends EntryItem {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
nameSpanCancelCustomHandler = (event, element) => {
|
|
44
44
|
const created = this.isCreated(),
|
|
45
45
|
explorer = this.getExplorer();
|
|
46
46
|
|
|
@@ -49,7 +49,7 @@ class DragEntryItem extends EntryItem {
|
|
|
49
49
|
this.cancel(created);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
startDragCustomHandler = (element) => {
|
|
53
53
|
const path = this.getPath(),
|
|
54
54
|
type = this.getType(),
|
|
55
55
|
explorer = this.getExplorer(),
|
|
@@ -59,7 +59,7 @@ class DragEntryItem extends EntryItem {
|
|
|
59
59
|
explorer.addMarker(markerEntryItemPath, dragEntryItemType);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
stopDragCustomHandler = (dropElement, aborted, element, done) => {
|
|
63
63
|
if (dropElement !== null) {
|
|
64
64
|
done();
|
|
65
65
|
|
|
@@ -227,25 +227,25 @@ class DragEntryItem extends EntryItem {
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
didMount() {
|
|
230
|
-
this.
|
|
230
|
+
this.onCustomStopDrag(this.stopDragCustomHandler);
|
|
231
231
|
|
|
232
|
-
this.
|
|
232
|
+
this.onCustomStartDrag(this.startDragCustomHandler);
|
|
233
233
|
|
|
234
|
-
this.
|
|
234
|
+
this.onCustomNameSpanChange(this.nameSpanChangeCustomHandler);
|
|
235
235
|
|
|
236
|
-
this.
|
|
236
|
+
this.onCustomNameSpanCancel(this.nameSpanCancelCustomHandler);
|
|
237
237
|
|
|
238
238
|
this.enableDrag();
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
willUnmount() {
|
|
242
|
-
this.
|
|
242
|
+
this.offCustomStopDrag(this.stopDragCustomHandler);
|
|
243
243
|
|
|
244
|
-
this.
|
|
244
|
+
this.offCustomStartDrag(this.startDragCustomHandler);
|
|
245
245
|
|
|
246
|
-
this.
|
|
246
|
+
this.offCustomNameSpanChange(this.nameSpanChangeCustomHandler);
|
|
247
247
|
|
|
248
|
-
this.
|
|
248
|
+
this.offCustomNameSpanCancel(this.nameSpanCancelCustomHandler);
|
|
249
249
|
|
|
250
250
|
this.disableDrag();
|
|
251
251
|
}
|
package/src/list/entries.js
CHANGED
|
@@ -80,11 +80,14 @@ class EntriesList extends Element {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
selectPath(path) {
|
|
83
|
+
let dragEntryItem = null;
|
|
84
|
+
|
|
83
85
|
const topmostDirectoryName = topmostDirectoryNameFromPath(path);
|
|
84
86
|
|
|
85
87
|
if (topmostDirectoryName === null) {
|
|
86
|
-
const name = path
|
|
87
|
-
|
|
88
|
+
const name = path; ///
|
|
89
|
+
|
|
90
|
+
dragEntryItem = this.findDragEntryItem(name);
|
|
88
91
|
|
|
89
92
|
if (dragEntryItem !== null) {
|
|
90
93
|
dragEntryItem.select();
|
|
@@ -99,9 +102,11 @@ class EntriesList extends Element {
|
|
|
99
102
|
|
|
100
103
|
topmostDirectoryNameDragEntryItem.expand();
|
|
101
104
|
|
|
102
|
-
topmostDirectoryNameDragEntryItem.selectPath(path);
|
|
105
|
+
dragEntryItem = topmostDirectoryNameDragEntryItem.selectPath(path);
|
|
103
106
|
}
|
|
104
107
|
}
|
|
108
|
+
|
|
109
|
+
return dragEntryItem;
|
|
105
110
|
}
|
|
106
111
|
|
|
107
112
|
addFilePath(filePath, readOnly = false) {
|