@budibase/bbui 2.9.30-alpha.11 → 2.9.30-alpha.13

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.30-alpha.11",
4
+ "version": "2.9.30-alpha.13",
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.30-alpha.11",
42
- "@budibase/string-templates": "2.9.30-alpha.11",
41
+ "@budibase/shared-core": "2.9.30-alpha.13",
42
+ "@budibase/string-templates": "2.9.30-alpha.13",
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": "86e421dc0862e9f04ea611997add10fbacf8cd74"
109
+ "gitHead": "b40d12ac024f628471a51bdce50cb8eafb5007f3"
110
110
  }
@@ -32,11 +32,10 @@ export default function positionDropdown(element, opts) {
32
32
  left: null,
33
33
  top: null,
34
34
  }
35
-
36
35
  // Determine vertical styles
37
36
  if (align === "right-outside") {
38
37
  styles.top = anchorBounds.top
39
- } else if (window.innerHeight - anchorBounds.bottom < 100) {
38
+ } else if (window.innerHeight - anchorBounds.bottom < (maxHeight || 100)) {
40
39
  styles.top = anchorBounds.top - elementBounds.height - offset
41
40
  styles.maxHeight = maxHeight || 240
42
41
  } else {
@@ -1,8 +1,8 @@
1
1
  <script>
2
+ import Popover from "../Popover/Popover.svelte"
3
+ import Layout from "../Layout/Layout.svelte"
2
4
  import { createEventDispatcher } from "svelte"
3
5
  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,9 +10,11 @@
10
10
  export let value
11
11
  export let size = "M"
12
12
  export let spectrumTheme
13
- export let alignRight = false
13
+ export let offset
14
+ export let align
14
15
 
15
- let open = false
16
+ let dropdown
17
+ let preview
16
18
 
17
19
  $: customValue = getCustomValue(value)
18
20
  $: checkColor = getCheckColor(value)
@@ -82,7 +84,7 @@
82
84
 
83
85
  const onChange = value => {
84
86
  dispatch("change", value)
85
- open = false
87
+ dropdown.hide()
86
88
  }
87
89
 
88
90
  const getCustomValue = value => {
@@ -119,30 +121,25 @@
119
121
 
120
122
  return "var(--spectrum-global-color-static-gray-900)"
121
123
  }
122
-
123
- const handleOutsideClick = event => {
124
- if (open) {
125
- event.stopPropagation()
126
- open = false
127
- }
128
- }
129
124
  </script>
130
125
 
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
- >
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>
139
+
140
+ <Popover bind:this={dropdown} anchor={preview} maxHeight={320} {offset} {align}>
141
+ <Layout paddingX="XL" paddingY="L">
142
+ <div class="container">
146
143
  {#each categories as category}
147
144
  <div class="category">
148
145
  <div class="heading">{category.label}</div>
@@ -187,8 +184,8 @@
187
184
  </div>
188
185
  </div>
189
186
  </div>
190
- {/if}
191
- </div>
187
+ </Layout>
188
+ </Popover>
192
189
 
193
190
  <style>
194
191
  .container {
@@ -248,20 +245,6 @@
248
245
  width: 48px;
249
246
  height: 48px;
250
247
  }
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
- }
265
248
  .colors {
266
249
  display: grid;
267
250
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
@@ -297,7 +280,11 @@
297
280
  .category--custom .heading {
298
281
  margin-bottom: var(--spacing-xs);
299
282
  }
300
-
283
+ .container {
284
+ display: flex;
285
+ flex-direction: column;
286
+ gap: var(--spacing-xl);
287
+ }
301
288
  .spectrum-wrapper {
302
289
  background-color: transparent;
303
290
  }
@@ -35,6 +35,14 @@
35
35
  open = false
36
36
  }
37
37
 
38
+ export const toggle = () => {
39
+ if (!open) {
40
+ show()
41
+ } else {
42
+ hide()
43
+ }
44
+ }
45
+
38
46
  const handleOutsideClick = e => {
39
47
  if (open) {
40
48
  // Stop propagation if the source is the anchor