@kompasid/lit-web-components 0.8.5 → 0.8.7

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 (22) hide show
  1. package/demo/index.html +13 -12
  2. package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.d.ts +1 -2
  3. package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js +57 -79
  4. package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js.map +1 -1
  5. package/dist/src/components/kompasid-metered-wall-register/types.d.ts +14 -10
  6. package/dist/src/components/kompasid-metered-wall-register/types.js.map +1 -1
  7. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.d.ts +0 -4
  8. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js +13 -12
  9. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js.map +1 -1
  10. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.d.ts +1 -1
  11. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js +15 -10
  12. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js.map +1 -1
  13. package/dist/src/utils/useTimeDIfference.d.ts +1 -0
  14. package/dist/src/utils/useTimeDIfference.js +27 -0
  15. package/dist/src/utils/useTimeDIfference.js.map +1 -0
  16. package/dist/tsconfig.tsbuildinfo +1 -1
  17. package/package.json +1 -1
  18. package/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.ts +68 -83
  19. package/src/components/kompasid-metered-wall-register/types.ts +16 -10
  20. package/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts +13 -12
  21. package/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.ts +19 -15
  22. package/src/utils/useTimeDIfference.ts +37 -0
package/demo/index.html CHANGED
@@ -87,7 +87,7 @@
87
87
  const headCopyExpand = ''
88
88
  const headCopyCollapse = ''
89
89
  const expand = false
90
- const countdownArticle = 2
90
+ const countdownArticle = 1
91
91
  const trackerContentAuthors = 'Author 1|Author 2'
92
92
  const trackerContentEditors = 'Editor 1|Editor 2'
93
93
  const trackerContentTags = 'Tag1|Tag2|Tag3'
@@ -98,7 +98,7 @@
98
98
  const notificationUrl = '/notif'
99
99
  const notificationTotal = '10'
100
100
  const ordersUrl = '/orders'
101
- const subscriptionUrl = ''
101
+ const subscriptionUrl = '/subs'
102
102
  const readLaterUrl = '/baca-nanti'
103
103
  const totalGracePeriod = '5'
104
104
  const productId = 9802032
@@ -122,8 +122,8 @@
122
122
  }
123
123
 
124
124
  const widgetOtherPost = {
125
- titleName: 'Lainnya Dalam Opini',
126
- titleLink: '/kategori/opini',
125
+ titleName: 'Lainnya Dalam ekonomi',
126
+ titleLink: '/kategori/ekonomi',
127
127
  }
128
128
 
