@obosbbl/grunnmuren-react 2.1.0 → 2.2.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 +23 -5
- package/dist/index.mjs +111 -19
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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, 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 } from 'react-aria-components';
|
|
2
|
-
export { ListBoxItemProps as ComboboxItemProps, Form, LabelProps, ListBoxItemProps as SelectItemProps, DisclosureGroup as UNSAFE_DisclosureGroup, DisclosureGroupProps as UNSAFE_DisclosureGroupProps } from 'react-aria-components';
|
|
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';
|
|
5
5
|
import { Ref, HTMLProps, ReactNode, RefAttributes, HTMLAttributes, RefObject, Dispatch, SetStateAction, ComponentProps } from 'react';
|
|
@@ -359,9 +359,9 @@ type Props = VariantProps<typeof alertVariants> & {
|
|
|
359
359
|
};
|
|
360
360
|
declare const Alertbox: ({ children, role, className, icon, variant, isDismissable, isDismissed, onDismiss, isExpandable, }: Props) => react_jsx_runtime.JSX.Element | undefined;
|
|
361
361
|
|
|
362
|
-
type HeadingProps = HTMLProps<HTMLHeadingElement> & {
|
|
362
|
+
type HeadingProps = Omit<HTMLProps<HTMLHeadingElement>, 'size'> & VariantProps<typeof headingVariants> & {
|
|
363
363
|
children?: React.ReactNode;
|
|
364
|
-
/** The level of the heading */
|
|
364
|
+
/** The semantic level of the heading */
|
|
365
365
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
366
366
|
/** @private Used internally for slotted components */
|
|
367
367
|
_innerWrapper?: (children: React.ReactNode) => React.ReactNode;
|
|
@@ -371,6 +371,15 @@ type HeadingProps = HTMLProps<HTMLHeadingElement> & {
|
|
|
371
371
|
ref?: Ref<HTMLHeadingElement>;
|
|
372
372
|
};
|
|
373
373
|
declare const HeadingContext: react.Context<ContextValue<Partial<HeadingProps>, HTMLHeadingElement>>;
|
|
374
|
+
declare const headingVariants: (props?: ({
|
|
375
|
+
size?: "s" | "xl" | "l" | "m" | "xs" | undefined;
|
|
376
|
+
} & ({
|
|
377
|
+
class?: cva.ClassValue;
|
|
378
|
+
className?: never;
|
|
379
|
+
} | {
|
|
380
|
+
class?: never;
|
|
381
|
+
className?: cva.ClassValue;
|
|
382
|
+
})) | undefined) => string;
|
|
374
383
|
declare const Heading: ({ ref, ...props }: HeadingProps) => string | number | bigint | boolean | Iterable<react.ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<react.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
375
384
|
declare const ContentContext: react.Context<ContextValue<Partial<ContentProps>, HTMLDivElement>>;
|
|
376
385
|
type ContentProps = HTMLProps<HTMLDivElement> & {
|
|
@@ -593,9 +602,18 @@ declare function TagList(props: TagListProps): react_jsx_runtime.JSX.Element;
|
|
|
593
602
|
*/
|
|
594
603
|
declare function Tag(props: TagProps): react_jsx_runtime.JSX.Element;
|
|
595
604
|
|
|
596
|
-
type HeroProps = HTMLProps<HTMLDivElement> & {
|
|
605
|
+
type HeroProps = HTMLProps<HTMLDivElement> & VariantProps<typeof variants> & {
|
|
597
606
|
children: React.ReactNode;
|
|
598
607
|
};
|
|
599
|
-
declare const
|
|
608
|
+
declare const variants: (props?: ({
|
|
609
|
+
variant?: "standard" | "full-bleed" | "two-column" | undefined;
|
|
610
|
+
} & ({
|
|
611
|
+
class?: cva.ClassValue;
|
|
612
|
+
className?: never;
|
|
613
|
+
} | {
|
|
614
|
+
class?: never;
|
|
615
|
+
className?: cva.ClassValue;
|
|
616
|
+
})) | undefined) => string;
|
|
617
|
+
declare const Hero: ({ variant, className, children }: HeroProps) => react_jsx_runtime.JSX.Element;
|
|
600
618
|
|
|
601
619
|
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, 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, 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, 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, Modal as UNSAFE_Modal, type ModalProps as UNSAFE_ModalProps, Tag as UNSAFE_Tag, TagGroup as UNSAFE_TagGroup, TagList as UNSAFE_TagList, VideoLoop, _useLocale as useLocale };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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, 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 } from 'react-aria-components';
|
|
3
|
-
export { Form, DisclosureGroup as UNSAFE_DisclosureGroup } 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, 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 } from 'react-aria-components';
|
|
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 } from '@obosbbl/grunnmuren-icons-react';
|
|
6
6
|
import { useLayoutEffect, filterDOMProps, mergeRefs, mergeProps, useObjectRef, useFormReset, useUpdateEffect } from '@react-aria/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { cva, cx, compose } from 'cva';
|
|
8
8
|
import { createContext, Children, useId, useState, useRef, useEffect, useContext, useCallback } from 'react';
|
|
9
9
|
import { useProgressBar, useDateFormatter, useFocusRing, useDisclosure, useField } from 'react-aria';
|
|
10
10
|
import { useDisclosureState } from 'react-stately';
|
|
@@ -33,13 +33,27 @@ function GrunnmurenProvider({ children, locale = 'nb', navigate, useHref }) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const HeadingContext = /*#__PURE__*/ createContext({});
|
|
36
|
+
const headingVariants = cva({
|
|
37
|
+
variants: {
|
|
38
|
+
/** The visual text size of the heading */ size: {
|
|
39
|
+
xl: 'heading-xl',
|
|
40
|
+
l: 'heading-l',
|
|
41
|
+
m: 'heading-m',
|
|
42
|
+
s: 'heading-s',
|
|
43
|
+
xs: 'heading-xs'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
36
47
|
const Heading = ({ ref = null, ...props })=>{
|
|
37
48
|
[props, ref] = useContextProps(props, ref, HeadingContext);
|
|
38
|
-
const { children, level, className, _innerWrapper: innerWrapper, _outerWrapper: outerWrapper, ...restProps } = props;
|
|
49
|
+
const { children, level, size, className, _innerWrapper: innerWrapper, _outerWrapper: outerWrapper, ...restProps } = props;
|
|
50
|
+
const _className = headingVariants({
|
|
51
|
+
size
|
|
52
|
+
});
|
|
39
53
|
const Element = `h${level}`;
|
|
40
54
|
const content = /*#__PURE__*/ jsx(Element, {
|
|
41
55
|
...restProps,
|
|
42
|
-
className: className,
|
|
56
|
+
className: cx(className, _className),
|
|
43
57
|
"data-slot": "heading",
|
|
44
58
|
children: innerWrapper ? innerWrapper(children) : children
|
|
45
59
|
});
|
|
@@ -1321,7 +1335,7 @@ const VideoLoop = ({ src, format, alt, className })=>{
|
|
|
1321
1335
|
"aria-hidden": true,
|
|
1322
1336
|
ref: videoRef,
|
|
1323
1337
|
// cursor-pointer is not working on the button below, so we add it here for the same effect
|
|
1324
|
-
className: "h-full max-h-[inherit] w-full cursor-pointer object-cover",
|
|
1338
|
+
className: "h-full max-h-[inherit] w-full cursor-pointer rounded-[inherit] object-cover",
|
|
1325
1339
|
playsInline: true,
|
|
1326
1340
|
loop: userPrefersReducedMotion === false,
|
|
1327
1341
|
autoPlay: userPrefersReducedMotion === false,
|
|
@@ -1343,7 +1357,7 @@ const VideoLoop = ({ src, format, alt, className })=>{
|
|
|
1343
1357
|
"aria-hidden": true,
|
|
1344
1358
|
type: "button",
|
|
1345
1359
|
onClick: ()=>setShouldPlay((prevState)=>!prevState),
|
|
1346
|
-
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
|
|
1360
|
+
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', 'rounded-[inherit]', // Setting the opacity to 0 before applying the transition below will ensure the button only fades in after the video has started playing
|
|
1347
1361
|
shouldPlay && 'opacity-0', isPlaying && [
|
|
1348
1362
|
'transition-opacity duration-200',
|
|
1349
1363
|
// Only show the pause button when the video is hovered or focused
|
|
@@ -1944,18 +1958,96 @@ const tagVariants = cva({
|
|
|
1944
1958
|
});
|
|
1945
1959
|
}
|
|
1946
1960
|
|
|
1947
|
-
const
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1961
|
+
const roundedMediaCorners = '*:data-[slot="media"]:*:rounded-3xl';
|
|
1962
|
+
// Common variant for "standard" and "full-bleed" Hero variants
|
|
1963
|
+
const oneColumnLayout = [
|
|
1964
|
+
// Vertical spacing in the <Content>
|
|
1965
|
+
'lg:*:data-[slot="content"]:gap-y-4',
|
|
1966
|
+
// Main text content takes up 9 columns on medium screens and above
|
|
1967
|
+
'lg:*:data-[slot="content"]:col-span-9',
|
|
1968
|
+
// Make sure other elements than <Content> and <Media> (i.e CTA) does not span the full width on small screens
|
|
1969
|
+
'*:not-data-[slot="content"]:not-data-[slot="media"]:w-fit',
|
|
1970
|
+
// Other elements than <Content> and <Media> (e.g. CTA, SVG logo or Badge) take up 3 columns on medium screens and above, and are right aligned
|
|
1971
|
+
'lg:*:not-data-[slot="content"]:not-data-[slot="media"]:col-span-3 lg:*:not-data-[slot="content"]:not-data-[slot="media"]:justify-self-end',
|
|
1972
|
+
// <Media> content takes up the full width on medium screens and above
|
|
1973
|
+
'lg:*:data-[slot="media"]:col-span-full *:data-[slot="media"]:*:w-full',
|
|
1974
|
+
// Aligns <Content> and any element beside it (e.g. <Media>, <Badge>, <CTA> etc.) to the bottom of the <Content> container
|
|
1975
|
+
'lg:items-end'
|
|
1976
|
+
];
|
|
1977
|
+
const variants = cva({
|
|
1978
|
+
base: [
|
|
1979
|
+
'container',
|
|
1980
|
+
// Grid variant to position the Hero's content
|
|
1981
|
+
'grid lg:grid-cols-12 lg:gap-x-12 xl:gap-x-16',
|
|
1982
|
+
'gap-y-10 lg:gap-y-12',
|
|
1983
|
+
// Enable vertical gap within <Content>
|
|
1984
|
+
'*:data-[slot="content"]:grid',
|
|
1985
|
+
// Vertical spacing in the <Content>
|
|
1986
|
+
'*:data-[slot="content"]:gap-y-3',
|
|
1987
|
+
// Make sure <Media> content fills any available vertical and horizontal space
|
|
1988
|
+
'*:data-[slot="media"]:*:object-cover'
|
|
1989
|
+
],
|
|
1990
|
+
variants: {
|
|
1991
|
+
/**
|
|
1992
|
+
* Defines the variant of the Hero
|
|
1993
|
+
* @default standard
|
|
1994
|
+
* */ variant: {
|
|
1995
|
+
standard: [
|
|
1996
|
+
roundedMediaCorners,
|
|
1997
|
+
oneColumnLayout
|
|
1998
|
+
],
|
|
1999
|
+
'full-bleed': [
|
|
2000
|
+
oneColumnLayout,
|
|
2001
|
+
// biome-ignore lint/nursery/useSortedClasses: biome is unable to sort the custom classes for 3xl and 4xl breakpoints
|
|
2002
|
+
'*:data-[slot="media"]:h-70 sm:*:data-[slot="media"]:h-[25rem] lg:*:data-[slot="media"]:h-[30rem] lg:*:data-[slot="media"]:h-[35rem] xl:*:data-[slot="media"]:h-[40rem] 2xl:*:data-[slot="media"]:h-[42rem] 3xl:*:data-[slot="media"]:h-[48rem] 4xl:*:data-[slot="media"]:h-[53rem]',
|
|
2003
|
+
// Match the heights of the <Media> wrapper for the Media content (e.g. image, VideoLoop, video etc.)
|
|
2004
|
+
// biome-ignore lint/nursery/useSortedClasses: biome is unable to sort the custom classes for 3xl and 4xl breakpoints
|
|
2005
|
+
'*:data-[slot="media"]:*:h-70 sm:*:data-[slot="media"]:*:h-[25rem] lg:*:data-[slot="media"]:*:h-[30rem] lg:*:data-[slot="media"]:*:h-[35rem] xl:*:data-[slot="media"]:*:h-[40rem] 2xl:*:data-[slot="media"]:*:h-[42rem] 3xl:*:data-[slot="media"]:*:h-[48rem] 4xl:*:data-[slot="media"]:*:h-[53rem]',
|
|
2006
|
+
// Position the media content to fill the entire viewport width
|
|
2007
|
+
'*:data-[slot="media"]:*:absolute *:data-[slot="media"]:*:left-0'
|
|
2008
|
+
],
|
|
2009
|
+
'two-column': [
|
|
2010
|
+
'lg:items-center lg:*:col-span-6',
|
|
2011
|
+
// Vertical spacing in the <Content>
|
|
2012
|
+
'lg:*:data-[slot="content"]:gap-y-7',
|
|
2013
|
+
roundedMediaCorners,
|
|
2014
|
+
// Set media aspect ratio to 1:1 (square)
|
|
2015
|
+
'lg:*:data-[slot="media"]:*:aspect-[1/1]'
|
|
2016
|
+
]
|
|
2017
|
+
}
|
|
2018
|
+
},
|
|
2019
|
+
defaultVariants: {
|
|
2020
|
+
variant: 'standard'
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
const Hero = ({ variant, className, children })=>{
|
|
2024
|
+
const variantsClassName = variants({
|
|
2025
|
+
variant,
|
|
2026
|
+
className
|
|
2027
|
+
});
|
|
2028
|
+
return /*#__PURE__*/ jsx(Provider, {
|
|
2029
|
+
values: [
|
|
2030
|
+
[
|
|
2031
|
+
HeadingContext,
|
|
2032
|
+
{
|
|
2033
|
+
// Sets the default heading size for the Hero based on the variant
|
|
2034
|
+
size: variant === 'two-column' ? 'xl' : 'l'
|
|
2035
|
+
}
|
|
2036
|
+
],
|
|
2037
|
+
[
|
|
2038
|
+
GroupContext,
|
|
2039
|
+
{
|
|
2040
|
+
// Prevents the group from being announced as a group by screen readers
|
|
2041
|
+
// The Group component is used to group the Hero's CTA buttons together visually, and has no semantic meaning
|
|
2042
|
+
role: 'presentation',
|
|
2043
|
+
className: 'flex flex-wrap gap-3 *:w-fit'
|
|
2044
|
+
}
|
|
2045
|
+
]
|
|
2046
|
+
],
|
|
2047
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
2048
|
+
className: cx(variantsClassName, className),
|
|
2049
|
+
children: children
|
|
2050
|
+
})
|
|
1959
2051
|
});
|
|
1960
2052
|
};
|
|
1961
2053
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obosbbl/grunnmuren-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Grunnmuren components in React",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/code-obos/grunnmuren"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"react": "^19"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"tailwindcss": "4.
|
|
37
|
+
"tailwindcss": "4.1.7"
|
|
38
38
|
},
|
|
39
39
|
"scripts": {
|
|
40
40
|
"build": "bunchee"
|