This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
import Splitter from './src/splitter.vue';
import SplitPanel from './src/split-panel.vue';
import type { SFCWithInstall } from 'element-plus/es/utils';
export declare const ElSplitter: SFCWithInstall<typeof Splitter> & {
SplitPanel: typeof SplitPanel;
};
export default ElSplitter;
export declare const ElSplitterPanel: SFCWithInstall<typeof SplitPanel>;
export * from './src/splitter';
export * from './src/split-panel';

View File

@@ -0,0 +1,13 @@
import Splitter from './src/splitter2.mjs';
import SplitPanel from './src/split-panel2.mjs';
export { splitterProps } from './src/splitter.mjs';
export { splitterPanelProps } from './src/split-panel.mjs';
import { withInstall, withNoopInstall } from '../../utils/vue/install.mjs';
const ElSplitter = withInstall(Splitter, {
SplitPanel
});
const ElSplitterPanel = withNoopInstall(SplitPanel);
export { ElSplitter, ElSplitterPanel, ElSplitter as default };
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":["../../../../../packages/components/splitter/index.ts"],"sourcesContent":["import { withInstall, withNoopInstall } from '@element-plus/utils'\nimport Splitter from './src/splitter.vue'\nimport SplitPanel from './src/split-panel.vue'\n\nimport type { SFCWithInstall } from '@element-plus/utils'\n\nexport const ElSplitter: SFCWithInstall<typeof Splitter> & {\n SplitPanel: typeof SplitPanel\n} = withInstall(Splitter, {\n SplitPanel,\n})\nexport default ElSplitter\n\nexport const ElSplitterPanel: SFCWithInstall<typeof SplitPanel> =\n withNoopInstall(SplitPanel)\n\nexport * from './src/splitter'\nexport * from './src/split-panel'\n"],"names":[],"mappings":";;;;;;AAGY,MAAC,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE;AAChD,EAAE,UAAU;AACZ,CAAC,EAAE;AAES,MAAC,eAAe,GAAG,eAAe,CAAC,UAAU;;;;"}

View File

@@ -0,0 +1,3 @@
export { useContainer } from './useContainer';
export { useResize } from './useResize';
export { useSize, isPct, isPx, getPct, getPx } from './useSize';

View File

@@ -0,0 +1,4 @@
export { useContainer } from './useContainer.mjs';
export { useResize } from './useResize.mjs';
export { getPct, getPx, isPct, isPx, useSize } from './useSize.mjs';
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}

View File

@@ -0,0 +1,5 @@
import type { Ref } from 'vue';
export declare function useContainer(layout: Ref<'horizontal' | 'vertical'>): {
containerEl: Ref<HTMLDivElement | undefined>;
containerSize: import("vue").ComputedRef<number>;
};

View File

@@ -0,0 +1,14 @@
import { ref, computed } from 'vue';
import { useElementSize } from '@vueuse/core';
function useContainer(layout) {
const containerEl = ref();
const { width, height } = useElementSize(containerEl);
const containerSize = computed(() => {
return layout.value === "horizontal" ? width.value : height.value;
});
return { containerEl, containerSize };
}
export { useContainer };
//# sourceMappingURL=useContainer.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useContainer.mjs","sources":["../../../../../../../packages/components/splitter/src/hooks/useContainer.ts"],"sourcesContent":["import { computed, ref } from 'vue'\nimport { useElementSize } from '@vueuse/core'\n\nimport type { Ref } from 'vue'\n\nexport function useContainer(layout: Ref<'horizontal' | 'vertical'>) {\n const containerEl = ref<HTMLDivElement>()\n const { width, height } = useElementSize(containerEl)\n\n const containerSize = computed(() => {\n return layout.value === 'horizontal' ? width.value : height.value\n })\n\n return { containerEl, containerSize }\n}\n"],"names":[],"mappings":";;;AAEO,SAAS,YAAY,CAAC,MAAM,EAAE;AACrC,EAAE,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC;AAC5B,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;AACxD,EAAE,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM;AACvC,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,YAAY,GAAG,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AACtE,GAAG,CAAC,CAAC;AACL,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;AACxC;;;;"}

View File

@@ -0,0 +1,9 @@
import type { PanelItemState } from '../type';
export declare function getCollapsible(collapsible: boolean | {
start?: boolean;
end?: boolean;
}): {
start?: boolean;
end?: boolean;
};
export declare function isCollapsible(panel: PanelItemState | null | undefined, size: number, nextPanel: PanelItemState | null | undefined, nextSize: number): boolean;

View File

