@budibase/bbui 3.5.2 → 3.5.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.
Files changed (37) hide show
  1. package/dist/bbui.mjs +13574 -15472
  2. package/package.json +2 -2
  3. package/src/Form/Core/TextArea.svelte +24 -21
  4. package/src/Form/TextArea.svelte +15 -6
  5. package/src/Icon/Icon.svelte +1 -1
  6. package/src/Icon/IconAvatar.svelte +7 -8
  7. package/src/IconPicker/IconPicker.svelte +16 -11
  8. package/src/InlineAlert/InlineAlert.svelte +10 -10
  9. package/src/Input/CopyInput.svelte +13 -11
  10. package/src/Label/Label.svelte +4 -4
  11. package/src/Layout/Layout.svelte +14 -9
  12. package/src/Layout/Page.svelte +6 -6
  13. package/src/List/List.svelte +2 -2
  14. package/src/Markdown/MarkdownEditor.svelte +12 -12
  15. package/src/Markdown/MarkdownViewer.svelte +4 -4
  16. package/src/Markdown/SpectrumMDE.svelte +11 -11
  17. package/src/Menu/Item.svelte +7 -7
  18. package/src/Menu/Menu.svelte +1 -1
  19. package/src/Menu/Section.svelte +2 -2
  20. package/src/Modal/Content.svelte +2 -2
  21. package/src/Modal/CustomContent.svelte +4 -4
  22. package/src/Modal/Modal.svelte +36 -33
  23. package/src/Modal/ModalContent.svelte +33 -31
  24. package/src/Notification/Notification.svelte +9 -9
  25. package/src/Notification/NotificationDisplay.svelte +1 -1
  26. package/src/Pagination/Pagination.svelte +6 -8
  27. package/src/ProgressBar/ProgressBar.svelte +15 -14
  28. package/src/ProgressCircle/ProgressCircle.svelte +11 -11
  29. package/src/Tooltip/TooltipWrapper.svelte +1 -1
  30. package/src/index.ts +0 -3
  31. package/src/Form/PickerDropdown.svelte +0 -132
  32. package/src/IconSideNav/IconSideNav.svelte +0 -14
  33. package/src/IconSideNav/IconSideNavItem.svelte +0 -58
  34. package/src/Menu/Menu.svench +0 -19
  35. package/src/Modal/Modal.svench +0 -116
  36. package/src/Modal/QuizModal.svelte +0 -53
  37. package/src/Stores/Notifications.svench.svx +0 -78
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.5.2",
4
+ "version": "3.5.3",
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": "2d3a130fceeb689d3013606dde57bab8db41c586"
102
+ "gitHead": "0f586f33c25c04b35a7dc72b7217fdbaa3e843c0"
103
103
  }
@@ -1,32 +1,34 @@
1
1
  <script lang="ts">
2
2
  import "@spectrum-css/textfield/dist/index-vars.css"
3
3
  import { createEventDispatcher } from "svelte"
4
+ import type { FocusEventHandler } from "svelte/elements"
4
5
 
5
- export let value = ""
6
- export let placeholder: string | undefined = undefined
6
+ export let value: string | null = null
7
+ export let placeholder: string | null = null
7
8
  export let disabled = false
8
9
  export let readonly = false
9
- export let id: string | undefined = undefined
10
- export let height: string | number | undefined = undefined
11
- export let minHeight: string | number | undefined = undefined
12
- export const getCaretPosition = () => ({
13
- start: textarea.selectionStart,
14
- end: textarea.selectionEnd,
15
- })
10
+ export let id: string | null = null
11
+ export let height: number | null = null
12
+ export let minHeight: number | null = null
16
13
  export let align = null
17
14
 
