@visactor/vtable-sheet 1.26.3 → 1.26.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/dist/vtable-sheet.js +116 -11
- package/dist/vtable-sheet.min.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/package.json +4 -4
package/cjs/index.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import VTableSheet from './components/vtable-sheet';
|
|
|
2
2
|
import type { ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions } from './ts-types';
|
|
3
3
|
import * as TYPES from './ts-types';
|
|
4
4
|
import * as VTable from './vtable';
|
|
5
|
-
export declare const version = "1.26.
|
|
5
|
+
export declare const version = "1.26.4";
|
|
6
6
|
export { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions };
|
package/cjs/index.js
CHANGED
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.26.
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6EAAoD;AAW3C,sBAXF,sBAAW,CAWE;AATpB,kDAAoC;AASd,sBAAK;AAR3B,iDAAmC;AAQN,wBAAM;AAPnC,0DAAsD;AACzC,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,IAAA,4BAAY,GAAE,CAAC","file":"index.js","sourcesContent":["import VTableSheet from './components/vtable-sheet';\nimport type { ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions } from './ts-types';\nimport * as TYPES from './ts-types';\nimport * as VTable from './vtable';\nimport { importStyles } from './styles/style-manager';\nexport const version = \"1.26.4\";\n// 导入样式\nimportStyles();\n/**\n * @namespace VTableSheet\n */\nexport { VTableSheet, TYPES, VTable, ISheetDefine, IVTableSheetOptions, IVTableSheetUpdateOptions };\n"]}
|
package/dist/vtable-sheet.js
CHANGED
|
@@ -45636,7 +45636,7 @@
|
|
|
45636
45636
|
rowEnd = null !== (_k = cellGroup.mergeEndCol) && void 0 !== _k ? _k : cellGroup.row,
|
|
45637
45637
|
leftIconWidth = null !== (_l = cellGroup._cellLeftIconWidth) && void 0 !== _l ? _l : 0,
|
|
45638
45638
|
rightIconWidth = null !== (_m = cellGroup._cellRightIconWidth) && void 0 !== _m ? _m : 0;
|
|
45639
|
-
if (image.keepAspectRatio) {
|
|
45639
|
+
if (image.keepAspectRatio || isDamagePic(image)) {
|
|
45640
45640
|
const {
|
|
45641
45641
|
width: imageWidth,
|
|
45642
45642
|
height: imageHeight
|
|
@@ -61445,7 +61445,7 @@
|
|
|
61445
61445
|
}
|
|
61446
61446
|
constructor(container, options = {}) {
|
|
61447
61447
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
|
|
61448
|
-
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.
|
|
61448
|
+
if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.26.4", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "undefined" != typeof window) {
|
|
61449
61449
|
const g = window;
|
|
61450
61450
|
g[this.id] = this;
|
|
61451
61451
|
const registry = g.__vtable__ || (g.__vtable__ = {
|
|
@@ -70310,8 +70310,66 @@
|
|
|
70310
70310
|
}
|
|
70311
70311
|
|
|
70312
70312
|
const regedIcons = get$2();
|
|
70313
|
+
function releaseVideoResource(video) {
|
|
70314
|
+
try {
|
|
70315
|
+
video.pause();
|
|
70316
|
+
} catch (err) {}
|
|
70317
|
+
video.removeAttribute("src");
|
|
70318
|
+
try {
|
|
70319
|
+
video.load();
|
|
70320
|
+
} catch (err) {}
|
|
70321
|
+
}
|
|
70322
|
+
function getVideoFirstFrameTimeout(table) {
|
|
70323
|
+
var _a;
|
|
70324
|
+
const timeout = null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.videoFirstFrameTimeout;
|
|
70325
|
+
return "number" == typeof timeout && timeout >= 0 ? timeout : 8e3;
|
|
70326
|
+
}
|
|
70327
|
+
function getVideoFirstFrameMaxCanvasSize(table) {
|
|
70328
|
+
var _a;
|
|
70329
|
+
const maxCanvasSize = null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.videoFirstFrameMaxCanvasSize;
|
|
70330
|
+
return "number" == typeof maxCanvasSize && maxCanvasSize > 0 ? maxCanvasSize : 512;
|
|
70331
|
+
}
|
|
70332
|
+
function snapshotVideoFirstFrame(video, image, table) {
|
|
70333
|
+
const displayWidth = image.attribute.width,
|
|
70334
|
+
displayHeight = image.attribute.height;
|
|
70335
|
+
if ("number" != typeof displayWidth || "number" != typeof displayHeight || displayWidth <= 0 || displayHeight <= 0) return !1;
|
|
70336
|
+
const canvas = document.createElement("canvas"),
|
|
70337
|
+
context = canvas.getContext("2d");
|
|
70338
|
+
if (!context) return !1;
|
|
70339
|
+
const dpr = Math.min(("undefined" == typeof window ? 1 : window.devicePixelRatio) || 1, 2),
|
|
70340
|
+
maxSize = getVideoFirstFrameMaxCanvasSize(table),
|
|
70341
|
+
scale = Math.min(dpr, maxSize / Math.max(displayWidth, displayHeight));
|
|
70342
|
+
canvas.width = Math.max(1, Math.ceil(displayWidth * scale)), canvas.height = Math.max(1, Math.ceil(displayHeight * scale)), canvas.style.width = `${displayWidth}px`, canvas.style.height = `${displayHeight}px`;
|
|
70343
|
+
try {
|
|
70344
|
+
return context.drawImage(video, 0, 0, canvas.width, canvas.height), image.setAttributes({
|
|
70345
|
+
image: canvas
|
|
70346
|
+
}), !0;
|
|
70347
|
+
} catch (err) {
|
|
70348
|
+
return !1;
|
|
70349
|
+
}
|
|
70350
|
+
}
|
|
70351
|
+
function getSvgSize(svg) {
|
|
70352
|
+
var _a;
|
|
70353
|
+
const svgTag = null === (_a = svg.match(/<svg\b[^>]*>/i)) || void 0 === _a ? void 0 : _a[0];
|
|
70354
|
+
if (!svgTag) return;
|
|
70355
|
+
const widthMatch = svgTag.match(/\bwidth=["']?([\d.]+)/i),
|
|
70356
|
+
heightMatch = svgTag.match(/\bheight=["']?([\d.]+)/i),
|
|
70357
|
+
width = widthMatch ? Number(widthMatch[1]) : void 0,
|
|
70358
|
+
height = heightMatch ? Number(heightMatch[1]) : void 0;
|
|
70359
|
+
if (width > 0 && height > 0) return {
|
|
70360
|
+
width: width,
|
|
70361
|
+
height: height
|
|
70362
|
+
};
|
|
70363
|
+
const viewBoxMatch = svgTag.match(/\bviewBox=["']\s*[-\d.]+\s+[-\d.]+\s+([\d.]+)\s+([\d.]+)\s*["']/i),
|
|
70364
|
+
viewBoxWidth = viewBoxMatch ? Number(viewBoxMatch[1]) : void 0,
|
|
70365
|
+
viewBoxHeight = viewBoxMatch ? Number(viewBoxMatch[2]) : void 0;
|
|
70366
|
+
return viewBoxWidth > 0 && viewBoxHeight > 0 ? {
|
|
70367
|
+
width: viewBoxWidth,
|
|
70368
|
+
height: viewBoxHeight
|
|
70369
|
+
} : void 0;
|
|
70370
|
+
}
|
|
70313
70371
|
function createVideoCellGroup(columnGroup, xOrigin, yOrigin, col, row, width, height, keepAspectRatio, imageAutoSizing, padding, textAlign, textBaseline, mayHaveIcon, table, cellTheme, range, isAsync) {
|
|
70314
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
70372
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
|
|
70315
70373
|
const headerStyle = table._getCellStyle(col, row),
|
|
70316
70374
|
functionalPadding = getFunctionalProp("padding", headerStyle, col, row, table);
|
|
70317
70375
|
(null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.imageMargin) ? padding = getQuadProps(null === (_b = table.options.customConfig) || void 0 === _b ? void 0 : _b.imageMargin) : isValid$2(functionalPadding) && (padding = functionalPadding), (null === (_c = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _c ? void 0 : _c.textAlign) && (textAlign = null === (_d = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _d ? void 0 : _d.textAlign), (null === (_e = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _e ? void 0 : _e.textBaseline) && (textBaseline = null === (_f = null == cellTheme ? void 0 : cellTheme.text) || void 0 === _f ? void 0 : _f.textBaseline);
|
|
@@ -70369,7 +70427,55 @@
|
|
|
70369
70427
|
}
|
|
70370
70428
|
const value = table.getCellValue(col, row),
|
|
70371
70429
|
video = document.createElement("video");
|
|
70430
|
+
video.muted = !0, video.playsInline = !0;
|
|
70431
|
+
const shouldSnapshot = !0 === (null === (_6 = table.options.customConfig) || void 0 === _6 ? void 0 : _6.videoFirstFrameSnapshot);
|
|
70432
|
+
let loadTimer,
|
|
70433
|
+
videoReleased = !1;
|
|
70434
|
+
const clearVideoLoadTimer = () => {
|
|
70435
|
+
void 0 !== loadTimer && (clearTimeout(loadTimer), loadTimer = void 0);
|
|
70436
|
+
},
|
|
70437
|
+
releaseCurrentVideo = () => {
|
|
70438
|
+
videoReleased || (videoReleased = !0, clearVideoLoadTimer(), releaseVideoResource(video));
|
|
70439
|
+
},
|
|
70440
|
+
isCurrentImage = () => cellGroup.getChildByName("image", !0) === image,
|
|
70441
|
+
handleVideoLoadFail = () => {
|
|
70442
|
+
videoReleased || (isCurrentImage() && ((() => {
|
|
70443
|
+
var _a, _b;
|
|
70444
|
+
const regedIcons = get$2(),
|
|
70445
|
+
damageIcon = regedIcons.video_damage_pic || regedIcons.damage_pic,
|
|
70446
|
+
damageImage = damageIcon.svg;
|
|
70447
|
+
image.setAttributes({
|
|
70448
|
+
image: damageImage
|
|
70449
|
+
});
|
|
70450
|
+
const originImage = null === (_b = null === (_a = image.resources) || void 0 === _a ? void 0 : _a.get(damageImage)) || void 0 === _b ? void 0 : _b.data,
|
|
70451
|
+
svgSize = "string" == typeof damageImage ? getSvgSize(damageImage) : void 0,
|
|
70452
|
+
originWidth = (null == originImage ? void 0 : originImage.width) || damageIcon.width || (null == svgSize ? void 0 : svgSize.width) || 24,
|
|
70453
|
+
originHeight = (null == originImage ? void 0 : originImage.height) || damageIcon.height || (null == svgSize ? void 0 : svgSize.height) || 24,
|
|
70454
|
+
{
|
|
70455
|
+
width: cellWidth,
|
|
70456
|
+
height: cellHeight,
|
|
70457
|
+
isMerge: isMerge
|
|
70458
|
+
} = getCellRange$1(cellGroup, table),
|
|
70459
|
+
availableWidth = cellWidth - padding[1] - padding[3],
|
|
70460
|
+
availableHeight = cellHeight - padding[0] - padding[2];
|
|
70461
|
+
if (originWidth > 0 && originHeight > 0 && availableWidth > 0 && availableHeight > 0) {
|
|
70462
|
+
const {
|
|
70463
|
+
width: imageWidth,
|
|
70464
|
+
height: imageHeight
|
|
70465
|
+
} = calcKeepAspectRatioSize(originWidth, originHeight, availableWidth, availableHeight),
|
|
70466
|
+
pos = calcStartPosition(0, 0, cellWidth, cellHeight, imageWidth, imageHeight, textAlign, textBaseline, padding);
|
|
70467
|
+
image.setAttributes({
|
|
70468
|
+
x: pos.x,
|
|
70469
|
+
y: pos.y,
|
|
70470
|
+
width: imageWidth,
|
|
70471
|
+
height: imageHeight
|
|
70472
|
+
}), isMerge && updateImageDxDy(cellGroup.mergeStartCol, cellGroup.mergeEndCol, cellGroup.mergeStartRow, cellGroup.mergeEndRow, table);
|
|
70473
|
+
}
|
|
70474
|
+
})(), table.scenegraph.updateNextFrame()), shouldSnapshot && releaseCurrentVideo());
|
|
70475
|
+
};
|
|
70372
70476
|
video.addEventListener("loadeddata", () => {
|
|
70477
|
+
if (clearVideoLoadTimer(), videoReleased) return;
|
|
70478
|
+
if (!isCurrentImage()) return void releaseCurrentVideo();
|
|
70373
70479
|
imageAutoSizing && _adjustWidthHeight(col, row, video.videoWidth, video.videoHeight, table.scenegraph, padding, cellGroup);
|
|
70374
70480
|
const {
|
|
70375
70481
|
width: cellWidth,
|
|
@@ -70419,11 +70525,8 @@
|
|
|
70419
70525
|
dx: dx,
|
|
70420
70526
|
dy: dy
|
|
70421
70527
|
});
|
|
70422
|
-
playIcon.name = "play-icon", cellGroup.appendChild(playIcon), table.scenegraph.updateNextFrame();
|
|
70423
|
-
}), video.
|
|
70424
|
-
const regedIcons = get$2();
|
|
70425
|
-
image.image = regedIcons.video_damage_pic ? regedIcons.video_damage_pic.svg : regedIcons.damage_pic.svg;
|
|
70426
|
-
}, video.src = value, video.setAttribute("preload", "auto");
|
|
70528
|
+
playIcon.name = "play-icon", cellGroup.appendChild(playIcon), shouldSnapshot && snapshotVideoFirstFrame(video, image, table) && releaseCurrentVideo(), table.scenegraph.updateNextFrame();
|
|
70529
|
+
}), video.addEventListener("error", handleVideoLoadFail), video.addEventListener("abort", handleVideoLoadFail);
|
|
70427
70530
|
const image = createImage({
|
|
70428
70531
|
x: padding[3],
|
|
70429
70532
|
y: padding[0],
|
|
@@ -70432,9 +70535,11 @@
|
|
|
70432
70535
|
image: video,
|
|
70433
70536
|
cursor: "pointer"
|
|
70434
70537
|
});
|
|
70435
|
-
|
|
70538
|
+
image.name = "image", image.keepAspectRatio = keepAspectRatio, image.textAlign = textAlign, image.textBaseline = textBaseline, cellGroup.appendChild(image), image.successCallback = () => {
|
|
70436
70539
|
isDamagePic(image) && (updateAutoSizingAndKeepAspectRatio(imageAutoSizing, keepAspectRatio, padding, textAlign, textBaseline, image, cellGroup, table), table.scenegraph.updateNextFrame());
|
|
70437
|
-
},
|
|
70540
|
+
}, video.setAttribute("preload", "auto"), video.src = value;
|
|
70541
|
+
const timeout = getVideoFirstFrameTimeout(table);
|
|
70542
|
+
return shouldSnapshot && timeout > 0 && (loadTimer = setTimeout(handleVideoLoadFail, timeout)), cellGroup;
|
|
70438
70543
|
}
|
|
70439
70544
|
|
|
70440
70545
|
function createMark(marked, cellGroup, table) {
|
|
@@ -96229,7 +96334,7 @@
|
|
|
96229
96334
|
importStyle();
|
|
96230
96335
|
}
|
|
96231
96336
|
|
|
96232
|
-
const version = "1.26.
|
|
96337
|
+
const version = "1.26.4";
|
|
96233
96338
|
importStyles();
|
|
96234
96339
|
|
|
96235
96340
|
exports.TYPES = index;
|