@harvest-profit/npk
Version:
NPK UI Design System
18 lines • 1.36 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = __importDefault(require("react"));
const Switch_module_css_1 = __importDefault(require("./Switch.module.css"));
const CheckboxWrapper = ({ labelChildren, children }) => {
if (!labelChildren)
return children;
return (0, jsx_runtime_1.jsxs)("label", { children: [children, (0, jsx_runtime_1.jsx)("span", { children: labelChildren })] });
};
const Switch = ({ className, id, onClick, value, children, variant = "default", size = "md", position = "leading", ...props }) => {
return ((0, jsx_runtime_1.jsxs)("div", { ...props, "data-variant": variant, "data-size": size, "data-position": position, className: `${Switch_module_css_1.default.Switch} ${className}`, onClick: onClick, children: [(0, jsx_runtime_1.jsx)(CheckboxWrapper, { labelChildren: children, children: (0, jsx_runtime_1.jsx)("input", { id: id, type: "checkbox", checked: value, readOnly: true, "aria-readonly": "true" }) }), (0, jsx_runtime_1.jsx)("span", { "data-active": value, className: Switch_module_css_1.default.Slider })] }));
};
exports.default = Switch;
//# sourceMappingURL=Switch.js.map