easy-file-system 2.1.10 → 2.1.12

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.
@@ -8,6 +8,8 @@ export default class DirectoryNameDragEntryItemDiv extends DragEntryItemDiv {
8
8
  directoryNameDragEntryItem = dragEntryItem; ///
9
9
 
10
10
  directoryNameDragEntryItem.toggle();
11
+
12
+ event.stopPropagation();
11
13
  }
12
14
 
13
15
  doubleClickHandler = (event, element) => {
@@ -18,18 +20,15 @@ export default class DirectoryNameDragEntryItemDiv extends DragEntryItemDiv {
18
20
  }
19
21
 
20
22
  childElements() {
21
- const { name, NameInput, NameButton, ToggleButton, DirectoryNameSVG } = this.properties;
23
+ const { name, NameSpan, ToggleButton, DirectoryNameSVG } = this.properties;
22
24
 
23
25
  return ([
24
26
 
25
27
  <ToggleButton onMouseDown={this.toggleButtonMouseDownHandler} />,
26
28
  <DirectoryNameSVG/>,
27
- <NameButton>
28
- {name}
29
- </NameButton>,
30
- <NameInput>
29
+ <NameSpan>
31
30
  {name}
32
- </NameInput>
31
+ </NameSpan>
33
32
 
34
33
  ]);
35
34
  }
@@ -12,17 +12,14 @@ export default class FileNameDragEntryItemDiv extends DragEntryItemDiv {
12
12
  }
13
13
 
14
14
  childElements() {
15
- const { name, NameInput, NameButton, FileNameSVG } = this.properties;
15
+ const { name, NameSpan, FileNameSVG } = this.properties;
16
16
 
17
17
  return ([
18
18
 
19
19
  <FileNameSVG/>,
20
- <NameButton>
20
+ <NameSpan>
21
21
  {name}
22
- </NameButton>,
23
- <NameInput>
24
- {name}
25
- </NameInput>
22
+ </NameSpan>
26
23
 
27
24
  ]);
28
25
  }
@@ -2,6 +2,8 @@
2
2
 
3
3
  import EntryItemDiv from "../../../div/item/entry";
4
4
 
5
+ import { EMPTY_STRING } from "../../../constants";
6
+
5
7
  export default class DragEntryItemDiv extends EntryItemDiv {
6
8
  mouseDownHandler = (event, element) => {
7
9
  const explorer = this.getExplorer(),
@@ -24,8 +26,7 @@ export default class DragEntryItemDiv extends EntryItemDiv {
24
26
 
25
27
  static ignoredProperties = [
26
28
  "name",
27
- "NameInput",
28
- "NameButton"
29
+ "NameSpan"
29
30
  ];
30
31
 
31
32
  static defaultProperties = {
@@ -34,7 +34,6 @@ class EntryItemDiv extends Element {
34
34
 
35
35
  export default withStyle(EntryItemDiv)`
36
36
 
37
- position: relative;
38
37
  padding-top: ${entryItemDivPaddingTop};
39
38
 
40
39
  `;
package/src/explorer.js CHANGED
@@ -105,9 +105,9 @@ class Explorer extends Element {
105
105
 
106
106
  if (selectedDragEntryItem !== null) {
107
107
  const dragEntryItem = selectedDragEntryItem, ///
108
- dragEntryItemEdited = dragEntryItem.isEdited();
108
+ dragEntryItemEditable = dragEntryItem.isEditable();
109
109
 
110
- if (dragEntryItemEdited) {
110
+ if (dragEntryItemEditable) {
111
111
  return;
112
112
  }
113
113
 
package/src/index.js CHANGED
@@ -5,8 +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";
9
- export { default as NameButton } from "./button/name";
8
+ export { default as NameSpan } from "./span/name";
10
9
  export { default as EntriesList } from "./list/entries";
11
10
  export { default as ToggleButton } from "./button/toggle";
12
11
 
@@ -117,13 +117,13 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
117
117
  retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps) {
118
118
  const name = this.getName(),
119
119
  pathMap = this.getPathMap(sourceEntryPath, targetEntryPath),
120
- nameInputName = this.getNameInputName();
120
+ nameSpanName = this.getNameSpanName();
121
121
 
122
122
  pathMaps.push(pathMap);
123
123
 
124
124
  sourceEntryPath = adjustSourceEntryPath(sourceEntryPath, name);
125
125
 
126
- targetEntryPath = adjustTargetEntryPath(targetEntryPath, nameInputName);
126
+ targetEntryPath = adjustTargetEntryPath(targetEntryPath, nameSpanName);
127
127
 
128
128
  this.forEachDragEntryItem((dragEntryItem) => {
129
129
  dragEntryItem.retrievePathMaps(sourceEntryPath, targetEntryPath, pathMaps);
@@ -180,7 +180,7 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
180
180
 
181
181
  childElements() {
182
182
  const { name } = this.properties,
183
- { NameInput, NameButton, ToggleButton, DirectoryNameSVG } = this.constructor,
183
+ { NameSpan, ToggleButton, DirectoryNameSVG } = this.constructor,
184
184
  explorer = this.getExplorer(),
185
185
  EntriesList = explorer.getEntriesList();
186
186
 
@@ -188,8 +188,7 @@ export default class DirectoryNameDragEntryItem extends DragEntryItem {
188
188
 
189
189
  <DirectoryNameDragEntryItemDiv name={name}
190
190
  explorer={explorer}
191
- NameInput={NameInput}
192
- NameButton={NameButton}
191
+ NameSpan={NameSpan}
193
192
  ToggleButton={ToggleButton}
194
193
  DirectoryNameSVG={DirectoryNameSVG}
195
194
  />,
@@ -54,17 +54,17 @@ export default class FileNameDragEntryItem extends DragEntryItem {
54
54
 
55
55
  childElements() {
56
56
  const { name } = this.properties,
57
- { NameInput, NameButton, FileNameSVG } = this.constructor,
57
+ { NameSpan, FileNameSVG } = this.constructor,
58
58
  explorer = this.getExplorer();
59
59
 
60
60
  return (
61
61
 
62
62
  <FileNameDragEntryItemDiv name={name}
63
63
  explorer={explorer}
64
- NameInput={NameInput}
65
- NameButton={NameButton}
64
+ NameSpan={NameSpan}
66
65
  FileNameSVG={FileNameSVG}
67
- />
66
+ />
67
+
68
68
  );
69
69
  }
70
70
 
@@ -4,25 +4,27 @@ import withStyle from "easy-with-style"; ///
4
4
 
5
5
  import { dragMixins } from "easy-drag-and-drop";
6
6
 
7
+ import NameSpan from "../../span/name";
7
8
  import EntryItem from "../../item/entry";
8
- import NameInput from "../../input/name";
9
- import NameButton from "../../button/name";
10
9
 
11
10
  import { EMPTY_STRING } from "../../constants";
12
11
  import { DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "../../entryTypes";
13
12
  import { adjustSourceEntryPath, adjustTargetEntryPath } from "../../utilities/pathMap";
14
13
 
15
14
  class DragEntryItem extends EntryItem {
16
- nameInputChangeHandler = () => {
17
- const created = this.isCreated(),
18
- explorer = this.getExplorer(),
19
- nameChanged = this.hasNameChanged(),
20
- dragEntryItem = this; ///
15
+ nameSpanChangeHandler = (event, element) => {
16
+ const { name } = this.getState(),
17
+ nameSpanName = this.getNameSpanName(),
18
+ nameChanged = (name !== nameSpanName);
21
19
 
22
20
  if (!nameChanged) {
23
21
  return;
24
22
  }
25
23
 
24
+ const created = this.isCreated(),
25
+ explorer = this.getExplorer(),
26
+ dragEntryItem = this; ///
27
+
26
28
  if (created) {
27
29
  explorer.createDragEntryItem(dragEntryItem, () => {
28
30
  this.cancel();
@@ -36,7 +38,7 @@ class DragEntryItem extends EntryItem {
36
38
  });
37
39
  }
38
40
 
39
- nameInputCancelHandler = () => {
41
+ nameSpanCancelHandler = (event, element) => {
40
42
  const created = this.isCreated();
41
43
 
42
44
  created ?
@@ -88,12 +90,12 @@ class DragEntryItem extends EntryItem {
88
90
  getPathMap(sourceEntryPath, targetEntryPath) {
89
91
  const name = this.getName(),
90
92
  collapsed = this.isCollapsed(),
91
- nameInputName = this.getNameInputName(),
93
+ nameSpanName = this.getNameSpanName(),
92
94
  entryDirectory = this.getEntryDirectory();
93
95
 
94
96
  sourceEntryPath = adjustSourceEntryPath(sourceEntryPath, name); ///
95
97
 
96
- targetEntryPath = adjustTargetEntryPath(targetEntryPath, nameInputName); ///
98
+ targetEntryPath = adjustTargetEntryPath(targetEntryPath, nameSpanName); ///
97
99
 
98
100
  const pathMap = {
99
101
  collapsed,
@@ -115,14 +117,6 @@ class DragEntryItem extends EntryItem {
115
117
  return pathMaps;
116
118
  }
117
119
 
118
- hasNameChanged() {
119
- const nameInputName = this.getNameInputName(),
120
- nameButtonName = this.getNameButtonName(),
121
- nameChanged = (nameInputName !== nameButtonName);
122
-
123
- return nameChanged;
124
- }
125
-
126
120
  getEntryDirectory() {
127
121
  const directoryNameDragEntryItem = this.isDirectoryNameDragEntryItem(),
128
122
  entryDirectory = directoryNameDragEntryItem; ///
@@ -150,11 +144,11 @@ class DragEntryItem extends EntryItem {
150
144
  return selected;
151
145
  }
152
146
 
153
- isEdited() {
154
- const nameInputDisplayed = this.isNameInputDisplayed(),
155
- edited = nameInputDisplayed; ///
147
+ isEditable() {
148
+ const nameSpanEdited = this.isNameSpanEditable(),
149
+ editable = nameSpanEdited; ///
156
150
 
157
- return edited;
151
+ return editable;
158
152
  }
159
153
 
160
154
  deselect() {
@@ -166,44 +160,38 @@ class DragEntryItem extends EntryItem {
166
160
  }
167
161
 
168
162
  edit() {
169
- const created = this.isCreated();
170
-
171
- if (created) {
172
- const name = EMPTY_STRING,
173
- nameInputName = name, ///
174
- nameButtonName = name; ///
175
-
176
- this.setNameInputName(nameInputName);
163
+ const created = this.isCreated(),
164
+ name = created ?
165
+ EMPTY_STRING :
166
+ this.getName(),
167
+ nameSpanName = name; ///
177
168
 
178
- this.setNameButtonName(nameButtonName);
179
- }
169
+ this.setNameSpanName(nameSpanName);
180
170
 
181
- this.hideNameButton();
171
+ this.updateState({
172
+ name
173
+ });
182
174
 
183
- this.showNameInput();
175
+ this.editNameSpan();
184
176
  }
185
177
 
186
178
  cancel() {
187
- const name = this.getName(),
188
- nameInputName = name; ///
189
-
190
- this.setNameInputName(nameInputName);
179
+ const { name } = this.getState(),
180
+ nameSpanName = name; ///
191
181
 
192
- this.showNameButton();
182
+ this.setNameSpanName(nameSpanName);
193
183
 
194
- this.hideNameInput();
184
+ this.cancelNameSpan();
195
185
  }
196
186
 
197
187
  didMount() {
198
- this.hideNameInput();
199
-
200
188
  this.onStopDrag(this.stopDragHandler);
201
189
 
202
190
  this.onStartDrag(this.startDragHandler);
203
191
 
204
- this.onNameInputChange(this.nameInputChangeHandler);
192
+ this.onNameSpanChange(this.nameSpanChangeHandler);
205
193
 
206
- this.onNameInputCancel(this.nameInputCancelHandler);
194
+ this.onNameSpanCancel(this.nameSpanCancelHandler);
207
195
 
208
196
  this.enableDrag();
209
197
  }
@@ -213,9 +201,9 @@ class DragEntryItem extends EntryItem {
213
201
 
214
202
  this.offStartDrag(this.startDragHandler);
215
203
 
216
- this.offNameInputChange(this.nameInputChangeHandler);
204
+ this.offNameSpanChange(this.nameSpanChangeHandler);
217
205
 
218
- this.offNameInputCancel(this.nameInputCancelHandler);
206
+ this.offNameSpanCancel(this.nameSpanCancelHandler);
219
207
 
220
208
  this.disableDrag();
221
209
  }
@@ -236,9 +224,7 @@ class DragEntryItem extends EntryItem {
236
224
  this.assignContext();
237
225
  }
238
226
 
239
- static NameInput = NameInput;
240
-
241
- static NameButton = NameButton;
227
+ static NameSpan = NameSpan;
242
228
 
243
229
  static ignoredProperties = [
244
230
  "created"
@@ -54,7 +54,7 @@ function callCancelHandlers() {
54
54
  });
55
55
  }
56
56
 
57
- const nameInputMixins = {
57
+ const nameSpanMixins = {
58
58
  onChange,
59
59
  offChange,
60
60
  onCancel,
@@ -63,4 +63,4 @@ const nameInputMixins = {
63
63
  callCancelHandlers
64
64
  };
65
65
 
66
- export default nameInputMixins;
66
+ export default nameSpanMixins;
@@ -4,15 +4,15 @@ import withStyle from "easy-with-style"; ///
4
4
 
5
5
  import { arrayUtilities } from "necessary";
6
6
 
7
- import nameInputMixins from "../mixins/nameInput";
7
+ import nameSpanMixins from "../mixins/nameSpan";
8
8
 
9
- import { NONE, INLINE_BLOCK } from "../constants";
10
9
  import { Element, window, document } from "easy";
11
10
  import { ENTER_KEY_CODE, ESCAPE_KEY_CODE } from "../keyCodes";
11
+ import { ROLE, TRUE, TEXTBOX, CONTENT_EDITABLE } from "../constants";
12
12
 
13
13
  const { first } = arrayUtilities;
14
14
 
15
- class NameInput extends Element {
15
+ class NameSpan extends Element {
16
16
  keyDownHandler = (event, element) => {
17
17
  const { keyCode } = event;
18
18
 
@@ -29,6 +29,12 @@ class NameInput extends Element {
29
29
  }
30
30
  }
31
31
 
32
+ isEditable() {
33
+ const editable = this.hasClass("editable");
34
+
35
+ return editable;
36
+ }
37
+
32
38
  getName() {
33
39
  const html = this.html(),
34
40
  name = html; ///
@@ -45,12 +51,14 @@ class NameInput extends Element {
45
51
  textNode.nodeValue = name; ///
46
52
  }
47
53
 
48
- show() {
49
- const display = INLINE_BLOCK;
54
+ edit() {
55
+ this.focus();
50
56
 
51
- this.display(display);
57
+ this.addClass("editable");
52
58
 
53
- this.focus();
59
+ this.addAttribute(ROLE, TEXTBOX);
60
+
61
+ this.addAttribute(CONTENT_EDITABLE, TRUE);
54
62
 
55
63
  const html = this.html(),
56
64
  range = document.createRange(),
@@ -68,65 +76,66 @@ class NameInput extends Element {
68
76
  selection.removeAllRanges();
69
77
 
70
78
  selection.addRange(range);
71
- }
72
79
 
73
- hide() {
74
- const display = NONE;
75
-
76
- this.display(display);
77
- }
78
-
79
- didMount() {
80
80
  this.onKeyDown(this.keyDownHandler);
81
81
  }
82
82
 
83
- willUnmount() {
83
+ cancel() {
84
84
  this.offKeyDown(this.keyDownHandler);
85
+
86
+ this.removeClass("editable");
87
+
88
+ this.removeAttribute(ROLE, TEXTBOX);
89
+
90
+ this.removeAttribute(CONTENT_EDITABLE, TRUE);
85
91
  }
86
92
 
87
93
  parentContext() {
88
- const showNameInput = this.show.bind(this), ///
89
- hideNameInput = this.hide.bind(this), ///
90
- getNameInputName = this.getName.bind(this), ///
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), ///
96
- isNameInputDisplayed = this.isDisplayed.bind(this); ///
94
+ const editNameSpan = this.edit.bind(this), ///
95
+ cancelNameSpan = this.cancel.bind(this), ///
96
+ getNameSpanName = this.getName.bind(this), ///
97
+ setNameSpanName = this.setName.bind(this), ///
98
+ onNameSpanChange = this.onChange.bind(this), ///
99
+ onNameSpanCancel = this.onCancel.bind(this), ///
100
+ offNameSpanChange = this.offChange.bind(this), ///
101
+ offNameSpanCancel = this.offCancel.bind(this), ///
102
+ isNameSpanEditable = this.isEditable.bind(this); ///
97
103
 
98
104
  return ({
99
- showNameInput,
100
- hideNameInput,
101
- getNameInputName,
102
- setNameInputName,
103
- onNameInputChange,
104
- onNameInputCancel,
105
- offNameInputChange,
106
- offNameInputCancel,
107
- isNameInputDisplayed
105
+ editNameSpan,
106
+ cancelNameSpan,
107
+ getNameSpanName,
108
+ setNameSpanName,
109
+ onNameSpanChange,
110
+ onNameSpanCancel,
111
+ offNameSpanChange,
112
+ offNameSpanCancel,
113
+ isNameSpanEditable
108
114
  });
109
115
  }
110
116
 
111
117
  static tagName = "span"; ///
112
118
 
113
119
  static defaultProperties = {
114
- role: "textbox",
115
- className: "name",
116
- contentEditable: "true"
120
+ className: "name"
117
121
  };
118
122
  }
119
123
 
120
- Object.assign(NameInput.prototype, nameInputMixins);
124
+ Object.assign(NameSpan.prototype, nameSpanMixins);
121
125
 
122
- export default withStyle(NameInput)`
123
-
124
- outline: none;
126
+ export default withStyle(NameSpan)`
127
+
128
+ border: none;
129
+ display: inline-block;
125
130
  font-size: inherit;
126
131
  text-align: left;
132
+ background: transparent;
127
133
  font-weight: inherit;
128
134
  font-family: inherit;
129
- border: 1px solid black;
130
- padding: 4px;
135
+
136
+ .editable {
137
+ border: 1px solid black;
138
+ padding: 4px;
139
+ }
131
140
 
132
141
  `;
@@ -37,15 +37,15 @@ export function adjustSourceEntryPath(sourceEntryPath, name) {
37
37
  return sourceEntryPath;
38
38
  }
39
39
 
40
- export function adjustTargetEntryPath(targetEntryPath, nameInputName) {
40
+ export function adjustTargetEntryPath(targetEntryPath, nameSpanName) {
41
41
  if (false) {
42
42
  ///
43
43
  } else if (targetEntryPath === null) {
44
44
  targetEntryPath = null;
45
45
  } else if (targetEntryPath === EMPTY_STRING) {
46
- targetEntryPath = nameInputName; ///
46
+ targetEntryPath = nameSpanName; ///
47
47
  } else {
48
- targetEntryPath = concatenatePaths(targetEntryPath, nameInputName);
48
+ targetEntryPath = concatenatePaths(targetEntryPath, nameSpanName);
49
49
  }
50
50
 
51
51
  return targetEntryPath;