@budibase/bbui 1.0.27-alpha.1 → 1.0.27-alpha.5
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/dist/bbui.es.js +1 -1
- package/dist/bbui.es.js.map +1 -1
- package/package.json +2 -2
- package/src/Drawer/Drawer.svelte +0 -8
- package/src/Table/BoldRenderer.svelte +11 -0
- package/src/Table/CodeRenderer.svelte +5 -0
- package/src/Table/Table.svelte +2 -1
- package/src/index.js +7 -0
- package/src/utils/helpers.js +58 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/bbui",
|
|
3
3
|
"description": "A UI solution used in the different Budibase projects.",
|
|
4
|
-
"version": "1.0.27-alpha.
|
|
4
|
+
"version": "1.0.27-alpha.5",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"svelte": "src/index.js",
|
|
7
7
|
"module": "dist/bbui.es.js",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"svelte-flatpickr": "^3.2.3",
|
|
83
83
|
"svelte-portal": "^1.0.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "48d354444d658d4c820897ec5ab8273e0ef84310"
|
|
86
86
|
}
|
package/src/Drawer/Drawer.svelte
CHANGED
|
@@ -21,16 +21,8 @@
|
|
|
21
21
|
}
|
|
22
22
|
visible = false
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
function handleKey(e) {
|
|
26
|
-
if (visible && e.key === "Escape") {
|
|
27
|
-
hide()
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
24
|
</script>
|
|
31
25
|
|
|
32
|
-
<svelte:window on:keydown={handleKey} />
|
|
33
|
-
|
|
34
26
|
{#if visible}
|
|
35
27
|
<Portal>
|
|
36
28
|
<section class:fillWidth class="drawer" transition:slide>
|
package/src/Table/Table.svelte
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import CellRenderer from "./CellRenderer.svelte"
|
|
5
5
|
import SelectEditRenderer from "./SelectEditRenderer.svelte"
|
|
6
6
|
import { cloneDeep } from "lodash"
|
|
7
|
+
import { deepGet } from "../utils/helpers"
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The expected schema is our normal couch schemas for our tables.
|
|
@@ -318,7 +319,7 @@
|
|
|
318
319
|
{customRenderers}
|
|
319
320
|
{row}
|
|
320
321
|
schema={schema[field]}
|
|
321
|
-
value={row
|
|
322
|
+
value={deepGet(row, field)}
|
|
322
323
|
on:clickrelationship
|
|
323
324
|
>
|
|
324
325
|
<slot />
|
package/src/index.js
CHANGED
|
@@ -61,6 +61,10 @@ export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte"
|
|
|
61
61
|
export { default as InlineAlert } from "./InlineAlert/InlineAlert.svelte"
|
|
62
62
|
export { default as Banner } from "./Banner/Banner.svelte"
|
|
63
63
|
|
|
64
|
+
// Renderers
|
|
65
|
+
export { default as BoldRenderer } from "./Table/BoldRenderer.svelte"
|
|
66
|
+
export { default as CodeRenderer } from "./Table/CodeRenderer.svelte"
|
|
67
|
+
|
|
64
68
|
// Typography
|
|
65
69
|
export { default as Body } from "./Typography/Body.svelte"
|
|
66
70
|
export { default as Heading } from "./Typography/Heading.svelte"
|
|
@@ -77,3 +81,6 @@ export { default as clickOutside } from "./Actions/click_outside"
|
|
|
77
81
|
|
|
78
82
|
// Stores
|
|
79
83
|
export { notifications, createNotificationStore } from "./Stores/notifications"
|
|
84
|
+
|
|
85
|
+
// Utils
|
|
86
|
+
export * from "./utils/helpers"
|
package/src/utils/helpers.js
CHANGED
|
@@ -6,3 +6,61 @@ export const generateID = () => {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Gets a key within an object. The key supports dot syntax for retrieving deep
|
|
12
|
+
* fields - e.g. "a.b.c".
|
|
13
|
+
* Exact matches of keys with dots in them take precedence over nested keys of
|
|
14
|
+
* the same path - e.g. getting "a.b" from { "a.b": "foo", a: { b: "bar" } }
|
|
15
|
+
* will return "foo" over "bar".
|
|
16
|
+
* @param obj the object
|
|
17
|
+
* @param key the key
|
|
18
|
+
* @return {*|null} the value or null if a value was not found for this key
|
|
19
|
+
*/
|
|
20
|
+
export const deepGet = (obj, key) => {
|
|
21
|
+
if (!obj || !key) {
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
25
|
+
return obj[key]
|
|
26
|
+
}
|
|
27
|
+
const split = key.split(".")
|
|
28
|
+
for (let i = 0; i < split.length; i++) {
|
|
29
|
+
obj = obj?.[split[i]]
|
|
30
|
+
}
|
|
31
|
+
return obj
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Sets a key within an object. The key supports dot syntax for retrieving deep
|
|
36
|
+
* fields - e.g. "a.b.c".
|
|
37
|
+
* Exact matches of keys with dots in them take precedence over nested keys of
|
|
38
|
+
* the same path - e.g. setting "a.b" of { "a.b": "foo", a: { b: "bar" } }
|
|
39
|
+
* will override the value "foo" rather than "bar".
|
|
40
|
+
* If a deep path is specified and the parent keys don't exist then these will
|
|
41
|
+
* be created.
|
|
42
|
+
* @param obj the object
|
|
43
|
+
* @param key the key
|
|
44
|
+
* @param value the value
|
|
45
|
+
*/
|
|
46
|
+
export const deepSet = (obj, key, value) => {
|
|
47
|
+
if (!obj || !key) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
51
|
+
obj[key] = value
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
const split = key.split(".")
|
|
55
|
+
for (let i = 0; i < split.length - 1; i++) {
|
|
56
|
+
const nextKey = split[i]
|
|
57
|
+
if (obj && obj[nextKey] == null) {
|
|
58
|
+
obj[nextKey] = {}
|
|
59
|
+
}
|
|
60
|
+
obj = obj?.[nextKey]
|
|
61
|
+
}
|
|
62
|
+
if (!obj) {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
obj[split[split.length - 1]] = value
|
|
66
|
+
}
|