@nyaruka/temba-components 0.31.4 → 0.31.7

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 (40) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{a4ce5e6b.js → 56002f06.js} +92 -15
  3. package/dist/index.js +92 -15
  4. package/dist/static/icons/symbol-defs.svg +7 -3
  5. package/dist/sw.js +1 -1
  6. package/dist/sw.js.map +1 -1
  7. package/dist/templates/components-body.html +1 -1
  8. package/dist/templates/components-head.html +1 -1
  9. package/out-tsc/src/contacts/ContactNameFetch.js +1 -1
  10. package/out-tsc/src/contacts/ContactNameFetch.js.map +1 -1
  11. package/out-tsc/src/contacts/events.js +1 -2
  12. package/out-tsc/src/contacts/events.js.map +1 -1
  13. package/out-tsc/src/dialog/Dialog.js +12 -1
  14. package/out-tsc/src/dialog/Dialog.js.map +1 -1
  15. package/out-tsc/src/interfaces.js.map +1 -1
  16. package/out-tsc/src/list/RunList.js +3 -2
  17. package/out-tsc/src/list/RunList.js.map +1 -1
  18. package/out-tsc/src/list/TembaMenu.js +102 -17
  19. package/out-tsc/src/list/TembaMenu.js.map +1 -1
  20. package/out-tsc/src/tabpane/TabPane.js +6 -0
  21. package/out-tsc/src/tabpane/TabPane.js.map +1 -1
  22. package/out-tsc/src/vectoricon/VectorIcon.js +2 -3
  23. package/out-tsc/src/vectoricon/VectorIcon.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/contacts/ContactNameFetch.ts +1 -1
  26. package/src/contacts/events.ts +1 -2
  27. package/src/dialog/Dialog.ts +12 -1
  28. package/src/interfaces.ts +1 -0
  29. package/src/list/RunList.ts +3 -2
  30. package/src/list/TembaMenu.ts +106 -17
  31. package/src/tabpane/TabPane.ts +6 -0
  32. package/src/vectoricon/VectorIcon.ts +2 -3
  33. package/static/icons/Read Me.txt +1 -1
  34. package/static/icons/SVG/menu-collapse.svg +5 -0
  35. package/static/icons/SVG/zapier.svg +2 -1
  36. package/static/icons/demo-external-svg.html +144 -139
  37. package/static/icons/demo-files/demo.css +4 -4
  38. package/static/icons/demo.html +151 -142
  39. package/static/icons/selection.json +250 -200
  40. package/static/icons/symbol-defs.svg +7 -3
