1 |
|
2 |
|
3 |
|
4 | import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
5 | import { b as getIonMode, c as config } from './ionic-global.js';
|
6 | import { B as BACKDROP, e as prepareOverlay, d as present, f as dismiss, g as eventMethod } from './overlays.js';
|
7 | import { s as sanitizeDOMString } from './index3.js';
|
8 | import { g as getClassMap } from './theme.js';
|
9 | import { c as createAnimation } from './animation.js';
|
10 | import { d as defineCustomElement$3 } from './backdrop.js';
|
11 | import { d as defineCustomElement$2 } from './spinner.js';
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const iosEnterAnimation = (baseEl) => {
|
17 | const baseAnimation = createAnimation();
|
18 | const backdropAnimation = createAnimation();
|
19 | const wrapperAnimation = createAnimation();
|
20 | backdropAnimation
|
21 | .addElement(baseEl.querySelector('ion-backdrop'))
|
22 | .fromTo('opacity', 0.01, 'var(--backdrop-opacity)')
|
23 | .beforeStyles({
|
24 | 'pointer-events': 'none'
|
25 | })
|
26 | .afterClearStyles(['pointer-events']);
|
27 | wrapperAnimation
|
28 | .addElement(baseEl.querySelector('.loading-wrapper'))
|
29 | .keyframes([
|
30 | { offset: 0, opacity: 0.01, transform: 'scale(1.1)' },
|
31 | { offset: 1, opacity: 1, transform: 'scale(1)' }
|
32 | ]);
|
33 | return baseAnimation
|
34 | .addElement(baseEl)
|
35 | .easing('ease-in-out')
|
36 | .duration(200)
|
37 | .addAnimation([backdropAnimation, wrapperAnimation]);
|
38 | };
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | const iosLeaveAnimation = (baseEl) => {
|
44 | const baseAnimation = createAnimation();
|
45 | const backdropAnimation = createAnimation();
|
46 | const wrapperAnimation = createAnimation();
|
47 | backdropAnimation
|
48 | .addElement(baseEl.querySelector('ion-backdrop'))
|
49 | .fromTo('opacity', 'var(--backdrop-opacity)', 0);
|
50 | wrapperAnimation
|
51 | .addElement(baseEl.querySelector('.loading-wrapper'))
|
52 | .keyframes([
|
53 | { offset: 0, opacity: 0.99, transform: 'scale(1)' },
|
54 | { offset: 1, opacity: 0, transform: 'scale(0.9)' }
|
55 | ]);
|
56 | return baseAnimation
|
57 | .addElement(baseEl)
|
58 | .easing('ease-in-out')
|
59 | .duration(200)
|
60 | .addAnimation([backdropAnimation, wrapperAnimation]);
|
61 | };
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | const mdEnterAnimation = (baseEl) => {
|
67 | const baseAnimation = createAnimation();
|
68 | const backdropAnimation = createAnimation();
|
69 | const wrapperAnimation = createAnimation();
|
70 | backdropAnimation
|
71 | .addElement(baseEl.querySelector('ion-backdrop'))
|
72 | .fromTo('opacity', 0.01, 'var(--backdrop-opacity)')
|
73 | .beforeStyles({
|
74 | 'pointer-events': 'none'
|
75 | })
|
76 | .afterClearStyles(['pointer-events']);
|
77 | wrapperAnimation
|
78 | .addElement(baseEl.querySelector('.loading-wrapper'))
|
79 | .keyframes([
|
80 | { offset: 0, opacity: 0.01, transform: 'scale(1.1)' },
|
81 | { offset: 1, opacity: 1, transform: 'scale(1)' }
|
82 | ]);
|
83 | return baseAnimation
|
84 | .addElement(baseEl)
|
85 | .easing('ease-in-out')
|
86 | .duration(200)
|
87 | .addAnimation([backdropAnimation, wrapperAnimation]);
|
88 | };
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | const mdLeaveAnimation = (baseEl) => {
|
94 | const baseAnimation = createAnimation();
|
95 | const backdropAnimation = createAnimation();
|
96 | const wrapperAnimation = createAnimation();
|
97 | backdropAnimation
|
98 | .addElement(baseEl.querySelector('ion-backdrop'))
|
99 | .fromTo('opacity', 'var(--backdrop-opacity)', 0);
|
100 | wrapperAnimation
|
101 | .addElement(baseEl.querySelector('.loading-wrapper'))
|
102 | .keyframes([
|
103 | { offset: 0, opacity: 0.99, transform: 'scale(1)' },
|
104 | { offset: 1, opacity: 0, transform: 'scale(0.9)' }
|
105 | ]);
|
106 | return baseAnimation
|
107 | .addElement(baseEl)
|
108 | .easing('ease-in-out')
|
109 | .duration(200)
|
110 | .addAnimation([backdropAnimation, wrapperAnimation]);
|
111 | };
|
112 |
|
113 | const loadingIosCss = ".sc-ion-loading-ios-h{--min-width:auto;--width:auto;--min-height:auto;--height:auto;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:fixed;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;outline:none;font-family:var(--ion-font-family, inherit);contain:strict;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:1001}.overlay-hidden.sc-ion-loading-ios-h{display:none}.loading-wrapper.sc-ion-loading-ios{display:-ms-flexbox;display:flex;-ms-flex-align:inherit;align-items:inherit;-ms-flex-pack:inherit;justify-content:inherit;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);background:var(--background);opacity:0;z-index:10}.spinner-lines.sc-ion-loading-ios,.spinner-lines-small.sc-ion-loading-ios,.spinner-bubbles.sc-ion-loading-ios,.spinner-circles.sc-ion-loading-ios,.spinner-crescent.sc-ion-loading-ios,.spinner-dots.sc-ion-loading-ios{color:var(--spinner-color)}.sc-ion-loading-ios-h{--background:var(--ion-overlay-background-color, var(--ion-color-step-100, #f9f9f9));--max-width:270px;--max-height:90%;--spinner-color:var(--ion-color-step-600, #666666);--backdrop-opacity:var(--ion-backdrop-opacity, 0.3);color:var(--ion-text-color, #000);font-size:14px}.loading-wrapper.sc-ion-loading-ios{border-radius:8px;padding-left:34px;padding-right:34px;padding-top:24px;padding-bottom:24px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.loading-wrapper.sc-ion-loading-ios{padding-left:unset;padding-right:unset;-webkit-padding-start:34px;padding-inline-start:34px;-webkit-padding-end:34px;padding-inline-end:34px}}@supports ((-webkit-backdrop-filter: blur(0)) or (backdrop-filter: blur(0))){.loading-translucent.sc-ion-loading-ios-h .loading-wrapper.sc-ion-loading-ios{background-color:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.8);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px)}}.loading-content.sc-ion-loading-ios{font-weight:bold}.loading-spinner.sc-ion-loading-ios+.loading-content.sc-ion-loading-ios{margin-left:16px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.loading-spinner.sc-ion-loading-ios+.loading-content.sc-ion-loading-ios{margin-left:unset;-webkit-margin-start:16px;margin-inline-start:16px}}";
|
114 |
|
115 | const loadingMdCss = ".sc-ion-loading-md-h{--min-width:auto;--width:auto;--min-height:auto;--height:auto;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:fixed;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;outline:none;font-family:var(--ion-font-family, inherit);contain:strict;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:1001}.overlay-hidden.sc-ion-loading-md-h{display:none}.loading-wrapper.sc-ion-loading-md{display:-ms-flexbox;display:flex;-ms-flex-align:inherit;align-items:inherit;-ms-flex-pack:inherit;justify-content:inherit;width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);background:var(--background);opacity:0;z-index:10}.spinner-lines.sc-ion-loading-md,.spinner-lines-small.sc-ion-loading-md,.spinner-bubbles.sc-ion-loading-md,.spinner-circles.sc-ion-loading-md,.spinner-crescent.sc-ion-loading-md,.spinner-dots.sc-ion-loading-md{color:var(--spinner-color)}.sc-ion-loading-md-h{--background:var(--ion-color-step-50, #f2f2f2);--max-width:280px;--max-height:90%;--spinner-color:var(--ion-color-primary, #3880ff);--backdrop-opacity:var(--ion-backdrop-opacity, 0.32);color:var(--ion-color-step-850, #262626);font-size:14px}.loading-wrapper.sc-ion-loading-md{border-radius:2px;padding-left:24px;padding-right:24px;padding-top:24px;padding-bottom:24px;-webkit-box-shadow:0 16px 20px rgba(0, 0, 0, 0.4);box-shadow:0 16px 20px rgba(0, 0, 0, 0.4)}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.loading-wrapper.sc-ion-loading-md{padding-left:unset;padding-right:unset;-webkit-padding-start:24px;padding-inline-start:24px;-webkit-padding-end:24px;padding-inline-end:24px}}.loading-spinner.sc-ion-loading-md+.loading-content.sc-ion-loading-md{margin-left:16px}@supports ((-webkit-margin-start: 0) or (margin-inline-start: 0)) or (-webkit-margin-start: 0){.loading-spinner.sc-ion-loading-md+.loading-content.sc-ion-loading-md{margin-left:unset;-webkit-margin-start:16px;margin-inline-start:16px}}";
|
116 |
|
117 | const Loading = proxyCustomElement(class extends HTMLElement {
|
118 | constructor() {
|
119 | super();
|
120 | this.__registerHost();
|
121 | this.didPresent = createEvent(this, "ionLoadingDidPresent", 7);
|
122 | this.willPresent = createEvent(this, "ionLoadingWillPresent", 7);
|
123 | this.willDismiss = createEvent(this, "ionLoadingWillDismiss", 7);
|
124 | this.didDismiss = createEvent(this, "ionLoadingDidDismiss", 7);
|
125 | this.presented = false;
|
126 | |
127 |
|
128 |
|
129 | this.keyboardClose = true;
|
130 | |
131 |
|
132 |
|
133 | this.duration = 0;
|
134 | |
135 |
|
136 |
|
137 | this.backdropDismiss = false;
|
138 | |
139 |
|
140 |
|
141 | this.showBackdrop = true;
|
142 | |
143 |
|
144 |
|
145 |
|
146 |
|
147 | this.translucent = false;
|
148 | |
149 |
|
150 |
|
151 | this.animated = true;
|
152 | this.onBackdropTap = () => {
|
153 | this.dismiss(undefined, BACKDROP);
|
154 | };
|
155 | }
|
156 | connectedCallback() {
|
157 | prepareOverlay(this.el);
|
158 | }
|
159 | componentWillLoad() {
|
160 | if (this.spinner === undefined) {
|
161 | const mode = getIonMode(this);
|
162 | this.spinner = config.get('loadingSpinner', config.get('spinner', mode === 'ios' ? 'lines' : 'crescent'));
|
163 | }
|
164 | }
|
165 | |
166 |
|
167 |
|
168 | async present() {
|
169 | await present(this, 'loadingEnter', iosEnterAnimation, mdEnterAnimation, undefined);
|
170 | if (this.duration > 0) {
|
171 | this.durationTimeout = setTimeout(() => this.dismiss(), this.duration + 10);
|
172 | }
|
173 | }
|
174 | |
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 | dismiss(data, role) {
|
184 | if (this.durationTimeout) {
|
185 | clearTimeout(this.durationTimeout);
|
186 | }
|
187 | return dismiss(this, data, role, 'loadingLeave', iosLeaveAnimation, mdLeaveAnimation);
|
188 | }
|
189 | |
190 |
|
191 |
|
192 | onDidDismiss() {
|
193 | return eventMethod(this.el, 'ionLoadingDidDismiss');
|
194 | }
|
195 | |
196 |
|
197 |
|
198 | onWillDismiss() {
|
199 | return eventMethod(this.el, 'ionLoadingWillDismiss');
|
200 | }
|
201 | render() {
|
202 | const { message, spinner, htmlAttributes } = this;
|
203 | const mode = getIonMode(this);
|
204 | return (h(Host, Object.assign({ tabindex: "-1" }, htmlAttributes, { style: {
|
205 | zIndex: `${40000 + this.overlayIndex}`
|
206 | }, onIonBackdropTap: this.onBackdropTap, class: Object.assign(Object.assign({}, getClassMap(this.cssClass)), { [mode]: true, 'overlay-hidden': true, 'loading-translucent': this.translucent }) }), h("ion-backdrop", { visible: this.showBackdrop, tappable: this.backdropDismiss }), h("div", { tabindex: "0" }), h("div", { class: "loading-wrapper ion-overlay-wrapper", role: "dialog" }, spinner && (h("div", { class: "loading-spinner" }, h("ion-spinner", { name: spinner, "aria-hidden": "true" }))), message && h("div", { class: "loading-content", innerHTML: sanitizeDOMString(message) })), h("div", { tabindex: "0" })));
|
207 | }
|
208 | get el() { return this; }
|
209 | static get style() { return {
|
210 | ios: loadingIosCss,
|
211 | md: loadingMdCss
|
212 | }; }
|
213 | }, [34, "ion-loading", {
|
214 | "overlayIndex": [2, "overlay-index"],
|
215 | "keyboardClose": [4, "keyboard-close"],
|
216 | "enterAnimation": [16],
|
217 | "leaveAnimation": [16],
|
218 | "message": [1],
|
219 | "cssClass": [1, "css-class"],
|
220 | "duration": [2],
|
221 | "backdropDismiss": [4, "backdrop-dismiss"],
|
222 | "showBackdrop": [4, "show-backdrop"],
|
223 | "spinner": [1025],
|
224 | "translucent": [4],
|
225 | "animated": [4],
|
226 | "htmlAttributes": [16],
|
227 | "present": [64],
|
228 | "dismiss": [64],
|
229 | "onDidDismiss": [64],
|
230 | "onWillDismiss": [64]
|
231 | }]);
|
232 | function defineCustomElement$1() {
|
233 | if (typeof customElements === "undefined") {
|
234 | return;
|
235 | }
|
236 | const components = ["ion-loading", "ion-backdrop", "ion-spinner"];
|
237 | components.forEach(tagName => { switch (tagName) {
|
238 | case "ion-loading":
|
239 | if (!customElements.get(tagName)) {
|
240 | customElements.define(tagName, Loading);
|
241 | }
|
242 | break;
|
243 | case "ion-backdrop":
|
244 | if (!customElements.get(tagName)) {
|
245 | defineCustomElement$3();
|
246 | }
|
247 | break;
|
248 | case "ion-spinner":
|
249 | if (!customElements.get(tagName)) {
|
250 | defineCustomElement$2();
|
251 | }
|
252 | break;
|
253 | } });
|
254 | }
|
255 |
|
256 | const IonLoading = Loading;
|
257 | const defineCustomElement = defineCustomElement$1;
|
258 |
|
259 | export { IonLoading, defineCustomElement };
|