@kompasid/lit-web-components 0.8.15 → 0.8.17
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.
- package/demo/index.html +4 -4
- package/dist/src/components/kompasid-header-notification/KompasHeaderNotification.js +19 -15
- package/dist/src/components/kompasid-header-notification/KompasHeaderNotification.js.map +1 -1
- package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js +19 -12
- package/dist/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.js.map +1 -1
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.d.ts +3 -0
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js +29 -9
- package/dist/src/components/kompasid-paywall-body/KompasPaywallBody.js.map +1 -1
- package/dist/src/utils/api/getLoginGuest.d.ts +1 -0
- package/dist/src/utils/api/getLoginGuest.js +18 -0
- package/dist/src/utils/api/getLoginGuest.js.map +1 -0
- package/dist/src/utils/customFetch.d.ts +21 -0
- package/dist/src/utils/customFetch.js +42 -0
- package/dist/src/utils/customFetch.js.map +1 -0
- package/dist/src/utils/ellipsisText.d.ts +8 -0
- package/dist/src/utils/ellipsisText.js +19 -0
- package/dist/src/utils/ellipsisText.js.map +1 -0
- package/dist/src/utils/getCookies.d.ts +1 -0
- package/dist/src/utils/getCookies.js +9 -0
- package/dist/src/utils/getCookies.js.map +1 -0
- package/dist/tailwind/tailwind.js +143 -133
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-header-notification/KompasHeaderNotification.ts +19 -18
- package/src/components/kompasid-header-notification/readme.md +1 -1
- package/src/components/kompasid-metered-wall-register/KompasMeteredWallRegister.ts +19 -12
- package/src/components/kompasid-paywall/readme.md +231 -182
- package/src/components/kompasid-paywall-body/KompasPaywallBody.ts +30 -9
- package/src/utils/api/getLoginGuest.ts +21 -0
- package/src/utils/customFetch.ts +89 -0
- package/src/utils/ellipsisText.ts +26 -0
- package/src/utils/getCookies.ts +8 -0
- package/tailwind/tailwind.css +80 -20
- package/tailwind/tailwind.ts +143 -133
- package/web-dev-server.config.mjs +0 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
/* eslint-disable no-undef */
|
|
3
|
+
// Define types for the API responses
|
|
4
|
+
interface RefreshTokenResponse {
|
|
5
|
+
data: {
|
|
6
|
+
accessToken: string
|
|
7
|
+
deviceKeyId: string
|
|
8
|
+
isVerified: boolean
|
|
9
|
+
refreshToken: string
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface ApiResponse<T> extends Response {
|
|
14
|
+
json(): Promise<T>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface RequestInit {
|
|
18
|
+
method?: string
|
|
19
|
+
headers?: Headers | { [key: string]: string }
|
|
20
|
+
body?: BodyInit | null
|
|
21
|
+
mode?: RequestMode
|
|
22
|
+
credentials?: RequestCredentials
|
|
23
|
+
cache?: RequestCache
|
|
24
|
+
redirect?: RequestRedirect
|
|
25
|
+
referrer?: string
|
|
26
|
+
referrerPolicy?: ReferrerPolicy
|
|
27
|
+
integrity?: string
|
|
28
|
+
keepalive?: boolean
|
|
29
|
+
signal?: AbortSignal
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Function to refresh the token
|
|
33
|
+
async function refreshAccessToken(
|
|
34
|
+
refreshToken: string,
|
|
35
|
+
domain: string
|
|
36
|
+
): Promise<string> {
|
|
37
|
+
const response = await fetch(
|
|
38
|
+
`https://api.kompas.${domain}/account/api/v1/tokens/refresh`,
|
|
39
|
+
{
|
|
40
|
+
method: 'POST',
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
refreshToken,
|
|
43
|
+
}),
|
|
44
|
+
headers: {
|
|
45
|
+
'Content-Type': 'application/json',
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error('Failed to refresh token')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const data: RefreshTokenResponse = await response.json()
|
|
55
|
+
return data.data.accessToken
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Custom fetch function that retries after 401
|
|
59
|
+
export async function customFetch<T>(
|
|
60
|
+
url: string,
|
|
61
|
+
refreshToken: string,
|
|
62
|
+
accessToken: string,
|
|
63
|
+
domain: string,
|
|
64
|
+
options: RequestInit = {}
|
|
65
|
+
): Promise<ApiResponse<T>> {
|
|
66
|
+
try {
|
|
67
|
+
// Retrieve and set access token in headers
|
|
68
|
+
const headers = new Headers(options.headers || {})
|
|
69
|
+
if (accessToken) {
|
|
70
|
+
headers.set('Authorization', `Bearer ${accessToken}`)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Set updated headers
|
|
74
|
+
options.headers = headers
|
|
75
|
+
let response = await fetch(url, options)
|
|
76
|
+
|
|
77
|
+
// Retry request if 401 error occurs
|
|
78
|
+
if (response.status === 401) {
|
|
79
|
+
const newToken = await refreshAccessToken(refreshToken, domain)
|
|
80
|
+
headers.set('Authorization', `Bearer ${newToken}`)
|
|
81
|
+
// Retry the original request with the new token
|
|
82
|
+
response = await fetch(url, { ...options, headers })
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return response as ApiResponse<T>
|
|
86
|
+
} catch (error) {
|
|
87
|
+
throw Error('Error making API call')
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shorten a string to a given length, appending an ellipsis if necessary.
|
|
3
|
+
* @param {string} string The string to be shortened.
|
|
4
|
+
* @param {number} [length=255] The desired length of the output string.
|
|
5
|
+
* @return {string}
|
|
6
|
+
*/
|
|
7
|
+
const ellipsisText = (string: string, length: number = 255): string => {
|
|
8
|
+
const parser = new DOMParser()
|
|
9
|
+
const doc = parser.parseFromString(string, 'text/html')
|
|
10
|
+
|
|
11
|
+
let fullText = doc.body.textContent || ''
|
|
12
|
+
|
|
13
|
+
if (fullText.length <= length) {
|
|
14
|
+
return fullText
|
|
15
|
+
}
|
|
16
|
+
fullText = fullText.substring(0, length - 1)
|
|
17
|
+
|
|
18
|
+
const lastSpace = fullText.lastIndexOf(' ')
|
|
19
|
+
|
|
20
|
+
return `${fullText.substring(
|
|
21
|
+
0,
|
|
22
|
+
Math.sign(lastSpace) > 0 ? lastSpace : length
|
|
23
|
+
)}...`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { ellipsisText }
|
package/tailwind/tailwind.css
CHANGED
|
@@ -713,10 +713,6 @@ video {
|
|
|
713
713
|
margin-left: 0.75rem;
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
-
.ml-4 {
|
|
717
|
-
margin-left: 1rem;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
716
|
.ml-8 {
|
|
721
717
|
margin-left: 2rem;
|
|
722
718
|
}
|
|
@@ -745,6 +741,14 @@ video {
|
|
|
745
741
|
margin-right: 1.5rem;
|
|
746
742
|
}
|
|
747
743
|
|
|
744
|
+
.mt-0 {
|
|
745
|
+
margin-top: 0px;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
.mt-0\.5 {
|
|
749
|
+
margin-top: 0.125rem;
|
|
750
|
+
}
|
|
751
|
+
|
|
748
752
|
.mt-1 {
|
|
749
753
|
margin-top: 0.25rem;
|
|
750
754
|
}
|
|
@@ -801,6 +805,10 @@ video {
|
|
|
801
805
|
height: 3rem;
|
|
802
806
|
}
|
|
803
807
|
|
|
808
|
+
.h-14 {
|
|
809
|
+
height: 3.5rem;
|
|
810
|
+
}
|
|
811
|
+
|
|
804
812
|
.h-16 {
|
|
805
813
|
height: 4rem;
|
|
806
814
|
}
|
|
@@ -845,6 +853,10 @@ video {
|
|
|
845
853
|
height: 17px;
|
|
846
854
|
}
|
|
847
855
|
|
|
856
|
+
.h-\[300px\] {
|
|
857
|
+
height: 300px;
|
|
858
|
+
}
|
|
859
|
+
|
|
848
860
|
.h-\[68px\] {
|
|
849
861
|
height: 68px;
|
|
850
862
|
}
|
|
@@ -874,6 +886,10 @@ video {
|
|
|
874
886
|
width: 33.333333%;
|
|
875
887
|
}
|
|
876
888
|
|
|
889
|
+
.w-1\/4 {
|
|
890
|
+
width: 25%;
|
|
891
|
+
}
|
|
892
|
+
|
|
877
893
|
.w-1\/5 {
|
|
878
894
|
width: 20%;
|
|
879
895
|
}
|
|
@@ -886,6 +902,10 @@ video {
|
|
|
886
902
|
width: 91.666667%;
|
|
887
903
|
}
|
|
888
904
|
|
|
905
|
+
.w-14 {
|
|
906
|
+
width: 3.5rem;
|
|
907
|
+
}
|
|
908
|
+
|
|
889
909
|
.w-16 {
|
|
890
910
|
width: 4rem;
|
|
891
911
|
}
|
|
@@ -1029,6 +1049,16 @@ video {
|
|
|
1029
1049
|
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
|
|
1030
1050
|
}
|
|
1031
1051
|
|
|
1052
|
+
@keyframes spin {
|
|
1053
|
+
to {
|
|
1054
|
+
transform: rotate(360deg);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
.animate-spin {
|
|
1059
|
+
animation: spin 1s linear infinite;
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1032
1062
|
.cursor-pointer {
|
|
1033
1063
|
cursor: pointer;
|
|
1034
1064
|
}
|
|
@@ -1173,6 +1203,10 @@ video {
|
|
|
1173
1203
|
overflow: hidden;
|
|
1174
1204
|
}
|
|
1175
1205
|
|
|
1206
|
+
.overflow-y-scroll {
|
|
1207
|
+
overflow-y: scroll;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1176
1210
|
.truncate {
|
|
1177
1211
|
overflow: hidden;
|
|
1178
1212
|
text-overflow: ellipsis;
|
|
@@ -1183,6 +1217,10 @@ video {
|
|
|
1183
1217
|
white-space: nowrap;
|
|
1184
1218
|
}
|
|
1185
1219
|
|
|
1220
|
+
.break-words {
|
|
1221
|
+
overflow-wrap: break-word;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1186
1224
|
.rounded {
|
|
1187
1225
|
border-radius: 0.25rem;
|
|
1188
1226
|
}
|
|
@@ -1351,6 +1389,11 @@ video {
|
|
|
1351
1389
|
background-color: rgb(46 46 46 / var(--tw-bg-opacity));
|
|
1352
1390
|
}
|
|
1353
1391
|
|
|
1392
|
+
.bg-green-100 {
|
|
1393
|
+
--tw-bg-opacity: 1;
|
|
1394
|
+
background-color: rgb(238 252 210 / var(--tw-bg-opacity));
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1354
1397
|
.bg-green-300 {
|
|
1355
1398
|
--tw-bg-opacity: 1;
|
|
1356
1399
|
background-color: rgb(151 219 83 / var(--tw-bg-opacity));
|
|
@@ -1391,6 +1434,11 @@ video {
|
|
|
1391
1434
|
background-color: rgb(255 238 204 / var(--tw-bg-opacity));
|
|
1392
1435
|
}
|
|
1393
1436
|
|
|
1437
|
+
.bg-red-100 {
|
|
1438
|
+
--tw-bg-opacity: 1;
|
|
1439
|
+
background-color: rgb(254 225 207 / var(--tw-bg-opacity));
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1394
1442
|
.bg-white {
|
|
1395
1443
|
--tw-bg-opacity: 1;
|
|
1396
1444
|
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
|
|
@@ -1443,6 +1491,11 @@ video {
|
|
|
1443
1491
|
padding: 1.5rem;
|
|
1444
1492
|
}
|
|
1445
1493
|
|
|
1494
|
+
.px-0 {
|
|
1495
|
+
padding-left: 0px;
|
|
1496
|
+
padding-right: 0px;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1446
1499
|
.px-2 {
|
|
1447
1500
|
padding-left: 0.5rem;
|
|
1448
1501
|
padding-right: 0.5rem;
|
|
@@ -1488,6 +1541,11 @@ video {
|
|
|
1488
1541
|
padding-bottom: 0.125rem;
|
|
1489
1542
|
}
|
|
1490
1543
|
|
|
1544
|
+
.py-1 {
|
|
1545
|
+
padding-top: 0.25rem;
|
|
1546
|
+
padding-bottom: 0.25rem;
|
|
1547
|
+
}
|
|
1548
|
+
|
|
1491
1549
|
.py-2 {
|
|
1492
1550
|
padding-top: 0.5rem;
|
|
1493
1551
|
padding-bottom: 0.5rem;
|
|
@@ -1573,8 +1631,8 @@ video {
|
|
|
1573
1631
|
padding-left: 1px;
|
|
1574
1632
|
}
|
|
1575
1633
|
|
|
1576
|
-
.pr-
|
|
1577
|
-
padding-right:
|
|
1634
|
+
.pr-1 {
|
|
1635
|
+
padding-right: 0.25rem;
|
|
1578
1636
|
}
|
|
1579
1637
|
|
|
1580
1638
|
.pr-2 {
|
|
@@ -1822,6 +1880,11 @@ video {
|
|
|
1822
1880
|
color: rgb(51 51 51 / var(--tw-text-opacity));
|
|
1823
1881
|
}
|
|
1824
1882
|
|
|
1883
|
+
.text-grey-700 {
|
|
1884
|
+
--tw-text-opacity: 1;
|
|
1885
|
+
color: rgb(0 0 0 / var(--tw-text-opacity));
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1825
1888
|
.text-orange-400 {
|
|
1826
1889
|
--tw-text-opacity: 1;
|
|
1827
1890
|
color: rgb(255 122 0 / var(--tw-text-opacity));
|
|
@@ -1832,6 +1895,11 @@ video {
|
|
|
1832
1895
|
color: rgb(219 93 0 / var(--tw-text-opacity));
|
|
1833
1896
|
}
|
|
1834
1897
|
|
|
1898
|
+
.text-red-600 {
|
|
1899
|
+
--tw-text-opacity: 1;
|
|
1900
|
+
color: rgb(174 9 27 / var(--tw-text-opacity));
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1835
1903
|
.text-white {
|
|
1836
1904
|
--tw-text-opacity: 1;
|
|
1837
1905
|
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
@@ -1930,8 +1998,8 @@ video {
|
|
|
1930
1998
|
margin-right: 1.25rem;
|
|
1931
1999
|
}
|
|
1932
2000
|
|
|
1933
|
-
.md\:
|
|
1934
|
-
margin-
|
|
2001
|
+
.md\:mr-6 {
|
|
2002
|
+
margin-right: 1.5rem;
|
|
1935
2003
|
}
|
|
1936
2004
|
|
|
1937
2005
|
.md\:mt-2 {
|
|
@@ -2011,10 +2079,6 @@ video {
|
|
|
2011
2079
|
width: 13rem;
|
|
2012
2080
|
}
|
|
2013
2081
|
|
|
2014
|
-
.md\:w-\[165px\] {
|
|
2015
|
-
width: 165px;
|
|
2016
|
-
}
|
|
2017
|
-
|
|
2018
2082
|
.md\:w-\[350px\] {
|
|
2019
2083
|
width: 350px;
|
|
2020
2084
|
}
|
|
@@ -2055,6 +2119,10 @@ video {
|
|
|
2055
2119
|
max-width: 464px;
|
|
2056
2120
|
}
|
|
2057
2121
|
|
|
2122
|
+
.md\:max-w-\[737px\] {
|
|
2123
|
+
max-width: 737px;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2058
2126
|
.md\:max-w-full {
|
|
2059
2127
|
max-width: 100%;
|
|
2060
2128
|
}
|
|
@@ -2091,10 +2159,6 @@ video {
|
|
|
2091
2159
|
justify-content: center;
|
|
2092
2160
|
}
|
|
2093
2161
|
|
|
2094
|
-
.md\:gap-2 {
|
|
2095
|
-
gap: 0.5rem;
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
2162
|
.md\:gap-8 {
|
|
2099
2163
|
gap: 2rem;
|
|
2100
2164
|
}
|
|
@@ -2149,10 +2213,6 @@ video {
|
|
|
2149
2213
|
align-self: flex-end;
|
|
2150
2214
|
}
|
|
2151
2215
|
|
|
2152
|
-
.md\:self-center {
|
|
2153
|
-
align-self: center;
|
|
2154
|
-
}
|
|
2155
|
-
|
|
2156
2216
|
.md\:rounded {
|
|
2157
2217
|
border-radius: 0.25rem;
|
|
2158
2218
|
}
|