aio-popup 6.5.0 → 6.6.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.
- package/index.d.ts +2 -0
- package/index.js +19 -8
- package/package.json +1 -1
package/index.d.ts
CHANGED
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);
|
|
@@ -278,7 +284,9 @@ const Popup = ({ modal, isLast, renderCaller }) => {
|
|
|
278
284
|
let popup = $(temp.dom.current);
|
|
279
285
|
popup.removeClass('not-mounted');
|
|
280
286
|
$(temp.backdropDom.current).removeClass('not-mounted');
|
|
281
|
-
|
|
287
|
+
if (modal.focus !== false) {
|
|
288
|
+
popup.focus();
|
|
289
|
+
}
|
|
282
290
|
}, 0);
|
|
283
291
|
$(window).unbind('click', handleBackClick);
|
|
284
292
|
$(window).bind('click', handleBackClick);
|
|
@@ -307,7 +315,7 @@ const Popup = ({ modal, isLast, renderCaller }) => {
|
|
|
307
315
|
if (!target || !target.length) {
|
|
308
316
|
return {};
|
|
309
317
|
}
|
|
310
|
-
let p = { modal: $(temp.dom.current), target, fitHorizontal: modal.fitHorizontal, limitTo: modal.limitTo, attrs, rtl: mainContext.rtl };
|
|
318
|
+
let p = { modal: $(temp.dom.current), target, fitHorizontal: modal.fitHorizontal, limitTo: modal.limitTo, attrs, rtl: mainContext.rtl, pageSelector: modal.pageSelector };
|
|
311
319
|
let style = Align(p);
|
|
312
320
|
let res = Object.assign(Object.assign({}, style), { position: 'absolute' });
|
|
313
321
|
return res;
|
|
@@ -324,7 +332,7 @@ const Popup = ({ modal, isLast, renderCaller }) => {
|
|
|
324
332
|
function mouseUp() {
|
|
325
333
|
setTimeout(() => modalMouseDown.current = false, 0);
|
|
326
334
|
}
|
|
327
|
-
function mouseDown(
|
|
335
|
+
function mouseDown() {
|
|
328
336
|
modalMouseDown.current = true;
|
|
329
337
|
$(window).unbind('mouseup', mouseUp);
|
|
330
338
|
$(window).bind('mouseup', mouseUp);
|
|
@@ -790,7 +798,10 @@ export class Loading {
|
|
|
790
798
|
return (`
|
|
791
799
|
<div class="aio-loading-container-0">
|
|
792
800
|
<div class="aio-loading-0">
|
|
793
|
-
${new Array(5).fill(0).map((o, i) =>
|
|
801
|
+
${new Array(5).fill(0).map((o, i) => {
|
|
802
|
+
if (o) { }
|
|
803
|
+
return this.getLoaderItem_0(`0.${i}`);
|
|
804
|
+
}).join(' ')}
|
|
794
805
|
</div>
|
|
795
806
|
</div>
|
|
796
807
|
`);
|