@@ -0,0 +1,23 @@
import { isObject } from '@vue/shared';
function getCollapsible(collapsible) {
if (collapsible && isObject(collapsible)) {
return collapsible;
}
return {
start: !!collapsible,
end: !!collapsible
};
}
function isCollapsible(panel, size, nextPanel, nextSize) {
if ((panel == null ? void 0 : panel.collapsible.end) && size > 0) {
return true;
}
if ((nextPanel == null ? void 0 : nextPanel.collapsible.start) && nextSize === 0 && size > 0) {
return true;
}
return false;
}
export { getCollapsible, isCollapsible };
//# sourceMappingURL=usePanel.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"usePanel.mjs","sources":["../../../../../../../packages/components/splitter/src/hooks/usePanel.ts"],"sourcesContent":["import { isObject } from '@element-plus/utils'\n\nimport type { PanelItemState } from '../type'\n\nexport function getCollapsible(\n collapsible: boolean | { start?: boolean; end?: boolean }\n) {\n if (collapsible && isObject(collapsible)) {\n return collapsible\n }\n return {\n start: !!collapsible,\n end: !!collapsible,\n }\n}\n\nexport function isCollapsible(\n panel: PanelItemState | null | undefined,\n size: number,\n nextPanel: PanelItemState | null | undefined,\n nextSize: number\n) {\n // If the current panel is collapsible and has size, then it can be collapsed\n if (panel?.collapsible.end && size > 0) {\n return true\n }\n\n // If the next panel is collapsible and has no size, but the current panel has size, then it can be collapsed\n if (nextPanel?.collapsible.start && nextSize === 0 && size > 0) {\n return true\n }\n\n return false\n}\n"],"names":[],"mappings":";;AACO,SAAS,cAAc,CAAC,WAAW,EAAE;AAC5C,EAAE,IAAI,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC,EAAE;AAC5C,IAAI,OAAO,WAAW,CAAC;AACvB,GAAG;AACH,EAAE,OAAO;AACT,IAAI,KAAK,EAAE,CAAC,CAAC,WAAW;AACxB,IAAI,GAAG,EAAE,CAAC,CAAC,WAAW;AACtB,GAAG,CAAC;AACJ,CAAC;AACM,SAAS,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE;AAChE,EAAE,IAAI,CAAC,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,KAAK,IAAI,GAAG,CAAC,EAAE;AACpE,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,SAAS,CAAC,WAAW,CAAC,KAAK,KAAK,QAAQ,KAAK,CAAC,IAAI,IAAI,GAAG,CAAC,EAAE;AAChG,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,OAAO,KAAK,CAAC;AACf;;;;"}

View File

@@ -0,0 +1,13 @@
import type { ComputedRef, Ref } from 'vue';
import type { PanelItemState } from '../type';
export declare function useResize(panels: Ref<PanelItemState[]>, containerSize: ComputedRef<number>, pxSizes: ComputedRef<number[]>, lazy: Ref<boolean>): {
lazyOffset: Ref<number>;
onMoveStart: (index: number) => void;
onMoving: (index: number, offset: number) => void;
onMoveEnd: () => void;
movingIndex: Ref<{
index: number;
confirmed: boolean;
} | null>;
onCollapse: (index: number, type: "start" | "end") => void;
};

View File

