@budibase/bbui 2.8.12-alpha.2 → 2.8.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": "2.8.12-alpha.2",
4
+ "version": "2.8.13",
5
5
  "license": "MPL-2.0",
6
6
  "svelte": "src/index.js",
7
7
  "module": "dist/bbui.es.js",
@@ -38,8 +38,8 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@adobe/spectrum-css-workflow-icons": "1.2.1",
41
- "@budibase/shared-core": "2.8.12-alpha.2",
42
- "@budibase/string-templates": "2.8.12-alpha.2",
41
+ "@budibase/shared-core": "2.8.13",
42
+ "@budibase/string-templates": "2.8.13",
43
43
  "@spectrum-css/accordion": "3.0.24",
44
44
  "@spectrum-css/actionbutton": "1.0.1",
45
45
  "@spectrum-css/actiongroup": "1.0.1",
@@ -104,5 +104,5 @@
104
104
  }
105
105
  }
106
106
  },
107
- "gitHead": "39160d1bf32c912a8fc66d46f451b4591d599e98"
107
+ "gitHead": "10ecc65c7cfb5dd738787ae627f990e83517e9f8"
108
108
  }
@@ -1,7 +1,6 @@
1
1
  <script>
2
2
  import "@spectrum-css/button/dist/index-vars.css"
3
- import AbsTooltip from "../Tooltip/AbsTooltip.svelte"
4
- import { createEventDispatcher } from "svelte"
3
+ import Tooltip from "../Tooltip/Tooltip.svelte"
5
4
 
6
5
  export let type
7
6
  export let disabled = false
@@ -18,52 +17,65 @@
18
17
  export let newStyles = true
19
18
  export let id
20
19
 
21
- const dispatch = createEventDispatcher()
20
+ let showTooltip = false
22
21
  </script>
23
22
 
