@vygruppen/spor-react 12.24.16 → 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.
Files changed (84) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/.turbo/turbo-postinstall.log +4 -3
  3. package/CHANGELOG.md +18 -0
  4. package/dist/index.cjs +2753 -2646
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +887 -601
  7. package/dist/index.d.ts +887 -601
  8. package/dist/index.mjs +2712 -2605
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +8 -8
  11. package/src/accordion/Accordion.tsx +34 -29
  12. package/src/accordion/Expandable.tsx +20 -21
  13. package/src/alert/Alert.tsx +7 -5
  14. package/src/alert/AlertIcon.tsx +19 -20
  15. package/src/alert/ExpandableAlert.tsx +65 -64
  16. package/src/alert/ServiceAlert.tsx +78 -78
  17. package/src/breadcrumb/Breadcrumb.tsx +37 -34
  18. package/src/button/Button.tsx +64 -57
  19. package/src/button/ButtonGroup.tsx +12 -10
  20. package/src/button/Clipboard.tsx +21 -18
  21. package/src/button/CloseButton.tsx +19 -17
  22. package/src/button/FloatingActionButton.tsx +41 -47
  23. package/src/button/IconButton.tsx +20 -18
  24. package/src/calendar/CalendarContext.tsx +1 -1
  25. package/src/color-mode/color-mode.tsx +7 -5
  26. package/src/datepicker/CalendarTriggerButton.tsx +11 -7
  27. package/src/datepicker/DateField.tsx +53 -51
  28. package/src/datepicker/DatePicker.tsx +127 -134
  29. package/src/datepicker/DateTimeSegment.tsx +44 -40
  30. package/src/datepicker/StyledField.tsx +39 -36
  31. package/src/dialog/Dialog.tsx +14 -11
  32. package/src/dialog/Drawer.tsx +74 -67
  33. package/src/input/AttachedInputs.tsx +35 -41
  34. package/src/input/Autocomplete.tsx +118 -129
  35. package/src/input/CardSelect.tsx +67 -65
  36. package/src/input/Checkbox.tsx +19 -17
  37. package/src/input/CheckboxGroup.tsx +0 -2
  38. package/src/input/ChoiceChip.tsx +42 -38
  39. package/src/input/Combobox.tsx +4 -4
  40. package/src/input/CountryCodeSelect.tsx +8 -8
  41. package/src/input/Field.tsx +78 -75
  42. package/src/input/FloatingLabel.tsx +6 -8
  43. package/src/input/Input.tsx +87 -92
  44. package/src/input/ListBox.tsx +3 -4
  45. package/src/input/Menu.tsx +149 -142
  46. package/src/input/NativeSelect.tsx +7 -5
  47. package/src/input/NumericStepper.tsx +15 -12
  48. package/src/input/PasswordInput.tsx +65 -61
  49. package/src/input/PhoneNumberInput.tsx +7 -7
  50. package/src/input/Popover.tsx +52 -55
  51. package/src/input/Radio.tsx +16 -11
  52. package/src/input/SearchInput.tsx +32 -31
  53. package/src/input/Select.tsx +106 -96
  54. package/src/input/Switch.tsx +43 -41
  55. package/src/input/Textarea.tsx +68 -66
  56. package/src/layout/PressableCard.tsx +11 -10
  57. package/src/layout/RadioCard.tsx +57 -53
  58. package/src/layout/Separator.tsx +8 -7
  59. package/src/layout/StaticCard.tsx +11 -10
  60. package/src/linjetag/LineIcon.tsx +48 -54
  61. package/src/linjetag/TravelTag.tsx +57 -59
  62. package/src/link/TextLink.tsx +50 -40
  63. package/src/loader/ProgressBar.tsx +41 -46
  64. package/src/loader/ProgressLoader.tsx +83 -86
  65. package/src/loader/Skeleton.tsx +56 -48
  66. package/src/logo/CargonetLogo.tsx +88 -87
  67. package/src/logo/VyLogo.tsx +80 -77
  68. package/src/logo/VyLogoPride.tsx +137 -135
  69. package/src/media-controller/JumpButton.tsx +30 -28
  70. package/src/media-controller/PlayPauseButton.tsx +8 -7
  71. package/src/media-controller/SkipButton.tsx +28 -26
  72. package/src/nudge/Nudge.tsx +66 -70
  73. package/src/pagination/Pagination.tsx +52 -46
  74. package/src/popover/index.tsx +46 -41
  75. package/src/progress-indicator/ProgressIndicator.tsx +10 -7
  76. package/src/stepper/Stepper.tsx +84 -81
  77. package/src/tab/Tabs.tsx +8 -4
  78. package/src/table/Table.tsx +89 -109
  79. package/src/tooltip.tsx +26 -22
  80. package/src/typography/Badge.tsx +8 -5
  81. package/src/typography/Code.tsx +8 -5
  82. package/src/typography/Heading.tsx +22 -23
  83. package/src/typography/Text.tsx +11 -9
  84. package/tsconfig.json +1 -0
