capibara 1.1.17 → 1.1.21

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.
@@ -179,6 +179,10 @@
179
179
  border: 1px solid $color;
180
180
  .left-icon {
181
181
  background: $color;
182
+ &.outlined{
183
+ border: 1px solid $color;
184
+ box-shadow: inset 0px 0px 0px 1px transparentize($color, 0.3);
185
+ }
182
186
  }
183
187
  .name {
184
188
  color: $color;
@@ -191,19 +195,32 @@
191
195
 
192
196
  .float-box-container {
193
197
  .float-box {
194
- span.data.#{$colorName}:not(.data-outlined){
198
+ span.data.#{$colorName}{
195
199
  background: transparentize($color, 0.2);
196
- color: white;
197
200
  }
198
201
 
199
- span.data.data-outlined.#{$colorName}{
202
+ span.data.shape-outlined.#{$colorName}{
200
203
  border-color: transparentize($color, 0.1);
201
204
  background: transparentize($color, 0.9);
202
205
  color: $color;
203
206
  }
204
207
 
208
+ span.data.shape-bar.#{$colorName}{
209
+ background: $color;
210
+ }
211
+
212
+ span.data.shape-bar-outlined.#{$colorName}{
213
+ border-color: transparentize($color, 0.1);
214
+ background: transparentize($color, 0.9);
215
+ }
216
+
217
+
205
218
  .dot.#{$colorName}{
206
219
  background: $color;
220
+ &.outlined{
221
+ border: 1px solid $color;
222
+ box-shadow: inset 0px 0px 0px 1px transparentize($color, 0.3);
223
+ }
207
224
  }
208
225
  }
209
226
  }
@@ -231,6 +248,13 @@
231
248
  }
232
249
  }
233
250
 
251
+
252
+ .input-box{
253
+ .mini-input-section--icon.#{$colorName} {
254
+ background: $color;
255
+ }
256
+ }
257
+
234
258
  }
235
259
 
236
260
 
