@vygruppen/spor-react 12.24.15 → 13.0.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 +10 -10
- package/.turbo/turbo-postinstall.log +4 -3
- package/CHANGELOG.md +25 -0
- package/dist/index.cjs +2888 -2534
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +921 -572
- package/dist/index.d.ts +921 -572
- package/dist/index.mjs +2860 -2517
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
- package/src/accordion/Accordion.tsx +34 -29
- package/src/accordion/Expandable.tsx +20 -21
- package/src/alert/Alert.tsx +7 -5
- package/src/alert/AlertIcon.tsx +19 -20
- package/src/alert/ExpandableAlert.tsx +65 -64
- package/src/alert/ServiceAlert.tsx +78 -78
- package/src/breadcrumb/Breadcrumb.tsx +37 -34
- package/src/button/Button.tsx +64 -57
- package/src/button/ButtonGroup.tsx +12 -10
- package/src/button/Clipboard.tsx +21 -18
- package/src/button/CloseButton.tsx +19 -17
- package/src/button/FloatingActionButton.tsx +41 -47
- package/src/button/IconButton.tsx +20 -18
- package/src/calendar/CalendarContext.tsx +1 -1
- package/src/color-mode/color-mode.tsx +7 -5
- package/src/datepicker/CalendarTriggerButton.tsx +11 -7
- package/src/datepicker/DateField.tsx +53 -51
- package/src/datepicker/DatePicker.tsx +127 -134
- package/src/datepicker/DateTimeSegment.tsx +44 -40
- package/src/datepicker/StyledField.tsx +39 -36
- package/src/dialog/Dialog.tsx +14 -11
- package/src/dialog/Drawer.tsx +74 -67
- package/src/input/AttachedInputs.tsx +35 -41
- package/src/input/Autocomplete.tsx +118 -129
- package/src/input/CardSelect.tsx +67 -65
- package/src/input/Checkbox.tsx +19 -17
- package/src/input/CheckboxGroup.tsx +0 -2
- package/src/input/ChoiceChip.tsx +42 -38
- package/src/input/Combobox.tsx +4 -4
- package/src/input/CountryCodeSelect.tsx +8 -8
- package/src/input/Field.tsx +78 -75
- package/src/input/FloatingLabel.tsx +6 -8
- package/src/input/Input.tsx +87 -92
- package/src/input/ListBox.tsx +3 -4
- package/src/input/Menu.tsx +241 -0
- package/src/input/NativeSelect.tsx +7 -5
- package/src/input/NumericStepper.tsx +15 -12
- package/src/input/PasswordInput.tsx +65 -61
- package/src/input/PhoneNumberInput.tsx +7 -7
- package/src/input/Popover.tsx +52 -55
- package/src/input/Radio.tsx +16 -11
- package/src/input/SearchInput.tsx +32 -31
- package/src/input/Select.tsx +106 -96
- package/src/input/Switch.tsx +43 -41
- package/src/input/Textarea.tsx +68 -66
- package/src/input/index.ts +1 -0
- package/src/layout/PressableCard.tsx +11 -10
- package/src/layout/RadioCard.tsx +57 -53
- package/src/layout/Separator.tsx +8 -7
- package/src/layout/StaticCard.tsx +11 -10
- package/src/linjetag/LineIcon.tsx +48 -54
- package/src/linjetag/TravelTag.tsx +57 -59
- package/src/link/TextLink.tsx +50 -40
- package/src/loader/ProgressBar.tsx +41 -46
- package/src/loader/ProgressLoader.tsx +83 -86
- package/src/loader/Skeleton.tsx +56 -48
- package/src/logo/CargonetLogo.tsx +88 -87
- package/src/logo/VyLogo.tsx +80 -77
- package/src/logo/VyLogoPride.tsx +137 -135
- package/src/media-controller/JumpButton.tsx +30 -28
- package/src/media-controller/PlayPauseButton.tsx +8 -7
- package/src/media-controller/SkipButton.tsx +28 -26
- package/src/nudge/Nudge.tsx +66 -70
- package/src/pagination/Pagination.tsx +52 -46
- package/src/popover/index.tsx +46 -41
- package/src/progress-indicator/ProgressIndicator.tsx +10 -7
- package/src/stepper/Stepper.tsx +84 -81
- package/src/tab/Tabs.tsx +8 -4
- package/src/table/Table.tsx +89 -109
- package/src/theme/slot-recipes/anatomy.ts +14 -0
- package/src/theme/slot-recipes/index.ts +2 -0
- package/src/theme/slot-recipes/menu.ts +111 -0
- package/src/tooltip.tsx +26 -22
- package/src/typography/Badge.tsx +8 -5
- package/src/typography/Code.tsx +8 -5
- package/src/typography/Heading.tsx +22 -23
- package/src/typography/Text.tsx +11 -9
- package/tsconfig.json +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vygruppen/spor-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "13.0.0",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-swipeable": "^7.0.1",
|
|
48
48
|
"usehooks-ts": "^3.1.0",
|
|
49
49
|
"@vygruppen/spor-design-tokens": "4.3.3",
|
|
50
|
-
"@vygruppen/spor-icon-react": "
|
|
50
|
+
"@vygruppen/spor-icon-react": "5.0.0",
|
|
51
51
|
"@vygruppen/spor-loader": "0.7.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
@@ -56,13 +56,13 @@
|
|
|
56
56
|
"@testing-library/jest-dom": "^6.4.5",
|
|
57
57
|
"@testing-library/react": "^14.3.1",
|
|
58
58
|
"@types/node": "^22.13.4",
|
|
59
|
-
"@types/react": "
|
|
60
|
-
"@types/react-dom": "
|
|
59
|
+
"@types/react": "19.2.3",
|
|
60
|
+
"@types/react-dom": "19.2.3",
|
|
61
61
|
"clsx": "^2.1.1",
|
|
62
62
|
"concurrently": "^9.1.2",
|
|
63
63
|
"eslint": "^9.39.1",
|
|
64
|
-
"react": "
|
|
65
|
-
"react-dom": "
|
|
64
|
+
"react": "19.2.3",
|
|
65
|
+
"react-dom": "19.2.3",
|
|
66
66
|
"tsup": "^7.2.0",
|
|
67
67
|
"typescript": "^5.7.3",
|
|
68
68
|
"vitest": "^0.26.3",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"@vygruppen/tsconfig": "0.1.1"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"react": ">=
|
|
76
|
-
"react-dom": ">=
|
|
75
|
+
"react": ">=19.0.0",
|
|
76
|
+
"react-dom": ">=19.0.0"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"build": "tsup",
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
useSlotRecipe,
|
|
9
9
|
} from "@chakra-ui/react";
|
|
10
10
|
import { DropdownDownFill24Icon } from "@vygruppen/spor-icon-react";
|
|
11
|
-
import { forwardRef } from "react";
|
|
12
11
|
|
|
13
12
|
import { warnAboutMismatchingIcon } from "./helpers";
|
|
14
13
|
import {
|
|
@@ -53,28 +52,33 @@ import {
|
|
|
53
52
|
* @see https://spor.vy.no/components/accordion
|
|
54
53
|
*/
|
|
55
54
|
|
|
56
|
-
export const Accordion =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
55
|
+
export const Accordion = ({
|
|
56
|
+
ref,
|
|
57
|
+
...props
|
|
58
|
+
}: AccordionProps & {
|
|
59
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
60
|
+
}) => {
|
|
61
|
+
const { variant = "core", children, gap = 2, css, ...rest } = props;
|
|
62
|
+
const recipe = useSlotRecipe({ key: "accordion" });
|
|
63
|
+
const styles = recipe({ variant });
|
|
64
|
+
return (
|
|
65
|
+
<ChakraAccordion.Root
|
|
66
|
+
{...rest}
|
|
67
|
+
ref={ref}
|
|
68
|
+
css={{ ...styles.root, ...css }}
|
|
69
|
+
variant={variant}
|
|
70
|
+
>
|
|
71
|
+
<Stack gap={gap}>{children}</Stack>
|
|
72
|
+
</ChakraAccordion.Root>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
73
75
|
|
|
74
|
-
export const AccordionItemTrigger =
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
export const AccordionItemTrigger = function AccordionItemTrigger({
|
|
77
|
+
ref,
|
|
78
|
+
...props
|
|
79
|
+
}: AccordionItemTriggerProps & {
|
|
80
|
+
ref?: React.RefObject<HTMLButtonElement>;
|
|
81
|
+
}) {
|
|
78
82
|
const {
|
|
79
83
|
startElement,
|
|
80
84
|
children,
|
|
@@ -105,12 +109,14 @@ export const AccordionItemTrigger = forwardRef<
|
|
|
105
109
|
</ChakraAccordion.ItemTrigger>
|
|
106
110
|
</Box>
|
|
107
111
|
);
|
|
108
|
-
}
|
|
112
|
+
};
|
|
109
113
|
|
|
110
|
-
export const AccordionItemContent =
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
+
export const AccordionItemContent = function AccordionItemContent({
|
|
115
|
+
ref,
|
|
116
|
+
...props
|
|
117
|
+
}: AccordionItemContentProps & {
|
|
118
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
119
|
+
}) {
|
|
114
120
|
const {
|
|
115
121
|
children,
|
|
116
122
|
css,
|
|
@@ -133,7 +139,6 @@ export const AccordionItemContent = forwardRef<
|
|
|
133
139
|
</ChakraAccordion.ItemBody>
|
|
134
140
|
</ChakraAccordion.ItemContent>
|
|
135
141
|
);
|
|
136
|
-
}
|
|
137
|
-
Accordion.displayName = "Accordion";
|
|
142
|
+
};
|
|
138
143
|
|
|
139
144
|
export const AccordionItem = ChakraAccordion.Item;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
|
-
|
|
5
3
|
import {
|
|
6
4
|
Accordion,
|
|
7
5
|
AccordionItem,
|
|
@@ -24,23 +22,26 @@ import { ExpandableItemProps, ExpandableProps } from "./types";
|
|
|
24
22
|
* ```
|
|
25
23
|
*/
|
|
26
24
|
|
|
27
|
-
export const Expandable =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
25
|
+
export const Expandable = ({
|
|
26
|
+
ref,
|
|
27
|
+
...props
|
|
28
|
+
}: ExpandableProps & {
|
|
29
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
30
|
+
}) => {
|
|
31
|
+
const { title, children, headingLevel, startElement, ...rest } = props;
|
|
32
|
+
return (
|
|
33
|
+
<Accordion ref={ref} {...rest}>
|
|
34
|
+
<ExpandableItem
|
|
35
|
+
title={title}
|
|
36
|
+
headingLevel={headingLevel}
|
|
37
|
+
startElement={startElement}
|
|
38
|
+
value="single-expandable"
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</ExpandableItem>
|
|
42
|
+
</Accordion>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
47
|
* An item in a set of Expandables. Must be wrapped in an `<Accordion>` component.
|
|
@@ -85,5 +86,3 @@ export const ExpandableItem = (props: ExpandableItemProps) => {
|
|
|
85
86
|
</AccordionItem>
|
|
86
87
|
);
|
|
87
88
|
};
|
|
88
|
-
|
|
89
|
-
Expandable.displayName = "Expandable";
|
package/src/alert/Alert.tsx
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useSlotRecipe,
|
|
8
8
|
} from "@chakra-ui/react";
|
|
9
9
|
import { IconComponent } from "@vygruppen/spor-icon-react";
|
|
10
|
-
import { forwardRef } from "react";
|
|
11
10
|
|
|
12
11
|
import { CloseButton } from "@/button";
|
|
13
12
|
|
|
@@ -44,7 +43,12 @@ export type AlertProps = Omit<ChakraAlert.RootProps, "colorPalette"> & {
|
|
|
44
43
|
* @see Docs https://spor.vy.no/alert
|
|
45
44
|
*/
|
|
46
45
|
|
|
47
|
-
export const Alert =
|
|
46
|
+
export const Alert = ({
|
|
47
|
+
ref,
|
|
48
|
+
...props
|
|
49
|
+
}: AlertProps & {
|
|
50
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
51
|
+
}) => {
|
|
48
52
|
const {
|
|
49
53
|
title,
|
|
50
54
|
showIndicator = true,
|
|
@@ -109,6 +113,4 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
|
109
113
|
)}
|
|
110
114
|
</ChakraAlert.Root>
|
|
111
115
|
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
Alert.displayName = "Alert";
|
|
116
|
+
};
|
package/src/alert/AlertIcon.tsx
CHANGED
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
SuccessFill24Icon,
|
|
13
13
|
WarningFill24Icon,
|
|
14
14
|
} from "@vygruppen/spor-icon-react";
|
|
15
|
-
import { forwardRef } from "react";
|
|
16
15
|
import { VisuallyHidden } from "react-aria";
|
|
17
16
|
|
|
18
17
|
import { createTexts, useTranslation } from "../i18n";
|
|
@@ -26,26 +25,26 @@ type AlertIconProps = {
|
|
|
26
25
|
/**
|
|
27
26
|
* Internal component that shows the correct icon for the alert
|
|
28
27
|
*/
|
|
29
|
-
export const AlertIcon =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
</VisuallyHidden>
|
|
38
|
-
{CustomAlertIcon ? (
|
|
39
|
-
<CustomAlertIcon color={`alert.${variant}.icon`} />
|
|
40
|
-
) : (
|
|
41
|
-
<BaseAlertIcon variant={variant} />
|
|
42
|
-
)}
|
|
43
|
-
</Box>
|
|
44
|
-
);
|
|
45
|
-
},
|
|
46
|
-
);
|
|
28
|
+
export const AlertIcon = ({
|
|
29
|
+
ref,
|
|
30
|
+
variant,
|
|
31
|
+
customIcon: CustomAlertIcon,
|
|
32
|
+
}: AlertIconProps & {
|
|
33
|
+
ref?: React.RefObject<SVGSVGElement>;
|
|
34
|
+
}) => {
|
|
35
|
+
const { t } = useTranslation();
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
return (
|
|
38
|
+
<Box ref={ref}>
|
|
39
|
+
<VisuallyHidden>{t(texts[variant as keyof typeof texts])}</VisuallyHidden>
|
|
40
|
+
{CustomAlertIcon ? (
|
|
41
|
+
<CustomAlertIcon color={`alert.${variant}.icon`} />
|
|
42
|
+
) : (
|
|
43
|
+
<BaseAlertIcon variant={variant} />
|
|
44
|
+
)}
|
|
45
|
+
</Box>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
49
48
|
|
|
50
49
|
export const BaseAlertIcon = ({
|
|
51
50
|
variant,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
useSlotRecipe,
|
|
11
11
|
} from "@chakra-ui/react";
|
|
12
12
|
import { DropdownDownFill18Icon } from "@vygruppen/spor-icon-react";
|
|
13
|
-
import {
|
|
13
|
+
import { PropsWithChildren } from "react";
|
|
14
14
|
|
|
15
15
|
import { AccordionItemContent } from "@/accordion";
|
|
16
16
|
import { alertExpandableSlotRecipe } from "@/theme/slot-recipes/alert-expandable";
|
|
@@ -59,70 +59,71 @@ type ExpandableAlertProps = PropsWithChildren<ExpandableAlertVariantProps> &
|
|
|
59
59
|
* </ExpandableAlert>
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
|
-
export const ExpandableAlert =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
export const ExpandableAlert = ({
|
|
63
|
+
ref,
|
|
64
|
+
...props
|
|
65
|
+
}: ExpandableAlertProps & {
|
|
66
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
67
|
+
}) => {
|
|
68
|
+
const {
|
|
69
|
+
variant = "info",
|
|
70
|
+
children,
|
|
71
|
+
title,
|
|
72
|
+
collapsible = true,
|
|
73
|
+
headingLevel = "h3",
|
|
74
|
+
defaultOpen = false,
|
|
75
|
+
css,
|
|
76
|
+
...rest
|
|
77
|
+
} = props;
|
|
78
|
+
const recipe = useSlotRecipe({ key: "alertExpandable" });
|
|
79
|
+
const styles = recipe({ variant });
|
|
76
80
|
|
|
77
|
-
|
|
81
|
+
const defaultValue = "alert-expandable";
|
|
78
82
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
</HStack>
|
|
113
|
-
|
|
114
|
-
<Accordion.ItemIndicator>
|
|
115
|
-
<DropdownDownFill18Icon />
|
|
116
|
-
</Accordion.ItemIndicator>
|
|
83
|
+
return (
|
|
84
|
+
<Accordion.Root
|
|
85
|
+
defaultValue={defaultOpen ? [defaultValue] : undefined}
|
|
86
|
+
ref={ref}
|
|
87
|
+
css={{ ...styles.root, ...css }}
|
|
88
|
+
collapsible={collapsible}
|
|
89
|
+
{...rest}
|
|
90
|
+
>
|
|
91
|
+
<Accordion.Item value={defaultValue}>
|
|
92
|
+
<Accordion.ItemTrigger css={styles.itemTrigger}>
|
|
93
|
+
<HStack
|
|
94
|
+
gap="1"
|
|
95
|
+
alignItems="center"
|
|
96
|
+
justifyContent="space-between"
|
|
97
|
+
flex="1"
|
|
98
|
+
width="full"
|
|
99
|
+
>
|
|
100
|
+
<HStack gap="1" alignItems="center">
|
|
101
|
+
<Box css={styles.indicator}>
|
|
102
|
+
<AlertIcon variant={variant} />
|
|
103
|
+
</Box>
|
|
104
|
+
<Span
|
|
105
|
+
as={headingLevel}
|
|
106
|
+
css={{
|
|
107
|
+
// Truncate the title to one line
|
|
108
|
+
display: "-webkit-box",
|
|
109
|
+
overflow: "hidden",
|
|
110
|
+
WebkitLineClamp: "1",
|
|
111
|
+
WebkitBoxOrient: "vertical",
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{title}
|
|
115
|
+
</Span>
|
|
117
116
|
</HStack>
|
|
118
|
-
</Accordion.ItemTrigger>
|
|
119
|
-
<AccordionItemContent css={styles.itemContent}>
|
|
120
|
-
{children}
|
|
121
|
-
</AccordionItemContent>
|
|
122
|
-
</Accordion.Item>
|
|
123
|
-
</Accordion.Root>
|
|
124
|
-
);
|
|
125
|
-
},
|
|
126
|
-
);
|
|
127
117
|
|
|
128
|
-
|
|
118
|
+
<Accordion.ItemIndicator>
|
|
119
|
+
<DropdownDownFill18Icon />
|
|
120
|
+
</Accordion.ItemIndicator>
|
|
121
|
+
</HStack>
|
|
122
|
+
</Accordion.ItemTrigger>
|
|
123
|
+
<AccordionItemContent css={styles.itemContent}>
|
|
124
|
+
{children}
|
|
125
|
+
</AccordionItemContent>
|
|
126
|
+
</Accordion.Item>
|
|
127
|
+
</Accordion.Root>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
ServiceFill24Icon,
|
|
15
15
|
WarningFill24Icon,
|
|
16
16
|
} from "@vygruppen/spor-icon-react";
|
|
17
|
-
import {
|
|
17
|
+
import { PropsWithChildren } from "react";
|
|
18
18
|
|
|
19
19
|
import { createTexts, useTranslation } from "../i18n";
|
|
20
20
|
import { alertServiceSlotRecipe } from "../theme/slot-recipes/alert-service";
|
|
@@ -57,86 +57,86 @@ type ServiceAlertProps = Omit<AlertProps, "variant"> &
|
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
59
|
|
|
60
|
-
export const ServiceAlert =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
export const ServiceAlert = ({
|
|
61
|
+
ref,
|
|
62
|
+
...props
|
|
63
|
+
}: ServiceAlertProps & {
|
|
64
|
+
ref?: React.RefObject<HTMLDivElement>;
|
|
65
|
+
}) => {
|
|
66
|
+
const {
|
|
67
|
+
variant = "service",
|
|
68
|
+
children,
|
|
69
|
+
title,
|
|
70
|
+
notification,
|
|
71
|
+
contentWidth = "container.md",
|
|
72
|
+
headingLevel = "h3",
|
|
73
|
+
defaultOpen = false,
|
|
74
|
+
collapsible = true,
|
|
75
|
+
css,
|
|
76
|
+
...rest
|
|
77
|
+
} = props;
|
|
78
|
+
const { t } = useTranslation();
|
|
79
|
+
const recipe = useSlotRecipe({ key: "alertService" });
|
|
80
|
+
const styles = recipe({ variant });
|
|
77
81
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
{title}
|
|
114
|
-
</Span>
|
|
115
|
-
</HStack>
|
|
116
|
-
<Flex alignItems="center" gap={[0.5, null, null, 1]}>
|
|
117
|
-
{notification && (
|
|
118
|
-
<Text css={styles.notificationText}>
|
|
119
|
-
{t(texts.notification(notification))}
|
|
120
|
-
</Text>
|
|
121
|
-
)}
|
|
122
|
-
<Accordion.ItemIndicator>
|
|
123
|
-
<DropdownDownFill24Icon color="icon.inverted" />
|
|
124
|
-
</Accordion.ItemIndicator>
|
|
125
|
-
</Flex>
|
|
82
|
+
const defaultValue = "spor-service-alert";
|
|
83
|
+
return (
|
|
84
|
+
<Accordion.Root
|
|
85
|
+
defaultValue={defaultOpen ? [defaultValue] : undefined}
|
|
86
|
+
collapsible={collapsible}
|
|
87
|
+
css={{ ...styles.root, ...css }}
|
|
88
|
+
ref={ref}
|
|
89
|
+
{...rest}
|
|
90
|
+
>
|
|
91
|
+
<Accordion.Item value={defaultValue}>
|
|
92
|
+
<Accordion.ItemTrigger css={styles.itemTrigger}>
|
|
93
|
+
<HStack
|
|
94
|
+
justifyContent="space-between"
|
|
95
|
+
alignContent="center"
|
|
96
|
+
width="100%"
|
|
97
|
+
maxWidth={contentWidth}
|
|
98
|
+
>
|
|
99
|
+
<HStack as={headingLevel} alignItems="center" gap="1">
|
|
100
|
+
{variant === "service" ? (
|
|
101
|
+
<ServiceFill24Icon aria-label={t(texts.service)} />
|
|
102
|
+
) : (
|
|
103
|
+
<WarningFill24Icon aria-label={t(texts["global-deviation"])} />
|
|
104
|
+
)}
|
|
105
|
+
<Span
|
|
106
|
+
css={{
|
|
107
|
+
// Truncate the title to one line
|
|
108
|
+
display: "-webkit-box",
|
|
109
|
+
overflow: "hidden",
|
|
110
|
+
WebkitLineClamp: "1",
|
|
111
|
+
WebkitBoxOrient: "vertical",
|
|
112
|
+
...styles.itemTriggerTitle,
|
|
113
|
+
}}
|
|
114
|
+
>
|
|
115
|
+
{title}
|
|
116
|
+
</Span>
|
|
126
117
|
</HStack>
|
|
127
|
-
|
|
118
|
+
<Flex alignItems="center" gap={[0.5, null, null, 1]}>
|
|
119
|
+
{notification && (
|
|
120
|
+
<Text css={styles.notificationText}>
|
|
121
|
+
{t(texts.notification(notification))}
|
|
122
|
+
</Text>
|
|
123
|
+
)}
|
|
124
|
+
<Accordion.ItemIndicator>
|
|
125
|
+
<DropdownDownFill24Icon color="icon.inverted" />
|
|
126
|
+
</Accordion.ItemIndicator>
|
|
127
|
+
</Flex>
|
|
128
|
+
</HStack>
|
|
129
|
+
</Accordion.ItemTrigger>
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
);
|
|
139
|
-
ServiceAlert.displayName = "ServiceAlert";
|
|
131
|
+
<Accordion.ItemContent css={styles.itemContent}>
|
|
132
|
+
<Accordion.ItemBody maxWidth={contentWidth} css={styles.itemBody}>
|
|
133
|
+
{children}
|
|
134
|
+
</Accordion.ItemBody>
|
|
135
|
+
</Accordion.ItemContent>
|
|
136
|
+
</Accordion.Item>
|
|
137
|
+
</Accordion.Root>
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
140
|
|
|
141
141
|
const texts = createTexts({
|
|
142
142
|
notification: (notification) => {
|