@rokkit/actions 1.0.0-next.57 → 1.0.0-next.58
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 +2 -2
- package/src/fillable.js +1 -3
- package/src/lib/internal.js +1 -5
- package/src/lib/viewport.js +2 -10
- package/src/navigable.js +2 -4
- package/src/navigator.js +4 -9
- package/src/swipeable.js +2 -4
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.58",
|
|
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",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"validators": "latest",
|
|
25
25
|
"vite": "^4.5.0",
|
|
26
26
|
"vitest": "~0.34.6",
|
|
27
|
-
"shared-config": "1.0.0-next.
|
|
27
|
+
"shared-config": "1.0.0-next.58"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
30
|
"src/**/*.js",
|
package/src/fillable.js
CHANGED
|
@@ -100,9 +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 == data.options[index].actualIndex
|
|
104
|
-
? 'pass'
|
|
105
|
-
: 'fail'
|
|
103
|
+
data.options[index].expectedIndex == data.options[index].actualIndex ? 'pass' : 'fail'
|
|
106
104
|
)
|
|
107
105
|
})
|
|
108
106
|
}
|
package/src/lib/internal.js
CHANGED
|
@@ -139,11 +139,7 @@ export function calculateSum(sizes, lower, upper, defaultSize = 40, gap = 0) {
|
|
|
139
139
|
* @returns {Array<number|null>}
|
|
140
140
|
*/
|
|
141
141
|
export function updateSizes(sizes, values, offset = 0) {
|
|
142
|
-
let result = [
|
|
143
|
-
...sizes.slice(0, offset),
|
|
144
|
-
...values,
|
|
145
|
-
...sizes.slice(offset + values.length)
|
|
146
|
-
]
|
|
142
|
+
let result = [...sizes.slice(0, offset), ...values, ...sizes.slice(offset + values.length)]
|
|
147
143
|
|
|
148
144
|
return result
|
|
149
145
|
}
|
package/src/lib/viewport.js
CHANGED
|
@@ -44,17 +44,9 @@ export function virtualListViewport(options) {
|
|
|
44
44
|
|
|
45
45
|
cache = updateSizes(cache, data.sizes ?? [], current.lower)
|
|
46
46
|
averageSize =
|
|
47
|
-
cache.length == 0
|
|
48
|
-
? minSize
|
|
49
|
-
: calculateSum(cache, 0, cache.length, averageSize) / cache.length
|
|
47
|
+
cache.length == 0 ? minSize : calculateSum(cache, 0, cache.length, averageSize) / cache.length
|
|
50
48
|
|
|
51
|
-
let visible = calculateSum(
|
|
52
|
-
cache,
|
|
53
|
-
current.lower,
|
|
54
|
-
current.upper,
|
|
55
|
-
averageSize,
|
|
56
|
-
gap
|
|
57
|
-
)
|
|
49
|
+
let visible = calculateSum(cache, current.lower, current.upper, averageSize, gap)
|
|
58
50
|
|
|
59
51
|
if (maxVisible > 0) {
|
|
60
52
|
visibleCount = maxVisible
|
package/src/navigable.js
CHANGED
|
@@ -26,10 +26,8 @@ export function navigable(node, options) {
|
|
|
26
26
|
function updateListeners(options) {
|
|
27
27
|
if (options.enabled) actions = getKeyboardActions(node, options, handlers)
|
|
28
28
|
|
|
29
|
-
if (options.enabled && !listening)
|
|
30
|
-
|
|
31
|
-
else if (!options.enabled && listening)
|
|
32
|
-
node.removeEventListener('keydown', handleKeydown)
|
|
29
|
+
if (options.enabled && !listening) node.addEventListener('keydown', handleKeydown)
|
|
30
|
+
else if (!options.enabled && listening) node.removeEventListener('keydown', handleKeydown)
|
|
33
31
|
listening = options.enabled
|
|
34
32
|
}
|
|
35
33
|
|
package/src/navigator.js
CHANGED
|
@@ -43,8 +43,7 @@ export function navigator(element, options) {
|
|
|
43
43
|
const previousNode = currentNode
|
|
44
44
|
path = moveNext(path, items, fields)
|
|
45
45
|
currentNode = getCurrentNode(path)
|
|
46
|
-
if (previousNode !== currentNode)
|
|
47
|
-
moveTo(element, path, currentNode, idPrefix)
|
|
46
|
+
if (previousNode !== currentNode) moveTo(element, path, currentNode, idPrefix)
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
const previous = () => {
|
|
@@ -52,8 +51,7 @@ export function navigator(element, options) {
|
|
|
52
51
|
path = movePrevious(path)
|
|
53
52
|
if (path.length > 0) {
|
|
54
53
|
currentNode = getCurrentNode(path)
|
|
55
|
-
if (previousNode !== currentNode)
|
|
56
|
-
moveTo(element, path, currentNode, idPrefix)
|
|
54
|
+
if (previousNode !== currentNode) moveTo(element, path, currentNode, idPrefix)
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
const select = () => {
|
|
@@ -110,12 +108,9 @@ export function navigator(element, options) {
|
|
|
110
108
|
if (hasChildren(currentNode, path[path.length - 1].fields)) {
|
|
111
109
|
currentNode[path[path.length - 1].fields.isOpen] =
|
|
112
110
|
!currentNode[path[path.length - 1].fields.isOpen]
|
|
113
|
-
const event = currentNode[path[path.length - 1].fields.isOpen]
|
|
114
|
-
? 'expand'
|
|
115
|
-
: 'collapse'
|
|
111
|
+
const event = currentNode[path[path.length - 1].fields.isOpen] ? 'expand' : 'collapse'
|
|
116
112
|
emit(event, element, indices, currentNode)
|
|
117
|
-
} else if (currentNode !== null)
|
|
118
|
-
emit('select', element, indices, currentNode)
|
|
113
|
+
} else if (currentNode !== null) emit('select', element, indices, currentNode)
|
|
119
114
|
}
|
|
120
115
|
}
|
|
121
116
|
|
package/src/swipeable.js
CHANGED
|
@@ -88,10 +88,8 @@ function touchEnd(event, node, options, track) {
|
|
|
88
88
|
|
|
89
89
|
if (speed <= options.minSpeed) return
|
|
90
90
|
|
|
91
|
-
const isHorizontalSwipe =
|
|
92
|
-
|
|
93
|
-
const isVerticalSwipe =
|
|
94
|
-
options.vertical && Math.abs(distY) >= options.threshold
|
|
91
|
+
const isHorizontalSwipe = options.horizontal && Math.abs(distX) >= options.threshold
|
|
92
|
+
const isVerticalSwipe = options.vertical && Math.abs(distY) >= options.threshold
|
|
95
93
|
|
|
96
94
|
if (!isHorizontalSwipe && !isVerticalSwipe) return
|
|
97
95
|
|