@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
@@ -0,0 +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,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAIjD,IAAM,iCAAiC,GAAvC,MAAM,iCAAkC,SAAQ,UAAU;IAA1D;;QAuBL;;WAEG;QACwB,UAAK,GAAa,EAAE,CAAA;QACnB,eAAU,GAA2B,SAAS,CAAA;QAC9C,gBAAW,GAAG,EAAE,CAAA;QAChB,qBAAgB,GAAG,EAAE,CAAA;QACrB,aAAQ,GAAG,GAAG,CAAA;QACd,UAAK,GAAG,EAAE,CAAA;QACV,SAAI,GAC9B,gBAAgB,CAAA;QACU,iBAAY,GAAG,EAAE,CAAA;IA2S/C,CAAC;IAzSC;;OAEG;IACH,IAAI,mBAAmB;;QACrB,OAAO,MAAA,IAAI,CAAC,UAAU,0CAAE,SAAS,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACrB,KAAK,CAAC,iBAAiB,EAAE,CAAA;QACzB,IAAI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AAa,CAAC;;;;;;mBAMhD,CACF;YACH,CAAC,CAAC,EAAE;;;;;;;;KAQb,CAAA;IACH,CAAC;;AA3UM,wCAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;KAiBF;IACD,QAAQ;CACT,CAAA;AAK0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gEAAqB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qEAA+C;AAC9C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;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;AAlClC,iCAAiC;IAD7C,aAAa,CAAC,wCAAwC,CAAC;GAC3C,iCAAiC,CA6U7C;SA7UY,iCAAiC","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { format } from 'date-fns'\nimport { id } from 'date-fns/locale/id'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\nimport { Post, Navigation } from './types.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: Object }) navigation: Navigation | undefined = undefined\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\n /**\n * Getters\n */\n get navigationPermalink(): string | undefined {\n return this.navigation?.permalink\n }\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 * Function to format date\n */\n formatDate(date: string) {\n return format(new Date(date), 'dd MMMM yyyy', { locale: id })\n }\n\n /**\n * Render widget components\n */\n\n private WidgetTitle() {\n if (this.navigationPermalink) {\n return html`\n <a\n href=\"${this.navigationPermalink}\"\n class=\"flex font-sans uppercase items-start mb-6 mt-8\"\n >\n <h5\n class=\"${[\n 'capitalize font-bold font-sans',\n this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',\n ].join(' ')}\"\n >\n ${this.navigation?.name}\n </h5>\n </a>\n `\n }\n\n return html`\n <div class=\"flex font-sans uppercase items-start mb-6 mt-8\">\n <div>\n <h5\n class=\"${[\n 'capitalize font-bold font-sans',\n this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',\n ].join(' ')}\"\n >\n ${this.navigation?.name}\n </h5>\n </div>\n </div>\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 isFreemium = post.isFreemium === true\n\n 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\">\n <!-- start: widget title -->\n ${this.WidgetTitle()}\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-grey-600\"\n >\n ${post.title}\n </h5>\n <p class=\"text-grey-600 pt-2\">\n ${this.formatDate(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-grey-600\"\n >\n ${post.title}\n </h5>\n <p class=\"text-grey-600 pt-2\">\n ${this.formatDate(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"]}
@@ -0,0 +1,27 @@
1
+ interface PostTag {
2
+ slug: string;
3
+ }
4
+ export interface Post {
5
+ title: string;
6
+ isAnalisis?: boolean;
7
+ isEksklusif?: boolean;
8
+ isFreemium?: boolean;
9
+ featuredImageThumbnailMedium: string;
10
+ permalink: string;
11
+ publishedDate: string;
12
+ postTag?: PostTag[];
13
+ thumbnails: {
14
+ sizes: {
15
+ thumbnailMedium: {
16
+ permalink: string;
17
+ width: number;
18
+ height: number;
19
+ };
20
+ };
21
+ };
22
+ }
23
+ export interface Navigation {
24
+ name: string;
25
+ permalink: string;
26
+ }
27
+ export {};
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/kompasid-widget-recirculations-default/types.ts"],"names":[],"mappings":"","sourcesContent":["interface PostTag {\n slug: string\n}\n\nexport interface Post {\n title: string\n isAnalisis?: boolean\n isEksklusif?: boolean\n isFreemium?: boolean\n featuredImageThumbnailMedium: string\n permalink: string\n publishedDate: string\n postTag?: PostTag[]\n thumbnails: {\n sizes: {\n thumbnailMedium: {\n permalink: string\n width: number\n height: number\n }\n }\n }\n}\n\nexport interface Navigation {\n name: string\n permalink: string\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import { LitElement } from 'lit';
2
+ interface PostTag {
3
+ slug: string;
4
+ }
5
+ interface ListItem {
6
+ title: string;
7
+ isAnalisis?: boolean;
8
+ isEksklusif?: boolean;
9
+ isFreemium?: boolean;
10
+ permalink: string;
11
+ publishedDate?: string;
12
+ postTag?: PostTag[];
13
+ }
14
+ export declare class KompasWidgetRecirculationsList extends LitElement {
15
+ widgetTitle: string;
16
+ articleList: ListItem[];
17
+ accessToken: string;
18
+ apiSlug: string;
19
+ static styles: import("lit").CSSResult[];
20
+ connectedCallback(): Promise<void>;
21
+ fetchAccessToken(): Promise<void>;
22
+ fetchArticles(): Promise<void>;
23
+ formatDate(date: string): string;
24
+ handleFetchError(error: unknown): void;
25
+ renderChips(item: ListItem): import("lit").TemplateResult<1>[];
26
+ render(): import("lit").TemplateResult<1>;
27
+ }
28
+ export {};
@@ -0,0 +1,188 @@
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 KompasWidgetRecirculationsList = class KompasWidgetRecirculationsList extends LitElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.widgetTitle = '';
11
+ this.articleList = [];
12
+ this.accessToken = '';
13
+ this.apiSlug = '';
14
+ }
15
+ async connectedCallback() {
16
+ super.connectedCallback();
17
+ try {
18
+ await this.fetchAccessToken();
19
+ await this.fetchArticles();
20
+ }
21
+ catch (error) {
22
+ this.handleFetchError(error);
23
+ }
24
+ }
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
+ 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}`;
49
+ const response = await fetch(endpoint, {
50
+ headers: {
51
+ Authorization: `Bearer ${this.accessToken}`,
52
+ 'Content-Type': 'application/json',
53
+ },
54
+ });
55
+ const result = await response.json();
56
+ if (result === null || result === void 0 ? void 0 : result.result) {
57
+ this.articleList = result.result.map((article) => {
58
+ const { postTag = [], isFreemium = false, title, permalink, publishedDate, } = article;
59
+ const isAnalisis = postTag.some((tag) => tag.slug === 'analisis');
60
+ const isEksklusif = postTag.some((tag) => tag.slug === 'eksklusif');
61
+ return {
62
+ isAnalisis,
63
+ isEksklusif,
64
+ isFreemium,
65
+ title,
66
+ permalink,
67
+ publishedDate,
68
+ };
69
+ });
70
+ }
71
+ else {
72
+ throw new Error('Data artikel populer tidak ditemukan');
73
+ }
74
+ }
75
+ formatDate(date) {
76
+ return format(new Date(date), "dd MMMM yyyy' · 'HH:mm' WIB", { locale: id });
77
+ }
78
+ handleFetchError(error) {
79
+ const errorMessage = error instanceof Error ? error.message : 'Kesalahan tidak diketahui';
80
+ alert(`Terjadi kesalahan: ${errorMessage}`);
81
+ }
82
+ renderChips(item) {
83
+ const chips = [];
84
+ if (item.isAnalisis) {
85
+ chips.push(html `
86
+ <div class="flex">
87
+ <div class="chip bg-orange-100 text-orange-500">Analisis</div>
88
+ </div>
89
+ `);
90
+ }
91
+ if (item.isEksklusif) {
92
+ chips.push(html `
93
+ <div class="flex">
94
+ <div class="chip bg-grey-600 text-white">
95
+ <img
96
+ src="https://cdn-www.kompas.id/assets/img/icons/kompas-icon-small.svg"
97
+ alt="Kompas Icon"
98
+ style="width: 16px; height: 16px; margin-right: 4px;"
99
+ />
100
+ Eksklusif
101
+ </div>
102
+ </div>
103
+ `);
104
+ }
105
+ if (item.isFreemium) {
106
+ chips.push(html `
107
+ <div class="flex">
108
+ <div class="chip bg-blue-100 text-brand-1">Bebas Akses</div>
109
+ </div>
110
+ `);
111
+ }
112
+ return chips;
113
+ }
114
+ render() {
115
+ return html `
116
+ <div>
117
+ <div class="mb-6">
118
+ <h5 class="capitalize font-bold text-grey-600 font-sans">
119
+ ${this.widgetTitle}
120
+ </h5>
121
+ </div>
122
+
123
+ <ul class="flex flex-col">
124
+ ${this.articleList.slice(0, 5).map(item => html `
125
+ <li class="flex flex-col items-start mb-3">
126
+ <div class="flex w-full">
127
+ <div class="flex flex-col w-full">
128
+ ${this.renderChips(item)}
129
+ <a
130
+ href="${item.permalink}"
131
+ class="font-bold font-sans hover:underline leading-tight text-base text-grey-600"
132
+ >
133
+ ${item.title}
134
+ </a>
135
+ <div
136
+ class="flex w-full flex-row items-center leading-normal justify-between text-sm text-grey-500 font-sans pt-2"
137
+ >
138
+ ${item.publishedDate
139
+ ? this.formatDate(item.publishedDate)
140
+ : 'Tanggal tidak tersedia'}
141
+ </div>
142
+ </div>
143
+ </div>
144
+ </li>
145
+ `)}
146
+ </ul>
147
+ </div>
148
+ `;
149
+ }
150
+ };
151
+ KompasWidgetRecirculationsList.styles = [
152
+ css `
153
+ :host {
154
+ font-family: 'PT Sans', sans-serif;
155
+ }
156
+ .chip {
157
+ align-items: center;
158
+ border-radius: 0.25rem;
159
+ display: flex;
160
+ font-family: 'PT Sans', sans-serif;
161
+ font-size: 0.75rem;
162
+ font-weight: bold;
163
+ height: 1.5rem;
164
+ justify-content: center;
165
+ line-height: 1rem;
166
+ margin-bottom: 0.25rem;
167
+ padding: 0.375rem 0.5rem;
168
+ }
169
+ `,
170
+ TWStyles,
171
+ ];
172
+ __decorate([
173
+ property({ type: String })
174
+ ], KompasWidgetRecirculationsList.prototype, "widgetTitle", void 0);
175
+ __decorate([
176
+ property({ type: Array })
177
+ ], KompasWidgetRecirculationsList.prototype, "articleList", void 0);
178
+ __decorate([
179
+ property({ type: String })
180
+ ], KompasWidgetRecirculationsList.prototype, "accessToken", void 0);
181
+ __decorate([
182
+ property({ type: String })
183
+ ], KompasWidgetRecirculationsList.prototype, "apiSlug", void 0);
184
+ KompasWidgetRecirculationsList = __decorate([
185
+ customElement('kompasid-widget-recirculations-list')
186
+ ], KompasWidgetRecirculationsList);
187
+ export { KompasWidgetRecirculationsList };
188
+ //# sourceMappingURL=KompasWidgetRecirculationsList.js.map
@@ -0,0 +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,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAiBjD,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;IA4M1C,CAAC;IApLC,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,CA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AAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;cAID,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;;;0BAGpB,IAAI,CAAC,KAAK;;;;;0BAKV,IAAI,CAAC,aAAa;YAClB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC;YACrC,CAAC,CAAC,wBAAwB;;;;;eAKrC,CACJ;;;KAGN,CAAA;IACH,CAAC;;AAzMM,qCAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;KAiBF;IACD,QAAQ;CACT,CAAA;AAzB2B;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;AAJ7B,8BAA8B;IAD1C,aAAa,CAAC,qCAAqC,CAAC;GACxC,8BAA8B,CAgN1C;SAhNY,8BAA8B","sourcesContent":["import { html, css, LitElement } from 'lit'\nimport { customElement, property } from 'lit/decorators.js'\nimport { format } from 'date-fns'\nimport { id } from 'date-fns/locale/id'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\ninterface PostTag {\n slug: string\n}\n\ninterface ListItem {\n title: string\n isAnalisis?: boolean\n isEksklusif?: boolean\n isFreemium?: 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 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\n return {\n isAnalisis,\n isEksklusif,\n isFreemium,\n title,\n permalink,\n publishedDate,\n }\n }\n )\n } else {\n throw new Error('Data artikel populer tidak ditemukan')\n }\n }\n\n formatDate(date: string) {\n return format(new Date(date), \"dd MMMM yyyy' · 'HH:mm' WIB\", { locale: id })\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.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 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 }\n\n 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 }\n\n return chips\n }\n\n render() {\n return html`\n <div>\n <div class=\"mb-6\">\n <h5 class=\"capitalize font-bold text-grey-600 font-sans\">\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-sans hover:underline leading-tight text-base text-grey-600\"\n >\n ${item.title}\n </a>\n <div\n class=\"flex w-full flex-row items-center leading-normal justify-between text-sm text-grey-500 font-sans pt-2\"\n >\n ${item.publishedDate\n ? this.formatDate(item.publishedDate)\n : 'Tanggal tidak tersedia'}\n </div>\n </div>\n </div>\n </li>\n `\n )}\n </ul>\n </div>\n `\n }\n}\n"]}
@@ -1,3 +1,5 @@
1
+ export { KompasWidgetRecirculationsDefault } from './components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js';
2
+ export { KompasWidgetRecirculationsList } from './components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js';
1
3
  export { KompasPaywall } from './components/kompasid-paywall/KompasPaywall.js';
