@kompasid/lit-web-components 0.9.11 → 0.9.13

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 (44) hide show
  1. package/demo/index.html +2 -2
  2. package/dist/src/components/kompasid-freewall/KompasFreewall.d.ts +9 -24
  3. package/dist/src/components/kompasid-freewall/KompasFreewall.js +44 -100
  4. package/dist/src/components/kompasid-freewall/KompasFreewall.js.map +1 -1
  5. package/dist/src/components/kompasid-freewall/old_KompasFreewall.d.ts +96 -0
  6. package/dist/src/components/kompasid-freewall/old_KompasFreewall.js +305 -0
  7. package/dist/src/components/kompasid-freewall/old_KompasFreewall.js.map +1 -0
  8. package/dist/src/components/kompasid-freewall/types.d.ts +26 -0
  9. package/dist/src/components/kompasid-freewall/types.js.map +1 -1
  10. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.d.ts +9 -14
  11. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js +58 -102
  12. package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js.map +1 -1
  13. package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.d.ts +34 -0
  14. package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js +228 -0
  15. package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js.map +1 -0
  16. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.d.ts +8 -19
  17. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js +33 -52
  18. package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js.map +1 -1
  19. package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.d.ts +38 -0
  20. package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js +125 -0
  21. package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js.map +1 -0
  22. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +1 -1
  23. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
  24. package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js +5 -7
  25. package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js.map +1 -1
  26. package/dist/tailwind/tailwind.js +48 -8
  27. package/dist/tailwind/tailwind.js.map +1 -1
  28. package/dist/tsconfig.tsbuildinfo +1 -1
  29. package/package.json +1 -1
  30. package/src/components/kompasid-freewall/KompasFreewall.ts +52 -85
  31. package/src/components/kompasid-freewall/old_KompasFreewall.ts +255 -0
  32. package/src/components/kompasid-freewall/readme.md +40 -84
  33. package/src/components/kompasid-freewall/types.ts +29 -0
  34. package/src/components/kompasid-freewall-body/KompasFreewallBody.ts +59 -101
  35. package/src/components/kompasid-freewall-body/old_KompasFreewallBody.ts +224 -0
  36. package/src/components/kompasid-freewall-body/readme.md +31 -7
  37. package/src/components/kompasid-freewall-head/KompasFreewallHead.ts +31 -39
  38. package/src/components/kompasid-freewall-head/old_KompasFreewallHead.ts +103 -0
  39. package/src/components/kompasid-freewall-head/readme.md +29 -13
  40. package/src/components/kompasid-grace-period/KompasGracePeriod.ts +1 -1
  41. package/src/components/kompasid-menu-side-bar/KompasMenuSideBar.ts +5 -7
  42. package/tailwind/tailwind.css +48 -6
  43. package/tailwind/tailwind.ts +48 -8
  44. 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
- <!-- <kompasid-grace-period
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 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
10
+ * property type untuk menghandle tipe freewall (akan menyematkan beberapa tipe data layer)
14
11
  * 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
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
- paywall_location: string;
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 packageData;
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 onSubscriptionClick;
71
+ private goToUrl;
87
72
  /**
88
73
  * Lifecycle
89
74
  */
@@ -2,7 +2,6 @@ import { __decorate } from "tslib";
2
2
  import { html, css, LitElement, nothing } from 'lit';
3
3
  import { property, customElement, state } from 'lit/decorators.js';
4
4
  import { TWStyles } from '../../../tailwind/tailwind.js';
5
- import { redirectToCheckout } from '../../utils/cta.js';
6
5
  import '../kompasid-freewall-head/KompasFreewallHead.js';
7
6
  import '../kompasid-freewall-body/KompasFreewallBody.js';
