@splendidlabz/svelte 4.14.0 → 4.15.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/actions/index.js +2 -2
- package/components/ContentList/ContentList.svelte +2 -4
- package/components/Disclosure/Modal/ModalContent.svelte +2 -2
- package/components/Disclosure/Modal/ModalTrigger.svelte +2 -2
- package/components/Disclosure/Popover/PopoverCloseButton.svelte +2 -1
- package/components/Form/Button.svelte +1 -0
- package/components/Form/SearchInput.svelte +1 -1
- package/components/Form/Switch.svelte +2 -19
- package/components/List/{NestedListItem.svelte → NestedList.svelte} +13 -2
- package/components/List/index.js +2 -2
- package/components/PerspectiveHover/PerspectiveHover.svelte +0 -1
- package/components/Populate/ConditionalPopulate.svelte +3 -1
- package/components/Populate/actions.js +5 -2
- package/components/Resizer/resizer.js +1 -1
- package/components/SVG/parser.js +15 -6
- package/components/Tabcordion/Tabcordion.svelte +1 -1
- package/components/Tabs/Tabs.svelte +2 -2
- package/components/Youtube.svelte +13 -1
- package/package.json +1 -1
package/actions/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from '../components/Populate/actions.js'
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
2
|
+
export * from './breakpoint-observer.js'
|
|
3
|
+
export * from './portal.js'
|
|
4
4
|
export * from './sync.svelte.js'
|
|
5
5
|
export * from './use-actions.js'
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
scrollObserver,
|
|
31
31
|
} from '@splendidlabz/utils/dom'
|
|
32
32
|
import { onMount } from 'svelte'
|
|
33
|
-
import NestedList from '../List/
|
|
33
|
+
import NestedList from '../List/NestedList.svelte'
|
|
34
34
|
import { buildStructure, updateAriaCurrent } from './contentlist.js'
|
|
35
35
|
|
|
36
36
|
let {
|
|
@@ -105,8 +105,6 @@
|
|
|
105
105
|
{:else}
|
|
106
106
|
{@render label?.()}
|
|
107
107
|
{/if}
|
|
108
|
-
<
|
|
109
|
-
<NestedList items={structure} />
|
|
110
|
-
</ul>
|
|
108
|
+
<NestedList items={structure} class={listClass} />
|
|
111
109
|
</div>
|
|
112
110
|
{/if}
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
const { newState } = event
|
|
72
72
|
if (newState === 'open' && onbeforeopen) onbeforeopen(event)
|
|
73
|
-
if (newState === '
|
|
73
|
+
if (newState === 'closed' && onbeforeclose) onbeforeclose(event)
|
|
74
74
|
if (onbeforetoggle) onbeforetoggle(event)
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
if (newState === 'open' && onopen) onopen(event)
|
|
87
|
-
if (newState === '
|
|
87
|
+
if (newState === 'closed' && onclose) onclose(event)
|
|
88
88
|
if (ontoggle) ontoggle(event)
|
|
89
89
|
}
|
|
90
90
|
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
|
|
42
42
|
// Allows trigger to know whether the modal is open or closed
|
|
43
43
|
function handleToggle(event) {
|
|
44
|
-
const { newState
|
|
44
|
+
const { newState } = event.detail
|
|
45
45
|
if (newState === 'open') show = true
|
|
46
|
-
if (
|
|
46
|
+
if (newState === 'closed') show = false
|
|
47
47
|
if (ontoggle) ontoggle(event)
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
@@ -7,33 +7,16 @@
|
|
|
7
7
|
export let ref
|
|
8
8
|
export let checked = false
|
|
9
9
|
|
|
10
|
-
let labels = {
|
|
11
|
-
left: undefined,
|
|
12
|
-
right: undefined,
|
|
13
|
-
}
|
|
14
|
-
|
|
15
10
|
const dispatch = createEventDispatcher()
|
|
16
11
|
|
|
17
12
|
function change(event) {
|
|
18
13
|
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
14
|
dispatch('change', { checked })
|
|
32
15
|
}
|
|
33
16
|
</script>
|
|
34
17
|
|
|
35
18
|
<label class="Switch {klass}">
|
|
36
|
-
<span aria-hidden=
|
|
19
|
+
<span aria-hidden={checked ? 'true' : undefined}>
|
|
37
20
|
<slot name="left-label" />
|
|
38
21
|
</span>
|
|
39
22
|
<input
|
|
@@ -44,7 +27,7 @@
|
|
|
44
27
|
bind:this={ref}
|
|
45
28
|
bind:checked
|
|
46
29
|
/>
|
|
47
|
-
<span aria-hidden=
|
|
30
|
+
<span aria-hidden={checked ? undefined : 'true'}>
|
|
48
31
|
<slot name="right-label" />
|
|
49
32
|
</span>
|
|
50
33
|
</label>
|
|
@@ -17,9 +17,18 @@ Props:
|
|
|
17
17
|
- liClass (string): Optional CSS class for the `<li>` element.
|
|
18
18
|
- aClass (string): Optional CSS class for the `<a>` element.
|
|
19
19
|
- children (Object[]): Optional array of nested items to be rendered as a sublist.
|
|
20
|
+
- class (string): Optional CSS class for the outer `<ul>`.
|
|
21
|
+
- liClass (string): Default class for every `<li>`, overridden per item.
|
|
22
|
+
- aClass (string): Default class for every `<a>`, overridden per item.
|
|
20
23
|
-->
|
|
21
24
|
<script>
|
|
22
|
-
const {
|
|
25
|
+
const {
|
|
26
|
+
items = [],
|
|
27
|
+
class: klass = '',
|
|
28
|
+
liClass = '',
|
|
29
|
+
aClass = '',
|
|
30
|
+
...rest
|
|
31
|
+
} = $props()
|
|
23
32
|
|
|
24
33
|
function parseItemProps(item) {
|
|
25
34
|
const {
|
|
@@ -65,4 +74,6 @@ Props:
|
|
|
65
74
|
{/if}
|
|
66
75
|
{/snippet}
|
|
67
76
|
|
|
68
|
-
{
|
|
77
|
+
<ul {...rest} class={klass}>
|
|
78
|
+
{@render nestedItems(items)}
|
|
79
|
+
</ul>
|
package/components/List/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import Lia from './Lia.svelte'
|
|
2
|
-
import
|
|
3
|
-
export { Lia,
|
|
2
|
+
import NestedList from './NestedList.svelte'
|
|
3
|
+
export { Lia, NestedList }
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
const list = prop.split('.')
|
|
16
16
|
|
|
17
17
|
// If source is provided, draw from source
|
|
18
|
-
if (!isEmpty(source))
|
|
18
|
+
if (!isEmpty(source)) {
|
|
19
|
+
value = conditions[getValueFromSource({ source, list })]
|
|
20
|
+
}
|
|
19
21
|
|
|
20
22
|
// If source is not provided, draw from localStorage, sessionstorage or query parameters (in this order) — in this case client:load is required.
|
|
21
23
|
if (isEmpty(source)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Bind into <input> elements as the value — that's probably the only use case so far.
|
|
2
|
-
import { getValueFromBrowserStorage, getValueFromSource } from './get-value'
|
|
2
|
+
import { getValueFromBrowserStorage, getValueFromSource } from './get-value.js'
|
|
3
3
|
|
|
4
4
|
import { isEmpty } from '@splendidlabz/utils'
|
|
5
5
|
|
|
@@ -19,7 +19,10 @@ export function conditionalPopulate(node, options) {
|
|
|
19
19
|
const list = prop.split('.')
|
|
20
20
|
let value
|
|
21
21
|
|
|
22
|
-
if (!isEmpty(source))
|
|
22
|
+
if (!isEmpty(source)) {
|
|
23
|
+
const tmp = getValueFromSource({ source, list })
|
|
24
|
+
value = conditions[tmp] || conditions.fallback
|
|
25
|
+
}
|
|
23
26
|
if (isEmpty(source)) {
|
|
24
27
|
const tmp = getValueFromBrowserStorage(list)
|
|
25
28
|
value = conditions[tmp] || conditions.fallback
|
|
@@ -110,7 +110,7 @@ export function resizer(node, options) {
|
|
|
110
110
|
elementToResize.style.height = `${maxHeight}px`
|
|
111
111
|
break
|
|
112
112
|
case !canExceedOriginal && newHeight > originalHeight:
|
|
113
|
-
elementToResize.style.
|
|
113
|
+
elementToResize.style.height = `${originalHeight}px`
|
|
114
114
|
break
|
|
115
115
|
default:
|
|
116
116
|
elementToResize.style.height = `${newHeight}px`
|
package/components/SVG/parser.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Simple regex parsing to add/adjust SVG attributes
|
|
2
2
|
// Written by AI.
|
|
3
3
|
export function naiveParser(content, options) {
|
|
4
|
-
const { class: klass, width, height, attributes = {} } = options
|
|
4
|
+
const { class: klass, width, height, attributes = {}, ...rest } = options
|
|
5
5
|
|
|
6
6
|
// Parse the opening <svg> tag
|
|
7
7
|
const svgMatch = content.match(/<svg[^>]*>/i)
|
|
@@ -79,8 +79,9 @@ export function naiveParser(content, options) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
// Add any additional attributes
|
|
83
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
82
|
+
// Add any additional attributes (rest props like style and role included)
|
|
83
|
+
Object.entries({ ...rest, ...attributes }).forEach(([key, value]) => {
|
|
84
|
+
if (!value) return
|
|
84
85
|
if (svgTag.includes(`${key}=`)) {
|
|
85
86
|
svgTag = svgTag.replace(new RegExp(`${key}="[^"]*"`), `${key}="${value}"`)
|
|
86
87
|
} else {
|
|
@@ -96,7 +97,14 @@ export function naiveParser(content, options) {
|
|
|
96
97
|
// Likely not needed.
|
|
97
98
|
// Written by AI.
|
|
98
99
|
export function domParser(content, options) {
|
|
99
|
-
const {
|
|
100
|
+
const {
|
|
101
|
+
class: className,
|
|
102
|
+
width,
|
|
103
|
+
height,
|
|
104
|
+
attributes = {},
|
|
105
|
+
transform,
|
|
106
|
+
...rest
|
|
107
|
+
} = options
|
|
100
108
|
|
|
101
109
|
// Parse SVG content
|
|
102
110
|
const parser = new DOMParser()
|
|
@@ -118,8 +126,9 @@ export function domParser(content, options) {
|
|
|
118
126
|
if (width) svgElement.setAttribute('width', width)
|
|
119
127
|
if (height) svgElement.setAttribute('height', height)
|
|
120
128
|
|
|
121
|
-
// Add additional attributes
|
|
122
|
-
Object.entries(attributes).forEach(([key, value]) => {
|
|
129
|
+
// Add additional attributes (rest props like style and role included)
|
|
130
|
+
Object.entries({ ...rest, ...attributes }).forEach(([key, value]) => {
|
|
131
|
+
if (!value) return
|
|
123
132
|
svgElement.setAttribute(key, value)
|
|
124
133
|
})
|
|
125
134
|
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
<!-- Render children purely for their registration side effect; they emit no DOM -->
|
|
68
68
|
{@render children?.()}
|
|
69
69
|
|
|
70
|
-
<div id={
|
|
70
|
+
<div id={tabcordionId} {...rest} class="tabcordion {klass}">
|
|
71
71
|
<div class="accordion-stack">
|
|
72
72
|
{#each items as item, i (i)}
|
|
73
73
|
<Accordion
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
<Tab
|
|
31
31
|
class={tabClass}
|
|
32
32
|
active={index === activeIndex}
|
|
33
|
-
{
|
|
33
|
+
{...tabOptions}
|
|
34
34
|
{...tabRest}
|
|
35
35
|
>
|
|
36
36
|
{text}
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
|
|
41
41
|
{#if children}
|
|
42
42
|
<Tabpanels {id} class={tabpanelsClass} {...tabpanelsOptions}>
|
|
43
|
-
{children()}
|
|
43
|
+
{@render children()}
|
|
44
44
|
</Tabpanels>
|
|
45
45
|
{/if}
|
|
@@ -10,7 +10,19 @@
|
|
|
10
10
|
timestamp = 0, // alias for start
|
|
11
11
|
} = $props()
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the video ID from any YouTube URL form
|
|
15
|
+
* (watch?v=, youtu.be, embed, shorts) or returns the value as-is
|
|
16
|
+
* @param {string} url - YouTube URL or bare video ID
|
|
17
|
+
* @returns {string|undefined} Video ID
|
|
18
|
+
*/
|
|
19
|
+
function getVideoId(url) {
|
|
20
|
+
if (!url) return undefined
|
|
21
|
+
const match = url.match(/(?:v=|youtu\.be\/|embed\/|shorts\/)([\w-]{11})/)
|
|
22
|
+
return match ? match[1] : url.split('/').pop()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const _id = $derived(id || getVideoId(link))
|
|
14
26
|
const src = $derived(
|
|
15
27
|
`https://www.youtube.com/embed/${_id}?vq=highres&start=${start || timestamp}&cc_load_policy=1&cc_lang_pref=en`,
|
|
16
28
|
)
|