@obosbbl/grunnmuren-react 2.0.0-canary.46 → 2.0.0-canary.48

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,8 +1,9 @@
1
- import { RouterProvider, ButtonProps as ButtonProps$1, LinkProps, CheckboxProps as CheckboxProps$1, CheckboxGroupProps as CheckboxGroupProps$1, ListBoxItemProps, ComboBoxProps, RadioGroupProps as RadioGroupProps$1, RadioProps as RadioProps$1, SelectProps as SelectProps$1, TextFieldProps as TextFieldProps$1, NumberFieldProps as NumberFieldProps$1, ContextValue, BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, Link } from 'react-aria-components';
1
+ import { RouterProvider, ButtonProps as ButtonProps$1, LinkProps, 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, ContextValue, BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1, Link } from 'react-aria-components';
2
2
  export { ListBoxItemProps as ComboboxItemProps, Form, 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';
5
5
  import { HTMLProps, ReactNode } from 'react';
6
+ import * as cva from 'cva';
6
7
  import { VariantProps } from 'cva';
7
8
  import { DateFormatterOptions } from 'react-aria';
8
9
 
@@ -58,117 +59,21 @@ declare const badgeVariants: (props?: ({
58
59
  color?: "gray-dark" | "mint" | "sky" | "white" | "blue-dark" | "green-dark" | undefined;
59
60
  size?: "small" | "medium" | "large" | undefined;
60
61
  } & ({
61
- class?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
62
- [x: string]: any;
63
- } | null | undefined)[] | {
64
- [x: string]: any;
65
- } | null | undefined)[] | {
66
- [x: string]: any;
67
- } | null | undefined)[] | {
68
- [x: string]: any;
69
- } | null | undefined)[] | {
70
- [x: string]: any;
71
- } | null | undefined)[] | {
72
- [x: string]: any;
73
- } | null | undefined)[] | {
74
- [x: string]: any;
75
- } | null | undefined)[] | {
76
- [x: string]: any;
77
- } | null | undefined)[] | {
78
- [x: string]: any;
79
- } | null | undefined)[] | {
80
- [x: string]: any;
81
- } | null | undefined)[] | {
82
- [x: string]: any;
83
- } | null | undefined)[] | {
84
- [x: string]: any;
85
- } | null | undefined;
62
+ class?: cva.ClassValue;
86
63
  className?: never;
87
64
  } | {
88
65
  class?: never;
89
- className?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
90
- [x: string]: any;
91
- } | null | undefined)[] | {
92
- [x: string]: any;
93
- } | null | undefined)[] | {
94
- [x: string]: any;
95
- } | null | undefined)[] | {
96
- [x: string]: any;
97
- } | null | undefined)[] | {
98
- [x: string]: any;
99
- } | null | undefined)[] | {
100
- [x: string]: any;
101
- } | null | undefined)[] | {
102
- [x: string]: any;
103
- } | null | undefined)[] | {
104
- [x: string]: any;
105
- } | null | undefined)[] | {
106
- [x: string]: any;
107
- } | null | undefined)[] | {
108
- [x: string]: any;
109
- } | null | undefined)[] | {
110
- [x: string]: any;
111
- } | null | undefined)[] | {
112
- [x: string]: any;
113
- } | null | undefined;
66
+ className?: cva.ClassValue;
114
67
  })) | undefined) => string;
115
68
  declare const _Badge: react.ForwardRefExoticComponent<VariantProps<(props?: ({
116
69
  color?: "gray-dark" | "mint" | "sky" | "white" | "blue-dark" | "green-dark" | undefined;
117
70
  size?: "small" | "medium" | "large" | undefined;
118
71
  } & ({
119
- class?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
120
- [x: string]: any;
121
- } | null | undefined)[] | {
122
- [x: string]: any;
123
- } | null | undefined)[] | {
124
- [x: string]: any;
125
- } | null | undefined)[] | {
126
- [x: string]: any;
127
- } | null | undefined)[] | {
128
- [x: string]: any;
129
- } | null | undefined)[] | {
130
- [x: string]: any;
131
- } | null | undefined)[] | {
132
- [x: string]: any;
133
- } | null | undefined)[] | {
134
- [x: string]: any;
135
- } | null | undefined)[] | {
136
- [x: string]: any;
137
- } | null | undefined)[] | {
138
- [x: string]: any;
139
- } | null | undefined)[] | {
140
- [x: string]: any;
141
- } | null | undefined)[] | {
142
- [x: string]: any;
143
- } | null | undefined;
72
+ class?: cva.ClassValue;
144
73
  className?: never;
