@adecore/charts 0.39.0 → 0.40.1

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/Heatmap.js CHANGED
@@ -6,6 +6,7 @@ import { Button, Surface } from '@adecore/ui';
6
6
  import { formatNumber } from '@adecore/ui/format';
7
7
  import { colorOf } from './color.js';
8
8
  import { FLOOR, heatMix, heatShare, moveCell } from './heat.js';
9
+ import { tableClasses } from './values-table.js';
9
10
  /* Between a cell and the card beside it. */
10
11
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
11
12
  const OFFSET = 8;
@@ -21,7 +22,7 @@ const cardPlace = (toRight, down) => ({
21
22
  });
22
23
  /* A grid of rows by columns, each cell shaded by its value, such as events per weekday and hour. */
23
24
  export function Heatmap(t0) {
24
- const $ = _c(89);
25
+ const $ = _c(95);
25
26
  const {
26
27
  rows,
27
28
  columns,
@@ -51,6 +52,7 @@ export function Heatmap(t0) {
51
52
  const [active, setActive] = useState(null);
52
53
  const [announce, setAnnounce] = useState(false);
53
54
  const [shown, setShown] = useState(false);
55
+ let classes;
54
56
  let current;
55
57
  let describe;
56
58
  let empty;
@@ -59,74 +61,84 @@ export function Heatmap(t0) {
59
61
  let t8;
60
62
  let t9;
61
63
  let valueAt;
62
- if ($[0] !== active || $[1] !== cellHeight || $[2] !== className || $[3] !== columns || $[4] !== format || $[5] !== id || $[6] !== label || $[7] !== legend || $[8] !== max || $[9] !== onActiveChange || $[10] !== ref || $[11] !== rows || $[12] !== steps || $[13] !== t || $[14] !== tone || $[15] !== valueLabel || $[16] !== values) {
64
+ if ($[0] !== active || $[1] !== cellHeight || $[2] !== className || $[3] !== columns || $[4] !== format || $[5] !== id || $[6] !== label || $[7] !== legend || $[8] !== max || $[9] !== onActiveChange || $[10] !== ref || $[11] !== rows || $[12] !== shown || $[13] !== steps || $[14] !== t || $[15] !== table || $[16] !== tone || $[17] !== valueLabel || $[18] !== values) {
63
65
  const color = colorOf(tone);
64
66
  let t10;
65
- if ($[25] !== values) {
67
+ if ($[28] !== values) {
66
68
  t10 = (row, column) => values[row]?.[column] ?? null;
67
- $[25] = values;
68
- $[26] = t10;
69
+ $[28] = values;
70
+ $[29] = t10;
69
71
  } else {
70
- t10 = $[26];
72
+ t10 = $[29];
71
73
  }
72
74
  valueAt = t10;
73
75
  let t11;
74
- if ($[27] !== max || $[28] !== values) {
76
+ if ($[30] !== max || $[31] !== values) {
75
77
  t11 = max ?? Math.max(0, ...values.flatMap(_temp2));
76
- $[27] = max;
77
- $[28] = values;
78
- $[29] = t11;
78
+ $[30] = max;
79
+ $[31] = values;
80
+ $[32] = t11;
79
81
  } else {
80
- t11 = $[29];
82
+ t11 = $[32];
81
83
  }
82
84
  const top = t11;
83
85
  empty = rows.length === 0 || columns.length === 0;
84
86
  let t12;
85
- if ($[30] !== format || $[31] !== t) {
87
+ if ($[33] !== format || $[34] !== t) {
86
88
  t12 = value_0 => value_0 === null ? t("noData") : format(value_0);
87
- $[30] = format;
88
- $[31] = t;
89
- $[32] = t12;
89
+ $[33] = format;
90
+ $[34] = t;
91
+ $[35] = t12;
90
92
  } else {
91
- t12 = $[32];
93
+ t12 = $[35];
92
94
  }
93
95
  const write = t12;
94
96
  let t13;
95
- if ($[33] !== columns || $[34] !== format || $[35] !== rows || $[36] !== t || $[37] !== valueAt || $[38] !== valueLabel) {
97
+ if ($[36] !== columns || $[37] !== format || $[38] !== rows || $[39] !== t || $[40] !== valueAt || $[41] !== valueLabel) {
96
98
  t13 = cell => {
97
99
  const value_1 = valueAt(cell.row, cell.column);
98
100
  return `${rows[cell.row].label}, ${columns[cell.column].label}, ${value_1 === null ? t("noData") : `${valueLabel} ${format(value_1)}`}`;
99
101
  };
100
- $[33] = columns;
101
- $[34] = format;
102
- $[35] = rows;
103
- $[36] = t;
104
- $[37] = valueAt;
105
- $[38] = valueLabel;
106
- $[39] = t13;
102
+ $[36] = columns;
103
+ $[37] = format;
104
+ $[38] = rows;
105
+ $[39] = t;
106
+ $[40] = valueAt;
107
+ $[41] = valueLabel;
108
+ $[42] = t13;
107
109
  } else {
108
- t13 = $[39];
110
+ t13 = $[42];
109
111
  }
110
112
  describe = t13;
111
113
  current = active !== null && active.row < rows.length && active.column < columns.length ? active : null;
112
- let t14;
113
- if ($[40] !== current || $[41] !== onActiveChange) {
114
- t14 = cell_0 => {
114
+ const t14 = table && shown;
115
+ let t15;
116
+ if ($[43] !== t14) {
117
+ t15 = tableClasses(t14);
118
+ $[43] = t14;
119
+ $[44] = t15;
120
+ } else {
121
+ t15 = $[44];
122
+ }
123
+ classes = t15;
124
+ let t16;
125
+ if ($[45] !== current || $[46] !== onActiveChange) {
126
+ t16 = cell_0 => {
115
127
  setActive(cell_0);
116
128
  if (!sameCell(cell_0, current)) {
117
129
  onActiveChange?.(cell_0);
118
130
  }
119
131
  };
120
- $[40] = current;
121
- $[41] = onActiveChange;
122
- $[42] = t14;
132
+ $[45] = current;
133
+ $[46] = onActiveChange;
134
+ $[47] = t16;
123
135
  } else {
124
- t14 = $[42];
136
+ t16 = $[47];
125
137
  }
126
- const activate = t14;
127
- let t15;
128
- if ($[43] !== activate || $[44] !== columns.length || $[45] !== current || $[46] !== rows.length) {
129
- t15 = e => {
138
+ const activate = t16;
139
+ let t17;
140
+ if ($[48] !== activate || $[49] !== columns.length || $[50] !== current || $[51] !== rows.length) {
141
+ t17 = e => {
130
142
  const target = moveCell(e.key, current, rows.length, columns.length, e.ctrlKey || e.metaKey);
131
143
  if (target === undefined) {
132
144
  return;
@@ -135,48 +147,48 @@ export function Heatmap(t0) {
135
147
  setAnnounce(target !== null);
136
148
  activate(target);
137
149
  };
138
- $[43] = activate;
139
- $[44] = columns.length;
140
- $[45] = current;
141
- $[46] = rows.length;
142
- $[47] = t15;
150
+ $[48] = activate;
151
+ $[49] = columns.length;
152
+ $[50] = current;
153
+ $[51] = rows.length;
154
+ $[52] = t17;
143
155
  } else {
144
- t15 = $[47];
156
+ t17 = $[52];
145
157
  }
146
- const onKeyDown = t15;
158
+ const onKeyDown = t17;
147
159
  t6 = ref;
148
- if ($[48] !== className) {
160
+ if ($[53] !== className) {
149
161
  t7 = clsx("flex min-w-0 flex-col gap-2", className);
150
- $[48] = className;
151
- $[49] = t7;
162
+ $[53] = className;
163
+ $[54] = t7;
152
164
  } else {
153
- t7 = $[49];
165
+ t7 = $[54];
154
166
  }
155
- let t16;
156
- if ($[50] !== t) {
157
- t16 = t("heatmap.name");
158
- $[50] = t;
159
- $[51] = t16;
167
+ let t18;
168
+ if ($[55] !== t) {
169
+ t18 = t("heatmap.name");
170
+ $[55] = t;
171
+ $[56] = t18;
160
172
  } else {
161
- t16 = $[51];
173
+ t18 = $[56];
162
174
  }
163
- const t17 = `${id}-hint`;
164
- let t18;
165
- let t19;
166
- if ($[52] !== activate) {
167
- t18 = () => activate(null);
168
- t19 = () => {
175
+ const t19 = `${id}-hint`;
176
+ let t20;
177
+ let t21;
178
+ if ($[57] !== activate) {
179
+ t20 = () => activate(null);
180
+ t21 = () => {
169
181
  activate(null);
170
182
  setAnnounce(false);
171
183
  };
172
- $[52] = activate;
173
- $[53] = t18;
174
- $[54] = t19;
184
+ $[57] = activate;
185
+ $[58] = t20;
186
+ $[59] = t21;
175
187
  } else {
176
- t18 = $[53];
177
- t19 = $[54];
188
+ t20 = $[58];
189
+ t21 = $[59];
178
190
  }
179
- const t20 = empty ? /*#__PURE__*/_jsx("p", {
191
+ const t22 = empty ? /*#__PURE__*/_jsx("p", {
180
192
  className: "py-6 text-center text-xs text-text-faint",
181
193
  children: t("noData")
182
194
  }) : /*#__PURE__*/_jsxs("div", {
@@ -234,29 +246,29 @@ export function Heatmap(t0) {
234
246
  })]
235
247
  }, row_0.key))]
236
248
  });
237
- if ($[55] !== label || $[56] !== onKeyDown || $[57] !== t16 || $[58] !== t17 || $[59] !== t18 || $[60] !== t19 || $[61] !== t20) {
249
+ if ($[60] !== label || $[61] !== onKeyDown || $[62] !== t18 || $[63] !== t19 || $[64] !== t20 || $[65] !== t21 || $[66] !== t22) {
238
250
  t8 = /*#__PURE__*/_jsx("div", {
239
251
  role: "group",
240
252
  tabIndex: 0,
241
- "aria-roledescription": t16,
253
+ "aria-roledescription": t18,
242
254
  "aria-label": label,
243
- "aria-describedby": t17,
255
+ "aria-describedby": t19,
244
256
  className: "focus-ring rounded-xs",
245
257
  onKeyDown: onKeyDown,
246
- onPointerLeave: t18,
247
- onBlur: t19,
248
- children: t20
258
+ onPointerLeave: t20,
259
+ onBlur: t21,
260
+ children: t22
249
261
  });
250
- $[55] = label;
251
- $[56] = onKeyDown;
252
- $[57] = t16;
253
- $[58] = t17;
254
- $[59] = t18;
255
- $[60] = t19;
256
- $[61] = t20;
257
- $[62] = t8;
262
+ $[60] = label;
263
+ $[61] = onKeyDown;
264
+ $[62] = t18;
265
+ $[63] = t19;
266
+ $[64] = t20;
267
+ $[65] = t21;
268
+ $[66] = t22;
269
+ $[67] = t8;
258
270
  } else {
259
- t8 = $[62];
271
+ t8 = $[67];
260
272
  }
261
273
  t9 = legend && !empty && /*#__PURE__*/_jsxs("div", {
262
274
  "aria-hidden": true,
@@ -298,31 +310,35 @@ export function Heatmap(t0) {
298
310
  $[9] = onActiveChange;
299
311
  $[10] = ref;
300
312
  $[11] = rows;
301
- $[12] = steps;
302
- $[13] = t;
303
- $[14] = tone;
304
- $[15] = valueLabel;
305
- $[16] = values;
306
- $[17] = current;
307
- $[18] = describe;
308
- $[19] = empty;
309
- $[20] = t6;
310
- $[21] = t7;
311
- $[22] = t8;
312
- $[23] = t9;
313
- $[24] = valueAt;
313
+ $[12] = shown;
314
+ $[13] = steps;
315
+ $[14] = t;
316
+ $[15] = table;
317
+ $[16] = tone;
318
+ $[17] = valueLabel;
319
+ $[18] = values;
320
+ $[19] = classes;
321
+ $[20] = current;
322
+ $[21] = describe;
323
+ $[22] = empty;
324
+ $[23] = t6;
325
+ $[24] = t7;
326
+ $[25] = t8;
327
+ $[26] = t9;
328
+ $[27] = valueAt;
314
329
  } else {
315
- current = $[17];
316
- describe = $[18];
317
- empty = $[19];
318
- t6 = $[20];
319
- t7 = $[21];
320
- t8 = $[22];
321
- t9 = $[23];
322
- valueAt = $[24];
330
+ classes = $[19];
331
+ current = $[20];
332
+ describe = $[21];
333
+ empty = $[22];
334
+ t6 = $[23];
335
+ t7 = $[24];
336
+ t8 = $[25];
337
+ t9 = $[26];
338
+ valueAt = $[27];
323
339
  }
324
340
  let t10;
325
- if ($[63] !== columns || $[64] !== empty || $[65] !== format || $[66] !== id || $[67] !== label || $[68] !== rows || $[69] !== shown || $[70] !== t || $[71] !== table || $[72] !== valueAt) {
341
+ if ($[68] !== classes || $[69] !== columns || $[70] !== empty || $[71] !== format || $[72] !== id || $[73] !== label || $[74] !== rows || $[75] !== shown || $[76] !== t || $[77] !== table || $[78] !== valueAt) {
326
342
  t10 = !empty && /*#__PURE__*/_jsxs("div", {
327
343
  className: table ? "flex flex-col items-start gap-2" : undefined,
328
344
  children: [table && /*#__PURE__*/_jsx(Button, {
@@ -333,34 +349,34 @@ export function Heatmap(t0) {
333
349
  children: shown ? t("values.hide") : t("values.show")
334
350
  }), /*#__PURE__*/_jsx("div", {
335
351
  id: `${id}-table`,
336
- className: table && shown ? "max-h-80 w-full overflow-auto rounded-md border border-border-soft" : "sr-only",
352
+ className: classes.box,
337
353
  children: /*#__PURE__*/_jsxs("table", {
338
- className: table && shown ? "w-full border-collapse text-xs tabular-nums" : undefined,
354
+ className: classes.table,
339
355
  children: [/*#__PURE__*/_jsx("caption", {
340
356
  className: "sr-only",
341
357
  children: t("values.caption", {
342
358
  label
343
359
  })
344
360
  }), /*#__PURE__*/_jsx("thead", {
345
- className: table && shown ? "sticky top-0 bg-surface-hover" : undefined,
361
+ className: classes.head,
346
362
  children: /*#__PURE__*/_jsxs("tr", {
347
363
  children: [/*#__PURE__*/_jsx("td", {}), columns.map(column_2 => /*#__PURE__*/_jsx("th", {
348
364
  scope: "col",
349
- className: table && shown ? "h-8 px-2 text-right font-medium whitespace-nowrap text-text-muted" : undefined,
365
+ className: classes.column,
350
366
  children: column_2.label
351
367
  }, column_2.key))]
352
368
  })
353
369
  }), /*#__PURE__*/_jsx("tbody", {
354
370
  children: rows.map((row_1, rowIndex_0) => /*#__PURE__*/_jsxs("tr", {
355
- className: table && shown ? "border-t border-border-soft" : undefined,
371
+ className: classes.row,
356
372
  children: [/*#__PURE__*/_jsx("th", {
357
373
  scope: "row",
358
- className: table && shown ? "h-8 px-2 text-left font-normal whitespace-nowrap text-text-muted" : undefined,
374
+ className: classes.rowHeading,
359
375
  children: row_1.label
360
376
  }), columns.map((column_3, columnIndex_0) => {
361
377
  const value_3 = valueAt(rowIndex_0, columnIndex_0);
362
378
  return /*#__PURE__*/_jsx("td", {
363
- className: table && shown ? "h-8 px-2 text-right whitespace-nowrap text-text" : undefined,
379
+ className: classes.cell,
364
380
  children: value_3 === null ? "" : format(value_3)
365
381
  }, column_3.key);
366
382
  })]
@@ -369,72 +385,73 @@ export function Heatmap(t0) {
369
385
  })
370
386
  })]
371
387
  });
372
- $[63] = columns;
373
- $[64] = empty;
374
- $[65] = format;
375
- $[66] = id;
376
- $[67] = label;
377
- $[68] = rows;
378
- $[69] = shown;
379
- $[70] = t;
380
- $[71] = table;
381
- $[72] = valueAt;
382
- $[73] = t10;
388
+ $[68] = classes;
389
+ $[69] = columns;
390
+ $[70] = empty;
391
+ $[71] = format;
392
+ $[72] = id;
393
+ $[73] = label;
394
+ $[74] = rows;
395
+ $[75] = shown;
396
+ $[76] = t;
397
+ $[77] = table;
398
+ $[78] = valueAt;
399
+ $[79] = t10;
383
400
  } else {
384
- t10 = $[73];
401
+ t10 = $[79];
385
402
  }
386
403
  const t11 = `${id}-hint`;
387
404
  let t12;
388
- if ($[74] !== t) {
405
+ if ($[80] !== t) {
389
406
  t12 = t("heatmap.keyboard");
390
- $[74] = t;
391
- $[75] = t12;
407
+ $[80] = t;
408
+ $[81] = t12;
392
409
  } else {
393
- t12 = $[75];
410
+ t12 = $[81];
394
411
  }
395
412
  let t13;
396
- if ($[76] !== t11 || $[77] !== t12) {
413
+ if ($[82] !== t11 || $[83] !== t12) {
397
414
  t13 = /*#__PURE__*/_jsx("p", {
398
415
  id: t11,
399
416
  className: "sr-only",
400
417
  children: t12
401
418
  });
402
- $[76] = t11;
403
- $[77] = t12;
404
- $[78] = t13;
419
+ $[82] = t11;
420
+ $[83] = t12;
421
+ $[84] = t13;
405
422
  } else {
406
- t13 = $[78];
423
+ t13 = $[84];
407
424
  }
408
425
  const t14 = announce && current !== null ? describe(current) : "";
409
426
  let t15;
410
- if ($[79] !== t14) {
427
+ if ($[85] !== t14) {
411
428
  t15 = /*#__PURE__*/_jsx("p", {
412
429
  "aria-live": "polite",
413
430
  className: "sr-only",
414
431
  children: t14
415
432
  });
416
- $[79] = t14;
417
- $[80] = t15;
433
+ $[85] = t14;
434
+ $[86] = t15;
418
435
  } else {
419
- t15 = $[80];
436
+ t15 = $[86];
420
437
  }
421
438
  let t16;
422
- if ($[81] !== t10 || $[82] !== t13 || $[83] !== t15 || $[84] !== t6 || $[85] !== t7 || $[86] !== t8 || $[87] !== t9) {
439
+ if ($[87] !== t10 || $[88] !== t13 || $[89] !== t15 || $[90] !== t6 || $[91] !== t7 || $[92] !== t8 || $[93] !== t9) {
423
440
  t16 = /*#__PURE__*/_jsxs("div", {
424
441
  ref: t6,
425
442
  className: t7,
426
443
  children: [t8, t9, t10, t13, t15]
427
444
  });
428
- $[81] = t10;
429
- $[82] = t13;
430
- $[83] = t15;
431
- $[84] = t6;
432
- $[85] = t7;
433
- $[86] = t8;
434
- $[87] = t9;
435
- $[88] = t16;
445
+ $[87] = t10;
446
+ $[88] = t13;
447
+ $[89] = t15;
448
+ $[90] = t6;
449
+ $[91] = t7;
450
+ $[92] = t8;
451
+ $[93] = t9;
452
+ $[94] = t16;
436
453
  } else {
437
- t16 = $[88];
454
+ t16 = $[94];
438
455
  }
439
456
  return t16;
440
457
  }