@memberjunction/ng-base-forms 6.2.0-edge.0 → 6.2.0-edge.1

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.
Files changed (73) hide show
  1. package/dist/lib/base-form-section-info.js +5 -5
  2. package/dist/lib/base-form-section-info.js.map +1 -1
  3. package/dist/lib/chrome/resolve-form-chrome.d.ts.map +1 -1
  4. package/dist/lib/chrome/resolve-form-chrome.js +22 -12
  5. package/dist/lib/chrome/resolve-form-chrome.js.map +1 -1
  6. package/dist/lib/container/record-form-container.component.d.ts +20 -12
  7. package/dist/lib/container/record-form-container.component.d.ts.map +1 -1
  8. package/dist/lib/container/record-form-container.component.js +129 -113
  9. package/dist/lib/container/record-form-container.component.js.map +1 -1
  10. package/dist/lib/explorer-entity-data-grid.component.d.ts +18 -1
  11. package/dist/lib/explorer-entity-data-grid.component.d.ts.map +1 -1
  12. package/dist/lib/explorer-entity-data-grid.component.js +38 -10
  13. package/dist/lib/explorer-entity-data-grid.component.js.map +1 -1
  14. package/dist/lib/field/form-field.component.d.ts +37 -5
  15. package/dist/lib/field/form-field.component.d.ts.map +1 -1
  16. package/dist/lib/field/form-field.component.js +106 -20
  17. package/dist/lib/field/form-field.component.js.map +1 -1
  18. package/dist/lib/form-state.service.d.ts +58 -0
  19. package/dist/lib/form-state.service.d.ts.map +1 -1
  20. package/dist/lib/form-state.service.js +156 -40
  21. package/dist/lib/form-state.service.js.map +1 -1
  22. package/dist/lib/host/entity-form-host.component.d.ts +10 -2
  23. package/dist/lib/host/entity-form-host.component.d.ts.map +1 -1
  24. package/dist/lib/host/entity-form-host.component.js +24 -8
  25. package/dist/lib/host/entity-form-host.component.js.map +1 -1
  26. package/dist/lib/interactive-form/interactive-form.component.d.ts +16 -4
  27. package/dist/lib/interactive-form/interactive-form.component.d.ts.map +1 -1
  28. package/dist/lib/interactive-form/interactive-form.component.js +38 -12
  29. package/dist/lib/interactive-form/interactive-form.component.js.map +1 -1
  30. package/dist/lib/isa-related-panel/isa-related-card.component.d.ts +3 -3
  31. package/dist/lib/isa-related-panel/isa-related-card.component.js +6 -6
  32. package/dist/lib/isa-related-panel/isa-related-card.component.js.map +1 -1
  33. package/dist/lib/isa-related-panel/isa-related-panel.component.d.ts +3 -3
  34. package/dist/lib/isa-related-panel/isa-related-panel.component.js +8 -8
  35. package/dist/lib/isa-related-panel/isa-related-panel.component.js.map +1 -1
  36. package/dist/lib/overlays/form-slide-in.component.d.ts +2 -0
  37. package/dist/lib/overlays/form-slide-in.component.d.ts.map +1 -1
  38. package/dist/lib/overlays/form-slide-in.component.js +5 -1
  39. package/dist/lib/overlays/form-slide-in.component.js.map +1 -1
  40. package/dist/lib/panel/collapsible-panel.component.d.ts +9 -9
  41. package/dist/lib/panel/collapsible-panel.component.js +23 -23
  42. package/dist/lib/panel/collapsible-panel.component.js.map +1 -1
  43. package/dist/lib/panel-slot/base-form-panel.d.ts +2 -0
  44. package/dist/lib/panel-slot/base-form-panel.d.ts.map +1 -1
  45. package/dist/lib/panel-slot/base-form-panel.js +5 -1
  46. package/dist/lib/panel-slot/base-form-panel.js.map +1 -1
  47. package/dist/lib/panel-slot/form-contribution.d.ts +12 -0
  48. package/dist/lib/panel-slot/form-contribution.d.ts.map +1 -1
  49. package/dist/lib/panel-slot/form-contribution.js +43 -10
  50. package/dist/lib/panel-slot/form-contribution.js.map +1 -1
  51. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts +10 -0
  52. package/dist/lib/panel-slot/form-slot-coordinator.service.d.ts.map +1 -1
  53. package/dist/lib/panel-slot/form-slot-coordinator.service.js +25 -5
  54. package/dist/lib/panel-slot/form-slot-coordinator.service.js.map +1 -1
  55. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts +2 -0
  56. package/dist/lib/panel-slot/related-entity-grid-panel.component.d.ts.map +1 -1
  57. package/dist/lib/panel-slot/related-entity-grid-panel.component.js +5 -1
  58. package/dist/lib/panel-slot/related-entity-grid-panel.component.js.map +1 -1
  59. package/dist/lib/section-loader-component.d.ts +5 -1
  60. package/dist/lib/section-loader-component.d.ts.map +1 -1
  61. package/dist/lib/section-loader-component.js +13 -5
  62. package/dist/lib/section-loader-component.js.map +1 -1
  63. package/dist/lib/section-manager/section-manager.component.d.ts +2 -2
  64. package/dist/lib/section-manager/section-manager.component.js +6 -6
  65. package/dist/lib/section-manager/section-manager.component.js.map +1 -1
  66. package/dist/lib/toolbar/form-toolbar.component.d.ts +5 -5
  67. package/dist/lib/toolbar/form-toolbar.component.js +22 -22
  68. package/dist/lib/toolbar/form-toolbar.component.js.map +1 -1
  69. package/dist/lib/types/form-types.d.ts +2 -0
  70. package/dist/lib/types/form-types.d.ts.map +1 -1
  71. package/dist/lib/types/form-types.js +5 -1
  72. package/dist/lib/types/form-types.js.map +1 -1
  73. package/package.json +18 -18