145
74
  } | {
146
75
  class?: never;
147
- className?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
148
- [x: string]: any;
149
- } | null | undefined)[] | {
150
- [x: string]: any;
151
- } | null | undefined)[] | {
152
- [x: string]: any;
153
- } | null | undefined)[] | {
154
- [x: string]: any;
155
- } | null | undefined)[] | {
156
- [x: string]: any;
157
- } | null | undefined)[] | {
158
- [x: string]: any;
159
- } | null | undefined)[] | {
160
- [x: string]: any;
161
- } | null | undefined)[] | {
162
- [x: string]: any;
163
- } | null | undefined)[] | {
164
- [x: string]: any;
165
- } | null | undefined)[] | {
166
- [x: string]: any;
167
- } | null | undefined)[] | {
168
- [x: string]: any;
169
- } | null | undefined)[] | {
170
- [x: string]: any;
171
- } | null | undefined;
76
+ className?: cva.ClassValue;
172
77
  })) | undefined) => string> & {
173
78
  children?: React.ReactNode;
174
79
  className?: string;
@@ -183,59 +88,11 @@ declare const buttonVariants: (props?: ({
183
88
  isIconOnly?: boolean | undefined;
184
89
  isPending?: boolean | undefined;
185
90
  } & ({
186
- class?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
187
- [x: string]: any;
188
- } | null | undefined)[] | {
189
- [x: string]: any;
190
- } | null | undefined)[] | {
191
- [x: string]: any;
192
- } | null | undefined)[] | {
193
- [x: string]: any;
194
- } | null | undefined)[] | {
195
- [x: string]: any;
196
- } | null | undefined)[] | {
197
- [x: string]: any;
198
- } | null | undefined)[] | {
199
- [x: string]: any;
200
- } | null | undefined)[] | {
201
- [x: string]: any;
202
- } | null | undefined)[] | {
203
- [x: string]: any;
204
- } | null | undefined)[] | {
205
- [x: string]: any;
206
- } | null | undefined)[] | {
207
- [x: string]: any;
208
- } | null | undefined)[] | {
209
- [x: string]: any;
210
- } | null | undefined;
91
+ class?: cva.ClassValue;
211
92
  className?: never;
212
93
  } | {
213
94
  class?: never;
214
- className?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
215
- [x: string]: any;
216
- } | null | undefined)[] | {
217
- [x: string]: any;
218
- } | null | undefined)[] | {
219
- [x: string]: any;
220
- } | null | undefined)[] | {
221
- [x: string]: any;
222
- } | null | undefined)[] | {
223
- [x: string]: any;
224
- } | null | undefined)[] | {
225
- [x: string]: any;
226
- } | null | undefined)[] | {
227
- [x: string]: any;
228
- } | null | undefined)[] | {
229
- [x: string]: any;
230
- } | null | undefined)[] | {
231
- [x: string]: any;
232
- } | null | undefined)[] | {
233
- [x: string]: any;
234
- } | null | undefined)[] | {
235
- [x: string]: any;
236
- } | null | undefined)[] | {
237
- [x: string]: any;
238
- } | null | undefined;
95
+ className?: cva.ClassValue;
239
96
  })) | undefined) => string;
240
97
  type ButtonOrLinkProps$1 = VariantProps<typeof buttonVariants> & {
241
98
  children?: React.ReactNode;
@@ -303,6 +160,14 @@ declare const _CheckboxGroup: react.ForwardRefExoticComponent<{
303
160
  } & Omit<CheckboxGroupProps$1, "style" | "children" | "className" | "isDisabled" | "isReadOnly" | "orientation"> & react.RefAttributes<HTMLDivElement>>;
304
161
 
305
162
  declare const ListBoxItem: (props: ListBoxItemProps) => react_jsx_runtime.JSX.Element;
163
+ /**
164
+ * This component can be used to group items in a listbox
165
+ */
166
+ declare const ListBoxSection: <T extends object>({ className, ...restProps }: ListBoxSectionProps<T>) => react_jsx_runtime.JSX.Element;
167
+ /**
168
+ * This component can be used to label grouped items in a `ListBoxSection` with a heading
169
+ */
170
+ declare const ListBoxHeader: (props: HeadingProps$1) => react_jsx_runtime.JSX.Element;
306
171
 
307
172
  type ComboboxProps<T extends object> = {
308
173
  children: React.ReactNode;
@@ -592,59 +457,11 @@ declare const _NumberField: react.ForwardRefExoticComponent<{
592
457
  declare const alertVariants: (props?: ({
593
458
  variant?: "info" | "success" | "warning" | "danger" | undefined;
594
459
  } & ({
595
- class?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
596
- [x: string]: any;
597
- } | null | undefined)[] | {
598
- [x: string]: any;
599
- } | null | undefined)[] | {
600
- [x: string]: any;
601
- } | null | undefined)[] | {
602
- [x: string]: any;
603
- } | null | undefined)[] | {
604
- [x: string]: any;
605
- } | null | undefined)[] | {
606
- [x: string]: any;
607
- } | null | undefined)[] | {
608
- [x: string]: any;
609
- } | null | undefined)[] | {
610
- [x: string]: any;
611
- } | null | undefined)[] | {
612
- [x: string]: any;
613
- } | null | undefined)[] | {
614
- [x: string]: any;
615
- } | null | undefined)[] | {
616
- [x: string]: any;
617
- } | null | undefined)[] | {
618
- [x: string]: any;
619
- } | null | undefined;
460
+ class?: cva.ClassValue;
620
461
  className?: never;
