@visactor/vrender-components 0.18.10 → 0.18.11-alpha.0

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.
@@ -15,5 +15,5 @@ export declare class CheckBox extends AbstractComponent<Required<CheckboxAttribu
15
15
  renderText(): void;
16
16
  renderGroup(): void;
17
17
  layout(): void;
18
- handleClick(): void;
18
+ private _handlePointerUp;
19
19
  }
@@ -11,9 +11,16 @@ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"),
11
11
  class CheckBox extends base_1.AbstractComponent {
12
12
  constructor(attributes, options) {
13
13
  super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, CheckBox.defaultAttributes, attributes)),
14
- this.renderGroup(), this.onBeforeAttributeUpdate = (val, attributes, key) => {
14
+ this._handlePointerUp = () => {
15
+ this.attribute.disabled || (this.attribute.checked ? (this.setAttribute("checked", !1),
16
+ this.setAttribute("indeterminate", !1)) : (this.setAttribute("checked", !0), this.setAttribute("indeterminate", !1)),
17
+ this._dispatchEvent("checkbox_state_change", {
18
+ eventType: "checkbox_state_change",
19
+ checked: this.attribute.checked
20
+ }));
21
+ }, this.renderGroup(), this.onBeforeAttributeUpdate = (val, attributes, key) => {
15
22
  "interactive" in val && this.setAttribute("pickable", val.interactive), "disabled" in val && this.setAttribute("cursor", val.disable ? this.attribute.disableCursor : this.attribute.cursor);
16
- }, this.addEventListener("click", this.handleClick);
23
+ }, this.addEventListener("pointerup", this._handlePointerUp);
17
24
  }
18
25
  render() {
19
26
  this.removeAllChild(!0), this.renderBox(), this.renderIcon(), this.renderText(),
@@ -65,14 +72,6 @@ class CheckBox extends base_1.AbstractComponent {
65
72
  y: textY
66
73
  });
67
74
  }
68
- handleClick() {
69
- this.attribute.disabled || (this.attribute.checked ? (this.setAttribute("checked", !1),
70
- this.setAttribute("indeterminate", !1)) : (this.setAttribute("checked", !0), this.setAttribute("indeterminate", !1)),
71
- this._dispatchEvent("checkbox_state_change", {
72
- eventType: "checkbox_state_change",
73
- checked: this.attribute.checked
74
- }));
75
- }
76
75
  }
77
76
 
