@obosbbl/grunnmuren-react 2.3.2 → 2.3.3
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/index.d.mts +19 -2
- package/dist/index.mjs +15 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -634,8 +634,16 @@ type CarouselProps = {
|
|
|
634
634
|
children: React.ReactNode;
|
|
635
635
|
/** Additional CSS className for the element. */
|
|
636
636
|
className?: string;
|
|
637
|
+
/**
|
|
638
|
+
* Callback that is triggered when a user navigates to new item in the Carousel.
|
|
639
|
+
* The argument to the callback is an object containing `index` of the new item scrolled into view and the `id` of that item (if set on the `<CarouselItem>`)
|
|
640
|
+
* It also provides `prevIndex` which is the index of the previous item that was in view
|
|
641
|
+
* And `prevId`, which is the id of the previous item that was in view (if set on the `<CarouselItem>`)
|
|
642
|
+
* @param item { index: number; id?: string; prevIndex: number; prevId?: string }
|
|
643
|
+
*/
|
|
644
|
+
onChange?: (item: CarouselItem) => void;
|
|
637
645
|
};
|
|
638
|
-
declare const Carousel: ({ className, children }: CarouselProps) => react_jsx_runtime.JSX.Element;
|
|
646
|
+
declare const Carousel: ({ className, children, onChange }: CarouselProps) => react_jsx_runtime.JSX.Element;
|
|
639
647
|
type CarouselItemsProps = {
|
|
640
648
|
/** The <CarouselItem/> components to be displayed within the carousel. */
|
|
641
649
|
children: React.ReactNode;
|
|
@@ -648,7 +656,16 @@ type CarouselItemProps = {
|
|
|
648
656
|
children: React.ReactNode;
|
|
649
657
|
/** Additional CSS className for the element. */
|
|
650
658
|
className?: string;
|
|
659
|
+
id?: string;
|
|
660
|
+
};
|
|
661
|
+
type CarouselItem = Pick<CarouselItemProps, 'id'> & {
|
|
662
|
+
/** The index of the item that is currently in view */
|
|
663
|
+
index: number;
|
|
664
|
+
/** The index of the previous item that was in view */
|
|
665
|
+
prevIndex: number;
|
|
666
|
+
/** The id of the previous item that was in view */
|
|
667
|
+
prevId?: CarouselItemProps['id'];
|
|
651
668
|
};
|
|
652
|
-
declare const CarouselItem: ({ className, children }: CarouselItemProps) => react_jsx_runtime.JSX.Element;
|
|
669
|
+
declare const CarouselItem: ({ className, children, id }: CarouselItemProps) => react_jsx_runtime.JSX.Element;
|
|
653
670
|
|
|
654
671
|
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, Alertbox, type Props as AlertboxProps, Avatar, type AvatarProps, Backlink, type BacklinkProps, Badge, type BadgeProps, Breadcrumb, type BreadcrumbProps, Breadcrumbs, type BreadcrumbsProps, Button, ButtonContext, type ButtonProps, Caption, type CaptionProps, Card, CardLink, type CardLinkProps, type CardProps, Checkbox, CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, type ComboboxProps, ListBoxSection as ComboboxSection, Content, ContentContext, type ContentProps, DateFormatter, type DateFormatterProps, Description, type DescriptionProps, DisclosureStateContext, ErrorMessage, type ErrorMessageProps, Footer, type FooterProps, GrunnmurenProvider, type GrunnmurenProviderProps, Heading, HeadingContext, type HeadingProps, Label, type Locale, Media, MediaContext, type MediaProps, NumberField, type NumberFieldProps, Radio, RadioGroup, type RadioGroupProps, type RadioProps, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, type SelectProps, ListBoxSection as SelectSection, type TagGroupProps, type TagListProps, type TagProps, TextArea, type TextAreaProps, TextField, type TextFieldProps, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, type CarouselItemProps as UNSAFE_CarouselItemProps, CarouselItems as UNSAFE_CarouselItems, type CarouselItemsProps as UNSAFE_CarouselItemsProps, type CarouselProps as UNSAFE_CarouselProps, Dialog as UNSAFE_Dialog, type DialogProps as UNSAFE_DialogProps, DialogTrigger as UNSAFE_DialogTrigger, type DialogTriggerProps as UNSAFE_DialogTriggerProps, Disclosure as UNSAFE_Disclosure, DisclosureButton as UNSAFE_DisclosureButton, type DisclosureButtonProps as UNSAFE_DisclosureButtonProps, DisclosurePanel as UNSAFE_DisclosurePanel, type DisclosurePanelProps as UNSAFE_DisclosurePanelProps, type DisclosureProps as UNSAFE_DisclosureProps, FileUpload as UNSAFE_FileUpload, type FileUploadProps as UNSAFE_FileUploadProps, Hero as UNSAFE_Hero, type HeroProps as UNSAFE_HeroProps, Modal as UNSAFE_Modal, type ModalProps as UNSAFE_ModalProps, Tag as UNSAFE_Tag, TagGroup as UNSAFE_TagGroup, TagList as UNSAFE_TagList, VideoLoop, _useLocale as useLocale };
|
package/dist/index.mjs
CHANGED
|
@@ -2107,7 +2107,7 @@ const Hero = ({ variant, className, children })=>{
|
|
|
2107
2107
|
});
|
|
2108
2108
|
};
|
|
2109
2109
|
|
|
2110
|
-
const Carousel = ({ className, children })=>{
|
|
2110
|
+
const Carousel = ({ className, children, onChange })=>{
|
|
2111
2111
|
const ref = useRef(null);
|
|
2112
2112
|
const locale = _useLocale();
|
|
2113
2113
|
const { previous, next } = translations$1;
|
|
@@ -2120,6 +2120,9 @@ const Carousel = ({ className, children })=>{
|
|
|
2120
2120
|
}, [
|
|
2121
2121
|
scrollTargetIndex
|
|
2122
2122
|
]);
|
|
2123
|
+
// Keep track of the previous index to determine if the user is scrolling forward or backward
|
|
2124
|
+
// This is used to determine which callback to call (onPrev or onNext)
|
|
2125
|
+
const prevIndex = useRef(0);
|
|
2123
2126
|
// Handle scrolling when user clicks the arrow icons
|
|
2124
2127
|
useUpdateEffect(()=>{
|
|
2125
2128
|
if (!ref.current) return;
|
|
@@ -2128,6 +2131,15 @@ const Carousel = ({ className, children })=>{
|
|
|
2128
2131
|
inline: 'start',
|
|
2129
2132
|
block: 'nearest'
|
|
2130
2133
|
});
|
|
2134
|
+
if (prevIndex.current !== scrollTargetIndex && onChange) {
|
|
2135
|
+
onChange({
|
|
2136
|
+
index: scrollTargetIndex,
|
|
2137
|
+
id: ref.current.children[scrollTargetIndex]?.id,
|
|
2138
|
+
prevIndex: prevIndex.current,
|
|
2139
|
+
prevId: ref.current.children[prevIndex.current]?.id
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
prevIndex.current = scrollTargetIndex;
|
|
2131
2143
|
}, [
|
|
2132
2144
|
scrollTargetIndex
|
|
2133
2145
|
]);
|
|
@@ -2249,10 +2261,11 @@ const CarouselItems = ({ className, children })=>/*#__PURE__*/ jsx(CarouselItems
|
|
|
2249
2261
|
children: children
|
|
2250
2262
|
})
|
|
2251
2263
|
});
|
|
2252
|
-
const CarouselItem = ({ className, children })=>{
|
|
2264
|
+
const CarouselItem = ({ className, children, id })=>{
|
|
2253
2265
|
return /*#__PURE__*/ jsx("div", {
|
|
2254
2266
|
className: cx(className, 'shrink-0 basis-full snap-start'),
|
|
2255
2267
|
"data-slot": "carousel-item",
|
|
2268
|
+
id: id,
|
|
2256
2269
|
children: /*#__PURE__*/ jsx(Provider, {
|
|
2257
2270
|
values: [
|
|
2258
2271
|
[
|