8
7
  let KompasFreewall = class KompasFreewall extends LitElement {
@@ -12,38 +11,24 @@ let KompasFreewall = class KompasFreewall extends LitElement {
12
11
  * Props
13
12
  */
14
13
  /**
15
- * property isLogin untuk menghandle apakah user sudah login atau belum
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
14
+ * property type untuk menghandle tipe freewall (akan menyematkan beberapa tipe data layer)
19
15
  * property expand to handle expand/collapse
20
- * property paywall_location is the location where user encounter the paywall
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
16
+ * property tracker_paywall_location is the location where user encounter the paywall
25
17
  * property tracker_page_type is the type of the page
26
18
  * 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
19
  * property tracker_user_type is the type of user based on their subscription
32
20
  * property tracker_subscription_status is the status of their subscription
33
21
  * property tracker_page_domain is the page domain
34
22
  * property tracker_metered_wall_type is the type of metered wall
35
23
  * property tracker_metered_wall_balance is the balance of their metered wall
24
+ * property tracker_content_title is the title of article [type=article]
25
+ * property tracker_content_id is the ID of article (slug) [type=article]
26
+ * property tracker_content_categories is the category of the content [type=article]
27
+ * property tracker_content_type is to decide whether it's free article or paid article [type=article]
36
28
  */
37
- this.isLogin = false;
38
29
  this.type = 'article';
39
- this.head_copy_expand = '';
40
- this.head_copy_collapse = '';
41
30
  this.expand = true;
42
- this.paywall_location = '';
43
- this.paywall_subscription_package = '';
44
- this.paywall_subscription_id = 0;
45
- this.paywall_subscription_price = 0;
46
- this.paywall_position = 1;
31
+ this.tracker_paywall_location = '';
47
32
  this.tracker_page_type = '';
48
33
  this.tracker_page_title = '';
49
34
  this.tracker_content_id = '';
@@ -71,8 +56,7 @@ let KompasFreewall = class KompasFreewall extends LitElement {
71
56
  */
72
57
  this.isLoading = true;
73
58
  this.isExpand = true;
74
- this.packageData = {};
75
- this.jsonPackageData = {};
59
+ this.pullData = {};
76
60
  }
77
61
  /**
78
62
  * Getter
@@ -83,19 +67,19 @@ let KompasFreewall = class KompasFreewall extends LitElement {
83
67
  /**
84
68
  * Data Layer
85
69
  */
86
- prepareImpressionsData() {
70
+ prepareImpressionsData(item) {
87
71
  const baseData = {
88
- paywall_location: this.paywall_location,
89
- paywall_subscription_package: this.paywall_subscription_package || this.packageData.slug,
90
- paywall_subscription_id: this.paywall_subscription_id || this.packageData.id,
91
- paywall_subscription_price: this.paywall_subscription_price || this.packageData.price,
92
- paywall_position: this.paywall_position || this.packageData.position,
72
+ paywall_subscription_package: item.packageSlug,
73
+ paywall_subscription_id: item.packageId,
74
+ paywall_subscription_price: item.priceDiscount || item.priceBased,
75
+ paywall_position: item.position,
76
+ paywall_location: this.tracker_paywall_location,
93
77
  user_type: this.tracker_user_type,
94
78
  subscription_status: this.tracker_subscription_status,
95
79
  page_domain: this.tracker_page_domain || 'Kompas.id',
96
80
  page_type: this.tracker_page_type,
97
81
  metered_wall_type: this.tracker_metered_wall_type || 'FP',
98
- metered_wall_balance: this.tracker_metered_wall_balance,
82
+ metered_wall_balance: this.tracker_metered_wall_balance, // from user
99
83
  };
100
84
  if (this.isArticle) {
101
85
  return {
@@ -111,19 +95,22 @@ let KompasFreewall = class KompasFreewall extends LitElement {
111
95
  page_title: this.tracker_page_title,
112
96
  };
113
97
  }
114
- sendDataLayer(event, includeImpressions = false) {
115
- const impressionsData = this.prepareImpressionsData();
116
- const data = includeImpressions
117
- ? { event, impressions: [impressionsData] }
118
- : { event, ...impressionsData };
98
+ sendDataLayer(event, position = 0 // ganti ke specific package
99
+ ) {
100
+ const impressionsData = this.pullData.body.map((item) => this.prepareImpressionsData(item));
101
+ const get = this.pullData.body.find(item => item.position === position);
102
+ const specificData = get ? this.prepareImpressionsData(get) : [];
103
+ const data = position
104
+ ? { event, ...specificData }
105
+ : { event, impressions: [impressionsData] };
119
106
  window.dataLayer.push(data);
120
107
  }
121
108
  sendDataLayerPaywallViewed() {
122
109
  if (this.isExpand)
123
- this.sendDataLayer('paywall_viewed', true);
110
+ this.sendDataLayer('paywall_viewed');
124
111
  }
125
- sendDataLayerSubscribeButtonClicked() {
126
- this.sendDataLayer('subscribe_button_clicked');
112
+ sendDataLayerSubscribeButtonClicked(pos) {
113
+ this.sendDataLayer('subscribe_button_clicked', pos);
127
114
  }
128
115
  /**
129
116
  * Logic Function
@@ -132,12 +119,11 @@ let KompasFreewall = class KompasFreewall extends LitElement {
132
119
  this.isExpand = !this.isExpand;
133
120
  this.sendDataLayerPaywallViewed();
134
121
  }
135
- onSubscriptionClick() {
136
- this.sendDataLayerSubscribeButtonClicked();
137
- redirectToCheckout({
138
- link: `${this.jsonPackageData.subscriptionUrl}&referrer=${this.packageData.referrer}`,
139
- source: this.type,
140
- });
122
+ goToUrl(url, position) {
123
+ if (!url)
124
+ return;
125
+ this.sendDataLayerSubscribeButtonClicked(position);
126
+ window.open(url, '_blank');
141
127
  }
142
128
  /**
143
129
  * Lifecycle
@@ -146,27 +132,14 @@ let KompasFreewall = class KompasFreewall extends LitElement {
146
132
  super.connectedCallback();
147
133
  await this.updateComplete;
148
134
  this.isExpand = this.expand;
149
- const originHost = encodeURIComponent(window.location.href);
150
- this.packageData = { ...this.showPackage, referrer: originHost };
151
135
  this.getFreewallData();
152
136
  this.sendDataLayerPaywallViewed();
153
137
  }
154
138
  async getFreewallData() {
155
139
  try {
156
- const response = await fetch('https://cdn-www.kompas.id/web-component/freewall.json');
140
+ const response = await fetch('https://cdn-www.kompas.id/web-component/freewall-new.json');
157
141
  const json = await response.json();
158
- this.jsonPackageData = {
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
- };
142
+ this.pullData = json;
170
143
  }
171
144
  catch (error) {
172
145
  throw Error('Failed to get metered paywall data');
@@ -183,27 +156,22 @@ let KompasFreewall = class KompasFreewall extends LitElement {
183
156
  ? html `
184
157
  <div class="sticky bottom-0 w-full h-full z-20 top-shadow">
185
158
  <div
186
- class="flex flex-col w-full bg-blue-100 justify-center ${this
159
+ class="flex flex-col transition-all w-full bg-blue-100 justify-center ${this
187
160
  .isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24"
188
161
  >
189
162
  <kompasid-freewall-head
190
163
  .expand=${this.isExpand}
191
- .type=${this.type}
192
- .head_copy_expand=${this.jsonPackageData.headCopyExpand}
193
- .head_copy_collapse=${this.jsonPackageData.headCopyCollapse}
194
164
  .toggleExpand=${() => this.toggleExpand()}
195
- .onSubscriptionClick=${() => this.onSubscriptionClick()}
196
- .packageData=${this.packageData}
197
- .jsonPackageData=${this.jsonPackageData}
165
+ .headData=${this.pullData.head}
166
+ .onButtonClick=${(url) => this.goToUrl(url)}
198
167
  ></kompasid-freewall-head>
199
168
  ${this.isExpand
200
- ? html `<kompasid-freewall-body
201
- .type=${this.type}
202
- .onSubscriptionClick=${() => this.onSubscriptionClick()}
203
- .packageData=${this.packageData}
204
- .jsonPackageData=${this.jsonPackageData}
205
- ?isLogin=${this.isLogin}
206
- ></kompasid-freewall-body>`
169
+ ? html ` <div>
170
+ <kompasid-freewall-body
171
+ .bodyData=${this.pullData.body}
172
+ .onButtonClick=${(url, position) => this.goToUrl(url, position)}
173
+ ></kompasid-freewall-body>
174
+ </div>`
207
175
  : nothing}
208
176
  </div>
209
177
  </div>
@@ -223,36 +191,15 @@ KompasFreewall.styles = [
223
191
  `,
224
192
  TWStyles,
225
193
  ];
226
- __decorate([
227
- property({ type: Boolean })
228
- ], KompasFreewall.prototype, "isLogin", void 0);
229
194
  __decorate([
230
195
  property({ type: String })
231
196
  ], 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
197
  __decorate([
239
198
  property({ type: Boolean })
240
199
  ], KompasFreewall.prototype, "expand", void 0);
241
200
  __decorate([
242
201
  property({ type: String })
243
- ], KompasFreewall.prototype, "paywall_location", void 0);
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);
202
+ ], KompasFreewall.prototype, "tracker_paywall_location", void 0);
256
203
  __decorate([
257
204
  property({ type: String })
258
205
  ], KompasFreewall.prototype, "tracker_page_type", void 0);
@@ -294,10 +241,7 @@ __decorate([
294
241
  ], KompasFreewall.prototype, "isExpand", void 0);
295
242
  __decorate([
296
243
  state()
297
- ], KompasFreewall.prototype, "packageData", void 0);
298
- __decorate([
299
- state()
300
- ], KompasFreewall.prototype, "jsonPackageData", void 0);
244
+ ], KompasFreewall.prototype, "pullData", void 0);
301
245
  KompasFreewall = __decorate([
302
246
  customElement('kompasid-freewall')
303
247
  ], 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,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;;;;;;;;;;;;;;;;;;;;;;WAsBG;QAE0B,YAAO,GAAG,KAAK,CAAA;QAChB,SAAI,GAA+B,SAAS,CAAA;QAC5C,qBAAgB,GAAG,EAAE,CAAA;QACrB,uBAAkB,GAAG,EAAE,CAAA;QACtB,WAAM,GAAG,IAAI,CAAA;QACd,qBAAgB,GAAG,EAAE,CAAA;QACrB,iCAA4B,GAAG,EAAE,CAAA;QACjC,4BAAuB,GAAG,CAAC,CAAA;QAC3B,+BAA0B,GAAG,CAAC,CAAA;QAC9B,qBAAgB,GAAG,CAAC,CAAA;QACpB,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,E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R,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,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,CAA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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;gDAAoE;AAnEjE,cAAc;IAD1B,aAAa,CAAC,mBAAmB,CAAC;GACtB,cAAc,CAqN1B;SArNY,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 '../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 window.open(url, '_blank')\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 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-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
+ }