@vygruppen/spor-react 12.8.10 → 12.10.0
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/.turbo/turbo-build.log +12 -12
- package/.turbo/turbo-postinstall.log +1 -1
- package/CHANGELOG.md +19 -0
- package/dist/index.cjs +25 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.mjs +26 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/dialog/Drawer.tsx +32 -22
- package/src/provider/SporProvider.tsx +12 -1
- package/src/theme/slot-recipes/choice-chip.ts +1 -1
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vygruppen/spor-react",
|
3
3
|
"type": "module",
|
4
|
-
"version": "12.
|
4
|
+
"version": "12.10.0",
|
5
5
|
"exports": {
|
6
6
|
".": {
|
7
7
|
"types": "./dist/index.d.ts",
|
@@ -46,7 +46,7 @@
|
|
46
46
|
"react-stately": "^3.31.1",
|
47
47
|
"react-swipeable": "^7.0.1",
|
48
48
|
"usehooks-ts": "^3.1.0",
|
49
|
-
"@vygruppen/spor-design-tokens": "4.0.
|
49
|
+
"@vygruppen/spor-design-tokens": "4.0.8",
|
50
50
|
"@vygruppen/spor-icon-react": "4.2.1",
|
51
51
|
"@vygruppen/spor-loader": "0.7.0"
|
52
52
|
},
|
@@ -67,8 +67,8 @@
|
|
67
67
|
"vitest": "^0.26.3",
|
68
68
|
"vitest-axe": "^0.1.0",
|
69
69
|
"vitest-canvas-mock": "^0.2.2",
|
70
|
-
"@vygruppen/
|
71
|
-
"@vygruppen/
|
70
|
+
"@vygruppen/tsconfig": "0.1.1",
|
71
|
+
"@vygruppen/eslint-config": "1.1.1"
|
72
72
|
},
|
73
73
|
"peerDependencies": {
|
74
74
|
"react": ">=18.0.0 <19.0.0",
|
package/src/dialog/Drawer.tsx
CHANGED
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
Grid,
|
8
8
|
GridItem,
|
9
9
|
Portal,
|
10
|
+
useDialogContext,
|
10
11
|
} from "@chakra-ui/react";
|
11
12
|
import {
|
12
13
|
ArrowLeftFill24Icon,
|
@@ -21,6 +22,7 @@ import {
|
|
21
22
|
DrawerFullScreenHeaderProps,
|
22
23
|
DrawerProps,
|
23
24
|
} from "./types";
|
25
|
+
import { useSwipeable } from "react-swipeable";
|
24
26
|
|
25
27
|
/**
|
26
28
|
* A drawer is a panel that slides in from the side of the screen. It is used to display additional content without taking up too much space.
|
@@ -56,15 +58,31 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
|
56
58
|
(props, ref) => {
|
57
59
|
const { children, portalled = true, portalRef, ...rest } = props;
|
58
60
|
const { size, placement } = useRootDrawerProps();
|
61
|
+
const { setOpen } = useDialogContext();
|
62
|
+
const handlers = useSwipeable({
|
63
|
+
onSwiped: (e) => {
|
64
|
+
const shouldClose =
|
65
|
+
(placement === "bottom" && e.dir === "Down") ||
|
66
|
+
(placement === "top" && e.dir === "Up") ||
|
67
|
+
(placement === "end" && e.dir === "Right") ||
|
68
|
+
(placement === "start" && e.dir === "Left");
|
69
|
+
if (shouldClose) {
|
70
|
+
setOpen(false);
|
71
|
+
}
|
72
|
+
},
|
73
|
+
swipeDuration: 250,
|
74
|
+
});
|
59
75
|
const sizeNotFull = size !== "full";
|
60
76
|
return (
|
61
77
|
<Portal disabled={!portalled} container={portalRef}>
|
62
78
|
<ChakraDrawer.Positioner>
|
63
|
-
<
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
79
|
+
<Box {...handlers} width="100%">
|
80
|
+
<ChakraDrawer.Content ref={ref} {...rest}>
|
81
|
+
{sizeNotFull && placement === "bottom" && <CloseDrawerLine />}
|
82
|
+
{children}
|
83
|
+
{sizeNotFull && placement === "top" && <CloseDrawerLine />}
|
84
|
+
</ChakraDrawer.Content>
|
85
|
+
</Box>
|
68
86
|
</ChakraDrawer.Positioner>
|
69
87
|
</Portal>
|
70
88
|
);
|
@@ -73,26 +91,18 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
|
73
91
|
DrawerContent.displayName = "DrawerContent";
|
74
92
|
|
75
93
|
export const CloseDrawerLine = forwardRef<HTMLButtonElement>((props, ref) => {
|
76
|
-
const { t } = useTranslation();
|
77
94
|
return (
|
78
|
-
<
|
95
|
+
<Box
|
96
|
+
width={7}
|
97
|
+
minHeight={1}
|
98
|
+
top={0}
|
99
|
+
marginY={2}
|
100
|
+
marginX="auto"
|
101
|
+
backgroundColor="silver"
|
102
|
+
borderRadius="xs"
|
79
103
|
{...props}
|
80
104
|
ref={ref}
|
81
|
-
|
82
|
-
insetEnd="unset"
|
83
|
-
aria-label={t(texts.close)}
|
84
|
-
cursor="pointer"
|
85
|
-
top={0}
|
86
|
-
paddingY={2}
|
87
|
-
>
|
88
|
-
<Box
|
89
|
-
width={7}
|
90
|
-
height={1}
|
91
|
-
backgroundColor="silver"
|
92
|
-
borderRadius="xs"
|
93
|
-
marginX="auto"
|
94
|
-
/>
|
95
|
-
</ChakraDrawer.CloseTrigger>
|
105
|
+
/>
|
96
106
|
);
|
97
107
|
});
|
98
108
|
CloseDrawerLine.displayName = "CloseDrawerLine";
|
@@ -12,8 +12,18 @@ import { fontFaces } from "../theme/brand";
|
|
12
12
|
import { Toaster } from "../toast/toast";
|
13
13
|
|
14
14
|
type SporProviderProps = Omit<ChakraProviderProps, "value"> & {
|
15
|
+
/**
|
16
|
+
* The current language of your application. Used for built-in microcopy and labels. Default is Norwegian (bokmål).
|
17
|
+
*/
|
15
18
|
language?: Language;
|
19
|
+
/**
|
20
|
+
* The theme to use for colors and design tokens. If not provided, the default Spor theme is used.
|
21
|
+
*/
|
16
22
|
theme?: SystemContext;
|
23
|
+
/**
|
24
|
+
* If true, enables system color mode. If false, the default theme is light.
|
25
|
+
*/
|
26
|
+
enableSystemColorMode?: boolean;
|
17
27
|
};
|
18
28
|
|
19
29
|
/**
|
@@ -56,12 +66,13 @@ import { theme } from '../../../../apps/docs/app/features/portable-text/code-blo
|
|
56
66
|
export const SporProvider = ({
|
57
67
|
language = Language.NorwegianBokmal,
|
58
68
|
theme = system,
|
69
|
+
enableSystemColorMode = true,
|
59
70
|
children,
|
60
71
|
}: SporProviderProps) => {
|
61
72
|
return (
|
62
73
|
<LanguageProvider language={language}>
|
63
74
|
<ChakraProvider value={theme}>
|
64
|
-
<ColorModeProvider>
|
75
|
+
<ColorModeProvider enableSystem={enableSystemColorMode}>
|
65
76
|
<Toaster />
|
66
77
|
<Global styles={fontFaces} />
|
67
78
|
|