@kompasid/lit-web-components 0.7.1 → 0.7.3

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 (24) hide show
  1. package/demo/index.html +7 -10
  2. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.d.ts +29 -0
  3. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +146 -0
  4. package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -0
  5. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.d.ts +5 -7
  6. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js +26 -38
  7. package/dist/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.js.map +1 -1
  8. package/dist/src/components/kompasid-widget-recirculations-default/types.d.ts +0 -4
  9. package/dist/src/components/kompasid-widget-recirculations-default/types.js.map +1 -1
  10. package/dist/src/index.d.ts +1 -0
  11. package/dist/src/index.js +1 -0
  12. package/dist/src/index.js.map +1 -1
  13. package/dist/tailwind/tailwind.js +29 -21
  14. package/dist/tailwind/tailwind.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/package.json +1 -1
  17. package/src/components/kompasid-grace-period/KompasGracePeriod.ts +133 -0
  18. package/src/components/kompasid-grace-period/readme.md +17 -0
  19. package/src/components/kompasid-widget-recirculations-default/KompasWidgetRecirculationsDefault.ts +22 -36
  20. package/src/components/kompasid-widget-recirculations-default/readme.md +6 -11
  21. package/src/components/kompasid-widget-recirculations-default/types.ts +0 -5
  22. package/src/index.ts +1 -0
  23. package/tailwind/tailwind.css +29 -21
  24. package/tailwind/tailwind.ts +29 -21
package/demo/index.html CHANGED
@@ -54,6 +54,7 @@
54
54
  import '../dist/src/components/kompasid-freewall/KompasFreewall.js'
55
55
  import '../dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js'
56
56
  import '../dist/src/components/kompasid-header-account/KompasHeaderAccount.js'
57
+ import '../dist/src/components/kompasid-grace-period/KompasGracePeriod.js'
57
58
 
58
59
  const type = 'reguler'
59
60
  const theme = ''
@@ -111,19 +112,13 @@
111
112
  }
112
113
 
113
114
  const widgetRelatedPost = {
114
- navigation: {
115
- name: 'Artikel Terkait',
116
- permalink: undefined
117
- },
118
115
  permalinkArticle: 'https://www.kompas.id/baca/opini/2024/05/02/pesan-bung-karno-jaga-persatuan-dan-keutuhan?open_from=Section_Artikel_Lainnya',
119
116
  slugs: 'persatuan,bung-karno, surat pembaca, eduard lukman, bharoto, wira hardiprakoso, vision'
120
117
  }
121
118
 
122
119
  const widgetOtherPost = {
123
- navigation: {
124
- name: 'Lainnya Dalam Opini',
125
- permalink: '/kategori/opini'
126
- }
120
+ titleName: 'Lainnya Dalam Opini',
121
+ titleLink: '/kategori/opini'
127
122
  }
128
123
 
