hongluan-ui
Version:
Hongluan Component Library for Vue 3
75 lines (70 loc) • 2.11 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
require('../../../hooks/index.js');
var index = require('../../group/index.js');
var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js');
var index$1 = require('../../../hooks/use-namespace/index.js');
const _sfc_main = vue.defineComponent({
name: "List",
components: { HlGroup: index.HlGroup },
props: {
hover: Boolean,
indent: Boolean,
merge: Boolean,
gap: String,
itemGap: String,
border: {
type: String,
default: "",
validator: (val) => ["", "bordered", "border-x"].includes(val)
}
},
setup() {
const { namespace } = index$1.useNamespace("list");
const hlGroupRef = vue.ref(null);
const selectItem = (evt) => {
Array.prototype.slice.call(hlGroupRef.value.$el.querySelectorAll(`.${namespace.value}-item`)).forEach((item) => {
if (item.classList.contains("is-active")) {
item.classList.remove("is-active");
}
});
evt.currentTarget.classList.add("is-active");
};
vue.provide("ListComponnetContext", {
selectItem
});
return {
namespace,
hlGroupRef
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_hl_group = vue.resolveComponent("hl-group");
return vue.openBlock(), vue.createBlock(_component_hl_group, {
ref: "hlGroupRef",
dir: "vertical",
class: vue.normalizeClass([
_ctx.namespace,
_ctx.border,
{
hover: _ctx.hover,
indent: _ctx.indent,
merge: _ctx.merge
}
]),
style: vue.normalizeStyle([
_ctx.gap ? `--list-gap: ${_ctx.gap}` : "",
_ctx.itemGap ? `--list-item-gap: ${_ctx.itemGap}` : ""
])
}, {
default: vue.withCtx(() => [
vue.renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["class", "style"]);
}
var List = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["render", _sfc_render]]);
exports["default"] = List;
//# sourceMappingURL=index.js.map