UNPKG

@codeworker.br/govbr-tw-react

Version:

Biblioteca de componentes React usando Tailwind CSS que implementa o Padrão Digital de Governo.

23 lines (22 loc) 1.53 kB
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; }; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import switchVariants from "./variants"; import labelSwitchVariants from "./label-variants"; import BASE_CLASSNAMES from "../../config/baseClassNames"; import { cn, getUIDClassName } from "../../libs/utils"; const Switch = forwardRef((_a, ref) => { var { className, children, variant = "default", density = "default", labelPosition = "left", id = `${BASE_CLASSNAMES.switch.label}-${getUIDClassName()}` } = _a, props = __rest(_a, ["className", "children", "variant", "density", "labelPosition", "id"]); return (_jsxs("label", { className: cn(labelSwitchVariants({ labelPosition }), BASE_CLASSNAMES.switch.label), htmlFor: id, children: [_jsx("input", Object.assign({ type: "checkbox", className: cn("sr-only peer", BASE_CLASSNAMES.switch.root), role: "switch", "aria-checked": props.checked, ref: ref, id: id }, props)), _jsx("div", { className: cn(switchVariants({ variant, density })) }), children] })); }); export default Switch;