@budibase/bbui 1.2.43 → 1.2.44-alpha.2

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.43",
4
+ "version": "1.2.44-alpha.2",
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.43",
41
+ "@budibase/string-templates": "1.2.44-alpha.2",
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": "bfdbb8672db3f9160c8a579fca565f7a455db25a"
88
+ "gitHead": "d6e4ab4c2a9ced9e5990306a538830451def9430"
89
89
  }
@@ -16,6 +16,7 @@
16
16
  export let appendTo = undefined
17
17
  export let timeOnly = false
18
18
  export let ignoreTimezones = false
19
+ export let time24hr = false
19
20
 
20
21
  const dispatch = createEventDispatcher()
21
22
  const flatpickrId = `${uuid()}-wrapper`
@@ -37,6 +38,7 @@
37
38
  enableTime: timeOnly || enableTime || false,
38
39
  noCalendar: timeOnly || false,
39
40
  altInput: true,
41
+ time_24hr: time24hr || false,
40
42
  altFormat: timeOnly ? "H:i" : enableTime ? "F j Y, H:i" : "F j, Y",
41
43
  wrap: true,
42
44
  appendTo,
@@ -49,6 +51,12 @@
49
51
  },
50
52
  }
51
53
 
54
+ $: redrawOptions = {
55
+ timeOnly,
56
+ enableTime,
57
+ time24hr,
58
+ }
59
+
52
60
  const handleChange = event => {
53
61
  const [dates] = event.detail
54
62
  const noTimezone = enableTime && !timeOnly && ignoreTimezones
@@ -142,7 +150,7 @@
142
150
  }
143
151
  </script>
144
152
 
145
- {#key timeOnly}
153
+ {#key redrawOptions}
146
154
  <Flatpickr
147
155
  bind:flatpickr
148
156
  value={parseDate(value)}
@@ -17,6 +17,7 @@
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
20
21
  export let handleFileTooLarge = null
21
22
  export let handleTooManyFiles = null
22
23
  export let gallery = true
@@ -94,6 +95,11 @@
94
95
  "change",
95
96
  value.filter((x, idx) => idx !== selectedImageIdx)
96
97
  )
98
+ if (deleteAttachments) {
99
+ await deleteAttachments(
100
+ value.filter((x, idx) => idx === selectedImageIdx).map(item => item.key)
101
+ )
102
+ }
97
103
  selectedImageIdx = 0
98
104
  }
99
105
 
@@ -23,7 +23,7 @@
23
23
  $: toggleOption = makeToggleOption(selectedLookupMap, value)
24
24
 
