@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.
Files changed (85) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/.turbo/turbo-postinstall.log +2 -2
  3. package/CHANGELOG.md +24 -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 +10 -10
  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/input/useFLoatingInputState.tsx +1 -1
  57. package/src/layout/PressableCard.tsx +11 -10
  58. package/src/layout/RadioCard.tsx +57 -53
  59. package/src/layout/Separator.tsx +8 -7
  60. package/src/layout/StaticCard.tsx +11 -10
  61. package/src/linjetag/LineIcon.tsx +48 -54
  62. package/src/linjetag/TravelTag.tsx +57 -59
  63. package/src/link/TextLink.tsx +50 -40
  64. package/src/loader/ProgressBar.tsx +41 -46
  65. package/src/loader/ProgressLoader.tsx +83 -86
  66. package/src/loader/Skeleton.tsx +56 -48
  67. package/src/logo/CargonetLogo.tsx +88 -87
  68. package/src/logo/VyLogo.tsx +80 -77
  69. package/src/logo/VyLogoPride.tsx +137 -135
  70. package/src/media-controller/JumpButton.tsx +30 -28
  71. package/src/media-controller/PlayPauseButton.tsx +8 -7
  72. package/src/media-controller/SkipButton.tsx +28 -26
  73. package/src/nudge/Nudge.tsx +66 -70
  74. package/src/pagination/Pagination.tsx +52 -46
  75. package/src/popover/index.tsx +46 -41
  76. package/src/progress-indicator/ProgressIndicator.tsx +10 -7
  77. package/src/stepper/Stepper.tsx +84 -81
  78. package/src/tab/Tabs.tsx +8 -4
  79. package/src/table/Table.tsx +89 -109
  80. package/src/tooltip.tsx +26 -22
  81. package/src/typography/Badge.tsx +8 -5
  82. package/src/typography/Code.tsx +8 -5
  83. package/src/typography/Heading.tsx +22 -23
  84. package/src/typography/Text.tsx +11 -9
  85. package/tsconfig.json +1 -0
@@ -9,7 +9,7 @@ import {
9
9
  DropdownDownFill18Icon,
10
10
  DropdownDownFill24Icon,
11
11
  } from "@vygruppen/spor-icon-react";
12
- import { forwardRef, ReactNode } from "react";
12
+ import { ReactNode } from "react";
13
13
 
14
14
  import { Button, ButtonProps, StaticCard, StaticCardProps } from "..";
15
15
 
@@ -17,31 +17,34 @@ export const CardSelect = ({ size = "md", ...props }: PopoverRootProps) => {
17
17
  return <ChakraPopover.Root size={size} {...props} />;
18
18
  };
19
19
 
20
- export const CardSelectContent = forwardRef<HTMLDivElement, StaticCardProps>(
21
- ({ children, ...props }, ref) => {
22
- return (
23
- <Portal>
24
- <ChakraPopover.Positioner>
25
- <ChakraPopover.Content ref={ref} padding={0} bg="none">
26
- <ChakraPopover.Body {...props}>
27
- <StaticCard
28
- p="2"
29
- bg="bg"
30
- border="sm"
31
- borderColor="floating.outline"
32
- borderRadius="sm"
33
- {...props}
34
- >
35
- {children}
36
- </StaticCard>
37
- </ChakraPopover.Body>
38
- </ChakraPopover.Content>
39
- </ChakraPopover.Positioner>
40
- </Portal>
41
- );
42
- },
43
- );
44
- CardSelectContent.displayName = "CardSelectContent";
20
+ export const CardSelectContent = ({
21
+ ref,
22
+ children,
23
+ ...props
24
+ }: StaticCardProps & {
25
+ ref?: React.Ref<HTMLDivElement>;
26
+ }) => {
27
+ return (
28
+ <Portal>
29
+ <ChakraPopover.Positioner>
30
+ <ChakraPopover.Content ref={ref} padding={0} bg="none">
31
+ <ChakraPopover.Body {...props}>
32
+ <StaticCard
33
+ p="2"
34
+ bg="bg"
35
+ border="sm"
36
+ borderColor="floating.outline"
37
+ borderRadius="sm"
38
+ {...props}
39
+ >
40
+ {children}
41
+ </StaticCard>
42
+ </ChakraPopover.Body>
43
+ </ChakraPopover.Content>
44
+ </ChakraPopover.Positioner>
45
+ </Portal>
46
+ );
47
+ };
45
48
 
