@budibase/bbui 2.3.18-alpha.16 → 2.3.18-alpha.18

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": "2.3.18-alpha.16",
4
+ "version": "2.3.18-alpha.18",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@adobe/spectrum-css-workflow-icons": "1.2.1",
41
- "@budibase/string-templates": "2.3.18-alpha.16",
41
+ "@budibase/string-templates": "2.3.18-alpha.18",
42
42
  "@spectrum-css/accordion": "3.0.24",
43
43
  "@spectrum-css/actionbutton": "1.0.1",
44
44
  "@spectrum-css/actiongroup": "1.0.1",
@@ -89,5 +89,5 @@
89
89
  "resolutions": {
90
90
  "loader-utils": "1.4.1"
91
91
  },
92
- "gitHead": "c350c15ae0869875936c804b89fcd46e4da4d8bb"
92
+ "gitHead": "082106f881e07f501794855fd1287d9e30895950"
93
93
  }
@@ -1,6 +1,9 @@
1
1
  <script>
2
2
  import "@spectrum-css/actionbutton/dist/index-vars.css"
3
3
  import { createEventDispatcher } from "svelte"
4
+ import Tooltip from "../Tooltip/Tooltip.svelte"
5
+ import { fade } from "svelte/transition"
6
+
4
7
  const dispatch = createEventDispatcher()
5
8
 
6
9
  export let quiet = false
@@ -13,6 +16,9 @@
13
16
  export let active = false
14
17
  export let fullWidth = false
15
18
  export let noPadding = false
19
+ export let tooltip = ""
20
+
21
+ let showTooltip = false
16
22
 
17
23
  function longPress(element) {
18
24
  if (!longPressable) return
@@ -35,42 +41,54 @@
35
41
  }
36
42
  </script>
37
43
 
38
- <button
39
- use:longPress
40
- class:spectrum-ActionButton--quiet={quiet}
41
- class:spectrum-ActionButton--emphasized={emphasized}
42
- class:is-selected={selected}
43
- class:noPadding
44
- class:fullWidth
45
- class="spectrum-ActionButton spectrum-ActionButton--size{size}"
46
- class:active
47
- {disabled}
48
- on:longPress
49
- on:click|preventDefault
44
+ <span
45
+ class="btn-wrap"
46
+ on:mouseover={() => (showTooltip = true)}
47
+ on:mouseleave={() => (showTooltip = false)}
48
+ on:focus={() => (showTooltip = true)}
50
49
  >
