@vunset/vue 1.0.0-rc.4 → 1.0.0-rc.5

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.
Files changed (33) hide show
  1. package/dist/chart.d.ts +1 -1
  2. package/dist/chart.js +1 -1
  3. package/dist/components/accordion/AccordionRoot.vue.d.ts +1 -1
  4. package/dist/components/button/Button.vue.d.ts +1 -1
  5. package/dist/components/calendar/CalendarRoot.vue.d.ts +2 -2
  6. package/dist/components/chart/ChartArea.vue.d.ts +6 -0
  7. package/dist/components/chart/ChartArea.vue_vue_type_script_setup_true_lang.js +9 -1
  8. package/dist/components/chart/ChartAxis.vue.d.ts +7 -1
  9. package/dist/components/chart/ChartAxis.vue_vue_type_script_setup_true_lang.js +7 -2
  10. package/dist/components/chart/ChartDonut.vue.d.ts +12 -5
  11. package/dist/components/chart/ChartDonut.vue_vue_type_script_setup_true_lang.js +23 -8
  12. package/dist/components/chart/ChartFrame.vue.d.ts +2 -2
  13. package/dist/components/chart/ChartFrame.vue_vue_type_script_setup_true_lang.js +40 -27
  14. package/dist/components/chart/ChartLegend.vue.d.ts +52 -22
  15. package/dist/components/chart/ChartLegend.vue_vue_type_script_setup_true_lang.js +22 -6
  16. package/dist/components/chart/ChartRoot.vue.d.ts +6 -0
  17. package/dist/components/chart/ChartRoot.vue_vue_type_script_setup_true_lang.js +22 -12
  18. package/dist/components/chart/ChartTooltip.vue.d.ts +1 -1
  19. package/dist/components/chart/chart-scales.d.ts +1 -1
  20. package/dist/components/chart/chart-scales.js +1 -1
  21. package/dist/components/chart/use-chart-series.d.ts +2 -0
  22. package/dist/components/chart/use-chart-series.js +1 -1
  23. package/dist/components/combobox/ComboboxRoot.vue.d.ts +3 -3
  24. package/dist/components/datepicker/DatepickerRoot.vue.d.ts +3 -3
  25. package/dist/components/field/FieldRoot.vue.d.ts +1 -1
  26. package/dist/components/group/Group.vue.d.ts +1 -1
  27. package/dist/components/range/RangeRoot.vue.d.ts +1 -1
  28. package/dist/components/scroll-area/ScrollArea.vue.d.ts +1 -1
  29. package/dist/components/select/SelectRoot.vue.d.ts +1 -1
  30. package/dist/components/tabs/TabsRoot.vue.d.ts +1 -1
  31. package/dist/components/timepicker/TimepickerRoot.vue.d.ts +2 -2
  32. package/dist/components/toggle/ToggleGroup.vue.d.ts +2 -2
  33. package/package.json +2 -2
package/dist/chart.d.ts CHANGED
@@ -6,6 +6,6 @@ export { default as ChartAxis } from './components/chart/ChartAxis.vue';
6
6
  export { default as ChartGrid } from './components/chart/ChartGrid.vue';
7
7
  export { default as ChartCrosshair } from './components/chart/ChartCrosshair.vue';
8
8
  export { default as ChartTooltip } from './components/chart/ChartTooltip.vue';
9
- export { default as ChartLegend } from './components/chart/ChartLegend.vue';
9
+ export { default as ChartLegend, type ChartLegendItem } from './components/chart/ChartLegend.vue';
10
10
  export { default as ChartDonut } from './components/chart/ChartDonut.vue';
11
11
  export { type ChartSeries } from './components/chart/use-chart-series';
package/dist/chart.js CHANGED
@@ -1,3 +1,4 @@
1
+ import ChartLegend_default from "./components/chart/ChartLegend.js";
1
2
  import ChartRoot_default from "./components/chart/ChartRoot.js";
2
3
  import ChartArea_default from "./components/chart/ChartArea.js";
3
4
  import ChartLine_default from "./components/chart/ChartLine.js";
@@ -6,6 +7,5 @@ import ChartAxis_default from "./components/chart/ChartAxis.js";
6
7
  import ChartGrid_default from "./components/chart/ChartGrid.js";
7
8
  import ChartCrosshair_default from "./components/chart/ChartCrosshair.js";
8
9
  import ChartTooltip_default from "./components/chart/ChartTooltip.js";
9
- import ChartLegend_default from "./components/chart/ChartLegend.js";
10
10
  import ChartDonut_default from "./components/chart/ChartDonut.js";
11
11
  export { ChartArea_default as ChartArea, ChartAxis_default as ChartAxis, ChartBar_default as ChartBar, ChartCrosshair_default as ChartCrosshair, ChartDonut_default as ChartDonut, ChartGrid_default as ChartGrid, ChartLegend_default as ChartLegend, ChartLine_default as ChartLine, ChartRoot_default as ChartRoot, ChartTooltip_default as ChartTooltip };
