创高项目初始化

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,6 @@
import { useCheck } from "./use-check.js";
import { useCheckedChange } from "./use-checked-change.js";
import { useComputedData } from "./use-computed-data.js";
import { useMove } from "./use-move.js";
import { usePropsAlias } from "./use-props-alias.js";
export { useCheck, useCheckedChange, useComputedData, useMove, usePropsAlias };

View File

@@ -0,0 +1,6 @@
import { usePropsAlias } from "./use-props-alias.mjs";
import { useCheck } from "./use-check.mjs";
import { useCheckedChange } from "./use-checked-change.mjs";
import { useComputedData } from "./use-computed-data.mjs";
import { useMove } from "./use-move.mjs";
export { useCheck, useCheckedChange, useComputedData, useMove, usePropsAlias };

View File

@@ -0,0 +1,19 @@
import { CheckboxValueType } from "../../../checkbox/src/checkbox.js";
import { TransferDataItem } from "../transfer.js";
import { TransferPanelEmits, TransferPanelProps, TransferPanelState } from "../transfer-panel.js";
import * as _$vue from "vue";
import { SetupContext } from "vue";
//#region ../../packages/components/transfer/src/composables/use-check.d.ts
declare const useCheck: <T extends TransferDataItem = TransferDataItem>(props: Required<Pick<TransferPanelProps<T>, "data" | "format" | "defaultChecked" | "props">> & {
filterMethod: TransferPanelProps<T>["filterMethod"];
}, panelState: TransferPanelState, emit: SetupContext<TransferPanelEmits>["emit"]) => {
filteredData: _$vue.ComputedRef<T[]>;
checkableData: _$vue.ComputedRef<T[]>;
checkedSummary: _$vue.ComputedRef<string>;
isIndeterminate: _$vue.ComputedRef<boolean>;
updateAllChecked: () => void;
handleAllCheckedChange: (value: CheckboxValueType) => void;
};
//#endregion
export { useCheck };

View File

@@ -0,0 +1,75 @@
import { isFunction } from "../../../../utils/types.mjs";
import { CHECKED_CHANGE_EVENT } from "../transfer-panel.mjs";
import { usePropsAlias } from "./use-props-alias.mjs";
import { computed, watch } from "vue";
//#region ../../packages/components/transfer/src/composables/use-check.ts
const useCheck = (props, panelState, emit) => {
const propsAlias = usePropsAlias(props);
const filteredData = computed(() => {
return props.data.filter((item) => {
if (isFunction(props.filterMethod)) return props.filterMethod(panelState.query, item);
else return String(item[propsAlias.value.label] || item[propsAlias.value.key]).toLowerCase().includes(panelState.query.toLowerCase());
});
});
const checkableData = computed(() => filteredData.value.filter((item) => !item[propsAlias.value.disabled]));
const checkedSummary = computed(() => {
const checkedLength = panelState.checked.length;
const dataLength = props.data.length;
const { noChecked, hasChecked } = props.format;
if (noChecked && hasChecked) return checkedLength > 0 ? hasChecked.replace(/\${checked}/g, checkedLength.toString()).replace(/\${total}/g, dataLength.toString()) : noChecked.replace(/\${total}/g, dataLength.toString());
else return `${checkedLength}/${dataLength}`;
});
const isIndeterminate = computed(() => {
const checkedLength = panelState.checked.length;
return checkedLength > 0 && checkedLength < checkableData.value.length;
});
const updateAllChecked = () => {
const checkableDataKeys = checkableData.value.map((item) => item[propsAlias.value.key]);
panelState.allChecked = checkableDataKeys.length > 0 && checkableDataKeys.every((item) => panelState.checked.includes(item));
};
const handleAllCheckedChange = (value) => {
panelState.checked = value ? checkableData.value.map((item) => item[propsAlias.value.key]) : [];
};
watch(() => panelState.checked, (val, oldVal) => {
updateAllChecked();
if (panelState.checkChangeByUser) emit(CHECKED_CHANGE_EVENT, val, val.concat(oldVal).filter((v) => !val.includes(v) || !oldVal.includes(v)));
else {
emit(CHECKED_CHANGE_EVENT, val);
panelState.checkChangeByUser = true;
}
});
watch(checkableData, () => {
updateAllChecked();
});
watch(() => props.data, () => {
const checked = [];
const filteredDataKeys = filteredData.value.map((item) => item[propsAlias.value.key]);
panelState.checked.forEach((item) => {
if (filteredDataKeys.includes(item)) checked.push(item);
});
panelState.checkChangeByUser = false;
panelState.checked = checked;
});
watch(() => props.defaultChecked, (val, oldVal) => {
if (oldVal && val.length === oldVal.length && val.every((item) => oldVal.includes(item))) return;
const checked = [];
const checkableDataKeys = checkableData.value.map((item) => item[propsAlias.value.key]);
val.forEach((item) => {
if (checkableDataKeys.includes(item)) checked.push(item);
});
panelState.checkChangeByUser = false;
panelState.checked = checked;
}, { immediate: true });
return {
filteredData,
checkableData,
checkedSummary,
isIndeterminate,
updateAllChecked,
handleAllCheckedChange
};
};
//#endregion
export { useCheck };
//# sourceMappingURL=use-check.mjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import { TransferCheckedState, TransferEmits, TransferKey } from "../transfer.js";
import { SetupContext } from "vue";
//#region ../../packages/components/transfer/src/composables/use-checked-change.d.ts
declare const useCheckedChange: (checkedState: TransferCheckedState, emit: SetupContext<TransferEmits>["emit"]) => {
onSourceCheckedChange: (val: TransferKey[], movedKeys?: TransferKey[]) => void;
onTargetCheckedChange: (val: TransferKey[], movedKeys?: TransferKey[]) => void;
};
//#endregion
export { useCheckedChange };