621
462
  } | {
622
463
  class?: never;
623
- className?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
624
- [x: string]: any;
625
- } | null | undefined)[] | {
626
- [x: string]: any;
627
- } | null | undefined)[] | {
628
- [x: string]: any;
629
- } | null | undefined)[] | {
630
- [x: string]: any;
631
- } | null | undefined)[] | {
632
- [x: string]: any;
633
- } | null | undefined)[] | {
634
- [x: string]: any;
635
- } | null | undefined)[] | {
636
- [x: string]: any;
637
- } | null | undefined)[] | {
638
- [x: string]: any;
639
- } | null | undefined)[] | {
640
- [x: string]: any;
641
- } | null | undefined)[] | {
642
- [x: string]: any;
643
- } | null | undefined)[] | {
644
- [x: string]: any;
645
- } | null | undefined)[] | {
646
- [x: string]: any;
647
- } | null | undefined;
464
+ className?: cva.ClassValue;
648
465
  })) | undefined) => string;
649
466
  type Props = VariantProps<typeof alertVariants> & {
650
467
  children: React.ReactNode;
@@ -654,6 +471,8 @@ type Props = VariantProps<typeof alertVariants> & {
654
471
  role: 'alert' | 'status' | 'none';
655
472
  /** Additional CSS className for the element. */
656
473
  className?: string;
474
+ /** Overrides the default icon for the alertbox variant. Should be used sparingly as the default icons are visually connected to the color of the variant. */
475
+ icon?: React.ComponentType;
657
476
  /**
658
477
  * Controls if the alert is expandable or not
659
478
  * @default false
@@ -676,7 +495,7 @@ type Props = VariantProps<typeof alertVariants> & {
676
495
  */
677
496
  onDismiss?: () => void;
678
497
  };
679
- declare const Alertbox: ({ children, role, className, variant, isDismissable, isDismissed, onDismiss, isExpandable, }: Props) => react_jsx_runtime.JSX.Element | undefined;
498
+ declare const Alertbox: ({ children, role, className, icon, variant, isDismissable, isDismissed, onDismiss, isExpandable, }: Props) => react_jsx_runtime.JSX.Element | undefined;
680
499
 
681
500
  type HeadingProps = HTMLProps<HTMLHeadingElement> & {
682
501
  children?: React.ReactNode;
@@ -699,6 +518,10 @@ declare const Media: (props: MediaProps) => react_jsx_runtime.JSX.Element;
699
518
  type FooterProps = HTMLProps<HTMLDivElement> & {
700
519
  children: React.ReactNode;
701
520
  };
521
+ type CaptionProps = HTMLProps<HTMLDivElement> & {
522
+ children: React.ReactNode;
523
+ };
524
+ declare const Caption: ({ className, ...restProps }: CaptionProps) => react_jsx_runtime.JSX.Element;
702
525
  declare const Footer: (props: FooterProps) => react_jsx_runtime.JSX.Element;
703
526
  declare const _Heading: react.ForwardRefExoticComponent<Omit<HeadingProps, "ref"> & react.RefAttributes<HTMLHeadingElement>>;
704
527
  declare const _Content: react.ForwardRefExoticComponent<Omit<ContentProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
@@ -756,59 +579,11 @@ type CardProps = VariantProps<typeof cardVariants> & {
756
579
  declare const cardVariants: (props?: ({
757
580
  variant?: "subtle" | "outlined" | undefined;
758
581
  } & ({
759
- class?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
760
- [x: string]: any;
761
- } | null | undefined)[] | {
762
- [x: string]: any;
763
- } | null | undefined)[] | {
764
- [x: string]: any;
765
- } | null | undefined)[] | {
766
- [x: string]: any;
767
- } | null | undefined)[] | {
768
- [x: string]: any;
769
- } | null | undefined)[] | {
770
- [x: string]: any;
771
- } | null | undefined)[] | {
772
- [x: string]: any;
773
- } | null | undefined)[] | {
774
- [x: string]: any;
775
- } | null | undefined)[] | {
776
- [x: string]: any;
777
- } | null | undefined)[] | {
778
- [x: string]: any;
779
- } | null | undefined)[] | {
780
- [x: string]: any;
781
- } | null | undefined)[] | {
782
- [x: string]: any;
783
- } | null | undefined;
582
+ class?: cva.ClassValue;
784
583
  className?: never;
785
584
  } | {
786
585
  class?: never;
787
- className?: string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | (string | number | boolean | /*elided*/ any | {
788
- [x: string]: any;
789
- } | null | undefined)[] | {
790
- [x: string]: any;
791
- } | null | undefined)[] | {
792
- [x: string]: any;
793
- } | null | undefined)[] | {
794
- [x: string]: any;
795
- } | null | undefined)[] | {
796
- [x: string]: any;
797
- } | null | undefined)[] | {
798
- [x: string]: any;
799
- } | null | undefined)[] | {
800
- [x: string]: any;
801
- } | null | undefined)[] | {
802
- [x: string]: any;
803
- } | null | undefined)[] | {
804
- [x: string]: any;
805
- } | null | undefined)[] | {
806
- [x: string]: any;
807
- } | null | undefined)[] | {
808
- [x: string]: any;
809
- } | null | undefined)[] | {
810
- [x: string]: any;
811
- } | null | undefined;
586
+ className?: cva.ClassValue;
812
587
  })) | undefined) => string;