@@ -31,9 +31,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, import("./u
31
31
  "onUpdate:modelValue"?: ((value: AccordionValue[]) => any) | undefined;
32
32
  }>, {
33
33
  defaultValue: AccordionValue[];
34
- orientation: Orientation;
35
34
  as: string | object;
36
35
  modelValue: AccordionValue[];
36
+ orientation: Orientation;
37
37
  disabled: boolean;
38
38
  loop: boolean;
39
39
  multiple: boolean;
@@ -15,8 +15,8 @@ type __VLS_Slots = {} & {
15
15
  default?: (props: typeof __VLS_8) => any;
16
16
  };
17
17
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, import("./use-button").UseButtonReturn, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
18
- type: "button" | "submit" | "reset";
19
18
  as: string | object;
19
+ type: "button" | "submit" | "reset";
20
20
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
21
21
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
22
22
  declare const _default: typeof __VLS_export;
@@ -73,10 +73,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, import("./u
73
73
  onChange?: ((value: CalendarValue) => any) | undefined;
74
74
  "onUpdate:modelValue"?: ((value: CalendarModelValue | undefined) => any) | undefined;
75
75
  }>, {
76
- required: boolean;
77
- invalid: boolean;
78
76
  mode: CalendarSelectionMode;
77
+ invalid: boolean;
79
78
  as: string | object;
79
+ required: boolean;
80
80
  disabled: boolean;
81
81
  readOnly: boolean;
82
82
  maxToday: boolean;
@@ -14,10 +14,16 @@ type __VLS_Props = {
14
14
  curve?: ChartCurve;
15
15
  /** Mark each row with a dot. */
16
16
  points?: boolean;
17
+ /** Draw the line along the band's top. Without it, the band alone takes the focus. @default true */
18
+ line?: boolean;
19
+ /** Fade the band towards the axis, or fill it evenly. @default true */
20
+ gradient?: boolean;
17
21
  };
18
22
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
23
+ line: boolean;
19
24
  curve: ChartCurve;
20
25
  scale: string;
26
+ gradient: boolean;
21
27
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
28
  declare const _default: typeof __VLS_export;
23
29
  export default _default;
@@ -11,7 +11,15 @@ var ChartArea_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
11
11
  scale: { default: "y" },
12
12
  format: {},
13
13
  curve: { default: "smooth" },
14
- points: { type: Boolean }
14
+ points: { type: Boolean },
15
+ line: {
16
+ type: Boolean,
17
+ default: true
18
+ },
19
+ gradient: {
20
+ type: Boolean,
21
+ default: true
22
+ }
15
23
  },
16
24
  setup(__props) {
17
25
  const props = __props;
@@ -14,7 +14,13 @@ type __VLS_Props = {
14
14
  trimLabels?: boolean;
15
15
  /** A title along the axis, such as its unit. */
16
16
  label?: string;
17
+ /** Draw the axis' own line along the plot's edge. */
18
+ line?: boolean;
19
+ /** The short mark at each label. @default true */
20
+ tickMarks?: boolean;
17
21
  };
18
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
22
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
23
+ tickMarks: boolean;
24
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
19
25
  declare const _default: typeof __VLS_export;
20
26
  export default _default;
@@ -8,10 +8,15 @@ var ChartAxis_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
8
8
  type: {},
9
9
  scale: {},
10
10
  side: {},
11
- format: { type: Function },
11
+ format: {},
12
12
  numTicks: {},
13
13
  trimLabels: { type: Boolean },
14
- label: {}
14
+ label: {},
15
+ line: { type: Boolean },
16
+ tickMarks: {
17
+ type: Boolean,
18
+ default: true
19
+ }
15
20
  },
16
21
  setup(__props) {
17
22
  const props = __props;
@@ -13,20 +13,27 @@ declare const __VLS_export: <T extends Record<string, any>>(__VLS_props: NonNull
13
13
  labelFormat?: (category: string) => string;
14
14
  /** One per slice. Defaults to `var(--chart-color-N)`. */
15
15
  colors?: string[];
16
+ /** How many `--chart-color-N` the theme defines: series past it start over at the first. @default 8 */
17
+ paletteSize?: number;
16
18
  /** Slices not drawn. `v-model:hidden` pairs it with a `ChartLegend`. */
17
19
  hidden?: string[];
18
20
  /** A number means pixels. @default '20rem' */
19
21
  height?: number | string;
20
- /** Gap between slices, in radians. @default 0.04 */
22
+ /** Gap between slices, in radians: a wedge, widening towards the edge. @default 0.04 */
21
23
  padAngle?: number;
24
+ /**
25
+ * Gap between slices, in pixels, the same width from the center to the edge; `0` for none. Replaces
26
+ * `pad-angle`. It's drawn as a line in `--chart-gap-color`, the page's background by default.
27
+ */
28
+ gap?: number;
22
29
  /** The radius of each slice's corners, in pixels. @default 6 */
23
30
  cornerRadius?: number;
24
31
  /** How thick the ring is. `0` fills it in, making a pie. @default 12 */
25
32
  arcWidth?: number;
26
- /** Defaults to the total of what is showing. Empty string for nothing. */
27
- centralLabel?: string;
28
- /** The line under the central label. @default 'Total' */
29
- centralSubLabel?: string;
33
+ /** Defaults to the total of what is showing; a pie, with no middle, shows none. `false` for nothing. */
34
+ centralLabel?: string | false;
35
+ /** The line under the central label. Defaults to 'Total', or none on a pie. `false` for nothing. */
36
+ centralSubLabel?: string | false;
30
37
  /** Shows the slice under the pointer. @default true */
31
38
  tooltip?: boolean;
32
39
  /** A class for the tooltip's box. */
@@ -1,5 +1,5 @@
1
1
  import { useChartSeries } from "./use-chart-series.js";
2
- import { SVG_ANIMATION, chartName } from "./chart-scales.js";
2
+ import { chartName } from "./chart-scales.js";
3
3
  import ChartFrame_default from "./ChartFrame.js";
4
4
  import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, defineComponent, guardReactiveProps, mergeProps, normalizeProps, normalizeStyle, openBlock, renderSlot, toDisplayString, withCtx } from "vue";
5
5
  import { formatNumber } from "@vunset/utils";
@@ -31,13 +31,21 @@ var ChartDonut_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
31
31
  valueFormat: {},
32
32
  labelFormat: {},
33
33
  colors: {},
34
+ paletteSize: {},
34
35
  hidden: {},
35
36
  height: { default: "20rem" },
36
37
  padAngle: { default: .04 },
38
+ gap: {},
37
39
  cornerRadius: { default: 6 },
38
40
  arcWidth: { default: 12 },
39
- centralLabel: { default: void 0 },
40
- centralSubLabel: { default: void 0 },
41
+ centralLabel: {
42
+ type: [String, Boolean],
43
+ default: void 0
44
+ },
45
+ centralSubLabel: {
46
+ type: [String, Boolean],
47
+ default: void 0
48
+ },
41
49
  tooltip: {
42
50
  type: Boolean,
43
51
  default: void 0
@@ -62,6 +70,7 @@ var ChartDonut_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
62
70
  const { visible } = useChartSeries({
63
71
  categories: () => slices.value.map((slice) => slice.category),
64
72
  colors: () => props.colors,
73
+ paletteSize: () => props.paletteSize,
65
74
  hidden: () => props.hidden,
66
75
  onHiddenChange: (next) => emit("update:hidden", next)
67
76
  });
@@ -82,17 +91,22 @@ var ChartDonut_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
82
91
  const definition = computed(() => {
83
92
  const width = props.arcWidth;
84
93
  const cornerRadius = props.cornerRadius;
94
+ const gap = props.gap;
85
95
  return defineChart({
86
- svgAnimation: SVG_ANIMATION,
96
+ svgAnimation: false,
87
97
  marks: [polar({
88
98
  marks: [radialArc(pie(shown.value, {
89
99
  value: "size",
90
- gapAngle: props.padAngle
100
+ gapAngle: gap === void 0 ? props.padAngle : 0
91
101
  }), {
92
102
  color: "category",
93
103
  key: "category",
94
104
  innerRadius: ({ radius }) => width > 0 ? Math.max(radius - width, 0) : 0,
95
- cornerRadius
105
+ cornerRadius,
106
+ ...gap !== void 0 && gap > 0 && {
107
+ stroke: "var(--chart-gap-color, Canvas)",
108
+ strokeWidth: gap
109
+ }
96
110
  })],
97
111
  scales: {
98
112
  angle: null,
@@ -117,8 +131,9 @@ var ChartDonut_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
117
131
  }
118
132
  });
119
133
  });
120
- const centralLabel = computed(() => props.centralLabel ?? format(total.value));
121
- const centralSubLabel = computed(() => props.centralSubLabel ?? "Total");
134
+ const filled = computed(() => props.arcWidth <= 0);
135
+ const centralLabel = computed(() => props.centralLabel ?? (filled.value ? false : format(total.value)));
136
+ const centralSubLabel = computed(() => props.centralSubLabel ?? (filled.value ? false : "Total"));
122
137
  const ariaLabel = computed(() => props.label ?? chartName(shown.value.map((slice) => slice.category), props.labelFormat, "Donut chart"));
123
138
  return (_ctx, _cache) => {
124
139
  return openBlock(), createBlock(ChartFrame_default, mergeProps({
@@ -30,8 +30,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
30
30
  /** `--chart-tick-font-size` in px, for the chart's definition. */
31
31
  tickSize?: number;
32
32
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
33
- "update:tickSize": (value: number | undefined) => any;
34
33
  render: (context: ChartRender) => any;
34
+ "update:tickSize": (value: number | undefined) => any;
35
35
  }, string, import("vue").PublicProps, Readonly<{
36
36
  /** Which chart this is, for `data-chart`. */
37
37
  kind?: string;
@@ -47,8 +47,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
47
47
  /** `--chart-tick-font-size` in px, for the chart's definition. */
48
48
  tickSize?: number;
49
49
  }> & Readonly<{
50
- "onUpdate:tickSize"?: ((value: number | undefined) => any) | undefined;
51
50
  onRender?: ((context: ChartRender) => any) | undefined;
51
+ "onUpdate:tickSize"?: ((value: number | undefined) => any) | undefined;
52
52
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
53
53
  /** Content before the drawing, such as a `ChartLegend`. */
54
54
  default(): unknown;
@@ -1,4 +1,5 @@
1
- import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, h, mergeModels, mergeProps, normalizeStyle, onMounted, openBlock, renderSlot, shallowRef, unref, useModel, useSlots, useTemplateRef } from "vue";
1
+ import ChartLegend_default from "./ChartLegend.js";
2
+ import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, h, mergeModels, mergeProps, normalizeStyle, onMounted, openBlock, renderSlot, shallowRef, unref, useModel, useSlots, useTemplateRef } from "vue";
2
3
  import { Chart } from "@tanstack/charts/vue";
3
4
  //#region src/components/chart/ChartFrame.vue?vue&type=script&setup=true&lang.ts
4
5
  var _hoisted_1 = ["data-chart"];
@@ -56,6 +57,14 @@ var ChartFrame_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
56
57
  point: primaryPoint,
57
58
  pinned
58
59
  }))]) : null;
60
+ const below = (node) => node.type === ChartLegend_default && node.props?.placement === "bottom";
61
+ function flat(nodes) {
62
+ return nodes.flatMap((node) => node.type === Fragment && Array.isArray(node.children) ? flat(node.children) : [node]);
63
+ }
64
+ const Content = (own) => {
65
+ return flat(slots.default?.() ?? []).filter((node) => below(node) === (own.bottom ?? false));
66
+ };
67
+ Content.props = { bottom: Boolean };
59
68
  const Drawing = defineComponent({
60
69
  name: "ChartDrawing",
61
70
  setup: () => () => h(Chart, {
@@ -69,32 +78,36 @@ var ChartFrame_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
69
78
  return openBlock(), createElementBlock("div", {
70
79
  "data-part": "chart",
71
80
  "data-chart": props.kind
72
- }, [renderSlot(_ctx.$slots, "default"), createElementVNode("div", _hoisted_2, [
73
- createElementVNode("span", {
74
- ref_key: "probe",
75
- ref: probe,
76
- "aria-hidden": "true",
77
- style: {
78
- position: "absolute",
79
- visibility: "hidden",
80
- fontSize: "var(--chart-tick-font-size, 0px)"
81
- }
82
- }, null, 512),
83
- createVNode(unref(Drawing)),
84
- slots.center && plot.value ? (openBlock(), createElementBlock("div", {
85
- key: 0,
86
- "data-part": "chart-center",
87
- style: normalizeStyle({
88
- position: "absolute",
89
- ...plot.value,
90
- display: "flex",
91
- flexDirection: "column",
92
- alignItems: "center",
93
- justifyContent: "center",
94
- pointerEvents: "none"
95
- })
96
- }, [renderSlot(_ctx.$slots, "center")], 4)) : createCommentVNode("", true)
97
- ])], 8, _hoisted_1);
81
+ }, [
82
+ createVNode(Content),
83
+ createElementVNode("div", _hoisted_2, [
84
+ createElementVNode("span", {
85
+ ref_key: "probe",
86
+ ref: probe,
87
+ "aria-hidden": "true",
88
+ style: {
89
+ position: "absolute",
90
+ visibility: "hidden",
91
+ fontSize: "var(--chart-tick-font-size, 0px)"
92
+ }
93
+ }, null, 512),
94
+ createVNode(unref(Drawing)),
95
+ slots.center && plot.value ? (openBlock(), createElementBlock("div", {
96
+ key: 0,
97
+ "data-part": "chart-center",
98
+ style: normalizeStyle({
99
+ position: "absolute",
100
+ ...plot.value,
101
+ display: "flex",
102
+ flexDirection: "column",
103
+ alignItems: "center",
104
+ justifyContent: "center",
105
+ pointerEvents: "none"
106
+ })
107
+ }, [renderSlot(_ctx.$slots, "center")], 4)) : createCommentVNode("", true)
108
+ ]),
109
+ createVNode(Content, { bottom: "" })
110
+ ], 8, _hoisted_1);
98
111
  };
99
112
  }
100
113
  });
@@ -1,44 +1,74 @@
1
- type __VLS_Props = {
1
+ import { type HTMLAttributes } from 'vue';
2
+ /** One entry in a legend. */
3
+ export interface ChartLegendItem {
4
+ category: string;
5
+ label: string;
6
+ color: string;
7
+ /** Its series isn't drawn. */
8
+ hidden: boolean;
9
+ /** Hides it, or shows it again. */
10
+ toggle: () => void;
11
+ }
12
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
14
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
2
15
  /** The hidden categories, bound with `v-model`, for a legend beside a chart rather than inside it. */
3
16
  modelValue?: string[];
4
17
  /** Taken from the chart this sits inside, when it sits inside one. */
5
18
  categories?: string[];
6
19
  /** One per category; taken from the chart this sits inside, or `var(--chart-color-N)`. */
7
20
  colors?: string[];
21
+ /** How many `--chart-color-N` the theme defines: series past it start over at the first. @default 8 */
22
+ paletteSize?: number;
8
23
  /** Renames a category for the reader. Inside a chart, each series' `label` already does. */
9
24
  labelFormat?: (category: string) => string;
25
+ /** Inside a chart: above the drawing, or below it. @default 'top' */
26
+ placement?: "top" | "bottom";
27
+ /** A class for each button, beside its `data-part="legend-item"`. */
28
+ itemClass?: HTMLAttributes["class"];
10
29
  /** Element or component to render. */
11
30
  as?: string | object;
12
- };
13
- type __VLS_Slots = {
31
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
32
+ "update:modelValue": (hidden: string[]) => any;
33
+ }, string, import("vue").PublicProps, Readonly<{
34
+ /** The hidden categories, bound with `v-model`, for a legend beside a chart rather than inside it. */
35
+ modelValue?: string[];
36
+ /** Taken from the chart this sits inside, when it sits inside one. */
37
+ categories?: string[];
38
+ /** One per category; taken from the chart this sits inside, or `var(--chart-color-N)`. */
39
+ colors?: string[];
40
+ /** How many `--chart-color-N` the theme defines: series past it start over at the first. @default 8 */
41
+ paletteSize?: number;
42
+ /** Renames a category for the reader. Inside a chart, each series' `label` already does. */
43
+ labelFormat?: (category: string) => string;
44
+ /** Inside a chart: above the drawing, or below it. @default 'top' */
45
+ placement?: "top" | "bottom";
46
+ /** A class for each button, beside its `data-part="legend-item"`. */
47
+ itemClass?: HTMLAttributes["class"];
48
+ /** Element or component to render. */
49
+ as?: string | object;
50
+ }> & Readonly<{
51
+ "onUpdate:modelValue"?: ((hidden: string[]) => any) | undefined;
52
+ }>, {
53
+ as: string | object;
54
+ modelValue: string[];
55
+ placement: "top" | "bottom";
56
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
14
57
  /**
15
58
  * Replaces the buttons.
16
59
  * @slotOnly The element carries only `data-part="legend"`.
17
60
  */
18
61
  default(props: {
19
62
  /** One per category, with its `category`, `label`, `color`, whether it is `hidden`, and a `toggle()`. */
20
- items: {
21
- category: string;
22
- label: string;
23
- color: string;
24
- hidden: boolean;
25
- toggle: () => void;
26
- }[];
63
+ items: ChartLegendItem[];
27
64
  /** The hidden categories. */
28
65
  hidden: string[];
29
66
  }): unknown;
30
- };
31
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
32
- "update:modelValue": (hidden: string[]) => any;
33
- }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
34
- "onUpdate:modelValue"?: ((hidden: string[]) => any) | undefined;
35
- }>, {
36
- as: string | object;
37
- modelValue: string[];
38
- }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
39
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
40
- declare const _default: typeof __VLS_export;
41
- export default _default;
67
+ /** Replaces what each button shows, a swatch and the label; the button and its toggling stay. */
68
+ item?(props: ChartLegendItem & {
69
+ index: number;
70
+ }): unknown;
71
+ }>;
42
72
  type __VLS_WithSlots<T, S> = T & {
43
73
  new (): {
44
74
  $slots: S;
@@ -2,7 +2,7 @@ import { mergeProps as mergeProps$1 } from "../../shared/merge-props.js";
2
2
  import { Part } from "../../shared/part.js";
3
3
  import { useControlled } from "../../shared/use-controlled.js";
4
4
  import { useOptionalChartContext } from "./use-chart-series.js";
5
- import { Fragment, computed, createBlock, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useAttrs, withCtx } from "vue";
5
+ import { Fragment, computed, createBlock, createElementBlock, createElementVNode, defineComponent, guardReactiveProps, mergeProps, normalizeClass, normalizeProps, normalizeStyle, openBlock, renderList, renderSlot, toDisplayString, unref, useAttrs, withCtx } from "vue";
6
6
  import { chartColors } from "@vunset/utils";
7
7
  //#region src/components/chart/ChartLegend.vue?vue&type=script&setup=true&lang.ts
8
8
  var _hoisted_1 = [
@@ -19,7 +19,16 @@ var ChartLegend_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
19
19
  modelValue: { default: void 0 },
20
20
  categories: {},
21
21
  colors: {},
22
+ paletteSize: {},
22
23
  labelFormat: {},
24
+ placement: { default: "top" },
25
+ itemClass: { type: [
26
+ Boolean,
27
+ null,
28
+ String,
29
+ Object,
30
+ Array
31
+ ] },
23
32
  as: { default: "div" }
24
33
  },
25
34
  emits: ["update:modelValue"],
@@ -36,7 +45,7 @@ var ChartLegend_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
36
45
  label: "modelValue"
37
46
  });