@@ -4,7 +4,7 @@ import {
4
4
  RecipeVariantProps,
5
5
  useSlotRecipe,
6
6
  } from "@chakra-ui/react";
7
- import React, { forwardRef, useId } from "react";
7
+ import React, { useId } from "react";
8
8
 
9
9
  import { radioCardSlotRecipe } from "../theme/slot-recipes/radio-card";
10
10
 
@@ -38,32 +38,34 @@ type RadioCardItemProps = Exclude<
38
38
  ariaLabel?: string;
39
39
  };
40
40
 
41
- export const RadioCard = forwardRef<HTMLInputElement, RadioCardItemProps>(
42
- (props, ref) => {
43
- const { inputProps, children } = props;
44
- const uniqueId = useId();
45
- const itemControlId = `radio-card-item-control-${uniqueId}`;
41
+ export const RadioCard = ({
42
+ ref,
43
+ ...props
44
+ }: RadioCardItemProps & {
45
+ ref?: React.RefObject<HTMLInputElement>;
46
+ }) => {
47
+ const { inputProps, children } = props;
48
+ const uniqueId = useId();
49
+ const itemControlId = `radio-card-item-control-${uniqueId}`;
46
50
 
47
- const inputHasAriaLabel =
48
- inputProps?.["aria-labelledby"] || inputProps?.["aria-label"];
51
+ const inputHasAriaLabel =
52
+ inputProps?.["aria-labelledby"] || inputProps?.["aria-label"];
49
53
 
50
- return (
51
- <ChakraRadioCard.Item {...props}>
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>
62
- </ChakraRadioCard.Item>
63
- );
64
- },
65
- );
66
- RadioCard.displayName = "RadioCard";
54
+ return (
55
+ <ChakraRadioCard.Item {...props}>
56
+ <ChakraRadioCard.ItemHiddenInput
57
+ aria-labelledby={
58
+ inputHasAriaLabel ? inputProps?.["aria-labelledby"] : itemControlId
59
+ }
60
+ ref={ref}
61
+ {...inputProps}
62
+ />
63
+ <ChakraRadioCard.ItemControl id={itemControlId} aria-hidden>
64
+ {children}
65
+ </ChakraRadioCard.ItemControl>
66
+ </ChakraRadioCard.Item>
67
+ );
68
+ };
67
69
 
68
70
  type RadioCardRootProps = RadioCardVariantProps &
69
71
  Exclude<ChakraRadioCard.RootProps, "variant"> & {
@@ -73,34 +75,36 @@ type RadioCardRootProps = RadioCardVariantProps &
73
75
  display?: string;
74
76
  };
75
77
 