129
129
  render(
@@ -143,7 +143,7 @@
143
143
  .notification_url=${notificationUrl}
144
144
  .notification_total=${notificationTotal}
145
145
  .orders_url=${ordersUrl}
146
- .subscription_url=${subscriptionUrl}
146
+ .subscriptionUrl=${subscriptionUrl}
147
147
  .read_later_url=${readLaterUrl}
148
148
  .total_grace_period=${totalGracePeriod}
149
149
  .paywall_location=${paywallLocation}
@@ -165,23 +165,23 @@
165
165
  ></kompasid-header-account>
166
166
  </div>
167
167
  </header>
168
-
169
- <kompasid-widget-recirculations-default
170
- .permalinkArticle=${widgetRelatedPost.permalinkArticle}
171
- .slugs=${widgetRelatedPost.slugs}
172
- ></kompasid-widget-recirculations-default>
173
-
168
+
174
169
  <kompasid-widget-recirculations-list
175
170
  widgetTitle="Terpopuler"
176
171
  apiSlug="popular-article"
177
172
  >
178
173
  </kompasid-widget-recirculations-list>
179
174
 
175
+ <kompasid-widget-recirculations-default
176
+ .permalinkArticle=${widgetRelatedPost.permalinkArticle}
177
+ .slugs=${widgetRelatedPost.slugs}
178
+ ></kompasid-widget-recirculations-default>
179
+
180
180
  <kompasid-widget-recirculations-default
181
181
  .titleName=${widgetOtherPost.titleName}
182
182
  .titleLink=${widgetOtherPost.titleLink}
183
183
  type="otherArticle"
184
- mainCategory="opini"
184
+ mainCategory="ekonomi"
185
185
  ></kompasid-widget-recirculations-default>
186
186
 
187
187
  <kompasid-paywall
@@ -277,6 +277,7 @@
277
277
  .tracker_metered_wall_type=${meteredWallType}
278
278
  .tracker_metered_wall_balance=${trackerMeteredWallBalance}
279
279
  .tracker_page_domain=${trackerPageDomain}
280
+ source="kompasid"
280
281
  ></kompasid-metered-wall-register>
281
282
 
282
283
  <!-- <kompasid-grace-period
@@ -45,7 +45,6 @@ export declare class KompasMeteredWallRegister extends LitElement {
45
45
  */
46
46
  countdownArticle: number;
47
47
  defaultExpandBanner: boolean;
48
- isDesktop: boolean;
49
48
  tracker_page_title: string;
50
49
  tracker_page_type: string;
51
50
  tracker_content_type: string;
@@ -62,11 +61,11 @@ export declare class KompasMeteredWallRegister extends LitElement {
62
61
  tracker_metered_wall_balance: number;
63
62
  tracker_page_domain: string;
64
63
  next_param: string;
64
+ source: string;
65
65
  /**
66
66
  * menentukan template yang akan di render
67
67
  */
68
68
  private setTemplate;
69
- private checkIsDesktop;
70
69
  /**
71
70
  * Render Statement
72
71
  */
@@ -26,14 +26,23 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
26
26
  * state textTemplate untuk menyimpan template yang di berikan.
27
27
  */
28
28
  this.textTemplate = {
29
- default: { title: '', lastArticle: { title: '' } },
30
29
  expand: {
31
- title: '',
32
30
  description: '',
33
- lastArticle: { title: '', description: '' },
31
+ imageUrl: '',
32
+ lastArticle: {
33
+ title: '',
34
+ description: '',
35
+ },
36
+ title: '',
37
+ ctaUrl: '',
38
+ ctaText: '',
39
+ },
40
+ collapse: {
41
+ lastArticle: {
42
+ title: '',
43
+ },
44
+ title: '',
34
45
  },
35
- ctaUrl: '',
36
- ctaText: '',
37
46
  };
38
47
  /**
39
48
  * Props
@@ -60,7 +69,6 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
60
69
  */
61
70
  this.countdownArticle = 0;
62
71
  this.defaultExpandBanner = false;
63
- this.isDesktop = false;
64
72
  this.tracker_page_title = '';
65
73
  this.tracker_page_type = '';
66
74
  this.tracker_content_type = '';
@@ -77,13 +85,14 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
77
85
  this.tracker_metered_wall_balance = 0;
78
86
  this.tracker_page_domain = '';
79
87
  this.next_param = 'https://www.kompas.id/baca/opini/2023/12/05/masa-depan-wolbachia-sebagai-alternatif-pengendalian-dbd?open_from=Section_Opini';
88
+ this.source = 'default';
80
89
  /**
81
90
  * mengarahkan ke page checkout promo
82
91
  */
83
92
  this.redirectToCTAUrl = () => {
84
93
  const params = new URLSearchParams(window.location.href);
85
- const newUrl = new URL(this.textTemplate.ctaUrl);
86
- const referrer = new URLSearchParams(this.textTemplate.ctaUrl).get('referrer');
94
+ const newUrl = new URL(this.textTemplate.expand.ctaUrl);
95
+ const referrer = new URLSearchParams(this.textTemplate.expand.ctaUrl).get('referrer');
87
96
  this.pushToDataLayer('mrw_clicked');
88
97
  if (!referrer) {
89
98
  newUrl.searchParams.append('referrer', params.toString());
@@ -110,19 +119,21 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
110
119
  /**
111
120
  * menentukan template yang akan di render
112
121
  */
113
- setTemplate(prop, mode = 'default') {
114
- const dynamicMode = this.textTemplate[mode];
122
+ setTemplate(prop, mode = 'collapse') {
123
+ const templateObj = this.textTemplate[mode];
115
124
  let template = '';
116
- if (typeof dynamicMode === 'object' && dynamicMode !== null) {
117
- // Check if dynamicMode has a lastArticle object and if the prop exists within it
118
- if (dynamicMode.lastArticle && prop in dynamicMode.lastArticle) {
119
- const value = dynamicMode.lastArticle[prop];
120
- if (typeof value === 'string') {
121
- template = value;
125
+ if (typeof templateObj === 'object' && templateObj !== null) {
126
+ // Check if templateObj has a lastArticle object and if the prop exists within it
127
+ if (this.countdownArticle === 1) {
128
+ if (templateObj.lastArticle && prop in templateObj.lastArticle) {
129
+ const value = templateObj.lastArticle[prop];
130
+ if (typeof value === 'string') {
131
+ template = value;
132
+ }
122
133
  }
123
134
  }
124
- else if (prop in dynamicMode) {
125
- const value = dynamicMode[prop];
135
+ else if (prop in templateObj) {
136
+ const value = templateObj[prop];
126
137
  if (typeof value === 'string') {
127
138
  template = value;
128
139
  }
@@ -130,14 +141,6 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
130
141
  }
131
142
  return template;
132
143
  }
133
- checkIsDesktop() {
134
- if (window.innerWidth >= 960) {
135
- this.isDesktop = true;
136
- }
137
- else {
138
- this.isDesktop = false;
139
- }
140
- }
141
144
  /**
142
145
  * Render Statement
143
146
  */
@@ -148,24 +151,15 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
148
151
  }
149
152
  defaultBannerContent() {
150
153
  return html `
151
- <div>
152
- <div
153
- class="${this.isDesktop
154
- ? 'cont-banner-content'
155
- : 'justify-between'} flex flex-row"
156
- >
157
- <div .hidden="${!this.isDesktop}" class="w-9 h-9"></div>
158
- <div class="banner-content flex flex-row">
154
+ <div class="flex flex-col space-y-4">
155
+ <div class="flex justify-between items-center h-full">
156
+ <div class="w-9 h-9 hidden lg:block"></div>
157
+ <div class="banner-content flex flex-row items-center">
159
158
  <div
160
- class="text-base md:text-lg font-lora mb-3 mt-1 pt-[5px] md:mb-0 md:mt-0 pr-14 md:px-0"
159
+ class="text-base md:text-lg font-lora"
161
160
  .innerHTML=${this.setTemplate('title')}
162
161
  ></div>
163
- <div .hidden="${!this.isDesktop}" class="md:self-center btn-regis">
164
- ${this.isDesktop
165
- ? html `<div class="ml-4"></div>
166
- ${this.registerButtonTemplate()}`
167
- : null}
168
- </div>
162
+ <div class="hidden md:block">${this.registerButtonTemplate()}</div>
169
163
  </div>
170
164
  <div>
171
165
  <button
@@ -182,19 +176,18 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
182
176
  </button>
183
177
  </div>
184
178
  </div>
185
- <div class="md:self-center mt-4">
186
- ${!this.isDesktop ? html `${this.registerButtonTemplate()} ` : null}
187
- </div>
179
+ <div class="block md:hidden">${this.registerButtonTemplate()}</div>
188
180
  </div>
189
181
  `;
190
182
  }
191
183
  expandedBannerContent() {
184
+ var _a;
192
185
  return html `
193
186
  <div
194
- class="flex flex-col-reverse justify-evenly md:flex-row gap-4 md:gap-8"
187
+ class="flex flex-col-reverse justify-between md:flex-row gap-4 md:gap-8"
195
188
  >
196
189
  <div
197
- class="flex flex-col justify-evenly md:text-left md:w-5/12 gap-4 md:gap-2"
190
+ class="flex flex-col justify-evenly md:text-left md:w-5/12 gap-4 ml-auto"
198
191
  >
199
192
  <p
200
193
  class="text-lg md:text-2xl font-lora"
@@ -204,23 +197,19 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
204
197
  class="text-sm md:text-base"
205
198
  .innerHTML=${this.setTemplate('description', 'expand')}
206
199
  ></p>
207
- <div class="${this.isDesktop ? 'expanded-btn' : null} md:self-start">
208
- ${this.registerButtonTemplate()}
209
- </div>
200
+ <div class="md:self-start">${this.registerButtonTemplate()}</div>
210
201
  </div>
211
202
  <div
212
- class="flex justify-center md:max-w-[200px] md:max-h-[220px] md:my-auto"
203
+ class="flex justify-center md:max-w-[200px] md:max-h-[220px] md:my-auto mx-auto"
213
204
  >
214
205
  <img
215
206
  alt="metered-wall-register"
216
- src="https://cdn-www.kompas.id/paywall-asset/paywall_ilustrasi3-03_1.png"
207
+ src="${(_a = this.textTemplate.expand.imageUrl) !== null && _a !== void 0 ? _a : ''}"
217
208
  />
218
209
  </div>
219
210
  <button
220
211
  @click="${this.triggerExpandBanner}"
221
- class="h-9 w-9 ${this.isDesktop
222
- ? null
223
- : 'ml-auto'} flex items-center justify-center text-blue-500 rounded bg-blue-200"
212
+ class="h-9 w-9 flex items-center justify-center text-blue-500 rounded bg-blue-200"
224
213
  >
225
214
  <div
226
215
  class="icon icon-blue-600 ${this.isExpandBanner
@@ -239,18 +228,18 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
239
228
  registerButtonTemplate() {
240
229
  return html `
241
230
  <div>
242
- ${!this.textTemplate.ctaUrl
231
+ ${!this.textTemplate.expand.ctaUrl
243
232
  ? html `<button
244
233
  @click=${this.redirectToRegister}
245
- class="bg-green-500 p-1.5 w-full rounded-md font-bold text-grey-100 text-sm md:text-base"
234
+ class="bg-green-500 p-1.5 w-full whitespace-nowrap rounded-md font-bold text-grey-100 text-sm md:text-base"
246
235
  >
247
236
  Daftar Akun
248
237
  </button>`
249
238
  : html `<button
250
239
  @click=${this.redirectToCTAUrl}
251
- class="bg-green-500 p-1.5 w-full rounded-md font-bold text-grey-100 px-5 text-sm md:text-base md:w-[165px]"
240
+ class="bg-green-500 p-1.5 w-full whitespace-nowrap rounded-md font-bold text-grey-100 px-5 text-sm md:text-base md:w-auto"
252
241
  >
253
- ${this.textTemplate.ctaText}
242
+ ${this.textTemplate.expand.ctaText}
254
243
  </button>`}
255
244
  </div>
256
245
  `;
@@ -292,14 +281,16 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
292
281
  super.connectedCallback();
293
282
  await this.updateComplete;
294
283
  this.loadData();
295
- this.checkIsDesktop();
296
284
  }
297
285
  async loadData() {
298
- const req = await fetch(`https://cdn-www.kompas.id/assets/register_wall.json`);
286
+ const { source } = this; // kompas_com || default
287
+ const req = await fetch(`https://cdn-www.kompas.id/assets/register_wall_new.json`);
299
288
  if (req.status !== 200) {
300
289
  throw new Error(`${req.status} Ada galat saat memproses permintaan.`);
301
290
  }
302
- this.textTemplate = await req.json();
291
+ const res = await req.json();
292
+ const validSource = source in res ? source : 'default';
293
+ this.textTemplate = res[validSource];
303
294
  const getCountdown = this.countdownArticle;
304
295
  if (!getCountdown) {
305
296
  this.isShowBanner = false;
@@ -316,8 +307,8 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
316
307
  ? html `
317
308
  <div class="sticky bottom-0 w-full h-full z-20">
318
309
  <div class="w-full bg-blue-100 px-4 xl:px-0 bottom-0 py-4">
319
- <div class="lg:max-w-7xl m-auto relative">
320
- <div>${this.bannerTemplate()}</div>
310
+ <div class="lg:max-w-7xl m-auto px-0 lg:px-24 relative">
311
+ ${this.bannerTemplate()}
321
312
  </div>
322
313
  </div>
323
314
  </div>
@@ -338,22 +329,9 @@ KompasMeteredWallRegister.styles = [
338
329
  width: 100%;
339
330
  }
340
331
 
341
- .btn-regis {
342
- margin-left: 16px;
343
- width: 127px;
344
- }
345
-
346
332
  .banner-content {
347
333
  gap: 55px;
348
334
  }
349
-
350
- .cont-banner-content {
351
- justify-content: space-evenly;
352
- }
353
-
354
- .expanded-btn {
355
- width: 127px;
356
- }
357
335
  `,
358
336
  TWStyles,
359
337
  ];
@@ -375,9 +353,6 @@ __decorate([
375
353
  __decorate([
376
354
  property({ type: Boolean })
377
355
  ], KompasMeteredWallRegister.prototype, "defaultExpandBanner", void 0);
378
- __decorate([
379
- property({ type: Boolean })
380
- ], KompasMeteredWallRegister.prototype, "isDesktop", void 0);
381
356
  __decorate([
382
357
  property({ type: String })
383
358
  ], KompasMeteredWallRegister.prototype, "tracker_page_title", void 0);
@@ -426,6 +401,9 @@ __decorate([
426
401
  __decorate([
427
402
  property({ type: String })
428
403
  ], KompasMeteredWallRegister.prototype, "next_param", void 0);
404
+ __decorate([
405
+ property({ type: String })
406
+ ], KompasMeteredWallRegister.prototype, "source", void 0);
429
407
  KompasMeteredWallRegister = __decorate([
430
408
  customElement('kompasid-metered-wall-register')
431
409
  ], KompasMeteredWallRegister);
@@ -1 +1 @@
1
- {"version":3,"file":"KompasMeteredWallRegister.js","sourceRoot":"","sources":["../../../../src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C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AAE,CAAC;4EAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+EAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACqG;AAzGrH,yBAAyB;IADrC,aAAa,CAAC,gCAAgC,CAAC;GACnC,yBAAyB,CAiYrC;SAjYY,yBAAyB","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, state, property } from 'lit/decorators.js'\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js'\nimport { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { meteredRegisterContent } from './types.js'\n\n@customElement('kompasid-metered-wall-register')\nexport class KompasMeteredWallRegister extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n\n .btn-regis {\n margin-left: 16px;\n width: 127px;\n }\n\n .banner-content {\n gap: 55px;\n }\n\n .cont-banner-content {\n justify-content: space-evenly;\n }\n\n .expanded-btn {\n width: 127px;\n }\n `,\n TWStyles,\n ]\n\n /**\n * state\n */\n /**\n * state registerUrl untuk memberikan link kemana user akan dialihkan.\n */\n @state() registerUrl: string =\n 'https://account.kompas.id/register?loc=metered_register_wall'\n /**\n * state isShowBanner untuk memunculkan component.\n */\n @state() isShowBanner: boolean = true\n /**\n * state isExpandBanner untuk menentukan apakah component sedang dalam mode expand.\n */\n @state() isExpandBanner: boolean = true\n /**\n * state textTemplate untuk menyimpan template yang di berikan.\n */\n @state() private textTemplate: meteredRegisterContent = {\n default: { title: '', lastArticle: { title: '' } },\n expand: {\n title: '',\n description: '',\n lastArticle: { title: '', description: '' },\n },\n ctaUrl: '',\n ctaText: '',\n }\n /**\n * Props\n */\n /**\n * prop countdownArticle untuk menghandle sudah berapa artikel gratis yang user baca.\n * prop defaultExpandBanner untuk menentukan keadaan awal komponen apakah dalam mode expand atau tidak.\n * prop tracker_page_title untuk title of the page\n * prop tracker_page_type untuk type of the page\n * prop tracker_content_type untuk whether it's a free article or paid article (will only be sent if the user views article detail page)\n * prop tracker_content_id untuk the ID for the article (will only be sent if the user views article detail page)\n * prop tracker_content_title untuk the title of the article (will only be sent if the user views article detail page)\n * prop tracker_content_authors untuk name of the authors (will only be sent if the user views article detail page)\n * prop tracker_content_editors untuk name of the editors (will only be sent if the user views article detail page)\n * prop tracker_content_tags untuk tags inside the article (will only be sent if the user views article detail page)\n * prop tracker_content_published_date untuk the published date (will only be sent if the user views article detail page)\n * prop tracker_content_categories untuk The main category the content belongs to\n * prop tracker_user_type untuk type of user based on their subscription\n * prop tracker_subscription_status untuk status of their subscription\n * prop tracker_metered_wall_type untuk the type of Metered Wall\n * prop tracker_metered_wall_balance untuk the balance of their metered wall\n * prop tracker_page_domain untuk Page Domain\n * prop next_param untuk page Domain\n */\n @property({ type: Number }) countdownArticle = 0\n @property({ type: Boolean }) defaultExpandBanner = false\n @property({ type: Boolean }) isDesktop = false\n @property({ type: String }) tracker_page_title = ''\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_authors = ''\n @property({ type: String }) tracker_content_editors = ''\n @property({ type: String }) tracker_content_tags = ''\n @property({ type: String }) tracker_content_published_date = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) next_param =\n 'https://www.kompas.id/baca/opini/2023/12/05/masa-depan-wolbachia-sebagai-alternatif-pengendalian-dbd?open_from=Section_Opini'\n\n /**\n * menentukan template yang akan di render\n */\n private setTemplate(\n prop: string,\n mode: keyof meteredRegisterContent = 'default'\n ): string {\n interface LastArticle {\n [key: string]: string\n }\n interface DynamicMode {\n lastArticle?: LastArticle\n [key: string]: string | LastArticle | undefined\n }\n const dynamicMode = this.textTemplate[mode] as DynamicMode | string\n\n let template: string = ''\n\n if (typeof dynamicMode === 'object' && dynamicMode !== null) {\n // Check if dynamicMode has a lastArticle object and if the prop exists within it\n if (dynamicMode.lastArticle && prop in dynamicMode.lastArticle) {\n const value = dynamicMode.lastArticle[prop]\n if (typeof value === 'string') {\n template = value\n }\n } else if (prop in dynamicMode) {\n const value = dynamicMode[prop]\n if (typeof value === 'string') {\n template = value\n }\n }\n }\n\n return template\n }\n\n private checkIsDesktop() {\n if (window.innerWidth >= 960) {\n this.isDesktop = true\n } else {\n this.isDesktop = false\n }\n }\n\n /**\n * Render Statement\n */\n\n private bannerTemplate() {\n return this.isExpandBanner\n ? this.expandedBannerContent()\n : this.defaultBannerContent()\n }\n\n private defaultBannerContent() {\n return html`\n <div>\n <div\n class=\"${this.isDesktop\n ? 'cont-banner-content'\n : 'justify-between'} flex flex-row\"\n >\n <div .hidden=\"${!this.isDesktop}\" class=\"w-9 h-9\"></div>\n <div class=\"banner-content flex flex-row\">\n <div\n class=\"text-base md:text-lg font-lora mb-3 mt-1 pt-[5px] md:mb-0 md:mt-0 pr-14 md:px-0\"\n .innerHTML=${this.setTemplate('title')}\n ></div>\n <div .hidden=\"${!this.isDesktop}\" class=\"md:self-center btn-regis\">\n ${this.isDesktop\n ? html`<div class=\"ml-4\"></div>\n ${this.registerButtonTemplate()}`\n : null}\n </div>\n </div>\n <div>\n <button\n @click=\"${this.triggerExpandBanner}\"\n class=\"h-9 w-9 flex ml-2 items-center justify-center text-blue-500 rounded bg-blue-200\"\n >\n <div\n class=\"icon icon-blue-600 ${this.isExpandBanner\n ? 'chevron-down'\n : 'rotate-180'}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-down'))}\n </div>\n </button>\n </div>\n </div>\n <div class=\"md:self-center mt-4\">\n ${!this.isDesktop ? html`${this.registerButtonTemplate()} ` : null}\n </div>\n </div>\n `\n }\n\n private expandedBannerContent() {\n return html`\n <div\n class=\"flex flex-col-reverse justify-evenly md:flex-row gap-4 md:gap-8\"\n >\n <div\n class=\"flex flex-col justify-evenly md:text-left md:w-5/12 gap-4 md:gap-2\"\n >\n <p\n class=\"text-lg md:text-2xl font-lora\"\n .innerHTML=${this.setTemplate('title', 'expand')}\n ></p>\n <p\n class=\"text-sm md:text-base\"\n .innerHTML=${this.setTemplate('description', 'expand')}\n ></p>\n <div class=\"${this.isDesktop ? 'expanded-btn' : null} md:self-start\">\n ${this.registerButtonTemplate()}\n </div>\n </div>\n <div\n class=\"flex justify-center md:max-w-[200px] md:max-h-[220px] md:my-auto\"\n >\n <img\n alt=\"metered-wall-register\"\n src=\"https://cdn-www.kompas.id/paywall-asset/paywall_ilustrasi3-03_1.png\"\n />\n </div>\n <button\n @click=\"${this.triggerExpandBanner}\"\n class=\"h-9 w-9 ${this.isDesktop\n ? null\n : 'ml-auto'} flex items-center justify-center text-blue-500 rounded bg-blue-200\"\n >\n <div\n class=\"icon icon-blue-600 ${this.isExpandBanner\n ? 'chevron-down'\n : 'rotate-180'}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-down'))}\n </div>\n </button>\n </div>\n `\n }\n\n /**\n * template button register\n */\n private registerButtonTemplate() {\n return html`\n <div>\n ${!this.textTemplate.ctaUrl\n ? html`<button\n @click=${this.redirectToRegister}\n class=\"bg-green-500 p-1.5 w-full rounded-md font-bold text-grey-100 text-sm md:text-base\"\n >\n Daftar Akun\n </button>`\n : html`<button\n @click=${this.redirectToCTAUrl}\n class=\"bg-green-500 p-1.5 w-full rounded-md font-bold text-grey-100 px-5 text-sm md:text-base md:w-[165px]\"\n >\n ${this.textTemplate.ctaText}\n </button>`}\n </div>\n `\n }\n\n /**\n * mengarahkan ke page checkout promo\n */\n private redirectToCTAUrl = (): void => {\n const params = new URLSearchParams(window.location.href)\n const newUrl = new URL(this.textTemplate.ctaUrl)\n const referrer = new URLSearchParams(this.textTemplate.ctaUrl).get(\n 'referrer'\n )\n this.pushToDataLayer('mrw_clicked')\n if (!referrer) {\n newUrl.searchParams.append('referrer', params.toString())\n window.location.href = newUrl.toString()\n } else {\n const currentReferrerValue = newUrl.searchParams.get('referrer')\n const updatedReferrerValue = `${params.toString()},${currentReferrerValue}`\n newUrl.searchParams.set('referrer', updatedReferrerValue)\n window.location.href = newUrl.toString()\n }\n }\n\n /**\n * mengarahkan ke page register\n */\n private redirectToRegister = (): void => {\n this.pushToDataLayer('mrw_clicked')\n const newUrl = new URL(decodeURIComponent(this.registerUrl))\n if (this.next_param)\n newUrl.searchParams.append('next', decodeURIComponent(this.next_param))\n window.location.href = newUrl.toString()\n }\n\n /**\n * mengirim event ke datalayer\n */\n private pushToDataLayer(eventName: string) {\n window.dataLayer.push({\n event: eventName,\n page_title: this.tracker_page_title,\n page_type: this.tracker_page_type,\n content_type: this.tracker_content_type,\n content_id: this.tracker_content_id,\n content_title: this.tracker_content_title,\n content_authors: this.tracker_content_authors,\n content_editors: this.tracker_content_editors,\n content_tags: this.tracker_content_tags,\n content_published_date: this.tracker_content_published_date,\n content_categories: this.tracker_content_categories,\n user_type: this.tracker_user_type || 'G',\n subscription_status: this.tracker_subscription_status || '',\n metered_wall_type: this.tracker_metered_wall_type || 'MRW',\n metered_wall_balance: this.tracker_metered_wall_balance,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n })\n }\n\n /**\n * toggle isExpandBanner flag\n */\n private triggerExpandBanner() {\n this.isExpandBanner = !this.isExpandBanner\n return !this.isExpandBanner && this.pushToDataLayer('mrw_closed')\n }\n\n /**\n * Lifecycle\n */\n\n override async connectedCallback() {\n super.connectedCallback()\n await this.updateComplete\n this.loadData()\n this.checkIsDesktop()\n }\n\n private async loadData() {\n const req = await fetch(\n `https://cdn-www.kompas.id/assets/register_wall.json`\n )\n\n if (req.status !== 200) {\n throw new Error(`${req.status} Ada galat saat memproses permintaan.`)\n }\n\n this.textTemplate = await req.json()\n\n const getCountdown = this.countdownArticle\n\n if (!getCountdown) {\n this.isShowBanner = false\n } else {\n this.isExpandBanner = this.defaultExpandBanner\n }\n\n if (this.isShowBanner) {\n this.pushToDataLayer('mrw_viewed')\n }\n }\n\n render() {\n return this.isShowBanner\n ? html`\n <div class=\"sticky bottom-0 w-full h-full z-20\">\n <div class=\"w-full bg-blue-100 px-4 xl:px-0 bottom-0 py-4\">\n <div class=\"lg:max-w-7xl m-auto relative\">\n <div>${this.bannerTemplate()}</div>\n </div>\n </div>\n </div>\n `\n : null\n }\n}\n"]}
1
+ {"version":3,"file":"KompasMeteredWallRegister.js","sourceRoot":"","sources":["../../../../src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAA;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAQjD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAU;IAAlD;;QAqBL;;WAEG;QACH;;WAEG;QACM,gBAAW,GAClB,8DAA8D,CAAA;QAChE;;WAEG;QACM,iBAAY,GAAY,IAAI,CAAA;QACrC;;WAEG;QACM,mBAAc,GAAY,IAAI,CAAA;QACvC;;WAEG;QACc,iBAAY,GAA2B;YACtD,MAAM,EAAE;gBACN,WAAW,EAAE,EAAE;gBACf,QAAQ,EAAE,EAAE;gBACZ,WAAW,EAAE;oBACX,KAAK,EAAE,EAAE;oB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,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iFAAoC;AACnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6EAAgC;AAC/B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8EAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4EAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+EAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACqG;AACpG;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAmB;AAvGnC,yBAAyB;IADrC,aAAa,CAAC,gCAAgC,CAAC;GACnC,yBAAyB,CA8WrC;SA9WY,yBAAyB","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, state, property } from 'lit/decorators.js'\nimport { unsafeSVG } from 'lit/directives/unsafe-svg.js'\nimport { getFontAwesomeIcon } from '../../utils/fontawesome-setup.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport {\n lastArticleData,\n meteredRegisterResponse,\n meteredRegisterContent,\n} from './types.js'\n\n@customElement('kompasid-metered-wall-register')\nexport class KompasMeteredWallRegister extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n\n .banner-content {\n gap: 55px;\n }\n `,\n TWStyles,\n ]\n\n /**\n * state\n */\n /**\n * state registerUrl untuk memberikan link kemana user akan dialihkan.\n */\n @state() registerUrl: string =\n 'https://account.kompas.id/register?loc=metered_register_wall'\n /**\n * state isShowBanner untuk memunculkan component.\n */\n @state() isShowBanner: boolean = true\n /**\n * state isExpandBanner untuk menentukan apakah component sedang dalam mode expand.\n */\n @state() isExpandBanner: boolean = true\n /**\n * state textTemplate untuk menyimpan template yang di berikan.\n */\n @state() private textTemplate: meteredRegisterContent = {\n expand: {\n description: '',\n imageUrl: '',\n lastArticle: {\n title: '',\n description: '',\n },\n title: '',\n ctaUrl: '',\n ctaText: '',\n },\n collapse: {\n lastArticle: {\n title: '',\n },\n title: '',\n },\n }\n\n /**\n * Props\n */\n /**\n * prop countdownArticle untuk menghandle sudah berapa artikel gratis yang user baca.\n * prop defaultExpandBanner untuk menentukan keadaan awal komponen apakah dalam mode expand atau tidak.\n * prop tracker_page_title untuk title of the page\n * prop tracker_page_type untuk type of the page\n * prop tracker_content_type untuk whether it's a free article or paid article (will only be sent if the user views article detail page)\n * prop tracker_content_id untuk the ID for the article (will only be sent if the user views article detail page)\n * prop tracker_content_title untuk the title of the article (will only be sent if the user views article detail page)\n * prop tracker_content_authors untuk name of the authors (will only be sent if the user views article detail page)\n * prop tracker_content_editors untuk name of the editors (will only be sent if the user views article detail page)\n * prop tracker_content_tags untuk tags inside the article (will only be sent if the user views article detail page)\n * prop tracker_content_published_date untuk the published date (will only be sent if the user views article detail page)\n * prop tracker_content_categories untuk The main category the content belongs to\n * prop tracker_user_type untuk type of user based on their subscription\n * prop tracker_subscription_status untuk status of their subscription\n * prop tracker_metered_wall_type untuk the type of Metered Wall\n * prop tracker_metered_wall_balance untuk the balance of their metered wall\n * prop tracker_page_domain untuk Page Domain\n * prop next_param untuk page Domain\n */\n @property({ type: Number }) countdownArticle = 0\n @property({ type: Boolean }) defaultExpandBanner = false\n\n @property({ type: String }) tracker_page_title = ''\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_authors = ''\n @property({ type: String }) tracker_content_editors = ''\n @property({ type: String }) tracker_content_tags = ''\n @property({ type: String }) tracker_content_published_date = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) next_param =\n 'https://www.kompas.id/baca/opini/2023/12/05/masa-depan-wolbachia-sebagai-alternatif-pengendalian-dbd?open_from=Section_Opini'\n @property({ type: String }) source = 'default'\n\n /**\n * menentukan template yang akan di render\n */\n private setTemplate(\n prop: string,\n mode: keyof meteredRegisterContent = 'collapse'\n ): string {\n interface templateType {\n lastArticle?: lastArticleData\n [key: string]: string | lastArticleData | undefined\n }\n const templateObj = this.textTemplate[mode] as unknown as\n | templateType\n | string\n\n let template: string = ''\n\n if (typeof templateObj === 'object' && templateObj !== null) {\n // Check if templateObj has a lastArticle object and if the prop exists within it\n\n if (this.countdownArticle === 1) {\n if (templateObj.lastArticle && prop in templateObj.lastArticle) {\n const value = (templateObj.lastArticle as any)[prop]\n if (typeof value === 'string') {\n template = value\n }\n }\n } else if (prop in templateObj) {\n const value = templateObj[prop]\n if (typeof value === 'string') {\n template = value\n }\n }\n }\n\n return template\n }\n\n /**\n * Render Statement\n */\n\n private bannerTemplate() {\n return this.isExpandBanner\n ? this.expandedBannerContent()\n : this.defaultBannerContent()\n }\n\n private defaultBannerContent() {\n return html`\n <div class=\"flex flex-col space-y-4\">\n <div class=\"flex justify-between items-center h-full\">\n <div class=\"w-9 h-9 hidden lg:block\"></div>\n <div class=\"banner-content flex flex-row items-center\">\n <div\n class=\"text-base md:text-lg font-lora\"\n .innerHTML=${this.setTemplate('title')}\n ></div>\n <div class=\"hidden md:block\">${this.registerButtonTemplate()}</div>\n </div>\n <div>\n <button\n @click=\"${this.triggerExpandBanner}\"\n class=\"h-9 w-9 flex ml-2 items-center justify-center text-blue-500 rounded bg-blue-200\"\n >\n <div\n class=\"icon icon-blue-600 ${this.isExpandBanner\n ? 'chevron-down'\n : 'rotate-180'}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-down'))}\n </div>\n </button>\n </div>\n </div>\n <div class=\"block md:hidden\">${this.registerButtonTemplate()}</div>\n </div>\n `\n }\n\n private expandedBannerContent() {\n return html`\n <div\n class=\"flex flex-col-reverse justify-between md:flex-row gap-4 md:gap-8\"\n >\n <div\n class=\"flex flex-col justify-evenly md:text-left md:w-5/12 gap-4 ml-auto\"\n >\n <p\n class=\"text-lg md:text-2xl font-lora\"\n .innerHTML=${this.setTemplate('title', 'expand')}\n ></p>\n <p\n class=\"text-sm md:text-base\"\n .innerHTML=${this.setTemplate('description', 'expand')}\n ></p>\n <div class=\"md:self-start\">${this.registerButtonTemplate()}</div>\n </div>\n <div\n class=\"flex justify-center md:max-w-[200px] md:max-h-[220px] md:my-auto mx-auto\"\n >\n <img\n alt=\"metered-wall-register\"\n src=\"${this.textTemplate.expand.imageUrl ?? ''}\"\n />\n </div>\n <button\n @click=\"${this.triggerExpandBanner}\"\n class=\"h-9 w-9 flex items-center justify-center text-blue-500 rounded bg-blue-200\"\n >\n <div\n class=\"icon icon-blue-600 ${this.isExpandBanner\n ? 'chevron-down'\n : 'rotate-180'}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fas', 'chevron-down'))}\n </div>\n </button>\n </div>\n `\n }\n\n /**\n * template button register\n */\n private registerButtonTemplate() {\n return html`\n <div>\n ${!this.textTemplate.expand.ctaUrl\n ? html`<button\n @click=${this.redirectToRegister}\n class=\"bg-green-500 p-1.5 w-full whitespace-nowrap rounded-md font-bold text-grey-100 text-sm md:text-base\"\n >\n Daftar Akun\n </button>`\n : html`<button\n @click=${this.redirectToCTAUrl}\n class=\"bg-green-500 p-1.5 w-full whitespace-nowrap rounded-md font-bold text-grey-100 px-5 text-sm md:text-base md:w-auto\"\n >\n ${this.textTemplate.expand.ctaText}\n </button>`}\n </div>\n `\n }\n\n /**\n * mengarahkan ke page checkout promo\n */\n private redirectToCTAUrl = (): void => {\n const params = new URLSearchParams(window.location.href)\n const newUrl = new URL(this.textTemplate.expand.ctaUrl)\n const referrer = new URLSearchParams(this.textTemplate.expand.ctaUrl).get(\n 'referrer'\n )\n this.pushToDataLayer('mrw_clicked')\n if (!referrer) {\n newUrl.searchParams.append('referrer', params.toString())\n window.location.href = newUrl.toString()\n } else {\n const currentReferrerValue = newUrl.searchParams.get('referrer')\n const updatedReferrerValue = `${params.toString()},${currentReferrerValue}`\n newUrl.searchParams.set('referrer', updatedReferrerValue)\n window.location.href = newUrl.toString()\n }\n }\n\n /**\n * mengarahkan ke page register\n */\n private redirectToRegister = (): void => {\n this.pushToDataLayer('mrw_clicked')\n const newUrl = new URL(decodeURIComponent(this.registerUrl))\n if (this.next_param)\n newUrl.searchParams.append('next', decodeURIComponent(this.next_param))\n window.location.href = newUrl.toString()\n }\n\n /**\n * mengirim event ke datalayer\n */\n private pushToDataLayer(eventName: string) {\n window.dataLayer.push({\n event: eventName,\n page_title: this.tracker_page_title,\n page_type: this.tracker_page_type,\n content_type: this.tracker_content_type,\n content_id: this.tracker_content_id,\n content_title: this.tracker_content_title,\n content_authors: this.tracker_content_authors,\n content_editors: this.tracker_content_editors,\n content_tags: this.tracker_content_tags,\n content_published_date: this.tracker_content_published_date,\n content_categories: this.tracker_content_categories,\n user_type: this.tracker_user_type || 'G',\n subscription_status: this.tracker_subscription_status || '',\n metered_wall_type: this.tracker_metered_wall_type || 'MRW',\n metered_wall_balance: this.tracker_metered_wall_balance,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n })\n }\n\n /**\n * toggle isExpandBanner flag\n */\n private triggerExpandBanner() {\n this.isExpandBanner = !this.isExpandBanner\n return !this.isExpandBanner && this.pushToDataLayer('mrw_closed')\n }\n\n /**\n * Lifecycle\n */\n\n override async connectedCallback() {\n super.connectedCallback()\n await this.updateComplete\n this.loadData()\n }\n\n private async loadData() {\n const { source } = this // kompas_com || default\n\n const req = await fetch(\n `https://cdn-www.kompas.id/assets/register_wall_new.json`\n )\n\n if (req.status !== 200) {\n throw new Error(`${req.status} Ada galat saat memproses permintaan.`)\n }\n\n const res: meteredRegisterResponse = await req.json()\n const validSource = source in res ? source : 'default'\n\n this.textTemplate = res[validSource as keyof typeof res]\n\n const getCountdown = this.countdownArticle\n\n if (!getCountdown) {\n this.isShowBanner = false\n } else {\n this.isExpandBanner = this.defaultExpandBanner\n }\n\n if (this.isShowBanner) {\n this.pushToDataLayer('mrw_viewed')\n }\n }\n\n render() {\n return this.isShowBanner\n ? html`\n <div class=\"sticky bottom-0 w-full h-full z-20\">\n <div class=\"w-full bg-blue-100 px-4 xl:px-0 bottom-0 py-4\">\n <div class=\"lg:max-w-7xl m-auto px-0 lg:px-24 relative\">\n ${this.bannerTemplate()}\n </div>\n </div>\n </div>\n `\n : null\n }\n}\n"]}
@@ -1,18 +1,22 @@
1
+ export interface lastArticleData {
2
+ title: string;
3
+ description?: string;
4
+ }
1
5
  export interface meteredRegisterContent {
2
6
  expand: {
3
- lastArticle: {
4
- title: string;
5
- description: string;
6
- };
7
+ lastArticle: lastArticleData;
7
8
  title: string;
8
9
  description: string;
10
+ ctaUrl: string;
11
+ ctaText: string;
12
+ imageUrl: string;
9
13
  };
10
- default: {
11
- lastArticle: {
12
- title: string;
13
- };
14
+ collapse: {
15
+ lastArticle: lastArticleData;
14
16
  title: string;
15
17
  };
16
- ctaUrl: string;
17
- ctaText: string;
18
+ }
19
+ export interface meteredRegisterResponse {
20
+ kompascom: meteredRegisterContent;
21
+ default: meteredRegisterContent;
18
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-metered-wall-register/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface meteredRegisterContent {\n expand: {\n lastArticle: {\n title: string\n description: string\n }\n title: string\n description: string\n }\n default: {\n lastArticle: {\n title: string\n }\n title: string\n }\n ctaUrl: string\n ctaText: string\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-metered-wall-register/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface lastArticleData {\n title: string\n description?: string\n}\n\nexport interface meteredRegisterContent {\n expand: {\n lastArticle: lastArticleData\n title: string\n description: string\n ctaUrl: string\n ctaText: string\n imageUrl: string\n }\n collapse: {\n lastArticle: lastArticleData\n title: string\n }\n}\n\nexport interface meteredRegisterResponse {\n kompascom: meteredRegisterContent\n default: meteredRegisterContent\n}\n"]}
@@ -23,10 +23,6 @@ export declare class KompasWidgetRecirculationsDefault extends LitElement {
23
23
  relatedArticles(): Promise<void>;
24
24
  otherArticles(): Promise<void>;
25
25
  handleFetchError(error: unknown): void;
26
- /**
27
- * Function to format date
28
- */
29
- formatDate(date: string): string;
30
26
  /**
31
27
  * Render widget components
32
28
  */
@@ -1,9 +1,8 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { html, css, LitElement } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
- import { format } from 'date-fns';
5
- import { id } from 'date-fns/locale/id';
6
4
  import { TWStyles } from '../../../tailwind/tailwind.js';
5
+ import { useTimeDifference } from '../../utils/useTimeDIfference.js';
7
6
  let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault extends LitElement {
8
7
  constructor() {
9
8
  super(...arguments);
@@ -119,12 +118,6 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
119
118
  const errorMessage = error instanceof Error ? error.message : 'Kesalahan tidak diketahui';
120
119
  alert(`Terjadi kesalahan: ${errorMessage}`);
121
120
  }
122
- /**
123
- * Function to format date
124
- */
125
- formatDate(date) {
126
- return format(new Date(date), 'dd MMMM yyyy', { locale: id });
127
- }
128
121
  /**
129
122
  * Render widget components
130
123
  */
@@ -161,12 +154,20 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
161
154
  `;
162
155
  }
163
156
  renderChips(post) {
164
- var _a, _b;
157
+ var _a, _b, _c;
165
158
  const chips = [];
166
159
  const isAnalisis = (_a = post.postTag) === null || _a === void 0 ? void 0 : _a.some(tag => tag.slug === 'analisis');
167
160
  const isEksklusif = (_b = post.postTag) === null || _b === void 0 ? void 0 : _b.some(tag => tag.slug === 'eksklusif');
161
+ const isKompasBrief = (_c = post.postTag) === null || _c === void 0 ? void 0 : _c.some(tag => tag.slug === 'kompas-brief');
168
162
  const isFreemium = post.isFreemium === true;
169
- if (isEksklusif) {
163
+ if (isKompasBrief) {
164
+ chips.push(html `
165
+ <div class="flex">
166
+ <div class="chip bg-red-100 text-red-600">Kompas Brief</div>
167
+ </div>
168
+ `);
169
+ }
170
+ else if (isEksklusif) {
170
171
  chips.push(html `
171
172
  <div class="flex">
172
173
  <div class="chip bg-grey-600 text-white">
@@ -245,7 +246,7 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
245
246
  ? 'text-white'
246
247
  : 'text-grey-600'}"
247
248
  >
248
- ${this.formatDate(post.publishedDate)}
249
+ ${useTimeDifference(post.publishedDate)}
249
250
  </p>
250
251
  </a>
251
252
  </div>
@@ -279,7 +280,7 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
279
280
  ? 'text-white'
280
281
  : 'text-grey-600'}"
281
282
  >
282
- ${this.formatDate(post.publishedDate)}
283
+ ${useTimeDifference(post.publishedDate)}
283
284
  </p>
284
285
  </a>
285
286
  </div>