View File

@@ -0,0 +1,22 @@
import { LEFT_CHECK_CHANGE_EVENT, RIGHT_CHECK_CHANGE_EVENT } from "../transfer.mjs";
//#region ../../packages/components/transfer/src/composables/use-checked-change.ts
const useCheckedChange = (checkedState, emit) => {
const onSourceCheckedChange = (val, movedKeys) => {
checkedState.leftChecked = val;
if (!movedKeys) return;
emit(LEFT_CHECK_CHANGE_EVENT, val, movedKeys);
};
const onTargetCheckedChange = (val, movedKeys) => {
checkedState.rightChecked = val;
if (!movedKeys) return;
emit(RIGHT_CHECK_CHANGE_EVENT, val, movedKeys);
};
return {
onSourceCheckedChange,
onTargetCheckedChange
};
};
//#endregion
export { useCheckedChange };
//# sourceMappingURL=use-checked-change.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-checked-change.mjs","names":[],"sources":["../../../../../../../packages/components/transfer/src/composables/use-checked-change.ts"],"sourcesContent":["import { LEFT_CHECK_CHANGE_EVENT, RIGHT_CHECK_CHANGE_EVENT } from '../transfer'\n\nimport type { SetupContext } from 'vue'\nimport type {\n TransferCheckedState,\n TransferEmits,\n TransferKey,\n} from '../transfer'\n\nexport const useCheckedChange = (\n checkedState: TransferCheckedState,\n emit: SetupContext<TransferEmits>['emit']\n) => {\n const onSourceCheckedChange = (\n val: TransferKey[],\n movedKeys?: TransferKey[]\n ) => {\n checkedState.leftChecked = val\n if (!movedKeys) return\n emit(LEFT_CHECK_CHANGE_EVENT, val, movedKeys)\n }\n\n const onTargetCheckedChange = (\n val: TransferKey[],\n movedKeys?: TransferKey[]\n ) => {\n checkedState.rightChecked = val\n if (!movedKeys) return\n emit(RIGHT_CHECK_CHANGE_EVENT, val, movedKeys)\n }\n\n return {\n onSourceCheckedChange,\n onTargetCheckedChange,\n }\n}\n"],"mappings":";;AASA,MAAa,oBACX,cACA,SACG;CACH,MAAM,yBACJ,KACA,cACG;EACH,aAAa,cAAc;EAC3B,IAAI,CAAC,WAAW;EAChB,KAAK,yBAAyB,KAAK,UAAU;;CAG/C,MAAM,yBACJ,KACA,cACG;EACH,aAAa,eAAe;EAC5B,IAAI,CAAC,WAAW;EAChB,KAAK,0BAA0B,KAAK,UAAU;;CAGhD,OAAO;EACL;EACA;EACD"}