78
77
  exports.CheckBox = CheckBox, CheckBox.defaultAttributes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/checkbox/checkbox.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,uCAAiD;AAEjD,yDAA+D;AAE/D,yCAAmD;AAEnD,MAAM,QAAQ,GACZ,wrBAAwrB,CAAC;AAE3rB,MAAM,gBAAgB,GACpB,2MAA2M,CAAC;AAE9M,IAAA,gCAAqB,GAAE,CAAC;AACxB,MAAa,QAAS,SAAQ,wBAA+C;IA2C3E,YAAY,UAA8B,EAAE,OAA0B;QACpE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAC7F,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,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;aAChD;YACD,IAAI,UAAU,IAAI,GAAG,EAAE;gBACrB,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;aACjG;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,CAAC;QAEF,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACnD,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,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AAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,cAAc,EAAE,QAAQ;QACxB,sBAAsB,EAAE,gBAAgB;QACxC,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,KAAK;KAChB;IACD,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 { Image, Rect, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadCheckBoxComponent } from './register';\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\nloadCheckBoxComponent();\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, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : 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(true);\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\n this._dispatchEvent('checkbox_state_change', {\n eventType: 'checkbox_state_change',\n checked: this.attribute.checked\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/checkbox/checkbox.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,uCAAiD;AAEjD,yDAA+D;AAE/D,yCAAmD;AAEnD,MAAM,QAAQ,GACZ,wrBAAwrB,CAAC;AAE3rB,MAAM,gBAAgB,GACpB,2MAA2M,CAAC;AAE9M,IAAA,gCAAqB,GAAE,CAAC;AACxB,MAAa,QAAS,SAAQ,wBAA+C;IA2C3E,YAAY,UAA8B,EAAE,OAA0B;QACpE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,cAAK,EAAC,EAAE,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC,CAAC;QAsHvF,qBAAgB,GAAG,GAAG,EAAE;YAC9B,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;gBAC3B,OAAO;aACR;iBAAM,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE;gBACjC,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBACpC,IAAI,CAAC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,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;SACT,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YACvB,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;SACT,CAAC,CAAC;IACL,CAAC;;AAhKH,4BAkLC;AAjLQ,0BAAiB,GAAgC;IACtD,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,aAAa,EAAE,KAAK;IACpB,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,aAAa;IAC5B,uBAAuB,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,cAAc,EAAE,QAAQ;QACxB,sBAAsB,EAAE,gBAAgB;QACxC,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,KAAK;KAChB;IACD,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 { Image, Rect, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadCheckBoxComponent } from './register';\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\nloadCheckBoxComponent();\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, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : 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('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\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 private _handlePointerUp = () => {\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\n this._dispatchEvent('checkbox_state_change', {\n eventType: 'checkbox_state_change',\n checked: this.attribute.checked\n });\n };\n}\n"]}
package/cjs/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.18.10";
1
+ export declare const version = "0.18.11-alpha.0";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
@@ -23,4 +23,5 @@ export * from './tooltip';
23
23
  export * from './interface';
24
24
  export * from './jsx';
25
25
  export * from './checkbox';
26
+ export * from './radio';
26
27
  export * from './util';
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.18.10", __exportStar(require("./core/base"), exports),
20
+ }), exports.version = void 0, exports.version = "0.18.11-alpha.0", __exportStar(require("./core/base"), exports),
21
21
  __exportStar(require("./core/type"), exports), __exportStar(require("./scrollbar"), exports),
22
22
  __exportStar(require("./tag"), exports), __exportStar(require("./poptip"), exports),
23
23
  __exportStar(require("./crosshair"), exports), __exportStar(require("./label"), exports),
@@ -29,5 +29,6 @@ __exportStar(require("./indicator"), exports), __exportStar(require("./slider"),
29
29
  __exportStar(require("./link-path"), exports), __exportStar(require("./player"), exports),
30
30
  __exportStar(require("./brush"), exports), __exportStar(require("./tooltip"), exports),
31
31
  __exportStar(require("./interface"), exports), __exportStar(require("./jsx"), exports),
32
- __exportStar(require("./checkbox"), exports), __exportStar(require("./util"), exports);
32
+ __exportStar(require("./checkbox"), exports), __exportStar(require("./radio"), exports),
33
+ __exportStar(require("./util"), exports);
33
34
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,SAAS,CAAC;AAEjC,8CAA4B;AAC5B,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;AAC3B,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.10\";\n\nexport * from './core/base';\nexport * from './core/type';\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';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACa,QAAA,OAAO,GAAG,iBAAiB,CAAC;AAEzC,8CAA4B;AAC5B,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;AAC3B,0CAAwB;AACxB,yCAAuB","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.11-alpha.0\";\n\nexport * from './core/base';\nexport * from './core/type';\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';\nexport * from './radio';\nexport * from './util';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './radio';
2
+ export * from './type';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
4
+ void 0 === k2 && (k2 = k);
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
7
+ enumerable: !0,
8
+ get: function() {
9
+ return m[k];
10
+ }
11
+ }), Object.defineProperty(o, k2, desc);
12
+ } : function(o, m, k, k2) {
13
+ void 0 === k2 && (k2 = k), o[k2] = m[k];
14
+ }), __exportStar = this && this.__exportStar || function(m, exports) {
15
+ for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
16
+ };
17
+
18
+ Object.defineProperty(exports, "__esModule", {
19
+ value: !0
20
+ }), __exportStar(require("./radio"), exports), __exportStar(require("./type"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,yCAAuB","file":"index.js","sourcesContent":["export * from './radio';\nexport * from './type';\n"]}
@@ -0,0 +1,16 @@
1
+ import { AbstractComponent } from '../core/base';
2
+ import type { RadioAttributes } from './type';
3
+ import { Arc, WrapText } from '@visactor/vrender-core';
4
+ import type { ComponentOptions } from '../interface';
5
+ export declare class Radio extends AbstractComponent<Required<RadioAttributes>> {
6
+ static defaultAttributes: Partial<RadioAttributes>;
7
+ _circle: Arc;
8
+ _text: WrapText;
9
+ constructor(attributes: RadioAttributes, options?: ComponentOptions);
10
+ render(): void;
11
+ renderCircle(): void;
12
+ renderText(): void;
13
+ renderGroup(): void;
14
+ layout(): void;
15
+ private _handlePointerUp;
16
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.Radio = void 0;
6
+
7
+ const vutils_1 = require("@visactor/vutils"), base_1 = require("../core/base"), vrender_core_1 = require("@visactor/vrender-core"), register_1 = require("./register");
8
+
9
+ (0, register_1.loadRadioComponent)();
10
+
11
+ class Radio extends base_1.AbstractComponent {
12
+ constructor(attributes, options) {
13
+ super((null == options ? void 0 : options.skipDefault) ? attributes : (0, vutils_1.merge)({}, Radio.defaultAttributes, attributes)),
14
+ this._handlePointerUp = () => {
15
+ this.attribute.disabled || this.attribute.checked || (this.setAttribute("checked", !0),
16
+ this._dispatchEvent("radio_checked", {
17
+ eventType: "radio_checked",
18
+ target: this
19
+ }));
20
+ }, this.renderGroup(), this.onBeforeAttributeUpdate = (val, attributes, key) => {
21
+ "interactive" in val && this.setAttribute("pickable", val.interactive), "disabled" in val && this.setAttribute("cursor", val.disable ? this.attribute.disableCursor : this.attribute.cursor);
22
+ }, this.addEventListener("pointerup", this._handlePointerUp);
23
+ }
24
+ render() {
25
+ this.removeAllChild(!0), this.renderCircle(), this.renderText(), this.layout();
26
+ }
27
+ renderCircle() {
28
+ this._circle = new vrender_core_1.Arc((0, vutils_1.merge)({}, this.attribute.circle));
29
+ const isChecked = this.attribute.checked;
30
+ isChecked && this.attribute.disabled ? this._circle.setAttributes({
31
+ fill: this.attribute.circle.disableCheckedFill,
32
+ stroke: this.attribute.circle.disableCheckedStroke
33
+ }) : isChecked && this._circle.setAttributes({
34
+ fill: this.attribute.circle.checkedFill,
35
+ stroke: this.attribute.circle.checkedStroke
36
+ }), this.appendChild(this._circle);
37
+ }
38
+ renderText() {
39
+ this._text = new vrender_core_1.WrapText((0, vutils_1.merge)({}, this.attribute.text)),
40
+ this.attribute.disabled && this._text.setAttribute("fill", this.attribute.text.disableFill),
41
+ this.appendChild(this._text);
42
+ }
43
+ renderGroup() {
44
+ this.attribute.interactive || this.setAttribute("pickable", !1), this.attribute.disabled && this.setAttribute("cursor", this.attribute.disableCursor);
45
+ }
46
+ layout() {
47
+ const circleHeight = 2 * this.attribute.circle.outerRadius, textHeight = this._text.AABBBounds.height(), maxHeight = Math.max(circleHeight, textHeight), circleY = maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius, textY = maxHeight / 2 - textHeight / 2, circleWidth = 2 * this.attribute.circle.outerRadius, circleX = this.attribute.circle.outerRadius, textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;
48
+ this._circle.setAttributes({
49
+ x: circleX,
50
+ y: circleY
51
+ }), this._text.setAttributes({
52
+ x: textX,
53
+ y: textY
54
+ });
55
+ }
56
+ }
57
+
58
+ exports.Radio = Radio, Radio.defaultAttributes = {
59
+ interactive: !0,
60
+ disabled: !1,
61
+ checked: !1,
62
+ cursor: "pointer",
63
+ disableCursor: "not-allowed",
64
+ spaceBetweenTextAndIcon: 8,
65
+ text: {
66
+ text: "text",
67
+ fontSize: 14,
68
+ fill: "#000",
69
+ disableFill: "rgb(201,205,212)",
70
+ textBaseline: "top",
71
+ pickable: !1
72
+ },
73
+ circle: {
74
+ outerRadius: 7,
75
+ innerRadius: 3,
76
+ startAngle: 0,
77
+ endAngle: 2 * Math.PI,
78
+ fill: "#fff",
79
+ stroke: "rgb(229,230,235)",
80
+ disableFill: "rgb(242,243,245)",
81
+ checkedFill: "rgb(22, 93, 255)",
82
+ checkedStroke: "rgb(22, 93, 255)",
83
+ disableCheckedFill: "rgb(148, 191, 255)",
84
+ disableCheckedStroke: "rgb(148, 191, 255)",
85
+ pickable: !1
86
+ }
87
+ };
88
+ //# sourceMappingURL=radio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/radio.ts"],"names":[],"mappings":";;;AAAA,6CAAyC;AACzC,uCAAiD;AAEjD,yDAAuD;AAEvD,yCAAgD;AAEhD,IAAA,6BAAkB,GAAE,CAAC;AACrB,MAAa,KAAM,SAAQ,wBAA4C;IAkCrE,YAAY,UAA2B,EAAE,OAA0B;QACjE,KAAK,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,EAAC,CAAC,CAAC,UAAU,CAAC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IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;QACrB,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":"radio.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { RadioAttributes } from './type';\nimport { Arc, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadRadioComponent } from './register';\n\nloadRadioComponent();\nexport class Radio extends AbstractComponent<Required<RadioAttributes>> {\n static defaultAttributes: Partial<RadioAttributes> = {\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 circle: {\n outerRadius: 7,\n innerRadius: 3,\n startAngle: 0,\n endAngle: 2 * Math.PI,\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 _circle: Arc;\n _text: WrapText;\n\n constructor(attributes: RadioAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Radio.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('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\n\n this.renderCircle();\n this.renderText();\n this.layout();\n }\n\n renderCircle() {\n this._circle = new Arc(merge({}, this.attribute.circle));\n const isChecked = this.attribute.checked;\n if (isChecked && this.attribute.disabled) {\n this._circle.setAttributes({\n fill: this.attribute.circle.disableCheckedFill,\n stroke: this.attribute.circle.disableCheckedStroke\n });\n } else if (isChecked) {\n this._circle.setAttributes({\n fill: this.attribute.circle.checkedFill,\n stroke: this.attribute.circle.checkedStroke\n });\n }\n this.appendChild(this._circle);\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 circleHeight = this.attribute.circle.outerRadius * 2;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(circleHeight, textHeight);\n const circleY = maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const circleWidth = this.attribute.circle.outerRadius * 2;\n const circleX = this.attribute.circle.outerRadius;\n const textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._circle.setAttributes({\n x: circleX,\n y: circleY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n private _handlePointerUp = () => {\n if (this.attribute.disabled || this.attribute.checked) {\n // checked do nothing\n return;\n }\n this.setAttribute('checked', true);\n\n this._dispatchEvent('radio_checked', {\n eventType: 'radio_checked',\n target: this\n });\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function loadRadioComponent(): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ }), exports.loadRadioComponent = void 0;
6
+
7
+ const vrender_kits_1 = require("@visactor/vrender-kits");
8
+
9
+ function loadRadioComponent() {
10
+ (0, vrender_kits_1.registerGroup)(), (0, vrender_kits_1.registerRect)(), (0, vrender_kits_1.registerWrapText)(),
11
+ (0, vrender_kits_1.registerImage)();
12
+ }
13
+
14
+ exports.loadRadioComponent = loadRadioComponent;
15
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/register.ts"],"names":[],"mappings":";;;AAAA,yDAAsG;AAEtG,SAAgB,kBAAkB;IAChC,IAAA,4BAAa,GAAE,CAAC;IAChB,IAAA,2BAAY,GAAE,CAAC;IACf,IAAA,+BAAgB,GAAE,CAAC;IACnB,IAAA,4BAAa,GAAE,CAAC;AAClB,CAAC;AALD,gDAKC","file":"register.js","sourcesContent":["import { registerGroup, registerImage, registerRect, registerWrapText } from '@visactor/vrender-kits';\n\nexport function loadRadioComponent() {\n registerGroup();\n registerRect();\n registerWrapText();\n registerImage();\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { Cursor, IArcGraphicAttribute, IColor, IGroupGraphicAttribute, IWrapTextGraphicAttribute } from '@visactor/vrender-core';
2
+ export type RadioText = {
3
+ disableFill?: IColor;
4
+ } & IWrapTextGraphicAttribute;
5
+ export type CircleStyle = {
6
+ disableFill?: IColor;
7
+ checkedFill?: IColor;
8
+ checkedStroke?: IColor;
9
+ disableCheckedFill?: IColor;
10
+ disableCheckedStroke?: IColor;
11
+ } & IArcGraphicAttribute;
12
+ export type RadioAttributes = IGroupGraphicAttribute & {
13
+ id?: string;
14
+ interactive?: boolean;
15
+ disabled?: boolean;
16
+ checked?: boolean;
17
+ text?: RadioText;
18
+ circle?: CircleStyle;
19
+ disableCursor?: Cursor;
20
+ spaceBetweenTextAndIcon?: number;
21
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: !0
5
+ });
6
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n Cursor,\n IArcGraphicAttribute,\n IColor,\n IGroupGraphicAttribute,\n IWrapTextGraphicAttribute\n} from '@visactor/vrender-core';\n\nexport type RadioText = {\n disableFill?: IColor;\n} & IWrapTextGraphicAttribute;\n\nexport type CircleStyle = {\n disableFill?: IColor;\n checkedFill?: IColor;\n checkedStroke?: IColor;\n disableCheckedFill?: IColor;\n disableCheckedStroke?: IColor;\n} & IArcGraphicAttribute;\n\nexport type RadioAttributes = IGroupGraphicAttribute & {\n id?: string;\n\n interactive?: boolean;\n disabled?: boolean;\n checked?: boolean;\n\n /**\n * 图例文字\n */\n text?: RadioText;\n /**\n * 图例选中图标\n */\n circle?: CircleStyle;\n /**\n * 图例选中图标\n */\n disableCursor?: Cursor;\n spaceBetweenTextAndIcon?: number;\n};\n"]}
@@ -15,5 +15,5 @@ export declare class CheckBox extends AbstractComponent<Required<CheckboxAttribu
15
15
  renderText(): void;
16
16
  renderGroup(): void;
17
17
  layout(): void;
18
- handleClick(): void;
18
+ private _handlePointerUp;
19
19
  }
@@ -13,9 +13,16 @@ loadCheckBoxComponent();
13
13
  export class CheckBox extends AbstractComponent {
14
14
  constructor(attributes, options) {
15
15
  super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, CheckBox.defaultAttributes, attributes)),
16
- this.renderGroup(), this.onBeforeAttributeUpdate = (val, attributes, key) => {
16
+ this._handlePointerUp = () => {
17
+ this.attribute.disabled || (this.attribute.checked ? (this.setAttribute("checked", !1),
18
+ this.setAttribute("indeterminate", !1)) : (this.setAttribute("checked", !0), this.setAttribute("indeterminate", !1)),
19
+ this._dispatchEvent("checkbox_state_change", {
20
+ eventType: "checkbox_state_change",
21
+ checked: this.attribute.checked
22
+ }));
23
+ }, this.renderGroup(), this.onBeforeAttributeUpdate = (val, attributes, key) => {
17
24
  "interactive" in val && this.setAttribute("pickable", val.interactive), "disabled" in val && this.setAttribute("cursor", val.disable ? this.attribute.disableCursor : this.attribute.cursor);
18
- }, this.addEventListener("click", this.handleClick);
25
+ }, this.addEventListener("pointerup", this._handlePointerUp);
19
26
  }
