uicore-ts
Version:
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 tha
105 lines (104 loc) • 3.87 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var UITextField_exports = {};
__export(UITextField_exports, {
UITextField: () => UITextField
});
module.exports = __toCommonJS(UITextField_exports);
var import_UIColor = require("./UIColor");
var import_UICore = require("./UICore");
var import_UIObject = require("./UIObject");
var import_UITextView = require("./UITextView");
var import_UIView = require("./UIView");
const _UITextField = class extends import_UITextView.UITextView {
constructor(elementID, viewHTMLElement = null, type = import_UITextView.UITextView.type.textField) {
super(elementID, type, viewHTMLElement);
this.viewHTMLElement.setAttribute("type", "text");
this.backgroundColor = import_UIColor.UIColor.whiteColor;
this.addTargetForControlEvent(
import_UIView.UIView.controlEvent.PointerUpInside,
(sender, event) => sender.focus()
);
this.viewHTMLElement.oninput = (event) => {
this.sendControlEventForKey(_UITextField.controlEvent.TextChange, event);
};
this.style.webkitUserSelect = "text";
this.nativeSelectionEnabled = import_UIObject.YES;
this.pausesPointerEvents = import_UIObject.NO;
}
get controlEventTargetAccumulator() {
return super.controlEventTargetAccumulator;
}
get viewHTMLElement() {
return this._viewHTMLElement;
}
set text(text) {
this.viewHTMLElement.value = text;
}
get text() {
return this.viewHTMLElement.value;
}
set placeholderText(text) {
this.viewHTMLElement.placeholder = text;
}
get placeholderText() {
return this.viewHTMLElement.placeholder;
}
setPlaceholderText(key, defaultString) {
this._placeholderTextKey = key;
this._defaultPlaceholderText = defaultString;
const languageName = import_UICore.UICore.languageService.currentLanguageKey;
this.placeholderText = import_UICore.UICore.languageService.stringForKey(key, languageName, defaultString, import_UIObject.nil);
}
didReceiveBroadcastEvent(event) {
super.didReceiveBroadcastEvent(event);
if (event.name == import_UIView.UIView.broadcastEventName.LanguageChanged || event.name == import_UIView.UIView.broadcastEventName.AddedToViewTree) {
this._setPlaceholderFromKeyIfPossible();
}
}
willMoveToSuperview(superview) {
super.willMoveToSuperview(superview);
this._setPlaceholderFromKeyIfPossible();
}
_setPlaceholderFromKeyIfPossible() {
if (this._placeholderTextKey && this._defaultPlaceholderText) {
this.setPlaceholderText(this._placeholderTextKey, this._defaultPlaceholderText);
}
}
get isSecure() {
const result = this.viewHTMLElement.type == "password";
return result;
}
set isSecure(secure) {
var type = "text";
if (secure) {
type = "password";
}
this.viewHTMLElement.type = type;
}
};
let UITextField = _UITextField;
UITextField.controlEvent = Object.assign({}, import_UITextView.UITextView.controlEvent, {
"TextChange": "TextChange"
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
UITextField
});
//# sourceMappingURL=UITextField.js.map