@agnos-ui/svelte-bootstrap 0.4.3 → 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
@@ -8,16 +8,20 @@ export { export_getPaginationDefaultConfig as getPaginationDefaultConfig };
8
8
  /**
9
9
  * A type for the slot context of the pagination widget
10
10
  */
11
- export type PaginationContext = WidgetSlotContext<PaginationWidget>;
11
+ export interface PaginationContext extends WidgetSlotContext<PaginationWidget> {
12
+ }
12
13
  /**
13
14
  * A type for the slot context of the pagination widget when the slot is the number label
14
15
  */
15
- export type PaginationNumberContext = PaginationContext & {
16
+ export interface PaginationNumberContext extends PaginationContext {
16
17
  /**
17
18
  * Displayed page
18
19
  */
19
20
  displayedPage: number;
20
- };
21
+ }
22
+ /**
23
+ * Represents the state of a pagination component.
24
+ */
21
25
  export interface PaginationState {
22
26
  /**
23
27
  * The number of pages.
@@ -53,14 +57,6 @@ export interface PaginationState {
53
57
  * @defaultValue `1`
54
58
  */
55
59
  page: number;
56
- /**
57
- * The pagination display size.
58
- *
59
- * Bootstrap currently supports small and large sizes.
60
- *
61
- * @defaultValue `null`
62
- */
63
- size: 'sm' | 'lg' | null;
64
60
  /**
65
61
  * The label for the nav element.
66
62
  *
@@ -223,7 +219,18 @@ export interface PaginationState {
223
219
  * ```
224
220
  */
225
221
  numberLabel: SlotContent<PaginationNumberContext>;
222
+ /**
223
+ * The pagination display size.
224
+ *
225
+ * Bootstrap currently supports small and large sizes.
226
+ *
227
+ * @defaultValue `null`
228
+ */
229
+ size: 'sm' | 'lg' | null;
226
230
  }
