diff --git a/svelte/demo/src/daisyui/main.ts b/svelte/demo/src/daisyui/main.ts index d8ec087a54..49f8232ce6 100644 --- a/svelte/demo/src/daisyui/main.ts +++ b/svelte/demo/src/daisyui/main.ts @@ -1,5 +1,6 @@ import App from './App.svelte'; +import {mount} from 'svelte'; -export const main = new App({ +export const main = mount(App, { target: document.getElementById('root')!, }); diff --git a/svelte/demo/src/daisyui/samples/accordion/Accordion.svelte b/svelte/demo/src/daisyui/samples/accordion/Accordion.svelte index 3fe7b5247d..10fe0def07 100644 --- a/svelte/demo/src/daisyui/samples/accordion/Accordion.svelte +++ b/svelte/demo/src/daisyui/samples/accordion/Accordion.svelte @@ -2,18 +2,23 @@ import {type AccordionProps, createAccordion} from '@agnos-ui/svelte-headless/components/accordion'; import {callWidgetFactory} from '@agnos-ui/svelte-headless/config'; import {setAccordionApi} from './accordion'; + import type {Snippet} from 'svelte'; - type $$Props = Partial>; + let { + children, + ...props + }: Partial> & {children: Snippet} = + $props(); const widget = callWidgetFactory({ factory: createAccordion, widgetName: 'accordion', - $$props, + props, }); setAccordionApi(widget.api); - $: widget.patchChangedProps($$props); + $effect(() => widget.patchChangedProps({...props}));
- + {@render children()}
diff --git a/svelte/demo/src/daisyui/samples/accordion/AccordionItem.svelte b/svelte/demo/src/daisyui/samples/accordion/AccordionItem.svelte index 0d196bc870..60e4e66d61 100644 --- a/svelte/demo/src/daisyui/samples/accordion/AccordionItem.svelte +++ b/svelte/demo/src/daisyui/samples/accordion/AccordionItem.svelte @@ -2,11 +2,19 @@ import {type AccordionItemProps, type AccordionItemWidget} from '@agnos-ui/svelte-headless/components/accordion'; import type {WidgetFactory} from '@agnos-ui/svelte-headless/types'; import {callWidgetFactory} from '@agnos-ui/svelte-headless/config'; - import {onMount} from 'svelte'; + import {onMount, type Snippet} from 'svelte'; import {createSimpleClassTransition} from '@agnos-ui/svelte-headless/services/transitions/simpleClassTransition'; import {getAccordionApi} from './accordion'; - type $$Props = Partial>; + let { + header, + children, + visible = $bindable(), + ...props + }: Partial> & { + header: Snippet; + children: Snippet; + } = $props(); const transition = createSimpleClassTransition({ showClasses: ['collapse-open'], @@ -14,10 +22,9 @@ }); const {registerItem} = getAccordionApi(); - export let visible: boolean | undefined = undefined; const widget = callWidgetFactory({ factory: registerItem as WidgetFactory, - $$props, + props: {visible, ...props}, events: { onVisibleChange: (event) => { visible = event; @@ -32,9 +39,9 @@ directives: {itemDirective, toggleDirective, transitionDirective, bodyContainerAttrsDirective}, api: {toggle}, } = widget; - $: widget.patchChangedProps($$props); + $effect(() => widget.patchChangedProps({visible, ...props})); - const onEnter = (e: KeyboardEvent) => { + const onkeydown = (e: KeyboardEvent) => { if (e.key === 'Enter') { toggle(); } @@ -43,12 +50,12 @@
-
- +
+ {@render header()}
{#if $shouldBeInDOM$} - + {@render children()} {/if}
diff --git a/svelte/demo/src/daisyui/samples/accordion/Default.route.svelte b/svelte/demo/src/daisyui/samples/accordion/Default.route.svelte index b40ab5e369..2c780c2266 100644 --- a/svelte/demo/src/daisyui/samples/accordion/Default.route.svelte +++ b/svelte/demo/src/daisyui/samples/accordion/Default.route.svelte @@ -5,15 +5,21 @@ - First header - First content + {#snippet header()} + First header + {/snippet} + First content - Second header - Second content + {#snippet header()} + Second header + {/snippet} + Second content - Third header - Third content + {#snippet header()} + Third header + {/snippet} + Third content diff --git a/svelte/demo/src/daisyui/samples/alert/Alert.svelte b/svelte/demo/src/daisyui/samples/alert/Alert.svelte index fd49add14d..1d18fe1552 100644 --- a/svelte/demo/src/daisyui/samples/alert/Alert.svelte +++ b/svelte/demo/src/daisyui/samples/alert/Alert.svelte @@ -4,7 +4,13 @@ import {callWidgetFactory} from '@agnos-ui/svelte-headless/config'; import {createSimpleClassTransition} from '@agnos-ui/svelte-headless/services/transitions/simpleClassTransition'; import closeIconSvg from '@agnos-ui/common/samples/common/close_icon.svg?raw'; - type $$Props = Partial>; + import type {Snippet} from 'svelte'; + + let { + visible = $bindable(), + children, + ...props + }: Partial> & {children: Snippet} = $props(); const transition = createSimpleClassTransition({ showClasses: ['transition-opacity'], @@ -12,7 +18,7 @@ animationPendingHideClasses: ['opacity-0', 'transition-opacity'], }); - export const { + const { stores: {className$, dismissible$, ariaCloseButtonLabel$, hidden$}, directives: {transitionDirective}, patchChangedProps, @@ -20,7 +26,7 @@ } = callWidgetFactory({ factory: createAlert, widgetName: 'alert', - $$props, + props: {...props, visible}, defaultConfig: {transition}, events: { onVisibleChange: (event) => { @@ -29,16 +35,14 @@ }, }); - export let visible: boolean | undefined = undefined; - - $: patchChangedProps($$props); + $effect(() => patchChangedProps({...props, visible})); {#if !$hidden$}