@@ -1309,7 +1309,20 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1309
1309
  get IsRequired() {
1310
1310
  return this.FieldInfo?.AllowsNull === false;
1311
1311
  }
1312
- /** Whether this is a required field that is currently empty (for validation styling) */
1312
+ /**
1313
+ * Whether this is a required field that is currently empty (for validation styling).
1314
+ *
1315
+ * "Empty" means null/undefined ONLY — an empty string is a VALUE, not absence (MJ #4359).
1316
+ * `IsRequired` here is derived from `AllowsNull === false`, i.e. the column's nullability, and a
1317
+ * NOT NULL string column accepts `''` in both SQL Server and `EntityField.Validate()`. Counting
1318
+ * `''` as empty therefore painted a field red that would save perfectly well — the form and the
1319
+ * save disagreed about the same value, and the section indicators inherited the disagreement.
1320
+ *
1321
+ * Requiring actual text is a separate, deliberate constraint (an `IsRequired`-style flag of the
1322
+ * kind `ActionParam` / `TemplateParam` carry, or a CHECK constraint), not something to infer from
1323
+ * nullability. Until such a flag exists for entity fields, this getter mirrors what the save will
1324
+ * actually refuse.
1325
+ */
1313
1326
  get IsRequiredEmpty() {
1314
1327
  // Defer to the validation system when it has active errors for this field
1315
1328
  if (this.ShowErrors)
@@ -1317,7 +1330,7 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1317
1330
  if (!this.IsRequired || !this.EditMode)
1318
1331
  return false;
1319
1332
  const val = this.Value;
1320
- return val === null || val === undefined || val === '';
1333
+ return val === null || val === undefined;
1321
1334
  }
1322
1335
  // ---- INLINE VALIDATION ----
1323
1336
  /** Whether the user has interacted with (changed) this field */
@@ -1589,7 +1602,7 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1589
1602
  * people to offer first. Each strategy documents its own keys.
1590
1603
  */
1591
1604
  FKLookupOptions = {};
1592
- /** Cleanup function for scroll/resize listeners */
1605
+ /** Cleanup function for the scroll/resize/outside-press listeners armed while a dropdown is open */
1593
1606
  _scrollCleanup = null;
1594
1607
  /** Inline style for the fixed-position dropdown */
