@blocklet/ui-react
Version:
Some useful front-end web components that can be used in Blocklets.
58 lines (57 loc) • 1.41 kB
JavaScript
import { jsxs as d, jsx as u } from "react/jsx-runtime";
import { useRef as p } from "react";
import { FormControl as f, TextField as h, FormHelperText as C } from "@mui/material";
import e from "dayjs";
import { useCreation as Y } from "ahooks";
function T({
value: t,
onChange: a,
error: n = void 0,
helperText: i = void 0,
label: m = void 0,
timezone: r = void 0
}) {
const l = p(null), s = e().format("YYYY-MM-DDTHH:mm"), c = Y(() => {
let o = e();
return t && (o = r ? e(t).tz(r) : e(t)), o.format("YYYY-MM-DD HH:mm");
}, [t, r]);
return /* @__PURE__ */ d(f, { fullWidth: !0, error: n, children: [
/* @__PURE__ */ u(
h,
{
inputRef: l,
type: "datetime-local",
value: c,
onChange: (o) => {
a(new Date(o.target.value));
},
label: m,
error: n,
onClick: () => {
l.current?.showPicker();
},
sx: {
"& .MuiInputBase-root": {
cursor: "pointer"
},
"& .MuiOutlinedInput-notchedOutline": {
cursor: "pointer"
}
},
slotProps: {
htmlInput: {
min: s,
style: { cursor: "pointer" }
},
inputLabel: {
shrink: !0
}
}
}
),
i && /* @__PURE__ */ u(C, { children: i })
] });
}
export {
T as default
};