25
25
  const getFieldText = (value, map, placeholder) => {
26
- if (value?.length) {
26
+ if (Array.isArray(value) && value.length > 0) {
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 (value?.length) {
39
+ if (Array.isArray(value) && value.length > 0) {
40
40
  value.forEach(option => {
41
41
  if (option) {
42
42
  map[option] = true
@@ -10,6 +10,7 @@
10
10
  export let error = null
11
11
  export let enableTime = true
12
12
  export let timeOnly = false
13
+ export let time24hr = false
13
14
  export let placeholder = null
14
15
  export let appendTo = undefined
15
16
  export let ignoreTimezones = false
@@ -30,6 +31,7 @@
30
31
  {placeholder}
31
32
  {enableTime}
32
33
  {timeOnly}
34
+ {time24hr}
33
35
  {appendTo}
34
36
  {ignoreTimezones}
35
37
  on:change={onChange}
@@ -10,6 +10,7 @@
10
10
  export let error = null
11
11
  export let fileSizeLimit = undefined
12
12
  export let processFiles = undefined
13
+ export let deleteAttachments = undefined
13
14
  export let handleFileTooLarge = undefined
14
15
  export let handleTooManyFiles = undefined
15
16
  export let gallery = true
@@ -30,6 +31,7 @@
30
31
  {value}
31
32
  {fileSizeLimit}
32
33
  {processFiles}
34
+ {deleteAttachments}
33
35
  {handleFileTooLarge}
34
36
  {handleTooManyFiles}
35
37
  {gallery}
@@ -83,4 +83,9 @@
83
83
  transform: translateX(-50%);
84
84
  text-align: center;
85
85
  }
86
+
87
+ .spectrum-Icon--sizeXS {
88
+ width: 10px;
89
+ height: 10px;
90
+ }
86
91
  </style>
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import { createEventDispatcher, getContext } from "svelte"
3
+ import Icon from "../Icon/Icon.svelte"
3
4
 
4
5
  const dispatch = createEventDispatcher()
5
6
  const actionMenu = getContext("actionMenu")
@@ -8,6 +9,22 @@
8
9
  export let icon = undefined
9
10
  export let disabled = undefined
10
11
  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
+ }
11
28
 
12
29
  const onClick = () => {
13
30
  if (actionMenu && !noClose) {
@@ -26,20 +43,54 @@
26
43
  tabindex="0"
27
44
  >
28
45
  {#if icon}
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>
46
+ <div class="icon">
47
+ <Icon name={icon} size="S" />
48
+ </div>
37
49
  {/if}
38
50
  <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}
39
64
  </li>
40
65
 
41
66
  <style>
42
- .spectrum-Menu-itemIcon {
67
+ .icon {
43
68
  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);
44
95
  }
45
96
  </style>
@@ -11,6 +11,8 @@
11
11
 
12
12
  const dispatch = createEventDispatcher()
13
13
  let visible = fixed || inline
14
+ let modal
15
+
14
16
  $: dispatch(visible ? "show" : "hide")
15
17
 
16
18
  export function show() {
@@ -41,12 +43,22 @@
41
43
  }
42
44
  }
43
45
 
44
- async function focusFirstInput(node) {
46
+ async function focusModal(node) {
47
+ await tick()
48
+
49
+ // Try to focus first input
45
50
  const inputs = node.querySelectorAll("input")
46
51
  if (inputs?.length) {
47
- await tick()
48
52
  inputs[0].focus()
49
53
  }
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
+ }
50
62
  }
51
63
 
52
64
  setContext(Context.Modal, { show, hide, cancel })
@@ -56,7 +68,7 @@
56
68
 
57
69
  {#if inline}
58
70
  {#if visible}
59
- <div use:focusFirstInput class="spectrum-Modal inline is-open">
71
+ <div use:focusModal bind:this={modal} class="spectrum-Modal inline is-open">
60
72
  <slot />
61
73
  </div>
62
74
  {/if}
@@ -70,17 +82,18 @@
70
82
  -->
71
83
  <Portal target=".modal-container">
72
84
  {#if visible}
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
- >
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
+ />
79
91
  <div class="modal-wrapper" on:mousedown|self={cancel}>
80
92
  <div class="modal-inner-wrapper" on:mousedown|self={cancel}>
81
93
  <slot name="outside" />
82
94
  <div
83
- use:focusFirstInput
95
+ use:focusModal
96
+ bind:this={modal}
84
97
  class="spectrum-Modal is-open"
85
98
  in:fly={{ y: 30, duration: 200 }}
86
99
  out:fly|local={{ y: 30, duration: 200 }}
@@ -103,7 +116,17 @@
103
116
  z-index: 999;
104
117
  overflow: auto;
105
118
  overflow-x: hidden;
106
- background: rgba(0, 0, 0, 0.75);
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;
107
130
  }
108
131
 
109
132
  .modal-wrapper {
@@ -63,7 +63,7 @@
63
63
 
64
64
  <style>
65
65
  .spectrum-Popover {
66
- min-width: var(--spectrum-global-dimension-size-2000) !important;
66
+ min-width: var(--spectrum-global-dimension-size-2000);
67
67
  }
68
68
  .spectrum-Popover.is-open.spectrum-Popover--withTip {
69
69
  margin-top: var(--spacing-xs);