@splendidlabz/svelte 4.8.3 → 4.8.4
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/CHANGELOG.md +6 -0
- package/components/Accordion/Accordion.svelte +17 -21
- package/components/Breadcrumbs/Breadcrumbs.svelte +8 -19
- package/components/Breadcrumbs/Crumb.svelte +19 -14
- package/components/BrowserFrame/BrowserFrame.svelte +8 -16
- package/components/Codepen/Codepen.svelte +2 -1
- package/components/ContentList/ContentList.svelte +6 -7
- package/components/Copyright.svelte +6 -7
- package/components/Disclosure/Disclosure/DisclosureContent.svelte +21 -21
- package/components/Disclosure/Disclosure/DisclosureTrigger.svelte +23 -22
- package/components/Disclosure/Drawer/DrawerCloseButton.svelte +2 -2
- package/components/Disclosure/Drawer/DrawerContent.svelte +20 -18
- package/components/Disclosure/Modal/ModalCloseButton.svelte +3 -6
- package/components/Disclosure/Modal/ModalContent.svelte +18 -19
- package/components/Disclosure/Modal/ModalTrigger.svelte +9 -11
- package/components/Disclosure/Popover/PopoverCloseButton.svelte +4 -5
- package/components/Disclosure/Popover/PopoverContent.svelte +12 -23
- package/components/Disclosure/Popover/PopoverTrigger.svelte +9 -13
- package/components/FancyList/FancyList.svelte +3 -6
- package/components/Form/ButtonGroup.svelte +30 -22
- package/components/Form/Checkbox.svelte +23 -18
- package/components/Form/Checkboxes.svelte +29 -27
- package/components/Form/Form.svelte +3 -6
- package/components/Form/Radio.svelte +11 -14
- package/components/Form/Radios.svelte +27 -27
- package/components/Form/Select.svelte +48 -60
- package/components/Form/TextInput.svelte +13 -15
- package/components/Form/Textarea.svelte +13 -20
- package/components/Image/Figure.svelte +13 -0
- package/components/Image/Image-old.svelte +58 -0
- package/components/Image/Image.svelte +41 -0
- package/components/Image/Picture.svelte +71 -0
- package/components/Image/image.js +61 -0
- package/components/LocalStorage/LocalStoragePush.svelte +1 -2
- package/components/LocalStorage/LocalStorageRemove.svelte +1 -2
- package/components/Markdown/Markdown.svelte +1 -1
- package/components/Resizer/Resizer.svelte +24 -23
- package/components/SVG/SVG.svelte +23 -21
- package/components/SVG/SVGGradient.svelte +7 -5
- package/components/Scrambler/Scrambler.svelte +1 -2
- package/components/Status.svelte +1 -3
- package/components/Tabs/Tablist.svelte +7 -8
- package/components/Tabs/Tabpanels.svelte +5 -1
- package/components/Tabs/Tabs.svelte +2 -3
- package/components/Youtube.svelte +7 -10
- package/package.json +2 -1
- package/utils/index.js +1 -0
- package/utils/init.js +3 -0
- package/vitest.config.js +8 -0
- package/components/Image.svelte +0 -24
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
import { toStyleString } from '@splendidlabz/utils'
|
|
27
27
|
import { onMount } from 'svelte'
|
|
28
28
|
import { domParser, naiveParser } from './parser.js'
|
|
29
|
+
import { init } from '../../utils'
|
|
29
30
|
/** @type {SVGProps} */
|
|
30
31
|
const {
|
|
31
32
|
icon,
|
|
32
33
|
style,
|
|
33
34
|
parser = 'naive', // or DOM
|
|
34
35
|
children, // Just to remove children slots
|
|
35
|
-
...
|
|
36
|
+
...rest
|
|
36
37
|
} = $props()
|
|
37
38
|
|
|
38
39
|
const files = {
|
|
@@ -41,33 +42,34 @@
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
// Find the SVG
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return
|
|
45
|
+
const file = init(() => {
|
|
46
|
+
if (!icon) throw new Error('icon property is required')
|
|
47
|
+
const found = Object.keys(files).find(f => f.split('/').pop() === `${icon}.svg`)
|
|
48
|
+
if (!found) throw new Error(`${icon}.svg not found`)
|
|
49
|
+
return found
|
|
49
50
|
})
|
|
50
51
|
|
|
51
|
-
if (!file) {
|
|
52
|
-
throw new Error(`${icon}.svg not found`)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
52
|
const content = files[file].default
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
|
|
54
|
+
function buildSvgProps() {
|
|
55
|
+
return {
|
|
56
|
+
role: 'img',
|
|
57
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
58
|
+
style: toStyleString(style),
|
|
59
|
+
...rest,
|
|
60
|
+
}
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
let svg = $state(null)
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
init(() => {
|
|
66
|
+
if (parser === 'naive') svg = naiveParser(content, buildSvgProps())
|
|
67
|
+
if (parser === 'dom') {
|
|
68
|
+
onMount(_ => {
|
|
69
|
+
svg = domParser(content, buildSvgProps())
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
})
|
|
71
73
|
</script>
|
|
72
74
|
|
|
73
75
|
<!--
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
stops = 2, // Or an array with the actual stop percentages
|
|
6
6
|
} = $props()
|
|
7
7
|
|
|
8
|
-
const _stops = (
|
|
9
|
-
(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const _stops = $derived(
|
|
9
|
+
(Array.isArray(stops) ? stops : Array(stops).fill({})).map(
|
|
10
|
+
(stop, index) => ({
|
|
11
|
+
offset: stop.offset || `${(index * 100) / (stops - 1)}%`,
|
|
12
|
+
'stop-color': stop.color || `var(--gradient-stop-${index + 1})`,
|
|
13
|
+
}),
|
|
14
|
+
),
|
|
13
15
|
)
|
|
14
16
|
</script>
|
|
15
17
|
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import { traverseAndScramble } from '@splendidlabz/utils/dom'
|
|
3
3
|
import { onMount } from 'svelte'
|
|
4
4
|
|
|
5
|
-
let { class: klass = '', ref = $bindable(null), ...
|
|
6
|
-
const { excludes = [], children, ...rest } = p
|
|
5
|
+
let { class: klass = '', ref = $bindable(null), excludes = [], children, ...rest } = $props()
|
|
7
6
|
|
|
8
7
|
onMount(_ => {
|
|
9
8
|
if (typeof window === 'undefined') return
|
package/components/Status.svelte
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
let { status = $bindable('info'), ...
|
|
3
|
-
|
|
4
|
-
const { class: klass = '', children, ...rest } = p
|
|
2
|
+
let { status = $bindable('info'), class: klass = '', children, ...rest } = $props()
|
|
5
3
|
|
|
6
4
|
function getStatusString(status) {
|
|
7
5
|
if (typeof status === 'string') return status
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { preferHorizontalScroll as preferHorizontalScrollAction } from '@splendidlabz/utils/dom'
|
|
3
3
|
import { breakpointObserver } from '../../actions/breakpoint-observer.js'
|
|
4
|
-
import {
|
|
4
|
+
import { init } from '../../utils'
|
|
5
5
|
import { getTab, tablist, updatePlacement } from './tabs.svelte.js'
|
|
6
6
|
|
|
7
|
-
let {
|
|
8
|
-
p = mergeOpts(p)
|
|
9
|
-
|
|
10
|
-
const {
|
|
7
|
+
let {
|
|
11
8
|
class: klass = '',
|
|
12
9
|
target = null,
|
|
13
10
|
breakpoints,
|
|
@@ -21,13 +18,15 @@
|
|
|
21
18
|
children,
|
|
22
19
|
|
|
23
20
|
...rest
|
|
24
|
-
} =
|
|
21
|
+
} = $props()
|
|
25
22
|
|
|
26
|
-
let placement = initialPlacement || 'top'
|
|
23
|
+
let placement = $state(_ => initialPlacement || 'top')
|
|
27
24
|
let tab = $derived(getTab(target))
|
|
28
25
|
let tablistClasses = $derived(getTablistClasses(tab))
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
init(() => {
|
|
28
|
+
if (!target) throw new Error('Tablist must have a target')
|
|
29
|
+
})
|
|
31
30
|
|
|
32
31
|
function getTablistClasses(tab) {
|
|
33
32
|
if (!tab) return ''
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { init } from '../../utils'
|
|
2
3
|
import { tabpanels } from './tabs.svelte.js'
|
|
3
4
|
|
|
4
5
|
const { id = null, class: klass = '', children, ...rest } = $props()
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
init(() => {
|
|
8
|
+
if (!id) throw new Error('Tabpanels must have an id')
|
|
9
|
+
})
|
|
6
10
|
</script>
|
|
7
11
|
|
|
8
12
|
<div {...rest} {id} class="tabpanels {klass}" use:tabpanels>
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
import Tab from './Tab.svelte'
|
|
4
4
|
import Tablist from './Tablist.svelte'
|
|
5
5
|
import Tabpanels from './Tabpanels.svelte'
|
|
6
|
-
const { tabs, ...p } = $props()
|
|
7
|
-
|
|
8
6
|
const {
|
|
7
|
+
tabs,
|
|
9
8
|
id = randomString(),
|
|
10
9
|
class: klass = '',
|
|
11
10
|
activeIndex = 0,
|
|
@@ -17,7 +16,7 @@
|
|
|
17
16
|
tabpanelsOptions,
|
|
18
17
|
children,
|
|
19
18
|
...rest
|
|
20
|
-
} =
|
|
19
|
+
} = $props()
|
|
21
20
|
</script>
|
|
22
21
|
|
|
23
22
|
<Tablist
|
|
@@ -10,16 +10,13 @@
|
|
|
10
10
|
timestamp = 0, // alias for start
|
|
11
11
|
} = $props()
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
width: '100%',
|
|
21
|
-
aspectRatio: short ? '9/16' : '16/9',
|
|
22
|
-
})
|
|
13
|
+
const _id = $derived(id || link?.split('/').pop())
|
|
14
|
+
const src = $derived(
|
|
15
|
+
`https://www.youtube.com/embed/${_id}?vq=highres&start=${start || timestamp}&cc_load_policy=1&cc_lang_pref=en`,
|
|
16
|
+
)
|
|
17
|
+
const style = $derived(
|
|
18
|
+
toStyleString({ width: '100%', aspectRatio: short ? '9/16' : '16/9' }),
|
|
19
|
+
)
|
|
23
20
|
</script>
|
|
24
21
|
|
|
25
22
|
<div class="youtube {klass}">
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@splendidlabz/svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.4",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"homepage": "https://splendidlabz.com/docs/svelte",
|
|
7
7
|
"scripts": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@splendidlabz/eslint-config": "2.1.3",
|
|
36
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
36
37
|
"@tsconfig/svelte": "^5.0.4",
|
|
37
38
|
"svelte": "^5.25.6",
|
|
38
39
|
"svelte-check": "^4.2.1",
|
package/utils/index.js
CHANGED
package/utils/init.js
ADDED
package/vitest.config.js
ADDED
package/components/Image.svelte
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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}
|