@vygruppen/spor-react 12.24.16 → 13.0.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 +2 -2
- package/CHANGELOG.md +24 -0
- package/dist/index.cjs +2753 -2646
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +887 -601
- package/dist/index.d.ts +887 -601
- package/dist/index.mjs +2712 -2605
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- 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 +149 -142
- 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/useFLoatingInputState.tsx +1 -1
- 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/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/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, {
|
|
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 =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
export const RadioCard = ({
|
|
42
|
+
ref,
|
|
43
|
+
...props
|
|
44
|
+
}: RadioCardItemProps & {
|
|
45
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
46
|
+
}) => {
|
|
47
|
+
const { inputProps, children } = props;
|
|
48
|
+
const uniqueId = useId();
|
|
49
|
+
const itemControlId = `radio-card-item-control-${uniqueId}`;
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const inputHasAriaLabel =
|
|
52
|
+
inputProps?.["aria-labelledby"] || inputProps?.["aria-label"];
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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 =
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
export const RadioCardGroup = ({
|
|
79
|
+
ref,
|
|
80
|
+
...props
|
|
81
|
+
}: RadioCardRootProps & {
|
|
82
|
+
ref?: React.Ref<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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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;
|
package/src/layout/Separator.tsx
CHANGED
|
@@ -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 =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export const Separator = ({
|
|
9
|
+
ref,
|
|
10
|
+
...props
|
|
11
|
+
}: ChakraSeparatorProps & {
|
|
12
|
+
ref?: React.Ref<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 =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
export const StaticCard = ({
|
|
47
|
+
ref,
|
|
48
|
+
...props
|
|
49
|
+
}: StaticCardProps & {
|
|
50
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
51
|
+
}) => {
|
|
52
|
+
const recipe = useRecipe({ key: "staticCard" });
|
|
53
|
+
const [recipeProps, restProps] = recipe.splitVariantProps(props);
|
|
54
|
+
const styles = recipe(recipeProps);
|
|
52
55
|
|
|
53
|
-
|
|
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 {
|
|
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 =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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.Ref<HTMLDivElement>;
|
|
78
|
+
}) {
|
|
79
|
+
const recipe = useSlotRecipe({ key: "lineIcon" });
|
|
80
|
+
const styles = recipe({ variant, size, ...rest });
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
const targetPadding = () => {
|
|
83
|
+
return target === "travelTag" ? 0.5 : 1;
|
|
84
|
+
};
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
86
|
+
const borderContainer = () => {
|
|
87
|
+
return variant === "walk" && target === "travelTag" ? 0 : "1px";
|
|
88
|
+
};
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
if (foregroundColor) {
|
|
91
|
+
styles.iconContainer.backgroundColor = disabled
|
|
92
|
+
? "surface.disabled"
|
|
93
|
+
: foregroundColor;
|
|
94
|
+
}
|
|
96
95
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
|
101
|
+
return "local-train";
|
|
105
102
|
}
|
|
103
|
+
return variant;
|
|
104
|
+
}
|
|
106
105
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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 {
|
|
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 =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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.Ref<HTMLDivElement>;
|
|
145
|
+
}) {
|
|
146
|
+
const recipie = useSlotRecipe({ key: "travelTag" });
|
|
147
|
+
const styles = recipie({
|
|
148
|
+
variant,
|
|
149
|
+
size,
|
|
150
|
+
deviationLevel,
|
|
151
|
+
});
|
|
153
152
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
{
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
+
};
|
package/src/link/TextLink.tsx
CHANGED
|
@@ -8,7 +8,12 @@ import {
|
|
|
8
8
|
LinkOutOutline18Icon,
|
|
9
9
|
LinkOutOutline24Icon,
|
|
10
10
|
} from "@vygruppen/spor-icon-react";
|
|
11
|
-
import 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 =
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
export const TextLink = ({
|
|
55
|
+
ref,
|
|
56
|
+
children,
|
|
57
|
+
external,
|
|
58
|
+
href,
|
|
59
|
+
...props
|
|
60
|
+
}: LinkProps & {
|
|
61
|
+
ref?: React.Ref<HTMLAnchorElement>;
|
|
62
|
+
}) => {
|
|
63
|
+
const { t } = useTranslation();
|
|
52
64
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
65
|
+
const isExternal =
|
|
66
|
+
external ??
|
|
67
|
+
Boolean(href?.startsWith("http://") || href?.startsWith("https://"));
|
|
56
68
|
|
|
57
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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, {
|
|
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 =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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.Ref<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
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
>
|
|
110
|
-
|
|
111
|
-
</Progress.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
+
};
|