@rubenpazch/radio-button 1.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # RadioButton
2
+
3
+ Generated component package.
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ export type RadioSize = "sm" | "md" | "lg";
3
+ export type RadioVariant = "default" | "primary" | "success" | "warning" | "danger";
4
+ export interface RadioButtonProps {
5
+ id?: string;
6
+ name: string;
7
+ label: string;
8
+ value: string;
9
+ checked?: boolean;
10
+ onChange?: (value: string) => void;
11
+ disabled?: boolean;
12
+ description?: string;
13
+ error?: string;
14
+ className?: string;
15
+ required?: boolean;
16
+ size?: RadioSize;
17
+ variant?: RadioVariant;
18
+ }
19
+ declare const RadioButton: React.FC<RadioButtonProps>;
20
+ export default RadioButton;
21
+ //# sourceMappingURL=RadioButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioButton.d.ts","sourceRoot":"","sources":["../src/RadioButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAC3C,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,WAAW,gBAAgB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAkDD,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA+E3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1,30 @@
1
+ import React from "react";
2
+ import { RadioSize, RadioVariant } from "./RadioButton";
3
+ export type RadioGroupOrientation = "vertical" | "horizontal";
4
+ export interface RadioOption {
5
+ label: string;
6
+ value: string;
7
+ description?: string;
8
+ disabled?: boolean;
9
+ }
10
+ export interface RadioGroupProps {
11
+ name: string;
12
+ options: RadioOption[];
13
+ value?: string;
14
+ onChange: (value: string) => void;
15
+ orientation?: RadioGroupOrientation;
16
+ size?: RadioSize;
17
+ variant?: RadioVariant;
18
+ disabled?: boolean;
19
+ required?: boolean;
20
+ error?: string;
21
+ className?: string;
22
+ showSelectedLabel?: boolean;
23
+ selectedLabelText?: string;
24
+ groupLabel?: string;
25
+ bordered?: boolean;
26
+ borderLabel?: string;
27
+ }
28
+ declare const RadioGroup: React.FC<RadioGroupProps>;
29
+ export default RadioGroup;
30
+ //# sourceMappingURL=RadioGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RadioGroup.d.ts","sourceRoot":"","sources":["../src/RadioGroup.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAoB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAErE,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,YAAY,CAAC;AAE9D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+EzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -0,0 +1,510 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var require$$0 = require('react');
6
+
7
+ var jsxRuntime = {exports: {}};
8
+
9
+ var reactJsxRuntime_production = {};
10
+
11
+ /**
12
+ * @license React
13
+ * react-jsx-runtime.production.js
14
+ *
15
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
16
+ *
17
+ * This source code is licensed under the MIT license found in the
18
+ * LICENSE file in the root directory of this source tree.
19
+ */
20
+
21
+ var hasRequiredReactJsxRuntime_production;
22
+
23
+ function requireReactJsxRuntime_production () {
24
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
25
+ hasRequiredReactJsxRuntime_production = 1;
26
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
27
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
28
+ function jsxProd(type, config, maybeKey) {
29
+ var key = null;
30
+ void 0 !== maybeKey && (key = "" + maybeKey);
31
+ void 0 !== config.key && (key = "" + config.key);
32
+ if ("key" in config) {
33
+ maybeKey = {};
34
+ for (var propName in config)
35
+ "key" !== propName && (maybeKey[propName] = config[propName]);
36
+ } else maybeKey = config;
37
+ config = maybeKey.ref;
38
+ return {
39
+ $$typeof: REACT_ELEMENT_TYPE,
40
+ type: type,
41
+ key: key,
42
+ ref: void 0 !== config ? config : null,
43
+ props: maybeKey
44
+ };
45
+ }
46
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
47
+ reactJsxRuntime_production.jsx = jsxProd;
48
+ reactJsxRuntime_production.jsxs = jsxProd;
49
+ return reactJsxRuntime_production;
50
+ }
51
+
52
+ var reactJsxRuntime_development = {};
53
+
54
+ /**
55
+ * @license React
56
+ * react-jsx-runtime.development.js
57
+ *
58
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
59
+ *
60
+ * This source code is licensed under the MIT license found in the
61
+ * LICENSE file in the root directory of this source tree.
62
+ */
63
+
64
+ var hasRequiredReactJsxRuntime_development;
65
+
66
+ function requireReactJsxRuntime_development () {
67
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
68
+ hasRequiredReactJsxRuntime_development = 1;
69
+ "production" !== process.env.NODE_ENV &&
70
+ (function () {
71
+ function getComponentNameFromType(type) {
72
+ if (null == type) return null;
73
+ if ("function" === typeof type)
74
+ return type.$$typeof === REACT_CLIENT_REFERENCE
75
+ ? null
76
+ : type.displayName || type.name || null;
77
+ if ("string" === typeof type) return type;
78
+ switch (type) {
79
+ case REACT_FRAGMENT_TYPE:
80
+ return "Fragment";
81
+ case REACT_PROFILER_TYPE:
82
+ return "Profiler";
83
+ case REACT_STRICT_MODE_TYPE:
84
+ return "StrictMode";
85
+ case REACT_SUSPENSE_TYPE:
86
+ return "Suspense";
87
+ case REACT_SUSPENSE_LIST_TYPE:
88
+ return "SuspenseList";
89
+ case REACT_ACTIVITY_TYPE:
90
+ return "Activity";
91
+ }
92
+ if ("object" === typeof type)
93
+ switch (
94
+ ("number" === typeof type.tag &&
95
+ console.error(
96
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
97
+ ),
98
+ type.$$typeof)
99
+ ) {
100
+ case REACT_PORTAL_TYPE:
101
+ return "Portal";
102
+ case REACT_CONTEXT_TYPE:
103
+ return type.displayName || "Context";
104
+ case REACT_CONSUMER_TYPE:
105
+ return (type._context.displayName || "Context") + ".Consumer";
106
+ case REACT_FORWARD_REF_TYPE:
107
+ var innerType = type.render;
108
+ type = type.displayName;
109
+ type ||
110
+ ((type = innerType.displayName || innerType.name || ""),
111
+ (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
112
+ return type;
113
+ case REACT_MEMO_TYPE:
114
+ return (
115
+ (innerType = type.displayName || null),
116
+ null !== innerType
117
+ ? innerType
118
+ : getComponentNameFromType(type.type) || "Memo"
119
+ );
120
+ case REACT_LAZY_TYPE:
121
+ innerType = type._payload;
122
+ type = type._init;
123
+ try {
124
+ return getComponentNameFromType(type(innerType));
125
+ } catch (x) {}
126
+ }
127
+ return null;
128
+ }
129
+ function testStringCoercion(value) {
130
+ return "" + value;
131
+ }
132
+ function checkKeyStringCoercion(value) {
133
+ try {
134
+ testStringCoercion(value);
135
+ var JSCompiler_inline_result = !1;
136
+ } catch (e) {
137
+ JSCompiler_inline_result = true;
138
+ }
139
+ if (JSCompiler_inline_result) {
140
+ JSCompiler_inline_result = console;
141
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
142
+ var JSCompiler_inline_result$jscomp$0 =
143
+ ("function" === typeof Symbol &&
144
+ Symbol.toStringTag &&
145
+ value[Symbol.toStringTag]) ||
146
+ value.constructor.name ||
147
+ "Object";
148
+ JSCompiler_temp_const.call(
149
+ JSCompiler_inline_result,
150
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
151
+ JSCompiler_inline_result$jscomp$0
152
+ );
153
+ return testStringCoercion(value);
154
+ }
155
+ }
156
+ function getTaskName(type) {
157
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
158
+ if (
159
+ "object" === typeof type &&
160
+ null !== type &&
161
+ type.$$typeof === REACT_LAZY_TYPE
162
+ )
163
+ return "<...>";
164
+ try {
165
+ var name = getComponentNameFromType(type);
166
+ return name ? "<" + name + ">" : "<...>";
167
+ } catch (x) {
168
+ return "<...>";
169
+ }
170
+ }
171
+ function getOwner() {
172
+ var dispatcher = ReactSharedInternals.A;
173
+ return null === dispatcher ? null : dispatcher.getOwner();
174
+ }
175
+ function UnknownOwner() {
176
+ return Error("react-stack-top-frame");
177
+ }
178
+ function hasValidKey(config) {
179
+ if (hasOwnProperty.call(config, "key")) {
180
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
181
+ if (getter && getter.isReactWarning) return false;
182
+ }
183
+ return void 0 !== config.key;
184
+ }
185
+ function defineKeyPropWarningGetter(props, displayName) {
186
+ function warnAboutAccessingKey() {
187
+ specialPropKeyWarningShown ||
188
+ ((specialPropKeyWarningShown = true),
189
+ console.error(
190
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
191
+ displayName
192
+ ));
193
+ }
194
+ warnAboutAccessingKey.isReactWarning = true;
195
+ Object.defineProperty(props, "key", {
196
+ get: warnAboutAccessingKey,
197
+ configurable: true
198
+ });
199
+ }
200
+ function elementRefGetterWithDeprecationWarning() {
201
+ var componentName = getComponentNameFromType(this.type);
202
+ didWarnAboutElementRef[componentName] ||
203
+ ((didWarnAboutElementRef[componentName] = true),
204
+ console.error(
205
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
206
+ ));
207
+ componentName = this.props.ref;
208
+ return void 0 !== componentName ? componentName : null;
209
+ }
210
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
211
+ var refProp = props.ref;
212
+ type = {
213
+ $$typeof: REACT_ELEMENT_TYPE,
214
+ type: type,
215
+ key: key,
216
+ props: props,
217
+ _owner: owner
218
+ };
219
+ null !== (void 0 !== refProp ? refProp : null)
220
+ ? Object.defineProperty(type, "ref", {
221
+ enumerable: false,
222
+ get: elementRefGetterWithDeprecationWarning
223
+ })
224
+ : Object.defineProperty(type, "ref", { enumerable: false, value: null });
225
+ type._store = {};
226
+ Object.defineProperty(type._store, "validated", {
227
+ configurable: false,
228
+ enumerable: false,
229
+ writable: true,
230
+ value: 0
231
+ });
232
+ Object.defineProperty(type, "_debugInfo", {
233
+ configurable: false,
234
+ enumerable: false,
235
+ writable: true,
236
+ value: null
237
+ });
238
+ Object.defineProperty(type, "_debugStack", {
239
+ configurable: false,
240
+ enumerable: false,
241
+ writable: true,
242
+ value: debugStack
243
+ });
244
+ Object.defineProperty(type, "_debugTask", {
245
+ configurable: false,
246
+ enumerable: false,
247
+ writable: true,
248
+ value: debugTask
249
+ });
250
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
251
+ return type;
252
+ }
253
+ function jsxDEVImpl(
254
+ type,
255
+ config,
256
+ maybeKey,
257
+ isStaticChildren,
258
+ debugStack,
259
+ debugTask
260
+ ) {
261
+ var children = config.children;
262
+ if (void 0 !== children)
263
+ if (isStaticChildren)
264
+ if (isArrayImpl(children)) {
265
+ for (
266
+ isStaticChildren = 0;
267
+ isStaticChildren < children.length;
268
+ isStaticChildren++
269
+ )
270
+ validateChildKeys(children[isStaticChildren]);
271
+ Object.freeze && Object.freeze(children);
272
+ } else
273
+ console.error(
274
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
275
+ );
276
+ else validateChildKeys(children);
277
+ if (hasOwnProperty.call(config, "key")) {
278
+ children = getComponentNameFromType(type);
279
+ var keys = Object.keys(config).filter(function (k) {
280
+ return "key" !== k;
281
+ });
282
+ isStaticChildren =
283
+ 0 < keys.length
284
+ ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
285
+ : "{key: someKey}";
286
+ didWarnAboutKeySpread[children + isStaticChildren] ||
287
+ ((keys =
288
+ 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
289
+ console.error(
290
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
291
+ isStaticChildren,
292
+ children,
293
+ keys,
294
+ children
295
+ ),
296
+ (didWarnAboutKeySpread[children + isStaticChildren] = true));
297
+ }
298
+ children = null;
299
+ void 0 !== maybeKey &&
300
+ (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
301
+ hasValidKey(config) &&
302
+ (checkKeyStringCoercion(config.key), (children = "" + config.key));
303
+ if ("key" in config) {
304
+ maybeKey = {};
305
+ for (var propName in config)
306
+ "key" !== propName && (maybeKey[propName] = config[propName]);
307
+ } else maybeKey = config;
308
+ children &&
309
+ defineKeyPropWarningGetter(
310
+ maybeKey,
311
+ "function" === typeof type
312
+ ? type.displayName || type.name || "Unknown"
313
+ : type
314
+ );
315
+ return ReactElement(
316
+ type,
317
+ children,
318
+ maybeKey,
319
+ getOwner(),
320
+ debugStack,
321
+ debugTask
322
+ );
323
+ }
324
+ function validateChildKeys(node) {
325
+ isValidElement(node)
326
+ ? node._store && (node._store.validated = 1)
327
+ : "object" === typeof node &&
328
+ null !== node &&
329
+ node.$$typeof === REACT_LAZY_TYPE &&
330
+ ("fulfilled" === node._payload.status
331
+ ? isValidElement(node._payload.value) &&
332
+ node._payload.value._store &&
333
+ (node._payload.value._store.validated = 1)
334
+ : node._store && (node._store.validated = 1));
335
+ }
336
+ function isValidElement(object) {
337
+ return (
338
+ "object" === typeof object &&
339
+ null !== object &&
340
+ object.$$typeof === REACT_ELEMENT_TYPE
341
+ );
342
+ }
343
+ var React = require$$0,
344
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
345
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
346
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
347
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
348
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
349
+ REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
350
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
351
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
352
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
353
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
354
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
355
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
356
+ REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
357
+ REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
358
+ ReactSharedInternals =
359
+ React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
360
+ hasOwnProperty = Object.prototype.hasOwnProperty,
361
+ isArrayImpl = Array.isArray,
362
+ createTask = console.createTask
363
+ ? console.createTask
364
+ : function () {
365
+ return null;
366
+ };
367
+ React = {
368
+ react_stack_bottom_frame: function (callStackForError) {
369
+ return callStackForError();
370
+ }
371
+ };
372
+ var specialPropKeyWarningShown;
373
+ var didWarnAboutElementRef = {};
374
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
375
+ React,
376
+ UnknownOwner
377
+ )();
378
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
379
+ var didWarnAboutKeySpread = {};
380
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
381
+ reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
382
+ var trackActualOwner =
383
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
384
+ return jsxDEVImpl(
385
+ type,
386
+ config,
387
+ maybeKey,
388
+ false,
389
+ trackActualOwner
390
+ ? Error("react-stack-top-frame")
391
+ : unknownOwnerDebugStack,
392
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
393
+ );
394
+ };
395
+ reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
396
+ var trackActualOwner =
397
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
398
+ return jsxDEVImpl(
399
+ type,
400
+ config,
401
+ maybeKey,
402
+ true,
403
+ trackActualOwner
404
+ ? Error("react-stack-top-frame")
405
+ : unknownOwnerDebugStack,
406
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
407
+ );
408
+ };
409
+ })();
410
+ return reactJsxRuntime_development;
411
+ }
412
+
413
+ var hasRequiredJsxRuntime;
414
+
415
+ function requireJsxRuntime () {
416
+ if (hasRequiredJsxRuntime) return jsxRuntime.exports;
417
+ hasRequiredJsxRuntime = 1;
418
+
419
+ if (process.env.NODE_ENV === 'production') {
420
+ jsxRuntime.exports = requireReactJsxRuntime_production();
421
+ } else {
422
+ jsxRuntime.exports = requireReactJsxRuntime_development();
423
+ }
424
+ return jsxRuntime.exports;
425
+ }
426
+
427
+ var jsxRuntimeExports = requireJsxRuntime();
428
+
429
+ const sizeClasses = {
430
+ sm: {
431
+ radio: "w-3 h-3",
432
+ label: "text-xs",
433
+ description: "text-[10px]",
434
+ container: "h-4",
435
+ },
436
+ md: {
437
+ radio: "w-4 h-4",
438
+ label: "text-sm",
439
+ description: "text-xs",
440
+ container: "h-5",
441
+ },
442
+ lg: {
443
+ radio: "w-5 h-5",
444
+ label: "text-base",
445
+ description: "text-sm",
446
+ container: "h-6",
447
+ },
448
+ };
449
+ const variantClasses = {
450
+ default: {
451
+ checked: "text-blue-600",
452
+ focus: "focus:ring-blue-500",
453
+ },
454
+ primary: {
455
+ checked: "text-indigo-600",
456
+ focus: "focus:ring-indigo-500",
457
+ },
458
+ success: {
459
+ checked: "text-green-600",
460
+ focus: "focus:ring-green-500",
461
+ },
462
+ warning: {
463
+ checked: "text-yellow-600",
464
+ focus: "focus:ring-yellow-500",
465
+ },
466
+ danger: {
467
+ checked: "text-red-600",
468
+ focus: "focus:ring-red-500",
469
+ },
470
+ };
471
+ const RadioButton = ({ id, name, label, value, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", }) => {
472
+ const radioId = id || `radio-${name}-${value}`;
473
+ const sizes = sizeClasses[size];
474
+ const variants = variantClasses[variant];
475
+ const handleChange = (event) => {
476
+ if (onChange && !disabled) {
477
+ onChange(event.target.value);
478
+ }
479
+ };
480
+ return (jsxRuntimeExports.jsxs("div", { className: `flex ${className}`, children: [jsxRuntimeExports.jsx("div", { className: `flex items-start ${sizes.container}`, children: jsxRuntimeExports.jsx("input", { id: radioId, name: name, type: "radio", value: value, checked: checked, onChange: handleChange, disabled: disabled, required: required, className: `
481
+ ${sizes.radio}
482
+ ${required && !checked ? "border-red-500" : "border-gray-300"}
483
+ ${variants.checked}
484
+ ${variants.focus}
485
+ focus:ring-2
486
+ focus:ring-offset-0
487
+ disabled:opacity-50
488
+ disabled:cursor-not-allowed
489
+ cursor-pointer
490
+ transition-colors
491
+ `, "aria-describedby": description ? `${radioId}-description` : undefined, "aria-invalid": !!error }) }), jsxRuntimeExports.jsxs("div", { className: "ml-3 flex-1", children: [jsxRuntimeExports.jsx("label", { htmlFor: radioId, className: `
492
+ ${sizes.label}
493
+ font-medium
494
+ ${disabled ? "text-gray-400 cursor-not-allowed" : required && !checked ? "text-red-600 cursor-pointer" : "text-gray-700 cursor-pointer"}
495
+ block
496
+ `, children: label }), description && (jsxRuntimeExports.jsx("p", { id: `${radioId}-description`, className: `${sizes.description} text-gray-500 mt-0.5`, children: description })), error && (jsxRuntimeExports.jsx("p", { className: `${sizes.description} text-red-600 mt-0.5`, children: error }))] })] }));
497
+ };
498
+
499
+ const RadioGroup = ({ name, options, value, onChange, orientation = "vertical", size = "md", variant = "default", disabled = false, required = false, error, className = "", showSelectedLabel = false, selectedLabelText = "Selected:", groupLabel, bordered = false, borderLabel, }) => {
500
+ const orientationClasses = {
501
+ vertical: "flex flex-col space-y-3",
502
+ horizontal: "flex flex-row flex-wrap gap-4",
503
+ };
504
+ const selectedOption = options.find((option) => option.value === value);
505
+ const radioGroupContent = (jsxRuntimeExports.jsx("div", { className: orientationClasses[orientation], role: "radiogroup", children: options.map((option) => (jsxRuntimeExports.jsx(RadioButton, { name: name, label: option.label, value: option.value, checked: value === option.value, onChange: onChange, description: option.description, disabled: disabled || option.disabled, required: required, size: size, variant: variant }, option.value))) }));
506
+ return (jsxRuntimeExports.jsxs("div", { className: className, children: [groupLabel && (jsxRuntimeExports.jsx("div", { className: `font-semibold mb-3 ${required && !value ? "text-red-600" : "text-gray-900"}`, children: groupLabel })), bordered ? (jsxRuntimeExports.jsxs("fieldset", { className: `rounded-lg p-4 ${required && !value ? "border-2 border-red-500" : "border border-gray-300"}`, children: [borderLabel && (jsxRuntimeExports.jsx("legend", { className: `px-2 text-sm font-medium ${required && !value ? "text-red-600" : "text-gray-700"}`, children: borderLabel })), radioGroupContent] })) : (radioGroupContent), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-red-600 mt-2", children: error }), showSelectedLabel && (jsxRuntimeExports.jsxs("div", { className: "mt-4 p-3 bg-gray-100 rounded", children: [jsxRuntimeExports.jsx("strong", { children: selectedLabelText }), " ", selectedOption?.label || value || "None"] }))] }));
507
+ };
508
+
509
+ exports.RadioGroup = RadioGroup;
510
+ exports.default = RadioButton;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+
3
+ type RadioSize = "sm" | "md" | "lg";
4
+ type RadioVariant = "default" | "primary" | "success" | "warning" | "danger";
5
+ interface RadioButtonProps {
6
+ id?: string;
7
+ name: string;
8
+ label: string;
9
+ value: string;
10
+ checked?: boolean;
11
+ onChange?: (value: string) => void;
12
+ disabled?: boolean;
13
+ description?: string;
14
+ error?: string;
15
+ className?: string;
16
+ required?: boolean;
17
+ size?: RadioSize;
18
+ variant?: RadioVariant;
19
+ }
20
+ declare const RadioButton: React.FC<RadioButtonProps>;
21
+
22
+ type RadioGroupOrientation = "vertical" | "horizontal";
23
+ interface RadioOption {
24
+ label: string;
25
+ value: string;
26
+ description?: string;
27
+ disabled?: boolean;
28
+ }
29
+ interface RadioGroupProps {
30
+ name: string;
31
+ options: RadioOption[];
32
+ value?: string;
33
+ onChange: (value: string) => void;
34
+ orientation?: RadioGroupOrientation;
35
+ size?: RadioSize;
36
+ variant?: RadioVariant;
37
+ disabled?: boolean;
38
+ required?: boolean;
39
+ error?: string;
40
+ className?: string;
41
+ showSelectedLabel?: boolean;
42
+ selectedLabelText?: string;
43
+ groupLabel?: string;
44
+ bordered?: boolean;
45
+ borderLabel?: string;
46
+ }
47
+ declare const RadioGroup: React.FC<RadioGroupProps>;
48
+
49
+ export { RadioGroup, RadioButton as default };
50
+ export type { RadioButtonProps, RadioGroupOrientation, RadioGroupProps, RadioOption, RadioSize, RadioVariant };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/E,YAAY,EACV,eAAe,EACf,WAAW,EACX,qBAAqB,GACtB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,505 @@
1
+ import require$$0 from 'react';
2
+
3
+ var jsxRuntime = {exports: {}};
4
+
5
+ var reactJsxRuntime_production = {};
6
+
7
+ /**
8
+ * @license React
9
+ * react-jsx-runtime.production.js
10
+ *
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+
17
+ var hasRequiredReactJsxRuntime_production;
18
+
19
+ function requireReactJsxRuntime_production () {
20
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
21
+ hasRequiredReactJsxRuntime_production = 1;
22
+ var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
23
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
24
+ function jsxProd(type, config, maybeKey) {
25
+ var key = null;
26
+ void 0 !== maybeKey && (key = "" + maybeKey);
27
+ void 0 !== config.key && (key = "" + config.key);
28
+ if ("key" in config) {
29
+ maybeKey = {};
30
+ for (var propName in config)
31
+ "key" !== propName && (maybeKey[propName] = config[propName]);
32
+ } else maybeKey = config;
33
+ config = maybeKey.ref;
34
+ return {
35
+ $$typeof: REACT_ELEMENT_TYPE,
36
+ type: type,
37
+ key: key,
38
+ ref: void 0 !== config ? config : null,
39
+ props: maybeKey
40
+ };
41
+ }
42
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
43
+ reactJsxRuntime_production.jsx = jsxProd;
44
+ reactJsxRuntime_production.jsxs = jsxProd;
45
+ return reactJsxRuntime_production;
46
+ }
47
+
48
+ var reactJsxRuntime_development = {};
49
+
50
+ /**
51
+ * @license React
52
+ * react-jsx-runtime.development.js
53
+ *
54
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
55
+ *
56
+ * This source code is licensed under the MIT license found in the
57
+ * LICENSE file in the root directory of this source tree.
58
+ */
59
+
60
+ var hasRequiredReactJsxRuntime_development;
61
+
62
+ function requireReactJsxRuntime_development () {
63
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
64
+ hasRequiredReactJsxRuntime_development = 1;
65
+ "production" !== process.env.NODE_ENV &&
66
+ (function () {
67
+ function getComponentNameFromType(type) {
68
+ if (null == type) return null;
69
+ if ("function" === typeof type)
70
+ return type.$$typeof === REACT_CLIENT_REFERENCE
71
+ ? null
72
+ : type.displayName || type.name || null;
73
+ if ("string" === typeof type) return type;
74
+ switch (type) {
75
+ case REACT_FRAGMENT_TYPE:
76
+ return "Fragment";
77
+ case REACT_PROFILER_TYPE:
78
+ return "Profiler";
79
+ case REACT_STRICT_MODE_TYPE:
80
+ return "StrictMode";
81
+ case REACT_SUSPENSE_TYPE:
82
+ return "Suspense";
83
+ case REACT_SUSPENSE_LIST_TYPE:
84
+ return "SuspenseList";
85
+ case REACT_ACTIVITY_TYPE:
86
+ return "Activity";
87
+ }
88
+ if ("object" === typeof type)
89
+ switch (
90
+ ("number" === typeof type.tag &&
91
+ console.error(
92
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
93
+ ),
94
+ type.$$typeof)
95
+ ) {
96
+ case REACT_PORTAL_TYPE:
97
+ return "Portal";
98
+ case REACT_CONTEXT_TYPE:
99
+ return type.displayName || "Context";
100
+ case REACT_CONSUMER_TYPE:
101
+ return (type._context.displayName || "Context") + ".Consumer";
102
+ case REACT_FORWARD_REF_TYPE:
103
+ var innerType = type.render;
104
+ type = type.displayName;
105
+ type ||
106
+ ((type = innerType.displayName || innerType.name || ""),
107
+ (type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef"));
108
+ return type;
109
+ case REACT_MEMO_TYPE:
110
+ return (
111
+ (innerType = type.displayName || null),
112
+ null !== innerType
113
+ ? innerType
114
+ : getComponentNameFromType(type.type) || "Memo"
115
+ );
116
+ case REACT_LAZY_TYPE:
117
+ innerType = type._payload;
118
+ type = type._init;
119
+ try {
120
+ return getComponentNameFromType(type(innerType));
121
+ } catch (x) {}
122
+ }
123
+ return null;
124
+ }
125
+ function testStringCoercion(value) {
126
+ return "" + value;
127
+ }
128
+ function checkKeyStringCoercion(value) {
129
+ try {
130
+ testStringCoercion(value);
131
+ var JSCompiler_inline_result = !1;
132
+ } catch (e) {
133
+ JSCompiler_inline_result = true;
134
+ }
135
+ if (JSCompiler_inline_result) {
136
+ JSCompiler_inline_result = console;
137
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
138
+ var JSCompiler_inline_result$jscomp$0 =
139
+ ("function" === typeof Symbol &&
140
+ Symbol.toStringTag &&
141
+ value[Symbol.toStringTag]) ||
142
+ value.constructor.name ||
143
+ "Object";
144
+ JSCompiler_temp_const.call(
145
+ JSCompiler_inline_result,
146
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
147
+ JSCompiler_inline_result$jscomp$0
148
+ );
149
+ return testStringCoercion(value);
150
+ }
151
+ }
152
+ function getTaskName(type) {
153
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
154
+ if (
155
+ "object" === typeof type &&
156
+ null !== type &&
157
+ type.$$typeof === REACT_LAZY_TYPE
158
+ )
159
+ return "<...>";
160
+ try {
161
+ var name = getComponentNameFromType(type);
162
+ return name ? "<" + name + ">" : "<...>";
163
+ } catch (x) {
164
+ return "<...>";
165
+ }
166
+ }
167
+ function getOwner() {
168
+ var dispatcher = ReactSharedInternals.A;
169
+ return null === dispatcher ? null : dispatcher.getOwner();
170
+ }
171
+ function UnknownOwner() {
172
+ return Error("react-stack-top-frame");
173
+ }
174
+ function hasValidKey(config) {
175
+ if (hasOwnProperty.call(config, "key")) {
176
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
177
+ if (getter && getter.isReactWarning) return false;
178
+ }
179
+ return void 0 !== config.key;
180
+ }
181
+ function defineKeyPropWarningGetter(props, displayName) {
182
+ function warnAboutAccessingKey() {
183
+ specialPropKeyWarningShown ||
184
+ ((specialPropKeyWarningShown = true),
185
+ console.error(
186
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
187
+ displayName
188
+ ));
189
+ }
190
+ warnAboutAccessingKey.isReactWarning = true;
191
+ Object.defineProperty(props, "key", {
192
+ get: warnAboutAccessingKey,
193
+ configurable: true
194
+ });
195
+ }
196
+ function elementRefGetterWithDeprecationWarning() {
197
+ var componentName = getComponentNameFromType(this.type);
198
+ didWarnAboutElementRef[componentName] ||
199
+ ((didWarnAboutElementRef[componentName] = true),
200
+ console.error(
201
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
202
+ ));
203
+ componentName = this.props.ref;
204
+ return void 0 !== componentName ? componentName : null;
205
+ }
206
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
207
+ var refProp = props.ref;
208
+ type = {
209
+ $$typeof: REACT_ELEMENT_TYPE,
210
+ type: type,
211
+ key: key,
212
+ props: props,
213
+ _owner: owner
214
+ };
215
+ null !== (void 0 !== refProp ? refProp : null)
216
+ ? Object.defineProperty(type, "ref", {
217
+ enumerable: false,
218
+ get: elementRefGetterWithDeprecationWarning
219
+ })
220
+ : Object.defineProperty(type, "ref", { enumerable: false, value: null });
221
+ type._store = {};
222
+ Object.defineProperty(type._store, "validated", {
223
+ configurable: false,
224
+ enumerable: false,
225
+ writable: true,
226
+ value: 0
227
+ });
228
+ Object.defineProperty(type, "_debugInfo", {
229
+ configurable: false,
230
+ enumerable: false,
231
+ writable: true,
232
+ value: null
233
+ });
234
+ Object.defineProperty(type, "_debugStack", {
235
+ configurable: false,
236
+ enumerable: false,
237
+ writable: true,
238
+ value: debugStack
239
+ });
240
+ Object.defineProperty(type, "_debugTask", {
241
+ configurable: false,
242
+ enumerable: false,
243
+ writable: true,
244
+ value: debugTask
245
+ });
246
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
247
+ return type;
248
+ }
249
+ function jsxDEVImpl(
250
+ type,
251
+ config,
252
+ maybeKey,
253
+ isStaticChildren,
254
+ debugStack,
255
+ debugTask
256
+ ) {
257
+ var children = config.children;
258
+ if (void 0 !== children)
259
+ if (isStaticChildren)
260
+ if (isArrayImpl(children)) {
261
+ for (
262
+ isStaticChildren = 0;
263
+ isStaticChildren < children.length;
264
+ isStaticChildren++
265
+ )
266
+ validateChildKeys(children[isStaticChildren]);
267
+ Object.freeze && Object.freeze(children);
268
+ } else
269
+ console.error(
270
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
271
+ );
272
+ else validateChildKeys(children);
273
+ if (hasOwnProperty.call(config, "key")) {
274
+ children = getComponentNameFromType(type);
275
+ var keys = Object.keys(config).filter(function (k) {
276
+ return "key" !== k;
277
+ });
278
+ isStaticChildren =
279
+ 0 < keys.length
280
+ ? "{key: someKey, " + keys.join(": ..., ") + ": ...}"
281
+ : "{key: someKey}";
282
+ didWarnAboutKeySpread[children + isStaticChildren] ||
283
+ ((keys =
284
+ 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}"),
285
+ console.error(
286
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
287
+ isStaticChildren,
288
+ children,
289
+ keys,
290
+ children
291
+ ),
292
+ (didWarnAboutKeySpread[children + isStaticChildren] = true));
293
+ }
294
+ children = null;
295
+ void 0 !== maybeKey &&
296
+ (checkKeyStringCoercion(maybeKey), (children = "" + maybeKey));
297
+ hasValidKey(config) &&
298
+ (checkKeyStringCoercion(config.key), (children = "" + config.key));
299
+ if ("key" in config) {
300
+ maybeKey = {};
301
+ for (var propName in config)
302
+ "key" !== propName && (maybeKey[propName] = config[propName]);
303
+ } else maybeKey = config;
304
+ children &&
305
+ defineKeyPropWarningGetter(
306
+ maybeKey,
307
+ "function" === typeof type
308
+ ? type.displayName || type.name || "Unknown"
309
+ : type
310
+ );
311
+ return ReactElement(
312
+ type,
313
+ children,
314
+ maybeKey,
315
+ getOwner(),
316
+ debugStack,
317
+ debugTask
318
+ );
319
+ }
320
+ function validateChildKeys(node) {
321
+ isValidElement(node)
322
+ ? node._store && (node._store.validated = 1)
323
+ : "object" === typeof node &&
324
+ null !== node &&
325
+ node.$$typeof === REACT_LAZY_TYPE &&
326
+ ("fulfilled" === node._payload.status
327
+ ? isValidElement(node._payload.value) &&
328
+ node._payload.value._store &&
329
+ (node._payload.value._store.validated = 1)
330
+ : node._store && (node._store.validated = 1));
331
+ }
332
+ function isValidElement(object) {
333
+ return (
334
+ "object" === typeof object &&
335
+ null !== object &&
336
+ object.$$typeof === REACT_ELEMENT_TYPE
337
+ );
338
+ }
339
+ var React = require$$0,
340
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
341
+ REACT_PORTAL_TYPE = Symbol.for("react.portal"),
342
+ REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
343
+ REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
344
+ REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
345
+ REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
346
+ REACT_CONTEXT_TYPE = Symbol.for("react.context"),
347
+ REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
348
+ REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
349
+ REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
350
+ REACT_MEMO_TYPE = Symbol.for("react.memo"),
351
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
352
+ REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
353
+ REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
354
+ ReactSharedInternals =
355
+ React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
356
+ hasOwnProperty = Object.prototype.hasOwnProperty,
357
+ isArrayImpl = Array.isArray,
358
+ createTask = console.createTask
359
+ ? console.createTask
360
+ : function () {
361
+ return null;
362
+ };
363
+ React = {
364
+ react_stack_bottom_frame: function (callStackForError) {
365
+ return callStackForError();
366
+ }
367
+ };
368
+ var specialPropKeyWarningShown;
369
+ var didWarnAboutElementRef = {};
370
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
371
+ React,
372
+ UnknownOwner
373
+ )();
374
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
375
+ var didWarnAboutKeySpread = {};
376
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
377
+ reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
378
+ var trackActualOwner =
379
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
380
+ return jsxDEVImpl(
381
+ type,
382
+ config,
383
+ maybeKey,
384
+ false,
385
+ trackActualOwner
386
+ ? Error("react-stack-top-frame")
387
+ : unknownOwnerDebugStack,
388
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
389
+ );
390
+ };
391
+ reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
392
+ var trackActualOwner =
393
+ 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
394
+ return jsxDEVImpl(
395
+ type,
396
+ config,
397
+ maybeKey,
398
+ true,
399
+ trackActualOwner
400
+ ? Error("react-stack-top-frame")
401
+ : unknownOwnerDebugStack,
402
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
403
+ );
404
+ };
405
+ })();
406
+ return reactJsxRuntime_development;
407
+ }
408
+
409
+ var hasRequiredJsxRuntime;
410
+
411
+ function requireJsxRuntime () {
412
+ if (hasRequiredJsxRuntime) return jsxRuntime.exports;
413
+ hasRequiredJsxRuntime = 1;
414
+
415
+ if (process.env.NODE_ENV === 'production') {
416
+ jsxRuntime.exports = requireReactJsxRuntime_production();
417
+ } else {
418
+ jsxRuntime.exports = requireReactJsxRuntime_development();
419
+ }
420
+ return jsxRuntime.exports;
421
+ }
422
+
423
+ var jsxRuntimeExports = requireJsxRuntime();
424
+
425
+ const sizeClasses = {
426
+ sm: {
427
+ radio: "w-3 h-3",
428
+ label: "text-xs",
429
+ description: "text-[10px]",
430
+ container: "h-4",
431
+ },
432
+ md: {
433
+ radio: "w-4 h-4",
434
+ label: "text-sm",
435
+ description: "text-xs",
436
+ container: "h-5",
437
+ },
438
+ lg: {
439
+ radio: "w-5 h-5",
440
+ label: "text-base",
441
+ description: "text-sm",
442
+ container: "h-6",
443
+ },
444
+ };
445
+ const variantClasses = {
446
+ default: {
447
+ checked: "text-blue-600",
448
+ focus: "focus:ring-blue-500",
449
+ },
450
+ primary: {
451
+ checked: "text-indigo-600",
452
+ focus: "focus:ring-indigo-500",
453
+ },
454
+ success: {
455
+ checked: "text-green-600",
456
+ focus: "focus:ring-green-500",
457
+ },
458
+ warning: {
459
+ checked: "text-yellow-600",
460
+ focus: "focus:ring-yellow-500",
461
+ },
462
+ danger: {
463
+ checked: "text-red-600",
464
+ focus: "focus:ring-red-500",
465
+ },
466
+ };
467
+ const RadioButton = ({ id, name, label, value, checked = false, onChange, disabled = false, description, error, className = "", required = false, size = "md", variant = "default", }) => {
468
+ const radioId = id || `radio-${name}-${value}`;
469
+ const sizes = sizeClasses[size];
470
+ const variants = variantClasses[variant];
471
+ const handleChange = (event) => {
472
+ if (onChange && !disabled) {
473
+ onChange(event.target.value);
474
+ }
475
+ };
476
+ return (jsxRuntimeExports.jsxs("div", { className: `flex ${className}`, children: [jsxRuntimeExports.jsx("div", { className: `flex items-start ${sizes.container}`, children: jsxRuntimeExports.jsx("input", { id: radioId, name: name, type: "radio", value: value, checked: checked, onChange: handleChange, disabled: disabled, required: required, className: `
477
+ ${sizes.radio}
478
+ ${required && !checked ? "border-red-500" : "border-gray-300"}
479
+ ${variants.checked}
480
+ ${variants.focus}
481
+ focus:ring-2
482
+ focus:ring-offset-0
483
+ disabled:opacity-50
484
+ disabled:cursor-not-allowed
485
+ cursor-pointer
486
+ transition-colors
487
+ `, "aria-describedby": description ? `${radioId}-description` : undefined, "aria-invalid": !!error }) }), jsxRuntimeExports.jsxs("div", { className: "ml-3 flex-1", children: [jsxRuntimeExports.jsx("label", { htmlFor: radioId, className: `
488
+ ${sizes.label}
489
+ font-medium
490
+ ${disabled ? "text-gray-400 cursor-not-allowed" : required && !checked ? "text-red-600 cursor-pointer" : "text-gray-700 cursor-pointer"}
491
+ block
492
+ `, children: label }), description && (jsxRuntimeExports.jsx("p", { id: `${radioId}-description`, className: `${sizes.description} text-gray-500 mt-0.5`, children: description })), error && (jsxRuntimeExports.jsx("p", { className: `${sizes.description} text-red-600 mt-0.5`, children: error }))] })] }));
493
+ };
494
+
495
+ const RadioGroup = ({ name, options, value, onChange, orientation = "vertical", size = "md", variant = "default", disabled = false, required = false, error, className = "", showSelectedLabel = false, selectedLabelText = "Selected:", groupLabel, bordered = false, borderLabel, }) => {
496
+ const orientationClasses = {
497
+ vertical: "flex flex-col space-y-3",
498
+ horizontal: "flex flex-row flex-wrap gap-4",
499
+ };
500
+ const selectedOption = options.find((option) => option.value === value);
501
+ const radioGroupContent = (jsxRuntimeExports.jsx("div", { className: orientationClasses[orientation], role: "radiogroup", children: options.map((option) => (jsxRuntimeExports.jsx(RadioButton, { name: name, label: option.label, value: option.value, checked: value === option.value, onChange: onChange, description: option.description, disabled: disabled || option.disabled, required: required, size: size, variant: variant }, option.value))) }));
502
+ return (jsxRuntimeExports.jsxs("div", { className: className, children: [groupLabel && (jsxRuntimeExports.jsx("div", { className: `font-semibold mb-3 ${required && !value ? "text-red-600" : "text-gray-900"}`, children: groupLabel })), bordered ? (jsxRuntimeExports.jsxs("fieldset", { className: `rounded-lg p-4 ${required && !value ? "border-2 border-red-500" : "border border-gray-300"}`, children: [borderLabel && (jsxRuntimeExports.jsx("legend", { className: `px-2 text-sm font-medium ${required && !value ? "text-red-600" : "text-gray-700"}`, children: borderLabel })), radioGroupContent] })) : (radioGroupContent), error && jsxRuntimeExports.jsx("p", { className: "text-sm text-red-600 mt-2", children: error }), showSelectedLabel && (jsxRuntimeExports.jsxs("div", { className: "mt-4 p-3 bg-gray-100 rounded", children: [jsxRuntimeExports.jsx("strong", { children: selectedLabelText }), " ", selectedOption?.label || value || "None"] }))] }));
503
+ };
504
+
505
+ export { RadioGroup, RadioButton as default };
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@rubenpazch/radio-button",
3
+ "version": "1.0.0",
4
+ "description": "Accessible radio button and radio group components with variants and validation",
5
+ "private": false,
6
+ "main": "dist/index.cjs.js",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/rubenpazch/lbyte-ui-library.git",
12
+ "directory": "packages/radio-button"
13
+ },
14
+ "author": "Ruben Paz Chuspe <rubenpazchuspe@outlook.com>",
15
+ "license": "MIT",
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "sideEffects": false,
20
+ "exports": {
21
+ ".": {
22
+ "import": "./dist/index.esm.js",
23
+ "require": "./dist/index.cjs.js",
24
+ "types": "./dist/index.d.ts"
25
+ }
26
+ },
27
+ "peerDependencies": {
28
+ "react": "^19.0.0",
29
+ "react-dom": "^19.0.0"
30
+ },
31
+ "devDependencies": {
32
+ "@rubenpazch/typescript-config": "2.0.0"
33
+ },
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
37
+ "scripts": {
38
+ "build": "rollup -c",
39
+ "test": "jest --passWithNoTests"
40
+ }
41
+ }