@visactor/vtable-calendar 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/dist/vtable-calendar.js +115 -10
- package/dist/vtable-calendar.min.js +1 -1
- package/package.json +3 -3
package/dist/vtable-calendar.js
CHANGED
|
@@ -41360,7 +41360,7 @@
|
|
|
41360
41360
|
rowEnd = null !== (_k = cellGroup.mergeEndCol) && void 0 !== _k ? _k : cellGroup.row,
|
|
41361
41361
|
leftIconWidth = null !== (_l = cellGroup._cellLeftIconWidth) && void 0 !== _l ? _l : 0,
|
|
41362
41362
|
rightIconWidth = null !== (_m = cellGroup._cellRightIconWidth) && void 0 !== _m ? _m : 0;
|
|
41363
|
-
if (image.keepAspectRatio) {
|
|
41363
|
+
if (image.keepAspectRatio || isDamagePic(image)) {
|
|
41364
41364
|
const {
|
|
41365
41365
|
width: imageWidth,
|
|
41366
41366
|
height: imageHeight
|
|
@@ -57169,7 +57169,7 @@
|
|
|
57169
57169
|
}
|
|
57170
57170
|
constructor(container, options = {}) {
|
|
57171
57171
|
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;
|
|
57172
|
-
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.
|
|
57172
|
+
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) {
|
|
57173
57173
|
const g = window;
|
|
57174
57174
|
g[this.id] = this;
|
|
57175
57175
|
const registry = g.__vtable__ || (g.__vtable__ = {
|
|
@@ -65998,8 +65998,66 @@
|
|
|
65998
65998
|
}
|
|
65999
65999
|
|
|
66000
66000
|
const regedIcons = get$2();
|
|
66001
|
+
function releaseVideoResource(video) {
|
|
66002
|
+
try {
|
|
66003
|
+
video.pause();
|
|
66004
|
+
} catch (err) {}
|
|
66005
|
+
video.removeAttribute("src");
|
|
66006
|
+
try {
|
|
66007
|
+
video.load();
|
|
66008
|
+
} catch (err) {}
|
|
66009
|
+
}
|
|
66010
|
+
function getVideoFirstFrameTimeout(table) {
|
|
66011
|
+
var _a;
|
|
66012
|
+
const timeout = null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.videoFirstFrameTimeout;
|
|
66013
|
+
return "number" == typeof timeout && timeout >= 0 ? timeout : 8e3;
|
|
66014
|
+
}
|
|
66015
|
+
function getVideoFirstFrameMaxCanvasSize(table) {
|
|
66016
|
+
var _a;
|
|
66017
|
+
const maxCanvasSize = null === (_a = table.options.customConfig) || void 0 === _a ? void 0 : _a.videoFirstFrameMaxCanvasSize;
|
|
66018
|
+
return "number" == typeof maxCanvasSize && maxCanvasSize > 0 ? maxCanvasSize : 512;
|
|
66019
|
+
}
|
|
66020
|
+
function snapshotVideoFirstFrame(video, image, table) {
|
|
66021
|
+
const displayWidth = image.attribute.width,
|
|
66022
|
+
displayHeight = image.attribute.height;
|
|
66023
|
+
if ("number" != typeof displayWidth || "number" != typeof displayHeight || displayWidth <= 0 || displayHeight <= 0) return !1;
|
|
66024
|
+
const canvas = document.createElement("canvas"),
|
|
66025
|
+
context = canvas.getContext("2d");
|
|
66026
|
+
if (!context) return !1;
|
|
66027
|
+
const dpr = Math.min(("undefined" == typeof window ? 1 : window.devicePixelRatio) || 1, 2),
|
|
66028
|
+
maxSize = getVideoFirstFrameMaxCanvasSize(table),
|
|
66029
|
+
scale = Math.min(dpr, maxSize / Math.max(displayWidth, displayHeight));
|
|
66030
|
+
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`;
|
|
66031
|
+
try {
|
|
66032
|
+
return context.drawImage(video, 0, 0, canvas.width, canvas.height), image.setAttributes({
|
|
66033
|
+
image: canvas
|
|
66034
|
+
}), !0;
|
|
66035
|
+
} catch (err) {
|
|
66036
|
+
return !1;
|
|
66037
|
+
}
|
|
66038
|
+
}
|
|
66039
|
+
function getSvgSize(svg) {
|
|
66040
|
+
var _a;
|
|
66041
|
+
const svgTag = null === (_a = svg.match(/<svg\b[^>]*>/i)) || void 0 === _a ? void 0 : _a[0];
|
|
66042
|
+
if (!svgTag) return;
|
|
66043
|
+
const widthMatch = svgTag.match(/\bwidth=["']?([\d.]+)/i),
|
|
66044
|
+
heightMatch = svgTag.match(/\bheight=["']?([\d.]+)/i),
|
|
66045
|
+
width = widthMatch ? Number(widthMatch[1]) : void 0,
|
|
66046
|
+
height = heightMatch ? Number(heightMatch[1]) : void 0;
|
|
66047
|
+
if (width > 0 && height > 0) return {
|
|
66048
|
+
width: width,
|
|
66049
|
+
height: height
|
|
66050
|
+
};
|
|
66051
|
+
const viewBoxMatch = svgTag.match(/\bviewBox=["']\s*[-\d.]+\s+[-\d.]+\s+([\d.]+)\s+([\d.]+)\s*["']/i),
|
|
66052
|
+
viewBoxWidth = viewBoxMatch ? Number(viewBoxMatch[1]) : void 0,
|
|
66053
|
+
viewBoxHeight = viewBoxMatch ? Number(viewBoxMatch[2]) : void 0;
|
|
66054
|
+
return viewBoxWidth > 0 && viewBoxHeight > 0 ? {
|
|
66055
|
+
width: viewBoxWidth,
|
|
66056
|
+
height: viewBoxHeight
|
|
66057
|
+
} : void 0;
|
|
66058
|
+
}
|
|
66001
66059
|
function createVideoCellGroup(columnGroup, xOrigin, yOrigin, col, row, width, height, keepAspectRatio, imageAutoSizing, padding, textAlign, textBaseline, mayHaveIcon, table, cellTheme, range, isAsync) {
|
|
66002
|
-
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;
|
|
66060
|
+
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;
|
|
66003
66061
|
const headerStyle = table._getCellStyle(col, row),
|
|
66004
66062
|
functionalPadding = getFunctionalProp("padding", headerStyle, col, row, table);
|
|
66005
66063
|
(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$1(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);
|
|
@@ -66057,7 +66115,55 @@
|
|
|
66057
66115
|
}
|
|
66058
66116
|
const value = table.getCellValue(col, row),
|
|
66059
66117
|
video = document.createElement("video");
|
|
66118
|
+
video.muted = !0, video.playsInline = !0;
|
|
66119
|
+
const shouldSnapshot = !0 === (null === (_6 = table.options.customConfig) || void 0 === _6 ? void 0 : _6.videoFirstFrameSnapshot);
|
|
66120
|
+
let loadTimer,
|
|
66121
|
+
videoReleased = !1;
|
|
66122
|
+
const clearVideoLoadTimer = () => {
|
|
66123
|
+
void 0 !== loadTimer && (clearTimeout(loadTimer), loadTimer = void 0);
|
|
66124
|
+
},
|
|
66125
|
+
releaseCurrentVideo = () => {
|
|
66126
|
+
videoReleased || (videoReleased = !0, clearVideoLoadTimer(), releaseVideoResource(video));
|
|
66127
|
+
},
|
|
66128
|
+
isCurrentImage = () => cellGroup.getChildByName("image", !0) === image,
|
|
66129
|
+
handleVideoLoadFail = () => {
|
|
66130
|
+
videoReleased || (isCurrentImage() && ((() => {
|
|
66131
|
+
var _a, _b;
|
|
66132
|
+
const regedIcons = get$2(),
|
|
66133
|
+
damageIcon = regedIcons.video_damage_pic || regedIcons.damage_pic,
|
|
66134
|
+
damageImage = damageIcon.svg;
|
|
66135
|
+
image.setAttributes({
|
|
66136
|
+
image: damageImage
|
|
66137
|
+
});
|
|
66138
|
+
const originImage = null === (_b = null === (_a = image.resources) || void 0 === _a ? void 0 : _a.get(damageImage)) || void 0 === _b ? void 0 : _b.data,
|
|
66139
|
+
svgSize = "string" == typeof damageImage ? getSvgSize(damageImage) : void 0,
|
|
66140
|
+
originWidth = (null == originImage ? void 0 : originImage.width) || damageIcon.width || (null == svgSize ? void 0 : svgSize.width) || 24,
|
|
66141
|
+
originHeight = (null == originImage ? void 0 : originImage.height) || damageIcon.height || (null == svgSize ? void 0 : svgSize.height) || 24,
|
|
66142
|
+
{
|
|
66143
|
+
width: cellWidth,
|
|
66144
|
+
height: cellHeight,
|
|
66145
|
+
isMerge: isMerge
|
|
66146
|
+
} = getCellRange$1(cellGroup, table),
|
|
66147
|
+
availableWidth = cellWidth - padding[1] - padding[3],
|
|
66148
|
+
availableHeight = cellHeight - padding[0] - padding[2];
|
|
66149
|
+
if (originWidth > 0 && originHeight > 0 && availableWidth > 0 && availableHeight > 0) {
|
|
66150
|
+
const {
|
|
66151
|
+
width: imageWidth,
|
|
66152
|
+
height: imageHeight
|
|
66153
|
+
} = calcKeepAspectRatioSize(originWidth, originHeight, availableWidth, availableHeight),
|
|
66154
|
+
pos = calcStartPosition(0, 0, cellWidth, cellHeight, imageWidth, imageHeight, textAlign, textBaseline, padding);
|
|
66155
|
+
image.setAttributes({
|
|
66156
|
+
x: pos.x,
|
|
66157
|
+
y: pos.y,
|
|
66158
|
+
width: imageWidth,
|
|
66159
|
+
height: imageHeight
|
|
66160
|
+
}), isMerge && updateImageDxDy(cellGroup.mergeStartCol, cellGroup.mergeEndCol, cellGroup.mergeStartRow, cellGroup.mergeEndRow, table);
|
|
66161
|
+
}
|
|
66162
|
+
})(), table.scenegraph.updateNextFrame()), shouldSnapshot && releaseCurrentVideo());
|
|
66163
|
+
};
|
|
66060
66164
|
video.addEventListener("loadeddata", () => {
|
|
66165
|
+
if (clearVideoLoadTimer(), videoReleased) return;
|
|
66166
|
+
if (!isCurrentImage()) return void releaseCurrentVideo();
|
|
66061
66167
|
imageAutoSizing && _adjustWidthHeight(col, row, video.videoWidth, video.videoHeight, table.scenegraph, padding, cellGroup);
|
|
66062
66168
|
const {
|
|
66063
66169
|
width: cellWidth,
|
|
@@ -66107,11 +66213,8 @@
|
|
|
66107
66213
|
dx: dx,
|
|
66108
66214
|
dy: dy
|
|
66109
66215
|
});
|
|
66110
|
-
playIcon.name = "play-icon", cellGroup.appendChild(playIcon), table.scenegraph.updateNextFrame();
|
|
66111
|
-
}), video.
|
|
66112
|
-
const regedIcons = get$2();
|
|
66113
|
-
image.image = regedIcons.video_damage_pic ? regedIcons.video_damage_pic.svg : regedIcons.damage_pic.svg;
|
|
66114
|
-
}, video.src = value, video.setAttribute("preload", "auto");
|
|
66216
|
+
playIcon.name = "play-icon", cellGroup.appendChild(playIcon), shouldSnapshot && snapshotVideoFirstFrame(video, image, table) && releaseCurrentVideo(), table.scenegraph.updateNextFrame();
|
|
66217
|
+
}), video.addEventListener("error", handleVideoLoadFail), video.addEventListener("abort", handleVideoLoadFail);
|
|
66115
66218
|
const image = createImage({
|
|
66116
66219
|
x: padding[3],
|
|
66117
66220
|
y: padding[0],
|
|
@@ -66120,9 +66223,11 @@
|
|
|
66120
66223
|
image: video,
|
|
66121
66224
|
cursor: "pointer"
|
|
66122
66225
|
});
|
|
66123
|
-
|
|
66226
|
+
image.name = "image", image.keepAspectRatio = keepAspectRatio, image.textAlign = textAlign, image.textBaseline = textBaseline, cellGroup.appendChild(image), image.successCallback = () => {
|
|
66124
66227
|
isDamagePic(image) && (updateAutoSizingAndKeepAspectRatio(imageAutoSizing, keepAspectRatio, padding, textAlign, textBaseline, image, cellGroup, table), table.scenegraph.updateNextFrame());
|
|
66125
|
-
},
|
|
66228
|
+
}, video.setAttribute("preload", "auto"), video.src = value;
|
|
66229
|
+
const timeout = getVideoFirstFrameTimeout(table);
|
|
66230
|
+
return shouldSnapshot && timeout > 0 && (loadTimer = setTimeout(handleVideoLoadFail, timeout)), cellGroup;
|
|
66126
66231
|
}
|
|
66127
66232
|
|
|
66128
66233
|
function createMark(marked, cellGroup, table) {
|