@kompasid/lit-web-components 0.6.8 → 0.7.1

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 (32) hide show
  1. package/demo/index.html +34 -0
  2. package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.d.ts +4 -0
  3. package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js +54 -16
  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 +2 -0
  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 +39 -0
  8. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js +340 -0
  9. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js.map +1 -0
  10. package/dist/src/components/kompasid-widget-recirculations-default/types.d.ts +27 -0
  11. package/dist/src/components/kompasid-widget-recirculations-default/types.js +2 -0
  12. package/dist/src/components/kompasid-widget-recirculations-default/types.js.map +1 -0
  13. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.d.ts +28 -0
  14. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js +188 -0
  15. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js.map +1 -0
  16. package/dist/src/index.d.ts +2 -0
  17. package/dist/src/index.js +2 -0
  18. package/dist/src/index.js.map +1 -1
  19. package/dist/tailwind/tailwind.js +83 -8
  20. package/dist/tailwind/tailwind.js.map +1 -1
  21. package/dist/tsconfig.tsbuildinfo +1 -1
  22. package/package.json +2 -1
  23. package/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.ts +63 -18
  24. package/src/components/kompasid-metered-wall-register/types.ts +2 -0
  25. package/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts +342 -0
  26. package/src/components/kompasid-widget-recirculations-default/readme.md +57 -0
  27. package/src/components/kompasid-widget-recirculations-default/types.ts +28 -0
  28. package/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.ts +230 -0
  29. package/src/components/kompasid-widget-recirculations-list/readme.md +27 -0
  30. package/src/index.ts +2 -0
  31. package/tailwind/tailwind.css +80 -8
  32. package/tailwind/tailwind.ts +83 -8
package/demo/index.html CHANGED
@@ -45,6 +45,8 @@
45
45
 
46
46
  <script type="module">
47
47
  import { html, render } from 'lit'
48
+ import '../dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js'
49
+ import '../dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js'
48
50
  import '../dist/src/components/kompasid-footer/KompasFooter.js'
49
51
  import '../dist/src/components/kompasid-paywall/KompasPaywall.js'
50
52
  import '../dist/src/components/kompasid-paywall-video/KompasPaywallVideo.js'
@@ -108,6 +110,22 @@
108
110
  updateMembership: 'Perbarui Langganan',
109
111
  }
110
112
 
