@budibase/bbui 2.2.26 → 2.2.27
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.es.js +3 -3
- package/dist/bbui.es.js.map +1 -1
- package/package.json +4 -3
- package/src/Accordion/Accordion.svelte +58 -0
- package/src/ActionButton/ActionButton.svelte +2 -3
- package/src/ActionMenu/ActionMenu.svelte +1 -2
- package/src/Actions/click_outside.js +28 -9
- package/src/Actions/position_dropdown.js +85 -53
- package/src/Avatar/Avatar.svelte +1 -0
- package/src/Badge/Badge.svelte +13 -0
- package/src/Button/Button.svelte +8 -4
- package/src/Drawer/DrawerContent.svelte +0 -1
- package/src/FancyForm/FancyButton.svelte +30 -0
- package/src/FancyForm/FancyButtonRadio.svelte +70 -0
- package/src/FancyForm/FancyCheckbox.svelte +53 -0
- package/src/FancyForm/FancyField.svelte +126 -0
- package/src/FancyForm/FancyFieldLabel.svelte +25 -0
- package/src/FancyForm/FancyForm.svelte +40 -0
- package/src/FancyForm/FancyInput.svelte +77 -0
- package/src/FancyForm/FancySelect.svelte +147 -0
- package/src/FancyForm/index.js +6 -0
- package/src/Form/Core/DatePicker.svelte +1 -1
- package/src/Form/Core/Dropzone.svelte +71 -66
- package/src/Form/Core/EnvDropdown.svelte +276 -0
- package/src/Form/Core/Picker.svelte +141 -124
- package/src/Form/Core/Select.svelte +3 -0
- package/src/Form/Core/Switch.svelte +0 -2
- package/src/Form/Core/TextField.svelte +0 -6
- package/src/Form/EnvDropdown.svelte +50 -0
- package/src/Form/Input.svelte +0 -2
- package/src/Form/InputDropdown.svelte +0 -2
- package/src/Form/PickerDropdown.svelte +0 -2
- package/src/Form/Toggle.svelte +1 -2
- package/src/Icon/IconAvatar.svelte +3 -0
- package/src/InlineAlert/InlineAlert.svelte +1 -0
- package/src/Label/Label.svelte +1 -0
- package/src/Layout/Page.svelte +82 -13
- package/src/Link/Link.svelte +4 -1
- package/src/List/ListItem.svelte +6 -3
- package/src/Menu/Item.svelte +0 -2
- package/src/Modal/CustomContent.svelte +0 -1
- package/src/Modal/Modal.svench +0 -1
- package/src/Modal/ModalContent.svelte +4 -4
- package/src/Modal/QuizModal.svelte +0 -1
- package/src/Popover/Popover.svelte +35 -31
- package/src/Popover/Popover.svench +0 -1
- package/src/SideNavigation/Item.svelte +0 -2
- package/src/Table/RelationshipRenderer.svelte +3 -8
- package/src/Table/StringRenderer.svelte +9 -1
- package/src/Table/Table.svelte +30 -19
- package/src/Tabs/Tab.svelte +5 -5
- package/src/Tags/Tag.svelte +1 -1
- package/src/Tags/Tags.svelte +10 -0
- package/src/Typography/Heading.svelte +6 -0
- package/src/bbui.css +7 -3
- package/src/context.js +1 -0
- package/src/index.js +5 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/textfield/dist/index-vars.css"
|
|
3
|
+
import { createEventDispatcher, onMount } from "svelte"
|
|
4
|
+
import clickOutside from "../../Actions/click_outside"
|
|
5
|
+
import Divider from "../../Divider/Divider.svelte"
|
|
6
|
+
|
|
7
|
+
export let value = null
|
|
8
|
+
export let placeholder = null
|
|
9
|
+
export let type = "text"
|
|
10
|
+
export let disabled = false
|
|
11
|
+
export let id = null
|
|
12
|
+
export let readonly = false
|
|
13
|
+
export let updateOnChange = true
|
|
14
|
+
export let align
|
|
15
|
+
export let autofocus = false
|
|
16
|
+
export let variables
|
|
17
|
+
export let showModal
|
|
18
|
+
export let environmentVariablesEnabled
|
|
19
|
+
export let handleUpgradePanel
|
|
20
|
+
const dispatch = createEventDispatcher()
|
|
21
|
+
|
|
22
|
+
let field
|
|
23
|
+
let focus = false
|
|
24
|
+
let iconFocused = false
|
|
25
|
+
let open = false
|
|
26
|
+
|
|
27
|
+
//eslint-disable-next-line
|
|
28
|
+
const STRIP_NAME_REGEX = /(?<=\.)(.*?)(?=\ })/g
|
|
29
|
+
|
|
30
|
+
// Strips the name out of the value which is {{ env.Variable }} resulting in an array like ["Variable"]
|
|
31
|
+
$: hbsValue = String(value)?.match(STRIP_NAME_REGEX) || []
|
|
32
|
+
|
|
33
|
+
const updateValue = newValue => {
|
|
34
|
+
if (readonly) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
if (type === "number") {
|
|
38
|
+
const float = parseFloat(newValue)
|
|
39
|
+
newValue = isNaN(float) ? null : float
|
|
40
|
+
}
|
|
41
|
+
dispatch("change", newValue)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const onFocus = () => {
|
|
45
|
+
if (readonly) {
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
focus = true
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const onBlur = event => {
|
|
52
|
+
if (readonly) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
focus = false
|
|
56
|
+
updateValue(event.target.value)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const onInput = event => {
|
|
60
|
+
if (readonly || !updateOnChange) {
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
updateValue(event.target.value)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleOutsideClick = event => {
|
|
67
|
+
if (open) {
|
|
68
|
+
event.stopPropagation()
|
|
69
|
+
open = false
|
|
70
|
+
focus = false
|
|
71
|
+
iconFocused = false
|
|
72
|
+
dispatch("closed")
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const handleVarSelect = variable => {
|
|
77
|
+
open = false
|
|
78
|
+
focus = false
|
|
79
|
+
iconFocused = false
|
|
80
|
+
updateValue(`{{ env.${variable} }}`)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onMount(() => {
|
|
84
|
+
focus = autofocus
|
|
85
|
+
if (focus) field.focus()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
function removeVariable() {
|
|
89
|
+
updateValue("")
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function openPopover() {
|
|
93
|
+
open = true
|
|
94
|
+
focus = true
|
|
95
|
+
iconFocused = true
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
<div class="spectrum-InputGroup">
|
|
100
|
+
<div
|
|
101
|
+
class:is-disabled={disabled || hbsValue.length}
|
|
102
|
+
class:is-focused={focus}
|
|
103
|
+
class="spectrum-Textfield"
|
|
104
|
+
>
|
|
105
|
+
<svg
|
|
106
|
+
class:close-color={hbsValue.length}
|
|
107
|
+
class:focused={iconFocused}
|
|
108
|
+
class="hoverable icon-position spectrum-Icon spectrum-Icon--sizeS spectrum-Textfield-validationIcon"
|
|
109
|
+
focusable="false"
|
|
110
|
+
aria-hidden="true"
|
|
111
|
+
on:click={() => {
|
|
112
|
+
hbsValue.length ? removeVariable() : openPopover()
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
<use
|
|
116
|
+
xlink:href={`#spectrum-icon-18-${!hbsValue.length ? "Key" : "Close"}`}
|
|
117
|
+
/>
|
|
118
|
+
</svg>
|
|
119
|
+
|
|
120
|
+
<input
|
|
121
|
+
bind:this={field}
|
|
122
|
+
disabled={hbsValue.length || disabled}
|
|
123
|
+
{readonly}
|
|
124
|
+
{id}
|
|
125
|
+
value={hbsValue.length ? `{{ ${hbsValue[0]} }}` : value}
|
|
126
|
+
placeholder={placeholder || ""}
|
|
127
|
+
on:click
|
|
128
|
+
on:blur
|
|
129
|
+
on:focus
|
|
130
|
+
on:input
|
|
131
|
+
on:keyup
|
|
132
|
+
on:blur={onBlur}
|
|
133
|
+
on:focus={onFocus}
|
|
134
|
+
on:input={onInput}
|
|
135
|
+
type={hbsValue.length ? "text" : type}
|
|
136
|
+
style={align ? `text-align: ${align};` : ""}
|
|
137
|
+
class="spectrum-Textfield-input"
|
|
138
|
+
inputmode={type === "number" ? "decimal" : "text"}
|
|
139
|
+
/>
|
|
140
|
+
</div>
|
|
141
|
+
{#if open}
|
|
142
|
+
<div
|
|
143
|
+
use:clickOutside={handleOutsideClick}
|
|
144
|
+
class="spectrum-Popover spectrum-Popover--bottom spectrum-Picker-popover is-open"
|
|
145
|
+
>
|
|
146
|
+
<ul class="spectrum-Menu" role="listbox">
|
|
147
|
+
{#if !environmentVariablesEnabled}
|
|
148
|
+
<div class="no-variables-text primary-text">
|
|
149
|
+
Upgrade your plan to get environment variables
|
|
150
|
+
</div>
|
|
151
|
+
{:else if variables.length}
|
|
152
|
+
<div style="max-height: 100px">
|
|
153
|
+
{#each variables as variable, idx}
|
|
154
|
+
<li
|
|
155
|
+
class="spectrum-Menu-item"
|
|
156
|
+
role="option"
|
|
157
|
+
aria-selected="true"
|
|
158
|
+
tabindex="0"
|
|
159
|
+
on:click={() => handleVarSelect(variable.name)}
|
|
160
|
+
>
|
|
161
|
+
<span class="spectrum-Menu-itemLabel">
|
|
162
|
+
<div class="primary-text">
|
|
163
|
+
{variable.name}
|
|
164
|
+
<span />
|
|
165
|
+
</div>
|
|
166
|
+
<svg
|
|
167
|
+
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
|
|
168
|
+
focusable="false"
|
|
169
|
+
aria-hidden="true"
|
|
170
|
+
>
|
|
171
|
+
<use xlink:href="#spectrum-css-icon-Checkmark100" />
|
|
172
|
+
</svg>
|
|
173
|
+
</span>
|
|
174
|
+
</li>
|
|
175
|
+
{/each}
|
|
176
|
+
</div>
|
|
177
|
+
{:else}
|
|
178
|
+
<div class="no-variables-text primary-text">
|
|
179
|
+
You don't have any environment variables yet
|
|
180
|
+
</div>
|
|
181
|
+
{/if}
|
|
182
|
+
</ul>
|
|
183
|
+
<Divider noMargin />
|
|
184
|
+
{#if environmentVariablesEnabled}
|
|
185
|
+
<div on:click={() => showModal()} class="add-variable">
|
|
186
|
+
<svg
|
|
187
|
+
class="spectrum-Icon spectrum-Icon--sizeS "
|
|
188
|
+
focusable="false"
|
|
189
|
+
aria-hidden="true"
|
|
190
|
+
>
|
|
191
|
+
<use xlink:href="#spectrum-icon-18-Add" />
|
|
192
|
+
</svg>
|
|
193
|
+
<div class="primary-text">Add Variable</div>
|
|
194
|
+
</div>
|
|
195
|
+
{:else}
|
|
196
|
+
<div on:click={() => handleUpgradePanel()} class="add-variable">
|
|
197
|
+
<svg
|
|
198
|
+
class="spectrum-Icon spectrum-Icon--sizeS "
|
|
199
|
+
focusable="false"
|
|
200
|
+
aria-hidden="true"
|
|
201
|
+
>
|
|
202
|
+
<use xlink:href="#spectrum-icon-18-ArrowUp" />
|
|
203
|
+
</svg>
|
|
204
|
+
<div class="primary-text">Upgrade plan</div>
|
|
205
|
+
</div>
|
|
206
|
+
{/if}
|
|
207
|
+
</div>
|
|
208
|
+
{/if}
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<style>
|
|
212
|
+
.spectrum-Textfield {
|
|
213
|
+
width: 100%;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.icon-position {
|
|
217
|
+
position: absolute;
|
|
218
|
+
top: 25%;
|
|
219
|
+
right: 2%;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.hoverable:hover {
|
|
223
|
+
cursor: pointer;
|
|
224
|
+
color: var(--spectrum-global-color-blue-400);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.primary-text {
|
|
228
|
+
white-space: nowrap;
|
|
229
|
+
overflow: hidden;
|
|
230
|
+
text-overflow: ellipsis;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.spectrum-InputGroup {
|
|
234
|
+
min-width: 0;
|
|
235
|
+
width: 100%;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.spectrum-Popover {
|
|
239
|
+
max-height: 240px;
|
|
240
|
+
z-index: 999;
|
|
241
|
+
top: 100%;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.spectrum-Popover.spectrum-Popover--bottom.spectrum-Picker-popover.is-open {
|
|
245
|
+
width: 100%;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.no-variables-text {
|
|
249
|
+
padding: var(--spacing-m);
|
|
250
|
+
color: var(--spectrum-global-color-gray-600);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.add-variable {
|
|
254
|
+
display: flex;
|
|
255
|
+
padding: var(--spacing-m) 0 var(--spacing-m) var(--spacing-m);
|
|
256
|
+
align-items: center;
|
|
257
|
+
gap: var(--spacing-s);
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.focused {
|
|
262
|
+
color: var(--spectrum-global-color-blue-400);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.add-variable:hover {
|
|
266
|
+
background: var(--grey-1);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.close-color {
|
|
270
|
+
color: var(--spectrum-global-color-gray-900) !important;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.close-color:hover {
|
|
274
|
+
color: var(--spectrum-global-color-blue-400) !important;
|
|
275
|
+
}
|
|
276
|
+
</style>
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import "@spectrum-css/picker/dist/index-vars.css"
|
|
3
3
|
import "@spectrum-css/popover/dist/index-vars.css"
|
|
4
4
|
import "@spectrum-css/menu/dist/index-vars.css"
|
|
5
|
-
import { fly } from "svelte/transition"
|
|
6
5
|
import { createEventDispatcher } from "svelte"
|
|
7
6
|
import clickOutside from "../../Actions/click_outside"
|
|
8
7
|
import Search from "./Search.svelte"
|
|
9
8
|
import Icon from "../../Icon/Icon.svelte"
|
|
10
9
|
import StatusLight from "../../StatusLight/StatusLight.svelte"
|
|
10
|
+
import Popover from "../../Popover/Popover.svelte"
|
|
11
11
|
|
|
12
12
|
export let id = null
|
|
13
13
|
export let disabled = false
|
|
@@ -33,7 +33,10 @@
|
|
|
33
33
|
export let sort = false
|
|
34
34
|
|
|
35
35
|
const dispatch = createEventDispatcher()
|
|
36
|
+
|
|
36
37
|
let searchTerm = null
|
|
38
|
+
let button
|
|
39
|
+
let popover
|
|
37
40
|
|
|
38
41
|
$: sortedOptions = getSortedOptions(options, getOptionLabel, sort)
|
|
39
42
|
$: filteredOptions = getFilteredOptions(
|
|
@@ -42,7 +45,9 @@
|
|
|
42
45
|
getOptionLabel
|
|
43
46
|
)
|
|
44
47
|
|
|
45
|
-
const onClick =
|
|
48
|
+
const onClick = e => {
|
|
49
|
+
e.preventDefault()
|
|
50
|
+
e.stopPropagation()
|
|
46
51
|
dispatch("click")
|
|
47
52
|
if (readonly) {
|
|
48
53
|
return
|
|
@@ -76,77 +81,119 @@
|
|
|
76
81
|
}
|
|
77
82
|
</script>
|
|
78
83
|
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</span>
|
|
94
|
-
{/if}
|
|
95
|
-
{#if fieldColour}
|
|
96
|
-
<span class="option-extra">
|
|
97
|
-
<StatusLight square color={fieldColour} />
|
|
98
|
-
</span>
|
|
99
|
-
{/if}
|
|
100
|
-
<span
|
|
101
|
-
class="spectrum-Picker-label"
|
|
102
|
-
class:is-placeholder={isPlaceholder}
|
|
103
|
-
class:auto-width={autoWidth}
|
|
104
|
-
>
|
|
105
|
-
{fieldText}
|
|
84
|
+
<button
|
|
85
|
+
{id}
|
|
86
|
+
class="spectrum-Picker spectrum-Picker--sizeM"
|
|
87
|
+
class:spectrum-Picker--quiet={quiet}
|
|
88
|
+
{disabled}
|
|
89
|
+
class:is-invalid={!!error}
|
|
90
|
+
class:is-open={open}
|
|
91
|
+
aria-haspopup="listbox"
|
|
92
|
+
on:click={onClick}
|
|
93
|
+
bind:this={button}
|
|
94
|
+
>
|
|
95
|
+
{#if fieldIcon}
|
|
96
|
+
<span class="option-extra icon">
|
|
97
|
+
<Icon size="S" name={fieldIcon} />
|
|
106
98
|
</span>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{
|
|
99
|
+
{/if}
|
|
100
|
+
{#if fieldColour}
|
|
101
|
+
<span class="option-extra">
|
|
102
|
+
<StatusLight square color={fieldColour} />
|
|
103
|
+
</span>
|
|
104
|
+
{/if}
|
|
105
|
+
<span
|
|
106
|
+
class="spectrum-Picker-label"
|
|
107
|
+
class:is-placeholder={isPlaceholder}
|
|
108
|
+
class:auto-width={autoWidth}
|
|
109
|
+
>
|
|
110
|
+
{fieldText}
|
|
111
|
+
</span>
|
|
112
|
+
{#if error}
|
|
117
113
|
<svg
|
|
118
|
-
class="spectrum-Icon spectrum-
|
|
114
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Picker-validationIcon"
|
|
119
115
|
focusable="false"
|
|
120
116
|
aria-hidden="true"
|
|
117
|
+
aria-label="Folder"
|
|
121
118
|
>
|
|
122
|
-
<use xlink:href="#spectrum-
|
|
119
|
+
<use xlink:href="#spectrum-icon-18-Alert" />
|
|
123
120
|
</svg>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
121
|
+
{/if}
|
|
122
|
+
<svg
|
|
123
|
+
class="spectrum-Icon spectrum-UIIcon-ChevronDown100 spectrum-Picker-menuIcon"
|
|
124
|
+
focusable="false"
|
|
125
|
+
aria-hidden="true"
|
|
126
|
+
>
|
|
127
|
+
<use xlink:href="#spectrum-css-icon-Chevron100" />
|
|
128
|
+
</svg>
|
|
129
|
+
</button>
|
|
130
|
+
|
|
131
|
+
<Popover
|
|
132
|
+
anchor={button}
|
|
133
|
+
align="left"
|
|
134
|
+
bind:this={popover}
|
|
135
|
+
{open}
|
|
136
|
+
on:close={() => (open = false)}
|
|
137
|
+
useAnchorWidth={!autoWidth}
|
|
138
|
+
maxWidth={autoWidth ? 400 : null}
|
|
139
|
+
>
|
|
140
|
+
<div
|
|
141
|
+
class="popover-content"
|
|
142
|
+
class:auto-width={autoWidth}
|
|
143
|
+
use:clickOutside={() => (open = false)}
|
|
144
|
+
>
|
|
145
|
+
{#if autocomplete}
|
|
146
|
+
<Search
|
|
147
|
+
value={searchTerm}
|
|
148
|
+
on:change={event => (searchTerm = event.detail)}
|
|
149
|
+
{disabled}
|
|
150
|
+
placeholder="Search"
|
|
151
|
+
/>
|
|
152
|
+
{/if}
|
|
153
|
+
<ul class="spectrum-Menu" role="listbox">
|
|
154
|
+
{#if placeholderOption}
|
|
155
|
+
<li
|
|
156
|
+
class="spectrum-Menu-item placeholder"
|
|
157
|
+
class:is-selected={isPlaceholder}
|
|
158
|
+
role="option"
|
|
159
|
+
aria-selected="true"
|
|
160
|
+
tabindex="0"
|
|
161
|
+
on:click={() => onSelectOption(null)}
|
|
162
|
+
>
|
|
163
|
+
<span class="spectrum-Menu-itemLabel">{placeholderOption}</span>
|
|
164
|
+
<svg
|
|
165
|
+
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
|
|
166
|
+
focusable="false"
|
|
167
|
+
aria-hidden="true"
|
|
168
|
+
>
|
|
169
|
+
<use xlink:href="#spectrum-css-icon-Checkmark100" />
|
|
170
|
+
</svg>
|
|
171
|
+
</li>
|
|
138
172
|
{/if}
|
|
139
|
-
|
|
140
|
-
{#
|
|
173
|
+
{#if filteredOptions.length}
|
|
174
|
+
{#each filteredOptions as option, idx}
|
|
141
175
|
<li
|
|
142
|
-
class="spectrum-Menu-item
|
|
143
|
-
class:is-selected={
|
|
176
|
+
class="spectrum-Menu-item"
|
|
177
|
+
class:is-selected={isOptionSelected(getOptionValue(option, idx))}
|
|
144
178
|
role="option"
|
|
145
179
|
aria-selected="true"
|
|
146
180
|
tabindex="0"
|
|
147
|
-
on:click={() => onSelectOption(
|
|
181
|
+
on:click={() => onSelectOption(getOptionValue(option, idx))}
|
|
182
|
+
class:is-disabled={!isOptionEnabled(option)}
|
|
148
183
|
>
|
|
149
|
-
|
|
184
|
+
{#if getOptionIcon(option, idx)}
|
|
185
|
+
<span class="option-extra icon">
|
|
186
|
+
<Icon size="S" name={getOptionIcon(option, idx)} />
|
|
187
|
+
</span>
|
|
188
|
+
{/if}
|
|
189
|
+
{#if getOptionColour(option, idx)}
|
|
190
|
+
<span class="option-extra">
|
|
191
|
+
<StatusLight square color={getOptionColour(option, idx)} />
|
|
192
|
+
</span>
|
|
193
|
+
{/if}
|
|
194
|
+
<span class="spectrum-Menu-itemLabel">
|
|
195
|
+
{getOptionLabel(option, idx)}
|
|
196
|
+
</span>
|
|
150
197
|
<svg
|
|
151
198
|
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
|
|
152
199
|
focusable="false"
|
|
@@ -155,61 +202,13 @@
|
|
|
155
202
|
<use xlink:href="#spectrum-css-icon-Checkmark100" />
|
|
156
203
|
</svg>
|
|
157
204
|
</li>
|
|
158
|
-
{/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
class:is-selected={isOptionSelected(getOptionValue(option, idx))}
|
|
164
|
-
role="option"
|
|
165
|
-
aria-selected="true"
|
|
166
|
-
tabindex="0"
|
|
167
|
-
on:click={() => onSelectOption(getOptionValue(option, idx))}
|
|
168
|
-
class:is-disabled={!isOptionEnabled(option)}
|
|
169
|
-
>
|
|
170
|
-
{#if getOptionIcon(option, idx)}
|
|
171
|
-
<span class="option-extra">
|
|
172
|
-
<Icon name={getOptionIcon(option, idx)} />
|
|
173
|
-
</span>
|
|
174
|
-
{/if}
|
|
175
|
-
{#if getOptionColour(option, idx)}
|
|
176
|
-
<span class="option-extra">
|
|
177
|
-
<StatusLight square color={getOptionColour(option, idx)} />
|
|
178
|
-
</span>
|
|
179
|
-
{/if}
|
|
180
|
-
<span class="spectrum-Menu-itemLabel">
|
|
181
|
-
{getOptionLabel(option, idx)}
|
|
182
|
-
</span>
|
|
183
|
-
<svg
|
|
184
|
-
class="spectrum-Icon spectrum-UIIcon-Checkmark100 spectrum-Menu-checkmark spectrum-Menu-itemIcon"
|
|
185
|
-
focusable="false"
|
|
186
|
-
aria-hidden="true"
|
|
187
|
-
>
|
|
188
|
-
<use xlink:href="#spectrum-css-icon-Checkmark100" />
|
|
189
|
-
</svg>
|
|
190
|
-
</li>
|
|
191
|
-
{/each}
|
|
192
|
-
{/if}
|
|
193
|
-
</ul>
|
|
194
|
-
</div>
|
|
195
|
-
{/if}
|
|
196
|
-
</div>
|
|
205
|
+
{/each}
|
|
206
|
+
{/if}
|
|
207
|
+
</ul>
|
|
208
|
+
</div>
|
|
209
|
+
</Popover>
|
|
197
210
|
|
|
198
211
|
<style>
|
|
199
|
-
.spectrum-Popover {
|
|
200
|
-
max-height: 240px;
|
|
201
|
-
z-index: 999;
|
|
202
|
-
top: 100%;
|
|
203
|
-
}
|
|
204
|
-
.spectrum-Popover:not(.auto-width) {
|
|
205
|
-
width: 100%;
|
|
206
|
-
}
|
|
207
|
-
.spectrum-Popover.auto-width :global(.spectrum-Menu-itemLabel) {
|
|
208
|
-
max-width: 400px;
|
|
209
|
-
white-space: nowrap;
|
|
210
|
-
overflow: hidden;
|
|
211
|
-
text-overflow: ellipsis;
|
|
212
|
-
}
|
|
213
212
|
.spectrum-Picker {
|
|
214
213
|
width: 100%;
|
|
215
214
|
box-shadow: none;
|
|
@@ -229,9 +228,6 @@
|
|
|
229
228
|
.spectrum-Picker-label.auto-width.is-placeholder {
|
|
230
229
|
padding-right: 2px;
|
|
231
230
|
}
|
|
232
|
-
.auto-width .spectrum-Menu-item {
|
|
233
|
-
padding-right: var(--spacing-xl);
|
|
234
|
-
}
|
|
235
231
|
|
|
236
232
|
/* Icon and colour alignment */
|
|
237
233
|
.spectrum-Menu-checkmark {
|
|
@@ -241,27 +237,48 @@
|
|
|
241
237
|
.option-extra {
|
|
242
238
|
padding-right: 8px;
|
|
243
239
|
}
|
|
240
|
+
.option-extra.icon {
|
|
241
|
+
margin: 0 -1px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* Popover */
|
|
245
|
+
.popover-content {
|
|
246
|
+
display: contents;
|
|
247
|
+
}
|
|
248
|
+
.popover-content.auto-width .spectrum-Menu-itemLabel {
|
|
249
|
+
white-space: nowrap;
|
|
250
|
+
overflow: hidden;
|
|
251
|
+
text-overflow: ellipsis;
|
|
252
|
+
}
|
|
253
|
+
.popover-content:not(.auto-width) .spectrum-Menu-itemLabel {
|
|
254
|
+
width: 0;
|
|
255
|
+
flex: 1 1 auto;
|
|
256
|
+
}
|
|
257
|
+
.popover-content.auto-width .spectrum-Menu-item {
|
|
258
|
+
padding-right: var(--spacing-xl);
|
|
259
|
+
}
|
|
260
|
+
.spectrum-Menu-item.is-disabled {
|
|
261
|
+
pointer-events: none;
|
|
262
|
+
}
|
|
244
263
|
|
|
245
|
-
|
|
264
|
+
/* Search styles inside popover */
|
|
265
|
+
.popover-content :global(.spectrum-Search) {
|
|
246
266
|
margin-top: -1px;
|
|
247
267
|
margin-left: -1px;
|
|
248
268
|
width: calc(100% + 2px);
|
|
249
269
|
}
|
|
250
|
-
.
|
|
270
|
+
.popover-content :global(.spectrum-Search input) {
|
|
251
271
|
height: auto;
|
|
252
272
|
border-bottom-left-radius: 0;
|
|
253
273
|
border-bottom-right-radius: 0;
|
|
254
274
|
padding-top: var(--spectrum-global-dimension-size-100);
|
|
255
275
|
padding-bottom: var(--spectrum-global-dimension-size-100);
|
|
256
276
|
}
|
|
257
|
-
.
|
|
277
|
+
.popover-content :global(.spectrum-Search .spectrum-ClearButton) {
|
|
258
278
|
right: 1px;
|
|
259
279
|
top: 2px;
|
|
260
280
|
}
|
|
261
|
-
.
|
|
281
|
+
.popover-content :global(.spectrum-Search .spectrum-Textfield-icon) {
|
|
262
282
|
top: 9px;
|
|
263
283
|
}
|
|
264
|
-
.spectrum-Menu-item.is-disabled {
|
|
265
|
-
pointer-events: none;
|
|
266
|
-
}
|
|
267
284
|
</style>
|
|
@@ -18,8 +18,11 @@
|
|
|
18
18
|
export let autoWidth = false
|
|
19
19
|
export let autocomplete = false
|
|
20
20
|
export let sort = false
|
|
21
|
+
|
|
21
22
|
const dispatch = createEventDispatcher()
|
|
23
|
+
|
|
22
24
|
let open = false
|
|
25
|
+
|
|
23
26
|
$: fieldText = getFieldText(value, options, placeholder)
|
|
24
27
|
$: fieldIcon = getFieldAttribute(getOptionIcon, value, options)
|
|
25
28
|
$: fieldColour = getFieldAttribute(getOptionColour, value, options)
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
export let id = null
|
|
7
7
|
export let text = null
|
|
8
8
|
export let disabled = false
|
|
9
|
-
export let dataCy = null
|
|
10
9
|
|
|
11
10
|
const dispatch = createEventDispatcher()
|
|
12
11
|
const onChange = event => {
|
|
@@ -16,7 +15,6 @@
|
|
|
16
15
|
|
|
17
16
|
<div class="spectrum-Switch spectrum-Switch--emphasized">
|
|
18
17
|
<input
|
|
19
|
-
data-cy={dataCy}
|
|
20
18
|
checked={value}
|
|
21
19
|
{disabled}
|
|
22
20
|
on:change={onChange}
|
|
@@ -11,7 +11,6 @@
|
|
|
11
11
|
export let readonly = false
|
|
12
12
|
export let updateOnChange = true
|
|
13
13
|
export let quiet = false
|
|
14
|
-
export let dataCy
|
|
15
14
|
export let align
|
|
16
15
|
export let autofocus = false
|
|
17
16
|
|
|
@@ -89,7 +88,6 @@
|
|
|
89
88
|
{disabled}
|
|
90
89
|
{readonly}
|
|
91
90
|
{id}
|
|
92
|
-
data-cy={dataCy}
|
|
93
91
|
value={value || ""}
|
|
94
92
|
placeholder={placeholder || ""}
|
|
95
93
|
on:click
|
|
@@ -112,8 +110,4 @@
|
|
|
112
110
|
.spectrum-Textfield {
|
|
113
111
|
width: 100%;
|
|
114
112
|
}
|
|
115
|
-
input:disabled {
|
|
116
|
-
color: var(--spectrum-global-color-gray-600) !important;
|
|
117
|
-
-webkit-text-fill-color: var(--spectrum-global-color-gray-600) !important;
|
|
118
|
-
}
|
|
119
113
|
</style>
|