aio-popup 6.4.0 → 6.6.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.d.ts +2 -0
- package/index.js +33 -22
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export type AP_modal = {
|
|
|
31
31
|
animate?: boolean;
|
|
32
32
|
fitHorizontal?: boolean;
|
|
33
33
|
setAttrs?: AP_setAttrs;
|
|
34
|
+
pageSelector?: string;
|
|
34
35
|
};
|
|
35
36
|
export type AP_alert = {
|
|
36
37
|
rtl?: boolean;
|
|
@@ -48,6 +49,7 @@ export type AP_alert = {
|
|
|
48
49
|
callback: any;
|
|
49
50
|
className?: string;
|
|
50
51
|
id: string;
|
|
52
|
+
close?: boolean;
|
|
51
53
|
}[];
|
|
52
54
|
};
|
|
53
55
|
export type AP_snackebar = {
|
package/index.js
CHANGED
|
@@ -16,9 +16,15 @@ import $ from 'jquery';
|
|
|
16
16
|
import './index.css';
|
|
17
17
|
const CTX = createContext({});
|
|
18
18
|
function Align(p) {
|
|
19
|
-
let { modal, target, fitHorizontal, rtl, limitTo } = p;
|
|
19
|
+
let { modal, target, fitHorizontal, rtl, limitTo, pageSelector } = p;
|
|
20
20
|
const bodyWidth = window.innerWidth, bodyHeight = window.innerHeight;
|
|
21
21
|
let pageLimit = { left: 0, top: 0, bottom: bodyHeight, right: bodyWidth, width: bodyWidth, height: bodyHeight };
|
|
22
|
+
if (pageSelector) {
|
|
23
|
+
let page = modal.parents(pageSelector);
|
|
24
|
+
if (page.length) {
|
|
25
|
+
pageLimit = getBound(page[0]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
22
28
|
let targetLimit = getBound(target[0]);
|
|
23
29
|
let domLimit = getBound(modal[0]);
|
|
24
30
|
targetLimit = Object.assign({}, targetLimit);
|
|
@@ -149,7 +155,7 @@ const usePopup = (props) => {
|
|
|
149
155
|
if (!item || item.onClose === false) {
|
|
150
156
|
return;
|
|
151
157
|
}
|
|
152
|
-
let newItems = items.filter((o
|
|
158
|
+
let newItems = items.filter((o) => o.id !== id);
|
|
153
159
|
setSnackebarItems(newItems);
|
|
154
160
|
if (typeof item.onClose === 'function') {
|
|
155
161
|
item.onClose();
|
|
@@ -253,9 +259,9 @@ const Prompt = ({ change, placeholder }) => {
|
|
|
253
259
|
return (_jsx("textarea", { placeholder: placeholder, value: text, onChange: (e) => { const value = e.target.value; setText(value); change(value); } }));
|
|
254
260
|
};
|
|
255
261
|
const POPUPCTX = createContext({});
|
|
256
|
-
const Popup = ({ modal, isLast
|
|
262
|
+
const Popup = ({ modal, isLast }) => {
|
|
257
263
|
const mainContext = useContext(CTX);
|
|
258
|
-
let { setAttrs = () => { return {}; },
|
|
264
|
+
let { setAttrs = () => { return {}; }, position = 'fullscreen', getTarget } = modal;
|
|
259
265
|
let [temp] = useState({ dom: createRef(), backdropDom: createRef(), dui: undefined });
|
|
260
266
|
let [popoverStyle, setPopoverStyle] = useState({});
|
|
261
267
|
let modalMouseDown = useRef(false);
|
|
@@ -307,7 +313,7 @@ const Popup = ({ modal, isLast, renderCaller }) => {
|
|
|
307
313
|
if (!target || !target.length) {
|
|
308
314
|
return {};
|
|
309
315
|
}
|
|
310
|
-
let p = { modal: $(temp.dom.current), target, fitHorizontal: modal.fitHorizontal, limitTo: modal.limitTo, attrs, rtl: mainContext.rtl };
|
|
316
|
+
let p = { modal: $(temp.dom.current), target, fitHorizontal: modal.fitHorizontal, limitTo: modal.limitTo, attrs, rtl: mainContext.rtl, pageSelector: modal.pageSelector };
|
|
311
317
|
let style = Align(p);
|
|
312
318
|
let res = Object.assign(Object.assign({}, style), { position: 'absolute' });
|
|
313
319
|
return res;
|
|
@@ -324,7 +330,7 @@ const Popup = ({ modal, isLast, renderCaller }) => {
|
|
|
324
330
|
function mouseUp() {
|
|
325
331
|
setTimeout(() => modalMouseDown.current = false, 0);
|
|
326
332
|
}
|
|
327
|
-
function mouseDown(
|
|
333
|
+
function mouseDown() {
|
|
328
334
|
modalMouseDown.current = true;
|
|
329
335
|
$(window).unbind('mouseup', mouseUp);
|
|
330
336
|
$(window).bind('mouseup', mouseUp);
|
|
@@ -552,7 +558,7 @@ export function Alert(props) {
|
|
|
552
558
|
<div class='aio-popup-alert-text' style="text-align:${rtl ? 'right' : 'left'}">${text}</div>
|
|
553
559
|
</div>
|
|
554
560
|
<div class='aio-popup-alert-footer'>
|
|
555
|
-
|
|
561
|
+
${onClose !== false ? `<button class='aio-popup-alert-close ${$$.id}'>${closeText}</button>` : ''}
|
|
556
562
|
${actions.map((o) => {
|
|
557
563
|
const { className, id, text } = o;
|
|
558
564
|
return `<button data-action='${id}' class='aio-popup-alert-action${className ? ' ' + className : ''}'>${text}</button>`;
|
|
@@ -569,9 +575,6 @@ export function Alert(props) {
|
|
|
569
575
|
if (typeof onClose === 'function') {
|
|
570
576
|
onClose();
|
|
571
577
|
}
|
|
572
|
-
if (onClose === false) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
578
|
$('.' + $$.id).remove();
|
|
576
579
|
}, 200);
|
|
577
580
|
},
|
|
@@ -587,6 +590,8 @@ export function Alert(props) {
|
|
|
587
590
|
}[type] || '';
|
|
588
591
|
},
|
|
589
592
|
startTimer() {
|
|
593
|
+
let timeoutTime = time / 50 * 1000;
|
|
594
|
+
timeoutTime = timeoutTime > 100000 ? 100000 : timeoutTime;
|
|
590
595
|
setTimeout(() => {
|
|
591
596
|
if ($$.time >= 100) {
|
|
592
597
|
$$.time = 100;
|
|
@@ -596,7 +601,7 @@ export function Alert(props) {
|
|
|
596
601
|
$$.time += 2;
|
|
597
602
|
$$.updateBarRender();
|
|
598
603
|
$$.startTimer();
|
|
599
|
-
},
|
|
604
|
+
}, timeoutTime);
|
|
600
605
|
},
|
|
601
606
|
toggleClass(mount) {
|
|
602
607
|
let dom = $(`.${$$.id}`);
|
|
@@ -615,6 +620,9 @@ export function Alert(props) {
|
|
|
615
620
|
return;
|
|
616
621
|
}
|
|
617
622
|
action.callback();
|
|
623
|
+
if (action.close) {
|
|
624
|
+
$$.close();
|
|
625
|
+
}
|
|
618
626
|
},
|
|
619
627
|
render() {
|
|
620
628
|
$('body').append($$.getRender());
|
|
@@ -746,16 +754,16 @@ function getEasing(highlight) {
|
|
|
746
754
|
const { easing } = highlight;
|
|
747
755
|
var easingNames = [
|
|
748
756
|
'linear',
|
|
749
|
-
'easeInQuad',
|
|
750
|
-
'easeInSine',
|
|
751
|
-
'easeInCirc',
|
|
752
|
-
'easeInBack',
|
|
753
|
-
'easeOutQuad',
|
|
754
|
-
'easeOutSine',
|
|
755
|
-
'easeOutCirc',
|
|
756
|
-
'easeInOutQuad',
|
|
757
|
-
'easeInOutSine',
|
|
758
|
-
'easeInOutBack',
|
|
757
|
+
'easeInQuad',
|
|
758
|
+
'easeInSine',
|
|
759
|
+
'easeInCirc',
|
|
760
|
+
'easeInBack',
|
|
761
|
+
'easeOutQuad',
|
|
762
|
+
'easeOutSine',
|
|
763
|
+
'easeOutCirc',
|
|
764
|
+
'easeInOutQuad',
|
|
765
|
+
'easeInOutSine',
|
|
766
|
+
'easeInOutBack',
|
|
759
767
|
'easeOutBounce', //27
|
|
760
768
|
];
|
|
761
769
|
if (typeof easing === 'number') {
|
|
@@ -788,7 +796,10 @@ export class Loading {
|
|
|
788
796
|
return (`
|
|
789
797
|
<div class="aio-loading-container-0">
|
|
790
798
|
<div class="aio-loading-0">
|
|
791
|
-
${new Array(5).fill(0).map((o, i) =>
|
|
799
|
+
${new Array(5).fill(0).map((o, i) => {
|
|
800
|
+
if (o) { }
|
|
801
|
+
return this.getLoaderItem_0(`0.${i}`);
|
|
802
|
+
}).join(' ')}
|
|
792
803
|
</div>
|
|
793
804
|
</div>
|
|
794
805
|
`);
|