@agnos-ui/svelte-bootstrap 0.4.4 → 0.5.0-next.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.
Files changed (103) hide show
  1. package/README.md +2 -2
  2. package/components/accordion/Accordion.svelte +20 -18
  3. package/components/accordion/Accordion.svelte.d.ts +8 -23
  4. package/components/accordion/Item.svelte +40 -44
  5. package/components/accordion/Item.svelte.d.ts +5 -20
  6. package/components/accordion/ItemDefaultStructure.svelte +17 -27
  7. package/components/accordion/ItemDefaultStructure.svelte.d.ts +3 -17
  8. package/components/accordion/accordion.d.ts +11 -6
  9. package/components/accordion/accordion.gen.d.ts +37 -9
  10. package/components/accordion/accordion.js +10 -0
  11. package/components/alert/Alert.svelte +36 -40
  12. package/components/alert/Alert.svelte.d.ts +5 -21
  13. package/components/alert/AlertDefaultStructure.svelte +8 -12
  14. package/components/alert/AlertDefaultStructure.svelte.d.ts +3 -17
  15. package/components/alert/alert.gen.d.ts +21 -2
  16. package/components/alert/index.d.ts +1 -1
  17. package/components/alert/index.js +1 -1
  18. package/components/collapse/Collapse.svelte +33 -0
  19. package/components/collapse/Collapse.svelte.d.ts +8 -0
  20. package/components/collapse/collapse.gen.d.ts +146 -0
  21. package/components/collapse/collapse.gen.js +14 -0
  22. package/components/collapse/index.d.ts +3 -0
  23. package/components/collapse/index.js +3 -0
  24. package/components/modal/Modal.svelte +45 -47
  25. package/components/modal/Modal.svelte.d.ts +16 -14
  26. package/components/modal/ModalDefaultHeader.svelte +10 -17
  27. package/components/modal/ModalDefaultHeader.svelte.d.ts +15 -12
  28. package/components/modal/ModalDefaultStructure.svelte +10 -36
  29. package/components/modal/ModalDefaultStructure.svelte.d.ts +15 -12
  30. package/components/modal/index.d.ts +1 -1
  31. package/components/modal/index.js +1 -1
  32. package/components/modal/modal.gen.d.ts +35 -18
  33. package/components/modal/modalService.d.ts +19 -1
  34. package/components/modal/modalService.js +21 -2
  35. package/components/pagination/Pagination.svelte +39 -47
  36. package/components/pagination/Pagination.svelte.d.ts +3 -21
  37. package/components/pagination/PaginationDefaultPages.svelte +13 -43
  38. package/components/pagination/PaginationDefaultPages.svelte.d.ts +3 -17
  39. package/components/pagination/PaginationDefaultStructure.svelte +18 -89
  40. package/components/pagination/PaginationDefaultStructure.svelte.d.ts +3 -17
  41. package/components/pagination/index.d.ts +1 -1
  42. package/components/pagination/index.js +1 -1
  43. package/components/pagination/pagination.gen.d.ts +49 -29
  44. package/components/progressbar/Progressbar.svelte +28 -31
  45. package/components/progressbar/Progressbar.svelte.d.ts +3 -21
  46. package/components/progressbar/ProgressbarDefaultStructure.svelte +6 -11
  47. package/components/progressbar/ProgressbarDefaultStructure.svelte.d.ts +3 -17
  48. package/components/progressbar/index.d.ts +1 -1
  49. package/components/progressbar/index.js +1 -1
  50. package/components/progressbar/progressbar.gen.d.ts +21 -4
  51. package/components/rating/Rating.svelte +33 -27
  52. package/components/rating/Rating.svelte.d.ts +3 -18
  53. package/components/rating/index.d.ts +1 -1
  54. package/components/rating/index.js +1 -1
  55. package/components/rating/rating.gen.d.ts +25 -17
  56. package/components/select/Select.svelte +57 -81
  57. package/components/select/Select.svelte.d.ts +16 -14
  58. package/components/select/index.d.ts +1 -1
  59. package/components/select/index.js +1 -1
  60. package/components/select/select.gen.d.ts +41 -25
  61. package/components/slider/Slider.svelte +39 -40
  62. package/components/slider/Slider.svelte.d.ts +3 -21
  63. package/components/slider/SliderDefaultHandle.svelte +7 -4
  64. package/components/slider/SliderDefaultHandle.svelte.d.ts +3 -17
  65. package/components/slider/SliderDefaultStructure.svelte +21 -75
  66. package/components/slider/SliderDefaultStructure.svelte.d.ts +3 -17
  67. package/components/slider/index.d.ts +1 -1
  68. package/components/slider/index.js +1 -1
  69. package/components/slider/slider.gen.d.ts +54 -33
  70. package/components/toast/Toast.svelte +43 -40
  71. package/components/toast/Toast.svelte.d.ts +5 -21
  72. package/components/toast/ToastDefaultStructure.svelte +13 -23
  73. package/components/toast/ToastDefaultStructure.svelte.d.ts +3 -17
  74. package/components/toast/index.d.ts +1 -1
  75. package/components/toast/index.js +1 -1
  76. package/components/toast/toast.gen.d.ts +22 -2
  77. package/config.d.ts +1 -12
  78. package/config.gen.d.ts +5 -0
  79. package/generated/index.d.ts +1 -1
  80. package/generated/index.js +1 -1
  81. package/generated/utils/widget.svelte.d.ts +1 -0
  82. package/generated/utils/widget.svelte.js +1 -0
  83. package/index.d.ts +1 -0
  84. package/index.js +1 -0
  85. package/package.json +8 -7
  86. package/components/alert/alert.d.ts +0 -5
  87. package/components/alert/alert.js +0 -1
  88. package/components/modal/modal.d.ts +0 -5
  89. package/components/modal/modal.js +0 -1
  90. package/components/pagination/pagination.d.ts +0 -5
  91. package/components/pagination/pagination.js +0 -1
  92. package/components/progressbar/progressbar.d.ts +0 -5
  93. package/components/progressbar/progressbar.js +0 -1
  94. package/components/rating/rating.d.ts +0 -5
  95. package/components/rating/rating.js +0 -1
  96. package/components/select/select.d.ts +0 -5
  97. package/components/select/select.js +0 -1
  98. package/components/slider/slider.d.ts +0 -5
  99. package/components/slider/slider.js +0 -1
  100. package/components/toast/toast.d.ts +0 -5
  101. package/components/toast/toast.js +0 -1
  102. package/generated/utils/widget.d.ts +0 -1
  103. package/generated/utils/widget.js +0 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@agnos-ui/svelte-bootstrap)](https://www.npmjs.com/package/@agnos-ui/svelte-bootstrap)
4
4
 
5
- [Bootstrap](https://getbootstrap.com/)-based widget library for [Svelte](https://svelte.dev/).
5
+ [Bootstrap](https://getbootstrap.com/)-based component library for [Svelte](https://svelte.dev/).
6
6
 
7
7
  ## Installation
8
8
 
@@ -12,4 +12,4 @@ npm install @agnos-ui/svelte-bootstrap
12
12
 
13
13
  ## Usage
14
14
 
15
- Please check [our demo site](https://amadeusitgroup.github.io/AgnosUI/latest/) to see all the available widgets and how to use them.
15
+ Please check [our demo site](https://www.agnosui.dev/latest/) to see all the available components and how to use them.
@@ -1,23 +1,25 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import {ssrAttributes as __AgnosUISveltePreprocess__ssrAttributes, classDirective as __AgnosUISveltePreprocess__classDirective} from '@agnos-ui/svelte-headless/utils/directive';
3
3
  import {BROWSER as __AgnosUISveltePreprocess__BROWSER} from 'esm-env';
4
- import { callWidgetFactory } from "../../config";
5
- import { createAccordion, setAccordionApi } from "./accordion";
6
- const widget = callWidgetFactory({
7
- factory: createAccordion,
8
- widgetName: "accordion",
9
- $$slots,
10
- $$props,
11
- events: {}
12
- });
13
- export const api = widget.api;
14
- const {
15
- directives: { accordionDirective }
16
- } = widget;
17
- setAccordionApi(widget.api);
18
- $: widget.patchChangedProps($$props);
4
+
5
+ import type {AccordionApi, AccordionProps} from './accordion';
6
+ import type {Snippet} from 'svelte';
7
+ import {callWidgetFactory} from '../../config';
8
+ import {createAccordion, setAccordionApi} from './accordion';
9
+
10
+ let {children, ...props}: Partial<AccordionProps> & {children: Snippet} = $props();
11
+
12
+ const {directives, api: accordionApi} = callWidgetFactory({
13
+ factory: createAccordion,
14
+ widgetName: 'accordion',
15
+ props,
16
+ enablePatchChanged: true,
17
+ });
18
+ export const api: AccordionApi = accordionApi;
19
+
20
+ setAccordionApi(accordionApi);
19
21
  </script>
20
22
 
21
- <div use:__AgnosUISveltePreprocess__classDirective={"accordion"} use:accordionDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(accordionDirective, [__AgnosUISveltePreprocess__classDirective, "accordion"])}>
22
- <slot />
23
+ <div use:__AgnosUISveltePreprocess__classDirective={"accordion"} use:directives.accordionDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(directives.accordionDirective, [__AgnosUISveltePreprocess__classDirective, "accordion"])}>
24
+ {@render children()}
23
25
  </div>
@@ -1,23 +1,8 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { AccordionApi, AccordionProps, AccordionSlots } from './accordion';
3
- declare const __propDef: {
4
- props: {
5
- api?: AccordionApi;
6
- } & Partial<AccordionProps>;
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: {
11
- default: Record<string, never>;
12
- } & AccordionSlots;
13
- exports?: {} | undefined;
14
- bindings?: string | undefined;
15
- };
16
- type AccordionProps_ = typeof __propDef.props;
17
- export { AccordionProps_ as AccordionProps };
18
- export type AccordionEvents = typeof __propDef.events;
19
- type AccordionSlots_ = typeof __propDef.slots;
20
- export { AccordionSlots_ as AccordionSlots };
21
- export default class Accordion extends SvelteComponent<AccordionProps_, AccordionEvents, AccordionSlots_> {
22
- get api(): AccordionApi;
23
- }
1
+ import type { AccordionApi, AccordionProps } from './accordion';
2
+ import type { Snippet } from 'svelte';
3
+ declare const Accordion: import("svelte").Component<Partial<AccordionProps> & {
4
+ children: Snippet;
5
+ }, {
6
+ api: AccordionApi;
7
+ }, "">;
8
+ export default Accordion;
@@ -1,51 +1,47 @@
1
- <script context="module">
1
+ <script lang="ts">
2
2
  import {ssrAttributes as __AgnosUISveltePreprocess__ssrAttributes, classDirective as __AgnosUISveltePreprocess__classDirective} from '@agnos-ui/svelte-headless/utils/directive';
3
3
  import {BROWSER as __AgnosUISveltePreprocess__BROWSER} from 'esm-env';
4
- import { toSlotContextWidget } from "@agnos-ui/svelte-headless/types";
5
- import { Slot } from "@agnos-ui/svelte-headless/slot";
6
- import { callWidgetFactory } from "../../config";
7
- import { onMount } from "svelte";
8
- import ItemDefaultStructure from "./ItemDefaultStructure.svelte";
9
- import { getAccordionApi } from "./accordion";
10
- const defaultConfig = {
11
- structure: ItemDefaultStructure
12
- };
13
- </script>
14
4
 
15
- <script>const accordionApi = getAccordionApi();
16
- const { registerItem } = accordionApi;
17
- export let visible = void 0;
18
- const widget = callWidgetFactory({
19
- factory: registerItem,
20
- $$slots,
21
- $$props,
22
- defaultConfig,
23
- events: {
24
- onVisibleChange: (event) => {
25
- visible = event;
26
- }
27
- }
28
- });
29
- const {
30
- stores: { structure$ },
31
- directives: { itemDirective },
32
- state$
33
- } = widget;
34
- export const api = widget.api;
35
- $: widget.patchChangedProps($$props);
36
- $: slotContext = { widget: toSlotContextWidget(widget), state: $state$ };
37
- onMount(() => {
38
- widget.api.initDone();
39
- });
5
+ import type {AccordionItemApi, AccordionItemContext, AccordionItemProps, AccordionItemWidget} from './accordion';
6
+ import type {WidgetFactory} from '@agnos-ui/svelte-headless/types';
7
+ import {Slot} from '@agnos-ui/svelte-headless/slot';
8
+ import {callWidgetFactory} from '../../config';
9
+ import {onMount} from 'svelte';
10
+ import ItemDefaultStructure from './ItemDefaultStructure.svelte';
11
+ import {getAccordionApi} from './accordion';
12
+
13
+ const accordionApi = getAccordionApi();
14
+ const {registerItem} = accordionApi;
15
+
16
+ let {visible = $bindable(), ...props}: Partial<AccordionItemProps> = $props();
17
+ const widget = callWidgetFactory({
18
+ factory: registerItem as WidgetFactory<AccordionItemWidget>,
19
+ get props() {
20
+ return {...props, visible};
21
+ },
22
+ enablePatchChanged: true,
23
+ defaultConfig: {structure},
24
+ events: {
25
+ onVisibleChange: (event) => {
26
+ visible = event;
27
+ },
28
+ },
29
+ });
30
+ const {
31
+ state,
32
+ directives: {itemDirective},
33
+ } = widget;
34
+ export const api: AccordionItemApi = widget.api;
35
+
36
+ onMount(() => {
37
+ widget.api.initDone();
38
+ });
40
39
  </script>
41
40
 
41
+ {#snippet structure(props: AccordionItemContext)}
42
+ <ItemDefaultStructure {...props} />
43
+ {/snippet}
44
+
42
45
  <div use:__AgnosUISveltePreprocess__classDirective={"accordion-item"} use:itemDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(itemDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-item"])}>
43
- <Slot slotContent={$structure$} props={slotContext} let:component let:props>
44
- <svelte:fragment slot="slot" let:props><slot name="structure" {...props} /></svelte:fragment>
45
- <svelte:component this={component} {...props}>
46
- <svelte:fragment let:state let:widget><slot {state} {widget} /></svelte:fragment>
47
- <svelte:fragment slot="header" let:state let:widget><slot name="header" {state} {widget} /></svelte:fragment>
48
- <svelte:fragment slot="structure" let:state let:widget><slot name="structure" {state} {widget} /></svelte:fragment>
49
- </svelte:component>
50
- </Slot>
46
+ <Slot content={state.structure} props={widget} />
51
47
  </div>
@@ -1,20 +1,5 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { AccordionItemApi, AccordionItemProps, AccordionItemSlots } from './accordion';
3
- declare const __propDef: {
4
- props: {
5
- api?: AccordionItemApi;
6
- } & Partial<AccordionItemProps>;
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: AccordionItemSlots;
11
- exports?: {} | undefined;
12
- bindings?: string | undefined;
13
- };
14
- export type ItemProps = typeof __propDef.props;
15
- export type ItemEvents = typeof __propDef.events;
16
- export type ItemSlots = typeof __propDef.slots;
17
- export default class Item extends SvelteComponent<ItemProps, ItemEvents, ItemSlots> {
18
- get api(): AccordionItemApi;
19
- }
20
- export {};
1
+ import type { AccordionItemApi, AccordionItemProps } from './accordion';
2
+ declare const Item: import("svelte").Component<Partial<AccordionItemProps>, {
3
+ api: AccordionItemApi;
4
+ }, "visible">;
5
+ export default Item;
@@ -1,37 +1,27 @@
1
- <script>
1
+ <script lang="ts">
2
2
  import {ssrAttributes as __AgnosUISveltePreprocess__ssrAttributes, classDirective as __AgnosUISveltePreprocess__classDirective} from '@agnos-ui/svelte-headless/utils/directive';
3
3
  import {BROWSER as __AgnosUISveltePreprocess__BROWSER} from 'esm-env';
4
- import { Slot } from "@agnos-ui/svelte-headless/slot";
5
- export let state;
6
- export let widget;
7
- const re = new RegExp("^h[1-6]$");
8
- $: slotContext = { widget, state };
9
- $: headingTag = re.test(state.headingTag) ? state.headingTag : "h2";
4
+
5
+ import type {AccordionItemContext} from './accordion';
6
+ import {Slot} from '@agnos-ui/svelte-headless/slot';
7
+
8
+ let widget: AccordionItemContext = $props();
9
+ const {state, directives} = widget;
10
+
11
+ const re = new RegExp('^h[1-6]$');
12
+
13
+ let headingTag = $derived(re.test(state.headingTag) ? state.headingTag : 'h2');
10
14
  </script>
11
15
 
12
- <svelte:element this={headingTag} use:__AgnosUISveltePreprocess__classDirective={"accordion-header"} use:slotContext.widget.directives.headerDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(slotContext.widget.directives.headerDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-header"])}>
13
- <button use:slotContext.widget.directives.buttonDirective use:__AgnosUISveltePreprocess__classDirective={"accordion-button"} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(slotContext.widget.directives.buttonDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-button"])}>
14
- <Slot slotContent={state.header} props={slotContext} let:component let:props>
15
- <svelte:fragment slot="slot" let:props><slot name="header" {...props} /></svelte:fragment>
16
- <svelte:component this={component} {...props}>
17
- <svelte:fragment let:state let:widget><slot {state} {widget} /></svelte:fragment>
18
- <svelte:fragment slot="header" let:state let:widget><slot name="header" {state} {widget} /></svelte:fragment>
19
- <svelte:fragment slot="structure" let:state let:widget><slot name="structure" {state} {widget} /></svelte:fragment>
20
- </svelte:component>
21
- </Slot>
16
+ <svelte:element this={headingTag} use:__AgnosUISveltePreprocess__classDirective={"accordion-header"} use:directives.headerDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(directives.headerDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-header"])}>
17
+ <button use:directives.buttonDirective use:__AgnosUISveltePreprocess__classDirective={"accordion-button"} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(directives.buttonDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-button"])}>
18
+ <Slot content={state.header} props={widget} />
22
19
  </button>
23
20
  </svelte:element>
24
21
  {#if state.shouldBeInDOM}
25
- <div use:__AgnosUISveltePreprocess__classDirective={"accordion-collapse"} use:widget.directives.bodyContainerDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(widget.directives.bodyContainerDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-collapse"])}>
26
- <div use:__AgnosUISveltePreprocess__classDirective={"accordion-body"} use:widget.directives.bodyDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(widget.directives.bodyDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-body"])}>
27
- <Slot slotContent={state.children} props={slotContext} let:component let:props>
28
- <svelte:fragment slot="slot" let:props><slot {...props} /></svelte:fragment>
29
- <svelte:component this={component} {...props}>
30
- <svelte:fragment let:state let:widget><slot {state} {widget} /></svelte:fragment>
31
- <svelte:fragment slot="header" let:state let:widget><slot name="header" {state} {widget} /></svelte:fragment>
32
- <svelte:fragment slot="structure" let:state let:widget><slot name="structure" {state} {widget} /></svelte:fragment>
33
- </svelte:component>
34
- </Slot>
22
+ <div use:__AgnosUISveltePreprocess__classDirective={"accordion-collapse"} use:directives.bodyContainerDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(directives.bodyContainerDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-collapse"])}>
23
+ <div use:__AgnosUISveltePreprocess__classDirective={"accordion-body"} use:directives.bodyDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(directives.bodyDirective, [__AgnosUISveltePreprocess__classDirective, "accordion-body"])}>
24
+ <Slot content={state.children} props={widget} />
35
25
  </div>
36
26
  </div>
37
27
  {/if}
@@ -1,17 +1,3 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { AccordionItemSlots } from './accordion';
3
- declare const __propDef: {
4
- props: WidgetSlotContext<Widget<import("./accordion.gen").AccordionItemProps, import("./accordion.gen").AccordionItemState, import("./accordion.gen").AccordionItemApi, import("./accordion.gen").AccordionItemActions, import("./accordion.gen").AccordionItemDirectives>>;
5
- events: {
6
- [evt: string]: CustomEvent<any>;
7
- };
8
- slots: AccordionItemSlots;
9
- exports?: {} | undefined;
10
- bindings?: string | undefined;
11
- };
12
- export type ItemDefaultStructureProps = typeof __propDef.props;
13
- export type ItemDefaultStructureEvents = typeof __propDef.events;
14
- export type ItemDefaultStructureSlots = typeof __propDef.slots;
15
- export default class ItemDefaultStructure extends SvelteComponent<ItemDefaultStructureProps, ItemDefaultStructureEvents, ItemDefaultStructureSlots> {
16
- }
17
- export {};
1
+ import type { AccordionItemContext } from './accordion';
2
+ declare const ItemDefaultStructure: import("svelte").Component<AccordionItemContext, {}, "">;
3
+ export default ItemDefaultStructure;
@@ -1,9 +1,14 @@
1
- import type { WidgetPropsSlots } from '@agnos-ui/svelte-headless/types';
2
- import type { AccordionApi, AccordionItemProps, AccordionProps } from './accordion.gen';
1
+ import type { AccordionApi } from './accordion.gen';
3
2
  export * from './accordion.gen';
4
- export interface AccordionSlots extends WidgetPropsSlots<AccordionProps> {
5
- }
6
- export interface AccordionItemSlots extends WidgetPropsSlots<AccordionItemProps> {
7
- }
3
+ /**
4
+ * Sets the Accordion API in the context.
5
+ *
6
+ * @param accordionApi - The Accordion API to be set in the context.
7
+ */
8
8
  export declare function setAccordionApi(accordionApi: AccordionApi): void;
9
+ /**
10
+ * Retrieves the Accordion API from the Svelte context.
11
+ *
12
+ * @returns {AccordionApi} The Accordion API instance.
13
+ */
9
14
  export declare function getAccordionApi(): AccordionApi;
@@ -6,7 +6,14 @@ import type { TransitionFn } from '@agnos-ui/svelte-headless/services/transition
6
6
  */
7
7
  declare const export_getAccordionDefaultConfig: () => AccordionProps;
8
8
  export { export_getAccordionDefaultConfig as getAccordionDefaultConfig };
9
- export type AccordionItemContext = WidgetSlotContext<AccordionItemWidget>;
9
+ /**
10
+ * Represents the context for an accordion item within the accordion component.
11
+ */
12
+ export interface AccordionItemContext extends WidgetSlotContext<AccordionItemWidget> {
13
+ }
14
+ /**
15
+ * Represents the state of an Accordion component.
16
+ */
10
17
  export interface AccordionState {
11
18
  /**
12
19
  * Array containing all the accordion-items contained in the accordion.
@@ -28,6 +35,9 @@ export interface AccordionState {
28
35
  */
29
36
  itemStructure: SlotContent<AccordionItemContext>;
30
37
  }
38
+ /**
39
+ * Represents the state of an AccordionItem component.
40
+ */
31
41
  export interface AccordionProps {
32
42
  /**
33
43
  * The transition to use for the accordion-item body-container when the accordion-item is toggled.
@@ -131,7 +141,13 @@ export interface AccordionProps {
131
141
  */
132
142
  itemStructure: SlotContent<AccordionItemContext>;
133
143
  }
134
- export type AccordionWidget = Widget<AccordionProps, AccordionState, AccordionApi, object, AccordionDirectives>;
144
+ /**
145
+ * Represents an Accordion widget type.
146
+ */
147
+ export type AccordionWidget = Widget<AccordionProps, AccordionState, AccordionApi, AccordionDirectives>;
148
+ /**
149
+ * Represents the state of an accordion item, extending the core item state and additional properties specific to the accordion item.
150
+ */
135
151
  export interface AccordionItemState {
136
152
  /**
137
153
  * If `true` the content of the accordion-item collapse should be in DOM. Its value depends on the
@@ -200,6 +216,9 @@ export interface AccordionItemState {
200
216
  */
201
217
  header: SlotContent<AccordionItemContext>;
202
218
  }
219
+ /**
220
+ * Represents the properties for an Accordion item component.
221
+ */
203
222
  export interface AccordionItemProps {
204
223
  /**
205
224
  * If `true`, accordion-item will be animated.
@@ -289,7 +308,10 @@ export interface AccordionItemProps {
289
308
  */
290
309
  header: SlotContent<AccordionItemContext>;
291
310
  }
292
- export type AccordionItemWidget = Widget<AccordionItemProps, AccordionItemState, AccordionItemApi, AccordionItemActions, AccordionItemDirectives>;
311
+ /**
312
+ * Represents a widget for an accordion item.
313
+ */
314
+ export type AccordionItemWidget = Widget<AccordionItemProps, AccordionItemState, AccordionItemApi, AccordionItemDirectives>;
293
315
  /**
294
316
  * Create an AccordionItemWidget with given config props
295
317
  * @param config - an optional AccordionItem config
@@ -315,6 +337,9 @@ export { export_createAccordion as createAccordion };
315
337
  */
316
338
  declare const export_factoryCreateAccordion: (itemFactory?: WidgetFactory<AccordionItemWidget>, accordionItemProps?: string[], accordionConfig?: AccordionProps, accordionValidator?: ConfigValidator<AccordionProps>) => WidgetFactory<AccordionWidget>;
317
339
  export { export_factoryCreateAccordion as factoryCreateAccordion };
340
+ /**
341
+ * Interface representing the API for an accordion component.
342
+ */
318
343
  export interface AccordionApi {
319
344
  /**
320
345
  * Given the itemId, will expand the corresponding accordion-item.
@@ -349,18 +374,18 @@ export interface AccordionApi {
349
374
  */
350
375
  registerItem(itemConfig?: PropsConfig<AccordionItemProps>): AccordionItemWidget;
351
376
  }
377
+ /**
378
+ * Interface representing the directives used in the Accordion component.
379
+ */
352
380
  export interface AccordionDirectives {
353
381
  /**
354
382
  * Directive to put on the accordion DOM element
355
383
  */
356
384
  accordionDirective: Directive;
357
385
  }
358
- export interface AccordionItemActions {
359
- /**
360
- * Action to be called when the user clicks on the accordion-item button. If the accordion-item is disabled nothing will happen.
361
- */
362
- click(): void;
363
- }
386
+ /**
387
+ * Interface representing the API for an accordion item.
388
+ */
364
389
  export interface AccordionItemApi {
365
390
  /**
366
391
  * It will collapse the accordion-item.
@@ -379,6 +404,9 @@ export interface AccordionItemApi {
379
404
  */
380
405
  initDone(): void;
381
406
  }
407
+ /**
408
+ * Interface representing the directives used in an accordion item.
409
+ */
382
410
  export interface AccordionItemDirectives {
383
411
  /**
384
412
  * Directive to use in special cases, if the accordion header does not use a button element to control the collapsing.
@@ -2,9 +2,19 @@ export * from './accordion.gen';
2
2
  // context
3
3
  import { getContext, setContext } from 'svelte';
4
4
  const contextInjectionKey = Symbol('accordion-api');
5
+ /**
6
+ * Sets the Accordion API in the context.
7
+ *
8
+ * @param accordionApi - The Accordion API to be set in the context.
9
+ */
5
10
  export function setAccordionApi(accordionApi) {
6
11
  setContext(contextInjectionKey, accordionApi);
7
12
  }
13
+ /**
14
+ * Retrieves the Accordion API from the Svelte context.
15
+ *
16
+ * @returns {AccordionApi} The Accordion API instance.
17
+ */
8
18
  export function getAccordionApi() {
9
19
  return getContext(contextInjectionKey);
10
20
  }
@@ -1,50 +1,46 @@
1
- <script context="module">
1
+ <script lang="ts">
2
2
  import {ssrAttributes as __AgnosUISveltePreprocess__ssrAttributes, classDirective as __AgnosUISveltePreprocess__classDirective} from '@agnos-ui/svelte-headless/utils/directive';
3
3
  import {BROWSER as __AgnosUISveltePreprocess__BROWSER} from 'esm-env';
4
- import { Slot } from "@agnos-ui/svelte-headless/slot";
5
- import { createAlert } from "./alert";
6
- import { callWidgetFactory } from "../../config";
7
- import AlertDefaultStructure from "./AlertDefaultStructure.svelte";
8
- const defaultConfig = {
9
- structure: AlertDefaultStructure
10
- };
11
- </script>
12
4
 
13
- <script>const widget = callWidgetFactory({
14
- factory: createAlert,
15
- widgetName: "alert",
16
- $$slots,
17
- $$props,
18
- defaultConfig,
19
- events: {
20
- onVisibleChange: (event) => {
21
- visible = event;
22
- }
23
- }
24
- });
25
- export let visible = void 0;
26
- export const api = widget.api;
27
- const {
28
- stores: { structure$, hidden$ },
29
- directives: { transitionDirective },
30
- state$
31
- } = widget;
32
- $: widget.patchChangedProps($$props);
33
- $: slotContext = { widget, state: $state$ };
5
+ import {Slot} from '@agnos-ui/svelte-headless/slot';
6
+ import {type AlertContext, createAlert, type AlertApi, type AlertProps} from './alert.gen';
7
+ import {callWidgetFactory} from '../../config';
8
+ import AlertDefaultStructure from './AlertDefaultStructure.svelte';
9
+
10
+ let {visible = $bindable(), ...props}: Partial<AlertProps> = $props();
11
+
12
+ const widget = callWidgetFactory({
13
+ factory: createAlert,
14
+ widgetName: 'alert',
15
+ get props() {
16
+ return {...props, visible};
17
+ },
18
+ enablePatchChanged: true,
19
+ defaultConfig: {structure},
20
+ events: {
21
+ onVisibleChange: (event) => {
22
+ visible = event;
23
+ },
24
+ },
25
+ });
26
+ export const api: AlertApi = widget.api;
27
+
28
+ const {
29
+ state,
30
+ directives: {transitionDirective},
31
+ } = widget;
34
32
  </script>
35
33
 
36
- {#if !$hidden$}
34
+ {#snippet structure(props: AlertContext)}
35
+ <AlertDefaultStructure {...props} />
36
+ {/snippet}
37
+
38
+ {#if !state.hidden}
37
39
  <div
38
40
  role="alert"
39
- use:__AgnosUISveltePreprocess__classDirective={"au-alert alert alert-"+($state$.type)+" "+($state$.className)+" "+($state$.dismissible ? 'alert-dismissible' : '')}
40
- use:transitionDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(transitionDirective, [__AgnosUISveltePreprocess__classDirective, "au-alert alert alert-"+($state$.type)+" "+($state$.className)+" "+($state$.dismissible ? 'alert-dismissible' : '')])}
41
+ use:__AgnosUISveltePreprocess__classDirective={"au-alert alert alert-"+(state.type)+" "+(state.className)+" "+(state.dismissible ? 'alert-dismissible' : '')}
42
+ use:transitionDirective {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(transitionDirective, [__AgnosUISveltePreprocess__classDirective, "au-alert alert alert-"+(state.type)+" "+(state.className)+" "+(state.dismissible ? 'alert-dismissible' : '')])}
41
43
  >
42
- <Slot slotContent={$structure$} props={slotContext} let:component let:props>
43
- <svelte:fragment slot="slot" let:props><slot name="structure" {...props} /></svelte:fragment>
44
- <svelte:component this={component} {...props}>
45
- <svelte:fragment let:state let:widget><slot {state} {widget} /></svelte:fragment>
46
- <svelte:fragment slot="structure" let:state let:widget><slot name="structure" {state} {widget} /></svelte:fragment>
47
- </svelte:component>
48
- </Slot>
44
+ <Slot content={state.structure} props={widget} />
49
45
  </div>
50
46
  {/if}
@@ -1,21 +1,5 @@
1
- import { SvelteComponent } from "svelte";
2
- import { type AlertApi, type AlertProps, type AlertSlots } from './alert';
3
- declare const __propDef: {
4
- props: {
5
- api?: AlertApi;
6
- } & Partial<AlertProps>;
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: AlertSlots;
11
- exports?: {} | undefined;
12
- bindings?: string | undefined;
13
- };
14
- type AlertProps_ = typeof __propDef.props;
15
- export { AlertProps_ as AlertProps };
16
- export type AlertEvents = typeof __propDef.events;
17
- type AlertSlots_ = typeof __propDef.slots;
18
- export { AlertSlots_ as AlertSlots };
19
- export default class Alert extends SvelteComponent<AlertProps_, AlertEvents, AlertSlots_> {
20
- get api(): AlertApi;
21
- }
1
+ import { type AlertApi, type AlertProps } from './alert.gen';
2
+ declare const Alert: import("svelte").Component<Partial<AlertProps>, {
3
+ api: AlertApi;
4
+ }, "visible">;
5
+ export default Alert;
@@ -1,18 +1,14 @@
1
- <script>import { Slot } from "@agnos-ui/svelte-headless/slot";
2
- export let state;
3
- export let widget;
4
- $: slotContext = { widget, state };
1
+ <script lang="ts">
2
+ import type {AlertContext} from './alert.gen';
3
+ import {Slot} from '@agnos-ui/svelte-headless/slot';
4
+
5
+ let widget: AlertContext = $props();
6
+ let state = widget.state;
5
7
  </script>
6
8
 
7
9
  <div class="alert-body">
8
- <Slot slotContent={state.children} props={slotContext} let:component let:props>
9
- <svelte:fragment slot="slot" let:props><slot {...props} /></svelte:fragment>
10
- <svelte:component this={component} {...props}>
11
- <svelte:fragment let:state let:widget><slot {state} {widget} /></svelte:fragment>
12
- <svelte:fragment slot="structure" let:state let:widget><slot name="structure" {state} {widget} /></svelte:fragment>
13
- </svelte:component>
14
- </Slot>
10
+ <Slot content={state.children} props={widget} />
15
11
  </div>
16
12
  {#if state.dismissible}
17
- <button type="button" class="btn-close" on:click={() => widget.api.close()} aria-label={state.ariaCloseButtonLabel} />
13
+ <button type="button" class="btn-close" onclick={() => widget.api.close()} aria-label={state.ariaCloseButtonLabel}></button>
18
14
  {/if}
@@ -1,17 +1,3 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { AlertSlots } from './alert';
3
- declare const __propDef: {
4
- props: WidgetSlotContext<Widget<import("./alert.gen").AlertProps, import("./alert.gen").AlertState, import("./alert.gen").AlertApi, object, import("./alert.gen").AlertDirectives>>;
5
- events: {
6
- [evt: string]: CustomEvent<any>;
7
- };
8
- slots: AlertSlots;
9
- exports?: {} | undefined;
10
- bindings?: string | undefined;
11
- };
12
- export type AlertDefaultStructureProps = typeof __propDef.props;
13
- export type AlertDefaultStructureEvents = typeof __propDef.events;
14
- export type AlertDefaultStructureSlots = typeof __propDef.slots;
15
- export default class AlertDefaultStructure extends SvelteComponent<AlertDefaultStructureProps, AlertDefaultStructureEvents, AlertDefaultStructureSlots> {
16
- }
17
- export {};
1
+ import type { AlertContext } from './alert.gen';
2
+ declare const AlertDefaultStructure: import("svelte").Component<AlertContext, {}, "">;
3
+ export default AlertDefaultStructure;