@budibase/bbui 1.1.1 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +375 -0
- package/README.md +19 -17
- package/dist/bbui.es.js +210 -0
- package/dist/bbui.es.js.map +1 -0
- package/package.json +71 -26
- package/src/ActionButton/ActionButton.svelte +95 -0
- package/src/ActionGroup/ActionGroup.svelte +26 -0
- package/src/ActionMenu/ActionMenu.svelte +44 -0
- package/src/Actions/ClickOutside.svench.svx +30 -0
- package/src/Actions/PositionDropdown.svench.svx +81 -0
- package/src/Actions/autoresize_textarea.js +14 -0
- package/src/Actions/click_outside.js +18 -0
- package/src/Actions/position_dropdown.js +66 -0
- package/src/Avatar/Avatar.svelte +49 -0
- package/src/Badge/Badge.svelte +29 -0
- package/src/Banner/Banner.svelte +72 -0
- package/src/Banner/BannerDisplay.svelte +31 -0
- package/src/Button/Button.svelte +114 -0
- package/src/Button/Button.svench +138 -0
- package/src/ButtonGroup/ButtonGroup.svelte +30 -0
- package/src/ClearButton/ClearButton.svelte +19 -0
- package/src/ColorPicker/ColorPicker.svelte +297 -0
- package/src/DetailSummary/DetailSummary.svelte +83 -0
- package/src/Divider/Divider.svelte +28 -0
- package/src/Drawer/Drawer.svelte +112 -0
- package/src/Drawer/Drawer.svench +42 -0
- package/src/Drawer/DrawerContent.svelte +46 -0
- package/src/Form/Checkbox.svelte +23 -0
- package/src/Form/Combobox.svelte +45 -0
- package/src/Form/Core/Checkbox.svelte +69 -0
- package/src/Form/Core/CheckboxGroup.svelte +68 -0
- package/src/Form/Core/Combobox.svelte +142 -0
- package/src/Form/Core/DatePicker.svelte +242 -0
- package/src/Form/Core/Dropzone.svelte +438 -0
- package/src/Form/Core/Multiselect.svelte +88 -0
- package/src/Form/Core/Picker.svelte +256 -0
- package/src/Form/Core/RadioGroup.svelte +47 -0
- package/src/Form/Core/RichTextField.svelte +42 -0
- package/src/Form/Core/Search.svelte +105 -0
- package/src/Form/Core/Select.svelte +76 -0
- package/src/Form/Core/Slider.svelte +86 -0
- package/src/Form/Core/Stepper.svelte +172 -0
- package/src/Form/Core/Switch.svelte +37 -0
- package/src/Form/Core/TextArea.svelte +78 -0
- package/src/Form/Core/TextField.svelte +119 -0
- package/src/Form/Core/index.js +15 -0
- package/src/Form/DatePicker.svelte +37 -0
- package/src/Form/Dropzone.svelte +40 -0
- package/src/Form/Field.svelte +42 -0
- package/src/Form/FieldLabel.svelte +32 -0
- package/src/Form/Input.svelte +40 -45
- package/src/Form/Multiselect.svelte +39 -0
- package/src/Form/RadioGroup.svelte +40 -0
- package/src/Form/RichTextField.svelte +36 -0
- package/src/Form/Search.svelte +36 -0
- package/src/Form/Select.svelte +48 -43
- package/src/Form/Slider.svelte +24 -0
- package/src/Form/Stepper.svelte +45 -0
- package/src/Form/TextArea.svelte +29 -44
- package/src/Form/Toggle.svelte +23 -0
- package/src/Icon/Icon.svelte +86 -0
- package/src/IconSideNav/IconSideNav.svelte +14 -0
- package/src/IconSideNav/IconSideNavItem.svelte +56 -0
- package/src/InlineAlert/InlineAlert.svelte +56 -0
- package/src/Label/Label.svelte +20 -0
- package/src/Layout/Layout.svelte +94 -0
- package/src/Layout/Page.svelte +32 -0
- package/src/Link/Link.svelte +22 -0
- package/src/List/Items/DetailSummary.svench +46 -8
- package/src/Markdown/MarkdownEditor.svelte +60 -0
- package/src/Markdown/MarkdownViewer.svelte +70 -0
- package/src/Markdown/SpectrumMDE.svelte +184 -0
- package/src/Menu/Item.svelte +45 -0
- package/src/Menu/Menu.svelte +7 -0
- package/src/Menu/Menu.svench +19 -0
- package/src/Menu/Section.svelte +10 -0
- package/src/Menu/Separator.svelte +1 -0
- package/src/Modal/Content.svelte +6 -0
- package/src/Modal/CustomContent.svelte +38 -0
- package/src/Modal/Modal.svelte +142 -0
- package/src/Modal/Modal.svench +117 -0
- package/src/Modal/ModalContent.svelte +190 -0
- package/src/Modal/QuizModal.svelte +54 -0
- package/src/Notification/Notification.svelte +70 -0
- package/src/Notification/NotificationDisplay.svelte +43 -0
- package/src/Pagination/Pagination.svelte +57 -0
- package/src/Popover/Popover.svelte +77 -0
- package/src/Popover/Popover.svench +121 -0
- package/src/ProgressBar/ProgressBar.svelte +54 -0
- package/src/ProgressCircle/ProgressCircle.svelte +62 -0
- package/src/SideNavigation/Item.svelte +47 -0
- package/src/SideNavigation/Navigation.svelte +12 -0
- package/src/StatusLight/StatusLight.svelte +64 -0
- package/src/Stores/Notifications.svench.svx +78 -0
- package/src/Stores/banner.js +37 -0
- package/src/Stores/notifications.js +84 -0
- package/src/Table/ArrayRenderer.svelte +17 -0
- package/src/Table/AttachmentRenderer.svelte +60 -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 +631 -0
- package/src/Table/index.js +1 -0
- package/src/Tabs/Tab.svelte +88 -0
- package/src/Tabs/Tabs.svelte +125 -0
- package/src/Tags/Tag.svelte +43 -0
- package/src/Tags/Tags.svelte +7 -0
- package/src/Tooltip/Tooltip.svelte +30 -0
- package/src/Tooltip/TooltipWrapper.svelte +60 -0
- package/src/TreeView/Item.svelte +41 -0
- package/src/TreeView/Tree.svelte +16 -0
- package/src/Typography/Body.svelte +21 -0
- package/src/Typography/Code.svelte +10 -0
- package/src/Typography/Detail.svelte +19 -0
- package/src/Typography/Heading.svelte +17 -0
- package/src/bbui.css +96 -0
- package/src/context.js +3 -0
- package/src/helpers.js +134 -0
- package/src/index.js +91 -11
- package/src/spectrum-icons-rollup.js +31 -0
- package/src/spectrum-icons-vite.js +31 -0
- package/dist/bundle.css +0 -7
- package/dist/bundle.css.map +0 -20
- package/dist/index.js +0 -1045
- package/dist/index.mjs +0 -1031
- 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/List/Items/DetailSummary.svelte +0 -66
- 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,125 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/tabs/dist/index-vars.css"
|
|
3
|
+
import { writable } from "svelte/store"
|
|
4
|
+
import { onMount, setContext, createEventDispatcher } from "svelte"
|
|
5
|
+
|
|
6
|
+
export let selected
|
|
7
|
+
export let vertical = false
|
|
8
|
+
export let noPadding = false
|
|
9
|
+
// added as a separate option as noPadding is used for vertical padding
|
|
10
|
+
export let noHorizPadding = false
|
|
11
|
+
export let quiet = false
|
|
12
|
+
export let emphasized = false
|
|
13
|
+
export let size = "M"
|
|
14
|
+
|
|
15
|
+
let thisSelected = undefined
|
|
16
|
+
|
|
17
|
+
let _id = id()
|
|
18
|
+
const tab = writable({ title: selected, id: _id, emphasized })
|
|
19
|
+
setContext("tab", tab)
|
|
20
|
+
|
|
21
|
+
let container
|
|
22
|
+
|
|
23
|
+
const dispatch = createEventDispatcher()
|
|
24
|
+
|
|
25
|
+
$: {
|
|
26
|
+
if (thisSelected !== selected) {
|
|
27
|
+
thisSelected = selected
|
|
28
|
+
dispatch("select", thisSelected)
|
|
29
|
+
} else if ($tab.title !== thisSelected) {
|
|
30
|
+
thisSelected = $tab.title
|
|
31
|
+
selected = $tab.title
|
|
32
|
+
dispatch("select", thisSelected)
|
|
33
|
+
}
|
|
34
|
+
if ($tab.title !== thisSelected) {
|
|
35
|
+
tab.update(state => {
|
|
36
|
+
state.title = thisSelected
|
|
37
|
+
return state
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let top, left, width, height
|
|
43
|
+
$: calculateIndicatorLength($tab)
|
|
44
|
+
$: calculateIndicatorOffset($tab)
|
|
45
|
+
|
|
46
|
+
function calculateIndicatorLength() {
|
|
47
|
+
if (!vertical) {
|
|
48
|
+
width = $tab.info?.width + "px"
|
|
49
|
+
height = $tab.info?.height
|
|
50
|
+
} else {
|
|
51
|
+
height = $tab.info?.height + 4 + "px"
|
|
52
|
+
width = $tab.info?.width
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function calculateIndicatorOffset() {
|
|
57
|
+
if (!vertical) {
|
|
58
|
+
left = $tab.info?.left - container?.getBoundingClientRect().left + "px"
|
|
59
|
+
} else {
|
|
60
|
+
top = $tab.info?.top - container?.getBoundingClientRect().top + "px"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
onMount(() => {
|
|
65
|
+
calculateIndicatorLength()
|
|
66
|
+
calculateIndicatorOffset()
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
function id() {
|
|
70
|
+
return "_" + Math.random().toString(36).slice(2, 9)
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<div
|
|
75
|
+
bind:this={container}
|
|
76
|
+
class:spectrum-Tabs--quiet={quiet}
|
|
77
|
+
class:noHorizPadding
|
|
78
|
+
class:spectrum-Tabs--vertical={vertical}
|
|
79
|
+
class:spectrum-Tabs--horizontal={!vertical}
|
|
80
|
+
class="spectrum-Tabs spectrum-Tabs--size{size}"
|
|
81
|
+
>
|
|
82
|
+
<slot />
|
|
83
|
+
{#if $tab.info}
|
|
84
|
+
<div
|
|
85
|
+
class="spectrum-Tabs-selectionIndicator"
|
|
86
|
+
class:emphasized
|
|
87
|
+
style="width: {width}; height: {height}; left: {left}; top: {top};"
|
|
88
|
+
/>
|
|
89
|
+
{/if}
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div
|
|
93
|
+
class="spectrum-Tabs-content spectrum-Tabs-content-{_id}"
|
|
94
|
+
class:noPadding
|
|
95
|
+
/>
|
|
96
|
+
|
|
97
|
+
<style>
|
|
98
|
+
.spectrum-Tabs--quiet {
|
|
99
|
+
border-bottom: none !important;
|
|
100
|
+
}
|
|
101
|
+
.spectrum-Tabs {
|
|
102
|
+
padding-left: var(--spacing-xl);
|
|
103
|
+
padding-right: var(--spacing-xl);
|
|
104
|
+
position: relative;
|
|
105
|
+
border-bottom-color: var(--spectrum-global-color-gray-200);
|
|
106
|
+
}
|
|
107
|
+
.spectrum-Tabs-content {
|
|
108
|
+
margin-top: var(--spectrum-global-dimension-static-size-150);
|
|
109
|
+
}
|
|
110
|
+
.spectrum-Tabs-selectionIndicator {
|
|
111
|
+
transition: all 200ms;
|
|
112
|
+
background-color: var(--spectrum-global-color-gray-900);
|
|
113
|
+
}
|
|
114
|
+
.spectrum-Tabs-selectionIndicator.emphasized {
|
|
115
|
+
background-color: var(--spectrum-global-color-blue-400);
|
|
116
|
+
}
|
|
117
|
+
.spectrum-Tabs--horizontal .spectrum-Tabs-selectionIndicator {
|
|
118
|
+
}
|
|
119
|
+
.noHorizPadding {
|
|
120
|
+
padding: 0;
|
|
121
|
+
}
|
|
122
|
+
.noPadding {
|
|
123
|
+
margin: 0;
|
|
124
|
+
}
|
|
125
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/tags/dist/index-vars.css"
|
|
3
|
+
import Avatar from "../Avatar/Avatar.svelte"
|
|
4
|
+
import ClearButton from "../ClearButton/ClearButton.svelte"
|
|
5
|
+
|
|
6
|
+
export let icon = ""
|
|
7
|
+
export let avatar = ""
|
|
8
|
+
export let invalid = false
|
|
9
|
+
export let disabled = false
|
|
10
|
+
export let closable = false
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div
|
|
14
|
+
class:is-invalid={invalid}
|
|
15
|
+
class:is-disabled={disabled}
|
|
16
|
+
class="spectrum-Tags-item"
|
|
17
|
+
role="listitem"
|
|
18
|
+
>
|
|
19
|
+
{#if avatar}
|
|
20
|
+
<Avatar url={avatar} />
|
|
21
|
+
{/if}
|
|
22
|
+
{#if icon}
|
|
23
|
+
<svg
|
|
24
|
+
class="spectrum-Icon spectrum-Icon--sizeS"
|
|
25
|
+
focusable="false"
|
|
26
|
+
aria-hidden="true"
|
|
27
|
+
aria-label="Tag"
|
|
28
|
+
>
|
|
29
|
+
<use xlink:href="#spectrum-icon-24-{icon}" />
|
|
30
|
+
</svg>
|
|
31
|
+
{/if}
|
|
32
|
+
<span class="spectrum-Tags-itemLabel"><slot /></span>
|
|
33
|
+
{#if closable}
|
|
34
|
+
<ClearButton on:click />
|
|
35
|
+
{/if}
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<style>
|
|
39
|
+
.spectrum-Tags-item {
|
|
40
|
+
margin-top: 0;
|
|
41
|
+
margin-bottom: 0;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/tooltip/dist/index-vars.css"
|
|
3
|
+
|
|
4
|
+
export let direction = "top"
|
|
5
|
+
export let text = ""
|
|
6
|
+
export let textWrapping = false
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<!-- Showing / Hiding a text wrapped tooltip should be handled outside the component -->
|
|
10
|
+
{#if textWrapping}
|
|
11
|
+
<span class="spectrum-Tooltip spectrum-Tooltip--{direction} is-open tooltip">
|
|
12
|
+
<span class="spectrum-Tooltip-label">{text}</span>
|
|
13
|
+
<span class="spectrum-Tooltip-tip" />
|
|
14
|
+
</span>
|
|
15
|
+
{:else}
|
|
16
|
+
<!-- The default show on hover tooltip does not support text wrapping -->
|
|
17
|
+
<span class="u-tooltip-showOnHover tooltip">
|
|
18
|
+
<slot />
|
|
19
|
+
<div class={`spectrum-Tooltip spectrum-Tooltip--${direction}`}>
|
|
20
|
+
<span class="spectrum-Tooltip-label">{text}</span>
|
|
21
|
+
<span class="spectrum-Tooltip-tip" />
|
|
22
|
+
</div>
|
|
23
|
+
</span>
|
|
24
|
+
{/if}
|
|
25
|
+
|
|
26
|
+
<style>
|
|
27
|
+
.tooltip {
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Tooltip from "./Tooltip.svelte"
|
|
3
|
+
import Icon from "../Icon/Icon.svelte"
|
|
4
|
+
|
|
5
|
+
export let tooltip = ""
|
|
6
|
+
export let size = "M"
|
|
7
|
+
|
|
8
|
+
let showTooltip = false
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<div class:container={!!tooltip}>
|
|
12
|
+
<slot />
|
|
13
|
+
{#if tooltip}
|
|
14
|
+
<div class="icon-container">
|
|
15
|
+
<div
|
|
16
|
+
class="icon"
|
|
17
|
+
class:icon-small={size === "M" || size === "S"}
|
|
18
|
+
on:mouseover={() => (showTooltip = true)}
|
|
19
|
+
on:mouseleave={() => (showTooltip = false)}
|
|
20
|
+
on:focus
|
|
21
|
+
>
|
|
22
|
+
<Icon name="InfoOutline" size="S" disabled={true} />
|
|
23
|
+
</div>
|
|
24
|
+
{#if showTooltip}
|
|
25
|
+
<div class="tooltip">
|
|
26
|
+
<Tooltip textWrapping={true} direction={"bottom"} text={tooltip} />
|
|
27
|
+
</div>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
{/if}
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
.container {
|
|
35
|
+
display: flex;
|
|
36
|
+
align-items: center;
|
|
37
|
+
}
|
|
38
|
+
.icon-container {
|
|
39
|
+
position: relative;
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
margin-left: 5px;
|
|
43
|
+
margin-right: 5px;
|
|
44
|
+
}
|
|
45
|
+
.tooltip {
|
|
46
|
+
position: absolute;
|
|
47
|
+
display: flex;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
top: 15px;
|
|
50
|
+
z-index: 100;
|
|
51
|
+
width: 160px;
|
|
52
|
+
}
|
|
53
|
+
.icon {
|
|
54
|
+
transform: scale(0.75);
|
|
55
|
+
}
|
|
56
|
+
.icon-small {
|
|
57
|
+
margin-top: -2px;
|
|
58
|
+
margin-bottom: -5px;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let selected = false
|
|
3
|
+
export let open = false
|
|
4
|
+
export let href = false
|
|
5
|
+
export let title
|
|
6
|
+
export let icon
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<li
|
|
10
|
+
class:is-selected={selected}
|
|
11
|
+
class:is-open={open}
|
|
12
|
+
class="spectrum-TreeView-item"
|
|
13
|
+
>
|
|
14
|
+
<a on:click class="spectrum-TreeView-itemLink" {href}>
|
|
15
|
+
{#if $$slots.default}
|
|
16
|
+
<svg
|
|
17
|
+
class="spectrum-Icon spectrum-UIIcon-ChevronRight100 spectrum-TreeView-itemIndicator"
|
|
18
|
+
focusable="false"
|
|
19
|
+
aria-hidden="true"
|
|
20
|
+
>
|
|
21
|
+
<use xlink:href="#spectrum-css-icon-Chevron100" />
|
|
22
|
+
</svg>
|
|
23
|
+
{/if}
|
|
24
|
+
{#if icon}
|
|
25
|
+
<svg
|
|
26
|
+
class="spectrum-TreeView-itemIcon spectrum-Icon spectrum-Icon--sizeM"
|
|
27
|
+
focusable="false"
|
|
28
|
+
aria-hidden="true"
|
|
29
|
+
aria-label="Layers"
|
|
30
|
+
>
|
|
31
|
+
<use xlink:href="#spectrum-icon-18-{icon}" />
|
|
32
|
+
</svg>
|
|
33
|
+
{/if}
|
|
34
|
+
<span class="spectrum-TreeView-itemLabel">{title}</span>
|
|
35
|
+
</a>
|
|
36
|
+
{#if $$slots.default}
|
|
37
|
+
<ul class="spectrum-TreeView">
|
|
38
|
+
<slot />
|
|
39
|
+
</ul>
|
|
40
|
+
{/if}
|
|
41
|
+
</li>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/treeview/dist/index-vars.css"
|
|
3
|
+
|
|
4
|
+
export let quiet = false
|
|
5
|
+
export let standalone = true
|
|
6
|
+
export let width = "250px"
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<ul
|
|
10
|
+
class:spectrum-TreeView--standalone={standalone}
|
|
11
|
+
class:spectrum-TreeView--quiet={quiet}
|
|
12
|
+
class="spectrum-TreeView"
|
|
13
|
+
style="width: {width}"
|
|
14
|
+
>
|
|
15
|
+
<slot />
|
|
16
|
+
</ul>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/typography/dist/index-vars.css"
|
|
3
|
+
|
|
4
|
+
export let size = "M"
|
|
5
|
+
export let serif = false
|
|
6
|
+
export let weight = null
|
|
7
|
+
export let textAlign = null
|
|
8
|
+
export let color = null
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<p
|
|
12
|
+
style={`
|
|
13
|
+
${weight ? `font-weight:${weight};` : ""}
|
|
14
|
+
${textAlign ? `text-align:${textAlign};` : ""}
|
|
15
|
+
${color ? `color:${color};` : ""}
|
|
16
|
+
`}
|
|
17
|
+
class="spectrum-Body spectrum-Body--size{size}"
|
|
18
|
+
class:spectrum-Body--serif={serif}
|
|
19
|
+
>
|
|
20
|
+
<slot />
|
|
21
|
+
</p>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/typography/dist/index-vars.css"
|
|
3
|
+
|
|
4
|
+
export let size = "M"
|
|
5
|
+
export let serif = false
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<p
|
|
9
|
+
class="spectrum-Detail spectrum-Detail--size{size}"
|
|
10
|
+
class:spectrum-Detail--serif={serif}
|
|
11
|
+
>
|
|
12
|
+
<slot />
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<style>
|
|
16
|
+
p {
|
|
17
|
+
font-weight: 600;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import "@spectrum-css/typography/dist/index-vars.css"
|
|
3
|
+
|
|
4
|
+
// Sizes
|
|
5
|
+
export let size = "M"
|
|
6
|
+
export let textAlign
|
|
7
|
+
export let noPadding = false
|
|
8
|
+
export let weight = "default" // light, heavy, default
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<h1
|
|
12
|
+
style={textAlign ? `text-align:${textAlign}` : ``}
|
|
13
|
+
class:noPadding
|
|
14
|
+
class="spectrum-Heading spectrum-Heading--size{size} spectrum-Heading--{weight}"
|
|
15
|
+
>
|
|
16
|
+
<slot />
|
|
17
|
+
</h1>
|
package/src/bbui.css
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--background: #ffffff;
|
|
3
|
+
--ink: #000000;
|
|
4
|
+
|
|
5
|
+
--grey-1: #fafafa;
|
|
6
|
+
--grey-2: #f5f5f5;
|
|
7
|
+
--grey-3: #eeeeee;
|
|
8
|
+
--grey-4: #e0e0e0;
|
|
9
|
+
--grey-5: #bdbdbd;
|
|
10
|
+
--grey-6: #9e9e9e;
|
|
11
|
+
--grey-7: #757575;
|
|
12
|
+
--grey-8: #616161;
|
|
13
|
+
--grey-9: #424242;
|
|
14
|
+
|
|
15
|
+
--blue-light: #f1f4fc;
|
|
16
|
+
--blue: #4285f4;
|
|
17
|
+
--blue-dark: #2f4c9b;
|
|
18
|
+
|
|
19
|
+
--red-light: #ffe6e6;
|
|
20
|
+
--red: #e26d69;
|
|
21
|
+
--red-dark: #800400;
|
|
22
|
+
|
|
23
|
+
--yellow-light: #fff7e6;
|
|
24
|
+
--yellow: #ffd26a;
|
|
25
|
+
--yellow-dark: #805900;
|
|
26
|
+
|
|
27
|
+
--orange-light: #fff0e6;
|
|
28
|
+
--orange: #f0955a;
|
|
29
|
+
--orange-dark: #803300;
|
|
30
|
+
|
|
31
|
+
--green-light: #e6ffeb;
|
|
32
|
+
--green: #84c991;
|
|
33
|
+
--green-dark: #008017;
|
|
34
|
+
|
|
35
|
+
--purple-light: #e9e6ff;
|
|
36
|
+
--purple: #806fde;
|
|
37
|
+
--purple-dark: #130080;
|
|
38
|
+
|
|
39
|
+
--rounded-small: 4px;
|
|
40
|
+
--rounded-medium: 8px;
|
|
41
|
+
--rounded-large: 16px;
|
|
42
|
+
|
|
43
|
+
--font-sans: Source Sans Pro, -apple-system, BlinkMacSystemFont, Segoe UI, "Inter",
|
|
44
|
+
"Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji",
|
|
45
|
+
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
|
46
|
+
--font-serif: "Georgia", Cambria, Times New Roman, Times, serif;
|
|
47
|
+
--font-mono: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
|
|
48
|
+
monospace;
|
|
49
|
+
|
|
50
|
+
font-size: 16px;
|
|
51
|
+
--font-size-xs: 0.75rem;
|
|
52
|
+
--font-size-s: 0.875rem;
|
|
53
|
+
--font-size-m: 1rem;
|
|
54
|
+
--font-size-l: 1.15rem;
|
|
55
|
+
--font-size-xl: 1.3rem;
|
|
56
|
+
|
|
57
|
+
--heading-font-size-xs: 0.875rem;
|
|
58
|
+
--heading-font-size-s: 1.12rem;
|
|
59
|
+
--heading-font-size-m: 1.5rem;
|
|
60
|
+
--heading-font-size-l: 2.6rem;
|
|
61
|
+
--heading-font-size-xl: 3rem;
|
|
62
|
+
|
|
63
|
+
--font-render: optimizeLegibility;
|
|
64
|
+
--font-smooth: antialiased;
|
|
65
|
+
|
|
66
|
+
--spacing-xs: 0.25rem;
|
|
67
|
+
--spacing-s: 0.5rem;
|
|
68
|
+
--spacing-m: 0.75rem;
|
|
69
|
+
--spacing-l: 1rem;
|
|
70
|
+
--spacing-xl: 1.25rem;
|
|
71
|
+
|
|
72
|
+
--layout-xs: 1.25rem;
|
|
73
|
+
--layout-s: 1.5rem;
|
|
74
|
+
--layout-m: 2rem;
|
|
75
|
+
--layout-l: 3rem;
|
|
76
|
+
--layout-xl: 4rem;
|
|
77
|
+
|
|
78
|
+
--border-radius-xs: 0.125rem;
|
|
79
|
+
--border-radius-s: 0.35rem;
|
|
80
|
+
--border-radius-m: 0.5rem;
|
|
81
|
+
--border-radius-l: 1rem;
|
|
82
|
+
--border-radius-xl: 100rem;
|
|
83
|
+
|
|
84
|
+
--border-black: 2px var(--ink) solid;
|
|
85
|
+
--border-dark: 2px var(--grey-7) solid;
|
|
86
|
+
--border-grey: 1px var(--grey-4) solid;
|
|
87
|
+
--border-grey-2: 2px var(--grey-4) solid;
|
|
88
|
+
--border-light: 1px var(--grey-3) solid;
|
|
89
|
+
--border-light-2: 2px var(--grey-3) solid;
|
|
90
|
+
--border-blue: 2px var(--blue) solid;
|
|
91
|
+
--border-transparent: 2px transparent solid;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
a {
|
|
95
|
+
text-decoration: none;
|
|
96
|
+
}
|
package/src/context.js
ADDED
package/src/helpers.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a DOM safe UUID.
|
|
3
|
+
* Starting with a letter is important to make it DOM safe.
|
|
4
|
+
* @return {string} a random DOM safe UUID
|
|
5
|
+
*/
|
|
6
|
+
export function uuid() {
|
|
7
|
+
return "cxxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, c => {
|
|
8
|
+
const r = (Math.random() * 16) | 0
|
|
9
|
+
const v = c === "x" ? r : (r & 0x3) | 0x8
|
|
10
|
+
return v.toString(16)
|
|
11
|
+
})
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Capitalises a string
|
|
16
|
+
* @param string the string to capitalise
|
|
17
|
+
* @return {string} the capitalised string
|
|
18
|
+
*/
|
|
19
|
+
export const capitalise = string => {
|
|
20
|
+
if (!string) {
|
|
21
|
+
return string
|
|
22
|
+
}
|
|
23
|
+
return string.substring(0, 1).toUpperCase() + string.substring(1)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Computes a short hash of a string
|
|
28
|
+
* @param string the string to compute a hash of
|
|
29
|
+
* @return {string} the hash string
|
|
30
|
+
*/
|
|
31
|
+
export const hashString = string => {
|
|
32
|
+
if (!string) {
|
|
33
|
+
return "0"
|
|
34
|
+
}
|
|
35
|
+
let hash = 0
|
|
36
|
+
for (let i = 0; i < string.length; i++) {
|
|
37
|
+
let char = string.charCodeAt(i)
|
|
38
|
+
hash = (hash << 5) - hash + char
|
|
39
|
+
hash = hash & hash // Convert to 32bit integer
|
|
40
|
+
}
|
|
41
|
+
return hash.toString()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Gets a key within an object. The key supports dot syntax for retrieving deep
|
|
46
|
+
* fields - e.g. "a.b.c".
|
|
47
|
+
* Exact matches of keys with dots in them take precedence over nested keys of
|
|
48
|
+
* the same path - e.g. getting "a.b" from { "a.b": "foo", a: { b: "bar" } }
|
|
49
|
+
* will return "foo" over "bar".
|
|
50
|
+
* @param obj the object
|
|
51
|
+
* @param key the key
|
|
52
|
+
* @return {*|null} the value or null if a value was not found for this key
|
|
53
|
+
*/
|
|
54
|
+
export const deepGet = (obj, key) => {
|
|
55
|
+
if (!obj || !key) {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
59
|
+
return obj[key]
|
|
60
|
+
}
|
|
61
|
+
const split = key.split(".")
|
|
62
|
+
for (let i = 0; i < split.length; i++) {
|
|
63
|
+
obj = obj?.[split[i]]
|
|
64
|
+
}
|
|
65
|
+
return obj
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Sets a key within an object. The key supports dot syntax for retrieving deep
|
|
70
|
+
* fields - e.g. "a.b.c".
|
|
71
|
+
* Exact matches of keys with dots in them take precedence over nested keys of
|
|
72
|
+
* the same path - e.g. setting "a.b" of { "a.b": "foo", a: { b: "bar" } }
|
|
73
|
+
* will override the value "foo" rather than "bar".
|
|
74
|
+
* If a deep path is specified and the parent keys don't exist then these will
|
|
75
|
+
* be created.
|
|
76
|
+
* @param obj the object
|
|
77
|
+
* @param key the key
|
|
78
|
+
* @param value the value
|
|
79
|
+
*/
|
|
80
|
+
export const deepSet = (obj, key, value) => {
|
|
81
|
+
if (!obj || !key) {
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
85
|
+
obj[key] = value
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
const split = key.split(".")
|
|
89
|
+
for (let i = 0; i < split.length - 1; i++) {
|
|
90
|
+
const nextKey = split[i]
|
|
91
|
+
if (obj && obj[nextKey] == null) {
|
|
92
|
+
obj[nextKey] = {}
|
|
93
|
+
}
|
|
94
|
+
obj = obj?.[nextKey]
|
|
95
|
+
}
|
|
96
|
+
if (!obj) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
obj[split[split.length - 1]] = value
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Deeply clones an object. Functions are not supported.
|
|
104
|
+
* @param obj the object to clone
|
|
105
|
+
*/
|
|
106
|
+
export const cloneDeep = obj => {
|
|
107
|
+
return JSON.parse(JSON.stringify(obj))
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Copies a value to the clipboard
|
|
112
|
+
* @param value the value to copy
|
|
113
|
+
*/
|
|
114
|
+
export const copyToClipboard = value => {
|
|
115
|
+
return new Promise(res => {
|
|
116
|
+
if (navigator.clipboard && window.isSecureContext) {
|
|
117
|
+
// Try using the clipboard API first
|
|
118
|
+
navigator.clipboard.writeText(value).then(res)
|
|
119
|
+
} else {
|
|
120
|
+
// Fall back to the textarea hack
|
|
121
|
+
let textArea = document.createElement("textarea")
|
|
122
|
+
textArea.value = value
|
|
123
|
+
textArea.style.position = "fixed"
|
|
124
|
+
textArea.style.left = "-9999px"
|
|
125
|
+
textArea.style.top = "-9999px"
|
|
126
|
+
document.body.appendChild(textArea)
|
|
127
|
+
textArea.focus()
|
|
128
|
+
textArea.select()
|
|
129
|
+
document.execCommand("copy")
|
|
130
|
+
textArea.remove()
|
|
131
|
+
res()
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|