@obosbbl/grunnmuren-react 3.0.13 → 3.0.15

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 { RouterProvider, ButtonProps as ButtonProps$1, LinkProps, ContextValue, CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, ListBoxItemProps, ListBoxSectionProps, HeadingProps as HeadingProps$1, ComboBoxProps, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps as SelectProps$1, TextFieldProps as TextFieldProps$1, NumberFieldProps as NumberFieldProps$1, BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, DisclosureProps as DisclosureProps$1, FileTriggerProps as FileTriggerProps$1, TextProps, LabelProps, DialogTriggerProps as DialogTriggerProps$1, ModalOverlayProps, DialogProps as DialogProps$1, TagGroupProps as TagGroupProps$1, TagListProps as TagListProps$1, TagProps as TagProps$1, TabsProps as TabsProps$1, TabListProps as TabListProps$1, TabProps as TabProps$1, TabPanelProps as TabPanelProps$1 } from 'react-aria-components';
1
+ import { RouterProvider, ButtonProps as ButtonProps$1, LinkProps, ContextValue, CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, ListBoxItemProps, ListBoxSectionProps, HeadingProps as HeadingProps$1, ComboBoxProps, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps as SelectProps$1, TextFieldProps as TextFieldProps$1, NumberFieldProps as NumberFieldProps$1, BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, DisclosureProps as DisclosureProps$1, FileTriggerProps as FileTriggerProps$1, TextProps, LabelProps, DialogTriggerProps as DialogTriggerProps$1, ModalOverlayProps, DialogProps as DialogProps$1, TagGroupProps as TagGroupProps$1, TagListProps as TagListProps$1, TagProps as TagProps$1, TabsProps as TabsProps$1, TabListProps as TabListProps$1, TabProps as TabProps$1, TabPanelProps as TabPanelProps$1, TableProps as TableProps$1, TableHeaderProps as TableHeaderProps$1, ColumnProps, TableBodyProps as TableBodyProps$1, RowProps, CellProps } from 'react-aria-components';
2
2
  export { ListBoxItemProps as ComboboxItemProps, Form, Group, LabelProps, ListBoxItemProps as SelectItemProps, DisclosureGroup as UNSAFE_DisclosureGroup, DisclosureGroupProps as UNSAFE_DisclosureGroupProps } from 'react-aria-components';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
@@ -701,6 +701,44 @@ declare function Tab(props: TabProps): react_jsx_runtime.JSX.Element;
701
701
  */
702
702
  declare function TabPanel(props: TabPanelProps): react_jsx_runtime.JSX.Element;
703
703
 
704
+ type TableProps = Omit<TableProps$1, 'aria-label' | 'aria-labelledby'> & RefAttributes<HTMLTableElement> & {
705
+ /**
706
+ * Visual variant of the table
707
+ * @default 'default'
708
+ */
709
+ variant?: 'default' | 'zebra-striped';
710
+ } & ({
711
+ 'aria-label': string;
712
+ 'aria-labelledby'?: never;
713
+ } | {
714
+ 'aria-label'?: never;
715
+ 'aria-labelledby': string;
716
+ });
717
+ type TableHeaderProps = TableHeaderProps$1<object> & RefAttributes<HTMLTableSectionElement>;
718
+ type TableColumnProps = ColumnProps & RefAttributes<HTMLTableCellElement> & {
719
+ children: React.ReactNode;
720
+ };
721
+ type TableBodyProps = TableBodyProps$1<object> & RefAttributes<HTMLTableSectionElement>;
722
+ type TableRowProps = RowProps<object> & RefAttributes<HTMLTableRowElement>;
723
+ type TableCellProps = CellProps & RefAttributes<HTMLTableCellElement> & {
724
+ children: React.ReactNode;
725
+ };
726
+ /**
727
+ * A container component for displaying tabular data with horizontal scrolling support.
728
+ */
729
+ declare function Table(props: TableProps): react_jsx_runtime.JSX.Element;
730
+ /**
731
+ * Container for table column headers.
732
+ */
733
+ declare function TableHeader({ className, children, ...restProps }: TableHeaderProps): react_jsx_runtime.JSX.Element;
734
+ declare function TableColumn(props: TableColumnProps): react_jsx_runtime.JSX.Element;
735
+ /**
736
+ * Container for table rows.
737
+ */
738
+ declare function TableBody({ className, children, ...restProps }: TableBodyProps): react_jsx_runtime.JSX.Element;
739
+ declare function TableRow(props: TableRowProps): react_jsx_runtime.JSX.Element;
740
+ declare function TableCell(props: TableCellProps): react_jsx_runtime.JSX.Element;
741
+
704
742
  type CustomLinkProps = LinkProps & {
705
743
  children: ReactNode;
706
744
  };
