@visactor/vrender-components 0.16.9-alpha.0 → 0.16.9
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/checkbox/checkbox.d.ts +2 -1
- package/cjs/checkbox/checkbox.js +23 -9
- package/cjs/checkbox/checkbox.js.map +1 -1
- package/cjs/checkbox/type.d.ts +5 -1
- package/cjs/checkbox/type.js.map +1 -1
- package/cjs/core/base.js +4 -3
- package/cjs/core/base.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/label/rect.js +27 -1
- package/cjs/label/rect.js.map +1 -1
- package/cjs/label/type.d.ts +1 -1
- package/cjs/label/type.js.map +1 -1
- package/dist/index.js +71 -16
- package/dist/index.min.js +1 -1
- package/es/checkbox/checkbox.d.ts +2 -1
- package/es/checkbox/checkbox.js +22 -8
- package/es/checkbox/checkbox.js.map +1 -1
- package/es/checkbox/type.d.ts +5 -1
- package/es/checkbox/type.js.map +1 -1
- package/es/core/base.js +1 -1
- package/es/core/base.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/label/rect.js +27 -1
- package/es/label/rect.js.map +1 -1
- package/es/label/type.d.ts +1 -1
- package/es/label/type.js.map +1 -1
- package/package.json +6 -6
|
@@ -4,7 +4,8 @@ import { Image, Rect, WrapText } from '@visactor/vrender-core';
|
|
|
4
4
|
export declare class CheckBox extends AbstractComponent<Required<CheckboxAttributes>> {
|
|
5
5
|
static defaultAttributes: Partial<CheckboxAttributes>;
|
|
6
6
|
_box: Rect;
|
|
7
|
-
|
|
7
|
+
_checkIcon: Image;
|
|
8
|
+
_indeterminateIcon: Image;
|
|
8
9
|
_text: WrapText;
|
|
9
10
|
constructor(attributes: CheckboxAttributes);
|
|
10
11
|
render(): void;
|
package/cjs/checkbox/checkbox.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.CheckBox = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), vrender_core_1 = require("@visactor/vrender-core"),
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), vrender_core_1 = require("@visactor/vrender-core"), checkSvg = '<svg width="200" height="200" viewBox="0 0 1024 1024" fill="#fff" xmlns="http://www.w3.org/2000/svg"><path d="M877.44815445 206.10060629a64.72691371 64.72691371 0 0 0-95.14856334 4.01306852L380.73381888 685.46812814 235.22771741 533.48933518a64.72691371 64.72691371 0 0 0-92.43003222-1.03563036l-45.82665557 45.82665443a64.72691371 64.72691371 0 0 0-0.90617629 90.61767965l239.61903446 250.10479331a64.72691371 64.72691371 0 0 0 71.19960405 15.14609778 64.33855261 64.33855261 0 0 0 35.08198741-21.23042702l36.24707186-42.71976334 40.5190474-40.77795556-3.36579926-3.49525333 411.40426297-486.74638962a64.72691371 64.72691371 0 0 0-3.88361443-87.64024149l-45.3088404-45.43829334z"></path></svg>', indeterminateSvg = '<svg width="200" height="200" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none"><path stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="5" d="M5 12h14"/></svg>';
|
|
8
8
|
|
|
9
9
|
class CheckBox extends base_1.AbstractComponent {
|
|
10
10
|
constructor(attributes) {
|
|
@@ -17,18 +17,26 @@ class CheckBox extends base_1.AbstractComponent {
|
|
|
17
17
|
this.removeAllChild(), this.renderBox(), this.renderIcon(), this.renderText(), this.layout();
|
|
18
18
|
}
|
|
19
19
|
renderBox() {
|
|
20
|
-
this._box = new vrender_core_1.Rect((0, vutils_1.merge)({}, this.attribute.box))
|
|
21
|
-
this.attribute.checked
|
|
20
|
+
this._box = new vrender_core_1.Rect((0, vutils_1.merge)({}, this.attribute.box));
|
|
21
|
+
const isCheckedOrIndeterminate = this.attribute.checked || this.attribute.indeterminate;
|
|
22
|
+
isCheckedOrIndeterminate && this.attribute.disabled ? this._box.setAttributes({
|
|
22
23
|
fill: this.attribute.box.disableCheckedFill,
|
|
23
24
|
stroke: this.attribute.box.disableCheckedStroke
|
|
24
|
-
}) :
|
|
25
|
+
}) : isCheckedOrIndeterminate && this._box.setAttributes({
|
|
25
26
|
fill: this.attribute.box.checkedFill,
|
|
26
27
|
stroke: this.attribute.box.checkedStroke
|
|
27
28
|
}), this.appendChild(this._box);
|
|
28
29
|
}
|
|
29
30
|
renderIcon() {
|
|
30
|
-
this.
|
|
31
|
-
|
|
31
|
+
this._checkIcon = new vrender_core_1.Image((0, vutils_1.merge)({
|
|
32
|
+
image: this.attribute.icon.checkIconImage
|
|
33
|
+
}, this.attribute.icon)), this.appendChild(this._checkIcon), this._indeterminateIcon = new vrender_core_1.Image((0,
|
|
34
|
+
vutils_1.merge)({
|
|
35
|
+
image: this.attribute.icon.indeterminateIconImage
|
|
36
|
+
}, this.attribute.icon)), this.appendChild(this._indeterminateIcon), this.attribute.checked ? (this._checkIcon.setAttribute("visible", !0),
|
|
37
|
+
this._indeterminateIcon.setAttribute("visible", !1)) : this.attribute.indeterminate ? (this._checkIcon.setAttribute("visible", !1),
|
|
38
|
+
this._indeterminateIcon.setAttribute("visible", !0)) : (this._checkIcon.setAttribute("visible", !1),
|
|
39
|
+
this._indeterminateIcon.setAttribute("visible", !1));
|
|
32
40
|
}
|
|
33
41
|
renderText() {
|
|
34
42
|
this._text = new vrender_core_1.WrapText((0, vutils_1.merge)({}, this.attribute.text)),
|
|
@@ -43,7 +51,10 @@ class CheckBox extends base_1.AbstractComponent {
|
|
|
43
51
|
this._box.setAttributes({
|
|
44
52
|
x: boxX,
|
|
45
53
|
y: boxY
|
|
46
|
-
}), this.
|
|
54
|
+
}), this._checkIcon.setAttributes({
|
|
55
|
+
x: iconX,
|
|
56
|
+
y: iconY
|
|
57
|
+
}), this._indeterminateIcon.setAttributes({
|
|
47
58
|
x: iconX,
|
|
48
59
|
y: iconY
|
|
49
60
|
}), this._text.setAttributes({
|
|
@@ -54,7 +65,8 @@ class CheckBox extends base_1.AbstractComponent {
|
|
|
54
65
|
handleClick() {
|
|
55
66
|
var _a;
|
|
56
67
|
if (this.attribute.disabled) return;
|
|
57
|
-
this.attribute.checked ? this.setAttribute("checked", !1) : this.setAttribute("checked", !0)
|
|
68
|
+
this.attribute.checked ? (this.setAttribute("checked", !1), this.setAttribute("indeterminate", !1)) : (this.setAttribute("checked", !0),
|
|
69
|
+
this.setAttribute("indeterminate", !1));
|
|
58
70
|
const changeEvent = new vrender_core_1.CustomEvent("checkbox_state_change", {
|
|
59
71
|
eventType: "checkbox_state_change",
|
|
60
72
|
checked: this.attribute.checked
|
|
@@ -68,6 +80,7 @@ exports.CheckBox = CheckBox, CheckBox.defaultAttributes = {
|
|
|
68
80
|
interactive: !0,
|
|
69
81
|
disabled: !1,
|
|
70
82
|
checked: !1,
|
|
83
|
+
indeterminate: !1,
|
|
71
84
|
cursor: "pointer",
|
|
72
85
|
disableCursor: "not-allowed",
|
|
73
86
|
spaceBetweenTextAndIcon: 8,
|
|
@@ -80,7 +93,8 @@ exports.CheckBox = CheckBox, CheckBox.defaultAttributes = {
|
|
|
80
93
|
pickable: !1
|
|
81
94
|
},
|
|
82
95
|
icon: {
|
|
83
|
-
|
|
96
|
+
checkIconImage: checkSvg,
|
|
97
|
+
indeterminateIconImage: indeterminateSvg,
|
|
84
98
|
width: 10,
|
|
85
99
|
height: 10,
|
|
86
100
|
pickable: !1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/checkbox/checkbox.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,uCAAiD;AAEjD,yDAA4E;AAE5E,MAAM,GAAG,GACP,wrBAAwrB,CAAC;AAE3rB,MAAa,QAAS,SAAQ,wBAA+C;IAwC3E,YAAY,UAA8B;QACxC,KAAK,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,C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ACD,GAAG,EAAE;QACH,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,CAAC;QACf,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,kBAAkB;QAC1B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE,kBAAkB;QAC/B,aAAa,EAAE,kBAAkB;QACjC,kBAAkB,EAAE,oBAAoB;QACxC,oBAAoB,EAAE,oBAAoB;QAC1C,QAAQ,EAAE,KAAK;KAChB;CACF,CAAC","file":"checkbox.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { CheckboxAttributes } from './type';\nimport { CustomEvent, Image, Rect, WrapText } from '@visactor/vrender-core';\n\nconst svg =\n '<svg width=\"200\" height=\"200\" viewBox=\"0 0 1024 1024\" fill=\"#fff\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M877.44815445 206.10060629a64.72691371 64.72691371 0 0 0-95.14856334 4.01306852L380.73381888 685.46812814 235.22771741 533.48933518a64.72691371 64.72691371 0 0 0-92.43003222-1.03563036l-45.82665557 45.82665443a64.72691371 64.72691371 0 0 0-0.90617629 90.61767965l239.61903446 250.10479331a64.72691371 64.72691371 0 0 0 71.19960405 15.14609778 64.33855261 64.33855261 0 0 0 35.08198741-21.23042702l36.24707186-42.71976334 40.5190474-40.77795556-3.36579926-3.49525333 411.40426297-486.74638962a64.72691371 64.72691371 0 0 0-3.88361443-87.64024149l-45.3088404-45.43829334z\"></path></svg>';\n\nexport class CheckBox extends AbstractComponent<Required<CheckboxAttributes>> {\n static defaultAttributes: Partial<CheckboxAttributes> = {\n interactive: true,\n disabled: false,\n checked: false,\n cursor: 'pointer',\n disableCursor: 'not-allowed',\n spaceBetweenTextAndIcon: 8,\n text: {\n text: 'text',\n fontSize: 14,\n fill: '#000',\n disableFill: 'rgb(201,205,212)',\n textBaseline: 'top',\n pickable: false\n },\n icon: {\n image: svg,\n width: 10,\n height: 10,\n pickable: false\n },\n box: {\n width: 14,\n height: 14,\n cornerRadius: 2,\n fill: '#fff',\n stroke: 'rgb(229,230,235)',\n disableFill: 'rgb(242,243,245)',\n checkedFill: 'rgb(22, 93, 255)',\n checkedStroke: 'rgb(22, 93, 255)',\n disableCheckedFill: 'rgb(148, 191, 255)',\n disableCheckedStroke: 'rgb(148, 191, 255)',\n pickable: false\n }\n };\n _box: Rect;\n _icon: Image;\n _text: WrapText;\n\n constructor(attributes: CheckboxAttributes) {\n super(merge({}, CheckBox.defaultAttributes, attributes));\n this.renderGroup();\n\n this.onBeforeAttributeUpdate = (val: any, attributes: any, key: null | string | string[]) => {\n if ('interactive' in val) {\n this.setAttribute('pickable', val.interactive);\n }\n if ('disabled' in val) {\n this.setAttribute('cursor', val.disable ? this.attribute.disableCursor : this.attribute.cursor);\n }\n return undefined;\n };\n\n this.addEventListener('click', this.handleClick);\n }\n\n render() {\n this.removeAllChild();\n\n this.renderBox();\n this.renderIcon();\n this.renderText();\n this.layout();\n }\n\n renderBox() {\n this._box = new Rect(merge({}, this.attribute.box));\n if (this.attribute.checked && this.attribute.disabled) {\n this._box.setAttributes({\n fill: this.attribute.box.disableCheckedFill,\n stroke: this.attribute.box.disableCheckedStroke\n });\n } else if (this.attribute.checked) {\n this._box.setAttributes({\n fill: this.attribute.box.checkedFill,\n stroke: this.attribute.box.checkedStroke\n });\n }\n this.appendChild(this._box);\n }\n\n renderIcon() {\n this._icon = new Image(merge({}, this.attribute.icon));\n if (!this.attribute.checked) {\n this._icon.setAttribute('visible', false);\n }\n this.appendChild(this._icon);\n }\n\n renderText() {\n this._text = new WrapText(merge({}, this.attribute.text));\n if (this.attribute.disabled) {\n this._text.setAttribute('fill', this.attribute.text.disableFill);\n }\n this.appendChild(this._text);\n }\n\n renderGroup() {\n if (!this.attribute.interactive) {\n this.setAttribute('pickable', false);\n }\n if (this.attribute.disabled) {\n this.setAttribute('cursor', this.attribute.disableCursor);\n }\n }\n\n layout() {\n const boxHeight = this.attribute.box.height;\n const iconHeight = this.attribute.icon.height;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(boxHeight, iconHeight, textHeight);\n const boxY = maxHeight / 2 - boxHeight / 2;\n const iconY = maxHeight / 2 - iconHeight / 2;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const boxWidth = this.attribute.box.width;\n const iconWidth = this.attribute.icon.width;\n const maxWidth = Math.max(boxWidth, iconWidth);\n const boxX = maxWidth / 2 - boxWidth / 2;\n const iconX = maxWidth / 2 - iconWidth / 2;\n const textX = maxWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._box.setAttributes({\n x: boxX,\n y: boxY\n });\n this._icon.setAttributes({\n x: iconX,\n y: iconY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n handleClick() {\n if (this.attribute.disabled) {\n return;\n } else if (this.attribute.checked) {\n this.setAttribute('checked', false);\n } else {\n this.setAttribute('checked', true);\n }\n const changeEvent = new CustomEvent('checkbox_state_change', {\n eventType: 'checkbox_state_change',\n checked: this.attribute.checked\n } as unknown) as any;\n changeEvent.manager = (this.stage as any)?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/checkbox/checkbox.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,uCAAiD;AAEjD,yDAA4E;AAE5E,MAAM,QAAQ,GACZ,wrBAAwrB,CAAC;AAE3rB,MAAM,gBAAgB,GACpB,2MAA2M,CAAC;AAE9M,MAAa,QAAS,SAAQ,wBAA+C;IA2C3E,YAAY,UAA8B;QACxC,KAAK,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW,EAAE,CAAC;QAEnB,IAAI,CAAC,uBAAuB,GAAG,CAAC,GAAQ,EAAE,UAAe,EAAE,GAA6B,EAAE,EAAE;YAC1F,IAAI,aAAa,IAAI,GAAG,EAAE;gBACxB,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nimport { AbstractComponent } from '../core/base';\nimport type { CheckboxAttributes } from './type';\nimport { CustomEvent, Image, Rect, WrapText } from '@visactor/vrender-core';\n\nconst checkSvg =\n '<svg width=\"200\" height=\"200\" viewBox=\"0 0 1024 1024\" fill=\"#fff\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M877.44815445 206.10060629a64.72691371 64.72691371 0 0 0-95.14856334 4.01306852L380.73381888 685.46812814 235.22771741 533.48933518a64.72691371 64.72691371 0 0 0-92.43003222-1.03563036l-45.82665557 45.82665443a64.72691371 64.72691371 0 0 0-0.90617629 90.61767965l239.61903446 250.10479331a64.72691371 64.72691371 0 0 0 71.19960405 15.14609778 64.33855261 64.33855261 0 0 0 35.08198741-21.23042702l36.24707186-42.71976334 40.5190474-40.77795556-3.36579926-3.49525333 411.40426297-486.74638962a64.72691371 64.72691371 0 0 0-3.88361443-87.64024149l-45.3088404-45.43829334z\"></path></svg>';\n\nconst indeterminateSvg =\n '<svg width=\"200\" height=\"200\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\"><path stroke=\"#fff\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"5\" d=\"M5 12h14\"/></svg>';\n\nexport class CheckBox extends AbstractComponent<Required<CheckboxAttributes>> {\n static defaultAttributes: Partial<CheckboxAttributes> = {\n interactive: true,\n disabled: false,\n checked: false,\n indeterminate: false,\n cursor: 'pointer',\n disableCursor: 'not-allowed',\n spaceBetweenTextAndIcon: 8,\n text: {\n text: 'text',\n fontSize: 14,\n fill: '#000',\n disableFill: 'rgb(201,205,212)',\n textBaseline: 'top',\n pickable: false\n },\n icon: {\n checkIconImage: checkSvg,\n indeterminateIconImage: indeterminateSvg,\n width: 10,\n height: 10,\n pickable: false\n },\n box: {\n width: 14,\n height: 14,\n cornerRadius: 2,\n fill: '#fff',\n stroke: 'rgb(229,230,235)',\n disableFill: 'rgb(242,243,245)',\n checkedFill: 'rgb(22, 93, 255)',\n checkedStroke: 'rgb(22, 93, 255)',\n disableCheckedFill: 'rgb(148, 191, 255)',\n disableCheckedStroke: 'rgb(148, 191, 255)',\n pickable: false\n }\n };\n _box: Rect;\n _checkIcon: Image;\n _indeterminateIcon: Image;\n _text: WrapText;\n\n constructor(attributes: CheckboxAttributes) {\n super(merge({}, CheckBox.defaultAttributes, attributes));\n this.renderGroup();\n\n this.onBeforeAttributeUpdate = (val: any, attributes: any, key: null | string | string[]) => {\n if ('interactive' in val) {\n this.setAttribute('pickable', val.interactive);\n }\n if ('disabled' in val) {\n this.setAttribute('cursor', val.disable ? this.attribute.disableCursor : this.attribute.cursor);\n }\n return undefined;\n };\n\n this.addEventListener('click', this.handleClick);\n }\n\n render() {\n this.removeAllChild();\n\n this.renderBox();\n this.renderIcon();\n this.renderText();\n this.layout();\n }\n\n renderBox() {\n this._box = new Rect(merge({}, this.attribute.box));\n const isCheckedOrIndeterminate = this.attribute.checked || this.attribute.indeterminate;\n if (isCheckedOrIndeterminate && this.attribute.disabled) {\n this._box.setAttributes({\n fill: this.attribute.box.disableCheckedFill,\n stroke: this.attribute.box.disableCheckedStroke\n });\n } else if (isCheckedOrIndeterminate) {\n this._box.setAttributes({\n fill: this.attribute.box.checkedFill,\n stroke: this.attribute.box.checkedStroke\n });\n }\n this.appendChild(this._box);\n }\n\n renderIcon() {\n this._checkIcon = new Image(merge({ image: this.attribute.icon.checkIconImage }, this.attribute.icon));\n this.appendChild(this._checkIcon);\n this._indeterminateIcon = new Image(\n merge(\n {\n image: this.attribute.icon.indeterminateIconImage\n },\n this.attribute.icon\n )\n );\n this.appendChild(this._indeterminateIcon);\n\n if (this.attribute.checked) {\n this._checkIcon.setAttribute('visible', true);\n this._indeterminateIcon.setAttribute('visible', false);\n } else if (this.attribute.indeterminate) {\n this._checkIcon.setAttribute('visible', false);\n this._indeterminateIcon.setAttribute('visible', true);\n } else {\n this._checkIcon.setAttribute('visible', false);\n this._indeterminateIcon.setAttribute('visible', false);\n }\n }\n\n renderText() {\n this._text = new WrapText(merge({}, this.attribute.text));\n if (this.attribute.disabled) {\n this._text.setAttribute('fill', this.attribute.text.disableFill);\n }\n this.appendChild(this._text);\n }\n\n renderGroup() {\n if (!this.attribute.interactive) {\n this.setAttribute('pickable', false);\n }\n if (this.attribute.disabled) {\n this.setAttribute('cursor', this.attribute.disableCursor);\n }\n }\n\n layout() {\n const boxHeight = this.attribute.box.height;\n const iconHeight = this.attribute.icon.height;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(boxHeight, iconHeight, textHeight);\n const boxY = maxHeight / 2 - boxHeight / 2;\n const iconY = maxHeight / 2 - iconHeight / 2;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const boxWidth = this.attribute.box.width;\n const iconWidth = this.attribute.icon.width;\n const maxWidth = Math.max(boxWidth, iconWidth);\n const boxX = maxWidth / 2 - boxWidth / 2;\n const iconX = maxWidth / 2 - iconWidth / 2;\n const textX = maxWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._box.setAttributes({\n x: boxX,\n y: boxY\n });\n this._checkIcon.setAttributes({\n x: iconX,\n y: iconY\n });\n this._indeterminateIcon.setAttributes({\n x: iconX,\n y: iconY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n handleClick() {\n if (this.attribute.disabled) {\n return;\n } else if (this.attribute.checked) {\n this.setAttribute('checked', false);\n this.setAttribute('indeterminate', false);\n } else {\n this.setAttribute('checked', true);\n this.setAttribute('indeterminate', false);\n }\n const changeEvent = new CustomEvent('checkbox_state_change', {\n eventType: 'checkbox_state_change',\n checked: this.attribute.checked\n } as unknown) as any;\n changeEvent.manager = (this.stage as any)?.eventSystem.manager;\n this.dispatchEvent(changeEvent);\n }\n}\n"]}
|
package/cjs/checkbox/type.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import type { Cursor, IColor, IGroupGraphicAttribute, IImageGraphicAttribute, IR
|
|
|
2
2
|
export type CheckboxText = {
|
|
3
3
|
disableFill?: IColor;
|
|
4
4
|
} & IWrapTextGraphicAttribute;
|
|
5
|
-
export type CheckboxIcon =
|
|
5
|
+
export type CheckboxIcon = {
|
|
6
|
+
checkIconImage?: string | HTMLImageElement | HTMLCanvasElement;
|
|
7
|
+
indeterminateIconImage?: string | HTMLImageElement | HTMLCanvasElement;
|
|
8
|
+
} & Omit<IImageGraphicAttribute, 'image'>;
|
|
6
9
|
export type CheckboxRect = {
|
|
7
10
|
disableFill?: IColor;
|
|
8
11
|
checkedFill?: IColor;
|
|
@@ -14,6 +17,7 @@ export type CheckboxAttributes = IGroupGraphicAttribute & {
|
|
|
14
17
|
interactive?: boolean;
|
|
15
18
|
disabled?: boolean;
|
|
16
19
|
checked?: boolean;
|
|
20
|
+
indeterminate?: boolean;
|
|
17
21
|
text?: CheckboxText;
|
|
18
22
|
icon?: CheckboxIcon;
|
|
19
23
|
box?: CheckboxRect;
|
package/cjs/checkbox/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/checkbox/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n Cursor,\n IColor,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n IRectGraphicAttribute,\n IWrapTextGraphicAttribute\n} from '@visactor/vrender-core';\n\nexport type CheckboxText = {\n disableFill?: IColor;\n} & IWrapTextGraphicAttribute;\n\nexport type CheckboxIcon =
|
|
1
|
+
{"version":3,"sources":["../src/checkbox/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n Cursor,\n IColor,\n IGroupGraphicAttribute,\n IImageGraphicAttribute,\n IRectGraphicAttribute,\n IWrapTextGraphicAttribute\n} from '@visactor/vrender-core';\n\nexport type CheckboxText = {\n disableFill?: IColor;\n} & IWrapTextGraphicAttribute;\n\nexport type CheckboxIcon = {\n checkIconImage?: string | HTMLImageElement | HTMLCanvasElement;\n indeterminateIconImage?: string | HTMLImageElement | HTMLCanvasElement;\n} & Omit<IImageGraphicAttribute, 'image'>;\n\nexport type CheckboxRect = {\n disableFill?: IColor;\n checkedFill?: IColor;\n checkedStroke?: IColor;\n disableCheckedFill?: IColor;\n disableCheckedStroke?: IColor;\n} & IRectGraphicAttribute;\n\nexport type CheckboxAttributes = IGroupGraphicAttribute & {\n interactive?: boolean;\n disabled?: boolean;\n checked?: boolean;\n indeterminate?: boolean;\n /**\n * 图例文字\n */\n text?: CheckboxText;\n /**\n * 图例选中图标\n */\n icon?: CheckboxIcon;\n /**\n * 图例选中图标\n */\n box?: CheckboxRect;\n disableCursor?: Cursor;\n spaceBetweenTextAndIcon?: number;\n};\n"]}
|
package/cjs/core/base.js
CHANGED
|
@@ -17,9 +17,10 @@ class AbstractComponent extends vrender_core_1.Group {
|
|
|
17
17
|
}));
|
|
18
18
|
}
|
|
19
19
|
setAttribute(key, value, forceUpdateTag) {
|
|
20
|
-
|
|
21
|
-
vutils_1.isFunction)(
|
|
22
|
-
|
|
20
|
+
(0, vutils_1.isPlainObject)(this.attribute[key]) && (0, vutils_1.isPlainObject)(value) && !(0,
|
|
21
|
+
vutils_1.isFunction)(this.attribute[key]) && !(0, vutils_1.isFunction)(value) ? (0,
|
|
22
|
+
vutils_1.merge)(this.attribute[key], value) : this.attribute[key] = value, GROUP_ATTRIBUTES.includes(key) || this.render(),
|
|
23
|
+
this.valid = this.isValid(), this.updateShapeAndBoundsTagSetted() || !forceUpdateTag && !this.needUpdateTag(key) ? this.addUpdateBoundTag() : this.addUpdateShapeAndBoundsTag(),
|
|
23
24
|
this.addUpdatePositionTag(), this.onAttributeUpdate();
|
|
24
25
|
}
|
|
25
26
|
setAttributes(params, forceUpdateTag) {
|
package/cjs/core/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/base.ts"],"names":[],"mappings":";;;AAIA,yDAA+C;AAC/C,6CAA2E;AAE3E,MAAM,gBAAgB,GAAG;IACvB,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,QAAQ;IACR,QAAQ;IACR,OAAO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UAAU;IAEpB,CAAC;IAKS,UAAU,CAAC,EAAU;QAC7B,OAAO,GAAG,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;IACzC,CAAC;CACF;AAxGD,8CAwGC","file":"base.js","sourcesContent":["/**\n * @description 组件基类\n */\nimport type { IGroupGraphicAttribute } from '@visactor/vrender-core';\nimport { Group } from '@visactor/vrender-core';\nimport { merge, isFunction, isPlainObject, isNil } from '@visactor/vutils';\n\nconst GROUP_ATTRIBUTES = [\n 'x',\n 'y',\n 'dx',\n 'dy',\n 'scaleX',\n 'scaleY',\n 'angle',\n 'anchor',\n 'postMatrix',\n 'visible',\n 'clip',\n 'pickable',\n 'childrenPickable',\n 'zIndex',\n 'cursor'\n];\n\nexport abstract class AbstractComponent<T extends IGroupGraphicAttribute = IGroupGraphicAttribute> extends Group {\n declare attribute: Partial<T>;\n\n protected mode: '2d' | '3d';\n\n constructor(attributes: T, mode: '2d' | '3d' = '2d') {\n super(attributes);\n this.mode = mode;\n // 组件需要精准 bounds,所以将这个 strokeBoundsBuffer 设置为 0,否则会影响包围盒的获取\n this.setTheme({\n common: {\n strokeBoundsBuffer: 0\n }\n });\n this.attribute = attributes;\n // 这里调用渲染和事件绑定逻辑\n this.onSetStage(() => {\n this.render();\n this.bindEvents();\n });\n }\n\n /**\n * @override\n * 更新单个属性值\n * @param key\n * @param value\n * @param forceUpdateTag\n */\n // @ts-ignore\n setAttribute(key: keyof T, value: any, forceUpdateTag?: boolean | undefined): void {\n // overwrite when previous or next attribute is function\n if (\n isPlainObject(this.attribute[key]) &&\n isPlainObject(value) &&\n !isFunction(this.attribute[key]) &&\n !isFunction(value)\n ) {\n merge(this.attribute[key], value);\n } else {\n this.attribute[key] = value;\n }\n\n // HACK: 待优化\n if (!GROUP_ATTRIBUTES.includes(key as string)) {\n this.render();\n }\n\n this.valid = this.isValid();\n if (!this.updateShapeAndBoundsTagSetted() && (forceUpdateTag || this.needUpdateTag(key as string))) {\n this.addUpdateShapeAndBoundsTag();\n } else {\n this.addUpdateBoundTag();\n }\n this.addUpdatePositionTag();\n this.onAttributeUpdate();\n }\n\n // @ts-ignore\n setAttributes(params: Partial<T>, forceUpdateTag?: boolean | undefined): void {\n const keys = Object.keys(params) as (keyof T)[];\n this._mergeAttributes(params, keys);\n\n // HACK: 待优化\n if (!keys.every(key => GROUP_ATTRIBUTES.includes(key as string))) {\n this.render();\n }\n\n this.valid = this.isValid();\n // 没有设置shape&bounds的tag\n if (!this.updateShapeAndBoundsTagSetted() && (forceUpdateTag || this.needUpdateTags(keys as string[]))) {\n this.addUpdateShapeAndBoundsTag();\n } else {\n this.addUpdateBoundTag();\n }\n this.addUpdatePositionTag();\n this.onAttributeUpdate();\n }\n\n protected _mergeAttributes(params: Partial<T>, keys?: (keyof T)[]) {\n if (isNil(keys)) {\n keys = Object.keys(params) as (keyof T)[];\n }\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i] as keyof Partial<T>;\n // overwrite when previous or next attribute is function\n if (isPlainObject(this.attribute[key]) && !isFunction(this.attribute[key]) && !isFunction(params[key])) {\n merge(this.attribute[key], params[key]);\n } else {\n this.attribute[key] = params[key];\n }\n }\n }\n\n protected bindEvents() {\n // please override\n }\n\n protected abstract render(): void;\n\n // 图形元素 id\n protected _getNodeId(id: string) {\n return `${this.id}-${this.name}-${id}`;\n }\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __createBinding = this && this.__createBinding || (Object.create ? function(
|
|
|
17
17
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", {
|
|
19
19
|
value: !0
|
|
20
|
-
}), exports.version = void 0, exports.version = "0.16.9
|
|
20
|
+
}), exports.version = void 0, exports.version = "0.16.9", __exportStar(require("./core/base"), exports),
|
|
21
21
|
__exportStar(require("./scrollbar"), exports), __exportStar(require("./tag"), exports),
|
|
22
22
|
__exportStar(require("./poptip"), exports), __exportStar(require("./crosshair"), exports),
|
|
23
23
|
__exportStar(require("./label"), exports), __exportStar(require("./axis"), exports),
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,QAAQ,CAAC;AAEhC,8CAA4B;AAC5B,8CAA4B;AAC5B,wCAAsB;AACtB,2CAAyB;AACzB,8CAA4B;AAC5B,0CAAwB;AACxB,yCAAuB;AACvB,8CAA4B;AAC5B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,2CAAyB;AACzB,0CAAwB;AACxB,8CAA4B;AAC5B,2CAAyB;AACzB,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,wCAAsB;AACtB,6CAA2B","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.16.9\";\n\nexport * from './core/base';\nexport * from './scrollbar';\nexport * from './tag';\nexport * from './poptip';\nexport * from './crosshair';\nexport * from './label';\nexport * from './axis';\nexport * from './axis/grid';\nexport * from './segment';\nexport * from './data-zoom';\nexport * from './marker';\nexport * from './pager';\nexport * from './legend';\nexport * from './title';\nexport * from './indicator';\nexport * from './slider';\nexport * from './link-path';\nexport * from './player';\nexport * from './brush';\nexport * from './tooltip';\nexport * from './interface';\nexport * from './jsx';\nexport * from './checkbox';\n"]}
|
package/cjs/label/rect.js
CHANGED
|
@@ -33,11 +33,37 @@ class RectLabel extends base_1.LabelBase {
|
|
|
33
33
|
case "right":
|
|
34
34
|
case "inside-right":
|
|
35
35
|
sx = .5;
|
|
36
|
+
break;
|
|
37
|
+
|
|
38
|
+
case "top-right":
|
|
39
|
+
sx = .5, sy = -.5;
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case "top-left":
|
|
43
|
+
sx = -.5, sy = -.5;
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
case "bottom-right":
|
|
47
|
+
sx = .5, sy = .5;
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case "bottom-left":
|
|
51
|
+
sx = -.5, sy = .5;
|
|
36
52
|
}
|
|
37
53
|
anchorX += sx * rectWidth, anchorY += sy * rectHeight;
|
|
38
54
|
let vx = 0, vy = 0;
|
|
39
55
|
const isInside = position.includes("inside");
|
|
40
|
-
position.includes("top") ? vy = isInside ? 1 : -1 : position.includes("bottom") ? vy = isInside ? -1 : 1 : position.includes("left") ? vx = isInside ? 1 : -1 : position.includes("right") && (vx = isInside ? -1 : 1)
|
|
56
|
+
switch (position.includes("top") ? vy = isInside ? 1 : -1 : position.includes("bottom") ? vy = isInside ? -1 : 1 : position.includes("left") ? vx = isInside ? 1 : -1 : position.includes("right") && (vx = isInside ? -1 : 1),
|
|
57
|
+
position) {
|
|
58
|
+
case "top-right":
|
|
59
|
+
case "bottom-right":
|
|
60
|
+
vx = -1;
|
|
61
|
+
break;
|
|
62
|
+
|
|
63
|
+
case "top-left":
|
|
64
|
+
case "bottom-left":
|
|
65
|
+
vx = 1;
|
|
66
|
+
}
|
|
41
67
|
return {
|
|
42
68
|
x: anchorX + vx * offset + vx * width / 2,
|
|
43
69
|
y: anchorY + vy * offset + vy * height / 2
|
package/cjs/label/rect.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/rect.ts"],"names":[],"mappings":";;;AACA,6CAAyC;AAEzC,iCAAmC;AAEnC,MAAa,SAAU,SAAQ,gBAAyB;IAgBtD,YAAY,UAA0B;QACpC,KAAK,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,SAAS,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;IAC5D,CAAC;IAES,QAAQ,CAAC,UAAuB,EAAE,aAA0B,EAAE,QAAQ,GA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CAAC,CAAC,CAAC;SACxB;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YACrC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACxB;QAED,QAAQ,QAAQ,EAAE;YAChB,KAAK,WAAW,CAAC;YACjB,KAAK,cAAc;gBACjB,EAAE,GAAG,CAAC,CAAC,CAAC;gBACR,MAAM;YACR,KAAK,UAAU,CAAC;YAChB,KAAK,aAAa;gBAChB,EAAE,GAAG,CAAC,CAAC;gBACP,MAAM;YACR;gBACE,MAAM;SACT;QAED,MAAM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,MAAM,GAAG,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAEpD,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;IAClB,CAAC;;AA1GH,8BA2GC;AA1GQ,aAAG,GAAG,YAAY,CAAC;AAEnB,2BAAiB,GAA4B;IAClD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,QAAQ;QACnB,YAAY,EAAE,QAAQ;QACtB,aAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAC9B;IACD,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,KAAK;CAChB,CAAC","file":"rect.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { merge } from '@visactor/vutils';\nimport type { RectLabelAttrs } from './type';\nimport { LabelBase } from './base';\n\nexport class RectLabel extends LabelBase<RectLabelAttrs> {\n static tag = 'rect-label';\n\n static defaultAttributes: Partial<RectLabelAttrs> = {\n textStyle: {\n fontSize: 12,\n fill: '#000',\n textAlign: 'center',\n textBaseline: 'middle',\n boundsPadding: [-1, 0, -1, 0] // to ignore the textBound buf\n },\n position: 'top',\n offset: 5,\n pickable: false\n };\n\n constructor(attributes: RectLabelAttrs) {\n super(merge({}, RectLabel.defaultAttributes, attributes));\n }\n\n protected labeling(textBounds: IBoundsLike, graphicBounds: IBoundsLike, position = 'top', offset = 0) {\n if (!textBounds || !graphicBounds) {\n return;\n }\n\n const { x1, y1, x2, y2 } = textBounds;\n const width = Math.abs(x2 - x1);\n const height = Math.abs(y2 - y1);\n\n const rectWidth = Math.abs(graphicBounds.x2 - graphicBounds.x1);\n const rectHeight = Math.abs(graphicBounds.y2 - graphicBounds.y1);\n let anchorX = (graphicBounds.x1 + graphicBounds.x2) / 2;\n let anchorY = (graphicBounds.y1 + graphicBounds.y2) / 2;\n\n let sx = 0;\n let sy = 0;\n\n switch (position) {\n case 'top':\n case 'inside-top':\n sy = -0.5;\n break;\n case 'bottom':\n case 'inside-bottom':\n sy = 0.5;\n break;\n case 'left':\n case 'inside-left':\n sx = -0.5;\n break;\n case 'right':\n case 'inside-right':\n sx = 0.5;\n break;\n case 'top-right':\n sx = 0.5;\n sy = -0.5;\n break;\n case 'top-left':\n sx = -0.5;\n sy = -0.5;\n break;\n case 'bottom-right':\n sx = 0.5;\n sy = 0.5;\n break;\n case 'bottom-left':\n sx = -0.5;\n sy = 0.5;\n }\n\n anchorX += sx * rectWidth;\n anchorY += sy * rectHeight;\n\n let vx = 0;\n let vy = 0;\n\n const isInside = position.includes('inside');\n\n if (position.includes('top')) {\n vy = isInside ? 1 : -1;\n } else if (position.includes('bottom')) {\n vy = isInside ? -1 : 1;\n } else if (position.includes('left')) {\n vx = isInside ? 1 : -1;\n } else if (position.includes('right')) {\n vx = isInside ? -1 : 1;\n }\n\n switch (position) {\n case 'top-right':\n case 'bottom-right':\n vx = -1;\n break;\n case 'top-left':\n case 'bottom-left':\n vx = 1;\n break;\n default:\n break;\n }\n\n const x = anchorX + vx * offset + (vx * width) / 2;\n const y = anchorY + vy * offset + (vy * height) / 2;\n\n return { x, y };\n }\n}\n"]}
|
package/cjs/label/type.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export interface SymbolLabelAttrs extends BaseLabelAttrs {
|
|
|
79
79
|
}
|
|
80
80
|
export interface RectLabelAttrs extends BaseLabelAttrs {
|
|
81
81
|
type: 'rect';
|
|
82
|
-
position?: Functional<'top' | 'bottom' | 'left' | 'right' | 'inside' | 'inside-top' | 'inside-bottom' | 'inside-right' | 'inside-left'>;
|
|
82
|
+
position?: Functional<'top' | 'bottom' | 'left' | 'right' | 'inside' | 'inside-top' | 'inside-bottom' | 'inside-right' | 'inside-left' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'>;
|
|
83
83
|
}
|
|
84
84
|
export interface LineLabelAttrs extends BaseLabelAttrs {
|
|
85
85
|
type: 'line';
|
package/cjs/label/type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGraphic,\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n Text,\n TextAlignType,\n TextBaselineType,\n ILineGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n [key: string]: T;\n};\n\nexport type LabelItem = {\n // 用于动画\n id?: string;\n // 原始数据\n data?: any;\n [key: string]: any;\n} & ITextGraphicAttribute;\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n /**\n * @hack not recommend to use\n * @returns\n */\n getBaseMarks?: () => IGraphic[];\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: LabelItem[];\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 连线的交互样式 */\n labelLineState?: LabelItemStateStyle<ILineGraphicAttribute>;\n\n syncState?: boolean;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | false;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | false;\n\n /** 动画配置 */\n animation?: ILabelAnimation | false;\n\n // 排序 or 删减\n dataFilter?: (data: LabelItem[]) => LabelItem[];\n\n /** 自定义布局函数\n * @description 当配置了 customLayoutFunc 后,默认布局逻辑将不再生效。(position/offset不生效)\n */\n customLayoutFunc?: (\n data: LabelItem[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint?: (data: LabelItem) => IPointLike\n ) => Text[];\n\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n */\n customOverlapFunc?: (\n label: Text[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint?: (data: LabelItem) => IPointLike\n ) => Text[];\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: { width: number; height: number };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 躲避指定图元\n * @default []\n */\n avoidMarks?: string[] | IGraphic[];\n\n /**\n * 发生重叠后的躲避策略\n */\n strategy?: Strategy[];\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: number;\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n /**\n * fillStrategy四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持fill设置的颜色)\n * @default 'invertBase'\n */\n fillStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * strokeStrategy的四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持stroke设置的颜色)\n * @default 'base'\n */\n strokeStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * 前景色与亮色具有对比度时,similarSeries使用该色\n * @default '#ffffff'\n */\n brightColor?: string;\n /**\n * 前景色与暗色具有对比度时,similarSeries使用该色\n * @default '#000000'\n */\n darkColor?: string;\n /**\n * label超出mark范围,也以mark作为背景色进行反色\n */\n outsideEnable?: boolean;\n}\n\nexport type PositionStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type BoundStrategy = {\n /**\n * 标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type MoveYStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top' | 'bottom' | 'left' | 'right' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center'\n >;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top'
|
|
1
|
+
{"version":3,"sources":["../src/label/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n EasingType,\n IGraphic,\n IGroupGraphicAttribute,\n ITextGraphicAttribute,\n Text,\n TextAlignType,\n TextBaselineType,\n ILineGraphicAttribute\n} from '@visactor/vrender-core';\nimport type { IPointLike } from '@visactor/vutils';\n\nexport type LabelItemStateStyle<T> = {\n hover?: T;\n hover_reverse?: T;\n selected?: T;\n selected_reverse?: T;\n [key: string]: T;\n};\n\nexport type LabelItem = {\n // 用于动画\n id?: string;\n // 原始数据\n data?: any;\n [key: string]: any;\n} & ITextGraphicAttribute;\n\nexport interface BaseLabelAttrs extends IGroupGraphicAttribute {\n type: string;\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n /**\n * @hack not recommend to use\n * @returns\n */\n getBaseMarks?: () => IGraphic[];\n /**\n * 是否开启选中交互\n * @default false\n */\n select?: boolean;\n /**\n * 是否开启 hover 交互\n * @default false\n */\n hover?: boolean;\n /**\n * 标签数据\n */\n data: LabelItem[];\n\n /** 文本样式,优先级低于 data */\n textStyle?: Partial<ITextGraphicAttribute>;\n\n /** 文本交互样式 */\n state?: LabelItemStateStyle<ITextGraphicAttribute>;\n\n /** 连线的交互样式 */\n labelLineState?: LabelItemStateStyle<ILineGraphicAttribute>;\n\n syncState?: boolean;\n\n /** 标签默认位置 */\n position?: Functional<string>;\n\n /** 偏移量 */\n offset?: number;\n\n /** 是否开启防重叠\n * @default true\n */\n overlap?: OverlapAttrs | false;\n\n /** 智能反色 */\n smartInvert?: SmartInvertAttrs | false;\n\n /** 动画配置 */\n animation?: ILabelAnimation | false;\n\n // 排序 or 删减\n dataFilter?: (data: LabelItem[]) => LabelItem[];\n\n /** 自定义布局函数\n * @description 当配置了 customLayoutFunc 后,默认布局逻辑将不再生效。(position/offset不生效)\n */\n customLayoutFunc?: (\n data: LabelItem[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint?: (data: LabelItem) => IPointLike\n ) => Text[];\n\n /** 自定义标签躲避函数\n * @description 当配置了 customOverlapFunc 后,会根据 position 和 offset 进行初始布局。配置的防重叠逻辑(overlap)不生效。\n */\n customOverlapFunc?: (\n label: Text[],\n getRelatedGraphic: (data: LabelItem) => IGraphic,\n getRelatedPoint?: (data: LabelItem) => IPointLike\n ) => Text[];\n /**\n * 关闭交互效果\n * @default false\n */\n disableTriggerEvent?: boolean;\n}\n\nexport interface OverlapAttrs {\n /**\n * 防重叠的区域大小\n */\n size?: { width: number; height: number };\n\n /**\n * 发生重叠后,是否隐藏标签\n * @default true\n */\n hideOnHit?: boolean;\n\n /**\n * 是否约束标签在指定 size 的范围内。开启后若标签被区域裁剪,会向内收缩。\n * @default true\n */\n clampForce?: boolean;\n\n /**\n * 是否躲避基础图元\n * @default false\n */\n avoidBaseMark?: boolean;\n\n /**\n * 躲避指定图元\n * @default []\n */\n avoidMarks?: string[] | IGraphic[];\n\n /**\n * 发生重叠后的躲避策略\n */\n strategy?: Strategy[];\n\n /**\n * 文字在防重叠计算中预留的边距。\n * @default 0\n */\n overlapPadding?: number;\n}\n\nexport interface SmartInvertAttrs {\n /**\n * 文本类型\n * 包含普通文本和大文本,对应不同的对比度标准,label默认为普通文本\n * 'normalText' | 'largeText'\n * @default 'normalText'\n */\n textType?: string;\n /**\n * 自定义对比度阈值\n */\n contrastRatiosThreshold?: number;\n /**\n * 自定义备选label颜色\n */\n alternativeColors?: string | string[];\n /**\n * fillStrategy四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持fill设置的颜色)\n * @default 'invertBase'\n */\n fillStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * strokeStrategy的四种策略:\n * - base(baseMark色),\n * - invertBase(执行智能反色),\n * - similarBase(智能反色的补色),\n * - null(不执行智能反色,保持stroke设置的颜色)\n * @default 'base'\n */\n strokeStrategy?: 'base' | 'invertBase' | 'similarBase' | 'null';\n /**\n * 前景色与亮色具有对比度时,similarSeries使用该色\n * @default '#ffffff'\n */\n brightColor?: string;\n /**\n * 前景色与暗色具有对比度时,similarSeries使用该色\n * @default '#000000'\n */\n darkColor?: string;\n /**\n * label超出mark范围,也以mark作为背景色进行反色\n */\n outsideEnable?: boolean;\n}\n\nexport type PositionStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则考虑 position 内的备选位置。\n */\n type: 'position';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type BoundStrategy = {\n /**\n * 标签配置在图形内部时使用。\n * 当图形大小不足以放下标签,则考虑 position 内的备选位置。\n */\n type: 'bound';\n position?: Functional<LabelPosition[]>;\n};\n\nexport type MoveYStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在Y方向上寻找位置。\n */\n type: 'moveY';\n /**\n * Y方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type MoveXStrategy = {\n /**\n * 可选位置策略。\n * 若默认位置没有足够的空间放置标签,则根据 offset 在X方向上寻找位置。\n */\n type: 'moveX';\n /**\n * X方向上的尝试的位置偏移量\n */\n offset: Functional<number[]>;\n};\n\nexport type Strategy = PositionStrategy | BoundStrategy | MoveYStrategy | MoveXStrategy;\n\nexport type LabelPosition = SymbolLabelAttrs['position'] | RectLabelAttrs['position'];\n\nexport interface SymbolLabelAttrs extends BaseLabelAttrs {\n type: 'symbol';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top' | 'bottom' | 'left' | 'right' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center'\n >;\n}\n\nexport interface RectLabelAttrs extends BaseLabelAttrs {\n type: 'rect';\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n | 'top'\n | 'bottom'\n | 'left'\n | 'right'\n | 'inside'\n | 'inside-top'\n | 'inside-bottom'\n | 'inside-right'\n | 'inside-left'\n | 'top-right'\n | 'top-left'\n | 'bottom-right'\n | 'bottom-left'\n >;\n}\n\nexport interface LineLabelAttrs extends BaseLabelAttrs {\n type: 'line';\n /**\n * 标签位置\n * @default 'end'\n */\n position?: Functional<'start' | 'end'>;\n}\n\nexport interface LineDataLabelAttrs extends BaseLabelAttrs {\n type: 'line-data';\n\n /**\n * 标签位置\n * @default 'top'\n */\n position?: Functional<\n 'top' | 'bottom' | 'left' | 'right' | 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'center'\n >;\n}\n\nexport interface PolygonLabelAttrs extends BaseLabelAttrs {\n type: 'polygon';\n /**\n * 标签位置\n * @default 'center'\n */\n position?: Functional<'center'>;\n}\n\nexport interface ArcLabelAttrs extends BaseLabelAttrs {\n type: 'arc';\n\n /**\n * 图元 group 名称\n */\n baseMarkGroupName: string;\n\n /**\n * 标签位置\n * @default 'outside'\n */\n position?: Functional<'inside' | 'outside' | 'inside-inner' | 'inside-outer'>;\n\n // 画布宽度\n width?: number;\n // 画布高度\n height?: number;\n\n /**\n * 是否允许标签重叠\n * @default false\n */\n coverEnable?: boolean;\n /**\n * 是否允许标签旋转\n * @default true\n */\n rotate?: boolean;\n\n /**\n * 文字与引导线间隔宽度\n * @default 5\n */\n spaceWidth?: number;\n /**\n * 标签旋转角度\n */\n angle?: number;\n /**\n * 标签旋转角度的偏移角度\n */\n offsetAngle?: number;\n /**\n * 标签相对于 `outerRadius` 的径向偏移,目前仅作用于 inside 标签\n */\n offsetRadius?: number;\n /**\n * 标签横向点对齐\n */\n textAlign?: TextAlignType;\n /**\n * 标签纵向点对齐\n */\n textBaseline?: TextBaselineType;\n /**\n * 扇区间标签的间隔\n * @default 6\n */\n layoutArcGap?: number;\n /** 标签引导线样式 */\n line?: IArcLabelLineSpec;\n /** 标签布局配置 */\n layout?: IArcLabelLayoutSpec;\n /** 标签引导线点集 */\n points?: IPoint[];\n /** 饼图扇区中心偏移 */\n centerOffset?: number;\n}\n\nexport interface IArcLabelLineSpec {\n /**\n * 是否显示引导线\n * @default true\n */\n visible?: boolean;\n /**\n * 引导线 line1 部分最小长度\n * @default 20\n */\n line1MinLength?: number;\n /**\n * 引导线 line2 部分最小长度\n * @default 10\n */\n line2MinLength?: number;\n /**\n * 引导线是否光滑\n * @default false\n */\n smooth?: boolean;\n /**\n * 引导线样式\n */\n style?: Partial<ILineGraphicAttribute>;\n}\n\nexport type ArcLabelAlignType = 'arc' | 'labelLine' | 'edge';\n\nexport type ArcLabelStrategyType = 'priority' | 'vertical' | 'none';\n\nexport interface IArcLabelLayoutSpec {\n /**\n * 标签对齐方式\n * @default 'arc'\n */\n textAlign?: ArcLabelAlignType;\n /** @deprecate 建议统一使用textAlign,后续将废除 */\n align?: ArcLabelAlignType;\n /**\n * 标签布局策略\n * @default 'priority'\n */\n strategy?: ArcLabelStrategyType;\n /**\n * 是否启用切线约束\n * @default true\n */\n tangentConstraint?: boolean;\n}\n\nexport interface DataLabelAttrs extends IGroupGraphicAttribute {\n dataLabels: (RectLabelAttrs | SymbolLabelAttrs | ArcLabelAttrs | LineDataLabelAttrs)[];\n /**\n * 防重叠的区域大小\n */\n size: { width: number; height: number };\n}\n\nexport type Functional<T> = T | ((data: any) => T);\n\nexport interface ILabelAnimation {\n mode?: 'same-time' | 'after' | 'after-all';\n duration?: number;\n delay?: number;\n easing?: EasingType;\n /** 是否开启 increaseCount 动画\n * @default true\n */\n increaseEffect?: boolean;\n}\n\nexport interface IPoint {\n x: number;\n y: number;\n}\n\nexport interface IPolarPoint {\n radius: number;\n angle: number;\n}\n\nexport type Quadrant = 1 | 2 | 3 | 4;\n\nexport type TextAlign = 'left' | 'right' | 'center';\n"]}
|
package/dist/index.js
CHANGED
|
@@ -7658,9 +7658,7 @@
|
|
|
7658
7658
|
var data = ResourceLoader.cache.get(url);
|
|
7659
7659
|
data ? "fail" === data.loadState ? application.global.getRequestAnimationFrame()(function () {
|
|
7660
7660
|
mark.imageLoadFail(url);
|
|
7661
|
-
}) : "init" === data.loadState || "loading" === data.loadState ? null === (_a = data.waitingMark) || void 0 === _a || _a.push(mark) : mark &&
|
|
7662
|
-
mark.imageLoadSuccess(url, data.data);
|
|
7663
|
-
}) : (data = {
|
|
7661
|
+
}) : "init" === data.loadState || "loading" === data.loadState ? null === (_a = data.waitingMark) || void 0 === _a || _a.push(mark) : mark && mark.imageLoadSuccess(url, data.data) : (data = {
|
|
7664
7662
|
type: "image",
|
|
7665
7663
|
loadState: "init"
|
|
7666
7664
|
}, ResourceLoader.cache.set(url, data), data.dataPromise = application.global.loadImage(url), data.dataPromise ? (data.waitingMark = [mark], data.dataPromise.then(function (res) {
|
|
@@ -8492,7 +8490,7 @@
|
|
|
8492
8490
|
data: "init",
|
|
8493
8491
|
state: null
|
|
8494
8492
|
};
|
|
8495
|
-
this.resources.set(url, cache), "string" == typeof image ? (cache.state = "loading",
|
|
8493
|
+
this.resources.set(url, cache), "string" == typeof image ? (cache.state = "loading", image.startsWith("<svg") ? (ResourceLoader.GetSvg(image, this), this.backgroundImg = this.backgroundImg || background) : (vutils.isValidUrl(image) || image.includes("/") || vutils.isBase64(image)) && (ResourceLoader.GetImage(image, this), this.backgroundImg = this.backgroundImg || background)) : (cache.state = "success", cache.data = image, this.backgroundImg = this.backgroundImg || background);
|
|
8496
8494
|
}
|
|
8497
8495
|
}, {
|
|
8498
8496
|
key: "imageLoadSuccess",
|
|
@@ -17831,6 +17829,7 @@
|
|
|
17831
17829
|
}, {
|
|
17832
17830
|
key: "clearScreen",
|
|
17833
17831
|
value: function clearScreen(renderService, context, drawContext) {
|
|
17832
|
+
var _a;
|
|
17834
17833
|
var clear = drawContext.clear;
|
|
17835
17834
|
if (clear) {
|
|
17836
17835
|
var canvas = context.getCanvas(),
|
|
@@ -17840,7 +17839,12 @@
|
|
|
17840
17839
|
height = _drawContext$height === void 0 ? canvas.height : _drawContext$height,
|
|
17841
17840
|
x = 0,
|
|
17842
17841
|
y = 0;
|
|
17843
|
-
context.clearRect(x, y, width, height)
|
|
17842
|
+
context.clearRect(x, y, width, height);
|
|
17843
|
+
var stage = null === (_a = renderService.drawParams) || void 0 === _a ? void 0 : _a.stage;
|
|
17844
|
+
if (stage && stage.backgroundImg && stage.resources) {
|
|
17845
|
+
var res = stage.resources.get(clear);
|
|
17846
|
+
res && "success" === res.state && res.data && context.drawImage(res.data, x, y, width, height);
|
|
17847
|
+
} else context.fillStyle = createColor(context, clear, {
|
|
17844
17848
|
AABBBounds: {
|
|
17845
17849
|
x1: x,
|
|
17846
17850
|
y1: y,
|
|
@@ -20037,7 +20041,10 @@
|
|
|
20037
20041
|
});
|
|
20038
20042
|
}
|
|
20039
20043
|
setAttribute(key, value, forceUpdateTag) {
|
|
20040
|
-
if (vutils.isPlainObject(this.attribute[key]) &&
|
|
20044
|
+
if (vutils.isPlainObject(this.attribute[key]) &&
|
|
20045
|
+
vutils.isPlainObject(value) &&
|
|
20046
|
+
!vutils.isFunction(this.attribute[key]) &&
|
|
20047
|
+
!vutils.isFunction(value)) {
|
|
20041
20048
|
vutils.merge(this.attribute[key], value);
|
|
20042
20049
|
}
|
|
20043
20050
|
else {
|
|
@@ -22679,6 +22686,21 @@
|
|
|
22679
22686
|
case 'inside-right':
|
|
22680
22687
|
sx = 0.5;
|
|
22681
22688
|
break;
|
|
22689
|
+
case 'top-right':
|
|
22690
|
+
sx = 0.5;
|
|
22691
|
+
sy = -0.5;
|
|
22692
|
+
break;
|
|
22693
|
+
case 'top-left':
|
|
22694
|
+
sx = -0.5;
|
|
22695
|
+
sy = -0.5;
|
|
22696
|
+
break;
|
|
22697
|
+
case 'bottom-right':
|
|
22698
|
+
sx = 0.5;
|
|
22699
|
+
sy = 0.5;
|
|
22700
|
+
break;
|
|
22701
|
+
case 'bottom-left':
|
|
22702
|
+
sx = -0.5;
|
|
22703
|
+
sy = 0.5;
|
|
22682
22704
|
}
|
|
22683
22705
|
anchorX += sx * rectWidth;
|
|
22684
22706
|
anchorY += sy * rectHeight;
|
|
@@ -22697,6 +22719,16 @@
|
|
|
22697
22719
|
else if (position.includes('right')) {
|
|
22698
22720
|
vx = isInside ? -1 : 1;
|
|
22699
22721
|
}
|
|
22722
|
+
switch (position) {
|
|
22723
|
+
case 'top-right':
|
|
22724
|
+
case 'bottom-right':
|
|
22725
|
+
vx = -1;
|
|
22726
|
+
break;
|
|
22727
|
+
case 'top-left':
|
|
22728
|
+
case 'bottom-left':
|
|
22729
|
+
vx = 1;
|
|
22730
|
+
break;
|
|
22731
|
+
}
|
|
22700
22732
|
const x = anchorX + vx * offset + (vx * width) / 2;
|
|
22701
22733
|
const y = anchorY + vy * offset + (vy * height) / 2;
|
|
22702
22734
|
return { x, y };
|
|
@@ -31048,7 +31080,8 @@
|
|
|
31048
31080
|
return new Tag(params ? params.attribute : {});
|
|
31049
31081
|
}
|
|
31050
31082
|
|
|
31051
|
-
const
|
|
31083
|
+
const checkSvg = '<svg width="200" height="200" viewBox="0 0 1024 1024" fill="#fff" xmlns="http://www.w3.org/2000/svg"><path d="M877.44815445 206.10060629a64.72691371 64.72691371 0 0 0-95.14856334 4.01306852L380.73381888 685.46812814 235.22771741 533.48933518a64.72691371 64.72691371 0 0 0-92.43003222-1.03563036l-45.82665557 45.82665443a64.72691371 64.72691371 0 0 0-0.90617629 90.61767965l239.61903446 250.10479331a64.72691371 64.72691371 0 0 0 71.19960405 15.14609778 64.33855261 64.33855261 0 0 0 35.08198741-21.23042702l36.24707186-42.71976334 40.5190474-40.77795556-3.36579926-3.49525333 411.40426297-486.74638962a64.72691371 64.72691371 0 0 0-3.88361443-87.64024149l-45.3088404-45.43829334z"></path></svg>';
|
|
31084
|
+
const indeterminateSvg = '<svg width="200" height="200" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none"><path stroke="#fff" stroke-linecap="round" stroke-linejoin="round" stroke-width="5" d="M5 12h14"/></svg>';
|
|
31052
31085
|
class CheckBox extends AbstractComponent {
|
|
31053
31086
|
constructor(attributes) {
|
|
31054
31087
|
super(vutils.merge({}, CheckBox.defaultAttributes, attributes));
|
|
@@ -31073,13 +31106,14 @@
|
|
|
31073
31106
|
}
|
|
31074
31107
|
renderBox() {
|
|
31075
31108
|
this._box = new Rect(vutils.merge({}, this.attribute.box));
|
|
31076
|
-
|
|
31109
|
+
const isCheckedOrIndeterminate = this.attribute.checked || this.attribute.indeterminate;
|
|
31110
|
+
if (isCheckedOrIndeterminate && this.attribute.disabled) {
|
|
31077
31111
|
this._box.setAttributes({
|
|
31078
31112
|
fill: this.attribute.box.disableCheckedFill,
|
|
31079
31113
|
stroke: this.attribute.box.disableCheckedStroke
|
|
31080
31114
|
});
|
|
31081
31115
|
}
|
|
31082
|
-
else if (
|
|
31116
|
+
else if (isCheckedOrIndeterminate) {
|
|
31083
31117
|
this._box.setAttributes({
|
|
31084
31118
|
fill: this.attribute.box.checkedFill,
|
|
31085
31119
|
stroke: this.attribute.box.checkedStroke
|
|
@@ -31088,11 +31122,24 @@
|
|
|
31088
31122
|
this.appendChild(this._box);
|
|
31089
31123
|
}
|
|
31090
31124
|
renderIcon() {
|
|
31091
|
-
this.
|
|
31092
|
-
|
|
31093
|
-
|
|
31125
|
+
this._checkIcon = new Image(vutils.merge({ image: this.attribute.icon.checkIconImage }, this.attribute.icon));
|
|
31126
|
+
this.appendChild(this._checkIcon);
|
|
31127
|
+
this._indeterminateIcon = new Image(vutils.merge({
|
|
31128
|
+
image: this.attribute.icon.indeterminateIconImage
|
|
31129
|
+
}, this.attribute.icon));
|
|
31130
|
+
this.appendChild(this._indeterminateIcon);
|
|
31131
|
+
if (this.attribute.checked) {
|
|
31132
|
+
this._checkIcon.setAttribute('visible', true);
|
|
31133
|
+
this._indeterminateIcon.setAttribute('visible', false);
|
|
31134
|
+
}
|
|
31135
|
+
else if (this.attribute.indeterminate) {
|
|
31136
|
+
this._checkIcon.setAttribute('visible', false);
|
|
31137
|
+
this._indeterminateIcon.setAttribute('visible', true);
|
|
31138
|
+
}
|
|
31139
|
+
else {
|
|
31140
|
+
this._checkIcon.setAttribute('visible', false);
|
|
31141
|
+
this._indeterminateIcon.setAttribute('visible', false);
|
|
31094
31142
|
}
|
|
31095
|
-
this.appendChild(this._icon);
|
|
31096
31143
|
}
|
|
31097
31144
|
renderText() {
|
|
31098
31145
|
this._text = new WrapText(vutils.merge({}, this.attribute.text));
|
|
@@ -31127,7 +31174,11 @@
|
|
|
31127
31174
|
x: boxX,
|
|
31128
31175
|
y: boxY
|
|
31129
31176
|
});
|
|
31130
|
-
this.
|
|
31177
|
+
this._checkIcon.setAttributes({
|
|
31178
|
+
x: iconX,
|
|
31179
|
+
y: iconY
|
|
31180
|
+
});
|
|
31181
|
+
this._indeterminateIcon.setAttributes({
|
|
31131
31182
|
x: iconX,
|
|
31132
31183
|
y: iconY
|
|
31133
31184
|
});
|
|
@@ -31143,9 +31194,11 @@
|
|
|
31143
31194
|
}
|
|
31144
31195
|
else if (this.attribute.checked) {
|
|
31145
31196
|
this.setAttribute('checked', false);
|
|
31197
|
+
this.setAttribute('indeterminate', false);
|
|
31146
31198
|
}
|
|
31147
31199
|
else {
|
|
31148
31200
|
this.setAttribute('checked', true);
|
|
31201
|
+
this.setAttribute('indeterminate', false);
|
|
31149
31202
|
}
|
|
31150
31203
|
const changeEvent = new CustomEvent('checkbox_state_change', {
|
|
31151
31204
|
eventType: 'checkbox_state_change',
|
|
@@ -31159,6 +31212,7 @@
|
|
|
31159
31212
|
interactive: true,
|
|
31160
31213
|
disabled: false,
|
|
31161
31214
|
checked: false,
|
|
31215
|
+
indeterminate: false,
|
|
31162
31216
|
cursor: 'pointer',
|
|
31163
31217
|
disableCursor: 'not-allowed',
|
|
31164
31218
|
spaceBetweenTextAndIcon: 8,
|
|
@@ -31171,7 +31225,8 @@
|
|
|
31171
31225
|
pickable: false
|
|
31172
31226
|
},
|
|
31173
31227
|
icon: {
|
|
31174
|
-
|
|
31228
|
+
checkIconImage: checkSvg,
|
|
31229
|
+
indeterminateIconImage: indeterminateSvg,
|
|
31175
31230
|
width: 10,
|
|
31176
31231
|
height: 10,
|
|
31177
31232
|
pickable: false
|
|
@@ -31191,7 +31246,7 @@
|
|
|
31191
31246
|
}
|
|
31192
31247
|
};
|
|
31193
31248
|
|
|
31194
|
-
const version = "0.16.9
|
|
31249
|
+
const version = "0.16.9";
|
|
31195
31250
|
|
|
31196
31251
|
exports.AbstractComponent = AbstractComponent;
|
|
31197
31252
|
exports.ArcInfo = ArcInfo;
|