neo.mjs 6.5.10 → 6.6.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.
package/src/grid/View.mjs CHANGED
@@ -29,7 +29,7 @@ class View extends Component {
29
29
  createViewData(inputData) {
30
30
  let me = this,
31
31
  amountRows = inputData.length,
32
- container = Neo.getComponent(me.parentId),
32
+ container = me.parent,
33
33
  columns = container.items[0].items,
34
34
  colCount = columns.length,
35
35
  data = [],
@@ -1,22 +1,22 @@
1
1
  import Base from '../core/Base.mjs';
2
2
  import DeltaUpdates from './mixin/DeltaUpdates.mjs';
3
3
  import Observable from '../core/Observable.mjs';
4
- import Rectangle from '../util/Rectangle.mjs';
4
+ import Rectangle from '../util/Rectangle.mjs';
5
5
 
6
6
  const
7
7
  lengthRE = /^\d+\w+$/,
8
8
  fontSizeProps = [
9
+ 'font-family',
10
+ 'font-kerning',
9
11
  'font-size',
10
12
  'font-size-adjust',
13
+ 'font-stretch',
11
14
  'font-style',
12
15
  'font-weight',
13
- 'font-family',
14
- 'font-kerning',
15
- 'font-stretch',
16
+ 'letter-spacing',
16
17
  'line-height',
17
- 'text-transform',
18
18
  'text-decoration',
19
- 'letter-spacing',
19
+ 'text-transform',
20
20
  'word-break'
21
21
  ];
22
22
 
@@ -77,6 +77,7 @@ class DomAccess extends Base {
77
77
  'selectNode',
78
78
  'setBodyCls',
79
79
  'setStyle',
80
+ 'syncModalMask',
80
81
  'windowScrollTo'
81
82
  ]
82
83
  },
@@ -96,6 +97,20 @@ class DomAccess extends Base {
96
97
  ]
97
98
  }
98
99
 
100
+ /**
101
+ * @returns {HTMLElement}
102
+ */
103
+ get modalMask() {
104
+ let me = this;
105
+
106
+ if (!me._modalMask) {
107
+ me._modalMask = document.createElement('div');
108
+ me._modalMask.className = 'neo-dialog-modal-mask';
109
+ }
110
+
111
+ return me._modalMask;
112
+ }
113
+
99
114
  /**
100
115
  * @param {Object} config
101
116
  */
@@ -111,16 +126,16 @@ class DomAccess extends Base {
111
126
  node = document.getElementById('neo-delta-updates');
112
127
 
113
128
  if (node) {
114
- node.innerHTML = String(me.countDeltasPer250ms * 4);
129
+ node.innerHTML = String(me.countDeltasPer250ms * 4)
115
130
  }
116
131
 
117
- me.countDeltasPer250ms = 0;
132
+ me.countDeltasPer250ms = 0
118
133
  }, 250)
119
134
  }
120
135
 
121
136
  // Set up our aligning callback which is called when things change which may
122
137
  // mean that alignments need to be updated.
123
- me.syncAligns = me.syncAligns.bind(me);
138
+ me.syncAligns = me.syncAligns.bind(me)
124
139
  }
125
140
 
126
141
  /**
@@ -144,7 +159,7 @@ class DomAccess extends Base {
144
159
 
145
160
  // Realign when constraining element changes size
146
161
  if (constrainToElement) {
147
- resizeObserver.observe(constrainToElement);
162
+ resizeObserver.observe(constrainToElement)
148
163
  }
149
164
  }
150
165
 
@@ -154,7 +169,7 @@ class DomAccess extends Base {
154
169
  passive: true
155
170
  });
156
171
 
157
- me.hasDocumentScrollListener = true;
172
+ me.hasDocumentScrollListener = true
158
173
  }
159
174
 
160
175
  if (!me.documentMutationObserver) {
@@ -179,12 +194,12 @@ class DomAccess extends Base {
179
194
  let script = document.createElement('script');
180
195
 
181
196
  if (!data.hasOwnProperty('async')) {
182
- data.async = true;
197
+ data.async = true
183
198
  }
184
199
 
185
200
  Object.assign(script, data);
186
201
 
187
- document.head.appendChild(script);
202
+ document.head.appendChild(script)
188
203
  }
189
204
 
190
205
  /**
@@ -627,18 +642,19 @@ class DomAccess extends Base {
627
642
  * Resets any DOM sizing configs to the last externally configured value.
628
643
  *
629
644
  * This is used during aligning to release any constraints applied by a previous alignment.
645
+ * @param {Object} align
630
646
  * @protected
631
647
  */