1595
1608
  get DropdownPositionStyle() {
@@ -1665,6 +1678,12 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1665
1678
  // the DOM yet when we first look, so retry across a few frames until it renders.
1666
1679
  // (The async DB path lands here post-render, so it succeeds on the first try.)
1667
1680
  const tryPortal = (retriesLeft) => {
1681
+ // The portal runs a tick after the open. If the field was destroyed or the panel
1682
+ // dismissed in between, moving the node to <body> now would orphan it there: a destroyed
1683
+ // component has no ngOnDestroy left to remove it, and a closed panel's @if has already
1684
+ // let go of it.
1685
+ if (this._destroyed || !this.ShowFKDropdown)
1686
+ return;
1668
1687
  const host = this.hostRef?.nativeElement;
1669
1688
  if (!host)
1670
1689
  return;
@@ -1683,7 +1702,12 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1683
1702
  }
1684
1703
  /** Tracks a dropdown element we relocated to body so we can drop the reference on close. */
1685
1704
  _portaledDropdownEl = null;
1686
- /** Start listening for scroll/resize to close dropdowns */
1705
+ /** Set in ngOnDestroy so deferred work (the portal microtask) knows not to touch the DOM. */
1706
+ _destroyed = false;
1707
+ /**
1708
+ * Arm the listeners that dismiss an open dropdown from outside the field: an ancestor scroll,
1709
+ * a resize, and a pointer press anywhere but the field or its panel.
1710
+ */
1687
1711
  startScrollListener() {
1688
1712
  this.stopScrollListener();
1689
1713
  const onScroll = (e) => {
@@ -1700,11 +1724,28 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1700
1724
  this.closeAllDropdowns();
1701
1725
  this.cdr.markForCheck();
1702
1726
  };
1727
+ // A press outside the field and its panel dismisses, whether or not the input has focus.
1728
+ // The input's blur covers the ordinary case, but the panel is portaled to <body> and must
1729
+ // own its dismissal: a panel that is open while nothing has focus has no blur to come, and
1730
+ // the input's Escape handler cannot hear a key it is not focused for.
1731
+ const onPointerDown = (e) => {
1732
+ const target = e.target;
1733
+ if (!target)
1734
+ return;
1735
+ if (this.hostRef.nativeElement.contains(target))
1736
+ return;
1737
+ if (this._portaledDropdownEl?.contains(target))
1738
+ return;
1739
+ this.closeAllDropdowns();
1740
+ this.cdr.markForCheck();
1741
+ };
1703
1742
  document.addEventListener('scroll', onScroll, true); // capture phase catches all scrollable ancestors
1704
1743
  window.addEventListener('resize', onResize);
1744
+ document.addEventListener('mousedown', onPointerDown, true);
1705
1745
  this._scrollCleanup = () => {
1706
1746
  document.removeEventListener('scroll', onScroll, true);
1707
1747
  window.removeEventListener('resize', onResize);
1748
+ document.removeEventListener('mousedown', onPointerDown, true);
1708
1749
  };
1709
1750
  }
1710
1751
  /** Remove scroll/resize listeners */
@@ -1723,8 +1764,23 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1723
1764
  this._portaledDropdownEl = null;
1724
1765
  this.ShowValueListDropdown = false;
1725
1766
  this.ShowSelectDropdown = false;
1767
+ this.cancelPendingFKSearch();
1726
1768
  this.stopScrollListener();
1727
1769
  }
1770
+ /**
1771
+ * Nothing started before a dismiss may reopen the panel. Retiring the sequence orphans a
1772
+ * lookup still in flight (its result is dropped at the sequence check), and cancelling the
1773
+ * debounce stops a keystroke's pending search from firing after the user has left the field.
1774
+ * Without this, a lookup slower than the blur grace period reopened the list with nothing
1775
+ * focused, and neither Escape nor clicking away could reach it — only picking a row could.
1776
+ */
1777
+ cancelPendingFKSearch() {
1778
+ this._fkSearchSeq++;
1779
+ if (this._fkSearchTimeout) {
1780
+ clearTimeout(this._fkSearchTimeout);
1781
+ this._fkSearchTimeout = null;
1782
+ }
1783
+ }
1728
1784
  // ============================================
1729
1785
  // FK AUTOCOMPLETE (custom implementation)
1730
1786
  // ============================================
