capibara 1.3.63 → 1.3.65

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.3.63",
3
+ "version": "1.3.65",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -382,6 +382,9 @@ export class Capibara{
382
382
  setVisibleSidebarRight(show = true){
383
383
  let fn = show ? "add" : "remove";
384
384
  this.$capibara.classList[fn]("extended-right");
385
+ this.refreshScrollUtilsVars();
386
+ this.refreshVirtualScrollVars();
387
+ this.refreshVirtualScroll();
385
388
  }
386
389
 
387
390
 
@@ -983,6 +986,8 @@ export class Capibara{
983
986
  this.selected.splice(index, 1);
984
987
  }
985
988
 
989
+ this.refreshInputsShowInputIf();
990
+
986
991
  this.setIndexToSelected();
987
992
 
988
993
  if(redraw){
@@ -1018,6 +1023,8 @@ export class Capibara{
1018
1023
  this.redraw({
1019
1024
  cornerRight: true,
1020
1025
  });
1026
+ this.$navRightDataDay = dataDay;
1027
+ this.$navRightDaySelected = this.selected[0];
1021
1028
  let {inputs, element, inputsWithReload, saveCancelBtns} = tableElements.redrawNavRight(this.config, this.$elements.$navRight, this.selected, this.tabSelected, dataDay, this.selected[0]);
1022
1029
  this.$elements.$navRight = element;
1023
1030
  this.$inputsNavRight = inputs;
@@ -1027,6 +1034,8 @@ export class Capibara{
1027
1034
 
1028
1035
  }
1029
1036
 
1037
+ this.refreshInputsShowInputIf();
1038
+
1030
1039
 
1031
1040
  let focused = false;
1032
1041
  if(!(this.isMobile && this.mobileSelectable)){
@@ -1054,6 +1063,30 @@ export class Capibara{
1054
1063
  };
1055
1064
 
1056
1065
 
1066
+ /**
1067
+ * Re-evalua showInputIf/disabledIf de cada input del sidebar derecho contra la seleccion actual,
1068
+ * mostrando/ocultando o habilitando/deshabilitando sin perder los valores ya ingresados por el usuario.
1069
+ */
1070
+ refreshInputsShowInputIf(){
1071
+ if(!this.$inputsNavRight || !this.tabSelected || !this.tabSelected.inputs) return;
1072
+
1073
+ this.$inputsNavRight.forEach($input => {
1074
+ let key = $input.getAttribute("input-key");
1075
+ let inputConfig = this.tabSelected.inputs.find(t => t.key == key);
1076
+ if(!inputConfig) return;
1077
+
1078
+ if(inputConfig.showInputIf){
1079
+ let isVisible = inputConfig.showInputIf(this.$navRightDataDay, this.$navRightDaySelected, this.selected, this.tabSelected);
1080
+ $input.classList[isVisible ? "remove" : "add"]("hide");
1081
+ }
1082
+
1083
+ if(inputConfig.disabledIf){
1084
+ tableElements.applyDisabledIf($input, inputConfig, this.$navRightDataDay, this.$navRightDaySelected, this.selected, this.tabSelected);
1085
+ }
1086
+ });
1087
+ };
1088
+
1089
+
1057
1090
  setIndexToSelected(){
1058
1091
  this.selected.forEach((s, index) => {
1059
1092
  s.index = index+1;
@@ -519,6 +519,25 @@
519
519
  height: 18px;
520
520
  vertical-align: middle;
521
521
  }
522
+
523
+ .cap-checkbox-label {
524
+ border-radius: 6px;
525
+ padding: 4px 6px;
526
+ margin: -4px -6px;
527
+ transition: background-color 0.15s ease;
528
+ cursor: pointer;
529
+
530
+ &:hover {
531
+ background-color: rgba(25, 118, 210, 0.15);
532
+ }
533
+
534
+ &.is-disabled {
535
+ cursor: not-allowed;
536
+ &:hover {
537
+ background-color: transparent;
538
+ }
539
+ }
540
+ }
522
541
  }
523
542
 
524
543
  @each $nameTheme, $theme in $themes {
@@ -34,5 +34,11 @@
34
34
  min-width: 100px;
35
35
  z-index: 5;
36
36
  }
37
+
38
+ &.cap-tooltip-wide:before {
39
+ min-width: 240px;
40
+ max-width: 340px;
41
+ white-space: normal;
42
+ }
37
43
  }
38
44
  }
@@ -1926,12 +1926,6 @@ export default {
1926
1926
  if (tabSelected && tabSelected.inputs) {
1927
1927
  tabSelected.inputs.forEach((i) => {
1928
1928
  if (i.disabled) return;
1929
- if (
1930
- i.showInputIf &&
1931
- !i.showInputIf(dataDay, daySelected, selected, tabSelected)
1932
- ) {
1933
- return;
1934
- }
1935
1929
 
1936
1930
  let $input = this.createInput(
1937
1931
  i,
@@ -1941,6 +1935,24 @@ export default {
1941
1935
  tabSelected
1942
1936
  );
1943
1937
  if ($input) {
1938
+ if (
1939
+ i.showInputIf &&
1940
+ !i.showInputIf(dataDay, daySelected, selected, tabSelected)
1941
+ ) {
1942
+ $input.classList.add("hide");
1943
+ }
1944
+
1945
+ if (i.disabledIf) {
1946
+ this.applyDisabledIf(
1947
+ $input,
1948
+ i,
1949
+ dataDay,
1950
+ daySelected,
1951
+ selected,
1952
+ tabSelected
1953
+ );
1954
+ }
1955
+
1944
1956
  $divContainer.appendChild($input);
1945
1957
  $inputs.push($input);
1946
1958
 
@@ -2878,19 +2890,11 @@ export default {
2878
2890
  </div >
2879
2891
  <div class="val">` +
2880
2892
  (v.hidePreffix !== true
2881
- ? `
2882
- <span class="prefix">
2883
- ${v.prefix || ""}
2884
- </span>`
2893
+ ? `<span class="prefix">${v.prefix || ""}</span>`
2885
2894
  : "") +
2886
- `<span class="value">
2887
- ${outputValue}
2888
- </span>` +
2895
+ `<span class="value">${outputValue}</span>` +
2889
2896
  (v.hideSuffix !== true
2890
- ? `
2891
- <span class="suffix">
2892
- ${valueLabeled.suffix || v.suffix || ""}
2893
- </span>`
2897
+ ? `<span class="suffix">${valueLabeled.suffix || v.suffix || ""}</span>`
2894
2898
  : "") +
2895
2899
  `
2896
2900
  </div>
@@ -4440,21 +4444,53 @@ export default {
4440
4444
  if (dataDay && dataDay.values) {
4441
4445
  value = utils.getVarByPath(dataDay, props.varName);
4442
4446
  }
4447
+ let tooltipAttr = props.tooltip ? `cap-tooltip="${props.tooltip}"` : "";
4448
+ let tooltipClass = props.tooltip ? "cap-tooltip-wide" : "";
4443
4449
  let r = dom.createElementFromHTML(`
4444
4450
  <div class="input-section ${props.isHidden ? "hide" : ""} " input-key="${
4445
4451
  props.key || ""
4446
4452
  }">
4447
- <label>
4453
+ <label class="cap-checkbox-label ${tooltipClass}" ${tooltipAttr} style="display:flex;align-items:center;gap:0.4em;">
4448
4454
  <input type="checkbox" name="${props.key || ""}" input-key="${
4449
4455
  props.key || ""
4450
4456
  }" ${value ? "checked" : ""}>
4451
- ${props.label}
4457
+ <span style="font-weight:600;">${props.label}</span>
4452
4458
  </label>
4453
4459
  </div>`);
4454
4460
 
4455
4461
  return r;
4456
4462
  },
4457
4463
 
4464
+ /**
4465
+ * Aplica/actualiza estado disabled de un input segun disabledIf, sin ocultarlo
4466
+ *
4467
+ * @param {Object} $input - elemento Dom del input (contenedor .input-section)
4468
+ * @param {Object} props - config del input, debe tener disabledIf
4469
+ * @param {Object} dataDay - dia de referencia usado al renderizar el sidebar
4470
+ * @param {Object} daySelected - primer seleccionado, usado al renderizar el sidebar
4471
+ * @param {Array} selected - seleccion actual
4472
+ * @param {Object} tabSelected - tab actual
4473
+ */
4474
+ applyDisabledIf($input, props, dataDay, daySelected, selected, tabSelected) {
4475
+ if (!props.disabledIf) return;
4476
+
4477
+ let isDisabled = !!props.disabledIf(dataDay, daySelected, selected, tabSelected);
4478
+ let $control = $input.querySelector("input, select, textarea, button");
4479
+ if ($control) {
4480
+ $control.disabled = isDisabled;
4481
+ $control.style.opacity = isDisabled ? "0.5" : "";
4482
+ }
4483
+
4484
+ let $span = $input.querySelector("label > span");
4485
+ if ($span) {
4486
+ $span.style.opacity = isDisabled ? "0.5" : "";
4487
+ }
4488
+
4489
+ let $label = $input.querySelector("label") || $input;
4490
+ $label.style.cursor = isDisabled ? "not-allowed" : "";
4491
+ $label.classList[isDisabled ? "add" : "remove"]("is-disabled");
4492
+ },
4493
+
4458
4494
  createInputButtonsGroup(props) {
4459
4495
  let $container = dom.createElementFromHTML(`
4460
4496
  <div class="input-section ${props.isHidden ? "hide" : ""} " input-key="${