@vygruppen/spor-react 12.24.15 → 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 (88) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/.turbo/turbo-postinstall.log +4 -3
  3. package/CHANGELOG.md +25 -0
  4. package/dist/index.cjs +2888 -2534
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +921 -572
  7. package/dist/index.d.ts +921 -572
  8. package/dist/index.mjs +2860 -2517
  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 +241 -0
  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/index.ts +1 -0
  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/theme/slot-recipes/anatomy.ts +14 -0
  81. package/src/theme/slot-recipes/index.ts +2 -0
  82. package/src/theme/slot-recipes/menu.ts +111 -0
  83. package/src/tooltip.tsx +26 -22
  84. package/src/typography/Badge.tsx +8 -5
  85. package/src/typography/Code.tsx +8 -5
  86. package/src/typography/Heading.tsx +22 -23
  87. package/src/typography/Text.tsx +11 -9
  88. package/tsconfig.json +1 -0
@@ -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: {
@@ -57,51 +57,54 @@ export type SelectProps = ChakraSelectRootProps &
57
57
  *
58
58
  */
59
59
 
60
- export const Select = React.forwardRef<HTMLDivElement, SelectProps>(
61
- (props, ref) => {
62
- const {
63
- variant = "core",
64
- children,
65
- positioning,
66
- label,
67
- errorText,
68
- invalid,
69
- helperText,
70
- css,
71
- ...rest
72
- } = props;
73
- const recipe = useSlotRecipe({ key: "select" });
74
- const styles = recipe({ variant });
60
+ export const Select = ({
61
+ ref,
62
+ ...props
63
+ }: SelectProps & {
64
+ ref?: React.RefObject<HTMLDivElement>;
65
+ }) => {
66
+ const {
67
+ variant = "core",
68
+ children,
69
+ positioning,
70
+ label,
71
+ errorText,
72
+ invalid,
73
+ helperText,
74
+ css,
75
+ ...rest
76
+ } = props;
77
+ const recipe = useSlotRecipe({ key: "select" });
78
+ const styles = recipe({ variant });
75
79
 
76
- return (
77
- <Field
78
- errorText={errorText}
79
- invalid={invalid}
80
- helperText={helperText}
81
- required={props.required}
82
- id={rest.id}
83
- css={css}
80
+ return (
81
+ <Field
82
+ errorText={errorText}
83
+ invalid={invalid}
84
+ helperText={helperText}
85
+ required={props.required}
86
+ id={rest.id}
87
+ css={css}
88
+ >
89
+ <ChakraSelect.Root
90
+ {...rest}
91
+ ref={ref}
92
+ positioning={{ sameWidth: true, ...positioning }}
93
+ variant={variant}
94
+ css={styles.root}
95
+ position="relative"
84
96
  >
85
- <ChakraSelect.Root
86
- {...rest}
87
- ref={ref}
88
- positioning={{ sameWidth: true, ...positioning }}
89
- variant={variant}
90
- css={styles.root}
91
- position="relative"
92
- >
93
- <SelectTrigger data-attachable>
94
- <SelectValueText withPlaceholder={label ? true : false} />
95
- </SelectTrigger>
96
- {label && <SelectLabel css={styles.label}>{label}</SelectLabel>}
97
- <SelectContent css={styles.selectContent} baseStyle={css}>
98
- {children}
99
- </SelectContent>
100
- </ChakraSelect.Root>
101
- </Field>
102
- );
103
- },
104
- );
97
+ <SelectTrigger data-attachable>
98
+ <SelectValueText withPlaceholder={label ? true : false} />
99
+ </SelectTrigger>
100
+ {label && <SelectLabel css={styles.label}>{label}</SelectLabel>}
101
+ <SelectContent css={styles.selectContent} baseStyle={css}>
102
+ {children}
103
+ </SelectContent>
104
+ </ChakraSelect.Root>
105
+ </Field>
106
+ );
107
+ };
105
108
 
106
109
  export const SelectLabel = (props: SelectLabelProps) => {
107
110
  const { value } = useSelectContext();
@@ -114,49 +117,49 @@ export const SelectLabel = (props: SelectLabelProps) => {
114
117
  );
115
118
  };
116
119
 
117
- Select.displayName = "Select";
118
-
119
120
  type SelectItemProps = ChakraSelect.ItemProps & {
120
121
  children: React.ReactNode;
121
122
  description?: React.ReactNode;
122
123
  };
123
124
 
124
- export const SelectItem = React.forwardRef<HTMLDivElement, SelectItemProps>(
125
- (props, ref) => {
126
- const { item, children, description, ...rest } = props;
127
- const recipe = useSlotRecipe({ key: "select" });
128
- const styles = recipe();
129
- return (
130
- <ChakraSelect.Item item={item} {...rest} ref={ref} css={styles.item}>
131
- <Box width="100%">
132
- <ChakraSelect.ItemText display="flex">
133
- {children}
134
- </ChakraSelect.ItemText>
135
- {description && (
136
- <Box data-part="item-description" css={styles.itemDescription}>
137
- {description}
138
- </Box>
139
- )}
140
- </Box>
125
+ export const SelectItem = ({
126
+ ref,
127
+ ...props
128
+ }: SelectItemProps & {
129
+ ref?: React.RefObject<HTMLDivElement>;
130
+ }) => {
131
+ const { item, children, description, ...rest } = props;
132
+ const recipe = useSlotRecipe({ key: "select" });
133
+ const styles = recipe();
134
+ return (
135
+ <ChakraSelect.Item item={item} {...rest} ref={ref} css={styles.item}>
136
+ <Box width="100%">
137
+ <ChakraSelect.ItemText display="flex">{children}</ChakraSelect.ItemText>
138
+ {description && (
139
+ <Box data-part="item-description" css={styles.itemDescription}>
140
+ {description}
141
+ </Box>
142
+ )}
143
+ </Box>
141
144
 
142
- <ChakraSelect.ItemIndicator>
143
- <CheckmarkFill18Icon />
144
- </ChakraSelect.ItemIndicator>
145
- </ChakraSelect.Item>
146
- );
147
- },
148
- );
149
- SelectItem.displayName = "SelectItem";
145
+ <ChakraSelect.ItemIndicator>
146
+ <CheckmarkFill18Icon />
147
+ </ChakraSelect.ItemIndicator>
148
+ </ChakraSelect.Item>
149
+ );
150
+ };
150
151
 
151
152
  type SelectItemGroupProps = ChakraSelect.ItemGroupProps & {
152
153
  label: React.ReactNode;
153
154
  children: React.ReactNode;
154
155
  };
155
156
 
156
- export const SelectItemGroup = React.forwardRef<
157
- HTMLDivElement,
158
- SelectItemGroupProps
159
- >(function SelectItemGroup(props, ref) {
157
+ export const SelectItemGroup = function SelectItemGroup({
158
+ ref,
159
+ ...props
160
+ }: SelectItemGroupProps & {
161
+ ref?: React.RefObject<HTMLDivElement>;
162
+ }) {
160
163
  const { children, label, ...rest } = props;
161
164
  return (
162
165
  <ChakraSelect.ItemGroup {...rest} ref={ref}>
@@ -164,17 +167,19 @@ export const SelectItemGroup = React.forwardRef<
164
167
  {children}
165
168
  </ChakraSelect.ItemGroup>
166
169
  );
167
- });
170
+ };
168
171
 
169
172
  type SelectTriggerProps = ChakraSelect.ControlProps & {
170
173
  clearable?: boolean;
171
174
  children?: React.ReactNode;
172
175
  };
173
176
 
174
- export const SelectTrigger = React.forwardRef<
175
- HTMLButtonElement,
176
- SelectTriggerProps
177
- >(function SelectTrigger(props, ref) {
177
+ export const SelectTrigger = function SelectTrigger({
178
+ ref,
179
+ ...props
180
+ }: SelectTriggerProps & {
181
+ ref?: React.RefObject<HTMLButtonElement>;
182
+ }) {
178
183
  const { children, clearable, ...rest } = props;
179
184
  const recipe = useSlotRecipe({ key: "select" });
180
185
  const styles = recipe();
@@ -194,16 +199,18 @@ export const SelectTrigger = React.forwardRef<
194
199
  </ChakraSelect.IndicatorGroup>
195
200
  </ChakraSelect.Control>
196
201
  );
197
- });
202
+ };
198
203
 
