@obosbbl/grunnmuren-react 2.0.0-canary.48 → 2.0.0-canary.49
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 +29 -4
- package/dist/index.mjs +123 -6
- package/package.json +3 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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, Link } from 'react-aria-components';
|
|
2
|
-
export { ListBoxItemProps as ComboboxItemProps, Form, ListBoxItemProps as SelectItemProps } from 'react-aria-components';
|
|
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, Link, DisclosureProps as DisclosureProps$1 } from 'react-aria-components';
|
|
2
|
+
export { ListBoxItemProps as ComboboxItemProps, Form, 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
|
-
import { HTMLProps, ReactNode } from 'react';
|
|
5
|
+
import { HTMLProps, ReactNode, RefAttributes, HTMLAttributes } from 'react';
|
|
6
6
|
import * as cva from 'cva';
|
|
7
7
|
import { VariantProps } from 'cva';
|
|
8
8
|
import { DateFormatterOptions } from 'react-aria';
|
|
@@ -628,4 +628,29 @@ type VideoLoopProps = {
|
|
|
628
628
|
};
|
|
629
629
|
declare const VideoLoop: ({ src, format, alt, className }: VideoLoopProps) => react_jsx_runtime.JSX.Element;
|
|
630
630
|
|
|
631
|
-
|
|
631
|
+
declare const disclosureButtonVariants: (props?: ({
|
|
632
|
+
withChevron?: boolean | undefined;
|
|
633
|
+
isIconOnly?: boolean | undefined;
|
|
634
|
+
} & ({
|
|
635
|
+
class?: cva.ClassValue;
|
|
636
|
+
className?: never;
|
|
637
|
+
} | {
|
|
638
|
+
class?: never;
|
|
639
|
+
className?: cva.ClassValue;
|
|
640
|
+
})) | undefined) => string;
|
|
641
|
+
type DisclosureButtonProps = Omit<ButtonProps$1, 'children' | 'aria-expanded' | 'aria-controls'> & VariantProps<typeof disclosureButtonVariants> & {
|
|
642
|
+
children: React.ReactNode;
|
|
643
|
+
} & RefAttributes<HTMLButtonElement>;
|
|
644
|
+
declare const DisclosureButton: ({ className, withChevron, isIconOnly, children, ref: _ref, ...restProps }: DisclosureButtonProps) => react_jsx_runtime.JSX.Element;
|
|
645
|
+
type DisclosureProps = DisclosureProps$1 & RefAttributes<HTMLDivElement> & {
|
|
646
|
+
children: React.ReactNode;
|
|
647
|
+
className?: string;
|
|
648
|
+
};
|
|
649
|
+
declare const Disclosure: ({ ref: _ref, children, ..._props }: DisclosureProps) => react_jsx_runtime.JSX.Element;
|
|
650
|
+
type DisclosurePanelProps = Omit<HTMLAttributes<HTMLDivElement>, 'role'> & {
|
|
651
|
+
children: React.ReactNode;
|
|
652
|
+
role?: 'group' | 'region' | 'none';
|
|
653
|
+
} & RefAttributes<HTMLDivElement>;
|
|
654
|
+
declare const DisclosurePanel: ({ ref: _ref, ..._props }: DisclosurePanelProps) => react_jsx_runtime.JSX.Element;
|
|
655
|
+
|
|
656
|
+
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, Caption, type CaptionProps, Card, CardLink, type CardLinkProps, type CardProps, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, type CheckboxGroupProps, type CheckboxProps, _Combobox as Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, type ComboboxProps, ListBoxSection as ComboboxSection, _Content as Content, ContentContext, type ContentProps, DateFormatter, type DateFormatterProps, Footer, type FooterProps, GrunnmurenProvider, type GrunnmurenProviderProps, _Heading as Heading, HeadingContext, type HeadingProps, type Locale, Media, type MediaProps, _NumberField as NumberField, type NumberFieldProps, _Radio as Radio, _RadioGroup as RadioGroup, type RadioGroupProps, type RadioProps, _Select as Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, type SelectProps, ListBoxSection as SelectSection, _TextArea as TextArea, type TextAreaProps, _TextField as TextField, type TextFieldProps, 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, VideoLoop, _useLocale as useLocale };
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
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 } from 'react-aria-components';
|
|
3
|
-
export { Form } 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 } from 'react-aria-components';
|
|
3
|
+
export { Form, 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 } from '@obosbbl/grunnmuren-icons-react';
|
|
6
|
-
import { useLayoutEffect } from '@react-aria/utils';
|
|
6
|
+
import { useLayoutEffect, filterDOMProps } from '@react-aria/utils';
|
|
7
7
|
import { cx, cva, compose } from 'cva';
|
|
8
|
-
import { createContext, forwardRef, Children, useId, useState, useRef, useEffect } from 'react';
|
|
9
|
-
import { useProgressBar, useDateFormatter } from 'react-aria';
|
|
8
|
+
import { createContext, forwardRef, Children, useId, useState, useRef, useEffect, useContext } from 'react';
|
|
9
|
+
import { useProgressBar, useDateFormatter, useDisclosure } from 'react-aria';
|
|
10
|
+
import { useDisclosureState } from 'react-stately';
|
|
10
11
|
|
|
11
12
|
function GrunnmurenProvider({ children, locale = 'nb', navigate, useHref }) {
|
|
12
13
|
return /*#__PURE__*/ jsx(I18nProvider, {
|
|
@@ -1305,4 +1306,120 @@ const VideoLoop = ({ src, format, alt, className })=>{
|
|
|
1305
1306
|
});
|
|
1306
1307
|
};
|
|
1307
1308
|
|
|
1308
|
-
|
|
1309
|
+
const disclosureButtonVariants = cva({
|
|
1310
|
+
base: [
|
|
1311
|
+
'inline-flex cursor-pointer items-center justify-between rounded-lg outline-none data-[focus-visible]:outline-focus',
|
|
1312
|
+
// Ensure a minimum click area of 44x44px, while making it look like it only has the size of the content
|
|
1313
|
+
'-m-2.5 p-2.5 data-[focus-visible]:outline-offset-[-0.625rem]'
|
|
1314
|
+
],
|
|
1315
|
+
variants: {
|
|
1316
|
+
withChevron: {
|
|
1317
|
+
true: '[&[aria-expanded="true"]_svg]:rotate-180',
|
|
1318
|
+
false: null
|
|
1319
|
+
},
|
|
1320
|
+
/**
|
|
1321
|
+
* When the button is without text, but with a single icon.
|
|
1322
|
+
* @default false
|
|
1323
|
+
*/ isIconOnly: {
|
|
1324
|
+
true: '[&>svg]:h-7 [&>svg]:w-7',
|
|
1325
|
+
false: 'gap-2.5'
|
|
1326
|
+
}
|
|
1327
|
+
},
|
|
1328
|
+
defaultVariants: {
|
|
1329
|
+
withChevron: false,
|
|
1330
|
+
isIconOnly: false
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
const DisclosureButton = ({ className, withChevron, isIconOnly, children, ref: _ref, ...restProps })=>{
|
|
1334
|
+
const [props, ref] = useContextProps(restProps, _ref, ButtonContext);
|
|
1335
|
+
return /*#__PURE__*/ jsxs(Button$1, {
|
|
1336
|
+
...props,
|
|
1337
|
+
ref: ref,
|
|
1338
|
+
className: disclosureButtonVariants({
|
|
1339
|
+
className,
|
|
1340
|
+
withChevron,
|
|
1341
|
+
isIconOnly
|
|
1342
|
+
}),
|
|
1343
|
+
children: [
|
|
1344
|
+
children,
|
|
1345
|
+
withChevron && /*#__PURE__*/ jsx(ChevronDown, {
|
|
1346
|
+
className: "flex-none transition-transform duration-300 motion-reduce:transition-none"
|
|
1347
|
+
})
|
|
1348
|
+
]
|
|
1349
|
+
});
|
|
1350
|
+
};
|
|
1351
|
+
const Disclosure = ({ ref: _ref, children, ..._props })=>{
|
|
1352
|
+
const [props, ref] = useContextProps(_props, _ref, DisclosureContext);
|
|
1353
|
+
const groupState = useContext(DisclosureGroupStateContext);
|
|
1354
|
+
let { id, ...otherProps } = props;
|
|
1355
|
+
const defaultId = useId();
|
|
1356
|
+
id ||= defaultId;
|
|
1357
|
+
const isExpanded = groupState ? groupState.expandedKeys.has(id) : props.isExpanded;
|
|
1358
|
+
const state = useDisclosureState({
|
|
1359
|
+
...props,
|
|
1360
|
+
isExpanded,
|
|
1361
|
+
onExpandedChange (isExpanded) {
|
|
1362
|
+
if (groupState) {
|
|
1363
|
+
groupState.toggleKey(id);
|
|
1364
|
+
}
|
|
1365
|
+
props.onExpandedChange?.(isExpanded);
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1368
|
+
const isDisabled = props.isDisabled || groupState?.isDisabled || false;
|
|
1369
|
+
const domProps = filterDOMProps(otherProps);
|
|
1370
|
+
const panelRef = useRef(null);
|
|
1371
|
+
const { buttonProps, panelProps } = useDisclosure({
|
|
1372
|
+
...props,
|
|
1373
|
+
isExpanded,
|
|
1374
|
+
isDisabled
|
|
1375
|
+
}, state, panelRef);
|
|
1376
|
+
const { role: _, ...propsWithoutRole } = panelProps;
|
|
1377
|
+
return /*#__PURE__*/ jsx(Provider, {
|
|
1378
|
+
values: [
|
|
1379
|
+
[
|
|
1380
|
+
DisclosureContext,
|
|
1381
|
+
state
|
|
1382
|
+
],
|
|
1383
|
+
[
|
|
1384
|
+
ButtonContext,
|
|
1385
|
+
buttonProps
|
|
1386
|
+
],
|
|
1387
|
+
[
|
|
1388
|
+
DisclosurePanelContext,
|
|
1389
|
+
{
|
|
1390
|
+
...propsWithoutRole,
|
|
1391
|
+
ref: panelRef
|
|
1392
|
+
}
|
|
1393
|
+
]
|
|
1394
|
+
],
|
|
1395
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1396
|
+
...domProps,
|
|
1397
|
+
className: otherProps.className,
|
|
1398
|
+
ref: ref,
|
|
1399
|
+
"data-expanded": state.isExpanded || undefined,
|
|
1400
|
+
"data-disabled": isDisabled || undefined,
|
|
1401
|
+
children: children
|
|
1402
|
+
})
|
|
1403
|
+
});
|
|
1404
|
+
};
|
|
1405
|
+
const DisclosurePanelContext = /*#__PURE__*/ createContext({});
|
|
1406
|
+
const DisclosurePanel = ({ ref: _ref, ..._props })=>{
|
|
1407
|
+
const disclosureContext = useContext(DisclosureContext);
|
|
1408
|
+
const [props, ref] = useContextProps(_props, _ref, DisclosurePanelContext);
|
|
1409
|
+
const { role: _role = 'group', className, ...restProps } = props;
|
|
1410
|
+
const ariaLabelledby = _props['aria-labelledby'] ?? restProps['aria-labelledby'];
|
|
1411
|
+
const isWithoutRole = _role === 'none';
|
|
1412
|
+
const role = isWithoutRole ? undefined : _role;
|
|
1413
|
+
return /*#__PURE__*/ jsx("div", {
|
|
1414
|
+
className: cx('grid transition-all duration-300 after:relative after:block after:h-0 after:transition-all after:duration-300 motion-reduce:transition-none', disclosureContext?.isExpanded ? 'grid-rows-[1fr] after:h-3.5' : 'grid-rows-[0fr]'),
|
|
1415
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1416
|
+
...restProps,
|
|
1417
|
+
ref: ref,
|
|
1418
|
+
className: cx(className, 'relative overflow-hidden [content-visibility:visible] before:relative before:block before:h-1.5 after:relative after:block after:h-1.5'),
|
|
1419
|
+
role: role,
|
|
1420
|
+
"aria-labelledby": isWithoutRole ? undefined : ariaLabelledby
|
|
1421
|
+
})
|
|
1422
|
+
});
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
export { _Accordion as Accordion, _AccordionItem as AccordionItem, Alertbox, _Backlink as Backlink, _Badge as Badge, _Breadcrumb as Breadcrumb, _Breadcrumbs as Breadcrumbs, _Button as Button, Caption, Card, CardLink, _Checkbox as Checkbox, _CheckboxGroup as CheckboxGroup, _Combobox as Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, _Content as Content, ContentContext, DateFormatter, Footer, GrunnmurenProvider, _Heading as Heading, HeadingContext, Media, _NumberField as NumberField, _Radio as Radio, _RadioGroup as RadioGroup, _Select as Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, _TextArea as TextArea, _TextField as TextField, Disclosure as UNSAFE_Disclosure, DisclosureButton as UNSAFE_DisclosureButton, DisclosurePanel as UNSAFE_DisclosurePanel, VideoLoop, _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.
|
|
3
|
+
"version": "2.0.0-canary.49",
|
|
4
4
|
"description": "Grunnmuren components in React",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/code-obos/grunnmuren"
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"@types/node": "^22.0.0",
|
|
24
24
|
"cva": "^1.0.0-0",
|
|
25
25
|
"react-aria": "^3.35.1",
|
|
26
|
-
"react-aria-components": "^1.3.1"
|
|
26
|
+
"react-aria-components": "^1.3.1",
|
|
27
|
+
"react-stately": "^3.35.0"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
30
|
"react": "^18 || ^19"
|