@@ -0,0 +1,125 @@
import { ref, computed, watch } from 'vue';
import { isPct, getPct, isPx, getPx } from './useSize.mjs';
import { NOOP } from '@vue/shared';
function useResize(panels, containerSize, pxSizes, lazy) {
const ptg2px = (ptg) => ptg * containerSize.value || 0;
function getLimitSize(str, defaultLimit) {
if (isPct(str)) {
return ptg2px(getPct(str));
} else if (isPx(str)) {
return getPx(str);
}
return str != null ? str : defaultLimit;
}
const lazyOffset = ref(0);
const movingIndex = ref(null);
let cachePxSizes = [];
let updatePanelSizes = NOOP;
const limitSizes = computed(() => panels.value.map((item) => [item.min, item.max]));
watch(lazy, () => {
if (lazyOffset.value) {
const mouseup = new MouseEvent("mouseup", { bubbles: true });
window.dispatchEvent(mouseup);
}
});
const onMoveStart = (index) => {
lazyOffset.value = 0;
movingIndex.value = { index, confirmed: false };
cachePxSizes = pxSizes.value;
};
const onMoving = (index, offset) => {
var _a, _b;
let confirmedIndex = null;
if ((!movingIndex.value || !movingIndex.value.confirmed) && offset !== 0) {
if (offset > 0) {
confirmedIndex = index;
movingIndex.value = { index, confirmed: true };
} else {
for (let i = index; i >= 0; i -= 1) {
if (cachePxSizes[i] > 0) {
confirmedIndex = i;
movingIndex.value = { index: i, confirmed: true };
break;
}
}
}
}
const mergedIndex = (_b = confirmedIndex != null ? confirmedIndex : (_a = movingIndex.value) == null ? void 0 : _a.index) != null ? _b : index;
const numSizes = [...cachePxSizes];
const nextIndex = mergedIndex + 1;
const startMinSize = getLimitSize(limitSizes.value[mergedIndex][0], 0);
const endMinSize = getLimitSize(limitSizes.value[nextIndex][0], 0);
const startMaxSize = getLimitSize(limitSizes.value[mergedIndex][1], containerSize.value || 0);
const endMaxSize = getLimitSize(limitSizes.value[nextIndex][1], containerSize.value || 0);
let mergedOffset = offset;
if (numSizes[mergedIndex] + mergedOffset < startMinSize) {
mergedOffset = startMinSize - numSizes[mergedIndex];
}
if (numSizes[nextIndex] - mergedOffset < endMinSize) {
mergedOffset = numSizes[nextIndex] - endMinSize;
}
if (numSizes[mergedIndex] + mergedOffset > startMaxSize) {
mergedOffset = startMaxSize - numSizes[mergedIndex];
}
if (numSizes[nextIndex] - mergedOffset > endMaxSize) {
mergedOffset = numSizes[nextIndex] - endMaxSize;
}
numSizes[mergedIndex] += mergedOffset;
numSizes[nextIndex] -= mergedOffset;
lazyOffset.value = mergedOffset;
updatePanelSizes = () => {
panels.value.forEach((panel, index2) => {
panel.size = numSizes[index2];
});
updatePanelSizes = NOOP;
};
if (!lazy.value) {
updatePanelSizes();
}
};
const onMoveEnd = () => {
if (lazy.value) {
updatePanelSizes();
}
lazyOffset.value = 0;
movingIndex.value = null;
cachePxSizes = [];
};
const cacheCollapsedSize = [];
const onCollapse = (index, type) => {
if (!cacheCollapsedSize.length) {
cacheCollapsedSize.push(...pxSizes.value);
}
const currentSizes = pxSizes.value;
const currentIndex = type === "start" ? index : index + 1;
const targetIndex = type === "start" ? index + 1 : index;
const currentSize = currentSizes[currentIndex];
const targetSize = currentSizes[targetIndex];
if (currentSize !== 0 && targetSize !== 0) {
currentSizes[currentIndex] = 0;
currentSizes[targetIndex] += currentSize;
cacheCollapsedSize[index] = currentSize;
} else {
const totalSize = currentSize + targetSize;
const targetCacheCollapsedSize = cacheCollapsedSize[index];
const currentCacheCollapsedSize = totalSize - targetCacheCollapsedSize;
currentSizes[targetIndex] = targetCacheCollapsedSize;
currentSizes[currentIndex] = currentCacheCollapsedSize;
}
panels.value.forEach((panel, index2) => {
panel.size = currentSizes[index2];
});
};
return {
lazyOffset,
onMoveStart,
onMoving,
onMoveEnd,
movingIndex,
onCollapse
};
}
export { useResize };
//# sourceMappingURL=useResize.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import type { ComputedRef, Ref } from 'vue';
import type { PanelItemState } from '../type';
export declare function getPct(str: string): number;
export declare function getPx(str: string): number;
export declare function isPct(itemSize: string | number | undefined): itemSize is string;
export declare function isPx(itemSize: string | number | undefined): itemSize is string;
export declare function useSize(panels: Ref<PanelItemState[]>, containerSize: ComputedRef<number>): {
percentSizes: Ref<number[]>;
pxSizes: ComputedRef<number[]>;
};

View File

