@agnos-ui/svelte-bootstrap 0.3.1 → 0.4.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.
- package/components/accordion/Accordion.svelte +2 -8
- package/components/accordion/Accordion.svelte.d.ts +4 -2
- package/components/accordion/Item.svelte +14 -16
- package/components/accordion/Item.svelte.d.ts +6 -4
- package/components/accordion/ItemDefaultStructure.svelte +12 -14
- package/components/accordion/ItemDefaultStructure.svelte.d.ts +7 -5
- package/components/accordion/accordion.d.ts +7 -21
- package/components/accordion/accordion.gen.d.ts +343 -0
- package/components/accordion/accordion.gen.js +1 -0
- package/components/accordion/accordion.js +3 -3
- package/components/alert/Alert.svelte +5 -7
- package/components/alert/Alert.svelte.d.ts +4 -2
- package/components/alert/AlertDefaultStructure.svelte +2 -3
- package/components/alert/AlertDefaultStructure.svelte.d.ts +6 -4
- package/components/alert/alert.d.ts +5 -14
- package/components/alert/alert.gen.d.ts +119 -0
- package/components/alert/alert.gen.js +1 -0
- package/components/alert/alert.js +2 -3
- package/components/modal/Modal.svelte +2 -4
- package/components/modal/Modal.svelte.d.ts +3 -3
- package/components/modal/ModalDefaultHeader.svelte +1 -2
- package/components/modal/ModalDefaultHeader.svelte.d.ts +5 -5
- package/components/modal/ModalDefaultStructure.svelte +2 -3
- package/components/modal/ModalDefaultStructure.svelte.d.ts +5 -5
- package/components/modal/modal.d.ts +7 -15
- package/components/modal/modal.gen.d.ts +239 -0
- package/components/modal/modal.gen.js +1 -0
- package/components/modal/modal.js +3 -3
- package/components/pagination/Pagination.svelte +2 -4
- package/components/pagination/Pagination.svelte.d.ts +4 -2
- package/components/pagination/PaginationDefaultPages.svelte.d.ts +6 -4
- package/components/pagination/PaginationDefaultStructure.svelte +2 -4
- package/components/pagination/PaginationDefaultStructure.svelte.d.ts +6 -4
- package/components/pagination/pagination.d.ts +5 -16
- package/components/pagination/pagination.gen.d.ts +394 -0
- package/components/pagination/pagination.gen.js +1 -0
- package/components/pagination/pagination.js +2 -3
- package/components/progressbar/Progressbar.svelte +2 -4
- package/components/progressbar/Progressbar.svelte.d.ts +4 -2
- package/components/progressbar/ProgressbarDefaultStructure.svelte +2 -3
- package/components/progressbar/ProgressbarDefaultStructure.svelte.d.ts +6 -4
- package/components/progressbar/progressbar.d.ts +5 -14
- package/components/progressbar/progressbar.gen.d.ts +126 -0
- package/components/progressbar/progressbar.gen.js +1 -0
- package/components/progressbar/progressbar.js +2 -3
- package/components/rating/Rating.svelte +3 -5
- package/components/rating/Rating.svelte.d.ts +6 -7
- package/components/rating/rating.d.ts +5 -12
- package/components/rating/rating.gen.d.ts +179 -0
- package/components/rating/rating.gen.js +1 -0
- package/components/rating/rating.js +2 -3
- package/components/select/Select.svelte +11 -8
- package/components/select/Select.svelte.d.ts +2 -2
- package/components/select/select.d.ts +5 -16
- package/components/select/select.gen.d.ts +293 -0
- package/components/select/select.gen.js +1 -0
- package/components/select/select.js +2 -3
- package/components/slider/Slider.svelte +6 -8
- package/components/slider/Slider.svelte.d.ts +4 -2
- package/components/slider/SliderDefaultHandle.svelte.d.ts +6 -4
- package/components/slider/SliderDefaultStructure.svelte +9 -10
- package/components/slider/SliderDefaultStructure.svelte.d.ts +6 -4
- package/components/slider/slider.d.ts +5 -18
- package/components/slider/slider.gen.d.ts +293 -0
- package/components/slider/slider.gen.js +1 -0
- package/components/slider/slider.js +2 -3
- package/components/toast/Toast.svelte +6 -15
- package/components/toast/Toast.svelte.d.ts +4 -2
- package/components/toast/ToastDefaultStructure.svelte +5 -6
- package/components/toast/ToastDefaultStructure.svelte.d.ts +6 -4
- package/components/toast/toast.d.ts +5 -14
- package/components/toast/toast.gen.d.ts +146 -0
- package/components/toast/toast.gen.js +1 -0
- package/components/toast/toast.js +2 -3
- package/config.d.ts +4 -6
- package/config.gen.d.ts +47 -0
- package/config.gen.js +1 -0
- package/package.json +6 -6
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { createProgressbar as coreCreateProgressbar } from '@agnos-ui/core-bootstrap/components/progressbar';
|
|
3
|
-
// factory
|
|
1
|
+
import { createProgressbar as coreCreateProgressbar, getProgressbarDefaultConfig as coreGetProgressbarDefaultConfig, } from '@agnos-ui/core-bootstrap/components/progressbar';
|
|
4
2
|
export const createProgressbar = coreCreateProgressbar;
|
|
3
|
+
export const getProgressbarDefaultConfig = coreGetProgressbarDefaultConfig;
|
|
@@ -16,13 +16,11 @@ const widget = callWidgetFactory({
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
export const api = widget.api;
|
|
20
19
|
const {
|
|
21
|
-
stores: { visibleRating$, stars$,
|
|
20
|
+
stores: { visibleRating$, stars$, star$ },
|
|
22
21
|
directives: { containerDirective, starDirective }
|
|
23
22
|
} = widget;
|
|
24
|
-
$:
|
|
25
|
-
widget.patchChangedProps($$props);
|
|
23
|
+
$: widget.patchChangedProps($$props);
|
|
26
24
|
</script>
|
|
27
25
|
|
|
28
26
|
<div use:containerDirective use:__AgnosUISveltePreprocess__classDirective={"d-inline-flex"} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(containerDirective, [__AgnosUISveltePreprocess__classDirective, "d-inline-flex"])}>
|
|
@@ -30,7 +28,7 @@ $:
|
|
|
30
28
|
{#each $stars$ as { fill, index }}
|
|
31
29
|
<span class="visually-hidden">({index < $visibleRating$ ? '*' : ' '})</span>
|
|
32
30
|
<span use:starDirective={{index}} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes([starDirective, {index}])}>
|
|
33
|
-
<Slot slotContent={$
|
|
31
|
+
<Slot slotContent={$star$} props={{fill, index}} let:component let:props>
|
|
34
32
|
<svelte:fragment slot="slot" let:props><slot name="star" {...props} /></svelte:fragment>
|
|
35
33
|
<svelte:component this={component} {...props} />
|
|
36
34
|
</Slot>
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { RatingProps, RatingSlots } from './rating';
|
|
3
3
|
declare const __propDef: {
|
|
4
|
-
props:
|
|
5
|
-
api?: RatingApi | undefined;
|
|
6
|
-
} & Partial<RatingProps>;
|
|
4
|
+
props: Partial<RatingProps>;
|
|
7
5
|
events: {
|
|
8
6
|
[evt: string]: CustomEvent<any>;
|
|
9
7
|
};
|
|
10
8
|
slots: RatingSlots;
|
|
9
|
+
exports?: {} | undefined;
|
|
10
|
+
bindings?: string | undefined;
|
|
11
11
|
};
|
|
12
12
|
type RatingProps_ = typeof __propDef.props;
|
|
13
13
|
export { RatingProps_ as RatingProps };
|
|
14
14
|
export type RatingEvents = typeof __propDef.events;
|
|
15
15
|
type RatingSlots_ = typeof __propDef.slots;
|
|
16
16
|
export { RatingSlots_ as RatingSlots };
|
|
17
|
-
export default class Rating extends
|
|
18
|
-
get api(): RatingApi;
|
|
17
|
+
export default class Rating extends SvelteComponent<RatingProps_, RatingEvents, RatingSlots_> {
|
|
19
18
|
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export interface RatingProps extends WidgetProps<RatingWidget> {
|
|
7
|
-
}
|
|
8
|
-
export interface RatingState extends WidgetState<RatingWidget> {
|
|
9
|
-
}
|
|
10
|
-
export interface RatingApi extends PropType<RatingWidget, 'api'> {
|
|
11
|
-
}
|
|
1
|
+
import type { WidgetPropsSlots, WidgetFactory } from '@agnos-ui/svelte-headless/types';
|
|
2
|
+
import type { RatingWidget, RatingProps } from './rating.gen';
|
|
3
|
+
export type * from './rating.gen';
|
|
4
|
+
export declare const createRating: WidgetFactory<RatingWidget>;
|
|
5
|
+
export declare const getRatingDefaultConfig: () => RatingProps;
|
|
12
6
|
export interface RatingSlots extends WidgetPropsSlots<RatingProps> {
|
|
13
7
|
}
|
|
14
|
-
export declare const createRating: WidgetFactory<RatingWidget>;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { SlotContent, Widget, Directive } from '@agnos-ui/svelte-headless/types';
|
|
2
|
+
export interface RatingState {
|
|
3
|
+
/**
|
|
4
|
+
* the aria value of the rating
|
|
5
|
+
*/
|
|
6
|
+
ariaValueText: string;
|
|
7
|
+
/**
|
|
8
|
+
* the visible value of the rating (it changes when hovering over the rating even though the real value did not change)
|
|
9
|
+
*/
|
|
10
|
+
visibleRating: number;
|
|
11
|
+
/**
|
|
12
|
+
* is the rating interactive i.e. listening to hover, click and keyboard events
|
|
13
|
+
*/
|
|
14
|
+
interactive: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* the list of stars
|
|
17
|
+
*/
|
|
18
|
+
stars: StarContext[];
|
|
19
|
+
/**
|
|
20
|
+
* The current rating. Could be a decimal value like `3.75`.
|
|
21
|
+
*/
|
|
22
|
+
rating: number;
|
|
23
|
+
/**
|
|
24
|
+
* The maximum rating that can be given.
|
|
25
|
+
*/
|
|
26
|
+
maxRating: number;
|
|
27
|
+
/**
|
|
28
|
+
* If `true`, the rating is disabled.
|
|
29
|
+
*/
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* If `true`, the rating can't be changed.
|
|
33
|
+
*/
|
|
34
|
+
readonly: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Define if the rating can be reset.
|
|
37
|
+
*
|
|
38
|
+
* If set to true, the user can 'unset' the rating value by cliking on the current rating value.
|
|
39
|
+
*/
|
|
40
|
+
resettable: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Allows setting a custom rating tabindex.
|
|
43
|
+
* If the component is disabled, `tabindex` will still be set to `-1`.
|
|
44
|
+
*/
|
|
45
|
+
tabindex: number;
|
|
46
|
+
/**
|
|
47
|
+
* The aria label
|
|
48
|
+
*/
|
|
49
|
+
ariaLabel: string;
|
|
50
|
+
/**
|
|
51
|
+
* The aria labelled by
|
|
52
|
+
*/
|
|
53
|
+
ariaLabelledBy: string;
|
|
54
|
+
/**
|
|
55
|
+
* CSS classes to be applied on the widget main container
|
|
56
|
+
*/
|
|
57
|
+
className: string;
|
|
58
|
+
/**
|
|
59
|
+
* The template to override the way each star is displayed.
|
|
60
|
+
*/
|
|
61
|
+
star: SlotContent<StarContext>;
|
|
62
|
+
}
|
|
63
|
+
export interface RatingProps {
|
|
64
|
+
/**
|
|
65
|
+
* Return the value for the 'aria-valuetext' attribute.
|
|
66
|
+
*/
|
|
67
|
+
ariaValueTextFn: (rating: number, maxRating: number) => string;
|
|
68
|
+
/**
|
|
69
|
+
* An event emitted when the rating is changed.
|
|
70
|
+
*
|
|
71
|
+
* Event payload is equal to the newly selected rating.
|
|
72
|
+
*/
|
|
73
|
+
onRatingChange: (rating: number) => void;
|
|
74
|
+
/**
|
|
75
|
+
* An event emitted when the user is hovering over a given rating.
|
|
76
|
+
*
|
|
77
|
+
* Event payload is equal to the rating being hovered over.
|
|
78
|
+
*/
|
|
79
|
+
onHover: (rating: number) => void;
|
|
80
|
+
/**
|
|
81
|
+
* An event emitted when the user stops hovering over a given rating.
|
|
82
|
+
*
|
|
83
|
+
* Event payload is equal to the rating of the last item being hovered over.
|
|
84
|
+
*/
|
|
85
|
+
onLeave: (rating: number) => void;
|
|
86
|
+
/**
|
|
87
|
+
* The current rating. Could be a decimal value like `3.75`.
|
|
88
|
+
*/
|
|
89
|
+
rating: number;
|
|
90
|
+
/**
|
|
91
|
+
* The maximum rating that can be given.
|
|
92
|
+
*/
|
|
93
|
+
maxRating: number;
|
|
94
|
+
/**
|
|
95
|
+
* If `true`, the rating is disabled.
|
|
96
|
+
*/
|
|
97
|
+
disabled: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* If `true`, the rating can't be changed.
|
|
100
|
+
*/
|
|
101
|
+
readonly: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Define if the rating can be reset.
|
|
104
|
+
*
|
|
105
|
+
* If set to true, the user can 'unset' the rating value by cliking on the current rating value.
|
|
106
|
+
*/
|
|
107
|
+
resettable: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Allows setting a custom rating tabindex.
|
|
110
|
+
* If the component is disabled, `tabindex` will still be set to `-1`.
|
|
111
|
+
*/
|
|
112
|
+
tabindex: number;
|
|
113
|
+
/**
|
|
114
|
+
* The aria label
|
|
115
|
+
*/
|
|
116
|
+
ariaLabel: string;
|
|
117
|
+
/**
|
|
118
|
+
* The aria labelled by
|
|
119
|
+
*/
|
|
120
|
+
ariaLabelledBy: string;
|
|
121
|
+
/**
|
|
122
|
+
* CSS classes to be applied on the widget main container
|
|
123
|
+
*/
|
|
124
|
+
className: string;
|
|
125
|
+
/**
|
|
126
|
+
* The template to override the way each star is displayed.
|
|
127
|
+
*/
|
|
128
|
+
star: SlotContent<StarContext>;
|
|
129
|
+
}
|
|
130
|
+
export type RatingWidget = Widget<RatingProps, RatingState, object, RatingActions, RatingDirectives>;
|
|
131
|
+
export interface StarContext {
|
|
132
|
+
/**
|
|
133
|
+
* indicates how much the current star is filled, from 0 to 100
|
|
134
|
+
*/
|
|
135
|
+
fill: number;
|
|
136
|
+
/**
|
|
137
|
+
* the position of the star in the rating
|
|
138
|
+
*/
|
|
139
|
+
index: number;
|
|
140
|
+
}
|
|
141
|
+
export interface RatingDirectives {
|
|
142
|
+
/**
|
|
143
|
+
* A directive to be applied to the main container
|
|
144
|
+
* This will handle the keydown, mouseleave, tabindex and aria attributes
|
|
145
|
+
*/
|
|
146
|
+
containerDirective: Directive;
|
|
147
|
+
/**
|
|
148
|
+
* A directive to be applied on each star element
|
|
149
|
+
*/
|
|
150
|
+
starDirective: Directive<{
|
|
151
|
+
index: number;
|
|
152
|
+
}>;
|
|
153
|
+
}
|
|
154
|
+
export interface RatingActions {
|
|
155
|
+
/**
|
|
156
|
+
* Method to be used when a star is clicked.
|
|
157
|
+
*
|
|
158
|
+
* To be used in the onclick event of a star
|
|
159
|
+
*/
|
|
160
|
+
click(index: number): void;
|
|
161
|
+
/**
|
|
162
|
+
* Method to be used when the mouse enter in a star.
|
|
163
|
+
*
|
|
164
|
+
* To be used in the onmouseenter of a star
|
|
165
|
+
*/
|
|
166
|
+
hover(index: number): void;
|
|
167
|
+
/**
|
|
168
|
+
* Method to be used when the mouse leave the widget.
|
|
169
|
+
*
|
|
170
|
+
* To be used in the onmouseleave of the rating container
|
|
171
|
+
*/
|
|
172
|
+
leave(): void;
|
|
173
|
+
/**
|
|
174
|
+
* Method to be used to handle the keyboard.
|
|
175
|
+
*
|
|
176
|
+
* To be used in the onkeydown of the rating container
|
|
177
|
+
*/
|
|
178
|
+
handleKey(event: KeyboardEvent): void;
|
|
179
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { createRating as coreCreateRating } from '@agnos-ui/core-bootstrap/components/rating';
|
|
3
|
-
// factory
|
|
1
|
+
import { createRating as coreCreateRating, getRatingDefaultConfig as coreGetRatingDefaultConfig } from '@agnos-ui/core-bootstrap/components/rating';
|
|
4
2
|
export const createRating = coreCreateRating;
|
|
3
|
+
export const getRatingDefaultConfig = coreGetRatingDefaultConfig;
|
|
@@ -28,7 +28,7 @@ const widget = callWidgetFactory({
|
|
|
28
28
|
});
|
|
29
29
|
export const api = widget.api;
|
|
30
30
|
const {
|
|
31
|
-
stores: { id$, ariaLabel$, highlighted$, open$, selectedContexts$,
|
|
31
|
+
stores: { id$, ariaLabel$, highlighted$, open$, selectedContexts$, badgeLabel$, itemLabel$, visibleItems$, className$, filterText$ },
|
|
32
32
|
state$,
|
|
33
33
|
actions: { onInput, onInputKeydown },
|
|
34
34
|
directives: {
|
|
@@ -41,21 +41,22 @@ const {
|
|
|
41
41
|
itemAttributesDirective
|
|
42
42
|
}
|
|
43
43
|
} = widget;
|
|
44
|
-
$:
|
|
45
|
-
widget.patchChangedProps($$props);
|
|
44
|
+
$: widget.patchChangedProps($$props);
|
|
46
45
|
</script>
|
|
47
46
|
|
|
48
47
|
<div use:referenceDirective use:__AgnosUISveltePreprocess__classDirective={"au-select dropdown border border-1 p-1 mb-3 d-block "+($className$)} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(referenceDirective, [__AgnosUISveltePreprocess__classDirective, "au-select dropdown border border-1 p-1 mb-3 d-block "+($className$)])}>
|
|
49
48
|
<div use:hasFocusDirective use:inputContainerDirective use:__AgnosUISveltePreprocess__classDirective={"d-flex align-items-center flex-wrap gap-1"} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes(hasFocusDirective, inputContainerDirective, [__AgnosUISveltePreprocess__classDirective, "d-flex align-items-center flex-wrap gap-1"])}>
|
|
50
49
|
{#each $selectedContexts$ as itemContext (itemContext.id)}
|
|
51
50
|
<div use:badgeAttributesDirective={itemContext} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes([badgeAttributesDirective, itemContext])}>
|
|
52
|
-
<Slot slotContent={$
|
|
51
|
+
<Slot slotContent={$badgeLabel$} props={{state: $state$, widget, itemContext}} let:component let:props>
|
|
53
52
|
<svelte:fragment slot="slot" let:props><slot name="badgeLabel" {...props} /></svelte:fragment>
|
|
54
53
|
<svelte:component this={component} {...props}>
|
|
55
54
|
<svelte:fragment slot="badgeLabel" let:itemContext let:state let:widget
|
|
56
55
|
><slot name="badgeLabel" {itemContext} {state} {widget} /></svelte:fragment
|
|
57
56
|
>
|
|
58
|
-
<svelte:fragment slot="
|
|
57
|
+
<svelte:fragment slot="itemLabel" let:itemContext let:state let:widget
|
|
58
|
+
><slot name="itemLabel" {itemContext} {state} {widget} /></svelte:fragment
|
|
59
|
+
>
|
|
59
60
|
</svelte:component>
|
|
60
61
|
</Slot>
|
|
61
62
|
</div>
|
|
@@ -79,13 +80,15 @@ $:
|
|
|
79
80
|
{#each $visibleItems$ as itemContext (itemContext.id)}
|
|
80
81
|
{@const isHighlighted = itemContext === $highlighted$}
|
|
81
82
|
<li use:__AgnosUISveltePreprocess__classDirective={"dropdown-item position-relative"} class:text-bg-primary={isHighlighted} use:itemAttributesDirective={itemContext} {...__AgnosUISveltePreprocess__BROWSER ? {} : __AgnosUISveltePreprocess__ssrAttributes([itemAttributesDirective, itemContext], [__AgnosUISveltePreprocess__classDirective, "dropdown-item position-relative"])}>
|
|
82
|
-
<Slot slotContent={$
|
|
83
|
-
<svelte:fragment slot="slot" let:props><slot name="
|
|
83
|
+
<Slot slotContent={$itemLabel$} props={{state: $state$, widget, itemContext}} let:component let:props>
|
|
84
|
+
<svelte:fragment slot="slot" let:props><slot name="itemLabel" {...props} /></svelte:fragment>
|
|
84
85
|
<svelte:component this={component} {...props}>
|
|
85
86
|
<svelte:fragment slot="badgeLabel" let:itemContext let:state let:widget
|
|
86
87
|
><slot name="badgeLabel" {itemContext} {state} {widget} /></svelte:fragment
|
|
87
88
|
>
|
|
88
|
-
<svelte:fragment slot="
|
|
89
|
+
<svelte:fragment slot="itemLabel" let:itemContext let:state let:widget
|
|
90
|
+
><slot name="itemLabel" {itemContext} {state} {widget} /></svelte:fragment
|
|
91
|
+
>
|
|
89
92
|
</svelte:component>
|
|
90
93
|
</Slot>
|
|
91
94
|
</li>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
2
|
import type { SelectApi, SelectProps, SelectSlots } from './select';
|
|
3
3
|
declare class __sveltets_Render<Item> {
|
|
4
4
|
props(): {
|
|
@@ -12,7 +12,7 @@ declare class __sveltets_Render<Item> {
|
|
|
12
12
|
export type SelectProps_<Item> = ReturnType<__sveltets_Render<Item>['props']>;
|
|
13
13
|
export type SelectEvents<Item> = ReturnType<__sveltets_Render<Item>['events']>;
|
|
14
14
|
export type SelectSlots_<Item> = ReturnType<__sveltets_Render<Item>['slots']>;
|
|
15
|
-
export default class Select<Item> extends
|
|
15
|
+
export default class Select<Item> extends SvelteComponent<SelectProps_<Item>, SelectEvents<Item>, SelectSlots_<Item>> {
|
|
16
16
|
get api(): SelectApi<Item>;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export interface SelectProps<Item> extends WidgetProps<SelectWidget<Item>> {
|
|
7
|
-
}
|
|
8
|
-
export interface SelectState<Item> extends WidgetState<SelectWidget<Item>> {
|
|
9
|
-
}
|
|
10
|
-
export interface SelectApi<Item> extends PropType<SelectWidget<Item>, 'api'> {
|
|
11
|
-
}
|
|
1
|
+
import type { WidgetPropsSlots, PropsConfig } from '@agnos-ui/svelte-headless/types';
|
|
2
|
+
import type { SelectProps, SelectWidget } from './select.gen';
|
|
3
|
+
export type * from './select.gen';
|
|
4
|
+
export declare const createSelect: <Item>(propsConfig?: PropsConfig<SelectProps<Item>>) => SelectWidget<Item>;
|
|
5
|
+
export declare const getSelectDefaultConfig: () => SelectProps<any>;
|
|
12
6
|
export interface SelectSlots<Item> extends WidgetPropsSlots<SelectProps<Item>> {
|
|
13
7
|
}
|
|
14
|
-
export interface SelectContext<Item> extends AdaptSlotContentProps<CoreContext<Item>> {
|
|
15
|
-
}
|
|
16
|
-
export interface SelectItemContext<Item> extends AdaptSlotContentProps<CoreItemContext<Item>> {
|
|
17
|
-
}
|
|
18
|
-
export declare const createSelect: <Item>(propsConfig?: PropsConfig<SelectProps<Item>>) => SelectWidget<Item>;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type { WidgetSlotContext, SlotContent, Widget, Directive } from '@agnos-ui/svelte-headless/types';
|
|
2
|
+
import type { Placement } from '@floating-ui/dom';
|
|
3
|
+
import type { HasFocus } from '@agnos-ui/svelte-headless/services/focustrack';
|
|
4
|
+
import type { FloatingUI } from '@agnos-ui/svelte-headless/services/floatingUI';
|
|
5
|
+
export type SelectContext<Item> = WidgetSlotContext<SelectWidget<Item>>;
|
|
6
|
+
export type SelectItemContext<Item> = SelectContext<Item> & {
|
|
7
|
+
/**
|
|
8
|
+
* Contextual data related to an item
|
|
9
|
+
*/
|
|
10
|
+
itemContext: ItemContext<Item>;
|
|
11
|
+
};
|
|
12
|
+
export interface SelectState<Item> {
|
|
13
|
+
/**
|
|
14
|
+
* List of item contexts, to be displayed in the menu
|
|
15
|
+
*/
|
|
16
|
+
visibleItems: ItemContext<Item>[];
|
|
17
|
+
/**
|
|
18
|
+
* List of selected items to be display
|
|
19
|
+
*/
|
|
20
|
+
selectedContexts: ItemContext<Item>[];
|
|
21
|
+
/**
|
|
22
|
+
* Highlighted item context.
|
|
23
|
+
* It is designed to define the highlighted item in the dropdown menu
|
|
24
|
+
*/
|
|
25
|
+
highlighted: ItemContext<Item> | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Current placement of the dropdown
|
|
28
|
+
*/
|
|
29
|
+
placement: Placement | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* id used for the input inside the select
|
|
32
|
+
*/
|
|
33
|
+
id: string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* aria-label used for the input inside the select
|
|
36
|
+
*/
|
|
37
|
+
ariaLabel: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* List of selected item ids
|
|
40
|
+
*/
|
|
41
|
+
selected: Item[];
|
|
42
|
+
/**
|
|
43
|
+
* Filtered text to be display in the filter input
|
|
44
|
+
*/
|
|
45
|
+
filterText: string;
|
|
46
|
+
/**
|
|
47
|
+
* true if the select is disabled
|
|
48
|
+
*/
|
|
49
|
+
disabled: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* true if the select is open
|
|
52
|
+
*/
|
|
53
|
+
open: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Class to be added on the dropdown menu container
|
|
56
|
+
*/
|
|
57
|
+
menuClassName: string;
|
|
58
|
+
/**
|
|
59
|
+
* Class to be added on menu items
|
|
60
|
+
*/
|
|
61
|
+
menuItemClassName: string;
|
|
62
|
+
/**
|
|
63
|
+
* Class to be added on selected items (displayed in the input zone)
|
|
64
|
+
*/
|
|
65
|
+
badgeClassName: string;
|
|
66
|
+
/**
|
|
67
|
+
* true if a loading process is being done
|
|
68
|
+
*/
|
|
69
|
+
loading: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* CSS classes to be applied on the widget main container
|
|
72
|
+
*/
|
|
73
|
+
className: string;
|
|
74
|
+
/**
|
|
75
|
+
* The template to override the way each badge on the left of the input is displayed.
|
|
76
|
+
* This define the content of the badge inside the badge container.
|
|
77
|
+
*/
|
|
78
|
+
badgeLabel: SlotContent<SelectItemContext<Item>>;
|
|
79
|
+
/**
|
|
80
|
+
* The template to override the way each item is displayed in the list.
|
|
81
|
+
* This define the content of the badge inside the badge container.
|
|
82
|
+
*/
|
|
83
|
+
itemLabel: SlotContent<SelectItemContext<Item>>;
|
|
84
|
+
}
|
|
85
|
+
export interface SelectProps<Item> {
|
|
86
|
+
/**
|
|
87
|
+
* List of available items for the dropdown
|
|
88
|
+
*/
|
|
89
|
+
items: Item[];
|
|
90
|
+
/**
|
|
91
|
+
* List of allowed placements for the dropdown.
|
|
92
|
+
* This refers to the [allowedPlacements from floating UI](https://floating-ui.com/docs/autoPlacement#allowedplacements), given the different [Placement possibilities](https://floating-ui.com/docs/computePosition#placement).
|
|
93
|
+
*/
|
|
94
|
+
allowedPlacements: Placement[];
|
|
95
|
+
/**
|
|
96
|
+
* Custom function to get the id of an item
|
|
97
|
+
* By default, the item is returned
|
|
98
|
+
*/
|
|
99
|
+
itemIdFn(item: Item): string;
|
|
100
|
+
/**
|
|
101
|
+
* Retrieves navigable elements within an HTML element containing badges and the input.
|
|
102
|
+
*/
|
|
103
|
+
navSelector(node: HTMLElement): NodeListOf<HTMLSpanElement | HTMLInputElement>;
|
|
104
|
+
/**
|
|
105
|
+
* Callback called dropdown open state change
|
|
106
|
+
*/
|
|
107
|
+
onOpenChange(isOpen: boolean): void;
|
|
108
|
+
/**
|
|
109
|
+
* Callback called when the text filter change
|
|
110
|
+
*/
|
|
111
|
+
onFilterTextChange(text: string): void;
|
|
112
|
+
/**
|
|
113
|
+
* Callback called when the selection change
|
|
114
|
+
*/
|
|
115
|
+
onSelectedChange(selected: Item[]): void;
|
|
116
|
+
/**
|
|
117
|
+
* id used for the input inside the select
|
|
118
|
+
*/
|
|
119
|
+
id: string | undefined;
|
|
120
|
+
/**
|
|
121
|
+
* aria-label used for the input inside the select
|
|
122
|
+
*/
|
|
123
|
+
ariaLabel: string | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* List of selected item ids
|
|
126
|
+
*/
|
|
127
|
+
selected: Item[];
|
|
128
|
+
/**
|
|
129
|
+
* Filtered text to be display in the filter input
|
|
130
|
+
*/
|
|
131
|
+
filterText: string;
|
|
132
|
+
/**
|
|
133
|
+
* true if the select is disabled
|
|
134
|
+
*/
|
|
135
|
+
disabled: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* true if the select is open
|
|
138
|
+
*/
|
|
139
|
+
open: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Class to be added on the dropdown menu container
|
|
142
|
+
*/
|
|
143
|
+
menuClassName: string;
|
|
144
|
+
/**
|
|
145
|
+
* Class to be added on menu items
|
|
146
|
+
*/
|
|
147
|
+
menuItemClassName: string;
|
|
148
|
+
/**
|
|
149
|
+
* Class to be added on selected items (displayed in the input zone)
|
|
150
|
+
*/
|
|
151
|
+
badgeClassName: string;
|
|
152
|
+
/**
|
|
153
|
+
* true if a loading process is being done
|
|
154
|
+
*/
|
|
155
|
+
loading: boolean;
|
|
156
|
+
/**
|
|
157
|
+
* CSS classes to be applied on the widget main container
|
|
158
|
+
*/
|
|
159
|
+
className: string;
|
|
160
|
+
/**
|
|
161
|
+
* The template to override the way each badge on the left of the input is displayed.
|
|
162
|
+
* This define the content of the badge inside the badge container.
|
|
163
|
+
*/
|
|
164
|
+
badgeLabel: SlotContent<SelectItemContext<Item>>;
|
|
165
|
+
/**
|
|
166
|
+
* The template to override the way each item is displayed in the list.
|
|
167
|
+
* This define the content of the badge inside the badge container.
|
|
168
|
+
*/
|
|
169
|
+
itemLabel: SlotContent<SelectItemContext<Item>>;
|
|
170
|
+
}
|
|
171
|
+
export type SelectWidget<Item> = Widget<SelectProps<Item>, SelectState<Item>, SelectApi<Item>, SelectActions<Item>, SelectDirectives<Item>>;
|
|
172
|
+
export interface ItemContext<T> {
|
|
173
|
+
/**
|
|
174
|
+
* Original item given in the parameters
|
|
175
|
+
*/
|
|
176
|
+
item: T;
|
|
177
|
+
/**
|
|
178
|
+
* Unique id to identify the item
|
|
179
|
+
*/
|
|
180
|
+
id: string;
|
|
181
|
+
/**
|
|
182
|
+
* Specify if the item is checked
|
|
183
|
+
*/
|
|
184
|
+
selected: boolean;
|
|
185
|
+
}
|
|
186
|
+
export interface SelectApi<Item> {
|
|
187
|
+
/**
|
|
188
|
+
* Clear all the selected items
|
|
189
|
+
*/
|
|
190
|
+
clear(): void;
|
|
191
|
+
/**
|
|
192
|
+
* Clear the filter text
|
|
193
|
+
*/
|
|
194
|
+
clearText(): void;
|
|
195
|
+
/**
|
|
196
|
+
* Highlight the given item, if there is a corresponding match among the visible list
|
|
197
|
+
*/
|
|
198
|
+
highlight(item: Item): void;
|
|
199
|
+
/**
|
|
200
|
+
* Highlight the first item among the visible list
|
|
201
|
+
*/
|
|
202
|
+
highlightFirst(): void;
|
|
203
|
+
/**
|
|
204
|
+
* Highlight the previous item among the visible list
|
|
205
|
+
* Loop to the last item if needed
|
|
206
|
+
*/
|
|
207
|
+
highlightPrevious(): void;
|
|
208
|
+
/**
|
|
209
|
+
* Highlight the next item among the visible list.
|
|
210
|
+
* Loop to the first item if needed
|
|
211
|
+
*/
|
|
212
|
+
highlightNext(): void;
|
|
213
|
+
/**
|
|
214
|
+
* Highlight the last item among the visible list
|
|
215
|
+
*/
|
|
216
|
+
highlightLast(): void;
|
|
217
|
+
/**
|
|
218
|
+
* Select the provided item.
|
|
219
|
+
* The selected list is used to
|
|
220
|
+
*/
|
|
221
|
+
select(item: Item): void;
|
|
222
|
+
/**
|
|
223
|
+
* Unselect the provided item.
|
|
224
|
+
*/
|
|
225
|
+
unselect(item: Item): void;
|
|
226
|
+
/**
|
|
227
|
+
* Toggle the selection of an item
|
|
228
|
+
*/
|
|
229
|
+
toggleItem(item: Item, selected?: boolean): void;
|
|
230
|
+
/**
|
|
231
|
+
* open the select
|
|
232
|
+
*/
|
|
233
|
+
open(): void;
|
|
234
|
+
/**
|
|
235
|
+
* close the select
|
|
236
|
+
*/
|
|
237
|
+
close(): void;
|
|
238
|
+
/**
|
|
239
|
+
* Toggle the dropdown menu
|
|
240
|
+
*/
|
|
241
|
+
toggle(isOpen?: boolean): void;
|
|
242
|
+
}
|
|
243
|
+
export interface SelectDirectives<Item> {
|
|
244
|
+
/**
|
|
245
|
+
* Directive to be used in the input group and the menu containers
|
|
246
|
+
*/
|
|
247
|
+
hasFocusDirective: HasFocus['directive'];
|
|
248
|
+
/**
|
|
249
|
+
* Directive that enables dynamic positioning of menu element
|
|
250
|
+
*/
|
|
251
|
+
floatingDirective: FloatingUI['directives']['floatingDirective'];
|
|
252
|
+
/**
|
|
253
|
+
* A directive to be applied to the input group element serves as the base for menu positioning
|
|
254
|
+
*/
|
|
255
|
+
referenceDirective: FloatingUI['directives']['referenceDirective'];
|
|
256
|
+
/**
|
|
257
|
+
* A directive to be applied to the element that contains the badges and the input
|
|
258
|
+
*/
|
|
259
|
+
inputContainerDirective: Directive;
|
|
260
|
+
/**
|
|
261
|
+
* A directive that applies all the necessary attributes to the container badges
|
|
262
|
+
*/
|
|
263
|
+
badgeAttributesDirective: Directive<ItemContext<Item>>;
|
|
264
|
+
/**
|
|
265
|
+
* A directive that applies all the necessary attributes to the dropdown menu
|
|
266
|
+
*/
|
|
267
|
+
menuAttributesDirective: Directive;
|
|
268
|
+
/**
|
|
269
|
+
* A directive that applies all the necessary attributes to the dropdown item
|
|
270
|
+
*/
|
|
271
|
+
itemAttributesDirective: Directive<ItemContext<Item>>;
|
|
272
|
+
}
|
|
273
|
+
export interface SelectActions<Item> {
|
|
274
|
+
/**
|
|
275
|
+
* Method to be plugged to on the 'input' event. The input text will be used as the filter text.
|
|
276
|
+
*/
|
|
277
|
+
onInput: (e: {
|
|
278
|
+
target: any;
|
|
279
|
+
}) => void;
|
|
280
|
+
/**
|
|
281
|
+
* Method to be attached to the node element to close a badge on click.
|
|
282
|
+
*/
|
|
283
|
+
onRemoveBadgeClick: (event: MouseEvent, item: Item) => void;
|
|
284
|
+
/**
|
|
285
|
+
* Method to be plugged to on an keydown event of the main input, in order to control the keyboard interactions with the highlighted item.
|
|
286
|
+
* It manages arrow keys to move the highlighted item, or enter to toggle the item.
|
|
287
|
+
*/
|
|
288
|
+
onInputKeydown: (event: KeyboardEvent) => void;
|
|
289
|
+
/**
|
|
290
|
+
* Method to be plugged to on an keydown event of a badge container, in order to manage main actions on badges.
|
|
291
|
+
*/
|
|
292
|
+
onBadgeKeydown: (event: KeyboardEvent, item: Item) => void;
|
|
293
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import { createSelect as coreCreateSelect } from '@agnos-ui/core-bootstrap/components/select';
|
|
3
|
-
// factory
|
|
1
|
+
import { createSelect as coreCreateSelect, getSelectDefaultConfig as coreGetSelectDefaultConfig } from '@agnos-ui/core-bootstrap/components/select';
|
|
4
2
|
export const createSelect = coreCreateSelect;
|
|
3
|
+
export const getSelectDefaultConfig = coreGetSelectDefaultConfig;
|