@obosbbl/grunnmuren-react 2.0.0-canary.45 → 2.0.0-canary.47
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 +30 -2
- package/dist/index.mjs +103 -6
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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';
|
|
@@ -303,6 +303,14 @@ declare const _CheckboxGroup: react.ForwardRefExoticComponent<{
|
|
|
303
303
|
} & Omit<CheckboxGroupProps$1, "style" | "children" | "className" | "isDisabled" | "isReadOnly" | "orientation"> & react.RefAttributes<HTMLDivElement>>;
|
|
304
304
|
|
|
305
305
|
declare const ListBoxItem: (props: ListBoxItemProps) => react_jsx_runtime.JSX.Element;
|
|
306
|
+
/**
|
|
307
|
+
* This component can be used to group items in a listbox
|
|
308
|
+
*/
|
|
309
|
+
declare const ListBoxSection: <T extends object>({ className, ...restProps }: ListBoxSectionProps<T>) => react_jsx_runtime.JSX.Element;
|
|
310
|
+
/**
|
|
311
|
+
* This component can be used to label grouped items in a `ListBoxSection` with a heading
|
|
312
|
+
*/
|
|
313
|
+
declare const ListBoxHeader: (props: HeadingProps$1) => react_jsx_runtime.JSX.Element;
|
|
306
314
|
|
|
307
315
|
type ComboboxProps<T extends object> = {
|
|
308
316
|
children: React.ReactNode;
|
|
@@ -699,6 +707,10 @@ declare const Media: (props: MediaProps) => react_jsx_runtime.JSX.Element;
|
|
|
699
707
|
type FooterProps = HTMLProps<HTMLDivElement> & {
|
|
700
708
|
children: React.ReactNode;
|
|
701
709
|
};
|
|
710
|
+
type CaptionProps = HTMLProps<HTMLDivElement> & {
|
|
711
|
+
children: React.ReactNode;
|
|
712
|
+
};
|
|
713
|
+
declare const Caption: ({ className, ...restProps }: CaptionProps) => react_jsx_runtime.JSX.Element;
|
|
702
714
|
declare const Footer: (props: FooterProps) => react_jsx_runtime.JSX.Element;
|
|
703
715
|
declare const _Heading: react.ForwardRefExoticComponent<Omit<HeadingProps, "ref"> & react.RefAttributes<HTMLHeadingElement>>;
|
|
704
716
|
declare const _Content: react.ForwardRefExoticComponent<Omit<ContentProps, "ref"> & react.RefAttributes<HTMLDivElement>>;
|
|
@@ -837,4 +849,20 @@ type DateFormatterProps = {
|
|
|
837
849
|
*/
|
|
838
850
|
declare const DateFormatter: ({ options: _options, value, children: render, }: DateFormatterProps) => ReactNode;
|
|
839
851
|
|
|
840
|
-
|
|
852
|
+
type VideoLoopProps = {
|
|
853
|
+
/** The video url */
|
|
854
|
+
src: string;
|
|
855
|
+
/** The video format */
|
|
856
|
+
format: string;
|
|
857
|
+
/**
|
|
858
|
+
* The content of the video must have a text description, so that it is accessible to screen readers.
|
|
859
|
+
* You can either just provide a just caption, just an alt text, or both a caption and an alt text.
|
|
860
|
+
* Make sure the alt text doesn't repeat too much of the caption text, if so just a caption is sufficent.
|
|
861
|
+
* Think of this just as an alt text, but for a muted video - this text will not be visible, but read by screen readers.
|
|
862
|
+
* */
|
|
863
|
+
alt?: string;
|
|
864
|
+
className?: string;
|
|
865
|
+
};
|
|
866
|
+
declare const VideoLoop: ({ src, format, alt, className }: VideoLoopProps) => react_jsx_runtime.JSX.Element;
|
|
867
|
+
|
|
868
|
+
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"
|
|
@@ -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 leading-6 text-blue-dark')
|
|
572
|
+
});
|
|
554
573
|
|
|
555
574
|
function InputAddonDivider() {
|
|
556
575
|
return /*#__PURE__*/ jsx("span", {
|
|
@@ -1054,7 +1073,7 @@ const cardVariants = cva({
|
|
|
1054
1073
|
base: [
|
|
1055
1074
|
'group/card',
|
|
1056
1075
|
'rounded-2xl border p-3',
|
|
1057
|
-
'
|
|
1076
|
+
'flex flex-col gap-y-4',
|
|
1058
1077
|
'relative',
|
|
1059
1078
|
// **** Heading ****
|
|
1060
1079
|
'[&_[data-slot="heading"]]:inline',
|
|
@@ -1065,7 +1084,7 @@ const cardVariants = cva({
|
|
|
1065
1084
|
'[&_[data-slot="heading"]]:hyphens-auto',
|
|
1066
1085
|
'[&_[data-slot="heading"]]:[word-break:break-word]',
|
|
1067
1086
|
// **** Content ****
|
|
1068
|
-
'[&_[data-slot="content"]]:
|
|
1087
|
+
'[&_[data-slot="content"]]:flex [&_[data-slot="content"]]:flex-col [&_[data-slot="content"]]:gap-y-4',
|
|
1069
1088
|
// **** Media ****
|
|
1070
1089
|
'[&_[data-slot="media"]]:overflow-hidden',
|
|
1071
1090
|
'[&_[data-slot="media"]]:rounded-t-2xl',
|
|
@@ -1208,4 +1227,82 @@ const cardLinkVariants = cva({
|
|
|
1208
1227
|
return render ? render(formatted) : formatted;
|
|
1209
1228
|
};
|
|
1210
1229
|
|
|
1211
|
-
|
|
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 bottom-0 left-0 right-0 top-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.
|
|
3
|
+
"version": "2.0.0-canary.47",
|
|
4
4
|
"description": "Grunnmuren components in React",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/code-obos/grunnmuren"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.
|
|
21
|
+
"@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.5",
|
|
22
22
|
"@react-aria/utils": "^3.25.1",
|
|
23
23
|
"@types/node": "^22.0.0",
|
|
24
24
|
"cva": "1.0.0-beta.2",
|