76
- export const RadioCardGroup = forwardRef<HTMLDivElement, RadioCardRootProps>(
77
- (props, ref) => {
78
- const {
79
- children,
80
- variant,
81
- gap = 2,
82
- direction = "column",
83
- display = "flex",
84
- ...rest
85
- } = props;
86
- const recipe = useSlotRecipe({ key: "radio-card" });
87
- const styles = recipe({ variant });
78
+ export const RadioCardGroup = ({
79
+ ref,
80
+ ...props
81
+ }: RadioCardRootProps & {
82
+ ref?: React.RefObject<HTMLDivElement>;
83
+ }) => {
84
+ const {
85
+ children,
86
+ variant,
87
+ gap = 2,
88
+ direction = "column",
89
+ display = "flex",
90
+ ...rest
91
+ } = props;
92
+ const recipe = useSlotRecipe({ key: "radio-card" });
93
+ const styles = recipe({ variant });
88
94
 
89
- return (
90
- <ChakraRadioCard.Root
91
- ref={ref}
92
- variant={variant}
93
- css={styles}
94
- display={display}
95
- gap={gap}
96
- flexDirection={direction}
97
- {...rest}
98
- >
99
- {children}
100
- </ChakraRadioCard.Root>
101
- );
102
- },
103
- );
104
- RadioCardGroup.displayName = "RadioCardGroup";
95
+ return (
96
+ <ChakraRadioCard.Root
97
+ ref={ref}
98
+ variant={variant}
99
+ css={styles}
100
+ display={display}
101
+ gap={gap}
102
+ flexDirection={direction}
103
+ {...rest}
104
+ >
105
+ {children}
106
+ </ChakraRadioCard.Root>
107
+ );
108
+ };
105
109
 
106
110
  export const RadioCardLabel = ChakraRadioCard.Label;
@@ -4,11 +4,12 @@ import {
4
4
  Separator as ChakraSeparator,
5
5
  SeparatorProps as ChakraSeparatorProps,
6
6
  } from "@chakra-ui/react";
7
- import { forwardRef } from "react";
8
7
 
9
- export const Separator = forwardRef<HTMLDivElement, ChakraSeparatorProps>(
10
- (props, ref) => {
11
- return <ChakraSeparator {...props} ref={ref} data- />;
12
- },
13
- );
14
- Separator.displayName = "Separator";
8
+ export const Separator = ({
9
+ ref,
10
+ ...props
11
+ }: ChakraSeparatorProps & {
12
+ ref?: React.RefObject<HTMLDivElement>;
13
+ }) => {
14
+ return <ChakraSeparator {...props} ref={ref} data- />;
15
+ };
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { Box, BoxProps, RecipeVariantProps, useRecipe } from "@chakra-ui/react";
3
- import { forwardRef } from "react";
4
3
 
5
4
  import { staticCardRecipe } from "../theme/recipes/static-card";
6
5
 
@@ -44,13 +43,15 @@ import { staticCardRecipe } from "../theme/recipes/static-card";
44
43
  export type StaticCardProps = RecipeVariantProps<typeof staticCardRecipe> &
45
44
  BoxProps;
46
45
 
47
- export const StaticCard = forwardRef<HTMLDivElement, StaticCardProps>(
48
- (props, ref) => {
49
- const recipe = useRecipe({ key: "staticCard" });
50
- const [recipeProps, restProps] = recipe.splitVariantProps(props);
51
- const styles = recipe(recipeProps);
46
+ export const StaticCard = ({
47
+ ref,
48
+ ...props
49
+ }: StaticCardProps & {
50
+ ref?: React.RefObject<HTMLDivElement>;
51
+ }) => {
52
+ const recipe = useRecipe({ key: "staticCard" });
53
+ const [recipeProps, restProps] = recipe.splitVariantProps(props);
54
+ const styles = recipe(recipeProps);
52
55
 
53
- return <Box css={styles} {...restProps} ref={ref}></Box>;
54
- },
55
- );
56
- StaticCard.displayName = "StaticCard";
56
+ return <Box css={styles} {...restProps} ref={ref}></Box>;
57
+ };
@@ -6,7 +6,7 @@ import {
6
6
  useSlotRecipe,
7
7
  } from "@chakra-ui/react";
