@atom-learning/components 6.17.0 → 7.0.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/dist/components/carousel/Carousel.d.ts +33 -25
- package/dist/components/carousel/Carousel.js +84 -14
- package/dist/components/carousel/Carousel.js.map +1 -1
- package/dist/components/carousel/CarouselArrows.d.ts +5 -6
- package/dist/components/carousel/CarouselArrows.js +25 -9
- package/dist/components/carousel/CarouselArrows.js.map +1 -1
- package/dist/components/carousel/CarouselPagination.d.ts +2 -3
- package/dist/components/carousel/CarouselPagination.js +31 -17
- package/dist/components/carousel/CarouselPagination.js.map +1 -1
- package/dist/components/carousel/CarouselSlide.d.ts +2 -4
- package/dist/components/carousel/CarouselSlide.js +14 -5
- package/dist/components/carousel/CarouselSlide.js.map +1 -1
- package/dist/components/carousel/CarouselSlider.d.ts +10 -4
- package/dist/components/carousel/CarouselSlider.js +22 -6
- package/dist/components/carousel/CarouselSlider.js.map +1 -1
- package/dist/docgen.json +1 -1
- package/dist/index.cjs.js +170 -47
- package/dist/index.cjs.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -45,7 +45,8 @@ let _radix_ui_react_tooltip = require("@radix-ui/react-tooltip");
|
|
|
45
45
|
let _radix_ui_react_alert_dialog = require("@radix-ui/react-alert-dialog");
|
|
46
46
|
let uid = require("uid");
|
|
47
47
|
let throttle_debounce = require("throttle-debounce");
|
|
48
|
-
let
|
|
48
|
+
let embla_carousel_react = require("embla-carousel-react");
|
|
49
|
+
embla_carousel_react = __toESM(embla_carousel_react);
|
|
49
50
|
let _radix_ui_react_checkbox = require("@radix-ui/react-checkbox");
|
|
50
51
|
_radix_ui_react_checkbox = __toESM(_radix_ui_react_checkbox);
|
|
51
52
|
let _radix_ui_react_collapsible = require("@radix-ui/react-collapsible");
|
|
@@ -687,7 +688,7 @@ var useIsMountedRef = () => {
|
|
|
687
688
|
};
|
|
688
689
|
//#endregion
|
|
689
690
|
//#region src/components/loader/Loader.tsx
|
|
690
|
-
var Dot = styled("div", {
|
|
691
|
+
var Dot$1 = styled("div", {
|
|
691
692
|
base: [
|
|
692
693
|
"animate-pulse",
|
|
693
694
|
"bg-current",
|
|
@@ -706,7 +707,7 @@ var Loader = ({ className, message = "Loading", size = "md", ...props }) => /* @
|
|
|
706
707
|
className: cn("flex", "justify-center", className),
|
|
707
708
|
role: "alert",
|
|
708
709
|
...props
|
|
709
|
-
}, /* @__PURE__ */ react.createElement("span", { className: "sr-only" }, message), /* @__PURE__ */ react.createElement(Dot, { size }), /* @__PURE__ */ react.createElement(Dot, { size }), /* @__PURE__ */ react.createElement(Dot, { size }));
|
|
710
|
+
}, /* @__PURE__ */ react.createElement("span", { className: "sr-only" }, message), /* @__PURE__ */ react.createElement(Dot$1, { size }), /* @__PURE__ */ react.createElement(Dot$1, { size }), /* @__PURE__ */ react.createElement(Dot$1, { size }));
|
|
710
711
|
//#endregion
|
|
711
712
|
//#region src/components/button/Button.tsx
|
|
712
713
|
var StyledButton = styled("button", {
|
|
@@ -2125,9 +2126,8 @@ var Box = styled("div", { base: [] });
|
|
|
2125
2126
|
Box.displayName = "Box";
|
|
2126
2127
|
//#endregion
|
|
2127
2128
|
//#region src/components/carousel/CarouselArrows.tsx
|
|
2128
|
-
var
|
|
2129
|
+
var ArrowButton = styled("button", { base: [
|
|
2129
2130
|
"items-center",
|
|
2130
|
-
"bg-[unset]",
|
|
2131
2131
|
"text-primary-800",
|
|
2132
2132
|
"cursor-pointer",
|
|
2133
2133
|
"flex",
|
|
@@ -2140,55 +2140,178 @@ var buttonStyles = [
|
|
|
2140
2140
|
"ease-in-out",
|
|
2141
2141
|
"hover:text-primary-900",
|
|
2142
2142
|
"active:text-primary-1000",
|
|
2143
|
-
"disabled:text-grey-200"
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
var
|
|
2147
|
-
|
|
2148
|
-
|
|
2143
|
+
"disabled:text-grey-200",
|
|
2144
|
+
"disabled:cursor-not-allowed"
|
|
2145
|
+
] });
|
|
2146
|
+
var CarouselArrowPrevious = (props) => {
|
|
2147
|
+
const { scrollPrev, canScrollPrev } = useCarousel();
|
|
2148
|
+
return /* @__PURE__ */ react.createElement(ArrowButton, {
|
|
2149
|
+
type: "button",
|
|
2150
|
+
onClick: scrollPrev,
|
|
2151
|
+
disabled: !canScrollPrev,
|
|
2152
|
+
"aria-label": "Previous slide",
|
|
2153
|
+
...props
|
|
2154
|
+
}, /* @__PURE__ */ react.createElement(Icon, { is: _atom_learning_icons.ChevronLeft }));
|
|
2155
|
+
};
|
|
2156
|
+
var CarouselArrowNext = (props) => {
|
|
2157
|
+
const { scrollNext, canScrollNext } = useCarousel();
|
|
2158
|
+
return /* @__PURE__ */ react.createElement(ArrowButton, {
|
|
2159
|
+
type: "button",
|
|
2160
|
+
onClick: scrollNext,
|
|
2161
|
+
disabled: !canScrollNext,
|
|
2162
|
+
"aria-label": "Next slide",
|
|
2163
|
+
...props
|
|
2164
|
+
}, /* @__PURE__ */ react.createElement(Icon, { is: _atom_learning_icons.ChevronRight }));
|
|
2165
|
+
};
|
|
2149
2166
|
//#endregion
|
|
2150
2167
|
//#region src/components/carousel/CarouselPagination.tsx
|
|
2151
|
-
var
|
|
2152
|
-
"
|
|
2153
|
-
"
|
|
2154
|
-
"
|
|
2155
|
-
"
|
|
2156
|
-
"
|
|
2157
|
-
"
|
|
2158
|
-
"
|
|
2159
|
-
"
|
|
2160
|
-
"
|
|
2161
|
-
"
|
|
2162
|
-
"
|
|
2163
|
-
"
|
|
2164
|
-
"
|
|
2165
|
-
"[&_button]:transition-all"
|
|
2168
|
+
var Dot = styled("button", { base: [
|
|
2169
|
+
"bg-grey-600",
|
|
2170
|
+
"cursor-pointer",
|
|
2171
|
+
"duration-100",
|
|
2172
|
+
"ease-in",
|
|
2173
|
+
"focus:bg-primary-900",
|
|
2174
|
+
"hover:bg-primary-900",
|
|
2175
|
+
"mx-1",
|
|
2176
|
+
"p-1",
|
|
2177
|
+
"rounded-full",
|
|
2178
|
+
"size-3",
|
|
2179
|
+
"transition-all",
|
|
2180
|
+
"disabled:bg-primary-800",
|
|
2181
|
+
"disabled:cursor-default"
|
|
2166
2182
|
] });
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2183
|
+
var CarouselPagination = ({ className, ...rest }) => {
|
|
2184
|
+
const { scrollSnaps, selectedIndex, scrollTo } = useCarousel();
|
|
2185
|
+
const dots = Array.from({ length: scrollSnaps.length }, (_, i) => i);
|
|
2186
|
+
return /* @__PURE__ */ react.createElement("div", {
|
|
2187
|
+
className: cn("flex", "justify-center", className),
|
|
2188
|
+
...rest
|
|
2189
|
+
}, dots.map((index) => /* @__PURE__ */ react.createElement(Dot, {
|
|
2190
|
+
key: index,
|
|
2191
|
+
type: "button",
|
|
2192
|
+
onClick: () => scrollTo(index),
|
|
2193
|
+
disabled: index === selectedIndex,
|
|
2194
|
+
"aria-label": "slide dot"
|
|
2195
|
+
})));
|
|
2196
|
+
};
|
|
2173
2197
|
//#endregion
|
|
2174
2198
|
//#region src/components/carousel/CarouselSlider.tsx
|
|
2175
|
-
var
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2199
|
+
var toSlideGapClass = {
|
|
2200
|
+
none: "",
|
|
2201
|
+
0: "px-0.5",
|
|
2202
|
+
1: "px-1",
|
|
2203
|
+
2: "px-2",
|
|
2204
|
+
3: "px-3",
|
|
2205
|
+
4: "px-4"
|
|
2206
|
+
};
|
|
2207
|
+
var CarouselSlideGapContext = react.createContext(3);
|
|
2208
|
+
var CarouselSlider = ({ children, className, gap = 3, overflow, tabIndex = 0, ...rest }) => {
|
|
2209
|
+
const { emblaRef } = useCarousel();
|
|
2210
|
+
return /* @__PURE__ */ react.createElement("div", {
|
|
2211
|
+
ref: emblaRef,
|
|
2212
|
+
className: cn("ml-[50%]", "-translate-x-1/2", "cursor-grab", overflow ? "overflow-visible" : "overflow-hidden", className),
|
|
2213
|
+
role: "listbox",
|
|
2214
|
+
"aria-live": "polite",
|
|
2215
|
+
tabIndex,
|
|
2216
|
+
...rest
|
|
2217
|
+
}, /* @__PURE__ */ react.createElement("div", { className: "flex" }, /* @__PURE__ */ react.createElement(CarouselSlideGapContext.Provider, { value: gap }, children)));
|
|
2218
|
+
};
|
|
2219
|
+
//#endregion
|
|
2220
|
+
//#region src/components/carousel/CarouselSlide.tsx
|
|
2221
|
+
var CarouselSlide = ({ children, className, index, ...rest }) => {
|
|
2222
|
+
const { selectedIndex } = useCarousel();
|
|
2223
|
+
const gap = react.useContext(CarouselSlideGapContext);
|
|
2224
|
+
const isSelected = selectedIndex === index;
|
|
2225
|
+
return /* @__PURE__ */ react.createElement("div", {
|
|
2226
|
+
role: "option",
|
|
2227
|
+
"aria-selected": isSelected,
|
|
2228
|
+
className: cn("min-w-0", "basis-full", "shrink-0", className),
|
|
2229
|
+
...rest
|
|
2230
|
+
}, /* @__PURE__ */ react.createElement("div", { className: cn("flex items-center justify-center", toSlideGapClass[gap]) }, children));
|
|
2231
|
+
};
|
|
2179
2232
|
//#endregion
|
|
2180
2233
|
//#region src/components/carousel/Carousel.tsx
|
|
2181
|
-
var
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2234
|
+
var CarouselContext = react.createContext(null);
|
|
2235
|
+
var CarouselComponent = ({ children, currentSlide = 0, ...props }) => {
|
|
2236
|
+
const [emblaRef, emblaApi] = (0, embla_carousel_react.default)({
|
|
2237
|
+
startIndex: currentSlide,
|
|
2238
|
+
align: "center"
|
|
2239
|
+
});
|
|
2240
|
+
const [selectedIndex, setSelectedIndex] = react.useState(currentSlide);
|
|
2241
|
+
const [scrollSnaps, setScrollSnaps] = react.useState([]);
|
|
2242
|
+
const [canScrollPrev, setCanScrollPrev] = react.useState(false);
|
|
2243
|
+
const [canScrollNext, setCanScrollNext] = react.useState(false);
|
|
2244
|
+
const scrollPrev = react.useCallback(() => {
|
|
2245
|
+
emblaApi?.scrollPrev();
|
|
2246
|
+
}, [emblaApi]);
|
|
2247
|
+
const scrollNext = react.useCallback(() => {
|
|
2248
|
+
emblaApi?.scrollNext();
|
|
2249
|
+
}, [emblaApi]);
|
|
2250
|
+
const scrollTo = react.useCallback((index) => {
|
|
2251
|
+
emblaApi?.scrollTo(index);
|
|
2252
|
+
}, [emblaApi]);
|
|
2253
|
+
const onSelect = react.useCallback(() => {
|
|
2254
|
+
if (!emblaApi) return;
|
|
2255
|
+
setSelectedIndex(emblaApi.selectedScrollSnap());
|
|
2256
|
+
setCanScrollPrev(emblaApi.canScrollPrev());
|
|
2257
|
+
setCanScrollNext(emblaApi.canScrollNext());
|
|
2258
|
+
}, [emblaApi]);
|
|
2259
|
+
const onInit = react.useCallback(() => {
|
|
2260
|
+
if (!emblaApi) return;
|
|
2261
|
+
setScrollSnaps(emblaApi.scrollSnapList());
|
|
2262
|
+
}, [emblaApi]);
|
|
2263
|
+
react.useEffect(() => {
|
|
2264
|
+
if (!emblaApi) return;
|
|
2265
|
+
onInit();
|
|
2266
|
+
onSelect();
|
|
2267
|
+
emblaApi.on("reInit", onInit);
|
|
2268
|
+
emblaApi.on("reInit", onSelect);
|
|
2269
|
+
emblaApi.on("select", onSelect);
|
|
2270
|
+
return () => {
|
|
2271
|
+
emblaApi.off("reInit", onInit);
|
|
2272
|
+
emblaApi.off("reInit", onSelect);
|
|
2273
|
+
emblaApi.off("select", onSelect);
|
|
2274
|
+
};
|
|
2275
|
+
}, [
|
|
2276
|
+
emblaApi,
|
|
2277
|
+
onInit,
|
|
2278
|
+
onSelect
|
|
2279
|
+
]);
|
|
2280
|
+
const contextValue = react.useMemo(() => ({
|
|
2281
|
+
emblaRef,
|
|
2282
|
+
emblaApi,
|
|
2283
|
+
selectedIndex,
|
|
2284
|
+
scrollSnaps,
|
|
2285
|
+
canScrollPrev,
|
|
2286
|
+
canScrollNext,
|
|
2287
|
+
scrollPrev,
|
|
2288
|
+
scrollNext,
|
|
2289
|
+
scrollTo
|
|
2290
|
+
}), [
|
|
2291
|
+
emblaRef,
|
|
2292
|
+
emblaApi,
|
|
2293
|
+
selectedIndex,
|
|
2294
|
+
scrollSnaps,
|
|
2295
|
+
canScrollPrev,
|
|
2296
|
+
canScrollNext,
|
|
2297
|
+
scrollPrev,
|
|
2298
|
+
scrollNext,
|
|
2299
|
+
scrollTo
|
|
2300
|
+
]);
|
|
2301
|
+
const { className, ...rest } = props;
|
|
2302
|
+
return /* @__PURE__ */ react.createElement("div", {
|
|
2303
|
+
className: cn("relative", "w-full", className),
|
|
2304
|
+
...rest
|
|
2305
|
+
}, /* @__PURE__ */ react.createElement(CarouselContext.Provider, { value: contextValue }, children));
|
|
2306
|
+
};
|
|
2307
|
+
var useCarousel = () => {
|
|
2308
|
+
const context = react.useContext(CarouselContext);
|
|
2309
|
+
if (!context) throw new Error("useCarousel must be used within a Carousel");
|
|
2310
|
+
return {
|
|
2311
|
+
...context,
|
|
2312
|
+
currentSlide: context.selectedIndex
|
|
2313
|
+
};
|
|
2314
|
+
};
|
|
2192
2315
|
var Carousel = Object.assign(CarouselComponent, {
|
|
2193
2316
|
ArrowNext: CarouselArrowNext,
|
|
2194
2317
|
ArrowPrevious: CarouselArrowPrevious,
|