20
27
  render() {
21
28
  this.removeAllChild(!0), this.renderBox(), this.renderIcon(), this.renderText(),
@@ -65,14 +72,6 @@ export class CheckBox extends AbstractComponent {
65
72
  y: textY
66
73
  });
67
74
  }
68
- handleClick() {
69
- this.attribute.disabled || (this.attribute.checked ? (this.setAttribute("checked", !1),
70
- this.setAttribute("indeterminate", !1)) : (this.setAttribute("checked", !0), this.setAttribute("indeterminate", !1)),
71
- this._dispatchEvent("checkbox_state_change", {
72
- eventType: "checkbox_state_change",
73
- checked: this.attribute.checked
74
- }));
75
- }
76
75
  }
77
76
 
78
77
  CheckBox.defaultAttributes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/checkbox/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,QAAQ,GACZ,wrBAAwrB,CAAC;AAE3rB,MAAM,gBAAgB,GACpB,2MAA2M,CAAC;AAE9M,qBAAqB,EAAE,CAAC;AACxB,MAAM,OAAO,QAAS,SAAQ,i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,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 { Image, Rect, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadCheckBoxComponent } from './register';\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\nloadCheckBoxComponent();\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, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : 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(true);\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\n this._dispatchEvent('checkbox_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SAAS;IACjB,aAAa,EAAE,aAAa;IAC5B,uBAAuB,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,IAAI,EAAE;QACJ,cAAc,EAAE,QAAQ;QACxB,sBAAsB,EAAE,gBAAgB;QACxC,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,KAAK;KAChB;IACD,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 { Image, Rect, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadCheckBoxComponent } from './register';\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\nloadCheckBoxComponent();\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, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : 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('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\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 private _handlePointerUp = () => {\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\n this._dispatchEvent('checkbox_state_change', {\n eventType: 'checkbox_state_change',\n checked: this.attribute.checked\n });\n };\n}\n"]}
