@budibase/bbui 3.20.2 → 3.20.3
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 +728 -735
- package/package.json +2 -2
- package/src/FancyForm/ErrorMessage.svelte +2 -2
- package/src/FancyForm/FancyField.svelte +12 -12
- package/src/FancyForm/FancyInput.svelte +15 -13
- package/src/FancyForm/FancySelect.svelte +33 -25
- package/src/context.ts +4 -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.20.
|
|
4
|
+
"version": "3.20.3",
|
|
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": "801ead90230ea40bd93f89daa92e2998310627ea"
|
|
110
110
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Icon from "../Icon/Icon.svelte"
|
|
1
|
+
<script lang="ts" generics="V">
|
|
3
2
|
import { getContext, onMount } from "svelte"
|
|
3
|
+
import Icon from "../Icon/Icon.svelte"
|
|
4
4
|
import ErrorMessage from "./ErrorMessage.svelte"
|
|
5
5
|
|
|
6
|
-
export let disabled = false
|
|
7
|
-
export let error = null
|
|
8
|
-
export let focused = false
|
|
9
|
-
export let clickable = false
|
|
10
|
-
export let validate
|
|
11
|
-
export let value
|
|
12
|
-
export let ref
|
|
13
|
-
export let autoHeight
|
|
14
|
-
export let compact = false
|
|
6
|
+
export let disabled: boolean = false
|
|
7
|
+
export let error: string | null = null
|
|
8
|
+
export let focused: boolean = false
|
|
9
|
+
export let clickable: boolean = false
|
|
10
|
+
export let validate: ((_value: V | undefined) => string | null) | null
|
|
11
|
+
export let value: V | undefined
|
|
12
|
+
export let ref: HTMLDivElement | undefined = undefined
|
|
13
|
+
export let autoHeight: boolean | undefined = undefined
|
|
14
|
+
export let compact: boolean = false
|
|
15
15
|
|
|
16
16
|
const formContext = getContext("fancy-form")
|
|
17
|
-
const id = Math.random()
|
|
17
|
+
const id = Math.random().toString()
|
|
18
18
|
const API = {
|
|
19
19
|
validate: () => {
|
|
20
20
|
if (validate) {
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { UIEvent } from "@budibase/types"
|
|
2
3
|
import { createEventDispatcher, onMount } from "svelte"
|
|
4
|
+
import { fade } from "svelte/transition"
|
|
3
5
|
import FancyField from "./FancyField.svelte"
|
|
4
6
|
import FancyFieldLabel from "./FancyFieldLabel.svelte"
|
|
5
|
-
import { fade } from "svelte/transition"
|
|
6
7
|
|
|
7
|
-
export let label
|
|
8
|
-
export let value
|
|
9
|
-
export let type = "text"
|
|
10
|
-
export let disabled = false
|
|
11
|
-
export let error = null
|
|
12
|
-
export let validate
|
|
13
|
-
|
|
14
|
-
export let
|
|
8
|
+
export let label: string
|
|
9
|
+
export let value: string
|
|
10
|
+
export let type: string = "text"
|
|
11
|
+
export let disabled: boolean = false
|
|
12
|
+
export let error: string | null = null
|
|
13
|
+
export let validate: ((_value: string | undefined) => string | null) | null =
|
|
14
|
+
null
|
|
15
|
+
export let suffix: string | null = null
|
|
16
|
+
export let validateOn: "change" | "blur" = "change"
|
|
15
17
|
|
|
16
18
|
const dispatch = createEventDispatcher()
|
|
17
19
|
|
|
18
|
-
let ref
|
|
20
|
+
let ref: HTMLInputElement
|
|
19
21
|
let focused = false
|
|
20
22
|
let autofilled = false
|
|
21
23
|
|
|
22
24
|
$: placeholder = !autofilled && !focused && !value
|
|
23
25
|
|
|
24
|
-
const onChange = e => {
|
|
26
|
+
const onChange = (e: UIEvent) => {
|
|
25
27
|
const newValue = e.target.value
|
|
26
28
|
dispatch("change", newValue)
|
|
27
29
|
value = newValue
|
|
@@ -30,7 +32,7 @@
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
const onBlur = e => {
|
|
35
|
+
const onBlur = (e: UIEvent) => {
|
|
34
36
|
focused = false
|
|
35
37
|
const newValue = e.target.value
|
|
36
38
|
dispatch("blur", newValue)
|
|
@@ -1,34 +1,44 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts" generics="O extends Record<string, any> | string">
|
|
2
2
|
import { createEventDispatcher } from "svelte"
|
|
3
|
-
import
|
|
3
|
+
import Picker from "../Form/Core/Picker.svelte"
|
|
4
4
|
import Icon from "../Icon/Icon.svelte"
|
|
5
|
-
import FancyFieldLabel from "./FancyFieldLabel.svelte"
|
|
6
5
|
import StatusLight from "../StatusLight/StatusLight.svelte"
|
|
7
|
-
import
|
|
6
|
+
import FancyField from "./FancyField.svelte"
|
|
7
|
+
import FancyFieldLabel from "./FancyFieldLabel.svelte"
|
|
8
8
|
|
|
9
|
-
export let label
|
|
10
|
-
export let value
|
|
11
|
-
export let disabled = false
|
|
12
|
-
export let error = null
|
|
13
|
-
export let validate = null
|
|
14
|
-
export let options = []
|
|
15
|
-
export let footer =
|
|
16
|
-
export let isOptionEnabled = () => true
|
|
17
|
-
export let getOptionLabel = option
|
|
18
|
-
|
|
19
|
-
export let
|
|
20
|
-
|
|
9
|
+
export let label: string | undefined
|
|
10
|
+
export let value: string | undefined
|
|
11
|
+
export let disabled: boolean = false
|
|
12
|
+
export let error: string | null = null
|
|
13
|
+
export let validate: ((_value: string | undefined) => string) | null = null
|
|
14
|
+
export let options: O[] = []
|
|
15
|
+
export let footer: string | undefined = undefined
|
|
16
|
+
export let isOptionEnabled = (_option: O) => true
|
|
17
|
+
export let getOptionLabel = (option: O, _index?: number) =>
|
|
18
|
+
extractProperty(option, "label")
|
|
19
|
+
export let getOptionValue = (option: O, _index?: number) =>
|
|
20
|
+
extractProperty(option, "value")
|
|
21
|
+
export let getOptionSubtitle = (option: O) =>
|
|
22
|
+
extractProperty(option, "subtitle")
|
|
23
|
+
export let getOptionColour: (
|
|
24
|
+
_option: O,
|
|
25
|
+
_index?: number
|
|
26
|
+
) => string | null = () => null
|
|
21
27
|
|
|
22
|
-
const dispatch = createEventDispatcher()
|
|
28
|
+
const dispatch = createEventDispatcher<{ change: string | undefined }>()
|
|
23
29
|
|
|
24
30
|
let open = false
|
|
25
|
-
let wrapper
|
|
31
|
+
let wrapper: HTMLDivElement
|
|
26
32
|
|
|
27
33
|
$: placeholder = !value
|
|
28
34
|
$: selectedLabel = getSelectedLabel(value)
|
|
29
35
|
$: fieldColour = getFieldAttribute(getOptionColour, value, options)
|
|
30
36
|
|
|
31
|
-
const getFieldAttribute = (
|
|
37
|
+
const getFieldAttribute = (
|
|
38
|
+
getAttribute: (_option: O, _index?: number) => string | null,
|
|
39
|
+
value: string | undefined,
|
|
40
|
+
options: O[]
|
|
41
|
+
) => {
|
|
32
42
|
// Wait for options to load if there is a value but no options
|
|
33
43
|
if (!options?.length) {
|
|
34
44
|
return ""
|
|
@@ -38,14 +48,14 @@
|
|
|
38
48
|
)
|
|
39
49
|
return index !== -1 ? getAttribute(options[index], index) : null
|
|
40
50
|
}
|
|
41
|
-
const extractProperty = (value, property) => {
|
|
51
|
+
const extractProperty = (value: O, property: string): string => {
|
|
42
52
|
if (value && typeof value === "object") {
|
|
43
53
|
return value[property]
|
|
44
54
|
}
|
|
45
55
|
return value
|
|
46
56
|
}
|
|
47
57
|
|
|
48
|
-
const onChange = newValue => {
|
|
58
|
+
const onChange = (newValue: string | undefined) => {
|
|
49
59
|
dispatch("change", newValue)
|
|
50
60
|
value = newValue
|
|
51
61
|
if (validate) {
|
|
@@ -54,7 +64,7 @@
|
|
|
54
64
|
open = false
|
|
55
65
|
}
|
|
56
66
|
|
|
57
|
-
const getSelectedLabel = value => {
|
|
67
|
+
const getSelectedLabel = (value: string | undefined) => {
|
|
58
68
|
if (!value || !options?.length) {
|
|
59
69
|
return ""
|
|
60
70
|
}
|
|
@@ -97,9 +107,7 @@
|
|
|
97
107
|
<div id="picker-wrapper">
|
|
98
108
|
<Picker
|
|
99
109
|
customAnchor={wrapper}
|
|
100
|
-
onlyPopover={true}
|
|
101
110
|
bind:open
|
|
102
|
-
{error}
|
|
103
111
|
{disabled}
|
|
104
112
|
{options}
|
|
105
113
|
{footer}
|
|
@@ -109,7 +117,7 @@
|
|
|
109
117
|
{getOptionColour}
|
|
110
118
|
{isOptionEnabled}
|
|
111
119
|
isPlaceholder={value == null || value === ""}
|
|
112
|
-
placeholderOption={placeholder === false ?
|
|
120
|
+
placeholderOption={placeholder === false ? undefined : placeholder}
|
|
113
121
|
onSelectOption={onChange}
|
|
114
122
|
isOptionSelected={option => option === value}
|
|
115
123
|
/>
|
package/src/context.ts
CHANGED