@kompasid/lit-web-components 0.8.19 → 0.8.21

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 (35) hide show
  1. package/demo/index.html +8 -2
  2. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.d.ts +1 -1
  3. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js +19 -20
  4. package/dist/src/components/kompasid-header-account/KompasHeaderAccount.js.map +1 -1
  5. package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.d.ts +0 -4
  6. package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.js +0 -7
  7. package/dist/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.js.map +1 -1
  8. package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js +2 -2
  9. package/dist/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.js.map +1 -1
  10. package/dist/src/components/kompasid-header-notification/KompasHeaderNotification.d.ts +1 -0
  11. package/dist/src/components/kompasid-header-notification/KompasHeaderNotification.js +18 -4
  12. package/dist/src/components/kompasid-header-notification/KompasHeaderNotification.js.map +1 -1
  13. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js +2 -8
  14. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js.map +1 -1
  15. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.d.ts +0 -2
  16. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js +1 -29
  17. package/dist/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js.map +1 -1
  18. package/dist/src/utils/getHeaderTheme.d.ts +3 -0
  19. package/dist/src/utils/getHeaderTheme.js +17 -0
  20. package/dist/src/utils/getHeaderTheme.js.map +1 -0
  21. package/dist/tailwind/tailwind.js +13 -16
  22. package/dist/tailwind/tailwind.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +2 -1
  25. package/src/components/kompasid-header-account/KompasHeaderAccount.ts +18 -18
  26. package/src/components/kompasid-header-account/readme.md +46 -0
  27. package/src/components/kompasid-header-account-menu/KompasHeaderAccountMenu.ts +0 -5
  28. package/src/components/kompasid-header-account-profile/KompasHeaderAccountProfile.ts +2 -2
  29. package/src/components/kompasid-header-notification/KompasHeaderNotification.ts +16 -4
  30. package/src/components/kompasid-header-notification/readme.md +3 -0
  31. package/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts +2 -9
  32. package/src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.ts +1 -31
  33. package/src/utils/getHeaderTheme.ts +19 -0
  34. package/tailwind/tailwind.css +4 -16
  35. package/tailwind/tailwind.ts +13 -16
