0701提交本本,包含整体所有子页面
This commit is contained in:
Generated
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
import { Alignment } from "../../../virtual-list/src/types.js";
|
||||
import { ScrollPos, useScrollbar } from "./use-scrollbar.js";
|
||||
import { UseColumnsReturn, useColumns } from "./use-columns.js";
|
||||
import { UseRowReturn, useRow } from "./use-row.js";
|
||||
import { UseDataReturn, useData } from "./use-data.js";
|
||||
import { UseStyleReturn, useStyles } from "./use-styles.js";
|
||||
import { useAutoResize } from "./use-auto-resize.js";
|
||||
export { ScrollPos, Alignment as ScrollStrategy, UseColumnsReturn, UseDataReturn, UseRowReturn, UseStyleReturn, useAutoResize, useColumns, useData, useRow, useScrollbar, useStyles };
|
||||
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_use_columns = require('./use-columns.js');
|
||||
const require_use_scrollbar = require('./use-scrollbar.js');
|
||||
const require_use_row = require('./use-row.js');
|
||||
const require_use_data = require('./use-data.js');
|
||||
const require_use_styles = require('./use-styles.js');
|
||||
const require_use_auto_resize = require('./use-auto-resize.js');
|
||||
|
||||
exports.useAutoResize = require_use_auto_resize.useAutoResize;
|
||||
exports.useColumns = require_use_columns.useColumns;
|
||||
exports.useData = require_use_data.useData;
|
||||
exports.useRow = require_use_row.useRow;
|
||||
exports.useScrollbar = require_use_scrollbar.useScrollbar;
|
||||
exports.useStyles = require_use_styles.useStyles;
|
||||
Generated
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
import { AutoResizerProps } from "../auto-resizer.js";
|
||||
import * as vue from "vue";
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-auto-resize.d.ts
|
||||
declare const useAutoResize: (props: AutoResizerProps) => {
|
||||
sizer: vue.Ref<HTMLElement | undefined, HTMLElement | undefined>;
|
||||
width: vue.Ref<number, number>;
|
||||
height: vue.Ref<number, number>;
|
||||
};
|
||||
//#endregion
|
||||
export { useAutoResize };
|
||||
Generated
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../../../_virtual/_rolldown/runtime.js');
|
||||
let _vueuse_core = require("@vueuse/core");
|
||||
let vue = require("vue");
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-auto-resize.ts
|
||||
const useAutoResize = (props) => {
|
||||
const sizer = (0, vue.ref)();
|
||||
const width$ = (0, vue.ref)(0);
|
||||
const height$ = (0, vue.ref)(0);
|
||||
let resizerStopper;
|
||||
(0, vue.onMounted)(() => {
|
||||
resizerStopper = (0, _vueuse_core.useResizeObserver)(sizer, ([entry]) => {
|
||||
const { width, height } = entry.contentRect;
|
||||
const { paddingLeft, paddingRight, paddingTop, paddingBottom } = getComputedStyle(entry.target);
|
||||
const left = Number.parseInt(paddingLeft) || 0;
|
||||
const right = Number.parseInt(paddingRight) || 0;
|
||||
const top = Number.parseInt(paddingTop) || 0;
|
||||
const bottom = Number.parseInt(paddingBottom) || 0;
|
||||
width$.value = width - left - right;
|
||||
height$.value = height - top - bottom;
|
||||
}).stop;
|
||||
});
|
||||
(0, vue.onBeforeUnmount)(() => {
|
||||
resizerStopper?.();
|
||||
});
|
||||
(0, vue.watch)([width$, height$], ([width, height]) => {
|
||||
props.onResize?.({
|
||||
width,
|
||||
height
|
||||
});
|
||||
});
|
||||
return {
|
||||
sizer,
|
||||
width: width$,
|
||||
height: height$
|
||||
};
|
||||
};
|
||||
|
||||
//#endregion
|
||||
exports.useAutoResize = useAutoResize;
|
||||
//# sourceMappingURL=use-auto-resize.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-auto-resize.js","names":[],"sources":["../../../../../../../packages/components/table-v2/src/composables/use-auto-resize.ts"],"sourcesContent":["import { onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useResizeObserver } from '@vueuse/core'\n\nimport type { AutoResizerProps } from '../auto-resizer'\n\nconst useAutoResize = (props: AutoResizerProps) => {\n const sizer = ref<HTMLElement>()\n const width$ = ref(0)\n const height$ = ref(0)\n\n let resizerStopper: ReturnType<typeof useResizeObserver>['stop']\n onMounted(() => {\n resizerStopper = useResizeObserver(sizer, ([entry]) => {\n const { width, height } = entry.contentRect\n const { paddingLeft, paddingRight, paddingTop, paddingBottom } =\n getComputedStyle(entry.target)\n\n const left = Number.parseInt(paddingLeft) || 0\n const right = Number.parseInt(paddingRight) || 0\n const top = Number.parseInt(paddingTop) || 0\n const bottom = Number.parseInt(paddingBottom) || 0\n\n width$.value = width - left - right\n height$.value = height - top - bottom\n }).stop\n })\n\n onBeforeUnmount(() => {\n resizerStopper?.()\n })\n\n watch([width$, height$], ([width, height]) => {\n props.onResize?.({\n width,\n height,\n })\n })\n\n return {\n sizer,\n width: width$,\n height: height$,\n }\n}\n\nexport { useAutoResize }\n"],"mappings":";;;;;;AAKA,MAAM,iBAAiB,UAA4B;CACjD,MAAM,sBAA0B;CAChC,MAAM,sBAAa,EAAE;CACrB,MAAM,uBAAc,EAAE;CAEtB,IAAI;AACJ,0BAAgB;AACd,uDAAmC,QAAQ,CAAC,WAAW;GACrD,MAAM,EAAE,OAAO,WAAW,MAAM;GAChC,MAAM,EAAE,aAAa,cAAc,YAAY,kBAC7C,iBAAiB,MAAM,OAAO;GAEhC,MAAM,OAAO,OAAO,SAAS,YAAY,IAAI;GAC7C,MAAM,QAAQ,OAAO,SAAS,aAAa,IAAI;GAC/C,MAAM,MAAM,OAAO,SAAS,WAAW,IAAI;GAC3C,MAAM,SAAS,OAAO,SAAS,cAAc,IAAI;AAEjD,UAAO,QAAQ,QAAQ,OAAO;AAC9B,WAAQ,QAAQ,SAAS,MAAM;IAC/B,CAAC;GACH;AAEF,gCAAsB;AACpB,oBAAkB;GAClB;AAEF,gBAAM,CAAC,QAAQ,QAAQ,GAAG,CAAC,OAAO,YAAY;AAC5C,QAAM,WAAW;GACf;GACA;GACD,CAAC;GACF;AAEF,QAAO;EACL;EACA,OAAO;EACP,QAAQ;EACT"}
|
||||
Generated
Vendored
+132
@@ -0,0 +1,132 @@
|
||||
import { Alignment, AnyColumns, CellRenderer, ClassNameGetter, Column, FixedDirection, HeaderCellRenderer, HeaderClassGetter, KeyType } from "../types.js";
|
||||
import { TableV2Props } from "../table.js";
|
||||
import * as vue from "vue";
|
||||
import { CSSProperties, Ref } from "vue";
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-columns.d.ts
|
||||
declare function useColumns(props: TableV2Props, columns: Ref<AnyColumns>, fixed: Ref<boolean>): {
|
||||
columns: vue.ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: Alignment;
|
||||
class?: string | ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
columnsStyles: vue.ComputedRef<Record<KeyType, CSSProperties>>;
|
||||
columnsTotalWidth: vue.ComputedRef<number>;
|
||||
fixedColumnsOnLeft: vue.ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: Alignment;
|
||||
class?: string | ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
fixedColumnsOnRight: vue.ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: Alignment;
|
||||
class?: string | ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
hasFixedColumns: vue.ComputedRef<number>;
|
||||
mainColumns: vue.ComputedRef<AnyColumns>;
|
||||
normalColumns: vue.ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: Alignment;
|
||||
class?: string | ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
visibleColumns: vue.ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: Alignment;
|
||||
class?: string | ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
getColumn: (key: KeyType) => {
|
||||
key: KeyType;
|
||||
align?: Alignment;
|
||||
class?: string | ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: HeaderCellRenderer<any> | undefined;
|
||||
} | undefined;
|
||||
getColumnStyle: (key: KeyType) => CSSProperties;
|
||||
updateColumnWidth: (column: Column<any>, width: number) => void;
|
||||
onColumnSorted: (e: MouseEvent) => void;
|
||||
};
|
||||
type UseColumnsReturn = ReturnType<typeof useColumns>;
|
||||
//#endregion
|
||||
export { UseColumnsReturn, useColumns };
|
||||
Generated
Vendored
+93
@@ -0,0 +1,93 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../../../_virtual/_rolldown/runtime.js');
|
||||
const require_constants = require('../constants.js');
|
||||
const require_private = require('../private.js');
|
||||
const require_utils = require('./utils.js');
|
||||
let vue = require("vue");
|
||||
let _vue_shared = require("@vue/shared");
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-columns.ts
|
||||
function useColumns(props, columns, fixed) {
|
||||
const _columns = (0, vue.computed)(() => (0, vue.unref)(columns).map((column, index) => ({
|
||||
...column,
|
||||
key: column.key ?? column.dataKey ?? index
|
||||
})));
|
||||
const visibleColumns = (0, vue.computed)(() => {
|
||||
return (0, vue.unref)(_columns).filter((column) => !column.hidden);
|
||||
});
|
||||
const fixedColumnsOnLeft = (0, vue.computed)(() => (0, vue.unref)(visibleColumns).filter((column) => column.fixed === "left" || column.fixed === true));
|
||||
const fixedColumnsOnRight = (0, vue.computed)(() => (0, vue.unref)(visibleColumns).filter((column) => column.fixed === "right"));
|
||||
const normalColumns = (0, vue.computed)(() => (0, vue.unref)(visibleColumns).filter((column) => !column.fixed));
|
||||
const mainColumns = (0, vue.computed)(() => {
|
||||
const ret = [];
|
||||
(0, vue.unref)(fixedColumnsOnLeft).forEach((column) => {
|
||||
ret.push({
|
||||
...column,
|
||||
placeholderSign: require_private.placeholderSign
|
||||
});
|
||||
});
|
||||
(0, vue.unref)(normalColumns).forEach((column) => {
|
||||
ret.push(column);
|
||||
});
|
||||
(0, vue.unref)(fixedColumnsOnRight).forEach((column) => {
|
||||
ret.push({
|
||||
...column,
|
||||
placeholderSign: require_private.placeholderSign
|
||||
});
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
const hasFixedColumns = (0, vue.computed)(() => {
|
||||
return (0, vue.unref)(fixedColumnsOnLeft).length || (0, vue.unref)(fixedColumnsOnRight).length;
|
||||
});
|
||||
const columnsStyles = (0, vue.computed)(() => {
|
||||
return (0, vue.unref)(_columns).reduce((style, column) => {
|
||||
style[column.key] = require_utils.calcColumnStyle(column, (0, vue.unref)(fixed), props.fixed);
|
||||
return style;
|
||||
}, {});
|
||||
});
|
||||
const columnsTotalWidth = (0, vue.computed)(() => {
|
||||
return (0, vue.unref)(visibleColumns).reduce((width, column) => width + column.width, 0);
|
||||
});
|
||||
const getColumn = (key) => {
|
||||
return (0, vue.unref)(_columns).find((column) => column.key === key);
|
||||
};
|
||||
const getColumnStyle = (key) => {
|
||||
return (0, vue.unref)(columnsStyles)[key];
|
||||
};
|
||||
const updateColumnWidth = (column, width) => {
|
||||
column.width = width;
|
||||
};
|
||||
function onColumnSorted(e) {
|
||||
const { key } = e.currentTarget.dataset;
|
||||
if (!key) return;
|
||||
const { sortState, sortBy } = props;
|
||||
let order = require_constants.SortOrder.ASC;
|
||||
if ((0, _vue_shared.isObject)(sortState)) order = require_constants.oppositeOrderMap[sortState[key]];
|
||||
else order = require_constants.oppositeOrderMap[sortBy.order];
|
||||
props.onColumnSort?.({
|
||||
column: getColumn(key),
|
||||
key,
|
||||
order
|
||||
});
|
||||
}
|
||||
return {
|
||||
columns: _columns,
|
||||
columnsStyles,
|
||||
columnsTotalWidth,
|
||||
fixedColumnsOnLeft,
|
||||
fixedColumnsOnRight,
|
||||
hasFixedColumns,
|
||||
mainColumns,
|
||||
normalColumns,
|
||||
visibleColumns,
|
||||
getColumn,
|
||||
getColumnStyle,
|
||||
updateColumnWidth,
|
||||
onColumnSorted
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
exports.useColumns = useColumns;
|
||||
//# sourceMappingURL=use-columns.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-columns.js","names":["calcColumnStyle","SortOrder","oppositeOrderMap"],"sources":["../../../../../../../packages/components/table-v2/src/composables/use-columns.ts"],"sourcesContent":["import { computed, unref } from 'vue'\nimport { isObject } from '@element-plus/utils'\nimport { SortOrder, oppositeOrderMap } from '../constants'\nimport { placeholderSign } from '../private'\nimport { calcColumnStyle } from './utils'\n\nimport type { CSSProperties, Ref } from 'vue'\nimport type { TableV2Props } from '../table'\nimport type { AnyColumns, Column, KeyType } from '../types'\n\nfunction useColumns(\n props: TableV2Props,\n columns: Ref<AnyColumns>,\n fixed: Ref<boolean>\n) {\n const _columns = computed(() =>\n unref(columns).map((column, index) => ({\n ...column,\n key: column.key ?? column.dataKey ?? index,\n }))\n )\n\n const visibleColumns = computed(() => {\n return unref(_columns).filter((column) => !column.hidden)\n })\n\n const fixedColumnsOnLeft = computed(() =>\n unref(visibleColumns).filter(\n (column) => column.fixed === 'left' || column.fixed === true\n )\n )\n\n const fixedColumnsOnRight = computed(() =>\n unref(visibleColumns).filter((column) => column.fixed === 'right')\n )\n\n const normalColumns = computed(() =>\n unref(visibleColumns).filter((column) => !column.fixed)\n )\n\n const mainColumns = computed(() => {\n const ret: AnyColumns = []\n\n unref(fixedColumnsOnLeft).forEach((column) => {\n ret.push({\n ...column,\n placeholderSign,\n })\n })\n\n unref(normalColumns).forEach((column) => {\n ret.push(column)\n })\n\n unref(fixedColumnsOnRight).forEach((column) => {\n ret.push({\n ...column,\n placeholderSign,\n })\n })\n\n return ret\n })\n\n const hasFixedColumns = computed(() => {\n return unref(fixedColumnsOnLeft).length || unref(fixedColumnsOnRight).length\n })\n\n const columnsStyles = computed(() => {\n return unref(_columns).reduce<Record<KeyType, CSSProperties>>(\n (style, column) => {\n style[column.key] = calcColumnStyle(column, unref(fixed), props.fixed)\n return style\n },\n {}\n )\n })\n\n const columnsTotalWidth = computed(() => {\n return unref(visibleColumns).reduce(\n (width, column) => width + column.width,\n 0\n )\n })\n\n const getColumn = (key: KeyType) => {\n return unref(_columns).find((column) => column.key === key)\n }\n\n const getColumnStyle = (key: KeyType) => {\n return unref(columnsStyles)[key]\n }\n\n const updateColumnWidth = (column: Column<any>, width: number) => {\n column.width = width\n }\n\n function onColumnSorted(e: MouseEvent) {\n const { key } = (e.currentTarget as HTMLElement).dataset\n if (!key) return\n const { sortState, sortBy } = props\n\n let order = SortOrder.ASC\n\n if (isObject(sortState)) {\n order = oppositeOrderMap[sortState[key]]\n } else {\n order = oppositeOrderMap[sortBy.order]\n }\n\n props.onColumnSort?.({ column: getColumn(key)!, key, order })\n }\n\n return {\n columns: _columns,\n columnsStyles,\n columnsTotalWidth,\n fixedColumnsOnLeft,\n fixedColumnsOnRight,\n hasFixedColumns,\n mainColumns,\n normalColumns,\n visibleColumns,\n\n getColumn,\n getColumnStyle,\n updateColumnWidth,\n onColumnSorted,\n }\n}\n\nexport { useColumns }\nexport type UseColumnsReturn = ReturnType<typeof useColumns>\n"],"mappings":";;;;;;;;;AAUA,SAAS,WACP,OACA,SACA,OACA;CACA,MAAM,kDACE,QAAQ,CAAC,KAAK,QAAQ,WAAW;EACrC,GAAG;EACH,KAAK,OAAO,OAAO,OAAO,WAAW;EACtC,EAAE,CACJ;CAED,MAAM,yCAAgC;AACpC,wBAAa,SAAS,CAAC,QAAQ,WAAW,CAAC,OAAO,OAAO;GACzD;CAEF,MAAM,4DACE,eAAe,CAAC,QACnB,WAAW,OAAO,UAAU,UAAU,OAAO,UAAU,KACzD,CACF;CAED,MAAM,6DACE,eAAe,CAAC,QAAQ,WAAW,OAAO,UAAU,QAAQ,CACnE;CAED,MAAM,uDACE,eAAe,CAAC,QAAQ,WAAW,CAAC,OAAO,MAAM,CACxD;CAED,MAAM,sCAA6B;EACjC,MAAM,MAAkB,EAAE;AAE1B,iBAAM,mBAAmB,CAAC,SAAS,WAAW;AAC5C,OAAI,KAAK;IACP,GAAG;IACH;IACD,CAAC;IACF;AAEF,iBAAM,cAAc,CAAC,SAAS,WAAW;AACvC,OAAI,KAAK,OAAO;IAChB;AAEF,iBAAM,oBAAoB,CAAC,SAAS,WAAW;AAC7C,OAAI,KAAK;IACP,GAAG;IACH;IACD,CAAC;IACF;AAEF,SAAO;GACP;CAEF,MAAM,0CAAiC;AACrC,wBAAa,mBAAmB,CAAC,yBAAgB,oBAAoB,CAAC;GACtE;CAEF,MAAM,wCAA+B;AACnC,wBAAa,SAAS,CAAC,QACpB,OAAO,WAAW;AACjB,SAAM,OAAO,OAAOA,8BAAgB,uBAAc,MAAM,EAAE,MAAM,MAAM;AACtE,UAAO;KAET,EAAE,CACH;GACD;CAEF,MAAM,4CAAmC;AACvC,wBAAa,eAAe,CAAC,QAC1B,OAAO,WAAW,QAAQ,OAAO,OAClC,EACD;GACD;CAEF,MAAM,aAAa,QAAiB;AAClC,wBAAa,SAAS,CAAC,MAAM,WAAW,OAAO,QAAQ,IAAI;;CAG7D,MAAM,kBAAkB,QAAiB;AACvC,wBAAa,cAAc,CAAC;;CAG9B,MAAM,qBAAqB,QAAqB,UAAkB;AAChE,SAAO,QAAQ;;CAGjB,SAAS,eAAe,GAAe;EACrC,MAAM,EAAE,QAAS,EAAE,cAA8B;AACjD,MAAI,CAAC,IAAK;EACV,MAAM,EAAE,WAAW,WAAW;EAE9B,IAAI,QAAQC,4BAAU;AAEtB,gCAAa,UAAU,CACrB,SAAQC,mCAAiB,UAAU;MAEnC,SAAQA,mCAAiB,OAAO;AAGlC,QAAM,eAAe;GAAE,QAAQ,UAAU,IAAI;GAAG;GAAK;GAAO,CAAC;;AAG/D,QAAO;EACL,SAAS;EACT;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACD"}
|
||||
Generated
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import { KeyType } from "../types.js";
|
||||
import { TableV2Props } from "../table.js";
|
||||
import { UseRowReturn } from "./use-row.js";
|
||||
import * as vue from "vue";
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-data.d.ts
|
||||
type UseDataProps = {
|
||||
expandedRowKeys: UseRowReturn['expandedRowKeys'];
|
||||
lastRenderedRowIndex: UseRowReturn['lastRenderedRowIndex'];
|
||||
resetAfterIndex: UseRowReturn['resetAfterIndex'];
|
||||
};
|
||||
declare const useData: (props: TableV2Props, {
|
||||
expandedRowKeys,
|
||||
lastRenderedRowIndex,
|
||||
resetAfterIndex
|
||||
}: UseDataProps) => {
|
||||
data: vue.ComputedRef<any[]>;
|
||||
depthMap: vue.Ref<Record<KeyType, number>, Record<KeyType, number>>;
|
||||
};
|
||||
type UseDataReturn = ReturnType<typeof useData>;
|
||||
//#endregion
|
||||
export { UseDataReturn, useData };
|
||||
Generated
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../../../_virtual/_rolldown/runtime.js');
|
||||
let vue = require("vue");
|
||||
let _vue_shared = require("@vue/shared");
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-data.ts
|
||||
const useData = (props, { expandedRowKeys, lastRenderedRowIndex, resetAfterIndex }) => {
|
||||
const depthMap = (0, vue.ref)({});
|
||||
const flattenedData = (0, vue.computed)(() => {
|
||||
const depths = {};
|
||||
const { data, rowKey } = props;
|
||||
const _expandedRowKeys = (0, vue.unref)(expandedRowKeys);
|
||||
if (!_expandedRowKeys || !_expandedRowKeys.length) return data;
|
||||
const array = [];
|
||||
const keysSet = /* @__PURE__ */ new Set();
|
||||
_expandedRowKeys.forEach((x) => keysSet.add(x));
|
||||
let copy = data.slice();
|
||||
copy.forEach((x) => depths[x[rowKey]] = 0);
|
||||
while (copy.length > 0) {
|
||||
const item = copy.shift();
|
||||
array.push(item);
|
||||
if (keysSet.has(item[rowKey]) && (0, _vue_shared.isArray)(item.children) && item.children.length > 0) {
|
||||
copy = [...item.children, ...copy];
|
||||
item.children.forEach((child) => depths[child[rowKey]] = depths[item[rowKey]] + 1);
|
||||
}
|
||||
}
|
||||
depthMap.value = depths;
|
||||
return array;
|
||||
});
|
||||
const data = (0, vue.computed)(() => {
|
||||
const { data, expandColumnKey } = props;
|
||||
return expandColumnKey ? (0, vue.unref)(flattenedData) : data;
|
||||
});
|
||||
(0, vue.watch)(data, (val, prev) => {
|
||||
if (val !== prev) {
|
||||
lastRenderedRowIndex.value = -1;
|
||||
resetAfterIndex(0, true);
|
||||
}
|
||||
});
|
||||
return {
|
||||
data,
|
||||
depthMap
|
||||
};
|
||||
};
|
||||
|
||||
//#endregion
|
||||
exports.useData = useData;
|
||||
//# sourceMappingURL=use-data.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-data.js","names":[],"sources":["../../../../../../../packages/components/table-v2/src/composables/use-data.ts"],"sourcesContent":["import { computed, ref, unref, watch } from 'vue'\nimport { isArray } from '@element-plus/utils'\n\nimport type { TableV2Props } from '../table'\nimport type { KeyType } from '../types'\nimport type { UseRowReturn } from './use-row'\n\ntype UseDataProps = {\n expandedRowKeys: UseRowReturn['expandedRowKeys']\n lastRenderedRowIndex: UseRowReturn['lastRenderedRowIndex']\n resetAfterIndex: UseRowReturn['resetAfterIndex']\n}\n\nexport const useData = (\n props: TableV2Props,\n { expandedRowKeys, lastRenderedRowIndex, resetAfterIndex }: UseDataProps\n) => {\n const depthMap = ref<Record<KeyType, number>>({})\n\n const flattenedData = computed(() => {\n const depths: Record<KeyType, number> = {}\n const { data, rowKey } = props\n\n const _expandedRowKeys = unref(expandedRowKeys)\n\n if (!_expandedRowKeys || !_expandedRowKeys.length) return data\n\n const array: any[] = []\n const keysSet = new Set()\n _expandedRowKeys.forEach((x) => keysSet.add(x))\n\n let copy: any[] = data.slice()\n copy.forEach((x) => (depths[x[rowKey]] = 0))\n while (copy.length > 0) {\n const item = copy.shift()!\n\n array.push(item)\n if (\n keysSet.has(item[rowKey]) &&\n isArray(item.children) &&\n item.children.length > 0\n ) {\n copy = [...item.children, ...copy]\n item.children.forEach(\n (child: any) => (depths[child[rowKey]] = depths[item[rowKey]] + 1)\n )\n }\n }\n\n depthMap.value = depths\n return array\n })\n\n const data = computed(() => {\n const { data, expandColumnKey } = props\n return expandColumnKey ? unref(flattenedData) : data\n })\n\n watch(data, (val, prev) => {\n if (val !== prev) {\n lastRenderedRowIndex.value = -1\n resetAfterIndex(0, true)\n }\n })\n\n return {\n data,\n depthMap,\n }\n}\n\nexport type UseDataReturn = ReturnType<typeof useData>\n"],"mappings":";;;;;;AAaA,MAAa,WACX,OACA,EAAE,iBAAiB,sBAAsB,sBACtC;CACH,MAAM,wBAAwC,EAAE,CAAC;CAEjD,MAAM,wCAA+B;EACnC,MAAM,SAAkC,EAAE;EAC1C,MAAM,EAAE,MAAM,WAAW;EAEzB,MAAM,kCAAyB,gBAAgB;AAE/C,MAAI,CAAC,oBAAoB,CAAC,iBAAiB,OAAQ,QAAO;EAE1D,MAAM,QAAe,EAAE;EACvB,MAAM,0BAAU,IAAI,KAAK;AACzB,mBAAiB,SAAS,MAAM,QAAQ,IAAI,EAAE,CAAC;EAE/C,IAAI,OAAc,KAAK,OAAO;AAC9B,OAAK,SAAS,MAAO,OAAO,EAAE,WAAW,EAAG;AAC5C,SAAO,KAAK,SAAS,GAAG;GACtB,MAAM,OAAO,KAAK,OAAO;AAEzB,SAAM,KAAK,KAAK;AAChB,OACE,QAAQ,IAAI,KAAK,QAAQ,6BACjB,KAAK,SAAS,IACtB,KAAK,SAAS,SAAS,GACvB;AACA,WAAO,CAAC,GAAG,KAAK,UAAU,GAAG,KAAK;AAClC,SAAK,SAAS,SACX,UAAgB,OAAO,MAAM,WAAW,OAAO,KAAK,WAAW,EACjE;;;AAIL,WAAS,QAAQ;AACjB,SAAO;GACP;CAEF,MAAM,+BAAsB;EAC1B,MAAM,EAAE,MAAM,oBAAoB;AAClC,SAAO,iCAAwB,cAAc,GAAG;GAChD;AAEF,gBAAM,OAAO,KAAK,SAAS;AACzB,MAAI,QAAQ,MAAM;AAChB,wBAAqB,QAAQ;AAC7B,mBAAgB,GAAG,KAAK;;GAE1B;AAEF,QAAO;EACL;EACA;EACD"}
|
||||
Generated
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
import { UseNamespaceReturn } from "../../../../hooks/use-namespace/index.js";
|
||||
import "../../../../hooks/index.js";
|
||||
import { FixedDirection, KeyType } from "../types.js";
|
||||
import { RowExpandParams, RowHeightChangedParams, RowHoverParams } from "../row.js";
|
||||
import { onRowRenderedParams } from "../grid.js";
|
||||
import { TableV2Props } from "../table.js";
|
||||
import { TableGridInstance } from "../table-grid.js";
|
||||
import * as vue from "vue";
|
||||
import { ComponentInternalInstance, Ref, ShallowRef } from "vue";
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-row.d.ts
|
||||
type Heights = Record<KeyType, number>;
|
||||
type GridInstanceRef = Ref<TableGridInstance | undefined>;
|
||||
type UseRowProps = {
|
||||
mainTableRef: GridInstanceRef;
|
||||
leftTableRef: GridInstanceRef;
|
||||
rightTableRef: GridInstanceRef;
|
||||
tableInstance: ComponentInternalInstance;
|
||||
ns: UseNamespaceReturn;
|
||||
isScrolling: ShallowRef<boolean>;
|
||||
};
|
||||
declare const useRow: (props: TableV2Props, {
|
||||
mainTableRef,
|
||||
leftTableRef,
|
||||
rightTableRef,
|
||||
tableInstance,
|
||||
ns,
|
||||
isScrolling
|
||||
}: UseRowProps) => {
|
||||
expandedRowKeys: Ref<KeyType[], KeyType[]>;
|
||||
lastRenderedRowIndex: Ref<number, number>;
|
||||
isDynamic: vue.ComputedRef<boolean>;
|
||||
isResetting: ShallowRef<boolean, boolean>;
|
||||
rowHeights: Ref<Heights, Heights>;
|
||||
resetAfterIndex: (index: number, forceUpdate?: boolean) => void;
|
||||
onRowExpanded: ({
|
||||
expanded,
|
||||
rowData,
|
||||
rowIndex,
|
||||
rowKey
|
||||
}: RowExpandParams) => void;
|
||||
onRowHovered: ({
|
||||
hovered,
|
||||
rowKey
|
||||
}: RowHoverParams) => void;
|
||||
onRowsRendered: (params: onRowRenderedParams) => void;
|
||||
onRowHeightChange: ({
|
||||
rowKey,
|
||||
height,
|
||||
rowIndex
|
||||
}: RowHeightChangedParams, fixedDir: FixedDirection) => void;
|
||||
};
|
||||
type UseRowReturn = ReturnType<typeof useRow>;
|
||||
//#endregion
|
||||
export { UseRowReturn, useRow };
|
||||
Generated
Vendored
+115
@@ -0,0 +1,115 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../../../_virtual/_rolldown/runtime.js');
|
||||
const require_types = require('../../../../utils/types.js');
|
||||
const require_constants = require('../constants.js');
|
||||
let lodash_unified = require("lodash-unified");
|
||||
let vue = require("vue");
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-row.ts
|
||||
const useRow = (props, { mainTableRef, leftTableRef, rightTableRef, tableInstance, ns, isScrolling }) => {
|
||||
const vm = (0, vue.getCurrentInstance)();
|
||||
const { emit } = vm;
|
||||
const isResetting = (0, vue.shallowRef)(false);
|
||||
const expandedRowKeys = (0, vue.ref)(props.defaultExpandedRowKeys || []);
|
||||
const lastRenderedRowIndex = (0, vue.ref)(-1);
|
||||
const resetIndex = (0, vue.shallowRef)(null);
|
||||
const rowHeights = (0, vue.ref)({});
|
||||
const pendingRowHeights = (0, vue.ref)({});
|
||||
const leftTableHeights = (0, vue.shallowRef)({});
|
||||
const mainTableHeights = (0, vue.shallowRef)({});
|
||||
const rightTableHeights = (0, vue.shallowRef)({});
|
||||
const isDynamic = (0, vue.computed)(() => require_types.isNumber(props.estimatedRowHeight));
|
||||
function onRowsRendered(params) {
|
||||
props.onRowsRendered?.(params);
|
||||
if (params.rowCacheEnd > (0, vue.unref)(lastRenderedRowIndex)) lastRenderedRowIndex.value = params.rowCacheEnd;
|
||||
}
|
||||
function onRowHovered({ hovered, rowKey }) {
|
||||
if (isScrolling.value) return;
|
||||
tableInstance.vnode.el.querySelectorAll(`[rowkey="${String(rowKey)}"]`).forEach((row) => {
|
||||
if (hovered) row.classList.add(ns.is("hovered"));
|
||||
else row.classList.remove(ns.is("hovered"));
|
||||
});
|
||||
}
|
||||
function onRowExpanded({ expanded, rowData, rowIndex, rowKey }) {
|
||||
const _expandedRowKeys = [...(0, vue.unref)(expandedRowKeys)];
|
||||
const currentKeyIndex = _expandedRowKeys.indexOf(rowKey);
|
||||
if (expanded) {
|
||||
if (currentKeyIndex === -1) _expandedRowKeys.push(rowKey);
|
||||
} else if (currentKeyIndex > -1) _expandedRowKeys.splice(currentKeyIndex, 1);
|
||||
expandedRowKeys.value = _expandedRowKeys;
|
||||
emit("update:expandedRowKeys", _expandedRowKeys);
|
||||
props.onRowExpand?.({
|
||||
expanded,
|
||||
rowData,
|
||||
rowIndex,
|
||||
rowKey
|
||||
});
|
||||
props.onExpandedRowsChange?.(_expandedRowKeys);
|
||||
if (tableInstance.vnode.el.querySelector(`.${ns.is("hovered")}[rowkey="${String(rowKey)}"]`)) (0, vue.nextTick)(() => onRowHovered({
|
||||
hovered: true,
|
||||
rowKey
|
||||
}));
|
||||
}
|
||||
const flushingRowHeights = (0, lodash_unified.debounce)(() => {
|
||||
isResetting.value = true;
|
||||
rowHeights.value = {
|
||||
...(0, vue.unref)(rowHeights),
|
||||
...(0, vue.unref)(pendingRowHeights)
|
||||
};
|
||||
resetAfterIndex((0, vue.unref)(resetIndex), false);
|
||||
pendingRowHeights.value = {};
|
||||
resetIndex.value = null;
|
||||
mainTableRef.value?.forceUpdate();
|
||||
leftTableRef.value?.forceUpdate();
|
||||
rightTableRef.value?.forceUpdate();
|
||||
vm.proxy?.$forceUpdate();
|
||||
isResetting.value = false;
|
||||
}, 0);
|
||||
function resetAfterIndex(index, forceUpdate = false) {
|
||||
if (!(0, vue.unref)(isDynamic)) return;
|
||||
[
|
||||
mainTableRef,
|
||||
leftTableRef,
|
||||
rightTableRef
|
||||
].forEach((tableRef) => {
|
||||
const table = (0, vue.unref)(tableRef);
|
||||
if (table) table.resetAfterRowIndex(index, forceUpdate);
|
||||
});
|
||||
}
|
||||
function resetHeights(rowKey, height, rowIdx) {
|
||||
const resetIdx = (0, vue.unref)(resetIndex);
|
||||
if (resetIdx === null) resetIndex.value = rowIdx;
|
||||
else if (resetIdx > rowIdx) resetIndex.value = rowIdx;
|
||||
pendingRowHeights.value[rowKey] = height;
|
||||
}
|
||||
function onRowHeightChange({ rowKey, height, rowIndex }, fixedDir) {
|
||||
if (!fixedDir) mainTableHeights.value[rowKey] = height;
|
||||
else if (fixedDir === require_constants.FixedDir.RIGHT) rightTableHeights.value[rowKey] = height;
|
||||
else leftTableHeights.value[rowKey] = height;
|
||||
const maximumHeight = Math.max(...[
|
||||
leftTableHeights,
|
||||
rightTableHeights,
|
||||
mainTableHeights
|
||||
].map((records) => records.value[rowKey] || 0));
|
||||
if ((0, vue.unref)(rowHeights)[rowKey] !== maximumHeight) {
|
||||
resetHeights(rowKey, maximumHeight, rowIndex);
|
||||
flushingRowHeights();
|
||||
}
|
||||
}
|
||||
return {
|
||||
expandedRowKeys,
|
||||
lastRenderedRowIndex,
|
||||
isDynamic,
|
||||
isResetting,
|
||||
rowHeights,
|
||||
resetAfterIndex,
|
||||
onRowExpanded,
|
||||
onRowHovered,
|
||||
onRowsRendered,
|
||||
onRowHeightChange
|
||||
};
|
||||
};
|
||||
|
||||
//#endregion
|
||||
exports.useRow = useRow;
|
||||
//# sourceMappingURL=use-row.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
import { Alignment } from "../../../virtual-list/src/types.js";
|
||||
import "../../../virtual-list/index.js";
|
||||
import { TableV2Props } from "../table.js";
|
||||
import { TableGridInstance } from "../table-grid.js";
|
||||
import { Ref } from "vue";
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-scrollbar.d.ts
|
||||
type ScrollPos = {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
};
|
||||
type GridInstanceRef = Ref<TableGridInstance | undefined>;
|
||||
type UseScrollBarProps = {
|
||||
mainTableRef: GridInstanceRef;
|
||||
leftTableRef: GridInstanceRef;
|
||||
rightTableRef: GridInstanceRef;
|
||||
onMaybeEndReached: () => void;
|
||||
};
|
||||
declare const useScrollbar: (props: TableV2Props, {
|
||||
mainTableRef,
|
||||
leftTableRef,
|
||||
rightTableRef,
|
||||
onMaybeEndReached
|
||||
}: UseScrollBarProps) => {
|
||||
scrollPos: Ref<{
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
}, ScrollPos | {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
}>;
|
||||
scrollTo: (params: ScrollPos) => void;
|
||||
scrollToLeft: (scrollLeft: number) => void;
|
||||
scrollToTop: (scrollTop: number) => void;
|
||||
scrollToRow: (row: number, strategy?: Alignment) => void;
|
||||
onScroll: (params: ScrollPos) => void;
|
||||
onVerticalScroll: ({
|
||||
scrollTop
|
||||
}: ScrollPos) => void;
|
||||
};
|
||||
//#endregion
|
||||
export { ScrollPos, useScrollbar };
|
||||
Generated
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../../../_virtual/_rolldown/runtime.js');
|
||||
let vue = require("vue");
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-scrollbar.ts
|
||||
const useScrollbar = (props, { mainTableRef, leftTableRef, rightTableRef, onMaybeEndReached }) => {
|
||||
const scrollPos = (0, vue.ref)({
|
||||
scrollLeft: 0,
|
||||
scrollTop: 0
|
||||
});
|
||||
function doScroll(params) {
|
||||
const { scrollTop } = params;
|
||||
mainTableRef.value?.scrollTo(params);
|
||||
leftTableRef.value?.scrollToTop(scrollTop);
|
||||
rightTableRef.value?.scrollToTop(scrollTop);
|
||||
}
|
||||
function scrollTo(params) {
|
||||
scrollPos.value = params;
|
||||
doScroll(params);
|
||||
}
|
||||
function scrollToTop(scrollTop) {
|
||||
scrollPos.value.scrollTop = scrollTop;
|
||||
doScroll((0, vue.unref)(scrollPos));
|
||||
}
|
||||
function scrollToLeft(scrollLeft) {
|
||||
scrollPos.value.scrollLeft = scrollLeft;
|
||||
mainTableRef.value?.scrollTo?.((0, vue.unref)(scrollPos));
|
||||
}
|
||||
function onScroll(params) {
|
||||
scrollTo(params);
|
||||
props.onScroll?.(params);
|
||||
}
|
||||
function onVerticalScroll({ scrollTop }) {
|
||||
const { scrollTop: currentScrollTop } = (0, vue.unref)(scrollPos);
|
||||
if (scrollTop !== currentScrollTop) scrollToTop(scrollTop);
|
||||
}
|
||||
function scrollToRow(row, strategy = "auto") {
|
||||
mainTableRef.value?.scrollToRow(row, strategy);
|
||||
}
|
||||
(0, vue.watch)(() => (0, vue.unref)(scrollPos).scrollTop, (cur, prev) => {
|
||||
if (cur > prev) onMaybeEndReached();
|
||||
});
|
||||
return {
|
||||
scrollPos,
|
||||
scrollTo,
|
||||
scrollToLeft,
|
||||
scrollToTop,
|
||||
scrollToRow,
|
||||
onScroll,
|
||||
onVerticalScroll
|
||||
};
|
||||
};
|
||||
|
||||
//#endregion
|
||||
exports.useScrollbar = useScrollbar;
|
||||
//# sourceMappingURL=use-scrollbar.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-scrollbar.js","names":[],"sources":["../../../../../../../packages/components/table-v2/src/composables/use-scrollbar.ts"],"sourcesContent":["import { ref, unref, watch } from 'vue'\n\nimport type { Ref } from 'vue'\nimport type { Alignment as ScrollStrategy } from '@element-plus/components/virtual-list'\nimport type { TableV2Props } from '../table'\nimport type { TableGridInstance } from '../table-grid'\n\nexport type ScrollPos = { scrollLeft: number; scrollTop: number }\ntype GridInstanceRef = Ref<TableGridInstance | undefined>\n\ntype UseScrollBarProps = {\n mainTableRef: GridInstanceRef\n leftTableRef: GridInstanceRef\n rightTableRef: GridInstanceRef\n\n onMaybeEndReached: () => void\n}\n\nexport type { ScrollStrategy }\n\nexport const useScrollbar = (\n props: TableV2Props,\n {\n mainTableRef,\n leftTableRef,\n rightTableRef,\n onMaybeEndReached,\n }: UseScrollBarProps\n) => {\n const scrollPos = ref<ScrollPos>({ scrollLeft: 0, scrollTop: 0 })\n\n function doScroll(params: ScrollPos) {\n const { scrollTop } = params\n\n mainTableRef.value?.scrollTo(params)\n leftTableRef.value?.scrollToTop(scrollTop)\n rightTableRef.value?.scrollToTop(scrollTop)\n }\n\n // methods\n function scrollTo(params: ScrollPos) {\n scrollPos.value = params\n\n doScroll(params)\n }\n\n function scrollToTop(scrollTop: number) {\n scrollPos.value.scrollTop = scrollTop\n\n doScroll(unref(scrollPos))\n }\n\n function scrollToLeft(scrollLeft: number) {\n scrollPos.value.scrollLeft = scrollLeft\n\n mainTableRef.value?.scrollTo?.(unref(scrollPos))\n }\n\n function onScroll(params: ScrollPos) {\n scrollTo(params)\n props.onScroll?.(params)\n }\n\n function onVerticalScroll({ scrollTop }: ScrollPos) {\n const { scrollTop: currentScrollTop } = unref(scrollPos)\n if (scrollTop !== currentScrollTop) scrollToTop(scrollTop)\n }\n\n function scrollToRow(row: number, strategy: ScrollStrategy = 'auto') {\n mainTableRef.value?.scrollToRow(row, strategy)\n }\n\n // When scrollTop changes, maybe reaching the bottom\n watch(\n () => unref(scrollPos).scrollTop,\n (cur, prev) => {\n if (cur > prev) onMaybeEndReached()\n }\n )\n\n return {\n scrollPos,\n\n scrollTo,\n scrollToLeft,\n scrollToTop,\n scrollToRow,\n onScroll,\n onVerticalScroll,\n }\n}\n"],"mappings":";;;;;AAoBA,MAAa,gBACX,OACA,EACE,cACA,cACA,eACA,wBAEC;CACH,MAAM,yBAA2B;EAAE,YAAY;EAAG,WAAW;EAAG,CAAC;CAEjE,SAAS,SAAS,QAAmB;EACnC,MAAM,EAAE,cAAc;AAEtB,eAAa,OAAO,SAAS,OAAO;AACpC,eAAa,OAAO,YAAY,UAAU;AAC1C,gBAAc,OAAO,YAAY,UAAU;;CAI7C,SAAS,SAAS,QAAmB;AACnC,YAAU,QAAQ;AAElB,WAAS,OAAO;;CAGlB,SAAS,YAAY,WAAmB;AACtC,YAAU,MAAM,YAAY;AAE5B,0BAAe,UAAU,CAAC;;CAG5B,SAAS,aAAa,YAAoB;AACxC,YAAU,MAAM,aAAa;AAE7B,eAAa,OAAO,0BAAiB,UAAU,CAAC;;CAGlD,SAAS,SAAS,QAAmB;AACnC,WAAS,OAAO;AAChB,QAAM,WAAW,OAAO;;CAG1B,SAAS,iBAAiB,EAAE,aAAwB;EAClD,MAAM,EAAE,WAAW,oCAA2B,UAAU;AACxD,MAAI,cAAc,iBAAkB,aAAY,UAAU;;CAG5D,SAAS,YAAY,KAAa,WAA2B,QAAQ;AACnE,eAAa,OAAO,YAAY,KAAK,SAAS;;AAIhD,qCACc,UAAU,CAAC,YACtB,KAAK,SAAS;AACb,MAAI,MAAM,KAAM,oBAAmB;GAEtC;AAED,QAAO;EACL;EAEA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
||||
Generated
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
import { TableV2Props } from "../table.js";
|
||||
import { UseColumnsReturn } from "./use-columns.js";
|
||||
import { CSSProperties, ComputedRef } from "vue";
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-styles.d.ts
|
||||
type UseStyleProps = {
|
||||
columnsTotalWidth: UseColumnsReturn['columnsTotalWidth'];
|
||||
fixedColumnsOnLeft: UseColumnsReturn['fixedColumnsOnLeft'];
|
||||
fixedColumnsOnRight: UseColumnsReturn['fixedColumnsOnRight'];
|
||||
rowsHeight: ComputedRef<number>;
|
||||
};
|
||||
declare const useStyles: (props: TableV2Props, {
|
||||
columnsTotalWidth,
|
||||
rowsHeight,
|
||||
fixedColumnsOnLeft,
|
||||
fixedColumnsOnRight
|
||||
}: UseStyleProps) => {
|
||||
bodyWidth: ComputedRef<number>;
|
||||
fixedTableHeight: ComputedRef<number>;
|
||||
mainTableHeight: ComputedRef<number>;
|
||||
leftTableWidth: ComputedRef<number>;
|
||||
rightTableWidth: ComputedRef<number>;
|
||||
windowHeight: ComputedRef<number>;
|
||||
footerHeight: ComputedRef<CSSProperties>;
|
||||
emptyStyle: ComputedRef<CSSProperties>;
|
||||
rootStyle: ComputedRef<CSSProperties>;
|
||||
headerHeight: ComputedRef<number>;
|
||||
};
|
||||
type UseStyleReturn = ReturnType<typeof useStyles>;
|
||||
//#endregion
|
||||
export { UseStyleReturn, useStyles };
|
||||
Generated
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
const require_runtime = require('../../../../_virtual/_rolldown/runtime.js');
|
||||
const require_types = require('../../../../utils/types.js');
|
||||
const require_style = require('../../../../utils/dom/style.js');
|
||||
const require_utils = require('../utils.js');
|
||||
let vue = require("vue");
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/use-styles.ts
|
||||
const useStyles = (props, { columnsTotalWidth, rowsHeight, fixedColumnsOnLeft, fixedColumnsOnRight }) => {
|
||||
const bodyWidth = (0, vue.computed)(() => {
|
||||
const { fixed, width, vScrollbarSize } = props;
|
||||
const ret = width - vScrollbarSize;
|
||||
return fixed ? Math.max(Math.round((0, vue.unref)(columnsTotalWidth)), ret) : ret;
|
||||
});
|
||||
const mainTableHeight = (0, vue.computed)(() => {
|
||||
const { height = 0, maxHeight = 0, footerHeight, hScrollbarSize } = props;
|
||||
if (maxHeight > 0) {
|
||||
const _fixedRowsHeight = (0, vue.unref)(fixedRowsHeight);
|
||||
const _rowsHeight = (0, vue.unref)(rowsHeight);
|
||||
const total = (0, vue.unref)(headerHeight) + _fixedRowsHeight + _rowsHeight + hScrollbarSize;
|
||||
return Math.min(total, maxHeight - footerHeight);
|
||||
}
|
||||
return height - footerHeight;
|
||||
});
|
||||
const fixedTableHeight = (0, vue.computed)(() => {
|
||||
const { maxHeight } = props;
|
||||
const tableHeight = (0, vue.unref)(mainTableHeight);
|
||||
if (require_types.isNumber(maxHeight) && maxHeight > 0) return tableHeight;
|
||||
const totalHeight = (0, vue.unref)(rowsHeight) + (0, vue.unref)(headerHeight) + (0, vue.unref)(fixedRowsHeight);
|
||||
return Math.min(tableHeight, totalHeight);
|
||||
});
|
||||
const mapColumn = (column) => column.width;
|
||||
const leftTableWidth = (0, vue.computed)(() => require_utils.sum((0, vue.unref)(fixedColumnsOnLeft).map(mapColumn)));
|
||||
const rightTableWidth = (0, vue.computed)(() => require_utils.sum((0, vue.unref)(fixedColumnsOnRight).map(mapColumn)));
|
||||
const headerHeight = (0, vue.computed)(() => require_utils.sum(props.headerHeight));
|
||||
const fixedRowsHeight = (0, vue.computed)(() => {
|
||||
return (props.fixedData?.length || 0) * props.rowHeight;
|
||||
});
|
||||
const windowHeight = (0, vue.computed)(() => {
|
||||
return (0, vue.unref)(mainTableHeight) - (0, vue.unref)(headerHeight) - (0, vue.unref)(fixedRowsHeight);
|
||||
});
|
||||
const rootStyle = (0, vue.computed)(() => {
|
||||
const { style = {}, height, width } = props;
|
||||
return require_utils.enforceUnit({
|
||||
...style,
|
||||
height,
|
||||
width
|
||||
});
|
||||
});
|
||||
return {
|
||||
bodyWidth,
|
||||
fixedTableHeight,
|
||||
mainTableHeight,
|
||||
leftTableWidth,
|
||||
rightTableWidth,
|
||||
windowHeight,
|
||||
footerHeight: (0, vue.computed)(() => require_utils.enforceUnit({ height: props.footerHeight })),
|
||||
emptyStyle: (0, vue.computed)(() => ({
|
||||
top: require_style.addUnit((0, vue.unref)(headerHeight)),
|
||||
bottom: require_style.addUnit(props.footerHeight),
|
||||
width: require_style.addUnit(props.width)
|
||||
})),
|
||||
rootStyle,
|
||||
headerHeight
|
||||
};
|
||||
};
|
||||
|
||||
//#endregion
|
||||
exports.useStyles = useStyles;
|
||||
//# sourceMappingURL=use-styles.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-styles.js","names":["isNumber","sum","enforceUnit","addUnit"],"sources":["../../../../../../../packages/components/table-v2/src/composables/use-styles.ts"],"sourcesContent":["import { computed, unref } from 'vue'\nimport { addUnit, isNumber } from '@element-plus/utils'\nimport { enforceUnit, sum } from '../utils'\n\nimport type { CSSProperties, ComputedRef } from 'vue'\nimport type { TableV2Props } from '../table'\nimport type { UseColumnsReturn } from './use-columns'\n\ntype UseStyleProps = {\n columnsTotalWidth: UseColumnsReturn['columnsTotalWidth']\n fixedColumnsOnLeft: UseColumnsReturn['fixedColumnsOnLeft']\n fixedColumnsOnRight: UseColumnsReturn['fixedColumnsOnRight']\n rowsHeight: ComputedRef<number>\n}\n\nexport const useStyles = (\n props: TableV2Props,\n {\n columnsTotalWidth,\n rowsHeight,\n fixedColumnsOnLeft,\n fixedColumnsOnRight,\n }: UseStyleProps\n) => {\n const bodyWidth = computed(() => {\n const { fixed, width, vScrollbarSize } = props\n const ret = width - vScrollbarSize\n return fixed ? Math.max(Math.round(unref(columnsTotalWidth)), ret) : ret\n })\n\n const mainTableHeight = computed(() => {\n const { height = 0, maxHeight = 0, footerHeight, hScrollbarSize } = props\n\n if (maxHeight > 0) {\n const _fixedRowsHeight = unref(fixedRowsHeight)\n const _rowsHeight = unref(rowsHeight)\n const _headerHeight = unref(headerHeight)\n const total =\n _headerHeight + _fixedRowsHeight + _rowsHeight + hScrollbarSize\n\n return Math.min(total, maxHeight - footerHeight)\n }\n\n return height - footerHeight\n })\n\n const fixedTableHeight = computed(() => {\n const { maxHeight } = props\n const tableHeight = unref(mainTableHeight)\n if (isNumber(maxHeight) && maxHeight > 0) return tableHeight\n\n const totalHeight =\n unref(rowsHeight) + unref(headerHeight) + unref(fixedRowsHeight)\n\n return Math.min(tableHeight, totalHeight)\n })\n\n const mapColumn = (column: TableV2Props['columns'][number]) => column.width\n\n const leftTableWidth = computed(() =>\n sum(unref(fixedColumnsOnLeft).map(mapColumn))\n )\n\n const rightTableWidth = computed(() =>\n sum(unref(fixedColumnsOnRight).map(mapColumn))\n )\n\n const headerHeight = computed(() => sum(props.headerHeight))\n\n const fixedRowsHeight = computed(() => {\n return (props.fixedData?.length || 0) * props.rowHeight\n })\n\n const windowHeight = computed(() => {\n return unref(mainTableHeight) - unref(headerHeight) - unref(fixedRowsHeight)\n })\n\n const rootStyle = computed<CSSProperties>(() => {\n const { style = {}, height, width } = props\n return enforceUnit({\n ...style,\n height,\n width,\n })\n })\n\n const footerHeight = computed(() =>\n enforceUnit({ height: props.footerHeight })\n )\n\n const emptyStyle = computed<CSSProperties>(() => ({\n top: addUnit(unref(headerHeight)),\n bottom: addUnit(props.footerHeight),\n width: addUnit(props.width),\n }))\n\n return {\n bodyWidth,\n fixedTableHeight,\n mainTableHeight,\n leftTableWidth,\n rightTableWidth,\n windowHeight,\n footerHeight,\n emptyStyle,\n rootStyle,\n headerHeight,\n }\n}\n\nexport type UseStyleReturn = ReturnType<typeof useStyles>\n"],"mappings":";;;;;;;;AAeA,MAAa,aACX,OACA,EACE,mBACA,YACA,oBACA,0BAEC;CACH,MAAM,oCAA2B;EAC/B,MAAM,EAAE,OAAO,OAAO,mBAAmB;EACzC,MAAM,MAAM,QAAQ;AACpB,SAAO,QAAQ,KAAK,IAAI,KAAK,qBAAY,kBAAkB,CAAC,EAAE,IAAI,GAAG;GACrE;CAEF,MAAM,0CAAiC;EACrC,MAAM,EAAE,SAAS,GAAG,YAAY,GAAG,cAAc,mBAAmB;AAEpE,MAAI,YAAY,GAAG;GACjB,MAAM,kCAAyB,gBAAgB;GAC/C,MAAM,6BAAoB,WAAW;GAErC,MAAM,uBADsB,aAAa,GAEvB,mBAAmB,cAAc;AAEnD,UAAO,KAAK,IAAI,OAAO,YAAY,aAAa;;AAGlD,SAAO,SAAS;GAChB;CAEF,MAAM,2CAAkC;EACtC,MAAM,EAAE,cAAc;EACtB,MAAM,6BAAoB,gBAAgB;AAC1C,MAAIA,uBAAS,UAAU,IAAI,YAAY,EAAG,QAAO;EAEjD,MAAM,6BACE,WAAW,kBAAS,aAAa,kBAAS,gBAAgB;AAElE,SAAO,KAAK,IAAI,aAAa,YAAY;GACzC;CAEF,MAAM,aAAa,WAA4C,OAAO;CAEtE,MAAM,yCACJC,iCAAU,mBAAmB,CAAC,IAAI,UAAU,CAAC,CAC9C;CAED,MAAM,0CACJA,iCAAU,oBAAoB,CAAC,IAAI,UAAU,CAAC,CAC/C;CAED,MAAM,uCAA8BA,kBAAI,MAAM,aAAa,CAAC;CAE5D,MAAM,0CAAiC;AACrC,UAAQ,MAAM,WAAW,UAAU,KAAK,MAAM;GAC9C;CAEF,MAAM,uCAA8B;AAClC,wBAAa,gBAAgB,kBAAS,aAAa,kBAAS,gBAAgB;GAC5E;CAEF,MAAM,oCAA0C;EAC9C,MAAM,EAAE,QAAQ,EAAE,EAAE,QAAQ,UAAU;AACtC,SAAOC,0BAAY;GACjB,GAAG;GACH;GACA;GACD,CAAC;GACF;AAYF,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA,sCAhBAA,0BAAY,EAAE,QAAQ,MAAM,cAAc,CAAC,CAC5C;EAgBC,qCAdgD;GAChD,KAAKC,qCAAc,aAAa,CAAC;GACjC,QAAQA,sBAAQ,MAAM,aAAa;GACnC,OAAOA,sBAAQ,MAAM,MAAM;GAC5B,EAAE;EAWD;EACA;EACD"}
|
||||
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
|
||||
//#region ../../packages/components/table-v2/src/composables/utils.ts
|
||||
const calcColumnStyle = (column, fixedColumn, fixed) => {
|
||||
const flex = {
|
||||
flexGrow: 0,
|
||||
flexShrink: 0,
|
||||
...fixed ? {} : {
|
||||
flexGrow: column.flexGrow ?? 0,
|
||||
flexShrink: column.flexShrink ?? 1
|
||||
}
|
||||
};
|
||||
const style = {
|
||||
...column.style ?? {},
|
||||
...flex,
|
||||
flexBasis: "auto",
|
||||
width: column.width
|
||||
};
|
||||
if (!fixedColumn) {
|
||||
if (column.maxWidth) style.maxWidth = column.maxWidth;
|
||||
if (column.minWidth) style.minWidth = column.minWidth;
|
||||
}
|
||||
return style;
|
||||
};
|
||||
|
||||
//#endregion
|
||||
exports.calcColumnStyle = calcColumnStyle;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","names":[],"sources":["../../../../../../../packages/components/table-v2/src/composables/utils.ts"],"sourcesContent":["import type { CSSProperties } from 'vue'\nimport type { AnyColumns } from '../types'\n\nexport const calcColumnStyle = (\n column: AnyColumns[number],\n fixedColumn: boolean,\n fixed: boolean\n): CSSProperties => {\n const flex = {\n flexGrow: 0,\n flexShrink: 0,\n ...(fixed\n ? {}\n : {\n flexGrow: column.flexGrow ?? 0,\n flexShrink: column.flexShrink ?? 1,\n }),\n }\n\n const style = {\n ...(column.style ?? {}),\n ...flex,\n flexBasis: 'auto',\n width: column.width,\n }\n\n if (!fixedColumn) {\n if (column.maxWidth) style.maxWidth = column.maxWidth\n if (column.minWidth) style.minWidth = column.minWidth\n }\n\n return style\n}\n"],"mappings":";;;AAGA,MAAa,mBACX,QACA,aACA,UACkB;CAClB,MAAM,OAAO;EACX,UAAU;EACV,YAAY;EACZ,GAAI,QACA,EAAE,GACF;GACE,UAAU,OAAO,YAAY;GAC7B,YAAY,OAAO,cAAc;GAClC;EACN;CAED,MAAM,QAAQ;EACZ,GAAI,OAAO,SAAS,EAAE;EACtB,GAAG;EACH,WAAW;EACX,OAAO,OAAO;EACf;AAED,KAAI,CAAC,aAAa;AAChB,MAAI,OAAO,SAAU,OAAM,WAAW,OAAO;AAC7C,MAAI,OAAO,SAAU,OAAM,WAAW,OAAO;;AAG/C,QAAO"}
|
||||
Reference in New Issue
Block a user