package/es/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const version = "0.18.10";
1
+ export declare const version = "0.18.11-alpha.0";
2
2
  export * from './core/base';
3
3
  export * from './core/type';
4
4
  export * from './scrollbar';
@@ -23,4 +23,5 @@ export * from './tooltip';
23
23
  export * from './interface';
24
24
  export * from './jsx';
25
25
  export * from './checkbox';
26
+ export * from './radio';
26
27
  export * from './util';
package/es/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = "0.18.10";
1
+ export const version = "0.18.11-alpha.0";
2
2
 
3
3
  export * from "./core/base";
4
4
 
@@ -48,5 +48,7 @@ export * from "./jsx";
48
48
 
49
49
  export * from "./checkbox";
50
50
 
51
+ export * from "./radio";
52
+
51
53
  export * from "./util";
52
54
  //# sourceMappingURL=index.js.map
package/es/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AAEjC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.10\";\n\nexport * from './core/base';\nexport * from './core/type';\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';\nexport * from './util';\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAC;AAEzC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["// 导出版本号\nexport const version = \"0.18.11-alpha.0\";\n\nexport * from './core/base';\nexport * from './core/type';\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';\nexport * from './radio';\nexport * from './util';\n"]}
@@ -0,0 +1,2 @@
1
+ export * from './radio';
2
+ export * from './type';
@@ -0,0 +1,4 @@
1
+ export * from "./radio";
2
+
3
+ export * from "./type";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC","file":"index.js","sourcesContent":["export * from './radio';\nexport * from './type';\n"]}
@@ -0,0 +1,16 @@
1
+ import { AbstractComponent } from '../core/base';
2
+ import type { RadioAttributes } from './type';
3
+ import { Arc, WrapText } from '@visactor/vrender-core';
4
+ import type { ComponentOptions } from '../interface';
5
+ export declare class Radio extends AbstractComponent<Required<RadioAttributes>> {
6
+ static defaultAttributes: Partial<RadioAttributes>;
7
+ _circle: Arc;
8
+ _text: WrapText;
9
+ constructor(attributes: RadioAttributes, options?: ComponentOptions);
10
+ render(): void;
11
+ renderCircle(): void;
12
+ renderText(): void;
13
+ renderGroup(): void;
14
+ layout(): void;
15
+ private _handlePointerUp;
16
+ }
@@ -0,0 +1,87 @@
1
+ import { merge } from "@visactor/vutils";
2
+
3
+ import { AbstractComponent } from "../core/base";
4
+
5
+ import { Arc, WrapText } from "@visactor/vrender-core";
6
+
7
+ import { loadRadioComponent } from "./register";
8
+
9
+ loadRadioComponent();
10
+
11
+ export class Radio extends AbstractComponent {
12
+ constructor(attributes, options) {
13
+ super((null == options ? void 0 : options.skipDefault) ? attributes : merge({}, Radio.defaultAttributes, attributes)),
14
+ this._handlePointerUp = () => {
15
+ this.attribute.disabled || this.attribute.checked || (this.setAttribute("checked", !0),
16
+ this._dispatchEvent("radio_checked", {
17
+ eventType: "radio_checked",
18
+ target: this
19
+ }));
20
+ }, this.renderGroup(), this.onBeforeAttributeUpdate = (val, attributes, key) => {
21
+ "interactive" in val && this.setAttribute("pickable", val.interactive), "disabled" in val && this.setAttribute("cursor", val.disable ? this.attribute.disableCursor : this.attribute.cursor);
22
+ }, this.addEventListener("pointerup", this._handlePointerUp);
23
+ }
24
+ render() {
25
+ this.removeAllChild(!0), this.renderCircle(), this.renderText(), this.layout();
26
+ }
27
+ renderCircle() {
28
+ this._circle = new Arc(merge({}, this.attribute.circle));
29
+ const isChecked = this.attribute.checked;
30
+ isChecked && this.attribute.disabled ? this._circle.setAttributes({
31
+ fill: this.attribute.circle.disableCheckedFill,
32
+ stroke: this.attribute.circle.disableCheckedStroke
33
+ }) : isChecked && this._circle.setAttributes({
34
+ fill: this.attribute.circle.checkedFill,
35
+ stroke: this.attribute.circle.checkedStroke
36
+ }), this.appendChild(this._circle);
37
+ }
38
+ renderText() {
39
+ this._text = new WrapText(merge({}, this.attribute.text)), this.attribute.disabled && this._text.setAttribute("fill", this.attribute.text.disableFill),
40
+ this.appendChild(this._text);
41
+ }
42
+ renderGroup() {
43
+ this.attribute.interactive || this.setAttribute("pickable", !1), this.attribute.disabled && this.setAttribute("cursor", this.attribute.disableCursor);
44
+ }
45
+ layout() {
46
+ const circleHeight = 2 * this.attribute.circle.outerRadius, textHeight = this._text.AABBBounds.height(), maxHeight = Math.max(circleHeight, textHeight), circleY = maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius, textY = maxHeight / 2 - textHeight / 2, circleWidth = 2 * this.attribute.circle.outerRadius, circleX = this.attribute.circle.outerRadius, textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;
47
+ this._circle.setAttributes({
48
+ x: circleX,
49
+ y: circleY
50
+ }), this._text.setAttributes({
51
+ x: textX,
52
+ y: textY
53
+ });
54
+ }
55
+ }
56
+
57
+ Radio.defaultAttributes = {
58
+ interactive: !0,
59
+ disabled: !1,
60
+ checked: !1,
61
+ cursor: "pointer",
62
+ disableCursor: "not-allowed",
63
+ spaceBetweenTextAndIcon: 8,
64
+ text: {
65
+ text: "text",
66
+ fontSize: 14,
67
+ fill: "#000",
68
+ disableFill: "rgb(201,205,212)",
69
+ textBaseline: "top",
70
+ pickable: !1
71
+ },
72
+ circle: {
73
+ outerRadius: 7,
74
+ innerRadius: 3,
75
+ startAngle: 0,
76
+ endAngle: 2 * Math.PI,
77
+ fill: "#fff",
78
+ stroke: "rgb(229,230,235)",
79
+ disableFill: "rgb(242,243,245)",
80
+ checkedFill: "rgb(22, 93, 255)",
81
+ checkedStroke: "rgb(22, 93, 255)",
82
+ disableCheckedFill: "rgb(148, 191, 255)",
83
+ disableCheckedStroke: "rgb(148, 191, 255)",
84
+ pickable: !1
85
+ }
86
+ };
87
+ //# sourceMappingURL=radio.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC;YACzB,CAAC,EAAE,OAAO;YACV,CAAC,EAAE,OAAO;SACX,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YACvB,CAAC,EAAE,KAAK;YACR,CAAC,EAAE,KAAK;SACT,CAAC,CAAC;IACL,CAAC;;AA/GM,uBAAiB,GAA6B;IACnD,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,aAAa;IAC5B,uBAAuB,EAAE,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,kBAAkB;QAC/B,YAAY,EAAE,KAAK;QACnB,QAAQ,EAAE,KAAK;KAChB;IACD,MAAM,EAAE;QACN,WAAW,EAAE,CAAC;QACd,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,CAAC;QACb,QAAQ,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE;QACrB,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":"radio.js","sourcesContent":["import { merge } from '@visactor/vutils';\nimport { AbstractComponent } from '../core/base';\nimport type { RadioAttributes } from './type';\nimport { Arc, WrapText } from '@visactor/vrender-core';\nimport type { ComponentOptions } from '../interface';\nimport { loadRadioComponent } from './register';\n\nloadRadioComponent();\nexport class Radio extends AbstractComponent<Required<RadioAttributes>> {\n static defaultAttributes: Partial<RadioAttributes> = {\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 circle: {\n outerRadius: 7,\n innerRadius: 3,\n startAngle: 0,\n endAngle: 2 * Math.PI,\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 _circle: Arc;\n _text: WrapText;\n\n constructor(attributes: RadioAttributes, options?: ComponentOptions) {\n super(options?.skipDefault ? attributes : merge({}, Radio.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('pointerup', this._handlePointerUp);\n }\n\n render() {\n this.removeAllChild(true);\n\n this.renderCircle();\n this.renderText();\n this.layout();\n }\n\n renderCircle() {\n this._circle = new Arc(merge({}, this.attribute.circle));\n const isChecked = this.attribute.checked;\n if (isChecked && this.attribute.disabled) {\n this._circle.setAttributes({\n fill: this.attribute.circle.disableCheckedFill,\n stroke: this.attribute.circle.disableCheckedStroke\n });\n } else if (isChecked) {\n this._circle.setAttributes({\n fill: this.attribute.circle.checkedFill,\n stroke: this.attribute.circle.checkedStroke\n });\n }\n this.appendChild(this._circle);\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 circleHeight = this.attribute.circle.outerRadius * 2;\n const textHeight = this._text.AABBBounds.height();\n const maxHeight = Math.max(circleHeight, textHeight);\n const circleY = maxHeight / 2 - circleHeight / 2 + this.attribute.circle.outerRadius;\n const textY = maxHeight / 2 - textHeight / 2;\n\n const circleWidth = this.attribute.circle.outerRadius * 2;\n const circleX = this.attribute.circle.outerRadius;\n const textX = circleWidth + this.attribute.spaceBetweenTextAndIcon;\n\n this._circle.setAttributes({\n x: circleX,\n y: circleY\n });\n this._text.setAttributes({\n x: textX,\n y: textY\n });\n }\n\n private _handlePointerUp = () => {\n if (this.attribute.disabled || this.attribute.checked) {\n // checked do nothing\n return;\n }\n this.setAttribute('checked', true);\n\n this._dispatchEvent('radio_checked', {\n eventType: 'radio_checked',\n target: this\n });\n };\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare function loadRadioComponent(): void;
@@ -0,0 +1,6 @@
1
+ import { registerGroup, registerImage, registerRect, registerWrapText } from "@visactor/vrender-kits";
2
+
3
+ export function loadRadioComponent() {
4
+ registerGroup(), registerRect(), registerWrapText(), registerImage();
5
+ }
6
+ //# sourceMappingURL=register.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAEtG,MAAM,UAAU,kBAAkB;IAChC,aAAa,EAAE,CAAC;IAChB,YAAY,EAAE,CAAC;IACf,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,CAAC;AAClB,CAAC","file":"register.js","sourcesContent":["import { registerGroup, registerImage, registerRect, registerWrapText } from '@visactor/vrender-kits';\n\nexport function loadRadioComponent() {\n registerGroup();\n registerRect();\n registerWrapText();\n registerImage();\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import type { Cursor, IArcGraphicAttribute, IColor, IGroupGraphicAttribute, IWrapTextGraphicAttribute } from '@visactor/vrender-core';
2
+ export type RadioText = {
3
+ disableFill?: IColor;
4
+ } & IWrapTextGraphicAttribute;
5
+ export type CircleStyle = {
6
+ disableFill?: IColor;
7
+ checkedFill?: IColor;
8
+ checkedStroke?: IColor;
9
+ disableCheckedFill?: IColor;
10
+ disableCheckedStroke?: IColor;
11
+ } & IArcGraphicAttribute;
12
+ export type RadioAttributes = IGroupGraphicAttribute & {
13
+ id?: string;
14
+ interactive?: boolean;
15
+ disabled?: boolean;
16
+ checked?: boolean;
17
+ text?: RadioText;
18
+ circle?: CircleStyle;
19
+ disableCursor?: Cursor;
20
+ spaceBetweenTextAndIcon?: number;
21
+ };
@@ -0,0 +1,2 @@
1
+ export { };
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/radio/type.ts"],"names":[],"mappings":"","file":"type.js","sourcesContent":["import type {\n Cursor,\n IArcGraphicAttribute,\n IColor,\n IGroupGraphicAttribute,\n IWrapTextGraphicAttribute\n} from '@visactor/vrender-core';\n\nexport type RadioText = {\n disableFill?: IColor;\n} & IWrapTextGraphicAttribute;\n\nexport type CircleStyle = {\n disableFill?: IColor;\n checkedFill?: IColor;\n checkedStroke?: IColor;\n disableCheckedFill?: IColor;\n disableCheckedStroke?: IColor;\n} & IArcGraphicAttribute;\n\nexport type RadioAttributes = IGroupGraphicAttribute & {\n id?: string;\n\n interactive?: boolean;\n disabled?: boolean;\n checked?: boolean;\n\n /**\n * 图例文字\n */\n text?: RadioText;\n /**\n * 图例选中图标\n */\n circle?: CircleStyle;\n /**\n * 图例选中图标\n */\n disableCursor?: Cursor;\n spaceBetweenTextAndIcon?: number;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-components",
3
- "version": "0.18.10",
3
+ "version": "0.18.11-alpha.0",
4
4
  "description": "components library for dp visualization",
5
5
  "sideEffects": false,
6
6
  "main": "cjs/index.js",
@@ -12,8 +12,8 @@
12
12
  "dist"
13
13
  ],
14
14
  "dependencies": {
15
- "@visactor/vrender-core": "0.18.10",
16
- "@visactor/vrender-kits": "0.18.10",
15
+ "@visactor/vrender-core": "0.18.11-alpha.0",
16
+ "@visactor/vrender-kits": "0.18.11-alpha.0",
17
17
  "@visactor/vutils": "~0.18.1",
18
18
  "@visactor/vscale": "~0.17.3"
19
19
  },