@antv/component 2.1.7 → 2.1.8
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/ui/axis/axis.js +18 -2
- package/esm/ui/axis/axis.js.map +1 -1
- package/esm/ui/axis/classname-map.d.ts +18 -0
- package/esm/ui/axis/classname-map.js +20 -0
- package/esm/ui/axis/classname-map.js.map +1 -0
- package/esm/ui/axis/constant.js +16 -15
- package/esm/ui/axis/constant.js.map +1 -1
- package/esm/ui/axis/guides/grid.js +8 -1
- package/esm/ui/axis/guides/grid.js.map +1 -1
- package/esm/ui/axis/guides/labels.js +11 -4
- package/esm/ui/axis/guides/labels.js.map +1 -1
- package/esm/ui/axis/guides/line.js +31 -8
- package/esm/ui/axis/guides/line.js.map +1 -1
- package/esm/ui/axis/guides/ticks.js +10 -3
- package/esm/ui/axis/guides/ticks.js.map +1 -1
- package/esm/ui/axis/guides/title.js +6 -2
- package/esm/ui/axis/guides/title.js.map +1 -1
- package/esm/ui/axis/types.d.ts +1 -0
- package/esm/ui/axis/utils/classname.d.ts +46 -0
- package/esm/ui/axis/utils/classname.js +53 -0
- package/esm/ui/axis/utils/classname.js.map +1 -0
- package/esm/ui/axis/utils/index.d.ts +1 -0
- package/esm/ui/axis/utils/index.js +1 -0
- package/esm/ui/axis/utils/index.js.map +1 -1
- package/esm/ui/legend/category/item.d.ts +3 -1
- package/esm/ui/legend/category/item.js +42 -14
- package/esm/ui/legend/category/item.js.map +1 -1
- package/esm/ui/legend/category/items.d.ts +2 -0
- package/esm/ui/legend/category/items.js +12 -9
- package/esm/ui/legend/category/items.js.map +1 -1
- package/esm/ui/legend/category.js +11 -3
- package/esm/ui/legend/category.js.map +1 -1
- package/esm/ui/legend/classname-map.d.ts +37 -0
- package/esm/ui/legend/classname-map.js +38 -0
- package/esm/ui/legend/classname-map.js.map +1 -0
- package/esm/ui/legend/constant.d.ts +1 -0
- package/esm/ui/legend/constant.js +1 -0
- package/esm/ui/legend/constant.js.map +1 -1
- package/esm/ui/legend/continuous/handle.d.ts +1 -0
- package/esm/ui/legend/continuous/handle.js +23 -3
- package/esm/ui/legend/continuous/handle.js.map +1 -1
- package/esm/ui/legend/continuous/ribbon.d.ts +1 -0
- package/esm/ui/legend/continuous/ribbon.js +11 -1
- package/esm/ui/legend/continuous/ribbon.js.map +1 -1
- package/esm/ui/legend/continuous.d.ts +6 -0
- package/esm/ui/legend/continuous.js +77 -10
- package/esm/ui/legend/continuous.js.map +1 -1
- package/esm/ui/legend/title/index.js +5 -1
- package/esm/ui/legend/title/index.js.map +1 -1
- package/esm/ui/legend/title/types.d.ts +1 -0
- package/esm/ui/legend/types.d.ts +1 -0
- package/esm/ui/legend/utils/classname.d.ts +31 -0
- package/esm/ui/legend/utils/classname.js +35 -0
- package/esm/ui/legend/utils/classname.js.map +1 -0
- package/esm/ui/legend/utils/index.d.ts +1 -0
- package/esm/ui/legend/utils/index.js +2 -0
- package/esm/ui/legend/utils/index.js.map +1 -0
- package/esm/ui/navigator/index.js +19 -4
- package/esm/ui/navigator/index.js.map +1 -1
- package/esm/ui/navigator/types.d.ts +1 -0
- package/esm/ui/slider/handle.d.ts +2 -0
- package/esm/ui/slider/handle.js +21 -6
- package/esm/ui/slider/handle.js.map +1 -1
- package/lib/ui/axis/axis.js +18 -2
- package/lib/ui/axis/axis.js.map +1 -1
- package/lib/ui/axis/classname-map.d.ts +18 -0
- package/lib/ui/axis/classname-map.js +23 -0
- package/lib/ui/axis/classname-map.js.map +1 -0
- package/lib/ui/axis/constant.js +16 -15
- package/lib/ui/axis/constant.js.map +1 -1
- package/lib/ui/axis/guides/grid.js +8 -1
- package/lib/ui/axis/guides/grid.js.map +1 -1
- package/lib/ui/axis/guides/labels.js +11 -4
- package/lib/ui/axis/guides/labels.js.map +1 -1
- package/lib/ui/axis/guides/line.js +31 -8
- package/lib/ui/axis/guides/line.js.map +1 -1
- package/lib/ui/axis/guides/ticks.js +10 -3
- package/lib/ui/axis/guides/ticks.js.map +1 -1
- package/lib/ui/axis/guides/title.js +6 -2
- package/lib/ui/axis/guides/title.js.map +1 -1
- package/lib/ui/axis/types.d.ts +1 -0
- package/lib/ui/axis/utils/classname.d.ts +46 -0
- package/lib/ui/axis/utils/classname.js +58 -0
- package/lib/ui/axis/utils/classname.js.map +1 -0
- package/lib/ui/axis/utils/index.d.ts +1 -0
- package/lib/ui/axis/utils/index.js +1 -0
- package/lib/ui/axis/utils/index.js.map +1 -1
- package/lib/ui/legend/category/item.d.ts +3 -1
- package/lib/ui/legend/category/item.js +42 -14
- package/lib/ui/legend/category/item.js.map +1 -1
- package/lib/ui/legend/category/items.d.ts +2 -0
- package/lib/ui/legend/category/items.js +11 -8
- package/lib/ui/legend/category/items.js.map +1 -1
- package/lib/ui/legend/category.js +11 -3
- package/lib/ui/legend/category.js.map +1 -1
- package/lib/ui/legend/classname-map.d.ts +37 -0
- package/lib/ui/legend/classname-map.js +41 -0
- package/lib/ui/legend/classname-map.js.map +1 -0
- package/lib/ui/legend/constant.d.ts +1 -0
- package/lib/ui/legend/constant.js +3 -1
- package/lib/ui/legend/constant.js.map +1 -1
- package/lib/ui/legend/continuous/handle.d.ts +1 -0
- package/lib/ui/legend/continuous/handle.js +23 -3
- package/lib/ui/legend/continuous/handle.js.map +1 -1
- package/lib/ui/legend/continuous/ribbon.d.ts +1 -0
- package/lib/ui/legend/continuous/ribbon.js +11 -1
- package/lib/ui/legend/continuous/ribbon.js.map +1 -1
- package/lib/ui/legend/continuous.d.ts +6 -0
- package/lib/ui/legend/continuous.js +76 -9
- package/lib/ui/legend/continuous.js.map +1 -1
- package/lib/ui/legend/title/index.js +5 -1
- package/lib/ui/legend/title/index.js.map +1 -1
- package/lib/ui/legend/title/types.d.ts +1 -0
- package/lib/ui/legend/types.d.ts +1 -0
- package/lib/ui/legend/utils/classname.d.ts +31 -0
- package/lib/ui/legend/utils/classname.js +39 -0
- package/lib/ui/legend/utils/classname.js.map +1 -0
- package/lib/ui/legend/utils/index.d.ts +1 -0
- package/lib/ui/legend/utils/index.js +5 -0
- package/lib/ui/legend/utils/index.js.map +1 -0
- package/lib/ui/navigator/index.js +19 -4
- package/lib/ui/navigator/index.js.map +1 -1
- package/lib/ui/navigator/types.d.ts +1 -0
- package/lib/ui/slider/handle.d.ts +2 -0
- package/lib/ui/slider/handle.js +21 -6
- package/lib/ui/slider/handle.js.map +1 -1
- package/package.json +2 -2
- package/src/ui/axis/axis.ts +19 -2
- package/src/ui/axis/classname-map.ts +22 -0
- package/src/ui/axis/constant.ts +17 -15
- package/src/ui/axis/guides/grid.ts +8 -1
- package/src/ui/axis/guides/labels.ts +16 -6
- package/src/ui/axis/guides/line.ts +50 -12
- package/src/ui/axis/guides/ticks.ts +15 -5
- package/src/ui/axis/guides/title.ts +10 -4
- package/src/ui/axis/types.ts +1 -0
- package/src/ui/axis/utils/classname.ts +62 -0
- package/src/ui/axis/utils/index.ts +1 -0
- package/src/ui/legend/category/item.ts +59 -12
- package/src/ui/legend/category/items.ts +17 -7
- package/src/ui/legend/category.ts +12 -3
- package/src/ui/legend/classname-map.ts +45 -0
- package/src/ui/legend/constant.ts +2 -0
- package/src/ui/legend/continuous/handle.ts +41 -4
- package/src/ui/legend/continuous/ribbon.ts +17 -1
- package/src/ui/legend/continuous.ts +96 -10
- package/src/ui/legend/title/index.ts +5 -1
- package/src/ui/legend/title/types.ts +1 -0
- package/src/ui/legend/types.ts +1 -0
- package/src/ui/legend/utils/classname.ts +39 -0
- package/src/ui/legend/utils/index.ts +1 -0
- package/src/ui/navigator/index.ts +32 -2
- package/src/ui/navigator/types.ts +1 -0
- package/src/ui/slider/handle.ts +44 -6
package/src/ui/legend/types.ts
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legend className utility functions
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generate legend className with optional prefix
|
|
7
|
+
* @param baseClassName - Base className, e.g., 'title-text'
|
|
8
|
+
* @param suffix - Suffix for prefixed className, e.g., 'title' -> '{prefix}legend-title'
|
|
9
|
+
* @param classNamePrefix - Optional className prefix, e.g., 'g2-'
|
|
10
|
+
* @returns Complete className, e.g., 'title-text g2-legend-title'
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* getLegendClassName('title-text', 'title', 'g2-')
|
|
14
|
+
* // Returns: 'title-text g2-legend-title'
|
|
15
|
+
*/
|
|
16
|
+
export function getLegendClassName(baseClassName: string, suffix: string, classNamePrefix?: string): string {
|
|
17
|
+
if (!classNamePrefix) return baseClassName;
|
|
18
|
+
return `${baseClassName} ${classNamePrefix}legend-${suffix}`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Generate className from component attributes
|
|
23
|
+
* @param attributes - Component attributes with classNamePrefix
|
|
24
|
+
* @param baseClassName - CLASS_NAMES object, e.g., CLASS_NAMES.text
|
|
25
|
+
* @param suffix - Suffix key from CLASSNAME_SUFFIX_MAP
|
|
26
|
+
* @returns Complete className
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* getClassNameFromAttrs(this.attributes, CLASS_NAMES.text, 'title')
|
|
30
|
+
* // Returns: 'title-text g2-legend-title' (if classNamePrefix = 'g2-')
|
|
31
|
+
*/
|
|
32
|
+
export function getClassNameFromAttrs(
|
|
33
|
+
attributes: { classNamePrefix?: string },
|
|
34
|
+
baseClassName: { name: string },
|
|
35
|
+
suffix: string
|
|
36
|
+
): string {
|
|
37
|
+
const { classNamePrefix = '' } = attributes;
|
|
38
|
+
return getLegendClassName(baseClassName.name, suffix, classNamePrefix);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './classname';
|
|
@@ -19,6 +19,8 @@ import {
|
|
|
19
19
|
} from '../../util';
|
|
20
20
|
import { button } from '../marker/symbol';
|
|
21
21
|
import type { NavigatorOptions, NavigatorStyleProps } from './types';
|
|
22
|
+
import { CLASSNAME_SUFFIX_MAP } from '../legend/classname-map';
|
|
23
|
+
import { getLegendClassName } from '../legend/utils/classname';
|
|
22
24
|
|
|
23
25
|
export type { NavigatorOptions, NavigatorStyleProps };
|
|
24
26
|
|
|
@@ -272,7 +274,7 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
private renderController(container: Selection) {
|
|
275
|
-
const { controllerSpacing: spacing } = this.attributes;
|
|
277
|
+
const { controllerSpacing: spacing, classNamePrefix = '' } = this.attributes;
|
|
276
278
|
const { pageWidth, pageHeight } = this.pageShape;
|
|
277
279
|
const visible = this.pageViews.length >= 2;
|
|
278
280
|
|
|
@@ -291,10 +293,28 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
291
293
|
this.prevBtnGroup = prevBtnGroup.node();
|
|
292
294
|
const prevBtn = prevBtnGroup.maybeAppendByClassName(CLASS_NAMES.prevBtn, 'path');
|
|
293
295
|
|
|
296
|
+
if (classNamePrefix) {
|
|
297
|
+
const prevBtnClassName = getLegendClassName(
|
|
298
|
+
CLASS_NAMES.prevBtn.name,
|
|
299
|
+
CLASSNAME_SUFFIX_MAP.prevBtn,
|
|
300
|
+
classNamePrefix
|
|
301
|
+
);
|
|
302
|
+
prevBtn.node().setAttribute('class', prevBtnClassName);
|
|
303
|
+
}
|
|
304
|
+
|
|
294
305
|
const nextBtnGroup = group.maybeAppendByClassName(CLASS_NAMES.nextBtnGroup, 'g').styles(groupStyle);
|
|
295
306
|
this.nextBtnGroup = nextBtnGroup.node();
|
|
296
307
|
const nextBtn = nextBtnGroup.maybeAppendByClassName(CLASS_NAMES.nextBtn, 'path');
|
|
297
308
|
|
|
309
|
+
if (classNamePrefix) {
|
|
310
|
+
const nextBtnClassName = getLegendClassName(
|
|
311
|
+
CLASS_NAMES.nextBtn.name,
|
|
312
|
+
CLASSNAME_SUFFIX_MAP.nextBtn,
|
|
313
|
+
classNamePrefix
|
|
314
|
+
);
|
|
315
|
+
nextBtn.node().setAttribute('class', nextBtnClassName);
|
|
316
|
+
}
|
|
317
|
+
|
|
298
318
|
[prevBtn, nextBtn].forEach((btn) => {
|
|
299
319
|
btn.styles({ ...pathStyle, transformOrigin: 'center' });
|
|
300
320
|
scaleToPixel(btn.node(), size, true);
|
|
@@ -303,7 +323,17 @@ export class Navigator extends Component<NavigatorStyleProps> {
|
|
|
303
323
|
const pageInfoGroup = group.maybeAppendByClassName(CLASS_NAMES.pageInfoGroup, 'g');
|
|
304
324
|
this.pageInfoGroup = pageInfoGroup.node();
|
|
305
325
|
|
|
306
|
-
pageInfoGroup.maybeAppendByClassName(CLASS_NAMES.pageInfo, 'text')
|
|
326
|
+
const pageInfoElement = pageInfoGroup.maybeAppendByClassName(CLASS_NAMES.pageInfo, 'text');
|
|
327
|
+
pageInfoElement.styles(textStyle);
|
|
328
|
+
|
|
329
|
+
if (classNamePrefix) {
|
|
330
|
+
const pageInfoClassName = getLegendClassName(
|
|
331
|
+
CLASS_NAMES.pageInfo.name,
|
|
332
|
+
CLASSNAME_SUFFIX_MAP.pageInfo,
|
|
333
|
+
classNamePrefix
|
|
334
|
+
);
|
|
335
|
+
pageInfoElement.node().setAttribute('class', pageInfoClassName);
|
|
336
|
+
}
|
|
307
337
|
|
|
308
338
|
this.updatePageInfo();
|
|
309
339
|
|
|
@@ -21,6 +21,7 @@ export type NavigatorStyleProps = Omit<RectStyleProps, 'width' | 'height'> &
|
|
|
21
21
|
pageWidth?: number;
|
|
22
22
|
/** infer to pageWidth */
|
|
23
23
|
pageHeight?: number;
|
|
24
|
+
classNamePrefix?: string;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export type NavigatorOptions = ComponentOptions<NavigatorStyleProps>;
|
package/src/ui/slider/handle.ts
CHANGED
|
@@ -14,6 +14,7 @@ export type IconStyleProps = PathStyleProps & {
|
|
|
14
14
|
radius?: number;
|
|
15
15
|
shape?: string | ((type: HandleType) => DisplayObject);
|
|
16
16
|
orientation?: 'horizontal' | 'vertical';
|
|
17
|
+
classNamePrefix?: string;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export type LabelStyleProps = Partial<TextStyleProps>;
|
|
@@ -27,6 +28,7 @@ export type HandleStyleProps = GroupStyleProps &
|
|
|
27
28
|
showLabel?: boolean;
|
|
28
29
|
spacing?: number;
|
|
29
30
|
type?: HandleType;
|
|
31
|
+
classNamePrefix?: string;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export type HandleOptions = ComponentOptions<HandleStyleProps>;
|
|
@@ -45,13 +47,23 @@ const CLASS_NAMES = classNames(
|
|
|
45
47
|
|
|
46
48
|
class HandleIcon extends Component<IconStyleProps> {
|
|
47
49
|
render(attributes: Required<IconStyleProps>, container: DisplayObject) {
|
|
48
|
-
const { x, y, size = 10, radius = size / 4, orientation, ...iconStyle } = attributes;
|
|
49
|
-
//
|
|
50
|
+
const { x, y, size = 10, radius = size / 4, orientation, classNamePrefix, ...iconStyle } = attributes;
|
|
51
|
+
// default handle
|
|
50
52
|
const width = size!;
|
|
51
53
|
const height = width * 2.4;
|
|
52
54
|
|
|
55
|
+
const rectClassName = classNamePrefix
|
|
56
|
+
? `${CLASS_NAMES.iconRect.name} ${classNamePrefix}handle-icon-rect`
|
|
57
|
+
: CLASS_NAMES.iconRect.name;
|
|
58
|
+
|
|
59
|
+
const lineClassName = (index: number) =>
|
|
60
|
+
classNamePrefix
|
|
61
|
+
? `${CLASS_NAMES.iconLine}-${index} ${classNamePrefix}handle-icon-line`
|
|
62
|
+
: `${CLASS_NAMES.iconLine}-${index}`;
|
|
63
|
+
|
|
53
64
|
const rect = select(container)
|
|
54
65
|
.maybeAppendByClassName(CLASS_NAMES.iconRect, 'rect')
|
|
66
|
+
.attr('className', rectClassName)
|
|
55
67
|
.styles({
|
|
56
68
|
...iconStyle,
|
|
57
69
|
width,
|
|
@@ -67,8 +79,27 @@ class HandleIcon extends Component<IconStyleProps> {
|
|
|
67
79
|
const y1 = y + (1 / 4) * height - height / 2;
|
|
68
80
|
const y2 = y + (3 / 4) * height - height / 2;
|
|
69
81
|
|
|
70
|
-
rect
|
|
71
|
-
|
|
82
|
+
rect
|
|
83
|
+
.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-1`, 'line')
|
|
84
|
+
.attr('className', lineClassName(1))
|
|
85
|
+
.styles({
|
|
86
|
+
x1,
|
|
87
|
+
x2: x1,
|
|
88
|
+
y1,
|
|
89
|
+
y2,
|
|
90
|
+
...iconStyle,
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
rect
|
|
94
|
+
.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-2`, 'line')
|
|
95
|
+
.attr('className', lineClassName(2))
|
|
96
|
+
.styles({
|
|
97
|
+
x1: x2,
|
|
98
|
+
x2,
|
|
99
|
+
y1,
|
|
100
|
+
y2,
|
|
101
|
+
...iconStyle,
|
|
102
|
+
});
|
|
72
103
|
|
|
73
104
|
if (orientation === 'vertical') rect.node().style.transform = 'rotate(90)';
|
|
74
105
|
}
|
|
@@ -119,8 +150,15 @@ export class Handle extends Component<HandleStyleProps> {
|
|
|
119
150
|
}
|
|
120
151
|
|
|
121
152
|
private renderIcon(container: Group) {
|
|
122
|
-
const { x, y, orientation, type } = this.attributes;
|
|
123
|
-
const iconStyle = {
|
|
153
|
+
const { x, y, orientation, type, classNamePrefix } = this.attributes;
|
|
154
|
+
const iconStyle = {
|
|
155
|
+
x,
|
|
156
|
+
y,
|
|
157
|
+
orientation,
|
|
158
|
+
classNamePrefix,
|
|
159
|
+
...HANDLE_ICON_DEFAULT_CFG,
|
|
160
|
+
...subStyleProps(this.attributes, 'icon'),
|
|
161
|
+
};
|
|
124
162
|
const { iconShape = () => new HandleIcon({ style: iconStyle }) } = this.attributes;
|
|
125
163
|
const iconGroup = select(container).maybeAppendByClassName(CLASS_NAMES.iconGroup, 'g');
|
|
126
164
|
iconGroup
|