denwa-react-shared
Version:
140 lines (139 loc) • 3.87 kB
JavaScript
import { G as e, J as t, K as n, X as r, n as i, t as a } from "./styles.module-djPz2AzU.js";
import o from "dayjs";
import { jsx as s, jsxs as c } from "react/jsx-runtime";
import { useDebounce as l } from "react-use";
import { createElement as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
import { Button as h, Flex as g, Input as _, Segmented as v, Select as y, Tooltip as b, theme as x } from "antd";
import { PlusOutlined as S, RedoOutlined as C } from "@ant-design/icons";
//#region src/shared/ui/admin-table/table-search.tsx
var w = ({ datePickerComponent: r, searchText: h, noDateText: b, emptyText: S, searchSelect: C, radioOptions: w, searchOptions: T, searchType: E, textSearchValue: D = "", dateSearchValue: O, numberSearchValue: k, multiselectSearchValue: A, multiselectOptions: j, onChangeSearch: M, onChangeTextSearch: N, onChangeRadioSearch: P, onChangeDateSearch: F, onChangeNumberSearch: I, onChangeMultiselectSearch: L }) => {
let [R, z] = m(D), B = p(!0);
d(() => {
z(D);
}, [D]);
let { token: { borderRadius: V, colorBgBase: H, paddingXXS: U } } = x.useToken(), { isMobileMaxWidth: W } = e(), { isSmallMaxWidth: G } = n(), K = f(() => G ? 2 : W ? 5 : 15, [W, G]);
l(() => {
if (B.current) {
B.current = !1;
return;
}
N?.(R);
}, t.milliseconds.milliseconds500, [R]);
let q = () => {
z("");
}, J = (e) => {
M(e), q();
}, Y = (e) => {
z(e.target.value.replace(/"/g, ""));
}, X = (e) => {
F?.(e);
};
return /* @__PURE__ */ c(g, {
className: a.flex,
gap: "small",
style: {
padding: U,
borderRadius: V,
background: H
},
children: [/* @__PURE__ */ s(y, {
defaultValue: C,
value: C,
style: {
width: 120,
minWidth: 120
},
options: T,
onChange: J
}), {
text: /* @__PURE__ */ s(_, {
placeholder: h,
value: R,
allowClear: !0,
onChange: Y
}),
radio: /* @__PURE__ */ s(v, {
options: w,
defaultValue: "all",
onChange: P
}),
date: u(r, {
noDateText: b,
currentValue: O ? o(O).format("YYYY-MM-DD") : "",
onChange: (e) => {
X(e ? e.toDate() : null);
},
onChangeDate: X
}),
number: /* @__PURE__ */ s(i, {
emptyText: S,
value: k,
placeholder: h,
min: 0,
max: 2147483647,
onChange: (e) => {
if (e == null || e === "") {
I?.(0);
return;
}
I?.(+e);
}
}),
multiselect: /* @__PURE__ */ s(y, {
className: a.select,
mode: "multiple",
placeholder: h,
maxTagCount: 1,
maxTagTextLength: K,
showSearch: !1,
allowClear: !0,
options: j,
value: A,
onChange: L
})
}[E]]
});
}, T = ({ sortTooltipText: e, updateDataText: t, refreshText: n, createText: i, createNewElementText: o, order: l, orderOptions: u, createButtonTooltip: d, searchProps: f, isCanCreate: p, isHiddenCreate: m, onCreate: _, onRefetch: v, onChangeOrder: x }) => /* @__PURE__ */ c(g, {
gap: "middle",
justify: "space-between",
wrap: "wrap",
style: { marginBottom: r.OFFSET[1] },
children: [/* @__PURE__ */ c(g, {
align: "center",
gap: "middle",
wrap: "wrap",
children: [/* @__PURE__ */ s(w, { ...f }), /* @__PURE__ */ s(b, {
title: e,
children: /* @__PURE__ */ s(y, {
className: a.sort,
value: l,
options: u,
onChange: x
})
})]
}), /* @__PURE__ */ c(g, {
className: a.buttonsContainer,
gap: "small",
align: "center",
children: [v && /* @__PURE__ */ s(b, {
title: t,
children: /* @__PURE__ */ s(h, {
className: a.button,
icon: /* @__PURE__ */ s(C, {}),
onClick: v,
children: n
})
}), !m && p && /* @__PURE__ */ s(b, {
title: d ?? o,
children: /* @__PURE__ */ s(h, {
className: a.button,
type: "primary",
icon: /* @__PURE__ */ s(S, {}),
onClick: _,
children: i
})
})]
})]
});
//#endregion
export { T as TableHead };