@budibase/bbui 1.2.44-alpha.0 → 1.2.46

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.2.44-alpha.0",
4
+ "version": "1.2.46",
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": "1.2.44-alpha.0",
41
+ "@budibase/string-templates": "^1.2.46",
42
42
  "@spectrum-css/actionbutton": "^1.0.1",
43
43
  "@spectrum-css/actiongroup": "^1.0.1",
44
44
  "@spectrum-css/avatar": "^3.0.2",
@@ -85,5 +85,5 @@
85
85
  "svelte-flatpickr": "^3.2.3",
86
86
  "svelte-portal": "^1.0.0"
87
87
  },
88
- "gitHead": "a9aebf552f8f7e69aa0afa1d88c6f090a609f470"
88
+ "gitHead": "9c20cb857b8fd3caa99fab0c926c32bc2189deaa"
89
89
  }
@@ -16,7 +16,6 @@
16
16
  export let appendTo = undefined
17
17
  export let timeOnly = false
18
18
  export let ignoreTimezones = false
19
- export let time24hr = false
20
19
 
21
20
  const dispatch = createEventDispatcher()
22
21
  const flatpickrId = `${uuid()}-wrapper`
@@ -38,7 +37,6 @@
38
37
  enableTime: timeOnly || enableTime || false,
39
38
  noCalendar: timeOnly || false,
40
39
  altInput: true,
41
- time_24hr: time24hr || false,
42
40
  altFormat: timeOnly ? "H:i" : enableTime ? "F j Y, H:i" : "F j, Y",
43
41
  wrap: true,
44
42
  appendTo,
@@ -51,12 +49,6 @@
51
49
  },
52
50
  }
53
51
 
54
- $: redrawOptions = {
55
- timeOnly,
56
- enableTime,
57
- time24hr,
58
- }
59
-
60
52
  const handleChange = event => {
61
53
  const [dates] = event.detail
62
54
  const noTimezone = enableTime && !timeOnly && ignoreTimezones
@@ -67,6 +59,13 @@
67
59
 
68
60
  // If time only set date component to 2000-01-01
69
61
  if (timeOnly) {
62
+ // Classic flackpickr causing issues.
63
+ // When selecting a value for the first time for a "time only" field,
64
+ // the time is always offset by 1 hour for some reason (regardless of time
65
+ // zone) so we need to correct it.
66
+ if (!value && newValue) {
67
+ newValue = new Date(dates[0].getTime() + 60 * 60 * 1000).toISOString()
68
+ }
70
69
  newValue = `2000-01-01T${newValue.split("T")[1]}`
71
70
  }
72
71
 
@@ -150,7 +149,7 @@
150
149
  }
151
150
  </script>
152
151
 
153
- {#key redrawOptions}
152
+ {#key timeOnly}
154
153
  <Flatpickr
155
154
  bind:flatpickr
156
155
  value={parseDate(value)}
@@ -17,7 +17,6 @@
17
17
  export let disabled = false
18
18
  export let fileSizeLimit = BYTES_IN_MB * 20
19
19
  export let processFiles = null
20
- export let deleteAttachments = null
21
20
  export let handleFileTooLarge = null
22
21
  export let handleTooManyFiles = null
23
22
  export let gallery = true
@@ -95,11 +94,6 @@
95
94
  "change",
96
95
  value.filter((x, idx) => idx !== selectedImageIdx)
97
96
  )
98
- if (deleteAttachments) {
99
- await deleteAttachments(
100
- value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key)
101
- )
102
- }
103
97
  selectedImageIdx = 0
104
98
  }
105
99
 
@@ -139,7 +133,13 @@
139
133
  <div class="title">
140
134
  <div class="filename">