@@ -0,0 +1,56 @@
import { computed, ref, watch } from 'vue';
import { isString } from '@vue/shared';
function getPct(str) {
return Number(str.slice(0, -1)) / 100;
}
function getPx(str) {
return Number(str.slice(0, -2));
}
function isPct(itemSize) {
return isString(itemSize) && itemSize.endsWith("%");
}
function isPx(itemSize) {
return isString(itemSize) && itemSize.endsWith("px");
}
function useSize(panels, containerSize) {
const propSizes = computed(() => panels.value.map((i) => i.size));
const panelCounts = computed(() => panels.value.length);
const percentSizes = ref([]);
watch([propSizes, panelCounts, containerSize], () => {
var _a;
let ptgList = [];
let emptyCount = 0;
for (let i = 0; i < panelCounts.value; i += 1) {
const itemSize = (_a = panels.value[i]) == null ? void 0 : _a.size;
if (isPct(itemSize)) {
ptgList[i] = getPct(itemSize);
} else if (isPx(itemSize)) {
ptgList[i] = getPx(itemSize) / containerSize.value;
} else if (itemSize || itemSize === 0) {
const num = Number(itemSize);
if (!Number.isNaN(num)) {
ptgList[i] = num / containerSize.value;
}
} else {
emptyCount += 1;
ptgList[i] = void 0;
}
}
const totalPtg = ptgList.reduce((acc, ptg) => acc + (ptg || 0), 0);
if (totalPtg > 1 || !emptyCount) {
const scale = 1 / totalPtg;
ptgList = ptgList.map((ptg) => ptg === void 0 ? 0 : ptg * scale);
} else {
const avgRest = (1 - totalPtg) / emptyCount;
ptgList = ptgList.map((ptg) => ptg === void 0 ? avgRest : ptg);
}
percentSizes.value = ptgList;
});
const ptg2px = (ptg) => ptg * containerSize.value;
const pxSizes = computed(() => percentSizes.value.map(ptg2px));
return { percentSizes, pxSizes };
}
export { getPct, getPx, isPct, isPx, useSize };
//# sourceMappingURL=useSize.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,147 @@
import { defineComponent, computed, ref, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, renderSlot, createBlock, resolveDynamicComponent, createCommentVNode, createElementVNode } from 'vue';
import { ArrowLeft, ArrowUp, ArrowRight, ArrowDown } from '@element-plus/icons-vue';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
const __default__ = defineComponent({
name: "ElSplitterBar"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: {
index: {
type: Number,
required: true
},
layout: {
type: String,
values: ["horizontal", "vertical"],
default: "horizontal"
},
resizable: {
type: Boolean,
default: true
},
lazy: Boolean,
startCollapsible: Boolean,
endCollapsible: Boolean
},
emits: ["moveStart", "moving", "moveEnd", "collapse"],
setup(__props, { emit }) {
const props = __props;
const ns = useNamespace("splitter-bar");
const isHorizontal = computed(() => props.layout === "horizontal");
const barWrapStyles = computed(() => {
if (isHorizontal.value) {
return { width: 0 };
}
return { height: 0 };
});
const draggerStyles = computed(() => {
return {
width: isHorizontal.value ? "16px" : "100%",
height: isHorizontal.value ? "100%" : "16px",
cursor: !props.resizable ? "auto" : isHorizontal.value ? "ew-resize" : "ns-resize",
touchAction: "none"
};
});
const draggerPseudoClass = computed(() => {
const prefix = ns.e("dragger");
return {
[`${prefix}-horizontal`]: isHorizontal.value,
[`${prefix}-vertical`]: !isHorizontal.value,
[`${prefix}-active`]: !!startPos.value
};
});
const startPos = ref(null);
const onMousedown = (e) => {
if (!props.resizable)
return;
startPos.value = [e.pageX, e.pageY];
emit("moveStart", props.index);
window.addEventListener("mouseup", onMouseUp);
window.addEventListener("mousemove", onMouseMove);
};
const onTouchStart = (e) => {
if (props.resizable && e.touches.length === 1) {
e.preventDefault();
const touch = e.touches[0];
startPos.value = [touch.pageX, touch.pageY];
emit("moveStart", props.index);
window.addEventListener("touchend", onTouchEnd);
window.addEventListener("touchmove", onTouchMove);
}
};
const onMouseMove = (e) => {
const { pageX, pageY } = e;
const offsetX = pageX - startPos.value[0];
const offsetY = pageY - startPos.value[1];
const offset = isHorizontal.value ? offsetX : offsetY;
emit("moving", props.index, offset);
};
const onTouchMove = (e) => {
if (e.touches.length === 1) {
e.preventDefault();
const touch = e.touches[0];
const offsetX = touch.pageX - startPos.value[0];
const offsetY = touch.pageY - startPos.value[1];
const offset = isHorizontal.value ? offsetX : offsetY;
emit("moving", props.index, offset);
}
};
const onMouseUp = () => {
startPos.value = null;
window.removeEventListener("mouseup", onMouseUp);
window.removeEventListener("mousemove", onMouseMove);
emit("moveEnd", props.index);
};
const onTouchEnd = () => {
startPos.value = null;
window.removeEventListener("touchend", onTouchEnd);
window.removeEventListener("touchmove", onTouchMove);
emit("moveEnd", props.index);
};
const StartIcon = computed(() => isHorizontal.value ? ArrowLeft : ArrowUp);
const EndIcon = computed(() => isHorizontal.value ? ArrowRight : ArrowDown);
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
class: normalizeClass([unref(ns).b()]),
style: normalizeStyle(unref(barWrapStyles))
}, [
__props.startCollapsible ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass([unref(ns).e("collapse-icon"), unref(ns).e(`${__props.layout}-collapse-icon-start`)]),
onClick: ($event) => emit("collapse", __props.index, "start")
}, [
renderSlot(_ctx.$slots, "start-collapsible", {}, () => [
(openBlock(), createBlock(resolveDynamicComponent(unref(StartIcon)), { style: { "width": "12px", "height": "12px" } }))
])
], 10, ["onClick"])) : createCommentVNode("v-if", true),
createElementVNode("div", {
class: normalizeClass([
unref(ns).e("dragger"),
unref(draggerPseudoClass),
unref(ns).is("disabled", !__props.resizable),
unref(ns).is("lazy", __props.resizable && __props.lazy)
]),
style: normalizeStyle(unref(draggerStyles)),
onMousedown,
onTouchstart: onTouchStart
}, null, 38),
__props.endCollapsible ? (openBlock(), createElementBlock("div", {
key: 1,
class: normalizeClass([unref(ns).e("collapse-icon"), unref(ns).e(`${__props.layout}-collapse-icon-end`)]),
onClick: ($event) => emit("collapse", __props.index, "end")
}, [
renderSlot(_ctx.$slots, "end-collapsible", {}, () => [
(openBlock(), createBlock(resolveDynamicComponent(unref(EndIcon)), { style: { "width": "12px", "height": "12px" } }))
])
], 10, ["onClick"])) : createCommentVNode("v-if", true)
], 6);
};
}
});
var SplitBar = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "split-bar.vue"]]);
export { SplitBar as default };
//# sourceMappingURL=split-bar.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,62 @@
declare function __VLS_template(): {
"start-collapsible"?(_: {}): any;
"end-collapsible"?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
index: {
type: NumberConstructor;
required: true;
};
layout: {
type: StringConstructor;
values: readonly ["horizontal", "vertical"];
default: string;
};
resizable: {
type: BooleanConstructor;
default: boolean;
};
lazy: BooleanConstructor;
startCollapsible: BooleanConstructor;
endCollapsible: BooleanConstructor;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
collapse: (...args: any[]) => void;
moveStart: (...args: any[]) => void;
moving: (...args: any[]) => void;
moveEnd: (...args: any[]) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
index: {
type: NumberConstructor;
required: true;
};
layout: {
type: StringConstructor;
values: readonly ["horizontal", "vertical"];
default: string;
};
resizable: {
type: BooleanConstructor;
default: boolean;
};
lazy: BooleanConstructor;
startCollapsible: BooleanConstructor;
endCollapsible: BooleanConstructor;
}>> & {
onCollapse?: ((...args: any[]) => any) | undefined;
onMoveStart?: ((...args: any[]) => any) | undefined;
onMoving?: ((...args: any[]) => any) | undefined;
onMoveEnd?: ((...args: any[]) => any) | undefined;
}, {
layout: string;
lazy: boolean;
resizable: boolean;
startCollapsible: boolean;
endCollapsible: boolean;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,27 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type SplitterPanel from './split-panel.vue';
export declare const splitterPanelProps: {
readonly min: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly max: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly resizable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly collapsible: BooleanConstructor;
};
export type SplitterPanelProps = ExtractPropTypes<typeof splitterPanelProps>;
export type SplitterPanelPropsPublic = __ExtractPublicPropTypes<typeof splitterPanelProps>;
export type SplitterPanelInstance = InstanceType<typeof SplitterPanel> & unknown;

View File

@@ -0,0 +1,21 @@
import { buildProps } from '../../../utils/vue/props/runtime.mjs';
const splitterPanelProps = buildProps({
min: {
type: [String, Number]
},
max: {
type: [String, Number]
},
size: {
type: [String, Number]
},
resizable: {
type: Boolean,
default: true
},
collapsible: Boolean
});
export { splitterPanelProps };
//# sourceMappingURL=split-panel.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"split-panel.mjs","sources":["../../../../../../packages/components/splitter/src/split-panel.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type SplitterPanel from './split-panel.vue'\n\nexport const splitterPanelProps = buildProps({\n min: {\n type: [String, Number],\n },\n max: {\n type: [String, Number],\n },\n size: {\n type: [String, Number],\n },\n resizable: {\n type: Boolean,\n default: true,\n },\n collapsible: Boolean,\n} as const)\n\nexport type SplitterPanelProps = ExtractPropTypes<typeof splitterPanelProps>\nexport type SplitterPanelPropsPublic = __ExtractPublicPropTypes<\n typeof splitterPanelProps\n>\nexport type SplitterPanelInstance = InstanceType<typeof SplitterPanel> & unknown\n"],"names":[],"mappings":";;AACY,MAAC,kBAAkB,GAAG,UAAU,CAAC;AAC7C,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,GAAG;AACH,EAAE,GAAG,EAAE;AACP,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,GAAG;AACH,EAAE,IAAI,EAAE;AACR,IAAI,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;AAC1B,GAAG;AACH,EAAE,SAAS,EAAE;AACb,IAAI,IAAI,EAAE,OAAO;AACjB,IAAI,OAAO,EAAE,IAAI;AACjB,GAAG;AACH,EAAE,WAAW,EAAE,OAAO;AACtB,CAAC;;;;"}

View File

@@ -0,0 +1,62 @@
declare function __VLS_template(): {
default?(_: {}): any;
"start-collapsible"?(_: {}): any;
"end-collapsible"?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly min: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly max: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly resizable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly collapsible: BooleanConstructor;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
"update:size": (value: number) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly min: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly max: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly size: {
readonly type: import("vue").PropType<import("element-plus/es/utils").EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown>>;
readonly required: false;
readonly validator: ((val: unknown) => boolean) | undefined;
__epPropKey: true;
};
readonly resizable: import("element-plus/es/utils").EpPropFinalized<BooleanConstructor, unknown, unknown, true, boolean>;
readonly collapsible: BooleanConstructor;
}>> & {
"onUpdate:size"?: ((value: number) => any) | undefined;
}, {
readonly resizable: import("element-plus/es/utils").EpPropMergeType<BooleanConstructor, unknown, unknown>;
readonly collapsible: boolean;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,161 @@
import { defineComponent, inject, toRefs, ref, getCurrentInstance, computed, watch, nextTick, reactive, onBeforeUnmount, openBlock, createElementBlock, Fragment, createElementVNode, mergeProps, unref, renderSlot, createBlock, withCtx, createCommentVNode } from 'vue';
import { isCollapsible, getCollapsible } from './hooks/usePanel.mjs';
import SplitBar from './split-bar.mjs';
import { splitterPanelProps } from './split-panel.mjs';
import { splitterRootContextKey } from './type.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { isPct, getPct, isPx, getPx } from './hooks/useSize.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { throwError } from '../../../utils/error.mjs';
const COMPONENT_NAME = "ElSplitterPanel";
const __default__ = defineComponent({
name: COMPONENT_NAME
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: splitterPanelProps,
emits: ["update:size"],
setup(__props, { emit: emits }) {
const props = __props;
const ns = useNamespace("splitter-panel");
const splitterContext = inject(splitterRootContextKey);
if (!splitterContext)
throwError(COMPONENT_NAME, "usage: <el-splitter><el-splitter-panel /></el-splitter/>");
const { panels, layout, lazy, containerSize, pxSizes } = toRefs(splitterContext);
const {
registerPanel,
unregisterPanel,
onCollapse,
onMoveEnd,
onMoveStart,
onMoving
} = splitterContext;
const panelEl = ref();
const instance = getCurrentInstance();
const uid = instance.uid;
const index = ref(0);
const panel = computed(() => panels.value[index.value]);
const setIndex = (val) => {
index.value = val;
};
const panelSize = computed(() => {
var _a;
if (!panel.value)
return 0;
return (_a = pxSizes.value[index.value]) != null ? _a : 0;
});
const nextSize = computed(() => {
var _a;
if (!panel.value)
return 0;
return (_a = pxSizes.value[index.value + 1]) != null ? _a : 0;
});
const nextPanel = computed(() => {
if (panel.value) {
return panels.value[index.value + 1];
}
return null;
});
const isResizable = computed(() => {
var _a;
if (!nextPanel.value)
return false;
return props.resizable && ((_a = nextPanel.value) == null ? void 0 : _a.resizable) && (panelSize.value !== 0 || !props.min) && (nextSize.value !== 0 || !nextPanel.value.min);
});
const isShowBar = computed(() => {
if (!panel.value)
return false;
return index.value !== panels.value.length - 1;
});
const startCollapsible = computed(() => isCollapsible(panel.value, panelSize.value, nextPanel.value, nextSize.value));
const endCollapsible = computed(() => isCollapsible(nextPanel.value, nextSize.value, panel.value, panelSize.value));
function sizeToPx(str) {
if (isPct(str)) {
return getPct(str) * containerSize.value || 0;
} else if (isPx(str)) {
return getPx(str);
}
return str != null ? str : 0;
}
let isSizeUpdating = false;
watch(() => props.size, () => {
if (!isSizeUpdating && panel.value) {
if (!containerSize.value) {
panel.value.size = props.size;
return;
}
const size = sizeToPx(props.size);
const maxSize = sizeToPx(props.max);
const minSize = sizeToPx(props.min);
const finalSize = Math.min(Math.max(size, minSize || 0), maxSize || size);
if (finalSize !== size) {
emits("update:size", finalSize);
}
panel.value.size = finalSize;
}
});
watch(() => {
var _a;
return (_a = panel.value) == null ? void 0 : _a.size;
}, (val) => {
if (val !== props.size) {
isSizeUpdating = true;
emits("update:size", val);
nextTick(() => isSizeUpdating = false);
}
});
watch(() => props.resizable, (val) => {
if (panel.value) {
panel.value.resizable = val;
}
});
const _panel = reactive({
el: panelEl.value,
uid,
getVnode: () => instance.vnode,
setIndex,
...props,
collapsible: computed(() => getCollapsible(props.collapsible))
});
registerPanel(_panel);
onBeforeUnmount(() => unregisterPanel(_panel));
return (_ctx, _cache) => {
return openBlock(), createElementBlock(Fragment, null, [
createElementVNode("div", mergeProps({
ref_key: "panelEl",
ref: panelEl,
class: [unref(ns).b()],
style: { flexBasis: `${unref(panelSize)}px` }
}, _ctx.$attrs), [
renderSlot(_ctx.$slots, "default")
], 16),
unref(isShowBar) ? (openBlock(), createBlock(SplitBar, {
key: 0,
index: index.value,
layout: unref(layout),
lazy: unref(lazy),
resizable: unref(isResizable),
"start-collapsible": unref(startCollapsible),
"end-collapsible": unref(endCollapsible),
onMoveStart: unref(onMoveStart),
onMoving: unref(onMoving),
onMoveEnd: unref(onMoveEnd),
onCollapse: unref(onCollapse)
}, {
"start-collapsible": withCtx(() => [
renderSlot(_ctx.$slots, "start-collapsible")
]),
"end-collapsible": withCtx(() => [
renderSlot(_ctx.$slots, "end-collapsible")
]),
_: 3
}, 8, ["index", "layout", "lazy", "resizable", "start-collapsible", "end-collapsible", "onMoveStart", "onMoving", "onMoveEnd", "onCollapse"])) : createCommentVNode("v-if", true)
], 64);
};
}
});
var SplitPanel = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "split-panel.vue"]]);
export { SplitPanel as default };
//# sourceMappingURL=split-panel2.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,9 @@
import type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue';
import type Splitter from './splitter.vue';
export declare const splitterProps: {
readonly layout: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "horizontal" | "vertical", unknown, "horizontal", boolean>;
readonly lazy: BooleanConstructor;
};
export type SplitterProps = ExtractPropTypes<typeof splitterProps>;
export type SplitterPropsPublic = __ExtractPublicPropTypes<typeof splitterProps>;
export type SplitterInstance = InstanceType<typeof Splitter> & unknown;

