aio-popup 8.0.0 → 8.1.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 +1 -0
- package/index.d.ts +1 -0
- package/index.js +11 -11
- package/package.json +2 -2
package/index.css
CHANGED
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -11,13 +11,13 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
11
11
|
import { createRef, useEffect, useState, createContext, useContext, useRef } from 'react';
|
|
12
12
|
import * as ReactDOMServer from 'react-dom/server';
|
|
13
13
|
import ReactDOM from 'react-dom';
|
|
14
|
-
import { $, anime } from 'aio-
|
|
14
|
+
import { $, anime } from 'aio-deps';
|
|
15
15
|
import './index.css';
|
|
16
16
|
const CTX = createContext({});
|
|
17
17
|
function Align(p) {
|
|
18
18
|
let { modal, target, fitHorizontal, rtl, limitTo, pageSelector } = p;
|
|
19
|
-
const
|
|
20
|
-
let pageLimit =
|
|
19
|
+
const page = modal.parents('.aio-popup-backdrop');
|
|
20
|
+
let pageLimit = getBound(page[0]);
|
|
21
21
|
if (pageSelector) {
|
|
22
22
|
let page = modal.parents(pageSelector);
|
|
23
23
|
if (page.length) {
|
|
@@ -46,7 +46,7 @@ function Align(p) {
|
|
|
46
46
|
//اگر راست به چپ باید باشد
|
|
47
47
|
if (rtl) {
|
|
48
48
|
//راست المان را با راست هدف ست کن
|
|
49
|
-
domLimit.right = targetLimit.right;
|
|
49
|
+
domLimit.right = targetLimit.right - pageLimit.left;
|
|
50
50
|
//چپ المان را بروز رسانی کن
|
|
51
51
|
domLimit.left = domLimit.right - domLimit.width;
|
|
52
52
|
//اگر المان از سمت چپ از صفحه بیرون زد سمت چپ المان را با سمت چپ صفحه ست کن
|
|
@@ -56,7 +56,7 @@ function Align(p) {
|
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
58
|
//چپ المان را با چپ هدف ست کن
|
|
59
|
-
domLimit.left = targetLimit.left;
|
|
59
|
+
domLimit.left = targetLimit.left + pageLimit.left;
|
|
60
60
|
//راست المان را بروز رسانی کن
|
|
61
61
|
domLimit.right = domLimit.left + domLimit.width;
|
|
62
62
|
//اگر المان از سمت راست صفحه بیرون زد سمت چپ المان را با پهنای المان ست کن
|
|
@@ -71,7 +71,7 @@ function Align(p) {
|
|
|
71
71
|
domLimit.top = pageLimit.bottom - domLimit.height;
|
|
72
72
|
}
|
|
73
73
|
else {
|
|
74
|
-
domLimit.top = targetLimit.top - domLimit.height;
|
|
74
|
+
domLimit.top = targetLimit.top - domLimit.height - (pageLimit.top);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
@@ -195,7 +195,7 @@ const usePopup = (props) => {
|
|
|
195
195
|
};
|
|
196
196
|
const addPrompt = (obj) => {
|
|
197
197
|
const id = 'a' + (Math.round(Math.random() * 100000));
|
|
198
|
-
let { title, text = '', subtitle, submitText = 'Submit', canselText = 'close', onSubmit, onCansel = () => { }, modalAttrs, backdropAttrs, headerAttrs, footerAttrs, bodyAttrs } = obj;
|
|
198
|
+
let { title, text = '', subtitle, submitText = 'Submit', placeholder = '', canselText = 'close', onSubmit, onCansel = () => { }, modalAttrs, backdropAttrs, headerAttrs, footerAttrs, bodyAttrs } = obj;
|
|
199
199
|
const submitAttrs = AddToAttrs(obj.submitAttrs, {
|
|
200
200
|
className: 'active', attrs: {
|
|
201
201
|
onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -230,7 +230,7 @@ const usePopup = (props) => {
|
|
|
230
230
|
position: 'center', header: { title, subtitle },
|
|
231
231
|
modalAttrs: AddToAttrs(modalAttrs, { className: 'aio-popup-prompt' }),
|
|
232
232
|
backdropAttrs, headerAttrs, footerAttrs, bodyAttrs,
|
|
233
|
-
body: _jsx(Prompt, { change: (value) => promptTexts.current = Object.assign(Object.assign({}, promptTexts.current), { [id]: value }), placeholder: text }),
|
|
233
|
+
body: _jsx(Prompt, { change: (value) => promptTexts.current = Object.assign(Object.assign({}, promptTexts.current), { [id]: value }), placeholder: placeholder, text: text }),
|
|
234
234
|
footer: (_jsxs(_Fragment, { children: [_jsx("button", Object.assign({}, canselAttrs, { children: canselText })), _jsx("button", Object.assign({}, submitAttrs, { children: submitText }))] }))
|
|
235
235
|
};
|
|
236
236
|
addModal(config);
|
|
@@ -251,9 +251,9 @@ const usePopup = (props) => {
|
|
|
251
251
|
return { addAlert, addSnackebar, removeModal, addModal, getModals, addHighlight, removeHighlight, render, addConfirm, addPrompt, portal };
|
|
252
252
|
};
|
|
253
253
|
export default usePopup;
|
|
254
|
-
const Prompt = ({ change, placeholder }) => {
|
|
255
|
-
const [
|
|
256
|
-
return (_jsx("textarea", { placeholder: placeholder, value:
|
|
254
|
+
const Prompt = ({ change, placeholder, text = '' }) => {
|
|
255
|
+
const [value, setValue] = useState(text);
|
|
256
|
+
return (_jsx("textarea", { placeholder: placeholder, value: value, onChange: (e) => { const value = e.target.value; setValue(value); change(value); } }));
|
|
257
257
|
};
|
|
258
258
|
const POPUPCTX = createContext({});
|
|
259
259
|
const Popup = ({ modal, isLast }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aio-popup",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "handle all types of popup and modals in react",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"url": "git+https://github.com/mohammadFeiz/aio-popup.git"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"aio-
|
|
15
|
+
"aio-deps": "latest"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
|
18
18
|
"popup",
|