hongluan-ui
Version:
Hongluan Component Library for Vue 3
59 lines (54 loc) • 1.79 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
const _sfc_main = vue.defineComponent({
name: "SimpleTableSortableIcon",
props: {
sortable: [Boolean, String]
},
emits: ["sort-change"],
setup(props, { emit }) {
const active = vue.ref(getActive());
const shouldShow = vue.computed(() => {
return typeof props.sortable === "boolean" ? props.sortable : !!props.sortable;
});
const sort = (which) => {
if (active.value !== which) {
active.value = which;
} else {
active.value = "";
}
emit("sort-change", active.value);
};
function getActive() {
return typeof props.sortable !== "boolean" && props.sortable ? props.sortable : "";
}
vue.watch(() => props.sortable, () => {
active.value = getActive();
});
return {
active,
shouldShow,
sort
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return _ctx.shouldShow ? (vue.openBlock(), vue.createElementBlock("span", {
key: 0,
class: vue.normalizeClass(["caret-wrapper", _ctx.active])
}, [
vue.createElementVNode("i", {
class: "sort-caret ascending",
onClick: ($event) => _ctx.sort("ascending")
}, null, 8, ["onClick"]),
vue.createElementVNode("i", {
class: "sort-caret descending",
onClick: ($event) => _ctx.sort("descending")
}, null, 8, ["onClick"])
], 2)) : vue.createCommentVNode("v-if", true);
}
var SortableIcon = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]);
exports["default"] = SortableIcon;
//# sourceMappingURL=sortable.js.map