hongluan-ui
Version:
Hongluan Component Library for Vue 3
165 lines (160 loc) • 7.18 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../utils/index.js');
require('../../../hooks/index.js');
var index$1 = require('../../checkbox/index.js');
var index$4 = require('../../checkbox-group/index.js');
var index$2 = require('../../input/index.js');
var index$3 = require('../../icon/index.js');
require('../../system-icon/index.js');
var transferPanel = require('./transfer-panel2.js');
require('./composables/index.js');
var index = require('../../../hooks/use-locale/index.js');
var usePropsAlias = require('./composables/use-props-alias.js');
var useCheck = require('./composables/use-check.js');
var types = require('../../../utils/types.js');
var search = require('../../system-icon/src/search.js');
const __default__ = vue.defineComponent({
name: "TransferPanel"
});
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...__default__,
props: transferPanel.transferPanelProps,
emits: transferPanel.transferPanelEmits,
setup(__props, { expose, emit }) {
const props = __props;
const slots = vue.useSlots();
const OptionContent = ({ option }) => option;
const { t } = index.useLocale();
const panelState = vue.reactive({
checked: [],
allChecked: false,
query: "",
inputHover: false,
checkChangeByUser: true
});
const propsAlias = usePropsAlias.usePropsAlias(props);
const {
filteredData,
checkedSummary,
isIndeterminate,
handleAllCheckedChange
} = useCheck.useCheck(props, panelState, emit);
const hasNoMatch = vue.computed(() => !types.isEmpty(panelState.query) && types.isEmpty(filteredData.value));
const hasFooter = vue.computed(() => !types.isEmpty(slots.default()[0].children));
const showClose = vue.computed(() => {
return panelState.query.length > 0 && panelState.inputHover ? "show-close" : "";
});
const { checked, allChecked, query, inputHover } = vue.toRefs(panelState);
expose({
query
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass(["transfer-panel", _ctx.mark])
}, [
!_ctx.showButtons ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: "panel-header"
}, [
vue.createElementVNode("span", null, vue.toDisplayString(_ctx.title), 1),
vue.createElementVNode("span", { class: "count" }, vue.toDisplayString(vue.unref(checkedSummary)), 1)
])) : (vue.openBlock(), vue.createElementBlock("div", {
key: 1,
class: "panel-header"
}, [
vue.createVNode(vue.unref(index$1.HlCheckbox), {
modelValue: vue.unref(allChecked),
"onUpdate:modelValue": ($event) => vue.isRef(allChecked) ? allChecked.value = $event : null,
"validate-event": false,
indeterminate: vue.unref(isIndeterminate),
onChange: vue.unref(handleAllCheckedChange)
}, {
default: vue.withCtx(() => [
vue.createTextVNode(vue.toDisplayString(_ctx.title), 1)
]),
_: 1
}, 8, ["modelValue", "onUpdate:modelValue", "indeterminate", "onChange"]),
vue.createElementVNode("span", { class: "count" }, vue.toDisplayString(vue.unref(checkedSummary)), 1)
])),
vue.createElementVNode("div", {
class: vue.normalizeClass(["panel-body", vue.unref(hasFooter) ? "is-with-footer" : ""])
}, [
_ctx.filterable ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: "panel-filter"
}, [
vue.createVNode(vue.unref(index$2.HlInput), vue.mergeProps({
modelValue: vue.unref(query),
"onUpdate:modelValue": ($event) => vue.isRef(query) ? query.value = $event : null,
class: "no-verify",
block: "",
clearable: "",
placeholder: _ctx.placeholder,
"validate-event": false
}, _ctx.filterProps, {
onMouseenter: ($event) => inputHover.value = true,
onMouseleave: ($event) => inputHover.value = false
}), {
prefix: vue.withCtx(() => [
vue.createVNode(vue.unref(index$3.HlIcon), null, {
default: vue.withCtx(() => [
vue.createVNode(vue.unref(search["default"]))
]),
_: 1
})
]),
_: 1
}, 16, ["modelValue", "onUpdate:modelValue", "placeholder", "onMouseenter", "onMouseleave"])
])) : vue.createCommentVNode("v-if", true),
vue.withDirectives(vue.createVNode(vue.unref(index$4.HlCheckboxGroup), {
modelValue: vue.unref(checked),
"onUpdate:modelValue": ($event) => vue.isRef(checked) ? checked.value = $event : null,
dir: "vertical",
"validate-event": false,
class: vue.normalizeClass({ "panel-list": true, "has-filterable": _ctx.filterable }),
custom: !_ctx.showButtons
}, {
default: vue.withCtx(() => [
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(filteredData), (item) => {
return vue.openBlock(), vue.createBlock(vue.unref(index$1.HlCheckbox), {
key: item[vue.unref(propsAlias).key],
class: "item",
label: item[vue.unref(propsAlias).key],
disabled: item[vue.unref(propsAlias).disabled],
"validate-event": false
}, {
default: vue.withCtx(() => {
var _a;
return [
vue.createVNode(OptionContent, {
option: (_a = _ctx.optionRender) == null ? void 0 : _a.call(_ctx, item)
}, null, 8, ["option"]),
vue.createCommentVNode(` <i v-if="mark === 'right' && !item[disabledProp]" class="system-icon error-fill"></i> `)
];
}),
_: 2
}, 1032, ["label", "disabled"]);
}), 128))
]),
_: 1
}, 8, ["modelValue", "onUpdate:modelValue", "class", "custom"]), [
[vue.vShow, !vue.unref(hasNoMatch) && !vue.unref(types.isEmpty)(_ctx.data)]
]),
vue.withDirectives(vue.createElementVNode("p", { class: "panel-empty" }, vue.toDisplayString(vue.unref(hasNoMatch) ? vue.unref(t)("hl.transfer.noMatch") : vue.unref(t)("hl.transfer.noData")), 513), [
[vue.vShow, vue.unref(hasNoMatch) || vue.unref(types.isEmpty)(_ctx.data)]
])
], 2),
vue.unref(hasFooter) ? (vue.openBlock(), vue.createElementBlock("p", {
key: 2,
class: "panel-footer"
}, [
vue.renderSlot(_ctx.$slots, "default")
])) : vue.createCommentVNode("v-if", true)
], 2);
};
}
});
exports["default"] = _sfc_main;
//# sourceMappingURL=transfer-panel.js.map