pushfeedback 0.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/feedback-button_2.cjs.entry.js +1024 -0
  3. package/dist/cjs/index-ecaab1ef.js +1466 -0
  4. package/dist/cjs/index.cjs.js +2 -0
  5. package/dist/cjs/loader.cjs.js +21 -0
  6. package/dist/cjs/pushfeedback.cjs.js +19 -0
  7. package/dist/collection/collection-manifest.json +13 -0
  8. package/dist/collection/components/feedback-button/feedback-button.css +16 -0
  9. package/dist/collection/components/feedback-button/feedback-button.js +263 -0
  10. package/dist/collection/components/feedback-modal/feedback-modal.css +209 -0
  11. package/dist/collection/components/feedback-modal/feedback-modal.js +462 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/components/feedback-button.d.ts +11 -0
  14. package/dist/components/feedback-button.js +88 -0
  15. package/dist/components/feedback-modal.d.ts +11 -0
  16. package/dist/components/feedback-modal.js +6 -0
  17. package/dist/components/feedback-modal2.js +1007 -0
  18. package/dist/components/index.d.ts +23 -0
  19. package/dist/components/index.js +3 -0
  20. package/dist/esm/feedback-button_2.entry.js +1019 -0
  21. package/dist/esm/index-4051fc1e.js +1440 -0
  22. package/dist/esm/index.js +1 -0
  23. package/dist/esm/loader.js +17 -0
  24. package/dist/esm/polyfills/core-js.js +11 -0
  25. package/dist/esm/polyfills/css-shim.js +1 -0
  26. package/dist/esm/polyfills/dom.js +79 -0
  27. package/dist/esm/polyfills/es5-html-element.js +1 -0
  28. package/dist/esm/polyfills/index.js +34 -0
  29. package/dist/esm/polyfills/system.js +6 -0
  30. package/dist/esm/pushfeedback.js +17 -0
  31. package/dist/index.cjs.js +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/pushfeedback/index.esm.js +0 -0
  34. package/dist/pushfeedback/p-a5896889.entry.js +1 -0
  35. package/dist/pushfeedback/p-e53ad7c2.js +2 -0
  36. package/dist/pushfeedback/pushfeedback.css +1 -0
  37. package/dist/pushfeedback/pushfeedback.esm.js +1 -0
  38. package/dist/types/components/feedback-button/feedback-button.d.ts +18 -0
  39. package/dist/types/components/feedback-modal/feedback-modal.d.ts +40 -0
  40. package/dist/types/components.d.ts +100 -0
  41. package/dist/types/index.d.ts +1 -0
  42. package/dist/types/stencil-public-runtime.d.ts +1581 -0
  43. package/loader/cdn.js +3 -0
  44. package/loader/index.cjs.js +3 -0
  45. package/loader/index.d.ts +12 -0
  46. package/loader/index.es2017.js +3 -0
  47. package/loader/index.js +4 -0
  48. package/loader/package.json +11 -0
  49. package/package.json +39 -0
  50. package/readme.md +75 -0