38
47
  const categories = computed(() => props.categories ?? chart?.categories.value ?? []);
39
- const colors = computed(() => props.colors ?? chart?.colors.value ?? chartColors(categories.value.length));
48
+ const colors = computed(() => props.colors ?? chart?.colors.value ?? chartColors(categories.value.length, void 0, void 0, props.paletteSize));
40
49
  const hidden = computed(() => driven ? chart.hidden.value : own.value);
41
50
  function toggle(category) {
42
51
  if (driven) {
@@ -53,24 +62,31 @@ var ChartLegend_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
53
62
  toggle: () => toggle(category)
54
63
  })));
55
64
  const attrs = useAttrs();
56
- const merged = computed(() => mergeProps$1({ "data-part": "legend" }, attrs));
65
+ const merged = computed(() => mergeProps$1({
66
+ "data-part": "legend",
67
+ "data-placement": props.placement
68
+ }, attrs));
57
69
  return (_ctx, _cache) => {
58
70
  return openBlock(), createBlock(unref(Part), mergeProps({ as: props.as }, merged.value), {
59
71
  default: withCtx(() => [renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps({
60
72
  items: items.value,
61
73
  hidden: hidden.value
62
- })), () => [(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item) => {
74
+ })), () => [(openBlock(true), createElementBlock(Fragment, null, renderList(items.value, (item, index) => {
63
75
  return openBlock(), createElementBlock("button", {
64
76
  key: item.category,
65
77
  type: "button",
66
78
  "data-part": "legend-item",
79
+ class: normalizeClass(props.itemClass),
67
80
  "data-hidden": item.hidden ? "" : void 0,
68
81
  "aria-pressed": !item.hidden,
69
82
  onClick: ($event) => item.toggle()
70
- }, [createElementVNode("span", {
83
+ }, [renderSlot(_ctx.$slots, "item", mergeProps({ ref_for: true }, {
84
+ ...item,
85
+ index
86
+ }), () => [createElementVNode("span", {
71
87
  "data-part": "legend-swatch",
72
88
  style: normalizeStyle({ background: item.color })
73
- }, null, 4), createElementVNode("span", _hoisted_2, toDisplayString(item.label), 1)], 8, _hoisted_1);
89
+ }, null, 4), createElementVNode("span", _hoisted_2, toDisplayString(item.label), 1)])], 10, _hoisted_1);
74
90
  }), 128))])]),
