vgapp 1.0.6 → 1.0.8

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.
@@ -638,6 +638,18 @@ class VGFiles extends VGFilesBase {
638
638
  const name = normalizeData(Manipulator.get(button, 'data-name'));
639
639
  const size = normalizeData(Manipulator.get(button, 'data-size'));
640
640
  const id = normalizeData(Manipulator.get(button, 'data-id'));
641
+ const emitRemove = () => {
642
+ const payload = {
643
+ button: button,
644
+ name: name,
645
+ size: size,
646
+ id: id,
647
+ remaining: this._files.length
648
+ };
649
+
650
+ this._triggerCallback('onRemoveFile', payload);
651
+ this._triggerEvent('remove', payload);
652
+ };
641
653
 
642
654
  const fileToRemove = this._files.find(f => f.name === name && f.size === size);
643
655
  if (fileToRemove) {
@@ -689,6 +701,8 @@ class VGFiles extends VGFilesBase {
689
701
  if (this._params.removes.single.toast) {
690
702
  VGToast.run(data?.response?.message);
691
703
  }
704
+
705
+ emitRemove();
692
706
  };
693
707
 
694
708
  if (this._params.removes.single.alert) {
@@ -720,20 +734,10 @@ class VGFiles extends VGFilesBase {
720
734
  this._files = this._files.filter(f => !(f.name === name && f.size === size));
721
735
  this._updateStatsAfterRemove();
722
736
  this._files.length ? this.build() : this.clear(true);
737
+ emitRemove();
723
738
  }
724
739
 
725
740
  this._resetFileInput();
726
-
727
- const payload = {
728
- button: button,
729
- name: name,
730
- size: size,
731
- id: id,
732
- remaining: this._files.length
733
- };
734
-
735
- this._triggerCallback('onRemoveFile', payload);
736
- this._triggerEvent('remove', payload);
737
741
  }
738
742
 
739
743
  _updateStatsAfterRemove() {
@@ -101,8 +101,6 @@ class VGNestable extends BaseModule {
101
101
  this._isDragging = false;
102
102
  this._startSnapshot = "";
103
103
  this._sourceInstance = this;
104
- this._sourceRoot = null;
105
- this._currentTargetInstance = this;
106
104
  this._lastDropInstance = this;
107
105
  this._activeDropList = null;
108
106
 
@@ -317,11 +315,14 @@ class VGNestable extends BaseModule {
317
315
  childList.id = `vg-nestable-collapse-${Math.random().toString(36).slice(2, 10)}`;
318
316
  }
319
317
 
318
+ const hasCollapseClass = childList.classList.contains("vg-collapse");
320
319
  childList.classList.add("vg-collapse");
321
- if (this._params.collapse.open) {
322
- childList.classList.add("show");
323
- } else {
324
- childList.classList.remove("show");
320
+ if (!hasCollapseClass) {
321
+ if (this._params.collapse.open) {
322
+ childList.classList.add("show");
323
+ } else {
324
+ childList.classList.remove("show");
325
+ }
325
326
  }
326
327
 
327
328
  if (!toggle) {
@@ -279,27 +279,29 @@ class VGToast extends BaseModule {
279
279
  * Скрывает тост
280
280
  * @returns {void}
281
281
  */
282
- hide() {
283
- if (isDisabled(this._element)) return;
284
-
285
- const hideEvent = EventHandler.trigger(this._element, EVENT_KEY_HIDE);
282
+ hide() {
283
+ if (isDisabled(this._element)) return;
284
+ this._clearTimeout();
285
+
286
+ const hideEvent = EventHandler.trigger(this._element, EVENT_KEY_HIDE);
286
287
  if (hideEvent.defaultPrevented) return;
287
288
 
288
289
  this._element.classList.remove(CLASS_NAME_SHOWN);
289
290
 
290
- setTimeout(() => {
291
- this._element.classList.remove(CLASS_NAME_SHOW);
292
-
293
- const completeCallback = () => {
294
- document.body.classList.remove(CLASS_NAME_OPEN);
295
- EventHandler.trigger(this._element, EVENT_KEY_HIDDEN);
296
-
297
- if (this._params.stack.enable) {
298
- this._setPlacement();
299
- }
300
-
301
- if (!this._params.static) {
302
- this.dispose();
291
+ setTimeout(() => {
292
+ this._element.classList.remove(CLASS_NAME_SHOW);
293
+ if (this._params.stack.enable) {
294
+ this._setPlacement();
295
+ }
296
+
297
+ const completeCallback = () => {
298
+ if (!Selectors.findOne('.vg-toast.show')) {
299
+ document.body.classList.remove(CLASS_NAME_OPEN);
300
+ }
301
+ EventHandler.trigger(this._element, EVENT_KEY_HIDDEN);
302
+
303
+ if (!this._params.static) {
304
+ this.dispose();
303
305
  }
304
306
  };
305
307
 
@@ -346,7 +348,6 @@ class VGToast extends BaseModule {
346
348
  */
347
349
  _enableStack() {
348
350
  const placement = this._params.placement;
349
- const isVerticalCenter = placement.includes('center');
350
351
  const isTop = placement.includes('top');
351
352
  const isBottom = !isTop; // по умолчанию снизу
352
353
 
@@ -388,16 +389,25 @@ class VGToast extends BaseModule {
388
389
  * Устанавливает позицию тостов с учётом стека
389
390
  * @private
390
391
  */
391
- _setPlacement() {
392
- const elms = this._enableStack();
393
- const isCenter = this._params.placement.includes('center');
394
- const isLeft = this._params.placement.includes('left');
395
- const isRight = this._params.placement.includes('right');
396
- const isTop = this._params.placement.includes('top');
397
-
398
- const stackClass = isTop ? 'top' : 'bottom';
399
-
400
- elms.forEach(({ el, top }) => {
392
+ _setPlacement() {
393
+ const stackItems = this._enableStack();
394
+ const isTop = this._params.placement.includes('top');
395
+
396
+ const stackClass = isTop ? 'top' : 'bottom';
397
+ const visibleStack = Selectors.findAll(`.vg-toast.show.${stackClass}`)
398
+ .filter(el => {
399
+ const instance = VGToast.getInstance(el);
400
+ return instance?._params.stack.enable;
401
+ });
402
+ const elms = visibleStack.length ? visibleStack : stackItems.map(item => item.el);
403
+ let offset = 0;
404
+
405
+ elms.forEach((el) => {
406
+ const instance = VGToast.getInstance(el);
407
+ const placement = instance?._params.placement || this._params.placement;
408
+ const isCenter = placement.includes('center');
409
+ const isLeft = placement.includes('left');
410
+ const isRight = placement.includes('right');
401
411
  const style = el.style;
402
412
  style.left = '';
403
413
  style.right = '';
@@ -419,13 +429,15 @@ class VGToast extends BaseModule {
419
429
  style.translate = '-50% 0';
420
430
  }
421
431
 
422
- if (isTop) {
423
- style.top = top + 'px';
424
- } else {
425
- style.bottom = top + 'px';
426
- }
427
- });
428
- }
432
+ if (isTop) {
433
+ style.top = offset + 'px';
434
+ } else {
435
+ style.bottom = offset + 'px';
436
+ }
437
+
438
+ offset += el.offsetHeight;
439
+ });
440
+ }
429
441
 
430
442
  /**
431
443
  * Очищает таймер
@@ -484,4 +496,4 @@ EventHandler.on(document, EVENT_KEY_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, functi
484
496
  data.toggle(this);
485
497
  });
486
498
 
487
- export default VGToast;
499
+ export default VGToast;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vgapp",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "",
5
5
  "author": {
6
6
  "name": "Vegas Studio",