129
124
  render(
@@ -142,13 +137,13 @@
142
137
  ></kompasid-header-account>
143
138
 
144
139
  <kompasid-widget-recirculations-default
145
- .navigation=${widgetRelatedPost.navigation}
146
140
  .permalinkArticle=${widgetRelatedPost.permalinkArticle}
147
141
  .slugs=${widgetRelatedPost.slugs}
148
142
  ></kompasid-widget-recirculations-default>
149
143
 
150
144
  <kompasid-widget-recirculations-default
151
- .navigation=${widgetOtherPost.navigation}
145
+ .titleName=${widgetOtherPost.titleName}
146
+ .titleLink=${widgetOtherPost.titleLink}
152
147
  type='otherArticle'
153
148
  mainCategory='opini'
154
149
  ></kompasid-widget-recirculations-default>
@@ -250,6 +245,8 @@
250
245
  .tracker_metered_wall_balance=${trackerMeteredWallBalance}
251
246
  .tracker_page_domain=${trackerPageDomain}
252
247
  ></kompasid-metered-wall-register>
248
+
249
+ <!-- <kompasid-grace-period totalGracePeriod="5" subscriptionId="9802032"></kompasid-grace-period> -->
253
250
  `,
254
251
  document.querySelector('#demo')
255
252
  )
@@ -0,0 +1,29 @@
1
+ import { LitElement } from 'lit';
2
+ export declare class KompasGracePeriod extends LitElement {
3
+ static styles: import("lit").CSSResult[];
4
+ /**
5
+ * Props
6
+ */
7
+ /**
8
+ * property totalGracePeriod = how many days are left in grace period
9
+ * property isColumn = changes how the component looks on different screen sizes
10
+ * property isShowButton = shows or hides a subscription button
11
+ * property subscriptionId = used for renewal subs
12
+ */
13
+ totalGracePeriod: number;
14
+ isColumn: boolean;
15
+ isShowButton: boolean;
16
+ subscriptionId: string;
17
+ /**
18
+ * State
19
+ */
20
+ private maxGracePeriod;
21
+ private updateSubscription;
22
+ private getCountdownGracePeriod;
23
+ private redirectToBerlangganan;
24
+ private dataLayeronPerbaruiLanggananButton;
25
+ private dataLayeronGracePeriod;
26
+ private gracePeriodTemplate;
27
+ connectedCallback(): Promise<void>;
28
+ render(): import("lit").TemplateResult<1>;
29
+ }
@@ -0,0 +1,146 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, css, nothing } from 'lit';
3
+ import { customElement, property, state } from 'lit/decorators.js';
4
+ import { deviceType } from '../../utils/deviceType.js';
5
+ import { TWStyles } from '../../../tailwind/tailwind.js';
6
+ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ /**
10
+ * Props
11
+ */
12
+ /**
13
+ * property totalGracePeriod = how many days are left in grace period
14
+ * property isColumn = changes how the component looks on different screen sizes
15
+ * property isShowButton = shows or hides a subscription button
16
+ * property subscriptionId = used for renewal subs
17
+ */
18
+ this.totalGracePeriod = 0;
19
+ this.isColumn = false;
20
+ this.isShowButton = false;
21
+ this.subscriptionId = '';
22
+ /**
23
+ * State
24
+ */
25
+ this.maxGracePeriod = 7;
26
+ this.updateSubscription = 'https://checkoutv2.kompas.id';
27
+ }
28
+ getCountdownGracePeriod() {
29
+ const { totalGracePeriod } = this;
30
+ const { maxGracePeriod } = this;
31
+ if (totalGracePeriod === 7) {
32
+ return html `
33
+ <p>
34
+ Anda dalam <b class="text-orange-500"> hari terakhir</b> masa tenggang
35
+ langganan. Segera perbarui paket langganan untuk tetap mengakses
36
+ konten premium tanpa batas.
37
+ </p>
38
+ `;
39
+ }
40
+ return html `
41
+ <p>
42
+ Masa tenggang langganan Anda tersisa
43
+ <b class="text-orange-500"
44
+ >${maxGracePeriod - totalGracePeriod + 1} hari lagi</b
45
+ >. Segera perbarui paket langganan untuk tetap mengakses konten premium
46
+ tanpa batas.
47
+ </p>
48
+ `;
49
+ }
50
+ redirectToBerlangganan() {
51
+ this.dataLayeronPerbaruiLanggananButton();
52
+ window.open(`${this.updateSubscription}/kdp?productId=${this.subscriptionId}`);
53
+ }
54
+ dataLayeronPerbaruiLanggananButton() {
55
+ window.dataLayer.push({
56
+ event: 'gracePeriodClick',
57
+ interface: deviceType(),
58
+ dayLeft: this.maxGracePeriod - this.totalGracePeriod,
59
+ urlName: window.location.href,
60
+ });
61
+ }
62
+ dataLayeronGracePeriod() {
63
+ window.dataLayer.push({
64
+ event: 'gracePeriodImpression',
65
+ interface: deviceType(),
66
+ dayLeft: this.maxGracePeriod - this.totalGracePeriod,
67
+ urlName: window.location.href,
68
+ });
69
+ }
70
+ gracePeriodTemplate() {
71
+ return html `
72
+ <div
73
+ class="${this.isColumn
74
+ ? 'rounded-lg'
75
+ : 'md:flex-row lg:px-8'} flex flex-col w-full justify-end py-4 md:space-x-4 px-4 bottom-0 max-w-7xl mx-auto"
76
+ >
77
+ <div class="text-grey-600 text-sm md:text-base self-center text-left">
78
+ ${this.getCountdownGracePeriod()}
79
+ </div>
80
+ ${!this.isShowButton
81
+ ? html `
82
+ <div
83
+ class="flex self-center w-full md:w-1/2 justify-end pt-4 md:pt-0"
84
+ >
85
+ <button
86
+ @click=${this.redirectToBerlangganan}
87
+ class="bg-green-500 p-2 px-5 rounded-md font-bold text-grey-100 text-sm md:text-base w-full md:w-auto"
88
+ >
89
+ Perbarui Langganan
90
+ </button>
91
+ </div>
92
+ `
93
+ : nothing}
94
+ </div>
95
+ `;
96
+ }
97
+ async connectedCallback() {
98
+ super.connectedCallback();
99
+ this.dataLayeronGracePeriod();
100
+ }
101
+ render() {
102
+ return html `
103
+ <div class="sticky bottom-0 w-full h-full bg-orange-100">
104
+ ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}
105
+ </div>
106
+ `;
107
+ }
108
+ };
109
+ KompasGracePeriod.styles = [
110
+ css `
111
+ :host {
112
+ font-family: 'PT Sans', sans-serif;
113
+ }
114
+
115
+ .body {
116
+ position: sticky;
117
+ top: 0;
118
+ height: 100%;
119
+ width: 100%;
120
+ }
121
+ `,
122
+ TWStyles,
123
+ ];
124
+ __decorate([
125
+ property({ type: Number })
126
+ ], KompasGracePeriod.prototype, "totalGracePeriod", void 0);
127
+ __decorate([
128
+ property({ type: Boolean })
129
+ ], KompasGracePeriod.prototype, "isColumn", void 0);
130
+ __decorate([
131
+ property({ type: Boolean })
132
+ ], KompasGracePeriod.prototype, "isShowButton", void 0);
133
+ __decorate([
134
+ property({ type: String })
135
+ ], KompasGracePeriod.prototype, "subscriptionId", void 0);
136
+ __decorate([
137
+ state()
138
+ ], KompasGracePeriod.prototype, "maxGracePeriod", void 0);
139
+ __decorate([
140
+ state()
141
+ ], KompasGracePeriod.prototype, "updateSubscription", void 0);
142
+ KompasGracePeriod = __decorate([
143
+ customElement('kompasid-grace-period')
144
+ ], KompasGracePeriod);
145
+ export { KompasGracePeriod };
146
+ //# sourceMappingURL=KompasGracePeriod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KompasGracePeriod.js","sourceRoot":"","sources":["../../../../src/components/kompasid-grace-period/KompasGracePeriod.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAGjD,IAAM,iB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,CAAC,IAAI;SAC9B,CAAC,CAAA;IACJ,CAAC;IAEO,mBAAmB;QACzB,OAAO,IAAI,CAAA;;iBAEE,IAAI,CAAC,QAAQ;YACpB,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,qBAAqB;;;YAGrB,IAAI,CAAC,uBAAuB,EAAE;;UAEhC,CAAC,IAAI,CAAC,YAAY;YAClB,CAAC,CAAC,IAAI,CAAA;;;;;2BAKW,IAAI,CAAC,sBAAsB;;;;;;aAMzC;YACH,CAAC,CAAC,OAAO;;KAEd,CAAA;IACH,CAAC;IAEQ,KAAK,CAAC,iBAAiB;QAC9B,KAAK,CAAC,iBAAiB,EAAE,CAAA;QACzB,IAAI,CAAC,sBAAsB,EAAE,CAAA;IAC/B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,CAAC,OAAO;;KAErE,CAAA;IACH,CAAC;;AA5HM,wBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;KAWF;IACD,QAAQ;CACT,CAAA;AAY2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAqB;AACnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAiB;AAChB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAqB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAoB;AAKtC;IAAR,KAAK,EAAE;yDAA2B;AAC1B;IAAR,KAAK,EAAE;6DAA4D;AApCzD,iBAAiB;IAD7B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,iBAAiB,CA8H7B;SA9HY,iBAAiB","sourcesContent":["import { LitElement, html, css, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { deviceType } from '../../utils/deviceType.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\n@customElement('kompasid-grace-period')\nexport class KompasGracePeriod extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property totalGracePeriod = how many days are left in grace period\n * property isColumn = changes how the component looks on different screen sizes\n * property isShowButton = shows or hides a subscription button\n * property subscriptionId = used for renewal subs\n */\n\n @property({ type: Number }) totalGracePeriod = 0\n @property({ type: Boolean }) isColumn = false\n @property({ type: Boolean }) isShowButton = false\n @property({ type: String }) subscriptionId = ''\n\n /**\n * State\n */\n @state() private maxGracePeriod = 7\n @state() private updateSubscription = 'https://checkoutv2.kompas.id'\n\n private getCountdownGracePeriod() {\n const { totalGracePeriod } = this\n const { maxGracePeriod } = this\n if (totalGracePeriod === 7) {\n return html`\n <p>\n Anda dalam <b class=\"text-orange-500\"> hari terakhir</b> masa tenggang\n langganan. Segera perbarui paket langganan untuk tetap mengakses\n konten premium tanpa batas.\n </p>\n `\n }\n return html`\n <p>\n Masa tenggang langganan Anda tersisa\n <b class=\"text-orange-500\"\n >${maxGracePeriod - totalGracePeriod + 1} hari lagi</b\n >. Segera perbarui paket langganan untuk tetap mengakses konten premium\n tanpa batas.\n </p>\n `\n }\n\n private redirectToBerlangganan(): void {\n this.dataLayeronPerbaruiLanggananButton()\n window.open(\n `${this.updateSubscription}/kdp?productId=${this.subscriptionId}`\n )\n }\n\n private dataLayeronPerbaruiLanggananButton(): void {\n window.dataLayer.push({\n event: 'gracePeriodClick',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private dataLayeronGracePeriod(): void {\n window.dataLayer.push({\n event: 'gracePeriodImpression',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private gracePeriodTemplate() {\n return html`\n <div\n class=\"${this.isColumn\n ? 'rounded-lg'\n : 'md:flex-row lg:px-8'} flex flex-col w-full justify-end py-4 md:space-x-4 px-4 bottom-0 max-w-7xl mx-auto\"\n >\n <div class=\"text-grey-600 text-sm md:text-base self-center text-left\">\n ${this.getCountdownGracePeriod()}\n </div>\n ${!this.isShowButton\n ? html`\n <div\n class=\"flex self-center w-full md:w-1/2 justify-end pt-4 md:pt-0\"\n >\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-green-500 p-2 px-5 rounded-md font-bold text-grey-100 text-sm md:text-base w-full md:w-auto\"\n >\n Perbarui Langganan\n </button>\n </div>\n `\n : nothing}\n </div>\n `\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n this.dataLayeronGracePeriod()\n }\n\n render() {\n return html`\n <div class=\"sticky bottom-0 w-full h-full bg-orange-100\">\n ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}\n </div>\n `\n }\n}\n"]}
@@ -1,22 +1,19 @@
1
1
  import { LitElement } from 'lit';
