stripe-pwa-elements 4.0.1 → 4.0.3

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.
Files changed (107) hide show
  1. package/dist/cjs/factory-Cm6zUD7R.js +1206 -0
  2. package/dist/cjs/{factory-Cd2VI_N2.js → i18n-lBbOeQt4.js} +12 -1149
  3. package/dist/cjs/ion-icon_2.cjs.entry.js +725 -0
  4. package/dist/cjs/loader.cjs.js +1 -1
  5. package/dist/cjs/stripe-address-element.cjs.entry.js +5 -4
  6. package/dist/cjs/stripe-card-element-modal.cjs.entry.js +3 -2
  7. package/dist/cjs/{stripe-card-element_2.cjs.entry.js → stripe-card-element.cjs.entry.js} +8 -93
  8. package/dist/cjs/stripe-currency-selector.cjs.entry.js +4 -3
  9. package/dist/cjs/stripe-elements.cjs.js +1 -1
  10. package/dist/cjs/stripe-express-checkout-element.cjs.entry.js +24 -5
  11. package/dist/cjs/stripe-link-authentication-element.cjs.entry.js +4 -3
  12. package/dist/cjs/stripe-payment-element.cjs.entry.js +12 -124
  13. package/dist/cjs/stripe-payment-element.helpers-CvAhIqLt.js +119 -0
  14. package/dist/cjs/stripe-payment-request-button.cjs.entry.js +2 -2
  15. package/dist/cjs/stripe-payment-sheet.cjs.entry.js +987 -0
  16. package/dist/collection/collection-manifest.json +2 -1
  17. package/dist/collection/components/stripe-address-element/stripe-address-element.js +2 -2
  18. package/dist/collection/components/stripe-card-element/stripe-card-element.js +3 -2
  19. package/dist/collection/components/stripe-card-element-modal/stripe-card-element-modal.js +4 -3
  20. package/dist/collection/components/stripe-express-checkout-element/stripe-express-checkout-element.js +18 -0
  21. package/dist/collection/components/stripe-modal/stripe-modal.css +27 -1
  22. package/dist/collection/components/stripe-modal/stripe-modal.js +132 -1
  23. package/dist/collection/components/stripe-payment-element/stripe-payment-element.helpers.js +4 -7
  24. package/dist/collection/components/stripe-payment-element/stripe-payment-element.js +4 -4
  25. package/dist/collection/components/stripe-payment-request-button/stripe-payment-request-button.js +3 -3
  26. package/dist/collection/components/stripe-payment-sheet/payment-sheet-state.js +193 -0
  27. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.checkout.js +94 -0
  28. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.css +68 -0
  29. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.helpers.js +274 -0
  30. package/dist/collection/components/stripe-payment-sheet/stripe-payment-sheet.js +763 -0
  31. package/dist/collection/services/express-checkout-element-manager.js +36 -2
  32. package/dist/collection/services/link-authentication-element-manager.js +5 -0
  33. package/dist/collection/services/stripe-service.js +20 -6
  34. package/dist/collection/utils/focus.js +76 -0
  35. package/dist/collection/utils/i18n.js +12 -0
  36. package/dist/components/factory.js +1 -1
  37. package/dist/components/i18n.js +1 -0
  38. package/dist/components/stripe-address-element.js +1 -1
  39. package/dist/components/stripe-card-element-modal.js +1 -1
  40. package/dist/components/stripe-card-element2.js +1 -1
  41. package/dist/components/stripe-currency-selector.js +1 -1
  42. package/dist/components/stripe-express-checkout-element.js +1 -1
  43. package/dist/components/stripe-link-authentication-element.js +1 -1
  44. package/dist/components/stripe-modal2.js +1 -1
  45. package/dist/components/stripe-payment-element.helpers.js +1 -0
  46. package/dist/components/stripe-payment-element.js +1 -1
  47. package/dist/components/stripe-payment-request-button2.js +1 -1
  48. package/dist/components/stripe-payment-sheet.d.ts +11 -0
  49. package/dist/components/stripe-payment-sheet.js +1 -0
  50. package/dist/esm/factory-BaGv8K_i.js +1203 -0
  51. package/dist/esm/{factory-VTa1Gc94.js → i18n-CL5n3bOb.js} +13 -1149
  52. package/dist/esm/ion-icon_2.entry.js +722 -0
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/stripe-address-element.entry.js +2 -1
  55. package/dist/esm/stripe-card-element-modal.entry.js +3 -2
  56. package/dist/esm/{stripe-card-element_2.entry.js → stripe-card-element.entry.js} +6 -90
  57. package/dist/esm/stripe-currency-selector.entry.js +2 -1
  58. package/dist/esm/stripe-elements.js +1 -1
  59. package/dist/esm/stripe-express-checkout-element.entry.js +20 -1
  60. package/dist/esm/stripe-link-authentication-element.entry.js +2 -1
  61. package/dist/esm/stripe-payment-element.entry.js +4 -116
  62. package/dist/esm/stripe-payment-element.helpers-Bu9RfxS4.js +114 -0
  63. package/dist/esm/stripe-payment-request-button.entry.js +2 -2
  64. package/dist/esm/stripe-payment-sheet.entry.js +985 -0
  65. package/dist/stripe-elements/p-2e41699e.entry.js +1 -0
  66. package/dist/stripe-elements/p-3fc4583a.entry.js +1 -0
  67. package/dist/stripe-elements/{p-ae0c336e.entry.js → p-4891edf0.entry.js} +1 -1
  68. package/dist/stripe-elements/p-7e826964.entry.js +1 -0
  69. package/dist/stripe-elements/p-BhKXGROE.js +1 -0
  70. package/dist/stripe-elements/p-CL5n3bOb.js +1 -0
  71. package/dist/stripe-elements/p-DlMEZwSe.js +1 -0
  72. package/dist/stripe-elements/p-a395a5d1.entry.js +1 -0
  73. package/dist/stripe-elements/p-b62c9dae.entry.js +1 -0
  74. package/dist/stripe-elements/p-b7c20e8e.entry.js +1 -0
  75. package/dist/stripe-elements/p-ba791c8f.entry.js +1 -0
  76. package/dist/stripe-elements/p-bec62526.entry.js +1 -0
  77. package/dist/stripe-elements/p-f5552c81.entry.js +1 -0
  78. package/dist/stripe-elements/stripe-elements.esm.js +1 -1
  79. package/dist/types/components/stripe-card-element/stripe-card-element.d.ts +2 -1
  80. package/dist/types/components/stripe-card-element-modal/stripe-card-element-modal.d.ts +2 -1
  81. package/dist/types/components/stripe-express-checkout-element/stripe-express-checkout-element.d.ts +5 -0
  82. package/dist/types/components/stripe-modal/stripe-modal.d.ts +43 -0
  83. package/dist/types/components/stripe-payment-element/stripe-payment-element.helpers.d.ts +7 -2
  84. package/dist/types/components/stripe-payment-request-button/stripe-payment-request-button.d.ts +1 -1
  85. package/dist/types/components/stripe-payment-sheet/payment-sheet-state.d.ts +121 -0
  86. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.checkout.d.ts +39 -0
  87. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.d.ts +157 -0
  88. package/dist/types/components/stripe-payment-sheet/stripe-payment-sheet.helpers.d.ts +153 -0
  89. package/dist/types/components.d.ts +182 -10
  90. package/dist/types/index.d.ts +2 -0
  91. package/dist/types/services/interfaces.d.ts +3 -0
  92. package/dist/types/services/stripe-service.d.ts +7 -2
  93. package/dist/types/utils/focus.d.ts +15 -0
  94. package/package.json +7 -3
  95. package/readme.md +59 -6
  96. package/dist/cjs/ion-icon.cjs.entry.js +0 -431
  97. package/dist/components/utils.js +0 -1
  98. package/dist/esm/ion-icon.entry.js +0 -429
  99. package/dist/stripe-elements/p-1bd46766.entry.js +0 -1
  100. package/dist/stripe-elements/p-1c6e0a45.entry.js +0 -1
  101. package/dist/stripe-elements/p-3f42ca0c.entry.js +0 -1
  102. package/dist/stripe-elements/p-5cf62945.entry.js +0 -1
  103. package/dist/stripe-elements/p-74de1556.entry.js +0 -1
  104. package/dist/stripe-elements/p-76e57d78.entry.js +0 -1
  105. package/dist/stripe-elements/p-840d499f.entry.js +0 -1
  106. package/dist/stripe-elements/p-CrjrbGJ3.js +0 -1
  107. package/dist/stripe-elements/p-cfd8e081.entry.js +0 -1
