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 CHANGED
@@ -572,6 +572,7 @@
572
572
 
573
573
  .aio-popup-confirm {
574
574
  overflow: hidden;
575
+ background: #fff;
575
576
  }
576
577
 
577
578
  .aio-popup-confirm .aio-popup-body {
package/index.d.ts CHANGED
@@ -102,6 +102,7 @@ export type AP_confirm = {
102
102
  export type AP_prompt = {
103
103
  title?: string;
104
104
  text: string;
105
+ placeholder?: string;
105
106
  subtitle?: string;
106
107
  submitText?: string;
107
108
  canselText?: string;
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-depencencies';
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 bodyWidth = window.innerWidth, bodyHeight = window.innerHeight;
20
- let pageLimit = { left: 0, top: 0, bottom: bodyHeight, right: bodyWidth, width: bodyWidth, height: bodyHeight };
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 [text, setText] = useState('');
256
- return (_jsx("textarea", { placeholder: placeholder, value: text, onChange: (e) => { const value = e.target.value; setText(value); change(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.0.0",
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-depencencies": "latest"
15
+ "aio-deps": "latest"
16
16
  },
17
17
  "keywords": [
18
18
  "popup",