增加admin管理帐号和项目的界面--初步实现
This commit is contained in:
Generated
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
export * from './use-columns';
|
||||
export * from './use-scrollbar';
|
||||
export * from './use-row';
|
||||
export * from './use-data';
|
||||
export * from './use-styles';
|
||||
export * from './use-auto-resize';
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var useColumns = require('./use-columns.js');
|
||||
var useScrollbar = require('./use-scrollbar.js');
|
||||
var useRow = require('./use-row.js');
|
||||
var useData = require('./use-data.js');
|
||||
var useStyles = require('./use-styles.js');
|
||||
var useAutoResize = require('./use-auto-resize.js');
|
||||
|
||||
|
||||
|
||||
exports.useColumns = useColumns.useColumns;
|
||||
exports.useScrollbar = useScrollbar.useScrollbar;
|
||||
exports.useRow = useRow.useRow;
|
||||
exports.useData = useData.useData;
|
||||
exports.useStyles = useStyles.useStyles;
|
||||
exports.useAutoResize = useAutoResize.useAutoResize;
|
||||
//# sourceMappingURL=index.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import type { AutoResizerProps } from '../auto-resizer';
|
||||
declare const useAutoResize: (props: AutoResizerProps) => {
|
||||
sizer: import("vue").Ref<HTMLElement | undefined>;
|
||||
width: import("vue").Ref<number>;
|
||||
height: import("vue").Ref<number>;
|
||||
};
|
||||
export { useAutoResize };
|
||||
Generated
Vendored
+43
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var core = require('@vueuse/core');
|
||||
|
||||
const useAutoResize = (props) => {
|
||||
const sizer = vue.ref();
|
||||
const width$ = vue.ref(0);
|
||||
const height$ = vue.ref(0);
|
||||
let resizerStopper;
|
||||
vue.onMounted(() => {
|
||||
resizerStopper = 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;
|
||||
});
|
||||
vue.onBeforeUnmount(() => {
|
||||
resizerStopper == null ? void 0 : resizerStopper();
|
||||
});
|
||||
vue.watch([width$, height$], ([width, height]) => {
|
||||
var _a;
|
||||
(_a = props.onResize) == null ? void 0 : _a.call(props, {
|
||||
width,
|
||||
height
|
||||
});
|
||||
});
|
||||
return {
|
||||
sizer,
|
||||
width: width$,
|
||||
height: height$
|
||||
};
|
||||
};
|
||||
|
||||
exports.useAutoResize = useAutoResize;
|
||||
//# sourceMappingURL=use-auto-resize.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-auto-resize.js","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"],"names":["ref","onMounted","useResizeObserver","onBeforeUnmount","watch"],"mappings":";;;;;;;AAEK,MAAC,aAAa,GAAG,CAAC,KAAK,KAAK;AACjC,EAAE,MAAM,KAAK,GAAGA,OAAG,EAAE,CAAC;AACtB,EAAE,MAAM,MAAM,GAAGA,OAAG,CAAC,CAAC,CAAC,CAAC;AACxB,EAAE,MAAM,OAAO,GAAGA,OAAG,CAAC,CAAC,CAAC,CAAC;AACzB,EAAE,IAAI,cAAc,CAAC;AACrB,EAAEC,aAAS,CAAC,MAAM;AAClB,IAAI,cAAc,GAAGC,sBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,KAAK;AAC3D,MAAM,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;AAClD,MAAM,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACtG,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACrD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACvD,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACnD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AACzD,MAAM,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;AAC1C,MAAM,OAAO,CAAC,KAAK,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC;AAC5C,KAAK,CAAC,CAAC,IAAI,CAAC;AACZ,GAAG,CAAC,CAAC;AACL,EAAEC,mBAAe,CAAC,MAAM;AACxB,IAAI,cAAc,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,cAAc,EAAE,CAAC;AACvD,GAAG,CAAC,CAAC;AACL,EAAEC,SAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK;AAChD,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,QAAQ,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE;AAC5D,MAAM,KAAK;AACX,MAAM,MAAM;AACZ,KAAK,CAAC,CAAC;AACP,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,KAAK;AACT,IAAI,KAAK,EAAE,MAAM;AACjB,IAAI,MAAM,EAAE,OAAO;AACnB,GAAG,CAAC;AACJ;;;;"}
|
||||
Generated
Vendored
+128
@@ -0,0 +1,128 @@
|
||||
import type { CSSProperties, Ref } from 'vue';
|
||||
import type { TableV2Props } from '../table';
|
||||
import type { AnyColumns, Column, KeyType } from '../types';
|
||||
declare function useColumns(props: TableV2Props, columns: Ref<AnyColumns>, fixed: Ref<boolean>): {
|
||||
columns: import("vue").ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: import("../types").Alignment;
|
||||
class?: string | import("../types").ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | import("../types").FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | import("../types").HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: import("../types").CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: import("../types").HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
columnsStyles: import("vue").ComputedRef<Record<KeyType, CSSProperties>>;
|
||||
columnsTotalWidth: import("vue").ComputedRef<number>;
|
||||
fixedColumnsOnLeft: import("vue").ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: import("../types").Alignment;
|
||||
class?: string | import("../types").ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | import("../types").FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | import("../types").HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: import("../types").CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: import("../types").HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
fixedColumnsOnRight: import("vue").ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: import("../types").Alignment;
|
||||
class?: string | import("../types").ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | import("../types").FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | import("../types").HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: import("../types").CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: import("../types").HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
hasFixedColumns: import("vue").ComputedRef<number>;
|
||||
mainColumns: import("vue").ComputedRef<AnyColumns>;
|
||||
normalColumns: import("vue").ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: import("../types").Alignment;
|
||||
class?: string | import("../types").ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | import("../types").FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | import("../types").HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: import("../types").CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: import("../types").HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
visibleColumns: import("vue").ComputedRef<{
|
||||
key: KeyType;
|
||||
align?: import("../types").Alignment;
|
||||
class?: string | import("../types").ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | import("../types").FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | import("../types").HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: import("../types").CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: import("../types").HeaderCellRenderer<any> | undefined;
|
||||
}[]>;
|
||||
getColumn: (key: KeyType) => {
|
||||
key: KeyType;
|
||||
align?: import("../types").Alignment;
|
||||
class?: string | import("../types").ClassNameGetter<any> | undefined;
|
||||
dataKey?: KeyType;
|
||||
fixed?: true | import("../types").FixedDirection;
|
||||
flexGrow?: CSSProperties["flexGrow"];
|
||||
flexShrink?: CSSProperties["flexShrink"];
|
||||
title?: string;
|
||||
hidden?: boolean;
|
||||
headerClass?: string | import("../types").HeaderClassGetter<any> | undefined;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
style?: CSSProperties;
|
||||
sortable?: boolean;
|
||||
width: number;
|
||||
cellRenderer?: import("../types").CellRenderer<any> | undefined;
|
||||
headerCellRenderer?: import("../types").HeaderCellRenderer<any> | undefined;
|
||||
} | undefined;
|
||||
getColumnStyle: (key: KeyType) => CSSProperties;
|
||||
updateColumnWidth: (column: Column<any>, width: number) => void;
|
||||
onColumnSorted: (e: MouseEvent) => void;
|
||||
};
|
||||
export { useColumns };
|
||||
export type UseColumnsReturn = ReturnType<typeof useColumns>;
|
||||
Generated
Vendored
+97
@@ -0,0 +1,97 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var constants = require('../constants.js');
|
||||
var _private = require('../private.js');
|
||||
var utils = require('./utils.js');
|
||||
var shared = require('@vue/shared');
|
||||
|
||||
function useColumns(props, columns, fixed) {
|
||||
const _columns = vue.computed(() => vue.unref(columns).map((column, index) => {
|
||||
var _a, _b;
|
||||
return {
|
||||
...column,
|
||||
key: (_b = (_a = column.key) != null ? _a : column.dataKey) != null ? _b : index
|
||||
};
|
||||
}));
|
||||
const visibleColumns = vue.computed(() => {
|
||||
return vue.unref(_columns).filter((column) => !column.hidden);
|
||||
});
|
||||
const fixedColumnsOnLeft = vue.computed(() => vue.unref(visibleColumns).filter((column) => column.fixed === "left" || column.fixed === true));
|
||||
const fixedColumnsOnRight = vue.computed(() => vue.unref(visibleColumns).filter((column) => column.fixed === "right"));
|
||||
const normalColumns = vue.computed(() => vue.unref(visibleColumns).filter((column) => !column.fixed));
|
||||
const mainColumns = vue.computed(() => {
|
||||
const ret = [];
|
||||
vue.unref(fixedColumnsOnLeft).forEach((column) => {
|
||||
ret.push({
|
||||
...column,
|
||||
placeholderSign: _private.placeholderSign
|
||||
});
|
||||
});
|
||||
vue.unref(normalColumns).forEach((column) => {
|
||||
ret.push(column);
|
||||
});
|
||||
vue.unref(fixedColumnsOnRight).forEach((column) => {
|
||||
ret.push({
|
||||
...column,
|
||||
placeholderSign: _private.placeholderSign
|
||||
});
|
||||
});
|
||||
return ret;
|
||||
});
|
||||
const hasFixedColumns = vue.computed(() => {
|
||||
return vue.unref(fixedColumnsOnLeft).length || vue.unref(fixedColumnsOnRight).length;
|
||||
});
|
||||
const columnsStyles = vue.computed(() => {
|
||||
return vue.unref(_columns).reduce((style, column) => {
|
||||
style[column.key] = utils.calcColumnStyle(column, vue.unref(fixed), props.fixed);
|
||||
return style;
|
||||
}, {});
|
||||
});
|
||||
const columnsTotalWidth = vue.computed(() => {
|
||||
return vue.unref(visibleColumns).reduce((width, column) => width + column.width, 0);
|
||||
});
|
||||
const getColumn = (key) => {
|
||||
return vue.unref(_columns).find((column) => column.key === key);
|
||||
};
|
||||
const getColumnStyle = (key) => {
|
||||
return vue.unref(columnsStyles)[key];
|
||||
};
|
||||
const updateColumnWidth = (column, width) => {
|
||||
column.width = width;
|
||||
};
|
||||
function onColumnSorted(e) {
|
||||
var _a;
|
||||
const { key } = e.currentTarget.dataset;
|
||||
if (!key)
|
||||
return;
|
||||
const { sortState, sortBy } = props;
|
||||
let order = constants.SortOrder.ASC;
|
||||
if (shared.isObject(sortState)) {
|
||||
order = constants.oppositeOrderMap[sortState[key]];
|
||||
} else {
|
||||
order = constants.oppositeOrderMap[sortBy.order];
|
||||
}
|
||||
(_a = props.onColumnSort) == null ? void 0 : _a.call(props, { column: getColumn(key), key, order });
|
||||
}
|
||||
return {
|
||||
columns: _columns,
|
||||
columnsStyles,
|
||||
columnsTotalWidth,
|
||||
fixedColumnsOnLeft,
|
||||
fixedColumnsOnRight,
|
||||
hasFixedColumns,
|
||||
mainColumns,
|
||||
normalColumns,
|
||||
visibleColumns,
|
||||
getColumn,
|
||||
getColumnStyle,
|
||||
updateColumnWidth,
|
||||
onColumnSorted
|
||||
};
|
||||
}
|
||||
|
||||
exports.useColumns = useColumns;
|
||||
//# sourceMappingURL=use-columns.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
import type { TableV2Props } from '../table';
|
||||
import type { KeyType } from '../types';
|
||||
import type { UseRowReturn } from './use-row';
|
||||
type UseDataProps = {
|
||||
expandedRowKeys: UseRowReturn['expandedRowKeys'];
|
||||
lastRenderedRowIndex: UseRowReturn['lastRenderedRowIndex'];
|
||||
resetAfterIndex: UseRowReturn['resetAfterIndex'];
|
||||
};
|
||||
export declare const useData: (props: TableV2Props, { expandedRowKeys, lastRenderedRowIndex, resetAfterIndex }: UseDataProps) => {
|
||||
data: import("vue").ComputedRef<any[]>;
|
||||
depthMap: import("vue").Ref<Record<KeyType, number>>;
|
||||
};
|
||||
export type UseDataReturn = ReturnType<typeof useData>;
|
||||
export {};
|
||||
Generated
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var shared = require('@vue/shared');
|
||||
|
||||
const useData = (props, { expandedRowKeys, lastRenderedRowIndex, resetAfterIndex }) => {
|
||||
const depthMap = vue.ref({});
|
||||
const flattenedData = vue.computed(() => {
|
||||
const depths = {};
|
||||
const { data: data2, rowKey } = props;
|
||||
const _expandedRowKeys = vue.unref(expandedRowKeys);
|
||||
if (!_expandedRowKeys || !_expandedRowKeys.length)
|
||||
return data2;
|
||||
const array = [];
|
||||
const keysSet = /* @__PURE__ */ new Set();
|
||||
_expandedRowKeys.forEach((x) => keysSet.add(x));
|
||||
let copy = data2.slice();
|
||||
copy.forEach((x) => depths[x[rowKey]] = 0);
|
||||
while (copy.length > 0) {
|
||||
const item = copy.shift();
|
||||
array.push(item);
|
||||
if (keysSet.has(item[rowKey]) && 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 = vue.computed(() => {
|
||||
const { data: data2, expandColumnKey } = props;
|
||||
return expandColumnKey ? vue.unref(flattenedData) : data2;
|
||||
});
|
||||
vue.watch(data, (val, prev) => {
|
||||
if (val !== prev) {
|
||||
lastRenderedRowIndex.value = -1;
|
||||
resetAfterIndex(0, true);
|
||||
}
|
||||
});
|
||||
return {
|
||||
data,
|
||||
depthMap
|
||||
};
|
||||
};
|
||||
|
||||
exports.useData = useData;
|
||||
//# sourceMappingURL=use-data.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-data.js","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"],"names":["ref","computed","unref","isArray","watch"],"mappings":";;;;;;;AAEY,MAAC,OAAO,GAAG,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,oBAAoB,EAAE,eAAe,EAAE,KAAK;AAC9F,EAAE,MAAM,QAAQ,GAAGA,OAAG,CAAC,EAAE,CAAC,CAAC;AAC3B,EAAE,MAAM,aAAa,GAAGC,YAAQ,CAAC,MAAM;AACvC,IAAI,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,IAAI,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;AAC1C,IAAI,MAAM,gBAAgB,GAAGC,SAAK,CAAC,eAAe,CAAC,CAAC;AACpD,IAAI,IAAI,CAAC,gBAAgB,IAAI,CAAC,gBAAgB,CAAC,MAAM;AACrD,MAAM,OAAO,KAAK,CAAC;AACnB,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;AACrB,IAAI,MAAM,OAAO,mBAAmB,IAAI,GAAG,EAAE,CAAC;AAC9C,IAAI,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACpD,IAAI,IAAI,IAAI,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;AAC7B,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,IAAI,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;AAC5B,MAAM,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;AAChC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvB,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAIC,cAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;AAC3F,QAAQ,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;AAC3C,QAAQ,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3F,OAAO;AACP,KAAK;AACL,IAAI,QAAQ,CAAC,KAAK,GAAG,MAAM,CAAC;AAC5B,IAAI,OAAO,KAAK,CAAC;AACjB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,IAAI,GAAGF,YAAQ,CAAC,MAAM;AAC9B,IAAI,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC;AACnD,IAAI,OAAO,eAAe,GAAGC,SAAK,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC;AAC1D,GAAG,CAAC,CAAC;AACL,EAAEE,SAAK,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,IAAI,KAAK;AAC7B,IAAI,IAAI,GAAG,KAAK,IAAI,EAAE;AACtB,MAAM,oBAAoB,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACtC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC/B,KAAK;AACL,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,IAAI;AACR,IAAI,QAAQ;AACZ,GAAG,CAAC;AACJ;;;;"}
|
||||
Generated
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
import type { ComponentInternalInstance, Ref, ShallowRef } from 'vue';
|
||||
import type { TableV2Props } from '../table';
|
||||
import type { RowExpandParams, RowHeightChangedParams, RowHoverParams } from '../row';
|
||||
import type { FixedDirection, KeyType } from '../types';
|
||||
import type { onRowRenderedParams } from '../grid';
|
||||
import type { TableGridInstance } from '../table-grid';
|
||||
import type { UseNamespaceReturn } from 'element-plus/es/hooks';
|
||||
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>;
|
||||
};
|
||||
export declare const useRow: (props: TableV2Props, { mainTableRef, leftTableRef, rightTableRef, tableInstance, ns, isScrolling, }: UseRowProps) => {
|
||||
expandedRowKeys: Ref<KeyType[]>;
|
||||
lastRenderedRowIndex: Ref<number>;
|
||||
isDynamic: import("vue").ComputedRef<boolean>;
|
||||
isResetting: ShallowRef<boolean>;
|
||||
rowHeights: Ref<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;
|
||||
};
|
||||
export type UseRowReturn = ReturnType<typeof useRow>;
|
||||
export {};
|
||||
Generated
Vendored
+146
@@ -0,0 +1,146 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var lodashUnified = require('lodash-unified');
|
||||
var constants = require('../constants.js');
|
||||
var types = require('../../../../utils/types.js');
|
||||
|
||||
const useRow = (props, {
|
||||
mainTableRef,
|
||||
leftTableRef,
|
||||
rightTableRef,
|
||||
tableInstance,
|
||||
ns,
|
||||
isScrolling
|
||||
}) => {
|
||||
const vm = vue.getCurrentInstance();
|
||||
const { emit } = vm;
|
||||
const isResetting = vue.shallowRef(false);
|
||||
const expandedRowKeys = vue.ref(props.defaultExpandedRowKeys || []);
|
||||
const lastRenderedRowIndex = vue.ref(-1);
|
||||
const resetIndex = vue.shallowRef(null);
|
||||
const rowHeights = vue.ref({});
|
||||
const pendingRowHeights = vue.ref({});
|
||||
const leftTableHeights = vue.shallowRef({});
|
||||
const mainTableHeights = vue.shallowRef({});
|
||||
const rightTableHeights = vue.shallowRef({});
|
||||
const isDynamic = vue.computed(() => types.isNumber(props.estimatedRowHeight));
|
||||
function onRowsRendered(params) {
|
||||
var _a;
|
||||
(_a = props.onRowsRendered) == null ? void 0 : _a.call(props, params);
|
||||
if (params.rowCacheEnd > vue.unref(lastRenderedRowIndex)) {
|
||||
lastRenderedRowIndex.value = params.rowCacheEnd;
|
||||
}
|
||||
}
|
||||
function onRowHovered({ hovered, rowKey }) {
|
||||
if (isScrolling.value) {
|
||||
return;
|
||||
}
|
||||
const tableRoot = tableInstance.vnode.el;
|
||||
const rows = tableRoot.querySelectorAll(`[rowkey="${String(rowKey)}"]`);
|
||||
rows.forEach((row) => {
|
||||
if (hovered) {
|
||||
row.classList.add(ns.is("hovered"));
|
||||
} else {
|
||||
row.classList.remove(ns.is("hovered"));
|
||||
}
|
||||
});
|
||||
}
|
||||
function onRowExpanded({
|
||||
expanded,
|
||||
rowData,
|
||||
rowIndex,
|
||||
rowKey
|
||||
}) {
|
||||
var _a, _b;
|
||||
const _expandedRowKeys = [...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);
|
||||
(_a = props.onRowExpand) == null ? void 0 : _a.call(props, {
|
||||
expanded,
|
||||
rowData,
|
||||
rowIndex,
|
||||
rowKey
|
||||
});
|
||||
(_b = props.onExpandedRowsChange) == null ? void 0 : _b.call(props, _expandedRowKeys);
|
||||
const tableRoot = tableInstance.vnode.el;
|
||||
const hoverRow = tableRoot.querySelector(`.${ns.is("hovered")}[rowkey="${String(rowKey)}"]`);
|
||||
if (hoverRow) {
|
||||
vue.nextTick(() => onRowHovered({ hovered: true, rowKey }));
|
||||
}
|
||||
}
|
||||
const flushingRowHeights = lodashUnified.debounce(() => {
|
||||
var _a, _b, _c, _d;
|
||||
isResetting.value = true;
|
||||
rowHeights.value = { ...vue.unref(rowHeights), ...vue.unref(pendingRowHeights) };
|
||||
resetAfterIndex(vue.unref(resetIndex), false);
|
||||
pendingRowHeights.value = {};
|
||||
resetIndex.value = null;
|
||||
(_a = mainTableRef.value) == null ? void 0 : _a.forceUpdate();
|
||||
(_b = leftTableRef.value) == null ? void 0 : _b.forceUpdate();
|
||||
(_c = rightTableRef.value) == null ? void 0 : _c.forceUpdate();
|
||||
(_d = vm.proxy) == null ? void 0 : _d.$forceUpdate();
|
||||
isResetting.value = false;
|
||||
}, 0);
|
||||
function resetAfterIndex(index, forceUpdate = false) {
|
||||
if (!vue.unref(isDynamic))
|
||||
return;
|
||||
[mainTableRef, leftTableRef, rightTableRef].forEach((tableRef) => {
|
||||
const table = vue.unref(tableRef);
|
||||
if (table)
|
||||
table.resetAfterRowIndex(index, forceUpdate);
|
||||
});
|
||||
}
|
||||
function resetHeights(rowKey, height, rowIdx) {
|
||||
const resetIdx = 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 === 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 (vue.unref(rowHeights)[rowKey] !== maximumHeight) {
|
||||
resetHeights(rowKey, maximumHeight, rowIndex);
|
||||
flushingRowHeights();
|
||||
}
|
||||
}
|
||||
return {
|
||||
expandedRowKeys,
|
||||
lastRenderedRowIndex,
|
||||
isDynamic,
|
||||
isResetting,
|
||||
rowHeights,
|
||||
resetAfterIndex,
|
||||
onRowExpanded,
|
||||
onRowHovered,
|
||||
onRowsRendered,
|
||||
onRowHeightChange
|
||||
};
|
||||
};
|
||||
|
||||
exports.useRow = useRow;
|
||||
//# sourceMappingURL=use-row.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
import type { Ref } from 'vue';
|
||||
import type { Alignment as ScrollStrategy } from 'element-plus/es/components/virtual-list';
|
||||
import type { TableV2Props } from '../table';
|
||||
import type { TableGridInstance } from '../table-grid';
|
||||
export type ScrollPos = {
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
};
|
||||
type GridInstanceRef = Ref<TableGridInstance | undefined>;
|
||||
type UseScrollBarProps = {
|
||||
mainTableRef: GridInstanceRef;
|
||||
leftTableRef: GridInstanceRef;
|
||||
rightTableRef: GridInstanceRef;
|
||||
onMaybeEndReached: () => void;
|
||||
};
|
||||
export type { ScrollStrategy };
|
||||
export declare const useScrollbar: (props: TableV2Props, { mainTableRef, leftTableRef, rightTableRef, onMaybeEndReached, }: UseScrollBarProps) => {
|
||||
scrollPos: Ref<{
|
||||
scrollLeft: number;
|
||||
scrollTop: number;
|
||||
}>;
|
||||
scrollTo: (params: ScrollPos) => void;
|
||||
scrollToLeft: (scrollLeft: number) => void;
|
||||
scrollToTop: (scrollTop: number) => void;
|
||||
scrollToRow: (row: number, strategy?: ScrollStrategy) => void;
|
||||
onScroll: (params: ScrollPos) => void;
|
||||
onVerticalScroll: ({ scrollTop }: ScrollPos) => void;
|
||||
};
|
||||
Generated
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
|
||||
const useScrollbar = (props, {
|
||||
mainTableRef,
|
||||
leftTableRef,
|
||||
rightTableRef,
|
||||
onMaybeEndReached
|
||||
}) => {
|
||||
const scrollPos = vue.ref({ scrollLeft: 0, scrollTop: 0 });
|
||||
function doScroll(params) {
|
||||
var _a, _b, _c;
|
||||
const { scrollTop } = params;
|
||||
(_a = mainTableRef.value) == null ? void 0 : _a.scrollTo(params);
|
||||
(_b = leftTableRef.value) == null ? void 0 : _b.scrollToTop(scrollTop);
|
||||
(_c = rightTableRef.value) == null ? void 0 : _c.scrollToTop(scrollTop);
|
||||
}
|
||||
function scrollTo(params) {
|
||||
scrollPos.value = params;
|
||||
doScroll(params);
|
||||
}
|
||||
function scrollToTop(scrollTop) {
|
||||
scrollPos.value.scrollTop = scrollTop;
|
||||
doScroll(vue.unref(scrollPos));
|
||||
}
|
||||
function scrollToLeft(scrollLeft) {
|
||||
var _a, _b;
|
||||
scrollPos.value.scrollLeft = scrollLeft;
|
||||
(_b = (_a = mainTableRef.value) == null ? void 0 : _a.scrollTo) == null ? void 0 : _b.call(_a, vue.unref(scrollPos));
|
||||
}
|
||||
function onScroll(params) {
|
||||
var _a;
|
||||
scrollTo(params);
|
||||
(_a = props.onScroll) == null ? void 0 : _a.call(props, params);
|
||||
}
|
||||
function onVerticalScroll({ scrollTop }) {
|
||||
const { scrollTop: currentScrollTop } = vue.unref(scrollPos);
|
||||
if (scrollTop !== currentScrollTop)
|
||||
scrollToTop(scrollTop);
|
||||
}
|
||||
function scrollToRow(row, strategy = "auto") {
|
||||
var _a;
|
||||
(_a = mainTableRef.value) == null ? void 0 : _a.scrollToRow(row, strategy);
|
||||
}
|
||||
vue.watch(() => vue.unref(scrollPos).scrollTop, (cur, prev) => {
|
||||
if (cur > prev)
|
||||
onMaybeEndReached();
|
||||
});
|
||||
return {
|
||||
scrollPos,
|
||||
scrollTo,
|
||||
scrollToLeft,
|
||||
scrollToTop,
|
||||
scrollToRow,
|
||||
onScroll,
|
||||
onVerticalScroll
|
||||
};
|
||||
};
|
||||
|
||||
exports.useScrollbar = useScrollbar;
|
||||
//# sourceMappingURL=use-scrollbar.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"use-scrollbar.js","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"],"names":["ref","unref","watch"],"mappings":"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"}
|
||||
Generated
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
import type { CSSProperties, ComputedRef } from 'vue';
|
||||
import type { TableV2Props } from '../table';
|
||||
import type { UseColumnsReturn } from './use-columns';
|
||||
type UseStyleProps = {
|
||||
columnsTotalWidth: UseColumnsReturn['columnsTotalWidth'];
|
||||
fixedColumnsOnLeft: UseColumnsReturn['fixedColumnsOnLeft'];
|
||||
fixedColumnsOnRight: UseColumnsReturn['fixedColumnsOnRight'];
|
||||
rowsHeight: ComputedRef<number>;
|
||||
};
|
||||
export 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>;
|
||||
};
|
||||
export type UseStyleReturn = ReturnType<typeof useStyles>;
|
||||
export {};
|
||||
Generated
Vendored
+80
@@ -0,0 +1,80 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
var vue = require('vue');
|
||||
var utils = require('../utils.js');
|
||||
var types = require('../../../../utils/types.js');
|
||||
var style = require('../../../../utils/dom/style.js');
|
||||
|
||||
const useStyles = (props, {
|
||||
columnsTotalWidth,
|
||||
rowsHeight,
|
||||
fixedColumnsOnLeft,
|
||||
fixedColumnsOnRight
|
||||
}) => {
|
||||
const bodyWidth = vue.computed(() => {
|
||||
const { fixed, width, vScrollbarSize } = props;
|
||||
const ret = width - vScrollbarSize;
|
||||
return fixed ? Math.max(Math.round(vue.unref(columnsTotalWidth)), ret) : ret;
|
||||
});
|
||||
const mainTableHeight = vue.computed(() => {
|
||||
const { height = 0, maxHeight = 0, footerHeight: footerHeight2, hScrollbarSize } = props;
|
||||
if (maxHeight > 0) {
|
||||
const _fixedRowsHeight = vue.unref(fixedRowsHeight);
|
||||
const _rowsHeight = vue.unref(rowsHeight);
|
||||
const _headerHeight = vue.unref(headerHeight);
|
||||
const total = _headerHeight + _fixedRowsHeight + _rowsHeight + hScrollbarSize;
|
||||
return Math.min(total, maxHeight - footerHeight2);
|
||||
}
|
||||
return height - footerHeight2;
|
||||
});
|
||||
const fixedTableHeight = vue.computed(() => {
|
||||
const { maxHeight } = props;
|
||||
const tableHeight = vue.unref(mainTableHeight);
|
||||
if (types.isNumber(maxHeight) && maxHeight > 0)
|
||||
return tableHeight;
|
||||
const totalHeight = vue.unref(rowsHeight) + vue.unref(headerHeight) + vue.unref(fixedRowsHeight);
|
||||
return Math.min(tableHeight, totalHeight);
|
||||
});
|
||||
const mapColumn = (column) => column.width;
|
||||
const leftTableWidth = vue.computed(() => utils.sum(vue.unref(fixedColumnsOnLeft).map(mapColumn)));
|
||||
const rightTableWidth = vue.computed(() => utils.sum(vue.unref(fixedColumnsOnRight).map(mapColumn)));
|
||||
const headerHeight = vue.computed(() => utils.sum(props.headerHeight));
|
||||
const fixedRowsHeight = vue.computed(() => {
|
||||
var _a;
|
||||
return (((_a = props.fixedData) == null ? void 0 : _a.length) || 0) * props.rowHeight;
|
||||
});
|
||||
const windowHeight = vue.computed(() => {
|
||||
return vue.unref(mainTableHeight) - vue.unref(headerHeight) - vue.unref(fixedRowsHeight);
|
||||
});
|
||||
const rootStyle = vue.computed(() => {
|
||||
const { style = {}, height, width } = props;
|
||||
return utils.enforceUnit({
|
||||
...style,
|
||||
height,
|
||||
width
|
||||
});
|
||||
});
|
||||
const footerHeight = vue.computed(() => utils.enforceUnit({ height: props.footerHeight }));
|
||||
const emptyStyle = vue.computed(() => ({
|
||||
top: style.addUnit(vue.unref(headerHeight)),
|
||||
bottom: style.addUnit(props.footerHeight),
|
||||
width: style.addUnit(props.width)
|
||||
}));
|
||||
return {
|
||||
bodyWidth,
|
||||
fixedTableHeight,
|
||||
mainTableHeight,
|
||||
leftTableWidth,
|
||||
rightTableWidth,
|
||||
windowHeight,
|
||||
footerHeight,
|
||||
emptyStyle,
|
||||
rootStyle,
|
||||
headerHeight
|
||||
};
|
||||
};
|
||||
|
||||
exports.useStyles = useStyles;
|
||||
//# sourceMappingURL=use-styles.js.map
|
||||
Generated
Vendored
+1
File diff suppressed because one or more lines are too long
Generated
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
import type { CSSProperties } from 'vue';
|
||||
import type { AnyColumns } from '../types';
|
||||
export declare const calcColumnStyle: (column: AnyColumns[number], fixedColumn: boolean, fixed: boolean) => CSSProperties;
|
||||
Generated
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const calcColumnStyle = (column, fixedColumn, fixed) => {
|
||||
var _a;
|
||||
const flex = {
|
||||
flexGrow: 0,
|
||||
flexShrink: 0,
|
||||
...fixed ? {} : {
|
||||
flexGrow: column.flexGrow || 0,
|
||||
flexShrink: column.flexShrink || 1
|
||||
}
|
||||
};
|
||||
if (!fixed) {
|
||||
flex.flexShrink = 1;
|
||||
}
|
||||
const style = {
|
||||
...(_a = column.style) != null ? _a : {},
|
||||
...flex,
|
||||
flexBasis: "auto",
|
||||
width: column.width
|
||||
};
|
||||
if (!fixedColumn) {
|
||||
if (column.maxWidth)
|
||||
style.maxWidth = column.maxWidth;
|
||||
if (column.minWidth)
|
||||
style.minWidth = column.minWidth;
|
||||
}
|
||||
return style;
|
||||
};
|
||||
|
||||
exports.calcColumnStyle = calcColumnStyle;
|
||||
//# sourceMappingURL=utils.js.map
|
||||
Generated
Vendored
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"utils.js","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 if (!fixed) {\n flex.flexShrink = 1\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"],"names":[],"mappings":";;;;AAAY,MAAC,eAAe,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,KAAK;AAC/D,EAAE,IAAI,EAAE,CAAC;AACT,EAAE,MAAM,IAAI,GAAG;AACf,IAAI,QAAQ,EAAE,CAAC;AACf,IAAI,UAAU,EAAE,CAAC;AACjB,IAAI,GAAG,KAAK,GAAG,EAAE,GAAG;AACpB,MAAM,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,CAAC;AACpC,MAAM,UAAU,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC;AACxC,KAAK;AACL,GAAG,CAAC;AACJ,EAAE,IAAI,CAAC,KAAK,EAAE;AACd,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;AACxB,GAAG;AACH,EAAE,MAAM,KAAK,GAAG;AAChB,IAAI,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,KAAK,IAAI,GAAG,EAAE,GAAG,EAAE;AAC5C,IAAI,GAAG,IAAI;AACX,IAAI,SAAS,EAAE,MAAM;AACrB,IAAI,KAAK,EAAE,MAAM,CAAC,KAAK;AACvB,GAAG,CAAC;AACJ,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAI,IAAI,MAAM,CAAC,QAAQ;AACvB,MAAM,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AACvC,IAAI,IAAI,MAAM,CAAC,QAAQ;AACvB,MAAM,KAAK,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AACvC,GAAG;AACH,EAAE,OAAO,KAAK,CAAC;AACf;;;;"}
|
||||
Reference in New Issue
Block a user