@obosbbl/grunnmuren-react 2.0.0-canary.15 → 2.0.0-canary.16
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 +35 -6
- package/dist/index.mjs +132 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { 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, BreadcrumbProps as BreadcrumbProps$1, BreadcrumbsProps as BreadcrumbsProps$1 } from 'react-aria-components';
|
|
1
|
+
import { 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 } 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
|
-
import { HTMLProps } from 'react';
|
|
5
|
+
import react__default, { HTMLProps, ForwardedRef } from 'react';
|
|
6
6
|
import { VariantProps } from 'cva';
|
|
7
7
|
|
|
8
8
|
type GrunnmurenProviderProps = {
|
|
@@ -17,6 +17,29 @@ type GrunnmurenProviderProps = {
|
|
|
17
17
|
};
|
|
18
18
|
declare function GrunnmurenProvider({ children, locale, navigate, }: GrunnmurenProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
19
|
|
|
20
|
+
type AccordionProps = {
|
|
21
|
+
children: react__default.ReactNode;
|
|
22
|
+
/** Additional CSS className for the element. */
|
|
23
|
+
className?: string;
|
|
24
|
+
/** Additional style properties for the element. */
|
|
25
|
+
style?: react__default.CSSProperties;
|
|
26
|
+
};
|
|
27
|
+
type AccordionItemProps = {
|
|
28
|
+
children?: react__default.ReactNode;
|
|
29
|
+
/** Additional CSS className for the element. */
|
|
30
|
+
className?: string;
|
|
31
|
+
/** Additional style properties for the element. */
|
|
32
|
+
style?: react__default.CSSProperties;
|
|
33
|
+
/** Whether the accordion is open (controlled) */
|
|
34
|
+
isOpen?: boolean;
|
|
35
|
+
/** Whether the accordion is open by default (uncontrolled) */
|
|
36
|
+
defaultOpen?: boolean;
|
|
37
|
+
/** Handler that is called when the accordion's open state changes */
|
|
38
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
39
|
+
};
|
|
40
|
+
declare const _Accordion: react__default.ForwardRefExoticComponent<AccordionProps & react__default.RefAttributes<HTMLDivElement>>;
|
|
41
|
+
declare const _AccordionItem: react__default.ForwardRefExoticComponent<AccordionItemProps & react__default.RefAttributes<HTMLDivElement>>;
|
|
42
|
+
|
|
20
43
|
/**
|
|
21
44
|
* Figma: https://www.figma.com/file/9OvSg0ZXI5E1eQYi7AWiWn/Grunnmuren-2.0-%E2%94%82-Designsystem?node-id=30%3A2574&mode=dev
|
|
22
45
|
*/
|
|
@@ -497,15 +520,21 @@ type Props = VariantProps<typeof alertVariants> & {
|
|
|
497
520
|
declare const Alertbox: ({ children, role, className, variant, isDismissable, isDismissed, onDismiss, isExpandable, }: Props) => react_jsx_runtime.JSX.Element | undefined;
|
|
498
521
|
|
|
499
522
|
type HeadingProps = HTMLProps<HTMLHeadingElement> & {
|
|
500
|
-
children
|
|
523
|
+
children?: React.ReactNode;
|
|
501
524
|
/** The level of the heading */
|
|
502
525
|
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
526
|
+
/** @private Used internally for slotted components */
|
|
527
|
+
_innerWrapper?: (children: React.ReactNode) => React.ReactNode;
|
|
503
528
|
};
|
|
504
|
-
declare const
|
|
529
|
+
declare const HeadingContext: react.Context<ContextValue<HeadingProps, HTMLHeadingElement>>;
|
|
530
|
+
declare const Heading: (props: HeadingProps, ref: ForwardedRef<HTMLHeadingElement>) => react_jsx_runtime.JSX.Element;
|
|
531
|
+
declare const ContentContext: react.Context<ContextValue<ContentProps, HTMLDivElement>>;
|
|
505
532
|
type ContentProps = HTMLProps<HTMLDivElement> & {
|
|
506
533
|
children: React.ReactNode;
|
|
534
|
+
/** @private Used internally for slotted components */
|
|
535
|
+
_outerWrapper?: (children: React.ReactNode) => React.ReactNode;
|
|
507
536
|
};
|
|
508
|
-
declare const Content: (props: ContentProps) => react_jsx_runtime.JSX.Element;
|
|
537
|
+
declare const Content: (props: ContentProps, ref: ForwardedRef<HTMLDivElement>) => string | number | boolean | Iterable<react.ReactNode> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
509
538
|
type FooterProps = HTMLProps<HTMLDivElement> & {
|
|
510
539
|
children: React.ReactNode;
|
|
511
540
|
};
|
|
@@ -541,4 +570,4 @@ declare const _Breadcrumbs: react.ForwardRefExoticComponent<{
|
|
|
541
570
|
style?: react.CSSProperties | undefined;
|
|
542
571
|
} & Omit<BreadcrumbsProps$1<BreadcrumbProps>, "className" | "style"> & react.RefAttributes<HTMLOListElement>>;
|
|
543
572
|
|
|
544
|
-
export { Alertbox, type Props as AlertboxProps, _Breadcrumb as Breadcrumb, type BreadcrumbProps, _Breadcrumbs as Breadcrumbs, type BreadcrumbsProps, _Button as Button, type ButtonProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ListBoxItem as ComboboxItem, type ComboboxProps, Content, type ContentProps, Footer, type FooterProps, GrunnmurenProvider, type GrunnmurenProviderProps, Heading, type HeadingProps, _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 };
|
|
573
|
+
export { _Accordion as Accordion, _AccordionItem as AccordionItem, type AccordionItemProps, type AccordionProps, Alertbox, type Props as AlertboxProps, _Breadcrumb as Breadcrumb, type BreadcrumbProps, _Breadcrumbs as Breadcrumbs, type BreadcrumbsProps, _Button as Button, type ButtonProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ListBoxItem as ComboboxItem, type ComboboxProps, Content, ContentContext, type ContentProps, Footer, type FooterProps, GrunnmurenProvider, type GrunnmurenProviderProps, Heading, HeadingContext, type HeadingProps, _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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { I18nProvider, RouterProvider, Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, CheckboxGroup as CheckboxGroup$1, FieldError, ListBoxItem as ListBoxItem$1, ListBox as ListBox$1, ComboBox, Group, Input, Button as Button$1, 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, useLocale, Breadcrumbs as Breadcrumbs$1, Breadcrumb as Breadcrumb$1, Link } from 'react-aria-components';
|
|
2
|
+
import { I18nProvider, RouterProvider, useContextProps, Provider, Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, CheckboxGroup as CheckboxGroup$1, FieldError, ListBoxItem as ListBoxItem$1, ListBox as ListBox$1, ComboBox, Group, Input, Button as Button$1, 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, useLocale, Breadcrumbs as Breadcrumbs$1, Breadcrumb as Breadcrumb$1, Link } from 'react-aria-components';
|
|
3
3
|
export { Form } from 'react-aria-components';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import { useLayoutEffect,
|
|
6
|
-
import {
|
|
7
|
-
import { LoadingSpinner, Check,
|
|
5
|
+
import { useLayoutEffect, createContext, forwardRef, Children, useId, useState, useRef } from 'react';
|
|
6
|
+
import { cx, cva, compose } from 'cva';
|
|
7
|
+
import { ChevronDown, LoadingSpinner, Check, Close, InfoCircle, CheckCircle, Warning, CloseCircle, ChevronRight } from '@obosbbl/grunnmuren-icons-react';
|
|
8
8
|
import { mergeRefs } from '@react-aria/utils';
|
|
9
9
|
|
|
10
10
|
function GrunnmurenProvider({ children, locale = 'nb', navigate }) {
|
|
@@ -22,6 +22,133 @@ const canUseDOM = ()=>{
|
|
|
22
22
|
};
|
|
23
23
|
const useClientLayoutEffect = canUseDOM() ? useLayoutEffect : ()=>{};
|
|
24
24
|
|
|
25
|
+
const HeadingContext = /*#__PURE__*/ createContext({});
|
|
26
|
+
const Heading = (props, ref)=>{
|
|
27
|
+
[props, ref] = useContextProps(props, ref, HeadingContext);
|
|
28
|
+
const { children, level, className, _innerWrapper: innerWrapper, ...restProps } = props;
|
|
29
|
+
const Element = `h${level}`;
|
|
30
|
+
return /*#__PURE__*/ jsx(Element, {
|
|
31
|
+
...restProps,
|
|
32
|
+
className: className,
|
|
33
|
+
"data-slot": "heading",
|
|
34
|
+
children: innerWrapper ? innerWrapper(children) : children
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const ContentContext = /*#__PURE__*/ createContext({});
|
|
38
|
+
const Content = (props, ref)=>{
|
|
39
|
+
[props, ref] = useContextProps(props, ref, ContentContext);
|
|
40
|
+
const { _outerWrapper: outerWrapper, ...restProps } = props;
|
|
41
|
+
const content = /*#__PURE__*/ jsx("div", {
|
|
42
|
+
...restProps,
|
|
43
|
+
"data-slot": "content"
|
|
44
|
+
});
|
|
45
|
+
return outerWrapper ? outerWrapper(content) : content;
|
|
46
|
+
};
|
|
47
|
+
const Footer = (props)=>/*#__PURE__*/ jsx("div", {
|
|
48
|
+
...props,
|
|
49
|
+
"data-slot": "footer"
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function Accordion(props, ref) {
|
|
53
|
+
const { children, ...restProps } = props;
|
|
54
|
+
const childCount = Children.count(children);
|
|
55
|
+
return /*#__PURE__*/ jsx("div", {
|
|
56
|
+
...restProps,
|
|
57
|
+
ref: ref,
|
|
58
|
+
children: Children.map(children, (child, index)=>/*#__PURE__*/ jsxs(Fragment, {
|
|
59
|
+
children: [
|
|
60
|
+
child,
|
|
61
|
+
index < childCount - 1 && /*#__PURE__*/ jsx("hr", {
|
|
62
|
+
className: "border-gray-light",
|
|
63
|
+
"aria-hidden": true
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
}))
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function AccordionItem(props, ref) {
|
|
70
|
+
const { className, children, defaultOpen = false, isOpen: controlledIsOpen, onOpenChange, ...restProps } = props;
|
|
71
|
+
const contentId = useId();
|
|
72
|
+
const buttonId = useId();
|
|
73
|
+
const isControlled = controlledIsOpen != null;
|
|
74
|
+
// This component has internal state that controls whether it is open or not,
|
|
75
|
+
// regardless if we are controlled or uncontrolled.
|
|
76
|
+
// If we are controlled, we use a layout effect to sync the controlled state
|
|
77
|
+
// with the internal state.
|
|
78
|
+
//
|
|
79
|
+
const [isOpen, setIsOpen] = useState(// If we are controlled, use that open state, otherwise use the uncontrolled
|
|
80
|
+
isControlled ? controlledIsOpen : defaultOpen);
|
|
81
|
+
useClientLayoutEffect(()=>{
|
|
82
|
+
if (isControlled) {
|
|
83
|
+
setIsOpen(controlledIsOpen);
|
|
84
|
+
}
|
|
85
|
+
}, [
|
|
86
|
+
controlledIsOpen,
|
|
87
|
+
isControlled
|
|
88
|
+
]);
|
|
89
|
+
const handleOpenChange = ()=>{
|
|
90
|
+
const newOpenState = !isOpen;
|
|
91
|
+
if (!isControlled) {
|
|
92
|
+
setIsOpen(newOpenState);
|
|
93
|
+
}
|
|
94
|
+
// Always call the change handler, even if we're uncontrolled.
|
|
95
|
+
// Easier to add stuff such as tracking etc.
|
|
96
|
+
if (onOpenChange) {
|
|
97
|
+
onOpenChange(newOpenState);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return /*#__PURE__*/ jsx("div", {
|
|
101
|
+
...restProps,
|
|
102
|
+
className: cx('group relative', className),
|
|
103
|
+
ref: ref,
|
|
104
|
+
"data-open": isOpen,
|
|
105
|
+
children: /*#__PURE__*/ jsx(Provider, {
|
|
106
|
+
values: [
|
|
107
|
+
[
|
|
108
|
+
HeadingContext,
|
|
109
|
+
{
|
|
110
|
+
className: 'font-semibold leading-7',
|
|
111
|
+
// Supply a default level here to make this typecheck ok. Will be overwritten with the consumers set heading level anyways
|
|
112
|
+
level: 3,
|
|
113
|
+
_innerWrapper: (children)=>/*#__PURE__*/ jsxs("button", {
|
|
114
|
+
"aria-controls": contentId,
|
|
115
|
+
"aria-expanded": isOpen,
|
|
116
|
+
// the z-index is necessary for the focus ring to be drawn above the left border of the content
|
|
117
|
+
className: "relative z-10 flex min-h-[44px] w-full items-center justify-between gap-1.5 rounded-sm py-3.5 text-left focus:outline-none focus-visible:ring focus-visible:ring-black",
|
|
118
|
+
id: buttonId,
|
|
119
|
+
onClick: handleOpenChange,
|
|
120
|
+
children: [
|
|
121
|
+
children,
|
|
122
|
+
/*#__PURE__*/ jsx(ChevronDown, {
|
|
123
|
+
className: cx('transition-transform duration-300 motion-reduce:transition-none', isOpen && 'rotate-180')
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
],
|
|
129
|
+
[
|
|
130
|
+
ContentContext,
|
|
131
|
+
{
|
|
132
|
+
className: // Uses pseudo element for vertical padding, since that doesn't affect the height when the accordion is closed
|
|
133
|
+
'text-sm font-light leading-6 px-3.5 relative overflow-hidden border-mint border-l-[3px] before:relative before:block before:h-1.5 after:relative after:block after:h-1.5',
|
|
134
|
+
role: 'region',
|
|
135
|
+
// @ts-expect-error TODO: remove this expect-error when we're on React 19 https://github.com/facebook/react/issues/17157#issuecomment-2003750544
|
|
136
|
+
inert: isOpen ? undefined : 'true',
|
|
137
|
+
'aria-labelledby': buttonId,
|
|
138
|
+
_outerWrapper: (children)=>/*#__PURE__*/ jsx("div", {
|
|
139
|
+
className: cx('grid transition-all duration-300 after:relative after:block after:h-0 after:transition-all after:duration-300 motion-reduce:transition-none', isOpen ? 'grid-rows-[1fr] after:h-3.5' : 'grid-rows-[0fr] '),
|
|
140
|
+
children: children
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
],
|
|
145
|
+
children: children
|
|
146
|
+
})
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const _Accordion = /*#__PURE__*/ forwardRef(Accordion);
|
|
150
|
+
const _AccordionItem = /*#__PURE__*/ forwardRef(AccordionItem);
|
|
151
|
+
|
|
25
152
|
/**
|
|
26
153
|
* Figma: https://www.figma.com/file/9OvSg0ZXI5E1eQYi7AWiWn/Grunnmuren-2.0-%E2%94%82-Designsystem?node-id=30%3A2574&mode=dev
|
|
27
154
|
*/ const buttonVariants = cva({
|
|
@@ -765,22 +892,6 @@ const Alertbox = ({ children, role, className, variant = 'info', isDismissable =
|
|
|
765
892
|
});
|
|
766
893
|
};
|
|
767
894
|
|
|
768
|
-
const Heading = ({ level, ...restProps })=>{
|
|
769
|
-
const Heading = `h${level}`;
|
|
770
|
-
return /*#__PURE__*/ jsx(Heading, {
|
|
771
|
-
...restProps,
|
|
772
|
-
"data-slot": "heading"
|
|
773
|
-
});
|
|
774
|
-
};
|
|
775
|
-
const Content = (props)=>/*#__PURE__*/ jsx("div", {
|
|
776
|
-
...props,
|
|
777
|
-
"data-slot": "content"
|
|
778
|
-
});
|
|
779
|
-
const Footer = (props)=>/*#__PURE__*/ jsx("div", {
|
|
780
|
-
...props,
|
|
781
|
-
"data-slot": "footer"
|
|
782
|
-
});
|
|
783
|
-
|
|
784
895
|
function Breadcrumbs(props, ref) {
|
|
785
896
|
const { className, children, ...restProps } = props;
|
|
786
897
|
return /*#__PURE__*/ jsx(Breadcrumbs$1, {
|
|
@@ -812,4 +923,4 @@ function Breadcrumb(props, ref) {
|
|
|
812
923
|
}
|
|
813
924
|
const _Breadcrumb = /*#__PURE__*/ forwardRef(Breadcrumb);
|
|
814
925
|
|
|
815
|
-
export { Alertbox, _Breadcrumb as Breadcrumb, _Breadcrumbs as Breadcrumbs, _Button as Button, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ListBoxItem as ComboboxItem, Content, Footer, GrunnmurenProvider, Heading, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, ListBoxItem as SelectItem, _TextArea as TextArea, _TextField as TextField };
|
|
926
|
+
export { _Accordion as Accordion, _AccordionItem as AccordionItem, Alertbox, _Breadcrumb as Breadcrumb, _Breadcrumbs as Breadcrumbs, _Button as Button, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ListBoxItem as ComboboxItem, Content, ContentContext, Footer, GrunnmurenProvider, Heading, HeadingContext, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, ListBoxItem as SelectItem, _TextArea as TextArea, _TextField as TextField };
|