@knowark/componarkjs 1.7.3 → 1.7.5
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/Makefile +6 -3
- package/jsconfig.json +23 -0
- package/lib/base/component/component.js +27 -26
- package/lib/base/component/component.test.js +76 -32
- package/lib/base/styles/styles.js +34 -5
- package/lib/base/utils/define.js +6 -7
- package/lib/base/utils/define.test.js +5 -5
- package/lib/base/utils/helpers.js +14 -10
- package/lib/base/utils/helpers.test.js +13 -13
- package/lib/base/utils/uuid.js +4 -4
- package/lib/components/audio/components/audio.js +6 -6
- package/lib/components/audio/components/audio.test.js +11 -10
- package/lib/components/audio/styles/ark.css.js +1 -1
- package/lib/components/camera/components/camera.test.js +6 -6
- package/lib/components/camera/styles/ark.css.js +1 -1
- package/lib/components/camera/styles/index.js +1 -1
- package/lib/components/capture/components/capture.js +2 -2
- package/lib/components/capture/components/capture.test.js +1 -1
- package/lib/components/droparea/components/droparea-preview.js +27 -26
- package/lib/components/droparea/components/droparea-preview.test.js +9 -9
- package/lib/components/droparea/components/droparea.js +19 -19
- package/lib/components/droparea/components/droparea.test.js +42 -42
- package/lib/components/droparea/styles/ark.css.js +1 -1
- package/lib/components/emit/components/emit.js +4 -4
- package/lib/components/emit/components/emit.test.js +5 -5
- package/lib/components/list/components/item.test.js +12 -14
- package/lib/components/list/components/list.js +25 -25
- package/lib/components/list/components/list.test.js +27 -29
- package/lib/components/paginator/components/paginator.js +2 -2
- package/lib/components/paginator/components/paginator.test.js +15 -18
- package/lib/components/paginator/styles/ark.css.js +1 -1
- package/lib/components/spinner/components/spinner.js +17 -17
- package/lib/components/spinner/styles/index.js +1 -1
- package/lib/components/splitview/components/splitview.detail.js +3 -3
- package/lib/components/splitview/components/splitview.detail.test.js +23 -23
- package/lib/components/splitview/components/splitview.js +3 -3
- package/lib/components/splitview/components/splitview.master.js +3 -3
- package/lib/components/splitview/components/splitview.master.test.js +2 -2
- package/lib/components/splitview/components/splitview.test.js +5 -7
- package/lib/components/translate/components/translate.js +17 -19
- package/lib/components/translate/components/translate.test.js +13 -14
- package/package.json +1 -1
- package/showcase/assets/knowark.svg +1 -0
- package/showcase/{design/screens/base/audio/audioDemo.js → components/demos/audio.js} +6 -10
- package/showcase/{design/screens/base/camera/cameraDemo.js → components/demos/camera.js} +6 -7
- package/showcase/{design/screens/base/droparea/dropareaDemo.js → components/demos/droparea.js} +7 -7
- package/showcase/{design/screens/base/list/listDemo.js → components/demos/list.js} +2 -3
- package/showcase/{design/screens/base/paginator/paginatorDemo.js → components/demos/paginator.js} +9 -9
- package/showcase/{design/screens/base/splitview/splitViewDemo.js → components/demos/splitview.js} +42 -9
- package/showcase/{design/screens/base/translate/translateDemo.js → components/demos/translate.js} +4 -5
- package/showcase/components/index.html +81 -0
- package/showcase/index.html +40 -82
- package/showcase/index.js +0 -1
- package/webpack.config.cjs +50 -50
- package/showcase/design/core/factories/development/development.factory.js +0 -5
- package/showcase/design/core/factories/development/index.js +0 -1
- package/showcase/design/core/factories/index.js +0 -11
- package/showcase/design/core/factories/standard.factory.js +0 -19
- package/showcase/design/index.html +0 -22
- package/showcase/design/index.js +0 -7
- package/showcase/design/screens/base/audio/index.js +0 -25
- package/showcase/design/screens/base/camera/index.js +0 -25
- package/showcase/design/screens/base/droparea/index.js +0 -25
- package/showcase/design/screens/base/index.js +0 -42
- package/showcase/design/screens/base/list/index.js +0 -25
- package/showcase/design/screens/base/paginator/index.js +0 -25
- package/showcase/design/screens/base/root.component.js +0 -294
- package/showcase/design/screens/base/root.routes.js +0 -28
- package/showcase/design/screens/base/spinner/index.js +0 -25
- package/showcase/design/screens/base/spinner/spinnerDemo.js +0 -55
- package/showcase/design/screens/base/splitview/detailDemo.js +0 -40
- package/showcase/design/screens/base/splitview/index.js +0 -25
- package/showcase/design/screens/base/translate/index.js +0 -20
- package/showcase/design/screens/main.js +0 -12
- package/showcase/design/screens/screens.routes.js +0 -23
- package/tsconfig.json +0 -23
- /package/showcase/{design/.htaccess → .htaccess} +0 -0
|
@@ -12,7 +12,7 @@ describe('List', () => {
|
|
|
12
12
|
container.remove()
|
|
13
13
|
container = null
|
|
14
14
|
})
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
it('can be instantiated', () => {
|
|
17
17
|
container.innerHTML = `
|
|
18
18
|
<ark-list></ark-list>
|
|
@@ -20,18 +20,17 @@ describe('List', () => {
|
|
|
20
20
|
|
|
21
21
|
const list = container.querySelector('ark-list')
|
|
22
22
|
expect(list).toEqual(list.init())
|
|
23
|
-
|
|
24
23
|
})
|
|
25
|
-
|
|
24
|
+
|
|
26
25
|
it('can be instantiated with items', async () => {
|
|
27
26
|
container.innerHTML = `
|
|
28
27
|
<ark-list></ark-list>
|
|
29
28
|
`
|
|
30
|
-
|
|
31
|
-
const list =
|
|
32
|
-
list.source =
|
|
29
|
+
|
|
30
|
+
const list = container.querySelector('ark-list')
|
|
31
|
+
list.source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
33
32
|
list.render()
|
|
34
|
-
|
|
33
|
+
|
|
35
34
|
const items = list.selectAll('ark-list-item')
|
|
36
35
|
|
|
37
36
|
expect(items.length).toEqual(4)
|
|
@@ -51,7 +50,7 @@ describe('List', () => {
|
|
|
51
50
|
list.source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
52
51
|
list.render()
|
|
53
52
|
const items = list.selectAll('ark-list-item')
|
|
54
|
-
|
|
53
|
+
|
|
55
54
|
expect(items.length).toEqual(4)
|
|
56
55
|
expect(items[0].textContent.trim()).toEqual('Colombia')
|
|
57
56
|
expect(items[1].textContent.trim()).toEqual('Uruguay')
|
|
@@ -63,14 +62,14 @@ describe('List', () => {
|
|
|
63
62
|
})
|
|
64
63
|
items[0].click()
|
|
65
64
|
})
|
|
66
|
-
|
|
65
|
+
|
|
67
66
|
it('can delete', async () => {
|
|
68
67
|
container.innerHTML = `
|
|
69
68
|
<ark-list click-disabled></ark-list
|
|
70
69
|
`
|
|
71
|
-
|
|
70
|
+
|
|
72
71
|
const list = container.querySelector('ark-list')
|
|
73
|
-
list.source =
|
|
72
|
+
list.source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
74
73
|
list.render()
|
|
75
74
|
|
|
76
75
|
list.delete(1)
|
|
@@ -84,22 +83,21 @@ describe('List', () => {
|
|
|
84
83
|
expect(items[0].textContent.trim()).toEqual('Perú')
|
|
85
84
|
})
|
|
86
85
|
|
|
87
|
-
|
|
88
86
|
it('can select an item when it is clicked', (done) => {
|
|
89
87
|
expect.assertions(2)
|
|
90
88
|
container.innerHTML = `
|
|
91
89
|
<ark-list></ark-list
|
|
92
90
|
`
|
|
93
|
-
|
|
91
|
+
|
|
94
92
|
const list = container.querySelector('ark-list')
|
|
95
|
-
list.source =
|
|
93
|
+
list.source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
96
94
|
list.render()
|
|
97
95
|
|
|
98
96
|
const items = list.selectAll('ark-list-item')
|
|
99
97
|
expect(items.length).toEqual(4)
|
|
100
98
|
|
|
101
99
|
list.addEventListener('list-selected', event => {
|
|
102
|
-
expect(event
|
|
100
|
+
expect(event.detail.data).toEqual('Brasil')
|
|
103
101
|
done()
|
|
104
102
|
})
|
|
105
103
|
|
|
@@ -107,16 +105,16 @@ describe('List', () => {
|
|
|
107
105
|
})
|
|
108
106
|
|
|
109
107
|
it('can be declaratively instantiated with JSON source', async () => {
|
|
110
|
-
const source =
|
|
108
|
+
const source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
111
109
|
|
|
112
110
|
container.innerHTML = `
|
|
113
111
|
<ark-list>
|
|
114
112
|
<data>${JSON.stringify(source)}</data>
|
|
115
113
|
</ark-list>
|
|
116
114
|
`
|
|
117
|
-
|
|
115
|
+
|
|
118
116
|
const list = container.querySelector('ark-list')
|
|
119
|
-
|
|
117
|
+
|
|
120
118
|
const items = list.selectAll('ark-list-item')
|
|
121
119
|
|
|
122
120
|
expect(items.length).toEqual(4)
|
|
@@ -127,11 +125,11 @@ describe('List', () => {
|
|
|
127
125
|
})
|
|
128
126
|
|
|
129
127
|
it('can be provided with a list item template', async () => {
|
|
130
|
-
const source =
|
|
128
|
+
const source = [
|
|
131
129
|
{ name: 'Colombia', code: 'CO' },
|
|
132
130
|
{ name: 'Uruguay', code: 'UY' },
|
|
133
131
|
{ name: 'Brasil', code: 'BR' },
|
|
134
|
-
{ name: 'Perú', code: 'PE' }
|
|
132
|
+
{ name: 'Perú', code: 'PE' }
|
|
135
133
|
]
|
|
136
134
|
|
|
137
135
|
container.innerHTML = `
|
|
@@ -151,9 +149,9 @@ describe('List', () => {
|
|
|
151
149
|
</template>
|
|
152
150
|
</ark-list>
|
|
153
151
|
`
|
|
154
|
-
|
|
152
|
+
|
|
155
153
|
const list = container.querySelector('ark-list')
|
|
156
|
-
|
|
154
|
+
|
|
157
155
|
const items = list.selectAll('ark-list-item')
|
|
158
156
|
|
|
159
157
|
expect(items.length).toEqual(4)
|
|
@@ -172,7 +170,7 @@ describe('List', () => {
|
|
|
172
170
|
})
|
|
173
171
|
|
|
174
172
|
it('can be render simple lists with an item template', async () => {
|
|
175
|
-
const source =
|
|
173
|
+
const source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
176
174
|
|
|
177
175
|
container.innerHTML = `
|
|
178
176
|
<ark-list>
|
|
@@ -182,9 +180,9 @@ describe('List', () => {
|
|
|
182
180
|
</template>
|
|
183
181
|
</ark-list>
|
|
184
182
|
`
|
|
185
|
-
|
|
183
|
+
|
|
186
184
|
const list = container.querySelector('ark-list')
|
|
187
|
-
|
|
185
|
+
|
|
188
186
|
const items = list.selectAll('ark-list-item')
|
|
189
187
|
|
|
190
188
|
expect(items.length).toEqual(4)
|
|
@@ -199,7 +197,7 @@ describe('List', () => {
|
|
|
199
197
|
})
|
|
200
198
|
|
|
201
199
|
it('can be rendered again given a new array through init', async () => {
|
|
202
|
-
let source =
|
|
200
|
+
let source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
203
201
|
container.innerHTML = `
|
|
204
202
|
<ark-list>
|
|
205
203
|
<data hidden>${JSON.stringify(source)}</data>
|
|
@@ -220,7 +218,7 @@ describe('List', () => {
|
|
|
220
218
|
expect(items[3].innerHTML.replace(/\s/g, '')).toEqual(
|
|
221
219
|
'<span><strong>Perú</strong></span>')
|
|
222
220
|
|
|
223
|
-
source =
|
|
221
|
+
source = ['Ecuador', 'Panama', 'Venezuela', 'USA']
|
|
224
222
|
list.init({ source }).render()
|
|
225
223
|
items = list.selectAll('ark-list-item')
|
|
226
224
|
|
|
@@ -236,7 +234,7 @@ describe('List', () => {
|
|
|
236
234
|
})
|
|
237
235
|
|
|
238
236
|
it('listens to delete events to remove its items', () => {
|
|
239
|
-
|
|
237
|
+
const source = ['Colombia', 'Uruguay', 'Brasil', 'Perú']
|
|
240
238
|
container.innerHTML = `
|
|
241
239
|
<ark-list>
|
|
242
240
|
<data hidden>${JSON.stringify(source)}</data>
|
|
@@ -260,7 +258,7 @@ describe('List', () => {
|
|
|
260
258
|
|
|
261
259
|
button = list.querySelector('[data-colombia]')
|
|
262
260
|
items = list.selectAll('ark-list-item')
|
|
263
|
-
|
|
261
|
+
|
|
264
262
|
expect(items.length).toEqual(3)
|
|
265
263
|
expect(button).toBeNull()
|
|
266
264
|
})
|
|
@@ -32,7 +32,7 @@ export class Paginator extends Component {
|
|
|
32
32
|
<div paginator-listen on-click="_move" class="ark-paginator__pages">
|
|
33
33
|
${this.currentPages.map((page) => (
|
|
34
34
|
`<button ${page == this.currentPage ? 'active' : ''}
|
|
35
|
-
data-page="${page}">${page}</button>`)).
|
|
35
|
+
data-page="${page}">${page}</button>`)).join('')}
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
<div class="ark-paginator__buttons">
|
|
@@ -56,7 +56,7 @@ export class Paginator extends Component {
|
|
|
56
56
|
let startPage = Math.max(currentPage - Math.trunc(displayedPages / 2), 1)
|
|
57
57
|
startPage = Math.min(1 + this.totalPages - displayedPages, startPage)
|
|
58
58
|
|
|
59
|
-
return Array.from({length: displayedPages}, (_, i) => i + startPage)
|
|
59
|
+
return Array.from({ length: displayedPages }, (_, i) => i + startPage)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
_notifyChange () {
|
|
@@ -13,7 +13,7 @@ describe('Paginator', () => {
|
|
|
13
13
|
container = null
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
it('can be instantiated',()=>{
|
|
16
|
+
it('can be instantiated', () => {
|
|
17
17
|
container.innerHTML = /* html */ `
|
|
18
18
|
<ark-paginator></ark-paginator>
|
|
19
19
|
`
|
|
@@ -22,21 +22,20 @@ describe('Paginator', () => {
|
|
|
22
22
|
expect(paginator).toBe(paginator.init())
|
|
23
23
|
})
|
|
24
24
|
|
|
25
|
-
|
|
26
25
|
it('can be instantiated with parameters', () => {
|
|
27
26
|
container.innerHTML = /* html */ `
|
|
28
27
|
<ark-paginator page-size="12" displayed-pages="5"></ark-paginator>
|
|
29
28
|
`
|
|
30
29
|
const paginator = container.querySelector('ark-paginator')
|
|
31
|
-
paginator.init({collectionSize: 120, currentPage: 4})
|
|
30
|
+
paginator.init({ collectionSize: 120, currentPage: 4 })
|
|
32
31
|
|
|
33
32
|
expect(paginator.pageSize).toBe('12')
|
|
34
33
|
expect(paginator.collectionSize).toBe('120')
|
|
35
34
|
expect(paginator.currentPage).toBe('4')
|
|
36
35
|
expect(paginator.displayedPages).toBe('5')
|
|
37
36
|
expect(paginator.totalPages).toBe(10)
|
|
38
|
-
|
|
39
|
-
paginator.init({collectionSize: 120, pageSize: 10})
|
|
37
|
+
|
|
38
|
+
paginator.init({ collectionSize: 120, pageSize: 10 })
|
|
40
39
|
expect(paginator.totalPages).toBe(12)
|
|
41
40
|
})
|
|
42
41
|
|
|
@@ -50,38 +49,37 @@ describe('Paginator', () => {
|
|
|
50
49
|
expect(paginator.currentPages).toEqual([1, 2, 3, 4, 5])
|
|
51
50
|
expect(paginator.totalPages).toEqual(10)
|
|
52
51
|
|
|
53
|
-
paginator.init({currentPage: 3})
|
|
52
|
+
paginator.init({ currentPage: 3 })
|
|
54
53
|
expect(paginator.currentPages).toEqual([1, 2, 3, 4, 5])
|
|
55
54
|
|
|
56
|
-
paginator.init({currentPage: 4})
|
|
55
|
+
paginator.init({ currentPage: 4 })
|
|
57
56
|
expect(paginator.currentPages).toEqual([2, 3, 4, 5, 6])
|
|
58
57
|
|
|
59
|
-
paginator.init({currentPage: 5})
|
|
58
|
+
paginator.init({ currentPage: 5 })
|
|
60
59
|
expect(paginator.currentPages).toEqual([3, 4, 5, 6, 7])
|
|
61
60
|
|
|
62
|
-
paginator.init({currentPage: 7})
|
|
61
|
+
paginator.init({ currentPage: 7 })
|
|
63
62
|
expect(paginator.currentPages).toEqual([5, 6, 7, 8, 9])
|
|
64
63
|
|
|
65
|
-
paginator.init({currentPage: 8})
|
|
64
|
+
paginator.init({ currentPage: 8 })
|
|
66
65
|
expect(paginator.currentPages).toEqual([6, 7, 8, 9, 10])
|
|
67
66
|
|
|
68
|
-
paginator.init({currentPage: 9})
|
|
67
|
+
paginator.init({ currentPage: 9 })
|
|
69
68
|
expect(paginator.currentPages).toEqual([6, 7, 8, 9, 10])
|
|
70
69
|
|
|
71
|
-
paginator.init({currentPage: 10})
|
|
70
|
+
paginator.init({ currentPage: 10 })
|
|
72
71
|
expect(paginator.currentPages).toEqual([6, 7, 8, 9, 10])
|
|
73
72
|
|
|
74
|
-
paginator.init({displayedPages: 6, currentPage: 5})
|
|
73
|
+
paginator.init({ displayedPages: 6, currentPage: 5 })
|
|
75
74
|
expect(paginator.currentPages).toEqual([2, 3, 4, 5, 6, 7])
|
|
76
75
|
|
|
77
|
-
paginator.init({displayedPages: 6, currentPage: 7})
|
|
76
|
+
paginator.init({ displayedPages: 6, currentPage: 7 })
|
|
78
77
|
expect(paginator.currentPages).toEqual([4, 5, 6, 7, 8, 9])
|
|
79
78
|
|
|
80
|
-
paginator.init({displayedPages: 6, currentPage: 9})
|
|
79
|
+
paginator.init({ displayedPages: 6, currentPage: 9 })
|
|
81
80
|
expect(paginator.currentPages).toEqual([5, 6, 7, 8, 9, 10])
|
|
82
81
|
})
|
|
83
82
|
|
|
84
|
-
|
|
85
83
|
it('enables and notifies page changes', () => {
|
|
86
84
|
container.innerHTML = /* html */ `
|
|
87
85
|
<ark-paginator collection-size="100" page-size="10"
|
|
@@ -120,12 +118,11 @@ describe('Paginator', () => {
|
|
|
120
118
|
|
|
121
119
|
paginator.select('[on-click="_first"]').click()
|
|
122
120
|
expect(paginator.currentPage).toEqual('1')
|
|
123
|
-
|
|
121
|
+
|
|
124
122
|
paginator.select('[on-click="_last"]').click()
|
|
125
123
|
expect(paginator.currentPage).toEqual('10')
|
|
126
124
|
|
|
127
125
|
paginator.select('[on-click="_next"]').click()
|
|
128
126
|
expect(paginator.currentPage).toEqual('10')
|
|
129
|
-
|
|
130
127
|
})
|
|
131
128
|
})
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Component } from
|
|
2
|
-
import styles from
|
|
1
|
+
import { Component } from '../../../base/component/index.js'
|
|
2
|
+
import styles from '../styles/index.js'
|
|
3
3
|
|
|
4
|
-
const tag =
|
|
4
|
+
const tag = 'ark-spinner'
|
|
5
5
|
export class Spinner extends Component {
|
|
6
|
-
init(context = {}) {
|
|
7
|
-
this.scale = context.scale || this.scale ||
|
|
8
|
-
this.type = context.type || this.type ||
|
|
6
|
+
init (context = {}) {
|
|
7
|
+
this.scale = context.scale || this.scale || '1'
|
|
8
|
+
this.type = context.type || this.type || 'circle'
|
|
9
9
|
|
|
10
10
|
return super.init()
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
reflectedProperties() {
|
|
14
|
-
return [
|
|
13
|
+
reflectedProperties () {
|
|
14
|
+
return ['scale', 'type']
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
render() {
|
|
17
|
+
render () {
|
|
18
18
|
this.innerHTML = /* html */ `
|
|
19
19
|
${this.spinnerType(this.type)}
|
|
20
20
|
`
|
|
@@ -22,20 +22,20 @@ export class Spinner extends Component {
|
|
|
22
22
|
return super.render()
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
setScale(scale) {
|
|
25
|
+
setScale (scale) {
|
|
26
26
|
this.style.setProperty('transform', `scale(${scale})`)
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/** @returns {HTMLElement} */
|
|
30
|
-
get loader() {
|
|
31
|
-
return this.querySelector(
|
|
30
|
+
get loader () {
|
|
31
|
+
return this.querySelector('[data-loader]')
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
spinnerType(type) {
|
|
35
|
-
let content =
|
|
34
|
+
spinnerType (type) {
|
|
35
|
+
let content = ''
|
|
36
36
|
|
|
37
37
|
if (type === 'circle') {
|
|
38
|
-
content = /*html*/ `
|
|
38
|
+
content = /* html */ `
|
|
39
39
|
<div data-loader class="sk-fading-circle">
|
|
40
40
|
<div class="sk-circle1 sk-circle"></div>
|
|
41
41
|
<div class="sk-circle2 sk-circle"></div>
|
|
@@ -52,7 +52,7 @@ export class Spinner extends Component {
|
|
|
52
52
|
</div>
|
|
53
53
|
`
|
|
54
54
|
} else if (type === 'chase') {
|
|
55
|
-
content = /*html*/ `
|
|
55
|
+
content = /* html */ `
|
|
56
56
|
<div data-loader class="sk-chase">
|
|
57
57
|
<div class="sk-chase-dot"></div>
|
|
58
58
|
<div class="sk-chase-dot"></div>
|
|
@@ -63,7 +63,7 @@ export class Spinner extends Component {
|
|
|
63
63
|
</div>
|
|
64
64
|
`
|
|
65
65
|
} else if (type === 'rect') {
|
|
66
|
-
content = /*html*/ `
|
|
66
|
+
content = /* html */ `
|
|
67
67
|
<div data-loader class="spinner">
|
|
68
68
|
<div class="rect1"></div>
|
|
69
69
|
<div class="rect2"></div>
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import styles from './ark.css.js'
|
|
2
|
-
export default styles
|
|
2
|
+
export default styles
|
|
@@ -2,16 +2,16 @@ import { Component } from '../../../base/component/index.js'
|
|
|
2
2
|
|
|
3
3
|
const tag = 'ark-splitview-detail'
|
|
4
4
|
export class SplitViewDetail extends Component {
|
|
5
|
-
constructor() {
|
|
5
|
+
constructor () {
|
|
6
6
|
super()
|
|
7
7
|
this.addEventListener(
|
|
8
8
|
'close', this.onClose.bind(this))
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
init(context = {}) {
|
|
11
|
+
init (context = {}) {
|
|
12
12
|
this.binding = 'splitview-detail-listen'
|
|
13
13
|
|
|
14
|
-
const [main] = this.slots
|
|
14
|
+
const [main] = this.slots.general
|
|
15
15
|
|
|
16
16
|
this.main = this.main || main
|
|
17
17
|
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Component } from
|
|
2
|
-
import
|
|
1
|
+
import { Component } from 'base/component'
|
|
2
|
+
import './splitview.detail.js'
|
|
3
3
|
|
|
4
4
|
class MockMain extends Component {
|
|
5
|
-
init(context = {}) {
|
|
5
|
+
init (context = {}) {
|
|
6
6
|
this.name = this.name || context.name || null
|
|
7
7
|
return super.init(context)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
render() {
|
|
10
|
+
render () {
|
|
11
11
|
if (this.name) {
|
|
12
12
|
this.content = `${this.name}`
|
|
13
13
|
}
|
|
14
14
|
return super.render()
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
Component.define(
|
|
17
|
+
Component.define('mock-main', MockMain)
|
|
18
18
|
|
|
19
|
-
describe(
|
|
19
|
+
describe('SplitViewDetail', () => {
|
|
20
20
|
let container = null
|
|
21
21
|
beforeEach(() => {
|
|
22
|
-
container = document.createElement(
|
|
22
|
+
container = document.createElement('div')
|
|
23
23
|
document.body.appendChild(container)
|
|
24
24
|
})
|
|
25
25
|
|
|
@@ -28,63 +28,63 @@ describe("SplitViewDetail", () => {
|
|
|
28
28
|
container = null
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
-
it(
|
|
31
|
+
it('can be instantiated', () => {
|
|
32
32
|
container.innerHTML = `
|
|
33
33
|
<ark-splitview-detail>
|
|
34
34
|
</ark-splitview-detail>
|
|
35
35
|
`
|
|
36
|
-
const detail = container.querySelector(
|
|
36
|
+
const detail = container.querySelector('ark-splitview-detail')
|
|
37
37
|
expect(detail).toBeTruthy()
|
|
38
38
|
|
|
39
39
|
expect(detail).toBe(detail.init())
|
|
40
40
|
})
|
|
41
41
|
|
|
42
|
-
it(
|
|
43
|
-
container.innerHTML = /*html */`
|
|
42
|
+
it('can be instantiated with an inner main Component', () => {
|
|
43
|
+
container.innerHTML = /* html */`
|
|
44
44
|
<ark-splitview-detail>
|
|
45
45
|
<mock-main>MAIN CONTENT</mock-main>
|
|
46
46
|
</ark-splitview-detail>
|
|
47
47
|
`
|
|
48
|
-
const detail = container.querySelector(
|
|
48
|
+
const detail = container.querySelector('ark-splitview-detail')
|
|
49
49
|
|
|
50
|
-
expect(detail.firstElementChild.textContent).toEqual(
|
|
50
|
+
expect(detail.firstElementChild.textContent).toEqual('MAIN CONTENT')
|
|
51
51
|
})
|
|
52
52
|
|
|
53
|
-
it(
|
|
53
|
+
it('can initialize its main Component', () => {
|
|
54
54
|
container.innerHTML = /* html */`
|
|
55
55
|
<ark-splitview-detail>
|
|
56
56
|
<mock-main></mock-main>
|
|
57
57
|
</ark-splitview-detail>
|
|
58
58
|
`
|
|
59
|
-
const detail = container.querySelector(
|
|
59
|
+
const detail = container.querySelector('ark-splitview-detail')
|
|
60
60
|
|
|
61
|
-
detail.init({ name:
|
|
61
|
+
detail.init({ name: 'Servagro' }).render()
|
|
62
62
|
|
|
63
|
-
expect(detail.firstElementChild.textContent).toEqual(
|
|
63
|
+
expect(detail.firstElementChild.textContent).toEqual('Servagro')
|
|
64
64
|
})
|
|
65
65
|
|
|
66
|
-
it(
|
|
66
|
+
it('can manipulate its hidden attribute', () => {
|
|
67
67
|
container.innerHTML = /* html */`
|
|
68
68
|
<ark-splitview-detail>
|
|
69
69
|
<mock-main></mock-main>
|
|
70
70
|
</ark-splitview-detail>
|
|
71
71
|
`
|
|
72
|
-
const detail = container.querySelector(
|
|
72
|
+
const detail = container.querySelector('ark-splitview-detail')
|
|
73
73
|
|
|
74
74
|
detail.show()
|
|
75
|
-
expect(detail.hasAttribute(
|
|
75
|
+
expect(detail.hasAttribute('hidden')).toBeFalsy()
|
|
76
76
|
|
|
77
77
|
detail.hide()
|
|
78
|
-
expect(detail.hasAttribute(
|
|
78
|
+
expect(detail.hasAttribute('hidden')).toBeTruthy()
|
|
79
79
|
})
|
|
80
80
|
|
|
81
|
-
it(
|
|
81
|
+
it('listens to close events to hide itself', () => {
|
|
82
82
|
container.innerHTML = /* html */`
|
|
83
83
|
<ark-splitview-detail>
|
|
84
84
|
<mock-main></mock-main>
|
|
85
85
|
</ark-splitview-detail>
|
|
86
86
|
`
|
|
87
|
-
const detail = container.querySelector(
|
|
87
|
+
const detail = container.querySelector('ark-splitview-detail')
|
|
88
88
|
detail.dispatchEvent(new Event('close'))
|
|
89
89
|
|
|
90
90
|
expect(detail.hasAttribute('hidden')).toBeTruthy()
|
|
@@ -2,14 +2,14 @@ import { Component, css } from '../../../base/component/index.js'
|
|
|
2
2
|
|
|
3
3
|
const tag = 'ark-splitview'
|
|
4
4
|
export class SplitView extends Component {
|
|
5
|
-
constructor() {
|
|
5
|
+
constructor () {
|
|
6
6
|
super()
|
|
7
7
|
this.binding = 'splitview-listen'
|
|
8
8
|
this.setDimensions()
|
|
9
9
|
globalThis.addEventListener('resize', this.setDimensions.bind(this))
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
setDimensions() {
|
|
12
|
+
setDimensions () {
|
|
13
13
|
this.style.setProperty('--inner-height', `${innerHeight}px`)
|
|
14
14
|
this.style.setProperty('--inner-width', `${innerWidth}px`)
|
|
15
15
|
}
|
|
@@ -44,7 +44,7 @@ export class SplitView extends Component {
|
|
|
44
44
|
|
|
45
45
|
const context = event.detail
|
|
46
46
|
this.renderDetail(context)
|
|
47
|
-
this.detail
|
|
47
|
+
this.detail.show()
|
|
48
48
|
|
|
49
49
|
this.emit('detail-change', context)
|
|
50
50
|
}
|
|
@@ -5,10 +5,10 @@ export class SplitViewMaster extends Component {
|
|
|
5
5
|
constructor () {
|
|
6
6
|
super()
|
|
7
7
|
this.addEventListener(
|
|
8
|
-
this
|
|
8
|
+
this.masterEvent, this.onMasterEvent.bind(this))
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
init(context = {}) {
|
|
10
|
+
|
|
11
|
+
init (context = {}) {
|
|
12
12
|
this.binding = 'splitview-master-listen'
|
|
13
13
|
return super.init(context)
|
|
14
14
|
}
|
|
@@ -13,7 +13,7 @@ describe('SplitViewMaster', () => {
|
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
it('can be instantiated', () => {
|
|
16
|
-
container.innerHTML = /*html*/`
|
|
16
|
+
container.innerHTML = /* html */`
|
|
17
17
|
<ark-splitview-master>
|
|
18
18
|
</ark-splitview-master>
|
|
19
19
|
`
|
|
@@ -46,7 +46,7 @@ describe('SplitViewMaster', () => {
|
|
|
46
46
|
const button = master.select('button')
|
|
47
47
|
|
|
48
48
|
let masterEvent = null
|
|
49
|
-
master.addEventListener('master-change', (event) => {masterEvent = event})
|
|
49
|
+
master.addEventListener('master-change', (event) => { masterEvent = event })
|
|
50
50
|
|
|
51
51
|
button.click()
|
|
52
52
|
|
|
@@ -4,32 +4,30 @@ import './splitview.detail'
|
|
|
4
4
|
import './splitview.master.js'
|
|
5
5
|
|
|
6
6
|
class NestedMaster extends Component {
|
|
7
|
-
constructor() {
|
|
7
|
+
constructor () {
|
|
8
8
|
super()
|
|
9
9
|
this.addEventListener('click', (_) => {
|
|
10
|
-
this.emit('nested:master', {value: 'NESTED MASTER VALUE'})
|
|
11
|
-
|
|
10
|
+
this.emit('nested:master', { value: 'NESTED MASTER VALUE' })
|
|
12
11
|
})
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
Component.define('nested-master', NestedMaster)
|
|
16
15
|
|
|
17
16
|
class NestedDetail extends Component {
|
|
18
|
-
init(context) {
|
|
19
|
-
if(!context.value) return super.init()
|
|
17
|
+
init (context) {
|
|
18
|
+
if (!context.value) return super.init()
|
|
20
19
|
|
|
21
20
|
this.value = context.value
|
|
22
21
|
return super.init()
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
render() {
|
|
24
|
+
render () {
|
|
26
25
|
this.content = this.value
|
|
27
26
|
return super.render()
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
Component.define('nested-detail', NestedDetail)
|
|
31
30
|
|
|
32
|
-
|
|
33
31
|
describe('SplitView', () => {
|
|
34
32
|
let container = null
|
|
35
33
|
beforeEach(() => {
|