hongluan-ui
Version:
Hongluan Component Library for Vue 3
71 lines (68 loc) • 2.07 kB
JavaScript
import { defineComponent, ref, provide, resolveComponent, openBlock, createBlock, normalizeClass, normalizeStyle, withCtx, renderSlot } from 'vue';
import '../../../hooks/index.mjs';
import { HlGroup } from '../../group/index.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
const _sfc_main = defineComponent({
name: "List",
components: { 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 } = useNamespace("list");
const hlGroupRef = 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");
};
provide("ListComponnetContext", {
selectItem
});
return {
namespace,
hlGroupRef
};
}
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
const _component_hl_group = resolveComponent("hl-group");
return openBlock(), createBlock(_component_hl_group, {
ref: "hlGroupRef",
dir: "vertical",
class: normalizeClass([
_ctx.namespace,
_ctx.border,
{
hover: _ctx.hover,
indent: _ctx.indent,
merge: _ctx.merge
}
]),
style: normalizeStyle([
_ctx.gap ? `--list-gap: ${_ctx.gap}` : "",
_ctx.itemGap ? `--list-item-gap: ${_ctx.itemGap}` : ""
])
}, {
default: withCtx(() => [
renderSlot(_ctx.$slots, "default")
]),
_: 3
}, 8, ["class", "style"]);
}
var List = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export { List as default };
//# sourceMappingURL=index.mjs.map