@@ -1800,9 +1856,14 @@ export class MjFormFieldComponent extends BaseAngularComponent {
1800
1856
  _fkQuery = '';
1801
1857
  /** Debounce timer for FK search */
1802
1858
  _fkSearchTimeout = null;
1859
+ /** The blur grace timer, so a refocus inside the grace window can cancel the close it scheduled. */
1860
+ _fkBlurTimeout = null;
1803
1861
  /** Last known FK input element for position recalculation */
1804
1862
  _lastFKInputEl = null;
1805
- /** Monotonic token so a slow DB response from a stale query can't clobber a newer one. */
1863
+ /**
1864
+ * Monotonic token so a slow lookup response cannot clobber a newer one — and, because every
1865
+ * dismiss retires it, cannot reopen a panel the user has already closed.
1866
+ */
1806
1867
  _fkSearchSeq = 0;
1807
1868
  /** Cached column plan for the current related entity (rebuilt on demand). */
1808
1869
  _fkColumnPlan = null;
@@ -2535,6 +2596,9 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2535
2596
  OnFKFocus(event) {
2536
2597
  const input = event.target;
2537
2598
  this._lastFKInputEl = input;
2599
+ // Focus regained inside the blur grace window: that blur must not close the panel this
2600
+ // focus is about to open, nor retire the lookup it starts.
2601
+ this.cancelPendingFKBlur();
2538
2602
  this.FKFocused = true; // reveal the scope pill while focused
2539
2603
  // Select any pre-filled (linked) text so the first keystroke replaces it instead
2540
2604
  // of appending — matches how a searchable dropdown behaves.
@@ -2593,7 +2657,9 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2593
2657
  /** Hide dropdown on blur, revert to matched name if user didn't select */
2594
2658
  OnFKBlur() {
2595
2659
  // Small delay so mousedown on dropdown items / scope menu fires first
2596
- setTimeout(() => {
2660
+ this.cancelPendingFKBlur();
2661
+ this._fkBlurTimeout = setTimeout(() => {
2662
+ this._fkBlurTimeout = null;
2597
2663
  this.closeFKDropdown();
2598
2664
  this.FKShowScopeMenu = false;
2599
2665
  this.FKFocused = false; // hide the scope pill
@@ -2604,18 +2670,32 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2604
2670
  this.cdr.markForCheck();
2605
2671
  }, 200);
2606
2672
  }
2673
+ cancelPendingFKBlur() {
2674
+ if (this._fkBlurTimeout) {
2675
+ clearTimeout(this._fkBlurTimeout);
2676
+ this._fkBlurTimeout = null;
2677
+ }
2678
+ }
2607
2679
  /**
2608
2680
  * Keyboard navigation in the FK input: ArrowDown/ArrowUp move the active row,
2609
2681
  * Enter selects it, Escape closes the dropdown.
2610
2682
  */
2611
2683
  OnFKKeydown(event) {
2612
- if (!this.ShowFKDropdown || this.FKSuggestions.length === 0) {
2613
- if (event.key === 'Escape') {
2684
+ if (event.key === 'Escape') {
2685
+ // Escape closes the panel and is consumed: the same key reaching the document would
2686
+ // also close a dialog hosting the form (mj-dialog listens for document Escape), and
2687
+ // dismissing a picker must not take the whole form with it. With no panel open the key
2688
+ // is left alone, so it still closes the dialog when that is what the user means.
2689
+ if (this.ShowFKDropdown) {
2690
+ event.preventDefault();
2691
+ event.stopPropagation();
2614
2692
  this.closeFKDropdown();
2615
2693
  this.cdr.markForCheck();
2616
2694
  }
2617
2695
  return;
2618
2696
  }
2697
+ if (!this.ShowFKDropdown || this.FKSuggestions.length === 0)
2698
+ return;
2619
2699
  switch (event.key) {
2620
2700
  case 'ArrowDown':
2621
2701
  event.preventDefault();
@@ -2637,11 +2717,6 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2637
2717
  }
2638
2718
  break;
2639
2719
  }
2640
- case 'Escape':
2641
- event.preventDefault();
2642
- this.closeFKDropdown();
2643
- this.cdr.markForCheck();
2644
- break;
2645
2720
  }
2646
2721
  }
2647
2722
  /** Scroll the keyboard-active option into view inside the (possibly portaled) dropdown. */
@@ -2794,7 +2869,9 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2794
2869
  if (nameFieldMap) {
2795
2870
  this.Record.Set(nameFieldMap, '');
2796
2871
  }
2797
- // Re-open the full list — clearing almost always precedes picking something else.
2872
+ // Re-open the full list — clearing almost always precedes picking something else. A blur
2873
+ // still inside its grace period must not close the list this just opened.
2874
+ this.cancelPendingFKBlur();
2798
2875
  this.showInitialFKSuggestions();
2799
2876
  this.cdr.markForCheck();
2800
2877
  }
@@ -2806,6 +2883,7 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2806
2883
  this.FKActiveIndex = -1;
2807
2884
  this.FKSelectedSuggestion = null;
2808
2885
  this._portaledDropdownEl = null;
2886
+ this.cancelPendingFKSearch();
2809
2887
  this.stopScrollListener();
2810
2888
  }
2811
2889
  /**
@@ -2850,6 +2928,7 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2850
2928
  ]);
2851
2929
  }
2852
2930
  catch (err) {
2931
+ // Stale: a newer keystroke fired, or the panel was dismissed while this was in flight.
2853
2932
  if (seq !== this._fkSearchSeq)
2854
2933
  return;
2855
2934
  LogError(`FK lookup strategy failed for ${this.Record?.EntityInfo?.Name ?? '?'}.${this.FieldName}: ` +
@@ -2857,7 +2936,8 @@ export class MjFormFieldComponent extends BaseAngularComponent {
2857
2936
  [groups, recent] = [await this.fallbackLookup(context), []];
2858
2937
  this.FKScopeLabels = null;
2859
2938
  }
2860
- // Ignore stale responses (a newer keystroke already fired).
2939
+ // Stale: a newer keystroke fired, or the panel was dismissed while this was in flight. A
2940
+ // dismissed panel stays dismissed — this result must not reopen it.
2861
2941
  if (seq !== this._fkSearchSeq)
2862
2942
  return;
2863
2943
  this.FKLoading = false;
@@ -3166,7 +3246,7 @@ export class MjFormFieldComponent extends BaseAngularComponent {
3166
3246
  * correct way to show it is in the zone it was written in. A `datetime`/`datetimeoffset` names
3167
3247
  * an instant, and the correct way to show THAT is the reader's local zone.
3168
3248
  */
3169
- get IsDateOnlyField() {
3249
+ get isDateOnlyField() {
3170
3250
  return IsDateOnlySQLType(this.FieldInfo?.Type);
3171
3251
  }
3172
3252
  FormatValue() {
@@ -3191,7 +3271,7 @@ export class MjFormFieldComponent extends BaseAngularComponent {
3191
3271
  * zone the day is computed in. A TIMESTAMP is left exactly as it was: it names an instant,
3192
3272
  * and local time is the right way to show one.
3193
3273
  */
3194
- if (this.IsDateOnlyField) {
3274
+ if (this.isDateOnlyField) {
3195
3275
  return FormatDateOnly(val);
3196
3276
  }
3197
3277
  return val.toLocaleString();
@@ -3244,6 +3324,9 @@ export class MjFormFieldComponent extends BaseAngularComponent {
3244
3324
  this._fkColWidths = {};
3245
3325
  this._fkPrefKey = null; // force prefs reload for the new field
3246
3326
  this._portaledDropdownEl = null;
3327
+ // A lookup still out for the previous record must not land on this one.
3328
+ this.cancelPendingFKSearch();
3329
+ this.stopScrollListener();
3247
3330
  this._fkColumnPlan = null;
3248
3331
  this._fkStrategy = null; // a different field may resolve a different strategy
3249
3332
  this._fkStrategyIsRegistered = false;
@@ -3274,10 +3357,13 @@ export class MjFormFieldComponent extends BaseAngularComponent {
3274
3357
  }
3275
3358
  }
3276
3359
  ngOnDestroy() {
3360
+ this._destroyed = true;
3277
3361
  this.sectionHost?.UnregisterField(this);
3278
- if (this._fkSearchTimeout) {
3279
- clearTimeout(this._fkSearchTimeout);
3280
- }
3362
+ // Retire the sequence too, not just the debounce: a lookup still in flight would otherwise
3363
+ // land on a destroyed component, reopen the panel and re-arm document listeners with no
3364
+ // owner left to remove them.
3365
+ this.cancelPendingFKSearch();
3366
+ this.cancelPendingFKBlur();
3281
3367
  this.teardownFKResizeListeners();
3282
3368
  this.stopScrollListener();
3283
3369
  // If we relocated the dropdown to <body> and Angular tears us down while it's