ayongui
Version:
45 lines (44 loc) • 1.17 kB
JavaScript
import { j as e } from "../../../react/jsx-runtime.mjs";
import s from "./index.module.less.mjs";
import { useState as x } from "react";
import "../../config/style.module.less.mjs";
function k(o) {
const {
value: l = !1,
style: n,
title: c,
className: i,
disabled: t,
activeColor: r = "#8aabec",
inactiveColor: d = "#9b9ea4",
onChange: m = (b) => {
}
} = o, [a, u] = x(l), h = () => {
u(!a), m(l);
}, p = `${s.ayongSwitch} ${a ? s.checked : ""} ${t ? "disabled" : ""} $`;
return /* @__PURE__ */ e.jsxs("div", { style: { display: "flex" }, className: i, children: [
/* @__PURE__ */ e.jsxs(
"button",
{
disabled: t,
type: "button",
style: {
border: "none",
background: a ? r : d,
cursor: t && "not-allowed",
...n
},
className: p,
onClick: h,
children: [
/* @__PURE__ */ e.jsx("div", { className: s.handle }),
/* @__PURE__ */ e.jsx("span", { className: s.inner })
]
}
),
/* @__PURE__ */ e.jsx("span", { className: s.title, children: c })
] });
}
export {
k as default
};