View File

@@ -0,0 +1,13 @@
import { buildProps } from '../../../utils/vue/props/runtime.mjs';
const splitterProps = buildProps({
layout: {
type: String,
default: "horizontal",
values: ["horizontal", "vertical"]
},
lazy: Boolean
});
export { splitterProps };
//# sourceMappingURL=splitter.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"splitter.mjs","sources":["../../../../../../packages/components/splitter/src/splitter.ts"],"sourcesContent":["import { buildProps } from '@element-plus/utils'\n\nimport type { ExtractPropTypes, __ExtractPublicPropTypes } from 'vue'\nimport type Splitter from './splitter.vue'\n\nexport const splitterProps = buildProps({\n layout: {\n type: String,\n default: 'horizontal',\n values: ['horizontal', 'vertical'] as const,\n },\n lazy: Boolean,\n} as const)\n\nexport type SplitterProps = ExtractPropTypes<typeof splitterProps>\nexport type SplitterPropsPublic = __ExtractPublicPropTypes<typeof splitterProps>\nexport type SplitterInstance = InstanceType<typeof Splitter> & unknown\n"],"names":[],"mappings":";;AACY,MAAC,aAAa,GAAG,UAAU,CAAC;AACxC,EAAE,MAAM,EAAE;AACV,IAAI,IAAI,EAAE,MAAM;AAChB,IAAI,OAAO,EAAE,YAAY;AACzB,IAAI,MAAM,EAAE,CAAC,YAAY,EAAE,UAAU,CAAC;AACtC,GAAG;AACH,EAAE,IAAI,EAAE,OAAO;AACf,CAAC;;;;"}