2
- import { Post, Navigation } from './types.js';
2
+ import { Post } from './types.js';
3
3
  export declare class KompasWidgetRecirculationsDefault extends LitElement {
4
4
  static styles: import("lit").CSSResult[];
5
5
  /**
6
6
  * Props
7
7
  */
8
8
  posts: Post[][];
9
- navigation: Navigation | undefined;
10
9
  accessToken: string;
11
10
  permalinkArticle: string;
12
11
  userGuid: string;
13
12
  slugs: string;
14
13
  type: 'relatedArticle' | 'otherArticle';
15
14
  mainCategory: string;
16
- /**
17
- * Getters
18
- */
19
- get navigationPermalink(): string | undefined;
15
+ titleName: string;
16
+ titleLink: string;
20
17
  /**
21
18
  * Fetch Data
22
19
  */
@@ -32,7 +29,8 @@ export declare class KompasWidgetRecirculationsDefault extends LitElement {
32
29
  /**
33
30
  * Render widget components
34
31
  */
35
- private WidgetTitle;
32
+ private titleRelatedArticle;
33
+ private titleOtherArticle;
36
34
  renderChips(post: Post): import("lit").TemplateResult<1>[];
37
35
  renderImage(post: Post): import("lit").TemplateResult<1> | "";
38
36
  render(): import("lit").TemplateResult<1>;
@@ -11,20 +11,14 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
11
11
  * Props
12
12
  */
13
13
  this.posts = [];
14
- this.navigation = undefined;
15
14
  this.accessToken = '';
16
15
  this.permalinkArticle = '';
17
16
  this.userGuid = '0';
18
17
  this.slugs = '';
19
18
  this.type = 'relatedArticle';
20
19
  this.mainCategory = '';
21
- }
22
- /**
23
- * Getters
24
- */
25
- get navigationPermalink() {
26
- var _a;
27
- return (_a = this.navigation) === null || _a === void 0 ? void 0 : _a.permalink;
20
+ this.titleName = ''; // contoh: Artikel Terkait / Lainnya dalam 'kategori'
21
+ this.titleLink = ''; // contoh: /kategori/opini
28
22
  }
29
23
  /**
30
24
  * Fetch Data
@@ -133,40 +127,29 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
133
127
  /**
134
128
  * Render widget components
135
129
  */
136
- WidgetTitle() {
137
- var _a, _b;
138
- if (this.navigationPermalink) {
139
- return html `
140
- <a
141
- href="${this.navigationPermalink}"
142
- class="flex font-sans uppercase items-start mb-6 mt-8"
143
- >
144
- <h5
145
- class="${[
146
- 'capitalize font-bold font-sans',
147
- this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
148
- ].join(' ')}"
149
- >
150
- ${(_a = this.navigation) === null || _a === void 0 ? void 0 : _a.name}
151
- </h5>
152
- </a>
153
- `;
154
- }
130
+ titleRelatedArticle() {
155
131
  return html `
156
132
  <div class="flex font-sans uppercase items-start mb-6 mt-8">
157
133
  <div>
158
- <h5
159
- class="${[
160
- 'capitalize font-bold font-sans',
161
- this.navigationPermalink ? 'text-brand-1' : 'text-grey-600',
162
- ].join(' ')}"
163
- >
164
- ${(_b = this.navigation) === null || _b === void 0 ? void 0 : _b.name}
134
+ <h5 class="capitalize font-bold font-sans text-grey-600">
135
+ Artikel Terkait
165
136
  </h5>
166
137
  </div>
167
138
  </div>
168
139
  `;
169
140
  }
141
+ titleOtherArticle() {
142
+ return html `
143
+ <a
144
+ href="${this.titleLink}"
145
+ class="flex font-sans uppercase items-start mb-6 mt-8"
146
+ >
147
+ <h5 class="capitalize font-bold font-sans text-brand-1">
148
+ ${this.titleName}
149
+ </h5>
150
+ </a>
151
+ `;
152
+ }
170
153
  renderChips(post) {
171
154
  var _a, _b;
172
155
  const chips = [];
@@ -223,7 +206,9 @@ let KompasWidgetRecirculationsDefault = class KompasWidgetRecirculationsDefault
223
206
  return html `
224
207
  <div class="w-full">
225
208
  <!-- start: widget title -->
226
- ${this.WidgetTitle()}
209
+ ${this.type === 'relatedArticle'
210
+ ? this.titleRelatedArticle()
211
+ : this.titleOtherArticle()}
227
212
  <!-- end: widget title -->
228
213
 
229
214
  <div class="grid grid-cols-1 md:grid-cols-2 gap-6 md:gap-8">
@@ -312,9 +297,6 @@ KompasWidgetRecirculationsDefault.styles = [
312
297
  __decorate([
313
298
  property({ type: Array })
314
299
  ], KompasWidgetRecirculationsDefault.prototype, "posts", void 0);
315
- __decorate([
316
- property({ type: Object })
317
- ], KompasWidgetRecirculationsDefault.prototype, "navigation", void 0);
318
300
  __decorate([
319
301
  property({ type: String })
320
302
  ], KompasWidgetRecirculationsDefault.prototype, "accessToken", void 0);
@@ -333,6 +315,12 @@ __decorate([
333
315
  __decorate([
334
316
  property({ type: String })
335
317
  ], KompasWidgetRecirculationsDefault.prototype, "mainCategory", void 0);
318
+ __decorate([
319
+ property({ type: String })
320
+ ], KompasWidgetRecirculationsDefault.prototype, "titleName", void 0);
321
+ __decorate([
322
+ property({ type: String })
323
+ ], KompasWidgetRecirculationsDefault.prototype, "titleLink", void 0);
336
324
  KompasWidgetRecirculationsDefault = __decorate([
337
325
  customElement('kompasid-widget-recirculations-default')
338
326
  ], KompasWidgetRecirculationsDefault);
@@ -1 +1 @@
1
- {"version":3,"file":"KompasWidgetRecirculationsDefault.js","sourceRoot":"","sources":["../../../../src/components/komp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AE,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"]}
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,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;QACjB,cAAS,GAAG,EAAE,CAAA,CAAC,qDAAqD;QACpE,cAAS,GAAG,EAAE,CAAA,CAAC,0BAA0B;IA4RvE,CAAC;IA1RC;;OAEG;IACH,KAAK,CAAC,iBAAiB;QACrB,KAAK,CAAC,iBAAiB,EAAE,CAAA;QACzB,IAAI;YACF,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAA;YAC7B,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB,EAAE;gBAClC,MAAM,IAAI,CAAC,eAAe,EAAE,CAAA;aAC7B;iBAAM,IAAI,IAAI,CAAC,IAAI,KAAK,cAAc,EAAE;gBACvC,MAAM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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;AAnC/B,iCAAiC;IAD7C,aAAa,CAAC,wCAAwC,CAAC;GAC3C,iCAAiC,CA+T7C;SA/TY,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 } 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: 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 /**\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 titleRelatedArticle() {\n return html`\n <div class=\"flex font-sans uppercase items-start mb-6 mt-8\">\n <div>\n <h5 class=\"capitalize font-bold font-sans text-grey-600\">\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 class=\"capitalize font-bold font-sans text-brand-1\">\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 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.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-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"]}
@@ -20,8 +20,4 @@ export interface Post {
20
20
  };
21
21
  };
