@budibase/bbui 3.6.0 → 3.7.0

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.6.0",
4
+ "version": "3.7.0",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.ts",
7
7
  "module": "dist/bbui.mjs",
@@ -99,5 +99,5 @@
99
99
  }
100
100
  }
101
101
  },
102
- "gitHead": "fcc8291c1f2968ee7fd17bd47ee6ca19181a14a7"
102
+ "gitHead": "701aef170adfb9552bb88b97a0231e31e6054f64"
103
103
  }
@@ -1,36 +1,36 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import "@spectrum-css/textfield/dist/index-vars.css"
3
3
  import { createEventDispatcher, onMount } from "svelte"
4
4
  import clickOutside from "../../Actions/click_outside"
5
5
  import Divider from "../../Divider/Divider.svelte"
6
+ import type { EnvDropdownType } from "../../types"
6
7
 
7
- export let value = null
8
- export let placeholder = null
9
- export let type = "text"
10
- export let disabled = false
11
- export let id = null
12
- export let readonly = false
13
- export let updateOnChange = true
14
- export let align
15
- export let autofocus = false
8
+ export let value: string | number | undefined = undefined
9
+ export let placeholder: string | undefined = undefined
10
+ export let type: EnvDropdownType = "text"
11
+ export let disabled: boolean = false
12
+ export let id: string | undefined = undefined
13
+ export let readonly: boolean = false
14
+ export let updateOnChange: boolean = true
15
+ export let align: string | undefined = undefined
16
+ export let autofocus: boolean = false
16
17
  export let variables
17
- export let showModal
18
+ export let showModal: () => void
18
19
  export let environmentVariablesEnabled
19
- export let handleUpgradePanel
20
+ export let handleUpgradePanel: () => void
20
21
  const dispatch = createEventDispatcher()
21
22
 
22
- let field
23
+ let field: HTMLInputElement
23
24
  let focus = false
24
25
  let iconFocused = false
25
26
  let open = false
26
27
 
27
- //eslint-disable-next-line
28
- const STRIP_NAME_REGEX = /(\w+?)(?=\ })/g
28
+ const STRIP_NAME_REGEX = /{{\s*env\.([^\s]+)\s*}}/g
29
29
 
30
30
  // Strips the name out of the value which is {{ env.Variable }} resulting in an array like ["Variable"]
31
- $: hbsValue = String(value)?.match(STRIP_NAME_REGEX) || []
31
+ $: hbsValue = (String(value) && STRIP_NAME_REGEX.exec(String(value))) || []
32
32
 