@@ -720,4 +758,4 @@ type LinkListItemProps = LinkProps & {
720
758
  };
721
759
  declare const LinkListItem: ({ children, isExternal, className, ...restProps }: LinkListItemProps) => react_jsx_runtime.JSX.Element;
722
760
 
723
- 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, CustomLink as UNSAFE_Link, LinkList as UNSAFE_LinkList, LinkListItem as UNSAFE_LinkListItem, type LinkListItemProps as UNSAFE_LinkListItemProps, type LinkListProps as UNSAFE_LinkListProps, type CustomLinkProps as UNSAFE_LinkProps, Modal as UNSAFE_Modal, type ModalProps as UNSAFE_ModalProps, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, type TabListProps as UNSAFE_TabListProps, TabPanel as UNSAFE_TabPanel, type TabPanelProps as UNSAFE_TabPanelProps, type TabProps as UNSAFE_TabProps, Tabs as UNSAFE_Tabs, type TabsProps as UNSAFE_TabsProps, Tag as UNSAFE_Tag, TagGroup as UNSAFE_TagGroup, TagList as UNSAFE_TagList, VideoLoop, _useLocale as useLocale };
761
+ 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, CustomLink as UNSAFE_Link, LinkList as UNSAFE_LinkList, LinkListItem as UNSAFE_LinkListItem, type LinkListItemProps as UNSAFE_LinkListItemProps, type LinkListProps as UNSAFE_LinkListProps, type CustomLinkProps as UNSAFE_LinkProps, Modal as UNSAFE_Modal, type ModalProps as UNSAFE_ModalProps, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, type TabListProps as UNSAFE_TabListProps, TabPanel as UNSAFE_TabPanel, type TabPanelProps as UNSAFE_TabPanelProps, type TabProps as UNSAFE_TabProps, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, type TableBodyProps as UNSAFE_TableBodyProps, TableCell as UNSAFE_TableCell, type TableCellProps as UNSAFE_TableCellProps, TableColumn as UNSAFE_TableColumn, type TableColumnProps as UNSAFE_TableColumnProps, TableHeader as UNSAFE_TableHeader, type TableHeaderProps as UNSAFE_TableHeaderProps, type TableProps as UNSAFE_TableProps, TableRow as UNSAFE_TableRow, type TableRowProps as UNSAFE_TableRowProps, Tabs as UNSAFE_Tabs, type TabsProps as UNSAFE_TabsProps, Tag as UNSAFE_Tag, TagGroup as UNSAFE_TagGroup, TagList as UNSAFE_TagList, VideoLoop, _useLocale as useLocale };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { I18nProvider, RouterProvider, useLocale, useContextProps, Provider, Link, Button as Button$1, Text, CheckboxContext, Checkbox as Checkbox$1, FieldError, Label as Label$1, CheckboxGroup as CheckboxGroup$1, ListBoxItem as ListBoxItem$1, ListBoxSection as ListBoxSection$1, Header, ListBox as ListBox$1, ComboBox, Group, Input, Popover, RadioGroup as RadioGroup$1, Radio as Radio$1, Select as Select$1, SelectValue, TextField as TextField$1, TextArea as TextArea$1, NumberField as NumberField$1, Breadcrumbs as Breadcrumbs$1, Breadcrumb as Breadcrumb$1, ButtonContext as ButtonContext$1, DisclosureContext, DisclosureGroupStateContext, DEFAULT_SLOT, useSlottedContext, FormContext, FieldErrorContext, LabelContext, InputContext, DialogTrigger as DialogTrigger$1, Modal as Modal$1, Dialog as Dialog$1, ModalOverlay as ModalOverlay$1, TagGroup as TagGroup$1, TagList as TagList$1, Tag as Tag$1, GroupContext, Tabs as Tabs$1, TabListStateContext, TabList as TabList$1, Tab as Tab$1, TabPanel as TabPanel$1 } from 'react-aria-components';
2
+ import { I18nProvider, RouterProvider, useLocale, useContextProps, Provider, Link, Button as Button$1, Text, CheckboxContext, Checkbox as Checkbox$1, FieldError, Label as Label$1, CheckboxGroup as CheckboxGroup$1, ListBoxItem as ListBoxItem$1, ListBoxSection as ListBoxSection$1, Header, ListBox as ListBox$1, ComboBox, Group, Input, Popover, RadioGroup as RadioGroup$1, Radio as Radio$1, Select as Select$1, SelectValue, TextField as TextField$1, TextArea as TextArea$1, NumberField as NumberField$1, Breadcrumbs as Breadcrumbs$1, Breadcrumb as Breadcrumb$1, ButtonContext as ButtonContext$1, DisclosureContext, DisclosureGroupStateContext, DEFAULT_SLOT, useSlottedContext, FormContext, FieldErrorContext, LabelContext, InputContext, DialogTrigger as DialogTrigger$1, Modal as Modal$1, Dialog as Dialog$1, ModalOverlay as ModalOverlay$1, TagGroup as TagGroup$1, TagList as TagList$1, Tag as Tag$1, GroupContext, Tabs as Tabs$1, TabListStateContext, TabList as TabList$1, Tab as Tab$1, TabPanel as TabPanel$1, Table as Table$1, TableHeader as TableHeader$1, Column, TableBody as TableBody$1, Row, Cell } from 'react-aria-components';
3
3
  export { Form, Group, DisclosureGroup as UNSAFE_DisclosureGroup } from 'react-aria-components';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { ChevronDown, LoadingSpinner, Check, Close, InfoCircle, CheckCircle, Warning, Error, ChevronRight, ChevronLeft, PlayerPause, PlayerPlay, Trash, User, ArrowRight, Download, LinkExternal } from '@obosbbl/grunnmuren-icons-react';
