@gnome-ui/react 1.42.0 → 1.44.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.
Files changed (47) hide show
  1. package/README.md +78 -1
  2. package/dist/components/Card/Card.module.css.cjs +1 -1
  3. package/dist/components/Card/Card.module.css.cjs.map +1 -1
  4. package/dist/components/Card/Card.module.css.js +5 -5
  5. package/dist/components/Card/Card.module.css.js.map +1 -1
  6. package/dist/components/ContributionGraph/ContributionGraph.cjs +1 -1
  7. package/dist/components/ContributionGraph/ContributionGraph.cjs.map +1 -1
  8. package/dist/components/ContributionGraph/ContributionGraph.d.ts +11 -6
  9. package/dist/components/ContributionGraph/ContributionGraph.js +211 -130
  10. package/dist/components/ContributionGraph/ContributionGraph.js.map +1 -1
  11. package/dist/components/ContributionGraph/ContributionGraph.module.css.cjs +1 -1
  12. package/dist/components/ContributionGraph/ContributionGraph.module.css.cjs.map +1 -1
  13. package/dist/components/ContributionGraph/ContributionGraph.module.css.js +9 -8
  14. package/dist/components/ContributionGraph/ContributionGraph.module.css.js.map +1 -1
  15. package/dist/components/ContributionGraph/index.d.ts +1 -1
  16. package/dist/components/Drawer/Drawer.cjs +2 -0
  17. package/dist/components/Drawer/Drawer.cjs.map +1 -0
  18. package/dist/components/Drawer/Drawer.d.ts +28 -0
  19. package/dist/components/Drawer/Drawer.js +55 -0
  20. package/dist/components/Drawer/Drawer.js.map +1 -0
  21. package/dist/components/Drawer/Drawer.module.css.cjs +2 -0
  22. package/dist/components/Drawer/Drawer.module.css.cjs.map +1 -0
  23. package/dist/components/Drawer/Drawer.module.css.js +18 -0
  24. package/dist/components/Drawer/Drawer.module.css.js.map +1 -0
  25. package/dist/components/Drawer/index.d.ts +2 -0
  26. package/dist/components/Drawer.cjs +1 -0
  27. package/dist/components/Drawer.d.ts +2 -0
  28. package/dist/components/Drawer.js +2 -0
  29. package/dist/components/GnomeProvider/GnomeContext.cjs +1 -1
  30. package/dist/components/GnomeProvider/GnomeContext.cjs.map +1 -1
  31. package/dist/components/GnomeProvider/GnomeContext.d.ts +12 -0
  32. package/dist/components/GnomeProvider/GnomeContext.js +14 -2
  33. package/dist/components/GnomeProvider/GnomeContext.js.map +1 -1
  34. package/dist/components/GnomeProvider/GnomeProvider.cjs +1 -1
  35. package/dist/components/GnomeProvider/GnomeProvider.cjs.map +1 -1
  36. package/dist/components/GnomeProvider/GnomeProvider.d.ts +17 -3
  37. package/dist/components/GnomeProvider/GnomeProvider.js +55 -16
  38. package/dist/components/GnomeProvider/GnomeProvider.js.map +1 -1
  39. package/dist/components/Icon/Icon.cjs +1 -1
  40. package/dist/components/Icon/Icon.cjs.map +1 -1
  41. package/dist/components/Icon/Icon.js +2 -1
  42. package/dist/components/Icon/Icon.js.map +1 -1
  43. package/dist/index.cjs +1 -1
  44. package/dist/index.d.ts +5 -3
  45. package/dist/index.js +68 -67
  46. package/dist/style.css +1 -1
  47. package/package.json +6 -1
@@ -1,23 +1,35 @@
1
1
  import e from "./ContributionGraph.module.css.js";
2
- import { useDateTimeFormatter as t } from "../GnomeProvider/GnomeContext.js";
3
- import { useMemo as n, useRef as r, useState as i } from "react";
4
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
2
+ import { GnomeContext as t, useDateTimeFormatter as n } from "../GnomeProvider/GnomeContext.js";
3
+ import { useContext as r, useEffect as i, useMemo as a, useRef as o, useState as s } from "react";
4
+ import { createPortal as c } from "react-dom";
5
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
5
6
  //#region src/components/ContributionGraph/ContributionGraph.tsx