22
22
  }
23
- export interface Navigation {
24
- name: string;
25
- permalink: string;
26
- }
27
23
  export {};
@@ -1 +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"]}
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"]}
@@ -7,6 +7,7 @@ export { KompasMeteredPaywall } from './components/kompasid-metered-paywall/Komp
7
7
  export { KompasFreewall } from './components/kompasid-freewall/KompasFreewall.js';
8
8
  export { KompasMeteredWallRegister } from './components/kompasid-metered-wall-register/KompasMeteredWallRegister.js';
9
9
  export { KompasHeaderAccount } from './components/kompasid-header-account/KompasHeaderAccount.js';
10
+ export { KompasGracePeriod } from './components/kompasid-grace-period/KompasGracePeriod.js';
10
11
  declare global {
11
12
  interface Window {
12
13
  gtag: (...args: any[]) => void;
package/dist/src/index.js CHANGED
@@ -7,4 +7,5 @@ export { KompasMeteredPaywall } from './components/kompasid-metered-paywall/Komp
7
7
  export { KompasFreewall } from './components/kompasid-freewall/KompasFreewall.js';
8
8
  export { KompasMeteredWallRegister } from './components/kompasid-metered-wall-register/KompasMeteredWallRegister.js';
9
9
  export { KompasHeaderAccount } from './components/kompasid-header-account/KompasHeaderAccount.js';
10
+ export { KompasGracePeriod } from './components/kompasid-grace-period/KompasGracePeriod.js';
10
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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"]}
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;AACjG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yDAAyD,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'\nexport { KompasGracePeriod } from './components/kompasid-grace-period/KompasGracePeriod.js'\n\ndeclare global {\n interface Window {\n gtag: (...args: any[]) => void\n dataLayer: Record<string, any>\n }\n}\n"]}
@@ -983,14 +983,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
983
983
  width: 100%;
984
984
  }
985
985
 
986
- .w-\\[165px\\] {
987
- width: 165px;
988
- }
989
-
990
- .min-w-\\[165px\\] {
991
- min-width: 165px;
992
- }
993
-
994
986
  .max-w-7xl {
995
987
  max-width: 80rem;
996
988
  }
@@ -1011,10 +1003,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1011
1003
  max-width: 20rem;
1012
1004
  }
