@antv/component 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/component.min.js +1 -1
- package/esm/animation/fadeIn.d.ts +1 -1
- package/esm/animation/fadeOut.d.ts +1 -1
- package/esm/animation/utils.d.ts +3 -3
- package/esm/core/component.d.ts +1 -0
- package/esm/core/component.js +5 -1
- package/esm/core/component.js.map +1 -1
- package/esm/ui/axis/axis.d.ts +1 -1
- package/esm/ui/axis/guides/grid.d.ts +1 -1
- package/esm/ui/axis/guides/labels.d.ts +1 -1
- package/esm/ui/axis/guides/ticks.d.ts +1 -1
- package/esm/ui/axis/guides/title.d.ts +1 -1
- package/esm/ui/checkbox/constant.d.ts +3 -3
- package/esm/ui/grid/index.d.ts +1 -1
- package/esm/ui/legend/base.d.ts +1 -1
- package/esm/ui/legend/category/item.js +14 -5
- package/esm/ui/legend/category/item.js.map +1 -1
- package/esm/ui/marker/index.js +1 -1
- package/esm/ui/marker/index.js.map +1 -1
- package/esm/ui/timebar/icons.d.ts +2 -2
- package/esm/util/keyframe-interpolate.d.ts +1 -1
- package/esm/util/number.d.ts +2 -2
- package/esm/util/text.d.ts +6 -1
- package/lib/animation/fadeIn.d.ts +1 -1
- package/lib/animation/fadeOut.d.ts +1 -1
- package/lib/animation/utils.d.ts +3 -3
- package/lib/core/component.d.ts +1 -0
- package/lib/core/component.js +4 -0
- package/lib/core/component.js.map +1 -1
- package/lib/ui/axis/axis.d.ts +1 -1
- package/lib/ui/axis/guides/grid.d.ts +1 -1
- package/lib/ui/axis/guides/labels.d.ts +1 -1
- package/lib/ui/axis/guides/ticks.d.ts +1 -1
- package/lib/ui/axis/guides/title.d.ts +1 -1
- package/lib/ui/checkbox/constant.d.ts +3 -3
- package/lib/ui/grid/index.d.ts +1 -1
- package/lib/ui/legend/base.d.ts +1 -1
- package/lib/ui/legend/category/item.js +14 -5
- package/lib/ui/legend/category/item.js.map +1 -1
- package/lib/ui/marker/index.js +1 -1
- package/lib/ui/marker/index.js.map +1 -1
- package/lib/ui/timebar/icons.d.ts +2 -2
- package/lib/util/keyframe-interpolate.d.ts +1 -1
- package/lib/util/number.d.ts +2 -2
- package/lib/util/text.d.ts +6 -1
- package/package.json +2 -1
- package/src/core/component.ts +5 -0
- package/src/ui/legend/category/item.ts +12 -5
- package/src/ui/marker/index.ts +1 -1
package/lib/util/number.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare function toScientificNotation(num: number): string;
|
|
|
18
18
|
* 12345 -> 12K
|
|
19
19
|
*/
|
|
20
20
|
export declare function toKNotation(num: number, precision?: number): string;
|
|
21
|
-
export declare const ifNegative: <T extends string | number | symbol>(x: any, a: T, b?: T
|
|
22
|
-
export declare const ifPositive: <T extends string | number | symbol>(x: any, a: T, b?: T
|
|
21
|
+
export declare const ifNegative: <T extends string | number | symbol>(x: any, a: T, b?: T) => T | undefined;
|
|
22
|
+
export declare const ifPositive: <T extends string | number | symbol>(x: any, a: T, b?: T) => T | undefined;
|
|
23
23
|
export declare const multi: (a: number, b: number) => number;
|
|
24
24
|
export declare const mid: (a: number, b?: number) => number;
|
package/lib/util/text.d.ts
CHANGED
|
@@ -5,7 +5,12 @@ export declare function setMockMeasureTextWidth(mock: (text: string, fontSize: n
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const measureTextWidth: {
|
|
7
7
|
(...args: any[]): any;
|
|
8
|
-
cache:
|
|
8
|
+
cache: {
|
|
9
|
+
clear: (isPartial?: number | undefined) => void;
|
|
10
|
+
has: (key: any) => boolean;
|
|
11
|
+
get: (key: any) => any;
|
|
12
|
+
set: (key: any, value: any) => void;
|
|
13
|
+
};
|
|
9
14
|
};
|
|
10
15
|
export declare const getFont: (textShape: Text) => {
|
|
11
16
|
fontSize: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Visualization components for AntV, based on G.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"build:cjs": "tsc -p tsconfig.json --target ES5 --module commonjs --outDir lib",
|
|
35
35
|
"build:esm": "tsc -p tsconfig.json --target ES5 --module ESNext --outDir esm",
|
|
36
36
|
"ci": "run-s lint test build",
|
|
37
|
+
"prepublishOnly": "npm run ci",
|
|
37
38
|
"prepare": "husky install"
|
|
38
39
|
},
|
|
39
40
|
"keywords": [
|
package/src/core/component.ts
CHANGED
|
@@ -60,4 +60,9 @@ export abstract class Component<T extends Record<string, any>> extends CustomEle
|
|
|
60
60
|
): void | AnimationResult[];
|
|
61
61
|
|
|
62
62
|
public bindEvents(attributes: T, container: Group): void {}
|
|
63
|
+
|
|
64
|
+
protected getSubShapeStyle(attributes: T): T {
|
|
65
|
+
const { x, y, transform, transformOrigin, class: _class, className, zIndex, ...style } = attributes;
|
|
66
|
+
return style as T;
|
|
67
|
+
}
|
|
63
68
|
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
RectStyleProps,
|
|
9
9
|
TextStyleProps,
|
|
10
10
|
} from '@antv/g';
|
|
11
|
+
import { Marker } from '../../marker';
|
|
11
12
|
import type { ComponentOptions } from '../../../core';
|
|
12
13
|
import { Component } from '../../../core';
|
|
13
14
|
import { ExtendDisplayObject, PrefixObject } from '../../../types';
|
|
@@ -179,15 +180,21 @@ export class CategoryItem extends Component<CategoryItemStyleProps> {
|
|
|
179
180
|
this.markerGroup = container.maybeAppendByClassName(CLASS_NAMES.markerGroup, 'g').style('zIndex', 0);
|
|
180
181
|
ifShow(!!marker, this.markerGroup, () => {
|
|
181
182
|
const parent = this.markerGroup.node();
|
|
182
|
-
const oldMarker = parent.
|
|
183
|
-
const newMarker =
|
|
183
|
+
const oldMarker = parent.childNodes?.[0] as DisplayObject | undefined;
|
|
184
|
+
const newMarker =
|
|
185
|
+
typeof marker === 'string'
|
|
186
|
+
? new Marker({ style: { symbol: marker }, className: CLASS_NAMES.marker.name })
|
|
187
|
+
: marker();
|
|
184
188
|
|
|
185
189
|
if (!oldMarker) {
|
|
186
|
-
select(newMarker).attr('className', CLASS_NAMES.marker.name).styles(style);
|
|
190
|
+
if (!(newMarker instanceof Marker)) select(newMarker).attr('className', CLASS_NAMES.marker.name).styles(style);
|
|
187
191
|
parent.appendChild(newMarker);
|
|
188
192
|
} else if (newMarker.nodeName === oldMarker.nodeName) {
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
if (oldMarker instanceof Marker) oldMarker.update({ ...style, symbol: marker });
|
|
194
|
+
else {
|
|
195
|
+
copyAttributes(oldMarker, newMarker);
|
|
196
|
+
select(oldMarker).styles(style);
|
|
197
|
+
}
|
|
191
198
|
} else {
|
|
192
199
|
oldMarker.remove();
|
|
193
200
|
select(newMarker).attr('className', CLASS_NAMES.marker.name).styles(style);
|
package/src/ui/marker/index.ts
CHANGED
|
@@ -44,7 +44,7 @@ function getType(symbol: MarkerStyleProps['symbol']): string | null {
|
|
|
44
44
|
|
|
45
45
|
export class Marker extends Component<MarkerStyleProps> {
|
|
46
46
|
public render(attributes: Required<MarkerStyleProps>, container: Group) {
|
|
47
|
-
const { symbol, size = 16, ...style } = attributes;
|
|
47
|
+
const { symbol, size = 16, ...style } = this.getSubShapeStyle(attributes);
|
|
48
48
|
const type = getType(symbol);
|
|
49
49
|
ifShow(!!type, select(container), (group) => {
|
|
50
50
|
group
|