@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.
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.25",
4
+ "version": "1.0.27-alpha.10",
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": "382b86689a90ef561bd06d9020ee3d1400052d19"
85
+ "gitHead": "37b3e81a0d6f99566d3b753f79b91d5b05185106"
86
86
  }
@@ -80,4 +80,8 @@
80
80
  .active svg {
81
81
  color: var(--spectrum-global-color-blue-600);
82
82
  }
83
+
84
+ .spectrum-ActionButton-label {
85
+ padding-bottom: 2px;
86
+ }
83
87
  </style>
@@ -0,0 +1,59 @@
1
+ <script>
2
+ import { createEventDispatcher } from "svelte"
3
+
4
+ let dispatch = createEventDispatcher()
5
+
6
+ export let type = "info"
7
+ export let icon = "Info"
8
+ export let size = "S"
9
+ export let extraButtonText
10
+ export let extraButtonAction
11
+
12
+ let show = true
13
+
14
+ function clear() {
15
+ show = false
16
+ dispatch("change")
17
+ }
18
+ </script>
19
+
20
+ {#if show}
21
+ <div class="spectrum-Toast spectrum-Toast--{type}">
22
+ <svg
23
+ class="spectrum-Icon spectrum-Icon--size{size} spectrum-Toast-typeIcon"
24
+ focusable="false"
25
+ aria-hidden="true"
26
+ >
27
+ <use xlink:href="#spectrum-icon-18-{icon}" />
28
+ </svg>
29
+ <div class="spectrum-Toast-body">
30
+ <div class="spectrum-Toast-content">
31
+ <slot />
32
+ </div>
33
+ {#if extraButtonText && extraButtonAction}
34
+ <button
35
+ class="spectrum-Button spectrum-Button--sizeM spectrum-Button--overBackground spectrum-Button--quiet"
36
+ on:click={extraButtonAction}
37
+ >
38
+ <span class="spectrum-Button-label">{extraButtonText}</span>
39
+ </button>
40
+ {/if}
41
+ </div>
42
+ <div class="spectrum-Toast-buttons">
43
+ <button
44
+ class="spectrum-ClearButton spectrum-ClearButton--overBackground spectrum-ClearButton--size{size}"
45
+ on:click={clear}
46
+ >
47
+ <div class="spectrum-ClearButton-fill">
48
+ <svg
49
+ class="spectrum-ClearButton-icon spectrum-Icon spectrum-UIIcon-Cross100"
50
+ focusable="false"
51
+ aria-hidden="true"
52
+ >
53
+ <use xlink:href="#spectrum-css-icon-Cross100" />
54
+ </svg>
55
+ </div>
56
+ </button>
57
+ </div>
58
+ </div>
59
+ {/if}
@@ -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>
@@ -6,6 +6,8 @@
6
6
  import { generateID } from "../../utils/helpers"
7
7
  import Icon from "../../Icon/Icon.svelte"
8
8
  import Link from "../../Link/Link.svelte"
9
+ import Tag from "../../Tags/Tag.svelte"
10
+ import Tags from "../../Tags/Tags.svelte"
9
11
 
10
12
  const BYTES_IN_KB = 1000
11
13
  const BYTES_IN_MB = 1000000
@@ -18,6 +20,8 @@
18
20
  export let handleFileTooLarge = null
19
21
  export let gallery = true
20
22
  export let error = null
23
+ export let fileTags = []
24
+ export let maximum = null
21
25
 
22
26
  const dispatch = createEventDispatcher()
23
27
  const imageExtensions = [
@@ -184,103 +188,118 @@
184
188
  {/each}
185
189
  {/if}
186
190
  {/if}
187
- <div
188
- class="spectrum-Dropzone"
189
- class:is-invalid={!!error}
190
- class:disabled
191
- role="region"
192
- tabindex="0"
193
- on:dragover={handleDragOver}
194
- on:dragleave={handleDragLeave}
195
- on:dragenter={handleDragOver}
196
- on:drop={handleDrop}
197
- class:is-dragged={fileDragged}
198
- >
199
- <div class="spectrum-IllustratedMessage spectrum-IllustratedMessage--cta">
200
- <input
201
- id={fieldId}
202
- {disabled}
203
- type="file"
204
- multiple
205
- on:change={handleFile}
206
- />
207
- <svg
208
- class="spectrum-IllustratedMessage-illustration"
209
- width="125"
210
- height="60"
211
- viewBox="0 0 199 97.7"
212
- >
213
- <defs>
214
- <style>
215
- .cls-1,
216
- .cls-2 {
217
- fill: none;
218
- stroke-linecap: round;
219
- stroke-linejoin: round;
220
- }
221
- .cls-1 {
222
- stroke-width: 3px;
223
- }
224
- .cls-2 {
225
- stroke-width: 2px;
226
- }
227
- </style>
228
- </defs>
229
- <path
230
- class="cls-1"
231
- d="M110.53,85.66,100.26,95.89a1.09,1.09,0,0,1-1.52,0L88.47,85.66"
191
+ {#if !maximum || (maximum && value?.length < maximum)}
192
+ <div
193
+ class="spectrum-Dropzone"
194
+ class:is-invalid={!!error}
195
+ class:disabled
196
+ role="region"
197
+ tabindex="0"
198
+ on:dragover={handleDragOver}
199
+ on:dragleave={handleDragLeave}
200
+ on:dragenter={handleDragOver}
201
+ on:drop={handleDrop}
202
+ class:is-dragged={fileDragged}
203
+ >
204
+ <div class="spectrum-IllustratedMessage spectrum-IllustratedMessage--cta">
205
+ <input
206
+ id={fieldId}
207
+ {disabled}
208
+ type="file"
209
+ multiple
210
+ on:change={handleFile}
232
211
  />
233
- <line class="cls-1" x1="99.5" y1="95.5" x2="99.5" y2="58.5" />
234
- <path class="cls-1" d="M105.5,73.5h19a2,2,0,0,0,2-2v-43" />
235
- <path
236
- class="cls-1"
237
- d="M126.5,22.5h-19a2,2,0,0,1-2-2V1.5h-31a2,2,0,0,0-2,2v68a2,2,0,0,0,2,2h19"
238
- />
239
- <line class="cls-1" x1="105.5" y1="1.5" x2="126.5" y2="22.5" />
240
- <path
241
- class="cls-2"
242
- d="M47.93,50.49a5,5,0,1,0-4.83-5A4.93,4.93,0,0,0,47.93,50.49Z"
243
- />
244
- <path
245
- class="cls-2"
246
- d="M36.6,65.93,42.05,60A2.06,2.06,0,0,1,45,60l12.68,13.2"
247
- />
248
- <path
249
- class="cls-2"
250
- d="M3.14,73.23,22.42,53.76a1.65,1.65,0,0,1,2.38,0l19.05,19.7"
251
- />
252
- <path
253
- class="cls-1"
254
- d="M139.5,36.5H196A1.49,1.49,0,0,1,197.5,38V72A1.49,1.49,0,0,1,196,73.5H141A1.49,1.49,0,0,1,139.5,72V32A1.49,1.49,0,0,1,141,30.5H154a2.43,2.43,0,0,1,1.67.66l6,5.66"
255
- />
256
- <rect
257
- class="cls-1"
258
- x="1.5"
259
- y="34.5"
260
- width="58"
261
- height="39"
262
- rx="2"
263
- ry="2"
264
- />
265
- </svg>
266
- <h2
267
- class="spectrum-Heading spectrum-Heading--sizeL spectrum-Heading--light spectrum-IllustratedMessage-heading"
268
- >
269
- Drag and drop your file
270
- </h2>
271
- {#if !disabled}
272
- <p
273
- class="spectrum-Body spectrum-Body--sizeS spectrum-IllustratedMessage-description"
212
+ <svg
213
+ class="spectrum-IllustratedMessage-illustration"
214
+ width="125"
215
+ height="60"
216
+ viewBox="0 0 199 97.7"
217
+ >
218
+ <defs>
219
+ <style>
220
+ .cls-1,
221
+ .cls-2 {
222
+ fill: none;
223
+ stroke-linecap: round;
224
+ stroke-linejoin: round;
225
+ }
226
+ .cls-1 {
227
+ stroke-width: 3px;
228
+ }
229
+ .cls-2 {
230
+ stroke-width: 2px;
231
+ }
232
+ </style>
233
+ </defs>
234
+ <path
235
+ class="cls-1"
236
+ d="M110.53,85.66,100.26,95.89a1.09,1.09,0,0,1-1.52,0L88.47,85.66"
237
+ />
238
+ <line class="cls-1" x1="99.5" y1="95.5" x2="99.5" y2="58.5" />
239
+ <path class="cls-1" d="M105.5,73.5h19a2,2,0,0,0,2-2v-43" />
240
+ <path
241
+ class="cls-1"
242
+ d="M126.5,22.5h-19a2,2,0,0,1-2-2V1.5h-31a2,2,0,0,0-2,2v68a2,2,0,0,0,2,2h19"
243
+ />
244
+ <line class="cls-1" x1="105.5" y1="1.5" x2="126.5" y2="22.5" />
245
+ <path
246
+ class="cls-2"
247
+ d="M47.93,50.49a5,5,0,1,0-4.83-5A4.93,4.93,0,0,0,47.93,50.49Z"
248
+ />
249
+ <path
250
+ class="cls-2"
251
+ d="M36.6,65.93,42.05,60A2.06,2.06,0,0,1,45,60l12.68,13.2"
252
+ />
253
+ <path
254
+ class="cls-2"
255
+ d="M3.14,73.23,22.42,53.76a1.65,1.65,0,0,1,2.38,0l19.05,19.7"
256
+ />
257
+ <path
258
+ class="cls-1"
259
+ d="M139.5,36.5H196A1.49,1.49,0,0,1,197.5,38V72A1.49,1.49,0,0,1,196,73.5H141A1.49,1.49,0,0,1,139.5,72V32A1.49,1.49,0,0,1,141,30.5H154a2.43,2.43,0,0,1,1.67.66l6,5.66"
260
+ />
261
+ <rect
262
+ class="cls-1"
263
+ x="1.5"
264
+ y="34.5"
265
+ width="58"
266
+ height="39"
267
+ rx="2"
268
+ ry="2"
269
+ />
270
+ </svg>
271
+ <h2
272
+ class="spectrum-Heading spectrum-Heading--sizeL spectrum-Heading--light spectrum-IllustratedMessage-heading"
274
273
  >
275
- <label for={fieldId} class="spectrum-Link">
276
- Select a file to upload
277
- </label>
278
- <br />
279
- from your computer
280
- </p>
281
- {/if}
274
+ Drag and drop your file
275
+ </h2>
276
+ {#if !disabled}
277
+ <p
278
+ class="spectrum-Body spectrum-Body--sizeS spectrum-IllustratedMessage-description"
279
+ >
280
+ <label for={fieldId} class="spectrum-Link">
281
+ Select a file to upload
282
+ </label>
283
+ <br />
284
+ from your computer
285
+ </p>
286
+ {#if fileTags.length}
287
+ <Tags>
288
+ <div class="tags">
289
+ {#each fileTags as tag}
290
+ <div class="tag">
291
+ <Tag>
292
+ {tag}
293
+ </Tag>
294
+ </div>
295
+ {/each}
296
+ </div>
297
+ </Tags>
298
+ {/if}
299
+ {/if}
300
+ </div>
282
301
  </div>
283
- </div>
302
+ {/if}
284
303
  </div>
285
304
 
286
305
  <style>
@@ -390,4 +409,15 @@
390
409
  .disabled .spectrum-Heading--sizeL {
391
410
  color: var(--spectrum-alias-text-color-disabled);
392
411
  }
412
+
413
+ .tags {
414
+ margin-top: 20px;
415
+ display: flex;
416
+ flex-wrap: wrap;
417
+ justify-content: center;
418
+ }
419
+
420
+ .tag {
421
+ margin-top: 8px;
422
+ }
393
423
  </style>
@@ -7,7 +7,7 @@
7
7
  export let disabled = false
8
8
  export let id = null
9
9
  export let updateOnChange = true
10
-
10
+ export let quiet = false
11
11
  const dispatch = createEventDispatcher()
12
12
  let focus = false
13
13
 
@@ -41,6 +41,7 @@
41
41
  <div class="spectrum-Search" class:is-disabled={disabled}>
42
42
  <div
43
43
  class="spectrum-Textfield"
44
+ class:spectrum-Textfield--quiet={quiet}
44
45
  class:is-focused={focus}
45
46
  class:is-disabled={disabled}
46
47
  >
@@ -25,7 +25,9 @@
25
25
  class="spectrum-Switch-input"
26
26
  />
27
27
  <span class="spectrum-Switch-switch" />
28
- <label class="spectrum-Switch-label" for={id}>{text}</label>
28
+ {#if text}
29
+ <label class="spectrum-Switch-label" for={id}>{text}</label>
30
+ {/if}
29
31
  </div>
30
32
 
31
33
  <style>
@@ -7,6 +7,8 @@
7
7
  export let disabled = false
8
8
  export let error = null
9
9
  export let id = null
10
+ export let height = null
11
+ export let minHeight = null
10
12
  export const getCaretPosition = () => ({
11
13
  start: textarea.selectionStart,
12
14
  end: textarea.selectionEnd,
@@ -22,6 +24,8 @@
22
24
  </script>
23
25
 
24
26
  <div
27
+ style={(height ? `height: ${height}px;` : "") +
28
+ (minHeight ? `min-height: ${minHeight}px` : "")}
25
29
  class="spectrum-Textfield spectrum-Textfield--multiline"
26
30
  class:is-invalid={!!error}
27
31
  class:is-disabled={disabled}
@@ -12,6 +12,8 @@
12
12
  export let processFiles = undefined
13
13
  export let handleFileTooLarge = undefined
14
14
  export let gallery = true
15
+ export let fileTags = []
16
+ export let maximum = undefined
15
17
 
16
18
  const dispatch = createEventDispatcher()
17
19
  const onChange = e => {
@@ -29,6 +31,8 @@
29
31
  {processFiles}
30
32
  {handleFileTooLarge}
31
33
  {gallery}
34
+ {fileTags}
35
+ {maximum}
32
36
  on:change={onChange}
33
37
  />
34
38
  </Field>
@@ -9,6 +9,7 @@
9
9
  export let labelPosition = "above"
10
10
  export let error = null
11
11
  export let options = []
12
+ export let direction = "vertical"
12
13
  export let getOptionLabel = option => extractProperty(option, "label")
13
14
  export let getOptionValue = option => extractProperty(option, "value")
14
15
 
@@ -31,6 +32,7 @@
31
32
  {disabled}
32
33
  {value}
33
34
  {options}
35
+ {direction}
34
36
  {getOptionLabel}
35
37
  {getOptionValue}
36
38
  on:change={onChange}
@@ -9,6 +9,7 @@
9
9
  export let placeholder = null
10
10
  export let disabled = false
11
11
  export let updateOnChange = true
12
+ export let quiet = false
12
13
 
13
14
  const dispatch = createEventDispatcher()
14
15
  const onChange = e => {
@@ -23,6 +24,7 @@
23
24
  {disabled}
24
25
  {value}
25
26
  {placeholder}
27
+ {quiet}
26
28
  on:change={onChange}
27
29
  on:click
28
30
  on:input
@@ -10,6 +10,8 @@
10
10
  export let disabled = false
11
11
  export let error = null
12
12
  export let getCaretPosition = null
13
+ export let height = null
14
+ export let minHeight = null
13
15
 
14
16
  const dispatch = createEventDispatcher()
15
17
  const onChange = e => {
@@ -25,6 +27,8 @@
25
27
  {disabled}
26
28
  {value}
27
29
  {placeholder}
30
+ {height}
31
+ {minHeight}
28
32
  on:change={onChange}
29
33
  />
30
34
  </Field>
@@ -9,6 +9,7 @@
9
9
  export let size = "M"
10
10
  export let hoverable = false
11
11
  export let disabled = false
12
+ export let color
12
13
 
13
14
  $: rotation = getRotation(direction)
14
15
 
@@ -25,7 +26,9 @@
25
26
  focusable="false"
26
27
  aria-hidden={hidden}
27
28
  aria-label={name}
28
- style={`transform: rotate(${rotation}deg)`}
29
+ style={`transform: rotate(${rotation}deg); ${
30
+ color ? `color: ${color};` : ""
31
+ }`}
29
32
  >
30
33
  <use xlink:href="#spectrum-icon-18-{name}" />
31
34
  </svg>
@@ -19,6 +19,7 @@
19
19
  <div class="icon-container">
20
20
  <div
21
21
  class="icon"
22
+ class:icon-small={size === "M" || size === "S"}
22
23
  on:mouseover={() => (showTooltip = true)}
23
24
  on:mouseleave={() => (showTooltip = false)}
24
25
  >
@@ -44,6 +45,7 @@
44
45
  }
45
46
  .container {
46
47
  display: flex;
48
+ align-items: center;
47
49
  }
48
50
  .icon-container {
49
51
  position: relative;
@@ -64,4 +66,8 @@
64
66
  .icon {
65
67
  transform: scale(0.75);
66
68
  }
69
+ .icon-small {
70
+ margin-top: -2px;
71
+ margin-bottom: -5px;
72
+ }
67
73
  </style>
@@ -63,6 +63,9 @@
63
63
  .gap-L {
64
64
  grid-gap: var(--spectrum-alias-grid-gutter-medium);
65
65
  }
66
+ .gap-XL {
67
+ grid-gap: var(--spectrum-alias-grid-gutter-large);
68
+ }
66
69
  .horizontal.gap-S :global(*) + :global(*) {
67
70
  margin-left: var(--spectrum-alias-grid-gutter-xsmall);
68
71
  }
@@ -18,10 +18,23 @@
18
18
  export let disabled = false
19
19
  export let showDivider = true
20
20
 
21
+ export let showSecondaryButton = false
22
+ export let secondaryButtonText = undefined
23
+ export let secondaryAction = undefined
24
+ export let secondaryButtonWarning = false
25
+
21
26
  const { hide, cancel } = getContext(Context.Modal)
22
27
  let loading = false
23
28
  $: confirmDisabled = disabled || loading
24
29
 
30
+ async function secondary() {
31
+ loading = true
32
+ if (!secondaryAction || (await secondaryAction()) !== false) {
33
+ hide()
34
+ }
35
+ loading = false
36
+ }
37
+
25
38
  async function confirm() {
26
39
  loading = true
27
40
  if (!onConfirm || (await onConfirm()) !== false) {
@@ -73,6 +86,18 @@
73
86
  class="spectrum-ButtonGroup spectrum-Dialog-buttonGroup spectrum-Dialog-buttonGroup--noFooter"
74
87
  >
75
88
  <slot name="footer" />
89
+
90
+ {#if showSecondaryButton && secondaryButtonText && secondaryAction}
91
+ <div class="secondary-action">
92
+ <Button
93
+ group
94
+ secondary
95
+ warning={secondaryButtonWarning}
96
+ on:click={secondary}>{secondaryButtonText}</Button
97
+ >
98
+ </div>
99
+ {/if}
100
+
76
101
  {#if showCancelButton}
77
102
  <Button group secondary on:click={close}>{cancelText}</Button>
78
103
  {/if}
@@ -136,4 +161,8 @@
136
161
  display: flex;
137
162
  justify-content: space-between;
138
163
  }
164
+
165
+ .secondary-action {
166
+ margin-right: auto;
167
+ }
139
168
  </style>
@@ -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 />
@@ -5,7 +5,7 @@
5
5
  export let icon = ""
6
6
 
7
7
  const dispatch = createEventDispatcher()
8
- const selected = getContext("tab")
8
+ let selected = getContext("tab")
9
9
  let tab
10
10
  let tabInfo
11
11
 
@@ -16,8 +16,8 @@
16
16
  // We just need to get this off the main thread to fix this, by using
17
17
  // a 0ms timeout.
18
18
  setTimeout(() => {
19
- tabInfo = tab.getBoundingClientRect()
20
- if ($selected.title === title) {
19
+ tabInfo = tab?.getBoundingClientRect()
20
+ if (tabInfo && $selected.title === title) {
21
21
  $selected.info = tabInfo
22
22
  }
23
23
  }, 0)