View File

@@ -0,0 +1,30 @@
declare function __VLS_template(): {
default?(_: {}): any;
};
declare const __VLS_component: import("vue").DefineComponent<{
readonly layout: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "horizontal" | "vertical", unknown, "horizontal", boolean>;
readonly lazy: BooleanConstructor;
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
resizeStart: (index: number, sizes: number[]) => void;
resize: (index: number, sizes: number[]) => void;
resizeEnd: (index: number, sizes: number[]) => void;
collapse: (index: number, type: "end" | "start", sizes: number[]) => void;
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
readonly layout: import("element-plus/es/utils").EpPropFinalized<StringConstructor, "horizontal" | "vertical", unknown, "horizontal", boolean>;
readonly lazy: BooleanConstructor;
}>> & {
onResize?: ((index: number, sizes: number[]) => any) | undefined;
onCollapse?: ((index: number, type: "end" | "start", sizes: number[]) => any) | undefined;
onResizeStart?: ((index: number, sizes: number[]) => any) | undefined;
onResizeEnd?: ((index: number, sizes: number[]) => any) | undefined;
}, {
readonly layout: import("element-plus/es/utils").EpPropMergeType<StringConstructor, "horizontal" | "vertical", unknown>;
readonly lazy: boolean;
}>;
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
export default _default;
type __VLS_WithTemplateSlots<T, S> = T & {
new (): {
$slots: S;
};
};

