@budibase/bbui 1.58.13 → 2.0.1
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/dist/bbui.es.js +14 -0
- package/dist/bbui.es.js.map +1 -0
- package/package.json +68 -32
- package/src/ActionButton/ActionButton.svelte +102 -0
- package/src/ActionGroup/ActionGroup.svelte +26 -0
- package/src/ActionMenu/ActionMenu.svelte +44 -0
- package/src/Actions/autoresize_textarea.js +9 -9
- package/src/Actions/click_outside.js +5 -5
- package/src/Actions/position_dropdown.js +46 -37
- 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 +41 -0
- package/src/Button/Button.svelte +102 -200
- 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 +76 -51
- package/src/Drawer/DrawerContent.svelte +46 -0
- package/src/Form/Checkbox.svelte +21 -132
- 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 +257 -0
- package/src/Form/Core/Dropzone.svelte +453 -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 +415 -0
- package/src/Form/Core/RadioGroup.svelte +48 -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 +39 -0
- package/src/Form/Dropzone.svelte +42 -0
- package/src/Form/Field.svelte +42 -0
- package/src/Form/FieldLabel.svelte +32 -0
- package/src/Form/Input.svelte +41 -187
- package/src/Form/InputDropdown.svelte +55 -0
- package/src/Form/Multiselect.svelte +36 -320
- package/src/Form/PickerDropdown.svelte +132 -0
- package/src/Form/RadioGroup.svelte +42 -0
- package/src/Form/RichTextField.svelte +36 -0
- package/src/Form/Search.svelte +36 -0
- package/src/Form/Select.svelte +48 -88
- package/src/Form/Slider.svelte +16 -91
- package/src/Form/Stepper.svelte +45 -0
- package/src/Form/TextArea.svelte +30 -128
- package/src/Form/Toggle.svelte +20 -110
- package/src/Icon/Icon.svelte +91 -0
- package/src/Icon/IconAvatar.svelte +58 -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 +60 -0
- package/src/Label/Label.svelte +29 -0
- package/src/Layout/Layout.svelte +94 -0
- package/src/Layout/Page.svelte +32 -0
- package/src/Link/Link.svelte +24 -0
- package/src/List/List.svelte +28 -0
- package/src/List/ListItem.svelte +90 -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 +96 -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 +0 -11
- package/src/Modal/CustomContent.svelte +9 -6
- package/src/Modal/Modal.svelte +104 -51
- package/src/Modal/ModalContent.svelte +131 -73
- package/src/Modal/QuizModal.svelte +16 -17
- 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 +43 -33
- package/src/ProgressBar/ProgressBar.svelte +67 -0
- package/src/ProgressCircle/ProgressCircle.svelte +62 -0
- package/src/SideNavigation/Item.svelte +61 -0
- package/src/SideNavigation/Navigation.svelte +12 -0
- package/src/StatusLight/StatusLight.svelte +80 -0
- package/src/Stores/Notifications.svench.svx +1 -1
- package/src/Stores/banner.js +65 -0
- package/src/Stores/notifications.js +75 -38
- package/src/Table/ArrayRenderer.svelte +17 -0
- package/src/Table/AttachmentRenderer.svelte +73 -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 +635 -0
- package/src/Table/index.js +1 -0
- package/src/Tabs/Tab.svelte +88 -0
- package/src/Tabs/Tabs.svelte +130 -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/{dist → src}/bbui.css +2 -99
- package/src/context.js +1 -1
- package/src/helpers.js +134 -0
- package/src/index.js +95 -40
- package/src/spectrum-icons-rollup.js +31 -0
- package/src/spectrum-icons-vite.js +31 -0
- package/dist/dist/bundle.css +0 -42
- package/dist/dist/bundle.css.map +0 -64
- package/dist/index.js +0 -36193
- package/dist/index.mjs +0 -36147
- package/src/Button/Close.svelte +0 -59
- package/src/Button/Close.svench +0 -36
- package/src/Button/TextButton.svelte +0 -128
- package/src/Button/TextButton.svench +0 -69
- package/src/DatePicker/DatePicker.svelte +0 -45
- package/src/DatePicker/DatePicker.svench +0 -17
- package/src/DropdownMenu/DropdownMenu.svelte +0 -77
- package/src/DropdownMenu/DropdownMenu.svench +0 -161
- package/src/Dropzone/Dropzone.svelte +0 -294
- package/src/Dropzone/Dropzone.svench +0 -17
- package/src/Dropzone/fileTypes.js +0 -5
- package/src/Form/Checkbox.svench.svx +0 -67
- package/src/Form/DataList.svelte +0 -158
- package/src/Form/DataList.svench +0 -57
- package/src/Form/Input.svench +0 -62
- package/src/Form/Multiselect.svench +0 -63
- package/src/Form/Radio.svelte +0 -133
- package/src/Form/Radio.svench.svx +0 -64
- package/src/Form/RichText.svelte +0 -61
- package/src/Form/RichText.svench.svx +0 -40
- package/src/Form/Select.svench +0 -62
- package/src/Form/Slider.svench +0 -26
- package/src/Form/TextArea.svench +0 -30
- package/src/Form/Toggle.svench +0 -21
- package/src/Icons/Contribution.svelte +0 -14
- package/src/Icons/Icon.svelte +0 -36
- package/src/Icons/Icon.svench +0 -109
- package/src/Icons/icon-paths.js +0 -136
- package/src/Links/Home.svelte +0 -51
- package/src/Links/Home.svench +0 -19
- package/src/List/Items/DetailSummary.svelte +0 -85
- package/src/List/Items/DetailSummary.svench +0 -53
- package/src/List/Search.svelte +0 -34
- package/src/List/Search.svench +0 -8
- package/src/Spacer/Spacer.svelte +0 -50
- package/src/Spacer/Spacer.svench +0 -51
- package/src/Styleguide/Body.svelte +0 -72
- package/src/Styleguide/Borders.svench +0 -175
- package/src/Styleguide/Budibase-logo.svelte +0 -68
- package/src/Styleguide/Color.svench +0 -201
- package/src/Styleguide/Heading.svelte +0 -74
- package/src/Styleguide/Label.svelte +0 -70
- package/src/Styleguide/Logo.svelte +0 -16
- package/src/Styleguide/Logo.svench +0 -8
- package/src/Styleguide/Spacing.svench +0 -191
- package/src/Styleguide/Typography.svench +0 -227
- package/src/Switcher/Switcher.svelte +0 -47
- package/src/Switcher/Switcher.svench +0 -27
- package/src/index.svench.svx +0 -35
- package/src/utils/buildStyle.js +0 -14
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/inputgroup/dist/index-vars.css"
|
|
3
|
+
import "@spectrum-css/popover/dist/index-vars.css"
|
|
4
|
+
import "@spectrum-css/menu/dist/index-vars.css"
|
|
5
|
+
import { fly } from "svelte/transition"
|
|
6
|
+
import { createEventDispatcher } from "svelte"
|
|
7
|
+
import clickOutside from "../../Actions/click_outside"
|
|
8
|
+
import Icon from "../../Icon/Icon.svelte"
|
|
9
|
+
import StatusLight from "../../StatusLight/StatusLight.svelte"
|
|
10
|
+
import Detail from "../../Typography/Detail.svelte"
|
|
11
|
+
import Search from "./Search.svelte"
|
|
12
|
+
import IconAvatar from "../../Icon/IconAvatar.svelte"
|
|
13
|
+
|
|
14
|
+
export let primaryLabel = ""
|
|
15
|
+
export let primaryValue = null
|
|
16
|
+
export let id = null
|
|
17
|
+
export let placeholder = "Choose an option or type"
|
|
18
|
+
export let disabled = false
|
|
19
|
+
export let error = null
|
|
20
|
+
export let secondaryOptions = []
|
|
21
|
+
export let primaryOptions = []
|
|
22
|
+
export let secondaryFieldText = ""
|
|
23
|
+
export let secondaryFieldIcon = ""
|
|
24
|
+
export let secondaryFieldColour = ""
|
|
25
|
+
export let getPrimaryOptionValue = option => option
|
|
26
|
+
export let getPrimaryOptionColour = () => null
|
|
27
|
+
export let getPrimaryOptionIcon = () => null
|
|
28
|
+
export let getSecondaryOptionLabel = option => option
|
|
29
|
+
export let getSecondaryOptionValue = option => option
|
|
30
|
+
export let getSecondaryOptionColour = () => null
|
|
31
|
+
export let onSelectOption = () => {}
|
|
32
|
+
export let autoWidth = false
|
|
33
|
+
export let autocomplete = false
|
|
34
|
+
export let isOptionSelected = () => false
|
|
35
|
+
export let isPlaceholder = false
|
|
36
|
+
export let placeholderOption = null
|
|
37
|
+
export let showClearIcon = true
|
|
38
|
+
|
|
39
|
+
const dispatch = createEventDispatcher()
|
|
40
|
+
let primaryOpen = false
|
|
41
|
+
let secondaryOpen = false
|
|
42
|
+
let focus = false
|
|
43
|
+
let searchTerm = null
|
|
44
|
+
|
|
45
|
+
$: groupTitles = Object.keys(primaryOptions)
|
|
46
|
+
let iconData
|
|
47
|
+
|
|
48
|
+
const updateSearch = e => {
|
|
49
|
+
dispatch("search", e.detail)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const updateValue = newValue => {
|
|
53
|
+
dispatch("change", newValue)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const onClickSecondary = () => {
|
|
57
|
+
dispatch("click")
|
|
58
|
+
secondaryOpen = true
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const onPickPrimary = newValue => {
|
|
62
|
+
dispatch("pickprimary", newValue)
|
|
63
|
+
primaryOpen = false
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const onClearPrimary = () => {
|
|
67
|
+
dispatch("pickprimary", null)
|
|
68
|
+
primaryOpen = false
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const onPickSecondary = newValue => {
|
|
72
|
+
dispatch("picksecondary", newValue)
|
|
73
|
+
secondaryOpen = false
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const onBlur = event => {
|
|
77
|
+
focus = false
|
|
78
|
+
updateValue(event.target.value)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const onInput = event => {
|
|
82
|
+
updateValue(event.target.value)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const updateValueOnEnter = event => {
|
|
86
|
+
if (event.key === "Enter") {
|
|
87
|
+
updateValue(event.target.value)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<div
|
|
93
|
+
class="spectrum-InputGroup"
|
|
94
|
+
class:is-invalid={!!error}
|
|
95
|
+
class:is-disabled={disabled}
|
|
96
|
+
>
|
|
97
|
+
<div
|
|
98
|
+
class="spectrum-Textfield spectrum-InputGroup-textfield"
|
|
99
|
+
class:is-invalid={!!error}
|
|
100
|
+
class:is-disabled={disabled}
|
|
101
|
+
class:is-focused={focus}
|
|
102
|
+
class:is-full-width={!secondaryOptions.length}
|
|
103
|
+
>
|
|
104
|
+
{#if iconData}
|
|
105
|
+
<svg
|
|
106
|
+
width="16px"
|
|
107
|
+
height="16px"
|
|
108
|
+
class="spectrum-Icon iconPadding"
|
|
109
|
+
style="color: {iconData?.color}"
|
|
110
|
+
focusable="false"
|
|
111
|
+
>
|
|
112
|
+
<use xlink:href="#spectrum-icon-18-{iconData?.icon}" />
|
|
113
|
+
</svg>
|
|
114
|
+
{/if}
|
|
115
|
+
<input
|
|
116
|
+
{id}
|
|
117
|
+
on:click={() => (primaryOpen = true)}
|
|
118
|
+
on:blur
|
|
119
|
+
on:focus
|
|
120
|
+
on:input
|
|
121
|
+
on:keyup
|
|
122
|
+
on:blur={onBlur}
|
|
123
|
+
on:input={onInput}
|
|
124
|
+
on:keyup={updateValueOnEnter}
|
|
125
|
+
value={primaryLabel || ""}
|
|
126
|
+
placeholder={placeholder || ""}
|
|
127
|
+
{disabled}
|
|
128
|
+
readonly
|
|
129
|
+
class="spectrum-Textfield-input spectrum-InputGroup-input"
|
|
130
|
+
class:labelPadding={iconData}
|
|
131
|
+
class:open={primaryOpen}
|
|
132
|
+
/>
|
|
133
|
+
{#if primaryValue && showClearIcon}
|
|
134
|
+
<button
|
|
135
|
+
on:click={() => onClearPrimary()}
|
|
136
|
+
type="reset"
|
|
137
|
+
class="spectrum-ClearButton spectrum-Search-clearButton"
|
|
138
|
+
>
|
|
139
|
+
<svg
|
|
140
|
+
class="spectrum-Icon spectrum-UIIcon-Cross75"
|
|
141
|
+
focusable="false"
|
|
142
|
+
aria-hidden="true"
|
|
143
|
+
>
|
|
144
|
+
<use xlink:href="#spectrum-css-icon-Cross75" />
|
|
145
|
+
</svg>
|
|
146
|
+
</button>
|
|
147
|
+
{/if}
|
|
148
|
+
</div>
|
|
149
|
+
{#if primaryOpen}
|
|
150
|
+
<div
|
|
151
|
+
use:clickOutside={() => (primaryOpen = false)}
|
|
152
|
+
transition:fly|local={{ y: -20, duration: 200 }}
|
|
153
|
+
class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
|
|
154
|
+
class:auto-width={autoWidth}
|
|
155
|
+
class:is-full-width={!secondaryOptions.length}
|
|
156
|
+
>
|
|
157
|
+
{#if autocomplete}
|
|
158
|
+
<Search
|
|
159
|
+
value={searchTerm}
|
|
160
|
+
on:change={event => updateSearch(event)}
|
|
161
|
+
{disabled}
|
|
162
|
+
placeholder="Search"
|
|
163
|
+
/>
|
|
164
|
+
{/if}
|
|
165
|
+
|
|
166
|
+
<ul class="spectrum-Menu" role="listbox">
|
|
167
|
+
{#if placeholderOption}
|
|
168
|
+
<li
|
|
169
|
+
class="spectrum-Menu-item placeholder"
|
|
170
|
+
class:is-selected={isPlaceholder}
|
|
171
|
+
role="option"
|
|
172
|
+
aria-selected="true"
|
|
173
|
+
tabindex="0"
|
|
174
|
+
on:click={() => onSelectOption(null)}
|
|
175
|
+
>
|
|
176
|
+
<span class="spectrum-Menu-itemLabel">{placeholderOption}</span>
|
|
177
|
+
<svg
|
|
178
|
+
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
|
|
179
|
+
focusable="false"
|
|
180
|
+
aria-hidden="true"
|
|
181
|
+
>
|
|
182
|
+
<use xlink:href="#spectrum-css-icon-Checkmark100" />
|
|
183
|
+
</svg>
|
|
184
|
+
</li>
|
|
185
|
+
{/if}
|
|
186
|
+
{#each groupTitles as title}
|
|
187
|
+
<div class="spectrum-Menu-item title">
|
|
188
|
+
<Detail>{title}</Detail>
|
|
189
|
+
</div>
|
|
190
|
+
{#if primaryOptions}
|
|
191
|
+
{#each primaryOptions[title].data as option, idx}
|
|
192
|
+
<li
|
|
193
|
+
class="spectrum-Menu-item"
|
|
194
|
+
class:is-selected={isOptionSelected(
|
|
195
|
+
getPrimaryOptionValue(option, idx)
|
|
196
|
+
)}
|
|
197
|
+
role="option"
|
|
198
|
+
aria-selected="true"
|
|
199
|
+
tabindex="0"
|
|
200
|
+
on:click={() =>
|
|
201
|
+
onPickPrimary({
|
|
202
|
+
value: primaryOptions[title].getValue(option),
|
|
203
|
+
label: primaryOptions[title].getLabel(option),
|
|
204
|
+
})}
|
|
205
|
+
>
|
|
206
|
+
{#if primaryOptions[title].getIcon(option)}
|
|
207
|
+
<IconAvatar
|
|
208
|
+
size="S"
|
|
209
|
+
icon={primaryOptions[title].getIcon(option)}
|
|
210
|
+
background={primaryOptions[title].getColour(option)}
|
|
211
|
+
/>
|
|
212
|
+
{:else if getPrimaryOptionColour(option, idx)}
|
|
213
|
+
<span class="option-left">
|
|
214
|
+
<StatusLight
|
|
215
|
+
square
|
|
216
|
+
color={getPrimaryOptionColour(option, idx)}
|
|
217
|
+
/>
|
|
218
|
+
</span>
|
|
219
|
+
{/if}
|
|
220
|
+
<span class="spectrum-Menu-itemLabel">
|
|
221
|
+
<div
|
|
222
|
+
class="primary-text"
|
|
223
|
+
class:spacing-group={primaryOptions[title].getIcon(option)}
|
|
224
|
+
>
|
|
225
|
+
{primaryOptions[title].getLabel(option)}
|
|
226
|
+
<span />
|
|
227
|
+
</div>
|
|
228
|
+
<svg
|
|
229
|
+
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
|
|
230
|
+
focusable="false"
|
|
231
|
+
aria-hidden="true"
|
|
232
|
+
>
|
|
233
|
+
<use xlink:href="#spectrum-css-icon-Checkmark100" />
|
|
234
|
+
</svg>
|
|
235
|
+
{#if getPrimaryOptionIcon(option, idx) && getPrimaryOptionColour(option, idx)}
|
|
236
|
+
<span class="option-right">
|
|
237
|
+
<StatusLight
|
|
238
|
+
square
|
|
239
|
+
color={getPrimaryOptionColour(option, idx)}
|
|
240
|
+
/>
|
|
241
|
+
</span>
|
|
242
|
+
{/if}
|
|
243
|
+
</span>
|
|
244
|
+
</li>
|
|
245
|
+
{/each}
|
|
246
|
+
{/if}
|
|
247
|
+
{/each}
|
|
248
|
+
</ul>
|
|
249
|
+
</div>
|
|
250
|
+
{/if}
|
|
251
|
+
{#if secondaryOptions.length}
|
|
252
|
+
<div style="width: 30%">
|
|
253
|
+
<button
|
|
254
|
+
{id}
|
|
255
|
+
class="spectrum-Picker spectrum-Picker--sizeM override-borders"
|
|
256
|
+
{disabled}
|
|
257
|
+
class:is-open={secondaryOpen}
|
|
258
|
+
aria-haspopup="listbox"
|
|
259
|
+
on:mousedown={onClickSecondary}
|
|
260
|
+
>
|
|
261
|
+
{#if secondaryFieldIcon}
|
|
262
|
+
<span class="option-left">
|
|
263
|
+
<Icon name={secondaryFieldIcon} />
|
|
264
|
+
</span>
|
|
265
|
+
{:else if secondaryFieldColour}
|
|
266
|
+
<span class="option-left">
|
|
267
|
+
<StatusLight square color={secondaryFieldColour} />
|
|
268
|
+
</span>
|
|
269
|
+
{/if}
|
|
270
|
+
|
|
271
|
+
<span class:auto-width={autoWidth} class="spectrum-Picker-label">
|
|
272
|
+
{secondaryFieldText}
|
|
273
|
+
</span>
|
|
274
|
+
<svg
|
|
275
|
+
class="spectrum-Icon spectrum-UIIcon-ChevronDown100 spectrum-Picker-menuIcon"
|
|
276
|
+
focusable="false"
|
|
277
|
+
aria-hidden="true"
|
|
278
|
+
>
|
|
279
|
+
<use xlink:href="#spectrum-css-icon-Chevron100" />
|
|
280
|
+
</svg>
|
|
281
|
+
</button>
|
|
282
|
+
{#if secondaryOpen}
|
|
283
|
+
<div
|
|
284
|
+
use:clickOutside={() => (secondaryOpen = false)}
|
|
285
|
+
transition:fly|local={{ y: -20, duration: 200 }}
|
|
286
|
+
class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
|
|
287
|
+
style="width: 30%"
|
|
288
|
+
>
|
|
289
|
+
<ul class="spectrum-Menu" role="listbox">
|
|
290
|
+
{#each secondaryOptions as option, idx}
|
|
291
|
+
<li
|
|
292
|
+
class="spectrum-Menu-item"
|
|
293
|
+
class:is-selected={isOptionSelected(
|
|
294
|
+
getSecondaryOptionValue(option, idx)
|
|
295
|
+
)}
|
|
296
|
+
role="option"
|
|
297
|
+
aria-selected="true"
|
|
298
|
+
tabindex="0"
|
|
299
|
+
on:click={() =>
|
|
300
|
+
onPickSecondary(getSecondaryOptionValue(option, idx))}
|
|
301
|
+
>
|
|
302
|
+
{#if getSecondaryOptionColour(option, idx)}
|
|
303
|
+
<span class="option-left">
|
|
304
|
+
<StatusLight
|
|
305
|
+
square
|
|
306
|
+
color={getSecondaryOptionColour(option, idx)}
|
|
307
|
+
/>
|
|
308
|
+
</span>
|
|
309
|
+
{/if}
|
|
310
|
+
|
|
311
|
+
<span class="spectrum-Menu-itemLabel">
|
|
312
|
+
{getSecondaryOptionLabel(option, idx)}
|
|
313
|
+
</span>
|
|
314
|
+
<svg
|
|
315
|
+
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
|
|
316
|
+
focusable="false"
|
|
317
|
+
aria-hidden="true"
|
|
318
|
+
>
|
|
319
|
+
<use xlink:href="#spectrum-css-icon-Checkmark100" />
|
|
320
|
+
</svg>
|
|
321
|
+
</li>
|
|
322
|
+
{/each}
|
|
323
|
+
</ul>
|
|
324
|
+
</div>
|
|
325
|
+
{/if}
|
|
326
|
+
</div>
|
|
327
|
+
{/if}
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<style>
|
|
331
|
+
.primary-text {
|
|
332
|
+
white-space: nowrap;
|
|
333
|
+
overflow: hidden;
|
|
334
|
+
text-overflow: ellipsis;
|
|
335
|
+
}
|
|
336
|
+
.spacing-group {
|
|
337
|
+
margin-left: var(--spacing-m);
|
|
338
|
+
}
|
|
339
|
+
.spectrum-InputGroup {
|
|
340
|
+
min-width: 0;
|
|
341
|
+
width: 100%;
|
|
342
|
+
}
|
|
343
|
+
.spectrum-InputGroup :global(.spectrum-Search-input) {
|
|
344
|
+
border: none;
|
|
345
|
+
border-bottom: 1px solid var(--spectrum-global-color-gray-300);
|
|
346
|
+
border-bottom-left-radius: 0;
|
|
347
|
+
border-bottom-right-radius: 0;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.override-borders {
|
|
351
|
+
border-top-left-radius: 0px;
|
|
352
|
+
border-bottom-left-radius: 0px;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.spectrum-Popover {
|
|
356
|
+
max-height: 240px;
|
|
357
|
+
z-index: 999;
|
|
358
|
+
top: 100%;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.option-left {
|
|
362
|
+
padding-right: 8px;
|
|
363
|
+
}
|
|
364
|
+
.option-right {
|
|
365
|
+
padding-left: 8px;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.iconPadding {
|
|
369
|
+
position: absolute;
|
|
370
|
+
top: 50%;
|
|
371
|
+
left: 10px;
|
|
372
|
+
transform: translateY(-50%);
|
|
373
|
+
color: silver;
|
|
374
|
+
margin-right: 10px;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
.labelPadding {
|
|
378
|
+
padding-left: calc(1em + 10px + 8px);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.spectrum-Textfield.spectrum-InputGroup-textfield {
|
|
382
|
+
width: 70%;
|
|
383
|
+
}
|
|
384
|
+
.spectrum-Textfield.spectrum-InputGroup-textfield.is-full-width {
|
|
385
|
+
width: 100%;
|
|
386
|
+
}
|
|
387
|
+
.spectrum-Textfield.spectrum-InputGroup-textfield.is-full-width input {
|
|
388
|
+
border-right-width: thin;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.spectrum-Popover.spectrum-Popover--bottom.spectrum-Picker-popover.is-open {
|
|
392
|
+
width: 70%;
|
|
393
|
+
}
|
|
394
|
+
.spectrum-Popover.spectrum-Popover--bottom.spectrum-Picker-popover.is-open.is-full-width {
|
|
395
|
+
width: 100%;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.spectrum-Search-clearButton {
|
|
399
|
+
position: absolute;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/* Fix focus borders to show only when opened */
|
|
403
|
+
.spectrum-Textfield-input {
|
|
404
|
+
border-color: var(--spectrum-global-color-gray-400) !important;
|
|
405
|
+
border-right-width: 1px;
|
|
406
|
+
}
|
|
407
|
+
.spectrum-Textfield-input.open {
|
|
408
|
+
border-color: var(--spectrum-global-color-blue-400) !important;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/* Fix being able to hover and select titles */
|
|
412
|
+
.spectrum-Menu-item.title {
|
|
413
|
+
pointer-events: none;
|
|
414
|
+
}
|
|
415
|
+
</style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/fieldgroup/dist/index-vars.css"
|
|
3
|
+
import "@spectrum-css/radio/dist/index-vars.css"
|
|
4
|
+
import { createEventDispatcher } from "svelte"
|
|
5
|
+
|
|
6
|
+
export let direction = "vertical"
|
|
7
|
+
export let value = null
|
|
8
|
+
export let options = []
|
|
9
|
+
export let error = null
|
|
10
|
+
export let disabled = false
|
|
11
|
+
export let getOptionLabel = option => option
|
|
12
|
+
export let getOptionValue = option => option
|
|
13
|
+
export let getOptionTitle = option => option
|
|
14
|
+
|
|
15
|
+
const dispatch = createEventDispatcher()
|
|
16
|
+
const onChange = e => dispatch("change", e.target.value)
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class={`spectrum-FieldGroup spectrum-FieldGroup--${direction}`}>
|
|
20
|
+
{#if options && Array.isArray(options)}
|
|
21
|
+
{#each options as option}
|
|
22
|
+
<div
|
|
23
|
+
title={getOptionTitle(option)}
|
|
24
|
+
class="spectrum-Radio spectrum-FieldGroup-item spectrum-Radio--emphasized"
|
|
25
|
+
class:is-invalid={!!error}
|
|
26
|
+
>
|
|
27
|
+
<input
|
|
28
|
+
on:change={onChange}
|
|
29
|
+
bind:group={value}
|
|
30
|
+
value={getOptionValue(option)}
|
|
31
|
+
type="radio"
|
|
32
|
+
class="spectrum-Radio-input"
|
|
33
|
+
{disabled}
|
|
34
|
+
/>
|
|
35
|
+
<span class="spectrum-Radio-button" />
|
|
36
|
+
<label for="" class="spectrum-Radio-label">
|
|
37
|
+
{getOptionLabel(option)}
|
|
38
|
+
</label>
|
|
39
|
+
</div>
|
|
40
|
+
{/each}
|
|
41
|
+
{/if}
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<style>
|
|
45
|
+
.spectrum-Radio-input {
|
|
46
|
+
opacity: 0;
|
|
47
|
+
}
|
|
48
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import MarkdownEditor from "../../Markdown/MarkdownEditor.svelte"
|
|
3
|
+
|
|
4
|
+
export let value = ""
|
|
5
|
+
export let placeholder = null
|
|
6
|
+
export let disabled = false
|
|
7
|
+
export let error = null
|
|
8
|
+
export let height = null
|
|
9
|
+
export let id = null
|
|
10
|
+
export let fullScreenOffset = null
|
|
11
|
+
export let easyMDEOptions = null
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div class:error>
|
|
15
|
+
<MarkdownEditor
|
|
16
|
+
{value}
|
|
17
|
+
{placeholder}
|
|
18
|
+
{height}
|
|
19
|
+
{id}
|
|
20
|
+
{fullScreenOffset}
|
|
21
|
+
{disabled}
|
|
22
|
+
{easyMDEOptions}
|
|
23
|
+
on:change
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<style>
|
|
28
|
+
.error :global(.EasyMDEContainer .editor-toolbar) {
|
|
29
|
+
border-top-color: var(--spectrum-semantic-negative-color-default);
|
|
30
|
+
border-left-color: var(--spectrum-semantic-negative-color-default);
|
|
31
|
+
border-right-color: var(--spectrum-semantic-negative-color-default);
|
|
32
|
+
}
|
|
33
|
+
.error :global(.EasyMDEContainer .CodeMirror) {
|
|
34
|
+
border-bottom-color: var(--spectrum-semantic-negative-color-default);
|
|
35
|
+
border-left-color: var(--spectrum-semantic-negative-color-default);
|
|
36
|
+
border-right-color: var(--spectrum-semantic-negative-color-default);
|
|
37
|
+
}
|
|
38
|
+
.error :global(.EasyMDEContainer .editor-preview-side) {
|
|
39
|
+
border-bottom-color: var(--spectrum-semantic-negative-color-default);
|
|
40
|
+
border-right-color: var(--spectrum-semantic-negative-color-default);
|
|
41
|
+
}
|
|
42
|
+
</style>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/search/dist/index-vars.css"
|
|
3
|
+
import { createEventDispatcher } from "svelte"
|
|
4
|
+
|
|
5
|
+
export let value = null
|
|
6
|
+
export let placeholder = null
|
|
7
|
+
export let disabled = false
|
|
8
|
+
export let id = null
|
|
9
|
+
export let updateOnChange = true
|
|
10
|
+
export let quiet = false
|
|
11
|
+
export let inputRef
|
|
12
|
+
|
|
13
|
+
const dispatch = createEventDispatcher()
|
|
14
|
+
let focus = false
|
|
15
|
+
|
|
16
|
+
const updateValue = value => {
|
|
17
|
+
dispatch("change", value)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const onFocus = () => {
|
|
21
|
+
focus = true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const onBlur = event => {
|
|
25
|
+
focus = false
|
|
26
|
+
updateValue(event.target.value)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const onInput = event => {
|
|
30
|
+
if (!updateOnChange) {
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
updateValue(event.target.value)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const updateValueOnEnter = event => {
|
|
37
|
+
if (event.key === "Enter") {
|
|
38
|
+
updateValue(event.target.value)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div class="spectrum-Search" class:is-disabled={disabled}>
|
|
44
|
+
<div
|
|
45
|
+
class="spectrum-Textfield"
|
|
46
|
+
class:spectrum-Textfield--quiet={quiet}
|
|
47
|
+
class:is-focused={focus}
|
|
48
|
+
class:is-disabled={disabled}
|
|
49
|
+
>
|
|
50
|
+
<svg
|
|
51
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-icon"
|
|
52
|
+
focusable="false"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
>
|
|
55
|
+
<use xlink:href="#spectrum-icon-18-Magnify" />
|
|
56
|
+
</svg>
|
|
57
|
+
<input
|
|
58
|
+
{disabled}
|
|
59
|
+
{id}
|
|
60
|
+
value={value || ""}
|
|
61
|
+
placeholder={placeholder || ""}
|
|
62
|
+
on:click
|
|
63
|
+
on:blur
|
|
64
|
+
on:focus
|
|
65
|
+
on:input
|
|
66
|
+
on:blur={onBlur}
|
|
67
|
+
on:focus={onFocus}
|
|
68
|
+
on:input={onInput}
|
|
69
|
+
on:keyup={updateValueOnEnter}
|
|
70
|
+
type="search"
|
|
71
|
+
class="spectrum-Textfield-input spectrum-Search-input"
|
|
72
|
+
autocomplete="off"
|
|
73
|
+
bind:this={inputRef}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
<button
|
|
77
|
+
on:click={() => updateValue("")}
|
|
78
|
+
type="reset"
|
|
79
|
+
class="spectrum-ClearButton spectrum-Search-clearButton"
|
|
80
|
+
>
|
|
81
|
+
<svg
|
|
82
|
+
class="spectrum-Icon spectrum-UIIcon-Cross75"
|
|
83
|
+
focusable="false"
|
|
84
|
+
aria-hidden="true"
|
|
85
|
+
>
|
|
86
|
+
<use xlink:href="#spectrum-css-icon-Cross75" />
|
|
87
|
+
</svg>
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<style>
|
|
92
|
+
.spectrum-Search,
|
|
93
|
+
.spectrum-Textfield {
|
|
94
|
+
width: 100%;
|
|
95
|
+
}
|
|
96
|
+
.spectrum-Search-input {
|
|
97
|
+
padding-right: 24px;
|
|
98
|
+
}
|
|
99
|
+
.is-disabled {
|
|
100
|
+
pointer-events: none;
|
|
101
|
+
}
|
|
102
|
+
.spectrum-Search-clearButton {
|
|
103
|
+
position: absolute;
|
|
104
|
+
}
|
|
105
|
+
</style>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte"
|
|
3
|
+
import Picker from "./Picker.svelte"
|
|
4
|
+
|
|
5
|
+
export let value = null
|
|
6
|
+
export let id = null
|
|
7
|
+
export let placeholder = "Choose an option"
|
|
8
|
+
export let disabled = false
|
|
9
|
+
export let error = null
|
|
10
|
+
export let options = []
|
|
11
|
+
export let getOptionLabel = option => option
|
|
12
|
+
export let getOptionValue = option => option
|
|
13
|
+
export let getOptionIcon = () => null
|
|
14
|
+
export let getOptionColour = () => null
|
|
15
|
+
export let readonly = false
|
|
16
|
+
export let quiet = false
|
|
17
|
+
export let autoWidth = false
|
|
18
|
+
export let autocomplete = false
|
|
19
|
+
export let sort = false
|
|
20
|
+
const dispatch = createEventDispatcher()
|
|
21
|
+
let open = false
|
|
22
|
+
$: fieldText = getFieldText(value, options, placeholder)
|
|
23
|
+
$: fieldIcon = getFieldAttribute(getOptionIcon, value, options)
|
|
24
|
+
$: fieldColour = getFieldAttribute(getOptionColour, value, options)
|
|
25
|
+
|
|
26
|
+
const getFieldAttribute = (getAttribute, value, options) => {
|
|
27
|
+
// Wait for options to load if there is a value but no options
|
|
28
|
+
if (!options?.length) {
|
|
29
|
+
return ""
|
|
30
|
+
}
|
|
31
|
+
const index = options.findIndex(
|
|
32
|
+
(option, idx) => getOptionValue(option, idx) === value
|
|
33
|
+
)
|
|
34
|
+
return index !== -1 ? getAttribute(options[index], index) : null
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const getFieldText = (value, options, placeholder) => {
|
|
38
|
+
// Always use placeholder if no value
|
|
39
|
+
if (value == null || value === "") {
|
|
40
|
+
return placeholder || "Choose an option"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return getFieldAttribute(getOptionLabel, value, options)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const selectOption = value => {
|
|
47
|
+
dispatch("change", value)
|
|
48
|
+
open = false
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<Picker
|
|
53
|
+
on:click
|
|
54
|
+
bind:open
|
|
55
|
+
{quiet}
|
|
56
|
+
{id}
|
|
57
|
+
{error}
|
|
58
|
+
{disabled}
|
|
59
|
+
{readonly}
|
|
60
|
+
{fieldText}
|
|
61
|
+
{fieldIcon}
|
|
62
|
+
{fieldColour}
|
|
63
|
+
{options}
|
|
64
|
+
{autoWidth}
|
|
65
|
+
{getOptionLabel}
|
|
66
|
+
{getOptionValue}
|
|
67
|
+
{getOptionIcon}
|
|
68
|
+
{getOptionColour}
|
|
69
|
+
{autocomplete}
|
|
70
|
+
{sort}
|
|
71
|
+
isPlaceholder={value == null || value === ""}
|
|
72
|
+
placeholderOption={placeholder}
|
|
73
|
+
isOptionSelected={option => option === value}
|
|
74
|
+
onSelectOption={selectOption}
|
|
75
|
+
/>
|