@obosbbl/grunnmuren-react 3.3.0 → 3.3.2

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
@@ -1,4 +1,4 @@
1
- import { DisclosureProps as DisclosureProps$1, ButtonProps as ButtonProps$1, LinkProps as LinkProps$1, ContextValue, BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, HeadingProps as HeadingProps$1, ListBoxItemProps, ListBoxSectionProps, ComboBoxProps, FileTriggerProps as FileTriggerProps$1, RouterProvider, TextProps, LabelProps, DialogProps as DialogProps$1, DialogTriggerProps as DialogTriggerProps$1, ModalOverlayProps, NumberFieldProps as NumberFieldProps$1, RadioProps as RadioProps$1, RadioGroupProps as RadioGroupProps$1, SelectProps as SelectProps$1, ColumnResizerProps, TableProps as TableProps$1, TableBodyProps as TableBodyProps$1, CellProps, ColumnProps, ResizableTableContainerProps, TableHeaderProps as TableHeaderProps$1, RowProps, TabProps as TabProps$1, TabListProps as TabListProps$1, TabPanelProps as TabPanelProps$1, TabsProps as TabsProps$1, TagGroupProps as TagGroupProps$1, TagListProps as TagListProps$1, TagProps as TagProps$1, TextFieldProps as TextFieldProps$1 } from 'react-aria-components';
1
+ import { DisclosureProps as DisclosureProps$1, ButtonProps as ButtonProps$1, LinkProps as LinkProps$1, ContextValue, BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, HeadingProps as HeadingProps$1, ListBoxItemProps, ListBoxSectionProps, ComboBoxProps, FileTriggerProps as FileTriggerProps$1, RouterProvider, TextProps, LabelProps, DialogProps as DialogProps$1, DialogTriggerProps as DialogTriggerProps$1, ModalOverlayProps as ModalOverlayProps$1, NumberFieldProps as NumberFieldProps$1, ProgressBarProps as ProgressBarProps$1, RadioProps as RadioProps$1, RadioGroupProps as RadioGroupProps$1, SelectProps as SelectProps$1, ColumnResizerProps, TableProps as TableProps$1, TableBodyProps as TableBodyProps$1, CellProps, ColumnProps, ResizableTableContainerProps, TableHeaderProps as TableHeaderProps$1, RowProps, TabProps as TabProps$1, TabListProps as TabListProps$1, TabPanelProps as TabPanelProps$1, TabsProps as TabsProps$1, TagGroupProps as TagGroupProps$1, TagListProps as TagListProps$1, TagProps as TagProps$1, TextFieldProps as TextFieldProps$1 } from 'react-aria-components';
2
2
  export { ListBoxItemProps as ComboboxItemProps, DisclosureGroup, DisclosureGroupProps, Form, Group, LabelProps, ListBoxItemProps as SelectItemProps } from 'react-aria-components';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
@@ -456,8 +456,14 @@ declare const LinkListItem: (props: LinkListItemProps) => react_jsx_runtime.JSX.
456
456
 
457
457
  type DialogTriggerProps = DialogTriggerProps$1;
458
458
  declare const DialogTrigger: (props: DialogTriggerProps) => react_jsx_runtime.JSX.Element;
459
- type ModalProps = Omit<ModalOverlayProps, 'isDismissable'>;
460
- declare const Modal: ({ className, ...restProps }: ModalProps) => react_jsx_runtime.JSX.Element;
459
+ type ModalOverlayProps = Omit<ModalOverlayProps$1, 'isDismissable'> & {
460
+ /** @default 10 Controls the z-index of the modal overlay */
461
+ zIndex?: number;
462
+ /** @default true Makes the modal dismissable */
463
+ isDismissable?: boolean;
464
+ };
465
+ type ModalProps = ModalOverlayProps;
466
+ declare const Modal: ({ isDismissable, isOpen, onOpenChange, defaultOpen, className, zIndex, ...restProps }: ModalProps) => react_jsx_runtime.JSX.Element;
461
467
  type DialogProps = DialogProps$1 & {
462
468
  children: React.ReactNode;
463
469
  };
@@ -498,6 +504,13 @@ type NumberFieldProps = {
498
504
  } & Omit<NumberFieldProps$1, 'className' | 'isReadOnly' | 'isDisabled' | 'children' | 'style' | 'hideStepper'>;