View File

@@ -0,0 +1,104 @@
import { defineComponent, toRef, getCurrentInstance, watch, computed, provide, reactive, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, renderSlot, createVNode, createCommentVNode, nextTick } from 'vue';
import { splitterProps } from './splitter.mjs';
import { splitterRootContextKey } from './type.mjs';
import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
import { useContainer } from './hooks/useContainer.mjs';
import { useSize } from './hooks/useSize.mjs';
import { useResize } from './hooks/useResize.mjs';
import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
import { useOrderedChildren } from '../../../hooks/use-ordered-children/index.mjs';
const __default__ = defineComponent({
name: "ElSplitter"
});
const _sfc_main = /* @__PURE__ */ defineComponent({
...__default__,
props: splitterProps,
emits: ["resizeStart", "resize", "resizeEnd", "collapse"],
setup(__props, { emit: emits }) {
const props = __props;
const ns = useNamespace("splitter");
const layout = toRef(props, "layout");
const lazy = toRef(props, "lazy");
const { containerEl, containerSize } = useContainer(layout);
const {
removeChild: unregisterPanel,
children: panels,
addChild: registerPanel,
ChildrenSorter: PanelsSorter
} = useOrderedChildren(getCurrentInstance(), "ElSplitterPanel");
watch(panels, () => {
panels.value.forEach((instance, index) => {
instance.setIndex(index);
});
});
const { percentSizes, pxSizes } = useSize(panels, containerSize);
const {
lazyOffset,
movingIndex,
onMoveStart,
onMoving,
onMoveEnd,
onCollapse
} = useResize(panels, containerSize, pxSizes, lazy);
const splitterStyles = computed(() => {
return {
[`--${ns.b()}-bar-offset`]: lazy.value ? `${lazyOffset.value}px` : void 0
};
});
const onResizeStart = (index) => {
onMoveStart(index);
emits("resizeStart", index, pxSizes.value);
};
const onResize = (index, offset) => {
onMoving(index, offset);
if (!lazy.value) {
emits("resize", index, pxSizes.value);
}
};
const onResizeEnd = async (index) => {
onMoveEnd();
await nextTick();
emits("resizeEnd", index, pxSizes.value);
};
const onCollapsible = (index, type) => {
onCollapse(index, type);
emits("collapse", index, type, pxSizes.value);
};
provide(splitterRootContextKey, reactive({
panels,
percentSizes,
pxSizes,
layout,
lazy,
movingIndex,
containerSize,
onMoveStart: onResizeStart,
onMoving: onResize,
onMoveEnd: onResizeEnd,
onCollapse: onCollapsible,
registerPanel,
unregisterPanel
}));
return (_ctx, _cache) => {
return openBlock(), createElementBlock("div", {
ref_key: "containerEl",
ref: containerEl,
class: normalizeClass([unref(ns).b(), unref(ns).e(unref(layout))]),
style: normalizeStyle(unref(splitterStyles))
}, [
renderSlot(_ctx.$slots, "default"),
createVNode(unref(PanelsSorter)),
createCommentVNode(" Prevent iframe touch events from breaking "),
unref(movingIndex) ? (openBlock(), createElementBlock("div", {
key: 0,
class: normalizeClass([unref(ns).e("mask"), unref(ns).e(`mask-${unref(layout)}`)])
}, null, 2)) : createCommentVNode("v-if", true)
], 6);
};
}
});
var Splitter = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "splitter.vue"]]);
export { Splitter as default };
//# sourceMappingURL=splitter2.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,35 @@
import type { InjectionKey, UnwrapRef, VNode } from 'vue';
export type Layout = 'horizontal' | 'vertical';
export type PanelItemState = UnwrapRef<{
uid: number;
getVnode: () => VNode;
el: HTMLElement;
collapsible: {
start?: boolean;
end?: boolean;
};
max?: number | string;
min?: number | string;
resizable: boolean;
size?: number | string;
setIndex: (val: number) => void;
}>;
export interface SplitterRootContext {
panels: PanelItemState[];
layout: Layout;
lazy: boolean;
containerSize: number;
movingIndex: {
index: number;
confirmed: boolean;
} | null;
percentSizes: number[];
pxSizes: number[];
registerPanel: (pane: PanelItemState) => void;
unregisterPanel: (pane: PanelItemState) => void;
onCollapse: (index: number, type: 'start' | 'end') => void;
onMoveEnd: (index: number) => Promise<void>;
onMoveStart: (index: number) => void;
onMoving: (index: number, offset: number) => void;
}
export declare const splitterRootContextKey: InjectionKey<SplitterRootContext>;

