@obosbbl/grunnmuren-react 3.4.6 → 3.5.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/index.d.mts CHANGED
@@ -27,7 +27,7 @@ import { ModalOverlayProps as ModalOverlayProps$1 } from 'react-aria-components/
27
27
  import { NumberFieldProps as NumberFieldProps$1 } from 'react-aria-components/NumberField';
28
28
  import { RadioProps as RadioProps$1, RadioGroupProps as RadioGroupProps$1 } from 'react-aria-components/RadioGroup';
29
29
  import { SelectProps as SelectProps$1 } from 'react-aria-components/Select';
30
- import { ColumnResizerProps, TableProps as TableProps$1, TableBodyProps as TableBodyProps$1, CellProps, ColumnProps, ResizableTableContainerProps, TableHeaderProps as TableHeaderProps$1, RowProps } from 'react-aria-components/Table';
30
+ import { ColumnResizerProps, TableProps as TableProps$1, TableBodyProps as TableBodyProps$1, CellProps, ColumnProps, ResizableTableContainerProps as ResizableTableContainerProps$1, TableHeaderProps as TableHeaderProps$1, RowProps } from 'react-aria-components/Table';
31
31
  import { TabProps as TabProps$1, TabListProps as TabListProps$1, TabPanelProps as TabPanelProps$1, TabsProps as TabsProps$1 } from 'react-aria-components/Tabs';
32
32
  import { TagGroupProps as TagGroupProps$1, TagListProps as TagListProps$1, TagProps as TagProps$1 } from 'react-aria-components/TagGroup';
33
33
  import { TextFieldProps as TextFieldProps$1 } from 'react-aria-components/TextField';