632
- async resetDimensions(align) {
633
- const { style } = this.getElement(align.id);
634
-
635
- style.flex = align.configuredFlex;
636
- style.width = align.configuredWidth;
637
- style.height = align.configuredHeight;
638
- style.minWidth = align.configuredMinWidth;
639
- style.minHeight = align.configuredMinHeight;
640
- style.maxWidth = align.configuredMaxWidth;
641
- style.maxHeight = align.configuredMaxHeight;
648
+ resetDimensions(align) {
649
+ Object.assign(this.getElement(align.id).style, {
650
+ flex : align.configuredFlex,
651
+ width : align.configuredWidth,
652
+ height : align.configuredHeight,
653
+ minWidth : align.configuredMinWidth,
654
+ minHeight: align.configuredMinHeight,
655
+ maxWidth : align.configuredMaxWidth,
656
+ maxHeight: align.configuredMaxHeight
657
+ })
642
658
  }
643
659
 
644
660
  /**
@@ -655,7 +671,7 @@ class DomAccess extends Base {
655
671
  node[`scroll${Neo.capitalize(data.direction)}`] += data.value;
656
672
  }
657
673
 
658
- return {id: data.id};
674
+ return {id: data.id}
659
675
  }
660
676
 
661
677
  /**
@@ -669,15 +685,13 @@ class DomAccess extends Base {
669
685
  scrollIntoView(data) {
670
686
  let node = this.getElement(data.id);
671
687
 
672
- if (node) {
673
- node.scrollIntoView({
674
- behavior: data.behavior || 'smooth',
675
- block : data.block || 'start',
676
- inline : data.inline || 'nearest'
677
- });
678
- }
688
+ node?.scrollIntoView({
689
+ behavior: data.behavior || 'smooth',
690
+ block : data.block || 'start',
691
+ inline : data.inline || 'nearest'
692
+ });
679
693
 
680
- return {id: data.id};
694
+ return {id: data.id}
681
695
  }
682
696
 
683
697
  /**
@@ -694,7 +708,7 @@ class DomAccess extends Base {
694
708
  node[`scroll${Neo.capitalize(data.direction)}`] = data.value;
695
709
  }
696
710
 
697
- return {id: data.id};
711
+ return {id: data.id}
698
712
  }
699
713
 
700
714
  /**
@@ -714,12 +728,12 @@ class DomAccess extends Base {
714
728
  top = node.getBoundingClientRect().top;
715
729
 
716
730
  wrapperNode.scrollTo({
717
- top : top - tableTop - (data.hasOwnProperty('offset') ? data.offset : 34),
718
- behavior: data.behavior || 'smooth'
719
- });
731
+ behavior: data.behavior || 'smooth',
732
+ top : top - tableTop - (data.hasOwnProperty('offset') ? data.offset : 34)
733
+ })
720
734
  }
721
735
 
722
- return {id: data.id};
736
+ return {id: data.id}
723
737
  }
724
738
 
725
739
  /**
@@ -739,7 +753,7 @@ class DomAccess extends Base {
739
753
  node.setSelectionRange(start, end);
740
754
  }
741
755
 
742
- return {id: data.id};
756
+ return {id: data.id}
743
757
  }
744
758
 
745
759
  /**
@@ -767,14 +781,14 @@ class DomAccess extends Base {
767
781
  Object.entries(data.style).forEach(([key, value]) => {
768
782
  if (Neo.isString(value) && value.includes('!important')) {
769
783
  value = value.replace('!important', '').trim();
770
- node.style.setProperty(Neo.decamel(key), value, 'important');
784
+ node.style.setProperty(Neo.decamel(key), value, 'important')
771
785
  } else {
772
- node.style[Neo.decamel(key)] = value;
786
+ node.style[Neo.decamel(key)] = value
773
787
  }
774
- });
788
+ })
775
789
  }
776
790
 
777
- return {id: data.id};
791
+ return {id: data.id}
778
792
  }
779
793
 
780
794
  /**
@@ -787,12 +801,19 @@ class DomAccess extends Base {
787
801
 
788
802
  // Keep all registered aligns aligned on any detected change
789
803
  _aligns?.forEach(align => {
804
+ const targetPresent = document.contains(align.targetElement);
805
+
790
806
  // Align subject and target still in the DOM - correct its alignment
791
- if (document.contains(align.subject) && document.contains(align.targetElement)) {
807
+ if (document.contains(align.subject) && targetPresent) {
792
808
  me.align(align);
793
809
  }
794
810
  // Align subject or target no longer in the DOM - remove it.
795
811
  else {
812
+ // If target is no longer in the DOM, hide the subject component
813
+ if (!targetPresent) {
814
+ Neo.worker.App.setConfigs({ id: align.id, hidden: true });
815
+ }
816
+
796
817
  const
797
818
  { _alignResizeObserver } = me,
798
819
  { constrainToElement } = align;
@@ -802,17 +823,40 @@ class DomAccess extends Base {
802
823
  _alignResizeObserver.unobserve(align.offsetParent);
803
824
  _alignResizeObserver.unobserve(align.targetElement);
804
825
  if (constrainToElement) {
805
- _alignResizeObserver.unobserve(constrainToElement);
826
+ _alignResizeObserver.unobserve(constrainToElement)
806
827
  }
807
828
 
808
829
  // Clear the last aligned class.
809
830
  align.subject.classList.remove(`neo-aligned-${align.result?.position}`);
810
831
 
811
- _aligns.delete(align.id);
832
+ _aligns.delete(align.id)
812
833
  }
813
834
  })
814
835
  }
815
836
 
837
+ syncModalMask({ id, modal }) {
838
+ const el = id && this.getElement(id);
839
+
840
+ // If we are visible and modal, the mask needs to be just below this element.
841
+ if (el && modal && el.ownerDocument.contains(el) && el.ownerDocument.defaultView.getComputedStyle(el).getPropertyValue('display') !== 'none') {
842
+ document.body.insertBefore(this.modalMask, el);
843
+ }
844
+ // Otherwise, the mask needs to be blow the next topmost modal dialog if possible, or hidden
845
+ else {
846
+ const
847
+ modals = document.querySelectorAll('.neo-modal'),
848
+ topmostModal = modals[modals.length - 1];
849
+
850
+ // Move the mask under the next topmost modal now modal "id" is gone.
851
+ if (topmostModal) {
852
+ this.syncModalMask({ id : topmostModal.id, modal : true })
853
+ }
854
+ else {
855
+ this._modalMask?.remove()
856
+ }
857
+ }
858
+ }
859
+
816
860
  /**
817
861
  * @param {Object} data
818
862
  * @param {String} [data.behavior='smooth'] // auto or smooth
@@ -824,7 +868,7 @@ class DomAccess extends Base {
824
868
  behavior: data.behavior || 'smooth',
825
869
  left : data.left || 0,
826
870
  top : data.top || 0
827
- });
871
+ })
828
872
  }
829
873
 
830
874
  /**
@@ -836,7 +880,7 @@ class DomAccess extends Base {
836
880
  index : data.parentIndex,
837
881
  outerHTML: data.html || data.outerHTML,
838
882
  parentId : data.parentId
839
- });
883
+ })
840
884
  }
841
885
  }
842
886
 
@@ -445,17 +445,13 @@ class Component extends Base {
445
445
  * @returns {Neo.model.Component|null}
446
446
  */
447
447
  getParent() {
448
- let me = this,
449
- parentComponent, parentId;
448
+ let me = this;
450
449
 
451
450
  if (me.parent) {
452
451
  return me.parent
453
452
  }
454
453
 
455
- parentId = me.component.parentId;
456
- parentComponent = parentId && Neo.getComponent(parentId);
457
-
458
- return parentComponent?.getModel() || null
454
+ return me.component.parent?.getModel() || null
459
455
  }
460
456
 
461
457
  /**