uicore-ts 1.1.373 → 1.1.375
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/UIBaseButton.d.ts +4 -4
- package/compiledScripts/UIBaseButton.js +22 -22
- package/compiledScripts/UIBaseButton.js.map +2 -2
- package/compiledScripts/UIColor.d.ts +1 -1
- package/compiledScripts/UIColor.js +2 -2
- package/compiledScripts/UIColor.js.map +2 -2
- package/compiledScripts/UIImageView.d.ts +3 -3
- package/compiledScripts/UIImageView.js +9 -9
- package/compiledScripts/UIImageView.js.map +2 -2
- package/compiledScripts/UILoadingView.d.ts +3 -3
- package/compiledScripts/UILoadingView.js +8 -8
- package/compiledScripts/UILoadingView.js.map +2 -2
- package/compiledScripts/UITextField.d.ts +1 -1
- package/compiledScripts/UITextField.js +1 -1
- package/compiledScripts/UITextField.js.map +2 -2
- package/compiledScripts/UITextMeasurement.d.ts +5 -5
- package/compiledScripts/UITextMeasurement.js +15 -15
- package/compiledScripts/UITextMeasurement.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIBaseButton.ts +22 -23
- package/scripts/UIColor.ts +2 -3
- package/scripts/UIImageView.ts +9 -12
- package/scripts/UILoadingView.ts +8 -9
- package/scripts/UITextField.ts +1 -1
- package/scripts/UITextMeasurement.ts +15 -16
|
@@ -85,11 +85,11 @@ export declare class UIBaseButton extends UIView {
|
|
|
85
85
|
get isToggleable(): boolean;
|
|
86
86
|
layoutSubviews(): void;
|
|
87
87
|
sendControlEventForKey(eventKey: string, nativeEvent: Event): void;
|
|
88
|
-
static
|
|
88
|
+
static eventCoordinatesInDocument(touchOrMouseEvent: any): {
|
|
89
89
|
x: number;
|
|
90
90
|
y: number;
|
|
91
91
|
};
|
|
92
|
-
static
|
|
92
|
+
static elementPositionInDocument(el: {
|
|
93
93
|
tagName: string;
|
|
94
94
|
offsetLeft: number;
|
|
95
95
|
scrollLeft: number;
|
|
@@ -102,11 +102,11 @@ export declare class UIBaseButton extends UIView {
|
|
|
102
102
|
x: number;
|
|
103
103
|
y: number;
|
|
104
104
|
};
|
|
105
|
-
static
|
|
105
|
+
static coordinatesInElementFromDocumentCoordinates(x: number, y: number, element: any): {
|
|
106
106
|
x: number;
|
|
107
107
|
y: number;
|
|
108
108
|
};
|
|
109
|
-
static
|
|
109
|
+
static eventCoordinatesInElement(touchOrMouseEvent: any, element: any): {
|
|
110
110
|
x: number;
|
|
111
111
|
y: number;
|
|
112
112
|
};
|
|
@@ -32,29 +32,29 @@ const _UIBaseButton = class extends import_UIView.UIView {
|
|
|
32
32
|
this._highlighted = import_UIObject.NO;
|
|
33
33
|
this._isToggleable = import_UIObject.NO;
|
|
34
34
|
this._isPointerInside = import_UIObject.NO;
|
|
35
|
-
const
|
|
35
|
+
const markHovered = () => {
|
|
36
36
|
this.hovered = import_UIObject.YES;
|
|
37
37
|
};
|
|
38
|
-
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerHover,
|
|
39
|
-
const
|
|
38
|
+
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerHover, markHovered);
|
|
39
|
+
const clearHovered = () => {
|
|
40
40
|
this.hovered = import_UIObject.NO;
|
|
41
41
|
};
|
|
42
42
|
this.addTargetForControlEvents([
|
|
43
43
|
import_UIView.UIView.controlEvent.PointerLeave,
|
|
44
44
|
import_UIView.UIView.controlEvent.PointerCancel,
|
|
45
45
|
import_UIView.UIView.controlEvent.MultipleTouches
|
|
46
|
-
],
|
|
46
|
+
], clearHovered);
|
|
47
47
|
let highlightingTime;
|
|
48
|
-
const
|
|
48
|
+
const markHighlighted = () => {
|
|
49
49
|
this.highlighted = import_UIObject.YES;
|
|
50
50
|
highlightingTime = Date.now();
|
|
51
51
|
};
|
|
52
|
-
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerDown,
|
|
53
|
-
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerEnter,
|
|
54
|
-
const
|
|
52
|
+
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerDown, markHighlighted);
|
|
53
|
+
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerEnter, markHighlighted);
|
|
54
|
+
const clearHighlighted = () => {
|
|
55
55
|
this.highlighted = import_UIObject.NO;
|
|
56
56
|
};
|
|
57
|
-
const
|
|
57
|
+
const clearHighlightedAfterMinimumDuration = () => {
|
|
58
58
|
const minimumDurationInMilliseconds = 50;
|
|
59
59
|
const elapsedTime = Date.now() - highlightingTime;
|
|
60
60
|
if (minimumDurationInMilliseconds < elapsedTime) {
|
|
@@ -69,17 +69,17 @@ const _UIBaseButton = class extends import_UIView.UIView {
|
|
|
69
69
|
import_UIView.UIView.controlEvent.PointerLeave,
|
|
70
70
|
import_UIView.UIView.controlEvent.PointerCancel,
|
|
71
71
|
import_UIView.UIView.controlEvent.MultipleTouches
|
|
72
|
-
],
|
|
73
|
-
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerUp,
|
|
72
|
+
], clearHighlighted);
|
|
73
|
+
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.PointerUp, clearHighlightedAfterMinimumDuration);
|
|
74
74
|
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.EnterDown, () => {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
markHighlighted();
|
|
76
|
+
clearHighlightedAfterMinimumDuration();
|
|
77
77
|
this.sendControlEventForKey(import_UIView.UIView.controlEvent.PointerUpInside, import_UIObject.nil);
|
|
78
78
|
});
|
|
79
79
|
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.SpaceDown, (sender, event) => {
|
|
80
80
|
event.preventDefault();
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
markHighlighted();
|
|
82
|
+
clearHighlightedAfterMinimumDuration();
|
|
83
83
|
this.sendControlEventForKey(import_UIView.UIView.controlEvent.PointerUpInside, import_UIObject.nil);
|
|
84
84
|
});
|
|
85
85
|
this.addTargetForControlEvent(
|
|
@@ -235,7 +235,7 @@ const _UIBaseButton = class extends import_UIView.UIView {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
|
-
static
|
|
238
|
+
static eventCoordinatesInDocument(touchOrMouseEvent) {
|
|
239
239
|
var posx = 0;
|
|
240
240
|
var posy = 0;
|
|
241
241
|
var e = touchOrMouseEvent;
|
|
@@ -252,7 +252,7 @@ const _UIBaseButton = class extends import_UIView.UIView {
|
|
|
252
252
|
const coordinates = { "x": posx, "y": posy };
|
|
253
253
|
return coordinates;
|
|
254
254
|
}
|
|
255
|
-
static
|
|
255
|
+
static elementPositionInDocument(el) {
|
|
256
256
|
var xPosition = 0;
|
|
257
257
|
var yPosition = 0;
|
|
258
258
|
while (el) {
|
|
@@ -268,14 +268,14 @@ const _UIBaseButton = class extends import_UIView.UIView {
|
|
|
268
268
|
y: yPosition
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
|
-
static
|
|
272
|
-
const elementPositionInDocument = this.
|
|
271
|
+
static coordinatesInElementFromDocumentCoordinates(x, y, element) {
|
|
272
|
+
const elementPositionInDocument = this.elementPositionInDocument(element);
|
|
273
273
|
const coordinatesInElement = { "x": x - elementPositionInDocument.x, "y": y - elementPositionInDocument.y };
|
|
274
274
|
return coordinatesInElement;
|
|
275
275
|
}
|
|
276
|
-
static
|
|
277
|
-
const coordinatesInDocument = this.
|
|
278
|
-
const coordinatesInElement = this.
|
|
276
|
+
static eventCoordinatesInElement(touchOrMouseEvent, element) {
|
|
277
|
+
const coordinatesInDocument = this.eventCoordinatesInDocument(touchOrMouseEvent);
|
|
278
|
+
const coordinatesInElement = this.coordinatesInElementFromDocumentCoordinates(
|
|
279
279
|
coordinatesInDocument.x,
|
|
280
280
|
coordinatesInDocument.y,
|
|
281
281
|
element
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIBaseButton.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIColor } from \"./UIColor\"\nimport { IS, nil, NO, YES } from \"./UIObject\"\nimport { UIView, UIViewAddControlEventTargetObject, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIBaseButton extends UIView {\n \n static override controlEvent = Object.assign({}, UIView.controlEvent, {\n \"PrimaryActionTriggered\": \"PrimaryActionTriggered\"\n } as const)\n \n override controlEvent = UIBaseButton.controlEvent\n \n override get controlEventTargetAccumulator(): UIViewAddControlEventTargetObject<typeof UIBaseButton> {\n return super.controlEventTargetAccumulator as any\n }\n \n \n _selected: boolean = NO\n _highlighted: boolean = NO\n \n override _isPointerInside: boolean\n \n \n _isToggleable: boolean = NO\n _hovered?: boolean\n _focused?: boolean\n \n \n constructor(elementID?: string, elementType?: string) {\n \n super(elementID, undefined, elementType)\n \n // Instance variables\n \n \n this._isPointerInside = NO\n \n \n const setHovered = () => {\n this.hovered = YES\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerHover, setHovered)\n \n const setNotHovered = () => {\n \n this.hovered = NO\n \n }\n \n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], setNotHovered)\n \n \n let highlightingTime: number\n const setHighlighted = () => {\n this.highlighted = YES\n highlightingTime = Date.now()\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerDown, setHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerEnter, setHighlighted)\n \n const setNotHighlighted = () => {\n this.highlighted = NO\n }\n const setNotHighlightedWithMinimumDuration = () => {\n const minimumDurationInMilliseconds = 50\n const elapsedTime = Date.now() - highlightingTime\n if (minimumDurationInMilliseconds < elapsedTime) {\n this.highlighted = NO\n }\n else {\n setTimeout(() => {\n this.highlighted = NO\n }, minimumDurationInMilliseconds - elapsedTime)\n }\n }\n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], setNotHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerUp, setNotHighlightedWithMinimumDuration)\n \n // Enter and Space both activate the button.\n // Fire PointerUpInside (which cascades to PrimaryActionTriggered via sendControlEventForKey).\n this.addTargetForControlEvent(UIView.controlEvent.EnterDown, () => {\n \n setHighlighted()\n setNotHighlightedWithMinimumDuration()\n this.sendControlEventForKey(UIView.controlEvent.PointerUpInside, nil)\n \n })\n \n this.addTargetForControlEvent(UIView.controlEvent.SpaceDown, (sender, event) => {\n \n event.preventDefault()\n setHighlighted()\n setNotHighlightedWithMinimumDuration()\n this.sendControlEventForKey(UIView.controlEvent.PointerUpInside, nil)\n \n })\n \n \n this.addTargetForControlEvent(\n UIView.controlEvent.Focus,\n (sender: UIView, event: Event) => {\n \n this.focused = YES\n \n }\n )\n \n this.addTargetForControlEvent(\n UIView.controlEvent.Blur,\n (sender: UIView, event: Event) => {\n \n this.focused = NO\n \n }\n )\n \n \n this.pausesPointerEvents = YES\n this.tabIndex = 1\n \n this.style.cursor = \"pointer\"\n \n //this.style.outline = \"none\";\n \n \n this.nativeSelectionEnabled = NO\n \n \n this.addTargetForControlEvents([\n UIBaseButton.controlEvent.PrimaryActionTriggered, UIView.controlEvent.PointerUpInside\n ], () => {\n \n if (this.isToggleable) {\n \n this.toggleSelectedState()\n \n }\n \n })\n \n }\n \n public set hovered(hovered: boolean) {\n this._hovered = hovered\n this.updateContentForCurrentState()\n }\n \n public get hovered(): boolean {\n return this._hovered ?? NO\n }\n \n public set highlighted(highlighted: boolean) {\n this._highlighted = highlighted\n this.updateContentForCurrentState()\n }\n \n public get highlighted(): boolean {\n return this._highlighted\n }\n \n public set focused(focused: boolean) {\n this._focused = focused\n if (focused) {\n this.focus()\n }\n else {\n this.blur()\n }\n this.updateContentForCurrentState()\n }\n \n public get focused(): boolean {\n return this._focused ?? NO\n }\n \n public set selected(selected: boolean) {\n this._selected = selected\n this.updateContentForCurrentState()\n }\n \n public get selected(): boolean {\n return this._selected\n }\n \n \n updateContentForCurrentState() {\n \n let updateFunction: Function = this.updateContentForNormalState\n if (this.selected && this.highlighted) {\n updateFunction = this.updateContentForSelectedAndHighlightedState\n }\n else if (this.selected) {\n updateFunction = this.updateContentForSelectedState\n }\n else if (this.focused) {\n updateFunction = this.updateContentForFocusedState\n }\n else if (this.highlighted) {\n updateFunction = this.updateContentForHighlightedState\n }\n else if (this.hovered) {\n updateFunction = this.updateContentForHoveredState\n }\n \n if (!IS(updateFunction)) {\n this.backgroundColor = UIColor.nilColor\n }\n else {\n updateFunction.call(this)\n }\n \n }\n \n updateContentForNormalState() {\n \n \n }\n \n updateContentForHoveredState() {\n \n this.updateContentForNormalState()\n \n }\n \n updateContentForFocusedState() {\n \n this.updateContentForHoveredState()\n \n }\n \n updateContentForHighlightedState() {\n \n \n }\n \n updateContentForSelectedState() {\n \n \n }\n \n updateContentForSelectedAndHighlightedState() {\n \n this.updateContentForSelectedState()\n \n }\n \n \n override set enabled(enabled: boolean) {\n super.enabled = enabled\n this.updateContentForCurrentEnabledState()\n }\n \n override get enabled() {\n return super.enabled\n }\n \n override updateContentForCurrentEnabledState() {\n \n if (this.enabled) {\n this.alpha = 1\n }\n else {\n this.alpha = 0.5\n }\n \n this.userInteractionEnabled = this.enabled\n \n }\n \n \n override addStyleClass(styleClassName: string) {\n \n super.addStyleClass(styleClassName)\n \n if (this.styleClassName != styleClassName) {\n \n this.updateContentForCurrentState.call(this)\n \n }\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.PageDidScroll || event.name ==\n UIView.broadcastEventName.AddedToViewTree) {\n \n const wasHovered = this._hovered\n const wasHighlighted = this._highlighted\n \n this._hovered = NO\n this._highlighted = NO\n \n if (wasHovered || wasHighlighted) {\n this.updateContentForCurrentState()\n }\n \n }\n \n \n }\n \n \n toggleSelectedState() {\n \n \n this.selected = !this.selected\n \n \n }\n \n set isToggleable(isToggleable: boolean) {\n \n this._isToggleable = isToggleable\n \n }\n \n get isToggleable() {\n \n return this._isToggleable\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n const bounds = this.bounds\n \n \n }\n \n \n override sendControlEventForKey(eventKey: string, nativeEvent: Event) {\n \n if (eventKey == UIView.controlEvent.PointerUpInside && !this.highlighted) {\n \n // Do not send the event in this case\n //super.sendControlEventForKey(eventKey, nativeEvent);\n \n const asd = 1\n \n }\n else {\n \n super.sendControlEventForKey(eventKey, nativeEvent)\n \n if (eventKey == UIView.controlEvent.PointerUpInside) {\n super.sendControlEventForKey(UIBaseButton.controlEvent.PrimaryActionTriggered, nativeEvent)\n }\n \n }\n \n }\n \n \n static getEventCoordinatesInDocument(touchOrMouseEvent: any) {\n // http://www.quirksmode.org/js/events_properties.html\n var posx = 0\n var posy = 0\n var e = touchOrMouseEvent\n if (!e) {\n e = window.event\n }\n if (e.pageX || e.pageY) {\n posx = e.pageX\n posy = e.pageY\n }\n else if (e.clientX || e.clientY) {\n posx = e.clientX + document.body.scrollLeft\n + document.documentElement.scrollLeft\n posy = e.clientY + document.body.scrollTop\n + document.documentElement.scrollTop\n }\n // posx and posy contain the mouse position relative to the document\n \n const coordinates = { \"x\": posx, \"y\": posy }\n \n return coordinates\n \n }\n \n \n static getElementPositionInDocument(el: { tagName: string; offsetLeft: number; scrollLeft: number; clientLeft: number; offsetTop: number; scrollTop: number; clientTop: number; offsetParent: any }) {\n //https://www.kirupa.com/html5/getting_mouse_click_position.htm\n var xPosition = 0\n var yPosition = 0\n \n while (el) {\n if (el.tagName == \"BODY\") {\n \n // Coordinates in document are coordinates in body, therefore subtracting the scroll position of the body is not needed\n \n // // deal with browser quirks with body/window/document and page scroll\n // var xScrollPos = el.scrollLeft || document.documentElement.scrollLeft;\n // var yScrollPos = el.scrollTop || document.documentElement.scrollTop;\n //\n // xPosition += (el.offsetLeft - xScrollPos + el.clientLeft);\n // yPosition += (el.offsetTop - yScrollPos + el.clientTop);\n }\n else {\n xPosition += (el.offsetLeft - el.scrollLeft + el.clientLeft)\n yPosition += (el.offsetTop - el.scrollTop + el.clientTop)\n }\n \n el = el.offsetParent\n }\n return {\n x: xPosition,\n y: yPosition\n }\n }\n \n static convertCoordinatesFromDocumentToElement(x: number, y: number, element: any) {\n const elementPositionInDocument = this.getElementPositionInDocument(element)\n const coordinatesInElement = { \"x\": x - elementPositionInDocument.x, \"y\": y - elementPositionInDocument.y }\n return coordinatesInElement\n }\n \n static getEventCoordinatesInElement(touchOrMouseEvent: any, element: any) {\n const coordinatesInDocument = this.getEventCoordinatesInDocument(touchOrMouseEvent)\n const coordinatesInElement = this.convertCoordinatesFromDocumentToElement(\n coordinatesInDocument.x,\n coordinatesInDocument.y,\n element\n )\n return coordinatesInElement\n }\n \n \n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAwB;AACxB,sBAAiC;AACjC,oBAAgF;AAGzE,MAAM,gBAAN,cAA2B,qBAAO;AAAA,EAwBrC,YAAY,WAAoB,aAAsB;AAElD,UAAM,WAAW,QAAW,WAAW;AApB3C,SAAS,eAAe,cAAa;AAOrC,qBAAqB;AACrB,wBAAwB;AAKxB,yBAAyB;AAYrB,SAAK,mBAAmB;AAGxB,UAAM,
|
|
4
|
+
"sourcesContent": ["import { UIColor } from \"./UIColor\"\nimport { IS, nil, NO, YES } from \"./UIObject\"\nimport { UIView, UIViewAddControlEventTargetObject, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIBaseButton extends UIView {\n \n static override controlEvent = Object.assign({}, UIView.controlEvent, {\n \"PrimaryActionTriggered\": \"PrimaryActionTriggered\"\n } as const)\n \n override controlEvent = UIBaseButton.controlEvent\n \n override get controlEventTargetAccumulator(): UIViewAddControlEventTargetObject<typeof UIBaseButton> {\n return super.controlEventTargetAccumulator as any\n }\n \n \n _selected: boolean = NO\n _highlighted: boolean = NO\n \n override _isPointerInside: boolean\n \n \n _isToggleable: boolean = NO\n _hovered?: boolean\n _focused?: boolean\n \n \n constructor(elementID?: string, elementType?: string) {\n \n super(elementID, undefined, elementType)\n \n // Instance variables\n \n \n this._isPointerInside = NO\n \n \n const markHovered = () => {\n this.hovered = YES\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerHover, markHovered)\n \n const clearHovered = () => {\n \n this.hovered = NO\n \n }\n \n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], clearHovered)\n \n \n let highlightingTime: number\n const markHighlighted = () => {\n this.highlighted = YES\n highlightingTime = Date.now()\n }\n this.addTargetForControlEvent(UIView.controlEvent.PointerDown, markHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerEnter, markHighlighted)\n \n const clearHighlighted = () => {\n this.highlighted = NO\n }\n const clearHighlightedAfterMinimumDuration = () => {\n const minimumDurationInMilliseconds = 50\n const elapsedTime = Date.now() - highlightingTime\n if (minimumDurationInMilliseconds < elapsedTime) {\n this.highlighted = NO\n }\n else {\n setTimeout(() => {\n this.highlighted = NO\n }, minimumDurationInMilliseconds - elapsedTime)\n }\n }\n this.addTargetForControlEvents([\n UIView.controlEvent.PointerLeave, UIView.controlEvent.PointerCancel, UIView.controlEvent.MultipleTouches\n ], clearHighlighted)\n this.addTargetForControlEvent(UIView.controlEvent.PointerUp, clearHighlightedAfterMinimumDuration)\n \n // Enter and Space both activate the button.\n // Fire PointerUpInside (which cascades to PrimaryActionTriggered via sendControlEventForKey).\n this.addTargetForControlEvent(UIView.controlEvent.EnterDown, () => {\n \n markHighlighted()\n clearHighlightedAfterMinimumDuration()\n this.sendControlEventForKey(UIView.controlEvent.PointerUpInside, nil)\n \n })\n \n this.addTargetForControlEvent(UIView.controlEvent.SpaceDown, (sender, event) => {\n \n event.preventDefault()\n markHighlighted()\n clearHighlightedAfterMinimumDuration()\n this.sendControlEventForKey(UIView.controlEvent.PointerUpInside, nil)\n \n })\n \n \n this.addTargetForControlEvent(\n UIView.controlEvent.Focus,\n (sender: UIView, event: Event) => {\n \n this.focused = YES\n \n }\n )\n \n this.addTargetForControlEvent(\n UIView.controlEvent.Blur,\n (sender: UIView, event: Event) => {\n \n this.focused = NO\n \n }\n )\n \n \n this.pausesPointerEvents = YES\n this.tabIndex = 1\n \n this.style.cursor = \"pointer\"\n \n //this.style.outline = \"none\";\n \n \n this.nativeSelectionEnabled = NO\n \n \n this.addTargetForControlEvents([\n UIBaseButton.controlEvent.PrimaryActionTriggered, UIView.controlEvent.PointerUpInside\n ], () => {\n \n if (this.isToggleable) {\n \n this.toggleSelectedState()\n \n }\n \n })\n \n }\n \n public set hovered(hovered: boolean) {\n this._hovered = hovered\n this.updateContentForCurrentState()\n }\n \n public get hovered(): boolean {\n return this._hovered ?? NO\n }\n \n public set highlighted(highlighted: boolean) {\n this._highlighted = highlighted\n this.updateContentForCurrentState()\n }\n \n public get highlighted(): boolean {\n return this._highlighted\n }\n \n public set focused(focused: boolean) {\n this._focused = focused\n if (focused) {\n this.focus()\n }\n else {\n this.blur()\n }\n this.updateContentForCurrentState()\n }\n \n public get focused(): boolean {\n return this._focused ?? NO\n }\n \n public set selected(selected: boolean) {\n this._selected = selected\n this.updateContentForCurrentState()\n }\n \n public get selected(): boolean {\n return this._selected\n }\n \n \n updateContentForCurrentState() {\n \n let updateFunction: Function = this.updateContentForNormalState\n if (this.selected && this.highlighted) {\n updateFunction = this.updateContentForSelectedAndHighlightedState\n }\n else if (this.selected) {\n updateFunction = this.updateContentForSelectedState\n }\n else if (this.focused) {\n updateFunction = this.updateContentForFocusedState\n }\n else if (this.highlighted) {\n updateFunction = this.updateContentForHighlightedState\n }\n else if (this.hovered) {\n updateFunction = this.updateContentForHoveredState\n }\n \n if (!IS(updateFunction)) {\n this.backgroundColor = UIColor.nilColor\n }\n else {\n updateFunction.call(this)\n }\n \n }\n \n updateContentForNormalState() {\n \n \n }\n \n updateContentForHoveredState() {\n \n this.updateContentForNormalState()\n \n }\n \n updateContentForFocusedState() {\n \n this.updateContentForHoveredState()\n \n }\n \n updateContentForHighlightedState() {\n \n \n }\n \n updateContentForSelectedState() {\n \n \n }\n \n updateContentForSelectedAndHighlightedState() {\n \n this.updateContentForSelectedState()\n \n }\n \n \n override set enabled(enabled: boolean) {\n super.enabled = enabled\n this.updateContentForCurrentEnabledState()\n }\n \n override get enabled() {\n return super.enabled\n }\n \n override updateContentForCurrentEnabledState() {\n \n if (this.enabled) {\n this.alpha = 1\n }\n else {\n this.alpha = 0.5\n }\n \n this.userInteractionEnabled = this.enabled\n \n }\n \n \n override addStyleClass(styleClassName: string) {\n \n super.addStyleClass(styleClassName)\n \n if (this.styleClassName != styleClassName) {\n \n this.updateContentForCurrentState.call(this)\n \n }\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.PageDidScroll || event.name ==\n UIView.broadcastEventName.AddedToViewTree) {\n \n const wasHovered = this._hovered\n const wasHighlighted = this._highlighted\n \n this._hovered = NO\n this._highlighted = NO\n \n if (wasHovered || wasHighlighted) {\n this.updateContentForCurrentState()\n }\n \n }\n \n \n }\n \n \n toggleSelectedState() {\n \n \n this.selected = !this.selected\n \n \n }\n \n set isToggleable(isToggleable: boolean) {\n \n this._isToggleable = isToggleable\n \n }\n \n get isToggleable() {\n \n return this._isToggleable\n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n const bounds = this.bounds\n \n \n }\n \n \n override sendControlEventForKey(eventKey: string, nativeEvent: Event) {\n \n if (eventKey == UIView.controlEvent.PointerUpInside && !this.highlighted) {\n \n // Do not send the event in this case\n //super.sendControlEventForKey(eventKey, nativeEvent);\n \n const asd = 1\n \n }\n else {\n \n super.sendControlEventForKey(eventKey, nativeEvent)\n \n if (eventKey == UIView.controlEvent.PointerUpInside) {\n super.sendControlEventForKey(UIBaseButton.controlEvent.PrimaryActionTriggered, nativeEvent)\n }\n \n }\n \n }\n \n \n static eventCoordinatesInDocument(touchOrMouseEvent: any) {\n // http://www.quirksmode.org/js/events_properties.html\n var posx = 0\n var posy = 0\n var e = touchOrMouseEvent\n if (!e) {\n e = window.event\n }\n if (e.pageX || e.pageY) {\n posx = e.pageX\n posy = e.pageY\n }\n else if (e.clientX || e.clientY) {\n posx = e.clientX + document.body.scrollLeft\n + document.documentElement.scrollLeft\n posy = e.clientY + document.body.scrollTop\n + document.documentElement.scrollTop\n }\n // posx and posy contain the mouse position relative to the document\n \n const coordinates = { \"x\": posx, \"y\": posy }\n \n return coordinates\n \n }\n \n static elementPositionInDocument(el: { tagName: string; offsetLeft: number; scrollLeft: number; clientLeft: number; offsetTop: number; scrollTop: number; clientTop: number; offsetParent: any }) {\n //https://www.kirupa.com/html5/getting_mouse_click_position.htm\n var xPosition = 0\n var yPosition = 0\n \n while (el) {\n if (el.tagName == \"BODY\") {\n \n // Coordinates in document are coordinates in body, therefore subtracting the scroll position of the body is not needed\n \n // // deal with browser quirks with body/window/document and page scroll\n // var xScrollPos = el.scrollLeft || document.documentElement.scrollLeft;\n // var yScrollPos = el.scrollTop || document.documentElement.scrollTop;\n //\n // xPosition += (el.offsetLeft - xScrollPos + el.clientLeft);\n // yPosition += (el.offsetTop - yScrollPos + el.clientTop);\n }\n else {\n xPosition += (el.offsetLeft - el.scrollLeft + el.clientLeft)\n yPosition += (el.offsetTop - el.scrollTop + el.clientTop)\n }\n \n el = el.offsetParent\n }\n return {\n x: xPosition,\n y: yPosition\n }\n }\n \n static coordinatesInElementFromDocumentCoordinates(x: number, y: number, element: any) {\n const elementPositionInDocument = this.elementPositionInDocument(element)\n const coordinatesInElement = { \"x\": x - elementPositionInDocument.x, \"y\": y - elementPositionInDocument.y }\n return coordinatesInElement\n }\n \n static eventCoordinatesInElement(touchOrMouseEvent: any, element: any) {\n const coordinatesInDocument = this.eventCoordinatesInDocument(touchOrMouseEvent)\n const coordinatesInElement = this.coordinatesInElementFromDocumentCoordinates(\n coordinatesInDocument.x,\n coordinatesInDocument.y,\n element\n )\n return coord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
|
|
7
7
|
}
|
|
@@ -79,7 +79,7 @@ export declare class UIColor extends UIObject {
|
|
|
79
79
|
colorWithAlpha(alpha: number): UIColor;
|
|
80
80
|
static colorWithRGBA(red: number, green: number, blue: number, alpha?: number): UIColor;
|
|
81
81
|
static colorWithDescriptor(descriptor: UIColorDescriptor): UIColor;
|
|
82
|
-
private static
|
|
82
|
+
private static alphaDefaultingToOne;
|
|
83
83
|
colorByMultiplyingRGB(multiplier: number): UIColor;
|
|
84
84
|
/**
|
|
85
85
|
* Returns the perceptual lightness (L*) of this color in the range [0, 1],
|
|
@@ -344,10 +344,10 @@ const _UIColor = class extends import_UIObject.UIObject {
|
|
|
344
344
|
const red = Math.min(255, Math.max(0, descriptor.red)).toFixed(0);
|
|
345
345
|
const green = Math.min(255, Math.max(0, descriptor.green)).toFixed(0);
|
|
346
346
|
const blue = Math.min(255, Math.max(0, descriptor.blue)).toFixed(0);
|
|
347
|
-
const alpha = this.
|
|
347
|
+
const alpha = this.alphaDefaultingToOne(descriptor.alpha);
|
|
348
348
|
return new _UIColor("rgba(" + red + "," + green + "," + blue + "," + alpha + ")");
|
|
349
349
|
}
|
|
350
|
-
static
|
|
350
|
+
static alphaDefaultingToOne(value = 1) {
|
|
351
351
|
if (value != value) {
|
|
352
352
|
value = 1;
|
|
353
353
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIColor.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIObject } from \"./UIObject\"\n\n\nexport interface UIColorDescriptor {\n \n red: number;\n green: number;\n blue: number;\n alpha?: number;\n \n}\n\n\nexport type UIColorSemanticKey = string\n\n\nexport class UIColor extends UIObject {\n \n \n // --- Semantic color registry ---\n \n static _liveColors: WeakRef<UIColor>[] = []\n static _registrationMap = new Map<string, UIColor>()\n static _cssSubscriptions = new Map<UIColorSemanticKey, Set<() => void>>()\n \n \n // --- Instance fields ---\n \n stringValue: string\n semanticKey?: UIColorSemanticKey\n _semanticClass?: typeof UIColor\n _elementRef?: HTMLElement\n _styleProperty?: string\n \n \n constructor(stringValue: string, semanticKey?: UIColorSemanticKey) {\n \n super()\n \n this.stringValue = stringValue\n this.semanticKey = semanticKey\n if (semanticKey) {\n this._semanticClass = this.constructor as typeof UIColor\n }\n \n }\n \n \n override toString() {\n return this.stringValue\n }\n \n \n // --- Semantic apply ---\n \n /**\n * Re-resolves this instance's stringValue from its class's static getter\n * matching the semanticKey, then writes the new value directly to the DOM\n * via the stored element reference and style property.\n * No-op if this instance has no semanticKey.\n */\n apply() {\n \n if (!this.semanticKey) { return }\n \n const colorClass = this._semanticClass ?? this.constructor as typeof UIColor\n const newColor = (colorClass as any)[this.semanticKey] as UIColor | undefined\n \n if (!newColor) { return }\n \n this.stringValue = newColor.stringValue\n \n const element = this._elementRef\n \n if (!element || !this._styleProperty) { return }\n \n (element.style as any)[this._styleProperty] = this.stringValue\n \n }\n \n \n /**\n * Assigns a semantic key and the class that owns it to this color instance.\n * Intended for derived colors that should participate in theme switching,\n * e.g. `BSColor._primaryBase.colorWithAlpha(0.5).withSemanticKey(\"primaryShadow\", BSColor)`.\n * Returns `this` for fluent chaining.\n */\n withSemanticKey(semanticKey: UIColorSemanticKey, semanticClass: typeof UIColor): this {\n this.semanticKey = semanticKey\n this._semanticClass = semanticClass\n return this\n }\n \n \n /**\n * Iterates all live registered UIColor instances, calls apply() on each,\n * compacts dead WeakRefs in the same pass, then fires any CSS subscriptions\n * whose semantic key was affected.\n */\n static applySemanticColors() {\n \n const affectedKeys = new Set<UIColorSemanticKey>()\n \n const live: WeakRef<UIColor>[] = []\n \n for (const ref of UIColor._liveColors) {\n \n const color = ref.deref()\n \n if (!color) {\n continue\n }\n \n live.push(ref)\n \n if (color.semanticKey) {\n affectedKeys.add(color.semanticKey)\n }\n \n color.apply()\n \n }\n \n UIColor._liveColors = live\n \n for (const key of affectedKeys) {\n UIColor._cssSubscriptions.get(key)?.forEach(callback => callback())\n }\n \n }\n \n \n /**\n * Updates the backing field for a semantic color and re-applies all live\n * semantic colors. The backing field is always `_` + semanticKey, e.g.\n * `BSColor.updateSemanticColor(\"primary\", \"#ff0000\")` sets `BSColor._primary`.\n * Called as a static method on the subclass that owns the color.\n */\n static updateSemanticColor(semanticKey: UIColorSemanticKey, value: string) {\n (this as any)[\"_\" + semanticKey] = value\n UIColor.applySemanticColors()\n }\n \n \n /**\n * Registers a callback to be fired when applySemanticColors() affects\n * the given semantic key. Intended for injected CSS blocks that cannot\n * be tracked via the colorStyleProxy.\n */\n static subscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n \n if (!UIColor._cssSubscriptions.has(semanticKey)) {\n UIColor._cssSubscriptions.set(semanticKey, new Set())\n }\n \n UIColor._cssSubscriptions.get(semanticKey)!.add(callback)\n \n }\n \n \n static unsubscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n UIColor._cssSubscriptions.get(semanticKey)?.delete(callback)\n }\n \n \n // --- Named colors ---\n \n static get redColor() {\n return new UIColor(\"red\")\n }\n \n static get blueColor() {\n return new UIColor(\"blue\")\n }\n \n static get greenColor() {\n return new UIColor(\"green\")\n }\n \n static get yellowColor() {\n return new UIColor(\"yellow\")\n }\n \n static get blackColor() {\n return new UIColor(\"black\")\n }\n \n static get brownColor() {\n return new UIColor(\"brown\")\n }\n \n static get whiteColor() {\n return new UIColor(\"white\")\n }\n \n static get greyColor() {\n return new UIColor(\"grey\")\n }\n \n static get lightGreyColor() {\n return new UIColor(\"lightgrey\")\n }\n \n static get transparentColor() {\n return new UIColor(\"transparent\")\n }\n \n static get clearColor() {\n return new UIColor(\"transparent\")\n }\n \n static get undefinedColor() {\n return new UIColor(\"\")\n }\n \n static get nilColor() {\n return new UIColor(\"\")\n }\n \n \n static nameToHex(name: string) {\n return {\n \"aliceblue\": \"#f0f8ff\",\n \"antiquewhite\": \"#faebd7\",\n \"aqua\": \"#00ffff\",\n \"aquamarine\": \"#7fffd4\",\n \"azure\": \"#f0ffff\",\n \"beige\": \"#f5f5dc\",\n \"bisque\": \"#ffe4c4\",\n \"black\": \"#000000\",\n \"blanchedalmond\": \"#ffebcd\",\n \"blue\": \"#0000ff\",\n \"blueviolet\": \"#8a2be2\",\n \"brown\": \"#a52a2a\",\n \"burlywood\": \"#deb887\",\n \"cadetblue\": \"#5f9ea0\",\n \"chartreuse\": \"#7fff00\",\n \"chocolate\": \"#d2691e\",\n \"coral\": \"#ff7f50\",\n \"cornflowerblue\": \"#6495ed\",\n \"cornsilk\": \"#fff8dc\",\n \"crimson\": \"#dc143c\",\n \"cyan\": \"#00ffff\",\n \"darkblue\": \"#00008b\",\n \"darkcyan\": \"#008b8b\",\n \"darkgoldenrod\": \"#b8860b\",\n \"darkgray\": \"#a9a9a9\",\n \"darkgreen\": \"#006400\",\n \"darkkhaki\": \"#bdb76b\",\n \"darkmagenta\": \"#8b008b\",\n \"darkolivegreen\": \"#556b2f\",\n \"darkorange\": \"#ff8c00\",\n \"darkorchid\": \"#9932cc\",\n \"darkred\": \"#8b0000\",\n \"darksalmon\": \"#e9967a\",\n \"darkseagreen\": \"#8fbc8f\",\n \"darkslateblue\": \"#483d8b\",\n \"darkslategray\": \"#2f4f4f\",\n \"darkturquoise\": \"#00ced1\",\n \"darkviolet\": \"#9400d3\",\n \"deeppink\": \"#ff1493\",\n \"deepskyblue\": \"#00bfff\",\n \"dimgray\": \"#696969\",\n \"dodgerblue\": \"#1e90ff\",\n \"firebrick\": \"#b22222\",\n \"floralwhite\": \"#fffaf0\",\n \"forestgreen\": \"#228b22\",\n \"fuchsia\": \"#ff00ff\",\n \"gainsboro\": \"#dcdcdc\",\n \"ghostwhite\": \"#f8f8ff\",\n \"gold\": \"#ffd700\",\n \"goldenrod\": \"#daa520\",\n \"gray\": \"#808080\",\n \"green\": \"#008000\",\n \"greenyellow\": \"#adff2f\",\n \"honeydew\": \"#f0fff0\",\n \"hotpink\": \"#ff69b4\",\n \"indianred \": \"#cd5c5c\",\n \"indigo\": \"#4b0082\",\n \"ivory\": \"#fffff0\",\n \"khaki\": \"#f0e68c\",\n \"lavender\": \"#e6e6fa\",\n \"lavenderblush\": \"#fff0f5\",\n \"lawngreen\": \"#7cfc00\",\n \"lemonchiffon\": \"#fffacd\",\n \"lightblue\": \"#add8e6\",\n \"lightcoral\": \"#f08080\",\n \"lightcyan\": \"#e0ffff\",\n \"lightgoldenrodyellow\": \"#fafad2\",\n \"lightgrey\": \"#d3d3d3\",\n \"lightgreen\": \"#90ee90\",\n \"lightpink\": \"#ffb6c1\",\n \"lightsalmon\": \"#ffa07a\",\n \"lightseagreen\": \"#20b2aa\",\n \"lightskyblue\": \"#87cefa\",\n \"lightslategray\": \"#778899\",\n \"lightsteelblue\": \"#b0c4de\",\n \"lightyellow\": \"#ffffe0\",\n \"lime\": \"#00ff00\",\n \"limegreen\": \"#32cd32\",\n \"linen\": \"#faf0e6\",\n \"magenta\": \"#ff00ff\",\n \"maroon\": \"#800000\",\n \"mediumaquamarine\": \"#66cdaa\",\n \"mediumblue\": \"#0000cd\",\n \"mediumorchid\": \"#ba55d3\",\n \"mediumpurple\": \"#9370d8\",\n \"mediumseagreen\": \"#3cb371\",\n \"mediumslateblue\": \"#7b68ee\",\n \"mediumspringgreen\": \"#00fa9a\",\n \"mediumturquoise\": \"#48d1cc\",\n \"mediumvioletred\": \"#c71585\",\n \"midnightblue\": \"#191970\",\n \"mintcream\": \"#f5fffa\",\n \"mistyrose\": \"#ffe4e1\",\n \"moccasin\": \"#ffe4b5\",\n \"navajowhite\": \"#ffdead\",\n \"navy\": \"#000080\",\n \"oldlace\": \"#fdf5e6\",\n \"olive\": \"#808000\",\n \"olivedrab\": \"#6b8e23\",\n \"orange\": \"#ffa500\",\n \"orangered\": \"#ff4500\",\n \"orchid\": \"#da70d6\",\n \"palegoldenrod\": \"#eee8aa\",\n \"palegreen\": \"#98fb98\",\n \"paleturquoise\": \"#afeeee\",\n \"palevioletred\": \"#d87093\",\n \"papayawhip\": \"#ffefd5\",\n \"peachpuff\": \"#ffdab9\",\n \"peru\": \"#cd853f\",\n \"pink\": \"#ffc0cb\",\n \"plum\": \"#dda0dd\",\n \"powderblue\": \"#b0e0e6\",\n \"purple\": \"#800080\",\n \"red\": \"#ff0000\",\n \"rosybrown\": \"#bc8f8f\",\n \"royalblue\": \"#4169e1\",\n \"saddlebrown\": \"#8b4513\",\n \"salmon\": \"#fa8072\",\n \"sandybrown\": \"#f4a460\",\n \"seagreen\": \"#2e8b57\",\n \"seashell\": \"#fff5ee\",\n \"sienna\": \"#a0522d\",\n \"silver\": \"#c0c0c0\",\n \"skyblue\": \"#87ceeb\",\n \"slateblue\": \"#6a5acd\",\n \"slategray\": \"#708090\",\n \"snow\": \"#fffafa\",\n \"springgreen\": \"#00ff7f\",\n \"steelblue\": \"#4682b4\",\n \"tan\": \"#d2b48c\",\n \"teal\": \"#008080\",\n \"thistle\": \"#d8bfd8\",\n \"tomato\": \"#ff6347\",\n \"turquoise\": \"#40e0d0\",\n \"violet\": \"#ee82ee\",\n \"wheat\": \"#f5deb3\",\n \"white\": \"#ffffff\",\n \"whitesmoke\": \"#f5f5f5\",\n \"yellow\": \"#ffff00\",\n \"yellowgreen\": \"#9acd32\"\n }[name.toLowerCase()]\n }\n \n \n static hexToDescriptor(c: string): UIColorDescriptor {\n if (c[0] === \"#\") {\n c = c.substr(1)\n }\n const r = parseInt(c.slice(0, 2), 16)\n const g = parseInt(c.slice(2, 4), 16)\n const b = parseInt(c.slice(4, 6), 16)\n const a = parseInt(c.slice(6, 8), 16)\n \n const result = { \"red\": r, \"green\": g, \"blue\": b, \"alpha\": a }\n \n return result\n \n }\n \n static rgbToDescriptor(colorString: string) {\n \n if (colorString.startsWith(\"rgba(\")) {\n colorString = colorString.slice(5, colorString.length - 1)\n }\n \n if (colorString.startsWith(\"rgb(\")) {\n colorString = colorString.slice(4, colorString.length - 1) + \", 0\"\n }\n \n const components = colorString.split(\",\")\n \n const result = {\n \"red\": Number(components[0]),\n \"green\": Number(components[1]),\n \"blue\": Number(components[2]),\n \"alpha\": Number(components[3])\n }\n \n return result\n \n }\n \n \n get colorDescriptor(): UIColorDescriptor {\n \n var descriptor\n \n const colorHEXFromName = UIColor.nameToHex(this.stringValue)\n \n if (this.stringValue.startsWith(\"rgb\")) {\n descriptor = UIColor.rgbToDescriptor(this.stringValue)\n }\n else if (colorHEXFromName) {\n descriptor = UIColor.hexToDescriptor(colorHEXFromName)\n }\n else {\n descriptor = UIColor.hexToDescriptor(this.stringValue)\n }\n \n return descriptor\n \n }\n \n \n colorWithRed(red: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithGreen(green: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithBlue(blue: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithAlpha(alpha: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + alpha + \")\"\n )\n \n }\n \n static colorWithRGBA(red: number, green: number, blue: number, alpha: number = 1) {\n \n const result = new UIColor(\"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha + \")\")\n \n return result\n \n }\n \n static colorWithDescriptor(descriptor: UIColorDescriptor) {\n \n const red = Math.min(255, Math.max(0, descriptor.red)).toFixed(0)\n const green = Math.min(255, Math.max(0, descriptor.green)).toFixed(0)\n const blue = Math.min(255, Math.max(0, descriptor.blue)).toFixed(0)\n const alpha = this.defaultAlphaToOne(descriptor.alpha)\n \n return new UIColor(\"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha + \")\")\n \n }\n \n \n private static defaultAlphaToOne(value = 1) {\n if (value != value) {\n value = 1\n }\n return value\n }\n \n \n colorByMultiplyingRGB(multiplier: number) {\n \n const descriptor = this.colorDescriptor\n \n descriptor.red = descriptor.red * multiplier\n descriptor.green = descriptor.green * multiplier\n descriptor.blue = descriptor.blue * multiplier\n \n return UIColor.colorWithDescriptor(descriptor)\n \n }\n \n \n /**\n * Returns the perceptual lightness (L*) of this color in the range [0, 1],\n * using the CIELAB formula. 0 = absolute black, 1 = absolute white.\n * Unlike raw relative luminance, this scale is perceptually uniform \u2014\n * 0.5 is the genuine visual midpoint between black and white.\n */\n get perceivedLightness(): number {\n \n const descriptor = this.colorDescriptor\n \n const linearise = (channel: number) => {\n const normalised = channel / 255\n if (normalised <= 0.04045) {\n return normalised / 12.92\n }\n return Math.pow((normalised + 0.055) / 1.055, 2.4)\n }\n \n const luminance = 0.2126 * linearise(descriptor.red)\n + 0.7152 * linearise(descriptor.green)\n + 0.0722 * linearise(descriptor.blue)\n \n const epsilon = Math.pow(6 / 29, 3) // ~0.00886\n \n const f = luminance > epsilon\n ? Math.pow(luminance, 1 / 3)\n : (Math.pow(29 / 6, 2) / 3) * luminance + 4 / 29\n \n return (116 * f - 16) / 100\n \n }\n \n get isLight(): boolean {\n return this.perceivedLightness >= 0.5\n }\n \n \n}\n\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAgBlB,MAAM,WAAN,cAAsB,yBAAS;AAAA,EAmBlC,YAAY,aAAqB,aAAkC;AAE/D,UAAM;AAEN,SAAK,cAAc;AACnB,SAAK,cAAc;AACnB,QAAI,aAAa;AACb,WAAK,iBAAiB,KAAK;AAAA,IAC/B;AAAA,EAEJ;AAAA,EAGS,WAAW;AAChB,WAAO,KAAK;AAAA,EAChB;AAAA,EAWA,QAAQ;AA7DZ;AA+DQ,QAAI,CAAC,KAAK,aAAa;AAAE;AAAA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AAAA,IAC9F;AAAA,EAEJ;AAAA,EAEA,eAAe,OAAe;AAE1B,UAAM,aAAa,KAAK;AAExB,WAAO,IAAI;AAAA,MACP,UAAU,WAAW,MAAM,MAAM,QAAQ,MAAM,WAAW,OAAO,MAAM,WAAW,QAAQ;AAAA,IAC9F;AAAA,EAEJ;AAAA,EAEA,cAAc,MAAc;AAExB,UAAM,aAAa,KAAK;AAExB,WAAO,IAAI;AAAA,MACP,UAAU,WAAW,MAAM,MAAM,WAAW,QAAQ,MAAM,OAAO,MAAM,WAAW,QAAQ;AAAA,IAC9F;AAAA,EAEJ;AAAA,EAEA,eAAe,OAAe;AAE1B,UAAM,aAAa,KAAK;AAExB,WAAO,IAAI;AAAA,MACP,UAAU,WAAW,MAAM,MAAM,WAAW,QAAQ,MAAM,WAAW,OAAO,MAAM,QAAQ;AAAA,IAC9F;AAAA,EAEJ;AAAA,EAEA,OAAO,cAAc,KAAa,OAAe,MAAc,QAAgB,GAAG;AAE9E,UAAM,SAAS,IAAI,SAAQ,UAAU,MAAM,MAAM,QAAQ,MAAM,OAAO,MAAM,QAAQ,GAAG;AAEvF,WAAO;AAAA,EAEX;AAAA,EAEA,OAAO,oBAAoB,YAA+B;AAEtD,UAAM,MAAM,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,WAAW,GAAG,CAAC,EAAE,QAAQ,CAAC;AAChE,UAAM,QAAQ,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,WAAW,KAAK,CAAC,EAAE,QAAQ,CAAC;AACpE,UAAM,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,WAAW,IAAI,CAAC,EAAE,QAAQ,CAAC;AAClE,UAAM,QAAQ,KAAK,
|
|
4
|
+
"sourcesContent": ["import { UIObject } from \"./UIObject\"\n\n\nexport interface UIColorDescriptor {\n \n red: number;\n green: number;\n blue: number;\n alpha?: number;\n \n}\n\n\nexport type UIColorSemanticKey = string\n\n\nexport class UIColor extends UIObject {\n \n \n // --- Semantic color registry ---\n \n static _liveColors: WeakRef<UIColor>[] = []\n static _registrationMap = new Map<string, UIColor>()\n static _cssSubscriptions = new Map<UIColorSemanticKey, Set<() => void>>()\n \n \n // --- Instance fields ---\n \n stringValue: string\n semanticKey?: UIColorSemanticKey\n _semanticClass?: typeof UIColor\n _elementRef?: HTMLElement\n _styleProperty?: string\n \n \n constructor(stringValue: string, semanticKey?: UIColorSemanticKey) {\n \n super()\n \n this.stringValue = stringValue\n this.semanticKey = semanticKey\n if (semanticKey) {\n this._semanticClass = this.constructor as typeof UIColor\n }\n \n }\n \n \n override toString() {\n return this.stringValue\n }\n \n \n // --- Semantic apply ---\n \n /**\n * Re-resolves this instance's stringValue from its class's static getter\n * matching the semanticKey, then writes the new value directly to the DOM\n * via the stored element reference and style property.\n * No-op if this instance has no semanticKey.\n */\n apply() {\n \n if (!this.semanticKey) { return }\n \n const colorClass = this._semanticClass ?? this.constructor as typeof UIColor\n const newColor = (colorClass as any)[this.semanticKey] as UIColor | undefined\n \n if (!newColor) { return }\n \n this.stringValue = newColor.stringValue\n \n const element = this._elementRef\n \n if (!element || !this._styleProperty) { return }\n \n (element.style as any)[this._styleProperty] = this.stringValue\n \n }\n \n \n /**\n * Assigns a semantic key and the class that owns it to this color instance.\n * Intended for derived colors that should participate in theme switching,\n * e.g. `BSColor._primaryBase.colorWithAlpha(0.5).withSemanticKey(\"primaryShadow\", BSColor)`.\n * Returns `this` for fluent chaining.\n */\n withSemanticKey(semanticKey: UIColorSemanticKey, semanticClass: typeof UIColor): this {\n this.semanticKey = semanticKey\n this._semanticClass = semanticClass\n return this\n }\n \n \n /**\n * Iterates all live registered UIColor instances, calls apply() on each,\n * compacts dead WeakRefs in the same pass, then fires any CSS subscriptions\n * whose semantic key was affected.\n */\n static applySemanticColors() {\n \n const affectedKeys = new Set<UIColorSemanticKey>()\n \n const live: WeakRef<UIColor>[] = []\n \n for (const ref of UIColor._liveColors) {\n \n const color = ref.deref()\n \n if (!color) {\n continue\n }\n \n live.push(ref)\n \n if (color.semanticKey) {\n affectedKeys.add(color.semanticKey)\n }\n \n color.apply()\n \n }\n \n UIColor._liveColors = live\n \n for (const key of affectedKeys) {\n UIColor._cssSubscriptions.get(key)?.forEach(callback => callback())\n }\n \n }\n \n \n /**\n * Updates the backing field for a semantic color and re-applies all live\n * semantic colors. The backing field is always `_` + semanticKey, e.g.\n * `BSColor.updateSemanticColor(\"primary\", \"#ff0000\")` sets `BSColor._primary`.\n * Called as a static method on the subclass that owns the color.\n */\n static updateSemanticColor(semanticKey: UIColorSemanticKey, value: string) {\n (this as any)[\"_\" + semanticKey] = value\n UIColor.applySemanticColors()\n }\n \n \n /**\n * Registers a callback to be fired when applySemanticColors() affects\n * the given semantic key. Intended for injected CSS blocks that cannot\n * be tracked via the colorStyleProxy.\n */\n static subscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n \n if (!UIColor._cssSubscriptions.has(semanticKey)) {\n UIColor._cssSubscriptions.set(semanticKey, new Set())\n }\n \n UIColor._cssSubscriptions.get(semanticKey)!.add(callback)\n \n }\n \n \n static unsubscribe(semanticKey: UIColorSemanticKey, callback: () => void) {\n UIColor._cssSubscriptions.get(semanticKey)?.delete(callback)\n }\n \n \n // --- Named colors ---\n \n static get redColor() {\n return new UIColor(\"red\")\n }\n \n static get blueColor() {\n return new UIColor(\"blue\")\n }\n \n static get greenColor() {\n return new UIColor(\"green\")\n }\n \n static get yellowColor() {\n return new UIColor(\"yellow\")\n }\n \n static get blackColor() {\n return new UIColor(\"black\")\n }\n \n static get brownColor() {\n return new UIColor(\"brown\")\n }\n \n static get whiteColor() {\n return new UIColor(\"white\")\n }\n \n static get greyColor() {\n return new UIColor(\"grey\")\n }\n \n static get lightGreyColor() {\n return new UIColor(\"lightgrey\")\n }\n \n static get transparentColor() {\n return new UIColor(\"transparent\")\n }\n \n static get clearColor() {\n return new UIColor(\"transparent\")\n }\n \n static get undefinedColor() {\n return new UIColor(\"\")\n }\n \n static get nilColor() {\n return new UIColor(\"\")\n }\n \n \n static nameToHex(name: string) {\n return {\n \"aliceblue\": \"#f0f8ff\",\n \"antiquewhite\": \"#faebd7\",\n \"aqua\": \"#00ffff\",\n \"aquamarine\": \"#7fffd4\",\n \"azure\": \"#f0ffff\",\n \"beige\": \"#f5f5dc\",\n \"bisque\": \"#ffe4c4\",\n \"black\": \"#000000\",\n \"blanchedalmond\": \"#ffebcd\",\n \"blue\": \"#0000ff\",\n \"blueviolet\": \"#8a2be2\",\n \"brown\": \"#a52a2a\",\n \"burlywood\": \"#deb887\",\n \"cadetblue\": \"#5f9ea0\",\n \"chartreuse\": \"#7fff00\",\n \"chocolate\": \"#d2691e\",\n \"coral\": \"#ff7f50\",\n \"cornflowerblue\": \"#6495ed\",\n \"cornsilk\": \"#fff8dc\",\n \"crimson\": \"#dc143c\",\n \"cyan\": \"#00ffff\",\n \"darkblue\": \"#00008b\",\n \"darkcyan\": \"#008b8b\",\n \"darkgoldenrod\": \"#b8860b\",\n \"darkgray\": \"#a9a9a9\",\n \"darkgreen\": \"#006400\",\n \"darkkhaki\": \"#bdb76b\",\n \"darkmagenta\": \"#8b008b\",\n \"darkolivegreen\": \"#556b2f\",\n \"darkorange\": \"#ff8c00\",\n \"darkorchid\": \"#9932cc\",\n \"darkred\": \"#8b0000\",\n \"darksalmon\": \"#e9967a\",\n \"darkseagreen\": \"#8fbc8f\",\n \"darkslateblue\": \"#483d8b\",\n \"darkslategray\": \"#2f4f4f\",\n \"darkturquoise\": \"#00ced1\",\n \"darkviolet\": \"#9400d3\",\n \"deeppink\": \"#ff1493\",\n \"deepskyblue\": \"#00bfff\",\n \"dimgray\": \"#696969\",\n \"dodgerblue\": \"#1e90ff\",\n \"firebrick\": \"#b22222\",\n \"floralwhite\": \"#fffaf0\",\n \"forestgreen\": \"#228b22\",\n \"fuchsia\": \"#ff00ff\",\n \"gainsboro\": \"#dcdcdc\",\n \"ghostwhite\": \"#f8f8ff\",\n \"gold\": \"#ffd700\",\n \"goldenrod\": \"#daa520\",\n \"gray\": \"#808080\",\n \"green\": \"#008000\",\n \"greenyellow\": \"#adff2f\",\n \"honeydew\": \"#f0fff0\",\n \"hotpink\": \"#ff69b4\",\n \"indianred \": \"#cd5c5c\",\n \"indigo\": \"#4b0082\",\n \"ivory\": \"#fffff0\",\n \"khaki\": \"#f0e68c\",\n \"lavender\": \"#e6e6fa\",\n \"lavenderblush\": \"#fff0f5\",\n \"lawngreen\": \"#7cfc00\",\n \"lemonchiffon\": \"#fffacd\",\n \"lightblue\": \"#add8e6\",\n \"lightcoral\": \"#f08080\",\n \"lightcyan\": \"#e0ffff\",\n \"lightgoldenrodyellow\": \"#fafad2\",\n \"lightgrey\": \"#d3d3d3\",\n \"lightgreen\": \"#90ee90\",\n \"lightpink\": \"#ffb6c1\",\n \"lightsalmon\": \"#ffa07a\",\n \"lightseagreen\": \"#20b2aa\",\n \"lightskyblue\": \"#87cefa\",\n \"lightslategray\": \"#778899\",\n \"lightsteelblue\": \"#b0c4de\",\n \"lightyellow\": \"#ffffe0\",\n \"lime\": \"#00ff00\",\n \"limegreen\": \"#32cd32\",\n \"linen\": \"#faf0e6\",\n \"magenta\": \"#ff00ff\",\n \"maroon\": \"#800000\",\n \"mediumaquamarine\": \"#66cdaa\",\n \"mediumblue\": \"#0000cd\",\n \"mediumorchid\": \"#ba55d3\",\n \"mediumpurple\": \"#9370d8\",\n \"mediumseagreen\": \"#3cb371\",\n \"mediumslateblue\": \"#7b68ee\",\n \"mediumspringgreen\": \"#00fa9a\",\n \"mediumturquoise\": \"#48d1cc\",\n \"mediumvioletred\": \"#c71585\",\n \"midnightblue\": \"#191970\",\n \"mintcream\": \"#f5fffa\",\n \"mistyrose\": \"#ffe4e1\",\n \"moccasin\": \"#ffe4b5\",\n \"navajowhite\": \"#ffdead\",\n \"navy\": \"#000080\",\n \"oldlace\": \"#fdf5e6\",\n \"olive\": \"#808000\",\n \"olivedrab\": \"#6b8e23\",\n \"orange\": \"#ffa500\",\n \"orangered\": \"#ff4500\",\n \"orchid\": \"#da70d6\",\n \"palegoldenrod\": \"#eee8aa\",\n \"palegreen\": \"#98fb98\",\n \"paleturquoise\": \"#afeeee\",\n \"palevioletred\": \"#d87093\",\n \"papayawhip\": \"#ffefd5\",\n \"peachpuff\": \"#ffdab9\",\n \"peru\": \"#cd853f\",\n \"pink\": \"#ffc0cb\",\n \"plum\": \"#dda0dd\",\n \"powderblue\": \"#b0e0e6\",\n \"purple\": \"#800080\",\n \"red\": \"#ff0000\",\n \"rosybrown\": \"#bc8f8f\",\n \"royalblue\": \"#4169e1\",\n \"saddlebrown\": \"#8b4513\",\n \"salmon\": \"#fa8072\",\n \"sandybrown\": \"#f4a460\",\n \"seagreen\": \"#2e8b57\",\n \"seashell\": \"#fff5ee\",\n \"sienna\": \"#a0522d\",\n \"silver\": \"#c0c0c0\",\n \"skyblue\": \"#87ceeb\",\n \"slateblue\": \"#6a5acd\",\n \"slategray\": \"#708090\",\n \"snow\": \"#fffafa\",\n \"springgreen\": \"#00ff7f\",\n \"steelblue\": \"#4682b4\",\n \"tan\": \"#d2b48c\",\n \"teal\": \"#008080\",\n \"thistle\": \"#d8bfd8\",\n \"tomato\": \"#ff6347\",\n \"turquoise\": \"#40e0d0\",\n \"violet\": \"#ee82ee\",\n \"wheat\": \"#f5deb3\",\n \"white\": \"#ffffff\",\n \"whitesmoke\": \"#f5f5f5\",\n \"yellow\": \"#ffff00\",\n \"yellowgreen\": \"#9acd32\"\n }[name.toLowerCase()]\n }\n \n \n static hexToDescriptor(c: string): UIColorDescriptor {\n if (c[0] === \"#\") {\n c = c.substr(1)\n }\n const r = parseInt(c.slice(0, 2), 16)\n const g = parseInt(c.slice(2, 4), 16)\n const b = parseInt(c.slice(4, 6), 16)\n const a = parseInt(c.slice(6, 8), 16)\n \n const result = { \"red\": r, \"green\": g, \"blue\": b, \"alpha\": a }\n \n return result\n \n }\n \n static rgbToDescriptor(colorString: string) {\n \n if (colorString.startsWith(\"rgba(\")) {\n colorString = colorString.slice(5, colorString.length - 1)\n }\n \n if (colorString.startsWith(\"rgb(\")) {\n colorString = colorString.slice(4, colorString.length - 1) + \", 0\"\n }\n \n const components = colorString.split(\",\")\n \n const result = {\n \"red\": Number(components[0]),\n \"green\": Number(components[1]),\n \"blue\": Number(components[2]),\n \"alpha\": Number(components[3])\n }\n \n return result\n \n }\n \n \n get colorDescriptor(): UIColorDescriptor {\n \n var descriptor\n \n const colorHEXFromName = UIColor.nameToHex(this.stringValue)\n \n if (this.stringValue.startsWith(\"rgb\")) {\n descriptor = UIColor.rgbToDescriptor(this.stringValue)\n }\n else if (colorHEXFromName) {\n descriptor = UIColor.hexToDescriptor(colorHEXFromName)\n }\n else {\n descriptor = UIColor.hexToDescriptor(this.stringValue)\n }\n \n return descriptor\n \n }\n \n \n colorWithRed(red: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithGreen(green: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + green + \",\" + descriptor.blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithBlue(blue: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + blue + \",\" + descriptor.alpha + \")\"\n )\n \n }\n \n colorWithAlpha(alpha: number) {\n \n const descriptor = this.colorDescriptor\n \n return new UIColor(\n \"rgba(\" + descriptor.red + \",\" + descriptor.green + \",\" + descriptor.blue + \",\" + alpha + \")\"\n )\n \n }\n \n static colorWithRGBA(red: number, green: number, blue: number, alpha: number = 1) {\n \n const result = new UIColor(\"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha + \")\")\n \n return result\n \n }\n \n static colorWithDescriptor(descriptor: UIColorDescriptor) {\n \n const red = Math.min(255, Math.max(0, descriptor.red)).toFixed(0)\n const green = Math.min(255, Math.max(0, descriptor.green)).toFixed(0)\n const blue = Math.min(255, Math.max(0, descriptor.blue)).toFixed(0)\n const alpha = this.alphaDefaultingToOne(descriptor.alpha)\n \n return new UIColor(\"rgba(\" + red + \",\" + green + \",\" + blue + \",\" + alpha + \")\")\n \n }\n \n \n private static alphaDefaultingToOne(value = 1) {\n if (value != value) {\n value = 1\n }\n return value\n }\n \n \n colorByMultiplyingRGB(multiplier: number) {\n \n const descriptor = this.colorDescriptor\n \n descriptor.red = descriptor.red * multiplier\n descriptor.green = descriptor.green * multiplier\n descriptor.blue = descriptor.blue * multiplier\n \n return UIColor.colorWithDescriptor(descriptor)\n \n }\n \n \n /**\n * Returns the perceptual lightness (L*) of this color in the range [0, 1],\n * using the CIELAB formula. 0 = absolute black, 1 = absolute white.\n * Unlike raw relative luminance, this scale is perceptually uniform \u2014\n * 0.5 is the genuine visual midpoint between black and white.\n */\n get perceivedLightness(): number {\n \n const descriptor = this.colorDescriptor\n \n const linearise = (channel: number) => {\n const normalised = channel / 255\n if (normalised <= 0.04045) {\n return normalised / 12.92\n }\n return Math.pow((normalised + 0.055) / 1.055, 2.4)\n }\n \n const luminance = 0.2126 * linearise(descriptor.red)\n + 0.7152 * linearise(descriptor.green)\n + 0.0722 * linearise(descriptor.blue)\n \n const epsilon = Math.pow(6 / 29, 3) // ~0.00886\n \n const f = luminance > epsilon\n ? Math.pow(luminance, 1 / 3)\n : (Math.pow(29 / 6, 2) / 3) * luminance + 4 / 29\n \n return (116 * f - 16) / 100\n \n }\n \n get isLight(): boolean {\n return this.perceivedLightness >= 0.5\n }\n \n \n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAyB;AAgBlB,MAAM,WAAN,cAAsB,yBAAS;AAAA,EAmBlC,YAAY,aAAqB,aAAkC;AAE/D,UAAM;AAEN,SAAK,cAAc;AACnB,SAAK,cAAc;AACnB,QAAI,aAAa;AACb,WAAK,iBAAiB,KAAK;AAAA,I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null) => void): void;
|
|
19
19
|
static dataURLWithMaxSize(URLString: string, maxSize: number, completion: (resultURLString: string) => void): void;
|
|
20
20
|
static dataURLWithSizes(URLString: string, height: number, width: number, completion: (resultURLString: string) => void): void;
|
|
21
|
-
|
|
21
|
+
dataURLWithHeightAndWidth(height?: number, width?: number): string;
|
|
22
22
|
get imageSource(): string;
|
|
23
23
|
set imageSource(sourceString: string);
|
|
24
|
-
|
|
24
|
+
applyLocalizedImageSourceForKey(key: string, defaultSource: string): void;
|
|
25
25
|
didReceiveBroadcastEvent(event: UIViewBroadcastEvent): void;
|
|
26
26
|
willMoveToSuperview(superview: UIView): void;
|
|
27
|
-
|
|
27
|
+
_applyLocalizedImageSourceIfPossible(): void;
|
|
28
28
|
get fillMode(): any;
|
|
29
29
|
set fillMode(fillMode: any);
|
|
30
30
|
get hiddenWhenEmpty(): boolean;
|
|
@@ -66,7 +66,7 @@ const _UIImageView = class extends import_UIView.UIView {
|
|
|
66
66
|
const originalSize = imageView.intrinsicContentSize();
|
|
67
67
|
let multiplier = maxSize / Math.max(originalSize.height, originalSize.width);
|
|
68
68
|
multiplier = Math.min(1, multiplier);
|
|
69
|
-
const result = imageView.
|
|
69
|
+
const result = imageView.dataURLWithHeightAndWidth((originalSize.height * multiplier).integerValue, (originalSize.width * multiplier).integerValue);
|
|
70
70
|
completion(result);
|
|
71
71
|
};
|
|
72
72
|
}
|
|
@@ -74,11 +74,11 @@ const _UIImageView = class extends import_UIView.UIView {
|
|
|
74
74
|
const imageView = new _UIImageView();
|
|
75
75
|
imageView.imageSource = URLString;
|
|
76
76
|
imageView.viewHTMLElement.onload = () => {
|
|
77
|
-
const result = imageView.
|
|
77
|
+
const result = imageView.dataURLWithHeightAndWidth(height, width);
|
|
78
78
|
completion(result);
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
dataURLWithHeightAndWidth(height, width) {
|
|
82
82
|
const img = this.viewHTMLElement;
|
|
83
83
|
const canvas = document.createElement("canvas");
|
|
84
84
|
canvas.width = width != null ? width : img.naturalWidth;
|
|
@@ -109,23 +109,23 @@ const _UIImageView = class extends import_UIView.UIView {
|
|
|
109
109
|
return (_a = this.superview) == null ? void 0 : _a.setNeedsLayout();
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
applyLocalizedImageSourceForKey(key, defaultSource) {
|
|
113
113
|
const languageName = import_UICore.UICore.languageService.currentLanguageKey;
|
|
114
|
-
this.imageSource = import_UICore.UICore.languageService.stringForKey(key, languageName,
|
|
114
|
+
this.imageSource = import_UICore.UICore.languageService.stringForKey(key, languageName, defaultSource, void 0);
|
|
115
115
|
}
|
|
116
116
|
didReceiveBroadcastEvent(event) {
|
|
117
117
|
super.didReceiveBroadcastEvent(event);
|
|
118
118
|
if (event.name == import_UIView.UIView.broadcastEventName.LanguageChanged || event.name == import_UIView.UIView.broadcastEventName.AddedToViewTree) {
|
|
119
|
-
this.
|
|
119
|
+
this._applyLocalizedImageSourceIfPossible();
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
willMoveToSuperview(superview) {
|
|
123
123
|
super.willMoveToSuperview(superview);
|
|
124
|
-
this.
|
|
124
|
+
this._applyLocalizedImageSourceIfPossible();
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
_applyLocalizedImageSourceIfPossible() {
|
|
127
127
|
if (this._sourceKey && this._defaultSource) {
|
|
128
|
-
this.
|
|
128
|
+
this.applyLocalizedImageSourceForKey(this._sourceKey, this._defaultSource);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
get fillMode() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UIImageView.ts"],
|
|
4
|
-
"sourcesContent": ["import { UICore } from \"./UICore\"\nimport { IS_NOT, NO, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIImageView extends UIView {\n \n \n //actionIndicator: UIActionIndicator;\n _sourceKey?: string\n _defaultSource?: string\n \n _fillMode: any\n \n _hiddenWhenEmpty = NO\n \n \n constructor(elementID?: string, viewHTMLElement = null) {\n \n super(elementID, viewHTMLElement, \"img\")\n \n \n //this.actionIndicator = new UIActionIndicator(elementID + \"ActionIndicator\");\n \n \n }\n \n \n static fillMode = {\n \n \"stretchToFill\": \"fill\",\n \"aspectFit\": \"contain\",\n \"aspectFill\": \"cover\",\n \"center\": \"none\",\n \"aspectFitIfLarger\": \"scale-down\"\n \n }\n \n \n override get viewHTMLElement() {\n \n return super.viewHTMLElement as HTMLImageElement\n \n }\n \n \n static objectURLFromDataURL(dataURL: string) {\n // @ts-ignore\n const blob = dataURLtoBlob(dataURL)\n return URL.createObjectURL(blob)\n }\n \n \n static dataURL(url: string | URL, callback: (arg0: string | ArrayBuffer | null) => void) {\n const xhr = new XMLHttpRequest()\n xhr.open(\"get\", url)\n xhr.responseType = \"blob\"\n xhr.onload = function () {\n const fr = new FileReader()\n \n fr.onload = function () {\n callback(this.result)\n }\n \n fr.readAsDataURL(xhr.response) // async call\n }\n \n xhr.send()\n }\n \n \n static dataURLWithMaxSize(URLString: string, maxSize: number, completion: (resultURLString: string) => void) {\n \n const imageView = new UIImageView()\n imageView.imageSource = URLString\n \n imageView.viewHTMLElement.onload = () => {\n \n const originalSize = imageView.intrinsicContentSize()\n \n let multiplier = maxSize / Math.max(originalSize.height, originalSize.width)\n multiplier = Math.min(1, multiplier)\n \n const result = imageView.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,sBAAgC;AAChC,yBAA4B;AAC5B,oBAA6C;AAGtC,MAAM,eAAN,cAA0B,qBAAO;AAAA,EAYpC,YAAY,WAAoB,kBAAkB,MAAM;AAEpD,UAAM,WAAW,iBAAiB,KAAK;AAL3C,4BAAmB;
|
|
4
|
+
"sourcesContent": ["import { UICore } from \"./UICore\"\nimport { IS_NOT, NO, YES } from \"./UIObject\"\nimport { UIRectangle } from \"./UIRectangle\"\nimport { UIView, UIViewBroadcastEvent } from \"./UIView\"\n\n\nexport class UIImageView extends UIView {\n \n \n //actionIndicator: UIActionIndicator;\n _sourceKey?: string\n _defaultSource?: string\n \n _fillMode: any\n \n _hiddenWhenEmpty = NO\n \n \n constructor(elementID?: string, viewHTMLElement = null) {\n \n super(elementID, viewHTMLElement, \"img\")\n \n \n //this.actionIndicator = new UIActionIndicator(elementID + \"ActionIndicator\");\n \n \n }\n \n \n static fillMode = {\n \n \"stretchToFill\": \"fill\",\n \"aspectFit\": \"contain\",\n \"aspectFill\": \"cover\",\n \"center\": \"none\",\n \"aspectFitIfLarger\": \"scale-down\"\n \n }\n \n \n override get viewHTMLElement() {\n \n return super.viewHTMLElement as HTMLImageElement\n \n }\n \n \n static objectURLFromDataURL(dataURL: string) {\n // @ts-ignore\n const blob = dataURLtoBlob(dataURL)\n return URL.createObjectURL(blob)\n }\n \n \n static dataURL(url: string | URL, callback: (arg0: string | ArrayBuffer | null) => void) {\n const xhr = new XMLHttpRequest()\n xhr.open(\"get\", url)\n xhr.responseType = \"blob\"\n xhr.onload = function () {\n const fr = new FileReader()\n \n fr.onload = function () {\n callback(this.result)\n }\n \n fr.readAsDataURL(xhr.response) // async call\n }\n \n xhr.send()\n }\n \n \n static dataURLWithMaxSize(URLString: string, maxSize: number, completion: (resultURLString: string) => void) {\n \n const imageView = new UIImageView()\n imageView.imageSource = URLString\n \n imageView.viewHTMLElement.onload = () => {\n \n const originalSize = imageView.intrinsicContentSize()\n \n let multiplier = maxSize / Math.max(originalSize.height, originalSize.width)\n multiplier = Math.min(1, multiplier)\n \n const result = imageView.dataURLWithHeightAndWidth((originalSize.height * multiplier).integerValue, (originalSize.width *\n multiplier).integerValue)\n \n completion(result)\n \n }\n \n }\n \n \n static dataURLWithSizes(\n URLString: string,\n height: number,\n width: number,\n completion: (resultURLString: string) => void\n ) {\n \n const imageView = new UIImageView()\n imageView.imageSource = URLString\n \n imageView.viewHTMLElement.onload = () => {\n \n const result = imageView.dataURLWithHeightAndWidth(height, width)\n completion(result)\n \n }\n \n }\n \n \n dataURLWithHeightAndWidth(height?: number, width?: number) {\n \n const img = this.viewHTMLElement\n \n // Create an empty canvas element\n const canvas: HTMLCanvasElement = document.createElement(\"canvas\")\n canvas.width = width ?? img.naturalWidth\n canvas.height = height ?? img.naturalHeight\n \n // Copy the image contents to the canvas\n const ctx = canvas.getContext(\"2d\") as CanvasRenderingContext2D\n ctx.drawImage(img, 0, 0, width ?? img.naturalWidth, height ?? img.naturalHeight)\n \n // Get the data-URL formatted image\n // Firefox supports PNG and JPEG. You could check img.src to\n // guess the original format, but be aware the using \"image/jpg\"\n // will re-encode the image.\n return canvas.toDataURL(\"image/png\")\n \n }\n \n get imageSource() {\n \n return this.viewHTMLElement.src\n \n }\n \n set imageSource(sourceString: string) {\n \n if (IS_NOT(sourceString)) {\n sourceString = \"\"\n }\n \n this.viewHTMLElement.src = sourceString\n \n if (this.hiddenWhenEmpty) {\n this.hidden = IS_NOT(this.imageSource)\n }\n \n if (!sourceString || !sourceString.length) {\n \n //this.actionIndicator.stop();\n this.hidden = YES\n \n return\n \n }\n else {\n \n this.hidden = NO\n \n }\n \n // this.superview.addSubview(this.actionIndicator);\n // this.actionIndicator.frame = this.frame;\n // this.actionIndicator.start();\n // this.actionIndicator.backgroundColor = UIColor.redColor\n \n // @ts-ignore\n this.viewHTMLElement.onload = () => this.superview?.setNeedsLayout()\n \n }\n \n \n applyLocalizedImageSourceForKey(key: string, defaultSource: string) {\n \n const languageName = UICore.languageService.currentLanguageKey\n this.imageSource = UICore.languageService.stringForKey(key, languageName, defaultSource, undefined)\n \n }\n \n \n override didReceiveBroadcastEvent(event: UIViewBroadcastEvent) {\n \n super.didReceiveBroadcastEvent(event)\n \n if (event.name == UIView.broadcastEventName.LanguageChanged || event.name ==\n UIView.broadcastEventName.AddedToViewTree) {\n \n this._applyLocalizedImageSourceIfPossible()\n \n }\n \n }\n \n \n override willMoveToSuperview(superview: UIView) {\n \n super.willMoveToSuperview(superview)\n \n this._applyLocalizedImageSourceIfPossible()\n \n }\n \n _applyLocalizedImageSourceIfPossible() {\n \n if (this._sourceKey && this._defaultSource) {\n \n this.applyLocalizedImageSourceForKey(this._sourceKey, this._defaultSource)\n \n }\n \n }\n \n \n get fillMode() {\n return this._fillMode\n }\n \n set fillMode(fillMode) {\n \n this._fillMode = fillMode;\n (this.style as any).objectFit = fillMode\n \n }\n \n \n get hiddenWhenEmpty() {\n return this._hiddenWhenEmpty\n }\n \n set hiddenWhenEmpty(hiddenWhenEmpty: boolean) {\n this._hiddenWhenEmpty = hiddenWhenEmpty\n if (hiddenWhenEmpty) {\n this.hidden = IS_NOT(this.imageSource)\n }\n }\n \n \n override didMoveToSuperview(superview: UIView) {\n \n super.didMoveToSuperview(superview)\n \n \n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n \n }\n \n \n override intrinsicContentSize = () => {\n \n \n return new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight, this.viewHTMLElement.naturalWidth)\n \n \n }\n \n override intrinsicContentSizeWithConstraints = (constrainingHeight = 0, constrainingWidth = 0) => {\n \n const heightRatio = constrainingHeight / this.viewHTMLElement.naturalHeight\n \n const widthRatio = constrainingWidth / this.viewHTMLElement.naturalWidth\n \n const multiplier = Math.max(heightRatio, widthRatio)\n \n return new UIRectangle(0, 0, this.viewHTMLElement.naturalHeight *\n multiplier, this.viewHTMLElement.naturalWidth * multiplier)\n \n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,sBAAgC;AAChC,yBAA4B;AAC5B,oBAA6C;AAGtC,MAAM,eAAN,cAA0B,qBAAO;AAAA,EAYpC,YAAY,WAAoB,kBAAkB,MAAM;AAEp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AAS;AAAA,EAEtG;AAAA,EAGS,yBAAyB,OAA6B;AAE3D,UAAM,yBAAyB,KAAK;AAEpC,QAAI,MAAM,QAAQ,qBAAO,mBAAmB,mBAAmB,MAAM,QACjE,qBAAO,mBAAmB,iBAAiB;AAE3C,WAAK,qCAAqC;AAAA,IAE9C;AAAA,EAEJ;AAAA,EAGS,oBAAoB,WAAmB;AAE5C,UAAM,oBAAoB,SAAS;AAEnC,SAAK,qCAAqC;AAAA,EAE9C;AAAA,EAEA,uCAAuC;AAEnC,QAAI,KAAK,cAAc,KAAK,gBAAgB;AAExC,WAAK,gCAAgC,KAAK,YAAY,KAAK,cAAc;AAAA,IAE7E;AAAA,EAEJ;AAAA,EAGA,IAAI,WAAW;AACX,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,SAAS,UAAU;AAEnB,SAAK,YAAY;AACjB,IAAC,KAAK,MAAc,YAAY;AAAA,EAEpC;AAAA,EAGA,IAAI,kBAAkB;AAClB,WAAO,KAAK;AAAA,EAChB;AAAA,EAEA,IAAI,gBAAgB,iBAA0B;AAC1C,SAAK,mBAAmB;AACxB,QAAI,iBAAiB;AACjB,WAAK,aAAS,wBAAO,KAAK,WAAW;AAAA,IACzC;AAAA,EACJ;AAAA,EAGS,mBAAmB,WAAmB;AAE3C,UAAM,mBAAmB,SAAS;AAAA,EAGtC;AAAA,EAGS,iBAAiB;AAEtB,UAAM,eAAe;AAAA,EAGzB;AA0BJ;AApRO,IAAM,cAAN;AAAM,YAuBF,WAAW;AAAA,EAEd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,UAAU;AAAA,EACV,qBAAqB;AAEzB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -14,8 +14,8 @@ export declare class UILoadingView extends UIView implements IUILoadingView {
|
|
|
14
14
|
get theme(): "light" | "dark";
|
|
15
15
|
constructor(elementID?: string);
|
|
16
16
|
initViewStyleSelectors(): void;
|
|
17
|
-
private
|
|
17
|
+
private applyCurrentThemeColors;
|
|
18
18
|
layoutSubviews(): void;
|
|
19
|
-
private
|
|
20
|
-
private
|
|
19
|
+
private enterPulsingMode;
|
|
20
|
+
private enterIndicatorMode;
|
|
21
21
|
}
|
|
@@ -40,7 +40,7 @@ class UILoadingView extends import_UIView.UIView {
|
|
|
40
40
|
style: { height: "100%", width: "100%" }
|
|
41
41
|
});
|
|
42
42
|
this.initViewStyleSelectors();
|
|
43
|
-
this.
|
|
43
|
+
this.applyCurrentThemeColors();
|
|
44
44
|
}
|
|
45
45
|
set loading(loading) {
|
|
46
46
|
}
|
|
@@ -49,7 +49,7 @@ class UILoadingView extends import_UIView.UIView {
|
|
|
49
49
|
}
|
|
50
50
|
set theme(theme) {
|
|
51
51
|
this._theme = theme;
|
|
52
|
-
this.
|
|
52
|
+
this.applyCurrentThemeColors();
|
|
53
53
|
}
|
|
54
54
|
get theme() {
|
|
55
55
|
return this._theme;
|
|
@@ -86,7 +86,7 @@ class UILoadingView extends import_UIView.UIView {
|
|
|
86
86
|
box-sizing: border-box;
|
|
87
87
|
`);
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
applyCurrentThemeColors() {
|
|
90
90
|
const isLightTheme = this._theme === "light";
|
|
91
91
|
const overlayColor = isLightTheme ? new import_UIColor.UIColor("rgba(255, 255, 255, 0.7)") : new import_UIColor.UIColor("rgba(0, 0, 0, 0.5)");
|
|
92
92
|
const spinnerColor = isLightTheme ? new import_UIColor.UIColor("#343a40") : new import_UIColor.UIColor("#f8f9fa");
|
|
@@ -108,12 +108,12 @@ class UILoadingView extends import_UIView.UIView {
|
|
|
108
108
|
const bounds = this.bounds;
|
|
109
109
|
const minDimension = Math.min(bounds.width, bounds.height);
|
|
110
110
|
if (minDimension < 40) {
|
|
111
|
-
this.
|
|
111
|
+
this.enterPulsingMode();
|
|
112
112
|
} else {
|
|
113
|
-
this.
|
|
113
|
+
this.enterIndicatorMode();
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
enterPulsingMode() {
|
|
117
117
|
if (this.isPulsing) {
|
|
118
118
|
return;
|
|
119
119
|
}
|
|
@@ -122,11 +122,11 @@ class UILoadingView extends import_UIView.UIView {
|
|
|
122
122
|
this.style.backgroundColor = "";
|
|
123
123
|
this.isPulsing = import_UIObject.YES;
|
|
124
124
|
}
|
|
125
|
-
|
|
125
|
+
enterIndicatorMode() {
|
|
126
126
|
this.removeStyleClass("UILoadingViewPulsing");
|
|
127
127
|
this.isPulsing = import_UIObject.NO;
|
|
128
128
|
this.spinnerView.hidden = import_UIObject.NO;
|
|
129
|
-
this.
|
|
129
|
+
this.applyCurrentThemeColors();
|
|
130
130
|
const spinnerSize = 32;
|
|
131
131
|
const borderWidth = 4;
|
|
132
132
|
const bounds = this.bounds;
|