vccs 0.3.0 → 0.4.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.
@@ -63,7 +63,7 @@ export declare const XAxis: import('vue').DefineComponent<import('vue').ExtractP
63
63
  type: PropType<AxisDomain>;
64
64
  };
65
65
  axisLine: {
66
- type: BooleanConstructor;
66
+ type: (ObjectConstructor | BooleanConstructor)[];
67
67
  default: boolean;
68
68
  };
69
69
  ticks: {
@@ -146,7 +146,7 @@ export declare const XAxis: import('vue').DefineComponent<import('vue').ExtractP
146
146
  type: PropType<AxisDomain>;
147
147
  };
148
148
  axisLine: {
149
- type: BooleanConstructor;
149
+ type: (ObjectConstructor | BooleanConstructor)[];
150
150
  default: boolean;
151
151
  };
152
152
  ticks: {
@@ -184,6 +184,6 @@ export declare const XAxis: import('vue').DefineComponent<import('vue').ExtractP
184
184
  allowDecimals: boolean;
185
185
  mirror: boolean;
186
186
  minTickGap: number;
187
- axisLine: boolean;
187
+ axisLine: boolean | Record<string, any>;
188
188
  tickLine: boolean | Record<string, any>;
189
189
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -3,7 +3,7 @@ import { VueClassValue } from '../../types/common';
3
3
  import { AxisInterval } from '../../types/axis';
4
4
  import { RechartsScale } from '../../types/scale';
5
5
  import { CartesianTickItem } from '../../types/tick';
6
- import { PropType } from 'vue';
6
+ import { PropType, SVGAttributes } from 'vue';
7
7
  /** The orientation of the axis in correspondence to the chart */
8
8
  export type Orientation = 'top' | 'bottom' | 'left' | 'right';
9
9
  /** A unit to be appended to a value */
@@ -30,7 +30,7 @@ export interface CartesianAxisProps {
30
30
  interval?: AxisInterval;
31
31
  angle?: number;
32
32
  scale: RechartsScale;
33
- axisLine?: string;
33
+ axisLine?: boolean | SVGAttributes;
34
34
  }
35
35
  export declare const CartesianAxis: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
36
36
  x: {
@@ -68,7 +68,7 @@ export declare const CartesianAxis: import('vue').DefineComponent<import('vue').
68
68
  default: boolean;
69
69
  };
70
70
  axisLine: {
71
- type: (ObjectConstructor | BooleanConstructor)[];
71
+ type: PropType<boolean | SVGAttributes>;
72
72
  default: () => boolean;
73
73
  };
74
74
  tickLine: {
@@ -146,7 +146,7 @@ export declare const CartesianAxis: import('vue').DefineComponent<import('vue').
146
146
  default: boolean;
147
147
  };
148
148
  axisLine: {
149
- type: (ObjectConstructor | BooleanConstructor)[];
149
+ type: PropType<boolean | SVGAttributes>;
150
150
  default: () => boolean;
151
151
  };
152
152
  tickLine: {
@@ -203,7 +203,7 @@ export declare const CartesianAxis: import('vue').DefineComponent<import('vue').
203
203
  hide: boolean;
204
204
  mirror: boolean;
205
205
  minTickGap: number;
206
- axisLine: boolean | Record<string, any>;
206
+ axisLine: boolean;
207
207
  tickLine: boolean | Record<string, any>;
208
208
  tickSize: number;
209
209
  tickMargin: number;
@@ -1,4 +1,13 @@
1
- declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
1
+ declare function __VLS_template(): {
2
+ attrs: Partial<{}>;
3
+ slots: {
4
+ default?(_: {}): any;
5
+ };
6
+ refs: {};
7
+ rootEl: SVGTextElement;
8
+ };
9
+ type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
+ declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
11
  x: {
3
12
  type: (NumberConstructor | StringConstructor)[];
4
13
  default: number;
@@ -146,4 +155,10 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
146
155
  breakAll: boolean;
147
156
  maxLines: number;
148
157
  }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, SVGTextElement>;
158
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
149
159
  export default _default;
160
+ type __VLS_WithTemplateSlots<T, S> = T & {
161
+ new (): {
162
+ $slots: S;
163
+ };
164
+ };
@@ -1,8 +1,9 @@
1
1
  import { PropType, SlotsType } from 'vue';
2
2
  import { TooltipIndex, TooltipPayload, TooltipPayloadEntry } from '../state/tooltipSlice';
3
3
  import { AxisId } from '../state/cartesianAxisSlice';
4
- import { ChartCoordinate, Coordinate } from '../types';
4
+ import { ChartCoordinate, Coordinate, LayoutType } from '../types';
5
5
  import { TooltipTrigger } from '../types/tooltip';
6
+ import { Point } from '../shape';
6
7
  export type ContentType = any | ((props: TooltipContentProps) => any);
7
8
  export type TooltipContentProps = {
8
9
  label?: string | number;
@@ -16,6 +17,49 @@ type AllowInDimension = {
16
17
  x: boolean;
17
18
  y: boolean;
18
19
  };
20
+ type CursorSlotCommon = {
21
+ class: string | string[];
22
+ style: {
23
+ pointerEvents: 'none';
24
+ };
25
+ /** Chart area offset — same fields spread by Recharts: left, top, width, height */
26
+ left: number;
27
+ top: number;
28
+ width: number;
29
+ height: number;
30
+ payload: TooltipPayload;
31
+ /** Active tooltip index — named payloadIndex to match Recharts */
32
+ payloadIndex: string | undefined;
33
+ [key: string]: any;
34
+ };
35
+ export type CrossCursorSlotProps = CursorSlotCommon & {
36
+ stroke: string;
37
+ fill: string;
38
+ x: number;
39
+ y: number;
40
+ };
41
+ export type RectangleCursorSlotProps = CursorSlotCommon & {
42
+ stroke: string;
43
+ fill: string;
44
+ x: number;
45
+ y: number;
46
+ };
47
+ export type SectorCursorSlotProps = CursorSlotCommon & {
48
+ stroke: string;
49
+ fill: string;
50
+ cx: number;
51
+ cy: number;
52
+ startAngle: number;
53
+ endAngle: number;
54
+ innerRadius: number;
55
+ outerRadius: number;
56
+ };
57
+ export type CurveCursorSlotProps = CursorSlotCommon & {
58
+ stroke: string;
59
+ layout: LayoutType;
60
+ points: ReadonlyArray<Point>;
61
+ };
62
+ export type CursorSlotProps = CrossCursorSlotProps | RectangleCursorSlotProps | SectorCursorSlotProps | CurveCursorSlotProps;
19
63
  type UniqueFunc<T> = (entry: T) => unknown;
20
64
  export type UniqueOption<T> = boolean | UniqueFunc<T>;
21
65
  export declare function getUniqPayload<T>(payload: ReadonlyArray<T>, option: UniqueOption<T>, defaultUniqBy: UniqueFunc<T>): ReadonlyArray<T>;
@@ -244,7 +288,7 @@ export declare const Tooltip: import('vue').DefineComponent<import('vue').Extrac
244
288
  readonly filterNull: boolean;
245
289
  }, SlotsType<{
246
290
  content?: (props: TooltipContentProps) => any;
247
- cursor?: (props: Record<string, any>) => any;
291
+ cursor?: (props: CursorSlotProps) => any;
248
292
  default?: () => any;
249
293
  }>, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
250
294
  export default Tooltip;
@@ -37,7 +37,7 @@ var XAxisImpl = /* @__PURE__ */ defineComponent({
37
37
  "width": axisSize.value?.width,
38
38
  "height": axisSize.value?.height,
39
39
  "ticks": cartesianTickItems.value,
40
- "class": ["v-charts-xAxis xAxis", attrs.class]
40
+ "class": ["v-charts-xAxis xAxis"]
41
41
  }), { default: () => [slots.tick ? { tick: slots.tick } : void 0] });
42
42
  };