51
- {#if longPressable}
52
- <svg
53
- class="spectrum-Icon spectrum-UIIcon-CornerTriangle100 spectrum-ActionButton-hold"
54
- focusable="false"
55
- aria-hidden="true"
56
- >
57
- <use xlink:href="#spectrum-css-icon-CornerTriangle100" />
58
- </svg>
59
- {/if}
60
- {#if icon}
61
- <svg
62
- class="spectrum-Icon spectrum-Icon--size{size}"
63
- focusable="false"
64
- aria-hidden="true"
65
- aria-label={icon}
66
- >
67
- <use xlink:href="#spectrum-icon-18-{icon}" />
68
- </svg>
69
- {/if}
70
- {#if $$slots}
71
- <span class="spectrum-ActionButton-label"><slot /></span>
72
- {/if}
73
- </button>
50
+ <button
51
+ use:longPress
52
+ class:spectrum-ActionButton--quiet={quiet}
53
+ class:spectrum-ActionButton--emphasized={emphasized}
54
+ class:is-selected={selected}
55
+ class:noPadding
56
+ class:fullWidth
57
+ class="spectrum-ActionButton spectrum-ActionButton--size{size}"
58
+ class:active
59
+ {disabled}
60
+ on:longPress
61
+ on:click|preventDefault
62
+ >
63
+ {#if longPressable}
64
+ <svg
65
+ class="spectrum-Icon spectrum-UIIcon-CornerTriangle100 spectrum-ActionButton-hold"
66
+ focusable="false"
67
+ aria-hidden="true"
68
+ >
69
+ <use xlink:href="#spectrum-css-icon-CornerTriangle100" />
70
+ </svg>
71
+ {/if}
72
+ {#if icon}
73
+ <svg
74
+ class="spectrum-Icon spectrum-Icon--size{size}"
75
+ focusable="false"
76
+ aria-hidden="true"
77
+ aria-label={icon}
78
+ >
79
+ <use xlink:href="#spectrum-icon-18-{icon}" />
80
+ </svg>
81
+ {/if}
82
+ {#if $$slots}
83
+ <span class="spectrum-ActionButton-label"><slot /></span>
84
+ {/if}
85
+ {#if tooltip && showTooltip}
86
+ <div class="tooltip" in:fade={{ duration: 130, delay: 250 }}>
87
+ <Tooltip textWrapping direction="bottom" text={tooltip} />
88
+ </div>
89
+ {/if}
90
+ </button>
91
+ </span>
74
92
 
75
93
  <style>
76
94
  .fullWidth {
@@ -98,4 +116,14 @@
98
116
  .is-selected:not(.emphasized) .spectrum-Icon {
99
117
  color: var(--spectrum-global-color-gray-900);
100
118
  }
119
+ .tooltip {
120
+ position: absolute;
121
+ pointer-events: none;
122
+ left: 50%;
123
+ top: calc(100% + 4px);
124
+ width: 100vw;
125
+ max-width: 150px;
126
+ transform: translateX(-50%);
127
+ text-align: center;
128
+ }
101
129
  </style>
@@ -24,6 +24,7 @@
24
24
  export let getOptionLabel = option => option
25
25
  export let getOptionValue = option => option
26
26
  export let getOptionIcon = () => null
27
+ export let useOptionIconImage = false
27
28
  export let getOptionColour = () => null
28
29
  export let open = false
29
30
  export let readonly = false
@@ -33,6 +34,9 @@
33
34
  export let sort = false
34
35
  export let fetchTerm = null
35
36
  export let customPopoverHeight
37
+ export let align = "left"
38
+ export let footer = null
39
+
36
40
  const dispatch = createEventDispatcher()
37
41
 
38
42
  let searchTerm = null
@@ -131,7 +135,7 @@
131
135
 
132
136
  <Popover
133
137
  anchor={button}
134
- align="left"
138
+ align={align || "left"}
135
139
  bind:this={popover}
136
140
  {open}
137
141
  on:close={() => (open = false)}
@@ -186,7 +190,16 @@
186
190
  >
187
191
  {#if getOptionIcon(option, idx)}
188
192
  <span class="option-extra icon">
189
- <Icon size="S" name={getOptionIcon(option, idx)} />
193
+ {#if useOptionIconImage}
194
+ <img
195
+ src={getOptionIcon(option, idx)}
196
+ alt="icon"
197
+ width="15"
198
+ height="15"
199
+ />
200
+ {:else}
201
+ <Icon size="S" name={getOptionIcon(option, idx)} />
202
+ {/if}
190
203
  </span>
191
204
  {/if}
192
205
  {#if getOptionColour(option, idx)}
@@ -208,6 +221,12 @@
208
221
  {/each}
209
222
  {/if}
210
223
  </ul>
224
+
225
+ {#if footer}
226
+ <div class="footer">
227
+ {footer}
228
+ </div>
229
+ {/if}
211
230
  </div>
212
231
  </Popover>
213
232
 
@@ -284,4 +303,11 @@
284
303
  .popover-content :global(.spectrum-Search .spectrum-Textfield-icon) {
285
304
  top: 9px;
286
305
  }
306
+
307
+ .footer {
308
+ padding: 4px 12px 12px 12px;
309
+ font-style: italic;
310
+ max-width: 170px;
311
+ font-size: 12px;
312
+ }
287
313
  </style>
@@ -11,6 +11,7 @@
11
11
  export let getOptionLabel = option => option
12
12
  export let getOptionValue = option => option
13
13
  export let getOptionIcon = () => null
14
+ export let useOptionIconImage = false
14
15
  export let getOptionColour = () => null
15
16
  export let isOptionEnabled
16
17
  export let readonly = false
@@ -18,6 +19,8 @@
18
19
  export let autoWidth = false
19
20
  export let autocomplete = false
20
21
  export let sort = false
22
+ export let align
23
+ export let footer = null
21
24
 
22
25
  const dispatch = createEventDispatcher()
23
26
 
@@ -41,7 +44,7 @@
41
44
  const getFieldText = (value, options, placeholder) => {
42
45
  // Always use placeholder if no value
43
46
  if (value == null || value === "") {
44
- return placeholder || "Choose an option"
47
+ return placeholder !== false ? "Choose an option" : ""
45
48
  }
46
49
 
47
50
  return getFieldAttribute(getOptionLabel, value, options)
@@ -66,15 +69,18 @@
66
69
  {fieldColour}
67
70
  {options}
68
71
  {autoWidth}
72
+ {align}
73
+ {footer}
69
74
  {getOptionLabel}
70
75
  {getOptionValue}
71
76
  {getOptionIcon}
77
+ {useOptionIconImage}
72
78
  {getOptionColour}
73
79
  {isOptionEnabled}
74
80
  {autocomplete}
75
81
  {sort}
76
82
  isPlaceholder={value == null || value === ""}
77
- placeholderOption={placeholder}
83
+ placeholderOption={placeholder === false ? null : placeholder}
78
84
  isOptionSelected={option => option === value}
79
85
  onSelectOption={selectOption}
80
86
  />
@@ -14,6 +14,7 @@
14
14
  export let getOptionLabel = option => extractProperty(option, "label")
15
15
  export let getOptionValue = option => extractProperty(option, "value")
16
16
  export let getOptionIcon = option => option?.icon
17
+ export let useOptionIconImage = false
17
18
  export let getOptionColour = option => option?.colour
18
19
  export let isOptionEnabled
19
20
  export let quiet = false
@@ -22,6 +23,8 @@
22
23
  export let tooltip = ""
23
24
  export let autocomplete = false
24
25
  export let customPopoverHeight
26
+ export let align
27
+ export let footer = null
25
28
 
26
29
  const dispatch = createEventDispatcher()
27
30
  const onChange = e => {
@@ -48,10 +51,13 @@
48
51
  {placeholder}
49
52
  {autoWidth}
50
53
  {sort}
54
+ {align}
55
+ {footer}
51
56
  {getOptionLabel}
52
57
  {getOptionValue}
53
58
  {getOptionIcon}
54
59
  {getOptionColour}
60
+ {useOptionIconImage}
55
61
  {isOptionEnabled}
56
62
  {autocomplete}
57
63
  {customPopoverHeight}