@design-factory/core 21.1.0-next.1

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 (176) hide show
  1. package/README.md +3 -0
  2. package/accordion-B0vs8JWM.cjs +314 -0
  3. package/accordion-D9ba0XYq.js +315 -0
  4. package/alert-AhaliJ17.cjs +9 -0
  5. package/alert-Cb9FhbFQ.js +10 -0
  6. package/collapse-Bn8iHKrd.js +95 -0
  7. package/collapse-BnWw4Hnc.cjs +94 -0
  8. package/common-B5jS-Ih_.cjs +73 -0
  9. package/common-DFyZvkII.js +74 -0
  10. package/components/accordion/accordion.d.ts +333 -0
  11. package/components/accordion/index.cjs +7 -0
  12. package/components/accordion/index.d.ts +1 -0
  13. package/components/accordion/index.js +7 -0
  14. package/components/alert/alert.d.ts +37 -0
  15. package/components/alert/common.d.ts +138 -0
  16. package/components/alert/index.cjs +5 -0
  17. package/components/alert/index.d.ts +1 -0
  18. package/components/alert/index.js +5 -0
  19. package/components/carousel/carousel.d.ts +247 -0
  20. package/components/carousel/index.cjs +292 -0
  21. package/components/carousel/index.d.ts +1 -0
  22. package/components/carousel/index.js +292 -0
  23. package/components/collapse/collapse.d.ts +135 -0
  24. package/components/collapse/index.cjs +5 -0
  25. package/components/collapse/index.d.ts +1 -0
  26. package/components/collapse/index.js +5 -0
  27. package/components/commonProps.d.ts +11 -0
  28. package/components/drawer/drawer.d.ts +279 -0
  29. package/components/drawer/index.cjs +5 -0
  30. package/components/drawer/index.d.ts +1 -0
  31. package/components/drawer/index.js +5 -0
  32. package/components/modal/index.cjs +8 -0
  33. package/components/modal/index.d.ts +1 -0
  34. package/components/modal/index.js +8 -0
  35. package/components/modal/modal.d.ts +245 -0
  36. package/components/pagination/index.cjs +5 -0
  37. package/components/pagination/index.d.ts +1 -0
  38. package/components/pagination/index.js +5 -0
  39. package/components/pagination/pagination.d.ts +313 -0
  40. package/components/progressbar/index.cjs +5 -0
  41. package/components/progressbar/index.d.ts +1 -0
  42. package/components/progressbar/index.js +5 -0
  43. package/components/progressbar/progressbar.d.ts +91 -0
  44. package/components/rating/index.cjs +5 -0
  45. package/components/rating/index.d.ts +1 -0
  46. package/components/rating/index.js +5 -0
  47. package/components/rating/rating.d.ts +191 -0
  48. package/components/slider/index.cjs +5 -0
  49. package/components/slider/index.d.ts +1 -0
  50. package/components/slider/index.js +5 -0
  51. package/components/slider/slider-utils.d.ts +25 -0
  52. package/components/slider/slider.d.ts +383 -0
  53. package/components/toast/index.cjs +7 -0
  54. package/components/toast/index.d.ts +2 -0
  55. package/components/toast/index.js +7 -0
  56. package/components/toast/toast.d.ts +66 -0
  57. package/components/toast/toaster.d.ts +128 -0
  58. package/components/tree/index.cjs +5 -0
  59. package/components/tree/index.d.ts +1 -0
  60. package/components/tree/index.js +5 -0
  61. package/components/tree/tree.d.ts +143 -0
  62. package/config.cjs +36 -0
  63. package/config.d.ts +117 -0
  64. package/config.js +36 -0
  65. package/directive-CNNSo5Yn.js +524 -0
  66. package/directive-DyTodNPd.cjs +523 -0
  67. package/drawer-BIIfJa0F.js +329 -0
  68. package/drawer-C8ojtwIn.cjs +328 -0
  69. package/index.cjs +134 -0
  70. package/index.d.ts +29 -0
  71. package/index.js +134 -0
  72. package/isFocusable-Ckwus82R.js +32 -0
  73. package/isFocusable-DfzDLeAN.cjs +31 -0
  74. package/modal-C13G13jV.js +253 -0
  75. package/modal-DWv0VqiG.cjs +252 -0
  76. package/package.json +56 -0
  77. package/pagination-BLVa1UsZ.cjs +254 -0
  78. package/pagination-BQWusWXN.js +255 -0
  79. package/progressbar-RopgvVeA.cjs +86 -0
  80. package/progressbar-S1pNn5rM.js +87 -0
  81. package/promise-CxCD3NYv.cjs +118 -0
  82. package/promise-D-RZVPuv.js +119 -0
  83. package/rating-DWgGgwk3.js +184 -0
  84. package/rating-DZ3OQgtt.cjs +183 -0
  85. package/scrollbars-CT87iv_6.cjs +30 -0
  86. package/scrollbars-CcxSrnCx.js +31 -0
  87. package/services/extendWidget.cjs +41 -0
  88. package/services/extendWidget.d.ts +31 -0
  89. package/services/extendWidget.js +41 -0
  90. package/services/floatingUI.cjs +111 -0
  91. package/services/floatingUI.d.ts +76 -0
  92. package/services/floatingUI.js +111 -0
  93. package/services/focusElement.cjs +46 -0
  94. package/services/focusElement.d.ts +9 -0
  95. package/services/focusElement.js +46 -0
  96. package/services/focustrack.cjs +47 -0
  97. package/services/focustrack.d.ts +40 -0
  98. package/services/focustrack.js +47 -0
  99. package/services/hash.cjs +15 -0
  100. package/services/hash.d.ts +3 -0
  101. package/services/hash.js +15 -0
  102. package/services/intersection.cjs +53 -0
  103. package/services/intersection.d.ts +30 -0
  104. package/services/intersection.js +53 -0
  105. package/services/matchMedia.cjs +14 -0
  106. package/services/matchMedia.d.ts +8 -0
  107. package/services/matchMedia.js +14 -0
  108. package/services/navManager.cjs +166 -0
  109. package/services/navManager.d.ts +144 -0
  110. package/services/navManager.js +166 -0
  111. package/services/pointerdownPosition.cjs +60 -0
  112. package/services/pointerdownPosition.d.ts +42 -0
  113. package/services/pointerdownPosition.js +60 -0
  114. package/services/portal.cjs +42 -0
  115. package/services/portal.d.ts +16 -0
  116. package/services/portal.js +42 -0
  117. package/services/resizeObserver.cjs +54 -0
  118. package/services/resizeObserver.d.ts +18 -0
  119. package/services/resizeObserver.js +54 -0
  120. package/services/siblingsInert.cjs +44 -0
  121. package/services/siblingsInert.d.ts +16 -0
  122. package/services/siblingsInert.js +44 -0
  123. package/services/transitions/baseTransitions.cjs +186 -0
  124. package/services/transitions/baseTransitions.d.ts +166 -0
  125. package/services/transitions/baseTransitions.js +186 -0
  126. package/services/transitions/collapse.cjs +40 -0
  127. package/services/transitions/collapse.d.ts +49 -0
  128. package/services/transitions/collapse.js +40 -0
  129. package/services/transitions/cssTransitions.cjs +32 -0
  130. package/services/transitions/cssTransitions.d.ts +25 -0
  131. package/services/transitions/cssTransitions.js +32 -0
  132. package/services/transitions/simpleClassTransition.cjs +37 -0
  133. package/services/transitions/simpleClassTransition.d.ts +47 -0
  134. package/services/transitions/simpleClassTransition.js +37 -0
  135. package/slider-Br_Qiopx.js +808 -0
  136. package/slider-pgDq1V5r.cjs +807 -0
  137. package/textDirection-cNgt24LJ.js +4 -0
  138. package/textDirection-zqcZ5-eK.cjs +3 -0
  139. package/toaster-BUBzFeJM.js +162 -0
  140. package/toaster-Dlube4Ya.cjs +161 -0
  141. package/tree-Chcy4ulJ.cjs +228 -0
  142. package/tree-vD7ZkV8Z.js +229 -0
  143. package/types.cjs +6 -0
  144. package/types.d.ts +246 -0
  145. package/types.js +6 -0
  146. package/utils/directive.cjs +28 -0
  147. package/utils/directive.d.ts +352 -0
  148. package/utils/directive.js +28 -0
  149. package/utils/func.cjs +7 -0
  150. package/utils/func.d.ts +11 -0
  151. package/utils/func.js +7 -0
  152. package/utils/id.cjs +5 -0
  153. package/utils/id.d.ts +6 -0
  154. package/utils/id.js +5 -0
  155. package/utils/internal/assign.d.ts +10 -0
  156. package/utils/internal/checks.d.ts +57 -0
  157. package/utils/internal/dom.d.ts +75 -0
  158. package/utils/internal/isFocusable.d.ts +9 -0
  159. package/utils/internal/math.d.ts +5 -0
  160. package/utils/internal/promise.d.ts +98 -0
  161. package/utils/internal/scrollbars.d.ts +8 -0
  162. package/utils/internal/sort.d.ts +16 -0
  163. package/utils/internal/ssrHTMLElement.d.ts +17 -0
  164. package/utils/internal/textDirection.d.ts +7 -0
  165. package/utils/internal/traversal.d.ts +54 -0
  166. package/utils/stores.cjs +172 -0
  167. package/utils/stores.d.ts +224 -0
  168. package/utils/stores.js +172 -0
  169. package/utils/widget.cjs +8 -0
  170. package/utils/widget.d.ts +11 -0
  171. package/utils/widget.js +8 -0
  172. package/utils/writables.cjs +16 -0
  173. package/utils/writables.d.ts +95 -0
  174. package/utils/writables.js +16 -0
  175. package/writables-DYGjj5T3.js +103 -0
  176. package/writables-Dt68gADJ.cjs +102 -0