View File

@@ -0,0 +1,4 @@
const splitterRootContextKey = Symbol("splitterRootContextKey");
export { splitterRootContextKey };
//# sourceMappingURL=type.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"type.mjs","sources":["../../../../../../packages/components/splitter/src/type.ts"],"sourcesContent":["import type { InjectionKey, UnwrapRef, VNode } from 'vue'\n\nexport type Layout = 'horizontal' | 'vertical'\n\nexport type PanelItemState = UnwrapRef<{\n uid: number\n getVnode: () => VNode\n el: HTMLElement\n collapsible: { start?: boolean; end?: boolean }\n max?: number | string\n min?: number | string\n resizable: boolean\n size?: number | string\n setIndex: (val: number) => void\n}>\n\nexport interface SplitterRootContext {\n panels: PanelItemState[]\n layout: Layout\n lazy: boolean\n containerSize: number\n movingIndex: { index: number; confirmed: boolean } | null\n percentSizes: number[]\n pxSizes: number[]\n registerPanel: (pane: PanelItemState) => void\n unregisterPanel: (pane: PanelItemState) => void\n onCollapse: (index: number, type: 'start' | 'end') => void\n onMoveEnd: (index: number) => Promise<void>\n onMoveStart: (index: number) => void\n onMoving: (index: number, offset: number) => void\n}\n\nexport const splitterRootContextKey: InjectionKey<SplitterRootContext> = Symbol(\n 'splitterRootContextKey'\n)\n"],"names":[],"mappings":"AAAY,MAAC,sBAAsB,GAAG,MAAM,CAAC,wBAAwB;;;;"}

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style/css';
import 'element-plus/theme-chalk/el-splitter.css';

View File

@@ -0,0 +1,3 @@
import '../../base/style/css.mjs';
import 'element-plus/theme-chalk/el-splitter.css';
//# sourceMappingURL=css.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"css.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}

View File

@@ -0,0 +1,2 @@
import 'element-plus/es/components/base/style';
import 'element-plus/theme-chalk/src/splitter.scss';

View File

@@ -0,0 +1,3 @@
import '../../base/style/index.mjs';
import 'element-plus/theme-chalk/src/splitter.scss';
//# sourceMappingURL=index.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}