@rsalianto/git-heatmap-vue 0.1.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/GitHeatmap.vue.d.ts +36 -0
- package/dist/GitHeatmap.vue.d.ts.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +238 -0
- package/dist/useHeatmapData.d.ts +32 -0
- package/dist/useHeatmapData.d.ts.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { HeatmapData, HeatmapDay, HeatmapTheme, LevelConfig } from '@rsalianto/git-heatmap-core';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
data?: HeatmapData;
|
|
4
|
+
apiUrl?: string;
|
|
5
|
+
fetchData?: () => Promise<HeatmapData>;
|
|
6
|
+
levels?: LevelConfig[];
|
|
7
|
+
cellSize?: number;
|
|
8
|
+
cellGap?: number;
|
|
9
|
+
cellRadius?: number;
|
|
10
|
+
showTotal?: boolean;
|
|
11
|
+
showLegend?: boolean;
|
|
12
|
+
showMonthLabels?: boolean;
|
|
13
|
+
showDayLabels?: boolean;
|
|
14
|
+
theme?: Partial<HeatmapTheme>;
|
|
15
|
+
label?: string;
|
|
16
|
+
};
|
|
17
|
+
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
18
|
+
"day-click": (day: HeatmapDay) => any;
|
|
19
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
20
|
+
"onDay-click"?: ((day: HeatmapDay) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
levels: LevelConfig[];
|
|
23
|
+
cellSize: number;
|
|
24
|
+
cellGap: number;
|
|
25
|
+
cellRadius: number;
|
|
26
|
+
showTotal: boolean;
|
|
27
|
+
showLegend: boolean;
|
|
28
|
+
showMonthLabels: boolean;
|
|
29
|
+
showDayLabels: boolean;
|
|
30
|
+
label: string;
|
|
31
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
32
|
+
wrapperRef: HTMLDivElement;
|
|
33
|
+
scrollRef: HTMLDivElement;
|
|
34
|
+
}, HTMLDivElement>;
|
|
35
|
+
export default _default;
|
|
36
|
+
//# sourceMappingURL=GitHeatmap.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GitHeatmap.vue.d.ts","sourceRoot":"","sources":["../src/GitHeatmap.vue"],"names":[],"mappings":"AAqOA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAGtG,KAAK,WAAW,GAAG;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;;;;;;YAVS,WAAW,EAAE;cACX,MAAM;aACP,MAAM;gBACH,MAAM;eACP,OAAO;gBACN,OAAO;qBACF,OAAO;mBACT,OAAO;WAEf,MAAM;;;;;AA6UhB,wBAUG"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),p=require("@rsalianto/git-heatmap-core");function S(t){const y=e.ref(t.data??null),a=e.ref(t.data?"success":"idle"),f=e.ref(null);async function c(){if(t.data){y.value=t.data,a.value="success";return}const g=t.fetchData??(t.apiUrl?()=>fetch(t.apiUrl).then(d=>d.json()):null);if(g){a.value="loading";try{y.value=await g(),a.value="success"}catch(d){f.value=d instanceof Error?d:new Error(String(d)),a.value="error"}}}return e.onMounted(c),e.watch(()=>t.apiUrl,c),{data:y,status:a,error:f}}const D=["aria-label"],V={key:0,style:{opacity:"0.6",padding:"1rem 0"}},N={key:0,style:{height:"16px",width:"160px",background:"var(--ghm-text)","border-radius":"4px","margin-bottom":"12px",opacity:"0.2"}},R={key:0,style:{"margin-bottom":"12px",color:"var(--ghm-text)"}},M={style:{display:"flex"}},G=["aria-label","onMouseenter","onClick"],F={key:1,style:{"margin-top":"8px","font-size":"0.9em",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)","border-radius":"4px",padding:"6px 12px"}},T={key:2,style:{display:"flex","align-items":"center","justify-content":"flex-end","margin-top":"8px"}},H={style:{display:"flex","align-items":"center",gap:"6px","font-size":"0.9em"}},U=["title"],z=e.defineComponent({__name:"GitHeatmap",props:{data:{},apiUrl:{},fetchData:{},levels:{default:()=>p.DEFAULT_LEVELS},cellSize:{default:p.CELL},cellGap:{default:p.GAP},cellRadius:{default:2},showTotal:{type:Boolean,default:!0},showLegend:{type:Boolean,default:!0},showMonthLabels:{type:Boolean,default:!0},showDayLabels:{type:Boolean,default:!0},theme:{},label:{default:"Contribution heatmap"}},emits:["day-click"],setup(t,{emit:y}){const a=t,f=y,{data:c,status:g,error:d}=S({data:a.data,apiUrl:a.apiUrl,fetchData:a.fetchData}),h=e.ref(null),x=e.ref(null),v=e.ref(null),m=e.ref(null),b=e.computed(()=>a.cellSize+a.cellGap),u=e.computed(()=>({...p.DEFAULT_THEME,...a.theme})),L=e.computed(()=>({"--ghm-color-l0":u.value.colorL0,"--ghm-color-l1":u.value.colorL1,"--ghm-color-l2":u.value.colorL2,"--ghm-color-l3":u.value.colorL3,"--ghm-color-l4":u.value.colorL4,"--ghm-text":u.value.textColor,"--ghm-tooltip-bg":u.value.tooltipBg,"--ghm-tooltip-border":u.value.tooltipBorderColor,"--ghm-tooltip-text":u.value.tooltipTextColor,"--ghm-font":u.value.fontFamily,"--ghm-fs":u.value.fontSize})),B=e.computed(()=>a.showMonthLabels&&c.value?p.buildMonthLabels(c.value.weeks):[]);function k(l){return l.count===0?`No contributions on ${l.date}`:`${l.count} contribution${l.count>1?"s":""} on ${l.date}`}function $(l){return`var(--ghm-color-l${l})`}function w(l,n){var i;const o=l.currentTarget.getBoundingClientRect(),r=(i=x.value)==null?void 0:i.getBoundingClientRect();r&&(m.value={day:n,x:o.left-r.left+a.cellSize/2,y:o.top-r.top})}function C(l){var n;v.value=((n=v.value)==null?void 0:n.date)===l.date?null:l,f("day-click",l)}return e.watch(c,l=>{l&&h.value&&(h.value.scrollLeft=h.value.scrollWidth)}),e.onMounted(()=>{if(typeof document>"u"||document.getElementById("ghm-style"))return;const l=document.createElement("style");l.id="ghm-style",l.textContent=`
|
|
2
|
+
[data-git-heatmap] {
|
|
3
|
+
display: block; position: relative; width: 100%;
|
|
4
|
+
font-size: var(--ghm-fs); font-family: var(--ghm-font);
|
|
5
|
+
color: var(--ghm-text); user-select: none; box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
[data-git-heatmap] * { box-sizing: border-box; }
|
|
8
|
+
`,document.head.appendChild(l)}),(l,n)=>(e.openBlock(),e.createElementBlock("div",{"data-git-heatmap":"",style:e.normalizeStyle(L.value),"aria-label":t.label,ref_key:"wrapperRef",ref:x},[e.unref(d)?(e.openBlock(),e.createElementBlock("p",V,"Could not load contribution data.")):e.unref(g)==="loading"||e.unref(g)==="idle"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[t.showTotal?(e.openBlock(),e.createElementBlock("div",N)):e.createCommentVNode("",!0),e.createElementVNode("div",{style:e.normalizeStyle({display:"flex",gap:`${t.cellGap}px`,opacity:.4})},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(53,o=>e.createElementVNode("div",{key:o,style:e.normalizeStyle({display:"flex",flexDirection:"column",gap:`${t.cellGap}px`})},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(7,r=>e.createElementVNode("div",{key:r,style:e.normalizeStyle({width:`${t.cellSize}px`,height:`${t.cellSize}px`,borderRadius:`${t.cellRadius}px`,background:"var(--ghm-color-l0)"})},null,4)),64))],4)),64))],4)],64)):e.unref(c)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[t.showTotal?(e.openBlock(),e.createElementBlock("p",R,e.toDisplayString(e.unref(c).totalContributions.toLocaleString())+" contributions in the last year ",1)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"scrollRef",ref:h,style:{"overflow-x":"auto","overflow-y":"visible","padding-bottom":"4px"}},[e.createElementVNode("div",{style:e.normalizeStyle({display:"inline-flex",flexDirection:"column",minWidth:`${e.unref(c).weeks.length*b.value}px`})},[t.showMonthLabels?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({display:"flex",marginBottom:`${t.cellGap}px`,marginLeft:t.showDayLabels?"32px":"0"})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,(o,r)=>{var i;return e.openBlock(),e.createElementBlock("div",{key:o.label+o.col,style:e.normalizeStyle({width:`${((((i=B.value[r+1])==null?void 0:i.col)??e.unref(c).weeks.length)-o.col)*b.value}px`,whiteSpace:"nowrap",fontSize:"0.9em"})},e.toDisplayString(o.label),5)}),128))],4)):e.createCommentVNode("",!0),e.createElementVNode("div",M,[t.showDayLabels?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({display:"flex",flexDirection:"column",gap:`${t.cellGap}px`,marginRight:"6px"})},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(7,o=>e.createElementVNode("div",{key:o,style:e.normalizeStyle({height:`${t.cellSize}px`,lineHeight:`${t.cellSize}px`,width:"26px",textAlign:"right",paddingRight:"4px",fontSize:"0.9em"})},e.toDisplayString(e.unref(p.DAY_LABELS)[o-1]??""),5)),64))],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{style:e.normalizeStyle({display:"flex",gap:`${t.cellGap}px`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(c).weeks,(o,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,style:e.normalizeStyle({display:"flex",flexDirection:"column",gap:`${t.cellGap}px`})},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(7,i=>{var E;return e.openBlock(),e.createElementBlock(e.Fragment,{key:i},[(E=o.days[i-1])!=null&&E.date?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({width:`${t.cellSize}px`,height:`${t.cellSize}px`,borderRadius:`${t.cellRadius}px`,background:$(o.days[i-1].level),cursor:"pointer",transition:"opacity 0.15s"}),"aria-label":k(o.days[i-1]),role:"button",tabindex:"0",onMouseenter:s=>w(s,o.days[i-1]),onMouseleave:n[0]||(n[0]=s=>m.value=null),onMouseover:n[1]||(n[1]=s=>s.currentTarget.style.opacity="0.7"),onMouseout:n[2]||(n[2]=s=>s.currentTarget.style.opacity="1"),onClick:s=>C(o.days[i-1])},null,44,G)):(e.openBlock(),e.createElementBlock("div",{key:1,style:e.normalizeStyle({width:`${t.cellSize}px`,height:`${t.cellSize}px`})},null,4))],64)}),64))],4))),128))],4)])],4)],512),v.value?(e.openBlock(),e.createElementBlock("div",F,e.toDisplayString(k(v.value)),1)):e.createCommentVNode("",!0),t.showLegend?(e.openBlock(),e.createElementBlock("div",T,[e.createElementVNode("div",H,[n[3]||(n[3]=e.createElementVNode("span",null,"Less",-1)),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.levels,(o,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,style:e.normalizeStyle({width:`${t.cellSize}px`,height:`${t.cellSize}px`,borderRadius:`${t.cellRadius}px`,background:`var(--ghm-color-l${r})`}),title:o.label},null,12,U))),128)),n[4]||(n[4]=e.createElementVNode("span",null,"More",-1))])])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",{key:3,style:e.normalizeStyle({pointerEvents:"none",position:"absolute",zIndex:50,left:`${m.value.x}px`,top:`${m.value.y-6}px`,transform:"translate(-50%, -100%)",background:"var(--ghm-tooltip-bg)",border:"1px solid var(--ghm-tooltip-border)",color:"var(--ghm-tooltip-text)",fontSize:"0.9em",borderRadius:"4px",padding:"3px 8px",whiteSpace:"nowrap"})},e.toDisplayString(k(m.value.day)),5)):e.createCommentVNode("",!0)],64)):e.createCommentVNode("",!0)],12,D))}}),A={install(t){t.component("GitHeatmap",z)}};exports.GitHeatmap=z;exports.GitHeatmapPlugin=A;exports.useHeatmapData=S;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { default as GitHeatmapVue } from './GitHeatmap.vue';
|
|
3
|
+
export { GitHeatmapVue as GitHeatmap };
|
|
4
|
+
export { useHeatmapData } from './useHeatmapData';
|
|
5
|
+
export type { HeatmapStatus } from './useHeatmapData';
|
|
6
|
+
export declare const GitHeatmapPlugin: {
|
|
7
|
+
install(app: App): void;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,aAAa,IAAI,UAAU,EAAE,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,eAAO,MAAM,gBAAgB;iBACd,GAAG;CAGjB,CAAC"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { ref as x, onMounted as M, watch as T, defineComponent as V, computed as C, openBlock as t, createElementBlock as l, normalizeStyle as i, unref as p, Fragment as h, createCommentVNode as y, createElementVNode as g, renderList as f, toDisplayString as L } from "vue";
|
|
2
|
+
import { GAP as N, CELL as j, DEFAULT_LEVELS as I, DEFAULT_THEME as P, buildMonthLabels as W, DAY_LABELS as Y } from "@rsalianto/git-heatmap-core";
|
|
3
|
+
function q(e) {
|
|
4
|
+
const k = x(e.data ?? null), r = x(e.data ? "success" : "idle"), w = x(null);
|
|
5
|
+
async function d() {
|
|
6
|
+
if (e.data) {
|
|
7
|
+
k.value = e.data, r.value = "success";
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const $ = e.fetchData ?? (e.apiUrl ? () => fetch(e.apiUrl).then((m) => m.json()) : null);
|
|
11
|
+
if ($) {
|
|
12
|
+
r.value = "loading";
|
|
13
|
+
try {
|
|
14
|
+
k.value = await $(), r.value = "success";
|
|
15
|
+
} catch (m) {
|
|
16
|
+
w.value = m instanceof Error ? m : new Error(String(m)), r.value = "error";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return M(d), T(() => e.apiUrl, d), { data: k, status: r, error: w };
|
|
21
|
+
}
|
|
22
|
+
const J = ["aria-label"], K = {
|
|
23
|
+
key: 0,
|
|
24
|
+
style: { opacity: "0.6", padding: "1rem 0" }
|
|
25
|
+
}, O = {
|
|
26
|
+
key: 0,
|
|
27
|
+
style: { height: "16px", width: "160px", background: "var(--ghm-text)", "border-radius": "4px", "margin-bottom": "12px", opacity: "0.2" }
|
|
28
|
+
}, Q = {
|
|
29
|
+
key: 0,
|
|
30
|
+
style: { "margin-bottom": "12px", color: "var(--ghm-text)" }
|
|
31
|
+
}, X = { style: { display: "flex" } }, Z = ["aria-label", "onMouseenter", "onClick"], _ = {
|
|
32
|
+
key: 1,
|
|
33
|
+
style: { "margin-top": "8px", "font-size": "0.9em", background: "rgba(255,255,255,0.05)", border: "1px solid rgba(255,255,255,0.1)", "border-radius": "4px", padding: "6px 12px" }
|
|
34
|
+
}, ee = {
|
|
35
|
+
key: 2,
|
|
36
|
+
style: { display: "flex", "align-items": "center", "justify-content": "flex-end", "margin-top": "8px" }
|
|
37
|
+
}, te = { style: { display: "flex", "align-items": "center", gap: "6px", "font-size": "0.9em" } }, le = ["title"], ae = /* @__PURE__ */ V({
|
|
38
|
+
__name: "GitHeatmap",
|
|
39
|
+
props: {
|
|
40
|
+
data: {},
|
|
41
|
+
apiUrl: {},
|
|
42
|
+
fetchData: {},
|
|
43
|
+
levels: { default: () => I },
|
|
44
|
+
cellSize: { default: j },
|
|
45
|
+
cellGap: { default: N },
|
|
46
|
+
cellRadius: { default: 2 },
|
|
47
|
+
showTotal: { type: Boolean, default: !0 },
|
|
48
|
+
showLegend: { type: Boolean, default: !0 },
|
|
49
|
+
showMonthLabels: { type: Boolean, default: !0 },
|
|
50
|
+
showDayLabels: { type: Boolean, default: !0 },
|
|
51
|
+
theme: {},
|
|
52
|
+
label: { default: "Contribution heatmap" }
|
|
53
|
+
},
|
|
54
|
+
emits: ["day-click"],
|
|
55
|
+
setup(e, { emit: k }) {
|
|
56
|
+
const r = e, w = k, { data: d, status: $, error: m } = q({
|
|
57
|
+
data: r.data,
|
|
58
|
+
apiUrl: r.apiUrl,
|
|
59
|
+
fetchData: r.fetchData
|
|
60
|
+
}), S = x(null), E = x(null), z = x(null), b = x(null), R = C(() => r.cellSize + r.cellGap), c = C(() => ({ ...P, ...r.theme })), U = C(() => ({
|
|
61
|
+
"--ghm-color-l0": c.value.colorL0,
|
|
62
|
+
"--ghm-color-l1": c.value.colorL1,
|
|
63
|
+
"--ghm-color-l2": c.value.colorL2,
|
|
64
|
+
"--ghm-color-l3": c.value.colorL3,
|
|
65
|
+
"--ghm-color-l4": c.value.colorL4,
|
|
66
|
+
"--ghm-text": c.value.textColor,
|
|
67
|
+
"--ghm-tooltip-bg": c.value.tooltipBg,
|
|
68
|
+
"--ghm-tooltip-border": c.value.tooltipBorderColor,
|
|
69
|
+
"--ghm-tooltip-text": c.value.tooltipTextColor,
|
|
70
|
+
"--ghm-font": c.value.fontFamily,
|
|
71
|
+
"--ghm-fs": c.value.fontSize
|
|
72
|
+
})), B = C(
|
|
73
|
+
() => r.showMonthLabels && d.value ? W(d.value.weeks) : []
|
|
74
|
+
);
|
|
75
|
+
function D(a) {
|
|
76
|
+
return a.count === 0 ? `No contributions on ${a.date}` : `${a.count} contribution${a.count > 1 ? "s" : ""} on ${a.date}`;
|
|
77
|
+
}
|
|
78
|
+
function H(a) {
|
|
79
|
+
return `var(--ghm-color-l${a})`;
|
|
80
|
+
}
|
|
81
|
+
function A(a, n) {
|
|
82
|
+
var s;
|
|
83
|
+
const o = a.currentTarget.getBoundingClientRect(), u = (s = E.value) == null ? void 0 : s.getBoundingClientRect();
|
|
84
|
+
u && (b.value = { day: n, x: o.left - u.left + r.cellSize / 2, y: o.top - u.top });
|
|
85
|
+
}
|
|
86
|
+
function F(a) {
|
|
87
|
+
var n;
|
|
88
|
+
z.value = ((n = z.value) == null ? void 0 : n.date) === a.date ? null : a, w("day-click", a);
|
|
89
|
+
}
|
|
90
|
+
return T(d, (a) => {
|
|
91
|
+
a && S.value && (S.value.scrollLeft = S.value.scrollWidth);
|
|
92
|
+
}), M(() => {
|
|
93
|
+
if (typeof document > "u" || document.getElementById("ghm-style")) return;
|
|
94
|
+
const a = document.createElement("style");
|
|
95
|
+
a.id = "ghm-style", a.textContent = `
|
|
96
|
+
[data-git-heatmap] {
|
|
97
|
+
display: block; position: relative; width: 100%;
|
|
98
|
+
font-size: var(--ghm-fs); font-family: var(--ghm-font);
|
|
99
|
+
color: var(--ghm-text); user-select: none; box-sizing: border-box;
|
|
100
|
+
}
|
|
101
|
+
[data-git-heatmap] * { box-sizing: border-box; }
|
|
102
|
+
`, document.head.appendChild(a);
|
|
103
|
+
}), (a, n) => (t(), l("div", {
|
|
104
|
+
"data-git-heatmap": "",
|
|
105
|
+
style: i(U.value),
|
|
106
|
+
"aria-label": e.label,
|
|
107
|
+
ref_key: "wrapperRef",
|
|
108
|
+
ref: E
|
|
109
|
+
}, [
|
|
110
|
+
p(m) ? (t(), l("p", K, "Could not load contribution data.")) : p($) === "loading" || p($) === "idle" ? (t(), l(h, { key: 1 }, [
|
|
111
|
+
e.showTotal ? (t(), l("div", O)) : y("", !0),
|
|
112
|
+
g("div", {
|
|
113
|
+
style: i({ display: "flex", gap: `${e.cellGap}px`, opacity: 0.4 })
|
|
114
|
+
}, [
|
|
115
|
+
(t(), l(h, null, f(53, (o) => g("div", {
|
|
116
|
+
key: o,
|
|
117
|
+
style: i({ display: "flex", flexDirection: "column", gap: `${e.cellGap}px` })
|
|
118
|
+
}, [
|
|
119
|
+
(t(), l(h, null, f(7, (u) => g("div", {
|
|
120
|
+
key: u,
|
|
121
|
+
style: i({ width: `${e.cellSize}px`, height: `${e.cellSize}px`, borderRadius: `${e.cellRadius}px`, background: "var(--ghm-color-l0)" })
|
|
122
|
+
}, null, 4)), 64))
|
|
123
|
+
], 4)), 64))
|
|
124
|
+
], 4)
|
|
125
|
+
], 64)) : p(d) ? (t(), l(h, { key: 2 }, [
|
|
126
|
+
e.showTotal ? (t(), l("p", Q, L(p(d).totalContributions.toLocaleString()) + " contributions in the last year ", 1)) : y("", !0),
|
|
127
|
+
g("div", {
|
|
128
|
+
ref_key: "scrollRef",
|
|
129
|
+
ref: S,
|
|
130
|
+
style: { "overflow-x": "auto", "overflow-y": "visible", "padding-bottom": "4px" }
|
|
131
|
+
}, [
|
|
132
|
+
g("div", {
|
|
133
|
+
style: i({ display: "inline-flex", flexDirection: "column", minWidth: `${p(d).weeks.length * R.value}px` })
|
|
134
|
+
}, [
|
|
135
|
+
e.showMonthLabels ? (t(), l("div", {
|
|
136
|
+
key: 0,
|
|
137
|
+
style: i({ display: "flex", marginBottom: `${e.cellGap}px`, marginLeft: e.showDayLabels ? "32px" : "0" })
|
|
138
|
+
}, [
|
|
139
|
+
(t(!0), l(h, null, f(B.value, (o, u) => {
|
|
140
|
+
var s;
|
|
141
|
+
return t(), l("div", {
|
|
142
|
+
key: o.label + o.col,
|
|
143
|
+
style: i({ width: `${((((s = B.value[u + 1]) == null ? void 0 : s.col) ?? p(d).weeks.length) - o.col) * R.value}px`, whiteSpace: "nowrap", fontSize: "0.9em" })
|
|
144
|
+
}, L(o.label), 5);
|
|
145
|
+
}), 128))
|
|
146
|
+
], 4)) : y("", !0),
|
|
147
|
+
g("div", X, [
|
|
148
|
+
e.showDayLabels ? (t(), l("div", {
|
|
149
|
+
key: 0,
|
|
150
|
+
style: i({ display: "flex", flexDirection: "column", gap: `${e.cellGap}px`, marginRight: "6px" })
|
|
151
|
+
}, [
|
|
152
|
+
(t(), l(h, null, f(7, (o) => g("div", {
|
|
153
|
+
key: o,
|
|
154
|
+
style: i({ height: `${e.cellSize}px`, lineHeight: `${e.cellSize}px`, width: "26px", textAlign: "right", paddingRight: "4px", fontSize: "0.9em" })
|
|
155
|
+
}, L(p(Y)[o - 1] ?? ""), 5)), 64))
|
|
156
|
+
], 4)) : y("", !0),
|
|
157
|
+
g("div", {
|
|
158
|
+
style: i({ display: "flex", gap: `${e.cellGap}px` })
|
|
159
|
+
}, [
|
|
160
|
+
(t(!0), l(h, null, f(p(d).weeks, (o, u) => (t(), l("div", {
|
|
161
|
+
key: u,
|
|
162
|
+
style: i({ display: "flex", flexDirection: "column", gap: `${e.cellGap}px` })
|
|
163
|
+
}, [
|
|
164
|
+
(t(), l(h, null, f(7, (s) => {
|
|
165
|
+
var G;
|
|
166
|
+
return t(), l(h, { key: s }, [
|
|
167
|
+
(G = o.days[s - 1]) != null && G.date ? (t(), l("div", {
|
|
168
|
+
key: 0,
|
|
169
|
+
style: i({
|
|
170
|
+
width: `${e.cellSize}px`,
|
|
171
|
+
height: `${e.cellSize}px`,
|
|
172
|
+
borderRadius: `${e.cellRadius}px`,
|
|
173
|
+
background: H(o.days[s - 1].level),
|
|
174
|
+
cursor: "pointer",
|
|
175
|
+
transition: "opacity 0.15s"
|
|
176
|
+
}),
|
|
177
|
+
"aria-label": D(o.days[s - 1]),
|
|
178
|
+
role: "button",
|
|
179
|
+
tabindex: "0",
|
|
180
|
+
onMouseenter: (v) => A(v, o.days[s - 1]),
|
|
181
|
+
onMouseleave: n[0] || (n[0] = (v) => b.value = null),
|
|
182
|
+
onMouseover: n[1] || (n[1] = (v) => v.currentTarget.style.opacity = "0.7"),
|
|
183
|
+
onMouseout: n[2] || (n[2] = (v) => v.currentTarget.style.opacity = "1"),
|
|
184
|
+
onClick: (v) => F(o.days[s - 1])
|
|
185
|
+
}, null, 44, Z)) : (t(), l("div", {
|
|
186
|
+
key: 1,
|
|
187
|
+
style: i({ width: `${e.cellSize}px`, height: `${e.cellSize}px` })
|
|
188
|
+
}, null, 4))
|
|
189
|
+
], 64);
|
|
190
|
+
}), 64))
|
|
191
|
+
], 4))), 128))
|
|
192
|
+
], 4)
|
|
193
|
+
])
|
|
194
|
+
], 4)
|
|
195
|
+
], 512),
|
|
196
|
+
z.value ? (t(), l("div", _, L(D(z.value)), 1)) : y("", !0),
|
|
197
|
+
e.showLegend ? (t(), l("div", ee, [
|
|
198
|
+
g("div", te, [
|
|
199
|
+
n[3] || (n[3] = g("span", null, "Less", -1)),
|
|
200
|
+
(t(!0), l(h, null, f(e.levels, (o, u) => (t(), l("div", {
|
|
201
|
+
key: u,
|
|
202
|
+
style: i({ width: `${e.cellSize}px`, height: `${e.cellSize}px`, borderRadius: `${e.cellRadius}px`, background: `var(--ghm-color-l${u})` }),
|
|
203
|
+
title: o.label
|
|
204
|
+
}, null, 12, le))), 128)),
|
|
205
|
+
n[4] || (n[4] = g("span", null, "More", -1))
|
|
206
|
+
])
|
|
207
|
+
])) : y("", !0),
|
|
208
|
+
b.value ? (t(), l("div", {
|
|
209
|
+
key: 3,
|
|
210
|
+
style: i({
|
|
211
|
+
pointerEvents: "none",
|
|
212
|
+
position: "absolute",
|
|
213
|
+
zIndex: 50,
|
|
214
|
+
left: `${b.value.x}px`,
|
|
215
|
+
top: `${b.value.y - 6}px`,
|
|
216
|
+
transform: "translate(-50%, -100%)",
|
|
217
|
+
background: "var(--ghm-tooltip-bg)",
|
|
218
|
+
border: "1px solid var(--ghm-tooltip-border)",
|
|
219
|
+
color: "var(--ghm-tooltip-text)",
|
|
220
|
+
fontSize: "0.9em",
|
|
221
|
+
borderRadius: "4px",
|
|
222
|
+
padding: "3px 8px",
|
|
223
|
+
whiteSpace: "nowrap"
|
|
224
|
+
})
|
|
225
|
+
}, L(D(b.value.day)), 5)) : y("", !0)
|
|
226
|
+
], 64)) : y("", !0)
|
|
227
|
+
], 12, J));
|
|
228
|
+
}
|
|
229
|
+
}), ie = {
|
|
230
|
+
install(e) {
|
|
231
|
+
e.component("GitHeatmap", ae);
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
export {
|
|
235
|
+
ae as GitHeatmap,
|
|
236
|
+
ie as GitHeatmapPlugin,
|
|
237
|
+
q as useHeatmapData
|
|
238
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HeatmapData } from '@rsalianto/git-heatmap-core';
|
|
2
|
+
export type HeatmapStatus = "idle" | "loading" | "success" | "error";
|
|
3
|
+
export declare function useHeatmapData(options: {
|
|
4
|
+
data?: HeatmapData;
|
|
5
|
+
apiUrl?: string;
|
|
6
|
+
fetchData?: () => Promise<HeatmapData>;
|
|
7
|
+
}): {
|
|
8
|
+
data: import('vue').Ref<{
|
|
9
|
+
totalContributions: number;
|
|
10
|
+
weeks: {
|
|
11
|
+
days: {
|
|
12
|
+
date: string;
|
|
13
|
+
count: number;
|
|
14
|
+
level: 0 | 1 | 2 | 3 | 4;
|
|
15
|
+
}[];
|
|
16
|
+
}[];
|
|
17
|
+
source: "github" | "gitlab" | "manual";
|
|
18
|
+
} | null, HeatmapData | {
|
|
19
|
+
totalContributions: number;
|
|
20
|
+
weeks: {
|
|
21
|
+
days: {
|
|
22
|
+
date: string;
|
|
23
|
+
count: number;
|
|
24
|
+
level: 0 | 1 | 2 | 3 | 4;
|
|
25
|
+
}[];
|
|
26
|
+
}[];
|
|
27
|
+
source: "github" | "gitlab" | "manual";
|
|
28
|
+
} | null>;
|
|
29
|
+
status: import('vue').Ref<HeatmapStatus, HeatmapStatus>;
|
|
30
|
+
error: import('vue').Ref<Error | null, Error | null>;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=useHeatmapData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHeatmapData.d.ts","sourceRoot":"","sources":["../src/useHeatmapData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;AAErE,wBAAgB,cAAc,CAAC,OAAO,EAAE;IACtC,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;CACxC;;;;;;;;;;;;;;;;;;;;;;;;EA6BA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rsalianto/git-heatmap-vue",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Vue 3 component for git contribution heatmap",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": ["dist", "README.md"],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "vite build",
|
|
19
|
+
"dev": "vite build --watch",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"clean": "rm -rf dist"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@rsalianto/git-heatmap-core": "*"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"vue": ">=3.3.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "*",
|
|
31
|
+
"vitest": "*",
|
|
32
|
+
"vue": "^3.5.0",
|
|
33
|
+
"vite": "^6.0.0",
|
|
34
|
+
"@vitejs/plugin-vue": "^5.0.0",
|
|
35
|
+
"vite-plugin-dts": "^4.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|