@budibase/bbui 2.9.33-alpha.2 → 2.9.34

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.9.33-alpha.2",
4
+ "version": "2.9.34",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -38,8 +38,8 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@adobe/spectrum-css-workflow-icons": "1.2.1",
41
- "@budibase/shared-core": "2.9.33-alpha.2",
42
- "@budibase/string-templates": "2.9.33-alpha.2",
41
+ "@budibase/shared-core": "2.9.34",
42
+ "@budibase/string-templates": "2.9.34",
43
43
  "@spectrum-css/accordion": "3.0.24",
44
44
  "@spectrum-css/actionbutton": "1.0.1",
45
45
  "@spectrum-css/actiongroup": "1.0.1",
@@ -106,5 +106,5 @@
106
106
  }
107
107
  }
108
108
  },
109
- "gitHead": "b7243d86d2b0c7871ba08bef072fe964d90662c5"
109
+ "gitHead": "b3c41ab2f3bf614f68b3de7b0e5ad16f08fc38a9"
110
110
  }
@@ -17,7 +17,6 @@ export default function positionDropdown(element, opts) {
17
17
  maxWidth,
18
18
  useAnchorWidth,
19
19
  offset = 5,
20
- customUpdate,
21
20
  } = opts
22
21
  if (!anchor) {
23
22
  return
@@ -34,41 +33,33 @@ export default function positionDropdown(element, opts) {
34
33
  top: null,
35
34
  }
36
35
 
37
- if (typeof customUpdate === "function") {
38
- styles = customUpdate(anchorBounds, elementBounds, styles)
36
+ // Determine vertical styles
37
+ if (align === "right-outside") {
38
+ styles.top = anchorBounds.top
39
+ } else if (window.innerHeight - anchorBounds.bottom < 100) {
40
+ styles.top = anchorBounds.top - elementBounds.height - offset
41
+ styles.maxHeight = maxHeight || 240
39
42
  } else {
40
- // Determine vertical styles
41
- if (align === "right-outside") {
42
- styles.top = anchorBounds.top
43
- } else if (
44
- window.innerHeight - anchorBounds.bottom <
45
- (maxHeight || 100)
46
- ) {
47
- styles.top = anchorBounds.top - elementBounds.height - offset
48
- styles.maxHeight = maxHeight || 240
49
- } else {
50
- styles.top = anchorBounds.bottom + offset
51
- styles.maxHeight =
52
- maxHeight || window.innerHeight - anchorBounds.bottom - 20
53
- }
43
+ styles.top = anchorBounds.bottom + offset
44
+ styles.maxHeight =
45
+ maxHeight || window.innerHeight - anchorBounds.bottom - 20
46
+ }
54
47
 
55
- // Determine horizontal styles
56
- if (!maxWidth && useAnchorWidth) {
57
- styles.maxWidth = anchorBounds.width
58
- }
59
- if (useAnchorWidth) {
60
- styles.minWidth = anchorBounds.width
61
- }
62
- if (align === "right") {
63
- styles.left =
64
- anchorBounds.left + anchorBounds.width - elementBounds.width
65
- } else if (align === "right-outside") {
66
- styles.left = anchorBounds.right + offset
67
- } else if (align === "left-outside") {
68
- styles.left = anchorBounds.left - elementBounds.width - offset
69
- } else {
70
- styles.left = anchorBounds.left
71
- }
48
+ // Determine horizontal styles
49
+ if (!maxWidth && useAnchorWidth) {
50
+ styles.maxWidth = anchorBounds.width
51
+ }
52
+ if (useAnchorWidth) {
53
+ styles.minWidth = anchorBounds.width
54
+ }
55
+ if (align === "right") {
56
+ styles.left = anchorBounds.left + anchorBounds.width - elementBounds.width
57
+ } else if (align === "right-outside") {
58
+ styles.left = anchorBounds.right + offset
59
+ } else if (align === "left-outside") {
60
+ styles.left = anchorBounds.left - elementBounds.width - offset
61
+ } else {
62
+ styles.left = anchorBounds.left
72
63
  }
73
64
 
74
65
  // Apply styles
@@ -1,8 +1,8 @@
1
1
  <script>
2
- import Popover from "../Popover/Popover.svelte"
3
- import Layout from "../Layout/Layout.svelte"
4
2
  import { createEventDispatcher } from "svelte"
5
3
  import "@spectrum-css/popover/dist/index-vars.css"
4
+ import clickOutside from "../Actions/click_outside"
5
+ import { fly } from "svelte/transition"
6
6
  import Icon from "../Icon/Icon.svelte"
7
7
  import Input from "../Form/Input.svelte"
8
8
  import { capitalise } from "../helpers"
@@ -10,11 +10,9 @@
10
10
  export let value
11
11
  export let size = "M"
12
12
  export let spectrumTheme
13
- export let offset
14
- export let align
13
+ export let alignRight = false
15
14
 
16
- let dropdown
17
- let preview
15
+ let open = false
18
16
 
19
17
  $: customValue = getCustomValue(value)
20
18
  $: checkColor = getCheckColor(value)
@@ -84,7 +82,7 @@
84
82
 
85
83
  const onChange = value => {
86
84
  dispatch("change", value)
87
- dropdown.hide()
85
+ open = false
88
86
  }
89
87
 
90
88
  const getCustomValue = value => {
@@ -121,25 +119,30 @@
121
119
 
122
120
  return "var(--spectrum-global-color-static-gray-900)"
123
121
  }
124
- </script>
125
122
 
126
- <div
127
- bind:this={preview}
128
- class="preview size--{size || 'M'}"
129
- on:click={() => {
130
- dropdown.toggle()
131
- }}
132
- >
133
- <div
134
- class="fill {spectrumTheme || ''}"
135
- style={value ? `background: ${value};` : ""}
136
- class:placeholder={!value}
137
- />
138
- </div>
123
+ const handleOutsideClick = event => {
124
+ if (open) {
125
+ event.stopPropagation()
126
+ open = false
127
+ }
128
+ }
129
+ </script>
139
130
 
140
- <Popover bind:this={dropdown} anchor={preview} maxHeight={320} {offset} {align}>
141
- <Layout paddingX="XL" paddingY="L">
142
- <div class="container">
131
+ <div class="container">
132
+ <div class="preview size--{size || 'M'}" on:click={() => (open = true)}>
133
+ <div
134
+ class="fill {spectrumTheme || ''}"
135
+ style={value ? `background: ${value};` : ""}
136
+ class:placeholder={!value}
137
+ />
138
+ </div>
139
+ {#if open}
140
+ <div
141
+ use:clickOutside={handleOutsideClick}
142
+ transition:fly|local={{ y: -20, duration: 200 }}
143
+ class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
144
+ class:spectrum-Popover--align-right={alignRight}
145
+ >
143
146
  {#each categories as category}
144
147
  <div class="category">
145
148
  <div class="heading">{category.label}</div>
@@ -184,8 +187,8 @@
184
187
  </div>
185
188
  </div>
186
189
  </div>
187
- </Layout>
188
- </Popover>
190
+ {/if}
191
+ </div>
189
192
 
190
193
  <style>
191
194
  .container {
@@ -245,6 +248,20 @@
245
248
  width: 48px;
246
249
  height: 48px;
247
250
  }
251
+ .spectrum-Popover {
252
+ width: 210px;
253
+ z-index: 999;
254
+ top: 100%;
255
+ padding: var(--spacing-l) var(--spacing-xl);
256
+ display: flex;
257
+ flex-direction: column;
258
+ justify-content: flex-start;
259
+ align-items: stretch;
260
+ gap: var(--spacing-xl);
261
+ }
262
+ .spectrum-Popover--align-right {
263
+ right: 0;
264
+ }
248
265
  .colors {
249
266
  display: grid;
250
267
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
@@ -280,11 +297,7 @@
280
297
  .category--custom .heading {
281
298
  margin-bottom: var(--spacing-xs);
282
299
  }
283
- .container {
284
- display: flex;
285
- flex-direction: column;
286
- gap: var(--spacing-xl);
287
- }
300
+
288
301
  .spectrum-wrapper {
289
302
  background-color: transparent;
290
303
  }
@@ -44,9 +44,7 @@
44
44
  align-items: stretch;
45
45
  border-bottom: var(--border-light);
46
46
  }
47
- .property-group-container:last-child {
48
- border-bottom: 0px;
49
- }
47
+
50
48
  .property-group-name {
51
49
  cursor: pointer;
52
50
  display: flex;
@@ -4,8 +4,6 @@
4
4
  import Body from "../Typography/Body.svelte"
5
5
  import Heading from "../Typography/Heading.svelte"
6
6
  import { setContext } from "svelte"
7
- import { createEventDispatcher } from "svelte"
8
- import { generate } from "shortid"
9
7
 
10
8
  export let title
11
9
  export let fillWidth
@@ -13,17 +11,13 @@
13
11
  export let width = "calc(100% - 626px)"
14
12
  export let headless = false
15
13
 
16
- const dispatch = createEventDispatcher()
17
-
18
14
  let visible = false
19
- let drawerId = generate()
20
15
 
21
16
  export function show() {
22
17
  if (visible) {
23
18
  return
24
19
  }
25
20
  visible = true
26
- dispatch("drawerShow", drawerId)
27
21
  }
28
22
 
29
23
  export function hide() {
@@ -31,7 +25,6 @@
31
25
  return
32
26
  }
33
27
  visible = false
34
- dispatch("drawerHide", drawerId)
35
28
  }
36
29
 
37
30
  setContext("drawer-actions", {
@@ -2,8 +2,8 @@
2
2
  import "@spectrum-css/inputgroup/dist/index-vars.css"
3
3
  import "@spectrum-css/popover/dist/index-vars.css"
4
4
  import "@spectrum-css/menu/dist/index-vars.css"
5
+ import { fly } from "svelte/transition"
5
6
  import { createEventDispatcher } from "svelte"
6
- import clickOutside from "../../Actions/click_outside"
7
7
 
8
8
  export let value = null
9
9
  export let id = null
@@ -80,11 +80,10 @@
80
80
  </svg>
81
81
  </button>
82
82
  {#if open}
83
+ <div class="overlay" on:mousedown|self={() => (open = false)} />
83
84
  <div
85
+ transition:fly|local={{ y: -20, duration: 200 }}
84
86
  class="spectrum-Popover spectrum-Popover--bottom is-open"
85
- use:clickOutside={() => {
86
- open = false
87
- }}
88
87
  >
89
88
  <ul class="spectrum-Menu" role="listbox">
90
89
  {#if options && Array.isArray(options)}
@@ -126,6 +125,14 @@
126
125
  .spectrum-Textfield-input {
127
126
  width: 0;
128
127
  }
128
+ .overlay {
129
+ position: fixed;
130
+ top: 0;
131
+ left: 0;
132
+ width: 100vw;
133
+ height: 100vh;
134
+ z-index: 999;
135
+ }
129
136
  .spectrum-Popover {
130
137
  max-height: 240px;
131
138
  width: 100%;
@@ -23,10 +23,6 @@
23
23
  export let animate = true
24
24
  export let customZindex
25
25
 
26
- export let handlePostionUpdate
27
- export let showPopover = true
28
- export let clickOutsideOverride = false
29
-
30
26
  $: target = portalTarget || getContext(Context.PopoverRoot) || ".spectrum"
31
27
 
32
28
  export const show = () => {
@@ -39,18 +35,7 @@
39
35
  open = false
40
36
  }
41
37
 
42
- export const toggle = () => {
43
- if (!open) {
44
- show()
45
- } else {
46
- hide()
47
- }
48
- }
49
-
50
38
  const handleOutsideClick = e => {
51
- if (clickOutsideOverride) {
52
- return
53
- }
54
39
  if (open) {
55
40
  // Stop propagation if the source is the anchor
56
41
  let node = e.target
@@ -69,9 +54,6 @@
69
54
  }
70
55
 
71
56
  function handleEscape(e) {
72
- if (!clickOutsideOverride) {
73
- return
74
- }
75
57
  if (open && e.key === "Escape") {
76
58
  hide()
77
59
  }
@@ -89,7 +71,6 @@
89
71
  maxWidth,
90
72
  useAnchorWidth,
91
73
  offset,
92
- customUpdate: handlePostionUpdate,
93
74
  }}
94
75
  use:clickOutside={{
95
76
  callback: dismissible ? handleOutsideClick : () => {},
@@ -98,7 +79,6 @@
98
79
  on:keydown={handleEscape}
99
80
  class="spectrum-Popover is-open"
100
81
  class:customZindex
101
- class:hide-popover={open && !showPopover}
102
82
  role="presentation"
103
83
  style="height: {customHeight}; --customZindex: {customZindex};"
104
84
  transition:fly|local={{ y: -20, duration: animate ? 200 : 0 }}
@@ -109,10 +89,6 @@
109
89
  {/if}
110
90
 
111
91
  <style>
112
- .hide-popover {
113
- display: contents;
114
- }
115
-
116
92
  .spectrum-Popover {
117
93
  min-width: var(--spectrum-global-dimension-size-2000);
118
94
  border-color: var(--spectrum-global-color-gray-300);