46
49
  export type CardSelectTriggerProps = {
47
50
  /** The design of the trigger button.
@@ -63,44 +66,43 @@ const bgActiveStyleMap = {
63
66
  floating: "floating.surface.active",
64
67
  };
65
68
 
66
- export const CardSelectTrigger = forwardRef<
67
- HTMLButtonElement,
68
- CardSelectTriggerProps
69
- >(
70
- (
71
- { icon, variant = "core", withChevron = true, size, children, ...props },
72
- ref,
73
- ) => {
74
- const ChevronIcon =
75
- size === "sm" ? DropdownDownFill18Icon : DropdownDownFill24Icon;
69
+ export const CardSelectTrigger = ({
70
+ ref,
71
+ icon,
72
+ variant = "core",
73
+ withChevron = true,
74
+ size,
75
+ children,
76
+ ...props
77
+ }: CardSelectTriggerProps & {
78
+ ref?: React.Ref<HTMLButtonElement>;
79
+ }) => {
80
+ const ChevronIcon =
81
+ size === "sm" ? DropdownDownFill18Icon : DropdownDownFill24Icon;
76
82
 
77
- const { open } = usePopoverContext();
83
+ const { open } = usePopoverContext();
78
84
 
79
- return (
80
- <ChakraPopover.Trigger asChild ref={ref}>
81
- <Button
82
- leftIcon={icon}
83
- variant={
84
- variant === "core"
85
- ? "tertiary"
86
- : (variant as ButtonProps["variant"])
87
- }
88
- size={size}
89
- bg={open ? bgActiveStyleMap[variant] : undefined}
90
- rightIcon={
91
- withChevron ? (
92
- <ChevronIcon
93
- transform={open ? "rotate(180deg)" : undefined}
94
- transition="transform 0.3s"
95
- />
96
- ) : null
97
- }
98
- {...props}
99
- >
100
- {children}
101
- </Button>
102
- </ChakraPopover.Trigger>
103
- );
104
- },
105
- );
106
- CardSelectTrigger.displayName = "CardSelectTrigger";
85
+ return (
86
+ <ChakraPopover.Trigger asChild ref={ref}>
87
+ <Button
88
+ leftIcon={icon}
89
+ variant={
90
+ variant === "core" ? "tertiary" : (variant as ButtonProps["variant"])
91
+ }
92
+ size={size}
93
+ bg={open ? bgActiveStyleMap[variant] : undefined}
94
+ rightIcon={
95
+ withChevron ? (
96
+ <ChevronIcon
97
+ transform={open ? "rotate(180deg)" : undefined}
98
+ transition="transform 0.3s"
99
+ />
100
+ ) : null
101
+ }
102
+ {...props}
103
+ >
104
+ {children}
105
+ </Button>
106
+ </ChakraPopover.Trigger>
107
+ );
108
+ };
@@ -29,20 +29,22 @@ type CheckboxProps = Omit<ChakraCheckbox.RootProps, "onChange"> &
29
29
  * You can group several of these together with a `CheckboxGroup`.
30
30
  */
31
31
 
32
- export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
33
- (props, ref) => {
34
- const { children, inputProps, rootRef, ...rest } = props;
35
- return (
36
- <ChakraCheckbox.Root ref={rootRef} {...rest}>
37
- <ChakraCheckbox.HiddenInput ref={ref} {...inputProps} />
38
- <ChakraCheckbox.Control>
39
- <ChakraCheckbox.Indicator />
40
- </ChakraCheckbox.Control>
41
- {children != null && (
42
- <ChakraCheckbox.Label>{children}</ChakraCheckbox.Label>
43
- )}
44
- </ChakraCheckbox.Root>
45
- );
46
- },
47
- );
48
- Checkbox.displayName = "Checkbox";
32
+ export const Checkbox = ({
33
+ ref,
34
+ ...props
35
+ }: CheckboxProps & {
36
+ ref?: React.Ref<HTMLInputElement>;
37
+ }) => {
38
+ const { children, inputProps, rootRef, ...rest } = props;
39
+ return (
40
+ <ChakraCheckbox.Root ref={rootRef} {...rest}>
41
+ <ChakraCheckbox.HiddenInput ref={ref} {...inputProps} />
42
+ <ChakraCheckbox.Control>
43
+ <ChakraCheckbox.Indicator />
44
+ </ChakraCheckbox.Control>
45
+ {children != null && (
46
+ <ChakraCheckbox.Label>{children}</ChakraCheckbox.Label>
47
+ )}
48
+ </ChakraCheckbox.Root>
49
+ );
50
+ };
@@ -29,7 +29,6 @@ export type CheckboxGroupProps = React.ComponentProps<
29
29
  */
