@aplus-frontend/ui
Version:
68 lines (67 loc) • 2.37 kB
JavaScript
import { defineComponent as B, computed as d, createElementBlock as f, openBlock as l, normalizeClass as r, unref as e, createBlock as _, createCommentVNode as D, resolveDynamicComponent as O, createVNode as g } from "vue";
import { useToken as V } from "@aplus-frontend/antdv/es/theme/internal";
import { CaretUpOutlined as j, CaretDownOutlined as z } from "@ant-design/icons-vue";
import { getTableTitle as A } from "../../../ap-table/utils.mjs";
import "../../../config-provider/index.mjs";
import { useInjectSorter as E } from "../../context.mjs";
import U from "../../style/custom-header.mjs";
import { useNamespace as C } from "../../../config-provider/hooks/use-namespace.mjs";
const P = /* @__PURE__ */ B({
__name: "index",
props: {
params: {}
},
setup(S) {
const o = S, { b: v, e: a } = C("ag-custom-header"), { be: b, bem: h } = C("ag-grid"), k = U("ag-custom-header"), [, I] = V(), { sorter: c, setSorter: T } = E(), n = d(() => o.params.column.sorter);
function y(t) {
return t ? t === "asc" ? "desc" : null : "asc";
}
const m = d(() => o.params?.column?.getColId?.());
function x() {
if (!n.value)
return;
const s = o.params.column.getColId(), N = o.params.column.getSort(), u = y(N), p = o.params.api, w = p.getColumnState().map((i) => ({
...i,
sort: i.colId === s ? u : null
}));
p.applyColumnState({
state: w
}), T({ [s]: u });
}
return (t, s) => (l(), f("div", {
class: r([
e(v)(),
{ sortable: n.value },
`align-${t.params.column.align || "left"}`,
e(k)
]),
onClick: x
}, [
(l(), _(O(
e(A)(
t.params.column,
[
e(b)("table-header", "title"),
t.params.column.tooltip ? "" : e(h)("table-header", "title", "single")
],
void 0,
e(I).colorTextTertiary
)
))),
n.value ? (l(), f("span", {
key: 0,
class: r(e(a)("sort-wrapper"))
}, [
g(e(j), {
class: r({ [e(a)("sorter-up")]: !0, active: e(c)[m.value] === "asc" })
}, null, 8, ["class"]),
g(e(z), {
class: r({ [e(a)("sorter-down")]: !0, active: e(c)[m.value] === "desc" })
}, null, 8, ["class"])
], 2)) : D("", !0)
], 2));
}
});
export {
P as default
};