@vygruppen/spor-react 12.1.1 → 12.2.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 +11 -11
- package/.turbo/turbo-typegen.log +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +151 -190
- package/dist/index.d.ts +151 -190
- package/dist/index.js +2327 -1915
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2214 -1811
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/accordion/Accordion.tsx +2 -1
- package/src/accordion/Expandable.tsx +3 -1
- package/src/accordion/helpers.ts +2 -1
- package/src/alert/Alert.tsx +3 -1
- package/src/alert/AlertIcon.tsx +17 -10
- package/src/alert/ExpandableAlert.tsx +3 -2
- package/src/alert/ServiceAlert.tsx +2 -1
- package/src/breadcrumb/Breadcrumb.tsx +9 -8
- package/src/button/Button.tsx +65 -52
- package/src/button/ButtonGroup.tsx +2 -1
- package/src/button/Clipboard.tsx +3 -0
- package/src/button/CloseButton.tsx +8 -4
- package/src/button/FloatingActionButton.tsx +5 -5
- package/src/button/IconButton.tsx +1 -0
- package/src/color-mode/color-mode.tsx +2 -2
- package/src/datepicker/Calendar.tsx +0 -1
- package/src/datepicker/CalendarCell.tsx +5 -5
- package/src/datepicker/CalendarGrid.tsx +3 -2
- package/src/datepicker/CalendarHeader.tsx +1 -4
- package/src/datepicker/CalendarTriggerButton.tsx +3 -4
- package/src/datepicker/DateField.tsx +13 -6
- package/src/datepicker/DatePicker.tsx +2 -1
- package/src/datepicker/DateRangePicker.tsx +1 -1
- package/src/datepicker/DateTimeSegment.tsx +2 -1
- package/src/datepicker/RangeCalendar.tsx +1 -1
- package/src/datepicker/StyledField.tsx +1 -1
- package/src/datepicker/TimeField.tsx +3 -3
- package/src/datepicker/TimePicker.tsx +4 -2
- package/src/datepicker/utils.ts +10 -5
- package/src/dialog/Dialog.tsx +1 -0
- package/src/dialog/Drawer.tsx +28 -26
- package/src/i18n/index.tsx +1 -0
- package/src/input/AttachedInputs.tsx +6 -3
- package/src/input/CardSelect.tsx +3 -1
- package/src/input/Checkbox.tsx +1 -0
- package/src/input/CheckboxGroup.tsx +3 -1
- package/src/input/ChoiceChip.tsx +1 -1
- package/src/input/Combobox.tsx +6 -4
- package/src/input/CountryCodeSelect.tsx +10 -4
- package/src/input/Field.tsx +2 -0
- package/src/input/Input.tsx +2 -3
- package/src/input/InputGroup.tsx +1 -1
- package/src/input/ListBox.tsx +9 -8
- package/src/input/NativeSelect.tsx +1 -2
- package/src/input/NumericStepper.tsx +22 -23
- package/src/input/PasswordInput.tsx +2 -1
- package/src/input/PhoneNumberInput.tsx +6 -2
- package/src/input/Popover.tsx +2 -0
- package/src/input/Radio.tsx +2 -0
- package/src/input/SearchInput.tsx +2 -1
- package/src/input/Select.tsx +8 -2
- package/src/input/Switch.tsx +22 -34
- package/src/input/Textarea.tsx +6 -4
- package/src/input/index.ts +1 -1
- package/src/layout/PressableCard.tsx +5 -2
- package/src/layout/RadioCard.tsx +3 -1
- package/src/layout/Separator.tsx +2 -1
- package/src/layout/StaticCard.tsx +6 -3
- package/src/linjetag/InfoTag.tsx +3 -2
- package/src/linjetag/LineIcon.tsx +5 -4
- package/src/linjetag/TravelTag.tsx +12 -8
- package/src/link/TextLink.tsx +44 -9
- package/src/loader/ColorInlineLoader.tsx +0 -1
- package/src/loader/ColorSpinner.tsx +0 -1
- package/src/loader/ContentLoader.tsx +0 -1
- package/src/loader/DarkFullScreenLoader.tsx +0 -1
- package/src/loader/DarkInlineLoader.tsx +0 -1
- package/src/loader/DarkSpinner.tsx +0 -1
- package/src/loader/LightFullScreenLoader.tsx +0 -1
- package/src/loader/LightInlineLoader.tsx +0 -1
- package/src/loader/LightSpinner.tsx +0 -1
- package/src/loader/Lottie.tsx +1 -2
- package/src/loader/ProgressBar.tsx +1 -2
- package/src/loader/ProgressLoader.tsx +2 -7
- package/src/logo/CargonetLogo.tsx +2 -1
- package/src/logo/VyLogo.tsx +3 -4
- package/src/logo/VyLogoPride.tsx +4 -1
- package/src/media-controller/JumpButton.tsx +2 -1
- package/src/media-controller/PlayPauseButton.tsx +2 -1
- package/src/media-controller/SkipButton.tsx +2 -1
- package/src/nudge/Nudge.tsx +7 -14
- package/src/pagination/Pagination.tsx +5 -0
- package/src/popover/index.tsx +2 -0
- package/src/progress-indicator/ProgressDot.tsx +1 -1
- package/src/progress-indicator/ProgressIndicator.tsx +4 -2
- package/src/provider/SporProvider.tsx +0 -1
- package/src/stepper/Stepper.tsx +1 -1
- package/src/tab/Tabs.tsx +1 -1
- package/src/table/Table.tsx +2 -1
- package/src/theme/recipes/button.ts +5 -0
- package/src/theme/slot-recipes/alert-expandable.ts +0 -4
- package/src/theme/slot-recipes/info-tag.ts +0 -1
- package/src/theme/slot-recipes/popover.ts +0 -1
- package/src/theme/slot-recipes/radio-card.ts +0 -3
- package/src/theme/utils/accent-utils.ts +12 -6
- package/src/theme/utils/bg-utils.ts +6 -3
- package/src/theme/utils/brand-utils.ts +7 -7
- package/src/theme/utils/core-utils.ts +23 -13
- package/src/theme/utils/floating-utils.ts +16 -8
- package/src/theme/utils/ghost-utils.ts +8 -4
- package/src/theme/utils/input-utils.ts +7 -4
- package/src/theme/utils/outline-utils.ts +6 -3
- package/src/theme/utils/surface-utils.ts +8 -4
- package/src/toast/toast.tsx +0 -1
- package/src/typography/Badge.tsx +8 -5
- package/src/typography/Heading.tsx +1 -1
- package/src/typography/Text.tsx +1 -1
- package/src/util/slugify.tsx +8 -8
- package/tsconfig.json +1 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { useControllableState } from "@chakra-ui/react";
|
3
|
-
import
|
3
|
+
import { forwardRef } from "react";
|
4
4
|
|
5
5
|
import { createTexts, Input, InputProps, useTranslation } from "..";
|
6
6
|
import { AttachedInputs } from "./AttachedInputs";
|
@@ -20,6 +20,7 @@ type PhoneNumberInputProps = InputProps & {
|
|
20
20
|
value?: CountryCodeAndPhoneNumber;
|
21
21
|
/** Returns an extra optional text when true */
|
22
22
|
optional?: boolean;
|
23
|
+
allowedCountryCodes?: string[];
|
23
24
|
invalid?: boolean;
|
24
25
|
errorText?: string;
|
25
26
|
};
|
@@ -51,6 +52,7 @@ export const PhoneNumberInput = forwardRef<
|
|
51
52
|
onValueChange: externalOnChange,
|
52
53
|
variant,
|
53
54
|
optional,
|
55
|
+
allowedCountryCodes,
|
54
56
|
invalid,
|
55
57
|
errorText,
|
56
58
|
} = props;
|
@@ -92,6 +94,7 @@ export const PhoneNumberInput = forwardRef<
|
|
92
94
|
height="100%"
|
93
95
|
width="6.25rem"
|
94
96
|
variant={variant}
|
97
|
+
allowedCountryCodes={allowedCountryCodes}
|
95
98
|
data-state="on"
|
96
99
|
/>
|
97
100
|
<Input
|
@@ -103,7 +106,7 @@ export const PhoneNumberInput = forwardRef<
|
|
103
106
|
onChange={(e) => {
|
104
107
|
const target = e.target as HTMLInputElement;
|
105
108
|
// Removes everything but numbers, spaces and dashes
|
106
|
-
const strippedValue = target.value.
|
109
|
+
const strippedValue = target.value.replaceAll(/[^\d\s-]/g, "");
|
107
110
|
onChange({
|
108
111
|
countryCode: value.countryCode,
|
109
112
|
nationalNumber: strippedValue,
|
@@ -118,6 +121,7 @@ export const PhoneNumberInput = forwardRef<
|
|
118
121
|
</AttachedInputs>
|
119
122
|
);
|
120
123
|
});
|
124
|
+
PhoneNumberInput.displayName = "PhoneNumberInput";
|
121
125
|
|
122
126
|
const texts = createTexts({
|
123
127
|
phoneNumber: {
|
package/src/input/Popover.tsx
CHANGED
@@ -73,6 +73,7 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
73
73
|
ref,
|
74
74
|
) => {
|
75
75
|
const internalRef = useRef<HTMLDivElement>(null);
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
76
77
|
const popoverRef = ref ?? (internalRef as any);
|
77
78
|
|
78
79
|
const { popoverProps, underlayProps } = usePopover(
|
@@ -112,3 +113,4 @@ export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
|
112
113
|
);
|
113
114
|
},
|
114
115
|
);
|
116
|
+
Popover.displayName = "Popover";
|
package/src/input/Radio.tsx
CHANGED
@@ -41,6 +41,7 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
|
|
41
41
|
</ChakraRadioGroup.Item>
|
42
42
|
);
|
43
43
|
});
|
44
|
+
Radio.displayName = "Radio";
|
44
45
|
|
45
46
|
type RadioGroupProps = Omit<
|
46
47
|
ChakraRadioGroup.RootProps,
|
@@ -52,3 +53,4 @@ export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
|
|
52
53
|
return <ChakraRadioGroup.Root ref={ref} {...props} aria-labelledby="" />;
|
53
54
|
},
|
54
55
|
);
|
56
|
+
RadioGroup.displayName = "RadioGroup";
|
@@ -4,7 +4,7 @@ import {
|
|
4
4
|
CloseOutline24Icon,
|
5
5
|
SearchOutline24Icon,
|
6
6
|
} from "@vygruppen/spor-icon-react";
|
7
|
-
import
|
7
|
+
import { forwardRef } from "react";
|
8
8
|
|
9
9
|
import { createTexts, Input, InputProps, useTranslation } from "..";
|
10
10
|
import { IconButton } from "../button/IconButton";
|
@@ -49,6 +49,7 @@ export const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
|
|
49
49
|
);
|
50
50
|
},
|
51
51
|
);
|
52
|
+
SearchInput.displayName = "SearchInput";
|
52
53
|
|
53
54
|
const texts = createTexts({
|
54
55
|
label: {
|
package/src/input/Select.tsx
CHANGED
@@ -80,6 +80,7 @@ export const Select = React.forwardRef<HTMLDivElement, SelectProps>(
|
|
80
80
|
);
|
81
81
|
},
|
82
82
|
);
|
83
|
+
Select.displayName = "Select";
|
83
84
|
|
84
85
|
type SelectItemProps = ChakraSelect.ItemProps &
|
85
86
|
React.PropsWithChildren<SelectVariantProps> & {
|
@@ -108,6 +109,7 @@ export const SelectItem = React.forwardRef<HTMLDivElement, SelectItemProps>(
|
|
108
109
|
);
|
109
110
|
},
|
110
111
|
);
|
112
|
+
SelectItem.displayName = "SelectItem";
|
111
113
|
|
112
114
|
type SelectItemGroupProps = ChakraSelect.ItemGroupProps &
|
113
115
|
React.PropsWithChildren<SelectVariantProps> & {
|
@@ -218,8 +220,12 @@ export const SelectValueText = React.forwardRef<
|
|
218
220
|
>
|
219
221
|
<ChakraSelect.Context>
|
220
222
|
{(select: {
|
221
|
-
selectedItems:
|
222
|
-
|
223
|
+
selectedItems: CollectionItem[];
|
224
|
+
|
225
|
+
collection: {
|
226
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
227
|
+
stringifyItem: (arg0: any) => any;
|
228
|
+
} /* Find a way to not use any */;
|
223
229
|
}) => {
|
224
230
|
const items = select.selectedItems;
|
225
231
|
if (items.length === 0) return placeholder;
|
package/src/input/Switch.tsx
CHANGED
@@ -44,38 +44,26 @@ export type SwitchProps = Exclude<
|
|
44
44
|
* ```
|
45
45
|
*/
|
46
46
|
|
47
|
-
export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
children,
|
52
|
-
rootRef,
|
53
|
-
trackLabel,
|
54
|
-
thumbLabel,
|
55
|
-
size = "md",
|
56
|
-
label,
|
57
|
-
onCheckedChange,
|
58
|
-
...rest
|
59
|
-
} = props;
|
47
|
+
export const Switch = forwardRef<HTMLInputElement, SwitchProps>((props) => {
|
48
|
+
const { rootRef, size = "md", label, ...rest } = props;
|
49
|
+
const recipe = useSlotRecipe({ key: "switch" });
|
50
|
+
const styles = recipe({ size });
|
60
51
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
>
|
72
|
-
<ChakraSwitch.
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
);
|
80
|
-
},
|
81
|
-
);
|
52
|
+
return (
|
53
|
+
<Field style={{ width: "auto" }}>
|
54
|
+
<ChakraSwitch.Root
|
55
|
+
ref={rootRef}
|
56
|
+
{...rest}
|
57
|
+
checked={props.checked}
|
58
|
+
css={styles.root}
|
59
|
+
>
|
60
|
+
<ChakraSwitch.Label>{label}</ChakraSwitch.Label>
|
61
|
+
<ChakraSwitch.HiddenInput />
|
62
|
+
<ChakraSwitch.Control css={styles.control}>
|
63
|
+
<ChakraSwitch.Thumb />
|
64
|
+
</ChakraSwitch.Control>
|
65
|
+
</ChakraSwitch.Root>
|
66
|
+
</Field>
|
67
|
+
);
|
68
|
+
});
|
69
|
+
Switch.displayName = "Switch";
|
package/src/input/Textarea.tsx
CHANGED
@@ -44,16 +44,17 @@ const useLabelHeight = (label: ReactNode | undefined) => {
|
|
44
44
|
};
|
45
45
|
|
46
46
|
const observer = new ResizeObserver(updateLabelHeight);
|
47
|
-
|
48
|
-
|
47
|
+
const currentLabelRef = labelRef.current;
|
48
|
+
if (currentLabelRef) {
|
49
|
+
observer.observe(currentLabelRef);
|
49
50
|
}
|
50
51
|
|
51
52
|
// Initial calculation with a slight delay to ensure CSS is applied
|
52
53
|
setTimeout(updateLabelHeight, 0);
|
53
54
|
|
54
55
|
return () => {
|
55
|
-
if (
|
56
|
-
observer.unobserve(
|
56
|
+
if (currentLabelRef) {
|
57
|
+
observer.unobserve(currentLabelRef);
|
57
58
|
}
|
58
59
|
};
|
59
60
|
}, [label]);
|
@@ -98,3 +99,4 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
98
99
|
);
|
99
100
|
},
|
100
101
|
);
|
102
|
+
Textarea.displayName = "Textarea";
|
package/src/input/index.ts
CHANGED
@@ -4,8 +4,8 @@ export * from "./Checkbox";
|
|
4
4
|
export * from "./CheckboxGroup";
|
5
5
|
export * from "./ChoiceChip";
|
6
6
|
export * from "./Combobox";
|
7
|
-
export * from "./Fieldset";
|
8
7
|
export * from "./Field";
|
8
|
+
export * from "./Fieldset";
|
9
9
|
export * from "./Input";
|
10
10
|
export * from "./ListBox";
|
11
11
|
export * from "./NativeSelect";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { ButtonProps, chakra, RecipeVariantProps } from "@chakra-ui/react";
|
3
|
-
import
|
3
|
+
import { forwardRef } from "react";
|
4
4
|
|
5
5
|
import { pressableCardRecipe } from "../theme/recipes/pressable-card";
|
6
6
|
|
@@ -40,5 +40,8 @@ type PressableCardProps = RecipeVariantProps<typeof pressableCardRecipe> &
|
|
40
40
|
ButtonProps;
|
41
41
|
|
42
42
|
export const PressableCard = forwardRef<HTMLDivElement, PressableCardProps>(
|
43
|
-
(props, ref) =>
|
43
|
+
(props, ref) => {
|
44
|
+
return <PressableCardButton {...props} ref={ref} />;
|
45
|
+
},
|
44
46
|
);
|
47
|
+
PressableCard.displayName = "PressableCard";
|
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
|
7
|
+
import React, { forwardRef } from "react";
|
8
8
|
|
9
9
|
import { radioCardSlotRecipe } from "../theme/slot-recipes/radio-card";
|
10
10
|
|
@@ -55,6 +55,7 @@ export const RadioCard = forwardRef<HTMLInputElement, RadioCardItemProps>(
|
|
55
55
|
);
|
56
56
|
},
|
57
57
|
);
|
58
|
+
RadioCard.displayName = "RadioCard";
|
58
59
|
|
59
60
|
type RadioCardRootProps = RadioCardVariantProps &
|
60
61
|
Exclude<ChakraRadioCard.RootProps, "variant"> & {
|
@@ -92,5 +93,6 @@ export const RadioCardGroup = forwardRef<HTMLDivElement, RadioCardRootProps>(
|
|
92
93
|
);
|
93
94
|
},
|
94
95
|
);
|
96
|
+
RadioCardGroup.displayName = "RadioCardGroup";
|
95
97
|
|
96
98
|
export const RadioCardLabel = ChakraRadioCard.Label;
|
package/src/layout/Separator.tsx
CHANGED
@@ -6,7 +6,7 @@ import {
|
|
6
6
|
SeparatorProps as ChakraSeparatorProps,
|
7
7
|
useRecipe,
|
8
8
|
} from "@chakra-ui/react";
|
9
|
-
import
|
9
|
+
import { forwardRef, PropsWithChildren } from "react";
|
10
10
|
|
11
11
|
import { separatorRecipe } from "../theme/recipes/separator";
|
12
12
|
|
@@ -31,3 +31,4 @@ export const Separator = forwardRef<HTMLDivElement, SeparatorProps>(
|
|
31
31
|
return <ChakraSeparator css={styles} {...props} ref={ref} />;
|
32
32
|
},
|
33
33
|
);
|
34
|
+
Separator.displayName = "Separator";
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
|
-
import {
|
3
|
-
import
|
2
|
+
import { BoxProps, chakra, RecipeVariantProps } from "@chakra-ui/react";
|
3
|
+
import { forwardRef } from "react";
|
4
4
|
|
5
5
|
import { staticCardRecipe } from "../theme/recipes/static-card";
|
6
6
|
|
@@ -47,5 +47,8 @@ export type StaticCardProps = RecipeVariantProps<typeof staticCardRecipe> &
|
|
47
47
|
BoxProps;
|
48
48
|
|
49
49
|
export const StaticCard = forwardRef<HTMLDivElement, StaticCardProps>(
|
50
|
-
(props, ref) =>
|
50
|
+
(props, ref) => {
|
51
|
+
return <StyledCardBox {...props} ref={ref}></StyledCardBox>;
|
52
|
+
},
|
51
53
|
);
|
54
|
+
StaticCard.displayName = "StaticCard";
|
package/src/linjetag/InfoTag.tsx
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, RecipeVariantProps, useSlotRecipe } from "@chakra-ui/react";
|
3
|
-
import
|
3
|
+
import { PropsWithChildren } from "react";
|
4
4
|
|
5
5
|
import { infoTagSlotRecipe } from "../theme/slot-recipes/info-tag";
|
6
6
|
import { LineIcon } from "./LineIcon";
|
@@ -18,7 +18,7 @@ export type InfoTagProps = TagProps & PropsWithChildren<InfoTagVariantProps>;
|
|
18
18
|
* ```tsx
|
19
19
|
* <InfoTag variant="subway" title="3" description="Ringen" />
|
20
20
|
* ```
|
21
|
-
* They support three different sizes
|
21
|
+
* They support three different sizes –`sm`, `md` and `lg`.
|
22
22
|
*
|
23
23
|
* ```tsx
|
24
24
|
* <InfoTag
|
@@ -63,6 +63,7 @@ export const InfoTag = ({
|
|
63
63
|
variant={variant}
|
64
64
|
size={size}
|
65
65
|
aria-label={title}
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
66
67
|
{...(customProps as any)} // TODO: Fix this
|
67
68
|
/>
|
68
69
|
<Box css={styles.textContainer}>
|
@@ -41,7 +41,7 @@ export type LineIconProps = Exclude<BoxProps, "variant"> &
|
|
41
41
|
* <LineIcon variant="subway" />
|
42
42
|
* ```
|
43
43
|
*
|
44
|
-
* They support three different sizes
|
44
|
+
* They support three different sizes - `sm`, `md` and `lg`.
|
45
45
|
*
|
46
46
|
* ```tsx
|
47
47
|
* <LineIcon variant="subway" size="lg" />
|
@@ -67,7 +67,7 @@ export const LineIcon = forwardRef<HTMLDivElement, LineIconProps>(
|
|
67
67
|
variant,
|
68
68
|
size = "md",
|
69
69
|
foregroundColor,
|
70
|
-
|
70
|
+
|
71
71
|
disabled,
|
72
72
|
style,
|
73
73
|
target = "lineIcon",
|
@@ -85,11 +85,12 @@ export const LineIcon = forwardRef<HTMLDivElement, LineIconProps>(
|
|
85
85
|
return variant === "walk" && target === "travelTag" ? 0 : 0.5;
|
86
86
|
};
|
87
87
|
|
88
|
-
const Icon:
|
88
|
+
const Icon: React.ElementType = getCorrectIcon({
|
89
89
|
variant:
|
90
90
|
variant === "custom" && "customIconVariant" in rest
|
91
91
|
? rest.customIconVariant
|
92
|
-
:
|
92
|
+
: // eslint-disable-next-line unicorn/no-nested-ternary
|
93
|
+
variant === "custom" //eslint rules and prettier conflict
|
93
94
|
? "local-train"
|
94
95
|
: variant,
|
95
96
|
size,
|
@@ -13,7 +13,7 @@ import {
|
|
13
13
|
WarningFill18Icon,
|
14
14
|
WarningFill24Icon,
|
15
15
|
} from "@vygruppen/spor-icon-react";
|
16
|
-
import
|
16
|
+
import { forwardRef, PropsWithChildren } from "react";
|
17
17
|
|
18
18
|
import { travelTagSlotRecipe } from "../theme/slot-recipes/travel-tag";
|
19
19
|
import { LineIcon } from "./LineIcon";
|
@@ -48,7 +48,7 @@ export type TravelTagProps = TagProps &
|
|
48
48
|
* <TravelTag variant="subway" title="3" description="Ringen" />
|
49
49
|
* ```
|
50
50
|
*
|
51
|
-
* They support three different sizes
|
51
|
+
* They support three different sizes - `sm`, `md` and `lg`.
|
52
52
|
*
|
53
53
|
* You can also render them with a deviation level to indicate an extra focus:
|
54
54
|
*
|
@@ -133,7 +133,8 @@ export const TravelTag = forwardRef<HTMLDivElement, TravelTagProps>(
|
|
133
133
|
customIconVariant={customIconVariant}
|
134
134
|
disabled={disabled}
|
135
135
|
target="travelTag"
|
136
|
-
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
137
|
+
{...(rest as any)} //Find a way to not use any here
|
137
138
|
/>
|
138
139
|
<Box css={styles.textContainer}>
|
139
140
|
{title && (
|
@@ -161,15 +162,18 @@ const getDeviationLevelIcon = ({
|
|
161
162
|
size,
|
162
163
|
}: Pick<TravelTagProps, "deviationLevel" | "size">) => {
|
163
164
|
switch (deviationLevel) {
|
164
|
-
case "critical":
|
165
|
+
case "critical": {
|
165
166
|
return size === "lg" ? ErrorFill24Icon : ErrorFill18Icon;
|
167
|
+
}
|
166
168
|
case "major":
|
167
|
-
case "minor":
|
169
|
+
case "minor": {
|
168
170
|
return size === "lg" ? WarningFill24Icon : WarningFill18Icon;
|
169
|
-
|
171
|
+
}
|
172
|
+
case "info": {
|
170
173
|
return size === "lg" ? InformationFill24Icon : InformationFill18Icon;
|
171
|
-
|
172
|
-
default:
|
174
|
+
}
|
175
|
+
default: {
|
173
176
|
return null;
|
177
|
+
}
|
174
178
|
}
|
175
179
|
};
|
package/src/link/TextLink.tsx
CHANGED
@@ -3,11 +3,18 @@ import {
|
|
3
3
|
Link as ChakraLink,
|
4
4
|
LinkProps as ChakraLinkProps,
|
5
5
|
RecipeVariantProps,
|
6
|
+
VisuallyHidden,
|
6
7
|
} from "@chakra-ui/react";
|
7
8
|
import { LinkOutOutline24Icon } from "@vygruppen/spor-icon-react";
|
8
|
-
import React, {
|
9
|
+
import React, {
|
10
|
+
cloneElement,
|
11
|
+
forwardRef,
|
12
|
+
isValidElement,
|
13
|
+
PropsWithChildren,
|
14
|
+
} from "react";
|
15
|
+
|
16
|
+
import { createTexts, useTranslation } from "@/i18n";
|
9
17
|
|
10
|
-
import { createTexts, useTranslation } from "..";
|
11
18
|
import { linkRecipe } from "../theme/recipes/link";
|
12
19
|
|
13
20
|
type linkVariantProps = RecipeVariantProps<typeof linkRecipe>;
|
@@ -29,21 +36,49 @@ export type LinkProps = Exclude<ChakraLinkProps, "variant"> &
|
|
29
36
|
* </TextLink>
|
30
37
|
* ```
|
31
38
|
*/
|
39
|
+
const ExternalIcon = ({ label }: { label: string }) => (
|
40
|
+
<>
|
41
|
+
<LinkOutOutline24Icon aria-hidden />
|
42
|
+
<VisuallyHidden>{label}</VisuallyHidden>
|
43
|
+
</>
|
44
|
+
);
|
45
|
+
|
32
46
|
export const TextLink = forwardRef<HTMLAnchorElement, LinkProps>(
|
33
|
-
({ children, ...props }, ref) => {
|
47
|
+
({ children, external, href, ...props }, ref) => {
|
34
48
|
const { t } = useTranslation();
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
49
|
+
|
50
|
+
const isExternal =
|
51
|
+
external ??
|
52
|
+
Boolean(href?.startsWith("http://") || href?.startsWith("https://"));
|
53
|
+
|
54
|
+
const externalLabel = t ? t(texts.externalLink) : texts.externalLink.en;
|
55
|
+
|
56
|
+
// If asChild is true, we need to clone the children and add the external icon
|
57
|
+
if (props.asChild && isValidElement(children)) {
|
58
|
+
return (
|
59
|
+
<ChakraLink href={href} {...props} ref={ref}>
|
60
|
+
{cloneElement(children as React.ReactElement, {
|
61
|
+
...children.props,
|
62
|
+
children: (
|
63
|
+
<>
|
64
|
+
{children.props.children}
|
65
|
+
{isExternal && <ExternalIcon label={externalLabel} />}
|
66
|
+
</>
|
67
|
+
),
|
68
|
+
})}
|
69
|
+
</ChakraLink>
|
70
|
+
);
|
71
|
+
}
|
72
|
+
|
39
73
|
return (
|
40
|
-
<ChakraLink {...props} ref={ref}>
|
74
|
+
<ChakraLink href={href} {...props} ref={ref}>
|
41
75
|
{children}
|
42
|
-
{
|
76
|
+
{isExternal && <ExternalIcon label={externalLabel} />}
|
43
77
|
</ChakraLink>
|
44
78
|
);
|
45
79
|
},
|
46
80
|
);
|
81
|
+
TextLink.displayName = "TextLink";
|
47
82
|
|
48
83
|
const texts = createTexts({
|
49
84
|
externalLink: {
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, BoxProps, Center, VisuallyHidden } from "@chakra-ui/react";
|
3
3
|
import { fullScreenLoaderWhiteData } from "@vygruppen/spor-loader";
|
4
|
-
import React from "react";
|
5
4
|
|
6
5
|
import { ClientOnly } from "./ClientOnly";
|
7
6
|
import Lottie from "./Lottie";
|
@@ -1,7 +1,6 @@
|
|
1
1
|
"use client";
|
2
2
|
import { Box, BoxProps, Center, VisuallyHidden } from "@chakra-ui/react";
|
3
3
|
import { fullScreenLoaderBlackData } from "@vygruppen/spor-loader";
|
4
|
-
import React from "react";
|
5
4
|
|
6
5
|
import { ClientOnly } from "./ClientOnly";
|
7
6
|
import Lottie from "./Lottie";
|
package/src/loader/Lottie.tsx
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import ReactLottie from "lottie-react";
|
2
|
-
import React from "react";
|
3
2
|
|
4
3
|
/**
|
5
4
|
* A wrapper around Lottie to make it tree-shakeable for SSR.
|
6
5
|
*/
|
7
|
-
export default function Lottie({ animationData }: { animationData:
|
6
|
+
export default function Lottie({ animationData }: { animationData: unknown }) {
|
8
7
|
return <ReactLottie animationData={animationData} />;
|
9
8
|
}
|
@@ -79,13 +79,11 @@ export const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
|
|
79
79
|
(
|
80
80
|
{
|
81
81
|
value,
|
82
|
-
colorPalette = "white",
|
83
82
|
label,
|
84
83
|
labelRotationDelay = 5000,
|
85
84
|
isActive = true,
|
86
85
|
showValueText = false,
|
87
86
|
height = "0.5rem",
|
88
|
-
"aria-label": ariaLabel,
|
89
87
|
...rest
|
90
88
|
},
|
91
89
|
ref,
|
@@ -117,3 +115,4 @@ export const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
|
|
117
115
|
);
|
118
116
|
},
|
119
117
|
);
|
118
|
+
ProgressBar.displayName = "ProgressBar";
|
@@ -1,11 +1,5 @@
|
|
1
1
|
"use client";
|
2
|
-
import {
|
3
|
-
Box,
|
4
|
-
BoxProps,
|
5
|
-
chakra,
|
6
|
-
RecipeVariantProps,
|
7
|
-
Text,
|
8
|
-
} from "@chakra-ui/react";
|
2
|
+
import { BoxProps, chakra, RecipeVariantProps, Text } from "@chakra-ui/react";
|
9
3
|
import React, { forwardRef, useEffect, useId, useRef, useState } from "react";
|
10
4
|
import { useProgressBar } from "react-aria";
|
11
5
|
|
@@ -175,6 +169,7 @@ export const ProgressLoader = forwardRef<HTMLDivElement, ProgressLoaderProps>(
|
|
175
169
|
);
|
176
170
|
},
|
177
171
|
);
|
172
|
+
ProgressLoader.displayName = "ProgressLoader";
|
178
173
|
|
179
174
|
const texts = createTexts({
|
180
175
|
fallbackLabel: (value) => ({
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { chakra } from "@chakra-ui/react";
|
2
|
-
import
|
2
|
+
import { forwardRef } from "react";
|
3
3
|
|
4
4
|
export type CargonetLogoProps = {
|
5
5
|
/** The color of the logo
|
@@ -96,3 +96,4 @@ export const CargonetLogo = forwardRef<SVGSVGElement, CargonetLogoProps>(
|
|
96
96
|
);
|
97
97
|
},
|
98
98
|
);
|
99
|
+
CargonetLogo.displayName = "CargonetLogo";
|
package/src/logo/VyLogo.tsx
CHANGED
@@ -1,7 +1,5 @@
|
|
1
|
-
import {
|
2
|
-
import React, { forwardRef,
|
3
|
-
|
4
|
-
import { useColorMode } from "..";
|
1
|
+
import { BoxProps, chakra } from "@chakra-ui/react";
|
2
|
+
import React, { forwardRef, useId } from "react";
|
5
3
|
|
6
4
|
export const SvgBox = chakra("svg");
|
7
5
|
|
@@ -119,3 +117,4 @@ export const VyLogo = forwardRef<SVGSVGElement, VyLogoProps>((props, ref) => {
|
|
119
117
|
</SvgBox>
|
120
118
|
);
|
121
119
|
});
|
120
|
+
VyLogo.displayName = "VyLogo";
|