30
30
 
31
31
  export const CheckboxGroup = (props: CheckboxGroupProps) => {
32
- // Forwardref caues issue with prop types not working. Forwardref is unessessary here, as ChakraCheckbox already has a ref prop and is deprecated in react 19.
33
32
  const { direction = "row", children, gap = 1, ...rest } = props;
34
33
 
35
34
  return (
@@ -40,4 +39,3 @@ export const CheckboxGroup = (props: CheckboxGroupProps) => {
40
39
  </ChakraCheckboxGroup>
41
40
  );
42
41
  };
43
- CheckboxGroup.displayName = "CheckboxGroup";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { CheckboxCard, CheckboxCardRootProps, Span } from "@chakra-ui/react";
3
3
  import { CloseOutline24Icon } from "@vygruppen/spor-icon-react";
4
- import React, { forwardRef } from "react";
4
+ import React from "react";
5
5
 
6
6
  type CheckBoxIcon = {
7
7
  default: React.ReactNode;
@@ -49,42 +49,46 @@ export type ChoiceChipProps = Omit<
49
49
  * ```
50
50
  */
51
51
 
52
- export const ChoiceChip = forwardRef<HTMLInputElement, ChoiceChipProps>(
53
- ({ children, icon, onCheckedChange, ...rootProps }, ref) => {
54
- return (
55
- <CheckboxCard.Root
56
- {...rootProps}
57
- {...(onCheckedChange && {
58
- onCheckedChange: (details) => onCheckedChange(!!details.checked),
59
- })}
60
- >
61
- <CheckboxCard.Context>
62
- {({ checked }) => (
63
- <>
64
- <CheckboxCard.HiddenInput ref={ref} />
65
- <CheckboxCard.Control>
66
- <CheckboxCard.Content>
67
- <CheckboxCard.Label>
68
- {icon && (
69
- <Span width="24px">
70
- {checked ? icon.checked : icon.default}
71
- </Span>
72
- )}
52
+ export const ChoiceChip = ({
53
+ ref,
54
+ children,
55
+ icon,
56
+ onCheckedChange,
57
+ ...rootProps
58
+ }: ChoiceChipProps & {
59
+ ref?: React.Ref<HTMLInputElement>;
60
+ }) => {
61
+ return (
62
+ <CheckboxCard.Root
63
+ {...rootProps}
64
+ {...(onCheckedChange && {
65
+ onCheckedChange: (details) => onCheckedChange(!!details.checked),
66
+ })}
67
+ >
68
+ <CheckboxCard.Context>
69
+ {({ checked }) => (
70
+ <>
71
+ <CheckboxCard.HiddenInput ref={ref} />
72
+ <CheckboxCard.Control>
73
+ <CheckboxCard.Content>
74
+ <CheckboxCard.Label>
75
+ {icon && (
76
+ <Span width="24px">
77
+ {checked ? icon.checked : icon.default}
78
+ </Span>
79
+ )}
73
80
 
74
- {rootProps.chipType !== "icon" && children}
81
+ {rootProps.chipType !== "icon" && children}
75
82
 
76
- {rootProps.chipType === "filter" && checked && (
77
- <CloseOutline24Icon />
78
- )}
79
- </CheckboxCard.Label>
80
- </CheckboxCard.Content>
81
- </CheckboxCard.Control>
82
- </>
83
- )}
84
- </CheckboxCard.Context>
85
- </CheckboxCard.Root>
86
- );
87
- },
88
- );
89
-
90
- ChoiceChip.displayName = "ChoiceChip";
83
+ {rootProps.chipType === "filter" && checked && (
84
+ <CloseOutline24Icon />
85
+ )}
86
+ </CheckboxCard.Label>
87
+ </CheckboxCard.Content>
88
+ </CheckboxCard.Control>
89
+ </>
90
+ )}
91
+ </CheckboxCard.Context>
92
+ </CheckboxCard.Root>
93
+ );
94
+ };
@@ -97,7 +97,9 @@ export const Combobox = (props: ComboboxProps<object>) => {
97
97
 
98
98
  const listboxId = useId();
99
99
 
100
- const inputWidth = useInputWidth(inputRef);
100
+ const inputWidth = useInputWidth(
101
+ inputRef as React.RefObject<HTMLInputElement>,
102
+ );
101
103
 
102
104
  const state = useComboBoxState({
103
105
  defaultFilter: contains,
@@ -231,7 +233,7 @@ export const Combobox = (props: ComboboxProps<object>) => {
231
233
  }}
232
234
  state={state}
233
235
  id={listboxId}
234
- listBoxRef={listBoxRef}
236
+ listBoxRef={listBoxRef as React.RefObject<HTMLUListElement>}
235
237
  emptyContent={emptyContent}
236
238
  maxWidth={inputWidth}
237
239
  variant={variant}
@@ -244,8 +246,6 @@ export const Combobox = (props: ComboboxProps<object>) => {
244
246
  );
245
247
  };
246
248
 
247
- Combobox.displayName = "Combobox";
248
-
249
249
  const useInputWidth = (inputRef: React.RefObject<HTMLInputElement>) => {
250
250
  const [inputWidth, setInputWidth] = useState("auto");
251
251
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { createListCollection } from "@chakra-ui/react";
4
4
  import { getSupportedCallingCodes } from "awesome-phonenumber";
5
- import { forwardRef, useMemo } from "react";
5
+ import { useMemo } from "react";
6
6
 
7
7
  import {
8
8
  createTexts,
@@ -37,10 +37,12 @@ type CountryCodeSelectProps = Omit<SelectProps, "label" | "collection"> & {
37
37
  allowedCountryCodes?: string[];
38
38
  };
39
39
 
40
- export const CountryCodeSelect = forwardRef<
41
- HTMLDivElement,
42
- CountryCodeSelectProps
43
- >((props, ref) => {
40
+ export const CountryCodeSelect = ({
41
+ ref,
42
+ ...props
43
+ }: CountryCodeSelectProps & {
44
+ ref?: React.Ref<HTMLDivElement>;
45
+ }) => {
44
46
  const { t } = useTranslation();
45
47
 
46
48
  const filteredCallingCodes = useMemo(() => {
@@ -71,9 +73,7 @@ export const CountryCodeSelect = forwardRef<
71
73
  ))}
72
74
  </Select>
73
75
  );
74
- });
75
-
76
- CountryCodeSelect.displayName = "CountryCodeSelect";
76
+ };
77
77
 
78
78
  const texts = createTexts({
79
79
  countryCode: {
@@ -32,14 +32,14 @@ function renderLabelWithIndicator(
32
32
  );
33
33
  }
34
34
 
35
- return React.cloneElement(label, {
36
- children: (
37
- <>
38
- {label.props.children}
39
- <ChakraField.RequiredIndicator />
40
- </>
41
- ),
42
- });
35
+ return React.cloneElement(
36
+ label,
37
+ {},
38
+ <>
39
+ {(label.props as React.PropsWithChildren).children}
40
+ <ChakraField.RequiredIndicator />
41
+ </>,
42
+ );
43
43
  }
44
44
 
45
45
  export type FieldBaseProps = {
@@ -80,80 +80,83 @@ export type FieldProps = Omit<
80
80
  * This component is not exported and should be used as a wrapper for other input components.
81
81
  */
82
82
 
83
- export const Field = React.forwardRef<HTMLDivElement, FieldProps>(
84
- (props, ref) => {
85
- const {
86
- label,
87
- children,
88
- helperText,
89
- errorText,
90
- floatingLabel = false,
91
- disabled,
92
- invalid,
93
- readOnly,
94
- required,
95
- direction,
96
- id,
97
- shouldFloat,
98
- labelAsChild,
99
- ...rest
100
- } = props;
101
- const recipe = useSlotRecipe({ key: "field" });
102
- const styles = recipe();
83
+ export const Field = ({
84
+ ref,
85
+ ...props
86
+ }: FieldProps & {
87
+ ref?: React.Ref<HTMLDivElement>;
88
+ }) => {
89
+ const {
90
+ label,
91
+ children,
92
+ helperText,
93
+ errorText,
94
+ floatingLabel = false,
95
+ disabled,
96
+ invalid,
97
+ readOnly,
98
+ required,
99
+ direction,
100
+ id,
101
+ shouldFloat,
102
+ labelAsChild,
103
+ ...rest
104
+ } = props;
105
+ const recipe = useSlotRecipe({ key: "field" });
106
+ const styles = recipe();
103
107
 
104
- return (
105
- <Stack gap="2" ref={ref} width="100%" {...rest}>
106
- <ChakraField.Root
107
- disabled={disabled}
108
- invalid={invalid}
109
- readOnly={readOnly}
110
- required={required}
111
- css={styles.root}
112
- direction={direction}
113
- id={id}
114
- >
115
- {label && !floatingLabel && (
116
- <Label asChild={labelAsChild} aria-hidden>
117
- {renderLabelWithIndicator(label, labelAsChild)}
118
- </Label>
119
- )}
108
+ return (
109
+ <Stack gap="2" ref={ref} width="100%" {...rest}>
110
+ <ChakraField.Root
111
+ disabled={disabled}
112
+ invalid={invalid}
113
+ readOnly={readOnly}
114
+ required={required}
115
+ css={styles.root}
116
+ direction={direction}
117
+ id={id}
118
+ >
119
+ {label && !floatingLabel && (
120
+ <Label asChild={labelAsChild} aria-hidden>
121
+ {renderLabelWithIndicator(label, labelAsChild)}
122
+ </Label>
123
+ )}
120
124
 
121
- {children}
125
+ {children}
122
126
 
123
- {label && floatingLabel && (
124
- <FloatingLabel
125
- data-float={shouldFloat ? true : undefined}
126
- asChild={labelAsChild}
127
- aria-hidden
128
- >
129
- {renderLabelWithIndicator(label, labelAsChild)}
130
- </FloatingLabel>
131
- )}
132
- {errorText && (
133
- <ChakraField.ErrorText aria-live="polite">
134
- {errorText}
135
- </ChakraField.ErrorText>
136
- )}
137
- </ChakraField.Root>
138
- {helperText && (
139
- <Text variant="sm" color="text.tertiary">
140
- {helperText}
141
- </Text>
127
+ {label && floatingLabel && (
128
+ <FloatingLabel
129
+ data-float={shouldFloat ? true : undefined}
130
+ asChild={labelAsChild}
131
+ aria-hidden
132
+ >
133
+ {renderLabelWithIndicator(label, labelAsChild)}
134
+ </FloatingLabel>
142
135
  )}
143
- </Stack>
144
- );
145
- },
146
- );
147
- Field.displayName = "Field";
136
+ {errorText && (
137
+ <ChakraField.ErrorText aria-live="polite">
138
+ {errorText}
139
+ </ChakraField.ErrorText>
140
+ )}
141
+ </ChakraField.Root>
142
+ {helperText && (
143
+ <Text variant="sm" color="text.tertiary">
144
+ {helperText}
145
+ </Text>
146
+ )}
147
+ </Stack>
148
+ );
149
+ };
148
150
 
149
- export const FieldErrorText = React.forwardRef<
150
- HTMLDivElement,
151
- ChakraField.ErrorTextProps
152
- >((props, ref) => {
151
+ export const FieldErrorText = ({
152
+ ref,
153
+ ...props
154
+ }: ChakraField.ErrorTextProps & {
155
+ ref?: React.Ref<HTMLDivElement>;
156
+ }) => {
153
157
  return (
154
158
  <ChakraField.ErrorText ref={ref}>{props.children}</ChakraField.ErrorText>
155
159
  );
156
- });
157
- FieldErrorText.displayName = "FieldErrorText";
160
+ };
158
161
 
159
162
  export const FieldLabel = ChakraField.Label;
@@ -1,13 +1,11 @@
1
1
  import { defineStyle, Field, FieldLabelProps } from "@chakra-ui/react";
2
- import { forwardRef } from "react";
3
2
 
4
- export const FloatingLabel = forwardRef<HTMLLabelElement, FieldLabelProps>(
5
- (props, ref) => (
6
- <Field.Label ref={ref} {...props} css={floatingLabelStyles} />
7
- ),
8
- );
9
-
10
- FloatingLabel.displayName = "FloatingLabel";
3
+ export const FloatingLabel = ({
4
+ ref,
5
+ ...props
6
+ }: FieldLabelProps & {
7
+ ref?: React.Ref<HTMLLabelElement | null>;
8
+ }) => <Field.Label ref={ref} {...props} css={floatingLabelStyles} />;
11
9
 
12
10
  const floatingLabelStyles = defineStyle({
13
11
  paddingX: 3,