@kompasid/lit-web-components 0.9.11 → 0.9.14
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/demo/index.html +2 -2
- package/dist/src/components/kompasid-freewall/KompasFreewall.d.ts +9 -24
- package/dist/src/components/kompasid-freewall/KompasFreewall.js +47 -98
- package/dist/src/components/kompasid-freewall/KompasFreewall.js.map +1 -1
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.d.ts +96 -0
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.js +305 -0
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.js.map +1 -0
- package/dist/src/components/kompasid-freewall/types.d.ts +26 -0
- package/dist/src/components/kompasid-freewall/types.js.map +1 -1
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.d.ts +9 -14
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js +62 -102
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js.map +1 -1
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.d.ts +34 -0
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js +228 -0
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js.map +1 -0
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.d.ts +8 -19
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js +34 -53
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js.map +1 -1
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.d.ts +38 -0
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js +125 -0
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js.map +1 -0
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +1 -1
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.d.ts +4 -1
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js +21 -18
- package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js.map +1 -1
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js +1 -1
- package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js.map +1 -1
- package/dist/src/components/kompasid-header-notification/KompasHeaderNotification.js +1 -1
- package/dist/src/components/kompasid-header-notification/KompasHeaderNotification.js.map +1 -1
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js +5 -7
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js.map +1 -1
- package/dist/src/utils/googleFont.js +1 -1
- package/dist/src/utils/googleFont.js.map +1 -1
- package/dist/tailwind/tailwind.js +56 -8
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-freewall/KompasFreewall.ts +58 -83
- package/src/components/kompasid-freewall/old_KompasFreewall.ts +255 -0
- package/src/components/kompasid-freewall/readme.md +41 -84
- package/src/components/kompasid-freewall/types.ts +29 -0
- package/src/components/kompasid-freewall-body/KompasFreewallBody.ts +63 -101
- package/src/components/kompasid-freewall-body/old_KompasFreewallBody.ts +224 -0
- package/src/components/kompasid-freewall-body/readme.md +31 -7
- package/src/components/kompasid-freewall-head/KompasFreewallHead.ts +32 -40
- package/src/components/kompasid-freewall-head/old_KompasFreewallHead.ts +103 -0
- package/src/components/kompasid-freewall-head/readme.md +29 -13
- package/src/components/kompasid-grace-period/KompasGracePeriod.ts +1 -1
- package/src/components/kompasid-header-account/KompasHeaderAccount.ts +21 -18
- package/src/components/kompasid-header-account/readme.md +47 -28
- package/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts +1 -1
- package/src/components/kompasid-header-notification/KompasHeaderNotification.ts +1 -1
- package/src/components/kompasid-menu-side-bar/KompasMenuSideBar.ts +5 -7
- package/src/components/kompasid-metered-paywall/readme.md +1 -1
- package/src/utils/googleFont.ts +1 -1
- package/tailwind/tailwind.css +56 -6
- package/tailwind/tailwind.ts +56 -8
- package/tailwind.config.js +1 -1
package/demo/index.html
CHANGED
|
@@ -361,7 +361,7 @@
|
|
|
361
361
|
source="kompasid"
|
|
362
362
|
></kompasid-metered-wall-register>
|
|
363
363
|
|
|
364
|
-
|
|
364
|
+
<kompasid-grace-period
|
|
365
365
|
totalGracePeriod="1"
|
|
366
366
|
isShowButton="true"
|
|
367
367
|
source="epaper"
|
|
@@ -380,7 +380,7 @@
|
|
|
380
380
|
.tracker_metered_wall_type=${meteredWallType}
|
|
381
381
|
.tracker_subscription_status=${trackerSubscriptionStatus}
|
|
382
382
|
.tracker_metered_wall_balance=${trackerMeteredWallBalance}
|
|
383
|
-
></kompasid-grace-period>
|
|
383
|
+
></kompasid-grace-period>
|
|
384
384
|
`,
|
|
385
385
|
document.querySelector('#demo')
|
|
386
386
|
)
|
|
@@ -7,38 +7,24 @@ export declare class KompasFreewall extends LitElement {
|
|
|
7
7
|
* Props
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
|
-
* property
|
|
11
|
-
* property type untuk menghandle tipe freewall
|
|
12
|
-
* property head_copy_expand to update copy header when expand
|
|
13
|
-
* property head_copy_collapse to update copy header when collapse
|
|
10
|
+
* property type untuk menghandle tipe freewall (akan menyematkan beberapa tipe data layer)
|
|
14
11
|
* property expand to handle expand/collapse
|
|
15
|
-
* property
|
|
16
|
-
* property paywall_subscription_package is the name of the subscription package viewed by user
|
|
17
|
-
* property paywall_subscription_id is the ID of the subscription package viewed by user
|
|
18
|
-
* property paywall_subscription_price is the price of the subscription package viewed by user
|
|
19
|
-
* property paywall_position is the position of the subscription package viewed by user
|
|
12
|
+
* property tracker_paywall_location is the location where user encounter the paywall
|
|
20
13
|
* property tracker_page_type is the type of the page
|
|
21
14
|
* property tracker_page_title is the title of the page
|
|
22
|
-
* property tracker_content_id is the ID of article (slug)
|
|
23
|
-
* property content_title is the title of article
|
|
24
|
-
* property tracker_content_categories is the category of the content
|
|
25
|
-
* property tracker_content_type is to decide whether it's free article or paid article
|
|
26
15
|
* property tracker_user_type is the type of user based on their subscription
|
|
27
16
|
* property tracker_subscription_status is the status of their subscription
|
|
28
17
|
* property tracker_page_domain is the page domain
|
|
29
18
|
* property tracker_metered_wall_type is the type of metered wall
|
|
30
19
|
* property tracker_metered_wall_balance is the balance of their metered wall
|
|
20
|
+
* property tracker_content_title is the title of article [type=article]
|
|
21
|
+
* property tracker_content_id is the ID of article (slug) [type=article]
|
|
22
|
+
* property tracker_content_categories is the category of the content [type=article]
|
|
23
|
+
* property tracker_content_type is to decide whether it's free article or paid article [type=article]
|
|
31
24
|
*/
|
|
32
|
-
isLogin: boolean;
|
|
33
25
|
type: 'article' | 'landing_page';
|
|
34
|
-
head_copy_expand: string;
|
|
35
|
-
head_copy_collapse: string;
|
|
36
26
|
expand: boolean;
|
|
37
|
-
|
|
38
|
-
paywall_subscription_package: string;
|
|
39
|
-
paywall_subscription_id: number;
|
|
40
|
-
paywall_subscription_price: number;
|
|
41
|
-
paywall_position: number;
|
|
27
|
+
tracker_paywall_location: string;
|
|
42
28
|
tracker_page_type: string;
|
|
43
29
|
tracker_page_title: string;
|
|
44
30
|
tracker_content_id: string;
|
|
@@ -66,8 +52,7 @@ export declare class KompasFreewall extends LitElement {
|
|
|
66
52
|
*/
|
|
67
53
|
private isLoading;
|
|
68
54
|
private isExpand;
|
|
69
|
-
private
|
|
70
|
-
private jsonPackageData;
|
|
55
|
+
private pullData;
|
|
71
56
|
/**
|
|
72
57
|
* Getter
|
|
73
58
|
*/
|
|
@@ -83,7 +68,7 @@ export declare class KompasFreewall extends LitElement {
|
|
|
83
68
|
* Logic Function
|
|
84
69
|
*/
|
|
85
70
|
private toggleExpand;
|
|
86
|
-
private
|
|
71
|
+
private goToUrl;
|
|
87
72
|
/**
|
|
88
73
|
* Lifecycle
|
|
89
74
|
*/
|
|
@@ -12,38 +12,24 @@ let KompasFreewall = class KompasFreewall extends LitElement {
|
|
|
12
12
|
* Props
|
|
13
13
|
*/
|
|
14
14
|
/**
|
|
15
|
-
* property
|
|
16
|
-
* property type untuk menghandle tipe freewall
|
|
17
|
-
* property head_copy_expand to update copy header when expand
|
|
18
|
-
* property head_copy_collapse to update copy header when collapse
|
|
15
|
+
* property type untuk menghandle tipe freewall (akan menyematkan beberapa tipe data layer)
|
|
19
16
|
* property expand to handle expand/collapse
|
|
20
|
-
* property
|
|
21
|
-
* property paywall_subscription_package is the name of the subscription package viewed by user
|
|
22
|
-
* property paywall_subscription_id is the ID of the subscription package viewed by user
|
|
23
|
-
* property paywall_subscription_price is the price of the subscription package viewed by user
|
|
24
|
-
* property paywall_position is the position of the subscription package viewed by user
|
|
17
|
+
* property tracker_paywall_location is the location where user encounter the paywall
|
|
25
18
|
* property tracker_page_type is the type of the page
|
|
26
19
|
* property tracker_page_title is the title of the page
|
|
27
|
-
* property tracker_content_id is the ID of article (slug)
|
|
28
|
-
* property content_title is the title of article
|
|
29
|
-
* property tracker_content_categories is the category of the content
|
|
30
|
-
* property tracker_content_type is to decide whether it's free article or paid article
|
|
31
20
|
* property tracker_user_type is the type of user based on their subscription
|
|
32
21
|
* property tracker_subscription_status is the status of their subscription
|
|
33
22
|
* property tracker_page_domain is the page domain
|
|
34
23
|
* property tracker_metered_wall_type is the type of metered wall
|
|
35
24
|
* property tracker_metered_wall_balance is the balance of their metered wall
|
|
25
|
+
* property tracker_content_title is the title of article [type=article]
|
|
26
|
+
* property tracker_content_id is the ID of article (slug) [type=article]
|
|
27
|
+
* property tracker_content_categories is the category of the content [type=article]
|
|
28
|
+
* property tracker_content_type is to decide whether it's free article or paid article [type=article]
|
|
36
29
|
*/
|
|
37
|
-
this.isLogin = false;
|
|
38
30
|
this.type = 'article';
|
|
39
|
-
this.head_copy_expand = '';
|
|
40
|
-
this.head_copy_collapse = '';
|
|
41
31
|
this.expand = true;
|
|
42
|
-
this.
|
|
43
|
-
this.paywall_subscription_package = '';
|
|
44
|
-
this.paywall_subscription_id = 0;
|
|
45
|
-
this.paywall_subscription_price = 0;
|
|
46
|
-
this.paywall_position = 1;
|
|
32
|
+
this.tracker_paywall_location = '';
|
|
47
33
|
this.tracker_page_type = '';
|
|
48
34
|
this.tracker_page_title = '';
|
|
49
35
|
this.tracker_content_id = '';
|
|
@@ -71,8 +57,7 @@ let KompasFreewall = class KompasFreewall extends LitElement {
|
|
|
71
57
|
*/
|
|
72
58
|
this.isLoading = true;
|
|
73
59
|
this.isExpand = true;
|
|
74
|
-
this.
|
|
75
|
-
this.jsonPackageData = {};
|
|
60
|
+
this.pullData = {};
|
|
76
61
|
}
|
|
77
62
|
/**
|
|
78
63
|
* Getter
|
|
@@ -83,19 +68,19 @@ let KompasFreewall = class KompasFreewall extends LitElement {
|
|
|
83
68
|
/**
|
|
84
69
|
* Data Layer
|
|
85
70
|
*/
|
|
86
|
-
prepareImpressionsData() {
|
|
71
|
+
prepareImpressionsData(item) {
|
|
87
72
|
const baseData = {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
paywall_subscription_package: item.packageSlug,
|
|
74
|
+
paywall_subscription_id: item.packageId,
|
|
75
|
+
paywall_subscription_price: item.priceDiscount || item.priceBased,
|
|
76
|
+
paywall_position: item.position,
|
|
77
|
+
paywall_location: this.tracker_paywall_location,
|
|
93
78
|
user_type: this.tracker_user_type,
|
|
94
79
|
subscription_status: this.tracker_subscription_status,
|
|
95
80
|
page_domain: this.tracker_page_domain || 'Kompas.id',
|
|
96
81
|
page_type: this.tracker_page_type,
|
|
97
82
|
metered_wall_type: this.tracker_metered_wall_type || 'FP',
|
|
98
|
-
metered_wall_balance: this.tracker_metered_wall_balance,
|
|
83
|
+
metered_wall_balance: this.tracker_metered_wall_balance, // from user
|
|
99
84
|
};
|
|
100
85
|
if (this.isArticle) {
|
|
101
86
|
return {
|
|
@@ -111,19 +96,22 @@ let KompasFreewall = class KompasFreewall extends LitElement {
|
|
|
111
96
|
page_title: this.tracker_page_title,
|
|
112
97
|
};
|
|
113
98
|
}
|
|
114
|
-
sendDataLayer(event,
|
|
115
|
-
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
99
|
+
sendDataLayer(event, position = 0 // ganti ke specific package
|
|
100
|
+
) {
|
|
101
|
+
const impressionsData = this.pullData.body.map((item) => this.prepareImpressionsData(item));
|
|
102
|
+
const get = this.pullData.body.find(item => item.position === position);
|
|
103
|
+
const specificData = get ? this.prepareImpressionsData(get) : [];
|
|
104
|
+
const data = position
|
|
105
|
+
? { event, ...specificData }
|
|
106
|
+
: { event, impressions: [impressionsData] };
|
|
119
107
|
window.dataLayer.push(data);
|
|
120
108
|
}
|
|
121
109
|
sendDataLayerPaywallViewed() {
|
|
122
110
|
if (this.isExpand)
|
|
123
|
-
this.sendDataLayer('paywall_viewed'
|
|
111
|
+
this.sendDataLayer('paywall_viewed');
|
|
124
112
|
}
|
|
125
|
-
sendDataLayerSubscribeButtonClicked() {
|
|
126
|
-
this.sendDataLayer('subscribe_button_clicked');
|
|
113
|
+
sendDataLayerSubscribeButtonClicked(pos) {
|
|
114
|
+
this.sendDataLayer('subscribe_button_clicked', pos);
|
|
127
115
|
}
|
|
128
116
|
/**
|
|
129
117
|
* Logic Function
|
|
@@ -132,10 +120,13 @@ let KompasFreewall = class KompasFreewall extends LitElement {
|
|
|
132
120
|
this.isExpand = !this.isExpand;
|
|
133
121
|
this.sendDataLayerPaywallViewed();
|
|
134
122
|
}
|
|
135
|
-
|
|
136
|
-
|
|
123
|
+
goToUrl(url, position) {
|
|
124
|
+
if (!url)
|
|
125
|
+
return;
|
|
126
|
+
this.sendDataLayerSubscribeButtonClicked(position);
|
|
127
|
+
const originHost = encodeURIComponent(window.location.href);
|
|
137
128
|
redirectToCheckout({
|
|
138
|
-
link: `${
|
|
129
|
+
link: `${url.replace('https://checkoutv2.kompas.id/', '')}&referrer=${originHost}`,
|
|
139
130
|
source: this.type,
|
|
140
131
|
});
|
|
141
132
|
}
|
|
@@ -146,27 +137,14 @@ let KompasFreewall = class KompasFreewall extends LitElement {
|
|
|
146
137
|
super.connectedCallback();
|
|
147
138
|
await this.updateComplete;
|
|
148
139
|
this.isExpand = this.expand;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
this.getFreewallData();
|
|
152
|
-
this.sendDataLayerPaywallViewed();
|
|
140
|
+
await this.getFreewallData();
|
|
141
|
+
await this.sendDataLayerPaywallViewed();
|
|
153
142
|
}
|
|
154
143
|
async getFreewallData() {
|
|
155
144
|
try {
|
|
156
|
-
const response = await fetch('https://cdn-www.kompas.id/web-component/freewall.json');
|
|
145
|
+
const response = await fetch('https://cdn-www.kompas.id/web-component/freewall-new.json');
|
|
157
146
|
const json = await response.json();
|
|
158
|
-
this.
|
|
159
|
-
headCopyCollapse: json.headCopyCollapse,
|
|
160
|
-
headCopyExpand: json.headCopyExpand,
|
|
161
|
-
subscriptionUrl: json.subscriptionUrl,
|
|
162
|
-
subscriptionTitle: json.subscriptionTitle,
|
|
163
|
-
subscriptionTitleGuest: json.subscriptionTitleGuest,
|
|
164
|
-
subscriptionDescription: json.subscriptionDescription,
|
|
165
|
-
subscriptionButtonText: json.subscriptionButtonText,
|
|
166
|
-
registerTitle: json.registerTitle,
|
|
167
|
-
registerDescription: json.registerDescription,
|
|
168
|
-
registerButtonText: json.registerButtonText,
|
|
169
|
-
};
|
|
147
|
+
this.pullData = json;
|
|
170
148
|
}
|
|
171
149
|
catch (error) {
|
|
172
150
|
throw Error('Failed to get metered paywall data');
|
|
@@ -183,27 +161,22 @@ let KompasFreewall = class KompasFreewall extends LitElement {
|
|
|
183
161
|
? html `
|
|
184
162
|
<div class="sticky bottom-0 w-full h-full z-20 top-shadow">
|
|
185
163
|
<div
|
|
186
|
-
class="flex flex-col w-full bg-blue-100 justify-center ${this
|
|
164
|
+
class="flex flex-col transition-all w-full bg-blue-100 justify-center ${this
|
|
187
165
|
.isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24"
|
|
188
166
|
>
|
|
189
167
|
<kompasid-freewall-head
|
|
190
168
|
.expand=${this.isExpand}
|
|
191
|
-
.type=${this.type}
|
|
192
|
-
.head_copy_expand=${this.jsonPackageData.headCopyExpand}
|
|
193
|
-
.head_copy_collapse=${this.jsonPackageData.headCopyCollapse}
|
|
194
169
|
.toggleExpand=${() => this.toggleExpand()}
|
|
195
|
-
.
|
|
196
|
-
.
|
|
197
|
-
.jsonPackageData=${this.jsonPackageData}
|
|
170
|
+
.headData=${this.pullData.head}
|
|
171
|
+
.onButtonClick=${(url) => this.goToUrl(url)}
|
|
198
172
|
></kompasid-freewall-head>
|
|
199
173
|
${this.isExpand
|
|
200
|
-
? html
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
></kompasid-freewall-body>`
|
|
174
|
+
? html ` <div>
|
|
175
|
+
<kompasid-freewall-body
|
|
176
|
+
.bodyData=${this.pullData.body}
|
|
177
|
+
.onButtonClick=${(url, position) => this.goToUrl(url, position)}
|
|
178
|
+
></kompasid-freewall-body>
|
|
179
|
+
</div>`
|
|
207
180
|
: nothing}
|
|
208
181
|
</div>
|
|
209
182
|
</div>
|
|
@@ -223,36 +196,15 @@ KompasFreewall.styles = [
|
|
|
223
196
|
`,
|
|
224
197
|
TWStyles,
|
|
225
198
|
];
|
|
226
|
-
__decorate([
|
|
227
|
-
property({ type: Boolean })
|
|
228
|
-
], KompasFreewall.prototype, "isLogin", void 0);
|
|
229
199
|
__decorate([
|
|
230
200
|
property({ type: String })
|
|
231
201
|
], KompasFreewall.prototype, "type", void 0);
|
|
232
|
-
__decorate([
|
|
233
|
-
property({ type: String })
|
|
234
|
-
], KompasFreewall.prototype, "head_copy_expand", void 0);
|
|
235
|
-
__decorate([
|
|
236
|
-
property({ type: String })
|
|
237
|
-
], KompasFreewall.prototype, "head_copy_collapse", void 0);
|
|
238
202
|
__decorate([
|
|
239
203
|
property({ type: Boolean })
|
|
240
204
|
], KompasFreewall.prototype, "expand", void 0);
|
|
241
205
|
__decorate([
|
|
242
206
|
property({ type: String })
|
|
243
|
-
], KompasFreewall.prototype, "
|
|
244
|
-
__decorate([
|
|
245
|
-
property({ type: String })
|
|
246
|
-
], KompasFreewall.prototype, "paywall_subscription_package", void 0);
|
|
247
|
-
__decorate([
|
|
248
|
-
property({ type: Number })
|
|
249
|
-
], KompasFreewall.prototype, "paywall_subscription_id", void 0);
|
|
250
|
-
__decorate([
|
|
251
|
-
property({ type: Number })
|
|
252
|
-
], KompasFreewall.prototype, "paywall_subscription_price", void 0);
|
|
253
|
-
__decorate([
|
|
254
|
-
property({ type: Number })
|
|
255
|
-
], KompasFreewall.prototype, "paywall_position", void 0);
|
|
207
|
+
], KompasFreewall.prototype, "tracker_paywall_location", void 0);
|
|
256
208
|
__decorate([
|
|
257
209
|
property({ type: String })
|
|
258
210
|
], KompasFreewall.prototype, "tracker_page_type", void 0);
|
|
@@ -294,10 +246,7 @@ __decorate([
|
|
|
294
246
|
], KompasFreewall.prototype, "isExpand", void 0);
|
|
295
247
|
__decorate([
|
|
296
248
|
state()
|
|
297
|
-
], KompasFreewall.prototype, "
|
|
298
|
-
__decorate([
|
|
299
|
-
state()
|
|
300
|
-
], KompasFreewall.prototype, "jsonPackageData", void 0);
|
|
249
|
+
], KompasFreewall.prototype, "pullData", void 0);
|
|
301
250
|
KompasFreewall = __decorate([
|
|
302
251
|
customElement('kompasid-freewall')
|
|
303
252
|
], KompasFreewall);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KompasFreewall.js","sourceRoot":"","sources":["../../../../src/components/kompasid-freewall/KompasFreewall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD,OAAO,EA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3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAAwB;AACvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DAA2B;AAC1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kEAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAA0B;AACzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iEAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAAiC;AAkBnD;IAAR,KAAK,EAAE;iDAAkC;AACjC;IAAR,KAAK,EAAE;gDAAiC;AAChC;IAAR,KAAK,EAAE;mDAAqD;AACpD;IAAR,KAAK,EAAE;uDAAiE;AAlF9D,cAAc;IAD1B,aAAa,CAAC,mBAAmB,CAAC;GACtB,cAAc,CAqP1B;SArPY,cAAc","sourcesContent":["import { html, css, LitElement, nothing } from 'lit'\nimport { property, customElement, state } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { JsonPackageData, PackageData } from './types.js'\nimport { redirectToCheckout } from '../../utils/cta.js'\nimport '../kompasid-freewall-head/KompasFreewallHead.js'\nimport '../kompasid-freewall-body/KompasFreewallBody.js'\n\n@customElement('kompasid-freewall')\nexport class KompasFreewall extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .top-shadow {\n box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.16);\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property isLogin untuk menghandle apakah user sudah login atau belum\n * property type untuk menghandle tipe freewall\n * property head_copy_expand to update copy header when expand\n * property head_copy_collapse to update copy header when collapse\n * property expand to handle expand/collapse\n * property paywall_location is the location where user encounter the paywall\n * property paywall_subscription_package is the name of the subscription package viewed by user\n * property paywall_subscription_id is the ID of the subscription package viewed by user\n * property paywall_subscription_price is the price of the subscription package viewed by user\n * property paywall_position is the position of the subscription package viewed by user\n * property tracker_page_type is the type of the page\n * property tracker_page_title is the title of the page\n * property tracker_content_id is the ID of article (slug)\n * property content_title is the title of article\n * property tracker_content_categories is the category of the content\n * property tracker_content_type is to decide whether it's free article or paid article\n * property tracker_user_type is the type of user based on their subscription\n * property tracker_subscription_status is the status of their subscription\n * property tracker_page_domain is the page domain\n * property tracker_metered_wall_type is the type of metered wall\n * property tracker_metered_wall_balance is the balance of their metered wall\n */\n\n @property({ type: Boolean }) isLogin = false\n @property({ type: String }) type: 'article' | 'landing_page' = 'article'\n @property({ type: String }) head_copy_expand = ''\n @property({ type: String }) head_copy_collapse = ''\n @property({ type: Boolean }) expand = true\n @property({ type: String }) paywall_location = ''\n @property({ type: String }) paywall_subscription_package = ''\n @property({ type: Number }) paywall_subscription_id = 0\n @property({ type: Number }) paywall_subscription_price = 0\n @property({ type: Number }) paywall_position = 1\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_page_title = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n\n showPackage = {\n duration: 1,\n durationType: 3,\n id: '9802035',\n link: 'kdp?productId=9802035&referrer=',\n price: 50000,\n position: 1,\n title: 'Kompas Digital Premium 1 Bulan',\n slug: 'cash-b2c-halaman-berlangganan-reguler_digital-kdp-1',\n referrer: '',\n }\n\n /**\n * State\n */\n\n @state() private isLoading: Boolean = true\n @state() private isExpand: boolean = true\n @state() private packageData: PackageData = {} as PackageData\n @state() private jsonPackageData: JsonPackageData = {} as JsonPackageData\n\n /**\n * Getter\n */\n\n get isArticle() {\n return this.type === 'article'\n }\n\n /**\n * Data Layer\n */\n\n private prepareImpressionsData(): Record<string, any> {\n const baseData = {\n paywall_location: this.paywall_location,\n paywall_subscription_package:\n this.paywall_subscription_package || this.packageData.slug,\n paywall_subscription_id:\n this.paywall_subscription_id || this.packageData.id,\n paywall_subscription_price:\n this.paywall_subscription_price || this.packageData.price,\n paywall_position: this.paywall_position || this.packageData.position,\n user_type: this.tracker_user_type,\n subscription_status: this.tracker_subscription_status,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n page_type: this.tracker_page_type,\n metered_wall_type: this.tracker_metered_wall_type || 'FP',\n metered_wall_balance: this.tracker_metered_wall_balance,\n }\n\n if (this.isArticle) {\n return {\n ...baseData,\n content_id: this.tracker_content_id,\n content_title: this.tracker_content_title,\n content_categories: this.tracker_content_categories,\n content_type: this.tracker_content_type,\n }\n }\n return {\n ...baseData,\n page_title: this.tracker_page_title,\n }\n }\n\n private sendDataLayer(\n event: string,\n includeImpressions: boolean = false\n ): void {\n const impressionsData = this.prepareImpressionsData()\n\n const data = includeImpressions\n ? { event, impressions: [impressionsData] }\n : { event, ...impressionsData }\n\n window.dataLayer.push(data)\n }\n\n private sendDataLayerPaywallViewed(): void {\n if (this.isExpand) this.sendDataLayer('paywall_viewed', true)\n }\n\n private sendDataLayerSubscribeButtonClicked(): void {\n this.sendDataLayer('subscribe_button_clicked')\n }\n\n /**\n * Logic Function\n */\n\n private toggleExpand() {\n this.isExpand = !this.isExpand\n this.sendDataLayerPaywallViewed()\n }\n\n private onSubscriptionClick() {\n this.sendDataLayerSubscribeButtonClicked()\n redirectToCheckout({\n link: `${this.jsonPackageData.subscriptionUrl}&referrer=${this.packageData.referrer}`,\n source: this.type,\n })\n }\n\n /**\n * Lifecycle\n */\n\n override async connectedCallback() {\n super.connectedCallback()\n await this.updateComplete\n\n this.isExpand = this.expand\n\n const originHost: string = encodeURIComponent(window.location.href)\n this.packageData = { ...this.showPackage, referrer: originHost }\n this.getFreewallData()\n\n this.sendDataLayerPaywallViewed()\n }\n\n async getFreewallData() {\n try {\n const response = await fetch(\n 'https://cdn-www.kompas.id/web-component/freewall.json'\n )\n const json = await response.json()\n this.jsonPackageData = {\n headCopyCollapse: json.headCopyCollapse,\n headCopyExpand: json.headCopyExpand,\n subscriptionUrl: json.subscriptionUrl,\n subscriptionTitle: json.subscriptionTitle,\n subscriptionTitleGuest: json.subscriptionTitleGuest,\n subscriptionDescription: json.subscriptionDescription,\n subscriptionButtonText: json.subscriptionButtonText,\n registerTitle: json.registerTitle,\n registerDescription: json.registerDescription,\n registerButtonText: json.registerButtonText,\n }\n } catch (error) {\n throw Error('Failed to get metered paywall data')\n } finally {\n this.isLoading = false\n }\n }\n\n /**\n * Render Statement\n */\n\n render() {\n return !this.isLoading\n ? html`\n <div class=\"sticky bottom-0 w-full h-full z-20 top-shadow\">\n <div\n class=\"flex flex-col w-full bg-blue-100 justify-center ${this\n .isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24\"\n >\n <kompasid-freewall-head\n .expand=${this.isExpand}\n .type=${this.type}\n .head_copy_expand=${this.jsonPackageData.headCopyExpand}\n .head_copy_collapse=${this.jsonPackageData.headCopyCollapse}\n .toggleExpand=${() => this.toggleExpand()}\n .onSubscriptionClick=${() => this.onSubscriptionClick()}\n .packageData=${this.packageData}\n .jsonPackageData=${this.jsonPackageData}\n ></kompasid-freewall-head>\n ${this.isExpand\n ? html`<kompasid-freewall-body\n .type=${this.type}\n .onSubscriptionClick=${() => this.onSubscriptionClick()}\n .packageData=${this.packageData}\n .jsonPackageData=${this.jsonPackageData}\n ?isLogin=${this.isLogin}\n ></kompasid-freewall-body>`\n : nothing}\n </div>\n </div>\n `\n : nothing\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KompasFreewall.js","sourceRoot":"","sources":["../../../../src/components/kompasid-freewall/KompasFreewall.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,iDAAiD,CAAA;AACxD,OAAO,iDAAiD,CAAA;AAGjD,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAcL;;WAEG;QACH;;;;;;;;;;;;;;;WAeG;QAEyB,SAAI,GAA+B,SAAS,CAAA;QAC3C,WAAM,GAAG,IAAI,CAAA;QACd,6BAAwB,GAAG,EAAE,CAAA;QAC7B,sBAAiB,GAAG,EAAE,CAAA;QACtB,uBAAkB,GAAG,EAAE,CAAA;QACvB,uBAAkB,GAAG,EAAE,CAAA;QACvB,0BAAqB,GAAG,EAAE,CAAA;QAC1B,+BAA0B,GAAG,EAAE,CAAA;QAC/B,yBAAoB,GAAG,EAAE,CAAA;QACzB,sBAAiB,GAAG,EAAE,CAAA;QACtB,gCAA2B,GAAG,EAAE,CAAA;QAChC,wBAAmB,GAAG,EAAE,CAAA;QACxB,8BAAyB,GAAG,EAAE,CAAA;QAC9B,iCAA4B,GAAG,CAAC,CAAA;QAE5D,gBAAW,GAAG;YACZ,QAAQ,EAAE,CAAC;YACX,YAAY,EAAE,CAAC;YACf,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,iCAAiC;YACvC,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,CAAC;YACX,KAAK,EAAE,gCAAgC;YACvC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C;AAkBnD;IAAR,KAAK,EAAE;iDAAkC;AACjC;IAAR,KAAK,EAAE;gDAAiC;AAChC;IAAR,KAAK,EAAE;gDAAoE;AAnEjE,cAAc;IAD1B,aAAa,CAAC,mBAAmB,CAAC;GACtB,cAAc,CA4N1B;SA5NY,cAAc","sourcesContent":["import { html, css, LitElement, nothing } from 'lit'\nimport { property, customElement, state } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { JsonPullDataFreeWall, CardPackage } from './types.js'\nimport { redirectToCheckout } from '../../utils/cta.js'\nimport '../kompasid-freewall-head/KompasFreewallHead.js'\nimport '../kompasid-freewall-body/KompasFreewallBody.js'\n\n@customElement('kompasid-freewall')\nexport class KompasFreewall extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .top-shadow {\n box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.16);\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property type untuk menghandle tipe freewall (akan menyematkan beberapa tipe data layer)\n * property expand to handle expand/collapse\n * property tracker_paywall_location is the location where user encounter the paywall\n * property tracker_page_type is the type of the page\n * property tracker_page_title is the title of the page\n * property tracker_user_type is the type of user based on their subscription\n * property tracker_subscription_status is the status of their subscription\n * property tracker_page_domain is the page domain\n * property tracker_metered_wall_type is the type of metered wall\n * property tracker_metered_wall_balance is the balance of their metered wall\n * property tracker_content_title is the title of article [type=article]\n * property tracker_content_id is the ID of article (slug) [type=article]\n * property tracker_content_categories is the category of the content [type=article]\n * property tracker_content_type is to decide whether it's free article or paid article [type=article]\n */\n\n @property({ type: String }) type: 'article' | 'landing_page' = 'article'\n @property({ type: Boolean }) expand = true\n @property({ type: String }) tracker_paywall_location = ''\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_page_title = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n\n showPackage = {\n duration: 1,\n durationType: 3,\n id: '9802035',\n link: 'kdp?productId=9802035&referrer=',\n price: 50000,\n position: 1,\n title: 'Kompas Digital Premium 1 Bulan',\n slug: 'cash-b2c-halaman-berlangganan-reguler_digital-kdp-1',\n referrer: '',\n }\n\n /**\n * State\n */\n\n @state() private isLoading: Boolean = true\n @state() private isExpand: boolean = true\n @state() private pullData: JsonPullDataFreeWall = {} as JsonPullDataFreeWall\n\n /**\n * Getter\n */\n\n get isArticle() {\n return this.type === 'article'\n }\n\n /**\n * Data Layer\n */\n\n private prepareImpressionsData(item: CardPackage): Record<string, any> {\n const baseData = {\n paywall_subscription_package: item.packageSlug,\n paywall_subscription_id: item.packageId,\n paywall_subscription_price: item.priceDiscount || item.priceBased,\n paywall_position: item.position,\n paywall_location: this.tracker_paywall_location, // from user\n user_type: this.tracker_user_type, // from user\n subscription_status: this.tracker_subscription_status, // from user\n page_domain: this.tracker_page_domain || 'Kompas.id', // from user\n page_type: this.tracker_page_type, // from user\n metered_wall_type: this.tracker_metered_wall_type || 'FP', // from user\n metered_wall_balance: this.tracker_metered_wall_balance, // from user\n }\n\n if (this.isArticle) {\n return {\n ...baseData,\n content_id: this.tracker_content_id,\n content_title: this.tracker_content_title,\n content_categories: this.tracker_content_categories,\n content_type: this.tracker_content_type,\n }\n }\n return {\n ...baseData,\n page_title: this.tracker_page_title,\n }\n }\n\n private sendDataLayer(\n event: string,\n position: number = 0 // ganti ke specific package\n ): void {\n const impressionsData = this.pullData.body.map((item: CardPackage) =>\n this.prepareImpressionsData(item)\n )\n\n const get = this.pullData.body.find(item => item.position === position)\n\n const specificData = get ? this.prepareImpressionsData(get) : []\n\n const data = position\n ? { event, ...specificData }\n : { event, impressions: [impressionsData] }\n\n window.dataLayer.push(data)\n }\n\n private sendDataLayerPaywallViewed(): void {\n if (this.isExpand) this.sendDataLayer('paywall_viewed')\n }\n\n private sendDataLayerSubscribeButtonClicked(pos?: number): void {\n this.sendDataLayer('subscribe_button_clicked', pos)\n }\n\n /**\n * Logic Function\n */\n\n private toggleExpand() {\n this.isExpand = !this.isExpand\n this.sendDataLayerPaywallViewed()\n }\n\n private goToUrl(url: string, position?: number) {\n if (!url) return\n this.sendDataLayerSubscribeButtonClicked(position)\n const originHost: string = encodeURIComponent(window.location.href)\n redirectToCheckout({\n link: `${url.replace(\n 'https://checkoutv2.kompas.id/',\n ''\n )}&referrer=${originHost}`,\n source: this.type,\n })\n }\n\n /**\n * Lifecycle\n */\n\n override async connectedCallback() {\n super.connectedCallback()\n await this.updateComplete\n\n this.isExpand = this.expand\n await this.getFreewallData()\n\n await this.sendDataLayerPaywallViewed()\n }\n\n async getFreewallData() {\n try {\n const response = await fetch(\n 'https://cdn-www.kompas.id/web-component/freewall-new.json'\n )\n const json: JsonPullDataFreeWall = await response.json()\n this.pullData = json\n } catch (error) {\n throw Error('Failed to get metered paywall data')\n } finally {\n this.isLoading = false\n }\n }\n\n /**\n * Render Statement\n */\n\n render() {\n return !this.isLoading\n ? html`\n <div class=\"sticky bottom-0 w-full h-full z-20 top-shadow\">\n <div\n class=\"flex flex-col transition-all w-full bg-blue-100 justify-center ${this\n .isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24\"\n >\n <kompasid-freewall-head\n .expand=${this.isExpand}\n .toggleExpand=${() => this.toggleExpand()}\n .headData=${this.pullData.head}\n .onButtonClick=${(url: string) => this.goToUrl(url)}\n ></kompasid-freewall-head>\n ${this.isExpand\n ? html` <div>\n <kompasid-freewall-body\n .bodyData=${this.pullData.body}\n .onButtonClick=${(url: string, position: number) =>\n this.goToUrl(url, position)}\n ></kompasid-freewall-body>\n </div>`\n : nothing}\n </div>\n </div>\n `\n : nothing\n }\n}\n"]}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { LitElement, nothing } from 'lit';
|
|
2
|
+
import '../kompasid-freewall-head/KompasFreewallHead.js';
|
|
3
|
+
import '../kompasid-freewall-body/KompasFreewallBody.js';
|
|
4
|
+
export declare class KompasFreewall extends LitElement {
|
|
5
|
+
static styles: import("lit").CSSResult[];
|
|
6
|
+
/**
|
|
7
|
+
* Props
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* property isLogin untuk menghandle apakah user sudah login atau belum
|
|
11
|
+
* property type untuk menghandle tipe freewall
|
|
12
|
+
* property head_copy_expand to update copy header when expand
|
|
13
|
+
* property head_copy_collapse to update copy header when collapse
|
|
14
|
+
* property expand to handle expand/collapse
|
|
15
|
+
* property paywall_location is the location where user encounter the paywall
|
|
16
|
+
* property paywall_subscription_package is the name of the subscription package viewed by user
|
|
17
|
+
* property paywall_subscription_id is the ID of the subscription package viewed by user
|
|
18
|
+
* property paywall_subscription_price is the price of the subscription package viewed by user
|
|
19
|
+
* property paywall_position is the position of the subscription package viewed by user
|
|
20
|
+
* property tracker_page_type is the type of the page
|
|
21
|
+
* property tracker_page_title is the title of the page
|
|
22
|
+
* property tracker_content_id is the ID of article (slug)
|
|
23
|
+
* property content_title is the title of article
|
|
24
|
+
* property tracker_content_categories is the category of the content
|
|
25
|
+
* property tracker_content_type is to decide whether it's free article or paid article
|
|
26
|
+
* property tracker_user_type is the type of user based on their subscription
|
|
27
|
+
* property tracker_subscription_status is the status of their subscription
|
|
28
|
+
* property tracker_page_domain is the page domain
|
|
29
|
+
* property tracker_metered_wall_type is the type of metered wall
|
|
30
|
+
* property tracker_metered_wall_balance is the balance of their metered wall
|
|
31
|
+
*/
|
|
32
|
+
isLogin: boolean;
|
|
33
|
+
type: 'article' | 'landing_page';
|
|
34
|
+
head_copy_expand: string;
|
|
35
|
+
head_copy_collapse: string;
|
|
36
|
+
expand: boolean;
|
|
37
|
+
paywall_location: string;
|
|
38
|
+
paywall_subscription_package: string;
|
|
39
|
+
paywall_subscription_id: number;
|
|
40
|
+
paywall_subscription_price: number;
|
|
41
|
+
paywall_position: number;
|
|
42
|
+
tracker_page_type: string;
|
|
43
|
+
tracker_page_title: string;
|
|
44
|
+
tracker_content_id: string;
|
|
45
|
+
tracker_content_title: string;
|
|
46
|
+
tracker_content_categories: string;
|
|
47
|
+
tracker_content_type: string;
|
|
48
|
+
tracker_user_type: string;
|
|
49
|
+
tracker_subscription_status: string;
|
|
50
|
+
tracker_page_domain: string;
|
|
51
|
+
tracker_metered_wall_type: string;
|
|
52
|
+
tracker_metered_wall_balance: number;
|
|
53
|
+
showPackage: {
|
|
54
|
+
duration: number;
|
|
55
|
+
durationType: number;
|
|
56
|
+
id: string;
|
|
57
|
+
link: string;
|
|
58
|
+
price: number;
|
|
59
|
+
position: number;
|
|
60
|
+
title: string;
|
|
61
|
+
slug: string;
|
|
62
|
+
referrer: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* State
|
|
66
|
+
*/
|
|
67
|
+
private isLoading;
|
|
68
|
+
private isExpand;
|
|
69
|
+
private packageData;
|
|
70
|
+
private jsonPackageData;
|
|
71
|
+
/**
|
|
72
|
+
* Getter
|
|
73
|
+
*/
|
|
74
|
+
get isArticle(): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Data Layer
|
|
77
|
+
*/
|
|
78
|
+
private prepareImpressionsData;
|
|
79
|
+
private sendDataLayer;
|
|
80
|
+
private sendDataLayerPaywallViewed;
|
|
81
|
+
private sendDataLayerSubscribeButtonClicked;
|
|
82
|
+
/**
|
|
83
|
+
* Logic Function
|
|
84
|
+
*/
|
|
85
|
+
private toggleExpand;
|
|
86
|
+
private onSubscriptionClick;
|
|
87
|
+
/**
|
|
88
|
+
* Lifecycle
|
|
89
|
+
*/
|
|
90
|
+
connectedCallback(): Promise<void>;
|
|
91
|
+
getFreewallData(): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Render Statement
|
|
94
|
+
*/
|
|
95
|
+
render(): import("lit-html").TemplateResult<1> | typeof nothing;
|
|
96
|
+
}
|