@splendidlabz/svelte 0.4.0
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/.eslintrc.cjs +3 -0
- package/CHANGELOG.md +91 -0
- package/actions/breakpoint-observer.js +71 -0
- package/actions/index.js +6 -0
- package/actions/portal.js +20 -0
- package/actions/resize-observer.js +43 -0
- package/actions/scroll-observer.js +47 -0
- package/common.js +21 -0
- package/components/Accordion/Accordion.svelte +108 -0
- package/components/Accordion/index.js +3 -0
- package/components/Breadcrumbs/Breadcrumbs.svelte +69 -0
- package/components/Breadcrumbs/Crumb.svelte +37 -0
- package/components/Breadcrumbs/CrumbCustom.svelte +14 -0
- package/components/Breadcrumbs/index.js +5 -0
- package/components/BrowserFrame.svelte +37 -0
- package/components/BrowserWithTabs.svelte +28 -0
- package/components/CQChecker/CQChecker.astro +20 -0
- package/components/CQChecker/CQChecker.svelte +89 -0
- package/components/Callout/Callout.svelte +17 -0
- package/components/Callout/index.js +3 -0
- package/components/Codepen/Codepen.astro +29 -0
- package/components/Codepen/Codepen.svelte +24 -0
- package/components/Codepen/index.js +3 -0
- package/components/ContentList/ContentList-old.svelte +117 -0
- package/components/ContentList/ContentList.svelte +68 -0
- package/components/ContentList/index.js +3 -0
- package/components/Disclosure/Drawer/Drawer.svelte +35 -0
- package/components/Disclosure/Drawer/DrawerCloseButton.svelte +31 -0
- package/components/Disclosure/Drawer/DrawerContent-wrecked.svelte +198 -0
- package/components/Disclosure/Drawer/DrawerContent.svelte +164 -0
- package/components/Disclosure/Drawer/DrawerTrigger.svelte +32 -0
- package/components/Disclosure/Drawer/drawer.js +112 -0
- package/components/Disclosure/Drawer/index.js +6 -0
- package/components/Disclosure/Dropdown/DropdownContent.svelte +15 -0
- package/components/Disclosure/Dropdown/DropdownTrigger.svelte +14 -0
- package/components/Disclosure/Dropdown/dropdown.js +4 -0
- package/components/Disclosure/Dropdown/index.js +4 -0
- package/components/Disclosure/Modal/ModalContent.svelte +3 -0
- package/components/Disclosure/Modal/ModalTrigger.svelte +33 -0
- package/components/Disclosure/Modal/exit-intent.js +17 -0
- package/components/Disclosure/Modal/modal.js +13 -0
- package/components/Disclosure/Popover/PopoverCloseButton.svelte +29 -0
- package/components/Disclosure/Popover/PopoverContent.svelte +107 -0
- package/components/Disclosure/Popover/PopoverTrigger.svelte +33 -0
- package/components/Disclosure/Popover/floating.js +171 -0
- package/components/Disclosure/Popover/index.js +5 -0
- package/components/Disclosure/Popover/popover.js +18 -0
- package/components/Disclosure/Popover/references/FollowTheMouse.svelte +45 -0
- package/components/Disclosure/Tooltip/Tooltip.svelte +14 -0
- package/components/Disclosure/Tooltip/TooltipContent.svelte +7 -0
- package/components/Disclosure/Tooltip/TooltipTrigger.svelte +33 -0
- package/components/Disclosure/Tooltip/index.js +5 -0
- package/components/Disclosure/Tooltip/tooltip.js +22 -0
- package/components/Disclosure/disclosure-store.js +48 -0
- package/components/Disclosure/disclosure.js +439 -0
- package/components/Disclosure/index.js +3 -0
- package/components/Disclosure/state.svelte.js +138 -0
- package/components/FancyList/FancyList.svelte +49 -0
- package/components/FancyList/index.js +3 -0
- package/components/Form/Button.svelte +24 -0
- package/components/Form/Checkbox.svelte +80 -0
- package/components/Form/Checkboxes.svelte +48 -0
- package/components/Form/Combobox/AutocompleteInput.svelte +63 -0
- package/components/Form/Combobox/AutocompleteOptions.svelte +74 -0
- package/components/Form/Combobox/TimepickerInput.svelte +81 -0
- package/components/Form/Combobox/TimepickerOptions.svelte +100 -0
- package/components/Form/Combobox/autocomplete-matching.js +114 -0
- package/components/Form/Combobox/autocomplete.js +393 -0
- package/components/Form/Combobox/combobox-store.js +65 -0
- package/components/Form/Combobox/combobox.js +359 -0
- package/components/Form/Combobox/index.js +14 -0
- package/components/Form/Combobox/timepicker.js +119 -0
- package/components/Form/Form.svelte +62 -0
- package/components/Form/Hidden.svelte +16 -0
- package/components/Form/Radio.svelte +69 -0
- package/components/Form/Radios.svelte +50 -0
- package/components/Form/Select.svelte +127 -0
- package/components/Form/Switch.svelte +50 -0
- package/components/Form/TextInput.svelte +87 -0
- package/components/Form/Textarea.svelte +103 -0
- package/components/Form/check.svg +3 -0
- package/components/Form/index.js +12 -0
- package/components/Highlight/Highlight.svelte +27 -0
- package/components/Highlight/_Highlight.scss +19 -0
- package/components/Highlight/index.js +2 -0
- package/components/Image.svelte +24 -0
- package/components/InteractiveRegion/InteractiveRegion.svelte +47 -0
- package/components/InteractiveRegion/index.js +3 -0
- package/components/List/Lia.svelte +12 -0
- package/components/List/NestedListItem.svelte +50 -0
- package/components/List/index.js +3 -0
- package/components/Markdown/Markdown.svelte +35 -0
- package/components/Masonry/Masonry.svelte +79 -0
- package/components/Masonry/index.js +3 -0
- package/components/PerspectiveHover/PerspectiveHover.svelte +10 -0
- package/components/PerspectiveHover/perspective-hover.js +46 -0
- package/components/Populate/ConditionalPopulate.svelte +33 -0
- package/components/Populate/Populate.svelte +45 -0
- package/components/Populate/actions.js +29 -0
- package/components/Populate/get-value.js +17 -0
- package/components/Populate/index.js +4 -0
- package/components/Portal.svelte +27 -0
- package/components/PushToLocalStorage.svelte +30 -0
- package/components/Resizer/Resizer.svelte +32 -0
- package/components/Resizer/draggable.js +23 -0
- package/components/Resizer/index.js +3 -0
- package/components/Resizer/resizer.js +133 -0
- package/components/SVG/SVG.svelte +120 -0
- package/components/Scrambler/Scrambler.svelte +27 -0
- package/components/Scrambler/index.js +3 -0
- package/components/Spotlight/PointerPosition.js +32 -0
- package/components/Spotlight/Spotlight.svelte +9 -0
- package/components/Status.svelte +27 -0
- package/components/Switcheroo/Switcheroo.svelte +71 -0
- package/components/Switcheroo/index.js +3 -0
- package/components/Table/RowGroup.svelte +8 -0
- package/components/Table/Table.svelte +23 -0
- package/components/Table/Td.svelte +20 -0
- package/components/Table/Th.svelte +27 -0
- package/components/Table/Thead.svelte +8 -0
- package/components/Table/Tr.svelte +8 -0
- package/components/Table/index.js +17 -0
- package/components/Table/table.js +35 -0
- package/components/Tabs/Tab.svelte +12 -0
- package/components/Tabs/Tablist.svelte +62 -0
- package/components/Tabs/Tabpanel.svelte +10 -0
- package/components/Tabs/Tabpanels.svelte +12 -0
- package/components/Tabs/index.js +6 -0
- package/components/Tabs/tab-store.js +60 -0
- package/components/Tabs/tabs.js +364 -0
- package/components/Tabs-Old/Tab.svelte +9 -0
- package/components/Tabs-Old/Tablist.svelte +13 -0
- package/components/Tabs-Old/Tabpanel.svelte +10 -0
- package/components/Tabs-Old/Tabpanels.svelte +14 -0
- package/components/Tabs-Old/Tabs.svelte +83 -0
- package/components/Tabs-Old/index.js +7 -0
- package/components/Tabs-Old/tabs.js +306 -0
- package/components/Textwall/Repeat.svelte +10 -0
- package/components/Textwall/Textwall.svelte +30 -0
- package/components/Textwall/index.js +4 -0
- package/components/Typewriter/Typewriter.svelte +70 -0
- package/components/Typewriter/index.js +3 -0
- package/components/Video.svelte +46 -0
- package/components/Vimeo.svelte +18 -0
- package/components/Wrapper.svelte +22 -0
- package/components/Youtube.svelte +15 -0
- package/components/_shared/accessibility.js +9 -0
- package/components/_shared/key.js +1 -0
- package/components/_shared/transitions.js +48 -0
- package/components/_shared/use-actions.js +31 -0
- package/index.js +35 -0
- package/jsconfig.json +5 -0
- package/package.json +39 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { toTitle } from '@splendidlabz/utils'
|
|
3
|
+
import { randomString } from '@splendidlabz/utils/dom'
|
|
4
|
+
import SVG from '../SVG/SVG.svelte'
|
|
5
|
+
import Hidden from './Hidden.svelte'
|
|
6
|
+
|
|
7
|
+
let klass = ''
|
|
8
|
+
export { klass as class }
|
|
9
|
+
export let icon = null // tabler-selector, ph:caret-up-down
|
|
10
|
+
export let iconClass = null
|
|
11
|
+
|
|
12
|
+
export let label = ''
|
|
13
|
+
export let id = ''
|
|
14
|
+
export let name
|
|
15
|
+
export let selected = null
|
|
16
|
+
export let items = []
|
|
17
|
+
export let required = null
|
|
18
|
+
export let readonly = null
|
|
19
|
+
export let disabled = null
|
|
20
|
+
export let multiple = null
|
|
21
|
+
export let size = 0 // Number of lines to show, useful for multiselect, 0, but show 4 lines by default.
|
|
22
|
+
export let ref = null
|
|
23
|
+
|
|
24
|
+
id = id || randomString(8)
|
|
25
|
+
|
|
26
|
+
// Autofix multiple
|
|
27
|
+
if (multiple) {
|
|
28
|
+
if (!name.endsWith('[]')) name = name += '[]'
|
|
29
|
+
if (!Array.isArray(selected)) selected = []
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Normalize items
|
|
33
|
+
items = items.map(option => {
|
|
34
|
+
if (typeof option === 'string') option = { value: option }
|
|
35
|
+
if (!option.label) option.label = toTitle(option.value)
|
|
36
|
+
|
|
37
|
+
// Updated selected & item.selected
|
|
38
|
+
if (multiple) {
|
|
39
|
+
if (selected.includes(option.value)) option.selected = true
|
|
40
|
+
if (option.selected && !selected.includes(option.value))
|
|
41
|
+
selected.push(option.value)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!multiple) {
|
|
45
|
+
if (option.value === selected) option.selected = true
|
|
46
|
+
if (option.selected) selected = option.value
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return option
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
// If none selected, preselect first item that is not disabled. (Single only)
|
|
53
|
+
if (!multiple && !selected) {
|
|
54
|
+
const firstNotDisabled = items.findIndex(item => !item.disabled)
|
|
55
|
+
const s = items[firstNotDisabled] || items[0]
|
|
56
|
+
s.selected = true
|
|
57
|
+
selected = s.value
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const props = {
|
|
61
|
+
id,
|
|
62
|
+
name,
|
|
63
|
+
required,
|
|
64
|
+
size,
|
|
65
|
+
disabled: disabled || readonly,
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<div class="TextField Select {klass}">
|
|
70
|
+
<label class="Label" for={id}>{label}</label>
|
|
71
|
+
<div class="InputGroup items-center" class:Stack={!multiple}>
|
|
72
|
+
{#if !multiple}
|
|
73
|
+
<select {...props} bind:value={selected} on:change {...$$restProps}>
|
|
74
|
+
{#each items as option}
|
|
75
|
+
{@const { label: optionLabel, ...rest } = option}
|
|
76
|
+
<option {...rest} value={option.value}>
|
|
77
|
+
{optionLabel}
|
|
78
|
+
</option>
|
|
79
|
+
{/each}
|
|
80
|
+
</select>
|
|
81
|
+
{#if readonly}
|
|
82
|
+
<Hidden {name} value={selected} />
|
|
83
|
+
{/if}
|
|
84
|
+
{:else}
|
|
85
|
+
<!-- Svelte requires multiple to be passed as a standard attribute for it to bind to an array value, hence the duplication here. -->
|
|
86
|
+
<select
|
|
87
|
+
{...props}
|
|
88
|
+
multiple
|
|
89
|
+
bind:value={selected}
|
|
90
|
+
on:change
|
|
91
|
+
bind:this={ref}
|
|
92
|
+
{...$$restProps}
|
|
93
|
+
>
|
|
94
|
+
{#each items as option}
|
|
95
|
+
{@const { label: optionLabel, ...rest } = option}
|
|
96
|
+
<option {...rest} value={option.value}>
|
|
97
|
+
{optionLabel}
|
|
98
|
+
</option>
|
|
99
|
+
{/each}
|
|
100
|
+
</select>
|
|
101
|
+
|
|
102
|
+
{#if readonly}
|
|
103
|
+
{#each selected as item}
|
|
104
|
+
<Hidden {name} value={item} />
|
|
105
|
+
{/each}
|
|
106
|
+
{/if}
|
|
107
|
+
{/if}
|
|
108
|
+
|
|
109
|
+
{#if !multiple}
|
|
110
|
+
<div class="Pos-right pointer-events-none" class:disabled class:readonly>
|
|
111
|
+
{#if icon}
|
|
112
|
+
<SVG class={iconClass} {icon} />
|
|
113
|
+
{:else}
|
|
114
|
+
<svg class={iconClass} width="24" height="24" viewBox="0 0 24 24">
|
|
115
|
+
<path
|
|
116
|
+
d="M8 9L12 5L16 9M16 15L12 19L8 15"
|
|
117
|
+
stroke="currentcolor"
|
|
118
|
+
stroke-width="2"
|
|
119
|
+
stroke-linecap="round"
|
|
120
|
+
stroke-linejoin="round"
|
|
121
|
+
/>
|
|
122
|
+
</svg>
|
|
123
|
+
{/if}
|
|
124
|
+
</div>
|
|
125
|
+
{/if}
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { createEventDispatcher } from 'svelte'
|
|
3
|
+
|
|
4
|
+
let klass = ''
|
|
5
|
+
export { klass as class }
|
|
6
|
+
export let name
|
|
7
|
+
export let ref
|
|
8
|
+
export let checked = false
|
|
9
|
+
|
|
10
|
+
let labels = {
|
|
11
|
+
left: undefined,
|
|
12
|
+
right: undefined,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const dispatch = createEventDispatcher()
|
|
16
|
+
|
|
17
|
+
function change(event) {
|
|
18
|
+
checked = event.target.checked
|
|
19
|
+
|
|
20
|
+
// Revert Aria attributes
|
|
21
|
+
labels.left.removeAttribute('aria-hidden')
|
|
22
|
+
labels.right.removeAttribute('aria-hidden')
|
|
23
|
+
|
|
24
|
+
// Hide labels
|
|
25
|
+
if (checked) {
|
|
26
|
+
labels.left.setAttribute('aria-hidden', 'true')
|
|
27
|
+
} else {
|
|
28
|
+
labels.right.setAttribute('aria-hidden', 'true')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
dispatch('change', { checked })
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<label class="Switch {klass}">
|
|
36
|
+
<span aria-hidden="true" bind:this={labels.left}>
|
|
37
|
+
<slot name="left-label" />
|
|
38
|
+
</span>
|
|
39
|
+
<input
|
|
40
|
+
{name}
|
|
41
|
+
type="checkbox"
|
|
42
|
+
role="switch"
|
|
43
|
+
on:change={change}
|
|
44
|
+
bind:this={ref}
|
|
45
|
+
bind:checked
|
|
46
|
+
/>
|
|
47
|
+
<span aria-hidden="true" bind:this={labels.right}>
|
|
48
|
+
<slot name="right-label" />
|
|
49
|
+
</span>
|
|
50
|
+
</label>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { randomString } from '@splendidlabz/utils/dom'
|
|
3
|
+
import { useActions } from '../_shared/use-actions'
|
|
4
|
+
let klass = ''
|
|
5
|
+
export { klass as class }
|
|
6
|
+
export let style = null
|
|
7
|
+
export let labelClass = ''
|
|
8
|
+
export let hintClass = ''
|
|
9
|
+
export let errorClass = ''
|
|
10
|
+
export let inputGroupClass = ''
|
|
11
|
+
export let fieldClass = ''
|
|
12
|
+
|
|
13
|
+
export let type = 'text'
|
|
14
|
+
export let id = null
|
|
15
|
+
export let name
|
|
16
|
+
export let label = ''
|
|
17
|
+
export let hint = null
|
|
18
|
+
export let error = null
|
|
19
|
+
export let value = null
|
|
20
|
+
export let placeholder = null
|
|
21
|
+
export let disabled = null
|
|
22
|
+
export let readonly = null
|
|
23
|
+
export let ref = null
|
|
24
|
+
export let actions = []
|
|
25
|
+
export let Stack = false
|
|
26
|
+
|
|
27
|
+
if (!name) throw new Error('TextInput requires a name')
|
|
28
|
+
|
|
29
|
+
const SUPPORTED_TYPES = ['text', 'email', 'password', 'search', 'url', 'tel']
|
|
30
|
+
// Other possible types
|
|
31
|
+
// date, number, time, week, file, image, month, number, radio, color
|
|
32
|
+
if (!SUPPORTED_TYPES.includes(type)) {
|
|
33
|
+
throw new Error(`Invalid type: ${type}`)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// IDs for aria-describedby
|
|
37
|
+
id = id || randomString(8)
|
|
38
|
+
const hintId = hint ? id + '-hint' : ''
|
|
39
|
+
const errorId = error ? id + '-error' : ''
|
|
40
|
+
const describedBy = `${hintId} ${errorId}`.trim() || null
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div class="TextField TextInput {klass}" {style} class:disabled class:readonly>
|
|
44
|
+
{#if label}
|
|
45
|
+
<label class="Label {labelClass}" for={id}>{label}</label>
|
|
46
|
+
{/if}
|
|
47
|
+
{#if hint}
|
|
48
|
+
<div id={hintId} class="Hint {hintClass}">{hint}</div>
|
|
49
|
+
{/if}
|
|
50
|
+
{#if error}
|
|
51
|
+
<output id={errorId} class="Error {errorClass}" for={id}>{error}</output>
|
|
52
|
+
{/if}
|
|
53
|
+
|
|
54
|
+
<div class="InputGroup {inputGroupClass}" class:Stack>
|
|
55
|
+
{#if $$slots.before}
|
|
56
|
+
<slot name="before" />
|
|
57
|
+
{#if !Stack}<div class="Divider-vertical"></div>{/if}
|
|
58
|
+
{/if}
|
|
59
|
+
<input
|
|
60
|
+
{id}
|
|
61
|
+
class="Field {fieldClass}"
|
|
62
|
+
{name}
|
|
63
|
+
{...{ type }}
|
|
64
|
+
{placeholder}
|
|
65
|
+
{disabled}
|
|
66
|
+
{readonly}
|
|
67
|
+
aria-describedby={describedBy}
|
|
68
|
+
aria-invalid={error ? 'true' : null}
|
|
69
|
+
on:input
|
|
70
|
+
on:change
|
|
71
|
+
on:focus
|
|
72
|
+
on:blur
|
|
73
|
+
on:click
|
|
74
|
+
on:keydown
|
|
75
|
+
on:keyup
|
|
76
|
+
on:keypress
|
|
77
|
+
bind:this={ref}
|
|
78
|
+
bind:value
|
|
79
|
+
use:useActions={actions}
|
|
80
|
+
{...$$restProps}
|
|
81
|
+
/>
|
|
82
|
+
{#if $$slots.after}
|
|
83
|
+
{#if !Stack}<div class="Divider-vertical"></div>{/if}
|
|
84
|
+
<slot name="after" />
|
|
85
|
+
{/if}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { randomString } from '@splendidlabz/utils/dom'
|
|
3
|
+
import { useActions } from '../_shared/use-actions'
|
|
4
|
+
|
|
5
|
+
let klass = ''
|
|
6
|
+
export { klass as class }
|
|
7
|
+
export let style = null
|
|
8
|
+
export let labelClass = ''
|
|
9
|
+
export let hintClass = ''
|
|
10
|
+
export let errorClass = ''
|
|
11
|
+
export let inputGroupClass = ''
|
|
12
|
+
export let fieldClass = ''
|
|
13
|
+
|
|
14
|
+
export let name
|
|
15
|
+
export let id = null
|
|
16
|
+
export let label = ''
|
|
17
|
+
export let hint = null
|
|
18
|
+
export let error = null
|
|
19
|
+
export let value = null
|
|
20
|
+
export let placeholder = null
|
|
21
|
+
export let disabled = null
|
|
22
|
+
export let readonly = null
|
|
23
|
+
export let ref = null
|
|
24
|
+
export let actions = []
|
|
25
|
+
|
|
26
|
+
export let options = { autogrow: false }
|
|
27
|
+
|
|
28
|
+
if (!name) throw new Error('Textarea requires a name')
|
|
29
|
+
|
|
30
|
+
// IDs for aria-describedby
|
|
31
|
+
id = id || randomString(8)
|
|
32
|
+
const hintId = hint ? id + '-hint' : ''
|
|
33
|
+
const errorId = error ? id + '-error' : ''
|
|
34
|
+
const describedBy = `${hintId} ${errorId}`.trim() || null
|
|
35
|
+
|
|
36
|
+
let dummyRef
|
|
37
|
+
|
|
38
|
+
// Think about auto-growing textarea
|
|
39
|
+
function autoGrow(event) {
|
|
40
|
+
if (options.autogrow) {
|
|
41
|
+
dummyRef.textContent = event.target.value
|
|
42
|
+
const last = event.target.value.slice(-1)
|
|
43
|
+
if (last === '\n') dummyRef.textContent += ' '
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
class="TextField Textarea {klass}"
|
|
50
|
+
class:disabled
|
|
51
|
+
class:readonly
|
|
52
|
+
class:Textarea-autogrow={options.autogrow}
|
|
53
|
+
{style}
|
|
54
|
+
>
|
|
55
|
+
{#if label}
|
|
56
|
+
<label class="Label {labelClass}" for={id}>{label}</label>
|
|
57
|
+
{/if}
|
|
58
|
+
{#if hint}
|
|
59
|
+
<div id={hintId} class="Hint {hintClass}">{hint}</div>
|
|
60
|
+
{/if}
|
|
61
|
+
{#if error}
|
|
62
|
+
<output id={errorId} class="Error {errorClass}" for={id}>{error}</output>
|
|
63
|
+
{/if}
|
|
64
|
+
|
|
65
|
+
<div class="InputGroup {inputGroupClass}">
|
|
66
|
+
{#if $$slots.before}
|
|
67
|
+
<slot name="before" />
|
|
68
|
+
<div class="Divider-vertical"></div>
|
|
69
|
+
{/if}
|
|
70
|
+
|
|
71
|
+
<div class="Field Stack">
|
|
72
|
+
<div class="Replica Field" bind:this={dummyRef}></div>
|
|
73
|
+
|
|
74
|
+
<textarea
|
|
75
|
+
{id}
|
|
76
|
+
class="Field {fieldClass}"
|
|
77
|
+
{name}
|
|
78
|
+
{placeholder}
|
|
79
|
+
{disabled}
|
|
80
|
+
{readonly}
|
|
81
|
+
aria-describedby={describedBy}
|
|
82
|
+
aria-invalid={error ? 'true' : null}
|
|
83
|
+
on:input={autoGrow}
|
|
84
|
+
on:change
|
|
85
|
+
on:focus
|
|
86
|
+
on:blur
|
|
87
|
+
on:click
|
|
88
|
+
on:keydown
|
|
89
|
+
on:keyup
|
|
90
|
+
on:keypress
|
|
91
|
+
bind:this={ref}
|
|
92
|
+
bind:value
|
|
93
|
+
use:useActions={actions}
|
|
94
|
+
{...$$restProps}
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
{#if $$slots.after}
|
|
99
|
+
<div class="Divider-vertical"></div>
|
|
100
|
+
<slot name="after" />
|
|
101
|
+
{/if}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as Button } from './Button.svelte'
|
|
2
|
+
export { default as Checkbox } from './Checkbox.svelte'
|
|
3
|
+
export { default as Checkboxes } from './Checkboxes.svelte'
|
|
4
|
+
export * from './Combobox/index.js'
|
|
5
|
+
export { default as Form } from './Form.svelte'
|
|
6
|
+
export { default as Hidden } from './Hidden.svelte'
|
|
7
|
+
export { default as Radio } from './Radio.svelte'
|
|
8
|
+
export { default as Radios } from './Radios.svelte'
|
|
9
|
+
export { default as Select } from './Select.svelte'
|
|
10
|
+
export { default as Switch } from './Switch.svelte'
|
|
11
|
+
export { default as TextInput } from './TextInput.svelte'
|
|
12
|
+
export { default as Textarea } from './Textarea.svelte'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { toStyleString } from '@splendidlabz/utils'
|
|
3
|
+
export let color
|
|
4
|
+
export let top
|
|
5
|
+
export let bottom
|
|
6
|
+
|
|
7
|
+
let style
|
|
8
|
+
|
|
9
|
+
if (!top && !bottom) {
|
|
10
|
+
style = 'background-color: var(--color);'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (top && bottom) {
|
|
14
|
+
style = toStyleString({
|
|
15
|
+
'line-height': 1,
|
|
16
|
+
'background-image': `linear-gradient(
|
|
17
|
+
transparent ${top},
|
|
18
|
+
var(--color) ${top},
|
|
19
|
+
var(--color) ${bottom},
|
|
20
|
+
transparent ${bottom}
|
|
21
|
+
)`,
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<!-- Remove space after <slot/> to ensure there's no extra whitespace -->
|
|
27
|
+
<span class="Highlight" {color} {style}><slot /></span>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.Highlight {
|
|
2
|
+
--text-color: var(--yellow-050);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
[color='red'] {
|
|
6
|
+
--text-color: var(--red-100);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
[color='yellow'] {
|
|
10
|
+
--text-color: var(--yellow-100);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[color='green'] {
|
|
14
|
+
--text-color: var(--green-100);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[color='blue'] {
|
|
18
|
+
--text-color: var(--blue-100);
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!-- TODO: Improve with Astro new image functionality -->
|
|
2
|
+
<script>
|
|
3
|
+
let klass = ''
|
|
4
|
+
export { klass as class }
|
|
5
|
+
export let src, alt, loading, caption
|
|
6
|
+
import Markdown from './Markdown/Markdown.svelte'
|
|
7
|
+
|
|
8
|
+
if (loading !== 'eager') loading = 'lazy'
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
{#if caption}
|
|
12
|
+
<figure class={klass} aria-label={caption} {...$$restProps}>
|
|
13
|
+
<img {src} alt={alt || caption} {loading} aria-hidden="true" />
|
|
14
|
+
<figcaption aria-hidden="true">
|
|
15
|
+
<Markdown content={caption} inline />
|
|
16
|
+
</figcaption>
|
|
17
|
+
</figure>
|
|
18
|
+
{/if}
|
|
19
|
+
|
|
20
|
+
{#if !caption}
|
|
21
|
+
<figure class={klass} {...$$restProps}>
|
|
22
|
+
<img {src} {alt} {loading} />
|
|
23
|
+
</figure>
|
|
24
|
+
{/if}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { onMount } from 'svelte'
|
|
3
|
+
|
|
4
|
+
let klass
|
|
5
|
+
export { klass as class }
|
|
6
|
+
|
|
7
|
+
let region
|
|
8
|
+
let down
|
|
9
|
+
let up
|
|
10
|
+
|
|
11
|
+
onMount(() => {
|
|
12
|
+
if (typeof window === 'undefined') return
|
|
13
|
+
region.style.cursor = 'pointer'
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
function handleClick(event) {
|
|
17
|
+
const primaryCTA =
|
|
18
|
+
region.querySelector('.PrimaryCTA') || region.querySelector('a, button')
|
|
19
|
+
|
|
20
|
+
// Allow other CTA clicks through
|
|
21
|
+
if (event.target.closest('a, button') !== primaryCTA) return
|
|
22
|
+
|
|
23
|
+
// Activate Primary CTA
|
|
24
|
+
primaryCTA.click()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function startCountdown() {
|
|
28
|
+
down = performance.now()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function endCountdown() {
|
|
32
|
+
up = performance.now()
|
|
33
|
+
if (up - down < 200) region.click()
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-noninteractive-tabindex a11y-no-static-element-interactions-->
|
|
38
|
+
<div
|
|
39
|
+
class="InteractiveRegion {klass}"
|
|
40
|
+
tabindex="0"
|
|
41
|
+
on:click={handleClick}
|
|
42
|
+
on:pointerdown={startCountdown}
|
|
43
|
+
on:pointereup={endCountdown}
|
|
44
|
+
bind:this={region}
|
|
45
|
+
>
|
|
46
|
+
<slot />
|
|
47
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let klass = null
|
|
3
|
+
export { klass as class }
|
|
4
|
+
export let style = null
|
|
5
|
+
export let href
|
|
6
|
+
export let aClass = null
|
|
7
|
+
export let aStyle = null
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<li class={klass} {style}>
|
|
11
|
+
<a class={aClass} style={aStyle} {href} {...$$restProps}><slot /></a>
|
|
12
|
+
</li>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!-- NestedList.svelte
|
|
2
|
+
A Svelte component for rendering a nested list structure. This component takes an array of items,
|
|
3
|
+
each potentially containing its own nested items, and renders them as a hierarchical list with
|
|
4
|
+
customizable classes for `<li>` and `<a>` elements.
|
|
5
|
+
|
|
6
|
+
Usage Example:
|
|
7
|
+
<NestedList items={[
|
|
8
|
+
{ label: 'Item 1', href: '#', liClass: 'item-class', aClass: 'link-class', children: [
|
|
9
|
+
{ label: 'Subitem 1.1', href: '#', liClass: 'subitem-class', aClass: 'sublink-class', children: [] }
|
|
10
|
+
]},
|
|
11
|
+
{ label: 'Item 2', href: '#', liClass: 'item-class', aClass: 'link-class', children: [] }
|
|
12
|
+
]} />
|
|
13
|
+
|
|
14
|
+
Props:
|
|
15
|
+
- items (Object[]): The array of items to render in the list. Each item is an object that can contain:
|
|
16
|
+
- label (string): The text content for the list item.
|
|
17
|
+
- liClass (string): Optional CSS class for the `<li>` element.
|
|
18
|
+
- aClass (string): Optional CSS class for the `<a>` element.
|
|
19
|
+
- children (Object[]): Optional array of nested items to be rendered as a sublist.
|
|
20
|
+
-->
|
|
21
|
+
<script>
|
|
22
|
+
// let klass = ''
|
|
23
|
+
// export { klass as class }
|
|
24
|
+
export let items = []
|
|
25
|
+
export let liClass = ''
|
|
26
|
+
export let aClass = ''
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<!-- {@html renderList(items)} -->
|
|
30
|
+
|
|
31
|
+
<!-- Svelte version below is not ideal. -->
|
|
32
|
+
<!-- Limitation: We cannot put the UL element here because we are using svelte:self to reference the entire element. -->
|
|
33
|
+
<!-- This can be fixed with Svelte 5 Snippets. -->
|
|
34
|
+
|
|
35
|
+
{#if items.length}
|
|
36
|
+
{#each items as item}
|
|
37
|
+
<li class={item.liClass || liClass}>
|
|
38
|
+
<a class={item.aClass || aClass} href={item.href}>{item.label}</a>
|
|
39
|
+
|
|
40
|
+
{#if item.children.length}
|
|
41
|
+
<ul>
|
|
42
|
+
<svelte:self {liClass} {aClass} items={item.children} />
|
|
43
|
+
</ul>
|
|
44
|
+
{/if}
|
|
45
|
+
</li>
|
|
46
|
+
{/each}
|
|
47
|
+
{/if}
|
|
48
|
+
|
|
49
|
+
<!-- What about items that are active according to the TARGET?! -->
|
|
50
|
+
<!-- Hm. How to style? CSS directly? -->
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Converts markdown into html
|
|
4
|
+
- @prop {string} `content` - Markdown content
|
|
5
|
+
- @prop {boolean} `inline` - Whether to inline the content.
|
|
6
|
+
-->
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import { marked } from 'marked'
|
|
10
|
+
import { mangle } from 'marked-mangle'
|
|
11
|
+
import { gfmHeadingId } from 'marked-gfm-heading-id'
|
|
12
|
+
import { treatMarkdownWhitespace } from '@splendidlabz/utils'
|
|
13
|
+
|
|
14
|
+
export let content
|
|
15
|
+
export let inline = false
|
|
16
|
+
|
|
17
|
+
// Prepare Marked
|
|
18
|
+
marked.use(mangle())
|
|
19
|
+
marked.use(gfmHeadingId())
|
|
20
|
+
|
|
21
|
+
// Process content
|
|
22
|
+
const { content: treatedContent } = treatMarkdownWhitespace(content, {
|
|
23
|
+
inline,
|
|
24
|
+
isSlot: false,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
// Parse Markdown -> HTML
|
|
28
|
+
let html = ''
|
|
29
|
+
$: {
|
|
30
|
+
html = marked.parse(treatedContent)
|
|
31
|
+
if (inline) html = html.replace('<p>', '').replace('</p>', '')
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
{@html html}
|