@@ -0,0 +1,1019 @@
1
+ import { r as registerInstance, h, H as Host } from './index-4051fc1e.js';
2
+
3
+ const feedbackButtonCss = ".feedback-button-content{cursor:pointer;background-color:var(--feedback-button-bg-color);border:1px solid var(--feedback-button-border-color);border-radius:var(--feedback-button-border-radius);color:var(--feedback-button-text-color);cursor:pointer;font-size:var(--feedback-modal-button-font-size);padding:5px 10px}.feedback-button-content:hover{color:var(--feedback-button-text-color-active);background-color:var(--feedback-button-bg-color-active);border:1px solid var(--feedback-button-border-color-active)}";
4
+
5
+ const FeedbackButton = class {
6
+ constructor(hostRef) {
7
+ registerInstance(this, hostRef);
8
+ this.feedbackModal = undefined;
9
+ this.modalTitle = 'Share your feedback';
10
+ this.successModalTitle = 'Thanks for your feedback!';
11
+ this.errorModalTitle = "Oops! We didn't receive your feedback. Please try again later.";
12
+ this.modalPosition = 'center';
13
+ this.sendButtonText = 'Send';
14
+ this.project = '';
15
+ this.screenshotButtonTooltipText = 'Take a Screenshot';
16
+ this.screenshotTopbarText = 'SELECT AN ELEMENT ON THE PAGE';
17
+ this.email = '';
18
+ this.emailPlaceholder = 'Email address (optional)';
19
+ this.messagePlaceholder = 'How could this page be more helpful?';
20
+ }
21
+ componentDidLoad() {
22
+ this.feedbackModal.showModal = false;
23
+ }
24
+ showModal() {
25
+ this.feedbackModal.showModal = true;
26
+ }
27
+ render() {
28
+ const propKeys = [
29
+ 'modalTitle',
30
+ 'successModalTitle',
31
+ 'errorModalTitle',
32
+ 'modalPosition',
33
+ 'sendButtonText',
34
+ 'project',
35
+ 'screenshotButtonTooltipText',
36
+ 'screenshotTopbarText',
37
+ 'email',
38
+ 'emailPlaceholder',
39
+ 'messagePlaceholder',
40
+ 'showModal',
41
+ ];
42
+ let feedbackModalProps = {};
43
+ propKeys.forEach((key) => {
44
+ feedbackModalProps[key] = this[key];
45
+ });
46
+ return (h(Host, null, h("a", { class: "feedback-button-content", onClick: () => this.showModal() }, h("slot", null)), h("feedback-modal", Object.assign({}, feedbackModalProps, { ref: (el) => this.feedbackModal = el }))));
47
+ }
48
+ };
49
+ FeedbackButton.style = feedbackButtonCss;
50
+
51
+ function createCommonjsModule(fn, basedir, module) {
52
+ return module = {
53
+ path: basedir,
54
+ exports: {},
55
+ require: function (path, base) {
56
+ return commonjsRequire();
57
+ }
58
+ }, fn(module, module.exports), module.exports;
59
+ }
60
+
61
+ function commonjsRequire () {
62
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
63
+ }
64
+
65
+ var domToImage = createCommonjsModule(function (module) {
66
+ (function (global) {
67
+
68
+ var util = newUtil();
69
+ var inliner = newInliner();
70
+ var fontFaces = newFontFaces();
71
+ var images = newImages();
72
+
73
+ // Default impl options
74
+ var defaultOptions = {
75
+ // Default is to fail on error, no placeholder
76
+ imagePlaceholder: undefined,
77
+ // Default cache bust is false, it will use the cache
78
+ cacheBust: false
79
+ };
80
+
81
+ var domtoimage = {
82
+ toSvg: toSvg,
83
+ toPng: toPng,
84
+ toJpeg: toJpeg,
85
+ toBlob: toBlob,
86
+ toPixelData: toPixelData,
87
+ impl: {
88
+ fontFaces: fontFaces,
89
+ images: images,
90
+ util: util,
91
+ inliner: inliner,
92
+ options: {}
93
+ }
94
+ };
95
+
96
+ module.exports = domtoimage;
97
+
98
+
99
+ /**
100
+ * @param {Node} node - The DOM Node object to render
101
+ * @param {Object} options - Rendering options
102
+ * @param {Function} options.filter - Should return true if passed node should be included in the output
103
+ * (excluding node means excluding it's children as well). Not called on the root node.
104
+ * @param {String} options.bgcolor - color for the background, any valid CSS color value.
105
+ * @param {Number} options.width - width to be applied to node before rendering.
106
+ * @param {Number} options.height - height to be applied to node before rendering.
107
+ * @param {Object} options.style - an object whose properties to be copied to node's style before rendering.
108
+ * @param {Number} options.quality - a Number between 0 and 1 indicating image quality (applicable to JPEG only),
109
+ defaults to 1.0.
110
+ * @param {String} options.imagePlaceholder - dataURL to use as a placeholder for failed images, default behaviour is to fail fast on images we can't fetch
111
+ * @param {Boolean} options.cacheBust - set to true to cache bust by appending the time to the request url
112
+ * @return {Promise} - A promise that is fulfilled with a SVG image data URL
113
+ * */
114
+ function toSvg(node, options) {
115
+ options = options || {};
116
+ copyOptions(options);
117
+ return Promise.resolve(node)
118
+ .then(function (node) {
119
+ return cloneNode(node, options.filter, true);
120
+ })
121
+ .then(embedFonts)
122
+ .then(inlineImages)
123
+ .then(applyOptions)
124
+ .then(function (clone) {
125
+ return makeSvgDataUri(clone,
126
+ options.width || util.width(node),
127
+ options.height || util.height(node)
128
+ );
129
+ });
130
+
131
+ function applyOptions(clone) {
132
+ if (options.bgcolor) clone.style.backgroundColor = options.bgcolor;
133
+
134
+ if (options.width) clone.style.width = options.width + 'px';
135
+ if (options.height) clone.style.height = options.height + 'px';
136
+
137
+ if (options.style)
138
+ Object.keys(options.style).forEach(function (property) {
139
+ clone.style[property] = options.style[property];
140
+ });
141
+
142
+ return clone;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * @param {Node} node - The DOM Node object to render
148
+ * @param {Object} options - Rendering options, @see {@link toSvg}
149
+ * @return {Promise} - A promise that is fulfilled with a Uint8Array containing RGBA pixel data.
150
+ * */
151
+ function toPixelData(node, options) {
152
+ return draw(node, options || {})
153
+ .then(function (canvas) {
154
+ return canvas.getContext('2d').getImageData(
155
+ 0,
156
+ 0,
157
+ util.width(node),
158
+ util.height(node)
159
+ ).data;
160
+ });
161
+ }
162
+
163
+ /**
164
+ * @param {Node} node - The DOM Node object to render
165
+ * @param {Object} options - Rendering options, @see {@link toSvg}
166
+ * @return {Promise} - A promise that is fulfilled with a PNG image data URL
167
+ * */
168
+ function toPng(node, options) {
169
+ return draw(node, options || {})
170
+ .then(function (canvas) {
171
+ return canvas.toDataURL();
172
+ });
173
+ }
174
+
175
+ /**
176
+ * @param {Node} node - The DOM Node object to render
177
+ * @param {Object} options - Rendering options, @see {@link toSvg}
178
+ * @return {Promise} - A promise that is fulfilled with a JPEG image data URL
179
+ * */
180
+ function toJpeg(node, options) {
181
+ options = options || {};
182
+ return draw(node, options)
183
+ .then(function (canvas) {
184
+ return canvas.toDataURL('image/jpeg', options.quality || 1.0);
185
+ });
186
+ }
187
+
188
+ /**
189
+ * @param {Node} node - The DOM Node object to render
190
+ * @param {Object} options - Rendering options, @see {@link toSvg}
191
+ * @return {Promise} - A promise that is fulfilled with a PNG image blob
192
+ * */
193
+ function toBlob(node, options) {
194
+ return draw(node, options || {})
195
+ .then(util.canvasToBlob);
196
+ }
197
+
198
+ function copyOptions(options) {
199
+ // Copy options to impl options for use in impl
200
+ if(typeof(options.imagePlaceholder) === 'undefined') {
201
+ domtoimage.impl.options.imagePlaceholder = defaultOptions.imagePlaceholder;
202
+ } else {
203
+ domtoimage.impl.options.imagePlaceholder = options.imagePlaceholder;
204
+ }
205
+
206
+ if(typeof(options.cacheBust) === 'undefined') {
207
+ domtoimage.impl.options.cacheBust = defaultOptions.cacheBust;
208
+ } else {
209
+ domtoimage.impl.options.cacheBust = options.cacheBust;
210
+ }
211
+ }
212
+
213
+ function draw(domNode, options) {
214
+ return toSvg(domNode, options)
215
+ .then(util.makeImage)
216
+ .then(util.delay(100))
217
+ .then(function (image) {
218
+ var canvas = newCanvas(domNode);
219
+ canvas.getContext('2d').drawImage(image, 0, 0);
220
+ return canvas;
221
+ });
222
+
223
+ function newCanvas(domNode) {
224
+ var canvas = document.createElement('canvas');
225
+ canvas.width = options.width || util.width(domNode);
226
+ canvas.height = options.height || util.height(domNode);
227
+
228
+ if (options.bgcolor) {
229
+ var ctx = canvas.getContext('2d');
230
+ ctx.fillStyle = options.bgcolor;
231
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
232
+ }
233
+
234
+ return canvas;
235
+ }
236
+ }
237
+
238
+ function cloneNode(node, filter, root) {
239
+ if (!root && filter && !filter(node)) return Promise.resolve();
240
+
241
+ return Promise.resolve(node)
242
+ .then(makeNodeCopy)
243
+ .then(function (clone) {
244
+ return cloneChildren(node, clone, filter);
245
+ })
246
+ .then(function (clone) {
247
+ return processClone(node, clone);
248
+ });
249
+
250
+ function makeNodeCopy(node) {
251
+ if (node instanceof HTMLCanvasElement) return util.makeImage(node.toDataURL());
252
+ return node.cloneNode(false);
253
+ }
254
+
255
+ function cloneChildren(original, clone, filter) {
256
+ var children = original.childNodes;
257
+ if (children.length === 0) return Promise.resolve(clone);
258
+
259
+ return cloneChildrenInOrder(clone, util.asArray(children), filter)
260
+ .then(function () {
261
+ return clone;
262
+ });
263
+
264
+ function cloneChildrenInOrder(parent, children, filter) {
265
+ var done = Promise.resolve();
266
+ children.forEach(function (child) {
267
+ done = done
268
+ .then(function () {
269
+ return cloneNode(child, filter);
270
+ })
271
+ .then(function (childClone) {
272
+ if (childClone) parent.appendChild(childClone);
273
+ });
274
+ });
275
+ return done;
276
+ }
277
+ }
278
+
279
+ function processClone(original, clone) {
280
+ if (!(clone instanceof Element)) return clone;
281
+
282
+ return Promise.resolve()
283
+ .then(cloneStyle)
284
+ .then(clonePseudoElements)
285
+ .then(copyUserInput)
286
+ .then(fixSvg)
287
+ .then(function () {
288
+ return clone;
289
+ });
290
+
291
+ function cloneStyle() {
292
+ copyStyle(window.getComputedStyle(original), clone.style);
293
+
294
+ function copyStyle(source, target) {
295
+ if (source.cssText) target.cssText = source.cssText;
296
+ else copyProperties(source, target);
297
+
298
+ function copyProperties(source, target) {
299
+ util.asArray(source).forEach(function (name) {
300
+ target.setProperty(
301
+ name,
302
+ source.getPropertyValue(name),
303
+ source.getPropertyPriority(name)
304
+ );
305
+ });
306
+ }
307
+ }
308
+ }
309
+
310
+ function clonePseudoElements() {
311
+ [':before', ':after'].forEach(function (element) {
312
+ clonePseudoElement(element);
313
+ });
314
+
315
+ function clonePseudoElement(element) {
316
+ var style = window.getComputedStyle(original, element);
317
+ var content = style.getPropertyValue('content');
318
+
319
+ if (content === '' || content === 'none') return;
320
+
321
+ var className = util.uid();
322
+ clone.className = clone.className + ' ' + className;
323
+ var styleElement = document.createElement('style');
324
+ styleElement.appendChild(formatPseudoElementStyle(className, element, style));
325
+ clone.appendChild(styleElement);
326
+
327
+ function formatPseudoElementStyle(className, element, style) {
328
+ var selector = '.' + className + ':' + element;
329
+ var cssText = style.cssText ? formatCssText(style) : formatCssProperties(style);
330
+ return document.createTextNode(selector + '{' + cssText + '}');
331
+
332
+ function formatCssText(style) {
333
+ var content = style.getPropertyValue('content');
334
+ return style.cssText + ' content: ' + content + ';';
335
+ }
336
+
337
+ function formatCssProperties(style) {
338
+
339
+ return util.asArray(style)
340
+ .map(formatProperty)
341
+ .join('; ') + ';';
342
+
343
+ function formatProperty(name) {
344
+ return name + ': ' +
345
+ style.getPropertyValue(name) +
346
+ (style.getPropertyPriority(name) ? ' !important' : '');
347
+ }
348
+ }
349
+ }
350
+ }
351
+ }
352
+
353
+ function copyUserInput() {
354
+ if (original instanceof HTMLTextAreaElement) clone.innerHTML = original.value;
355
+ if (original instanceof HTMLInputElement) clone.setAttribute("value", original.value);
356
+ }
357
+
358
+ function fixSvg() {
359
+ if (!(clone instanceof SVGElement)) return;
360
+ clone.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
361
+
362
+ if (!(clone instanceof SVGRectElement)) return;
363
+ ['width', 'height'].forEach(function (attribute) {
364
+ var value = clone.getAttribute(attribute);
365
+ if (!value) return;
366
+
367
+ clone.style.setProperty(attribute, value);
368
+ });
369
+ }
370
+ }
371
+ }
372
+
373
+ function embedFonts(node) {
374
+ return fontFaces.resolveAll()
375
+ .then(function (cssText) {
376
+ var styleNode = document.createElement('style');
377
+ node.appendChild(styleNode);
378
+ styleNode.appendChild(document.createTextNode(cssText));
379
+ return node;
380
+ });
381
+ }
382
+
383
+ function inlineImages(node) {
384
+ return images.inlineAll(node)
385
+ .then(function () {
386
+ return node;
387
+ });
388
+ }
389
+
390
+ function makeSvgDataUri(node, width, height) {
391
+ return Promise.resolve(node)
392
+ .then(function (node) {
393
+ node.setAttribute('xmlns', 'http://www.w3.org/1999/xhtml');
394
+ return new XMLSerializer().serializeToString(node);
395
+ })
396
+ .then(util.escapeXhtml)
397
+ .then(function (xhtml) {
398
+ return '<foreignObject x="0" y="0" width="100%" height="100%">' + xhtml + '</foreignObject>';
399
+ })
400
+ .then(function (foreignObject) {
401
+ return '<svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '">' +
402
+ foreignObject + '</svg>';
403
+ })
404
+ .then(function (svg) {
405
+ return 'data:image/svg+xml;charset=utf-8,' + svg;
406
+ });
407
+ }
408
+
409
+ function newUtil() {
410
+ return {
411
+ escape: escape,
412
+ parseExtension: parseExtension,
413
+ mimeType: mimeType,
414
+ dataAsUrl: dataAsUrl,
415
+ isDataUrl: isDataUrl,
416
+ canvasToBlob: canvasToBlob,
417
+ resolveUrl: resolveUrl,
418
+ getAndEncode: getAndEncode,
419
+ uid: uid(),
420
+ delay: delay,
421
+ asArray: asArray,
422
+ escapeXhtml: escapeXhtml,
423
+ makeImage: makeImage,
424
+ width: width,
425
+ height: height
426
+ };
427
+
428
+ function mimes() {
429
+ /*
430
+ * Only WOFF and EOT mime types for fonts are 'real'
431
+ * see http://www.iana.org/assignments/media-types/media-types.xhtml
432
+ */
433
+ var WOFF = 'application/font-woff';
434
+ var JPEG = 'image/jpeg';
435
+
436
+ return {
437
+ 'woff': WOFF,
438
+ 'woff2': WOFF,
439
+ 'ttf': 'application/font-truetype',
440
+ 'eot': 'application/vnd.ms-fontobject',
441
+ 'png': 'image/png',
442
+ 'jpg': JPEG,
443
+ 'jpeg': JPEG,
444
+ 'gif': 'image/gif',
445
+ 'tiff': 'image/tiff',
446
+ 'svg': 'image/svg+xml'
447
+ };
448
+ }
449
+
450
+ function parseExtension(url) {
451
+ var match = /\.([^\.\/]*?)$/g.exec(url);
452
+ if (match) return match[1];
453
+ else return '';
454
+ }
455
+
456
+ function mimeType(url) {
457
+ var extension = parseExtension(url).toLowerCase();
458
+ return mimes()[extension] || '';
459
+ }
460
+
461
+ function isDataUrl(url) {
462
+ return url.search(/^(data:)/) !== -1;
463
+ }
464
+
465
+ function toBlob(canvas) {
466
+ return new Promise(function (resolve) {
467
+ var binaryString = window.atob(canvas.toDataURL().split(',')[1]);
468
+ var length = binaryString.length;
469
+ var binaryArray = new Uint8Array(length);
470
+
471
+ for (var i = 0; i < length; i++)
472
+ binaryArray[i] = binaryString.charCodeAt(i);
473
+
474
+ resolve(new Blob([binaryArray], {
475
+ type: 'image/png'
476
+ }));
477
+ });
478
+ }
479
+
480
+ function canvasToBlob(canvas) {
481
+ if (canvas.toBlob)
482
+ return new Promise(function (resolve) {
483
+ canvas.toBlob(resolve);
484
+ });
485
+
486
+ return toBlob(canvas);
487
+ }
488
+
489
+ function resolveUrl(url, baseUrl) {
490
+ var doc = document.implementation.createHTMLDocument();
491
+ var base = doc.createElement('base');
492
+ doc.head.appendChild(base);
493
+ var a = doc.createElement('a');
494
+ doc.body.appendChild(a);
495
+ base.href = baseUrl;
496
+ a.href = url;
497
+ return a.href;
498
+ }
499
+
500
+ function uid() {
501
+ var index = 0;
502
+
503
+ return function () {
504
+ return 'u' + fourRandomChars() + index++;
505
+
506
+ function fourRandomChars() {
507
+ /* see http://stackoverflow.com/a/6248722/2519373 */
508
+ return ('0000' + (Math.random() * Math.pow(36, 4) << 0).toString(36)).slice(-4);
509
+ }
510
+ };
511
+ }
512
+
513
+ function makeImage(uri) {
514
+ return new Promise(function (resolve, reject) {
515
+ var image = new Image();
516
+ image.onload = function () {
517
+ resolve(image);
518
+ };
519
+ image.onerror = reject;
520
+ image.src = uri;
521
+ });
522
+ }
523
+
524
+ function getAndEncode(url) {
525
+ var TIMEOUT = 30000;
526
+ if(domtoimage.impl.options.cacheBust) {
527
+ // Cache bypass so we dont have CORS issues with cached images
528
+ // Source: https://developer.mozilla.org/en/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest#Bypassing_the_cache
529
+ url += ((/\?/).test(url) ? "&" : "?") + (new Date()).getTime();
530
+ }
531
+
532
+ return new Promise(function (resolve) {
533
+ var request = new XMLHttpRequest();
534
+
535
+ request.onreadystatechange = done;
536
+ request.ontimeout = timeout;
537
+ request.responseType = 'blob';
538
+ request.timeout = TIMEOUT;
539
+ request.open('GET', url, true);
540
+ request.send();
541
+
542
+ var placeholder;
543
+ if(domtoimage.impl.options.imagePlaceholder) {
544
+ var split = domtoimage.impl.options.imagePlaceholder.split(/,/);
545
+ if(split && split[1]) {
546
+ placeholder = split[1];
547
+ }
548
+ }
549
+
550
+ function done() {
551
+ if (request.readyState !== 4) return;
552
+
553
+ if (request.status !== 200) {
554
+ if(placeholder) {
555
+ resolve(placeholder);
556
+ } else {
557
+ fail('cannot fetch resource: ' + url + ', status: ' + request.status);
558
+ }
559
+
560
+ return;
561
+ }
562
+
563
+ var encoder = new FileReader();
564
+ encoder.onloadend = function () {
565
+ var content = encoder.result.split(/,/)[1];
566
+ resolve(content);
567
+ };
568
+ encoder.readAsDataURL(request.response);
569
+ }
570
+
571
+ function timeout() {
572
+ if(placeholder) {
573
+ resolve(placeholder);
574
+ } else {
575
+ fail('timeout of ' + TIMEOUT + 'ms occured while fetching resource: ' + url);
576
+ }
577
+ }
578
+
579
+ function fail(message) {
580
+ console.error(message);
581
+ resolve('');
582
+ }
583
+ });
584
+ }
585
+
586
+ function dataAsUrl(content, type) {
587
+ return 'data:' + type + ';base64,' + content;
588
+ }
589
+
590
+ function escape(string) {
591
+ return string.replace(/([.*+?^${}()|\[\]\/\\])/g, '\\$1');
592
+ }
593
+
594
+ function delay(ms) {
595
+ return function (arg) {
596
+ return new Promise(function (resolve) {
597
+ setTimeout(function () {
598
+ resolve(arg);
599
+ }, ms);
600
+ });
601
+ };
602
+ }
603
+
604
+ function asArray(arrayLike) {
605
+ var array = [];
606
+ var length = arrayLike.length;
607
+ for (var i = 0; i < length; i++) array.push(arrayLike[i]);
608
+ return array;
609
+ }
610
+
611
+ function escapeXhtml(string) {
612
+ return string.replace(/#/g, '%23').replace(/\n/g, '%0A');
613
+ }
614
+
615
+ function width(node) {
616
+ var leftBorder = px(node, 'border-left-width');
617
+ var rightBorder = px(node, 'border-right-width');
618
+ return node.scrollWidth + leftBorder + rightBorder;
619
+ }
620
+
621
+ function height(node) {
622
+ var topBorder = px(node, 'border-top-width');
623
+ var bottomBorder = px(node, 'border-bottom-width');
624
+ return node.scrollHeight + topBorder + bottomBorder;
625
+ }
626
+
627
+ function px(node, styleProperty) {
628
+ var value = window.getComputedStyle(node).getPropertyValue(styleProperty);
629
+ return parseFloat(value.replace('px', ''));
630
+ }
631
+ }
632
+
633
+ function newInliner() {
634
+ var URL_REGEX = /url\(['"]?([^'"]+?)['"]?\)/g;
635
+
636
+ return {
637
+ inlineAll: inlineAll,
638
+ shouldProcess: shouldProcess,
639
+ impl: {
640
+ readUrls: readUrls,
641
+ inline: inline
642
+ }
643
+ };
644
+
645
+ function shouldProcess(string) {
646
+ return string.search(URL_REGEX) !== -1;
647
+ }
648
+
649
+ function readUrls(string) {
650
+ var result = [];
651
+ var match;
652
+ while ((match = URL_REGEX.exec(string)) !== null) {
653
+ result.push(match[1]);
654
+ }
655
+ return result.filter(function (url) {
656
+ return !util.isDataUrl(url);
657
+ });
658
+ }
659
+
660
+ function inline(string, url, baseUrl, get) {
661
+ return Promise.resolve(url)
662
+ .then(function (url) {
663
+ return baseUrl ? util.resolveUrl(url, baseUrl) : url;
664
+ })
665
+ .then(get || util.getAndEncode)
666
+ .then(function (data) {
667
+ return util.dataAsUrl(data, util.mimeType(url));
668
+ })
669
+ .then(function (dataUrl) {
670
+ return string.replace(urlAsRegex(url), '$1' + dataUrl + '$3');
671
+ });
672
+
673
+ function urlAsRegex(url) {
674
+ return new RegExp('(url\\([\'"]?)(' + util.escape(url) + ')([\'"]?\\))', 'g');
675
+ }
676
+ }
677
+
678
+ function inlineAll(string, baseUrl, get) {
679
+ if (nothingToInline()) return Promise.resolve(string);
680
+
681
+ return Promise.resolve(string)
682
+ .then(readUrls)
683
+ .then(function (urls) {
684
+ var done = Promise.resolve(string);
685
+ urls.forEach(function (url) {
686
+ done = done.then(function (string) {
687
+ return inline(string, url, baseUrl, get);
688
+ });
689
+ });
690
+ return done;
691
+ });
692
+
693
+ function nothingToInline() {
694
+ return !shouldProcess(string);
695
+ }
696
+ }
697
+ }
698
+
699
+ function newFontFaces() {
700
+ return {
701
+ resolveAll: resolveAll,
702
+ impl: {
703
+ readAll: readAll
704
+ }
705
+ };
706
+
707
+ function resolveAll() {
708
+ return readAll()
709
+ .then(function (webFonts) {
710
+ return Promise.all(
711
+ webFonts.map(function (webFont) {
712
+ return webFont.resolve();
713
+ })
714
+ );
715
+ })
716
+ .then(function (cssStrings) {
717
+ return cssStrings.join('\n');
718
+ });
719
+ }
720
+
721
+ function readAll() {
722
+ return Promise.resolve(util.asArray(document.styleSheets))
723
+ .then(getCssRules)
724
+ .then(selectWebFontRules)
725
+ .then(function (rules) {
726
+ return rules.map(newWebFont);
727
+ });
728
+
729
+ function selectWebFontRules(cssRules) {
730
+ return cssRules
731
+ .filter(function (rule) {
732
+ return rule.type === CSSRule.FONT_FACE_RULE;
733
+ })
734
+ .filter(function (rule) {
735
+ return inliner.shouldProcess(rule.style.getPropertyValue('src'));
736
+ });
737
+ }
738
+
739
+ function getCssRules(styleSheets) {
740
+ var cssRules = [];
741
+ styleSheets.forEach(function (sheet) {
742
+ try {
743
+ util.asArray(sheet.cssRules || []).forEach(cssRules.push.bind(cssRules));
744
+ } catch (e) {
745
+ console.log('Error while reading CSS rules from ' + sheet.href, e.toString());
746
+ }
747
+ });
748
+ return cssRules;
749
+ }
750
+
751
+ function newWebFont(webFontRule) {
752
+ return {
753
+ resolve: function resolve() {
754
+ var baseUrl = (webFontRule.parentStyleSheet || {}).href;
755
+ return inliner.inlineAll(webFontRule.cssText, baseUrl);
756
+ },
757
+ src: function () {
758
+ return webFontRule.style.getPropertyValue('src');
759
+ }
760
+ };
761
+ }
762
+ }
763
+ }
764
+
765
+ function newImages() {
766
+ return {
767
+ inlineAll: inlineAll,
768
+ impl: {
769
+ newImage: newImage
770
+ }
771
+ };
772
+
773
+ function newImage(element) {
774
+ return {
775
+ inline: inline
776
+ };
777
+
778
+ function inline(get) {
779
+ if (util.isDataUrl(element.src)) return Promise.resolve();
780
+
781
+ return Promise.resolve(element.src)
782
+ .then(get || util.getAndEncode)
783
+ .then(function (data) {
784
+ return util.dataAsUrl(data, util.mimeType(element.src));
785
+ })
786
+ .then(function (dataUrl) {
787
+ return new Promise(function (resolve, reject) {
788
+ element.onload = resolve;
789
+ element.onerror = reject;
790
+ element.src = dataUrl;
791
+ });
792
+ });
793
+ }
794
+ }
795
+
796
+ function inlineAll(node) {
797
+ if (!(node instanceof Element)) return Promise.resolve(node);
798
+
799
+ return inlineBackground(node)
800
+ .then(function () {
801
+ if (node instanceof HTMLImageElement)
802
+ return newImage(node).inline();
803
+ else
804
+ return Promise.all(
805
+ util.asArray(node.childNodes).map(function (child) {
806
+ return inlineAll(child);
807
+ })
808
+ );
809
+ });
810
+
811
+ function inlineBackground(node) {
812
+ var background = node.style.getPropertyValue('background');
813
+
814
+ if (!background) return Promise.resolve(node);
815
+
816
+ return inliner.inlineAll(background)
817
+ .then(function (inlined) {
818
+ node.style.setProperty(
819
+ 'background',
820
+ inlined,
821
+ node.style.getPropertyPriority('background')
822
+ );
823
+ })
824
+ .then(function () {
825
+ return node;
826
+ });
827
+ }
828
+ }
829
+ }
830
+ })();
831
+ });
832
+
833
+ const feedbackModalCss = ".text-center{text-align:center;flex-grow:1}.feedback-modal{display:inline-block;position:relative}.feedback-modal-content{background-color:var(--feedback-modal-content-bg-color);border-color:1px solid var(--feedback-modal-header-text-color);border-radius:var(--feedback-modal-content-border-radius);box-shadow:0px 1px 2px 0px rgba(60, 64, 67, .30), 0px 2px 6px 2px rgba(60, 64, 67, .15);box-sizing:border-box;color:var(--feedback-modal-content-text-color);display:flex;flex-direction:column;font-family:var(--feedback-modal-content-font-family);max-width:300px;padding:20px;position:fixed;width:100%;z-index:300}.feedback-modal-content.feedback-modal-content--center{left:50%;top:50%;transform:translate(-50%, -50%)}.feedback-modal-content.feedback-modal-content--bottom-right{bottom:var(--feedback-modal-content-position-bottom);right:var(--feedback-modal-content-position-right)}.feedback-modal-content.feedback-modal-content--bottom-left{bottom:var(--feedback-modal-content-position-bottom);left:var(--feedback-modal-content-position-left)}.feedback-modal-content.feedback-modal-content--top-right{right:var(--feedback-modal-content-position-right);top:var(--fedback-modal-content-position-top)}.feedback-modal-content.feedback-modal-content--top-left{left:var(--feedback-modal-content-position-left);top:var(--fedback-modal-content-position-top)}.feedback-modal-header{align-items:center;color:var(--feedback-modal-header-text-color);font-family:var(--feedback-modal-header-font-family);display:flex;font-size:var(--feedback-header-font-size);justify-content:space-between;margin-bottom:20px}.feedback-modal-text{margin-bottom:20px}.feedback-modal-text textarea{border:1px solid var(--feedback-modal-input-border-color);border-radius:4px;box-sizing:border-box;font-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);height:100px;padding:10px;resize:none;width:100%}.feedback-modal-email{margin-bottom:20px}.feedback-modal-email input{border:1px solid var(--feedback-modal-input-border-color);border-radius:4px;box-sizing:border-box;font-family:var(--feedback-modal-content-font-family);font-size:var(--feedback-modal-input-font-size);height:40px;padding:10px;width:100%}.feedback-modal-text textarea:focus,.feedback-modal-email input:focus{border:1px solid var(--feedback-modal-input-border-color-focused);outline:none}.feedback-modal-buttons{display:flex;justify-content:space-between}.button{background-color:transparent;border:1px solid var(--feedback-modal-button-border-color);border-radius:var(--feedback-modal-button-border-radius);color:var(--feedback-modal-button-text-color);cursor:pointer;font-size:var(--feedback-modal-button-font-size);padding:5px 10px}.button:hover,.button.active{color:var(--feedback-modal-button-text-color-active);background-color:var(--feedback-modal-button-bg-color-active);border:1px solid var(--feedback-modal-button-border-color-active)}.feedback-modal-footer{font-size:12px;margin-top:5px 0;text-align:center}.feedback-modal-footer a{color:#191919;text-decoration:none}.feedback-logo{display:flex;align-items:center;justify-content:center;margin-top:5px}.feedback-logo svg{max-width:12px;margin-right:5px}.feedback-modal-close{background-color:var(--feedback-modal-close-bg-color);border:0;border-radius:50%;cursor:pointer;margin-left:auto;padding:0;width:24px;height:24px}.feedback-modal-screenshot{background-color:var(--feedback-modal-screenshot-bg-color);box-shadow:0px 0px 0px 5px var(--feedback-modal-screenshot-element-selected-bg-color) inset;height:100vh;left:0;position:fixed;top:0;width:100%;z-index:100}.feedback-modal-screenshot-header{align-items:center;background-color:var(--feedback-modal-screenshot-header-bg-color);color:var(--feedback-modal-screenshot-element-selected-text-color);cursor:pointer;display:flex;padding:5px;position:fixed;justify-content:center;width:100%;z-index:200}.feedback-modal-screenshot-header span{padding-left:10px;padding-right:10px}.feedback-modal-screenshot-overlay{background-color:transparent;cursor:unset;height:100vh;left:0;position:fixed;top:0;width:100%;z-index:100}.feedback-modal-message{font-size:var(--fedback-modal-message-font-size)}.feedback-modal-element-hover{cursor:pointer;background-color:transparent;border:4px dashed var(--feedback-modal-screenshot-element-hover-border-color)}.feedback-modal-element-selected{border:4px solid var(--feedback-modal-screenshot-element-selected-border-color)}";
834
+
835
+ const FeedbackModal = class {
836
+ constructor(hostRef) {
837
+ registerInstance(this, hostRef);
838
+ this.handleSubmit = async (event) => {
839
+ event.preventDefault();
840
+ this.showScreenshotMode = false;
841
+ this.showModal = false;
842
+ this.sending = true;
843
+ let encodedScreenshot = "";
844
+ if (this.encodedScreenshot) {
845
+ await this.encodedScreenshot.then((data) => {
846
+ encodedScreenshot = data;
847
+ }).catch((error) => {
848
+ console.log(error);
849
+ });
850
+ }
851
+ try {
852
+ const res = await fetch('https://app.pushfeedback.com/api/feedback/', {
853
+ method: 'POST',
854
+ body: JSON.stringify({
855
+ url: window.location.href,
856
+ message: this.formMessage,
857
+ email: this.formEmail,
858
+ project: this.project,
859
+ screenshot: encodedScreenshot
860
+ }),
861
+ headers: {
862
+ 'Content-Type': 'application/json'
863
+ }
864
+ });
865
+ if (res.status === 200) {
866
+ this.formSuccess = true;
867
+ this.formError = false;
868
+ }
869
+ else {
870
+ this.formSuccess = false;
871
+ this.formError = true;
872
+ }
873
+ }
874
+ catch (error) {
875
+ this.formSuccess = false;
876
+ this.formError = true;
877
+ }
878
+ finally {
879
+ this.sending = false;
880
+ this.showModal = true;
881
+ }
882
+ };
883
+ this.close = () => {
884
+ this.sending = false;
885
+ this.showModal = false;
886
+ this.showScreenshotMode = false;
887
+ this.hasSelectedElement = false;
888
+ this.encodedScreenshot = null;
889
+ this.formSuccess = false;
890
+ this.formError = false;
891
+ this.formMessage = '';
892
+ this.formEmail = '';
893
+ };
894
+ this.openScreenShot = () => {
895
+ this.hasSelectedElement = false;
896
+ this.showModal = false;
897
+ this.showScreenshotMode = true;
898
+ this.encodedScreenshot = null;
899
+ const page = document.getElementsByTagName('html')[0];
900
+ page.style.overflow = 'auto';
901
+ };
902
+ this.closeScreenShot = () => {
903
+ this.showModal = false;
904
+ this.showScreenshotMode = false;
905
+ this.hasSelectedElement = false;
906
+ this.encodedScreenshot = null;
907
+ this.overlay.style.display = 'none';
908
+ const page = document.getElementsByTagName('html')[0];
909
+ page.style.overflow = 'inherit';
910
+ };
911
+ this.handleMouseOverScreenShot = (event) => {
912
+ event.preventDefault();
913
+ if (this.hasSelectedElement)
914
+ return;
915
+ this.overlay.style.display = 'none';
916
+ this.screenshotModal.style.display = 'none';
917
+ const elementUnder = document.elementFromPoint(event.clientX, event.clientY);
918
+ const rect = elementUnder.getBoundingClientRect();
919
+ this.screenshotModal.style.display = '';
920
+ // Get the bounding box of the element selected
921
+ this.elementSelected.style.position = "absolute";
922
+ this.elementSelected.style.left = `${rect.left}px`;
923
+ this.elementSelected.style.top = `${rect.top}px`;
924
+ this.elementSelected.style.width = `${rect.width}px`;
925
+ this.elementSelected.style.height = `${rect.height}px`;
926
+ this.elementSelected.classList.add('feedback-modal-element-hover');
927
+ // Set the background color of nonselected areas
928
+ // Top
929
+ this.topSide.style.position = "absolute";
930
+ this.topSide.style.left = `${rect.left}px`;
931
+ this.topSide.style.top = '0px';
932
+ this.topSide.style.width = `${rect.width + 8}px`;
933
+ this.topSide.style.height = `${rect.top}px`;
934
+ this.topSide.style.backgroundColor = "rgba(0, 0, 0, 0.3)";
935
+ // Left
936
+ this.leftSide.style.position = "absolute";
937
+ this.leftSide.style.left = '0px';
938
+ this.leftSide.style.top = '0px';
939
+ this.leftSide.style.width = `${rect.left}px`;
940
+ this.leftSide.style.height = '100vh';
941
+ this.leftSide.style.backgroundColor = "rgba(0, 0, 0, 0.3)";
942
+ // Bottom
943
+ this.bottomSide.style.position = "absolute";
944
+ this.bottomSide.style.left = `${rect.left}px`;
945
+ this.bottomSide.style.top = `${rect.bottom + 8}px`;
946
+ this.bottomSide.style.width = `${rect.width + 8}px`;
947
+ this.bottomSide.style.height = '100vh';
948
+ this.bottomSide.style.backgroundColor = "rgba(0, 0, 0, 0.3)";
949
+ // Right
950
+ this.rightSide.style.position = "absolute";
951
+ this.rightSide.style.left = `${rect.right + 8}px`;
952
+ this.rightSide.style.top = '0px';
953
+ this.rightSide.style.width = '100%';
954
+ this.rightSide.style.height = '100vh';
955
+ this.rightSide.style.backgroundColor = "rgba(0, 0, 0, 0.3)";
956
+ // Restore the visibility of the screenshot-modal
957
+ this.screenshotModal.style.backgroundColor = 'transparent';
958
+ };
959
+ this.handleMouseClickedSelectedElement = (event) => {
960
+ event.preventDefault();
961
+ if (this.elementSelected)
962
+ this.elementSelected.classList.add('feedback-modal-element-selected');
963
+ let top = this.elementSelected.getBoundingClientRect().top;
964
+ this.elementSelected.style.top = `${top + window.pageYOffset}px`;
965
+ const clonedElementSelected = this.elementSelected.cloneNode(true);
966
+ document.body.appendChild(clonedElementSelected);
967
+ this.elementSelected.style.top = `${top}px`;
968
+ this.encodedScreenshot = domToImage.toPng(document.body, { cacheBust: true })
969
+ .then(function (dataUrl) {
970
+ document.body.removeChild(clonedElementSelected);
971
+ return dataUrl;
972
+ })
973
+ .catch(function (error) {
974
+ console.error('oops, something went wrong!', error);
975
+ return "";
976
+ });
977
+ const page = document.getElementsByTagName('html')[0];
978
+ page.style.overflow = 'hidden';
979
+ this.hasSelectedElement = true;
980
+ this.overlay.style.display = 'block';
981
+ this.showModal = true;
982
+ };
983
+ this.sending = false;
984
+ this.formMessage = '';
985
+ this.formEmail = '';
986
+ this.formSuccess = false;
987
+ this.formError = false;
988
+ this.encodedScreenshot = undefined;
989
+ this.modalTitle = 'Share your feedback';
990
+ this.successModalTitle = 'Thanks for your feedback!';
991
+ this.errorModalTitle = "Oops! We didn't receive your feedback. Please try again later.";
992
+ this.modalPosition = 'center';
993
+ this.sendButtonText = 'Send';
994
+ this.project = '';
995
+ this.screenshotButtonTooltipText = 'Take a Screenshot';
996
+ this.screenshotTopbarText = 'SELECT AN ELEMENT ON THE PAGE';
997
+ this.email = '';
998
+ this.emailPlaceholder = 'Email address (optional)';
999
+ this.messagePlaceholder = 'How could this page be more helpful?';
1000
+ this.showModal = false;
1001
+ this.showScreenshotMode = false;
1002
+ this.hasSelectedElement = false;
1003
+ }
1004
+ componentWillLoad() {
1005
+ this.formEmail = this.email;
1006
+ }
1007
+ handleMessageInput(event) {
1008
+ this.formMessage = event.target.value;
1009
+ }
1010
+ handleEmailInput(event) {
1011
+ this.formEmail = event.target.value;
1012
+ }
1013
+ render() {
1014
+ return (h("div", { class: "feedback-modal-wrapper" }, this.showScreenshotMode && (h("div", { class: "feedback-modal-screenshot", ref: el => (this.screenshotModal = el), onMouseMove: this.handleMouseOverScreenShot }, h("div", { class: "feedback-modal-screenshot-element-selected", ref: el => (this.elementSelected = el), onClick: this.handleMouseClickedSelectedElement }), h("div", { class: "top-side", ref: el => (this.topSide = el) }), h("div", { class: "left-side", ref: el => (this.leftSide = el) }), h("div", { class: "bottom-side", ref: el => (this.bottomSide = el) }), h("div", { class: "right-side", ref: el => (this.rightSide = el) }), h("div", { class: "feedback-modal-screenshot-header", onClick: this.closeScreenShot }, h("span", null, this.screenshotTopbarText), h("span", { class: "feedback-modal-screenshot-close" }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#fff", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather feather-x" }, h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })))), h("div", { class: "feedback-modal-screenshot-overlay", ref: el => (this.overlay = el) }))), this.showModal && (h("div", { class: `feedback-modal-content feedback-modal-content--${this.modalPosition}`, ref: el => (this.modalContent = el) }, h("div", { class: "feedback-modal-header" }, !this.formSuccess && !this.formError ? (h("span", null, this.modalTitle)) : this.formSuccess ? (h("span", { class: "text-center" }, this.successModalTitle)) : this.formError ? (h("span", { class: "text-center" }, this.errorModalTitle)) : h("span", null), h("button", { class: "feedback-modal-close", onClick: this.close }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "#ccc", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather feather-x" }, h("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), h("line", { x1: "6", y1: "6", x2: "18", y2: "18" })))), h("div", { class: "feedback-modal-body" }, !this.formSuccess && !this.formError ? (h("form", { onSubmit: this.handleSubmit }, h("div", { class: "feedback-modal-text" }, h("textarea", { placeholder: this.messagePlaceholder, value: this.formMessage, onInput: (event) => this.handleMessageInput(event), required: true })), !this.email && (h("div", { class: "feedback-modal-email" }, h("input", { type: "email", placeholder: this.emailPlaceholder, onInput: (event) => this.handleEmailInput(event), value: this.formEmail }))), h("div", { class: "feedback-modal-buttons" }, h("button", { type: "button", class: `button${this.encodedScreenshot ? " active" : ""}`, title: this.screenshotButtonTooltipText, onClick: this.openScreenShot, disabled: this.sending }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", "stroke-width": "2", "stroke-linecap": "round", "stroke-linejoin": "round", class: "feather feather-camera" }, h("path", { d: "M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" }), h("circle", { cx: "12", cy: "13", r: "4" }))), h("button", { class: "button", type: "submit", disabled: this.sending }, this.sendButtonText)))) : h("span", null)), h("div", { class: "feedback-modal-footer" }, h("div", { class: "feedback-logo" }, h("svg", { class: "w-8 h-8", viewBox: "0 0 32 32", xmlns: "http://www.w3.org/2000/svg" }, h("defs", null, h("radialGradient", { cx: "21.152%", cy: "86.063%", fx: "21.152%", fy: "86.063%", r: "79.941%", id: "footer-logo" }, h("stop", { "stop-color": "#4FD1C5", offset: "0%" }), h("stop", { "stop-color": "#81E6D9", offset: "25.871%" }), h("stop", { "stop-color": "#338CF5", offset: "100%" }))), h("rect", { width: "32", height: "32", rx: "16", fill: "url(#footer-logo)", "fill-rule": "nonzero" })), " ", h("a", { href: "https://pushfeedback.com" }, "PushFeedback")))))));
1015
+ }
1016
+ };
1017
+ FeedbackModal.style = feedbackModalCss;
1018
+
1019
+ export { FeedbackButton as feedback_button, FeedbackModal as feedback_modal };