@nyaruka/temba-components 0.124.3 → 0.125.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 (46) hide show
  1. package/.eslintrc.js +3 -1
  2. package/CHANGELOG.md +13 -0
  3. package/demo/data/flows/sample-flow.json +1072 -0
  4. package/demo/data/server/sample-flow.json +0 -0
  5. package/demo/flow/example.html +46 -0
  6. package/demo/index.html +155 -144
  7. package/demo/webchat/example.html +71 -0
  8. package/dist/temba-components.js +43 -33
  9. package/dist/temba-components.js.map +1 -1
  10. package/out-tsc/src/chart/TembaChart.js +111 -47
  11. package/out-tsc/src/chart/TembaChart.js.map +1 -1
  12. package/out-tsc/src/flow/EditorNode.js +2 -1
  13. package/out-tsc/src/flow/EditorNode.js.map +1 -1
  14. package/out-tsc/src/flow/config.js +70 -20
  15. package/out-tsc/src/flow/config.js.map +1 -1
  16. package/out-tsc/src/formfield/FormField.js +4 -1
  17. package/out-tsc/src/formfield/FormField.js.map +1 -1
  18. package/out-tsc/src/utils/index.js +3 -0
  19. package/out-tsc/src/utils/index.js.map +1 -1
  20. package/out-tsc/src/webchat/WebChat.js +2 -0
  21. package/out-tsc/src/webchat/WebChat.js.map +1 -1
  22. package/out-tsc/test/temba-chart.test.js +6 -18
  23. package/out-tsc/test/temba-chart.test.js.map +1 -1
  24. package/out-tsc/test/temba-formfield.test.js +94 -0
  25. package/out-tsc/test/temba-formfield.test.js.map +1 -0
  26. package/out-tsc/test/temba-integration-markdown.test.js +36 -0
  27. package/out-tsc/test/temba-integration-markdown.test.js.map +1 -0
  28. package/out-tsc/test/temba-select.test.js +14 -1
  29. package/out-tsc/test/temba-select.test.js.map +1 -1
  30. package/package.json +2 -1
  31. package/screenshots/truth/formfield/markdown-errors.png +0 -0
  32. package/screenshots/truth/formfield/no-errors.png +0 -0
  33. package/screenshots/truth/formfield/plain-text-errors.png +0 -0
  34. package/screenshots/truth/formfield/widget-only-markdown-errors.png +0 -0
  35. package/screenshots/truth/integration/checkbox-markdown-errors.png +0 -0
  36. package/src/chart/TembaChart.ts +124 -47
  37. package/src/flow/EditorNode.ts +2 -1
  38. package/src/flow/config.ts +71 -20
  39. package/src/formfield/FormField.ts +4 -1
  40. package/src/utils/index.ts +3 -0
  41. package/src/webchat/WebChat.ts +2 -0
  42. package/test/temba-chart.test.ts +7 -23
  43. package/test/temba-formfield.test.ts +121 -0
  44. package/test/temba-integration-markdown.test.ts +45 -0
  45. package/test/temba-select.test.ts +17 -0
  46. package/web-dev-server.config.mjs +18 -0
@@ -7,6 +7,8 @@ import { getStore } from '../store/Store';
7
7
  // eslint-disable-next-line import/no-named-as-default
8
8
  import Chart from 'chart.js/auto';
9
9
  import 'chartjs-adapter-luxon';
10
+ import ChartDataLabels from 'chartjs-plugin-datalabels';
11
+ Chart.register(ChartDataLabels);
10
12
  const DEFAULT_PALETTE = 'qualitative-set1';