2
4
  export { KompasFooter } from './components/kompasid-footer/KompasFooter.js';
3
5
  export { KompasPaywallVideo } from './components/kompasid-paywall-video/KompasPaywallVideo.js';
package/dist/src/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ export { KompasWidgetRecirculationsDefault } from './components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js';
2
+ export { KompasWidgetRecirculationsList } from './components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js';
1
3
  export { KompasPaywall } from './components/kompasid-paywall/KompasPaywall.js';
2
4
  export { KompasFooter } from './components/kompasid-footer/KompasFooter.js';
3
5
  export { KompasPaywallVideo } from './components/kompasid-paywall-video/KompasPaywallVideo.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2DAA2D,CAAA;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,+DAA+D,CAAA;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAA;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAA;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6DAA6D,CAAA","sourcesContent":["export { KompasPaywall } from './components/kompasid-paywall/KompasPaywall.js'\nexport { KompasFooter } from './components/kompasid-footer/KompasFooter.js'\nexport { KompasPaywallVideo } from './components/kompasid-paywall-video/KompasPaywallVideo.js'\nexport { KompasMeteredPaywall } from './components/kompasid-metered-paywall/KompasMeteredPaywall.js'\nexport { KompasFreewall } from './components/kompasid-freewall/KompasFreewall.js'\nexport { KompasMeteredWallRegister } from './components/kompasid-metered-wall-register/KompasMeteredWallRegister.js'\nexport { KompasHeaderAccount } from './components/kompasid-header-account/KompasHeaderAccount.js'\n\ndeclare global {\n interface Window {\n gtag: (...args: any[]) => void\n dataLayer: Record<string, any>\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,0FAA0F,CAAA;AAC5I,OAAO,EAAE,8BAA8B,EAAE,MAAM,oFAAoF,CAAA;AACnI,OAAO,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAA;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,8CAA8C,CAAA;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2DAA2D,CAAA;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,+DAA+D,CAAA;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAA;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,0EAA0E,CAAA;AACpH,OAAO,EAAE,mBAAmB,EAAE,MAAM,6DAA6D,CAAA","sourcesContent":["export { KompasWidgetRecirculationsDefault } from './components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js'\nexport { KompasWidgetRecirculationsList } from './components/kompasid-widget-recirculations-list/KompasWidgetRecirculationsList.js'\nexport { KompasPaywall } from './components/kompasid-paywall/KompasPaywall.js'\nexport { KompasFooter } from './components/kompasid-footer/KompasFooter.js'\nexport { KompasPaywallVideo } from './components/kompasid-paywall-video/KompasPaywallVideo.js'\nexport { KompasMeteredPaywall } from './components/kompasid-metered-paywall/KompasMeteredPaywall.js'\nexport { KompasFreewall } from './components/kompasid-freewall/KompasFreewall.js'\nexport { KompasMeteredWallRegister } from './components/kompasid-metered-wall-register/KompasMeteredWallRegister.js'\nexport { KompasHeaderAccount } from './components/kompasid-header-account/KompasHeaderAccount.js'\n\ndeclare global {\n interface Window {\n gtag: (...args: any[]) => void\n dataLayer: Record<string, any>\n }\n}\n"]}
