@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
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import { Button, useControllableState } from "@chakra-ui/react";
4
- import React, { forwardRef } from "react";
4
+ import React from "react";
5
5
 
6
6
  import { ButtonProps, Input, InputProps } from "..";
7
7
  import { createTexts, useTranslation } from "..";
@@ -42,70 +42,74 @@ export interface PasswordInputProps
42
42
  * @see https://spor.vy.no/components/password-input
43
43
  */
44
44
 
45
- export const PasswordInput = forwardRef<HTMLInputElement, PasswordInputProps>(
46
- (props, ref) => {
47
- const {
48
- defaultVisible,
49
- visible: visibleProperty,
50
- onVisibleChange,
51
- label,
52
- startElement,
53
- ...rest
54
- } = props;
45
+ export const PasswordInput = ({
46
+ ref,
47
+ ...props
48
+ }: PasswordInputProps & {
49
+ ref?: React.RefObject<HTMLInputElement>;
50
+ }) => {
51
+ const {
52
+ defaultVisible,
53
+ visible: visibleProperty,
54
+ onVisibleChange,
55
+ label,
56
+ startElement,
57
+ ...rest
58
+ } = props;
55
59
 
56
- const [visible, setVisible] = useControllableState({
57
- value: visibleProperty,
58
- defaultValue: defaultVisible || false,
59
- onChange: onVisibleChange,
60
- });
60
+ const [visible, setVisible] = useControllableState({
61
+ value: visibleProperty,
62
+ defaultValue: defaultVisible || false,
63
+ onChange: onVisibleChange,
64
+ });
61
65
 
62
- const { t } = useTranslation();
66
+ const { t } = useTranslation();
63
67
 
64
- return (
65
- <Input
66
- ref={ref}
67
- startElement={startElement && startElement}
68
- label={label}
69
- type={visible ? "text" : "password"}
70
- endElement={
71
- <VisibilityTrigger
72
- variant="ghost"
73
- disabled={rest.disabled}
74
- onPointerDown={(event) => {
75
- if (rest.disabled) return;
76
- if (event.button !== 0) return;
77
- event.preventDefault();
78
- setVisible(!visible);
79
- }}
80
- >
81
- {visible ? t(texts.hidePassword) : t(texts.showPassword)}
82
- </VisibilityTrigger>
83
- }
84
- {...rest}
85
- />
86
- );
87
- },
88
- );
89
- PasswordInput.displayName = "PasswordInput";
68
+ return (
69
+ <Input
70
+ ref={ref}
71
+ startElement={startElement && startElement}
72
+ label={label}
73
+ type={visible ? "text" : "password"}
74
+ endElement={
75
+ <VisibilityTrigger
76
+ variant="ghost"
77
+ disabled={rest.disabled}
78
+ onPointerDown={(event) => {
79
+ if (rest.disabled) return;
80
+ if (event.button !== 0) return;
81
+ event.preventDefault();
82
+ setVisible(!visible);
83
+ }}
84
+ >
85
+ {visible ? t(texts.hidePassword) : t(texts.showPassword)}
86
+ </VisibilityTrigger>
87
+ }
88
+ {...rest}
89
+ />
90
+ );
91
+ };
90
92
 
91
- const VisibilityTrigger = React.forwardRef<HTMLButtonElement, ButtonProps>(
92
- (props, ref) => {
93
- return (
94
- <Button
95
- ref={ref}
96
- type="button"
97
- fontWeight="normal"
98
- size="sm"
99
- borderRadius="sm"
100
- marginRight={1}
101
- {...props}
102
- >
103
- {props.children}
104
- </Button>
105
- );
106
- },
107
- );
108
- VisibilityTrigger.displayName = "VisibilityTrigger";
93
+ const VisibilityTrigger = ({
94
+ ref,
95
+ ...props
96
+ }: ButtonProps & {
97
+ ref?: React.RefObject<HTMLButtonElement>;
98
+ }) => {
99
+ return (
100
+ <Button
101
+ ref={ref}
102
+ type="button"
103
+ fontWeight="normal"
104
+ size="sm"
105
+ borderRadius="sm"
106
+ marginRight={1}
107
+ {...props}
108
+ >
109
+ {props.children}
110
+ </Button>
111
+ );
112
+ };
109
113
 
