@budibase/bbui 2.2.26 → 2.2.27

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.
Files changed (57) hide show
  1. package/dist/bbui.es.js +3 -3
  2. package/dist/bbui.es.js.map +1 -1
  3. package/package.json +4 -3
  4. package/src/Accordion/Accordion.svelte +58 -0
  5. package/src/ActionButton/ActionButton.svelte +2 -3
  6. package/src/ActionMenu/ActionMenu.svelte +1 -2
  7. package/src/Actions/click_outside.js +28 -9
  8. package/src/Actions/position_dropdown.js +85 -53
  9. package/src/Avatar/Avatar.svelte +1 -0
  10. package/src/Badge/Badge.svelte +13 -0
  11. package/src/Button/Button.svelte +8 -4
  12. package/src/Drawer/DrawerContent.svelte +0 -1
  13. package/src/FancyForm/FancyButton.svelte +30 -0
  14. package/src/FancyForm/FancyButtonRadio.svelte +70 -0
  15. package/src/FancyForm/FancyCheckbox.svelte +53 -0
  16. package/src/FancyForm/FancyField.svelte +126 -0
  17. package/src/FancyForm/FancyFieldLabel.svelte +25 -0
  18. package/src/FancyForm/FancyForm.svelte +40 -0
  19. package/src/FancyForm/FancyInput.svelte +77 -0
  20. package/src/FancyForm/FancySelect.svelte +147 -0
  21. package/src/FancyForm/index.js +6 -0
  22. package/src/Form/Core/DatePicker.svelte +1 -1
  23. package/src/Form/Core/Dropzone.svelte +71 -66
  24. package/src/Form/Core/EnvDropdown.svelte +276 -0
  25. package/src/Form/Core/Picker.svelte +141 -124
  26. package/src/Form/Core/Select.svelte +3 -0
  27. package/src/Form/Core/Switch.svelte +0 -2
  28. package/src/Form/Core/TextField.svelte +0 -6
  29. package/src/Form/EnvDropdown.svelte +50 -0
  30. package/src/Form/Input.svelte +0 -2
  31. package/src/Form/InputDropdown.svelte +0 -2
  32. package/src/Form/PickerDropdown.svelte +0 -2
  33. package/src/Form/Toggle.svelte +1 -2
  34. package/src/Icon/IconAvatar.svelte +3 -0
  35. package/src/InlineAlert/InlineAlert.svelte +1 -0
  36. package/src/Label/Label.svelte +1 -0
  37. package/src/Layout/Page.svelte +82 -13
  38. package/src/Link/Link.svelte +4 -1
  39. package/src/List/ListItem.svelte +6 -3
  40. package/src/Menu/Item.svelte +0 -2
  41. package/src/Modal/CustomContent.svelte +0 -1
  42. package/src/Modal/Modal.svench +0 -1
  43. package/src/Modal/ModalContent.svelte +4 -4
  44. package/src/Modal/QuizModal.svelte +0 -1
  45. package/src/Popover/Popover.svelte +35 -31
  46. package/src/Popover/Popover.svench +0 -1
  47. package/src/SideNavigation/Item.svelte +0 -2
  48. package/src/Table/RelationshipRenderer.svelte +3 -8
  49. package/src/Table/StringRenderer.svelte +9 -1
  50. package/src/Table/Table.svelte +30 -19
  51. package/src/Tabs/Tab.svelte +5 -5
  52. package/src/Tags/Tag.svelte +1 -1
  53. package/src/Tags/Tags.svelte +10 -0
  54. package/src/Typography/Heading.svelte +6 -0
  55. package/src/bbui.css +7 -3
  56. package/src/context.js +1 -0
  57. package/src/index.js +5 -0