View File

@@ -0,0 +1,10 @@
import { TransferDataItem, TransferProps } from "../transfer.js";
import * as _$vue from "vue";
//#region ../../packages/components/transfer/src/composables/use-computed-data.d.ts
declare const useComputedData: <T extends TransferDataItem = TransferDataItem>(props: Required<Omit<TransferProps<T>, "filterPlaceholder" | "filterMethod" | "renderContent">>) => {
sourceData: _$vue.ComputedRef<T[]>;
targetData: _$vue.ComputedRef<T[]>;
};
//#endregion
export { useComputedData };

View File

@@ -0,0 +1,22 @@
import { usePropsAlias } from "./use-props-alias.mjs";
import { computed } from "vue";
//#region ../../packages/components/transfer/src/composables/use-computed-data.ts
const useComputedData = (props) => {
const propsAlias = usePropsAlias(props);
const dataObj = computed(() => props.data.reduce((o, cur) => (o[cur[propsAlias.value.key]] = cur, o), {}));
return {
sourceData: computed(() => props.data.filter((item) => !props.modelValue.includes(item[propsAlias.value.key]))),
targetData: computed(() => {
if (props.targetOrder === "original") return props.data.filter((item) => props.modelValue.includes(item[propsAlias.value.key]));
else return props.modelValue.reduce((arr, cur) => {
const val = dataObj.value[cur];
if (val) arr.push(val);
return arr;
}, []);
})
};
};
//#endregion
export { useComputedData };
//# sourceMappingURL=use-computed-data.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-computed-data.mjs","names":[],"sources":["../../../../../../../packages/components/transfer/src/composables/use-computed-data.ts"],"sourcesContent":["import { computed } from 'vue'\nimport { usePropsAlias } from './use-props-alias'\n\nimport type { TransferDataItem, TransferKey, TransferProps } from '../transfer'\n\nexport const useComputedData = <T extends TransferDataItem = TransferDataItem>(\n props: Required<\n Omit<\n TransferProps<T>,\n 'filterPlaceholder' | 'filterMethod' | 'renderContent'\n >\n >\n) => {\n const propsAlias = usePropsAlias(props)\n\n const dataObj = computed(() =>\n props.data.reduce<Record<string, T>>(\n (o, cur) => ((o[cur[propsAlias.value.key]] = cur), o),\n {}\n )\n )\n\n const sourceData = computed(() =>\n props.data.filter(\n (item) => !props.modelValue.includes(item[propsAlias.value.key])\n )\n )\n\n const targetData = computed(() => {\n if (props.targetOrder === 'original') {\n return props.data.filter((item) =>\n props.modelValue.includes(item[propsAlias.value.key])\n )\n } else {\n return props.modelValue.reduce((arr: T[], cur: TransferKey) => {\n const val = dataObj.value[cur]\n if (val) {\n arr.push(val)\n }\n return arr\n }, [])\n }\n })\n\n return {\n sourceData,\n targetData,\n }\n}\n"],"mappings":";;;AAKA,MAAa,mBACX,UAMG;CACH,MAAM,aAAa,cAAc,MAAM;CAEvC,MAAM,UAAU,eACd,MAAM,KAAK,QACR,GAAG,SAAU,EAAE,IAAI,WAAW,MAAM,QAAQ,KAAM,IACnD,EAAE,CACH,CACF;CAwBD,OAAO;EACL,YAvBiB,eACjB,MAAM,KAAK,QACR,SAAS,CAAC,MAAM,WAAW,SAAS,KAAK,WAAW,MAAM,KAAK,CACjE,CAoBS;EACV,YAlBiB,eAAe;GAChC,IAAI,MAAM,gBAAgB,YACxB,OAAO,MAAM,KAAK,QAAQ,SACxB,MAAM,WAAW,SAAS,KAAK,WAAW,MAAM,KAAK,CACtD;QAED,OAAO,MAAM,WAAW,QAAQ,KAAU,QAAqB;IAC7D,MAAM,MAAM,QAAQ,MAAM;IAC1B,IAAI,KACF,IAAI,KAAK,IAAI;IAEf,OAAO;MACN,EAAE,CAAC;IAME;EACX"}