24
- <AbsTooltip text={tooltip}>
25
- <button
26
- {id}
27
- {type}
28
- class:spectrum-Button--cta={cta}
29
- class:spectrum-Button--primary={primary}
30
- class:spectrum-Button--secondary={secondary}
31
- class:spectrum-Button--warning={warning}
32
- class:spectrum-Button--overBackground={overBackground}
33
- class:spectrum-Button--quiet={quiet}
34
- class:new-styles={newStyles}
35
- class:active
36
- class:is-disabled={disabled}
37
- class="spectrum-Button spectrum-Button--size{size.toUpperCase()}"
38
- on:click|preventDefault={() => {
39
- if (!disabled) {
40
- dispatch("click")
41
- }
42
- }}
43
- >
44
- {#if icon}
23
+ <button
24
+ {id}
25
+ {type}
26
+ class:spectrum-Button--cta={cta}
27
+ class:spectrum-Button--primary={primary}
28
+ class:spectrum-Button--secondary={secondary}
29
+ class:spectrum-Button--warning={warning}
30
+ class:spectrum-Button--overBackground={overBackground}
31
+ class:spectrum-Button--quiet={quiet}
32
+ class:new-styles={newStyles}
33
+ class:active
34
+ class:disabled
35
+ class="spectrum-Button spectrum-Button--size{size.toUpperCase()}"
36
+ {disabled}
37
+ on:click|preventDefault
38
+ on:mouseover={() => (showTooltip = true)}
39
+ on:focus={() => (showTooltip = true)}
40
+ on:mouseleave={() => (showTooltip = false)}
41
+ >
42
+ {#if icon}
43
+ <svg
44
+ class="spectrum-Icon spectrum-Icon--size{size.toUpperCase()}"
45
+ focusable="false"
46
+ aria-hidden="true"
47
+ aria-label={icon}
48
+ >
49
+ <use xlink:href="#spectrum-icon-18-{icon}" />
50
+ </svg>
51
+ {/if}
52
+ {#if $$slots}
53
+ <span class="spectrum-Button-label"><slot /></span>
54
+ {/if}
55
+ {#if !disabled && tooltip}
56
+ <div class="tooltip-icon">
45
57
  <svg
46
58
  class="spectrum-Icon spectrum-Icon--size{size.toUpperCase()}"
47
59
  focusable="false"
48
60
  aria-hidden="true"
49
- aria-label={icon}
61
+ aria-label="Info"
50
62
  >
51
- <use xlink:href="#spectrum-icon-18-{icon}" />
63
+ <use xlink:href="#spectrum-icon-18-InfoOutline" />
52
64
  </svg>
53
- {/if}
54
- {#if $$slots}
55
- <span class="spectrum-Button-label"><slot /></span>
56
- {/if}
57
- </button>
58
- </AbsTooltip>
65
+ </div>
66
+ {/if}
67
+ {#if showTooltip && tooltip}
68
+ <div class="tooltip">
69
+ <Tooltip textWrapping={true} direction={"bottom"} text={tooltip} />
70
+ </div>
71
+ {/if}
72
+ </button>
59
73
 
60
74
  <style>
61
75
  button {
62
76
  position: relative;
63
77
  }
64
- button.is-disabled {
65
- cursor: default;
66
- }
78
+
67
79
  .spectrum-Button-label {
68
80
  white-space: nowrap;
69
81
  overflow: hidden;
@@ -72,6 +84,21 @@
72
84
  .active {
73
85
  color: var(--spectrum-global-color-blue-600) !important;
74
86
  }
87
+ .tooltip {
88
+ position: absolute;
89
+ display: flex;
90
+ justify-content: center;
91
+ z-index: 100;
92
+ width: 160px;
93
+ text-align: center;
94
+ transform: translateX(-50%);
95
+ left: 50%;
96
+ top: calc(100% - 3px);
97
+ }
98
+ .tooltip-icon {
99
+ padding-left: var(--spacing-m);
100
+ line-height: 0;
101
+ }
75
102
  .spectrum-Button--primary.new-styles {
76
103
  background: var(--spectrum-global-color-gray-800);
77
104
  border-color: transparent;
@@ -85,10 +112,10 @@
85
112
  border-color: transparent;
86
113
  color: var(--spectrum-global-color-gray-900);
87
114
  }
88
- .spectrum-Button--secondary.new-styles:not(.is-disabled):hover {
115
+ .spectrum-Button--secondary.new-styles:not(.disabled):hover {
89
116
  background: var(--spectrum-global-color-gray-300);
90
117
  }
91
- .spectrum-Button--secondary.new-styles.is-disabled {
118
+ .spectrum-Button--secondary.new-styles.disabled {
92
119
  color: var(--spectrum-global-color-gray-500);
93
120
  }
94
121
  </style>
@@ -15,6 +15,8 @@
15
15
 
16
16
  const dispatch = createEventDispatcher()
17
17
 
18
+ $: placeholder = !value
19
+
18
20
  const extractProperty = (value, property) => {
19
21
  if (value && typeof value === "object") {
20
22
  return value[property]
@@ -150,7 +150,7 @@
150
150
  </div>
151
151
  {:else if variables.length}
152
152
  <div style="max-height: 100px">
153
- {#each variables as variable}
153
+ {#each variables as variable, idx}
154
154
  <li
155
155
  class="spectrum-Menu-item"
156
156
  role="option"
@@ -1,7 +1,6 @@
1
1
  <script>
2
2
  import "@spectrum-css/link/dist/index-vars.css"
3
3
  import { createEventDispatcher } from "svelte"
4
- import Tooltip from "../Tooltip/Tooltip.svelte"
5
4
 
6
5
  export let href = "#"
7
6
  export let size = "M"
@@ -11,61 +10,18 @@
11
10
  export let overBackground = false
12
11
  export let target
13
12
  export let download
14
- export let disabled = false
15
- export let tooltip = null
16
13
 
17
14
  const dispatch = createEventDispatcher()
18
-
19
- const onClick = e => {
20
- if (!disabled) {
21
- dispatch("click")
22
- e.stopPropagation()
23
- }
24
- }
25
15
  </script>
26
16
 
27
17
  <a
28
- on:click={onClick}
18
+ on:click={e => dispatch("click") && e.stopPropagation()}
29
19
  {href}
30
20
  {target}
31
21
  {download}
32
- class:disabled
33
22
  class:spectrum-Link--primary={primary}
34
23
  class:spectrum-Link--secondary={secondary}
35
24
  class:spectrum-Link--overBackground={overBackground}
36
25
  class:spectrum-Link--quiet={quiet}
37
- class="spectrum-Link spectrum-Link--size{size}"
26
+ class="spectrum-Link spectrum-Link--size{size}"><slot /></a
38
27
  >
39
- <slot />
40
- {#if tooltip}
41
- <div class="tooltip">
42
- <Tooltip textWrapping direction="bottom" text={tooltip} />
43
- </div>
44
- {/if}
45
- </a>
46
-
47
- <style>
48
- a {
49
- position: relative;
50
- }
51
- a.disabled {
52
- color: var(--spectrum-global-color-gray-500);
53
- }
54
- a.disabled:hover {
55
- text-decoration: none;
56
- cursor: default;
57
- }
58
- .tooltip {
59
- position: absolute;
60
- left: 50%;
61
- top: 100%;
62
- transform: translateX(-50%);
63
- opacity: 0;
64
- transition: 130ms ease-out;
65
- pointer-events: none;
66
- z-index: 100;
67
- }
68
- a:hover .tooltip {
69
- opacity: 1;
70
- }
71
- </style>
@@ -1,7 +1,3 @@
1
- <script context="module">
2
- export const keepOpen = Symbol("keepOpen")
3
- </script>
4
-
5
1
  <script>
6
2
  import "@spectrum-css/dialog/dist/index-vars.css"
7
3
  import { getContext } from "svelte"
@@ -34,7 +30,7 @@
34
30
 
35
31
  async function secondary(e) {
36
32
  loading = true
37
- if (!secondaryAction || (await secondaryAction(e)) !== keepOpen) {
33
+ if (!secondaryAction || (await secondaryAction(e)) !== false) {
38
34
  hide()
39
35
  }
40
36
  loading = false
@@ -42,7 +38,7 @@
42
38
 
43
39
  async function confirm() {
44
40
  loading = true
45
- if (!onConfirm || (await onConfirm()) !== keepOpen) {
41
+ if (!onConfirm || (await onConfirm()) !== false) {
46
42
  hide()
47
43
  }
48
44
  loading = false
@@ -50,7 +46,7 @@
50
46
 
51
47
  async function close() {
52
48
  loading = true
53
- if (!onCancel || (await onCancel()) !== keepOpen) {
49
+ if (!onCancel || (await onCancel()) !== false) {
54
50
  cancel()
55
51
  }
56
52
  loading = false
@@ -29,6 +29,7 @@
29
29
  $: type = getType(schema)
30
30
  $: customRenderer = customRenderers?.find(x => x.column === schema?.name)
31
31
  $: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
32
+ $: width = schema?.width || "150px"
32
33
  $: cellValue = getCellValue(value, schema.template)
33
34
 
34
35
  const getType = schema => {
@@ -379,7 +379,7 @@
379
379
  </div>
380
380
  {/if}
381
381
  {#if sortedRows?.length}
382
- {#each sortedRows as row}
382
+ {#each sortedRows as row, idx}
383
383
  <div class="spectrum-Table-row" class:clickable={allowClickRows}>
384
384
  {#if showEditColumn}
385
385
  <div
package/src/index.js CHANGED
@@ -36,19 +36,13 @@ export { default as Layout } from "./Layout/Layout.svelte"
36
36
  export { default as Page } from "./Layout/Page.svelte"
37
37
  export { default as Link } from "./Link/Link.svelte"
38
38
  export { default as Tooltip } from "./Tooltip/Tooltip.svelte"
39
- export { default as TempTooltip } from "./Tooltip/TempTooltip.svelte"
40
- export {
41
- default as AbsTooltip,
42
- TooltipPosition,
43
- TooltipType,
44
- } from "./Tooltip/AbsTooltip.svelte"
45
39
  export { default as TooltipWrapper } from "./Tooltip/TooltipWrapper.svelte"
46
40
  export { default as Menu } from "./Menu/Menu.svelte"
47
41
  export { default as MenuSection } from "./Menu/Section.svelte"
48
42
  export { default as MenuSeparator } from "./Menu/Separator.svelte"
49
43
  export { default as MenuItem } from "./Menu/Item.svelte"
50
44
  export { default as Modal } from "./Modal/Modal.svelte"
51
- export { default as ModalContent, keepOpen } from "./Modal/ModalContent.svelte"
45
+ export { default as ModalContent } from "./Modal/ModalContent.svelte"
52
46
  export { default as NotificationDisplay } from "./Notification/NotificationDisplay.svelte"
53
47
  export { default as Notification } from "./Notification/Notification.svelte"
54
48
  export { default as SideNavigation } from "./SideNavigation/Navigation.svelte"
@@ -1,157 +0,0 @@
1
- <script context="module">
2
- export const TooltipPosition = {
3
- Top: "top",
4
- Right: "right",
5
- Bottom: "bottom",
6
- Left: "left",
7
- }
8
- export const TooltipType = {
9
- Default: "default",
10
- Info: "info",
11
- Positive: "positive",
12
- Negative: "negative",
13
- }
14
- </script>
15
-
16
- <script>
17
- import Portal from "svelte-portal"
18
- import { fade } from "svelte/transition"
19
- import "@spectrum-css/tooltip/dist/index-vars.css"
20
- import { onDestroy } from "svelte"
21
-
22
- export let position = TooltipPosition.Top
23
- export let type = TooltipType.Default
24
- export let text = ""
25
- export let fixed = false
26
- export let color = null
27
-
28
- let wrapper
29
- let hovered = false
30
- let left
31
- let top
32
- let visible = false
33
- let timeout
34
- let interval
35
-
36
- $: {
37
- if (hovered || fixed) {
38
- // Debounce showing by 200ms to avoid flashing tooltip
39
- timeout = setTimeout(show, 200)
40
- } else {
41
- hide()
42
- }
43
- }
44
- $: tooltipStyle = color ? `background:${color};` : null
45
- $: tipStyle = color ? `border-top-color:${color};` : null
46
-
47
- // Computes the position of the tooltip
48
- const updateTooltipPosition = () => {
49
- const node = wrapper?.children?.[0]
50
- if (!node) {
51
- left = null
52
- top = null
53
- return
54
- }
55
- const bounds = node.getBoundingClientRect()
56
-
57
- // Determine where to render tooltip based on position prop
58
- if (position === TooltipPosition.Top) {
59
- left = bounds.left + bounds.width / 2
60
- top = bounds.top
61
- } else if (position === TooltipPosition.Right) {
62
- left = bounds.left + bounds.width
63
- top = bounds.top + bounds.height / 2
64
- } else if (position === TooltipPosition.Bottom) {
65
- left = bounds.left + bounds.width / 2
66
- top = bounds.top + bounds.height
67
- } else if (position === TooltipPosition.Left) {
68
- left = bounds.left
69
- top = bounds.top + bounds.height / 2
70
- }
71
- }
72
-
73
- // Computes the position of the tooltip then shows it.
74
- // We set up a poll to frequently update the position of the tooltip in case
75
- // the target moves.
76
- const show = () => {
77
- updateTooltipPosition()
78
- interval = setInterval(updateTooltipPosition, 100)
79
- visible = true
80
- }
81
-
82
- // Hides the tooltip
83
- const hide = () => {
84
- clearTimeout(timeout)
85
- clearInterval(interval)
86
- visible = false
87
- }
88
-
89
- // Ensure we clean up interval and timeout
90
- onDestroy(hide)
91
- </script>
92
-
93
- <div
94
- bind:this={wrapper}
95
- class="abs-tooltip"
96
- on:focus={null}
97
- on:mouseover={() => (hovered = true)}
98
- on:mouseleave={() => (hovered = false)}
99
- >
100
- <slot />
101
- </div>
102
-
103
- {#if visible && text && left != null && top != null}
104
- <Portal target=".spectrum">
105
- <span
106
- class="spectrum-Tooltip spectrum-Tooltip--{type} spectrum-Tooltip--{position} is-open"
107
- style={`left:${left}px;top:${top}px;${tooltipStyle}`}
108
- transition:fade|local={{ duration: 130 }}
109
- >
110
- <span class="spectrum-Tooltip-label">{text}</span>
111
- <span class="spectrum-Tooltip-tip" style={tipStyle} />
112
- </span>
113
- </Portal>
114
- {/if}
115
-
116
- <style>
117
- .abs-tooltip {
118
- display: contents;
119
- }
120
- .spectrum-Tooltip {
121
- position: absolute;
122
- z-index: 9999;
123
- pointer-events: none;
124
- margin: 0;
125
- max-width: 280px;
126
- transition: top 130ms ease-out, left 130ms ease-out;
127
- }
128
- .spectrum-Tooltip-label {
129
- text-overflow: ellipsis;
130
- white-space: nowrap;
131
- overflow: hidden;
132
- font-size: 12px;
133
- font-weight: 600;
134
- }
135
-
136
- /* Colour overrides for default type */
137
- .spectrum-Tooltip--default {
138
- background: var(--spectrum-global-color-gray-500);
139
- }
140
- .spectrum-Tooltip--default .spectrum-Tooltip-tip {
141
- border-top-color: var(--spectrum-global-color-gray-500);
142
- }
143
-
144
- /* Position styles */
145
- .spectrum-Tooltip--top {
146
- transform: translateX(-50%) translateY(calc(-100% - 8px));
147
- }
148
- .spectrum-Tooltip--right {
149
- transform: translateX(8px) translateY(-50%);
150
- }
151
- .spectrum-Tooltip--bottom {
152
- transform: translateX(-50%) translateY(8px);
153
- }
154
- .spectrum-Tooltip--left {
155
- transform: translateX(calc(-100% - 8px)) translateY(-50%);
156
- }
157
- </style>
@@ -1,39 +0,0 @@
1
- <script>
2
- import AbsTooltip from "./AbsTooltip.svelte"
3
- import { onDestroy } from "svelte"
4
-
5
- export let text = null
6
- export let condition = true
7
- export let duration = 3000
8
- export let position
9
- export let type
10
-
11
- let visible = false
12
- let timeout
13
-
14
- $: {
15
- if (condition) {
16
- showTooltip()
17
- } else {
18
- hideTooltip()
19
- }
20
- }
21
-
22
- const showTooltip = () => {
23
- visible = true
24
- timeout = setTimeout(() => {
25
- visible = false
26
- }, duration)
27
- }
28
-
29
- const hideTooltip = () => {
30
- visible = false
31
- clearTimeout(timeout)
32
- }
33
-
34
- onDestroy(hideTooltip)
35
- </script>
36
-
37
- <AbsTooltip {position} {type} text={visible ? text : null} fixed={visible}>
38
- <slot />
39
- </AbsTooltip>