@rokkit/core 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/calendar.js +1 -8
- package/src/connector.js +1 -5
- package/src/hacks.js +1 -3
- package/src/mapped-list.js +5 -24
- package/src/mapping.js +2 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rokkit/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.58",
|
|
4
4
|
"description": "Core components, actions and stores for svelte apps.",
|
|
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/calendar.js
CHANGED
package/src/connector.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export function getLineTypes(
|
|
2
|
-
hasChildren = false,
|
|
3
|
-
parentTypes = [],
|
|
4
|
-
position = 'child'
|
|
5
|
-
) {
|
|
1
|
+
export function getLineTypes(hasChildren = false, parentTypes = [], position = 'child') {
|
|
6
2
|
let types = parentTypes.slice(0, -1).map((type) => {
|
|
7
3
|
return type === 'child' ? 'sibling' : type === 'last' ? 'empty' : type
|
|
8
4
|
})
|
package/src/hacks.js
CHANGED
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
export function adjustViewport(browser = false, small = false) {
|
|
8
8
|
if (browser) {
|
|
9
9
|
const viewportHeight =
|
|
10
|
-
window.innerHeight != window.outerHeight && small
|
|
11
|
-
? window.innerHeight + 'px'
|
|
12
|
-
: '100vh'
|
|
10
|
+
window.innerHeight != window.outerHeight && small ? window.innerHeight + 'px' : '100vh'
|
|
13
11
|
document.body.style.visibility = 'hidden'
|
|
14
12
|
document.body.style.setProperty('--viewport-height', viewportHeight)
|
|
15
13
|
document.body.style.visibility = 'visible'
|
package/src/mapped-list.js
CHANGED
|
@@ -9,13 +9,7 @@ import { equals } from 'ramda'
|
|
|
9
9
|
* @param {Array} position - The current position in the tree.
|
|
10
10
|
* @returns {Object} The found item, or null if not found.
|
|
11
11
|
*/
|
|
12
|
-
export function findItemByValue(
|
|
13
|
-
value,
|
|
14
|
-
items,
|
|
15
|
-
fields = defaultFields,
|
|
16
|
-
attr = null,
|
|
17
|
-
position = []
|
|
18
|
-
) {
|
|
12
|
+
export function findItemByValue(value, items, fields = defaultFields, attr = null, position = []) {
|
|
19
13
|
for (let i = 0; i < items.length; i++) {
|
|
20
14
|
const item = items[i]
|
|
21
15
|
|
|
@@ -84,16 +78,8 @@ export function findNearestItemBefore(position, items, fields) {
|
|
|
84
78
|
return findLastVisibleChild(items[index], [index], fields)
|
|
85
79
|
}
|
|
86
80
|
|
|
87
|
-
const sibling = findItemByIndexArray(
|
|
88
|
-
|
|
89
|
-
items,
|
|
90
|
-
fields
|
|
91
|
-
)
|
|
92
|
-
result = findLastVisibleChild(
|
|
93
|
-
sibling.item,
|
|
94
|
-
sibling.position,
|
|
95
|
-
sibling.fields
|
|
96
|
-
)
|
|
81
|
+
const sibling = findItemByIndexArray([...position.slice(0, -1), index], items, fields)
|
|
82
|
+
result = findLastVisibleChild(sibling.item, sibling.position, sibling.fields)
|
|
97
83
|
} else {
|
|
98
84
|
result = findItemByIndexArray(position.slice(0, -1), items, fields)
|
|
99
85
|
}
|
|
@@ -188,11 +174,7 @@ function getNextSiblingOrAncestor(position, items, fields) {
|
|
|
188
174
|
if (index < children.length - 1) {
|
|
189
175
|
index += 1
|
|
190
176
|
|
|
191
|
-
const sibling = findItemByIndexArray(
|
|
192
|
-
[...position.slice(0, -1), index],
|
|
193
|
-
items,
|
|
194
|
-
fields
|
|
195
|
-
)
|
|
177
|
+
const sibling = findItemByIndexArray([...position.slice(0, -1), index], items, fields)
|
|
196
178
|
return { item: sibling.item, position: sibling.position, fields }
|
|
197
179
|
} else {
|
|
198
180
|
while (index === children.length - 1) {
|
|
@@ -220,8 +202,7 @@ function getNextSiblingOrAncestor(position, items, fields) {
|
|
|
220
202
|
*/
|
|
221
203
|
export function mappedList(items, fields) {
|
|
222
204
|
const findByValue = (value) => findItemByValue(value, items, fields)
|
|
223
|
-
const findByAttribute = (value, attr) =>
|
|
224
|
-
findItemByValue(value, items, fields, attr)
|
|
205
|
+
const findByAttribute = (value, attr) => findItemByValue(value, items, fields, attr)
|
|
225
206
|
const findByIndexArray = (index) => findItemByIndexArray(index, items, fields)
|
|
226
207
|
const previous = (position) => findNearestItemBefore(position, items, fields)
|
|
227
208
|
const next = (position) => findNearestItemAfter(position, items, fields)
|
package/src/mapping.js
CHANGED
|
@@ -21,8 +21,7 @@ export function getComponent(value, fields, using) {
|
|
|
21
21
|
* @param {import('./types.js').FieldMapping} fields
|
|
22
22
|
*/
|
|
23
23
|
export function getIcon(value, fields = defaultFields) {
|
|
24
|
-
if (fields.icon === undefined || typeof (value ?? '') !== 'object')
|
|
25
|
-
return null
|
|
24
|
+
if (fields.icon === undefined || typeof (value ?? '') !== 'object') return null
|
|
26
25
|
|
|
27
26
|
return typeof value[fields.icon] == 'object'
|
|
28
27
|
? value[fields.icon][value[fields.state]]
|
|
@@ -38,9 +37,7 @@ export function getIcon(value, fields = defaultFields) {
|
|
|
38
37
|
* @returns {*}
|
|
39
38
|
*/
|
|
40
39
|
export function getValue(node, fields = defaultFields) {
|
|
41
|
-
return typeof node === 'object' && node !== null
|
|
42
|
-
? node[fields.value] ?? node[fields.text]
|
|
43
|
-
: node
|
|
40
|
+
return typeof node === 'object' && node !== null ? node[fields.value] ?? node[fields.text] : node
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
/**
|