@budibase/bbui 1.0.0 → 1.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/README.md +19 -17
- package/dist/bbui.es.js +2 -0
- package/dist/bbui.es.js.map +1 -0
- package/package.json +68 -26
- package/src/ActionButton/ActionButton.svelte +83 -0
- package/src/ActionGroup/ActionGroup.svelte +26 -0
- package/src/ActionMenu/ActionMenu.svelte +43 -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 +49 -0
- package/src/Badge/Badge.svelte +29 -0
- package/src/Button/Button.svelte +52 -0
- package/src/Button/Button.svench +138 -0
- package/src/ButtonGroup/ButtonGroup.svelte +19 -0
- package/src/ClearButton/ClearButton.svelte +19 -0
- package/src/ColorPicker/ColorPicker.svelte +292 -0
- package/src/DetailSummary/DetailSummary.svelte +83 -0
- package/src/Divider/Divider.svelte +25 -0
- package/src/Drawer/Drawer.svelte +85 -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 +44 -0
- package/src/Form/Core/Checkbox.svelte +67 -0
- package/src/Form/Core/Combobox.svelte +156 -0
- package/src/Form/Core/DatePicker.svelte +183 -0
- package/src/Form/Core/Dropzone.svelte +393 -0
- package/src/Form/Core/Multiselect.svelte +88 -0
- package/src/Form/Core/Picker.svelte +241 -0
- package/src/Form/Core/RadioGroup.svelte +47 -0
- package/src/Form/Core/Search.svelte +101 -0
- package/src/Form/Core/Select.svelte +81 -0
- package/src/Form/Core/Stepper.svelte +172 -0
- package/src/Form/Core/Switch.svelte +35 -0
- package/src/Form/Core/TextArea.svelte +60 -0
- package/src/Form/Core/TextField.svelte +104 -0
- package/src/Form/Core/index.js +12 -0
- package/src/Form/DatePicker.svelte +33 -0
- package/src/Form/Dropzone.svelte +34 -0
- package/src/Form/Field.svelte +41 -0
- package/src/Form/FieldLabel.svelte +27 -0
- package/src/Form/Input.svelte +38 -45
- package/src/Form/Multiselect.svelte +39 -0
- package/src/Form/RadioGroup.svelte +38 -0
- package/src/Form/Search.svelte +32 -0
- package/src/Form/Select.svelte +45 -43
- package/src/Form/Stepper.svelte +45 -0
- package/src/Form/TextArea.svelte +25 -44
- package/src/Form/Toggle.svelte +23 -0
- package/src/Icon/Icon.svelte +47 -0
- package/src/InlineAlert/InlineAlert.svelte +56 -0
- package/src/Label/Label.svelte +67 -0
- package/src/Layout/Layout.svelte +75 -0
- package/src/Layout/Page.svelte +25 -0
- package/src/Link/Link.svelte +22 -0
- package/src/List/Items/DetailSummary.svench +53 -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 +133 -0
- package/src/Modal/Modal.svench +117 -0
- package/src/Modal/ModalContent.svelte +139 -0
- package/src/Modal/QuizModal.svelte +54 -0
- package/src/Notification/Notification.svelte +20 -0
- package/src/Notification/NotificationDisplay.svelte +36 -0
- package/src/Pagination/Pagination.svelte +57 -0
- package/src/Popover/Popover.svelte +52 -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 +45 -0
- package/src/SideNavigation/Navigation.svelte +12 -0
- package/src/StatusLight/StatusLight.svelte +41 -0
- package/src/Stores/Notifications.svench.svx +78 -0
- package/src/Stores/notifications.js +56 -0
- package/src/Table/ArrayRenderer.svelte +17 -0
- package/src/Table/AttachmentRenderer.svelte +55 -0
- package/src/Table/BooleanRenderer.svelte +42 -0
- package/src/Table/CellRenderer.svelte +37 -0
- package/src/Table/DateTimeRenderer.svelte +13 -0
- package/src/Table/InternalRenderer.svelte +28 -0
- package/src/Table/RelationshipRenderer.svelte +40 -0
- package/src/Table/SelectEditRenderer.svelte +16 -0
- package/src/Table/StringRenderer.svelte +13 -0
- package/src/Table/Table.svelte +506 -0
- package/src/Table/index.js +1 -0
- package/src/Tabs/Tab.svelte +66 -0
- package/src/Tabs/Tabs.svelte +105 -0
- package/src/Tags/Tag.svelte +43 -0
- package/src/Tags/Tags.svelte +7 -0
- package/src/Tooltip/Tooltip.svelte +24 -0
- package/src/TreeView/Item.svelte +41 -0
- package/src/TreeView/Tree.svelte +16 -0
- package/src/Typography/Body.svelte +19 -0
- package/src/Typography/Code.svelte +10 -0
- package/src/Typography/Detail.svelte +15 -0
- package/src/Typography/Heading.svelte +16 -0
- package/src/bbui.css +96 -0
- package/src/context.js +3 -0
- package/src/index.js +75 -10
- package/src/spectrum-icons-rollup.js +31 -0
- package/src/spectrum-icons-vite.js +31 -0
- package/src/utils/helpers.js +8 -0
- package/dist/bundle.css +0 -6
- package/dist/bundle.css.map +0 -18
- package/dist/index.js +0 -919
- package/dist/index.mjs +0 -906
- 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 -52
- package/src/Form/Button.svench +0 -26
- 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/actions/autoresize_textarea.js +0 -14
- package/src/icons/Contribution.svelte +0 -14
- package/src/index.svench.svx +0 -35
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
|
|
14
|
+
const dispatch = createEventDispatcher()
|
|
15
|
+
const onChange = e => dispatch("change", e.target.value)
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div class={`spectrum-FieldGroup spectrum-FieldGroup--${direction}`}>
|
|
19
|
+
{#if options && Array.isArray(options)}
|
|
20
|
+
{#each options as option}
|
|
21
|
+
<div
|
|
22
|
+
title={getOptionLabel(option)}
|
|
23
|
+
class="spectrum-Radio spectrum-FieldGroup-item spectrum-Radio--emphasized"
|
|
24
|
+
class:is-invalid={!!error}
|
|
25
|
+
>
|
|
26
|
+
<input
|
|
27
|
+
on:change={onChange}
|
|
28
|
+
bind:group={value}
|
|
29
|
+
value={getOptionValue(option)}
|
|
30
|
+
type="radio"
|
|
31
|
+
class="spectrum-Radio-input"
|
|
32
|
+
{disabled}
|
|
33
|
+
/>
|
|
34
|
+
<span class="spectrum-Radio-button" />
|
|
35
|
+
<label for="" class="spectrum-Radio-label">
|
|
36
|
+
{getOptionLabel(option)}
|
|
37
|
+
</label>
|
|
38
|
+
</div>
|
|
39
|
+
{/each}
|
|
40
|
+
{/if}
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<style>
|
|
44
|
+
.spectrum-Radio-input {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
@@ -0,0 +1,101 @@
|
|
|
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
|
+
|
|
11
|
+
const dispatch = createEventDispatcher()
|
|
12
|
+
let focus = false
|
|
13
|
+
|
|
14
|
+
const updateValue = value => {
|
|
15
|
+
dispatch("change", value)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const onFocus = () => {
|
|
19
|
+
focus = true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const onBlur = event => {
|
|
23
|
+
focus = false
|
|
24
|
+
updateValue(event.target.value)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const onInput = event => {
|
|
28
|
+
if (!updateOnChange) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
updateValue(event.target.value)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const updateValueOnEnter = event => {
|
|
35
|
+
if (event.key === "Enter") {
|
|
36
|
+
updateValue(event.target.value)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<div class="spectrum-Search" class:is-disabled={disabled}>
|
|
42
|
+
<div
|
|
43
|
+
class="spectrum-Textfield"
|
|
44
|
+
class:is-focused={focus}
|
|
45
|
+
class:is-disabled={disabled}
|
|
46
|
+
>
|
|
47
|
+
<svg
|
|
48
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-icon"
|
|
49
|
+
focusable="false"
|
|
50
|
+
aria-hidden="true"
|
|
51
|
+
>
|
|
52
|
+
<use xlink:href="#spectrum-icon-18-Magnify" />
|
|
53
|
+
</svg>
|
|
54
|
+
<input
|
|
55
|
+
{disabled}
|
|
56
|
+
{id}
|
|
57
|
+
value={value || ""}
|
|
58
|
+
placeholder={placeholder || ""}
|
|
59
|
+
on:click
|
|
60
|
+
on:blur
|
|
61
|
+
on:focus
|
|
62
|
+
on:input
|
|
63
|
+
on:blur={onBlur}
|
|
64
|
+
on:focus={onFocus}
|
|
65
|
+
on:input={onInput}
|
|
66
|
+
on:keyup={updateValueOnEnter}
|
|
67
|
+
type="search"
|
|
68
|
+
class="spectrum-Textfield-input spectrum-Search-input"
|
|
69
|
+
autocomplete="off"
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
<button
|
|
73
|
+
on:click={() => updateValue("")}
|
|
74
|
+
type="reset"
|
|
75
|
+
class="spectrum-ClearButton spectrum-Search-clearButton"
|
|
76
|
+
>
|
|
77
|
+
<svg
|
|
78
|
+
class="spectrum-Icon spectrum-UIIcon-Cross75"
|
|
79
|
+
focusable="false"
|
|
80
|
+
aria-hidden="true"
|
|
81
|
+
>
|
|
82
|
+
<use xlink:href="#spectrum-css-icon-Cross75" />
|
|
83
|
+
</svg>
|
|
84
|
+
</button>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<style>
|
|
88
|
+
.spectrum-Search,
|
|
89
|
+
.spectrum-Textfield {
|
|
90
|
+
width: 100%;
|
|
91
|
+
}
|
|
92
|
+
.spectrum-Search-input {
|
|
93
|
+
padding-right: 24px;
|
|
94
|
+
}
|
|
95
|
+
.is-disabled {
|
|
96
|
+
pointer-events: none;
|
|
97
|
+
}
|
|
98
|
+
.spectrum-Search-clearButton {
|
|
99
|
+
position: absolute;
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,81 @@
|
|
|
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 readonly = false
|
|
15
|
+
export let quiet = false
|
|
16
|
+
export let autoWidth = false
|
|
17
|
+
export let autocomplete = false
|
|
18
|
+
export let sort = false
|
|
19
|
+
|
|
20
|
+
const dispatch = createEventDispatcher()
|
|
21
|
+
let open = false
|
|
22
|
+
$: fieldText = getFieldText(value, options, placeholder)
|
|
23
|
+
$: fieldIcon = getFieldIcon(value, options, placeholder)
|
|
24
|
+
|
|
25
|
+
const getFieldText = (value, options, placeholder) => {
|
|
26
|
+
// Always use placeholder if no value
|
|
27
|
+
if (value == null || value === "") {
|
|
28
|
+
return placeholder || "Choose an option"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Wait for options to load if there is a value but no options
|
|
32
|
+
if (!options?.length) {
|
|
33
|
+
return ""
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Render the label if the selected option is found, otherwise raw value
|
|
37
|
+
const index = options.findIndex(
|
|
38
|
+
(option, idx) => getOptionValue(option, idx) === value
|
|
39
|
+
)
|
|
40
|
+
return index !== -1 ? getOptionLabel(options[index], index) : value
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const getFieldIcon = (value, options) => {
|
|
44
|
+
// Wait for options to load if there is a value but no options
|
|
45
|
+
if (!options?.length) {
|
|
46
|
+
return ""
|
|
47
|
+
}
|
|
48
|
+
const index = options.findIndex(
|
|
49
|
+
(option, idx) => getOptionValue(option, idx) === value
|
|
50
|
+
)
|
|
51
|
+
return index !== -1 ? getOptionIcon(options[index], index) : null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const selectOption = value => {
|
|
55
|
+
dispatch("change", value)
|
|
56
|
+
open = false
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<Picker
|
|
61
|
+
on:click
|
|
62
|
+
bind:open
|
|
63
|
+
{quiet}
|
|
64
|
+
{id}
|
|
65
|
+
{error}
|
|
66
|
+
{disabled}
|
|
67
|
+
{readonly}
|
|
68
|
+
{fieldText}
|
|
69
|
+
{options}
|
|
70
|
+
{autoWidth}
|
|
71
|
+
{getOptionLabel}
|
|
72
|
+
{getOptionValue}
|
|
73
|
+
{getOptionIcon}
|
|
74
|
+
{fieldIcon}
|
|
75
|
+
{autocomplete}
|
|
76
|
+
{sort}
|
|
77
|
+
isPlaceholder={value == null || value === ""}
|
|
78
|
+
placeholderOption={placeholder}
|
|
79
|
+
isOptionSelected={option => option === value}
|
|
80
|
+
onSelectOption={selectOption}
|
|
81
|
+
/>
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/textfield/dist/index-vars.css"
|
|
3
|
+
import "@spectrum-css/actionbutton/dist/index-vars.css"
|
|
4
|
+
import "@spectrum-css/stepper/dist/index-vars.css"
|
|
5
|
+
import { createEventDispatcher } from "svelte"
|
|
6
|
+
|
|
7
|
+
export let value = null
|
|
8
|
+
export let placeholder = null
|
|
9
|
+
export let disabled = false
|
|
10
|
+
export let error = null
|
|
11
|
+
export let id = null
|
|
12
|
+
export let readonly = false
|
|
13
|
+
export let updateOnChange = true
|
|
14
|
+
export let quiet = false
|
|
15
|
+
export let min
|
|
16
|
+
export let max
|
|
17
|
+
export let step
|
|
18
|
+
|
|
19
|
+
const dispatch = createEventDispatcher()
|
|
20
|
+
let focus = false
|
|
21
|
+
|
|
22
|
+
// We need to keep the field value bound to a different variable in order
|
|
23
|
+
// to properly handle erroneous values. If we don't do this then it is
|
|
24
|
+
// possible for the field to show stale text which does not represent the
|
|
25
|
+
// real value. The reactive statement is to ensure that external changes to
|
|
26
|
+
// the value prop are reflected.
|
|
27
|
+
let fieldValue = value
|
|
28
|
+
$: fieldValue = value
|
|
29
|
+
|
|
30
|
+
// Ensure step is always a numeric value defaulting to 1
|
|
31
|
+
$: step = step == null || isNaN(step) ? 1 : step
|
|
32
|
+
|
|
33
|
+
const updateValue = value => {
|
|
34
|
+
if (readonly) {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const float = parseFloat(value)
|
|
38
|
+
value = isNaN(float) ? null : float
|
|
39
|
+
if (value != null) {
|
|
40
|
+
if (min != null && value < min) {
|
|
41
|
+
value = min
|
|
42
|
+
} else if (max != null && value > max) {
|
|
43
|
+
value = max
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
dispatch("change", value)
|
|
47
|
+
fieldValue = value
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const onFocus = () => {
|
|
51
|
+
if (readonly) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
focus = true
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const onBlur = event => {
|
|
58
|
+
if (readonly) {
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
focus = false
|
|
62
|
+
updateValue(event.target.value)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const onInput = event => {
|
|
66
|
+
if (readonly || !updateOnChange) {
|
|
67
|
+
return
|
|
68
|
+
}
|
|
69
|
+
updateValue(event.target.value)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const updateValueOnEnter = event => {
|
|
73
|
+
if (readonly) {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
if (event.key === "Enter") {
|
|
77
|
+
updateValue(event.target.value)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const stepUp = () => {
|
|
82
|
+
if (value == null || isNaN(value)) {
|
|
83
|
+
updateValue(step)
|
|
84
|
+
} else {
|
|
85
|
+
updateValue(value + step)
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const stepDown = () => {
|
|
90
|
+
if (value == null || isNaN(value)) {
|
|
91
|
+
updateValue(step)
|
|
92
|
+
} else {
|
|
93
|
+
updateValue(value - step)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
</script>
|
|
97
|
+
|
|
98
|
+
<div
|
|
99
|
+
class="spectrum-Stepper"
|
|
100
|
+
class:spectrum-Stepper--quiet={quiet}
|
|
101
|
+
class:is-invalid={!!error}
|
|
102
|
+
class:is-disabled={disabled}
|
|
103
|
+
class:is-focused={focus}
|
|
104
|
+
>
|
|
105
|
+
{#if error}
|
|
106
|
+
<svg
|
|
107
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-validationIcon"
|
|
108
|
+
focusable="false"
|
|
109
|
+
aria-hidden="true"
|
|
110
|
+
>
|
|
111
|
+
<use xlink:href="#spectrum-icon-18-Alert" />
|
|
112
|
+
</svg>
|
|
113
|
+
{/if}
|
|
114
|
+
|
|
115
|
+
<div class="spectrum-Textfield spectrum-Stepper-textfield">
|
|
116
|
+
<input
|
|
117
|
+
{disabled}
|
|
118
|
+
{readonly}
|
|
119
|
+
{id}
|
|
120
|
+
bind:value={fieldValue}
|
|
121
|
+
placeholder={placeholder || ""}
|
|
122
|
+
type="number"
|
|
123
|
+
class="spectrum-Textfield-input spectrum-Stepper-input"
|
|
124
|
+
on:click
|
|
125
|
+
on:blur
|
|
126
|
+
on:focus
|
|
127
|
+
on:input
|
|
128
|
+
on:keyup
|
|
129
|
+
on:blur={onBlur}
|
|
130
|
+
on:focus={onFocus}
|
|
131
|
+
on:input={onInput}
|
|
132
|
+
on:keyup={updateValueOnEnter}
|
|
133
|
+
/>
|
|
134
|
+
</div>
|
|
135
|
+
<span class="spectrum-Stepper-buttons">
|
|
136
|
+
<button
|
|
137
|
+
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-Stepper-stepUp"
|
|
138
|
+
tabindex="-1"
|
|
139
|
+
on:click={stepUp}
|
|
140
|
+
>
|
|
141
|
+
<svg
|
|
142
|
+
class="spectrum-Icon spectrum-UIIcon-ChevronUp75"
|
|
143
|
+
focusable="false"
|
|
144
|
+
aria-hidden="true"
|
|
145
|
+
>
|
|
146
|
+
<use xlink:href="#spectrum-css-icon-Chevron75" />
|
|
147
|
+
</svg>
|
|
148
|
+
</button>
|
|
149
|
+
<button
|
|
150
|
+
class="spectrum-ActionButton spectrum-ActionButton--sizeM spectrum-Stepper-stepDown"
|
|
151
|
+
tabindex="-1"
|
|
152
|
+
on:click={stepDown}
|
|
153
|
+
>
|
|
154
|
+
<svg
|
|
155
|
+
class="spectrum-Icon spectrum-UIIcon-ChevronDown75"
|
|
156
|
+
focusable="false"
|
|
157
|
+
aria-hidden="true"
|
|
158
|
+
>
|
|
159
|
+
<use xlink:href="#spectrum-css-icon-Chevron75" />
|
|
160
|
+
</svg>
|
|
161
|
+
</button>
|
|
162
|
+
</span>
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
<style>
|
|
166
|
+
.spectrum-Stepper {
|
|
167
|
+
width: 100%;
|
|
168
|
+
}
|
|
169
|
+
.spectrum-Stepper::before {
|
|
170
|
+
display: none;
|
|
171
|
+
}
|
|
172
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/switch/dist/index-vars.css"
|
|
3
|
+
import { createEventDispatcher } from "svelte"
|
|
4
|
+
|
|
5
|
+
export let value = false
|
|
6
|
+
export let id = null
|
|
7
|
+
export let text = null
|
|
8
|
+
export let disabled = false
|
|
9
|
+
export let dataCy = null
|
|
10
|
+
|
|
11
|
+
const dispatch = createEventDispatcher()
|
|
12
|
+
const onChange = event => {
|
|
13
|
+
dispatch("change", event.target.checked)
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<div class="spectrum-Switch spectrum-Switch--emphasized">
|
|
18
|
+
<input
|
|
19
|
+
data-cy={dataCy}
|
|
20
|
+
checked={value}
|
|
21
|
+
{disabled}
|
|
22
|
+
on:change={onChange}
|
|
23
|
+
{id}
|
|
24
|
+
type="checkbox"
|
|
25
|
+
class="spectrum-Switch-input"
|
|
26
|
+
/>
|
|
27
|
+
<span class="spectrum-Switch-switch" />
|
|
28
|
+
<label class="spectrum-Switch-label" for={id}>{text}</label>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.spectrum-Switch-input {
|
|
33
|
+
opacity: 0;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/textfield/dist/index-vars.css"
|
|
3
|
+
import { createEventDispatcher } from "svelte"
|
|
4
|
+
|
|
5
|
+
export let value = ""
|
|
6
|
+
export let placeholder = null
|
|
7
|
+
export let disabled = false
|
|
8
|
+
export let error = null
|
|
9
|
+
export let id = null
|
|
10
|
+
export const getCaretPosition = () => ({
|
|
11
|
+
start: textarea.selectionStart,
|
|
12
|
+
end: textarea.selectionEnd,
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
let focus = false
|
|
16
|
+
let textarea
|
|
17
|
+
const dispatch = createEventDispatcher()
|
|
18
|
+
const onChange = event => {
|
|
19
|
+
dispatch("change", event.target.value)
|
|
20
|
+
focus = false
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<div
|
|
25
|
+
class="spectrum-Textfield spectrum-Textfield--multiline"
|
|
26
|
+
class:is-invalid={!!error}
|
|
27
|
+
class:is-disabled={disabled}
|
|
28
|
+
class:is-focused={focus}
|
|
29
|
+
>
|
|
30
|
+
{#if error}
|
|
31
|
+
<svg
|
|
32
|
+
class="spectrum-Icon spectrum-Icon--sizeM
|
|
33
|
+
spectrum-Textfield-validationIcon"
|
|
34
|
+
focusable="false"
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
>
|
|
37
|
+
<use xlink:href="#spectrum-icon-18-Alert" />
|
|
38
|
+
</svg>
|
|
39
|
+
{/if}
|
|
40
|
+
<!-- prettier-ignore -->
|
|
41
|
+
<textarea
|
|
42
|
+
bind:this={textarea}
|
|
43
|
+
placeholder={placeholder || ""}
|
|
44
|
+
class="spectrum-Textfield-input"
|
|
45
|
+
{disabled}
|
|
46
|
+
{id}
|
|
47
|
+
on:focus={() => (focus = true)}
|
|
48
|
+
on:blur={onChange}
|
|
49
|
+
>{value || ""}</textarea>
|
|
50
|
+
</div>
|
|
51
|
+
|
|
52
|
+
<style>
|
|
53
|
+
.spectrum-Textfield {
|
|
54
|
+
width: 100%;
|
|
55
|
+
}
|
|
56
|
+
textarea {
|
|
57
|
+
resize: vertical;
|
|
58
|
+
min-height: 80px !important;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/textfield/dist/index-vars.css"
|
|
3
|
+
import { createEventDispatcher } from "svelte"
|
|
4
|
+
|
|
5
|
+
export let value = null
|
|
6
|
+
export let placeholder = null
|
|
7
|
+
export let type = "text"
|
|
8
|
+
export let disabled = false
|
|
9
|
+
export let error = null
|
|
10
|
+
export let id = null
|
|
11
|
+
export let readonly = false
|
|
12
|
+
export let updateOnChange = true
|
|
13
|
+
export let quiet = false
|
|
14
|
+
export let dataCy
|
|
15
|
+
|
|
16
|
+
const dispatch = createEventDispatcher()
|
|
17
|
+
let focus = false
|
|
18
|
+
|
|
19
|
+
const updateValue = newValue => {
|
|
20
|
+
if (readonly) {
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
if (type === "number") {
|
|
24
|
+
const float = parseFloat(newValue)
|
|
25
|
+
newValue = isNaN(float) ? null : float
|
|
26
|
+
}
|
|
27
|
+
dispatch("change", newValue)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const onFocus = () => {
|
|
31
|
+
if (readonly) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
focus = true
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const onBlur = event => {
|
|
38
|
+
if (readonly) {
|
|
39
|
+
return
|
|
40
|
+
}
|
|
41
|
+
focus = false
|
|
42
|
+
updateValue(event.target.value)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const onInput = event => {
|
|
46
|
+
if (readonly || !updateOnChange) {
|
|
47
|
+
return
|
|
48
|
+
}
|
|
49
|
+
updateValue(event.target.value)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const updateValueOnEnter = event => {
|
|
53
|
+
if (readonly) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
if (event.key === "Enter") {
|
|
57
|
+
updateValue(event.target.value)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
class="spectrum-Textfield"
|
|
64
|
+
class:spectrum-Textfield--quiet={quiet}
|
|
65
|
+
class:is-invalid={!!error}
|
|
66
|
+
class:is-disabled={disabled}
|
|
67
|
+
class:is-focused={focus}
|
|
68
|
+
>
|
|
69
|
+
{#if error}
|
|
70
|
+
<svg
|
|
71
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-validationIcon"
|
|
72
|
+
focusable="false"
|
|
73
|
+
aria-hidden="true"
|
|
74
|
+
>
|
|
75
|
+
<use xlink:href="#spectrum-icon-18-Alert" />
|
|
76
|
+
</svg>
|
|
77
|
+
{/if}
|
|
78
|
+
<input
|
|
79
|
+
{disabled}
|
|
80
|
+
{readonly}
|
|
81
|
+
{id}
|
|
82
|
+
data-cy={dataCy}
|
|
83
|
+
value={value || ""}
|
|
84
|
+
placeholder={placeholder || ""}
|
|
85
|
+
on:click
|
|
86
|
+
on:blur
|
|
87
|
+
on:focus
|
|
88
|
+
on:input
|
|
89
|
+
on:keyup
|
|
90
|
+
on:blur={onBlur}
|
|
91
|
+
on:focus={onFocus}
|
|
92
|
+
on:input={onInput}
|
|
93
|
+
on:keyup={updateValueOnEnter}
|
|
94
|
+
{type}
|
|
95
|
+
inputmode={type === "number" ? "decimal" : "text"}
|
|
96
|
+
class="spectrum-Textfield-input"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
|
|
100
|
+
<style>
|
|
101
|
+
.spectrum-Textfield {
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as CoreTextField } from "./TextField.svelte"
|
|
2
|
+
export { default as CoreSelect } from "./Select.svelte"
|
|
3
|
+
export { default as CoreMultiselect } from "./Multiselect.svelte"
|
|
4
|
+
export { default as CoreCheckbox } from "./Checkbox.svelte"
|
|
5
|
+
export { default as CoreRadioGroup } from "./RadioGroup.svelte"
|
|
6
|
+
export { default as CoreTextArea } from "./TextArea.svelte"
|
|
7
|
+
export { default as CoreCombobox } from "./Combobox.svelte"
|
|
8
|
+
export { default as CoreSwitch } from "./Switch.svelte"
|
|
9
|
+
export { default as CoreSearch } from "./Search.svelte"
|
|
10
|
+
export { default as CoreDatePicker } from "./DatePicker.svelte"
|
|
11
|
+
export { default as CoreDropzone } from "./Dropzone.svelte"
|
|
12
|
+
export { default as CoreStepper } from "./Stepper.svelte"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Field from "./Field.svelte"
|
|
3
|
+
import DatePicker from "./Core/DatePicker.svelte"
|
|
4
|
+
import { createEventDispatcher } from "svelte"
|
|
5
|
+
|
|
6
|
+
export let value = null
|
|
7
|
+
export let label = null
|
|
8
|
+
export let labelPosition = "above"
|
|
9
|
+
export let disabled = false
|
|
10
|
+
export let error = null
|
|
11
|
+
export let enableTime = true
|
|
12
|
+
export let placeholder = null
|
|
13
|
+
export let appendTo = undefined
|
|
14
|
+
|
|
15
|
+
const dispatch = createEventDispatcher()
|
|
16
|
+
|
|
17
|
+
const onChange = e => {
|
|
18
|
+
value = e.detail
|
|
19
|
+
dispatch("change", e.detail)
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Field {label} {labelPosition} {error}>
|
|
24
|
+
<DatePicker
|
|
25
|
+
{error}
|
|
26
|
+
{disabled}
|
|
27
|
+
{value}
|
|
28
|
+
{placeholder}
|
|
29
|
+
{enableTime}
|
|
30
|
+
{appendTo}
|
|
31
|
+
on:change={onChange}
|
|
32
|
+
/>
|
|
33
|
+
</Field>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Field from "./Field.svelte"
|
|
3
|
+
import CoreDropzone from "./Core/Dropzone.svelte"
|
|
4
|
+
import { createEventDispatcher } from "svelte"
|
|
5
|
+
|
|
6
|
+
export let value = []
|
|
7
|
+
export let label = null
|
|
8
|
+
export let labelPosition = "above"
|
|
9
|
+
export let disabled = false
|
|
10
|
+
export let error = null
|
|
11
|
+
export let fileSizeLimit = undefined
|
|
12
|
+
export let processFiles = undefined
|
|
13
|
+
export let handleFileTooLarge = undefined
|
|
14
|
+
export let gallery = true
|
|
15
|
+
|
|
16
|
+
const dispatch = createEventDispatcher()
|
|
17
|
+
const onChange = e => {
|
|
18
|
+
value = e.detail
|
|
19
|
+
dispatch("change", e.detail)
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Field {label} {labelPosition} {error}>
|
|
24
|
+
<CoreDropzone
|
|
25
|
+
{error}
|
|
26
|
+
{disabled}
|
|
27
|
+
{value}
|
|
28
|
+
{fileSizeLimit}
|
|
29
|
+
{processFiles}
|
|
30
|
+
{handleFileTooLarge}
|
|
31
|
+
{gallery}
|
|
32
|
+
on:change={onChange}
|
|
33
|
+
/>
|
|
34
|
+
</Field>
|