@agnos-ui/core 0.8.0-next.0 → 0.8.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/{accordion-hVi2XRk-.js → accordion-BLVIYePx.js} +3 -3
- package/{accordion-DTQj-TQ1.cjs → accordion-vfnqMstG.cjs} +1 -1
- package/{alert-BSixS_cz.js → alert-BpepSIHu.js} +1 -1
- package/{alert-BrVkxOnA.cjs → alert-D6W48Ffr.cjs} +1 -1
- package/{common-CcQOJ_hf.cjs → common-BToNPUDq.cjs} +1 -1
- package/{common-CuZAeECD.js → common-BqUjUBPy.js} +1 -1
- package/components/accordion/index.cjs +1 -1
- package/components/accordion/index.js +1 -1
- package/components/alert/index.cjs +1 -1
- package/components/alert/index.js +1 -1
- package/components/carousel/carousel.d.ts +232 -0
- package/components/carousel/index.cjs +288 -0
- package/components/carousel/index.d.ts +1 -0
- package/components/carousel/index.js +288 -0
- package/components/modal/index.cjs +1 -1
- package/components/modal/index.js +1 -1
- package/components/pagination/index.cjs +1 -1
- package/components/pagination/index.js +1 -1
- package/components/progressbar/index.cjs +1 -1
- package/components/progressbar/index.js +1 -1
- package/components/rating/index.cjs +1 -1
- package/components/rating/index.js +1 -1
- package/components/select/index.js +1 -1
- package/components/slider/index.cjs +1 -1
- package/components/slider/index.js +1 -1
- package/components/toast/index.cjs +5 -3
- package/components/toast/index.d.ts +1 -0
- package/components/toast/index.js +3 -1
- package/components/toast/toaster.d.ts +128 -0
- package/components/tree/index.cjs +1 -1
- package/components/tree/index.js +1 -1
- package/config.d.ts +5 -0
- package/{dom-BB9jLllr.js → dom-gfxqXJpK.js} +1 -1
- package/index.cjs +15 -12
- package/index.js +21 -18
- package/{modal-BQcw6bnM.js → modal-CGK3h9pR.js} +3 -3
- package/{modal-B7bYoubx.cjs → modal-Dw1MuWPV.cjs} +1 -1
- package/package.json +4 -1
- package/{pagination-5YARuB3V.cjs → pagination-BzyKulaI.cjs} +1 -1
- package/{pagination-BwaZEokc.js → pagination-CRAKaOuh.js} +2 -2
- package/{progressbar-b_kXzGPc.js → progressbar-Csnqx_Pk.js} +2 -2
- package/{progressbar-BpSrg4HG.cjs → progressbar-D9rvrxXi.cjs} +1 -1
- package/{promise-CBh_HbSK.js → promise-XSP94FjG.js} +1 -1
- package/{rating-C8tn9xTO.cjs → rating-C4c8Paz-.cjs} +1 -1
- package/{rating-B1JLZgIR.js → rating-CvTnNxgN.js} +2 -2
- package/{select-Bb2RAVs0.js → select-C-77MJfC.js} +1 -1
- package/services/floatingUI.js +2 -2
- package/services/focustrack.js +1 -1
- package/services/matchMedia.js +1 -1
- package/services/navManager.js +1 -1
- package/services/portal.js +1 -1
- package/services/resizeObserver.js +1 -1
- package/services/siblingsInert.js +1 -1
- package/services/transitions/baseTransitions.cjs +1 -1
- package/services/transitions/baseTransitions.js +3 -3
- package/services/transitions/collapse.js +1 -1
- package/services/transitions/cssTransitions.js +2 -2
- package/services/transitions/simpleClassTransition.js +1 -1
- package/{slider-B2JFXDLt.cjs → slider-B0ZfAY0K.cjs} +200 -97
- package/{slider-C-BSdQ0b.js → slider-BF6a0eh_.js} +201 -98
- package/toaster-B2ibv38T.cjs +208 -0
- package/toaster-PwfLC7FH.js +209 -0
- package/{tree-DWv0zwFJ.js → tree-DUU_TWqy.js} +2 -2
- package/{tree-D4t2SOql.cjs → tree-Dwv2U0ea.cjs} +1 -1
- package/utils/directive.js +1 -1
- package/utils/stores.js +2 -2
- package/utils/writables.cjs +2 -1
- package/utils/writables.d.ts +7 -0
- package/utils/writables.js +7 -6
- package/{writables-BPAJvaL_.cjs → writables-Bn3uhKEG.cjs} +4 -0
- package/{writables-DCiBdIBK.js → writables-CgpOQ4hA.js} +10 -6
- package/toast-Bw2QSzBX.js +0 -64
- package/toast-CaIcB2sD.cjs +0 -63
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { writablesForProps, idWithDefault, stateStores, mergeConfigStores, normalizeConfigStores, true$ } from "./utils/stores.js";
|
|
2
2
|
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
3
|
-
import { writable, computed,
|
|
3
|
+
import { writable, computed, asWritable, readable } from "@amadeus-it-group/tansu";
|
|
4
4
|
import { noop } from "./utils/func.js";
|
|
5
|
-
import {
|
|
6
|
-
import { k as mergeDirectives, n as createAttributesDirective, r as registrationArray, d as directiveSubscribe } from "./dom-
|
|
5
|
+
import { e as typeString, g as typeFunction, c as typeBoolean } from "./writables-CgpOQ4hA.js";
|
|
6
|
+
import { k as mergeDirectives, n as createAttributesDirective, r as registrationArray, d as directiveSubscribe } from "./dom-gfxqXJpK.js";
|
|
7
7
|
function adjustItemsCloseOthers(items, openItems, oldOpen) {
|
|
8
8
|
let keepOpen;
|
|
9
9
|
if (openItems.length == 2) {
|
|
@@ -3,7 +3,7 @@ const utils_stores = require("./utils/stores.cjs");
|
|
|
3
3
|
const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
|
|
4
4
|
const tansu = require("@amadeus-it-group/tansu");
|
|
5
5
|
const utils_func = require("./utils/func.cjs");
|
|
6
|
-
const utils_writables = require("./writables-
|
|
6
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
7
7
|
const utils_directive = require("./dom-CuBx1JPZ.cjs");
|
|
8
8
|
function adjustItemsCloseOthers(items, openItems, oldOpen) {
|
|
9
9
|
let keepOpen;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as createCommonAlert, g as getCommonAlertDefaultConfig } from "./common-BqUjUBPy.js";
|
|
2
2
|
function getAlertDefaultConfig() {
|
|
3
3
|
return { ...getCommonAlertDefaultConfig() };
|
|
4
4
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const services_transitions_baseTransitions = require("./services/transitions/baseTransitions.cjs");
|
|
3
3
|
const utils_func = require("./utils/func.cjs");
|
|
4
4
|
const utils_stores = require("./utils/stores.cjs");
|
|
5
|
-
const utils_writables = require("./writables-
|
|
5
|
+
const utils_writables = require("./writables-Bn3uhKEG.cjs");
|
|
6
6
|
const defaultCommonAlertConfig = {
|
|
7
7
|
visible: true,
|
|
8
8
|
dismissible: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createTransition } from "./services/transitions/baseTransitions.js";
|
|
2
2
|
import { noop } from "./utils/func.js";
|
|
3
3
|
import { writablesForProps, stateStores } from "./utils/stores.js";
|
|
4
|
-
import {
|
|
4
|
+
import { e as typeString, c as typeBoolean, g as typeFunction } from "./writables-CgpOQ4hA.js";
|
|
5
5
|
const defaultCommonAlertConfig = {
|
|
6
6
|
visible: true,
|
|
7
7
|
dismissible: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const accordion = require("../../accordion-
|
|
3
|
+
const accordion = require("../../accordion-vfnqMstG.cjs");
|
|
4
4
|
exports.createAccordion = accordion.createAccordion;
|
|
5
5
|
exports.createAccordionItem = accordion.createAccordionItem;
|
|
6
6
|
exports.factoryCreateAccordion = accordion.factoryCreateAccordion;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const alert = require("../../alert-
|
|
3
|
+
const alert = require("../../alert-D6W48Ffr.cjs");
|
|
4
4
|
exports.createAlert = alert.createAlert;
|
|
5
5
|
exports.getAlertDefaultConfig = alert.getAlertDefaultConfig;
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import type { Directive, PropsConfig, Widget } from '../../types';
|
|
2
|
+
import type { EmblaCarouselType, EmblaPluginsType, EmblaPluginType } from 'embla-carousel';
|
|
3
|
+
import type { ReadableSignal } from '@amadeus-it-group/tansu';
|
|
4
|
+
/**
|
|
5
|
+
* Represents the Embla carousel options
|
|
6
|
+
*/
|
|
7
|
+
interface EmblaOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Align the slides relative to the carousel viewport
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://www.embla-carousel.com/api/options/#align}
|
|
12
|
+
* @defaultValue `'center'`
|
|
13
|
+
*/
|
|
14
|
+
align: 'start' | 'center' | 'end';
|
|
15
|
+
/**
|
|
16
|
+
* Enables choosing a custom container element which holds the slides. By default, Embla will choose the first direct child element of the root element. Provide a valid CSS selector string.
|
|
17
|
+
*
|
|
18
|
+
* @see {@link https://www.embla-carousel.com/api/options/#container}
|
|
19
|
+
*/
|
|
20
|
+
container: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Clear leading and trailing empty space that causes excessive scrolling
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://www.embla-carousel.com/api/options/#containScroll}
|
|
25
|
+
* @defaultValue `'trimSnaps'`
|
|
26
|
+
*/
|
|
27
|
+
containScroll: false | 'trimSnaps' | 'keepSnaps';
|
|
28
|
+
/**
|
|
29
|
+
* Choose content direction between `ltr` and `rtl`
|
|
30
|
+
*
|
|
31
|
+
* @see {@link https://www.embla-carousel.com/api/options/#direction}
|
|
32
|
+
* @defaultValue `'ltr'`
|
|
33
|
+
*/
|
|
34
|
+
direction: 'ltr' | 'rtl';
|
|
35
|
+
/**
|
|
36
|
+
* Enables momentum scrolling
|
|
37
|
+
*
|
|
38
|
+
* @see {@link https://www.embla-carousel.com/api/options/#dragFree}
|
|
39
|
+
* @defaultValue `false`
|
|
40
|
+
*/
|
|
41
|
+
dragFree: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Drag threshold in pixels
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://www.embla-carousel.com/api/options/#dragThreshold}
|
|
46
|
+
* @defaultValue `10`
|
|
47
|
+
*/
|
|
48
|
+
dragThreshold: number;
|
|
49
|
+
/**
|
|
50
|
+
* Set scroll duration when triggered by any of the API methods
|
|
51
|
+
*
|
|
52
|
+
* @see {@link https://www.embla-carousel.com/api/options/#duration}
|
|
53
|
+
* @defaultValue `25`
|
|
54
|
+
*/
|
|
55
|
+
duration: number;
|
|
56
|
+
/**
|
|
57
|
+
* Enables infinite looping
|
|
58
|
+
*
|
|
59
|
+
* @see {@link https://www.embla-carousel.com/api/options/#loop}
|
|
60
|
+
* @defaultValue `false`
|
|
61
|
+
*/
|
|
62
|
+
loop: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Allow the carousel to skip scroll snaps if it's dragged vigorously
|
|
65
|
+
*
|
|
66
|
+
* @see {@link https://www.embla-carousel.com/api/options/#skipsnaps}
|
|
67
|
+
* @defaultValue `false`
|
|
68
|
+
*/
|
|
69
|
+
skipSnaps: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface CarouselCommonPropsState extends Pick<EmblaOptions, 'direction'> {
|
|
72
|
+
/**
|
|
73
|
+
* If `true`, 'previous' and 'next' navigation arrows will be visible.
|
|
74
|
+
*/
|
|
75
|
+
showNavigationArrows: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* If `true`, navigation indicators at the bottom of the slide will be visible.
|
|
78
|
+
*/
|
|
79
|
+
showNavigationIndicators: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Represents the properties for the carousel component.
|
|
83
|
+
*/
|
|
84
|
+
export interface CarouselProps extends EmblaOptions, CarouselCommonPropsState {
|
|
85
|
+
/**
|
|
86
|
+
* Plugins to extend the carousel with additional features
|
|
87
|
+
* @defaultValue `[]`
|
|
88
|
+
*/
|
|
89
|
+
plugins: EmblaPluginType[];
|
|
90
|
+
/**
|
|
91
|
+
* Aria label for navigation indicators
|
|
92
|
+
*/
|
|
93
|
+
ariaIndicatorLabel: (index: number) => string;
|
|
94
|
+
/**
|
|
95
|
+
* Aria label for previous button
|
|
96
|
+
*/
|
|
97
|
+
ariaPrevLabel: string;
|
|
98
|
+
/**
|
|
99
|
+
* Aria label for next button
|
|
100
|
+
*/
|
|
101
|
+
ariaNextLabel: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Represents the state of a carousel component.
|
|
105
|
+
*/
|
|
106
|
+
export interface CarouselState extends CarouselCommonPropsState {
|
|
107
|
+
/**
|
|
108
|
+
* is the carousel currently scrolling
|
|
109
|
+
*/
|
|
110
|
+
scrolling: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* can carousel scroll to previous slide
|
|
113
|
+
*/
|
|
114
|
+
canScrollPrev: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* can carousel scroll to next slide
|
|
117
|
+
*/
|
|
118
|
+
canScrollNext: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* selected scroll snap
|
|
121
|
+
*/
|
|
122
|
+
selectedScrollSnap: number;
|
|
123
|
+
/**
|
|
124
|
+
* is the carousel initialized
|
|
125
|
+
*/
|
|
126
|
+
initialized: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Represents the API for a carousel component.
|
|
130
|
+
*/
|
|
131
|
+
export interface CarouselApi {
|
|
132
|
+
/**
|
|
133
|
+
* Scroll to the previous snap point if possible.
|
|
134
|
+
* @param jump - scroll instantly
|
|
135
|
+
*/
|
|
136
|
+
scrollPrev: (jump?: boolean) => void;
|
|
137
|
+
/**
|
|
138
|
+
* Scroll to the next snap point if possible.
|
|
139
|
+
* @param jump - scroll instantly
|
|
140
|
+
*/
|
|
141
|
+
scrollNext: (jump?: boolean) => void;
|
|
142
|
+
/**
|
|
143
|
+
* Scroll to a snap point by index
|
|
144
|
+
* @param index - the snap point index
|
|
145
|
+
* @param jump - scroll instantly
|
|
146
|
+
*/
|
|
147
|
+
scrollTo: (index: number, jump?: boolean) => void;
|
|
148
|
+
/**
|
|
149
|
+
* Retrieve the enabled plugins
|
|
150
|
+
*/
|
|
151
|
+
plugins: () => EmblaPluginsType | undefined;
|
|
152
|
+
/**
|
|
153
|
+
* Retrieve the inner EmblaApi object
|
|
154
|
+
*/
|
|
155
|
+
emblaApi: () => EmblaCarouselType | undefined;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Represents the directives for a carousel component.
|
|
159
|
+
*/
|
|
160
|
+
export interface CarouselDirectives {
|
|
161
|
+
/**
|
|
162
|
+
* the root directive
|
|
163
|
+
*/
|
|
164
|
+
root: Directive;
|
|
165
|
+
/**
|
|
166
|
+
* A directive to be applied to a navigation button allowing to scroll to the previous slide.
|
|
167
|
+
*/
|
|
168
|
+
scrollPrev: Directive;
|
|
169
|
+
/**
|
|
170
|
+
* A directive to be applied to a navigation button allowing to scroll to the next slide.
|
|
171
|
+
*/
|
|
172
|
+
scrollNext: Directive;
|
|
173
|
+
/**
|
|
174
|
+
* A directive to be applied to each slide in the carousel.
|
|
175
|
+
*/
|
|
176
|
+
slide: Directive<{
|
|
177
|
+
id: string;
|
|
178
|
+
index: number;
|
|
179
|
+
}>;
|
|
180
|
+
/**
|
|
181
|
+
* A directive to be applied to a tab list allowing to navigate to the corresponding slide.
|
|
182
|
+
* This directive adds the role `tablist` and is recommended to be used together with {@link tabIndicator}.
|
|
183
|
+
*/
|
|
184
|
+
tabList: Directive;
|
|
185
|
+
/**
|
|
186
|
+
* A directive to be applied to a navigation indicator allowing to scroll to the corresponding slide.
|
|
187
|
+
* As this directive adds the role `tab` to the element, it is recommended to use it on a button or a link and the parent element should have the {@link tabList} directive attached.
|
|
188
|
+
*/
|
|
189
|
+
tabIndicator: Directive<{
|
|
190
|
+
index: number;
|
|
191
|
+
id: string;
|
|
192
|
+
jump?: boolean;
|
|
193
|
+
}>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Represents a carousel widget with specific properties, state, API, and directives.
|
|
197
|
+
*/
|
|
198
|
+
export type CarouselWidget = Widget<CarouselProps, CarouselState, CarouselApi, CarouselDirectives>;
|
|
199
|
+
/**
|
|
200
|
+
* Retrieve a shallow copy of the default Carousel config
|
|
201
|
+
* @returns the default Carousel config
|
|
202
|
+
*/
|
|
203
|
+
export declare function getCarouselDefaultConfig(): CarouselProps;
|
|
204
|
+
/**
|
|
205
|
+
* An Embla Carousel widget factory.
|
|
206
|
+
*
|
|
207
|
+
* @internal
|
|
208
|
+
* @param options$ - the store of Embla options
|
|
209
|
+
* @param plugins$ - the store of Embla plugins
|
|
210
|
+
* @returns the Embla carousel widget
|
|
211
|
+
*/
|
|
212
|
+
export declare function createEmblaCarousel(options$: ReadableSignal<Partial<EmblaOptions>>, plugins$?: ReadableSignal<EmblaPluginType[]>): {
|
|
213
|
+
directive: Directive;
|
|
214
|
+
stores: {
|
|
215
|
+
scrolling$: ReadableSignal<boolean>;
|
|
216
|
+
canScrollPrev$: ReadableSignal<boolean>;
|
|
217
|
+
canScrollNext$: ReadableSignal<boolean>;
|
|
218
|
+
selectedScrollSnap$: ReadableSignal<number>;
|
|
219
|
+
initialized$: ReadableSignal<boolean>;
|
|
220
|
+
slideNodes$: ReadableSignal<HTMLElement[]>;
|
|
221
|
+
};
|
|
222
|
+
api: EmblaCarouselType | undefined;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Create an CarouselWidget with given config props
|
|
226
|
+
*
|
|
227
|
+
* @template SlideData - The type of data used by each slide in the carousel.
|
|
228
|
+
* @param config - an optional carousel config
|
|
229
|
+
* @returns a CarouselWidget
|
|
230
|
+
*/
|
|
231
|
+
export declare function createCarousel(config?: PropsConfig<CarouselProps>): CarouselWidget;
|
|
232
|
+
export {};
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const utils_stores = require("../../utils/stores.cjs");
|
|
4
|
+
const utils_directive = require("../../dom-CuBx1JPZ.cjs");
|
|
5
|
+
const EmblaCarousel = require("embla-carousel");
|
|
6
|
+
const tansu = require("@amadeus-it-group/tansu");
|
|
7
|
+
const utils_writables = require("../../writables-Bn3uhKEG.cjs");
|
|
8
|
+
const services_navManager = require("../../services/navManager.cjs");
|
|
9
|
+
const defaultConfig = {
|
|
10
|
+
align: "center",
|
|
11
|
+
container: null,
|
|
12
|
+
containScroll: "trimSnaps",
|
|
13
|
+
direction: "ltr",
|
|
14
|
+
dragFree: false,
|
|
15
|
+
dragThreshold: 10,
|
|
16
|
+
duration: 25,
|
|
17
|
+
loop: false,
|
|
18
|
+
skipSnaps: false,
|
|
19
|
+
plugins: [],
|
|
20
|
+
showNavigationArrows: true,
|
|
21
|
+
showNavigationIndicators: true,
|
|
22
|
+
ariaPrevLabel: "Select previous slide",
|
|
23
|
+
ariaNextLabel: "Select next slide",
|
|
24
|
+
ariaIndicatorLabel: (index) => `Select slide ${index + 1}`
|
|
25
|
+
};
|
|
26
|
+
function getCarouselDefaultConfig() {
|
|
27
|
+
return { ...defaultConfig };
|
|
28
|
+
}
|
|
29
|
+
const configValidator = {
|
|
30
|
+
dragFree: utils_writables.typeBoolean,
|
|
31
|
+
plugins: utils_writables.typeArray,
|
|
32
|
+
align: utils_writables.createTypeEnum(["start", "center", "end"]),
|
|
33
|
+
container: utils_writables.typeStringOrNull,
|
|
34
|
+
containScroll: utils_writables.createTypeEnum([false, "trimSnaps", "keepSnaps"]),
|
|
35
|
+
direction: utils_writables.createTypeEnum(["ltr", "rtl"]),
|
|
36
|
+
dragThreshold: utils_writables.typeNumber,
|
|
37
|
+
duration: utils_writables.typeNumber,
|
|
38
|
+
loop: utils_writables.typeBoolean,
|
|
39
|
+
skipSnaps: utils_writables.typeBoolean,
|
|
40
|
+
showNavigationArrows: utils_writables.typeBoolean,
|
|
41
|
+
showNavigationIndicators: utils_writables.typeBoolean,
|
|
42
|
+
ariaPrevLabel: utils_writables.typeString,
|
|
43
|
+
ariaNextLabel: utils_writables.typeString,
|
|
44
|
+
ariaIndicatorLabel: utils_writables.typeFunction
|
|
45
|
+
};
|
|
46
|
+
function createEmblaCarousel(options$, plugins$) {
|
|
47
|
+
let emblaApi;
|
|
48
|
+
const scrolling$ = tansu.writable(false);
|
|
49
|
+
const canScrollPrev$ = tansu.writable(false);
|
|
50
|
+
const canScrollNext$ = tansu.writable(true);
|
|
51
|
+
const selectedScrollSnap$ = tansu.writable(0);
|
|
52
|
+
const initialized$ = tansu.writable(false);
|
|
53
|
+
const slideNodes$ = tansu.writable([]);
|
|
54
|
+
const directiveArgs$ = tansu.computed(() => ({
|
|
55
|
+
options: options$(),
|
|
56
|
+
plugins: plugins$ ? plugins$() : []
|
|
57
|
+
}));
|
|
58
|
+
return {
|
|
59
|
+
directive: utils_directive.bindDirective(
|
|
60
|
+
utils_directive.browserDirective((element, { options, plugins }) => {
|
|
61
|
+
if (emblaApi) {
|
|
62
|
+
throw new Error("Only one Embla directive can be attached per carousel widget !");
|
|
63
|
+
}
|
|
64
|
+
emblaApi = EmblaCarousel(element, options, plugins);
|
|
65
|
+
emblaApi.on("scroll", () => {
|
|
66
|
+
scrolling$.set(true);
|
|
67
|
+
});
|
|
68
|
+
emblaApi.on("settle", () => {
|
|
69
|
+
scrolling$.set(false);
|
|
70
|
+
});
|
|
71
|
+
emblaApi.on("select", (api) => {
|
|
72
|
+
canScrollNext$.set(api.canScrollNext());
|
|
73
|
+
canScrollPrev$.set(api.canScrollPrev());
|
|
74
|
+
selectedScrollSnap$.set(api.selectedScrollSnap());
|
|
75
|
+
});
|
|
76
|
+
emblaApi.on("init", () => {
|
|
77
|
+
initialized$.set(true);
|
|
78
|
+
});
|
|
79
|
+
emblaApi.on("reInit", (api) => {
|
|
80
|
+
canScrollNext$.set(api.canScrollNext());
|
|
81
|
+
canScrollPrev$.set(api.canScrollPrev());
|
|
82
|
+
scrolling$.set(false);
|
|
83
|
+
selectedScrollSnap$.set(api.selectedScrollSnap());
|
|
84
|
+
});
|
|
85
|
+
emblaApi.on("slidesChanged", (api) => {
|
|
86
|
+
slideNodes$.set(api.slideNodes());
|
|
87
|
+
});
|
|
88
|
+
canScrollNext$.set(emblaApi.canScrollNext());
|
|
89
|
+
canScrollPrev$.set(emblaApi.canScrollPrev());
|
|
90
|
+
slideNodes$.set(emblaApi.slideNodes());
|
|
91
|
+
return {
|
|
92
|
+
update: ({ options: options2, plugins: plugins2 }) => {
|
|
93
|
+
emblaApi.reInit(options2, plugins2);
|
|
94
|
+
},
|
|
95
|
+
destroy: () => {
|
|
96
|
+
emblaApi == null ? void 0 : emblaApi.destroy();
|
|
97
|
+
emblaApi = void 0;
|
|
98
|
+
initialized$.set(false);
|
|
99
|
+
scrolling$.set(false);
|
|
100
|
+
canScrollPrev$.set(false);
|
|
101
|
+
canScrollNext$.set(true);
|
|
102
|
+
selectedScrollSnap$.set(0);
|
|
103
|
+
slideNodes$.set([]);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}),
|
|
107
|
+
directiveArgs$
|
|
108
|
+
),
|
|
109
|
+
stores: {
|
|
110
|
+
scrolling$: tansu.asReadable(scrolling$),
|
|
111
|
+
canScrollPrev$: tansu.asReadable(canScrollPrev$),
|
|
112
|
+
canScrollNext$: tansu.asReadable(canScrollNext$),
|
|
113
|
+
selectedScrollSnap$: tansu.asReadable(selectedScrollSnap$),
|
|
114
|
+
initialized$: tansu.asReadable(initialized$),
|
|
115
|
+
slideNodes$: tansu.asReadable(slideNodes$)
|
|
116
|
+
},
|
|
117
|
+
get api() {
|
|
118
|
+
return emblaApi;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function createCarousel(config) {
|
|
123
|
+
const [
|
|
124
|
+
{
|
|
125
|
+
align$,
|
|
126
|
+
container$,
|
|
127
|
+
containScroll$,
|
|
128
|
+
direction$,
|
|
129
|
+
dragFree$,
|
|
130
|
+
dragThreshold$,
|
|
131
|
+
duration$,
|
|
132
|
+
loop$,
|
|
133
|
+
skipSnaps$,
|
|
134
|
+
plugins$,
|
|
135
|
+
ariaPrevLabel$,
|
|
136
|
+
ariaNextLabel$,
|
|
137
|
+
ariaIndicatorLabel$,
|
|
138
|
+
showNavigationIndicators$,
|
|
139
|
+
...stateProps
|
|
140
|
+
},
|
|
141
|
+
patch
|
|
142
|
+
] = utils_stores.writablesForProps(defaultConfig, config, configValidator);
|
|
143
|
+
const emblaOptions$ = tansu.computed(() => ({
|
|
144
|
+
align: align$(),
|
|
145
|
+
container: container$(),
|
|
146
|
+
containScroll: containScroll$(),
|
|
147
|
+
direction: direction$(),
|
|
148
|
+
dragFree: dragFree$(),
|
|
149
|
+
dragThreshold: dragThreshold$(),
|
|
150
|
+
duration: duration$(),
|
|
151
|
+
loop: loop$(),
|
|
152
|
+
skipSnaps: skipSnaps$()
|
|
153
|
+
}));
|
|
154
|
+
const emblaCarousel = createEmblaCarousel(emblaOptions$, plugins$);
|
|
155
|
+
const {
|
|
156
|
+
stores: { slideNodes$, ...emblaStores }
|
|
157
|
+
} = emblaCarousel;
|
|
158
|
+
const { directive: navDirective, refreshElements, focusPrevious, focusNext, focusFirst, focusLast } = services_navManager.createNavManager();
|
|
159
|
+
const navManagerConfig = {
|
|
160
|
+
keys: {
|
|
161
|
+
ArrowLeft: focusPrevious,
|
|
162
|
+
ArrowRight: focusNext,
|
|
163
|
+
Home: focusFirst,
|
|
164
|
+
End: focusLast
|
|
165
|
+
},
|
|
166
|
+
selector: (node) => node.querySelectorAll("[role='tab']")
|
|
167
|
+
};
|
|
168
|
+
return {
|
|
169
|
+
...utils_stores.stateStores({
|
|
170
|
+
...emblaStores,
|
|
171
|
+
...stateProps,
|
|
172
|
+
direction$,
|
|
173
|
+
showNavigationIndicators$
|
|
174
|
+
}),
|
|
175
|
+
patch,
|
|
176
|
+
api: {
|
|
177
|
+
scrollPrev: (jump) => {
|
|
178
|
+
var _a, _b;
|
|
179
|
+
(_b = (_a = emblaCarousel.api) == null ? void 0 : _a.scrollPrev) == null ? void 0 : _b.call(_a, jump);
|
|
180
|
+
},
|
|
181
|
+
scrollNext: (jump) => {
|
|
182
|
+
var _a, _b;
|
|
183
|
+
(_b = (_a = emblaCarousel.api) == null ? void 0 : _a.scrollNext) == null ? void 0 : _b.call(_a, jump);
|
|
184
|
+
},
|
|
185
|
+
scrollTo: (index, jump) => {
|
|
186
|
+
var _a, _b;
|
|
187
|
+
(_b = (_a = emblaCarousel.api) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, index, jump);
|
|
188
|
+
},
|
|
189
|
+
plugins: () => {
|
|
190
|
+
var _a, _b;
|
|
191
|
+
return (_b = (_a = emblaCarousel.api) == null ? void 0 : _a.plugins) == null ? void 0 : _b.call(_a);
|
|
192
|
+
},
|
|
193
|
+
emblaApi: () => emblaCarousel.api
|
|
194
|
+
},
|
|
195
|
+
directives: {
|
|
196
|
+
root: utils_directive.mergeDirectives(
|
|
197
|
+
emblaCarousel.directive,
|
|
198
|
+
utils_directive.createAttributesDirective(() => ({
|
|
199
|
+
classNames: {
|
|
200
|
+
"au-carousel": utils_stores.true$
|
|
201
|
+
},
|
|
202
|
+
attributes: {
|
|
203
|
+
role: tansu.readable("region"),
|
|
204
|
+
"aria-roledescription": tansu.readable("carousel"),
|
|
205
|
+
dir: direction$
|
|
206
|
+
}
|
|
207
|
+
}))
|
|
208
|
+
),
|
|
209
|
+
scrollPrev: utils_directive.createAttributesDirective(() => ({
|
|
210
|
+
attributes: {
|
|
211
|
+
"aria-label": ariaPrevLabel$,
|
|
212
|
+
disabled: tansu.computed(() => !emblaCarousel.stores.canScrollPrev$() || void 0)
|
|
213
|
+
},
|
|
214
|
+
events: {
|
|
215
|
+
click: () => {
|
|
216
|
+
var _a;
|
|
217
|
+
return (_a = emblaCarousel.api) == null ? void 0 : _a.scrollPrev();
|
|
218
|
+
},
|
|
219
|
+
pointerdown: (event) => event.preventDefault(),
|
|
220
|
+
touchstart: (event) => event.stopPropagation()
|
|
221
|
+
}
|
|
222
|
+
})),
|
|
223
|
+
scrollNext: utils_directive.createAttributesDirective(() => ({
|
|
224
|
+
attributes: {
|
|
225
|
+
"aria-label": ariaNextLabel$,
|
|
226
|
+
disabled: tansu.computed(() => !emblaCarousel.stores.canScrollNext$() || void 0)
|
|
227
|
+
},
|
|
228
|
+
events: {
|
|
229
|
+
click: () => {
|
|
230
|
+
var _a;
|
|
231
|
+
return (_a = emblaCarousel.api) == null ? void 0 : _a.scrollNext();
|
|
232
|
+
},
|
|
233
|
+
pointerdown: (event) => event.preventDefault(),
|
|
234
|
+
touchstart: (event) => event.stopPropagation()
|
|
235
|
+
}
|
|
236
|
+
})),
|
|
237
|
+
tabList: utils_directive.mergeDirectives(
|
|
238
|
+
utils_directive.bindDirective(navDirective, tansu.readable(navManagerConfig)),
|
|
239
|
+
utils_directive.browserDirective(() => {
|
|
240
|
+
const unsubscribe = slideNodes$.subscribe(() => {
|
|
241
|
+
refreshElements();
|
|
242
|
+
});
|
|
243
|
+
return {
|
|
244
|
+
destroy: unsubscribe
|
|
245
|
+
};
|
|
246
|
+
}),
|
|
247
|
+
utils_directive.createAttributesDirective(() => ({
|
|
248
|
+
attributes: {
|
|
249
|
+
role: tansu.readable("tablist")
|
|
250
|
+
}
|
|
251
|
+
}))
|
|
252
|
+
),
|
|
253
|
+
tabIndicator: utils_directive.createAttributesDirective((slide$) => ({
|
|
254
|
+
events: {
|
|
255
|
+
click: () => {
|
|
256
|
+
var _a;
|
|
257
|
+
(_a = emblaCarousel.api) == null ? void 0 : _a.scrollTo(slide$().index, slide$().jump ?? true);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
attributes: {
|
|
261
|
+
"aria-label": tansu.computed(() => ariaIndicatorLabel$()(slide$().index)),
|
|
262
|
+
"aria-selected": tansu.computed(() => slide$().index === emblaCarousel.stores.selectedScrollSnap$() ? "true" : void 0),
|
|
263
|
+
"aria-controls": tansu.computed(() => slide$().id),
|
|
264
|
+
role: tansu.readable("tab"),
|
|
265
|
+
tabindex: tansu.computed(() => slide$().index === emblaCarousel.stores.selectedScrollSnap$() ? "0" : "-1")
|
|
266
|
+
}
|
|
267
|
+
})),
|
|
268
|
+
slide: utils_directive.createAttributesDirective((slide$) => {
|
|
269
|
+
const selected$ = tansu.computed(() => slide$().index === emblaCarousel.stores.selectedScrollSnap$());
|
|
270
|
+
return {
|
|
271
|
+
attributes: {
|
|
272
|
+
id: tansu.computed(() => slide$().id),
|
|
273
|
+
"aria-hidden": tansu.computed(() => selected$() ? void 0 : "true"),
|
|
274
|
+
role: tansu.computed(() => showNavigationIndicators$() ? "tabpanel" : "group"),
|
|
275
|
+
"aria-roledescription": tansu.computed(() => showNavigationIndicators$() ? void 0 : "slide"),
|
|
276
|
+
tabindex: tansu.computed(() => showNavigationIndicators$() && selected$() ? "0" : void 0)
|
|
277
|
+
},
|
|
278
|
+
classNames: {
|
|
279
|
+
"au-carousel-slide": utils_stores.true$
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
exports.createCarousel = createCarousel;
|
|
287
|
+
exports.createEmblaCarousel = createEmblaCarousel;
|
|
288
|
+
exports.getCarouselDefaultConfig = getCarouselDefaultConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './carousel';
|