@@ -698,6 +698,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
698
698
  margin-bottom: 1.25rem;
699
699
  }
700
700
 
701
+ .mb-6 {
702
+ margin-bottom: 1.5rem;
703
+ }
704
+
701
705
  .ml-0 {
702
706
  margin-left: 0px;
703
707
  }
@@ -794,6 +798,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
794
798
  display: none;
795
799
  }
796
800
 
801
+ .aspect-video {
802
+ aspect-ratio: 16 / 9;
803
+ }
804
+
797
805
  .h-10 {
798
806
  height: 2.5rem;
799
807
  }
@@ -826,10 +834,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
826
834
  height: 1rem;
827
835
  }
828
836
 
829
- .h-40 {
830
- height: 10rem;
831
- }
832
-
833
837
  .h-5 {
834
838
  height: 1.25rem;
835
839
  }
@@ -875,6 +879,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
875
879
  height: max-content;
876
880
  }
877
881
 
882
+ .w-1\\/2 {
883
+ width: 50%;
884
+ }
885
+
878
886
  .w-1\\/3 {
879
887
  width: 33.333333%;
880
888
  }
@@ -975,6 +983,14 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
975
983
  width: 100%;
976
984
  }
977
985
 
986
+ .w-\\[165px\\] {
987
+ width: 165px;
988
+ }
989
+
990
+ .min-w-\\[165px\\] {
991
+ min-width: 165px;
992
+ }
993
+
978
994
  .max-w-7xl {
979
995
  max-width: 80rem;
980
996
  }
