@alexochihua/exos-library-components 2.25.20 → 2.25.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.
@@ -30502,6 +30502,14 @@ const EDialogvue_type_script_setup_true_lang_js_hoisted_3 = {
30502
30502
  if (!value) return true;
30503
30503
  return (value.type === 'id' || value.type === 'class') && typeof value.value === 'string';
30504
30504
  }
30505
+ },
30506
+ /**
30507
+ * Cierra el diálogo cuando hay navegación (back/forward/hash)
30508
+ * @values true - cierra en navegación, false - ignora navegación
30509
+ */
30510
+ closeOnNavigation: {
30511
+ type: Boolean,
30512
+ default: true
30505
30513
  }
30506
30514
  },
30507
30515
  emits: [
@@ -30593,6 +30601,11 @@ const EDialogvue_type_script_setup_true_lang_js_hoisted_3 = {
30593
30601
  function handleEnter() {
30594
30602
  emits('handleEnter');
30595
30603
  }
30604
+ function handleNavigationClose() {
30605
+ if (!props.closeOnNavigation) return;
30606
+ if (!showDialog.value) return;
30607
+ close();
30608
+ }
30596
30609
 
30597
30610
  // Lifecycle Hooks
30598
30611
  (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.onMounted)(() => {
@@ -30633,6 +30646,12 @@ const EDialogvue_type_script_setup_true_lang_js_hoisted_3 = {
30633
30646
  }
30634
30647
  });
30635
30648
  }
30649
+ window.addEventListener('popstate', handleNavigationClose);
30650
+ window.addEventListener('hashchange', handleNavigationClose);
30651
+ });
30652
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.onBeforeUnmount)(() => {
30653
+ window.removeEventListener('popstate', handleNavigationClose);
30654
+ window.removeEventListener('hashchange', handleNavigationClose);
30636
30655
  });
30637
30656
 
30638
30657
  // Watchers
@@ -61300,6 +61319,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61300
61319
  const numRowsByPage = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(props.rowsByPage?.[0]?.value || 10);
61301
61320
  const formRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(null);
61302
61321
  const pendingConfirmIndex = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(null);
61322
+ const visibleFieldsSnapshot = (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.ref)(null);
61303
61323
 
61304
61324
  // Inicializar items desde modelValue
