@rokkit/actions 1.0.0-next.92 → 1.0.0-next.93
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/package.json +12 -12
- package/src/fillable.js +3 -3
- package/src/hierarchy.js +1 -1
- package/src/lib/viewport.js +4 -2
- package/src/navigator.js +2 -2
- package/src/switchable.js +8 -9
- package/src/traversable.js +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/actions",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.93",
|
|
4
4
|
"description": "Contains generic actions that can be used in various components.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
|
16
16
|
"@testing-library/svelte": "^4.1.0",
|
|
17
|
-
"@types/ramda": "^0.29.
|
|
18
|
-
"@vitest/coverage-v8": "^1.
|
|
19
|
-
"@vitest/ui": "~1.
|
|
17
|
+
"@types/ramda": "^0.29.11",
|
|
18
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
19
|
+
"@vitest/ui": "~1.4.0",
|
|
20
20
|
"jsdom": "^24.0.0",
|
|
21
|
-
"svelte": "^4.2.
|
|
22
|
-
"typescript": "^5.
|
|
23
|
-
"vite": "^5.
|
|
24
|
-
"vitest": "~1.
|
|
25
|
-
"shared-config": "1.0.0-next.
|
|
26
|
-
"validators": "1.0.0-next.
|
|
21
|
+
"svelte": "^4.2.12",
|
|
22
|
+
"typescript": "^5.4.3",
|
|
23
|
+
"vite": "^5.2.7",
|
|
24
|
+
"vitest": "~1.4.0",
|
|
25
|
+
"shared-config": "1.0.0-next.93",
|
|
26
|
+
"validators": "1.0.0-next.93"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"src/**/*.js",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"ramda": "^0.29.1",
|
|
45
|
-
"@rokkit/core": "1.0.0-next.
|
|
46
|
-
"@rokkit/stores": "1.0.0-next.
|
|
45
|
+
"@rokkit/core": "1.0.0-next.93",
|
|
46
|
+
"@rokkit/stores": "1.0.0-next.93"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"format": "prettier --write .",
|
package/src/fillable.js
CHANGED
|
@@ -10,7 +10,7 @@ export function fillable(node, { options, current, check }) {
|
|
|
10
10
|
let blanks = node.getElementsByTagName('del')
|
|
11
11
|
|
|
12
12
|
function click(event) {
|
|
13
|
-
if (
|
|
13
|
+
if (event.target.innerHTML !== '?') {
|
|
14
14
|
clear(event, node)
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -58,7 +58,7 @@ function initialize(blanks, click) {
|
|
|
58
58
|
*/
|
|
59
59
|
function fill(blanks, options, current) {
|
|
60
60
|
if (current > -1 && current < Object.keys(blanks).length) {
|
|
61
|
-
let index = options.findIndex(({ actualIndex }) => actualIndex
|
|
61
|
+
let index = options.findIndex(({ actualIndex }) => actualIndex === current)
|
|
62
62
|
if (index > -1) {
|
|
63
63
|
blanks[current].innerHTML = options[index].value
|
|
64
64
|
blanks[current].classList.remove('empty')
|
|
@@ -100,7 +100,7 @@ function validate(blanks, data) {
|
|
|
100
100
|
let index = data.options.findIndex(({ actualIndex }) => actualIndex == ref)
|
|
101
101
|
if (index > -1)
|
|
102
102
|
blanks[ref].classList.add(
|
|
103
|
-
data.options[index].expectedIndex
|
|
103
|
+
data.options[index].expectedIndex === data.options[index].actualIndex ? 'pass' : 'fail'
|
|
104
104
|
)
|
|
105
105
|
})
|
|
106
106
|
}
|
package/src/hierarchy.js
CHANGED
package/src/lib/viewport.js
CHANGED
|
@@ -38,13 +38,15 @@ export function virtualListViewport(options) {
|
|
|
38
38
|
|
|
39
39
|
if (items.length !== cache.length) {
|
|
40
40
|
cache = Array.from({ length: items.length }).fill(null)
|
|
41
|
-
if (items.length
|
|
41
|
+
if (items.length === 0) index = -1
|
|
42
42
|
}
|
|
43
43
|
current = { lower: data.start, upper: data.end }
|
|
44
44
|
|
|
45
45
|
cache = updateSizes(cache, data.sizes ?? [], current.lower)
|
|
46
46
|
averageSize =
|
|
47
|
-
cache.length
|
|
47
|
+
cache.length === 0
|
|
48
|
+
? minSize
|
|
49
|
+
: calculateSum(cache, 0, cache.length, averageSize) / cache.length
|
|
48
50
|
|
|
49
51
|
let visible = calculateSum(cache, current.lower, current.upper, averageSize, gap)
|
|
50
52
|
|
package/src/navigator.js
CHANGED
|
@@ -100,9 +100,9 @@ export function navigator(element, options) {
|
|
|
100
100
|
: target.dataset.path
|
|
101
101
|
.split(',')
|
|
102
102
|
.filter((item) => item !== '')
|
|
103
|
-
.map((item) =>
|
|
103
|
+
.map((item) => Number(item))
|
|
104
104
|
|
|
105
|
-
if (indices.length > 0 && event.target.tagName
|
|
105
|
+
if (indices.length > 0 && event.target.tagName !== 'DETAIL') {
|
|
106
106
|
path = pathFromIndices(indices, items, fields)
|
|
107
107
|
currentNode = getCurrentNode(path)
|
|
108
108
|
if (hasChildren(currentNode, path[path.length - 1].fields)) {
|
package/src/switchable.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { removeListeners, setupListeners } from './lib'
|
|
2
|
+
|
|
1
3
|
export function switchable(node, data) {
|
|
2
4
|
let index = 0
|
|
3
5
|
let { value, options, disabled } = data
|
|
@@ -10,14 +12,12 @@ export function switchable(node, data) {
|
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
const toggle = (increment = 1) => {
|
|
13
|
-
if (disabled) return
|
|
14
15
|
index = (index + increment) % options.length
|
|
15
16
|
value = options[index]
|
|
16
17
|
node.dispatchEvent(new CustomEvent('change', { detail: value }))
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
const keydown = (e) => {
|
|
20
|
-
if (disabled) return
|
|
21
21
|
if ([' ', 'Enter', 'ArrowRight', 'ArrowLeft'].includes(e.key)) {
|
|
22
22
|
e.preventDefault()
|
|
23
23
|
e.stopPropagation()
|
|
@@ -25,17 +25,16 @@ export function switchable(node, data) {
|
|
|
25
25
|
toggle(e.key === 'ArrowLeft' ? options.length - 1 : 1)
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const listeners = {
|
|
29
|
+
click: () => toggle(1),
|
|
30
|
+
keydown
|
|
31
|
+
}
|
|
29
32
|
|
|
30
33
|
update(data)
|
|
31
|
-
node
|
|
32
|
-
node.addEventListener('keydown', keydown)
|
|
34
|
+
setupListeners(node, listeners, { enabled: !disabled })
|
|
33
35
|
|
|
34
36
|
return {
|
|
35
37
|
update,
|
|
36
|
-
destroy()
|
|
37
|
-
node.removeEventListener('click', click)
|
|
38
|
-
node.removeEventListener('keydown', keydown)
|
|
39
|
-
}
|
|
38
|
+
destroy: () => removeListeners(node, listeners)
|
|
40
39
|
}
|
|
41
40
|
}
|
package/src/traversable.js
CHANGED
|
@@ -37,7 +37,7 @@ export function traversable(element, options) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const checkAndEmit = (event) => {
|
|
40
|
-
if (current
|
|
40
|
+
if (current?.item) {
|
|
41
41
|
emit(element, event, pick(['item', 'position'], current))
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -97,7 +97,7 @@ export function traversable(element, options) {
|
|
|
97
97
|
// }
|
|
98
98
|
|
|
99
99
|
// function scrollIntoView(element, position) {
|
|
100
|
-
// if (!Array.isArray(position) || position.length
|
|
100
|
+
// if (!Array.isArray(position) || position.length === 0) return
|
|
101
101
|
// const node = element.querySelector(`[data-index="${position.join(',')}"]`)
|
|
102
102
|
// if (node) node.scrollIntoView()
|
|
103
103
|
// }
|