@@ -995,6 +1011,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
995
1011
  max-width: 20rem;
996
1012
  }
997
1013
 
1014
+ .max-w-\\[165px\\] {
1015
+ max-width: 165px;
1016
+ }
1017
+
998
1018
  .flex-none {
999
1019
  flex: none;
1000
1020
  }
@@ -1391,6 +1411,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1391
1411
  background-color: rgb(51 51 51 / var(--tw-bg-opacity));
1392
1412
  }
1393
1413
 
1414
+ .bg-orange-100 {
1415
+ --tw-bg-opacity: 1;
1416
+ background-color: rgb(255 238 204 / var(--tw-bg-opacity));
1417
+ }
1418
+
1394
1419
  .bg-white {
1395
1420
  --tw-bg-opacity: 1;
1396
1421
  background-color: rgb(255 255 255 / var(--tw-bg-opacity));
@@ -1508,6 +1533,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1508
1533
  padding-bottom: 5.6px;
1509
1534
  }
1510
1535
 
1536
+ .px-5 {
1537
+ padding-left: 1.25rem;
1538
+ padding-right: 1.25rem;
1539
+ }
1540
+
1511
1541
  .pb-1 {
1512
1542
  padding-bottom: 0.25rem;
1513
1543
  }
@@ -1592,6 +1622,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1592
1622
  padding-top: 2.5rem;