231
+ /**
232
+ * Represents the properties for the Pagination component.
233
+ */
227
234
  export interface PaginationProps {
228
235
  /**
229
236
  * The number of items in your paginated collection.
@@ -300,7 +307,7 @@ export interface PaginationProps {
300
307
  *
301
308
  * @defaultValue
302
309
  * ```ts
303
- * (currentPage: number, pageCount: number) => `Current page is ${currentPage}`
310
+ * (currentPage: number) => `Current page is ${currentPage}`
304
311
  * ```
305
312
  */
306
313
  ariaLiveLabel: (currentPage: number, pageCount: number) => string;
@@ -323,14 +330,6 @@ export interface PaginationProps {
323
330
  * @defaultValue `1`
324
331
  */
325
332
  page: number;
326
- /**
327
- * The pagination display size.
328
- *
329
- * Bootstrap currently supports small and large sizes.
330
- *
331
- * @defaultValue `null`
332
- */
333
- size: 'sm' | 'lg' | null;
334
333
  /**
335
334
  * The label for the nav element.
336
335
  *
@@ -493,8 +492,22 @@ export interface PaginationProps {
493
492
  * ```
494
493
  */
495
494
  numberLabel: SlotContent<PaginationNumberContext>;
495
+ /**
496
+ * The pagination display size.
497
+ *
498
+ * Bootstrap currently supports small and large sizes.
499
+ *
500
+ * @defaultValue `null`
501
+ */
502
+ size: 'sm' | 'lg' | null;
496
503
  }
497
- export type PaginationWidget = Widget<PaginationProps, PaginationState, PaginationApi, PaginationActions, PaginationDirectives>;
504
+ /**
505
+ * Represents a pagination widget component.
506
+ *
507
+ * This type defines a widget that handles pagination functionality,
508
+ * including properties, state, api and directives specific to pagination.
509
+ */
510
+ export type PaginationWidget = Widget<PaginationProps, PaginationState, PaginationApi, PaginationDirectives>;
498
511
  /**
499
512
  * Create a PaginationWidget with given config props
500
513
  * @param config - an optional alert config
@@ -502,6 +515,9 @@ export type PaginationWidget = Widget<PaginationProps, PaginationState, Paginati
502
515
  */
503
516
  declare const export_createPagination: WidgetFactory<PaginationWidget>;
504
517
  export { export_createPagination as createPagination };
518
+ /**
519
+ * Interface representing the hrefs for pagination navigation links.
520
+ */
505
521
  export interface DirectionsHrefs {
506
522
  /**
507
523
  * The href for the 'Previous' navigation link
@@ -512,29 +528,35 @@ export interface DirectionsHrefs {
512
528
  */
513
529
  next: string;
514
530
  }
515
- export interface PaginationActions {
531
+ /**
532
+ * Interface representing pagination API for navigating through pages.
533
+ */
534
+ export interface PaginationApi {
516
535
  /**
517
536
  * To "go" to a specific page
518
537
  * @param page - The page number to select
519
538
  */
520
- select(page: number, event?: MouseEvent): void;
539
+ select(page: number): void;
521
540
  /**
522
541
  * To "go" to the first page
523
542
  */
524
- first(event?: MouseEvent): void;
543
+ first(): void;
525
544
  /**
526
545
  * To "go" to the previous page
527
546
  */
528
- previous(event?: MouseEvent): void;
547
+ previous(): void;
529
548
  /**
530
549
  * To "go" to the next page
531
550
  */
532
- next(event?: MouseEvent): void;
551
+ next(): void;
533
552
  /**
534
553
  * To "go" to the last page
535
554
  */
536
- last(event?: MouseEvent): void;
555
+ last(): void;
537
556
  }
557
+ /**
558
+ * Interface representing the directives for pagination components.
559
+ */
538
560
  export interface PaginationDirectives {
539
561
  /**
540
562
  * A directive to be applied to each page link
@@ -560,5 +582,3 @@ export interface PaginationDirectives {
560
582
  */
561
583
  pageLast: Directive;
562
584
  }
563
- export interface PaginationApi {
564
- }
@@ -1,36 +1,33 @@
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 { createProgressbar } from "./progressbar";
5
- import { Slot } from "@agnos-ui/svelte-headless/slot";
6
- import { callWidgetFactory } from "../../config";
7
- import ProgressbarDefaultStructure from "./ProgressbarDefaultStructure.svelte";
8
- const widget = callWidgetFactory({
9
- factory: createProgressbar,
10
- widgetName: "progressbar",
11
- $$slots,
12
- $$props,
13
- defaultConfig: {
14
- structure: ProgressbarDefaultStructure
15
- },
16
- events: {}
17
- });
18
- const {
19
- stores: { structure$, className$ },
20
- state$,
21
- directives: { ariaDirective }
22
- } = widget;
23
- export const api = widget.api;
24
- $: widget.patchChangedProps($$props);
25
- $: slotContext = { widget, state: $state$ };
4
+
5
+ import {createProgressbar, type ProgressbarContext, type ProgressbarProps} from './progressbar.gen';
6
+ import {Slot} from '@agnos-ui/svelte-headless/slot';
7
+ import {callWidgetFactory} from '../../config';
8
+ import ProgressbarDefaultStructure from './ProgressbarDefaultStructure.svelte';
9
+
10
+ let props: Partial<ProgressbarProps> = $props();
11
+
12
+ const widget = callWidgetFactory({
13
+ factory: createProgressbar,
14
+ widgetName: 'progressbar',
15
+ props,
16
+ enablePatchChanged: true,
17
+ defaultConfig: {
18
+ structure,
19
+ },
20
+ });
21
+ const {
22
+ state,
23
+ directives: {ariaDirective},
24
+ } = widget;
26
25
  </script>
27
26
 
28
- <div use:ariaDirective use:__AgnosUISveltePreprocess__classDirective={($className$ || undefined)} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(ariaDirective, [__AgnosUISveltePreprocess__classDirective, ($className$ || undefined)])}>
29
- <Slot slotContent={$structure$} props={slotContext} let:component let:props>
30
- <svelte:fragment slot="slot" let:props><slot name="structure" {...props} /></svelte:fragment>
31
- <svelte:component this={component} {...props}>
32
- <svelte:fragment let:state let:widget><slot {state} {widget} /></svelte:fragment>
33
- <svelte:fragment slot="structure" let:state let:widget><slot name="structure" {state} {widget} /></svelte:fragment>
34
- </svelte:component>
35
- </Slot>
27
+ {#snippet structure(props: ProgressbarContext)}
28
+ <ProgressbarDefaultStructure {...props} />
29
+ {/snippet}
30
+
31
+ <div use:ariaDirective use:__AgnosUISveltePreprocess__classDirective={(state.className || undefined)} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(ariaDirective, [__AgnosUISveltePreprocess__classDirective, (state.className || undefined)])}>
32
+ <Slot content={state.structure} props={widget} />
36
33
  </div>
@@ -1,21 +1,3 @@
1
- import { SvelteComponent } from "svelte";
2
- import { type ProgressbarProps, type ProgressbarSlots, type ProgressbarApi } from './progressbar';
3
- declare const __propDef: {
4
- props: {
5
- api?: ProgressbarApi;
6
- } & Partial<ProgressbarProps>;
7
- events: {
8
- [evt: string]: CustomEvent<any>;
9
- };
10
- slots: ProgressbarSlots;
11
- exports?: {} | undefined;
12
- bindings?: string | undefined;
13
- };
14
- type ProgressbarProps_ = typeof __propDef.props;
15
- export { ProgressbarProps_ as ProgressbarProps };
16
- export type ProgressbarEvents = typeof __propDef.events;
17
- type ProgressbarSlots_ = typeof __propDef.slots;
18
- export { ProgressbarSlots_ as ProgressbarSlots };
19
- export default class Progressbar extends SvelteComponent<ProgressbarProps_, ProgressbarEvents, ProgressbarSlots_> {
20
- get api(): ProgressbarApi;
21
- }
1
+ import { type ProgressbarProps } from './progressbar.gen';
2
+ declare const Progressbar: import("svelte").Component<Partial<ProgressbarProps>, {}, "">;
3
+ export default Progressbar;
@@ -1,7 +1,8 @@
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 {Slot} from '@agnos-ui/svelte-headless/slot';
3
+ import type {ProgressbarContext} from './progressbar.gen';
4
+
5
+ let {state, api, directives}: ProgressbarContext = $props();
5
6
  </script>
6
7
 
7
8
  <div class="progress" style:height={state.height}>
@@ -11,12 +12,6 @@ $: slotContext = { widget, state };
11
12
  class:progress-bar-animated={state.animated}
12
13
  style:width={`${state.percentage}%`}
13
14
  >
14
- <Slot slotContent={state.children} props={slotContext} let:component let:props>
15
- <svelte:fragment slot="slot" let:props><slot {...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="structure" let:state let:widget><slot name="structure" {state} {widget} /></svelte:fragment>
19
- </svelte:component>
20
- </Slot>
15
+ <Slot content={state.children} props={{state, api, directives}} />
21
16
  </div>
22
17
  </div>
@@ -1,17 +1,3 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { ProgressbarSlots } from './progressbar';
3
- declare const __propDef: {
4
- props: WidgetSlotContext<Widget<import("./progressbar.gen").ProgressbarProps, import("./progressbar.gen").ProgressbarState, import("./progressbar.gen").ProgressbarApi, object, import("./progressbar.gen").ProgressbarDirectives>>;
5
- events: {
6
- [evt: string]: CustomEvent<any>;
7
- };
8
- slots: ProgressbarSlots;
9
- exports?: {} | undefined;
10
- bindings?: string | undefined;
11
- };
12
- export type ProgressbarDefaultStructureProps = typeof __propDef.props;
13
- export type ProgressbarDefaultStructureEvents = typeof __propDef.events;
14
- export type ProgressbarDefaultStructureSlots = typeof __propDef.slots;
15
- export default class ProgressbarDefaultStructure extends SvelteComponent<ProgressbarDefaultStructureProps, ProgressbarDefaultStructureEvents, ProgressbarDefaultStructureSlots> {
16
- }
17
- export {};
1
+ import type { ProgressbarContext } from './progressbar.gen';
2
+ declare const ProgressbarDefaultStructure: import("svelte").Component<ProgressbarContext, {}, "">;
3
+ export default ProgressbarDefaultStructure;
@@ -1,3 +1,3 @@
1
1
  import Progressbar from './Progressbar.svelte';
2
- export * from './progressbar';
2
+ export * from './progressbar.gen';
3
3
  export { Progressbar };
@@ -1,3 +1,3 @@
1
1
  import Progressbar from './Progressbar.svelte';
2
- export * from './progressbar';
2
+ export * from './progressbar.gen';
3
3
  export { Progressbar };
@@ -6,7 +6,15 @@ import type { BSContextualClass } from '@agnos-ui/core-bootstrap/types';
6
6
  */
7
7
  declare const export_getProgressbarDefaultConfig: () => ProgressbarProps;
8
8
  export { export_getProgressbarDefaultConfig as getProgressbarDefaultConfig };
9
- export type ProgressbarContext = WidgetSlotContext<ProgressbarWidget>;
9
+ /**
10
+ * Represents the context for a Progressbar widget.
11
+ * This interface is used to define the context object that is passed to the Progressbar widget.
12
+ */
13
+ export interface ProgressbarContext extends WidgetSlotContext<ProgressbarWidget> {
14
+ }
15
+ /**
16
+ * Represents the state of a Progressbar component.
17
+ */
10
18
  export interface ProgressbarState {
11
19
  /**
12
20
  * Percentage of completion.
@@ -86,6 +94,9 @@ export interface ProgressbarState {
86
94
  */
87
95
  type: BSContextualClass | undefined;
88
96
  }
97
+ /**
98
+ * Interface representing the properties for the Progressbar component.
99
+ */
89
100
  export interface ProgressbarProps {
90
101
  /**
91
102
  * Return the value for the 'aria-valuetext' attribute.
@@ -161,7 +172,12 @@ export interface ProgressbarProps {
161
172
  */
162
173
  type: BSContextualClass | undefined;
163
174
  }
164
- export type ProgressbarWidget = Widget<ProgressbarProps, ProgressbarState, ProgressbarApi, object, ProgressbarDirectives>;
175
+ /**
176
+ * Represents a Progressbar widget.
177
+ *
178
+ * This type defines the structure of a Progressbar widget, including its properties, state, and directives.
179
+ */
180
+ export type ProgressbarWidget = Widget<ProgressbarProps, ProgressbarState, object, ProgressbarDirectives>;
165
181
  /**
166
182
  * Create a Progressbar with given config props
167
183
  * @param config - an optional progressbar config
@@ -169,11 +185,12 @@ export type ProgressbarWidget = Widget<ProgressbarProps, ProgressbarState, Progr
169
185
  */
170
186
  declare const export_createProgressbar: WidgetFactory<ProgressbarWidget>;
171
187
  export { export_createProgressbar as createProgressbar };
188
+ /**
189
+ * Interface representing directives for a progress bar component.
190
+ */
172
191
  export interface ProgressbarDirectives {
173
192
  /**
174
193
  * A directive to be applied to the main container that handles aria attributes.
175
194
  */
176
195
  ariaDirective: Directive;
177
196
  }
178
- export interface ProgressbarApi {
179
- }
@@ -1,37 +1,43 @@
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 { createRating } from "./rating";
5
- import { callWidgetFactory } from "../../config";
6
- import { Slot } from "@agnos-ui/svelte-headless/slot";
7
- export let rating = void 0;
8
- const widget = callWidgetFactory({
9
- factory: createRating,
10
- widgetName: "rating",
11
- $$slots,
12
- $$props,
13
- events: {
14
- onRatingChange: (value) => {
15
- rating = value;
16
- }
17
- }
18
- });
19
- const {
20
- stores: { visibleRating$, stars$, star$ },
21
- directives: { containerDirective, starDirective }
22
- } = widget;
23
- $: widget.patchChangedProps($$props);
4
+
5
+ import type {RatingProps, StarContext} from './rating.gen';
6
+ import {createRating} from './rating.gen';
7
+ import {callWidgetFactory} from '../../config';
8
+ import {Slot} from '@agnos-ui/svelte-headless/slot';
9
+
10
+ let {rating = $bindable(), ...props}: Partial<RatingProps> = $props();
11
+
12
+ const {
13
+ state,
14
+ directives: {containerDirective, starDirective},
15
+ } = callWidgetFactory({
16
+ factory: createRating,
17
+ widgetName: 'rating',
18
+ get props() {
19
+ return {...props, rating};
20
+ },
21
+ enablePatchChanged: true,
22
+ defaultConfig: {star},
23
+ events: {
24
+ onRatingChange: (value: number) => {
25
+ rating = value;
26
+ },
27
+ },
28
+ });
24
29
  </script>
25
30
 
31
+ {#snippet star({fill}: StarContext)}
32
+ {String.fromCharCode(fill === 100 ? 9733 : 9734)}
33
+ {/snippet}
34
+
26
35
  <div use:containerDirective use:__AgnosUISveltePreprocess__classDirective={"d-inline-flex"} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(containerDirective, [__AgnosUISveltePreprocess__classDirective, "d-inline-flex"])}>
27
36
  <!-- on:blur={onTouched} ?? -->
28
- {#each $stars$ as { fill, index }}
29
- <span class="visually-hidden">({index < $visibleRating$ ? '*' : ' '})</span>
37
+ {#each state.stars as { fill, index }}
38
+ <span class="visually-hidden">({index < state.visibleRating ? '*' : ' '})</span>
30
39
  <span use:starDirective={{index}} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes([starDirective, {index}])}>
31
- <Slot slotContent={$star$} props={{fill, index}} let:component let:props>
32
- <svelte:fragment slot="slot" let:props><slot name="star" {...props} /></svelte:fragment>
33
- <svelte:component this={component} {...props} />
34
- </Slot>
40
+ <Slot content={state.star} props={{fill, index}} />
35
41
  </span>
36
42
  {/each}
37
43
  </div>
@@ -1,18 +1,3 @@
1
- import { SvelteComponent } from "svelte";
2
- import type { RatingProps, RatingSlots } from './rating';
3
- declare const __propDef: {
4
- props: Partial<RatingProps>;
5
- events: {
6
- [evt: string]: CustomEvent<any>;
7
- };
8
- slots: RatingSlots;
9
- exports?: {} | undefined;
10
- bindings?: string | undefined;
11
- };
12
- type RatingProps_ = typeof __propDef.props;
13
- export { RatingProps_ as RatingProps };
14
- export type RatingEvents = typeof __propDef.events;
15
- type RatingSlots_ = typeof __propDef.slots;
16
- export { RatingSlots_ as RatingSlots };
17
- export default class Rating extends SvelteComponent<RatingProps_, RatingEvents, RatingSlots_> {
18
- }
1
+ import type { RatingProps } from './rating.gen';
2
+ declare const Rating: import("svelte").Component<Partial<RatingProps>, {}, "rating">;
3
+ export default Rating;
@@ -1,3 +1,3 @@
1
1
  import Rating from './Rating.svelte';
2
- export * from './rating';
2
+ export * from './rating.gen';
3
3
  export { Rating };
@@ -1,3 +1,3 @@
1
1
  import Rating from './Rating.svelte';
2
- export * from './rating';
2
+ export * from './rating.gen';
3
3
  export { Rating };
@@ -5,6 +5,9 @@ import type { SlotContent, Widget, WidgetFactory, Directive } from '@agnos-ui/sv
5
5
  */
6
6
  declare const export_getRatingDefaultConfig: () => RatingProps;
7
7
  export { export_getRatingDefaultConfig as getRatingDefaultConfig };
8
+ /**
9
+ * Represents the state of a rating component.
10
+ */
8
11
  export interface RatingState {
9
12
  /**
10
13
  * the aria value of the rating
@@ -89,6 +92,9 @@ export interface RatingState {
89
92
  */
90
93
  star: SlotContent<StarContext>;
91
94
  }
95
+ /**
96
+ * Represents the properties for the Rating component.
97
+ */
92
98
  export interface RatingProps {
93
99
  /**
94
100
  * Return the value for the 'aria-valuetext' attribute.
@@ -201,7 +207,10 @@ export interface RatingProps {
201
207
  */
202
208
  star: SlotContent<StarContext>;
203
209
  }
204
- export type RatingWidget = Widget<RatingProps, RatingState, object, RatingActions, RatingDirectives>;
210
+ /**
211
+ * Represents a Rating Widget component.
212
+ */
213
+ export type RatingWidget = Widget<RatingProps, RatingState, RatingApi, RatingDirectives>;
205
214
  /**
206
215
  * Create a RatingWidget with given config props
207
216
  * @param config - an optional rating config
@@ -209,6 +218,9 @@ export type RatingWidget = Widget<RatingProps, RatingState, object, RatingAction
209
218
  */
210
219
  declare const export_createRating: WidgetFactory<RatingWidget>;
211
220
  export { export_createRating as createRating };
221
+ /**
222
+ * Represents the context for a star in a rating component.
223
+ */
212
224
  export interface StarContext {
213
225
  /**
214
226
  * indicates how much the current star is filled, from 0 to 100
@@ -219,6 +231,9 @@ export interface StarContext {
219
231
  */
220
232
  index: number;
221
233
  }
234
+ /**
235
+ * Interface representing directives for a rating component.
236
+ */
222
237
  export interface RatingDirectives {
223
238
  /**
224
239
  * A directive to be applied to the main container
@@ -232,31 +247,24 @@ export interface RatingDirectives {
232
247
  index: number;
233
248
  }>;
234
249
  }
235
- export interface RatingActions {
250
+ /**
251
+ * Interface representing the API that can be performed on a rating component.
252
+ */
253
+ export interface RatingApi {
236
254
  /**
237
- * Method to be used when a star is clicked.
255
+ * Sets the rating value.
238
256
  *
239
- * To be used in the onclick event of a star
240
257
  * @param index - Star index, starting from 1
241
258
  */
242
- click(index: number): void;
259
+ setRating(index: number): void;
243
260
  /**
244
- * Method to be used when the mouse enter in a star.
261
+ * Sets the hovered rating value.
245
262
  *
246
- * To be used in the onmouseenter of a star
247
263
  * @param index - Star index, starting from 1
248
264
  */
249
- hover(index: number): void;
265
+ setHoveredRating(index: number): void;
250
266
  /**
251
- * Method to be used when the mouse leave the widget.
252
- *
253
- * To be used in the onmouseleave of the rating container
267
+ * Leave the rating, resetting the visible rating to the rating value and triggering the onLeave callback
254
268
  */
255
269
  leave(): void;
256
- /**
257
- * Method to be used to handle the keyboard.
258
- *
259
- * To be used in the onkeydown of the rating container
260
- */
261
- handleKey(event: KeyboardEvent): void;
262
270
  }