UNPKG

ayongui

Version:
167 lines (166 loc) 5.02 kB
import { j as r } from "../../../react/jsx-runtime.mjs"; import { useRef as b, useState as i, useEffect as y } from "react"; import R from "../date-picker/index.mjs"; import S from "../input/index.mjs"; import e from "./index.module.less.mjs"; import "../icon/index.module.less.mjs"; import z from "../icon/components/swapright-frame/index.mjs"; import "../icon/components/loading-frame/loading.module.less.mjs"; import H from "../icon/components/cendas-frame/index.mjs"; import O from "../icon/components/wrong-solid/index.mjs"; import q from "../button/index.mjs"; import G from "../../config/style.module.less.mjs"; const ne = ($) => { const { picker: d = "day", yearsRange: x = [1970, 2099], className: T, disabled: c = !1, onChange: V = () => { }, onClear: A = () => { }, showTime: v = !1 } = $, p = b(null), u = b(null), [o, m] = i(""), [n, f] = i(""), [E, g] = i(!1), [J, F] = i({}), [w, k] = i(!0), [C, j] = i(!0), [h, a] = i(""); y(() => { const s = (t) => { t.stopPropagation(), w && C && (g(!1), a("")), k(!0), j(!0); }; return document.addEventListener("click", s), () => { document.removeEventListener("click", s); }; }, [w, C]); const D = () => { var s, t; g(!1), (s = p.current) == null || s.closeDropdown(), (t = u.current) == null || t.closeDropdown(), a(""); }, N = (s) => { var t, l; (t = p.current) == null || t.openDropdown(), (l = u.current) == null || l.openDropdown(), g(!0), k(!1), j(!1); }, I = (s, t) => { m(d === "week" ? t : s.comprehensiveStr); }, W = (s, t) => { f(d === "week" ? t : s.comprehensiveStr); }; y(() => { o && n && (V([o, n]), D()); }, [o, n]); const M = (s) => { var t, l; s.stopPropagation(), m(""), f(""), (t = u.current) == null || t.onWrong(), (l = p.current) == null || l.onWrong(), A(), a(""), F(() => ({ selectedHour: "", selectedMinute: "", selectedSecond: "" })); }, P = () => { if (n && o) { D(); return; } o || a("left"), n || a("right"); }, L = () => { c || (N(), a("right")); }, B = () => { c || (N(), a("left")); }; return /* @__PURE__ */ r.jsxs("div", { className: e.warp, children: [ /* @__PURE__ */ r.jsxs( "main", { className: `${e.main} ${o && n ? e.hoverMain : ""} ${h && e.hoverActive} ${h && h === "left" ? e.hoverActiveRight : e.hoverActiveLeft} ${c ? G.disabled : ""} ${T} `, children: [ /* @__PURE__ */ r.jsx( S, { style: { border: "none" }, className: e.startInput, disabled: c, value: o, onChange: () => { }, placeholder: "请选择开始日期", onFocus: B } ), /* @__PURE__ */ r.jsx(z, { className: e.swapright }), /* @__PURE__ */ r.jsx( S, { style: { border: "none" }, className: e.startInput, disabled: c, value: n, onChange: () => { }, placeholder: "请选择结束日期", onFocus: L } ), /* @__PURE__ */ r.jsxs("div", { style: { width: "26px", height: "26px", display: "flex", textAlign: "center", alignItems: "center" }, children: [ /* @__PURE__ */ r.jsx( O, { onClick: M, className: e.pickerWrong } ), /* @__PURE__ */ r.jsx(H, { className: e.pickerCollapse }) ] }) ] } ), /* @__PURE__ */ r.jsxs( "div", { className: `${e.dropdown} ${E ? e.baseCalendarShow : e.baseCalendarNone}`, children: [ /* @__PURE__ */ r.jsxs("div", { className: e.transverseBox, children: [ /* @__PURE__ */ r.jsx( R, { ref: p, showTime: v, onChange: I, picker: d, yearsRange: x, footerRender: () => { }, rangMode: "rangbefore", isRange: !0 } ), /* @__PURE__ */ r.jsx( R, { ref: u, showTime: v, picker: d, yearsRange: x, footerRender: () => { }, onChange: W, rangMode: "rangeafter", isRange: !0 } ) ] }), /* @__PURE__ */ r.jsx("div", { style: { width: "100%", textAlign: "right", padding: "0 6px 6px 0" }, children: /* @__PURE__ */ r.jsx(q, { onClick: P, size: "small", children: " 确定" }) }) ] } ) ] }); }; export { ne as default };