813
588
  declare const Card: ({ children, className: _className, variant, ...restProps }: CardProps) => react_jsx_runtime.JSX.Element;
814
589
  type CardLinkWrapperProps = {
@@ -837,4 +612,20 @@ type DateFormatterProps = {
837
612
  */
838
613
  declare const DateFormatter: ({ options: _options, value, children: render, }: DateFormatterProps) => ReactNode;
839
614
 
840
- export { _Accordion as Accordion, _AccordionItem as AccordionItem, type AccordionItemProps, type AccordionProps, Alertbox, type Props as AlertboxProps, _Backlink as Backlink, type BacklinkProps, _Badge as Badge, type BadgeProps, _Breadcrumb as Breadcrumb, type BreadcrumbProps, _Breadcrumbs as Breadcrumbs, type BreadcrumbsProps, _Button as Button, type ButtonProps, Card, CardLink, type CardLinkProps, type CardProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ListBoxItem as ComboboxItem, type ComboboxProps, _Content as Content, ContentContext, type ContentProps, DateFormatter, type DateFormatterProps, Footer, type FooterProps, GrunnmurenProvider, type GrunnmurenProviderProps, _Heading as Heading, HeadingContext, type HeadingProps, type Locale, Media, type MediaProps, _NumberField as NumberField, type NumberFieldProps, _Radio as Radio, _RadioGroup as RadioGroup, type RadioGroupProps, type RadioProps, _Select as Select, ListBoxItem as SelectItem, type SelectProps, _TextArea as TextArea, type TextAreaProps, _TextField as TextField, type TextFieldProps, _useLocale as useLocale };
615
+ type VideoLoopProps = {
616
+ /** The video url */
617
+ src: string;
618
+ /** The video format */
619
+ format: string;
620
+ /**
621
+ * The content of the video must have a text description, so that it is accessible to screen readers.
622
+ * You can either just provide a just caption, just an alt text, or both a caption and an alt text.
623
+ * Make sure the alt text doesn't repeat too much of the caption text, if so just a caption is sufficent.
624
+ * Think of this just as an alt text, but for a muted video - this text will not be visible, but read by screen readers.
625
+ * */
626
+ alt?: string;
627
+ className?: string;
628
+ };
629
+ declare const VideoLoop: ({ src, format, alt, className }: VideoLoopProps) => react_jsx_runtime.JSX.Element;
630
+
631
+ export { _Accordion as Accordion, _AccordionItem as AccordionItem, type AccordionItemProps, type AccordionProps, Alertbox, type Props as AlertboxProps, _Backlink as Backlink, type BacklinkProps, _Badge as Badge, type BadgeProps, _Breadcrumb as Breadcrumb, type BreadcrumbProps, _Breadcrumbs as Breadcrumbs, type BreadcrumbsProps, _Button as Button, type ButtonProps, Caption, type CaptionProps, Card, CardLink, type CardLinkProps, type CardProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, type ComboboxProps, ListBoxSection as ComboboxSection, _Content as Content, ContentContext, type ContentProps, DateFormatter, type DateFormatterProps, Footer, type FooterProps, GrunnmurenProvider, type GrunnmurenProviderProps, _Heading as Heading, HeadingContext, type HeadingProps, type Locale, Media, type MediaProps, _NumberField as NumberField, type NumberFieldProps, _Radio as Radio, _RadioGroup as RadioGroup, type RadioGroupProps, type RadioProps, _Select as Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, type SelectProps, ListBoxSection as SelectSection, _TextArea as TextArea, type TextAreaProps, _TextField as TextField, type TextFieldProps, VideoLoop, _useLocale as useLocale };
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
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, 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 } 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 } from 'react-aria-components';
3
3
  export { Form } from 'react-aria-components';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
- import { ChevronDown, LoadingSpinner, Check, Close, InfoCircle, CheckCircle, Warning, Error, ChevronRight, ChevronLeft } from '@obosbbl/grunnmuren-icons-react';
5
+ import { ChevronDown, LoadingSpinner, Check, Close, InfoCircle, CheckCircle, Warning, Error, ChevronRight, ChevronLeft, PlayerPause, PlayerPlay } from '@obosbbl/grunnmuren-icons-react';
6
6
  import { useLayoutEffect } from '@react-aria/utils';
7
7
  import { cx, cva, compose } from 'cva';
8
- import { createContext, forwardRef, Children, useId, useState } from 'react';
8
+ import { createContext, forwardRef, Children, useId, useState, useRef, useEffect } from 'react';
9
9
  import { useProgressBar, useDateFormatter } from 'react-aria';
10
10
 
