UNPKG

@geekyhawks/react-native-ui-components

Version:

A lightweight and reusable React Native UI components library with customizable Text, TextInput, FloatingLabelTextInput, Button, and more. Built with TypeScript, fully typed, and designed for easy integration into any React Native project.

53 lines 2.25 kB
"use strict"; /** * RadioGroup * * Provides a container for managing a group of `Radio` components. * - Maintains the currently selected value in state (controlled or uncontrolled). * - Passes down context (`RadioGroupContext`) so individual radios can update and reflect selection. * - Ensures only one radio can be selected at a time within the group. * * Author: Geeky Hawks FZE LLC */ var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.RadioGroup = void 0; const react_1 = __importDefault(require("react")); const react_native_1 = require("react-native"); const RadioContext_1 = require("./RadioContext"); /** * RadioGroup * * A container that manages a set of `Radio` components. * - Provides the selected value and change handler through context. * - Can operate in controlled (`value` + `onValueChange`) or uncontrolled (`defaultValue`) mode. * - Ensures mutual exclusivity: only one `Radio` can be selected at a time. * * Example: * ```tsx * <RadioGroup value={selected} onValueChange={setSelected}> * <Radio value="option1" label="Option 1" /> * <Radio value="option2" label="Option 2" /> * </RadioGroup> * ``` */ const RadioGroup = (_a) => { var { selectedValue, onValueChange, children } = _a, rest = __rest(_a, ["selectedValue", "onValueChange", "children"]); return (react_1.default.createElement(RadioContext_1.RadioGroupContext.Provider, { value: { selectedValue, onValueChange } }, react_1.default.createElement(react_native_1.View, Object.assign({}, rest), children))); }; exports.RadioGroup = RadioGroup; //# sourceMappingURL=RadioGroup.js.map