@obosbbl/grunnmuren-react 2.0.0-canary.35 → 2.0.0-canary.36
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 +8 -2
- package/dist/index.mjs +14 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,12 @@ import * as react from 'react';
|
|
|
5
5
|
import react__default, { HTMLProps, ForwardedRef } from 'react';
|
|
6
6
|
import { VariantProps } from 'cva';
|
|
7
7
|
|
|
8
|
+
type Locale = 'nb' | 'sv' | 'en';
|
|
9
|
+
/**
|
|
10
|
+
* Returns the locale set in `<GrunnmurenProvider />`
|
|
11
|
+
*/
|
|
12
|
+
declare function _useLocale(): Locale;
|
|
13
|
+
|
|
8
14
|
type RouterProviderProps = React.ComponentProps<typeof RouterProvider>;
|
|
9
15
|
type GrunnmurenProviderProps = {
|
|
10
16
|
children: React.ReactNode;
|
|
@@ -12,7 +18,7 @@ type GrunnmurenProviderProps = {
|
|
|
12
18
|
* The locale to apply to the children.
|
|
13
19
|
* @default nb
|
|
14
20
|
*/
|
|
15
|
-
locale?:
|
|
21
|
+
locale?: Locale;
|
|
16
22
|
/** The router to use for client side navigation */
|
|
17
23
|
navigate?: RouterProviderProps['navigate'];
|
|
18
24
|
/** Converts a router-specific href to a native HTML href, e.g. prepending a base path */
|
|
@@ -724,4 +730,4 @@ type ButtonOrLinkProps = {
|
|
|
724
730
|
type BacklinkProps = (ButtonProps$1 | React.ComponentPropsWithoutRef<typeof Link>) & ButtonOrLinkProps;
|
|
725
731
|
declare const _Backlink: react.ForwardRefExoticComponent<BacklinkProps & react.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
|
|
726
732
|
|
|
727
|
-
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, _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 };
|
|
733
|
+
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, _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, type Locale, _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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
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,
|
|
2
|
+
import { I18nProvider, RouterProvider, useLocale, 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, 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
5
|
import { createContext, forwardRef, Children, useId, useState, useRef } from 'react';
|
|
@@ -18,6 +18,14 @@ function GrunnmurenProvider({ children, locale = 'nb', navigate, useHref }) {
|
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Returns the locale set in `<GrunnmurenProvider />`
|
|
23
|
+
*/ function _useLocale() {
|
|
24
|
+
// a small wrapper around react-arias useLocale with a simpler return type with only the locales that we actually support
|
|
25
|
+
const locale = useLocale();
|
|
26
|
+
return locale.locale;
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
const HeadingContext = /*#__PURE__*/ createContext({});
|
|
22
30
|
const Heading = (props, ref)=>{
|
|
23
31
|
[props, ref] = useContextProps(props, ref, HeadingContext);
|
|
@@ -324,6 +332,8 @@ const formField = cx('group flex flex-col gap-2');
|
|
|
324
332
|
const formFieldError = cx('w-fit rounded-sm bg-red-light px-2 py-1 text-sm leading-6 text-red');
|
|
325
333
|
const input = cva({
|
|
326
334
|
base: [
|
|
335
|
+
// All inputs should always have a white background (this also ensures that type="search" on Safri doesn't get a gray background)
|
|
336
|
+
'bg-white',
|
|
327
337
|
// Use box-content to enable auto width based on number of characters (size)
|
|
328
338
|
// Setting min-height to prevent the input from collapsing in Safari
|
|
329
339
|
// Combining these with a padding-y as base classes makes it easier to standardize the height (44px) of all inputs
|
|
@@ -341,7 +351,7 @@ const input = cva({
|
|
|
341
351
|
visible: 'data-[focus-visible]:ring-2 group-data-[invalid]:data-[focus-visible]:ring'
|
|
342
352
|
},
|
|
343
353
|
isGrouped: {
|
|
344
|
-
false: '
|
|
354
|
+
false: 'px-3',
|
|
345
355
|
true: 'flex-1 !ring-0'
|
|
346
356
|
}
|
|
347
357
|
},
|
|
@@ -903,7 +913,7 @@ const translations = {
|
|
|
903
913
|
};
|
|
904
914
|
const Alertbox = ({ children, role, className, variant = 'info', isDismissable = false, isDismissed, onDismiss, isExpandable })=>{
|
|
905
915
|
const Icon = iconMap[variant];
|
|
906
|
-
const
|
|
916
|
+
const locale = _useLocale();
|
|
907
917
|
const id = useId();
|
|
908
918
|
const [isExpanded, setIsExpanded] = useState(false);
|
|
909
919
|
const isCollapsed = isExpandable && !isExpanded;
|
|
@@ -1022,4 +1032,4 @@ function Backlink(props, ref) {
|
|
|
1022
1032
|
}
|
|
1023
1033
|
const _Backlink = /*#__PURE__*/ forwardRef(Backlink);
|
|
1024
1034
|
|
|
1025
|
-
export { _Accordion as Accordion, _AccordionItem as AccordionItem, Alertbox, _Backlink as Backlink, _Badge as Badge, _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 };
|
|
1035
|
+
export { _Accordion as Accordion, _AccordionItem as AccordionItem, Alertbox, _Backlink as Backlink, _Badge as Badge, _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, _useLocale as useLocale };
|