@simplybusiness/mobius 5.32.4 → 6.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.
package/dist/esm/index.js
CHANGED
|
@@ -3532,12 +3532,14 @@ var Radio = forwardRef39(
|
|
|
3532
3532
|
} = props;
|
|
3533
3533
|
const realDisabled = groupDisabled || isDisabled;
|
|
3534
3534
|
const isMultiline = label && children;
|
|
3535
|
-
const
|
|
3535
|
+
const isControlled = selected !== void 0;
|
|
3536
|
+
const isChecked = isControlled ? selected === value : defaultChecked;
|
|
3536
3537
|
const hasIconFirst = useMemo3(() => {
|
|
3537
3538
|
if (!children || Children7.count(children) === 0) return false;
|
|
3538
3539
|
const firstChild = Children7.toArray(children)[0];
|
|
3539
3540
|
if (!isValidElement5(firstChild)) return false;
|
|
3540
|
-
|
|
3541
|
+
const props2 = firstChild.props;
|
|
3542
|
+
return "icon" in props2 && props2.icon !== void 0;
|
|
3541
3543
|
}, [children]);
|
|
3542
3544
|
const radioClasses = {
|
|
3543
3545
|
"--is-disabled": realDisabled,
|
|
@@ -3566,6 +3568,15 @@ var Radio = forwardRef39(
|
|
|
3566
3568
|
"aria-describedby": _ariaDescribedBy,
|
|
3567
3569
|
...rest
|
|
3568
3570
|
} = otherProps;
|
|
3571
|
+
const handleChange = (event) => {
|
|
3572
|
+
if (onChange) {
|
|
3573
|
+
const adaptedEvent = {
|
|
3574
|
+
...event.nativeEvent,
|
|
3575
|
+
target: event.target
|
|
3576
|
+
};
|
|
3577
|
+
onChange(adaptedEvent);
|
|
3578
|
+
}
|
|
3579
|
+
};
|
|
3569
3580
|
return /* @__PURE__ */ jsxs24(Fragment4, { children: [
|
|
3570
3581
|
/* @__PURE__ */ jsxs24(Label, { className: containerClasses, children: [
|
|
3571
3582
|
/* @__PURE__ */ jsx51(
|
|
@@ -3579,7 +3590,7 @@ var Radio = forwardRef39(
|
|
|
3579
3590
|
value,
|
|
3580
3591
|
tabIndex: 0,
|
|
3581
3592
|
type: "radio",
|
|
3582
|
-
defaultChecked:
|
|
3593
|
+
...isControlled ? { checked: isChecked, onChange: handleChange } : { defaultChecked: isChecked },
|
|
3583
3594
|
name,
|
|
3584
3595
|
required: isRequired,
|
|
3585
3596
|
...rest
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
export declare const adornmentWithClassName: (component?: ReactElement, validationClasses?: string, className?: string) => ReactElement<
|
|
2
|
+
export declare const adornmentWithClassName: (component?: ReactElement, validationClasses?: string, className?: string) => ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplybusiness/mobius",
|
|
3
3
|
"license": "UNLICENSED",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0",
|
|
5
5
|
"description": "Core library of Mobius react components",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@eslint/eslintrc": "^3.3.1",
|
|
47
47
|
"@eslint/js": "^9.29.0",
|
|
48
48
|
"@react-types/progress": "^3.5.13",
|
|
49
|
-
"@simplybusiness/eslint-config": "^0.
|
|
50
|
-
"@simplybusiness/eslint-plugin": "^0.
|
|
49
|
+
"@simplybusiness/eslint-config": "^1.0.0",
|
|
50
|
+
"@simplybusiness/eslint-plugin": "^1.0.0",
|
|
51
51
|
"@swc/core": "^1.12.5",
|
|
52
52
|
"@swc/jest": "^0.2.38",
|
|
53
53
|
"@testing-library/dom": "^10.4.0",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"@types/jest": "^30.0.0",
|
|
59
59
|
"@types/lodash.debounce": "^4.0.9",
|
|
60
60
|
"@types/node": "^20.19.1",
|
|
61
|
-
"@types/react": "^
|
|
62
|
-
"@types/react-dom": "^
|
|
61
|
+
"@types/react": "^19.1.11",
|
|
62
|
+
"@types/react-dom": "^19.1.8",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^8.35.0",
|
|
64
64
|
"@typescript-eslint/parser": "^8.35.0",
|
|
65
65
|
"build-scripts": "^1.0.1",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"jest-config": "^30.0.3",
|
|
72
72
|
"jest-environment-jsdom": "^30.0.2",
|
|
73
73
|
"prettier": "^3.6.0",
|
|
74
|
-
"react": "^
|
|
75
|
-
"react-dom": "^
|
|
74
|
+
"react": "^19.1.1",
|
|
75
|
+
"react-dom": "^19.1.1",
|
|
76
76
|
"ts-jest": "^29.4.0",
|
|
77
77
|
"tslib": "^2.8.1",
|
|
78
78
|
"typescript": "^5.8.3"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"react": "^
|
|
82
|
-
"react-dom": "^
|
|
81
|
+
"react": "^19.1.0",
|
|
82
|
+
"react-dom": "^19.1.0"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@floating-ui/react": "^0.27.12",
|
|
@@ -83,7 +83,8 @@ const Radio: ForwardedRefComponent<RadioProps, RadioElementType> = forwardRef(
|
|
|
83
83
|
} = props;
|
|
84
84
|
const realDisabled = groupDisabled || isDisabled;
|
|
85
85
|
const isMultiline = label && children;
|
|
86
|
-
const
|
|
86
|
+
const isControlled = selected !== undefined;
|
|
87
|
+
const isChecked = isControlled ? selected === value : defaultChecked;
|
|
87
88
|
|
|
88
89
|
const hasIconFirst = useMemo(() => {
|
|
89
90
|
if (!children || Children.count(children) === 0) return false;
|
|
@@ -91,7 +92,8 @@ const Radio: ForwardedRefComponent<RadioProps, RadioElementType> = forwardRef(
|
|
|
91
92
|
const firstChild = Children.toArray(children)[0];
|
|
92
93
|
if (!isValidElement(firstChild)) return false;
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
const props = firstChild.props as Record<string, unknown>;
|
|
96
|
+
return "icon" in props && props.icon !== undefined;
|
|
95
97
|
}, [children]);
|
|
96
98
|
|
|
97
99
|
const radioClasses = {
|
|
@@ -126,6 +128,18 @@ const Radio: ForwardedRefComponent<RadioProps, RadioElementType> = forwardRef(
|
|
|
126
128
|
...rest
|
|
127
129
|
} = otherProps;
|
|
128
130
|
|
|
131
|
+
// Adapter function to convert React's ChangeEvent to our HTMLElementEvent
|
|
132
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
133
|
+
if (onChange) {
|
|
134
|
+
// Create an HTMLElementEvent-compatible object
|
|
135
|
+
const adaptedEvent: HTMLElementEvent<HTMLInputElement> = {
|
|
136
|
+
...event.nativeEvent,
|
|
137
|
+
target: event.target,
|
|
138
|
+
};
|
|
139
|
+
onChange(adaptedEvent);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
|
|
129
143
|
return (
|
|
130
144
|
<>
|
|
131
145
|
<Label className={containerClasses}>
|
|
@@ -138,7 +152,9 @@ const Radio: ForwardedRefComponent<RadioProps, RadioElementType> = forwardRef(
|
|
|
138
152
|
value={value}
|
|
139
153
|
tabIndex={0}
|
|
140
154
|
type="radio"
|
|
141
|
-
|
|
155
|
+
{...(isControlled
|
|
156
|
+
? { checked: isChecked, onChange: handleChange }
|
|
157
|
+
: { defaultChecked: isChecked })}
|
|
142
158
|
name={name}
|
|
143
159
|
required={isRequired}
|
|
144
160
|
{...rest}
|