@varlet/ui
Version:
A Vue3 component library based on Material Design 2 and 3, supporting mobile and desktop.
87 lines (86 loc) • 2.8 kB
JavaScript
import { computed, defineComponent, onUpdated, ref } from "vue";
import { isBoolean, toNumber } from "@varlet/shared";
import { onSmartMounted } from "@varlet/use";
import { createNamespace } from "../utils/components.mjs";
import { toSizeUnit } from "../utils/elements.mjs";
import { props } from "./props.mjs";
const { name, n, classes } = createNamespace("divider");
import { renderSlot as _renderSlot, toDisplayString as _toDisplayString, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle } from "vue";
function __render__(_ctx, _cache) {
return _openBlock(), _createElementBlock(
"div",
{
class: _normalizeClass(
_ctx.classes(
_ctx.n(),
_ctx.n("$--box"),
[_ctx.vertical, _ctx.n("--vertical")],
[_ctx.withText, _ctx.n("--with-text")],
[_ctx.withPresetInset, _ctx.n("--inset")],
[_ctx.dashed, _ctx.n("--dashed")],
[_ctx.hairline, _ctx.n("--hairline")]
)
),
style: _normalizeStyle(_ctx.style),
role: "separator"
},
[
!_ctx.vertical ? _renderSlot(_ctx.$slots, "default", { key: 0 }, () => [
_ctx.description ? (_openBlock(), _createElementBlock(
"span",
{
key: 0,
class: _normalizeClass(_ctx.n("text"))
},
_toDisplayString(_ctx.description),
3
/* TEXT, CLASS */
)) : _createCommentVNode("v-if", true)
]) : _createCommentVNode("v-if", true)
],
6
/* CLASS, STYLE */
);
}
const __sfc__ = defineComponent({
name,
props,
setup(props2, { slots }) {
const withText = ref(false);
const withPresetInset = computed(() => {
const { vertical, inset } = props2;
return !vertical && inset === true;
});
const style = computed(() => {
const { inset, vertical, margin } = props2;
if (isBoolean(inset) || vertical) {
return { margin };
}
const _inset = toNumber(inset);
const absInsetWithUnit = Math.abs(_inset) + (inset + "").replace(_inset + "", "");
return {
margin,
width: `calc(100% - ${toSizeUnit(absInsetWithUnit)})`,
left: _inset > 0 ? toSizeUnit(absInsetWithUnit) : toSizeUnit(0)
};
});
onSmartMounted(checkHasText);
onUpdated(checkHasText);
function checkHasText() {
const { description, vertical } = props2;
withText.value = (slots.default || description != null) && !vertical;
}
return {
n,
classes,
withText,
style,
withPresetInset
};
}
});
__sfc__.render = __render__;
var stdin_default = __sfc__;
export {
stdin_default as default
};