@budibase/bbui 1.0.25 → 1.0.27-alpha.10

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.
@@ -6,8 +6,14 @@
6
6
  export let selected
7
7
  export let vertical = false
8
8
  export let noPadding = false
9
+ // added as a separate option as noPadding is used for vertical padding
10
+ export let noHorizPadding = false
9
11
  export let quiet = false
10
12
  export let emphasized = false
13
+ // overlay content from the tab bar onto tabs e.g. for a dropdown
14
+ export let onTop = false
15
+
16
+ let thisSelected = undefined
11
17
 
12
18
  let _id = id()
13
19
  const tab = writable({ title: selected, id: _id, emphasized })
@@ -18,9 +24,19 @@
18
24
  const dispatch = createEventDispatcher()
19
25
 
20
26
  $: {
21
- if ($tab.title !== selected) {
27
+ if (thisSelected !== selected) {
28
+ thisSelected = selected
29
+ dispatch("select", thisSelected)
30
+ } else if ($tab.title !== thisSelected) {
31
+ thisSelected = $tab.title
22
32
  selected = $tab.title
23
- dispatch("select", selected)
33
+ dispatch("select", thisSelected)
34
+ }
35
+ if ($tab.title !== thisSelected) {
36
+ tab.update(state => {
37
+ state.title = thisSelected
38
+ return state
39
+ })
24
40
  }
25
41
  }
26
42
 
@@ -59,10 +75,12 @@
59
75
  <div
60
76
  bind:this={container}
61
77
  class:quiet
78
+ class:noHorizPadding
62
79
  class="selected-border spectrum-Tabs {quiet &&
63
80
  'spectrum-Tabs--quiet'} spectrum-Tabs--{vertical
64
81
  ? 'vertical'
65
82
  : 'horizontal'}"
83
+ class:onTop
66
84
  >
67
85
  <slot />
68
86
  {#if $tab.info}
@@ -83,7 +101,9 @@
83
101
  .quiet {
84
102
  border-bottom: none !important;
85
103
  }
86
-
104
+ .onTop {
105
+ z-index: 20;
106
+ }
87
107
  .spectrum-Tabs {
88
108
  padding-left: var(--spacing-xl);
89
109
  padding-right: var(--spacing-xl);
@@ -99,6 +119,9 @@
99
119
  .spectrum-Tabs--horizontal .spectrum-Tabs-selectionIndicator {
100
120
  bottom: 0 !important;
101
121
  }
122
+ .noHorizPadding {
123
+ padding: 0;
124
+ }
102
125
  .noPadding {
103
126
  margin: 0;
104
127
  }
@@ -13,3 +13,9 @@
13
13
  >
14
14
  <slot />
15
15
  </p>
16
+
17
+ <style>
18
+ p {
19
+ font-weight: 600;
20
+ }
21
+ </style>
package/src/index.js CHANGED
@@ -59,6 +59,11 @@ export { default as Badge } from "./Badge/Badge.svelte"
59
59
  export { default as StatusLight } from "./StatusLight/StatusLight.svelte"
60
60
  export { default as ColorPicker } from "./ColorPicker/ColorPicker.svelte"
61
61
  export { default as InlineAlert } from "./InlineAlert/InlineAlert.svelte"
62
+ export { default as Banner } from "./Banner/Banner.svelte"
63
+
64
+ // Renderers
65
+ export { default as BoldRenderer } from "./Table/BoldRenderer.svelte"
66
+ export { default as CodeRenderer } from "./Table/CodeRenderer.svelte"
62
67
 
63
68
  // Typography
64
69
  export { default as Body } from "./Typography/Body.svelte"
@@ -76,3 +81,6 @@ export { default as clickOutside } from "./Actions/click_outside"
76
81
 
77
82
  // Stores
78
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
+ }