199
204
  type SelectClearTriggerProps = ChakraSelect.ClearTriggerProps & {
200
205
  children?: React.ReactNode;
201
206
  };
202
207
 
203
- const SelectClearTrigger = React.forwardRef<
204
- HTMLButtonElement,
205
- SelectClearTriggerProps
206
- >(function SelectClearTrigger(props, ref) {
208
+ const SelectClearTrigger = function SelectClearTrigger({
209
+ ref,
210
+ ...props
211
+ }: SelectClearTriggerProps & {
212
+ ref?: React.RefObject<HTMLButtonElement>;
213
+ }) {
207
214
  return (
208
215
  <ChakraSelect.ClearTrigger asChild {...props} ref={ref}>
209
216
  <CloseButton
@@ -214,7 +221,7 @@ const SelectClearTrigger = React.forwardRef<
214
221
  />
215
222
  </ChakraSelect.ClearTrigger>
216
223
  );
217
- });
224
+ };
218
225
 
219
226
  type SelectContentProps = ChakraSelect.ContentProps & {
220
227
  portalled?: boolean;
@@ -222,12 +229,13 @@ type SelectContentProps = ChakraSelect.ContentProps & {
222
229
  baseStyle?: SystemStyleObject;
223
230
  };
224
231
 
225
- export const SelectContent = React.forwardRef<
226
- HTMLDivElement,
227
- SelectContentProps
228
- >(function SelectContent(props, ref) {
232
+ export const SelectContent = function SelectContent({
233
+ ref,
234
+ ...props
235
+ }: SelectContentProps & {
236
+ ref?: React.RefObject<HTMLDivElement>;
237
+ }) {
229
238
  const { portalled = true, portalRef, baseStyle, ...rest } = props;
230
-
231
239
  return (
232
240
  <Portal disabled={!portalled} container={portalRef}>
233
241
  <ChakraSelect.Positioner css={baseStyle}>
@@ -235,7 +243,7 @@ export const SelectContent = React.forwardRef<
235
243
  </ChakraSelect.Positioner>
236
244
  </Portal>
237
245
  );
238
- });
246
+ };
239
247
 
240
248
  type SelectValueTextProps = Omit<ChakraSelect.ValueTextProps, "children"> & {
241
249
  children?(items: CollectionItem[]): React.ReactNode;
@@ -243,10 +251,12 @@ type SelectValueTextProps = Omit<ChakraSelect.ValueTextProps, "children"> & {
243
251
  withPlaceholder?: boolean;
244
252
  };
245
253
 
246
- export const SelectValueText = React.forwardRef<
247
- HTMLSpanElement,
248
- SelectValueTextProps
249
- >(function SelectValueText(props, ref) {
254
+ export const SelectValueText = function SelectValueText({
255
+ ref,
256
+ ...props
257
+ }: SelectValueTextProps & {
258
+ ref?: React.RefObject<HTMLSpanElement>;
259
+ }) {
250
260
  const { children, withPlaceholder, placeholder, ...rest } = props;
251
261
  return (
252
262
  <ChakraSelect.ValueText
@@ -274,7 +284,7 @@ export const SelectValueText = React.forwardRef<
274
284
  </ChakraSelect.Context>
275
285
  </ChakraSelect.ValueText>
276
286
  );
277
- });
287
+ };
278
288
 
279
289
  export const SelectItemText = ChakraSelect.ItemText;
280
290
  export const SelectRoot = ChakraSelect.Root;
@@ -5,7 +5,7 @@ import {
5
5
  Switch as ChakraSwitch,
6
6
  useSlotRecipe,
7
7
  } from "@chakra-ui/react";
8
- import React, { forwardRef, PropsWithChildren } from "react";
8
+ import React, { PropsWithChildren } from "react";
9
9
 
10
10
  import { switchSlotRecipe } from "../theme/slot-recipes/switch";
11
11
  import { Field, FieldBaseProps } from "./Field";
@@ -45,45 +45,47 @@ export type SwitchProps = Exclude<
45
45
  * ```
46
46
  */
47
47
 
48
- export const Switch = forwardRef<HTMLInputElement, SwitchProps>(
49
- (props, ref) => {
50
- const {
51
- rootRef,
52
- size = "md",
53
- label,
54
- invalid,
55
- errorText,
56
- helperText,
57
- css,
58
- ...rest
59
- } = props;
60
- const recipe = useSlotRecipe({ key: "switch" });
61
- const styles = recipe({ size });
48
+ export const Switch = ({
49
+ ref,
50
+ ...props
51
+ }: SwitchProps & {
52
+ ref?: React.RefObject<HTMLInputElement>;
53
+ }) => {
54
+ const {
55
+ rootRef,
56
+ size = "md",
57
+ label,
58
+ invalid,
59
+ errorText,
60
+ helperText,
61
+ css,
62
+ ...rest
63
+ } = props;
64
+ const recipe = useSlotRecipe({ key: "switch" });
65
+ const styles = recipe({ size });
62
66
 
63
- return (
64
- <Field
65
- style={{ width: "auto" }}
66
- invalid={invalid}
67
- errorText={errorText}
68
- helperText={helperText}
69
- required={props.required}
70
- id={rest.id}
71
- css={css}
67
+ return (
68
+ <Field
69
+ style={{ width: "auto" }}
70
+ invalid={invalid}
71
+ errorText={errorText}
72
+ helperText={helperText}
73
+ required={props.required}
74
+ id={rest.id}
75
+ css={css}
76
+ >
77
+ <ChakraSwitch.Root
78
+ ref={rootRef}
79
+ {...rest}
80
+ checked={props.checked}
81
+ css={styles.root}
72
82
  >
73
- <ChakraSwitch.Root
74
- ref={rootRef}
75
- {...rest}
76
- checked={props.checked}
77
- css={styles.root}
78
- >
79
- <ChakraSwitch.HiddenInput ref={ref} />
80
- <ChakraSwitch.Control css={styles.control}>
81
- <ChakraSwitch.Thumb />
82
- </ChakraSwitch.Control>
83
- {label && <ChakraSwitch.Label>{label}</ChakraSwitch.Label>}
84
- </ChakraSwitch.Root>
85
- </Field>
86
- );
87
- },
88
- );
89
- Switch.displayName = "Switch";
83
+ <ChakraSwitch.HiddenInput ref={ref} />
84
+ <ChakraSwitch.Control css={styles.control}>
85
+ <ChakraSwitch.Thumb />
86
+ </ChakraSwitch.Control>
87
+ {label && <ChakraSwitch.Label>{label}</ChakraSwitch.Label>}
88
+ </ChakraSwitch.Root>
89
+ </Field>
90
+ );
91
+ };