@splendidlabz/svelte 4.12.0 → 4.12.1
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/package.json +11 -8
- package/CHANGELOG.md +0 -636
- package/common.js +0 -21
- package/components/Accordion/accordion-controlled.spec.js +0 -14
- package/components/DisclosureOld/Drawer/Drawer.svelte +0 -31
- package/components/DisclosureOld/Drawer/DrawerCloseButton.svelte +0 -37
- package/components/DisclosureOld/Drawer/DrawerContent.svelte +0 -105
- package/components/DisclosureOld/Drawer/DrawerTrigger.svelte +0 -11
- package/components/DisclosureOld/Drawer/drawer.js +0 -18
- package/components/DisclosureOld/Drawer/index.js +0 -6
- package/components/DisclosureOld/Dropdown/DropdownContent.svelte +0 -15
- package/components/DisclosureOld/Dropdown/DropdownTrigger.svelte +0 -14
- package/components/DisclosureOld/Dropdown/dropdown.js +0 -4
- package/components/DisclosureOld/Dropdown/index.js +0 -4
- package/components/DisclosureOld/Modal/Modal.svelte +0 -30
- package/components/DisclosureOld/Modal/ModalCloseButton.svelte +0 -7
- package/components/DisclosureOld/Modal/ModalContent.svelte +0 -50
- package/components/DisclosureOld/Modal/ModalTrigger.svelte +0 -11
- package/components/DisclosureOld/Modal/exit-intent.js +0 -17
- package/components/DisclosureOld/Modal/index.js +0 -5
- package/components/DisclosureOld/Modal/modal.js +0 -4
- package/components/DisclosureOld/Old/DisclosureContentOld.svelte +0 -109
- package/components/DisclosureOld/Old/DisclosureTriggerOld.svelte +0 -62
- package/components/DisclosureOld/Popover/PopoverCloseButton.svelte +0 -32
- package/components/DisclosureOld/Popover/PopoverContent.svelte +0 -107
- package/components/DisclosureOld/Popover/PopoverTrigger.svelte +0 -33
- package/components/DisclosureOld/Popover/floating.js +0 -171
- package/components/DisclosureOld/Popover/index.js +0 -5
- package/components/DisclosureOld/Popover/popover.js +0 -18
- package/components/DisclosureOld/Popover/references/FollowTheMouse.svelte +0 -45
- package/components/DisclosureOld/Tooltip/Tooltip.svelte +0 -14
- package/components/DisclosureOld/Tooltip/TooltipContent.svelte +0 -7
- package/components/DisclosureOld/Tooltip/TooltipTrigger.svelte +0 -33
- package/components/DisclosureOld/Tooltip/index.js +0 -5
- package/components/DisclosureOld/Tooltip/tooltip.js +0 -22
- package/components/DisclosureOld/disclosure-store.js +0 -48
- package/components/DisclosureOld/disclosure.js +0 -443
- package/components/DisclosureOld/disclosure.svelte.js +0 -432
- package/components/Markdown/Markdown.spec.js +0 -48
- package/components/Tabs/tabs-css.spec.js +0 -43
- package/components/Tabs/tabs.spec.js +0 -553
- package/eslint.config.js +0 -2
- package/jsconfig.json +0 -16
- package/svelte.config.js +0 -13
- package/test-utils.js +0 -44
- package/vitest.config.js +0 -11
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { randomString } from '@splendidlabz/utils/dom'
|
|
3
|
-
|
|
4
|
-
import DrawerCloseButton from './DrawerCloseButton.svelte'
|
|
5
|
-
import DrawerContent from './DrawerContent.svelte'
|
|
6
|
-
import DrawerTrigger from './DrawerTrigger.svelte'
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
id = randomString(8),
|
|
10
|
-
triggerOptions = {},
|
|
11
|
-
contentOptions = {},
|
|
12
|
-
closeButtonOptions = {},
|
|
13
|
-
|
|
14
|
-
// Slots
|
|
15
|
-
trigger,
|
|
16
|
-
contentHeader,
|
|
17
|
-
content,
|
|
18
|
-
} = $props()
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
<DrawerTrigger target={id} {...triggerOptions}>
|
|
22
|
-
{#if trigger}{@render trigger()}{/if}
|
|
23
|
-
</DrawerTrigger>
|
|
24
|
-
|
|
25
|
-
<DrawerContent {id} {...contentOptions}>
|
|
26
|
-
<div class="horizontal">
|
|
27
|
-
{#if contentHeader}{@render contentHeader()}{/if}
|
|
28
|
-
<DrawerCloseButton {...closeButtonOptions} />
|
|
29
|
-
</div>
|
|
30
|
-
{#if content}{@render content()}{/if}
|
|
31
|
-
</DrawerContent>
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import Icon from '../../Icon/Icon.svelte'
|
|
3
|
-
import { close, getDisclosure } from '../disclosure.svelte.js'
|
|
4
|
-
|
|
5
|
-
const {
|
|
6
|
-
class: klass = '',
|
|
7
|
-
icon = 'tabler:x',
|
|
8
|
-
iconClass = '',
|
|
9
|
-
target = '',
|
|
10
|
-
children,
|
|
11
|
-
...rest
|
|
12
|
-
} = $props()
|
|
13
|
-
|
|
14
|
-
let button = null
|
|
15
|
-
|
|
16
|
-
function closeDrawer() {
|
|
17
|
-
const id =
|
|
18
|
-
document.querySelector(`${target}`)?.id ||
|
|
19
|
-
button.closest('.drawer-content').id
|
|
20
|
-
const d = getDisclosure(id)
|
|
21
|
-
close(d, { shouldFocusWhenClosing: true })
|
|
22
|
-
}
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<button
|
|
26
|
-
bind:this={button}
|
|
27
|
-
class="drawer-close-button {klass}"
|
|
28
|
-
aria-label="Close dialog"
|
|
29
|
-
{...rest}
|
|
30
|
-
onclick={closeDrawer}
|
|
31
|
-
>
|
|
32
|
-
{#if children}
|
|
33
|
-
{@render children()}
|
|
34
|
-
{:else}
|
|
35
|
-
<Icon class={iconClass} {icon} />
|
|
36
|
-
{/if}
|
|
37
|
-
</button>
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { splitObject, toStyleString } from '@splendidlabz/utils'
|
|
3
|
-
import {
|
|
4
|
-
TRANSITION_OPT_KEYS,
|
|
5
|
-
applyTransition,
|
|
6
|
-
mergeOpts,
|
|
7
|
-
} from '../../../utils/index.js'
|
|
8
|
-
import Portal from '../../Portal.svelte'
|
|
9
|
-
import { getDisclosure } from '../disclosure.svelte.js'
|
|
10
|
-
import DisclosureContent from '../Disclosure/DisclosureContent.svelte'
|
|
11
|
-
import {
|
|
12
|
-
DRAWER_CONTENT_OPTS,
|
|
13
|
-
DRAWER_POSITION_OPTS,
|
|
14
|
-
getTBLRValues,
|
|
15
|
-
} from './drawer.js'
|
|
16
|
-
|
|
17
|
-
let {
|
|
18
|
-
ref = $bindable(null),
|
|
19
|
-
position = DRAWER_CONTENT_OPTS.position,
|
|
20
|
-
...p
|
|
21
|
-
} = $props()
|
|
22
|
-
|
|
23
|
-
const opts = $derived(
|
|
24
|
-
mergeOpts(DRAWER_CONTENT_OPTS, DRAWER_POSITION_OPTS[position], p),
|
|
25
|
-
)
|
|
26
|
-
|
|
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)
|
|
35
|
-
|
|
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
|
-
})
|
|
50
|
-
|
|
51
|
-
const transitionSplit = $derived(splitObject(rest, TRANSITION_OPT_KEYS))
|
|
52
|
-
const transitionOpts = $derived(transitionSplit.picked)
|
|
53
|
-
|
|
54
|
-
const TBLR = $derived(getTBLRValues({ placement, position }))
|
|
55
|
-
const style = $derived(toStyleString(TBLR) + styleString)
|
|
56
|
-
|
|
57
|
-
let d = $derived(getDisclosure(id))
|
|
58
|
-
let show = $derived(d?.state.show)
|
|
59
|
-
|
|
60
|
-
// Temp remove push transition
|
|
61
|
-
// Replace transition string with our custom push transition
|
|
62
|
-
// if (options?.transition === 'push') options.transition = push
|
|
63
|
-
//
|
|
64
|
-
// NOTE: FLY transition seems to be broken...
|
|
65
|
-
</script>
|
|
66
|
-
|
|
67
|
-
{#snippet drawerBackdrop()}
|
|
68
|
-
<div
|
|
69
|
-
class="drawer-backdrop {backdropClass} "
|
|
70
|
-
class:backdrop-blur={backdrop && blurBackdrop}
|
|
71
|
-
transition:applyTransition|global={{
|
|
72
|
-
...transitionOpts,
|
|
73
|
-
transition: 'fade',
|
|
74
|
-
}}
|
|
75
|
-
>
|
|
76
|
-
{@render drawerContent()}
|
|
77
|
-
</div>
|
|
78
|
-
{/snippet}
|
|
79
|
-
|
|
80
|
-
{#snippet drawerContent({ portal = false } = {})}
|
|
81
|
-
<DisclosureContent
|
|
82
|
-
{...rest}
|
|
83
|
-
{id}
|
|
84
|
-
{style}
|
|
85
|
-
class="drawer-content {klass}"
|
|
86
|
-
componentName="DrawerContent"
|
|
87
|
-
{placement}
|
|
88
|
-
{portal}
|
|
89
|
-
bind:ref
|
|
90
|
-
/>
|
|
91
|
-
{/snippet}
|
|
92
|
-
|
|
93
|
-
{#if show}
|
|
94
|
-
{#if position === 'fixed'}
|
|
95
|
-
{#if portal}
|
|
96
|
-
<Portal>{@render drawerBackdrop()}</Portal>
|
|
97
|
-
{:else}
|
|
98
|
-
{@render drawerBackdrop()}
|
|
99
|
-
{/if}
|
|
100
|
-
{/if}
|
|
101
|
-
|
|
102
|
-
{#if position === 'absolute' || position === 'static'}
|
|
103
|
-
{@render drawerContent()}
|
|
104
|
-
{/if}
|
|
105
|
-
{/if}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Use logical properties straight up
|
|
2
|
-
export function getTBLRValues({ placement, position }) {
|
|
3
|
-
const style = { position }
|
|
4
|
-
|
|
5
|
-
if (placement === 'top' || placement === 'bottom') {
|
|
6
|
-
style.insetInline = 0
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (placement === 'left' || placement === 'right') {
|
|
10
|
-
style.insetBlock = 0
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (placement === 'top') style.insetBlockStart = 0
|
|
14
|
-
if (placement === 'bottom') style.insetBlockEnd = 0
|
|
15
|
-
if (placement === 'left') style.insetInlineStart = 0
|
|
16
|
-
if (placement === 'right') style.insetInlineEnd = 0
|
|
17
|
-
return style
|
|
18
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import Drawer from './Drawer.svelte'
|
|
2
|
-
import DrawerCloseButton from './DrawerCloseButton.svelte'
|
|
3
|
-
import DrawerContent from './DrawerContent.svelte'
|
|
4
|
-
import DrawerTrigger from './DrawerTrigger.svelte'
|
|
5
|
-
|
|
6
|
-
export { Drawer, DrawerCloseButton, DrawerContent, DrawerTrigger }
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { PopoverContent } from '../Popover'
|
|
3
|
-
import { defaultDropdownFloatingOpts } from './dropdown.js'
|
|
4
|
-
|
|
5
|
-
export let klass
|
|
6
|
-
export { klass as class }
|
|
7
|
-
</script>
|
|
8
|
-
|
|
9
|
-
<PopoverContent
|
|
10
|
-
class="DropdownContent {klass}"
|
|
11
|
-
options={defaultDropdownFloatingOpts}
|
|
12
|
-
{...$$restProps}
|
|
13
|
-
>
|
|
14
|
-
<slot />
|
|
15
|
-
</PopoverContent>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import SVG from '../../Icon/Icon.svelte'
|
|
3
|
-
import { PopoverTrigger } from '../Popover'
|
|
4
|
-
|
|
5
|
-
export let klass
|
|
6
|
-
export let icon = 'tabler:chevron-down'
|
|
7
|
-
|
|
8
|
-
export { klass as class }
|
|
9
|
-
</script>
|
|
10
|
-
|
|
11
|
-
<PopoverTrigger class="DropdownTrigger {klass}" {...$$restProps}>
|
|
12
|
-
<slot />
|
|
13
|
-
<SVG {icon} />
|
|
14
|
-
</PopoverTrigger>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { randomString } from '@splendidlabz/utils/dom'
|
|
3
|
-
import ModalCloseButton from './ModalCloseButton.svelte'
|
|
4
|
-
import ModalContent from './ModalContent.svelte'
|
|
5
|
-
import ModalTrigger from './ModalTrigger.svelte'
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
id = randomString(8),
|
|
9
|
-
triggerOptions = {},
|
|
10
|
-
contentOptions = {},
|
|
11
|
-
closeButtonOptions = {},
|
|
12
|
-
|
|
13
|
-
// Slots
|
|
14
|
-
trigger,
|
|
15
|
-
contentHeader,
|
|
16
|
-
content,
|
|
17
|
-
} = $props()
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<ModalTrigger target={id} {...triggerOptions}>
|
|
21
|
-
{#if trigger}{@render trigger()}{/if}
|
|
22
|
-
</ModalTrigger>
|
|
23
|
-
|
|
24
|
-
<ModalContent {id} {...contentOptions}>
|
|
25
|
-
<div class="horizontal">
|
|
26
|
-
{#if contentHeader}{@render contentHeader()}{/if}
|
|
27
|
-
<ModalCloseButton {...closeButtonOptions} />
|
|
28
|
-
</div>
|
|
29
|
-
{#if content}{@render content()}{/if}
|
|
30
|
-
</ModalContent>
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { splitObject } from '@splendidlabz/utils'
|
|
3
|
-
import { mergeOpts } from '../../../utils'
|
|
4
|
-
import {
|
|
5
|
-
TRANSITION_OPT_KEYS,
|
|
6
|
-
applyTransition,
|
|
7
|
-
} from '../../../utils/transitions.js'
|
|
8
|
-
import DisclosureContent from '../Disclosure/DisclosureContent.svelte'
|
|
9
|
-
import { MODAL_CONTENT_OPTS } from './modal.js'
|
|
10
|
-
|
|
11
|
-
let { ref = $bindable(null), ...p } = $props()
|
|
12
|
-
const opts = $derived(mergeOpts(MODAL_CONTENT_OPTS, p))
|
|
13
|
-
|
|
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
|
-
})
|
|
28
|
-
|
|
29
|
-
const transitionSplit = $derived(splitObject(rest, TRANSITION_OPT_KEYS))
|
|
30
|
-
const transitionOpts = $derived(transitionSplit.picked)
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
{#snippet modalBackdrop()}
|
|
34
|
-
<div
|
|
35
|
-
class="modal-backdrop {backdropClass} "
|
|
36
|
-
class:backdrop-blur={backdrop && blurBackdrop}
|
|
37
|
-
transition:applyTransition|global={{
|
|
38
|
-
...transitionOpts,
|
|
39
|
-
transition: 'fade',
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
{@render modalContent()}
|
|
43
|
-
</div>
|
|
44
|
-
{/snippet}
|
|
45
|
-
|
|
46
|
-
{#snippet modalContent()}
|
|
47
|
-
<DisclosureContent class="modal-content {klass}" bind:ref {...rest} />
|
|
48
|
-
{/snippet}
|
|
49
|
-
|
|
50
|
-
{@render modalBackdrop()}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
export function exitIntent(node) {
|
|
3
|
-
document.addEventListener('pointerout', exiting)
|
|
4
|
-
|
|
5
|
-
function exiting(event) {
|
|
6
|
-
const { toElement, relatedTarget } = event
|
|
7
|
-
if (toElement === null && relatedTarget === null) {
|
|
8
|
-
node.dispatchEvent(new CustomEvent('exit'))
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
destroy() {
|
|
14
|
-
document.removeEventListener('pointerout', exiting)
|
|
15
|
-
},
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { splitObject } from '@splendidlabz/utils'
|
|
3
|
-
import {
|
|
4
|
-
hasAccessibleName,
|
|
5
|
-
markActiveAnchorIn,
|
|
6
|
-
scrollToElement,
|
|
7
|
-
} from '@splendidlabz/utils/dom'
|
|
8
|
-
import {
|
|
9
|
-
TRANSITION_OPT_KEYS,
|
|
10
|
-
applyTransition,
|
|
11
|
-
} from '../../../utils/transitions.js'
|
|
12
|
-
import Portal from '../../Portal.svelte'
|
|
13
|
-
import {
|
|
14
|
-
DISCLOSURE_CONTENT_OPT_KEYS,
|
|
15
|
-
disclosureContent,
|
|
16
|
-
getDisclosure,
|
|
17
|
-
} from '../disclosure.svelte.js'
|
|
18
|
-
|
|
19
|
-
let { ref = $bindable(null), ...p } = $props()
|
|
20
|
-
|
|
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
|
-
})
|
|
47
|
-
|
|
48
|
-
const disclosureSplit = $derived(
|
|
49
|
-
splitObject(restProps, DISCLOSURE_CONTENT_OPT_KEYS),
|
|
50
|
-
)
|
|
51
|
-
const disclosureContentOpts = $derived(disclosureSplit.picked)
|
|
52
|
-
const rest = $derived(disclosureSplit.omitted)
|
|
53
|
-
|
|
54
|
-
const transitionSplit = $derived(
|
|
55
|
-
splitObject(rest, TRANSITION_OPT_KEYS),
|
|
56
|
-
)
|
|
57
|
-
const transitionOpts = $derived(transitionSplit.picked)
|
|
58
|
-
const remaining = $derived(transitionSplit.omitted)
|
|
59
|
-
|
|
60
|
-
$effect(() => {
|
|
61
|
-
if (!id) throw new Error(`${componentName} requires an id`)
|
|
62
|
-
|
|
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
|
-
})
|
|
70
|
-
|
|
71
|
-
let d = $derived(getDisclosure(id))
|
|
72
|
-
let show = $derived(d?.state.show)
|
|
73
|
-
|
|
74
|
-
$effect(_ => {
|
|
75
|
-
if (show && ref && scrollToAnchor) {
|
|
76
|
-
const anchor = markActiveAnchorIn(ref)
|
|
77
|
-
scrollToElement(anchor)
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
</script>
|
|
81
|
-
|
|
82
|
-
<!-- Snippets -->
|
|
83
|
-
{#snippet dc()}
|
|
84
|
-
<div
|
|
85
|
-
{...remaining}
|
|
86
|
-
{id}
|
|
87
|
-
class="disclosure-content {klass}"
|
|
88
|
-
{role}
|
|
89
|
-
bind:this={ref}
|
|
90
|
-
use:disclosureContent={{ options: disclosureContentOpts }}
|
|
91
|
-
aria-label={ariaLabel}
|
|
92
|
-
aria-labelledby={ariaLabelledBy}
|
|
93
|
-
aria-describedby={ariaDescribedBy}
|
|
94
|
-
transition:applyTransition|global={transitionOpts}
|
|
95
|
-
>
|
|
96
|
-
{#if children}
|
|
97
|
-
{@render children()}
|
|
98
|
-
{/if}
|
|
99
|
-
</div>
|
|
100
|
-
{/snippet}
|
|
101
|
-
|
|
102
|
-
<!-- Render -->
|
|
103
|
-
{#if show}
|
|
104
|
-
{#if portal}
|
|
105
|
-
<Portal>{@render dc()}</Portal>
|
|
106
|
-
{:else}
|
|
107
|
-
{@render dc()}
|
|
108
|
-
{/if}
|
|
109
|
-
{/if}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import { splitObject } from '@splendidlabz/utils'
|
|
3
|
-
import Icon from '../../Icon/Icon.svelte'
|
|
4
|
-
import {
|
|
5
|
-
DISCLOSURE_TRIGGER_OPT_KEYS,
|
|
6
|
-
disclosureTrigger,
|
|
7
|
-
} from '../disclosure.svelte.js'
|
|
8
|
-
|
|
9
|
-
let { show = $bindable(false), ...p } = $props()
|
|
10
|
-
|
|
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
|
-
})
|
|
31
|
-
|
|
32
|
-
const triggerSplit = $derived(
|
|
33
|
-
splitObject(restProps, DISCLOSURE_TRIGGER_OPT_KEYS),
|
|
34
|
-
)
|
|
35
|
-
const triggerOpts = $derived(triggerSplit.picked)
|
|
36
|
-
const rest = $derived(triggerSplit.omitted)
|
|
37
|
-
|
|
38
|
-
$effect(() => {
|
|
39
|
-
if (!target)
|
|
40
|
-
throw new Error(`${componentName} must contain a target property`)
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
// TODO: Test creating an IconSnippet to render the icon vs contents
|
|
44
|
-
// <script module> currently breaks when prettier is enabled. So, ¯\_(ツ)_/¯ if we can ever do that.
|
|
45
|
-
</script>
|
|
46
|
-
|
|
47
|
-
<button
|
|
48
|
-
{...rest}
|
|
49
|
-
{target}
|
|
50
|
-
class="button {klass}"
|
|
51
|
-
aria-haspopup={ariaHasPopup}
|
|
52
|
-
use:disclosureTrigger={{
|
|
53
|
-
state: { show },
|
|
54
|
-
options: triggerOpts,
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
{#if children}
|
|
58
|
-
{@render children()}
|
|
59
|
-
{:else if icon}
|
|
60
|
-
<Icon class={iconClass} {icon} />
|
|
61
|
-
{/if}
|
|
62
|
-
</button>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import SVG from '../../Icon/Icon.svelte'
|
|
3
|
-
import {
|
|
4
|
-
close,
|
|
5
|
-
getDisclosure,
|
|
6
|
-
} from '../Disclosure/Old/disclosure.jsd/disclosure.js'
|
|
7
|
-
|
|
8
|
-
export let klass = ''
|
|
9
|
-
export { klass as class }
|
|
10
|
-
export let icon = 'tabler:x'
|
|
11
|
-
export let iconClass = ''
|
|
12
|
-
export let target = null
|
|
13
|
-
|
|
14
|
-
let button = null
|
|
15
|
-
|
|
16
|
-
function handleClick() {
|
|
17
|
-
const id = target || button.closest('.PopoverContent').id
|
|
18
|
-
const d = getDisclosure(id)
|
|
19
|
-
close(d, { shouldFocusTrigger: true })
|
|
20
|
-
}
|
|
21
|
-
</script>
|
|
22
|
-
|
|
23
|
-
<!-- aria-label="Close dialog" -->
|
|
24
|
-
|
|
25
|
-
<button
|
|
26
|
-
class="PopoverCloseButton Button-icon {klass}"
|
|
27
|
-
bind:this={button}
|
|
28
|
-
on:click={handleClick}
|
|
29
|
-
{...$$restProps}
|
|
30
|
-
>
|
|
31
|
-
<slot><SVG class={iconClass} {icon} /></slot>
|
|
32
|
-
</button>
|