@budibase/bbui 3.22.2 → 3.22.4
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/dist/bbui.mjs +3 -3
- package/dist/{easymde-c2c99922.mjs → easymde-f1db47d2.mjs} +1 -1
- package/dist/{index-8a0f8fbd.mjs → index-388d0a6d.mjs} +1672 -1447
- package/package.json +2 -2
- package/src/Banner/Banner.svelte +0 -9
- package/src/Form/Core/Picker.svelte +42 -14
- package/src/Form/Core/PickerIcon.svelte +25 -0
- package/src/Menu/Item.svelte +0 -1
- package/src/types/Picker.ts +23 -0
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.22.
|
|
4
|
+
"version": "3.22.4",
|
|
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": "
|
|
109
|
+
"gitHead": "cfc4bc92d83006b473fc2777f9be8b58e0406363"
|
|
110
110
|
}
|
package/src/Banner/Banner.svelte
CHANGED
|
@@ -18,11 +18,13 @@
|
|
|
18
18
|
import AbsTooltip from "../../Tooltip/AbsTooltip.svelte"
|
|
19
19
|
import { PopoverAlignment } from "../../constants"
|
|
20
20
|
import Search from "./Search.svelte"
|
|
21
|
+
import PickerIcon from "./PickerIcon.svelte"
|
|
22
|
+
import type { PickerIconInput, ResolvedIcon } from "../../types/Picker"
|
|
21
23
|
|
|
22
24
|
export let id: string | undefined = undefined
|
|
23
25
|
export let disabled: boolean = false
|
|
24
26
|
export let fieldText: string = ""
|
|
25
|
-
export let fieldIcon:
|
|
27
|
+
export let fieldIcon: PickerIconInput = undefined
|
|
26
28
|
export let fieldColour: string = ""
|
|
27
29
|
export let isPlaceholder: boolean = false
|
|
28
30
|
export let placeholderOption: string | undefined | boolean = undefined
|
|
@@ -72,8 +74,28 @@
|
|
|
72
74
|
|
|
73
75
|
const dispatch = createEventDispatcher()
|
|
74
76
|
|
|
75
|
-
let button:
|
|
76
|
-
let component:
|
|
77
|
+
let button: HTMLButtonElement | null = null
|
|
78
|
+
let component: HTMLUListElement | null = null
|
|
79
|
+
let optionIconDescriptor: ResolvedIcon | null = null
|
|
80
|
+
|
|
81
|
+
const resolveIcon = (icon: PickerIconInput): ResolvedIcon | null => {
|
|
82
|
+
if (!icon) {
|
|
83
|
+
return null
|
|
84
|
+
}
|
|
85
|
+
if (typeof icon === "object" && icon.component) {
|
|
86
|
+
return {
|
|
87
|
+
type: "component",
|
|
88
|
+
component: icon.component,
|
|
89
|
+
props: icon.props || {},
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (typeof icon === "string") {
|
|
93
|
+
return { type: "string", value: icon }
|
|
94
|
+
}
|
|
95
|
+
return null
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
$: resolvedFieldIcon = resolveIcon(fieldIcon)
|
|
77
99
|
|
|
78
100
|
$: sortedOptions = getSortedOptions(options, getOptionLabel, sort)
|
|
79
101
|
$: filteredOptions = getFilteredOptions(
|
|
@@ -136,7 +158,7 @@
|
|
|
136
158
|
|
|
137
159
|
$: component?.addEventListener("scroll", onScroll)
|
|
138
160
|
onDestroy(() => {
|
|
139
|
-
component?.removeEventListener("scroll",
|
|
161
|
+
component?.removeEventListener("scroll", onScroll)
|
|
140
162
|
})
|
|
141
163
|
</script>
|
|
142
164
|
|
|
@@ -150,16 +172,14 @@
|
|
|
150
172
|
on:click={onClick}
|
|
151
173
|
bind:this={button}
|
|
152
174
|
>
|
|
153
|
-
{#if
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
</span>
|
|
162
|
-
{/if}
|
|
175
|
+
{#if resolvedFieldIcon}
|
|
176
|
+
<span
|
|
177
|
+
class="option-extra icon"
|
|
178
|
+
class:field-icon={useOptionIconImage &&
|
|
179
|
+
resolvedFieldIcon.type !== "component"}
|
|
180
|
+
>
|
|
181
|
+
<PickerIcon icon={resolvedFieldIcon} {useOptionIconImage} />
|
|
182
|
+
</span>
|
|
163
183
|
{/if}
|
|
164
184
|
{#if fieldColour}
|
|
165
185
|
<span class="option-extra">
|
|
@@ -274,6 +294,11 @@
|
|
|
274
294
|
{/if}
|
|
275
295
|
</span>
|
|
276
296
|
{/if}
|
|
297
|
+
{#if (optionIconDescriptor = resolveIcon(getOptionIcon(option, idx)))}
|
|
298
|
+
<span class="option-extra icon">
|
|
299
|
+
<PickerIcon icon={optionIconDescriptor} {useOptionIconImage} />
|
|
300
|
+
</span>
|
|
301
|
+
{/if}
|
|
277
302
|
{#if getOptionColour(option, idx)}
|
|
278
303
|
<span class="option-extra">
|
|
279
304
|
<StatusLight square color={getOptionColour(option, idx)} />
|
|
@@ -378,6 +403,9 @@
|
|
|
378
403
|
.popover-content:not(.auto-width) .spectrum-Menu-itemLabel {
|
|
379
404
|
width: 0;
|
|
380
405
|
flex: 1 1 auto;
|
|
406
|
+
overflow: hidden;
|
|
407
|
+
text-overflow: ellipsis;
|
|
408
|
+
white-space: nowrap;
|
|
381
409
|
}
|
|
382
410
|
.popover-content.auto-width .spectrum-Menu-item {
|
|
383
411
|
padding-right: var(--spacing-xl);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from "../../Icon/Icon.svelte"
|
|
3
|
+
import type { ResolvedIcon } from "../../types/Picker"
|
|
4
|
+
|
|
5
|
+
export let icon: ResolvedIcon | null = null
|
|
6
|
+
export let useOptionIconImage: boolean = false
|
|
7
|
+
export let defaultColour: string = "var(--spectrum-global-color-gray-600)"
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{#if icon}
|
|
11
|
+
{#if icon.type === "component"}
|
|
12
|
+
<svelte:component this={icon.component} {...icon.props} />
|
|
13
|
+
{:else if useOptionIconImage}
|
|
14
|
+
<img class="icon-dims" src={icon.value} alt="icon" />
|
|
15
|
+
{:else}
|
|
16
|
+
<Icon size="M" color={defaultColour} name={icon.value} />
|
|
17
|
+
{/if}
|
|
18
|
+
{/if}
|
|
19
|
+
|
|
20
|
+
<style>
|
|
21
|
+
.icon-dims {
|
|
22
|
+
height: 15px;
|
|
23
|
+
width: auto;
|
|
24
|
+
}
|
|
25
|
+
</style>
|
package/src/Menu/Item.svelte
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ComponentType } from "svelte"
|
|
2
|
+
|
|
3
|
+
type ComponentIcon = {
|
|
4
|
+
type: "component"
|
|
5
|
+
component: ComponentType
|
|
6
|
+
props?: Record<string, unknown>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
type StringIcon = {
|
|
10
|
+
type: "string"
|
|
11
|
+
value: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ResolvedIcon = ComponentIcon | StringIcon
|
|
15
|
+
|
|
16
|
+
export type PickerIconInput =
|
|
17
|
+
| string
|
|
18
|
+
| {
|
|
19
|
+
component: ComponentType
|
|
20
|
+
props?: Record<string, unknown>
|
|
21
|
+
}
|
|
22
|
+
| null
|
|
23
|
+
| undefined
|