@vygruppen/spor-react 13.2.1 → 13.3.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/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-postinstall.log +4 -3
- package/CHANGELOG.md +18 -0
- package/dist/index.cjs +282 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.mjs +212 -124
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
- package/src/error-summary/index.tsx +79 -0
- package/src/index.tsx +1 -0
- package/src/theme/slot-recipes/anatomy.ts +7 -0
- package/src/theme/slot-recipes/datepicker.ts +1 -1
- package/src/theme/slot-recipes/error-summary.ts +32 -0
- package/src/theme/slot-recipes/index.ts +2 -0
- package/src/theme/slot-recipes/popover.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vygruppen/spor-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "13.
|
|
4
|
+
"version": "13.3.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -39,7 +39,6 @@
|
|
|
39
39
|
"awesome-phonenumber": "^5.11.0",
|
|
40
40
|
"deepmerge": "^4.3.1",
|
|
41
41
|
"framer-motion": "^11.11.17",
|
|
42
|
-
"jscodeshift": "^17.3.0",
|
|
43
42
|
"lottie-react": "^2.4.1",
|
|
44
43
|
"next-themes": "^0.4.4",
|
|
45
44
|
"react-aria": "^3.33.1",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Box, Flex, useSlotRecipe } from "@chakra-ui/react";
|
|
2
|
+
import { ErrorFill24Icon } from "@vygruppen/spor-icon-react";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
|
|
5
|
+
import { TextLink } from "@/link";
|
|
6
|
+
import { List, ListItem } from "@/list";
|
|
7
|
+
import { Heading } from "@/typography";
|
|
8
|
+
import { slugify } from "@/util";
|
|
9
|
+
|
|
10
|
+
export const ErrorSummary = ({
|
|
11
|
+
ref: externalRef,
|
|
12
|
+
children,
|
|
13
|
+
headingLevel = "h2",
|
|
14
|
+
heading,
|
|
15
|
+
...rest
|
|
16
|
+
}: {
|
|
17
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
headingLevel?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
|
|
20
|
+
heading: string;
|
|
21
|
+
}) => {
|
|
22
|
+
const recipe = useSlotRecipe({ key: "errorSummary" });
|
|
23
|
+
const styles = recipe();
|
|
24
|
+
|
|
25
|
+
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
26
|
+
const headingRef = useRef<HTMLHeadingElement>(null);
|
|
27
|
+
|
|
28
|
+
const ref = externalRef ?? wrapperRef;
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Box
|
|
32
|
+
css={styles.container}
|
|
33
|
+
ref={ref}
|
|
34
|
+
{...rest}
|
|
35
|
+
aria-labelledby={slugify(heading)}
|
|
36
|
+
tabIndex={-1}
|
|
37
|
+
>
|
|
38
|
+
{heading && (
|
|
39
|
+
<Flex css={styles.heading}>
|
|
40
|
+
<ErrorFill24Icon
|
|
41
|
+
css={{
|
|
42
|
+
flexShrink: 0,
|
|
43
|
+
"& path:first-of-type": {
|
|
44
|
+
fill: `icon.critical`,
|
|
45
|
+
},
|
|
46
|
+
"& path:not(:first-of-type)": {
|
|
47
|
+
fill: `surface.critical`,
|
|
48
|
+
},
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
<Heading as={headingLevel} variant="md" autoId ref={headingRef}>
|
|
52
|
+
{heading}
|
|
53
|
+
</Heading>
|
|
54
|
+
</Flex>
|
|
55
|
+
)}
|
|
56
|
+
<List css={styles.list} gap={2}>
|
|
57
|
+
{children}
|
|
58
|
+
</List>
|
|
59
|
+
</Box>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const ErrorSummaryItem = ({
|
|
64
|
+
children,
|
|
65
|
+
href,
|
|
66
|
+
...rest
|
|
67
|
+
}: {
|
|
68
|
+
children: React.ReactNode;
|
|
69
|
+
href: string;
|
|
70
|
+
}) => {
|
|
71
|
+
const recipe = useSlotRecipe({ key: "errorSummary" });
|
|
72
|
+
const styles = recipe();
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<ListItem css={styles.item} {...rest}>
|
|
76
|
+
<TextLink href={href}>{children}</TextLink>
|
|
77
|
+
</ListItem>
|
|
78
|
+
);
|
|
79
|
+
};
|
package/src/index.tsx
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineSlotRecipe } from "@chakra-ui/react";
|
|
2
|
+
|
|
3
|
+
import { errorSummaryAnatomy } from "./anatomy";
|
|
4
|
+
|
|
5
|
+
export const errorSummarySlotRecipe = defineSlotRecipe({
|
|
6
|
+
slots: errorSummaryAnatomy.keys(),
|
|
7
|
+
className: "spor-error-summary",
|
|
8
|
+
base: {
|
|
9
|
+
container: {
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "column",
|
|
12
|
+
padding: [3, 5],
|
|
13
|
+
backgroundColor: "surface.critical",
|
|
14
|
+
borderRadius: "md",
|
|
15
|
+
},
|
|
16
|
+
heading: {
|
|
17
|
+
fontSize: "md",
|
|
18
|
+
fontWeight: "bold",
|
|
19
|
+
color: "text.critical",
|
|
20
|
+
gap: [1, 1.5],
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
},
|
|
23
|
+
list: {
|
|
24
|
+
alignItems: "flex-start",
|
|
25
|
+
paddingLeft: [4, 5],
|
|
26
|
+
},
|
|
27
|
+
item: {
|
|
28
|
+
color: "text.critical.subtle",
|
|
29
|
+
marginTop: [2, 1.5],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -10,6 +10,7 @@ import { collapsibleSlotRecipe } from "./collapsible";
|
|
|
10
10
|
import { datePickerSlotRecipe } from "./datepicker";
|
|
11
11
|
import { dialogSlotRecipe } from "./dialog";
|
|
12
12
|
import { drawerSlotRecipe } from "./drawer";
|
|
13
|
+
import { errorSummarySlotRecipe } from "./error-summary";
|
|
13
14
|
import { fieldSlotRecipe } from "./field";
|
|
14
15
|
import { filterChipSlotRecipe } from "./filter-chip";
|
|
15
16
|
import { floatingActionButtonSlotRecipe } from "./floating-action-button";
|
|
@@ -75,4 +76,5 @@ export const slotRecipes = {
|
|
|
75
76
|
tag: inputChipSlotRecipe,
|
|
76
77
|
menu: menuSlotRecipe,
|
|
77
78
|
choiceChip: choiceChipSlotRecipe,
|
|
79
|
+
errorSummary: errorSummarySlotRecipe,
|
|
78
80
|
};
|
|
@@ -24,6 +24,8 @@ export const popoverSlotRecipe = defineSlotRecipe({
|
|
|
24
24
|
|
|
25
25
|
transformOrigin: "var(--transform-origin)",
|
|
26
26
|
maxHeight: "var(--available-height)",
|
|
27
|
+
maxWidth: "var(--available-width)",
|
|
28
|
+
|
|
27
29
|
_open: {
|
|
28
30
|
animationStyle: "scale-fade-in",
|
|
29
31
|
animationDuration: "fast",
|