@obosbbl/grunnmuren-react 2.0.0-canary.32 → 2.0.0-canary.34
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/README.md +47 -1
- package/dist/index.d.mts +25 -33
- package/dist/index.mjs +34 -42
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ import { GrunnmurenProvider } from '@obosbbl/grunnmuren-react';
|
|
|
81
81
|
import { useRouter } from 'next/navigation';
|
|
82
82
|
|
|
83
83
|
export function Providers({children, locale}: { children: React.ReactNode, locale: string}) {
|
|
84
|
-
|
|
84
|
+
const router = useRouter();
|
|
85
85
|
|
|
86
86
|
return (
|
|
87
87
|
<GrunnmurenProvider locale={locale} navigate={router.push}>
|
|
@@ -116,6 +116,52 @@ export default function RootLayout({
|
|
|
116
116
|
}
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
+
#### Basepath
|
|
120
|
+
|
|
121
|
+
If you're using a router such as Next's, then you can use the `useHref` prop to convert router-specific hrefs into native HTML hrefs. This is very useful for instance when using Next's [basepath](https://nextjs.org/docs/app/api-reference/next-config-js/basePath) setting, as you can use this to prepend the basepath to all links, similar to Next's `<Link>`.
|
|
122
|
+
|
|
123
|
+
**Before**
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import Link from 'next/link';
|
|
127
|
+
import { Button } from '@obosbbl/grunnmuren-react';
|
|
128
|
+
|
|
129
|
+
// Notice how you have to handle the basepath yourself with Grunnmuren's component, but not with Next's.
|
|
130
|
+
|
|
131
|
+
<Link href="/bli-medlem">Bli medlem</Link>
|
|
132
|
+
<Button href="/medlem/bli-medlem">Bli medlem</Button>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**After**
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
// app/providers.tsx
|
|
139
|
+
'use client'
|
|
140
|
+
import { GrunnmurenProvider } from '@obosbbl/grunnmuren-react';
|
|
141
|
+
import { useRouter } from 'next/navigation';
|
|
142
|
+
|
|
143
|
+
export function Providers({children, locale}: { children: React.ReactNode, locale: string}) {
|
|
144
|
+
const router = useRouter();
|
|
145
|
+
const useHref = (href: string) => '/medlem' + href;
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<GrunnmurenProvider locale={locale} navigate={router.push} useHref={useHref}>
|
|
149
|
+
{children}
|
|
150
|
+
</GrunnmurenProvider>
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import Link from 'next/link';
|
|
157
|
+
import { Button } from '@obosbbl/grunnmuren-react';
|
|
158
|
+
|
|
159
|
+
// The hrefs are the same, as basepath is handled by the useHref hook in the provider.
|
|
160
|
+
|
|
161
|
+
<Link href="/bli-medlem">Bli medlem</Link>
|
|
162
|
+
<Button href="/bli-medlem">Bli medlem</Button>
|
|
163
|
+
```
|
|
164
|
+
|
|
119
165
|
### Optimize bundle size by removing unused locales
|
|
120
166
|
|
|
121
167
|
React Aria Components has built in support for over 30 languages, most of which will be unused in your application. To optimize your applications bundle size, it is recommended to use React Aria's build plugin to remove all the unused locales. Here is a quick example for Next.js:
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ButtonProps as ButtonProps$1, Link, 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
|
|
1
|
+
import { RouterProvider, ButtonProps as ButtonProps$1, Link, 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
5
|
import react__default, { HTMLProps, ForwardedRef } from 'react';
|
|
6
6
|
import { VariantProps } from 'cva';
|
|
7
7
|
|
|
8
|
+
type RouterProviderProps = React.ComponentProps<typeof RouterProvider>;
|
|
8
9
|
type GrunnmurenProviderProps = {
|
|
9
10
|
children: React.ReactNode;
|
|
10
11
|
/**
|
|
@@ -12,10 +13,12 @@ type GrunnmurenProviderProps = {
|
|
|
12
13
|
* @default nb
|
|
13
14
|
*/
|
|
14
15
|
locale?: 'nb' | 'sv' | 'en';
|
|
15
|
-
/** The router to use for navigation */
|
|
16
|
-
navigate?:
|
|
16
|
+
/** The router to use for client side navigation */
|
|
17
|
+
navigate?: RouterProviderProps['navigate'];
|
|
18
|
+
/** Converts a router-specific href to a native HTML href, e.g. prepending a base path */
|
|
19
|
+
useHref?: RouterProviderProps['useHref'];
|
|
17
20
|
};
|
|
18
|
-
declare function GrunnmurenProvider({ children, locale, navigate, }: GrunnmurenProviderProps): react_jsx_runtime.JSX.Element;
|
|
21
|
+
declare function GrunnmurenProvider({ children, locale, navigate, useHref, }: GrunnmurenProviderProps): react_jsx_runtime.JSX.Element;
|
|
19
22
|
|
|
20
23
|
type AccordionProps = {
|
|
21
24
|
children: react__default.ReactNode;
|
|
@@ -102,7 +105,7 @@ declare const buttonVariants: (props?: ({
|
|
|
102
105
|
[x: string]: any;
|
|
103
106
|
} | null | undefined;
|
|
104
107
|
})) | undefined) => string;
|
|
105
|
-
type ButtonOrLinkProps = VariantProps<typeof buttonVariants> & {
|
|
108
|
+
type ButtonOrLinkProps$1 = VariantProps<typeof buttonVariants> & {
|
|
106
109
|
children?: React.ReactNode;
|
|
107
110
|
href?: string;
|
|
108
111
|
/**
|
|
@@ -111,7 +114,7 @@ type ButtonOrLinkProps = VariantProps<typeof buttonVariants> & {
|
|
|
111
114
|
*/
|
|
112
115
|
isLoading?: boolean;
|
|
113
116
|
};
|
|
114
|
-
type ButtonProps = (ButtonProps$1 | React.ComponentPropsWithoutRef<typeof Link>) & ButtonOrLinkProps;
|
|
117
|
+
type ButtonProps = (ButtonProps$1 | React.ComponentPropsWithoutRef<typeof Link>) & ButtonOrLinkProps$1;
|
|
115
118
|
declare const _Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
116
119
|
|
|
117
120
|
type CheckboxProps = {
|
|
@@ -135,7 +138,7 @@ declare const _Checkbox: react.ForwardRefExoticComponent<{
|
|
|
135
138
|
errorMessage?: React.ReactNode;
|
|
136
139
|
/** Additional style properties for the element. */
|
|
137
140
|
style?: React.CSSProperties;
|
|
138
|
-
} & Omit<CheckboxProps$1, "
|
|
141
|
+
} & Omit<CheckboxProps$1, "style" | "children" | "isDisabled" | "isIndeterminate" | "isReadOnly"> & react.RefAttributes<HTMLLabelElement>>;
|
|
139
142
|
|
|
140
143
|
type CheckboxGroupProps = {
|
|
141
144
|
children: React.ReactNode;
|
|
@@ -162,7 +165,7 @@ declare const _CheckboxGroup: react.ForwardRefExoticComponent<{
|
|
|
162
165
|
label?: React.ReactNode;
|
|
163
166
|
/** Additional style properties for the element. */
|
|
164
167
|
style?: React.CSSProperties;
|
|
165
|
-
} & Omit<CheckboxGroupProps$1, "
|
|
168
|
+
} & Omit<CheckboxGroupProps$1, "style" | "children" | "className" | "isDisabled" | "isReadOnly" | "orientation"> & react.RefAttributes<HTMLDivElement>>;
|
|
166
169
|
|
|
167
170
|
declare const ListBoxItem: (props: ListBoxItemProps) => react_jsx_runtime.JSX.Element;
|
|
168
171
|
|
|
@@ -205,7 +208,7 @@ declare const _Combobox: react.ForwardRefExoticComponent<{
|
|
|
205
208
|
placeholder?: string;
|
|
206
209
|
/** Additional style properties for the element. */
|
|
207
210
|
style?: React.CSSProperties;
|
|
208
|
-
} & Omit<ComboBoxProps<object>, "
|
|
211
|
+
} & Omit<ComboBoxProps<object>, "style" | "children" | "className" | "isDisabled" | "isReadOnly"> & react.RefAttributes<HTMLInputElement>>;
|
|
209
212
|
|
|
210
213
|
type RadioGroupProps = {
|
|
211
214
|
children: React.ReactNode;
|
|
@@ -232,7 +235,7 @@ declare const _RadioGroup: react.ForwardRefExoticComponent<{
|
|
|
232
235
|
label?: React.ReactNode;
|
|
233
236
|
/** Additional style properties for the element. */
|
|
234
237
|
style?: React.CSSProperties;
|
|
235
|
-
} & Omit<RadioGroupProps$1, "
|
|
238
|
+
} & Omit<RadioGroupProps$1, "style" | "children" | "className" | "isDisabled" | "isReadOnly" | "orientation"> & react.RefAttributes<HTMLDivElement>>;
|
|
236
239
|
|
|
237
240
|
type RadioProps = {
|
|
238
241
|
children: React.ReactNode;
|
|
@@ -251,7 +254,7 @@ declare const _Radio: react.ForwardRefExoticComponent<{
|
|
|
251
254
|
description?: React.ReactNode;
|
|
252
255
|
/** Additional style properties for the element. */
|
|
253
256
|
style?: React.CSSProperties;
|
|
254
|
-
} & Omit<RadioProps$1, "
|
|
257
|
+
} & Omit<RadioProps$1, "style" | "children" | "isDisabled"> & react.RefAttributes<HTMLLabelElement>>;
|
|
255
258
|
|
|
256
259
|
type SelectProps<T extends object> = {
|
|
257
260
|
children: React.ReactNode;
|
|
@@ -282,7 +285,7 @@ declare const _Select: react.ForwardRefExoticComponent<{
|
|
|
282
285
|
placeholder?: string;
|
|
283
286
|
/** Additional style properties for the element. */
|
|
284
287
|
style?: React.CSSProperties;
|
|
285
|
-
} & Omit<SelectProps$1<object>, "
|
|
288
|
+
} & Omit<SelectProps$1<object>, "style" | "children" | "className" | "isDisabled" | "isReadOnly"> & react.RefAttributes<HTMLButtonElement>>;
|
|
286
289
|
|
|
287
290
|
type TextAreaProps = {
|
|
288
291
|
/** Additional CSS className for the element. */
|
|
@@ -321,7 +324,7 @@ declare const _TextArea: react.ForwardRefExoticComponent<{
|
|
|
321
324
|
* @default 2
|
|
322
325
|
*/
|
|
323
326
|
rows?: number;
|
|
324
|
-
} & Omit<TextFieldProps$1, "
|
|
327
|
+
} & Omit<TextFieldProps$1, "style" | "children" | "className" | "isDisabled" | "isReadOnly"> & react.RefAttributes<HTMLTextAreaElement>>;
|
|
325
328
|
|
|
326
329
|
type TextFieldProps = {
|
|
327
330
|
/** Additional CSS className for the element. */
|
|
@@ -376,7 +379,7 @@ declare const _TextField: react.ForwardRefExoticComponent<{
|
|
|
376
379
|
withAddonDivider?: boolean;
|
|
377
380
|
/** Defines the number of characters and determines the width of the input element */
|
|
378
381
|
size?: number;
|
|
379
|
-
} & Omit<TextFieldProps$1, "
|
|
382
|
+
} & Omit<TextFieldProps$1, "style" | "children" | "className" | "isDisabled" | "isReadOnly"> & react.RefAttributes<HTMLInputElement>>;
|
|
380
383
|
|
|
381
384
|
type NumberFieldProps = {
|
|
382
385
|
/** Additional CSS className for the element. */
|
|
@@ -439,7 +442,7 @@ declare const _NumberField: react.ForwardRefExoticComponent<{
|
|
|
439
442
|
maxValue?: number;
|
|
440
443
|
/** Defines the minimum numeric value */
|
|
441
444
|
minValue?: number;
|
|
442
|
-
} & Omit<NumberFieldProps$1, "
|
|
445
|
+
} & Omit<NumberFieldProps$1, "style" | "children" | "className" | "isDisabled" | "isReadOnly" | "hideStepper"> & react.RefAttributes<HTMLInputElement>>;
|
|
443
446
|
|
|
444
447
|
declare const alertVariants: (props?: ({
|
|
445
448
|
variant?: "info" | "success" | "warning" | "danger" | undefined;
|
|
@@ -566,7 +569,7 @@ declare const _Breadcrumb: react.ForwardRefExoticComponent<{
|
|
|
566
569
|
style?: React.CSSProperties;
|
|
567
570
|
/** The URL to navigate to when clicking the breadcrumb. */
|
|
568
571
|
href?: string;
|
|
569
|
-
} & Omit<BreadcrumbProps$1, "
|
|
572
|
+
} & Omit<BreadcrumbProps$1, "style" | "className"> & react.RefAttributes<HTMLLIElement>>;
|
|
570
573
|
|
|
571
574
|
type BreadcrumbsProps = {
|
|
572
575
|
/** Additional CSS className for the element. */
|
|
@@ -579,31 +582,20 @@ declare const _Breadcrumbs: react.ForwardRefExoticComponent<{
|
|
|
579
582
|
className?: string;
|
|
580
583
|
/** Additional style properties for the element. */
|
|
581
584
|
style?: React.CSSProperties;
|
|
582
|
-
} & Omit<BreadcrumbsProps$1<BreadcrumbProps>, "
|
|
585
|
+
} & Omit<BreadcrumbsProps$1<BreadcrumbProps>, "style" | "className"> & react.RefAttributes<HTMLOListElement>>;
|
|
583
586
|
|
|
584
|
-
type
|
|
585
|
-
/** Additional CSS className for the element. */
|
|
586
|
-
className?: string;
|
|
587
|
-
/** The URL to navigate to when clicking the backlink. */
|
|
588
|
-
href?: string;
|
|
589
|
-
/** The content of the link */
|
|
587
|
+
type ButtonOrLinkProps = {
|
|
590
588
|
children?: React.ReactNode;
|
|
591
|
-
/** To add a permanent underline on the link (not only on hover)
|
|
592
|
-
* @default false
|
|
593
|
-
*/
|
|
594
|
-
withUnderline?: boolean;
|
|
595
|
-
} & LinkProps;
|
|
596
|
-
declare const _Backlink: react.ForwardRefExoticComponent<{
|
|
597
589
|
/** Additional CSS className for the element. */
|
|
598
590
|
className?: string;
|
|
599
|
-
/**
|
|
591
|
+
/** Determines whether to use an anchor or a button for the Backlink */
|
|
600
592
|
href?: string;
|
|
601
|
-
/** The content of the link */
|
|
602
|
-
children?: React.ReactNode;
|
|
603
593
|
/** To add a permanent underline on the link (not only on hover)
|
|
604
594
|
* @default false
|
|
605
595
|
*/
|
|
606
596
|
withUnderline?: boolean;
|
|
607
|
-
}
|
|
597
|
+
};
|
|
598
|
+
type BacklinkProps = (ButtonProps$1 | React.ComponentPropsWithoutRef<typeof Link>) & ButtonOrLinkProps;
|
|
599
|
+
declare const _Backlink: react.ForwardRefExoticComponent<BacklinkProps & react.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
608
600
|
|
|
609
601
|
export { _Accordion as Accordion, _AccordionItem as AccordionItem, type AccordionItemProps, type AccordionProps, Alertbox, type Props as AlertboxProps, _Backlink as Backlink, type BacklinkProps, _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
|
@@ -2,26 +2,22 @@
|
|
|
2
2
|
import { I18nProvider, RouterProvider, useContextProps, Provider, Link, Button as Button$1, Text, CheckboxContext, Checkbox as Checkbox$1, Label as Label$1, FieldError, 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, useLocale, 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 {
|
|
5
|
+
import { createContext, forwardRef, Children, useId, useState, useRef } from 'react';
|
|
6
6
|
import { cx, cva, compose } from 'cva';
|
|
7
7
|
import { ChevronDown, LoadingSpinner, Check, Close, InfoCircle, CheckCircle, Warning, CloseCircle, ChevronRight, ChevronLeft } from '@obosbbl/grunnmuren-icons-react';
|
|
8
|
-
import { mergeRefs } from '@react-aria/utils';
|
|
8
|
+
import { useLayoutEffect, mergeRefs } from '@react-aria/utils';
|
|
9
9
|
|
|
10
|
-
function GrunnmurenProvider({ children, locale = 'nb', navigate }) {
|
|
10
|
+
function GrunnmurenProvider({ children, locale = 'nb', navigate, useHref }) {
|
|
11
11
|
return /*#__PURE__*/ jsx(I18nProvider, {
|
|
12
12
|
locale: locale,
|
|
13
13
|
children: navigate ? /*#__PURE__*/ jsx(RouterProvider, {
|
|
14
14
|
navigate: navigate,
|
|
15
|
+
useHref: useHref,
|
|
15
16
|
children: children
|
|
16
17
|
}) : children
|
|
17
18
|
});
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
const canUseDOM = ()=>{
|
|
21
|
-
return typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined';
|
|
22
|
-
};
|
|
23
|
-
const useClientLayoutEffect = canUseDOM() ? useLayoutEffect : ()=>{};
|
|
24
|
-
|
|
25
21
|
const HeadingContext = /*#__PURE__*/ createContext({});
|
|
26
22
|
const Heading = (props, ref)=>{
|
|
27
23
|
[props, ref] = useContextProps(props, ref, HeadingContext);
|
|
@@ -80,7 +76,7 @@ function AccordionItem(props, ref) {
|
|
|
80
76
|
//
|
|
81
77
|
const [isOpen, setIsOpen] = useState(// If we are controlled, use that open state, otherwise use the uncontrolled
|
|
82
78
|
isControlled ? controlledIsOpen : defaultOpen);
|
|
83
|
-
|
|
79
|
+
useLayoutEffect(()=>{
|
|
84
80
|
if (isControlled) {
|
|
85
81
|
setIsOpen(controlledIsOpen);
|
|
86
82
|
}
|
|
@@ -194,7 +190,7 @@ const _AccordionItem = /*#__PURE__*/ forwardRef(AccordionItem);
|
|
|
194
190
|
{
|
|
195
191
|
color: 'green',
|
|
196
192
|
variant: 'secondary',
|
|
197
|
-
className: '
|
|
193
|
+
className: 'text-black shadow-green hover:bg-green hover:text-white active:bg-green'
|
|
198
194
|
},
|
|
199
195
|
{
|
|
200
196
|
color: 'mint',
|
|
@@ -234,15 +230,15 @@ const _AccordionItem = /*#__PURE__*/ forwardRef(AccordionItem);
|
|
|
234
230
|
isIconOnly: false
|
|
235
231
|
}
|
|
236
232
|
});
|
|
237
|
-
function isLinkProps(props) {
|
|
238
|
-
return
|
|
233
|
+
function isLinkProps$1(props) {
|
|
234
|
+
return !!props.href;
|
|
239
235
|
}
|
|
240
236
|
function Button(props, forwardedRef) {
|
|
241
237
|
const { children: _children, color, isIconOnly, isLoading, variant, style: _style, ...restProps } = props;
|
|
242
238
|
const [widthOverride, setWidthOverride] = useState();
|
|
243
239
|
const ownRef = useRef(null);
|
|
244
240
|
const ref = mergeRefs(ownRef, forwardedRef);
|
|
245
|
-
|
|
241
|
+
useLayoutEffect(()=>{
|
|
246
242
|
if (isLoading) {
|
|
247
243
|
const requestID = window.requestAnimationFrame(()=>{
|
|
248
244
|
setWidthOverride(ownRef.current?.getBoundingClientRect()?.width);
|
|
@@ -268,9 +264,9 @@ function Button(props, forwardedRef) {
|
|
|
268
264
|
}) : _children;
|
|
269
265
|
const style = {
|
|
270
266
|
..._style,
|
|
271
|
-
widthOverride
|
|
267
|
+
width: widthOverride
|
|
272
268
|
};
|
|
273
|
-
return isLinkProps(restProps) ? /*#__PURE__*/ jsx(Link, {
|
|
269
|
+
return isLinkProps$1(restProps) ? /*#__PURE__*/ jsx(Link, {
|
|
274
270
|
...restProps,
|
|
275
271
|
className: className,
|
|
276
272
|
style: style,
|
|
@@ -290,7 +286,7 @@ const formField = cx('group flex flex-col gap-2');
|
|
|
290
286
|
const formFieldError = cx('w-fit rounded-sm bg-red-light px-2 py-1 text-sm leading-6 text-red');
|
|
291
287
|
const input = cva({
|
|
292
288
|
base: [
|
|
293
|
-
'rounded-md py-2.5 text-base font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
|
|
289
|
+
'min-h-11 rounded-md py-2.5 text-base font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
|
|
294
290
|
// invalid styles
|
|
295
291
|
'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red',
|
|
296
292
|
// Fix invisible ring on safari: https://github.com/tailwindlabs/tailwindcss.com/issues/1135
|
|
@@ -317,9 +313,9 @@ const inputGroup = cx([
|
|
|
317
313
|
'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring'
|
|
318
314
|
]);
|
|
319
315
|
const dropdown = {
|
|
320
|
-
popover: cx(
|
|
321
|
-
|
|
322
|
-
listbox: cx('max-h-[25rem] text-sm outline-none'),
|
|
316
|
+
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'),
|
|
317
|
+
// overflow-x-hidden is needed to prevent visible vertical scrollbars from overflowing the border radius of the popover
|
|
318
|
+
listbox: cx('max-h-[25rem] overflow-x-hidden text-sm outline-none'),
|
|
323
319
|
chevronIcon: cx('text-base transition-transform duration-150 group-data-[open]:rotate-180 motion-reduce:transition-none')
|
|
324
320
|
};
|
|
325
321
|
|
|
@@ -334,7 +330,7 @@ function ErrorMessage(props) {
|
|
|
334
330
|
}
|
|
335
331
|
|
|
336
332
|
const defaultClasses$1 = cx([
|
|
337
|
-
'group relative left-0 inline-flex max-w-fit cursor-pointer items-start gap-4
|
|
333
|
+
'group relative left-0 -mx-2.5 inline-flex max-w-fit cursor-pointer items-start gap-4 p-2.5 leading-7'
|
|
338
334
|
]);
|
|
339
335
|
// Pulling this out into it's own component. Will probably export it in the future
|
|
340
336
|
// so it can be used in other views, outside of an input of type checkbox, like in table rows.
|
|
@@ -381,9 +377,6 @@ function Checkbox(props, ref) {
|
|
|
381
377
|
isInvalid: isInvalid,
|
|
382
378
|
ref: ref,
|
|
383
379
|
children: [
|
|
384
|
-
/*#__PURE__*/ jsx("span", {
|
|
385
|
-
className: "absolute -left-2.5 top-0 z-10 h-11 w-11"
|
|
386
|
-
}),
|
|
387
380
|
/*#__PURE__*/ jsx(CheckmarkBox, {}),
|
|
388
381
|
children
|
|
389
382
|
]
|
|
@@ -577,7 +570,7 @@ function RadioGroup(props, ref) {
|
|
|
577
570
|
const _RadioGroup = /*#__PURE__*/ forwardRef(RadioGroup);
|
|
578
571
|
|
|
579
572
|
const defaultClasses = cx([
|
|
580
|
-
'relative inline-flex max-w-fit cursor-pointer items-start gap-4 py-2 leading-7',
|
|
573
|
+
'relative -ml-2.5 inline-flex max-w-fit cursor-pointer items-start gap-4 py-2.5 pl-2.5 leading-7',
|
|
581
574
|
// the radio button itself
|
|
582
575
|
'before:flex-none before:rounded-full before:border-2 before:border-black',
|
|
583
576
|
// 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.
|
|
@@ -597,24 +590,19 @@ const defaultClasses = cx([
|
|
|
597
590
|
]);
|
|
598
591
|
function Radio(props, ref) {
|
|
599
592
|
const { children, className, description, ...restProps } = props;
|
|
600
|
-
return /*#__PURE__*/
|
|
593
|
+
return /*#__PURE__*/ jsx(Radio$1, {
|
|
601
594
|
...restProps,
|
|
602
595
|
className: cx(className, defaultClasses),
|
|
603
596
|
ref: ref,
|
|
604
|
-
children:
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
children: description
|
|
614
|
-
})
|
|
615
|
-
]
|
|
616
|
-
})
|
|
617
|
-
]
|
|
597
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
598
|
+
children: [
|
|
599
|
+
children,
|
|
600
|
+
description && /*#__PURE__*/ jsx(Description, {
|
|
601
|
+
className: "mt-2 block",
|
|
602
|
+
children: description
|
|
603
|
+
})
|
|
604
|
+
]
|
|
605
|
+
})
|
|
618
606
|
});
|
|
619
607
|
}
|
|
620
608
|
const _Radio = /*#__PURE__*/ forwardRef(Radio);
|
|
@@ -966,13 +954,17 @@ function Breadcrumb(props, ref) {
|
|
|
966
954
|
}
|
|
967
955
|
const _Breadcrumb = /*#__PURE__*/ forwardRef(Breadcrumb);
|
|
968
956
|
|
|
957
|
+
function isLinkProps(props) {
|
|
958
|
+
return !!props.href;
|
|
959
|
+
}
|
|
969
960
|
function Backlink(props, ref) {
|
|
970
|
-
const { className, children,
|
|
971
|
-
|
|
961
|
+
const { className, children, withUnderline, ...restProps } = props;
|
|
962
|
+
const Component = isLinkProps(props) ? Link : Button$1;
|
|
963
|
+
return /*#__PURE__*/ jsxs(Component, {
|
|
972
964
|
className: cx(className, 'group flex max-w-fit cursor-pointer items-center gap-3 rounded-md p-2.5 no-underline focus:outline-none data-[focus-visible]:ring data-[focus-visible]:ring-black'),
|
|
973
965
|
...restProps,
|
|
966
|
+
// @ts-expect-error ignore the type of the ref here
|
|
974
967
|
ref: ref,
|
|
975
|
-
href: href,
|
|
976
968
|
children: [
|
|
977
969
|
/*#__PURE__*/ jsx(ChevronLeft, {
|
|
978
970
|
className: cx('-ml-[0.5em] flex-shrink-0 transition-transform duration-300 group-hover:-translate-x-1')
|
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.34",
|
|
4
4
|
"description": "Grunnmuren components in React",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/code-obos/grunnmuren"
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@obosbbl/grunnmuren-icons-react": "^2.0.0-canary.1",
|
|
22
|
-
"@react-aria/utils": "^3.
|
|
22
|
+
"@react-aria/utils": "^3.25.1",
|
|
23
23
|
"@types/node": "^20.11.19",
|
|
24
24
|
"cva": "1.0.0-beta.1",
|
|
25
|
-
"react-aria-components": "^1.
|
|
25
|
+
"react-aria-components": "^1.3.1"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"react": "^18"
|