@rehagro/ui 1.0.31 → 1.0.32

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/native.d.mts CHANGED
@@ -477,4 +477,88 @@ type SelectMultipleProps = SelectBaseProps & {
477
477
  type SelectProps = SelectSingleProps | SelectMultipleProps;
478
478
  declare const Select: React__default.ForwardRefExoticComponent<SelectProps & React__default.RefAttributes<View>>;
479
479
 
480
- export { ActivityIndicator, type ActivityIndicatorColor, type ActivityIndicatorProps, type ActivityIndicatorSize, Avatar, type AvatarProps, type AvatarSize, type AvatarVariant, Button, ButtonColor, type ButtonProps, type ButtonRadius, type ButtonSize, type ButtonVariant, Card, CardContent, type CardContentProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardPadding, type CardProps, type CardRadius, type CardVariant, Checkbox, type CheckboxProps, type CheckboxSize, IconButton, type IconButtonColor, type IconButtonProps, type IconButtonRadius, type IconButtonSize, type IconButtonVariant, RehagroNativeProvider, type RehagroNativeProviderProps, type RehagroNativeTheme, Select, type SelectMultipleProps, type SelectOption, type SelectProps, type SelectRadius, type SelectSingleProps, type SelectSize, type SelectStatus, Tag, type TagColor, type TagProps, type TagSize, Text, type TextColor, TextInput, type TextInputProps, type TextInputRadius, type TextInputSize, type TextInputStatus, type TextProps, type TextSize, useRehagroTheme };
480
+ type RadioSize = "sm" | "md" | "lg";
481
+ type RadioOrientation = "horizontal" | "vertical";
482
+ type RadioColor = "primary" | "secondary" | "danger" | "warning" | "success" | "info";
483
+ type RadioBaseProps = Omit<PressableProps, "style" | "onPress"> & {
484
+ /** Radio size */
485
+ size?: RadioSize;
486
+ /** Label text displayed next to the radio */
487
+ label?: React__default.ReactNode;
488
+ /** Description text below the label */
489
+ description?: React__default.ReactNode;
490
+ /** Color scheme for checked state — preset name or custom color string */
491
+ color?: RadioColor | (string & {});
492
+ /** Custom style for the outer wrapper */
493
+ style?: StyleProp<ViewStyle>;
494
+ };
495
+ type RadioProps = RadioBaseProps & {
496
+ /** Controlled checked state */
497
+ checked?: boolean;
498
+ /** Default checked state (uncontrolled) */
499
+ defaultChecked?: boolean;
500
+ /** Callback fired when the value changes */
501
+ onChange?: (checked: boolean) => void;
502
+ };
503
+ type RadioOptionProps = RadioBaseProps & {
504
+ /** Unique value for this option */
505
+ value: string;
506
+ };
507
+ type RadioGroupProps = {
508
+ children?: React__default.ReactNode;
509
+ /** Currently selected value */
510
+ value?: string;
511
+ /** Default value (uncontrolled) */
512
+ defaultValue?: string;
513
+ /** Called when selection changes */
514
+ onChange?: (value: string) => void;
515
+ /** Radio size for all items */
516
+ size?: RadioSize;
517
+ /** Layout orientation */
518
+ orientation?: RadioOrientation;
519
+ /** Color scheme for checked state */
520
+ color?: RadioColor | (string & {});
521
+ /** Whether the entire group is disabled */
522
+ disabled?: boolean;
523
+ /** Gap between items */
524
+ gap?: "sm" | "md" | "lg";
525
+ /** Custom style for the group wrapper */
526
+ style?: StyleProp<ViewStyle>;
527
+ };
528
+ declare const Radio: React__default.ForwardRefExoticComponent<Omit<PressableProps, "style" | "onPress"> & {
529
+ /** Radio size */
530
+ size?: RadioSize;
531
+ /** Label text displayed next to the radio */
532
+ label?: React__default.ReactNode;
533
+ /** Description text below the label */
534
+ description?: React__default.ReactNode;
535
+ /** Color scheme for checked state — preset name or custom color string */
536
+ color?: RadioColor | (string & {});
537
+ /** Custom style for the outer wrapper */
538
+ style?: StyleProp<ViewStyle>;
539
+ } & {
540
+ /** Controlled checked state */
541
+ checked?: boolean;
542
+ /** Default checked state (uncontrolled) */
543
+ defaultChecked?: boolean;
544
+ /** Callback fired when the value changes */
545
+ onChange?: (checked: boolean) => void;
546
+ } & React__default.RefAttributes<View>>;
547
+ declare const RadioOption: React__default.ForwardRefExoticComponent<Omit<PressableProps, "style" | "onPress"> & {
548
+ /** Radio size */
549
+ size?: RadioSize;
550
+ /** Label text displayed next to the radio */
551
+ label?: React__default.ReactNode;
552
+ /** Description text below the label */
553
+ description?: React__default.ReactNode;
554
+ /** Color scheme for checked state — preset name or custom color string */
555
+ color?: RadioColor | (string & {});
556
+ /** Custom style for the outer wrapper */
557
+ style?: StyleProp<ViewStyle>;
558
+ } & {
559
+ /** Unique value for this option */
560
+ value: string;
561
+ } & React__default.RefAttributes<View>>;
562
+ declare const RadioGroup: React__default.ForwardRefExoticComponent<RadioGroupProps & React__default.RefAttributes<View>>;
563
+
564
+ export { ActivityIndicator, type ActivityIndicatorColor, type ActivityIndicatorProps, type ActivityIndicatorSize, Avatar, type AvatarProps, type AvatarSize, type AvatarVariant, Button, ButtonColor, type ButtonProps, type ButtonRadius, type ButtonSize, type ButtonVariant, Card, CardContent, type CardContentProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardPadding, type CardProps, type CardRadius, type CardVariant, Checkbox, type CheckboxProps, type CheckboxSize, IconButton, type IconButtonColor, type IconButtonProps, type IconButtonRadius, type IconButtonSize, type IconButtonVariant, Radio, type RadioColor, RadioGroup, type RadioGroupProps, RadioOption, type RadioOptionProps, type RadioOrientation, type RadioProps, type RadioSize, RehagroNativeProvider, type RehagroNativeProviderProps, type RehagroNativeTheme, Select, type SelectMultipleProps, type SelectOption, type SelectProps, type SelectRadius, type SelectSingleProps, type SelectSize, type SelectStatus, Tag, type TagColor, type TagProps, type TagSize, Text, type TextColor, TextInput, type TextInputProps, type TextInputRadius, type TextInputSize, type TextInputStatus, type TextProps, type TextSize, useRehagroTheme };
package/dist/native.d.ts CHANGED
@@ -477,4 +477,88 @@ type SelectMultipleProps = SelectBaseProps & {
477
477
  type SelectProps = SelectSingleProps | SelectMultipleProps;
478
478
  declare const Select: React__default.ForwardRefExoticComponent<SelectProps & React__default.RefAttributes<View>>;
479
479
 
480
- export { ActivityIndicator, type ActivityIndicatorColor, type ActivityIndicatorProps, type ActivityIndicatorSize, Avatar, type AvatarProps, type AvatarSize, type AvatarVariant, Button, ButtonColor, type ButtonProps, type ButtonRadius, type ButtonSize, type ButtonVariant, Card, CardContent, type CardContentProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardPadding, type CardProps, type CardRadius, type CardVariant, Checkbox, type CheckboxProps, type CheckboxSize, IconButton, type IconButtonColor, type IconButtonProps, type IconButtonRadius, type IconButtonSize, type IconButtonVariant, RehagroNativeProvider, type RehagroNativeProviderProps, type RehagroNativeTheme, Select, type SelectMultipleProps, type SelectOption, type SelectProps, type SelectRadius, type SelectSingleProps, type SelectSize, type SelectStatus, Tag, type TagColor, type TagProps, type TagSize, Text, type TextColor, TextInput, type TextInputProps, type TextInputRadius, type TextInputSize, type TextInputStatus, type TextProps, type TextSize, useRehagroTheme };
480
+ type RadioSize = "sm" | "md" | "lg";
481
+ type RadioOrientation = "horizontal" | "vertical";
482
+ type RadioColor = "primary" | "secondary" | "danger" | "warning" | "success" | "info";
483
+ type RadioBaseProps = Omit<PressableProps, "style" | "onPress"> & {
484
+ /** Radio size */
485
+ size?: RadioSize;
486
+ /** Label text displayed next to the radio */
487
+ label?: React__default.ReactNode;
488
+ /** Description text below the label */
489
+ description?: React__default.ReactNode;
490
+ /** Color scheme for checked state — preset name or custom color string */
491
+ color?: RadioColor | (string & {});
492
+ /** Custom style for the outer wrapper */
493
+ style?: StyleProp<ViewStyle>;
494
+ };
495
+ type RadioProps = RadioBaseProps & {
496
+ /** Controlled checked state */
497
+ checked?: boolean;
498
+ /** Default checked state (uncontrolled) */
499
+ defaultChecked?: boolean;
500
+ /** Callback fired when the value changes */
501
+ onChange?: (checked: boolean) => void;
502
+ };
503
+ type RadioOptionProps = RadioBaseProps & {
504
+ /** Unique value for this option */
505
+ value: string;
506
+ };
507
+ type RadioGroupProps = {
508
+ children?: React__default.ReactNode;
509
+ /** Currently selected value */
510
+ value?: string;
511
+ /** Default value (uncontrolled) */
512
+ defaultValue?: string;
513
+ /** Called when selection changes */
514
+ onChange?: (value: string) => void;
515
+ /** Radio size for all items */
516
+ size?: RadioSize;
517
+ /** Layout orientation */
518
+ orientation?: RadioOrientation;
519
+ /** Color scheme for checked state */
520
+ color?: RadioColor | (string & {});
521
+ /** Whether the entire group is disabled */
522
+ disabled?: boolean;
523
+ /** Gap between items */
524
+ gap?: "sm" | "md" | "lg";
525
+ /** Custom style for the group wrapper */
526
+ style?: StyleProp<ViewStyle>;
527
+ };
528
+ declare const Radio: React__default.ForwardRefExoticComponent<Omit<PressableProps, "style" | "onPress"> & {
529
+ /** Radio size */
530
+ size?: RadioSize;
531
+ /** Label text displayed next to the radio */
532
+ label?: React__default.ReactNode;
533
+ /** Description text below the label */
534
+ description?: React__default.ReactNode;
535
+ /** Color scheme for checked state — preset name or custom color string */
536
+ color?: RadioColor | (string & {});
537
+ /** Custom style for the outer wrapper */
538
+ style?: StyleProp<ViewStyle>;
539
+ } & {
540
+ /** Controlled checked state */
541
+ checked?: boolean;
542
+ /** Default checked state (uncontrolled) */
543
+ defaultChecked?: boolean;
544
+ /** Callback fired when the value changes */
545
+ onChange?: (checked: boolean) => void;
546
+ } & React__default.RefAttributes<View>>;
547
+ declare const RadioOption: React__default.ForwardRefExoticComponent<Omit<PressableProps, "style" | "onPress"> & {
548
+ /** Radio size */
549
+ size?: RadioSize;
550
+ /** Label text displayed next to the radio */
551
+ label?: React__default.ReactNode;
552
+ /** Description text below the label */
553
+ description?: React__default.ReactNode;
554
+ /** Color scheme for checked state — preset name or custom color string */
555
+ color?: RadioColor | (string & {});
556
+ /** Custom style for the outer wrapper */
557
+ style?: StyleProp<ViewStyle>;
558
+ } & {
559
+ /** Unique value for this option */
560
+ value: string;
561
+ } & React__default.RefAttributes<View>>;
562
+ declare const RadioGroup: React__default.ForwardRefExoticComponent<RadioGroupProps & React__default.RefAttributes<View>>;
563
+
564
+ export { ActivityIndicator, type ActivityIndicatorColor, type ActivityIndicatorProps, type ActivityIndicatorSize, Avatar, type AvatarProps, type AvatarSize, type AvatarVariant, Button, ButtonColor, type ButtonProps, type ButtonRadius, type ButtonSize, type ButtonVariant, Card, CardContent, type CardContentProps, CardFooter, type CardFooterProps, CardHeader, type CardHeaderProps, type CardPadding, type CardProps, type CardRadius, type CardVariant, Checkbox, type CheckboxProps, type CheckboxSize, IconButton, type IconButtonColor, type IconButtonProps, type IconButtonRadius, type IconButtonSize, type IconButtonVariant, Radio, type RadioColor, RadioGroup, type RadioGroupProps, RadioOption, type RadioOptionProps, type RadioOrientation, type RadioProps, type RadioSize, RehagroNativeProvider, type RehagroNativeProviderProps, type RehagroNativeTheme, Select, type SelectMultipleProps, type SelectOption, type SelectProps, type SelectRadius, type SelectSingleProps, type SelectSize, type SelectStatus, Tag, type TagColor, type TagProps, type TagSize, Text, type TextColor, TextInput, type TextInputProps, type TextInputRadius, type TextInputSize, type TextInputStatus, type TextProps, type TextSize, useRehagroTheme };
package/dist/native.js CHANGED
@@ -1282,6 +1282,212 @@ var Select = react.forwardRef(function Select2(props, ref) {
1282
1282
  )
1283
1283
  ] });
