@dt-dds/react-radio 1.0.0-beta.100

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Daimler Truck AG.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Radio Package
2
+
3
+ The Radio package allows to select one option from a set.
4
+
5
+ ## Usage
6
+
7
+ ```jsx
8
+ import { Radio, RadioGroup } from '@dt-dds/react';
9
+
10
+ export const App = () => {
11
+ return (
12
+ <RadioGroup onChange={onChange} name='group-name'>
13
+ <Radio value='1' label='Label 1' isDefaultChecked={true} />
14
+ <Radio value='2' label='Label 2' isDisabled={true} />
15
+ </RadioGroup>
16
+ );
17
+ };
18
+ ```
19
+
20
+ ## Properties
21
+
22
+ ### Radio
23
+
24
+ | Property | Type | Default | Description |
25
+ | ------------------ | ---------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------- |
26
+ | `label` | `string` | - | A label to help users understand the scope of the radio. |
27
+ | `onChange` | `(evt: ChangeEvent<HTMLInputElement>) => void` | - | The triggered function when the input change. |
28
+ | `isDisabled` | `boolean` | `false` | Specifies if the element should be disabled. |
29
+ | `isDefaultChecked` | `boolean` | `false` | Indicates that this default radio button is selected one in the group. |
30
+ | `isChecked` | `boolean` | `false` | Indicates that this radio button is selected one in the group. Used when the radio is controlled by another element |
31
+ | `name` | `string` | `radio-group-name` | Should represent the group name |
32
+ | `value` | `string` | - | String containing the radio button's value |
33
+ | `hasError` | `boolean` | `false` | Indicates that the radio button has an error |
34
+
35
+ ### RadioGroup
36
+
37
+ | Property | Type | Default | Description |
38
+ | ------------ | ---------------------------------------------- | ------- | --------------------------------------------- |
39
+ | `children` | `ReactNode` | - | Child components to be rendered |
40
+ | `dataTestId` | `string` | - | Customizable test identifier |
41
+ | `direction` | "row" \| "column" | row | Sets the flex direction of the group |
42
+ | `name` | `string` | - | Should represent the group name |
43
+ | `onChange` | `(evt: ChangeEvent<HTMLInputElement>) => void` | - | The triggered function when the input change. |
44
+ | `size` | `"small" \| "large" | `large` | Sets the dimensions of the radio buttons |
45
+
46
+ ## Stack
47
+
48
+ - [TypeScript](https://www.typescriptlang.org/) for static type checking
49
+ - [React](https://reactjs.org/) — JavaScript library for user interfaces
50
+ - [Emotion](https://emotion.sh/docs/introduction) — for writing css styles with JavaScript
51
+ - [Storybook](https://storybook.js.org/) — UI component environment powered by Vite
52
+ - [Jest](https://jestjs.io/) - JavaScript Testing Framework
53
+ - [React Testing Library](https://testing-library.com/) - to test UI components in a user-centric way
54
+ - [ESLint](https://eslint.org/) for code linting
55
+ - [Prettier](https://prettier.io) for code formatting
56
+ - [Tsup](https://github.com/egoist/tsup) — TypeScript bundler powered by esbuild
57
+ - [Yarn](https://yarnpkg.com/) from managing packages
58
+
59
+ ## Commands
60
+
61
+ - `yarn build` - Build the package
62
+ - `yarn dev` - Run the package locally
63
+ - `yarn lint` - Lint all files within this package
64
+ - `yarn test` - Run all unit tests
65
+ - `yarn test:report` - Open the test coverage report
66
+ - `yarn test:update:snapshot` - Run all unit tests and update the snapshot
67
+
68
+ ## Compilation
69
+
70
+ Running `yarn build` from the root of the package will use [tsup](https://tsup.egoist.dev/) to compile the raw TypeScript and React code to plain JavaScript.
71
+
72
+ The `/dist` folder contains the compiled output.
73
+
74
+ ```bash
75
+ radio
76
+ └── dist
77
+ ├── index.d.ts <-- Types
78
+ ├── index.js <-- CommonJS version
79
+ └── index.mjs <-- ES Modules version
80
+ ...
81
+ ```
82
+
83
+ ## Versioning
84
+
85
+ Follows [semantic versioning](https://semver.org/)
86
+
87
+ ## &copy; License
88
+
89
+ Licensed under [MIT License](LICENSE)
@@ -0,0 +1,35 @@
1
+ import { CustomTheme } from '@dt-dds/themes';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { BaseProps } from '@dt-dds/react-core';
4
+
5
+ type RadioDirection = 'column' | 'row';
6
+ type RadioSize = 'large' | 'small';
7
+ interface RadioGroupProps extends BaseProps {
8
+ onChange: React.ChangeEventHandler<HTMLInputElement>;
9
+ name: string;
10
+ direction?: RadioDirection;
11
+ size?: RadioSize;
12
+ }
13
+ interface RadioProps {
14
+ label?: string;
15
+ value: string;
16
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
17
+ isChecked?: boolean;
18
+ isDisabled?: boolean;
19
+ name?: string;
20
+ hasError?: boolean;
21
+ size?: RadioSize;
22
+ dataTestId?: string;
23
+ isDefaultChecked?: boolean;
24
+ }
25
+
26
+ declare const Radio: ({ onChange, label, isChecked, isDefaultChecked, isDisabled, name, value, hasError, size, dataTestId, }: RadioProps) => react_jsx_runtime.JSX.Element;
27
+
28
+ declare const RadioGroup: ({ children, onChange, dataTestId, direction, size, name, }: RadioGroupProps) => react_jsx_runtime.JSX.Element;
29
+
30
+ declare module '@emotion/react' {
31
+ interface Theme extends CustomTheme {
32
+ }
33
+ }
34
+
35
+ export { Radio, RadioGroup };
@@ -0,0 +1,35 @@
1
+ import { CustomTheme } from '@dt-dds/themes';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { BaseProps } from '@dt-dds/react-core';
4
+
5
+ type RadioDirection = 'column' | 'row';
6
+ type RadioSize = 'large' | 'small';
7
+ interface RadioGroupProps extends BaseProps {
8
+ onChange: React.ChangeEventHandler<HTMLInputElement>;
9
+ name: string;
10
+ direction?: RadioDirection;
11
+ size?: RadioSize;
12
+ }
13
+ interface RadioProps {
14
+ label?: string;
15
+ value: string;
16
+ onChange?: React.ChangeEventHandler<HTMLInputElement>;
17
+ isChecked?: boolean;
18
+ isDisabled?: boolean;
19
+ name?: string;
20
+ hasError?: boolean;
21
+ size?: RadioSize;
22
+ dataTestId?: string;
23
+ isDefaultChecked?: boolean;
24
+ }
25
+
26
+ declare const Radio: ({ onChange, label, isChecked, isDefaultChecked, isDisabled, name, value, hasError, size, dataTestId, }: RadioProps) => react_jsx_runtime.JSX.Element;
27
+
28
+ declare const RadioGroup: ({ children, onChange, dataTestId, direction, size, name, }: RadioGroupProps) => react_jsx_runtime.JSX.Element;
29
+
30
+ declare module '@emotion/react' {
31
+ interface Theme extends CustomTheme {
32
+ }
33
+ }
34
+
35
+ export { Radio, RadioGroup };
package/dist/index.js ADDED
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __defProps = Object.defineProperties;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __copyProps = (to, from, except, desc) => {
30
+ if (from && typeof from === "object" || typeof from === "function") {
31
+ for (let key of __getOwnPropNames(from))
32
+ if (!__hasOwnProp.call(to, key) && key !== except)
33
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
34
+ }
35
+ return to;
36
+ };
37
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
38
+ // If the importer is in node compatibility mode or this is not an ESM
39
+ // file that has been converted to a CommonJS file using a Babel-
40
+ // compatible transform (i.e. "__esModule" has not been set), then set
41
+ // "default" to the CommonJS "module.exports" for node compatibility.
42
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
43
+ mod
44
+ ));
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+
47
+ // index.ts
48
+ var index_exports = {};
49
+ __export(index_exports, {
50
+ Radio: () => Radio,
51
+ RadioGroup: () => RadioGroup
52
+ });
53
+ module.exports = __toCommonJS(index_exports);
54
+
55
+ // src/Radio.tsx
56
+ var import_react = require("@emotion/react");
57
+ var import_react_box = require("@dt-dds/react-box");
58
+ var import_react_typography = require("@dt-dds/react-typography");
59
+
60
+ // src/Radio.styled.tsx
61
+ var import_styled = __toESM(require("@emotion/styled"));
62
+ var RADIO_SIZES = {
63
+ large: {
64
+ outerCircle: 24,
65
+ innerCircle: 10
66
+ },
67
+ small: {
68
+ outerCircle: 20,
69
+ innerCircle: 8
70
+ }
71
+ };
72
+ var RadioInputStyled = import_styled.default.input`
73
+ ${({ theme, radioSize }) => `
74
+ background: ${theme.palette.surface.contrast};
75
+ border: 1px solid ${theme.palette.informative.default};
76
+ border-radius: 50%;
77
+ width: ${RADIO_SIZES[radioSize].outerCircle}px;
78
+ height: ${RADIO_SIZES[radioSize].outerCircle}px;
79
+ appearance: none;
80
+ position: relative;
81
+ cursor: pointer;
82
+ flex-shrink: 0;
83
+
84
+ &:disabled + label {
85
+ color: ${theme.palette.content.light};
86
+ }
87
+
88
+ &:hover {
89
+ background: ${theme.palette.informative.light};
90
+ }
91
+
92
+ &:checked:not(:disabled):hover {
93
+ background: ${theme.palette.informative.dark};
94
+ border-color: ${theme.palette.informative.dark};
95
+ }
96
+
97
+ &:checked {
98
+ background: ${theme.palette.informative.default};
99
+ }
100
+
101
+ &:disabled {
102
+ pointer-events: none;
103
+ cursor: not-allowed;
104
+ border-color: ${theme.palette.informative.light};
105
+ background-color: ${theme.palette.informative.light};
106
+ }
107
+
108
+ &:checked:before {
109
+ content: "";
110
+ width: ${RADIO_SIZES[radioSize].innerCircle}px;
111
+ height: ${RADIO_SIZES[radioSize].innerCircle}px;
112
+ background: ${theme.palette.surface.contrast};
113
+ border-radius: 50%;
114
+ position: absolute;
115
+ top: 50%;
116
+ left: 50%;
117
+ transform: translate(-50%, -50%);
118
+ }
119
+
120
+ &[data-error="true"] {
121
+ border-color: ${theme.palette.error.default};
122
+ }
123
+
124
+ &[data-error="true"]:hover {
125
+ background-color: ${theme.palette.error.light};
126
+ }
127
+
128
+ &[data-error="true"]:disabled {
129
+ background-color: ${theme.palette.error.light};
130
+ border-color: ${theme.palette.error.light};
131
+ }
132
+
133
+ &[data-error="true"]:checked {
134
+ background-color: ${theme.palette.error.default};
135
+ }
136
+
137
+ &[data-error="true"]:checked:disabled {
138
+ background-color: ${theme.palette.error.light};
139
+ border-color: ${theme.palette.error.light};
140
+ }
141
+
142
+ &[data-error="true"]:checked:not(:disabled):hover {
143
+ background-color: ${theme.palette.error.dark};
144
+ border-color: ${theme.palette.error.dark};
145
+ }
146
+
147
+ &:focus-visible {
148
+ outline: 2px solid ${theme.palette.primary.default};
149
+ outline-offset: 2px;
150
+ }
151
+ `}
152
+ `;
153
+
154
+ // src/Radio.tsx
155
+ var import_jsx_runtime = require("react/jsx-runtime");
156
+ var Radio = ({
157
+ onChange,
158
+ label,
159
+ isChecked,
160
+ isDefaultChecked,
161
+ isDisabled,
162
+ name = "radio-group-name",
163
+ value,
164
+ hasError,
165
+ size = "large",
166
+ dataTestId
167
+ }) => {
168
+ const radioId = `${value}-id`;
169
+ const theme = (0, import_react.useTheme)();
170
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
171
+ import_react_box.Box,
172
+ {
173
+ style: {
174
+ flexDirection: "row",
175
+ gap: theme.spacing.spacing_30,
176
+ cursor: isDisabled ? "not-allowed" : "pointer"
177
+ },
178
+ children: [
179
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
180
+ RadioInputStyled,
181
+ {
182
+ checked: isChecked,
183
+ "data-error": hasError,
184
+ "data-testid": dataTestId,
185
+ defaultChecked: isDefaultChecked,
186
+ disabled: isDisabled,
187
+ id: radioId,
188
+ name,
189
+ onChange,
190
+ radioSize: size,
191
+ tabIndex: isDisabled ? -1 : 0,
192
+ type: "radio",
193
+ value
194
+ }
195
+ ),
196
+ label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
197
+ import_react_typography.Typography,
198
+ {
199
+ element: "label",
200
+ fontStyles: size === "large" ? "bodyLgRegular" : "bodyMdRegular",
201
+ htmlFor: radioId,
202
+ style: { cursor: isDisabled ? "not-allowed" : "pointer" },
203
+ children: label
204
+ }
205
+ ) : null
206
+ ]
207
+ }
208
+ );
209
+ };
210
+
211
+ // src/RadioGroup.tsx
212
+ var import_react2 = require("react");
213
+ var import_react3 = require("@emotion/react");
214
+ var import_react_box2 = require("@dt-dds/react-box");
215
+ var import_jsx_runtime2 = require("react/jsx-runtime");
216
+ var RadioGroup = ({
217
+ children,
218
+ onChange,
219
+ dataTestId,
220
+ direction = "row",
221
+ size = "large",
222
+ name
223
+ }) => {
224
+ const theme = (0, import_react3.useTheme)();
225
+ const clonedChildren = (0, import_react2.useMemo)(
226
+ () => import_react2.Children.map(children, (child) => {
227
+ return child && (0, import_react2.cloneElement)(child, __spreadProps(__spreadValues({}, child.props), {
228
+ onChange,
229
+ name,
230
+ size
231
+ }));
232
+ }),
233
+ [children, onChange, name, size]
234
+ );
235
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
236
+ import_react_box2.Box,
237
+ {
238
+ "data-testid": dataTestId != null ? dataTestId : "radio-group",
239
+ role: "radiogroup",
240
+ style: {
241
+ flexDirection: direction,
242
+ gap: theme.spacing.spacing_40,
243
+ alignItems: direction === "row" ? "center" : "flex-start"
244
+ },
245
+ children: clonedChildren
246
+ }
247
+ );
248
+ };
249
+ // Annotate the CommonJS export names for ESM import in node:
250
+ 0 && (module.exports = {
251
+ Radio,
252
+ RadioGroup
253
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,218 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+
21
+ // src/Radio.tsx
22
+ import { useTheme } from "@emotion/react";
23
+ import { Box } from "@dt-dds/react-box";
24
+ import { Typography } from "@dt-dds/react-typography";
25
+
26
+ // src/Radio.styled.tsx
27
+ import styled from "@emotion/styled";
28
+ var RADIO_SIZES = {
29
+ large: {
30
+ outerCircle: 24,
31
+ innerCircle: 10
32
+ },
33
+ small: {
34
+ outerCircle: 20,
35
+ innerCircle: 8
36
+ }
37
+ };
38
+ var RadioInputStyled = styled.input`
39
+ ${({ theme, radioSize }) => `
40
+ background: ${theme.palette.surface.contrast};
41
+ border: 1px solid ${theme.palette.informative.default};
42
+ border-radius: 50%;
43
+ width: ${RADIO_SIZES[radioSize].outerCircle}px;
44
+ height: ${RADIO_SIZES[radioSize].outerCircle}px;
45
+ appearance: none;
46
+ position: relative;
47
+ cursor: pointer;
48
+ flex-shrink: 0;
49
+
50
+ &:disabled + label {
51
+ color: ${theme.palette.content.light};
52
+ }
53
+
54
+ &:hover {
55
+ background: ${theme.palette.informative.light};
56
+ }
57
+
58
+ &:checked:not(:disabled):hover {
59
+ background: ${theme.palette.informative.dark};
60
+ border-color: ${theme.palette.informative.dark};
61
+ }
62
+
63
+ &:checked {
64
+ background: ${theme.palette.informative.default};
65
+ }
66
+
67
+ &:disabled {
68
+ pointer-events: none;
69
+ cursor: not-allowed;
70
+ border-color: ${theme.palette.informative.light};
71
+ background-color: ${theme.palette.informative.light};
72
+ }
73
+
74
+ &:checked:before {
75
+ content: "";
76
+ width: ${RADIO_SIZES[radioSize].innerCircle}px;
77
+ height: ${RADIO_SIZES[radioSize].innerCircle}px;
78
+ background: ${theme.palette.surface.contrast};
79
+ border-radius: 50%;
80
+ position: absolute;
81
+ top: 50%;
82
+ left: 50%;
83
+ transform: translate(-50%, -50%);
84
+ }
85
+
86
+ &[data-error="true"] {
87
+ border-color: ${theme.palette.error.default};
88
+ }
89
+
90
+ &[data-error="true"]:hover {
91
+ background-color: ${theme.palette.error.light};
92
+ }
93
+
94
+ &[data-error="true"]:disabled {
95
+ background-color: ${theme.palette.error.light};
96
+ border-color: ${theme.palette.error.light};
97
+ }
98
+
99
+ &[data-error="true"]:checked {
100
+ background-color: ${theme.palette.error.default};
101
+ }
102
+
103
+ &[data-error="true"]:checked:disabled {
104
+ background-color: ${theme.palette.error.light};
105
+ border-color: ${theme.palette.error.light};
106
+ }
107
+
108
+ &[data-error="true"]:checked:not(:disabled):hover {
109
+ background-color: ${theme.palette.error.dark};
110
+ border-color: ${theme.palette.error.dark};
111
+ }
112
+
113
+ &:focus-visible {
114
+ outline: 2px solid ${theme.palette.primary.default};
115
+ outline-offset: 2px;
116
+ }
117
+ `}
118
+ `;
119
+
120
+ // src/Radio.tsx
121
+ import { jsx, jsxs } from "react/jsx-runtime";
122
+ var Radio = ({
123
+ onChange,
124
+ label,
125
+ isChecked,
126
+ isDefaultChecked,
127
+ isDisabled,
128
+ name = "radio-group-name",
129
+ value,
130
+ hasError,
131
+ size = "large",
132
+ dataTestId
133
+ }) => {
134
+ const radioId = `${value}-id`;
135
+ const theme = useTheme();
136
+ return /* @__PURE__ */ jsxs(
137
+ Box,
138
+ {
139
+ style: {
140
+ flexDirection: "row",
141
+ gap: theme.spacing.spacing_30,
142
+ cursor: isDisabled ? "not-allowed" : "pointer"
143
+ },
144
+ children: [
145
+ /* @__PURE__ */ jsx(
146
+ RadioInputStyled,
147
+ {
148
+ checked: isChecked,
149
+ "data-error": hasError,
150
+ "data-testid": dataTestId,
151
+ defaultChecked: isDefaultChecked,
152
+ disabled: isDisabled,
153
+ id: radioId,
154
+ name,
155
+ onChange,
156
+ radioSize: size,
157
+ tabIndex: isDisabled ? -1 : 0,
158
+ type: "radio",
159
+ value
160
+ }
161
+ ),
162
+ label ? /* @__PURE__ */ jsx(
163
+ Typography,
164
+ {
165
+ element: "label",
166
+ fontStyles: size === "large" ? "bodyLgRegular" : "bodyMdRegular",
167
+ htmlFor: radioId,
168
+ style: { cursor: isDisabled ? "not-allowed" : "pointer" },
169
+ children: label
170
+ }
171
+ ) : null
172
+ ]
173
+ }
174
+ );
175
+ };
176
+
177
+ // src/RadioGroup.tsx
178
+ import { Children, cloneElement, useMemo } from "react";
179
+ import { useTheme as useTheme2 } from "@emotion/react";
180
+ import { Box as Box2 } from "@dt-dds/react-box";
181
+ import { jsx as jsx2 } from "react/jsx-runtime";
182
+ var RadioGroup = ({
183
+ children,
184
+ onChange,
185
+ dataTestId,
186
+ direction = "row",
187
+ size = "large",
188
+ name
189
+ }) => {
190
+ const theme = useTheme2();
191
+ const clonedChildren = useMemo(
192
+ () => Children.map(children, (child) => {
193
+ return child && cloneElement(child, __spreadProps(__spreadValues({}, child.props), {
194
+ onChange,
195
+ name,
196
+ size
197
+ }));
198
+ }),
199
+ [children, onChange, name, size]
200
+ );
201
+ return /* @__PURE__ */ jsx2(
202
+ Box2,
203
+ {
204
+ "data-testid": dataTestId != null ? dataTestId : "radio-group",
205
+ role: "radiogroup",
206
+ style: {
207
+ flexDirection: direction,
208
+ gap: theme.spacing.spacing_40,
209
+ alignItems: direction === "row" ? "center" : "flex-start"
210
+ },
211
+ children: clonedChildren
212
+ }
213
+ );
214
+ };
215
+ export {
216
+ Radio,
217
+ RadioGroup
218
+ };