@syncfusion/ej2-filemanager 33.1.44 → 33.1.47

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.
@@ -4088,6 +4088,9 @@ function triggerPopupOpen(parent, dlgModule, dialogName) {
4088
4088
  function triggerPopupClose(parent, dlgModule, dialogName) {
4089
4089
  var args = { popupModule: dlgModule, element: dlgModule.element, popupName: dialogName };
4090
4090
  parent.trigger('popupClose', args);
4091
+ if (dialogName !== 'Duplicate Items') {
4092
+ parent.restoreFocus();
4093
+ }
4091
4094
  }
4092
4095
  /**
4093
4096
  *
@@ -4971,6 +4974,7 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
4971
4974
  this.isInteracted = true;
4972
4975
  this.imageEventArgsMap = new Map();
4973
4976
  this.imageUrlCache = new Map();
4977
+ this.nextFocusIndex = null;
4974
4978
  this.parent = parent;
4975
4979
  this.element = select('#' + this.parent.element.id + LARGEICON_ID, this.parent.element);
4976
4980
  addClass([this.element], LARGE_ICONS);
@@ -5379,6 +5383,13 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
5379
5383
  };
5380
5384
  LargeIconsView.prototype.onDeleteInit = function () {
5381
5385
  if (this.parent.activeModule === 'largeiconsview') {
5386
+ var activeItem = this.getFocusedItem() || this.getActiveItem();
5387
+ if (activeItem) {
5388
+ var index = this.itemList.indexOf(activeItem);
5389
+ if (index !== -1) {
5390
+ this.nextFocusIndex = index;
5391
+ }
5392
+ }
5382
5393
  Delete(this.parent, this.parent.selectedItems, this.parent.path, 'delete');
5383
5394
  }
5384
5395
  };
@@ -5389,6 +5400,16 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
5389
5400
  }
5390
5401
  this.onLayoutChange(args);
5391
5402
  this.parent.setProperties({ selectedItems: [] }, true);
5403
+ if (typeof this.nextFocusIndex === 'number') {
5404
+ var items = this.element.querySelectorAll('li.e-list-item');
5405
+ if (items.length > 0) {
5406
+ var focusIndex = this.nextFocusIndex >= items.length
5407
+ ? (this.nextFocusIndex === items.length ? items.length - 1 : 0) : this.nextFocusIndex;
5408
+ // eslint-disable-next-line security/detect-object-injection
5409
+ this.addFocus(items[focusIndex]);
5410
+ }
5411
+ this.nextFocusIndex = null;
5412
+ }
5392
5413
  this.clearSelect();
5393
5414
  };
5394
5415
  LargeIconsView.prototype.onRefreshEnd = function (args) {
@@ -5416,6 +5437,30 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
5416
5437
  this.clearSelect();
5417
5438
  this.addSelection(this.parent.renamedItem);
5418
5439
  }
5440
+ var mappedItem = null;
5441
+ if (this.parent._lastFocused && this.parent.pathId && this.parent.pathId.length && this.items && this.itemList) {
5442
+ var key = this.parent.pathId[this.parent.pathId.length - 1];
5443
+ // eslint-disable-next-line security/detect-object-injection
5444
+ var mappedId = this.parent._lastFocused[key];
5445
+ if (mappedId) {
5446
+ var foundIndex = -1;
5447
+ for (var i = 0; i < this.items.length; i++) {
5448
+ // eslint-disable-next-line security/detect-object-injection
5449
+ if (getValue('_fm_id', this.items[i]) === mappedId || (this.parent.hasId && getValue('id', this.items[i]) === mappedId) || getValue('name', this.items[i]) === mappedId) {
5450
+ foundIndex = i;
5451
+ break;
5452
+ }
5453
+ }
5454
+ // eslint-disable-next-line security/detect-object-injection
5455
+ if (foundIndex > -1 && this.itemList[foundIndex]) {
5456
+ mappedItem = this.itemList[foundIndex];
5457
+ }
5458
+ }
5459
+ }
5460
+ var targetItem = this.getFocusedItem() || mappedItem || this.parent.visitedItem || this.getFirstItem();
5461
+ if (targetItem) {
5462
+ this.addFocus(targetItem);
5463
+ }
5419
5464
  }
5420
5465
  };
5421
5466
  LargeIconsView.prototype.onOpenInit = function (args) {
@@ -5871,11 +5916,15 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
5871
5916
  }
5872
5917
  var eventArgs = { cancel: false, fileDetails: details_1, module: 'LargeIconsView' };
5873
5918
  this.parent.trigger('fileOpen', eventArgs, function (fileOpenArgs) {
5919
+ var _a;
5874
5920
  if (!fileOpenArgs.cancel) {
5875
5921
  var text = getValue('name', details_1);
5876
5922
  if (!_this.parent.isFile) {
5877
5923
  var val = _this.parent.breadcrumbbarModule.searchObj.element.value;
5878
5924
  if (val === '' && !_this.parent.isFiltered) {
5925
+ if (_this.parent.pathId && _this.parent.pathId.length) {
5926
+ _this.parent._lastFocused = Object.assign(_this.parent._lastFocused || {}, (_a = {}, _a[_this.parent.pathId[_this.parent.pathId.length - 1]] = getValue('_fm_id', details_1) || getValue('id', details_1) || text, _a));
5927
+ }
5879
5928
  var id = getValue('id', details_1);
5880
5929
  _this.parent.oldPath = _this.parent.path;
5881
5930
  var newPath = _this.parent.path + (isNullOrUndefined(id) ? text : id) + '/';
@@ -6116,12 +6165,26 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
6116
6165
  var indexes = this.getIndexes([item], this.parent.hasId);
6117
6166
  return this.itemList[indexes[0]];
6118
6167
  };
6168
+ /**
6169
+ *
6170
+ * Gets the currently focused item element in the large icon view.
6171
+ *
6172
+ * @returns {Element} - The DOM element of the focused item, or null if none is focused.
6173
+ * @hidden
6174
+ */
6119
6175
  LargeIconsView.prototype.getFocusedItem = function () {
6120
6176
  return select('.' + LIST_ITEM + '.' + FOCUS, this.element);
6121
6177
  };
6122
6178
  LargeIconsView.prototype.getActiveItem = function () {
6123
6179
  return select('.' + LIST_ITEM + '.' + ACTIVE, this.element);
6124
6180
  };
6181
+ /**
6182
+ *
6183
+ * Gets the first item element in the large icon view.
6184
+ *
6185
+ * @returns {Element} - The DOM element representing the first item in the list.
6186
+ * @hidden
6187
+ */
6125
6188
  LargeIconsView.prototype.getFirstItem = function () {
6126
6189
  return this.itemList[0];
6127
6190
  };
@@ -6326,6 +6389,14 @@ var LargeIconsView = /** @__PURE__ @class */ (function () {
6326
6389
  var data = this.getItemObject(item);
6327
6390
  return getItemName(this.parent, data);
6328
6391
  };
6392
+ /**
6393
+ *
6394
+ * Adds focus to the specified item element in the large icon view.
6395
+ *
6396
+ * @param {Element} item - The DOM element representing the item to focus.
6397
+ * @returns {void} - If null or invalid, no focus is applied.
6398
+ * @hidden
6399
+ */
6329
6400
  LargeIconsView.prototype.addFocus = function (item) {
6330
6401
  this.element.setAttribute('tabindex', '-1');
6331
6402
  var fItem = this.getFocusedItem();
@@ -6668,14 +6739,16 @@ var BreadCrumbBar = /** @__PURE__ @class */ (function () {
6668
6739
  var icon = createElement('span', { className: ICONS });
6669
6740
  addressbarLI.appendChild(icon);
6670
6741
  }
6671
- if (pathNamesLen - i !== 1) {
6672
- addressATag = createElement('a', { className: LIST_TEXT });
6673
- addressbarLI.setAttribute('tabindex', '0');
6674
- }
6675
- else {
6676
- addressATag = createElement('span', { className: LIST_TEXT });
6742
+ addressbarLI.setAttribute('tabindex', '0');
6743
+ addressbarLI.setAttribute('role', 'link');
6744
+ var pathLabel = pathNames.slice(0, i + 1).join(' / ');
6745
+ addressbarLI.setAttribute('aria-label', pathLabel);
6746
+ if (pathNamesLen - i === 1) {
6747
+ addressbarLI.setAttribute('aria-current', 'page');
6677
6748
  }
6678
6749
  id = '';
6750
+ addressATag = createElement('a', { className: LIST_TEXT });
6751
+ addressATag.setAttribute('role', 'presentation');
6679
6752
  addressATag.innerText = pathNames[i];
6680
6753
  addressbarLI.appendChild(addressATag);
6681
6754
  addressbarUL.appendChild(addressbarLI);
@@ -7084,6 +7157,9 @@ var ContextMenu = /** @__PURE__ @class */ (function () {
7084
7157
  return;
7085
7158
  }
7086
7159
  });
7160
+ if (!this.isMenuItemClicked && this.menuTarget) {
7161
+ this.parent.restoreFocus();
7162
+ }
7087
7163
  this.menuTarget = null;
7088
7164
  if (!this.isMenuItemClicked && this.parent.pathId.length > 1 && this.parent.activeModule === 'navigationpane') {
7089
7165
  this.parent.pathId.pop();
@@ -9206,6 +9282,20 @@ var FileManager = /** @__PURE__ @class */ (function (_super) {
9206
9282
  this.uploadObj.enableRtl = rtl;
9207
9283
  }
9208
9284
  };
9285
+ FileManager.prototype.restoreFocus = function () {
9286
+ if (this.activeModule === 'detailsview') {
9287
+ if (this.detailsviewModule.gridObj) {
9288
+ this.detailsviewModule.addFocus(this.detailsviewModule.gridObj.selectedRowIndex > -1
9289
+ ? this.detailsviewModule.gridObj.selectedRowIndex : 0);
9290
+ }
9291
+ return;
9292
+ }
9293
+ var targetItem = this.largeiconsviewModule.getFocusedItem()
9294
+ || this.visitedItem || this.largeiconsviewModule.getFirstItem();
9295
+ if (targetItem && this.largeiconsviewModule) {
9296
+ this.largeiconsviewModule.addFocus(targetItem);
9297
+ }
9298
+ };
9209
9299
  var FileManager_1;
9210
9300
  __decorate$8([
9211
9301
  Complex({}, AjaxSettings)
@@ -11212,6 +11302,7 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11212
11302
  this.isMultiSelect = false;
11213
11303
  this.pasteOperation = false;
11214
11304
  this.uploadOperation = false;
11305
+ this.nextFocusIndex = null;
11215
11306
  Grid.Inject(Resize, ContextMenu$2, Sort, VirtualScroll);
11216
11307
  this.parent = parent;
11217
11308
  this.element = select('#' + this.parent.element.id + GRID_ID, this.parent.element);
@@ -11668,6 +11759,13 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11668
11759
  sortIconElement.classList.remove('e-icon-ascending', 'e-ascending', 'e-icon-descending', 'e-descending');
11669
11760
  }
11670
11761
  }
11762
+ if (typeof this.nextFocusIndex === 'number') {
11763
+ var rowCount = this.gridObj.getRows().length;
11764
+ if (rowCount > 0) {
11765
+ this.addFocus(this.nextFocusIndex >= rowCount ? rowCount : this.nextFocusIndex);
11766
+ }
11767
+ this.nextFocusIndex = null;
11768
+ }
11671
11769
  };
11672
11770
  DetailsView.prototype.selectRecords = function (nodes) {
11673
11771
  var gridRecords = this.gridObj.getCurrentViewRecords();
@@ -11802,6 +11900,21 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11802
11900
  showSpinner(this.parent.element);
11803
11901
  this.parent.setProperties({ selectedItems: [] }, true);
11804
11902
  this.gridObj.dataSource = getSortedData(this.parent, args.files);
11903
+ if (this.parent._lastFocused && this.parent.pathId && this.parent.pathId.length) {
11904
+ var key = this.parent.pathId[this.parent.pathId.length - 1];
11905
+ // eslint-disable-next-line security/detect-object-injection
11906
+ var mappedId = this.parent._lastFocused[key];
11907
+ if (mappedId) {
11908
+ var gridItems = getSortedData(this.parent, args.files);
11909
+ for (var i = 0; i < gridItems.length; i++) {
11910
+ // eslint-disable-next-line security/detect-object-injection
11911
+ if (getValue('_fm_id', gridItems[i]) === mappedId || (this.parent.hasId && getValue('id', gridItems[i]) === mappedId) || getValue('name', gridItems[i]) === mappedId) {
11912
+ this.nextFocusIndex = i;
11913
+ break;
11914
+ }
11915
+ }
11916
+ }
11917
+ }
11805
11918
  this.gridObj.freezeRefresh();
11806
11919
  if (this.parent.isReact) {
11807
11920
  this.gridObj.on('reactTemplateRender', this.reactTemplateRender, this);
@@ -11861,6 +11974,7 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11861
11974
  }
11862
11975
  var eventArgs = { cancel: false, fileDetails: data, module: 'DetailsView' };
11863
11976
  this.parent.trigger('fileOpen', eventArgs, function (fileOpenArgs) {
11977
+ var _a;
11864
11978
  if (!fileOpenArgs.cancel) {
11865
11979
  var name_2 = getValue('name', data);
11866
11980
  if (getValue('isFile', data)) {
@@ -11873,6 +11987,9 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11873
11987
  else {
11874
11988
  var val = _this.parent.breadcrumbbarModule.searchObj.element.value;
11875
11989
  if (val === '' && !_this.parent.isFiltered) {
11990
+ if (_this.parent.pathId && _this.parent.pathId.length) {
11991
+ _this.parent._lastFocused = Object.assign(_this.parent._lastFocused || {}, (_a = {}, _a[_this.parent.pathId[_this.parent.pathId.length - 1]] = getValue('_fm_id', data) || getValue('id', data) || name_2, _a));
11992
+ }
11876
11993
  var id = getValue('id', data);
11877
11994
  _this.parent.oldPath = _this.parent.path;
11878
11995
  var newPath = _this.parent.path + (isNullOrUndefined(id) ? name_2 : id) + '/';
@@ -11993,6 +12110,8 @@ var DetailsView = /** @__PURE__ @class */ (function () {
11993
12110
  };
11994
12111
  DetailsView.prototype.onDeleteInit = function () {
11995
12112
  if (this.parent.activeModule === 'detailsview') {
12113
+ var selectedIndex = this.gridObj.selectedRowIndex;
12114
+ this.nextFocusIndex = selectedIndex >= 0 ? selectedIndex : this.nextFocusIndex;
11996
12115
  Delete(this.parent, this.parent.selectedItems, this.parent.path, 'delete');
11997
12116
  }
11998
12117
  };
@@ -12942,6 +13061,14 @@ var DetailsView = /** @__PURE__ @class */ (function () {
12942
13061
  }
12943
13062
  this.startIndex = this.gridObj.selectedRowIndex;
12944
13063
  };
13064
+ /**
13065
+ * Adds focus to the specified grid row.
13066
+ *
13067
+ * @param {number | null} item - The row index of the item to focus.
13068
+ * If null or invalid, no focus is applied.
13069
+ * @returns {void}
13070
+ * @hidden
13071
+ */
12945
13072
  DetailsView.prototype.addFocus = function (item) {
12946
13073
  var fItem = this.getFocusedItem();
12947
13074
  var itemElement = this.gridObj.getRowByIndex(item);