highcourt-affidavit-elements 0.2.11 → 0.2.12
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.
|
@@ -13,9 +13,16 @@
|
|
|
13
13
|
* data-mode="live"
|
|
14
14
|
* data-template-id="1"
|
|
15
15
|
* data-app-id="APP123"
|
|
16
|
+
* data-payload='{"key":"value"}'
|
|
16
17
|
* data-target="#affidavit-root"></script>
|
|
17
18
|
* <div id="affidavit-root"></div>
|
|
18
19
|
*
|
|
20
|
+
* Event listeners can be set up directly on the element:
|
|
21
|
+
* const element = document.querySelector('highcourt-affidavit');
|
|
22
|
+
* element.addEventListener('callBack', (event) => { ... });
|
|
23
|
+
* element.addEventListener('onPaymentSuccess', (event) => { ... });
|
|
24
|
+
* element.addEventListener('overlayClose', (event) => { ... });
|
|
25
|
+
*
|
|
19
26
|
* Usage example (pay-affidavit):
|
|
20
27
|
* <script src="https://cdn.your-domain.com/highcourt-affidavit-elements/v0.2.3/loader.js"
|
|
21
28
|
* data-component="pay-affidavit"
|
|
@@ -79,6 +86,7 @@
|
|
|
79
86
|
var clientRef = getAttr('clientRef', 'data-client-ref') || '';
|
|
80
87
|
var affidavitTemplateId = getAttr('affidavitTemplateId', 'data-affidavit-template-id') || '';
|
|
81
88
|
var paymentRedirectUrl = getAttr('paymentRedirectUrl', 'data-payment-redirect-url') || '';
|
|
89
|
+
var payload = getAttr('payload', 'data-payload') || '';
|
|
82
90
|
|
|
83
91
|
var src = currentScript && currentScript.src ? currentScript.src : '';
|
|
84
92
|
var baseUrl = src ? src.substring(0, src.lastIndexOf('/') + 1) : './';
|
|
@@ -142,6 +150,15 @@
|
|
|
142
150
|
el.setAttribute('mode', mode);
|
|
143
151
|
}
|
|
144
152
|
|
|
153
|
+
// Set overlay attribute based on loader's overlay setting
|
|
154
|
+
// If loader overlay is enabled, disable component's internal overlay to avoid conflicts
|
|
155
|
+
// If loader overlay is disabled, let component handle its own overlay
|
|
156
|
+
if (overlayEnabled) {
|
|
157
|
+
el.setAttribute('overlay', 'false');
|
|
158
|
+
} else {
|
|
159
|
+
el.setAttribute('overlay', 'true');
|
|
160
|
+
}
|
|
161
|
+
|
|
145
162
|
// Component-specific attributes
|
|
146
163
|
if (componentType === 'highcourt-affidavit') {
|
|
147
164
|
if (templateId) {
|
|
@@ -150,6 +167,15 @@
|
|
|
150
167
|
if (appId) {
|
|
151
168
|
el.setAttribute('app-id', appId);
|
|
152
169
|
}
|
|
170
|
+
if (payload) {
|
|
171
|
+
// Try to parse as JSON if it looks like JSON, otherwise use as string
|
|
172
|
+
try {
|
|
173
|
+
var parsedPayload = JSON.parse(payload);
|
|
174
|
+
el.setAttribute('payload', JSON.stringify(parsedPayload));
|
|
175
|
+
} catch (e) {
|
|
176
|
+
el.setAttribute('payload', payload);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
153
179
|
} else if (componentType === 'pay-affidavit') {
|
|
154
180
|
if (appNo) {
|
|
155
181
|
el.setAttribute('app-no', appNo);
|
|
@@ -198,6 +224,11 @@
|
|
|
198
224
|
if (mode && 'mode' in el) {
|
|
199
225
|
el.mode = mode;
|
|
200
226
|
}
|
|
227
|
+
// Set overlay property
|
|
228
|
+
if ('overlay' in el) {
|
|
229
|
+
el.overlay = overlayEnabled ? false : true;
|
|
230
|
+
}
|
|
231
|
+
|
|
201
232
|
if (componentType === 'highcourt-affidavit') {
|
|
202
233
|
if (templateId && 'templateId' in el) {
|
|
203
234
|
el.templateId = templateId;
|
|
@@ -205,6 +236,14 @@
|
|
|
205
236
|
if (appId && 'appId' in el) {
|
|
206
237
|
el.appId = appId;
|
|
207
238
|
}
|
|
239
|
+
if (payload && 'payload' in el) {
|
|
240
|
+
try {
|
|
241
|
+
var parsedPayload = JSON.parse(payload);
|
|
242
|
+
el.payload = parsedPayload;
|
|
243
|
+
} catch (e) {
|
|
244
|
+
el.payload = payload;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
208
247
|
} else if (componentType === 'pay-affidavit') {
|
|
209
248
|
if (appNo) {
|
|
210
249
|
if ('appNo' in el) {
|
|
@@ -256,6 +295,10 @@
|
|
|
256
295
|
return el;
|
|
257
296
|
}
|
|
258
297
|
|
|
298
|
+
// Note: Angular Elements automatically converts @Output() events to custom DOM events
|
|
299
|
+
// Users can listen directly: element.addEventListener('callBack', handler)
|
|
300
|
+
// No need to set up listeners here - Angular handles it automatically
|
|
301
|
+
|
|
259
302
|
function ensureElement(host) {
|
|
260
303
|
if (!host) return null;
|
|
261
304
|
var el = host.querySelector(tag);
|
|
@@ -373,6 +416,17 @@
|
|
|
373
416
|
applyAttributes(el);
|
|
374
417
|
}
|
|
375
418
|
}, 500);
|
|
419
|
+
// For components that use internal overlay system, trigger their overlay creation
|
|
420
|
+
// This ensures the component's overlay is properly initialized when shown via loader
|
|
421
|
+
setTimeout(function() {
|
|
422
|
+
if (el && typeof el.openAffidavitOverlay === 'function') {
|
|
423
|
+
try {
|
|
424
|
+
el.openAffidavitOverlay();
|
|
425
|
+
} catch (e) {
|
|
426
|
+
// Component might not have this method, ignore
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}, 300);
|
|
376
430
|
}
|
|
377
431
|
}
|
|
378
432
|
|