@@ -1 +1 @@
1
- {"version":3,"file":"KompasHeaderNotification.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-notification/KompasHeaderNotification.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzE,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,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;AAOxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAGjC,IAAM,wBAAwB,GAA9B,MAAM,wBAAyB,SAAQ,UAAU;IAmJtD;QACE,KAAK,EAAE,CAAA;QA3BA,mBAAc,GAAY,KAAK,CAAA;QAC/B,gBAAW,GA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,EAAE,CAAC;qEAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2EAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8EAAiC;AAjJjD,wBAAwB;IADpC,aAAa,CAAC,8BAA8B,CAAC;GACjC,wBAAwB,CA+nBpC;SA/nBY,wBAAwB","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { format, isToday, formatDistanceStrict, subDays } from 'date-fns'\nimport { id } from 'date-fns/locale/id'\nimport { customElement, property, state } 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 UserNotification,\n NotificationList,\n ApiResponse,\n ApiRubrikResponse,\n} from './types.js'\nimport { customFetch } from './utils.js'\n\n@customElement('kompasid-header-notification')\nexport class KompasHeaderNotification extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .header-account--notification-indicator {\n position: absolute;\n top: 0;\n height: 0.5rem;\n width: 0.5rem;\n background-color: #ff7a00;\n border-radius: 50%;\n right: -0.403rem;\n top: -0.281rem;\n }\n\n .break-words {\n overflow-wrap: break-word;\n }\n\n .header-notification-dropdown {\n width: 20.5rem;\n background-color: #ffffff;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.875rem;\n position: absolute;\n right: -7.5vmax;\n }\n\n .w-14 {\n width: 3.25rem;\n }\n\n .pb-18 {\n padding-bottom: 4.5rem;\n }\n\n .h-\\\\[300px\\\\] {\n height: 300px;\n }\n\n .h-14 {\n height: 3.25rem;\n }\n\n .bg-green-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(238 252 210 / var(--tw-bg-opacity));\n }\n\n .overflow-y-scroll {\n overflow-y: scroll;\n }\n\n .link-active {\n color: #0468cb;\n border-color: #0468cb;\n border-bottom-width: 3px;\n background-color: transparent !important;\n }\n\n .animate-spin {\n animation: spin 2s linear infinite;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n\n .object-cover {\n object-fit: cover;\n }\n\n .z-index-max {\n z-index: 99999;\n }\n\n /* Custom Scrollbar for header */\n /* width */\n ::-webkit-scrollbar {\n width: 4px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background: transparent;\n }\n\n /* Handle */\n ::-webkit-scrollbar-thumb {\n background: #0356a8;\n border-radius: 100px;\n }\n\n /* Handle on hover */\n ::-webkit-scrollbar-thumb:hover {\n background: #0356a8;\n }\n\n @media (min-width: 1024px) {\n .header-notification-dropdown {\n right: -4vmax;\n }\n }\n\n @media (max-width: 360px) {\n .header-notification-dropdown {\n right: -10vmax;\n }\n }\n `,\n TWStyles,\n ]\n\n @state() isShowDropdown: boolean = false\n @state() selectedTab: string = 'Info'\n @state() notificationInfoData: UserNotification = {} as UserNotification\n @state() notificationContentData: any[] = []\n @state() isDataLoaded: boolean = false\n\n /*\n * property accessToken is the access token of the user\n * property refreshToken is the refresh token of the user\n * property domain is the domain of the API based on website\n * property tracker_user_type is the type of user based on their subscription\n * property tracker_subscription_status is the status of their subscription\n * property tracker_page_domain is the page domain\n * property tracker_metered_wall_type is the type of metered wall\n * property tracker_metered_wall_balance is the balance of their metered wall\n */\n\n @property({ type: String }) accessToken = ''\n @property({ type: String }) refreshToken = ''\n @property({ type: String }) domain = 'id' // 'id' | 'cloud'\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n\n constructor() {\n super()\n this.handleClickOutside = this.handleClickOutside.bind(this)\n }\n\n /**\n * Function to format date\n */\n formatDate(date: string) {\n // Check if the provided date is today\n let result\n if (isToday(date)) {\n // Return time difference if it's today (e.g., \"7 hours ago\")\n result = `${formatDistanceStrict(date, new Date(), { locale: id })} lalu`\n } else {\n // Return formatted date (e.g., \"12 Sep 2024, 09:00\")\n result = format(date, 'dd MMM yyyy, HH:mm', { locale: id })\n }\n return result\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n this.isShowDropdown = false\n\n if ((this.accessToken || this.refreshToken) && this.domain)\n await this.loadData()\n document.addEventListener('click', this.handleClickOutside)\n }\n\n override async disconnectedCallback() {\n super.disconnectedCallback()\n document.removeEventListener('click', this.handleClickOutside)\n }\n\n private async apiFetch(url: string, options: any) {\n const response = await customFetch(\n url,\n this.refreshToken,\n this.accessToken,\n this.domain,\n { ...options }\n )\n\n return response\n }\n\n private async getNotifRubrik() {\n const req = this.apiFetch(\n `https://cds.kompas.${this.domain}/api/v1/article/pilihanku`,\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n return req\n }\n\n private async getNotifList() {\n const req = await this.apiFetch(\n `https://api.kompas.${this.domain}/account/api/v1/users/notification`,\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n return req\n }\n\n private async getEpaperData() {\n const formatDate = 'yyyy/MM/dd'\n const startDate = format(subDays(new Date(), 1), formatDate)\n const endDate = format(new Date(), formatDate).toString()\n const req = await this.apiFetch(\n `https://apiepaper.kompas.${this.domain}/products?startDate=${startDate}&endDate=${endDate}&sort=desc`,\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n\n return req\n }\n\n private async notifRead(notifId: string) {\n const req = await this.apiFetch(\n `https://api.kompas.${this.domain}/account/api/v1/users/notification/read`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n body: JSON.stringify({\n notificationId: notifId,\n }),\n }\n )\n return req\n }\n\n private async loadData() {\n const apiCalls = [\n this.getNotifList(),\n this.getNotifRubrik(),\n this.getEpaperData(),\n ]\n this.isDataLoaded = false\n\n Promise.all(apiCalls)\n .then(responses =>\n Promise.all(responses.map(response => response.json()))\n )\n .then(values => {\n this.notificationInfoData = (\n values[0] as ApiResponse<UserNotification>\n ).data\n this.notificationInfoData.notificationList =\n this.notificationInfoData.notificationList || []\n const rubrikData = (values[1] as ApiRubrikResponse<any>).result || []\n const ePaperData = (values[2] as ApiResponse<any>).data[0] || {}\n\n const { publishDate, description, thumbnail, title, url } = ePaperData\n\n const data = {\n title,\n category: [{ name: 'ePaper', slug: 'epaper' }],\n publishedDate: format(new Date(publishDate), 'yyyy-MM-dd HH:mm:ss'),\n permalink: url,\n thumbnails: {\n sizes: { thumbnailSquareMedium: { permalink: thumbnail } },\n },\n excerpt: description,\n }\n\n this.notificationContentData = [data, ...rubrikData]\n this.notificationContentData.sort(\n (a: any, b: any) =>\n new Date(b.publishedDate).getTime() -\n new Date(a.publishedDate).getTime()\n )\n\n this.isDataLoaded = true\n })\n }\n\n private toggleDropdown() {\n this.isShowDropdown = !this.isShowDropdown\n\n // if opened, fire the datalayer\n if (this.isShowDropdown) this.pushDataLayer('notification_opened')\n }\n\n private notificationIcon() {\n const notificationIndicator = () => {\n if (!this.notificationInfoData.notificationCount) return html``\n return html`<div class=\"header-account--notification-indicator\"></div>`\n }\n\n return html`\n <button\n @click=${this.toggleDropdown}\n class=\"cursor-pointer relative flex items-center\"\n >\n ${notificationIndicator()}\n <div class=\"flex flex-row items-center self-center\">\n <div class=\"text-white cursor-pointer mt-0.5\">\n ${unsafeSVG(getFontAwesomeIcon('fas', 'bell', 21, 21))}\n </div>\n </div>\n </button>\n `\n }\n\n private handleClick = (value: string) => {\n this.selectedTab = value\n }\n\n private handleNotificationUrlParam = (url: string, type: string) => {\n const params = {\n open_from: type,\n }\n const newUrl = new URL(decodeURIComponent(url))\n if (newUrl.search) {\n for (const [key, value] of Object.entries(params)) {\n if (!newUrl.searchParams.has(key)) {\n newUrl.searchParams.append(key, value)\n }\n }\n } else {\n newUrl.search = new URLSearchParams(params).toString()\n }\n\n return newUrl.toString()\n }\n\n private redirectTo = async (notifData: NotificationList) => {\n const { notificationId: notifId, link, label } = notifData\n const res = await this.notifRead(notifId)\n\n if (res.status === 200) {\n this.notificationInfoData = {\n ...this.notificationInfoData,\n notificationList: this.notificationInfoData.notificationList\n ? this.notificationInfoData.notificationList.map(notifItem => ({\n ...notifItem,\n isRead:\n notifItem.notificationId === notifId ? true : notifItem.isRead,\n }))\n : [],\n }\n }\n\n this.pushDataLayer('notification_clicked', 'Information', label)\n if (link) {\n const url = this.handleNotificationUrlParam(link, 'Notification_Info')\n window.open(url, '_blank')\n }\n }\n\n private handleClickOutside(event: Event) {\n if (!this.isShowDropdown) return\n\n const popup = this.shadowRoot?.getElementById('headerNotification')\n const ev = event.composedPath()\n if (this.isShowDropdown && popup && !ev?.includes(popup as HTMLElement)) {\n this.isShowDropdown = false // Close the popup\n }\n }\n\n // Notification Info\n private notificationInfoSection() {\n const {\n notificationList,\n }: { notificationList: NotificationList[] | null } =\n this.notificationInfoData\n\n // Empty state\n if (!notificationList || !notificationList.length)\n return html`\n <div class=\"text-center px-4 pt-6 pb-18\">\n <img\n src=\"https://cdn-www.kompas.id/assets/empty-state-notification.png\"\n alt=\"empty-state-notification\"\n class=\"w-auto mx-auto\"\n />\n <p class=\"font-bold text-center text-lg py-2\">Belum Ada Notifikasi</p>\n <p class=\"px-2\">\n Kami akan memberitahukan Anda ketika ada informasi dan pemberitahuan\n terbaru.\n </p>\n </div>\n `\n\n const notificationInfoListTemplate = (item: NotificationList) => {\n const imgUrl =\n item.label === 'Akun'\n ? `https://cdn-www.kompas.id/assets/notifikasi-akun.svg`\n : `https://cdn-www.kompas.id/assets/langganan-anda-telah-berakhir.svg`\n\n return html`<div class=\"w-3/4 pr-1\">\n <div class=\"flex items-center mb-1 text-xs font-bold\">\n <span class=\"text-green-500 bg-green-100 rounded-sm p-1 px-2\">\n ${item.label}\n </span>\n <span class=\"text-grey-400 ml-2\"\n >${this.formatDate(item.time)}</span\n >\n </div>\n <div class=\"text-grey-600\">\n <p class=\"text-sm font-bold break-words\">${item.title}</p>\n <p class=\"text-sm\">${item.description}</p>\n </div>\n </div>\n <div class=\"w-1/4\">\n <img src=\"${imgUrl}\" alt=\"${item.label}-alt\" class=\"w-14 h-14\" />\n </div>`\n }\n\n return html`<div class=\"h-[300px] overflow-y-scroll\">\n ${notificationList.map(\n item =>\n html`<button\n class=\"flex w-full text-left items-start p-4 cursor-pointer justify-between ${!item.isRead\n ? 'bg-blue-100'\n : ''}\"\n @click=${() => this.redirectTo(item)}\n >\n ${notificationInfoListTemplate(item)}\n </button> `\n )}\n </div>\n <!-- Footer Link -->\n <div class=\"px-4 py-4 text-center\">\n <a href=\"#\" @click=\"${() =>\n this.redirectToNotification(\n 'info'\n )}\" class=\"text-base font-bold text-blue-500\">\n Lihat Selengkapnya</a\n >\n </div>\n </div>`\n }\n\n private redirectToNotification(tab: string) {\n window.open(\n `https://account.kompas.${this.domain}/manage-account/notification/${tab}`,\n '_blank'\n )\n }\n\n // Notification Content\n private notificationContentSection() {\n // Empty state\n if (!this.notificationContentData.length) {\n return html`\n <div class=\"text-center px-4 pt-6 pb-18\">\n <img\n src=\"https://cdn-www.kompas.id/assets/empty-state-notification.png\"\n alt=\"empty-state-notification\"\n class=\"w-auto mx-auto\"\n />\n <p class=\"font-bold text-center text-lg py-2\">Belum Ada Notifikasi</p>\n <p class=\"px-2\">\n Kami akan memberitahukan Anda ketika ada informasi dan pemberitahuan\n terbaru.\n </p>\n </div>\n `\n }\n const notificationContentListTemplate = (item: any) => html`<div\n class=\"w-3/4 pr-1 \"\n >\n <div class=\"flex items-center mb-1 text-xs font-bold\">\n <span class=\"text-green-500 bg-green-100 rounded-sm p-1 px-2\">\n ${item.category[0].name}\n </span>\n <span class=\"text-grey-400 ml-2\">\n ${this.formatDate(item.publishedDate)}</span\n >\n </div>\n <p class=\"font-bold text-sm text-grey-600 py-1 break-words\">\n ${item.title}\n </p>\n </div>\n <div class=\"w-1/4\">\n <img\n src=\"${item.thumbnails.sizes.thumbnailSquareMedium.permalink}\"\n alt=\"content-img-alt\"\n class=\"w-14 h-14 object-cover\"\n />\n </div>`\n\n return html`<div class=\"h-[300px] overflow-y-scroll\">\n ${this.notificationContentData.map(\n item =>\n html`<button\n class=\"flex w-full text-left items-start p-4 cursor-pointer justify-between ${!item.isRead\n ? 'bg-blue-100'\n : ''}\"\n @click=${() => {\n this.pushDataLayer('notification_clicked', 'Content', 'Content')\n window.open(\n this.handleNotificationUrlParam(\n item.permalink,\n 'Notification_Content'\n ),\n '_blank'\n )\n }}\n >\n ${notificationContentListTemplate(item)}\n </button> `\n )}\n </div>\n <!-- Footer Link -->\n <div class=\"px-4 py-4 text-center\">\n <a href=\"#\" @click=\"${() =>\n this.redirectToNotification(\n 'konten'\n )}\" class=\"text-base font-bold text-blue-500\">\n Lihat Selengkapnya</a\n >\n </div>\n </div>`\n }\n\n private notificationPopup() {\n const tab = ['Info', 'Konten']\n\n return html`\n <div\n id=\"notificationPopup\"\n class=\"header-notification-dropdown rounded-lg shadow-lg z-50 mt-2 ${this\n .isShowDropdown\n ? 'active'\n : ''}\"\n >\n <div class=\"sticky\">\n <div class=\"flex justify-center py-4 border-b border-grey-300\">\n <span class=\"font-bold text-base text-grey-700\">Notifikasi</span>\n </div>\n <!-- Tabs for Info and Content -->\n <div class=\"flex justify-between text-grey-400\">\n ${tab.map(\n item =>\n html`\n <button\n class=\"focus:outline-none font-bold py-2 w-1/2 ${this\n .selectedTab === item && 'link-active'}\"\n @click=${() => this.handleClick(item)}\n >\n ${item}\n </button>\n `\n )}\n </div>\n </div>\n\n <!-- Notification Content -->\n ${this.selectedTab === 'Info'\n ? this.notificationInfoSection()\n : this.notificationContentSection()}\n </div>\n `\n }\n\n private getParamsData(tab?: string, type?: string): any {\n let notificationData = {}\n let notifType = type\n\n if (type && tab) {\n if (type !== 'Content') {\n switch (true) {\n case /langganan/i.test(type):\n notifType = 'Subscription'\n break\n case type === 'Akun':\n notifType = 'Account'\n break\n case /bayar/i.test(type):\n notifType = 'Payment'\n break\n default:\n notifType = 'Information'\n break\n }\n }\n\n notificationData = {\n notification_tab: tab,\n notification_type: notifType,\n }\n }\n\n const data = {\n user_type: this.tracker_user_type,\n subscription_status: this.tracker_subscription_status,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n metered_wall_type: this.tracker_metered_wall_type || 'FP',\n metered_wall_balance: this.tracker_metered_wall_balance,\n }\n\n return {\n ...notificationData,\n ...data,\n }\n }\n\n private pushDataLayer(eventName: string, tab?: string, type?: string): void {\n const data = this.getParamsData(tab, type)\n window.dataLayer.push({\n event: eventName,\n ...data,\n })\n }\n\n render() {\n return html`<div id=\"headerNotification\" class=\"relative\">\n ${this.isDataLoaded\n ? this.notificationIcon()\n : html`<div class=\"text-white cursor-pointer mt-0.5 animate-spin\">\n ${unsafeSVG(getFontAwesomeIcon('fa', 'circle-notch', 21, 21))}\n </div>`}\n ${this.isShowDropdown ? this.notificationPopup() : ''}\n </div>`\n }\n}\n"]}
1
+ {"version":3,"file":"KompasHeaderNotification.js","sourceRoot":"","sources":["../../../../src/components/kompasid-header-notification/KompasHeaderNotification.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AACzE,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,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;AAOxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAGvD,I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AE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAc;AACb;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAyC;AAExC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6EAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2EAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8EAAiC;AApJjD,wBAAwB;IADpC,aAAa,CAAC,8BAA8B,CAAC;GACjC,wBAAwB,CA0oBpC;SA1oBY,wBAAwB","sourcesContent":["import { LitElement, html, css } from 'lit'\nimport { format, isToday, formatDistanceStrict, subDays } from 'date-fns'\nimport { id } from 'date-fns/locale/id'\nimport { customElement, property, state } 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 UserNotification,\n NotificationList,\n ApiResponse,\n ApiRubrikResponse,\n} from './types.js'\nimport { customFetch } from './utils.js'\nimport { getHeaderTheme } from '../../utils/getHeaderTheme.js'\n\n@customElement('kompasid-header-notification')\nexport class KompasHeaderNotification extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .header-account--notification-indicator {\n position: absolute;\n top: 0;\n height: 0.5rem;\n width: 0.5rem;\n background-color: #ff7a00;\n border-radius: 50%;\n right: 0.03rem;\n top: 0.09rem;\n border: 1.2px solid white;\n }\n\n .break-words {\n overflow-wrap: break-word;\n }\n\n .header-notification-dropdown {\n width: 20.5rem;\n background-color: #ffffff;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.875rem;\n position: absolute;\n right: -7.5vmax;\n }\n\n .w-14 {\n width: 3.25rem;\n }\n\n .pb-18 {\n padding-bottom: 4.5rem;\n }\n\n .h-\\\\[300px\\\\] {\n height: 300px;\n }\n\n .h-14 {\n height: 3.25rem;\n }\n\n .bg-green-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(238 252 210 / var(--tw-bg-opacity));\n }\n\n .overflow-y-scroll {\n overflow-y: scroll;\n }\n\n .link-active {\n color: #0468cb;\n border-color: #0468cb;\n border-bottom-width: 3px;\n background-color: transparent !important;\n }\n\n .animate-spin {\n animation: spin 2s linear infinite;\n }\n\n @keyframes spin {\n from {\n transform: rotate(0deg);\n }\n to {\n transform: rotate(360deg);\n }\n }\n\n .object-cover {\n object-fit: cover;\n }\n\n .z-index-max {\n z-index: 99999;\n }\n\n /* Custom Scrollbar for header */\n /* width */\n ::-webkit-scrollbar {\n width: 4px;\n }\n\n /* Track */\n ::-webkit-scrollbar-track {\n background: transparent;\n }\n\n /* Handle */\n ::-webkit-scrollbar-thumb {\n background: #0356a8;\n border-radius: 100px;\n }\n\n /* Handle on hover */\n ::-webkit-scrollbar-thumb:hover {\n background: #0356a8;\n }\n\n @media (min-width: 1024px) {\n .header-notification-dropdown {\n right: -4vmax;\n }\n }\n\n @media (max-width: 360px) {\n .header-notification-dropdown {\n right: -10vmax;\n }\n }\n `,\n TWStyles,\n ]\n\n @state() isShowDropdown: boolean = false\n @state() selectedTab: string = 'Info'\n @state() notificationInfoData: UserNotification = {} as UserNotification\n @state() notificationContentData: any[] = []\n @state() isDataLoaded: boolean = false\n\n /*\n * property accessToken is the access token of the user\n * property refreshToken is the refresh token of the user\n * property domain is the domain of the API based on website\n * property tracker_user_type is the type of user based on their subscription\n * property tracker_subscription_status is the status of their subscription\n * property tracker_page_domain is the page domain\n * property tracker_metered_wall_type is the type of metered wall\n * property tracker_metered_wall_balance is the balance of their metered wall\n */\n\n @property({ type: String }) accessToken = ''\n @property({ type: String }) refreshToken = ''\n @property({ type: String }) domain = 'id' // 'id' | 'cloud'\n @property({ type: String }) theme: 'default' | 'primary' = 'default'\n\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n\n constructor() {\n super()\n this.handleClickOutside = this.handleClickOutside.bind(this)\n }\n\n /**\n * Function to format date\n */\n formatDate(date: string) {\n // Check if the provided date is today\n let result\n if (isToday(date)) {\n // Return time difference if it's today (e.g., \"7 hours ago\")\n result = `${formatDistanceStrict(date, new Date(), { locale: id })} lalu`\n } else {\n // Return formatted date (e.g., \"12 Sep 2024, 09:00\")\n result = format(date, 'dd MMM yyyy, HH:mm', { locale: id })\n }\n return result\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n this.isShowDropdown = false\n\n if ((this.accessToken || this.refreshToken) && this.domain)\n await this.loadData()\n document.addEventListener('click', this.handleClickOutside)\n }\n\n override async disconnectedCallback() {\n super.disconnectedCallback()\n document.removeEventListener('click', this.handleClickOutside)\n }\n\n private async apiFetch(url: string, options: any) {\n const response = await customFetch(\n url,\n this.refreshToken,\n this.accessToken,\n this.domain,\n { ...options }\n )\n\n return response\n }\n\n private async getNotifRubrik() {\n const req = this.apiFetch(\n `https://cds.kompas.${this.domain}/api/v1/article/pilihanku`,\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n return req\n }\n\n private async getNotifList() {\n const req = await this.apiFetch(\n `https://api.kompas.${this.domain}/account/api/v1/users/notification`,\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n return req\n }\n\n private async getEpaperData() {\n const formatDate = 'yyyy/MM/dd'\n const startDate = format(subDays(new Date(), 1), formatDate)\n const endDate = format(new Date(), formatDate).toString()\n const req = await this.apiFetch(\n `https://apiepaper.kompas.${this.domain}/products?startDate=${startDate}&endDate=${endDate}&sort=desc`,\n {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n }\n )\n\n return req\n }\n\n private async notifRead(notifId: string) {\n const req = await this.apiFetch(\n `https://api.kompas.${this.domain}/account/api/v1/users/notification/read`,\n {\n headers: {\n 'Content-Type': 'application/json',\n },\n method: 'PUT',\n body: JSON.stringify({\n notificationId: notifId,\n }),\n }\n )\n return req\n }\n\n private async loadData() {\n const apiCalls = [\n this.getNotifList(),\n this.getNotifRubrik(),\n this.getEpaperData(),\n ]\n this.isDataLoaded = false\n\n Promise.all(apiCalls)\n .then(responses =>\n Promise.all(responses.map(response => response.json()))\n )\n .then(values => {\n this.notificationInfoData = (\n values[0] as ApiResponse<UserNotification>\n ).data\n this.notificationInfoData.notificationList =\n this.notificationInfoData.notificationList || []\n const rubrikData = (values[1] as ApiRubrikResponse<any>).result || []\n const ePaperData = (values[2] as ApiResponse<any>).data[0] || {}\n\n const { publishDate, description, thumbnail, title, url } = ePaperData\n\n const data = {\n title,\n category: [{ name: 'ePaper', slug: 'epaper' }],\n publishedDate: format(new Date(publishDate), 'yyyy-MM-dd HH:mm:ss'),\n permalink: url,\n thumbnails: {\n sizes: { thumbnailSquareMedium: { permalink: thumbnail } },\n },\n excerpt: description,\n }\n\n this.notificationContentData = [data, ...rubrikData]\n this.notificationContentData.sort(\n (a: any, b: any) =>\n new Date(b.publishedDate).getTime() -\n new Date(a.publishedDate).getTime()\n )\n\n this.isDataLoaded = true\n })\n }\n\n private toggleDropdown() {\n this.isShowDropdown = !this.isShowDropdown\n\n // if opened, fire the datalayer\n if (this.isShowDropdown) this.pushDataLayer('notification_opened')\n }\n\n private notificationIcon() {\n const notificationIndicator = () => {\n if (!this.notificationInfoData.notificationCount) return html``\n return html`<div class=\"header-account--notification-indicator\"></div>`\n }\n\n return html`\n <button\n @click=${this.toggleDropdown}\n class=\"cursor-pointer relative flex items-center\"\n >\n ${notificationIndicator()}\n <div class=\"flex flex-row items-center self-center\">\n <div\n class=\"cursor-pointer mt-0.5 ${getHeaderTheme({\n icon: this.theme,\n })}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fas', 'bell', 21, 21))}\n </div>\n </div>\n </button>\n `\n }\n\n private handleClick = (value: string) => {\n this.selectedTab = value\n }\n\n private handleNotificationUrlParam = (url: string, type: string) => {\n const params = {\n open_from: type,\n }\n const newUrl = new URL(decodeURIComponent(url))\n if (newUrl.search) {\n for (const [key, value] of Object.entries(params)) {\n if (!newUrl.searchParams.has(key)) {\n newUrl.searchParams.append(key, value)\n }\n }\n } else {\n newUrl.search = new URLSearchParams(params).toString()\n }\n\n return newUrl.toString()\n }\n\n private redirectTo = async (notifData: NotificationList) => {\n const { notificationId: notifId, link, label } = notifData\n const res = await this.notifRead(notifId)\n\n if (res.status === 200) {\n this.notificationInfoData = {\n ...this.notificationInfoData,\n notificationList: this.notificationInfoData.notificationList\n ? this.notificationInfoData.notificationList.map(notifItem => ({\n ...notifItem,\n isRead:\n notifItem.notificationId === notifId ? true : notifItem.isRead,\n }))\n : [],\n }\n }\n\n this.pushDataLayer('notification_clicked', 'Information', label)\n if (link) {\n const url = this.handleNotificationUrlParam(link, 'Notification_Info')\n window.open(url, '_blank')\n }\n }\n\n private handleClickOutside(event: Event) {\n if (!this.isShowDropdown) return\n\n const popup = this.shadowRoot?.getElementById('headerNotification')\n const ev = event.composedPath()\n if (this.isShowDropdown && popup && !ev?.includes(popup as HTMLElement)) {\n this.isShowDropdown = false // Close the popup\n }\n }\n\n // Notification Info\n private notificationInfoSection() {\n const {\n notificationList,\n }: { notificationList: NotificationList[] | null } =\n this.notificationInfoData\n\n // Empty state\n if (!notificationList || !notificationList.length)\n return html`\n <div class=\"text-center px-4 pt-6 pb-18\">\n <img\n src=\"https://cdn-www.kompas.id/assets/empty-state-notification.png\"\n alt=\"empty-state-notification\"\n class=\"w-auto mx-auto\"\n />\n <p class=\"font-bold text-center text-lg py-2\">Belum Ada Notifikasi</p>\n <p class=\"px-2\">\n Kami akan memberitahukan Anda ketika ada informasi dan pemberitahuan\n terbaru.\n </p>\n </div>\n `\n\n const notificationInfoListTemplate = (item: NotificationList) => {\n const imgUrl =\n item.label === 'Akun'\n ? `https://cdn-www.kompas.id/assets/notifikasi-akun.svg`\n : `https://cdn-www.kompas.id/assets/langganan-anda-telah-berakhir.svg`\n\n return html`<div class=\"w-3/4 pr-1\">\n <div class=\"flex items-center mb-1 text-xs font-bold\">\n <span class=\"text-green-500 bg-green-100 rounded-sm p-1 px-2\">\n ${item.label}\n </span>\n <span class=\"text-grey-400 ml-2\"\n >${this.formatDate(item.time)}</span\n >\n </div>\n <div class=\"text-grey-600\">\n <p class=\"text-sm font-bold break-words\">${item.title}</p>\n <p class=\"text-sm\">${item.description}</p>\n </div>\n </div>\n <div class=\"w-1/4\">\n <img src=\"${imgUrl}\" alt=\"${item.label}-alt\" class=\"w-14 h-14\" />\n </div>`\n }\n\n return html`<div class=\"h-[300px] overflow-y-scroll\">\n ${notificationList.map(\n item =>\n html`<button\n class=\"flex w-full text-left items-start p-4 cursor-pointer justify-between ${!item.isRead\n ? 'bg-blue-100'\n : ''}\"\n @click=${() => this.redirectTo(item)}\n >\n ${notificationInfoListTemplate(item)}\n </button> `\n )}\n </div>\n <!-- Footer Link -->\n <div class=\"px-4 py-4 text-center\">\n <a href=\"#\" @click=\"${() =>\n this.redirectToNotification(\n 'info'\n )}\" class=\"text-base font-bold text-blue-500\">\n Lihat Selengkapnya</a\n >\n </div>\n </div>`\n }\n\n private redirectToNotification(tab: string) {\n window.open(\n `https://account.kompas.${this.domain}/manage-account/notification/${tab}`,\n '_blank'\n )\n }\n\n // Notification Content\n private notificationContentSection() {\n // Empty state\n if (!this.notificationContentData.length) {\n return html`\n <div class=\"text-center px-4 pt-6 pb-18\">\n <img\n src=\"https://cdn-www.kompas.id/assets/empty-state-notification.png\"\n alt=\"empty-state-notification\"\n class=\"w-auto mx-auto\"\n />\n <p class=\"font-bold text-center text-lg py-2\">Belum Ada Notifikasi</p>\n <p class=\"px-2\">\n Kami akan memberitahukan Anda ketika ada informasi dan pemberitahuan\n terbaru.\n </p>\n </div>\n `\n }\n const notificationContentListTemplate = (item: any) => html`<div\n class=\"w-3/4 pr-1 \"\n >\n <div class=\"flex items-center mb-1 text-xs font-bold\">\n <span class=\"text-green-500 bg-green-100 rounded-sm p-1 px-2\">\n ${item.category[0].name}\n </span>\n <span class=\"text-grey-400 ml-2\">\n ${this.formatDate(item.publishedDate)}</span\n >\n </div>\n <p class=\"font-bold text-sm text-grey-600 py-1 break-words\">\n ${item.title}\n </p>\n </div>\n <div class=\"w-1/4\">\n <img\n src=\"${item.thumbnails.sizes.thumbnailSquareMedium.permalink}\"\n alt=\"content-img-alt\"\n class=\"w-14 h-14 object-cover\"\n />\n </div>`\n\n return html`<div class=\"h-[300px] overflow-y-scroll\">\n ${this.notificationContentData.map(\n item =>\n html`<button\n class=\"flex w-full text-left items-start p-4 cursor-pointer justify-between ${!item.isRead\n ? 'bg-blue-100'\n : ''}\"\n @click=${() => {\n this.pushDataLayer('notification_clicked', 'Content', 'Content')\n window.open(\n this.handleNotificationUrlParam(\n item.permalink,\n 'Notification_Content'\n ),\n '_blank'\n )\n }}\n >\n ${notificationContentListTemplate(item)}\n </button> `\n )}\n </div>\n <!-- Footer Link -->\n <div class=\"px-4 py-4 text-center\">\n <a href=\"#\" @click=\"${() =>\n this.redirectToNotification(\n 'konten'\n )}\" class=\"text-base font-bold text-blue-500\">\n Lihat Selengkapnya</a\n >\n </div>\n </div>`\n }\n\n private notificationPopup() {\n const tab = ['Info', 'Konten']\n\n return html`\n <div\n id=\"notificationPopup\"\n class=\"header-notification-dropdown rounded-lg shadow-lg z-50 mt-2 ${this\n .isShowDropdown\n ? 'active'\n : ''}\"\n >\n <div class=\"sticky\">\n <div class=\"flex justify-center py-4 border-b border-grey-300\">\n <span class=\"font-bold text-base text-grey-700\">Notifikasi</span>\n </div>\n <!-- Tabs for Info and Content -->\n <div class=\"flex justify-between text-grey-400\">\n ${tab.map(\n item =>\n html`\n <button\n class=\"focus:outline-none font-bold py-2 w-1/2 ${this\n .selectedTab === item && 'link-active'}\"\n @click=${() => this.handleClick(item)}\n >\n ${item}\n </button>\n `\n )}\n </div>\n </div>\n\n <!-- Notification Content -->\n ${this.selectedTab === 'Info'\n ? this.notificationInfoSection()\n : this.notificationContentSection()}\n </div>\n `\n }\n\n private getParamsData(tab?: string, type?: string): any {\n let notificationData = {}\n let notifType = type\n\n if (type && tab) {\n if (type !== 'Content') {\n switch (true) {\n case /langganan/i.test(type):\n notifType = 'Subscription'\n break\n case type === 'Akun':\n notifType = 'Account'\n break\n case /bayar/i.test(type):\n notifType = 'Payment'\n break\n default:\n notifType = 'Information'\n break\n }\n }\n\n notificationData = {\n notification_tab: tab,\n notification_type: notifType,\n }\n }\n\n const data = {\n user_type: this.tracker_user_type,\n subscription_status: this.tracker_subscription_status,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n metered_wall_type: this.tracker_metered_wall_type || 'FP',\n metered_wall_balance: this.tracker_metered_wall_balance,\n }\n\n return {\n ...notificationData,\n ...data,\n }\n }\n\n private pushDataLayer(eventName: string, tab?: string, type?: string): void {\n const data = this.getParamsData(tab, type)\n window.dataLayer.push({\n event: eventName,\n ...data,\n })\n }\n\n render() {\n return html`<div id=\"headerNotification\" class=\"relative\">\n ${this.isDataLoaded\n ? this.notificationIcon()\n : html`<div\n class=\"cursor-pointer mt-0.5 animate-spin ${getHeaderTheme({\n icon: this.theme,\n })}\"\n >\n ${unsafeSVG(getFontAwesomeIcon('fa', 'circle-notch', 21, 21))}\n </div>`}\n ${this.isShowDropdown ? this.notificationPopup() : ''}\n </div>`\n }\n}\n"]}
@@ -26,8 +26,8 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
26
26
  async connectedCallback() {
27
27
  super.connectedCallback();
28
28
  try {
29
- await this.fetchAccessToken();
30
29
  if (this.type === 'relatedArticle') {
30
+ await this.fetchAccessToken();
31
31
  await this.relatedArticles();
32
32
  }
33
33
  else if (this.type === 'otherArticle') {
@@ -83,22 +83,17 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
83
83
  const firstChunk = items.slice(0, 5);
84
84
  const secondChunk = items.slice(5, 7);
85
85
  this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)];
86
- console.log('related article:', this.posts);
87
86
  }
88
87
  else {
89
88
  throw new Error('Data artikel terkait tidak ditemukan');
90
89
  }
91
90
  }
