aio-popup 4.5.2 → 5.0.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 CHANGED
@@ -1,153 +1,146 @@
1
- import React, { FC, ReactNode } from 'react';
2
- import './index.css';
3
- export type AP_props = {
4
- rtl?: boolean;
5
- id?: string;
6
- };
7
- export type AP_position = 'fullscreen' | 'center' | 'popover' | 'left' | 'right' | 'top' | 'bottom';
8
- export type AP_attrsKey = 'backdrop' | 'modal' | 'header' | 'body' | 'footer';
9
- export type AP_header = ((p: {
10
- close: () => void;
11
- state: any;
12
- setState: any;
13
- }) => ReactNode) | {
14
- title?: string;
15
- subtitle?: string;
16
- before?: ReactNode;
17
- after?: ReactNode;
18
- onClose?: boolean | ((p: {
19
- state: any;
20
- setState: (state: any) => void;
21
- }) => void);
22
- attrs?: any;
23
- };
24
- export type AP_body = (p: {
25
- close: () => void;
26
- state?: any;
27
- setState?: (state: any) => void;
28
- }) => ReactNode;
29
- export type AP_footer = (p: {
30
- state: any;
31
- setState: (v: any) => void;
32
- close: () => void;
33
- }) => ReactNode;
34
- type AP_setAttrs = (mode: AP_attrsKey) => any;
35
- export type AP_modal = {
36
- getTarget?: () => any;
37
- pageSelector?: string;
38
- limitTo?: string;
39
- maxHeight?: number | 'string';
40
- fixStyle?: (o: any, p: {
41
- targetLimit: any;
42
- pageLimit: any;
43
- }) => any;
44
- rtl?: boolean;
45
- id?: string;
46
- onClose?: boolean | (() => void);
47
- position?: AP_position;
48
- header?: AP_header;
49
- state?: any;
50
- footer?: AP_footer;
51
- body?: AP_body;
52
- animate?: boolean;
53
- fitHorizontal?: boolean;
54
- setAttrs?: AP_setAttrs;
55
- };
56
- export type AP_alert = {
57
- icon?: false | ReactNode;
58
- position?: AP_position;
59
- type: 'success' | 'error' | 'warning' | 'info';
60
- text?: ReactNode;
61
- subtext?: string;
62
- time?: number;
63
- className?: string;
64
- closeText?: string;
65
- animate?: boolean;
66
- onClose?: boolean | (() => void);
67
- };
68
- export type AP_snackebar = {
69
- id?: string;
70
- text: string;
71
- subtext?: string;
72
- icon?: ReactNode;
73
- time?: number;
74
- action?: {
75
- text: string;
76
- onClick: () => void;
77
- };
78
- type: 'success' | 'error' | 'warning' | 'info';
79
- verticalAlign?: 'start' | 'end';
80
- horizontalAlign?: 'start' | 'center' | 'end';
81
- onClose?: boolean | (() => void);
82
- attrs?: any;
83
- };
84
- export type AP_highlight = {
85
- dom: any;
86
- html: ReactNode;
87
- onClick?: () => void;
88
- mouseAccess?: boolean;
89
- attrs?: any;
90
- padding?: number;
91
- easing?: number | AP_easing;
92
- duration?: number;
93
- };
94
- export type AP_confirm = {
95
- title?: string;
96
- subtitle?: string;
97
- text?: ReactNode;
98
- submitText?: string;
99
- canselText?: string;
100
- onSubmit?: () => Promise<boolean>;
101
- onCansel?: () => void;
102
- setAttrs?: AP_setAttrs;
103
- };
104
- export type AP_prompt = {
105
- title?: string;
106
- subtitle?: string;
107
- text?: string;
108
- submitText?: string;
109
- canselText?: string;
110
- onSubmit?: (text: string) => Promise<boolean>;
111
- onCansel?: () => void;
112
- setAttrs?: AP_setAttrs;
113
- };
114
- export type AP_Snackebar = {
115
- getActions: (p: {
116
- add: (item: AP_snackebar) => void;
117
- }) => void;
118
- rtl: boolean;
119
- };
120
- export type AP_SnackebarItem = {
121
- item: AP_snackebar;
122
- onRemove: (id: string) => void;
123
- index: number;
124
- rtl: boolean;
125
- };
126
- export default class AIOPopup {
127
- rtl?: boolean;
128
- render: () => ReactNode;
129
- addModal: (p: AP_modal) => void;
130
- addHighlight: (p: AP_highlight) => void;
131
- removeHighlight: () => void;
132
- addAlert: (p: AP_alert) => void;
133
- removeModal: (arg?: string) => void;
134
- addSnackebar: (p: AP_snackebar) => void;
135
- getModals: () => AP_modal[];
136
- addConfirm: (p: AP_confirm) => void;
137
- addPrompt: (p: AP_prompt) => void;
138
- popupId?: string;
139
- popupsRef: React.RefObject<typeof Popups>;
140
- highlightRef: React.RefObject<typeof Highlight>;
141
- constructor(obj?: AP_props);
142
- }
143
- type AP_Popups = {
144
- ref: any;
145
- rtl: boolean;
146
- };
147
- declare const Popups: FC<AP_Popups>;
148
- type AP_easing = 'linear' | 'easeInQuad' | 'easeInCubic' | 'easeInQuart' | 'easeInQuint' | 'easeInSine' | 'easeInExpo' | 'easeInCirc' | 'easeInBack' | 'easeOutQuad' | 'easeOutCubic' | 'easeOutQuart' | 'easeOutQuint' | 'easeOutSine' | 'easeOutExpo' | 'easeOutCirc' | 'easeOutBack' | 'easeInBounce' | 'easeInOutQuad' | 'easeInOutCubic' | 'easeInOutQuart' | 'easeInOutQuint' | 'easeInOutSine' | 'easeInOutExpo' | 'easeInOutCirc' | 'easeInOutBack' | 'easeInOutBounce' | 'easeOutBounce' | 'easeOutInQuad' | 'easeOutInCubic' | 'easeOutInQuart' | 'easeOutInQuint' | 'easeOutInSine' | 'easeOutInExpo' | 'easeOutInCirc' | 'easeOutInBack' | 'easeOutInBounce';
149
- type AP_Highlight = {
150
- ref: any;
151
- };
152
- declare const Highlight: FC<AP_Highlight>;
153
- export {};
1
+ import { ReactNode } from 'react';
2
+ import './index.css';
3
+ export type AP_position = 'fullscreen' | 'center' | 'popover' | 'left' | 'right' | 'top' | 'bottom';
4
+ export type AP_attrsKey = 'backdrop' | 'modal' | 'header' | 'body' | 'footer';
5
+ export type AP_header = ((p: {
6
+ removeModal: () => void;
7
+ state: any;
8
+ setState: any;
9
+ }) => ReactNode) | {
10
+ title?: string;
11
+ subtitle?: string;
12
+ before?: ReactNode;
13
+ after?: ReactNode;
14
+ onClose?: boolean | ((p: {
15
+ state: any;
16
+ setState: (state: any) => void;
17
+ }) => void);
18
+ };
19
+ export type AP_body = (p: {
20
+ removeModal: () => void;
21
+ state: any;
22
+ setState: (state: any) => void;
23
+ }) => ReactNode;
24
+ export type AP_footer = (p: {
25
+ state: any;
26
+ setState: (v: any) => void;
27
+ removeModal: () => void;
28
+ }) => ReactNode;
29
+ type AP_setAttrs = (mode: AP_attrsKey) => any;
30
+ export type AP_modal = {
31
+ getTarget?: () => any;
32
+ limitTo?: string;
33
+ rtl?: boolean;
34
+ id?: string;
35
+ onClose?: boolean | (() => void);
36
+ position?: AP_position;
37
+ header?: AP_header;
38
+ state?: any;
39
+ footer?: AP_footer;
40
+ body?: AP_body;
41
+ animate?: boolean;
42
+ fitHorizontal?: boolean;
43
+ setAttrs?: AP_setAttrs;
44
+ };
45
+ export type AP_alert = {
46
+ icon?: false | ReactNode;
47
+ type: 'success' | 'error' | 'warning' | 'info';
48
+ text?: ReactNode;
49
+ subtext?: string;
50
+ time?: number;
51
+ className?: string;
52
+ closeText?: string;
53
+ animate?: boolean;
54
+ onClose?: boolean | (() => void);
55
+ };
56
+ export type AP_snackebar = {
57
+ id?: string;
58
+ text: string;
59
+ subtext?: string;
60
+ icon?: ReactNode;
61
+ time?: number;
62
+ action?: {
63
+ text: string;
64
+ onClick: () => void;
65
+ };
66
+ type: 'success' | 'error' | 'warning' | 'info';
67
+ align?: ['left' | 'center' | 'right', 'top' | 'bottom'];
68
+ onClose?: boolean | (() => void);
69
+ attrs?: any;
70
+ };
71
+ export type AP_highlight = {
72
+ dom: any;
73
+ html: ReactNode;
74
+ onClick?: () => void;
75
+ mouseAccess?: boolean;
76
+ attrs?: any;
77
+ padding?: number;
78
+ easing?: number | AP_easing;
79
+ duration?: number;
80
+ };
81
+ export type AP_confirm = {
82
+ title?: string;
83
+ subtitle?: string;
84
+ text?: ReactNode;
85
+ submitText?: string;
86
+ canselText?: string;
87
+ onSubmit?: () => Promise<boolean>;
88
+ onCansel?: () => void;
89
+ setAttrs?: AP_setAttrs;
90
+ };
91
+ export type AP_prompt = {
92
+ title?: string;
93
+ subtitle?: string;
94
+ text?: string;
95
+ submitText?: string;
96
+ canselText?: string;
97
+ onSubmit?: (text: string) => Promise<boolean>;
98
+ onCansel?: () => void;
99
+ setAttrs?: AP_setAttrs;
100
+ };
101
+ type AP_removeModal = (arg?: string) => void;
102
+ type AP_addAlert = (p: AP_alert) => void;
103
+ type AP_addSnackebar = (item: AP_snackebar) => void;
104
+ type AP_addModal = (o: AP_modal) => void;
105
+ type AP_addHighlight = (highlight: AP_highlight) => void;
106
+ type AP_removeHighlight = () => void;
107
+ type AP_getModals = () => AP_modal[];
108
+ type AP_addConfirm = (item: AP_confirm) => void;
109
+ type AP_addPrompt = (item: AP_prompt) => void;
110
+ type AP_render = () => ReactNode;
111
+ export type AP_usePopup = {
112
+ addAlert: AP_addAlert;
113
+ addSnackebar: AP_addSnackebar;
114
+ removeModal: AP_removeModal;
115
+ addModal: AP_addModal;
116
+ getModals: AP_getModals;
117
+ addHighlight: AP_addHighlight;
118
+ removeHighlight: AP_removeHighlight;
119
+ render: AP_render;
120
+ addConfirm: AP_addConfirm;
121
+ addPrompt: AP_addPrompt;
122
+ };
123
+ export type I_usePopup = {
124
+ addAlert: AP_addAlert;
125
+ addSnackebar: AP_addSnackebar;
126
+ removeModal: AP_removeModal;
127
+ addModal: AP_addModal;
128
+ getModals: AP_getModals;
129
+ addHighlight: AP_addHighlight;
130
+ removeHighlight: AP_removeHighlight;
131
+ render: AP_render;
132
+ addConfirm: AP_addConfirm;
133
+ addPrompt: AP_addPrompt;
134
+ portal: () => void;
135
+ };
136
+ declare const usePopup: (props?: {
137
+ rtl?: boolean;
138
+ id?: string;
139
+ }) => I_usePopup;
140
+ export default usePopup;
141
+ export type AP_SnackebarItem = {
142
+ item: AP_snackebar;
143
+ index: number;
144
+ };
145
+ export declare function Alert(props: AP_alert): void;
146
+ type AP_easing = 'linear' | 'easeInQuad' | 'easeInCubic' | 'easeInQuart' | 'easeInQuint' | 'easeInSine' | 'easeInExpo' | 'easeInCirc' | 'easeInBack' | 'easeOutQuad' | 'easeOutCubic' | 'easeOutQuart' | 'easeOutQuint' | 'easeOutSine' | 'easeOutExpo' | 'easeOutCirc' | 'easeOutBack' | 'easeInBounce' | 'easeInOutQuad' | 'easeInOutCubic' | 'easeInOutQuart' | 'easeInOutQuint' | 'easeInOutSine' | 'easeInOutExpo' | 'easeInOutCirc' | 'easeInOutBack' | 'easeInOutBounce' | 'easeOutBounce' | 'easeOutInQuad' | 'easeOutInCubic' | 'easeOutInQuart' | 'easeOutInQuint' | 'easeOutInSine' | 'easeOutInExpo' | 'easeOutInCirc' | 'easeOutInBack' | 'easeOutInBounce';
package/index.js CHANGED
@@ -1,17 +1,15 @@
1
- import t,{Component as e,createRef as i,useEffect as o,useState as r,createContext as a,useContext as n,useRef as l,forwardRef as s,useImperativeHandle as d,createElement as p}from"react";import*as c from"react-dom/server";import h from"jquery";import"./index.css";import u from"animejs/lib/anime.es.js";import{jsx as _,Fragment as $,jsxs as m}from"react/jsx-runtime";function _defineProperty(t,e,i){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function _toPropertyKey(t){var e=_toPrimitive(t,"string");return"symbol"==typeof e?e:e+""}function _toPrimitive(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var o=i.call(t,e||"default");if("object"!=typeof o)return o;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}export default class f{constructor(t){_defineProperty(this,"rtl",void 0),_defineProperty(this,"render",void 0),_defineProperty(this,"addModal",void 0),_defineProperty(this,"addHighlight",void 0),_defineProperty(this,"removeHighlight",void 0),_defineProperty(this,"addAlert",void 0),_defineProperty(this,"removeModal",void 0),_defineProperty(this,"addSnackebar",void 0),_defineProperty(this,"getModals",void 0),_defineProperty(this,"addConfirm",void 0),_defineProperty(this,"addPrompt",void 0),_defineProperty(this,"popupId",void 0),_defineProperty(this,"popupsRef",void 0),_defineProperty(this,"highlightRef",void 0);let{rtl:e=!1}=t||{};this.rtl=e,this.addSnackebar=()=>{},this.popupsRef=i(),this.highlightRef=i(),this.getModals=()=>{let t=this.popupsRef.current;return null===t?[]:t.getModals()||[]},this.addModal=t=>{let e=this.popupsRef.current;null!==e&&e.addModal(t)},this.addHighlight=t=>{let e=this.highlightRef.current;null!==e&&e.addHighlight(t)},this.removeModal=t=>{let e=this.popupsRef.current;null!==e&&e.removeModal(t)},this.removeHighlight=()=>{let t=this.highlightRef.current;null!==t&&t.removeHighlight()},this.render=()=>{let t={rtl:e,getActions:({add:t})=>this.addSnackebar=t};return m($,{children:[_(Popups,{rtl:e,ref:this.popupsRef}),_(Snackebar,{...t}),_(Highlight,{ref:this.highlightRef})]})},this.addAlert=t=>Alert(t),this.addConfirm=t=>{let{title:e,subtitle:i,text:o,submitText:r="Yes",canselText:a="No",onSubmit:n,onCansel:l=()=>{},setAttrs:s=()=>({})}=t,d={position:"center",setAttrs(t){let e=s(t);return"modal"===t?AddToAttrs(e,{className:"aio-popup-confirm"}):e},header:{title:e,subtitle:i},body:()=>o,footer:()=>m($,{children:[_("button",{type:"button",onClick:()=>{l(),this.removeModal()},children:a}),_("button",{type:"button",className:"active",onClick:async()=>{if(n)!1!==await n()&&this.removeModal()},children:r})]})};this.addModal(d)},this.addPrompt=t=>{let{title:e,subtitle:i,text:o,submitText:r="Submit",canselText:a="close",onSubmit:n,onCansel:l=()=>{},setAttrs:s=()=>({})}=t,d={position:"center",setAttrs(t){let e=s(t);return"modal"===t?AddToAttrs(e,{className:"aio-popup-prompt"}):e},state:{temp:""},header:{title:e,subtitle:i},body:({state:t,setState:e})=>_("textarea",{placeholder:o,value:t.temp,onChange(t){e&&e({temp:t.target.value})}}),footer:({state:t,setState:e})=>m($,{children:[_("button",{type:"button",onClick:()=>{l(),this.removeModal()},children:a}),_("button",{type:"button",className:"active",onClick:async()=>{if(n)!1!==await n(t.temp)?this.removeModal():e({temp:""})},disabled:!t.temp,children:r})]})};this.addModal(d)}}};let Popups=s((t,e)=>{let[i,o]=r([]),a=l(i);a.current=i;let{rtl:n}=t;function s(t){void 0===t.id&&(t.id="popup"+Math.round(1e6*Math.random()));let e=t;o(i=>[...i.filter(({id:e})=>e!==t.id),e])}async function p(t="last"){if("all"===t){o([]);return}if(!a.current.length)return;"last"===t&&(t=a.current[a.current.length-1].id);let e=a.current.find(e=>e.id===t);e&&(h(`[data-id=${t}]`).addClass("not-mounted"),setTimeout(()=>{e&&"function"==typeof e.onClose&&e.onClose(),o(e=>e.filter(e=>e.id!==t))},300))}function c(){return a.current.map((t,e)=>_(Popup,{modal:t,rtl:n,isLast:e===a.current.length-1,onClose:()=>p(t.id)},t.id))}d(e,()=>({addModal:s,removeModal:p,getModals:()=>a.current}));let u=c();return u.length?_($,{children:u}):null}),CTX=a({});function Popup(t){let{modal:e,rtl:a,onClose:n,isLast:s}=t,{setAttrs:d=()=>({}),id:p,position:c="fullscreen",getTarget:u,maxHeight:$,fixStyle:f=t=>t}=e,[g]=r({dom:i(),backdropDom:i(),dui:void 0,isDown:!1}),[v,b]=r({}),[y,L]=r(e.state),k=d("modal")||{},C=d("backdrop")||{},w=l(!1);async function M(){n()}function N(t){if(!g.dui)return;let e=h(t.target);"popover"===c&&e.attr("data-id")!==g.dui&&!e.parents(`[data-id=${g.dui}]`).length&&M()}o(()=>()=>{h(window).unbind("click",N)}),o(()=>{let t="popover"===c?function t(){if(!u)return{};let i=u();if(!i||!i.length)return{};let o={dom:h(g.dom.current),target:i,fitHorizontal:e.fitHorizontal,fixStyle:f,pageSelector:e.pageSelector,limitTo:e.limitTo,attrs:k,rtl:a},r={...Align(o),position:"absolute"};return $&&(r.maxHeight=$),r}():{};if(console.log("updatedStyle.top",t.top),b(t),u){g.dui="a"+Math.round(1e7*Math.random());u().attr("data-id",g.dui)}setTimeout(()=>{let t=h(g.dom.current);t.removeClass("not-mounted"),h(g.backdropDom.current).removeClass("not-mounted"),t.focus()},0),h(window).unbind("click",N),h(window).bind("click",N)},[]);function A(t){if(s)27===t.keyCode&&n()}function x(){setTimeout(()=>g.isDown=!1,0)}let H,P,S,T;return _(CTX.Provider,{value:{close:M,state:y,setState:L},children:_("div",{...(H="aio-popup-backdrop",H+=` aio-popup-position-${c}`,H+=a?" rtl":" ltr",w&&(H+=" not-mounted"),AddToAttrs(C,{className:H,attrs:{ref:g.backdropDom,onKeyDown:A,tabIndex:0,"data-id":p,onClick:C.onClick?C.onClick:function t(e){if(!g.isDown){e.stopPropagation();h(e.target).hasClass("aio-popup-backdrop")&&M()}}}})),children:m("div",{...(P={...v,...k.style},S="ontouchstart"in document.documentElement?"onTouchStart":"onMouseDown",{...k,ref:g.dom,"data-id":e.id,tabIndex:0,onKeyDown:A,[S]:function t(e){h(window).unbind("mouseup",x),h(window).bind("mouseup",x),g.isDown=!0},className:(T="aio-popup",T+=a?" rtl":" ltr",w&&(T+=" not-mounted"),k.className&&(T+=" "+k.className),T),style:{...P}}),children:[!!e.header&&_(ModalHeader,{modal:e}),_(ModalBody,{modal:e}),!!e.footer&&_("div",{...AddToAttrs(d("footer"),{className:"aio-popup-footer"}),children:e.footer({state:y,setState:L,close:M})})]})})})}let ModalHeader=t=>{let e=n(CTX),{modal:i}=t,{state:o,setState:r}=e,{setAttrs:a=()=>({})}=i,l=a("header")||{};if("function"==typeof i.header)return i.header({close:e.close,state:o,setState:r});if("object"!=typeof i.header)return null;let s="aio-popup-header",{title:d,subtitle:p,onClose:c,before:h,after:u}=i.header;function $(t){t.stopPropagation(),t.preventDefault(),"function"==typeof c?c({state:o,setState:r}):e.close()}function f(){return p?m("div",{className:`${s}-text`,children:[_("div",{className:`${s}-title`,children:d}),_("div",{className:`${s}-subtitle`,children:p})]}):_("div",{className:`${s}-title`,style:{display:"flex",alignItems:"center",flex:1},children:d})}return m("div",{...AddToAttrs(l,{className:s}),children:[void 0!==h&&_("div",{className:`${s}-before`,onClick:t=>$(t),children:h}),!!d&&f(),void 0!==u&&_("div",{className:`${s}-after`,onClick:t=>$(t),children:u}),!1!==c&&_("div",{className:`${s}-close-button`,onClick:t=>$(t),children:_(CloseIcon,{})})]})},ModalBody=t=>{let{state:e,setState:i,close:o}=n(CTX),{modal:r}=t,{body:a=()=>null,setAttrs:l=()=>({})}=r,s=l("body")||{},d={close:o,state:e,setState:i},p=a(d);return p&&null!==p?_("div",{...AddToAttrs(s,{className:"aio-popup-body aio-popup-scroll"}),children:p}):null};function Alert(t){let{icon:e,type:i="",text:o="",subtext:r="",time:a=10,className:n,closeText:l="بستن",position:s="center",onClose:d}=t,p={id:"",time:0,getId:()=>"aa"+Math.round(1e8*Math.random()),getBarRender:()=>`<div class='aio-popup-time-bar' style="width:${p.time}%;"></div>`,updateBarRender(){h(`.aio-popup-alert-container.${p.id} .aio-popup-time`).html(p.getBarRender())},getRender:()=>`
2
- <div class='aio-popup-alert-container not-mounted ${p.id} aio-popup-alert-container-${s}${n?` ${n}`:""}'>
3
- <div class='aio-popup-alert aio-popup-alert-${i}'>
4
- <div class='aio-popup-alert-header'>${p.getIcon()}</div>
1
+ import{createRef as t,useEffect as e,useState as o,createContext as i,useContext as r,useRef as a}from"react";import*as n from"react-dom/server";import l from"react-dom";import d from"animejs/lib/anime.es.js";import s from"jquery";import"./index.css";import{jsx as p}from"react/jsx-runtime";import{Fragment as c}from"react/jsx-runtime";import{jsxs as u}from"react/jsx-runtime";let CTX=i({});function Align(t){let{modal:e,target:o,fitHorizontal:i,rtl:r,limitTo:a}=t,n=window.innerWidth,l=window.innerHeight,d={left:0,top:0,bottom:l,right:n,width:n,height:l},s=getBound(o[0]),p=getBound(e[0]);s={...s};let c;if((p={...p}).top=s.bottom,p.bottom=p.top+p.height,i)p.width=s.width,p.left=s.left,p.right=s.left+s.width;else{if(a){let u=e.parents(a);u.length&&(d=getBound(u[0]))}r?(p.right=s.right,p.left=p.right-p.width,p.left<d.left&&(p.left=d.left)):(p.left=s.left,p.right=p.left+p.width,p.right>d.right&&(p.left=d.right-p.width))}return p.bottom>d.bottom?p.height>s.top-d.top?p.top=d.bottom-p.height:p.top=s.top-p.height:p.top=s.bottom,p.height>d.height&&(p.top=d.top,p.height=d.height,c="auto"),{left:p.left,top:p.top,width:p.width,overflowY:c,maxWidth:d.width}}let CloseIcon=()=>p("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:p("path",{d:"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",style:{fill:"currentcolor"}})});function AddToAttrs(t,e){let{style:o}=e,i,r=[...(t=t||{}).className?t.className.split(" "):[],...(e.className?Array.isArray(e.className)?e.className:e.className.split(" "):[]).filter(t=>!!t)],a=r.length?r.join(" "):void 0,n={...t.style,...o};return{...t,className:a,style:n,...e.attrs}}let usePopup=t=>{let[e,i]=o([]),r=a(e);r.current=e;let[n,d]=o([]),_=a(n);_.current=n;let[h,$]=o(),m=t=>{void 0===t.id&&(t.id="popup"+Math.round(1e6*Math.random()));let e=t;i(o=>[...o.filter(({id:e})=>e!==t.id),e])},g=async t=>{if("string"!=typeof t&&(t="last"),"all"===t){i([]);return}if(!r.current.length)return;"last"===t&&(t=r.current[r.current.length-1].id);let e=r.current.find(e=>e.id===t);e&&(s(`[data-id=${t}]`).addClass("not-mounted"),setTimeout(()=>{e&&"function"==typeof e.onClose&&e.onClose(),i(e=>e.filter(e=>e.id!==t))},300))},f=t=>{d([..._.current,{...t,id:"a"+Math.round(1e9*Math.random())}])},v=t=>{let e=_.current,o=e.find(e=>e.id===t);if(o&&!1!==o.onClose)d(e.filter((e,o)=>e.id!==t)),"function"==typeof o.onClose&&o.onClose()},b=t=>Alert(t),C=t=>$(t),k=()=>$(void 0),y=t=>{let{title:e,subtitle:o,text:i,submitText:r="Yes",canselText:a="No",onSubmit:n,onCansel:l=()=>{},setAttrs:d=()=>({})}=t,s={position:"center",setAttrs(t){let e=d(t);return"modal"===t?AddToAttrs(e,{className:"aio-popup-confirm"}):e},header:{title:e,subtitle:o},body:()=>i,footer:()=>u(c,{children:[p("button",{type:"button",onClick(){l(),g()},children:a}),p("button",{type:"button",className:"active",async onClick(){if(n)!1!==await n()&&g()},children:r})]})};m(s)},L=t=>{let{title:e,subtitle:o,text:i,submitText:r="Submit",canselText:a="close",onSubmit:n,onCansel:l=()=>{},setAttrs:d=()=>({})}=t,s={position:"center",setAttrs(t){let e=d(t);return"modal"===t?AddToAttrs(e,{className:"aio-popup-prompt"}):e},state:{temp:""},header:{title:e,subtitle:o},body:({state:t,setState:e})=>p("textarea",{placeholder:i,value:t.temp,onChange(t){e&&e({temp:t.target.value})}}),footer:({state:t,setState:e})=>u(c,{children:[p("button",{type:"button",onClick(){l(),g()},children:a}),p("button",{type:"button",className:"active",async onClick(){if(n)!1!==await n(t.temp)?g():e({temp:""})},disabled:!t.temp,children:r})]})};m(s)},M=()=>({rtl:!!t&&!!t.rtl,snackebarItems:_.current,removeSnackebar:v,removeModal:g}),S=()=>u(CTX.Provider,{value:M(),children:[r.current.map((t,e)=>p(Popup,{modal:t,isLast:e===r.current.length-1},t.id)),n.map((t,e)=>p(SnackebarItem,{item:t,index:e},t.id)),!!h&&p(Highlight,{highlight:h})]}),w=()=>l.createPortal(S(),document.body);return{addAlert:b,addSnackebar:f,removeModal:g,addModal:m,getModals:()=>r.current,addHighlight:C,removeHighlight:k,render:S,addConfirm:y,addPrompt:L,portal:w}};export default usePopup;let POPUPCTX=i({}),Popup=({modal:i,isLast:n})=>{let l=r(CTX),{setAttrs:d=()=>({}),id:c,position:_="fullscreen",getTarget:h}=i,[$]=o({dom:t(),backdropDom:t(),dui:void 0}),[m,g]=o({}),[f,v]=o(i.state),b=d("modal")||{},C=a(!1);function k(t){if(!$.dui)return;let e=s(t.target);"popover"===_&&e.attr("data-id")!==$.dui&&!e.parents(`[data-id=${$.dui}]`).length&&l.removeModal()}function y(){let t={...m,...b.style},e="ontouchstart"in document.documentElement?"onTouchStart":"onMouseDown";return{...b,ref:$.dom,"data-id":i.id,tabIndex:0,onKeyDown:M,[e]:w,className:T(),style:{...t}}}function L(){if(!h)return{};let t=h();if(!t||!t.length)return{};let e={modal:s($.dom.current),target:t,fitHorizontal:i.fitHorizontal,limitTo:i.limitTo,attrs:b,rtl:l.rtl};return{...Align(e),position:"absolute"}}function M(t){if(n)27===t.keyCode&&l.removeModal()}function S(){}function w(t){s(window).unbind("mouseup",S),s(window).bind("mouseup",S)}function T(){let t="aio-popup";return t+=l.rtl?" rtl":" ltr",C&&(t+=" not-mounted"),b.className&&(t+=" "+b.className),t}e(()=>()=>{s(window).unbind("click",k)}),e(()=>{let t="popover"===_?L():{};if(console.log("updatedStyle.top",t.top),g(t),h){$.dui="a"+Math.round(1e7*Math.random());h().attr("data-id",$.dui)}setTimeout(()=>{let t=s($.dom.current);t.removeClass("not-mounted"),s($.backdropDom.current).removeClass("not-mounted"),t.focus()},0),s(window).unbind("click",k),s(window).bind("click",k)},[]);let x=()=>({mainContext:l,modal:i,isLast:n,state:f,setState:v,onKeyDown:M});return p(POPUPCTX.Provider,{value:x(),children:p(ModalBackdrop,{content:u("div",{...y(),children:[p(ModalHeader,{}),p(ModalBody,{}),p(ModalFooter,{})]}),firstMount:!!C,ref:$.backdropDom})})},ModalBackdrop=({content:t,firstMount:e,ref:i})=>{let{mainContext:a,modal:n,onKeyDown:l}=r(POPUPCTX),{setAttrs:d=()=>({}),id:c,position:u="fullscreen"}=n,[_]=o(d("backdrop")||{});function h(t){if(t.target===t.currentTarget){t.stopPropagation();s(t.target).hasClass("aio-popup-backdrop")&&a.removeModal()}}function $(){let t="aio-popup-backdrop";return t+=` aio-popup-position-${u}`,t+=a.rtl?" rtl":" ltr",e&&(t+=" not-mounted"),AddToAttrs(_,{className:t,attrs:{ref:i,onKeyDown:l,tabIndex:0,"data-id":c,onClick:_.onClick?_.onClick:h}})}return p("div",{...$(),children:t})},ModalHeader=()=>{let{mainContext:t,modal:e,state:o,setState:i}=r(POPUPCTX);if(!e.header)return null;let{setAttrs:a=()=>({})}=e,n=a("header")||{};return"function"==typeof e.header?e.header({removeModal:t.removeModal,state:o,setState:i}):"object"!=typeof e.header?null:u("div",{...AddToAttrs(n,{className:"aio-popup-header"}),children:[p(ModalHeaderElement,{type:"before"},"before"),p(ModalHeaderElement,{type:"title"},"title"),p(ModalHeaderElement,{type:"after"},"after"),p(ModalClose,{})]})},ModalHeaderElement=({type:t})=>{let{modal:e}=r(POPUPCTX),{header:o}=e;return"function"!=typeof o&&o&&o[t]?p("div",{className:`aio-popup-header-${t}`,"data-subtitle":"title"===t?o.subtitle:void 0,children:o[t]}):null},ModalClose=()=>{let{modal:t,state:e,setState:o,mainContext:i}=r(POPUPCTX),{header:a}=t;return"function"!=typeof a&&a&&!1!==a.onClose?p("div",{className:"aio-popup-header-close",onClick(r){r.stopPropagation(),r.preventDefault(),"function"==typeof a.onClose?a.onClose({state:e,setState:o}):i.removeModal(t.id)},children:p(CloseIcon,{})}):null},ModalBody=()=>{let{mainContext:t,state:e,setState:o,modal:i}=r(POPUPCTX),{body:a=()=>null,setAttrs:n=()=>({})}=i,l=n("body")||{},d={removeModal:t.removeModal,state:e,setState:o},s=a(d);return s&&null!==s?p("div",{...AddToAttrs(l,{className:"aio-popup-body aio-popup-scroll"}),children:s}):null},ModalFooter=()=>{let{mainContext:t,modal:e,state:o,setState:i}=r(POPUPCTX),{setAttrs:a=()=>({}),footer:n}=e;if(!n)return null;let l=a("footer")||{},d=AddToAttrs(l,{className:"aio-popup-footer"});return p("div",{...d,children:n({state:o,setState:i,removeModal:t.removeModal})})},SBCTX=i({}),SnackebarItem=t=>{let i=r(CTX),{item:a}=t,{time:n=8,id:l,align:d=["right","top"]}=a;"top"!==d[1]&&"bottom"!==d[1]&&(d[1]="top"),"left"!==d[0]&&"right"!==d[0]&&"center"!==d[0]&&(d[0]="right");let[s,c]=o(!1);function u(){c(!1),setTimeout(()=>i.removeSnackebar(l),200)}e(()=>{setTimeout(()=>c(!0),0),setTimeout(()=>u(),1e3*n)},[]);let _=t=>"error"===t||"warning"===t||"info"===t?p(InfoSvg,{}):p(SuccessSvg,{}),h=()=>({mainContext:i,remove:u,item:{...t.item,time:n,align:d},index:t.index,mounted:s,getSvg:_});return p(SBCTX.Provider,{value:h(),children:p(SnackebarContainer,{})})},SnackebarContainer=()=>{let{mainContext:t,mounted:e,index:o,item:i,remove:a}=r(SBCTX),{rtl:n}=t,{onClose:l,align:d=["right","top"]}=i;function c(t){let e=s(".aio-popup-snackebar-item-container"),o={top:12,bottom:12};for(let i=0;i<t;i++){let r=e.eq(i),a=r.height()+6,n=r.attr("data-vertical-align");o[n]+=a}return{["top"===d[1]?"top":"bottom"]:o[d[1]]}}let u="aio-popup-snackebar-item-container";u+=` aio-popup-snackebar-item-container-horizontal-align-${d[0]}`,e&&(u+=" mounted"),n&&(u+=" rtl");let _=c(o),h={"data-vertical-align":d[1],className:u,style:_,onClick:!1===l?void 0:()=>a()};return p("div",{...h,children:p(SnackebarCard,{})})},SnackebarCard=()=>{let{item:t}=r(SBCTX),{type:e,attrs:o={}}=t,i="aio-popup-snackebar-item";return i+=` aio-popup-snackebar-item-${e}`,o.className&&(i+=` ${o.className}`),u("div",{...{...o,className:i,style:o.style},children:[p(SnackebarIcon,{}),p(SnackebarText,{}),p(SnackebarAction,{}),p(SnackebarBar,{})]})},SnackebarIcon=()=>{let{getSvg:t,item:e}=r(SBCTX);return p("div",{className:"aio-popup-snackebar-item-icon",children:e.icon?e.icon:t(e.type)})},SnackebarText=()=>{let{item:t}=r(SBCTX);return u("div",{className:"aio-popup-snackebar-item-text",children:[p("div",{className:"aio-popup-snackebar-item-uptext",children:t.text}),!!t.subtext&&p("div",{className:"aio-popup-snackebar-item-subtext",children:t.subtext})]})},SnackebarAction=()=>{let{item:t,remove:e}=r(SBCTX),{action:o}=t;return o&&o.text?p("button",{className:"aio-popup-snackebar-item-action",onClick(t){t.stopPropagation(),o&&o.onClick(),e()},children:o.text}):null},SnackebarBar=()=>{let{item:t}=r(SBCTX);return p("div",{className:"aio-popup-snackebar-bar",style:{transition:`${t.time||8}s linear`}})};export function Alert(t){let{icon:e,type:o="",text:i="",subtext:r="",time:a=10,className:l,closeText:d="Close",onClose:p}=t,c={id:"",time:0,getId:()=>"aa"+Math.round(1e8*Math.random()),getBarRender:()=>`<div class='aio-popup-time-bar' style="width:${c.time}%;"></div>`,updateBarRender(){s(`.aio-popup-alert-container.${c.id} .aio-popup-time`).html(c.getBarRender())},getRender:()=>`
2
+ <div class='aio-popup-alert-container not-mounted ${c.id} aio-popup-alert-container-center${l?` ${l}`:""}'>
3
+ <div class='aio-popup-alert aio-popup-alert-${o}'>
4
+ <div class='aio-popup-alert-header'>${c.getIcon()}</div>
5
5
  <div class='aio-popup-alert-body aio-popup-scroll'>
6
- <div class='aio-popup-alert-text'>${c.renderToStaticMarkup(o)}</div>
6
+ <div class='aio-popup-alert-text'>${n.renderToStaticMarkup(i)}</div>
7
7
  <div class='aio-popup-alert-subtext'>${r}</div>
8
8
  </div>
9
9
  <div class='aio-popup-alert-footer'>
10
- <button class='aio-popup-alert-close ${p.id}'>${l}</button>
10
+ <button class='aio-popup-alert-close ${c.id}'>${d}</button>
11
11
  </div>
12
12
  <div class='aio-popup-time'></div>
13
13
  </div>
14
14
  </div>
15
- `,close(){p.toggleClass(!1),setTimeout(()=>{"function"==typeof d&&d(),!1!==d&&h("."+p.id).remove()},200)},getIcon:()=>!1===e?"":e||({error:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg>',warning:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16"></path></svg>',info:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"></path></svg>',success:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z"></path></svg>'})[i]||"",startTimer(){setTimeout(()=>{if(p.time>=100){p.time=100,p.close();return}p.time+=2,p.updateBarRender(),p.startTimer()},a/50*1e3)},toggleClass(t){let e=h(`.${p.id}`);t?setTimeout(()=>e.removeClass("not-mounted"),0):e.addClass("not-mounted")},render(){h("body").append(p.getRender()),h("button."+p.id).off("click",p.close),h("button."+p.id).on("click",p.close),p.toggleClass(!0)}};p.id=p.getId(),p.render(),a&&p.startTimer()}class Snackebar extends e{constructor(t){super(t),this.state={items:[]},t.getActions({add:this.add.bind(this)})}add(t){let{items:e}=this.state,i=[...e,{...t,id:"a"+Math.round(1e9*Math.random())}];this.setState({items:i})}remove(t,e){if(!1===e)return;let{items:i}=this.state,o=i.filter((e,i)=>e.id!==t);this.setState({items:o}),"function"==typeof e&&e()}render(){let{items:t}=this.state,{rtl:e}=this.props;return _($,{children:t.map((t,i)=>p(SnackebarItem,{rtl:e,item:t,index:i,onRemove:e=>this.remove(e,t.onClose),key:t.id}))})}}function SnackebarItem(t){var e;let{item:i,onRemove:a,index:n,rtl:l}=t,{time:s=8,id:d,text:p,type:c,subtext:u,action:$,onClose:f,verticalAlign:g="end",horizontalAlign:v="center",icon:b,attrs:y={}}=i;"start"!==g&&"end"!==g&&(g="end",console.error('aio-popup error => snackebar item .verticalAlign should be "start" or "end"')),"start"!==v&&"end"!==v&&"center"!==v&&(v="center",console.error('aio-popup error => snackebar item .horizontalAlign should be "start" or "end" or "center"'));let[L,k]=r(!1);function C(){k(!1),setTimeout(()=>{a(d)},200)}o(()=>{setTimeout(()=>k(!0),0),setTimeout(()=>C(),1e3*s)},[]);let w,M,N,A;return w="aio-popup-snackebar-item-container",w+=` aio-popup-snackebar-item-container-horizontal-align-${v}`,L&&(w+=" mounted"),l&&(w+=" rtl"),M=function t(e){let i=h(".aio-popup-snackebar-item-container"),o={start:12,end:12};for(let r=0;r<e;r++){let a=i.eq(r),n=a.height()+6,l=a.attr("data-vertical-align");o[l]+=n}return{["start"===g?"top":"bottom"]:o[g]}}(n),N={"data-vertical-align":g,className:w,style:M,onClick:!1===f?void 0:()=>C()},_("div",{...N,children:(A="aio-popup-snackebar-item",A+=` aio-popup-snackebar-item-${c}`,y.className&&(A+=` ${y.className}`),m("div",{...{...y,className:A,style:y.style},children:[_("div",{className:"aio-popup-snackebar-item-icon",children:b||("error"===(e=c)||"warning"===e||"info"===e?_("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:_("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",style:{fill:"currentcolor"}})}):_("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:_("path",{d:"M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z",style:{fill:"currentcolor"}})}))})," ",m("div",{className:"aio-popup-snackebar-item-text",children:[_("div",{className:"aio-popup-snackebar-item-uptext",children:p}),!!u&&_("div",{className:"aio-popup-snackebar-item-subtext",children:u})]})," ",$&&$.text?_("button",{className:"aio-popup-snackebar-item-action",onClick(t){t.stopPropagation(),$&&$.onClick(),C()},children:$.text}):null," ",_("div",{className:"aio-popup-snackebar-bar",style:{transition:`${s}s linear`}})," "]}))})}function Align(t){let{dom:e,target:i,fitHorizontal:o,fixStyle:r=t=>t,attrs:a={},pageSelector:n,rtl:l,limitTo:s}=t,d={getDomLimit(t,e){let i=t.offset(),o=i.left-window.pageXOffset,r=i.top-window.pageYOffset;if(n&&"page"!==e){let a=h(n);try{let{left:l,top:s}=a.offset()||{left:0,top:0};l-=window.scrollX,s-=window.scrollY,o-=l,r-=s}catch{}}let d=t.outerWidth(),p=t.outerHeight(),c=o+d,u=r+p;return{left:o,top:r,right:c,bottom:u,width:d,height:p}},getPageLimit(){let t=n?h(n):void 0;t=Array.isArray(t)&&0===t.length?void 0:t;let e=window.innerWidth,i=window.innerHeight,o=t?d.getDomLimit(t,"page"):{left:0,top:0,right:e,bottom:i};return o.left<0&&(o.left=0),o.right>e&&(o.right=e),o.top<0&&(o.top=0),o.bottom>i&&(o.bottom=i),o},getRelatedToLmit(){if(!s)return;let t=e.parents(s);if(!t.length)return;let i=t.offset(),o=i.left-window.pageXOffset,r=i.top-window.pageYOffset,a=t.outerWidth(),n=t.outerHeight();return{left:o,top:r,right:o+a,bottom:r+n,width:a,height:n}},align(){let t=d.getPageLimit(),n=d.getDomLimit(i,"target"),s=d.getDomLimit(e,"popover"),p;if(s.top=n.bottom,s.bottom=s.top+s.height,o)s.width=n.width,s.left=n.left,s.right=n.left+n.width;else{let c=d.getRelatedToLmit()||t;l?(s.right=n.right,s.left=s.right-s.width,s.left<c.left&&(s.left=c.left)):(s.left=n.left,s.right=s.left+s.width,s.right>c.right&&(s.left=c.right-s.width))}return s.bottom>t.bottom?s.height>n.top-t.top?s.top=t.bottom-s.height:s.top=n.top-s.height:s.top=n.bottom,s.height>t.bottom-t.top&&(s.top=6,s.bottom=void 0,s.height=t.bottom-t.top-12,p="auto"),r({left:s.left,top:s.top,width:s.width,overflowY:p,...a.style},{targetLimit:n,pageLimit:t})}};return d.align()}let Highlight=s((t,e)=>{let[i,o]=r(!1),[a,n]=r({Left:0,Top:0,Width:0,Height:0,TopSpace:0,BottomSpace:0}),s=l(),p=s.current,c=l(a);function h(t){let e=k("padding",6),i=t.offset(),o=i.left-window.pageXOffset,r=i.top-window.pageYOffset,a=window.innerHeight,n=t.outerWidth(),l=t.outerHeight();return{Left:o-1*e,Top:r-1*e,Width:n+2*e,Height:l+2*e,TopSpace:r,BottomSpace:a-(r+l)}}function f(){let t=k("easing",void 0);var e=["linear","easeInQuad","easeInSine","easeInCirc","easeInBack","easeOutQuad","easeOutSine","easeOutCirc","easeInOutQuad","easeInOutSine","easeInOutBack","easeOutBounce"];return"number"==typeof t?e[t]||e[0]:t}function g(){n({Left:0,Top:0,Width:0,Height:0,TopSpace:0,BottomSpace:0}),o(!1)}function v(t){let{dom:e}=t;s.current=t,o(!0),setTimeout(()=>{try{let t=k("duration",1200);e[0].scrollIntoView();let i=h(e),o=f(),r={...i,targets:[{...c.current}],duration:t,update(t){let{animatables:e}=t;n({...e[0].target})}};o&&(r.easing=o),u(r)}catch{alert(`
16
- aio-highlighter error => connot find dom
17
- `)}},0)}function b(t){return _("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 512 512",...t,children:m("g",{children:[_("path",{d:"M242.1,45.2c7.7-7.7,20.2-7.7,27.8-0.1l0.1,0.1l236.3,236.3c7.7,7.7,7.7,20.2,0,27.9c-7.7,7.7-20.2,7.7-27.9,0 L256,86.9L33.7,309.3c-7.7,7.7-20.2,7.7-27.9,0c-7.7-7.7-7.7-20.2,0-27.9L242.1,45.2z"}),_("path",{d:"M242.1,202.7c7.7-7.7,20.2-7.7,27.8-0.1l0.1,0.1L506.2,439c7.7,7.7,7.7,20.2,0,27.9c-7.7,7.7-20.2,7.7-27.9,0 L256,244.5L33.7,466.9c-7.7,7.7-20.2,7.7-27.9,0c-7.7-7.7-7.7-20.2,0-27.9L242.1,202.7z"})]})})}function y(t,e,i){return _("div",{className:"aio-popup-highlight-arrow",children:b({width:24,height:24,style:{position:"absolute",height:24,width:24,left:e+i/2-12},className:`aio-popup-highlight-arrow-${t}`})})}function L(t){if(!p||!p.html)return"";let e,i=p.html||"",o=_("div",{className:"aio-popup-highlight-space"}),r=_("div",{className:"aio-popup-highlight-html",children:i}),a=y(t,c.current.Left,c.current.Width);return e="top"===t?m($,{children:[o,r,a]}):m($,{children:[a,r,o]}),_("div",{className:"aio-popup-highlight-html-container",children:e})}function k(t,e){if(!p||null===p)return e;let i=p[t];return void 0===i?e:i}function C(){!k("mouseAccess",!1)&&null!=p&&p.onClick&&p.onClick()}function w(t){let e="",i=0,o="aio-popup-highlight-mask",r=c.current;return"top"===t?(i=r.Top,r.TopSpace>r.BottomSpace&&(e=L("top"))):"bottom"===t?(o+=" aio-popup-highlight-mask-flex",r.TopSpace<=r.BottomSpace&&(e=L("bottom"))):"left"===t?i=r.Left:o+=" aio-popup-highlight-mask-flex",_("div",{className:o,style:{["top"===t||"bottom"===t?"height":"width"]:i},onClick:()=>C(),children:e})}function M(){let t=k("mouseAccess",!1);return _("div",{style:{width:a.Width},className:"aio-popup-highlight-focus-container",onClick:t?void 0:()=>C(),children:_("div",{className:"aio-popup-highlight-focus"})})}function N(){return m("div",{className:"aio-popup-highlight-main",style:{height:a.Height},children:[w("left"),M(),w("right")]})}if(c.current=a,d(e,()=>({addHighlight:v,removeHighlight:g})),!i)return null;function A(){let t=k("mouseAccess",!1);return{pointerEvents:t?"none":"all"}}let x=AddToAttrs(k("attrs",{}),{className:"aio-popup-highlight",style:A()});return m("div",{...x,children:[w("top"),N(),w("bottom")]})}),CloseIcon=()=>_("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:_("path",{d:"M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",style:{fill:"currentcolor"}})});function AddToAttrs(t,e){let{style:i}=e,o,r=[...(t=t||{}).className?t.className.split(" "):[],...(e.className?Array.isArray(e.className)?e.className:e.className.split(" "):[]).filter(t=>!!t)],a=r.length?r.join(" "):void 0,n={...t.style,...i};return{...t,className:a,style:n,...e.attrs}}
15
+ `,close(){c.toggleClass(!1),setTimeout(()=>{"function"==typeof p&&p(),!1!==p&&s("."+c.id).remove()},200)},getIcon:()=>!1===e?"":e||({error:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"></path></svg>',warning:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12,2L1,21H23M12,6L19.53,19H4.47M11,10V14H13V10M11,16V18H13V16"></path></svg>',info:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z"></path></svg>',success:'<svg viewBox="0 0 24 24" role="presentation" style="width: 4.5rem; height: 4.5rem;"><path d="M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z"></path></svg>'})[o]||"",startTimer(){setTimeout(()=>{if(c.time>=100){c.time=100,c.close();return}c.time+=2,c.updateBarRender(),c.startTimer()},a/50*1e3)},toggleClass(t){let e=s(`.${c.id}`);t?setTimeout(()=>e.removeClass("not-mounted"),0):e.addClass("not-mounted")},render(){s("body").append(c.getRender()),s("button."+c.id).off("click",c.close),s("button."+c.id).on("click",c.close),c.toggleClass(!0)}};c.id=c.getId(),c.render(),a&&c.startTimer()}let Highlight=({highlight:t})=>{let[i,r]=o({Left:0,Top:0,Width:0,Height:0,TopSpace:0,BottomSpace:0}),n=a(i);function l(t){return p("svg",{version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 512 512",...t,children:u("g",{children:[p("path",{d:"M242.1,45.2c7.7-7.7,20.2-7.7,27.8-0.1l0.1,0.1l236.3,236.3c7.7,7.7,7.7,20.2,0,27.9c-7.7,7.7-20.2,7.7-27.9,0 L256,86.9L33.7,309.3c-7.7,7.7-20.2,7.7-27.9,0c-7.7-7.7-7.7-20.2,0-27.9L242.1,45.2z"}),p("path",{d:"M242.1,202.7c7.7-7.7,20.2-7.7,27.8-0.1l0.1,0.1L506.2,439c7.7,7.7,7.7,20.2,0,27.9c-7.7,7.7-20.2,7.7-27.9,0 L256,244.5L33.7,466.9c-7.7,7.7-20.2,7.7-27.9,0c-7.7-7.7-7.7-20.2,0-27.9L242.1,202.7z"})]})})}function s(t,e,o){return p("div",{className:"aio-popup-highlight-arrow",children:l({width:24,height:24,style:{position:"absolute",height:24,width:24,left:e+o/2-12},className:`aio-popup-highlight-arrow-${t}`})})}function _(e){if(!t.html)return"";let o,i=t.html||"",r=p("div",{className:"aio-popup-highlight-space"}),a=p("div",{className:"aio-popup-highlight-html",children:i}),l=s(e,n.current.Left,n.current.Width);return o="top"===e?u(c,{children:[r,a,l]}):u(c,{children:[l,a,r]}),p("div",{className:"aio-popup-highlight-html-container",children:o})}function h(){!t.mouseAccess&&t.onClick&&t.onClick()}function $(t){let e="",o=0,i="aio-popup-highlight-mask",r=n.current;return"top"===t?(o=r.Top,r.TopSpace>r.BottomSpace&&(e=_("top"))):"bottom"===t?(i+=" aio-popup-highlight-mask-flex",r.TopSpace<=r.BottomSpace&&(e=_("bottom"))):"left"===t?o=r.Left:i+=" aio-popup-highlight-mask-flex",p("div",{className:i,style:{["top"===t||"bottom"===t?"height":"width"]:o},onClick:()=>h(),children:e})}function m(){return p("div",{style:{width:i.Width},className:"aio-popup-highlight-focus-container",onClick:h,children:p("div",{className:"aio-popup-highlight-focus"})})}function g(){return u("div",{className:"aio-popup-highlight-main",style:{height:i.Height},children:[$("left"),m(),$("right")]})}function f(){return{pointerEvents:t.mouseAccess?"none":"all"}}n.current=i,e(()=>{setTimeout(()=>{try{let{dom:e,duration:o=1200}=t;e[0].scrollIntoView();let i=getHLLimit(t),a=getEasing(t),l={...i,targets:[{...n.current}],duration:o,update(t){let{animatables:e}=t;r({...e[0].target})}};a&&(l.easing=a),d(l)}catch{alert("aio-highlighter error => connot find dom")}},0)});let v=AddToAttrs(t.attrs,{className:"aio-popup-highlight",style:f()});return u("div",{...v,children:[$("top"),g(),$("bottom")]})};function getHLLimit(t){let{padding:e=6,dom:o}=t,i=o.offset(),r=i.left-window.pageXOffset,a=i.top-window.pageYOffset,n=window.innerHeight,l=o.outerWidth(),d=o.outerHeight();return{Left:r-1*e,Top:a-1*e,Width:l+2*e,Height:d+2*e,TopSpace:a,BottomSpace:n-(a+d)}}function getEasing(t){let{easing:e}=t;var o=["linear","easeInQuad","easeInSine","easeInCirc","easeInBack","easeOutQuad","easeOutSine","easeOutCirc","easeInOutQuad","easeInOutSine","easeInOutBack","easeOutBounce"];return"number"==typeof e?o[e]||o[0]:e}let InfoSvg=()=>p("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:p("path",{d:"M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M11,17H13V11H11V17Z",style:{fill:"currentcolor"}})}),SuccessSvg=()=>p("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:p("path",{d:"M12 2C6.5 2 2 6.5 2 12S6.5 22 12 22 22 17.5 22 12 17.5 2 12 2M12 20C7.59 20 4 16.41 4 12S7.59 4 12 4 20 7.59 20 12 16.41 20 12 20M16.59 7.58L10 14.17L7.41 11.59L6 13L10 17L18 9L16.59 7.58Z",style:{fill:"currentcolor"}})});function getBound(t){try{let e=t.getBoundingClientRect();return{width:e.width,height:e.height,left:e.left,top:e.top,bottom:e.bottom,right:e.right}}catch{return{width:0,height:0,left:0,top:0,bottom:0,right:0}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aio-popup",
3
- "version": "4.5.2",
3
+ "version": "5.0.0",
4
4
  "description": "handle all types of popup and modals in react",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,8 +12,6 @@
12
12
  "url": "git+https://github.com/mohammadFeiz/aio-popup.git"
13
13
  },
14
14
  "dependencies": {
15
- "@mdi/js": "^7.0.96",
16
- "@mdi/react": "^1.6.1",
17
15
  "jquery": "^3.6.1",
18
16
  "animejs": "^3.2.1"
19
17
  },
package/theme2.css ADDED
@@ -0,0 +1,139 @@
1
+ :root {
2
+ --aio-popup-theme2-color: #00b1f2;
3
+ }
4
+
5
+ .aio-popup-theme-container2 .aio-popup {
6
+ border-radius: 24px;
7
+ overflow: hidden;
8
+ }
9
+
10
+ .aio-popup-theme-container2 .aio-popup-alert-footer {
11
+ justify-content: center;
12
+ padding: 24px;
13
+ height: unset;
14
+ }
15
+
16
+ .aio-popup-theme-container2 .aio-popup-alert-footer button {
17
+ border-radius: 24px;
18
+ height: 36px;
19
+ width: 100%;
20
+ }
21
+
22
+ .aio-popup-theme-container2 .aio-popup-alert-text {
23
+ font-size: 20px;
24
+ padding: 12px;
25
+ }
26
+
27
+ .aio-popup-theme-container2 .aio-popup-alert-header {
28
+ display: none;
29
+ }
30
+
31
+ .aio-popup-theme-container2 .aio-popup-alert-error .aio-popup-alert-text {
32
+ color: #f14747;
33
+ }
34
+
35
+ .aio-popup-theme-container2 .aio-popup-alert-error .aio-popup-time-bar {
36
+ background: #f14747;
37
+ }
38
+
39
+ .aio-popup-theme-container2 .aio-popup-alert-error .aio-popup-alert-footer button {
40
+ background: #f14747;
41
+ }
42
+
43
+ .aio-popup-theme-container2 .aio-popup-alert-warning .aio-popup-alert-text {
44
+ color: #ff7800;
45
+ }
46
+
47
+ .aio-popup-theme-container2 .aio-popup-alert-warning .aio-popup-time-bar {
48
+ background: #ff7800;
49
+ }
50
+
51
+ .aio-popup-theme-container2 .aio-popup-alert-warning .aio-popup-alert-footer button {
52
+ background: #ff7800;
53
+ }
54
+
55
+ .aio-popup-theme-container2 .aio-popup-alert-success .aio-popup-alert-text {
56
+ color: #6EBC3D;
57
+ }
58
+
59
+ .aio-popup-theme-container2 .aio-popup-alert-success .aio-popup-time-bar {
60
+ background: #6EBC3D;
61
+ }
62
+
63
+ .aio-popup-theme-container2 .aio-popup-alert-success .aio-popup-alert-footer button {
64
+ background: #6EBC3D;
65
+ }
66
+
67
+ .aio-popup-theme-container2 .aio-popup-alert-info .aio-popup-alert-text {
68
+ color: var(--aio-popup-theme2-color);
69
+ }
70
+
71
+ .aio-popup-theme-container2 .aio-popup-alert-info .aio-popup-time-bar {
72
+ background: var(--aio-popup-theme2-color);
73
+ }
74
+
75
+ .aio-popup-theme-container2 .aio-popup-alert-info .aio-popup-alert-footer button {
76
+ background: var(--aio-popup-theme2-color);
77
+ }
78
+
79
+ .aio-popup-theme-container2 .aio-popup-confirm {
80
+ border-radius: 24px;
81
+ }
82
+
83
+ .aio-popup-theme-container2 .aio-popup-footer {
84
+ padding: 24px;
85
+ padding-top: 12px;
86
+ border-top: none;
87
+ gap: 6px;
88
+ }
89
+
90
+ .aio-popup-theme-container2 .aio-popup-footer button {
91
+ height: 36px;
92
+ border: none;
93
+ color: var(--aio-popup-theme2-color);
94
+ background: #f1ebed;
95
+ padding: 0 36px;
96
+ border-radius: 24px;
97
+ }
98
+
99
+ .aio-popup-theme-container2 .aio-popup-footer button.active {
100
+ height: 36px;
101
+ border: none;
102
+ color: #fff;
103
+ background: var(--aio-popup-theme2-color);
104
+ padding: 0 36px;
105
+ border-radius: 24px;
106
+ }
107
+
108
+ .aio-popup-theme-container2 .aio-popup-body {
109
+ justify-content: center;
110
+ display: flex;
111
+ color: #000;
112
+ }
113
+
114
+ .aio-popup-theme-container2 .aio-popup-header-close-button {
115
+ display: none;
116
+ }
117
+
118
+ .aio-popup-theme-container2 .aio-popup-header {
119
+ border-bottom: none;
120
+ color: var(--aio-popup-theme2-color);
121
+ font-size: 18px;
122
+ font-weight: bold;
123
+ }
124
+
125
+ .aio-popup-theme-container2 .aio-popup-header-title {
126
+ justify-content: center;
127
+ padding: 8px;
128
+ padding-bottom: 0px;
129
+ }
130
+
131
+ .aio-popup-theme-container2 .aio-popup-prompt textarea {
132
+ border: 1px solid #ddd !important;
133
+ }
134
+
135
+ .aio-popup-theme-container2 .aio-popup-snackebar-item {
136
+ background: #fff;
137
+ border-radius: 24px;
138
+ color: #000;
139
+ }