@@ -0,0 +1,292 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const utils_stores = require("../../utils/stores.cjs");
4
+ const utils_directive = require("../../directive-DyTodNPd.cjs");
5
+ const EmblaCarousel = require("embla-carousel");
6
+ const tansu = require("@amadeus-it-group/tansu");
7
+ const utils_writables = require("../../writables-Dt68gADJ.cjs");
8
+ const services_navManager = require("../../services/navManager.cjs");
9
+ const utils_widget = require("../../utils/widget.cjs");
10
+ const defaultConfig = {
11
+ align: "center",
12
+ container: null,
13
+ containScroll: "trimSnaps",
14
+ direction: "ltr",
15
+ dragFree: false,
16
+ dragThreshold: 10,
17
+ duration: 25,
18
+ loop: false,
19
+ skipSnaps: false,
20
+ plugins: [],
21
+ showNavigationArrows: true,
22
+ showNavigationIndicators: true,
23
+ ariaPrevLabel: "Select previous slide",
24
+ ariaNextLabel: "Select next slide",
25
+ ariaIndicatorLabel: (index) => `Select slide ${index + 1}`
26
+ };
27
+ function getCarouselDefaultConfig() {
28
+ return { ...defaultConfig };
29
+ }
30
+ const configValidator = {
31
+ dragFree: utils_writables.typeBoolean,
32
+ plugins: utils_writables.typeArray,
33
+ align: utils_writables.createTypeEnum(["start", "center", "end"]),
34
+ container: utils_writables.typeStringOrNull,
35
+ containScroll: utils_writables.createTypeEnum([false, "trimSnaps", "keepSnaps"]),
36
+ direction: utils_writables.createTypeEnum(["ltr", "rtl"]),
37
+ dragThreshold: utils_writables.typeNumber,
38
+ duration: utils_writables.typeNumber,
39
+ loop: utils_writables.typeBoolean,
40
+ skipSnaps: utils_writables.typeBoolean,
41
+ showNavigationArrows: utils_writables.typeBoolean,
42
+ showNavigationIndicators: utils_writables.typeBoolean,
43
+ ariaPrevLabel: utils_writables.typeString,
44
+ ariaNextLabel: utils_writables.typeString,
45
+ ariaIndicatorLabel: utils_writables.typeFunction
46
+ };
47
+ function createEmblaCarousel(options$, plugins$) {
48
+ let emblaApi;
49
+ const scrolling$ = tansu.writable(false);
50
+ const canScrollPrev$ = tansu.writable(false);
51
+ const canScrollNext$ = tansu.writable(true);
52
+ const selectedScrollSnap$ = tansu.writable(0);
53
+ const initialized$ = tansu.writable(false);
54
+ const slideNodes$ = tansu.writable([]);
55
+ const directiveArgs$ = tansu.computed(() => ({
56
+ options: options$(),
57
+ plugins: plugins$ ? plugins$() : []
58
+ }));
59
+ return {
60
+ directive: utils_directive.bindDirective(
61
+ utils_directive.browserDirective(
62
+ (element, { options, plugins }) => {
63
+ if (emblaApi) {
64
+ throw new Error("Only one Embla directive can be attached per carousel widget !");
65
+ }
66
+ emblaApi = EmblaCarousel(element, options, plugins);
67
+ emblaApi.on("scroll", () => {
68
+ scrolling$.set(true);
69
+ });
70
+ emblaApi.on("settle", () => {
71
+ scrolling$.set(false);
72
+ });
73
+ emblaApi.on("select", (api) => {
74
+ canScrollNext$.set(api.canScrollNext());
75
+ canScrollPrev$.set(api.canScrollPrev());
76
+ selectedScrollSnap$.set(api.selectedScrollSnap());
77
+ });
78
+ emblaApi.on("init", () => {
79
+ initialized$.set(true);
80
+ });
81
+ emblaApi.on("reInit", (api) => {
82
+ canScrollNext$.set(api.canScrollNext());
83
+ canScrollPrev$.set(api.canScrollPrev());
84
+ scrolling$.set(false);
85
+ selectedScrollSnap$.set(api.selectedScrollSnap());
86
+ });
87
+ emblaApi.on("slidesChanged", (api) => {
88
+ slideNodes$.set(api.slideNodes());
89
+ });
90
+ canScrollNext$.set(emblaApi.canScrollNext());
91
+ canScrollPrev$.set(emblaApi.canScrollPrev());
92
+ slideNodes$.set(emblaApi.slideNodes());
93
+ return {
94
+ update: ({ options: options2, plugins: plugins2 }) => {
95
+ emblaApi.reInit(options2, plugins2);
96
+ },
97
+ destroy: () => {
98
+ emblaApi?.destroy();
99
+ emblaApi = void 0;
100
+ initialized$.set(false);
101
+ scrolling$.set(false);
102
+ canScrollPrev$.set(false);
103
+ canScrollNext$.set(true);
104
+ selectedScrollSnap$.set(0);
105
+ slideNodes$.set([]);
106
+ }
107
+ };
108
+ }
109
+ ),
110
+ directiveArgs$
111
+ ),
112
+ stores: {
113
+ scrolling$: tansu.asReadable(scrolling$),
114
+ canScrollPrev$: tansu.asReadable(canScrollPrev$),
115
+ canScrollNext$: tansu.asReadable(canScrollNext$),
116
+ selectedScrollSnap$: tansu.asReadable(selectedScrollSnap$),
117
+ initialized$: tansu.asReadable(initialized$),
118
+ slideNodes$: tansu.asReadable(slideNodes$)
119
+ },
120
+ get api() {
121
+ return emblaApi;
122
+ }
123
+ };
124
+ }
125
+ const createCarousel = utils_widget.createWidgetFactory(
126
+ "carousel",
127
+ (config) => {
128
+ const [
129
+ {
130
+ align$,
131
+ container$,
132
+ containScroll$,
133
+ direction$,
134
+ dragFree$,
135
+ dragThreshold$,
136
+ duration$,
137
+ loop$,
138
+ skipSnaps$,
139
+ plugins$,
140
+ ariaPrevLabel$,
141
+ ariaNextLabel$,
142
+ ariaIndicatorLabel$,
143
+ showNavigationIndicators$,
144
+ ...stateProps
145
+ },
146
+ patch
147
+ ] = utils_stores.writablesForProps(defaultConfig, config, configValidator);
148
+ const emblaOptions$ = tansu.computed(() => ({
149
+ align: align$(),
150
+ container: container$(),
151
+ containScroll: containScroll$(),
152
+ direction: direction$(),
153
+ dragFree: dragFree$(),
154
+ dragThreshold: dragThreshold$(),
155
+ duration: duration$(),
156
+ loop: loop$(),
157
+ skipSnaps: skipSnaps$()
158
+ }));
159
+ const emblaCarousel = createEmblaCarousel(emblaOptions$, plugins$);
160
+ const {
161
+ stores: { slideNodes$, ...emblaStores }
162
+ } = emblaCarousel;
163
+ const {
164
+ directive: navDirective,
165
+ refreshElements,
166
+ focusLeft,
167
+ focusRight,
168
+ focusFirst,
169
+ focusLast
170
+ } = services_navManager.createNavManager();
171
+ const navManagerConfig = {
172
+ keys: {
173
+ ArrowLeft: focusLeft,
174
+ ArrowRight: focusRight,
175
+ Home: focusFirst,
176
+ End: focusLast
177
+ },
178
+ selector: (node) => node.querySelectorAll("[role='tab']")
179
+ };
180
+ return {
181
+ ...utils_stores.stateStores({
182
+ ...emblaStores,
183
+ ...stateProps,
184
+ direction$,
185
+ showNavigationIndicators$
186
+ }),
187
+ patch,
188
+ api: {
189
+ scrollPrev: (jump) => {
190
+ emblaCarousel.api?.scrollPrev?.(jump);
191
+ },
192
+ scrollNext: (jump) => {
193
+ emblaCarousel.api?.scrollNext?.(jump);
194
+ },
195
+ scrollTo: (index, jump) => {
196
+ emblaCarousel.api?.scrollTo?.(index, jump);
197
+ },
198
+ plugins: () => emblaCarousel.api?.plugins?.(),
199
+ emblaApi: () => emblaCarousel.api
200
+ },
201
+ directives: {
202
+ root: utils_directive.mergeDirectives(
203
+ emblaCarousel.directive,
204
+ utils_directive.createAttributesDirective(() => ({
205
+ classNames: {
206
+ "au-carousel": utils_stores.true$
207
+ },
208
+ attributes: {
209
+ role: tansu.readable("region"),
210
+ "aria-roledescription": tansu.readable("carousel"),
211
+ dir: direction$
212
+ }
213
+ }))
214
+ ),
215
+ scrollPrev: utils_directive.createAttributesDirective(() => ({
216
+ attributes: {
217
+ "aria-label": ariaPrevLabel$,
218
+ disabled: tansu.computed(() => !emblaCarousel.stores.canScrollPrev$() || void 0)
219
+ },
220
+ events: {
221
+ click: () => emblaCarousel.api?.scrollPrev(),
222
+ pointerdown: (event) => event.preventDefault(),
223
+ touchstart: (event) => event.stopPropagation()
224
+ }
225
+ })),
226
+ scrollNext: utils_directive.createAttributesDirective(() => ({
227
+ attributes: {
228
+ "aria-label": ariaNextLabel$,
229
+ disabled: tansu.computed(() => !emblaCarousel.stores.canScrollNext$() || void 0)
230
+ },
231
+ events: {
232
+ click: () => emblaCarousel.api?.scrollNext(),
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(
254
+ (slide$) => ({
255
+ events: {
256
+ click: () => {
257
+ emblaCarousel.api?.scrollTo(slide$().index, slide$().jump ?? true);
258
+ }
259
+ },
260
+ attributes: {
261
+ "aria-label": tansu.computed(() => ariaIndicatorLabel$()(slide$().index)),
262
+ "aria-selected": tansu.computed(
263
+ () => slide$().index === emblaCarousel.stores.selectedScrollSnap$() ? "true" : void 0
264
+ ),
265
+ "aria-controls": tansu.computed(() => slide$().id),
266
+ role: tansu.readable("tab"),
267
+ tabindex: tansu.computed(() => slide$().index === emblaCarousel.stores.selectedScrollSnap$() ? "0" : "-1")
268
+ }
269
+ })
270
+ ),
271
+ slide: utils_directive.createAttributesDirective((slide$) => {
272
+ const selected$ = tansu.computed(() => slide$().index === emblaCarousel.stores.selectedScrollSnap$());
273
+ return {
274
+ attributes: {
275
+ id: tansu.computed(() => slide$().id),
276
+ "aria-hidden": tansu.computed(() => selected$() ? void 0 : "true"),
277
+ role: tansu.computed(() => showNavigationIndicators$() ? "tabpanel" : "group"),
278
+ "aria-roledescription": tansu.computed(() => showNavigationIndicators$() ? void 0 : "slide"),
279
+ tabindex: tansu.computed(() => showNavigationIndicators$() && selected$() ? "0" : void 0)
280
+ },
281
+ classNames: {
282
+ "au-carousel-slide": utils_stores.true$
283
+ }
284
+ };
285
+ })
286
+ }
287
+ };
288
+ }
289
+ );
290
+ exports.createCarousel = createCarousel;
291
+ exports.createEmblaCarousel = createEmblaCarousel;
292
+ exports.getCarouselDefaultConfig = getCarouselDefaultConfig;
@@ -0,0 +1 @@
1
+ export * from './carousel';
@@ -0,0 +1,292 @@
1
+ import { writablesForProps, true$, stateStores } from "../../utils/stores.js";
2
+ import { b as bindDirective, d as browserDirective, g as createAttributesDirective, s as mergeDirectives } from "../../directive-CNNSo5Yn.js";
3
+ import EmblaCarousel from "embla-carousel";
4
+ import { writable, computed, asReadable, readable } from "@amadeus-it-group/tansu";
5
+ import { e as typeFunction, j as typeString, b as typeBoolean, g as typeNumber, k as typeStringOrNull, a as typeArray, c as createTypeEnum } from "../../writables-DYGjj5T3.js";
6
+ import { createNavManager } from "../../services/navManager.js";
7
+ import { createWidgetFactory } from "../../utils/widget.js";
8
+ const defaultConfig = {
9
+ align: "center",
10
+ container: null,
11
+ containScroll: "trimSnaps",
12
+ direction: "ltr",
13
+ dragFree: false,
14
+ dragThreshold: 10,
15
+ duration: 25,
16
+ loop: false,
17
+ skipSnaps: false,
18
+ plugins: [],
19
+ showNavigationArrows: true,
20
+ showNavigationIndicators: true,
21
+ ariaPrevLabel: "Select previous slide",
22
+ ariaNextLabel: "Select next slide",
23
+ ariaIndicatorLabel: (index) => `Select slide ${index + 1}`
24
+ };
25
+ function getCarouselDefaultConfig() {
26
+ return { ...defaultConfig };
27
+ }
28
+ const configValidator = {
29
+ dragFree: typeBoolean,
30
+ plugins: typeArray,
31
+ align: createTypeEnum(["start", "center", "end"]),
32
+ container: typeStringOrNull,
33
+ containScroll: createTypeEnum([false, "trimSnaps", "keepSnaps"]),
34
+ direction: createTypeEnum(["ltr", "rtl"]),
35
+ dragThreshold: typeNumber,
36
+ duration: typeNumber,
37
+ loop: typeBoolean,
38
+ skipSnaps: typeBoolean,
39
+ showNavigationArrows: typeBoolean,
40
+ showNavigationIndicators: typeBoolean,
41
+ ariaPrevLabel: typeString,
42
+ ariaNextLabel: typeString,
43
+ ariaIndicatorLabel: typeFunction
44
+ };
45
+ function createEmblaCarousel(options$, plugins$) {
46
+ let emblaApi;
47
+ const scrolling$ = writable(false);
48
+ const canScrollPrev$ = writable(false);
49
+ const canScrollNext$ = writable(true);
50
+ const selectedScrollSnap$ = writable(0);
51
+ const initialized$ = writable(false);
52
+ const slideNodes$ = writable([]);
53
+ const directiveArgs$ = computed(() => ({
54
+ options: options$(),
55
+ plugins: plugins$ ? plugins$() : []
56
+ }));
57
+ return {
58
+ directive: bindDirective(
59
+ browserDirective(
60
+ (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?.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
+ ),
108
+ directiveArgs$
109
+ ),
110
+ stores: {
111
+ scrolling$: asReadable(scrolling$),
112
+ canScrollPrev$: asReadable(canScrollPrev$),
113
+ canScrollNext$: asReadable(canScrollNext$),
114
+ selectedScrollSnap$: asReadable(selectedScrollSnap$),
115
+ initialized$: asReadable(initialized$),
116
+ slideNodes$: asReadable(slideNodes$)
117
+ },
118
+ get api() {
119
+ return emblaApi;
120
+ }
121
+ };
122
+ }
123
+ const createCarousel = createWidgetFactory(
124
+ "carousel",
125
+ (config) => {
126
+ const [
127
+ {
128
+ align$,
129
+ container$,
130
+ containScroll$,
131
+ direction$,
132
+ dragFree$,
133
+ dragThreshold$,
134
+ duration$,
135
+ loop$,
136
+ skipSnaps$,
137
+ plugins$,
138
+ ariaPrevLabel$,
139
+ ariaNextLabel$,
140
+ ariaIndicatorLabel$,
141
+ showNavigationIndicators$,
142
+ ...stateProps
143
+ },
144
+ patch
145
+ ] = writablesForProps(defaultConfig, config, configValidator);
146
+ const emblaOptions$ = computed(() => ({
147
+ align: align$(),
148
+ container: container$(),
149
+ containScroll: containScroll$(),
150
+ direction: direction$(),
151
+ dragFree: dragFree$(),
152
+ dragThreshold: dragThreshold$(),
153
+ duration: duration$(),
154
+ loop: loop$(),
155
+ skipSnaps: skipSnaps$()
156
+ }));
157
+ const emblaCarousel = createEmblaCarousel(emblaOptions$, plugins$);
158
+ const {
159
+ stores: { slideNodes$, ...emblaStores }
160
+ } = emblaCarousel;
161
+ const {
162
+ directive: navDirective,
163
+ refreshElements,
164
+ focusLeft,
165
+ focusRight,
166
+ focusFirst,
167
+ focusLast
168
+ } = createNavManager();
169
+ const navManagerConfig = {
170
+ keys: {
171
+ ArrowLeft: focusLeft,
172
+ ArrowRight: focusRight,
173
+ Home: focusFirst,
174
+ End: focusLast
175
+ },
176
+ selector: (node) => node.querySelectorAll("[role='tab']")
177
+ };
178
+ return {
179
+ ...stateStores({
180
+ ...emblaStores,
181
+ ...stateProps,
182
+ direction$,
183
+ showNavigationIndicators$
184
+ }),
185
+ patch,
186
+ api: {
187
+ scrollPrev: (jump) => {
188
+ emblaCarousel.api?.scrollPrev?.(jump);
189
+ },
190
+ scrollNext: (jump) => {
191
+ emblaCarousel.api?.scrollNext?.(jump);
192
+ },
193
+ scrollTo: (index, jump) => {
194
+ emblaCarousel.api?.scrollTo?.(index, jump);
195
+ },
196
+ plugins: () => emblaCarousel.api?.plugins?.(),
197
+ emblaApi: () => emblaCarousel.api
198
+ },
199
+ directives: {
200
+ root: mergeDirectives(
201
+ emblaCarousel.directive,
202
+ createAttributesDirective(() => ({
203
+ classNames: {
204
+ "au-carousel": true$
205
+ },
206
+ attributes: {
207
+ role: readable("region"),
208
+ "aria-roledescription": readable("carousel"),
209
+ dir: direction$
210
+ }
211
+ }))
212
+ ),
213
+ scrollPrev: createAttributesDirective(() => ({
214
+ attributes: {
215
+ "aria-label": ariaPrevLabel$,
216
+ disabled: computed(() => !emblaCarousel.stores.canScrollPrev$() || void 0)
217
+ },
218
+ events: {
219
+ click: () => emblaCarousel.api?.scrollPrev(),
220
+ pointerdown: (event) => event.preventDefault(),
221
+ touchstart: (event) => event.stopPropagation()
222
+ }
223
+ })),
224
+ scrollNext: createAttributesDirective(() => ({
225
+ attributes: {
226
+ "aria-label": ariaNextLabel$,
227
+ disabled: computed(() => !emblaCarousel.stores.canScrollNext$() || void 0)
228
+ },
229
+ events: {
230
+ click: () => emblaCarousel.api?.scrollNext(),
231
+ pointerdown: (event) => event.preventDefault(),
232
+ touchstart: (event) => event.stopPropagation()
233
+ }
234
+ })),
235
+ tabList: mergeDirectives(
236
+ bindDirective(navDirective, readable(navManagerConfig)),
237
+ browserDirective(() => {
238
+ const unsubscribe = slideNodes$.subscribe(() => {
239
+ refreshElements();
240
+ });
241
+ return {
242
+ destroy: unsubscribe
243
+ };
244
+ }),
245
+ createAttributesDirective(() => ({
246
+ attributes: {
247
+ role: readable("tablist")
248
+ }
249
+ }))
250
+ ),
251
+ tabIndicator: createAttributesDirective(
252
+ (slide$) => ({
253
+ events: {
254
+ click: () => {
255
+ emblaCarousel.api?.scrollTo(slide$().index, slide$().jump ?? true);
256
+ }
257
+ },
258
+ attributes: {
259
+ "aria-label": computed(() => ariaIndicatorLabel$()(slide$().index)),
260
+ "aria-selected": computed(
261
+ () => slide$().index === emblaCarousel.stores.selectedScrollSnap$() ? "true" : void 0
262
+ ),
263
+ "aria-controls": computed(() => slide$().id),
264
+ role: readable("tab"),
265
+ tabindex: computed(() => slide$().index === emblaCarousel.stores.selectedScrollSnap$() ? "0" : "-1")
266
+ }
267
+ })
268
+ ),
269
+ slide: createAttributesDirective((slide$) => {
270
+ const selected$ = computed(() => slide$().index === emblaCarousel.stores.selectedScrollSnap$());
271
+ return {
272
+ attributes: {
273
+ id: computed(() => slide$().id),
274
+ "aria-hidden": computed(() => selected$() ? void 0 : "true"),
275
+ role: computed(() => showNavigationIndicators$() ? "tabpanel" : "group"),
276
+ "aria-roledescription": computed(() => showNavigationIndicators$() ? void 0 : "slide"),
277
+ tabindex: computed(() => showNavigationIndicators$() && selected$() ? "0" : void 0)
278
+ },
279
+ classNames: {
280
+ "au-carousel-slide": true$
281
+ }
282
+ };
283
+ })
284
+ }
285
+ };
286
+ }
287
+ );
288
+ export {
289
+ createCarousel,
290
+ createEmblaCarousel,
291
+ getCarouselDefaultConfig
292
+ };