@visactor/vtable 0.15.4 → 0.15.5-alpha.2
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/components/axis/axis.d.ts +3 -1
- package/cjs/components/axis/axis.js +10 -8
- package/cjs/components/axis/axis.js.map +1 -1
- package/cjs/core/BaseTable.js +17 -6
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/chart-helper/get-axis-config.d.ts +2 -0
- package/cjs/layout/chart-helper/get-axis-config.js +23 -2
- package/cjs/layout/chart-helper/get-axis-config.js.map +1 -1
- package/cjs/layout/pivot-header-layout.d.ts +15 -9
- package/cjs/layout/pivot-header-layout.js +71 -154
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/layout/pivot-layout-helper.d.ts +10 -2
- package/cjs/layout/pivot-layout-helper.js +108 -6
- package/cjs/layout/pivot-layout-helper.js.map +1 -1
- package/cjs/layout/simple-header-layout.d.ts +1 -0
- package/cjs/layout/simple-header-layout.js +5 -7
- package/cjs/layout/simple-header-layout.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +4 -4
- package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
- package/cjs/scenegraph/graphic/group.js +5 -3
- package/cjs/scenegraph/graphic/group.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/proxy.d.ts +1 -0
- package/cjs/scenegraph/group-creater/progress/proxy.js +12 -0
- package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
- package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
- package/cjs/scenegraph/layout/compute-col-width.js +28 -17
- package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
- package/cjs/scenegraph/layout/compute-row-height.js +21 -7
- package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
- package/cjs/scenegraph/layout/update-row.js +8 -3
- package/cjs/scenegraph/layout/update-row.js.map +1 -1
- package/cjs/scenegraph/layout/update-width.js +3 -2
- package/cjs/scenegraph/layout/update-width.js.map +1 -1
- package/cjs/scenegraph/refresh-node/update-chart.js +3 -2
- package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/cjs/scenegraph/scenegraph.js +2 -2
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/scenegraph/style/frame-border.js +26 -12
- package/cjs/scenegraph/style/frame-border.js.map +1 -1
- package/dist/vtable.js +490 -286
- package/dist/vtable.min.js +2 -2
- package/es/components/axis/axis.d.ts +3 -1
- package/es/components/axis/axis.js +7 -5
- package/es/components/axis/axis.js.map +1 -1
- package/es/core/BaseTable.js +18 -5
- package/es/core/BaseTable.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/chart-helper/get-axis-config.d.ts +2 -0
- package/es/layout/chart-helper/get-axis-config.js +20 -0
- package/es/layout/chart-helper/get-axis-config.js.map +1 -1
- package/es/layout/pivot-header-layout.d.ts +15 -9
- package/es/layout/pivot-header-layout.js +71 -151
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/layout/pivot-layout-helper.d.ts +10 -2
- package/es/layout/pivot-layout-helper.js +107 -5
- package/es/layout/pivot-layout-helper.js.map +1 -1
- package/es/layout/simple-header-layout.d.ts +1 -0
- package/es/layout/simple-header-layout.js +5 -7
- package/es/layout/simple-header-layout.js.map +1 -1
- package/es/scenegraph/graphic/contributions/group-contribution-render.js +4 -4
- package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
- package/es/scenegraph/graphic/group.js +5 -3
- package/es/scenegraph/graphic/group.js.map +1 -1
- package/es/scenegraph/group-creater/cell-helper.js +1 -1
- package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/es/scenegraph/group-creater/progress/proxy.d.ts +1 -0
- package/es/scenegraph/group-creater/progress/proxy.js +12 -0
- package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +3 -3
- package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
- package/es/scenegraph/layout/compute-col-width.js +28 -17
- package/es/scenegraph/layout/compute-col-width.js.map +1 -1
- package/es/scenegraph/layout/compute-row-height.js +21 -7
- package/es/scenegraph/layout/compute-row-height.js.map +1 -1
- package/es/scenegraph/layout/update-row.js +8 -3
- package/es/scenegraph/layout/update-row.js.map +1 -1
- package/es/scenegraph/layout/update-width.js +2 -2
- package/es/scenegraph/layout/update-width.js.map +1 -1
- package/es/scenegraph/refresh-node/update-chart.js +5 -1
- package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/es/scenegraph/scenegraph.js +2 -2
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/scenegraph/style/frame-border.js +25 -11
- package/es/scenegraph/style/frame-border.js.map +1 -1
- package/package.json +5 -5
|
@@ -9,27 +9,38 @@ const vrender_1 = require("@visactor/vrender"), vutils_1 = require("@visactor/vu
|
|
|
9
9
|
function createFrameBorder(group, frameTheme, role, strokeArray, justForXYPosition) {
|
|
10
10
|
var _a, _b, _c, _d;
|
|
11
11
|
if (!frameTheme) return;
|
|
12
|
-
const isTableGroup = "table" === role, {shadowBlur: shadowBlur, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowColor: shadowColor, cornerRadius: cornerRadius, borderColor: borderColor, borderLineWidth: borderLineWidth, borderLineDash: borderLineDash} = frameTheme
|
|
12
|
+
const isTableGroup = "table" === role, {shadowBlur: shadowBlur, shadowOffsetX: shadowOffsetX, shadowOffsetY: shadowOffsetY, shadowColor: shadowColor, cornerRadius: cornerRadius, borderColor: borderColor, borderLineWidth: borderLineWidth, borderLineDash: borderLineDash} = frameTheme;
|
|
13
|
+
let hasShadow = !1;
|
|
14
|
+
const groupAttributes = {}, rectAttributes = {
|
|
13
15
|
pickable: !1
|
|
14
16
|
};
|
|
15
17
|
shadowBlur && isTableGroup && (rectAttributes.shadowBlur = shadowBlur, rectAttributes.shadowOffsetX = shadowOffsetX,
|
|
16
18
|
rectAttributes.shadowOffsetY = shadowOffsetY, rectAttributes.shadowColor = shadowColor,
|
|
17
19
|
rectAttributes.stroke = !0, rectAttributes.stroke = shadowColor, rectAttributes.lineWidth = 1,
|
|
18
|
-
|
|
19
|
-
rectAttributes.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
hasShadow = !0), borderLineWidth && (rectAttributes.stroke = !0, rectAttributes.fill = !1,
|
|
21
|
+
rectAttributes.stroke = getStroke(borderColor, strokeArray), rectAttributes.lineWidth = borderLineWidth,
|
|
22
|
+
borderLineDash && (rectAttributes.lineDash = borderLineDash), rectAttributes.lineCap = "square"),
|
|
23
|
+
Array.isArray(borderColor) && (rectAttributes.strokeArrayColor = (0, padding_1.getQuadProps)(borderColor)),
|
|
24
|
+
Array.isArray(borderLineWidth) && (rectAttributes.strokeArrayWidth = (0, padding_1.getQuadProps)(borderLineWidth),
|
|
25
|
+
rectAttributes.lineWidth = 1), cornerRadius && (rectAttributes.cornerRadius = cornerRadius,
|
|
24
26
|
groupAttributes.cornerRadius = cornerRadius);
|
|
25
27
|
const borderTop = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[0] : null !== (_a = rectAttributes.lineWidth) && void 0 !== _a ? _a : 0, borderRight = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[1] : null !== (_b = rectAttributes.lineWidth) && void 0 !== _b ? _b : 0, borderBottom = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[2] : null !== (_c = rectAttributes.lineWidth) && void 0 !== _c ? _c : 0, borderLeft = rectAttributes.strokeArrayWidth ? rectAttributes.strokeArrayWidth[3] : null !== (_d = rectAttributes.lineWidth) && void 0 !== _d ? _d : 0;
|
|
26
28
|
if (group.setAttributes(groupAttributes), !justForXYPosition && rectAttributes.stroke) if (rectAttributes.x = borderLeft / 2,
|
|
27
29
|
rectAttributes.y = borderTop / 2, rectAttributes.pickable = !1, isTableGroup) {
|
|
28
|
-
|
|
29
|
-
rectAttributes.width = group.attribute.width + borderLeft / 2 + borderRight / 2,
|
|
30
|
-
rectAttributes.height = group.attribute.height + borderTop / 2 + borderBottom / 2
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
let shadowRect, borderRect;
|
|
31
|
+
rectAttributes.x = -borderLeft / 2, rectAttributes.y = -borderTop / 2, rectAttributes.width = group.attribute.width + borderLeft / 2 + borderRight / 2,
|
|
32
|
+
rectAttributes.height = group.attribute.height + borderTop / 2 + borderBottom / 2,
|
|
33
|
+
hasShadow ? (rectAttributes.fill = "white", rectAttributes.notAdjustPos = !0, shadowRect = (0,
|
|
34
|
+
vrender_1.createRect)(rectAttributes), borderRect = (0, vrender_1.createGroup)({
|
|
35
|
+
x: group.attribute.x,
|
|
36
|
+
y: group.attribute.y,
|
|
37
|
+
width: group.attribute.width,
|
|
38
|
+
height: group.attribute.height,
|
|
39
|
+
fill: "red",
|
|
40
|
+
cornerRadius: group.attribute.cornerRadius,
|
|
41
|
+
globalCompositeOperation: "destination-out"
|
|
42
|
+
}), borderRect.name = "table-border-rect", borderRect.addChild(shadowRect)) : (borderRect = (0,
|
|
43
|
+
vrender_1.createRect)(rectAttributes), borderRect.name = "table-border-rect"), group.parent.insertBefore(borderRect, group),
|
|
33
44
|
group.border = borderRect;
|
|
34
45
|
} else {
|
|
35
46
|
rectAttributes.width = group.attribute.width - borderLeft / 2 - borderRight / 2,
|
|
@@ -59,6 +70,9 @@ function updateFrameBorderSize(group) {
|
|
|
59
70
|
group.border.setAttributes({
|
|
60
71
|
width: group.attribute.width - borderLeft / 2 - borderRight / 2,
|
|
61
72
|
height: group.attribute.height - borderTop / 2 - borderBottom / 2
|
|
73
|
+
}), "group" === group.border.type && group.border.firstChild.setAttributes({
|
|
74
|
+
width: group.attribute.width,
|
|
75
|
+
height: group.attribute.height
|
|
62
76
|
});
|
|
63
77
|
}
|
|
64
78
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/scenegraph/style/frame-border.ts"],"names":[],"mappings":";;;AACA,+CAA+C;AAG/C,6CAA2C;AAC3C,8CAAgD;AAUhD,SAAgB,iBAAiB,CAC/B,KAAY,EACZ,UAAuC,EACvC,IAAY,EACZ,WAA6D,EAC7D,iBAA2B;;IAE3B,IAAI,CAAC,UAAU,EAAE;QACf,OAAO;KACR;IAED,MAAM,YAAY,GAAG,IAAI,KAAK,OAAO,CAAC;IAEtC,MAAM,EACJ,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACf,GAAG,UAAU,CAAC;IAEf,MAAM,eAAe,GAA2B,EAAE,CAAC;IACnD,MAAM,cAAc,GAA0B;QAC5C,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,IAAI,UAAU,IAAI,YAAY,EAAE;QAE9B,cAAc,CAAC,UAAU,GAAG,UAAU,CAAC;QACvC,cAAc,CAAC,aAAa,GAAG,aAAa,CAAC;QAC7C,cAAc,CAAC,aAAa,GAAG,aAAa,CAAC;QAC7C,cAAc,CAAC,WAAW,GAAG,WAAW,CAAC;QACzC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC;QAC7B,cAAc,CAAC,MAAM,GAAG,WAAW,CAAC;QACpC,cAAc,CAAC,SAAS,GAAG,CAAC,CAAC;QAE7B,cAAc,CAAC,IAAI,GAAG,IAAI,CAAC;QAC3B,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC;KACnC;IAGD,IAAI,eAAe,EAAE;QACnB,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC;QAC7B,cAAc,CAAC,IAA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CAAC;AACL,CAAC;AArBD,sDAqBC","file":"frame-border.js","sourcesContent":["import type { IGroupGraphicAttribute, IRectGraphicAttribute } from '@visactor/vrender';\nimport { createRect } from '@visactor/vrender';\nimport type { TableFrameStyle } from '../../ts-types';\nimport type { Group } from '../graphic/group';\nimport { isArray } from '@visactor/vutils';\nimport { getQuadProps } from '../utils/padding';\n\n/**\n * @description: create frame border\n * @param {Group} group\n * @param {TableFrameStyle} frameTheme\n * @param {string} role\n * @param {[boolean, boolean, boolean, boolean]} strokeArray\n * @return {*}\n */\nexport function createFrameBorder(\n group: Group,\n frameTheme: TableFrameStyle | undefined,\n role: string,\n strokeArray: [boolean, boolean, boolean, boolean] | undefined, // to do 处理成0b001111形式\n justForXYPosition?: boolean\n) {\n if (!frameTheme) {\n return;\n }\n\n const isTableGroup = role === 'table';\n\n const {\n shadowBlur,\n shadowOffsetX,\n shadowOffsetY,\n shadowColor,\n cornerRadius,\n borderColor,\n borderLineWidth,\n borderLineDash\n } = frameTheme;\n\n const groupAttributes: IGroupGraphicAttribute = {};\n const rectAttributes: IRectGraphicAttribute = {\n pickable: false\n };\n // 处理shadow\n if (shadowBlur && isTableGroup) {\n // 只有table才能配置shadow\n rectAttributes.shadowBlur = shadowBlur;\n rectAttributes.shadowOffsetX = shadowOffsetX;\n rectAttributes.shadowOffsetY = shadowOffsetY;\n rectAttributes.shadowColor = shadowColor;\n rectAttributes.stroke = true;\n rectAttributes.stroke = shadowColor;\n rectAttributes.lineWidth = 1;\n\n rectAttributes.fill = true;\n rectAttributes.fillOpacity = 0.01;\n }\n\n // 处理边框\n if (borderLineWidth) {\n rectAttributes.stroke = true;\n rectAttributes.fill = false;\n rectAttributes.stroke = getStroke(borderColor, strokeArray);\n rectAttributes.lineWidth = borderLineWidth as number;\n borderLineDash && (rectAttributes.lineDash = borderLineDash as number[]);\n rectAttributes.lineCap = 'square';\n }\n\n if (Array.isArray(borderColor)) {\n (rectAttributes as any).strokeArrayColor = getQuadProps(borderColor as any);\n }\n if (Array.isArray(borderLineWidth)) {\n (rectAttributes as any).strokeArrayWidth = getQuadProps(borderLineWidth);\n (rectAttributes as any).lineWidth = 1;\n }\n\n if (cornerRadius) {\n rectAttributes.cornerRadius = cornerRadius;\n groupAttributes.cornerRadius = cornerRadius;\n }\n\n const borderTop = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[0]\n : (rectAttributes.lineWidth as number) ?? 0;\n const borderRight = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[1]\n : (rectAttributes.lineWidth as number) ?? 0;\n const borderBottom = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[2]\n : (rectAttributes.lineWidth as number) ?? 0;\n const borderLeft = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[3]\n : (rectAttributes.lineWidth as number) ?? 0;\n\n // // 处理边框引起的宽度高度变化(只对最外层tableGroup生效)\n // if (isTableGroup && (rectAttributes.shadowBlur || rectAttributes.lineWidth)) {\n // const deltaX = (rectAttributes.shadowBlur ?? 0) + (borderLeft + borderRight) / 2;\n // const deltaY = (rectAttributes.shadowBlur ?? 0) + (borderTop + borderBottom) / 2;\n\n // groupAttributes.x = deltaX;\n // groupAttributes.y = deltaY;\n // // 宽度高度在tableNoFrameWidth&tableNoFrameHeight中处理\n // // groupAttributes.width = group.attribute.width - deltaX - deltaX;\n // // groupAttributes.height = group.attribute.height - deltaY - deltaY;\n // }\n group.setAttributes(groupAttributes);\n\n if (justForXYPosition) {\n return;\n }\n\n if (rectAttributes.stroke) {\n rectAttributes.x = borderLeft / 2;\n rectAttributes.y = borderTop / 2;\n rectAttributes.pickable = false;\n if (isTableGroup) {\n rectAttributes.x = group.attribute.x - borderLeft / 2;\n rectAttributes.y = group.attribute.y - borderTop / 2;\n rectAttributes.width = group.attribute.width + borderLeft / 2 + borderRight / 2;\n rectAttributes.height = group.attribute.height + borderTop / 2 + borderBottom / 2;\n const borderRect = createRect(rectAttributes);\n borderRect.name = 'table-border-rect';\n group.parent.insertBefore(borderRect, group);\n (group as any).border = borderRect;\n } else {\n // rectAttributes.x = rectAttributes.lineWidth / 2;\n // rectAttributes.y = rectAttributes.lineWidth / 2;\n rectAttributes.width = group.attribute.width - borderLeft / 2 - borderRight / 2;\n rectAttributes.height = group.attribute.height - borderTop / 2 - borderBottom / 2;\n const borderRect = createRect(rectAttributes);\n borderRect.name = 'border-rect';\n group.addChild(borderRect);\n (group as any).border = borderRect;\n }\n }\n}\n\n/**\n * @description: update frame border stroke atrribute\n * @param {Group} group\n * @param {TableFrameStyle} frameTheme\n * @param {array} strokeArray stroke boolean array\n * @return {*}\n */\nexport function updateFrameBorder(\n group: Group,\n frameTheme: TableFrameStyle | undefined,\n strokeArray: [boolean, boolean, boolean, boolean] // to do 处理成0b001111形式\n) {\n const { borderColor } = frameTheme;\n group.border?.setAttribute('stroke', getStroke(borderColor, strokeArray));\n}\n\nexport function getStroke(borderColor: string | string[], strokeArray: boolean[] | undefined) {\n let stroke: boolean | string | (boolean | string)[] = true;\n if (strokeArray && !isArray(borderColor)) {\n stroke = strokeArray.map(stroke => {\n if (stroke) {\n return borderColor;\n }\n return false;\n });\n } else if (strokeArray) {\n stroke = strokeArray;\n } else if (!strokeArray && !isArray(borderColor)) {\n stroke = borderColor;\n } else if (isArray(borderColor)) {\n stroke = true;\n }\n return stroke;\n}\n\n/**\n * @description: update frame border size when group size change\n * @param {Group} group\n * @return {*}\n */\nexport function updateFrameBorderSize(group: Group) {\n if (!group.border) {\n return;\n }\n const borderTop = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[0]\n : (group.border.attribute.lineWidth as number) ?? 0;\n const borderRight = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[1]\n : (group.border.attribute.lineWidth as number) ?? 0;\n const borderBottom = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[2]\n : (group.border.attribute.lineWidth as number) ?? 0;\n const borderLeft = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[3]\n : (group.border.attribute.lineWidth as number) ?? 0;\n\n group.border.setAttributes({\n width: group.attribute.width - borderLeft / 2 - borderRight / 2,\n height: group.attribute.height - borderTop / 2 - borderBottom / 2\n });\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/scenegraph/style/frame-border.ts"],"names":[],"mappings":";;;AACA,+CAA4D;AAG5D,6CAA2C;AAC3C,8CAAgD;AAUhD,SAAgB,iBAAiB,CAC/B,KAAY,EACZ,UAAuC,EACvC,IAAY,EACZ,WAA6D,EAC7D,iBAA2B;;IAE3B,IAAI,CAAC,UAAU,EAAE;QACf,OAAO;KACR;IAED,MAAM,YAAY,GAAG,IAAI,KAAK,OAAO,CAAC;IAEtC,MAAM,EACJ,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACf,GAAG,UAAU,CAAC;IAEf,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,MAAM,eAAe,GAA2B,EAAE,CAAC;IACnD,MAAM,cAAc,GAA0B;QAC5C,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,IAAI,UAAU,IAAI,YAAY,EAAE;QAE9B,cAAc,CAAC,UAAU,GAAG,UAAU,CAAC;QACvC,cAAc,CAAC,aAAa,GAAG,aAAa,CAAC;QAC7C,cAAc,CAAC,aAAa,GAAG,aAAa,CAAC;QAC7C,cAAc,CAAC,WAAW,GAAG,WAAW,CAAC;QACzC,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC;QAC7B,cAAc,CAAC,MAAM,GAAG,WAAW,CAAC;QACpC,cAAc,CAAC,SAAS,GAAG,CAAC,CAAC;QAC7B,SAAS,GAAG,IAAI,CAAC;KAIlB;IAGD,IAAI,eAAe,EAAE;QACnB,cAAc,CAAC,MAAM,GAAG,IAAI,CAAC;QA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C,CAAE,KAAK,CAAC,MAAM,CAAC,SAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC,MAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,SAAoB,mCAAI,CAAC,CAAC;IACtD,MAAM,UAAU,GAAI,KAAK,CAAC,MAAM,CAAC,SAAiB,CAAC,gBAAgB;QACjE,CAAC,CAAE,KAAK,CAAC,MAAM,CAAC,SAAiB,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACrD,CAAC,CAAC,MAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,SAAoB,mCAAI,CAAC,CAAC;IAEtD,KAAK,CAAC,MAAM,CAAC,aAAa,CAAC;QACzB,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK,GAAG,UAAU,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC;QAC/D,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,SAAS,GAAG,CAAC,GAAG,YAAY,GAAG,CAAC;KAClE,CAAC,CAAC;IAEH,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE;QAChC,KAAK,CAAC,MAAM,CAAC,UAAoB,CAAC,aAAa,CAAC;YAC/C,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,KAAK;YAC5B,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,MAAM;SAC/B,CAAC,CAAC;KACJ;AACH,CAAC;AA5BD,sDA4BC","file":"frame-border.js","sourcesContent":["import type { IGroupGraphicAttribute, IRect, IRectGraphicAttribute } from '@visactor/vrender';\nimport { createGroup, createRect } from '@visactor/vrender';\nimport type { TableFrameStyle } from '../../ts-types';\nimport type { Group } from '../graphic/group';\nimport { isArray } from '@visactor/vutils';\nimport { getQuadProps } from '../utils/padding';\n\n/**\n * @description: create frame border\n * @param {Group} group\n * @param {TableFrameStyle} frameTheme\n * @param {string} role\n * @param {[boolean, boolean, boolean, boolean]} strokeArray\n * @return {*}\n */\nexport function createFrameBorder(\n group: Group,\n frameTheme: TableFrameStyle | undefined,\n role: string,\n strokeArray: [boolean, boolean, boolean, boolean] | undefined, // to do 处理成0b001111形式\n justForXYPosition?: boolean\n) {\n if (!frameTheme) {\n return;\n }\n\n const isTableGroup = role === 'table';\n\n const {\n shadowBlur,\n shadowOffsetX,\n shadowOffsetY,\n shadowColor,\n cornerRadius,\n borderColor,\n borderLineWidth,\n borderLineDash\n } = frameTheme;\n\n let hasShadow = false;\n const groupAttributes: IGroupGraphicAttribute = {};\n const rectAttributes: IRectGraphicAttribute = {\n pickable: false\n };\n // 处理shadow\n if (shadowBlur && isTableGroup) {\n // 只有table才能配置shadow\n rectAttributes.shadowBlur = shadowBlur;\n rectAttributes.shadowOffsetX = shadowOffsetX;\n rectAttributes.shadowOffsetY = shadowOffsetY;\n rectAttributes.shadowColor = shadowColor;\n rectAttributes.stroke = true;\n rectAttributes.stroke = shadowColor;\n rectAttributes.lineWidth = 1;\n hasShadow = true;\n\n // rectAttributes.fill = true;\n // rectAttributes.fillOpacity = 0.01;\n }\n\n // 处理边框\n if (borderLineWidth) {\n rectAttributes.stroke = true;\n rectAttributes.fill = false;\n rectAttributes.stroke = getStroke(borderColor, strokeArray);\n rectAttributes.lineWidth = borderLineWidth as number;\n borderLineDash && (rectAttributes.lineDash = borderLineDash as number[]);\n rectAttributes.lineCap = 'square';\n }\n\n if (Array.isArray(borderColor)) {\n (rectAttributes as any).strokeArrayColor = getQuadProps(borderColor as any);\n }\n if (Array.isArray(borderLineWidth)) {\n (rectAttributes as any).strokeArrayWidth = getQuadProps(borderLineWidth);\n (rectAttributes as any).lineWidth = 1;\n }\n\n if (cornerRadius) {\n rectAttributes.cornerRadius = cornerRadius;\n groupAttributes.cornerRadius = cornerRadius;\n }\n\n const borderTop = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[0]\n : (rectAttributes.lineWidth as number) ?? 0;\n const borderRight = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[1]\n : (rectAttributes.lineWidth as number) ?? 0;\n const borderBottom = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[2]\n : (rectAttributes.lineWidth as number) ?? 0;\n const borderLeft = (rectAttributes as any).strokeArrayWidth\n ? (rectAttributes as any).strokeArrayWidth[3]\n : (rectAttributes.lineWidth as number) ?? 0;\n\n // // 处理边框引起的宽度高度变化(只对最外层tableGroup生效)\n // if (isTableGroup && (rectAttributes.shadowBlur || rectAttributes.lineWidth)) {\n // const deltaX = (rectAttributes.shadowBlur ?? 0) + (borderLeft + borderRight) / 2;\n // const deltaY = (rectAttributes.shadowBlur ?? 0) + (borderTop + borderBottom) / 2;\n\n // groupAttributes.x = deltaX;\n // groupAttributes.y = deltaY;\n // // 宽度高度在tableNoFrameWidth&tableNoFrameHeight中处理\n // // groupAttributes.width = group.attribute.width - deltaX - deltaX;\n // // groupAttributes.height = group.attribute.height - deltaY - deltaY;\n // }\n group.setAttributes(groupAttributes);\n\n if (justForXYPosition) {\n return;\n }\n\n if (rectAttributes.stroke) {\n rectAttributes.x = borderLeft / 2;\n rectAttributes.y = borderTop / 2;\n rectAttributes.pickable = false;\n if (isTableGroup) {\n rectAttributes.x = -borderLeft / 2;\n rectAttributes.y = -borderTop / 2;\n rectAttributes.width = group.attribute.width + borderLeft / 2 + borderRight / 2;\n rectAttributes.height = group.attribute.height + borderTop / 2 + borderBottom / 2;\n\n let shadowRect;\n let borderRect;\n if (hasShadow) {\n rectAttributes.fill = 'white';\n (rectAttributes as any).notAdjustPos = true;\n // first draw\n shadowRect = createRect(rectAttributes);\n // second draw\n borderRect = createGroup({\n x: group.attribute.x,\n y: group.attribute.y,\n width: group.attribute.width,\n height: group.attribute.height,\n fill: 'red',\n cornerRadius: group.attribute.cornerRadius,\n globalCompositeOperation: 'destination-out'\n });\n borderRect.name = 'table-border-rect';\n borderRect.addChild(shadowRect);\n } else {\n borderRect = createRect(rectAttributes);\n borderRect.name = 'table-border-rect';\n }\n\n group.parent.insertBefore(borderRect, group);\n (group as any).border = borderRect;\n } else {\n // rectAttributes.x = rectAttributes.lineWidth / 2;\n // rectAttributes.y = rectAttributes.lineWidth / 2;\n rectAttributes.width = group.attribute.width - borderLeft / 2 - borderRight / 2;\n rectAttributes.height = group.attribute.height - borderTop / 2 - borderBottom / 2;\n const borderRect = createRect(rectAttributes);\n borderRect.name = 'border-rect';\n group.addChild(borderRect);\n (group as any).border = borderRect;\n }\n }\n}\n\n/**\n * @description: update frame border stroke atrribute\n * @param {Group} group\n * @param {TableFrameStyle} frameTheme\n * @param {array} strokeArray stroke boolean array\n * @return {*}\n */\nexport function updateFrameBorder(\n group: Group,\n frameTheme: TableFrameStyle | undefined,\n strokeArray: [boolean, boolean, boolean, boolean] // to do 处理成0b001111形式\n) {\n const { borderColor } = frameTheme;\n group.border?.setAttribute('stroke', getStroke(borderColor, strokeArray));\n}\n\nexport function getStroke(borderColor: string | string[], strokeArray: boolean[] | undefined) {\n let stroke: boolean | string | (boolean | string)[] = true;\n if (strokeArray && !isArray(borderColor)) {\n stroke = strokeArray.map(stroke => {\n if (stroke) {\n return borderColor;\n }\n return false;\n });\n } else if (strokeArray) {\n stroke = strokeArray;\n } else if (!strokeArray && !isArray(borderColor)) {\n stroke = borderColor;\n } else if (isArray(borderColor)) {\n stroke = true;\n }\n return stroke;\n}\n\n/**\n * @description: update frame border size when group size change\n * @param {Group} group\n * @return {*}\n */\nexport function updateFrameBorderSize(group: Group) {\n if (!group.border) {\n return;\n }\n const borderTop = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[0]\n : (group.border.attribute.lineWidth as number) ?? 0;\n const borderRight = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[1]\n : (group.border.attribute.lineWidth as number) ?? 0;\n const borderBottom = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[2]\n : (group.border.attribute.lineWidth as number) ?? 0;\n const borderLeft = (group.border.attribute as any).strokeArrayWidth\n ? (group.border.attribute as any).strokeArrayWidth[3]\n : (group.border.attribute.lineWidth as number) ?? 0;\n\n group.border.setAttributes({\n width: group.attribute.width - borderLeft / 2 - borderRight / 2,\n height: group.attribute.height - borderTop / 2 - borderBottom / 2\n });\n\n if (group.border.type === 'group') {\n (group.border.firstChild as IRect).setAttributes({\n width: group.attribute.width,\n height: group.attribute.height\n });\n }\n}\n"]}
|