@@ -17,6 +17,7 @@ export interface MenuItem {
17
17
  level?: number;
18
18
  trigger?: string;
19
19
  href?: string;
20
+ show_header?: boolean;
20
21
  items?: MenuItem[];
21
22
  inline?: boolean;
22
23
  type?: string;
@@ -129,6 +130,9 @@ export class TembaMenu extends RapidElement {
129
130
  .level-0 > .top {
130
131
  padding-top: var(--menu-padding);
131
132
  background: var(--color-primary-dark);
133
+ display: flex;
134
+ flex-direction: column;
135
+ align-items: center;
132
136
  }
133
137
 
134
138
  .level-0 > .empty {
@@ -395,7 +399,7 @@ export class TembaMenu extends RapidElement {
395
399
  }
396
400
 
397
401
  .fully-collapsed .level-1 {
398
- margin-left: -217px;
402
+ margin-left: -208px;
399
403
  pointer-events: none;
400
404
  border: none;
401
405
  overflow: hidden;
@@ -421,6 +425,54 @@ export class TembaMenu extends RapidElement {
421
425
  margin-left: 0.75em;
422
426
  margin-right: 0.75em;
423
427
  }
428
+
429
+ .expand-icon {
430
+ transform: rotate(180deg);
431
+ --icon-color: rgba(255, 255, 255, 0.5);
432
+ cursor: pointer;
433
+ max-height: 0px;
434
+ overflow: hidden;
435
+ opacity: 0;
436
+ transition: all 400ms ease-in-out 400ms;
437
+ }
438
+
439
+ .expand-icon:hover {
440
+ --icon-color: #fff;
441
+ }
442
+
443
+ .fully-collapsed .expand-icon {
444
+ padding-top: 0.5em;
445
+ max-height: 2em;
446
+ opacity: 1;
447
+ }
448
+
449
+ .section-header {
450
+ display: flex;
451
+ align-items: center;
452
+ }
453
+
454
+ .section-header .section {
455
+ flex-grow: 1;
456
+ }
457
+
458
+ .section-header temba-icon {
459
+ --icon-color: #ddd;
460
+ cursor: pointer;
461
+ padding-bottom: 0.5em;
462
+ padding-right: 0.5em;
463
+ }
464
+
465
+ .section-header temba-icon:hover {
466
+ --icon-color: var(--color-link-primary);
467
+ }
468
+
469
+ slot[name='header'] {
470
+ display: none;
471
+ }
472
+
473
+ slot[name='header'].show-header {
474
+ display: block;
475
+ }
424
476
  `;
425
477
  }
426
478
 
@@ -524,21 +576,24 @@ export class TembaMenu extends RapidElement {
524
576
  private fireNoPath(missingId: string) {
525
577
  const item = this.getMenuItem();
526
578
 
527
- const details = {
528
- item: item.id,
529
- selection: '/' + this.selection.join('/'),
530
- endpoint: item.endpoint,
531
- path: missingId + '/' + this.pending.join('/') + document.location.search,
532
- };
579
+ if (item) {
580
+ const details = {
581
+ item: item.id,
582
+ selection: '/' + this.selection.join('/'),
583
+ endpoint: item.endpoint,
584
+ path:
585
+ missingId + '/' + this.pending.join('/') + document.location.search,
586
+ };
533
587
 
534
- // remove any excess from our selection
535
- const selection = this.selection.join('/');
536
- selection.replace(details.path, '');
537
- this.selection = selection.split('/');
588
+ // remove any excess from our selection
589
+ const selection = this.selection.join('/');
590
+ selection.replace(details.path, '');
591
+ this.selection = selection.split('/');
538
592
 
539
- this.fireCustomEvent(CustomEventType.NoPath, details);
540
- this.pending = [];
541
- this.requestUpdate('root');
593
+ this.fireCustomEvent(CustomEventType.NoPath, details);
594
+ this.pending = [];
595
+ this.requestUpdate('root');
596
+ }
542
597
  }
543
598
 
544
599
  // eslint-disable-next-line @typescript-eslint/no-empty-function
@@ -645,7 +700,7 @@ export class TembaMenu extends RapidElement {
645
700
  }
646
701
 
647
702
  if (menuItem.endpoint) {
648
- this.loadItems(menuItem, !menuItem.href);
703
+ this.loadItems(menuItem, true);
649
704
  this.dispatchEvent(new Event('change'));
650
705
  } else {
651
706
  if (this.pending && this.pending.length > 0) {
@@ -744,6 +799,14 @@ export class TembaMenu extends RapidElement {
744
799
  }
745
800
  }
746
801
 
802
+ public handleExpand() {
803
+ this.collapsed = false;
804
+ }
805
+
806
+ public handleCollapse() {
807
+ this.collapsed = true;
808
+ }
809
+
747
810
  public async setFocusedItem(path: string) {
748
811
  const focusedPath = path.split('/').filter(step => !!step);
749
812
 
@@ -923,7 +986,15 @@ export class TembaMenu extends RapidElement {
923
986
 
924
987
  levels.push(
925
988
  html`<div class="level level-0 ${this.submenu ? 'hidden' : ''}">
926
- <div class="top"></div>
989
+ <div class="top">
990
+ <div class="expand-icon" @click=${this.handleExpand}>
991
+ <temba-icon
992
+ name="menu-collapse"
993
+ class="expand"
994
+ size="1.4"
995
+ ></temba-icon>
996
+ </div>
997
+ </div>
927
998
 
928
999
  ${items
929
1000
  .filter(item => !item.bottom)
@@ -972,7 +1043,25 @@ export class TembaMenu extends RapidElement {
972
1043
  })}"
973
1044
  >
974
1045
  ${!this.submenu
975
- ? html`<div class="section">${selected.name}</div>`
1046
+ ? html`
1047
+ <slot
1048
+ class="${getClasses({
1049
+ 'show-header': selected.show_header,
1050
+ })}"
1051
+ name="header"
1052
+ ></slot>
1053
+ <div class="section-header">
1054
+ <div class="section">${selected.name}</div>
1055
+
1056
+ ${index == 0 && !this.collapsed
1057
+ ? html`<temba-icon
1058
+ name="menu-collapse"
1059
+ size="1.1"
1060
+ @click=${this.handleCollapse}
1061
+ ></temba-icon>`
1062
+ : null}
1063
+ </div>
1064
+ `
976
1065
  : null}
977
1066
  ${items.map((item: MenuItem) => {
978
1067
  if (item.inline && item.items) {
@@ -16,6 +16,7 @@ export class TabPane extends RapidElement {
16
16
 
17
17
  .tabs {
18
18
  display: flex;
19
+ padding-left: 0.18em;
19
20
  }
20
21
 
21
22
  .tab {
@@ -32,6 +33,7 @@ export class TabPane extends RapidElement {
32
33
  color: var(--color-text-dark);
33
34
  --icon-color: var(--color-text-dark);
34
35
  white-space: nowrap;
36
+ transition: all 100ms ease-in-out;
35
37
  }
36
38
 
37
39
  .tab.hidden {
@@ -70,6 +72,8 @@ export class TabPane extends RapidElement {
70
72
  cursor: default;
71
73
  box-shadow: 2px 1px 3px 2px rgba(0, 0, 0, 0.07);
72
74
  background: #fff;
75
+ transform: scale(1.05) translateY(-0.05em);
76
+ z-index: 0;
73
77
  }
74
78
 
75
79
  .pane {
@@ -81,10 +85,12 @@ export class TabPane extends RapidElement {
81
85
  box-shadow: 2px 5px 12px 2px rgba(0, 0, 0, 0.09),
82
86
  3px 3px 2px 1px rgba(0, 0, 0, 0.05);
83
87
  min-height: 0;
88
+ z-index: 1;
84
89
  }
85
90
 
86
91
  .pane.first {
87
92
  border-top-left-radius: 0px;
93
+ overflow: hidden;
88
94
  }
89
95
 
90
96
  .badge {
@@ -4,7 +4,7 @@ import { property } from 'lit/decorators';
4
4
  import { getClasses } from '../utils';
5
5
 
6
6
  // for cache busting, increase whenever the icon set changes
7
- const ICON_VERSION = 14;
7
+ const ICON_VERSION = 15;
8
8
 
9
9
  export class VectorIcon extends LitElement {
10
10
  @property({ type: String })
@@ -51,7 +51,6 @@ export class VectorIcon extends LitElement {
51
51
  return css`
52
52
  :host {
53
53
  margin: auto;
54
- --color1: var(--icon-color);
55
54
  }
56
55
 
57
56
  .sheet {
@@ -90,7 +89,7 @@ export class VectorIcon extends LitElement {
90
89
 
91
90
  .clickable:hover {
92
91
  cursor: pointer;
93
- fill: var(--color-link-primary);
92
+ fill: var(--color-link-primary) !important;
94
93
  background: rgb(255, 255, 255);
95
94
  }
96
95
 
@@ -4,7 +4,7 @@ If you prefer using PNGs, PDFs, or CSS sprites, refer to the Preferences panel o
4
4
 
5
5
  *demo.html* lists the icons that you selected. To insert your icons as inline SVGs (with the <use> element), copy the <svg> element (that contains symbol definitions) from the source of the demo.html file, below your own HTML's <body> tag. After copying this SVG, you can reference your glyphs like the following:
6
6
 
7
- <svg class="icon icon-hourglass"><use xlink:href="#icon-hourglass"></use></svg>
7
+ <svg class="icon icon-zapier"><use xlink:href="#icon-zapier"></use></svg>
8
8
 
9
9
  You can get this code from the SVG tab of the IcoMoon app, or by referring to the source of the demo.html file. To see how you can change the color/size of your icons using CSS, refer to the example provided in the *style.css* file.
10
10
 
@@ -0,0 +1,5 @@
1
+ <!-- Generated by IcoMoon.io -->
2
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
3
+ <title>menu-collapse</title>
4
+ <path d="M21 15.609l-1.406 1.406-5.016-5.016 5.016-5.016 1.406 1.406-3.563 3.609zM3 6h12.984v2.016h-12.984v-2.016zM3 12.984v-1.969h9.984v1.969h-9.984zM3 18v-2.016h12.984v2.016h-12.984z"></path>
5
+ </svg>
@@ -1,5 +1,6 @@
1
1
  <!-- Generated by IcoMoon.io -->
2
2
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
3
3
  <title>zapier</title>
4
- <path fill="#ff4a00" d="M20 16.005c0 1.191-0.22 2.328-0.615 3.38-1.049 0.396-2.191 0.615-3.38 0.615h-0.012c-1.191 0-2.327-0.22-3.379-0.615-0.396-1.052-0.615-2.191-0.615-3.38v-0.012c0-1.191 0.219-2.327 0.615-3.379 1.052-0.396 2.189-0.615 3.379-0.615h0.012c1.191 0 2.331 0.219 3.38 0.616 0.396 1.051 0.615 2.188 0.615 3.38zM31.78 13.333h-9.34l6.597-6.603c-0.52-0.731-1.093-1.413-1.727-2.044-0.631-0.632-1.313-1.209-2.040-1.728l-6.605 6.599v-9.337c-0.865-0.139-1.751-0.22-2.66-0.22h-0.013c-0.907 0-1.795 0.081-2.66 0.22v9.34l-6.6-6.599c-0.732 0.515-1.413 1.095-2.045 1.725-0.632 0.632-1.211 1.316-1.728 2.044l6.599 6.603h-9.337c0 0-0.22 1.755-0.22 2.66v0.012c0 0.907 0.081 1.797 0.22 2.66h9.34l-6.599 6.603c1.036 1.461 2.311 2.735 3.769 3.773l6.603-6.6v9.339c0.864 0.14 1.751 0.22 2.655 0.22h0.023c0.905 0 1.792-0.080 2.655-0.22v-9.339l6.603 6.6c0.731-0.5 1.413-1.083 2.039-1.72h0.007c0.631-0.62 1.208-1.301 1.728-2.041l-6.6-6.599h9.339c0.14-0.86 0.22-1.739 0.22-2.64v-0.041c0-0.904-0.080-1.791-0.22-2.653z"></path>
4
+ <path fill="#474747" d="M4.8 0h22.4c2.651 0 4.8 2.149 4.8 4.8v22.4c0 2.651-2.149 4.8-4.8 4.8h-22.4c-2.651 0-4.8-2.149-4.8-4.8v-22.4c0-2.651 2.149-4.8 4.8-4.8z"></path>
5
+ <path fill="#fff" d="M4.8 20.8h22.4v6.4h-22.4v-6.4z"></path>
5
6
  </svg>