@budibase/bbui 2.0.38 → 2.0.39

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.0.38",
4
+ "version": "2.0.39",
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": "^2.0.38",
41
+ "@budibase/string-templates": "^2.0.39",
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": "59f4582687ba685c4f2228c0d5b29f5ed8400cbc"
88
+ "gitHead": "dce0d52b0ad22c3214c348154a7090f872a82ecf"
89
89
  }
@@ -1,6 +1,6 @@
1
1
  <script>
2
2
  import Picker from "./Picker.svelte"
3
- import { createEventDispatcher } from "svelte"
3
+ import { createEventDispatcher, onMount } from "svelte"
4
4
 
5
5
  export let value = []
6
6
  export let id = null
@@ -16,8 +16,33 @@
16
16
  export let autoWidth = false
17
17
 
18
18
  const dispatch = createEventDispatcher()
19
+ const parseValues = value => {
20
+ return Array.isArray(value)
21
+ ? value.reduce((acc, entry) => {
22
+ if (typeof ele === "string" && entry.trim() === "") {
23
+ return acc
24
+ }
25
+ let processedOption = String(entry)
26
+ if (options.indexOf(processedOption) > -1) {
27
+ acc.push(processedOption)
28
+ }
29
+ return acc
30
+ }, [])
31
+ : []
32
+ }
33
+ let loaded = false
34
+
35
+ $: combinedValues = value ? [...value].concat(options) : []
36
+ $: superSet = new Set(combinedValues)
37
+
38
+ $: if (loaded && options.length != superSet.size) {
39
+ // ensure that the values being pushed in are valid.
40
+ dispatch("change", parseValues(value))
41
+ }
42
+
19
43
  $: selectedLookupMap = getSelectedLookupMap(value)
20
44
  $: optionLookupMap = getOptionLookupMap(options)
45
+
21
46
  $: fieldText = getFieldText(value, optionLookupMap, placeholder)
22
47
  $: isOptionSelected = optionValue => selectedLookupMap[optionValue] === true
23
48
  $: toggleOption = makeToggleOption(selectedLookupMap, value)
@@ -70,6 +95,10 @@
70
95
  }
71
96
  }
72
97
  }
98
+
99
+ onMount(() => {
100
+ loaded = true
101
+ })
73
102
  </script>
74
103
 
75
104
  <Picker