@sumit_yewale/angular 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -0
- package/bundles/sumit_yewale-angular.umd.js +415 -0
- package/bundles/sumit_yewale-angular.umd.js.map +1 -0
- package/bundles/sumit_yewale-angular.umd.min.js +2 -0
- package/bundles/sumit_yewale-angular.umd.min.js.map +1 -0
- package/esm2015/lib/csvbox-angular.module.js +21 -0
- package/esm2015/lib/csvbox-button.component.js +327 -0
- package/esm2015/lib/interfaces/interface.js +14 -0
- package/esm2015/public-api.js +13 -0
- package/esm2015/sumit_yewale-angular.js +10 -0
- package/esm2015/utlis/insertCSS.js +44 -0
- package/esm5/lib/csvbox-angular.module.js +25 -0
- package/esm5/lib/csvbox-button.component.js +344 -0
- package/esm5/lib/interfaces/interface.js +14 -0
- package/esm5/public-api.js +13 -0
- package/esm5/sumit_yewale-angular.js +10 -0
- package/esm5/utlis/insertCSS.js +27 -0
- package/fesm2015/sumit_yewale-angular.js +418 -0
- package/fesm2015/sumit_yewale-angular.js.map +1 -0
- package/fesm5/sumit_yewale-angular.js +420 -0
- package/fesm5/sumit_yewale-angular.js.map +1 -0
- package/lib/csvbox-angular.module.d.ts +2 -0
- package/lib/csvbox-button.component.d.ts +45 -0
- package/lib/interfaces/interface.d.ts +3 -0
- package/package.json +55 -0
- package/public-api.d.ts +3 -0
- package/sumit_yewale-angular.d.ts +4 -0
- package/sumit_yewale-angular.metadata.json +1 -0
- package/utlis/insertCSS.d.ts +1 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import { SecurityContext, Component, ViewChild, Input, NgModule } from '@angular/core';
|
|
2
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
3
|
+
import { generateUuid, buildImportUrl, classifyStructuredMessage, buildInitPayload } from '@sumit_yewale/adapter-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @fileoverview added by tsickle
|
|
7
|
+
* Generated from: utlis/insertCSS.ts
|
|
8
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
9
|
+
*/
|
|
10
|
+
/** @type {?} */
|
|
11
|
+
let styleElement;
|
|
12
|
+
/** @type {?} */
|
|
13
|
+
const GLOBAL_CSS = `
|
|
14
|
+
.csvbox-holder {
|
|
15
|
+
z-index: 2147483647;
|
|
16
|
+
position: fixed;
|
|
17
|
+
top: 0;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
right: 0;
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
23
|
+
.csvbox-holder iframe {
|
|
24
|
+
height: 100%;
|
|
25
|
+
width: 100%;
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 0px;
|
|
28
|
+
left: 0px;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
/** @type {?} */
|
|
32
|
+
const insertCSS = (/**
|
|
33
|
+
* @return {?}
|
|
34
|
+
*/
|
|
35
|
+
() => {
|
|
36
|
+
if (styleElement) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
styleElement = document.createElement('style');
|
|
40
|
+
styleElement.setAttribute('type', 'text/css');
|
|
41
|
+
/** @type {?} */
|
|
42
|
+
const head = document.querySelector('head');
|
|
43
|
+
if (head) {
|
|
44
|
+
head.appendChild(styleElement);
|
|
45
|
+
}
|
|
46
|
+
styleElement.textContent = GLOBAL_CSS;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @fileoverview added by tsickle
|
|
51
|
+
* Generated from: lib/csvbox-button.component.ts
|
|
52
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
53
|
+
*/
|
|
54
|
+
/** @type {?} */
|
|
55
|
+
const appVersion = '1.1.16';
|
|
56
|
+
class CSVBoxButtonComponent {
|
|
57
|
+
/**
|
|
58
|
+
* @param {?} sanitizer
|
|
59
|
+
*/
|
|
60
|
+
constructor(sanitizer) {
|
|
61
|
+
this.sanitizer = sanitizer;
|
|
62
|
+
this.isModalShown = false;
|
|
63
|
+
this.licenseKey = null;
|
|
64
|
+
this.uuid = null;
|
|
65
|
+
this.customDomain = null;
|
|
66
|
+
this.dataLocation = null;
|
|
67
|
+
this.language = null;
|
|
68
|
+
this.theme = null;
|
|
69
|
+
this.isIframeLoaded = false;
|
|
70
|
+
this.openModalOnIframeLoad = false;
|
|
71
|
+
this.lazy = false;
|
|
72
|
+
this.iframe = null;
|
|
73
|
+
this.disabled = true;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @return {?}
|
|
77
|
+
*/
|
|
78
|
+
ngOnInit() {
|
|
79
|
+
this.uuid = generateUuid();
|
|
80
|
+
/** @type {?} */
|
|
81
|
+
let iframeUrl = buildImportUrl({
|
|
82
|
+
licenseKey: this.licenseKey,
|
|
83
|
+
customDomain: this.customDomain,
|
|
84
|
+
dataLocation: this.dataLocation,
|
|
85
|
+
language: this.language,
|
|
86
|
+
theme: this.theme,
|
|
87
|
+
environment: this.environment
|
|
88
|
+
}, "angular", appVersion);
|
|
89
|
+
this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* @param {?} changes
|
|
93
|
+
* @return {?}
|
|
94
|
+
*/
|
|
95
|
+
ngOnChanges(changes) {
|
|
96
|
+
if (changes["user"] && changes['user'].currentValue != changes['user'].previousValue) {
|
|
97
|
+
this.updateUserVariabe(changes['user'].currentValue);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @param {?} data
|
|
102
|
+
* @return {?}
|
|
103
|
+
*/
|
|
104
|
+
updateUserVariabe(data) {
|
|
105
|
+
this.user = data;
|
|
106
|
+
if (this.iframe && this.iframe.contentWindow) {
|
|
107
|
+
this.iframe.contentWindow.postMessage({
|
|
108
|
+
"customer": data
|
|
109
|
+
}, "*");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* @return {?}
|
|
114
|
+
*/
|
|
115
|
+
ngAfterContentInit() {
|
|
116
|
+
window.addEventListener("message", (/**
|
|
117
|
+
* @param {?} event
|
|
118
|
+
* @return {?}
|
|
119
|
+
*/
|
|
120
|
+
(event) => {
|
|
121
|
+
/** @type {?} */
|
|
122
|
+
let message = classifyStructuredMessage(event.data, (/** @type {?} */ (this.uuid)));
|
|
123
|
+
if (!message) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (message.type === "data-on-submit") {
|
|
127
|
+
if (this.onSubmit)
|
|
128
|
+
this.onSubmit(message.metadata);
|
|
129
|
+
if (this.isSubmitted)
|
|
130
|
+
this.isSubmitted(message.metadata);
|
|
131
|
+
if (this.submitted)
|
|
132
|
+
this.submitted(message.metadata);
|
|
133
|
+
}
|
|
134
|
+
else if (message.type === "data-push-status") {
|
|
135
|
+
if (!message.success) {
|
|
136
|
+
delete message.metadata["unique_token"];
|
|
137
|
+
}
|
|
138
|
+
if (this.onImport)
|
|
139
|
+
this.onImport(message.success, message.metadata);
|
|
140
|
+
if (this.isImported)
|
|
141
|
+
this.isImported(message.success, message.metadata);
|
|
142
|
+
if (this.imported)
|
|
143
|
+
this.imported(message.success, message.metadata);
|
|
144
|
+
}
|
|
145
|
+
else if (message.type === "csvbox-modal-hidden") {
|
|
146
|
+
this.handleModalClosed();
|
|
147
|
+
}
|
|
148
|
+
else if (message.type === "csvbox-upload-successful") {
|
|
149
|
+
if (this.onImport)
|
|
150
|
+
this.onImport(true);
|
|
151
|
+
if (this.isImported)
|
|
152
|
+
this.isImported(true);
|
|
153
|
+
if (this.imported)
|
|
154
|
+
this.imported(true);
|
|
155
|
+
}
|
|
156
|
+
else if (message.type === "csvbox-upload-failed") {
|
|
157
|
+
if (this.onImport)
|
|
158
|
+
this.onImport(false);
|
|
159
|
+
if (this.isImported)
|
|
160
|
+
this.isImported(false);
|
|
161
|
+
if (this.imported)
|
|
162
|
+
this.imported(false);
|
|
163
|
+
}
|
|
164
|
+
}), false);
|
|
165
|
+
if (this.lazy) {
|
|
166
|
+
this.disabled = false;
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.disabled = true;
|
|
170
|
+
this.initImporter();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* @return {?}
|
|
175
|
+
*/
|
|
176
|
+
handleModalClosed() {
|
|
177
|
+
if (this.holder)
|
|
178
|
+
this.holder.style.display = 'none';
|
|
179
|
+
this.isModalShown = false;
|
|
180
|
+
this.isIframeLoaded = false;
|
|
181
|
+
this.openModalOnIframeLoad = false;
|
|
182
|
+
if (this.holder)
|
|
183
|
+
this.holder.remove();
|
|
184
|
+
this.holder = null;
|
|
185
|
+
this.iframe = null;
|
|
186
|
+
if (this.onClose)
|
|
187
|
+
this.onClose();
|
|
188
|
+
if (this.isClosed)
|
|
189
|
+
this.isClosed();
|
|
190
|
+
if (this.closed)
|
|
191
|
+
this.closed();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @return {?}
|
|
195
|
+
*/
|
|
196
|
+
initImporter() {
|
|
197
|
+
if (this.loadStarted)
|
|
198
|
+
this.loadStarted();
|
|
199
|
+
this.uuid = generateUuid();
|
|
200
|
+
insertCSS();
|
|
201
|
+
/** @type {?} */
|
|
202
|
+
let iframe = document.createElement("iframe");
|
|
203
|
+
this.iframe = iframe;
|
|
204
|
+
iframe.setAttribute("src", this.safeUrl);
|
|
205
|
+
iframe.frameBorder = "0";
|
|
206
|
+
/** @type {?} */
|
|
207
|
+
let self = this;
|
|
208
|
+
iframe.onload = (/**
|
|
209
|
+
* @return {?}
|
|
210
|
+
*/
|
|
211
|
+
function () {
|
|
212
|
+
if (self.onReady)
|
|
213
|
+
self.onReady();
|
|
214
|
+
if (self.isReady)
|
|
215
|
+
self.isReady();
|
|
216
|
+
if (self.importerReady)
|
|
217
|
+
self.importerReady();
|
|
218
|
+
self.disabled = false;
|
|
219
|
+
self.isIframeLoaded = true;
|
|
220
|
+
if (self.iframe && self.iframe.contentWindow) {
|
|
221
|
+
self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, (/** @type {?} */ (self.uuid))), "*");
|
|
222
|
+
}
|
|
223
|
+
if (self.openModalOnIframeLoad) {
|
|
224
|
+
self.openModal();
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
this.holder = document.createElement('div');
|
|
228
|
+
this.holder.classList.add('csvbox-holder');
|
|
229
|
+
this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);
|
|
230
|
+
this.holder.appendChild(iframe);
|
|
231
|
+
document.body.insertAdjacentElement('beforeend', this.holder);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* @return {?}
|
|
235
|
+
*/
|
|
236
|
+
openModal() {
|
|
237
|
+
if (!this.iframe) {
|
|
238
|
+
this.openModalOnIframeLoad = true;
|
|
239
|
+
this.initImporter();
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (!this.isModalShown) {
|
|
243
|
+
if (this.isIframeLoaded) {
|
|
244
|
+
this.isModalShown = true;
|
|
245
|
+
if (this.holder)
|
|
246
|
+
this.holder.style.display = 'block';
|
|
247
|
+
if (this.iframe && this.iframe.contentWindow) {
|
|
248
|
+
this.iframe.contentWindow.postMessage('openModal', '*');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.openModalOnIframeLoad = true;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
CSVBoxButtonComponent.decorators = [
|
|
258
|
+
{ type: Component, args: [{
|
|
259
|
+
selector: 'csvbox-button',
|
|
260
|
+
template: `
|
|
261
|
+
<div>
|
|
262
|
+
<button [disabled]="disabled" #initiator (click)="openModal()" [attr.data-csvbox-token]="uuid">
|
|
263
|
+
<ng-content></ng-content>
|
|
264
|
+
</button>
|
|
265
|
+
</div>
|
|
266
|
+
`
|
|
267
|
+
}] }
|
|
268
|
+
];
|
|
269
|
+
/** @nocollapse */
|
|
270
|
+
CSVBoxButtonComponent.ctorParameters = () => [
|
|
271
|
+
{ type: DomSanitizer }
|
|
272
|
+
];
|
|
273
|
+
CSVBoxButtonComponent.propDecorators = {
|
|
274
|
+
initiator: [{ type: ViewChild, args: ['initiator', { static: false },] }],
|
|
275
|
+
onImport: [{ type: Input }],
|
|
276
|
+
onReady: [{ type: Input }],
|
|
277
|
+
onClose: [{ type: Input }],
|
|
278
|
+
onSubmit: [{ type: Input }],
|
|
279
|
+
isImported: [{ type: Input }],
|
|
280
|
+
isReady: [{ type: Input }],
|
|
281
|
+
isClosed: [{ type: Input }],
|
|
282
|
+
isSubmitted: [{ type: Input }],
|
|
283
|
+
importerReady: [{ type: Input }],
|
|
284
|
+
closed: [{ type: Input }],
|
|
285
|
+
submitted: [{ type: Input }],
|
|
286
|
+
imported: [{ type: Input }],
|
|
287
|
+
loadStarted: [{ type: Input }],
|
|
288
|
+
user: [{ type: Input }],
|
|
289
|
+
dynamicColumns: [{ type: Input }],
|
|
290
|
+
licenseKey: [{ type: Input }],
|
|
291
|
+
options: [{ type: Input }],
|
|
292
|
+
uuid: [{ type: Input }],
|
|
293
|
+
customDomain: [{ type: Input }],
|
|
294
|
+
dataLocation: [{ type: Input }],
|
|
295
|
+
language: [{ type: Input }],
|
|
296
|
+
environment: [{ type: Input }],
|
|
297
|
+
theme: [{ type: Input }],
|
|
298
|
+
isIframeLoaded: [{ type: Input }],
|
|
299
|
+
openModalOnIframeLoad: [{ type: Input }],
|
|
300
|
+
lazy: [{ type: Input }],
|
|
301
|
+
disabled: [{ type: Input }]
|
|
302
|
+
};
|
|
303
|
+
if (false) {
|
|
304
|
+
/** @type {?} */
|
|
305
|
+
CSVBoxButtonComponent.prototype.isModalShown;
|
|
306
|
+
/** @type {?} */
|
|
307
|
+
CSVBoxButtonComponent.prototype.initiator;
|
|
308
|
+
/** @type {?} */
|
|
309
|
+
CSVBoxButtonComponent.prototype.onImport;
|
|
310
|
+
/** @type {?} */
|
|
311
|
+
CSVBoxButtonComponent.prototype.onReady;
|
|
312
|
+
/** @type {?} */
|
|
313
|
+
CSVBoxButtonComponent.prototype.onClose;
|
|
314
|
+
/** @type {?} */
|
|
315
|
+
CSVBoxButtonComponent.prototype.onSubmit;
|
|
316
|
+
/** @type {?} */
|
|
317
|
+
CSVBoxButtonComponent.prototype.isImported;
|
|
318
|
+
/** @type {?} */
|
|
319
|
+
CSVBoxButtonComponent.prototype.isReady;
|
|
320
|
+
/** @type {?} */
|
|
321
|
+
CSVBoxButtonComponent.prototype.isClosed;
|
|
322
|
+
/** @type {?} */
|
|
323
|
+
CSVBoxButtonComponent.prototype.isSubmitted;
|
|
324
|
+
/** @type {?} */
|
|
325
|
+
CSVBoxButtonComponent.prototype.importerReady;
|
|
326
|
+
/** @type {?} */
|
|
327
|
+
CSVBoxButtonComponent.prototype.closed;
|
|
328
|
+
/** @type {?} */
|
|
329
|
+
CSVBoxButtonComponent.prototype.submitted;
|
|
330
|
+
/** @type {?} */
|
|
331
|
+
CSVBoxButtonComponent.prototype.imported;
|
|
332
|
+
/** @type {?} */
|
|
333
|
+
CSVBoxButtonComponent.prototype.loadStarted;
|
|
334
|
+
/** @type {?} */
|
|
335
|
+
CSVBoxButtonComponent.prototype.user;
|
|
336
|
+
/** @type {?} */
|
|
337
|
+
CSVBoxButtonComponent.prototype.dynamicColumns;
|
|
338
|
+
/** @type {?} */
|
|
339
|
+
CSVBoxButtonComponent.prototype.licenseKey;
|
|
340
|
+
/** @type {?} */
|
|
341
|
+
CSVBoxButtonComponent.prototype.options;
|
|
342
|
+
/** @type {?} */
|
|
343
|
+
CSVBoxButtonComponent.prototype.uuid;
|
|
344
|
+
/** @type {?} */
|
|
345
|
+
CSVBoxButtonComponent.prototype.customDomain;
|
|
346
|
+
/** @type {?} */
|
|
347
|
+
CSVBoxButtonComponent.prototype.dataLocation;
|
|
348
|
+
/** @type {?} */
|
|
349
|
+
CSVBoxButtonComponent.prototype.language;
|
|
350
|
+
/** @type {?} */
|
|
351
|
+
CSVBoxButtonComponent.prototype.environment;
|
|
352
|
+
/** @type {?} */
|
|
353
|
+
CSVBoxButtonComponent.prototype.theme;
|
|
354
|
+
/** @type {?} */
|
|
355
|
+
CSVBoxButtonComponent.prototype.isIframeLoaded;
|
|
356
|
+
/** @type {?} */
|
|
357
|
+
CSVBoxButtonComponent.prototype.openModalOnIframeLoad;
|
|
358
|
+
/** @type {?} */
|
|
359
|
+
CSVBoxButtonComponent.prototype.lazy;
|
|
360
|
+
/** @type {?} */
|
|
361
|
+
CSVBoxButtonComponent.prototype.safeUrl;
|
|
362
|
+
/** @type {?} */
|
|
363
|
+
CSVBoxButtonComponent.prototype.iframe;
|
|
364
|
+
/** @type {?} */
|
|
365
|
+
CSVBoxButtonComponent.prototype.disabled;
|
|
366
|
+
/** @type {?} */
|
|
367
|
+
CSVBoxButtonComponent.prototype.holder;
|
|
368
|
+
/** @type {?} */
|
|
369
|
+
CSVBoxButtonComponent.prototype.sanitizer;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* @fileoverview added by tsickle
|
|
374
|
+
* Generated from: lib/csvbox-angular.module.ts
|
|
375
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
376
|
+
*/
|
|
377
|
+
class CSVBoxAngularModule {
|
|
378
|
+
}
|
|
379
|
+
CSVBoxAngularModule.decorators = [
|
|
380
|
+
{ type: NgModule, args: [{
|
|
381
|
+
declarations: [
|
|
382
|
+
CSVBoxButtonComponent
|
|
383
|
+
],
|
|
384
|
+
imports: [],
|
|
385
|
+
exports: [
|
|
386
|
+
CSVBoxButtonComponent
|
|
387
|
+
]
|
|
388
|
+
},] }
|
|
389
|
+
];
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* @fileoverview added by tsickle
|
|
393
|
+
* Generated from: lib/interfaces/interface.ts
|
|
394
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
395
|
+
*/
|
|
396
|
+
/**
|
|
397
|
+
* @record
|
|
398
|
+
*/
|
|
399
|
+
function CSVBoxMethods() { }
|
|
400
|
+
if (false) {
|
|
401
|
+
/** @type {?|undefined} */
|
|
402
|
+
CSVBoxMethods.prototype.onData;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* @fileoverview added by tsickle
|
|
407
|
+
* Generated from: public-api.ts
|
|
408
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
409
|
+
*/
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* @fileoverview added by tsickle
|
|
413
|
+
* Generated from: sumit_yewale-angular.ts
|
|
414
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
415
|
+
*/
|
|
416
|
+
|
|
417
|
+
export { CSVBoxAngularModule, CSVBoxButtonComponent };
|
|
418
|
+
//# sourceMappingURL=sumit_yewale-angular.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sumit_yewale-angular.js","sources":["ng://@sumit_yewale/angular/utlis/insertCSS.ts","ng://@sumit_yewale/angular/lib/csvbox-button.component.ts","ng://@sumit_yewale/angular/lib/csvbox-angular.module.ts","ng://@sumit_yewale/angular/lib/interfaces/interface.ts"],"sourcesContent":["let styleElement: HTMLStyleElement\n\nconst GLOBAL_CSS = `\n.csvbox-holder {\n z-index: 2147483647;\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n display: none;\n}\n.csvbox-holder iframe {\n height: 100%;\n width: 100%;\n position: absolute;\n top: 0px;\n left: 0px;\n}\n`\n\nexport const insertCSS = (): void => {\n if (styleElement) {\n return\n }\n\n styleElement = document.createElement('style')\n styleElement.setAttribute('type', 'text/css')\n const head = document.querySelector('head');\n if (head) {\n head.appendChild(styleElement);\n }\n\n styleElement.textContent = GLOBAL_CSS\n}\n","import {\n Component,\n OnInit,\n ViewChild,\n Input,\n OnChanges,\n SimpleChanges,\n SecurityContext,\n AfterContentInit\n} from '@angular/core';\n\nimport { DomSanitizer, SafeUrl } from '@angular/platform-browser';\nimport { insertCSS } from '../utlis/insertCSS';\nimport { buildImportUrl, generateUuid, buildInitPayload, classifyStructuredMessage } from '@sumit_yewale/adapter-core';\n\nconst appVersion = '1.1.16';\n\n@Component({\n selector: 'csvbox-button',\n template: `\n <div>\n <button [disabled]=\"disabled\" #initiator (click)=\"openModal()\" [attr.data-csvbox-token]=\"uuid\">\n <ng-content></ng-content>\n </button>\n </div>\n `\n})\n\nexport class CSVBoxButtonComponent implements OnInit, OnChanges, AfterContentInit {\n\n isModalShown = false;\n\n @ViewChild('initiator', {static: false}) initiator: any;\n @Input() onImport?: Function;\n @Input() onReady?: Function;\n @Input() onClose?: Function;\n @Input() onSubmit?: Function;\n\n @Input() isImported?: Function;\n @Input() isReady?: Function;\n @Input() isClosed?: Function;\n @Input() isSubmitted?: Function;\n\n @Input() importerReady?: Function;\n @Input() closed?: Function;\n @Input() submitted?: Function;\n @Input() imported?: Function;\n @Input() loadStarted?: Function;\n\n @Input() user?: object;\n @Input() dynamicColumns?: object;\n @Input() licenseKey: string | null = null;\n @Input() options?: object;\n @Input() uuid: string | null = null;\n @Input() customDomain: string | null = null;\n @Input() dataLocation: string | null = null;\n @Input() language: string | null = null;\n @Input() environment?: object;\n\n @Input() theme: string | null = null;\n\n @Input() isIframeLoaded: boolean = false;\n @Input() openModalOnIframeLoad: boolean = false;\n\n @Input() lazy: boolean = false;\n\n safeUrl: any;\n\n iframe: HTMLIFrameElement | null = null;\n\n @Input() disabled: boolean = true;\n\n constructor(public sanitizer:DomSanitizer) {}\n\n holder: any;\n\n ngOnInit(): void {\n this.uuid = generateUuid();\n let iframeUrl = buildImportUrl(\n {\n licenseKey: this.licenseKey,\n customDomain: this.customDomain,\n dataLocation: this.dataLocation,\n language: this.language,\n theme: this.theme,\n environment: this.environment\n },\n \"angular\",\n appVersion\n );\n this.safeUrl = this.sanitizer.sanitize(SecurityContext.RESOURCE_URL, this.sanitizer.bypassSecurityTrustResourceUrl(iframeUrl));\n }\n\n ngOnChanges(changes: SimpleChanges) {\n if(changes[\"user\"] && changes['user'].currentValue != changes['user'].previousValue) {\n this.updateUserVariabe(changes['user'].currentValue);\n }\n }\n\n updateUserVariabe(data: any): void {\n this.user = data;\n if (this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage({\n \"customer\" : data\n }, \"*\");\n }\n }\n\n ngAfterContentInit(): void {\n window.addEventListener(\"message\", (event) => {\n let message = classifyStructuredMessage(event.data, this.uuid!);\n if (!message) {\n return;\n }\n\n if (message.type === \"data-on-submit\") {\n if (this.onSubmit) this.onSubmit(message.metadata);\n if (this.isSubmitted) this.isSubmitted(message.metadata);\n if (this.submitted) this.submitted(message.metadata);\n } else if (message.type === \"data-push-status\") {\n if (!message.success) {\n delete message.metadata[\"unique_token\"];\n }\n if (this.onImport) this.onImport(message.success, message.metadata);\n if (this.isImported) this.isImported(message.success, message.metadata);\n if (this.imported) this.imported(message.success, message.metadata);\n } else if (message.type === \"csvbox-modal-hidden\") {\n this.handleModalClosed();\n } else if (message.type === \"csvbox-upload-successful\") {\n if (this.onImport) this.onImport(true);\n if (this.isImported) this.isImported(true);\n if (this.imported) this.imported(true);\n } else if (message.type === \"csvbox-upload-failed\") {\n if (this.onImport) this.onImport(false);\n if (this.isImported) this.isImported(false);\n if (this.imported) this.imported(false);\n }\n }, false);\n\n if(this.lazy) {\n this.disabled = false;\n } else {\n this.disabled = true;\n this.initImporter();\n }\n }\n\n handleModalClosed(): void {\n if (this.holder) this.holder.style.display = 'none';\n this.isModalShown = false;\n this.isIframeLoaded = false;\n this.openModalOnIframeLoad = false;\n if (this.holder) this.holder.remove();\n this.holder = null;\n this.iframe = null;\n if (this.onClose) this.onClose();\n if (this.isClosed) this.isClosed();\n if (this.closed) this.closed();\n }\n\n initImporter() {\n if (this.loadStarted) this.loadStarted();\n\n this.uuid = generateUuid();\n\n insertCSS();\n\n let iframe = document.createElement(\"iframe\");\n this.iframe = iframe;\n iframe.setAttribute(\"src\", this.safeUrl);\n iframe.frameBorder = \"0\";\n\n let self = this;\n iframe.onload = function () {\n if (self.onReady) self.onReady();\n if (self.isReady) self.isReady();\n if (self.importerReady) self.importerReady();\n\n self.disabled = false;\n self.isIframeLoaded = true;\n if (self.iframe && self.iframe.contentWindow) {\n self.iframe.contentWindow.postMessage(buildInitPayload(self.user, self.dynamicColumns, self.options, self.uuid!), \"*\");\n }\n if(self.openModalOnIframeLoad) {\n self.openModal();\n }\n }\n\n this.holder = document.createElement('div');\n this.holder.classList.add('csvbox-holder');\n this.holder.setAttribute('id', `csvbox-embed-${this.uuid}`);\n this.holder.appendChild(iframe);\n\n document.body.insertAdjacentElement(\n 'beforeend', this.holder\n );\n }\n\n openModal(): void {\n if(!this.iframe) {\n this.openModalOnIframeLoad = true;\n this.initImporter();\n return;\n }\n if(!this.isModalShown) {\n if(this.isIframeLoaded) {\n this.isModalShown = true;\n if(this.holder) this.holder.style.display = 'block';\n if(this.iframe && this.iframe.contentWindow) {\n this.iframe.contentWindow.postMessage('openModal', '*');\n }\n } else {\n this.openModalOnIframeLoad = true;\n }\n }\n }\n\n}\n","import { NgModule } from '@angular/core';\nimport { CSVBoxButtonComponent } from './csvbox-button.component';\n\n\n\n@NgModule({\n declarations: [\n CSVBoxButtonComponent\n ],\n imports: [\n ],\n exports: [\n CSVBoxButtonComponent\n ]\n})\nexport class CSVBoxAngularModule { }\n","export interface CSVBoxMethods {\n onData?: (result:boolean, data:any) => void;\n}\n"],"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