@rokkit/actions 1.0.0-next.92 → 1.0.0-next.94

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/actions",
3
- "version": "1.0.0-next.92",
3
+ "version": "1.0.0-next.94",
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,22 +14,20 @@
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.10",
18
- "@vitest/coverage-v8": "^1.3.1",
19
- "@vitest/ui": "~1.3.1",
17
+ "@types/ramda": "^0.29.12",
18
+ "@vitest/coverage-v8": "^1.4.0",
19
+ "@vitest/ui": "~1.4.0",
20
20
  "jsdom": "^24.0.0",
21
- "svelte": "^4.2.11",
22
- "typescript": "^5.3.3",
23
- "vite": "^5.1.4",
24
- "vitest": "~1.3.1",
25
- "shared-config": "1.0.0-next.92",
26
- "validators": "1.0.0-next.92"
21
+ "svelte": "^4.2.12",
22
+ "typescript": "^5.4.4",
23
+ "vite": "^5.2.8",
24
+ "vitest": "~1.4.0",
25
+ "shared-config": "1.0.0-next.94",
26
+ "validators": "1.0.0-next.94"
27
27
  },
28
28
  "files": [
29
29
  "src/**/*.js",
30
- "src/**/*.svelte",
31
- "!src/mocks",
32
- "!src/**/*.spec.js"
30
+ "src/**/*.svelte"
33
31
  ],
34
32
  "exports": {
35
33
  "./src": "./src",
@@ -42,13 +40,12 @@
42
40
  },
43
41
  "dependencies": {
44
42
  "ramda": "^0.29.1",
45
- "@rokkit/core": "1.0.0-next.92",
46
- "@rokkit/stores": "1.0.0-next.92"
43
+ "@rokkit/core": "1.0.0-next.94",
44
+ "@rokkit/stores": "1.0.0-next.94"
47
45
  },
48
46
  "scripts": {
49
47
  "format": "prettier --write .",
50
48
  "lint": "eslint --fix .",
51
- "test:ct": "playwright test -c playwright.config.js",
52
49
  "test:ci": "vitest run",
53
50
  "test:ui": "vitest --ui",
54
51
  "test": "vitest",
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 ('?' !== event.target.innerHTML) {
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 == current)
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')
@@ -96,11 +96,11 @@ function clear(event, node) {
96
96
  * @param {import('./types').FillOptions} data
97
97
  */
98
98
  function validate(blanks, data) {
99
- Object.keys(blanks).map((ref) => {
100
- let index = data.options.findIndex(({ actualIndex }) => actualIndex == ref)
99
+ Object.keys(blanks).map((_, ref) => {
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 ? 'pass' : 'fail'
103
+ data.options[index].expectedIndex === data.options[index].actualIndex ? 'pass' : 'fail'
104
104
  )
105
105
  })
106
106
  }
package/src/hierarchy.js CHANGED
@@ -80,7 +80,7 @@ export function movePrevious(path) {
80
80
 
81
81
  const current = path[path.length - 1]
82
82
 
83
- if (current.index == 0) {
83
+ if (current.index === 0) {
84
84
  if (path.length > 1) path.pop()
85
85
  return path
86
86
  }
@@ -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 == 0) index = -1
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 == 0 ? minSize : calculateSum(cache, 0, cache.length, averageSize) / 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) => +item)
103
+ .map((item) => Number(item))
104
104
 
105
- if (indices.length > 0 && event.target.tagName != 'DETAIL') {
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 click = () => toggle(1)
28
+ const listeners = {
29
+ click: () => toggle(1),
30
+ keydown
31
+ }
29
32
 
30
33
  update(data)
31
- node.addEventListener('click', click)
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
  }
@@ -37,7 +37,7 @@ export function traversable(element, options) {
37
37
  }
38
38
 
39
39
  const checkAndEmit = (event) => {
40
- if (current && current.item) {
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 == 0) return
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
  // }