499
505
  declare function NumberField(props: NumberFieldProps): react_jsx_runtime.JSX.Element;
500
506
 
507
+ type ProgressBarProps = ProgressBarProps$1;
508
+ type ProgressBarValueTextProps = Omit<HTMLProps<HTMLSpanElement>, 'children'> & {
509
+ className?: string;
510
+ };
511
+ declare const ProgressBarValueText: ({ className, ...restProps }: ProgressBarValueTextProps) => react_jsx_runtime.JSX.Element;
512
+ declare const ProgressBar: ({ children, className, ...restProps }: ProgressBarProps) => react_jsx_runtime.JSX.Element;
513
+
501
514
  type RadioProps = {
502
515
  children: React.ReactNode;
503
516
  /** Additional CSS className for the element. */
@@ -745,5 +758,5 @@ type VideoLoopProps = {
745
758
  };
746
759
  declare const VideoLoop: ({ src, format, alt, className }: VideoLoopProps) => react_jsx_runtime.JSX.Element;
747
760
 
748
- export { Accordion, AccordionItem, Alertbox, Avatar, Backlink, Badge, Breadcrumb, Breadcrumbs, Button, ButtonContext, Caption, Card, CardLink, Checkbox, CheckboxGroup, Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, Content, ContentContext, DateFormatter, Description, Disclosure, DisclosureButton, DisclosurePanel, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, LinkList, LinkListContainer, LinkListItem, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, Link as UNSAFE_Link, Modal as UNSAFE_Modal, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, TabPanel as UNSAFE_TabPanel, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, TableCell as UNSAFE_TableCell, TableColumn as UNSAFE_TableColumn, TableColumnResizer as UNSAFE_TableColumnResizer, TableContainer as UNSAFE_TableContainer, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, Tabs as UNSAFE_Tabs, VideoLoop, _LinkContext, _useLocale as useLocale };
749
- export type { AccordionItemProps, AccordionProps, Props as AlertboxProps, AvatarProps, BacklinkProps, BadgeProps, BreadcrumbProps, BreadcrumbsProps, ButtonProps, CaptionProps, CardLinkProps, CardProps, CheckboxGroupProps, CheckboxProps, ComboboxProps, ContentProps, DateFormatterProps, DescriptionProps, DisclosureButtonProps, DisclosurePanelProps, DisclosureProps, ErrorMessageProps, FooterProps, GrunnmurenProviderProps, HeadingProps, LinkListContainerProps, LinkListItemProps, LinkListProps, Locale, MediaProps, NumberFieldProps, RadioGroupProps, RadioProps, SelectProps, TagGroupProps, TagListProps, TagProps, TextAreaProps, TextFieldProps, CarouselItemProps as UNSAFE_CarouselItemProps, CarouselItemsProps as UNSAFE_CarouselItemsProps, CarouselProps as UNSAFE_CarouselProps, DialogProps as UNSAFE_DialogProps, DialogTriggerProps as UNSAFE_DialogTriggerProps, FileUploadProps as UNSAFE_FileUploadProps, HeroProps as UNSAFE_HeroProps, LinkProps as UNSAFE_LinkProps, ModalProps as UNSAFE_ModalProps, TabListProps as UNSAFE_TabListProps, TabPanelProps as UNSAFE_TabPanelProps, TabProps as UNSAFE_TabProps, TableBodyProps as UNSAFE_TableBodyProps, TableCellProps as UNSAFE_TableCellProps, TableColumnProps as UNSAFE_TableColumnProps, TableColumnResizerProps as UNSAFE_TableColumnResizerProps, TableContainerProps as UNSAFE_TableContainerProps, TableHeaderProps as UNSAFE_TableHeaderProps, TableProps as UNSAFE_TableProps, TableRowProps as UNSAFE_TableRowProps, TabsProps as UNSAFE_TabsProps };
761
+ export { Accordion, AccordionItem, Alertbox, Avatar, Backlink, Badge, Breadcrumb, Breadcrumbs, Button, ButtonContext, Caption, Card, CardLink, Checkbox, CheckboxGroup, Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, Content, ContentContext, DateFormatter, Description, Disclosure, DisclosureButton, DisclosurePanel, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, LinkList, LinkListContainer, LinkListItem, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, Link as UNSAFE_Link, Modal as UNSAFE_Modal, ProgressBar as UNSAFE_ProgressBar, ProgressBarValueText as UNSAFE_ProgressBarValueText, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, TabPanel as UNSAFE_TabPanel, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, TableCell as UNSAFE_TableCell, TableColumn as UNSAFE_TableColumn, TableColumnResizer as UNSAFE_TableColumnResizer, TableContainer as UNSAFE_TableContainer, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, Tabs as UNSAFE_Tabs, VideoLoop, _LinkContext, _useLocale as useLocale };
762
+ export type { AccordionItemProps, AccordionProps, Props as AlertboxProps, AvatarProps, BacklinkProps, BadgeProps, BreadcrumbProps, BreadcrumbsProps, ButtonProps, CaptionProps, CardLinkProps, CardProps, CheckboxGroupProps, CheckboxProps, ComboboxProps, ContentProps, DateFormatterProps, DescriptionProps, DisclosureButtonProps, DisclosurePanelProps, DisclosureProps, ErrorMessageProps, FooterProps, GrunnmurenProviderProps, HeadingProps, LinkListContainerProps, LinkListItemProps, LinkListProps, Locale, MediaProps, NumberFieldProps, RadioGroupProps, RadioProps, SelectProps, TagGroupProps, TagListProps, TagProps, TextAreaProps, TextFieldProps, CarouselItemProps as UNSAFE_CarouselItemProps, CarouselItemsProps as UNSAFE_CarouselItemsProps, CarouselProps as UNSAFE_CarouselProps, DialogProps as UNSAFE_DialogProps, DialogTriggerProps as UNSAFE_DialogTriggerProps, FileUploadProps as UNSAFE_FileUploadProps, HeroProps as UNSAFE_HeroProps, LinkProps as UNSAFE_LinkProps, ModalProps as UNSAFE_ModalProps, ProgressBarProps as UNSAFE_ProgressBarProps, ProgressBarValueTextProps as UNSAFE_ProgressBarValueTextProps, TabListProps as UNSAFE_TabListProps, TabPanelProps as UNSAFE_TabPanelProps, TabProps as UNSAFE_TabProps, TableBodyProps as UNSAFE_TableBodyProps, TableCellProps as UNSAFE_TableCellProps, TableColumnProps as UNSAFE_TableColumnProps, TableColumnResizerProps as UNSAFE_TableColumnResizerProps, TableContainerProps as UNSAFE_TableContainerProps, TableHeaderProps as UNSAFE_TableHeaderProps, TableProps as UNSAFE_TableProps, TableRowProps as UNSAFE_TableRowProps, TabsProps as UNSAFE_TabsProps };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useContextProps, DisclosureContext, DisclosureGroupStateContext, Provider, ButtonContext as ButtonContext$1, DEFAULT_SLOT, Button as Button$1, useLocale, Link as Link$1, Breadcrumb as Breadcrumb$1, Breadcrumbs as Breadcrumbs$1, Text, CheckboxContext, Checkbox as Checkbox$1, FieldError, Label as Label$1, CheckboxGroup as CheckboxGroup$1, Header, ListBoxItem as ListBoxItem$1, ListBoxSection as ListBoxSection$1, ListBox as ListBox$1, ComboBox, Group, Input, Popover, useSlottedContext, FormContext, FieldErrorContext, LabelContext, InputContext, I18nProvider, RouterProvider, GroupContext, Dialog as Dialog$1, DialogTrigger as DialogTrigger$1, Modal as Modal$1, ModalOverlay as ModalOverlay$1, NumberField as NumberField$1, Radio as Radio$1, RadioGroup as RadioGroup$1, Select as Select$1, SelectValue, ColumnResizer, Table as Table$1, TableBody as TableBody$1, Cell, Column, ResizableTableContainer, TableHeader as TableHeader$1, Row, Tab as Tab$1, TabListStateContext, TabList as TabList$1, TabPanel as TabPanel$1, Tabs as Tabs$1, TagGroup as TagGroup$1, TagList as TagList$1, Tag as Tag$1, TextField as TextField$1, TextArea as TextArea$1 } from 'react-aria-components';
2
+ import { useContextProps, DisclosureContext, DisclosureGroupStateContext, Provider, ButtonContext as ButtonContext$1, DEFAULT_SLOT, Button as Button$1, useLocale, Link as Link$1, Breadcrumb as Breadcrumb$1, Breadcrumbs as Breadcrumbs$1, Text, CheckboxContext, Checkbox as Checkbox$1, FieldError, Label as Label$1, CheckboxGroup as CheckboxGroup$1, Header, ListBoxItem as ListBoxItem$1, ListBoxSection as ListBoxSection$1, ListBox as ListBox$1, ComboBox, Group, Input, Popover, useSlottedContext, FormContext, FieldErrorContext, LabelContext, InputContext, I18nProvider, RouterProvider, GroupContext, Dialog as Dialog$1, DialogTrigger as DialogTrigger$1, Modal as Modal$1, ModalOverlay, NumberField as NumberField$1, ProgressBar as ProgressBar$1, Radio as Radio$1, RadioGroup as RadioGroup$1, Select as Select$1, SelectValue, ColumnResizer, Table as Table$1, TableBody as TableBody$1, Cell, Column, ResizableTableContainer, TableHeader as TableHeader$1, Row, Tab as Tab$1, TabListStateContext, TabList as TabList$1, TabPanel as TabPanel$1, Tabs as Tabs$1, TagGroup as TagGroup$1, TagList as TagList$1, Tag as Tag$1, TextField as TextField$1, TextArea as TextArea$1 } from 'react-aria-components';
3
3
  export { DisclosureGroup, Form, Group } from 'react-aria-components';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { cva, cx, compose } from 'cva';