View File

@@ -0,0 +1,10 @@
import { TransferCheckedState, TransferDataItem, TransferEmits, TransferProps } from "../transfer.js";
import { SetupContext } from "vue";
//#region ../../packages/components/transfer/src/composables/use-move.d.ts
declare const useMove: <T extends TransferDataItem = TransferDataItem>(props: Required<Omit<TransferProps<T>, "filterPlaceholder" | "filterMethod" | "renderContent">>, checkedState: TransferCheckedState, emit: SetupContext<TransferEmits>["emit"]) => {
addToLeft: () => void;
addToRight: () => void;
};
//#endregion
export { useMove };

View File

@@ -0,0 +1,36 @@
import { CHANGE_EVENT, UPDATE_MODEL_EVENT } from "../../../../constants/event.mjs";
import { usePropsAlias } from "./use-props-alias.mjs";
//#region ../../packages/components/transfer/src/composables/use-move.ts
const useMove = (props, checkedState, emit) => {
const propsAlias = usePropsAlias(props);
const _emit = (value, direction, movedKeys) => {
emit(UPDATE_MODEL_EVENT, value);
emit(CHANGE_EVENT, value, direction, movedKeys);
};
const addToLeft = () => {
const currentValue = props.modelValue.slice();
checkedState.rightChecked.forEach((item) => {
const index = currentValue.indexOf(item);
if (index > -1) currentValue.splice(index, 1);
});
_emit(currentValue, "left", checkedState.rightChecked);
};
const addToRight = () => {
let currentValue = props.modelValue.slice();
const itemsToBeMoved = props.data.filter((item) => {
const itemKey = item[propsAlias.value.key];
return checkedState.leftChecked.includes(itemKey) && !props.modelValue.includes(itemKey);
}).map((item) => item[propsAlias.value.key]);
currentValue = props.targetOrder === "unshift" ? itemsToBeMoved.concat(currentValue) : currentValue.concat(itemsToBeMoved);
if (props.targetOrder === "original") currentValue = props.data.filter((item) => currentValue.includes(item[propsAlias.value.key])).map((item) => item[propsAlias.value.key]);
_emit(currentValue, "right", checkedState.leftChecked);
};
return {
addToLeft,
addToRight
};
};
//#endregion
export { useMove };
//# sourceMappingURL=use-move.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-move.mjs","names":[],"sources":["../../../../../../../packages/components/transfer/src/composables/use-move.ts"],"sourcesContent":["import { CHANGE_EVENT, UPDATE_MODEL_EVENT } from '@element-plus/constants'\nimport { usePropsAlias } from './use-props-alias'\n\nimport type { SetupContext } from 'vue'\nimport type {\n TransferCheckedState,\n TransferDataItem,\n TransferDirection,\n TransferEmits,\n TransferKey,\n TransferProps,\n} from '../transfer'\n\nexport const useMove = <T extends TransferDataItem = TransferDataItem>(\n props: Required<\n Omit<\n TransferProps<T>,\n 'filterPlaceholder' | 'filterMethod' | 'renderContent'\n >\n >,\n checkedState: TransferCheckedState,\n emit: SetupContext<TransferEmits>['emit']\n) => {\n const propsAlias = usePropsAlias(props)\n\n const _emit = (\n value: TransferKey[],\n direction: TransferDirection,\n movedKeys: TransferKey[]\n ) => {\n emit(UPDATE_MODEL_EVENT, value)\n emit(CHANGE_EVENT, value, direction, movedKeys)\n }\n\n const addToLeft = () => {\n const currentValue = props.modelValue.slice()\n\n checkedState.rightChecked.forEach((item) => {\n const index = currentValue.indexOf(item)\n if (index > -1) {\n currentValue.splice(index, 1)\n }\n })\n _emit(currentValue, 'left', checkedState.rightChecked)\n }\n\n const addToRight = () => {\n let currentValue = props.modelValue.slice()\n\n const itemsToBeMoved = props.data\n .filter((item) => {\n const itemKey = item[propsAlias.value.key]\n return (\n checkedState.leftChecked.includes(itemKey) &&\n !props.modelValue.includes(itemKey)\n )\n })\n .map((item) => item[propsAlias.value.key])\n\n currentValue =\n props.targetOrder === 'unshift'\n ? itemsToBeMoved.concat(currentValue)\n : currentValue.concat(itemsToBeMoved)\n\n if (props.targetOrder === 'original') {\n currentValue = props.data\n .filter((item) => currentValue.includes(item[propsAlias.value.key]))\n .map((item) => item[propsAlias.value.key])\n }\n\n _emit(currentValue, 'right', checkedState.leftChecked)\n }\n\n return {\n addToLeft,\n addToRight,\n }\n}\n"],"mappings":";;;AAaA,MAAa,WACX,OAMA,cACA,SACG;CACH,MAAM,aAAa,cAAc,MAAM;CAEvC,MAAM,SACJ,OACA,WACA,cACG;EACH,KAAK,oBAAoB,MAAM;EAC/B,KAAK,cAAc,OAAO,WAAW,UAAU;;CAGjD,MAAM,kBAAkB;EACtB,MAAM,eAAe,MAAM,WAAW,OAAO;EAE7C,aAAa,aAAa,SAAS,SAAS;GAC1C,MAAM,QAAQ,aAAa,QAAQ,KAAK;GACxC,IAAI,QAAQ,IACV,aAAa,OAAO,OAAO,EAAE;IAE/B;EACF,MAAM,cAAc,QAAQ,aAAa,aAAa;;CAGxD,MAAM,mBAAmB;EACvB,IAAI,eAAe,MAAM,WAAW,OAAO;EAE3C,MAAM,iBAAiB,MAAM,KAC1B,QAAQ,SAAS;GAChB,MAAM,UAAU,KAAK,WAAW,MAAM;GACtC,OACE,aAAa,YAAY,SAAS,QAAQ,IAC1C,CAAC,MAAM,WAAW,SAAS,QAAQ;IAErC,CACD,KAAK,SAAS,KAAK,WAAW,MAAM,KAAK;EAE5C,eACE,MAAM,gBAAgB,YAClB,eAAe,OAAO,aAAa,GACnC,aAAa,OAAO,eAAe;EAEzC,IAAI,MAAM,gBAAgB,YACxB,eAAe,MAAM,KAClB,QAAQ,SAAS,aAAa,SAAS,KAAK,WAAW,MAAM,KAAK,CAAC,CACnE,KAAK,SAAS,KAAK,WAAW,MAAM,KAAK;EAG9C,MAAM,cAAc,SAAS,aAAa,YAAY;;CAGxD,OAAO;EACL;EACA;EACD"}

