@svelte-atoms/core 1.0.0-alpha.44 → 1.0.0-alpha.46
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/README.md +13 -0
- package/dist/components/accordion/item/accordion-item-body.svelte +5 -8
- package/dist/components/accordion/item/accordion-item-header.svelte +0 -13
- package/dist/components/accordion/item/accordion-item-indicator.svelte +0 -12
- package/dist/components/accordion/item/accordion-item-root.svelte +0 -12
- package/dist/components/alert/alert-actions.svelte +0 -12
- package/dist/components/alert/alert-close-button.svelte +0 -12
- package/dist/components/alert/alert-content.svelte +0 -12
- package/dist/components/alert/alert-description.svelte +0 -12
- package/dist/components/alert/alert-icon.svelte +0 -12
- package/dist/components/alert/alert-root.svelte +1 -13
- package/dist/components/alert/alert-title.svelte +0 -12
- package/dist/components/atom/html-atom.svelte +31 -17
- package/dist/components/atom/types.d.ts +9 -0
- package/dist/components/atom/utils/base.d.ts +6 -0
- package/dist/components/atom/utils/base.js +8 -0
- package/dist/components/atom/utils/cache.d.ts +17 -0
- package/dist/components/atom/utils/cache.js +134 -0
- package/dist/components/atom/utils/classes.d.ts +14 -0
- package/dist/components/atom/utils/classes.js +42 -0
- package/dist/components/atom/utils/constants.d.ts +9 -0
- package/dist/components/atom/utils/constants.js +9 -0
- package/dist/components/atom/utils/index.d.ts +6 -0
- package/dist/components/atom/utils/index.js +5 -0
- package/dist/components/atom/utils/preset.d.ts +22 -0
- package/dist/components/atom/utils/preset.js +94 -0
- package/dist/components/atom/utils/props.d.ts +13 -0
- package/dist/components/atom/utils/props.js +60 -0
- package/dist/components/atom/utils/variants.d.ts +31 -0
- package/dist/components/atom/utils/variants.js +270 -0
- package/dist/components/card/card-body.svelte +0 -12
- package/dist/components/card/card-description.svelte +0 -12
- package/dist/components/card/card-footer.svelte +0 -12
- package/dist/components/card/card-header.svelte +0 -12
- package/dist/components/card/card-media.svelte +0 -12
- package/dist/components/card/card-root.svelte +0 -12
- package/dist/components/card/card-subtitle.svelte +0 -12
- package/dist/components/card/card-title.svelte +0 -12
- package/dist/components/collapsible/collapsible-body.svelte +5 -12
- package/dist/components/collapsible/collapsible-header.svelte +0 -12
- package/dist/components/collapsible/collapsible-indicator.svelte +0 -12
- package/dist/components/collapsible/collapsible-root.svelte +0 -12
- package/dist/components/combobox/combobox-control.svelte +0 -12
- package/dist/components/combobox/combobox-item.svelte +0 -12
- package/dist/components/combobox/combobox-item.svelte.d.ts +0 -6
- package/dist/components/combobox/index.d.ts +1 -1
- package/dist/components/container/container.svelte +0 -12
- package/dist/components/datagrid/column/datagrid-column-sort-icon.svelte +3 -12
- package/dist/components/datagrid/column/datagrid-column-sort-icon.svelte.d.ts +0 -6
- package/dist/components/datagrid/datagrid-body.svelte +17 -1
- package/dist/components/dialog/dialog-body.svelte +0 -12
- package/dist/components/dialog/dialog-close-button.svelte +0 -12
- package/dist/components/dialog/dialog-close.svelte +0 -12
- package/dist/components/dialog/dialog-content.svelte +4 -12
- package/dist/components/dialog/dialog-description.svelte +0 -12
- package/dist/components/dialog/dialog-footer.svelte +0 -12
- package/dist/components/dialog/dialog-header.svelte +0 -12
- package/dist/components/dialog/dialog-title.svelte +0 -12
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/dialog/index.js +3 -0
- package/dist/components/drawer/drawer-backdrop.svelte +0 -12
- package/dist/components/drawer/drawer-body.svelte +0 -12
- package/dist/components/drawer/drawer-content.svelte +5 -12
- package/dist/components/drawer/drawer-description.svelte +0 -12
- package/dist/components/drawer/drawer-footer.svelte +0 -12
- package/dist/components/drawer/drawer-header.svelte +0 -12
- package/dist/components/drawer/drawer-root.svelte +5 -4
- package/dist/components/drawer/drawer-title.svelte +0 -12
- package/dist/components/dropdown/dropdown-placeholder.svelte +0 -6
- package/dist/components/dropdown/dropdown-placeholder.svelte.d.ts +0 -6
- package/dist/components/dropdown/dropdown-query.svelte +0 -12
- package/dist/components/dropdown-menu/bond.svelte.d.ts +0 -4
- package/dist/components/dropdown-menu/dropdown-menu-content.svelte +0 -12
- package/dist/components/dropdown-menu/dropdown-menu-content.svelte.d.ts +0 -6
- package/dist/components/dropdown-menu/index.d.ts +1 -1
- package/dist/components/form/field/bond.svelte.d.ts +29 -17
- package/dist/components/form/field/bond.svelte.js +73 -49
- package/dist/components/form/field/field-control.svelte +21 -18
- package/dist/components/form/field/field-label.svelte +2 -2
- package/dist/components/form/field/field-root.svelte +2 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/input/input-file-control.svelte +0 -12
- package/dist/components/input/input-icon.svelte +3 -3
- package/dist/components/input/input-number-control.svelte +28 -35
- package/dist/components/input/input-text-control.svelte +8 -3
- package/dist/components/input/input-url-control.svelte +2 -2
- package/dist/components/input/types.d.ts +4 -4
- package/dist/components/kbd/index.d.ts +3 -0
- package/dist/components/kbd/index.js +3 -0
- package/dist/components/kbd/kbd.svelte +19 -0
- package/dist/components/kbd/kbd.svelte.d.ts +4 -0
- package/dist/components/kbd/shortcut.svelte +38 -0
- package/dist/components/kbd/shortcut.svelte.d.ts +4 -0
- package/dist/components/kbd/types.d.ts +20 -0
- package/dist/components/kbd/types.js +1 -0
- package/dist/components/layer/layer-inner.svelte +0 -12
- package/dist/components/layer/layer-root.svelte +0 -12
- package/dist/components/menu/menu-content.svelte +0 -12
- package/dist/components/menu/menu-content.svelte.d.ts +0 -6
- package/dist/components/popover/bond.svelte.d.ts +29 -1
- package/dist/components/popover/bond.svelte.js +55 -2
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/popover/popover-arrow.svelte +4 -2
- package/dist/components/popover/popover-content.svelte +17 -90
- package/dist/components/popover/popover-overlay.svelte +98 -0
- package/dist/components/popover/popover-overlay.svelte.d.ts +4 -0
- package/dist/components/popover/popover-trigger.svelte +9 -0
- package/dist/components/popover/strategies/floating.svelte +10 -10
- package/dist/components/popover/types.d.ts +7 -2
- package/dist/components/portal/portal-inner.svelte +0 -12
- package/dist/components/portal/portal-root.svelte +0 -12
- package/dist/components/portal/types.d.ts +1 -1
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/progress/index.js +3 -0
- package/dist/components/progress/progress-circular.svelte +99 -0
- package/dist/components/progress/progress-circular.svelte.d.ts +6 -0
- package/dist/components/progress/progress-linear.svelte +66 -0
- package/dist/components/progress/progress-linear.svelte.d.ts +6 -0
- package/dist/components/progress/types.d.ts +18 -0
- package/dist/components/progress/types.js +1 -0
- package/dist/components/scrollable/scrollable-container.svelte +0 -12
- package/dist/components/scrollable/scrollable-content.svelte +0 -12
- package/dist/components/scrollable/scrollable-root.svelte +0 -12
- package/dist/components/scrollable/scrollable-thumb.svelte +1 -12
- package/dist/components/scrollable/scrollable-track.svelte +0 -12
- package/dist/components/select/bond.svelte.d.ts +0 -4
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/select-placeholder.svelte +0 -6
- package/dist/components/select/select-placeholder.svelte.d.ts +0 -6
- package/dist/components/sidebar/sidebar-content.svelte +5 -12
- package/dist/components/stack/bond.svelte.js +6 -0
- package/dist/components/stack/stack-item.svelte +4 -0
- package/dist/components/switch/switch.svelte +2 -0
- package/dist/components/tabs/tab/tab-header.svelte +4 -4
- package/dist/components/tabs/tabs-body.svelte +0 -2
- package/dist/components/tabs/tabs-root.svelte +11 -3
- package/dist/components/toast/atoms.d.ts +1 -1
- package/dist/components/toast/atoms.js +1 -1
- package/dist/components/toast/attachments.svelte.d.ts +10 -2
- package/dist/components/toast/attachments.svelte.js +9 -1
- package/dist/components/toast/bond.svelte.d.ts +73 -0
- package/dist/components/toast/bond.svelte.js +132 -0
- package/dist/components/toast/index.d.ts +1 -1
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toast/toast-close.svelte +47 -0
- package/dist/components/toast/toast-close.svelte.d.ts +26 -0
- package/dist/components/toast/toast-description.svelte +16 -24
- package/dist/components/toast/toast-description.svelte.d.ts +15 -19
- package/dist/components/toast/toast-root.svelte +36 -26
- package/dist/components/toast/toast-root.svelte.d.ts +16 -15
- package/dist/components/toast/toast-title.svelte +17 -22
- package/dist/components/toast/toast-title.svelte.d.ts +13 -13
- package/dist/components/toast/toaster.svelte.d.ts +38 -0
- package/dist/components/toast/toaster.svelte.js +107 -0
- package/dist/components/toast/types.d.ts +13 -21
- package/dist/components/tree/tree-body.svelte +5 -12
- package/dist/components/tree/tree-header.svelte +0 -12
- package/dist/components/tree/tree-indicator.svelte +0 -12
- package/dist/components/tree/tree-root.svelte +0 -12
- package/dist/context/preset.svelte.d.ts +53 -37
- package/dist/context/preset.svelte.js +29 -3
- package/package.json +1 -1
- package/dist/components/atom/utils.d.ts +0 -44
- package/dist/components/atom/utils.js +0 -275
- package/dist/components/popover/popover-engine.svelte +0 -118
- package/dist/components/popover/popover-engine.svelte.d.ts +0 -3
- package/dist/components/toast/bond.d.ts +0 -35
- package/dist/components/toast/bond.js +0 -59
- package/dist/components/toast/manager.svelte.d.ts +0 -38
- package/dist/components/toast/manager.svelte.js +0 -82
- package/dist/components/toast/toast-root-managed.svelte +0 -64
- package/dist/components/toast/toast-root-managed.svelte.d.ts +0 -7
- package/dist/components/toast/toast-toaster.svelte +0 -42
- package/dist/components/toast/toast-toaster.svelte.d.ts +0 -4
- /package/dist/components/popover/{motion.d.ts → motion.svelte.d.ts} +0 -0
- /package/dist/components/popover/{motion.js → motion.svelte.js} +0 -0
|
@@ -8,12 +8,6 @@
|
|
|
8
8
|
let {
|
|
9
9
|
class: klass = '',
|
|
10
10
|
children,
|
|
11
|
-
onmount,
|
|
12
|
-
ondestroy,
|
|
13
|
-
animate,
|
|
14
|
-
enter,
|
|
15
|
-
exit,
|
|
16
|
-
initial,
|
|
17
11
|
...restProps
|
|
18
12
|
}: ScrollableContentProps<E, B> = $props();
|
|
19
13
|
|
|
@@ -32,12 +26,6 @@
|
|
|
32
26
|
as="div"
|
|
33
27
|
preset="scrollable.content"
|
|
34
28
|
class={['scrollable-content border-border h-full max-h-full', '$preset', klass]}
|
|
35
|
-
{enter}
|
|
36
|
-
{exit}
|
|
37
|
-
{initial}
|
|
38
|
-
{animate}
|
|
39
|
-
{onmount}
|
|
40
|
-
{ondestroy}
|
|
41
29
|
{...contentProps}
|
|
42
30
|
>
|
|
43
31
|
{#if children}
|
|
@@ -16,12 +16,6 @@
|
|
|
16
16
|
open = true,
|
|
17
17
|
factory = _factory,
|
|
18
18
|
children,
|
|
19
|
-
onmount,
|
|
20
|
-
ondestroy,
|
|
21
|
-
animate,
|
|
22
|
-
enter,
|
|
23
|
-
exit,
|
|
24
|
-
initial,
|
|
25
19
|
...restProps
|
|
26
20
|
}: ScrollableRootProps<E, B> = $props();
|
|
27
21
|
|
|
@@ -94,12 +88,6 @@
|
|
|
94
88
|
as="div"
|
|
95
89
|
preset="scrollable"
|
|
96
90
|
class={['scrollable-root border-border relative box-content overflow-hidden', '$preset', klass]}
|
|
97
|
-
{enter}
|
|
98
|
-
{exit}
|
|
99
|
-
{initial}
|
|
100
|
-
{animate}
|
|
101
|
-
{onmount}
|
|
102
|
-
{ondestroy}
|
|
103
91
|
{...rootProps}
|
|
104
92
|
>
|
|
105
93
|
{@render children?.({ scrollable: bond })}
|
|
@@ -7,12 +7,7 @@
|
|
|
7
7
|
class: klass = '',
|
|
8
8
|
children,
|
|
9
9
|
orientation = 'vertical',
|
|
10
|
-
|
|
11
|
-
ondestroy,
|
|
12
|
-
animate,
|
|
13
|
-
enter,
|
|
14
|
-
exit,
|
|
15
|
-
initial,
|
|
10
|
+
|
|
16
11
|
...restProps
|
|
17
12
|
}: ScrollableThumbProps<E, B> = $props();
|
|
18
13
|
|
|
@@ -39,12 +34,6 @@
|
|
|
39
34
|
'$preset',
|
|
40
35
|
klass
|
|
41
36
|
]}
|
|
42
|
-
{enter}
|
|
43
|
-
{exit}
|
|
44
|
-
{initial}
|
|
45
|
-
{animate}
|
|
46
|
-
{onmount}
|
|
47
|
-
{ondestroy}
|
|
48
37
|
{...thumbProps}
|
|
49
38
|
>
|
|
50
39
|
{@render children?.()}
|
|
@@ -7,12 +7,6 @@
|
|
|
7
7
|
class: klass = '',
|
|
8
8
|
orientation = 'vertical',
|
|
9
9
|
children,
|
|
10
|
-
onmount,
|
|
11
|
-
ondestroy,
|
|
12
|
-
animate,
|
|
13
|
-
enter,
|
|
14
|
-
exit,
|
|
15
|
-
initial,
|
|
16
10
|
...restProps
|
|
17
11
|
}: ScrollableTrackProps<E, B> = $props();
|
|
18
12
|
|
|
@@ -45,12 +39,6 @@
|
|
|
45
39
|
'$preset',
|
|
46
40
|
klass
|
|
47
41
|
]}
|
|
48
|
-
{enter}
|
|
49
|
-
{exit}
|
|
50
|
-
{initial}
|
|
51
|
-
{animate}
|
|
52
|
-
{onmount}
|
|
53
|
-
{ondestroy}
|
|
54
42
|
{...trackProps}
|
|
55
43
|
>
|
|
56
44
|
{@render children?.()}
|
|
@@ -21,10 +21,6 @@ declare class SelectContentAtom extends DropdownMenuContentAtom {
|
|
|
21
21
|
'aria-multiselectable': boolean;
|
|
22
22
|
'aria-activedescendant': string | undefined;
|
|
23
23
|
'aria-orientation': "vertical";
|
|
24
|
-
'aria-modal': boolean;
|
|
25
|
-
'aria-labelledby': string;
|
|
26
|
-
inert: boolean | undefined;
|
|
27
|
-
tabindex: number;
|
|
28
24
|
'data-active': boolean;
|
|
29
25
|
};
|
|
30
26
|
}
|
|
@@ -7,5 +7,5 @@ export { filterSelectData } from './runes.svelte';
|
|
|
7
7
|
*/
|
|
8
8
|
export { filterSelectData as filter } from './runes.svelte';
|
|
9
9
|
export * from './types';
|
|
10
|
-
export type { AnimatePopoverContentParams as AnimateSelectContentParams, animatePopoverContent as animateSelectContent } from '../popover/motion';
|
|
10
|
+
export type { AnimatePopoverContentParams as AnimateSelectContentParams, animatePopoverContent as animateSelectContent } from '../popover/motion.svelte';
|
|
11
11
|
export { select } from './attachments.svelte';
|
|
@@ -3,12 +3,6 @@ declare function $$render<T extends keyof HTMLElementTagNameMap = 'div', B exten
|
|
|
3
3
|
props: {
|
|
4
4
|
class?: string;
|
|
5
5
|
children?: any;
|
|
6
|
-
onmount?: any;
|
|
7
|
-
ondestroy?: any;
|
|
8
|
-
animate?: any;
|
|
9
|
-
enter?: any;
|
|
10
|
-
exit?: any;
|
|
11
|
-
initial?: any;
|
|
12
6
|
} & Record<string, any>;
|
|
13
7
|
exports: {};
|
|
14
8
|
bindings: "";
|
|
@@ -9,12 +9,10 @@
|
|
|
9
9
|
let {
|
|
10
10
|
class: klass = '',
|
|
11
11
|
children = undefined,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
exit = undefined,
|
|
17
|
-
initial = animateSidebarContent({ '0': '0px', '1': 'auto', duration: 0 }),
|
|
12
|
+
fallback = {
|
|
13
|
+
animate: animateSidebarContent({ '0': '0px', '1': 'auto' }),
|
|
14
|
+
initial: animateSidebarContent({ '0': '0px', '1': 'auto', duration: 0 })
|
|
15
|
+
},
|
|
18
16
|
...restProps
|
|
19
17
|
}: SidebarRootProps<E, B> = $props();
|
|
20
18
|
|
|
@@ -28,12 +26,7 @@
|
|
|
28
26
|
{bond}
|
|
29
27
|
preset="sidebar.content"
|
|
30
28
|
class={['bg-card border-border', '$preset', klass]}
|
|
31
|
-
|
|
32
|
-
exit={exit?.bind(bond.state)}
|
|
33
|
-
initial={initial?.bind(bond.state)}
|
|
34
|
-
animate={animate?.bind(bond.state)}
|
|
35
|
-
onmount={onmount?.bind(bond.state)}
|
|
36
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
29
|
+
{fallback}
|
|
37
30
|
{...contentProps}
|
|
38
31
|
>
|
|
39
32
|
{@render children?.({ sidebar: bond })}
|
|
@@ -53,6 +53,12 @@ export class StackState extends BondState {
|
|
|
53
53
|
#order = $state([]);
|
|
54
54
|
constructor(props) {
|
|
55
55
|
super(props);
|
|
56
|
+
$effect(() => {
|
|
57
|
+
const value = this.props.value;
|
|
58
|
+
if (value) {
|
|
59
|
+
untrack(() => this.bringToFront(value));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
56
62
|
}
|
|
57
63
|
register(value) {
|
|
58
64
|
const order = untrack(() => this.#order);
|
|
@@ -38,11 +38,15 @@
|
|
|
38
38
|
// Merge user style with z-index from atom
|
|
39
39
|
style: userStyle ? `${userStyle}; z-index: ${zIndex}` : `z-index: ${zIndex}`
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
const isActive = $derived(bond?.state.props.value === value);
|
|
41
43
|
</script>
|
|
42
44
|
|
|
43
45
|
<HtmlAtom
|
|
44
46
|
preset="stack.item"
|
|
45
47
|
class={['stack-item', '$preset', klass]}
|
|
48
|
+
data-value={value}
|
|
49
|
+
data-active={isActive}
|
|
46
50
|
{...itemProps}
|
|
47
51
|
>
|
|
48
52
|
{@render children?.()}
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
role="switch"
|
|
44
44
|
aria-checked={checked}
|
|
45
45
|
aria-disabled={disabled || undefined}
|
|
46
|
+
data-checked={checked}
|
|
46
47
|
onclick={handleClick}
|
|
47
48
|
{...restProps}
|
|
48
49
|
>
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
checked ? 'translate-x-6' : 'translate-x-1',
|
|
69
70
|
'$preset'
|
|
70
71
|
]}
|
|
72
|
+
data-checked={checked}
|
|
71
73
|
/>
|
|
72
74
|
</HtmlAtom>
|
|
73
75
|
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
class: klass = '',
|
|
20
20
|
as = 'button' as E,
|
|
21
21
|
children,
|
|
22
|
-
|
|
22
|
+
onclick,
|
|
23
23
|
...restProps
|
|
24
24
|
}: TabHeaderProps<E, B> = $props();
|
|
25
25
|
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
...restProps
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
function
|
|
31
|
+
function handleClick(ev: PointerEvent) {
|
|
32
32
|
if (isDisabled) return;
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
onclick?.(ev, { ...(bond ? { tab: bond } : {}) });
|
|
35
35
|
|
|
36
36
|
if (ev.defaultPrevented) {
|
|
37
37
|
return;
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
]}
|
|
55
55
|
type="button"
|
|
56
56
|
disabled={isDisabled}
|
|
57
|
-
|
|
57
|
+
onclick={handleClick}
|
|
58
58
|
{...headerProps}
|
|
59
59
|
>
|
|
60
60
|
{@render children?.({ ...(bond ? { tab: bond } : {}) })}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
2
|
import { type Base } from '../atom';
|
|
3
|
-
import { tick } from 'svelte';
|
|
4
3
|
import { Stack } from '../stack';
|
|
5
|
-
import { StackBond } from '../stack/bond.svelte';
|
|
6
4
|
import { TabsBond } from './bond.svelte';
|
|
7
5
|
import type { TabsBodyProps } from './types';
|
|
8
6
|
|
|
@@ -9,18 +9,26 @@
|
|
|
9
9
|
|
|
10
10
|
let {
|
|
11
11
|
class: klass = '',
|
|
12
|
-
value = $bindable(
|
|
12
|
+
value = $bindable(),
|
|
13
13
|
children,
|
|
14
14
|
onchange,
|
|
15
15
|
preset = 'tabs' as const,
|
|
16
16
|
...restProps
|
|
17
17
|
}: TabsRootProps<D, E, B> = $props();
|
|
18
18
|
|
|
19
|
+
let revision = $state(0);
|
|
20
|
+
|
|
19
21
|
const bondProps = defineState<TabsBondProps>([
|
|
20
22
|
defineProperty(
|
|
21
23
|
'value',
|
|
22
|
-
() =>
|
|
23
|
-
|
|
24
|
+
() => {
|
|
25
|
+
void revision; // Ensure reactivity in uncontrolled mode
|
|
26
|
+
return value;
|
|
27
|
+
},
|
|
28
|
+
(v) => {
|
|
29
|
+
value = v as D | undefined;
|
|
30
|
+
revision++; // Trigger reactivity in uncontrolled mode
|
|
31
|
+
}
|
|
24
32
|
),
|
|
25
33
|
defineProperty('rest', () => restProps)
|
|
26
34
|
]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as Root } from './toast-root.svelte';
|
|
2
2
|
export { default as Title } from './toast-title.svelte';
|
|
3
3
|
export { default as Description } from './toast-description.svelte';
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as Close } from './toast-close.svelte';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as Root } from './toast-root.svelte';
|
|
2
2
|
export { default as Title } from './toast-title.svelte';
|
|
3
3
|
export { default as Description } from './toast-description.svelte';
|
|
4
|
-
export { default as
|
|
4
|
+
export { default as Close } from './toast-close.svelte';
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
import { ToastBond } from './bond';
|
|
2
|
-
|
|
1
|
+
import { ToastBond } from './bond.svelte';
|
|
2
|
+
/**
|
|
3
|
+
* Attachment helper for accessing the nearest ToastBond inside a custom node.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```svelte
|
|
7
|
+
* <div {@attach toast((node, bond) => bond?.state.close())} />
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
export declare function toast<T>(callback: (node: HTMLElement, bond: ToastBond | undefined) => T): (node: HTMLElement) => T;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { ToastBond } from './bond';
|
|
1
|
+
import { ToastBond } from './bond.svelte';
|
|
2
|
+
/**
|
|
3
|
+
* Attachment helper for accessing the nearest ToastBond inside a custom node.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```svelte
|
|
7
|
+
* <div {@attach toast((node, bond) => bond?.state.close())} />
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
2
10
|
export function toast(callback) {
|
|
3
11
|
const bond = ToastBond.get();
|
|
4
12
|
return (node) => callback(node, bond);
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Bond, BondState, BondAtom, type BondStateProps } from '../../shared/bond.svelte';
|
|
2
|
+
export type ToastBondProps = BondStateProps & {
|
|
3
|
+
open: boolean;
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
readonly rest?: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export type ToastBondElements = {
|
|
8
|
+
root: HTMLElement;
|
|
9
|
+
title: HTMLElement;
|
|
10
|
+
description: HTMLElement;
|
|
11
|
+
close: HTMLElement;
|
|
12
|
+
};
|
|
13
|
+
export declare class ToastRootAtom extends BondAtom<ToastBond> {
|
|
14
|
+
constructor(bond: ToastBond);
|
|
15
|
+
get attrs(): {
|
|
16
|
+
role: string;
|
|
17
|
+
'aria-live': string;
|
|
18
|
+
'aria-atomic': string;
|
|
19
|
+
'aria-labelledby': string;
|
|
20
|
+
'aria-describedby': string;
|
|
21
|
+
'aria-disabled': string;
|
|
22
|
+
'data-open': boolean;
|
|
23
|
+
'data-state': string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare class ToastTitleAtom extends BondAtom<ToastBond> {
|
|
27
|
+
constructor(bond: ToastBond);
|
|
28
|
+
get attrs(): {
|
|
29
|
+
id: string;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare class ToastDescriptionAtom extends BondAtom<ToastBond> {
|
|
33
|
+
constructor(bond: ToastBond);
|
|
34
|
+
get attrs(): {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export declare class ToastCloseAtom extends BondAtom<ToastBond> {
|
|
39
|
+
constructor(bond: ToastBond);
|
|
40
|
+
get attrs(): {
|
|
41
|
+
type: string | undefined;
|
|
42
|
+
role: string | undefined;
|
|
43
|
+
tabindex: number | undefined;
|
|
44
|
+
'aria-label': string;
|
|
45
|
+
};
|
|
46
|
+
get handlers(): {
|
|
47
|
+
onclick: (ev: MouseEvent) => void;
|
|
48
|
+
onkeydown: (ev: KeyboardEvent) => void;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare class ToastBond<State extends ToastBondState<ToastBondProps> = ToastBondState<ToastBondProps>> extends Bond<ToastBondProps, State, ToastBondElements> {
|
|
52
|
+
static CONTEXT_KEY: string;
|
|
53
|
+
constructor(s: State);
|
|
54
|
+
share(): this;
|
|
55
|
+
/** Handle for granular access to root attrs and attachment */
|
|
56
|
+
root(): ToastRootAtom;
|
|
57
|
+
/** Handle for granular access to title attrs and attachment */
|
|
58
|
+
title(): ToastTitleAtom;
|
|
59
|
+
/** Handle for granular access to description attrs and attachment */
|
|
60
|
+
description(): ToastDescriptionAtom;
|
|
61
|
+
/** Handle for granular access to close button attrs, handlers, and attachment */
|
|
62
|
+
dismiss(): ToastCloseAtom;
|
|
63
|
+
static get(): ToastBond | undefined;
|
|
64
|
+
static set(bond: ToastBond): ToastBond;
|
|
65
|
+
}
|
|
66
|
+
export declare class ToastBondState<Props extends ToastBondProps> extends BondState<Props> {
|
|
67
|
+
constructor(props: () => Props);
|
|
68
|
+
get isOpen(): boolean;
|
|
69
|
+
get isDisabled(): boolean;
|
|
70
|
+
open(): void;
|
|
71
|
+
close(): void;
|
|
72
|
+
toggle(): void;
|
|
73
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { getContext, setContext, untrack } from 'svelte';
|
|
2
|
+
import { Bond, BondState, BondAtom } from '../../shared/bond.svelte';
|
|
3
|
+
import { getElementId } from '../../utils/dom.svelte';
|
|
4
|
+
export class ToastRootAtom extends BondAtom {
|
|
5
|
+
constructor(bond) {
|
|
6
|
+
super(bond, 'root');
|
|
7
|
+
}
|
|
8
|
+
get attrs() {
|
|
9
|
+
const props = untrack(() => this.bond.state?.props);
|
|
10
|
+
const isOpen = props?.open ?? false;
|
|
11
|
+
const isDisabled = props?.disabled ?? false;
|
|
12
|
+
const titleId = getElementId(this.bond.id, 'toast-title');
|
|
13
|
+
const descriptionId = getElementId(this.bond.id, 'toast-description');
|
|
14
|
+
return {
|
|
15
|
+
...super.attrs,
|
|
16
|
+
role: 'status',
|
|
17
|
+
'aria-live': 'polite',
|
|
18
|
+
'aria-atomic': 'true',
|
|
19
|
+
'aria-labelledby': titleId,
|
|
20
|
+
'aria-describedby': descriptionId,
|
|
21
|
+
'aria-disabled': isDisabled ? 'true' : 'false',
|
|
22
|
+
'data-open': isOpen,
|
|
23
|
+
'data-state': isOpen ? 'open' : 'closed'
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class ToastTitleAtom extends BondAtom {
|
|
28
|
+
constructor(bond) {
|
|
29
|
+
super(bond, 'title');
|
|
30
|
+
}
|
|
31
|
+
get attrs() {
|
|
32
|
+
return {
|
|
33
|
+
...super.attrs,
|
|
34
|
+
id: getElementId(this.bond.id, 'toast-title')
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class ToastDescriptionAtom extends BondAtom {
|
|
39
|
+
constructor(bond) {
|
|
40
|
+
super(bond, 'description');
|
|
41
|
+
}
|
|
42
|
+
get attrs() {
|
|
43
|
+
return {
|
|
44
|
+
...super.attrs,
|
|
45
|
+
id: getElementId(this.bond.id, 'toast-description')
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class ToastCloseAtom extends BondAtom {
|
|
50
|
+
constructor(bond) {
|
|
51
|
+
super(bond, 'close');
|
|
52
|
+
}
|
|
53
|
+
get attrs() {
|
|
54
|
+
const isButton = this.element?.tagName?.toLowerCase() === 'button';
|
|
55
|
+
return {
|
|
56
|
+
...super.attrs,
|
|
57
|
+
type: isButton ? 'button' : undefined,
|
|
58
|
+
role: isButton ? undefined : 'button',
|
|
59
|
+
tabindex: isButton ? undefined : 0,
|
|
60
|
+
'aria-label': 'Dismiss notification'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
get handlers() {
|
|
64
|
+
return {
|
|
65
|
+
onclick: (ev) => {
|
|
66
|
+
ev.stopPropagation();
|
|
67
|
+
this.bond.state.close();
|
|
68
|
+
},
|
|
69
|
+
onkeydown: (ev) => {
|
|
70
|
+
if (ev.key === 'Enter' || ev.key === ' ') {
|
|
71
|
+
ev.preventDefault();
|
|
72
|
+
this.bond.state.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class ToastBond extends Bond {
|
|
79
|
+
static CONTEXT_KEY = '@atoms/context/toast';
|
|
80
|
+
constructor(s) {
|
|
81
|
+
super(s, 'toast');
|
|
82
|
+
}
|
|
83
|
+
share() {
|
|
84
|
+
return ToastBond.set(this);
|
|
85
|
+
}
|
|
86
|
+
/** Handle for granular access to root attrs and attachment */
|
|
87
|
+
root() {
|
|
88
|
+
return this.atom('root', () => new ToastRootAtom(this));
|
|
89
|
+
}
|
|
90
|
+
/** Handle for granular access to title attrs and attachment */
|
|
91
|
+
title() {
|
|
92
|
+
return this.atom('title', () => new ToastTitleAtom(this));
|
|
93
|
+
}
|
|
94
|
+
/** Handle for granular access to description attrs and attachment */
|
|
95
|
+
description() {
|
|
96
|
+
return this.atom('description', () => new ToastDescriptionAtom(this));
|
|
97
|
+
}
|
|
98
|
+
/** Handle for granular access to close button attrs, handlers, and attachment */
|
|
99
|
+
dismiss() {
|
|
100
|
+
return this.atom('close', () => new ToastCloseAtom(this));
|
|
101
|
+
}
|
|
102
|
+
static get() {
|
|
103
|
+
return getContext(ToastBond.CONTEXT_KEY);
|
|
104
|
+
}
|
|
105
|
+
static set(bond) {
|
|
106
|
+
return setContext(ToastBond.CONTEXT_KEY, bond);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
export class ToastBondState extends BondState {
|
|
110
|
+
constructor(props) {
|
|
111
|
+
super(props);
|
|
112
|
+
}
|
|
113
|
+
get isOpen() {
|
|
114
|
+
return this.props.open;
|
|
115
|
+
}
|
|
116
|
+
get isDisabled() {
|
|
117
|
+
return this.props.disabled;
|
|
118
|
+
}
|
|
119
|
+
open() {
|
|
120
|
+
if (this.props.disabled)
|
|
121
|
+
return;
|
|
122
|
+
this.props.open = true;
|
|
123
|
+
}
|
|
124
|
+
close() {
|
|
125
|
+
this.props.open = false;
|
|
126
|
+
}
|
|
127
|
+
toggle() {
|
|
128
|
+
if (this.props.disabled)
|
|
129
|
+
return;
|
|
130
|
+
this.props.open = !this.props.open;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export * as Toast from './atoms';
|
|
2
2
|
export * from './types';
|
|
3
|
-
export {
|
|
3
|
+
export { Toaster, type ToastType, type ToastOptions, type ToastItem } from './toaster.svelte';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<script
|
|
2
|
+
lang="ts"
|
|
3
|
+
generics="E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base"
|
|
4
|
+
>
|
|
5
|
+
import { Icon } from '../icon';
|
|
6
|
+
import Close from '../../icons/icon-close.svelte';
|
|
7
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
8
|
+
import { ToastBond } from './bond.svelte';
|
|
9
|
+
import type { ToastCloseProps } from './types';
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
class: klass = '',
|
|
13
|
+
as = 'button' as E,
|
|
14
|
+
preset = 'toast.close',
|
|
15
|
+
children = undefined,
|
|
16
|
+
onclick = undefined,
|
|
17
|
+
...restProps
|
|
18
|
+
}: ToastCloseProps<E, B> = $props();
|
|
19
|
+
|
|
20
|
+
const bond = ToastBond.get();
|
|
21
|
+
|
|
22
|
+
const closeProps = $derived({
|
|
23
|
+
...(bond?.dismiss().spread ?? {}),
|
|
24
|
+
...restProps
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
function onclick_(ev: MouseEvent) {
|
|
28
|
+
(onclick as ((ev: MouseEvent) => void) | undefined)?.(ev);
|
|
29
|
+
if (ev.defaultPrevented) return;
|
|
30
|
+
bond?.state.close();
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<HtmlAtom
|
|
35
|
+
{as}
|
|
36
|
+
{bond}
|
|
37
|
+
{preset}
|
|
38
|
+
class={['cursor-pointer text-current h-6', '$preset', klass]}
|
|
39
|
+
{...closeProps}
|
|
40
|
+
onclick={onclick_}
|
|
41
|
+
>
|
|
42
|
+
{#if children}
|
|
43
|
+
{@render children({ toast: bond })}
|
|
44
|
+
{:else}
|
|
45
|
+
<Icon class="h-full" src={Close} />
|
|
46
|
+
{/if}
|
|
47
|
+
</HtmlAtom>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Base } from '../atom';
|
|
2
|
+
import type { ToastCloseProps } from './types';
|
|
3
|
+
declare function $$render<E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base>(): {
|
|
4
|
+
props: ToastCloseProps<E, B>;
|
|
5
|
+
exports: {};
|
|
6
|
+
bindings: "";
|
|
7
|
+
slots: {};
|
|
8
|
+
events: {};
|
|
9
|
+
};
|
|
10
|
+
declare class __sveltets_Render<E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base> {
|
|
11
|
+
props(): ReturnType<typeof $$render<E, B>>['props'];
|
|
12
|
+
events(): ReturnType<typeof $$render<E, B>>['events'];
|
|
13
|
+
slots(): ReturnType<typeof $$render<E, B>>['slots'];
|
|
14
|
+
bindings(): "";
|
|
15
|
+
exports(): {};
|
|
16
|
+
}
|
|
17
|
+
interface $$IsomorphicComponent {
|
|
18
|
+
new <E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<E, B>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<E, B>['props']>, ReturnType<__sveltets_Render<E, B>['events']>, ReturnType<__sveltets_Render<E, B>['slots']>> & {
|
|
19
|
+
$$bindings?: ReturnType<__sveltets_Render<E, B>['bindings']>;
|
|
20
|
+
} & ReturnType<__sveltets_Render<E, B>['exports']>;
|
|
21
|
+
<E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base>(internal: unknown, props: ReturnType<__sveltets_Render<E, B>['props']> & {}): ReturnType<__sveltets_Render<E, B>['exports']>;
|
|
22
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
23
|
+
}
|
|
24
|
+
declare const ToastClose: $$IsomorphicComponent;
|
|
25
|
+
type ToastClose<E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base> = InstanceType<typeof ToastClose<E, B>>;
|
|
26
|
+
export default ToastClose;
|