11
11
  function GrunnmurenProvider({ children, locale = 'nb', navigate, useHref }) {
@@ -55,6 +55,11 @@ const Media = (props)=>/*#__PURE__*/ jsx("div", {
55
55
  ...props,
56
56
  "data-slot": "media"
57
57
  });
58
+ const Caption = ({ className, ...restProps })=>/*#__PURE__*/ jsx("div", {
59
+ ...restProps,
60
+ className: cx('description', className),
61
+ "data-slot": "caption"
62
+ });
58
63
  const Footer = (props)=>/*#__PURE__*/ jsx("div", {
59
64
  ...props,
60
65
  "data-slot": "footer"
@@ -237,7 +242,7 @@ const _Badge = /*#__PURE__*/ forwardRef(Badge);
237
242
  },
238
243
  // Make the content of the button transparent to hide it's content, but keep the button width
239
244
  isPending: {
240
- true: 'relative !text-transparent',
245
+ true: '!text-transparent relative',
241
246
  false: null
242
247
  }
243
248
  },
@@ -262,7 +267,7 @@ const _Badge = /*#__PURE__*/ forwardRef(Badge);
262
267
  color: 'mint',
263
268
  variant: 'primary',
264
269
  // Darken bg by 20% on hover. The color is manually crafted
265
- className: 'active:[#9ddac6] bg-mint text-black hover:bg-[#8dd4bd] [&_[role="progressbar"]]:text-black'
270
+ className: 'bg-mint text-black hover:bg-[#8dd4bd] active:[#9ddac6] [&_[role="progressbar"]]:text-black'
266
271
  },
