capibara 1.3.64 → 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.64",
3
+ "version": "1.3.65",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -986,6 +986,8 @@ export class Capibara{
986
986
  this.selected.splice(index, 1);
987
987
  }
988
988
 
989
+ this.refreshInputsShowInputIf();
990
+
989
991
  this.setIndexToSelected();
990
992
 
991
993
  if(redraw){
@@ -1021,6 +1023,8 @@ export class Capibara{
1021
1023
  this.redraw({
1022
1024
  cornerRight: true,
1023
1025
  });
1026
+ this.$navRightDataDay = dataDay;
1027
+ this.$navRightDaySelected = this.selected[0];
1024
1028
  let {inputs, element, inputsWithReload, saveCancelBtns} = tableElements.redrawNavRight(this.config, this.$elements.$navRight, this.selected, this.tabSelected, dataDay, this.selected[0]);
1025
1029
  this.$elements.$navRight = element;
1026
1030
  this.$inputsNavRight = inputs;
@@ -1030,6 +1034,8 @@ export class Capibara{
1030
1034
 
1031
1035
  }
1032
1036
 
1037
+ this.refreshInputsShowInputIf();
1038
+
1033
1039
 
1034
1040
  let focused = false;
1035
1041
  if(!(this.isMobile && this.mobileSelectable)){
@@ -1057,6 +1063,30 @@ export class Capibara{
1057
1063
  };
1058
1064
 
1059
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
+
1060
1090
  setIndexToSelected(){
1061
1091
  this.selected.forEach((s, index) => {
1062
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
 
@@ -4432,21 +4444,53 @@ export default {
4432
4444
  if (dataDay && dataDay.values) {
4433
4445
  value = utils.getVarByPath(dataDay, props.varName);
4434
4446
  }
4447
+ let tooltipAttr = props.tooltip ? `cap-tooltip="${props.tooltip}"` : "";
4448
+ let tooltipClass = props.tooltip ? "cap-tooltip-wide" : "";
4435
4449
  let r = dom.createElementFromHTML(`
4436
4450
  <div class="input-section ${props.isHidden ? "hide" : ""} " input-key="${
4437
4451
  props.key || ""
4438
4452
  }">
4439
- <label>
4453
+ <label class="cap-checkbox-label ${tooltipClass}" ${tooltipAttr} style="display:flex;align-items:center;gap:0.4em;">
4440
4454
  <input type="checkbox" name="${props.key || ""}" input-key="${
4441
4455
  props.key || ""
4442
4456
  }" ${value ? "checked" : ""}>
4443
- ${props.label}
4457
+ <span style="font-weight:600;">${props.label}</span>
4444
4458
  </label>
4445
4459
  </div>`);
4446
4460
 
4447
4461
  return r;
4448
4462
  },
4449
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
+
4450
4494
  createInputButtonsGroup(props) {
4451
4495
  let $container = dom.createElementFromHTML(`
4452
4496
  <div class="input-section ${props.isHidden ? "hide" : ""} " input-key="${