@ai-table/grid 0.5.2 → 0.5.4

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.
@@ -11830,11 +11830,10 @@ function toggleSelectAllRecords(aiTable, checked) {
11830
11830
  }
11831
11831
  function getNextRecordByActiveCell(aiTable) {
11832
11832
  const records = aiTable.gridData().records;
11833
- const visibleRowsIndexMap = aiTable.context.visibleRowsIndexMap();
11834
11833
  const currentId = aiTable.selection().activeCell?.[0];
11835
11834
  if (!currentId)
11836
11835
  return null;
11837
- const currentIndex = visibleRowsIndexMap.get(currentId) || 0;
11836
+ const currentIndex = records.findIndex((item) => item._id === currentId);
11838
11837
  if (currentIndex === -1 || currentIndex === records.length - 1) {
11839
11838
  return null;
11840
11839
  }
@@ -11843,11 +11842,10 @@ function getNextRecordByActiveCell(aiTable) {
11843
11842
  }
11844
11843
  function getPreviousRecordByActiveCell(aiTable) {
11845
11844
  const records = aiTable.gridData().records;
11846
- const visibleRowsIndexMap = aiTable.context.visibleRowsIndexMap();
11847
11845
  const currentId = aiTable.selection().activeCell?.[0];
11848
11846
  if (!currentId)
11849
11847
  return null;
11850
- const currentIndex = visibleRowsIndexMap.get(currentId) || 0;
11848
+ const currentIndex = records.findIndex((item) => item._id === currentId);
11851
11849
  if (currentIndex <= 0) {
11852
11850
  return null;
11853
11851
  }
@@ -11856,8 +11854,7 @@ function getPreviousRecordByActiveCell(aiTable) {
11856
11854
  }
11857
11855
  function getRecordNavigationInfo(aiTable, recordId) {
11858
11856
  const records = aiTable.gridData().records;
11859
- const visibleRowsIndexMap = aiTable.context.visibleRowsIndexMap();
11860
- const index = visibleRowsIndexMap.get(recordId) || 0;
11857
+ const index = records.findIndex((item) => item._id === recordId);
11861
11858
  if (index === -1)
11862
11859
  return null;
11863
11860
  return {
@@ -12653,6 +12650,7 @@ class RecordDetailComponent {
12653
12650
  this.activeFieldId = null;
12654
12651
  this.fieldMenuActive = signal({}, ...(ngDevMode ? [{ debugName: "fieldMenuActive" }] : []));
12655
12652
  this.fieldMenuPopoverRef = null;
12653
+ this.currentPopoverFieldId = null;
12656
12654
  this.slideRef = inject(ThySlideRef);
12657
12655
  this.thyPopover = inject(ThyPopover);
12658
12656
  effect(() => {
@@ -12668,6 +12666,17 @@ class RecordDetailComponent {
12668
12666
  this.internalRecordId.set(activeCell[0]);
12669
12667
  }
12670
12668
  });
12669
+ effect(() => {
12670
+ const fields = this.fields();
12671
+ if (this.currentPopoverFieldId && this.fieldMenuPopoverRef) {
12672
+ const fieldExists = fields.some((field) => field._id === this.currentPopoverFieldId);
12673
+ if (!fieldExists) {
12674
+ this.fieldMenuPopoverRef.close();
12675
+ this.fieldMenuPopoverRef = null;
12676
+ this.currentPopoverFieldId = null;
12677
+ }
12678
+ }
12679
+ });
12671
12680
  }
12672
12681
  updateRecordId(recordId) {
12673
12682
  this.recordId.set(recordId);
@@ -12698,6 +12707,7 @@ class RecordDetailComponent {
12698
12707
  const origin = e.currentTarget;
12699
12708
  const position = fieldMenuOrigin.getBoundingClientRect();
12700
12709
  this.fieldMenuActive.set({ [fieldId]: true });
12710
+ this.currentPopoverFieldId = fieldId;
12701
12711
  let isSelfClose = false;
12702
12712
  this.fieldMenuPopoverRef =
12703
12713
  this.thyPopover.open(AITableFieldMenu, {
@@ -12723,6 +12733,7 @@ class RecordDetailComponent {
12723
12733
  this.fieldMenuActive.set({ [fieldId]: false });
12724
12734
  }
12725
12735
  this.fieldMenuPopoverRef = null;
12736
+ this.currentPopoverFieldId = null;
12726
12737
  });
12727
12738
  }
12728
12739
  }