8
8
  import clsx from "clsx";
9
- import { forwardRef, PropsWithChildren } from "react";
9
+ import { PropsWithChildren } from "react";
10
10
 
11
11
  import { lineIconSlotRecipe } from "../theme/slot-recipes/line-icon";
12
12
  import { LinjeTagIcon } from "./icons";
@@ -63,63 +63,57 @@ export type LineIconProps = Exclude<BoxProps, "variant"> &
63
63
  * @see https://spor.vy.no/components/line-tags
64
64
  */
65
65
 
66
- export const LineIcon = forwardRef<HTMLDivElement, LineIconProps>(
67
- function LineIcon(
68
- {
69
- variant,
70
- size = "md",
71
- foregroundColor,
72
- disabled,
73
- style,
74
- target = "lineIcon",
75
- label,
76
- ...rest
77
- },
78
- ref,
79
- ) {
80
- const recipe = useSlotRecipe({ key: "lineIcon" });
81
- const styles = recipe({ variant, size, ...rest });
66
+ export const LineIcon = function LineIcon({
67
+ ref,
68
+ variant,
69
+ size = "md",
70
+ foregroundColor,
71
+ disabled,
72
+ style,
73
+ target = "lineIcon",
74
+ label,
75
+ ...rest
76
+ }: LineIconProps & {
77
+ ref?: React.RefObject<HTMLDivElement>;
78
+ }) {
79
+ const recipe = useSlotRecipe({ key: "lineIcon" });
80
+ const styles = recipe({ variant, size, ...rest });
82
81
 
83
- const targetPadding = () => {
84
- return target === "travelTag" ? 0.5 : 1;
85
- };
82
+ const targetPadding = () => {
83
+ return target === "travelTag" ? 0.5 : 1;
84
+ };
86
85
 
87
- const borderContainer = () => {
88
- return variant === "walk" && target === "travelTag" ? 0 : "1px";
89
- };
86
+ const borderContainer = () => {
87
+ return variant === "walk" && target === "travelTag" ? 0 : "1px";
88
+ };
90
89
 
91
- if (foregroundColor) {
92
- styles.iconContainer.backgroundColor = disabled
93
- ? "surface.disabled"
94
- : foregroundColor;
95
- }
90
+ if (foregroundColor) {
91
+ styles.iconContainer.backgroundColor = disabled
92
+ ? "surface.disabled"
93
+ : foregroundColor;
94
+ }
96
95
 
97
- function getIconVariant() {
98
- if (variant === "custom") {
99
- if ("customIconVariant" in rest) {
100
- return rest.customIconVariant;
101
- }
102
- return "local-train";
96
+ function getIconVariant() {
97
+ if (variant === "custom") {
98
+ if ("customIconVariant" in rest) {
99
+ return rest.customIconVariant;
103
100
  }
104
- return variant;
101
+ return "local-train";
105
102
  }
103
+ return variant;
104
+ }
106
105
 
107
- return (
108
- <Box
109
- css={{ ...styles.iconContainer, ...style }}
110
- padding={targetPadding()}
111
- borderWidth={borderContainer()}
112
- borderColor={variant === "walk" ? "core.outline" : "transparent"}
113
- aria-label={label}
114
- ref={ref}
115
- className={clsx("light", rest.className)}
116
- >
117
- <LinjeTagIcon
118
- size={size}
119
- css={styles.icon}
120
- variant={getIconVariant()}
121
- />
122
- </Box>
123
- );
124
- },
125
- );
106
+ return (
107
+ <Box
108
+ css={{ ...styles.iconContainer, ...style }}
109
+ padding={targetPadding()}
110
+ borderWidth={borderContainer()}
111
+ borderColor={variant === "walk" ? "core.outline" : "transparent"}
112
+ aria-label={label}
113
+ ref={ref}
114
+ className={clsx("light", rest.className)}
115
+ >
116
+ <LinjeTagIcon size={size} css={styles.icon} variant={getIconVariant()} />
117
+ </Box>
118
+ );
119
+ };
@@ -15,7 +15,7 @@ import {
15
15
  WarningFill24Icon,
16
16
  } from "@vygruppen/spor-icon-react";
17
17
  import clsx from "clsx";
18
- import { forwardRef, PropsWithChildren } from "react";
18
+ import { PropsWithChildren } from "react";
19
19
 
20
20
  import { travelTagSlotRecipe } from "../theme/slot-recipes/travel-tag";
21
21
  import { LineIcon } from "./LineIcon";
@@ -128,64 +128,62 @@ function renderDeviationLevelIcon(
128
128
  }
129
129
  }
130
130
 
131
- export const TravelTag = forwardRef<HTMLDivElement, TravelTagProps>(
132
- function TravelTag(
133
- {
134
- variant,
135
- size = "md",
136
- deviationLevel = "none",
137
- title,
138
- description,
139
- disabled,
140
- foregroundColor,
141
- backgroundColor,
142
- customIconVariant,
143
- ...rest
144
- },
145
- ref,
146
- ) {
147
- const recipie = useSlotRecipe({ key: "travelTag" });
148
- const styles = recipie({
149
- variant,
150
- size,
151
- deviationLevel,
152
- });
131
+ export const TravelTag = function TravelTag({
132
+ ref,
133
+ variant,
134
+ size = "md",
135
+ deviationLevel = "none",
136
+ title,
137
+ description,
138
+ disabled,
139
+ foregroundColor,
140
+ backgroundColor,
141
+ customIconVariant,
142
+ ...rest
143
+ }: TravelTagProps & {
144
+ ref?: React.RefObject<HTMLDivElement>;
145
+ }) {
146
+ const recipie = useSlotRecipe({ key: "travelTag" });
147
+ const styles = recipie({
148
+ variant,
149
+ size,
150
+ deviationLevel,
151
+ });
153
152
 
154
- return (
155
- <Box
156
- css={styles.container}
157
- aria-disabled={disabled}
158
- ref={ref}
159
- className={clsx("light", rest.className)}
153
+ return (
154
+ <Box
155
+ css={styles.container}
156
+ aria-disabled={disabled}
157
+ ref={ref}
158
+ className={clsx("light", rest.className)}
159
+ backgroundColor={backgroundColor}
160
+ {...rest}
161
+ >
162
+ <LineIcon
163
+ variant={variant}
164
+ size={size}
165
+ foregroundColor={foregroundColor}
160
166
  backgroundColor={backgroundColor}
161
- {...rest}
162
- >
163
- <LineIcon
164
- variant={variant}
165
- size={size}
166
- foregroundColor={foregroundColor}
167
- backgroundColor={backgroundColor}
168
- customIconVariant={customIconVariant}
169
- disabled={disabled}
170
- target="travelTag"
171
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
172
- {...(rest as any)} //Find a way to not use any here
173
- />
174
- <Box css={styles.textContainer}>
175
- {title && (
176
- <Box as="span" css={styles.title}>
177
- {title}
178
- </Box>
179
- )}
180
- {title && description && " "}
181
- {description && (
182
- <Box as="span" css={styles.description}>
183
- {description}
184
- </Box>
185
- )}
186
- </Box>
187
- {renderDeviationLevelIcon(deviationLevel, size, styles.deviationIcon)}
167
+ customIconVariant={customIconVariant}
168
+ disabled={disabled}
169
+ target="travelTag"
170
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
171
+ {...(rest as any)} //Find a way to not use any here
172
+ />
173
+ <Box css={styles.textContainer}>
174
+ {title && (
175
+ <Box as="span" css={styles.title}>
176
+ {title}
177
+ </Box>
178
+ )}
179
+ {title && description && " "}
180
+ {description && (
181
+ <Box as="span" css={styles.description}>
182
+ {description}
183
+ </Box>
184
+ )}
188
185
  </Box>
189
- );
190
- },
191
- );
186
+ {renderDeviationLevelIcon(deviationLevel, size, styles.deviationIcon)}
187
+ </Box>
188
+ );
189
+ };
@@ -8,7 +8,12 @@ import {
8
8
  LinkOutOutline18Icon,
9
9
  LinkOutOutline24Icon,
10
10
  } from "@vygruppen/spor-icon-react";
11
- import React, { cloneElement, forwardRef, isValidElement } from "react";
11
+ import React, {
12
+ cloneElement,
13
+ isValidElement,
14
+ PropsWithChildren,
15
+ ReactNode,
16
+ } from "react";
12
17
 
13
18
  import { createTexts, useTranslation } from "@/i18n";
14
19
 
@@ -46,43 +51,25 @@ const ExternalIcon = ({
46
51
  </>
47
52
  );
48
53
 
49
- export const TextLink = forwardRef<HTMLAnchorElement, LinkProps>(
50
- ({ children, external, href, ...props }, ref) => {
51
- const { t } = useTranslation();
54
+ export const TextLink = ({
55
+ ref,
56
+ children,
57
+ external,
58
+ href,
59
+ ...props
60
+ }: LinkProps & {
61
+ ref?: React.RefObject<HTMLAnchorElement>;
62
+ }) => {
63
+ const { t } = useTranslation();
52
64
 
53
- const isExternal =
54
- external ??
55
- Boolean(href?.startsWith("http://") || href?.startsWith("https://"));
65
+ const isExternal =
66
+ external ??
67
+ Boolean(href?.startsWith("http://") || href?.startsWith("https://"));
56
68
 
57
- const externalLabel = t ? t(texts.externalLink) : texts.externalLink.en;
58
-
59
- // If asChild is true, we need to clone the children and add the external icon
60
- if (props.asChild && isValidElement(children)) {
61
- return (
62
- <ChakraLink
63
- href={href}
64
- {...props}
65
- ref={ref}
66
- {...(isExternal && {
67
- target: "_blank",
68
- rel: "noopener noreferrer",
69
- })}
70
- >
71
- {cloneElement(children as React.ReactElement, {
72
- ...children.props,
73
- children: (
74
- <>
75
- {children.props.children}
76
- {isExternal && (
77
- <ExternalIcon label={externalLabel} size={props.size} />
78
- )}
79
- </>
80
- ),
81
- })}
82
- </ChakraLink>
83
- );
84
- }
69
+ const externalLabel = t ? t(texts.externalLink) : texts.externalLink.en;
85
70
 
71
+ // If asChild is true, we need to clone the children and add the external icon
72
+ if (props.asChild && isValidElement(children)) {
86
73
  return (
87
74
  <ChakraLink
88
75
  href={href}
@@ -93,13 +80,36 @@ export const TextLink = forwardRef<HTMLAnchorElement, LinkProps>(
93
80
  rel: "noopener noreferrer",
94
81
  })}
95
82
  >
96
- {children}
97
- {isExternal && <ExternalIcon label={externalLabel} size={props.size} />}
83
+ {cloneElement(children as React.ReactElement<{ children: ReactNode }>, {
84
+ ...(children.props as object),
85
+ children: (
86
+ <>
87
+ {(children.props as PropsWithChildren).children}
88
+ {isExternal && (
89
+ <ExternalIcon label={externalLabel} size={props.size} />
90
+ )}
91
+ </>
92
+ ),
93
+ })}
98
94
  </ChakraLink>
99
95
  );
100
- },
101
- );
102
- TextLink.displayName = "TextLink";
96
+ }
97
+
98
+ return (
99
+ <ChakraLink
100
+ href={href}
101
+ {...props}
102
+ ref={ref}
103
+ {...(isExternal && {
104
+ target: "_blank",
105
+ rel: "noopener noreferrer",
106
+ })}
107
+ >
108
+ {children}
109
+ {isExternal && <ExternalIcon label={externalLabel} size={props.size} />}
110
+ </ChakraLink>
111
+ );
112
+ };
103
113
 
