aio-popup 6.0.0 → 6.0.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.css +2 -3
- package/index.d.ts +3 -2
- package/index.js +10 -792
- package/package.json +1 -1
package/index.css
CHANGED
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
overflow-y: auto;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
.aio-popup-alert-
|
|
356
|
+
.aio-popup-alert-title {
|
|
357
357
|
display: flex;
|
|
358
358
|
align-items: center;
|
|
359
359
|
justify-content: center;
|
|
@@ -362,9 +362,8 @@
|
|
|
362
362
|
margin-bottom: 12px;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
.aio-popup-alert-
|
|
365
|
+
.aio-popup-alert-text {
|
|
366
366
|
font-size: 12px;
|
|
367
|
-
|
|
368
367
|
}
|
|
369
368
|
|
|
370
369
|
.aio-popup-alert-footer {
|
package/index.d.ts
CHANGED
|
@@ -33,10 +33,11 @@ export type AP_modal = {
|
|
|
33
33
|
setAttrs?: AP_setAttrs;
|
|
34
34
|
};
|
|
35
35
|
export type AP_alert = {
|
|
36
|
+
align?: 'left' | 'right' | 'center';
|
|
36
37
|
icon?: false | ReactNode;
|
|
37
38
|
type: 'success' | 'error' | 'warning' | 'info';
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
title?: ReactNode;
|
|
40
|
+
text: string;
|
|
40
41
|
time?: number;
|
|
41
42
|
className?: string;
|
|
42
43
|
closeText?: string;
|
package/index.js
CHANGED
|
@@ -1,803 +1,21 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
12
|
-
import { createRef, useEffect, useState, createContext, useContext, useRef } from 'react';
|
|
13
|
-
import * as ReactDOMServer from 'react-dom/server';
|
|
14
|
-
import ReactDOM from 'react-dom';
|
|
15
|
-
import anime from "animejs/lib/anime.es.js";
|
|
16
|
-
import $ from 'jquery';
|
|
17
|
-
import './index.css';
|
|
18
|
-
const CTX = createContext({});
|
|
19
|
-
function Align(p) {
|
|
20
|
-
let { modal, target, fitHorizontal, rtl, limitTo } = p;
|
|
21
|
-
const bodyWidth = window.innerWidth, bodyHeight = window.innerHeight;
|
|
22
|
-
let pageLimit = { left: 0, top: 0, bottom: bodyHeight, right: bodyWidth, width: bodyWidth, height: bodyHeight };
|
|
23
|
-
let targetLimit = getBound(target[0]);
|
|
24
|
-
let domLimit = getBound(modal[0]);
|
|
25
|
-
targetLimit = Object.assign({}, targetLimit);
|
|
26
|
-
domLimit = Object.assign({}, domLimit);
|
|
27
|
-
let overflowY;
|
|
28
|
-
domLimit.top = targetLimit.bottom;
|
|
29
|
-
domLimit.bottom = domLimit.top + domLimit.height;
|
|
30
|
-
if (fitHorizontal) {
|
|
31
|
-
domLimit.width = targetLimit.width;
|
|
32
|
-
domLimit.left = targetLimit.left;
|
|
33
|
-
domLimit.right = targetLimit.left + targetLimit.width;
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
if (limitTo) {
|
|
37
|
-
let elem = modal.parents(limitTo);
|
|
38
|
-
if (elem.length) {
|
|
39
|
-
pageLimit = getBound(elem[0]);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
//اگر راست به چپ باید باشد
|
|
43
|
-
if (rtl) {
|
|
44
|
-
//راست المان را با راست هدف ست کن
|
|
45
|
-
domLimit.right = targetLimit.right;
|
|
46
|
-
//چپ المان را بروز رسانی کن
|
|
47
|
-
domLimit.left = domLimit.right - domLimit.width;
|
|
48
|
-
//اگر المان از سمت چپ از صفحه بیرون زد سمت چپ المان را با سمت چپ صفحه ست کن
|
|
49
|
-
if (domLimit.left < pageLimit.left) {
|
|
50
|
-
domLimit.left = pageLimit.left;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
//چپ المان را با چپ هدف ست کن
|
|
55
|
-
domLimit.left = targetLimit.left;
|
|
56
|
-
//راست المان را بروز رسانی کن
|
|
57
|
-
domLimit.right = domLimit.left + domLimit.width;
|
|
58
|
-
//اگر المان از سمت راست صفحه بیرون زد سمت چپ المان را با پهنای المان ست کن
|
|
59
|
-
if (domLimit.right > pageLimit.right) {
|
|
60
|
-
domLimit.left = pageLimit.right - domLimit.width;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
//اگر المان از سمت پایین صفحه بیرون زد
|
|
65
|
-
if (domLimit.bottom > pageLimit.bottom) {
|
|
66
|
-
if (domLimit.height > targetLimit.top - pageLimit.top) {
|
|
67
|
-
domLimit.top = pageLimit.bottom - domLimit.height;
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
domLimit.top = targetLimit.top - domLimit.height;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
domLimit.top = targetLimit.bottom;
|
|
75
|
-
}
|
|
76
|
-
if (domLimit.height > pageLimit.height) {
|
|
77
|
-
domLimit.top = pageLimit.top;
|
|
78
|
-
domLimit.height = pageLimit.height;
|
|
79
|
-
overflowY = 'auto';
|
|
80
|
-
}
|
|
81
|
-
return { left: domLimit.left, top: domLimit.top, width: domLimit.width, overflowY, maxWidth: pageLimit.width };
|
|
82
|
-
}
|
|
83
|
-
const CloseIcon = () => {
|
|
84
|
-
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.2rem', height: '1.2rem' }, children: _jsx("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' } }) }));
|
|
85
|
-
};
|
|
86
|
-
function AddToAttrs(attrs, p) {
|
|
87
|
-
attrs = attrs || {};
|
|
88
|
-
let { style } = p;
|
|
89
|
-
let attrClassName = attrs.className ? attrs.className.split(' ') : [];
|
|
90
|
-
let className = p.className ? (Array.isArray(p.className) ? p.className : p.className.split(' ')) : [];
|
|
91
|
-
let classNames = [...attrClassName, ...className.filter((o) => !!o)];
|
|
92
|
-
let newClassName = classNames.length ? classNames.join(' ') : undefined;
|
|
93
|
-
let newStyle = Object.assign(Object.assign({}, attrs.style), style);
|
|
94
|
-
return Object.assign(Object.assign(Object.assign({}, attrs), { className: newClassName, style: newStyle }), p.attrs);
|
|
95
|
-
}
|
|
96
|
-
const usePopup = (props) => {
|
|
97
|
-
let [modals, setModals] = useState([]);
|
|
98
|
-
const promptTexts = useRef({});
|
|
99
|
-
let modalsRef = useRef(modals);
|
|
100
|
-
modalsRef.current = modals;
|
|
101
|
-
const getModals = () => modalsRef.current;
|
|
102
|
-
const [snackebarItems, setSnackebarItems] = useState([]);
|
|
103
|
-
const snackebarItemsRef = useRef(snackebarItems);
|
|
104
|
-
snackebarItemsRef.current = snackebarItems;
|
|
105
|
-
const [highlight, setHighlight] = useState();
|
|
106
|
-
const addModal = (o) => {
|
|
107
|
-
if (o.id === undefined) {
|
|
108
|
-
o.id = 'popup' + Math.round(Math.random() * 1000000);
|
|
109
|
-
}
|
|
110
|
-
let newModal = o;
|
|
111
|
-
setModals(prevModals => {
|
|
112
|
-
let newModals = prevModals.filter(({ id }) => id !== o.id);
|
|
113
|
-
return [...newModals, newModal];
|
|
114
|
-
});
|
|
115
|
-
};
|
|
116
|
-
const removeModal = (arg) => __awaiter(void 0, void 0, void 0, function* () {
|
|
117
|
-
if (typeof arg !== 'string') {
|
|
118
|
-
arg = 'last';
|
|
119
|
-
}
|
|
120
|
-
if (arg === 'all') {
|
|
121
|
-
setModals([]);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (!modalsRef.current.length) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (arg === 'last') {
|
|
128
|
-
arg = modalsRef.current[modalsRef.current.length - 1].id;
|
|
129
|
-
}
|
|
130
|
-
let modal = modalsRef.current.find((o) => o.id === arg);
|
|
131
|
-
if (!modal) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
$(`[data-id=${arg}]`).addClass('not-mounted');
|
|
135
|
-
setTimeout(() => {
|
|
136
|
-
if (modal && typeof modal.onClose === 'function') {
|
|
137
|
-
modal.onClose();
|
|
138
|
-
}
|
|
139
|
-
setModals(prevModals => prevModals.filter((o) => o.id !== arg));
|
|
140
|
-
}, 300);
|
|
141
|
-
});
|
|
142
|
-
const addSnackebar = (item) => {
|
|
143
|
-
let items = snackebarItemsRef.current;
|
|
144
|
-
let newItems = [...items, Object.assign(Object.assign({}, item), { id: 'a' + Math.round(Math.random() * 1000000000) })];
|
|
145
|
-
setSnackebarItems(newItems);
|
|
146
|
-
};
|
|
147
|
-
const removeSnackebar = (id) => {
|
|
148
|
-
const items = snackebarItemsRef.current;
|
|
149
|
-
const item = items.find((o) => o.id === id);
|
|
150
|
-
if (!item || item.onClose === false) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
let newItems = items.filter((o, i) => o.id !== id);
|
|
154
|
-
setSnackebarItems(newItems);
|
|
155
|
-
if (typeof item.onClose === 'function') {
|
|
156
|
-
item.onClose();
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const addAlert = (obj) => Alert(obj);
|
|
160
|
-
const addHighlight = (highlight) => setHighlight(highlight);
|
|
161
|
-
const removeHighlight = () => setHighlight(undefined);
|
|
162
|
-
const addConfirm = (obj) => {
|
|
163
|
-
let { title, subtitle, submitText = 'Yes', canselText = 'No', onSubmit, onCansel = () => { }, setAttrs = () => { return {}; } } = obj;
|
|
164
|
-
let config = {
|
|
165
|
-
position: 'center',
|
|
166
|
-
setAttrs: (key) => {
|
|
167
|
-
let attrs = setAttrs(key);
|
|
168
|
-
if (key === 'modal') {
|
|
169
|
-
return AddToAttrs(attrs, { className: 'aio-popup-confirm' });
|
|
170
|
-
}
|
|
171
|
-
return attrs;
|
|
172
|
-
},
|
|
173
|
-
header: { title, subtitle },
|
|
174
|
-
body: _jsx(_Fragment, { children: "text" }),
|
|
175
|
-
footer: (_jsxs(_Fragment, { children: [_jsx("button", { type: 'button', onClick: () => { onCansel(); removeModal(); }, children: canselText }), _jsx("button", { type: 'button', className: 'active', onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
176
|
-
if (!onSubmit) {
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
let res = yield onSubmit();
|
|
180
|
-
if (res !== false) {
|
|
181
|
-
removeModal();
|
|
182
|
-
}
|
|
183
|
-
}), children: submitText })] }))
|
|
184
|
-
};
|
|
185
|
-
addModal(config);
|
|
186
|
-
};
|
|
187
|
-
const addPrompt = (obj) => {
|
|
188
|
-
const id = 'a' + (Math.round(Math.random() * 100000));
|
|
189
|
-
let { title, subtitle, submitText = 'Submit', canselText = 'close', onSubmit, onCansel = () => { }, setAttrs = () => { return {}; } } = obj;
|
|
190
|
-
let config = {
|
|
191
|
-
position: 'center',
|
|
192
|
-
setAttrs: (key) => {
|
|
193
|
-
let attrs = setAttrs(key);
|
|
194
|
-
if (key === 'modal') {
|
|
195
|
-
return AddToAttrs(attrs, { className: 'aio-popup-prompt' });
|
|
196
|
-
}
|
|
197
|
-
return attrs;
|
|
198
|
-
},
|
|
199
|
-
header: { title, subtitle },
|
|
200
|
-
body: _jsx(Prompt, { change: (value) => promptTexts.current = Object.assign(Object.assign({}, promptTexts.current), { [id]: value }) }),
|
|
201
|
-
footer: (_jsxs(_Fragment, { children: [_jsx("button", { type: 'button', onClick: () => { onCansel(); removeModal(); }, children: canselText }), _jsx("button", { type: 'button', className: 'active', onClick: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
202
|
-
if (!onSubmit) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
const value = promptTexts.current[id];
|
|
206
|
-
let res = yield onSubmit(value);
|
|
207
|
-
if (res !== false) {
|
|
208
|
-
removeModal();
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
const newPromptTexts = {};
|
|
212
|
-
for (let prop in promptTexts.current) {
|
|
213
|
-
if (prop !== id) {
|
|
214
|
-
newPromptTexts[prop] = promptTexts.current[prop];
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
promptTexts.current = newPromptTexts;
|
|
218
|
-
}
|
|
219
|
-
}), disabled: !promptTexts.current[id], children: submitText })] }))
|
|
220
|
-
};
|
|
221
|
-
addModal(config);
|
|
222
|
-
};
|
|
223
|
-
const getContext = () => {
|
|
224
|
-
return {
|
|
225
|
-
rtl: !!props && !!props.rtl,
|
|
226
|
-
snackebarItems: snackebarItemsRef.current,
|
|
227
|
-
removeSnackebar, removeModal
|
|
228
|
-
};
|
|
229
|
-
};
|
|
230
|
-
const render = (caller) => {
|
|
231
|
-
return (_jsxs(CTX.Provider, { value: getContext(), children: [modalsRef.current.map((modal, i) => {
|
|
232
|
-
return (_jsx(Popup, { modal: modal, isLast: i === modalsRef.current.length - 1, renderCaller: caller }, modal.id));
|
|
233
|
-
}), snackebarItems.map((item, i) => _jsx(SnackebarItem, { item: item, index: i }, item.id)), !!highlight && _jsx(Highlight, { highlight: highlight })] }));
|
|
234
|
-
};
|
|
235
|
-
const portal = () => ReactDOM.createPortal(render(), document.body);
|
|
236
|
-
return { addAlert, addSnackebar, removeModal, addModal, getModals, addHighlight, removeHighlight, render, addConfirm, addPrompt, portal };
|
|
237
|
-
};
|
|
238
|
-
export default usePopup;
|
|
239
|
-
const Prompt = ({ change }) => {
|
|
240
|
-
const [text, setText] = useState('');
|
|
241
|
-
return (_jsx("textarea", { placeholder: text, value: text, onChange: (e) => { const value = e.target.value; setText(value); change(value); } }));
|
|
242
|
-
};
|
|
243
|
-
const POPUPCTX = createContext({});
|
|
244
|
-
const Popup = ({ modal, isLast, renderCaller }) => {
|
|
245
|
-
const mainContext = useContext(CTX);
|
|
246
|
-
let { setAttrs = () => { return {}; }, id, position = 'fullscreen', getTarget } = modal;
|
|
247
|
-
let [temp] = useState({ dom: createRef(), backdropDom: createRef(), dui: undefined });
|
|
248
|
-
let [popoverStyle, setPopoverStyle] = useState({});
|
|
249
|
-
let modalMouseDown = useRef(false);
|
|
250
|
-
//bar taraf kardane moshkele mozakhrafe click rooye backdrop ke az har ja mouse ro roosh vel mikoni modal baste mishe
|
|
251
|
-
const isModalMouseDown = () => modalMouseDown.current;
|
|
252
|
-
let [state, setState] = useState(modal.state);
|
|
253
|
-
let attrs = setAttrs('modal') || {};
|
|
254
|
-
const firstMount = useRef(false);
|
|
255
|
-
useEffect(() => () => { $(window).unbind('click', handleBackClick); });
|
|
256
|
-
useEffect(() => {
|
|
257
|
-
if (position === 'popover') {
|
|
258
|
-
setPopoverStyle(getPopoverStyle());
|
|
259
|
-
}
|
|
260
|
-
if (getTarget) {
|
|
261
|
-
temp.dui = 'a' + (Math.round(Math.random() * 10000000));
|
|
262
|
-
let target = getTarget();
|
|
263
|
-
target.attr('data-id', temp.dui);
|
|
264
|
-
}
|
|
265
|
-
setTimeout(() => {
|
|
266
|
-
let popup = $(temp.dom.current);
|
|
267
|
-
popup.removeClass('not-mounted');
|
|
268
|
-
$(temp.backdropDom.current).removeClass('not-mounted');
|
|
269
|
-
popup.focus();
|
|
270
|
-
}, 0);
|
|
271
|
-
$(window).unbind('click', handleBackClick);
|
|
272
|
-
$(window).bind('click', handleBackClick);
|
|
273
|
-
}, []);
|
|
274
|
-
function handleBackClick(e) {
|
|
275
|
-
//در مود پاپاور اگر هر جایی غیر از اینپوت و پاپاور کلیک شد پاپاپ رو ببند
|
|
276
|
-
if (!temp.dui) {
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
let target = $(e.target);
|
|
280
|
-
if (position !== 'popover' || target.attr('data-id') === temp.dui || target.parents(`[data-id=${temp.dui}]`).length) {
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
mainContext.removeModal();
|
|
284
|
-
}
|
|
285
|
-
function getModalProps() {
|
|
286
|
-
let style = Object.assign(Object.assign({}, popoverStyle), attrs.style);
|
|
287
|
-
let ev = "ontouchstart" in document.documentElement ? 'onTouchStart' : 'onMouseDown';
|
|
288
|
-
return Object.assign(Object.assign({}, attrs), { ref: temp.dom, "data-id": modal.id, tabIndex: 0, onKeyDown, [ev]: mouseDown, className: getClassName(), style: Object.assign({}, style), onClick: (e) => { e.stopPropagation(); } });
|
|
289
|
-
}
|
|
290
|
-
function getPopoverStyle() {
|
|
291
|
-
if (!getTarget) {
|
|
292
|
-
return {};
|
|
293
|
-
}
|
|
294
|
-
let target = getTarget();
|
|
295
|
-
if (!target || !target.length) {
|
|
296
|
-
return {};
|
|
297
|
-
}
|
|
298
|
-
let p = { modal: $(temp.dom.current), target, fitHorizontal: modal.fitHorizontal, limitTo: modal.limitTo, attrs, rtl: mainContext.rtl };
|
|
299
|
-
let style = Align(p);
|
|
300
|
-
let res = Object.assign(Object.assign({}, style), { position: 'absolute' });
|
|
301
|
-
return res;
|
|
302
|
-
}
|
|
303
|
-
function onKeyDown(e) {
|
|
304
|
-
if (!isLast) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
let code = e.keyCode;
|
|
308
|
-
if (code === 27) {
|
|
309
|
-
mainContext.removeModal();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
function mouseUp() {
|
|
313
|
-
setTimeout(() => modalMouseDown.current = false, 0);
|
|
314
|
-
}
|
|
315
|
-
function mouseDown(e) {
|
|
316
|
-
modalMouseDown.current = true;
|
|
317
|
-
$(window).unbind('mouseup', mouseUp);
|
|
318
|
-
$(window).bind('mouseup', mouseUp);
|
|
319
|
-
}
|
|
320
|
-
function getClassName() {
|
|
321
|
-
let className = 'aio-popup';
|
|
322
|
-
className += mainContext.rtl ? ' rtl' : ' ltr';
|
|
323
|
-
if (firstMount) {
|
|
324
|
-
className += ' not-mounted';
|
|
325
|
-
}
|
|
326
|
-
if (attrs.className) {
|
|
327
|
-
className += ' ' + attrs.className;
|
|
328
|
-
}
|
|
329
|
-
return className;
|
|
330
|
-
}
|
|
331
|
-
const getContext = () => ({ modal, isLast, state, setState, onKeyDown });
|
|
332
|
-
return (_jsx(POPUPCTX.Provider, { value: getContext(), children: _jsx(ModalBackdrop, { firstMount: !!firstMount, backdropDom: temp.backdropDom, isModalMouseDown: isModalMouseDown, children: _jsxs("div", Object.assign({}, getModalProps(), { children: [_jsx(ModalHeader, {}), _jsx(ModalBody, {}, modal.id), _jsx(ModalFooter, {})] }), modal.id) }, modal.id) }));
|
|
333
|
-
};
|
|
334
|
-
const ModalBackdrop = ({ children, firstMount, backdropDom, isModalMouseDown }) => {
|
|
335
|
-
const { removeModal, rtl } = useContext(CTX);
|
|
336
|
-
let { modal, onKeyDown } = useContext(POPUPCTX);
|
|
337
|
-
let { setAttrs = () => { return {}; }, id, position = 'fullscreen' } = modal;
|
|
338
|
-
const [attrs] = useState(setAttrs('backdrop') || {});
|
|
339
|
-
function backClick(e) {
|
|
340
|
-
if (isModalMouseDown()) {
|
|
341
|
-
return;
|
|
342
|
-
}
|
|
343
|
-
if (e.target !== e.currentTarget) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
let target = $(e.target);
|
|
347
|
-
if (!target.hasClass('aio-popup-backdrop')) {
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
removeModal();
|
|
351
|
-
}
|
|
352
|
-
function getProps() {
|
|
353
|
-
let className = 'aio-popup-backdrop';
|
|
354
|
-
className += ` aio-popup-position-${position}`;
|
|
355
|
-
className += rtl ? ' rtl' : ' ltr';
|
|
356
|
-
if (firstMount) {
|
|
357
|
-
className += ' not-mounted';
|
|
358
|
-
}
|
|
359
|
-
return AddToAttrs(attrs, { className, attrs: { ref: backdropDom, onKeyDown, tabIndex: 0, ['data-id']: id, onClick: attrs.onClick ? attrs.onClick : backClick } });
|
|
360
|
-
}
|
|
361
|
-
return _jsx("div", Object.assign({}, getProps(), { children: children }));
|
|
362
|
-
};
|
|
363
|
-
const ModalHeader = () => {
|
|
364
|
-
const { removeModal } = useContext(CTX);
|
|
365
|
-
let { modal, state, setState } = useContext(POPUPCTX);
|
|
366
|
-
if (!modal.header) {
|
|
367
|
-
return null;
|
|
368
|
-
}
|
|
369
|
-
let { setAttrs = () => { return {}; } } = modal;
|
|
370
|
-
let attrs = setAttrs('header') || {};
|
|
371
|
-
if (typeof modal.header === 'function') {
|
|
372
|
-
return modal.header({ removeModal: removeModal, state, setState });
|
|
373
|
-
}
|
|
374
|
-
if (typeof modal.header !== 'object') {
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
return (_jsxs("div", Object.assign({}, AddToAttrs(attrs, { className: 'aio-popup-header' }), { children: [_jsx(ModalHeaderElement, { type: 'before' }, 'before'), _jsx(ModalHeaderElement, { type: 'title' }, 'title'), _jsx(ModalHeaderElement, { type: 'after' }, 'after'), _jsx(ModalClose, {})] })));
|
|
378
|
-
};
|
|
379
|
-
const ModalHeaderElement = ({ type }) => {
|
|
380
|
-
let { modal } = useContext(POPUPCTX), { header } = modal;
|
|
381
|
-
if (typeof header === 'function' || !header) {
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
|
-
if (!header[type]) {
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
|
-
return _jsx("div", { className: `aio-popup-header-${type}`, "data-subtitle": type === 'title' ? header.subtitle : undefined, children: header[type] });
|
|
388
|
-
};
|
|
389
|
-
const ModalClose = () => {
|
|
390
|
-
const { removeModal } = useContext(CTX);
|
|
391
|
-
let { modal, state, setState } = useContext(POPUPCTX), { header } = modal;
|
|
392
|
-
if (typeof header === 'function' || !header) {
|
|
393
|
-
return null;
|
|
394
|
-
}
|
|
395
|
-
if (header.onClose === false) {
|
|
396
|
-
return null;
|
|
397
|
-
}
|
|
398
|
-
return _jsx("div", { className: `aio-popup-header-close`, onClick: (e) => {
|
|
399
|
-
e.stopPropagation();
|
|
400
|
-
e.preventDefault();
|
|
401
|
-
if (typeof header.onClose === 'function') {
|
|
402
|
-
header.onClose({ state, setState });
|
|
403
|
-
}
|
|
404
|
-
else {
|
|
405
|
-
removeModal(modal.id);
|
|
406
|
-
}
|
|
407
|
-
}, children: _jsx(CloseIcon, {}) });
|
|
408
|
-
};
|
|
409
|
-
const ModalBody = () => {
|
|
410
|
-
const { modal } = useContext(POPUPCTX);
|
|
411
|
-
let { body, setAttrs = () => { return {}; } } = modal;
|
|
412
|
-
let attrs = setAttrs('body') || {};
|
|
413
|
-
if (!body || body === null) {
|
|
414
|
-
return null;
|
|
415
|
-
}
|
|
416
|
-
return (_jsx("div", Object.assign({}, AddToAttrs(attrs, { className: 'aio-popup-body aio-popup-scroll' }), { children: body })));
|
|
417
|
-
};
|
|
418
|
-
const ModalFooter = () => {
|
|
419
|
-
const { modal } = useContext(POPUPCTX);
|
|
420
|
-
let { setAttrs = () => { return {}; }, footer } = modal;
|
|
421
|
-
if (!footer) {
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
let Attrs = setAttrs('footer') || {};
|
|
425
|
-
const attrs = AddToAttrs(Attrs, { className: 'aio-popup-footer' });
|
|
426
|
-
return _jsx("div", Object.assign({}, attrs, { children: footer }));
|
|
427
|
-
};
|
|
428
|
-
const SBCTX = createContext({});
|
|
429
|
-
const SnackebarItem = (props) => {
|
|
430
|
-
const mainContext = useContext(CTX);
|
|
431
|
-
let { item } = props;
|
|
432
|
-
let { time = 8, id, align = ['right', 'top'] } = item;
|
|
433
|
-
if (align[1] !== 'top' && align[1] !== 'bottom') {
|
|
434
|
-
align[1] = 'top';
|
|
435
|
-
}
|
|
436
|
-
if (align[0] !== 'left' && align[0] !== 'right' && align[0] !== 'center') {
|
|
437
|
-
align[0] = 'right';
|
|
438
|
-
}
|
|
439
|
-
let [mounted, setMounted] = useState(false);
|
|
440
|
-
useEffect(() => {
|
|
441
|
-
setTimeout(() => setMounted(true), 0);
|
|
442
|
-
setTimeout(() => remove(), time * 1000);
|
|
443
|
-
}, []);
|
|
444
|
-
function remove() {
|
|
445
|
-
setMounted(false);
|
|
446
|
-
setTimeout(() => mainContext.removeSnackebar(id), 200);
|
|
447
|
-
}
|
|
448
|
-
const getSvg = (type) => { return type === 'error' || type === 'warning' || type === 'info' ? _jsx(InfoSvg, {}) : _jsx(SuccessSvg, {}); };
|
|
449
|
-
const getContext = () => {
|
|
450
|
-
return { mainContext, remove, item: Object.assign(Object.assign({}, props.item), { time, align }), index: props.index, mounted, getSvg };
|
|
451
|
-
};
|
|
452
|
-
return (_jsx(SBCTX.Provider, { value: getContext(), children: _jsx(SnackebarContainer, {}) }));
|
|
453
|
-
};
|
|
454
|
-
const SnackebarContainer = () => {
|
|
455
|
-
const { mainContext, mounted, index, item, remove } = useContext(SBCTX);
|
|
456
|
-
const { rtl } = mainContext;
|
|
457
|
-
let { onClose, align = ['right', 'top'] } = item;
|
|
458
|
-
function getOffsetStyle(index) {
|
|
459
|
-
let els = $('.aio-popup-snackebar-item-container'), sum = { top: 12, bottom: 12 };
|
|
460
|
-
for (let i = 0; i < index; i++) {
|
|
461
|
-
let dom = els.eq(i);
|
|
462
|
-
let height = dom.height() + 6;
|
|
463
|
-
let va = dom.attr('data-vertical-align');
|
|
464
|
-
sum[va] += height;
|
|
465
|
-
}
|
|
466
|
-
return {
|
|
467
|
-
[align[1] === 'top' ? 'top' : 'bottom']: sum[align[1]]
|
|
468
|
-
};
|
|
469
|
-
}
|
|
470
|
-
let className = 'aio-popup-snackebar-item-container';
|
|
471
|
-
className += ` aio-popup-snackebar-item-container-horizontal-align-${align[0]}`;
|
|
472
|
-
if (mounted) {
|
|
473
|
-
className += ' mounted';
|
|
474
|
-
}
|
|
475
|
-
if (rtl) {
|
|
476
|
-
className += ' rtl';
|
|
477
|
-
}
|
|
478
|
-
let style = getOffsetStyle(index);
|
|
479
|
-
let p = { 'data-vertical-align': align[1], className, style, onClick: onClose === false ? undefined : () => remove() };
|
|
480
|
-
return _jsx("div", Object.assign({}, p, { children: _jsx(SnackebarCard, {}) }));
|
|
481
|
-
};
|
|
482
|
-
const SnackebarCard = () => {
|
|
483
|
-
const { item } = useContext(SBCTX);
|
|
484
|
-
let { type, attrs = {} } = item;
|
|
485
|
-
let className = 'aio-popup-snackebar-item';
|
|
486
|
-
className += ` aio-popup-snackebar-item-${type}`;
|
|
487
|
-
if (attrs.className) {
|
|
488
|
-
className += ` ${attrs.className}`;
|
|
489
|
-
}
|
|
490
|
-
let p = Object.assign(Object.assign({}, attrs), { className, style: attrs.style });
|
|
491
|
-
return (_jsxs("div", Object.assign({}, p, { children: [_jsx(SnackebarIcon, {}), _jsx(SnackebarText, {}), _jsx(SnackebarAction, {}), _jsx(SnackebarBar, {})] })));
|
|
492
|
-
};
|
|
493
|
-
const SnackebarIcon = () => {
|
|
494
|
-
const { getSvg, item } = useContext(SBCTX);
|
|
495
|
-
return _jsx("div", { className: `aio-popup-snackebar-item-icon`, children: !!item.icon ? item.icon : getSvg(item.type) });
|
|
496
|
-
};
|
|
497
|
-
const SnackebarText = () => {
|
|
498
|
-
const { item } = useContext(SBCTX);
|
|
499
|
-
return (_jsxs("div", { className: 'aio-popup-snackebar-item-text', children: [_jsx("div", { className: 'aio-popup-snackebar-item-uptext', children: item.text }), !!item.subtext && _jsx("div", { className: 'aio-popup-snackebar-item-subtext', children: item.subtext })] }));
|
|
500
|
-
};
|
|
501
|
-
const SnackebarAction = () => {
|
|
502
|
-
const { item, remove } = useContext(SBCTX);
|
|
503
|
-
const { action } = item;
|
|
504
|
-
if (!action || !action.text) {
|
|
505
|
-
return null;
|
|
506
|
-
}
|
|
507
|
-
let p = {
|
|
508
|
-
className: 'aio-popup-snackebar-item-action',
|
|
509
|
-
onClick: (e) => { e.stopPropagation(); if (action) {
|
|
510
|
-
action.onClick();
|
|
511
|
-
} remove(); }
|
|
512
|
-
};
|
|
513
|
-
return (_jsx("button", Object.assign({}, p, { children: action.text })));
|
|
514
|
-
};
|
|
515
|
-
const SnackebarBar = () => {
|
|
516
|
-
const { item } = useContext(SBCTX);
|
|
517
|
-
return _jsx("div", { className: 'aio-popup-snackebar-bar', style: { transition: `${item.time || 8}s linear` } });
|
|
518
|
-
};
|
|
519
|
-
export function Alert(props) {
|
|
520
|
-
let { icon, type = '', text = '', subtext = '', time = 10, className, closeText = 'Close', onClose } = props;
|
|
521
|
-
let $$ = {
|
|
522
|
-
id: '',
|
|
523
|
-
time: 0,
|
|
524
|
-
getId() {
|
|
525
|
-
return 'aa' + Math.round((Math.random() * 100000000));
|
|
526
|
-
},
|
|
527
|
-
getBarRender() {
|
|
528
|
-
return `<div class='aio-popup-time-bar' style="width:${$$.time}%;"></div>`;
|
|
529
|
-
},
|
|
530
|
-
updateBarRender() {
|
|
531
|
-
$(`.aio-popup-alert-container.${$$.id} .aio-popup-time`).html($$.getBarRender());
|
|
532
|
-
},
|
|
533
|
-
getRender() {
|
|
534
|
-
return (`
|
|
535
|
-
<div class='aio-popup-alert-container not-mounted ${$$.id} aio-popup-alert-container-center${!!className ? ` ${className}` : ''}'>
|
|
536
|
-
<div class='aio-popup-alert aio-popup-alert-${type}'>
|
|
537
|
-
<div class='aio-popup-alert-header'>${$$.getIcon()}</div>
|
|
1
|
+
var __awaiter=this&&this.__awaiter||function(t,e,i,o){return new(i||(i=Promise))(function(r,n){function a(t){try{s(o.next(t))}catch(e){n(e)}}function l(t){try{s(o.throw(t))}catch(e){n(e)}}function s(t){var e;t.done?r(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(a,l)}s((o=o.apply(t,e||[])).next())})};import{jsx as t,Fragment as e,jsxs as i}from"react/jsx-runtime";import{createRef as o,useEffect as r,useState as n,createContext as a,useContext as l,useRef as s}from"react";import*as d from"react-dom/server";import c from"react-dom";import p from"animejs/lib/anime.es.js";import u from"jquery";import"./index.css";let CTX=a({});function Align(t){let{modal:e,target:i,fitHorizontal:o,rtl:r,limitTo:n}=t,a=window.innerWidth,l=window.innerHeight,s={left:0,top:0,bottom:l,right:a,width:a,height:l},d=getBound(i[0]),c=getBound(e[0]);d=Object.assign({},d);let p;if((c=Object.assign({},c)).top=d.bottom,c.bottom=c.top+c.height,o)c.width=d.width,c.left=d.left,c.right=d.left+d.width;else{if(n){let u=e.parents(n);u.length&&(s=getBound(u[0]))}r?(c.right=d.right,c.left=c.right-c.width,c.left<s.left&&(c.left=s.left)):(c.left=d.left,c.right=c.left+c.width,c.right>s.right&&(c.left=s.right-c.width))}return c.bottom>s.bottom?c.height>d.top-s.top?c.top=s.bottom-c.height:c.top=d.top-c.height:c.top=d.bottom,c.height>s.height&&(c.top=s.top,c.height=s.height,p="auto"),{left:c.left,top:c.top,width:c.width,overflowY:p,maxWidth:s.width}}let CloseIcon=()=>t("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:t("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)],n=r.length?r.join(" "):void 0,a=Object.assign(Object.assign({},t.style),i);return Object.assign(Object.assign(Object.assign({},t),{className:n,style:a}),e.attrs)}let usePopup=o=>{let[r,a]=n([]),l=s({}),d=s(r);d.current=r;let[p,_]=n([]),h=s(p);h.current=p;let[$,g]=n(),m=t=>{void 0===t.id&&(t.id="popup"+Math.round(1e6*Math.random()));let e=t;a(i=>[...i.filter(({id:e})=>e!==t.id),e])},f=t=>__awaiter(void 0,void 0,void 0,function*(){if("string"!=typeof t&&(t="last"),"all"===t){a([]);return}if(!d.current.length)return;"last"===t&&(t=d.current[d.current.length-1].id);let e=d.current.find(e=>e.id===t);e&&(u(`[data-id=${t}]`).addClass("not-mounted"),setTimeout(()=>{e&&"function"==typeof e.onClose&&e.onClose(),a(e=>e.filter(e=>e.id!==t))},300))}),v=t=>{_([...h.current,Object.assign(Object.assign({},t),{id:"a"+Math.round(1e9*Math.random())})])},b=t=>{let e=h.current,i=e.find(e=>e.id===t);if(i&&!1!==i.onClose)_(e.filter((e,i)=>e.id!==t)),"function"==typeof i.onClose&&i.onClose()},C=t=>Alert(t),y=t=>g(t),k=()=>g(void 0),L=o=>{let{title:r,subtitle:n,submitText:a="Yes",canselText:l="No",onSubmit:s,onCansel:d=()=>{},setAttrs:c=()=>({})}=o,p={position:"center",setAttrs(t){let e=c(t);return"modal"===t?AddToAttrs(e,{className:"aio-popup-confirm"}):e},header:{title:r,subtitle:n},body:t(e,{children:"text"}),footer:i(e,{children:[t("button",{type:"button",onClick(){d(),f()},children:l}),t("button",{type:"button",className:"active",onClick:()=>__awaiter(void 0,void 0,void 0,function*(){if(s)!1!==(yield s())&&f()}),children:a})]})};m(p)},w=o=>{let r="a"+Math.round(1e5*Math.random()),{title:n,subtitle:a,submitText:s="Submit",canselText:d="close",onSubmit:c,onCansel:p=()=>{},setAttrs:u=()=>({})}=o,_={position:"center",setAttrs(t){let e=u(t);return"modal"===t?AddToAttrs(e,{className:"aio-popup-prompt"}):e},header:{title:n,subtitle:a},body:t(Prompt,{change:t=>l.current=Object.assign(Object.assign({},l.current),{[r]:t})}),footer:i(e,{children:[t("button",{type:"button",onClick(){p(),f()},children:d}),t("button",{type:"button",className:"active",onClick:()=>__awaiter(void 0,void 0,void 0,function*(){if(!c)return;let t=l.current[r];if(!1!==(yield c(t)))f();else{let e={};for(let i in l.current)i!==r&&(e[i]=l.current[i]);l.current=e}}),disabled:!l.current[r],children:s})]})};m(_)},S=()=>({rtl:!!o&&!!o.rtl,snackebarItems:h.current,removeSnackebar:b,removeModal:f}),T=e=>i(CTX.Provider,{value:S(),children:[d.current.map((i,o)=>t(Popup,{modal:i,isLast:o===d.current.length-1,renderCaller:e},i.id)),p.map((e,i)=>t(SnackebarItem,{item:e,index:i},e.id)),!!$&&t(Highlight,{highlight:$})]}),M=()=>c.createPortal(T(),document.body);return{addAlert:C,addSnackebar:v,removeModal:f,addModal:m,getModals:()=>d.current,addHighlight:y,removeHighlight:k,render:T,addConfirm:L,addPrompt:w,portal:M}};export default usePopup;let Prompt=({change:e})=>{let[i,o]=n("");return t("textarea",{placeholder:i,value:i,onChange(t){let i=t.target.value;o(i),e(i)}})},POPUPCTX=a({}),Popup=({modal:e,isLast:a,renderCaller:d})=>{let c=l(CTX),{setAttrs:p=()=>({}),id:_,position:h="fullscreen",getTarget:$}=e,[g]=n({dom:o(),backdropDom:o(),dui:void 0}),[m,f]=n({}),v=s(!1),[b,C]=n(e.state),y=p("modal")||{},k=s(!1);function L(t){if(!g.dui)return;let e=u(t.target);"popover"===h&&e.attr("data-id")!==g.dui&&!e.parents(`[data-id=${g.dui}]`).length&&c.removeModal()}function w(){let t=Object.assign(Object.assign({},m),y.style),i="ontouchstart"in document.documentElement?"onTouchStart":"onMouseDown";return Object.assign(Object.assign({},y),{ref:g.dom,"data-id":e.id,tabIndex:0,onKeyDown:T,[i]:x,className:B(),style:Object.assign({},t),onClick(t){t.stopPropagation()}})}function S(){if(!$)return{};let t=$();if(!t||!t.length)return{};let i={modal:u(g.dom.current),target:t,fitHorizontal:e.fitHorizontal,limitTo:e.limitTo,attrs:y,rtl:c.rtl};return Object.assign(Object.assign({},Align(i)),{position:"absolute"})}function T(t){if(a)27===t.keyCode&&c.removeModal()}function M(){setTimeout(()=>v.current=!1,0)}function x(t){v.current=!0,u(window).unbind("mouseup",M),u(window).bind("mouseup",M)}function B(){let t="aio-popup";return t+=c.rtl?" rtl":" ltr",k&&(t+=" not-mounted"),y.className&&(t+=" "+y.className),t}r(()=>()=>{u(window).unbind("click",L)}),r(()=>{if("popover"===h&&f(S()),$){g.dui="a"+Math.round(1e7*Math.random());$().attr("data-id",g.dui)}setTimeout(()=>{let t=u(g.dom.current);t.removeClass("not-mounted"),u(g.backdropDom.current).removeClass("not-mounted"),t.focus()},0),u(window).unbind("click",L),u(window).bind("click",L)},[]);let N=()=>({modal:e,isLast:a,state:b,setState:C,onKeyDown:T});return t(POPUPCTX.Provider,{value:N(),children:t(ModalBackdrop,{firstMount:!!k,backdropDom:g.backdropDom,isModalMouseDown:()=>v.current,children:i("div",Object.assign({},w(),{children:[t(ModalHeader,{}),t(ModalBody,{},e.id),t(ModalFooter,{})]}),e.id)},e.id)})},ModalBackdrop=({children:e,firstMount:i,backdropDom:o,isModalMouseDown:r})=>{let{removeModal:a,rtl:s}=l(CTX),{modal:d,onKeyDown:c}=l(POPUPCTX),{setAttrs:p=()=>({}),id:_,position:h="fullscreen"}=d,[$]=n(p("backdrop")||{});function g(t){if(!r()&&t.target===t.currentTarget)u(t.target).hasClass("aio-popup-backdrop")&&a()}function m(){let t="aio-popup-backdrop";return t+=` aio-popup-position-${h}`,t+=s?" rtl":" ltr",i&&(t+=" not-mounted"),AddToAttrs($,{className:t,attrs:{ref:o,onKeyDown:c,tabIndex:0,"data-id":_,onClick:$.onClick?$.onClick:g}})}return t("div",Object.assign({},m(),{children:e}))},ModalHeader=()=>{let{removeModal:e}=l(CTX),{modal:o,state:r,setState:n}=l(POPUPCTX);if(!o.header)return null;let{setAttrs:a=()=>({})}=o,s=a("header")||{};return"function"==typeof o.header?o.header({removeModal:e,state:r,setState:n}):"object"!=typeof o.header?null:i("div",Object.assign({},AddToAttrs(s,{className:"aio-popup-header"}),{children:[t(ModalHeaderElement,{type:"before"},"before"),t(ModalHeaderElement,{type:"title"},"title"),t(ModalHeaderElement,{type:"after"},"after"),t(ModalClose,{})]}))},ModalHeaderElement=({type:e})=>{let{modal:i}=l(POPUPCTX),{header:o}=i;return"function"!=typeof o&&o&&o[e]?t("div",{className:`aio-popup-header-${e}`,"data-subtitle":"title"===e?o.subtitle:void 0,children:o[e]}):null},ModalClose=()=>{let{removeModal:e}=l(CTX),{modal:i,state:o,setState:r}=l(POPUPCTX),{header:n}=i;return"function"!=typeof n&&n&&!1!==n.onClose?t("div",{className:"aio-popup-header-close",onClick(t){t.stopPropagation(),t.preventDefault(),"function"==typeof n.onClose?n.onClose({state:o,setState:r}):e(i.id)},children:t(CloseIcon,{})}):null},ModalBody=()=>{let{modal:e}=l(POPUPCTX),{body:i,setAttrs:o=()=>({})}=e,r=o("body")||{};return i&&null!==i?t("div",Object.assign({},AddToAttrs(r,{className:"aio-popup-body aio-popup-scroll"}),{children:i})):null},ModalFooter=()=>{let{modal:e}=l(POPUPCTX),{setAttrs:i=()=>({}),footer:o}=e;if(!o)return null;let r=i("footer")||{},n=AddToAttrs(r,{className:"aio-popup-footer"});return t("div",Object.assign({},n,{children:o}))},SBCTX=a({}),SnackebarItem=e=>{let i=l(CTX),{item:o}=e,{time:a=8,id:s,align:d=["right","top"]}=o;"top"!==d[1]&&"bottom"!==d[1]&&(d[1]="top"),"left"!==d[0]&&"right"!==d[0]&&"center"!==d[0]&&(d[0]="right");let[c,p]=n(!1);function u(){p(!1),setTimeout(()=>i.removeSnackebar(s),200)}r(()=>{setTimeout(()=>p(!0),0),setTimeout(()=>u(),1e3*a)},[]);let _=e=>"error"===e||"warning"===e||"info"===e?t(InfoSvg,{}):t(SuccessSvg,{}),h=()=>({mainContext:i,remove:u,item:Object.assign(Object.assign({},e.item),{time:a,align:d}),index:e.index,mounted:c,getSvg:_});return t(SBCTX.Provider,{value:h(),children:t(SnackebarContainer,{})})},SnackebarContainer=()=>{let{mainContext:e,mounted:i,index:o,item:r,remove:n}=l(SBCTX),{rtl:a}=e,{onClose:s,align:d=["right","top"]}=r;function c(t){let e=u(".aio-popup-snackebar-item-container"),i={top:12,bottom:12};for(let o=0;o<t;o++){let r=e.eq(o),n=r.height()+6,a=r.attr("data-vertical-align");i[a]+=n}return{["top"===d[1]?"top":"bottom"]:i[d[1]]}}let p="aio-popup-snackebar-item-container";p+=` aio-popup-snackebar-item-container-horizontal-align-${d[0]}`,i&&(p+=" mounted"),a&&(p+=" rtl");let _=c(o),h={"data-vertical-align":d[1],className:p,style:_,onClick:!1===s?void 0:()=>n()};return t("div",Object.assign({},h,{children:t(SnackebarCard,{})}))},SnackebarCard=()=>{let{item:e}=l(SBCTX),{type:o,attrs:r={}}=e,n="aio-popup-snackebar-item";return n+=` aio-popup-snackebar-item-${o}`,r.className&&(n+=` ${r.className}`),i("div",Object.assign({},Object.assign(Object.assign({},r),{className:n,style:r.style}),{children:[t(SnackebarIcon,{}),t(SnackebarText,{}),t(SnackebarAction,{}),t(SnackebarBar,{})]}))},SnackebarIcon=()=>{let{getSvg:e,item:i}=l(SBCTX);return t("div",{className:"aio-popup-snackebar-item-icon",children:i.icon?i.icon:e(i.type)})},SnackebarText=()=>{let{item:e}=l(SBCTX);return i("div",{className:"aio-popup-snackebar-item-text",children:[t("div",{className:"aio-popup-snackebar-item-uptext",children:e.text}),!!e.subtext&&t("div",{className:"aio-popup-snackebar-item-subtext",children:e.subtext})]})},SnackebarAction=()=>{let{item:e,remove:i}=l(SBCTX),{action:o}=e;return o&&o.text?t("button",Object.assign({},{className:"aio-popup-snackebar-item-action",onClick(t){t.stopPropagation(),o&&o.onClick(),i()}},{children:o.text})):null},SnackebarBar=()=>{let{item:e}=l(SBCTX);return t("div",{className:"aio-popup-snackebar-bar",style:{transition:`${e.time||8}s linear`}})};export function Alert(t){let{icon:e,type:i="",title:o="",text:r="",time:n=10,className:a,closeText:l="Close",onClose:s,align:c="left"}=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(){u(`.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-center${a?` ${a}`:""}'>
|
|
3
|
+
<div class='aio-popup-alert aio-popup-alert-${i}'>
|
|
4
|
+
<div class='aio-popup-alert-header'>${p.getIcon()}</div>
|
|
538
5
|
<div class='aio-popup-alert-body aio-popup-scroll'>
|
|
539
|
-
<div class='aio-popup-alert-
|
|
540
|
-
<div class='aio-popup-alert-
|
|
6
|
+
<div class='aio-popup-alert-title'>${d.renderToStaticMarkup(o)}</div>
|
|
7
|
+
<div class='aio-popup-alert-text' style="text-align:${c}">${r}</div>
|
|
541
8
|
</div>
|
|
542
9
|
<div class='aio-popup-alert-footer'>
|
|
543
|
-
<button class='aio-popup-alert-close ${
|
|
10
|
+
<button class='aio-popup-alert-close ${p.id}'>${l}</button>
|
|
544
11
|
</div>
|
|
545
12
|
<div class='aio-popup-time'></div>
|
|
546
13
|
</div>
|
|
547
14
|
</div>
|
|
548
|
-
`);
|
|
549
|
-
},
|
|
550
|
-
close() {
|
|
551
|
-
$$.toggleClass(false);
|
|
552
|
-
setTimeout(() => {
|
|
553
|
-
if (typeof onClose === 'function') {
|
|
554
|
-
onClose();
|
|
555
|
-
}
|
|
556
|
-
if (onClose === false) {
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
$('.' + $$.id).remove();
|
|
560
|
-
}, 200);
|
|
561
|
-
},
|
|
562
|
-
getIcon() {
|
|
563
|
-
if (icon === false) {
|
|
564
|
-
return '';
|
|
565
|
-
}
|
|
566
|
-
return icon || {
|
|
567
|
-
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>`),
|
|
568
|
-
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>`),
|
|
569
|
-
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>`),
|
|
570
|
-
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>`)
|
|
571
|
-
}[type] || '';
|
|
572
|
-
},
|
|
573
|
-
startTimer() {
|
|
574
|
-
setTimeout(() => {
|
|
575
|
-
if ($$.time >= 100) {
|
|
576
|
-
$$.time = 100;
|
|
577
|
-
$$.close();
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
$$.time += 2;
|
|
581
|
-
$$.updateBarRender();
|
|
582
|
-
$$.startTimer();
|
|
583
|
-
}, time / 50 * 1000);
|
|
584
|
-
},
|
|
585
|
-
toggleClass(mount) {
|
|
586
|
-
let dom = $(`.${$$.id}`);
|
|
587
|
-
if (mount) {
|
|
588
|
-
setTimeout(() => dom.removeClass('not-mounted'), 0);
|
|
589
|
-
}
|
|
590
|
-
else {
|
|
591
|
-
dom.addClass('not-mounted');
|
|
592
|
-
}
|
|
593
|
-
},
|
|
594
|
-
render() {
|
|
595
|
-
$('body').append($$.getRender());
|
|
596
|
-
$('button.' + $$.id).off('click', $$.close);
|
|
597
|
-
$('button.' + $$.id).on('click', $$.close);
|
|
598
|
-
$$.toggleClass(true);
|
|
599
|
-
}
|
|
600
|
-
};
|
|
601
|
-
$$.id = $$.getId();
|
|
602
|
-
$$.render();
|
|
603
|
-
if (time) {
|
|
604
|
-
$$.startTimer();
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
const Highlight = ({ highlight }) => {
|
|
608
|
-
const [limit, setLimit] = useState({ Left: 0, Top: 0, Width: 0, Height: 0, TopSpace: 0, BottomSpace: 0 });
|
|
609
|
-
const limitRef = useRef(limit);
|
|
610
|
-
limitRef.current = limit;
|
|
611
|
-
useEffect(() => {
|
|
612
|
-
setTimeout(() => {
|
|
613
|
-
try {
|
|
614
|
-
const { dom, duration = 1200 } = highlight;
|
|
615
|
-
dom[0].scrollIntoView();
|
|
616
|
-
let newLimit = getHLLimit(highlight);
|
|
617
|
-
let easing = getEasing(highlight);
|
|
618
|
-
let obj = Object.assign(Object.assign({}, newLimit), { targets: [Object.assign({}, limitRef.current)], duration, update: (p) => {
|
|
619
|
-
const { animatables } = p;
|
|
620
|
-
setLimit(Object.assign({}, animatables[0].target));
|
|
621
|
-
} });
|
|
622
|
-
if (easing) {
|
|
623
|
-
obj.easing = easing;
|
|
624
|
-
}
|
|
625
|
-
anime(obj);
|
|
626
|
-
}
|
|
627
|
-
catch (_a) {
|
|
628
|
-
alert(`aio-highlighter error => connot find dom`);
|
|
629
|
-
}
|
|
630
|
-
}, 0);
|
|
631
|
-
});
|
|
632
|
-
function getArrowIcon(props) {
|
|
633
|
-
return (_jsx("svg", Object.assign({ version: "1.1", id: "Layer_1", xmlns: "http://www.w3.org/2000/svg", x: "0px", y: "0px", viewBox: "0 0 512 512" }, props, { children: _jsxs("g", { children: [_jsx("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\r\n 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" }), _jsx("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\r\n 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" })] }) })));
|
|
634
|
-
}
|
|
635
|
-
function getArrow(dir, left, width) {
|
|
636
|
-
let center = left + width / 2, Left = center - 12;
|
|
637
|
-
let style = { position: 'absolute', height: 24, width: 24, left: Left };
|
|
638
|
-
let props = { width: 24, height: 24, style, className: `aio-popup-highlight-arrow-${dir}` };
|
|
639
|
-
return (_jsx("div", { className: "aio-popup-highlight-arrow", children: getArrowIcon(props) }));
|
|
640
|
-
}
|
|
641
|
-
function getHtml(dir) {
|
|
642
|
-
if (!highlight.html) {
|
|
643
|
-
return '';
|
|
644
|
-
}
|
|
645
|
-
let column;
|
|
646
|
-
let html = highlight.html || '';
|
|
647
|
-
let space = _jsx("div", { className: "aio-popup-highlight-space" });
|
|
648
|
-
let content = _jsx("div", { className: "aio-popup-highlight-html", children: html });
|
|
649
|
-
let arrow = getArrow(dir, limitRef.current.Left, limitRef.current.Width);
|
|
650
|
-
if (dir === 'top') {
|
|
651
|
-
column = _jsxs(_Fragment, { children: [space, content, arrow] });
|
|
652
|
-
}
|
|
653
|
-
else {
|
|
654
|
-
column = _jsxs(_Fragment, { children: [arrow, content, space] });
|
|
655
|
-
}
|
|
656
|
-
return _jsx("div", { className: "aio-popup-highlight-html-container", children: column });
|
|
657
|
-
}
|
|
658
|
-
function click() {
|
|
659
|
-
if (highlight.mouseAccess) {
|
|
660
|
-
return;
|
|
661
|
-
}
|
|
662
|
-
if (highlight.onClick) {
|
|
663
|
-
highlight.onClick();
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
function vMask_node(type) {
|
|
667
|
-
let html = '', size = 0, className = 'aio-popup-highlight-mask';
|
|
668
|
-
let dir = type === 'top' || type === 'bottom' ? 'height' : 'width';
|
|
669
|
-
let limit = limitRef.current;
|
|
670
|
-
if (type === 'top') {
|
|
671
|
-
size = limit.Top;
|
|
672
|
-
if (limit.TopSpace > limit.BottomSpace) {
|
|
673
|
-
html = getHtml('top');
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
else if (type === 'bottom') {
|
|
677
|
-
className += ' aio-popup-highlight-mask-flex';
|
|
678
|
-
if (limit.TopSpace <= limit.BottomSpace) {
|
|
679
|
-
html = getHtml('bottom');
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
else if (type === 'left') {
|
|
683
|
-
size = limit.Left;
|
|
684
|
-
}
|
|
685
|
-
else {
|
|
686
|
-
className += ' aio-popup-highlight-mask-flex';
|
|
687
|
-
}
|
|
688
|
-
return (_jsx("div", { className: className, style: { [dir]: size }, onClick: () => click(), children: html }));
|
|
689
|
-
}
|
|
690
|
-
function focus_node() {
|
|
691
|
-
const cls1 = "aio-popup-highlight-focus-container", cls2 = 'aio-popup-highlight-focus';
|
|
692
|
-
return (_jsx("div", { style: { width: limit.Width }, className: cls1, onClick: click, children: _jsx("div", { className: cls2 }) }));
|
|
693
|
-
}
|
|
694
|
-
function main_node() {
|
|
695
|
-
return _jsxs("div", { className: "aio-popup-highlight-main", style: { height: limit.Height }, children: [vMask_node('left'), focus_node(), vMask_node('right')] });
|
|
696
|
-
}
|
|
697
|
-
function getStyle() { return { pointerEvents: highlight.mouseAccess ? 'none' : 'all' }; }
|
|
698
|
-
const attrs = AddToAttrs(highlight.attrs, { className: 'aio-popup-highlight', style: getStyle() });
|
|
699
|
-
return (_jsxs("div", Object.assign({}, attrs, { children: [vMask_node('top'), main_node(), vMask_node('bottom')] })));
|
|
700
|
-
};
|
|
701
|
-
function getHLLimit(highlight) {
|
|
702
|
-
const { padding = 6, dom } = highlight;
|
|
703
|
-
let offset = dom.offset();
|
|
704
|
-
let left = offset.left - window.pageXOffset;
|
|
705
|
-
let top = offset.top - window.pageYOffset;
|
|
706
|
-
let pageHeight = window.innerHeight;
|
|
707
|
-
let width = dom.outerWidth();
|
|
708
|
-
let height = dom.outerHeight();
|
|
709
|
-
let Top = top - 1 * padding;
|
|
710
|
-
let Left = left - 1 * padding;
|
|
711
|
-
let Width = width + 2 * padding;
|
|
712
|
-
let Height = height + 2 * padding;
|
|
713
|
-
let TopSpace = top;
|
|
714
|
-
let BottomSpace = pageHeight - (top + height);
|
|
715
|
-
let res = { Left, Top, Width, Height, TopSpace, BottomSpace };
|
|
716
|
-
return res;
|
|
717
|
-
}
|
|
718
|
-
function getEasing(highlight) {
|
|
719
|
-
const { easing } = highlight;
|
|
720
|
-
var easingNames = [
|
|
721
|
-
'linear',
|
|
722
|
-
'easeInQuad',
|
|
723
|
-
'easeInSine',
|
|
724
|
-
'easeInCirc',
|
|
725
|
-
'easeInBack',
|
|
726
|
-
'easeOutQuad',
|
|
727
|
-
'easeOutSine',
|
|
728
|
-
'easeOutCirc',
|
|
729
|
-
'easeInOutQuad',
|
|
730
|
-
'easeInOutSine',
|
|
731
|
-
'easeInOutBack',
|
|
732
|
-
'easeOutBounce', //27
|
|
733
|
-
];
|
|
734
|
-
if (typeof easing === 'number') {
|
|
735
|
-
let res = easingNames[easing];
|
|
736
|
-
return res || easingNames[0];
|
|
737
|
-
}
|
|
738
|
-
return easing;
|
|
739
|
-
}
|
|
740
|
-
const InfoSvg = () => {
|
|
741
|
-
const 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";
|
|
742
|
-
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.2rem', height: '1.2rem' }, children: _jsx("path", { d: d, style: { fill: 'currentcolor' } }) }));
|
|
743
|
-
};
|
|
744
|
-
const SuccessSvg = () => {
|
|
745
|
-
const 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";
|
|
746
|
-
return (_jsx("svg", { viewBox: "0 0 24 24", role: "presentation", style: { width: '1.2rem', height: '1.2rem' }, children: _jsx("path", { d: d, style: { fill: 'currentcolor' } }) }));
|
|
747
|
-
};
|
|
748
|
-
function getBound(dom) {
|
|
749
|
-
try {
|
|
750
|
-
const res = dom.getBoundingClientRect();
|
|
751
|
-
return { width: res.width, height: res.height, left: res.left, top: res.top, bottom: res.bottom, right: res.right };
|
|
752
|
-
}
|
|
753
|
-
catch (_a) {
|
|
754
|
-
return { width: 0, height: 0, left: 0, top: 0, bottom: 0, right: 0 };
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
export class Loading {
|
|
758
|
-
constructor(loader) {
|
|
759
|
-
this.loader = '0';
|
|
760
|
-
this.getLoader_0 = () => {
|
|
761
|
-
return (`
|
|
15
|
+
`,close(){p.toggleClass(!1),setTimeout(()=>{"function"==typeof s&&s(),!1!==s&&u("."+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()},n/50*1e3)},toggleClass(t){let e=u(`.${p.id}`);t?setTimeout(()=>e.removeClass("not-mounted"),0):e.addClass("not-mounted")},render(){u("body").append(p.getRender()),u("button."+p.id).off("click",p.close),u("button."+p.id).on("click",p.close),p.toggleClass(!0)}};p.id=p.getId(),p.render(),n&&p.startTimer()}let Highlight=({highlight:o})=>{let[a,l]=n({Left:0,Top:0,Width:0,Height:0,TopSpace:0,BottomSpace:0}),d=s(a);function c(e){return t("svg",Object.assign({version:"1.1",id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",viewBox:"0 0 512 512"},e,{children:i("g",{children:[t("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\r\n 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"}),t("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\r\n 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 u(e,i,o){return t("div",{className:"aio-popup-highlight-arrow",children:c({width:24,height:24,style:{position:"absolute",height:24,width:24,left:i+o/2-12},className:`aio-popup-highlight-arrow-${e}`})})}function _(r){if(!o.html)return"";let n,a=o.html||"",l=t("div",{className:"aio-popup-highlight-space"}),s=t("div",{className:"aio-popup-highlight-html",children:a}),c=u(r,d.current.Left,d.current.Width);return n="top"===r?i(e,{children:[l,s,c]}):i(e,{children:[c,s,l]}),t("div",{className:"aio-popup-highlight-html-container",children:n})}function h(){!o.mouseAccess&&o.onClick&&o.onClick()}function $(e){let i="",o=0,r="aio-popup-highlight-mask",n=d.current;return"top"===e?(o=n.Top,n.TopSpace>n.BottomSpace&&(i=_("top"))):"bottom"===e?(r+=" aio-popup-highlight-mask-flex",n.TopSpace<=n.BottomSpace&&(i=_("bottom"))):"left"===e?o=n.Left:r+=" aio-popup-highlight-mask-flex",t("div",{className:r,style:{["top"===e||"bottom"===e?"height":"width"]:o},onClick:()=>h(),children:i})}function g(){return t("div",{style:{width:a.Width},className:"aio-popup-highlight-focus-container",onClick:h,children:t("div",{className:"aio-popup-highlight-focus"})})}function m(){return i("div",{className:"aio-popup-highlight-main",style:{height:a.Height},children:[$("left"),g(),$("right")]})}function f(){return{pointerEvents:o.mouseAccess?"none":"all"}}d.current=a,r(()=>{setTimeout(()=>{try{let{dom:t,duration:e=1200}=o;t[0].scrollIntoView();let i=getHLLimit(o),r=getEasing(o),n=Object.assign(Object.assign({},i),{targets:[Object.assign({},d.current)],duration:e,update(t){let{animatables:e}=t;l(Object.assign({},e[0].target))}});r&&(n.easing=r),p(n)}catch(a){alert("aio-highlighter error => connot find dom")}},0)});let v=AddToAttrs(o.attrs,{className:"aio-popup-highlight",style:f()});return i("div",Object.assign({},v,{children:[$("top"),m(),$("bottom")]}))};function getHLLimit(t){let{padding:e=6,dom:i}=t,o=i.offset(),r=o.left-window.pageXOffset,n=o.top-window.pageYOffset,a=window.innerHeight,l=i.outerWidth(),s=i.outerHeight();return{Left:r-1*e,Top:n-1*e,Width:l+2*e,Height:s+2*e,TopSpace:n,BottomSpace:a-(n+s)}}function getEasing(t){let{easing:e}=t;var i=["linear","easeInQuad","easeInSine","easeInCirc","easeInBack","easeOutQuad","easeOutSine","easeOutCirc","easeInOutQuad","easeInOutSine","easeInOutBack","easeOutBounce"];return"number"==typeof e?i[e]||i[0]:e}let InfoSvg=()=>t("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:t("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=()=>t("svg",{viewBox:"0 0 24 24",role:"presentation",style:{width:"1.2rem",height:"1.2rem"},children:t("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(i){return{width:0,height:0,left:0,top:0,bottom:0,right:0}}}export class Loading{constructor(t){this.loader="0",this.getLoader_0=()=>`
|
|
762
16
|
<div class="aio-loading-container-0">
|
|
763
17
|
<div class="aio-loading-0">
|
|
764
|
-
${
|
|
18
|
+
${[,,,,,].fill(0).map((t,e)=>this.getLoaderItem_0(`0.${e}`)).join(" ")}
|
|
765
19
|
</div>
|
|
766
20
|
</div>
|
|
767
|
-
|
|
768
|
-
};
|
|
769
|
-
this.getLoaderItem_0 = (ease) => {
|
|
770
|
-
return `<div class="aio-loading-item-0" style="animation: 1s ease-in-out ${ease}s infinite normal none running aioloading0;"></div>`;
|
|
771
|
-
};
|
|
772
|
-
this.getLoader = (id) => {
|
|
773
|
-
let content = '';
|
|
774
|
-
if (this.loader === '0') {
|
|
775
|
-
content = this.getLoader_0();
|
|
776
|
-
}
|
|
777
|
-
else if (typeof this.loader === 'string') {
|
|
778
|
-
content = this.loader;
|
|
779
|
-
}
|
|
780
|
-
return (`<div class="aio-loading" id="aio-loading-${id}">${content}</div>`);
|
|
781
|
-
};
|
|
782
|
-
this.show = (id, parentSelector) => {
|
|
783
|
-
parentSelector = parentSelector || 'body';
|
|
784
|
-
let loadingStr = this.getLoader(id);
|
|
785
|
-
let parent = document.querySelector(parentSelector);
|
|
786
|
-
if (parent) {
|
|
787
|
-
parent.insertAdjacentHTML('beforeend', loadingStr);
|
|
788
|
-
}
|
|
789
|
-
};
|
|
790
|
-
this.hide = (id) => {
|
|
791
|
-
let loadingDom = document.getElementById('aio-loading-' + id);
|
|
792
|
-
if (!loadingDom) {
|
|
793
|
-
loadingDom = document.querySelector('.aio-loading');
|
|
794
|
-
}
|
|
795
|
-
if (loadingDom) {
|
|
796
|
-
loadingDom.remove();
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
if (typeof loader === 'string') {
|
|
800
|
-
this.loader = loader;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
}
|
|
21
|
+
`,this.getLoaderItem_0=t=>`<div class="aio-loading-item-0" style="animation: 1s ease-in-out ${t}s infinite normal none running aioloading0;"></div>`,this.getLoader=t=>{let e="";return"0"===this.loader?e=this.getLoader_0():"string"==typeof this.loader&&(e=this.loader),`<div class="aio-loading" id="aio-loading-${t}">${e}</div>`},this.show=(t,e)=>{e=e||"body";let i=this.getLoader(t),o=document.querySelector(e);o&&o.insertAdjacentHTML("beforeend",i)},this.hide=t=>{let e=document.getElementById("aio-loading-"+t);e||(e=document.querySelector(".aio-loading")),e&&e.remove()},"string"==typeof t&&(this.loader=t)}}
|