easy-file-system 1.5.25 → 1.5.27
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 +429 -335
- package/lib/button/name.js +5 -3
- package/lib/button/svg.js +27 -1
- package/lib/constants.js +5 -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 +67 -3
- package/lib/input/name.js +12 -12
- package/lib/item/entry/drag/directoryName.js +2 -12
- package/lib/item/entry/drag/fileName.js +2 -12
- package/lib/item/entry/drag.js +51 -23
- package/lib/list/entries.js +17 -14
- 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 +1 -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 +80 -4
- package/src/input/name.js +20 -16
- package/src/item/entry/drag/directoryName.js +0 -9
- package/src/item/entry/drag/fileName.js +0 -9
- package/src/item/entry/drag.js +75 -32
- package/src/list/entries.js +17 -14
- 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/input/name.js
CHANGED
|
@@ -4,6 +4,8 @@ import withStyle from "easy-with-style"; ///
|
|
|
4
4
|
|
|
5
5
|
import { arrayUtilities } from "necessary";
|
|
6
6
|
|
|
7
|
+
import nameInputMixins from "../mixins/nameInput";
|
|
8
|
+
|
|
7
9
|
import { NONE, INLINE_BLOCK } from "../constants";
|
|
8
10
|
import { Element, window, document } from "easy";
|
|
9
11
|
import { ENTER_KEY_CODE, ESCAPE_KEY_CODE } from "../keyCodes";
|
|
@@ -15,19 +17,13 @@ class NameInput extends Element {
|
|
|
15
17
|
const { keyCode } = event;
|
|
16
18
|
|
|
17
19
|
if (keyCode === ENTER_KEY_CODE) {
|
|
18
|
-
|
|
19
|
-
changeHandler = onChange; ///
|
|
20
|
-
|
|
21
|
-
changeHandler();
|
|
20
|
+
this.callChangeHandlers();
|
|
22
21
|
|
|
23
22
|
event.preventDefault();
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
if (keyCode === ESCAPE_KEY_CODE) {
|
|
27
|
-
|
|
28
|
-
cancelHandler = onCancel; ///
|
|
29
|
-
|
|
30
|
-
cancelHandler();
|
|
26
|
+
this.callCancelHandlers();
|
|
31
27
|
|
|
32
28
|
event.preventDefault();
|
|
33
29
|
}
|
|
@@ -41,9 +37,12 @@ class NameInput extends Element {
|
|
|
41
37
|
}
|
|
42
38
|
|
|
43
39
|
setName(name) {
|
|
44
|
-
const
|
|
40
|
+
const domElement = this.getDOMElement(),
|
|
41
|
+
{ childNodes } = domElement,
|
|
42
|
+
firstChildNode = first(childNodes),
|
|
43
|
+
textNode = firstChildNode; ///
|
|
45
44
|
|
|
46
|
-
|
|
45
|
+
textNode.nodeValue = name; ///
|
|
47
46
|
}
|
|
48
47
|
|
|
49
48
|
show() {
|
|
@@ -87,9 +86,13 @@ class NameInput extends Element {
|
|
|
87
86
|
|
|
88
87
|
parentContext() {
|
|
89
88
|
const showNameInput = this.show.bind(this), ///
|
|
90
|
-
hideNameInput = this.hide.bind(this),
|
|
89
|
+
hideNameInput = this.hide.bind(this), ///
|
|
91
90
|
getNameInputName = this.getName.bind(this), ///
|
|
92
91
|
setNameInputName = this.setName.bind(this), ///
|
|
92
|
+
onNameInputChange = this.onChange.bind(this), ///
|
|
93
|
+
onNameInputCancel = this.onCancel.bind(this), ///
|
|
94
|
+
offNameInputChange = this.offChange.bind(this), ///
|
|
95
|
+
offNameInputCancel = this.offCancel.bind(this), ///
|
|
93
96
|
isNameInputDisplayed = this.isDisplayed.bind(this); ///
|
|
94
97
|
|
|
95
98
|
return ({
|
|
@@ -97,17 +100,16 @@ class NameInput extends Element {
|
|
|
97
100
|
hideNameInput,
|
|
98
101
|
getNameInputName,
|
|
99
102
|
setNameInputName,
|
|
103
|
+
onNameInputChange,
|
|
104
|
+
onNameInputCancel,
|
|
105
|
+
offNameInputChange,
|
|
106
|
+
offNameInputCancel,
|
|
100
107
|
isNameInputDisplayed
|
|
101
108
|
});
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
static tagName = "span"; ///
|
|
105
112
|
|
|
106
|
-
static ignoredProperties = [
|
|
107
|
-
"onChange",
|
|
108
|
-
"onCancel"
|
|
109
|
-
];
|
|
110
|
-
|
|
111
113
|
static defaultProperties = {
|
|
112
114
|
role: "textbox",
|
|
113
115
|
className: "name",
|
|
@@ -115,6 +117,8 @@ class NameInput extends Element {
|
|
|
115
117
|
};
|
|
116
118
|
}
|
|
117
119
|
|
|
120
|
+
Object.assign(NameInput.prototype, nameInputMixins);
|
|
121
|
+
|
|
118
122
|
export default withStyle(NameInput)`
|
|
119
123
|
|
|
120
124
|
outline: none;
|
|
@@ -114,12 +114,6 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
114
114
|
return collapsed;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
isEntryDirectory() {
|
|
118
|
-
const entryDirectory = true;
|
|
119
|
-
|
|
120
|
-
return entryDirectory;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
117
|
retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps) {
|
|
124
118
|
const name = this.getName(),
|
|
125
119
|
pathMap = this.getPathMap(sourceEntryPath, targetEntryPath),
|
|
@@ -198,9 +192,6 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
|
|
|
198
192
|
NameButton={NameButton}
|
|
199
193
|
ToggleButton={ToggleButton}
|
|
200
194
|
DirectoryNameSVG={DirectoryNameSVG}
|
|
201
|
-
onNameChange={this.nameChangeHandler}
|
|
202
|
-
onNameCancel={this.nameCancelHandler}
|
|
203
|
-
onSVGButtonClick={this.svgButtonClickHandler}
|
|
204
195
|
/>,
|
|
205
196
|
<EntriesList explorer={explorer} />
|
|
206
197
|
|
|
@@ -46,12 +46,6 @@ export default class FileNameDragEntryItem extends DragEntryItem {
|
|
|
46
46
|
return collapsed;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
isEntryDirectory() {
|
|
50
|
-
const entryDirectory = false;
|
|
51
|
-
|
|
52
|
-
return entryDirectory;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
49
|
retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps) {
|
|
56
50
|
const pathMap = this.getPathMap(sourceEntryPath, targetEntryPath);
|
|
57
51
|
|
|
@@ -70,9 +64,6 @@ export default class FileNameDragEntryItem extends DragEntryItem {
|
|
|
70
64
|
NameInput={NameInput}
|
|
71
65
|
NameButton={NameButton}
|
|
72
66
|
FileNameSVG={FileNameSVG}
|
|
73
|
-
onNameChange={this.nameChangeHandler}
|
|
74
|
-
onNameCancel={this.nameCancelHandler}
|
|
75
|
-
onSVGButtonClick={this.svgButtonClickHandler}
|
|
76
67
|
/>
|
|
77
68
|
);
|
|
78
69
|
}
|
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
|
-
}
|
|
86
|
-
|
|
87
|
-
getInputPath() {
|
|
88
|
-
const path = this.getPath(),
|
|
89
|
-
inputName = this.getInputName(),
|
|
90
|
-
pathWithoutBottommostName = pathWithoutBottommostNameFromPath(path),
|
|
91
|
-
inputPath = (pathWithoutBottommostName === null) ?
|
|
92
|
-
inputName :
|
|
93
|
-
concatenatePaths(pathWithoutBottommostName, inputName);
|
|
91
|
+
isCreated() {
|
|
92
|
+
const { created } = this.properties;
|
|
94
93
|
|
|
95
|
-
return
|
|
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,19 +125,34 @@ 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
|
|
|
@@ -161,7 +175,20 @@ class DragEntryItem extends EntryItem {
|
|
|
161
175
|
}
|
|
162
176
|
|
|
163
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
|
+
|
|
164
190
|
this.hideNameButton();
|
|
191
|
+
|
|
165
192
|
this.showNameInput();
|
|
166
193
|
}
|
|
167
194
|
|
|
@@ -178,17 +205,29 @@ class DragEntryItem extends EntryItem {
|
|
|
178
205
|
didMount() {
|
|
179
206
|
this.hideNameInput();
|
|
180
207
|
|
|
181
|
-
this.onStartDrag(this.startDragHandler);
|
|
182
|
-
|
|
183
208
|
this.onStopDrag(this.stopDragHandler);
|
|
184
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
|
+
|
|
185
218
|
this.enableDrag();
|
|
186
219
|
}
|
|
187
220
|
|
|
188
221
|
willUnmount() {
|
|
222
|
+
this.offStopDrag(this.stopDragHandler);
|
|
223
|
+
|
|
189
224
|
this.offStartDrag(this.startDragHandler);
|
|
190
225
|
|
|
191
|
-
this.
|
|
226
|
+
this.offSVGButtonClick(this.svgButtonClickHandler);
|
|
227
|
+
|
|
228
|
+
this.offNameInputChange(this.nameInputChangeHandler);
|
|
229
|
+
|
|
230
|
+
this.offNameInputCancel(this.nameInputCancelHandler);
|
|
192
231
|
|
|
193
232
|
this.disableDrag();
|
|
194
233
|
}
|
|
@@ -213,6 +252,10 @@ class DragEntryItem extends EntryItem {
|
|
|
213
252
|
|
|
214
253
|
static NameButton = NameButton;
|
|
215
254
|
|
|
255
|
+
static ignoredProperties = [
|
|
256
|
+
"created"
|
|
257
|
+
];
|
|
258
|
+
|
|
216
259
|
static defaultProperties = {
|
|
217
260
|
className: "drag"
|
|
218
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
|
|
|
@@ -593,7 +596,7 @@ class EntriesList extends Element {
|
|
|
593
596
|
forEachDragEntryItem = this.forEachDragEntryItem.bind(this),
|
|
594
597
|
retrieveDragEntryItems = this.retrieveDragEntryItems.bind(this),
|
|
595
598
|
retrieveMarkerEntryItem = this.retrieveMarkerEntryItem.bind(this),
|
|
596
|
-
retrieveSelectedDragEntryItem = this.retrieveSelectedDragEntryItem.bind(this)
|
|
599
|
+
retrieveSelectedDragEntryItem = this.retrieveSelectedDragEntryItem.bind(this);
|
|
597
600
|
|
|
598
601
|
return ({
|
|
599
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
|
-
}
|