winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
44 lines (43 loc) • 1.22 kB
JavaScript
import { defineComponent, toRefs, computed } from "vue";
import RenderFunction from "../_components/render-function.js";
import { getPrefixCls } from "../_utils/global-config.js";
import Tooltip from "../tooltip/index.js";
var _sfc_main = defineComponent({
name: "ImagePreviewToolbar",
components: {
RenderFunction,
Tooltip
},
props: {
actions: {
type: Array,
default: () => []
},
actionsLayout: {
type: Array,
default: () => []
}
},
setup(props) {
const {
actions,
actionsLayout
} = toRefs(props);
const prefixCls = getPrefixCls("image-preview-toolbar");
const resultActions = computed(() => {
const actionsLayoutSet = new Set(actionsLayout.value);
const filterWithLayout = (item) => actionsLayoutSet.has(item.key);
const filteredActions = actions.value.filter(filterWithLayout);
return filteredActions.sort((pre, cur) => {
const preIndex = actionsLayout.value.indexOf(pre.key);
const curIndex = actionsLayout.value.indexOf(cur.key);
return preIndex > curIndex ? 1 : -1;
});
});
return {
prefixCls,
resultActions
};
}
});
export { _sfc_main as default };