aio-popup 6.3.0 → 6.5.0

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/index.css CHANGED
@@ -372,6 +372,7 @@
372
372
  align-items: center;
373
373
  box-sizing: border-box;
374
374
  padding: 0 12px;
375
+ gap:6px;
375
376
  }
376
377
 
377
378
  .aio-popup-time {
package/index.d.ts CHANGED
@@ -43,6 +43,13 @@ export type AP_alert = {
43
43
  closeText?: string;
44
44
  animate?: boolean;
45
45
  onClose?: boolean | (() => void);
46
+ actions?: {
47
+ text: string;
48
+ callback: any;
49
+ className?: string;
50
+ id: string;
51
+ close?: boolean;
52
+ }[];
46
53
  };
47
54
  export type AP_snackebar = {
48
55
  id?: string;
package/index.js CHANGED
@@ -529,7 +529,7 @@ const SnackebarBar = () => {
529
529
  return _jsx("div", { className: 'aio-popup-snackebar-bar', style: { transition: `${item.time || 8}s linear` } });
530
530
  };
531
531
  export function Alert(props) {
532
- let { icon, type = '', title = '', text = '', time = 10, className, closeText = 'Close', onClose, rtl } = props;
532
+ let { icon, type = '', title = '', text = '', time = 10, className, closeText = 'Close', onClose, rtl, actions = [] } = props;
533
533
  let $$ = {
534
534
  id: '',
535
535
  time: 0,
@@ -552,7 +552,11 @@ export function Alert(props) {
552
552
  <div class='aio-popup-alert-text' style="text-align:${rtl ? 'right' : 'left'}">${text}</div>
553
553
  </div>
554
554
  <div class='aio-popup-alert-footer'>
555
- <button class='aio-popup-alert-close ${$$.id}'>${closeText}</button>
555
+ ${onClose !== false ? `<button class='aio-popup-alert-close ${$$.id}'>${closeText}</button>` : ''}
556
+ ${actions.map((o) => {
557
+ const { className, id, text } = o;
558
+ return `<button data-action='${id}' class='aio-popup-alert-action${className ? ' ' + className : ''}'>${text}</button>`;
559
+ }).join(' ')}
556
560
  </div>
557
561
  <div class='aio-popup-time'></div>
558
562
  </div>
@@ -565,9 +569,6 @@ export function Alert(props) {
565
569
  if (typeof onClose === 'function') {
566
570
  onClose();
567
571
  }
568
- if (onClose === false) {
569
- return;
570
- }
571
572
  $('.' + $$.id).remove();
572
573
  }, 200);
573
574
  },
@@ -583,6 +584,8 @@ export function Alert(props) {
583
584
  }[type] || '';
584
585
  },
585
586
  startTimer() {
587
+ let timeoutTime = time / 50 * 1000;
588
+ timeoutTime = timeoutTime > 100000 ? 100000 : timeoutTime;
586
589
  setTimeout(() => {
587
590
  if ($$.time >= 100) {
588
591
  $$.time = 100;
@@ -592,7 +595,7 @@ export function Alert(props) {
592
595
  $$.time += 2;
593
596
  $$.updateBarRender();
594
597
  $$.startTimer();
595
- }, time / 50 * 1000);
598
+ }, timeoutTime);
596
599
  },
597
600
  toggleClass(mount) {
598
601
  let dom = $(`.${$$.id}`);
@@ -603,10 +606,24 @@ export function Alert(props) {
603
606
  dom.addClass('not-mounted');
604
607
  }
605
608
  },
609
+ callAction(e) {
610
+ const target = $(e.target);
611
+ const actionId = target.attr('data-action');
612
+ const action = actions.find((o) => o.id === actionId);
613
+ if (!action) {
614
+ return;
615
+ }
616
+ action.callback();
617
+ if (action.close) {
618
+ $$.close();
619
+ }
620
+ },
606
621
  render() {
607
622
  $('body').append($$.getRender());
608
623
  $('button.' + $$.id).off('click', $$.close);
609
624
  $('button.' + $$.id).on('click', $$.close);
625
+ $('button.aio-popup-alert-action').off('click', $$.callAction);
626
+ $('button.aio-popup-alert-action').on('click', $$.callAction);
610
627
  $$.toggleClass(true);
611
628
  }
612
629
  };
@@ -731,16 +748,16 @@ function getEasing(highlight) {
731
748
  const { easing } = highlight;
732
749
  var easingNames = [
733
750
  'linear',
734
- 'easeInQuad',
735
- 'easeInSine',
736
- 'easeInCirc',
737
- 'easeInBack',
738
- 'easeOutQuad',
739
- 'easeOutSine',
740
- 'easeOutCirc',
741
- 'easeInOutQuad',
742
- 'easeInOutSine',
743
- 'easeInOutBack',
751
+ 'easeInQuad', //1
752
+ 'easeInSine', //5
753
+ 'easeInCirc', //7
754
+ 'easeInBack', //8
755
+ 'easeOutQuad', //9
756
+ 'easeOutSine', //13
757
+ 'easeOutCirc', //15
758
+ 'easeInOutQuad', //18
759
+ 'easeInOutSine', //22
760
+ 'easeInOutBack', //25
744
761
  'easeOutBounce', //27
745
762
  ];
746
763
  if (typeof easing === 'number') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-popup",
3
- "version": "6.3.0",
3
+ "version": "6.5.0",
4
4
  "description": "handle all types of popup and modals in react",
5
5
  "main": "index.js",
6
6
  "scripts": {