@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.
54 lines • 2.4 kB
JavaScript
/**
* CheckBoxGroup
*
* Provides a container for managing a group of `CheckBox` components.
* - Maintains the array of selected values in state (controlled or uncontrolled).
* - Passes down context (`CheckBoxGroupContext`) so individual checkboxes can update and reflect selection.
* - Allows multiple checkboxes to be selected simultaneously 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.CheckBoxGroup = void 0;
const react_1 = __importDefault(require("react"));
const react_native_1 = require("react-native");
const CheckBoxContext_1 = require("./CheckBoxContext");
/**
* CheckBoxGroup
*
* A container that manages a set of `CheckBox` components.
* - Provides the selected values and change handler through context.
* - Can operate in controlled (`selectedValues` + `onValueChange`) or uncontrolled (`defaultValues`) mode.
* - Supports multi-select: any number of `CheckBox` components can be selected at once.
*
* Example:
* ```tsx
* <CheckBoxGroup selectedValues={selected} onValueChange={setSelected}>
* <CheckBox value="opt1" label="Option 1" />
* <CheckBox value="opt2" label="Option 2" />
* <CheckBox value="opt3" label="Option 3" />
* </CheckBoxGroup>
* ```
*/
const CheckBoxGroup = (_a) => {
var { selectedValues, onValueChange, children } = _a, rest = __rest(_a, ["selectedValues", "onValueChange", "children"]);
return (react_1.default.createElement(CheckBoxContext_1.CheckBoxGroupContext.Provider, { value: { selectedValues, onValueChange } },
react_1.default.createElement(react_native_1.View, Object.assign({}, rest), children)));
};
exports.CheckBoxGroup = CheckBoxGroup;
//# sourceMappingURL=CheckBoxGroup.js.map
;