@@ -9,6 +9,12 @@ $themes:(
9
9
  background : rgba(245,245,245,1),
10
10
  color : rgba(55,71,79,1),
11
11
 
12
+ floatBox:(
13
+ shapeBar:(
14
+ border: white,
15
+ )
16
+ ),
17
+
12
18
  detailDay:(
13
19
  background : white,
14
20
  border : rgba(0, 0, 0, 0.2),
@@ -156,6 +162,12 @@ $themes:(
156
162
  background: mapGet($darkBlueColors, darken-2), // rgb(32, 39, 55),
157
163
  color: rgb(240,240,240),
158
164
 
165
+ floatBox:(
166
+ shapeBar:(
167
+ border: mapGet($darkBlueColors, base),
168
+ )
169
+ ),
170
+
159
171
  scroll:(
160
172
  background: transparent,
161
173
  color: rgba(189,189,189,1),
@@ -21,6 +21,12 @@ export default {
21
21
  })
22
22
  }
23
23
 
24
+ if(options.attributes){
25
+ options.attributes.forEach(attr => {
26
+ e.setAttribute(attr.name, attr.value);
27
+ });
28
+ }
29
+
24
30
  if(options.text){
25
31
  e.appendChild(ocument.createTextNode(options.text));
26
32
  }
@@ -2,30 +2,43 @@ import utils from './utils';
2
2
  import _ from "lodash";
3
3
 
4
4
  export default {
5
+ cleanStyle(config){
6
+
7
+ utils.setCSSVariable(config, "--nav-width", null);
8
+ utils.setCSSVariable(config, "--nav-item-col-width", null);
9
+ utils.setCSSVariable(config, "--initial-nav-width", null);
10
+ utils.setCSSVariable(config, "--ex-nav-width", null);
11
+ utils.setCSSVariable(config, "--btn-nav-width", null);
12
+ utils.setCSSVariable(config, "--header-height", null);
13
+ utils.setCSSVariable(config, "--header-top-height", null);
14
+ utils.setCSSVariable(config, "--ex-header-height", null);
15
+ utils.setCSSVariable(config, "--day-width", null);
16
+ utils.setCSSVariable(config, "--item-height", null);
17
+ },
5
18
 
6
19
  setNavStyle(config) {
7
20
  if (config.timeline.nav.left.initial.width && !utils.checkIsMobile()) {
8
- utils.setCSSVariable("--nav-width", config.timeline.nav.left.initial.width + "px");
21
+ utils.setCSSVariable(config, "--nav-width", config.timeline.nav.left.initial.width + "px");
9
22
  }
10
23
  if (config.timeline.nav.left.initial.mobile && utils.checkIsMobile()) {
11
- utils.setCSSVariable("--nav-width", config.timeline.nav.left.initial.mobile.width + "px");
24
+ utils.setCSSVariable(config, "--nav-width", config.timeline.nav.left.initial.mobile.width + "px");
12
25
  }
13
26
  if (config.timeline.nav.columnWidth) {
14
- utils.setCSSVariable("--nav-item-col-width", config.timeline.nav.columnWidth + "px");
27
+ utils.setCSSVariable(config, "--nav-item-col-width", config.timeline.nav.columnWidth + "px");
15
28
  }
16
29
  },
17
- setNavLeftInitialStyle(config, isShow) {
18
- this.setSubNavStyle(config, isShow, "left.initial", "--initial-nav-width");
30
+ setNavLeftInitialStyle(config, isShow, tab) {
31
+ this.setSubNavStyle(config, isShow, "left.initial", "--initial-nav-width", tab);
19
32
  },
20
- setNavLeftExtendedStyle(config, isShow) {
21
- this.setSubNavStyle(config, isShow, "left.extend", "--ex-nav-width");
33
+ setNavLeftExtendedStyle(config, isShow, tab) {
34
+ this.setSubNavStyle(config, isShow, "left.extend", "--ex-nav-width", tab);
22
35
  },
23
- setNavLeftButtonsStyle(config, isShow) {
24
- this.setSubNavStyle(config, isShow, "left.buttons", "--btn-nav-width");
36
+ setNavLeftButtonsStyle(config, isShow, tab) {
37
+ this.setSubNavStyle(config, isShow, "left.buttons", "--btn-nav-width", tab);
25
38
  },
26
39
 
27
- setSubNavStyle(config, isShow, path, cssVarName) {
28
- let columnWidth = parseFloat(utils.getCSSVariable("--nav-item-col-width"));
40
+ setSubNavStyle(config, isShow, path, cssVarName, tab = null) {
41
+ let columnWidth = parseFloat(utils.getCSSVariable(config, "--nav-item-col-width"));
29
42
  let nav = _.get(config, "timeline.nav." + path);
30
43
  let width = null;
31
44
  if (nav) {
@@ -36,33 +49,34 @@ export default {
36
49
  if (nav.width) {
37
50
  width = nav.width;
38
51
  } else if (nav.vars && columnWidth) {
39
- width = columnWidth * nav.vars.length;
52
+ let navVarsFiltered = nav.vars.filter(v => (v.onlyTab == undefined || (v.onlyTab && tab && v.onlyTab == tab.key)));
53
+ width = columnWidth * navVarsFiltered.length;
40
54
  }
41
55
  } else {
42
56
  width = 0;
43
57
  }
44
58
 
45
59
  if (width !== null) {
46
- utils.setCSSVariable(cssVarName, width + "px");
60
+ utils.setCSSVariable(config, cssVarName, width + "px");
47
61
  }
48
62
  }
49
63
  },
50
64
 
51
65
  setHeaderStyle(config) {
52
66
  if (config.timeline.header.height) {
53
- utils.setCSSVariable("--header-height", config.timeline.header.height + "px");
67
+ utils.setCSSVariable(config, "--header-height", config.timeline.header.height + "px");
54
68
  }
55
69
 
56
70
  if (config.timeline.header.top && config.timeline.header.top.height) {
57
- utils.setCSSVariable("--header-top-height", config.timeline.header.top.height + "px");
71
+ utils.setCSSVariable(config, "--header-top-height", config.timeline.header.top.height + "px");
58
72
  }
59
73
 
60
74
  if (config.timeline.header.extend.enabled === false) {
61
- utils.setCSSVariable("--ex-header-height","0px");
75
+ utils.setCSSVariable(config, "--ex-header-height","0px");
62
76
  }
63
77
 
64
78
  if (config.timeline.header.extend.height) {
65
- utils.setCSSVariable("--ex-header-height", config.timeline.header.extend.height + "px");
79
+ utils.setCSSVariable(config, "--ex-header-height", config.timeline.header.extend.height + "px");
66
80
  }
67
81
 
68
82
  },
@@ -70,16 +84,16 @@ export default {
70
84
  setTableStyle(config) {
71
85
  if (config.timeline.day.width) {
72
86
  if (config.timeline.day.mobile && utils.checkIsMobile()) {
73
- utils.setCSSVariable("--day-width", config.timeline.day.mobile.width + "px");
87
+ utils.setCSSVariable(config, "--day-width", config.timeline.day.mobile.width + "px");
74
88
  }else{
75
- utils.setCSSVariable("--day-width", config.timeline.day.width + "px");
89
+ utils.setCSSVariable(config, "--day-width", config.timeline.day.width + "px");
76
90
  }
77
91
  }
78
92
  if (config.timeline.day.height) {
79
93
  if (config.timeline.day.mobile && utils.checkIsMobile()) {
80
- utils.setCSSVariable("--item-height", config.timeline.day.mobile.height + "px");
94
+ utils.setCSSVariable(config, "--item-height", config.timeline.day.mobile.height + "px");
81
95
  }else{
82
- utils.setCSSVariable("--item-height", config.timeline.day.height + "px");
96
+ utils.setCSSVariable(config, "--item-height", config.timeline.day.height + "px");
83
97
  }
84
98
  }
85
99
 
@@ -25,10 +25,10 @@ export default {
25
25
  if(config.timeline.dark){
26
26
  e.classList.add("dark-theme");
27
27
  }
28
- if(config.timeline.nav.left.extend.enabled){
28
+ if(config.timeline.nav.left.extend.isShow){
29
29
  //e.classList.add("extended");
30
30
  }
31
- if(config.timeline.header.extend.enabled){
31
+ if(config.timeline.header.extend.isShow){
32
32
  e.classList.add("header-extended");
33
33
  }
34
34
  return e;
@@ -46,8 +46,8 @@ export default {
46
46
  * @return {Object} elemento Dom Background
47
47
  */
48
48
  createBackground(config, $elem = null){
49
- let w = parseFloat(utils.getCSSVariable("--day-width"));
50
- let h = parseFloat(utils.getCSSVariable("--item-height"));
49
+ let w = parseFloat(utils.getCSSVariable(config, "--day-width"));
50
+ let h = parseFloat(utils.getCSSVariable(config, "--item-height"));
51
51
  let start = new Date(config.timeline.start);
52
52
  let end = new Date(config.timeline.end);
53
53
 
@@ -111,7 +111,7 @@ export default {
111
111
  if(config.timeline.plots && config.timeline.plots.vertical){
112
112
  config.timeline.plots.vertical.forEach(p => {
113
113
  let diffDays = Math.floor(dateUtils.diffDays(config.timeline.start, p.date));
114
- let dayWidth = parseFloat(utils.getCSSVariable("--day-width"));
114
+ let dayWidth = parseFloat(utils.getCSSVariable(config, "--day-width"));
115
115
  let left = diffDays * dayWidth;
116
116
  let plot = dom.createElement("div", {
117
117
  classNames:["plot-vertical", (p.className || '')],
@@ -129,7 +129,7 @@ export default {
129
129
  config.timeline.plots.horizontal.forEach(p => {
130
130
  let item = utils.getItemById(config, p.idNode, p.typeNode);
131
131
  let topPosition = utils.getPositionByItem(config, item, "parent");
132
- let itemHeight = parseFloat(utils.getCSSVariable("--item-height"));
132
+ let itemHeight = parseFloat(utils.getCSSVariable(config, "--item-height"));
133
133
  let plot = dom.createElement("div", {
134
134
  classNames:["plot-horizontal", (p.className || '')],
135
135
  style:{'margin-top': (topPosition * itemHeight)+"px"}}
@@ -152,16 +152,18 @@ export default {
152
152
  * @param {Object} config - Configuracion capibara
153
153
  * @return {Object} Elemento Dom Corner
154
154
  */
155
- createCorner(config){
155
+ createCorner(config, tab = null){
156
156
  let $elem = dom.createElement("div", {className: "corner"});
157
- return this.redrawCorner($elem, config);
157
+ return this.redrawCorner($elem, config, tab);
158
158
  },
159
159
 
160
- redrawCorner($elem, config){
160
+ redrawCorner($elem, config, tab=null){
161
161
  let labelsInitialCorner = config.timeline.nav.left.initial.vars
162
+ .filter(v => (v.onlyTab == undefined || (v.onlyTab && tab && v.onlyTab == tab.key)))
162
163
  .map(d=>`<span class="item-col">${d.label}</span>`).join("");
163
164
 
164
165
  let labelsExtendCorner = config.timeline.nav.left.extend.vars
166
+ .filter(v => (v.onlyTab == undefined || (v.onlyTab && tab && v.onlyTab == tab.key)))
165
167
  .map(d=>`<span class="item-col">${d.label}</span>`).join("");
166
168
 
167
169
 
@@ -464,7 +466,7 @@ export default {
464
466
  </div>
465
467
  `;
466
468
  */
467
- let $r = dom.createElementFromHTML(str );
469
+ let $r = dom.createElementFromHTML(str);
468
470
 
469
471
  $r.querySelector("[toggle-dark]").addEventListener("click", e => {
470
472
  $r.dispatchEvent(new CustomEvent("toggleDark", {
@@ -629,7 +631,8 @@ export default {
629
631
  let day = datesTree[keyY][keyM][keyD];
630
632
  let isWeekend = day.isWeekend;
631
633
  let isToday = day.isToday;
632
- str+=`<div class="dia-calendario ${isToday?'today':''} ${isWeekend?'weekend':''}">${keyD}</div>`;
634
+ let date = dateUtils.formatDate(day.Date);
635
+ str += `<div class="dia-calendario ${isToday?'today':''} ${isWeekend?'weekend':''} ${config.timeline.dateSelectable ?'is-clickeable':''}" date="${date}">${keyD}</div>`;
633
636
  });
634
637
  str += `</div></div>`;
635
638
  });
@@ -640,6 +643,23 @@ export default {
640
643
  str += `</div>`;
641
644
  $elem.innerHTML = "";
642
645
  $elem.append(dom.createElementFromHTML(str));
646
+
647
+ if(config.timeline.dateSelectable){
648
+ $elem.querySelectorAll(".dia-calendario[date]").forEach($dia => {
649
+ $dia.addEventListener("click", evt => {
650
+
651
+ $elem.dispatchEvent(new CustomEvent("clickDate", {
652
+ bubbles : true,
653
+ cancelable : false,
654
+ detail : {
655
+ $elem: $dia,
656
+ date: $dia.getAttribute("date"),
657
+ }
658
+ }));
659
+ });
660
+ });
661
+ }
662
+
643
663
  return $elem;
644
664
  },
645
665
 
@@ -758,9 +778,9 @@ export default {
758
778
  * @param {Object} config - Configuracion capibara
759
779
  * @return {Object} Elemento Dom Sidebar Izquierdo
760
780
  */
761
- createNavLeft(config){
781
+ createNavLeft(config, tab = null){
762
782
  let $elem = dom.createElement("nav", {className:"left"});
763
- return this.redrawNavLeft($elem, config);
783
+ return this.redrawNavLeft($elem, config,tab);
764
784
  },
765
785
 
766
786
  /**
@@ -773,7 +793,7 @@ export default {
773
793
  * @return {Object} Elemento Dom navLeft
774
794
  */
775
795
 
776
- redrawNavLeft($elem, config){
796
+ redrawNavLeft($elem, config, tab = null){
777
797
 
778
798
  let navList = "";
779
799
  let initialNavList = "";
@@ -926,6 +946,9 @@ export default {
926
946
  d.children.forEach(c => {
927
947
  initialNavList += `<div class="child-initial-nav-item ${d.hidden ? 'hide' :''}" child="${d.id || -1}">`;
928
948
  config.timeline.nav.left.initial.vars.forEach(v => {
949
+
950
+ if(v.onlyTab && tab && v.onlyTab !== tab.key) return;
951
+
929
952
  let value = c.values[v.varName] ? c.values[v.varName] : '';
930
953
  if(v.round && !isNaN(value)){
931
954
  value = utils.round(value, v.round);
@@ -1073,6 +1096,8 @@ export default {
1073
1096
  exNavList += `<div class="child-ex-nav-item ${d.hidden ? 'hide' :''}" child="${d.id || -1}">`;
1074
1097
  config.timeline.nav.left.extend.vars.forEach(v => {
1075
1098
 
1099
+ if(v.onlyTab && tab && v.onlyTab !== tab.key) return;
1100
+
1076
1101
  let value = c.values[v.varName] ? c.values[v.varName] : '';
1077
1102
  if(v.round && !isNaN(value)){
1078
1103
  value = utils.round(value, v.round);
@@ -1386,7 +1411,8 @@ export default {
1386
1411
  itemId : itemId,
1387
1412
  item : item,
1388
1413
  type : typeNode,
1389
- value : value
1414
+ value : value,
1415
+ tabSelected: tab
1390
1416
  }
1391
1417
  }));
1392
1418
  });
@@ -1501,7 +1527,7 @@ export default {
1501
1527
  * inputs es un array de elementos Dom de cada input creado
1502
1528
  * (no son elementos html de tipo input)
1503
1529
  */
1504
- createNavRight(config, tab){
1530
+ createNavRight(config, tab = null){
1505
1531
  var $elem = dom.createElement("nav",{className:"right"});
1506
1532
  return this.redrawNavRight(config, $elem, tab);
1507
1533
  },
@@ -1520,12 +1546,12 @@ export default {
1520
1546
  * @param {Object} daySelected.pos - posicion de dia seleccionado
1521
1547
  * @return {Object} Elemento Dom Sidebar Derecho
1522
1548
  */
1523
- redrawNavRight(config, $elem, tab, dataDay = null, daySelected = null){
1549
+ redrawNavRight(config, $elem, tab = null, dataDay = null, daySelected = null){
1524
1550
  let $navRight = $elem; //dom.createElement("nav",{className:"right"});
1525
1551
  let $divContainer = dom.createElement("div",{className:"nav-input-container"});
1526
1552
  let $inputs = [];
1527
1553
  let checkboxInputs = [];
1528
- let tabSelected = tab || null; //econfig.timeline.tabs[0];
1554
+ let tabSelected = tab;
1529
1555
 
1530
1556
  if(tabSelected && tabSelected.inputs){
1531
1557
  tabSelected.inputs.forEach(i => {
@@ -1698,7 +1724,7 @@ export default {
1698
1724
  }
1699
1725
 
1700
1726
  let diffDays = Math.floor( dateUtils.diffDays(config.timeline.start, dateUtils.formatDate(new Date()) ));
1701
- let dayWidth = parseFloat(utils.getCSSVariable("--day-width"));
1727
+ let dayWidth = parseFloat(utils.getCSSVariable(config, "--day-width"));
1702
1728
  let diff = diffDays * dayWidth;
1703
1729
  diff += (dayWidth / 2) - 2; // para centrar linea
1704
1730
  Object.assign($elem.style,{'margin-left': diff+"px"});
@@ -1793,8 +1819,8 @@ export default {
1793
1819
  hideIf = Boolean( utils.getVarByPath(data.values, n.varHide) );
1794
1820
  }
1795
1821
 
1796
- if(n.outlined){
1797
- className += "data-outlined";
1822
+ if(n.shape){
1823
+ className += "shape-"+n.shape;
1798
1824
  }
1799
1825
 
1800
1826
  if(dataFloatBox !== null && showIf && !hideIf){
@@ -2082,7 +2108,7 @@ export default {
2082
2108
  repositionFloatBox(config, $floatBoxContainer){
2083
2109
  $floatBoxContainer.querySelectorAll(".float-box").forEach($f => {
2084
2110
  let itemId = $f.getAttribute("item-id");
2085
- let itemHeight = parseFloat(utils.getCSSVariable("--item-height"));
2111
+ let itemHeight = parseFloat(utils.getCSSVariable(config, "--item-height"));
2086
2112
  let item,parent;
2087
2113
  ({item, parent} = utils.getItemById(config, itemId, "child", true));
2088
2114
  if(item){
@@ -2110,7 +2136,9 @@ export default {
2110
2136
  $elem.innerHTML = "";
2111
2137
  if(selected){
2112
2138
  selected.forEach(s => {
2113
- let $s = dom.createElement("div", {className: "selected-day"});
2139
+ let $s = dom.createElement("div", {className: "selected-day", attributes:[
2140
+ {name:"selected-index", value:s.index }
2141
+ ]});
2114
2142
  $s.style.left = s.pos.left + "px";
2115
2143
  $s.style.top = s.pos.top + "px";
2116
2144
  $elem.append($s);
@@ -2133,8 +2161,8 @@ export default {
2133
2161
  getPositionFloatBox(config, data, item){
2134
2162
  let left = dateUtils.diffDays(config.timeline.start, data.date);
2135
2163
  let top = utils.getPositionByItem(config, item);
2136
- let dayWidth = parseFloat(utils.getCSSVariable("--day-width"));
2137
- let itemHeight = parseFloat(utils.getCSSVariable("--item-height"));
2164
+ let dayWidth = parseFloat(utils.getCSSVariable(config, "--day-width"));
2165
+ let itemHeight = parseFloat(utils.getCSSVariable(config, "--item-height"));
2138
2166
  left *= dayWidth;
2139
2167
  top *= itemHeight;
2140
2168
  return "top: "+top+".5px; left:"+left+".5px;";
@@ -2585,6 +2613,7 @@ export default {
2585
2613
  let value_found = value ? value.find(val => val.id == i.id) : null;
2586
2614
  let v = value_found || '';
2587
2615
  let tooltip = "";
2616
+ let icon = "";
2588
2617
 
2589
2618
  if(i.tooltip){
2590
2619
  tooltip = `
@@ -2593,6 +2622,12 @@ export default {
2593
2622
  </div>`;
2594
2623
  }
2595
2624
 
2625
+ if(i.colorIcon){
2626
+ icon= `<div class="mini-input-section--icon ${i.colorIcon}"> </div>`;
2627
+ }
2628
+
2629
+
2630
+
2596
2631
  str += `
2597
2632
  <div class="mini-input-section">
2598
2633
  <label class="truncate">
@@ -2600,6 +2635,7 @@ export default {
2600
2635
  input-id="${i.id || '' }"
2601
2636
  input-key="${i.key || i.label}"
2602
2637
  value="${v.value || ''}">
2638
+ ${icon }
2603
2639
  <span class="mini-input-section--name">
2604
2640
  ${i.label}
2605
2641
  </span>
@@ -2653,5 +2689,87 @@ export default {
2653
2689
  }));
2654
2690
  }
2655
2691
  });
2656
- }
2692
+ },
2693
+
2694
+
2695
+ createContextMenu( { config, evt=null, position = null, date=null, item=null, selected = []} ){
2696
+
2697
+ if(config.timeline.contextMenu === undefined) return {elem: null, isVisible: false} ;
2698
+
2699
+ let className = "";
2700
+ let style = "";
2701
+ let left = 0;
2702
+ let top = 0;
2703
+ let isVisible = true;
2704
+
2705
+ if(evt){
2706
+ left = evt.clientX + 5;
2707
+ top = evt.clientY + 5 - evt.currentTarget.offsetTop;
2708
+ }
2709
+
2710
+ if(position){
2711
+ style += `top: ${ top }px; left: ${ left }px`;
2712
+ }else{
2713
+ className += "cm-hide";
2714
+ isVisible = false;
2715
+ }
2716
+
2717
+
2718
+ let strHtml = '';
2719
+
2720
+ strHtml += ` <div class="cap-context-menu-container ${className}">
2721
+ <div class="cap-context-menu" style="${style}">
2722
+ </div>
2723
+ </div>`;
2724
+
2725
+ let $contextMenuContainer = dom.createElementFromHTML(strHtml);
2726
+ let $contextMenu = $contextMenuContainer.querySelector(".cap-context-menu");
2727
+
2728
+ config.timeline.contextMenu.options.forEach(option => {
2729
+
2730
+ if(option.showIf){
2731
+ let show = option.showIf({item, date, selected});
2732
+ if(!show) return;
2733
+ }
2734
+
2735
+
2736
+ let isEnabled = true;
2737
+ if(option.enableIf){
2738
+ isEnabled = option.enableIf({item, date, selected});
2739
+ }
2740
+
2741
+ let optionClassName = "";
2742
+
2743
+ if(!isEnabled){
2744
+ optionClassName += "is-disabled";
2745
+ }
2746
+
2747
+ let optionStrHtml = `
2748
+ <div class="cap-context-menu--item ${optionClassName}">
2749
+ ${option.label}
2750
+ </div>`;
2751
+
2752
+ let $option = dom.createElementFromHTML(optionStrHtml);
2753
+
2754
+ if(isEnabled){
2755
+ $option.addEventListener("click", (evtClick) => option.onClick({
2756
+ config, evt:evtClick, date, item, selected
2757
+ }));
2758
+ }else{
2759
+ $option.addEventListener("click", (evtClick) => {
2760
+ evtClick.preventDefault();
2761
+ evtClick.stopPropagation();
2762
+ });
2763
+ }
2764
+
2765
+ $contextMenu.append($option);
2766
+ });
2767
+
2768
+ return {
2769
+ elem: $contextMenuContainer,
2770
+ isVisible
2771
+ };
2772
+
2773
+ },
2774
+
2657
2775
  }
package/src/util/utils.js CHANGED
@@ -207,9 +207,9 @@ export default {
207
207
  eventToPosition(config, ev, elem) {
208
208
  let target = elem || ev.currentTarget;
209
209
  let rect = elem.getBoundingClientRect();
210
- let itemHeight = parseFloat(this.getCSSVariable("--item-height"));
211
- let dayWidth = parseFloat(this.getCSSVariable("--day-width"));
212
- let headerHeight = parseFloat(this.getCSSVariable("--header-height"));
210
+ let itemHeight = parseFloat(this.getCSSVariable(config, "--item-height"));
211
+ let dayWidth = parseFloat(this.getCSSVariable(config, "--day-width"));
212
+ let headerHeight = parseFloat(this.getCSSVariable(config, "--header-height"));
213
213
 
214
214
  let paddingLeft = parseInt(target.style.paddingLeft || 0); // + parseInt(elem.offsetLeft);
215
215
  let paddingTop = parseInt(target.style.paddingTop || 0); // + parseInt(elem.offsetTop);
@@ -255,8 +255,8 @@ export default {
255
255
  let target = elem || ev.currentTarget;
256
256
  let rect = elem.getBoundingClientRect();
257
257
  let rectParent = elem.parentElement.getBoundingClientRect();
258
- let itemHeight = parseFloat(this.getCSSVariable("--item-height"));
259
- let headerHeight = parseFloat(this.getCSSVariable("--header-height"));
258
+ let itemHeight = parseFloat(this.getCSSVariable(config, "--item-height"));
259
+ let headerHeight = parseFloat(this.getCSSVariable(config, "--header-height"));
260
260
 
261
261
  let paddingTop = parseInt(target.style.paddingTop || 0);
262
262
  let topPosition = ev.clientY - paddingTop - parseInt(rect.top);
@@ -277,8 +277,8 @@ export default {
277
277
 
278
278
  getPositionByItemDate(config, item, date){
279
279
 
280
- let h = parseFloat(this.getCSSVariable("--item-height"));
281
- let w = parseFloat(this.getCSSVariable("--day-width"));
280
+ let h = parseFloat(this.getCSSVariable(config, "--item-height"));
281
+ let w = parseFloat(this.getCSSVariable(config, "--day-width"));
282
282
  let y = this.getPositionByItem(config, item);
283
283
  let x = dateUtils.diffDays(config.timeline.start, date);
284
284
  let left = x * w;
@@ -432,9 +432,9 @@ export default {
432
432
  * @param {Any} value - valor a asignar a variable CSS
433
433
  */
434
434
 
435
- setCSSVariable(varName, value) {
436
- let root = document.documentElement;
437
- root.style.setProperty(varName,value);
435
+ setCSSVariable(config, varName, value) {
436
+ let containerElement = document.querySelector(config.selector);
437
+ containerElement.style.setProperty(varName,value);
438
438
  },
439
439
 
440
440
  /**
@@ -443,9 +443,9 @@ export default {
443
443
  * @return {Float} Numero redondeado
444
444
  */
445
445
 
446
- getCSSVariable(varName) {
447
- let root = document.documentElement;
448
- return getComputedStyle(root).getPropertyValue(varName);
446
+ getCSSVariable(config, varName) {
447
+ let containerElement = document.querySelector(config.selector);
448
+ return getComputedStyle(containerElement).getPropertyValue(varName);
449
449
  },
450
450
 
451
451