@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.
- package/dist/bbui.mjs +13574 -15472
- package/package.json +2 -2
- package/src/Form/Core/TextArea.svelte +24 -21
- package/src/Form/TextArea.svelte +15 -6
- package/src/Icon/Icon.svelte +1 -1
- package/src/Icon/IconAvatar.svelte +7 -8
- package/src/IconPicker/IconPicker.svelte +16 -11
- package/src/InlineAlert/InlineAlert.svelte +10 -10
- package/src/Input/CopyInput.svelte +13 -11
- package/src/Label/Label.svelte +4 -4
- package/src/Layout/Layout.svelte +14 -9
- package/src/Layout/Page.svelte +6 -6
- package/src/List/List.svelte +2 -2
- package/src/Markdown/MarkdownEditor.svelte +12 -12
- package/src/Markdown/MarkdownViewer.svelte +4 -4
- package/src/Markdown/SpectrumMDE.svelte +11 -11
- package/src/Menu/Item.svelte +7 -7
- package/src/Menu/Menu.svelte +1 -1
- package/src/Menu/Section.svelte +2 -2
- package/src/Modal/Content.svelte +2 -2
- package/src/Modal/CustomContent.svelte +4 -4
- package/src/Modal/Modal.svelte +36 -33
- package/src/Modal/ModalContent.svelte +33 -31
- package/src/Notification/Notification.svelte +9 -9
- package/src/Notification/NotificationDisplay.svelte +1 -1
- package/src/Pagination/Pagination.svelte +6 -8
- package/src/ProgressBar/ProgressBar.svelte +15 -14
- package/src/ProgressCircle/ProgressCircle.svelte +11 -11
- package/src/Tooltip/TooltipWrapper.svelte +1 -1
- package/src/index.ts +0 -3
- package/src/Form/PickerDropdown.svelte +0 -132
- package/src/IconSideNav/IconSideNav.svelte +0 -14
- package/src/IconSideNav/IconSideNavItem.svelte +0 -58
- package/src/Menu/Menu.svench +0 -19
- package/src/Modal/Modal.svench +0 -116
- package/src/Modal/QuizModal.svelte +0 -53
- package/src/Stores/Notifications.svench.svx +0 -78
package/src/Modal/Modal.svelte
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import "@spectrum-css/modal/dist/index-vars.css"
|
|
3
3
|
import "@spectrum-css/underlay/dist/index-vars.css"
|
|
4
4
|
import { createEventDispatcher, setContext, tick, onMount } from "svelte"
|
|
@@ -6,33 +6,37 @@
|
|
|
6
6
|
import Portal from "svelte-portal"
|
|
7
7
|
import Context from "../context"
|
|
8
8
|
|
|
9
|
-
export let fixed = false
|
|
10
|
-
export let inline = false
|
|
11
|
-
export let disableCancel = false
|
|
12
|
-
export let autoFocus = true
|
|
13
|
-
export let zIndex = 1001
|
|
9
|
+
export let fixed: boolean = false
|
|
10
|
+
export let inline: boolean = false
|
|
11
|
+
export let disableCancel: boolean = false
|
|
12
|
+
export let autoFocus: boolean = true
|
|
13
|
+
export let zIndex: number = 1001
|
|
14
14
|
|
|
15
|
-
const dispatch = createEventDispatcher
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const dispatch = createEventDispatcher<{
|
|
16
|
+
show: void
|
|
17
|
+
hide: void
|
|
18
|
+
cancel: void
|
|
19
|
+
}>()
|
|
20
|
+
let visible: boolean = fixed || inline
|
|
21
|
+
let modal: HTMLElement | undefined
|
|
18
22
|
|
|
19
23
|
$: dispatch(visible ? "show" : "hide")
|
|
20
24
|
|
|
21
|
-
export function show() {
|
|
25
|
+
export function show(): void {
|
|
22
26
|
if (visible) {
|
|
23
27
|
return
|
|
24
28
|
}
|
|
25
29
|
visible = true
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
export function hide() {
|
|
32
|
+
export function hide(): void {
|
|
29
33
|
if (!visible || fixed || inline) {
|
|
30
34
|
return
|
|
31
35
|
}
|
|
32
36
|
visible = false
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
export function toggle() {
|
|
39
|
+
export function toggle(): void {
|
|
36
40
|
if (visible) {
|
|
37
41
|
hide()
|
|
38
42
|
} else {
|
|
@@ -40,7 +44,7 @@
|
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
export function cancel() {
|
|
47
|
+
export function cancel(): void {
|
|
44
48
|
if (!visible || disableCancel) {
|
|
45
49
|
return
|
|
46
50
|
}
|
|
@@ -48,34 +52,33 @@
|
|
|
48
52
|
hide()
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
function handleKey(e) {
|
|
55
|
+
function handleKey(e: KeyboardEvent): void {
|
|
52
56
|
if (visible && e.key === "Escape") {
|
|
53
57
|
cancel()
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
|
|
58
|
-
if (!autoFocus)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// Otherwise try to focus confirmation button
|
|
70
|
-
else if (modal) {
|
|
71
|
-
const confirm = modal.querySelector(".confirm-wrap .spectrum-Button")
|
|
72
|
-
if (confirm) {
|
|
73
|
-
confirm.focus()
|
|
61
|
+
function focusModal(node: HTMLElement): void {
|
|
62
|
+
if (!autoFocus) return
|
|
63
|
+
tick().then(() => {
|
|
64
|
+
const inputs = node.querySelectorAll("input")
|
|
65
|
+
if (inputs?.length) {
|
|
66
|
+
inputs[0].focus()
|
|
67
|
+
} else if (modal) {
|
|
68
|
+
const confirm = modal.querySelector(".confirm-wrap .spectrum-Button")
|
|
69
|
+
if (confirm) {
|
|
70
|
+
;(confirm as HTMLElement).focus()
|
|
71
|
+
}
|
|
74
72
|
}
|
|
75
|
-
}
|
|
73
|
+
})
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
setContext(Context.Modal, {
|
|
76
|
+
setContext(Context.Modal, {
|
|
77
|
+
show,
|
|
78
|
+
hide,
|
|
79
|
+
toggle,
|
|
80
|
+
cancel,
|
|
81
|
+
} as { show: () => void; hide: () => void; toggle: () => void; cancel: () => void })
|
|
79
82
|
|
|
80
83
|
onMount(() => {
|
|
81
84
|
document.addEventListener("keydown", handleKey)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<script context="module">
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
2
|
export const keepOpen = Symbol("keepOpen")
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
|
-
<script>
|
|
5
|
+
<script lang="ts">
|
|
6
6
|
import "@spectrum-css/dialog/dist/index-vars.css"
|
|
7
7
|
import { getContext } from "svelte"
|
|
8
8
|
import Button from "../Button/Button.svelte"
|
|
@@ -11,31 +11,36 @@
|
|
|
11
11
|
import Context from "../context"
|
|
12
12
|
import ProgressCircle from "../ProgressCircle/ProgressCircle.svelte"
|
|
13
13
|
|
|
14
|
-
export let title = undefined
|
|
15
|
-
export let size = "S"
|
|
16
|
-
export let cancelText = "Cancel"
|
|
17
|
-
export let confirmText = "Confirm"
|
|
18
|
-
export let showCancelButton = true
|
|
19
|
-
export let showConfirmButton = true
|
|
20
|
-
export let showCloseIcon = true
|
|
21
|
-
export let onConfirm = undefined
|
|
22
|
-
export let onCancel = undefined
|
|
23
|
-
export let disabled = false
|
|
24
|
-
export let showDivider = true
|
|
25
|
-
|
|
26
|
-
export let showSecondaryButton = false
|
|
27
|
-
export let secondaryButtonText = undefined
|
|
28
|
-
export let secondaryAction
|
|
29
|
-
|
|
30
|
-
export let
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
export let title: string | undefined = undefined
|
|
15
|
+
export let size: "S" | "M" | "L" | "XL" = "S"
|
|
16
|
+
export let cancelText: string = "Cancel"
|
|
17
|
+
export let confirmText: string = "Confirm"
|
|
18
|
+
export let showCancelButton: boolean = true
|
|
19
|
+
export let showConfirmButton: boolean = true
|
|
20
|
+
export let showCloseIcon: boolean = true
|
|
21
|
+
export let onConfirm: (() => Promise<any> | any) | undefined = undefined
|
|
22
|
+
export let onCancel: (() => Promise<any> | any) | undefined = undefined
|
|
23
|
+
export let disabled: boolean = false
|
|
24
|
+
export let showDivider: boolean = true
|
|
25
|
+
|
|
26
|
+
export let showSecondaryButton: boolean = false
|
|
27
|
+
export let secondaryButtonText: string | undefined = undefined
|
|
28
|
+
export let secondaryAction: ((_e: Event) => Promise<any> | any) | undefined =
|
|
29
|
+
undefined
|
|
30
|
+
export let secondaryButtonWarning: boolean = false
|
|
31
|
+
export let custom: boolean = false
|
|
32
|
+
|
|
33
|
+
const { hide, cancel } = getContext(Context.Modal) as {
|
|
34
|
+
hide: () => void
|
|
35
|
+
cancel: () => void
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let loading: boolean = false
|
|
39
|
+
|
|
40
|
+
let confirmDisabled: boolean
|
|
36
41
|
$: confirmDisabled = disabled || loading
|
|
37
42
|
|
|
38
|
-
async function secondary(e) {
|
|
43
|
+
async function secondary(e: Event): Promise<void> {
|
|
39
44
|
loading = true
|
|
40
45
|
if (!secondaryAction || (await secondaryAction(e)) !== keepOpen) {
|
|
41
46
|
hide()
|
|
@@ -43,7 +48,7 @@
|
|
|
43
48
|
loading = false
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
export async function confirm() {
|
|
51
|
+
export async function confirm(): Promise<void> {
|
|
47
52
|
loading = true
|
|
48
53
|
if (!onConfirm || (await onConfirm()) !== keepOpen) {
|
|
49
54
|
hide()
|
|
@@ -51,7 +56,7 @@
|
|
|
51
56
|
loading = false
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
async function close() {
|
|
59
|
+
async function close(): Promise<void> {
|
|
55
60
|
loading = true
|
|
56
61
|
if (!onCancel || (await onCancel()) !== keepOpen) {
|
|
57
62
|
cancel()
|
|
@@ -90,7 +95,6 @@
|
|
|
90
95
|
{/if}
|
|
91
96
|
{/if}
|
|
92
97
|
|
|
93
|
-
<!-- TODO: Remove content-grid class once Layout components are in bbui -->
|
|
94
98
|
<section class="spectrum-Dialog-content content-grid">
|
|
95
99
|
<slot {loading} />
|
|
96
100
|
</section>
|
|
@@ -102,7 +106,6 @@
|
|
|
102
106
|
{#if showSecondaryButton && secondaryButtonText && secondaryAction}
|
|
103
107
|
<div class="secondary-action">
|
|
104
108
|
<Button
|
|
105
|
-
group
|
|
106
109
|
secondary
|
|
107
110
|
warning={secondaryButtonWarning}
|
|
108
111
|
on:click={secondary}>{secondaryButtonText}</Button
|
|
@@ -111,14 +114,13 @@
|
|
|
111
114
|
{/if}
|
|
112
115
|
|
|
113
116
|
{#if showCancelButton}
|
|
114
|
-
<Button
|
|
117
|
+
<Button secondary on:click={close}>
|
|
115
118
|
{cancelText}
|
|
116
119
|
</Button>
|
|
117
120
|
{/if}
|
|
118
121
|
{#if showConfirmButton}
|
|
119
122
|
<span class="confirm-wrap">
|
|
120
123
|
<Button
|
|
121
|
-
group
|
|
122
124
|
cta
|
|
123
125
|
{...$$restProps}
|
|
124
126
|
disabled={confirmDisabled}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import { ActionButton } from "../"
|
|
3
3
|
|
|
4
4
|
import { createEventDispatcher } from "svelte"
|
|
5
5
|
|
|
6
|
-
export let type = "info"
|
|
7
|
-
export let icon = "Info"
|
|
8
|
-
export let message = ""
|
|
9
|
-
export let dismissable = false
|
|
10
|
-
export let actionMessage = null
|
|
11
|
-
export let action = null
|
|
12
|
-
export let wide = false
|
|
6
|
+
export let type: string = "info"
|
|
7
|
+
export let icon: string = "Info"
|
|
8
|
+
export let message: string = ""
|
|
9
|
+
export let dismissable: boolean = false
|
|
10
|
+
export let actionMessage: string | null = null
|
|
11
|
+
export let action: ((_dismiss: () => void) => void) | null = null
|
|
12
|
+
export let wide: boolean = false
|
|
13
13
|
|
|
14
|
-
const dispatch = createEventDispatcher()
|
|
14
|
+
const dispatch = createEventDispatcher<{ dismiss: void }>()
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<div class="spectrum-Toast spectrum-Toast--{type}" class:wide>
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import "@spectrum-css/pagination/dist/index-vars.css"
|
|
3
3
|
import "@spectrum-css/actionbutton/dist/index-vars.css"
|
|
4
4
|
import "@spectrum-css/typography/dist/index-vars.css"
|
|
5
5
|
|
|
6
|
-
export let page
|
|
7
|
-
export let goToPrevPage
|
|
8
|
-
export let goToNextPage
|
|
9
|
-
export let hasPrevPage = true
|
|
10
|
-
export let hasNextPage = true
|
|
6
|
+
export let page: number
|
|
7
|
+
export let goToPrevPage: () => void
|
|
8
|
+
export let goToNextPage: () => void
|
|
9
|
+
export let hasPrevPage: boolean = true
|
|
10
|
+
export let hasNextPage: boolean = true
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
14
14
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
15
15
|
<nav class="spectrum-Pagination spectrum-Pagination--explicit">
|
|
16
16
|
<div
|
|
17
|
-
href="#"
|
|
18
17
|
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-ActionButton--quiet spectrum-Pagination-prevButton"
|
|
19
18
|
on:click={hasPrevPage ? goToPrevPage : null}
|
|
20
19
|
class:is-disabled={!hasPrevPage}
|
|
@@ -32,7 +31,6 @@
|
|
|
32
31
|
Page {page}
|
|
33
32
|
</span>
|
|
34
33
|
<div
|
|
35
|
-
href="#"
|
|
36
34
|
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-ActionButton--quiet spectrum-Pagination-nextButton"
|
|
37
35
|
on:click={hasNextPage ? goToNextPage : null}
|
|
38
36
|
class:is-disabled={!hasNextPage}
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import "@spectrum-css/progressbar/dist/index-vars.css"
|
|
3
3
|
|
|
4
|
-
export let value = false
|
|
5
|
-
export let duration = 1000
|
|
6
|
-
export let width = false
|
|
7
|
-
export let sideLabel = false
|
|
8
|
-
export let hidePercentage = true
|
|
9
|
-
export let color // red, green, default = blue
|
|
10
|
-
export let size = "M"
|
|
4
|
+
export let value: number | boolean = false
|
|
5
|
+
export let duration: number = 1000
|
|
6
|
+
export let width: string | boolean = false
|
|
7
|
+
export let sideLabel: boolean = false
|
|
8
|
+
export let hidePercentage: boolean = true
|
|
9
|
+
export let color: "red" | "green" | undefined = undefined // red, green, default = blue
|
|
10
|
+
export let size: string = "M"
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<div
|
|
14
14
|
class:spectrum-ProgressBar--indeterminate={!value && value !== 0}
|
|
15
15
|
class:spectrum-ProgressBar--sideLabel={sideLabel}
|
|
16
16
|
class="spectrum-ProgressBar spectrum-ProgressBar--size{size}"
|
|
17
|
-
{value}
|
|
18
17
|
role="progressbar"
|
|
19
|
-
aria-valuenow={value}
|
|
18
|
+
aria-valuenow={typeof value === "number" ? value : undefined}
|
|
20
19
|
aria-valuemin="0"
|
|
21
20
|
aria-valuemax="100"
|
|
22
|
-
style={width ? `width: ${width};` : ""}
|
|
21
|
+
style={width ? `width: ${typeof width === "string" ? width : ""};` : ""}
|
|
23
22
|
>
|
|
24
23
|
{#if $$slots}
|
|
25
24
|
<div
|
|
@@ -32,7 +31,7 @@
|
|
|
32
31
|
<div
|
|
33
32
|
class="spectrum-FieldLabel spectrum-ProgressBar-percentage spectrum-FieldLabel--size{size}"
|
|
34
33
|
>
|
|
35
|
-
{Math.round(value)}%
|
|
34
|
+
{Math.round(Number(value))}%
|
|
36
35
|
</div>
|
|
37
36
|
{/if}
|
|
38
37
|
<div class="spectrum-ProgressBar-track">
|
|
@@ -40,10 +39,12 @@
|
|
|
40
39
|
class="spectrum-ProgressBar-fill"
|
|
41
40
|
class:color-green={color === "green"}
|
|
42
41
|
class:color-red={color === "red"}
|
|
43
|
-
style="width: {value
|
|
42
|
+
style="width: {typeof value === 'number'
|
|
43
|
+
? value
|
|
44
|
+
: 0}%; --duration: {duration}ms;"
|
|
44
45
|
/>
|
|
45
46
|
</div>
|
|
46
|
-
<div class="spectrum-ProgressBar-label" hidden=
|
|
47
|
+
<div class="spectrum-ProgressBar-label" hidden={false} />
|
|
47
48
|
</div>
|
|
48
49
|
|
|
49
50
|
<style>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
<script>
|
|
1
|
+
<script lang="ts">
|
|
2
2
|
import "@spectrum-css/progresscircle/dist/index-vars.css"
|
|
3
3
|
|
|
4
|
-
export let size = "M"
|
|
5
|
-
function convertSize(size) {
|
|
4
|
+
export let size: "S" | "M" | "L" = "M"
|
|
5
|
+
function convertSize(size: "S" | "M" | "L"): string | undefined {
|
|
6
6
|
switch (size) {
|
|
7
7
|
case "S":
|
|
8
8
|
return "small"
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export let value = null
|
|
17
|
-
export let minValue = 0
|
|
18
|
-
export let maxValue = 100
|
|
16
|
+
export let value: number | null = null
|
|
17
|
+
export let minValue: number = 0
|
|
18
|
+
export let maxValue: number = 100
|
|
19
19
|
|
|
20
|
-
let subMask1Style
|
|
21
|
-
let subMask2Style
|
|
20
|
+
let subMask1Style: string | undefined
|
|
21
|
+
let subMask2Style: string | undefined
|
|
22
22
|
$: calculateSubMasks(value)
|
|
23
23
|
|
|
24
|
-
function calculateSubMasks(value) {
|
|
24
|
+
function calculateSubMasks(value: number | null): void {
|
|
25
25
|
if (value) {
|
|
26
26
|
let percentage = ((value - minValue) / (maxValue - minValue)) * 100
|
|
27
|
-
let angle
|
|
27
|
+
let angle: number
|
|
28
28
|
if (percentage > 0 && percentage <= 50) {
|
|
29
29
|
angle = -180 + (percentage / 50) * 180
|
|
30
30
|
subMask1Style = `transform: rotate(${angle}deg);`
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export let overBackground = false
|
|
40
|
+
export let overBackground: boolean = false
|
|
41
41
|
</script>
|
|
42
42
|
|
|
43
43
|
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,6 @@ export { default as Toggle } from "./Form/Toggle.svelte"
|
|
|
17
17
|
export { default as RadioGroup } from "./Form/RadioGroup.svelte"
|
|
18
18
|
export { default as Checkbox } from "./Form/Checkbox.svelte"
|
|
19
19
|
export { default as InputDropdown } from "./Form/InputDropdown.svelte"
|
|
20
|
-
export { default as PickerDropdown } from "./Form/PickerDropdown.svelte"
|
|
21
20
|
export { default as EnvDropdown } from "./Form/EnvDropdown.svelte"
|
|
22
21
|
export { default as Multiselect } from "./Form/Multiselect.svelte"
|
|
23
22
|
export { default as Search } from "./Form/Search.svelte"
|
|
@@ -87,8 +86,6 @@ export { default as MarkdownEditor } from "./Markdown/MarkdownEditor.svelte"
|
|
|
87
86
|
export { default as MarkdownViewer } from "./Markdown/MarkdownViewer.svelte"
|
|
88
87
|
export { default as List } from "./List/List.svelte"
|
|
89
88
|
export { default as ListItem } from "./List/ListItem.svelte"
|
|
90
|
-
export { default as IconSideNav } from "./IconSideNav/IconSideNav.svelte"
|
|
91
|
-
export { default as IconSideNavItem } from "./IconSideNav/IconSideNavItem.svelte"
|
|
92
89
|
export { default as Accordion } from "./Accordion/Accordion.svelte"
|
|
93
90
|
export { default as AbsTooltip } from "./Tooltip/AbsTooltip.svelte"
|
|
94
91
|
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Field from "./Field.svelte"
|
|
3
|
-
import PickerDropdown from "./Core/PickerDropdown.svelte"
|
|
4
|
-
import { createEventDispatcher } from "svelte"
|
|
5
|
-
|
|
6
|
-
export let primaryValue = null
|
|
7
|
-
export let secondaryValue = null
|
|
8
|
-
export let inputType = "text"
|
|
9
|
-
export let label = null
|
|
10
|
-
export let labelPosition = "above"
|
|
11
|
-
export let secondaryPlaceholder = null
|
|
12
|
-
export let autocomplete
|
|
13
|
-
export let placeholder = null
|
|
14
|
-
export let disabled = false
|
|
15
|
-
export let readonly = false
|
|
16
|
-
export let error = null
|
|
17
|
-
export let getSecondaryOptionLabel = option =>
|
|
18
|
-
extractProperty(option, "label")
|
|
19
|
-
export let getSecondaryOptionValue = option =>
|
|
20
|
-
extractProperty(option, "value")
|
|
21
|
-
export let getSecondaryOptionColour = () => {}
|
|
22
|
-
export let getSecondaryOptionIcon = () => {}
|
|
23
|
-
export let quiet = false
|
|
24
|
-
export let autofocus
|
|
25
|
-
export let primaryOptions = []
|
|
26
|
-
export let secondaryOptions = []
|
|
27
|
-
export let searchTerm
|
|
28
|
-
export let showClearIcon = true
|
|
29
|
-
export let helpText = null
|
|
30
|
-
|
|
31
|
-
let primaryLabel
|
|
32
|
-
let secondaryLabel
|
|
33
|
-
const dispatch = createEventDispatcher()
|
|
34
|
-
|
|
35
|
-
$: secondaryFieldText = getSecondaryFieldText(
|
|
36
|
-
secondaryValue,
|
|
37
|
-
secondaryOptions,
|
|
38
|
-
secondaryPlaceholder
|
|
39
|
-
)
|
|
40
|
-
$: secondaryFieldIcon = getSecondaryFieldAttribute(
|
|
41
|
-
getSecondaryOptionIcon,
|
|
42
|
-
secondaryValue,
|
|
43
|
-
secondaryOptions
|
|
44
|
-
)
|
|
45
|
-
$: secondaryFieldColour = getSecondaryFieldAttribute(
|
|
46
|
-
getSecondaryOptionColour,
|
|
47
|
-
secondaryValue,
|
|
48
|
-
secondaryOptions
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
const getSecondaryFieldAttribute = (getAttribute, value, options) => {
|
|
52
|
-
// Wait for options to load if there is a value but no options
|
|
53
|
-
|
|
54
|
-
if (!options?.length) {
|
|
55
|
-
return ""
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const index = options.findIndex(
|
|
59
|
-
(option, idx) => getSecondaryOptionValue(option, idx) === value
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
return index !== -1 ? getAttribute(options[index], index) : null
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const getSecondaryFieldText = (value, options, placeholder) => {
|
|
66
|
-
// Always use placeholder if no value
|
|
67
|
-
if (value == null || value === "") {
|
|
68
|
-
return placeholder || "Choose an option"
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return getSecondaryFieldAttribute(getSecondaryOptionLabel, value, options)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const onPickPrimary = e => {
|
|
75
|
-
primaryLabel = e?.detail?.label || null
|
|
76
|
-
primaryValue = e?.detail?.value || null
|
|
77
|
-
dispatch("pickprimary", e?.detail?.value || {})
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const onPickSecondary = e => {
|
|
81
|
-
secondaryValue = e.detail
|
|
82
|
-
dispatch("picksecondary", e.detail)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const extractProperty = (value, property) => {
|
|
86
|
-
if (value && typeof value === "object") {
|
|
87
|
-
return value[property]
|
|
88
|
-
}
|
|
89
|
-
return value
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const updateSearchTerm = e => {
|
|
93
|
-
searchTerm = e.detail
|
|
94
|
-
}
|
|
95
|
-
</script>
|
|
96
|
-
|
|
97
|
-
<Field {helpText} {label} {labelPosition} {error}>
|
|
98
|
-
<PickerDropdown
|
|
99
|
-
{searchTerm}
|
|
100
|
-
{autocomplete}
|
|
101
|
-
{error}
|
|
102
|
-
{disabled}
|
|
103
|
-
{readonly}
|
|
104
|
-
{placeholder}
|
|
105
|
-
{inputType}
|
|
106
|
-
{quiet}
|
|
107
|
-
{autofocus}
|
|
108
|
-
{primaryOptions}
|
|
109
|
-
{secondaryOptions}
|
|
110
|
-
{getSecondaryOptionLabel}
|
|
111
|
-
{getSecondaryOptionValue}
|
|
112
|
-
{getSecondaryOptionIcon}
|
|
113
|
-
{getSecondaryOptionColour}
|
|
114
|
-
{secondaryFieldText}
|
|
115
|
-
{secondaryFieldIcon}
|
|
116
|
-
{secondaryFieldColour}
|
|
117
|
-
{primaryValue}
|
|
118
|
-
{secondaryValue}
|
|
119
|
-
{primaryLabel}
|
|
120
|
-
{secondaryLabel}
|
|
121
|
-
{showClearIcon}
|
|
122
|
-
on:pickprimary={onPickPrimary}
|
|
123
|
-
on:picksecondary={onPickSecondary}
|
|
124
|
-
on:search={updateSearchTerm}
|
|
125
|
-
on:click
|
|
126
|
-
on:input
|
|
127
|
-
on:blur
|
|
128
|
-
on:focus
|
|
129
|
-
on:keyup
|
|
130
|
-
on:closed
|
|
131
|
-
/>
|
|
132
|
-
</Field>
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Icon from "../Icon/Icon.svelte"
|
|
3
|
-
import Tooltip from "../Tooltip/Tooltip.svelte"
|
|
4
|
-
import { fade } from "svelte/transition"
|
|
5
|
-
|
|
6
|
-
export let icon
|
|
7
|
-
export let active = false
|
|
8
|
-
export let tooltip
|
|
9
|
-
|
|
10
|
-
let showTooltip = false
|
|
11
|
-
</script>
|
|
12
|
-
|
|
13
|
-
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
|
14
|
-
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
15
|
-
<div
|
|
16
|
-
class="icon-side-nav-item"
|
|
17
|
-
class:active
|
|
18
|
-
on:mouseover={() => (showTooltip = true)}
|
|
19
|
-
on:focus={() => (showTooltip = true)}
|
|
20
|
-
on:mouseleave={() => (showTooltip = false)}
|
|
21
|
-
on:click
|
|
22
|
-
>
|
|
23
|
-
<Icon name={icon} hoverable />
|
|
24
|
-
{#if tooltip && showTooltip}
|
|
25
|
-
<div class="tooltip" in:fade={{ duration: 130, delay: 250 }}>
|
|
26
|
-
<Tooltip textWrapping direction="right" text={tooltip} />
|
|
27
|
-
</div>
|
|
28
|
-
{/if}
|
|
29
|
-
</div>
|
|
30
|
-
|
|
31
|
-
<style>
|
|
32
|
-
.icon-side-nav-item {
|
|
33
|
-
width: 36px;
|
|
34
|
-
height: 36px;
|
|
35
|
-
display: grid;
|
|
36
|
-
place-items: center;
|
|
37
|
-
border-radius: 4px;
|
|
38
|
-
position: relative;
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
transition: background 130ms ease-out;
|
|
41
|
-
}
|
|
42
|
-
.icon-side-nav-item:hover :global(svg),
|
|
43
|
-
.active :global(svg) {
|
|
44
|
-
color: var(--spectrum-global-color-gray-900);
|
|
45
|
-
}
|
|
46
|
-
.active {
|
|
47
|
-
background: var(--spectrum-global-color-gray-300);
|
|
48
|
-
}
|
|
49
|
-
.tooltip {
|
|
50
|
-
position: absolute;
|
|
51
|
-
pointer-events: none;
|
|
52
|
-
left: calc(100% - 4px);
|
|
53
|
-
top: 50%;
|
|
54
|
-
white-space: nowrap;
|
|
55
|
-
transform: translateY(-50%);
|
|
56
|
-
z-index: 1;
|
|
57
|
-
}
|
|
58
|
-
</style>
|
package/src/Menu/Menu.svench
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Menu from './Menu.svelte'
|
|
3
|
-
import Separator from './Separator.svelte'
|
|
4
|
-
import Section from './Section.svelte'
|
|
5
|
-
import Item from './Item.svelte'
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
|
-
<Menu>
|
|
9
|
-
<Section heading="Section heading">
|
|
10
|
-
<Item>Some Item 1</Item>
|
|
11
|
-
<Item>Some Item 2</Item>
|
|
12
|
-
<Item>Some Item 3</Item>
|
|
13
|
-
</Section>
|
|
14
|
-
<Separator />
|
|
15
|
-
<Section heading="Section heading">
|
|
16
|
-
<Item icon="SaveFloppy">Save</Item>
|
|
17
|
-
<Item disabled icon="DataDownload">Download</Item>
|
|
18
|
-
</Section>
|
|
19
|
-
</Menu>
|