75
91
  _: 3
76
92
  }, 16, ["as"]);
@@ -12,6 +12,8 @@ export interface ChartSeriesPart {
12
12
  curve?: ChartCurve;
13
13
  points?: boolean;
14
14
  gradient?: boolean;
15
+ /** Areas only: the line along the band's top. */
16
+ line?: boolean;
15
17
  roundedCorners?: number;
16
18
  padding?: number;
17
19
  }
@@ -23,6 +25,8 @@ export interface ChartAxisPart {
23
25
  numTicks?: number;
24
26
  trimLabels?: boolean;
25
27
  label?: string;
28
+ line?: boolean;
29
+ tickMarks?: boolean;
26
30
  }
27
31
  export interface ChartGridPart {
28
32
  type: 'x' | 'y';
@@ -106,6 +110,8 @@ declare const __VLS_export: <T extends Record<string, any>>(__VLS_props: NonNull
106
110
  hidden?: string[];
107
111
  /** The chart's accessible name. Defaults to its series. */
108
112
  label?: string;
113
+ /** How many `--chart-color-N` the theme defines: series past it start over at the first. @default 8 */
114
+ paletteSize?: number;
109
115
  } & {
110
116
  "onUpdate:hidden"?: ((hidden: string[]) => any) | undefined;
111
117
  }> & (typeof globalThis extends {
@@ -61,7 +61,8 @@ var ChartRoot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
61
61
  orientation: { default: "vertical" },
62
62
  stacked: { type: Boolean },
63
63
  hidden: { default: void 0 },
64
- label: {}
64
+ label: {},
65
+ paletteSize: {}
65
66
  },
66
67
  emits: ["update:hidden"],
67
68
  setup(__props, { emit: __emit }) {
@@ -92,7 +93,7 @@ var ChartRoot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
92
93
  const { colors, visible } = useChartSeries({
93
94
  categories: () => keys.value,
94
95
  colors: () => {
95
- const palette = chartColors(keys.value.length);
96
+ const palette = chartColors(keys.value.length, void 0, void 0, props.paletteSize);
96
97
  return keys.value.map((key, index) => series.value.find((entry) => entry.yKey === key && entry.color)?.color ?? palette[index]);
97
98
  },
98
99
  labels: () => keys.value.map(labelOf),
@@ -222,10 +223,15 @@ var ChartRoot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
222
223
  if (entry.kind === "line") return [line];
223
224
  const area = (horizontal.value ? areaX : areaY)(points, {
224
225
  ...channels,
225
- fill: `url(#${areaGradient(entry.yKey)})`,
226
- fillOpacity: 1
226
+ ...entry.gradient === false ? {
227
+ fill: colors.value[colorIndex(entry.yKey)],
228
+ fillOpacity: .25
229
+ } : {
230
+ fill: `url(#${areaGradient(entry.yKey)})`,
231
+ fillOpacity: 1
232
+ }
227
233
  });
228
- return [decorative(area), line];
234
+ return entry.line === false ? [area] : [decorative(area), line];
229
235
  }
230
236
  const fade = computed(() => horizontal.value ? {
231
237
  x1: 1,
@@ -242,7 +248,7 @@ var ChartRoot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
242
248
  const found = /* @__PURE__ */ new Map();
243
249
  for (const entry of shown.value) {
244
250
  const color = colors.value[colorIndex(entry.yKey)];
245
- if (entry.kind === "area") found.set(areaGradient(entry.yKey), {
251
+ if (entry.kind === "area" && entry.gradient !== false) found.set(areaGradient(entry.yKey), {
246
252
  id: areaGradient(entry.yKey),
247
253
  x1: 0,
248
254
  y1: 0,
@@ -295,28 +301,31 @@ var ChartRoot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
295
301
  const x = xAxis.value;
296
302
  const firstBar = series.value.find((entry) => entry.kind === "bar");
297
303
  const titled = (axis) => axis?.label ? { label: axis.label } : {};
304
+ const stubs = (axis) => axis.tickMarks === false ? { line: false } : {};
298
305
  const rowScale = continuous.value ? {
299
306
  scale: props.xScale === "linear" ? scaleLinear : props.xScale,
300
307
  grid: grids.value.some((entry) => entry.type === "x"),
301
308
  axis: x ? {
302
- line: false,
309
+ line: x.line === true,
303
310
  ...tickLabels(tickSize.value),
304
311
  ...titled(x),
305
312
  ticks: {
306
313
  ...x.format && { format: x.format },
307
- ...x.numTicks !== void 0 && { count: x.numTicks }
314
+ ...x.numTicks !== void 0 && { count: x.numTicks },
315
+ ...stubs(x)
308
316
  }
309
317
  } : false
310
318
  } : {
311
319
  scale: firstBar ? () => scaleBand().padding(firstBar.padding ?? .1) : () => scalePoint().padding(0),
312
320
  grid: grids.value.some((entry) => entry.type === "x"),
313
321
  axis: x ? {
314
- line: false,
322
+ line: x.line === true,
315
323
  ...tickLabels(tickSize.value),
316
324
  ...titled(x),
317
325
  ticks: {
318
326
  format: (index) => trim(xText(props.data[index]), budget),
319
- values: shown.value.length ? rowTicks(props.data.length, x.numTicks) : void 0
327
+ values: shown.value.length ? rowTicks(props.data.length, x.numTicks) : void 0,
328
+ ...stubs(x)
320
329
  }
321
330
  } : false
322
331
  };
@@ -331,12 +340,13 @@ var ChartRoot_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
331
340
  nice: true,
332
341
  grid: valueGrid.value === scale,
333
342
  axis: axis && axisShown(scale) ? {
334
- line: false,
343
+ line: axis.line === true,
335
344
  ...tickLabels(tickSize.value),
336
345
  ...titled(axis),
337
346
  ticks: {
338
347
  format: (raw) => valueLabel(raw, axis.format),
339
- ...axis.numTicks !== void 0 && { count: axis.numTicks }
348
+ ...axis.numTicks !== void 0 && { count: axis.numTicks },
349
+ ...stubs(axis)
340
350
  }
341
351
  } : false
342
352
  }];
@@ -12,8 +12,8 @@ type __VLS_Slots = {
12
12
  default?(props: ChartTooltipSlotProps): unknown;
13
13
  };
14
14
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
15
- sticky: boolean;
16
15
  mode: "row" | "point";
16
+ sticky: boolean;
17
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
18
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
19
19
  declare const _default: typeof __VLS_export;
@@ -6,7 +6,7 @@ import type { ChartCurve } from '@tanstack/charts';
6
6
  export declare function rowTicks(length: number, count: number | undefined): number[] | undefined;
7
7
  /** TanStack's own tick label size, in px, until `--chart-tick-font-size` sets one. */
8
8
  export declare const TICK_FONT_SIZE = 11;
9
- /** Tweens a redraw for new data or a toggled series; off under reduced motion, never on resize. */
9
+ /** Tweens a cartesian chart's redraw for new data or a toggled series; off under reduced motion, never on resize. */
10
10
  export declare const SVG_ANIMATION: {
11
11
  readonly duration: 240;
12
12
  readonly easing: "ease-out";
@@ -10,7 +10,7 @@ function rowTicks(length, count) {
10
10
  const step = Math.max(1, Math.ceil(length / Math.max(1, count)));
11
11
  return Array.from({ length }, (_, index) => index).filter((index) => index % step === 0);
12
12
  }
13
- /** Tweens a redraw for new data or a toggled series; off under reduced motion, never on resize. */
13
+ /** Tweens a cartesian chart's redraw for new data or a toggled series; off under reduced motion, never on resize. */
14
14
  var SVG_ANIMATION = {
15
15
  duration: 240,
16
16
  easing: "ease-out"
@@ -24,6 +24,8 @@ export declare const provideChartContext: (value: ChartContext) => ChartContext,
24
24
  export interface UseChartSeriesOptions {
25
25
  categories: () => string[];
26
26
  colors: () => string[] | undefined;
27
+ /** How many palette colors the default cycles through. */
28
+ paletteSize?: () => number | undefined;
27
29
  labels?: () => string[];
28
30
  /** Supplying this makes the hidden list controlled. */
29
31
  hidden: () => string[] | undefined;
@@ -18,7 +18,7 @@ var { provideContext: provideChartContext, useContext: useChartContext, useOptio
18
18
  * happens to be showing.
19
19
  */
20
20
  function useChartSeries(options) {
21
- const colors = computed(() => options.colors() ?? chartColors(options.categories().length));
21
+ const colors = computed(() => options.colors() ?? chartColors(options.categories().length, void 0, void 0, options.paletteSize?.()));
22
22
  const hidden = useControlled({
23
23
  value: options.hidden,
24
24
  defaultValue: () => [],
@@ -82,18 +82,18 @@ type __VLS_Slots = {} & {
82
82
  default?: (props: typeof __VLS_8) => any;
83
83
  };
84
84
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
85
- create: (value: string) => any;
86
85
  "update:modelValue": (value: ListboxOptionValue | ListboxOptionValue[] | null | undefined) => any;
86
+ create: (value: string) => any;
87
87
  "update:open": (open: boolean) => any;
88
88
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
89
- onCreate?: ((value: string) => any) | undefined;
90
89
  "onUpdate:modelValue"?: ((value: ListboxOptionValue | ListboxOptionValue[] | null | undefined) => any) | undefined;
90
+ onCreate?: ((value: string) => any) | undefined;
91
91
  "onUpdate:open"?: ((open: boolean) => any) | undefined;
92
92
  }>, {
93
- required: boolean;
94
93
  invalid: boolean;
95
94
  as: string | object;
96
95
  modelValue: ListboxOptionValue | ListboxOptionValue[] | null;
96
+ required: boolean;
97
97
  options: ListboxItem[];
98
98
  disabled: boolean;
99
99
  open: boolean;
@@ -147,11 +147,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
147
147
  "onUpdate:modelValue"?: ((value: CalendarModelValue | undefined) => any) | undefined;
148
148
  "onUpdate:open"?: ((open: boolean) => any) | undefined;
149
149
  }>, {
150
- required: boolean;
151
- invalid: boolean;
152
150
  mode: CalendarSelectionMode;
153
- side: Side;
151
+ invalid: boolean;
154
152
  as: string | object;
153
+ required: boolean;
154
+ side: Side;
155
155
  disabled: boolean;
156
156
  open: boolean;
157
157
  align: Align;
@@ -29,9 +29,9 @@ type __VLS_Slots = {
29
29
  custom(props: UseFieldReturn): unknown;
30
30
  };
31
31
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, UseFieldReturn, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
32
- required: boolean;
33
32
  invalid: boolean;
34
33
  as: string | object;
34
+ required: boolean;
35
35
  disabled: boolean;
36
36
  readOnly: boolean;
37
37
  touched: boolean;
@@ -42,8 +42,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
42
42
  /** Element or component to render. */
43
43
  as?: string | object;
44
44
  }> & Readonly<{}>, {
45
- orientation: Orientation;
46
45
  as: string | object;
46
+ orientation: Orientation;
47
47
  variant: GroupVariant;
48
48
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
49
49
  default?: (props: {
@@ -63,9 +63,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, import("./u
63
63
  }>, {
64
64
  defaultValue: number | number[];
65
65
  invalid: boolean;
66
- orientation: RangeOrientation;
67
66
  as: string | object;
68
67
  modelValue: number | number[];
68
+ orientation: RangeOrientation;
69
69
  disabled: boolean;
70
70
  min: number;
71
71
  max: number;
@@ -80,8 +80,8 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
80
80
  /** Element or component to render. */
81
81
  as?: string | object;
82
82
  }> & Readonly<{}>, {
83
- axis: ScrollAreaAxis;
84
83
  as: string | object;
84
+ axis: ScrollAreaAxis;
85
85
  fade: ScrollAreaFade;
86
86
  overflowThreshold: number;
87
87
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
@@ -90,10 +90,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {},
90
90
  "onUpdate:modelValue"?: ((value: ListboxOptionValue | ListboxOptionValue[] | null | undefined) => any) | undefined;
91
91
  "onUpdate:open"?: ((open: boolean) => any) | undefined;
92
92
  }>, {
93
- required: boolean;
94
93
  invalid: boolean;
95
94
  as: string | object;
96
95
  modelValue: ListboxOptionValue | ListboxOptionValue[] | null;
96
+ required: boolean;
97
97
  options: ListboxItem[];
98
98
  disabled: boolean;
99
99
  open: boolean;
@@ -28,9 +28,9 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, import("./u
28
28
  "onUpdate:modelValue"?: ((value: TabValue) => any) | undefined;
29
29
  }>, {
30
30
  defaultValue: TabValue;
31
- orientation: TabsOrientation;
32
31
  as: string | object;
33
32
  modelValue: TabValue;
33
+ orientation: TabsOrientation;
34
34
  loop: boolean;
35
35
  activateOnFocus: boolean;
36
36
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -58,10 +58,10 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
58
58
  "onUpdate:modelValue"?: ((value: string | null | undefined) => any) | undefined;
59
59
  "onUpdate:open"?: ((open: boolean) => any) | undefined;
60
60
  }>, {
61
- required: boolean;
62
61
  invalid: boolean;
63
- side: Side;
64
62
  as: string | object;
63
+ required: boolean;
64
+ side: Side;
65
65
  disabled: boolean;
66
66
  open: boolean;
67
67
  align: Align;
@@ -45,11 +45,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, import("./u
45
45
  "onUpdate:modelValue"?: ((value: ToggleGroupValue | undefined) => any) | undefined;
46
46
  }>, {
47
47
  defaultValue: ToggleGroupValue;
48
- required: boolean;
49
48
  invalid: boolean;
50
- orientation: Orientation;
51
49
  as: string | object;
52
50
  modelValue: ToggleGroupValue;
51
+ required: boolean;
52
+ orientation: Orientation;
53
53
  disabled: boolean;
54
54
  loop: boolean;
55
55
  multiple: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunset/vue",
3
- "version": "1.0.0-rc.4",
3
+ "version": "1.0.0-rc.5",
4
4
  "description": "Headless, unstyled Vue 3 components: keyboard, focus and ARIA handled, the look left to you.",
5
5
  "keywords": [
6
6
  "vue",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@floating-ui/vue": "^2.0.1",
50
- "@vunset/utils": "1.0.0-rc.4"
50
+ "@vunset/utils": "1.0.0-rc.5"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "@tanstack/charts": "^1.1.0",