@obosbbl/grunnmuren-react 2.3.2 → 2.3.4

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 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
@@ -168,7 +168,7 @@ function AccordionItem(props) {
168
168
  HeadingContext,
169
169
  {
170
170
  // Negative margin to strech the button to the entire with of the accordion (to support containers with a background color)
171
- className: 'font-semibold leading-7 -mx-2 text-base',
171
+ className: 'font-medium leading-7 -mx-2 text-base',
172
172
  // Supply a default level here to make this typecheck ok. Will be overwritten with the consumers set heading level anyways
173
173
  level: 3,
174
174
  _innerWrapper: (children)=>/*#__PURE__*/ jsxs("button", {
@@ -2025,6 +2025,7 @@ const oneColumnLayout = [
2025
2025
  // Aligns <Content> and any element beside it (e.g. <Media>, <Badge>, <CTA> etc.) to the bottom of the <Content> container
2026
2026
  'lg:items-end'
2027
2027
  ];
2028
+ const nonFullBleedAspectRatiosForSmallScreens = '*:data-[slot="media"]:*:aspect-[1/1] sm:*:data-[slot="media"]:*:aspect-4/3 md:*:data-[slot="media"]:*:aspect-3/2';
2028
2029
  const variants = cva({
2029
2030
  base: [
2030
2031
  'container px-0',
@@ -2045,19 +2046,26 @@ const variants = cva({
2045
2046
  * */ variant: {
2046
2047
  standard: [
2047
2048
  roundedMediaCorners,
2048
- oneColumnLayout
2049
+ oneColumnLayout,
2050
+ nonFullBleedAspectRatiosForSmallScreens,
2051
+ 'lg:*:data-[slot="media"]:*:aspect-2/1'
2049
2052
  ],
2050
2053
  'full-bleed': [
2051
2054
  oneColumnLayout,
2052
2055
  // Position the media and carousel content to fill the entire viewport width
2053
2056
  '*:data-[slot="media"]:*:absolute *:data-[slot="media"]:*:left-0',
2054
- '*:data-[slot="carousel"]:*:absolute *:data-[slot="carousel"]:*:left-0',
2057
+ // Special case for Carousel, where the Media is nested inside a CarouselItem
2058
+ '*:data-[slot="carousel"]:**:data-[slot="media"]:w-full *:data-[slot="carousel"]:*:absolute *:data-[slot="carousel"]:*:left-0',
2055
2059
  // Match the heights of the <Media> or <Carousel> wrapper for the Media content (e.g. image, VideoLoop, video etc.)
2056
2060
  // This is necessary due to the absolute positioning of the media and carousel containers in this variant
2057
2061
  // biome-ignore lint/nursery/useSortedClasses: biome is unable to sort the custom classes for 3xl and 4xl breakpoints
2058
- '*:data-[slot="media"]:*:h-70 sm:*:data-[slot="media"]:*:h-[25rem] md:*:data-[slot="media"]:*:h-[30rem] lg:*:data-[slot="media"]:*:h-[35rem] xl:*:data-[slot="media"]:*:h-[40rem] 2xl:*:data-[slot="media"]:*:h-[42rem] 3xl:*:data-[slot="media"]:*:h-[48rem] 4xl:*:data-[slot="media"]:*:h-[53rem]',
2062
+ '**:data-[slot="media"]:h-70 sm:**:data-[slot="media"]:h-[25rem] md:**:data-[slot="media"]:h-[30rem] lg:**:data-[slot="media"]:h-[35rem] xl:**:data-[slot="media"]:h-[40rem] 2xl:**:data-[slot="media"]:h-[42rem] 3xl:**:data-[slot="media"]:h-[48rem] 4xl:**:data-[slot="media"]:h-[53rem]',
2063
+ // biome-ignore lint/nursery/useSortedClasses: biome is unable to sort the custom classes for 3xl and 4xl breakpoints
2064
+ '**:data-[slot="media"]:*:h-70 sm:**:data-[slot="media"]:*:h-[25rem] md:**:data-[slot="media"]:*:h-[30rem] lg:**:data-[slot="media"]:*:h-[35rem] xl:**:data-[slot="media"]:*:h-[40rem] 2xl:**:data-[slot="media"]:*:h-[42rem] 3xl:**:data-[slot="media"]:*:h-[48rem] 4xl:**:data-[slot="media"]:*:h-[53rem]',
2059
2065
  // biome-ignore lint/nursery/useSortedClasses: biome is unable to sort the custom classes for 3xl and 4xl breakpoints
2060
2066
  '*:data-[slot="carousel"]:h-70 sm:*:data-[slot="carousel"]:h-[25rem] md:*:data-[slot="carousel"]:h-[30rem] lg:*:data-[slot="carousel"]:h-[35rem] xl:*:data-[slot="carousel"]:h-[40rem] 2xl:*:data-[slot="carousel"]:h-[42rem] 3xl:*:data-[slot="carousel"]:h-[48rem] 4xl:*:data-[slot="carousel"]:h-[53rem]',
2067
+ // Override aspect ratio of the media and carousel-item slots (since we can not use aspect for full-bleed layout)
2068
+ '**:data-[slot="carousel-item"]:data-[slot="media"]:*:aspect-none',
2061
2069
  '**:data-[slot="carousel-controls"]:container **:data-[slot="carousel-controls"]:right-0 **:data-[slot="carousel-controls"]:bottom-4 **:data-[slot="carousel-controls"]:left-0 **:data-[slot="carousel-controls"]:justify-end',
2062
2070
  // Override rounded corners of Carousel slots
2063
2071
  '*:data-[slot="carousel"]:*:rounded-none'
@@ -2067,6 +2075,7 @@ const variants = cva({
2067
2075
  // Vertical spacing in the <Content>
2068
2076
  'lg:*:data-[slot="content"]:gap-y-7',
2069
2077
  roundedMediaCorners,
2078
+ nonFullBleedAspectRatiosForSmallScreens,
2070
2079
  // Set media aspect ratio to 1:1 (square)
2071
2080
  'lg:*:data-[slot="media"]:*:aspect-[1/1]'
2072
2081
  ]
@@ -2087,7 +2096,9 @@ const Hero = ({ variant, className, children })=>{
2087
2096
  HeadingContext,
2088
2097
  {
2089
2098
  // Sets the default heading size for the Hero based on the variant
2090
- size: variant === 'two-column' ? 'xl' : 'l'
2099
+ size: variant === 'two-column' ? 'xl' : 'l',
2100
+ className: // word-break:break-word to allow long words to break (this is necessary to make hyphens work in grid containers in Safari)
2101
+ 'hyphens-auto text-pretty [word-break:break-word]'
2091
2102
  }
2092
2103
  ],
2093
2104
  [
@@ -2107,7 +2118,7 @@ const Hero = ({ variant, className, children })=>{
2107
2118
  });
2108
2119
  };
2109
2120
 
2110
- const Carousel = ({ className, children })=>{
2121
+ const Carousel = ({ className, children, onChange })=>{
2111
2122
  const ref = useRef(null);
2112
2123
  const locale = _useLocale();
2113
2124
  const { previous, next } = translations$1;
@@ -2120,6 +2131,9 @@ const Carousel = ({ className, children })=>{
2120
2131
  }, [
2121
2132
  scrollTargetIndex
2122
2133
  ]);
2134
+ // Keep track of the previous index to determine if the user is scrolling forward or backward
2135
+ // This is used to determine which callback to call (onPrev or onNext)
2136
+ const prevIndex = useRef(0);
2123
2137
  // Handle scrolling when user clicks the arrow icons
2124
2138
  useUpdateEffect(()=>{
2125
2139
  if (!ref.current) return;
@@ -2128,6 +2142,15 @@ const Carousel = ({ className, children })=>{
2128
2142
  inline: 'start',
2129
2143
  block: 'nearest'
2130
2144
  });
2145
+ if (prevIndex.current !== scrollTargetIndex && onChange) {
2146
+ onChange({
2147
+ index: scrollTargetIndex,
2148
+ id: ref.current.children[scrollTargetIndex]?.id,
2149
+ prevIndex: prevIndex.current,
2150
+ prevId: ref.current.children[prevIndex.current]?.id
2151
+ });
2152
+ }
2153
+ prevIndex.current = scrollTargetIndex;
2131
2154
  }, [
2132
2155
  scrollTargetIndex
2133
2156
  ]);
@@ -2249,18 +2272,18 @@ const CarouselItems = ({ className, children })=>/*#__PURE__*/ jsx(CarouselItems
2249
2272
  children: children
2250
2273
  })
2251
2274
  });
2252
- const CarouselItem = ({ className, children })=>{
2275
+ const CarouselItem = ({ className, children, id })=>{
2253
2276
  return /*#__PURE__*/ jsx("div", {
2254
2277
  className: cx(className, 'shrink-0 basis-full snap-start'),
2255
2278
  "data-slot": "carousel-item",
2279
+ id: id,
2256
2280
  children: /*#__PURE__*/ jsx(Provider, {
2257
2281
  values: [
2258
2282
  [
2259
2283
  MediaContext,
2260
2284
  {
2261
2285
  fit: 'cover',
2262
- className: cx('data-[fit="contain"]:bg-blue-dark', '*:w-full', // biome-ignore lint/nursery/useSortedClasses: biome is unable to sort the custom classes for 3xl and 4xl breakpoints
2263
- '*:h-70 sm:*:h-[25rem] lg:*:h-[35rem] xl:*:h-[40rem] 2xl:*:h-[42rem] 3xl:*:h-[48rem] 4xl:*:h-[53rem]')
2286
+ className: cx('data-[fit="contain"]:bg-blue-dark', '*:h-full *:w-full', 'aspect-1/1 max-sm:data-[fit="contain"]:*:object-cover sm:aspect-4/3 md:aspect-3/2 lg:aspect-2/1')
2264
2287
  }
2265
2288
  ]
2266
2289
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "2.3.2",
3
+ "version": "2.3.4",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"
@@ -35,7 +35,7 @@
35
35
  "react": "^19"
36
36
  },
37
37
  "devDependencies": {
38
- "tailwindcss": "4.1.7"
38
+ "tailwindcss": "4.1.10"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "bunchee"