uicore-ts 1.1.376 → 1.1.378
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/compiledScripts/UIRectangle.d.ts +59 -0
- package/compiledScripts/UIRectangle.js +315 -17
- package/compiledScripts/UIRectangle.js.map +3 -3
- package/compiledScripts/UIView.d.ts +2 -2
- package/compiledScripts/UIView.js +25 -8
- package/compiledScripts/UIView.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIRectangle.ts +408 -9
- package/scripts/UIView.ts +24 -8
|
@@ -2,7 +2,42 @@ import { UIObject } from "./UIObject";
|
|
|
2
2
|
import { UIPoint } from "./UIPoint";
|
|
3
3
|
import { UIView } from "./UIView";
|
|
4
4
|
export type SizeNumberOrFunctionOrView = number | ((constrainingOrthogonalSize: number) => number) | UIView;
|
|
5
|
+
export type UIGroupingWrapperFrameConfiguration = {
|
|
6
|
+
/** Stable identity used to reuse the same wrapper when surrounding conditional layout changes. */
|
|
7
|
+
identifier?: string;
|
|
8
|
+
/** CSS classes applied to the generated outer wrapper element. */
|
|
9
|
+
classNames?: string[];
|
|
10
|
+
/** HTML attributes applied to the generated outer wrapper element. */
|
|
11
|
+
attributes?: Record<string, string>;
|
|
12
|
+
/** Presentational CSS applied to the generated outer wrapper element. */
|
|
13
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
14
|
+
/** Optionally transforms the bounding frame calculated from all assigned view frames. */
|
|
15
|
+
frame?: (defaultFrame: UIRectangle, assignedFrames: UIRectangle[]) => UIRectangle;
|
|
16
|
+
};
|
|
17
|
+
type UIGroupingWrapperFrameContext = {
|
|
18
|
+
configuration: UIGroupingWrapperFrameConfiguration;
|
|
19
|
+
views: UIView[];
|
|
20
|
+
framesByView: Map<UIView, UIRectangle>;
|
|
21
|
+
childContexts: UIGroupingWrapperFrameContext[];
|
|
22
|
+
};
|
|
23
|
+
type UIGroupingWrapperFrameLayoutPass = {
|
|
24
|
+
owner: UIView;
|
|
25
|
+
groupingContextStack: UIGroupingWrapperFrameContext[];
|
|
26
|
+
requests: UIGroupingWrapperFrameContext[];
|
|
27
|
+
};
|
|
28
|
+
type UIGroupingWrapperFrameRecord = {
|
|
29
|
+
identifier?: string;
|
|
30
|
+
wrapperHTMLElement: HTMLDivElement;
|
|
31
|
+
coordinateSpaceHTMLElement: HTMLDivElement;
|
|
32
|
+
views: UIView[];
|
|
33
|
+
childRecords: UIGroupingWrapperFrameRecord[];
|
|
34
|
+
configuredClassNames: string[];
|
|
35
|
+
configuredAttributeNames: string[];
|
|
36
|
+
configuredStyleNames: string[];
|
|
37
|
+
};
|
|
5
38
|
export declare class UIRectangle extends UIObject {
|
|
39
|
+
static _groupingWrapperFrameLayoutPasses: UIGroupingWrapperFrameLayoutPass[];
|
|
40
|
+
static _groupingWrapperFrameRecordsByOwner: WeakMap<UIView, UIGroupingWrapperFrameRecord[]>;
|
|
6
41
|
_isBeingUpdated: boolean;
|
|
7
42
|
rectanglePointDidChange?: (b: any) => void;
|
|
8
43
|
private _data;
|
|
@@ -132,6 +167,24 @@ export declare class UIRectangle extends UIObject {
|
|
|
132
167
|
settingMaxWidth(maxWidth?: number): this;
|
|
133
168
|
rectangleByEnforcingMinAndMaxSizes(centeredOnXPosition?: number, centeredOnYPosition?: number): UIRectangle;
|
|
134
169
|
assignedAsFrameOfView(view: UIView, isWeakFrame?: boolean): this;
|
|
170
|
+
/**
|
|
171
|
+
* Begins collecting views assigned through the rectangle frame-assignment API into a DOM wrapper.
|
|
172
|
+
* The matching endGroupingWrapperFrame() returns the current rectangle unchanged, preserving the chain.
|
|
173
|
+
*/
|
|
174
|
+
beginGroupingWrapperFrame(configuration?: UIGroupingWrapperFrameConfiguration): this;
|
|
175
|
+
/** Ends the current grouping wrapper frame and returns this rectangle unchanged. */
|
|
176
|
+
endGroupingWrapperFrame(): this;
|
|
177
|
+
static _beginGroupingWrapperFrameLayoutPass(owner: UIView): void;
|
|
178
|
+
static _endGroupingWrapperFrameLayoutPass(owner: UIView): void;
|
|
179
|
+
static _assignFrameToView(frame: UIRectangle, view: UIView): void;
|
|
180
|
+
static _reconcileGroupingWrapperFrames(layoutPass: UIGroupingWrapperFrameLayoutPass): void;
|
|
181
|
+
static _viewsInGroupingWrapperFrameRecord(record: UIGroupingWrapperFrameRecord): UIView[];
|
|
182
|
+
static _reorderGroupingWrapperFrameElements(containerHTMLElement: HTMLElement, desiredElements: HTMLElement[]): void;
|
|
183
|
+
static _newGroupingWrapperFrameRecord(): UIGroupingWrapperFrameRecord;
|
|
184
|
+
static _configureGroupingWrapperFrameRecord(record: UIGroupingWrapperFrameRecord, request: UIGroupingWrapperFrameContext, owner: UIView, containerHTMLElement: HTMLElement): void;
|
|
185
|
+
static _topLevelHTMLElementForView(view: UIView): HTMLElement & import("./UIView").LooseObject;
|
|
186
|
+
static _detachViewFromGroupingWrapperFrame(view: UIView): void;
|
|
187
|
+
static _removeEmptyGroupingWrapperFrameAncestors(wrapperHTMLElement: Element | null): void;
|
|
135
188
|
toString(): string;
|
|
136
189
|
get [Symbol.toStringTag](): string;
|
|
137
190
|
IF(condition: boolean): UIRectangleConditionalChain<UIRectangle>;
|
|
@@ -146,6 +199,12 @@ export declare class UIRectangle extends UIObject {
|
|
|
146
199
|
didChange(): void;
|
|
147
200
|
_rectanglePointDidChange(): void;
|
|
148
201
|
}
|
|
202
|
+
declare global {
|
|
203
|
+
interface Array<T> {
|
|
204
|
+
/** Returns the smallest rectangle containing every point and rectangle in the array. */
|
|
205
|
+
boundingBox(this: Array<UIPoint | UIRectangle>): UIRectangle;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
149
208
|
type RectangleChainMethods<TResult> = {
|
|
150
209
|
[K in keyof UIRectangle as (K extends 'IF' | 'ELSE' | 'ELSE_IF' | 'ENDIF' ? never : K)]: UIRectangle[K] extends (...args: infer Args) => infer R ? R extends UIRectangle | UIRectangle[] ? (...args: Args) => UIRectangleConditionalChain<R, TResult> : never : never;
|
|
151
210
|
};
|
|
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(UIRectangle_exports);
|
|
|
24
24
|
var import_UIObject = require("./UIObject");
|
|
25
25
|
var import_UIPoint = require("./UIPoint");
|
|
26
26
|
var import_UIView = require("./UIView");
|
|
27
|
-
class
|
|
27
|
+
const _UIRectangle = class extends import_UIObject.UIObject {
|
|
28
28
|
constructor(x = 0, y = 0, height = 0, width = 0) {
|
|
29
29
|
super();
|
|
30
30
|
this._isLazyCopy = import_UIObject.NO;
|
|
@@ -72,7 +72,7 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
lazyCopy() {
|
|
75
|
-
const result = Object.create(
|
|
75
|
+
const result = Object.create(_UIRectangle.prototype);
|
|
76
76
|
result._data = this._data;
|
|
77
77
|
result._data.refCount++;
|
|
78
78
|
result._isLazyCopy = import_UIObject.YES;
|
|
@@ -125,7 +125,7 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
125
125
|
this._data.maxWidth = value;
|
|
126
126
|
}
|
|
127
127
|
copy() {
|
|
128
|
-
const result = new
|
|
128
|
+
const result = new _UIRectangle(this.x, this.y, this.height, this.width);
|
|
129
129
|
result.minHeight = this.minHeight;
|
|
130
130
|
result.minWidth = this.minWidth;
|
|
131
131
|
result.maxHeight = this.maxHeight;
|
|
@@ -136,7 +136,7 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
136
136
|
return (0, import_UIObject.IS)(rectangle) && this.min.isEqualTo(rectangle.min) && this.max.isEqualTo(rectangle.max);
|
|
137
137
|
}
|
|
138
138
|
static zero() {
|
|
139
|
-
return new
|
|
139
|
+
return new _UIRectangle(0, 0, 0, 0);
|
|
140
140
|
}
|
|
141
141
|
containsPoint(point) {
|
|
142
142
|
return this.min.x <= point.x && this.min.y <= point.y && point.x <= this.max.x && point.y <= this.max.y;
|
|
@@ -528,7 +528,7 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
528
528
|
weights = [weights].arrayByRepeating(views.length);
|
|
529
529
|
}
|
|
530
530
|
const frames = this.rectanglesBySplittingWidth(weights, paddings, absoluteWidths);
|
|
531
|
-
frames.forEach((frame, index) => (0, import_UIObject.FIRST_OR_NIL)(views[index])
|
|
531
|
+
frames.forEach((frame, index) => _UIRectangle._assignFrameToView(frame, (0, import_UIObject.FIRST_OR_NIL)(views[index])));
|
|
532
532
|
return this;
|
|
533
533
|
}
|
|
534
534
|
distributeViewsAlongHeight(views, weights = 1, paddings, absoluteHeights) {
|
|
@@ -536,17 +536,17 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
536
536
|
weights = [weights].arrayByRepeating(views.length);
|
|
537
537
|
}
|
|
538
538
|
const frames = this.rectanglesBySplittingHeight(weights, paddings, absoluteHeights);
|
|
539
|
-
frames.forEach((frame, index) => (0, import_UIObject.FIRST_OR_NIL)(views[index])
|
|
539
|
+
frames.forEach((frame, index) => _UIRectangle._assignFrameToView(frame, (0, import_UIObject.FIRST_OR_NIL)(views[index])));
|
|
540
540
|
return this;
|
|
541
541
|
}
|
|
542
542
|
distributeViewsEquallyAlongWidth(views, padding) {
|
|
543
543
|
const frames = this.rectanglesByEquallySplittingWidth(views.length, padding);
|
|
544
|
-
frames.forEach((frame, index) => views[index]
|
|
544
|
+
frames.forEach((frame, index) => _UIRectangle._assignFrameToView(frame, views[index]));
|
|
545
545
|
return this;
|
|
546
546
|
}
|
|
547
547
|
distributeViewsEquallyAlongHeight(views, padding) {
|
|
548
548
|
const frames = this.rectanglesByEquallySplittingHeight(views.length, padding);
|
|
549
|
-
frames.forEach((frame, index) => views[index]
|
|
549
|
+
frames.forEach((frame, index) => _UIRectangle._assignFrameToView(frame, views[index]));
|
|
550
550
|
return this;
|
|
551
551
|
}
|
|
552
552
|
_heightNumberFromSizeNumberOrFunctionOrView(height) {
|
|
@@ -617,7 +617,7 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
617
617
|
if ((0, import_UIObject.IS_NOT_NIL)(absoluteHeights[i])) {
|
|
618
618
|
frame.height = absoluteHeights[i];
|
|
619
619
|
}
|
|
620
|
-
views[i]
|
|
620
|
+
_UIRectangle._assignFrameToView(frame, views[i]);
|
|
621
621
|
frames.push(frame);
|
|
622
622
|
const padding = paddings[i] || 0;
|
|
623
623
|
currentRectangle = frame.rectangleForNextRow(padding);
|
|
@@ -653,7 +653,7 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
653
653
|
frame.x += offset;
|
|
654
654
|
});
|
|
655
655
|
}
|
|
656
|
-
frames.forEach((frame, index) => views[index]
|
|
656
|
+
frames.forEach((frame, index) => _UIRectangle._assignFrameToView(frame, views[index]));
|
|
657
657
|
return frames;
|
|
658
658
|
}
|
|
659
659
|
framesByDistributingViewsAsGrid(views, paddings = 0, absoluteHeights = import_UIObject.nil) {
|
|
@@ -676,7 +676,7 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
676
676
|
const heightNumber = absoluteHeights[i];
|
|
677
677
|
rowFrames.forEach((frame, j) => {
|
|
678
678
|
frame.height = heightNumber;
|
|
679
|
-
rowViews[j]
|
|
679
|
+
_UIRectangle._assignFrameToView(frame, rowViews[j]);
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
frames.push(rowFrames);
|
|
@@ -722,10 +722,295 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
722
722
|
);
|
|
723
723
|
}
|
|
724
724
|
assignedAsFrameOfView(view, isWeakFrame = view.hasWeakFrame) {
|
|
725
|
-
|
|
725
|
+
_UIRectangle._assignFrameToView(this, view);
|
|
726
726
|
view.hasWeakFrame = isWeakFrame;
|
|
727
727
|
return this;
|
|
728
728
|
}
|
|
729
|
+
beginGroupingWrapperFrame(configuration = {}) {
|
|
730
|
+
const layoutPass = _UIRectangle._groupingWrapperFrameLayoutPasses.lastElement;
|
|
731
|
+
if (!layoutPass) {
|
|
732
|
+
throw new Error("beginGroupingWrapperFrame() must be called during a UIView layout pass");
|
|
733
|
+
}
|
|
734
|
+
const groupingContext = {
|
|
735
|
+
configuration,
|
|
736
|
+
views: [],
|
|
737
|
+
framesByView: /* @__PURE__ */ new Map(),
|
|
738
|
+
childContexts: []
|
|
739
|
+
};
|
|
740
|
+
const parentContext = layoutPass.groupingContextStack.lastElement;
|
|
741
|
+
if (parentContext) {
|
|
742
|
+
parentContext.childContexts.push(groupingContext);
|
|
743
|
+
} else {
|
|
744
|
+
layoutPass.requests.push(groupingContext);
|
|
745
|
+
}
|
|
746
|
+
layoutPass.groupingContextStack.push(groupingContext);
|
|
747
|
+
return this;
|
|
748
|
+
}
|
|
749
|
+
endGroupingWrapperFrame() {
|
|
750
|
+
const layoutPass = _UIRectangle._groupingWrapperFrameLayoutPasses.lastElement;
|
|
751
|
+
if (!(layoutPass == null ? void 0 : layoutPass.groupingContextStack.length)) {
|
|
752
|
+
throw new Error("endGroupingWrapperFrame() requires a matching beginGroupingWrapperFrame()");
|
|
753
|
+
}
|
|
754
|
+
layoutPass.groupingContextStack.pop();
|
|
755
|
+
return this;
|
|
756
|
+
}
|
|
757
|
+
static _beginGroupingWrapperFrameLayoutPass(owner) {
|
|
758
|
+
_UIRectangle._groupingWrapperFrameLayoutPasses.push({
|
|
759
|
+
owner,
|
|
760
|
+
groupingContextStack: [],
|
|
761
|
+
requests: []
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
static _endGroupingWrapperFrameLayoutPass(owner) {
|
|
765
|
+
const layoutPass = _UIRectangle._groupingWrapperFrameLayoutPasses.pop();
|
|
766
|
+
if (!layoutPass || layoutPass.owner !== owner) {
|
|
767
|
+
throw new Error("Unbalanced grouping wrapper frame layout pass");
|
|
768
|
+
}
|
|
769
|
+
if (layoutPass.groupingContextStack.length) {
|
|
770
|
+
console.error("beginGroupingWrapperFrame() was not balanced with endGroupingWrapperFrame()", owner);
|
|
771
|
+
layoutPass.groupingContextStack.length = 0;
|
|
772
|
+
}
|
|
773
|
+
if (!import_UIView.UIView.isVirtualLayouting) {
|
|
774
|
+
_UIRectangle._reconcileGroupingWrapperFrames(layoutPass);
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
static _assignFrameToView(frame, view) {
|
|
778
|
+
var _a;
|
|
779
|
+
view.frame = frame;
|
|
780
|
+
const groupingContexts = (_a = _UIRectangle._groupingWrapperFrameLayoutPasses.lastElement) == null ? void 0 : _a.groupingContextStack;
|
|
781
|
+
if (!(groupingContexts == null ? void 0 : groupingContexts.length)) {
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
groupingContexts.forEach((groupingContext) => groupingContext.framesByView.set(view, frame.copy()));
|
|
785
|
+
const innermostContext = groupingContexts.lastElement;
|
|
786
|
+
if (!innermostContext.views.contains(view)) {
|
|
787
|
+
innermostContext.views.push(view);
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
static _reconcileGroupingWrapperFrames(layoutPass) {
|
|
791
|
+
var _a;
|
|
792
|
+
const owner = layoutPass.owner;
|
|
793
|
+
const previousRecords = (_a = _UIRectangle._groupingWrapperFrameRecordsByOwner.get(owner)) != null ? _a : [];
|
|
794
|
+
const availablePreviousRecords = previousRecords.copy();
|
|
795
|
+
const nextRecords = [];
|
|
796
|
+
const groupedViews = /* @__PURE__ */ new Set();
|
|
797
|
+
const configuredIdentifiers = /* @__PURE__ */ new Set();
|
|
798
|
+
const validateContext = (request) => {
|
|
799
|
+
if (request.configuration.identifier) {
|
|
800
|
+
if (configuredIdentifiers.has(request.configuration.identifier)) {
|
|
801
|
+
throw new Error("Grouping wrapper frame identifiers must be unique within one layout owner");
|
|
802
|
+
}
|
|
803
|
+
configuredIdentifiers.add(request.configuration.identifier);
|
|
804
|
+
}
|
|
805
|
+
request.views.forEach((view) => {
|
|
806
|
+
if (view.superview !== owner) {
|
|
807
|
+
throw new Error("Views in a grouping wrapper frame must be direct subviews of the layout owner");
|
|
808
|
+
}
|
|
809
|
+
if (groupedViews.has(view)) {
|
|
810
|
+
throw new Error("A view cannot belong to multiple grouping wrapper frames in one layout pass");
|
|
811
|
+
}
|
|
812
|
+
groupedViews.add(view);
|
|
813
|
+
});
|
|
814
|
+
request.childContexts.forEach(validateContext);
|
|
815
|
+
};
|
|
816
|
+
layoutPass.requests.forEach(validateContext);
|
|
817
|
+
const recordForRequest = (request) => {
|
|
818
|
+
let record;
|
|
819
|
+
if (request.configuration.identifier) {
|
|
820
|
+
record = availablePreviousRecords.find(
|
|
821
|
+
(candidate) => candidate.identifier === request.configuration.identifier
|
|
822
|
+
);
|
|
823
|
+
} else {
|
|
824
|
+
record = availablePreviousRecords.find((candidate) => !candidate.identifier);
|
|
825
|
+
}
|
|
826
|
+
if (record) {
|
|
827
|
+
availablePreviousRecords.removeElement(record);
|
|
828
|
+
} else {
|
|
829
|
+
record = _UIRectangle._newGroupingWrapperFrameRecord();
|
|
830
|
+
}
|
|
831
|
+
return record;
|
|
832
|
+
};
|
|
833
|
+
const reconcileContext = (request, containerHTMLElement) => {
|
|
834
|
+
if (!request.framesByView.size) {
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
const record = recordForRequest(request);
|
|
838
|
+
_UIRectangle._configureGroupingWrapperFrameRecord(
|
|
839
|
+
record,
|
|
840
|
+
request,
|
|
841
|
+
owner,
|
|
842
|
+
containerHTMLElement
|
|
843
|
+
);
|
|
844
|
+
nextRecords.push(record);
|
|
845
|
+
record.childRecords = request.childContexts.map(
|
|
846
|
+
(childContext) => reconcileContext(childContext, record.coordinateSpaceHTMLElement)
|
|
847
|
+
).filter((childRecord) => !!childRecord);
|
|
848
|
+
const elementByView = /* @__PURE__ */ new Map();
|
|
849
|
+
record.views.forEach((view) => elementByView.set(view, view.viewHTMLElement));
|
|
850
|
+
record.childRecords.forEach((childRecord) => {
|
|
851
|
+
_UIRectangle._viewsInGroupingWrapperFrameRecord(childRecord).forEach(
|
|
852
|
+
(view) => elementByView.set(view, childRecord.wrapperHTMLElement)
|
|
853
|
+
);
|
|
854
|
+
});
|
|
855
|
+
_UIRectangle._reorderGroupingWrapperFrameElements(
|
|
856
|
+
record.coordinateSpaceHTMLElement,
|
|
857
|
+
owner.subviews.map((view) => elementByView.get(view)).filter(
|
|
858
|
+
(element) => !!element
|
|
859
|
+
)
|
|
860
|
+
);
|
|
861
|
+
return record;
|
|
862
|
+
};
|
|
863
|
+
const rootRecords = layoutPass.requests.map(
|
|
864
|
+
(request) => reconcileContext(request, owner.viewHTMLElement)
|
|
865
|
+
).filter((record) => !!record);
|
|
866
|
+
availablePreviousRecords.forEach((record) => {
|
|
867
|
+
record.views.forEach((view) => {
|
|
868
|
+
if (view.viewHTMLElement.parentElement === record.coordinateSpaceHTMLElement) {
|
|
869
|
+
owner.viewHTMLElement.appendChild(view.viewHTMLElement);
|
|
870
|
+
}
|
|
871
|
+
});
|
|
872
|
+
record.wrapperHTMLElement.remove();
|
|
873
|
+
});
|
|
874
|
+
const rootRecordByView = /* @__PURE__ */ new Map();
|
|
875
|
+
rootRecords.forEach((record) => {
|
|
876
|
+
_UIRectangle._viewsInGroupingWrapperFrameRecord(record).forEach(
|
|
877
|
+
(view) => rootRecordByView.set(view, record)
|
|
878
|
+
);
|
|
879
|
+
});
|
|
880
|
+
const desiredTopLevelElements = [];
|
|
881
|
+
owner.subviews.forEach((view) => {
|
|
882
|
+
var _a2;
|
|
883
|
+
const record = rootRecordByView.get(view);
|
|
884
|
+
const element = (_a2 = record == null ? void 0 : record.wrapperHTMLElement) != null ? _a2 : view.viewHTMLElement;
|
|
885
|
+
if (!desiredTopLevelElements.contains(element)) {
|
|
886
|
+
desiredTopLevelElements.push(element);
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
_UIRectangle._reorderGroupingWrapperFrameElements(owner.viewHTMLElement, desiredTopLevelElements);
|
|
890
|
+
_UIRectangle._groupingWrapperFrameRecordsByOwner.set(owner, nextRecords);
|
|
891
|
+
}
|
|
892
|
+
static _viewsInGroupingWrapperFrameRecord(record) {
|
|
893
|
+
return record.views.concat(record.childRecords.flatMap(
|
|
894
|
+
(childRecord) => _UIRectangle._viewsInGroupingWrapperFrameRecord(childRecord)
|
|
895
|
+
));
|
|
896
|
+
}
|
|
897
|
+
static _reorderGroupingWrapperFrameElements(containerHTMLElement, desiredElements) {
|
|
898
|
+
const uniqueDesiredElements = desiredElements.filter(
|
|
899
|
+
(element, index) => desiredElements.indexOf(element) === index
|
|
900
|
+
);
|
|
901
|
+
const currentElements = Array.from(containerHTMLElement.children).filter(
|
|
902
|
+
(element) => uniqueDesiredElements.contains(element)
|
|
903
|
+
);
|
|
904
|
+
if (!currentElements.isEqualToArray(uniqueDesiredElements) || uniqueDesiredElements.some((element) => element.parentElement !== containerHTMLElement)) {
|
|
905
|
+
uniqueDesiredElements.forEach((element) => containerHTMLElement.appendChild(element));
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
static _newGroupingWrapperFrameRecord() {
|
|
909
|
+
const wrapperHTMLElement = document.createElement("div");
|
|
910
|
+
const coordinateSpaceHTMLElement = document.createElement("div");
|
|
911
|
+
wrapperHTMLElement.classList.add("UICore_UIGroupingWrapperFrame");
|
|
912
|
+
wrapperHTMLElement.setAttribute("data-uicore-grouping-wrapper-frame", "");
|
|
913
|
+
coordinateSpaceHTMLElement.classList.add("UICore_UIGroupingWrapperFrame_CoordinateSpace");
|
|
914
|
+
coordinateSpaceHTMLElement.setAttribute("data-uicore-grouping-wrapper-coordinate-space", "");
|
|
915
|
+
wrapperHTMLElement.appendChild(coordinateSpaceHTMLElement);
|
|
916
|
+
return {
|
|
917
|
+
wrapperHTMLElement,
|
|
918
|
+
coordinateSpaceHTMLElement,
|
|
919
|
+
views: [],
|
|
920
|
+
childRecords: [],
|
|
921
|
+
configuredClassNames: [],
|
|
922
|
+
configuredAttributeNames: [],
|
|
923
|
+
configuredStyleNames: []
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
static _configureGroupingWrapperFrameRecord(record, request, owner, containerHTMLElement) {
|
|
927
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
928
|
+
const wrapperHTMLElement = record.wrapperHTMLElement;
|
|
929
|
+
record.configuredClassNames.forEach((className) => wrapperHTMLElement.classList.remove(className));
|
|
930
|
+
record.configuredAttributeNames.forEach((attributeName) => wrapperHTMLElement.removeAttribute(attributeName));
|
|
931
|
+
record.configuredStyleNames.forEach((styleName) => wrapperHTMLElement.style[styleName] = "");
|
|
932
|
+
wrapperHTMLElement.classList.add("UICore_UIGroupingWrapperFrame");
|
|
933
|
+
wrapperHTMLElement.setAttribute("data-uicore-grouping-wrapper-frame", "");
|
|
934
|
+
record.identifier = request.configuration.identifier;
|
|
935
|
+
record.views = request.views.copy();
|
|
936
|
+
record.configuredClassNames = (_b = (_a = request.configuration.classNames) == null ? void 0 : _a.copy()) != null ? _b : [];
|
|
937
|
+
record.configuredAttributeNames = Object.keys((_c = request.configuration.attributes) != null ? _c : {});
|
|
938
|
+
record.configuredStyleNames = Object.keys((_d = request.configuration.style) != null ? _d : {});
|
|
939
|
+
record.configuredClassNames.forEach((className) => wrapperHTMLElement.classList.add(className));
|
|
940
|
+
Object.keys((_e = request.configuration.attributes) != null ? _e : {}).forEach((attributeName) => {
|
|
941
|
+
wrapperHTMLElement.setAttribute(
|
|
942
|
+
attributeName,
|
|
943
|
+
request.configuration.attributes[attributeName]
|
|
944
|
+
);
|
|
945
|
+
});
|
|
946
|
+
Object.keys((_f = request.configuration.style) != null ? _f : {}).forEach((styleName) => {
|
|
947
|
+
wrapperHTMLElement.style[styleName] = request.configuration.style[styleName];
|
|
948
|
+
});
|
|
949
|
+
if (record.identifier) {
|
|
950
|
+
wrapperHTMLElement.setAttribute("data-uicore-grouping-wrapper-frame-identifier", record.identifier);
|
|
951
|
+
} else {
|
|
952
|
+
wrapperHTMLElement.removeAttribute("data-uicore-grouping-wrapper-frame-identifier");
|
|
953
|
+
}
|
|
954
|
+
const assignedFrames = Array.from(request.framesByView.values());
|
|
955
|
+
const framePoints = [];
|
|
956
|
+
assignedFrames.forEach((frame) => {
|
|
957
|
+
framePoints.push(frame.min);
|
|
958
|
+
framePoints.push(frame.max);
|
|
959
|
+
});
|
|
960
|
+
const defaultFrame = _UIRectangle.boundingBoxForPoints(framePoints);
|
|
961
|
+
const wrapperFrame = (_i = (_h = (_g = request.configuration).frame) == null ? void 0 : _h.call(_g, defaultFrame.copy(), assignedFrames.copy())) != null ? _i : defaultFrame;
|
|
962
|
+
wrapperHTMLElement.style.position = "absolute";
|
|
963
|
+
wrapperHTMLElement.style.left = wrapperFrame.x + "px";
|
|
964
|
+
wrapperHTMLElement.style.top = wrapperFrame.y + "px";
|
|
965
|
+
wrapperHTMLElement.style.width = wrapperFrame.width + "px";
|
|
966
|
+
wrapperHTMLElement.style.height = wrapperFrame.height + "px";
|
|
967
|
+
wrapperHTMLElement.style.boxSizing = "border-box";
|
|
968
|
+
if (wrapperHTMLElement.parentElement !== containerHTMLElement) {
|
|
969
|
+
containerHTMLElement.appendChild(wrapperHTMLElement);
|
|
970
|
+
}
|
|
971
|
+
const coordinateSpaceHTMLElement = record.coordinateSpaceHTMLElement;
|
|
972
|
+
coordinateSpaceHTMLElement.classList.add("UICore_UIGroupingWrapperFrame_CoordinateSpace");
|
|
973
|
+
coordinateSpaceHTMLElement.setAttribute("data-uicore-grouping-wrapper-coordinate-space", "");
|
|
974
|
+
coordinateSpaceHTMLElement.style.position = "absolute";
|
|
975
|
+
coordinateSpaceHTMLElement.style.left = -wrapperFrame.x - (wrapperHTMLElement.clientLeft || 0) + "px";
|
|
976
|
+
coordinateSpaceHTMLElement.style.top = -wrapperFrame.y - (wrapperHTMLElement.clientTop || 0) + "px";
|
|
977
|
+
coordinateSpaceHTMLElement.style.width = owner.bounds.width + "px";
|
|
978
|
+
coordinateSpaceHTMLElement.style.height = owner.bounds.height + "px";
|
|
979
|
+
}
|
|
980
|
+
static _topLevelHTMLElementForView(view) {
|
|
981
|
+
var _a;
|
|
982
|
+
let element = view.viewHTMLElement;
|
|
983
|
+
while (element.parentElement && element.parentElement !== ((_a = view.superview) == null ? void 0 : _a.viewHTMLElement)) {
|
|
984
|
+
element = element.parentElement;
|
|
985
|
+
}
|
|
986
|
+
return element;
|
|
987
|
+
}
|
|
988
|
+
static _detachViewFromGroupingWrapperFrame(view) {
|
|
989
|
+
var _a;
|
|
990
|
+
const superviewHTMLElement = (_a = view.superview) == null ? void 0 : _a.viewHTMLElement;
|
|
991
|
+
if (!superviewHTMLElement || view.viewHTMLElement.parentElement === superviewHTMLElement) {
|
|
992
|
+
return;
|
|
993
|
+
}
|
|
994
|
+
const wrapperHTMLElement = view.viewHTMLElement.closest("[data-uicore-grouping-wrapper-frame]");
|
|
995
|
+
superviewHTMLElement.appendChild(view.viewHTMLElement);
|
|
996
|
+
_UIRectangle._removeEmptyGroupingWrapperFrameAncestors(wrapperHTMLElement);
|
|
997
|
+
}
|
|
998
|
+
static _removeEmptyGroupingWrapperFrameAncestors(wrapperHTMLElement) {
|
|
999
|
+
var _a, _b;
|
|
1000
|
+
while (wrapperHTMLElement) {
|
|
1001
|
+
const parentWrapperHTMLElement = (_b = (_a = wrapperHTMLElement.parentElement) == null ? void 0 : _a.closest(
|
|
1002
|
+
"[data-uicore-grouping-wrapper-frame]"
|
|
1003
|
+
)) != null ? _b : null;
|
|
1004
|
+
const coordinateSpaceHTMLElement = wrapperHTMLElement.querySelector(
|
|
1005
|
+
":scope > [data-uicore-grouping-wrapper-coordinate-space]"
|
|
1006
|
+
);
|
|
1007
|
+
if (coordinateSpaceHTMLElement == null ? void 0 : coordinateSpaceHTMLElement.children.length) {
|
|
1008
|
+
return;
|
|
1009
|
+
}
|
|
1010
|
+
wrapperHTMLElement.remove();
|
|
1011
|
+
wrapperHTMLElement = parentWrapperHTMLElement;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
729
1014
|
toString() {
|
|
730
1015
|
const result = "[" + this.class.name + "] { x: " + this.x + ", y: " + this.y + ", height: " + this.height.toFixed(2) + ", width: " + this.height.toFixed(2) + " }";
|
|
731
1016
|
return result;
|
|
@@ -751,10 +1036,10 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
751
1036
|
}
|
|
752
1037
|
static boundingBoxForPoints(points) {
|
|
753
1038
|
if (points.length === 0) {
|
|
754
|
-
return new
|
|
1039
|
+
return new _UIRectangle();
|
|
755
1040
|
}
|
|
756
1041
|
const first = points[0];
|
|
757
|
-
const result = new
|
|
1042
|
+
const result = new _UIRectangle(first.x, first.y, 0, 0);
|
|
758
1043
|
for (let i = 1; i < points.length; i++) {
|
|
759
1044
|
result.updateByAddingPoint(points[i]);
|
|
760
1045
|
}
|
|
@@ -762,13 +1047,13 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
762
1047
|
}
|
|
763
1048
|
static boundingBoxForRectanglesAndPoints(rectanglesAndPoints) {
|
|
764
1049
|
if (rectanglesAndPoints.length === 0) {
|
|
765
|
-
return new
|
|
1050
|
+
return new _UIRectangle();
|
|
766
1051
|
}
|
|
767
1052
|
const first = rectanglesAndPoints[0];
|
|
768
|
-
const result = first instanceof
|
|
1053
|
+
const result = first instanceof _UIRectangle ? new _UIRectangle(first.x, first.y, first.height, first.width) : new _UIRectangle(first.x, first.y, 0, 0);
|
|
769
1054
|
for (let i = 1; i < rectanglesAndPoints.length; i++) {
|
|
770
1055
|
const rectangleOrPoint = rectanglesAndPoints[i];
|
|
771
|
-
if (rectangleOrPoint instanceof
|
|
1056
|
+
if (rectangleOrPoint instanceof _UIRectangle) {
|
|
772
1057
|
result.updateByAddingPoint(rectangleOrPoint.min);
|
|
773
1058
|
result.updateByAddingPoint(rectangleOrPoint.max);
|
|
774
1059
|
} else {
|
|
@@ -791,6 +1076,19 @@ class UIRectangle extends import_UIObject.UIObject {
|
|
|
791
1076
|
this.didChange();
|
|
792
1077
|
}
|
|
793
1078
|
}
|
|
1079
|
+
};
|
|
1080
|
+
let UIRectangle = _UIRectangle;
|
|
1081
|
+
UIRectangle._groupingWrapperFrameLayoutPasses = [];
|
|
1082
|
+
UIRectangle._groupingWrapperFrameRecordsByOwner = /* @__PURE__ */ new WeakMap();
|
|
1083
|
+
if (!("boundingBox" in Array.prototype)) {
|
|
1084
|
+
Object.defineProperty(Array.prototype, "boundingBox", {
|
|
1085
|
+
configurable: import_UIObject.YES,
|
|
1086
|
+
enumerable: import_UIObject.NO,
|
|
1087
|
+
writable: import_UIObject.YES,
|
|
1088
|
+
value: function() {
|
|
1089
|
+
return UIRectangle.boundingBoxForRectanglesAndPoints(this);
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
794
1092
|
}
|
|
795
1093
|
class UIRectangleConditionalBlock {
|
|
796
1094
|
constructor(initialResult, condition) {
|