hongluan-ui
Version:
Hongluan Component Library for Vue 3
66 lines (61 loc) • 2.12 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
var shared = require('@vue/shared');
const panelProps = {
borderless: Boolean,
outlineless: Boolean,
collapsed: Boolean,
fullscreen: {
type: [Boolean, Object],
default: false
},
radius: String,
headerHeight: String,
padding: String,
bodyPadding: String,
footerPadding: String,
headerClass: String,
headerStyle: String,
bodyClass: String,
bodyStyle: String,
footerClass: String,
footerStyle: String,
fullBody: Boolean
};
const panelStyleProps = ["radius", "padding", "headerHeight", "bodyPadding", "footerPadding"];
const panelClassProps = ["borderless", "outlineless", "collapsed", "fullscreen", "fullBody"];
function usePanelProps(props) {
const panelClass = {};
panelClassProps.forEach((p) => {
panelClass[shared.hyphenate(p)] = typeof props[p] === "boolean" ? props[p] : !!props[p];
});
const panelStyle = [];
panelStyleProps.forEach((p) => {
const propVal = getPropVal(p);
panelStyle.push(propVal.val ? `--panel-${propVal.otherName}: ${propVal.val}` : "");
});
if (props.fullscreen && typeof props.fullscreen === "object") {
["top", "bottom", "left", "right"].forEach((p) => {
panelStyle.push(props.fullscreen[p] ? `--panel-fullscreen-${p}: ${props.fullscreen[p]}` : "");
});
}
function getPropVal(propName) {
const propNameOther = propName.replace(/([A-Z])/g, (_, $1) => "-" + $1.toLowerCase());
return { val: props[propName] || props[propNameOther], otherName: propNameOther };
}
return {
panelClass,
headerClass: getPropVal("headerClass").val || "",
headerStyle: getPropVal("headerStyle").val || "",
bodyClass: getPropVal("bodyClass").val || "",
bodyStyle: getPropVal("bodyStyle").val || "",
footerClass: getPropVal("footerClass").val || "",
footerStyle: getPropVal("footerStyle").val || "",
panelStyle
};
}
exports.panelClassProps = panelClassProps;
exports.panelProps = panelProps;
exports.panelStyleProps = panelStyleProps;
exports.usePanelProps = usePanelProps;
//# sourceMappingURL=panel2.js.map