scb-wc-test 0.1.71 → 0.1.72
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/all.js +2 -0
- package/index.d.ts +1 -0
- package/index.js +42 -40
- package/mvc/components/all.js +1 -0
- package/mvc/components/scb-pagination/scb-pagination.js +175 -0
- package/package.json +6 -2
- package/scb-pagination/scb-pagination.d.ts +18 -0
- package/scb-pagination/scb-pagination.js +264 -0
- package/scb-wc-test.bundle.js +490 -316
package/all.js
CHANGED
|
@@ -43,6 +43,7 @@ import './mvc/components/scb-menu/scb-menu.js';
|
|
|
43
43
|
import './mvc/components/scb-menu/scb-sub-menu.js';
|
|
44
44
|
import './mvc/components/scb-notification/scb-notification.js';
|
|
45
45
|
import './mvc/components/scb-notification-card/scb-notification-card.js';
|
|
46
|
+
import './mvc/components/scb-pagination/scb-pagination.js';
|
|
46
47
|
import './mvc/components/scb-progress-indicator/scb-progress-indicator.js';
|
|
47
48
|
import './mvc/components/scb-radio-button/scb-radio-button.js';
|
|
48
49
|
import './mvc/components/scb-radio-button/scb-radio-group.js';
|
|
@@ -105,6 +106,7 @@ import './scb-menu/scb-menu.js';
|
|
|
105
106
|
import './scb-menu/scb-sub-menu.js';
|
|
106
107
|
import './scb-notification/scb-notification.js';
|
|
107
108
|
import './scb-notification-card/scb-notification-card.js';
|
|
109
|
+
import './scb-pagination/scb-pagination.js';
|
|
108
110
|
import './scb-progress-indicator/scb-progress-indicator.js';
|
|
109
111
|
import './scb-radio-button/scb-radio-button.js';
|
|
110
112
|
import './scb-radio-button/scb-radio-group.js';
|
package/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from './scb-menu/scb-menu';
|
|
|
40
40
|
export * from './scb-menu/scb-sub-menu';
|
|
41
41
|
export * from './scb-notification/scb-notification';
|
|
42
42
|
export * from './scb-notification-card/scb-notification-card';
|
|
43
|
+
export * from './scb-pagination/scb-pagination';
|
|
43
44
|
export * from './scb-progress-indicator/scb-progress-indicator';
|
|
44
45
|
export * from './scb-radio-button/scb-radio-button';
|
|
45
46
|
export * from './scb-radio-button/scb-radio-group';
|
package/index.js
CHANGED
|
@@ -8,13 +8,13 @@ import { SCBBreadcrumb as n } from "./scb-breadcrumb/scb-breadcrumb.js";
|
|
|
8
8
|
import { ScbButton as C } from "./scb-button/scb-button.js";
|
|
9
9
|
import { ScbCalendarCard as l } from "./scb-calendar-card/scb-calendar-card.js";
|
|
10
10
|
import { ScbCard as D } from "./scb-card/scb-card.js";
|
|
11
|
-
import { ScbCheckboxGroup as
|
|
11
|
+
import { ScbCheckboxGroup as g } from "./scb-checkbox/scb-checkbox-group.js";
|
|
12
12
|
import { ScbCheckbox as s } from "./scb-checkbox/scb-checkbox.js";
|
|
13
13
|
import { ScbChip as H } from "./scb-chip/scb-chip.js";
|
|
14
14
|
import { ScbDialog as k } from "./scb-dialog/scb-dialog.js";
|
|
15
15
|
import { ScbDivider as y } from "./scb-divider/scb-divider.js";
|
|
16
|
-
import { ScbDrawerItem as
|
|
17
|
-
import { ScbDrawerSection as
|
|
16
|
+
import { ScbDrawerItem as P } from "./scb-drawer/scb-drawer-item.js";
|
|
17
|
+
import { ScbDrawerSection as M } from "./scb-drawer/scb-drawer-section.js";
|
|
18
18
|
import { ScbDrawer as N } from "./scb-drawer/scb-drawer.js";
|
|
19
19
|
import { ScbSubDrawer as z } from "./scb-drawer/scb-sub-drawer.js";
|
|
20
20
|
import { ScbFactCardContent as U } from "./scb-fact-card/scb-fact-card-content.js";
|
|
@@ -35,27 +35,28 @@ import { ScbKeyFigureCard as nr } from "./scb-keyfigure-card/scb-keyfigure-card.
|
|
|
35
35
|
import { ScbLink as Cr } from "./scb-link/scb-link.js";
|
|
36
36
|
import { ScbListItem as lr } from "./scb-list/scb-list-item.js";
|
|
37
37
|
import { ScbList as Dr } from "./scb-list/scb-list.js";
|
|
38
|
-
import { ScbMenuItem as
|
|
38
|
+
import { ScbMenuItem as gr } from "./scb-menu/scb-menu-item.js";
|
|
39
39
|
import { ScbMenu as sr } from "./scb-menu/scb-menu.js";
|
|
40
40
|
import { ScbSubMenu as Hr } from "./scb-menu/scb-sub-menu.js";
|
|
41
41
|
import { ScbNotification as kr } from "./scb-notification/scb-notification.js";
|
|
42
42
|
import { ScbNotificationCard as yr } from "./scb-notification-card/scb-notification-card.js";
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
import {
|
|
43
|
+
import { ScbPagination as Pr } from "./scb-pagination/scb-pagination.js";
|
|
44
|
+
import { ScbProgressIndicator as Mr } from "./scb-progress-indicator/scb-progress-indicator.js";
|
|
45
|
+
import { ScbRadioButton as Nr } from "./scb-radio-button/scb-radio-button.js";
|
|
46
|
+
import { ScbRadioGroup as zr } from "./scb-radio-button/scb-radio-group.js";
|
|
47
|
+
import { ScbSearch as Ur } from "./scb-search/scb-search.js";
|
|
48
|
+
import { ScbSegmentedButton as qr } from "./scb-segmented-button/scb-segmented-button.js";
|
|
49
|
+
import { ScbSegmentedItem as Jr } from "./scb-segmented-button/scb-segmented-item.js";
|
|
50
|
+
import { ScbSnackbar as Qr } from "./scb-snackbar/scb-snackbar.js";
|
|
51
|
+
import { ScbStatusPill as Wr } from "./scb-status-pill/scb-status-pill.js";
|
|
52
|
+
import { ScbSwitch as Yr } from "./scb-switch/scb-switch.js";
|
|
53
|
+
import { ScbPrimaryTab as _r } from "./scb-tabs/scb-primary-tab.js";
|
|
54
|
+
import { ScbSecondaryTab as ro } from "./scb-tabs/scb-secondary-tab.js";
|
|
55
|
+
import { ScbTabs as eo } from "./scb-tabs/scb-tabs.js";
|
|
56
|
+
import { ScbTextField2 as co } from "./scb-textfield/scb-textfield.js";
|
|
57
|
+
import { ScbTocItem as So } from "./scb-toc/scb-toc-item.js";
|
|
58
|
+
import { ScbToc as po } from "./scb-toc/scb-toc.js";
|
|
59
|
+
import { ScbTooltip as fo } from "./scb-tooltip/scb-tooltip.js";
|
|
59
60
|
export {
|
|
60
61
|
n as SCBBreadcrumb,
|
|
61
62
|
i as SCBBreadcrumbItem,
|
|
@@ -68,13 +69,13 @@ export {
|
|
|
68
69
|
l as ScbCalendarCard,
|
|
69
70
|
D as ScbCard,
|
|
70
71
|
s as ScbCheckbox,
|
|
71
|
-
|
|
72
|
+
g as ScbCheckboxGroup,
|
|
72
73
|
H as ScbChip,
|
|
73
74
|
k as ScbDialog,
|
|
74
75
|
y as ScbDivider,
|
|
75
76
|
N as ScbDrawer,
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
P as ScbDrawerItem,
|
|
78
|
+
M as ScbDrawerSection,
|
|
78
79
|
q as ScbFactCard,
|
|
79
80
|
U as ScbFactCardContent,
|
|
80
81
|
Q as ScbFooter,
|
|
@@ -93,26 +94,27 @@ export {
|
|
|
93
94
|
Dr as ScbList,
|
|
94
95
|
lr as ScbListItem,
|
|
95
96
|
sr as ScbMenu,
|
|
96
|
-
|
|
97
|
+
gr as ScbMenuItem,
|
|
97
98
|
kr as ScbNotification,
|
|
98
99
|
yr as ScbNotificationCard,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
Nr as
|
|
103
|
-
zr as
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
qr as
|
|
107
|
-
Jr as
|
|
100
|
+
Pr as ScbPagination,
|
|
101
|
+
_r as ScbPrimaryTab,
|
|
102
|
+
Mr as ScbProgressIndicator,
|
|
103
|
+
Nr as ScbRadioButton,
|
|
104
|
+
zr as ScbRadioGroup,
|
|
105
|
+
Ur as ScbSearch,
|
|
106
|
+
ro as ScbSecondaryTab,
|
|
107
|
+
qr as ScbSegmentedButton,
|
|
108
|
+
Jr as ScbSegmentedItem,
|
|
109
|
+
Qr as ScbSnackbar,
|
|
108
110
|
_ as ScbStack,
|
|
109
|
-
|
|
111
|
+
Wr as ScbStatusPill,
|
|
110
112
|
z as ScbSubDrawer,
|
|
111
113
|
Hr as ScbSubMenu,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
Yr as ScbSwitch,
|
|
115
|
+
eo as ScbTabs,
|
|
116
|
+
co as ScbTextField2,
|
|
117
|
+
po as ScbToc,
|
|
118
|
+
So as ScbTocItem,
|
|
119
|
+
fo as ScbTooltip
|
|
118
120
|
};
|
package/mvc/components/all.js
CHANGED
|
@@ -40,6 +40,7 @@ import './scb-menu/scb-menu-item.js';
|
|
|
40
40
|
import './scb-menu/scb-sub-menu.js';
|
|
41
41
|
import './scb-notification-card/scb-notification-card.js';
|
|
42
42
|
import './scb-notification/scb-notification.js';
|
|
43
|
+
import './scb-pagination/scb-pagination.js';
|
|
43
44
|
import './scb-progress-indicator/scb-progress-indicator.js';
|
|
44
45
|
import './scb-radio-button/scb-radio-button.js';
|
|
45
46
|
import './scb-radio-button/scb-radio-group.js';
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import{a as g,n as d,i as b,x as s,t as h}from"../../vendor/vendor.js";import"../scb-link/scb-link.js";import"../scb-button/scb-button.js";import"../scb-icon-button/scb-icon-button.js";import"../../vendor/vendor-material.js";import"../../vendor/preload-helper.js";import"../scb-tooltip/scb-tooltip.js";(function(){try{var p=typeof globalThis<"u"?globalThis:window;if(!p.__scb_ce_guard_installed__){p.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(n,i,r){try{customElements.get(n)||e(n,i,r)}catch(a){var o=String(a||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var u=Object.defineProperty,v=Object.getOwnPropertyDescriptor,c=(p,e,n,i)=>{for(var r=i>1?void 0:i?v(e,n):e,o=p.length-1,a;o>=0;o--)(a=p[o])&&(r=(i?a(e,n,r):a(r))||r);return i&&r&&u(e,n,r),r};let l=class extends b{constructor(){super(...arguments),this.variant="icon-text",this.page=1,this.totalPages=0,this.pagingHref="/products?page=",this.paginationAriaLabel="Paginering",this.currentAriaLabel="Nuvarande sida, ",this.pagingNumberAriaLabel="Gå till sida ",this.isNarrow=window.innerWidth<=768,this._onResize=()=>{this.isNarrow=window.innerWidth<=768}}_prevPage(){this.page>1&&this.page--,this.dispatchEvent(new CustomEvent("page-change",{detail:{page:this.page}}))}_nextPage(){this.page<this.totalPages&&this.page++,this.dispatchEvent(new CustomEvent("page-change",{detail:{page:this.page}}))}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this._onResize),this._onResize()}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this._onResize)}render(){if(this.totalPages===0)return null;const p=this.variant?`${this.variant.toLowerCase()}`:"",e=[],{page:n,totalPages:i}=this,r=window.innerWidth<=768,o=r?1:2,a=t=>t===n?s`
|
|
2
|
+
<li>
|
|
3
|
+
<span
|
|
4
|
+
class="page-number active"
|
|
5
|
+
aria-current="page"
|
|
6
|
+
aria-label="${this.currentAriaLabel} ${t}"
|
|
7
|
+
>${t}</span>
|
|
8
|
+
</li>
|
|
9
|
+
`:s`
|
|
10
|
+
<li>
|
|
11
|
+
<scb-link
|
|
12
|
+
class="page-number${t===n?" active":""}"
|
|
13
|
+
@click=${()=>{this.page=t,this.dispatchEvent(new CustomEvent("page-change",{detail:{page:t}}))}}
|
|
14
|
+
aria-current=${t===n?"page":void 0}
|
|
15
|
+
aria-label="${this.pagingNumberAriaLabel} ${t}"
|
|
16
|
+
href=${this.pagingHref}${t}
|
|
17
|
+
?disabled=${t===n}>${t}
|
|
18
|
+
</scb-link>
|
|
19
|
+
</li>
|
|
20
|
+
`;if(i<=8)for(let t=1;t<=i;t++)e.push(a(t));else if(e.push(a(1)),n<=4&&!r){for(let t=2;t<=5;t++)e.push(a(t));i>6?(e.push(s`<li><span class="ellipsis" aria-hidden="true">…</span></li>`),e.push(a(i))):i===6&&e.push(a(i))}else if(n<=3&&r){for(let t=2;t<=3;t++)e.push(a(t));i>4?(e.push(s`<li><span class="ellipsis" aria-hidden="true">…</span></li>`),e.push(a(i))):i===4&&e.push(a(i))}else if(n>=i-(o+1)){e.push(s`<li><span class="ellipsis" aria-hidden="true">…</span></li>`);for(let t=i-o*2;t<=i;t++)t>1&&e.push(a(t))}else{e.push(s`<li><span class="ellipsis" aria-hidden="true">…</span></li>`);for(let t=n-o;t<=n+o;t++)t>1&&t<i&&e.push(a(t));e.push(s`<li><span class="ellipsis" aria-hidden="true">…</span></li>`),e.push(a(i))}return r?s`
|
|
21
|
+
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${p}">
|
|
22
|
+
<div class="pagination-row">
|
|
23
|
+
<div class="prev">
|
|
24
|
+
${this.variant==="icon"?s`<scb-icon-button icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page===1} aria-label="Föregående sida"></scb-icon-button>`:s`<scb-button variant="text" label="Föregående" icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page===1} aria-label="Föregående sida"></scb-button>`}
|
|
25
|
+
</div>
|
|
26
|
+
<ol>
|
|
27
|
+
${e}
|
|
28
|
+
</ol>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="next">
|
|
31
|
+
${this.variant==="icon"?s`<scb-icon-button icon="chevron_right" @click=${this._nextPage} ?disabled=${this.page===this.totalPages} aria-label="Nästa sida"></scb-icon-button>`:s`<scb-button variant="text" label="Nästa" icon="chevron_right" iconPosition="right" @click=${this._nextPage} ?disabled=${this.page===this.totalPages} aria-label="Nästa sida" trailing-icon></scb-button>`}
|
|
32
|
+
</div>
|
|
33
|
+
</nav>
|
|
34
|
+
`:s`
|
|
35
|
+
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${p}">
|
|
36
|
+
<div class="pagination-row">
|
|
37
|
+
<div class="prev">
|
|
38
|
+
${this.variant==="icon"?s`<scb-icon-button icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page===1} aria-label="Föregående sida"></scb-icon-button>`:s`<scb-button variant="text" label="Föregående" icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page===1} aria-label="Föregående sida"></scb-button>`}
|
|
39
|
+
</div>
|
|
40
|
+
<ol>
|
|
41
|
+
${e}
|
|
42
|
+
</ol>
|
|
43
|
+
<div class="next">
|
|
44
|
+
${this.variant==="icon"?s`<scb-icon-button icon="chevron_right" @click=${this._nextPage} ?disabled=${this.page===this.totalPages} aria-label="Nästa sida"></scb-icon-button>`:s`<scb-button variant="text" label="Nästa" icon="chevron_right" iconPosition="right" @click=${this._nextPage} ?disabled=${this.page===this.totalPages} aria-label="Nästa sida" trailing-icon></scb-button>`}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</nav>
|
|
48
|
+
`}};l.styles=[g`
|
|
49
|
+
:host .pagination {
|
|
50
|
+
--md-text-button-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
51
|
+
--md-text-button-pressed-state-layer-color: var(--md-sys-color-on-surface, #0F0865);
|
|
52
|
+
--md-text-button-focus-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
53
|
+
--md-text-button-hover-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
54
|
+
--md-text-button-pressed-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
55
|
+
--md-text-button-label-text-weight: var(--weight-regular, 400);
|
|
56
|
+
--md-text-button-label-text-line-height: var(--md-sys-typescale-body-medium-line-height, 24px);
|
|
57
|
+
--md-text-button-label-text-size: var(--md-sys-typescale-body-medium-size, 16px);
|
|
58
|
+
--md-text-button-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
59
|
+
--md-text-button-focus-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
60
|
+
--md-text-button-hover-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
61
|
+
--md-text-button-pressed-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
62
|
+
--scb-link-decoration: none;
|
|
63
|
+
--scb-link-color: var(--md-sys-color-on-surface, #0F0865);
|
|
64
|
+
|
|
65
|
+
scb-link.page-number a {
|
|
66
|
+
cursor: pointer;
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
display: inline-flex;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.pagination {
|
|
73
|
+
width: 100%;
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
gap: 0;
|
|
77
|
+
}
|
|
78
|
+
.pagination-row {
|
|
79
|
+
width: 100%;
|
|
80
|
+
display: flex;
|
|
81
|
+
flex-direction: row;
|
|
82
|
+
align-items: center;
|
|
83
|
+
gap: 4px;
|
|
84
|
+
}
|
|
85
|
+
.pagination-row .prev {
|
|
86
|
+
display: flex;
|
|
87
|
+
justify-content: flex-start;
|
|
88
|
+
width: auto;
|
|
89
|
+
}
|
|
90
|
+
.pagination-row ol {
|
|
91
|
+
width: auto;
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: row;
|
|
94
|
+
justify-content: flex-start;
|
|
95
|
+
gap: 4px;
|
|
96
|
+
margin: 0;
|
|
97
|
+
padding: 0;
|
|
98
|
+
list-style: none;
|
|
99
|
+
}
|
|
100
|
+
.pagination-row ol li {
|
|
101
|
+
min-width: 40px;
|
|
102
|
+
min-height: 40px;
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
}
|
|
107
|
+
.pagination-row .next {
|
|
108
|
+
display: flex;
|
|
109
|
+
justify-content: flex-start;
|
|
110
|
+
align-items: center;
|
|
111
|
+
width: auto;
|
|
112
|
+
margin-top: 0;
|
|
113
|
+
}
|
|
114
|
+
scb-link.page-number a {
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
text-decoration: none;
|
|
117
|
+
display: inline-flex;
|
|
118
|
+
}
|
|
119
|
+
.page-number.active {
|
|
120
|
+
display: inline-flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
justify-content: center;
|
|
123
|
+
border-radius: 50%;
|
|
124
|
+
background: var(--md-sys-color-primary, #1F44FF);
|
|
125
|
+
color: var(--md-sys-color-on-primary, #FFF);
|
|
126
|
+
text-align: center;
|
|
127
|
+
width: 40px;
|
|
128
|
+
height: 40px;
|
|
129
|
+
}
|
|
130
|
+
.page-number.active {
|
|
131
|
+
font-family: var(--brand-font, 'Inter', sans-serif);
|
|
132
|
+
}
|
|
133
|
+
.ellipsis {
|
|
134
|
+
margin: 0 4px;
|
|
135
|
+
color: #888;
|
|
136
|
+
user-select: none;
|
|
137
|
+
pointer-events: none;
|
|
138
|
+
}
|
|
139
|
+
scb-button[disabled] {
|
|
140
|
+
opacity: 0.5;
|
|
141
|
+
pointer-events: none;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@media (max-width: 768px) {
|
|
145
|
+
|
|
146
|
+
.pagination .prev {
|
|
147
|
+
display: flex;
|
|
148
|
+
justify-content: flex-start;
|
|
149
|
+
}
|
|
150
|
+
.pagination .next {
|
|
151
|
+
width: 100%;
|
|
152
|
+
margin-top: 8px;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@media (max-width: 390px) {
|
|
157
|
+
.pagination-row {
|
|
158
|
+
flex-direction: column;
|
|
159
|
+
gap: 0;
|
|
160
|
+
}
|
|
161
|
+
.pagination-row .prev {
|
|
162
|
+
width: 100%;
|
|
163
|
+
margin-bottom: 8px;
|
|
164
|
+
align-items: center;
|
|
165
|
+
}
|
|
166
|
+
.pagination-row ol {
|
|
167
|
+
width: 100%;
|
|
168
|
+
align-items: center;
|
|
169
|
+
}
|
|
170
|
+
.pagination-row .next {
|
|
171
|
+
width: 100%;
|
|
172
|
+
margin-top: 8px;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
`];c([d({type:String})],l.prototype,"variant",2);c([d({type:Number})],l.prototype,"page",2);c([d({type:Number,attribute:"total-pages"})],l.prototype,"totalPages",2);c([d({type:String,attribute:"paging-href"})],l.prototype,"pagingHref",2);c([d({type:String,attribute:"pagination-aria-label"})],l.prototype,"paginationAriaLabel",2);c([d({type:String,attribute:"current-aria-label"})],l.prototype,"currentAriaLabel",2);c([d({type:String,attribute:"paging-number-aria-label"})],l.prototype,"pagingNumberAriaLabel",2);c([d({type:Boolean})],l.prototype,"isNarrow",2);l=c([h("scb-pagination")],l);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.72",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -226,6 +226,10 @@
|
|
|
226
226
|
"import": "./scb-notification-card/scb-notification-card.js",
|
|
227
227
|
"require": "./scb-notification-card/scb-notification-card.js"
|
|
228
228
|
},
|
|
229
|
+
"./scb-pagination": {
|
|
230
|
+
"import": "./scb-pagination/scb-pagination.js",
|
|
231
|
+
"require": "./scb-pagination/scb-pagination.js"
|
|
232
|
+
},
|
|
229
233
|
"./scb-progress-indicator": {
|
|
230
234
|
"import": "./scb-progress-indicator/scb-progress-indicator.js",
|
|
231
235
|
"require": "./scb-progress-indicator/scb-progress-indicator.js"
|
|
@@ -292,5 +296,5 @@
|
|
|
292
296
|
},
|
|
293
297
|
"./mvc/*": "./mvc/*"
|
|
294
298
|
},
|
|
295
|
-
"buildHash": "
|
|
299
|
+
"buildHash": "33CE97F08BBD09532DCCF9A27161C746EE8DD54CC4DB0581E0FFCFE28A6BE144"
|
|
296
300
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class ScbPagination extends LitElement {
|
|
3
|
+
variant: 'icon-text' | 'icon';
|
|
4
|
+
page: number;
|
|
5
|
+
totalPages: number;
|
|
6
|
+
pagingHref: string;
|
|
7
|
+
paginationAriaLabel: string;
|
|
8
|
+
currentAriaLabel: string;
|
|
9
|
+
pagingNumberAriaLabel: string;
|
|
10
|
+
isNarrow: boolean;
|
|
11
|
+
static styles: import('lit').CSSResult[];
|
|
12
|
+
private _prevPage;
|
|
13
|
+
private _nextPage;
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
disconnectedCallback(): void;
|
|
16
|
+
private _onResize;
|
|
17
|
+
render(): import('lit-html').TemplateResult<1> | null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { css as g, LitElement as h, html as a } from "lit";
|
|
2
|
+
import { property as p, customElement as b } from "lit/decorators.js";
|
|
3
|
+
import "../scb-link/scb-link.js";
|
|
4
|
+
import "../scb-button/scb-button.js";
|
|
5
|
+
import "../scb-icon-button/scb-icon-button.js";
|
|
6
|
+
import "@material/web/icon/icon.js";
|
|
7
|
+
import "@material/web/focus/md-focus-ring.js";
|
|
8
|
+
var u = Object.defineProperty, v = Object.getOwnPropertyDescriptor, l = (d, e, s, i) => {
|
|
9
|
+
for (var r = i > 1 ? void 0 : i ? v(e, s) : e, c = d.length - 1, n; c >= 0; c--)
|
|
10
|
+
(n = d[c]) && (r = (i ? n(e, s, r) : n(r)) || r);
|
|
11
|
+
return i && r && u(e, s, r), r;
|
|
12
|
+
};
|
|
13
|
+
let o = class extends h {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments), this.variant = "icon-text", this.page = 1, this.totalPages = 0, this.pagingHref = "/products?page=", this.paginationAriaLabel = "Paginering", this.currentAriaLabel = "Nuvarande sida, ", this.pagingNumberAriaLabel = "Gå till sida ", this.isNarrow = window.innerWidth <= 768, this._onResize = () => {
|
|
16
|
+
this.isNarrow = window.innerWidth <= 768;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
_prevPage() {
|
|
20
|
+
this.page > 1 && this.page--, this.dispatchEvent(new CustomEvent("page-change", { detail: { page: this.page } }));
|
|
21
|
+
}
|
|
22
|
+
_nextPage() {
|
|
23
|
+
this.page < this.totalPages && this.page++, this.dispatchEvent(new CustomEvent("page-change", { detail: { page: this.page } }));
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
super.connectedCallback(), window.addEventListener("resize", this._onResize), this._onResize();
|
|
27
|
+
}
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
super.disconnectedCallback(), window.removeEventListener("resize", this._onResize);
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
if (this.totalPages === 0) return null;
|
|
33
|
+
const d = this.variant ? `${this.variant.toLowerCase()}` : "", e = [], { page: s, totalPages: i } = this, r = window.innerWidth <= 768, c = r ? 1 : 2, n = (t) => t === s ? a`
|
|
34
|
+
<li>
|
|
35
|
+
<span
|
|
36
|
+
class="page-number active"
|
|
37
|
+
aria-current="page"
|
|
38
|
+
aria-label="${this.currentAriaLabel} ${t}"
|
|
39
|
+
>${t}</span>
|
|
40
|
+
</li>
|
|
41
|
+
` : a`
|
|
42
|
+
<li>
|
|
43
|
+
<scb-link
|
|
44
|
+
class="page-number${t === s ? " active" : ""}"
|
|
45
|
+
@click=${() => {
|
|
46
|
+
this.page = t, this.dispatchEvent(new CustomEvent("page-change", { detail: { page: t } }));
|
|
47
|
+
}}
|
|
48
|
+
aria-current=${t === s ? "page" : void 0}
|
|
49
|
+
aria-label="${this.pagingNumberAriaLabel} ${t}"
|
|
50
|
+
href=${this.pagingHref}${t}
|
|
51
|
+
?disabled=${t === s}>${t}
|
|
52
|
+
</scb-link>
|
|
53
|
+
</li>
|
|
54
|
+
`;
|
|
55
|
+
if (i <= 8)
|
|
56
|
+
for (let t = 1; t <= i; t++)
|
|
57
|
+
e.push(n(t));
|
|
58
|
+
else if (e.push(n(1)), s <= 4 && !r) {
|
|
59
|
+
for (let t = 2; t <= 5; t++) e.push(n(t));
|
|
60
|
+
i > 6 ? (e.push(a`<li><span class="ellipsis" aria-hidden="true">…</span></li>`), e.push(n(i))) : i === 6 && e.push(n(i));
|
|
61
|
+
} else if (s <= 3 && r) {
|
|
62
|
+
for (let t = 2; t <= 3; t++) e.push(n(t));
|
|
63
|
+
i > 4 ? (e.push(a`<li><span class="ellipsis" aria-hidden="true">…</span></li>`), e.push(n(i))) : i === 4 && e.push(n(i));
|
|
64
|
+
} else if (s >= i - (c + 1)) {
|
|
65
|
+
e.push(a`<li><span class="ellipsis" aria-hidden="true">…</span></li>`);
|
|
66
|
+
for (let t = i - c * 2; t <= i; t++)
|
|
67
|
+
t > 1 && e.push(n(t));
|
|
68
|
+
} else {
|
|
69
|
+
e.push(a`<li><span class="ellipsis" aria-hidden="true">…</span></li>`);
|
|
70
|
+
for (let t = s - c; t <= s + c; t++)
|
|
71
|
+
t > 1 && t < i && e.push(n(t));
|
|
72
|
+
e.push(a`<li><span class="ellipsis" aria-hidden="true">…</span></li>`), e.push(n(i));
|
|
73
|
+
}
|
|
74
|
+
return r ? a`
|
|
75
|
+
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${d}">
|
|
76
|
+
<div class="pagination-row">
|
|
77
|
+
<div class="prev">
|
|
78
|
+
${this.variant === "icon" ? a`<scb-icon-button icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page === 1} aria-label="Föregående sida"></scb-icon-button>` : a`<scb-button variant="text" label="Föregående" icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page === 1} aria-label="Föregående sida"></scb-button>`}
|
|
79
|
+
</div>
|
|
80
|
+
<ol>
|
|
81
|
+
${e}
|
|
82
|
+
</ol>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="next">
|
|
85
|
+
${this.variant === "icon" ? a`<scb-icon-button icon="chevron_right" @click=${this._nextPage} ?disabled=${this.page === this.totalPages} aria-label="Nästa sida"></scb-icon-button>` : a`<scb-button variant="text" label="Nästa" icon="chevron_right" iconPosition="right" @click=${this._nextPage} ?disabled=${this.page === this.totalPages} aria-label="Nästa sida" trailing-icon></scb-button>`}
|
|
86
|
+
</div>
|
|
87
|
+
</nav>
|
|
88
|
+
` : a`
|
|
89
|
+
<nav aria-label="${this.paginationAriaLabel}" class="pagination ${d}">
|
|
90
|
+
<div class="pagination-row">
|
|
91
|
+
<div class="prev">
|
|
92
|
+
${this.variant === "icon" ? a`<scb-icon-button icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page === 1} aria-label="Föregående sida"></scb-icon-button>` : a`<scb-button variant="text" label="Föregående" icon="chevron_left" @click=${this._prevPage} ?disabled=${this.page === 1} aria-label="Föregående sida"></scb-button>`}
|
|
93
|
+
</div>
|
|
94
|
+
<ol>
|
|
95
|
+
${e}
|
|
96
|
+
</ol>
|
|
97
|
+
<div class="next">
|
|
98
|
+
${this.variant === "icon" ? a`<scb-icon-button icon="chevron_right" @click=${this._nextPage} ?disabled=${this.page === this.totalPages} aria-label="Nästa sida"></scb-icon-button>` : a`<scb-button variant="text" label="Nästa" icon="chevron_right" iconPosition="right" @click=${this._nextPage} ?disabled=${this.page === this.totalPages} aria-label="Nästa sida" trailing-icon></scb-button>`}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
</nav>
|
|
102
|
+
`;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
o.styles = [
|
|
106
|
+
g`
|
|
107
|
+
:host .pagination {
|
|
108
|
+
--md-text-button-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
109
|
+
--md-text-button-pressed-state-layer-color: var(--md-sys-color-on-surface, #0F0865);
|
|
110
|
+
--md-text-button-focus-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
111
|
+
--md-text-button-hover-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
112
|
+
--md-text-button-pressed-label-text-color: var(--md-sys-color-on-surface, #0F0865);
|
|
113
|
+
--md-text-button-label-text-weight: var(--weight-regular, 400);
|
|
114
|
+
--md-text-button-label-text-line-height: var(--md-sys-typescale-body-medium-line-height, 24px);
|
|
115
|
+
--md-text-button-label-text-size: var(--md-sys-typescale-body-medium-size, 16px);
|
|
116
|
+
--md-text-button-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
117
|
+
--md-text-button-focus-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
118
|
+
--md-text-button-hover-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
119
|
+
--md-text-button-pressed-icon-color : var(--md-sys-color-on-surface, #0F0865);
|
|
120
|
+
--scb-link-decoration: none;
|
|
121
|
+
--scb-link-color: var(--md-sys-color-on-surface, #0F0865);
|
|
122
|
+
|
|
123
|
+
scb-link.page-number a {
|
|
124
|
+
cursor: pointer;
|
|
125
|
+
text-decoration: none;
|
|
126
|
+
display: inline-flex;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.pagination {
|
|
131
|
+
width: 100%;
|
|
132
|
+
display: flex;
|
|
133
|
+
flex-direction: column;
|
|
134
|
+
gap: 0;
|
|
135
|
+
}
|
|
136
|
+
.pagination-row {
|
|
137
|
+
width: 100%;
|
|
138
|
+
display: flex;
|
|
139
|
+
flex-direction: row;
|
|
140
|
+
align-items: center;
|
|
141
|
+
gap: 4px;
|
|
142
|
+
}
|
|
143
|
+
.pagination-row .prev {
|
|
144
|
+
display: flex;
|
|
145
|
+
justify-content: flex-start;
|
|
146
|
+
width: auto;
|
|
147
|
+
}
|
|
148
|
+
.pagination-row ol {
|
|
149
|
+
width: auto;
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-direction: row;
|
|
152
|
+
justify-content: flex-start;
|
|
153
|
+
gap: 4px;
|
|
154
|
+
margin: 0;
|
|
155
|
+
padding: 0;
|
|
156
|
+
list-style: none;
|
|
157
|
+
}
|
|
158
|
+
.pagination-row ol li {
|
|
159
|
+
min-width: 40px;
|
|
160
|
+
min-height: 40px;
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
}
|
|
165
|
+
.pagination-row .next {
|
|
166
|
+
display: flex;
|
|
167
|
+
justify-content: flex-start;
|
|
168
|
+
align-items: center;
|
|
169
|
+
width: auto;
|
|
170
|
+
margin-top: 0;
|
|
171
|
+
}
|
|
172
|
+
scb-link.page-number a {
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
text-decoration: none;
|
|
175
|
+
display: inline-flex;
|
|
176
|
+
}
|
|
177
|
+
.page-number.active {
|
|
178
|
+
display: inline-flex;
|
|
179
|
+
align-items: center;
|
|
180
|
+
justify-content: center;
|
|
181
|
+
border-radius: 50%;
|
|
182
|
+
background: var(--md-sys-color-primary, #1F44FF);
|
|
183
|
+
color: var(--md-sys-color-on-primary, #FFF);
|
|
184
|
+
text-align: center;
|
|
185
|
+
width: 40px;
|
|
186
|
+
height: 40px;
|
|
187
|
+
}
|
|
188
|
+
.page-number.active {
|
|
189
|
+
font-family: var(--brand-font, 'Inter', sans-serif);
|
|
190
|
+
}
|
|
191
|
+
.ellipsis {
|
|
192
|
+
margin: 0 4px;
|
|
193
|
+
color: #888;
|
|
194
|
+
user-select: none;
|
|
195
|
+
pointer-events: none;
|
|
196
|
+
}
|
|
197
|
+
scb-button[disabled] {
|
|
198
|
+
opacity: 0.5;
|
|
199
|
+
pointer-events: none;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@media (max-width: 768px) {
|
|
203
|
+
|
|
204
|
+
.pagination .prev {
|
|
205
|
+
display: flex;
|
|
206
|
+
justify-content: flex-start;
|
|
207
|
+
}
|
|
208
|
+
.pagination .next {
|
|
209
|
+
width: 100%;
|
|
210
|
+
margin-top: 8px;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
@media (max-width: 390px) {
|
|
215
|
+
.pagination-row {
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
gap: 0;
|
|
218
|
+
}
|
|
219
|
+
.pagination-row .prev {
|
|
220
|
+
width: 100%;
|
|
221
|
+
margin-bottom: 8px;
|
|
222
|
+
align-items: center;
|
|
223
|
+
}
|
|
224
|
+
.pagination-row ol {
|
|
225
|
+
width: 100%;
|
|
226
|
+
align-items: center;
|
|
227
|
+
}
|
|
228
|
+
.pagination-row .next {
|
|
229
|
+
width: 100%;
|
|
230
|
+
margin-top: 8px;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
`
|
|
234
|
+
];
|
|
235
|
+
l([
|
|
236
|
+
p({ type: String })
|
|
237
|
+
], o.prototype, "variant", 2);
|
|
238
|
+
l([
|
|
239
|
+
p({ type: Number })
|
|
240
|
+
], o.prototype, "page", 2);
|
|
241
|
+
l([
|
|
242
|
+
p({ type: Number, attribute: "total-pages" })
|
|
243
|
+
], o.prototype, "totalPages", 2);
|
|
244
|
+
l([
|
|
245
|
+
p({ type: String, attribute: "paging-href" })
|
|
246
|
+
], o.prototype, "pagingHref", 2);
|
|
247
|
+
l([
|
|
248
|
+
p({ type: String, attribute: "pagination-aria-label" })
|
|
249
|
+
], o.prototype, "paginationAriaLabel", 2);
|
|
250
|
+
l([
|
|
251
|
+
p({ type: String, attribute: "current-aria-label" })
|
|
252
|
+
], o.prototype, "currentAriaLabel", 2);
|
|
253
|
+
l([
|
|
254
|
+
p({ type: String, attribute: "paging-number-aria-label" })
|
|
255
|
+
], o.prototype, "pagingNumberAriaLabel", 2);
|
|
256
|
+
l([
|
|
257
|
+
p({ type: Boolean })
|
|
258
|
+
], o.prototype, "isNarrow", 2);
|
|
259
|
+
o = l([
|
|
260
|
+
b("scb-pagination")
|
|
261
|
+
], o);
|
|
262
|
+
export {
|
|
263
|
+
o as ScbPagination
|
|
264
|
+
};
|