110
114
  const texts = createTexts({
111
115
  showPassword: {
@@ -1,6 +1,5 @@
1
1
  "use client";
2
2
  import { useControllableState } from "@chakra-ui/react";
3
- import { forwardRef } from "react";
4
3
 
5
4
  import { createTexts, Input, InputProps, useTranslation } from "..";
6
5
  import { AttachedInputs } from "./AttachedInputs";
@@ -42,10 +41,12 @@ type PhoneNumberInputProps = Omit<InputProps, "value"> & {
42
41
  * ```
43
42
  */
44
43
 
45
- export const PhoneNumberInput = forwardRef<
46
- HTMLInputElement,
47
- PhoneNumberInputProps
48
- >((props, ref) => {
44
+ export const PhoneNumberInput = ({
45
+ ref,
46
+ ...props
47
+ }: PhoneNumberInputProps & {
48
+ ref?: React.RefObject<HTMLInputElement>;
49
+ }) => {
49
50
  const {
50
51
  label: externalLabel,
51
52
  value: externalValue,
@@ -114,8 +115,7 @@ export const PhoneNumberInput = forwardRef<
114
115
  />
115
116
  </AttachedInputs>
116
117
  );
117
- });
118
- PhoneNumberInput.displayName = "PhoneNumberInput";
118
+ };
119
119
 
120
120
  const texts = createTexts({
121
121
  phoneNumber: {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { Box } from "@chakra-ui/react";
3
- import React, { forwardRef, useRef } from "react";
3
+ import React, { useRef } from "react";
4
4
  import {
5
5
  AriaPopoverProps,
6
6
  DismissButton,
@@ -56,62 +56,59 @@ type PopoverProps = {
56
56
  *
57
57
  * Used to render accessible popover content, only used in ComboBox.
58
58
  */
59
- export const Popover = forwardRef<HTMLDivElement, PopoverProps>(
60
- (
59
+ export const Popover = ({
60
+ ref,
61
+ children,
62
+ state,
63
+ triggerRef,
64
+ offset = 0,
65
+ crossOffset = 0,
66
+ placement = "bottom",
67
+ shouldFlip = false,
68
+ isNonModal = false,
69
+ hasBackdrop = true,
70
+ containerPadding = 12,
71
+ }: PopoverProps & {
72
+ ref?: React.RefObject<HTMLDivElement | null>;
73
+ }) => {
74
+ const internalRef = useRef<HTMLDivElement>(null);
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ const popoverRef = ref ?? (internalRef as any);
77
+
78
+ const { popoverProps, underlayProps } = usePopover(
61
79
  {
62
- children,
63
- state,
64
80
  triggerRef,
65
- offset = 0,
66
- crossOffset = 0,
67
- placement = "bottom",
68
- shouldFlip = false,
69
- isNonModal = false,
70
- hasBackdrop = true,
71
- containerPadding = 12,
81
+ popoverRef,
82
+ offset,
83
+ crossOffset,
84
+ placement,
85
+ shouldFlip,
86
+ isNonModal,
87
+ containerPadding,
72
88
  },
73
- ref,
74
- ) => {
75
- const internalRef = useRef<HTMLDivElement>(null);
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- const popoverRef = ref ?? (internalRef as any);
78
-
79
- const { popoverProps, underlayProps } = usePopover(
80
- {
81
- triggerRef,
82
- popoverRef,
83
- offset,
84
- crossOffset,
85
- placement,
86
- shouldFlip,
87
- isNonModal,
88
- containerPadding,
89
- },
90
- state,
91
- );
89
+ state,
90
+ );
92
91
 
93
- const popoverBox = (
94
- <Box
95
- {...popoverProps}
96
- ref={popoverRef}
97
- // eslint-disable-next-line react-hooks/refs
98
- minWidth={triggerRef.current?.clientWidth ?? "auto"}
99
- >
100
- <DismissButton onDismiss={state.close} />
101
- {children}
102
- <DismissButton onDismiss={state.close} />
103
- </Box>
104
- );
92
+ const popoverBox = (
93
+ <Box
94
+ {...popoverProps}
95
+ ref={popoverRef}
96
+ // eslint-disable-next-line react-hooks/refs
97
+ minWidth={triggerRef.current?.clientWidth ?? "auto"}
98
+ >
99
+ <DismissButton onDismiss={state.close} />
100
+ {children}
101
+ <DismissButton onDismiss={state.close} />
102
+ </Box>
103
+ );
105
104
 
106
- if (isNonModal) {
107
- return popoverBox;
108
- }
109
- return (
110
- <Overlay>
111
- {hasBackdrop && <Box {...underlayProps} position="fixed" inset="0" />}
112
- {popoverBox}
113
- </Overlay>
114
- );
115
- },
116
- );
117
- Popover.displayName = "Popover";
105
+ if (isNonModal) {
106
+ return popoverBox;
107
+ }
108
+ return (
109
+ <Overlay>
110
+ {hasBackdrop && <Box {...underlayProps} position="fixed" inset="0" />}
111
+ {popoverBox}
112
+ </Overlay>
113
+ );
114
+ };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { RecipeVariantProps } from "@chakra-ui/react";
3
3
  import { RadioGroup as ChakraRadioGroup } from "@chakra-ui/react";
4
- import React, { forwardRef, PropsWithChildren } from "react";
4
+ import React, { PropsWithChildren } from "react";
5
5
 
6
6
  import { radioGroupSlotRecipe } from "../theme/slot-recipes/radio";
7
7
 
@@ -28,7 +28,12 @@ export type RadioProps = PropsWithChildren<RadioVariants> &
28
28
  * </RadioGroup>
29
29
  */
30
30
 
31
- export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
31
+ export const Radio = ({
32
+ ref,
33
+ ...props
34
+ }: RadioProps & {
35
+ ref?: React.RefObject<HTMLInputElement>;
36
+ }) => {
32
37
  const { children, inputProps, rootRef, ...rest } = props;
33
38
 
34
39
  return (
@@ -40,17 +45,17 @@ export const Radio = forwardRef<HTMLInputElement, RadioProps>((props, ref) => {
40
45
  )}
41
46
  </ChakraRadioGroup.Item>
42
47
  );
43
- });
44
- Radio.displayName = "Radio";
45
-
48
+ };
46
49
  type RadioGroupProps = Omit<
47
50
  ChakraRadioGroup.RootProps,
48
51
  "colorPalette" | "variant" | "size"
49
52
  > & {};
50
53
 
51
- export const RadioGroup = forwardRef<HTMLDivElement, RadioGroupProps>(
52
- (props, ref) => {
53
- return <ChakraRadioGroup.Root ref={ref} {...props} aria-labelledby="" />;
54
- },
55
- );
56
- RadioGroup.displayName = "RadioGroup";
54
+ export const RadioGroup = ({
55
+ ref,
56
+ ...props
57
+ }: RadioGroupProps & {
58
+ ref?: React.RefObject<HTMLDivElement>;
59
+ }) => {
60
+ return <ChakraRadioGroup.Root ref={ref} {...props} aria-labelledby="" />;
61
+ };
@@ -4,7 +4,6 @@ import {
4
4
  CloseOutline24Icon,
5
5
  SearchOutline24Icon,
6
6
  } from "@vygruppen/spor-icon-react";
7
- import { forwardRef } from "react";
8
7
 
9
8
  import { createTexts, Input, InputProps, useTranslation } from "..";
10
9
  import { IconButton } from "../button/IconButton";
@@ -19,37 +18,39 @@ export type SearchInputProps = InputProps & {
19
18
  * Includes a search icon, a localized label and a reset button.
20
19
  */
21
20
 
22
- export const SearchInput = forwardRef<HTMLInputElement, SearchInputProps>(
23
- (props, ref) => {
24
- const { t } = useTranslation();
25
- const { variant = "core", onReset, label, value } = props;
26
- const clearButton = onReset && value;
21
+ export const SearchInput = ({
22
+ ref,
23
+ ...props
24
+ }: SearchInputProps & {
25
+ ref?: React.RefObject<HTMLInputElement>;
26
+ }) => {
27
+ const { t } = useTranslation();
28
+ const { variant = "core", onReset, label, value } = props;
29
+ const clearButton = onReset && value;
27
30
 
28
- return (
29
- <Input
30
- ref={ref}
31
- type="search"
32
- variant={variant}
33
- {...props}
34
- startElement={<SearchOutline24Icon color="icon" />}
35
- endElement={
36
- clearButton && (
37
- <IconButton
38
- variant="ghost"
39
- type="button"
40
- size="sm"
41
- aria-label={t(texts.reset)}
42
- icon={<CloseOutline24Icon />}
43
- onClick={onReset}
44
- />
45
- )
46
- }
47
- label={(label as string) ?? t(texts.label)}
48
- />
49
- );
50
- },
51
- );
52
- SearchInput.displayName = "SearchInput";
31
+ return (
32
+ <Input
33
+ ref={ref}
34
+ type="search"
35
+ variant={variant}
36
+ {...props}
37
+ startElement={<SearchOutline24Icon color="icon" />}
38
+ endElement={
39
+ clearButton && (
40
+ <IconButton
41
+ variant="ghost"
42
+ type="button"
43
+ size="sm"
44
+ aria-label={t(texts.reset)}
45
+ icon={<CloseOutline24Icon />}
46
+ onClick={onReset}
47
+ />
48
+ )
49
+ }
50
+ label={(label as string) ?? t(texts.label)}
51
+ />
52
+ );
53
+ };
53
54
 
54
55
  const texts = createTexts({
55
56
  label: {