33
- const updateValue = newValue => {
33
+ const updateValue = (newValue: any) => {
34
34
  if (readonly) {
35
35
  return
36
36
  }
@@ -48,7 +48,7 @@
48
48
  focus = true
49
49
  }
50
50
 
51
- const onBlur = event => {
51
+ const onBlur = (event: any) => {
52
52
  if (readonly) {
53
53
  return
54
54
  }
@@ -56,14 +56,14 @@
56
56
  updateValue(event.target.value)
57
57
  }
58
58
 
59
- const onInput = event => {
59
+ const onInput = (event: any) => {
60
60
  if (readonly || !updateOnChange) {
61
61
  return
62
62
  }
63
63
  updateValue(event.target.value)
64
64
  }
65
65
 
66
- const handleOutsideClick = event => {
66
+ const handleOutsideClick = (event: Event) => {
67
67
  if (open) {
68
68
  event.stopPropagation()
69
69
  open = false
@@ -73,7 +73,7 @@
73
73
  }
74
74
  }
75
75
 
76
- const handleVarSelect = variable => {
76
+ const handleVarSelect = (variable: string) => {
77
77
  open = false
78
78
  focus = false
79
79
  iconFocused = false
@@ -121,10 +121,10 @@
121
121
 
122
122
  <input
123
123
  bind:this={field}
124
- disabled={hbsValue.length || disabled}
124
+ disabled={!!hbsValue.length || disabled}
125
125
  {readonly}
126
126
  {id}
127
- value={hbsValue.length ? `{{ ${hbsValue[0]} }}` : value}
127
+ value={(hbsValue.length ? `{{ ${hbsValue[1]} }}` : value) ?? ""}
128
128
  placeholder={placeholder || ""}
129
129
  on:click
130
130
  on:blur
@@ -13,7 +13,7 @@
13
13
  export let quiet = false
14
14
  export let align: "left" | "right" | "center" | undefined = undefined
15
15
  export let autofocus: boolean | null = false
16
- export let autocomplete: boolean | undefined
16
+ export let autocomplete: boolean | string | undefined
17
17
 
18
18
  const dispatch = createEventDispatcher()
19
19
 
@@ -1,26 +1,26 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import Field from "./Field.svelte"
3
3
  import EnvDropdown from "./Core/EnvDropdown.svelte"
4
4
  import { createEventDispatcher } from "svelte"
5
+ import type { EnvDropdownType } from "../types"
5
6
 
6
- export let value = null
7
- export let label = null
8
- export let labelPosition = "above"
9
- export let placeholder = null
10
- export let type = "text"
7
+ export let value: string | undefined = undefined
8
+ export let label: string | undefined = undefined
9
+ export let labelPosition: string = "above"
10
+ export let placeholder: string | undefined = undefined
11
+ export let type: EnvDropdownType = "text"
11
12
  export let disabled = false
12
13
  export let readonly = false
13
- export let error = null
14
+ export let error: string | undefined = undefined
14
15
  export let updateOnChange = true
15
- export let quiet = false
16
- export let autofocus
17
- export let variables
18
- export let showModal
19
- export let helpText = null
20
- export let environmentVariablesEnabled
21
- export let handleUpgradePanel
16
+ export let autofocus: boolean = false
17
+ export let variables: { name: string }[] = []
18
+ export let showModal: () => void
19
+ export let helpText: string | undefined = undefined
20
+ export let environmentVariablesEnabled: boolean = false
21
+ export let handleUpgradePanel: () => void = () => {}
22
22
  const dispatch = createEventDispatcher()
23
- const onChange = e => {
23
+ const onChange = (e: any) => {
24
24
  value = e.detail
25
25
  dispatch("change", e.detail)
26
26
  }
@@ -29,13 +29,11 @@
29
29
  <Field {helpText} {label} {labelPosition} {error}>
30
30
  <EnvDropdown
31
31
  {updateOnChange}
32
- {error}
33
32
  {disabled}
34
33
  {readonly}
35
34
  {value}
36
35
  {placeholder}
37
36
  {type}
38
- {quiet}
39
37
  {autofocus}
40
38
  {variables}
41
39
  {showModal}
@@ -14,7 +14,7 @@
14
14
  export let updateOnChange = true
15
15
  export let quiet = false
16
16
  export let autofocus: boolean | undefined = undefined
17
- export let autocomplete: boolean | undefined = undefined
17
+ export let autocomplete: boolean | string | undefined = undefined
18
18
  export let helpText: string | undefined = undefined
19
19
 
20
20
  const dispatch = createEventDispatcher()
@@ -3,7 +3,7 @@
3
3
  import Icon from "../Icon/Icon.svelte"
4
4
 
5
5
  const dispatch = createEventDispatcher()
6
- const actionMenu = getContext("actionMenu") as { hideAll: () => void }
6
+ const actionMenu = getContext("actionMenu")
7
7
 
8
8
  export let icon: string | undefined = undefined
9
9
  export let disabled: boolean | undefined = undefined
package/src/context.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { ActionMenu } from "./types"
2
+ import { ModalContext } from "./types"
2
3
 
3
4
  declare module "svelte" {
4
5
  export function getContext(key: "actionMenu"): ActionMenu | undefined
6
+ export function getContext(key: "bbui-modal"): ModalContext
5
7
  }
6
8
 
7
9
  export const Modal = "bbui-modal"
package/src/index.ts CHANGED
@@ -111,3 +111,5 @@ export { banner, BANNER_TYPES } from "./Stores/banner"
111
111
 
112
112
  // Helpers
113
113
  export * as Helpers from "./helpers"
114
+
115
+ export type * from "./types"
@@ -1,3 +1,4 @@
1
1
  export interface ActionMenu {
2
2
  hide: () => void
3
+ hideAll: () => void
3
4
  }
@@ -0,0 +1 @@
1
+ export type EnvDropdownType = "text" | "number" | "password" | "port"
@@ -0,0 +1,3 @@
1
+ export * from "./actionMenu"
2
+ export * from "./envDropdown"
3
+ export * from "./modalContext"
@@ -0,0 +1,3 @@
1
+ export interface ModalContext {
2
+ hide: () => void
3
+ }