@vygruppen/spor-react 12.24.10 → 12.24.12
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 +2 -2
- package/CHANGELOG.md +16 -0
- package/dist/index.cjs +291 -165
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -3
- package/dist/index.d.ts +9 -3
- package/dist/index.mjs +291 -165
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/accordion/Accordion.tsx +21 -6
- package/src/alert/Alert.tsx +10 -2
- package/src/breadcrumb/Breadcrumb.tsx +10 -5
- package/src/calendar/Calendar.tsx +11 -2
- package/src/calendar/CalendarCell.tsx +1 -0
- package/src/calendar/CalendarGrid.tsx +2 -1
- package/src/calendar/CalendarHeader.tsx +6 -1
- package/src/datepicker/Calendar.tsx +9 -2
- package/src/datepicker/CalendarCell.tsx +1 -0
- package/src/datepicker/CalendarGrid.tsx +2 -2
- package/src/datepicker/CalendarHeader.tsx +6 -1
- package/src/datepicker/DatePicker.tsx +7 -1
- package/src/input/Autocomplete.tsx +8 -9
- package/src/input/Switch.tsx +2 -0
- package/src/layout/RadioCard.tsx +16 -4
- package/src/loader/ProgressBar.tsx +7 -1
- package/src/progress-indicator/ProgressIndicator.tsx +18 -8
- package/src/stepper/Stepper.tsx +17 -5
- package/src/stepper/StepperStep.tsx +2 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vygruppen/spor-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "12.24.
|
|
4
|
+
"version": "12.24.12",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"usehooks-ts": "^3.1.0",
|
|
49
49
|
"@vygruppen/spor-design-tokens": "4.3.3",
|
|
50
50
|
"@vygruppen/spor-loader": "0.7.0",
|
|
51
|
-
"@vygruppen/spor-icon-react": "4.5.
|
|
51
|
+
"@vygruppen/spor-icon-react": "4.5.3"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@react-types/datepicker": "^3.10.0",
|
|
@@ -55,14 +55,14 @@ import {
|
|
|
55
55
|
|
|
56
56
|
export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
|
|
57
57
|
(props, ref) => {
|
|
58
|
-
const { variant = "core", children, gap = 2, ...rest } = props;
|
|
58
|
+
const { variant = "core", children, gap = 2, css, ...rest } = props;
|
|
59
59
|
const recipe = useSlotRecipe({ key: "accordion" });
|
|
60
60
|
const styles = recipe({ variant });
|
|
61
61
|
return (
|
|
62
62
|
<ChakraAccordion.Root
|
|
63
63
|
{...rest}
|
|
64
64
|
ref={ref}
|
|
65
|
-
css={styles.root}
|
|
65
|
+
css={{ ...styles.root, ...css }}
|
|
66
66
|
variant={variant}
|
|
67
67
|
>
|
|
68
68
|
<Stack gap={gap}>{children}</Stack>
|
|
@@ -79,6 +79,7 @@ export const AccordionItemTrigger = forwardRef<
|
|
|
79
79
|
startElement,
|
|
80
80
|
children,
|
|
81
81
|
headingLevel,
|
|
82
|
+
css,
|
|
82
83
|
showChevron = true,
|
|
83
84
|
...rest
|
|
84
85
|
} = props;
|
|
@@ -87,7 +88,11 @@ export const AccordionItemTrigger = forwardRef<
|
|
|
87
88
|
const styles = recipe();
|
|
88
89
|
return (
|
|
89
90
|
<Box as={headingLevel}>
|
|
90
|
-
<ChakraAccordion.ItemTrigger
|
|
91
|
+
<ChakraAccordion.ItemTrigger
|
|
92
|
+
{...rest}
|
|
93
|
+
ref={ref}
|
|
94
|
+
css={{ ...styles.itemTrigger, ...css }}
|
|
95
|
+
>
|
|
91
96
|
<HStack flex="1" gap={1} textAlign="start" width="full">
|
|
92
97
|
{startElement && startElement}
|
|
93
98
|
{children}
|
|
@@ -106,14 +111,24 @@ export const AccordionItemContent = forwardRef<
|
|
|
106
111
|
HTMLDivElement,
|
|
107
112
|
AccordionItemContentProps
|
|
108
113
|
>(function AccordionItemContent(props, ref) {
|
|
109
|
-
const {
|
|
114
|
+
const {
|
|
115
|
+
children,
|
|
116
|
+
css,
|
|
117
|
+
"aria-labelledby": ariaLabelledBy,
|
|
118
|
+
...otherProps
|
|
119
|
+
} = props;
|
|
110
120
|
|
|
111
121
|
const recipe = useSlotRecipe({ key: "accordion" });
|
|
112
122
|
const styles = recipe();
|
|
113
123
|
|
|
124
|
+
// We need to be able to override aria-labelledby here to prevent an issue on voiceover on iPhone where the related AccordionItemTrigger
|
|
125
|
+
// is announced after announcing the ItemContent. This issue occurs because the default aria-labelledby is set to the id of the AccordionItemTrigger.
|
|
114
126
|
return (
|
|
115
|
-
<ChakraAccordion.ItemContent
|
|
116
|
-
|
|
127
|
+
<ChakraAccordion.ItemContent
|
|
128
|
+
css={{ ...styles.itemContent, ...css }}
|
|
129
|
+
aria-labelledby={ariaLabelledBy}
|
|
130
|
+
>
|
|
131
|
+
<ChakraAccordion.ItemBody {...otherProps} ref={ref}>
|
|
117
132
|
{children}
|
|
118
133
|
</ChakraAccordion.ItemBody>
|
|
119
134
|
</ChakraAccordion.ItemContent>
|
package/src/alert/Alert.tsx
CHANGED
|
@@ -66,7 +66,10 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
|
66
66
|
if (!open) return null;
|
|
67
67
|
return (
|
|
68
68
|
<ChakraAlert.Root ref={ref} {...props}>
|
|
69
|
-
<ChakraAlert.Content
|
|
69
|
+
<ChakraAlert.Content
|
|
70
|
+
flexDirection={title ? "column" : "row"}
|
|
71
|
+
data-part="content"
|
|
72
|
+
>
|
|
70
73
|
<HStack gap="1" alignItems="flex-start">
|
|
71
74
|
{showIndicator && (
|
|
72
75
|
<ChakraAlert.Indicator asChild>
|
|
@@ -74,7 +77,10 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
|
74
77
|
</ChakraAlert.Indicator>
|
|
75
78
|
)}
|
|
76
79
|
{title && (
|
|
77
|
-
<ChakraAlert.Title
|
|
80
|
+
<ChakraAlert.Title
|
|
81
|
+
paddingRight={closable ? 6 : 0}
|
|
82
|
+
data-part="title"
|
|
83
|
+
>
|
|
78
84
|
{title}
|
|
79
85
|
</ChakraAlert.Title>
|
|
80
86
|
)}
|
|
@@ -84,6 +90,7 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
|
84
90
|
width="100%"
|
|
85
91
|
paddingLeft={title ? 0.5 : 0}
|
|
86
92
|
paddingRight={closable ? 6 : 0}
|
|
93
|
+
data-part="description"
|
|
87
94
|
>
|
|
88
95
|
{children}
|
|
89
96
|
</ChakraAlert.Description>
|
|
@@ -91,6 +98,7 @@ export const Alert = forwardRef<HTMLDivElement, AlertProps>((props, ref) => {
|
|
|
91
98
|
</ChakraAlert.Content>
|
|
92
99
|
{closable && (
|
|
93
100
|
<CloseButton
|
|
101
|
+
data-part="close-button"
|
|
94
102
|
size="xs"
|
|
95
103
|
position="absolute"
|
|
96
104
|
top="1.5"
|
|
@@ -21,21 +21,26 @@ import React, { forwardRef } from "react";
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export const Breadcrumb = forwardRef<HTMLDivElement, BreadcrumbRootProps>(
|
|
24
|
-
({ children, ...props }, ref) => {
|
|
24
|
+
({ children, css, ...props }, ref) => {
|
|
25
25
|
const validChildren = React.Children.toArray(children).filter((element) =>
|
|
26
26
|
React.isValidElement(element),
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
|
-
<ChakraBreadcrumb.Root ref={ref} {...props}>
|
|
31
|
-
<ChakraBreadcrumb.List>
|
|
30
|
+
<ChakraBreadcrumb.Root ref={ref} {...props} css={css}>
|
|
31
|
+
<ChakraBreadcrumb.List data-part="list">
|
|
32
32
|
{validChildren.map((child, index) => {
|
|
33
33
|
const isLast = index === validChildren.length - 1;
|
|
34
34
|
return (
|
|
35
35
|
<React.Fragment key={index}>
|
|
36
|
-
<ChakraBreadcrumb.Item>
|
|
36
|
+
<ChakraBreadcrumb.Item data-part="item">
|
|
37
|
+
{child}
|
|
38
|
+
</ChakraBreadcrumb.Item>
|
|
37
39
|
{!isLast && (
|
|
38
|
-
<ChakraBreadcrumb.Separator
|
|
40
|
+
<ChakraBreadcrumb.Separator
|
|
41
|
+
aria-hidden="true"
|
|
42
|
+
data-part="separator"
|
|
43
|
+
>
|
|
39
44
|
<DropdownRightFill18Icon />
|
|
40
45
|
</ChakraBreadcrumb.Separator>
|
|
41
46
|
)}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { SystemStyleObject } from "@chakra-ui/react";
|
|
2
|
+
|
|
1
3
|
import { useCalendar } from "@/calendar/CalendarContext";
|
|
2
4
|
import { CalendarGrid } from "@/calendar/CalendarGrid";
|
|
3
5
|
import { CalendarHeader } from "@/calendar/CalendarHeader";
|
|
@@ -8,17 +10,24 @@ type Props = {
|
|
|
8
10
|
* Show two months side by side
|
|
9
11
|
*/
|
|
10
12
|
dualView?: boolean;
|
|
13
|
+
css?: SystemStyleObject;
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
/**
|
|
14
17
|
* Calendar component that displays a grid of days for a specific month.
|
|
15
18
|
* Standard view with pagination, with the option to show dual months side by side.
|
|
16
19
|
*/
|
|
17
|
-
export function Calendar({ dualView }: Props) {
|
|
20
|
+
export function Calendar({ dualView, css }: Props) {
|
|
18
21
|
const { calendarProps, ref } = useCalendar();
|
|
19
22
|
|
|
20
23
|
return (
|
|
21
|
-
<Box
|
|
24
|
+
<Box
|
|
25
|
+
width="fit-content"
|
|
26
|
+
ref={ref}
|
|
27
|
+
{...calendarProps}
|
|
28
|
+
css={css}
|
|
29
|
+
data-part="root"
|
|
30
|
+
>
|
|
22
31
|
<CalendarHeader dualView={dualView} />
|
|
23
32
|
|
|
24
33
|
<Flex alignItems="flex-start">
|
|
@@ -41,7 +41,7 @@ export function CalendarGrid({ offset = {} }: Props) {
|
|
|
41
41
|
const weeksInMonth = getWeeksInMonth(startDate, locale);
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
|
-
<table {...gridProps} cellPadding="0">
|
|
44
|
+
<table {...gridProps} cellPadding="0" data-part="calendar-grid">
|
|
45
45
|
<thead {...headerProps}>
|
|
46
46
|
<tr>
|
|
47
47
|
{weekDays[language].map((day, index) => (
|
|
@@ -61,6 +61,7 @@ export function CalendarGrid({ offset = {} }: Props) {
|
|
|
61
61
|
paddingTop={0.5}
|
|
62
62
|
textAlign="center"
|
|
63
63
|
fontWeight="bold"
|
|
64
|
+
data-part="calendar-table-heading"
|
|
64
65
|
>
|
|
65
66
|
{day}
|
|
66
67
|
</Text>
|
|
@@ -32,7 +32,12 @@ export function CalendarHeader({ dualView }: Props) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
|
-
<Flex
|
|
35
|
+
<Flex
|
|
36
|
+
flex={1}
|
|
37
|
+
alignItems="center"
|
|
38
|
+
paddingBottom={4}
|
|
39
|
+
data-part="calendar-header"
|
|
40
|
+
>
|
|
36
41
|
{/* Add a screen reader only description of the entire visible range rather than
|
|
37
42
|
* a separate heading above each month grid. This is placed first in the DOM order
|
|
38
43
|
* so that it is the first thing a touch screen reader user encounters.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { Box, useSlotRecipe } from "@chakra-ui/react";
|
|
3
|
+
import { Box, SystemStyleObject, useSlotRecipe } from "@chakra-ui/react";
|
|
4
4
|
import { createCalendar } from "@internationalized/date";
|
|
5
5
|
import {
|
|
6
6
|
CalendarProps as ReactAriaCalendarProps,
|
|
@@ -18,10 +18,13 @@ import { useCurrentLocale } from "./utils";
|
|
|
18
18
|
type CalendarProps = ReactAriaCalendarProps<DateValue> &
|
|
19
19
|
CalendarVariants & {
|
|
20
20
|
showYearNavigation?: boolean;
|
|
21
|
+
} & {
|
|
22
|
+
css?: SystemStyleObject;
|
|
21
23
|
};
|
|
22
24
|
export function Calendar({
|
|
23
25
|
showYearNavigation,
|
|
24
26
|
variant,
|
|
27
|
+
css,
|
|
25
28
|
...props
|
|
26
29
|
}: CalendarProps) {
|
|
27
30
|
const { t } = useTranslation();
|
|
@@ -43,7 +46,11 @@ export function Calendar({
|
|
|
43
46
|
t(texts.calendar) + (calendarAriaLabel ? ` ${calendarAriaLabel}` : "");
|
|
44
47
|
|
|
45
48
|
return (
|
|
46
|
-
<Box
|
|
49
|
+
<Box
|
|
50
|
+
{...calendarProps}
|
|
51
|
+
aria-label={ariaLabel}
|
|
52
|
+
css={{ ...styles.box, ...css }}
|
|
53
|
+
>
|
|
47
54
|
<CalendarHeader state={state} showYearNavigation={showYearNavigation} />
|
|
48
55
|
<CalendarGrid variant={variant} state={state} />
|
|
49
56
|
</Box>
|
|
@@ -52,9 +52,9 @@ export function CalendarGrid({
|
|
|
52
52
|
const styles = recipe({ variant });
|
|
53
53
|
|
|
54
54
|
return (
|
|
55
|
-
<Box as="table" {...gridProps} css={styles.box}>
|
|
55
|
+
<Box as="table" {...gridProps} css={styles.box} data-part="calendar-grid">
|
|
56
56
|
<thead {...headerProps}>
|
|
57
|
-
<tr>
|
|
57
|
+
<tr data-part="calendar-table-heading">
|
|
58
58
|
{weekDays[language].map((day, index) => {
|
|
59
59
|
return (
|
|
60
60
|
<Text
|
|
@@ -42,7 +42,12 @@ export function CalendarHeader({
|
|
|
42
42
|
const isYearPickerVisible = showYearNavigation && !areAllOtherYearsDisabled;
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<Flex
|
|
45
|
+
<Flex
|
|
46
|
+
alignItems="center"
|
|
47
|
+
paddingBottom="4"
|
|
48
|
+
justifyContent="space-between"
|
|
49
|
+
data-part="calendar-header"
|
|
50
|
+
>
|
|
46
51
|
<CalendarNavigator
|
|
47
52
|
title={title || (isYearPickerVisible ? monthTitle : monthAndYearTitle)}
|
|
48
53
|
unit="month"
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
PopoverRootProps,
|
|
8
8
|
Portal,
|
|
9
9
|
RecipeVariantProps,
|
|
10
|
+
SystemStyleObject,
|
|
10
11
|
useFieldContext,
|
|
11
12
|
useSlotRecipe,
|
|
12
13
|
} from "@chakra-ui/react";
|
|
@@ -47,7 +48,9 @@ type DatePickerProps = Omit<AriaDatePickerProps<DateValue>, "onChange"> &
|
|
|
47
48
|
overrideBorderColor?: string;
|
|
48
49
|
isActive?: boolean;
|
|
49
50
|
onClick?: () => void;
|
|
50
|
-
} & FieldBaseProps
|
|
51
|
+
} & FieldBaseProps & {
|
|
52
|
+
css?: SystemStyleObject;
|
|
53
|
+
};
|
|
51
54
|
|
|
52
55
|
/**
|
|
53
56
|
* A date picker component.
|
|
@@ -71,6 +74,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
|
71
74
|
invalid = false,
|
|
72
75
|
helperText,
|
|
73
76
|
positioning,
|
|
77
|
+
css,
|
|
74
78
|
...props
|
|
75
79
|
},
|
|
76
80
|
externalRef,
|
|
@@ -121,6 +125,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
|
121
125
|
{...calendarProps}
|
|
122
126
|
variant={variant}
|
|
123
127
|
showYearNavigation={showYearNavigation}
|
|
128
|
+
css={css}
|
|
124
129
|
/>
|
|
125
130
|
</ChakraPopover.Body>
|
|
126
131
|
</ChakraPopover.Content>
|
|
@@ -134,6 +139,7 @@ export const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>(
|
|
|
134
139
|
display="inline-flex"
|
|
135
140
|
flexDirection="column"
|
|
136
141
|
width={width}
|
|
142
|
+
css={css}
|
|
137
143
|
>
|
|
138
144
|
<ChakraPopover.Root {...dialogProps} positioning={positioning}>
|
|
139
145
|
<Field
|
|
@@ -73,7 +73,7 @@ export const Autocomplete = ({
|
|
|
73
73
|
|
|
74
74
|
const combobox = useCombobox({
|
|
75
75
|
collection,
|
|
76
|
-
openOnClick,
|
|
76
|
+
openOnClick: filteredChildren.length > 0 ? openOnClick : false,
|
|
77
77
|
onInputValueChange: (event) => {
|
|
78
78
|
if (!filteredExternally) {
|
|
79
79
|
filter(event.inputValue);
|
|
@@ -107,7 +107,8 @@ export const Autocomplete = ({
|
|
|
107
107
|
required={required}
|
|
108
108
|
onFocus={(event) => {
|
|
109
109
|
onFocus?.(event);
|
|
110
|
-
if (openOnFocus
|
|
110
|
+
if (openOnFocus && filteredChildren.length > 0)
|
|
111
|
+
combobox.setOpen(true);
|
|
111
112
|
}}
|
|
112
113
|
/>
|
|
113
114
|
</Combobox.Input>
|
|
@@ -119,14 +120,12 @@ export const Autocomplete = ({
|
|
|
119
120
|
</Combobox.Control>
|
|
120
121
|
<Combobox.Positioner>
|
|
121
122
|
<Combobox.Content>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
<ColorSpinner width="1.5rem" p="2" />
|
|
127
|
-
) : (
|
|
128
|
-
<>{filteredChildren}</>
|
|
123
|
+
{!loading && (
|
|
124
|
+
<Combobox.Empty>
|
|
125
|
+
{emptyLabel ?? t(texts.noItemsFound)}
|
|
126
|
+
</Combobox.Empty>
|
|
129
127
|
)}
|
|
128
|
+
{loading ? <ColorSpinner width="1.5rem" p="2" /> : filteredChildren}
|
|
130
129
|
</Combobox.Content>
|
|
131
130
|
</Combobox.Positioner>
|
|
132
131
|
</Combobox.RootProvider>
|
package/src/input/Switch.tsx
CHANGED
|
@@ -54,6 +54,7 @@ export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
|
|
|
54
54
|
invalid,
|
|
55
55
|
errorText,
|
|
56
56
|
helperText,
|
|
57
|
+
css,
|
|
57
58
|
...rest
|
|
58
59
|
} = props;
|
|
59
60
|
const recipe = useSlotRecipe({ key: "switch" });
|
|
@@ -67,6 +68,7 @@ export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
|
|
|
67
68
|
helperText={helperText}
|
|
68
69
|
required={props.required}
|
|
69
70
|
id={rest.id}
|
|
71
|
+
css={css}
|
|
70
72
|
>
|
|
71
73
|
<ChakraSwitch.Root
|
|
72
74
|
ref={rootRef}
|
package/src/layout/RadioCard.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
RecipeVariantProps,
|
|
5
5
|
useSlotRecipe,
|
|
6
6
|
} from "@chakra-ui/react";
|
|
7
|
-
import React, { forwardRef } from "react";
|
|
7
|
+
import React, { forwardRef, useId } from "react";
|
|
8
8
|
|
|
9
9
|
import { radioCardSlotRecipe } from "../theme/slot-recipes/radio-card";
|
|
10
10
|
|
|
@@ -41,12 +41,24 @@ type RadioCardItemProps = Exclude<
|
|
|
41
41
|
export const RadioCard = forwardRef<HTMLInputElement, RadioCardItemProps>(
|
|
42
42
|
(props, ref) => {
|
|
43
43
|
const { inputProps, children } = props;
|
|
44
|
+
const uniqueId = useId();
|
|
45
|
+
const itemControlId = `radio-card-item-control-${uniqueId}`;
|
|
46
|
+
|
|
47
|
+
const inputHasAriaLabel =
|
|
48
|
+
inputProps?.["aria-labelledby"] || inputProps?.["aria-label"];
|
|
44
49
|
|
|
45
50
|
return (
|
|
46
51
|
<ChakraRadioCard.Item {...props}>
|
|
47
|
-
<ChakraRadioCard.ItemHiddenInput
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
<ChakraRadioCard.ItemHiddenInput
|
|
53
|
+
aria-labelledby={
|
|
54
|
+
inputHasAriaLabel ? inputProps?.["aria-labelledby"] : itemControlId
|
|
55
|
+
}
|
|
56
|
+
ref={ref}
|
|
57
|
+
{...inputProps}
|
|
58
|
+
/>
|
|
59
|
+
<ChakraRadioCard.ItemControl id={itemControlId} aria-hidden>
|
|
60
|
+
{children}
|
|
61
|
+
</ChakraRadioCard.ItemControl>
|
|
50
62
|
</ChakraRadioCard.Item>
|
|
51
63
|
);
|
|
52
64
|
},
|
|
@@ -84,6 +84,7 @@ export const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
|
|
|
84
84
|
isActive = true,
|
|
85
85
|
showValueText = false,
|
|
86
86
|
height = "0.5rem",
|
|
87
|
+
css,
|
|
87
88
|
...rest
|
|
88
89
|
},
|
|
89
90
|
ref,
|
|
@@ -96,7 +97,12 @@ export const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
|
|
|
96
97
|
});
|
|
97
98
|
|
|
98
99
|
return (
|
|
99
|
-
<Progress.Root
|
|
100
|
+
<Progress.Root
|
|
101
|
+
css={{ ...styles.container, ...css }}
|
|
102
|
+
ref={ref}
|
|
103
|
+
value={value}
|
|
104
|
+
{...rest}
|
|
105
|
+
>
|
|
100
106
|
<Progress.Track
|
|
101
107
|
height={height}
|
|
102
108
|
css={isActive ? styles.background : styles.disabledBackground}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
BoxProps,
|
|
4
|
+
RecipeVariantProps,
|
|
5
|
+
SystemStyleObject,
|
|
6
|
+
useSlotRecipe,
|
|
7
|
+
} from "@chakra-ui/react";
|
|
3
8
|
import React, { forwardRef, PropsWithChildren } from "react";
|
|
4
9
|
|
|
5
10
|
import { Box, createTexts, useTranslation } from "..";
|
|
@@ -16,6 +21,7 @@ export type ProgressIndicatorProps = BoxProps &
|
|
|
16
21
|
numberOfSteps: number;
|
|
17
22
|
activeStep: number;
|
|
18
23
|
colorPalette?: string;
|
|
24
|
+
css?: SystemStyleObject;
|
|
19
25
|
};
|
|
20
26
|
|
|
21
27
|
/**
|
|
@@ -35,7 +41,7 @@ export type ProgressIndicatorProps = BoxProps &
|
|
|
35
41
|
export const ProgressIndicator = forwardRef<
|
|
36
42
|
HTMLDivElement,
|
|
37
43
|
ProgressIndicatorProps
|
|
38
|
-
>(({ numberOfSteps, activeStep }, ref) => {
|
|
44
|
+
>(({ numberOfSteps, activeStep, css }, ref) => {
|
|
39
45
|
const { t } = useTranslation();
|
|
40
46
|
const recipe = useSlotRecipe({
|
|
41
47
|
key: "progressIndicator",
|
|
@@ -45,7 +51,7 @@ export const ProgressIndicator = forwardRef<
|
|
|
45
51
|
|
|
46
52
|
return (
|
|
47
53
|
<Box
|
|
48
|
-
css={styles.root}
|
|
54
|
+
css={{ ...styles.root, ...css }}
|
|
49
55
|
role="progressbar"
|
|
50
56
|
aria-valuemin={1}
|
|
51
57
|
aria-valuemax={numberOfSteps}
|
|
@@ -53,13 +59,17 @@ export const ProgressIndicator = forwardRef<
|
|
|
53
59
|
aria-valuetext={t(texts.stepsOf(activeStep, numberOfSteps))}
|
|
54
60
|
ref={ref}
|
|
55
61
|
>
|
|
56
|
-
<Box css={styles.container}>
|
|
62
|
+
<Box css={{ ...styles.container, ...css }}>
|
|
57
63
|
{Array.from({ length: numberOfSteps }, (_, index) => (
|
|
58
|
-
<
|
|
64
|
+
<Box
|
|
59
65
|
key={index}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
66
|
+
data-part={activeStep === index + 1 ? "current-step" : "step"}
|
|
67
|
+
>
|
|
68
|
+
<ProgressDot
|
|
69
|
+
aria-valuenow={index + 1}
|
|
70
|
+
isActive={activeStep === index + 1}
|
|
71
|
+
/>
|
|
72
|
+
</Box>
|
|
63
73
|
))}
|
|
64
74
|
</Box>
|
|
65
75
|
</Box>
|
package/src/stepper/Stepper.tsx
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Flex,
|
|
4
|
+
RecipeVariantProps,
|
|
5
|
+
SystemStyleObject,
|
|
6
|
+
useSlotRecipe,
|
|
7
|
+
} from "@chakra-ui/react";
|
|
3
8
|
import { ArrowLeftFill24Icon } from "@vygruppen/spor-icon-react";
|
|
4
9
|
import { forwardRef, PropsWithChildren } from "react";
|
|
5
10
|
|
|
@@ -36,6 +41,7 @@ type StepperProps = PropsWithChildren<StepperVariantProps> & {
|
|
|
36
41
|
variant: "core" | "accent";
|
|
37
42
|
/** Disables all clicks */
|
|
38
43
|
disabled?: boolean;
|
|
44
|
+
css?: SystemStyleObject;
|
|
39
45
|
};
|
|
40
46
|
/**
|
|
41
47
|
* A stepper is used to show which step of a process a user is currently in.
|
|
@@ -63,6 +69,7 @@ export const Stepper = forwardRef<HTMLDivElement, StepperProps>(
|
|
|
63
69
|
headingLevel,
|
|
64
70
|
variant,
|
|
65
71
|
disabled,
|
|
72
|
+
css,
|
|
66
73
|
} = props;
|
|
67
74
|
const recipe = useSlotRecipe({ key: "stepper" });
|
|
68
75
|
const style = recipe({ variant });
|
|
@@ -72,14 +79,14 @@ export const Stepper = forwardRef<HTMLDivElement, StepperProps>(
|
|
|
72
79
|
const hideBackButtonOnFirstStep = activeStep === 1 && !onBackButtonClick;
|
|
73
80
|
|
|
74
81
|
return (
|
|
75
|
-
<Box css={style.root} ref={ref}>
|
|
82
|
+
<Box css={{ ...style.root, ...css }} ref={ref}>
|
|
76
83
|
<StepperProvider
|
|
77
84
|
onClick={onClick}
|
|
78
85
|
activeStep={activeStep}
|
|
79
86
|
variant={variant}
|
|
80
87
|
numberOfSteps={numberOfSteps}
|
|
81
88
|
>
|
|
82
|
-
<Box css={style.container}>
|
|
89
|
+
<Box css={style.container} data-part="root">
|
|
83
90
|
<Box css={style.innerContainer}>
|
|
84
91
|
<Flex
|
|
85
92
|
justifyContent="space-between"
|
|
@@ -102,11 +109,16 @@ export const Stepper = forwardRef<HTMLDivElement, StepperProps>(
|
|
|
102
109
|
}}
|
|
103
110
|
/>
|
|
104
111
|
{heading && (
|
|
105
|
-
<Text
|
|
112
|
+
<Text
|
|
113
|
+
variant="sm"
|
|
114
|
+
as={headingLevel}
|
|
115
|
+
css={style.title}
|
|
116
|
+
data-part="title"
|
|
117
|
+
>
|
|
106
118
|
{heading}
|
|
107
119
|
</Text>
|
|
108
120
|
)}
|
|
109
|
-
<Box css={style.stepCounter}>
|
|
121
|
+
<Box css={style.stepCounter} data-part="step-counter">
|
|
110
122
|
{t(texts.stepsOf(activeStep, numberOfSteps))}
|
|
111
123
|
</Box>
|
|
112
124
|
</Flex>
|
|
@@ -33,7 +33,7 @@ export const StepperStep = ({
|
|
|
33
33
|
(state !== "active" && disabledOverride) || state === "disabled";
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<Box css={style.stepContainer}>
|
|
36
|
+
<Box css={style.stepContainer} data-part="step-container">
|
|
37
37
|
{stepNumber > 1 && (
|
|
38
38
|
<DropdownRightFill18Icon
|
|
39
39
|
marginX={5}
|
|
@@ -67,6 +67,7 @@ export const StepperStep = ({
|
|
|
67
67
|
: style.stepButton
|
|
68
68
|
}
|
|
69
69
|
fontWeight={state === "active" ? "bold" : undefined}
|
|
70
|
+
data-part="step-button"
|
|
70
71
|
>
|
|
71
72
|
{children}
|
|
72
73
|
</Button>
|