1013
1005
 
1014
- .max-w-\\[165px\\] {
1015
- max-width: 165px;
1016
- }
1017
-
1018
1006
  .flex-none {
1019
1007
  flex: none;
1020
1008
  }
@@ -1483,6 +1471,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1483
1471
  padding-right: 1rem;
1484
1472
  }
1485
1473
 
1474
+ .px-5 {
1475
+ padding-left: 1.25rem;
1476
+ padding-right: 1.25rem;
1477
+ }
1478
+
1486
1479
  .px-8 {
1487
1480
  padding-left: 2rem;
1488
1481
  padding-right: 2rem;
@@ -1533,11 +1526,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
1533
1526
  padding-bottom: 5.6px;
1534
1527
  }
1535
1528
 
1536
- .px-5 {
1537
- padding-left: 1.25rem;
1538
- padding-right: 1.25rem;
1539
- }
1540
-
1541
1529
  .pb-1 {
1542
1530
  padding-bottom: 0.25rem;
1543
1531
  }
@@ -2030,6 +2018,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2030
2018
  width: 13rem;
2031
2019
  }
2032
2020
 
2021
+ .md\\:w-\\[165px\\] {
2022
+ width: 165px;
2023
+ }
2024
+
2033
2025
  .md\\:w-\\[350px\\] {
2034
2026
  width: 350px;
2035
2027
  }