267
272
  {
268
273
  color: 'mint',
@@ -347,7 +352,7 @@ function Button(props, ref) {
347
352
  const _Button = /*#__PURE__*/ forwardRef(Button);
348
353
 
349
354
  const formField = cx('group flex flex-col gap-2');
350
- const formFieldError = cx('w-fit rounded-sm bg-red-light px-2 py-1 text-sm leading-6 text-red');
355
+ const formFieldError = cx('w-fit rounded-sm bg-red-light px-2 py-1 text-red text-sm leading-6');
351
356
  const input = cva({
352
357
  base: [
353
358
  // All inputs should always have a white background (this also ensures that type="search" on Safri doesn't get a gray background)
@@ -356,7 +361,7 @@ const input = cva({
356
361
  // Setting min-height to prevent the input from collapsing in Safari
357
362
  // Combining these with a padding-y as base classes makes it easier to standardize the height (44px) of all inputs
358
363
  'box-content min-h-6 py-2.5',
359
- 'rounded-md text-base font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
364
+ 'rounded-md font-normal text-base leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
360
365
  // invalid styles
361
366
  'group-data-[invalid]:ring-focus group-data-[invalid]:ring-red',
362
367
  // Fix invisible ring on safari: https://github.com/tailwindlabs/tailwindcss.com/issues/1135
@@ -370,7 +375,7 @@ const input = cva({
370
375
  },
371
376
  isGrouped: {
372
377
  false: 'px-3',
373
- true: 'flex-1 !ring-0'
378
+ true: '!ring-0 flex-1'
374
379
  }
375
380
  },
376
381
  defaultVariants: {
@@ -383,7 +388,7 @@ const inputGroup = cx([
383
388
  'group-data-[invalid]:ring-focus group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring'
384
389
  ]);
385
390
  const dropdown = {
386
- popover: cx('min-w-[--trigger-width] overflow-y-auto rounded-md border border-black bg-white shadow data-[entering]:animate-in data-[exiting]:animate-out data-[entering]:fade-in data-[exiting]:fade-out'),
391
+ popover: cx('data-[entering]:fade-in data-[exiting]:fade-out min-w-[--trigger-width] overflow-y-auto rounded-md border border-black bg-white shadow data-[entering]:animate-in data-[exiting]:animate-out'),
387
392
  // overflow-x-hidden is needed to prevent visible vertical scrollbars from overflowing the border radius of the popover
388
393
  listbox: cx('max-h-[25rem] overflow-x-hidden text-sm outline-none'),
389
394
  chevronIcon: cx('text-base transition-transform duration-150 group-data-[open]:rotate-180 motion-reduce:transition-none')
@@ -400,7 +405,7 @@ function ErrorMessage(props) {
400
405
  }
401
406
 
402
407
  const defaultClasses$1 = cx([
403
- 'group relative left-0 -mx-2.5 inline-flex max-w-fit cursor-pointer items-start gap-4 p-2.5 leading-7'
408
+ 'group -mx-2.5 relative left-0 inline-flex max-w-fit cursor-pointer items-start gap-4 p-2.5 leading-7'
404
409
  ]);
405
410
  // Pulling this out into it's own component. Will probably export it in the future
406
411
  // so it can be used in other views, outside of an input of type checkbox, like in table rows.
@@ -418,10 +423,10 @@ function CheckmarkBox() {
418
423
  // focus
419
424
  'group-data-[focus-visible]:outline-focus-offset',
420
425
  // hovered
421
- 'group-data-[hovered]:border-green group-data-[hovered]:group-data-[invalid]:border-red group-data-[hovered]:bg-green-lightest group-data-[hovered]:group-data-[invalid]:bg-red-light',
426
+ 'group-data-[hovered]:group-data-[invalid]:border-red group-data-[hovered]:group-data-[invalid]:bg-red-light group-data-[hovered]:border-green group-data-[hovered]:bg-green-lightest',
422
427
  // invalid - The border is 1 px thicker when invalid. We don't actually want to change the border width, as that causes the element's size to change
423
428
  // so we use an inner shadow of 1 px instead to pad the actual border
424
- 'group-data-[invalid]:border-red group-data-[invalid]:group-data-[selected]:shadow-none group-data-[invalid]:shadow-[inset_0_0_0_1px] group-data-[invalid]:shadow-red'
429
+ 'group-data-[invalid]:group-data-[selected]:shadow-none group-data-[invalid]:border-red group-data-[invalid]:shadow-[inset_0_0_0_1px] group-data-[invalid]:shadow-red'
425
430
  ]),
426
431
  children: /*#__PURE__*/ jsx(Check, {
427
432
  className: "h-full w-full opacity-0 group-data-[selected]:opacity-100"
@@ -551,6 +556,20 @@ const ListBoxItem = (props)=>{
551
556
  })
552
557
  });
553
558
  };
559
+ /**
560
+ * This component can be used to group items in a listbox
561
+ */ const ListBoxSection = ({ className, ...restProps })=>/*#__PURE__*/ jsx(ListBoxSection$1, {
562
+ ...restProps,
563
+ // The :not(:first-child) selector adds extra spacing to all the options, but not the section (group) headings
564
+ // This way we get the desired extra indent on all options within a group
565
+ className: cx(className, 'pb-1 [&>:not(:first-child)]:pl-10')
566
+ });
567
+ /**
568
+ * This component can be used to label grouped items in a `ListBoxSection` with a heading
569
+ */ const ListBoxHeader = (props)=>/*#__PURE__*/ jsx(Header, {
570
+ ...props,
571
+ className: cx(props.className, 'mx-6 cursor-default py-2 font-medium text-blue-dark leading-6')
572
+ });
554
573
 
555
574
  function InputAddonDivider() {
556
575
  return /*#__PURE__*/ jsx("span", {
@@ -641,7 +660,7 @@ function RadioGroup(props, ref) {
641
660
  const _RadioGroup = /*#__PURE__*/ forwardRef(RadioGroup);
642
661
 
643
662
  const defaultClasses = cx([
644
- 'relative -ml-2.5 inline-flex max-w-fit cursor-pointer items-start gap-4 py-2.5 pl-2.5 leading-7',
663
+ '-ml-2.5 relative inline-flex max-w-fit cursor-pointer items-start gap-4 py-2.5 pl-2.5 leading-7',
645
664
  // the radio button itself
646
665
  'before:flex-none before:rounded-full before:border-2 before:border-black',
647
666
  // to vertically align the radio we need to calculate the label's height, which is equal to it's font size multiplied by the line height.
@@ -652,12 +671,12 @@ const defaultClasses = cx([
652
671
  // selected
653
672
  'data-[selected]:before:border-black data-[selected]:before:bg-green data-[selected]:before:shadow-[inset_0_0_0_4px_rgb(255,255,255)]',
654
673
  // hover
655
- 'data-[hovered]:before:border-green data-[hovered]:before:bg-green-lightest data-[hovered]:data-[invalid]:before:bg-red-light',
674
+ 'data-[hovered]:data-[invalid]:before:bg-red-light data-[hovered]:before:border-green data-[hovered]:before:bg-green-lightest',
656
675
  // focus
657
676
  'data-[focus-visible]:before:ring-focus-offset',
658
677
  // invalid - The border is 1 px thicker when invalid. We don't actually want to change the border width, as that causes the element's size to change
659
678
  // so we use an inner outline to artifically pad the border
660
- 'data-[invalid]:before:outline-solid data-[invalid]:before:border-red data-[invalid]:data-[selected]:before:!bg-red data-[invalid]:before:outline data-[invalid]:before:outline-[3px] data-[invalid]:before:outline-offset-[-3px] data-[invalid]:before:outline-red'
679
+ 'data-[invalid]:data-[selected]:before:!bg-red data-[invalid]:before:border-red data-[invalid]:before:outline data-[invalid]:before:outline-[3px] data-[invalid]:before:outline-red data-[invalid]:before:outline-solid data-[invalid]:before:outline-offset-[-3px]'
661
680
  ]);
662
681
  function Radio(props, ref) {
663
682
  const { children, className, description, ...restProps } = props;
@@ -891,11 +910,11 @@ const alertVariants = cva({
891
910
  base: [
892
911
  'grid grid-cols-[auto_1fr_auto] items-center gap-2 rounded-md border-2 px-3 py-2',
893
912
  // Heading styles:
894
- '[&_[data-slot="heading"]]:text-base [&_[data-slot="heading"]]:font-medium [&_[data-slot="heading"]]:leading-7',
913
+ '[&_[data-slot="heading"]]:font-medium [&_[data-slot="heading"]]:text-base [&_[data-slot="heading"]]:leading-7',
895
914
  // Content styles:
896
915
  '[&:has([data-slot="heading"])_[data-slot="content"]]:col-span-full [&_[data-slot="content"]]:text-sm [&_[data-slot="content"]]:leading-6',
897
916
  // Footer styles:
898
- '[&_[data-slot="footer"]]:col-span-full [&_[data-slot="footer"]]:text-xs [&_[data-slot="footer"]]:font-light [&_[data-slot="footer"]]:leading-6'
917
+ '[&_[data-slot="footer"]]:col-span-full [&_[data-slot="footer"]]:font-light [&_[data-slot="footer"]]:text-xs [&_[data-slot="footer"]]:leading-6'
899
918
  ],
900
919
  variants: {
901
920
  /**
@@ -929,8 +948,8 @@ const translations = {
929
948
  en: 'Show less'
930
949
  }
931
950
  };
932
- const Alertbox = ({ children, role, className, variant = 'info', isDismissable = false, isDismissed, onDismiss, isExpandable })=>{
933
- const Icon = iconMap[variant];
951
+ const Alertbox = ({ children, role, className, icon, variant = 'info', isDismissable = false, isDismissed, onDismiss, isExpandable })=>{
952
+ const Icon = icon ?? iconMap[variant];
934
953
  const locale = _useLocale();
935
954
  const id = useId();
936
955
  const [isExpanded, setIsExpanded] = useState(false);
@@ -963,15 +982,15 @@ const Alertbox = ({ children, role, className, variant = 'info', isDismissable =
963
982
  /*#__PURE__*/ jsx(Icon, {}),
964
983
  firstChild,
965
984
  isDismissable && /*#__PURE__*/ jsx("button", {
966
- className: cx('-m-2 grid h-11 w-11 place-items-center rounded-xl', 'focus-visible:outline-focus focus-visible:-outline-offset-8'),
985
+ className: cx('-m-2 grid h-11 w-11 place-items-center rounded-xl', 'focus-visible:-outline-offset-8 focus-visible:outline-focus'),
967
986
  onClick: close,
968
987
  "aria-label": translations.close[locale],
969
988
  type: "button",
970
989
  children: /*#__PURE__*/ jsx(Close, {})
971
990
  }),
972
991
  isExpandable && /*#__PURE__*/ jsxs("button", {
973
- className: cx('relative col-span-full row-start-2 -my-3 inline-flex max-w-fit cursor-pointer items-center gap-1 py-3 text-sm leading-6', // Focus styles:
974
- 'outline-none after:absolute after:bottom-3 after:left-0 after:right-0 after:h-0', 'focus-visible:after:h-[2px] focus-visible:after:bg-black'),
992
+ className: cx('-my-3 relative col-span-full row-start-2 inline-flex max-w-fit cursor-pointer items-center gap-1 py-3 text-sm leading-6', // Focus styles:
993
+ 'outline-none after:absolute after:right-0 after:bottom-3 after:left-0 after:h-0', 'focus-visible:after:h-[2px] focus-visible:after:bg-black'),
975
994
  onClick: ()=>setIsExpanded((prevState)=>!prevState),
976
995
  "aria-expanded": isExpanded,
977
996
  "aria-controls": id,
@@ -1013,7 +1032,7 @@ function Breadcrumb(props, ref) {
1013
1032
  href ? /*#__PURE__*/ jsx(Link, {
1014
1033
  href: href,
1015
1034
  // use outline instead of ring for focus marker that can be offset without creating a white background between the focus marker and the element content
1016
- className: "rounded-sm data-[focus-visible]:outline-focus group-last:no-underline [&:not([data-focus-visible])]:outline-none",
1035
+ className: "rounded-sm group-last:no-underline data-[focus-visible]:outline-focus [&:not([data-focus-visible])]:outline-none",
1017
1036
  children: children
1018
1037
  }) : children,
1019
1038
  /*#__PURE__*/ jsx(ChevronRight, {
@@ -1037,11 +1056,11 @@ function Backlink(props, ref) {
1037
1056
  ref: ref,
1038
1057
  children: [
1039
1058
  /*#__PURE__*/ jsx(ChevronLeft, {
1040
- className: cx('-ml-[0.5em] flex-shrink-0 transition-transform duration-300 group-hover:-translate-x-1')
1059
+ className: cx('-ml-[0.5em] group-hover:-translate-x-1 flex-shrink-0 transition-transform duration-300')
1041
1060
  }),
1042
1061
  /*#__PURE__*/ jsx("span", {
1043
1062
  children: /*#__PURE__*/ jsx("span", {
1044
- className: cx('border-b-[1px] border-t-[1px] border-transparent transition-colors duration-300', withUnderline ? 'border-b-black' : 'group-hover:border-b-black'),
1063
+ className: cx('border-transparent border-t-[1px] border-b-[1px] transition-colors duration-300', withUnderline ? 'border-b-black' : 'group-hover:border-b-black'),
1045
1064
  children: children
1046
1065
  })
1047
1066
  })
@@ -1208,4 +1227,82 @@ const cardLinkVariants = cva({
1208
1227
  return render ? render(formatted) : formatted;
1209
1228
  };
1210
1229
 
1211
- export { _Accordion as Accordion, _AccordionItem as AccordionItem, Alertbox, _Backlink as Backlink, _Badge as Badge, _Breadcrumb as Breadcrumb, _Breadcrumbs as Breadcrumbs, _Button as Button, Card, CardLink, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ListBoxItem as ComboboxItem, _Content as Content, ContentContext, DateFormatter, Footer, GrunnmurenProvider, _Heading as Heading, HeadingContext, Media, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, ListBoxItem as SelectItem, _TextArea as TextArea, _TextField as TextField, _useLocale as useLocale };
1230
+ const VideoLoop = ({ src, format, alt, className })=>{
1231
+ // Control the video playback state, so that the user can pause and play the video at will, also control the video autoplay
1232
+ const [shouldPlay, setShouldPlay] = useState(false);
1233
+ // 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)
1234
+ const [isPlaying, setIsPlaying] = useState(false);
1235
+ // We need to check if the user prefers reduced motion, so that we can prevent the video from autoplaying if so
1236
+ const [userPrefersReducedMotion, setUserPrefersReducedMotion] = useState(null);
1237
+ const videoRef = useRef(null);
1238
+ useEffect(()=>{
1239
+ const { matches: userPrefersReducedMotion } = matchMedia('(prefers-reduced-motion: reduce)');
1240
+ setUserPrefersReducedMotion(userPrefersReducedMotion);
1241
+ // Autoplay the video if the user does not prefer reduced motion
1242
+ setShouldPlay(!userPrefersReducedMotion);
1243
+ }, []);
1244
+ // Follow google's autoplay policy: https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
1245
+ // "Don't assume a video will play, and don't show a pause button when the video is not actually playing."
1246
+ // "You should always look at the Promise returned by the play function to see if it was rejected:"
1247
+ // This is why we use the promise returned by the play function, and an extra state variable to determine if the video is actually playing or not
1248
+ useEffect(()=>{
1249
+ if (!videoRef.current) return;
1250
+ if (shouldPlay) {
1251
+ videoRef.current.play().then(()=>setIsPlaying(true)).catch(()=>setIsPlaying(false));
1252
+ } else {
1253
+ videoRef.current.pause();
1254
+ setIsPlaying(false);
1255
+ }
1256
+ }, [
1257
+ shouldPlay
1258
+ ]);
1259
+ return /*#__PURE__*/ jsxs("div", {
1260
+ className: cx(className, 'relative', userPrefersReducedMotion === null && 'opacity-0'),
1261
+ children: [
1262
+ /*#__PURE__*/ jsx("video", {
1263
+ "aria-hidden": true,
1264
+ ref: videoRef,
1265
+ // cursor-pointer is not working on the button below, so we add it here for the same effect
1266
+ className: "h-full w-full cursor-pointer object-cover",
1267
+ playsInline: true,
1268
+ loop: userPrefersReducedMotion === false,
1269
+ autoPlay: userPrefersReducedMotion === false,
1270
+ muted: true,
1271
+ onEnded: (event)=>{
1272
+ if (userPrefersReducedMotion) {
1273
+ // Reset the video to the beginning if the user prefers reduced motion, since the video will not loop
1274
+ event.currentTarget.currentTime = 0;
1275
+ setShouldPlay(false);
1276
+ setIsPlaying(false);
1277
+ }
1278
+ },
1279
+ children: /*#__PURE__*/ jsx("source", {
1280
+ src: src,
1281
+ type: `video/${format}`
1282
+ })
1283
+ }),
1284
+ userPrefersReducedMotion !== null && /*#__PURE__*/ jsx("button", {
1285
+ "aria-hidden": true,
1286
+ type: "button",
1287
+ onClick: ()=>setShouldPlay((prevState)=>!prevState),
1288
+ className: cx('absolute top-0 right-0 bottom-0 left-0 m-auto grid place-items-center', 'focus-visible:outline-focus focus-visible:outline-focus-offset', // Setting the opacity to 0 before applying the transition below will ensure the button only fades in after the video has started playing
1289
+ shouldPlay && 'opacity-0', isPlaying && [
1290
+ 'transition-opacity duration-200',
1291
+ // Only show the pause button when the video is hovered or focused
1292
+ 'focus-visible:opacity-100',
1293
+ 'hover:opacity-100'
1294
+ ]),
1295
+ children: /*#__PURE__*/ jsx("span", {
1296
+ className: "grid h-12 w-12 place-items-center rounded-full bg-white outline-none",
1297
+ children: isPlaying ? /*#__PURE__*/ jsx(PlayerPause, {}) : /*#__PURE__*/ jsx(PlayerPlay, {})
1298
+ })
1299
+ }),
1300
+ alt && /*#__PURE__*/ jsx("p", {
1301
+ className: "sr-only",
1302
+ children: alt
1303
+ })
1304
+ ]
1305
+ });
1306
+ };
1307
+
1308
+ export { _Accordion as Accordion, _AccordionItem as AccordionItem, Alertbox, _Backlink as Backlink, _Badge as Badge, _Breadcrumb as Breadcrumb, _Breadcrumbs as Breadcrumbs, _Button as Button, Caption, Card, CardLink, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, _Content as Content, ContentContext, DateFormatter, Footer, GrunnmurenProvider, _Heading as Heading, HeadingContext, Media, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, _TextArea as TextArea, _TextField as TextField, VideoLoop, _useLocale as useLocale };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "2.0.0-canary.46",
3
+ "version": "2.0.0-canary.48",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"
@@ -18,10 +18,10 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.4",
21
+ "@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.7",
22
22
  "@react-aria/utils": "^3.25.1",
23
23
  "@types/node": "^22.0.0",
24
- "cva": "1.0.0-beta.2",
24
+ "cva": "^1.0.0-0",
25
25
  "react-aria": "^3.35.1",
26
26
  "react-aria-components": "^1.3.1"
27
27
  },