1593
1623
  }
1594
1624
 
1625
+ .pt-2 {
1626
+ padding-top: 0.5rem;
1627
+ }
1628
+
1595
1629
  .pt-4 {
1596
1630
  padding-top: 1rem;
1597
1631
  }
@@ -1620,6 +1654,13 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1620
1654
  text-align: end;
1621
1655
  }
1622
1656
 
1657
+ .font-sans {
1658
+ font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
1659
+ 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
1660
+ 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
1661
+ 'Noto Color Emoji';
1662
+ }
1663
+
1623
1664
  .font-serif {
1624
1665
  font-family: ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif;
1625
1666
  }
@@ -1669,6 +1710,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1669
1710
  font-weight: 400;
1670
1711
  }
1671
1712
 
1713
+ .uppercase {
1714
+ text-transform: uppercase;
1715
+ }
1716
+
1672
1717
  .capitalize {
1673
1718
  text-transform: capitalize;
1674
1719
  }
@@ -1701,6 +1746,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1701
1746
  line-height: 1.5;
1702
1747
  }
1703
1748
 
1749
+ .leading-tight {
1750
+ line-height: 1.25;
1751
+ }
1752
+
1704
1753
  .tracking-wide {
1705
1754
  letter-spacing: 0.025em;
1706
1755
  }
