capibara 1.1.21 → 1.1.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capibara",
3
- "version": "1.1.21",
3
+ "version": "1.1.25",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -169,6 +169,7 @@ export class Capibara{
169
169
  this.$inputsNavRight = inputs;
170
170
  this.$capibara = $capibara;
171
171
  this.$elements = {
172
+ $headerTop,
172
173
  $detailDay,
173
174
  $contextMenu,
174
175
  $floatBoxContainer,
@@ -188,10 +189,7 @@ export class Capibara{
188
189
 
189
190
  this.containerElement.innerHTML = "";
190
191
  this.containerElement.appendChild($capibara);
191
-
192
- if(config.timeline.tabs){
193
- this.selectTab(initialTab, false);
194
- }
192
+ this.selectTab(initialTab);
195
193
 
196
194
  return $capibara;
197
195
  }
@@ -254,18 +252,21 @@ export class Capibara{
254
252
  */
255
253
  selectTab(tab, redraw = true){
256
254
 
257
- let $tab = this.$capibara.querySelector('.tab[input-key="'+tab.id+'"]');
255
+ //let $tab = this.$capibara.querySelector('.tab[input-key="'+tab.id+'"]');
258
256
 
259
- if($tab){
257
+ if(tab){
260
258
  this.tabSelected = tab;
259
+ /*
261
260
  this.$capibara.querySelector(".tabs-select").value = tab.id;
262
261
  this.$capibara.querySelectorAll(".tab").forEach(t => {t.classList.remove("active")});
263
262
  $tab.classList.add("active");
263
+ */
264
264
 
265
265
  this.cleanMultiInput();
266
266
 
267
267
  if(redraw){
268
268
  this.redraw({
269
+ headerTop:true,
269
270
  cornerLeft: true,
270
271
  navLeft: true,
271
272
  navRight: true,
@@ -288,6 +289,19 @@ export class Capibara{
288
289
  }
289
290
  }
290
291
 
292
+ selectLegend(evt){
293
+ let legend = evt.detail.legend;
294
+ if(legend){
295
+ legend.active = !legend.active;
296
+ }
297
+
298
+ this.redraw({
299
+ headerTop: true,
300
+ floatBox: true,
301
+ detailDay: true
302
+ });
303
+ }
304
+
291
305
  /**
292
306
  * muestra alternadamente los sidebar initial y extended
293
307
  */
@@ -655,12 +669,12 @@ export class Capibara{
655
669
  rightClickOnTable(evt){
656
670
  if(this.config.timeline.contextMenu){
657
671
  this.hideDetailDay();
658
- this.showContextMenu(evt);
672
+ this.showContextMenuOnTable(evt);
659
673
  evt.preventDefault();
660
674
  }
661
675
  };
662
676
 
663
- showContextMenu(evt){
677
+ showContextMenuOnTable(evt){
664
678
 
665
679
  let date = utils.getDayByEvent(this.config, evt, this.$elements.$table);
666
680
  let item = utils.getItemByEvent(this.config, evt, this.$elements.$table);
@@ -670,14 +684,17 @@ export class Capibara{
670
684
  return;
671
685
  }
672
686
 
673
- let position = utils.eventToPosition(this.config, evt, this.$elements.$table);
687
+ //let position = utils.eventToPosition(this.config, evt, this.$elements.$table);
674
688
  let { elem:$elem, isVisible } = tableElements.createContextMenu({
689
+ tabSelected: this.tabSelected,
690
+ $capibaraElem : this.$capibara,
675
691
  config: this.config,
676
692
  evt,
677
- position,
693
+ //position,
678
694
  date,
679
695
  item,
680
- selected: this.selected
696
+ selected: this.selected,
697
+ name: "onTable"
681
698
  });
682
699
 
683
700
  if($elem){
@@ -796,9 +813,7 @@ export class Capibara{
796
813
  this.selected.splice(index, 1);
797
814
  }
798
815
 
799
- this.selected.forEach((s, index) => {
800
- s.index = index+1;
801
- })
816
+ this.setIndexToSelected();
802
817
 
803
818
  if(redraw){
804
819
  this.redrawSelection()
@@ -812,9 +827,7 @@ export class Capibara{
812
827
 
813
828
 
814
829
  select(date, item, pos, redraw = true){
815
- let index = utils.indexSelectedDay(this.selected, {date, item});
816
-
817
- if(index < 0){
830
+ if(!this.isSelected(date, item)){
818
831
 
819
832
  this.selected.push({
820
833
  index: 0,
@@ -858,9 +871,7 @@ export class Capibara{
858
871
  }
859
872
  })
860
873
 
861
- this.selected.forEach((s, index) => {
862
- s.index = index+1;
863
- })
874
+ this.setIndexToSelected();
864
875
 
865
876
  if(redraw){
866
877
  this.redrawSelection()
@@ -868,7 +879,40 @@ export class Capibara{
868
879
  };
869
880
 
870
881
 
882
+ setIndexToSelected(){
883
+ this.selected.forEach((s, index) => {
884
+ s.index = index+1;
885
+ })
886
+ };
887
+
888
+
889
+ isSelectedAllDate(date){
890
+ let isAllSelected = true;
891
+ this.config.data.forEach(parent => {
892
+ parent.children.forEach(item => {
893
+ if(!this.isSelected(date, item)){
894
+ isAllSelected = false;
895
+ }
896
+ });
897
+ });
898
+ return isAllSelected;
899
+ };
871
900
 
901
+ selectByDate(date){
902
+ this.config.data.forEach(parent => {
903
+ parent.children.forEach(item => {
904
+ this.selectByItemDate(date, item, false);
905
+ });
906
+ });
907
+ };
908
+
909
+ deselectByDate(date){
910
+ this.config.data.forEach(parent => {
911
+ parent.children.forEach(item => {
912
+ this.deselectByItemDate(date, item, false);
913
+ });
914
+ });
915
+ };
872
916
 
873
917
  selectByItemDate(date, item, redraw = true){
874
918
  if(!this.isSelected(date, item)){
@@ -909,7 +953,9 @@ export class Capibara{
909
953
  };
910
954
 
911
955
  hideContextMenu(){
912
- this.$elements.$contextMenu.classList.add("cm-hide");
956
+ if(this.$elements.$contextMenu){
957
+ this.$elements.$contextMenu.classList.add("cm-hide");
958
+ }
913
959
  this.isVisibleContextMenu = false;
914
960
  };
915
961
 
@@ -933,13 +979,13 @@ export class Capibara{
933
979
  let yPositionClass = "has-top-arrow";
934
980
  let xPositionClass = "";
935
981
 
936
- //condicion para primeras 2 filas
937
- if(position.topClient <= itemHeight *2 ){
982
+ //condicion para primeras 3 filas
983
+ if(position.topClient <= itemHeight *3 ){
938
984
  yPositionClass = "has-ceil-arrow";
939
985
  }else if( position.yPercent > 20 &&
940
- position.yPercent <= 50){ //entre 20 y 50 %
986
+ position.yPercent <= 70){ //entre 20 y 50 %
941
987
  yPositionClass = "has-middle-arrow";
942
- }else if(position.yPercent > 50){
988
+ }else if(position.yPercent > 70){
943
989
  yPositionClass = "has-bottom-arrow";
944
990
  }
945
991
 
@@ -987,15 +1033,47 @@ export class Capibara{
987
1033
 
988
1034
  clickDateHeader(evt){
989
1035
  let date = evt.detail.date;
990
- this.selected = [];
991
- this.config.data.forEach(parent => {
992
- parent.children.forEach(item => {
993
- this.selectByItemDate(date, item, false);
994
- });
995
- });
1036
+ this.toggleSelectByDate(date);
996
1037
  this.redrawSelection();
997
1038
  }
998
1039
 
1040
+ toggleSelectByDate(date){
1041
+ if(this.isSelectedAllDate(date)){
1042
+ this.deselectByDate(date);
1043
+ }else{
1044
+ this.selectByDate(date);
1045
+ }
1046
+ this.selected = this.selected.sort((s, n) => {
1047
+ return (new Date(s.date)) - (new Date(n.date));
1048
+ });
1049
+ this.setIndexToSelected();
1050
+ }
1051
+
1052
+
1053
+ contextMenuDateHeader(evt){
1054
+ let left = evt.detail.clientX;
1055
+ let top = evt.detail.clientY - this.$capibara.getBoundingClientRect().top;
1056
+ let date = evt.detail.date;
1057
+
1058
+ let { elem:$elem, isVisible } = tableElements.createContextMenu({
1059
+ tabSelected: this.tabSelected,
1060
+ $capibaraElem: this.$capibara,
1061
+ config: this.config,
1062
+ selected: this.selected,
1063
+ date,
1064
+ left,
1065
+ top,
1066
+ name: "onDateHeader"
1067
+ });
1068
+
1069
+ if($elem){
1070
+ this.isVisibleContextMenu = isVisible;
1071
+ this.$elements.$contextMenu.replaceWith($elem);
1072
+ this.$elements.$contextMenu = $elem;
1073
+ }
1074
+
1075
+ }
1076
+
999
1077
  /**
1000
1078
  * Captura evento window resize
1001
1079
  * para verificar si es mobile o no
@@ -1063,6 +1141,7 @@ export class Capibara{
1063
1141
  this.$capibara.addEventListener("clickNavLeftTreeIcon" , this.clickNavLeftTreeIcon.bind(this));
1064
1142
  this.$capibara.addEventListener("mouseOverFloatBox" , this.mouseOverFloatBox.bind(this));
1065
1143
  this.$capibara.addEventListener("selectTabHeader" , e => { this.selectTab(e.detail.tab); });
1144
+ this.$capibara.addEventListener("selectLegendHeader" , this.selectLegend.bind(this));
1066
1145
 
1067
1146
  this.$elements.$floatBoxContainer.addEventListener("mousemove", this.mouseMoveOnFlexBoxContainer.bind(this));
1068
1147
  this.$elements.$floatBoxContainer.addEventListener("mouseleave", this.mouseLeaveOnFloatBoxContainer.bind(this));
@@ -1074,6 +1153,7 @@ export class Capibara{
1074
1153
  this.$elements.$container.addEventListener("scroll", this.hideContextMenu.bind(this));
1075
1154
 
1076
1155
  this.$elements.$container.addEventListener("clickDate", this.clickDateHeader.bind(this));
1156
+ this.$elements.$container.addEventListener("contextMenuDate", this.contextMenuDateHeader.bind(this));
1077
1157
 
1078
1158
  window.addEventListener('resize',this.onWindowResize.bind(this));
1079
1159
 
@@ -1120,6 +1200,10 @@ export class Capibara{
1120
1200
  }
1121
1201
  }
1122
1202
 
1203
+ if(options.headerTop){
1204
+ this.$elements.$headerTop = tableElements.redrawHeaderTop(this.config, this.tabSelected, this.$elements.$headerTop);
1205
+ }
1206
+
1123
1207
  if(options.detailDay){
1124
1208
  this.hideDetailDay();
1125
1209
  this.lastDataDay = null;
@@ -55,4 +55,4 @@ $darkBlueColors:(
55
55
  "lighten-3" : rgb(72, 87, 118),
56
56
  "lighten-4" : rgb(80, 96, 131),
57
57
  "lighten-5" : rgb(88, 106, 143)
58
- );
58
+ );
@@ -122,25 +122,30 @@
122
122
  }
123
123
 
124
124
  &.shape-bar{
125
- height: calc(var(--item-height) / 4);
126
- line-height: calc(var(--item-height) / 4 + 1);
125
+ height: calc(var(--item-height) / 4 - 1.5px);
126
+ width: calc(var(--day-width) - 6px);
127
+ line-height: 0;
127
128
  color: transparent;
128
129
  border-radius: 1px;
129
- border: 1px solid white;
130
- margin: 0px 0px -1px 0px;
130
+ border: 1px solid rgba(0, 0, 0, 0.4);
131
+ margin: 0px 3px;
132
+ &:first-child{
133
+ margin-top: 3px;
134
+ }
131
135
  }
132
136
 
133
137
  &.shape-bar-outlined{
134
- height: calc(var(--item-height) / 4);
138
+ height: calc(var(--item-height) / 4 - 1.5px);
139
+ width: calc(var(--day-width) - 6px);
135
140
  line-height: 0px;
136
141
  color: transparent;
137
142
  border-radius: 1px;
138
- border: 1px solid white;
139
- margin: 0px 0px -1px 0px;
140
- border-width: 2px;
141
- border-color: grey;
142
- border-style: solid;
143
+ border: 1px solid rgba(0, 0, 0, 0.2);
144
+ margin: 0px 3px;
143
145
  backdrop-filter: blur(2px);
146
+ &:first-child{
147
+ margin-top: 3px;
148
+ }
144
149
  }
145
150
 
146
151
  }
@@ -26,16 +26,36 @@
26
26
  visibility: visible;
27
27
  opacity: 1;
28
28
  padding: 0.4em 0px;
29
+ vertical-align:middle;
29
30
 
30
- &--item {
31
+ &_item {
31
32
  padding: 0.5em 1em;
33
+ flex: 0 0 auto;
34
+
35
+ display:flex;
36
+ flex-direction: row;
37
+ align-items: center;;
38
+
32
39
  &:hover {
33
40
  background: rgba(20, 20, 20, 0.2);
34
41
  }
35
42
  &.is-disabled {
36
43
  opacity: 0.5;
37
44
  }
45
+
46
+ &_icon{
47
+ display: inline-block;
48
+ flex: 0 0 auto;
49
+ padding-right: 0.5em;
50
+ svg{
51
+ width: 16px;
52
+ height: 16px;
53
+ }
54
+ }
55
+
38
56
  }
57
+
58
+
39
59
  }
40
60
  }
41
61
 
@@ -45,9 +65,12 @@
45
65
  &#{$nameTheme}{
46
66
  .cap-context-menu-container{
47
67
  .cap-context-menu{
48
- color: mapGet($theme, detailDay, color);
68
+ color: mapGet($theme, color);
49
69
  border-color: mapGet($theme, detailDay, border);
50
70
  background: mapGet($theme, detailDay, background);
71
+ svg path{
72
+ fill: mapGet($theme, color);
73
+ }
51
74
  }
52
75
  }
53
76
  }
@@ -309,7 +309,7 @@
309
309
  @each $nameTheme , $theme in $themes {
310
310
  &#{$nameTheme}{
311
311
  .detail-day{
312
- color: mapGet($theme, detailDay, color);
312
+ color: mapGet($theme, color);
313
313
  border-color: mapGet($theme, detailDay, border);
314
314
  background: mapGet($theme, detailDay, background);
315
315
  &:after{
@@ -13,7 +13,10 @@
13
13
 
14
14
  .tabs-container {
15
15
  display: flex;
16
- padding: 0px 16px;
16
+
17
+ &:not(:empty){
18
+ padding: 0px 16px;
19
+ }
17
20
 
18
21
  .tab {
19
22
  cursor: pointer;
@@ -32,6 +35,43 @@
32
35
  }
33
36
  }
34
37
  }
38
+
39
+ .legends-container {
40
+
41
+ &:not(:empty){
42
+ padding: 0.5em 1em ;
43
+ }
44
+
45
+ .legend {
46
+ display: flex;
47
+ flex-direction: row;
48
+ margin-right: 1em;
49
+ cursor: pointer;
50
+ padding: 0 0.5em;
51
+ &:not(.active) {
52
+ opacity: 0.5;
53
+ }
54
+ .icon-legend {
55
+ width: 0.825em;
56
+ height: 0.825em;
57
+ margin: 2px 0.5em 2px 0;
58
+ background: grey;
59
+ box-shadow: 0px 1px 2px rgba(0,0,0,0.4);
60
+ display: inline-block;
61
+ border-radius: 1px;
62
+ border: 1px solid rgba(0, 0, 0, 0.4);
63
+ &.circle {
64
+ border-radius: 50%;
65
+ }
66
+ }
67
+ &:hover {
68
+ span {
69
+ text-decoration: underline;
70
+ }
71
+
72
+ }
73
+ }
74
+ }
35
75
  }
36
76
 
37
77
 
@@ -13,23 +13,24 @@
13
13
  position: absolute;
14
14
  background: rgba(189,189,189,0.4);
15
15
  box-shadow: inset 0px 0px 5px rgba(189,189,189,0.8);
16
- &[selected-index]{
16
+ &[cap-badge]{
17
17
  &::after{
18
- content:attr(selected-index);
18
+ content:attr(cap-badge);
19
19
  display: block;
20
20
  position:absolute;
21
- left:-2px;
22
- top: -2px;
23
- background: red;
21
+ right:-3px;
22
+ top: -3px;
23
+ background: rgb(21,101,192);
24
24
  font-size: 0.75em;
25
25
  color: white;
26
- width: 1.3em;
27
- height:1.3em;
26
+ width: 1.5em;
27
+ height:1.5em;
28
28
  border-radius:50%;
29
- border: 1px solid blue;
30
29
  z-index: 2;
31
30
  text-align: center;
32
31
  font-weight:bold;
32
+ padding: 2px;
33
+ box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
33
34
  }
34
35
  }
35
36
  }
@@ -6,6 +6,7 @@
6
6
  top: var(--header-height) ;
7
7
  width: calc(100% - var(--nav-width ) - var(--initial-nav-width ) - var(--ex-nav-width ) - var(--btn-nav-width));
8
8
  max-height: calc(100% - var(--header-height));
9
+ height: calc(100% - var(--header-height));
9
10
  margin-top: -1px;
10
11
 
11
12
  .day-mouse-over{
@@ -210,8 +210,8 @@
210
210
  }
211
211
 
212
212
  span.data.shape-bar-outlined.#{$colorName}{
213
- border-color: transparentize($color, 0.1);
214
- background: transparentize($color, 0.9);
213
+ //border-color: darken(transparentize($color, 0.1), 15%);
214
+ background: transparentize($color, 0.5);
215
215
  }
216
216
 
217
217
 
@@ -219,7 +219,7 @@
219
219
  background: $color;
220
220
  &.outlined{
221
221
  border: 1px solid $color;
222
- box-shadow: inset 0px 0px 0px 1px transparentize($color, 0.3);
222
+ box-shadow: inset 0px 0px 0px 1px transparentize($color, 0.3);
223
223
  }
224
224
  }
225
225
  }
@@ -11,7 +11,7 @@ $themes:(
11
11
 
12
12
  floatBox:(
13
13
  shapeBar:(
14
- border: white,
14
+ border: rgba(0, 0, 0, 0.3),
15
15
  )
16
16
  ),
17
17
 
@@ -164,7 +164,7 @@ $themes:(
164
164
 
165
165
  floatBox:(
166
166
  shapeBar:(
167
- border: mapGet($darkBlueColors, base),
167
+ border: rgba(0, 0, 0, 0.6),
168
168
  )
169
169
  ),
170
170