@budibase/bbui 3.13.12 → 3.13.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": "3.13.12",
4
+ "version": "3.13.13",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.ts",
7
7
  "module": "dist/bbui.mjs",
@@ -106,5 +106,5 @@
106
106
  }
107
107
  }
108
108
  },
109
- "gitHead": "fc4f6a024f4bd3a9cb8af3f292ce0c783a4331a3"
109
+ "gitHead": "12d0bfb1846c841fb2043159bfadc99b4424ae09"
110
110
  }
@@ -4,9 +4,10 @@
4
4
 
5
5
  <script lang="ts">
6
6
  import Picker from "./Picker.svelte"
7
+ import type { Primitive } from "@budibase/types"
7
8
  import { createEventDispatcher } from "svelte"
8
9
 
9
- export let value: string[] = []
10
+ export let value: Primitive[] = []
10
11
  export let id: string | undefined = undefined
11
12
  export let placeholder: string | null = null
12
13
  export let disabled: boolean = false
@@ -36,7 +37,7 @@
36
37
  $: toggleOption = makeToggleOption(selectedLookupMap, arrayValue)
37
38
 
38
39
  const getFieldText = (
39
- value: string[],
40
+ value: Primitive[],
40
41
  map: Record<string, any> | null,
41
42
  placeholder: string | null
42
43
  ) => {
@@ -44,19 +45,25 @@
44
45
  if (!map) {
45
46
  return ""
46
47
  }
47
- const vals = value.map(option => map[option] || option).join(", ")
48
+ const vals = value
49
+ .map(v => {
50
+ const str = typeof v === "string" ? v : v.toString()
51
+ return map[str] || v
52
+ })
53
+ .join(", ")
48
54
  return `(${value.length}) ${vals}`
49
55
  } else {
50
56
  return placeholder || "Choose some options"
51
57
  }
52
58
  }
53
59
 
54
- const getSelectedLookupMap = (value: string[]) => {
60
+ const getSelectedLookupMap = (value: Primitive[]) => {
55
61
  const map: Record<string, boolean> = {}
56
62
  if (Array.isArray(value) && value.length > 0) {
57
- value.forEach(option => {
58
- if (option) {
59
- map[option] = true
63
+ value.forEach(v => {
64
+ if (v) {
65
+ const str = typeof v === "string" ? v : v.toString()
66
+ map[str] = true
60
67
  }
61
68
  })
62
69
  }
@@ -78,10 +85,16 @@
78
85
  return map
79
86
  }
80
87
 
81
- const makeToggleOption = (map: Record<string, boolean>, value: string[]) => {
88
+ const makeToggleOption = (
89
+ map: Record<string, boolean>,
90
+ value: Primitive[]
91
+ ) => {
82
92
  return (optionValue: string) => {
83
93
  if (map[optionValue]) {
84
- const filtered = value.filter(option => option !== optionValue)
94
+ // comparison needs to take into account different types, always compare them as strings
95
+ const filtered = value.filter(
96
+ option => option.toString() !== optionValue.toString()
97
+ )
85
98
  dispatch("change", filtered)
86
99
  } else {
87
100
  dispatch("change", [...value, optionValue])
@@ -316,7 +316,6 @@
316
316
  /* Icon and colour alignment */
317
317
  .check {
318
318
  display: none;
319
- margin-right: -8px;
320
319
  padding-left: 8px;
321
320
  }
322
321
  li.is-selected .check {
@@ -335,7 +334,7 @@
335
334
  }
336
335
  .popover-content.auto-width .spectrum-Menu-itemLabel {
337
336
  white-space: nowrap;
338
- overflow: none;
337
+ overflow: hidden;
339
338
  text-overflow: ellipsis;
340
339
  }
341
340
  .popover-content:not(.auto-width) .spectrum-Menu-itemLabel {