easy-file-system 1.5.24 → 1.5.26
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 +451 -365
- package/lib/button/name.js +5 -3
- package/lib/button/svg.js +27 -1
- package/lib/constants.js +9 -1
- package/lib/div/item/entry/directoryName.js +5 -13
- package/lib/div/item/entry/fileName.js +5 -13
- package/lib/eventTypes.js +17 -2
- package/lib/example/view/button.js +39 -0
- package/lib/example/view/explorer/first.js +2 -2
- package/lib/example/view.js +35 -14
- package/lib/explorer.js +73 -4
- package/lib/input/name.js +17 -38
- package/lib/item/entry/drag/directoryName.js +2 -12
- package/lib/item/entry/drag/fileName.js +2 -12
- package/lib/item/entry/drag.js +58 -23
- package/lib/list/entries.js +17 -15
- package/lib/mixins/explorer.js +22 -4
- package/lib/mixins/nameInput.js +52 -0
- package/lib/utilities/path.js +19 -0
- package/lib/utilities/pathMap.js +7 -8
- package/package.json +1 -1
- package/src/button/name.js +6 -2
- package/src/button/svg.js +10 -0
- package/src/constants.js +2 -0
- package/src/div/item/entry/directoryName.js +4 -10
- package/src/div/item/entry/fileName.js +4 -10
- package/src/eventTypes.js +7 -1
- package/src/example/view/button.js +14 -0
- package/src/example/view/explorer/first.js +2 -1
- package/src/example/view.js +44 -11
- package/src/explorer.js +89 -5
- package/src/input/name.js +27 -20
- package/src/item/entry/drag/directoryName.js +0 -9
- package/src/item/entry/drag/fileName.js +0 -9
- package/src/item/entry/drag.js +82 -32
- package/src/list/entries.js +17 -16
- package/src/mixins/explorer.js +38 -8
- package/src/mixins/nameInput.js +66 -0
- package/src/utilities/path.js +16 -0
- package/src/utilities/pathMap.js +10 -15
- package/lib/example/view/button/editSelected.js +0 -157
- package/src/example/view/button/editSelected.js +0 -23
package/src/item/entry/drag.js
CHANGED
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
import withStyle from "easy-with-style"; ///
|
|
4
4
|
|
|
5
5
|
import { dragMixins } from "easy-drag-and-drop";
|
|
6
|
-
import { pathUtilities } from "necessary";
|
|
7
6
|
|
|
8
7
|
import EntryItem from "../../item/entry";
|
|
9
8
|
import NameInput from "../../input/name";
|
|
10
9
|
import NameButton from "../../button/name";
|
|
11
10
|
|
|
11
|
+
import { EMPTY_STRING } from "../../constants";
|
|
12
|
+
import { DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "../../entryTypes";
|
|
12
13
|
import { adjustSourceEntryPath, adjustTargetEntryPath } from "../../utilities/pathMap";
|
|
13
14
|
|
|
14
|
-
const { concatenatePaths, pathWithoutBottommostNameFromPath } = pathUtilities;
|
|
15
|
-
|
|
16
15
|
class DragEntryItem extends EntryItem {
|
|
17
16
|
svgButtonClickHandler = (event, element) => {
|
|
18
17
|
const explorer = this.getExplorer(),
|
|
@@ -23,24 +22,36 @@ class DragEntryItem extends EntryItem {
|
|
|
23
22
|
event.stopPropagation();
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
const
|
|
25
|
+
nameInputChangeHandler = () => {
|
|
26
|
+
const created = this.isCreated(),
|
|
27
|
+
explorer = this.getExplorer(),
|
|
28
|
+
nameChanged = this.hasNameChanged(),
|
|
29
|
+
dragEntryItem = this; ///
|
|
28
30
|
|
|
29
31
|
if (!nameChanged) {
|
|
30
|
-
this.cancel();
|
|
31
|
-
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (created) {
|
|
36
|
+
explorer.createDragEntryItem(dragEntryItem, () => {
|
|
37
|
+
this.cancel();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
37
42
|
|
|
38
43
|
explorer.renameDragEntryItem(dragEntryItem, () => {
|
|
39
44
|
this.cancel();
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
|
|
48
|
+
nameInputCancelHandler = () => {
|
|
49
|
+
const created = this.isCreated();
|
|
50
|
+
|
|
51
|
+
created ?
|
|
52
|
+
this.remove() :
|
|
53
|
+
this.cancel();
|
|
54
|
+
|
|
44
55
|
this.cancel();
|
|
45
56
|
}
|
|
46
57
|
|
|
@@ -77,29 +88,17 @@ class DragEntryItem extends EntryItem {
|
|
|
77
88
|
markerEntryItemExplorer.dropDragEntryItem(dragEntryItem, done);
|
|
78
89
|
}
|
|
79
90
|
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
inputName = nameInputName; ///
|
|
83
|
-
|
|
84
|
-
return inputName;
|
|
85
|
-
}
|
|
91
|
+
isCreated() {
|
|
92
|
+
const { created } = this.properties;
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
const path = this.getPath(),
|
|
89
|
-
inputName = this.getInputName(),
|
|
90
|
-
pathWithoutBottommostName = pathWithoutBottommostNameFromPath(path),
|
|
91
|
-
inputPath = (pathWithoutBottommostName === null) ?
|
|
92
|
-
inputName :
|
|
93
|
-
concatenatePaths(pathWithoutBottommostName, inputName);
|
|
94
|
-
|
|
95
|
-
return inputPath;
|
|
94
|
+
return created;
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
getPathMap(sourceEntryPath, targetEntryPath) {
|
|
99
98
|
const name = this.getName(),
|
|
100
99
|
collapsed = this.isCollapsed(),
|
|
101
100
|
nameInputName = this.getNameInputName(),
|
|
102
|
-
entryDirectory = this.
|
|
101
|
+
entryDirectory = this.getEntryDirectory();
|
|
103
102
|
|
|
104
103
|
sourceEntryPath = adjustSourceEntryPath(sourceEntryPath, name); ///
|
|
105
104
|
|
|
@@ -126,25 +125,47 @@ class DragEntryItem extends EntryItem {
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
hasNameChanged() {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
nameChanged = (
|
|
128
|
+
const nameInputName = this.getNameInputName(),
|
|
129
|
+
nameButtonName = this.getNameButtonName(),
|
|
130
|
+
nameChanged = (nameInputName !== nameButtonName);
|
|
132
131
|
|
|
133
132
|
return nameChanged;
|
|
134
133
|
}
|
|
135
134
|
|
|
135
|
+
getEntryDirectory() {
|
|
136
|
+
const directoryNameDragEntryItem = this.isDirectoryNameDragEntryItem(),
|
|
137
|
+
entryDirectory = directoryNameDragEntryItem; ///
|
|
138
|
+
|
|
139
|
+
return entryDirectory;
|
|
140
|
+
}
|
|
141
|
+
|
|
136
142
|
retrieveMarkerEntryItem() {
|
|
137
143
|
const { markerEntryItem } = globalThis;
|
|
138
144
|
|
|
139
145
|
return markerEntryItem;
|
|
140
146
|
}
|
|
141
147
|
|
|
148
|
+
isDirectoryNameDragEntryItem() {
|
|
149
|
+
const type = this.getType(),
|
|
150
|
+
typeDirectoryNameDragEntryItemType = (type === DIRECTORY_NAME_DRAG_ENTRY_TYPE),
|
|
151
|
+
directoryNameDragEntryItem = typeDirectoryNameDragEntryItemType; ///
|
|
152
|
+
|
|
153
|
+
return directoryNameDragEntryItem;
|
|
154
|
+
}
|
|
155
|
+
|
|
142
156
|
isSelected() {
|
|
143
157
|
const selected = this.hasClass("selected"); ///
|
|
144
158
|
|
|
145
159
|
return selected;
|
|
146
160
|
}
|
|
147
161
|
|
|
162
|
+
isEdited() {
|
|
163
|
+
const nameInputDisplayed = this.isNameInputDisplayed(),
|
|
164
|
+
edited = nameInputDisplayed; ///
|
|
165
|
+
|
|
166
|
+
return edited;
|
|
167
|
+
}
|
|
168
|
+
|
|
148
169
|
deselect() {
|
|
149
170
|
this.removeClass("selected");
|
|
150
171
|
}
|
|
@@ -154,7 +175,20 @@ class DragEntryItem extends EntryItem {
|
|
|
154
175
|
}
|
|
155
176
|
|
|
156
177
|
edit() {
|
|
178
|
+
const created = this.isCreated();
|
|
179
|
+
|
|
180
|
+
if (created) {
|
|
181
|
+
const name = EMPTY_STRING,
|
|
182
|
+
nameInputName = name, ///
|
|
183
|
+
nameButtonName = name; ///
|
|
184
|
+
|
|
185
|
+
this.setNameInputName(nameInputName);
|
|
186
|
+
|
|
187
|
+
this.setNameButtonName(nameButtonName);
|
|
188
|
+
}
|
|
189
|
+
|
|
157
190
|
this.hideNameButton();
|
|
191
|
+
|
|
158
192
|
this.showNameInput();
|
|
159
193
|
}
|
|
160
194
|
|
|
@@ -171,17 +205,29 @@ class DragEntryItem extends EntryItem {
|
|
|
171
205
|
didMount() {
|
|
172
206
|
this.hideNameInput();
|
|
173
207
|
|
|
174
|
-
this.onStartDrag(this.startDragHandler);
|
|
175
|
-
|
|
176
208
|
this.onStopDrag(this.stopDragHandler);
|
|
177
209
|
|
|
210
|
+
this.onStartDrag(this.startDragHandler);
|
|
211
|
+
|
|
212
|
+
this.onSVGButtonClick(this.svgButtonClickHandler);
|
|
213
|
+
|
|
214
|
+
this.onNameInputChange(this.nameInputChangeHandler);
|
|
215
|
+
|
|
216
|
+
this.onNameInputCancel(this.nameInputCancelHandler);
|
|
217
|
+
|
|
178
218
|
this.enableDrag();
|
|
179
219
|
}
|
|
180
220
|
|
|
181
221
|
willUnmount() {
|
|
222
|
+
this.offStopDrag(this.stopDragHandler);
|
|
223
|
+
|
|
182
224
|
this.offStartDrag(this.startDragHandler);
|
|
183
225
|
|
|
184
|
-
this.
|
|
226
|
+
this.offSVGButtonClick(this.svgButtonClickHandler);
|
|
227
|
+
|
|
228
|
+
this.offNameInputChange(this.nameInputChangeHandler);
|
|
229
|
+
|
|
230
|
+
this.offNameInputCancel(this.nameInputCancelHandler);
|
|
185
231
|
|
|
186
232
|
this.disableDrag();
|
|
187
233
|
}
|
|
@@ -206,6 +252,10 @@ class DragEntryItem extends EntryItem {
|
|
|
206
252
|
|
|
207
253
|
static NameButton = NameButton;
|
|
208
254
|
|
|
255
|
+
static ignoredProperties = [
|
|
256
|
+
"created"
|
|
257
|
+
];
|
|
258
|
+
|
|
209
259
|
static defaultProperties = {
|
|
210
260
|
className: "drag"
|
|
211
261
|
};
|
package/src/list/entries.js
CHANGED
|
@@ -104,7 +104,7 @@ class EntriesList extends Element {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
addFilePath(filePath) {
|
|
107
|
+
addFilePath(filePath, created = false) {
|
|
108
108
|
let fileNameDragEntryItem;
|
|
109
109
|
|
|
110
110
|
const topmostDirectoryName = topmostDirectoryNameFromPath(filePath);
|
|
@@ -115,7 +115,7 @@ class EntriesList extends Element {
|
|
|
115
115
|
fileNameDragEntryItem = this.findFileNameDragEntryItem(fileName);
|
|
116
116
|
|
|
117
117
|
if (fileNameDragEntryItem === null) {
|
|
118
|
-
fileNameDragEntryItem = this.createFileNameDragEntryItem(fileName);
|
|
118
|
+
fileNameDragEntryItem = this.createFileNameDragEntryItem(fileName, created);
|
|
119
119
|
|
|
120
120
|
this.addEntryItem(fileNameDragEntryItem);
|
|
121
121
|
}
|
|
@@ -123,9 +123,10 @@ class EntriesList extends Element {
|
|
|
123
123
|
let topmostDirectoryNameDragEntryItem = this.findDirectoryNameDragEntryItem(topmostDirectoryName);
|
|
124
124
|
|
|
125
125
|
if (topmostDirectoryNameDragEntryItem === null) {
|
|
126
|
-
const
|
|
126
|
+
const created = false,
|
|
127
|
+
collapsed = true;
|
|
127
128
|
|
|
128
|
-
topmostDirectoryNameDragEntryItem = this.createDirectoryNameDragEntryItem(topmostDirectoryName, collapsed);
|
|
129
|
+
topmostDirectoryNameDragEntryItem = this.createDirectoryNameDragEntryItem(topmostDirectoryName, collapsed, created);
|
|
129
130
|
|
|
130
131
|
this.addEntryItem(topmostDirectoryNameDragEntryItem);
|
|
131
132
|
}
|
|
@@ -134,7 +135,7 @@ class EntriesList extends Element {
|
|
|
134
135
|
|
|
135
136
|
filePath = filePathWithoutTopmostDirectoryName; ///
|
|
136
137
|
|
|
137
|
-
fileNameDragEntryItem = topmostDirectoryNameDragEntryItem.addFilePath(filePath);
|
|
138
|
+
fileNameDragEntryItem = topmostDirectoryNameDragEntryItem.addFilePath(filePath, created);
|
|
138
139
|
}
|
|
139
140
|
|
|
140
141
|
return fileNameDragEntryItem;
|
|
@@ -183,7 +184,7 @@ class EntriesList extends Element {
|
|
|
183
184
|
});
|
|
184
185
|
}
|
|
185
186
|
|
|
186
|
-
addDirectoryPath(directoryPath, collapsed = true) {
|
|
187
|
+
addDirectoryPath(directoryPath, collapsed = true, created = false) {
|
|
187
188
|
let directoryNameDragEntryItem;
|
|
188
189
|
|
|
189
190
|
const topmostDirectoryName = topmostDirectoryNameFromPath(directoryPath);
|
|
@@ -194,7 +195,9 @@ class EntriesList extends Element {
|
|
|
194
195
|
directoryNameDragEntryItem = this.findDirectoryNameDragEntryItem(directoryName);
|
|
195
196
|
|
|
196
197
|
if (directoryNameDragEntryItem === null) {
|
|
197
|
-
|
|
198
|
+
const created = false;
|
|
199
|
+
|
|
200
|
+
directoryNameDragEntryItem = this.createDirectoryNameDragEntryItem(directoryName, collapsed, created);
|
|
198
201
|
|
|
199
202
|
this.addEntryItem(directoryNameDragEntryItem);
|
|
200
203
|
} else {
|
|
@@ -206,7 +209,7 @@ class EntriesList extends Element {
|
|
|
206
209
|
let topmostDirectoryNameDragEntryItem = this.findDirectoryNameDragEntryItem(topmostDirectoryName);
|
|
207
210
|
|
|
208
211
|
if (topmostDirectoryNameDragEntryItem === null) {
|
|
209
|
-
topmostDirectoryNameDragEntryItem = this.createDirectoryNameDragEntryItem(topmostDirectoryName, collapsed);
|
|
212
|
+
topmostDirectoryNameDragEntryItem = this.createDirectoryNameDragEntryItem(topmostDirectoryName, collapsed, created);
|
|
210
213
|
|
|
211
214
|
this.addEntryItem(topmostDirectoryNameDragEntryItem);
|
|
212
215
|
}
|
|
@@ -215,7 +218,7 @@ class EntriesList extends Element {
|
|
|
215
218
|
|
|
216
219
|
directoryPath = directoryPathWithoutTopmostDirectoryName; ///
|
|
217
220
|
|
|
218
|
-
directoryNameDragEntryItem = topmostDirectoryNameDragEntryItem.addDirectoryPath(directoryPath, collapsed);
|
|
221
|
+
directoryNameDragEntryItem = topmostDirectoryNameDragEntryItem.addDirectoryPath(directoryPath, collapsed, created);
|
|
219
222
|
}
|
|
220
223
|
|
|
221
224
|
return directoryNameDragEntryItem;
|
|
@@ -364,26 +367,26 @@ class EntriesList extends Element {
|
|
|
364
367
|
});
|
|
365
368
|
}
|
|
366
369
|
|
|
367
|
-
createFileNameDragEntryItem(fileName) {
|
|
370
|
+
createFileNameDragEntryItem(fileName, created) {
|
|
368
371
|
const name = fileName, ///
|
|
369
372
|
explorer = this.getExplorer(),
|
|
370
373
|
FileNameDragEntryItem = explorer.getFileNameDragEntryItem(),
|
|
371
374
|
fileNameDragEntryItem =
|
|
372
375
|
|
|
373
|
-
<FileNameDragEntryItem name={name} explorer={explorer} />
|
|
376
|
+
<FileNameDragEntryItem name={name} explorer={explorer} created={created} />
|
|
374
377
|
|
|
375
378
|
;
|
|
376
379
|
|
|
377
380
|
return fileNameDragEntryItem;
|
|
378
381
|
}
|
|
379
382
|
|
|
380
|
-
createDirectoryNameDragEntryItem(directoryName, collapsed) {
|
|
383
|
+
createDirectoryNameDragEntryItem(directoryName, collapsed, created) {
|
|
381
384
|
const name = directoryName, ///
|
|
382
385
|
explorer = this.getExplorer(),
|
|
383
386
|
DirectoryNameDragEntryItem = explorer.getDirectoryNameDragEntryItem(),
|
|
384
387
|
directoryNameDragEntryItem =
|
|
385
388
|
|
|
386
|
-
<DirectoryNameDragEntryItem name={name} collapsed={collapsed}
|
|
389
|
+
<DirectoryNameDragEntryItem name={name} explorer={explorer} collapsed={collapsed} created={created} />
|
|
387
390
|
|
|
388
391
|
;
|
|
389
392
|
|
|
@@ -525,8 +528,6 @@ class EntriesList extends Element {
|
|
|
525
528
|
const selected = dragEntryItem.isSelected();
|
|
526
529
|
|
|
527
530
|
if (selected) {
|
|
528
|
-
dragEntryItem.edit();
|
|
529
|
-
|
|
530
531
|
return true;
|
|
531
532
|
}
|
|
532
533
|
}) || null;
|
|
@@ -595,7 +596,7 @@ class EntriesList extends Element {
|
|
|
595
596
|
forEachDragEntryItem = this.forEachDragEntryItem.bind(this),
|
|
596
597
|
retrieveDragEntryItems = this.retrieveDragEntryItems.bind(this),
|
|
597
598
|
retrieveMarkerEntryItem = this.retrieveMarkerEntryItem.bind(this),
|
|
598
|
-
retrieveSelectedDragEntryItem = this.retrieveSelectedDragEntryItem.bind(this)
|
|
599
|
+
retrieveSelectedDragEntryItem = this.retrieveSelectedDragEntryItem.bind(this);
|
|
599
600
|
|
|
600
601
|
return ({
|
|
601
602
|
expandEntriesList,
|
package/src/mixins/explorer.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { asynchronousUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
-
import { MOVE_EVENT_TYPE, OPEN_EVENT_TYPE, REMOVE_EVENT_TYPE, RENAME_EVENT_TYPE, SELECT_EVENT_TYPE } from "../eventTypes";
|
|
5
|
+
import { MOVE_EVENT_TYPE, OPEN_EVENT_TYPE, REMOVE_EVENT_TYPE, RENAME_EVENT_TYPE, SELECT_EVENT_TYPE, CREATE_EVENT_TYPE } from "../eventTypes";
|
|
6
6
|
|
|
7
7
|
const { forEach } = asynchronousUtilities;
|
|
8
8
|
|
|
@@ -62,6 +62,20 @@ function offRename(renameHandler, element) {
|
|
|
62
62
|
this.removeEventListener(eventType, handler, element);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
function onCreate(createHandler, element) {
|
|
66
|
+
const eventType = CREATE_EVENT_TYPE,
|
|
67
|
+
handler = createHandler; ///
|
|
68
|
+
|
|
69
|
+
this.addEventListener(eventType, handler, element);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function offCreate(createHandler, element) {
|
|
73
|
+
const eventType = CREATE_EVENT_TYPE,
|
|
74
|
+
handler = createHandler; ///
|
|
75
|
+
|
|
76
|
+
this.removeEventListener(eventType, handler, element);
|
|
77
|
+
}
|
|
78
|
+
|
|
65
79
|
function onSelect(selectHandler, element) {
|
|
66
80
|
const eventType = SELECT_EVENT_TYPE,
|
|
67
81
|
handler = selectHandler; ///
|
|
@@ -94,7 +108,7 @@ function callSelectHandlers(path, selected) {
|
|
|
94
108
|
|
|
95
109
|
eventListeners.forEach((eventListener) => {
|
|
96
110
|
const { handler, element } = eventListener,
|
|
97
|
-
|
|
111
|
+
selectHandler = handler; ///
|
|
98
112
|
|
|
99
113
|
selectHandler.call(element, path, selected, this); ///
|
|
100
114
|
});
|
|
@@ -115,12 +129,12 @@ function callMoveHandlersAsync(pathMaps, done) {
|
|
|
115
129
|
|
|
116
130
|
function callRemoveHandlersAsync(pathMaps, done) {
|
|
117
131
|
const eventType = REMOVE_EVENT_TYPE,
|
|
118
|
-
|
|
132
|
+
eventListeners = this.findEventListeners(eventType);
|
|
119
133
|
|
|
120
134
|
forEach(eventListeners, (eventListener, next) => {
|
|
121
135
|
const { handler, element } = eventListener,
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
removeHandler = handler, ///
|
|
137
|
+
done = next; ///
|
|
124
138
|
|
|
125
139
|
removeHandler.call(element, pathMaps, done);
|
|
126
140
|
}, done);
|
|
@@ -139,7 +153,20 @@ function callRenameHandlersAsync(pathMaps, done) {
|
|
|
139
153
|
}, done);
|
|
140
154
|
}
|
|
141
155
|
|
|
142
|
-
|
|
156
|
+
function callCreateHandlersAsync(pathMaps, done) {
|
|
157
|
+
const eventType = CREATE_EVENT_TYPE,
|
|
158
|
+
eventListeners = this.findEventListeners(eventType);
|
|
159
|
+
|
|
160
|
+
forEach(eventListeners, (eventListener, next) => {
|
|
161
|
+
const { handler, element } = eventListener,
|
|
162
|
+
createHandler = handler, ///
|
|
163
|
+
done = next; ///
|
|
164
|
+
|
|
165
|
+
createHandler.call(element, pathMaps, done);
|
|
166
|
+
}, done);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const explorerMixins = {
|
|
143
170
|
onOpen,
|
|
144
171
|
offOpen,
|
|
145
172
|
onMove,
|
|
@@ -148,13 +175,16 @@ const eventMixins = {
|
|
|
148
175
|
offRemove,
|
|
149
176
|
onRename,
|
|
150
177
|
offRename,
|
|
178
|
+
onCreate,
|
|
179
|
+
offCreate,
|
|
151
180
|
onSelect,
|
|
152
181
|
offSelect,
|
|
153
182
|
callOpenHandlers,
|
|
154
183
|
callSelectHandlers,
|
|
155
184
|
callMoveHandlersAsync,
|
|
156
185
|
callRemoveHandlersAsync,
|
|
157
|
-
callRenameHandlersAsync
|
|
186
|
+
callRenameHandlersAsync,
|
|
187
|
+
callCreateHandlersAsync
|
|
158
188
|
};
|
|
159
189
|
|
|
160
|
-
export default
|
|
190
|
+
export default explorerMixins;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { CHANGE_EVENT_TYPE, CANCEL_EVENT_TYPE } from "../eventTypes";
|
|
4
|
+
|
|
5
|
+
function onChange(changeHandler, element) {
|
|
6
|
+
const eventType = CHANGE_EVENT_TYPE,
|
|
7
|
+
handler = changeHandler; ///
|
|
8
|
+
|
|
9
|
+
this.addEventListener(eventType, handler, element);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function offChange(changeHandler, element) {
|
|
13
|
+
const eventType = CHANGE_EVENT_TYPE,
|
|
14
|
+
handler = changeHandler; ///
|
|
15
|
+
|
|
16
|
+
this.removeEventListener(eventType, handler, element);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function onCancel(cancelHandler, element) {
|
|
20
|
+
const eventType = CANCEL_EVENT_TYPE,
|
|
21
|
+
handler = cancelHandler; ///
|
|
22
|
+
|
|
23
|
+
this.addEventListener(eventType, handler, element);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function offCancel(cancelHandler, element) {
|
|
27
|
+
const eventType = CANCEL_EVENT_TYPE,
|
|
28
|
+
handler = cancelHandler; ///
|
|
29
|
+
|
|
30
|
+
this.removeEventListener(eventType, handler, element);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function callChangeHandlers() {
|
|
34
|
+
const eventType = CHANGE_EVENT_TYPE,
|
|
35
|
+
eventListeners = this.findEventListeners(eventType);
|
|
36
|
+
|
|
37
|
+
eventListeners.forEach((eventListener) => {
|
|
38
|
+
const { handler, element } = eventListener,
|
|
39
|
+
changeHandler = handler; ///
|
|
40
|
+
|
|
41
|
+
changeHandler.call(element);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function callCancelHandlers() {
|
|
46
|
+
const eventType = CANCEL_EVENT_TYPE,
|
|
47
|
+
eventListeners = this.findEventListeners(eventType);
|
|
48
|
+
|
|
49
|
+
eventListeners.forEach((eventListener) => {
|
|
50
|
+
const { handler, element } = eventListener,
|
|
51
|
+
cancelHandler = handler; ///
|
|
52
|
+
|
|
53
|
+
cancelHandler.call(element);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const nameInputMixins = {
|
|
58
|
+
onChange,
|
|
59
|
+
offChange,
|
|
60
|
+
onCancel,
|
|
61
|
+
offCancel,
|
|
62
|
+
callChangeHandlers,
|
|
63
|
+
callCancelHandlers
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default nameInputMixins;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { pathUtilities } from "necessary";
|
|
4
|
+
|
|
5
|
+
import { EMPTY_STRING } from "../constants";
|
|
6
|
+
|
|
7
|
+
const { pathWithoutBottommostNameFromPath } = pathUtilities;
|
|
8
|
+
|
|
9
|
+
export function nonNullPathWithoutBottommostNameFromPath(path) {
|
|
10
|
+
const pathWithoutBottommostName = pathWithoutBottommostNameFromPath(path),
|
|
11
|
+
nonNullPathWithoutBottommostName = (pathWithoutBottommostName !== null) ?
|
|
12
|
+
pathWithoutBottommostName : ///
|
|
13
|
+
EMPTY_STRING;
|
|
14
|
+
|
|
15
|
+
return nonNullPathWithoutBottommostName;
|
|
16
|
+
}
|
package/src/utilities/pathMap.js
CHANGED
|
@@ -3,21 +3,22 @@
|
|
|
3
3
|
import { pathUtilities } from "necessary";
|
|
4
4
|
|
|
5
5
|
import { EMPTY_STRING } from "../constants";
|
|
6
|
+
import { nonNullPathWithoutBottommostNameFromPath } from "../utilities/path";
|
|
6
7
|
|
|
7
|
-
const { concatenatePaths
|
|
8
|
+
const { concatenatePaths } = pathUtilities;
|
|
8
9
|
|
|
9
10
|
export function sourceEntryPathFromEntryItem(entryItem) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
sourceEntryPath =
|
|
11
|
+
const path = entryItem.getPath(),
|
|
12
|
+
nonNullPathWithoutBottommostName = nonNullPathWithoutBottommostNameFromPath(path),
|
|
13
|
+
sourceEntryPath = nonNullPathWithoutBottommostName; ///
|
|
13
14
|
|
|
14
15
|
return sourceEntryPath;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export function targetEntryPathFromEntryItem(entryItem) {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
targetEntryPath =
|
|
19
|
+
const path = entryItem.getPath(),
|
|
20
|
+
nonNullPathWithoutBottommostName = nonNullPathWithoutBottommostNameFromPath(path),
|
|
21
|
+
targetEntryPath = nonNullPathWithoutBottommostName; ///
|
|
21
22
|
|
|
22
23
|
return targetEntryPath;
|
|
23
24
|
}
|
|
@@ -25,6 +26,8 @@ export function targetEntryPathFromEntryItem(entryItem) {
|
|
|
25
26
|
export function adjustSourceEntryPath(sourceEntryPath, name) {
|
|
26
27
|
if (false) {
|
|
27
28
|
///
|
|
29
|
+
} else if (sourceEntryPath === null) {
|
|
30
|
+
sourceEntryPath = null;
|
|
28
31
|
} else if (sourceEntryPath === EMPTY_STRING) {
|
|
29
32
|
sourceEntryPath = name; ///
|
|
30
33
|
} else {
|
|
@@ -47,11 +50,3 @@ export function adjustTargetEntryPath(targetEntryPath, nameInputName) {
|
|
|
47
50
|
|
|
48
51
|
return targetEntryPath;
|
|
49
52
|
}
|
|
50
|
-
|
|
51
|
-
function nonNullPathFromName(name) {
|
|
52
|
-
const path = (name !== null) ?
|
|
53
|
-
name : ///
|
|
54
|
-
EMPTY_STRING;
|
|
55
|
-
|
|
56
|
-
return path;
|
|
57
|
-
}
|