@@ -1800,6 +1849,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1800
1849
  color: rgb(255 122 0 / var(--tw-text-opacity));
1801
1850
  }
1802
1851
 
1852
+ .text-orange-500 {
1853
+ --tw-text-opacity: 1;
1854
+ color: rgb(219 93 0 / var(--tw-text-opacity));
1855
+ }
1856
+
1803
1857
  .text-white {
1804
1858
  --tw-text-opacity: 1;
1805
1859
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -1878,6 +1932,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1878
1932
  margin-bottom: 2rem;
1879
1933
  }
1880
1934
 
1935
+ .md\\:my-auto {
1936
+ margin-top: auto;
1937
+ margin-bottom: auto;
1938
+ }
1939
+
1881
1940
  .md\\:mb-0 {
1882
1941
  margin-bottom: 0px;
1883
1942
  }
@@ -1938,15 +1997,15 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1938
1997
  height: 68px;
1939
1998
  }
1940
1999
 
1941
- .md\\:h-full {
1942
- height: 100%;
1943
- }
1944
-
1945
2000
  .md\\:h-max {
1946
2001
  height: -moz-max-content;
1947
2002
  height: max-content;
1948
2003
  }
1949
2004
 
2005
+ .md\\:max-h-\\[220px\\] {
2006
+ max-height: 220px;
2007
+ }
2008
+
1950
2009
  .md\\:min-h-\\[244px\\] {
1951
2010
  min-height: 244px;
1952
2011
  }
@@ -1995,10 +2054,22 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1995
2054
  width: 100%;
1996
2055
  }
1997
2056
 
2057
+ .md\\:w-auto {
2058
+ width: auto;
2059
+ }
2060
+
2061
+ .md\\:w-\\[165px\\] {
2062
+ width: 165px;
2063
+ }
2064
+
1998
2065
  .md\\:max-w-\\[137px\\] {
1999
2066
  max-width: 137px;
2000
2067
  }
2001
2068
 
2069
+ .md\\:max-w-\\[200px\\] {
2070
+ max-width: 200px;
2071
+ }
2072
+
2002
2073
  .md\\:max-w-full {
2003
2074
  max-width: 100%;
2004
2075
  }
@@ -2011,6 +2082,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2011
2082
  grid-template-columns: repeat(1, minmax(0, 1fr));
2012
2083
  }
2013
2084
 
2085
+ .md\\:grid-cols-2 {
2086
+ grid-template-columns: repeat(2, minmax(0, 1fr));
2087
+ }
2088
+
2014
2089
  .md\\:flex-row {
2015
2090
  flex-direction: row;
2016
2091
  }