@@ -2310,6 +2310,71 @@ const CarouselItem = ({ className, children, id })=>{
2310
2310
  });
2311
2311
  };
2312
2312
 
2313
+ function ScrollButton({ direction, onClick, isVisible, hasScrollingOccurred, className, iconClassName }) {
2314
+ const Icon = direction === 'left' ? ChevronLeft : ChevronRight;
2315
+ return(// biome-ignore lint/a11y/useKeyWithClickEvents: This button is only for mouse interaction to help users scroll. Keyboard and screen reader users can navigate the content directly without needing these scroll helpers.
2316
+ /*#__PURE__*/ jsx("div", {
2317
+ onClick: onClick,
2318
+ className: cx(// Base scroll button styling
2319
+ 'flex cursor-pointer items-center justify-center', 'text-black hover:bg-white', direction === 'left' ? 'bg-[linear-gradient(90deg,white,white_calc(100%-10px),transparent)]' : 'bg-[linear-gradient(90deg,transparent,white_calc(10px),white)]', // Animation
2320
+ hasScrollingOccurred && 'duration-100 ease-in motion-safe:transition-transform', // Hide/show animation
2321
+ direction === 'left' ? !isVisible && '-translate-x-full pointer-events-none' : !isVisible && 'pointer-events-none translate-x-full', direction === 'left' ? '-left-3' : '-right-3', className),
2322
+ children: /*#__PURE__*/ jsx(Icon, {
2323
+ className: iconClassName
2324
+ })
2325
+ }));
2326
+ }
2327
+ /**
2328
+ * Simple hook for detecting horizontal scroll capabilities
2329
+ * Returns scroll state and a ref to attach to your scrollable container
2330
+ */ function useHorizontalScroll() {
2331
+ const scrollContainerRef = useRef(null);
2332
+ const [scrollState, setScrollState] = useState({
2333
+ canScrollLeft: false,
2334
+ canScrollRight: false,
2335
+ hasScrollingOccurred: false
2336
+ });
2337
+ const updateScrollState = useCallback(()=>{
2338
+ const container = scrollContainerRef.current;
2339
+ if (!container) {
2340
+ return;
2341
+ }
2342
+ const { scrollLeft, scrollWidth, clientWidth } = container;
2343
+ const isAtStart = scrollLeft <= 0;
2344
+ const isAtEnd = scrollLeft >= scrollWidth - clientWidth;
2345
+ setScrollState((prev)=>({
2346
+ canScrollLeft: !isAtStart,
2347
+ canScrollRight: !isAtEnd,
2348
+ hasScrollingOccurred: prev.hasScrollingOccurred || scrollLeft > 0
2349
+ }));
2350
+ }, []);
2351
+ const debouncedUpdateScrollState = useDebouncedCallback(updateScrollState, 100);
2352
+ useEffect(()=>{
2353
+ const container = scrollContainerRef.current;
2354
+ if (!container) {
2355
+ return;
2356
+ }
2357
+ // Initial check
2358
+ updateScrollState();
2359
+ // Listen for scroll events
2360
+ container.addEventListener('scroll', debouncedUpdateScrollState);
2361
+ // Listen for resize events (content or container size changes)
2362
+ const resizeObserver = new ResizeObserver(updateScrollState);
2363
+ resizeObserver.observe(container);
2364
+ return ()=>{
2365
+ container.removeEventListener('scroll', debouncedUpdateScrollState);
2366
+ resizeObserver.disconnect();
2367
+ };
2368
+ }, [
2369
+ updateScrollState,
2370
+ debouncedUpdateScrollState
2371
+ ]);
2372
+ return {
2373
+ scrollContainerRef,
2374
+ ...scrollState
2375
+ };
2376
+ }
2377
+
2313
2378
  const tabsVariants = cva({
2314
2379
  base: [
2315
2380
  'grid gap-4'
@@ -2339,17 +2404,9 @@ const tabsVariants = cva({
2339
2404
  /**
2340
2405
  * A container component for Tab components within Tabs.
2341
2406
  */ function TabList({ className, children, ...restProps }) {
2342
- const scrollContainerRef = useRef(null);
2343
- const [canScrollLeft, setCanScrollLeft] = useState(false);
2344
- const [canScrollRight, setCanScrollRight] = useState(false);
2345
- const checkScrollOverflow = useCallback(()=>{
2346
- const container = scrollContainerRef.current;
2347
- if (!container) return;
2348
- const { scrollLeft, scrollWidth, clientWidth } = container;
2349
- setCanScrollLeft(scrollLeft > 0);
2350
- setCanScrollRight(scrollLeft < scrollWidth - clientWidth - 1);
2351
- }, []);
2352
2407
  const state = useContext(TabListStateContext);
2408
+ const { scrollContainerRef, canScrollLeft, canScrollRight, hasScrollingOccurred } = useHorizontalScroll();
2409
+ // Tab-specific navigation logic
2353
2410
  const prevKey = state?.selectedKey && state?.collection.getKeyBefore(state.selectedKey);
2354
2411
  const onPrev = prevKey ? ()=>state?.setSelectedKey(prevKey) : ()=>{
2355
2412
  if (canScrollLeft && state?.selectedKey === state?.collection.firstKey) {
@@ -2370,30 +2427,6 @@ const tabsVariants = cva({
2370
2427
  });
2371
2428
  }
2372
2429
  };
2373
- // To controll if the animation for the scroll buttons and the scrolling behavior
2374
- // This is used to prevent animations from running when the component mounts
2375
- // We use a ref here to prevent redundant render cycles and potentially uninteded scrolling.
2376
- const hasScrollingOccurredRef = useRef(false);
2377
- // Debounce the scroll handler to avoid performance issues with frequent scroll events
2378
- const scrollHandler = useDebouncedCallback(()=>{
2379
- checkScrollOverflow();
2380
- hasScrollingOccurredRef.current = true;
2381
- }, 100);
2382
- useEffect(()=>{
2383
- const container = scrollContainerRef.current;
2384
- if (!container) return;
2385
- checkScrollOverflow();
2386
- container.addEventListener('scroll', scrollHandler);
2387
- const resizeObserver = new ResizeObserver(checkScrollOverflow);
2388
- resizeObserver.observe(container);
2389
- return ()=>{
2390
- container.removeEventListener('scroll', scrollHandler);
2391
- resizeObserver.disconnect();
2392
- };
2393
- }, [
2394
- checkScrollOverflow,
2395
- scrollHandler
2396
- ]);
2397
2430
  // Scroll to the selected tab when the selected key changes
2398
2431
  // We use the state.selectedItem here instead of just the state.selectedKey, since state.selectedItem is set when the tab list is mounted
2399
2432
  // This way we can make sure the default selected tab is scrolled into view.
@@ -2410,7 +2443,7 @@ const tabsVariants = cva({
2410
2443
  // Set the scroll position to try and ish center the selected tab
2411
2444
  const scrollLeft = offsetLeft - (containerWidth - selectedTab.clientWidth) / 2;
2412
2445
  // When the scroll is initiated by the user we want a smooth scroll
2413
- if (hasScrollingOccurredRef.current) {
2446
+ if (hasScrollingOccurred) {
2414
2447
  // The RAC TabList component prevents us from using scroll snapping, so by using requestAnimationFrame, we can ensure the scroll position is set correctly.
2415
2448
  // We want the active tab to be centered in the view when navigating with the scroll buttons, selecting a tab with the keyboard, or clicking on a tab.
2416
2449
  requestAnimationFrame(()=>{
@@ -2427,7 +2460,9 @@ const tabsVariants = cva({
2427
2460
  });
2428
2461
  }
2429
2462
  }, [
2430
- state?.selectedItem
2463
+ state?.selectedItem,
2464
+ hasScrollingOccurred,
2465
+ scrollContainerRef
2431
2466
  ]);
2432
2467
  return /*#__PURE__*/ jsxs("div", {
2433
2468
  className: "relative overflow-hidden",
@@ -2447,33 +2482,21 @@ const tabsVariants = cva({
2447
2482
  },
2448
2483
  children: children
2449
2484
  }),
2450
- // biome-ignore lint/a11y/useKeyWithClickEvents: These are just for scrolling, and not necessary for keyboard or screen reader users. They can use the tablist's keyboard navigation pattern to navigate the entire list the same way.
2451
- /*#__PURE__*/ jsx("div", {
2485
+ /*#__PURE__*/ jsx(ScrollButton, {
2486
+ direction: "left",
2452
2487
  onClick: onPrev,
2453
- className: cx('cursor-pointer', 'flex items-center', // Ensure click are of 44px by 44px.
2454
- 'size-11', // Position the button at the left of the tab list, with a small (left) offset to avoid overlap with the tabs.
2455
- // The bottom offset is to avoid overlap with the tab lists bottom border.
2456
- '-left-3 absolute bottom-0.25', // Creates a gradient background that fades to transparent on the right side, which creates a smooth overlay effect over the tabs that are scrolled out of view.
2457
- 'bg-[linear-gradient(90deg,white,white_calc(100%-10px),transparent)]', // Slide in and out based on scroll position, match duration with the debounce delay of the scrollHandler function
2458
- // Wait until user started scrolling until animation is applied, to prevent the animation from running on mount
2459
- hasScrollingOccurredRef.current && 'duration-100 ease-in motion-safe:transition-transform', !canScrollLeft && '-translate-x-full pointer-events-none'),
2460
- children: /*#__PURE__*/ jsx(ChevronLeft, {
2461
- className: "mt-0.25 h-6 w-full text-black"
2462
- })
2488
+ isVisible: canScrollLeft,
2489
+ hasScrollingOccurred: hasScrollingOccurred,
2490
+ className: "absolute bottom-0.25 size-11",
2491
+ iconClassName: "mt-0.25 h-6 w-full text-black"
2463
2492
  }),
2464
- // biome-ignore lint/a11y/useKeyWithClickEvents: These are just for scrolling, and not necessary for keyboard or screen reader users. They can use the tablist's keyboard navigation pattern to navigate the entire list the same way.
2465
- /*#__PURE__*/ jsx("div", {
2493
+ /*#__PURE__*/ jsx(ScrollButton, {
2494
+ direction: "right",
2466
2495
  onClick: onNext,
2467
- className: cx('cursor-pointer', 'flex items-center', // Ensure click are of 44px by 44px.
2468
- 'size-11', // Position the button at the right of the tab list, with a small (right) offset to avoid overlap with the tabs.
2469
- // The bottom offset is to avoid overlap with the tab lists bottom border.
2470
- '-right-3 absolute bottom-0.25', // Creates a gradient background that fades to transparent on the left side, which creates a smooth overlay effect over the tabs that are scrolled out of view.
2471
- 'bg-[linear-gradient(90deg,transparent,white_calc(10px),white)]', // Slide in and out based on scroll position, match duration with the debounce delay of the scrollHandler function
2472
- // Wait until user started scrolling until animation is applied, to prevent the animation from running on mount
2473
- hasScrollingOccurredRef.current && 'duration-100 ease-in motion-safe:transition-transform', !canScrollRight && 'pointer-events-none translate-x-full'),
2474
- children: /*#__PURE__*/ jsx(ChevronRight, {
2475
- className: "mt-0.25 h-6 w-full text-black "
2476
- })
2496
+ isVisible: canScrollRight,
2497
+ hasScrollingOccurred: hasScrollingOccurred,
2498
+ className: "absolute bottom-0.25 size-11",
2499
+ iconClassName: "mt-0.25 h-6 w-full text-black"
2477
2500
  })
2478
2501
  ]
2479
2502
  });
@@ -2500,7 +2523,128 @@ const tabsVariants = cva({
2500
2523
  const { className, children, ...restProps } = props;
2501
2524
  return /*#__PURE__*/ jsx(TabPanel$1, {
2502
2525
  ...restProps,
2503
- className: cx(className, 'flex-1 data-focus-visible:outline-focus-offset'),
2526
+ shouldForceMount: true,
2527
+ className: cx(className, 'flex-1 data-inert:hidden data-focus-visible:outline-focus-offset'),
2528
+ children: children
2529
+ });
2530
+ }
2531
+
2532
+ const tableVariants = cva({
2533
+ base: [
2534
+ 'relative'
2535
+ ],
2536
+ variants: {
2537
+ variant: {
2538
+ default: '',
2539
+ 'zebra-striped': ''
2540
+ }
2541
+ }
2542
+ });
2543
+ const tableRowVariants = cva({
2544
+ base: [
2545
+ 'data-focus-visible:outline-focus-inset',
2546
+ 'group-data-[variant=zebra-striped]:odd:bg-white',
2547
+ 'group-data-[variant=zebra-striped]:even:bg-sky-lightest'
2548
+ ]
2549
+ });
2550
+ /**
2551
+ * A container component for displaying tabular data with horizontal scrolling support.
2552
+ */ function Table(props) {
2553
+ const { className, children, variant = 'default', ...restProps } = props;
2554
+ const { scrollContainerRef, canScrollLeft, canScrollRight, hasScrollingOccurred } = useHorizontalScroll();
2555
+ const handleScroll = useCallback((direction)=>{
2556
+ const container = scrollContainerRef.current;
2557
+ if (!container) return;
2558
+ const scrollAmount = container.clientWidth * 0.8;
2559
+ container.scrollBy({
2560
+ left: direction === 'left' ? -scrollAmount : scrollAmount,
2561
+ behavior: 'smooth'
2562
+ });
2563
+ }, [
2564
+ scrollContainerRef
2565
+ ]);
2566
+ return /*#__PURE__*/ jsx("div", {
2567
+ className: tableVariants({
2568
+ className,
2569
+ variant
2570
+ }),
2571
+ children: /*#__PURE__*/ jsxs("div", {
2572
+ className: "relative overflow-hidden",
2573
+ children: [
2574
+ /*#__PURE__*/ jsx(ScrollButton, {
2575
+ direction: "left",
2576
+ onClick: ()=>handleScroll('left'),
2577
+ isVisible: canScrollLeft,
2578
+ hasScrollingOccurred: hasScrollingOccurred,
2579
+ className: "-translate-y-1/2 absolute top-5 z-10 h-11 w-11",
2580
+ iconClassName: "h-5 w-5"
2581
+ }),
2582
+ /*#__PURE__*/ jsx(ScrollButton, {
2583
+ direction: "right",
2584
+ onClick: ()=>handleScroll('right'),
2585
+ isVisible: canScrollRight,
2586
+ hasScrollingOccurred: hasScrollingOccurred,
2587
+ className: "-translate-y-1/2 absolute top-5 z-10 h-11 w-11",
2588
+ iconClassName: "h-5 w-5"
2589
+ }),
2590
+ /*#__PURE__*/ jsx("div", {
2591
+ ref: scrollContainerRef,
2592
+ className: "scrollbar-hidden overflow-x-auto",
2593
+ style: {
2594
+ WebkitOverflowScrolling: 'touch'
2595
+ },
2596
+ children: /*#__PURE__*/ jsx(Table$1, {
2597
+ ...restProps,
2598
+ className: "group w-full min-w-fit",
2599
+ "data-variant": variant,
2600
+ children: children
2601
+ })
2602
+ })
2603
+ ]
2604
+ })
2605
+ });
2606
+ }
2607
+ /**
2608
+ * Container for table column headers.
2609
+ */ function TableHeader({ className, children, ...restProps }) {
2610
+ return /*#__PURE__*/ jsx(TableHeader$1, {
2611
+ ...restProps,
2612
+ className: cx(className, 'border-black border-b'),
2613
+ children: children
2614
+ });
2615
+ }
2616
+ function TableColumn(props) {
2617
+ const { className, children, ...restProps } = props;
2618
+ return /*#__PURE__*/ jsx(Column, {
2619
+ ...restProps,
2620
+ className: cx(className, 'px-4 py-3 text-left font-medium text-black text-sm', 'data-focus-visible:outline-focus-inset', 'min-w-fit whitespace-nowrap'),
2621
+ children: children
2622
+ });
2623
+ }
2624
+ /**
2625
+ * Container for table rows.
2626
+ */ function TableBody({ className, children, ...restProps }) {
2627
+ return /*#__PURE__*/ jsx(TableBody$1, {
2628
+ ...restProps,
2629
+ className: className,
2630
+ children: children
2631
+ });
2632
+ }
2633
+ function TableRow(props) {
2634
+ const { className, children, ...restProps } = props;
2635
+ return /*#__PURE__*/ jsx(Row, {
2636
+ ...restProps,
2637
+ className: tableRowVariants({
2638
+ className
2639
+ }),
2640
+ children: children
2641
+ });
2642
+ }
2643
+ function TableCell(props) {
2644
+ const { className, children, ...restProps } = props;
2645
+ return /*#__PURE__*/ jsx(Cell, {
2646
+ ...restProps,
2647
+ className: cx(className, 'px-4 py-3 text-black text-sm leading-relaxed', 'min-w-fit whitespace-nowrap', 'align-top', 'data-focus-visible:outline-focus-inset'),
2504
2648
  children: children
2505
2649
  });
2506
2650
  }
@@ -2561,4 +2705,4 @@ const LinkListItem = ({ children, isExternal, className, ...restProps })=>{
2561
2705
  });
2562
2706
  };
2563
2707
 
2564
- 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, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, Disclosure as UNSAFE_Disclosure, DisclosureButton as UNSAFE_DisclosureButton, DisclosurePanel as UNSAFE_DisclosurePanel, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, CustomLink as UNSAFE_Link, LinkList as UNSAFE_LinkList, LinkListItem as UNSAFE_LinkListItem, Modal as UNSAFE_Modal, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, TabPanel as UNSAFE_TabPanel, Tabs as UNSAFE_Tabs, Tag as UNSAFE_Tag, TagGroup as UNSAFE_TagGroup, TagList as UNSAFE_TagList, VideoLoop, _useLocale as useLocale };
2708
+ 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, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, Disclosure as UNSAFE_Disclosure, DisclosureButton as UNSAFE_DisclosureButton, DisclosurePanel as UNSAFE_DisclosurePanel, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, CustomLink as UNSAFE_Link, LinkList as UNSAFE_LinkList, LinkListItem as UNSAFE_LinkListItem, 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, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, Tabs as UNSAFE_Tabs, Tag as UNSAFE_Tag, TagGroup as UNSAFE_TagGroup, TagList as UNSAFE_TagList, VideoLoop, _useLocale as useLocale };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "3.0.13",
3
+ "version": "3.0.15",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"