@budibase/bbui 0.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 +42 -0
- package/dist/bbui.es.js +8 -0
- package/dist/bbui.es.js.map +1 -0
- package/package.json +94 -0
- package/src/Accordion/Accordion.svelte +58 -0
- package/src/ActionButton/ActionButton.svelte +132 -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 +76 -0
- package/src/Actions/position_dropdown.js +116 -0
- package/src/Avatar/Avatar.svelte +63 -0
- package/src/Badge/Badge.svelte +42 -0
- package/src/Banner/Banner.svelte +72 -0
- package/src/Banner/BannerDisplay.svelte +41 -0
- package/src/Button/Button.svelte +118 -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 +304 -0
- package/src/DetailSummary/DetailSummary.svelte +92 -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 +45 -0
- 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 +109 -0
- package/src/FancyForm/FancySelect.svelte +147 -0
- package/src/FancyForm/index.js +6 -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 +265 -0
- package/src/Form/Core/Dropzone.svelte +482 -0
- package/src/Form/Core/EnvDropdown.svelte +276 -0
- package/src/Form/Core/File.svelte +115 -0
- package/src/Form/Core/InputDropdown.svelte +235 -0
- package/src/Form/Core/Multiselect.svelte +99 -0
- package/src/Form/Core/Picker.svelte +314 -0
- package/src/Form/Core/PickerDropdown.svelte +431 -0
- package/src/Form/Core/RadioGroup.svelte +65 -0
- package/src/Form/Core/RichTextField.svelte +42 -0
- package/src/Form/Core/Search.svelte +105 -0
- package/src/Form/Core/Select.svelte +90 -0
- package/src/Form/Core/Slider.svelte +86 -0
- package/src/Form/Core/Stepper.svelte +172 -0
- package/src/Form/Core/Switch.svelte +35 -0
- package/src/Form/Core/TextArea.svelte +78 -0
- package/src/Form/Core/TextField.svelte +115 -0
- package/src/Form/Core/index.js +16 -0
- package/src/Form/DatePicker.svelte +46 -0
- package/src/Form/Dropzone.svelte +44 -0
- package/src/Form/EnvDropdown.svelte +50 -0
- package/src/Form/Field.svelte +42 -0
- package/src/Form/FieldLabel.svelte +32 -0
- package/src/Form/File.svelte +37 -0
- package/src/Form/Input.svelte +45 -0
- package/src/Form/InputDropdown.svelte +53 -0
- package/src/Form/Multiselect.svelte +49 -0
- package/src/Form/PickerDropdown.svelte +131 -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 +67 -0
- package/src/Form/Slider.svelte +24 -0
- package/src/Form/Stepper.svelte +45 -0
- package/src/Form/TextArea.svelte +34 -0
- package/src/Form/Toggle.svelte +22 -0
- package/src/Icon/Icon.svelte +94 -0
- package/src/Icon/IconAvatar.svelte +61 -0
- package/src/IconPicker/IconPicker.svelte +184 -0
- package/src/IconSideNav/IconSideNav.svelte +14 -0
- package/src/IconSideNav/IconSideNavItem.svelte +56 -0
- package/src/InlineAlert/InlineAlert.svelte +63 -0
- package/src/Input/CopyInput.svelte +59 -0
- package/src/Label/Label.svelte +31 -0
- package/src/Layout/Layout.svelte +94 -0
- package/src/Layout/Page.svelte +101 -0
- package/src/Link/Link.svelte +27 -0
- package/src/List/List.svelte +28 -0
- package/src/List/ListItem.svelte +93 -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 +94 -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 +37 -0
- package/src/Modal/Modal.svelte +178 -0
- package/src/Modal/Modal.svench +116 -0
- package/src/Modal/ModalContent.svelte +190 -0
- package/src/Modal/QuizModal.svelte +53 -0
- package/src/Notification/Notification.svelte +74 -0
- package/src/Notification/NotificationDisplay.svelte +43 -0
- package/src/Pagination/Pagination.svelte +57 -0
- package/src/Popover/Popover.svelte +95 -0
- package/src/Popover/Popover.svench +120 -0
- package/src/ProgressBar/ProgressBar.svelte +67 -0
- package/src/ProgressCircle/ProgressCircle.svelte +62 -0
- package/src/SideNavigation/Item.svelte +59 -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 +65 -0
- package/src/Stores/notifications.js +84 -0
- package/src/Table/ArrayRenderer.svelte +18 -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 +70 -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 +35 -0
- package/src/Table/SelectEditRenderer.svelte +28 -0
- package/src/Table/StringRenderer.svelte +22 -0
- package/src/Table/Table.svelte +657 -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 +17 -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 +22 -0
- package/src/Typography/Code.svelte +10 -0
- package/src/Typography/Detail.svelte +19 -0
- package/src/Typography/Heading.svelte +24 -0
- package/src/bbui.css +118 -0
- package/src/context.js +4 -0
- package/src/helpers.js +116 -0
- package/src/index.js +109 -0
- package/src/spectrum-icons-rollup.js +31 -0
- package/src/spectrum-icons-vite.js +31 -0
|
@@ -0,0 +1,90 @@
|
|
|
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 useOptionIconImage = false
|
|
15
|
+
export let getOptionColour = () => null
|
|
16
|
+
export let isOptionEnabled
|
|
17
|
+
export let readonly = false
|
|
18
|
+
export let quiet = false
|
|
19
|
+
export let autoWidth = false
|
|
20
|
+
export let autocomplete = false
|
|
21
|
+
export let sort = false
|
|
22
|
+
export let align
|
|
23
|
+
export let footer = null
|
|
24
|
+
|
|
25
|
+
const dispatch = createEventDispatcher()
|
|
26
|
+
|
|
27
|
+
let open = false
|
|
28
|
+
|
|
29
|
+
$: fieldText = getFieldText(value, options, placeholder)
|
|
30
|
+
$: fieldIcon = getFieldAttribute(getOptionIcon, value, options)
|
|
31
|
+
$: fieldColour = getFieldAttribute(getOptionColour, value, options)
|
|
32
|
+
|
|
33
|
+
const getFieldAttribute = (getAttribute, value, options) => {
|
|
34
|
+
// Wait for options to load if there is a value but no options
|
|
35
|
+
if (!options?.length) {
|
|
36
|
+
return ""
|
|
37
|
+
}
|
|
38
|
+
const index = options.findIndex(
|
|
39
|
+
(option, idx) => getOptionValue(option, idx) === value
|
|
40
|
+
)
|
|
41
|
+
return index !== -1 ? getAttribute(options[index], index) : null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const getFieldText = (value, options, placeholder) => {
|
|
45
|
+
if (value == null || value === "") {
|
|
46
|
+
// Explicit false means use no placeholder and allow an empty fields
|
|
47
|
+
if (placeholder === false) {
|
|
48
|
+
return ""
|
|
49
|
+
}
|
|
50
|
+
// Otherwise we use the placeholder if possible
|
|
51
|
+
return placeholder || "Choose an option"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return getFieldAttribute(getOptionLabel, value, options)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const selectOption = value => {
|
|
58
|
+
dispatch("change", value)
|
|
59
|
+
open = false
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<Picker
|
|
64
|
+
on:click
|
|
65
|
+
bind:open
|
|
66
|
+
{quiet}
|
|
67
|
+
{id}
|
|
68
|
+
{error}
|
|
69
|
+
{disabled}
|
|
70
|
+
{readonly}
|
|
71
|
+
{fieldText}
|
|
72
|
+
{fieldIcon}
|
|
73
|
+
{fieldColour}
|
|
74
|
+
{options}
|
|
75
|
+
{autoWidth}
|
|
76
|
+
{align}
|
|
77
|
+
{footer}
|
|
78
|
+
{getOptionLabel}
|
|
79
|
+
{getOptionValue}
|
|
80
|
+
{getOptionIcon}
|
|
81
|
+
{useOptionIconImage}
|
|
82
|
+
{getOptionColour}
|
|
83
|
+
{isOptionEnabled}
|
|
84
|
+
{autocomplete}
|
|
85
|
+
{sort}
|
|
86
|
+
isPlaceholder={value == null || value === ""}
|
|
87
|
+
placeholderOption={placeholder === false ? null : placeholder}
|
|
88
|
+
isOptionSelected={option => option === value}
|
|
89
|
+
onSelectOption={selectOption}
|
|
90
|
+
/>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/slider/dist/index-vars.css"
|
|
3
|
+
import { createEventDispatcher } from "svelte"
|
|
4
|
+
|
|
5
|
+
export let value = false
|
|
6
|
+
export let id = null
|
|
7
|
+
export let disabled = false
|
|
8
|
+
export let min = 0
|
|
9
|
+
export let max = 100
|
|
10
|
+
export let step = 1
|
|
11
|
+
|
|
12
|
+
const dispatch = createEventDispatcher()
|
|
13
|
+
const onChange = event => {
|
|
14
|
+
dispatch("change", event.target.value)
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div>
|
|
19
|
+
<input
|
|
20
|
+
type="range"
|
|
21
|
+
{min}
|
|
22
|
+
{max}
|
|
23
|
+
{step}
|
|
24
|
+
{value}
|
|
25
|
+
{disabled}
|
|
26
|
+
{id}
|
|
27
|
+
on:change={onChange}
|
|
28
|
+
/>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
div {
|
|
33
|
+
display: grid;
|
|
34
|
+
place-items: center;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
input {
|
|
38
|
+
width: 100%;
|
|
39
|
+
padding: 0;
|
|
40
|
+
margin: 0;
|
|
41
|
+
-webkit-appearance: none;
|
|
42
|
+
background: transparent;
|
|
43
|
+
}
|
|
44
|
+
input::-webkit-slider-thumb {
|
|
45
|
+
-webkit-appearance: none;
|
|
46
|
+
}
|
|
47
|
+
input:focus {
|
|
48
|
+
outline: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
52
|
+
-webkit-appearance: none;
|
|
53
|
+
border: 2px solid var(--spectrum-global-color-gray-700);
|
|
54
|
+
height: 16px;
|
|
55
|
+
width: 16px;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
background: var(--background);
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
transition: background 130ms ease-out;
|
|
60
|
+
margin-top: -7px;
|
|
61
|
+
}
|
|
62
|
+
input[type="range"]::-moz-range-thumb {
|
|
63
|
+
border: 2px solid var(--spectrum-global-color-gray-700);
|
|
64
|
+
height: 12px;
|
|
65
|
+
width: 12px;
|
|
66
|
+
border-radius: 50%;
|
|
67
|
+
background: var(--background);
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
transition: background 130ms ease-out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
input[type="range"]::-webkit-slider-runnable-track {
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 2px;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
background: var(--spectrum-global-color-gray-300);
|
|
77
|
+
border-radius: 2px;
|
|
78
|
+
}
|
|
79
|
+
input[type="range"]::-moz-range-track {
|
|
80
|
+
width: 100%;
|
|
81
|
+
height: 2px;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
background: var(--spectrum-global-color-gray-300);
|
|
84
|
+
border-radius: 2px;
|
|
85
|
+
}
|
|
86
|
+
</style>
|
|
@@ -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
|
+
|
|
10
|
+
const dispatch = createEventDispatcher()
|
|
11
|
+
const onChange = event => {
|
|
12
|
+
dispatch("change", event.target.checked)
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div class="spectrum-Switch spectrum-Switch--emphasized">
|
|
17
|
+
<input
|
|
18
|
+
checked={value}
|
|
19
|
+
{disabled}
|
|
20
|
+
on:change={onChange}
|
|
21
|
+
{id}
|
|
22
|
+
type="checkbox"
|
|
23
|
+
class="spectrum-Switch-input"
|
|
24
|
+
/>
|
|
25
|
+
<span class="spectrum-Switch-switch" />
|
|
26
|
+
{#if text}
|
|
27
|
+
<label class="spectrum-Switch-label" for={id}>{text}</label>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.spectrum-Switch-input {
|
|
33
|
+
opacity: 0;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
@@ -0,0 +1,78 @@
|
|
|
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 let height = null
|
|
11
|
+
export let minHeight = null
|
|
12
|
+
export const getCaretPosition = () => ({
|
|
13
|
+
start: textarea.selectionStart,
|
|
14
|
+
end: textarea.selectionEnd,
|
|
15
|
+
})
|
|
16
|
+
export let align = null
|
|
17
|
+
|
|
18
|
+
let focus = false
|
|
19
|
+
let textarea
|
|
20
|
+
const dispatch = createEventDispatcher()
|
|
21
|
+
const onChange = event => {
|
|
22
|
+
dispatch("change", event.target.value)
|
|
23
|
+
focus = false
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const getStyleString = (attribute, value) => {
|
|
27
|
+
if (!attribute || value == null) {
|
|
28
|
+
return ""
|
|
29
|
+
}
|
|
30
|
+
if (isNaN(value)) {
|
|
31
|
+
return `${attribute}:${value};`
|
|
32
|
+
}
|
|
33
|
+
return `${attribute}:${value}px;`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
$: heightString = getStyleString("height", height)
|
|
37
|
+
$: minHeightString = getStyleString("min-height", minHeight)
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<div
|
|
41
|
+
style={`${heightString}${minHeightString}`}
|
|
42
|
+
class="spectrum-Textfield spectrum-Textfield--multiline"
|
|
43
|
+
class:is-invalid={!!error}
|
|
44
|
+
class:is-disabled={disabled}
|
|
45
|
+
class:is-focused={focus}
|
|
46
|
+
>
|
|
47
|
+
{#if error}
|
|
48
|
+
<svg
|
|
49
|
+
class="spectrum-Icon spectrum-Icon--sizeM
|
|
50
|
+
spectrum-Textfield-validationIcon"
|
|
51
|
+
focusable="false"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
>
|
|
54
|
+
<use xlink:href="#spectrum-icon-18-Alert" />
|
|
55
|
+
</svg>
|
|
56
|
+
{/if}
|
|
57
|
+
<!-- prettier-ignore -->
|
|
58
|
+
<textarea
|
|
59
|
+
bind:this={textarea}
|
|
60
|
+
placeholder={placeholder || ""}
|
|
61
|
+
class="spectrum-Textfield-input"
|
|
62
|
+
style={align ? `text-align: ${align}` : ""}
|
|
63
|
+
{disabled}
|
|
64
|
+
{id}
|
|
65
|
+
on:focus={() => (focus = true)}
|
|
66
|
+
on:blur={onChange}
|
|
67
|
+
>{value || ""}</textarea>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
.spectrum-Textfield {
|
|
72
|
+
width: 100%;
|
|
73
|
+
}
|
|
74
|
+
textarea {
|
|
75
|
+
resize: vertical;
|
|
76
|
+
min-height: 80px !important;
|
|
77
|
+
}
|
|
78
|
+
</style>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/textfield/dist/index-vars.css"
|
|
3
|
+
import { createEventDispatcher, onMount } 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 align
|
|
15
|
+
export let autofocus = false
|
|
16
|
+
export let autocomplete = null
|
|
17
|
+
|
|
18
|
+
const dispatch = createEventDispatcher()
|
|
19
|
+
|
|
20
|
+
let field
|
|
21
|
+
let focus = false
|
|
22
|
+
|
|
23
|
+
const updateValue = newValue => {
|
|
24
|
+
if (readonly) {
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
if (type === "number") {
|
|
28
|
+
const float = parseFloat(newValue)
|
|
29
|
+
newValue = isNaN(float) ? null : float
|
|
30
|
+
}
|
|
31
|
+
dispatch("change", newValue)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const onFocus = () => {
|
|
35
|
+
if (readonly) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
focus = true
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const onBlur = event => {
|
|
42
|
+
if (readonly) {
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
focus = false
|
|
46
|
+
updateValue(event.target.value)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const onInput = event => {
|
|
50
|
+
if (readonly || !updateOnChange) {
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
updateValue(event.target.value)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const updateValueOnEnter = event => {
|
|
57
|
+
if (readonly) {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
if (event.key === "Enter") {
|
|
61
|
+
updateValue(event.target.value)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
onMount(() => {
|
|
66
|
+
focus = autofocus
|
|
67
|
+
if (focus) field.focus()
|
|
68
|
+
})
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<div
|
|
72
|
+
class="spectrum-Textfield"
|
|
73
|
+
class:spectrum-Textfield--quiet={quiet}
|
|
74
|
+
class:is-invalid={!!error}
|
|
75
|
+
class:is-disabled={disabled}
|
|
76
|
+
class:is-focused={focus}
|
|
77
|
+
>
|
|
78
|
+
{#if error}
|
|
79
|
+
<svg
|
|
80
|
+
class="spectrum-Icon spectrum-Icon--sizeM spectrum-Textfield-validationIcon"
|
|
81
|
+
focusable="false"
|
|
82
|
+
aria-hidden="true"
|
|
83
|
+
>
|
|
84
|
+
<use xlink:href="#spectrum-icon-18-Alert" />
|
|
85
|
+
</svg>
|
|
86
|
+
{/if}
|
|
87
|
+
<input
|
|
88
|
+
bind:this={field}
|
|
89
|
+
{disabled}
|
|
90
|
+
{readonly}
|
|
91
|
+
{id}
|
|
92
|
+
value={value || ""}
|
|
93
|
+
placeholder={placeholder || ""}
|
|
94
|
+
on:click
|
|
95
|
+
on:blur
|
|
96
|
+
on:focus
|
|
97
|
+
on:input
|
|
98
|
+
on:keyup
|
|
99
|
+
on:blur={onBlur}
|
|
100
|
+
on:focus={onFocus}
|
|
101
|
+
on:input={onInput}
|
|
102
|
+
on:keyup={updateValueOnEnter}
|
|
103
|
+
{type}
|
|
104
|
+
class="spectrum-Textfield-input"
|
|
105
|
+
style={align ? `text-align: ${align};` : ""}
|
|
106
|
+
inputmode={type === "number" ? "decimal" : "text"}
|
|
107
|
+
{autocomplete}
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<style>
|
|
112
|
+
.spectrum-Textfield {
|
|
113
|
+
width: 100%;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
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 CoreCheckboxGroup } from "./CheckboxGroup.svelte"
|
|
7
|
+
export { default as CoreTextArea } from "./TextArea.svelte"
|
|
8
|
+
export { default as CoreCombobox } from "./Combobox.svelte"
|
|
9
|
+
export { default as CoreSwitch } from "./Switch.svelte"
|
|
10
|
+
export { default as CoreSearch } from "./Search.svelte"
|
|
11
|
+
export { default as CoreDatePicker } from "./DatePicker.svelte"
|
|
12
|
+
export { default as CoreDropzone } from "./Dropzone.svelte"
|
|
13
|
+
export { default as CoreStepper } from "./Stepper.svelte"
|
|
14
|
+
export { default as CoreRichTextField } from "./RichTextField.svelte"
|
|
15
|
+
export { default as CoreSlider } from "./Slider.svelte"
|
|
16
|
+
export { default as CoreFile } from "./File.svelte"
|
|
@@ -0,0 +1,46 @@
|
|
|
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 timeOnly = false
|
|
13
|
+
export let time24hr = false
|
|
14
|
+
export let placeholder = null
|
|
15
|
+
export let appendTo = undefined
|
|
16
|
+
export let ignoreTimezones = false
|
|
17
|
+
export let range = false
|
|
18
|
+
const dispatch = createEventDispatcher()
|
|
19
|
+
|
|
20
|
+
const onChange = e => {
|
|
21
|
+
if (range) {
|
|
22
|
+
// Flatpickr cant take two dates and work out what to display, needs to be provided a string.
|
|
23
|
+
// Like - "Date1 to Date2". Hence passing in that specifically from the array
|
|
24
|
+
value = e?.detail[1]
|
|
25
|
+
} else {
|
|
26
|
+
value = e.detail
|
|
27
|
+
}
|
|
28
|
+
dispatch("change", e.detail)
|
|
29
|
+
}
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<Field {label} {labelPosition} {error}>
|
|
33
|
+
<DatePicker
|
|
34
|
+
{error}
|
|
35
|
+
{disabled}
|
|
36
|
+
{value}
|
|
37
|
+
{placeholder}
|
|
38
|
+
{enableTime}
|
|
39
|
+
{timeOnly}
|
|
40
|
+
{time24hr}
|
|
41
|
+
{appendTo}
|
|
42
|
+
{ignoreTimezones}
|
|
43
|
+
{range}
|
|
44
|
+
on:change={onChange}
|
|
45
|
+
/>
|
|
46
|
+
</Field>
|
|
@@ -0,0 +1,44 @@
|
|
|
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 deleteAttachments = undefined
|
|
14
|
+
export let handleFileTooLarge = undefined
|
|
15
|
+
export let handleTooManyFiles = undefined
|
|
16
|
+
export let gallery = true
|
|
17
|
+
export let fileTags = []
|
|
18
|
+
export let maximum = undefined
|
|
19
|
+
export let compact = false
|
|
20
|
+
|
|
21
|
+
const dispatch = createEventDispatcher()
|
|
22
|
+
const onChange = e => {
|
|
23
|
+
value = e.detail
|
|
24
|
+
dispatch("change", e.detail)
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Field {label} {labelPosition} {error}>
|
|
29
|
+
<CoreDropzone
|
|
30
|
+
{error}
|
|
31
|
+
{disabled}
|
|
32
|
+
{value}
|
|
33
|
+
{fileSizeLimit}
|
|
34
|
+
{processFiles}
|
|
35
|
+
{deleteAttachments}
|
|
36
|
+
{handleFileTooLarge}
|
|
37
|
+
{handleTooManyFiles}
|
|
38
|
+
{gallery}
|
|
39
|
+
{fileTags}
|
|
40
|
+
{maximum}
|
|
41
|
+
{compact}
|
|
42
|
+
on:change={onChange}
|
|
43
|
+
/>
|
|
44
|
+
</Field>
|