92
91
  async otherArticles() {
93
- if (!this.accessToken) {
94
- throw new Error('Token akses tidak tersedia');
95
- }
96
- const kompasApiCdsSPA = 'https://cds.kompas.id/api/v1';
92
+ const kompasApiCdsSPA = 'https://cds.kompas.id/api/v2';
97
93
  // Constructing the URL with parameters
98
94
  const endpoint = `${kompasApiCdsSPA}/article/list/category/${this.mainCategory}`;
99
95
  const response = await fetch(endpoint, {
100
96
  headers: {
101
- Authorization: `Bearer ${this.accessToken}`,
102
97
  'Content-Type': 'application/json',
103
98
  },
104
99
  });
@@ -108,7 +103,6 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
108
103
  const firstChunk = items.slice(0, 5);
109
104
  const secondChunk = items.slice(5, 7);
110
105
  this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)];
111
- console.log('other article:', this.posts);
112
106
  }
113
107
  else {
114
108
  throw new Error('Data artikel lainnya tidak ditemukan');
@@ -1 +1 @@
1
- {"version":3,"file":"KompasWidgetRecirculationsDefault.js","sourceRoot":"","sources":["../../../../src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,QAAQ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C;sEAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2EAAsB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gEAAW;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DACT;AACU;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAAkB;AACjB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAAe;AAEb;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iEAAe;AArChC,iCAAiC;IAD7C,aAAa,CAAC,wCAAwC,CAAC;GAC3C,iCAAiC,CA0V7C;SA1VY,iCAAiC","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { Post } from './types.js'\nimport { useTimeDifference } from '../../utils/useTimeDIfference.js'\n\n@customElement('kompasid-widget-recirculations-default')\nexport class KompasWidgetRecirculationsDefault extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n .chip {\n align-items: center;\n border-radius: 0.25rem;\n display: flex;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.75rem;\n font-weight: bold;\n height: 1.5rem;\n justify-content: center;\n line-height: 1rem;\n margin-bottom: 0.25rem;\n padding: 0.375rem 0.5rem;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n @property({ type: Array }) posts: Post[][] = []\n @property({ type: String }) accessToken = ''\n @property({ type: String }) permalinkArticle = ''\n @property({ type: String }) userGuid = '0'\n @property({ type: String }) slugs = ''\n @property({ type: String }) type: 'relatedArticle' | 'otherArticle' =\n 'relatedArticle'\n @property({ type: String }) mainCategory = ''\n @property({ type: String }) titleName = '' // contoh: Artikel Terkait / Lainnya dalam 'kategori'\n @property({ type: String }) titleLink = '' // contoh: /kategori/opini\n\n @property({ type: Boolean }) isDark = false\n\n /**\n * Fetch Data\n */\n async connectedCallback() {\n super.connectedCallback()\n try {\n await this.fetchAccessToken()\n if (this.type === 'relatedArticle') {\n await this.relatedArticles()\n } else if (this.type === 'otherArticle') {\n await this.otherArticles()\n }\n } catch (error) {\n this.handleFetchError(error)\n }\n }\n\n async fetchAccessToken() {\n const response = await fetch(\n 'https://api.kompas.id/account/api/v1/login/guest',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n email: 'anonynous.user@kompas.id',\n }),\n }\n )\n\n const result = await response.json()\n\n if (result?.data?.accessToken) {\n this.accessToken = result.data.accessToken\n } else {\n throw new Error('Token akses tidak tersedia dalam respons')\n }\n }\n\n async relatedArticles() {\n if (!this.accessToken) {\n throw new Error('Token akses tidak tersedia')\n }\n\n const kompasApiAi = 'https://ai.kompas.id/api/v1'\n\n // Constructing parameters\n const params = new URLSearchParams()\n params.append('page_url', this.permalinkArticle)\n params.append('page_type', 'read')\n params.append('item_type', 'articles')\n params.append('guid', this.userGuid)\n params.append('slugs', this.slugs)\n\n // Constructing the URL with parameters\n const endpoint = `${kompasApiAi}/recommendation?${params.toString()}`\n\n const response = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${this.accessToken}`,\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n const items = result.result\n const firstChunk = items.slice(0, 5)\n const secondChunk = items.slice(5, 7)\n this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]\n console.log('related article:', this.posts)\n } else {\n throw new Error('Data artikel terkait tidak ditemukan')\n }\n }\n\n async otherArticles() {\n if (!this.accessToken) {\n throw new Error('Token akses tidak tersedia')\n }\n\n const kompasApiCdsSPA = 'https://cds.kompas.id/api/v1'\n\n // Constructing the URL with parameters\n const endpoint = `${kompasApiCdsSPA}/article/list/category/${this.mainCategory}`\n\n const response = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${this.accessToken}`,\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n const items = result.result\n const firstChunk = items.slice(0, 5)\n const secondChunk = items.slice(5, 7)\n this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]\n console.log('other article:', this.posts)\n } else {\n throw new Error('Data artikel lainnya tidak ditemukan')\n }\n }\n\n handleFetchError(error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : 'Kesalahan tidak diketahui'\n alert(`Terjadi kesalahan: ${errorMessage}`)\n }\n\n /**\n * Render widget components\n */\n\n private titleRelatedArticle() {\n return html`\n <div class=\"flex font-sans uppercase items-start mb-6 mt-8\">\n <div>\n <h5\n class=\"capitalize font-bold font-sans text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n Artikel Terkait\n </h5>\n </div>\n </div>\n `\n }\n\n private titleOtherArticle() {\n return html`\n <a\n href=\"${this.titleLink}\"\n class=\"flex font-sans uppercase items-start mb-6 mt-8\"\n >\n <h5\n class=\"capitalize font-bold font-sans text-lg md:text-xl ${this.isDark\n ? 'text-blue-200'\n : 'text-brand-1'}\"\n >\n ${this.titleName}\n </h5>\n </a>\n `\n }\n\n renderChips(post: Post) {\n const chips = []\n const isAnalisis = post.postTag?.some(tag => tag.slug === 'analisis')\n const isEksklusif = post.postTag?.some(tag => tag.slug === 'eksklusif')\n const isKompasBrief = post.postTag?.some(tag => tag.slug === 'kompas-brief')\n const isFreemium = post.isFreemium === true\n\n if (isKompasBrief) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-red-100 text-red-600\">Kompas Brief</div>\n </div>\n `\n )\n } else if (isEksklusif) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-grey-600 text-white\">\n <img\n src=\"https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg\"\n alt=\"Kompas Icon\"\n style=\"width: 16px; height: 16px; margin-right: 4px;\"\n />\n Eksklusif\n </div>\n </div>\n `\n )\n } else if (isFreemium) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-blue-100 text-brand-1\">Bebas Akses</div>\n </div>\n `\n )\n } else if (isAnalisis) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-orange-100 text-orange-500\">Analisis</div>\n </div>\n `\n )\n }\n\n return chips\n }\n\n renderImage(post: Post) {\n const { thumbnailMedium } = post.thumbnails?.sizes || {}\n if (!thumbnailMedium) return ''\n\n const { permalink, width, height } = thumbnailMedium\n return html`\n <img\n src=\"${permalink}\"\n width=\"${width}\"\n height=\"${height}\"\n alt=\"${post.title}\"\n class=\"aspect-video object-cover w-full\"\n />\n `\n }\n\n render() {\n return html`\n <div class=\"w-full ${this.isDark ? 'bg-dark-5 ' : ''}\">\n <!-- start: widget title -->\n ${this.type === 'relatedArticle'\n ? this.titleRelatedArticle()\n : this.titleOtherArticle()}\n <!-- end: widget title -->\n\n <div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8\">\n <!-- start: left-post-loop -->\n <div class=\"grid grid-cols-1 gap-6\">\n ${this.posts[0]\n ? this.posts[0].map(\n post => html`\n <div class=\"w-full\">\n <div class=\"flex\">\n <div class=\"w-1/2\">${this.renderImage(post)}</div>\n <div class=\"flex-grow pl-4 w-1/2\">\n <a href=\"${post.permalink}\">\n ${this.renderChips(post)}\n <h5\n class=\"hover:underline font-bold font-sans leading-tight text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${post.title}\n </h5>\n <p\n class=\"font-sans pt-2 text-sm ${this.isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${useTimeDifference(post.publishedDate)}\n </p>\n </a>\n </div>\n </div>\n </div>\n `\n )\n : 'Belum ada artikel'}\n </div>\n <!-- end: left-post-loop -->\n\n <!-- start: right-post-loop -->\n <div class=\"flex flex-col w-full\">\n ${this.posts[1]\n ? this.posts[1].map(\n post => html`\n <div class=\"mb-6\">\n <div class=\"flex\">\n <div class=\"w-1/2\">${this.renderImage(post)}</div>\n <div class=\"flex-grow pl-4 w-1/2\">\n <a href=\"${post.permalink}\">\n ${this.renderChips(post)}\n <h5\n class=\"hover:underline font-bold font-sans leading-tight text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${post.title}\n </h5>\n <p\n class=\"font-sans pt-2 text-sm ${this.isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${useTimeDifference(post.publishedDate)}\n </p>\n </a>\n </div>\n </div>\n </div>\n `\n )\n : ''}\n <!-- start: ads -->\n <slot></slot>\n <!-- end: ads -->\n </div>\n <!-- end: right-post-loop -->\n </div>\n </div>\n `\n }\n}\n"]}
1
+ {"version":3,"file":"KompasWidgetRecirculationsDefault.js","sourceRoot":"","sources":["../../../../src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAG7D,IAAM,iCAAiC,GAAvC,MAAM,iCAAkC,SAAQ,UAAU;IAA1D;;QAuBL;;WAEG;QACwB,UAAK,GAAa,EAAE,CAAA;QACnB,gBAAW,GAAG,EAAE,CAAA;QAChB,qBAAgB,GAAG,EAAE,CAAA;QACrB,aAAQ,GAAG,GAAG,CAAA;QACd,UAAK,GAAG,EAAE,CAAA;QACV,SAAI,GAC9B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AmV7C;SAnVY,iCAAiC","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { Post } from './types.js'\nimport { useTimeDifference } from '../../utils/useTimeDIfference.js'\n\n@customElement('kompasid-widget-recirculations-default')\nexport class KompasWidgetRecirculationsDefault extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n .chip {\n align-items: center;\n border-radius: 0.25rem;\n display: flex;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.75rem;\n font-weight: bold;\n height: 1.5rem;\n justify-content: center;\n line-height: 1rem;\n margin-bottom: 0.25rem;\n padding: 0.375rem 0.5rem;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n @property({ type: Array }) posts: Post[][] = []\n @property({ type: String }) accessToken = ''\n @property({ type: String }) permalinkArticle = ''\n @property({ type: String }) userGuid = '0'\n @property({ type: String }) slugs = ''\n @property({ type: String }) type: 'relatedArticle' | 'otherArticle' =\n 'relatedArticle'\n @property({ type: String }) mainCategory = ''\n @property({ type: String }) titleName = '' // contoh: Artikel Terkait / Lainnya dalam 'kategori'\n @property({ type: String }) titleLink = '' // contoh: /kategori/opini\n\n @property({ type: Boolean }) isDark = false\n\n /**\n * Fetch Data\n */\n async connectedCallback() {\n super.connectedCallback()\n try {\n if (this.type === 'relatedArticle') {\n await this.fetchAccessToken()\n await this.relatedArticles()\n } else if (this.type === 'otherArticle') {\n await this.otherArticles()\n }\n } catch (error) {\n this.handleFetchError(error)\n }\n }\n\n async fetchAccessToken() {\n const response = await fetch(\n 'https://api.kompas.id/account/api/v1/login/guest',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n email: 'anonynous.user@kompas.id',\n }),\n }\n )\n\n const result = await response.json()\n\n if (result?.data?.accessToken) {\n this.accessToken = result.data.accessToken\n } else {\n throw new Error('Token akses tidak tersedia dalam respons')\n }\n }\n\n async relatedArticles() {\n if (!this.accessToken) {\n throw new Error('Token akses tidak tersedia')\n }\n\n const kompasApiAi = 'https://ai.kompas.id/api/v1'\n\n // Constructing parameters\n const params = new URLSearchParams()\n params.append('page_url', this.permalinkArticle)\n params.append('page_type', 'read')\n params.append('item_type', 'articles')\n params.append('guid', this.userGuid)\n params.append('slugs', this.slugs)\n\n // Constructing the URL with parameters\n const endpoint = `${kompasApiAi}/recommendation?${params.toString()}`\n\n const response = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${this.accessToken}`,\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n const items = result.result\n const firstChunk = items.slice(0, 5)\n const secondChunk = items.slice(5, 7)\n this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]\n } else {\n throw new Error('Data artikel terkait tidak ditemukan')\n }\n }\n\n async otherArticles() {\n const kompasApiCdsSPA = 'https://cds.kompas.id/api/v2'\n\n // Constructing the URL with parameters\n const endpoint = `${kompasApiCdsSPA}/article/list/category/${this.mainCategory}`\n\n const response = await fetch(endpoint, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n const items = result.result\n const firstChunk = items.slice(0, 5)\n const secondChunk = items.slice(5, 7)\n this.posts = [Object.freeze(firstChunk), Object.freeze(secondChunk)]\n } else {\n throw new Error('Data artikel lainnya tidak ditemukan')\n }\n }\n\n handleFetchError(error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : 'Kesalahan tidak diketahui'\n alert(`Terjadi kesalahan: ${errorMessage}`)\n }\n\n /**\n * Render widget components\n */\n\n private titleRelatedArticle() {\n return html`\n <div class=\"flex font-sans uppercase items-start mb-6 mt-8\">\n <div>\n <h5\n class=\"capitalize font-bold font-sans text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n Artikel Terkait\n </h5>\n </div>\n </div>\n `\n }\n\n private titleOtherArticle() {\n return html`\n <a\n href=\"${this.titleLink}\"\n class=\"flex font-sans uppercase items-start mb-6 mt-8\"\n >\n <h5\n class=\"capitalize font-bold font-sans text-lg md:text-xl ${this.isDark\n ? 'text-blue-200'\n : 'text-brand-1'}\"\n >\n ${this.titleName}\n </h5>\n </a>\n `\n }\n\n renderChips(post: Post) {\n const chips = []\n const isAnalisis = post.postTag?.some(tag => tag.slug === 'analisis')\n const isEksklusif = post.postTag?.some(tag => tag.slug === 'eksklusif')\n const isKompasBrief = post.postTag?.some(tag => tag.slug === 'kompas-brief')\n const isFreemium = post.isFreemium === true\n\n if (isKompasBrief) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-red-100 text-red-600\">Kompas Brief</div>\n </div>\n `\n )\n } else if (isEksklusif) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-grey-600 text-white\">\n <img\n src=\"https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg\"\n alt=\"Kompas Icon\"\n style=\"width: 16px; height: 16px; margin-right: 4px;\"\n />\n Eksklusif\n </div>\n </div>\n `\n )\n } else if (isFreemium) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-blue-100 text-brand-1\">Bebas Akses</div>\n </div>\n `\n )\n } else if (isAnalisis) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-orange-100 text-orange-500\">Analisis</div>\n </div>\n `\n )\n }\n\n return chips\n }\n\n renderImage(post: Post) {\n const { thumbnailMedium } = post.thumbnails?.sizes || {}\n if (!thumbnailMedium) return ''\n\n const { permalink, width, height } = thumbnailMedium\n return html`\n <img\n src=\"${permalink}\"\n width=\"${width}\"\n height=\"${height}\"\n alt=\"${post.title}\"\n class=\"aspect-video object-cover w-full\"\n />\n `\n }\n\n render() {\n return html`\n <div class=\"w-full ${this.isDark ? 'bg-dark-5 ' : ''}\">\n <!-- start: widget title -->\n ${this.type === 'relatedArticle'\n ? this.titleRelatedArticle()\n : this.titleOtherArticle()}\n <!-- end: widget title -->\n\n <div class=\"grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8\">\n <!-- start: left-post-loop -->\n <div class=\"grid grid-cols-1 gap-6\">\n ${this.posts[0]\n ? this.posts[0].map(\n post => html`\n <div class=\"w-full\">\n <div class=\"flex\">\n <div class=\"w-1/2\">${this.renderImage(post)}</div>\n <div class=\"flex-grow pl-4 w-1/2\">\n <a href=\"${post.permalink}\">\n ${this.renderChips(post)}\n <h5\n class=\"hover:underline font-bold font-sans leading-tight text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${post.title}\n </h5>\n <p\n class=\"font-sans pt-2 text-sm ${this.isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${useTimeDifference(post.publishedDate)}\n </p>\n </a>\n </div>\n </div>\n </div>\n `\n )\n : 'Belum ada artikel'}\n </div>\n <!-- end: left-post-loop -->\n\n <!-- start: right-post-loop -->\n <div class=\"flex flex-col w-full\">\n ${this.posts[1]\n ? this.posts[1].map(\n post => html`\n <div class=\"mb-6\">\n <div class=\"flex\">\n <div class=\"w-1/2\">${this.renderImage(post)}</div>\n <div class=\"flex-grow pl-4 w-1/2\">\n <a href=\"${post.permalink}\">\n ${this.renderChips(post)}\n <h5\n class=\"hover:underline font-bold font-sans leading-tight text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${post.title}\n </h5>\n <p\n class=\"font-sans pt-2 text-sm ${this.isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${useTimeDifference(post.publishedDate)}\n </p>\n </a>\n </div>\n </div>\n </div>\n `\n )\n : ''}\n <!-- start: ads -->\n <slot></slot>\n <!-- end: ads -->\n </div>\n <!-- end: right-post-loop -->\n </div>\n </div>\n `\n }\n}\n"]}
@@ -15,12 +15,10 @@ interface ListItem {
15
15
  export declare class KompasWidgetRecirculationsList extends LitElement {
16
16
  widgetTitle: string;
17
17
  articleList: ListItem[];
18
- accessToken: string;
19
18
  apiSlug: string;
20
19
  isDark: boolean;
21
20
  static styles: import("lit").CSSResult[];
22
21
  connectedCallback(): Promise<void>;
23
- fetchAccessToken(): Promise<void>;
24
22
  fetchArticles(): Promise<void>;
25
23
  handleFetchError(error: unknown): void;
26
24
  renderChips(item: ListItem): import("lit").TemplateResult<1>[];
@@ -8,47 +8,22 @@ let KompasWidgetRecirculationsList = class KompasWidgetRecirculationsList extend
8
8
  super(...arguments);
9
9
  this.widgetTitle = '';
10
10
  this.articleList = [];
11
- this.accessToken = '';
12
11
  this.apiSlug = '';
13
12
  this.isDark = false;
14
13
  }
15
14
  async connectedCallback() {
16
15
  super.connectedCallback();
17
16
  try {
18
- await this.fetchAccessToken();
19
17
  await this.fetchArticles();
20
18
  }
21
19
  catch (error) {
22
20
  this.handleFetchError(error);
23
21
  }
24
22
  }
25
- async fetchAccessToken() {
26
- var _a;
27
- const response = await fetch('https://api.kompas.id/account/api/v1/login/guest', {
28
- method: 'POST',
29
- headers: {
30
- 'Content-Type': 'application/json',
31
- },
32
- body: JSON.stringify({
33
- email: 'anonynous.user@kompas.id',
34
- }),
35
- });
36
- const result = await response.json();
37
- if ((_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.accessToken) {
38
- this.accessToken = result.data.accessToken;
39
- }
40
- else {
41
- throw new Error('Token akses tidak tersedia dalam respons');
42
- }
43
- }
44
23
  async fetchArticles() {
45
- if (!this.accessToken) {
46
- throw new Error('Token akses tidak tersedia');
47
- }
48
- const endpoint = `https://cds.kompas.id/api/v1/article/${this.apiSlug}`;
24
+ const endpoint = `https://cds.kompas.id/api/v2/article/${this.apiSlug}`;
49
25
  const response = await fetch(endpoint, {
50
26
  headers: {
51
- Authorization: `Bearer ${this.accessToken}`,
52
27
  'Content-Type': 'application/json',
53
28
  },
54
29
  });
@@ -192,9 +167,6 @@ __decorate([
192
167
  __decorate([
193
168
  property({ type: Array })
194
169
  ], KompasWidgetRecirculationsList.prototype, "articleList", void 0);
195
- __decorate([
196
- property({ type: String })
197
- ], KompasWidgetRecirculationsList.prototype, "accessToken", void 0);
198
170
  __decorate([
199
171
  property({ type: String })
200
172
  ], KompasWidgetRecirculationsList.prototype, "apiSlug", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"KompasWidgetRecirculationsList.js","sourceRoot":"","sources":["../../../../src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAkB7D,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,UAAU;IAAvD;;QACuB,gBAAW,GAAG,EAAE,CAAA;QACjB,gBAAW,GAAe,EAAE,CAAA;QAC3B,gBAAW,GAAG,EAAE,CAAA;QAChB,YAAO,GAAG,EAAE,CAAA;QAEX,WAAM,GAAG,KAAK,CAAA;IA2N7C,CAAC;IAnMC,KAAK,CAAC,iBAAiB;QACrB,KAAK,CAAC,iBAAiB,EAAE,CAAA;QACzB,IAAI;YACF,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAA;YAC7B,MAAM,IAAI,CAAC,aAAa,EAAE,CAAA;SAC3B;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;SAC7B;IACH,CAAC;IAED,KAAK,CAAC,gBAAgB;;QACpB,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,kDAAkD,EAClD;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,KAAK,EAAE,0BAA0B;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,CAAC,CAAC,eAAe;;cAEjB,IAAI,CAAC,WAAW;;;;;YAKlB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAChC,IAAI,CAAC,EAAE,CACL,IAAI,CAAA;;;;wBAIM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;;gCAEd,IAAI,CAAC,SAAS;4FAC8C,IAAI;aACrE,MAAM;YACP,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,eAAe;;0BAEjB,IAAI,CAAC,KAAK;;;yHAGqF,IAAI;aAClG,MAAM;YACP,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,eAAe;;0BAEjB,IAAI,CAAC,aAAa;YAClB,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC;YAC7C,CAAC,CAAC,wBAAwB;;;;;eAKrC,CACJ;;;KAGN,CAAA;IACH,CAAC;;AAxNM,qCAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;KAiBF;IACD,QAAQ;CACT,CAAA;AA3B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAiB;AACjB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mEAA6B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAiB;AAChB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAAa;AAEX;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8DAAe;AANhC,8BAA8B;IAD1C,aAAa,CAAC,qCAAqC,CAAC;GACxC,8BAA8B,CAiO1C;SAjOY,8BAA8B","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { useTimeDifference } from '../../utils/useTimeDIfference.js'\n\ninterface PostTag {\n slug: string\n}\n\ninterface ListItem {\n title: string\n isAnalisis?: boolean\n isEksklusif?: boolean\n isFreemium?: boolean\n isKompasBrief?: boolean\n permalink: string\n publishedDate?: string\n postTag?: PostTag[]\n}\n\n@customElement('kompasid-widget-recirculations-list')\nexport class KompasWidgetRecirculationsList extends LitElement {\n @property({ type: String }) widgetTitle = ''\n @property({ type: Array }) articleList: ListItem[] = []\n @property({ type: String }) accessToken = ''\n @property({ type: String }) apiSlug = ''\n\n @property({ type: Boolean }) isDark = false\n\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n .chip {\n align-items: center;\n border-radius: 0.25rem;\n display: flex;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.75rem;\n font-weight: bold;\n height: 1.5rem;\n justify-content: center;\n line-height: 1rem;\n margin-bottom: 0.25rem;\n padding: 0.375rem 0.5rem;\n }\n `,\n TWStyles,\n ]\n\n async connectedCallback() {\n super.connectedCallback()\n try {\n await this.fetchAccessToken()\n await this.fetchArticles()\n } catch (error) {\n this.handleFetchError(error)\n }\n }\n\n async fetchAccessToken() {\n const response = await fetch(\n 'https://api.kompas.id/account/api/v1/login/guest',\n {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n email: 'anonynous.user@kompas.id',\n }),\n }\n )\n\n const result = await response.json()\n\n if (result?.data?.accessToken) {\n this.accessToken = result.data.accessToken\n } else {\n throw new Error('Token akses tidak tersedia dalam respons')\n }\n }\n\n async fetchArticles() {\n if (!this.accessToken) {\n throw new Error('Token akses tidak tersedia')\n }\n\n const endpoint = `https://cds.kompas.id/api/v1/article/${this.apiSlug}`\n\n const response = await fetch(endpoint, {\n headers: {\n Authorization: `Bearer ${this.accessToken}`,\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n this.articleList = result.result.map(\n (article: {\n postTag?: never[] | undefined\n isFreemium?: false | undefined\n title: any\n permalink: any\n publishedDate: any\n }) => {\n const {\n postTag = [],\n isFreemium = false,\n title,\n permalink,\n publishedDate,\n } = article\n\n const isAnalisis = postTag.some(\n (tag: { slug: string }) => tag.slug === 'analisis'\n )\n const isEksklusif = postTag.some(\n (tag: { slug: string }) => tag.slug === 'eksklusif'\n )\n const isKompasBrief = postTag.some(\n (tag: { slug: string }) => tag.slug === 'kompas-brief'\n )\n\n return {\n isAnalisis,\n isEksklusif,\n isFreemium,\n isKompasBrief,\n title,\n permalink,\n publishedDate,\n }\n }\n )\n } else {\n throw new Error('Data artikel populer tidak ditemukan')\n }\n }\n\n handleFetchError(error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : 'Kesalahan tidak diketahui'\n alert(`Terjadi kesalahan: ${errorMessage}`)\n }\n\n renderChips(item: ListItem) {\n const chips = []\n\n if (item.isKompasBrief) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-red-100 text-red-600\">Kompas Brief</div>\n </div>\n `\n )\n } else if (item.isEksklusif) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-grey-600 text-white\">\n <img\n src=\"https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg\"\n alt=\"Kompas Icon\"\n style=\"width: 16px; height: 16px; margin-right: 4px;\"\n />\n Eksklusif\n </div>\n </div>\n `\n )\n } else if (item.isFreemium) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-blue-100 text-brand-1\">Bebas Akses</div>\n </div>\n `\n )\n } else if (item.isAnalisis) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-orange-100 text-orange-500\">Analisis</div>\n </div>\n `\n )\n }\n\n return chips\n }\n\n render() {\n return html`\n <div class=\"${this.isDark ? 'bg-dark-5 ' : ''}\">\n <div class=\"mb-6\">\n <h5\n class=\"capitalize font-bold font-sans text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${this.widgetTitle}\n </h5>\n </div>\n\n <ul class=\"flex flex-col\">\n ${this.articleList.slice(0, 5).map(\n item =>\n html`\n <li class=\"flex flex-col items-start mb-3\">\n <div class=\"flex w-full\">\n <div class=\"flex flex-col w-full\">\n ${this.renderChips(item)}\n <a\n href=\"${item.permalink}\"\n class=\"font-bold font-lora hover:underline leading-normal text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${item.title}\n </a>\n <div\n class=\"flex w-full flex-row font-sans items-center leading-normal justify-between pt-2 text-sm ${this\n .isDark\n ? 'text-white'\n : 'text-grey-500'}\"\n >\n ${item.publishedDate\n ? useTimeDifference(item.publishedDate, true)\n : 'Tanggal tidak tersedia'}\n </div>\n </div>\n </div>\n </li>\n `\n )}\n </ul>\n </div>\n `\n }\n}\n"]}
1
+ {"version":3,"file":"KompasWidgetRecirculationsList.js","sourceRoot":"","sources":["../../../../src/components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAkB7D,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,UAAU;IAAvD;;QACuB,gBAAW,GAAG,EAAE,CAAA;QACjB,gBAAW,GAAe,EAAE,CAAA;QAC3B,YAAO,GAAG,EAAE,CAAA;QAEX,WAAM,GAAG,KAAK,CAAA;IA8L7C,CAAC;IAtKC,KAAK,CAAC,iBAAiB;QACrB,KAAK,CAAC,iBAAiB,EAAE,CAAA;QACzB,IAAI;YACF,MAAM,IAAI,CAAC,aAAa,EAAE,CAAA;SAC3B;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC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AAa;YAClB,CAAC,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC;YAC7C,CAAC,CAAC,wBAAwB;;;;;eAKrC,CACJ;;;KAGN,CAAA;IACH,CAAC;;AA3LM,qCAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;KAiBF;IACD,QAAQ;CACT,CAAA;AA1B2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mEAAiB;AACjB;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;mEAA6B;AAC3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAAa;AAEX;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8DAAe;AALhC,8BAA8B;IAD1C,aAAa,CAAC,qCAAqC,CAAC;GACxC,8BAA8B,CAmM1C;SAnMY,8BAA8B","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { useTimeDifference } from '../../utils/useTimeDIfference.js'\n\ninterface PostTag {\n slug: string\n}\n\ninterface ListItem {\n title: string\n isAnalisis?: boolean\n isEksklusif?: boolean\n isFreemium?: boolean\n isKompasBrief?: boolean\n permalink: string\n publishedDate?: string\n postTag?: PostTag[]\n}\n\n@customElement('kompasid-widget-recirculations-list')\nexport class KompasWidgetRecirculationsList extends LitElement {\n @property({ type: String }) widgetTitle = ''\n @property({ type: Array }) articleList: ListItem[] = []\n @property({ type: String }) apiSlug = ''\n\n @property({ type: Boolean }) isDark = false\n\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n .chip {\n align-items: center;\n border-radius: 0.25rem;\n display: flex;\n font-family: 'PT Sans', sans-serif;\n font-size: 0.75rem;\n font-weight: bold;\n height: 1.5rem;\n justify-content: center;\n line-height: 1rem;\n margin-bottom: 0.25rem;\n padding: 0.375rem 0.5rem;\n }\n `,\n TWStyles,\n ]\n\n async connectedCallback() {\n super.connectedCallback()\n try {\n await this.fetchArticles()\n } catch (error) {\n this.handleFetchError(error)\n }\n }\n\n async fetchArticles() {\n const endpoint = `https://cds.kompas.id/api/v2/article/${this.apiSlug}`\n\n const response = await fetch(endpoint, {\n headers: {\n 'Content-Type': 'application/json',\n },\n })\n\n const result = await response.json()\n\n if (result?.result) {\n this.articleList = result.result.map(\n (article: {\n postTag?: never[] | undefined\n isFreemium?: false | undefined\n title: any\n permalink: any\n publishedDate: any\n }) => {\n const {\n postTag = [],\n isFreemium = false,\n title,\n permalink,\n publishedDate,\n } = article\n\n const isAnalisis = postTag.some(\n (tag: { slug: string }) => tag.slug === 'analisis'\n )\n const isEksklusif = postTag.some(\n (tag: { slug: string }) => tag.slug === 'eksklusif'\n )\n const isKompasBrief = postTag.some(\n (tag: { slug: string }) => tag.slug === 'kompas-brief'\n )\n\n return {\n isAnalisis,\n isEksklusif,\n isFreemium,\n isKompasBrief,\n title,\n permalink,\n publishedDate,\n }\n }\n )\n } else {\n throw new Error('Data artikel populer tidak ditemukan')\n }\n }\n\n handleFetchError(error: unknown) {\n const errorMessage =\n error instanceof Error ? error.message : 'Kesalahan tidak diketahui'\n alert(`Terjadi kesalahan: ${errorMessage}`)\n }\n\n renderChips(item: ListItem) {\n const chips = []\n\n if (item.isKompasBrief) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-red-100 text-red-600\">Kompas Brief</div>\n </div>\n `\n )\n } else if (item.isEksklusif) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-grey-600 text-white\">\n <img\n src=\"https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg\"\n alt=\"Kompas Icon\"\n style=\"width: 16px; height: 16px; margin-right: 4px;\"\n />\n Eksklusif\n </div>\n </div>\n `\n )\n } else if (item.isFreemium) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-blue-100 text-brand-1\">Bebas Akses</div>\n </div>\n `\n )\n } else if (item.isAnalisis) {\n chips.push(\n html`\n <div class=\"flex\">\n <div class=\"chip bg-orange-100 text-orange-500\">Analisis</div>\n </div>\n `\n )\n }\n\n return chips\n }\n\n render() {\n return html`\n <div class=\"${this.isDark ? 'bg-dark-5 ' : ''}\">\n <div class=\"mb-6\">\n <h5\n class=\"capitalize font-bold font-sans text-lg md:text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${this.widgetTitle}\n </h5>\n </div>\n\n <ul class=\"flex flex-col\">\n ${this.articleList.slice(0, 5).map(\n item =>\n html`\n <li class=\"flex flex-col items-start mb-3\">\n <div class=\"flex w-full\">\n <div class=\"flex flex-col w-full\">\n ${this.renderChips(item)}\n <a\n href=\"${item.permalink}\"\n class=\"font-bold font-lora hover:underline leading-normal text-xl ${this\n .isDark\n ? 'text-white'\n : 'text-grey-600'}\"\n >\n ${item.title}\n </a>\n <div\n class=\"flex w-full flex-row font-sans items-center leading-normal justify-between pt-2 text-sm ${this\n .isDark\n ? 'text-white'\n : 'text-grey-500'}\"\n >\n ${item.publishedDate\n ? useTimeDifference(item.publishedDate, true)\n : 'Tanggal tidak tersedia'}\n </div>\n </div>\n </div>\n </li>\n `\n )}\n </ul>\n </div>\n `\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const getHeaderTheme: (props?: import("class-variance-authority/dist/types").ClassProp | ({
2
+ [x: string]: string | number | symbol | null | undefined;
3
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
@@ -0,0 +1,17 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ import { cva } from 'class-variance-authority';
3
+ let responseData;
4
+ await fetch('https://cdn-www.kompas.id/global-header/theme.json', {
5
+ method: 'GET',
6
+ headers: {
7
+ 'Content-Type': 'application/json',
8
+ },
9
+ })
10
+ .then(response => response.json())
11
+ .then(data => {
12
+ responseData = data;
13
+ });
14
+ export const getHeaderTheme = cva('', {
15
+ variants: responseData.header,
16
+ });
17
+ //# sourceMappingURL=getHeaderTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getHeaderTheme.js","sourceRoot":"","sources":["../../../src/utils/getHeaderTheme.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAE9C,IAAI,YAAY,CAAA;AAEhB,MAAM,KAAK,CAAC,oDAAoD,EAAE;IAChE,MAAM,EAAE,KAAK;IACb,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;KACnC;CACF,CAAC;KACC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;KACjC,IAAI,CAAC,IAAI,CAAC,EAAE;IACX,YAAY,GAAG,IAAI,CAAA;AACrB,CAAC,CAAC,CAAA;AAEJ,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC,EAAE,EAAE;IACpC,QAAQ,EAAG,YAAoB,CAAC,MAAM;CACvC,CAAC,CAAA","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport { cva } from 'class-variance-authority'\n\nlet responseData\n\nawait fetch('https://cdn-www.kompas.id/global-header/theme.json', {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n})\n .then(response => response.json())\n .then(data => {\n responseData = data\n })\n\nexport const getHeaderTheme = cva('', {\n variants: (responseData as any).header,\n})\n"]}
@@ -822,14 +822,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
822
822
  height: 4rem;
823
823
  }
824
824
 
825
- .h-2 {
826
- height: 0.5rem;
827
- }
828
-
829
- .h-2\\.5 {
830
- height: 0.625rem;
831
- }
832
-
833
825
  .h-20 {
834
826
  height: 5rem;
835
827
  }
@@ -919,14 +911,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
919
911
  width: 4rem;
920
912
  }
921
913
 
922
- .w-2 {
923
- width: 0.5rem;
924
- }
925
-
926
- .w-2\\.5 {
927
- width: 0.625rem;
928
- }
929
-
930
914
  .w-2\\/3 {
931
915
  width: 66.666667%;
932
916
  }
@@ -935,6 +919,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
935
919
  width: 5rem;
936
920
  }
937
921
 
922
+ .w-3 {
923
+ width: 0.75rem;
924
+ }
925
+
938
926
  .w-3\\/4 {
939
927
  width: 75%;
940
928
  }
@@ -1230,6 +1218,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1230
1218
  white-space: nowrap;
1231
1219
  }
1232
1220
 
1221
+ .break-words {
1222
+ overflow-wrap: break-word;
1223
+ }
1224
+
1233
1225
  .rounded {
1234
1226
  border-radius: 0.25rem;
1235
1227
  }
@@ -1892,6 +1884,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1892
1884
  color: rgb(51 51 51 / var(--tw-text-opacity));
1893
1885
  }
1894
1886
 
1887
+ .text-grey-700 {
1888
+ --tw-text-opacity: 1;
1889
+ color: rgb(0 0 0 / var(--tw-text-opacity));
1890
+ }
1891
+
1895
1892
  .text-orange-400 {
1896
1893
  --tw-text-opacity: 1;
1897
1894
  color: rgb(255 122 0 / var(--tw-text-opacity));