@budibase/bbui 1.2.0 → 1.2.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/LICENSE +375 -0
- package/README.md +19 -17
- package/dist/bbui.es.js +210 -0
- package/dist/bbui.es.js.map +1 -0
- package/package.json +71 -26
- package/src/ActionButton/ActionButton.svelte +102 -0
- package/src/ActionGroup/ActionGroup.svelte +26 -0
- package/src/ActionMenu/ActionMenu.svelte +44 -0
- package/src/Actions/ClickOutside.svench.svx +30 -0
- package/src/Actions/PositionDropdown.svench.svx +81 -0
- package/src/Actions/autoresize_textarea.js +14 -0
- package/src/Actions/click_outside.js +18 -0
- package/src/Actions/position_dropdown.js +66 -0
- package/src/Avatar/Avatar.svelte +62 -0
- package/src/Badge/Badge.svelte +29 -0
- package/src/Banner/Banner.svelte +72 -0
- package/src/Banner/BannerDisplay.svelte +31 -0
- package/src/Button/Button.svelte +114 -0
- package/src/Button/Button.svench +138 -0
- package/src/ButtonGroup/ButtonGroup.svelte +30 -0
- package/src/ClearButton/ClearButton.svelte +19 -0
- package/src/ColorPicker/ColorPicker.svelte +297 -0
- package/src/DetailSummary/DetailSummary.svelte +83 -0
- package/src/Divider/Divider.svelte +28 -0
- package/src/Drawer/Drawer.svelte +113 -0
- package/src/Drawer/Drawer.svench +42 -0
- package/src/Drawer/DrawerContent.svelte +46 -0
- package/src/Form/Checkbox.svelte +23 -0
- package/src/Form/Combobox.svelte +45 -0
- package/src/Form/Core/Checkbox.svelte +69 -0
- package/src/Form/Core/CheckboxGroup.svelte +68 -0
- package/src/Form/Core/Combobox.svelte +142 -0
- package/src/Form/Core/DatePicker.svelte +242 -0
- package/src/Form/Core/Dropzone.svelte +438 -0
- package/src/Form/Core/InputDropdown.svelte +228 -0
- package/src/Form/Core/Multiselect.svelte +90 -0
- package/src/Form/Core/Picker.svelte +259 -0
- package/src/Form/Core/PickerDropdown.svelte +436 -0
- package/src/Form/Core/RadioGroup.svelte +47 -0
- package/src/Form/Core/RichTextField.svelte +42 -0
- package/src/Form/Core/Search.svelte +105 -0
- package/src/Form/Core/Select.svelte +75 -0
- package/src/Form/Core/Slider.svelte +86 -0
- package/src/Form/Core/Stepper.svelte +172 -0
- package/src/Form/Core/Switch.svelte +37 -0
- package/src/Form/Core/TextArea.svelte +78 -0
- package/src/Form/Core/TextField.svelte +119 -0
- package/src/Form/Core/index.js +15 -0
- package/src/Form/DatePicker.svelte +37 -0
- package/src/Form/Dropzone.svelte +40 -0
- package/src/Form/Field.svelte +42 -0
- package/src/Form/FieldLabel.svelte +32 -0
- package/src/Form/Input.svelte +40 -45
- package/src/Form/InputDropdown.svelte +55 -0
- package/src/Form/Multiselect.svelte +40 -0
- package/src/Form/PickerDropdown.svelte +132 -0
- package/src/Form/RadioGroup.svelte +40 -0
- package/src/Form/RichTextField.svelte +36 -0
- package/src/Form/Search.svelte +36 -0
- package/src/Form/Select.svelte +48 -43
- package/src/Form/Slider.svelte +24 -0
- package/src/Form/Stepper.svelte +45 -0
- package/src/Form/TextArea.svelte +29 -44
- package/src/Form/Toggle.svelte +23 -0
- package/src/Icon/Icon.svelte +86 -0
- package/src/IconPicker/IconPicker.svelte +177 -0
- package/src/IconSideNav/IconSideNav.svelte +14 -0
- package/src/IconSideNav/IconSideNavItem.svelte +56 -0
- package/src/InlineAlert/InlineAlert.svelte +56 -0
- package/src/Label/Label.svelte +20 -0
- package/src/Layout/Layout.svelte +94 -0
- package/src/Layout/Page.svelte +32 -0
- package/src/Link/Link.svelte +22 -0
- package/src/List/List.svelte +28 -0
- package/src/List/ListItem.svelte +92 -0
- package/src/Markdown/MarkdownEditor.svelte +60 -0
- package/src/Markdown/MarkdownViewer.svelte +70 -0
- package/src/Markdown/SpectrumMDE.svelte +184 -0
- package/src/Menu/Item.svelte +45 -0
- package/src/Menu/Menu.svelte +7 -0
- package/src/Menu/Menu.svench +19 -0
- package/src/Menu/Section.svelte +10 -0
- package/src/Menu/Separator.svelte +1 -0
- package/src/Modal/Content.svelte +6 -0
- package/src/Modal/CustomContent.svelte +38 -0
- package/src/Modal/Modal.svelte +142 -0
- package/src/Modal/Modal.svench +117 -0
- package/src/Modal/ModalContent.svelte +190 -0
- package/src/Modal/QuizModal.svelte +54 -0
- package/src/Notification/Notification.svelte +70 -0
- package/src/Notification/NotificationDisplay.svelte +43 -0
- package/src/Pagination/Pagination.svelte +57 -0
- package/src/Popover/Popover.svelte +77 -0
- package/src/Popover/Popover.svench +121 -0
- package/src/ProgressBar/ProgressBar.svelte +54 -0
- package/src/ProgressCircle/ProgressCircle.svelte +62 -0
- package/src/SideNavigation/Item.svelte +47 -0
- package/src/SideNavigation/Navigation.svelte +12 -0
- package/src/StatusLight/StatusLight.svelte +80 -0
- package/src/Stores/Notifications.svench.svx +78 -0
- package/src/Stores/banner.js +37 -0
- package/src/Stores/notifications.js +84 -0
- package/src/Table/ArrayRenderer.svelte +17 -0
- package/src/Table/AttachmentRenderer.svelte +57 -0
- package/src/Table/BoldRenderer.svelte +15 -0
- package/src/Table/BooleanRenderer.svelte +42 -0
- package/src/Table/CellRenderer.svelte +69 -0
- package/src/Table/CodeRenderer.svelte +14 -0
- package/src/Table/DateTimeRenderer.svelte +29 -0
- package/src/Table/InternalRenderer.svelte +24 -0
- package/src/Table/RelationshipRenderer.svelte +40 -0
- package/src/Table/SelectEditRenderer.svelte +28 -0
- package/src/Table/StringRenderer.svelte +14 -0
- package/src/Table/Table.svelte +648 -0
- package/src/Table/index.js +1 -0
- package/src/Tabs/Tab.svelte +88 -0
- package/src/Tabs/Tabs.svelte +125 -0
- package/src/Tags/Tag.svelte +43 -0
- package/src/Tags/Tags.svelte +7 -0
- package/src/Tooltip/Tooltip.svelte +34 -0
- package/src/Tooltip/TooltipWrapper.svelte +60 -0
- package/src/TreeView/Item.svelte +41 -0
- package/src/TreeView/Tree.svelte +16 -0
- package/src/Typography/Body.svelte +21 -0
- package/src/Typography/Code.svelte +10 -0
- package/src/Typography/Detail.svelte +19 -0
- package/src/Typography/Heading.svelte +17 -0
- package/src/bbui.css +96 -0
- package/src/context.js +3 -0
- package/src/helpers.js +134 -0
- package/src/index.js +97 -11
- package/src/spectrum-icons-rollup.js +31 -0
- package/src/spectrum-icons-vite.js +31 -0
- package/dist/bundle.css +0 -7
- package/dist/bundle.css.map +0 -20
- package/dist/index.js +0 -1100
- package/dist/index.mjs +0 -1086
- package/src/Branding/Budibase-logo.svelte +0 -68
- package/src/Branding/Logo.svelte +0 -16
- package/src/Branding/Logo.svench +0 -8
- package/src/Form/Button.svelte +0 -131
- package/src/Form/Button.svench +0 -49
- package/src/Form/Input.svench +0 -8
- package/src/Form/Select.svench +0 -8
- package/src/Form/TextArea.svench +0 -8
- package/src/Links/Home.svelte +0 -49
- package/src/Links/Home.svench +0 -19
- package/src/List/Items/DetailSummary.svelte +0 -66
- package/src/List/Items/DetailSummary.svench +0 -15
- package/src/actions/autoresize_textarea.js +0 -14
- package/src/icons/Contribution.svelte +0 -14
- package/src/index.svench.svx +0 -35
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import SpectrumMDE from "./SpectrumMDE.svelte"
|
|
3
|
+
import { createEventDispatcher } from "svelte"
|
|
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 easyMDEOptions
|
|
12
|
+
|
|
13
|
+
const dispatch = createEventDispatcher()
|
|
14
|
+
|
|
15
|
+
let latestValue
|
|
16
|
+
let mde
|
|
17
|
+
|
|
18
|
+
// Ensure the value is updated if the value prop changes outside the editor's
|
|
19
|
+
// control
|
|
20
|
+
$: checkValue(value)
|
|
21
|
+
$: mde?.codemirror.on("change", debouncedUpdate)
|
|
22
|
+
|
|
23
|
+
const checkValue = val => {
|
|
24
|
+
if (mde && val !== latestValue) {
|
|
25
|
+
mde.value(val)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const debounce = (fn, interval) => {
|
|
30
|
+
let timeout
|
|
31
|
+
return () => {
|
|
32
|
+
clearTimeout(timeout)
|
|
33
|
+
timeout = setTimeout(fn, interval)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const update = () => {
|
|
38
|
+
latestValue = mde.value()
|
|
39
|
+
dispatch("change", latestValue)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Debounce the update function to avoid spamming it constantly
|
|
43
|
+
const debouncedUpdate = debounce(update, 250)
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
{#key height}
|
|
47
|
+
<SpectrumMDE
|
|
48
|
+
bind:mde
|
|
49
|
+
scroll={true}
|
|
50
|
+
{height}
|
|
51
|
+
{id}
|
|
52
|
+
{fullScreenOffset}
|
|
53
|
+
{disabled}
|
|
54
|
+
easyMDEOptions={{
|
|
55
|
+
initialValue: value,
|
|
56
|
+
placeholder,
|
|
57
|
+
...easyMDEOptions,
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
{/key}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import SpectrumMDE from "./SpectrumMDE.svelte"
|
|
3
|
+
|
|
4
|
+
export let value
|
|
5
|
+
export let height
|
|
6
|
+
|
|
7
|
+
let mde
|
|
8
|
+
|
|
9
|
+
// Keep the value up to date
|
|
10
|
+
$: mde && mde.value(value || "")
|
|
11
|
+
$: {
|
|
12
|
+
if (mde && !mde.isPreviewActive()) {
|
|
13
|
+
mde.togglePreview()
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div class="markdown-viewer" style="height:{height};">
|
|
19
|
+
<SpectrumMDE
|
|
20
|
+
bind:mde
|
|
21
|
+
scroll={false}
|
|
22
|
+
easyMDEOptions={{
|
|
23
|
+
initialValue: value,
|
|
24
|
+
toolbar: false,
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<style>
|
|
30
|
+
.markdown-viewer {
|
|
31
|
+
overflow: auto;
|
|
32
|
+
}
|
|
33
|
+
/* Remove padding, borders and background colors */
|
|
34
|
+
.markdown-viewer :global(.editor-preview) {
|
|
35
|
+
padding: 0;
|
|
36
|
+
border: none;
|
|
37
|
+
background: transparent;
|
|
38
|
+
}
|
|
39
|
+
.markdown-viewer :global(.CodeMirror) {
|
|
40
|
+
border: none;
|
|
41
|
+
background: transparent;
|
|
42
|
+
padding: 0;
|
|
43
|
+
}
|
|
44
|
+
.markdown-viewer :global(.EasyMDEContainer) {
|
|
45
|
+
background: transparent;
|
|
46
|
+
}
|
|
47
|
+
/* Hide the actual code editor */
|
|
48
|
+
.markdown-viewer :global(.CodeMirror-scroll) {
|
|
49
|
+
display: none;
|
|
50
|
+
}
|
|
51
|
+
/*Hide the scrollbar*/
|
|
52
|
+
.markdown-viewer :global(.CodeMirror-vscrollbar) {
|
|
53
|
+
display: none !important;
|
|
54
|
+
}
|
|
55
|
+
/*Position relatively so we only consume whatever space we need */
|
|
56
|
+
.markdown-viewer :global(.editor-preview-full) {
|
|
57
|
+
position: relative;
|
|
58
|
+
}
|
|
59
|
+
/* Remove margin on the first and last components to fully trim the preview */
|
|
60
|
+
.markdown-viewer :global(.editor-preview-full > :first-child) {
|
|
61
|
+
margin-top: 0;
|
|
62
|
+
}
|
|
63
|
+
.markdown-viewer :global(.editor-preview-full > :last-child) {
|
|
64
|
+
margin-bottom: 0;
|
|
65
|
+
}
|
|
66
|
+
/* Code blocks in preview */
|
|
67
|
+
.markdown-viewer :global(.editor-preview-full pre) {
|
|
68
|
+
background: var(--spectrum-global-color-gray-200);
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import EasyMDE from "easymde"
|
|
3
|
+
import "easymde/dist/easymde.min.css"
|
|
4
|
+
import { onMount } from "svelte"
|
|
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
|
|
13
|
+
|
|
14
|
+
let element
|
|
15
|
+
|
|
16
|
+
onMount(() => {
|
|
17
|
+
height = height || "200px"
|
|
18
|
+
mde = new EasyMDE({
|
|
19
|
+
element,
|
|
20
|
+
spellChecker: false,
|
|
21
|
+
status: false,
|
|
22
|
+
unorderedListStyle: "-",
|
|
23
|
+
maxHeight: scroll ? height : undefined,
|
|
24
|
+
minHeight: scroll ? undefined : height,
|
|
25
|
+
...easyMDEOptions,
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
// Revert the editor when we unmount
|
|
29
|
+
return () => {
|
|
30
|
+
mde.toTextArea()
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
$: styleString = getStyleString(fullScreenOffset)
|
|
35
|
+
|
|
36
|
+
const getStyleString = offset => {
|
|
37
|
+
let string = ""
|
|
38
|
+
string += `--fullscreen-offset-x:${offset?.x || "0px"};`
|
|
39
|
+
string += `--fullscreen-offset-y:${offset?.y || "0px"};`
|
|
40
|
+
return string
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div class:disabled style={styleString}>
|
|
45
|
+
<textarea disabled {id} bind:this={element} />
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
/* Disabled styles */
|
|
50
|
+
.disabled :global(textarea) {
|
|
51
|
+
display: none;
|
|
52
|
+
}
|
|
53
|
+
.disabled :global(.CodeMirror-cursor) {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
.disabled :global(.EasyMDEContainer) {
|
|
57
|
+
pointer-events: none;
|
|
58
|
+
}
|
|
59
|
+
.disabled :global(.editor-toolbar button i) {
|
|
60
|
+
color: var(--spectrum-global-color-gray-400);
|
|
61
|
+
}
|
|
62
|
+
.disabled :global(.CodeMirror) {
|
|
63
|
+
color: var(--spectrum-global-color-gray-600);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Toolbar container */
|
|
67
|
+
:global(.EasyMDEContainer .editor-toolbar) {
|
|
68
|
+
background: var(--spectrum-global-color-gray-50);
|
|
69
|
+
border-top: 1px solid var(--spectrum-alias-border-color);
|
|
70
|
+
border-left: 1px solid var(--spectrum-alias-border-color);
|
|
71
|
+
border-right: 1px solid var(--spectrum-alias-border-color);
|
|
72
|
+
}
|
|
73
|
+
/* Main code mirror instance and default color */
|
|
74
|
+
:global(.EasyMDEContainer .CodeMirror) {
|
|
75
|
+
border: 1px solid var(--spectrum-alias-border-color);
|
|
76
|
+
background: var(--spectrum-global-color-gray-50);
|
|
77
|
+
color: var(--spectrum-alias-text-color);
|
|
78
|
+
}
|
|
79
|
+
/* Toolbar button active state */
|
|
80
|
+
:global(.EasyMDEContainer .editor-toolbar button.active) {
|
|
81
|
+
background: var(--spectrum-global-color-gray-200);
|
|
82
|
+
border-color: var(--spectrum-global-color-gray-400);
|
|
83
|
+
}
|
|
84
|
+
/* Toolbar button hover state */
|
|
85
|
+
:global(.EasyMDEContainer .editor-toolbar button:hover) {
|
|
86
|
+
background: var(--spectrum-global-color-gray-200);
|
|
87
|
+
border-color: var(--spectrum-global-color-gray-400);
|
|
88
|
+
}
|
|
89
|
+
/* Toolbar button color */
|
|
90
|
+
:global(.EasyMDEContainer .editor-toolbar button i) {
|
|
91
|
+
color: var(--spectrum-global-color-gray-800);
|
|
92
|
+
}
|
|
93
|
+
/* Separator between toolbar buttons*/
|
|
94
|
+
:global(.EasyMDEContainer .editor-toolbar i.separator) {
|
|
95
|
+
border-color: var(--spectrum-global-color-gray-300);
|
|
96
|
+
}
|
|
97
|
+
/* Cursor */
|
|
98
|
+
:global(.EasyMDEContainer .CodeMirror-cursor) {
|
|
99
|
+
border-color: var(--spectrum-alias-text-color);
|
|
100
|
+
}
|
|
101
|
+
/* Text selections */
|
|
102
|
+
:global(.EasyMDEContainer .CodeMirror-selectedtext) {
|
|
103
|
+
background: var(--spectrum-global-color-gray-400) !important;
|
|
104
|
+
}
|
|
105
|
+
/* Background of lines containing selected text */
|
|
106
|
+
:global(.EasyMDEContainer .CodeMirror-selected) {
|
|
107
|
+
background: var(--spectrum-global-color-gray-400) !important;
|
|
108
|
+
}
|
|
109
|
+
/* Color of text for images and links */
|
|
110
|
+
:global(.EasyMDEContainer .cm-s-easymde .cm-link) {
|
|
111
|
+
color: var(--spectrum-global-color-gray-600);
|
|
112
|
+
}
|
|
113
|
+
/* Color of URL for images and links */
|
|
114
|
+
:global(.EasyMDEContainer .cm-s-easymde .cm-url) {
|
|
115
|
+
color: var(--spectrum-global-color-gray-500);
|
|
116
|
+
}
|
|
117
|
+
/* Full preview window */
|
|
118
|
+
:global(.EasyMDEContainer .editor-preview) {
|
|
119
|
+
background: var(--spectrum-global-color-gray-50);
|
|
120
|
+
}
|
|
121
|
+
/* Side by side preview window */
|
|
122
|
+
:global(.EasyMDEContainer .editor-preview) {
|
|
123
|
+
border: 1px solid var(--spectrum-alias-border-color);
|
|
124
|
+
}
|
|
125
|
+
/* Code blocks in editor */
|
|
126
|
+
:global(.EasyMDEContainer .cm-s-easymde .cm-comment) {
|
|
127
|
+
background: var(--spectrum-global-color-gray-100);
|
|
128
|
+
}
|
|
129
|
+
/* Code blocks in preview */
|
|
130
|
+
:global(.EasyMDEContainer pre) {
|
|
131
|
+
background: var(--spectrum-global-color-gray-100);
|
|
132
|
+
padding: 4px;
|
|
133
|
+
border-radius: 4px;
|
|
134
|
+
}
|
|
135
|
+
:global(.EasyMDEContainer code) {
|
|
136
|
+
color: #e83e8c;
|
|
137
|
+
}
|
|
138
|
+
:global(.EasyMDEContainer pre code) {
|
|
139
|
+
color: var(--spectrum-alias-text-color);
|
|
140
|
+
}
|
|
141
|
+
/* Block quotes */
|
|
142
|
+
:global(.EasyMDEContainer blockquote) {
|
|
143
|
+
border-left: 4px solid var(--spectrum-global-color-gray-400);
|
|
144
|
+
color: var(--spectrum-global-color-gray-700);
|
|
145
|
+
margin-left: 0;
|
|
146
|
+
padding-left: 20px;
|
|
147
|
+
}
|
|
148
|
+
/* HR's */
|
|
149
|
+
:global(.EasyMDEContainer hr) {
|
|
150
|
+
background-color: var(--spectrum-global-color-gray-300);
|
|
151
|
+
border: none;
|
|
152
|
+
height: 2px;
|
|
153
|
+
}
|
|
154
|
+
/* Tables */
|
|
155
|
+
:global(.EasyMDEContainer td, .EasyMDEContainer th) {
|
|
156
|
+
border-color: var(--spectrum-alias-border-color) !important;
|
|
157
|
+
}
|
|
158
|
+
/* Links */
|
|
159
|
+
:global(.EasyMDEContainer a) {
|
|
160
|
+
color: var(--primaryColor);
|
|
161
|
+
}
|
|
162
|
+
:global(.EasyMDEContainer a:hover) {
|
|
163
|
+
color: var(--primaryColorHover);
|
|
164
|
+
}
|
|
165
|
+
/* Allow full screen offset */
|
|
166
|
+
:global(.EasyMDEContainer .editor-toolbar.fullscreen) {
|
|
167
|
+
left: var(--fullscreen-offset-x);
|
|
168
|
+
top: var(--fullscreen-offset-y);
|
|
169
|
+
}
|
|
170
|
+
:global(.EasyMDEContainer .CodeMirror-fullscreen) {
|
|
171
|
+
left: var(--fullscreen-offset-x);
|
|
172
|
+
top: calc(50px + var(--fullscreen-offset-y));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
:global(.EasyMDEContainer .CodeMirror-fullscreen.CodeMirror-sided) {
|
|
176
|
+
width: calc((100% - var(--fullscreen-offset-x)) / 2) !important;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
:global(.EasyMDEContainer .editor-preview-side) {
|
|
180
|
+
left: calc(50% + (var(--fullscreen-offset-x) / 2));
|
|
181
|
+
top: calc(50px + var(--fullscreen-offset-y));
|
|
182
|
+
width: calc((100% - var(--fullscreen-offset-x)) / 2) !important;
|
|
183
|
+
}
|
|
184
|
+
</style>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher, getContext } from "svelte"
|
|
3
|
+
|
|
4
|
+
const dispatch = createEventDispatcher()
|
|
5
|
+
const actionMenu = getContext("actionMenu")
|
|
6
|
+
|
|
7
|
+
export let dataCy
|
|
8
|
+
export let icon = undefined
|
|
9
|
+
export let disabled = undefined
|
|
10
|
+
export let noClose = false
|
|
11
|
+
|
|
12
|
+
const onClick = () => {
|
|
13
|
+
if (actionMenu && !noClose) {
|
|
14
|
+
actionMenu.hide()
|
|
15
|
+
}
|
|
16
|
+
dispatch("click")
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<li
|
|
21
|
+
data-cy={dataCy}
|
|
22
|
+
on:click|preventDefault={disabled ? null : onClick}
|
|
23
|
+
class="spectrum-Menu-item"
|
|
24
|
+
class:is-disabled={disabled}
|
|
25
|
+
role="menuitem"
|
|
26
|
+
tabindex="0"
|
|
27
|
+
>
|
|
28
|
+
{#if icon}
|
|
29
|
+
<svg
|
|
30
|
+
class="spectrum-Icon spectrum-Icon--sizeS spectrum-Menu-itemIcon"
|
|
31
|
+
focusable="false"
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
aria-label={icon}
|
|
34
|
+
>
|
|
35
|
+
<use xlink:href="#spectrum-icon-18-{icon}" />
|
|
36
|
+
</svg>
|
|
37
|
+
{/if}
|
|
38
|
+
<span class="spectrum-Menu-itemLabel"><slot /></span>
|
|
39
|
+
</li>
|
|
40
|
+
|
|
41
|
+
<style>
|
|
42
|
+
.spectrum-Menu-itemIcon {
|
|
43
|
+
align-self: center;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
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>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<li class="spectrum-Menu-divider" role="separator" />
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { getContext } from "svelte"
|
|
3
|
+
import Context from "../context"
|
|
4
|
+
|
|
5
|
+
const { hide } = getContext(Context.Modal)
|
|
6
|
+
|
|
7
|
+
let count = 0
|
|
8
|
+
const clicks = 5
|
|
9
|
+
$: if (count === clicks) hide()
|
|
10
|
+
$: remaining = clicks - count
|
|
11
|
+
|
|
12
|
+
function increment() {
|
|
13
|
+
count++
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div on:click={increment}>
|
|
18
|
+
Click me
|
|
19
|
+
{remaining}
|
|
20
|
+
more time{remaining === 1 ? "" : "s"}
|
|
21
|
+
to close this modal!
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
div {
|
|
26
|
+
padding: 40px;
|
|
27
|
+
background-color: var(--purple);
|
|
28
|
+
color: white;
|
|
29
|
+
font-family: var(--font-sans);
|
|
30
|
+
font-weight: bold;
|
|
31
|
+
text-align: center;
|
|
32
|
+
user-select: none;
|
|
33
|
+
font-size: 20px;
|
|
34
|
+
}
|
|
35
|
+
div:hover {
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
}
|
|
38
|
+
</style>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/modal/dist/index-vars.css"
|
|
3
|
+
import "@spectrum-css/underlay/dist/index-vars.css"
|
|
4
|
+
import { createEventDispatcher, setContext, tick } from "svelte"
|
|
5
|
+
import { fade, fly } from "svelte/transition"
|
|
6
|
+
import Portal from "svelte-portal"
|
|
7
|
+
import Context from "../context"
|
|
8
|
+
|
|
9
|
+
export let fixed = false
|
|
10
|
+
export let inline = false
|
|
11
|
+
|
|
12
|
+
const dispatch = createEventDispatcher()
|
|
13
|
+
let visible = fixed || inline
|
|
14
|
+
$: dispatch(visible ? "show" : "hide")
|
|
15
|
+
|
|
16
|
+
export function show() {
|
|
17
|
+
if (visible) {
|
|
18
|
+
return
|
|
19
|
+
}
|
|
20
|
+
visible = true
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function hide() {
|
|
24
|
+
if (!visible || fixed || inline) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
visible = false
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function cancel() {
|
|
31
|
+
if (!visible) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
dispatch("cancel")
|
|
35
|
+
hide()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function handleKey(e) {
|
|
39
|
+
if (visible && e.key === "Escape") {
|
|
40
|
+
cancel()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function focusFirstInput(node) {
|
|
45
|
+
const inputs = node.querySelectorAll("input")
|
|
46
|
+
if (inputs?.length) {
|
|
47
|
+
await tick()
|
|
48
|
+
inputs[0].focus()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setContext(Context.Modal, { show, hide, cancel })
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<svelte:window on:keydown={handleKey} />
|
|
56
|
+
|
|
57
|
+
{#if inline}
|
|
58
|
+
{#if visible}
|
|
59
|
+
<div use:focusFirstInput class="spectrum-Modal inline is-open">
|
|
60
|
+
<slot />
|
|
61
|
+
</div>
|
|
62
|
+
{/if}
|
|
63
|
+
{:else}
|
|
64
|
+
<!--
|
|
65
|
+
We cannot conditionally render the portal as this leads to a missing
|
|
66
|
+
insertion point when using nested modals. Therefore we just conditionally
|
|
67
|
+
render the content of the portal.
|
|
68
|
+
It still breaks the modal animation, but its better than soft bricking the
|
|
69
|
+
screen.
|
|
70
|
+
-->
|
|
71
|
+
<Portal target=".modal-container">
|
|
72
|
+
{#if visible}
|
|
73
|
+
<div
|
|
74
|
+
class="spectrum-Underlay is-open"
|
|
75
|
+
in:fade={{ duration: 200 }}
|
|
76
|
+
out:fade|local={{ duration: 200 }}
|
|
77
|
+
on:mousedown|self={cancel}
|
|
78
|
+
>
|
|
79
|
+
<div class="modal-wrapper" on:mousedown|self={cancel}>
|
|
80
|
+
<div class="modal-inner-wrapper" on:mousedown|self={cancel}>
|
|
81
|
+
<slot name="outside" />
|
|
82
|
+
<div
|
|
83
|
+
use:focusFirstInput
|
|
84
|
+
class="spectrum-Modal is-open"
|
|
85
|
+
in:fly={{ y: 30, duration: 200 }}
|
|
86
|
+
out:fly|local={{ y: 30, duration: 200 }}
|
|
87
|
+
>
|
|
88
|
+
<slot />
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
{/if}
|
|
94
|
+
</Portal>
|
|
95
|
+
{/if}
|
|
96
|
+
|
|
97
|
+
<style>
|
|
98
|
+
.spectrum-Underlay {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: row;
|
|
101
|
+
justify-content: center;
|
|
102
|
+
align-items: center;
|
|
103
|
+
z-index: 999;
|
|
104
|
+
overflow: auto;
|
|
105
|
+
overflow-x: hidden;
|
|
106
|
+
background: rgba(0, 0, 0, 0.75);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.modal-wrapper {
|
|
110
|
+
flex: 1 1 auto;
|
|
111
|
+
display: flex;
|
|
112
|
+
flex-direction: row;
|
|
113
|
+
-moz-box-pack: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
align-items: flex-start;
|
|
116
|
+
max-height: 100%;
|
|
117
|
+
}
|
|
118
|
+
.modal-inner-wrapper {
|
|
119
|
+
flex: 1 1 auto;
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: row;
|
|
122
|
+
-moz-box-pack: center;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
align-items: flex-start;
|
|
125
|
+
width: 0;
|
|
126
|
+
position: relative;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.spectrum-Modal {
|
|
130
|
+
overflow: visible;
|
|
131
|
+
max-height: none;
|
|
132
|
+
margin: 40px 0;
|
|
133
|
+
transform: none;
|
|
134
|
+
--spectrum-dialog-confirm-border-radius: var(
|
|
135
|
+
--spectrum-global-dimension-size-100
|
|
136
|
+
);
|
|
137
|
+
max-width: 100%;
|
|
138
|
+
}
|
|
139
|
+
:global(.spectrum--lightest .spectrum-Modal.inline) {
|
|
140
|
+
border: var(--border-light);
|
|
141
|
+
}
|
|
142
|
+
</style>
|