@@ -0,0 +1,722 @@
1
+ import { e as getAssetPath, r as registerInstance, f as Build, h, d as Host, g as getElement, a as createEvent } from './index-C6bbmyga.js';
2
+ import { c as checkPlatform, i as i18n } from './i18n-CL5n3bOb.js';
3
+
4
+ let CACHED_MAP;
5
+ const getIconMap = () => {
6
+ if (typeof window === 'undefined') {
7
+ return new Map();
8
+ }
9
+ else {
10
+ if (!CACHED_MAP) {
11
+ const win = window;
12
+ win.Ionicons = win.Ionicons || {};
13
+ CACHED_MAP = win.Ionicons.map = win.Ionicons.map || new Map();
14
+ }
15
+ return CACHED_MAP;
16
+ }
17
+ };
18
+ const getUrl = (i) => {
19
+ let url = getSrc(i.src);
20
+ if (url) {
21
+ return url;
22
+ }
23
+ url = getName(i.name, i.icon, i.mode, i.ios, i.md);
24
+ if (url) {
25
+ return getNamedUrl(url, i);
26
+ }
27
+ if (i.icon) {
28
+ url = getSrc(i.icon);
29
+ if (url) {
30
+ return url;
31
+ }
32
+ url = getSrc(i.icon[i.mode]);
33
+ if (url) {
34
+ return url;
35
+ }
36
+ }
37
+ return null;
38
+ };
39
+ const getNamedUrl = (iconName, iconEl) => {
40
+ const url = getIconMap().get(iconName);
41
+ if (url) {
42
+ return url;
43
+ }
44
+ try {
45
+ return getAssetPath(`svg/${iconName}.svg`);
46
+ }
47
+ catch (e) {
48
+ console.log('e', e);
49
+ /**
50
+ * In the custom elements build version of ionicons, referencing an icon
51
+ * by name will throw an invalid URL error because the asset path is not defined.
52
+ * This catches that error and logs something that is more developer-friendly.
53
+ * We also include a reference to the ion-icon element so developers can
54
+ * figure out which instance of ion-icon needs to be updated.
55
+ */
56
+ console.warn(`[Ionicons Warning]: Could not load icon with name "${iconName}". Ensure that the icon is registered using addIcons or that the icon SVG data is passed directly to the icon component.`, iconEl);
57
+ }
58
+ };
59
+ const getName = (iconName, icon, mode, ios, md) => {
60
+ // default to "md" if somehow the mode wasn't set
61
+ mode = (mode && toLower(mode)) === 'ios' ? 'ios' : 'md';
62
+ // if an icon was passed in using the ios or md attributes
63
+ // set the iconName to whatever was passed in
64
+ if (ios && mode === 'ios') {
65
+ iconName = toLower(ios);
66
+ }
67
+ else if (md && mode === 'md') {
68
+ iconName = toLower(md);
69
+ }
70
+ else {
71
+ if (!iconName && icon && !isSrc(icon)) {
72
+ iconName = icon;
73
+ }
74
+ if (isStr(iconName)) {
75
+ iconName = toLower(iconName);
76
+ }
77
+ }
78
+ if (!isStr(iconName) || iconName.trim() === '') {
79
+ return null;
80
+ }
81
+ // only allow alpha characters and dash
82
+ const invalidChars = iconName.replace(/[a-z]|-|\d/gi, '');
83
+ if (invalidChars !== '') {
84
+ return null;
85
+ }
86
+ return iconName;
87
+ };
88
+ const getSrc = (src) => {
89
+ if (isStr(src)) {
90
+ src = src.trim();
91
+ if (isSrc(src)) {
92
+ return src;
93
+ }
94
+ }
95
+ return null;
96
+ };
97
+ const isSrc = (str) => str.length > 0 && /(\/|\.)/.test(str);
98
+ const isStr = (val) => typeof val === 'string';
99
+ const toLower = (val) => val.toLowerCase();
100
+ /**
101
+ * Elements inside of web components sometimes need to inherit global attributes
102
+ * set on the host. For example, the inner input in `ion-input` should inherit
103
+ * the `title` attribute that developers set directly on `ion-input`. This
104
+ * helper function should be called in componentWillLoad and assigned to a variable
105
+ * that is later used in the render function.
106
+ *
107
+ * This does not need to be reactive as changing attributes on the host element
108
+ * does not trigger a re-render.
109
+ */
110
+ const inheritAttributes = (el, attributes = []) => {
111
+ const attributeObject = {};
112
+ attributes.forEach((attr) => {
113
+ if (el.hasAttribute(attr)) {
114
+ const value = el.getAttribute(attr);
115
+ if (value !== null) {
116
+ attributeObject[attr] = el.getAttribute(attr);
117
+ }
118
+ el.removeAttribute(attr);
119
+ }
120
+ });
121
+ return attributeObject;
122
+ };
123
+ /**
124
+ * Returns `true` if the document or host element
125
+ * has a `dir` set to `rtl`. The host value will always
126
+ * take priority over the root document value.
127
+ */
128
+ const isRTL = (hostEl) => {
129
+ if (hostEl) {
130
+ if (hostEl.dir !== '') {
131
+ return hostEl.dir.toLowerCase() === 'rtl';
132
+ }
133
+ }
134
+ return (document === null || document === void 0 ? void 0 : document.dir.toLowerCase()) === 'rtl';
135
+ };
136
+
137
+ const validateContent = (svgContent) => {
138
+ const div = document.createElement('div');
139
+ div.innerHTML = svgContent;
140
+ // setup this way to ensure it works on our buddy IE
141
+ for (let i = div.childNodes.length - 1; i >= 0; i--) {
142
+ if (div.childNodes[i].nodeName.toLowerCase() !== 'svg') {
143
+ div.removeChild(div.childNodes[i]);
144
+ }
145
+ }
146
+ // must only have 1 root element
147
+ const svgElm = div.firstElementChild;
148
+ if (svgElm && svgElm.nodeName.toLowerCase() === 'svg') {
149
+ const svgClass = svgElm.getAttribute('class') || '';
150
+ svgElm.setAttribute('class', (svgClass + ' s-ion-icon').trim());
151
+ // root element must be an svg
152
+ // lets double check we've got valid elements
153
+ // do not allow scripts
154
+ if (isValid(svgElm)) {
155
+ return div.innerHTML;
156
+ }
157
+ }
158
+ return '';
159
+ };
160
+ const isValid = (elm) => {
161
+ if (elm.nodeType === 1) {
162
+ if (elm.nodeName.toLowerCase() === 'script') {
163
+ return false;
164
+ }
165
+ for (let i = 0; i < elm.attributes.length; i++) {
166
+ const name = elm.attributes[i].name;
167
+ if (isStr(name) && name.toLowerCase().indexOf('on') === 0) {
168
+ return false;
169
+ }
170
+ }
171
+ for (let i = 0; i < elm.childNodes.length; i++) {
172
+ if (!isValid(elm.childNodes[i])) {
173
+ return false;
174
+ }
175
+ }
176
+ }
177
+ return true;
178
+ };
179
+ const isSvgDataUrl = (url) => url.startsWith('data:image/svg+xml');
180
+ const isEncodedDataUrl = (url) => url.indexOf(';utf8,') !== -1;
181
+
182
+ const ioniconContent = new Map();
183
+ const requests = new Map();
184
+ let parser;
185
+ /**
186
+ * Safely fallback to an empty svg
187
+ */
188
+ function safeFallback(url) {
189
+ const svg = '';
190
+ ioniconContent.set(url, svg);
191
+ return svg;
192
+ }
193
+ const getSvgContent = (url, sanitize) => {
194
+ /**
195
+ * See if we already have a request for this url
196
+ */
197
+ const req = requests.get(url);
198
+ if (req) {
199
+ return req;
200
+ }
201
+ if (typeof fetch !== 'undefined' && typeof document !== 'undefined') {
202
+ /**
203
+ * If the url is a data url of an svg, then try to parse it
204
+ * with the DOMParser. This works with content security policies enabled.
205
+ */
206
+ if (isSvgDataUrl(url) && isEncodedDataUrl(url)) {
207
+ return Promise.resolve(getSvgByUrl(url));
208
+ }
209
+ return fetchSvg(url, sanitize);
210
+ }
211
+ return Promise.resolve(safeFallback(url));
212
+ };
213
+ function getSvgByUrl(url) {
214
+ if (!parser) {
215
+ /**
216
+ * Create an instance of the DOM parser. This creates a single
217
+ * parser instance for the entire app, which is more efficient.
218
+ */
219
+ parser = new DOMParser();
220
+ }
221
+ const doc = parser.parseFromString(url, 'text/html');
222
+ const svg = doc.querySelector('svg');
223
+ if (svg) {
224
+ ioniconContent.set(url, svg.outerHTML);
225
+ return svg.outerHTML;
226
+ }
227
+ throw new Error(`Could not parse svg from ${url}`);
228
+ }
229
+ function fetchSvg(url, sanitize) {
230
+ /**
231
+ * We don't already have a request
232
+ */
233
+ const req = fetch(url)
234
+ .then((rsp) => {
235
+ /**
236
+ * When fetching from a file:// URL, some browsers return
237
+ * a 0 status code even when the request succeeds so don't
238
+ * rely on rsp.ok as the only signal of success.
239
+ */
240
+ return rsp
241
+ .text()
242
+ .then((svgContent) => {
243
+ if (svgContent && sanitize !== false) {
244
+ svgContent = validateContent(svgContent);
245
+ }
246
+ const svg = svgContent || '';
247
+ ioniconContent.set(url, svg);
248
+ return svg;
249
+ })
250
+ .catch(() => safeFallback(url));
251
+ })
252
+ .catch(() => safeFallback(url));
253
+ /**
254
+ * Cache for the same requests
255
+ */
256
+ requests.set(url, req);
257
+ return req;
258
+ }
259
+
260
+ const iconCss = () => `:host{display:inline-block;width:1em;height:1em;contain:strict;fill:currentColor;box-sizing:content-box !important}:host .ionicon{stroke:currentColor}.ionicon-fill-none{fill:none}.ionicon-stroke-width{stroke-width:var(--ionicon-stroke-width, 32px)}.icon-inner,.ionicon,svg{display:block;height:100%;width:100%}@supports (background: -webkit-named-image(i)){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}@supports not selector(:dir(rtl)) and selector(:host-context([dir='rtl'])){:host(.icon-rtl) .icon-inner{transform:scaleX(-1)}}:host(.flip-rtl):host-context([dir='rtl']) .icon-inner{transform:scaleX(-1)}@supports selector(:dir(rtl)){:host(.flip-rtl:dir(rtl)) .icon-inner{transform:scaleX(-1)}:host(.flip-rtl:dir(ltr)) .icon-inner{transform:scaleX(1)}}:host(.icon-small){font-size:1.125rem !important}:host(.icon-large){font-size:2rem !important}:host(.ion-color){color:var(--ion-color-base) !important}:host(.ion-color-primary){--ion-color-base:var(--ion-color-primary, #3880ff)}:host(.ion-color-secondary){--ion-color-base:var(--ion-color-secondary, #0cd1e8)}:host(.ion-color-tertiary){--ion-color-base:var(--ion-color-tertiary, #f4a942)}:host(.ion-color-success){--ion-color-base:var(--ion-color-success, #10dc60)}:host(.ion-color-warning){--ion-color-base:var(--ion-color-warning, #ffce00)}:host(.ion-color-danger){--ion-color-base:var(--ion-color-danger, #f14141)}:host(.ion-color-light){--ion-color-base:var(--ion-color-light, #f4f5f8)}:host(.ion-color-medium){--ion-color-base:var(--ion-color-medium, #989aa2)}:host(.ion-color-dark){--ion-color-base:var(--ion-color-dark, #222428)}`;
261
+
262
+ const Icon = class {
263
+ constructor(hostRef) {
264
+ registerInstance(this, hostRef);
265
+ this.iconName = null;
266
+ this.inheritedAttributes = {};
267
+ this.didLoadIcon = false;
268
+ this.isVisible = false;
269
+ /**
270
+ * The mode determines which platform styles to use.
271
+ */
272
+ this.mode = getIonMode();
273
+ /**
274
+ * If enabled, ion-icon will be loaded lazily when it's visible in the viewport.
275
+ * Default, `false`.
276
+ */
277
+ this.lazy = false;
278
+ /**
279
+ * When set to `false`, SVG content that is HTTP fetched will not be checked
280
+ * if the response SVG content has any `<script>` elements, or any attributes
281
+ * that start with `on`, such as `onclick`.
282
+ * @default true
283
+ */
284
+ this.sanitize = true;
285
+ }
286
+ componentWillLoad() {
287
+ this.inheritedAttributes = inheritAttributes(this.el, ['aria-label']);
288
+ }
289
+ connectedCallback() {
290
+ /**
291
+ * purposely do not return the promise here because loading
292
+ * the svg file should not hold up loading the app
293
+ * only load the svg if it's visible
294
+ */
295
+ this.waitUntilVisible(this.el, '50px', () => {
296
+ this.isVisible = true;
297
+ this.loadIcon();
298
+ });
299
+ }
300
+ /**
301
+ * Loads the icon after the component has finished rendering.
302
+ */
303
+ componentDidLoad() {
304
+ /**
305
+ * Addresses an Angular issue where property values are assigned after the 'connectedCallback' but prior to the registration of watchers.
306
+ * This enhancement ensures the loading of an icon when the component has finished rendering and the icon has yet to apply the SVG data.
307
+ * This modification pertains to the usage of Angular's binding syntax:
308
+ * `<ion-icon [name]="myIconName"></ion-icon>`
309
+ */
310
+ if (!this.didLoadIcon) {
311
+ this.loadIcon();
312
+ }
313
+ }
314
+ /**
315
+ * Disconnect the IntersectionObserver.
316
+ */
317
+ disconnectedCallback() {
318
+ if (this.io) {
319
+ this.io.disconnect();
320
+ this.io = undefined;
321
+ }
322
+ }
323
+ /**
324
+ * Wait until the icon is visible in the viewport.
325
+ * @param el - The element to observe.
326
+ * @param rootMargin - The root margin of the observer.
327
+ * @param cb - The callback to call when the element is visible.
328
+ */
329
+ waitUntilVisible(el, rootMargin, cb) {
330
+ /**
331
+ * IntersectionObserver is a browser API that allows you to observe
332
+ * the visibility of an element relative to a root element. It is
333
+ * supported in all modern browsers, except IE and when server-side
334
+ * rendering.
335
+ */
336
+ const hasIntersectionObserverSupport = Boolean(Build.isBrowser && this.lazy && typeof window !== 'undefined' && window.IntersectionObserver);
337
+ /**
338
+ * browser doesn't support IntersectionObserver
339
+ * so just fallback to always show it
340
+ */
341
+ if (!hasIntersectionObserverSupport) {
342
+ return cb();
343
+ }
344
+ const io = (this.io = new window.IntersectionObserver((data) => {
345
+ if (data[0].isIntersecting) {
346
+ io.disconnect();
347
+ this.io = undefined;
348
+ cb();
349
+ }
350
+ }, { rootMargin }));
351
+ io.observe(el);
352
+ }
353
+ /**
354
+ * Watch for changes to the icon name, src, icon, ios, or md properties.
355
+ * When a change is detected, the icon will be loaded.
356
+ */
357
+ loadIcon() {
358
+ if (Build.isBrowser && this.isVisible) {
359
+ const url = getUrl(this);
360
+ if (url) {
361
+ if (ioniconContent.has(url)) {
362
+ // sync if it's already loaded
363
+ this.svgContent = ioniconContent.get(url);
364
+ }
365
+ else {
366
+ // async if it hasn't been loaded
367
+ getSvgContent(url, this.sanitize).then(() => (this.svgContent = ioniconContent.get(url)));
368
+ }
369
+ this.didLoadIcon = true;
370
+ }
371
+ }
372
+ this.iconName = getName(this.name, this.icon, this.mode, this.ios, this.md);
373
+ }
374
+ render() {
375
+ const { flipRtl, iconName, inheritedAttributes, el } = this;
376
+ const mode = this.mode || 'md';
377
+ /**
378
+ * we have designated that arrows & chevrons should automatically flip (unless flip-rtl
379
+ * is set to false) because "back" is left in ltr and right in rtl, and "forward" is the opposite
380
+ */
381
+ const shouldAutoFlip = iconName
382
+ ? (iconName.includes('arrow') || iconName.includes('chevron')) && flipRtl !== false
383
+ : false;
384
+ /**
385
+ * if shouldBeFlippable is true, the icon should change direction when `dir` changes
386
+ */
387
+ const shouldBeFlippable = flipRtl || shouldAutoFlip;
388
+ return (h(Host, Object.assign({ key: '0578c899781ca145dd8205acd9670af39b57cf2e', role: "img", class: Object.assign(Object.assign({ [mode]: true }, createColorClasses(this.color)), { [`icon-${this.size}`]: !!this.size, 'flip-rtl': shouldBeFlippable, 'icon-rtl': shouldBeFlippable && isRTL(el) }) }, inheritedAttributes), Build.isBrowser && this.svgContent ? (h("div", { class: "icon-inner", innerHTML: this.svgContent })) : (h("div", { class: "icon-inner" }))));
389
+ }
390
+ static get assetsDirs() { return ["svg"]; }
391
+ get el() { return getElement(this); }
392
+ static get watchers() { return {
393
+ "name": [{
394
+ "loadIcon": 0
395
+ }],
396
+ "src": [{
397
+ "loadIcon": 0
398
+ }],
399
+ "icon": [{
400
+ "loadIcon": 0
401
+ }],
402
+ "ios": [{
403
+ "loadIcon": 0
404
+ }],
405
+ "md": [{
406
+ "loadIcon": 0
407
+ }]
408
+ }; }
409
+ };
410
+ /**
411
+ * Get the mode of the document.
412
+ * @returns The mode of the document.
413
+ */
414
+ const getIonMode = () => (Build.isBrowser && typeof document !== 'undefined' && document.documentElement.getAttribute('mode')) || 'md';
415
+ /**
416
+ * Create color classes for the icon.
417
+ * @param color - The color of the icon.
418
+ * @returns The color classes for the icon.
419
+ */
420
+ const createColorClasses = (color) => {
421
+ return color
422
+ ? {
423
+ 'ion-color': true,
424
+ [`ion-color-${color}`]: true,
425
+ }
426
+ : null;
427
+ };
428
+ Icon.style = iconCss();
429
+
430
+ const TABBABLE_SELECTOR = [
431
+ 'a[href]',
432
+ 'area[href]',
433
+ 'button:not([disabled])',
434
+ 'input:not([disabled]):not([type="hidden"])',
435
+ 'select:not([disabled])',
436
+ 'textarea:not([disabled])',
437
+ 'iframe',
438
+ 'audio[controls]',
439
+ 'video[controls]',
440
+ 'summary',
441
+ '[contenteditable]:not([contenteditable="false"])',
442
+ '[tabindex]',
443
+ ].join(',');
444
+ /**
445
+ * Whether the element can be reached with the Tab key.
446
+ * Elements hidden with `display: none` / `visibility: hidden` are excluded when the browser supports `checkVisibility()`.
447
+ */
448
+ const isTabbable = (element) => {
449
+ if (!element.matches(TABBABLE_SELECTOR)) {
450
+ return false;
451
+ }
452
+ const tabindex = element.getAttribute('tabindex');
453
+ if (tabindex !== null && Number(tabindex) < 0) {
454
+ return false;
455
+ }
456
+ if (element.hasAttribute('hidden') || element.closest('[inert]') !== null) {
457
+ return false;
458
+ }
459
+ const { checkVisibility } = element;
460
+ if (typeof checkVisibility === 'function' && !checkVisibility.call(element, { visibilityProperty: true })) {
461
+ return false;
462
+ }
463
+ return true;
464
+ };
465
+ const getComposedChildren = (node) => {
466
+ if (node instanceof Element && node.tagName === 'SLOT') {
467
+ const slot = node;
468
+ const assigned = typeof slot.assignedElements === 'function' ? slot.assignedElements({ flatten: true }) : [];
469
+ // Fall back to the slot's default content when nothing is assigned
470
+ return assigned.length > 0 ? assigned : Array.from(slot.children);
471
+ }
472
+ if (node instanceof Element && node.shadowRoot != null) {
473
+ return Array.from(node.shadowRoot.children);
474
+ }
475
+ return Array.from(node.children);
476
+ };
477
+ /**
478
+ * Collect tabbable elements under `root` in DOM order, following the composed (flattened) tree:
479
+ * open shadow roots are entered and `<slot>` elements are replaced by their assigned elements.
480
+ * Positive `tabindex` ordering is not taken into account.
481
+ */
482
+ const getTabbableElements = (root) => {
483
+ const result = [];
484
+ const walk = (node) => {
485
+ for (const child of getComposedChildren(node)) {
486
+ if (isTabbable(child)) {
487
+ result.push(child);
488
+ }
489
+ walk(child);
490
+ }
491
+ };
492
+ walk(root);
493
+ return result;
494
+ };
495
+ /**
496
+ * Return the focused element, descending into open shadow roots.
497
+ */
498
+ const getDeepActiveElement = (doc = document) => {
499
+ var _a, _b;
500
+ let active = (_a = doc.activeElement) !== null && _a !== void 0 ? _a : null;
501
+ while (((_b = active === null || active === void 0 ? void 0 : active.shadowRoot) === null || _b === void 0 ? void 0 : _b.activeElement) != null) {
502
+ active = active.shadowRoot.activeElement;
503
+ }
504
+ return active;
505
+ };
506
+
507
+ const stripeModalCss = () => `:root{--color-label:#565656;--color-placeholder:#acacac;--color-heading-text:#333;--color-text-error:#ef4444;--color-input-border:#e4e4e6;--color-input-border-shadow:rgba(228, 228, 230, 0.6);--color-button-text:rgba(255, 255, 255, 0.95);--color-button-text-disabled:rgba(255, 255, 255, 0.4);--color-primary:#0074d4}:host{box-sizing:border-box}:host *:where(:not(iframe,canvas,img,svg,video):not(svg *)){all:unset;display:revert;background:none;border:none;font-family:"Roboto", sans-serif;box-sizing:border-box}:host button{cursor:pointer}:host{display:block}.modal-row{opacity:0;pointer-events:none;will-change:transform;visibility:hidden}.modal-row.open{opacity:1;pointer-events:auto;visibility:visible;position:fixed;top:0;left:0;width:100%;height:100%;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:1ch;background:rgba(0, 0, 0, 0.3)}.modal-row .modal-child{transform:translateY(100%);transition:transform 420ms ease;position:relative}.modal-row .modal-child .modal-loading{display:none;position:absolute;top:160px;left:50%;transform:translateX(-50%);width:24px;height:24px}.modal-row .modal-child.loading .modal-loading{display:flex;justify-content:center;align-items:center}.modal-row .modal-child.loading .modal-loading svg{width:24px;height:24px}.modal-row .modal-child.loading .modal-content{visibility:hidden}.modal-row.open .modal-child{transform:translateY(0%)}.modal-child{padding:16px 8px 24px;background-color:#fff;width:100%;max-height:100vh;max-height:100dvh;overflow-y:auto;overscroll-behavior:contain}.modal-close-button-wrap{padding-left:8px}.modal-close-button-wrap .modal-close-button{display:block;width:32px;cursor:pointer;border-radius:4px}.modal-close-button-wrap .modal-close-button:focus-visible{outline:2px solid var(--color-label, #000);outline-offset:2px}.modal-close-button-wrap .modal-close-button ion-icon{width:32px;display:block;fill:var(--color-label)}.modal-child:focus{outline:none}.focus-guard{position:absolute;width:1px;height:1px;overflow:hidden}`;
508
+
509
+ const StripeModal = class {
510
+ constructor(hostRef) {
511
+ registerInstance(this, hostRef);
512
+ this.close = createEvent(this, "close", 7);
513
+ /**
514
+ * If true, the modal display close button
515
+ */
516
+ this.showCloseButton = true;
517
+ /**
518
+ * Modal state.
519
+ * If true, the modal will open
520
+ */
521
+ this.open = false;
522
+ /**
523
+ * Effect `this.open`. This is for animation.
524
+ * Ionic Ref: https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/accordion/accordion.tsx#L83
525
+ */
526
+ this.renderedOpen = false;
527
+ /**
528
+ * The element that had focus before the modal opened. Focus returns to it when the modal closes.
529
+ */
530
+ this.returnFocusElement = null;
531
+ /**
532
+ * Set when the modal opens; the initial focus is moved after the open state has been rendered.
533
+ */
534
+ this.shouldFocusOnRender = false;
535
+ /**
536
+ * The last element inside the modal that received focus.
537
+ * `FocusEvent.relatedTarget` is `null` when focus crosses an iframe boundary (e.g. leaving a Stripe Elements field),
538
+ * so the guards fall back to this value to tell which way focus is moving.
539
+ */
540
+ this.lastFocusedInside = null;
541
+ this.handleKeyDown = (event) => {
542
+ if (!this.open || event.key !== 'Escape') {
543
+ return;
544
+ }
545
+ // Escape that cancels an IME composition (keyCode 229) or that a slotted widget (e.g. an autocomplete popup) already handled must not close the modal
546
+ if (event.isComposing || event.keyCode === 229 || event.defaultPrevented) {
547
+ return;
548
+ }
549
+ // Prevent an outer modal (or the page) from also reacting to the same key press
550
+ event.preventDefault();
551
+ event.stopPropagation();
552
+ this.closeModal();
553
+ };
554
+ /**
555
+ * Whether focus came from a focusable element inside the modal (not from the container itself or from outside).
556
+ * The guards use it to tell Tab from Shift+Tab: a guard cannot see the key, but it can see where focus came from.
557
+ */
558
+ this.handleFocusIn = (event) => {
559
+ var _a, _b;
560
+ const target = ((_b = (_a = event.composedPath) === null || _a === void 0 ? void 0 : _a.call(event)[0]) !== null && _b !== void 0 ? _b : event.target);
561
+ if ((target === null || target === void 0 ? void 0 : target.classList) !== undefined && !target.classList.contains('focus-guard')) {
562
+ this.lastFocusedInside = target;
563
+ }
564
+ };
565
+ this.handleStartGuardFocus = (event) => {
566
+ // Shift+Tab from the first element wraps to the last; Tab from the container (or from outside) enters at the first
567
+ this.cameFromFocusableInside(event) ? this.focusLastElement() : this.focusFirstElement();
568
+ };
569
+ this.handleEndGuardFocus = (event) => {
570
+ // Tab from the last element wraps to the first; Shift+Tab from outside enters at the last
571
+ this.isInsideModal(this.getFocusOrigin(event)) ? this.focusFirstElement() : this.focusLastElement();
572
+ };
573
+ }
574
+ onOpenChange(open) {
575
+ if (open) {
576
+ this.rememberFocus();
577
+ this.openModalAnimation();
578
+ }
579
+ else {
580
+ this.renderedOpen = false;
581
+ this.shouldFocusOnRender = false;
582
+ this.lastFocusedInside = null;
583
+ this.close.emit();
584
+ this.restoreFocus();
585
+ }
586
+ }
587
+ /**
588
+ * Toggle modal state
589
+ */
590
+ async toggleModal() {
591
+ this.open ? await this.closeModal() : await this.openModal();
592
+ }
593
+ /**
594
+ * Open the modal
595
+ */
596
+ async openModal() {
597
+ this.open = true;
598
+ }
599
+ /**
600
+ * Close the modal
601
+ */
602
+ async closeModal() {
603
+ this.open = false;
604
+ }
605
+ componentDidLoad() {
606
+ const platformName = checkPlatform();
607
+ if (platformName) {
608
+ this.el.classList.add(platformName);
609
+ }
610
+ if (this.open) {
611
+ this.rememberFocus();
612
+ this.openModalAnimation();
613
+ }
614
+ }
615
+ componentDidRender() {
616
+ if (this.shouldFocusOnRender && this.renderedOpen) {
617
+ this.shouldFocusOnRender = false;
618
+ this.focusFirstElement();
619
+ }
620
+ }
621
+ rememberFocus() {
622
+ var _a;
623
+ if (typeof document === 'undefined') {
624
+ return;
625
+ }
626
+ const active = getDeepActiveElement(document);
627
+ // Ignore focus that is already inside the modal and the default document focus
628
+ if (active === null || active === document.body || this.el.contains(active) || ((_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.contains(active)) === true) {
629
+ return;
630
+ }
631
+ this.returnFocusElement = active;
632
+ }
633
+ restoreFocus() {
634
+ const target = this.returnFocusElement;
635
+ this.returnFocusElement = null;
636
+ if (target != null && target.isConnected && typeof target.focus === 'function') {
637
+ target.focus();
638
+ }
639
+ }
640
+ getTabbableElements() {
641
+ if (this.dialogElement === undefined) {
642
+ return [];
643
+ }
644
+ return getTabbableElements(this.dialogElement).filter(element => !element.classList.contains('focus-guard'));
645
+ }
646
+ isInsideModal(node) {
647
+ var _a;
648
+ return node !== null && (this.el.contains(node) || ((_a = this.dialogElement) === null || _a === void 0 ? void 0 : _a.contains(node)) === true);
649
+ }
650
+ getFocusOrigin(event) {
651
+ var _a;
652
+ return (_a = event.relatedTarget) !== null && _a !== void 0 ? _a : this.lastFocusedInside;
653
+ }
654
+ /**
655
+ * Whether focus came from a focusable element inside the modal (not from the container itself or from outside).
656
+ * The guards use it to tell Tab from Shift+Tab: a guard cannot see the key, but it can see where focus came from.
657
+ */
658
+ cameFromFocusableInside(event) {
659
+ const from = this.getFocusOrigin(event);
660
+ return from !== this.dialogElement && this.isInsideModal(from);
661
+ }
662
+ /**
663
+ * Slotted content is hidden (and therefore not focusable) while the open transition runs.
664
+ * When it ends, move focus from the placeholder (container / close button) into the content, unless the user already moved it.
665
+ */
666
+ focusContentAfterLoading() {
667
+ var _a;
668
+ if (!this.open || this.contentElement === undefined) {
669
+ return;
670
+ }
671
+ const active = getDeepActiveElement(document);
672
+ const focusIsIdle = active === null || active === document.body || active === this.dialogElement || active === this.closeButtonElement;
673
+ if (!focusIsIdle) {
674
+ return;
675
+ }
676
+ (_a = getTabbableElements(this.contentElement)[0]) === null || _a === void 0 ? void 0 : _a.focus();
677
+ }
678
+ focusFirstElement() {
679
+ var _a;
680
+ const [first] = this.getTabbableElements();
681
+ (_a = (first !== null && first !== void 0 ? first : this.dialogElement)) === null || _a === void 0 ? void 0 : _a.focus();
682
+ }
683
+ focusLastElement() {
684
+ var _a, _b;
685
+ const elements = this.getTabbableElements();
686
+ (_b = ((_a = elements[elements.length - 1]) !== null && _a !== void 0 ? _a : this.dialogElement)) === null || _b === void 0 ? void 0 : _b.focus();
687
+ }
688
+ openModalAnimation() {
689
+ this.shouldFocusOnRender = true;
690
+ if (!this.el.shadowRoot) {
691
+ this.renderedOpen = true;
692
+ return;
693
+ }
694
+ const modalChild = this.el.shadowRoot.querySelector('.modal-child');
695
+ // The panel stays in the DOM while closed and keeps its scroll position; start each opening at the top (title, close button)
696
+ modalChild.scrollTop = 0;
697
+ modalChild.classList.add('loading');
698
+ modalChild.style.willChange = 'transform';
699
+ modalChild.addEventListener('transitionend', () => {
700
+ modalChild.style.willChange = 'auto';
701
+ modalChild.classList.remove('loading');
702
+ this.focusContentAfterLoading();
703
+ }, { once: true });
704
+ requestAnimationFrame(() => {
705
+ this.renderedOpen = this.open;
706
+ });
707
+ }
708
+ render() {
709
+ const { renderedOpen, showCloseButton } = this;
710
+ const guardTabIndex = renderedOpen ? 0 : -1;
711
+ return (h(Host, { key: '55e0d63b18df165313ea3dd8b8f17aa0e0d0a253', role: renderedOpen ? 'dialog' : undefined, "aria-modal": renderedOpen ? 'true' : undefined, onKeyDown: this.handleKeyDown, onFocusin: this.handleFocusIn }, h("div", { key: 'adb0b493c0ae525f275025c03e1b8f02b04de1af', class: `modal-row${renderedOpen ? ' open' : ''}`, onClick: () => this.closeModal() }, h("div", { key: '478bdad2ad481bfc2d8ffcf552788292fa93daed', class: "modal-child", tabindex: "-1", ref: el => (this.dialogElement = el), onClick: e => e.stopPropagation() }, h("div", { key: '8cc68ecefa37ec1db65f6c910d1da40f9144e722', class: "focus-guard", tabindex: guardTabIndex, onFocus: this.handleStartGuardFocus }), showCloseButton ? (h("div", { class: "modal-close-button-wrap" }, h("button", { type: "button", class: "modal-close-button", "aria-label": i18n.t('Close'), ref: el => (this.closeButtonElement = el), onClick: () => this.closeModal() }, h("ion-icon", { name: "close", size: "large", "aria-hidden": "true" })))) : null, h("div", { key: '26271a75906a72e9944599f98da007bfebc2e348', class: "modal-loading" }, h("svg", { key: 'bc6b1267e2f3b6b1dd7209db55be717fddf9acd4', version: "1.1", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 2400 2400" }, h("g", { key: '00ed54798ac376ed71f87a088fad2519cb1262dc', "stroke-width": "200", "stroke-linecap": "round", stroke: "currentColor", fill: "none", id: "spinner" }, h("line", { key: '98242d65eb9470430bd5cc656cbb479232782746', x1: "1200", y1: "600", x2: "1200", y2: "100" }), h("line", { key: '2e2f0538a6d048465ef5f8a3d5ed1932f6c59270', opacity: "0.5", x1: "1200", y1: "2300", x2: "1200", y2: "1800" }), h("line", { key: '11f850b0e7dc0d259f35f56aab17068d4d25ca95', opacity: "0.917", x1: "900", y1: "680.4", x2: "650", y2: "247.4" }), h("line", { key: '14c3226b5d2741902f428a208966adf016c1bb7e', opacity: "0.417", x1: "1750", y1: "2152.6", x2: "1500", y2: "1719.6" }), h("line", { key: 'd41da322484b62c1db1df72b9bd1bcc0dbb85a2c', opacity: "0.833", x1: "680.4", y1: "900", x2: "247.4", y2: "650" }), h("line", { key: '246dcdd4a011775dc8fea8a05cfcfc429d5bd03c', opacity: "0.333", x1: "2152.6", y1: "1750", x2: "1719.6", y2: "1500" }), h("line", { key: 'f0a2d217a33a8caa6995a30d840002cb8c076e8d', opacity: "0.75", x1: "600", y1: "1200", x2: "100", y2: "1200" }), h("line", { key: '7552fb2c04f85c54b8bcc2235a32690e4489177f', opacity: "0.25", x1: "2300", y1: "1200", x2: "1800", y2: "1200" }), h("line", { key: '7b5a62164a0ef759b057f9100c7c5af834c9f6b7', opacity: "0.667", x1: "680.4", y1: "1500", x2: "247.4", y2: "1750" }), h("line", { key: 'd36af9d23059da4ca91147084e47ba94e19f5ada', opacity: "0.167", x1: "2152.6", y1: "650", x2: "1719.6", y2: "900" }), h("line", { key: 'f8eed2a97d817b68e0b29f5b5037d34d46a79a46', opacity: "0.583", x1: "900", y1: "1719.6", x2: "650", y2: "2152.6" }), h("line", { key: '1641d577b703e213157bc553966e434a40ba7158', opacity: "0.083", x1: "1750", y1: "247.4", x2: "1500", y2: "680.4" }), h("animateTransform", { key: '60fb2d30c248db1b4195d6015dc96225a15e4010', attributeName: "transform", attributeType: "XML", type: "rotate", keyTimes: "0;0.08333;0.16667;0.25;0.33333;0.41667;0.5;0.58333;0.66667;0.75;0.83333;0.91667", values: "0 1199 1199;30 1199 1199;60 1199 1199;90 1199 1199;120 1199 1199;150 1199 1199;180 1199 1199;210 1199 1199;240 1199 1199;270 1199 1199;300 1199 1199;330 1199 1199", dur: "0.83333s", begin: "0s", repeatCount: "indefinite", calcMode: "discrete" })))), h("div", { key: '27d3b71da43e5935dff3eff2e1bc507a24261b70', class: "modal-content", ref: el => (this.contentElement = el) }, h("slot", { key: '641408238d3969b830d1f3e9398be6f05bc1f65b' })), h("div", { key: 'c6178542b98a99d6a50b74270adc273671d5cc19', class: "focus-guard", tabindex: guardTabIndex, onFocus: this.handleEndGuardFocus })))));
712
+ }
713
+ get el() { return getElement(this); }
714
+ static get watchers() { return {
715
+ "open": [{
716
+ "onOpenChange": 0
717
+ }]
718
+ }; }
719
+ };
720
+ StripeModal.style = stripeModalCss();
721
+
722
+ export { Icon as ion_icon, StripeModal as stripe_modal };