@rokkit/core 1.0.0-next.62 → 1.0.0-next.63
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 +3 -3
- package/src/mapping.js +10 -2
- package/src/utils.js +17 -2
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.63",
|
|
4
4
|
"description": "Core components, actions and stores for svelte apps.",
|
|
5
5
|
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"validators": "latest",
|
|
24
24
|
"vite": "^5.0.11",
|
|
25
25
|
"vitest": "~1.1.3",
|
|
26
|
-
"shared-config": "1.0.0-next.
|
|
26
|
+
"shared-config": "1.0.0-next.63"
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"src/**/*.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"date-fns": "^3.
|
|
44
|
+
"date-fns": "^3.2.0",
|
|
45
45
|
"ramda": "^0.29.1"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
package/src/mapping.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { type } from 'ramda'
|
|
1
2
|
import { defaultFields } from './constants'
|
|
3
|
+
import { isObject } from '.'
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Get the component to be used to render the item.
|
|
@@ -22,7 +24,7 @@ export function getComponent(value, fields, using) {
|
|
|
22
24
|
*/
|
|
23
25
|
export function getIcon(value, fields = defaultFields) {
|
|
24
26
|
if (fields.icon === undefined || typeof (value ?? '') !== 'object') return null
|
|
25
|
-
|
|
27
|
+
// console.log(fields.icon, fields.state, value[fields.icon][value[fields.state]])
|
|
26
28
|
return typeof value[fields.icon] == 'object'
|
|
27
29
|
? value[fields.icon][value[fields.state]]
|
|
28
30
|
: value[fields.icon]
|
|
@@ -49,7 +51,13 @@ export function getValue(node, fields = defaultFields) {
|
|
|
49
51
|
* @returns {*}
|
|
50
52
|
*/
|
|
51
53
|
export function getText(node, fields = defaultFields) {
|
|
52
|
-
|
|
54
|
+
let value = typeof node === 'object' && node !== null ? node[fields.text] : node
|
|
55
|
+
|
|
56
|
+
return value != null
|
|
57
|
+
? isObject(value)
|
|
58
|
+
? JSON.stringify(value, null, 2)
|
|
59
|
+
: value.toString()
|
|
60
|
+
: value
|
|
53
61
|
}
|
|
54
62
|
|
|
55
63
|
/**
|
package/src/utils.js
CHANGED
|
@@ -6,8 +6,23 @@ const modifiers = {
|
|
|
6
6
|
none: (value) => value
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Generates a random id
|
|
11
|
+
*
|
|
12
|
+
* @returns {string} A random id
|
|
13
|
+
*/
|
|
9
14
|
export function id() {
|
|
10
|
-
return Math.random().toString(36).
|
|
15
|
+
return Math.random().toString(36).substring(2, 9)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Check if a value is a json object
|
|
20
|
+
*
|
|
21
|
+
* @param {*} val
|
|
22
|
+
* @returns {boolean}
|
|
23
|
+
*/
|
|
24
|
+
export function isObject(val) {
|
|
25
|
+
return typeof val === 'object' && val !== null && !(val instanceof Date)
|
|
11
26
|
}
|
|
12
27
|
|
|
13
28
|
/**
|
|
@@ -82,7 +97,7 @@ export function iconShortcuts(icons, collection, variants) {
|
|
|
82
97
|
[name]: [collection, name].join(':') + suffix
|
|
83
98
|
}),
|
|
84
99
|
{}
|
|
85
|
-
|
|
100
|
+
)
|
|
86
101
|
|
|
87
102
|
return shortcuts
|
|
88
103
|
}
|