113
+ const widgetRelatedPost = {
114
+ navigation: {
115
+ name: 'Artikel Terkait',
116
+ permalink: undefined
117
+ },
118
+ permalinkArticle: 'https://www.kompas.id/baca/opini/2024/05/02/pesan-bung-karno-jaga-persatuan-dan-keutuhan?open_from=Section_Artikel_Lainnya',
119
+ slugs: 'persatuan,bung-karno, surat pembaca, eduard lukman, bharoto, wira hardiprakoso, vision'
120
+ }
121
+
122
+ const widgetOtherPost = {
123
+ navigation: {
124
+ name: 'Lainnya Dalam Opini',
125
+ permalink: '/kategori/opini'
126
+ }
127
+ }
128
+
111
129
  render(
112
130
  html`
113
131
  <kompasid-header-account
@@ -122,6 +140,22 @@
122
140
  .read_later_url=${readLaterUrl}
123
141
  .total_grace_period=${totalGracePeriod}
124
142
  ></kompasid-header-account>
143
+
144
+ <kompasid-widget-recirculations-default
145
+ .navigation=${widgetRelatedPost.navigation}
146
+ .permalinkArticle=${widgetRelatedPost.permalinkArticle}
147
+ .slugs=${widgetRelatedPost.slugs}
148
+ ></kompasid-widget-recirculations-default>
149
+
150
+ <kompasid-widget-recirculations-default
151
+ .navigation=${widgetOtherPost.navigation}
152
+ type='otherArticle'
153
+ mainCategory='opini'
154
+ ></kompasid-widget-recirculations-default>
155
+
156
+ <kompasid-widget-recirculations-list widgetTitle="Terpopuler" apiSlug="popular-article">
157
+ </kompasid-widget-recirculations-list>
158
+
125
159
  <kompasid-paywall
126
160
  .type=${type}
127
161
  .theme=${theme}
@@ -77,6 +77,10 @@ export declare class KompasMeteredWallRegister extends LitElement {
77
77
  * template button register
78
78
  */
79
79
  private registerButtonTemplate;
80
+ /**
81
+ * mengarahkan ke page checkout promo
82
+ */
83
+ private redirectToCTAUrl;
80
84
  /**
81
85
  * mengarahkan ke page register
82
86
  */
@@ -32,6 +32,8 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
32
32
  description: '',
33
33
  lastArticle: { title: '', description: '' },
34
34
  },
35
+ ctaUrl: '',
36
+ ctaText: '',
35
37
  };
36
38
  /**
37
39
  * Props
@@ -75,6 +77,25 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
75
77
  this.tracker_metered_wall_balance = 0;
76
78
  this.tracker_page_domain = '';
77
79
  this.next_param = 'https://www.kompas.id/baca/opini/2023/12/05/masa-depan-wolbachia-sebagai-alternatif-pengendalian-dbd?open_from=Section_Opini';
80
+ /**
81
+ * mengarahkan ke page checkout promo
82
+ */
83
+ this.redirectToCTAUrl = () => {
84
+ 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');
87
+ this.pushToDataLayer('mrw_clicked');
88
+ if (!referrer) {
89
+ newUrl.searchParams.append('referrer', params.toString());
90
+ window.location.href = newUrl.toString();
91
+ }
92
+ else {
93
+ const currentReferrerValue = newUrl.searchParams.get('referrer');
94
+ const updatedReferrerValue = `${params.toString()},${currentReferrerValue}`;
95
+ newUrl.searchParams.set('referrer', updatedReferrerValue);
96
+ window.location.href = newUrl.toString();
97
+ }
98
+ };
78
99
  /**
79
100
  * mengarahkan ke page register
80
101
  */
@@ -90,15 +111,22 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
90
111
  * menentukan template yang akan di render
91
112
  */
92
113
  setTemplate(prop, mode = 'default') {
93
- let template = '';
94
- // dynamicMode dibuat agar typescript bisa akses data lastArticle
95
114
  const dynamicMode = this.textTemplate[mode];
96
- if ('lastArticle' in dynamicMode) {
97
- const lastArticleMode = dynamicMode;
98
- template = lastArticleMode.lastArticle[prop] || '';
99
- }
100
- else {
101
- template = dynamicMode[prop] || '';
115
+ 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;
122
+ }
123
+ }
124
+ else if (prop in dynamicMode) {
125
+ const value = dynamicMode[prop];
126
+ if (typeof value === 'string') {
127
+ template = value;
128
+ }
129
+ }
102
130
  }
103
131
  return template;
104
132
  }
@@ -180,11 +208,12 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
180
208
  ${this.registerButtonTemplate()}
181
209
  </div>
182
210
  </div>
183
- <div class="flex justify-center">
211
+ <div
212
+ class="flex justify-center md:max-w-[200px] md:max-h-[220px] md:my-auto"
213
+ >
184
214
  <img
185
215
  alt="metered-wall-register"
186
216
  src="https://d3w4qaq4xm1ncv.cloudfront.net/paywall-asset/paywall_ilustrasi3-03_1.png"
187
- class="h-40 w-40 md:w-full md:h-full"
188
217
  />
189
218
  </div>
190
219
  <button
@@ -209,12 +238,21 @@ let KompasMeteredWallRegister = class KompasMeteredWallRegister extends LitEleme
209
238
  */
210
239
  registerButtonTemplate() {
211
240
  return html `
212
- <button
213
- @click=${this.redirectToRegister}
214
- class="bg-green-500 p-1.5 w-full rounded-md font-bold text-grey-100 text-sm md:text-base"
215
- >
216
- Daftar Akun
217
- </button>
241
+ <div>
242
+ ${!this.textTemplate.ctaUrl
243
+ ? html `<button
244
+ @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"
246
+ >
247
+ Daftar Akun
248
+ </button>`
249
+ : html `<button
250
+ @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]"
252
+ >
253
+ ${this.textTemplate.ctaText}
254
+ </button>`}
255
+ </div>
218
256
  `;
219
257
  }
220
258
  /**
@@ -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,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;AAIjD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAU;IAAlD;;QAkCL;;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,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAA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AC5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0EAA6B;AAC5B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAA0B;AACzB;IAA3B,QAAQ,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;AAxGrH,yBAAyB;IADrC,aAAa,CAAC,gCAAgC,CAAC;GACnC,yBAAyB,CAoVrC;SApVY,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 }\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\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 let template = ''\n\n // dynamicMode dibuat agar typescript bisa akses data lastArticle\n const dynamicMode = this.textTemplate[mode]\n\n if ('lastArticle' in dynamicMode) {\n const lastArticleMode = dynamicMode as {\n lastArticle: { [key: string]: string }\n }\n template = lastArticleMode.lastArticle[prop] || ''\n } else {\n template = dynamicMode[prop] || ''\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 class=\"flex justify-center\">\n <img\n alt=\"metered-wall-register\"\n src=\"https://d3w4qaq4xm1ncv.cloudfront.net/paywall-asset/paywall_ilustrasi3-03_1.png\"\n class=\"h-40 w-40 md:w-full md:h-full\"\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 <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 `\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://d3w4qaq4xm1ncv.cloudfront.net/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;AAIjD,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,UAAU;IAAlD;;QAkCL;;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,OAAO,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;YAClD,MAAM,EAAE;gBACN,KAAK,EAAE,EAAE;gBACT,WAAW,EAAE,EAAE;gBACf,WAAW,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE;aAC5C;YACD,MAAM,EAAE,EAAE;YACV,OAAO,EAAE,EAAE;SACZ,CAAA;QACD;;WAEG;QACH;;;;;;;;;;;;;;;;;;;WAmBG;QACyB,qBAAgB,GAAG,CAA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AAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAA0B;AACzB;IAA3B,QAAQ,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;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://d3w4qaq4xm1ncv.cloudfront.net/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://d3w4qaq4xm1ncv.cloudfront.net/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"]}
@@ -13,4 +13,6 @@ export interface meteredRegisterContent {
13
13
  };
14
14
  title: string;
15
15
  };
