前端初始化

This commit is contained in:
“hsc”
2026-08-21 15:36:24 +08:00
commit e4d8ecde13
14411 changed files with 2275932 additions and 0 deletions
@@ -0,0 +1,85 @@
import { TableColumnCtx } from "../table-column/defaults.js";
import { Store } from "../store/index.js";
import TableLayout from "../table-layout.js";
import { DefaultRow, Sort, SummaryMethod } from "../table/defaults.js";
import * as _$vue from "vue";
import { PropType } from "vue";
//#region ../../packages/components/table/src/table-footer/index.d.ts
interface TableFooter<T extends DefaultRow> {
fixed: string;
store: Store<T>;
summaryMethod: SummaryMethod<T>;
sumText: string;
border: boolean;
defaultSort: Sort;
}
declare const _default: _$vue.DefineComponent<_$vue.ExtractPropTypes<{
fixed: {
type: StringConstructor;
default: string;
};
store: {
required: true;
type: PropType<TableFooter<any>["store"]>;
};
summaryMethod: PropType<TableFooter<any>["summaryMethod"]>;
sumText: StringConstructor;
border: BooleanConstructor;
defaultSort: {
type: PropType<TableFooter<any>["defaultSort"]>;
default: () => {
prop: string;
order: string;
};
};
}>, {
ns: {
namespace: _$vue.ComputedRef<string>;
b: (blockSuffix?: string) => string;
e: (element?: string) => string;
m: (modifier?: string) => string;
be: (blockSuffix?: string, element?: string) => string;
em: (element?: string, modifier?: string) => string;
bm: (blockSuffix?: string, modifier?: string) => string;
bem: (blockSuffix?: string, element?: string, modifier?: string) => string;
is: {
(name: string, state: boolean | undefined): string;
(name: string): string;
};
cssVar: (object: Record<string, string>) => Record<string, string>;
cssVarName: (name: string) => string;
cssVarBlock: (object: Record<string, string>) => Record<string, string>;
cssVarBlockName: (name: string) => string;
};
onScrollableChange: (layout: TableLayout<any>) => void;
onColumnsChange: (layout: TableLayout<any>) => void;
getCellClasses: (columns: TableColumnCtx<any>[], cellIndex: number) => string[];
getCellStyles: (column: TableColumnCtx<any>, cellIndex: number) => _$vue.CSSProperties | undefined;
columns: _$vue.ComputedRef<TableColumnCtx<DefaultRow>[]>;
}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, string, _$vue.PublicProps, Readonly<_$vue.ExtractPropTypes<{
fixed: {
type: StringConstructor;
default: string;
};
store: {
required: true;
type: PropType<TableFooter<any>["store"]>;
};
summaryMethod: PropType<TableFooter<any>["summaryMethod"]>;
sumText: StringConstructor;
border: BooleanConstructor;
defaultSort: {
type: PropType<TableFooter<any>["defaultSort"]>;
default: () => {
prop: string;
order: string;
};
};
}>> & Readonly<{}>, {
fixed: string;
border: boolean;
defaultSort: Sort;
}, {}, {}, {}, string, _$vue.ComponentProvideOptions, true, {}, any>;
//#endregion
export { TableFooter, _default as default };
@@ -0,0 +1,88 @@
import { useNamespace } from "../../../../hooks/use-namespace/index.mjs";
import useLayoutObserver from "../layout-observer.mjs";
import { TABLE_INJECTION_KEY } from "../tokens.mjs";
import useStyle from "./style-helper.mjs";
import { defineComponent, h, inject } from "vue";
//#region ../../packages/components/table/src/table-footer/index.ts
var table_footer_default = defineComponent({
name: "ElTableFooter",
props: {
fixed: {
type: String,
default: ""
},
store: {
required: true,
type: Object
},
summaryMethod: Function,
sumText: String,
border: Boolean,
defaultSort: {
type: Object,
default: () => {
return {
prop: "",
order: ""
};
}
}
},
setup(props) {
const parent = inject(TABLE_INJECTION_KEY);
const ns = useNamespace("table");
const { getCellClasses, getCellStyles, columns } = useStyle(props);
const { onScrollableChange, onColumnsChange } = useLayoutObserver(parent);
return {
ns,
onScrollableChange,
onColumnsChange,
getCellClasses,
getCellStyles,
columns
};
},
render() {
const { columns, getCellStyles, getCellClasses, summaryMethod, sumText } = this;
const data = this.store.states.data.value;
let sums = [];
if (summaryMethod) sums = summaryMethod({
columns,
data
});
else columns.forEach((column, index) => {
if (index === 0) {
sums[index] = sumText;
return;
}
const values = data.map((item) => Number(item[column.property]));
const precisions = [];
let notNumber = true;
values.forEach((value) => {
if (!Number.isNaN(+value)) {
notNumber = false;
const decimal = `${value}`.split(".")[1];
precisions.push(decimal ? decimal.length : 0);
}
});
const precision = Math.max.apply(null, precisions);
if (!notNumber) sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!Number.isNaN(+value)) return Number.parseFloat((prev + curr).toFixed(Math.min(precision, 20)));
else return prev;
}, 0);
else sums[index] = "";
});
return h(h("tfoot", [h("tr", {}, [...columns.map((column, cellIndex) => h("td", {
key: cellIndex,
colspan: column.colSpan,
rowspan: column.rowSpan,
class: getCellClasses(columns, cellIndex),
style: getCellStyles(column, cellIndex)
}, [h("div", { class: ["cell", column.labelClassName] }, [sums[cellIndex]])]))])]));
}
});
//#endregion
export { table_footer_default as default };
//# sourceMappingURL=index.mjs.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
import { TableColumnCtx } from "../table-column/defaults.js";
import { DefaultRow } from "../table/defaults.js";
import * as _$vue from "vue";
//#region ../../packages/components/table/src/table-footer/mapState-helper.d.ts
declare function useMapState(): {
leftFixedLeafCount: _$vue.ComputedRef<number>;
rightFixedLeafCount: _$vue.ComputedRef<number>;
columnsCount: _$vue.ComputedRef<number>;
leftFixedCount: _$vue.ComputedRef<number>;
rightFixedCount: _$vue.ComputedRef<number>;
columns: _$vue.ComputedRef<TableColumnCtx<DefaultRow>[]>;
};
//#endregion
export { useMapState as default };
@@ -0,0 +1,28 @@
import { TABLE_INJECTION_KEY } from "../tokens.mjs";
import { computed, inject } from "vue";
//#region ../../packages/components/table/src/table-footer/mapState-helper.ts
function useMapState() {
const store = inject(TABLE_INJECTION_KEY)?.store;
return {
leftFixedLeafCount: computed(() => {
return store?.states.fixedLeafColumnsLength.value ?? 0;
}),
rightFixedLeafCount: computed(() => {
return store?.states.rightFixedColumns.value.length ?? 0;
}),
columnsCount: computed(() => {
return store?.states.columns.value.length ?? 0;
}),
leftFixedCount: computed(() => {
return store?.states.fixedColumns.value.length ?? 0;
}),
rightFixedCount: computed(() => {
return store?.states.rightFixedColumns.value.length ?? 0;
}),
columns: computed(() => store?.states.columns.value ?? [])
};
}
//#endregion
export { useMapState as default };
//# sourceMappingURL=mapState-helper.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"mapState-helper.mjs","names":[],"sources":["../../../../../../../packages/components/table/src/table-footer/mapState-helper.ts"],"sourcesContent":["import { computed, inject } from 'vue'\nimport { TABLE_INJECTION_KEY } from '../tokens'\n\nfunction useMapState() {\n const table = inject(TABLE_INJECTION_KEY)\n const store = table?.store\n const leftFixedLeafCount = computed(() => {\n return store?.states.fixedLeafColumnsLength.value ?? 0\n })\n const rightFixedLeafCount = computed(() => {\n return store?.states.rightFixedColumns.value.length ?? 0\n })\n const columnsCount = computed(() => {\n return store?.states.columns.value.length ?? 0\n })\n const leftFixedCount = computed(() => {\n return store?.states.fixedColumns.value.length ?? 0\n })\n const rightFixedCount = computed(() => {\n return store?.states.rightFixedColumns.value.length ?? 0\n })\n\n return {\n leftFixedLeafCount,\n rightFixedLeafCount,\n columnsCount,\n leftFixedCount,\n rightFixedCount,\n columns: computed(() => store?.states.columns.value ?? []),\n }\n}\n\nexport default useMapState\n"],"mappings":";;;AAGA,SAAS,cAAc;CAErB,MAAM,QADQ,OAAO,oBACF,EAAE;CAiBrB,OAAO;EACL,oBAjByB,eAAe;GACxC,OAAO,OAAO,OAAO,uBAAuB,SAAS;IAgBnC;EAClB,qBAf0B,eAAe;GACzC,OAAO,OAAO,OAAO,kBAAkB,MAAM,UAAU;IAcpC;EACnB,cAbmB,eAAe;GAClC,OAAO,OAAO,OAAO,QAAQ,MAAM,UAAU;IAYjC;EACZ,gBAXqB,eAAe;GACpC,OAAO,OAAO,OAAO,aAAa,MAAM,UAAU;IAUpC;EACd,iBATsB,eAAe;GACrC,OAAO,OAAO,OAAO,kBAAkB,MAAM,UAAU;IAQxC;EACf,SAAS,eAAe,OAAO,OAAO,QAAQ,SAAS,EAAE,CAAC;EAC3D"}
@@ -0,0 +1,13 @@
import { TableColumnCtx } from "../table-column/defaults.js";
import { DefaultRow } from "../table/defaults.js";
import { TableFooter } from "./index.js";
import * as _$vue from "vue";
//#region ../../packages/components/table/src/table-footer/style-helper.d.ts
declare function useStyle<T extends DefaultRow>(props: TableFooter<T>): {
getCellClasses: (columns: TableColumnCtx<T>[], cellIndex: number) => string[];
getCellStyles: (column: TableColumnCtx<T>, cellIndex: number) => _$vue.CSSProperties | undefined;
columns: _$vue.ComputedRef<TableColumnCtx<DefaultRow>[]>;
};
//#endregion
export { useStyle as default };
@@ -0,0 +1,36 @@
import { useNamespace } from "../../../../hooks/use-namespace/index.mjs";
import { ensurePosition, getFixedColumnOffset, getFixedColumnsClass } from "../util.mjs";
import useMapState from "./mapState-helper.mjs";
//#region ../../packages/components/table/src/table-footer/style-helper.ts
function useStyle(props) {
const { columns } = useMapState();
const ns = useNamespace("table");
const getCellClasses = (columns, cellIndex) => {
const column = columns[cellIndex];
const classes = [
ns.e("cell"),
column.id,
column.align,
column.labelClassName,
...getFixedColumnsClass(ns.b(), cellIndex, column.fixed, props.store)
];
if (column.className) classes.push(column.className);
if (!column.children) classes.push(ns.is("leaf"));
return classes;
};
const getCellStyles = (column, cellIndex) => {
const fixedStyle = getFixedColumnOffset(cellIndex, column.fixed, props.store);
ensurePosition(fixedStyle, "left");
ensurePosition(fixedStyle, "right");
return fixedStyle;
};
return {
getCellClasses,
getCellStyles,
columns
};
}
//#endregion
export { useStyle as default };
//# sourceMappingURL=style-helper.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"style-helper.mjs","names":[],"sources":["../../../../../../../packages/components/table/src/table-footer/style-helper.ts"],"sourcesContent":["import { useNamespace } from '@element-plus/hooks'\nimport {\n ensurePosition,\n getFixedColumnOffset,\n getFixedColumnsClass,\n} from '../util'\nimport useMapState from './mapState-helper'\n\nimport type { TableColumnCtx } from '../table-column/defaults'\nimport type { DefaultRow } from '../table/defaults'\nimport type { TableFooter } from '.'\n\nfunction useStyle<T extends DefaultRow>(props: TableFooter<T>) {\n const { columns } = useMapState()\n const ns = useNamespace('table')\n\n const getCellClasses = (columns: TableColumnCtx<T>[], cellIndex: number) => {\n const column = columns[cellIndex]\n const classes = [\n ns.e('cell'),\n column.id,\n column.align,\n column.labelClassName,\n ...getFixedColumnsClass(ns.b(), cellIndex, column.fixed, props.store),\n ]\n if (column.className) {\n classes.push(column.className)\n }\n if (!column.children) {\n classes.push(ns.is('leaf'))\n }\n return classes\n }\n\n const getCellStyles = (column: TableColumnCtx<T>, cellIndex: number) => {\n const fixedStyle = getFixedColumnOffset(\n cellIndex,\n column.fixed,\n props.store\n )\n ensurePosition(fixedStyle, 'left')\n ensurePosition(fixedStyle, 'right')\n return fixedStyle\n }\n\n return {\n getCellClasses,\n getCellStyles,\n columns,\n }\n}\n\nexport default useStyle\n"],"mappings":";;;;AAYA,SAAS,SAA+B,OAAuB;CAC7D,MAAM,EAAE,YAAY,aAAa;CACjC,MAAM,KAAK,aAAa,QAAQ;CAEhC,MAAM,kBAAkB,SAA8B,cAAsB;EAC1E,MAAM,SAAS,QAAQ;EACvB,MAAM,UAAU;GACd,GAAG,EAAE,OAAO;GACZ,OAAO;GACP,OAAO;GACP,OAAO;GACP,GAAG,qBAAqB,GAAG,GAAG,EAAE,WAAW,OAAO,OAAO,MAAM,MAAM;GACtE;EACD,IAAI,OAAO,WACT,QAAQ,KAAK,OAAO,UAAU;EAEhC,IAAI,CAAC,OAAO,UACV,QAAQ,KAAK,GAAG,GAAG,OAAO,CAAC;EAE7B,OAAO;;CAGT,MAAM,iBAAiB,QAA2B,cAAsB;EACtE,MAAM,aAAa,qBACjB,WACA,OAAO,OACP,MAAM,MACP;EACD,eAAe,YAAY,OAAO;EAClC,eAAe,YAAY,QAAQ;EACnC,OAAO;;CAGT,OAAO;EACL;EACA;EACA;EACD"}