uicore-ts 1.1.262 → 1.1.302
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 +2 -1
- package/compiledScripts/UIBaseButton.js +5 -2
- package/compiledScripts/UIBaseButton.js.map +2 -2
- package/compiledScripts/UILinkButton.js +1 -1
- package/compiledScripts/UILinkButton.js.map +2 -2
- package/package.json +1 -1
- package/scripts/UIBaseButton.ts +9 -4
- package/scripts/UILinkButton.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UIView, UIViewBroadcastEvent } from "./UIView";
|
|
1
|
+
import { UIView, UIViewAddControlEventTargetObject, UIViewBroadcastEvent } from "./UIView";
|
|
2
2
|
export declare class UIBaseButton extends UIView {
|
|
3
3
|
static controlEvent: {
|
|
4
4
|
readonly PointerDown: "PointerDown";
|
|
@@ -52,6 +52,7 @@ export declare class UIBaseButton extends UIView {
|
|
|
52
52
|
} & {
|
|
53
53
|
readonly PrimaryActionTriggered: "PrimaryActionTriggered";
|
|
54
54
|
};
|
|
55
|
+
get controlEventTargetAccumulator(): UIViewAddControlEventTargetObject<typeof UIBaseButton>;
|
|
55
56
|
_selected: boolean;
|
|
56
57
|
_highlighted: boolean;
|
|
57
58
|
_isPointerInside: boolean;
|
|
@@ -74,13 +74,13 @@ const _UIBaseButton = class extends import_UIView.UIView {
|
|
|
74
74
|
this.addTargetForControlEvent(import_UIView.UIView.controlEvent.EnterDown, () => {
|
|
75
75
|
setHighlighted();
|
|
76
76
|
setNotHighlightedWithMinimumDuration();
|
|
77
|
-
this.sendControlEventForKey(
|
|
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
81
|
setHighlighted();
|
|
82
82
|
setNotHighlightedWithMinimumDuration();
|
|
83
|
-
this.sendControlEventForKey(
|
|
83
|
+
this.sendControlEventForKey(import_UIView.UIView.controlEvent.PointerUpInside, import_UIObject.nil);
|
|
84
84
|
});
|
|
85
85
|
this.addTargetForControlEvent(
|
|
86
86
|
import_UIView.UIView.controlEvent.Focus,
|
|
@@ -107,6 +107,9 @@ const _UIBaseButton = class extends import_UIView.UIView {
|
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
+
get controlEventTargetAccumulator() {
|
|
111
|
+
return super.controlEventTargetAccumulator;
|
|
112
|
+
}
|
|
110
113
|
set hovered(hovered) {
|
|
111
114
|
this._hovered = hovered;
|
|
112
115
|
this.updateContentForCurrentState();
|
|
@@ -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, 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 \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 \u2014 fire PrimaryActionTriggered\n this.addTargetForControlEvent(UIView.controlEvent.EnterDown, () => {\n \n setHighlighted()\n setNotHighlightedWithMinimumDuration()\n this.sendControlEventForKey(UIBaseButton.controlEvent.PrimaryActionTriggered, nil)\n \n })\n \n this.addTargetForControlEvent(UIView.controlEvent.SpaceDown, (sender, event) => {\n \n event.preventDefault()\n setHighlighted()\n setNotHighlightedWithMinimumDuration()\n this.sendControlEventForKey(UIBaseButton.controlEvent.PrimaryActionTriggered, 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,
|
|
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,aAAa,MAAM;AACrB,WAAK,UAAU;AAAA,IACnB;AACA,SAAK,yBAAyB,qBAAO,aAAa,cAAc,UAAU;AAE1E,UAAM,gBAAgB,MAAM;AAExB,WAAK,UAAU;AAAA,IAEnB;AAEA,SAAK,0BAA0B;AAAA,MAC3B,qBAAO,aAAa;AAAA,MAAc,qBAAO,aAAa;AAAA,MAAe,qBAAO,aAAa;AAAA,IAC7F,GAAG,aAAa;AAGhB,QAAI;AACJ,UAAM,iBAAiB,MAAM;AACzB,WAAK,cAAc;AACnB,yBAAmB,KAAK,IAAI;AAAA,IAChC;AACA,SAAK,yBAAyB,qBAAO,aAAa,aAAa,cAAc;AAC7E,SAAK,yBAAyB,qBAAO,aAAa,cAAc,cAAc;AAE9E,UAAM,oBAAoB,MAAM;AAC5B,WAAK,cAAc;AAAA,IACvB;AACA,UAAM,uCAAuC,MAAM;AAC/C,YAAM,gCAAgC;AACtC,YAAM,cAAc,KAAK,IAAI,IAAI;AACj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M,wBAAwB,KAAK,8BAA8B,iBAAiB;AAClF,UAAM,uBAAuB,KAAK;AAAA,MAC9B,sBAAsB;AAAA,MACtB,sBAAsB;AAAA,MACtB;AAAA,IACJ;AACA,WAAO;AAAA,EACX;AAGJ;AAlbO,IAAM,eAAN;AAAM,aAEO,eAAe,OAAO,OAAO,CAAC,GAAG,qBAAO,cAAc;AAAA,EAClE,0BAA0B;AAC9B,CAAU;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -29,7 +29,7 @@ class UILinkButton extends import_UILink.UILink {
|
|
|
29
29
|
this.button = new import_UIButton.UIButton(this.elementID + "Button", elementType, titleType);
|
|
30
30
|
this.addSubview(this.button);
|
|
31
31
|
this.style.position = "absolute";
|
|
32
|
-
this.button.controlEventTargetAccumulator.
|
|
32
|
+
this.button.controlEventTargetAccumulator.PrimaryActionTriggered = () => window.location = this.target;
|
|
33
33
|
}
|
|
34
34
|
get titleLabel() {
|
|
35
35
|
return this.button.titleLabel;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../scripts/UILinkButton.ts"],
|
|
4
|
-
"sourcesContent": ["import { UIButton, UIButtonColorSpecifier } from \"./UIButton\"\nimport { UILink } from \"./UILink\"\n\n\nexport class UILinkButton extends UILink {\n \n button: UIButton\n \n constructor(elementID?: string, elementType?: string, titleType?: string) {\n \n super(elementID)\n \n // Instance variables\n this.button = new UIButton(this.elementID + \"Button\", elementType, titleType)\n this.addSubview(this.button)\n \n this.style.position = \"absolute\"\n this.button.controlEventTargetAccumulator.
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiD;AACjD,oBAAuB;AAGhB,MAAM,qBAAqB,qBAAO;AAAA,EAIrC,YAAY,WAAoB,aAAsB,WAAoB;AAEtE,UAAM,SAAS;AAGf,SAAK,SAAS,IAAI,yBAAS,KAAK,YAAY,UAAU,aAAa,SAAS;AAC5E,SAAK,WAAW,KAAK,MAAM;AAE3B,SAAK,MAAM,WAAW;AACtB,SAAK,OAAO,8BAA8B,
|
|
4
|
+
"sourcesContent": ["import { UIButton, UIButtonColorSpecifier } from \"./UIButton\"\nimport { UILink } from \"./UILink\"\n\n\nexport class UILinkButton extends UILink {\n \n button: UIButton\n \n constructor(elementID?: string, elementType?: string, titleType?: string) {\n \n super(elementID)\n \n // Instance variables\n this.button = new UIButton(this.elementID + \"Button\", elementType, titleType)\n this.addSubview(this.button)\n \n this.style.position = \"absolute\"\n this.button.controlEventTargetAccumulator.PrimaryActionTriggered = () => window.location = this.target as any\n \n }\n \n \n get titleLabel() {\n return this.button.titleLabel\n }\n \n get imageView() {\n return this.button.imageView\n }\n \n \n override set colors(colors: UIButtonColorSpecifier) {\n this.button.colors = colors\n }\n \n override get colors(): UIButtonColorSpecifier {\n return this.button.colors\n }\n \n \n override get viewHTMLElement() {\n return super.viewHTMLElement as HTMLLinkElement\n }\n \n \n override set target(target: string) {\n this.viewHTMLElement.setAttribute(\"href\", target)\n }\n \n override get target() {\n return this.viewHTMLElement.getAttribute(\"href\") ?? \"\"\n }\n \n \n override layoutSubviews() {\n \n super.layoutSubviews()\n \n const bounds = this.bounds\n \n this.button.frame = bounds\n this.button.layoutSubviews()\n \n }\n \n \n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\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,sBAAiD;AACjD,oBAAuB;AAGhB,MAAM,qBAAqB,qBAAO;AAAA,EAIrC,YAAY,WAAoB,aAAsB,WAAoB;AAEtE,UAAM,SAAS;AAGf,SAAK,SAAS,IAAI,yBAAS,KAAK,YAAY,UAAU,aAAa,SAAS;AAC5E,SAAK,WAAW,KAAK,MAAM;AAE3B,SAAK,MAAM,WAAW;AACtB,SAAK,OAAO,8BAA8B,yBAAyB,MAAM,OAAO,WAAW,KAAK;AAAA,EAEpG;AAAA,EAGA,IAAI,aAAa;AACb,WAAO,KAAK,OAAO;AAAA,EACvB;AAAA,EAEA,IAAI,YAAY;AACZ,WAAO,KAAK,OAAO;AAAA,EACvB;AAAA,EAGA,IAAa,OAAO,QAAgC;AAChD,SAAK,OAAO,SAAS;AAAA,EACzB;AAAA,EAEA,IAAa,SAAiC;AAC1C,WAAO,KAAK,OAAO;AAAA,EACvB;AAAA,EAGA,IAAa,kBAAkB;AAC3B,WAAO,MAAM;AAAA,EACjB;AAAA,EAGA,IAAa,OAAO,QAAgB;AAChC,SAAK,gBAAgB,aAAa,QAAQ,MAAM;AAAA,EACpD;AAAA,EAEA,IAAa,SAAS;AAjD1B;AAkDQ,YAAO,UAAK,gBAAgB,aAAa,MAAM,MAAxC,YAA6C;AAAA,EACxD;AAAA,EAGS,iBAAiB;AAEtB,UAAM,eAAe;AAErB,UAAM,SAAS,KAAK;AAEpB,SAAK,OAAO,QAAQ;AACpB,SAAK,OAAO,eAAe;AAAA,EAE/B;AAGJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uicore-ts",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.302",
|
|
4
4
|
"description": "UICore is a library to build native-like user interfaces using pure Typescript. No HTML is needed at all. Components are described as TS classes and all user interactions are handled explicitly. This library is strongly inspired by the UIKit framework that is used in IOS. In addition, UICore has tools to handle URL based routing, array sorting and filtering and adds a number of other utilities for convenience.",
|
|
5
5
|
"main": "compiledScripts/index.js",
|
|
6
6
|
"types": "compiledScripts/index.d.ts",
|
package/scripts/UIBaseButton.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UIColor } from "./UIColor"
|
|
2
2
|
import { IS, nil, NO, YES } from "./UIObject"
|
|
3
|
-
import { UIView, UIViewBroadcastEvent } from "./UIView"
|
|
3
|
+
import { UIView, UIViewAddControlEventTargetObject, UIViewBroadcastEvent } from "./UIView"
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
export class UIBaseButton extends UIView {
|
|
@@ -11,6 +11,10 @@ export class UIBaseButton extends UIView {
|
|
|
11
11
|
|
|
12
12
|
override controlEvent = UIBaseButton.controlEvent
|
|
13
13
|
|
|
14
|
+
override get controlEventTargetAccumulator(): UIViewAddControlEventTargetObject<typeof UIBaseButton> {
|
|
15
|
+
return super.controlEventTargetAccumulator as any
|
|
16
|
+
}
|
|
17
|
+
|
|
14
18
|
|
|
15
19
|
_selected: boolean = NO
|
|
16
20
|
_highlighted: boolean = NO
|
|
@@ -77,12 +81,13 @@ export class UIBaseButton extends UIView {
|
|
|
77
81
|
], setNotHighlighted)
|
|
78
82
|
this.addTargetForControlEvent(UIView.controlEvent.PointerUp, setNotHighlightedWithMinimumDuration)
|
|
79
83
|
|
|
80
|
-
// Enter and Space both activate the button
|
|
84
|
+
// Enter and Space both activate the button.
|
|
85
|
+
// Fire PointerUpInside (which cascades to PrimaryActionTriggered via sendControlEventForKey).
|
|
81
86
|
this.addTargetForControlEvent(UIView.controlEvent.EnterDown, () => {
|
|
82
87
|
|
|
83
88
|
setHighlighted()
|
|
84
89
|
setNotHighlightedWithMinimumDuration()
|
|
85
|
-
this.sendControlEventForKey(
|
|
90
|
+
this.sendControlEventForKey(UIView.controlEvent.PointerUpInside, nil)
|
|
86
91
|
|
|
87
92
|
})
|
|
88
93
|
|
|
@@ -91,7 +96,7 @@ export class UIBaseButton extends UIView {
|
|
|
91
96
|
event.preventDefault()
|
|
92
97
|
setHighlighted()
|
|
93
98
|
setNotHighlightedWithMinimumDuration()
|
|
94
|
-
this.sendControlEventForKey(
|
|
99
|
+
this.sendControlEventForKey(UIView.controlEvent.PointerUpInside, nil)
|
|
95
100
|
|
|
96
101
|
})
|
|
97
102
|
|
package/scripts/UILinkButton.ts
CHANGED
|
@@ -15,7 +15,7 @@ export class UILinkButton extends UILink {
|
|
|
15
15
|
this.addSubview(this.button)
|
|
16
16
|
|
|
17
17
|
this.style.position = "absolute"
|
|
18
|
-
this.button.controlEventTargetAccumulator.
|
|
18
|
+
this.button.controlEventTargetAccumulator.PrimaryActionTriggered = () => window.location = this.target as any
|
|
19
19
|
|
|
20
20
|
}
|
|
21
21
|
|