@obosbbl/grunnmuren-react 3.1.3 → 3.2.1
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.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { useContextProps, DisclosureContext, DisclosureGroupStateContext, Provider, ButtonContext as ButtonContext$1, DEFAULT_SLOT, Button as Button$1, useLocale, Link as Link$1, Breadcrumb as Breadcrumb$1, Breadcrumbs as Breadcrumbs$1, Text, CheckboxContext, Checkbox as Checkbox$1, FieldError, Label as Label$1, CheckboxGroup as CheckboxGroup$1, Header, ListBoxItem as ListBoxItem$1, ListBoxSection as ListBoxSection$1, ListBox as ListBox$1, ComboBox, Group, Input, Popover, useSlottedContext, FormContext, FieldErrorContext, LabelContext, InputContext, I18nProvider, RouterProvider, GroupContext, Dialog as Dialog$1, DialogTrigger as DialogTrigger$1, Modal as Modal$1, ModalOverlay as ModalOverlay$1, NumberField as NumberField$1, Radio as Radio$1, RadioGroup as RadioGroup$1, Select as Select$1, SelectValue, Table as Table$1, TableBody as TableBody$1, Cell, Column, TableHeader as TableHeader$1, Row, Tab as Tab$1, TabListStateContext, TabList as TabList$1, TabPanel as TabPanel$1, Tabs as Tabs$1, TagGroup as TagGroup$1, TagList as TagList$1, Tag as Tag$1, TextField as TextField$1, TextArea as TextArea$1 } from 'react-aria-components';
|
|
3
|
-
export { Form, Group
|
|
2
|
+
import { useContextProps, DisclosureContext, DisclosureGroupStateContext, Provider, ButtonContext as ButtonContext$1, DEFAULT_SLOT, Button as Button$1, useLocale, Link as Link$1, Breadcrumb as Breadcrumb$1, Breadcrumbs as Breadcrumbs$1, Text, CheckboxContext, Checkbox as Checkbox$1, FieldError, Label as Label$1, CheckboxGroup as CheckboxGroup$1, Header, ListBoxItem as ListBoxItem$1, ListBoxSection as ListBoxSection$1, ListBox as ListBox$1, ComboBox, Group, Input, Popover, useSlottedContext, FormContext, FieldErrorContext, LabelContext, InputContext, I18nProvider, RouterProvider, GroupContext, Dialog as Dialog$1, DialogTrigger as DialogTrigger$1, Modal as Modal$1, ModalOverlay as ModalOverlay$1, NumberField as NumberField$1, Radio as Radio$1, RadioGroup as RadioGroup$1, Select as Select$1, SelectValue, ColumnResizer, Table as Table$1, TableBody as TableBody$1, Cell, Column, ResizableTableContainer, TableHeader as TableHeader$1, Row, Tab as Tab$1, TabListStateContext, TabList as TabList$1, TabPanel as TabPanel$1, Tabs as Tabs$1, TagGroup as TagGroup$1, TagList as TagList$1, Tag as Tag$1, TextField as TextField$1, TextArea as TextArea$1 } from 'react-aria-components';
|
|
3
|
+
export { DisclosureGroup, Form, Group } from 'react-aria-components';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import { cva, cx, compose } from 'cva';
|
|
6
6
|
import { createContext, useContext, useId, useRef, Children, useState, useEffect, isValidElement, cloneElement, useCallback } from 'react';
|
|
@@ -117,6 +117,7 @@ const disclosureButtonVariants = cva({
|
|
|
117
117
|
});
|
|
118
118
|
const DisclosureButton = ({ className, withChevron, isIconOnly, children, ref: _ref, ...restProps })=>{
|
|
119
119
|
const [props, ref] = useContextProps(restProps, _ref, ButtonContext$1);
|
|
120
|
+
const hasContext = !!useContext(DisclosureContext);
|
|
120
121
|
return /*#__PURE__*/ jsxs(Button$1, {
|
|
121
122
|
...props,
|
|
122
123
|
ref: ref,
|
|
@@ -125,7 +126,7 @@ const DisclosureButton = ({ className, withChevron, isIconOnly, children, ref: _
|
|
|
125
126
|
withChevron,
|
|
126
127
|
isIconOnly
|
|
127
128
|
}),
|
|
128
|
-
slot:
|
|
129
|
+
slot: hasContext ? 'trigger' : undefined,
|
|
129
130
|
children: [
|
|
130
131
|
children,
|
|
131
132
|
withChevron && /*#__PURE__*/ jsx(ChevronDown, {
|
|
@@ -349,6 +350,11 @@ const translations$1 = {
|
|
|
349
350
|
nb: 'Neste',
|
|
350
351
|
sv: 'Nästa',
|
|
351
352
|
en: 'Next'
|
|
353
|
+
},
|
|
354
|
+
externalLink: {
|
|
355
|
+
nb: '(ekstern lenke)',
|
|
356
|
+
sv: '(extern länk)',
|
|
357
|
+
en: '(external link)'
|
|
352
358
|
}
|
|
353
359
|
};
|
|
354
360
|
|
|
@@ -476,13 +482,30 @@ const Avatar = ({ src, alt = '', className, onError, loading = 'lazy', ...rest }
|
|
|
476
482
|
});
|
|
477
483
|
};
|
|
478
484
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
485
|
+
const _LinkContext = /*#__PURE__*/ createContext({});
|
|
486
|
+
const Link = ({ ref: _ref, ..._props })=>{
|
|
487
|
+
const [props, ref] = useContextProps(_props, _ref, _LinkContext);
|
|
488
|
+
const { className, _innerWrapper, children: _children, ...restProps } = props;
|
|
489
|
+
const locale = _useLocale();
|
|
490
|
+
const externalLinkSR = props.rel?.includes('external') ? /*#__PURE__*/ jsx("span", {
|
|
491
|
+
className: "sr-only",
|
|
492
|
+
children: translations$1.externalLink[locale]
|
|
493
|
+
}) : null;
|
|
494
|
+
const reactNodeChildren = /*#__PURE__*/ jsxs(Fragment, {
|
|
495
|
+
children: [
|
|
496
|
+
_children,
|
|
497
|
+
externalLinkSR
|
|
498
|
+
]
|
|
499
|
+
});
|
|
500
|
+
const children = _innerWrapper ? _innerWrapper({
|
|
501
|
+
...restProps,
|
|
502
|
+
children: typeof _children === 'function' ? (values)=>_children(values) : reactNodeChildren
|
|
503
|
+
}) : reactNodeChildren;
|
|
483
504
|
return /*#__PURE__*/ jsx(Link$1, {
|
|
484
505
|
...restProps,
|
|
485
|
-
|
|
506
|
+
ref: ref,
|
|
507
|
+
"data-slot": "link",
|
|
508
|
+
className: cx(className, 'inline-flex cursor-pointer items-center gap-1 font-medium hover:no-underline focus-visible:outline-current focus-visible:outline-focus-offset [&>svg]:shrink-0 [&>svg]:transition-transform'),
|
|
486
509
|
children: children
|
|
487
510
|
});
|
|
488
511
|
};
|
|
@@ -1925,50 +1948,61 @@ const Hero = ({ variant, className, children, ...rest })=>{
|
|
|
1925
1948
|
});
|
|
1926
1949
|
};
|
|
1927
1950
|
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1951
|
+
// Sets the correct icons for each link in the link list
|
|
1952
|
+
const _LinkProvider = ({ children })=>/*#__PURE__*/ jsx(Provider, {
|
|
1953
|
+
values: [
|
|
1954
|
+
[
|
|
1955
|
+
_LinkContext,
|
|
1956
|
+
{
|
|
1957
|
+
_innerWrapper: ({ children, download, rel })=>(values)=>{
|
|
1958
|
+
let Icon = ArrowRight;
|
|
1959
|
+
if (download) {
|
|
1960
|
+
Icon = Download;
|
|
1961
|
+
} else if (rel?.includes('external')) {
|
|
1962
|
+
Icon = LinkExternal;
|
|
1963
|
+
}
|
|
1964
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
1965
|
+
children: [
|
|
1966
|
+
typeof children === 'function' ? children({
|
|
1967
|
+
...values,
|
|
1968
|
+
defaultChildren: null
|
|
1969
|
+
}) : children,
|
|
1970
|
+
/*#__PURE__*/ jsx(Icon, {})
|
|
1971
|
+
]
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
]
|
|
1976
|
+
],
|
|
1977
|
+
children: children
|
|
1943
1978
|
});
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
iconTransition = cx('group-hover:motion-safe:-translate-y-0.5 group-hover:motion-safe:translate-x-0.5');
|
|
1953
|
-
Icon = LinkExternal;
|
|
1954
|
-
}
|
|
1955
|
-
return /*#__PURE__*/ jsx("li", {
|
|
1956
|
-
// Creates divider lines that works in any grid layout and with the focus ring
|
|
1957
|
-
className: "after:-top-px relative p-0.75 after:absolute after:right-0 after:left-0 after:h-px after:w-full after:bg-gray-light",
|
|
1958
|
-
children: /*#__PURE__*/ jsxs(Link, {
|
|
1959
|
-
...restProps,
|
|
1960
|
-
className: cx(className, 'group paragraph flex w-full cursor-pointer justify-between gap-x-2 py-3.5 font-medium no-underline focus-visible:outline-focus'),
|
|
1961
|
-
children: [
|
|
1962
|
-
/*#__PURE__*/ jsx("span", {
|
|
1963
|
-
children: children
|
|
1964
|
-
}),
|
|
1965
|
-
/*#__PURE__*/ jsx(Icon, {
|
|
1966
|
-
className: iconTransition
|
|
1967
|
-
})
|
|
1979
|
+
const LinkListContainer = ({ className, ...restProps })=>// Dual providers makes for easier typing and more readable code
|
|
1980
|
+
/*#__PURE__*/ jsx(Provider, {
|
|
1981
|
+
values: [
|
|
1982
|
+
[
|
|
1983
|
+
HeadingContext,
|
|
1984
|
+
{
|
|
1985
|
+
size: 'm'
|
|
1986
|
+
}
|
|
1968
1987
|
]
|
|
1988
|
+
],
|
|
1989
|
+
children: /*#__PURE__*/ jsx(_LinkProvider, {
|
|
1990
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1991
|
+
className: cx(className, 'link-list-container'),
|
|
1992
|
+
...restProps
|
|
1993
|
+
})
|
|
1969
1994
|
})
|
|
1970
1995
|
});
|
|
1971
|
-
|
|
1996
|
+
const LinkList = (props)=>/*#__PURE__*/ jsx(_LinkProvider, {
|
|
1997
|
+
children: /*#__PURE__*/ jsx("ul", {
|
|
1998
|
+
...props,
|
|
1999
|
+
"data-slot": "link-list"
|
|
2000
|
+
})
|
|
2001
|
+
});
|
|
2002
|
+
const LinkListItem = (props)=>/*#__PURE__*/ jsx("li", {
|
|
2003
|
+
...props,
|
|
2004
|
+
"data-slot": "link-list-item"
|
|
2005
|
+
});
|
|
1972
2006
|
|
|
1973
2007
|
const DialogTrigger = (props)=>/*#__PURE__*/ jsx(DialogTrigger$1, {
|
|
1974
2008
|
...props
|
|
@@ -2233,7 +2267,7 @@ function ScrollButton({ direction, onClick, isVisible, hasScrollingOccurred, cla
|
|
|
2233
2267
|
/**
|
|
2234
2268
|
* Simple hook for detecting horizontal scroll capabilities
|
|
2235
2269
|
* Returns scroll state and a ref to attach to your scrollable container
|
|
2236
|
-
*/ function useHorizontalScroll() {
|
|
2270
|
+
*/ function useHorizontalScroll(scrollStateDeps = []) {
|
|
2237
2271
|
const scrollContainerRef = useRef(null);
|
|
2238
2272
|
const [scrollState, setScrollState] = useState({
|
|
2239
2273
|
canScrollLeft: false,
|
|
@@ -2255,13 +2289,15 @@ function ScrollButton({ direction, onClick, isVisible, hasScrollingOccurred, cla
|
|
|
2255
2289
|
}));
|
|
2256
2290
|
}, []);
|
|
2257
2291
|
const debouncedUpdateScrollState = useDebouncedCallback(updateScrollState, 100);
|
|
2292
|
+
// Initial check and react to dependency changes
|
|
2293
|
+
useEffect(updateScrollState, [
|
|
2294
|
+
...scrollStateDeps
|
|
2295
|
+
]);
|
|
2258
2296
|
useEffect(()=>{
|
|
2259
2297
|
const container = scrollContainerRef.current;
|
|
2260
2298
|
if (!container) {
|
|
2261
2299
|
return;
|
|
2262
2300
|
}
|
|
2263
|
-
// Initial check
|
|
2264
|
-
updateScrollState();
|
|
2265
2301
|
// Listen for scroll events
|
|
2266
2302
|
container.addEventListener('scroll', debouncedUpdateScrollState);
|
|
2267
2303
|
// Listen for resize events (content or container size changes)
|
|
@@ -2299,11 +2335,18 @@ const tableRowVariants = cva({
|
|
|
2299
2335
|
'group-data-[variant=zebra-striped]:even:bg-sky-lightest'
|
|
2300
2336
|
]
|
|
2301
2337
|
});
|
|
2338
|
+
// Used to deal with showing or hiding scroll indicators during column resizing
|
|
2339
|
+
const TableScrollContainerContext = /*#__PURE__*/ createContext({
|
|
2340
|
+
isResizing: false
|
|
2341
|
+
});
|
|
2302
2342
|
/**
|
|
2303
2343
|
* A container component for displaying tabular data with horizontal scrolling support.
|
|
2304
2344
|
*/ function Table(props) {
|
|
2305
2345
|
const { className, children, variant = 'default', ...restProps } = props;
|
|
2306
|
-
const {
|
|
2346
|
+
const { isResizing } = useContext(TableScrollContainerContext);
|
|
2347
|
+
const { scrollContainerRef, canScrollLeft, canScrollRight, hasScrollingOccurred } = useHorizontalScroll([
|
|
2348
|
+
isResizing
|
|
2349
|
+
]);
|
|
2307
2350
|
const handleScroll = useCallback((direction)=>{
|
|
2308
2351
|
const container = scrollContainerRef.current;
|
|
2309
2352
|
if (!container) return;
|
|
@@ -2369,10 +2412,16 @@ function TableColumn(props) {
|
|
|
2369
2412
|
const { className, children, ...restProps } = props;
|
|
2370
2413
|
return /*#__PURE__*/ jsx(Column, {
|
|
2371
2414
|
...restProps,
|
|
2372
|
-
className: cx(className, 'px-4 py-3 text-left font-medium text-black text-sm', 'data-focus-visible:outline-focus-inset', 'min-w-fit whitespace-nowrap'),
|
|
2415
|
+
className: cx(className, 'px-4 py-3 text-left font-medium text-black text-sm', 'data-focus-visible:outline-focus-inset', '[&_:not([data-slot="table-column-resizer"]):focus-visible]:outline-focus-offset', 'min-w-fit whitespace-nowrap', 'has-data-[slot=table-column-resizer]:*:data-[slot=content]:flex has-data-[slot=table-column-resizer]:*:data-[slot=content]:justify-between has-data-[slot=table-column-resizer]:*:data-[slot=content]:gap-2'),
|
|
2416
|
+
"data-slot": "table-column",
|
|
2373
2417
|
children: children
|
|
2374
2418
|
});
|
|
2375
2419
|
}
|
|
2420
|
+
const TableColumnResizer = ({ className, ...restProps })=>/*#__PURE__*/ jsx(ColumnResizer, {
|
|
2421
|
+
...restProps,
|
|
2422
|
+
className: cx(className, '-my-3 -mr-4.5 size-11 flex-none', 'cursor-ew-resize', 'relative after:absolute after:top-2 after:right-5 after:bottom-2 after:w-px after:bg-black', 'data-focused:after:outline-focus-offset'),
|
|
2423
|
+
"data-slot": "table-column-resizer"
|
|
2424
|
+
});
|
|
2376
2425
|
/**
|
|
2377
2426
|
* Container for table rows.
|
|
2378
2427
|
*/ function TableBody({ className, children, ...restProps }) {
|
|
@@ -2397,9 +2446,29 @@ function TableCell(props) {
|
|
|
2397
2446
|
return /*#__PURE__*/ jsx(Cell, {
|
|
2398
2447
|
...restProps,
|
|
2399
2448
|
className: cx(className, 'px-4 py-3 text-black text-sm leading-relaxed', 'min-w-fit whitespace-nowrap', 'align-top', 'data-focus-visible:outline-focus-inset'),
|
|
2449
|
+
"data-slot": "table-cell",
|
|
2400
2450
|
children: children
|
|
2401
2451
|
});
|
|
2402
2452
|
}
|
|
2453
|
+
const TableContainer = ({ className, ...restProps })=>{
|
|
2454
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
2455
|
+
return /*#__PURE__*/ jsx(Provider, {
|
|
2456
|
+
values: [
|
|
2457
|
+
[
|
|
2458
|
+
TableScrollContainerContext,
|
|
2459
|
+
{
|
|
2460
|
+
isResizing
|
|
2461
|
+
}
|
|
2462
|
+
]
|
|
2463
|
+
],
|
|
2464
|
+
children: /*#__PURE__*/ jsx(ResizableTableContainer, {
|
|
2465
|
+
...restProps,
|
|
2466
|
+
className: cx(className, '**:data-[slot=table-column]:overflow-hidden **:data-[slot=table-column]:text-ellipsis', '**:data-[slot=table-cell]:overflow-hidden **:data-[slot=table-cell]:text-ellipsis'),
|
|
2467
|
+
onResizeStart: ()=>setIsResizing(true),
|
|
2468
|
+
onResizeEnd: ()=>setIsResizing(false)
|
|
2469
|
+
})
|
|
2470
|
+
});
|
|
2471
|
+
};
|
|
2403
2472
|
|
|
2404
2473
|
const tabsVariants = cva({
|
|
2405
2474
|
base: [
|
|
@@ -2795,4 +2864,4 @@ const VideoLoop = ({ src, format, alt, className })=>{
|
|
|
2795
2864
|
});
|
|
2796
2865
|
};
|
|
2797
2866
|
|
|
2798
|
-
export { Accordion, AccordionItem, Alertbox, Avatar, Backlink, Badge, Breadcrumb, Breadcrumbs, Button, ButtonContext, Caption, Card, CardLink, Checkbox, CheckboxGroup, Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, Content, ContentContext, DateFormatter, Description, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger,
|
|
2867
|
+
export { Accordion, AccordionItem, Alertbox, Avatar, Backlink, Badge, Breadcrumb, Breadcrumbs, Button, ButtonContext, Caption, Card, CardLink, Checkbox, CheckboxGroup, Combobox, ListBoxHeader as ComboboxHeader, ListBoxItem as ComboboxItem, ListBoxSection as ComboboxSection, Content, ContentContext, DateFormatter, Description, Disclosure, DisclosureButton, DisclosurePanel, DisclosureStateContext, ErrorMessage, Footer, GrunnmurenProvider, Heading, HeadingContext, Label, Media, MediaContext, NumberField, Radio, RadioGroup, Select, ListBoxHeader as SelectHeader, ListBoxItem as SelectItem, ListBoxSection as SelectSection, Tag, TagGroup, TagList, TextArea, TextField, Carousel as UNSAFE_Carousel, CarouselItem as UNSAFE_CarouselItem, CarouselItems as UNSAFE_CarouselItems, Dialog as UNSAFE_Dialog, DialogTrigger as UNSAFE_DialogTrigger, FileUpload as UNSAFE_FileUpload, Hero as UNSAFE_Hero, Link as UNSAFE_Link, LinkList as UNSAFE_LinkList, LinkListContainer as UNSAFE_LinkListContainer, LinkListItem as UNSAFE_LinkListItem, Modal as UNSAFE_Modal, Tab as UNSAFE_Tab, TabList as UNSAFE_TabList, TabPanel as UNSAFE_TabPanel, Table as UNSAFE_Table, TableBody as UNSAFE_TableBody, TableCell as UNSAFE_TableCell, TableColumn as UNSAFE_TableColumn, TableColumnResizer as UNSAFE_TableColumnResizer, TableContainer as UNSAFE_TableContainer, TableHeader as UNSAFE_TableHeader, TableRow as UNSAFE_TableRow, Tabs as UNSAFE_Tabs, VideoLoop, _LinkContext, _useLocale as useLocale };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@obosbbl/grunnmuren-react",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Grunnmuren components in React",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/code-obos/grunnmuren"
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"@react-aria/utils": "^3.29.1",
|
|
25
25
|
"@react-stately/form": "^3.1.5",
|
|
26
26
|
"@react-stately/utils": "^3.10.7",
|
|
27
|
-
"@types/node": "^22.0.0",
|
|
28
27
|
"cva": "^1.0.0-0",
|
|
29
28
|
"react-aria": "^3.41.1",
|
|
30
29
|
"react-aria-components": "^1.10.1",
|
|
@@ -35,7 +34,8 @@
|
|
|
35
34
|
"react": "^19"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"
|
|
37
|
+
"@types/node": "^24.0.0",
|
|
38
|
+
"tailwindcss": "4.1.17"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
41
|
"build": "bunchee"
|