View File

@@ -0,0 +1,13 @@
import { TransferPropsAlias } from "../transfer.js";
import * as _$vue from "vue";
//#region ../../packages/components/transfer/src/composables/use-props-alias.d.ts
declare const usePropsAlias: (props: {
props?: TransferPropsAlias;
}) => _$vue.ComputedRef<{
label: string;
key: string;
disabled: string;
}>;
//#endregion
export { usePropsAlias };

View File

@@ -0,0 +1,17 @@
import { computed } from "vue";
//#region ../../packages/components/transfer/src/composables/use-props-alias.ts
const usePropsAlias = (props) => {
const initProps = {
label: "label",
key: "key",
disabled: "disabled"
};
return computed(() => ({
...initProps,
...props.props
}));
};
//#endregion
export { usePropsAlias };
//# sourceMappingURL=use-props-alias.mjs.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-props-alias.mjs","names":[],"sources":["../../../../../../../packages/components/transfer/src/composables/use-props-alias.ts"],"sourcesContent":["import { computed } from 'vue'\n\nimport type { TransferPropsAlias } from '../transfer'\n\nexport const usePropsAlias = (props: { props?: TransferPropsAlias }) => {\n const initProps: Required<TransferPropsAlias> = {\n label: 'label',\n key: 'key',\n disabled: 'disabled',\n }\n\n return computed(() => ({\n ...initProps,\n ...props.props,\n }))\n}\n"],"mappings":";;AAIA,MAAa,iBAAiB,UAA0C;CACtE,MAAM,YAA0C;EAC9C,OAAO;EACP,KAAK;EACL,UAAU;EACX;CAED,OAAO,gBAAgB;EACrB,GAAG;EACH,GAAG,MAAM;EACV,EAAE"}