141
135
  {#if selectedUrl}
142
- <Link href={selectedUrl}>{selectedImage.name}</Link>
136
+ <Link
137
+ target="_blank"
138
+ download={selectedImage.name}
139
+ href={selectedUrl}
140
+ >
141
+ {selectedImage.name}
142
+ </Link>
143
143
  {:else}
144
144
  {selectedImage.name}
145
145
  {/if}
@@ -23,7 +23,7 @@
23
23
  $: toggleOption = makeToggleOption(selectedLookupMap, value)
24
24
 
25
25
  const getFieldText = (value, map, placeholder) => {
26
- if (Array.isArray(value) && value.length > 0) {
26
+ if (value?.length) {
27
27
  if (!map) {
28
28
  return ""
29
29
  }
@@ -36,7 +36,7 @@
36
36
 
37
37
  const getSelectedLookupMap = value => {
38
38
  let map = {}
39
- if (Array.isArray(value) && value.length > 0) {
39
+ if (value?.length) {
40
40
  value.forEach(option => {
41
41
  if (option) {
42
42
  map[option] = true
@@ -10,7 +10,6 @@
10
10
  export let error = null
11
11
  export let enableTime = true
12
12
  export let timeOnly = false
13
- export let time24hr = false
14
13
  export let placeholder = null
15
14
  export let appendTo = undefined
16
15
  export let ignoreTimezones = false
@@ -31,7 +30,6 @@
31
30
  {placeholder}
32
31
  {enableTime}
33
32
  {timeOnly}
34
- {time24hr}
35
33
  {appendTo}
36
34
  {ignoreTimezones}
37
35
  on:change={onChange}
@@ -10,7 +10,6 @@
10
10
  export let error = null
11
11
  export let fileSizeLimit = undefined
12
12
  export let processFiles = undefined
13
- export let deleteAttachments = undefined
14
13
  export let handleFileTooLarge = undefined
15
14
  export let handleTooManyFiles = undefined
16
15
  export let gallery = true
@@ -31,7 +30,6 @@
31
30
  {value}
32
31
  {fileSizeLimit}
33
32
  {processFiles}
34
- {deleteAttachments}
35
33
  {handleFileTooLarge}
36
34
  {handleTooManyFiles}
37
35
  {gallery}
@@ -83,9 +83,4 @@
83
83
  transform: translateX(-50%);
84
84
  text-align: center;
85
85
  }
86
-
87
- .spectrum-Icon--sizeXS {
88
- width: 10px;
89
- height: 10px;
90
- }
91
86
  </style>
@@ -8,12 +8,14 @@
8
8
  export let secondary = false
9
9
  export let overBackground = false
10
10
  export let target
11
+ export let download
11
12
  </script>
12
13
 
13
14
  <a
14
15
  on:click
15
16
  {href}
16
17
  {target}
18
+ {download}
17
19
  class:spectrum-Link--primary={primary}
18
20
  class:spectrum-Link--secondary={secondary}
19
21
  class:spectrum-Link--overBackground={overBackground}
@@ -1,6 +1,5 @@
1
1
  <script>
2
2
  import { createEventDispatcher, getContext } from "svelte"
3
- import Icon from "../Icon/Icon.svelte"
4
3
 
5
4
  const dispatch = createEventDispatcher()
6
5
  const actionMenu = getContext("actionMenu")
@@ -9,22 +8,6 @@
9
8
  export let icon = undefined
10
9
  export let disabled = undefined
11
10
  export let noClose = false
12
- export let keyBind = undefined
13
-
14
- $: keys = getKeys(keyBind)
15
-
16
- const getKeys = keyBind => {
17
- let keys = keyBind?.split("+") || []
18
- for (let i = 0; i < keys.length; i++) {
19
- if (
20
- keys[i].toLowerCase() === "ctrl" &&
21
- navigator.platform.startsWith("Mac")
22
- ) {
23
- keys[i] = "⌘"
24
- }
25
- }
26
- return keys
27
- }
28
11
 
29
12
  const onClick = () => {
30
13
  if (actionMenu && !noClose) {
@@ -43,54 +26,20 @@
43
26
  tabindex="0"
44
27
  >
45
28
  {#if icon}
46
- <div class="icon">
47
- <Icon name={icon} size="S" />
48
- </div>
29
+ <svg
30
+ class="spectrum-Icon spectrum-Icon--sizeS spectrum-Menu-itemIcon"
31
+ focusable="false"
32
+ aria-hidden="true"
33
+ aria-label={icon}
34
+ >
35
+ <use xlink:href="#spectrum-icon-18-{icon}" />
36
+ </svg>
49
37
  {/if}
50
38
  <span class="spectrum-Menu-itemLabel"><slot /></span>
51
- {#if keys?.length}
52
- <div class="keys">
53
- {#each keys as key}
54
- <div class="key">
55
- {#if key.startsWith("!")}
56
- <Icon size="XS" name={key.split("!")[1]} />
57
- {:else}
58
- {key}
59
- {/if}
60
- </div>
61
- {/each}
62
- </div>
63
- {/if}
64
39
  </li>
65
40
 
66
41
  <style>
67
- .icon {
42
+ .spectrum-Menu-itemIcon {
68
43
  align-self: center;
69
- margin-right: var(--spacing-s);
70
- }
71
- .keys {
72
- margin-left: 30px;
73
- display: flex;
74
- flex-direction: row;
75
- justify-content: flex-end;
76
- align-items: center;
77
- gap: 4px;
78
- }
79
- .key {
80
- color: var(--spectrum-global-color-gray-900);
81
- padding: 2px 4px;
82
- font-size: 12px;
83
- font-weight: 600;
84
- background-color: var(--spectrum-global-color-gray-300);
85
- border-radius: 4px;
86
- min-width: 12px;
87
- height: 16px;
88
- text-align: center;
89
- margin: -1px 0;
90
- display: grid;
91
- place-items: center;
92
- }
93
- .is-disabled .key {
94
- color: var(--spectrum-global-color-gray-600);
95
44
  }
96
45
  </style>
@@ -11,8 +11,6 @@
11
11
 
12
12
  const dispatch = createEventDispatcher()
13
13
  let visible = fixed || inline
14
- let modal
15
-
16
14
  $: dispatch(visible ? "show" : "hide")
17
15
 
18
16
  export function show() {
@@ -43,22 +41,12 @@
43
41
  }
44
42
  }
45
43
 
46
- async function focusModal(node) {
47
- await tick()
48
-
49
- // Try to focus first input
44
+ async function focusFirstInput(node) {
50
45
  const inputs = node.querySelectorAll("input")
51
46
  if (inputs?.length) {
47
+ await tick()
52
48
  inputs[0].focus()
53
49
  }
54
-
55
- // Otherwise try to focus confirmation button
56
- else if (modal) {
57
- const confirm = modal.querySelector(".confirm-wrap .spectrum-Button")
58
- if (confirm) {
59
- confirm.focus()
60
- }
61
- }
62
50
  }
63
51
 
64
52
  setContext(Context.Modal, { show, hide, cancel })
@@ -68,7 +56,7 @@
68
56
 
69
57
  {#if inline}
70
58
  {#if visible}
71
- <div use:focusModal bind:this={modal} class="spectrum-Modal inline is-open">
59
+ <div use:focusFirstInput class="spectrum-Modal inline is-open">
72
60
  <slot />
73
61
  </div>
74
62
  {/if}
@@ -82,18 +70,17 @@
82
70
  -->
83
71
  <Portal target=".modal-container">
84
72
  {#if visible}
85
- <div class="spectrum-Underlay is-open" on:mousedown|self={cancel}>
86
- <div
87
- class="background"
88
- in:fade={{ duration: 200 }}
89
- out:fade|local={{ duration: 200 }}
90
- />
73
+ <div
74
+ class="spectrum-Underlay is-open"
75
+ in:fade={{ duration: 200 }}
76
+ out:fade|local={{ duration: 200 }}
77
+ on:mousedown|self={cancel}
78
+ >
91
79
  <div class="modal-wrapper" on:mousedown|self={cancel}>
92
80
  <div class="modal-inner-wrapper" on:mousedown|self={cancel}>
93
81
  <slot name="outside" />
94
82
  <div
95
- use:focusModal
96
- bind:this={modal}
83
+ use:focusFirstInput
97
84
  class="spectrum-Modal is-open"
98
85
  in:fly={{ y: 30, duration: 200 }}
99
86
  out:fly|local={{ y: 30, duration: 200 }}
@@ -116,17 +103,7 @@
116
103
  z-index: 999;
117
104
  overflow: auto;
118
105
  overflow-x: hidden;
119
- background: transparent;
120
- }
121
- .background {
122
- background: var(--modal-background, rgba(0, 0, 0, 0.75));
123
- position: fixed;
124
- top: 0;
125
- left: 0;
126
- height: 100vh;
127
- width: 100vw;
128
- opacity: 0.65;
129
- pointer-events: none;
106
+ background: rgba(0, 0, 0, 0.75);
130
107
  }
131
108
 
132
109
  .modal-wrapper {
@@ -63,7 +63,7 @@
63
63
 
64
64
  <style>
65
65
  .spectrum-Popover {
66
- min-width: var(--spectrum-global-dimension-size-2000);
66
+ min-width: var(--spectrum-global-dimension-size-2000) !important;
67
67
  }
68
68
  .spectrum-Popover.is-open.spectrum-Popover--withTip {
69
69
  margin-top: var(--spacing-xs);
@@ -15,14 +15,24 @@
15
15
 
16
16
  {#each attachments as attachment}
17
17
  {#if isImage(attachment.extension)}
18
- <Link quiet target="_blank" href={attachment.url}>
18
+ <Link
19
+ quiet
20
+ target="_blank"
21
+ download={attachment.name}
22
+ href={attachment.url}
23
+ >
19
24
  <div class="center" title={attachment.name}>
20
25
  <img src={attachment.url} alt={attachment.extension} />
21
26
  </div>
22
27
  </Link>
23
28
  {:else}
24
29
  <div class="file" title={attachment.name}>
25
- <Link quiet target="_blank" href={attachment.url}>
30
+ <Link
31
+ quiet
32
+ target="_blank"
33
+ download={attachment.name}
34
+ href={attachment.url}
35
+ >
26
36
  {attachment.extension}
27
37
  </Link>
28
38
  </div>