104
114
  const texts = createTexts({
105
115
  externalLink: {
@@ -6,7 +6,7 @@ import {
6
6
  UseProgressProps,
7
7
  useSlotRecipe,
8
8
  } from "@chakra-ui/react";
9
- import React, { forwardRef, PropsWithChildren } from "react";
9
+ import React, { PropsWithChildren } from "react";
10
10
 
11
11
  import { progressBarRecipe } from "../theme/slot-recipes/progress-bar";
12
12
  import { useRotatingLabel } from "./useRotatingLabel";
@@ -75,50 +75,45 @@ export type ProgressBarProps = BoxProps &
75
75
  * ```
76
76
  */
77
77
 
78
- export const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
79
- (
80
- {
81
- value,
82
- label,
83
- labelRotationDelay = 5000,
84
- isActive = true,
85
- showValueText = false,
86
- height = "0.5rem",
87
- css,
88
- ...rest
89
- },
90
- ref,
91
- ) => {
92
- const recipe = useSlotRecipe({ key: "progressbar" });
93
- const styles = recipe({});
94
- const currentLoadingText = useRotatingLabel({
95
- label,
96
- delay: labelRotationDelay,
97
- });
78
+ export const ProgressBar = ({
79
+ ref,
80
+ value,
81
+ label,
82
+ labelRotationDelay = 5000,
83
+ isActive = true,
84
+ showValueText = false,
85
+ height = "0.5rem",
86
+ css,
87
+ ...rest
88
+ }: ProgressBarProps & {
89
+ ref?: React.RefObject<HTMLDivElement>;
90
+ }) => {
91
+ const recipe = useSlotRecipe({ key: "progressbar" });
92
+ const styles = recipe({});
93
+ const currentLoadingText = useRotatingLabel({
94
+ label,
95
+ delay: labelRotationDelay,
96
+ });
98
97
 
99
- return (
100
- <Progress.Root
101
- css={{ ...styles.container, ...css }}
102
- ref={ref}
103
- value={value}
104
- {...rest}
98
+ return (
99
+ <Progress.Root
100
+ css={{ ...styles.container, ...css }}
101
+ ref={ref}
102
+ value={value}
103
+ {...rest}
104
+ >
105
+ <Progress.Track
106
+ height={height}
107
+ css={isActive ? styles.background : styles.disabledBackground}
105
108
  >
106
- <Progress.Track
107
- height={height}
108
- css={isActive ? styles.background : styles.disabledBackground}
109
- >
110
- <Progress.Range css={styles.progress} />
111
- </Progress.Track>
112
-
113
- {label && (
114
- <Progress.Label css={styles.description}>
115
- {currentLoadingText}
116
- </Progress.Label>
117
- )}
118
-
119
- {showValueText && <Progress.ValueText>{value}%</Progress.ValueText>}
120
- </Progress.Root>
121
- );
122
- },
123
- );
124
- ProgressBar.displayName = "ProgressBar";
109
+ <Progress.Range css={styles.progress} />
110
+ </Progress.Track>
111
+ {label && (
112
+ <Progress.Label css={styles.description}>
113
+ {currentLoadingText}
114
+ </Progress.Label>
115
+ )}
116
+ {showValueText && <Progress.ValueText>{value}%</Progress.ValueText>}
117
+ </Progress.Root>
118
+ );
119
+ };