创高项目初始化

This commit is contained in:
王文昊
2026-05-12 16:53:18 +08:00
commit abc3b4f875
13573 changed files with 2231964 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
import { DrawerEmits, DrawerProps } from "../drawer.js";
import * as _$vue from "vue";
import { Ref, SetupContext } from "vue";
//#region ../../packages/components/drawer/src/composables/useResizable.d.ts
declare function useResizable(props: DrawerProps & Required<Pick<DrawerProps, 'direction'>>, target: Ref<HTMLElement | undefined>, emit: SetupContext<DrawerEmits>['emit']): {
size: _$vue.ComputedRef<string | undefined>;
isResizing: Ref<boolean, boolean>;
isHorizontal: _$vue.ComputedRef<boolean>;
};
//#endregion
export { useResizable };

View File

@@ -0,0 +1,74 @@
import { addUnit } from "../../../../utils/dom/style.mjs";
import { clamp, useEventListener, useWindowSize } from "@vueuse/core";
import { computed, onBeforeUnmount, ref, watch } from "vue";
//#region ../../packages/components/drawer/src/composables/useResizable.ts
function useResizable(props, target, emit) {
const { width, height } = useWindowSize();
const isHorizontal = computed(() => ["ltr", "rtl"].includes(props.direction));
const sign = computed(() => ["ltr", "ttb"].includes(props.direction) ? 1 : -1);
const windowSize = computed(() => isHorizontal.value ? width.value : height.value);
const getSize = computed(() => {
return clamp(startSize.value + sign.value * offset.value, 4, windowSize.value);
});
const startSize = ref(0);
const offset = ref(0);
const isResizing = ref(false);
const hasStartedDragging = ref(false);
let startPos = [];
let cleanups = [];
const getActualSize = () => {
const drawerEl = target.value?.closest("[aria-modal=\"true\"]");
if (drawerEl) return isHorizontal.value ? drawerEl.offsetWidth : drawerEl.offsetHeight;
return 100;
};
watch(() => [props.size, props.resizable], () => {
hasStartedDragging.value = false;
startSize.value = 0;
offset.value = 0;
onMouseUp();
});
const onMousedown = (e) => {
if (!props.resizable) return;
if (!hasStartedDragging.value) {
startSize.value = getActualSize();
hasStartedDragging.value = true;
}
startPos = [e.pageX, e.pageY];
isResizing.value = true;
emit("resize-start", e, startSize.value);
cleanups.push(useEventListener(window, "mouseup", onMouseUp), useEventListener(window, "mousemove", onMouseMove));
};
const onMouseMove = (e) => {
const { pageX, pageY } = e;
const offsetX = pageX - startPos[0];
const offsetY = pageY - startPos[1];
offset.value = isHorizontal.value ? offsetX : offsetY;
emit("resize", e, getSize.value);
};
const onMouseUp = (e) => {
if (!isResizing.value) return;
startPos = [];
startSize.value = getSize.value;
offset.value = 0;
isResizing.value = false;
cleanups.forEach((cleanup) => cleanup?.());
cleanups = [];
if (e) emit("resize-end", e, startSize.value);
};
const cleanup = useEventListener(target, "mousedown", onMousedown);
onBeforeUnmount(() => {
cleanup();
onMouseUp();
});
return {
size: computed(() => {
return hasStartedDragging.value ? `${getSize.value}px` : addUnit(props.size);
}),
isResizing,
isHorizontal
};
}
//#endregion
export { useResizable };
//# sourceMappingURL=useResizable.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"useResizable.mjs","names":[],"sources":["../../../../../../../packages/components/drawer/src/composables/useResizable.ts"],"sourcesContent":["import { computed, onBeforeUnmount, ref, watch } from 'vue'\nimport { addUnit } from '@element-plus/utils'\nimport { clamp, useEventListener, useWindowSize } from '@vueuse/core'\n\nimport type { Ref, SetupContext } from 'vue'\nimport type { DrawerEmits, DrawerProps } from '../drawer'\n\nexport function useResizable(\n props: DrawerProps & Required<Pick<DrawerProps, 'direction'>>,\n target: Ref<HTMLElement | undefined>,\n emit: SetupContext<DrawerEmits>['emit']\n) {\n const { width, height } = useWindowSize()\n\n const isHorizontal = computed(() => ['ltr', 'rtl'].includes(props.direction))\n const sign = computed(() =>\n ['ltr', 'ttb'].includes(props.direction) ? 1 : -1\n )\n const windowSize = computed(() =>\n isHorizontal.value ? width.value : height.value\n )\n const getSize = computed(() => {\n return clamp(\n startSize.value + sign.value * offset.value,\n 4,\n windowSize.value\n )\n })\n\n const startSize = ref(0)\n const offset = ref(0)\n const isResizing = ref(false)\n const hasStartedDragging = ref(false)\n let startPos: number[] = []\n let cleanups: (() => void)[] = []\n\n const getActualSize = () => {\n const drawerEl = target.value?.closest('[aria-modal=\"true\"]') as HTMLElement\n if (drawerEl) {\n return isHorizontal.value ? drawerEl.offsetWidth : drawerEl.offsetHeight\n }\n return 100\n }\n\n watch(\n () => [props.size, props.resizable] as const,\n () => {\n hasStartedDragging.value = false\n startSize.value = 0\n offset.value = 0\n onMouseUp()\n }\n )\n\n const onMousedown = (e: MouseEvent) => {\n if (!props.resizable) return\n\n if (!hasStartedDragging.value) {\n startSize.value = getActualSize()\n hasStartedDragging.value = true\n }\n\n startPos = [e.pageX, e.pageY]\n isResizing.value = true\n emit('resize-start', e, startSize.value)\n cleanups.push(\n useEventListener(window, 'mouseup', onMouseUp),\n useEventListener(window, 'mousemove', onMouseMove)\n )\n }\n\n const onMouseMove = (e: MouseEvent) => {\n const { pageX, pageY } = e\n const offsetX = pageX - startPos[0]\n const offsetY = pageY - startPos[1]\n offset.value = isHorizontal.value ? offsetX : offsetY\n emit('resize', e, getSize.value)\n }\n\n const onMouseUp = (e?: MouseEvent) => {\n // premature interruption\n // avoid triggering meaningless execution due to watch size/resizable constraints.\n if (!isResizing.value) return\n\n startPos = []\n startSize.value = getSize.value\n offset.value = 0\n isResizing.value = false\n cleanups.forEach((cleanup) => cleanup?.())\n cleanups = []\n if (e) {\n emit('resize-end', e, startSize.value)\n }\n }\n\n const cleanup = useEventListener(target, 'mousedown', onMousedown)\n\n onBeforeUnmount(() => {\n cleanup()\n onMouseUp()\n })\n\n return {\n size: computed(() => {\n return hasStartedDragging.value\n ? `${getSize.value}px`\n : addUnit(props.size)\n }),\n isResizing,\n isHorizontal,\n }\n}\n"],"mappings":";;;;AAOA,SAAgB,aACd,OACA,QACA,MACA;CACA,MAAM,EAAE,OAAO,WAAW,eAAe;CAEzC,MAAM,eAAe,eAAe,CAAC,OAAO,MAAM,CAAC,SAAS,MAAM,UAAU,CAAC;CAC7E,MAAM,OAAO,eACX,CAAC,OAAO,MAAM,CAAC,SAAS,MAAM,UAAU,GAAG,IAAI,GAChD;CACD,MAAM,aAAa,eACjB,aAAa,QAAQ,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