@splendidlabz/svelte 4.10.0 → 4.12.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/CHANGELOG.md +25 -0
- package/components/Disclosure/Popover/Popover.svelte +45 -31
- package/components/DisclosureOld/Drawer/DrawerContent.svelte +30 -17
- package/components/DisclosureOld/Modal/ModalContent.svelte +17 -9
- package/components/DisclosureOld/Old/DisclosureContentOld.svelte +43 -31
- package/components/DisclosureOld/Old/DisclosureTriggerOld.svelte +28 -17
- package/components/Form/Form.svelte +8 -2
- package/components/Form/TextInput.svelte +15 -8
- package/components/Form/Textarea.svelte +10 -6
- package/components/Image/Image-old.svelte +3 -3
- package/components/Image/Image.svelte +6 -2
- package/components/Image/Picture.svelte +6 -5
- package/components/SVG/Noise.svelte +57 -0
- package/components/SVG/index.js +2 -1
- package/components/Status.svelte +28 -10
- package/components/Tabcordion/Tabcordion.svelte +9 -1
- package/components/Tabcordion/TabcordionItem.svelte +8 -1
- package/package.json +1 -1
- package/svelte.config.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @splendidlabz/svelte
|
|
2
2
|
|
|
3
|
+
## 4.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a7cafd9: Add Noise component (SVG feTurbulence-based texture overlay) to the SVG package.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [293c7a0]
|
|
12
|
+
- Updated dependencies [d6adbe4]
|
|
13
|
+
- @splendidlabz/styles@4.10.1
|
|
14
|
+
|
|
15
|
+
## 4.11.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 8e3054d: Refactor Status to use `<output>` element with automatic live region: `role="alert"` for errors, `role="status"` for all other states. Add `statusText` prop. Form now accepts `status` and `statusText` props and renders a linked Status component.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 8e3054d: Fix accessibility of TextInput and Textarea: move `aria-label` onto the input element, make error live region always present in DOM (sr-only when empty), use `<output for={id} role="alert">` pattern for error announcements.
|
|
24
|
+
- df4623c: Resolve Svelte `state_referenced_locally` warnings in form, tabcordion, disclosure, and image components.
|
|
25
|
+
- Updated dependencies [42cd5a2]
|
|
26
|
+
- @splendidlabz/utils@1.11.6
|
|
27
|
+
|
|
3
28
|
## 4.10.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
|
@@ -10,42 +10,55 @@
|
|
|
10
10
|
as = 'dialog',
|
|
11
11
|
ref = $bindable(null),
|
|
12
12
|
referenceNode = $bindable(null),
|
|
13
|
-
...
|
|
13
|
+
...props
|
|
14
14
|
} = $props()
|
|
15
15
|
|
|
16
|
-
p = mergeOpts(
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
16
|
+
const p = $derived(mergeOpts(props))
|
|
17
|
+
|
|
18
|
+
const componentName = $derived(p.componentName ?? 'Popover')
|
|
19
|
+
const ariaLabel = $derived(p['aria-label'])
|
|
20
|
+
const ariaLabelledBy = $derived(p['aria-labelledBy'])
|
|
21
|
+
const ariaDescribedBy = $derived(p['aria-describedby'])
|
|
22
|
+
|
|
23
|
+
const id = $derived(p.id)
|
|
24
|
+
const popover = $derived(p.popover ?? 'auto') // manual, hint
|
|
25
|
+
|
|
26
|
+
const onbeforetoggle = $derived(p.onbeforetoggle ?? null)
|
|
27
|
+
const ontoggle = $derived(p.ontoggle ?? null)
|
|
28
|
+
const onopen = $derived(p.onopen ?? null)
|
|
29
|
+
const onclose = $derived(p.onclose ?? null)
|
|
30
|
+
|
|
31
|
+
const children = $derived(p.children)
|
|
32
|
+
const rest = $derived.by(() => {
|
|
33
|
+
const {
|
|
34
|
+
componentName = 'Popover',
|
|
35
|
+
'aria-label': ariaLabel,
|
|
36
|
+
'aria-labelledBy': ariaLabelledBy,
|
|
37
|
+
'aria-describedby': ariaDescribedBy,
|
|
38
|
+
id,
|
|
39
|
+
popover = 'auto',
|
|
40
|
+
onbeforetoggle = null,
|
|
41
|
+
ontoggle = null,
|
|
42
|
+
onopen = null,
|
|
43
|
+
onclose = null,
|
|
44
|
+
children,
|
|
45
|
+
...rest
|
|
46
|
+
} = p
|
|
47
|
+
return rest
|
|
48
|
+
})
|
|
38
49
|
|
|
39
50
|
// ========================
|
|
40
51
|
// Checks
|
|
41
52
|
// ========================
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
53
|
+
$effect(() => {
|
|
54
|
+
if (!id) throw new Error(`${componentName} requires an id`)
|
|
55
|
+
|
|
56
|
+
// Accessible name warning
|
|
57
|
+
checkForAccessibleName({
|
|
58
|
+
name: `${componentName} (id: ${id})`,
|
|
59
|
+
ariaLabel,
|
|
60
|
+
ariaLabelledBy,
|
|
61
|
+
})
|
|
49
62
|
})
|
|
50
63
|
|
|
51
64
|
// ========================================
|
|
@@ -54,7 +67,8 @@
|
|
|
54
67
|
let trigger = null
|
|
55
68
|
let floating = null
|
|
56
69
|
|
|
57
|
-
const
|
|
70
|
+
const floatingSplit = $derived(splitObject(rest, FLOATING_OPTS_KEYS))
|
|
71
|
+
const floatingOpts = $derived(floatingSplit.picked)
|
|
58
72
|
|
|
59
73
|
// ========================================
|
|
60
74
|
// Event Listeners
|
|
@@ -20,26 +20,39 @@
|
|
|
20
20
|
...p
|
|
21
21
|
} = $props()
|
|
22
22
|
|
|
23
|
-
const opts =
|
|
23
|
+
const opts = $derived(
|
|
24
|
+
mergeOpts(DRAWER_CONTENT_OPTS, DRAWER_POSITION_OPTS[position], p),
|
|
25
|
+
)
|
|
24
26
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
blurBackdrop,
|
|
27
|
+
const id = $derived(opts.id)
|
|
28
|
+
const klass = $derived(opts.class ?? '')
|
|
29
|
+
const styleString = $derived(opts.style ?? '')
|
|
30
|
+
const backdropClass = $derived(opts.backdropClass ?? '')
|
|
31
|
+
const portal = $derived(opts.portal ?? true)
|
|
32
|
+
const placement = $derived(opts.placement)
|
|
33
|
+
const backdrop = $derived(opts.backdrop)
|
|
34
|
+
const blurBackdrop = $derived(opts.blurBackdrop)
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const rest = $derived.by(() => {
|
|
37
|
+
const {
|
|
38
|
+
id,
|
|
39
|
+
class: klass = '',
|
|
40
|
+
style: styleString = '',
|
|
41
|
+
backdropClass = '',
|
|
42
|
+
portal = true,
|
|
43
|
+
placement,
|
|
44
|
+
backdrop,
|
|
45
|
+
blurBackdrop,
|
|
46
|
+
...rest
|
|
47
|
+
} = opts
|
|
48
|
+
return rest
|
|
49
|
+
})
|
|
38
50
|
|
|
39
|
-
const
|
|
51
|
+
const transitionSplit = $derived(splitObject(rest, TRANSITION_OPT_KEYS))
|
|
52
|
+
const transitionOpts = $derived(transitionSplit.picked)
|
|
40
53
|
|
|
41
|
-
const TBLR = getTBLRValues({ placement, position })
|
|
42
|
-
const style = toStyleString(TBLR) + styleString
|
|
54
|
+
const TBLR = $derived(getTBLRValues({ placement, position }))
|
|
55
|
+
const style = $derived(toStyleString(TBLR) + styleString)
|
|
43
56
|
|
|
44
57
|
let d = $derived(getDisclosure(id))
|
|
45
58
|
let show = $derived(d?.state.show)
|
|
@@ -79,7 +92,7 @@
|
|
|
79
92
|
|
|
80
93
|
{#if show}
|
|
81
94
|
{#if position === 'fixed'}
|
|
82
|
-
{#if
|
|
95
|
+
{#if portal}
|
|
83
96
|
<Portal>{@render drawerBackdrop()}</Portal>
|
|
84
97
|
{:else}
|
|
85
98
|
{@render drawerBackdrop()}
|
|
@@ -9,17 +9,25 @@
|
|
|
9
9
|
import { MODAL_CONTENT_OPTS } from './modal.js'
|
|
10
10
|
|
|
11
11
|
let { ref = $bindable(null), ...p } = $props()
|
|
12
|
-
const opts = mergeOpts(MODAL_CONTENT_OPTS, p)
|
|
12
|
+
const opts = $derived(mergeOpts(MODAL_CONTENT_OPTS, p))
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const klass = $derived(opts.class ?? '')
|
|
15
|
+
const backdrop = $derived(opts.backdrop)
|
|
16
|
+
const backdropClass = $derived(opts.backdropClass)
|
|
17
|
+
const blurBackdrop = $derived(opts.blurBackdrop)
|
|
18
|
+
const rest = $derived.by(() => {
|
|
19
|
+
const {
|
|
20
|
+
class: klass = '',
|
|
21
|
+
backdrop,
|
|
22
|
+
backdropClass,
|
|
23
|
+
blurBackdrop,
|
|
24
|
+
...rest
|
|
25
|
+
} = opts
|
|
26
|
+
return rest
|
|
27
|
+
})
|
|
21
28
|
|
|
22
|
-
const
|
|
29
|
+
const transitionSplit = $derived(splitObject(rest, TRANSITION_OPT_KEYS))
|
|
30
|
+
const transitionOpts = $derived(transitionSplit.picked)
|
|
23
31
|
</script>
|
|
24
32
|
|
|
25
33
|
{#snippet modalBackdrop()}
|
|
@@ -18,43 +18,55 @@
|
|
|
18
18
|
|
|
19
19
|
let { ref = $bindable(null), ...p } = $props()
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
21
|
+
const klass = $derived(p.class)
|
|
22
|
+
const id = $derived(p.id)
|
|
23
|
+
const role = $derived(p.role ?? 'dialog')
|
|
24
|
+
const ariaLabel = $derived(p['aria-label'])
|
|
25
|
+
const ariaLabelledBy = $derived(p['aria-labelledBy'])
|
|
26
|
+
const ariaDescribedBy = $derived(p['aria-describedby'])
|
|
27
|
+
const componentName = $derived(p.componentName ?? 'DisclosureContent')
|
|
28
|
+
const portal = $derived(p.portal ?? true)
|
|
29
|
+
const scrollToAnchor = $derived(p.scrollToAnchor ?? false)
|
|
30
|
+
const children = $derived(p.children)
|
|
31
|
+
const restProps = $derived.by(() => {
|
|
32
|
+
const {
|
|
33
|
+
class: klass,
|
|
34
|
+
id,
|
|
35
|
+
role = 'dialog',
|
|
36
|
+
'aria-label': ariaLabel,
|
|
37
|
+
'aria-labelledBy': ariaLabelledBy,
|
|
38
|
+
'aria-describedby': ariaDescribedBy,
|
|
39
|
+
componentName = 'DisclosureContent',
|
|
40
|
+
portal = true,
|
|
41
|
+
scrollToAnchor = false,
|
|
42
|
+
children,
|
|
43
|
+
...restProps
|
|
44
|
+
} = p
|
|
45
|
+
return restProps
|
|
46
|
+
})
|
|
39
47
|
|
|
40
|
-
const
|
|
41
|
-
restProps,
|
|
42
|
-
DISCLOSURE_CONTENT_OPT_KEYS,
|
|
48
|
+
const disclosureSplit = $derived(
|
|
49
|
+
splitObject(restProps, DISCLOSURE_CONTENT_OPT_KEYS),
|
|
43
50
|
)
|
|
51
|
+
const disclosureContentOpts = $derived(disclosureSplit.picked)
|
|
52
|
+
const rest = $derived(disclosureSplit.omitted)
|
|
44
53
|
|
|
45
|
-
const
|
|
46
|
-
rest,
|
|
47
|
-
TRANSITION_OPT_KEYS,
|
|
54
|
+
const transitionSplit = $derived(
|
|
55
|
+
splitObject(rest, TRANSITION_OPT_KEYS),
|
|
48
56
|
)
|
|
57
|
+
const transitionOpts = $derived(transitionSplit.picked)
|
|
58
|
+
const remaining = $derived(transitionSplit.omitted)
|
|
49
59
|
|
|
50
|
-
|
|
60
|
+
$effect(() => {
|
|
61
|
+
if (!id) throw new Error(`${componentName} requires an id`)
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
// Accessible name warning
|
|
64
|
+
if (role === 'dialog' && !hasAccessibleName(ariaLabel, ariaLabelledBy)) {
|
|
65
|
+
console.warn(
|
|
66
|
+
`DrawerContent (with id: ${id}) is a dialog and should have an accessible name. Please create one with aria-label or aria-labelledby.`,
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
})
|
|
58
70
|
|
|
59
71
|
let d = $derived(getDisclosure(id))
|
|
60
72
|
let show = $derived(d?.state.show)
|
|
@@ -8,26 +8,37 @@
|
|
|
8
8
|
|
|
9
9
|
let { show = $bindable(false), ...p } = $props()
|
|
10
10
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const klass = $derived(p.class ?? '')
|
|
12
|
+
const componentName = $derived(p.componentName ?? 'DisclosureTrigger')
|
|
13
|
+
const icon = $derived(p.icon ?? 'tabler:menu')
|
|
14
|
+
const iconClass = $derived(p.iconClass)
|
|
15
|
+
const ariaHasPopup = $derived(p['aria-haspopup'] ?? 'dialog')
|
|
16
|
+
const target = $derived(p.target)
|
|
17
|
+
const children = $derived(p.children)
|
|
18
|
+
const restProps = $derived.by(() => {
|
|
19
|
+
const {
|
|
20
|
+
class: klass = '',
|
|
21
|
+
componentName = 'DisclosureTrigger',
|
|
22
|
+
icon = 'tabler:menu',
|
|
23
|
+
iconClass,
|
|
24
|
+
'aria-haspopup': ariaHasPopup = 'dialog',
|
|
25
|
+
target,
|
|
26
|
+
children,
|
|
27
|
+
...restProps
|
|
28
|
+
} = p
|
|
29
|
+
return restProps
|
|
30
|
+
})
|
|
18
31
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
...restProps
|
|
22
|
-
} = p
|
|
23
|
-
|
|
24
|
-
const { picked: triggerOpts, omitted: rest } = splitObject(
|
|
25
|
-
restProps,
|
|
26
|
-
DISCLOSURE_TRIGGER_OPT_KEYS,
|
|
32
|
+
const triggerSplit = $derived(
|
|
33
|
+
splitObject(restProps, DISCLOSURE_TRIGGER_OPT_KEYS),
|
|
27
34
|
)
|
|
35
|
+
const triggerOpts = $derived(triggerSplit.picked)
|
|
36
|
+
const rest = $derived(triggerSplit.omitted)
|
|
28
37
|
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
$effect(() => {
|
|
39
|
+
if (!target)
|
|
40
|
+
throw new Error(`${componentName} must contain a target property`)
|
|
41
|
+
})
|
|
31
42
|
|
|
32
43
|
// TODO: Test creating an IconSnippet to render the icon vs contents
|
|
33
44
|
// <script module> currently breaks when prettier is enabled. So, ¯\_(ツ)_/¯ if we can ever do that.
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { flattenArrayFields, formDataToObject } from '@splendidlabz/utils'
|
|
3
|
-
import { sanitize as sanitizeFn } from '@splendidlabz/utils/dom'
|
|
3
|
+
import { randomString, sanitize as sanitizeFn } from '@splendidlabz/utils/dom'
|
|
4
|
+
import Status from '../Status.svelte'
|
|
4
5
|
import Honeypot from './Honeypot.svelte'
|
|
5
6
|
|
|
6
7
|
let {
|
|
7
8
|
ref = $bindable(null),
|
|
9
|
+
id = $bindable(randomString()),
|
|
8
10
|
class: klass = '',
|
|
9
11
|
method = 'post',
|
|
10
12
|
action = null,
|
|
@@ -14,6 +16,8 @@
|
|
|
14
16
|
honeypotDuration = 2000,
|
|
15
17
|
onsubmit = null,
|
|
16
18
|
children,
|
|
19
|
+
status,
|
|
20
|
+
statusText,
|
|
17
21
|
...rest
|
|
18
22
|
} = $props()
|
|
19
23
|
|
|
@@ -49,8 +53,9 @@
|
|
|
49
53
|
</script>
|
|
50
54
|
|
|
51
55
|
<form
|
|
52
|
-
{...rest}
|
|
53
56
|
bind:this={ref}
|
|
57
|
+
{id}
|
|
58
|
+
{...rest}
|
|
54
59
|
class="form {klass}"
|
|
55
60
|
{action}
|
|
56
61
|
{method}
|
|
@@ -64,3 +69,4 @@
|
|
|
64
69
|
{/if}
|
|
65
70
|
{@render children?.()}
|
|
66
71
|
</form>
|
|
72
|
+
<Status for={id} {status} {statusText} />
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
import { randomString } from '@splendidlabz/utils/dom'
|
|
3
3
|
import { useActions } from '../../actions/use-actions'
|
|
4
|
-
import Markdown from '../Markdown/Markdown.svelte'
|
|
5
4
|
import { init } from '../../utils'
|
|
5
|
+
import Markdown from '../Markdown/Markdown.svelte'
|
|
6
6
|
|
|
7
7
|
let {
|
|
8
8
|
value = $bindable(''),
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
// IDs for aria-describedby
|
|
39
39
|
const hintId = $derived(hint ? id + '-hint' : '')
|
|
40
|
-
const errorId = $derived(
|
|
40
|
+
const errorId = $derived(id + '-error')
|
|
41
41
|
const describedBy = $derived(`${hintId} ${errorId}`.trim() || null)
|
|
42
42
|
|
|
43
43
|
// ========================================
|
|
@@ -47,7 +47,8 @@
|
|
|
47
47
|
const SUPPORTED_TYPES = ['text', 'email', 'password', 'search', 'url', 'tel']
|
|
48
48
|
init(() => {
|
|
49
49
|
if (!name) throw new Error('TextInput requires a name')
|
|
50
|
-
if (!SUPPORTED_TYPES.includes(type))
|
|
50
|
+
if (!SUPPORTED_TYPES.includes(type))
|
|
51
|
+
throw new Error(`Invalid type: ${type}`)
|
|
51
52
|
})
|
|
52
53
|
</script>
|
|
53
54
|
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
{...{ type }}
|
|
63
64
|
aria-describedby={describedBy}
|
|
64
65
|
aria-invalid={error ? 'true' : null}
|
|
66
|
+
aria-label={!labelVisible && label ? label : null}
|
|
65
67
|
{disabled}
|
|
66
68
|
{readonly}
|
|
67
69
|
bind:value
|
|
@@ -75,7 +77,6 @@
|
|
|
75
77
|
class="input-container text-input text-field {klass}"
|
|
76
78
|
class:disabled
|
|
77
79
|
class:readonly
|
|
78
|
-
aria-label={(!labelVisible && label) || null}
|
|
79
80
|
>
|
|
80
81
|
{#if label && labelVisible}
|
|
81
82
|
<label class="label input-meta {labelClass}" for={id}>
|
|
@@ -87,11 +88,17 @@
|
|
|
87
88
|
<Markdown content={hint} inline />
|
|
88
89
|
</div>
|
|
89
90
|
{/if}
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
<output
|
|
92
|
+
id={errorId}
|
|
93
|
+
class="error input-meta {errorClass}"
|
|
94
|
+
class:sr-only={!error}
|
|
95
|
+
for={id}
|
|
96
|
+
role="alert"
|
|
97
|
+
>
|
|
98
|
+
{#if error}
|
|
92
99
|
<Markdown content={error} inline />
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
{/if}
|
|
101
|
+
</output>
|
|
95
102
|
|
|
96
103
|
{#if before || after}
|
|
97
104
|
<div class="input-group {inputGroupClass}">
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
// IDs for aria-describedby
|
|
35
35
|
const hintId = $derived(hint ? id + '-hint' : '')
|
|
36
|
-
const errorId = $derived(
|
|
36
|
+
const errorId = $derived(id + '-error')
|
|
37
37
|
const describedBy = $derived(`${hintId} ${errorId}`.trim() || null)
|
|
38
38
|
|
|
39
39
|
// ========================================
|
|
@@ -84,11 +84,15 @@
|
|
|
84
84
|
{#if hint}
|
|
85
85
|
<div id={hintId} class="hint input-meta {hintClass}">{hint}</div>
|
|
86
86
|
{/if}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
<output
|
|
88
|
+
id={errorId}
|
|
89
|
+
for={id}
|
|
90
|
+
class="error input-meta {errorClass}"
|
|
91
|
+
class:sr-only={!error}
|
|
92
|
+
role="alert"
|
|
93
|
+
>
|
|
94
|
+
{#if error}{error}{/if}
|
|
95
|
+
</output>
|
|
92
96
|
|
|
93
97
|
{#if before || after}
|
|
94
98
|
<div class="input-group {inputGroupClass}">
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
...rest
|
|
17
17
|
} = $props()
|
|
18
18
|
|
|
19
|
-
const image = resolveImage(src)
|
|
20
|
-
const isGif = image.format === 'gif' || image.src?.includes('.gif')
|
|
21
|
-
const usePicture = picture && !isGif
|
|
19
|
+
const image = $derived(resolveImage(src))
|
|
20
|
+
const isGif = $derived(image.format === 'gif' || image.src?.includes('.gif'))
|
|
21
|
+
const usePicture = $derived(picture && !isGif)
|
|
22
22
|
</script>
|
|
23
23
|
|
|
24
24
|
{#snippet img()}
|
|
@@ -15,8 +15,12 @@
|
|
|
15
15
|
...p
|
|
16
16
|
} = $props()
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const figureSplit = $derived(splitObject(p, ['caption', 'captionClass']))
|
|
19
|
+
const figureProps = $derived(figureSplit.p)
|
|
20
|
+
const p1 = $derived(figureSplit.o)
|
|
21
|
+
const pictureSplit = $derived(splitObject(p1, ['pictureClass']))
|
|
22
|
+
const pictureProps = $derived(pictureSplit.p)
|
|
23
|
+
const rest = $derived(pictureSplit.o)
|
|
20
24
|
</script>
|
|
21
25
|
|
|
22
26
|
{#snippet img()}
|
|
@@ -16,11 +16,12 @@
|
|
|
16
16
|
...rest
|
|
17
17
|
} = $props()
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
19
|
+
const fallback = $derived.by(() => {
|
|
20
|
+
if (!sources) throw new Error('Missing prop: sources')
|
|
21
|
+
return sources[fallbackIndex] ?? sources[sources.length - 1]
|
|
22
|
+
})
|
|
23
|
+
const fallbackSrc = $derived(fallback.image.src)
|
|
24
|
+
const fallbackAttrs = $derived(fallback.image.attributes)
|
|
24
25
|
</script>
|
|
25
26
|
|
|
26
27
|
{#if figure}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let {
|
|
3
|
+
class: klass = '',
|
|
4
|
+
frequency = 0.9,
|
|
5
|
+
octaves = 2,
|
|
6
|
+
alpha = 0.6,
|
|
7
|
+
opacity = 0.18,
|
|
8
|
+
blend = 'overlay',
|
|
9
|
+
seed,
|
|
10
|
+
} = $props()
|
|
11
|
+
|
|
12
|
+
// frequency — how zoomed in the noise is.
|
|
13
|
+
// low (0.01–0.1): large blobs, clouds, smoke
|
|
14
|
+
// high (0.5–1): fine grain, film noise, static
|
|
15
|
+
//
|
|
16
|
+
// octaves — layers of noise stacked on top of each other.
|
|
17
|
+
// Each octave adds finer detail at double the frequency (costs render perf).
|
|
18
|
+
// low (1): smooth, soft, single frequency
|
|
19
|
+
// high (4–8): complex, detailed texture
|
|
20
|
+
//
|
|
21
|
+
// Combinations:
|
|
22
|
+
// frequency: 0.05, octaves: 6 → realistic cloudy smoke
|
|
23
|
+
// frequency: 0.9, octaves: 2 → subtle film grain overlay (default)
|
|
24
|
+
// frequency: 0.3, octaves: 4 → mid-range crumpled paper texture
|
|
25
|
+
|
|
26
|
+
// seed — omit to let the browser pick. Pass a number to lock noise across
|
|
27
|
+
// renders or to get a different pattern per instance.
|
|
28
|
+
const seedAttr = $derived(seed != null ? ` seed='${seed}'` : '')
|
|
29
|
+
|
|
30
|
+
const svg = $derived(
|
|
31
|
+
"<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'>" +
|
|
32
|
+
"<filter id='n'>" +
|
|
33
|
+
`<feTurbulence type='fractalNoise' baseFrequency='${frequency}' numOctaves='${octaves}' stitchTiles='stitch'${seedAttr}/>` +
|
|
34
|
+
`<feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ${alpha} 0'/>` +
|
|
35
|
+
'</filter>' +
|
|
36
|
+
"<rect width='100%' height='100%' filter='url(%23n)'/>" +
|
|
37
|
+
'</svg>',
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
const bg = $derived(`url("data:image/svg+xml;utf8,${svg}")`)
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<div
|
|
44
|
+
style:background-image={bg}
|
|
45
|
+
style:opacity
|
|
46
|
+
style:mix-blend-mode={blend}
|
|
47
|
+
class="Noise {klass}"
|
|
48
|
+
aria-hidden="true"
|
|
49
|
+
></div>
|
|
50
|
+
|
|
51
|
+
<style>
|
|
52
|
+
.Noise {
|
|
53
|
+
position: absolute;
|
|
54
|
+
inset: 0;
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
}
|
|
57
|
+
</style>
|
package/components/SVG/index.js
CHANGED
package/components/Status.svelte
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
let {
|
|
2
|
+
let {
|
|
3
|
+
class: klass = '',
|
|
4
|
+
status = $bindable('info'),
|
|
5
|
+
statusText = '',
|
|
6
|
+
children,
|
|
7
|
+
...rest
|
|
8
|
+
} = $props()
|
|
9
|
+
|
|
10
|
+
const statusClasses = {
|
|
11
|
+
info: 'status-info',
|
|
12
|
+
success: 'status-success',
|
|
13
|
+
error: 'status-error',
|
|
14
|
+
}
|
|
3
15
|
|
|
4
16
|
function getStatusString(status) {
|
|
5
17
|
if (typeof status === 'string') return status
|
|
@@ -9,17 +21,23 @@
|
|
|
9
21
|
return 'info'
|
|
10
22
|
}
|
|
11
23
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
success: 'status-success',
|
|
15
|
-
error: 'status-error',
|
|
24
|
+
function getStatusClass(status) {
|
|
25
|
+
return statusClasses[getStatusString(status)]
|
|
16
26
|
}
|
|
17
27
|
|
|
18
|
-
let statusClass = $derived
|
|
28
|
+
let statusClass = $derived(getStatusClass(status))
|
|
29
|
+
let role = $derived(getStatusString(status) === 'error' ? 'alert' : 'status')
|
|
19
30
|
</script>
|
|
20
31
|
|
|
21
|
-
<
|
|
22
|
-
{
|
|
23
|
-
|
|
32
|
+
<output
|
|
33
|
+
{...rest}
|
|
34
|
+
class="status {statusClass} {klass}"
|
|
35
|
+
class:sr-only={!statusText && !children}
|
|
36
|
+
{role}
|
|
37
|
+
>
|
|
38
|
+
{#if statusText}
|
|
39
|
+
{statusText}
|
|
40
|
+
{:else}
|
|
41
|
+
{@render children?.()}
|
|
24
42
|
{/if}
|
|
25
|
-
</
|
|
43
|
+
</output>
|
|
@@ -23,7 +23,11 @@
|
|
|
23
23
|
|
|
24
24
|
const tabcordionId = randomString()
|
|
25
25
|
const tabpanelsId = randomString()
|
|
26
|
-
|
|
26
|
+
function getActiveIndexProp() {
|
|
27
|
+
return activeIndexProp
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let activeIndex = $state(getActiveIndexProp())
|
|
27
31
|
const items = $state([])
|
|
28
32
|
|
|
29
33
|
setContext('tabcordion', {
|
|
@@ -33,6 +37,10 @@
|
|
|
33
37
|
},
|
|
34
38
|
})
|
|
35
39
|
|
|
40
|
+
$effect(() => {
|
|
41
|
+
activeIndex = activeIndexProp
|
|
42
|
+
})
|
|
43
|
+
|
|
36
44
|
$effect(() => {
|
|
37
45
|
const tabStore = getTab(tabpanelsId)
|
|
38
46
|
if (!tabStore) return
|
package/package.json
CHANGED