16
+ ctaUrl: string;
17
+ ctaText: string;
16
18
  }
@@ -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}\n"]}
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"]}
@@ -0,0 +1,39 @@
1
+ import { LitElement } from 'lit';
2
+ import { Post, Navigation } from './types.js';
3
+ export declare class KompasWidgetRecirculationsDefault extends LitElement {
4
+ static styles: import("lit").CSSResult[];
5
+ /**
6
+ * Props
7
+ */
8
+ posts: Post[][];
9
+ navigation: Navigation | undefined;
10
+ accessToken: string;
11
+ permalinkArticle: string;
12
+ userGuid: string;
13
+ slugs: string;
14
+ type: 'relatedArticle' | 'otherArticle';
15
+ mainCategory: string;
16
+ /**
17
+ * Getters
18
+ */
19
+ get navigationPermalink(): string | undefined;
20
+ /**
21
+ * Fetch Data
22
+ */
23
+ connectedCallback(): Promise<void>;
24
+ fetchAccessToken(): Promise<void>;
25
+ relatedArticles(): Promise<void>;
26
+ otherArticles(): Promise<void>;
27
+ handleFetchError(error: unknown): void;
28
+ /**
29
+ * Function to format date
30
+ */
31
+ formatDate(date: string): string;
32
+ /**
33
+ * Render widget components
34
+ */
35
+ private WidgetTitle;
36
+ renderChips(post: Post): import("lit").TemplateResult<1>[];
37
+ renderImage(post: Post): import("lit").TemplateResult<1> | "";
38
+ render(): import("lit").TemplateResult<1>;
39
+ }
@@ -0,0 +1,340 @@
1
+ import { __decorate } from "tslib";
2
+ import { html, css, LitElement } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { format } from 'date-fns';
5
+ import { id } from 'date-fns/locale/id';
6
+ import { TWStyles } from '../../../tailwind/tailwind.js';
7
+ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault extends LitElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ /**
11
+ * Props
12
+ */
13
+ this.posts = [];
14
+ this.navigation = undefined;
15
+ this.accessToken = '';
16
+ this.permalinkArticle = '';
17
+ this.userGuid = '0';
18
+ this.slugs = '';
19
+ this.type = 'relatedArticle';
20
+ this.mainCategory = '';
21
+ }
22
+ /**
23
+ * Getters
24
+ */
25
+ get navigationPermalink() {
26
+ var _a;
27
+ return (_a = this.navigation) === null || _a === void 0 ? void 0 : _a.permalink;
28
+ }
29
+ /**
30
+ * Fetch Data
31
+ */
32
+ async connectedCallback() {
33
+ super.connectedCallback();
34
+ try {
35
+ await this.fetchAccessToken();
36
+ if (this.type === 'relatedArticle') {
37
+ await this.relatedArticles();
38
+ }
39
+ else if (this.type === 'otherArticle') {
40
+ await this.otherArticles();
41
+ }
42
+ }
43
+ catch (error) {
44
+ this.handleFetchError(error);
45
+ }
46
+ }
47
+ async fetchAccessToken() {
48
+ var _a;
49
+ const response = await fetch('https://api.kompas.id/account/api/v1/login/guest', {
50
+ method: 'POST',
51
+ headers: {
52
+ 'Content-Type': 'application/json',
53
+ },
54
+ body: JSON.stringify({
55
+ email: 'anonynous.user@kompas.id',
56
+ }),
57
+ });
58
+ const result = await response.json();
59
+ if ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.accessToken) {
60
+ this.accessToken = result.data.accessToken;
61
+ }
62
+ else {
63
+ throw new Error('Token akses tidak tersedia dalam respons');
64
+ }
65
+ }
66
+ async relatedArticles() {
67
+ if (!this.accessToken) {
68
+ throw new Error('Token akses tidak tersedia');
69
+ }
70
+ const kompasApiAi = 'https://ai.kompas.id/api/v1';
71
+ // Constructing parameters
72
+ const params = new URLSearchParams();
73
+ params.append('page_url', this.permalinkArticle);
74
+ params.append('page_type', 'read');
75
+ params.append('item_type', 'articles');
76
+ params.append('guid', this.userGuid);
77
+ params.append('slugs', this.slugs);
78
+ // Constructing the URL with parameters
79
+ const endpoint = `${kompasApiAi}/recommendation?${params.toString()}`;
80
+ const response = await fetch(endpoint, {
81
+ headers: {
82
+ Authorization: `Bearer ${this.accessToken}`,
83
+ 'Content-Type': 'application/json',
84
+ },
85
+ });
86
+ const result = await response.json();
87
+ if (result === null || result === void 0 ? void 0 : result.result) {
88
+ const items = result.result;
89
+ const firstChunk = items.slice(0, 5);
90
+ const secondChunk = items.slice(5, 7);
91
+ this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)];
92
+ console.log('related article:', this.posts);
93
+ }
94
+ else {
95
+ throw new Error('Data artikel terkait tidak ditemukan');
96
+ }
97
+ }
98
+ async otherArticles() {
99
+ if (!this.accessToken) {
100
+ throw new Error('Token akses tidak tersedia');
101
+ }
102
+ const kompasApiCdsSPA = 'https://cds.kompas.id/api/v1';
103
+ // Constructing the URL with parameters
104
+ const endpoint = `${kompasApiCdsSPA}/article/list/category/${this.mainCategory}`;
105
+ const response = await fetch(endpoint, {
106
+ headers: {
107
+ Authorization: `Bearer ${this.accessToken}`,
108
+ 'Content-Type': 'application/json',
109
+ },
110
+ });
111
+ const result = await response.json();
112
+ if (result === null || result === void 0 ? void 0 : result.result) {
113
+ const items = result.result;
114
+ const firstChunk = items.slice(0, 5);
115
+ const secondChunk = items.slice(5, 7);
116
+ this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)];
117
+ console.log('other article:', this.posts);
118
+ }
119
+ else {
120
+ throw new Error('Data artikel lainnya tidak ditemukan');
121
+ }
122
+ }
123
+ handleFetchError(error) {
124
+ const errorMessage = error instanceof Error ? error.message : 'Kesalahan tidak diketahui';
125
+ alert(`Terjadi kesalahan: ${errorMessage}`);
126
+ }
127
+ /**
128
+ * Function to format date
129
+ */
130
+ formatDate(date) {
131
+ return format(new Date(date), 'dd MMMM yyyy', { locale: id });
132
+ }
133
+ /**
134
+ * Render widget components
135
+ */
136
+ WidgetTitle() {
137
+ var _a, _b;
138
+ if (this.navigationPermalink) {
139
+ return html `
140
+ <a
141
+ href="${this.navigationPermalink}"
142
+ class="flex font-sans uppercase items-start mb-6 mt-8"
143
+ >
144
+ <h5
145
+ class="${[
146
+ 'capitalize font-bold font-sans',
147
+ this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
148
+ ].join(' ')}"
149
+ >
150
+ ${(_a = this.navigation) === null || _a === void 0 ? void 0 : _a.name}
151
+ </h5>
152
+ </a>
153
+ `;
154
+ }
155
+ return html `
156
+ <div class="flex font-sans uppercase items-start mb-6 mt-8">
157
+ <div>
158
+ <h5
159
+ class="${[
160
+ 'capitalize font-bold font-sans',
161
+ this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
162
+ ].join(' ')}"
163
+ >
164
+ ${(_b = this.navigation) === null || _b === void 0 ? void 0 : _b.name}
165
+ </h5>
166
+ </div>
167
+ </div>
168
+ `;
169
+ }
170
+ renderChips(post) {
171
+ var _a, _b;
172
+ const chips = [];
173
+ const isAnalisis = (_a = post.postTag) === null || _a === void 0 ? void 0 : _a.some(tag => tag.slug === 'analisis');
174
+ const isEksklusif = (_b = post.postTag) === null || _b === void 0 ? void 0 : _b.some(tag => tag.slug === 'eksklusif');
175
+ const isFreemium = post.isFreemium === true;
176
+ if (isEksklusif) {
177
+ chips.push(html `
178
+ <div class="flex">
179
+ <div class="chip bg-grey-600 text-white">
180
+ <img
181
+ src="https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg"
182
+ alt="Kompas Icon"
183
+ style="width: 16px; height: 16px; margin-right: 4px;"
184
+ />
185
+ Eksklusif
186
+ </div>
187
+ </div>
188
+ `);
189
+ }
190
+ else if (isFreemium) {
191
+ chips.push(html `
192
+ <div class="flex">
193
+ <div class="chip bg-blue-100 text-brand-1">Bebas Akses</div>
194
+ </div>
195
+ `);
196
+ }
197
+ else if (isAnalisis) {
198
+ chips.push(html `
199
+ <div class="flex">
200
+ <div class="chip bg-orange-100 text-orange-500">Analisis</div>
201
+ </div>
202
+ `);
203
+ }
204
+ return chips;
205
+ }
206
+ renderImage(post) {
207
+ var _a;
208
+ const { thumbnailMedium } = ((_a = post.thumbnails) === null || _a === void 0 ? void 0 : _a.sizes) || {};
209
+ if (!thumbnailMedium)
210
+ return '';
211
+ const { permalink, width, height } = thumbnailMedium;
212
+ return html `
213
+ <img
214
+ src="${permalink}"
215
+ width="${width}"
216
+ height="${height}"
217
+ alt="${post.title}"
218
+ class="aspect-video object-cover w-full"
219
+ />
220
+ `;
221
+ }
222
+ render() {
223
+ return html `
224
+ <div class="w-full">
225
+ <!-- start: widget title -->
226
+ ${this.WidgetTitle()}
227
+ <!-- end: widget title -->
228
+
229
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
230
+ <!-- start: left-post-loop -->
231
+ <div class="grid grid-cols-1 gap-6">
232
+ ${this.posts[0]
233
+ ? this.posts[0].map(post => html `
234
+ <div class="w-full">
235
+ <div class="flex">
236
+ <div class="w-1/2">${this.renderImage(post)}</div>
237
+ <div class="flex-grow pl-4 w-1/2">
238
+ <a href="${post.permalink}">
239
+ ${this.renderChips(post)}
240
+ <h5
241
+ class="hover:underline font-bold font-sans leading-tight text-grey-600"
242
+ >
243
+ ${post.title}
244
+ </h5>
245
+ <p class="text-grey-600 pt-2">
246
+ ${this.formatDate(post.publishedDate)}
247
+ </p>
248
+ </a>
249
+ </div>
250
+ </div>
251
+ </div>
252
+ `)
253
+ : 'Belum ada artikel'}
254
+ </div>
255
+ <!-- end: left-post-loop -->
256
+
257
+ <!-- start: right-post-loop -->
258
+ <div class="flex flex-col w-full">
259
+ ${this.posts[1]
260
+ ? this.posts[1].map(post => html `
261
+ <div class="mb-6">
262
+ <div class="flex">
263
+ <div class="w-1/2">${this.renderImage(post)}</div>
264
+ <div class="flex-grow pl-4 w-1/2">
265
+ <a href="${post.permalink}">
266
+ ${this.renderChips(post)}
267
+ <h5
268
+ class="hover:underline font-bold font-sans leading-tight text-grey-600"
269
+ >
270
+ ${post.title}
271
+ </h5>
272
+ <p class="text-grey-600 pt-2">
273
+ ${this.formatDate(post.publishedDate)}
274
+ </p>
275
+ </a>
276
+ </div>
277
+ </div>
278
+ </div>
279
+ `)
280
+ : ''}
281
+ <!-- start: ads -->
282
+ <slot></slot>
283
+ <!-- end: ads -->
284
+ </div>
285
+ <!-- end: right-post-loop -->
286
+ </div>
287
+ </div>
288
+ `;
289
+ }
290
+ };
291
+ KompasWidgetRecirculationsDefault.styles = [
292
+ css `
293
+ :host {
294
+ font-family: 'PT Sans', sans-serif;
295
+ }
296
+ .chip {
297
+ align-items: center;
298
+ border-radius: 0.25rem;
299
+ display: flex;
300
+ font-family: 'PT Sans', sans-serif;
301
+ font-size: 0.75rem;
302
+ font-weight: bold;
303
+ height: 1.5rem;
304
+ justify-content: center;
305
+ line-height: 1rem;
306
+ margin-bottom: 0.25rem;
307
+ padding: 0.375rem 0.5rem;
308
+ }
309
+ `,
310
+ TWStyles,
311
+ ];
312
+ __decorate([
313
+ property({ type: Array })
314
+ ], KompasWidgetRecirculationsDefault.prototype, "posts", void 0);
315
+ __decorate([
316
+ property({ type: Object })
317
+ ], KompasWidgetRecirculationsDefault.prototype, "navigation", void 0);
318
+ __decorate([
319
+ property({ type: String })
320
+ ], KompasWidgetRecirculationsDefault.prototype, "accessToken", void 0);
321
+ __decorate([
322
+ property({ type: String })
323
+ ], KompasWidgetRecirculationsDefault.prototype, "permalinkArticle", void 0);
324
+ __decorate([
325
+ property({ type: String })
326
+ ], KompasWidgetRecirculationsDefault.prototype, "userGuid", void 0);
327
+ __decorate([
328
+ property({ type: String })
329
+ ], KompasWidgetRecirculationsDefault.prototype, "slugs", void 0);
330
+ __decorate([
331
+ property({ type: String })
332
+ ], KompasWidgetRecirculationsDefault.prototype, "type", void 0);
333
+ __decorate([
334
+ property({ type: String })
335
+ ], KompasWidgetRecirculationsDefault.prototype, "mainCategory", void 0);
336
+ KompasWidgetRecirculationsDefault = __decorate([
337
+ customElement('kompasid-widget-recirculations-default')
338
+ ], KompasWidgetRecirculationsDefault);
339
+ export { KompasWidgetRecirculationsDefault };
340
+ //# sourceMappingURL=KompasWidgetRecirculationsDefault.js.map