43
43
  }
@@ -178,7 +178,7 @@ var XAxis = /* @__PURE__ */ defineComponent({
178
178
  },
179
179
  domain: { type: Array },
180
180
  axisLine: {
181
- type: Boolean,
181
+ type: [Boolean, Object],
182
182
  default: true
183
183
  },
184
184
  ticks: { type: Array },
@@ -31,7 +31,7 @@ var YAxisImpl = /* @__PURE__ */ defineComponent({
31
31
  "width": axisSize.value?.width,
32
32
  "height": axisSize.value?.height,
33
33
  "ticks": cartesianTickItems.value,
34
- "class": ["v-charts-yAxis yAxis", attrs.class]
34
+ "class": ["v-charts-yAxis yAxis"]
35
35
  }), null);
36
36
  };
37
37
  }
@@ -92,8 +92,7 @@ var CartesianAxis = /* @__PURE__ */ defineComponent({
92
92
  default: "#666"
93
93
  }
94
94
  },
95
- inheritAttrs: false,
96
- setup(props, { attrs, slots }) {
95
+ setup(props, { slots }) {
97
96
  const state = reactive({
98
97
  fontSize: "",
99
98
  letterSpacing: ""
@@ -269,7 +268,7 @@ var CartesianAxis = /* @__PURE__ */ defineComponent({
269
268
  if (hide) return null;
270
269
  if (width != null && width <= 0 || height != null && height <= 0) return null;
271
270
  return createVNode(Layer, {
272
- "class": ["v-charts-cartesian-axis", attrs.class],
271
+ "class": ["v-charts-cartesian-axis"],
273
272
  "ref": (ref) => {
274
273
  const elm = ref?.$el;
275
274
  if (elm) {
@@ -266,11 +266,17 @@ var SVGElementPropKeys = [
266
266
  "stroke",
267
267
  "stroke-dasharray",
268
268
  "strokeDashoffset",
269
+ "stroke-dashoffset",
269
270
  "strokeLinecap",
271
+ "stroke-linecap",
270
272
  "strokeLinejoin",
273
+ "stroke-linejoin",
271
274
  "strokeMiterlimit",
275
+ "stroke-miterlimit",
272
276
  "strokeOpacity",
277
+ "stroke-opacity",
273
278
  "strokeWidth",
279
+ "stroke-width",
274
280
  "surfaceScale",
275
281
  "systemLanguage",
276
282
  "tableValues",
@@ -1,6 +1,6 @@
1
1
  import { getStringSize } from "../utils/attrs.mjs";
2
2
  import { reduceCSSCalc } from "../utils/ReduceCSSCalc.mjs";
3
- import { Fragment, computed, createElementBlock, defineComponent, normalizeStyle, openBlock, renderList, toDisplayString } from "vue";
3
+ import { Fragment, computed, createElementBlock, defineComponent, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString } from "vue";
4
4
  //#region src/components/Text.vue?vue&type=script&setup=true&lang.ts
5
5
  var _hoisted_1 = [
6
6
  "x",
@@ -177,13 +177,13 @@ var Text_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineCom
177
177
  fill: props.fill && props.fill.includes("url") ? "#808080" : props.fill,
178
178
  class: "v-charts-text",
179
179
  style: normalizeStyle(props.style)
180
- }, [(openBlock(true), createElementBlock(Fragment, null, renderList(wordsByLines.value, (line, index) => {
180
+ }, [renderSlot(_ctx.$slots, "default", {}, () => [(openBlock(true), createElementBlock(Fragment, null, renderList(wordsByLines.value, (line, index) => {
181
181
  return openBlock(), createElementBlock("tspan", {
182
182
  key: index,
183
183
  x: x.value,
184
184
  dy: index === 0 ? startDy.value : props.lineHeight
185
185
  }, toDisplayString(line.words.join(props.breakAll ? "" : " ")), 9, _hoisted_2);
186
- }), 128))], 12, _hoisted_1);
186
+ }), 128))])], 12, _hoisted_1);
187
187
  };
188
188
  }
189
189
  });
@@ -235,17 +235,15 @@ var Cursor = /* @__PURE__ */ defineComponent({
235
235
  let cursorElement;
236
236
  if (isScatterChart) {
237
237
  const { offset: _offset, ...coord } = props.coordinate;
238
- const { top, left, width, height } = offset.value;
239
238
  const crossProps = {
240
239
  stroke: "#ccc",
241
240
  fill: "none",
241
+ ...offset.value,
242
242
  ...coord,
243
- top,
244
- left,
245
- width,
246
- height,
247
243
  class: "v-charts-tooltip-cursor",
248
244
  style: { pointerEvents: "none" },
245
+ payload: props.payload ?? [],
246
+ payloadIndex: props.index,
249
247
  ...cursorSvgProps
250
248
  };
251
249
  cursorElement = props.cursorSlot ? props.cursorSlot(crossProps) : createVNode(Cross, crossProps, null);
@@ -255,6 +253,7 @@ var Cursor = /* @__PURE__ */ defineComponent({
255
253
  const coord = props.coordinate;
256
254
  const off = offset.value;
257
255
  const rectProps = {
256
+ ...off,
258
257
  stroke: "none",
259
258
  fill: "#ccc",
260
259
  x: layout.value === "horizontal" ? coord.x - halfSize : off.left + .5,
@@ -263,32 +262,40 @@ var Cursor = /* @__PURE__ */ defineComponent({
263
262
  height: layout.value === "horizontal" ? off.height - 1 : bandSize,
264
263
  class: "v-charts-tooltip-cursor",
265
264
  style: { pointerEvents: "none" },
265
+ payload: props.payload ?? [],
266
+ payloadIndex: props.index,
266
267
  ...cursorSvgProps
267
268
  };
268
269
  cursorElement = props.cursorSlot ? props.cursorSlot(rectProps) : createVNode(Rectangle, rectProps, null);
269
270
  } else if (layout.value === "radial" && props.coordinate?.cx != null) {
270
271
  const radialPoints = points.value;
271
272
  const sectorProps = {
273
+ stroke: "#ccc",
274
+ ...offset.value,
272
275
  cx: radialPoints.cx,
273
276
  cy: radialPoints.cy,
274
277
  startAngle: radialPoints.startAngle,
275
278
  endAngle: radialPoints.endAngle,
276
279
  innerRadius: radialPoints.radius,
277
280
  outerRadius: radialPoints.radius,
278
- stroke: "#ccc",
279
281
  fill: "none",
280
282
  class: "v-charts-tooltip-cursor",
281
283
  style: { pointerEvents: "none" },
284
+ payload: props.payload ?? [],
285
+ payloadIndex: props.index,
282
286
  ...cursorSvgProps
283
287
  };
284
288
  cursorElement = props.cursorSlot ? props.cursorSlot(sectorProps) : createVNode(Sector, sectorProps, null);
285
289
  } else {
286
290
  const cursorProps = {
287
291
  stroke: "#ccc",
288
- class: ["v-charts-tooltip-cursor"],
292
+ ...offset.value,
289
293
  layout: layout.value,
290
294
  points: points.value,
295
+ class: ["v-charts-tooltip-cursor"],
291
296
  style: { pointerEvents: "none" },
297
+ payload: props.payload ?? [],
298
+ payloadIndex: props.index,
292
299
  ...cursorSvgProps
293
300
  };
294
301
  cursorElement = props.cursorSlot ? props.cursorSlot(cursorProps) : createVNode(Curve, cursorProps, null);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vccs",
3
3
  "type": "module",
4
- "version": "0.3.0",
4
+ "version": "0.4.0",
5
5
  "description": "Composable charting components for Vue 3 — an unofficial port of Recharts",
6
6
  "author": "rick-hup",
7
7
  "license": "MIT",