@@ -179,10 +179,8 @@ declare const linkVariants: (props?: (((VariantProps<(props?: ({
179
179
  })) | undefined) => string;
180
180
  type LinkProps = VariantProps<typeof linkVariants> & LinkProps$1 & React.RefAttributes<HTMLAnchorElement> & {
181
181
  children?: React.ReactNode;
182
- /** @private Internal use */
183
- '~iconRight'?: React.ReactNode;
184
182
  };
185
- declare const Link: ({ animateIcon, children, className, "~iconRight": iconRight, ...props }: LinkProps) => react_jsx_runtime.JSX.Element;
183
+ declare const Link: ({ animateIcon, children, className, ...props }: LinkProps) => react_jsx_runtime.JSX.Element;
186
184
 
187
185
  type BreadcrumbProps = {
188
186
  /** Additional CSS className for the element. */
@@ -562,6 +560,10 @@ declare function ErrorMessage(props: ErrorMessageProps): react_jsx_runtime.JSX.E
562
560
 
563
561
  declare function Label(props: LabelProps): react_jsx_runtime.JSX.Element;
564
562
 
563
+ type LinkListContextValue = {
564
+ shouldRenderAutoIcons: boolean;
565
+ };
566
+ declare const LinkListContext: react.Context<LinkListContextValue | null>;
565
567
  declare const linkListContainerVariants: (props?: ({
566
568
  layout?: "stack" | "grid" | undefined;
567
569
  } & ({
@@ -578,7 +580,7 @@ declare const LinkListContainer: ({ className, layout, ...props }: LinkListConta
578
580
  type LinkListProps = React.HTMLProps<HTMLUListElement> & {
579
581
  children: JSX.Element | JSX.Element[];
580
582
  };
581
- declare const LinkList: ({ className, ...restProps }: LinkListProps) => react_jsx_runtime.JSX.Element;
583
+ declare const LinkList: ({ className, children, ...restProps }: LinkListProps) => react_jsx_runtime.JSX.Element;
582
584
  type LinkListItemProps = React.HTMLProps<HTMLLIElement> & {
583
585
  children: ReactNode;
584
586
  };
@@ -712,12 +714,13 @@ type StepProps = HTMLProps<HTMLLIElement> & {
712
714
  };
713
715
  declare const Step: ({ isDisabled, state, children, "~stepIndex": stepIndex, progress, ...restProps }: StepProps) => react_jsx_runtime.JSX.Element;
714
716
 
717
+ type TableVariant = 'default' | 'zebra-striped';
715
718
  type TableProps = Omit<TableProps$1, 'aria-label' | 'aria-labelledby'> & RefAttributes<HTMLTableElement> & {
716
719
  /**
717
720
  * Visual variant of the table
718
721
  * @default 'default'
719
722
  */
720
- variant?: 'default' | 'zebra-striped';
723
+ variant?: TableVariant;
721
724
  } & ({
722
725
  'aria-label': string;
723
726
  'aria-labelledby'?: never;
@@ -734,16 +737,23 @@ type TableRowProps = RowProps<object> & RefAttributes<HTMLTableRowElement>;
734
737
  type TableCellProps = CellProps & RefAttributes<HTMLTableCellElement> & {
735
738
  children: React.ReactNode;
736
739
  };
740
+ type TableColumnResizerProps = ColumnResizerProps;
741
+ type ResizableTableContainerProps = ResizableTableContainerProps$1;
737
742
  /**
738
743
  * A container component for displaying tabular data with horizontal scrolling support.
739
744
  */
740
745
  declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
746
+ /**
747
+ * Container that enables column resizing and horizontal scrolling for the
748
+ * nested <Table>. Use when you want resizable columns or want to apply
749
+ * `maxWidth`/`minWidth` truncation on columns.
750
+ */
751
+ declare function ResizableTableContainer({ className, children, ...restProps }: ResizableTableContainerProps): react_jsx_runtime.JSX.Element;
741
752
  /**
742
753
  * Container for table column headers.
743
754
  */
744
755
  declare function TableHeader({ className, children, ...restProps }: TableHeaderProps): react_jsx_runtime.JSX.Element;
745
756
  declare function TableColumn(props: TableColumnProps): react_jsx_runtime.JSX.Element;
746
- type TableColumnResizerProps = ColumnResizerProps;
747
757
  declare const TableColumnResizer: ({ className, ...restProps }: TableColumnResizerProps) => react_jsx_runtime.JSX.Element;
748
758
  /**
749
759
  * Container for table rows.
@@ -751,8 +761,10 @@ declare const TableColumnResizer: ({ className, ...restProps }: TableColumnResiz
751
761
  declare function TableBody({ className, children, ...restProps }: TableBodyProps): react_jsx_runtime.JSX.Element;
752
762
  declare function TableRow(props: TableRowProps): react_jsx_runtime.JSX.Element;
753
763
  declare function TableCell(props: TableCellProps): react_jsx_runtime.JSX.Element;
754
- type TableContainerProps = ResizableTableContainerProps;
755
- declare const TableContainer: ({ className, ...restProps }: ResizableTableContainerProps) => react_jsx_runtime.JSX.Element;
764
+ /** @deprecated Use `UNSAFE_ResizableTableContainer` instead. */
765
+ declare const UNSAFE_TableContainer: typeof ResizableTableContainer;
766
+ /** @deprecated Use `UNSAFE_ResizableTableContainerProps` instead. */
767
+ type UNSAFE_TableContainerProps = ResizableTableContainerProps;
756
768
 
757
769
  type TabsProps = Omit<TabsProps$1, 'className'> & RefAttributes<HTMLDivElement> & {
758
770
  /**
@@ -910,5 +922,5 @@ type VideoLoopProps = {
910
922
  };
911
923
  declare const VideoLoop: ({ src, format, alt, className }: VideoLoopProps) => react_jsx_runtime.JSX.Element;
912
924
 
913
- 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, CarouselButton as UNSAFE_CarouselButton, CarouselContext as UNSAFE_CarouselContext, CarouselControls as UNSAFE_CarouselControls, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, CarouselItemsContainer as UNSAFE_CarouselItemsContainer, CarouselItemsContainer as UNSAFE_CarouselItemsContainerProps, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, HeroContext as UNSAFE_HeroContext, Link as UNSAFE_Link, Modal as UNSAFE_Modal, Step as UNSAFE_Step, Stepper as UNSAFE_Stepper, 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, _useLocale as useLocale };
914
- 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, CarouselButtonProps as UNSAFE_CarouselButtonProps, CarouselContextValue as UNSAFE_CarouselContextValue, CarouselControlsProps as UNSAFE_CarouselControlsProps, CarouselItemProps as UNSAFE_CarouselItemProps, CarouselItemsProps as UNSAFE_CarouselItemsProps, CarouselProps as UNSAFE_CarouselProps, CarouselElement as UNSAFE_CarouselRef, DialogProps as UNSAFE_DialogProps, DialogTriggerProps as UNSAFE_DialogTriggerProps, FileUploadProps as UNSAFE_FileUploadProps, HeroContextValue as UNSAFE_HeroContextValue, HeroProps as UNSAFE_HeroProps, LinkProps as UNSAFE_LinkProps, ModalProps as UNSAFE_ModalProps, StepProps as UNSAFE_StepProps, StepperProps as UNSAFE_StepperProps, 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 };
925
+ 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, LinkListContext, LinkListItem, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tab, TabList, TabPanel, Tabs, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselButton as UNSAFE_CarouselButton, CarouselContext as UNSAFE_CarouselContext, CarouselControls as UNSAFE_CarouselControls, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, CarouselItemsContainer as UNSAFE_CarouselItemsContainer, CarouselItemsContainer as UNSAFE_CarouselItemsContainerProps, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, HeroContext as UNSAFE_HeroContext, Link as UNSAFE_Link, Modal as UNSAFE_Modal, ResizableTableContainer as UNSAFE_ResizableTableContainer, Step as UNSAFE_Step, Stepper as UNSAFE_Stepper, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, TableCell as UNSAFE_TableCell, TableColumn as UNSAFE_TableColumn, TableColumnResizer as UNSAFE_TableColumnResizer, UNSAFE_TableContainer, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, VideoLoop, _useLocale as useLocale };
926
+ 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, LinkListContextValue, LinkListItemProps, LinkListProps, Locale, MediaProps, NumberFieldProps, RadioGroupProps, RadioProps, SelectProps, TabListProps, TabPanelProps, TabProps, TabsProps, TagGroupProps, TagListProps, TagProps, TextAreaProps, TextFieldProps, CarouselButtonProps as UNSAFE_CarouselButtonProps, CarouselContextValue as UNSAFE_CarouselContextValue, CarouselControlsProps as UNSAFE_CarouselControlsProps, CarouselItemProps as UNSAFE_CarouselItemProps, CarouselItemsProps as UNSAFE_CarouselItemsProps, CarouselProps as UNSAFE_CarouselProps, CarouselElement as UNSAFE_CarouselRef, DialogProps as UNSAFE_DialogProps, DialogTriggerProps as UNSAFE_DialogTriggerProps, FileUploadProps as UNSAFE_FileUploadProps, HeroContextValue as UNSAFE_HeroContextValue, HeroProps as UNSAFE_HeroProps, LinkProps as UNSAFE_LinkProps, ModalProps as UNSAFE_ModalProps, ResizableTableContainerProps as UNSAFE_ResizableTableContainerProps, StepProps as UNSAFE_StepProps, StepperProps as UNSAFE_StepperProps, TableBodyProps as UNSAFE_TableBodyProps, TableCellProps as UNSAFE_TableCellProps, TableColumnProps as UNSAFE_TableColumnProps, TableColumnResizerProps as UNSAFE_TableColumnResizerProps, UNSAFE_TableContainerProps, TableHeaderProps as UNSAFE_TableHeaderProps, TableProps as UNSAFE_TableProps, TableRowProps as UNSAFE_TableRowProps };
package/dist/index.mjs CHANGED
@@ -3,9 +3,9 @@ import { RouterProvider } from 'react-aria-components';
3
3
  export { Form, Group } from 'react-aria-components';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { cva, cx, compose } from 'cva';
6
- import { createContext, useContext, useId, useRef, Children, useState, useEffect, useMemo, useCallback, useImperativeHandle, isValidElement, cloneElement, use } from 'react';
6
+ import { createContext, useContext, useId, useRef, Children, useState, useEffect, useMemo, useCallback, useImperativeHandle, isValidElement, use, cloneElement } from 'react';
7
7
  import { useContextProps, Provider, DEFAULT_SLOT, useSlottedContext } from 'react-aria-components/slots';
8
- import { ChevronDown, Error, Warning, CheckCircle, InfoCircle, Close, User, ChevronLeft, ChevronRight, LoadingSpinner, Check, Trash, Download, LinkExternal, ArrowRight, Edit, PlayerPause, PlayerPlay } from '@obosbbl/grunnmuren-icons-react';
8
+ import { ChevronDown, Error, Warning, CheckCircle, InfoCircle, Close, User, ChevronLeft, Download, LinkExternal, ArrowRight, ChevronRight, LoadingSpinner, Check, Trash, Edit, PlayerPause, PlayerPlay } from '@obosbbl/grunnmuren-icons-react';
9
9
  import { ButtonContext as ButtonContext$1, Button as Button$1 } from 'react-aria-components/Button';
10
10
  import { DisclosureContext, DisclosureGroupStateContext } from 'react-aria-components/DisclosureGroup';
11
11
  export { DisclosureGroup } from 'react-aria-components/DisclosureGroup';
@@ -50,7 +50,8 @@ import { Radio as Radio$1, RadioGroup as RadioGroup$1 } from 'react-aria-compone
50
50
  import { Select as Select$1, SelectValue } from 'react-aria-components/Select';
51
51
  import { ProgressBar as ProgressBar$1 } from 'react-aria-components/ProgressBar';
52
52
  import { useDebouncedCallback } from 'use-debounce';
53
- import { ColumnResizer, Table as Table$1, TableBody as TableBody$1, Cell, Column, ResizableTableContainer, TableHeader as TableHeader$1, Row } from 'react-aria-components/Table';
53
+ import { composeRenderProps } from 'react-aria-components/composeRenderProps';
54
+ import { ColumnResizer, Table as Table$1, TableBody as TableBody$1, Cell, Column, TableHeader as TableHeader$1, Row, ResizableTableContainer as ResizableTableContainer$1 } from 'react-aria-components/Table';
54
55
  import { Tab as Tab$1, TabListStateContext, TabList as TabList$1, TabPanel as TabPanel$1, Tabs as Tabs$1 } from 'react-aria-components/Tabs';
55
56
  import { TagGroup as TagGroup$1, TagList as TagList$1, Tag as Tag$1 } from 'react-aria-components/TagGroup';
56
57
  import { TextArea as TextArea$1 } from 'react-aria-components/TextArea';
@@ -668,18 +669,116 @@ function Badge(props) {
668
669
  });
669
670
  }
670
671
 
672
+ const LinkListContext = /*#__PURE__*/ createContext(null);
673
+ const linkStyles = [
674
+ '*:data-[slot=link]:flex',
675
+ '*:data-[slot=link]:w-full',
676
+ '*:data-[slot=link]:justify-between',
677
+ '*:data-[slot=link]:gap-x-2',
678
+ '*:data-[slot=link]:py-3.5',
679
+ '*:data-[slot=link]:no-underline',
680
+ '*:data-[slot=link]:focus-visible:outline-focus'
681
+ ];
682
+ const linkListContainerVariants = cva({
683
+ base: [
684
+ '*:data-[slot=link-list]:overflow-visible',
685
+ '*:data-[slot=heading]:p-1.25',
686
+ '*:data-[slot=heading]:*:data-[slot=link]:py-2.25',
687
+ '**:[svg]:text-base',
688
+ 'has-data-[slot=heading]:*:data-[slot=link-list]:overflow-visible',
689
+ '*:data-[slot=heading]:has-not:*:data-[slot=link]:my-2.25'
690
+ ],
691
+ variants: {
692
+ layout: {
693
+ stack: null,
694
+ grid: '@container'
695
+ }
696
+ },
697
+ defaultVariants: {
698
+ layout: 'stack'
699
+ }
700
+ });
701
+ const LinkListContainer = ({ className, layout = 'stack', ...props })=>{
702
+ const container = /*#__PURE__*/ jsx(Provider, {
703
+ values: [
704
+ [
705
+ HeadingContext,
706
+ {
707
+ size: 'm',
708
+ className: cx(linkStyles)
709
+ }
710
+ ]
711
+ ],
712
+ children: /*#__PURE__*/ jsx("div", {
713
+ ...props,
714
+ className: linkListContainerVariants({
715
+ className,
716
+ layout
717
+ }),
718
+ "data-layout": layout,
719
+ "data-slot": "link-list-container"
720
+ })
721
+ });
722
+ const hasLinkListContext = !!useContext(LinkListContext);
723
+ if (hasLinkListContext) {
724
+ return container;
725
+ }
726
+ return /*#__PURE__*/ jsx(LinkListContext.Provider, {
727
+ value: {
728
+ shouldRenderAutoIcons: true
729
+ },
730
+ children: container
731
+ });
732
+ };
733
+ const LinkList = ({ className, children, ...restProps })=>{
734
+ const ul = /*#__PURE__*/ jsx("ul", {
735
+ ...restProps,
736
+ "data-slot": "link-list",
737
+ className: cx(/**
738
+ * Hides dividers at the top of the list (overflow-y)
739
+ * while preventing arrow icons from overflowing container when animated to the right (overflow-x)
740
+ */ 'grid min-w-fit auto-rows-max gap-y-px overflow-hidden', className),
741
+ children: children
742
+ });
743
+ const hasLinkListContext = !!useContext(LinkListContext);
744
+ if (hasLinkListContext) {
745
+ return ul;
746
+ }
747
+ return /*#__PURE__*/ jsx(LinkListContext.Provider, {
748
+ value: {
749
+ shouldRenderAutoIcons: true
750
+ },
751
+ children: ul
752
+ });
753
+ };
754
+ const LinkListItem = ({ children, className, ...props })=>/*#__PURE__*/ jsx("li", {
755
+ ...props,
756
+ className: cx(className, 'after:bg-gray-light relative p-1.25 after:absolute after:inset-x-0 after:-top-px after:h-px after:w-full', '*:data-[slot=link]:paragraph', ...linkStyles),
757
+ "data-slot": "link-list-item",
758
+ children: children
759
+ });
760
+
671
761
  const linkVariants = compose(animateIconVariants, cva({
672
762
  base: 'focus-visible:outline-focus-offset inline-flex cursor-pointer items-center gap-1 font-medium hover:no-underline focus-visible:outline-current data-disabled:cursor-default data-disabled:font-normal data-disabled:no-underline'
673
763
  }));
674
- const Link = ({ animateIcon, children, className, '~iconRight': iconRight, ...props })=>{
764
+ const Link = ({ animateIcon, children, className, ...props })=>{
675
765
  const locale = _useLocale();
676
766
  const externalLinkText = translations$1.externalLink[locale];
767
+ const shouldRenderAutoIcons = useContext(LinkListContext)?.shouldRenderAutoIcons ?? false;
768
+ let resolvedAnimateIcon = animateIcon;
769
+ let autoIcon = null;
770
+ if (shouldRenderAutoIcons) {
771
+ if (resolvedAnimateIcon === undefined) {
772
+ resolvedAnimateIcon = props.download ? 'down' : props.rel?.includes('external') ? 'up-right' : 'right';
773
+ }
774
+ autoIcon = props.download ? /*#__PURE__*/ jsx(Download, {}) : props.rel?.includes('external') ? /*#__PURE__*/ jsx(LinkExternal, {}) : /*#__PURE__*/ jsx(ArrowRight, {});
775
+ }
677
776
  return /*#__PURE__*/ jsxs(Link$1, {
678
777
  ...props,
679
778
  "data-slot": "link",
680
779
  className: linkVariants({
681
780
  className,
682
- animateIcon
781
+ animateIcon: resolvedAnimateIcon
683
782
  }),
684
783
  children: [
685
784
  children,
@@ -687,7 +786,7 @@ const Link = ({ animateIcon, children, className, '~iconRight': iconRight, ...pr
687
786
  className: "sr-only",
688
787
  children: externalLinkText
689
788
  }),
690
- iconRight
789
+ autoIcon
691
790
  ]
692
791
  });
693
792
  };
@@ -2290,78 +2389,6 @@ function GrunnmurenProvider({ children, locale = 'nb', navigate, useHref }) {
2290
2389
  });
2291
2390
  }
2292
2391
 
2293
- const linkStyles = [
2294
- '*:data-[slot=link]:flex',
2295
- '*:data-[slot=link]:w-full',
2296
- '*:data-[slot=link]:justify-between',
2297
- '*:data-[slot=link]:gap-x-2',
2298
- '*:data-[slot=link]:py-3.5',
2299
- '*:data-[slot=link]:no-underline',
2300
- '*:data-[slot=link]:focus-visible:outline-focus'
2301
- ];
2302
- const linkListContainerVariants = cva({
2303
- base: [
2304
- '*:data-[slot=link-list]:overflow-visible',
2305
- '*:data-[slot=heading]:p-1.25',
2306
- '*:data-[slot=heading]:*:data-[slot=link]:py-2.25',
2307
- '**:[svg]:text-base',
2308
- 'has-data-[slot=heading]:*:data-[slot=link-list]:overflow-visible',
2309
- '*:data-[slot=heading]:has-not:*:data-[slot=link]:my-2.25'
2310
- ],
2311
- variants: {
2312
- layout: {
2313
- stack: null,
2314
- grid: '@container'
2315
- }
2316
- },
2317
- defaultVariants: {
2318
- layout: 'stack'
2319
- }
2320
- });
2321
- const LinkListContainer = ({ className, layout = 'stack', ...props })=>/*#__PURE__*/ jsx(Provider, {
2322
- values: [
2323
- [
2324
- HeadingContext,
2325
- {
2326
- size: 'm',
2327
- className: cx(linkStyles)
2328
- }
2329
- ]
2330
- ],
2331
- children: /*#__PURE__*/ jsx("div", {
2332
- ...props,
2333
- className: linkListContainerVariants({
2334
- className,
2335
- layout
2336
- }),
2337
- "data-layout": layout,
2338
- "data-slot": "link-list-container"
2339
- })
2340
- });
2341
- const LinkList = ({ className, ...restProps })=>/*#__PURE__*/ jsx("ul", {
2342
- ...restProps,
2343
- "data-slot": "link-list",
2344
- className: cx(/**
2345
- * Hides dividers at the top of the list (overflow-y)
2346
- * while preventing arrow icons from overflowing container when animated to the right (overflow-x)
2347
- */ 'grid min-w-fit auto-rows-max gap-y-px overflow-hidden', className)
2348
- });
2349
- const LinkListItem = ({ children, className, ...props })=>{
2350
- const child = Children.only(children);
2351
- const childProps = /*#__PURE__*/ isValidElement(child) ? child.props : {};
2352
- const animateIcon = childProps.animateIcon || childProps.download ? 'down' : childProps.rel?.includes('external') ? 'up-right' : 'right';
2353
- const iconRight = childProps['~iconRight'] || childProps.download ? /*#__PURE__*/ jsx(Download, {}) : childProps.rel?.includes('external') ? /*#__PURE__*/ jsx(LinkExternal, {}) : /*#__PURE__*/ jsx(ArrowRight, {});
2354
- return /*#__PURE__*/ jsx("li", {
2355
- ...props,
2356
- className: cx(className, 'after:bg-gray-light relative p-1.25 after:absolute after:inset-x-0 after:-top-px after:h-px after:w-full', '*:data-[slot=link]:paragraph', ...linkStyles),
2357
- "data-slot": "link-list-item",
2358
- children: /*#__PURE__*/ isValidElement(child) && /*#__PURE__*/ cloneElement(child, {
2359
- animateIcon,
2360
- '~iconRight': iconRight
2361
- })
2362
- });
2363
- };
2364
-
2365
2392
  // This component is based on a copy of ../textfield/TextField, refactoring is TBD: https://github.com/code-obos/grunnmuren/pull/722#issuecomment-1931478786
2366
2393
  const inputVariants$1 = compose(input, cva({
2367
2394
  base: '',
@@ -2760,33 +2787,28 @@ const Step = ({ isDisabled = false, state, children, '~stepIndex': stepIndex, pr
2760
2787
  });
2761
2788
  };
2762
2789
 
2763
- const tableVariants = cva({
2764
- base: [
2765
- 'relative'
2766
- ],
2767
- variants: {
2768
- variant: {
2769
- default: '',
2770
- 'zebra-striped': ''
2771
- }
2772
- }
2773
- });
2790
+ const _ResizableTableContainerContext = /*#__PURE__*/ createContext(null);
2774
2791
  const tableRowVariants = cva({
2775
2792
  base: [
2793
+ 'group/row',
2776
2794
  'data-focus-visible:outline-focus-inset',
2777
- 'group-data-[variant=zebra-striped]:odd:bg-white',
2778
- 'group-data-[variant=zebra-striped]:even:bg-sky-lightest'
2795
+ 'group-data-[variant=zebra-striped]/table:odd:bg-white',
2796
+ 'group-data-[variant=zebra-striped]/table:even:bg-sky-lightest',
2797
+ // When the row has expandable children, the chevron button makes the
2798
+ // row taller than a plain text row. Center-align the cells' content so
2799
+ // the chevron icon lines up with text in sibling cells.
2800
+ 'data-has-child-items:*:align-middle'
2779
2801
  ]
2780
2802
  });
2781
- // Used to deal with showing or hiding scroll indicators during column resizing
2782
- const TableScrollContainerContext = /*#__PURE__*/ createContext({
2783
- isResizing: false
2784
- });
2785
2803
  /**
2786
- * A container component for displaying tabular data with horizontal scrolling support.
2787
- */ function Table(props) {
2788
- const { className, children, variant = 'default', ...restProps } = props;
2789
- const { isResizing } = useContext(TableScrollContainerContext);
2804
+ * Shared scroll wrapper that renders an overflow container with left/right
2805
+ * scroll indicators around the table. If it is rendered inside a
2806
+ * <ResizableTableContainer>, the overflow element is RAC's
2807
+ * <ResizableTableContainer> (required for column resizing to measure column
2808
+ * widths against the correct scroll viewport); otherwise it is a plain div.
2809
+ */ function ScrollWrapper({ children }) {
2810
+ const containerCtx = useContext(_ResizableTableContainerContext);
2811
+ const [isResizing, setIsResizing] = useState(false);
2790
2812
  const { scrollContainerRef, canScrollLeft, canScrollRight, hasScrollingOccurred } = useHorizontalScroll([
2791
2813
  isResizing
2792
2814
  ]);
@@ -2801,43 +2823,76 @@ const TableScrollContainerContext = /*#__PURE__*/ createContext({
2801
2823
  }, [
2802
2824
  scrollContainerRef
2803
2825
  ]);
2804
- return /*#__PURE__*/ jsx("div", {
2805
- className: tableVariants({
2806
- className,
2807
- variant
2808
- }),
2809
- children: /*#__PURE__*/ jsxs("div", {
2810
- className: "relative overflow-hidden",
2811
- children: [
2812
- /*#__PURE__*/ jsx("div", {
2813
- ref: scrollContainerRef,
2814
- className: "scrollbar-hidden overflow-x-auto",
2815
- style: {
2816
- WebkitOverflowScrolling: 'touch'
2817
- },
2818
- children: /*#__PURE__*/ jsx(Table$1, {
2819
- ...restProps,
2820
- className: "group w-full min-w-fit",
2821
- "data-variant": variant,
2822
- children: children
2823
- })
2824
- }),
2825
- /*#__PURE__*/ jsx(ScrollButton, {
2826
- direction: "left",
2827
- onClick: ()=>handleScroll('left'),
2828
- isVisible: canScrollLeft,
2829
- hasScrollingOccurred: hasScrollingOccurred
2830
- }),
2831
- /*#__PURE__*/ jsx(ScrollButton, {
2832
- direction: "right",
2833
- onClick: ()=>handleScroll('right'),
2834
- isVisible: canScrollRight,
2835
- hasScrollingOccurred: hasScrollingOccurred
2836
- })
2837
- ]
2826
+ const scrollClasses = 'scrollbar-hidden overflow-x-auto';
2827
+ const touchStyle = {
2828
+ WebkitOverflowScrolling: 'touch'
2829
+ };
2830
+ return /*#__PURE__*/ jsxs("div", {
2831
+ className: "relative overflow-hidden",
2832
+ children: [
2833
+ containerCtx ? /*#__PURE__*/ jsx(ResizableTableContainer$1, {
2834
+ ...containerCtx.resizableProps,
2835
+ ref: scrollContainerRef,
2836
+ className: cx(scrollClasses, containerCtx.resizableProps.className),
2837
+ style: touchStyle,
2838
+ onResizeStart: (widths)=>{
2839
+ setIsResizing(true);
2840
+ containerCtx.resizableProps.onResizeStart?.(widths);
2841
+ },
2842
+ onResizeEnd: (widths)=>{
2843
+ setIsResizing(false);
2844
+ containerCtx.resizableProps.onResizeEnd?.(widths);
2845
+ },
2846
+ children: children
2847
+ }) : /*#__PURE__*/ jsx("div", {
2848
+ ref: scrollContainerRef,
2849
+ className: scrollClasses,
2850
+ style: touchStyle,
2851
+ children: children
2852
+ }),
2853
+ /*#__PURE__*/ jsx(ScrollButton, {
2854
+ direction: "left",
2855
+ onClick: ()=>handleScroll('left'),
2856
+ isVisible: canScrollLeft,
2857
+ hasScrollingOccurred: hasScrollingOccurred
2858
+ }),
2859
+ /*#__PURE__*/ jsx(ScrollButton, {
2860
+ direction: "right",
2861
+ onClick: ()=>handleScroll('right'),
2862
+ isVisible: canScrollRight,
2863
+ hasScrollingOccurred: hasScrollingOccurred
2864
+ })
2865
+ ]
2866
+ });
2867
+ }
2868
+ /**
2869
+ * A container component for displaying tabular data with horizontal scrolling support.
2870
+ */ function Table(props) {
2871
+ const { className, children, variant = 'default', ...restProps } = props;
2872
+ return /*#__PURE__*/ jsx(ScrollWrapper, {
2873
+ children: /*#__PURE__*/ jsx(Table$1, {
2874
+ ...restProps,
2875
+ className: cx(className, 'group/table w-full min-w-fit'),
2876
+ "data-variant": variant,
2877
+ children: children
2838
2878
  })
2839
2879
  });
2840
2880
  }
2881
+ /**
2882
+ * Container that enables column resizing and horizontal scrolling for the
2883
+ * nested <Table>. Use when you want resizable columns or want to apply
2884
+ * `maxWidth`/`minWidth` truncation on columns.
2885
+ */ function ResizableTableContainer({ className, children, ...restProps }) {
2886
+ return /*#__PURE__*/ jsx(_ResizableTableContainerContext.Provider, {
2887
+ value: {
2888
+ resizableProps: {
2889
+ ...restProps,
2890
+ className: cx(className, '**:data-[slot=table-column]:overflow-hidden **:data-[slot=table-column]:text-ellipsis', '**:data-[slot=table-cell]:overflow-hidden **:data-[slot=table-cell]:text-ellipsis')
2891
+ }
2892
+ },
2893
+ children: children
2894
+ });
2895
+ }
2841
2896
  /**
2842
2897
  * Container for table column headers.
2843
2898
  */ function TableHeader({ className, children, ...restProps }) {
@@ -2884,30 +2939,32 @@ function TableCell(props) {
2884
2939
  const { className, children, ...restProps } = props;
2885
2940
  return /*#__PURE__*/ jsx(Cell, {
2886
2941
  ...restProps,
2887
- className: cx(className, 'px-4 py-3 text-sm/relaxed text-black', 'min-w-fit whitespace-nowrap', 'align-top', 'data-focus-visible:outline-focus-inset'),
2942
+ className: cx(className, 'px-4 py-3 text-sm/relaxed text-black', 'min-w-fit whitespace-nowrap', 'align-top', 'data-focus-visible:outline-focus-inset', // When this cell is in the column designated by `treeColumn` and
2943
+ // its row has nested child rows, we render an expand/collapse button
2944
+ // (see composeRenderProps below). Use flex so the button lines up
2945
+ // nicely next to the cell content.
2946
+ 'data-tree-column:flex data-tree-column:items-center data-tree-column:gap-2'),
2888
2947
  "data-slot": "table-cell",
2889
- children: children
2948
+ children: composeRenderProps(children, (resolved, { isTreeColumn, hasChildItems })=>/*#__PURE__*/ jsxs(Fragment, {
2949
+ children: [
2950
+ isTreeColumn && hasChildItems && /*#__PURE__*/ jsx(Button, {
2951
+ slot: "chevron",
2952
+ variant: "tertiary",
2953
+ isIconOnly: true,
2954
+ className: "-my-1 group-data-expanded/row:[&_svg]:rotate-90",
2955
+ children: /*#__PURE__*/ jsx(ChevronRight, {
2956
+ className: "transition-transform duration-300 motion-reduce:transition-none"
2957
+ })
2958
+ }),
2959
+ resolved
2960
+ ]
2961
+ }))
2890
2962
  });
2891
2963
  }
2892
- const TableContainer = ({ className, ...restProps })=>{
2893
- const [isResizing, setIsResizing] = useState(false);
2894
- return /*#__PURE__*/ jsx(Provider, {
2895
- values: [
2896
- [
2897
- TableScrollContainerContext,
2898
- {
2899
- isResizing
2900
- }
2901
- ]
2902
- ],
2903
- children: /*#__PURE__*/ jsx(ResizableTableContainer, {
2904
- ...restProps,
2905
- className: cx(className, '**:data-[slot=table-column]:overflow-hidden **:data-[slot=table-column]:text-ellipsis', '**:data-[slot=table-cell]:overflow-hidden **:data-[slot=table-cell]:text-ellipsis'),
2906
- onResizeStart: ()=>setIsResizing(true),
2907
- onResizeEnd: ()=>setIsResizing(false)
2908
- })
2909
- });
2910
- };
2964
+ // Deprecated aliases kept for backwards compatibility during the UNSAFE_ phase.
2965
+ // Remove these once the Table component is stabilized and the UNSAFE_ prefix
2966
+ // is dropped.
2967
+ /** @deprecated Use `UNSAFE_ResizableTableContainer` instead. */ const UNSAFE_TableContainer = ResizableTableContainer;
2911
2968
 
2912
2969
  const tabsVariants = cva({
2913
2970
  base: [
@@ -3038,8 +3095,8 @@ const tabsVariants = cva({
3038
3095
  return /*#__PURE__*/ jsx(Tab$1, {
3039
3096
  ...restProps,
3040
3097
  className: cx(className, 'data-focus-visible:outline-focus data-focus-visible:-outline-offset-10', 'description h-11 cursor-pointer border-transparent px-4 py-[0.71875rem] font-light', // Transition
3041
- 'transition-colors duration-150 ease-out', // TODO: Should disabled tabs just be hidden?
3042
- 'data-disabled:cursor-not-allowed data-disabled:opacity-50', // Selection
3098
+ 'transition-colors duration-150 ease-out', // Hide disabled tabs entirely the design system avoids disabled states (see https://grunnmuren.obos.no/disabled-state)
3099
+ 'data-disabled:hidden', // Selection
3043
3100
  'data-selected:text-blue-dark data-selected:font-medium', // Hover with layout shift prevention using pseudo-element
3044
3101
  'after:invisible after:block after:h-0 after:overflow-hidden after:font-medium after:content-[attr(data-text)]', 'data-hovered:font-medium', // Pressed
3045
3102
  'data-pressed:text-blue-dark data-pressed:font-medium'),
@@ -3301,4 +3358,4 @@ const VideoLoop = ({ src, format, alt, className })=>{
3301
3358
  });
3302
3359
  };
3303
3360
 
3304
- 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, CarouselButton as UNSAFE_CarouselButton, CarouselContext as UNSAFE_CarouselContext, CarouselControls as UNSAFE_CarouselControls, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, CarouselItemsContainer as UNSAFE_CarouselItemsContainer, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, HeroContext as UNSAFE_HeroContext, Link as UNSAFE_Link, Modal as UNSAFE_Modal, Step as UNSAFE_Step, Stepper as UNSAFE_Stepper, 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, _useLocale as useLocale };
3361
+ 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, LinkListContext, LinkListItem, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tab, TabList, TabPanel, Tabs, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselButton as UNSAFE_CarouselButton, CarouselContext as UNSAFE_CarouselContext, CarouselControls as UNSAFE_CarouselControls, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, CarouselItemsContainer as UNSAFE_CarouselItemsContainer, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, HeroContext as UNSAFE_HeroContext, Link as UNSAFE_Link, Modal as UNSAFE_Modal, ResizableTableContainer as UNSAFE_ResizableTableContainer, Step as UNSAFE_Step, Stepper as UNSAFE_Stepper, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, TableCell as UNSAFE_TableCell, TableColumn as UNSAFE_TableColumn, TableColumnResizer as UNSAFE_TableColumnResizer, UNSAFE_TableContainer, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, VideoLoop, _useLocale as useLocale };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "3.4.6",
3
+ "version": "3.5.0",
4
4
  "description": "Grunnmuren components in React",
5
5
  "license": "MIT",
6
6
  "repository": {