@vygruppen/spor-react 12.14.2 → 12.15.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 +11 -0
- package/dist/index.cjs +51 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.mjs +52 -34
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/alert/AlertIcon.tsx +30 -15
- package/src/datepicker/CalendarCell.tsx +5 -3
- package/src/dialog/Drawer.tsx +20 -6
- package/src/dialog/types.ts +5 -0
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.15.0",
|
5
5
|
"exports": {
|
6
6
|
".": {
|
7
7
|
"types": "./dist/index.d.ts",
|
@@ -68,8 +68,8 @@
|
|
68
68
|
"vitest": "^0.26.3",
|
69
69
|
"vitest-axe": "^0.1.0",
|
70
70
|
"vitest-canvas-mock": "^0.2.2",
|
71
|
-
"@vygruppen/
|
72
|
-
"@vygruppen/
|
71
|
+
"@vygruppen/eslint-config": "1.2.3",
|
72
|
+
"@vygruppen/tsconfig": "0.1.1"
|
73
73
|
},
|
74
74
|
"peerDependencies": {
|
75
75
|
"react": ">=18.0.0 <19.0.0",
|
package/src/alert/AlertIcon.tsx
CHANGED
@@ -26,49 +26,64 @@ type AlertIconProps = {
|
|
26
26
|
* Internal component that shows the correct icon for the alert
|
27
27
|
*/
|
28
28
|
export const AlertIcon = forwardRef<SVGSVGElement, AlertIconProps>(
|
29
|
-
({ variant, customIcon }, ref) => {
|
29
|
+
({ variant, customIcon: CustomAlertIcon }, ref) => {
|
30
30
|
const { t } = useTranslation();
|
31
31
|
|
32
|
-
const Icon = customIcon ?? getIcon(variant);
|
33
|
-
|
34
32
|
return (
|
35
33
|
<Box
|
36
|
-
|
34
|
+
asChild
|
37
35
|
ref={ref}
|
38
36
|
aria-label={t(texts[variant as keyof typeof texts])}
|
39
|
-
|
40
|
-
|
37
|
+
>
|
38
|
+
{CustomAlertIcon ? (
|
39
|
+
<CustomAlertIcon color={`alert.${variant}.icon`} />
|
40
|
+
) : (
|
41
|
+
<BaseAlertIcon variant={variant} />
|
42
|
+
)}
|
43
|
+
</Box>
|
41
44
|
);
|
42
45
|
},
|
43
46
|
);
|
44
47
|
|
45
48
|
AlertIcon.displayName = "AlertIcon";
|
46
49
|
|
47
|
-
const
|
50
|
+
const BaseAlertIcon = ({ variant }: { variant: AlertProps["variant"] }) => {
|
51
|
+
const css = {
|
52
|
+
"& path:first-of-type": {
|
53
|
+
fill: `alert.${variant}.icon`,
|
54
|
+
},
|
55
|
+
"& path:not(:first-of-type)": {
|
56
|
+
fill: `alert.${variant}.surface`,
|
57
|
+
},
|
58
|
+
};
|
59
|
+
|
48
60
|
switch (variant) {
|
49
61
|
case "info": {
|
50
|
-
return InformationFill24Icon
|
62
|
+
return <InformationFill24Icon css={css} />;
|
51
63
|
}
|
52
64
|
case "success": {
|
53
|
-
return SuccessFill24Icon
|
65
|
+
return <SuccessFill24Icon css={css} />;
|
54
66
|
}
|
55
67
|
case "important": {
|
56
|
-
return WarningFill24Icon
|
68
|
+
return <WarningFill24Icon />;
|
57
69
|
}
|
58
70
|
case "alt": {
|
59
|
-
return AltTransportFill24Icon
|
71
|
+
return <AltTransportFill24Icon css={css} />;
|
60
72
|
}
|
61
73
|
case "error": {
|
62
|
-
return ErrorFill24Icon
|
74
|
+
return <ErrorFill24Icon css={css} />;
|
63
75
|
}
|
64
76
|
case "error-secondary": {
|
65
|
-
return ErrorOutline24Icon
|
77
|
+
return <ErrorOutline24Icon css={css} />;
|
66
78
|
}
|
67
79
|
case "neutral": {
|
68
|
-
return QuestionFill24Icon
|
80
|
+
return <QuestionFill24Icon css={css} />;
|
69
81
|
}
|
70
82
|
case "service": {
|
71
|
-
return ServiceFill24Icon
|
83
|
+
return <ServiceFill24Icon />;
|
84
|
+
}
|
85
|
+
default: {
|
86
|
+
return <InformationFill24Icon css={css} />;
|
72
87
|
}
|
73
88
|
}
|
74
89
|
};
|
@@ -11,6 +11,8 @@ import { PropsWithChildren, useEffect, useRef } from "react";
|
|
11
11
|
import { useCalendarCell } from "react-aria";
|
12
12
|
import { CalendarState, RangeCalendarState } from "react-stately";
|
13
13
|
|
14
|
+
import { spor } from "@/util";
|
15
|
+
|
14
16
|
import { DatePickerVariantProps } from "./DatePicker";
|
15
17
|
import { CalendarVariants } from "./types";
|
16
18
|
|
@@ -74,8 +76,8 @@ export function CalendarCell({
|
|
74
76
|
|
75
77
|
return (
|
76
78
|
<Box as="td" {...cellProps} textAlign="center" css={styles.cell}>
|
77
|
-
<
|
78
|
-
|
79
|
+
<spor.button
|
80
|
+
type="button" // Prevents form submission
|
79
81
|
{...buttonProps}
|
80
82
|
{...stateProps}
|
81
83
|
ref={ref}
|
@@ -83,7 +85,7 @@ export function CalendarCell({
|
|
83
85
|
hidden={isOutsideVisibleRange}
|
84
86
|
>
|
85
87
|
{date.day}
|
86
|
-
</
|
88
|
+
</spor.button>
|
87
89
|
</Box>
|
88
90
|
);
|
89
91
|
}
|
package/src/dialog/Drawer.tsx
CHANGED
@@ -19,6 +19,7 @@ import { ResponsiveButton } from "@/button/ResponsiveButton";
|
|
19
19
|
import { CloseButton } from "../button";
|
20
20
|
import { createTexts, useTranslation } from "../i18n";
|
21
21
|
import {
|
22
|
+
DrawerCloseTriggerProps,
|
22
23
|
DrawerContentProps,
|
23
24
|
DrawerFullScreenHeaderProps,
|
24
25
|
DrawerProps,
|
@@ -56,7 +57,13 @@ const [RootDrawerProvider, useRootDrawerProps] =
|
|
56
57
|
|
57
58
|
export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
58
59
|
(props, ref) => {
|
59
|
-
const {
|
60
|
+
const {
|
61
|
+
children,
|
62
|
+
portalled = true,
|
63
|
+
portalRef,
|
64
|
+
hideHandle = false,
|
65
|
+
...rest
|
66
|
+
} = props;
|
60
67
|
const { size, placement } = useRootDrawerProps();
|
61
68
|
const { setOpen } = useDialogContext();
|
62
69
|
const handlers = useSwipeable({
|
@@ -73,14 +80,20 @@ export const DrawerContent = forwardRef<HTMLDivElement, DrawerContentProps>(
|
|
73
80
|
swipeDuration: 250,
|
74
81
|
});
|
75
82
|
const sizeNotFull = size !== "full";
|
83
|
+
const showHandle = !hideHandle;
|
84
|
+
|
76
85
|
return (
|
77
86
|
<Portal disabled={!portalled} container={portalRef}>
|
78
87
|
<ChakraDrawer.Positioner asChild>
|
79
88
|
<Box {...handlers} width="100%">
|
80
89
|
<ChakraDrawer.Content ref={ref} {...rest}>
|
81
|
-
{sizeNotFull && placement === "bottom" &&
|
90
|
+
{showHandle && sizeNotFull && placement === "bottom" && (
|
91
|
+
<CloseDrawerLine />
|
92
|
+
)}
|
82
93
|
{children}
|
83
|
-
{sizeNotFull && placement === "top" &&
|
94
|
+
{showHandle && sizeNotFull && placement === "top" && (
|
95
|
+
<CloseDrawerLine />
|
96
|
+
)}
|
84
97
|
</ChakraDrawer.Content>
|
85
98
|
</Box>
|
86
99
|
</ChakraDrawer.Positioner>
|
@@ -109,13 +122,14 @@ CloseDrawerLine.displayName = "CloseDrawerLine";
|
|
109
122
|
|
110
123
|
export const DrawerCloseTrigger = forwardRef<
|
111
124
|
HTMLButtonElement,
|
112
|
-
|
125
|
+
DrawerCloseTriggerProps
|
113
126
|
>(function DrawerCloseTrigger(props, ref) {
|
127
|
+
const { showText = false, ...rest } = props;
|
114
128
|
const { size } = useRootDrawerProps();
|
115
129
|
const { t } = useTranslation();
|
116
130
|
return (
|
117
|
-
<ChakraDrawer.CloseTrigger ref={ref} {...
|
118
|
-
{size === "full" ? (
|
131
|
+
<ChakraDrawer.CloseTrigger ref={ref} {...rest} asChild>
|
132
|
+
{showText || size === "full" ? (
|
119
133
|
<ResponsiveButton
|
120
134
|
variant="ghost"
|
121
135
|
icon={<CloseFill24Icon />}
|
package/src/dialog/types.ts
CHANGED
@@ -10,6 +10,7 @@ export type DrawerContentProps = ChakraDrawer.ContentProps &
|
|
10
10
|
children: React.ReactNode;
|
11
11
|
portalled?: boolean;
|
12
12
|
portalRef?: React.RefObject<HTMLElement>;
|
13
|
+
hideHandle?: boolean;
|
13
14
|
};
|
14
15
|
|
15
16
|
export type DrawerProps = Omit<
|
@@ -28,3 +29,7 @@ export type DrawerFullScreenHeaderProps = Omit<
|
|
28
29
|
backTrigger?: boolean;
|
29
30
|
closeTrigger?: boolean;
|
30
31
|
};
|
32
|
+
|
33
|
+
export type DrawerCloseTriggerProps = ChakraDrawer.CloseTriggerProps & {
|
34
|
+
showText?: boolean;
|
35
|
+
};
|