@budibase/bbui 1.0.27-alpha.0 → 1.0.27-alpha.4

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,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.0",
4
+ "version": "1.0.27-alpha.4",
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": "02df048171ce810a73736b68d1209e06c46f854d"
85
+ "gitHead": "23ca7a9750e188e0c392dc56dcdb1842eaa6d3a9"
86
86
  }
@@ -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>
@@ -0,0 +1,11 @@
1
+ <script>
2
+ export let value
3
+ </script>
4
+
5
+ <div class="bold">{value}</div>
6
+
7
+ <style>
8
+ .bold {
9
+ font-weight: bold;
10
+ }
11
+ </style>
@@ -0,0 +1,5 @@
1
+ <script>
2
+ export let value
3
+ </script>
4
+
5
+ <code>{value}</code>
@@ -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[field]}
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"
@@ -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
+ }