@telia-ace/alliance-ui 1.0.15 → 1.0.16-next.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.
- package/CHANGELOG.md +15 -0
- package/components/alliance-link.js +2 -2
- package/components/alliance-modal.js +3 -3
- package/components/alliance-paginator.js +3 -3
- package/components/alliance-pop-over.d.ts +2 -0
- package/components/alliance-pop-over.js +5 -0
- package/components/alliance-pop-over.js.map +1 -0
- package/components/alliance-table.js +3 -3
- package/components/alliance-view.js +43 -99
- package/components/alliance-view.js.map +1 -1
- package/components/chunk-2PC6L5RK.js +115 -0
- package/components/chunk-2PC6L5RK.js.map +1 -0
- package/components/{chunk-ADFC4JKF.js → chunk-4546RD56.js} +162 -198
- package/components/chunk-4546RD56.js.map +1 -0
- package/components/{chunk-B6YHD7BN.js → chunk-5A2VXG2P.js} +1 -1
- package/components/chunk-5A2VXG2P.js.map +1 -0
- package/components/chunk-AW7BCYX5.js +22 -0
- package/components/chunk-AW7BCYX5.js.map +1 -0
- package/components/{chunk-LYU2K33W.js → chunk-CZPHL6EU.js} +109 -226
- package/components/chunk-CZPHL6EU.js.map +1 -0
- package/components/chunk-IFHLWFVT.js +133 -0
- package/components/chunk-IFHLWFVT.js.map +1 -0
- package/components/{chunk-XPHFAKEI.js → chunk-MA6NFT5S.js} +21 -64
- package/components/chunk-MA6NFT5S.js.map +1 -0
- package/components/index.js +7 -6
- package/package.json +4 -3
- package/voca/foundations/index.js +3 -4
- package/voca/foundations/index.js.map +1 -1
- package/components/chunk-ADFC4JKF.js.map +0 -1
- package/components/chunk-B6YHD7BN.js.map +0 -1
- package/components/chunk-LYU2K33W.js.map +0 -1
- package/components/chunk-NB6ODBZJ.js +0 -13
- package/components/chunk-NB6ODBZJ.js.map +0 -1
- package/components/chunk-WYQTL7R3.js +0 -167
- package/components/chunk-WYQTL7R3.js.map +0 -1
- package/components/chunk-XPHFAKEI.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { spacing, borders, colors, motion, focus, breakpoints } from './chunk-
|
|
2
|
-
import {
|
|
1
|
+
import { spacing, borders, colors, motion, focus, breakpoints } from './chunk-5A2VXG2P.js';
|
|
2
|
+
import { __decorateClass, define } from './chunk-AW7BCYX5.js';
|
|
3
3
|
import { LitElement, css, unsafeCSS, html } from 'lit';
|
|
4
4
|
import { property, state } from 'lit/decorators.js';
|
|
5
5
|
import { repeat } from 'lit/directives/repeat.js';
|
|
@@ -8,28 +8,21 @@ import { chevronLeft, chevronRight } from '@teliads/components/icons';
|
|
|
8
8
|
|
|
9
9
|
// src/components/alliance-paginator/utils.ts
|
|
10
10
|
var DOTS = "...";
|
|
11
|
-
var range =
|
|
11
|
+
var range = (start, end) => {
|
|
12
12
|
const length = end - start + 1;
|
|
13
|
-
return Array.from({
|
|
14
|
-
|
|
15
|
-
}, (_, idx) => idx + start);
|
|
16
|
-
}, "range");
|
|
13
|
+
return Array.from({ length }, (_, idx) => idx + start);
|
|
14
|
+
};
|
|
17
15
|
function getLastPage(pages) {
|
|
18
16
|
return pages[pages.length - 1];
|
|
19
17
|
}
|
|
20
|
-
__name(getLastPage, "getLastPage");
|
|
21
18
|
function listPages(lastPage) {
|
|
22
|
-
return Array.from({
|
|
23
|
-
length: lastPage
|
|
24
|
-
}, (_, i) => {
|
|
19
|
+
return Array.from({ length: lastPage }, (_, i) => {
|
|
25
20
|
return pageToSelectValue(i + 1, lastPage);
|
|
26
21
|
});
|
|
27
22
|
}
|
|
28
|
-
__name(listPages, "listPages");
|
|
29
23
|
function pageToSelectValue(page, lastPage) {
|
|
30
24
|
return `${page} / ${lastPage}`;
|
|
31
25
|
}
|
|
32
|
-
__name(pageToSelectValue, "pageToSelectValue");
|
|
33
26
|
function selectValueToPage(selectValue) {
|
|
34
27
|
const value = selectValue.split("/")[0];
|
|
35
28
|
if (typeof value !== "string") {
|
|
@@ -37,7 +30,6 @@ function selectValueToPage(selectValue) {
|
|
|
37
30
|
}
|
|
38
31
|
return parseInt(value);
|
|
39
32
|
}
|
|
40
|
-
__name(selectValueToPage, "selectValueToPage");
|
|
41
33
|
function getPagination({ itemCount, pageSize, siblingCount, currentPage }) {
|
|
42
34
|
const totalPageCount = Math.ceil(itemCount / pageSize);
|
|
43
35
|
const totalPageNumbers = siblingCount + 5;
|
|
@@ -53,62 +45,39 @@ function getPagination({ itemCount, pageSize, siblingCount, currentPage }) {
|
|
|
53
45
|
if (!shouldShowLeftDots && shouldShowRightDots) {
|
|
54
46
|
const leftItemCount = 3 + 2 * siblingCount;
|
|
55
47
|
const leftRange = range(1, leftItemCount);
|
|
56
|
-
return [
|
|
57
|
-
...leftRange,
|
|
58
|
-
DOTS,
|
|
59
|
-
totalPageCount
|
|
60
|
-
];
|
|
48
|
+
return [...leftRange, DOTS, totalPageCount];
|
|
61
49
|
}
|
|
62
50
|
if (shouldShowLeftDots && !shouldShowRightDots) {
|
|
63
51
|
const rightItemCount = 3 + 2 * siblingCount;
|
|
64
52
|
const rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);
|
|
65
|
-
return [
|
|
66
|
-
firstPageIndex,
|
|
67
|
-
DOTS,
|
|
68
|
-
...rightRange
|
|
69
|
-
];
|
|
53
|
+
return [firstPageIndex, DOTS, ...rightRange];
|
|
70
54
|
}
|
|
71
55
|
if (shouldShowLeftDots && shouldShowRightDots) {
|
|
72
56
|
const middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
73
|
-
return [
|
|
74
|
-
firstPageIndex,
|
|
75
|
-
DOTS,
|
|
76
|
-
...middleRange,
|
|
77
|
-
DOTS,
|
|
78
|
-
lastPageIndex
|
|
79
|
-
];
|
|
57
|
+
return [firstPageIndex, DOTS, ...middleRange, DOTS, lastPageIndex];
|
|
80
58
|
}
|
|
81
59
|
return range(1, totalPageCount);
|
|
82
60
|
}
|
|
83
|
-
__name(getPagination, "getPagination");
|
|
84
61
|
|
|
85
62
|
// src/components/alliance-paginator/alliance-page-selector.ts
|
|
86
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
87
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
88
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
89
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
90
|
-
else
|
|
91
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
92
|
-
if (d = decorators[i])
|
|
93
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
94
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
95
|
-
}
|
|
96
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
97
|
-
function _ts_metadata(k, v) {
|
|
98
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
99
|
-
return Reflect.metadata(k, v);
|
|
100
|
-
}
|
|
101
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
102
63
|
var PageSelect = class extends LitElement {
|
|
103
|
-
static {
|
|
104
|
-
__name(this, "PageSelect");
|
|
105
|
-
}
|
|
106
64
|
constructor() {
|
|
107
65
|
super();
|
|
66
|
+
this.onChange = (e) => {
|
|
67
|
+
const nextPage = selectValueToPage(e.currentTarget.value);
|
|
68
|
+
const event = new CustomEvent("select-page", {
|
|
69
|
+
bubbles: true,
|
|
70
|
+
composed: true,
|
|
71
|
+
detail: { nextPage, previousPage: this.currentPage },
|
|
72
|
+
cancelable: true
|
|
73
|
+
});
|
|
74
|
+
this.dispatchEvent(event);
|
|
75
|
+
};
|
|
108
76
|
this.currentPage = 0;
|
|
109
77
|
this.lastPage = 0;
|
|
110
78
|
}
|
|
111
|
-
static
|
|
79
|
+
static {
|
|
80
|
+
this.styles = css`
|
|
112
81
|
:host select {
|
|
113
82
|
padding: ${unsafeCSS(spacing.spacing16)} ${unsafeCSS(spacing.spacing24)};
|
|
114
83
|
border-radius: ${unsafeCSS(borders.radiusFull)};
|
|
@@ -157,19 +126,7 @@ var PageSelect = class extends LitElement {
|
|
|
157
126
|
outline-offset: ${unsafeCSS(spacing.spacing4)};
|
|
158
127
|
}
|
|
159
128
|
`;
|
|
160
|
-
|
|
161
|
-
const nextPage = selectValueToPage(e.currentTarget.value);
|
|
162
|
-
const event = new CustomEvent("select-page", {
|
|
163
|
-
bubbles: true,
|
|
164
|
-
composed: true,
|
|
165
|
-
detail: {
|
|
166
|
-
nextPage,
|
|
167
|
-
previousPage: this.currentPage
|
|
168
|
-
},
|
|
169
|
-
cancelable: true
|
|
170
|
-
});
|
|
171
|
-
this.dispatchEvent(event);
|
|
172
|
-
};
|
|
129
|
+
}
|
|
173
130
|
render() {
|
|
174
131
|
return html`
|
|
175
132
|
<select
|
|
@@ -177,50 +134,56 @@ var PageSelect = class extends LitElement {
|
|
|
177
134
|
@change=${this.onChange}
|
|
178
135
|
.value=${pageToSelectValue(this.currentPage, this.lastPage)}
|
|
179
136
|
>
|
|
180
|
-
${repeat(
|
|
137
|
+
${repeat(
|
|
138
|
+
listPages(this.lastPage),
|
|
139
|
+
(page) => html`<option value="${page}">${page}</option>`
|
|
140
|
+
)}
|
|
181
141
|
</select>
|
|
182
142
|
`;
|
|
183
143
|
}
|
|
184
144
|
};
|
|
185
|
-
|
|
186
|
-
property({
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
})
|
|
190
|
-
|
|
191
|
-
], PageSelect.prototype, "currentPage", void 0);
|
|
192
|
-
_ts_decorate([
|
|
193
|
-
property({
|
|
194
|
-
type: Number,
|
|
195
|
-
attribute: "last-page"
|
|
196
|
-
}),
|
|
197
|
-
_ts_metadata("design:type", Number)
|
|
198
|
-
], PageSelect.prototype, "lastPage", void 0);
|
|
145
|
+
__decorateClass([
|
|
146
|
+
property({ type: Number, attribute: "current-page" })
|
|
147
|
+
], PageSelect.prototype, "currentPage", 2);
|
|
148
|
+
__decorateClass([
|
|
149
|
+
property({ type: Number, attribute: "last-page" })
|
|
150
|
+
], PageSelect.prototype, "lastPage", 2);
|
|
199
151
|
define("alliance-page-selector", PageSelect);
|
|
200
152
|
|
|
201
153
|
// src/components/alliance-paginator/alliance-paginator.ts
|
|
202
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
203
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
204
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
205
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
206
|
-
else
|
|
207
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
208
|
-
if (d = decorators[i])
|
|
209
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
210
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
211
|
-
}
|
|
212
|
-
__name(_ts_decorate2, "_ts_decorate");
|
|
213
|
-
function _ts_metadata2(k, v) {
|
|
214
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
215
|
-
return Reflect.metadata(k, v);
|
|
216
|
-
}
|
|
217
|
-
__name(_ts_metadata2, "_ts_metadata");
|
|
218
154
|
var Paginator = class extends LitElement {
|
|
219
|
-
static {
|
|
220
|
-
__name(this, "Paginator");
|
|
221
|
-
}
|
|
222
155
|
constructor() {
|
|
223
156
|
super();
|
|
157
|
+
this.changePage = (nextPage) => {
|
|
158
|
+
if (nextPage === this.currentPage || // Next page is the same
|
|
159
|
+
nextPage < 1 || // Next page is 0
|
|
160
|
+
nextPage > this.pages[this.pages.length - 1]) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const event = new CustomEvent("change-page", {
|
|
164
|
+
bubbles: true,
|
|
165
|
+
composed: true,
|
|
166
|
+
detail: { nextPage, previousPage: this.currentPage },
|
|
167
|
+
cancelable: true
|
|
168
|
+
});
|
|
169
|
+
const defaultNotPrevented = this.dispatchEvent(event);
|
|
170
|
+
if (defaultNotPrevented) {
|
|
171
|
+
this.currentPage = nextPage;
|
|
172
|
+
this.pages = getPagination({
|
|
173
|
+
itemCount: this.itemCount,
|
|
174
|
+
pageSize: this.pageSize,
|
|
175
|
+
siblingCount: this.siblingCount,
|
|
176
|
+
currentPage: this.currentPage
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
this.next = () => {
|
|
181
|
+
this.changePage(this.currentPage + 1);
|
|
182
|
+
};
|
|
183
|
+
this.previous = () => {
|
|
184
|
+
this.changePage(this.currentPage - 1);
|
|
185
|
+
};
|
|
186
|
+
this.onPageSelect = (event) => this.changePage(event.detail.nextPage);
|
|
224
187
|
this.itemCount = 0;
|
|
225
188
|
this.pageSize = 50;
|
|
226
189
|
this.initialPage = 1;
|
|
@@ -228,7 +191,8 @@ var Paginator = class extends LitElement {
|
|
|
228
191
|
this.currentPage = this.initialPage;
|
|
229
192
|
this.pages = [];
|
|
230
193
|
}
|
|
231
|
-
static
|
|
194
|
+
static {
|
|
195
|
+
this.styles = css`
|
|
232
196
|
:host {
|
|
233
197
|
display: flex;
|
|
234
198
|
flex-direction: row;
|
|
@@ -263,6 +227,7 @@ var Paginator = class extends LitElement {
|
|
|
263
227
|
}
|
|
264
228
|
}
|
|
265
229
|
`;
|
|
230
|
+
}
|
|
266
231
|
connectedCallback() {
|
|
267
232
|
super.connectedCallback();
|
|
268
233
|
this.currentPage = this.initialPage;
|
|
@@ -286,39 +251,6 @@ var Paginator = class extends LitElement {
|
|
|
286
251
|
[name]: value
|
|
287
252
|
});
|
|
288
253
|
}
|
|
289
|
-
changePage = (nextPage) => {
|
|
290
|
-
if (nextPage === this.currentPage || // Next page is the same
|
|
291
|
-
nextPage < 1 || // Next page is 0
|
|
292
|
-
nextPage > this.pages[this.pages.length - 1]) {
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
const event = new CustomEvent("change-page", {
|
|
296
|
-
bubbles: true,
|
|
297
|
-
composed: true,
|
|
298
|
-
detail: {
|
|
299
|
-
nextPage,
|
|
300
|
-
previousPage: this.currentPage
|
|
301
|
-
},
|
|
302
|
-
cancelable: true
|
|
303
|
-
});
|
|
304
|
-
const defaultNotPrevented = this.dispatchEvent(event);
|
|
305
|
-
if (defaultNotPrevented) {
|
|
306
|
-
this.currentPage = nextPage;
|
|
307
|
-
this.pages = getPagination({
|
|
308
|
-
itemCount: this.itemCount,
|
|
309
|
-
pageSize: this.pageSize,
|
|
310
|
-
siblingCount: this.siblingCount,
|
|
311
|
-
currentPage: this.currentPage
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
next = () => {
|
|
316
|
-
this.changePage(this.currentPage + 1);
|
|
317
|
-
};
|
|
318
|
-
previous = () => {
|
|
319
|
-
this.changePage(this.currentPage - 1);
|
|
320
|
-
};
|
|
321
|
-
onPageSelect = (event) => this.changePage(event.detail.nextPage);
|
|
322
254
|
render() {
|
|
323
255
|
return html`
|
|
324
256
|
<alliance-paginator-button
|
|
@@ -327,11 +259,14 @@ var Paginator = class extends LitElement {
|
|
|
327
259
|
icon="left"
|
|
328
260
|
></alliance-paginator-button>
|
|
329
261
|
|
|
330
|
-
${repeat(
|
|
262
|
+
${repeat(
|
|
263
|
+
this.pages,
|
|
264
|
+
(pageNumber) => pageNumber === "..." ? html`<telia-label>...</telia-label>` : html`<alliance-paginator-button
|
|
331
265
|
page=${pageNumber}
|
|
332
266
|
@click=${() => this.changePage(pageNumber)}
|
|
333
267
|
?selected=${this.currentPage === pageNumber}
|
|
334
|
-
></alliance-paginator-button>`
|
|
268
|
+
></alliance-paginator-button>`
|
|
269
|
+
)}
|
|
335
270
|
|
|
336
271
|
<alliance-page-selector
|
|
337
272
|
current-page=${this.currentPage}
|
|
@@ -348,68 +283,31 @@ var Paginator = class extends LitElement {
|
|
|
348
283
|
`;
|
|
349
284
|
}
|
|
350
285
|
};
|
|
351
|
-
|
|
352
|
-
property({
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
})
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}),
|
|
370
|
-
_ts_metadata2("design:type", Number)
|
|
371
|
-
], Paginator.prototype, "initialPage", void 0);
|
|
372
|
-
_ts_decorate2([
|
|
373
|
-
property({
|
|
374
|
-
type: Number,
|
|
375
|
-
attribute: "sibling-count"
|
|
376
|
-
}),
|
|
377
|
-
_ts_metadata2("design:type", Number)
|
|
378
|
-
], Paginator.prototype, "siblingCount", void 0);
|
|
379
|
-
_ts_decorate2([
|
|
380
|
-
state(),
|
|
381
|
-
_ts_metadata2("design:type", Number)
|
|
382
|
-
], Paginator.prototype, "currentPage", void 0);
|
|
383
|
-
_ts_decorate2([
|
|
384
|
-
state(),
|
|
385
|
-
_ts_metadata2("design:type", typeof Pages === "undefined" ? Object : Pages)
|
|
386
|
-
], Paginator.prototype, "pages", void 0);
|
|
286
|
+
__decorateClass([
|
|
287
|
+
property({ type: Number, attribute: "item-count" })
|
|
288
|
+
], Paginator.prototype, "itemCount", 2);
|
|
289
|
+
__decorateClass([
|
|
290
|
+
property({ type: Number, attribute: "page-size" })
|
|
291
|
+
], Paginator.prototype, "pageSize", 2);
|
|
292
|
+
__decorateClass([
|
|
293
|
+
property({ type: Number, attribute: "initial-page" })
|
|
294
|
+
], Paginator.prototype, "initialPage", 2);
|
|
295
|
+
__decorateClass([
|
|
296
|
+
property({ type: Number, attribute: "sibling-count" })
|
|
297
|
+
], Paginator.prototype, "siblingCount", 2);
|
|
298
|
+
__decorateClass([
|
|
299
|
+
state()
|
|
300
|
+
], Paginator.prototype, "currentPage", 2);
|
|
301
|
+
__decorateClass([
|
|
302
|
+
state()
|
|
303
|
+
], Paginator.prototype, "pages", 2);
|
|
387
304
|
define("alliance-paginator", Paginator);
|
|
388
|
-
|
|
389
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
390
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
391
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
392
|
-
else
|
|
393
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
394
|
-
if (d = decorators[i])
|
|
395
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
396
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
397
|
-
}
|
|
398
|
-
__name(_ts_decorate3, "_ts_decorate");
|
|
399
|
-
function _ts_metadata3(k, v) {
|
|
400
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
401
|
-
return Reflect.metadata(k, v);
|
|
402
|
-
}
|
|
403
|
-
__name(_ts_metadata3, "_ts_metadata");
|
|
404
|
-
var Icon;
|
|
405
|
-
(function(Icon2) {
|
|
305
|
+
var Icon = /* @__PURE__ */ ((Icon2) => {
|
|
406
306
|
Icon2["Left"] = "left";
|
|
407
307
|
Icon2["Right"] = "right";
|
|
408
|
-
|
|
308
|
+
return Icon2;
|
|
309
|
+
})(Icon || {});
|
|
409
310
|
var PaginatorButton = class extends LitElement {
|
|
410
|
-
static {
|
|
411
|
-
__name(this, "PaginatorButton");
|
|
412
|
-
}
|
|
413
311
|
constructor() {
|
|
414
312
|
super();
|
|
415
313
|
this.selected = false;
|
|
@@ -417,10 +315,10 @@ var PaginatorButton = class extends LitElement {
|
|
|
417
315
|
this.clickable = true;
|
|
418
316
|
}
|
|
419
317
|
renderContent() {
|
|
420
|
-
if (this.icon === "left") {
|
|
318
|
+
if (this.icon === "left" /* Left */) {
|
|
421
319
|
return html`<telia-icon size="sm" svg="${chevronLeft.svg}" />`;
|
|
422
320
|
}
|
|
423
|
-
if (this.icon === "right") {
|
|
321
|
+
if (this.icon === "right" /* Right */) {
|
|
424
322
|
return html`<telia-icon size="sm" svg="${chevronRight.svg}" />`;
|
|
425
323
|
}
|
|
426
324
|
return html`<span>${this.page}</span>`;
|
|
@@ -429,36 +327,21 @@ var PaginatorButton = class extends LitElement {
|
|
|
429
327
|
return html`<telia-button ?disabled=${this.disabled} variant=${this.selected ? "primary" : "tertiary-purple"}>${this.renderContent()}</telia-button> `;
|
|
430
328
|
}
|
|
431
329
|
};
|
|
432
|
-
|
|
433
|
-
property({
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
], PaginatorButton.prototype, "
|
|
438
|
-
|
|
439
|
-
property({
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
], PaginatorButton.prototype, "
|
|
444
|
-
|
|
445
|
-
property({
|
|
446
|
-
|
|
447
|
-
}),
|
|
448
|
-
_ts_metadata3("design:type", Boolean)
|
|
449
|
-
], PaginatorButton.prototype, "selected", void 0);
|
|
450
|
-
_ts_decorate3([
|
|
451
|
-
property({
|
|
452
|
-
type: Boolean
|
|
453
|
-
}),
|
|
454
|
-
_ts_metadata3("design:type", Boolean)
|
|
455
|
-
], PaginatorButton.prototype, "disabled", void 0);
|
|
456
|
-
_ts_decorate3([
|
|
457
|
-
property({
|
|
458
|
-
type: Boolean
|
|
459
|
-
}),
|
|
460
|
-
_ts_metadata3("design:type", Boolean)
|
|
461
|
-
], PaginatorButton.prototype, "clickable", void 0);
|
|
330
|
+
__decorateClass([
|
|
331
|
+
property({ type: Icon })
|
|
332
|
+
], PaginatorButton.prototype, "icon", 2);
|
|
333
|
+
__decorateClass([
|
|
334
|
+
property({ type: String })
|
|
335
|
+
], PaginatorButton.prototype, "page", 2);
|
|
336
|
+
__decorateClass([
|
|
337
|
+
property({ type: Boolean })
|
|
338
|
+
], PaginatorButton.prototype, "selected", 2);
|
|
339
|
+
__decorateClass([
|
|
340
|
+
property({ type: Boolean })
|
|
341
|
+
], PaginatorButton.prototype, "disabled", 2);
|
|
342
|
+
__decorateClass([
|
|
343
|
+
property({ type: Boolean })
|
|
344
|
+
], PaginatorButton.prototype, "clickable", 2);
|
|
462
345
|
define("alliance-paginator-button", PaginatorButton);
|
|
463
346
|
//# sourceMappingURL=out.js.map
|
|
464
|
-
//# sourceMappingURL=chunk-
|
|
347
|
+
//# sourceMappingURL=chunk-CZPHL6EU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/alliance-paginator/alliance-page-selector.ts","../src/components/alliance-paginator/utils.ts","../src/components/alliance-paginator/alliance-paginator.ts","../src/voca/components/telia-label.ts","../src/components/alliance-paginator/alliance-paginator-button.ts"],"names":["LitElement","css","html","unsafeCSS","property","repeat","Icon"],"mappings":";;;;;;;;;;;;;;AAAA,SAAS,YAAY,KAAK,MAAM,iBAAiB;AACjD,SAAS,gBAAgB;AACzB,SAAS,cAAc;;;ACCvB,IAAM,OAAO;AAEb,IAAM,QAAQ,CAAC,OAAe,QAAgB;AAC1C,QAAM,SAAS,MAAM,QAAQ;AAK7B,SAAO,MAAM,KAAK,EAAE,OAAO,GAAG,CAAC,GAAG,QAAQ,MAAM,KAAK;AACzD;AAWO,SAAS,YAAY,OAAsB;AAC9C,SAAO,MAAM,MAAM,SAAS,CAAC;AACjC;AAEO,SAAS,UAAU,UAA4B;AAClD,SAAO,MAAM,KAAK,EAAE,QAAQ,SAAS,GAAG,CAAC,GAAG,MAAM;AAC9C,WAAO,kBAAkB,IAAI,GAAG,QAAQ;AAAA,EAC5C,CAAC;AACL;AAEO,SAAS,kBAAkB,MAAc,UAA0B;AACtE,SAAO,GAAG,IAAI,MAAM,QAAQ;AAChC;AAEO,SAAS,kBAAkB,aAA6B;AAC3D,QAAM,QAAQ,YAAY,MAAM,GAAG,EAAE,CAAC;AAEtC,MAAI,OAAO,UAAU,UAAU;AAC3B,UAAM,IAAI,MAAM,yCAAyC;AAAA,EAC7D;AAEA,SAAO,SAAS,KAAK;AACzB;AAEO,SAAS,cAAc,EAAE,WAAW,UAAU,cAAc,YAAY,GAAgB;AAC3F,QAAM,iBAAiB,KAAK,KAAK,YAAY,QAAQ;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,WAAW,YAAY,iBAAiB,IAAI,KAAK,cAAc,CAAC;AAAA,EACxI;AACJ;AArCY;AAAA,EADPE,UAAS,EAAE,MAAM,KAAK,CAAC;AAAA,GAPf,gBAQD;AAGA;AAAA,EADPA,UAAS,EAAE,MAAM,OAAO,CAAC;AAAA,GAVjB,gBAWD;AAGA;AAAA,EADPA,UAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GAblB,gBAcD;AAGA;AAAA,EADPA,UAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GAhBlB,gBAiBD;AAGA;AAAA,EADPA,UAAS,EAAE,MAAM,QAAQ,CAAC;AAAA,GAnBlB,gBAoBD;AA2BZ,OAAO,6BAA6B,eAAe","sourcesContent":["import { LitElement, css, html, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\n\nimport { define } from '@/utils';\nimport '@/voca/components/telia-button';\nimport { borders, colors, focus, motion, spacing } from '@/voca/foundations';\n\nimport { listPages, pageToSelectValue, selectValueToPage } from './utils';\n\n/**\n * Event dispatched when selecting a page.\n *\n * Event: `change-page`\n *\n * Detail: Object containing the properties `nextPage` and `previousPage`.\n */\nexport type SelectPageEvent = CustomEvent<{ nextPage: number; previousPage: number }>;\n\nexport class PageSelect extends LitElement {\n constructor() {\n super();\n this.currentPage = 0;\n this.lastPage = 0;\n }\n static styles = css`\n :host select {\n padding: ${unsafeCSS(spacing.spacing16)} ${unsafeCSS(spacing.spacing24)};\n border-radius: ${unsafeCSS(borders.radiusFull)};\n border: ${unsafeCSS(borders.widthXs)} solid ${unsafeCSS(colors.purple850)};\n background-color: transparent;\n color: ${unsafeCSS(colors.purple850)};\n text-align: center;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n display: inline-flex;\n font-family: 'TeliaSans', Helvetica, Arial, 'Lucida Grande', sans-serif;\n font-size: ${unsafeCSS(spacing.spacing16)};\n line-height: ${unsafeCSS(spacing.spacing16)};\n transition:\n color ${unsafeCSS(motion.duration150)} ease,\n background-color ${unsafeCSS(motion.duration150)} ease;\n\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n outline: none;\n }\n\n :host select:hover {\n background-color: ${unsafeCSS(colors.purple850)};\n color: ${unsafeCSS(colors.white)};\n }\n\n :host select:active {\n background-color: ${unsafeCSS(colors.purple700)};\n }\n\n :host select option {\n background-color: ${unsafeCSS(colors.white)};\n color: ${unsafeCSS(colors.black)};\n text-align: center;\n }\n\n :host select::-ms-expand {\n display: none;\n }\n\n :host select:focus-visible {\n outline: solid ${unsafeCSS(focus.focusBorderWidth)} ${unsafeCSS(focus.focusColor)};\n outline-offset: ${unsafeCSS(spacing.spacing4)};\n }\n `;\n\n @property({ type: Number, attribute: 'current-page' })\n declare currentPage: number;\n\n @property({ type: Number, attribute: 'last-page' })\n declare lastPage: number;\n\n onChange = (\n e: Event & {\n currentTarget: HTMLSelectElement;\n },\n ) => {\n const nextPage = selectValueToPage(e.currentTarget.value);\n\n const event: SelectPageEvent = new CustomEvent('select-page', {\n bubbles: true,\n composed: true,\n detail: { nextPage, previousPage: this.currentPage },\n cancelable: true,\n });\n this.dispatchEvent(event);\n };\n\n render() {\n return html`\n <select\n id=\"select\"\n @change=${this.onChange}\n .value=${pageToSelectValue(this.currentPage, this.lastPage)}\n >\n ${repeat(\n listPages(this.lastPage),\n (page) => html`<option value=\"${page}\">${page}</option>`,\n )}\n </select>\n `;\n }\n}\n\ndefine('alliance-page-selector', PageSelect);\n","/* \n Pagination logic taken from https://www.freecodecamp.org/news/build-a-custom-pagination-component-in-react/\n*/\nconst DOTS = '...';\n\nconst range = (start: number, end: number) => {\n const length = end - start + 1;\n /*\n Create an array of certain length and set the elements within it from\n start value to end value.\n */\n return Array.from({ length }, (_, idx) => idx + start);\n};\n\ntype Args = {\n itemCount: number;\n pageSize: number;\n siblingCount: number;\n currentPage: number;\n};\n\nexport type Pages = (number | '...')[];\n\nexport function getLastPage(pages: Pages): number {\n return pages[pages.length - 1] as number;\n}\n\nexport function listPages(lastPage: number): string[] {\n return Array.from({ length: lastPage }, (_, i) => {\n return pageToSelectValue(i + 1, lastPage);\n });\n}\n\nexport function pageToSelectValue(page: number, lastPage: number): string {\n return `${page} / ${lastPage}`;\n}\n\nexport function selectValueToPage(selectValue: string): number {\n const value = selectValue.split('/')[0];\n\n if (typeof value !== 'string') {\n throw new Error('Could not parse page value from select.');\n }\n\n return parseInt(value);\n}\n\nexport function getPagination({ itemCount, pageSize, siblingCount, currentPage }: Args): Pages {\n const totalPageCount = Math.ceil(itemCount / pageSize);\n\n // Pages count is determined as siblingCount + firstPage + lastPage + currentPage + 2*DOTS\n const totalPageNumbers = siblingCount + 5;\n\n /*\n Case 1:\n If the number of pages is less than the page numbers we want to show in our\n paginationComponent, we return the range [1..totalPageCount]\n */\n if (totalPageNumbers >= totalPageCount) {\n return range(1, totalPageCount);\n }\n\n /*\n Calculate left and right sibling index and make sure they are within range 1 and totalPageCount\n */\n const leftSiblingIndex = Math.max(currentPage - siblingCount, 1);\n const rightSiblingIndex = Math.min(currentPage + siblingCount, totalPageCount);\n\n /*\n We do not show dots just when there is just one page number to be inserted between the extremes of sibling and the page limits i.e 1 and totalPageCount. Hence we are using leftSiblingIndex > 2 and rightSiblingIndex < totalPageCount - 2\n */\n const shouldShowLeftDots = leftSiblingIndex > 2;\n const shouldShowRightDots = rightSiblingIndex < totalPageCount - 2;\n\n const firstPageIndex = 1;\n const lastPageIndex = totalPageCount;\n\n /*\n Case 2: No left dots to show, but rights dots to be shown\n */\n if (!shouldShowLeftDots && shouldShowRightDots) {\n const leftItemCount = 3 + 2 * siblingCount;\n const leftRange = range(1, leftItemCount);\n\n return [...leftRange, DOTS, totalPageCount];\n }\n\n /*\n Case 3: No right dots to show, but left dots to be shown\n */\n if (shouldShowLeftDots && !shouldShowRightDots) {\n const rightItemCount = 3 + 2 * siblingCount;\n const rightRange = range(totalPageCount - rightItemCount + 1, totalPageCount);\n return [firstPageIndex, DOTS, ...rightRange];\n }\n\n /*\n Case 4: Both left and right dots to be shown\n */\n if (shouldShowLeftDots && shouldShowRightDots) {\n const middleRange = range(leftSiblingIndex, rightSiblingIndex);\n return [firstPageIndex, DOTS, ...middleRange, DOTS, lastPageIndex];\n }\n\n return range(1, totalPageCount);\n}\n","import { LitElement, css, html, unsafeCSS } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\n\nimport { define } from '@/utils';\nimport '@/voca/components/telia-button';\nimport '@/voca/components/telia-label';\nimport { breakpoints, colors, spacing } from '@/voca/foundations';\n\nimport type { SelectPageEvent } from './alliance-page-selector';\nimport { type Pages, getLastPage, getPagination } from './utils';\n\n/**\n * Event dispatched when pressing a page button.\n *\n * Event: `change-page`\n *\n * Detail: Object containing the properties `nextPage` and `previousPage`.\n */\nexport type ChangePageEvent = CustomEvent<{ nextPage: number; previousPage: number }>;\n\nexport class Paginator extends LitElement {\n constructor() {\n super();\n this.itemCount = 0;\n this.pageSize = 50;\n this.initialPage = 1;\n this.siblingCount = 2;\n this.currentPage = this.initialPage;\n this.pages = [];\n }\n static styles = css`\n :host {\n display: flex;\n flex-direction: row;\n place-items: center;\n gap: ${unsafeCSS(spacing.spacing8)};\n }\n\n :host telia-label {\n display: none;\n }\n\n :host .telia-label {\n color: ${unsafeCSS(colors.purple700)};\n }\n\n :host alliance-paginator-button[page] {\n display: none;\n }\n\n span {\n display: block;\n }\n\n @container (min-width: ${unsafeCSS(breakpoints.breakpointLg)}) {\n :host telia-label,\n :host alliance-paginator-button[page] {\n display: block;\n }\n\n :host alliance-page-selector {\n display: none;\n }\n }\n `;\n\n connectedCallback() {\n super.connectedCallback();\n\n this.currentPage = this.initialPage;\n this.pages = getPagination({\n itemCount: this.itemCount,\n pageSize: this.pageSize,\n siblingCount: this.siblingCount,\n currentPage: this.currentPage,\n });\n }\n\n attributeChangedCallback(name: string, _: string | null, value: string | null) {\n super.attributeChangedCallback(name, _, value);\n\n if (name === 'initial-page') {\n this.currentPage = this.initialPage;\n }\n\n this.pages = getPagination({\n itemCount: this.itemCount,\n pageSize: this.pageSize,\n siblingCount: this.siblingCount,\n currentPage: this.currentPage,\n [name]: value,\n });\n }\n\n @property({ type: Number, attribute: 'item-count' })\n declare itemCount: number;\n\n @property({ type: Number, attribute: 'page-size' })\n declare pageSize: number;\n\n @property({ type: Number, attribute: 'initial-page' })\n declare initialPage: number;\n\n @property({ type: Number, attribute: 'sibling-count' })\n declare siblingCount: number;\n\n @state()\n declare currentPage: number;\n\n @state()\n declare pages: Pages;\n\n changePage = (nextPage: number) => {\n if (\n nextPage === this.currentPage || // Next page is the same\n nextPage < 1 || // Next page is 0\n nextPage > (this.pages[this.pages.length - 1] as number) // Next page is outside of available pages\n ) {\n return;\n }\n\n const event: ChangePageEvent = new CustomEvent('change-page', {\n bubbles: true,\n composed: true,\n detail: { nextPage, previousPage: this.currentPage },\n cancelable: true,\n });\n const defaultNotPrevented = this.dispatchEvent(event);\n\n if (defaultNotPrevented) {\n this.currentPage = nextPage;\n\n this.pages = getPagination({\n itemCount: this.itemCount,\n pageSize: this.pageSize,\n siblingCount: this.siblingCount,\n currentPage: this.currentPage,\n });\n }\n };\n\n next = () => {\n this.changePage(this.currentPage + 1);\n };\n\n previous = () => {\n this.changePage(this.currentPage - 1);\n };\n\n onPageSelect = (event: SelectPageEvent) => this.changePage(event.detail.nextPage);\n\n render() {\n return html`\n <alliance-paginator-button\n @click=${this.previous}\n ?disabled=${this.currentPage === 1}\n icon=\"left\"\n ></alliance-paginator-button>\n\n ${repeat(this.pages, (pageNumber) =>\n pageNumber === '...'\n ? html`<telia-label>...</telia-label>`\n : html`<alliance-paginator-button\n page=${pageNumber}\n @click=${() => this.changePage(pageNumber)}\n ?selected=${this.currentPage === pageNumber}\n ></alliance-paginator-button>`,\n )}\n\n <alliance-page-selector\n current-page=${this.currentPage}\n last-page=${getLastPage(this.pages)}\n @select-page=${this.onPageSelect}\n >\n </alliance-page-selector>\n\n <alliance-paginator-button\n @click=${this.next}\n ?disabled=${this.currentPage === getLastPage(this.pages)}\n icon=\"right\"\n ></alliance-paginator-button>\n `;\n }\n}\n\ndefine('alliance-paginator', Paginator);\n","// This file is generated - see scripts/map-voca-components.js\nimport '@teliads/components/dist/components/telia-label';\n","import { chevronLeft, chevronRight } from '@teliads/components/icons';\nimport { LitElement, html } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { define } from '@/utils';\nimport '@/voca/components/telia-button';\nimport '@/voca/components/telia-icon';\n\nenum Icon {\n Left = 'left',\n Right = 'right',\n}\n\nexport class PaginatorButton extends LitElement {\n constructor() {\n super();\n this.selected = false;\n this.disabled = false;\n this.clickable = true;\n }\n @property({ type: Icon })\n declare icon?: Icon;\n\n @property({ type: String })\n declare page?: string;\n\n @property({ type: Boolean })\n declare selected: boolean;\n\n @property({ type: Boolean })\n declare disabled: boolean;\n\n @property({ type: Boolean })\n declare clickable: boolean;\n\n private renderContent() {\n if (this.icon === Icon.Left) {\n return html`<telia-icon size=\"sm\" svg=\"${chevronLeft.svg}\" />`;\n }\n\n if (this.icon === Icon.Right) {\n return html`<telia-icon size=\"sm\" svg=\"${chevronRight.svg}\" />`;\n }\n\n return html`<span>${this.page}</span>`;\n }\n\n render() {\n /*\n Ignore prettier on next line because Voca \n uses textContent on the telia-button element\n to detect whether or not it only contains an\n icon - which does not take account for white space...\n https://github.com/telia-company/design-system/issues/813\n */\n // prettier-ignore\n return html`<telia-button ?disabled=${this.disabled} variant=${this.selected ? 'primary' : 'tertiary-purple'}>${this.renderContent()}</telia-button> `;\n }\n}\n\ndefine('alliance-paginator-button', PaginatorButton);\n"]}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { layers, borders, colors, shadows, spacing } from './chunk-5A2VXG2P.js';
|
|
2
|
+
import { __decorateClass, define } from './chunk-AW7BCYX5.js';
|
|
3
|
+
import { autoPlacement, computePosition, autoUpdate } from '@floating-ui/dom';
|
|
4
|
+
import { LitElement, css, unsafeCSS, html } from 'lit';
|
|
5
|
+
import { property } from 'lit/decorators.js';
|
|
6
|
+
import '@teliads/components/dist/components/telia-skeleton';
|
|
7
|
+
|
|
8
|
+
// src/components/alliance-pop-over/alliance-pop-over.ts
|
|
9
|
+
var PopOver = class extends LitElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.onWindowClick = (event) => {
|
|
13
|
+
const { target, clientX, clientY } = event;
|
|
14
|
+
if (!this.cursor) {
|
|
15
|
+
this.cursor = { x: clientX, y: clientY };
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!target || target === this || this.contains(target)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (this.anchorElement && (target === this.anchorElement || this.anchorElement.contains(target))) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.remove();
|
|
25
|
+
};
|
|
26
|
+
this.position = () => {
|
|
27
|
+
const middleware = [];
|
|
28
|
+
if (!this.placement) {
|
|
29
|
+
middleware.push(autoPlacement());
|
|
30
|
+
}
|
|
31
|
+
computePosition(this.reference(), this, {
|
|
32
|
+
middleware,
|
|
33
|
+
placement: this.placement
|
|
34
|
+
}).then(({ x, y }) => {
|
|
35
|
+
Object.assign(this.style, {
|
|
36
|
+
left: `${x}px`,
|
|
37
|
+
top: `${y}px`
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
this.reference = () => {
|
|
42
|
+
if (!this.anchorElement && !this.cursor) {
|
|
43
|
+
return virtual({ x: 0, y: 0 });
|
|
44
|
+
}
|
|
45
|
+
return this.anchorElement || virtual(this.cursor);
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
static {
|
|
49
|
+
this.styles = css`
|
|
50
|
+
:host {
|
|
51
|
+
display: block;
|
|
52
|
+
width: max-content;
|
|
53
|
+
position: absolute;
|
|
54
|
+
top: 0;
|
|
55
|
+
left: 0;
|
|
56
|
+
|
|
57
|
+
z-index: ${unsafeCSS(Number(layers.modal) * 2)};
|
|
58
|
+
border: ${unsafeCSS(borders.widthXs)};
|
|
59
|
+
border-radius: ${unsafeCSS(borders.radiusSm)};
|
|
60
|
+
background-color: ${unsafeCSS(colors.white)};
|
|
61
|
+
box-shadow: ${unsafeCSS(shadows.md)};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:host([loading]) {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
padding: ${unsafeCSS(spacing.spacing12)};
|
|
68
|
+
gap: ${unsafeCSS(spacing.spacing12)};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:host([loading]) telia-skeleton {
|
|
72
|
+
height: ${unsafeCSS(spacing.spacing12)};
|
|
73
|
+
width: ${unsafeCSS(spacing.spacing128)};
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
connectedCallback() {
|
|
78
|
+
super.connectedCallback();
|
|
79
|
+
const anchorElement = document.getElementById(this.anchor);
|
|
80
|
+
if (anchorElement) {
|
|
81
|
+
this.anchorElement = anchorElement;
|
|
82
|
+
}
|
|
83
|
+
window.addEventListener("click", this.onWindowClick);
|
|
84
|
+
const cleanup = autoUpdate(this.reference(), this, this.position);
|
|
85
|
+
this.cleanup = () => {
|
|
86
|
+
window.removeEventListener("click", this.onWindowClick);
|
|
87
|
+
cleanup();
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
disconnectedCallback() {
|
|
91
|
+
this.dispatchEvent(new CustomEvent("close"));
|
|
92
|
+
this.cleanup();
|
|
93
|
+
super.disconnectedCallback();
|
|
94
|
+
}
|
|
95
|
+
render() {
|
|
96
|
+
if (this.loading) {
|
|
97
|
+
return html`
|
|
98
|
+
<telia-skeleton round> </telia-skeleton>
|
|
99
|
+
<telia-skeleton round> </telia-skeleton>
|
|
100
|
+
<telia-skeleton round> </telia-skeleton>
|
|
101
|
+
<telia-skeleton round> </telia-skeleton>
|
|
102
|
+
<telia-skeleton round> </telia-skeleton>
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
return html` <slot> </slot> `;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
__decorateClass([
|
|
109
|
+
property({ type: String })
|
|
110
|
+
], PopOver.prototype, "anchor", 2);
|
|
111
|
+
__decorateClass([
|
|
112
|
+
property({ type: String, attribute: true, reflect: true })
|
|
113
|
+
], PopOver.prototype, "placement", 2);
|
|
114
|
+
__decorateClass([
|
|
115
|
+
property({ type: Boolean, attribute: true, reflect: true })
|
|
116
|
+
], PopOver.prototype, "loading", 2);
|
|
117
|
+
define("alliance-pop-over", PopOver);
|
|
118
|
+
function virtual({ x, y }) {
|
|
119
|
+
return {
|
|
120
|
+
getBoundingClientRect: () => ({
|
|
121
|
+
width: 0,
|
|
122
|
+
height: 0,
|
|
123
|
+
x,
|
|
124
|
+
y,
|
|
125
|
+
top: y,
|
|
126
|
+
left: x,
|
|
127
|
+
right: x,
|
|
128
|
+
bottom: y
|
|
129
|
+
})
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=out.js.map
|
|
133
|
+
//# sourceMappingURL=chunk-IFHLWFVT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/alliance-pop-over/alliance-pop-over.ts","../src/voca/components/telia-skeleton.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AAAA,EAGI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AACP,SAAS,YAAY,KAAK,MAAM,iBAAiB;AACjD,SAAS,gBAAgB;;;ACPzB,OAAO;;;ADaA,IAAM,UAAN,cAAsB,WAAW;AAAA,EAAjC;AAAA;AAiEH,SAAQ,gBAAgB,CAAC,UAAsB;AAC3C,YAAM,EAAE,QAAQ,SAAS,QAAQ,IAAI;AAGrC,UAAI,CAAC,KAAK,QAAQ;AACd,aAAK,SAAS,EAAE,GAAG,SAAS,GAAG,QAAQ;AACvC;AAAA,MACJ;AAGA,UAAI,CAAC,UAAU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-ui/dom';\nimport { LitElement, css, html, unsafeCSS } from 'lit';\nimport { property } from 'lit/decorators.js';\n\nimport { define } from '@/utils';\nimport '@/voca/components/telia-skeleton';\nimport { borders, colors, layers, shadows, spacing } from '@/voca/foundations';\n\nexport class PopOver extends LitElement {\n static styles = css`\n :host {\n display: block;\n width: max-content;\n position: absolute;\n top: 0;\n left: 0;\n\n z-index: ${unsafeCSS(Number(layers.modal) * 2)};\n border: ${unsafeCSS(borders.widthXs)};\n border-radius: ${unsafeCSS(borders.radiusSm)};\n background-color: ${unsafeCSS(colors.white)};\n box-shadow: ${unsafeCSS(shadows.md)};\n }\n\n :host([loading]) {\n display: flex;\n flex-direction: column;\n padding: ${unsafeCSS(spacing.spacing12)};\n gap: ${unsafeCSS(spacing.spacing12)};\n }\n\n :host([loading]) telia-skeleton {\n height: ${unsafeCSS(spacing.spacing12)};\n width: ${unsafeCSS(spacing.spacing128)};\n }\n `;\n\n @property({ type: String })\n declare anchor: string;\n\n @property({ type: String, attribute: true, reflect: true })\n declare placement?: Placement;\n\n @property({ type: Boolean, attribute: true, reflect: true })\n declare loading: boolean;\n\n connectedCallback() {\n super.connectedCallback();\n\n const anchorElement = document.getElementById(this.anchor);\n if (anchorElement) {\n this.anchorElement = anchorElement;\n }\n\n window.addEventListener('click', this.onWindowClick);\n\n const cleanup = autoUpdate(this.reference(), this, this.position);\n this.cleanup = () => {\n window.removeEventListener('click', this.onWindowClick);\n cleanup();\n };\n }\n\n disconnectedCallback() {\n this.dispatchEvent(new CustomEvent('close'));\n this.cleanup();\n super.disconnectedCallback();\n }\n\n private declare cleanup: () => void;\n private declare anchorElement: HTMLElement;\n private declare cursor: { x: number; y: number };\n\n private onWindowClick = (event: MouseEvent) => {\n const { target, clientX, clientY } = event;\n\n // First click, only store cursor position\n if (!this.cursor) {\n this.cursor = { x: clientX, y: clientY };\n return;\n }\n\n // Click target is part of popup\n if (!target || target === this || this.contains(target as Node)) {\n return;\n }\n\n // Click target is part of anchor element\n if (\n this.anchorElement &&\n (target === this.anchorElement || this.anchorElement.contains(target as Node))\n ) {\n return;\n }\n\n this.remove();\n };\n\n private position = () => {\n const middleware: Middleware[] = [];\n\n if (!this.placement) {\n middleware.push(autoPlacement());\n }\n\n computePosition(this.reference(), this, {\n middleware,\n placement: this.placement,\n }).then(({ x, y }) => {\n Object.assign(this.style, {\n left: `${x}px`,\n top: `${y}px`,\n });\n });\n };\n\n private reference = () => {\n if (!this.anchorElement && !this.cursor) {\n return virtual({ x: 0, y: 0 });\n }\n\n return this.anchorElement || virtual(this.cursor);\n };\n\n render() {\n if (this.loading) {\n return html`\n <telia-skeleton round> </telia-skeleton>\n <telia-skeleton round> </telia-skeleton>\n <telia-skeleton round> </telia-skeleton>\n <telia-skeleton round> </telia-skeleton>\n <telia-skeleton round> </telia-skeleton>\n `;\n }\n\n return html` <slot> </slot> `;\n }\n}\n\ndefine('alliance-pop-over', PopOver);\n\nfunction virtual({ x, y }: { x: number; y: number }) {\n return {\n getBoundingClientRect: () => ({\n width: 0,\n height: 0,\n x: x,\n y: y,\n top: y,\n left: x,\n right: x,\n bottom: y,\n }),\n };\n}\n","// This file is generated - see scripts/map-voca-components.js\nimport '@teliads/components/dist/components/telia-skeleton';\n"]}
|