@knowark/componarkjs 1.12.0 → 1.13.0
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.
|
@@ -7,7 +7,7 @@ export class Paginator extends Component {
|
|
|
7
7
|
this.binding = 'paginator-listen'
|
|
8
8
|
this.collectionSize = (
|
|
9
9
|
context.collectionSize || this.collectionSize || '120')
|
|
10
|
-
this.pageSize = context.pageSize || this.pageSize || '
|
|
10
|
+
this.pageSize = context.pageSize || this.pageSize || '60'
|
|
11
11
|
this.currentPage = context.currentPage || this.currentPage || '1'
|
|
12
12
|
this.displayedPages = (
|
|
13
13
|
context.displayedPages || this.displayedPages || '12')
|
|
@@ -23,14 +23,13 @@ export class Paginator extends Component {
|
|
|
23
23
|
|
|
24
24
|
render () {
|
|
25
25
|
this._grabSlots()
|
|
26
|
-
this.content = /* html
|
|
26
|
+
this.content = /* html */`
|
|
27
27
|
<div class="ark-paginator__body">
|
|
28
28
|
<div data-start class="ark-paginator__buttons">
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
<div data-middle paginator-listen on-click="_move"
|
|
32
|
-
class="ark-paginator__pages">
|
|
33
|
-
</div>
|
|
32
|
+
class="ark-paginator__pages"></div>
|
|
34
33
|
|
|
35
34
|
<div data-end class="ark-paginator__buttons">
|
|
36
35
|
</div>
|
|
@@ -121,7 +120,7 @@ export class Paginator extends Component {
|
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
_grabSlots() {
|
|
124
|
-
const [pageButton] = [this.slots.
|
|
123
|
+
const [pageButton] = [this.slots.page].flat()
|
|
125
124
|
this.pageButton = this.pageButton ?? pageButton
|
|
126
125
|
const [firstButton] = [this.slots.first].flat()
|
|
127
126
|
this.firstButton = this.firstButton ?? firstButton
|
|
@@ -134,8 +133,8 @@ export class Paginator extends Component {
|
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
_buildButton (element, handler, content, attributes = []) {
|
|
137
|
-
const button = element ?? document.createElement('button')
|
|
138
|
-
button.
|
|
136
|
+
const button = (element ?? document.createElement('button')).cloneNode(true)
|
|
137
|
+
button.innerHTML = button.innerHTML || content
|
|
139
138
|
if (handler) {
|
|
140
139
|
button.setAttribute('paginator-listen', '')
|
|
141
140
|
button.setAttribute('on-click', handler)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './paginator.js'
|
|
2
2
|
|
|
3
3
|
describe('Paginator', () => {
|
|
4
4
|
let container = null
|
|
@@ -129,9 +129,11 @@ describe('Paginator', () => {
|
|
|
129
129
|
it('can be provided with custom styleable elements', () => {
|
|
130
130
|
container.innerHTML = /* html */ `
|
|
131
131
|
<ark-paginator page-size="12" displayed-pages="5">
|
|
132
|
-
<button data-first slot="first"
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
<button data-first slot="first">
|
|
133
|
+
<span style="pointer-events: none">FIRST</span>
|
|
134
|
+
</button>
|
|
135
|
+
<button data-previous slot="previous">BACK</button>
|
|
136
|
+
<button data-page-general slot="page"></button>
|
|
135
137
|
<button data-next slot="next"></button>
|
|
136
138
|
<button data-last slot="last"></button>
|
|
137
139
|
</ark-paginator>
|
|
@@ -139,8 +141,10 @@ describe('Paginator', () => {
|
|
|
139
141
|
|
|
140
142
|
const paginator = container.querySelector('ark-paginator')
|
|
141
143
|
|
|
142
|
-
expect(paginator.querySelector('[data-first]')).
|
|
143
|
-
|
|
144
|
+
expect(paginator.querySelector('[data-first]').innerHTML.trim()).toEqual(
|
|
145
|
+
'<span style="pointer-events: none">FIRST</span>')
|
|
146
|
+
expect(paginator.querySelector('[data-previous]').innerHTML.trim()).toEqual(
|
|
147
|
+
'BACK')
|
|
144
148
|
expect(paginator.querySelector('[data-page-general]')).toBeTruthy()
|
|
145
149
|
expect(paginator.querySelector('[data-next]')).toBeTruthy()
|
|
146
150
|
expect(paginator.querySelector('[data-last]')).toBeTruthy()
|