@simplybusiness/mobius 6.9.0 → 6.9.2

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 (155) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/cjs/index.js +1110 -1185
  3. package/dist/esm/index.js +989 -1079
  4. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  5. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  6. package/dist/types/src/components/Accordion/Accordion.d.ts +4 -2
  7. package/dist/types/src/components/Accordion/AccordionLink.d.ts +1 -2
  8. package/dist/types/src/components/AddressLookup/AddressLookup.d.ts +4 -3
  9. package/dist/types/src/components/AddressLookup/types.d.ts +3 -2
  10. package/dist/types/src/components/Alert/Alert.d.ts +5 -4
  11. package/dist/types/src/components/Box/Box.d.ts +5 -5
  12. package/dist/types/src/components/Breadcrumbs/BreadcrumbItem.d.ts +6 -5
  13. package/dist/types/src/components/Breadcrumbs/Breadcrumbs.d.ts +5 -4
  14. package/dist/types/src/components/Button/Button.d.ts +5 -4
  15. package/dist/types/src/components/Checkbox/Checkbox.d.ts +5 -3
  16. package/dist/types/src/components/Checkbox/CheckboxGroup.d.ts +5 -3
  17. package/dist/types/src/components/Checkbox/types.d.ts +1 -3
  18. package/dist/types/src/components/Container/Container.d.ts +5 -4
  19. package/dist/types/src/components/DateField/DateField.d.ts +5 -3
  20. package/dist/types/src/components/Drawer/Content.d.ts +5 -3
  21. package/dist/types/src/components/Drawer/Drawer.d.ts +4 -3
  22. package/dist/types/src/components/Drawer/Header.d.ts +5 -3
  23. package/dist/types/src/components/Drawer/index.d.ts +12 -3
  24. package/dist/types/src/components/Drawer/types.d.ts +3 -2
  25. package/dist/types/src/components/DropdownMenu/DropdownMenu.d.ts +4 -2
  26. package/dist/types/src/components/DropdownMenu/Item.d.ts +4 -2
  27. package/dist/types/src/components/DropdownMenu/index.d.ts +2 -3
  28. package/dist/types/src/components/ExpandableText/ExpandableText.d.ts +7 -5
  29. package/dist/types/src/components/Fieldset/Fieldset.d.ts +5 -4
  30. package/dist/types/src/components/Flex/Flex.d.ts +5 -3
  31. package/dist/types/src/components/Flex/types.d.ts +1 -2
  32. package/dist/types/src/components/Grid/Grid.d.ts +5 -4
  33. package/dist/types/src/components/Grid/Item.d.ts +5 -4
  34. package/dist/types/src/components/Grid/index.d.ts +2 -3
  35. package/dist/types/src/components/Icon/Icon.d.ts +1 -1
  36. package/dist/types/src/components/Icon/types.d.ts +2 -3
  37. package/dist/types/src/components/Image/Image.d.ts +5 -4
  38. package/dist/types/src/components/Label/Label.d.ts +5 -4
  39. package/dist/types/src/components/Link/Link.d.ts +7 -6
  40. package/dist/types/src/components/List/List.d.ts +5 -4
  41. package/dist/types/src/components/List/ListItem.d.ts +5 -4
  42. package/dist/types/src/components/LoadingIndicator/LoadingIndicator.d.ts +5 -4
  43. package/dist/types/src/components/Logo/Logo.d.ts +5 -4
  44. package/dist/types/src/components/MaskedField/MaskedField.d.ts +4 -2
  45. package/dist/types/src/components/Modal/Content.d.ts +5 -3
  46. package/dist/types/src/components/Modal/Header.d.ts +5 -3
  47. package/dist/types/src/components/Modal/Modal.d.ts +4 -3
  48. package/dist/types/src/components/Modal/index.d.ts +12 -3
  49. package/dist/types/src/components/Modal/types.d.ts +3 -2
  50. package/dist/types/src/components/NumberField/NumberField.d.ts +5 -4
  51. package/dist/types/src/components/Option/Option.d.ts +5 -4
  52. package/dist/types/src/components/PasswordField/PasswordField.d.ts +5 -3
  53. package/dist/types/src/components/Popover/Popover.d.ts +1 -2
  54. package/dist/types/src/components/Progress/Progress.d.ts +5 -4
  55. package/dist/types/src/components/Radio/Radio.d.ts +5 -4
  56. package/dist/types/src/components/Radio/RadioGroup.d.ts +5 -4
  57. package/dist/types/src/components/SVG/SVG.d.ts +5 -4
  58. package/dist/types/src/components/Select/Select.d.ts +5 -4
  59. package/dist/types/src/components/Stack/Stack.d.ts +4 -2
  60. package/dist/types/src/components/Switch/Switch.d.ts +5 -3
  61. package/dist/types/src/components/Table/Body.d.ts +4 -2
  62. package/dist/types/src/components/Table/Cell.d.ts +4 -2
  63. package/dist/types/src/components/Table/Foot.d.ts +4 -2
  64. package/dist/types/src/components/Table/Head.d.ts +4 -2
  65. package/dist/types/src/components/Table/HeaderCell.d.ts +4 -2
  66. package/dist/types/src/components/Table/Row.d.ts +4 -2
  67. package/dist/types/src/components/Table/Table.d.ts +4 -2
  68. package/dist/types/src/components/Table/index.d.ts +7 -8
  69. package/dist/types/src/components/Text/Text.d.ts +5 -4
  70. package/dist/types/src/components/TextArea/TextArea.d.ts +5 -4
  71. package/dist/types/src/components/TextAreaInput/TextAreaInput.d.ts +5 -4
  72. package/dist/types/src/components/TextField/TextField.d.ts +4 -2
  73. package/dist/types/src/components/TextOrHTML/TextOrHTML.d.ts +6 -5
  74. package/dist/types/src/components/Title/Title.d.ts +5 -4
  75. package/dist/types/src/components/Trust/Trust.d.ts +2 -3
  76. package/dist/types/src/components/Trust/types.d.ts +1 -2
  77. package/dist/types/src/types/components.d.ts +4 -2
  78. package/dist/types/src/utils/mergeRefs.d.ts +1 -1
  79. package/package.json +1 -1
  80. package/src/components/Accordion/Accordion.tsx +3 -8
  81. package/src/components/Accordion/AccordionLink.tsx +1 -2
  82. package/src/components/AddressLookup/AddressLookup.tsx +55 -64
  83. package/src/components/AddressLookup/types.tsx +10 -8
  84. package/src/components/Alert/Alert.tsx +48 -54
  85. package/src/components/Box/Box.tsx +47 -59
  86. package/src/components/Breadcrumbs/BreadcrumbItem.tsx +7 -11
  87. package/src/components/Breadcrumbs/Breadcrumbs.tsx +4 -10
  88. package/src/components/Button/Button.tsx +60 -65
  89. package/src/components/Checkbox/Checkbox.tsx +4 -8
  90. package/src/components/Checkbox/CheckboxGroup.tsx +4 -14
  91. package/src/components/Checkbox/types.ts +1 -4
  92. package/src/components/Combobox/Combobox.tsx +314 -313
  93. package/src/components/Container/Container.tsx +10 -15
  94. package/src/components/DateField/DateField.tsx +83 -90
  95. package/src/components/Drawer/Content.tsx +5 -9
  96. package/src/components/Drawer/Drawer.tsx +3 -5
  97. package/src/components/Drawer/Header.tsx +18 -22
  98. package/src/components/Drawer/types.ts +3 -2
  99. package/src/components/DropdownMenu/DropdownMenu.stories.tsx +12 -15
  100. package/src/components/DropdownMenu/DropdownMenu.test.tsx +2 -3
  101. package/src/components/DropdownMenu/DropdownMenu.tsx +3 -13
  102. package/src/components/DropdownMenu/Item.tsx +35 -38
  103. package/src/components/DropdownMenu/index.tsx +2 -4
  104. package/src/components/ExpandableText/ExpandableText.tsx +8 -9
  105. package/src/components/Fieldset/Fieldset.tsx +20 -24
  106. package/src/components/Flex/Flex.tsx +23 -27
  107. package/src/components/Flex/types.ts +1 -3
  108. package/src/components/Grid/Grid.tsx +31 -37
  109. package/src/components/Grid/Item.tsx +40 -44
  110. package/src/components/Grid/index.tsx +2 -4
  111. package/src/components/Icon/Icon.mdx +17 -0
  112. package/src/components/Icon/Icon.stories.tsx +6 -8
  113. package/src/components/Icon/Icon.tsx +2 -0
  114. package/src/components/Icon/types.ts +2 -4
  115. package/src/components/Image/Image.tsx +10 -16
  116. package/src/components/Label/Label.tsx +11 -17
  117. package/src/components/Link/Link.tsx +42 -43
  118. package/src/components/List/List.tsx +34 -39
  119. package/src/components/List/ListItem.tsx +27 -32
  120. package/src/components/LoadingIndicator/LoadingIndicator.tsx +3 -10
  121. package/src/components/Logo/Logo.tsx +42 -47
  122. package/src/components/MaskedField/MaskedField.tsx +6 -10
  123. package/src/components/Modal/Content.tsx +5 -9
  124. package/src/components/Modal/Header.tsx +17 -21
  125. package/src/components/Modal/Modal.tsx +3 -5
  126. package/src/components/Modal/types.ts +3 -2
  127. package/src/components/NumberField/NumberField.tsx +3 -16
  128. package/src/components/Option/Option.tsx +9 -14
  129. package/src/components/PasswordField/PasswordField.tsx +26 -27
  130. package/src/components/Popover/Popover.tsx +1 -3
  131. package/src/components/Progress/Progress.tsx +73 -81
  132. package/src/components/Radio/Radio.tsx +166 -174
  133. package/src/components/Radio/RadioGroup.tsx +3 -10
  134. package/src/components/SVG/SVG.tsx +20 -26
  135. package/src/components/Select/Select.tsx +85 -89
  136. package/src/components/Stack/Stack.tsx +12 -15
  137. package/src/components/Switch/Switch.tsx +2 -6
  138. package/src/components/Table/Body.tsx +4 -7
  139. package/src/components/Table/Cell.tsx +8 -12
  140. package/src/components/Table/Foot.tsx +4 -7
  141. package/src/components/Table/Head.tsx +4 -7
  142. package/src/components/Table/HeaderCell.tsx +8 -11
  143. package/src/components/Table/Row.tsx +4 -8
  144. package/src/components/Table/Table.tsx +4 -8
  145. package/src/components/Table/index.tsx +7 -9
  146. package/src/components/Text/Text.tsx +16 -22
  147. package/src/components/TextArea/TextArea.tsx +44 -52
  148. package/src/components/TextAreaInput/TextAreaInput.tsx +3 -10
  149. package/src/components/TextField/TextField.tsx +102 -105
  150. package/src/components/TextOrHTML/TextOrHTML.tsx +35 -41
  151. package/src/components/Title/Title.tsx +21 -27
  152. package/src/components/Trust/Trust.tsx +74 -76
  153. package/src/components/Trust/types.ts +1 -3
  154. package/src/types/components.ts +4 -8
  155. package/src/utils/mergeRefs.ts +1 -1
