@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.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/index.js +1110 -1185
- package/dist/esm/index.js +989 -1079
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/components/Accordion/Accordion.d.ts +4 -2
- package/dist/types/src/components/Accordion/AccordionLink.d.ts +1 -2
- package/dist/types/src/components/AddressLookup/AddressLookup.d.ts +4 -3
- package/dist/types/src/components/AddressLookup/types.d.ts +3 -2
- package/dist/types/src/components/Alert/Alert.d.ts +5 -4
- package/dist/types/src/components/Box/Box.d.ts +5 -5
- package/dist/types/src/components/Breadcrumbs/BreadcrumbItem.d.ts +6 -5
- package/dist/types/src/components/Breadcrumbs/Breadcrumbs.d.ts +5 -4
- package/dist/types/src/components/Button/Button.d.ts +5 -4
- package/dist/types/src/components/Checkbox/Checkbox.d.ts +5 -3
- package/dist/types/src/components/Checkbox/CheckboxGroup.d.ts +5 -3
- package/dist/types/src/components/Checkbox/types.d.ts +1 -3
- package/dist/types/src/components/Container/Container.d.ts +5 -4
- package/dist/types/src/components/DateField/DateField.d.ts +5 -3
- package/dist/types/src/components/Drawer/Content.d.ts +5 -3
- package/dist/types/src/components/Drawer/Drawer.d.ts +4 -3
- package/dist/types/src/components/Drawer/Header.d.ts +5 -3
- package/dist/types/src/components/Drawer/index.d.ts +12 -3
- package/dist/types/src/components/Drawer/types.d.ts +3 -2
- package/dist/types/src/components/DropdownMenu/DropdownMenu.d.ts +4 -2
- package/dist/types/src/components/DropdownMenu/Item.d.ts +4 -2
- package/dist/types/src/components/DropdownMenu/index.d.ts +2 -3
- package/dist/types/src/components/ExpandableText/ExpandableText.d.ts +7 -5
- package/dist/types/src/components/Fieldset/Fieldset.d.ts +5 -4
- package/dist/types/src/components/Flex/Flex.d.ts +5 -3
- package/dist/types/src/components/Flex/types.d.ts +1 -2
- package/dist/types/src/components/Grid/Grid.d.ts +5 -4
- package/dist/types/src/components/Grid/Item.d.ts +5 -4
- package/dist/types/src/components/Grid/index.d.ts +2 -3
- package/dist/types/src/components/Icon/Icon.d.ts +1 -1
- package/dist/types/src/components/Icon/types.d.ts +2 -3
- package/dist/types/src/components/Image/Image.d.ts +5 -4
- package/dist/types/src/components/Label/Label.d.ts +5 -4
- package/dist/types/src/components/Link/Link.d.ts +7 -6
- package/dist/types/src/components/List/List.d.ts +5 -4
- package/dist/types/src/components/List/ListItem.d.ts +5 -4
- package/dist/types/src/components/LoadingIndicator/LoadingIndicator.d.ts +5 -4
- package/dist/types/src/components/Logo/Logo.d.ts +5 -4
- package/dist/types/src/components/MaskedField/MaskedField.d.ts +4 -2
- package/dist/types/src/components/Modal/Content.d.ts +5 -3
- package/dist/types/src/components/Modal/Header.d.ts +5 -3
- package/dist/types/src/components/Modal/Modal.d.ts +4 -3
- package/dist/types/src/components/Modal/index.d.ts +12 -3
- package/dist/types/src/components/Modal/types.d.ts +3 -2
- package/dist/types/src/components/NumberField/NumberField.d.ts +5 -4
- package/dist/types/src/components/Option/Option.d.ts +5 -4
- package/dist/types/src/components/PasswordField/PasswordField.d.ts +5 -3
- package/dist/types/src/components/Popover/Popover.d.ts +1 -2
- package/dist/types/src/components/Progress/Progress.d.ts +5 -4
- package/dist/types/src/components/Radio/Radio.d.ts +5 -4
- package/dist/types/src/components/Radio/RadioGroup.d.ts +5 -4
- package/dist/types/src/components/SVG/SVG.d.ts +5 -4
- package/dist/types/src/components/Select/Select.d.ts +5 -4
- package/dist/types/src/components/Stack/Stack.d.ts +4 -2
- package/dist/types/src/components/Switch/Switch.d.ts +5 -3
- package/dist/types/src/components/Table/Body.d.ts +4 -2
- package/dist/types/src/components/Table/Cell.d.ts +4 -2
- package/dist/types/src/components/Table/Foot.d.ts +4 -2
- package/dist/types/src/components/Table/Head.d.ts +4 -2
- package/dist/types/src/components/Table/HeaderCell.d.ts +4 -2
- package/dist/types/src/components/Table/Row.d.ts +4 -2
- package/dist/types/src/components/Table/Table.d.ts +4 -2
- package/dist/types/src/components/Table/index.d.ts +7 -8
- package/dist/types/src/components/Text/Text.d.ts +5 -4
- package/dist/types/src/components/TextArea/TextArea.d.ts +5 -4
- package/dist/types/src/components/TextAreaInput/TextAreaInput.d.ts +5 -4
- package/dist/types/src/components/TextField/TextField.d.ts +4 -2
- package/dist/types/src/components/TextOrHTML/TextOrHTML.d.ts +6 -5
- package/dist/types/src/components/Title/Title.d.ts +5 -4
- package/dist/types/src/components/Trust/Trust.d.ts +2 -3
- package/dist/types/src/components/Trust/types.d.ts +1 -2
- package/dist/types/src/types/components.d.ts +4 -2
- package/dist/types/src/utils/mergeRefs.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Accordion/Accordion.tsx +3 -8
- package/src/components/Accordion/AccordionLink.tsx +1 -2
- package/src/components/AddressLookup/AddressLookup.tsx +55 -64
- package/src/components/AddressLookup/types.tsx +10 -8
- package/src/components/Alert/Alert.tsx +48 -54
- package/src/components/Box/Box.tsx +47 -59
- package/src/components/Breadcrumbs/BreadcrumbItem.tsx +7 -11
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +4 -10
- package/src/components/Button/Button.tsx +60 -65
- package/src/components/Checkbox/Checkbox.tsx +4 -8
- package/src/components/Checkbox/CheckboxGroup.tsx +4 -14
- package/src/components/Checkbox/types.ts +1 -4
- package/src/components/Combobox/Combobox.tsx +314 -313
- package/src/components/Container/Container.tsx +10 -15
- package/src/components/DateField/DateField.tsx +83 -90
- package/src/components/Drawer/Content.tsx +5 -9
- package/src/components/Drawer/Drawer.tsx +3 -5
- package/src/components/Drawer/Header.tsx +18 -22
- package/src/components/Drawer/types.ts +3 -2
- package/src/components/DropdownMenu/DropdownMenu.stories.tsx +12 -15
- package/src/components/DropdownMenu/DropdownMenu.test.tsx +2 -3
- package/src/components/DropdownMenu/DropdownMenu.tsx +3 -13
- package/src/components/DropdownMenu/Item.tsx +35 -38
- package/src/components/DropdownMenu/index.tsx +2 -4
- package/src/components/ExpandableText/ExpandableText.tsx +8 -9
- package/src/components/Fieldset/Fieldset.tsx +20 -24
- package/src/components/Flex/Flex.tsx +23 -27
- package/src/components/Flex/types.ts +1 -3
- package/src/components/Grid/Grid.tsx +31 -37
- package/src/components/Grid/Item.tsx +40 -44
- package/src/components/Grid/index.tsx +2 -4
- package/src/components/Icon/Icon.mdx +17 -0
- package/src/components/Icon/Icon.stories.tsx +6 -8
- package/src/components/Icon/Icon.tsx +2 -0
- package/src/components/Icon/types.ts +2 -4
- package/src/components/Image/Image.tsx +10 -16
- package/src/components/Label/Label.tsx +11 -17
- package/src/components/Link/Link.tsx +42 -43
- package/src/components/List/List.tsx +34 -39
- package/src/components/List/ListItem.tsx +27 -32
- package/src/components/LoadingIndicator/LoadingIndicator.tsx +3 -10
- package/src/components/Logo/Logo.tsx +42 -47
- package/src/components/MaskedField/MaskedField.tsx +6 -10
- package/src/components/Modal/Content.tsx +5 -9
- package/src/components/Modal/Header.tsx +17 -21
- package/src/components/Modal/Modal.tsx +3 -5
- package/src/components/Modal/types.ts +3 -2
- package/src/components/NumberField/NumberField.tsx +3 -16
- package/src/components/Option/Option.tsx +9 -14
- package/src/components/PasswordField/PasswordField.tsx +26 -27
- package/src/components/Popover/Popover.tsx +1 -3
- package/src/components/Progress/Progress.tsx +73 -81
- package/src/components/Radio/Radio.tsx +166 -174
- package/src/components/Radio/RadioGroup.tsx +3 -10
- package/src/components/SVG/SVG.tsx +20 -26
- package/src/components/Select/Select.tsx +85 -89
- package/src/components/Stack/Stack.tsx +12 -15
- package/src/components/Switch/Switch.tsx +2 -6
- package/src/components/Table/Body.tsx +4 -7
- package/src/components/Table/Cell.tsx +8 -12
- package/src/components/Table/Foot.tsx +4 -7
- package/src/components/Table/Head.tsx +4 -7
- package/src/components/Table/HeaderCell.tsx +8 -11
- package/src/components/Table/Row.tsx +4 -8
- package/src/components/Table/Table.tsx +4 -8
- package/src/components/Table/index.tsx +7 -9
- package/src/components/Text/Text.tsx +16 -22
- package/src/components/TextArea/TextArea.tsx +44 -52
- package/src/components/TextAreaInput/TextAreaInput.tsx +3 -10
- package/src/components/TextField/TextField.tsx +102 -105
- package/src/components/TextOrHTML/TextOrHTML.tsx +35 -41
- package/src/components/Title/Title.tsx +21 -27
- package/src/components/Trust/Trust.tsx +74 -76
- package/src/components/Trust/types.ts +1 -3
- package/src/types/components.ts +4 -8
- 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,
|
|
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:
|
|
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 {
|
|
2
|
-
import {
|
|
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
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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,
|
|
6
|
-
import {
|
|
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
|
-
|
|
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
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
const validationClasses = useValidationClasses({
|
|
53
|
+
validationState,
|
|
54
|
+
isInvalid,
|
|
55
|
+
});
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
63
|
+
const sharedClasses = classNames(validationClasses, stateClasses);
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
const handleChange = (e: ChangeEvent<HTMLSelectElement>) => {
|
|
89
|
+
if (onChange) {
|
|
90
|
+
onChange(e);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
97
93
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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:
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
const classes = classNames(
|
|
24
|
+
"mobius",
|
|
25
|
+
"mobius-stack",
|
|
26
|
+
{
|
|
27
|
+
[`--gap-${gap}`]: gap,
|
|
28
|
+
},
|
|
29
|
+
otherProps.className,
|
|
30
|
+
);
|
|
34
31
|
|
|
35
|
-
|
|
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
|
-
|
|
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:
|
|
14
|
-
|
|
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
|
-
|
|
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:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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:
|
|
14
|
-
|
|
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
|
-
|
|
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:
|
|
14
|
-
|
|
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
|
-
|
|
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:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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:
|
|
14
|
-
(
|
|
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
|
-
|
|
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:
|
|
17
|
-
(
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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, {
|