@@ -0,0 +1,126 @@
1
+ <script>
2
+ import Icon from "../Icon/Icon.svelte"
3
+ import { getContext, onMount } from "svelte"
4
+ import { slide } from "svelte/transition"
5
+
6
+ export let disabled = false
7
+ export let error = null
8
+ export let focused = false
9
+ export let clickable = false
10
+ export let validate
11
+ export let value
12
+ export let ref
13
+ export let autoHeight
14
+
15
+ const formContext = getContext("fancy-form")
16
+ const id = Math.random()
17
+ const API = {
18
+ validate: () => {
19
+ if (validate) {
20
+ error = validate(value)
21
+ }
22
+ return !error
23
+ },
24
+ }
25
+
26
+ onMount(() => {
27
+ if (formContext) {
28
+ formContext.registerField(id, API)
29
+ }
30
+ return () => {
31
+ if (formContext) {
32
+ formContext.unregisterField(id)
33
+ }
34
+ }
35
+ })
36
+ </script>
37
+
38
+ <div
39
+ bind:this={ref}
40
+ class="fancy-field"
41
+ class:error
42
+ class:disabled
43
+ class:focused
44
+ class:clickable
45
+ class:auto-height={autoHeight}
46
+ >
47
+ <div class="content" on:click>
48
+ <div class="field">
49
+ <slot />
50
+ </div>
51
+ {#if error}
52
+ <div class="error-icon">
53
+ <Icon name="Alert" />
54
+ </div>
55
+ {/if}
56
+ </div>
57
+ {#if error}
58
+ <div transition:slide|local={{ duration: 130 }} class="error-message">
59
+ {error}
60
+ </div>
61
+ {/if}
62
+ </div>
63
+
64
+ <style>
65
+ .fancy-field {
66
+ max-width: 400px;
67
+ background: var(--spectrum-global-color-gray-75);
68
+ border: 1px solid var(--spectrum-global-color-gray-300);
69
+ border-radius: 4px;
70
+ box-sizing: border-box;
71
+ transition: border-color 130ms ease-out, background 130ms ease-out,
72
+ background 130ms ease-out;
73
+ color: var(--spectrum-global-color-gray-800);
74
+ }
75
+ .fancy-field:hover {
76
+ border-color: var(--spectrum-global-color-gray-400);
77
+ }
78
+ .fancy-field.clickable:hover {
79
+ background: var(--spectrum-global-color-gray-200);
80
+ cursor: pointer;
81
+ }
82
+ .fancy-field.focused {
83
+ border-color: var(--spectrum-global-color-blue-400);
84
+ }
85
+ .fancy-field.error {
86
+ border-color: var(--spectrum-global-color-red-400);
87
+ }
88
+ .fancy-field.disabled {
89
+ background: var(--spectrum-global-color-gray-200);
90
+ color: var(--spectrum-global-color-gray-400);
91
+ border: 1px solid var(--spectrum-global-color-gray-300);
92
+ pointer-events: none;
93
+ }
94
+ .content {
95
+ position: relative;
96
+ height: 64px;
97
+ padding: 0 16px;
98
+ }
99
+ .fancy-field.auto-height .content {
100
+ height: auto;
101
+ }
102
+ .content,
103
+ .field {
104
+ display: flex;
105
+ flex-direction: row;
106
+ justify-content: flex-start;
107
+ align-items: center;
108
+ gap: 16px;
109
+ }
110
+ .field {
111
+ flex: 1 1 auto;
112
+ }
113
+ .error-message {
114
+ background: var(--spectrum-global-color-red-400);
115
+ color: white;
116
+ font-size: 14px;
117
+ padding: 6px 16px;
118
+ font-weight: 500;
119
+ }
120
+ .error-icon {
121
+ flex: 0 0 auto;
122
+ }
123
+ .error-icon :global(.spectrum-Icon) {
124
+ fill: var(--spectrum-global-color-red-400);
125
+ }
126
+ </style>
@@ -0,0 +1,25 @@
1
+ <script>
2
+ export let placeholder = true
3
+ </script>
4
+
5
+ <div class:placeholder>
6
+ <slot />
7
+ </div>
8
+
9
+ <style>
10
+ div {
11
+ font-size: 14px;
12
+ line-height: 15px;
13
+ font-weight: 500;
14
+ position: absolute;
15
+ top: 10px;
16
+ color: var(--spectrum-global-color-gray-600);
17
+ transition: font-size 130ms ease-out, top 130ms ease-out,
18
+ transform 130ms ease-out;
19
+ }
20
+ div.placeholder {
21
+ top: 50%;
22
+ font-size: 15px;
23
+ transform: translateY(-50%);
24
+ }
25
+ </style>
@@ -0,0 +1,40 @@
1
+ <script>
2
+ import { setContext } from "svelte"
3
+
4
+ let fields = {}
5
+
6
+ setContext("fancy-form", {
7
+ registerField: (id, api) => {
8
+ fields = { ...fields, [id]: api }
9
+ },
10
+ unregisterField: id => {
11
+ delete fields[id]
12
+ fields = fields
13
+ },
14
+ })
15
+
16
+ export const validate = () => {
17
+ let valid = true
18
+ Object.values(fields).forEach(api => {
19
+ if (!api.validate()) {
20
+ valid = false
21
+ }
22
+ })
23
+ return valid
24
+ }
25
+ </script>
26
+
27
+ <div class="fancy-form">
28
+ <slot />
29
+ </div>
30
+
31
+ <style>
32
+ .fancy-form :global(.fancy-field:not(:first-of-type)) {
33
+ border-top-left-radius: 0;
34
+ border-top-right-radius: 0;
35
+ }
36
+ .fancy-form :global(.fancy-field:not(:last-of-type)) {
37
+ border-bottom-left-radius: 0;
38
+ border-bottom-right-radius: 0;
39
+ }
40
+ </style>
@@ -0,0 +1,77 @@
1
+ <script>
2
+ import { createEventDispatcher } from "svelte"
3
+ import FancyField from "./FancyField.svelte"
4
+ import FancyFieldLabel from "./FancyFieldLabel.svelte"
5
+ import { fade } from "svelte/transition"
6
+
7
+ export let label
8
+ export let value
9
+ export let type = "text"
10
+ export let disabled = false
11
+ export let error = null
12
+ export let validate = null
13
+ export let suffix = null
14
+
15
+ const dispatch = createEventDispatcher()
16
+
17
+ let focused = false
18
+ $: placeholder = !focused && !value
19
+
20
+ const onChange = e => {
21
+ const newValue = e.target.value
22
+ dispatch("change", newValue)
23
+ value = newValue
24
+ if (validate) {
25
+ error = validate(newValue)
26
+ }
27
+ }
28
+ </script>
29
+
30
+ <FancyField {error} {value} {validate} {disabled} {focused}>
31
+ {#if label}
32
+ <FancyFieldLabel {placeholder}>{label}</FancyFieldLabel>
33
+ {/if}
34
+ <input
35
+ {disabled}
36
+ value={value || ""}
37
+ type={type || "text"}
38
+ on:input={onChange}
39
+ on:focus={() => (focused = true)}
40
+ on:blur={() => (focused = false)}
41
+ class:placeholder
42
+ />
43
+ {#if suffix && !placeholder}
44
+ <div in:fade|local={{ duration: 130 }} class="suffix">{suffix}</div>
45
+ {/if}
46
+ </FancyField>
47
+
48
+ <style>
49
+ input {
50
+ width: 100%;
51
+ transition: transform 130ms ease-out;
52
+ transform: translateY(9px);
53
+ background: transparent;
54
+ font-size: 15px;
55
+ line-height: 17px;
56
+ font-family: var(--font-sans);
57
+ color: var(--spectrum-global-color-gray-900);
58
+ outline: none;
59
+ border: none;
60
+ padding: 0;
61
+ margin: 0;
62
+ }
63
+ input.placeholder {
64
+ transform: translateY(0);
65
+ position: absolute;
66
+ top: 0;
67
+ left: 0;
68
+ height: 100%;
69
+ }
70
+ .suffix {
71
+ color: var(--spectrum-global-color-gray-600);
72
+ transform: translateY(9px);
73
+ font-size: 15px;
74
+ line-height: 17px;
75
+ font-family: var(--font-sans);
76
+ }
77
+ </style>
@@ -0,0 +1,147 @@
1
+ <script>
2
+ import { createEventDispatcher } from "svelte"
3
+ import FancyField from "./FancyField.svelte"
4
+ import Icon from "../Icon/Icon.svelte"
5
+ import Popover from "../Popover/Popover.svelte"
6
+ import FancyFieldLabel from "./FancyFieldLabel.svelte"
7
+
8
+ export let label
9
+ export let value
10
+ export let disabled = false
11
+ export let error = null
12
+ export let validate = null
13
+ export let options = []
14
+ export let getOptionLabel = option => extractProperty(option, "label")
15
+ export let getOptionValue = option => extractProperty(option, "value")
16
+
17
+ const dispatch = createEventDispatcher()
18
+
19
+ let open = false
20
+ let popover
21
+ let wrapper
22
+
23
+ $: placeholder = !value
24
+ $: selectedLabel = getSelectedLabel(value)
25
+
26
+ const extractProperty = (value, property) => {
27
+ if (value && typeof value === "object") {
28
+ return value[property]
29
+ }
30
+ return value
31
+ }
32
+
33
+ const onChange = newValue => {
34
+ dispatch("change", newValue)
35
+ value = newValue
36
+ if (validate) {
37
+ error = validate(newValue)
38
+ }
39
+ open = false
40
+ }
41
+
42
+ const getSelectedLabel = value => {
43
+ if (!value || !options?.length) {
44
+ return ""
45
+ }
46
+ const selectedOption = options.find(x => getOptionValue(x) === value)
47
+ if (!selectedOption) {
48
+ return value
49
+ }
50
+ return getOptionLabel(selectedOption)
51
+ }
52
+ </script>
53
+
54
+ <FancyField
55
+ bind:ref={wrapper}
56
+ {error}
57
+ {value}
58
+ {validate}
59
+ {disabled}
60
+ clickable
61
+ on:click={() => (open = true)}
62
+ >
63
+ {#if label}
64
+ <FancyFieldLabel {placeholder}>{label}</FancyFieldLabel>
65
+ {/if}
66
+
67
+ <div class="value" class:placeholder>
68
+ {selectedLabel || ""}
69
+ </div>
70
+
71
+ <div class="arrow">
72
+ <Icon name="ChevronDown" />
73
+ </div>
74
+ </FancyField>
75
+
76
+ <Popover
77
+ anchor={wrapper}
78
+ align="left"
79
+ portalTarget={document.documentElement}
80
+ bind:this={popover}
81
+ {open}
82
+ on:close={() => (open = false)}
83
+ useAnchorWidth={true}
84
+ maxWidth={null}
85
+ >
86
+ <div class="popover-content">
87
+ {#if options.length}
88
+ {#each options as option, idx}
89
+ <div
90
+ class="popover-option"
91
+ tabindex="0"
92
+ on:click={() => onChange(getOptionValue(option, idx))}
93
+ >
94
+ <span class="option-text">
95
+ {getOptionLabel(option, idx)}
96
+ </span>
97
+ {#if value === getOptionValue(option, idx)}
98
+ <Icon name="Checkmark" />
99
+ {/if}
100
+ </div>
101
+ {/each}
102
+ {/if}
103
+ </div>
104
+ </Popover>
105
+
106
+ <style>
107
+ .value {
108
+ display: block;
109
+ flex: 1 1 auto;
110
+ font-size: 15px;
111
+ line-height: 17px;
112
+ color: var(--spectrum-global-color-gray-900);
113
+ transition: transform 130ms ease-out, opacity 130ms ease-out;
114
+ opacity: 1;
115
+ white-space: nowrap;
116
+ text-overflow: ellipsis;
117
+ overflow: hidden;
118
+ width: 0;
119
+ transform: translateY(9px);
120
+ }
121
+ .value.placeholder {
122
+ transform: translateY(0);
123
+ opacity: 0;
124
+ pointer-events: none;
125
+ margin-top: 0;
126
+ }
127
+ .popover-content {
128
+ display: flex;
129
+ flex-direction: column;
130
+ justify-content: flex-start;
131
+ align-items: stretch;
132
+ padding: 7px 0;
133
+ }
134
+ .popover-option {
135
+ display: flex;
136
+ flex-direction: row;
137
+ justify-content: space-between;
138
+ align-items: center;
139
+ padding: 7px 16px;
140
+ transition: background 130ms ease-out;
141
+ font-size: 15px;
142
+ }
143
+ .popover-option:hover {
144
+ background: var(--spectrum-global-color-gray-200);
145
+ cursor: pointer;
146
+ }
147
+ </style>
@@ -0,0 +1,6 @@
1
+ export { default as FancyInput } from "./FancyInput.svelte"
2
+ export { default as FancyCheckbox } from "./FancyCheckbox.svelte"
3
+ export { default as FancySelect } from "./FancySelect.svelte"
4
+ export { default as FancyButton } from "./FancyButton.svelte"
5
+ export { default as FancyForm } from "./FancyForm.svelte"
6
+ export { default as FancyButtonRadio } from "./FancyButtonRadio.svelte"
@@ -257,7 +257,7 @@
257
257
  max-height: 100%;
258
258
  }
259
259
  :global(.flatpickr-calendar) {
260
- font-family: "Source Sans Pro", sans-serif;
260
+ font-family: var(--font-sans);
261
261
  }
262
262
  .is-disabled {
263
263
  pointer-events: none !important;
@@ -15,6 +15,7 @@
15
15
  export let value = []
16
16
  export let id = null
17
17
  export let disabled = false
18
+ export let compact = false
18
19
  export let fileSizeLimit = BYTES_IN_MB * 20
19
20
  export let processFiles = null
20
21
  export let deleteAttachments = null
@@ -239,70 +240,72 @@
239
240
  bind:this={fileInput}
240
241
  on:change={handleFile}
241
242
  />
242
- <svg
243
- class="spectrum-IllustratedMessage-illustration"
244
- width="125"
245
- height="60"
246
- viewBox="0 0 199 97.7"
247
- >
248
- <defs>
249
- <style>
250
- .cls-1,
251
- .cls-2 {
252
- fill: none;
253
- stroke-linecap: round;
254
- stroke-linejoin: round;
255
- }
256
- .cls-1 {
257
- stroke-width: 3px;
258
- }
259
- .cls-2 {
260
- stroke-width: 2px;
261
- }
262
- </style>
263
- </defs>
264
- <path
265
- class="cls-1"
266
- d="M110.53,85.66,100.26,95.89a1.09,1.09,0,0,1-1.52,0L88.47,85.66"
267
- />
268
- <line class="cls-1" x1="99.5" y1="95.5" x2="99.5" y2="58.5" />
269
- <path class="cls-1" d="M105.5,73.5h19a2,2,0,0,0,2-2v-43" />
270
- <path
271
- class="cls-1"
272
- 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"
273
- />
274
- <line class="cls-1" x1="105.5" y1="1.5" x2="126.5" y2="22.5" />
275
- <path
276
- class="cls-2"
277
- d="M47.93,50.49a5,5,0,1,0-4.83-5A4.93,4.93,0,0,0,47.93,50.49Z"
278
- />
279
- <path
280
- class="cls-2"
281
- d="M36.6,65.93,42.05,60A2.06,2.06,0,0,1,45,60l12.68,13.2"
282
- />
283
- <path
284
- class="cls-2"
285
- d="M3.14,73.23,22.42,53.76a1.65,1.65,0,0,1,2.38,0l19.05,19.7"
286
- />
287
- <path
288
- class="cls-1"
289
- 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"
290
- />
291
- <rect
292
- class="cls-1"
293
- x="1.5"
294
- y="34.5"
295
- width="58"
296
- height="39"
297
- rx="2"
298
- ry="2"
299
- />
300
- </svg>
301
- <h2
302
- class="spectrum-Heading spectrum-Heading--sizeL spectrum-Heading--light spectrum-IllustratedMessage-heading"
303
- >
304
- Drag and drop your file
305
- </h2>
243
+ {#if !compact}
244
+ <svg
245
+ class="spectrum-IllustratedMessage-illustration"
246
+ width="125"
247
+ height="60"
248
+ viewBox="0 0 199 97.7"
249
+ >
250
+ <defs>
251
+ <style>
252
+ .cls-1,
253
+ .cls-2 {
254
+ fill: none;
255
+ stroke-linecap: round;
256
+ stroke-linejoin: round;
257
+ }
258
+ .cls-1 {
259
+ stroke-width: 3px;
260
+ }
261
+ .cls-2 {
262
+ stroke-width: 2px;
263
+ }
264
+ </style>
265
+ </defs>
266
+ <path
267
+ class="cls-1"
268
+ d="M110.53,85.66,100.26,95.89a1.09,1.09,0,0,1-1.52,0L88.47,85.66"
269
+ />
270
+ <line class="cls-1" x1="99.5" y1="95.5" x2="99.5" y2="58.5" />
271
+ <path class="cls-1" d="M105.5,73.5h19a2,2,0,0,0,2-2v-43" />
272
+ <path
273
+ class="cls-1"
274
+ 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"
275
+ />
276
+ <line class="cls-1" x1="105.5" y1="1.5" x2="126.5" y2="22.5" />
277
+ <path
278
+ class="cls-2"
279
+ d="M47.93,50.49a5,5,0,1,0-4.83-5A4.93,4.93,0,0,0,47.93,50.49Z"
280
+ />
281
+ <path
282
+ class="cls-2"
283
+ d="M36.6,65.93,42.05,60A2.06,2.06,0,0,1,45,60l12.68,13.2"
284
+ />
285
+ <path
286
+ class="cls-2"
287
+ d="M3.14,73.23,22.42,53.76a1.65,1.65,0,0,1,2.38,0l19.05,19.7"
288
+ />
289
+ <path
290
+ class="cls-1"
291
+ 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"
292
+ />
293
+ <rect
294
+ class="cls-1"
295
+ x="1.5"
296
+ y="34.5"
297
+ width="58"
298
+ height="39"
299
+ rx="2"
300
+ ry="2"
301
+ />
302
+ </svg>
303
+ <h2
304
+ class="spectrum-Heading spectrum-Heading--sizeL spectrum-Heading--light spectrum-IllustratedMessage-heading"
305
+ >
306
+ Drag and drop your file
307
+ </h2>
308
+ {/if}
306
309
  {#if !disabled}
307
310
  <p
308
311
  class="spectrum-Body spectrum-Body--sizeS spectrum-IllustratedMessage-description"
@@ -310,8 +313,10 @@
310
313
  <label for={fieldId} class="spectrum-Link">
311
314
  Select a file to upload
312
315
  </label>
313
- <br />
314
- from your computer
316
+ {#if !compact}
317
+ <br />
318
+ from your computer
319
+ {/if}
315
320
  </p>
316
321
  {#if fileTags.length}
317
322
  <Tags>