18
- let focus = false
19
- let textarea: any
20
- const dispatch = createEventDispatcher()
21
- const onChange = (event: any) => {
22
- dispatch("change", event.target.value)
23
- focus = false
15
+ let isFocused = false
16
+ let textarea: HTMLTextAreaElement
17
+ const dispatch = createEventDispatcher<{ change: string }>()
18
+ const onChange: FocusEventHandler<HTMLTextAreaElement> = event => {
19
+ dispatch("change", event.currentTarget.value)
20
+ isFocused = false
24
21
  }
25
22
 
26
- const getStyleString = (
27
- attribute: string,
28
- value: string | number | undefined
29
- ) => {
23
+ export function focus() {
24
+ textarea.focus()
25
+ }
26
+
27
+ export function contents() {
28
+ return textarea.value
29
+ }
30
+
31
+ const getStyleString = (attribute: string, value: number | null) => {
30
32
  if (!attribute || value == null) {
31
33
  return ""
32
34
  }
@@ -44,7 +46,7 @@
44
46
  style={`${heightString}${minHeightString}`}
45
47
  class="spectrum-Textfield spectrum-Textfield--multiline"
46
48
  class:is-disabled={disabled}
47
- class:is-focused={focus}
49
+ class:is-focused={isFocused}
48
50
  >
49
51
  <!-- prettier-ignore -->
50
52
  <textarea
@@ -55,8 +57,9 @@
55
57
  {disabled}
56
58
  {readonly}
57
59
  {id}
58
- on:focus={() => (focus = true)}
60
+ on:focus={() => (isFocused = true)}
59
61
  on:blur={onChange}
62
+ on:keypress
60
63
  >{value || ""}</textarea>
61
64
  </div>
62
65
 
@@ -5,17 +5,25 @@
5
5
 
6
6
  export let value: string | undefined = undefined
7
7
  export let label: string | undefined = undefined
8
- export let labelPosition: string = "above"
8
+ export let labelPosition = "above"
9
9
  export let placeholder: string | undefined = undefined
10
10
  export let disabled = false
11
11
  export let error: string | undefined = undefined
12
- export let getCaretPosition: any = undefined
13
- export let height: string | number | undefined = undefined
14
- export let minHeight: string | number | undefined = undefined
12
+ export let height: number | undefined = undefined
13
+ export let minHeight: number | undefined = undefined
15
14
  export let helpText: string | undefined = undefined
16
15
 
16
+ let textarea: TextArea
17
+ export function focus() {
18
+ textarea.focus()
19
+ }
20
+
21
+ export function contents() {
22
+ return textarea.contents()
23
+ }
24
+
17
25
  const dispatch = createEventDispatcher()
18
- const onChange = (e: any) => {
26
+ const onChange = (e: CustomEvent<string>) => {
19
27
  value = e.detail
20
28
  dispatch("change", e.detail)
21
29
  }
@@ -23,12 +31,13 @@
23
31
 
24
32
  <Field {helpText} {label} {labelPosition} {error}>
25
33
  <TextArea
26
- bind:getCaretPosition
34
+ bind:this={textarea}
27
35
  {disabled}
28
36
  {value}
29
37
  {placeholder}
30
38
  {height}
31
39
  {minHeight}
32
40
  on:change={onChange}
41
+ on:keypress
33
42
  />
34
43
  </Field>
@@ -25,12 +25,12 @@
25
25
  noWrap={tooltipWrap}
26
26
  >
27
27
  <div class="icon" class:newStyles>
28
+ <!-- svelte-ignore a11y-mouse-events-have-key-events -->
28
29
  <svg
29
30
  on:contextmenu
30
31
  on:click
31
32
  on:mouseover
32
33
  on:mouseleave
33
- on:focus
34
34
  class:hoverable
35
35
  class:disabled
36
36
  class="spectrum-Icon spectrum-Icon--size{size}"
@@ -1,16 +1,15 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import Icon from "./Icon.svelte"
3
-
4
3
  import Tooltip from "../Tooltip/Tooltip.svelte"
5
4
  import { fade } from "svelte/transition"
6
5
 
7
- export let icon
8
- export let background
9
- export let color
10
- export let size = "M"
11
- export let tooltip
6
+ export let icon: string | undefined = undefined
7
+ export let background: string | undefined = undefined
8
+ export let color: string | undefined = undefined
9
+ export let size: "XS" | "S" | "M" | "L" = "M"
10
+ export let tooltip: string | undefined = undefined
12
11
 
13
- let showTooltip = false
12
+ let showTooltip: boolean = false
14
13
  </script>
15
14
 
16
15
  <!-- svelte-ignore a11y-no-static-element-interactions -->
@@ -1,19 +1,24 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import "@spectrum-css/popover/dist/index-vars.css"
3
3
  import clickOutside from "../Actions/click_outside"
4
4
  import { fly } from "svelte/transition"
5
5
  import Icon from "../Icon/Icon.svelte"
6
6
  import { createEventDispatcher } from "svelte"
7
7
 
8
- export let value
9
- export let size = "M"
10
- export let alignRight = false
8
+ export let value: string | undefined
9
+ export let size: "S" | "M" | "L" = "M"
10
+ export let alignRight: boolean = false
11
11
 
12
- let open = false
12
+ let open: boolean = false
13
13
 
14
14
  const dispatch = createEventDispatcher()
15
15
 
16
- const iconList = [
16
+ interface IconCategory {
17
+ label: string
18
+ icons: string[]
19
+ }
20
+
21
+ const iconList: IconCategory[] = [
17
22
  {
18
23
  label: "Icons",
19
24
  icons: [
@@ -45,12 +50,12 @@
45
50
  },
46
51
  ]
47
52
 
48
- const onChange = value => {
53
+ const onChange = (value: string) => {
49
54
  dispatch("change", value)
50
55
  open = false
51
56
  }
52
57
 
53
- const handleOutsideClick = event => {
58
+ const handleOutsideClick = (event: MouseEvent) => {
54
59
  if (open) {
55
60
  event.stopPropagation()
56
61
  open = false
@@ -77,11 +82,11 @@
77
82
  class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
78
83
  class:spectrum-Popover--align-right={alignRight}
79
84
  >
80
- {#each iconList as icon}
85
+ {#each iconList as iconList}
81
86
  <div class="category">
82
- <div class="heading">{icon.label}</div>
87
+ <div class="heading">{iconList.label}</div>
83
88
  <div class="icons">
84
- {#each icon.icons as icon}
89
+ {#each iconList.icons as icon}
85
90
  <div
86
91
  on:click={() => {
87
92
  onChange(icon)
@@ -1,22 +1,22 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import "@spectrum-css/inlinealert/dist/index-vars.css"
3
3
  import Button from "../Button/Button.svelte"
4
4
  import Icon from "../Icon/Icon.svelte"
5
5
 
6
- export let type = "info"
7
- export let header = ""
8
- export let message = ""
9
- export let onConfirm = undefined
10
- export let buttonText = ""
11
- export let cta = false
12
- export let link = ""
13
- export let linkText = ""
6
+ export let type: "info" | "error" | "success" | "help" | "negative" = "info"
7
+ export let header: string = ""
8
+ export let message: string = ""
9
+ export let onConfirm: (() => void) | undefined = undefined
10
+ export let buttonText: string = ""
11
+ export let cta: boolean = false
12
+ export let link: string = ""
13
+ export let linkText: string = ""
14
14
 
15
15
  $: icon = selectIcon(type)
16
16
  // if newlines used, convert them to different elements
17
17
  $: split = message.split("\n")
18
18
 
19
- function selectIcon(alertType) {
19
+ function selectIcon(alertType: string): string {
20
20
  switch (alertType) {
21
21
  case "error":
22
22
  case "negative":
@@ -1,19 +1,21 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import Input from "../Form/Input.svelte"
3
3
  import Icon from "../Icon/Icon.svelte"
4
4
  import { notifications } from "../Stores/notifications"
5
5
 
6
- export let label = null
7
- export let value
6
+ export let label: string | undefined = undefined
7
+ export let value: string | undefined = undefined
8
8
 
9
- const copyToClipboard = val => {
10
- const dummy = document.createElement("textarea")
11
- document.body.appendChild(dummy)
12
- dummy.value = val
13
- dummy.select()
14
- document.execCommand("copy")
15
- document.body.removeChild(dummy)
16
- notifications.success(`Copied to clipboard`)
9
+ const copyToClipboard = (val: string | undefined) => {
10
+ if (val) {
11
+ const dummy = document.createElement("textarea")
12
+ document.body.appendChild(dummy)
13
+ dummy.value = val
14
+ dummy.select()
15
+ document.execCommand("copy")
16
+ document.body.removeChild(dummy)
17
+ notifications.success(`Copied to clipboard`)
18
+ }
17
19
  }
18
20
  </script>
19
21
 
@@ -1,10 +1,10 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import "@spectrum-css/fieldlabel/dist/index-vars.css"
3
3
  import TooltipWrapper from "../Tooltip/TooltipWrapper.svelte"
4
4
 
5
- export let size = "M"
6
- export let tooltip = ""
7
- export let muted = undefined
5
+ export let size: "S" | "M" | "L" = "M"
6
+ export let tooltip: string = ""
7
+ export let muted: boolean | undefined = undefined
8
8
  </script>
9
9
 
10
10
  <TooltipWrapper {tooltip} {size}>
@@ -1,12 +1,17 @@
1
- <script>
2
- export let horizontal = false
3
- export let paddingX = "M"
4
- export let paddingY = "M"
5
- export let noPadding = false
6
- export let gap = "M"
7
- export let noGap = false
8
- export let alignContent = "normal"
9
- export let justifyItems = "stretch"
1
+ <script lang="ts">
2
+ export let horizontal: boolean = false
3
+ export let paddingX: "S" | "M" | "L" | "XL" | "XXL" = "M"
4
+ export let paddingY: "S" | "M" | "L" | "XL" | "XXL" = "M"
5
+ export let noPadding: boolean = false
6
+ export let gap: "XXS" | "XS" | "S" | "M" | "L" | "XL" = "M"
7
+ export let noGap: boolean = false
8
+ export let alignContent:
9
+ | "start"
10
+ | "center"
11
+ | "space-between"
12
+ | "space-around"
13
+ | "normal" = "normal"
14
+ export let justifyItems: "stretch" | "start" | "center" | "end" = "stretch"
10
15
  </script>
11
16
 
12
17
  <div
@@ -1,13 +1,13 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import { setContext } from "svelte"
3
3
  import clickOutside from "../Actions/click_outside"
4
4
 
5
- export let wide = false
6
- export let narrow = false
7
- export let narrower = false
8
- export let noPadding = false
5
+ export let wide: boolean = false
6
+ export let narrow: boolean = false
7
+ export let narrower: boolean = false
8
+ export let noPadding: boolean = false
9
9
 
10
- let sidePanelVisible = false
10
+ let sidePanelVisible: boolean = false
11
11
 
12
12
  setContext("side-panel", {
13
13
  open: () => (sidePanelVisible = true),
@@ -1,7 +1,7 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import Detail from "../Typography/Detail.svelte"
3
3
 
4
- export let title = null
4
+ export let title: string | null = null
5
5
  </script>
6
6
 
7
7
  <div>
@@ -1,20 +1,20 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import SpectrumMDE from "./SpectrumMDE.svelte"
3
3
  import { createEventDispatcher } from "svelte"
4
4
 
5
- export let value = null
6
- export let height = null
7
- export let placeholder = null
8
- export let id = null
9
- export let fullScreenOffset = 0
10
- export let disabled = false
11
- export let readonly = false
12
- export let easyMDEOptions
5
+ export let value: string | null = null
6
+ export let height: string | null = null
7
+ export let placeholder: string | null = null
8
+ export let id: string | null = null
9
+ export let fullScreenOffset: { x: string; y: string } | null = null
10
+ export let disabled: boolean = false
11
+ export let readonly: boolean = false
12
+ export let easyMDEOptions: Record<string, any> = {}
13
13
 
14
14
  const dispatch = createEventDispatcher()
15
15
 
16
- let latestValue
17
- let mde
16
+ let latestValue: string | null
17
+ let mde: any
18
18
 
19
19
  // Ensure the value is updated if the value prop changes outside the editor's
20
20
  // control
@@ -24,7 +24,7 @@
24
24
  mde?.togglePreview()
25
25
  }
26
26
 
27
- const checkValue = val => {
27
+ const checkValue = (val: string | null) => {
28
28
  if (mde && val !== latestValue) {
29
29
  mde.value(val)
30
30
  }
@@ -1,10 +1,10 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import SpectrumMDE from "./SpectrumMDE.svelte"
3
3
 
4
- export let value
5
- export let height
4
+ export let value: string | null = null
5
+ export let height: string | null = null
6
6
 
7
- let mde
7
+ let mde: any
8
8
 
9
9
  // Keep the value up to date
10
10
  $: mde && mde.value(value || "")
@@ -1,17 +1,17 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import EasyMDE from "easymde"
3
3
  import "easymde/dist/easymde.min.css"
4
4
  import { onMount } from "svelte"
5
5
 
6
- export let height = null
7
- export let scroll = true
8
- export let easyMDEOptions = null
9
- export let mde = null
10
- export let id = null
11
- export let fullScreenOffset = null
12
- export let disabled = false
6
+ export let height: string | null = null
7
+ export let scroll: boolean = true
8
+ export let easyMDEOptions: Record<string, any> | null = null
9
+ export let mde: EasyMDE | null = null
10
+ export let id: string | null = null
11
+ export let fullScreenOffset: { x: string; y: string } | null = null
12
+ export let disabled: boolean = false
13
13
 
14
- let element
14
+ let element: HTMLTextAreaElement | undefined = undefined
15
15
 
16
16
  onMount(() => {
17
17
  height = height || "200px"
@@ -27,13 +27,13 @@
27
27
 
28
28
  // Revert the editor when we unmount
29
29
  return () => {
30
- mde.toTextArea()
30
+ mde?.toTextArea()
31
31
  }
32
32
  })
33
33
 
34
34
  $: styleString = getStyleString(fullScreenOffset)
35
35
 
36
- const getStyleString = offset => {
36
+ const getStyleString = (offset: { x?: string; y?: string } | null) => {
37
37
  let string = ""
38
38
  string += `--fullscreen-offset-x:${offset?.x || "0px"};`
39
39
  string += `--fullscreen-offset-y:${offset?.y || "0px"};`
@@ -1,18 +1,18 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import { createEventDispatcher, getContext } from "svelte"
3
3
  import Icon from "../Icon/Icon.svelte"
4
4
 
5
5
  const dispatch = createEventDispatcher()
6
- const actionMenu = getContext("actionMenu")
6
+ const actionMenu = getContext("actionMenu") as { hideAll: () => void }
7
7
 
8
- export let icon = undefined
9
- export let disabled = undefined
10
- export let noClose = false
11
- export let keyBind = undefined
8
+ export let icon: string | undefined = undefined
9
+ export let disabled: boolean | undefined = undefined
10
+ export let noClose: boolean = false
11
+ export let keyBind: string | undefined = undefined
12
12
 
13
13
  $: keys = getKeys(keyBind)
14
14
 
15
- const getKeys = keyBind => {
15
+ const getKeys = (keyBind: string | undefined): string[] => {
16
16
  let keys = keyBind?.split("+") || []
17
17
  for (let i = 0; i < keys.length; i++) {
18
18
  if (
@@ -1,4 +1,4 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import "@spectrum-css/menu/dist/index-vars.css"
3
3
  </script>
4
4
 
@@ -1,5 +1,5 @@
1
- <script>
2
- export let heading
1
+ <script lang="ts">
2
+ export let heading: string
3
3
  </script>
4
4
 
5
5
  <li role="presentation">
@@ -1,7 +1,7 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import Input from "../Form/Input.svelte"
3
3
 
4
- let value = ""
4
+ let value: string = ""
5
5
  </script>
6
6
 
7
7
  <Input label="Your Name" bind:value />
@@ -1,11 +1,11 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import { getContext } from "svelte"
3
3
  import Context from "../context"
4
4
 
5
- const { hide } = getContext(Context.Modal)
5
+ const { hide } = getContext(Context.Modal) as { hide: () => void }
6
6
 
7
- let count = 0
8
- const clicks = 5
7
+ let count: number = 0
8
+ const clicks: number = 5
9
9
  $: if (count === clicks) hide()
10
10
  $: remaining = clicks - count
11
11