@vespera-ui/vue 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.
package/dist/index.d.cts CHANGED
@@ -896,5 +896,157 @@ declare const Accordion: vue.DefineComponent<vue.ExtractPropTypes<{
896
896
  multiple: boolean;
897
897
  defaultOpen: number[];
898
898
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
899
+ type Pt = [number, number];
900
+ /** Smooth (cubic) SVG path through points. */
901
+ declare function smoothPath(pts: Pt[]): string;
902
+ declare const Sparkline: vue.DefineComponent<vue.ExtractPropTypes<{
903
+ data: {
904
+ type: PropType<number[]>;
905
+ default: () => never[];
906
+ };
907
+ color: {
908
+ type: StringConstructor;
909
+ default: string;
910
+ };
911
+ w: {
912
+ type: NumberConstructor;
913
+ default: number;
914
+ };
915
+ h: {
916
+ type: NumberConstructor;
917
+ default: number;
918
+ };
919
+ fill: {
920
+ type: BooleanConstructor;
921
+ default: boolean;
922
+ };
923
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
924
+ [key: string]: any;
925
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
926
+ data: {
927
+ type: PropType<number[]>;
928
+ default: () => never[];
929
+ };
930
+ color: {
931
+ type: StringConstructor;
932
+ default: string;
933
+ };
934
+ w: {
935
+ type: NumberConstructor;
936
+ default: number;
937
+ };
938
+ h: {
939
+ type: NumberConstructor;
940
+ default: number;
941
+ };
942
+ fill: {
943
+ type: BooleanConstructor;
944
+ default: boolean;
945
+ };
946
+ }>> & Readonly<{}>, {
947
+ fill: boolean;
948
+ data: number[];
949
+ w: number;
950
+ h: number;
951
+ color: string;
952
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
953
+ interface DonutDatum {
954
+ label: string;
955
+ value: number;
956
+ color: string;
957
+ }
958
+ declare const Donut: vue.DefineComponent<vue.ExtractPropTypes<{
959
+ data: {
960
+ type: PropType<DonutDatum[]>;
961
+ default: () => never[];
962
+ };
963
+ size: {
964
+ type: NumberConstructor;
965
+ default: number;
966
+ };
967
+ thickness: {
968
+ type: NumberConstructor;
969
+ default: number;
970
+ };
971
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
972
+ [key: string]: any;
973
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
974
+ data: {
975
+ type: PropType<DonutDatum[]>;
976
+ default: () => never[];
977
+ };
978
+ size: {
979
+ type: NumberConstructor;
980
+ default: number;
981
+ };
982
+ thickness: {
983
+ type: NumberConstructor;
984
+ default: number;
985
+ };
986
+ }>> & Readonly<{}>, {
987
+ size: number;
988
+ data: DonutDatum[];
989
+ thickness: number;
990
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
991
+ declare const StatCard: vue.DefineComponent<vue.ExtractPropTypes<{
992
+ label: {
993
+ type: StringConstructor;
994
+ default: undefined;
995
+ };
996
+ value: {
997
+ type: StringConstructor;
998
+ default: undefined;
999
+ };
1000
+ delta: {
1001
+ type: StringConstructor;
1002
+ default: undefined;
1003
+ };
1004
+ deltaDir: {
1005
+ type: PropType<"up" | "down">;
1006
+ default: string;
1007
+ };
1008
+ spark: {
1009
+ type: PropType<number[]>;
1010
+ default: undefined;
1011
+ };
1012
+ sparkColor: {
1013
+ type: StringConstructor;
1014
+ default: string;
1015
+ };
1016
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1017
+ [key: string]: any;
1018
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
1019
+ label: {
1020
+ type: StringConstructor;
1021
+ default: undefined;
1022
+ };
1023
+ value: {
1024
+ type: StringConstructor;
1025
+ default: undefined;
1026
+ };
1027
+ delta: {
1028
+ type: StringConstructor;
1029
+ default: undefined;
1030
+ };
1031
+ deltaDir: {
1032
+ type: PropType<"up" | "down">;
1033
+ default: string;
1034
+ };
1035
+ spark: {
1036
+ type: PropType<number[]>;
1037
+ default: undefined;
1038
+ };
1039
+ sparkColor: {
1040
+ type: StringConstructor;
1041
+ default: string;
1042
+ };
1043
+ }>> & Readonly<{}>, {
1044
+ label: string;
1045
+ value: string;
1046
+ delta: string;
1047
+ deltaDir: "up" | "down";
1048
+ spark: number[];
1049
+ sparkColor: string;
1050
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
899
1051
 
900
- export { Accordion, type AccordionItem, Alert, type AlertTone, Avatar, AvatarGroup, Badge, type BadgeTone, Banner, Breadcrumb, Button, type ButtonVariant, Card, CardHead, Checkbox, CircularProgress, DescriptionList, Divider, EmptyState, Field, IconButton, Input, Kbd, NativeSelect, Pagination, type Person, Progress, Radio, RadioGroup, Segmented, type SelectOption, Skeleton, Slider, Spinner, Stat, Stepper, Switch, type TabItem, Tabs, Tag, Textarea, Timeline, type TimelineItem };
1052
+ export { Accordion, type AccordionItem, Alert, type AlertTone, Avatar, AvatarGroup, Badge, type BadgeTone, Banner, Breadcrumb, Button, type ButtonVariant, Card, CardHead, Checkbox, CircularProgress, DescriptionList, Divider, Donut, type DonutDatum, EmptyState, Field, IconButton, Input, Kbd, NativeSelect, Pagination, type Person, Progress, Radio, RadioGroup, Segmented, type SelectOption, Skeleton, Slider, Sparkline, Spinner, Stat, StatCard, Stepper, Switch, type TabItem, Tabs, Tag, Textarea, Timeline, type TimelineItem, smoothPath };
package/dist/index.d.ts CHANGED
@@ -896,5 +896,157 @@ declare const Accordion: vue.DefineComponent<vue.ExtractPropTypes<{
896
896
  multiple: boolean;
897
897
  defaultOpen: number[];
898
898
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
899
+ type Pt = [number, number];
900
+ /** Smooth (cubic) SVG path through points. */
901
+ declare function smoothPath(pts: Pt[]): string;
902
+ declare const Sparkline: vue.DefineComponent<vue.ExtractPropTypes<{
903
+ data: {
904
+ type: PropType<number[]>;
905
+ default: () => never[];
906
+ };
907
+ color: {
908
+ type: StringConstructor;
909
+ default: string;
910
+ };
911
+ w: {
912
+ type: NumberConstructor;
913
+ default: number;
914
+ };
915
+ h: {
916
+ type: NumberConstructor;
917
+ default: number;
918
+ };
919
+ fill: {
920
+ type: BooleanConstructor;
921
+ default: boolean;
922
+ };
923
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
924
+ [key: string]: any;
925
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
926
+ data: {
927
+ type: PropType<number[]>;
928
+ default: () => never[];
929
+ };
930
+ color: {
931
+ type: StringConstructor;
932
+ default: string;
933
+ };
934
+ w: {
935
+ type: NumberConstructor;
936
+ default: number;
937
+ };
938
+ h: {
939
+ type: NumberConstructor;
940
+ default: number;
941
+ };
942
+ fill: {
943
+ type: BooleanConstructor;
944
+ default: boolean;
945
+ };
946
+ }>> & Readonly<{}>, {
947
+ fill: boolean;
948
+ data: number[];
949
+ w: number;
950
+ h: number;
951
+ color: string;
952
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
953
+ interface DonutDatum {
954
+ label: string;
955
+ value: number;
956
+ color: string;
957
+ }
958
+ declare const Donut: vue.DefineComponent<vue.ExtractPropTypes<{
959
+ data: {
960
+ type: PropType<DonutDatum[]>;
961
+ default: () => never[];
962
+ };
963
+ size: {
964
+ type: NumberConstructor;
965
+ default: number;
966
+ };
967
+ thickness: {
968
+ type: NumberConstructor;
969
+ default: number;
970
+ };
971
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
972
+ [key: string]: any;
973
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
974
+ data: {
975
+ type: PropType<DonutDatum[]>;
976
+ default: () => never[];
977
+ };
978
+ size: {
979
+ type: NumberConstructor;
980
+ default: number;
981
+ };
982
+ thickness: {
983
+ type: NumberConstructor;
984
+ default: number;
985
+ };
986
+ }>> & Readonly<{}>, {
987
+ size: number;
988
+ data: DonutDatum[];
989
+ thickness: number;
990
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
991
+ declare const StatCard: vue.DefineComponent<vue.ExtractPropTypes<{
992
+ label: {
993
+ type: StringConstructor;
994
+ default: undefined;
995
+ };
996
+ value: {
997
+ type: StringConstructor;
998
+ default: undefined;
999
+ };
1000
+ delta: {
1001
+ type: StringConstructor;
1002
+ default: undefined;
1003
+ };
1004
+ deltaDir: {
1005
+ type: PropType<"up" | "down">;
1006
+ default: string;
1007
+ };
1008
+ spark: {
1009
+ type: PropType<number[]>;
1010
+ default: undefined;
1011
+ };
1012
+ sparkColor: {
1013
+ type: StringConstructor;
1014
+ default: string;
1015
+ };
1016
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
1017
+ [key: string]: any;
1018
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
1019
+ label: {
1020
+ type: StringConstructor;
1021
+ default: undefined;
1022
+ };
1023
+ value: {
1024
+ type: StringConstructor;
1025
+ default: undefined;
1026
+ };
1027
+ delta: {
1028
+ type: StringConstructor;
1029
+ default: undefined;
1030
+ };
1031
+ deltaDir: {
1032
+ type: PropType<"up" | "down">;
1033
+ default: string;
1034
+ };
1035
+ spark: {
1036
+ type: PropType<number[]>;
1037
+ default: undefined;
1038
+ };
1039
+ sparkColor: {
1040
+ type: StringConstructor;
1041
+ default: string;
1042
+ };
1043
+ }>> & Readonly<{}>, {
1044
+ label: string;
1045
+ value: string;
1046
+ delta: string;
1047
+ deltaDir: "up" | "down";
1048
+ spark: number[];
1049
+ sparkColor: string;
1050
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
899
1051
 
900
- export { Accordion, type AccordionItem, Alert, type AlertTone, Avatar, AvatarGroup, Badge, type BadgeTone, Banner, Breadcrumb, Button, type ButtonVariant, Card, CardHead, Checkbox, CircularProgress, DescriptionList, Divider, EmptyState, Field, IconButton, Input, Kbd, NativeSelect, Pagination, type Person, Progress, Radio, RadioGroup, Segmented, type SelectOption, Skeleton, Slider, Spinner, Stat, Stepper, Switch, type TabItem, Tabs, Tag, Textarea, Timeline, type TimelineItem };
1052
+ export { Accordion, type AccordionItem, Alert, type AlertTone, Avatar, AvatarGroup, Badge, type BadgeTone, Banner, Breadcrumb, Button, type ButtonVariant, Card, CardHead, Checkbox, CircularProgress, DescriptionList, Divider, Donut, type DonutDatum, EmptyState, Field, IconButton, Input, Kbd, NativeSelect, Pagination, type Person, Progress, Radio, RadioGroup, Segmented, type SelectOption, Skeleton, Slider, Sparkline, Spinner, Stat, StatCard, Stepper, Switch, type TabItem, Tabs, Tag, Textarea, Timeline, type TimelineItem, smoothPath };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { defineComponent, h, ref } from "vue";
2
+ import { defineComponent, h, ref, useId } from "vue";
3
3
  var cx = (...parts) => parts.filter(Boolean).join(" ");
4
4
  var Button = defineComponent({
5
5
  name: "VspButton",
@@ -974,6 +974,240 @@ var Accordion = defineComponent({
974
974
  );
975
975
  }
976
976
  });
977
+ function smoothPath(pts) {
978
+ if (pts.length < 2) return "";
979
+ let d = `M ${pts[0][0]} ${pts[0][1]}`;
980
+ for (let i = 0; i < pts.length - 1; i++) {
981
+ const [x0, y0] = pts[i];
982
+ const [x1, y1] = pts[i + 1];
983
+ const cx2 = (x0 + x1) / 2;
984
+ d += ` C ${cx2} ${y0} ${cx2} ${y1} ${x1} ${y1}`;
985
+ }
986
+ return d;
987
+ }
988
+ var Sparkline = defineComponent({
989
+ name: "VspSparkline",
990
+ props: {
991
+ data: { type: Array, default: () => [] },
992
+ color: { type: String, default: "var(--accent)" },
993
+ w: { type: Number, default: 110 },
994
+ h: { type: Number, default: 34 },
995
+ fill: { type: Boolean, default: true }
996
+ },
997
+ setup(props) {
998
+ const gid = "spk" + useId().replace(/[^a-zA-Z0-9]/g, "");
999
+ return () => {
1000
+ const data = props.data;
1001
+ const min = Math.min(...data);
1002
+ const max = Math.max(...data);
1003
+ const rng = max - min || 1;
1004
+ const pts = data.map((v, i) => [
1005
+ i / (data.length - 1) * props.w,
1006
+ props.h - 3 - (v - min) / rng * (props.h - 6)
1007
+ ]);
1008
+ const d = smoothPath(pts);
1009
+ const last = pts[pts.length - 1] ?? [0, 0];
1010
+ return h(
1011
+ "svg",
1012
+ {
1013
+ width: props.w,
1014
+ height: props.h,
1015
+ viewBox: `0 0 ${props.w} ${props.h}`,
1016
+ style: { display: "block", overflow: "visible" }
1017
+ },
1018
+ [
1019
+ props.fill ? h("defs", null, [
1020
+ h("linearGradient", { id: gid, x1: "0", x2: "0", y1: "0", y2: "1" }, [
1021
+ h("stop", { offset: "0", "stop-color": props.color, "stop-opacity": "0.28" }),
1022
+ h("stop", { offset: "1", "stop-color": props.color, "stop-opacity": "0" })
1023
+ ])
1024
+ ]) : null,
1025
+ props.fill ? h("path", {
1026
+ d: `${d} L ${props.w} ${props.h} L 0 ${props.h} Z`,
1027
+ fill: `url(#${gid})`
1028
+ }) : null,
1029
+ h("path", {
1030
+ d,
1031
+ fill: "none",
1032
+ stroke: props.color,
1033
+ "stroke-width": "2",
1034
+ "stroke-linecap": "round"
1035
+ }),
1036
+ h("circle", { cx: last[0], cy: last[1], r: "2.6", fill: props.color })
1037
+ ]
1038
+ );
1039
+ };
1040
+ }
1041
+ });
1042
+ var Donut = defineComponent({
1043
+ name: "VspDonut",
1044
+ props: {
1045
+ data: { type: Array, default: () => [] },
1046
+ size: { type: Number, default: 168 },
1047
+ thickness: { type: Number, default: 22 }
1048
+ },
1049
+ setup(props) {
1050
+ return () => {
1051
+ const total = props.data.reduce((s, d) => s + d.value, 0) || 1;
1052
+ const r = (props.size - props.thickness) / 2;
1053
+ const c = props.size / 2;
1054
+ const circ = 2 * Math.PI * r;
1055
+ let acc = 0;
1056
+ const segs = props.data.map((d, i) => {
1057
+ const len = d.value / total * circ;
1058
+ const seg = h("circle", {
1059
+ key: i,
1060
+ cx: c,
1061
+ cy: c,
1062
+ r,
1063
+ fill: "none",
1064
+ stroke: d.color,
1065
+ "stroke-width": props.thickness,
1066
+ "stroke-dasharray": `${len - 2.5} ${circ - len + 2.5}`,
1067
+ "stroke-dashoffset": -acc,
1068
+ "stroke-linecap": "round"
1069
+ });
1070
+ acc += len;
1071
+ return seg;
1072
+ });
1073
+ return h("div", { style: { display: "flex", alignItems: "center", gap: "22px" } }, [
1074
+ h(
1075
+ "svg",
1076
+ {
1077
+ width: props.size,
1078
+ height: props.size,
1079
+ style: { transform: "rotate(-90deg)", flexShrink: 0 }
1080
+ },
1081
+ [
1082
+ h("circle", {
1083
+ cx: c,
1084
+ cy: c,
1085
+ r,
1086
+ fill: "none",
1087
+ stroke: "var(--surface-3)",
1088
+ "stroke-width": props.thickness
1089
+ }),
1090
+ ...segs
1091
+ ]
1092
+ ),
1093
+ h(
1094
+ "div",
1095
+ { style: { display: "flex", flexDirection: "column", gap: "9px", flex: 1 } },
1096
+ props.data.map(
1097
+ (d, i) => h(
1098
+ "div",
1099
+ {
1100
+ key: i,
1101
+ style: { display: "flex", alignItems: "center", gap: "9px", fontSize: "12.5px" }
1102
+ },
1103
+ [
1104
+ h("i", {
1105
+ style: {
1106
+ width: "9px",
1107
+ height: "9px",
1108
+ borderRadius: "3px",
1109
+ background: d.color,
1110
+ flexShrink: 0
1111
+ }
1112
+ }),
1113
+ h("span", { style: { color: "var(--text-dim)", flex: 1 } }, d.label),
1114
+ h(
1115
+ "span",
1116
+ { class: "mono tnum", style: { fontWeight: 600 } },
1117
+ `${Math.round(d.value / total * 100)}%`
1118
+ )
1119
+ ]
1120
+ )
1121
+ )
1122
+ )
1123
+ ]);
1124
+ };
1125
+ }
1126
+ });
1127
+ var StatCard = defineComponent({
1128
+ name: "VspStatCard",
1129
+ props: {
1130
+ label: { type: String, default: void 0 },
1131
+ value: { type: String, default: void 0 },
1132
+ delta: { type: String, default: void 0 },
1133
+ deltaDir: { type: String, default: "up" },
1134
+ spark: { type: Array, default: void 0 },
1135
+ sparkColor: { type: String, default: "var(--accent)" }
1136
+ },
1137
+ setup(props, { slots }) {
1138
+ return () => h(
1139
+ "div",
1140
+ {
1141
+ class: "card card-pad vsp-rise",
1142
+ style: { display: "flex", flexDirection: "column", gap: "14px" }
1143
+ },
1144
+ [
1145
+ h(
1146
+ "div",
1147
+ { style: { display: "flex", alignItems: "center", justifyContent: "space-between" } },
1148
+ [
1149
+ h("div", { style: { display: "flex", alignItems: "center", gap: "10px" } }, [
1150
+ h(
1151
+ "span",
1152
+ {
1153
+ style: {
1154
+ width: "34px",
1155
+ height: "34px",
1156
+ borderRadius: "var(--r-sm)",
1157
+ display: "grid",
1158
+ placeItems: "center",
1159
+ background: "color-mix(in oklab, var(--accent) 13%, transparent)",
1160
+ color: "var(--accent)"
1161
+ }
1162
+ },
1163
+ slots.icon?.()
1164
+ ),
1165
+ h("span", { class: "eyebrow" }, props.label)
1166
+ ]),
1167
+ props.delta != null ? h(
1168
+ "span",
1169
+ { class: cx("badge", props.deltaDir === "up" ? "badge-pos" : "badge-neg") },
1170
+ [
1171
+ svgIcon(
1172
+ props.deltaDir === "up" ? "M12 19V5M5 12l7-7 7 7" : "M12 5v14M5 12l7 7 7-7",
1173
+ 11
1174
+ ),
1175
+ props.delta
1176
+ ]
1177
+ ) : null
1178
+ ]
1179
+ ),
1180
+ h(
1181
+ "div",
1182
+ {
1183
+ style: {
1184
+ display: "flex",
1185
+ alignItems: "flex-end",
1186
+ justifyContent: "space-between",
1187
+ gap: "12px"
1188
+ }
1189
+ },
1190
+ [
1191
+ h(
1192
+ "div",
1193
+ {
1194
+ class: "tnum",
1195
+ style: {
1196
+ fontSize: "30px",
1197
+ fontWeight: 800,
1198
+ letterSpacing: "-.02em",
1199
+ lineHeight: 1
1200
+ }
1201
+ },
1202
+ props.value
1203
+ ),
1204
+ props.spark ? h(Sparkline, { data: props.spark, color: props.sparkColor }) : null
1205
+ ]
1206
+ )
1207
+ ]
1208
+ );
1209
+ }
1210
+ });
977
1211
  export {
978
1212
  Accordion,
979
1213
  Alert,
@@ -989,6 +1223,7 @@ export {
989
1223
  CircularProgress,
990
1224
  DescriptionList,
991
1225
  Divider,
1226
+ Donut,
992
1227
  EmptyState,
993
1228
  Field,
994
1229
  IconButton,
@@ -1002,13 +1237,16 @@ export {
1002
1237
  Segmented,
1003
1238
  Skeleton,
1004
1239
  Slider,
1240
+ Sparkline,
1005
1241
  Spinner,
1006
1242
  Stat,
1243
+ StatCard,
1007
1244
  Stepper,
1008
1245
  Switch,
1009
1246
  Tabs,
1010
1247
  Tag,
1011
1248
  Textarea,
1012
- Timeline
1249
+ Timeline,
1250
+ smoothPath
1013
1251
  };
1014
1252
  //# sourceMappingURL=index.js.map