@obosbbl/grunnmuren-react 2.0.0-canary.35 → 2.0.0-canary.37

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 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?: 'nb' | 'sv' | 'en';
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, useLocale, 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, 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);
@@ -97,7 +105,7 @@ function AccordionItem(props, ref) {
97
105
  };
98
106
  return /*#__PURE__*/ jsx("div", {
99
107
  ...restProps,
100
- className: cx('group relative px-2', className),
108
+ className: cx('relative px-2', className),
101
109
  ref: ref,
102
110
  "data-open": isOpen,
103
111
  children: /*#__PURE__*/ jsx(Provider, {
@@ -113,7 +121,7 @@ function AccordionItem(props, ref) {
113
121
  "aria-controls": contentId,
114
122
  "aria-expanded": isOpen,
115
123
  // Use outline with offset as focus indicator, this does not cover the left mint border on the expanded content and works with or without a background color on the accordion container
116
- className: "flex min-h-[44px] w-full items-center justify-between gap-1.5 rounded-lg px-2 py-3.5 text-left focus-visible:outline focus-visible:outline-4 focus-visible:outline-offset-[-6px] focus-visible:outline-black",
124
+ className: "flex min-h-[44px] w-full items-center justify-between gap-1.5 rounded-lg px-2 py-3.5 text-left focus-visible:outline-focus focus-visible:outline-focus-inset",
117
125
  id: buttonId,
118
126
  onClick: handleOpenChange,
119
127
  children: [
@@ -190,7 +198,7 @@ const _Badge = /*#__PURE__*/ forwardRef(Badge);
190
198
  * Figma: https://www.figma.com/file/9OvSg0ZXI5E1eQYi7AWiWn/Grunnmuren-2.0-%E2%94%82-Designsystem?node-id=30%3A2574&mode=dev
191
199
  */ const buttonVariants = cva({
192
200
  base: [
193
- 'inline-flex min-h-[44px] cursor-pointer items-center justify-center whitespace-nowrap rounded-lg font-medium transition-all duration-200 focus:outline-none data-[focus-visible]:ring-2 data-[focus-visible]:ring-offset-2'
201
+ 'inline-flex min-h-[44px] cursor-pointer items-center justify-center whitespace-nowrap rounded-lg font-medium transition-colors duration-200 focus-visible:outline-focus-offset'
194
202
  ],
195
203
  variants: {
196
204
  /**
@@ -206,9 +214,9 @@ const _Badge = /*#__PURE__*/ forwardRef(Badge);
206
214
  * Adjusts the color of the button for usage on different backgrounds.
207
215
  * @default green
208
216
  */ color: {
209
- green: 'focus-visible:ring-black',
210
- mint: 'focus-visible:ring-mint focus-visible:ring-offset-green-dark',
211
- white: 'focus-visible:ring-white focus-visible:ring-offset-blue'
217
+ green: 'focus-visible:outline-focus',
218
+ mint: 'focus-visible:outline-focus focus-visible:outline-mint',
219
+ white: 'focus-visible:outline-focus focus-visible:outline-white'
212
220
  },
213
221
  /**
214
222
  * When the button is without text, but with a single icon.
@@ -324,24 +332,26 @@ 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
330
340
  'box-content min-h-6 py-2.5',
331
341
  'rounded-md text-base font-normal leading-6 placeholder-[#727070] outline-none ring-1 ring-black',
332
342
  // invalid styles
333
- 'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red',
343
+ 'group-data-[invalid]:ring-focus group-data-[invalid]:ring-red',
334
344
  // Fix invisible ring on safari: https://github.com/tailwindlabs/tailwindcss.com/issues/1135
335
345
  'appearance-none'
336
346
  ],
337
347
  variants: {
338
348
  // Focus rings. Can either be :focus or :focus-visible based on the needs of the particular component.
339
349
  focusModifier: {
340
- focus: 'focus:ring-2 group-data-[invalid]:focus:ring',
341
- visible: 'data-[focus-visible]:ring-2 group-data-[invalid]:data-[focus-visible]:ring'
350
+ focus: 'focus:ring-focus group-data-[invalid]:focus:ring',
351
+ visible: 'data-[focus-visible]:ring-focus group-data-[invalid]:data-[focus-visible]:ring'
342
352
  },
343
353
  isGrouped: {
344
- false: 'bg-white px-3',
354
+ false: 'px-3',
345
355
  true: 'flex-1 !ring-0'
346
356
  }
347
357
  },
@@ -351,8 +361,8 @@ const input = cva({
351
361
  }
352
362
  });
353
363
  const inputGroup = cx([
354
- 'inline-flex items-center gap-3 overflow-hidden rounded-md bg-white px-3 text-base ring-1 ring-black focus-within:ring-2',
355
- 'group-data-[invalid]:ring-2 group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring'
364
+ 'inline-flex items-center gap-3 overflow-hidden rounded-md bg-white px-3 text-base ring-1 ring-black focus-within:ring-focus',
365
+ 'group-data-[invalid]:ring-focus group-data-[invalid]:ring-red group-data-[invalid]:focus-within:ring'
356
366
  ]);
357
367
  const dropdown = {
358
368
  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'),
@@ -388,7 +398,7 @@ function CheckmarkBox() {
388
398
  // selected
389
399
  'group-data-[selected]:!border-green group-data-[selected]:!bg-green',
390
400
  // focus
391
- 'group-data-[focus-visible]:ring-2 group-data-[focus-visible]:ring-black group-data-[focus-visible]:ring-offset-[9px]',
401
+ 'group-data-[focus-visible]:outline-focus-offset',
392
402
  // hovered
393
403
  'group-data-[hovered]:border-green group-data-[hovered]:group-data-[invalid]:border-red group-data-[hovered]:bg-green-lightest group-data-[hovered]:group-data-[invalid]:bg-red-light',
394
404
  // invalid - The border is 1 px thicker when invalid. We don't actually want to change the border width, as that causes the element's size to change
@@ -625,7 +635,7 @@ const defaultClasses = cx([
625
635
  // hover
626
636
  'data-[hovered]:before:border-green data-[hovered]:before:bg-green-lightest data-[hovered]:data-[invalid]:before:bg-red-light',
627
637
  // focus
628
- 'data-[focus-visible]:before:ring data-[focus-visible]:before:ring-black data-[focus-visible]:before:ring-offset-[9px]',
638
+ 'data-[focus-visible]:before:ring-focus-offset',
629
639
  // invalid - The border is 1 px thicker when invalid. We don't actually want to change the border width, as that causes the element's size to change
630
640
  // so we use an inner outline to artifically pad the border
631
641
  'data-[invalid]:before:outline-solid data-[invalid]:before:border-red data-[invalid]:data-[selected]:before:!bg-red data-[invalid]:before:outline data-[invalid]:before:outline-[3px] data-[invalid]:before:outline-offset-[-3px] data-[invalid]:before:outline-red'
@@ -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 { locale } = useLocale();
916
+ const locale = _useLocale();
907
917
  const id = useId();
908
918
  const [isExpanded, setIsExpanded] = useState(false);
909
919
  const isCollapsed = isExpandable && !isExpanded;
@@ -936,14 +946,14 @@ const Alertbox = ({ children, role, className, variant = 'info', isDismissable =
936
946
  /*#__PURE__*/ jsx(Icon, {}),
937
947
  firstChild,
938
948
  isDismissable && /*#__PURE__*/ jsx("button", {
939
- className: cx('-m-2 grid h-11 w-11 place-items-center rounded-xl', 'focus-visible:outline-none focus-visible:-outline-offset-8 focus-visible:outline-black'),
949
+ className: cx('-m-2 grid h-11 w-11 place-items-center rounded-xl', 'focus-visible:outline-focus focus-visible:-outline-offset-8'),
940
950
  onClick: close,
941
951
  "aria-label": translations.close[locale],
942
952
  children: /*#__PURE__*/ jsx(Close, {})
943
953
  }),
944
954
  isExpandable && /*#__PURE__*/ jsxs("button", {
945
955
  className: cx('relative col-span-full row-start-2 -my-3 inline-flex max-w-fit cursor-pointer items-center gap-1 py-3 text-sm leading-6', // Focus styles:
946
- 'outline-none after:absolute after:bottom-3 after:left-0 after:right-0 after:h-0 after:bg-transparent after:transition-all after:duration-200', 'focus-visible:after:h-[2px] focus-visible:after:bg-black'),
956
+ 'outline-none after:absolute after:bottom-3 after:left-0 after:right-0 after:h-0', 'focus-visible:after:h-[2px] focus-visible:after:bg-black'),
947
957
  onClick: ()=>setIsExpanded((prevState)=>!prevState),
948
958
  "aria-expanded": isExpanded,
949
959
  "aria-controls": id,
@@ -985,7 +995,7 @@ function Breadcrumb(props, ref) {
985
995
  href ? /*#__PURE__*/ jsx(Link, {
986
996
  href: href,
987
997
  // use outline instead of ring for focus marker that can be offset without creating a white background between the focus marker and the element content
988
- className: "rounded-sm focus:outline-none group-last:no-underline data-[focus-visible]:outline data-[focus-visible]:outline-offset-2 data-[focus-visible]:outline-black",
998
+ className: "rounded-sm data-[focus-visible]:focus-visible:outline-focus focus:outline-none group-last:no-underline",
989
999
  children: children
990
1000
  }) : children,
991
1001
  /*#__PURE__*/ jsx(ChevronRight, {
@@ -1003,7 +1013,7 @@ function Backlink(props, ref) {
1003
1013
  const { className, children, withUnderline, ...restProps } = props;
1004
1014
  const Component = isLinkProps(props) ? Link : Button$1;
1005
1015
  return /*#__PURE__*/ jsxs(Component, {
1006
- 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'),
1016
+ className: cx(className, 'group flex max-w-fit cursor-pointer items-center gap-3 rounded-md p-2.5 no-underline focus-visible:outline-focus'),
1007
1017
  ...restProps,
1008
1018
  // @ts-expect-error ignore the type of the ref here
1009
1019
  ref: ref,
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@obosbbl/grunnmuren-react",
3
- "version": "2.0.0-canary.35",
3
+ "version": "2.0.0-canary.37",
4
4
  "description": "Grunnmuren components in React",
5
5
  "repository": {
6
6
  "url": "https://github.com/code-obos/grunnmuren"