@@ -279,6 +279,7 @@ function AccordionItem(props) {
279
279
  const _defaultExpanded = defaultOpen ?? defaultExpanded;
280
280
  const _isExpanded = controlledIsOpen ?? isExpanded;
281
281
  const _onExpandedChange = onOpenChange ?? onExpandedChange;
282
+ const buttonId = useId();
282
283
  return /*#__PURE__*/ jsx(Disclosure, {
283
284
  ...restProps,
284
285
  className: cx('relative px-2', className),
@@ -299,6 +300,7 @@ function AccordionItem(props) {
299
300
  className: "flex min-h-11 w-full gap-1.5 rounded-lg px-2 py-3.5 text-left focus-visible:outline-focus-inset!",
300
301
  type: "button",
301
302
  withChevron: true,
303
+ id: buttonId,
302
304
  children: children
303
305
  })
304
306
  }
@@ -308,8 +310,9 @@ function AccordionItem(props) {
308
310
  {
309
311
  className: // Uses pseudo elements for vertical padding, since that doesn't affect the height when the accordion is closed
310
312
  'text-sm font-light leading-6 px-3.5 data-[expanded]:after:h-3.5 relative overflow-hidden border-sky border-l-[3px] before:relative before:block before:h-1.5 after:relative after:block after:h-1.5',
311
- role: 'region',
312
313
  _outerWrapper: (children)=>/*#__PURE__*/ jsx(DisclosurePanel, {
314
+ "aria-labelledby": buttonId,
315
+ role: "region",
313
316
  children: children
314
317
  })
315
318
  }
@@ -972,6 +975,27 @@ const cardLinkVariants = cva({
972
975
  });
973
976
  };
974
977
 
978
+ /**
979
+ * Hook that detects the user's preference for reduced motion.
980
+ *
981
+ * Keep in mind that this hook relies on a browser API's and doesn't run on the server.
982
+ * You can supply an initial value that will be used for server side rendering.
983
+ */ function usePrefersReducedMotion(initialValue = true) {
984
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(initialValue);
985
+ useEffect(()=>{
986
+ const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
987
+ setPrefersReducedMotion(mediaQuery.matches);
988
+ const changeListener = (event)=>{
989
+ setPrefersReducedMotion(event.matches);
990
+ };
991
+ mediaQuery.addEventListener('change', changeListener);
992
+ return ()=>{
993
+ mediaQuery.removeEventListener('change', changeListener);
994
+ };
995
+ }, []);
996
+ return prefersReducedMotion;
997
+ }
998
+
975
999
  const Carousel = ({ className, children, onChange, ...rest })=>{
976
1000
  const carouselRef = useRef(null);
977
1001
  const carouselItemsRef = useRef(null);
@@ -983,6 +1007,7 @@ const Carousel = ({ className, children, onChange, ...rest })=>{
983
1007
  const scrollQueue = useRef([]);
984
1008
  const [hasReachedScrollStart, setHasReachedScrollStart] = useState(scrollTargetIndex === 0);
985
1009
  const [hasReachedScrollEnd, setHasReachedScrollEnd] = useState(!carouselItemsRef.current || carouselItemsRef.current.children.length - 1 === scrollTargetIndex);
1010
+ const prefersReducedMotion = usePrefersReducedMotion();
986
1011
  useEffect(()=>{
987
1012
  setHasReachedScrollStart(scrollTargetIndex === 0);
988
1013
  setHasReachedScrollEnd(!carouselItemsRef.current || carouselItemsRef.current.children.length - 1 === scrollTargetIndex);
@@ -1014,7 +1039,6 @@ const Carousel = ({ className, children, onChange, ...rest })=>{
1014
1039
  }
1015
1040
  isScrollingProgrammatically.current = true;
1016
1041
  const elementWithFocusVisible = carouselRef.current?.querySelector(':focus-visible');
1017
- const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
1018
1042
  carouselItemsRef.current.children[scrollTargetIndex]?.scrollIntoView({
1019
1043
  behavior: prefersReducedMotion ? 'instant' : 'smooth',
1020
1044
  inline: 'start',
@@ -1063,7 +1087,8 @@ const Carousel = ({ className, children, onChange, ...rest })=>{
1063
1087
  processQueue(); // Process any queued scrolls
1064
1088
  }, 500);
1065
1089
  }, [
1066
- scrollTargetIndex
1090
+ scrollTargetIndex,
1091
+ prefersReducedMotion
1067
1092
  ]);
1068
1093
  // Clean up timeout on unmount
1069
1094
  useEffect(()=>{
@@ -1218,16 +1243,7 @@ const CarouselItemsContext = /*#__PURE__*/ createContext({
1218
1243
  });
1219
1244
  const CarouselItems = ({ className, children })=>{
1220
1245
  const { carouselItemsRef, onScroll, activeIndex, handlePrevious, handleNext } = useContext(CarouselItemsContext);
1221
- const prefersReducedMotion = useRef(window.matchMedia('(prefers-reduced-motion: reduce)').matches);
1222
- // Update the ref when the media query changes
1223
- useEffect(()=>{
1224
- const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
1225
- const handleChange = (e)=>{
1226
- prefersReducedMotion.current = e.matches;
1227
- };
1228
- mediaQuery.addEventListener('change', handleChange);
1229
- return ()=>mediaQuery.removeEventListener('change', handleChange);
1230
- }, []);
1246
+ const prefersReducedMotion = usePrefersReducedMotion();
1231
1247
  const handleKeyDown = (event)=>{
1232
1248
  // Prevent default behavior when holding down arrow keys (when repeat is true)
1233
1249
  // The default behavior in scroll snapping causes a staggering scroll effect that feels janky
@@ -1236,7 +1252,7 @@ const CarouselItems = ({ className, children })=>{
1236
1252
  return;
1237
1253
  }
1238
1254
  // For users with prefers-reduced-motion, trigger button click behavior instead of native scroll
1239
- if (prefersReducedMotion.current) {
1255
+ if (prefersReducedMotion) {
1240
1256
  if (event.key === 'ArrowLeft' && handlePrevious) {
1241
1257
  event.preventDefault();
1242
1258
  handlePrevious();
@@ -2031,52 +2047,66 @@ const LinkListItem = (props)=>/*#__PURE__*/ jsx("li", {
2031
2047
  const DialogTrigger = (props)=>/*#__PURE__*/ jsx(DialogTrigger$1, {
2032
2048
  ...props
2033
2049
  });
2034
- const ModalOverlay = (props)=>/*#__PURE__*/ jsx(ModalOverlay$1, {
2035
- ...props,
2036
- isDismissable: true,
2037
- className: ({ isEntering, isExiting })=>cx('fixed inset-0 z-10 flex min-h-full items-center justify-center overflow-y-auto bg-black/25 p-4 text-center backdrop-blur-sm', isEntering && 'fade-in animate-in duration-300 ease-out', isExiting && 'fade-out animate-out duration-200 ease-in', // Using the motion-safe class does not work, so we use motion-reduce to overwrite instead
2038
- 'motion-reduce:animate-none')
2050
+ const _ModalOverlay = ({ style = {}, zIndex = 10, ...restProps })=>/*#__PURE__*/ jsx(ModalOverlay, {
2051
+ ...restProps,
2052
+ className: ({ isEntering, isExiting })=>cx('fixed inset-0 flex min-h-full items-center justify-center overflow-y-auto bg-black/25 p-4 text-center backdrop-blur-sm', isEntering && 'fade-in animate-in duration-300 ease-out', isExiting && 'fade-out animate-out duration-200 ease-in', // Using the motion-safe class does not work, so we use motion-reduce to overwrite instead
2053
+ 'motion-reduce:animate-none'),
2054
+ style: {
2055
+ zIndex,
2056
+ ...style
2057
+ }
2039
2058
  });
2040
- const Modal = ({ className, ...restProps })=>/*#__PURE__*/ jsx(ModalOverlay, {
2041
- children: /*#__PURE__*/ jsx(Modal$1, {
2042
- ...restProps,
2043
- className: ({ isEntering, isExiting })=>cx(className, 'w-full max-w-md overflow-hidden rounded-2xl bg-white p-4 text-left align-middle shadow-xl', isEntering && 'zoom-in-95 animate-in duration-300 ease-out', isExiting && 'zoom-out-95 animate-out duration-200 ease-in', // Using the motion-safe class does not work, so we use motion-reduce to overwrite instead
2044
- 'motion-reduce:animate-none')
2059
+ const Modal = ({ isDismissable = true, isOpen, onOpenChange, defaultOpen, className, zIndex, ...restProps })=>{
2060
+ const locale = _useLocale();
2061
+ return /*#__PURE__*/ jsx(Provider, {
2062
+ values: [
2063
+ [
2064
+ HeadingContext,
2065
+ {
2066
+ slots: {
2067
+ [DEFAULT_SLOT]: {},
2068
+ title: {
2069
+ className: 'heading-s',
2070
+ _outerWrapper: (children)=>/*#__PURE__*/ jsxs("div", {
2071
+ className: "flex items-center justify-between gap-x-2",
2072
+ children: [
2073
+ children,
2074
+ isDismissable && /*#__PURE__*/ jsx(Button, {
2075
+ slot: "close",
2076
+ variant: "tertiary",
2077
+ className: "px-2.5! data-focus-visible:outline-focus-inset",
2078
+ "aria-label": translations$1.close[locale],
2079
+ onPress: ()=>onOpenChange?.(false),
2080
+ children: /*#__PURE__*/ jsx(Close, {})
2081
+ })
2082
+ ]
2083
+ })
2084
+ }
2085
+ }
2086
+ }
2087
+ ]
2088
+ ],
2089
+ children: /*#__PURE__*/ jsx(_ModalOverlay, {
2090
+ isOpen: isOpen,
2091
+ onOpenChange: onOpenChange,
2092
+ defaultOpen: defaultOpen,
2093
+ isDismissable: isDismissable,
2094
+ zIndex: zIndex,
2095
+ children: /*#__PURE__*/ jsx(Modal$1, {
2096
+ ...restProps,
2097
+ className: ({ isEntering, isExiting })=>cx(className, 'w-full max-w-md overflow-hidden rounded-2xl bg-white p-4 text-left align-middle shadow-xl', isEntering && 'zoom-in-95 animate-in duration-300 ease-out', isExiting && 'zoom-out-95 animate-out duration-200 ease-in', // Using the motion-safe class does not work, so we use motion-reduce to overwrite instead
2098
+ 'motion-reduce:animate-none')
2099
+ })
2045
2100
  })
2046
2101
  });
2047
- const Dialog = ({ className, children, ...restProps })=>{
2048
- const locale = _useLocale();
2049
- return /*#__PURE__*/ jsx(Dialog$1, {
2102
+ };
2103
+ const Dialog = ({ className, children, ...restProps })=>/*#__PURE__*/ jsx(Dialog$1, {
2050
2104
  ...restProps,
2051
2105
  className: cx('relative grid gap-y-5 outline-none', // Footer
2052
2106
  '[&_[data-slot="footer"]]:flex [&_[data-slot="footer"]]:gap-x-2'),
2053
2107
  children: ({ close })=>/*#__PURE__*/ jsx(Fragment, {
2054
2108
  children: /*#__PURE__*/ jsx(Provider, {
2055
2109
  values: [
2056
- [
2057
- HeadingContext,
2058
- {
2059
- slots: {
2060
- [DEFAULT_SLOT]: {},
2061
- title: {
2062
- className: 'heading-s',
2063
- _outerWrapper: (children)=>/*#__PURE__*/ jsxs("div", {
2064
- className: "flex items-center justify-between gap-x-2",
2065
- children: [
2066
- children,
2067
- /*#__PURE__*/ jsx(Button, {
2068
- slot: "close",
2069
- variant: "tertiary",
2070
- className: "!px-2.5 data-focus-visible:outline-focus-inset",
2071
- "aria-label": translations$1.close[locale],
2072
- children: /*#__PURE__*/ jsx(Close, {})
2073
- })
2074
- ]
2075
- })
2076
- }
2077
- }
2078
- }
2079
- ],
2080
2110
  [
2081
2111
  ButtonContext$1,
2082
2112
  {
@@ -2098,7 +2128,6 @@ const Dialog = ({ className, children, ...restProps })=>{
2098
2128
  })
2099
2129
  })
2100
2130
  });
2101
- };
2102
2131
 
2103
2132
  // This component is based on a copy of ../textfield/TextField, refactoring is TBD: https://github.com/code-obos/grunnmuren/pull/722#issuecomment-1931478786
2104
2133
  const inputVariants$1 = compose(input, cva({
@@ -2164,6 +2193,44 @@ function NumberField(props) {
2164
2193
  });
2165
2194
  }
2166
2195
 
2196
+ const _ProgressBarValueTextContext = /*#__PURE__*/ createContext(undefined);
2197
+ const _ProgressBarValueTextProvider = _ProgressBarValueTextContext.Provider;
2198
+ const ProgressBarValueText = ({ className, ...restProps })=>{
2199
+ const value = useContext(_ProgressBarValueTextContext);
2200
+ return /*#__PURE__*/ jsx("span", {
2201
+ ...restProps,
2202
+ className: cx(className, 'px-2 leading-7'),
2203
+ "data-slot": "progress-bar-value-text",
2204
+ children: value
2205
+ });
2206
+ };
2207
+ const ProgressBar = ({ children, className, ...restProps })=>{
2208
+ return /*#__PURE__*/ jsx(ProgressBar$1, {
2209
+ "data-slot": "progress-bar",
2210
+ ...restProps,
2211
+ className: cx(className, 'max-w-full'),
2212
+ children: ({ percentage, valueText, ...restArgs })=>/*#__PURE__*/ jsxs(_ProgressBarValueTextProvider, {
2213
+ value: valueText,
2214
+ children: [
2215
+ typeof children === 'function' ? children({
2216
+ percentage,
2217
+ valueText,
2218
+ ...restArgs
2219
+ }) : children,
2220
+ /*#__PURE__*/ jsx("div", {
2221
+ className: "relative h-0.75 rounded bg-gray-light",
2222
+ children: /*#__PURE__*/ jsx("div", {
2223
+ className: "h-0.75 rounded bg-blue-dark transition-all duration-300 ease-in-out",
2224
+ style: {
2225
+ width: `${percentage}%`
2226
+ }
2227
+ })
2228
+ })
2229
+ ]
2230
+ })
2231
+ });
2232
+ };
2233
+
2167
2234
  const defaultClasses = cx([
2168
2235
  '-ml-2.5 relative inline-flex max-w-fit cursor-pointer items-start gap-4 py-2.5 pl-2.5 leading-7',
2169
2236
  // the radio button itself
@@ -2814,15 +2881,14 @@ const VideoLoop = ({ src, format, alt, className })=>{
2814
2881
  const [shouldPlay, setShouldPlay] = useState(false);
2815
2882
  // Needed to show the pause button when the video is actually playing (refer to google's autoplay policy: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes)
2816
2883
  const [isPlaying, setIsPlaying] = useState(false);
2817
- // We need to check if the user prefers reduced motion, so that we can prevent the video from autoplaying if so
2818
- const [userPrefersReducedMotion, setUserPrefersReducedMotion] = useState(null);
2884
+ const prefersReducedMotion = usePrefersReducedMotion(null);
2819
2885
  const videoRef = useRef(null);
2820
2886
  useEffect(()=>{
2821
- const { matches: userPrefersReducedMotion } = matchMedia('(prefers-reduced-motion: reduce)');
2822
- setUserPrefersReducedMotion(userPrefersReducedMotion);
2823
2887
  // Autoplay the video if the user does not prefer reduced motion
2824
- setShouldPlay(!userPrefersReducedMotion);
2825
- }, []);
2888
+ setShouldPlay(!prefersReducedMotion);
2889
+ }, [
2890
+ prefersReducedMotion
2891
+ ]);
2826
2892
  // Follow google's autoplay policy: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
2827
2893
  // "Don't assume a video will play, and don't show a pause button when the video is not actually playing."
2828
2894
  // "You should always look at the Promise returned by the play function to see if it was rejected:"
@@ -2839,7 +2905,7 @@ const VideoLoop = ({ src, format, alt, className })=>{
2839
2905
  shouldPlay
2840
2906
  ]);
2841
2907
  return /*#__PURE__*/ jsxs("div", {
2842
- className: cx(className, 'relative', userPrefersReducedMotion === null && 'opacity-0'),
2908
+ className: cx(className, 'relative', prefersReducedMotion === null && 'opacity-0'),
2843
2909
  children: [
2844
2910
  /*#__PURE__*/ jsx("video", {
2845
2911
  "aria-hidden": true,
@@ -2847,11 +2913,11 @@ const VideoLoop = ({ src, format, alt, className })=>{
2847
2913
  // cursor-pointer is not working on the button below, so we add it here for the same effect
2848
2914
  className: "h-full max-h-[inherit] w-full cursor-pointer rounded-[inherit] object-cover",
2849
2915
  playsInline: true,
2850
- loop: userPrefersReducedMotion === false,
2851
- autoPlay: userPrefersReducedMotion === false,
2916
+ loop: prefersReducedMotion === false,
2917
+ autoPlay: prefersReducedMotion === false,
2852
2918
  muted: true,
2853
2919
  onEnded: (event)=>{
2854
- if (userPrefersReducedMotion) {
2920
+ if (prefersReducedMotion) {
2855
2921
  // Reset the video to the beginning if the user prefers reduced motion, since the video will not loop
2856
2922
  event.currentTarget.currentTime = 0;
2857
2923
  setShouldPlay(false);
@@ -2863,7 +2929,7 @@ const VideoLoop = ({ src, format, alt, className })=>{
2863
2929
  type: `video/${format}`
2864
2930
  })
2865
2931
  }),
2866
- userPrefersReducedMotion !== null && /*#__PURE__*/ jsx("button", {
2932
+ prefersReducedMotion !== null && /*#__PURE__*/ jsx("button", {
2867
2933
  "data-slot": "video-loop-button",
2868
2934
  "aria-hidden": true,
2869
2935
  type: "button",
@@ -2888,4 +2954,4 @@ const VideoLoop = ({ src, format, alt, className })=>{
2888
2954
  });
2889
2955
  };
2890
2956
 
2891
- export { Accordion, AccordionItem, Alertbox, Avatar, Backlink, Badge, Breadcrumb, Breadcrumbs, Button, ButtonContext, Caption, Card, CardLink, Checkbox, CheckboxGroup, Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, Content, ContentContext, DateFormatter, Description, Disclosure, DisclosureButton, DisclosurePanel, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, LinkList, LinkListContainer, LinkListItem, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, Link as UNSAFE_Link, Modal as UNSAFE_Modal, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, TabPanel as UNSAFE_TabPanel, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, TableCell as UNSAFE_TableCell, TableColumn as UNSAFE_TableColumn, TableColumnResizer as UNSAFE_TableColumnResizer, TableContainer as UNSAFE_TableContainer, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, Tabs as UNSAFE_Tabs, VideoLoop, _LinkContext, _useLocale as useLocale };
2957
+ export { Accordion, AccordionItem, Alertbox, Avatar, Backlink, Badge, Breadcrumb, Breadcrumbs, Button, ButtonContext, Caption, Card, CardLink, Checkbox, CheckboxGroup, Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, Content, ContentContext, DateFormatter, Description, Disclosure, DisclosureButton, DisclosurePanel, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, LinkList, LinkListContainer, LinkListItem, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, Link as UNSAFE_Link, Modal as UNSAFE_Modal, ProgressBar as UNSAFE_ProgressBar, ProgressBarValueText as UNSAFE_ProgressBarValueText, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, TabPanel as UNSAFE_TabPanel, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, TableCell as UNSAFE_TableCell, TableColumn as UNSAFE_TableColumn, TableColumnResizer as UNSAFE_TableColumnResizer, TableContainer as UNSAFE_TableContainer, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, Tabs as UNSAFE_Tabs, VideoLoop, _LinkContext, _useLocale as useLocale };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"