@@ -1,11 +1,10 @@
1
1
  "use client";
2
2
 
3
3
  import classNames from "classnames/dedupe";
4
- import type { ReactElement, ReactNode, Ref, RefAttributes } from "react";
4
+ import type { ReactElement, ReactNode, RefAttributes } from "react";
5
5
  import {
6
6
  Children,
7
7
  cloneElement,
8
- forwardRef,
9
8
  isValidElement,
10
9
  useCallback,
11
10
  useEffect,
@@ -15,7 +14,6 @@ import {
15
14
  } from "react";
16
15
  import { useValidationClasses } from "../../hooks";
17
16
  import type { Validation } from "../../types";
18
- import type { ForwardedRefComponent } from "../../types/components";
19
17
  import type { DOMProps } from "../../types/dom";
20
18
  import type { HTMLElementEvent } from "../../types/events";
21
19
  import { spaceDelimitedList } from "../../utils/spaceDelimitedList";
@@ -67,8 +65,6 @@ export interface RadioGroupProps
67
65
  name?: string;
68
66
  }
69
67
 
70
- export type RadioGroupRef = Ref<RadioGroupElementType>;
71
-
72
68
  const getDefaultVal = (children: ReactNode, defaultValue?: string) => {
73
69
  if (Array.isArray(children) && defaultValue) {
74
70
  const option = children?.find(item => item.props.value === defaultValue);
@@ -81,10 +77,7 @@ const getDefaultVal = (children: ReactNode, defaultValue?: string) => {
81
77
  return "";
82
78
  };
83
79
 
84
- const RadioGroup: ForwardedRefComponent<
85
- RadioGroupProps,
86
- RadioGroupElementType
87
- > = forwardRef((props: RadioGroupProps, ref: RadioGroupRef) => {
80
+ const RadioGroup = ({ ref, ...props }: RadioGroupProps) => {
88
81
  const {
89
82
  label,
90
83
  isDisabled = false,
@@ -224,7 +217,7 @@ const RadioGroup: ForwardedRefComponent<
224
217
  </Stack>
225
218
  </div>
226
219
  );
227
- });
220
+ };
228
221
 
229
222
  RadioGroup.displayName = "RadioGroup";
230
223
  export { RadioGroup };
@@ -1,39 +1,33 @@
1
- import type { Ref, RefAttributes } from "react";
2
- import { forwardRef, Children } from "react";
1
+ import type { RefAttributes } from "react";
2
+ import { Children } from "react";
3
3
  import classNames from "classnames/dedupe";
4
4
  import type { DOMProps } from "../../types/dom";
5
- import type { ForwardedRefComponent } from "../../types/components";
6
5
 
7
6
  export interface SVGProps extends DOMProps, RefAttributes<SVGSVGElement> {
8
7
  children: React.ReactElement<React.SVGProps<SVGSVGElement>>;
9
8
  className?: string;
10
9
  style?: React.CSSProperties;
11
10
  }
11
+ const SVG = ({ ref, ...props }: SVGProps) => {
12
+ const { children, className, ...otherProps } = props;
12
13
 
13
- export type SVGRef = Ref<SVGSVGElement>;
14
+ const classes = classNames("mobius", "mobius-svg", className);
15
+ const svgNode = Children.only(children);
16
+ // Remove originalType and mdxType props
17
+ const { children: svgChildren, viewBox, xmlns } = svgNode.props;
14
18
 
15
- const SVG: ForwardedRefComponent<SVGProps, SVGSVGElement> = forwardRef(
16
- (props: SVGProps, ref: SVGRef) => {
17
- const { children, className, ...otherProps } = props;
18
-
19
- const classes = classNames("mobius", "mobius-svg", className);
20
- const svgNode = Children.only(children);
21
- // Remove originalType and mdxType props
22
- const { children: svgChildren, viewBox, xmlns } = svgNode.props;
23
-
24
- return (
25
- <svg
26
- viewBox={viewBox}
27
- xmlns={xmlns}
28
- ref={ref}
29
- {...otherProps}
30
- className={classes}
31
- >
32
- {svgChildren}
33
- </svg>
34
- );
35
- },
36
- );
19
+ return (
20
+ <svg
21
+ viewBox={viewBox}
22
+ xmlns={xmlns}
23
+ ref={ref}
24
+ {...otherProps}
25
+ className={classes}
26
+ >
27
+ {svgChildren}
28
+ </svg>
29
+ );
30
+ };
37
31
 
38
32
  SVG.displayName = "SVG";
39
33
  export { SVG };
@@ -2,13 +2,12 @@
2
2
 
3
3
  import { chevronDown } from "@simplybusiness/icons";
4
4
  import classNames from "classnames/dedupe";
5
- import type { ChangeEvent, ReactElement, Ref, RefAttributes } from "react";
6
- import { forwardRef, useId } from "react";
5
+ import type { ChangeEvent, ReactElement, RefAttributes } from "react";
6
+ import { useId } from "react";
7
7
  import { useValidationClasses } from "../../hooks";
8
8
  import type { UseLabelProps } from "../../hooks/useLabel";
9
9
  import { useLabel } from "../../hooks/useLabel";
10
10
  import type { DOMProps, Validation } from "../../types";
11
- import type { ForwardedRefComponent } from "../../types/components";
12
11
  import { spaceDelimitedList } from "../../utils/spaceDelimitedList";
13
12
  import { ErrorMessage } from "../ErrorMessage";
14
13
  import { Icon } from "../Icon";
@@ -33,99 +32,96 @@ export interface SelectProps
33
32
  isDisabled?: boolean;
34
33
  }
35
34
 
36
- export type SelectRef = Ref<SelectElementType>;
35
+ const Select = ({ ref, ...props }: SelectProps) => {
36
+ const {
37
+ label,
38
+ onChange,
39
+ validationState,
40
+ isInvalid,
41
+ errorMessage,
42
+ isDisabled = false,
43
+ isRequired,
44
+ ...otherProps
45
+ } = props;
37
46
 
38
- const Select: ForwardedRefComponent<SelectProps, SelectElementType> =
39
- forwardRef((props: SelectProps, ref: SelectRef) => {
40
- const {
41
- label,
42
- onChange,
43
- validationState,
44
- isInvalid,
45
- errorMessage,
46
- isDisabled = false,
47
- isRequired,
48
- ...otherProps
49
- } = props;
50
-
51
- const { labelProps, fieldProps } = useLabel({
52
- label,
53
- ...otherProps,
54
- });
47
+ const { labelProps, fieldProps } = useLabel({
48
+ label,
49
+ ...otherProps,
50
+ });
55
51
 
56
- const validationClasses = useValidationClasses({
57
- validationState,
58
- isInvalid,
59
- });
52
+ const validationClasses = useValidationClasses({
53
+ validationState,
54
+ isInvalid,
55
+ });
60
56
 
61
- const stateClasses = {
62
- "--is-disabled": isDisabled,
63
- "--is-required": typeof isRequired === "boolean" && isRequired,
64
- "--is-optional": typeof isRequired === "boolean" && !isRequired,
65
- };
57
+ const stateClasses = {
58
+ "--is-disabled": isDisabled,
59
+ "--is-required": typeof isRequired === "boolean" && isRequired,
60
+ "--is-optional": typeof isRequired === "boolean" && !isRequired,
61
+ };
66
62
 
67
- const sharedClasses = classNames(validationClasses, stateClasses);
63
+ const sharedClasses = classNames(validationClasses, stateClasses);
68
64
 
69
- const wrapperClasses = classNames(
70
- "mobius-select__wrapper",
71
- sharedClasses,
72
- otherProps.className,
73
- );
74
- const selectClasses = classNames(
75
- "mobius-select",
76
- sharedClasses,
77
- otherProps.className,
78
- );
79
- const labelClasses = classNames(
80
- "mobius-label",
81
- sharedClasses,
82
- otherProps.className,
83
- );
84
- const iconClasses = classNames("mobius-select__icon", sharedClasses);
85
- const errorMessageId = useId();
86
- const shouldErrorMessageShow = errorMessage ? errorMessageId : undefined;
87
- const describedBy = spaceDelimitedList([
88
- shouldErrorMessageShow,
89
- props["aria-describedby"],
90
- ]);
65
+ const wrapperClasses = classNames(
66
+ "mobius-select__wrapper",
67
+ sharedClasses,
68
+ otherProps.className,
69
+ );
70
+ const selectClasses = classNames(
71
+ "mobius-select",
72
+ sharedClasses,
73
+ otherProps.className,
74
+ );
75
+ const labelClasses = classNames(
76
+ "mobius-label",
77
+ sharedClasses,
78
+ otherProps.className,
79
+ );
80
+ const iconClasses = classNames("mobius-select__icon", sharedClasses);
81
+ const errorMessageId = useId();
82
+ const shouldErrorMessageShow = errorMessage ? errorMessageId : undefined;
83
+ const describedBy = spaceDelimitedList([
84
+ shouldErrorMessageShow,
85
+ props["aria-describedby"],
86
+ ]);
91
87
 
92
- const handleChange = (e: ChangeEvent<HTMLSelectElement>) => {
93
- if (onChange) {
94
- onChange(e);
95
- }
96
- };
88
+ const handleChange = (e: ChangeEvent<HTMLSelectElement>) => {
89
+ if (onChange) {
90
+ onChange(e);
91
+ }
92
+ };
97
93
 
98
- return (
99
- <Stack className="mobius mobius-select__outer" gap="xs">
100
- {label && (
101
- <Label {...labelProps} className={labelClasses}>
102
- {label}
103
- </Label>
104
- )}
105
- <div className={wrapperClasses}>
106
- <select
107
- {...otherProps}
108
- {...fieldProps}
109
- ref={ref}
110
- multiple={false}
111
- className={selectClasses}
112
- disabled={isDisabled}
113
- aria-invalid={!!errorMessage}
114
- aria-describedby={describedBy}
115
- aria-required={isRequired}
116
- required={isRequired}
117
- onChange={handleChange}
118
- />
119
- <span className={iconClasses}>
120
- <Icon icon={chevronDown} />
121
- </span>
122
- </div>
123
- {errorMessage && (
124
- <ErrorMessage id={errorMessageId} errorMessage={errorMessage} />
125
- )}
126
- </Stack>
127
- );
128
- });
94
+ return (
95
+ <Stack className="mobius mobius-select__outer" gap="xs">
96
+ {label && (
97
+ <Label {...labelProps} className={labelClasses}>
98
+ {label}
99
+ </Label>
100
+ )}
101
+ <div className={wrapperClasses}>
102
+ <select
103
+ {...otherProps}
104
+ {...fieldProps}
105
+ ref={ref}
106
+ multiple={false}
107
+ className={selectClasses}
108
+ disabled={isDisabled}
109
+ aria-invalid={!!errorMessage}
110
+ aria-describedby={describedBy}
111
+ aria-required={isRequired}
112
+ required={isRequired}
113
+ onChange={handleChange}
114
+ />
115
+ <span className={iconClasses}>
116
+ <Icon icon={chevronDown} />
117
+ </span>
118
+ </div>
119
+ {errorMessage && (
120
+ <ErrorMessage id={errorMessageId} errorMessage={errorMessage} />
121
+ )}
122
+ </Stack>
123
+ );
124
+ };
129
125
 
130
126
  Select.displayName = "Select";
131
127
  export { Select };
@@ -1,9 +1,7 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
2
  import type React from "react";
3
- import { forwardRef } from "react";
4
3
  import classNames from "classnames/dedupe";
5
4
  import type { DOMProps } from "../../types/dom";
6
- import type { ForwardedRefComponent } from "../../types/components";
7
5
  import type { SpacingType } from "../../types";
8
6
 
9
7
  export type StackElementType = HTMLDivElement;
@@ -19,20 +17,19 @@ export interface StackProps extends DOMProps, RefAttributes<StackElementType> {
19
17
 
20
18
  export type StackRef = Ref<StackElementType>;
21
19
 
22
- export const Stack: ForwardedRefComponent<StackProps, StackElementType> =
23
- forwardRef((props: StackProps, ref: StackRef) => {
24
- const { elementType: Element = "div", gap, ...otherProps } = props;
20
+ export const Stack = ({ ref, ...props }: StackProps) => {
21
+ const { elementType: Element = "div", gap, ...otherProps } = props;
25
22
 
26
- const classes = classNames(
27
- "mobius",
28
- "mobius-stack",
29
- {
30
- [`--gap-${gap}`]: gap,
31
- },
32
- otherProps.className,
33
- );
23
+ const classes = classNames(
24
+ "mobius",
25
+ "mobius-stack",
26
+ {
27
+ [`--gap-${gap}`]: gap,
28
+ },
29
+ otherProps.className,
30
+ );
34
31
 
35
- return <Element ref={ref} {...otherProps} className={classes} />;
36
- });
32
+ return <Element ref={ref} {...otherProps} className={classes} />;
33
+ };
37
34
 
38
35
  Stack.displayName = "Stack";
@@ -2,9 +2,7 @@
2
2
 
3
3
  import {
4
4
  type ChangeEvent,
5
- type Ref,
6
5
  type RefAttributes,
7
- forwardRef,
8
6
  useState,
9
7
  useEffect,
10
8
  } from "react";
@@ -24,9 +22,7 @@ export interface SwitchProps
24
22
  isDisabled?: boolean;
25
23
  }
26
24
 
27
- export type SwitchRef = Ref<SwitchElementType>;
28
-
29
- const Switch = forwardRef<HTMLLabelElement, SwitchProps>((props, ref) => {
25
+ const Switch = ({ ref, ...props }: SwitchProps) => {
30
26
  const {
31
27
  checked = false,
32
28
  className,
@@ -73,7 +69,7 @@ const Switch = forwardRef<HTMLLabelElement, SwitchProps>((props, ref) => {
73
69
  <span className="mobius-switch__slider"></span>
74
70
  </label>
75
71
  );
76
- });
72
+ };
77
73
 
78
74
  Switch.displayName = "Switch";
79
75
  export { Switch };
@@ -1,7 +1,5 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
- import { forwardRef } from "react";
3
2
  import classNames from "classnames/dedupe";
4
- import type { ForwardedRefComponent } from "../../types/components";
5
3
 
6
4
  export interface BodyProps extends RefAttributes<HTMLTableSectionElement> {
7
5
  children?: ReactNode;
@@ -10,12 +8,11 @@ export interface BodyProps extends RefAttributes<HTMLTableSectionElement> {
10
8
 
11
9
  export type BodyRef = Ref<HTMLTableSectionElement>;
12
10
 
13
- const Body: ForwardedRefComponent<BodyProps, HTMLTableSectionElement> =
14
- forwardRef((props: BodyProps, ref: BodyRef) => {
15
- const classes = classNames("mobius", "mobius-table__body", props.className);
11
+ const Body = ({ ref, ...props }: BodyProps) => {
12
+ const classes = classNames("mobius", "mobius-table__body", props.className);
16
13
 
17
- return <tbody ref={ref} {...props} className={classes} />;
18
- });
14
+ return <tbody ref={ref} {...props} className={classes} />;
15
+ };
19
16
 
20
17
  Body.displayName = "Table.Body";
21
18
  export { Body };
@@ -1,7 +1,5 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
- import { forwardRef } from "react";
3
2
  import classNames from "classnames/dedupe";
4
- import type { ForwardedRefComponent } from "../../types/components";
5
3
 
6
4
  export interface CellProps extends RefAttributes<HTMLTableCellElement> {
7
5
  children?: ReactNode;
@@ -12,17 +10,15 @@ export interface CellProps extends RefAttributes<HTMLTableCellElement> {
12
10
 
13
11
  export type CellRef = Ref<HTMLTableCellElement>;
14
12
 
15
- const Cell: ForwardedRefComponent<CellProps, HTMLTableCellElement> = forwardRef(
16
- (props: CellProps, ref: CellRef) => {
17
- const classes = classNames(
18
- "mobius",
19
- "mobius-table__body-cell",
20
- props.className,
21
- );
13
+ const Cell = ({ ref, ...props }: CellProps) => {
14
+ const classes = classNames(
15
+ "mobius",
16
+ "mobius-table__body-cell",
17
+ props.className,
18
+ );
22
19
 
23
- return <td ref={ref} {...props} className={classes} />;
24
- },
25
- );
20
+ return <td ref={ref} {...props} className={classes} />;
21
+ };
26
22
 
27
23
  Cell.displayName = "Table.Cell";
28
24
  export { Cell };
@@ -1,7 +1,5 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
- import { forwardRef } from "react";
3
2
  import classNames from "classnames/dedupe";
4
- import type { ForwardedRefComponent } from "../../types/components";
5
3
 
6
4
  export interface FootProps extends RefAttributes<HTMLTableSectionElement> {
7
5
  children?: ReactNode;
@@ -10,12 +8,11 @@ export interface FootProps extends RefAttributes<HTMLTableSectionElement> {
10
8
 
11
9
  export type FootRef = Ref<HTMLTableSectionElement>;
12
10
 
13
- const Foot: ForwardedRefComponent<FootProps, HTMLTableSectionElement> =
14
- forwardRef((props: FootProps, ref: FootRef) => {
15
- const classes = classNames("mobius", "mobius-table__foot", props.className);
11
+ const Foot = ({ ref, ...props }: FootProps) => {
12
+ const classes = classNames("mobius", "mobius-table__foot", props.className);
16
13
 
17
- return <tfoot ref={ref} {...props} className={classes} />;
18
- });
14
+ return <tfoot ref={ref} {...props} className={classes} />;
15
+ };
19
16
 
20
17
  Foot.displayName = "Table.Foot";
21
18
  export { Foot };
@@ -1,7 +1,5 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
- import { forwardRef } from "react";
3
2
  import classNames from "classnames/dedupe";
4
- import type { ForwardedRefComponent } from "../../types/components";
5
3
 
6
4
  export interface HeadProps extends RefAttributes<HTMLTableSectionElement> {
7
5
  children?: ReactNode;
@@ -10,12 +8,11 @@ export interface HeadProps extends RefAttributes<HTMLTableSectionElement> {
10
8
 
11
9
  export type HeadRef = Ref<HTMLTableSectionElement>;
12
10
 
13
- const Head: ForwardedRefComponent<HeadProps, HTMLTableSectionElement> =
14
- forwardRef((props: HeadProps, ref: HeadRef) => {
15
- const classes = classNames("mobius", "mobius-table__head", props.className);
11
+ const Head = ({ ref, ...props }: HeadProps) => {
12
+ const classes = classNames("mobius", "mobius-table__head", props.className);
16
13
 
17
- return <thead ref={ref} {...props} className={classes} />;
18
- });
14
+ return <thead ref={ref} {...props} className={classes} />;
15
+ };
19
16
 
20
17
  Head.displayName = "Table.Head";
21
18
  export { Head };
@@ -1,7 +1,5 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
- import { forwardRef } from "react";
3
2
  import classNames from "classnames/dedupe";
4
- import type { ForwardedRefComponent } from "../../types/components";
5
3
 
6
4
  export interface HeaderCellProps extends RefAttributes<HTMLTableCellElement> {
7
5
  children?: ReactNode;
@@ -12,16 +10,15 @@ export interface HeaderCellProps extends RefAttributes<HTMLTableCellElement> {
12
10
 
13
11
  export type HeaderCellRef = Ref<HTMLTableCellElement>;
14
12
 
15
- const HeaderCell: ForwardedRefComponent<HeaderCellProps, HTMLTableCellElement> =
16
- forwardRef((props: HeaderCellProps, ref: HeaderCellRef) => {
17
- const classes = classNames(
18
- "mobius",
19
- "mobius-table__head-cell",
20
- props.className,
21
- );
13
+ const HeaderCell = ({ ref, ...props }: HeaderCellProps) => {
14
+ const classes = classNames(
15
+ "mobius",
16
+ "mobius-table__head-cell",
17
+ props.className,
18
+ );
22
19
 
23
- return <th {...props} ref={ref} className={classes} />;
24
- });
20
+ return <th {...props} ref={ref} className={classes} />;
21
+ };
25
22
 
26
23
  HeaderCell.displayName = "Table.HeaderCell";
27
24
  export { HeaderCell };
@@ -1,7 +1,5 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
- import { forwardRef } from "react";
3
2
  import classNames from "classnames/dedupe";
4
- import type { ForwardedRefComponent } from "../../types/components";
5
3
 
6
4
  export interface RowProps extends RefAttributes<HTMLTableRowElement> {
7
5
  children?: ReactNode;
@@ -10,13 +8,11 @@ export interface RowProps extends RefAttributes<HTMLTableRowElement> {
10
8
 
11
9
  export type RowRef = Ref<HTMLTableRowElement>;
12
10
 
13
- const Row: ForwardedRefComponent<RowProps, HTMLTableRowElement> = forwardRef(
14
- (props: RowProps, ref: RowRef) => {
15
- const classes = classNames("mobius", "mobius-table__row", props.className);
11
+ const Row = ({ ref, ...props }: RowProps) => {
12
+ const classes = classNames("mobius", "mobius-table__row", props.className);
16
13
 
17
- return <tr ref={ref} {...props} className={classes} />;
18
- },
19
- );
14
+ return <tr ref={ref} {...props} className={classes} />;
15
+ };
20
16
 
21
17
  Row.displayName = "Table.Row";
22
18
  export { Row };
@@ -1,8 +1,6 @@
1
1
  import type { Ref, RefAttributes, ReactNode } from "react";
2
- import { forwardRef } from "react";
3
2
  import classNames from "classnames/dedupe";
4
3
  import type { DOMProps } from "../../types/dom";
5
- import type { ForwardedRefComponent } from "../../types/components";
6
4
 
7
5
  export type TableElementType = HTMLTableElement;
8
6
 
@@ -13,13 +11,11 @@ export interface TableProps extends DOMProps, RefAttributes<TableElementType> {
13
11
 
14
12
  export type TableRef = Ref<TableElementType>;
15
13
 
16
- const Table: ForwardedRefComponent<TableProps, TableElementType> = forwardRef(
17
- (props: TableProps, ref: TableRef) => {
18
- const classes = classNames("mobius", "mobius-table", props.className);
14
+ const Table = ({ ref, ...props }: TableProps) => {
15
+ const classes = classNames("mobius", "mobius-table", props.className);
19
16
 
20
- return <table ref={ref} {...props} className={classes} />;
21
- },
22
- );
17
+ return <table ref={ref} {...props} className={classes} />;
18
+ };
23
19
 
24
20
  Table.displayName = "Table";
25
21
  export { Table };
@@ -1,4 +1,3 @@
1
- import type { ForwardedRefComponent } from "../../types/components";
2
1
  import { Table as TableComponent } from "./Table";
3
2
  import { Head } from "./Head";
4
3
  import { Body } from "./Body";
@@ -30,14 +29,13 @@ import type {
30
29
  CellRef as TableCellRef,
31
30
  } from "./Cell";
32
31
 
33
- export interface TableCompound
34
- extends ForwardedRefComponent<TableProps, HTMLTableElement> {
35
- Head: ForwardedRefComponent<TableHeadProps, HTMLTableSectionElement>;
36
- Body: ForwardedRefComponent<TableBodyProps, HTMLTableSectionElement>;
37
- Foot: ForwardedRefComponent<TableFootProps, HTMLTableSectionElement>;
38
- Row: ForwardedRefComponent<TableRowProps, HTMLTableRowElement>;
39
- HeaderCell: ForwardedRefComponent<TableHeaderCellProps, HTMLTableCellElement>;
40
- Cell: ForwardedRefComponent<TableCellProps, HTMLTableCellElement>;
32
+ export interface TableCompound extends React.FC<TableProps> {
33
+ Head: React.FC<TableHeadProps>;
34
+ Body: React.FC<TableBodyProps>;
35
+ Foot: React.FC<TableFootProps>;
36
+ Row: React.FC<TableRowProps>;
37
+ HeaderCell: React.FC<TableHeaderCellProps>;
38
+ Cell: React.FC<TableCellProps>;
41
39
  }
42
40
 
43
41
  const Table: TableCompound = Object.assign(TableComponent, {