mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-03 14:20:50 +08:00
171 lines
5.2 KiB
JavaScript
171 lines
5.2 KiB
JavaScript
import { p as cB, W as cM, d as defineComponent, q as useTheme, r as ref, x as useConfig, aI as layoutLight, $ as provide, aJ as useReactivated, G as computed, ap as useThemeClass, l as h, aK as Scrollbar, aL as createInjectionKey } from "./index-DKaFsuse.js";
|
|
const positionProp = {
|
|
type: String,
|
|
default: "static"
|
|
};
|
|
const style = cB("layout", `
|
|
color: var(--n-text-color);
|
|
background-color: var(--n-color);
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
z-index: auto;
|
|
flex: auto;
|
|
overflow: hidden;
|
|
transition:
|
|
box-shadow .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier);
|
|
`, [cB("layout-scroll-container", `
|
|
overflow-x: hidden;
|
|
box-sizing: border-box;
|
|
height: 100%;
|
|
`), cM("absolute-positioned", `
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
`)]);
|
|
const layoutProps = {
|
|
embedded: Boolean,
|
|
position: positionProp,
|
|
nativeScrollbar: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
scrollbarProps: Object,
|
|
onScroll: Function,
|
|
contentClass: String,
|
|
contentStyle: {
|
|
type: [String, Object],
|
|
default: ""
|
|
},
|
|
hasSider: Boolean,
|
|
siderPlacement: {
|
|
type: String,
|
|
default: "left"
|
|
}
|
|
};
|
|
const layoutInjectionKey = createInjectionKey("n-layout");
|
|
function createLayoutComponent(isContent) {
|
|
return defineComponent({
|
|
name: "Layout",
|
|
props: Object.assign(Object.assign({}, useTheme.props), layoutProps),
|
|
setup(props) {
|
|
const scrollableElRef = ref(null);
|
|
const scrollbarInstRef = ref(null);
|
|
const {
|
|
mergedClsPrefixRef,
|
|
inlineThemeDisabled
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Layout", "-layout", style, layoutLight, props, mergedClsPrefixRef);
|
|
function scrollTo(options, y) {
|
|
if (props.nativeScrollbar) {
|
|
const {
|
|
value: scrollableEl
|
|
} = scrollableElRef;
|
|
if (scrollableEl) {
|
|
if (y === void 0) {
|
|
scrollableEl.scrollTo(options);
|
|
} else {
|
|
scrollableEl.scrollTo(options, y);
|
|
}
|
|
}
|
|
} else {
|
|
const {
|
|
value: scrollbarInst
|
|
} = scrollbarInstRef;
|
|
if (scrollbarInst) {
|
|
scrollbarInst.scrollTo(options, y);
|
|
}
|
|
}
|
|
}
|
|
provide(layoutInjectionKey, props);
|
|
let scrollX = 0;
|
|
let scrollY = 0;
|
|
const handleNativeElScroll = (e) => {
|
|
var _a;
|
|
const target = e.target;
|
|
scrollX = target.scrollLeft;
|
|
scrollY = target.scrollTop;
|
|
(_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
};
|
|
useReactivated(() => {
|
|
if (props.nativeScrollbar) {
|
|
const el = scrollableElRef.value;
|
|
if (el) {
|
|
el.scrollTop = scrollY;
|
|
el.scrollLeft = scrollX;
|
|
}
|
|
}
|
|
});
|
|
const hasSiderStyle = {
|
|
display: "flex",
|
|
flexWrap: "nowrap",
|
|
width: "100%",
|
|
flexDirection: "row"
|
|
};
|
|
const exposedMethods = {
|
|
scrollTo
|
|
};
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut
|
|
},
|
|
self
|
|
} = themeRef.value;
|
|
return {
|
|
"--n-bezier": cubicBezierEaseInOut,
|
|
"--n-color": props.embedded ? self.colorEmbedded : self.color,
|
|
"--n-text-color": self.textColor
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("layout", computed(() => {
|
|
return props.embedded ? "e" : "";
|
|
}), cssVarsRef, props) : void 0;
|
|
return Object.assign({
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
scrollableElRef,
|
|
scrollbarInstRef,
|
|
hasSiderStyle,
|
|
mergedTheme: themeRef,
|
|
handleNativeElScroll,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
}, exposedMethods);
|
|
},
|
|
render() {
|
|
var _a;
|
|
const {
|
|
mergedClsPrefix,
|
|
hasSider
|
|
} = this;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
const hasSiderStyle = hasSider ? this.hasSiderStyle : void 0;
|
|
const layoutClass = [this.themeClass, isContent, `${mergedClsPrefix}-layout`, `${mergedClsPrefix}-layout--${this.position}-positioned`];
|
|
return h("div", {
|
|
class: layoutClass,
|
|
style: this.cssVars
|
|
}, this.nativeScrollbar ? h("div", {
|
|
ref: "scrollableElRef",
|
|
class: [`${mergedClsPrefix}-layout-scroll-container`, this.contentClass],
|
|
style: [this.contentStyle, hasSiderStyle],
|
|
onScroll: this.handleNativeElScroll
|
|
}, this.$slots) : h(Scrollbar, Object.assign({}, this.scrollbarProps, {
|
|
onScroll: this.onScroll,
|
|
ref: "scrollbarInstRef",
|
|
theme: this.mergedTheme.peers.Scrollbar,
|
|
themeOverrides: this.mergedTheme.peerOverrides.Scrollbar,
|
|
contentClass: this.contentClass,
|
|
contentStyle: [this.contentStyle, hasSiderStyle]
|
|
}), this.$slots));
|
|
}
|
|
});
|
|
}
|
|
const __unplugin_components_1 = createLayoutComponent(false);
|
|
export {
|
|
__unplugin_components_1 as _
|
|
};
|