easy-file-system 1.4.1 → 1.5.1

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.
@@ -3,12 +3,13 @@
3
3
  import withStyle from "easy-with-style"; ///
4
4
 
5
5
  import { Element } from "easy";
6
- import { pathUtilities } from "necessary";
6
+ import { pathUtilities, arrayUtilities } from "necessary";
7
7
 
8
8
  import { entriesListPaddingLeft } from "../styles";
9
9
  import { FILE_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE } from "../entryTypes";
10
10
 
11
- const { topmostDirectoryNameFromPath, pathWithoutTopmostDirectoryNameFromPath } = pathUtilities;
11
+ const { filter } = arrayUtilities,
12
+ { topmostDirectoryNameFromPath, pathWithoutTopmostDirectoryNameFromPath } = pathUtilities;
12
13
 
13
14
  const markerEntryItem = null;
14
15
 
@@ -78,6 +79,31 @@ class EntriesList extends Element {
78
79
  this.removeMarkerEntryItem();
79
80
  }
80
81
 
82
+ selectPath(path) {
83
+ const topmostDirectoryName = topmostDirectoryNameFromPath(path);
84
+
85
+ if (topmostDirectoryName === null) {
86
+ const name = path, ///
87
+ dragEntryItem = this.findDragEntryItem(name);
88
+
89
+ if (dragEntryItem !== null) {
90
+ dragEntryItem.select();
91
+ }
92
+ } else {
93
+ let topmostDirectoryNameDragEntryItem = this.findDirectoryNameDragEntryItem(topmostDirectoryName);
94
+
95
+ if (topmostDirectoryNameDragEntryItem !== null) {
96
+ const filePathWithoutTopmostDirectoryName = pathWithoutTopmostDirectoryNameFromPath(path);
97
+
98
+ path = filePathWithoutTopmostDirectoryName; ///
99
+
100
+ topmostDirectoryNameDragEntryItem.expand();
101
+
102
+ topmostDirectoryNameDragEntryItem.selectPath(path);
103
+ }
104
+ }
105
+ }
106
+
81
107
  addFilePath(filePath) {
82
108
  let fileNameDragEntryItem;
83
109
 
@@ -149,6 +175,14 @@ class EntriesList extends Element {
149
175
  this.removeEntryItems();
150
176
  }
151
177
 
178
+ deselectAllPaths() {
179
+ const dragEntryItems = this.retrieveDragEntryItems();
180
+
181
+ dragEntryItems.forEach((dragEntryItem) => {
182
+ dragEntryItem.deselect();
183
+ });
184
+ }
185
+
152
186
  addDirectoryPath(directoryPath, collapsed = true) {
153
187
  let directoryNameDragEntryItem;
154
188
 
@@ -413,22 +447,37 @@ class EntriesList extends Element {
413
447
 
414
448
  findEntryItemByTypes(callback, ...types) {
415
449
  const entryItems = this.getEntryItems(),
416
- entryItem = entryItems.find((entryItem) => {
417
- const entryItemType = entryItem.getType(),
418
- typesIncludesEntryItemType = types.includes(entryItemType);
450
+ entryItem = entryItems.find((entryItem) => {
451
+ const entryItemType = entryItem.getType(),
452
+ typesIncludesEntryItemType = types.includes(entryItemType);
419
453
 
420
- if (typesIncludesEntryItemType) {
421
- const result = callback(entryItem);
454
+ if (typesIncludesEntryItemType) {
455
+ const result = callback(entryItem);
422
456
 
423
- if (result) {
424
- return true;
457
+ if (result) {
458
+ return true;
459
+ }
425
460
  }
426
- }
427
- }) || null; ///;
461
+ }) || null; ///;
428
462
 
429
463
  return entryItem;
430
464
  }
431
465
 
466
+ findEntryItemsByTypes(...types) {
467
+ const entryItems = this.getEntryItems();
468
+
469
+ filter(entryItems, (entryItem) => {
470
+ const entryItemType = entryItem.getType(),
471
+ typesIncludesEntryItemType = types.includes(entryItemType);
472
+
473
+ if (typesIncludesEntryItemType) {
474
+ return true;
475
+ }
476
+ });
477
+
478
+ return entryItems;
479
+ }
480
+
432
481
  findEntryItemByNameAndTypes(name, ...types) {
433
482
  const entryItem = this.findEntryItemByTypes((entryItem) => {
434
483
  const entryItemName = entryItem.getName();
@@ -441,6 +490,20 @@ class EntriesList extends Element {
441
490
  return entryItem;
442
491
  }
443
492
 
493
+ findDragEntryItem(name) {
494
+ const entryItem = this.findEntryItemByNameAndTypes(name, FILE_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE),
495
+ dragEntryItem = entryItem; ///
496
+
497
+ return dragEntryItem;
498
+ }
499
+
500
+ findDragEntryItems() {
501
+ const entryItems = this.findEntryItemsByTypes(FILE_NAME_DRAG_ENTRY_TYPE, DIRECTORY_NAME_DRAG_ENTRY_TYPE),
502
+ dragEntryItems = entryItems; ///
503
+
504
+ return dragEntryItems;
505
+ }
506
+
444
507
  findFileNameDragEntryItem(fileName) {
445
508
  const name = fileName, ///
446
509
  entryItem = this.findEntryItemByNameAndTypes(name, FILE_NAME_DRAG_ENTRY_TYPE),
@@ -506,10 +569,12 @@ class EntriesList extends Element {
506
569
  isEntriesListCollapsed = this.isCollapsed.bind(this), ///
507
570
  isEmpty = this.isEmpty.bind(this),
508
571
  addMarker = this.addMarker.bind(this),
572
+ selectPath = this.selectPath.bind(this),
509
573
  addFilePath = this.addFilePath.bind(this),
510
574
  removeMarker = this.removeMarker.bind(this),
511
575
  removeFilePath = this.removeFilePath.bind(this),
512
576
  removeAllPaths = this.removeAllPaths.bind(this),
577
+ deselectAllPaths = this.deselectAllPaths.bind(this),
513
578
  addDirectoryPath = this.addDirectoryPath.bind(this),
514
579
  removeDirectoryPath = this.removeDirectoryPath.bind(this),
515
580
  forEachDragEntryItem = this.forEachDragEntryItem.bind(this),
@@ -522,10 +587,12 @@ class EntriesList extends Element {
522
587
  isEntriesListCollapsed,
523
588
  isEmpty,
524
589
  addMarker,
590
+ selectPath,
525
591
  addFilePath,
526
592
  removeMarker,
527
593
  removeFilePath,
528
594
  removeAllPaths,
595
+ deselectAllPaths,
529
596
  addDirectoryPath,
530
597
  removeDirectoryPath,
531
598
  forEachDragEntryItem,