11
13
  const COLOR_PALETTES = {
12
14
  // Qualitative (categorical, no order)
@@ -246,6 +248,18 @@ export function formatDurationFromSeconds(seconds) {
246
248
  return units.slice(0, 2).join(' ');
247
249
  }
248
250
  export class TembaChart extends RapidElement {
251
+ // head-room for labels when percentages are visible
252
+ getInflatedMax() {
253
+ if (!this.showPercent || !this.data)
254
+ return undefined;
255
+ // total stacked value for each x-index
256
+ const totals = Array(this.data.labels.length).fill(0);
257
+ for (const ds of this.datasets) {
258
+ ds.data.forEach((v, i) => (totals[i] += v));
259
+ }
260
+ const maxStack = Math.max(...totals);
261
+ return maxStack > 0 ? maxStack * 1.15 : undefined;
262
+ }
249
263
  static get styles() {
250
264
  return css `
251
265
  .chart-title {
@@ -297,19 +311,21 @@ export class TembaChart extends RapidElement {
297
311
  this.other = false;
298
312
  this.datasets = [];
299
313
  this.maxSplits = 2;
314
+ this.xType = 'category';
315
+ this.yType = 'count';
300
316
  this.hideOther = false;
301
317
  this.splits = [];
302
318
  this.dataname = 'Counts';
303
319
  this.single = false;
304
320
  this.legend = false;
305
321
  this.config = false;
306
- this.formatDuration = false;
307
322
  this.showAll = false;
308
323
  this.colorIndex = 0;
309
324
  this.showConfig = false;
310
325
  this.opacity = 1;
311
326
  this.seriesBorderRadius = 2;
312
327
  this.seriesBorderWidth = 1;
328
+ this.showPercent = false;
313
329
  }
314
330
  firstUpdated(changes) {
315
331
  super.firstUpdated(changes);
@@ -341,6 +357,14 @@ export class TembaChart extends RapidElement {
341
357
  this.seriesBorderWidth = Math.max(1, this.seriesBorderWidth);
342
358
  }
343
359
  }
360
+ if (changes.has('showPercent') && this.chart) {
361
+ const yScale = this.chart.options.scales.y;
362
+ yScale.ticks.display = !this.showPercent;
363
+ yScale.grid.display = !this.showPercent;
364
+ yScale.border.display = !this.showPercent;
365
+ yScale.max = this.showPercent ? this.getInflatedMax() : undefined;
366
+ this.chart.update();
367
+ }
344
368
  }
345
369
  /**
346
370
  * Returns a tuple: [backgroundColors[], borderColors[]].
@@ -349,25 +373,25 @@ export class TembaChart extends RapidElement {
349
373
  */
350
374
  get colors() {
351
375
  const baseColors = COLOR_PALETTES[this.palette] || COLOR_PALETTES[DEFAULT_PALETTE];
352
- // Clamp transparency between 0 and 1
376
+ // clamp transparency between 0 and 1
353
377
  const alpha = Math.max(0, Math.min(1, this.opacity));
354
- // Borders: darken base color, no transparency
378
+ // borders darken base color, no transparency
355
379
  const borderColors = baseColors.map((color) => darkenColor(color, 0.25));
356
- // Backgrounds: apply transparency to base color
380
+ // backgrounds apply transparency to base color
357
381
  const backgroundColors = baseColors.map((color) => {
358
- // If already rgba, just replace the alpha
382
+ // if already rgba, just replace the alpha
359
383
  if (color.startsWith('rgba')) {
360
384
  return color.replace(/rgba\(([^,]+),([^,]+),([^,]+),([^)]+)\)/, (_m, r, g, b) => {
361
385
  return `rgba(${r},${g},${b},${alpha})`;
362
386
  });
363
387
  }
364
- // If already rgb, convert to rgba
388
+ // if already rgb, convert to rgba
365
389
  if (color.startsWith('rgb(')) {
366
390
  return color.replace(/rgb\(([^,]+),([^,]+),([^,]+)\)/, (_m, r, g, b) => {
367
391
  return `rgba(${r},${g},${b},${alpha})`;
368
392
  });
369
393
  }
370
- // If hex, convert to rgba
394
+ // if hex, convert to rgba
371
395
  if (color.startsWith('#')) {
372
396
  let hex = color.replace('#', '');
373
397
  if (hex.length === 3) {
@@ -387,14 +411,10 @@ export class TembaChart extends RapidElement {
387
411
  });
388
412
  return [backgroundColors, borderColors];
389
413
  }
390
- /**
391
- * Utility to darken an rgba or hex color by a given factor (0-1).
392
- */
393
414
  calculateSplits() {
394
415
  if (this.data) {
395
416
  const datasets = [];
396
417
  const sums = [];
397
- // Get color arrays
398
418
  const [backgroundColors, borderColors] = this.colors;
399
419
  for (const dataset of this.data.datasets) {
400
420
  if (!this.showAll &&
@@ -450,9 +470,28 @@ export class TembaChart extends RapidElement {
450
470
  updateChart() {
451
471
  var _a;
452
472
  if (((_a = this.datasets) === null || _a === void 0 ? void 0 : _a.length) > 0) {
473
+ const grandTotal = this.datasets.reduce((sum, ds) => sum +
474
+ ds.data.reduce((dsSum, v) => dsSum + (v !== null && v !== void 0 ? v : 0), 0), 0) || undefined;
475
+ const percentFormatter = (value) => {
476
+ const pct = grandTotal ? (value / grandTotal) * 100 : 0;
477
+ return `${Math.round(pct)}%`;
478
+ };
453
479
  if (this.chart) {
454
480
  this.chart.data.labels = this.data.labels;
455
481
  this.chart.data.datasets = this.datasets;
482
+ // update y-axis max dynamically
483
+ if (this.showPercent) {
484
+ this.chart.options.scales.y.max = this.getInflatedMax();
485
+ }
486
+ const datalabels = this.chart.options.plugins.datalabels || {};
487
+ datalabels.display = this.showPercent;
488
+ if (this.showPercent) {
489
+ datalabels.formatter = percentFormatter;
490
+ }
491
+ else {
492
+ delete datalabels.formatter;
493
+ }
494
+ this.chart.options.plugins.datalabels = datalabels;
456
495
  this.chart.update();
457
496
  }
458
497
  else {
@@ -463,55 +502,74 @@ export class TembaChart extends RapidElement {
463
502
  datasets: this.datasets
464
503
  },
465
504
  options: {
505
+ maxBarThickness: 80,
466
506
  plugins: {
467
- legend: {
468
- display: this.legend
469
- },
470
- ...(this.formatDuration && {
471
- tooltip: {
472
- callbacks: {
473
- label: (context) => {
474
- const label = context.dataset.label || '';
475
- const value = context.parsed.y;
476
- const formattedValue = formatDurationFromSeconds(value);
477
- return `${label}: ${formattedValue}`;
507
+ legend: { display: this.legend },
508
+ tooltip: {
509
+ callbacks: {
510
+ label: (context) => {
511
+ const label = context.dataset.label || '';
512
+ const value = context.parsed.y;
513
+ if (this.yType === 'duration') {
514
+ return `${label}: ${formatDurationFromSeconds(value)}`;
478
515
  }
516
+ return `${label}: ${value}`;
479
517
  }
480
518
  }
481
- })
519
+ },
520
+ datalabels: {
521
+ display: this.showPercent,
522
+ anchor: 'end',
523
+ align: 'end',
524
+ offset: -3,
525
+ clamp: true,
526
+ ...(this.showPercent && { formatter: percentFormatter }),
527
+ color: '#666',
528
+ font: { weight: '600' }
529
+ }
482
530
  },
483
531
  responsive: true,
484
532
  maintainAspectRatio: false,
485
- animation: {
486
- x: { from: 500 },
487
- y: { from: 500 }
533
+ animations: {
534
+ x: {
535
+ // no horizontal motion
536
+ duration: 0
537
+ },
538
+ y: {
539
+ duration: 200,
540
+ easing: 'easeOutCubic'
541
+ }
488
542
  },
489
543
  scales: {
490
544
  y: {
491
545
  min: 0,
546
+ ...(this.showPercent && { max: this.getInflatedMax() }),
492
547
  stacked: true,
493
- ...(this.formatDuration && {
494
- ticks: {
495
- callback: (value) => {
496
- return formatDurationFromSeconds(value);
497
- }
498
- }
499
- }),
500
- grid: { color: 'rgba(0,0,0,0.04)' }
548
+ grid: {
549
+ color: 'rgba(0,0,0,0.04)',
550
+ display: !this.showPercent, // hide gridlines in percent mode
551
+ drawBorder: !this.showPercent // hides axis line when false
552
+ },
553
+ border: {
554
+ display: !this.showPercent // Chart.js >= 4
555
+ },
556
+ ticks: {
557
+ display: !this.showPercent,
558
+ ...(this.yType === 'duration' &&
559
+ !this.showPercent && {
560
+ callback: (value) => formatDurationFromSeconds(value)
561
+ })
562
+ }
501
563
  },
502
564
  x: {
503
- type: 'time',
565
+ type: this.xType,
566
+ grid: { display: false },
567
+ stacked: true,
504
568
  time: {
505
569
  unit: 'day',
506
- tooltipFormat: 'DDD', // Luxon for 'Feb 16, 2025'
507
- displayFormats: {
508
- day: 'MMM dd'
509
- }
510
- },
511
- grid: {
512
- display: false
513
- },
514
- stacked: true
570
+ tooltipFormat: 'DDD',
571
+ displayFormats: { day: 'MMM dd' }
572
+ }
515
573
  }
516
574
  }
517
575
  }
@@ -603,6 +661,12 @@ __decorate([
603
661
  __decorate([
604
662
  property({ type: String, attribute: 'splits' })
605
663
  ], TembaChart.prototype, "splitNames", void 0);
664
+ __decorate([
665
+ property({ type: String })
666
+ ], TembaChart.prototype, "xType", void 0);
667
+ __decorate([
668
+ property({ type: String })
669
+ ], TembaChart.prototype, "yType", void 0);
606
670
  __decorate([
607
671
  property({ type: Boolean })
608
672
  ], TembaChart.prototype, "hideOther", void 0);
@@ -621,9 +685,6 @@ __decorate([
621
685
  __decorate([
622
686
  property({ type: Boolean })
623
687
  ], TembaChart.prototype, "config", void 0);
624
- __decorate([
625
- property({ type: Boolean })
626
- ], TembaChart.prototype, "formatDuration", void 0);
627
688
  __decorate([
628
689
  property({ type: Boolean })
629
690
  ], TembaChart.prototype, "showAll", void 0);
@@ -645,4 +706,7 @@ __decorate([
645
706
  __decorate([
646
707
  property({ type: Number })
647
708
  ], TembaChart.prototype, "seriesBorderWidth", void 0);
709
+ __decorate([
710
+ property({ type: Boolean, attribute: 'percent' })
711
+ ], TembaChart.prototype, "showPercent", void 0);
648
712
  //# sourceMappingURL=TembaChart.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TembaChart.js","sourceRoot":"","sources":["../../../src/chart/TembaChart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EA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AAS;QACT,SAAS;QACT,SAAS;KACV;IACD,oBAAoB,EAAE;QACpB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,gBAAgB,EAAE;QAChB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,kBAAkB,EAAE;QAClB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,gBAAgB,EAAE;QAChB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IAED,8CAA8C;IAC9C,kBAAkB,EAAE;QAClB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,mBAAmB,EAAE;QACnB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,oBAAoB,EAAE;QACpB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,oBAAoB,EAAE;QACpB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,iBAAiB,EAAE;QACjB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS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,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACJ;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACJ;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDACI;AAGhC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACH;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACJ;AAGvB;IADC,KAAK,EAAE;8CACoB;AAG5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACU;AAGrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACG","sourcesContent":["import { RapidElement } from '../RapidElement';\nimport { property, state } from 'lit/decorators.js';\nimport { css, html, PropertyValueMap, TemplateResult } from 'lit';\n\nimport { Select, SelectOption } from '../select/Select';\nimport { darkenColor, getClasses } from '../utils';\nimport { getStore } from '../store/Store';\n\n// eslint-disable-next-line import/no-named-as-default\nimport Chart, { ChartType } from 'chart.js/auto';\nimport 'chartjs-adapter-luxon';\n\nconst DEFAULT_PALETTE: keyof typeof COLOR_PALETTES = 'qualitative-set1';\nconst COLOR_PALETTES = {\n // Qualitative (categorical, no order)\n 'qualitative-set1': [\n '#5ea3db',\n '#c186e3',\n '#66c2a5',\n '#fc8d62',\n '#a6d854',\n '#ffd92f',\n '#e5c494',\n '#b3b3b3'\n ],\n 'qualitative-set2': [\n '#377eb8',\n '#984ea3',\n '#4daf4a',\n '#ff7f00',\n '#e41a1c',\n '#a65628',\n '#f781bf',\n '#ffff33'\n ],\n 'qualitative-set3': [\n '#1b9e77',\n '#d95f02',\n '#7570b3',\n '#e7298a',\n '#66a61e',\n '#e6ab02',\n '#a6761d'\n ],\n 'qualitative-paired': [\n '#1f78b4',\n '#a6cee3',\n '#6a3d9a',\n '#cab2d6',\n '#33a02c',\n '#b2df8a',\n '#e31a1c',\n '#fb9a99',\n '#ff7f00',\n '#fdbf6f'\n ],\n 'qualitative-accent': [\n '#7fc97f',\n '#beaed4',\n '#fdc086',\n '#ffff99',\n '#386cb0',\n '#f0027f',\n '#bf5b17',\n '#666666'\n ],\n 'qualitative-pastel1': [\n '#fbb4ae',\n '#b3cde3',\n '#ccebc5',\n '#decbe4',\n '#fed9a6',\n '#ffffcc',\n '#e5d8bd',\n '#fddaec'\n ],\n 'qualitative-pastel2': [\n '#b3e2cd',\n '#fdcdac',\n '#cbd5e8',\n '#f4cae4',\n '#e6f5c9',\n '#fff2ae',\n '#f1e2cc'\n ],\n // Diverging (for data with midpoint like 0)\n 'diverging-prgn': [\n '#40004b',\n '#762a83',\n '#9970ab',\n '#c2a5cf',\n '#e7d4e8',\n '#f7f7f7',\n '#d9f0d3',\n '#a6dba0',\n '#5aae61',\n '#1b7837',\n '#00441b'\n ],\n 'diverging-spectral': [\n '#9e0142',\n '#d53e4f',\n '#f46d43',\n '#fdae61',\n '#fee08b',\n '#ffffbf',\n '#e6f598',\n '#abdda4',\n '#66c2a5',\n '#3288bd',\n '#5e4fa2'\n ],\n 'diverging-piyg': [\n '#8e0152',\n '#c51b7d',\n '#de77ae',\n '#f1b6da',\n '#fde0ef',\n '#f7f7f7',\n '#e6f5d0',\n '#b8e186',\n '#7fbc41',\n '#4d9221',\n '#276419'\n ],\n 'diverging-rdylgn': [\n '#a50026',\n '#d73027',\n '#f46d43',\n '#fdae61',\n '#fee08b',\n '#ffffbf',\n '#d9ef8b',\n '#a6d96a',\n '#66bd63',\n '#1a9850',\n '#006837'\n ],\n 'diverging-brbg': [\n '#543005',\n '#8c510a',\n '#bf812d',\n '#dfc27d',\n '#f6e8c3',\n '#f5f5f5',\n '#c7eae5',\n '#80cdc1',\n '#35978f',\n '#01665e',\n '#003c30'\n ],\n\n // Sequential (for continuous or ordered data)\n 'sequential-blues': [\n '#f7fbff',\n '#deebf7',\n '#c6dbef',\n '#9ecae1',\n '#6baed6',\n '#4292c6',\n '#2171b5',\n '#08519c',\n '#08306b'\n ],\n 'sequential-greens': [\n '#f7fcf5',\n '#e5f5e0',\n '#c7e9c0',\n '#a1d99b',\n '#74c476',\n '#41ab5d',\n '#238b45',\n '#006d2c',\n '#00441b'\n ],\n 'sequential-oranges': [\n '#fff5eb',\n '#fee6ce',\n '#fdd0a2',\n '#fdae6b',\n '#fd8d3c',\n '#f16913',\n '#d94801',\n '#a63603',\n '#7f2704'\n ],\n 'sequential-purples': [\n '#fcfbfd',\n '#efedf5',\n '#dadaeb',\n '#bcbddc',\n '#9e9ac8',\n '#807dba',\n '#6a51a3',\n '#54278f',\n '#3f007d'\n ],\n 'sequential-reds': [\n '#fff5f0',\n '#fee0d2',\n '#fcbba1',\n '#fc9272',\n '#fb6a4a',\n '#ef3b2c',\n '#cb181d',\n '#a50f15',\n '#67000d'\n ],\n 'sequential-ylgnbu': [\n '#ffffd9',\n '#edf8b1',\n '#c7e9b4',\n '#7fcdbb',\n '#41b6c4',\n '#1d91c0',\n '#225ea8',\n '#253494',\n '#081d58'\n ]\n};\n\nconst otherBackgroundColor = 'rgba(212, 212, 212, 0.5)';\n\n/**\n * Formats a duration in seconds to a human-readable string showing the two largest units.\n * Examples: 68787 -> \"19h 6m\", 958000 -> \"11d 2h\", 3661 -> \"1h 1m\"\n */\nexport function formatDurationFromSeconds(seconds: number): string {\n if (seconds === 0) {\n return '0s';\n }\n\n const totalDays = Math.floor(seconds / 86400);\n const remainingAfterDays = seconds % 86400;\n const remainingHours = Math.floor(remainingAfterDays / 3600);\n const remainingAfterHours = remainingAfterDays % 3600;\n const remainingMinutes = Math.floor(remainingAfterHours / 60);\n const remainingSeconds = remainingAfterHours % 60;\n\n const units = [];\n\n if (totalDays > 0) {\n units.push(`${totalDays}d`);\n }\n if (remainingHours > 0) {\n units.push(`${remainingHours}h`);\n }\n if (remainingMinutes > 0 && units.length < 2) {\n units.push(`${remainingMinutes}m`);\n }\n if (remainingSeconds > 0 && units.length < 2) {\n units.push(`${remainingSeconds}s`);\n }\n\n // Return the first two most significant units\n return units.slice(0, 2).join(' ');\n}\n\nexport interface RapidChartData {\n labels: string[];\n datasets: { label: string; data: number[] }[];\n}\n\nexport class TembaChart extends RapidElement {\n @property({ type: String })\n chartType: ChartType = 'bar';\n\n @property({ type: String })\n url: string;\n\n @property({ type: String })\n header: string = '';\n\n @property({ type: Boolean })\n other: boolean = false;\n\n @property({ type: Object })\n data: RapidChartData;\n\n @state()\n datasets: { label: string; data: number[] }[] = [];\n\n @property({ type: Number })\n maxSplits: number = 2;\n\n @property({ type: String, attribute: 'splits' })\n splitNames: string;\n\n @property({ type: Boolean })\n hideOther: boolean = false;\n\n @state()\n splits: string[] = [];\n\n @property({ type: String })\n dataname = 'Counts';\n\n @property({ type: Boolean })\n single: boolean = false;\n\n @property({ type: Boolean })\n legend: boolean = false;\n\n @property({ type: Boolean })\n config: boolean = false;\n\n @property({ type: Boolean })\n formatDuration: boolean = false;\n\n @property({ type: Boolean })\n showAll: boolean = false;\n\n @property({ type: Number })\n colorIndex: number = 0;\n\n @state()\n showConfig: boolean = false;\n\n @property({ type: String })\n palette: keyof typeof COLOR_PALETTES;\n\n @property({ type: Number })\n opacity: number = 1;\n\n @property({ type: Number })\n seriesBorderRadius: number = 2;\n\n @property({ type: Number })\n seriesBorderWidth: number = 1;\n\n chart: Chart;\n shadowRootDiv: HTMLDivElement;\n canvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n\n static get styles() {\n return css`\n .chart-title {\n font-size: 1.2em;\n font-weight: 600;\n text-align: center;\n }\n\n temba-select {\n display: block;\n }\n\n .config-toggle {\n margin-top: -2.5em;\n margin-right: -0.5em;\n color: #bbb;\n display: none;\n }\n\n .config-toggle:hover {\n color: #666;\n }\n\n .config-toggle.show {\n color: #666;\n display: block;\n }\n\n .config {\n max-height: 0px;\n padding: 0em 1em;\n border-radius: var(--curvature);\n border: 1px solid transparent;\n background: transparent;\n overflow: hidden;\n transition: all 0.2s ease-in-out;\n }\n\n .config.show {\n padding: 2em 1em 1.5em 1em;\n max-height: 50px;\n }\n `;\n }\n\n constructor() {\n super();\n }\n\n protected firstUpdated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.firstUpdated(changes);\n const wrapper = this.shadowRoot.querySelector('#canvas-wrapper');\n this.canvas = document.createElement('canvas');\n this.canvas.setAttribute('height', '300px');\n wrapper.appendChild(this.canvas);\n this.ctx = this.canvas.getContext('2d');\n }\n\n protected updated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.updated(changes);\n\n if (changes.has('splitNames')) {\n this.splits = this.splitNames.split(',').map((s) => s.trim());\n }\n\n if (changes.has('data') || changes.has('splits')) {\n this.calculateSplits();\n }\n\n if (changes.has('datasets')) {\n this.updateChart();\n }\n\n if (changes.has('url')) {\n const store = getStore();\n store.getUrl(this.url, { skipCache: true }).then((response) => {\n this.data = response.json.data;\n });\n }\n\n if (changes.has('chartType')) {\n if (this.chartType === 'line') {\n this.seriesBorderWidth = Math.max(1, this.seriesBorderWidth);\n }\n }\n }\n\n /**\n * Returns a tuple: [backgroundColors[], borderColors[]].\n * Border colors are darkened versions of the base palette (before transparency).\n * Background colors have transparency applied.\n */\n get colors(): [string[], string[]] {\n const baseColors =\n COLOR_PALETTES[this.palette] || COLOR_PALETTES[DEFAULT_PALETTE];\n // Clamp transparency between 0 and 1\n const alpha = Math.max(0, Math.min(1, this.opacity));\n // Borders: darken base color, no transparency\n const borderColors = baseColors.map((color) => darkenColor(color, 0.25));\n // Backgrounds: apply transparency to base color\n const backgroundColors = baseColors.map((color) => {\n // If already rgba, just replace the alpha\n if (color.startsWith('rgba')) {\n return color.replace(\n /rgba\\(([^,]+),([^,]+),([^,]+),([^)]+)\\)/,\n (_m, r, g, b) => {\n return `rgba(${r},${g},${b},${alpha})`;\n }\n );\n }\n // If already rgb, convert to rgba\n if (color.startsWith('rgb(')) {\n return color.replace(\n /rgb\\(([^,]+),([^,]+),([^,]+)\\)/,\n (_m, r, g, b) => {\n return `rgba(${r},${g},${b},${alpha})`;\n }\n );\n }\n // If hex, convert to rgba\n if (color.startsWith('#')) {\n let hex = color.replace('#', '');\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((c) => c + c)\n .join('');\n }\n const num = parseInt(hex, 16);\n const r = (num >> 16) & 255;\n const g = (num >> 8) & 255;\n const b = num & 255;\n return `rgba(${r},${g},${b},${alpha})`;\n }\n // fallback\n return color;\n });\n return [backgroundColors, borderColors];\n }\n\n /**\n * Utility to darken an rgba or hex color by a given factor (0-1).\n */\n\n private calculateSplits() {\n if (this.data) {\n const datasets = [];\n const sums = [];\n // Get color arrays\n const [backgroundColors, borderColors] = this.colors;\n for (const dataset of this.data.datasets) {\n if (\n !this.showAll &&\n this.splits.find((s) => s === dataset.label) === undefined\n ) {\n for (let i = 0; i < dataset.data.length; i++) {\n if (sums[i] === undefined) {\n sums[i] = dataset.data[i];\n } else {\n sums[i] += dataset.data[i];\n }\n }\n } else {\n const colorIdx =\n (datasets.length + this.colorIndex) % backgroundColors.length;\n const bgColor = backgroundColors[colorIdx];\n const borderColor = borderColors[colorIdx];\n datasets.push({\n ...dataset,\n backgroundColor: bgColor,\n borderColor,\n borderWidth: this.seriesBorderWidth,\n borderRadius: this.seriesBorderRadius\n });\n }\n }\n\n if (datasets.length === 0) {\n const idx = this.colorIndex % backgroundColors.length;\n datasets.push({\n label: this.single ? this.dataname : `All ${this.dataname}`,\n data: sums,\n backgroundColor: backgroundColors[idx],\n borderColor: borderColors[idx],\n borderWidth: this.seriesBorderWidth,\n borderRadius: this.seriesBorderRadius\n });\n } else {\n if (!this.hideOther && !this.showAll) {\n datasets.push({\n label: 'Other',\n data: sums,\n backgroundColor: otherBackgroundColor,\n borderColor: darkenColor(otherBackgroundColor, 0.05),\n borderWidth: 1,\n borderRadius: this.seriesBorderRadius\n });\n }\n }\n this.datasets = datasets;\n }\n }\n\n public updateChart(): void {\n if (this.datasets?.length > 0) {\n if (this.chart) {\n this.chart.data.labels = this.data.labels;\n this.chart.data.datasets = this.datasets;\n this.chart.update();\n } else {\n const chartData = {\n type: this.chartType,\n data: {\n labels: this.data.labels,\n datasets: this.datasets\n },\n options: {\n plugins: {\n legend: {\n display: this.legend\n },\n ...(this.formatDuration && {\n tooltip: {\n callbacks: {\n label: (context: any) => {\n const label = context.dataset.label || '';\n const value = context.parsed.y;\n const formattedValue = formatDurationFromSeconds(value);\n return `${label}: ${formattedValue}`;\n }\n }\n }\n })\n },\n responsive: true,\n maintainAspectRatio: false,\n animation: {\n x: { from: 500 },\n y: { from: 500 }\n },\n scales: {\n y: {\n min: 0,\n stacked: true,\n ...(this.formatDuration && {\n ticks: {\n callback: (value: any) => {\n return formatDurationFromSeconds(value);\n }\n }\n }),\n grid: { color: 'rgba(0,0,0,0.04)' }\n },\n x: {\n type: 'time',\n time: {\n unit: 'day',\n tooltipFormat: 'DDD', // Luxon for 'Feb 16, 2025'\n displayFormats: {\n day: 'MMM dd'\n }\n },\n grid: {\n display: false\n },\n stacked: true\n }\n }\n }\n };\n this.chart = new Chart(this.ctx, chartData as any);\n }\n }\n }\n\n private handleSplitsChanged(e: Event) {\n const select = e.target as Select<SelectOption>;\n this.splits = select.values.map((option) => {\n return option.value;\n });\n }\n\n private handleToggleConfig() {\n this.showConfig = !this.showConfig;\n if (!this.showConfig) {\n this.splits = [];\n }\n }\n\n protected render(): TemplateResult {\n return html`<div>\n ${this.header\n ? html`<div class=\"chart-title\">${this.header}</div>`\n : null}\n <div id=\"canvas-wrapper\"></div>\n ${this.config && this.data\n ? html`\n <div\n class=\"${getClasses({\n 'config-toggle': true,\n show: this.showConfig && this.data?.datasets?.length > 1\n })}\"\n style=\"display: flex; flex-direction: row; align-items: center; justify-content: space-between;\"\n >\n <div></div>\n <div>\n <temba-icon\n animateChange=\"spin\"\n name=\"${this.showConfig ? 'close' : 'settings'}\"\n clickable\n size=\"1.5\"\n @click=${this.handleToggleConfig}\n ></temba-icon>\n </div>\n </div>\n `\n : null}\n\n <div class=${getClasses({ config: true, show: this.showConfig })}>\n <temba-select\n multi\n placeholder=\"Select ${this.dataname}\"\n options=${JSON.stringify(\n this.data?.datasets.map((dataset) => ({\n name: dataset.label,\n value: dataset.label\n }))\n )}\n .values=${this.splits.map((s) => ({ name: s, value: s }))}\n @change=${this.handleSplitsChanged}\n >\n </temba-select>\n <div></div>\n </div>\n </div>`;\n }\n}\n"]}
1
+ {"version":3,"file":"TembaChart.js","sourceRoot":"","sources":["../../../src/chart/TembaChart.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoC,MAAM,KAAK,CAAC;AAGlE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,sDAAsD;AACtD,OAAO,KAAoB,MAAM,eAAe,CAAC;AACjD,OAAO,uBAAuB,CAAC;AAC/B,OAAO,eAAe,MAAM,2BAA2B,CAAC;AAExD,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAEhC,MAAM,eAAe,GAAgC,kBAAkB,CAAC;AACxE,MAAM,cAAc,GAAG;IACrB,sCAAsC;IACtC,kBAAkB,EAAE;QAClB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,kBAAkB,EAAE;QAClB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,kBAAkB,EAAE;QAClB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,oBAAoB,EAAE;QACpB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,oBAAoB,EAAE;QACpB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,qBAAqB,EAAE;QACrB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,qBAAqB,EAAE;QACrB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,4CAA4C;IAC5C,gBAAgB,EAAE;QAChB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,oBAAoB,EAAE;QACpB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,gBAAgB,EAAE;QAChB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,kBAAkB,EAAE;QAClB,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IACD,gBAAgB,EAAE;QAChB,SAAS;QACT,SAAS;QACT,SAAS;QACT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E,MAAM,EAAE,CAAC;yCACa;AAGxC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCACW;AAGtC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CACD;AAG3B;IADC,KAAK,EAAE;0CACc;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACJ;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACJ;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;0CACJ;AAGxB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2CACH;AAGzB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACJ;AAGvB;IADC,KAAK,EAAE;8CACoB;AAG5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACU;AAGrC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2CACP;AAGpB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDACI;AAG/B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDACG;AAG9B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;+CACrB","sourcesContent":["import { RapidElement } from '../RapidElement';\nimport { property, state } from 'lit/decorators.js';\nimport { css, html, PropertyValueMap, TemplateResult } from 'lit';\n\nimport { Select, SelectOption } from '../select/Select';\nimport { darkenColor, getClasses } from '../utils';\nimport { getStore } from '../store/Store';\n\n// eslint-disable-next-line import/no-named-as-default\nimport Chart, { ChartType } from 'chart.js/auto';\nimport 'chartjs-adapter-luxon';\nimport ChartDataLabels from 'chartjs-plugin-datalabels';\n\nChart.register(ChartDataLabels);\n\nconst DEFAULT_PALETTE: keyof typeof COLOR_PALETTES = 'qualitative-set1';\nconst COLOR_PALETTES = {\n // Qualitative (categorical, no order)\n 'qualitative-set1': [\n '#5ea3db',\n '#c186e3',\n '#66c2a5',\n '#fc8d62',\n '#a6d854',\n '#ffd92f',\n '#e5c494',\n '#b3b3b3'\n ],\n 'qualitative-set2': [\n '#377eb8',\n '#984ea3',\n '#4daf4a',\n '#ff7f00',\n '#e41a1c',\n '#a65628',\n '#f781bf',\n '#ffff33'\n ],\n 'qualitative-set3': [\n '#1b9e77',\n '#d95f02',\n '#7570b3',\n '#e7298a',\n '#66a61e',\n '#e6ab02',\n '#a6761d'\n ],\n 'qualitative-paired': [\n '#1f78b4',\n '#a6cee3',\n '#6a3d9a',\n '#cab2d6',\n '#33a02c',\n '#b2df8a',\n '#e31a1c',\n '#fb9a99',\n '#ff7f00',\n '#fdbf6f'\n ],\n 'qualitative-accent': [\n '#7fc97f',\n '#beaed4',\n '#fdc086',\n '#ffff99',\n '#386cb0',\n '#f0027f',\n '#bf5b17',\n '#666666'\n ],\n 'qualitative-pastel1': [\n '#fbb4ae',\n '#b3cde3',\n '#ccebc5',\n '#decbe4',\n '#fed9a6',\n '#ffffcc',\n '#e5d8bd',\n '#fddaec'\n ],\n 'qualitative-pastel2': [\n '#b3e2cd',\n '#fdcdac',\n '#cbd5e8',\n '#f4cae4',\n '#e6f5c9',\n '#fff2ae',\n '#f1e2cc'\n ],\n // Diverging (for data with midpoint like 0)\n 'diverging-prgn': [\n '#40004b',\n '#762a83',\n '#9970ab',\n '#c2a5cf',\n '#e7d4e8',\n '#f7f7f7',\n '#d9f0d3',\n '#a6dba0',\n '#5aae61',\n '#1b7837',\n '#00441b'\n ],\n 'diverging-spectral': [\n '#9e0142',\n '#d53e4f',\n '#f46d43',\n '#fdae61',\n '#fee08b',\n '#ffffbf',\n '#e6f598',\n '#abdda4',\n '#66c2a5',\n '#3288bd',\n '#5e4fa2'\n ],\n 'diverging-piyg': [\n '#8e0152',\n '#c51b7d',\n '#de77ae',\n '#f1b6da',\n '#fde0ef',\n '#f7f7f7',\n '#e6f5d0',\n '#b8e186',\n '#7fbc41',\n '#4d9221',\n '#276419'\n ],\n 'diverging-rdylgn': [\n '#a50026',\n '#d73027',\n '#f46d43',\n '#fdae61',\n '#fee08b',\n '#ffffbf',\n '#d9ef8b',\n '#a6d96a',\n '#66bd63',\n '#1a9850',\n '#006837'\n ],\n 'diverging-brbg': [\n '#543005',\n '#8c510a',\n '#bf812d',\n '#dfc27d',\n '#f6e8c3',\n '#f5f5f5',\n '#c7eae5',\n '#80cdc1',\n '#35978f',\n '#01665e',\n '#003c30'\n ],\n\n // Sequential (for continuous or ordered data)\n 'sequential-blues': [\n '#f7fbff',\n '#deebf7',\n '#c6dbef',\n '#9ecae1',\n '#6baed6',\n '#4292c6',\n '#2171b5',\n '#08519c',\n '#08306b'\n ],\n 'sequential-greens': [\n '#f7fcf5',\n '#e5f5e0',\n '#c7e9c0',\n '#a1d99b',\n '#74c476',\n '#41ab5d',\n '#238b45',\n '#006d2c',\n '#00441b'\n ],\n 'sequential-oranges': [\n '#fff5eb',\n '#fee6ce',\n '#fdd0a2',\n '#fdae6b',\n '#fd8d3c',\n '#f16913',\n '#d94801',\n '#a63603',\n '#7f2704'\n ],\n 'sequential-purples': [\n '#fcfbfd',\n '#efedf5',\n '#dadaeb',\n '#bcbddc',\n '#9e9ac8',\n '#807dba',\n '#6a51a3',\n '#54278f',\n '#3f007d'\n ],\n 'sequential-reds': [\n '#fff5f0',\n '#fee0d2',\n '#fcbba1',\n '#fc9272',\n '#fb6a4a',\n '#ef3b2c',\n '#cb181d',\n '#a50f15',\n '#67000d'\n ],\n 'sequential-ylgnbu': [\n '#ffffd9',\n '#edf8b1',\n '#c7e9b4',\n '#7fcdbb',\n '#41b6c4',\n '#1d91c0',\n '#225ea8',\n '#253494',\n '#081d58'\n ]\n};\n\nconst otherBackgroundColor = 'rgba(212, 212, 212, 0.5)';\n\n/**\n * Formats a duration in seconds to a human-readable string showing the two largest units.\n * Examples: 68787 -> \"19h 6m\", 958000 -> \"11d 2h\", 3661 -> \"1h 1m\"\n */\nexport function formatDurationFromSeconds(seconds: number): string {\n if (seconds === 0) {\n return '0s';\n }\n\n const totalDays = Math.floor(seconds / 86400);\n const remainingAfterDays = seconds % 86400;\n const remainingHours = Math.floor(remainingAfterDays / 3600);\n const remainingAfterHours = remainingAfterDays % 3600;\n const remainingMinutes = Math.floor(remainingAfterHours / 60);\n const remainingSeconds = remainingAfterHours % 60;\n\n const units = [];\n\n if (totalDays > 0) {\n units.push(`${totalDays}d`);\n }\n if (remainingHours > 0) {\n units.push(`${remainingHours}h`);\n }\n if (remainingMinutes > 0 && units.length < 2) {\n units.push(`${remainingMinutes}m`);\n }\n if (remainingSeconds > 0 && units.length < 2) {\n units.push(`${remainingSeconds}s`);\n }\n\n // Return the first two most significant units\n return units.slice(0, 2).join(' ');\n}\n\nexport interface RapidChartData {\n labels: string[];\n datasets: { label: string; data: number[] }[];\n}\n\nexport class TembaChart extends RapidElement {\n @property({ type: String })\n chartType: ChartType = 'bar';\n\n @property({ type: String })\n url: string;\n\n @property({ type: String })\n header: string = '';\n\n @property({ type: Boolean })\n other: boolean = false;\n\n @property({ type: Object })\n data: RapidChartData;\n\n @state()\n datasets: { label: string; data: number[] }[] = [];\n\n @property({ type: Number })\n maxSplits: number = 2;\n\n @property({ type: String, attribute: 'splits' })\n splitNames: string;\n\n @property({ type: String })\n xType: 'category' | 'time' = 'category';\n\n @property({ type: String })\n yType: 'count' | 'duration' = 'count';\n\n @property({ type: Boolean })\n hideOther: boolean = false;\n\n @state()\n splits: string[] = [];\n\n @property({ type: String })\n dataname = 'Counts';\n\n @property({ type: Boolean })\n single: boolean = false;\n\n @property({ type: Boolean })\n legend: boolean = false;\n\n @property({ type: Boolean })\n config: boolean = false;\n\n @property({ type: Boolean })\n showAll: boolean = false;\n\n @property({ type: Number })\n colorIndex: number = 0;\n\n @state()\n showConfig: boolean = false;\n\n @property({ type: String })\n palette: keyof typeof COLOR_PALETTES;\n\n @property({ type: Number })\n opacity: number = 1;\n\n @property({ type: Number })\n seriesBorderRadius: number = 2;\n\n @property({ type: Number })\n seriesBorderWidth: number = 1;\n\n @property({ type: Boolean, attribute: 'percent' })\n showPercent: boolean = false;\n\n // head-room for labels when percentages are visible\n private getInflatedMax(): number | undefined {\n if (!this.showPercent || !this.data) return undefined;\n\n // total stacked value for each x-index\n const totals: number[] = Array(this.data.labels.length).fill(0);\n for (const ds of this.datasets) {\n ds.data.forEach((v, i) => (totals[i] += v));\n }\n const maxStack = Math.max(...totals);\n return maxStack > 0 ? maxStack * 1.15 : undefined;\n }\n\n chart: Chart;\n shadowRootDiv: HTMLDivElement;\n canvas: HTMLCanvasElement;\n ctx: CanvasRenderingContext2D;\n\n static get styles() {\n return css`\n .chart-title {\n font-size: 1.2em;\n font-weight: 600;\n text-align: center;\n }\n\n temba-select {\n display: block;\n }\n\n .config-toggle {\n margin-top: -2.5em;\n margin-right: -0.5em;\n color: #bbb;\n display: none;\n }\n\n .config-toggle:hover {\n color: #666;\n }\n\n .config-toggle.show {\n color: #666;\n display: block;\n }\n\n .config {\n max-height: 0px;\n padding: 0em 1em;\n border-radius: var(--curvature);\n border: 1px solid transparent;\n background: transparent;\n overflow: hidden;\n transition: all 0.2s ease-in-out;\n }\n\n .config.show {\n padding: 2em 1em 1.5em 1em;\n max-height: 50px;\n }\n `;\n }\n\n constructor() {\n super();\n }\n\n protected firstUpdated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.firstUpdated(changes);\n const wrapper = this.shadowRoot.querySelector('#canvas-wrapper');\n this.canvas = document.createElement('canvas');\n this.canvas.setAttribute('height', '300px');\n wrapper.appendChild(this.canvas);\n this.ctx = this.canvas.getContext('2d');\n }\n\n protected updated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.updated(changes);\n\n if (changes.has('splitNames')) {\n this.splits = this.splitNames.split(',').map((s) => s.trim());\n }\n\n if (changes.has('data') || changes.has('splits')) {\n this.calculateSplits();\n }\n\n if (changes.has('datasets')) {\n this.updateChart();\n }\n\n if (changes.has('url')) {\n const store = getStore();\n store.getUrl(this.url, { skipCache: true }).then((response) => {\n this.data = response.json.data;\n });\n }\n\n if (changes.has('chartType')) {\n if (this.chartType === 'line') {\n this.seriesBorderWidth = Math.max(1, this.seriesBorderWidth);\n }\n }\n\n if (changes.has('showPercent') && this.chart) {\n const yScale = (this.chart.options.scales as any).y;\n yScale.ticks.display = !this.showPercent;\n yScale.grid.display = !this.showPercent;\n yScale.border.display = !this.showPercent;\n yScale.max = this.showPercent ? this.getInflatedMax() : undefined;\n this.chart.update();\n }\n }\n\n /**\n * Returns a tuple: [backgroundColors[], borderColors[]].\n * Border colors are darkened versions of the base palette (before transparency).\n * Background colors have transparency applied.\n */\n get colors(): [string[], string[]] {\n const baseColors =\n COLOR_PALETTES[this.palette] || COLOR_PALETTES[DEFAULT_PALETTE];\n // clamp transparency between 0 and 1\n const alpha = Math.max(0, Math.min(1, this.opacity));\n // borders darken base color, no transparency\n const borderColors = baseColors.map((color) => darkenColor(color, 0.25));\n // backgrounds apply transparency to base color\n const backgroundColors = baseColors.map((color) => {\n // if already rgba, just replace the alpha\n if (color.startsWith('rgba')) {\n return color.replace(\n /rgba\\(([^,]+),([^,]+),([^,]+),([^)]+)\\)/,\n (_m, r, g, b) => {\n return `rgba(${r},${g},${b},${alpha})`;\n }\n );\n }\n // if already rgb, convert to rgba\n if (color.startsWith('rgb(')) {\n return color.replace(\n /rgb\\(([^,]+),([^,]+),([^,]+)\\)/,\n (_m, r, g, b) => {\n return `rgba(${r},${g},${b},${alpha})`;\n }\n );\n }\n // if hex, convert to rgba\n if (color.startsWith('#')) {\n let hex = color.replace('#', '');\n if (hex.length === 3) {\n hex = hex\n .split('')\n .map((c) => c + c)\n .join('');\n }\n const num = parseInt(hex, 16);\n const r = (num >> 16) & 255;\n const g = (num >> 8) & 255;\n const b = num & 255;\n return `rgba(${r},${g},${b},${alpha})`;\n }\n // fallback\n return color;\n });\n return [backgroundColors, borderColors];\n }\n\n private calculateSplits() {\n if (this.data) {\n const datasets = [];\n const sums = [];\n const [backgroundColors, borderColors] = this.colors;\n for (const dataset of this.data.datasets) {\n if (\n !this.showAll &&\n this.splits.find((s) => s === dataset.label) === undefined\n ) {\n for (let i = 0; i < dataset.data.length; i++) {\n if (sums[i] === undefined) {\n sums[i] = dataset.data[i];\n } else {\n sums[i] += dataset.data[i];\n }\n }\n } else {\n const colorIdx =\n (datasets.length + this.colorIndex) % backgroundColors.length;\n const bgColor = backgroundColors[colorIdx];\n const borderColor = borderColors[colorIdx];\n datasets.push({\n ...dataset,\n backgroundColor: bgColor,\n borderColor,\n borderWidth: this.seriesBorderWidth,\n borderRadius: this.seriesBorderRadius\n });\n }\n }\n\n if (datasets.length === 0) {\n const idx = this.colorIndex % backgroundColors.length;\n datasets.push({\n label: this.single ? this.dataname : `All ${this.dataname}`,\n data: sums,\n backgroundColor: backgroundColors[idx],\n borderColor: borderColors[idx],\n borderWidth: this.seriesBorderWidth,\n borderRadius: this.seriesBorderRadius\n });\n } else {\n if (!this.hideOther && !this.showAll) {\n datasets.push({\n label: 'Other',\n data: sums,\n backgroundColor: otherBackgroundColor,\n borderColor: darkenColor(otherBackgroundColor, 0.05),\n borderWidth: 1,\n borderRadius: this.seriesBorderRadius\n });\n }\n }\n this.datasets = datasets;\n }\n }\n\n public updateChart(): void {\n if (this.datasets?.length > 0) {\n const grandTotal =\n this.datasets.reduce(\n (sum: number, ds: any) =>\n sum +\n (ds.data as number[]).reduce(\n (dsSum: number, v: number) => dsSum + (v ?? 0),\n 0\n ),\n 0\n ) || undefined;\n\n const percentFormatter = (value: number): string => {\n const pct = grandTotal ? (value / grandTotal) * 100 : 0;\n return `${Math.round(pct)}%`;\n };\n\n if (this.chart) {\n this.chart.data.labels = this.data.labels;\n this.chart.data.datasets = this.datasets;\n\n // update y-axis max dynamically\n if (this.showPercent) {\n (this.chart.options.scales as any).y.max = this.getInflatedMax();\n }\n\n const datalabels = this.chart.options.plugins.datalabels || {};\n datalabels.display = this.showPercent;\n if (this.showPercent) {\n datalabels.formatter = percentFormatter;\n } else {\n delete datalabels.formatter;\n }\n this.chart.options.plugins.datalabels = datalabels;\n\n this.chart.update();\n } else {\n const chartData = {\n type: this.chartType,\n data: {\n labels: this.data.labels,\n datasets: this.datasets\n },\n options: {\n maxBarThickness: 80,\n plugins: {\n legend: { display: this.legend },\n tooltip: {\n callbacks: {\n label: (context: any) => {\n const label = context.dataset.label || '';\n const value = context.parsed.y;\n if (this.yType === 'duration') {\n return `${label}: ${formatDurationFromSeconds(value)}`;\n }\n return `${label}: ${value}`;\n }\n }\n },\n datalabels: {\n display: this.showPercent,\n anchor: 'end',\n align: 'end',\n offset: -3,\n clamp: true,\n ...(this.showPercent && { formatter: percentFormatter }),\n color: '#666',\n font: { weight: '600' }\n }\n },\n responsive: true,\n maintainAspectRatio: false,\n animations: {\n x: {\n // no horizontal motion\n duration: 0\n },\n y: {\n duration: 200,\n easing: 'easeOutCubic'\n }\n },\n scales: {\n y: {\n min: 0,\n ...(this.showPercent && { max: this.getInflatedMax() }),\n stacked: true,\n grid: {\n color: 'rgba(0,0,0,0.04)',\n display: !this.showPercent, // hide gridlines in percent mode\n drawBorder: !this.showPercent // hides axis line when false\n },\n border: {\n display: !this.showPercent // Chart.js >= 4\n },\n ticks: {\n display: !this.showPercent,\n ...(this.yType === 'duration' &&\n !this.showPercent && {\n callback: (value: any) => formatDurationFromSeconds(value)\n })\n }\n },\n x: {\n type: this.xType,\n grid: { display: false },\n stacked: true,\n time: {\n unit: 'day',\n tooltipFormat: 'DDD',\n displayFormats: { day: 'MMM dd' }\n }\n }\n }\n }\n };\n\n this.chart = new Chart(this.ctx, chartData as any);\n }\n }\n }\n\n private handleSplitsChanged(e: Event) {\n const select = e.target as Select<SelectOption>;\n this.splits = select.values.map((option) => {\n return option.value;\n });\n }\n\n private handleToggleConfig() {\n this.showConfig = !this.showConfig;\n if (!this.showConfig) {\n this.splits = [];\n }\n }\n\n protected render(): TemplateResult {\n return html`<div>\n ${this.header\n ? html`<div class=\"chart-title\">${this.header}</div>`\n : null}\n <div id=\"canvas-wrapper\"></div>\n ${this.config && this.data\n ? html`\n <div\n class=\"${getClasses({\n 'config-toggle': true,\n show: this.showConfig && this.data?.datasets?.length > 1\n })}\"\n style=\"display: flex; flex-direction: row; align-items: center; justify-content: space-between;\"\n >\n <div></div>\n <div>\n <temba-icon\n animateChange=\"spin\"\n name=\"${this.showConfig ? 'close' : 'settings'}\"\n clickable\n size=\"1.5\"\n @click=${this.handleToggleConfig}\n ></temba-icon>\n </div>\n </div>\n `\n : null}\n\n <div class=${getClasses({ config: true, show: this.showConfig })}>\n <temba-select\n multi\n placeholder=\"Select ${this.dataname}\"\n options=${JSON.stringify(\n this.data?.datasets.map((dataset) => ({\n name: dataset.label,\n value: dataset.label\n }))\n )}\n .values=${this.splits.map((s) => ({ name: s, value: s }))}\n @change=${this.handleSplitsChanged}\n >\n </temba-select>\n <div></div>\n </div>\n </div>`;\n }\n}\n"]}
@@ -18,8 +18,9 @@ export class EditorNode extends RapidElement {
18
18
  min-width: 200px;
19
19
  border-radius: calc(var(--curvature) * 1.5);
20
20
  overflow: hidden;
21
+ color: #333;
21
22
  }
22
-
23
+
23
24
  .action {
24
25
  max-width: 200px;
25
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EditorNode.js","sourceRoot":"","sources":["../../../src/flow/EditorNode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoC,MAAM,KAAK,CAAC;AAClE,OAAO,EAAE,aAAa,EAAY,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAA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,EAAE;gBAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC,CAAC;mBACG;;KAEd,CAAC;IACJ,CAAC;CACF;AA5MS;IADP,KAAK,EAAE;2CACiB;AAGjB;IADP,KAAK,EAAE;wCACW;AAGX;IADP,KAAK,EAAE;sCACW","sourcesContent":["import { css, html, PropertyValueMap, TemplateResult } from 'lit';\nimport { EDITOR_CONFIG, UIConfig } from './config';\nimport { Action, Exit, Node, NodeUI, Router } from '../store/flow-definition';\nimport { state } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\nimport { Plumber } from './Plumber';\nimport { getStore } from '../store/Store';\n\nexport class EditorNode extends RapidElement {\n createRenderRoot() {\n return this;\n }\n\n @state()\n private plumber: Plumber;\n\n @state()\n private node: Node;\n\n @state()\n private ui: NodeUI;\n\n static get styles() {\n return css`\n .node {\n position: absolute;\n background-color: #fff;\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n min-width: 200px;\n border-radius: calc(var(--curvature) * 1.5);\n overflow: hidden;\n }\n\n .action {\n max-width: 200px;\n }\n\n .action .body {\n padding: 1em;\n }\n\n .action .title,\n .router .title {\n color: #fff;\n padding: 5px 1px;\n text-align: center;\n font-size: 1em;\n font-weight: normal;\n }\n\n .quick-replies {\n margin-top: 0.5em;\n }\n\n .quick-reply {\n background-color: #f0f0f0;\n border: 1px solid #e0e0e0;\n border-radius: calc(var(--curvature) * 1.5);\n padding: 0.2em 1em;\n display: inline-block;\n font-size: 0.8em;\n margin: 0.2em;\n }\n\n .categories {\n display: flex;\n flex-direction: row;\n\n }\n\n .category {\n margin:-1px -0.5px;\n border: 1px solid #f3f3f3;\n padding: 0.75em;\n flex-grow:1;\n text-align: center;\n }\n\n .action-exits {\n padding-bottom: 0.75em;\n margin-top: -0.75em;\n }\n\n .category .title {\n font-weight: normal;\n font-size: 1em;\n }\n\n .router .body {\n padding: 0.75em;\n }\n\n .result-name {\n font-weight: bold;\n display: inline-block;\n }\n \n .exit {\n padding-top: 10px;\n margin-bottom: -10px;\n }\n }`;\n }\n\n protected updated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.updated(changes);\n if (changes.has('node')) {\n this.plumber.makeTarget(this.node.uuid);\n\n // our node was changed, see if we have new destinations\n for (const exit of this.node.exits) {\n if (!exit.destination_uuid) {\n this.plumber.makeSource(exit.uuid);\n } else {\n this.plumber.connectIds(exit.uuid, exit.destination_uuid);\n }\n }\n\n const ele = this.querySelector('.node');\n const rect = ele.getBoundingClientRect();\n\n getStore()\n .getState()\n .expandCanvas(\n this.ui.position.left + rect.width,\n this.ui.position.top + rect.height\n );\n }\n }\n\n private renderTitle(config: UIConfig) {\n return html`<div class=\"title\" style=\"background:${config.color}\">\n ${config.name}\n </div>`;\n }\n\n private renderAction(node: Node, action: Action) {\n const config = EDITOR_CONFIG[action.type];\n\n if (config) {\n return html`<div class=\"action ${action.type}\">\n ${this.renderTitle(config)}\n <div class=\"body\">\n ${config.render\n ? config.render(node, action)\n : html`<pre>${action.type}</pre>`}\n </div>\n </div>`;\n }\n return html`<div>${action.type}</div>`;\n }\n\n private renderRouter(router: Router, ui: NodeUI) {\n const config = EDITOR_CONFIG[ui.type];\n if (config) {\n return html`<div class=\"router\">\n ${this.renderTitle(config)}\n ${router.result_name\n ? html`<div class=\"body\">\n Save as\n <div class=\"result-name\">${router.result_name}</div>\n </div>`\n : null}\n </div>`;\n }\n }\n\n private renderCategories(node: Node) {\n if (!node.router || !node.router.categories) {\n return null;\n }\n const categories = node.router.categories.map((category) => {\n const exit = node.exits.find(\n (exit: Exit) => exit.uuid == category.exit_uuid\n );\n\n return html`<div class=\"category\">\n <div class=\"title\">${category.name}</div>\n ${this.renderExit(exit)}\n </div>`;\n });\n\n return html`<div class=\"categories\">${categories}</div>`;\n }\n\n private renderExit(exit: Exit): TemplateResult {\n return html`<div\n id=\"${exit.uuid}\"\n class=${getClasses({\n exit: true,\n connected: !!exit.destination_uuid\n })}\n ></div>`;\n }\n\n public render() {\n return html`\n <div\n id=\"${this.node.uuid}\"\n class=\"node\"\n style=\"left:${this.ui.position.left}px;top:${this.ui.position.top}px\"\n >\n ${this.node.actions.map((actionSpec) => {\n return this.renderAction(this.node, actionSpec);\n })}\n ${this.node.router\n ? html` ${this.renderRouter(this.node.router, this.ui)}\n ${this.renderCategories(this.node)}`\n : html`<div class=\"action-exits\">\n ${this.node.exits.map((exit) => {\n return this.renderExit(exit);\n })}\n </div>`}\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"EditorNode.js","sourceRoot":"","sources":["../../../src/flow/EditorNode.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAoC,MAAM,KAAK,CAAC;AAClE,OAAO,EAAE,aAAa,EAAY,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,MAAM,OAAO,UAAW,SAAQ,YAAY;IAC1C,gBAAgB;QACd,OAAO,IAAI,CAAC;IACd,CAAC;IAWD,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+EV,CAAC;IACH,CAAC;IAES,OAAO,CACf,OAA0D;QAE1D,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAExC,wDAAwD;YACxD,K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AED,IAAI,CAAC,IAAI,CAAC,IAAI;;sBAEN,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG;;UAE/D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YACrC,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAClD,CAAC,CAAC;UACA,IAAI,CAAC,IAAI,CAAC,MAAM;YAChB,CAAC,CAAC,IAAI,CAAA,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;cAClD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YACtC,CAAC,CAAC,IAAI,CAAA;gBACA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC,CAAC;mBACG;;KAEd,CAAC;IACJ,CAAC;CACF;AA7MS;IADP,KAAK,EAAE;2CACiB;AAGjB;IADP,KAAK,EAAE;wCACW;AAGX;IADP,KAAK,EAAE;sCACW","sourcesContent":["import { css, html, PropertyValueMap, TemplateResult } from 'lit';\nimport { EDITOR_CONFIG, UIConfig } from './config';\nimport { Action, Exit, Node, NodeUI, Router } from '../store/flow-definition';\nimport { state } from 'lit/decorators.js';\nimport { RapidElement } from '../RapidElement';\nimport { getClasses } from '../utils';\nimport { Plumber } from './Plumber';\nimport { getStore } from '../store/Store';\n\nexport class EditorNode extends RapidElement {\n createRenderRoot() {\n return this;\n }\n\n @state()\n private plumber: Plumber;\n\n @state()\n private node: Node;\n\n @state()\n private ui: NodeUI;\n\n static get styles() {\n return css`\n .node {\n position: absolute;\n background-color: #fff;\n box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);\n min-width: 200px;\n border-radius: calc(var(--curvature) * 1.5);\n overflow: hidden;\n color: #333;\n }\n \n .action {\n max-width: 200px;\n }\n\n .action .body {\n padding: 1em;\n }\n\n .action .title,\n .router .title {\n color: #fff;\n padding: 5px 1px;\n text-align: center;\n font-size: 1em;\n font-weight: normal;\n }\n\n .quick-replies {\n margin-top: 0.5em;\n }\n\n .quick-reply {\n background-color: #f0f0f0;\n border: 1px solid #e0e0e0;\n border-radius: calc(var(--curvature) * 1.5);\n padding: 0.2em 1em;\n display: inline-block;\n font-size: 0.8em;\n margin: 0.2em;\n }\n\n .categories {\n display: flex;\n flex-direction: row;\n\n }\n\n .category {\n margin:-1px -0.5px;\n border: 1px solid #f3f3f3;\n padding: 0.75em;\n flex-grow:1;\n text-align: center;\n }\n\n .action-exits {\n padding-bottom: 0.75em;\n margin-top: -0.75em;\n }\n\n .category .title {\n font-weight: normal;\n font-size: 1em;\n }\n\n .router .body {\n padding: 0.75em;\n }\n\n .result-name {\n font-weight: bold;\n display: inline-block;\n }\n \n .exit {\n padding-top: 10px;\n margin-bottom: -10px;\n }\n }`;\n }\n\n protected updated(\n changes: PropertyValueMap<any> | Map<PropertyKey, unknown>\n ): void {\n super.updated(changes);\n if (changes.has('node')) {\n this.plumber.makeTarget(this.node.uuid);\n\n // our node was changed, see if we have new destinations\n for (const exit of this.node.exits) {\n if (!exit.destination_uuid) {\n this.plumber.makeSource(exit.uuid);\n } else {\n this.plumber.connectIds(exit.uuid, exit.destination_uuid);\n }\n }\n\n const ele = this.querySelector('.node');\n const rect = ele.getBoundingClientRect();\n\n getStore()\n .getState()\n .expandCanvas(\n this.ui.position.left + rect.width,\n this.ui.position.top + rect.height\n );\n }\n }\n\n private renderTitle(config: UIConfig) {\n return html`<div class=\"title\" style=\"background:${config.color}\">\n ${config.name}\n </div>`;\n }\n\n private renderAction(node: Node, action: Action) {\n const config = EDITOR_CONFIG[action.type];\n\n if (config) {\n return html`<div class=\"action ${action.type}\">\n ${this.renderTitle(config)}\n <div class=\"body\">\n ${config.render\n ? config.render(node, action)\n : html`<pre>${action.type}</pre>`}\n </div>\n </div>`;\n }\n return html`<div>${action.type}</div>`;\n }\n\n private renderRouter(router: Router, ui: NodeUI) {\n const config = EDITOR_CONFIG[ui.type];\n if (config) {\n return html`<div class=\"router\">\n ${this.renderTitle(config)}\n ${router.result_name\n ? html`<div class=\"body\">\n Save as\n <div class=\"result-name\">${router.result_name}</div>\n </div>`\n : null}\n </div>`;\n }\n }\n\n private renderCategories(node: Node) {\n if (!node.router || !node.router.categories) {\n return null;\n }\n const categories = node.router.categories.map((category) => {\n const exit = node.exits.find(\n (exit: Exit) => exit.uuid == category.exit_uuid\n );\n\n return html`<div class=\"category\">\n <div class=\"title\">${category.name}</div>\n ${this.renderExit(exit)}\n </div>`;\n });\n\n return html`<div class=\"categories\">${categories}</div>`;\n }\n\n private renderExit(exit: Exit): TemplateResult {\n return html`<div\n id=\"${exit.uuid}\"\n class=${getClasses({\n exit: true,\n connected: !!exit.destination_uuid\n })}\n ></div>`;\n }\n\n public render() {\n return html`\n <div\n id=\"${this.node.uuid}\"\n class=\"node\"\n style=\"left:${this.ui.position.left}px;top:${this.ui.position.top}px\"\n >\n ${this.node.actions.map((actionSpec) => {\n return this.renderAction(this.node, actionSpec);\n })}\n ${this.node.router\n ? html` ${this.renderRouter(this.node.router, this.ui)}\n ${this.renderCategories(this.node)}`\n : html`<div class=\"action-exits\">\n ${this.node.exits.map((exit) => {\n return this.renderExit(exit);\n })}\n </div>`}\n </div>\n `;\n }\n}\n"]}