@knowark/componarkjs 1.14.0 → 1.14.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/README.md +57 -45
- package/lib/base/component/component.js +127 -21
- package/lib/base/component/component.test.js +296 -3
- package/lib/base/component/index.js +3 -0
- package/lib/base/styles/index.js +4 -1
- package/lib/base/utils/define.js +2 -1
- package/lib/base/utils/format.js +12 -6
- package/lib/base/utils/helpers.js +31 -5
- package/lib/base/utils/index.js +1 -0
- package/lib/base/utils/slots.js +3 -2
- package/lib/base/utils/uuid.js +1 -1
- package/lib/components/audio/components/audio.js +17 -2
- package/lib/components/audio/index.js +1 -0
- package/lib/components/audio/styles/index.js +5 -1
- package/lib/components/camera/components/camera.js +10 -0
- package/lib/components/camera/index.js +1 -0
- package/lib/components/camera/styles/index.js +5 -1
- package/lib/components/capture/components/capture.js +18 -2
- package/lib/components/capture/index.js +1 -0
- package/lib/components/droparea/components/droparea-preview.js +58 -13
- package/lib/components/droparea/components/droparea-preview.test.js +82 -0
- package/lib/components/droparea/components/droparea.js +41 -2
- package/lib/components/droparea/index.js +1 -0
- package/lib/components/droparea/styles/index.js +5 -1
- package/lib/components/emit/components/emit.js +11 -1
- package/lib/components/emit/index.js +1 -0
- package/lib/components/index.js +2 -1
- package/lib/components/list/components/item.js +6 -0
- package/lib/components/list/components/list.js +18 -4
- package/lib/components/list/index.js +1 -0
- package/lib/components/paginator/components/paginator.js +34 -8
- package/lib/components/paginator/index.js +1 -0
- package/lib/components/paginator/styles/index.js +5 -1
- package/lib/components/spinner/components/spinner.js +10 -0
- package/lib/components/spinner/index.js +1 -0
- package/lib/components/spinner/styles/index.js +5 -1
- package/lib/components/splitview/components/splitview.detail.js +10 -1
- package/lib/components/splitview/components/splitview.js +18 -3
- package/lib/components/splitview/components/splitview.master.js +10 -0
- package/lib/components/splitview/index.js +1 -0
- package/lib/components/translate/components/translate.js +42 -11
- package/lib/components/translate/components/translate.test.js +169 -1
- package/lib/components/translate/index.js +1 -0
- package/lib/index.js +3 -0
- package/package.json +2 -1
- package/tsconfig.json +1 -1
- package/types/base/component/component.d.ts +43 -8
- package/types/base/component/component.d.ts.map +1 -1
- package/types/base/component/index.d.ts +4 -6
- package/types/base/component/index.d.ts.map +1 -1
- package/types/base/styles/index.d.ts +3 -2
- package/types/base/styles/index.d.ts.map +1 -1
- package/types/base/utils/define.d.ts +3 -2
- package/types/base/utils/define.d.ts.map +1 -1
- package/types/base/utils/format.d.ts +12 -6
- package/types/base/utils/format.d.ts.map +1 -1
- package/types/base/utils/helpers.d.ts +27 -7
- package/types/base/utils/helpers.d.ts.map +1 -1
- package/types/base/utils/slots.d.ts +8 -10
- package/types/base/utils/slots.d.ts.map +1 -1
- package/types/base/utils/uuid.d.ts +1 -1
- package/types/base/utils/uuid.d.ts.map +1 -1
- package/types/components/audio/components/audio.d.ts +23 -9
- package/types/components/audio/components/audio.d.ts.map +1 -1
- package/types/components/audio/styles/index.d.ts +3 -2
- package/types/components/audio/styles/index.d.ts.map +1 -1
- package/types/components/camera/components/camera.d.ts +11 -3
- package/types/components/camera/components/camera.d.ts.map +1 -1
- package/types/components/camera/styles/index.d.ts +3 -2
- package/types/components/camera/styles/index.d.ts.map +1 -1
- package/types/components/capture/components/capture.d.ts +23 -3
- package/types/components/capture/components/capture.d.ts.map +1 -1
- package/types/components/droparea/components/droparea-preview.d.ts +64 -11
- package/types/components/droparea/components/droparea-preview.d.ts.map +1 -1
- package/types/components/droparea/components/droparea.d.ts +58 -13
- package/types/components/droparea/components/droparea.d.ts.map +1 -1
- package/types/components/droparea/styles/index.d.ts +3 -2
- package/types/components/droparea/styles/index.d.ts.map +1 -1
- package/types/components/emit/components/emit.d.ts +15 -3
- package/types/components/emit/components/emit.d.ts.map +1 -1
- package/types/components/list/components/item.d.ts +8 -1
- package/types/components/list/components/item.d.ts.map +1 -1
- package/types/components/list/components/list.d.ts +23 -5
- package/types/components/list/components/list.d.ts.map +1 -1
- package/types/components/paginator/components/paginator.d.ts +32 -8
- package/types/components/paginator/components/paginator.d.ts.map +1 -1
- package/types/components/paginator/styles/index.d.ts +3 -2
- package/types/components/paginator/styles/index.d.ts.map +1 -1
- package/types/components/spinner/components/spinner.d.ts +14 -3
- package/types/components/spinner/components/spinner.d.ts.map +1 -1
- package/types/components/spinner/styles/index.d.ts +3 -2
- package/types/components/spinner/styles/index.d.ts.map +1 -1
- package/types/components/splitview/components/splitview.d.ts +22 -4
- package/types/components/splitview/components/splitview.d.ts.map +1 -1
- package/types/components/splitview/components/splitview.detail.d.ts +12 -2
- package/types/components/splitview/components/splitview.detail.d.ts.map +1 -1
- package/types/components/splitview/components/splitview.master.d.ts +12 -1
- package/types/components/splitview/components/splitview.master.d.ts.map +1 -1
- package/types/components/translate/components/translate.d.ts +44 -10
- package/types/components/translate/components/translate.d.ts.map +1 -1
|
@@ -5,6 +5,11 @@ import './droparea-preview.js'
|
|
|
5
5
|
/** @import {DropareaPreview} from './droparea-preview.js' */
|
|
6
6
|
|
|
7
7
|
const tag = 'ark-droparea'
|
|
8
|
+
/**
|
|
9
|
+
* Drag-and-drop and file input area.
|
|
10
|
+
* Emits:
|
|
11
|
+
* - `alter` with current media list details.
|
|
12
|
+
*/
|
|
8
13
|
|
|
9
14
|
export class Droparea extends Component {
|
|
10
15
|
constructor () {
|
|
@@ -13,6 +18,8 @@ export class Droparea extends Component {
|
|
|
13
18
|
this._onOpenInput = this.openInput.bind(this)
|
|
14
19
|
}
|
|
15
20
|
|
|
21
|
+
/** @param {object} context
|
|
22
|
+
* @returns {this} */
|
|
16
23
|
init (context = {}) {
|
|
17
24
|
this.fileList = []
|
|
18
25
|
this.contextFiles = context.contextFiles || this.contextFiles || []
|
|
@@ -22,6 +29,7 @@ export class Droparea extends Component {
|
|
|
22
29
|
return super.init()
|
|
23
30
|
}
|
|
24
31
|
|
|
32
|
+
/** @returns {this} */
|
|
25
33
|
render () {
|
|
26
34
|
this._grabSlots()
|
|
27
35
|
this.content = /* html */ `
|
|
@@ -43,10 +51,12 @@ export class Droparea extends Component {
|
|
|
43
51
|
return super.render()
|
|
44
52
|
}
|
|
45
53
|
|
|
54
|
+
/** @returns {string[]} */
|
|
46
55
|
reflectedProperties () {
|
|
47
56
|
return ['size', 'accept', 'maxSize', 'title']
|
|
48
57
|
}
|
|
49
58
|
|
|
59
|
+
/** @returns {Promise<void>} */
|
|
50
60
|
async load () {
|
|
51
61
|
this._detachListeners()
|
|
52
62
|
|
|
@@ -72,11 +82,13 @@ export class Droparea extends Component {
|
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
84
|
|
|
85
|
+
/** @returns {void} */
|
|
75
86
|
disconnectedCallback () {
|
|
76
87
|
this._detachListeners()
|
|
77
88
|
super.disconnectedCallback()
|
|
78
89
|
}
|
|
79
90
|
|
|
91
|
+
/** @returns {void} */
|
|
80
92
|
_detachListeners () {
|
|
81
93
|
if (this.dragDropEvents) {
|
|
82
94
|
this.dragDropEvents.forEach((eventName) => {
|
|
@@ -101,25 +113,35 @@ export class Droparea extends Component {
|
|
|
101
113
|
this.openButton?.removeEventListener('click', this._onOpenInput)
|
|
102
114
|
}
|
|
103
115
|
|
|
116
|
+
/** @param {Event} event
|
|
117
|
+
* @returns {void} */
|
|
104
118
|
openInput (event) {
|
|
105
119
|
event.stopPropagation()
|
|
106
120
|
const input = this.select('[data-input]')
|
|
107
121
|
input.click()
|
|
108
122
|
}
|
|
109
123
|
|
|
124
|
+
/** @param {Event} event
|
|
125
|
+
* @returns {void} */
|
|
110
126
|
preventDefaults (event) {
|
|
111
127
|
event.preventDefault()
|
|
112
128
|
event.stopPropagation()
|
|
113
129
|
}
|
|
114
130
|
|
|
131
|
+
/** @param {Event} event
|
|
132
|
+
* @returns {void} */
|
|
115
133
|
highlight (event) {
|
|
116
134
|
this.dropZone.classList.add('highlight')
|
|
117
135
|
}
|
|
118
136
|
|
|
137
|
+
/** @param {Event} event
|
|
138
|
+
* @returns {void} */
|
|
119
139
|
unhighlight (event) {
|
|
120
140
|
this.dropZone.classList.remove('highlight')
|
|
121
141
|
}
|
|
122
142
|
|
|
143
|
+
/** @param {DragEvent} event
|
|
144
|
+
* @returns {void} */
|
|
123
145
|
handleDrop (event) {
|
|
124
146
|
event.stopPropagation()
|
|
125
147
|
const data = event.dataTransfer
|
|
@@ -127,13 +149,17 @@ export class Droparea extends Component {
|
|
|
127
149
|
this.handleFiles(files)
|
|
128
150
|
}
|
|
129
151
|
|
|
152
|
+
/** @param {Event} event
|
|
153
|
+
* @returns {void} */
|
|
130
154
|
onChange (event) {
|
|
131
155
|
event.stopPropagation()
|
|
132
|
-
const input = event.target
|
|
156
|
+
const input = /** @type {HTMLInputElement} */ (event.target)
|
|
133
157
|
const files = input.files
|
|
134
158
|
this.handleFiles(files)
|
|
135
159
|
}
|
|
136
160
|
|
|
161
|
+
/** @param {FileList|File[]} files
|
|
162
|
+
* @returns {void} */
|
|
137
163
|
handleFiles (files) {
|
|
138
164
|
if (this.single) {
|
|
139
165
|
files = [files[0]]
|
|
@@ -163,6 +189,10 @@ export class Droparea extends Component {
|
|
|
163
189
|
this.preview.dispatchAlterEvent()
|
|
164
190
|
}
|
|
165
191
|
|
|
192
|
+
/**
|
|
193
|
+
* @param {File[]|FileList} fileList
|
|
194
|
+
* @returns {boolean}
|
|
195
|
+
*/
|
|
166
196
|
validate (fileList) {
|
|
167
197
|
if (!this.accept || this.accept.length === 0) return true
|
|
168
198
|
const acceptList = this.accept.split(',').map(
|
|
@@ -186,15 +216,20 @@ export class Droparea extends Component {
|
|
|
186
216
|
return true
|
|
187
217
|
}
|
|
188
218
|
|
|
219
|
+
/** @param {File} file
|
|
220
|
+
* @returns {boolean} */
|
|
189
221
|
maxSizeValidate (file) {
|
|
190
222
|
return true
|
|
191
223
|
}
|
|
192
224
|
|
|
225
|
+
/** @returns {void} */
|
|
193
226
|
_grabSlots() {
|
|
194
227
|
const [fileInput] = [this.slots.general].flat()
|
|
195
228
|
this.fileInput = this.fileInput ?? fileInput
|
|
196
229
|
}
|
|
197
230
|
|
|
231
|
+
/** @param {HTMLInputElement|undefined} element
|
|
232
|
+
* @returns {HTMLInputElement} */
|
|
198
233
|
_buildFileInput (element) {
|
|
199
234
|
const input = element ?? document.createElement('input')
|
|
200
235
|
const attributes = [['class', `${tag}__input`],
|
|
@@ -203,14 +238,18 @@ export class Droparea extends Component {
|
|
|
203
238
|
return input
|
|
204
239
|
}
|
|
205
240
|
|
|
241
|
+
/** @returns {HTMLFormElement} */
|
|
206
242
|
get dropZone () {
|
|
207
|
-
return
|
|
243
|
+
return /** @type {HTMLFormElement} */ (
|
|
244
|
+
this.querySelector('.ark-droparea__form'))
|
|
208
245
|
}
|
|
209
246
|
|
|
247
|
+
/** @returns {DropareaPreview} */
|
|
210
248
|
get preview () {
|
|
211
249
|
return /** @type {DropareaPreview} */ (this.select('ark-droparea-preview'))
|
|
212
250
|
}
|
|
213
251
|
|
|
252
|
+
/** @returns {Array<{name:string,type:string,size:number,url:string}>} */
|
|
214
253
|
get mediaList () {
|
|
215
254
|
return this.preview.mediaList
|
|
216
255
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Component } from "#base/index.js"
|
|
2
2
|
|
|
3
3
|
const tag = 'ark-emit'
|
|
4
|
+
/**
|
|
5
|
+
* Declarative event forwarding component.
|
|
6
|
+
*/
|
|
4
7
|
export class Emit extends Component {
|
|
5
8
|
constructor () {
|
|
6
9
|
super()
|
|
@@ -15,6 +18,8 @@ export class Emit extends Component {
|
|
|
15
18
|
return ['receive', 'dispatch', 'bind']
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
/** @param {CustomEvent} event
|
|
22
|
+
* @returns {void} */
|
|
18
23
|
handle (event) {
|
|
19
24
|
const detail = Object.assign({}, event.detail)
|
|
20
25
|
|
|
@@ -27,19 +32,22 @@ export class Emit extends Component {
|
|
|
27
32
|
|
|
28
33
|
Object.assign(detail, data)
|
|
29
34
|
|
|
30
|
-
const value = event.target
|
|
35
|
+
const value = /** @type {HTMLInputElement|null} */ (event.target)?.value
|
|
31
36
|
if (value) Object.assign(detail, { value })
|
|
32
37
|
|
|
33
38
|
const type = this.dispatch || 'emit'
|
|
34
39
|
this.emit(type, detail)
|
|
35
40
|
}
|
|
36
41
|
|
|
42
|
+
/** @param {string} selector
|
|
43
|
+
* @returns {Element|null} */
|
|
37
44
|
_pop (selector) {
|
|
38
45
|
const element = this.querySelector(selector)
|
|
39
46
|
element?.remove()
|
|
40
47
|
return element
|
|
41
48
|
}
|
|
42
49
|
|
|
50
|
+
/** @returns {any|null} */
|
|
43
51
|
_resolveBoundData () {
|
|
44
52
|
const element = this.closest(this.bind)
|
|
45
53
|
if (!element) return null
|
|
@@ -52,6 +60,8 @@ export class Emit extends Component {
|
|
|
52
60
|
}
|
|
53
61
|
}
|
|
54
62
|
|
|
63
|
+
/** @param {string} source
|
|
64
|
+
* @returns {object|null} */
|
|
55
65
|
_parseJSON (source) {
|
|
56
66
|
try {
|
|
57
67
|
return JSON.parse(source)
|
package/lib/components/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Aggregated component exports. */
|
|
1
2
|
export * from './audio/index.js'
|
|
2
3
|
export * from './camera/index.js'
|
|
3
4
|
export * from './capture/index.js'
|
|
@@ -6,4 +7,4 @@ export * from './list/index.js'
|
|
|
6
7
|
export * from './paginator/index.js'
|
|
7
8
|
export * from './spinner/index.js'
|
|
8
9
|
export * from './splitview/index.js'
|
|
9
|
-
export * from './translate/index.js'
|
|
10
|
+
export * from './translate/index.js'
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Component } from "#base/index.js"
|
|
2
2
|
|
|
3
3
|
const tag = 'ark-list-item'
|
|
4
|
+
/**
|
|
5
|
+
* Single list item for list component.
|
|
6
|
+
*/
|
|
4
7
|
export class ListItem extends Component {
|
|
8
|
+
/** @param {object} context
|
|
9
|
+
* @returns {this} */
|
|
5
10
|
init (context = {}) {
|
|
6
11
|
this.index = context.index
|
|
7
12
|
this.data = context.data || null
|
|
@@ -14,6 +19,7 @@ export class ListItem extends Component {
|
|
|
14
19
|
return ['index']
|
|
15
20
|
}
|
|
16
21
|
|
|
22
|
+
/** @returns {this} */
|
|
17
23
|
render () {
|
|
18
24
|
this.content = this.template(this.data)
|
|
19
25
|
return super.render()
|
|
@@ -3,6 +3,9 @@ import { ListItem } from './item.js'
|
|
|
3
3
|
|
|
4
4
|
const tag = 'ark-list'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* List component (array-driven rendering).
|
|
8
|
+
*/
|
|
6
9
|
export class List extends Component {
|
|
7
10
|
constructor () {
|
|
8
11
|
super()
|
|
@@ -10,7 +13,8 @@ export class List extends Component {
|
|
|
10
13
|
this.addEventListener('delete', this._onDeleted.bind(this))
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
/** @param {
|
|
16
|
+
/** @param {object} context
|
|
17
|
+
* @returns {this} */
|
|
14
18
|
init (context = {}) {
|
|
15
19
|
this.source = /** @type {Array} */ (context.source) || this.source || []
|
|
16
20
|
this.template = context.template || this.template || ((data) => `${data}`)
|
|
@@ -18,6 +22,7 @@ export class List extends Component {
|
|
|
18
22
|
return super.init()
|
|
19
23
|
}
|
|
20
24
|
|
|
25
|
+
/** @returns {this} */
|
|
21
26
|
render () {
|
|
22
27
|
const listData = this.select('data')
|
|
23
28
|
const list = this._parseJSON(listData?.textContent)
|
|
@@ -48,7 +53,10 @@ export class List extends Component {
|
|
|
48
53
|
return super.render()
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
/** @param {number} start
|
|
56
|
+
/** @param {number} start
|
|
57
|
+
* @param {number} [deleteCount=1]
|
|
58
|
+
* @returns {void}
|
|
59
|
+
*/
|
|
52
60
|
delete (start, deleteCount = 1) {
|
|
53
61
|
this.source.splice(start, deleteCount)
|
|
54
62
|
const deletions = []
|
|
@@ -59,6 +67,8 @@ export class List extends Component {
|
|
|
59
67
|
deletions.map(item => item.remove())
|
|
60
68
|
}
|
|
61
69
|
|
|
70
|
+
/** @param {string} template
|
|
71
|
+
* @returns {(data: any)=>string} */
|
|
62
72
|
_format (template) {
|
|
63
73
|
let render = null
|
|
64
74
|
|
|
@@ -80,7 +90,8 @@ export class List extends Component {
|
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
|
|
83
|
-
/** @param {MouseEvent} event
|
|
93
|
+
/** @param {MouseEvent} event
|
|
94
|
+
* @returns {void} */
|
|
84
95
|
_onSelected (event) {
|
|
85
96
|
event.stopImmediatePropagation()
|
|
86
97
|
|
|
@@ -101,7 +112,8 @@ export class List extends Component {
|
|
|
101
112
|
)
|
|
102
113
|
}
|
|
103
114
|
|
|
104
|
-
/** @param {MouseEvent} event
|
|
115
|
+
/** @param {MouseEvent} event
|
|
116
|
+
* @returns {void} */
|
|
105
117
|
_onDeleted (event) {
|
|
106
118
|
event.stopImmediatePropagation()
|
|
107
119
|
|
|
@@ -112,6 +124,8 @@ export class List extends Component {
|
|
|
112
124
|
this.delete(Number(item.index))
|
|
113
125
|
}
|
|
114
126
|
|
|
127
|
+
/** @param {string|null} source
|
|
128
|
+
* @returns {any[]|null} */
|
|
115
129
|
_parseJSON (source) {
|
|
116
130
|
if (!source) return null
|
|
117
131
|
|
|
@@ -2,7 +2,12 @@ import { Component } from '#base/index.js'
|
|
|
2
2
|
import styles from '../styles/index.js'
|
|
3
3
|
|
|
4
4
|
const tag = 'ark-paginator'
|
|
5
|
+
/**
|
|
6
|
+
* Pagination control component.
|
|
7
|
+
*/
|
|
5
8
|
export class Paginator extends Component {
|
|
9
|
+
/** @param {object} context
|
|
10
|
+
* @returns {this} */
|
|
6
11
|
init (context = {}) {
|
|
7
12
|
this.binding = 'paginator-listen'
|
|
8
13
|
this.collectionSize = (
|
|
@@ -21,6 +26,7 @@ export class Paginator extends Component {
|
|
|
21
26
|
return ['collectionSize', 'pageSize', 'displayedPages', 'currentPage']
|
|
22
27
|
}
|
|
23
28
|
|
|
29
|
+
/** @returns {this} */
|
|
24
30
|
render () {
|
|
25
31
|
this._grabSlots()
|
|
26
32
|
this.content = /* html */`
|
|
@@ -42,12 +48,13 @@ export class Paginator extends Component {
|
|
|
42
48
|
this._buildButton(this.previousButton, '_prev', '<'))
|
|
43
49
|
|
|
44
50
|
for (const page of this.currentPages) {
|
|
45
|
-
|
|
51
|
+
/** @type {[string, string][]} */
|
|
52
|
+
const attributes = [['data-page', String(page)]]
|
|
46
53
|
if ((Number(page) === Number(this.currentPage))) {
|
|
47
54
|
attributes.unshift(['active', ''])
|
|
48
55
|
}
|
|
49
56
|
this.querySelector('[data-middle]').appendChild(
|
|
50
|
-
this._buildButton(this.pageButton, null, page
|
|
57
|
+
this._buildButton(this.pageButton, null, `${page}`, attributes))
|
|
51
58
|
}
|
|
52
59
|
|
|
53
60
|
this.querySelector('[data-end]').appendChild(
|
|
@@ -58,10 +65,12 @@ export class Paginator extends Component {
|
|
|
58
65
|
return super.render()
|
|
59
66
|
}
|
|
60
67
|
|
|
68
|
+
/** @returns {number} */
|
|
61
69
|
get totalPages () {
|
|
62
70
|
return Math.ceil(this.collectionSize / this.pageSize)
|
|
63
71
|
}
|
|
64
72
|
|
|
73
|
+
/** @returns {number[]} */
|
|
65
74
|
get currentPages () {
|
|
66
75
|
const displayedPages = Math.min(
|
|
67
76
|
parseInt(this.displayedPages), this.totalPages)
|
|
@@ -72,6 +81,7 @@ export class Paginator extends Component {
|
|
|
72
81
|
return Array.from({ length: displayedPages }, (_, i) => i + startPage)
|
|
73
82
|
}
|
|
74
83
|
|
|
84
|
+
/** @returns {void} */
|
|
75
85
|
_notifyChange () {
|
|
76
86
|
const page = parseInt(this.currentPage)
|
|
77
87
|
const limit = parseInt(this.pageSize)
|
|
@@ -80,6 +90,8 @@ export class Paginator extends Component {
|
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
/** @param {number} currentPage */
|
|
93
|
+
/** @param {number} currentPage
|
|
94
|
+
* @returns {void} */
|
|
83
95
|
_setCurrentPage (currentPage) {
|
|
84
96
|
if (currentPage > 0 && currentPage <= this.totalPages) {
|
|
85
97
|
this.currentPage = currentPage
|
|
@@ -88,19 +100,22 @@ export class Paginator extends Component {
|
|
|
88
100
|
}
|
|
89
101
|
}
|
|
90
102
|
|
|
91
|
-
/** @param {Event} event
|
|
103
|
+
/** @param {Event} event
|
|
104
|
+
* @returns {void} */
|
|
92
105
|
_first (event) {
|
|
93
106
|
event.stopPropagation()
|
|
94
107
|
this._setCurrentPage(1)
|
|
95
108
|
}
|
|
96
109
|
|
|
97
|
-
/** @param {Event} event
|
|
110
|
+
/** @param {Event} event
|
|
111
|
+
* @returns {void} */
|
|
98
112
|
_prev (event) {
|
|
99
113
|
event.stopPropagation()
|
|
100
114
|
this._setCurrentPage(parseInt(this.currentPage) - 1)
|
|
101
115
|
}
|
|
102
116
|
|
|
103
|
-
/** @param {Event} event
|
|
117
|
+
/** @param {Event} event
|
|
118
|
+
* @returns {void} */
|
|
104
119
|
_move (event) {
|
|
105
120
|
event.stopPropagation()
|
|
106
121
|
const target = /** @type {HTMLElement} */ (event.target)
|
|
@@ -108,18 +123,21 @@ export class Paginator extends Component {
|
|
|
108
123
|
this._setCurrentPage(page)
|
|
109
124
|
}
|
|
110
125
|
|
|
111
|
-
/** @param {Event} event
|
|
126
|
+
/** @param {Event} event
|
|
127
|
+
* @returns {void} */
|
|
112
128
|
_next (event) {
|
|
113
129
|
event.stopPropagation()
|
|
114
130
|
this._setCurrentPage(parseInt(this.currentPage) + 1)
|
|
115
131
|
}
|
|
116
132
|
|
|
117
|
-
/** @param {Event} event
|
|
133
|
+
/** @param {Event} event
|
|
134
|
+
* @returns {void} */
|
|
118
135
|
_last (event) {
|
|
119
136
|
event.stopPropagation()
|
|
120
137
|
this._setCurrentPage(this.totalPages)
|
|
121
138
|
}
|
|
122
139
|
|
|
140
|
+
/** @returns {void} */
|
|
123
141
|
_grabSlots() {
|
|
124
142
|
const [pageButton] = [this.slots.page].flat()
|
|
125
143
|
this.pageButton = this.pageButton ?? pageButton
|
|
@@ -133,8 +151,16 @@ export class Paginator extends Component {
|
|
|
133
151
|
this.lastButton = this.lastButton ?? lastButton
|
|
134
152
|
}
|
|
135
153
|
|
|
154
|
+
/**
|
|
155
|
+
* @param {HTMLButtonElement|null} element
|
|
156
|
+
* @param {string|null} handler
|
|
157
|
+
* @param {string} content
|
|
158
|
+
* @param {Array<[string,string]>} attributes
|
|
159
|
+
* @returns {HTMLButtonElement}
|
|
160
|
+
*/
|
|
136
161
|
_buildButton (element, handler, content, attributes = []) {
|
|
137
|
-
const button =
|
|
162
|
+
const button = /** @type {HTMLButtonElement} */ (
|
|
163
|
+
(element ?? document.createElement('button')).cloneNode(true))
|
|
138
164
|
button.innerHTML = button.innerHTML || content
|
|
139
165
|
if (handler) {
|
|
140
166
|
button.setAttribute('paginator-listen', '')
|
|
@@ -2,7 +2,12 @@ import { Component } from '#base/index.js'
|
|
|
2
2
|
import styles from '../styles/index.js'
|
|
3
3
|
|
|
4
4
|
const tag = 'ark-spinner'
|
|
5
|
+
/**
|
|
6
|
+
* Configurable loading spinner component.
|
|
7
|
+
*/
|
|
5
8
|
export class Spinner extends Component {
|
|
9
|
+
/** @param {object} context
|
|
10
|
+
* @returns {this} */
|
|
6
11
|
init (context = {}) {
|
|
7
12
|
this.scale = context.scale || this.scale || '1'
|
|
8
13
|
this.type = context.type || this.type || 'circle'
|
|
@@ -14,6 +19,7 @@ export class Spinner extends Component {
|
|
|
14
19
|
return ['scale', 'type']
|
|
15
20
|
}
|
|
16
21
|
|
|
22
|
+
/** @returns {this} */
|
|
17
23
|
render () {
|
|
18
24
|
this.innerHTML = /* html */ `
|
|
19
25
|
${this.spinnerType(this.type)}
|
|
@@ -22,6 +28,8 @@ export class Spinner extends Component {
|
|
|
22
28
|
return super.render()
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
/** @param {string} scale
|
|
32
|
+
* @returns {void} */
|
|
25
33
|
setScale (scale) {
|
|
26
34
|
this.style.setProperty('transform', `scale(${scale})`)
|
|
27
35
|
}
|
|
@@ -31,6 +39,8 @@ export class Spinner extends Component {
|
|
|
31
39
|
return this.querySelector('[data-loader]')
|
|
32
40
|
}
|
|
33
41
|
|
|
42
|
+
/** @param {string} type
|
|
43
|
+
* @returns {string} */
|
|
34
44
|
spinnerType (type) {
|
|
35
45
|
let content = ''
|
|
36
46
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Component } from "#base/index.js"
|
|
2
2
|
|
|
3
3
|
const tag = 'ark-splitview-detail'
|
|
4
|
+
/**
|
|
5
|
+
* Detail slot wrapper for split-view component.
|
|
6
|
+
*/
|
|
4
7
|
export class SplitViewDetail extends Component {
|
|
5
8
|
constructor () {
|
|
6
9
|
super()
|
|
@@ -8,6 +11,8 @@ export class SplitViewDetail extends Component {
|
|
|
8
11
|
'close', this.onClose.bind(this))
|
|
9
12
|
}
|
|
10
13
|
|
|
14
|
+
/** @param {object} context
|
|
15
|
+
* @returns {this} */
|
|
11
16
|
init (context = {}) {
|
|
12
17
|
this.binding = 'splitview-detail-listen'
|
|
13
18
|
|
|
@@ -22,6 +27,7 @@ export class SplitViewDetail extends Component {
|
|
|
22
27
|
return super.init(context)
|
|
23
28
|
}
|
|
24
29
|
|
|
30
|
+
/** @returns {this} */
|
|
25
31
|
render () {
|
|
26
32
|
this.content = ''
|
|
27
33
|
this.append(this.main)
|
|
@@ -29,16 +35,19 @@ export class SplitViewDetail extends Component {
|
|
|
29
35
|
return super.render()
|
|
30
36
|
}
|
|
31
37
|
|
|
32
|
-
/** @param {Event} event
|
|
38
|
+
/** @param {Event} event
|
|
39
|
+
* @returns {void} */
|
|
33
40
|
onClose (event) {
|
|
34
41
|
event.stopPropagation()
|
|
35
42
|
this.hide()
|
|
36
43
|
}
|
|
37
44
|
|
|
45
|
+
/** @returns {void} */
|
|
38
46
|
show () {
|
|
39
47
|
this.removeAttribute('hidden')
|
|
40
48
|
}
|
|
41
49
|
|
|
50
|
+
/** @returns {void} */
|
|
42
51
|
hide () {
|
|
43
52
|
this.setAttribute('hidden', '')
|
|
44
53
|
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { Component, css } from "#base/index.js"
|
|
2
2
|
|
|
3
3
|
/** @import {SplitViewDetail} from './splitview.detail.js' */
|
|
4
|
+
/** @import {SplitViewMaster} from './splitview.master.js' */
|
|
4
5
|
|
|
5
6
|
const tag = 'ark-splitview'
|
|
7
|
+
/**
|
|
8
|
+
* Master-detail split view orchestrator.
|
|
9
|
+
*/
|
|
6
10
|
export class SplitView extends Component {
|
|
7
11
|
constructor () {
|
|
8
12
|
super()
|
|
@@ -12,6 +16,7 @@ export class SplitView extends Component {
|
|
|
12
16
|
this._master = null
|
|
13
17
|
}
|
|
14
18
|
|
|
19
|
+
/** @returns {void} */
|
|
15
20
|
setDimensions () {
|
|
16
21
|
if (typeof globalThis.innerHeight !== 'number') return
|
|
17
22
|
if (typeof globalThis.innerWidth !== 'number') return
|
|
@@ -20,18 +25,21 @@ export class SplitView extends Component {
|
|
|
20
25
|
this.style.setProperty('--inner-width', `${globalThis.innerWidth}px`)
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
/** @returns {void} */
|
|
23
29
|
connectedCallback () {
|
|
24
30
|
this.setDimensions()
|
|
25
31
|
globalThis.addEventListener('resize', this._onResize)
|
|
26
32
|
super.connectedCallback()
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
/** @returns {void} */
|
|
29
36
|
disconnectedCallback () {
|
|
30
37
|
globalThis.removeEventListener('resize', this._onResize)
|
|
31
38
|
this._removeMasterListener()
|
|
32
39
|
super.disconnectedCallback()
|
|
33
40
|
}
|
|
34
41
|
|
|
42
|
+
/** @returns {void} */
|
|
35
43
|
_setMasterListener () {
|
|
36
44
|
const master = this.master
|
|
37
45
|
if (master === this._master) return
|
|
@@ -41,34 +49,41 @@ export class SplitView extends Component {
|
|
|
41
49
|
this._master?.addEventListener('master-change', this._onMasterChange)
|
|
42
50
|
}
|
|
43
51
|
|
|
52
|
+
/** @returns {void} */
|
|
44
53
|
_removeMasterListener () {
|
|
45
54
|
if (!this._master) return
|
|
46
55
|
this._master.removeEventListener('master-change', this._onMasterChange)
|
|
47
56
|
this._master = null
|
|
48
57
|
}
|
|
49
58
|
|
|
59
|
+
/** @returns {(SplitViewMaster|null)} */
|
|
50
60
|
get master () {
|
|
51
|
-
return
|
|
61
|
+
return /** @type {SplitViewMaster|null} */ (
|
|
62
|
+
this.querySelector('ark-splitview-master'))
|
|
52
63
|
}
|
|
53
64
|
|
|
65
|
+
/** @returns {SplitViewDetail} */
|
|
54
66
|
get detail () {
|
|
55
67
|
return /** @type {SplitViewDetail} */ (this.select('ark-splitview-detail'))
|
|
56
68
|
}
|
|
57
69
|
|
|
70
|
+
/** @returns {this} */
|
|
58
71
|
render () {
|
|
59
72
|
this.renderDetail()
|
|
60
73
|
this._setMasterListener()
|
|
61
74
|
return super.render()
|
|
62
75
|
}
|
|
63
76
|
|
|
64
|
-
/** @param {
|
|
77
|
+
/** @param {object} context
|
|
78
|
+
* @returns {void} */
|
|
65
79
|
renderDetail (context = {}) {
|
|
66
80
|
if (!this.detail || !this.detail.init) return
|
|
67
81
|
|
|
68
82
|
this.detail.init(context).render()
|
|
69
83
|
}
|
|
70
84
|
|
|
71
|
-
/** @param {CustomEvent} event
|
|
85
|
+
/** @param {CustomEvent} event
|
|
86
|
+
* @returns {void} */
|
|
72
87
|
onMasterChange (event) {
|
|
73
88
|
event.stopPropagation()
|
|
74
89
|
|