1284
1284
  });
1285
+ var RadioGroupContext = react.createContext(null);
1286
+ var useRadioGroup = () => react.useContext(RadioGroupContext);
1287
+ var PRESET_COLORS4 = /* @__PURE__ */ new Set([
1288
+ "primary",
1289
+ "secondary",
1290
+ "danger",
1291
+ "warning",
1292
+ "success",
1293
+ "info"
1294
+ ]);
1295
+ var isPresetColor4 = (color) => PRESET_COLORS4.has(color);
1296
+ var resolveColor = (color, theme) => {
1297
+ if (isPresetColor4(color)) {
1298
+ return theme[color] ?? "#16a34a";
1299
+ }
1300
+ return color;
1301
+ };
1302
+ var outerSizeMap = {
1303
+ sm: 16,
1304
+ md: 20,
1305
+ lg: 24
1306
+ };
1307
+ var innerSizeMap = {
1308
+ sm: 8,
1309
+ md: 10,
1310
+ lg: 12
1311
+ };
1312
+ var labelSizeMap = {
1313
+ sm: 14,
1314
+ md: 14,
1315
+ lg: 16
1316
+ };
1317
+ var descriptionSizeMap = {
1318
+ sm: 12,
1319
+ md: 12,
1320
+ lg: 14
1321
+ };
1322
+ var gapMap = {
1323
+ sm: 8,
1324
+ md: 12,
1325
+ lg: 16
1326
+ };
1327
+ var Radio = react.forwardRef(function Radio2({
1328
+ size = "md",
1329
+ label,
1330
+ description,
1331
+ color = "primary",
1332
+ disabled,
1333
+ checked: controlledChecked,
1334
+ defaultChecked = false,
1335
+ onChange,
1336
+ style,
1337
+ accessibilityLabel,
1338
+ ...rest
1339
+ }, ref) {
1340
+ const theme = useRehagroTheme();
1341
+ const isControlled = controlledChecked !== void 0;
1342
+ const [internalChecked, setInternalChecked] = react.useState(defaultChecked);
1343
+ const isChecked = isControlled ? controlledChecked : internalChecked;
1344
+ const resolvedColor = resolveColor(color, theme);
1345
+ const handlePress = react.useCallback(() => {
1346
+ if (disabled) return;
1347
+ if (!isControlled) setInternalChecked(true);
1348
+ onChange?.(true);
1349
+ }, [disabled, isControlled, onChange]);
1350
+ const outerSize = outerSizeMap[size];
1351
+ const innerSize = innerSizeMap[size];
1352
+ const outerStyle = {
1353
+ width: outerSize,
1354
+ height: outerSize,
1355
+ borderRadius: outerSize / 2,
1356
+ borderWidth: theme.borderWidthSm ?? 1,
1357
+ borderColor: isChecked ? resolvedColor : theme.border ?? "#d1d5db",
1358
+ backgroundColor: theme.surface ?? "#ffffff",
1359
+ alignItems: "center",
1360
+ justifyContent: "center"
1361
+ };
1362
+ const innerStyle = {
1363
+ width: innerSize,
1364
+ height: innerSize,
1365
+ borderRadius: innerSize / 2,
1366
+ backgroundColor: resolvedColor
1367
+ };
1368
+ const accessibilityText = accessibilityLabel ?? (typeof label === "string" ? label : void 0);
1369
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1370
+ reactNative.Pressable,
1371
+ {
1372
+ ref,
1373
+ onPress: handlePress,
1374
+ disabled,
1375
+ accessibilityRole: "radio",
1376
+ accessibilityState: { checked: isChecked, disabled: !!disabled },
1377
+ accessibilityLabel: accessibilityText,
1378
+ style: [
1379
+ {
1380
+ flexDirection: "row",
1381
+ alignItems: "flex-start",
1382
+ gap: 8,
1383
+ opacity: disabled ? 0.5 : 1
1384
+ },
1385
+ style
1386
+ ],
1387
+ ...rest,
1388
+ children: [
1389
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: outerStyle, children: isChecked && /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: innerStyle }) }),
1390
+ (label || description) && /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { flex: 1, gap: 2 }, children: [
1391
+ label && /* @__PURE__ */ jsxRuntime.jsx(
1392
+ reactNative.Text,
1393
+ {
1394
+ style: {
1395
+ fontSize: labelSizeMap[size],
1396
+ color: theme.text,
1397
+ ...theme.fontFamilyBody ? { fontFamily: theme.fontFamilyBody } : {}
1398
+ },
1399
+ children: label
1400
+ }
1401
+ ),
1402
+ description && /* @__PURE__ */ jsxRuntime.jsx(
1403
+ reactNative.Text,
1404
+ {
1405
+ style: {
1406
+ fontSize: descriptionSizeMap[size],
1407
+ color: theme.textMuted,
1408
+ ...theme.fontFamilyBody ? { fontFamily: theme.fontFamilyBody } : {}
1409
+ },
1410
+ children: description
1411
+ }
1412
+ )
1413
+ ] })
1414
+ ]
1415
+ }
1416
+ );
1417
+ });
1418
+ var RadioOption = react.forwardRef(function RadioOption2({ value, size, color, disabled, ...rest }, ref) {
1419
+ const group = useRadioGroup();
1420
+ const mergedSize = size ?? group?.size ?? "md";
1421
+ const mergedColor = color ?? group?.color ?? "primary";
1422
+ const mergedDisabled = disabled ?? group?.disabled ?? false;
1423
+ const isChecked = group?.value === value;
1424
+ const handleChange = () => {
1425
+ group?.onChange?.(value);
1426
+ };
1427
+ return /* @__PURE__ */ jsxRuntime.jsx(
1428
+ Radio,
1429
+ {
1430
+ ref,
1431
+ size: mergedSize,
1432
+ color: mergedColor,
1433
+ disabled: mergedDisabled,
1434
+ checked: isChecked,
1435
+ onChange: handleChange,
1436
+ ...rest
1437
+ }
1438
+ );
1439
+ });
1440
+ var RadioGroup = react.forwardRef(function RadioGroup2({
1441
+ children,
1442
+ value,
1443
+ defaultValue,
1444
+ onChange,
1445
+ size = "md",
1446
+ orientation = "vertical",
1447
+ color = "primary",
1448
+ disabled = false,
1449
+ gap = "md",
1450
+ style
1451
+ }, ref) {
1452
+ const [internalValue, setInternalValue] = react.useState(defaultValue);
1453
+ const isControlled = value !== void 0;
1454
+ const currentValue = isControlled ? value : internalValue;
1455
+ const handleChange = react.useCallback(
1456
+ (newValue) => {
1457
+ if (!isControlled) setInternalValue(newValue);
1458
+ onChange?.(newValue);
1459
+ },
1460
+ [isControlled, onChange]
1461
+ );
1462
+ return /* @__PURE__ */ jsxRuntime.jsx(
1463
+ RadioGroupContext.Provider,
1464
+ {
1465
+ value: {
1466
+ value: currentValue,
1467
+ onChange: handleChange,
1468
+ size,
1469
+ color,
1470
+ disabled
1471
+ },
1472
+ children: /* @__PURE__ */ jsxRuntime.jsx(
1473
+ reactNative.View,
1474
+ {
1475
+ ref,
1476
+ accessibilityRole: "radiogroup",
1477
+ style: [
1478
+ {
1479
+ flexDirection: orientation === "vertical" ? "column" : "row",
1480
+ flexWrap: orientation === "horizontal" ? "wrap" : "nowrap",
1481
+ gap: gapMap[gap]
1482
+ },
1483
+ style
1484
+ ],
1485
+ children
1486
+ }
1487
+ )
1488
+ }
1489
+ );
1490
+ });
1285
1491
 
1286
1492
  exports.ActivityIndicator = ActivityIndicator3;
1287
1493
  exports.Avatar = Avatar;
@@ -1292,6 +1498,9 @@ exports.CardFooter = CardFooter;
1292
1498
  exports.CardHeader = CardHeader;
1293
1499
  exports.Checkbox = Checkbox;
1294
1500
  exports.IconButton = IconButton;
1501
+ exports.Radio = Radio;
1502
+ exports.RadioGroup = RadioGroup;
1503
+ exports.RadioOption = RadioOption;
1295
1504
  exports.RehagroNativeProvider = RehagroNativeProvider;
1296
1505
  exports.Select = Select;
1297
1506
  exports.Tag = Tag;