@@ -2058,10 +2050,6 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2058
2050
  width: auto;
2059
2051
  }
2060
2052
 
2061
- .md\\:w-\\[165px\\] {
2062
- width: 165px;
2063
- }
2064
-
2065
2053
  .md\\:max-w-\\[137px\\] {
2066
2054
  max-width: 137px;
2067
2055
  }
@@ -2126,6 +2114,12 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2126
2114
  margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
2127
2115
  }
2128
2116
 
2117
+ .md\\:space-x-4 > :not([hidden]) ~ :not([hidden]) {
2118
+ --tw-space-x-reverse: 0;
2119
+ margin-right: calc(1rem * var(--tw-space-x-reverse));
2120
+ margin-left: calc(1rem * calc(1 - var(--tw-space-x-reverse)));
2121
+ }
2122
+
2129
2123
  .md\\:space-x-5 > :not([hidden]) ~ :not([hidden]) {
2130
2124
  --tw-space-x-reverse: 0;
2131
2125
  margin-right: calc(1.25rem * var(--tw-space-x-reverse));
@@ -2226,6 +2220,10 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2226
2220
  padding-bottom: 1.75rem;
2227
2221
  }
2228
2222
 
2223
+ .md\\:pt-0 {
2224
+ padding-top: 0px;
2225
+ }
2226
+
2229
2227
  .md\\:pt-3 {
2230
2228
  padding-top: 0.75rem;
2231
2229
  }
@@ -2389,6 +2387,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2389
2387
  padding-right: 0px;
2390
2388
  }
2391
2389
 
2390
+ .lg\\:px-20 {
2391
+ padding-left: 5rem;
2392
+ padding-right: 5rem;
2393
+ }
2394
+
2392
2395
  .lg\\:px-24 {
2393
2396
  padding-left: 6rem;
2394
2397
  padding-right: 6rem;
@@ -2399,6 +2402,11 @@ Constrain images and videos to the parent width and preserve their intrinsic asp
2399
2402
  padding-bottom: 2.5rem;
2400
2403
  }
2401
2404
 
2405
+ .lg\\:px-8 {
2406
+ padding-left: 2rem;
2407
+ padding-right: 2rem;
2408
+ }
2409
+
2402
2410
  .lg\\:pb-0 {
2403
2411
  padding-bottom: 0px;
2404
2412
  }