6
- var s = new Date(2e3, 0, 2);
7
- function c(e, t) {
7
+ var d = new Date(2e3, 0, 2);
8
+ function f(e, t) {
8
9
  return t.format(new Date(2e3, e));
9
10
  }
10
- function l(e, t) {
11
- let n = new Date(s);
12
- return n.setDate(s.getDate() + e), t.format(n);
11
+ function ee(e, t) {
12
+ let n = new Date(d);
13
+ return n.setDate(d.getDate() + e), t.format(n);
14
+ }
15
+ var te = 28, ne = 20, re = new Set([
16
+ "blue",
17
+ "green",
18
+ "yellow",
19
+ "orange",
20
+ "red",
21
+ "purple",
22
+ "brown"
23
+ ]);
24
+ function ie(e) {
25
+ return [
26
+ "var(--gnome-card-shade-color)",
27
+ `var(--gnome-${e}-1)`,
28
+ `var(--gnome-${e}-2)`,
29
+ `var(--gnome-${e}-4)`,
30
+ `var(--gnome-${e}-5)`
31
+ ];
13
32
  }
14
- var u = 28, d = 20, f = [
15
- "var(--gnome-card-shade-color, rgba(0,0,0,0.07))",
16
- "var(--gnome-green-1, #8ff0a4)",
17
- "var(--gnome-green-2, #57e389)",
18
- "var(--gnome-green-4, #2ec27e)",
19
- "var(--gnome-green-5, #26a269)"
20
- ];
21
33
  function p(e) {
22
34
  return `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`;
23
35
  }
@@ -28,38 +40,92 @@ function m(e) {
28
40
  function h(e, t) {
29
41
  return t.format(m(e));
30
42
  }
31
- function g({ data: s, maxLevel: m = 4, colorScale: g, cellSize: _ = 12, cellGap: v = 3, weekStartDay: y = 1, showMonthLabels: b = !0, showDayLabels: x = !0, showLegend: S = !0, weeks: C = 52, ariaLabel: w = "Contribution graph", onDayClick: T, tooltipContent: E, className: D }) {
32
- let O = t({ month: "short" }), k = t({ weekday: "short" }), A = t({
43
+ function g({ data: d, maxLevel: m = 4, cellSize: g = 12, cellGap: _ = 3, responsive: v = !0, minCellSize: ae = 8, maxCellSize: oe = 24, weekStartDay: y = 1, showMonthLabels: b = !0, showDayLabels: x = !0, showLegend: se = !0, weeks: ce = 52, ariaLabel: S = "Contribution graph", onDayClick: C, tooltipContent: le, className: ue }) {
44
+ let w = n({ month: "short" }), T = n({ weekday: "short" }), E = n({
33
45
  weekday: "long",
34
46
  year: "numeric",
35
47
  month: "long",
36
48
  day: "numeric"
37
- }), j = _ + v, M = r(null), N = r(null), P = g ?? f, [F, I] = i({
49
+ }), { accentColor: D } = r(t), O = re.has(D) ? D : "green", k = o(null), A = o(null), j = o(null), M = a(() => ie(O), [O]), [N, de] = s(null), [P, F] = s({
38
50
  col: 0,
39
51
  row: 0
40
- }), [L, R] = i(null), z = n(() => {
52
+ }), [I, L] = s(null), [R, z] = s(null);
53
+ i(() => {
54
+ if (!v) return;
55
+ let e = A.current;
56
+ if (!e) return;
57
+ let t = () => {
58
+ let t = e.clientWidth || e.getBoundingClientRect().width;
59
+ t > 0 && de(t);
60
+ };
61
+ if (t(), typeof ResizeObserver > "u") return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
62
+ let n = new ResizeObserver(t);
63
+ return n.observe(e), () => n.disconnect();
64
+ }, [v]), i(() => {
65
+ if (!I) return;
66
+ let e = () => {
67
+ let e = j.current;
68
+ if (!e) return;
69
+ let t = I.target.getBoundingClientRect(), n = e.getBoundingClientRect(), r = document.documentElement.clientWidth || window.innerWidth, i = document.documentElement.clientHeight || window.innerHeight, a = Math.max(8, r - n.width - 8), o = Math.max(8, i - n.height - 8), s = t.left + t.width / 2 - n.width / 2, c = t.top - n.height - 6, l = c >= 8 ? c : t.bottom + 6;
70
+ z({
71
+ left: Math.max(8, Math.min(s, a)),
72
+ top: Math.max(8, Math.min(l, o))
73
+ });
74
+ };
75
+ return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, {
76
+ passive: !0,
77
+ capture: !0
78
+ }), () => {
79
+ window.removeEventListener("resize", e), window.removeEventListener("scroll", e, { capture: !0 });
80
+ };
81
+ }, [I]);
82
+ let B = a(() => {
41
83
  let e = /* @__PURE__ */ new Map();
42
- for (let t of s) e.set(t.date, t.count);
84
+ for (let t of d) e.set(t.date, t.count);
43
85
  return e;
44
- }, [s]), B = n(() => Math.max(1, ...s.map((e) => e.count)), [s]), { grid: V, monthLabels: H } = n(() => {
86
+ }, [d]), V = a(() => Math.max(1, ...d.map((e) => e.count)), [d]), H = x ? te : 0, U = b ? ne : 0, W = Math.max(1, Math.floor(ce)), G = Math.max(1, ae), K = Math.max(G, oe), q = a(() => {
87
+ if (!v || N === null) return {
88
+ cellSize: g,
89
+ weeks: W
90
+ };
91
+ let e = Math.max(0, N - H), t = (e + _) / W - _;
92
+ if (t >= G) return {
93
+ cellSize: Math.min(K, t),
94
+ weeks: W
95
+ };
96
+ let n = Math.floor((e + _) / (G + _));
97
+ return {
98
+ cellSize: G,
99
+ weeks: Math.max(1, Math.min(W, n))
100
+ };
101
+ }, [
102
+ N,
103
+ _,
104
+ g,
105
+ W,
106
+ H,
107
+ K,
108
+ G,
109
+ v
110
+ ]), J = q.weeks, Y = q.cellSize, X = Y + _, { grid: Z, monthLabels: fe } = a(() => {
45
111
  let e = /* @__PURE__ */ new Date();
46
112
  e.setHours(0, 0, 0, 0);
47
113
  let t = (e.getDay() - y + 7) % 7, n = new Date(e);
48
114
  n.setDate(e.getDate() - t);
49
115
  let r = new Date(n);
50
- r.setDate(n.getDate() - (C - 1) * 7);
116
+ r.setDate(n.getDate() - (J - 1) * 7);
51
117
  let i = [], a = [], o = -1;
52
- for (let t = 0; t < C; t++) {
118
+ for (let t = 0; t < J; t++) {
53
119
  let n = new Date(r);
54
120
  n.setDate(r.getDate() + t * 7), n.getMonth() !== o && (a.push({
55
121
  col: t,
56
- month: c(n.getMonth(), O)
122
+ month: f(n.getMonth(), w)
57
123
  }), o = n.getMonth());
58
124
  let s = [];
59
125
  for (let n = 0; n < 7; n++) {
60
126
  let i = new Date(r);
61
127
  i.setDate(r.getDate() + t * 7 + n);
62
- let a = i > e, o = p(i), c = a ? 0 : z.get(o) ?? 0, l = c === 0 ? 0 : Math.min(m, Math.ceil(c / B * m));
128
+ let a = i > e, o = p(i), c = a ? 0 : B.get(o) ?? 0, l = c === 0 ? 0 : Math.min(m, Math.ceil(c / V * m));
63
129
  s.push({
64
130
  iso: o,
65
131
  count: c,
@@ -74,157 +140,172 @@ function g({ data: s, maxLevel: m = 4, colorScale: g, cellSize: _ = 12, cellGap:
74
140
  monthLabels: a
75
141
  };
76
142
  }, [
77
- z,
78
143
  B,
144
+ V,
79
145
  m,
80
- C,
146
+ J,
81
147
  y,
82
- O
83
- ]), U = n(() => [
148
+ w
149
+ ]), pe = a(() => [
84
150
  1,
85
151
  3,
86
152
  5
87
153
  ].map((e) => ({
88
154
  row: (e - y + 7) % 7,
89
- label: l(e, k)
90
- })), [y, k]), W = x ? u : 0, G = b ? d : 0, K = W + C * j - v, q = G + 7 * j - v, J = Math.min(4, Math.floor(_ / 3));
91
- function Y(e, t) {
92
- let n = Math.max(0, Math.min(C - 1, e)), r = Math.max(0, Math.min(6, t));
93
- I({
155
+ label: ee(e, T)
156
+ })), [y, T]), Q = H + J * X - _, me = U + 7 * X - _, $ = Math.min(4, Math.floor(Y / 3));
157
+ i(() => {
158
+ F((e) => ({
159
+ col: Math.min(J - 1, e.col),
160
+ row: e.row
161
+ }));
162
+ }, [J]);
163
+ function he(e, t) {
164
+ let n = Math.max(0, Math.min(J - 1, e)), r = Math.max(0, Math.min(6, t));
165
+ F({
94
166
  col: n,
95
167
  row: r
96
- }), M.current?.querySelector(`[data-col="${n}"][data-row="${r}"]`)?.focus();
168
+ }), k.current?.querySelector(`[data-col="${n}"][data-row="${r}"]`)?.focus();
97
169
  }
98
- function X(e, t, n) {
170
+ function ge(e, t, n) {
99
171
  let r = {
100
172
  ArrowRight: [t + 1, n],
101
173
  ArrowLeft: [t - 1, n],
102
174
  ArrowDown: [t, n + 1],
103
175
  ArrowUp: [t, n - 1]
104
176
  };
105
- if (r[e.key]) e.preventDefault(), Y(...r[e.key]);
177
+ if (r[e.key]) e.preventDefault(), he(...r[e.key]);
106
178
  else if (e.key === "Enter" || e.key === " ") {
107
179
  e.preventDefault();
108
- let r = V[t]?.[n];
109
- r && !r.future && T?.({
180
+ let r = Z[t]?.[n];
181
+ r && !r.future && C?.({
110
182
  date: r.iso,
111
183
  count: r.count
112
184
  });
113
185
  }
114
186
  }
115
- function Z(e, t) {
116
- let n = N.current;
117
- if (!n) return;
118
- let r = n.getBoundingClientRect(), i = e.currentTarget.getBoundingClientRect();
119
- R({
120
- x: i.left - r.left + _ / 2,
121
- y: i.top - r.top,
187
+ function _e(e, t) {
188
+ z(null), L({
189
+ target: e.currentTarget,
122
190
  text: t
123
191
  });
124
192
  }
125
- function Q(e) {
126
- return e.future ? P[0] : P[Math.min(e.level, P.length - 1)] ?? P[P.length - 1];
193
+ function ve() {
194
+ L(null), z(null);
127
195
  }
128
- function $(e) {
129
- if (e.future) return h(e.iso, A);
130
- let t = h(e.iso, A);
131
- return E?.({
196
+ function ye(e) {
197
+ return e.future ? M[0] : M[Math.min(e.level, M.length - 1)] ?? M[M.length - 1];
198
+ }
199
+ function be(e) {
200
+ if (e.future) return h(e.iso, E);
201
+ let t = h(e.iso, E);
202
+ return le?.({
132
203
  date: e.iso,
133
204
  count: e.count
134
205
  }) ?? `${e.count} contribution${e.count === 1 ? "" : "s"} on ${t}`;
135
206
  }
136
- return /* @__PURE__ */ o("div", {
137
- ref: N,
138
- className: [e.wrapper, D].filter(Boolean).join(" "),
207
+ return /* @__PURE__ */ u("div", {
208
+ className: [e.wrapper, ue].filter(Boolean).join(" "),
139
209
  children: [
140
- /* @__PURE__ */ o("svg", {
141
- ref: M,
142
- width: K,
143
- height: q,
144
- className: e.svg,
145
- "aria-label": w,
146
- role: "img",
147
- children: [
148
- b && H.map(({ col: t, month: n }) => /* @__PURE__ */ a("text", {
149
- x: W + t * j,
150
- y: 12,
151
- className: e.label,
152
- children: n
153
- }, `m-${t}`)),
154
- x && U.map(({ row: t, label: n }) => /* @__PURE__ */ a("text", {
155
- x: 0,
156
- y: G + t * j + _ - 1,
157
- className: e.label,
158
- children: n
159
- }, `d-${t}`)),
160
- /* @__PURE__ */ a("g", {
161
- role: "grid",
162
- "aria-label": w,
163
- children: V.map((t, n) => /* @__PURE__ */ a("g", {
164
- role: "row",
165
- children: t.map((t, r) => {
166
- let i = $(t), o = F.col === n && F.row === r;
167
- return /* @__PURE__ */ a("rect", {
168
- "data-col": n,
169
- "data-row": r,
170
- x: W + n * j,
171
- y: G + r * j,
172
- width: _,
173
- height: _,
174
- rx: J,
175
- fill: Q(t),
176
- opacity: t.future ? .35 : 1,
177
- className: e.cell,
178
- role: "gridcell",
179
- "aria-label": i,
180
- "aria-disabled": t.future || void 0,
181
- tabIndex: o ? 0 : -1,
182
- onClick: () => !t.future && T?.({
183
- date: t.iso,
184
- count: t.count
185
- }),
186
- onKeyDown: (e) => X(e, n, r),
187
- onFocus: () => I({
188
- col: n,
189
- row: r
190
- }),
191
- onMouseEnter: (e) => Z(e, i),
192
- onMouseLeave: () => R(null)
193
- }, `${n}-${r}`);
194
- })
195
- }, n))
196
- })
197
- ]
210
+ /* @__PURE__ */ l("div", {
211
+ ref: A,
212
+ className: e.graphViewport,
213
+ children: /* @__PURE__ */ u("svg", {
214
+ ref: k,
215
+ width: Q,
216
+ height: me,
217
+ className: e.svg,
218
+ "aria-label": S,
219
+ role: "img",
220
+ "data-cell-size": Y,
221
+ "data-visible-weeks": J,
222
+ children: [
223
+ b && fe.map(({ col: t, month: n }) => /* @__PURE__ */ l("text", {
224
+ x: H + t * X,
225
+ y: 12,
226
+ className: e.label,
227
+ children: n
228
+ }, `m-${t}`)),
229
+ x && pe.map(({ row: t, label: n }) => /* @__PURE__ */ l("text", {
230
+ x: 0,
231
+ y: U + t * X + Y - 1,
232
+ className: e.label,
233
+ children: n
234
+ }, `d-${t}`)),
235
+ /* @__PURE__ */ l("g", {
236
+ role: "grid",
237
+ "aria-label": S,
238
+ children: Z.map((t, n) => /* @__PURE__ */ l("g", {
239
+ role: "row",
240
+ children: t.map((t, r) => {
241
+ let i = be(t), a = P.col === n && P.row === r;
242
+ return /* @__PURE__ */ l("rect", {
243
+ "data-col": n,
244
+ "data-row": r,
245
+ x: H + n * X,
246
+ y: U + r * X,
247
+ width: Y,
248
+ height: Y,
249
+ rx: $,
250
+ fill: ye(t),
251
+ opacity: t.future ? .35 : 1,
252
+ className: e.cell,
253
+ role: "gridcell",
254
+ "aria-label": i,
255
+ "aria-disabled": t.future || void 0,
256
+ tabIndex: a ? 0 : -1,
257
+ onClick: () => !t.future && C?.({
258
+ date: t.iso,
259
+ count: t.count
260
+ }),
261
+ onKeyDown: (e) => ge(e, n, r),
262
+ onFocus: () => F({
263
+ col: n,
264
+ row: r
265
+ }),
266
+ onMouseEnter: (e) => _e(e, i),
267
+ onMouseLeave: ve
268
+ }, `${n}-${r}`);
269
+ })
270
+ }, n))
271
+ })
272
+ ]
273
+ })
198
274
  }),
199
- L && /* @__PURE__ */ a("div", {
275
+ I && typeof document < "u" && c(/* @__PURE__ */ l("div", {
276
+ ref: j,
200
277
  className: e.tooltip,
201
- style: {
202
- left: L.x,
203
- top: L.y
278
+ style: R ? {
279
+ left: R.left,
280
+ top: R.top
281
+ } : {
282
+ visibility: "hidden",
283
+ left: 0,
284
+ top: 0
204
285
  },
205
286
  role: "tooltip",
206
- children: L.text
207
- }),
208
- S && /* @__PURE__ */ o("div", {
287
+ children: I.text
288
+ }), document.body),
289
+ se && /* @__PURE__ */ u("div", {
209
290
  className: e.legend,
210
291
  children: [
211
- /* @__PURE__ */ a("span", {
292
+ /* @__PURE__ */ l("span", {
212
293
  className: e.legendLabel,
213
294
  children: "Less"
214
295
  }),
215
- Array.from({ length: m + 1 }, (t, n) => /* @__PURE__ */ a("svg", {
216
- width: _,
217
- height: _,
296
+ Array.from({ length: m + 1 }, (t, n) => /* @__PURE__ */ l("svg", {
297
+ width: Y,
298
+ height: Y,
218
299
  "aria-hidden": "true",
219
300
  className: e.legendCell,
220
- children: /* @__PURE__ */ a("rect", {
221
- width: _,
222
- height: _,
223
- rx: J,
224
- fill: P[Math.min(n, P.length - 1)]
301
+ children: /* @__PURE__ */ l("rect", {
302
+ width: Y,
303
+ height: Y,
304
+ rx: $,
305
+ fill: M[Math.min(n, M.length - 1)]
225
306
  })
226
307
  }, n)),
227
- /* @__PURE__ */ a("span", {
308
+ /* @__PURE__ */ l("span", {
228
309
  className: e.legendLabel,
229
310
  children: "More"
230
311
  })
@@ -1 +1 @@
1
- {"version":3,"file":"ContributionGraph.js","names":[],"sources":["../../../src/components/ContributionGraph/ContributionGraph.tsx"],"sourcesContent":["import { useMemo, useRef, useState } from \"react\";\nimport type { KeyboardEvent } from \"react\";\nimport styles from \"./ContributionGraph.module.css\";\nimport { useDateTimeFormatter } from \"../GnomeProvider/GnomeContext\";\n\nexport interface ContributionDay {\n /** ISO 8601 date — \"YYYY-MM-DD\". */\n date: string;\n /** Non-negative activity count. */\n count: number;\n}\n\nexport interface ContributionGraphProps {\n /** Activity data. Days absent from the array are treated as count = 0. */\n data: ContributionDay[];\n /**\n * Number of intensity levels (excluding 0).\n * @default 4\n */\n maxLevel?: number;\n /**\n * Colour scale — length must be maxLevel + 1 (index 0 = empty).\n * Defaults to the Adwaita green palette.\n */\n colorScale?: string[];\n /** Cell side length in pixels. @default 12 */\n cellSize?: number;\n /** Gap between cells in pixels. @default 3 */\n cellGap?: number;\n /** 0 = Sunday · 1 = Monday (GNOME locale default). @default 1 */\n weekStartDay?: 0 | 1;\n /** @default true */\n showMonthLabels?: boolean;\n /** @default true */\n showDayLabels?: boolean;\n /** @default true */\n showLegend?: boolean;\n /** Number of week columns to display. @default 52 */\n weeks?: number;\n /** @default \"Contribution graph\" */\n ariaLabel?: string;\n onDayClick?: (day: ContributionDay) => void;\n /** Returns a plain-text tooltip string for a day. */\n tooltipContent?: (day: ContributionDay) => string;\n className?: string;\n}\n\n// Reference Sunday: 2000-01-02 is a Sunday (day index 0)\nconst REF_SUNDAY = new Date(2000, 0, 2);\n\nfunction getShortMonth(\n monthIndex: number,\n formatter: Intl.DateTimeFormat,\n): string {\n return formatter.format(new Date(2000, monthIndex));\n}\n\nfunction getShortDay(\n dayIndex: number,\n formatter: Intl.DateTimeFormat,\n): string {\n const date = new Date(REF_SUNDAY);\n date.setDate(REF_SUNDAY.getDate() + dayIndex);\n return formatter.format(date);\n}\n\nconst DAY_LABEL_WIDTH = 28;\nconst MONTH_LABEL_HEIGHT = 20;\n\nconst DEFAULT_COLORS = [\n \"var(--gnome-card-shade-color, rgba(0,0,0,0.07))\",\n \"var(--gnome-green-1, #8ff0a4)\",\n \"var(--gnome-green-2, #57e389)\",\n \"var(--gnome-green-4, #2ec27e)\",\n \"var(--gnome-green-5, #26a269)\",\n];\n\nfunction dateToIso(date: Date): string {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction isoToLocal(iso: string): Date {\n const [y, m, d] = iso.split(\"-\").map(Number);\n return new Date(y, m - 1, d);\n}\n\nfunction fullDateLabel(iso: string, formatter: Intl.DateTimeFormat): string {\n return formatter.format(isoToLocal(iso));\n}\n\ninterface GridCell {\n iso: string;\n count: number;\n level: number;\n future: boolean;\n}\n\nexport function ContributionGraph({\n data,\n maxLevel = 4,\n colorScale,\n cellSize = 12,\n cellGap = 3,\n weekStartDay = 1,\n showMonthLabels = true,\n showDayLabels = true,\n showLegend = true,\n weeks = 52,\n ariaLabel = \"Contribution graph\",\n onDayClick,\n tooltipContent,\n className,\n}: ContributionGraphProps) {\n const monthFormatter = useDateTimeFormatter({ month: \"short\" });\n const weekdayFormatter = useDateTimeFormatter({ weekday: \"short\" });\n const fullDateFormatter = useDateTimeFormatter({\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n });\n const stride = cellSize + cellGap;\n const svgRef = useRef<SVGSVGElement>(null);\n const wrapperRef = useRef<HTMLDivElement>(null);\n const colors = colorScale ?? DEFAULT_COLORS;\n\n const [focusedCell, setFocusedCell] = useState({ col: 0, row: 0 });\n const [tooltip, setTooltip] = useState<{\n x: number;\n y: number;\n text: string;\n } | null>(null);\n\n const countMap = useMemo(() => {\n const map = new Map<string, number>();\n for (const d of data) map.set(d.date, d.count);\n return map;\n }, [data]);\n\n const maxCount = useMemo(\n () => Math.max(1, ...data.map((d) => d.count)),\n [data],\n );\n\n const { grid, monthLabels } = useMemo(() => {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n\n // Align to start of current week\n const daysFromWeekStart = (today.getDay() - weekStartDay + 7) % 7;\n const lastWeekStart = new Date(today);\n lastWeekStart.setDate(today.getDate() - daysFromWeekStart);\n\n const firstDay = new Date(lastWeekStart);\n firstDay.setDate(lastWeekStart.getDate() - (weeks - 1) * 7);\n\n const gridResult: GridCell[][] = [];\n const labels: { col: number; month: string }[] = [];\n let lastMonth = -1;\n\n for (let col = 0; col < weeks; col++) {\n const colStart = new Date(firstDay);\n colStart.setDate(firstDay.getDate() + col * 7);\n\n // Month label when the column starts a new month\n if (colStart.getMonth() !== lastMonth) {\n labels.push({\n col,\n month: getShortMonth(colStart.getMonth(), monthFormatter),\n });\n lastMonth = colStart.getMonth();\n }\n\n const column: GridCell[] = [];\n for (let row = 0; row < 7; row++) {\n const date = new Date(firstDay);\n date.setDate(firstDay.getDate() + col * 7 + row);\n const future = date > today;\n const iso = dateToIso(date);\n const count = future ? 0 : (countMap.get(iso) ?? 0);\n const level =\n count === 0\n ? 0\n : Math.min(maxLevel, Math.ceil((count / maxCount) * maxLevel));\n column.push({ iso, count, level, future });\n }\n gridResult.push(column);\n }\n\n return { grid: gridResult, monthLabels: labels };\n }, [countMap, maxCount, maxLevel, weeks, weekStartDay, monthFormatter]);\n\n // Always label Mon(1), Wed(3), Fri(5) — rows shift with weekStartDay\n const labelRows = useMemo(\n () =>\n [1, 3, 5].map((dayIndex) => ({\n row: (dayIndex - weekStartDay + 7) % 7,\n label: getShortDay(dayIndex, weekdayFormatter),\n })),\n [weekStartDay, weekdayFormatter],\n );\n\n const dayLabelW = showDayLabels ? DAY_LABEL_WIDTH : 0;\n const monthLabelH = showMonthLabels ? MONTH_LABEL_HEIGHT : 0;\n const svgWidth = dayLabelW + weeks * stride - cellGap;\n const svgHeight = monthLabelH + 7 * stride - cellGap;\n const cellRx = Math.min(4, Math.floor(cellSize / 3));\n\n function focusCell(col: number, row: number) {\n const c = Math.max(0, Math.min(weeks - 1, col));\n const r = Math.max(0, Math.min(6, row));\n setFocusedCell({ col: c, row: r });\n svgRef.current\n ?.querySelector<SVGRectElement>(`[data-col=\"${c}\"][data-row=\"${r}\"]`)\n ?.focus();\n }\n\n function handleCellKey(e: KeyboardEvent, col: number, row: number) {\n const moves: Record<string, [number, number]> = {\n ArrowRight: [col + 1, row],\n ArrowLeft: [col - 1, row],\n ArrowDown: [col, row + 1],\n ArrowUp: [col, row - 1],\n };\n if (moves[e.key]) {\n e.preventDefault();\n focusCell(...moves[e.key]);\n } else if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const cell = grid[col]?.[row];\n if (cell && !cell.future) onDayClick?.({ date: cell.iso, count: cell.count });\n }\n }\n\n function handleMouseEnter(\n e: React.MouseEvent<SVGRectElement>,\n text: string,\n ) {\n const wrapper = wrapperRef.current;\n if (!wrapper) return;\n const wRect = wrapper.getBoundingClientRect();\n const rRect = (e.currentTarget as Element).getBoundingClientRect();\n setTooltip({\n x: rRect.left - wRect.left + cellSize / 2,\n y: rRect.top - wRect.top,\n text,\n });\n }\n\n function cellColor(cell: GridCell): string {\n if (cell.future) return colors[0];\n return colors[Math.min(cell.level, colors.length - 1)] ?? colors[colors.length - 1];\n }\n\n function cellTooltip(cell: GridCell): string {\n if (cell.future) return fullDateLabel(cell.iso, fullDateFormatter);\n const formattedDate = fullDateLabel(cell.iso, fullDateFormatter);\n return (\n tooltipContent?.({ date: cell.iso, count: cell.count }) ??\n `${cell.count} contribution${cell.count !== 1 ? \"s\" : \"\"} on ${formattedDate}`\n );\n }\n\n return (\n <div\n ref={wrapperRef}\n className={[styles.wrapper, className].filter(Boolean).join(\" \")}\n >\n <svg\n ref={svgRef}\n width={svgWidth}\n height={svgHeight}\n className={styles.svg}\n aria-label={ariaLabel}\n role=\"img\"\n >\n {/* Month labels */}\n {showMonthLabels &&\n monthLabels.map(({ col, month }) => (\n <text\n key={`m-${col}`}\n x={dayLabelW + col * stride}\n y={12}\n className={styles.label}\n >\n {month}\n </text>\n ))}\n\n {/* Day-of-week labels: Mon, Wed, Fri */}\n {showDayLabels &&\n labelRows.map(({ row, label }) => (\n <text\n key={`d-${row}`}\n x={0}\n y={monthLabelH + row * stride + cellSize - 1}\n className={styles.label}\n >\n {label}\n </text>\n ))}\n\n {/* Activity grid */}\n <g role=\"grid\" aria-label={ariaLabel}>\n {grid.map((column, col) => (\n <g key={col} role=\"row\">\n {column.map((cell, row) => {\n const tipText = cellTooltip(cell);\n const isFocused =\n focusedCell.col === col && focusedCell.row === row;\n\n return (\n <rect\n key={`${col}-${row}`}\n data-col={col}\n data-row={row}\n x={dayLabelW + col * stride}\n y={monthLabelH + row * stride}\n width={cellSize}\n height={cellSize}\n rx={cellRx}\n fill={cellColor(cell)}\n opacity={cell.future ? 0.35 : 1}\n className={styles.cell}\n role=\"gridcell\"\n aria-label={tipText}\n aria-disabled={cell.future || undefined}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => !cell.future && onDayClick?.({ date: cell.iso, count: cell.count })}\n onKeyDown={(e) => handleCellKey(e, col, row)}\n onFocus={() => setFocusedCell({ col, row })}\n onMouseEnter={(e) => handleMouseEnter(e, tipText)}\n onMouseLeave={() => setTooltip(null)}\n />\n );\n })}\n </g>\n ))}\n </g>\n </svg>\n\n {tooltip && (\n <div\n className={styles.tooltip}\n style={{ left: tooltip.x, top: tooltip.y }}\n role=\"tooltip\"\n >\n {tooltip.text}\n </div>\n )}\n\n {showLegend && (\n <div className={styles.legend}>\n <span className={styles.legendLabel}>Less</span>\n {Array.from({ length: maxLevel + 1 }, (_, i) => (\n <svg\n key={i}\n width={cellSize}\n height={cellSize}\n aria-hidden=\"true\"\n className={styles.legendCell}\n >\n <rect\n width={cellSize}\n height={cellSize}\n rx={cellRx}\n fill={colors[Math.min(i, colors.length - 1)]}\n />\n </svg>\n ))}\n <span className={styles.legendLabel}>More</span>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;AAgDA,IAAM,IAAa,IAAI,KA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ElB,kBAAC,QAAD;OACE,OAAO;OACP,QAAQ;OACR,IAAI;OACJ,MAAM,EAAO,KAAK,IAAI,GAAG,EAAO,SAAS,EAAE;OAC3C,CAAA;MACE,EAZC,EAYD,CACN;KACF,kBAAC,QAAD;MAAM,WAAW,EAAO;gBAAa;MAAW,CAAA;KAC5C;;GAEJ"}
1
+ {"version":3,"file":"ContributionGraph.js","names":[],"sources":["../../../src/components/ContributionGraph/ContributionGraph.tsx"],"sourcesContent":["import { useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { KeyboardEvent } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport styles from \"./ContributionGraph.module.css\";\nimport {\n GnomeContext,\n useDateTimeFormatter,\n type GnomeNamedAccentColor,\n} from \"../GnomeProvider/GnomeContext\";\n\nexport interface ContributionDay {\n /** ISO 8601 date — \"YYYY-MM-DD\". */\n date: string;\n /** Non-negative activity count. */\n count: number;\n}\n\nexport interface ContributionGraphProps {\n /** Activity data. Days absent from the array are treated as count = 0. */\n data: ContributionDay[];\n /**\n * Number of intensity levels (excluding 0).\n * @default 4\n */\n maxLevel?: number;\n /** Cell side length in pixels. @default 12 */\n cellSize?: number;\n /** Gap between cells in pixels. @default 3 */\n cellGap?: number;\n /**\n * Fit the graph to its container by resizing cells and reducing visible\n * weeks when the configured range cannot stay legible.\n * @default true\n */\n responsive?: boolean;\n /** Smallest responsive cell side length in pixels. @default 8 */\n minCellSize?: number;\n /** Largest responsive cell side length in pixels. @default 24 */\n maxCellSize?: number;\n /** 0 = Sunday · 1 = Monday (GNOME locale default). @default 1 */\n weekStartDay?: 0 | 1;\n /** @default true */\n showMonthLabels?: boolean;\n /** @default true */\n showDayLabels?: boolean;\n /** @default true */\n showLegend?: boolean;\n /** Number of week columns to display. @default 52 */\n weeks?: number;\n /** @default \"Contribution graph\" */\n ariaLabel?: string;\n onDayClick?: (day: ContributionDay) => void;\n /** Returns a plain-text tooltip string for a day. */\n tooltipContent?: (day: ContributionDay) => string;\n className?: string;\n}\n\n// Reference Sunday: 2000-01-02 is a Sunday (day index 0)\nconst REF_SUNDAY = new Date(2000, 0, 2);\n\nfunction getShortMonth(\n monthIndex: number,\n formatter: Intl.DateTimeFormat,\n): string {\n return formatter.format(new Date(2000, monthIndex));\n}\n\nfunction getShortDay(\n dayIndex: number,\n formatter: Intl.DateTimeFormat,\n): string {\n const date = new Date(REF_SUNDAY);\n date.setDate(REF_SUNDAY.getDate() + dayIndex);\n return formatter.format(date);\n}\n\nconst DAY_LABEL_WIDTH = 28;\nconst MONTH_LABEL_HEIGHT = 20;\n\nconst NAMED_ACCENTS = new Set<GnomeNamedAccentColor>([\n \"blue\",\n \"green\",\n \"yellow\",\n \"orange\",\n \"red\",\n \"purple\",\n \"brown\",\n]);\n\nfunction accentScale(accentColor: GnomeNamedAccentColor): string[] {\n return [\n \"var(--gnome-card-shade-color)\",\n `var(--gnome-${accentColor}-1)`,\n `var(--gnome-${accentColor}-2)`,\n `var(--gnome-${accentColor}-4)`,\n `var(--gnome-${accentColor}-5)`,\n ];\n}\n\nfunction dateToIso(date: Date): string {\n const y = date.getFullYear();\n const m = String(date.getMonth() + 1).padStart(2, \"0\");\n const d = String(date.getDate()).padStart(2, \"0\");\n return `${y}-${m}-${d}`;\n}\n\nfunction isoToLocal(iso: string): Date {\n const [y, m, d] = iso.split(\"-\").map(Number);\n return new Date(y, m - 1, d);\n}\n\nfunction fullDateLabel(iso: string, formatter: Intl.DateTimeFormat): string {\n return formatter.format(isoToLocal(iso));\n}\n\ninterface GridCell {\n iso: string;\n count: number;\n level: number;\n future: boolean;\n}\n\nexport function ContributionGraph({\n data,\n maxLevel = 4,\n cellSize = 12,\n cellGap = 3,\n responsive = true,\n minCellSize = 8,\n maxCellSize = 24,\n weekStartDay = 1,\n showMonthLabels = true,\n showDayLabels = true,\n showLegend = true,\n weeks = 52,\n ariaLabel = \"Contribution graph\",\n onDayClick,\n tooltipContent,\n className,\n}: ContributionGraphProps) {\n const monthFormatter = useDateTimeFormatter({ month: \"short\" });\n const weekdayFormatter = useDateTimeFormatter({ weekday: \"short\" });\n const fullDateFormatter = useDateTimeFormatter({\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n });\n const { accentColor } = useContext(GnomeContext);\n const graphAccent = NAMED_ACCENTS.has(accentColor as GnomeNamedAccentColor)\n ? accentColor as GnomeNamedAccentColor\n : \"green\";\n const svgRef = useRef<SVGSVGElement>(null);\n const graphViewportRef = useRef<HTMLDivElement>(null);\n const tooltipRef = useRef<HTMLDivElement>(null);\n const colors = useMemo(() => accentScale(graphAccent), [graphAccent]);\n\n const [availableWidth, setAvailableWidth] = useState<number | null>(null);\n const [focusedCell, setFocusedCell] = useState({ col: 0, row: 0 });\n const [tooltip, setTooltip] = useState<{\n target: SVGRectElement;\n text: string;\n } | null>(null);\n const [tooltipPosition, setTooltipPosition] = useState<{\n left: number;\n top: number;\n } | null>(null);\n\n useEffect(() => {\n if (!responsive) return;\n\n const viewport = graphViewportRef.current;\n if (!viewport) return;\n\n const updateWidth = () => {\n const width = viewport.clientWidth || viewport.getBoundingClientRect().width;\n if (width > 0) setAvailableWidth(width);\n };\n\n updateWidth();\n\n if (typeof ResizeObserver === \"undefined\") {\n window.addEventListener(\"resize\", updateWidth);\n return () => window.removeEventListener(\"resize\", updateWidth);\n }\n\n const observer = new ResizeObserver(updateWidth);\n observer.observe(viewport);\n return () => observer.disconnect();\n }, [responsive]);\n\n useEffect(() => {\n if (!tooltip) return;\n\n const placeTooltip = () => {\n const tooltipNode = tooltipRef.current;\n if (!tooltipNode) return;\n\n const cellRect = tooltip.target.getBoundingClientRect();\n const tipRect = tooltipNode.getBoundingClientRect();\n const margin = 8;\n const gap = 6;\n const viewportWidth = document.documentElement.clientWidth || window.innerWidth;\n const viewportHeight = document.documentElement.clientHeight || window.innerHeight;\n const maxLeft = Math.max(margin, viewportWidth - tipRect.width - margin);\n const maxTop = Math.max(margin, viewportHeight - tipRect.height - margin);\n const centeredLeft = cellRect.left + cellRect.width / 2 - tipRect.width / 2;\n const aboveTop = cellRect.top - tipRect.height - gap;\n const preferredTop = aboveTop >= margin ? aboveTop : cellRect.bottom + gap;\n\n setTooltipPosition({\n left: Math.max(margin, Math.min(centeredLeft, maxLeft)),\n top: Math.max(margin, Math.min(preferredTop, maxTop)),\n });\n };\n\n placeTooltip();\n window.addEventListener(\"resize\", placeTooltip);\n window.addEventListener(\"scroll\", placeTooltip, { passive: true, capture: true });\n\n return () => {\n window.removeEventListener(\"resize\", placeTooltip);\n window.removeEventListener(\"scroll\", placeTooltip, { capture: true });\n };\n }, [tooltip]);\n\n const countMap = useMemo(() => {\n const map = new Map<string, number>();\n for (const d of data) map.set(d.date, d.count);\n return map;\n }, [data]);\n\n const maxCount = useMemo(\n () => Math.max(1, ...data.map((d) => d.count)),\n [data],\n );\n\n const dayLabelW = showDayLabels ? DAY_LABEL_WIDTH : 0;\n const monthLabelH = showMonthLabels ? MONTH_LABEL_HEIGHT : 0;\n const configuredWeeks = Math.max(1, Math.floor(weeks));\n const normalizedMinCellSize = Math.max(1, minCellSize);\n const normalizedMaxCellSize = Math.max(normalizedMinCellSize, maxCellSize);\n const fit = useMemo(() => {\n if (!responsive || availableWidth === null) {\n return { cellSize, weeks: configuredWeeks };\n }\n\n const gridWidth = Math.max(0, availableWidth - dayLabelW);\n const fittedCellSize = (gridWidth + cellGap) / configuredWeeks - cellGap;\n\n if (fittedCellSize >= normalizedMinCellSize) {\n return {\n cellSize: Math.min(normalizedMaxCellSize, fittedCellSize),\n weeks: configuredWeeks,\n };\n }\n\n const fittedWeeks = Math.floor((gridWidth + cellGap) / (normalizedMinCellSize + cellGap));\n return {\n cellSize: normalizedMinCellSize,\n weeks: Math.max(1, Math.min(configuredWeeks, fittedWeeks)),\n };\n }, [\n availableWidth,\n cellGap,\n cellSize,\n configuredWeeks,\n dayLabelW,\n normalizedMaxCellSize,\n normalizedMinCellSize,\n responsive,\n ]);\n const visibleWeeks = fit.weeks;\n const resolvedCellSize = fit.cellSize;\n const stride = resolvedCellSize + cellGap;\n\n const { grid, monthLabels } = useMemo(() => {\n const today = new Date();\n today.setHours(0, 0, 0, 0);\n\n // Align to start of current week\n const daysFromWeekStart = (today.getDay() - weekStartDay + 7) % 7;\n const lastWeekStart = new Date(today);\n lastWeekStart.setDate(today.getDate() - daysFromWeekStart);\n\n const firstDay = new Date(lastWeekStart);\n firstDay.setDate(lastWeekStart.getDate() - (visibleWeeks - 1) * 7);\n\n const gridResult: GridCell[][] = [];\n const labels: { col: number; month: string }[] = [];\n let lastMonth = -1;\n\n for (let col = 0; col < visibleWeeks; col++) {\n const colStart = new Date(firstDay);\n colStart.setDate(firstDay.getDate() + col * 7);\n\n // Month label when the column starts a new month\n if (colStart.getMonth() !== lastMonth) {\n labels.push({\n col,\n month: getShortMonth(colStart.getMonth(), monthFormatter),\n });\n lastMonth = colStart.getMonth();\n }\n\n const column: GridCell[] = [];\n for (let row = 0; row < 7; row++) {\n const date = new Date(firstDay);\n date.setDate(firstDay.getDate() + col * 7 + row);\n const future = date > today;\n const iso = dateToIso(date);\n const count = future ? 0 : (countMap.get(iso) ?? 0);\n const level =\n count === 0\n ? 0\n : Math.min(maxLevel, Math.ceil((count / maxCount) * maxLevel));\n column.push({ iso, count, level, future });\n }\n gridResult.push(column);\n }\n\n return { grid: gridResult, monthLabels: labels };\n }, [countMap, maxCount, maxLevel, visibleWeeks, weekStartDay, monthFormatter]);\n\n // Always label Mon(1), Wed(3), Fri(5) — rows shift with weekStartDay\n const labelRows = useMemo(\n () =>\n [1, 3, 5].map((dayIndex) => ({\n row: (dayIndex - weekStartDay + 7) % 7,\n label: getShortDay(dayIndex, weekdayFormatter),\n })),\n [weekStartDay, weekdayFormatter],\n );\n\n const svgWidth = dayLabelW + visibleWeeks * stride - cellGap;\n const svgHeight = monthLabelH + 7 * stride - cellGap;\n const cellRx = Math.min(4, Math.floor(resolvedCellSize / 3));\n\n useEffect(() => {\n setFocusedCell((current) => ({\n col: Math.min(visibleWeeks - 1, current.col),\n row: current.row,\n }));\n }, [visibleWeeks]);\n\n function focusCell(col: number, row: number) {\n const c = Math.max(0, Math.min(visibleWeeks - 1, col));\n const r = Math.max(0, Math.min(6, row));\n setFocusedCell({ col: c, row: r });\n svgRef.current\n ?.querySelector<SVGRectElement>(`[data-col=\"${c}\"][data-row=\"${r}\"]`)\n ?.focus();\n }\n\n function handleCellKey(e: KeyboardEvent, col: number, row: number) {\n const moves: Record<string, [number, number]> = {\n ArrowRight: [col + 1, row],\n ArrowLeft: [col - 1, row],\n ArrowDown: [col, row + 1],\n ArrowUp: [col, row - 1],\n };\n if (moves[e.key]) {\n e.preventDefault();\n focusCell(...moves[e.key]);\n } else if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n const cell = grid[col]?.[row];\n if (cell && !cell.future) onDayClick?.({ date: cell.iso, count: cell.count });\n }\n }\n\n function handleMouseEnter(\n e: React.MouseEvent<SVGRectElement>,\n text: string,\n ) {\n setTooltipPosition(null);\n setTooltip({\n target: e.currentTarget,\n text,\n });\n }\n\n function hideTooltip() {\n setTooltip(null);\n setTooltipPosition(null);\n }\n\n function cellColor(cell: GridCell): string {\n if (cell.future) return colors[0];\n return colors[Math.min(cell.level, colors.length - 1)] ?? colors[colors.length - 1];\n }\n\n function cellTooltip(cell: GridCell): string {\n if (cell.future) return fullDateLabel(cell.iso, fullDateFormatter);\n const formattedDate = fullDateLabel(cell.iso, fullDateFormatter);\n return (\n tooltipContent?.({ date: cell.iso, count: cell.count }) ??\n `${cell.count} contribution${cell.count !== 1 ? \"s\" : \"\"} on ${formattedDate}`\n );\n }\n\n return (\n <div\n className={[styles.wrapper, className].filter(Boolean).join(\" \")}\n >\n <div ref={graphViewportRef} className={styles.graphViewport}>\n <svg\n ref={svgRef}\n width={svgWidth}\n height={svgHeight}\n className={styles.svg}\n aria-label={ariaLabel}\n role=\"img\"\n data-cell-size={resolvedCellSize}\n data-visible-weeks={visibleWeeks}\n >\n {/* Month labels */}\n {showMonthLabels &&\n monthLabels.map(({ col, month }) => (\n <text\n key={`m-${col}`}\n x={dayLabelW + col * stride}\n y={12}\n className={styles.label}\n >\n {month}\n </text>\n ))}\n\n {/* Day-of-week labels: Mon, Wed, Fri */}\n {showDayLabels &&\n labelRows.map(({ row, label }) => (\n <text\n key={`d-${row}`}\n x={0}\n y={monthLabelH + row * stride + resolvedCellSize - 1}\n className={styles.label}\n >\n {label}\n </text>\n ))}\n\n {/* Activity grid */}\n <g role=\"grid\" aria-label={ariaLabel}>\n {grid.map((column, col) => (\n <g key={col} role=\"row\">\n {column.map((cell, row) => {\n const tipText = cellTooltip(cell);\n const isFocused =\n focusedCell.col === col && focusedCell.row === row;\n\n return (\n <rect\n key={`${col}-${row}`}\n data-col={col}\n data-row={row}\n x={dayLabelW + col * stride}\n y={monthLabelH + row * stride}\n width={resolvedCellSize}\n height={resolvedCellSize}\n rx={cellRx}\n fill={cellColor(cell)}\n opacity={cell.future ? 0.35 : 1}\n className={styles.cell}\n role=\"gridcell\"\n aria-label={tipText}\n aria-disabled={cell.future || undefined}\n tabIndex={isFocused ? 0 : -1}\n onClick={() => !cell.future && onDayClick?.({ date: cell.iso, count: cell.count })}\n onKeyDown={(e) => handleCellKey(e, col, row)}\n onFocus={() => setFocusedCell({ col, row })}\n onMouseEnter={(e) => handleMouseEnter(e, tipText)}\n onMouseLeave={hideTooltip}\n />\n );\n })}\n </g>\n ))}\n </g>\n </svg>\n </div>\n\n {tooltip && typeof document !== \"undefined\" && createPortal(\n <div\n ref={tooltipRef}\n className={styles.tooltip}\n style={\n tooltipPosition\n ? { left: tooltipPosition.left, top: tooltipPosition.top }\n : { visibility: \"hidden\", left: 0, top: 0 }\n }\n role=\"tooltip\"\n >\n {tooltip.text}\n </div>,\n document.body,\n )}\n\n {showLegend && (\n <div className={styles.legend}>\n <span className={styles.legendLabel}>Less</span>\n {Array.from({ length: maxLevel + 1 }, (_, i) => (\n <svg\n key={i}\n width={resolvedCellSize}\n height={resolvedCellSize}\n aria-hidden=\"true\"\n className={styles.legendCell}\n >\n <rect\n width={resolvedCellSize}\n height={resolvedCellSize}\n rx={cellRx}\n fill={colors[Math.min(i, colors.length - 1)]}\n />\n </svg>\n ))}\n <span className={styles.legendLabel}>More</span>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AA0DA,IAAM,IAAa,IAAI,KAAK,KAAM,GAAG,EAAE;AAEvC,SAAS,EACP,GACA,GACQ;AACR,QAAO,EAAU,OAAO,IAAI,KAAK,KAAM,EAAW,CAAC;;AAGrD,SAAS,GACP,GACA,GACQ;CACR,IAAM,IAAO,IAAI,KAAK,EAAW;AAEjC,QADA,EAAK,QAAQ,EAAW,SAAS,GAAG,EAAS,EACtC,EAAU,OAAO,EAAK;;AAG/B,IAAM,KAAkB,IAClB,KAAqB,IAErB,KAAgB,IAAI,IAA2B;CACnD;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAS,GAAY,GAA8C;AACjE,QAAO;EACL;EACA,eAAe,EAAY;EAC3B,eAAe,EAAY;EAC3B,eAAe,EAAY;EAC3B,eAAe,EAAY;EAC5B;;AAGH,SAAS,EAAU,GAAoB;AAIrC,QAAO,GAHG,EAAK,aAAa,CAGhB,GAFF,OAAO,EAAK,UAAU,GAAG,EAAE,CAAC,SAAS,GAAG,IAAI,CAErC,GADP,OAAO,EAAK,SAAS,CAAC,CAAC,SAAS,GAAG,IAAI;;AAInD,SAAS,EAAW,GAAmB;CACrC,IAAM,CAAC,GAAG,GAAG,KAAK,EAAI,MAAM,IAAI,CAAC,IAAI,OAAO;AAC5C,QAAO,IAAI,KAAK,GAAG,IAAI,GAAG,EAAE;;AAG9B,SAAS,EAAc,GAAa,GAAwC;AAC1E,QAAO,EAAU,OAAO,EAAW,EAAI,CAAC;;AAU1C,SAAgB,EAAkB,EAChC,SACA,cAAW,GACX,cAAW,IACX,aAAU,GACV,gBAAa,IACb,kBAAc,GACd,kBAAc,IACd,kBAAe,GACf,qBAAkB,IAClB,mB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gB;KAAK,GACxD;KAAE,YAAY;KAAU,MAAM;KAAG,KAAK;KAAG;IAE/C,MAAK;cAEJ,EAAQ;IACL,CAAA,EACN,SAAS,KACV;GAEA,MACC,kBAAC,OAAD;IAAK,WAAW,EAAO;cAAvB;KACE,kBAAC,QAAD;MAAM,WAAW,EAAO;gBAAa;MAAW,CAAA;KAC/C,MAAM,KAAK,EAAE,QAAQ,IAAW,GAAG,GAAG,GAAG,MACxC,kBAAC,OAAD;MAEE,OAAO;MACP,QAAQ;MACR,eAAY;MACZ,WAAW,EAAO;gBAElB,kBAAC,QAAD;OACE,OAAO;OACP,QAAQ;OACR,IAAI;OACJ,MAAM,EAAO,KAAK,IAAI,GAAG,EAAO,SAAS,EAAE;OAC3C,CAAA;MACE,EAZC,EAYD,CACN;KACF,kBAAC,QAAD;MAAM,WAAW,EAAO;gBAAa;MAAW,CAAA;KAC5C;;GAEJ"}
@@ -1,2 +1,2 @@
1
- var e={wrapper:`_wrapper_1upmq_1`,svg:`_svg_1upmq_10`,label:`_label_1upmq_15`,cell:`_cell_1upmq_23`,tooltip:`_tooltip_1upmq_58`,legend:`_legend_1upmq_74`,legendLabel:`_legendLabel_1upmq_81`,legendCell:`_legendCell_1upmq_89`};exports.default=e;
1
+ var e={wrapper:`_wrapper_1onba_1`,graphViewport:`_graphViewport_1onba_10`,svg:`_svg_1onba_17`,label:`_label_1onba_22`,cell:`_cell_1onba_30`,tooltip:`_tooltip_1onba_67`,legend:`_legend_1onba_86`,legendLabel:`_legendLabel_1onba_93`,legendCell:`_legendCell_1onba_101`};exports.default=e;
2
2
  //# sourceMappingURL=ContributionGraph.module.css.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContributionGraph.module.css.cjs","names":[],"sources":["../../../src/components/ContributionGraph/ContributionGraph.module.css"],"sourcesContent":[".wrapper {\n position: relative;\n display: inline-flex;\n flex-direction: column;\n gap: var(--gnome-space-1, 6px);\n overflow-x: auto;\n max-width: 100%;\n}\n\n.svg {\n display: block;\n flex-shrink: 0;\n}\n\n.label {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n fill: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.cell {\n cursor: default;\n transition: transform var(--gnome-transition-fast, 100ms) ease;\n transform-box: fill-box;\n transform-origin: center;\n outline: none;\n}\n\n.cell:not([aria-disabled=\"true\"]):hover {\n transform: scale(1.2);\n}\n\n.cell:not([aria-disabled=\"true\"]) {\n cursor: pointer;\n}\n\n.cell:focus-visible {\n outline: 2px solid var(--gnome-accent-color, #3584e4);\n outline-offset: 1px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .cell {\n transition: none;\n }\n}\n\n@media (prefers-contrast: more) {\n .cell {\n stroke: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n stroke-width: 0.5;\n stroke-opacity: 0.3;\n }\n}\n\n.tooltip {\n position: absolute;\n transform: translate(-50%, calc(-100% - 6px));\n background: var(--gnome-popover-bg-color, #fff);\n border: 1px solid var(--gnome-light-3, #deddda);\n border-radius: var(--gnome-radius-md, 8px);\n padding: 4px 8px;\n font-family: var(--gnome-font-family, system-ui);\n font-size: 12px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n box-shadow: var(--gnome-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.12));\n pointer-events: none;\n white-space: nowrap;\n z-index: 10;\n}\n\n.legend {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: var(--gnome-space-1, 6px);\n}\n\n.legendLabel {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.legendCell {\n display: block;\n flex-shrink: 0;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"ContributionGraph.module.css.cjs","names":[],"sources":["../../../src/components/ContributionGraph/ContributionGraph.module.css"],"sourcesContent":[".wrapper {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n gap: var(--gnome-space-1, 6px);\n min-width: 0;\n}\n\n.graphViewport {\n width: 100%;\n min-width: 0;\n overflow-x: auto;\n overflow-y: visible;\n}\n\n.svg {\n display: block;\n flex-shrink: 0;\n}\n\n.label {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n fill: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.cell {\n cursor: default;\n transition:\n stroke-opacity var(--gnome-transition-fast, 100ms) ease,\n stroke-width var(--gnome-transition-fast, 100ms) ease;\n outline: none;\n}\n\n.cell:not([aria-disabled=\"true\"]):hover {\n stroke: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n stroke-opacity: 0.35;\n stroke-width: 1;\n}\n\n.cell:not([aria-disabled=\"true\"]) {\n cursor: pointer;\n}\n\n.cell:focus-visible {\n outline: 2px solid var(--gnome-accent-color, #3584e4);\n outline-offset: 1px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .cell {\n transition: none;\n }\n}\n\n@media (prefers-contrast: more) {\n .cell {\n stroke: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n stroke-width: 0.5;\n stroke-opacity: 0.3;\n }\n}\n\n.tooltip {\n position: fixed;\n box-sizing: border-box;\n max-width: calc(100vw - 16px);\n background: var(--gnome-popover-bg-color, #fff);\n border: 1px solid var(--gnome-light-3, #deddda);\n border-radius: var(--gnome-radius-md, 8px);\n padding: 4px 8px;\n font-family: var(--gnome-font-family, system-ui);\n font-size: 12px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n box-shadow: var(--gnome-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.12));\n pointer-events: none;\n overflow-wrap: anywhere;\n text-align: center;\n white-space: normal;\n z-index: 10001;\n}\n\n.legend {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: var(--gnome-space-1, 6px);\n}\n\n.legendLabel {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.legendCell {\n display: block;\n flex-shrink: 0;\n}\n"],"mappings":""}
@@ -1,12 +1,13 @@
1
1
  var e = {
2
- wrapper: "_wrapper_1upmq_1",
3
- svg: "_svg_1upmq_10",
4
- label: "_label_1upmq_15",
5
- cell: "_cell_1upmq_23",
6
- tooltip: "_tooltip_1upmq_58",
7
- legend: "_legend_1upmq_74",
8
- legendLabel: "_legendLabel_1upmq_81",
9
- legendCell: "_legendCell_1upmq_89"
2
+ wrapper: "_wrapper_1onba_1",
3
+ graphViewport: "_graphViewport_1onba_10",
4
+ svg: "_svg_1onba_17",
5
+ label: "_label_1onba_22",
6
+ cell: "_cell_1onba_30",
7
+ tooltip: "_tooltip_1onba_67",
8
+ legend: "_legend_1onba_86",
9
+ legendLabel: "_legendLabel_1onba_93",
10
+ legendCell: "_legendCell_1onba_101"
10
11
  };
11
12
  //#endregion
12
13
  export { e as default };
@@ -1 +1 @@
1
- {"version":3,"file":"ContributionGraph.module.css.js","names":[],"sources":["../../../src/components/ContributionGraph/ContributionGraph.module.css"],"sourcesContent":[".wrapper {\n position: relative;\n display: inline-flex;\n flex-direction: column;\n gap: var(--gnome-space-1, 6px);\n overflow-x: auto;\n max-width: 100%;\n}\n\n.svg {\n display: block;\n flex-shrink: 0;\n}\n\n.label {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n fill: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.cell {\n cursor: default;\n transition: transform var(--gnome-transition-fast, 100ms) ease;\n transform-box: fill-box;\n transform-origin: center;\n outline: none;\n}\n\n.cell:not([aria-disabled=\"true\"]):hover {\n transform: scale(1.2);\n}\n\n.cell:not([aria-disabled=\"true\"]) {\n cursor: pointer;\n}\n\n.cell:focus-visible {\n outline: 2px solid var(--gnome-accent-color, #3584e4);\n outline-offset: 1px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .cell {\n transition: none;\n }\n}\n\n@media (prefers-contrast: more) {\n .cell {\n stroke: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n stroke-width: 0.5;\n stroke-opacity: 0.3;\n }\n}\n\n.tooltip {\n position: absolute;\n transform: translate(-50%, calc(-100% - 6px));\n background: var(--gnome-popover-bg-color, #fff);\n border: 1px solid var(--gnome-light-3, #deddda);\n border-radius: var(--gnome-radius-md, 8px);\n padding: 4px 8px;\n font-family: var(--gnome-font-family, system-ui);\n font-size: 12px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n box-shadow: var(--gnome-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.12));\n pointer-events: none;\n white-space: nowrap;\n z-index: 10;\n}\n\n.legend {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: var(--gnome-space-1, 6px);\n}\n\n.legendLabel {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.legendCell {\n display: block;\n flex-shrink: 0;\n}\n"],"mappings":""}
1
+ {"version":3,"file":"ContributionGraph.module.css.js","names":[],"sources":["../../../src/components/ContributionGraph/ContributionGraph.module.css"],"sourcesContent":[".wrapper {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n gap: var(--gnome-space-1, 6px);\n min-width: 0;\n}\n\n.graphViewport {\n width: 100%;\n min-width: 0;\n overflow-x: auto;\n overflow-y: visible;\n}\n\n.svg {\n display: block;\n flex-shrink: 0;\n}\n\n.label {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n fill: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.cell {\n cursor: default;\n transition:\n stroke-opacity var(--gnome-transition-fast, 100ms) ease,\n stroke-width var(--gnome-transition-fast, 100ms) ease;\n outline: none;\n}\n\n.cell:not([aria-disabled=\"true\"]):hover {\n stroke: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n stroke-opacity: 0.35;\n stroke-width: 1;\n}\n\n.cell:not([aria-disabled=\"true\"]) {\n cursor: pointer;\n}\n\n.cell:focus-visible {\n outline: 2px solid var(--gnome-accent-color, #3584e4);\n outline-offset: 1px;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .cell {\n transition: none;\n }\n}\n\n@media (prefers-contrast: more) {\n .cell {\n stroke: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n stroke-width: 0.5;\n stroke-opacity: 0.3;\n }\n}\n\n.tooltip {\n position: fixed;\n box-sizing: border-box;\n max-width: calc(100vw - 16px);\n background: var(--gnome-popover-bg-color, #fff);\n border: 1px solid var(--gnome-light-3, #deddda);\n border-radius: var(--gnome-radius-md, 8px);\n padding: 4px 8px;\n font-family: var(--gnome-font-family, system-ui);\n font-size: 12px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n box-shadow: var(--gnome-shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.12));\n pointer-events: none;\n overflow-wrap: anywhere;\n text-align: center;\n white-space: normal;\n z-index: 10001;\n}\n\n.legend {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: var(--gnome-space-1, 6px);\n}\n\n.legendLabel {\n font-family: var(--gnome-font-family, system-ui);\n font-size: 11px;\n color: var(--gnome-window-fg-color, rgba(0, 0, 0, 0.8));\n opacity: 0.6;\n user-select: none;\n}\n\n.legendCell {\n display: block;\n flex-shrink: 0;\n}\n"],"mappings":""}
@@ -1,2 +1,2 @@
1
1
  export { ContributionGraph } from './ContributionGraph';
2
- export type { ContributionGraphProps, ContributionDay } from './ContributionGraph';
2
+ export type { ContributionGraphProps, ContributionDay, } from './ContributionGraph';
@@ -0,0 +1,2 @@
1
+ const e=require(`../Dialog/dialogUtils.cjs`),t=require(`./Drawer.module.css.cjs`);let n=require(`react`),r=require(`react-dom`),i=require(`react/jsx-runtime`);function a({open:a,side:o=`right`,size:s=`classic`,title:c,content:l,children:u,onClose:d,closeOnBackdrop:f=!0,className:p,...m}){let h=(0,n.useRef)(null),g=(0,n.useId)(),_=(0,n.useRef)(null),v=e.useVisualViewport(),y=l===void 0?u:l;(0,n.useEffect)(()=>{a?(_.current=document.activeElement,h.current?.querySelector(e.FOCUSABLE)?.focus()):_.current?.focus()},[a]);let b=(0,n.useCallback)(t=>{if(t.key===`Escape`){t.preventDefault(),d?.();return}e.trapFocus(t,h)},[d]);if(!a)return null;let x=(0,i.jsx)(`div`,{className:t.default.backdrop,style:v,onClick:f?d:void 0,children:(0,i.jsxs)(`div`,{ref:h,role:`dialog`,"aria-modal":`true`,"aria-labelledby":c?g:void 0,"data-side":o,"data-size":s,className:[t.default.drawer,o===`left`?t.default.left:t.default.right,s===`wide`?t.default.wide:t.default.classic,p].filter(Boolean).join(` `),onKeyDown:b,onClick:e=>e.stopPropagation(),...m,children:[c&&(0,i.jsx)(`div`,{id:g,className:t.default.title,children:c}),y!==void 0&&(0,i.jsx)(`div`,{className:t.default.content,children:y})]})});return typeof document>`u`?x:(0,r.createPortal)(x,document.body)}exports.Drawer=a;
2
+ //# sourceMappingURL=Drawer.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Drawer.cjs","names":[],"sources":["../../../src/components/Drawer/Drawer.tsx"],"sourcesContent":["import {\n useCallback,\n useEffect,\n useId,\n useRef,\n type HTMLAttributes,\n type KeyboardEvent,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { FOCUSABLE, trapFocus, useVisualViewport } from \"../Dialog/dialogUtils\";\nimport styles from \"./Drawer.module.css\";\n\nexport type DrawerSide = \"left\" | \"right\";\nexport type DrawerSize = \"classic\" | \"wide\";\n\nexport interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, \"content\" | \"title\"> {\n /** Whether the drawer is visible. */\n open: boolean;\n /** Edge that the drawer slides in from. Defaults to `\"right\"`. */\n side?: DrawerSide;\n /** Preset drawer width. Defaults to `\"classic\"`. */\n size?: DrawerSize;\n /** Optional drawer heading. */\n title?: ReactNode;\n /** Drawer content when a prop is preferred over `children`. */\n content?: ReactNode;\n /** Drawer content. Used when `content` is not provided. */\n children?: ReactNode;\n /** Called when the user dismisses the drawer with Escape or the backdrop. */\n onClose?: () => void;\n /** Whether clicking the backdrop closes the drawer. Defaults to `true`. */\n closeOnBackdrop?: boolean;\n}\n\n/**\n * Slide-over panel for supplementary content.\n *\n * The drawer is controlled through `open`, renders into `document.body`, and\n * accepts its body as either `content` or `children`.\n */\nexport function Drawer({\n open,\n side = \"right\",\n size = \"classic\",\n title,\n content,\n children,\n onClose,\n closeOnBackdrop = true,\n className,\n ...props\n}: DrawerProps) {\n const drawerRef = useRef<HTMLDivElement>(null);\n const titleId = useId();\n const previouslyFocused = useRef<Element | null>(null);\n const viewportStyle = useVisualViewport();\n const body = content !== undefined ? content : children;\n\n useEffect(() => {\n if (open) {\n previouslyFocused.current = document.activeElement;\n drawerRef.current?.querySelector<HTMLElement>(FOCUSABLE)?.focus();\n } else {\n (previouslyFocused.current as HTMLElement | null)?.focus();\n }\n }, [open]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n onClose?.();\n return;\n }\n\n trapFocus(event, drawerRef);\n },\n [onClose],\n );\n\n if (!open) return null;\n\n const node = (\n <div\n className={styles.backdrop}\n style={viewportStyle}\n onClick={closeOnBackdrop ? onClose : undefined}\n >\n <div\n ref={drawerRef}\n role=\"dialog\"\n aria-modal=\"true\"\n aria-labelledby={title ? titleId : undefined}\n data-side={side}\n data-size={size}\n className={[\n styles.drawer,\n side === \"left\" ? styles.left : styles.right,\n size === \"wide\" ? styles.wide : styles.classic,\n className,\n ]\n .filter(Boolean)\n .join(\" \")}\n onKeyDown={handleKeyDown}\n onClick={(event) => event.stopPropagation()}\n {...props}\n >\n {title && <div id={titleId} className={styles.title}>{title}</div>}\n {body !== undefined && <div className={styles.content}>{body}</div>}\n </div>\n </div>\n );\n\n if (typeof document === \"undefined\") return node;\n return createPortal(node, document.body);\n}\n"],"mappings":"+JAyCA,SAAgB,EAAO,CACrB,OACA,OAAO,QACP,OAAO,UACP,QACA,UACA,WACA,UACA,kBAAkB,GAClB,YACA,GAAG,GACW,CACd,IAAM,GAAA,EAAA,EAAA,QAAmC,KAAK,CACxC,GAAA,EAAA,EAAA,QAAiB,CACjB,GAAA,EAAA,EAAA,QAA2C,KAAK,CAChD,EAAgB,EAAA,mBAAmB,CACnC,EAAO,IAAY,IAAA,GAAsB,EAAV,GAErC,EAAA,EAAA,eAAgB,CACV,GACF,EAAkB,QAAU,SAAS,cACrC,EAAU,SAAS,cAA2B,EAAA,UAAU,EAAE,OAAO,EAEhE,EAAkB,SAAgC,OAAO,EAE3D,CAAC,EAAK,CAAC,CAEV,IAAM,GAAA,EAAA,EAAA,aACH,GAAyC,CACxC,GAAI,EAAM,MAAQ,SAAU,CAC1B,EAAM,gBAAgB,CACtB,KAAW,CACX,OAGF,EAAA,UAAU,EAAO,EAAU,EAE7B,CAAC,EAAQ,CACV,CAED,GAAI,CAAC,EAAM,OAAO,KAElB,IAAM,GACJ,EAAA,EAAA,KAAC,MAAD,CACE,UAAW,EAAA,QAAO,SAClB,MAAO,EACP,QAAS,EAAkB,EAAU,IAAA,aAErC,EAAA,EAAA,MAAC,MAAD,CACE,IAAK,EACL,KAAK,SACL,aAAW,OACX,kBAAiB,EAAQ,EAAU,IAAA,GACnC,YAAW,EACX,YAAW,EACX,UAAW,CACT,EAAA,QAAO,OACP,IAAS,OAAS,EAAA,QAAO,KAAO,EAAA,QAAO,MACvC,IAAS,OAAS,EAAA,QAAO,KAAO,EAAA,QAAO,QACvC,EACD,CACE,OAAO,QAAQ,CACf,KAAK,IAAI,CACZ,UAAW,EACX,QAAU,GAAU,EAAM,iBAAiB,CAC3C,GAAI,WAjBN,CA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