UNPKG

daily-toolset

Version:

A lightweight, versatile collection of TypeScript utility functions for everyday development needs. Simplify and streamline your Node.js, React, and Next.js projects with a powerful suite of well-organized helpers for strings, arrays, dates, objects, and

18 lines (17 loc) 932 B
"use strict"; "use client"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Switch = Switch; const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const switch_1 = require("../../components/ui/switch"); const FormLabel_1 = require("./FormLabel"); function Switch({ isChecked = false, value, name, label, handleCheck, }) { const [checked, setChecked] = (0, react_1.useState)(isChecked); const id = (0, react_1.useId)(); function handleCheckChange(checked) { setChecked(checked); handleCheck && handleCheck(checked); } return ((0, jsx_runtime_1.jsxs)("div", { className: "explita-switch-toggle-root", children: [(0, jsx_runtime_1.jsx)(switch_1.Switch, { id: id, value: checked ? value : "", defaultChecked: checked, name: name, onCheckedChange: handleCheckChange }), (0, jsx_runtime_1.jsx)(FormLabel_1.Label, { id: id, label: label })] })); }