61305
61325
  (0,external_commonjs_vue_commonjs2_vue_root_Vue_namespaceObject.watch)(() => props.modelValue, newValue => {
@@ -61369,29 +61389,32 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61369
61389
  * @param {Object} item - Item (registro) actual para evaluar la condición
61370
61390
  * @returns {Array} - Array de fields visibles
61371
61391
  */
61392
+ const getFieldVisibility = (field, item) => {
61393
+ // Si no tiene showWhen, mostrar el field por defecto
61394
+ if (!field.showWhen) {
61395
+ return true;
61396
+ }
61397
+
61398
+ // Si showWhen existe pero no es una función, mostrar warning y ocultar el field
61399
+ if (typeof field.showWhen !== 'function') {
61400
+ console.warn(`showWhen debe ser una función para el field "${field.field}"`);
61401
+ return false;
61402
+ }
61403
+
61404
+ // Ejecutar la función showWhen con el item
61405
+ try {
61406
+ return field.showWhen(item) === true;
61407
+ } catch (error) {
61408
+ console.warn(`Error al evaluar showWhen para el field "${field.field}":`, error);
61409
+ return false;
61410
+ }
61411
+ };
61372
61412
  const getVisibleFields = (fields, item) => {
61373
61413
  if (!fields || !Array.isArray(fields)) {
61374
61414
  return [];
61375
61415
  }
61376
61416
  return fields.filter(field => {
61377
- // Si no tiene showWhen, mostrar el field por defecto
61378
- if (!field.showWhen) {
61379
- return true;
61380
- }
61381
-
61382
- // Si showWhen existe pero no es una función, mostrar warning y ocultar el field
61383
- if (typeof field.showWhen !== 'function') {
61384
- console.warn(`showWhen debe ser una función para el field "${field.field}"`);
61385
- return false;
61386
- }
61387
-
61388
- // Ejecutar la función showWhen con el item
61389
- try {
61390
- return field.showWhen(item) === true;
61391
- } catch (error) {
61392
- console.warn(`Error al evaluar showWhen para el field "${field.field}":`, error);
61393
- return false;
61394
- }
61417
+ return getFieldVisibility(field, item);
61395
61418
  });
61396
61419
  };
61397
61420
  const getCellScope = (item, col, indexCol) => {
@@ -61595,31 +61618,42 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61595
61618
  }
61596
61619
  return baseProps;
61597
61620
  };
61598
-
61599
- /**
61600
- * Limpia los campos que están ocultos por showWhen
61601
- * @param {Object} item - Item (registro) actual
61602
- */
61603
- const cleanHiddenFields = item => {
61621
+ const buildVisibilitySnapshot = item => {
61622
+ const snapshot = {};
61604
61623
  props.columns.forEach(col => {
61605
61624
  if (col.fields && Array.isArray(col.fields)) {
61606
61625
  col.fields.forEach(field => {
61607
- // Si el campo tiene showWhen y no cumple la condición, limpiarlo
61608
- if (field.showWhen && typeof field.showWhen === 'function') {
61609
- try {
61610
- const shouldShow = field.showWhen(item) === true;
61611
- if (!shouldShow && field.field) {
61612
- // El campo está oculto, limpiar su valor
61613
- setFieldValue(item, field.field, null);
61614
- }
61615
- } catch (error) {
61616
- // Si hay error al evaluar, no hacer nada
61617
- console.warn(`Error al evaluar showWhen para limpiar el field "${field.field}":`, error);
61618
- }
61626
+ if (field.field && field.showWhen) {
61627
+ snapshot[field.field] = getFieldVisibility(field, item);
61619
61628
  }
61620
61629
  });
61621
61630
  }
61622
61631
  });
61632
+ return snapshot;
61633
+ };
61634
+ const updateVisibilitySnapshot = item => {
61635
+ visibleFieldsSnapshot.value = buildVisibilitySnapshot(item);
61636
+ };
61637
+
61638
+ /**
61639
+ * Limpia los campos que cambian de visible -> oculto durante la edición
61640
+ * @param {Object} item - Item (registro) actual
61641
+ */
61642
+ const cleanHiddenFieldsOnVisibilityChange = item => {
61643
+ if (!visibleFieldsSnapshot.value) {
61644
+ updateVisibilitySnapshot(item);
61645
+ return;
61646
+ }
61647
+ const previousSnapshot = visibleFieldsSnapshot.value;
61648
+ const currentSnapshot = buildVisibilitySnapshot(item);
61649
+ Object.keys(currentSnapshot).forEach(fieldName => {
61650
+ const wasVisible = previousSnapshot[fieldName] === true;
61651
+ const isVisible = currentSnapshot[fieldName] === true;
61652
+ if (wasVisible && !isVisible) {
61653
+ setFieldValue(item, fieldName, null);
61654
+ }
61655
+ });
61656
+ visibleFieldsSnapshot.value = currentSnapshot;
61623
61657
  };
61624
61658
  const handleFieldUpdate = (item, field, value, parentCol) => {
61625
61659
  // Actualizar el valor
@@ -61647,8 +61681,8 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61647
61681
  }
61648
61682
  });
61649
61683
 
61650
- // Limpiar campos que ahora están ocultos por showWhen
61651
- cleanHiddenFields(item);
61684
+ // Limpiar campos que ahora están ocultos por showWhen (solo si cambiaron)
61685
+ cleanHiddenFieldsOnVisibilityChange(item);
61652
61686
 
61653
61687
  // Emitir actualización para forzar re-render de componentes dependientes
61654
61688
  emit('update:modelValue', items.value);
@@ -61763,6 +61797,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61763
61797
  items.value.unshift(newItem);
61764
61798
  editingIndex.value = 0;
61765
61799
  originalData.value = null;
61800
+ updateVisibilitySnapshot(newItem);
61766
61801
  currentPage.value = 1; // Ir a la primera página para ver el nuevo elemento
61767
61802
  emit('add', {
61768
61803
  item: newItem,
@@ -61777,6 +61812,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61777
61812
  const globalIndex = getGlobalIndex(index);
61778
61813
  editingIndex.value = globalIndex;
61779
61814
  originalData.value = JSON.parse(JSON.stringify(items.value[globalIndex]));
61815
+ updateVisibilitySnapshot(items.value[globalIndex]);
61780
61816
  emit('edit', {
61781
61817
  item: items.value[globalIndex],
61782
61818
  index: globalIndex
@@ -61808,11 +61844,12 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61808
61844
  const globalIndex = pendingConfirmIndex.value;
61809
61845
  const item = items.value[globalIndex];
61810
61846
 
61811
- // Limpiar campos ocultos antes de guardar
61812
- cleanHiddenFields(item);
61847
+ // Limpiar campos ocultos solo si cambiaron durante la edición
61848
+ cleanHiddenFieldsOnVisibilityChange(item);
61813
61849
  editingIndex.value = null;
61814
61850
  originalData.value = null;
61815
61851
  pendingConfirmIndex.value = null;
61852
+ visibleFieldsSnapshot.value = null;
61816
61853
  emit('update:modelValue', items.value);
61817
61854
  emit('save', {
61818
61855
  item,
@@ -61834,6 +61871,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61834
61871
  }
61835
61872
  editingIndex.value = null;
61836
61873
  originalData.value = null;
61874
+ visibleFieldsSnapshot.value = null;
61837
61875
  emit('cancel', {
61838
61876
  item,
61839
61877
  index: globalIndex
@@ -30520,6 +30520,14 @@ const EDialogvue_type_script_setup_true_lang_js_hoisted_3 = {
30520
30520
  if (!value) return true;
30521
30521
  return (value.type === 'id' || value.type === 'class') && typeof value.value === 'string';
30522
30522
  }
30523
+ },
30524
+ /**
30525
+ * Cierra el diálogo cuando hay navegación (back/forward/hash)
30526
+ * @values true - cierra en navegación, false - ignora navegación
30527
+ */
30528
+ closeOnNavigation: {
30529
+ type: Boolean,
30530
+ default: true
30523
30531
  }
30524
30532
  },
30525
30533
  emits: [
@@ -30611,6 +30619,11 @@ const EDialogvue_type_script_setup_true_lang_js_hoisted_3 = {
30611
30619
  function handleEnter() {
30612
30620
  emits('handleEnter');
30613
30621
  }
30622
+ function handleNavigationClose() {
30623
+ if (!props.closeOnNavigation) return;
30624
+ if (!showDialog.value) return;
30625
+ close();
30626
+ }
30614
30627
 
30615
30628
  // Lifecycle Hooks
30616
30629
  (0,external_commonjs_vue_commonjs2_vue_root_Vue_.onMounted)(() => {
@@ -30651,6 +30664,12 @@ const EDialogvue_type_script_setup_true_lang_js_hoisted_3 = {
30651
30664
  }
30652
30665
  });
30653
30666
  }
30667
+ window.addEventListener('popstate', handleNavigationClose);
30668
+ window.addEventListener('hashchange', handleNavigationClose);
30669
+ });
30670
+ (0,external_commonjs_vue_commonjs2_vue_root_Vue_.onBeforeUnmount)(() => {
30671
+ window.removeEventListener('popstate', handleNavigationClose);
30672
+ window.removeEventListener('hashchange', handleNavigationClose);
30654
30673
  });
30655
30674
 
30656
30675
  // Watchers
@@ -61318,6 +61337,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61318
61337
  const numRowsByPage = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(props.rowsByPage?.[0]?.value || 10);
61319
61338
  const formRef = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(null);
61320
61339
  const pendingConfirmIndex = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(null);
61340
+ const visibleFieldsSnapshot = (0,external_commonjs_vue_commonjs2_vue_root_Vue_.ref)(null);
61321
61341
 
61322
61342
  // Inicializar items desde modelValue
61323
61343
  (0,external_commonjs_vue_commonjs2_vue_root_Vue_.watch)(() => props.modelValue, newValue => {
@@ -61387,29 +61407,32 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61387
61407
  * @param {Object} item - Item (registro) actual para evaluar la condición
61388
61408
  * @returns {Array} - Array de fields visibles
61389
61409
  */
61410
+ const getFieldVisibility = (field, item) => {
61411
+ // Si no tiene showWhen, mostrar el field por defecto
61412
+ if (!field.showWhen) {
61413
+ return true;
61414
+ }
61415
+
61416
+ // Si showWhen existe pero no es una función, mostrar warning y ocultar el field
61417
+ if (typeof field.showWhen !== 'function') {
61418
+ console.warn(`showWhen debe ser una función para el field "${field.field}"`);
61419
+ return false;
61420
+ }
61421
+
61422
+ // Ejecutar la función showWhen con el item
61423
+ try {
61424
+ return field.showWhen(item) === true;
61425
+ } catch (error) {
61426
+ console.warn(`Error al evaluar showWhen para el field "${field.field}":`, error);
61427
+ return false;
61428
+ }
61429
+ };
61390
61430
  const getVisibleFields = (fields, item) => {
61391
61431
  if (!fields || !Array.isArray(fields)) {
61392
61432
  return [];
61393
61433
  }
61394
61434
  return fields.filter(field => {
61395
- // Si no tiene showWhen, mostrar el field por defecto
61396
- if (!field.showWhen) {
61397
- return true;
61398
- }
61399
-
61400
- // Si showWhen existe pero no es una función, mostrar warning y ocultar el field
61401
- if (typeof field.showWhen !== 'function') {
61402
- console.warn(`showWhen debe ser una función para el field "${field.field}"`);
61403
- return false;
61404
- }
61405
-
61406
- // Ejecutar la función showWhen con el item
61407
- try {
61408
- return field.showWhen(item) === true;
61409
- } catch (error) {
61410
- console.warn(`Error al evaluar showWhen para el field "${field.field}":`, error);
61411
- return false;
61412
- }
61435
+ return getFieldVisibility(field, item);
61413
61436
  });
61414
61437
  };
61415
61438
  const getCellScope = (item, col, indexCol) => {
@@ -61613,31 +61636,42 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61613
61636
  }
61614
61637
  return baseProps;
61615
61638
  };
61616
-
61617
- /**
61618
- * Limpia los campos que están ocultos por showWhen
61619
- * @param {Object} item - Item (registro) actual
61620
- */
61621
- const cleanHiddenFields = item => {
61639
+ const buildVisibilitySnapshot = item => {
61640
+ const snapshot = {};
61622
61641
  props.columns.forEach(col => {
61623
61642
  if (col.fields && Array.isArray(col.fields)) {
61624
61643
  col.fields.forEach(field => {
61625
- // Si el campo tiene showWhen y no cumple la condición, limpiarlo
61626
- if (field.showWhen && typeof field.showWhen === 'function') {
61627
- try {
61628
- const shouldShow = field.showWhen(item) === true;
61629
- if (!shouldShow && field.field) {
61630
- // El campo está oculto, limpiar su valor
61631
- setFieldValue(item, field.field, null);
61632
- }
61633
- } catch (error) {
61634
- // Si hay error al evaluar, no hacer nada
61635
- console.warn(`Error al evaluar showWhen para limpiar el field "${field.field}":`, error);
61636
- }
61644
+ if (field.field && field.showWhen) {
61645
+ snapshot[field.field] = getFieldVisibility(field, item);
61637
61646
  }
61638
61647
  });
61639
61648
  }
61640
61649
  });
61650
+ return snapshot;
61651
+ };
61652
+ const updateVisibilitySnapshot = item => {
61653
+ visibleFieldsSnapshot.value = buildVisibilitySnapshot(item);
61654
+ };
61655
+
61656
+ /**
61657
+ * Limpia los campos que cambian de visible -> oculto durante la edición
61658
+ * @param {Object} item - Item (registro) actual
61659
+ */
61660
+ const cleanHiddenFieldsOnVisibilityChange = item => {
61661
+ if (!visibleFieldsSnapshot.value) {
61662
+ updateVisibilitySnapshot(item);
61663
+ return;
61664
+ }
61665
+ const previousSnapshot = visibleFieldsSnapshot.value;
61666
+ const currentSnapshot = buildVisibilitySnapshot(item);
61667
+ Object.keys(currentSnapshot).forEach(fieldName => {
61668
+ const wasVisible = previousSnapshot[fieldName] === true;
61669
+ const isVisible = currentSnapshot[fieldName] === true;
61670
+ if (wasVisible && !isVisible) {
61671
+ setFieldValue(item, fieldName, null);
61672
+ }
61673
+ });
61674
+ visibleFieldsSnapshot.value = currentSnapshot;
61641
61675
  };
61642
61676
  const handleFieldUpdate = (item, field, value, parentCol) => {
61643
61677
  // Actualizar el valor
@@ -61665,8 +61699,8 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61665
61699
  }
61666
61700
  });
61667
61701
 
61668
- // Limpiar campos que ahora están ocultos por showWhen
61669
- cleanHiddenFields(item);
61702
+ // Limpiar campos que ahora están ocultos por showWhen (solo si cambiaron)
61703
+ cleanHiddenFieldsOnVisibilityChange(item);
61670
61704
 
61671
61705
  // Emitir actualización para forzar re-render de componentes dependientes
61672
61706
  emit('update:modelValue', items.value);
@@ -61781,6 +61815,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61781
61815
  items.value.unshift(newItem);
61782
61816
  editingIndex.value = 0;
61783
61817
  originalData.value = null;
61818
+ updateVisibilitySnapshot(newItem);
61784
61819
  currentPage.value = 1; // Ir a la primera página para ver el nuevo elemento
61785
61820
  emit('add', {
61786
61821
  item: newItem,
@@ -61795,6 +61830,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61795
61830
  const globalIndex = getGlobalIndex(index);
61796
61831
  editingIndex.value = globalIndex;
61797
61832
  originalData.value = JSON.parse(JSON.stringify(items.value[globalIndex]));
61833
+ updateVisibilitySnapshot(items.value[globalIndex]);
61798
61834
  emit('edit', {
61799
61835
  item: items.value[globalIndex],
61800
61836
  index: globalIndex
@@ -61826,11 +61862,12 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61826
61862
  const globalIndex = pendingConfirmIndex.value;
61827
61863
  const item = items.value[globalIndex];
61828
61864
 
61829
- // Limpiar campos ocultos antes de guardar
61830
- cleanHiddenFields(item);
61865
+ // Limpiar campos ocultos solo si cambiaron durante la edición
61866
+ cleanHiddenFieldsOnVisibilityChange(item);
61831
61867
  editingIndex.value = null;
61832
61868
  originalData.value = null;
61833
61869
  pendingConfirmIndex.value = null;
61870
+ visibleFieldsSnapshot.value = null;
61834
61871
  emit('update:modelValue', items.value);
61835
61872
  emit('save', {
61836
61873
  item,
@@ -61852,6 +61889,7 @@ const EDynamicTablevue_type_script_setup_true_lang_js_hoisted_16 = {
61852
61889
  }
61853
61890
  editingIndex.value = null;
61854
61891
  originalData.value = null;
61892
+ visibleFieldsSnapshot.value = null;
61855
61893
  emit('cancel', {
61856
61894
  item,
61857
61895
  index: globalIndex