Added minimal functionality for Robot teaching
- Added minimal HMI - Added possibility to open and close all chamber doors
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
import { AccordionItem } from './TcHmiAccordionItem.js';
|
||||
/**
|
||||
* How to use
|
||||
* HTML example
|
||||
<tchmi-accordion>
|
||||
<tchmi-accordion-item name="Item1" open>
|
||||
<tchmi-accordion-header>Header 1</tchmi-accordion-header>
|
||||
<tchmi-accordion-content">Content 1</tchmi-accordion-content>
|
||||
</tchmi-accordion-item>
|
||||
<tchmi-accordion-item name="Item2">
|
||||
<tchmi-accordion-header>Header 2</tchmi-accordion-header>
|
||||
<tchmi-accordion-content>Content 1</tchmi-accordion-content>
|
||||
</tchmi-accordion-item>
|
||||
<tchmi-accordion-item name="Item3">
|
||||
<tchmi-accordion-header>Header Only</tchmi-accordion-header>
|
||||
</tchmi-accordion-item>
|
||||
</tchmi-accordion>
|
||||
**/
|
||||
export declare class Accordion extends HTMLElement {
|
||||
/**
|
||||
* Map of all valid AccordionItems including content and header
|
||||
* Key is the name of the AccordionItem
|
||||
*/
|
||||
private __items;
|
||||
/** When set to true only one opened item per level is allowed */
|
||||
private __autoCollapse;
|
||||
/**
|
||||
* Contains all functions which are fired on item change.
|
||||
*/
|
||||
private __itemClickedCallbacks;
|
||||
/**
|
||||
* Contains all functions which are fired on item down is changed.
|
||||
*/
|
||||
private __itemDownChangedCallbacks;
|
||||
private __itemContentOpenedCallbacks;
|
||||
private __itemContentClosedCallbacks;
|
||||
constructor();
|
||||
/**
|
||||
* Is called when the element is connected to the DOM.
|
||||
*/
|
||||
connectedCallback(): void;
|
||||
/**
|
||||
* Is called when the element is disconnected from the DOM.
|
||||
*/
|
||||
disconnectedCallback(): void;
|
||||
/**
|
||||
* Adds an item to the accordion.
|
||||
*/
|
||||
addItem(name: string, header: HTMLElement, content?: HTMLElement): AccordionItem | null;
|
||||
/**
|
||||
* Removes an item from the accordion.
|
||||
*/
|
||||
removeItemByName(name: string): void;
|
||||
protected __headerClickedCallback(clickedItem: AccordionItem): void;
|
||||
protected __headerExpandedCallback(expandedItem: AccordionItem): void;
|
||||
protected __headerDownChangedCallback(changedItem: AccordionItem): void;
|
||||
protected __itemContentOpenedCallback(changedItem: AccordionItem): void;
|
||||
protected __itemContentClosedCallback(changedItem: AccordionItem): void;
|
||||
/**
|
||||
* Add callback, which is fired when an item is clicked.
|
||||
* @param cb Function which is fired when an item is clicked.
|
||||
*/
|
||||
addItemClickedCallback(cb: (item: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when an item is clicked.
|
||||
* @param cb Function which is fired when an item is clicked.
|
||||
*/
|
||||
removeItemClickedCallback(cb: (item: AccordionItem) => void): void;
|
||||
/**
|
||||
* Add callback, which is fired when the down class is added or removed from an item.
|
||||
* @param cb Function which is fired when the down class is added or removed from an item.
|
||||
*/
|
||||
addItemDownChangedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the down class is added or removed from an item.
|
||||
* @param cb Function which is fired when the down class is added or removed from an item.
|
||||
*/
|
||||
removeItemDownChangedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Add callback, which is fired when the content is opened.
|
||||
* @param cb Function which is fired when the content is opened.
|
||||
*/
|
||||
addItemContentOpenedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the content is opened.
|
||||
* @param cb Function which is fired when the content is opened.
|
||||
*/
|
||||
removeItemContentOpenedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Add callback, which is fired when the content is closed.
|
||||
* @param cb Function which is fired when the content is closed.
|
||||
*/
|
||||
addItemContentClosedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the content is closed.
|
||||
* @param cb Function which is fired when the content is closed.
|
||||
*/
|
||||
removeItemContentClosedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Function to set the auto collapse value.
|
||||
*/
|
||||
setAutoCollapse(value: boolean): void;
|
||||
/**
|
||||
* Returns the current auto collapse value
|
||||
* @returns
|
||||
*/
|
||||
getAutoCollapse(): boolean;
|
||||
/**
|
||||
* Returns the items of the accordion.
|
||||
*/
|
||||
getItems(): Map<string, AccordionItem>;
|
||||
/**
|
||||
* Returns a specific item by its name.
|
||||
*/
|
||||
getItemByName(name: string): AccordionItem | undefined;
|
||||
}
|
||||
declare const _Accordion: typeof Accordion;
|
||||
type tAccordion = Accordion;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers.TcHmiAccordion {
|
||||
let Accordion: typeof _Accordion;
|
||||
type Accordion = tAccordion;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=TcHmiAccordion.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,164 @@
|
||||
export declare class AccordionItem extends HTMLElement {
|
||||
#private;
|
||||
private __name?;
|
||||
private __header?;
|
||||
private __content?;
|
||||
private __disabled;
|
||||
private __isOpen;
|
||||
private __expanderElement;
|
||||
/** Defines if an open item is closed on a normal click */
|
||||
private __closeWhenClicked;
|
||||
private __destroyOnDisconnect;
|
||||
private __headerDestroyFunctions;
|
||||
private __pointerUpDestroyer;
|
||||
private __headerPointerLeaveDestroyer;
|
||||
private __headerPointerEnterDestroyer;
|
||||
private __expanderPointerLeaveDestroyer;
|
||||
private __expanderPointerEnterDestroyer;
|
||||
/**
|
||||
* Contains all functions which are fired on item change.
|
||||
*/
|
||||
private __headerClickedCallbacks;
|
||||
private __headerDownChangedCallbacks;
|
||||
private __headerExpandedCallbacks;
|
||||
private __contentOpenedCallbacks;
|
||||
private __contentClosedCallbacks;
|
||||
constructor();
|
||||
/**
|
||||
* Is called when the element is connected to the DOM.
|
||||
*/
|
||||
connectedCallback(): void;
|
||||
/**
|
||||
* Is called when the element is disconnected from the DOM.
|
||||
*/
|
||||
disconnectedCallback(): void;
|
||||
/**
|
||||
* Callback function for a click on the header.
|
||||
*/
|
||||
protected __onHeaderClick(): void;
|
||||
/**
|
||||
* Callback function for a click on the expander.
|
||||
*/
|
||||
protected __onExpanderClick(event: Event): void;
|
||||
/**
|
||||
* Disables or enables the item.
|
||||
*/
|
||||
disable(disable: boolean): void;
|
||||
/**
|
||||
* Returns true if the element is disabled.
|
||||
*/
|
||||
isDisabled(): boolean;
|
||||
/**
|
||||
* Function to set a header element.
|
||||
*/
|
||||
setHeader(header: HTMLElement | undefined): void;
|
||||
/**
|
||||
* Return the current header element.
|
||||
*/
|
||||
getHeader(): HTMLElement | undefined;
|
||||
/**
|
||||
* Function to set the content element.
|
||||
*/
|
||||
setContent(content: HTMLElement | undefined): void;
|
||||
/**
|
||||
* Returns the content element.
|
||||
*/
|
||||
getContent(): HTMLElement | undefined;
|
||||
/**
|
||||
* Function to set the name of the item.
|
||||
*/
|
||||
setName(name: string): void;
|
||||
/**
|
||||
* Returns the name of the Item.
|
||||
*/
|
||||
getName(): string | undefined;
|
||||
/**
|
||||
* Opens or closes the content of the item.
|
||||
*/
|
||||
protected __changeState(): void;
|
||||
/**
|
||||
* Opens the item.
|
||||
* @param animationList A list of animation functions. Store the animations of parent elements on a recuresive use of the function. Can be set to "null" if the animation should be skipped.
|
||||
*/
|
||||
open(animationList?: (() => void)[] | null): void;
|
||||
/**
|
||||
* Closes the element and its child elements.
|
||||
*/
|
||||
close(): void;
|
||||
/**
|
||||
* Returns the if the element is opened.
|
||||
*/
|
||||
IsOpen(): boolean;
|
||||
/**
|
||||
* Defines if an open item is closed on a normal click.
|
||||
*/
|
||||
setCloseWhenClicked(valueNew: boolean): void;
|
||||
getCloseWhenClicked(): boolean;
|
||||
/**
|
||||
* Add callback, which is fired when the header is clicked.
|
||||
* @param cb Function which is fired when the header is clicked.
|
||||
*/
|
||||
addHeaderClickedCallback(cb: (clickedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the header is clicked.
|
||||
* @param cb Function which is fired when the header is clicked.
|
||||
*/
|
||||
removeHeaderClickedCallback(cb: (clickedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Add callback, which is fired when the down class is added or removed from the header.
|
||||
* @param cb Function which is fired when the down class is added or removed from the header.
|
||||
*/
|
||||
addHeaderDownChangedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the down class is added or removed from the header.
|
||||
* @param cb Function which is fired when the down class is added or removed from the header.
|
||||
*/
|
||||
removeHeaderDownChangedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Add callback, which is fired when the header is expanded.
|
||||
* @param cb Function which is fired when the header is expanded.
|
||||
*/
|
||||
addHeaderExpandedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the header is expanded.
|
||||
* @param cb Function which is fired when the header is expanded.
|
||||
*/
|
||||
removeHeaderExpandedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Add callback, which is fired when the content is opened.
|
||||
* @param cb Function which is fired when the content is opened.
|
||||
*/
|
||||
addContentOpenedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the content is opened.
|
||||
* @param cb Function which is fired when the content is opened.
|
||||
*/
|
||||
removeContentOpenedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Add callback, which is fired when the content is closed.
|
||||
* @param cb Function which is fired when the content is closed.
|
||||
*/
|
||||
addContentClosedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired when the content is closed.
|
||||
* @param cb Function which is fired when the content is closed.
|
||||
*/
|
||||
removeContentClosedCallback(cb: (changedItem: AccordionItem) => void): void;
|
||||
protected __onPointerUp(): void;
|
||||
protected __onPointerDown(): void;
|
||||
protected __onPointerLeave(): void;
|
||||
protected __onPointerEnter(): void;
|
||||
protected __onExpanderPointerDown(): void;
|
||||
protected __onExpanderPointerLeave(): void;
|
||||
protected __onExpanderPointerEnter(): void;
|
||||
}
|
||||
declare const _AccordionItem: typeof AccordionItem;
|
||||
type tAccordionItem = AccordionItem;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers.TcHmiAccordion {
|
||||
let AccordionItem: typeof _AccordionItem;
|
||||
type AccordionItem = tAccordionItem;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=TcHmiAccordionItem.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,45 @@
|
||||
import type { TcHmiControl } from 'Beckhoff.TwinCAT.HMI.Framework/index.esm.js';
|
||||
import { Banner } from './Banner.js';
|
||||
import type { Control as TcHmiButton } from '../../TcHmiButton/TcHmiButton.esm.js';
|
||||
import type { Control as TcHmiCheckbox } from '../../TcHmiCheckbox/TcHmiCheckbox.esm.js';
|
||||
export declare class ApprovalBanner extends Banner {
|
||||
protected readonly __parentControl?: (TcHmiControl.Control | null) | undefined;
|
||||
protected __approveButton: TcHmiButton;
|
||||
protected __repetitionCheckbox: TcHmiCheckbox;
|
||||
protected __storage: TcHmi.LocalStorage<{
|
||||
dontShowAgain: boolean;
|
||||
}> | undefined;
|
||||
/**
|
||||
* Creates a new Banner instance.
|
||||
* @param targetElement The element the banner is placed over.
|
||||
* @param storageId The storage id to rember if the banner should not be displayed anymore
|
||||
* @param __parentControl The control which owns the Banner.
|
||||
*/
|
||||
constructor(targetElement: HTMLElement, storageId: string | null, __parentControl?: (TcHmiControl.Control | null) | undefined);
|
||||
show(): void;
|
||||
/**
|
||||
* Handler for the onPressed event of the OK button.
|
||||
*/
|
||||
protected __onApproved(): void;
|
||||
/**
|
||||
* Sets texts which can either be localizable or static.
|
||||
*/
|
||||
setTexts(texts: Partial<ApprovalBanner.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ApprovalBanner {
|
||||
interface LocalizableTexts extends Banner.LocalizableTexts {
|
||||
buttonText: TcHmi.Localizable;
|
||||
checkboxText: TcHmi.Localizable;
|
||||
}
|
||||
}
|
||||
import _ApprovalBanner = ApprovalBanner;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ApprovalBanner: typeof _ApprovalBanner;
|
||||
type ApprovalBanner = _ApprovalBanner;
|
||||
namespace ApprovalBanner {
|
||||
type LocalizableTexts = _ApprovalBanner.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ApprovalBanner.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,77 @@
|
||||
export declare class Banner {
|
||||
#private;
|
||||
protected readonly __parentControl?: (TcHmi.Controls.System.TcHmiControl | null) | undefined;
|
||||
protected __name: string;
|
||||
protected __targetElement: HTMLElement;
|
||||
protected __element: HTMLDivElement;
|
||||
protected __elementHeaderContainer: HTMLDivElement;
|
||||
protected __elementHeader: HTMLHeadingElement;
|
||||
protected __elementContent: HTMLDivElement;
|
||||
protected __elementFooter: HTMLDivElement;
|
||||
/** Controls in this array will be destroyed automatically when the popup is destroyed */
|
||||
protected __childControls: TcHmi.Controls.System.TcHmiControl[];
|
||||
/** Destroyers in this array will be called automatically when the popup is destroyed */
|
||||
protected __destroyers: TcHmi.DestroyFunction[];
|
||||
protected __isShowing: boolean;
|
||||
protected __localizationSymbols: Map<string, {
|
||||
symbol: TcHmi.Symbol<string>;
|
||||
destroyWatch: TcHmi.DestroyFunction;
|
||||
}>;
|
||||
protected readonly __className = "TcHmi_Controls_Helpers_Banner";
|
||||
/**
|
||||
* Creates a new Banner instance.
|
||||
* @param targetElement The element the banner is placed over.
|
||||
* @param __parentControl The control which owns the Banner.
|
||||
*/
|
||||
constructor(targetElement: HTMLElement, __parentControl?: (TcHmi.Controls.System.TcHmiControl | null) | undefined);
|
||||
/**
|
||||
* Gets a value indicating if the banner is currently shown to the user.
|
||||
*/
|
||||
isShowing(): boolean;
|
||||
/**
|
||||
* Shows the banner.
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* Hides the banner.
|
||||
*/
|
||||
hide(): void;
|
||||
/**
|
||||
* Destroys the banner and all its controls.
|
||||
* @param force If true, child controls will be removed from the parent control before destruction, to ensure destruction in case of keepAlive === true.
|
||||
*/
|
||||
destroy(force?: boolean): void;
|
||||
/**
|
||||
* Watch the given symbol and call the onChange callback every time it changes with the resolved and formatted symbol value.
|
||||
* @param name The name for this symbol. Must be unique across all inheritance layers and further calls for the same localization must use the same name.
|
||||
* @param localization The localization to watch.
|
||||
* @param onChange The callback that is called with the localized and formatted text as a parameter.
|
||||
*/
|
||||
protected __watchLocalization(name: string, localization: TcHmi.FormattedLocalizable, onChange: (localizedText: string) => void): void;
|
||||
/**
|
||||
* Destroys the localization watch with the given name, if it exists.
|
||||
* @param name The name that was used with __watchLoclalization to start watching the symbol.
|
||||
*/
|
||||
protected __unwatchLocalization(name: string): void;
|
||||
/**
|
||||
* Sets texts which can either be localizable or static.
|
||||
*/
|
||||
setTexts(texts: Partial<Banner.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace Banner {
|
||||
interface LocalizableTexts {
|
||||
headerText: TcHmi.Localizable;
|
||||
contentText: TcHmi.Localizable;
|
||||
}
|
||||
}
|
||||
import _Banner = Banner;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let Banner: typeof _Banner;
|
||||
type Banner = _Banner;
|
||||
namespace Banner {
|
||||
type LocalizableTexts = _Banner.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Banner.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
export class Banner{__parentControl;static#tchmiFQN="TcHmi.Controls.Helpers."+this.name;__name;__targetElement;__element;__elementHeaderContainer;__elementHeader;__elementContent;__elementFooter;__childControls=[];__destroyers=[];__isShowing=!1;__localizationSymbols=new Map;__className="TcHmi_Controls_Helpers_Banner";constructor(targetElement,__parentControl){this.__parentControl=__parentControl,this.__name=`${this.constructor.name}-${tchmi_create_guid()}`,this.__parentControl&&(this.__name=`${this.__parentControl.getId()}.${this.__name}`),this.__targetElement=targetElement;const controlClass=this.__parentControl?.getType().replace(/\./g,"_");this.__element=document.createElement("div"),this.__element.classList.add(this.__className,`${this.__className}-${this.constructor.name}`),controlClass&&this.__element.classList.add(`${controlClass}-banner`),this.__elementHeaderContainer=document.createElement("div"),this.__elementHeaderContainer.classList.add(`${this.__className}-header-container`),this.__elementHeader=document.createElement("h1"),this.__elementHeaderContainer.appendChild(this.__elementHeader),this.__element.appendChild(this.__elementHeaderContainer),this.__elementContent=document.createElement("div"),this.__elementContent.classList.add(`${this.__className}-content`),this.__element.appendChild(this.__elementContent),this.__elementFooter=document.createElement("div"),this.__elementFooter.classList.add(`${this.__className}-footer`),this.__element.appendChild(this.__elementFooter),this.__parentControl&&this.__destroyers.push(TcHmi.EventProvider.register(this.__parentControl.getId()+".onDestroyed",()=>{this.destroy()}))}isShowing(){return this.__isShowing}show(){this.__isShowing||(this.__isShowing=!0,this.__targetElement.appendChild(this.__element))}hide(){this.__isShowing&&(this.__isShowing=!1,this.__element.remove())}destroy(force=!1){for(const destroy of this.__destroyers)destroy();this.__destroyers=[];for(const control of this.__childControls)force&&this.__parentControl&&this.__parentControl.__removeChild(control),control.destroy();this.__childControls=[];for(const entry of this.__localizationSymbols.values())entry.destroyWatch(),entry.symbol.destroy();this.__localizationSymbols.clear()}__watchLocalization(name,localization,onChange){const existing=this.__localizationSymbols.get(name);existing?.destroyWatch(),existing?.symbol.destroy();const symbol=new TcHmi.Symbol(localization.symbolExpression),destroyWatch=symbol.watch(data=>{if(data.error!==TcHmi.Errors.NONE)return void TcHmi.Log.errorEx(`[Source=ControlHelpers, Module=${Banner.#tchmiFQN}${this.__parentControl?`, Id=${this.__parentControl.getId()}`:""}, TcHmi.SymbolExpression=${localization.symbolExpression}] `+TcHmi.Log.buildMessage(data.details));let text=data.value??"";localization.formatValues.length>0&&(text=tchmi_format_string(text,...localization.formatValues)),onChange(text)});this.__localizationSymbols.set(name,{symbol,destroyWatch})}__unwatchLocalization(name){const existing=this.__localizationSymbols.get(name);existing&&(existing.destroyWatch(),existing.symbol.destroy(),this.__localizationSymbols.delete(name))}setTexts(texts){void 0!==texts.headerText&&null!==texts.headerText&&("object"==typeof texts.headerText||TcHmi.Symbol.isSymbolExpression(texts.headerText)?this.__watchLocalization("headerText","string"==typeof texts.headerText?{symbolExpression:texts.headerText,formatValues:[]}:texts.headerText,text=>this.__elementHeader.textContent=text):(this.__unwatchLocalization("headerText"),this.__elementHeader.textContent=texts.headerText)),void 0!==texts.contentText&&null!==texts.contentText&&("object"==typeof texts.contentText||TcHmi.Symbol.isSymbolExpression(texts.contentText)?this.__watchLocalization("contentText","string"==typeof texts.contentText?{symbolExpression:texts.contentText,formatValues:[]}:texts.contentText,text=>this.__elementContent.textContent=text):(this.__unwatchLocalization("contentText"),this.__elementContent.textContent=texts.contentText))}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.Banner=Banner;
|
||||
@@ -0,0 +1,51 @@
|
||||
declare abstract class CallbackCollectionBase<C extends (...args: any[]) => any> {
|
||||
protected __callbacks: Set<C>;
|
||||
/**
|
||||
* Adds a callback.
|
||||
* @param callback The callback to add.
|
||||
*/
|
||||
add(callback: C): DestroyFunction;
|
||||
/**
|
||||
* Removes the callback.
|
||||
* @param callback The callback to remove.
|
||||
*/
|
||||
remove(callback: C): void;
|
||||
/**
|
||||
* Removes all callbacks.
|
||||
*/
|
||||
clear(): void;
|
||||
/**
|
||||
* Returns a frozen object containig the add and remove methods. Useful for exposing these methods to the public
|
||||
* without also exposing the trigger method.
|
||||
*/
|
||||
getManipulators(): Readonly<{
|
||||
add: (callback: C) => DestroyFunction;
|
||||
remove: (callback: C) => void;
|
||||
}>;
|
||||
}
|
||||
/**
|
||||
* A collection of callbacks.
|
||||
*/
|
||||
export declare class CallbackCollection<C extends (...args: any[]) => any> extends CallbackCollectionBase<C> {
|
||||
/**
|
||||
* Calls all registered callbacks with the provided arguments.
|
||||
* @param args The parametes for the callback invocations.
|
||||
*/
|
||||
trigger(...args: Parameters<C>): PromiseSettledResult<ReturnType<C>>[];
|
||||
}
|
||||
/**
|
||||
* A collection of asynchronous callbacks.
|
||||
*/
|
||||
export declare class AsyncCallbackCollection<C extends (...args: any[]) => Promise<any>> extends CallbackCollectionBase<C> {
|
||||
/**
|
||||
* Calls all registered callbacks with the provided arguments.
|
||||
* @param args The parametes for the callback invocations.
|
||||
*/
|
||||
trigger(...args: Parameters<C>): Promise<PromiseSettledResult<Awaited<ReturnType<C>>>[]>;
|
||||
}
|
||||
/**
|
||||
* A function that removes the callback from the collection when called.
|
||||
*/
|
||||
type DestroyFunction = () => void;
|
||||
export {};
|
||||
//# sourceMappingURL=CallbackCollection.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
class CallbackCollectionBase{__callbacks=new Set;add(callback){return this.__callbacks.add(callback),()=>this.remove(callback)}remove(callback){this.__callbacks.delete(callback)}clear(){this.__callbacks.clear()}getManipulators(){return Object.freeze({add:this.add.bind(this),remove:this.remove.bind(this)})}}export class CallbackCollection extends CallbackCollectionBase{trigger(...args){const result=[];for(const callback of this.__callbacks)try{result.push({status:"fulfilled",value:callback(...args)})}catch(error){result.push({status:"rejected",reason:error})}return result}}export class AsyncCallbackCollection extends CallbackCollectionBase{trigger(...args){let promises=[];for(const callback of this.__callbacks)try{promises.push(callback(...args))}catch(error){promises.push(Promise.reject(error instanceof Error?error:new Error("string"==typeof error?error:void 0)))}return Promise.allSettled(promises)}}
|
||||
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* How to use
|
||||
* HTML example
|
||||
<tchmi-content-tabs>
|
||||
<tchmi-tab-links>
|
||||
<tchmi-tab-link active ref="Tab2">Header 2</tchmi-tab-link>
|
||||
<tchmi-tab-link ref="Tab1">Header 1</tchmi-tab-link>
|
||||
</tchmi-tab-links>
|
||||
<tchmi-tab-contents>
|
||||
<tchmi-tab-content name="Tab1">Content 1</tchmi-tab-content>
|
||||
<tchmi-tab-content active name="Tab2">Content 2</tchmi-tab-content>
|
||||
<tchmi-tab-content name="Unused"></tchmi-tab-content>
|
||||
</tchmi-tab-contents>
|
||||
</tchmi-content-tabs>
|
||||
**/
|
||||
export declare class ContentTabs extends HTMLElement {
|
||||
#private;
|
||||
constructor();
|
||||
connectedCallback(): void;
|
||||
disconnectedCallback(): void;
|
||||
/**
|
||||
* Add ContentTab.
|
||||
* @param name Name of ContentTab to add.
|
||||
* @param link HTMLElement to click on to open the content of the tab.
|
||||
* @param content HTMLElement which is shown when tab is active.
|
||||
*/
|
||||
addContentTab(name: string, link: HTMLElement, content: HTMLElement): void;
|
||||
/**
|
||||
* Arrange displayed tabs and the tab link overflow element.
|
||||
*/
|
||||
arrangeTabLinks(): void;
|
||||
/**
|
||||
* Remove ContentTab.
|
||||
* @param name Name of ContentTab to remove.
|
||||
*/
|
||||
removeContentTab(name: string): void;
|
||||
/**
|
||||
* Opens a tab by its name.
|
||||
* @param nameOfTabToOpen Name of tab which should be opened. If no tab name is specified, the active tab is selected. If this is also not known, the first tab is opened.
|
||||
*/
|
||||
openTab(nameOfTabToOpen?: string): void;
|
||||
/**
|
||||
* Show dropdown element in top most layer
|
||||
*/
|
||||
private __openDropdown;
|
||||
/**
|
||||
* Resize the dropdown element
|
||||
*/
|
||||
private __resizeDropdown;
|
||||
/**
|
||||
* Get tab by name.
|
||||
* @param tabName name of tab which should be returned.
|
||||
**/
|
||||
getTab(tabName: string): _ContentTabs.Tab | undefined;
|
||||
/**
|
||||
* Returns name of active tab.
|
||||
*/
|
||||
get activeTab(): string | undefined;
|
||||
/**
|
||||
* Enable a tab. Tab is enabled by default.
|
||||
* @param tabName name of tab which should be enabled.
|
||||
**/
|
||||
enableTab(tabName: string): void;
|
||||
/**
|
||||
* Disable a tab. Tab is enabled by default.
|
||||
* @param tabName name of tab which should be disabled.
|
||||
**/
|
||||
disableTab(tabName: string): void;
|
||||
/**
|
||||
* Disables the content tabs element.
|
||||
*/
|
||||
disableContentTabs(): void;
|
||||
/**
|
||||
* Enables the content tabs element.
|
||||
*/
|
||||
enableContentTabs(): void;
|
||||
/**
|
||||
* Add the attribute 'use-max-content' to the TabContentsWrapper
|
||||
* to prevent the size of the container from jumping back and forth
|
||||
* => content container always assumes the size of the largest content
|
||||
*/
|
||||
useMaxContent(): void;
|
||||
/**
|
||||
* Remove the attribute 'use-max-content' from the TabContentsWrapper
|
||||
* that prevent the size of the container from jumping back and forth
|
||||
* => this means that the content container only ever has the size of the visible content
|
||||
**/
|
||||
doNotUseMaxContent(): void;
|
||||
/**
|
||||
* Add callback, which is fired on tab change.
|
||||
* @param cb Function which is fired on tab change. Parameter contains the name of the new tab.
|
||||
*/
|
||||
addTabChangeCallback(cb: (newTabName: string) => void): void;
|
||||
/**
|
||||
* Remove callback, which is fired on tab change.
|
||||
* @param cb Function which is fired on tab change. Parameter contains the name of the new tab.
|
||||
*/
|
||||
removeTabChangeCallback(cb: (newTabName: string) => void): void;
|
||||
/**
|
||||
* Set the alignment of the tabs.
|
||||
* @param tabAlignment the new alignment of the tabs.
|
||||
*/
|
||||
setTabAlignment(tabAlignment: ContentTabs.TabAlignment): void;
|
||||
private __getTabLinksWrapper;
|
||||
private __getTabContentsWrapper;
|
||||
private __appendTabLinksOverflowElement;
|
||||
private __removeTabLinksOverflowElement;
|
||||
private __updateLinksAndContents;
|
||||
/**
|
||||
* Add openTab event on all tchmi-tab-link.
|
||||
*/
|
||||
private __addEvents;
|
||||
/**
|
||||
* Remove openTab event on all tchmi-tab-link.
|
||||
*/
|
||||
private __removeEvents;
|
||||
/**
|
||||
* Finds the first active tab, marks all other tabs as inactive and
|
||||
* synchronizes the active attribute between link and content.
|
||||
*/
|
||||
private __findActiveTab;
|
||||
/**
|
||||
* Sets the tabOverflowMode value.
|
||||
* @param valueNew The new value for tabOverflowMode.
|
||||
*/
|
||||
setTabOverflowMode(valueNew: ContentTabs.TabOverflowMode): void;
|
||||
/**
|
||||
* Processes the tab overflow mode.
|
||||
*/
|
||||
private __processTabOverflowMode;
|
||||
/**
|
||||
* Event handler for scroll events on the tab links wrapper.
|
||||
*/
|
||||
private __onScroll;
|
||||
/**
|
||||
* Enables or disables the scroll elements based on the current scroll position.
|
||||
* @returns {void}
|
||||
*/
|
||||
private __enableOrDisableScrollElements;
|
||||
/**
|
||||
* Event handler for scrolling the tab links wrapper to the right.
|
||||
*/
|
||||
private __onScrollElementRight;
|
||||
/**
|
||||
* Event handler for scrolling the tab links wrapper to the left.
|
||||
*/
|
||||
private __onScrollElementLeft;
|
||||
/**
|
||||
* Event handler for the wheel event on the tab links wrapper.
|
||||
* This allows horizontal scrolling using vertical wheel movements.
|
||||
* @param e The WheelEvent object.
|
||||
*/
|
||||
private __onWheel;
|
||||
/**
|
||||
* Creates a scroll element for the tab links.
|
||||
* @param direction The direction of the scroll element, either 'left' or 'right'.
|
||||
* @returns The SVG element representing the scroll arrow.
|
||||
*/
|
||||
private __createTabLinkScrollElement;
|
||||
/** Returns true if container is scrolled all the way left (or empty)
|
||||
* @param tolerance Optional tolerance in pixels to consider the left edge as "scrolled to left"
|
||||
* @returns {boolean} True if the container is scrolled to the left edge, false otherwise.
|
||||
*/
|
||||
private __isScrolledToLeftByRects;
|
||||
/** Returns true if container is scrolled all the way right (or empty)
|
||||
* @param tolerance Optional tolerance in pixels to consider the right edge as "scrolled to right"
|
||||
* @returns {boolean} True if the container is scrolled to the right edge, false otherwise.
|
||||
*/
|
||||
private __isScrolledToRightByRects;
|
||||
/**
|
||||
* Map of all valid Tabs including content and link
|
||||
* Key is the name of the tab
|
||||
*/
|
||||
private __tabs;
|
||||
private __activeTab?;
|
||||
/**
|
||||
* The elements that are used to scroll the tab links left or right.
|
||||
*/
|
||||
private __scrollElementLeft;
|
||||
private __scrollElementRight;
|
||||
private __resizeObserver;
|
||||
/**
|
||||
* The element that contains the tab links that are hidden due to less space.
|
||||
*/
|
||||
private __tabLinksOverflowElement;
|
||||
/**
|
||||
* The element that contains the tab links that are hidden due to less space.
|
||||
*/
|
||||
private __tabLinkDropdown;
|
||||
private __tabAlignment;
|
||||
/** The overflow mode of the tabs */
|
||||
protected __tabOverflowMode: ContentTabs.TabOverflowMode;
|
||||
/**
|
||||
* Contains all functions which are fired on tab change.
|
||||
*/
|
||||
private __tabChangeCallbacks;
|
||||
}
|
||||
export declare namespace ContentTabs {
|
||||
interface Tab {
|
||||
link: HTMLElement;
|
||||
content: HTMLElement;
|
||||
openTabHandler: () => void;
|
||||
disabled: boolean;
|
||||
dropdown: boolean;
|
||||
}
|
||||
type TabAlignment = 'Top' | 'Right' | 'Bottom' | 'Left';
|
||||
type TabOverflowMode = 'Popup' | 'Scroll';
|
||||
}
|
||||
import _ContentTabs = ContentTabs;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ContentTabs: typeof _ContentTabs;
|
||||
type ContentTabs = _ContentTabs;
|
||||
namespace ContentTabs {
|
||||
type Tab = _ContentTabs.Tab;
|
||||
type TabAlignment = _ContentTabs.TabAlignment;
|
||||
type TabOverflowMode = _ContentTabs.TabOverflowMode;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,167 @@
|
||||
import { DirectoryBrowser } from './DirectoryBrowser.js';
|
||||
/**
|
||||
* The data model for a directory and the current path and selected item.
|
||||
*/
|
||||
export declare class Directory<TFile, TFolder> {
|
||||
private __root;
|
||||
private __path;
|
||||
private __currentItem;
|
||||
private __selectedItems;
|
||||
private __navigationToFilesAllowed;
|
||||
private __multiSelectAllowed;
|
||||
private __onBeforePathChangeManager;
|
||||
/** Event handlers that are called before the path is changed. If the cancelable parameter is true, returning false from one of the handlers will cancel the path change. */
|
||||
onBeforePathChange: Readonly<{
|
||||
add: (callback: (newCurrentItem: DirectoryBrowser.Item<TFile, TFolder>, newPath: string[], cancelable: boolean) => Promise<boolean>) => () => void;
|
||||
remove: (callback: (newCurrentItem: DirectoryBrowser.Item<TFile, TFolder>, newPath: string[], cancelable: boolean) => Promise<boolean>) => void;
|
||||
}>;
|
||||
private __onBeforeSelectionChangeManager;
|
||||
/** Event handlers that are called before the selection is changed. If the cancelable parameter is true, returning false from one of the handlers will cancel the selection change. */
|
||||
onBeforeSelectionChange: Readonly<{
|
||||
add: (callback: (newSelectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[], cancelable: boolean) => Promise<boolean>) => () => void;
|
||||
remove: (callback: (newSelectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[], cancelable: boolean) => Promise<boolean>) => void;
|
||||
}>;
|
||||
private __onSelectionChangeManager;
|
||||
/** Event handlers that are called after the selection has changed. */
|
||||
onSelectionChange: Readonly<{
|
||||
add: (callback: (selectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[]) => void) => () => void;
|
||||
remove: (callback: (selectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[]) => void) => void;
|
||||
}>;
|
||||
private __onSelectedItemUpdateManager;
|
||||
/** Event handlers that are called when one of the selected items is updated. This happens when the payload or metadata of the item changes. */
|
||||
onSelectedItemUpdate: Readonly<{
|
||||
add: (callback: (selectedItem: DirectoryBrowser.DescendantItem<TFile, TFolder> | null) => void) => () => void;
|
||||
remove: (callback: (selectedItem: DirectoryBrowser.DescendantItem<TFile, TFolder> | null) => void) => void;
|
||||
}>;
|
||||
private __onPathChangeManager;
|
||||
/** Event handlers that are called after the path has changed. */
|
||||
onPathChange: Readonly<{
|
||||
add: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder>, path: string[]) => void) => () => void;
|
||||
remove: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder>, path: string[]) => void) => void;
|
||||
}>;
|
||||
private __onCurrentItemUpdateManager;
|
||||
/** Event handlers that are called when the current item is updated. This happens when the payload or metadata of the item changes. */
|
||||
onCurrentItemUpdate: Readonly<{
|
||||
add: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder>) => void) => () => void;
|
||||
remove: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder>) => void) => void;
|
||||
}>;
|
||||
private __onDirectoryUpdateManager;
|
||||
/** Event handlers that are called after the directory was updated. */
|
||||
onDirectoryUpdate: Readonly<{
|
||||
add: (callback: (root: DirectoryBrowser.Root<TFile, TFolder>) => void) => () => void;
|
||||
remove: (callback: (root: DirectoryBrowser.Root<TFile, TFolder>) => void) => void;
|
||||
}>;
|
||||
/**
|
||||
* Creates a new data model.
|
||||
* @param __root The root of the folder structure
|
||||
*/
|
||||
constructor(__root: DirectoryBrowser.Root<TFile, TFolder>);
|
||||
/**
|
||||
* Gets the root of the folder structure
|
||||
*/
|
||||
get root(): DirectoryBrowser.Root<TFile, TFolder>;
|
||||
/**
|
||||
* Sets a new root, validates the current path and updates the selection. Returns false if the current path is no longer valid with the new root. In that case the path will be truncated to a valid value.
|
||||
* @param value The new root
|
||||
*/
|
||||
setRootAndValidate(value: DirectoryBrowser.Root<TFile, TFolder>): Promise<boolean>;
|
||||
/**
|
||||
* Gets the current path.
|
||||
*/
|
||||
get path(): string[];
|
||||
/**
|
||||
* Gets an array of Item objects describing the path.
|
||||
*/
|
||||
get decoratedPath(): DirectoryBrowser.Item<TFile, TFolder>[];
|
||||
/**
|
||||
* Sets a new path, validates it and clears the selection. Returns false if the new path is invalid and could not be applied or if the action was canceled.
|
||||
* @param value The new path
|
||||
*/
|
||||
setPathAndValidate(value: string[], cancelable?: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Pushes a new name onto the path, validates it and clears the selection. Returns false if the path with the pushed name is invalid and could not be applied or if the action was canceled.
|
||||
* @param name The new name to push
|
||||
*/
|
||||
pushPath(name: string, cancelable?: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Pops the last name from the path. Returns the popped name or null if the path was already empty.
|
||||
*/
|
||||
popPath(cancelable?: boolean): Promise<string | false | null>;
|
||||
/**
|
||||
* Gets current the folder or file. This is the item the path points to.
|
||||
*/
|
||||
get currentItem(): DirectoryBrowser.Item<TFile, TFolder>;
|
||||
/**
|
||||
* Gets the current folder. If the current item is a file its parent is returned, otherwise the current item itself.
|
||||
*/
|
||||
get currentFolder(): DirectoryBrowser.Root<TFile, TFolder> | DirectoryBrowser.Folder<TFile, TFolder> | DirectoryBrowser.FolderLikeItem<TFile, TFolder>;
|
||||
/**
|
||||
* Gets the names of the selected items that are children of the current item.
|
||||
*/
|
||||
get selectedItemNames(): Set<string>;
|
||||
/**
|
||||
* Gets the selected items.
|
||||
*/
|
||||
get selectedItems(): DirectoryBrowser.DescendantItem<TFile, TFolder>[];
|
||||
/**
|
||||
* Selects the given item. Returns false if the action was canceled.
|
||||
* @param item The item to select.
|
||||
* @param expandSelection Controls whether the newly selected element should be added to the already existing selection or replace it.
|
||||
* @param cancelable Controls whether this action should be cancelable by returning false in one of the beforeSelectionChange event handlers.
|
||||
*/
|
||||
selectItem(item: DirectoryBrowser.DescendantItem<TFile, TFolder>, expandSelection: boolean, cancelable?: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Selects the child of the current item with the given name. Returns false if no child with the given name exists or the action was canceled.
|
||||
* @param name The name of the item to select.
|
||||
* @param expandSelection Controls whether the newly selected element should be added to the already existing selection or replace it.
|
||||
* @param cancelable Controls whether this action should be cancelable by returning false in one of the beforeSelectionChange event handlers.
|
||||
*/
|
||||
selectItem(name: string, expandSelection: boolean, cancelable?: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Deselects the given item. Returns false if the action was canceled.
|
||||
* @param name The item to deselect.
|
||||
* @param cancelable Controls whether this action should be cancelable by returning false in one of the beforeSelectionChange event handlers.
|
||||
*/
|
||||
deselectItem(item: DirectoryBrowser.DescendantItem<TFile, TFolder>, cancelable?: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Deselects the item with the given name. Returns false if the action was canceled.
|
||||
* @param name The name of the item to deselect.
|
||||
* @param cancelable Controls whether this action should be cancelable by returning false in one of the beforeSelectionChange event handlers.
|
||||
*/
|
||||
deselectItem(name: string, cancelable?: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Clears the selected elements. Returns false if the action was canceled.
|
||||
* @param cancelable Controls whether this action should be cancelable by returning false in one of the beforeSelectionChange event handlers.
|
||||
*/
|
||||
clearSelection(cancelable?: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Controls whether naviagtion to files is allowed.
|
||||
*/
|
||||
set navigationToFilesAllowed(value: boolean);
|
||||
/**
|
||||
* Controls whether naviagtion to files is allowed.
|
||||
*/
|
||||
get navigationToFilesAllowed(): boolean;
|
||||
/**
|
||||
* Controls whether multiselection is allowed.
|
||||
*/
|
||||
set multiSelectAllowed(value: boolean);
|
||||
/**
|
||||
* Controls whether multiselection is allowed.
|
||||
*/
|
||||
get multiSelectAllowed(): boolean;
|
||||
/**
|
||||
* Checks if the given root contains a file or folder reachable by the given path and returns an object indicating the validity of the path, containing a valid path and the item the (valid) path leads to.
|
||||
* @param root The root item.
|
||||
* @param path The path to validate.
|
||||
*/
|
||||
private __validatePath;
|
||||
/**
|
||||
* Checks if the given items are equivalent. Two items are considered equivalent if they have the same type, name, payload and metadata.
|
||||
* Parent and children are ignored because we don't want to compare the whole tree.
|
||||
* @param a The first item to compare.
|
||||
* @param b The second item to compare.
|
||||
*/
|
||||
private __itemsEquivalent;
|
||||
}
|
||||
//# sourceMappingURL=Directory.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,382 @@
|
||||
import { Directory } from './Directory.js';
|
||||
import { Callback } from 'Beckhoff.TwinCAT.HMI.Framework/index.esm.js';
|
||||
import type { Display } from './Display.js';
|
||||
export declare class DirectoryBrowser<TFile, TFolder> {
|
||||
protected __displays: Set<Display>;
|
||||
protected __directory: Directory<TFile, TFolder> | null;
|
||||
protected __suspended: boolean;
|
||||
protected __autoSuspended: boolean;
|
||||
protected __directoryUpdatesSuspension: {
|
||||
suspended: boolean;
|
||||
cachedUpdate: DirectoryBrowser.Root<TFile, TFolder> | null | undefined;
|
||||
};
|
||||
protected __fakeFile: {
|
||||
path: string[];
|
||||
payload: TFile;
|
||||
metadata?: TcHmi.Dictionary<any>;
|
||||
remove: () => DirectoryBrowser.Root<TFile, TFolder> | null;
|
||||
} | null;
|
||||
protected __pathToSet: {
|
||||
path: string[];
|
||||
callback: (result: boolean | PromiseLike<boolean>) => void;
|
||||
} | null;
|
||||
protected __itemsToSelect: {
|
||||
pathOrName: string[] | string;
|
||||
callback?: (result: boolean | PromiseLike<boolean>) => void;
|
||||
}[];
|
||||
protected __navigationToFilesAllowedCache: boolean;
|
||||
private __multiSelectAllowedCache;
|
||||
protected __onBeforePathChangeManager: Callback.AsyncCollection<(newCurrentItem: DirectoryBrowser.Item<TFile, TFolder> | null, newPath: string[] | null, cancelable: boolean) => Promise<boolean>>;
|
||||
/** Event handlers that are called before the path is changed. If the cancelable parameter is true, returning false from one of the handlers will cancel the path change. */
|
||||
onBeforePathChange: Readonly<{
|
||||
add: (callback: (newCurrentItem: DirectoryBrowser.Item<TFile, TFolder> | null, newPath: string[] | null, cancelable: boolean) => Promise<boolean>) => () => void;
|
||||
remove: (callback: (newCurrentItem: DirectoryBrowser.Item<TFile, TFolder> | null, newPath: string[] | null, cancelable: boolean) => Promise<boolean>) => void;
|
||||
}>;
|
||||
protected __onBeforeSelectionChangeManager: Callback.AsyncCollection<(newSelectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[] | null, cancelable: boolean) => Promise<boolean>>;
|
||||
/** Event handlers that are called before the selection is changed. If the cancelable parameter is true, returning false from one of the handlers will cancel the selection change. */
|
||||
onBeforeSelectionChange: Readonly<{
|
||||
add: (callback: (newSelectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[] | null, cancelable: boolean) => Promise<boolean>) => () => void;
|
||||
remove: (callback: (newSelectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[] | null, cancelable: boolean) => Promise<boolean>) => void;
|
||||
}>;
|
||||
protected __onSelectionChangeManager: Callback.Collection<(selectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[] | null) => void>;
|
||||
/** Event handlers that are called after the selection has changed. */
|
||||
onSelectionChange: Readonly<{
|
||||
add: (callback: (selectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[] | null) => void) => () => void;
|
||||
remove: (callback: (selectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[] | null) => void) => void;
|
||||
}>;
|
||||
protected __onSelectedItemUpdateManager: Callback.Collection<(selectedItem: DirectoryBrowser.DescendantItem<TFile, TFolder>) => void>;
|
||||
/** Event handlers that are called when one of the selected items is updated. This happens when the payload or metadata of the item changes. */
|
||||
onSelectedItemUpdate: Readonly<{
|
||||
add: (callback: (selectedItem: DirectoryBrowser.DescendantItem<TFile, TFolder>) => void) => () => void;
|
||||
remove: (callback: (selectedItem: DirectoryBrowser.DescendantItem<TFile, TFolder>) => void) => void;
|
||||
}>;
|
||||
protected __onPathChangeManager: Callback.Collection<(currentItem: DirectoryBrowser.Item<TFile, TFolder> | null, path: string[] | null) => void>;
|
||||
/** Event handlers that are called after the path has changed. */
|
||||
onPathChange: Readonly<{
|
||||
add: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder> | null, path: string[] | null) => void) => () => void;
|
||||
remove: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder> | null, path: string[] | null) => void) => void;
|
||||
}>;
|
||||
protected __onCurrentItemUpdateManager: Callback.Collection<(currentItem: DirectoryBrowser.Item<TFile, TFolder>) => void>;
|
||||
/** Event handlers that are called when the current item is updated. This happens when the payload or metadata of the item changes. */
|
||||
onCurrentItemUpdate: Readonly<{
|
||||
add: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder>) => void) => () => void;
|
||||
remove: (callback: (currentItem: DirectoryBrowser.Item<TFile, TFolder>) => void) => void;
|
||||
}>;
|
||||
protected __parentControl: TcHmi.Controls.System.TcHmiControl | undefined;
|
||||
protected __destroyOnParentDestroy: TcHmi.DestroyFunction[];
|
||||
hasData: Promise<void>;
|
||||
protected __resolveHasData: () => void;
|
||||
/**
|
||||
* Creates a new DirectoryBrowser.
|
||||
* @param displays A list of components that are responsible for displaying the directory browser.
|
||||
*/
|
||||
constructor(displays?: Iterable<Display>);
|
||||
/**
|
||||
* Creates a new DirectoryBrowser.
|
||||
* @param parentControl The control that uses this directory browser.
|
||||
*/
|
||||
constructor(parentControl: TcHmi.Controls.System.TcHmiControl);
|
||||
/**
|
||||
* Creates a new DirectoryBrowser.
|
||||
* @param displays A list of components that are responsible for displaying the directory browser.
|
||||
* @param parentControl The control that uses this directory browser.
|
||||
*/
|
||||
constructor(displays: Iterable<Display>, parentControl?: TcHmi.Controls.System.TcHmiControl);
|
||||
/**
|
||||
* Adds a display.
|
||||
* @param display The display to add.
|
||||
*/
|
||||
addDisplay(display: Display): void;
|
||||
/**
|
||||
* Removes a display. It will automatically be suspended if it was registered on this DirectoryBrowser.
|
||||
* @param display The display to remove.
|
||||
*/
|
||||
removeDisplay(display: Display): void;
|
||||
/**
|
||||
* Removes all event listeners. Should be called when the owning control is detached or destroyed.
|
||||
* @param clear Set to true to remove all child elements from the path and browsing elements.
|
||||
*/
|
||||
suspend(clear?: boolean): void;
|
||||
/**
|
||||
* Re-adds event listeners that were previously removed by suspend. Should be called when owning control is reattached.
|
||||
*/
|
||||
resume(): void;
|
||||
/**
|
||||
* Suspends directory updates. Updates that come in after this method was called will be cached and not applied to the DOM until resumeDirectoryUpdates is called.
|
||||
*/
|
||||
suspendDirectoryUpdates(): void;
|
||||
/**
|
||||
* Resumes directory updates. If an update was chached during the suspension it will be applied now.
|
||||
*/
|
||||
resumeDirectoryUpdates(): void;
|
||||
/**
|
||||
* Gets the item the path points to. Returns null if the directory browser has no items.
|
||||
*/
|
||||
getCurrentItem(): _DirectoryBrowser.Item<TFile, TFolder> | null;
|
||||
/**
|
||||
* Gets the current folder. If the current item is a file, the parent folder of the current item is returned, otherwise the current item itself.
|
||||
* Returns null if the directory browser has no items.
|
||||
*/
|
||||
getCurrentFolder(): _DirectoryBrowser.FolderLikeItem<TFile, TFolder> | null;
|
||||
/**
|
||||
* Gets the current path as an array of strings. Returns null if the directory browser has no items.
|
||||
*/
|
||||
getPath(): string[] | null;
|
||||
/**
|
||||
* Gets the path of the current folder. If the current item is a file, the path of the parent folder is returned, otherwise the path of the current item itself.
|
||||
* Returns null if the directory browser has no items.
|
||||
*/
|
||||
getFolderPath(): string[] | null;
|
||||
/**
|
||||
* Gets the selected item.
|
||||
*/
|
||||
getSelectedItems(): _DirectoryBrowser.DescendantItem<TFile, TFolder>[] | null;
|
||||
/**
|
||||
* Tries to set the path. Returns false if the path was invalid or the action was canceled.
|
||||
* If the DirectoryBrowser does not yet have a directory, the path will be set as soon as a directory is set.
|
||||
* @param value The new path.
|
||||
*/
|
||||
setPath(value: string[]): Promise<boolean>;
|
||||
/**
|
||||
* Tries to select an item. If the current folder does not have an item with the given name, false is returned.
|
||||
* If the DirectoryBrowser does not yet have a directory, the item will be selected as soon as a directory is
|
||||
* set.
|
||||
* @param name The name of the item to select.
|
||||
* @param expandSelection Set to false to replace the current selection, set to true to add to the
|
||||
* current selection.
|
||||
*/
|
||||
selectItem(name: string, expandSelection: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Tries to select an item. If the item does not exist, false is returned.
|
||||
* If the DirectoryBrowser does not yet have a directory, the item will be selected as soon as a directory is
|
||||
* set.
|
||||
* @param path The path of the item to select.
|
||||
* @param expandSelection Set to false to replace the current selection, set to true to add to the
|
||||
* current selection.
|
||||
*/
|
||||
selectItem(path: string[], expandSelection: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Deselects a selected item. Returns false if no item with the given name was selected or the action was
|
||||
* canceled.
|
||||
* @param name The name of the item to deselect.
|
||||
*/
|
||||
deselectItem(name: string): Promise<boolean>;
|
||||
/**
|
||||
* Deselects a selected item. Returns false if no item with the given name was selected or the action was
|
||||
* canceled.
|
||||
* @param path The path of the item to deselect.
|
||||
*/
|
||||
deselectItem(path: string[]): Promise<boolean>;
|
||||
/**
|
||||
* Clears the selected items. Returns false if the action was canceled.
|
||||
*/
|
||||
clearSelection(): Promise<boolean>;
|
||||
/**
|
||||
* Adds a fake file to the directory.
|
||||
* @param path The path and name of the file.
|
||||
* @param payload The content of the file.
|
||||
*/
|
||||
fakeFile(path: string[], payload: TFile, metadata?: TcHmi.Dictionary<any>): void;
|
||||
/**
|
||||
* Removes the faked file from the directory.
|
||||
*/
|
||||
clearFakedFile(): void;
|
||||
/**
|
||||
* Returns whether the directory contains a faked file.
|
||||
*/
|
||||
hasFakedFile(): boolean;
|
||||
/**
|
||||
* Sets whether it should be allowed to navigate to files.
|
||||
* @param value Whether it should be allowed to navigate to files.
|
||||
*/
|
||||
setNavigationToFilesAllowed(value: boolean): void;
|
||||
/**
|
||||
* Gets whether it should be allowed to navigate to files.
|
||||
*/
|
||||
getNavigationToFilesAllowed(): boolean;
|
||||
/**
|
||||
* Sets whether it should be allowed to select multiple items.
|
||||
* @param value Whether it should be allowed to select multiple items.
|
||||
*/
|
||||
setMultiSelectAllowed(value: boolean): void;
|
||||
/**
|
||||
* Gets whether it should be allowed to select multiple items.
|
||||
*/
|
||||
getMultiSelectAllowed(): boolean;
|
||||
/**
|
||||
* Callback for the beforePathChange event of the data model. Triggers onBeforePathChange.
|
||||
*/
|
||||
protected __onBeforePathChange(newCurrentItem: DirectoryBrowser.Item<TFile, TFolder>, path: string[], cancelable: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Callback for the beforeSelectionChange event of the data model. Triggers onBeforeSelectionChange.
|
||||
*/
|
||||
protected __onBeforeSelectionChange(newSelectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[], cancelable: boolean): Promise<boolean>;
|
||||
/**
|
||||
* Callback for the selectionChange event of the data model. Triggers onSelectionChange.
|
||||
*/
|
||||
protected __onSelectionChange(newSelectedItems: DirectoryBrowser.DescendantItem<TFile, TFolder>[]): void;
|
||||
/**
|
||||
* Callback for the selectedItemUpdate event of the data model. Triggers onSelectedItemUpdate.
|
||||
*/
|
||||
protected __onSelectedItemUpdate(selectedItem: DirectoryBrowser.DescendantItem<TFile, TFolder>): void;
|
||||
/**
|
||||
* Callback for the pathChange event of the data model. Triggers onPathChange.
|
||||
*/
|
||||
protected __onPathChange(currentItem: DirectoryBrowser.Item<TFile, TFolder>, path: string[]): void;
|
||||
/**
|
||||
* Callback for the currentItemChange event of the data model. Triggers onCurrentItemChange.
|
||||
*/
|
||||
protected __onCurrentItemChange(currentItem: DirectoryBrowser.Item<TFile, TFolder>): void;
|
||||
/**
|
||||
* Sets the directory.
|
||||
* @param rootFolder The root folder object.
|
||||
* @param getChildren A function that takes a folder object and returns a map that contains the children of the folder and their names as keys.
|
||||
* @param isFile A function that determines if the given object is a file or folder.
|
||||
* @param getMetadata A function that returns metadata about the given file or folder.
|
||||
*/
|
||||
setDirectory(rootFolder: TFolder | null, getChildren: (folder: TFolder) => Map<string, TFile | TFolder>, isFile: (candidate: TFile | TFolder) => boolean, getMetadata?: (item: TFile | TFolder) => TcHmi.Dictionary<any>): Promise<void>;
|
||||
/**
|
||||
* Updates the directory and the path and browsing elements.
|
||||
* @param directory The new directory.
|
||||
*/
|
||||
protected __updateDirectory(directory: DirectoryBrowser.Root<TFile, TFolder> | null): Promise<void>;
|
||||
/**
|
||||
* Builds a directory tree from the root folder.
|
||||
* @param rootFolder The root folder object.
|
||||
* @param getChildren A function that takes a folder object and returns a map that contains the children of the folder and their names as keys.
|
||||
* @param isFile A function that determines if the given object is a file or folder.
|
||||
* @param getMetadata A function that returns metadata about the given file or folder.
|
||||
*/
|
||||
protected buildDirectoryTree(rootFolder: TFolder, getChildren: (folder: TFolder) => Map<string, TFile | TFolder>, isFile: (candidate: TFile | TFolder) => candidate is TFile, getMetadata?: (item: TFile | TFolder) => TcHmi.Dictionary<any>): _DirectoryBrowser.Root<TFile, TFolder>;
|
||||
static Directory: typeof Directory;
|
||||
}
|
||||
export declare namespace DirectoryBrowser {
|
||||
enum ItemType {
|
||||
File = 0,
|
||||
Folder = 1,
|
||||
Root = 2
|
||||
}
|
||||
/**
|
||||
* The root of the directory tree. Fundamentally a folder but does not have a parent or a name.
|
||||
*/
|
||||
interface Root<TFile, TFolder> {
|
||||
/**
|
||||
* Must be ItemType.Root to identify this object as the root folder
|
||||
*/
|
||||
type: ItemType.Root;
|
||||
/**
|
||||
* The original folder object
|
||||
*/
|
||||
payload: TFolder;
|
||||
/**
|
||||
* The children of this folder
|
||||
*/
|
||||
children: Map<string, DescendantItem<TFile, TFolder>>;
|
||||
/**
|
||||
* Optional metadata
|
||||
*/
|
||||
metadata?: TcHmi.Dictionary<any>;
|
||||
}
|
||||
/**
|
||||
* A folder in the directory tree. Can contain other folders and files as children and has a parent and a name.
|
||||
*/
|
||||
interface Folder<TFile, TFolder> {
|
||||
/**
|
||||
* Must be ItemType.Folder to identify this object as a folder
|
||||
*/
|
||||
type: ItemType.Folder;
|
||||
/**
|
||||
* The name of the folder
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The original folder object
|
||||
*/
|
||||
payload: TFolder;
|
||||
/**
|
||||
* The parent of this folder
|
||||
*/
|
||||
parent: FolderLikeItem<TFile, TFolder>;
|
||||
/**
|
||||
* The children of this folder
|
||||
*/
|
||||
children: Map<string, DescendantItem<TFile, TFolder>>;
|
||||
/**
|
||||
* Optional metadata
|
||||
*/
|
||||
metadata?: TcHmi.Dictionary<any>;
|
||||
}
|
||||
/**
|
||||
* A file in the directory tree. Has no children, but a parent and a name.
|
||||
*/
|
||||
interface File<TFile, TFolder> {
|
||||
/**
|
||||
* Must be ItemType.File to identify this object as a file
|
||||
*/
|
||||
type: ItemType.File;
|
||||
/**
|
||||
* The name of the file
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* The original file object
|
||||
*/
|
||||
payload: TFile;
|
||||
/**
|
||||
* The parent of this file
|
||||
*/
|
||||
parent: FolderLikeItem<TFile, TFolder>;
|
||||
/**
|
||||
* Optional metadata
|
||||
*/
|
||||
metadata?: TcHmi.Dictionary<any>;
|
||||
}
|
||||
type Item<TFile, TFolder> = Root<TFile, TFolder> | Folder<TFile, TFolder> | File<TFile, TFolder>;
|
||||
type FolderLikeItem<TFile, TFolder> = Root<TFile, TFolder> | Folder<TFile, TFolder>;
|
||||
type DescendantItem<TFile, TFolder> = Folder<TFile, TFolder> | File<TFile, TFolder>;
|
||||
interface Sort {
|
||||
sorting: TcHmi.SortingInfo[];
|
||||
caseSensitive: boolean;
|
||||
}
|
||||
/**
|
||||
* A utilitiy function that returns -1, 1 or 0 depending on if a should be sorted higher, lower or equal to b
|
||||
* according to the given sort.
|
||||
* @param sort The sorting to use.
|
||||
* @param a The first item to compare.
|
||||
* @param b The second item to compare.
|
||||
*/
|
||||
function compare(sort: Sort, a: DescendantItem<unknown, unknown>, b: DescendantItem<unknown, unknown>): number;
|
||||
/**
|
||||
* Returns the path as an array of strings to the given item.
|
||||
* @param item The item to get the path to.
|
||||
*/
|
||||
function getPath(item: Item<unknown, unknown>): string[];
|
||||
/**
|
||||
* Returns the item indicated by the given path originating from the given root. Returns null if the path is
|
||||
* invalid.
|
||||
* @param root The root item to start following the path from.
|
||||
* @param path The path to follow.
|
||||
*/
|
||||
function getItem<TFile, TFolder>(root: FolderLikeItem<TFile, TFolder>, path: string[]): Item<TFile, TFolder> | null;
|
||||
}
|
||||
import _DirectoryBrowser = DirectoryBrowser;
|
||||
type tDirectory<TFile, TFolder> = Directory<TFile, TFolder>;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let DirectoryBrowser: typeof _DirectoryBrowser;
|
||||
type DirectoryBrowser<TFile, TFolder> = _DirectoryBrowser<TFile, TFolder>;
|
||||
namespace DirectoryBrowser {
|
||||
type ItemType = _DirectoryBrowser.ItemType;
|
||||
type Root<TFile, TFolder> = _DirectoryBrowser.Root<TFile, TFolder>;
|
||||
type Folder<TFile, TFolder> = _DirectoryBrowser.Folder<TFile, TFolder>;
|
||||
type File<TFile, TFolder> = _DirectoryBrowser.File<TFile, TFolder>;
|
||||
type Item<TFile, TFolder> = _DirectoryBrowser.Item<TFile, TFolder>;
|
||||
type FolderLikeItem<TFile, TFolder> = _DirectoryBrowser.FolderLikeItem<TFile, TFolder>;
|
||||
type DescendantItem<TFile, TFolder> = _DirectoryBrowser.DescendantItem<TFile, TFolder>;
|
||||
type Sort = _DirectoryBrowser.Sort;
|
||||
type Directory<TFile, TFolder> = tDirectory<TFile, TFolder>;
|
||||
}
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=DirectoryBrowser.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,44 @@
|
||||
import type { Directory } from './Directory.js';
|
||||
export declare abstract class Display {
|
||||
protected __element: HTMLElement;
|
||||
protected __parentControl: TcHmi.Controls.System.TcHmiControl;
|
||||
protected __suspended: boolean;
|
||||
protected __autoSuspended: boolean;
|
||||
protected __directory: Directory<unknown, unknown> | null;
|
||||
protected __directoryEventDestroyers: TcHmi.DestroyFunction[];
|
||||
protected __parentControlEventDestroyers: TcHmi.DestroyFunction[];
|
||||
/**
|
||||
* Creates a new Display.
|
||||
* @param __element The element that hosts the Display in the DOM.
|
||||
* @param __parentControl The control that owns this display.
|
||||
*/
|
||||
constructor(__element: HTMLElement, __parentControl: TcHmi.Controls.System.TcHmiControl);
|
||||
/**
|
||||
* Removes all event listeners. Should be called when the owning control is detached or destroyed.
|
||||
* @param clear Set to true to remove all child elements from the element.
|
||||
*/
|
||||
suspend(clear: boolean): void;
|
||||
/**
|
||||
* Re-adds event listeners that were previously removed by suspend. Should be called when owning control is reattached.
|
||||
* The display is initialised in a suspended state, so resume can be called from the constructor to add event listeners.
|
||||
*/
|
||||
resume(): void;
|
||||
/**
|
||||
* Sets a new directory.
|
||||
*/
|
||||
setDirectory(directory: Directory<unknown, unknown> | null): void;
|
||||
/**
|
||||
* Processes the directory.
|
||||
*/
|
||||
protected abstract __processDirectory(): void;
|
||||
}
|
||||
declare const _Display: typeof Display;
|
||||
type tDisplay = Display;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let Display: typeof _Display;
|
||||
type Display = tDisplay;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=Display.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
export class Display{__element;__parentControl;__suspended=!0;__autoSuspended=!1;__directory=null;__directoryEventDestroyers=[];__parentControlEventDestroyers=[];constructor(__element,__parentControl){this.__element=__element,this.__parentControl=__parentControl,this.__parentControlEventDestroyers.push(TcHmi.EventProvider.register(this.__parentControl.getId()+".onDetached",()=>{this.__suspended||(this.suspend(!0),this.__autoSuspended=!0)}),TcHmi.EventProvider.register(this.__parentControl.getId()+".onAttached",()=>{this.__autoSuspended&&(this.resume(),this.__autoSuspended=!1)}),TcHmi.EventProvider.register(this.__parentControl.getId()+".onDestroyed",()=>{this.suspend(!0);for(let destroyer of this.__parentControlEventDestroyers)destroyer();this.__parentControlEventDestroyers=[]}))}suspend(clear){if(!this.__suspended){for(const destroy of this.__directoryEventDestroyers)destroy();this.__directoryEventDestroyers=[],this.__suspended=!0}}resume(){this.__suspended&&(this.__suspended=!1,this.__processDirectory())}setDirectory(directory){for(const destroy of this.__directoryEventDestroyers)destroy();this.__directoryEventDestroyers=[],this.__directory=directory,this.__suspended||this.__processDirectory()}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.Display=Display;
|
||||
@@ -0,0 +1,87 @@
|
||||
import { Callback } from 'Beckhoff.TwinCAT.HMI.Framework/index.esm.js';
|
||||
import { Display } from './Display.js';
|
||||
export declare abstract class DragAndDropDisplay extends Display {
|
||||
protected __dragAndDropAllowed: boolean;
|
||||
protected __draggedElement: HTMLElement | null;
|
||||
protected __dropElement: HTMLElement | null;
|
||||
protected __eventDestroyers: TcHmi.DestroyFunction[];
|
||||
protected readonly __onDragAndDropManager: Callback.Collection<(draggedItems: string[], droppedOnto: {
|
||||
name: string;
|
||||
isParent: boolean;
|
||||
}) => void>;
|
||||
readonly onDragAndDrop: Readonly<{
|
||||
add: (callback: (draggedItems: string[], droppedOnto: {
|
||||
name: string;
|
||||
isParent: boolean;
|
||||
}) => void) => () => void;
|
||||
remove: (callback: (draggedItems: string[], droppedOnto: {
|
||||
name: string;
|
||||
isParent: boolean;
|
||||
}) => void) => void;
|
||||
}>;
|
||||
/**
|
||||
* Creates a new DragAndDropDisplay.
|
||||
* @param __element The element that hosts the DragAndDropDisplay in the DOM.
|
||||
*/
|
||||
constructor(element: HTMLElement, parentControl: TcHmi.Controls.System.TcHmiControl);
|
||||
/**
|
||||
* Event handler for the dragstart event of __element.
|
||||
* @param event The event
|
||||
*/
|
||||
protected __onDragStart(event: DragEvent): void;
|
||||
/**
|
||||
* Event handler for the dragover event of __element.
|
||||
* @param event The event
|
||||
*/
|
||||
protected __onDragOver(event: DragEvent): void;
|
||||
/**
|
||||
* Event handler for the drop event of __element.
|
||||
* @param event The event
|
||||
*/
|
||||
protected __onDrop(event: DragEvent): void;
|
||||
/**
|
||||
* Event handler for the dragend event of __element.
|
||||
* @param event The event
|
||||
*/
|
||||
protected __onDragEnd(_event: DragEvent): void;
|
||||
/**
|
||||
* Removes all event listeners. Should be called when the owning control is detached or destroyed.
|
||||
* @param clear Set to true to remove all child elements from the path element.
|
||||
*/
|
||||
suspend(clear?: boolean): void;
|
||||
/**
|
||||
* Re-adds event listeners that were previously removed by suspend. Should be called when owning control is reattached.
|
||||
*/
|
||||
resume(): void;
|
||||
/**
|
||||
* Sets dragAndDropAllowed to control whether items can be dragged and dropped.
|
||||
* @param valueNew The new value for dragAndDropAllowed.
|
||||
*/
|
||||
setDragAndDropAllowed(valueNew: boolean): void;
|
||||
/**
|
||||
* Gets the current value of dragAndDropAllowed.
|
||||
*/
|
||||
getDragAndDropAllowed(): boolean;
|
||||
/**
|
||||
* Processes the current value of __dragAndDropAllowed
|
||||
*/
|
||||
protected __processDragAndDropAllowed(): void;
|
||||
/**
|
||||
* Adds event handlers for drag and drop events.
|
||||
*/
|
||||
protected __addDragAndDropHandlers(): void;
|
||||
/**
|
||||
* Removes event handlers for drag and drop events.
|
||||
*/
|
||||
protected __removeDragAndDropHandlers(): void;
|
||||
}
|
||||
declare const _DragAndDropDisplay: typeof DragAndDropDisplay;
|
||||
type tDragAndDropDisplay = DragAndDropDisplay;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let DragAndDropDisplay: typeof _DragAndDropDisplay;
|
||||
type DragAndDropDisplay = tDragAndDropDisplay;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=DragAndDropDisplay.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,151 @@
|
||||
import { Display } from './Display.js';
|
||||
import { DirectoryBrowser } from './DirectoryBrowser.js';
|
||||
export declare class ListBrowsingDisplay extends Display {
|
||||
protected __showingParent: boolean;
|
||||
protected __lastPointerDown: {
|
||||
type: string;
|
||||
timestamp: number;
|
||||
doubleClickOnNextUp: boolean;
|
||||
ignoreNextUp: boolean;
|
||||
target: EventTarget | null;
|
||||
timeoutID: number;
|
||||
coords: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
protected __pointerMultiselect: boolean;
|
||||
protected __formatMetadata: ((item: DirectoryBrowser.Item<unknown, unknown>) => string) | null;
|
||||
protected __search: {
|
||||
term: string;
|
||||
caseSensitive: boolean;
|
||||
} | null;
|
||||
protected __sort: DirectoryBrowser.Sort | null;
|
||||
protected readonly __defaultSort: DirectoryBrowser.Sort;
|
||||
protected __eventDestroyers: TcHmi.DestroyFunction[];
|
||||
/**
|
||||
* Creates a new ListBrowsingDisplay.
|
||||
* @param element The element that hosts the ListBrowsingDisplay in the DOM.
|
||||
* @param parentControl The control that owns the ListBrowsingDisplay.
|
||||
*/
|
||||
constructor(element: HTMLUListElement, parentControl: TcHmi.Controls.System.TcHmiControl);
|
||||
/**
|
||||
* Event handler for the pointerdown event of document.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onPointerDown(event: PointerEvent): void;
|
||||
/**
|
||||
* Event handler for the pointerup event of the list element.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onPointerUp(event: PointerEvent): void;
|
||||
/**
|
||||
* Event handler for the pointermove event of document.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onPointerMove(event: PointerEvent): void;
|
||||
/**
|
||||
* Event handler for the scroll event of the document and the list element.
|
||||
*/
|
||||
protected __onScroll(): void;
|
||||
/**
|
||||
* Event handler for the contextmenu event of the list element.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onContextMenu(event: Event): void;
|
||||
/**
|
||||
* Checks if the event should be acted upon and if yes, returns the target, item name and whether the target represents the parent item.
|
||||
* @param event The event to check.
|
||||
*/
|
||||
protected __preprocessPointerEvent(event: PointerEvent): false | ListBrowsingDisplay.ListItemEvent;
|
||||
/**
|
||||
* Selects an item.
|
||||
* @param event The event containing information about the item to select. Use null to clear the selection.
|
||||
*/
|
||||
protected __select(event: ListBrowsingDisplay.ListItemEvent | null): Promise<void>;
|
||||
/**
|
||||
* Navigates to a child or parent item.
|
||||
* @param event The event containing information about the item that should be navigated to.
|
||||
*/
|
||||
protected __navigate(event: ListBrowsingDisplay.ListItemEvent): void;
|
||||
/**
|
||||
* Removes all event listeners. Should be called when the owning control is detached or destroyed.
|
||||
* @param clear Set to true to remove all child elements from the path element.
|
||||
*/
|
||||
suspend(clear?: boolean): void;
|
||||
/**
|
||||
* Re-adds event listeners that were previously removed by suspend. Should be called when owning control is reattached.
|
||||
*/
|
||||
resume(): void;
|
||||
/**
|
||||
* Show metadata about each item.
|
||||
* @param metadataFormatter A function that receives an item and returns a string that should be displayed as the metadata
|
||||
*/
|
||||
showMetadata<TFile, TFolder>(metadataFormatter: (item: DirectoryBrowser.Item<TFile, TFolder>) => string): void;
|
||||
/**
|
||||
* Hides the metadata.
|
||||
*/
|
||||
hideMetadata(): void;
|
||||
/**
|
||||
* Only displays items that contain the given string in their name.
|
||||
* @param term The string to search.
|
||||
* @param caseSensitive Whether to perform a case sensitive search.
|
||||
*/
|
||||
search(term: string | null, caseSensitive?: boolean): void;
|
||||
/**
|
||||
* Sorts the displayed items.
|
||||
* @param sorting The sorting to apply.
|
||||
* @param caseSensitive Whether to perform a case sensitive sort.
|
||||
*/
|
||||
sort(sorting: TcHmi.SortingInfo[] | null, caseSensitive?: boolean): void;
|
||||
/**
|
||||
* Processes the directory.
|
||||
*/
|
||||
protected __processDirectory(): void;
|
||||
/**
|
||||
* Updates the currentItem.
|
||||
*/
|
||||
protected __updateCurrentItem(currentItem: DirectoryBrowser.Item<unknown, unknown> | null | undefined): void;
|
||||
/**
|
||||
* Creates a new list element, or updates an existing one, to represent the given pathItem.
|
||||
* @param item The item to represent.
|
||||
* @param status Signals whether the pathItem is the parent of the displayed view, or the current item.
|
||||
* @param element Can be set to reuse an existing element.
|
||||
*/
|
||||
protected __createOrUpdateListElement(item: DirectoryBrowser.Item<unknown, unknown>, status?: _ListBrowsingDisplay.ListItemStatus, element?: HTMLLIElement): HTMLLIElement;
|
||||
/**
|
||||
* Updates the selected item
|
||||
* @param selectedItemName The name of the selected item.
|
||||
*/
|
||||
protected __updateSelection(): void;
|
||||
}
|
||||
export declare namespace ListBrowsingDisplay {
|
||||
enum ListItemStatus {
|
||||
Default = 0,
|
||||
Selected = 1,
|
||||
Current = 2,
|
||||
Parent = 3
|
||||
}
|
||||
interface ListItemEvent {
|
||||
target: HTMLLIElement;
|
||||
item: {
|
||||
isParent: false;
|
||||
name: string;
|
||||
} | {
|
||||
isParent: true;
|
||||
};
|
||||
multiselect: boolean;
|
||||
}
|
||||
}
|
||||
import _ListBrowsingDisplay = ListBrowsingDisplay;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ListBrowsingDisplay: typeof _ListBrowsingDisplay;
|
||||
type ListBrowsingDisplay = _ListBrowsingDisplay;
|
||||
namespace ListBrowsingDisplay {
|
||||
type ListItemStatus = _ListBrowsingDisplay.ListItemStatus;
|
||||
type ListItemEvent = _ListBrowsingDisplay.ListItemEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ListBrowsingDisplay.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,71 @@
|
||||
import { Display } from './Display.js';
|
||||
import { DirectoryBrowser } from './DirectoryBrowser.js';
|
||||
export declare class PathDisplay extends Display {
|
||||
protected __scrollContainer: HTMLDivElement;
|
||||
protected __itemListElement: HTMLUListElement;
|
||||
protected __mouseDragScrolling: {
|
||||
startX: number;
|
||||
mouseDown: boolean;
|
||||
dragging: boolean;
|
||||
ignoreClick: boolean;
|
||||
};
|
||||
protected __eventDestroyers: TcHmi.DestroyFunction[];
|
||||
/**
|
||||
* Creates a new PathDisplay.
|
||||
* @param element The element that hosts the PathDisplay in the DOM.
|
||||
*/
|
||||
constructor(element: HTMLDivElement, parentControl: TcHmi.Controls.System.TcHmiControl);
|
||||
/**
|
||||
* Event handler for the click event of __itemListElement.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onClick(event: MouseEvent): void;
|
||||
/**
|
||||
* Event handler for the mousedown event of __element.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onMouseDown(event: MouseEvent): void;
|
||||
/**
|
||||
* Event handler for the mouseup event of document.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onMouseUp(event: MouseEvent): void;
|
||||
/**
|
||||
* Event handler for the mousemove event of document.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onMouseMove(event: MouseEvent): void;
|
||||
/**
|
||||
* Removes all event listeners. Should be called when the owning control is detached or destroyed.
|
||||
* @param clear Set to true to remove all child elements from the path element.
|
||||
*/
|
||||
suspend(clear?: boolean): void;
|
||||
/**
|
||||
* Re-adds event listeners that were previously removed by suspend. Should be called when owning control is reattached.
|
||||
*/
|
||||
resume(): void;
|
||||
/**
|
||||
* Processes the directory.
|
||||
*/
|
||||
protected __processDirectory(): void;
|
||||
/**
|
||||
* Updates the path display.
|
||||
*/
|
||||
protected __updatePath(path: DirectoryBrowser.Item<unknown, unknown>[] | null | undefined): void;
|
||||
/**
|
||||
* Creates a new list element, or updates an existing one, to represent the given pathItem.
|
||||
* @param item The item to represent.
|
||||
* @param element Can be set to reuse an existing element.
|
||||
*/
|
||||
protected __createOrUpdateListElement(item: DirectoryBrowser.Item<unknown, unknown>, element?: HTMLLIElement): HTMLLIElement;
|
||||
}
|
||||
declare const _PathDisplay: typeof PathDisplay;
|
||||
type tPathDisplay = PathDisplay;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let PathDisplay: typeof _PathDisplay;
|
||||
type PathDisplay = tPathDisplay;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=PathDisplay.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,164 @@
|
||||
import { Display } from './Display.js';
|
||||
import { DirectoryBrowser } from './DirectoryBrowser.js';
|
||||
export declare class TreeBrowsingDisplay extends Display {
|
||||
protected __treeItems: Map<HTMLElement, DirectoryBrowser.DescendantItem<unknown, unknown>>;
|
||||
protected __expandedItems: Set<string>;
|
||||
/**
|
||||
* Stores information about pointer events to decide if something like a doubleclick or long click should be
|
||||
* emulated.
|
||||
*/
|
||||
protected __lastPointerDown: {
|
||||
type: string;
|
||||
timestamp: number;
|
||||
doubleClickOnNextUp: boolean;
|
||||
ignoreNextUp: boolean;
|
||||
target: EventTarget | null;
|
||||
timeoutID: number;
|
||||
coords: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Is set to true if a multiselect is in progress that was started by long-pressing an item.
|
||||
*/
|
||||
protected __pointerMultiselect: boolean;
|
||||
protected __search: {
|
||||
term: string;
|
||||
caseSensitive: boolean;
|
||||
} | null;
|
||||
protected __sort: DirectoryBrowser.Sort | null;
|
||||
protected readonly __defaultSort: DirectoryBrowser.Sort;
|
||||
protected __eventDestroyers: TcHmi.DestroyFunction[];
|
||||
/**
|
||||
* Creates a new TreeBrowsingDisplay.
|
||||
* @param element The element that hosts the TreeBrowsingDisplay in the DOM.
|
||||
* @param parentControl The control that owns the TreeBrowsingDisplay.
|
||||
*/
|
||||
constructor(element: HTMLDivElement, parentControl: TcHmi.Controls.System.TcHmiControl);
|
||||
/**
|
||||
* Event handler for the pointerdown event of document.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onPointerDown(event: PointerEvent): void;
|
||||
/**
|
||||
* Event handler for the pointerup event of the list element.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onPointerUp(event: PointerEvent): void;
|
||||
/**
|
||||
* Event handler for the pointerup event of the list element.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onClick(event: MouseEvent): void;
|
||||
/**
|
||||
* Event handler for the pointermove event of document.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onPointerMove(event: PointerEvent): void;
|
||||
/**
|
||||
* Event handler for the scroll event of the document and the list element.
|
||||
*/
|
||||
protected __onScroll(): void;
|
||||
/**
|
||||
* Event handler for the contextmenu event of the list element.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onContextMenu(event: Event): void;
|
||||
/**
|
||||
* Event handler for the toggle event of the details elements.
|
||||
* @param event The event.
|
||||
*/
|
||||
protected __onToggle(event: ToggleEvent): void;
|
||||
/**
|
||||
* Checks if the event should be acted upon and if yes, returns the target row, item name and whether
|
||||
* multiselect is active.
|
||||
* @param event The event to check.
|
||||
*/
|
||||
protected __preprocessPointerEvent(event: PointerEvent): TreeBrowsingDisplay.TreePointerEvent;
|
||||
/**
|
||||
* Selects an item.
|
||||
* @param event The event containing information about the item to select. Use null to clear the selection.
|
||||
*/
|
||||
protected __select(event: TreeBrowsingDisplay.RowEvent | null): Promise<void>;
|
||||
/**
|
||||
* Navigates to an item.
|
||||
* @param event The event containing information about the item that should be navigated to.
|
||||
*/
|
||||
protected __navigate(event: TreeBrowsingDisplay.RowEvent): void;
|
||||
/**
|
||||
* Removes all event listeners. Should be called when the owning control is detached or destroyed.
|
||||
* @param clear Set to true to remove all child elements from the path element.
|
||||
*/
|
||||
suspend(clear?: boolean): void;
|
||||
/**
|
||||
* Re-adds event listeners that were previously removed by suspend. Should be called when owning control is reattached.
|
||||
*/
|
||||
resume(): void;
|
||||
/**
|
||||
* Only displays items that contain the given string in their name.
|
||||
* @param term The string to search.
|
||||
* @param caseSensitive Whether to perform a case sensitive search.
|
||||
*/
|
||||
search(term: string | null, caseSensitive?: boolean): void;
|
||||
/**
|
||||
* Marks all elements that match the current search.
|
||||
*/
|
||||
protected __performSearch(): void;
|
||||
/**
|
||||
* Sorts the displayed items.
|
||||
* @param sorting The sorting to apply.
|
||||
* @param caseSensitive Whether to perform a case sensitive sort.
|
||||
*/
|
||||
sort(sorting: TcHmi.SortingInfo[] | null, caseSensitive?: boolean): void;
|
||||
/**
|
||||
* Expands all items.
|
||||
*/
|
||||
expandAll(): void;
|
||||
/**
|
||||
* Collapses all items.
|
||||
*/
|
||||
collapseAll(): void;
|
||||
/**
|
||||
* Processes the directory.
|
||||
*/
|
||||
protected __processDirectory(): void;
|
||||
/**
|
||||
* Render the current directory.
|
||||
*/
|
||||
protected __render(): void;
|
||||
/**
|
||||
* Builds the DOM tree for the given directory. Calls itself recursively.
|
||||
* @param directory The directory to build the DOM tree for.
|
||||
*/
|
||||
protected __buildTree(directory: DirectoryBrowser.FolderLikeItem<unknown, unknown>, path?: string[]): DocumentFragment;
|
||||
}
|
||||
export declare namespace TreeBrowsingDisplay {
|
||||
type TreePointerEvent = RowEvent | ClearEvent | IgnoreEvent;
|
||||
interface RowEvent {
|
||||
type: 'Row';
|
||||
row: HTMLElement;
|
||||
item: DirectoryBrowser.DescendantItem<unknown, unknown>;
|
||||
multiselect: boolean;
|
||||
}
|
||||
interface ClearEvent {
|
||||
type: 'Clear';
|
||||
}
|
||||
interface IgnoreEvent {
|
||||
type: 'Ignore';
|
||||
}
|
||||
}
|
||||
import _TreeBrowsingDisplay = TreeBrowsingDisplay;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TreeBrowsingDisplay: typeof _TreeBrowsingDisplay;
|
||||
type TreeBrowsingDisplay = _TreeBrowsingDisplay;
|
||||
namespace TreeBrowsingDisplay {
|
||||
type TreePointerEvent = _TreeBrowsingDisplay.TreePointerEvent;
|
||||
type RowEvent = _TreeBrowsingDisplay.RowEvent;
|
||||
type ClearEvent = _TreeBrowsingDisplay.ClearEvent;
|
||||
type IgnoreEvent = _TreeBrowsingDisplay.IgnoreEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=TreeBrowsingDisplay.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,178 @@
|
||||
import type { Control as TcHmiTextblock } from '../../../TcHmiTextblock/TcHmiTextblock.esm.js';
|
||||
import type { Control as TcHmiTextbox } from '../../../TcHmiTextbox/TcHmiTextbox.esm.js';
|
||||
import type { Control as TcHmiInput } from '../../../TcHmiInput/TcHmiInput.esm.js';
|
||||
import type { Control as TcHmiPasswordInput } from '../../../TcHmiPasswordInput/TcHmiPasswordInput.esm.js';
|
||||
import type { Control as TcHmiCombobox } from '../../../TcHmiCombobox/TcHmiCombobox.esm.js';
|
||||
import { OkCancelPrompt } from '../../TcHmiPopups/OkCancelPrompt.js';
|
||||
import type { Editor } from '../../TcHmiJsonEditors/BaseEditors/Editor.js';
|
||||
/**
|
||||
* Creates a prompt for writing to a symbol that requires either reauthentication or additional audit trail input like a comment.
|
||||
* Symbol will be written via an isolated websocket and the prompt will ask for reauthentication credentials if
|
||||
* this is required, allow adding further information and adjusting the new value before writing.
|
||||
* This prompt is not meant to be used directly but it is part of the UiProvider.PopupProvider for customization.
|
||||
* The framework will call the prompt via a queue system for any write request to this symbol when its necessary.
|
||||
*/
|
||||
export declare class InteractiveWritePrompt extends OkCancelPrompt<TcHmi.UiProvider.PopupProvider.InteractiveWritePrompt.Value, TcHmi.UiProvider.PopupProvider.InteractiveWritePrompt.Value> {
|
||||
/**
|
||||
* Creates a new InputPrompt instance.
|
||||
* @param parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(symbol: TcHmi.UiProvider.PopupProvider.InteractiveWritePrompt.Symbol, options?: TcHmi.UiProvider.PopupProvider.InteractiveWritePrompt.Options | null, parentControl?: TcHmi.Controls.System.TcHmiControl | null);
|
||||
protected __texts: Partial<InteractiveWritePrompt.LocalizableTexts> | null;
|
||||
protected __controlTextblockMessageGeneral: TcHmiTextblock | null;
|
||||
protected __options: TcHmi.UiProvider.PopupProvider.InteractiveWritePrompt.Options | null;
|
||||
protected __symbolName: string | null;
|
||||
protected __schema: TcHmi.JsonSchema | null;
|
||||
protected __reauthenticationRequired: boolean;
|
||||
protected __reviewerGroups: string[] | null;
|
||||
protected __commentRequired: boolean;
|
||||
protected __domainUserNames: TcHmi.Dictionary<string[]> | null;
|
||||
protected __reviewerDomainUserNames: TcHmi.Dictionary<string[]> | null;
|
||||
protected __defaultDomain: string | null;
|
||||
protected __targetDomain: string | null;
|
||||
protected __targetReviewerDomain: string | null;
|
||||
protected __result: TcHmi.Server.IValueResultObject | undefined;
|
||||
protected __error: TcHmi.IErrorDetails | null;
|
||||
protected __done: boolean;
|
||||
protected __editorNewValue: Editor<any, Editor.EditorInfo> | null;
|
||||
protected __editorPrevValue: Editor<any, Editor.EditorInfo> | null;
|
||||
protected __controlTextblockSymbolName: TcHmiTextblock | null;
|
||||
protected __controlTextblockDescription: TcHmiTextblock | null;
|
||||
protected __controlTextblockMessage: TcHmiTextblock | null;
|
||||
protected __controlTextboxComment: TcHmiTextbox | null;
|
||||
protected __controlInputUsername: TcHmiInput | null;
|
||||
protected __controlComboboxUsername: TcHmiCombobox<string, string[]> | null;
|
||||
protected __controlInputPassword: TcHmiPasswordInput | null;
|
||||
protected __controlTextblockDomainLabel: TcHmiTextblock | null;
|
||||
protected __controlComboboxDomain: TcHmiCombobox<string, string[]> | null;
|
||||
protected __controlTextblockUsernameLabel: TcHmiTextblock | null;
|
||||
protected __controlInputReviewerUsername: TcHmiInput | null;
|
||||
protected __controlComboboxReviewerUsername: TcHmiCombobox<string, string[]> | null;
|
||||
protected __controlInputReviewerPassword: TcHmiPasswordInput | null;
|
||||
protected __controlTextblockReviewerDomainLabel: TcHmiTextblock | null;
|
||||
protected __controlComboboxReviewerDomain: TcHmiCombobox<string, string[]> | null;
|
||||
protected __controlTextblockReviewerUsernameLabel: TcHmiTextblock | null;
|
||||
protected __controlTextblockPrevValueLabel: TcHmiTextblock | null;
|
||||
protected __controlTextblockNewValueLabel: TcHmiTextblock | null;
|
||||
protected __controlTextblockCommentLabel: TcHmiTextblock | null;
|
||||
protected __controlTextblockPasswordLabel: TcHmiTextblock | null;
|
||||
protected __controlTextblockReviewerPasswordLabel: TcHmiTextblock | null;
|
||||
protected __elementContentContainerUser: HTMLElement | null;
|
||||
protected __elementContentContainerReviewer: HTMLElement | null;
|
||||
protected __elementContentContainerValue: HTMLElement | null;
|
||||
protected __elementContentContainerAdditionalInformation: HTMLElement | null;
|
||||
protected __elementHeadlineUser: HTMLElement | null;
|
||||
protected __elementHeadlineReviewer: HTMLElement | null;
|
||||
protected __elementHeadlineValue: HTMLElement | null;
|
||||
protected __elementHeadlineAdditionalInformation: HTMLElement | null;
|
||||
protected __elementNewValueEditorContainer: HTMLElement | null;
|
||||
protected __elementPrevValueEditorContainer: HTMLElement | null;
|
||||
protected __elementProgressContainer: HTMLElement | null;
|
||||
protected __elementLoadingSpinnerContainerContainer: HTMLElement | null;
|
||||
protected __destroyComboboxDomainSelectionChanged: TcHmi.DestroyFunction | null;
|
||||
protected __destroyReviewerComboboxDomainSelectionChanged: TcHmi.DestroyFunction | null;
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
* @param force If true, child controls will be removed from the parent control before destruction, to ensure destruction in case of keepAlive === true.
|
||||
*/
|
||||
destroy(force?: boolean): void;
|
||||
/**
|
||||
* Raised when domain selection changes.
|
||||
*/
|
||||
protected __onComboboxDomainSelectionChanged(_event: TcHmi.EventProvider.Event, data: {
|
||||
id: number | null;
|
||||
text: string | null;
|
||||
value: any;
|
||||
}): void;
|
||||
/**
|
||||
* Raised when domain selection changes.
|
||||
*/
|
||||
protected __onComboboxReviewerDomainSelectionChanged(_event: TcHmi.EventProvider.Event, data: {
|
||||
id: number | null;
|
||||
text: string | null;
|
||||
value: any;
|
||||
}): void;
|
||||
/**
|
||||
* Performs the action for the OK button, i.e. calling prompt.answer().
|
||||
*/
|
||||
protected __ok(): void;
|
||||
/**
|
||||
* Performs the action for the Cancel button.
|
||||
*/
|
||||
protected __cancel(): void;
|
||||
/**
|
||||
* Shows an overall error message
|
||||
* @param message
|
||||
*/
|
||||
protected __showError(message: string): void;
|
||||
/**
|
||||
* Clear existing overall error message
|
||||
* @param message
|
||||
*/
|
||||
protected __clearError(): void;
|
||||
/**
|
||||
* Enables all controls for a specified symbol area.
|
||||
* @param symbol
|
||||
*/
|
||||
protected __enableSymbolControls(): void;
|
||||
/**
|
||||
* Disables all controls for a specified symbol area.
|
||||
* @param symbol
|
||||
*/
|
||||
protected __disableSymbolControls(): void;
|
||||
/**
|
||||
* Enables all controls for a specified symbol area.
|
||||
* @param focus Controls whether focus should be moved to one of the popups inputs.
|
||||
*/
|
||||
protected __showSymbolControls(focus?: boolean): void;
|
||||
/**
|
||||
* Disables all controls for a specified symbol area.
|
||||
* @param symbol
|
||||
*/
|
||||
protected __hideSymbolControls(): void;
|
||||
/**
|
||||
* Shows the loading state for a symbol area.
|
||||
* @param symbol
|
||||
*/
|
||||
protected __showSymbolLoading(): void;
|
||||
/**
|
||||
* Shows an error message for a specified symbol area and disables all related controls.
|
||||
* @param symbol
|
||||
* @param message
|
||||
*/
|
||||
protected __showSymbolError(message: string): void;
|
||||
/**
|
||||
* Clears an error message for a specified symbol area and enables all related controls.
|
||||
* @param symbol
|
||||
* @param message
|
||||
*/
|
||||
protected __showSymbolSuccess(): void;
|
||||
/**
|
||||
* Clears an error message for a specified symbol area and enables all related controls.
|
||||
* @param symbol
|
||||
* @param message
|
||||
*/
|
||||
protected __showSymbolReady(): void;
|
||||
/**
|
||||
*
|
||||
* @param texts
|
||||
*/
|
||||
setTexts(texts: Partial<InteractiveWritePrompt.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace InteractiveWritePrompt {
|
||||
interface LocalizableTexts extends OkCancelPrompt.LocalizableTexts {
|
||||
headerText: TcHmi.Localizable;
|
||||
editorTexts: Partial<Editor.LocalizableTexts>;
|
||||
}
|
||||
}
|
||||
import _InteractiveWritePrompt = InteractiveWritePrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let InteractiveWritePrompt: typeof _InteractiveWritePrompt;
|
||||
type InteractiveWritePrompt = _InteractiveWritePrompt;
|
||||
namespace InteractiveWritePrompt {
|
||||
type LocalizableTexts = _InteractiveWritePrompt.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=InteractiveWritePrompt.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,76 @@
|
||||
import { ButtonBasedEditor } from './ButtonBasedEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import { Editor } from './Editor.js';
|
||||
/**
|
||||
* Editor for arrays.
|
||||
*/
|
||||
export declare class ArrayEditor extends ButtonBasedEditor<any[], ArrayEditor.Info> {
|
||||
protected __value: any[];
|
||||
/**
|
||||
* Create a new array editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: ArrayEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: ArrayEditor.Info, value: any): value is any[];
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: ArrayEditor.Info, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: any[] | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): any[];
|
||||
/**
|
||||
* Opens the popup for the editor.
|
||||
*/
|
||||
protected openPopup(): Promise<void>;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ArrayEditor {
|
||||
interface Info extends Editor.Info<any[]> {
|
||||
type: 'array';
|
||||
items: Editor.EditorInfo;
|
||||
minItems?: number;
|
||||
maxItems?: number;
|
||||
uniqueItems: boolean;
|
||||
}
|
||||
}
|
||||
import _ArrayEditor = ArrayEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ArrayEditor: typeof _ArrayEditor;
|
||||
type ArrayEditor = _ArrayEditor;
|
||||
namespace ArrayEditor {
|
||||
type Info = _ArrayEditor.Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ArrayEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ButtonBasedEditor}from"./ButtonBasedEditor.js";import{Editor}from"./Editor.js";import{ArrayEditorPrompt}from"../Popups/ArrayEditorPrompt.js";export class ArrayEditor extends ButtonBasedEditor{__value=[];constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__processEditorInfo()}destroy(){super.destroy(),this.__popup?.destroy(!0)}static validate(editorInfo,value){return 0===ArrayEditor.checkForErrors(editorInfo,value,!0).length}static checkForErrors(editorInfo,value,returnEarly=!1){if(!Array.isArray(value))return[{error:Editor.Error.NOT_AN_ARRAY,parameters:[value]}];if(null!==Object.getPrototypeOf(value)&&Object.getPrototypeOf(value)!==Object.getPrototypeOf([]))return[{error:Editor.Error.ARRAY_HAS_INVALID_PROTOTYPE,parameters:[value]}];const errors=[];if(void 0!==editorInfo.minItems&&value.length<editorInfo.minItems&&(errors.push({error:Editor.Error.ARRAY_HAS_TOO_FEW_ITEMS,parameters:[value,editorInfo.minItems,value.length]}),returnEarly))return errors;if(void 0!==editorInfo.maxItems&&value.length>editorInfo.maxItems&&(errors.push({error:Editor.Error.ARRAY_HAS_TOO_MANY_ITEMS,parameters:[value,editorInfo.maxItems,value.length]}),returnEarly))return errors;for(const[index,item]of value.entries()){const underlyingErrors=Editor.checkForErrors(editorInfo.items,item,returnEarly);if(underlyingErrors.length>0&&(errors.push({error:Editor.Error.ARRAY_CONTAINS_INVALID_VALUE,parameters:[value,index],underlying:underlyingErrors}),returnEarly))return errors}if(editorInfo.uniqueItems)for(let i=0,ii=value.length-1;i<ii;i++){const duplicateIndices=[i];for(let j=i+1,jj=value.length;j<jj;j++)if(tchmi_equal(value[i],value[j],{compareDates:!0})&&(duplicateIndices.push(j),returnEarly))return[{error:Editor.Error.ARRAY_CONTAINS_DUPLICATE_ITEMS,parameters:[value,duplicateIndices]}];duplicateIndices.length>1&&errors.push({error:Editor.Error.ARRAY_CONTAINS_DUPLICATE_ITEMS,parameters:[value,duplicateIndices]})}return errors}__processEditorInfo(){this.__popup?.setEditorInfo(this.__editorInfo),this.__textSpan.textContent=this.__editorInfo.name,this.__container.classList.toggle("invalid",!this.getState().isValid)}setValue(value){this.__value=value??[],this.__popup?.setValue(value);const state=this.getState();this.__container.classList.toggle("invalid",!state.isValid),this.__onChangeManager.trigger(this,state)}getRawValue(){return this.__value}async openPopup(){this.__popup||(this.__popup=new ArrayEditorPrompt(this.__editorInfo,this.__factory),this.__popup.setBackgroundAction({close:!0,action:"cancel"}),this.__popup.setIsReadOnly(this.__isReadOnly),this.__popup.setSettings(this.__settings),this.__popup.setLocalizations({buttonTextOk:this.__localizations?.arrayEditorPrompt?.buttonTextOk??this.__localizations?.editorPrompt?.buttonTextOk,buttonTooltipOk:this.__localizations?.arrayEditorPrompt?.buttonTooltipOk??this.__localizations?.editorPrompt?.buttonTooltipOk,buttonTextCancel:this.__localizations?.arrayEditorPrompt?.buttonTextCancel??this.__localizations?.editorPrompt?.buttonTextCancel,buttonTooltipCancel:this.__localizations?.arrayEditorPrompt?.buttonTooltipCancel??this.__localizations?.editorPrompt?.buttonTooltipCancel,editorLocalizations:this.__localizations}));try{this.__popup.setValue(this.__value);const result=await this.__popup.prompt();if(result.isOk){this.__value=result.value;const state=this.getState();this.__container.classList.toggle("invalid",!state.isValid),this.__onChangeManager.trigger(this,state),state.isValid&&this.__onConfirmManager.trigger(this,state)}}catch(ex){}}setLocalizations(texts){super.setLocalizations(texts),this.__popup?.setLocalizations({buttonTextOk:this.__localizations?.arrayEditorPrompt?.buttonTextOk??this.__localizations?.editorPrompt?.buttonTextOk,buttonTooltipOk:this.__localizations?.arrayEditorPrompt?.buttonTooltipOk??this.__localizations?.editorPrompt?.buttonTooltipOk,buttonTextCancel:this.__localizations?.arrayEditorPrompt?.buttonTextCancel??this.__localizations?.editorPrompt?.buttonTextCancel,buttonTooltipCancel:this.__localizations?.arrayEditorPrompt?.buttonTooltipCancel??this.__localizations?.editorPrompt?.buttonTooltipCancel,editorLocalizations:this.__localizations})}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.ArrayEditor=ArrayEditor;
|
||||
@@ -0,0 +1,78 @@
|
||||
import { ComboboxBasedEditor } from './ComboboxBasedEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import { Editor } from './Editor.js';
|
||||
/**
|
||||
* Editor for booleans.
|
||||
*/
|
||||
export declare class BooleanEditor extends ComboboxBasedEditor<boolean, BooleanEditor.Info> {
|
||||
protected __comboboxTexts: {
|
||||
false: string;
|
||||
true: string;
|
||||
};
|
||||
/**
|
||||
* Create a new boolean editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: BooleanEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param _editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(_editorInfo: BooleanEditor.Info, value: any): value is boolean;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param _editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param _returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(_editorInfo: BooleanEditor.Info, value: any, _returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: boolean | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): boolean | null;
|
||||
/**
|
||||
* Updates the combobox srcData with current texts.
|
||||
*/
|
||||
protected __updateSrcData(): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace BooleanEditor {
|
||||
interface Info extends Editor.Info<boolean> {
|
||||
type: 'boolean';
|
||||
}
|
||||
type LocalizableTexts = {
|
||||
booleanEditor: Partial<{
|
||||
falseText: TcHmi.Localizable;
|
||||
trueText: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _BooleanEditor = BooleanEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let BooleanEditor: typeof _BooleanEditor;
|
||||
type BooleanEditor = _BooleanEditor;
|
||||
namespace BooleanEditor {
|
||||
type Info = _BooleanEditor.Info;
|
||||
type LocalizableTexts = _BooleanEditor.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=BooleanEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ComboboxBasedEditor}from"./ComboboxBasedEditor.js";import{Editor}from"./Editor.js";export class BooleanEditor extends ComboboxBasedEditor{__comboboxTexts={false:"",true:""};constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__updateSrcData()}static validate(_editorInfo,value){return"boolean"==typeof value}static checkForErrors(_editorInfo,value,_returnEarly=!1){return"boolean"!=typeof value?[{error:Editor.Error.NOT_A_BOOLEAN}]:[]}__processEditorInfo(){}setValue(value){switch(value){case!1:this.__combobox.setSelectedIndex(0);break;case!0:this.__combobox.setSelectedIndex(1);break;default:this.__combobox.setSelectedIndex(null)}}getRawValue(){return this.__combobox.getSelectedValue()}__updateSrcData(){this.__combobox.setSrcData([{value:!1,text:this.__comboboxTexts.false},{value:!0,text:this.__comboboxTexts.true}])}setLocalizations(texts){super.setLocalizations(texts);let update=!1;this.__localizations&&(this.__localizations.booleanEditor?.falseText&&("string"==typeof this.__localizations.booleanEditor.falseText?(this.__comboboxTexts.false=this.__localizations.booleanEditor.falseText,update=!0):this.__watchLocalization("falseText",this.__localizations.booleanEditor.falseText,text=>{this.__comboboxTexts.false=text,this.__updateSrcData()})),this.__localizations.booleanEditor?.trueText&&("string"==typeof this.__localizations.booleanEditor.trueText?(this.__comboboxTexts.true=this.__localizations.booleanEditor.trueText,update=!0):this.__watchLocalization("trueText",this.__localizations.booleanEditor.trueText,text=>{this.__comboboxTexts.true=text,this.__updateSrcData()}))),update&&this.__updateSrcData()}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.BooleanEditor=BooleanEditor;
|
||||
@@ -0,0 +1,70 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import type { Control as TcHmiButton } from '../../../TcHmiButton/TcHmiButton.esm.js';
|
||||
import type { EditorPrompt } from '../Popups/EditorPrompt.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor that is based on a button to open a popup for complex datatypes.
|
||||
*/
|
||||
export declare abstract class ButtonBasedEditor<T, I extends Editor.EditorInfo = Editor.EditorInfo> extends Editor<T, I> {
|
||||
protected __container: HTMLDivElement;
|
||||
protected __textSpan: HTMLSpanElement;
|
||||
protected __button: TcHmiButton;
|
||||
protected __popup?: EditorPrompt<T, I>;
|
||||
/**
|
||||
* Create a new button based editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: I, factory: EditorFactory);
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Event handler for the onPressed event of the button.
|
||||
*/
|
||||
protected __onPressed(): void;
|
||||
/**
|
||||
* Starts editing by opening the popup.
|
||||
*/
|
||||
startEditing(): void;
|
||||
/**
|
||||
* Opens the popup for the editor.
|
||||
*/
|
||||
protected abstract openPopup(): Promise<void>;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<Editor.EditorSettings & S>): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ButtonBasedEditor {
|
||||
type LocalizableTexts = {
|
||||
buttonBasedEditor: Partial<{
|
||||
buttonTooltip: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _ButtonBasedEditor = ButtonBasedEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ButtonBasedEditor: typeof _ButtonBasedEditor;
|
||||
type ButtonBasedEditor<T, I extends Editor.EditorInfo = Editor.EditorInfo> = _ButtonBasedEditor<T, I>;
|
||||
namespace ButtonBasedEditor {
|
||||
type LocalizableTexts = _ButtonBasedEditor.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ButtonBasedEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
var __runInitializers=this&&this.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=this&&this.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(void 0!==f&&"function"!=typeof f)throw new TypeError("Function expected");return f}for(var _,kind=contextIn.kind,key="getter"===kind?"get":"setter"===kind?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]="access"===p?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])("accessor"===kind?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if("accessor"===kind){if(void 0===result)continue;if(null===result||"object"!=typeof result)throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&("field"===kind?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};import{Editor}from"./Editor.js";let ButtonBasedEditor=(()=>{var _a;let ___onPressed_decorators,_classSuper=Editor,_instanceExtraInitializers=[];return class extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onPressed_decorators=[(_a=TcHmi).CallbackMethod.bind(_a)],__esDecorate(this,null,___onPressed_decorators,{kind:"method",name:"__onPressed",static:!1,private:!1,access:{has:obj=>"__onPressed"in obj,get:obj=>obj.__onPressed},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}__container=__runInitializers(this,_instanceExtraInitializers);__textSpan;__button;__popup;constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__container=document.createElement("div"),this.__container.classList.add("compound-control-container","with-validation"),this.__textSpan=document.createElement("span"),this.__textSpan.classList.add("value-description"),this.__container.appendChild(this.__textSpan);const button=TcHmi.ControlFactory.createEx("TcHmi.Controls.Beckhoff.TcHmiButton",`${this.__name}.button`,{"data-tchmi-width":26,"data-tchmi-height":100,"data-tchmi-height-unit":"%","data-tchmi-text":"..."},this.__parentControl);if(!button)throw new Error("Could not create controls for button based editor.");this.__button=button,this.__childControls.add(button),this.__container.appendChild(button.getElement()[0]),this.__element.appendChild(this.__container),this.__eventDestroyers.push(TcHmi.EventProvider.register(button.getId()+".onPressed",this.__onPressed))}destroy(){TcHmi.Binding.removeEx2(null,"Tooltip",this.__button),super.destroy()}__onPressed(){if(this.__parentControl){if(!this.__parentControl.getIsEnabled())return;if(!TcHmi.Access.checkAccess(this.__parentControl,"operate"))return}this.openPopup()}startEditing(){this.openPopup()}__processIsReadOnly(){this.__popup?.setIsReadOnly(this.__isReadOnly)}setSettings(settings){super.setSettings(settings),this.__popup?.setSettings(this.__settings)}setLocalizations(texts){super.setLocalizations(texts),this.__localizations&&this.__localizations.buttonBasedEditor?.buttonTooltip&&("string"==typeof this.__localizations.buttonBasedEditor.buttonTooltip?(this.__unwatchLocalization("buttonTooltip"),TcHmi.Binding.createEx2(this.__localizations.buttonBasedEditor.buttonTooltip,"Tooltip",this.__button)):(TcHmi.Binding.removeEx2(null,"Tooltip",this.__button),this.__watchLocalization("buttonTooltip",this.__localizations.buttonBasedEditor.buttonTooltip,text=>this.__button.setTooltip(text)))),this.__popup?.setLocalizations({buttonTextOk:this.__localizations?.editorPrompt?.buttonTextOk,buttonTooltipOk:this.__localizations?.editorPrompt?.buttonTooltipOk,buttonTextCancel:this.__localizations?.editorPrompt?.buttonTextCancel,buttonTooltipCancel:this.__localizations?.editorPrompt?.buttonTooltipCancel,editorLocalizations:this.__localizations})}}})();export{ButtonBasedEditor};TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.ButtonBasedEditor=ButtonBasedEditor;
|
||||
@@ -0,0 +1,125 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import type { Control as TcHmiCombobox } from '../../../TcHmiCombobox/TcHmiCombobox.esm.js';
|
||||
/**
|
||||
* Editor for types that offer a choice. Usually used for anyOf or oneOf schemas.
|
||||
*/
|
||||
export declare class ChoiceEditor extends Editor<any, ChoiceEditor.Info> {
|
||||
protected __value: any;
|
||||
protected __container: HTMLDivElement;
|
||||
protected __combobox: TcHmiCombobox<unknown>;
|
||||
protected __editors: Map<Editor.EditorType, {
|
||||
editor: Editor<any>;
|
||||
container: HTMLDivElement;
|
||||
}>;
|
||||
protected __activeEditor: {
|
||||
editor: Editor<any>;
|
||||
container: HTMLDivElement;
|
||||
} | null;
|
||||
/**
|
||||
* Create a new choice editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: ChoiceEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Create a choice editor info that allows any type.
|
||||
* @param ref Can be passed in to be filled out.
|
||||
*/
|
||||
static createAnyEditorInfo(ref?: Editor.Info<any>): ChoiceEditor.Info;
|
||||
/**
|
||||
* Create a choice editor info that allows any type.
|
||||
*/
|
||||
static getAnyChoices(): Exclude<ChoiceEditor.Info['choices'], undefined>;
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: ChoiceEditor.Info, value: any): value is any;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: ChoiceEditor.Info, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Starts editing by opening the drop down of the type selection combobox.
|
||||
*/
|
||||
startEditing(): void;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Handler for the selectionChanged event of the combobox
|
||||
*/
|
||||
protected __onSelectionChanged(): void;
|
||||
/**
|
||||
* Handler for the change event of the editor.
|
||||
* @param editor The editor that changed.
|
||||
* @param state The state of the editor that changed.
|
||||
*/
|
||||
protected __onEditorChanged(editor: Editor<any>, state: Editor.State<any>): void;
|
||||
/**
|
||||
* Handler for the confirm event of the editor.
|
||||
* @param _editor The editor that was confirmed.
|
||||
* @param state The state of the editor that was confirmed.
|
||||
*/
|
||||
protected __onEditorConfirmed(_editor: Editor<any>, state: Editor.ValidState<any>): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: any | null): void;
|
||||
/**
|
||||
* Gets the current value.
|
||||
*/
|
||||
getState(): Editor.State<any>;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): any;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<Editor.EditorSettings & S>): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ChoiceEditor {
|
||||
interface Info extends Editor.Info<any> {
|
||||
type: 'choice';
|
||||
choices?: Exclude<Editor.EditorInfo, Info>[];
|
||||
}
|
||||
type LocalizableTexts = {
|
||||
choiceEditor: Partial<{
|
||||
comboboxText: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _ChoiceEditor = ChoiceEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ChoiceEditor: typeof _ChoiceEditor;
|
||||
type ChoiceEditor = _ChoiceEditor;
|
||||
namespace ChoiceEditor {
|
||||
type Info = _ChoiceEditor.Info;
|
||||
type LocalizableTexts = _ChoiceEditor.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ChoiceEditor.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,38 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import type { Control as TcHmiCombobox, ListItemGeneric as TcHmiCombobox_ListItemGeneric } from '../../../TcHmiCombobox/TcHmiCombobox.esm.js';
|
||||
/**
|
||||
* Editor that is based on a combobox like for enums and booleans.
|
||||
*/
|
||||
export declare abstract class ComboboxBasedEditor<T, I extends Editor.EditorInfo = Editor.EditorInfo> extends Editor<T, I> {
|
||||
protected __combobox: TcHmiCombobox<T, TcHmiCombobox_ListItemGeneric<T>[]>;
|
||||
/**
|
||||
* Create a new combobox based editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: I, factory: EditorFactory);
|
||||
/**
|
||||
* Starts editing by opening the drop down.
|
||||
*/
|
||||
startEditing(): void;
|
||||
/**
|
||||
* Event handler for the onSelectionChanged event of the combobox.
|
||||
*/
|
||||
protected __onSelectionChanged(): void;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
}
|
||||
declare const _ComboboxBasedEditor: typeof ComboboxBasedEditor;
|
||||
type tComboboxBasedEditor<T, I extends Editor.EditorInfo = Editor.EditorInfo> = ComboboxBasedEditor<T, I>;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ComboboxBasedEditor: typeof _ComboboxBasedEditor;
|
||||
type ComboboxBasedEditor<T, I extends Editor.EditorInfo = Editor.EditorInfo> = tComboboxBasedEditor<T, I>;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=ComboboxBasedEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
var __runInitializers=this&&this.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=this&&this.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(void 0!==f&&"function"!=typeof f)throw new TypeError("Function expected");return f}for(var _,kind=contextIn.kind,key="getter"===kind?"get":"setter"===kind?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]="access"===p?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])("accessor"===kind?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if("accessor"===kind){if(void 0===result)continue;if(null===result||"object"!=typeof result)throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&("field"===kind?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};import{Editor}from"./Editor.js";let ComboboxBasedEditor=(()=>{var _a;let ___onSelectionChanged_decorators,_classSuper=Editor,_instanceExtraInitializers=[];return class extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onSelectionChanged_decorators=[(_a=TcHmi).CallbackMethod.bind(_a)],__esDecorate(this,null,___onSelectionChanged_decorators,{kind:"method",name:"__onSelectionChanged",static:!1,private:!1,access:{has:obj=>"__onSelectionChanged"in obj,get:obj=>obj.__onSelectionChanged},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}__combobox=__runInitializers(this,_instanceExtraInitializers);constructor(element,editorInfo,factory){super(element,editorInfo,factory);const combobox=TcHmi.ControlFactory.createEx("TcHmi.Controls.Beckhoff.TcHmiCombobox",`${this.__name}.combobox`,{"data-tchmi-content-padding":{top:3,right:3,bottom:3,left:3}},this.__parentControl);if(!combobox)throw new Error("Could not create controls for combobox based editor.");this.__combobox=combobox,this.__childControls.add(combobox);const comboboxElement=combobox.getElement()[0];comboboxElement.classList.add("with-validation","invalid"),this.__element.appendChild(comboboxElement),this.__eventDestroyers.push(TcHmi.EventProvider.register(combobox.getId()+".onSelectionChanged",this.__onSelectionChanged))}startEditing(){this.__combobox.focus(),this.__combobox.open()}__onSelectionChanged(){if(this.__parentControl){if(!this.__parentControl.getIsEnabled())return;if(!TcHmi.Access.checkAccess(this.__parentControl,"operate"))return}const state=this.getState();this.__combobox.getElement()[0].classList.toggle("invalid",!state.isValid),this.__onChangeManager.trigger(this,state),state.isValid&&this.__onConfirmManager.trigger(this,state)}__processIsReadOnly(){this.__combobox.setIsReadOnly(this.__isReadOnly)}}})();export{ComboboxBasedEditor};TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.ComboboxBasedEditor=ComboboxBasedEditor;
|
||||
@@ -0,0 +1,321 @@
|
||||
import { Callback, type TcHmiControl } from 'Beckhoff.TwinCAT.HMI.Framework/index.esm.js';
|
||||
import type { ButtonBasedEditor } from '../BaseEditors/ButtonBasedEditor.js';
|
||||
import type { BooleanEditor } from '../BaseEditors/BooleanEditor.js';
|
||||
import type { NumberEditor } from '../BaseEditors/NumberEditor.js';
|
||||
import type { StringEditor } from '../BaseEditors/StringEditor.js';
|
||||
import type { TimeEditor } from '../BaseEditors/TimeEditor.js';
|
||||
import type { EnumEditor } from '../BaseEditors/EnumEditor.js';
|
||||
import type { ObjectEditor } from '../BaseEditors/ObjectEditor.js';
|
||||
import type { ArrayEditor } from '../BaseEditors/ArrayEditor.js';
|
||||
import type { TupleEditor } from '../BaseEditors/TupleEditor.js';
|
||||
import type { OptionalEditor } from '../BaseEditors/OptionalEditor.js';
|
||||
import type { ChoiceEditor } from '../BaseEditors/ChoiceEditor.js';
|
||||
import type { NullEditor } from '../BaseEditors/NullEditor.js';
|
||||
import type { InvalidEditor } from '../BaseEditors/InvalidEditor.js';
|
||||
import type { ArrayBasedEditorPane } from '../BaseEditors/EditorPanes/ArrayBasedEditorPane.js';
|
||||
import type { ObjectEditorPane } from '../BaseEditors/EditorPanes/ObjectEditorPane.js';
|
||||
import { EditorFactory } from '../EditorFactory.js';
|
||||
import type { EditorPrompt } from '../Popups/EditorPrompt.js';
|
||||
import type { TextboxBasedEditor } from '../BaseEditors/TextboxBasedEditor.js';
|
||||
/**
|
||||
* Base editor class.
|
||||
*/
|
||||
export declare abstract class Editor<T, I extends Editor.EditorInfo = Editor.EditorInfo> {
|
||||
#private;
|
||||
protected __element: HTMLElement;
|
||||
protected __editorInfo: I;
|
||||
protected __factory: EditorFactory;
|
||||
protected __parentControl: TcHmiControl.Control | null;
|
||||
protected __name: string;
|
||||
protected readonly __className = "TcHmi_Controls_Helpers_Editor";
|
||||
protected __childControls: Set<TcHmi.Controls.System.TcHmiControl>;
|
||||
protected __eventDestroyers: TcHmi.DestroyFunction[];
|
||||
protected __isEnabled: boolean;
|
||||
protected __visibility: 'Visible' | 'Hidden' | 'Collapsed';
|
||||
protected __isReadOnly: boolean;
|
||||
protected __settings: Partial<Editor.Settings>;
|
||||
protected __localizations: Partial<Editor.LocalizableTexts & Editor.Localizables> | undefined;
|
||||
protected __localizationSymbols: Map<string, {
|
||||
symbol: TcHmi.Symbol<string>;
|
||||
destroyWatch: TcHmi.DestroyFunction;
|
||||
}>;
|
||||
protected readonly __onChangeManager: Callback.Collection<(editor: Editor<T, I>, state: Editor.State<T>) => void>;
|
||||
readonly onChange: Readonly<{
|
||||
add: (callback: (editor: Editor<T, I>, state: Editor.State<T>) => void) => () => void;
|
||||
remove: (callback: (editor: Editor<T, I>, state: Editor.State<T>) => void) => void;
|
||||
}>;
|
||||
protected readonly __onConfirmManager: Callback.Collection<(editor: Editor<T, I>, state: Editor.ValidState<T>) => void>;
|
||||
readonly onConfirm: Readonly<{
|
||||
add: (callback: (editor: Editor<T, I>, state: Editor.ValidState<T>) => void) => () => void;
|
||||
remove: (callback: (editor: Editor<T, I>, state: Editor.ValidState<T>) => void) => void;
|
||||
}>;
|
||||
/**
|
||||
* Create a new editor.
|
||||
* @param __element The element to contain the editor.
|
||||
* @param __editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param __factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(__element: HTMLElement, __editorInfo: I, __factory: EditorFactory);
|
||||
/**
|
||||
* Create a new editor for the given editor info.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param parentControl The control owning the editor.
|
||||
* @param localizations A collection of localization symbols to display texts in the editor.
|
||||
*/
|
||||
static create(element: HTMLElement, editorInfo: Editor.EditorInfo, parentControl?: TcHmiControl.Control | null, localizations?: Partial<Editor.LocalizableTexts>): Editor<any, _Editor.EditorInfo>;
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Sets the editorInfo.
|
||||
* @param editorInfo The editorInfo to set.
|
||||
*/
|
||||
setEditorInfo(editorInfo: I): void;
|
||||
/**
|
||||
* Gets the editor info.
|
||||
*/
|
||||
getEditorInfo(): I;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected abstract __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
abstract setValue(value: T | null): void;
|
||||
/**
|
||||
* Gets the current value.
|
||||
*/
|
||||
getState(): Editor.State<T>;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid. To get the final actual value, always use getState.
|
||||
*/
|
||||
abstract getRawValue(): any;
|
||||
/**
|
||||
* Prepares the editor so that the user can immediately start editing,
|
||||
* for example by focusing a textbox or opening a combobox.
|
||||
*/
|
||||
startEditing?(): void;
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: Editor.EditorInfo, value: any): boolean;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: Editor.EditorInfo, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Enable or disable the editor. Disabled editors are greyed out and cannot be interacted with.
|
||||
* @param isEnabled Whether the editor should be enabled or disabled.
|
||||
*/
|
||||
setIsEnabled(isEnabled: boolean): void;
|
||||
/**
|
||||
* Get whether the editor is enabled or disabled.
|
||||
*/
|
||||
getIsEnabled(): boolean;
|
||||
/**
|
||||
* Define the editor visibility.
|
||||
* @param visibility Visibility
|
||||
*/
|
||||
setVisibility(visibility: 'Visible' | 'Hidden' | 'Collapsed'): void;
|
||||
/**
|
||||
* Get editor visibility
|
||||
*/
|
||||
getVisibility(): "Visible" | "Hidden" | "Collapsed";
|
||||
/**
|
||||
* Set the editors read-only status. A read-only editor will display values, but not allow the user to change
|
||||
* them.
|
||||
* @param isReadOnly Whether the editor should be in read-only mode or not.
|
||||
*/
|
||||
setIsReadOnly(isReadOnly: boolean): void;
|
||||
/**
|
||||
* Get whether the editor is in read-only mode.
|
||||
*/
|
||||
getIsReadOnly(): boolean;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<Editor.EditorSettings & S>): void;
|
||||
/**
|
||||
* Get the current editor settings.
|
||||
*/
|
||||
getSettings<S extends Editor.Settings = Editor.Settings>(): Partial<Editor.EditorSettings & S>;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected abstract __processIsReadOnly(): void;
|
||||
/**
|
||||
* Builds an error message from the validation errors in an editor state.
|
||||
* @param state The state to build the message from.
|
||||
* @param maxDepth The maximum depth of errors that should be included in the message.
|
||||
*/
|
||||
protected __buildValidationMessage(state: Editor.State<T>, maxDepth?: number): string;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<Editor.LocalizableTexts & L>): void;
|
||||
/**
|
||||
* Watch the given symbol and call the onChange callback every time it changes with the resolved and formatted symbol value.
|
||||
* @param name The name for this symbol. Must be unique across all inheritance layers and further calls for the same localization must use the same name.
|
||||
* @param localization The localization to watch.
|
||||
* @param onChange The callback that is called with the localized and formatted text as a parameter.
|
||||
*/
|
||||
protected __watchLocalization(name: string, localization: TcHmi.FormattedLocalizable, onChange: (localizedText: string) => void): void;
|
||||
/**
|
||||
* Destroys the localization watch with the given name, if it exists.
|
||||
* @param name The name that was used with __watchLoclalization to start watching the symbol.
|
||||
*/
|
||||
protected __unwatchLocalization(name: string): void;
|
||||
}
|
||||
export declare namespace Editor {
|
||||
type Constructor<T, I extends EditorInfo = EditorInfo> = new (element: HTMLElement, editorInfo: I, factory: EditorFactory) => Editor<T, I>;
|
||||
type GenericConstructor<E extends Editor<T, I>, T, I extends EditorInfo = EditorInfo> = new (element: HTMLElement, editorInfo: I, factory: EditorFactory) => E;
|
||||
interface Info<T> {
|
||||
type: EditorType;
|
||||
schema: TcHmi.JsonSchema;
|
||||
name: string;
|
||||
defaultValue?: T;
|
||||
}
|
||||
type EditorType = 'boolean' | 'number' | 'string' | 'time' | 'enum' | 'object' | 'array' | 'tuple' | 'optional' | 'choice' | 'null' | 'invalid';
|
||||
type EditorInfo = BooleanEditor.Info | NumberEditor.Info | StringEditor.Info | TimeEditor.Info | EnumEditor.Info | ObjectEditor.Info | ArrayEditor.Info | TupleEditor.Info | OptionalEditor.Info<unknown> | ChoiceEditor.Info | NullEditor.Info | InvalidEditor.Info;
|
||||
type State<T> = InvalidState | ValidState<T>;
|
||||
interface InvalidState {
|
||||
isValid: false;
|
||||
errors?: ErrorDetail[];
|
||||
}
|
||||
interface ValidState<T> {
|
||||
isValid: true;
|
||||
value: T;
|
||||
}
|
||||
enum Error {
|
||||
ERROR = 1,
|
||||
RESTRICTION_ERROR = 10,
|
||||
FAILS_ALL_RESTRICTIONS = 11,
|
||||
FAILS_THIS_RESTRICTION = 12,
|
||||
TYPE_ERROR = 20,
|
||||
NOT_A_BOOLEAN = 21,
|
||||
NOT_A_NUMBER = 22,
|
||||
NOT_A_STRING = 23,
|
||||
NOT_AN_OBJECT = 24,
|
||||
NOT_AN_ARRAY = 25,
|
||||
NOT_NULL = 26,
|
||||
BOOLEAN_ERROR = 40,
|
||||
NUMBER_ERROR = 60,
|
||||
NUMBER_TOO_SMALL = 61,
|
||||
NUMBER_TOO_BIG = 62,
|
||||
NUMBER_NOT_MULTIPLE_OF = 63,
|
||||
NUMBER_NOT_INTEGER = 64,
|
||||
NUMBER_NOT_FINITE = 65,
|
||||
STRING_ERROR = 80,
|
||||
STRING_TOO_SHORT = 81,
|
||||
STRING_TOO_LONG = 82,
|
||||
STRING_DOES_NOT_MATCH = 83,
|
||||
STRING_NOT_DATE_TIME = 84,
|
||||
STRING_NOT_TIMESPAN = 85,
|
||||
STRING_NOT_EMAIL = 86,
|
||||
STRING_NOT_HOSTNAME = 87,
|
||||
STRING_NOT_IPV4 = 88,
|
||||
STRING_NOT_IPV6 = 89,
|
||||
STRING_NOT_URI = 90,
|
||||
OBJECT_ERROR = 100,
|
||||
OBJECT_HAS_TOO_FEW_PROPERTIES = 101,
|
||||
OBJECT_HAS_TOO_MANY_PROPERTIES = 102,
|
||||
OBJECT_IS_MISSING_PROPERTY = 103,
|
||||
OBJECT_CONTAINS_INVALID_PROPERTY_NAME = 104,
|
||||
OBJECT_CONTAINS_INVALID_VALUE = 105,
|
||||
OBJECT_HAS_INVALID_PROTOTYPE = 106,
|
||||
OBJECT_HAS_INVALID_DEPENDENCY = 107,
|
||||
ARRAY_ERROR = 120,
|
||||
ARRAY_HAS_TOO_FEW_ITEMS = 121,
|
||||
ARRAY_HAS_TOO_MANY_ITEMS = 122,
|
||||
ARRAY_CONTAINS_INVALID_VALUE = 123,
|
||||
ARRAY_CONTAINS_DUPLICATE_ITEMS = 124,
|
||||
ARRAY_HAS_INVALID_PROTOTYPE = 125,
|
||||
TUPLE_ERROR = 140,
|
||||
ENUM_ERROR = 160,
|
||||
ENUM_VALUE_NOT_A_MEMBER = 161,
|
||||
OPTIONAL_ERROR = 180,
|
||||
OPTIONAL_TEMPORARILY_REQUIRED = 181,
|
||||
CHOICE_ERROR = 200,
|
||||
DOES_NOT_FIT_ANY_CHOICE = 201,
|
||||
DOES_NOT_FIT_THIS_CHOICE = 202
|
||||
}
|
||||
interface ErrorDetail {
|
||||
error: Error;
|
||||
parameters?: any[];
|
||||
underlying?: ErrorDetail[];
|
||||
}
|
||||
interface Settings {
|
||||
[editor: string]: Record<string, any>;
|
||||
}
|
||||
/**
|
||||
* Intersection type of all editor-specific settings for base editors.
|
||||
*/
|
||||
type EditorSettings = TextboxBasedEditor.Settings;
|
||||
interface Localizables {
|
||||
[editor: string]: Record<string, TcHmi.Localizable>;
|
||||
}
|
||||
/**
|
||||
* Intersection type of all editor-specific localizables.
|
||||
*/
|
||||
type LocalizableTexts = {
|
||||
/**
|
||||
* Localizable texts for error messages when validation of a value fails.
|
||||
*/
|
||||
errors: Partial<{
|
||||
[E in Error]: string;
|
||||
}>;
|
||||
/**
|
||||
* Localizable texts to be used in editor popups.
|
||||
*/
|
||||
editorPrompt: Partial<Omit<EditorPrompt.LocalizableTexts, 'editorLocalizations'>>;
|
||||
/**
|
||||
* Legacy overwrite for localizable texts to be used in array editor popups.
|
||||
*/
|
||||
arrayEditorPrompt: Partial<Omit<EditorPrompt.LocalizableTexts, 'editorLocalizations'>>;
|
||||
/**
|
||||
* Legacy overwrite for localizable texts to be used in object editor popups.
|
||||
*/
|
||||
objectEditorPrompt: Partial<Omit<EditorPrompt.LocalizableTexts, 'editorLocalizations'>>;
|
||||
/**
|
||||
* Legacy overwrite for localizable texts to be used in tuple editor popups.
|
||||
*/
|
||||
tupleEditorPrompt: Partial<Omit<EditorPrompt.LocalizableTexts, 'editorLocalizations'>>;
|
||||
} & OptionalEditor.LocalizableTexts & ButtonBasedEditor.LocalizableTexts & BooleanEditor.LocalizableTexts & TimeEditor.LocalizableTexts & ChoiceEditor.LocalizableTexts & InvalidEditor.LocalizableTexts & ArrayBasedEditorPane.LocalizableTexts & ObjectEditorPane.LocalizableTexts;
|
||||
}
|
||||
import _Editor = Editor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let Editor: typeof _Editor;
|
||||
type Editor<T, I extends _Editor.EditorInfo = _Editor.EditorInfo> = _Editor<T, I>;
|
||||
namespace Editor {
|
||||
type Constructor<T, I extends EditorInfo = EditorInfo> = _Editor.Constructor<T, I>;
|
||||
type GenericConstructor<E extends Editor<T, I>, T, I extends EditorInfo = EditorInfo> = _Editor.GenericConstructor<E, T, I>;
|
||||
type Info<T> = _Editor.Info<T>;
|
||||
type EditorType = _Editor.EditorType;
|
||||
type EditorInfo = _Editor.EditorInfo;
|
||||
type State<T> = _Editor.State<T>;
|
||||
type InvalidState = _Editor.InvalidState;
|
||||
type ValidState<T> = _Editor.ValidState<T>;
|
||||
type Error = _Editor.Error;
|
||||
type ErrorDetail = _Editor.ErrorDetail;
|
||||
type Settings = _Editor.Settings;
|
||||
type EditorSettings = _Editor.EditorSettings;
|
||||
type Localizables = _Editor.Localizables;
|
||||
type LocalizableTexts = _Editor.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Editor.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,152 @@
|
||||
import { Editor } from '../Editor.js';
|
||||
import type { EditorFactory } from '../../EditorFactory.js';
|
||||
import type { ArrayEditor } from '../ArrayEditor.js';
|
||||
import type { TupleEditor } from '../TupleEditor.js';
|
||||
import type { Control as TcHmiButton } from '../../../../TcHmiButton/TcHmiButton.esm.js';
|
||||
/**
|
||||
* Editor Pane for arrays or tuples.
|
||||
*/
|
||||
export declare abstract class ArrayBasedEditorPane<I extends ArrayEditor.Info | TupleEditor.Info> extends Editor<any[], I> {
|
||||
protected __editorTable: HTMLTableElement;
|
||||
protected __addItemButton: TcHmiButton;
|
||||
protected __upButton: TcHmiButton;
|
||||
protected __downButton: TcHmiButton;
|
||||
protected __removeButtonTooltip: string;
|
||||
protected __errorContainer: HTMLDivElement;
|
||||
protected __editors: ArrayBasedEditorPane.EditorEntry[];
|
||||
protected __selectedEditorEntry: ArrayBasedEditorPane.EditorEntry | null;
|
||||
protected __pauseChangeHandlers: boolean;
|
||||
/**
|
||||
* Create a new array based editor pane.
|
||||
* @param element The element to contain the editor pane.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: I, factory: EditorFactory);
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): any[];
|
||||
/**
|
||||
* Creates a table row for the given editor info.
|
||||
* @param editorInfo Info about the editor in the row.
|
||||
* @param removable Set to false if you don't want the editor row to be removable.
|
||||
*/
|
||||
protected __createEditorRow(editorInfo: Editor.EditorInfo, removable?: boolean): ArrayBasedEditorPane.EditorEntry;
|
||||
/**
|
||||
* Handler for the change events of the editors.
|
||||
* @param editor The editor that changed.
|
||||
*/
|
||||
protected __onEditorChanged(editor: Editor<any, Editor.EditorInfo>): void;
|
||||
/**
|
||||
* Handles the change events of the editors.
|
||||
* @param _editor The editor that changed.
|
||||
*/
|
||||
protected __handleOnEditorChanged(_editor: Editor<any, Editor.EditorInfo>): void;
|
||||
/**
|
||||
* Creates a handler callback for the pressed event of a remove button.
|
||||
* @param entry The entry describing the row to remove.
|
||||
*/
|
||||
protected __getRemoveButtonPressedHandler(entry: ArrayBasedEditorPane.EditorEntry): () => void;
|
||||
/**
|
||||
* Remove a row.
|
||||
* @param editorEntry The entry describing the row to remove.
|
||||
*/
|
||||
protected __removeEditorRow(editorEntry: ArrayBasedEditorPane.EditorEntry): void;
|
||||
/**
|
||||
* Mark the row element of the given editor entry as selected and set this.__selectedEditorEntry.
|
||||
* @param editorEntry The editor entry to select. Pass null to reset the selection.
|
||||
*/
|
||||
protected __selectItem(editorEntry: ArrayBasedEditorPane.EditorEntry | null): void;
|
||||
/**
|
||||
* Disables or enables the up and down buttons depending on the index of the selected item.
|
||||
* @param selectedIndex The index of the selected item.
|
||||
*/
|
||||
protected __updateMoveButtons(selectedIndex: number): void;
|
||||
/**
|
||||
* Handler for the click event of the editor element.
|
||||
* @param event The event object.
|
||||
*/
|
||||
protected __onClick(event: MouseEvent): void;
|
||||
/**
|
||||
* Handler for the pressed event of the add item button.
|
||||
*/
|
||||
protected __onAddItemPressed(): void;
|
||||
/**
|
||||
* Adds a new table row with an editor for a new item
|
||||
*/
|
||||
protected abstract __addItem(): void;
|
||||
/**
|
||||
* Handler for the pressed event of the up button.
|
||||
*/
|
||||
protected __onUpPressed(): void;
|
||||
/**
|
||||
* Handler for the pressed event of the down button.
|
||||
*/
|
||||
protected __onDownPressed(): void;
|
||||
/**
|
||||
* Event handler for the onLocaleChanged event.
|
||||
*/
|
||||
protected __onLocaleChanged(): void;
|
||||
/**
|
||||
* Update the validation message.
|
||||
* @param state The current state of the editor pane, if it's already known. Should be used to avoid a duplicate
|
||||
* getState() call, not to pass in a manipulated state.
|
||||
*/
|
||||
protected __updateValidationStatus(state?: Editor.State<any>): boolean;
|
||||
/**
|
||||
* Enable or disable the editor. Disabled editors are greyed out and cannot be interacted with.
|
||||
* @param isEnabled Whether the editor should be enabled or disabled.
|
||||
*/
|
||||
setIsEnabled(isEnabled: boolean): void;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<Editor.EditorSettings & S>): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ArrayBasedEditorPane {
|
||||
interface EditorEntry {
|
||||
editor: Editor<any>;
|
||||
row: HTMLTableRowElement;
|
||||
cell: HTMLTableCellElement;
|
||||
removeButton?: TcHmiButton;
|
||||
removeDestroyer?: TcHmi.DestroyFunction;
|
||||
}
|
||||
type LocalizableTexts = {
|
||||
arrayBasedEditorPane: Partial<{
|
||||
addButtonTooltip: TcHmi.Localizable;
|
||||
upButtonTooltip: TcHmi.Localizable;
|
||||
downButtonTooltip: TcHmi.Localizable;
|
||||
removeButtonTooltip: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _ArrayBasedEditorPane = ArrayBasedEditorPane;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ArrayBasedEditorPane: typeof _ArrayBasedEditorPane;
|
||||
type ArrayBasedEditorPane<I extends ArrayEditor.Info | TupleEditor.Info> = _ArrayBasedEditorPane<I>;
|
||||
namespace ArrayBasedEditorPane {
|
||||
type EditorEntry = _ArrayBasedEditorPane.EditorEntry;
|
||||
type LocalizableTexts = _ArrayBasedEditorPane.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ArrayBasedEditorPane.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,38 @@
|
||||
import { ArrayBasedEditorPane } from './ArrayBasedEditorPane.js';
|
||||
import type { ArrayEditor } from '../ArrayEditor.js';
|
||||
import type { EditorFactory } from '../../EditorFactory.js';
|
||||
/**
|
||||
* Editor Pane for arrays.
|
||||
*/
|
||||
export declare class ArrayEditorPane extends ArrayBasedEditorPane<ArrayEditor.Info> {
|
||||
/**
|
||||
* Create a new array editor pane.
|
||||
* @param element The element to contain the editor pane.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: ArrayEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: any[] | null): void;
|
||||
/**
|
||||
* Adds a new table row with an editor for a new item
|
||||
*/
|
||||
protected __addItem(): void;
|
||||
}
|
||||
declare const _ArrayEditorPane: typeof ArrayEditorPane;
|
||||
type tArrayEditorPane = ArrayEditorPane;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ArrayEditorPane: typeof _ArrayEditorPane;
|
||||
type ArrayEditorPane = tArrayEditorPane;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=ArrayEditorPane.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ArrayBasedEditorPane}from"./ArrayBasedEditorPane.js";export class ArrayEditorPane extends ArrayBasedEditorPane{constructor(element,editorInfo,factory){super(element,editorInfo,factory)}__processEditorInfo(){const value=this.getRawValue();this.__editorTable.innerHTML="";for(const entry of this.__editors)this.__removeEditorRow(entry);this.setValue(value)}setValue(value){this.__pauseChangeHandlers=!0,value||(value=[]);let index=0;for(let length=value.length;index<length;index++){let editorEntry=this.__editors[index];editorEntry||(editorEntry=this.__createEditorRow(this.__editorInfo.items),this.__editorTable.appendChild(editorEntry.row),this.__editors.push(editorEntry)),editorEntry.editor.setValue(value[index])}if(index<this.__editors.length){const deletedEditors=this.__editors.splice(index);for(const entry of deletedEditors)this.__removeEditorRow(entry)}this.__pauseChangeHandlers=!1;const state=this.getState();this.__onChangeManager.trigger(this,state),this.__updateValidationStatus(state)}__addItem(){const editorEntry=this.__createEditorRow(this.__editorInfo.items);this.__editorTable.appendChild(editorEntry.row),this.__editors.push(editorEntry),this.__pauseChangeHandlers||this.__onChangeManager.trigger(this,this.getState()),this.__selectItem(editorEntry)}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.ArrayEditorPane=ArrayEditorPane;
|
||||
@@ -0,0 +1,153 @@
|
||||
import { ObjectEditor } from '../ObjectEditor.js';
|
||||
import { Editor } from '../Editor.js';
|
||||
import type { Control as TcHmiInput } from '../../../../TcHmiInput/TcHmiInput.esm.js';
|
||||
import type { Control as TcHmiButton } from '../../../../TcHmiButton/TcHmiButton.esm.js';
|
||||
import type { EditorFactory } from '../../EditorFactory.js';
|
||||
/**
|
||||
* Editor pane for objects.
|
||||
*/
|
||||
export declare class ObjectEditorPane extends Editor<object, ObjectEditor.Info> {
|
||||
protected __editorTable: HTMLTableElement;
|
||||
protected __newPropertyContainer: HTMLDivElement;
|
||||
protected __newPropertyTextbox: TcHmiInput;
|
||||
protected __acceptNewPropertyButton: TcHmiButton;
|
||||
protected __cancelNewPropertyButton: TcHmiButton;
|
||||
protected __addPropertyButton: TcHmiButton;
|
||||
protected __removeButtonTooltip: string;
|
||||
protected __errorContainer: HTMLDivElement;
|
||||
protected __editors: Map<string, _ObjectEditorPane.EditorEntry>;
|
||||
protected __dependencyOverride: ObjectEditor.Info;
|
||||
protected __pauseChangeHandlers: boolean;
|
||||
/**
|
||||
* Create a new object editor pane.
|
||||
* @param element The element to contain the editor pane.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: ObjectEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: TcHmi.Dictionary<any> | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): TcHmi.Dictionary<any>;
|
||||
/**
|
||||
* Determines which dependencies should be applied and changes the editors accordingly.
|
||||
*/
|
||||
protected __applyDependencies(): void;
|
||||
/**
|
||||
* Creates a table row for the given editor info.
|
||||
* @param name The name of the property the row should edit.
|
||||
* @param editorInfo Info about the editor in the row.
|
||||
* @param isAdditional Whether the row describes an additional property that can be removed.
|
||||
*/
|
||||
protected __createEditorRow(name: string, editorInfo: Editor.EditorInfo, isAdditional: boolean): _ObjectEditorPane.EditorEntry;
|
||||
/**
|
||||
* Handler for the change events of the editors.
|
||||
* @param editor The editor that changed.
|
||||
*/
|
||||
protected __onEditorChanged(editor: Editor<any>): void;
|
||||
/**
|
||||
* Creates a handler callback for the pressed event of a remove button.
|
||||
* @param name The name of the row to remove.
|
||||
*/
|
||||
protected __getRemoveButtonPressedHandler(name: string): () => void;
|
||||
/**
|
||||
* Remove a row.
|
||||
* @param name The name of the row to remove.
|
||||
*/
|
||||
protected __removeEditorRow(name: string): void;
|
||||
/**
|
||||
* Handler for the pressed event of the add property button.
|
||||
*/
|
||||
protected __onAddPropertyPressed(): void;
|
||||
/**
|
||||
* Handler for the text changed event of the new property textbox.
|
||||
*/
|
||||
protected __onNewPropertyTextChanged(): void;
|
||||
/**
|
||||
* Handler for the pressed event of the accept new property button.
|
||||
*/
|
||||
protected __onAcceptNewPropertyPressed(): void;
|
||||
/**
|
||||
* Handler for the pressed event of the cancel new property button.
|
||||
*/
|
||||
protected __onCancelNewPropertyPressed(): void;
|
||||
/**
|
||||
* Clear the new property textbox, hide the new property container and show the add property button.
|
||||
*/
|
||||
protected __cancelNewProperty(): void;
|
||||
/**
|
||||
* Event handler for the onLocaleChanged event.
|
||||
*/
|
||||
protected __onLocaleChanged(): void;
|
||||
/**
|
||||
* Update the validation message.
|
||||
* @param state The current state of the editor pane, if it's already known. Should be used to avoid a duplicate
|
||||
* getState() call, not to pass in a manipulated state.
|
||||
*/
|
||||
protected __updateValidationStatus(state?: Editor.State<any>): boolean;
|
||||
/**
|
||||
* Enable or disable the editor. Disabled editors are greyed out and cannot be interacted with.
|
||||
* @param isEnabled Whether the editor should be enabled or disabled.
|
||||
*/
|
||||
setIsEnabled(isEnabled: boolean): void;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<Editor.EditorSettings & S>): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ObjectEditorPane {
|
||||
interface EditorEntry {
|
||||
editor: Editor<any>;
|
||||
row: HTMLTableRowElement;
|
||||
cell: HTMLTableCellElement;
|
||||
removeButton?: TcHmiButton;
|
||||
additionalDestroyer?: TcHmi.DestroyFunction;
|
||||
}
|
||||
type LocalizableTexts = {
|
||||
objectEditorPane: Partial<{
|
||||
addButtonTooltip: TcHmi.Localizable;
|
||||
acceptButtonText: TcHmi.Localizable;
|
||||
acceptButtonTooltip: TcHmi.Localizable;
|
||||
cancelButtonTooltip: TcHmi.Localizable;
|
||||
removeButtonTooltip: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _ObjectEditorPane = ObjectEditorPane;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ObjectEditorPane: typeof _ObjectEditorPane;
|
||||
type ObjectEditorPane = _ObjectEditorPane;
|
||||
namespace ObjectEditorPane {
|
||||
type EditorEntry = _ObjectEditorPane.EditorEntry;
|
||||
type LocalizableTexts = _ObjectEditorPane.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ObjectEditorPane.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,58 @@
|
||||
import type { EditorFactory } from '../../EditorFactory.js';
|
||||
import type { TupleEditor } from '../TupleEditor.js';
|
||||
import type { Editor } from '../Editor.js';
|
||||
import { ArrayBasedEditorPane } from './ArrayBasedEditorPane.js';
|
||||
/**
|
||||
* Editor pane for tuples.
|
||||
*/
|
||||
export declare class TupleEditorPane extends ArrayBasedEditorPane<TupleEditor.Info> {
|
||||
/**
|
||||
* Create a new tuple editor pane.
|
||||
* @param element The element to contain the editor pane.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: TupleEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: any[] | null): void;
|
||||
/**
|
||||
* Marks optional editors as temporarily required.
|
||||
*/
|
||||
protected __markRequired(): void;
|
||||
/**
|
||||
* Handles the change events of the editors.
|
||||
* @param editor The editor that was changed.
|
||||
*/
|
||||
protected __handleOnEditorChanged(editor: Editor<any>): void;
|
||||
/**
|
||||
* Adds a new table row with an editor for a new item
|
||||
*/
|
||||
protected __addItem(): void;
|
||||
/**
|
||||
* Remove a row.
|
||||
* @param editorEntry The entry describing the row to remove.
|
||||
*/
|
||||
protected __removeEditorRow(editorEntry: ArrayBasedEditorPane.EditorEntry): void;
|
||||
/**
|
||||
* Disables or enables the up and down buttons depending on the index of the selected item.
|
||||
* @param selectedIndex The index of the selected item.
|
||||
*/
|
||||
protected __updateMoveButtons(selectedIndex: number): void;
|
||||
}
|
||||
declare const _TupleEditorPane: typeof TupleEditorPane;
|
||||
type tTupleEditorPane = TupleEditorPane;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TupleEditorPane: typeof _TupleEditorPane;
|
||||
type TupleEditorPane = tTupleEditorPane;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=TupleEditorPane.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ChoiceEditor}from"../ChoiceEditor.js";import{ArrayBasedEditorPane}from"./ArrayBasedEditorPane.js";export class TupleEditorPane extends ArrayBasedEditorPane{constructor(element,editorInfo,factory){super(element,editorInfo,factory)}__processEditorInfo(){const value=this.getRawValue();this.__editorTable.innerHTML="";for(const entry of this.__editors)this.__removeEditorRow(entry);for(const item of this.__editorInfo.items){const editorEntry=this.__createEditorRow(item,!1);this.__editorTable.appendChild(editorEntry.row),this.__editors.push(editorEntry)}this.setValue(value),this.__addItemButton.setVisibility(this.__editorInfo.additionalItems.allowed&&this.__editorInfo.additionalItems.editorInfo?"Visible":"Hidden")}setValue(value){this.__pauseChangeHandlers=!0,value||(value=[]);let index=0;for(let length=value.length;index<length;index++){let editorEntry=this.__editors[index];if(!editorEntry){let info;info=this.__editorInfo.additionalItems.allowed?this.__editorInfo.additionalItems.editorInfo??ChoiceEditor.createAnyEditorInfo():{type:"invalid",schema:{},name:"Invalid"},editorEntry=this.__createEditorRow(info),this.__editorTable.appendChild(editorEntry.row),this.__editors.push(editorEntry)}editorEntry.editor.setValue(value[index])}for(;index<this.__editorInfo.items.length;)this.__editors[index].editor.setValue(void 0),index++;if(index<this.__editors.length){const deletedEditors=this.__editors.splice(index);for(const entry of deletedEditors)this.__removeEditorRow(entry)}this.__pauseChangeHandlers=!1;const state=this.getState();this.__onChangeManager.trigger(this,state),this.__updateValidationStatus(state)}__markRequired(){this.__pauseChangeHandlers=!0;let triggerChangeHandlers=!1,shouldBeRequired=this.__editors.length>this.__editorInfo.items.length;for(let i=this.__editorInfo.items.length-1;i>=0;i--){const editor=this.__editors[i].editor;let editorInfo=this.__editors[i].editor.getEditorInfo();if("optional"!==editorInfo.type)break;editorInfo.temporarilyRequired!==shouldBeRequired&&(editorInfo=tchmi_clone_object(editorInfo),editorInfo.temporarilyRequired=shouldBeRequired,editor.setEditorInfo(editorInfo),triggerChangeHandlers=!0),shouldBeRequired||void 0===editor.getRawValue()||(shouldBeRequired=!0)}this.__pauseChangeHandlers=!1,triggerChangeHandlers&&this.__onChangeManager.trigger(this,this.getState())}__handleOnEditorChanged(editor){super.__handleOnEditorChanged(editor),this.__markRequired()}__addItem(){if(!this.__editorInfo.additionalItems.allowed)return;const info=this.__editorInfo.additionalItems.editorInfo??ChoiceEditor.createAnyEditorInfo(),editorEntry=this.__createEditorRow(info);this.__editorTable.appendChild(editorEntry.row),this.__editors.push(editorEntry),this.__pauseChangeHandlers||this.__onChangeManager.trigger(this,this.getState()),this.__markRequired(),this.__selectItem(editorEntry)}__removeEditorRow(editorEntry){super.__removeEditorRow(editorEntry),this.__markRequired()}__updateMoveButtons(selectedIndex){this.__upButton.setIsEnabled(-1!==selectedIndex&&selectedIndex>this.__editorInfo.items.length),this.__downButton.setIsEnabled(-1!==selectedIndex&&selectedIndex>=this.__editorInfo.items.length&&selectedIndex<this.__editors.length-1)}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.TupleEditorPane=TupleEditorPane;
|
||||
@@ -0,0 +1,59 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import { ComboboxBasedEditor } from './ComboboxBasedEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor for enums.
|
||||
*/
|
||||
export declare class EnumEditor<T> extends ComboboxBasedEditor<T, EnumEditor.Info<T>> {
|
||||
/**
|
||||
* Create a new enum editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: EnumEditor.Info<T>, factory: EditorFactory);
|
||||
/**
|
||||
* Returns whether the editor contains a valid value for the schema.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate<T = any>(editorInfo: EnumEditor.Info, value: any): value is T;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param _returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: EnumEditor.Info, value: any, _returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: T | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): T | null;
|
||||
}
|
||||
export declare namespace EnumEditor {
|
||||
interface Info<T = any> extends Editor.Info<T> {
|
||||
type: 'enum';
|
||||
members: Map<T, string | undefined>;
|
||||
}
|
||||
}
|
||||
import _EnumEditor = EnumEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let EnumEditor: typeof _EnumEditor;
|
||||
type EnumEditor<T> = _EnumEditor<T>;
|
||||
namespace EnumEditor {
|
||||
type Info = _EnumEditor.Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=EnumEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{Editor}from"./Editor.js";import{ComboboxBasedEditor}from"./ComboboxBasedEditor.js";export class EnumEditor extends ComboboxBasedEditor{constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__processEditorInfo()}static validate(editorInfo,value){return editorInfo.members.has(value)}static checkForErrors(editorInfo,value,_returnEarly=!1){return editorInfo.members.has(value)?[]:[{error:Editor.Error.ENUM_VALUE_NOT_A_MEMBER}]}__processEditorInfo(){function stringify(value){return"string"==typeof value?value:JSON.stringify(value)}this.__combobox.setSrcData(Array.from(this.__editorInfo.members.entries()).map(([value,label])=>({value,text:label?`${label} (${stringify(value)})`:stringify(value)})))}setValue(value){if(null==value)this.__combobox.setSelectedIndex(null);else{const index=Array.from(this.__editorInfo.members.keys()).indexOf(value);this.__combobox.setSelectedIndex(-1!==index?index:null)}}getRawValue(){return this.__combobox.getSelectedValue()}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.EnumEditor=EnumEditor;
|
||||
@@ -0,0 +1,74 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor that is used if a JSON schema does not allow any possible value.
|
||||
*/
|
||||
export declare class InvalidEditor extends Editor<any, InvalidEditor.Info> {
|
||||
#private;
|
||||
protected __value: any;
|
||||
protected __textContainer: HTMLElement;
|
||||
/**
|
||||
* Create a new invalid editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: InvalidEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param _editorInfo The editor info to validate against.
|
||||
* @param _value The value to validate.
|
||||
*/
|
||||
static validate(_editorInfo: InvalidEditor.Info, _value: any): _value is any;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param _editorInfo The editor info to check against.
|
||||
* @param _value The value to check.
|
||||
* @param _returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(_editorInfo: InvalidEditor.Info, _value: any, _returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: any | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): any;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace InvalidEditor {
|
||||
interface Info extends Editor.Info<never> {
|
||||
type: 'invalid';
|
||||
}
|
||||
type LocalizableTexts = {
|
||||
invalidEditor: Partial<{
|
||||
invalidSchemaText: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _InvalidEditor = InvalidEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let InvalidEditor: typeof _InvalidEditor;
|
||||
namespace InvalidEditor {
|
||||
type Info = _InvalidEditor.Info;
|
||||
type LocalizableTexts = _InvalidEditor.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=InvalidEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{Editor}from"./Editor.js";export class InvalidEditor extends Editor{static#tchmiFQN="TcHmi.Controls.Helpers."+this.name;__value;__textContainer;constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__textContainer=document.createElement("span"),this.__textContainer.classList.add("with-validation","invalid"),this.__element.appendChild(this.__textContainer),this.__parentControl?TcHmi.Log.Controls.error(this.__parentControl,InvalidEditor.#tchmiFQN,"Failed to construct an editor because the JSON schema is invalid.",editorInfo.schema):TcHmi.Log.errorEx(`[Source=Control, Module=Beckhoff.TwinCAT.HMI.Controls, Origin=${InvalidEditor.#tchmiFQN}] Failed to construct an editor because the JSON schema is invalid.`,editorInfo.schema)}static validate(_editorInfo,_value){return!1}static checkForErrors(_editorInfo,_value,_returnEarly=!1){return[{error:Editor.Error.ERROR}]}__processEditorInfo(){}__processIsReadOnly(){}setValue(value){tchmi_equal(this.__value,value)||(this.__value=value,this.__onChangeManager.trigger(this,this.getState()))}getRawValue(){return this.__value}setLocalizations(texts){super.setLocalizations(texts),this.__localizations?.invalidEditor?.invalidSchemaText&&this.__watchLocalization("invalidSchemaText","string"==typeof this.__localizations.invalidEditor.invalidSchemaText?{symbolExpression:this.__localizations.invalidEditor.invalidSchemaText,formatValues:[]}:this.__localizations.invalidEditor.invalidSchemaText,text=>{this.__textContainer.textContent=text})}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.InvalidEditor=InvalidEditor;
|
||||
@@ -0,0 +1,62 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor that is used if the schema demands a value to be null. Mostly useful in ChoiceEditors.
|
||||
*/
|
||||
export declare class NullEditor extends Editor<null, NullEditor.Info> {
|
||||
protected __onChangeTriggered: boolean;
|
||||
/**
|
||||
* Create a new null editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: NullEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param _editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(_editorInfo: NullEditor.Info, value: any): value is null;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param _editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param _returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(_editorInfo: NullEditor.Info, value: any, _returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param _value The value to set.
|
||||
*/
|
||||
setValue(_value: null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): null;
|
||||
}
|
||||
export declare namespace NullEditor {
|
||||
interface Info extends Editor.Info<null> {
|
||||
type: 'null';
|
||||
}
|
||||
}
|
||||
import _NullEditor = NullEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let NullEditor: typeof _NullEditor;
|
||||
type NullEditor = _NullEditor;
|
||||
namespace NullEditor {
|
||||
type Info = _NullEditor.Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=NullEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{Editor}from"./Editor.js";export class NullEditor extends Editor{__onChangeTriggered=!1;constructor(element,editorInfo,factory){super(element,editorInfo,factory);const textSpan=document.createElement("span");textSpan.classList.add("value-description"),textSpan.textContent="null",this.__element.appendChild(textSpan)}static validate(_editorInfo,value){return null===value}static checkForErrors(_editorInfo,value,_returnEarly=!1){return null!==value?[{error:Editor.Error.NOT_NULL}]:[]}__processEditorInfo(){}__processIsReadOnly(){}setValue(_value){this.__onChangeTriggered||(this.__onChangeTriggered=!0,this.__onChangeManager.trigger(this,this.getState()))}getRawValue(){return null}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.NullEditor=NullEditor;
|
||||
@@ -0,0 +1,99 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import { TextboxBasedEditor } from './TextboxBasedEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor for numbers.
|
||||
*/
|
||||
export declare class NumberEditor extends TextboxBasedEditor<number | string, NumberEditor.Info> {
|
||||
/**
|
||||
* Create a new number editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: NumberEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: NumberEditor.Info, value: any): value is number | string;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: NumberEditor.Info, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Gets the current value.
|
||||
*/
|
||||
getState(): Editor.State<number | string>;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Tests whether the supplied number fits into the given minimum.
|
||||
* @param value The number to test.
|
||||
* @param minimum The minimum to test against.
|
||||
* @param minimum.value The value of the minimum.
|
||||
* @param minimum.exclusive Whether a value that is equal to the minimum value should be valid or not.
|
||||
*/
|
||||
protected static __testMinimum(value: number, minimum: {
|
||||
value: number;
|
||||
exclusive: boolean;
|
||||
}): boolean;
|
||||
/**
|
||||
* Tests whether the supplied number fits into the given maximum.
|
||||
* @param value The number to test.
|
||||
* @param maximum The maximum to test against.
|
||||
* @param maximum.value The value of the maximum.
|
||||
* @param maximum.exclusive Whether a value that is equal to the maximum value should be valid or not.
|
||||
*/
|
||||
protected static __testMaximum(value: number, maximum: {
|
||||
value: number;
|
||||
exclusive: boolean;
|
||||
}): boolean;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: number | string | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): string | number;
|
||||
}
|
||||
export declare namespace NumberEditor {
|
||||
interface Info extends Editor.Info<number> {
|
||||
type: 'number';
|
||||
restrictions: Restriction[];
|
||||
specialValues: Set<string>;
|
||||
}
|
||||
interface Restriction {
|
||||
isInteger: boolean;
|
||||
multipleOf?: number;
|
||||
maximum?: {
|
||||
value: number;
|
||||
exclusive: boolean;
|
||||
};
|
||||
minimum?: {
|
||||
value: number;
|
||||
exclusive: boolean;
|
||||
};
|
||||
}
|
||||
}
|
||||
import _NumberEditor = NumberEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let NumberEditor: typeof _NumberEditor;
|
||||
type NumberEditor = _NumberEditor;
|
||||
namespace NumberEditor {
|
||||
type Info = _NumberEditor.Info;
|
||||
type Restriction = _NumberEditor.Restriction;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=NumberEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{Editor}from"./Editor.js";import{TextboxBasedEditor}from"./TextboxBasedEditor.js";export class NumberEditor extends TextboxBasedEditor{constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__textbox.setTextHorizontalAlignment("Right"),this.__textbox.setSystemKeyboardInputMode(editorInfo.restrictions.every(restriction=>restriction.isInteger)?"numeric":"decimal")}static validate(editorInfo,value){return 0===NumberEditor.checkForErrors(editorInfo,value,!0).length}static checkForErrors(editorInfo,value,returnEarly=!1){if("string"==typeof value)return value&&editorInfo.specialValues.has(value)&&editorInfo.restrictions.some(restriction=>!restriction.isInteger)?[]:[{error:Editor.Error.NOT_A_NUMBER,parameters:[value]}];if("number"!=typeof value)return[{error:Editor.Error.NOT_A_NUMBER,parameters:[value]}];if(!Number.isFinite(value)){const text=value.toString();return editorInfo.specialValues.has(text)&&editorInfo.restrictions.some(restriction=>!restriction.isInteger)?[]:[{error:Editor.Error.NUMBER_NOT_FINITE,parameters:[value]}]}if(0===editorInfo.restrictions.length)return[];const restrictionErrors=[];for(const restriction of editorInfo.restrictions){const errors=[];if(restrictionErrors.push(errors),(!restriction.isInteger||Number.isInteger(value)||(errors.push({error:Editor.Error.NUMBER_NOT_INTEGER,parameters:[value]}),!returnEarly))&&(!restriction.minimum||this.__testMinimum(value,restriction.minimum)||(errors.push({error:Editor.Error.NUMBER_TOO_SMALL,parameters:[value,restriction.minimum.value,restriction.minimum.exclusive?">":">="]}),!returnEarly))&&(!restriction.maximum||this.__testMaximum(value,restriction.maximum)||(errors.push({error:Editor.Error.NUMBER_TOO_BIG,parameters:[value,restriction.maximum.value,restriction.maximum.exclusive?"<":"<="]}),!returnEarly))&&(void 0===restriction.multipleOf||value%restriction.multipleOf===0||(errors.push({error:Editor.Error.NUMBER_NOT_MULTIPLE_OF,parameters:[value,restriction.multipleOf]}),!returnEarly))&&0===errors.length)return[]}return 1===restrictionErrors.length?restrictionErrors[0]:[{error:Editor.Error.FAILS_ALL_RESTRICTIONS,parameters:[value],underlying:restrictionErrors.map(errors=>({error:Editor.Error.FAILS_THIS_RESTRICTION,underlying:errors}))}]}getState(){const value=this.getRawValue(),errors=NumberEditor.checkForErrors(this.__editorInfo,value);return 0===errors.length?{isValid:!0,value}:{isValid:!1,errors}}__processEditorInfo(){this.__updateValidationStatus()}static __testMinimum(value,minimum){return minimum.exclusive?value>minimum.value:value>=minimum.value}static __testMaximum(value,maximum){return maximum.exclusive?value<maximum.value:value<=maximum.value}setValue(value){"number"==typeof value?this.__textbox.setText(value.toString(10)):this.__textbox.setText(value)}getRawValue(){const text=this.__textbox.getText()??"";return/^[+-]?\d*\.?\d+(?:[eE][+-]?\d+)?$/.test(text)?parseFloat(text):text}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.NumberEditor=NumberEditor;
|
||||
@@ -0,0 +1,94 @@
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import { Editor } from './Editor.js';
|
||||
import type { InvalidEditor } from './InvalidEditor.js';
|
||||
import { ButtonBasedEditor } from './ButtonBasedEditor.js';
|
||||
/**
|
||||
* Editor for objects.
|
||||
*/
|
||||
export declare class ObjectEditor extends ButtonBasedEditor<Record<string | number | symbol, any>, ObjectEditor.Info> {
|
||||
protected __value: Record<string | number | symbol, any>;
|
||||
/**
|
||||
* Create a new object editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: ObjectEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: ObjectEditor.Info, value: any): value is object;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: ObjectEditor.Info, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Resolves dependencies of an object editor info by merging the dependecies with names contained in knownProperties into the editorInfo. Returns the original editorInfo if no dependecies are matched.
|
||||
* @param editorInfo The editor info to resolve.
|
||||
* @param knownProperties The properties that are known to exist on the object value.
|
||||
*/
|
||||
static resolveDependencies(editorInfo: ObjectEditor.Info, knownProperties: Set<string>): ObjectEditor.Info | InvalidEditor.Info;
|
||||
/**
|
||||
* Determines which editor info to use for the given property.
|
||||
* @param editorInfo The object editor info containing infos about the given property.
|
||||
* @param property The name of the property.
|
||||
*/
|
||||
static getEditorInfoForProperty(editorInfo: ObjectEditor.Info, property: string): Editor.EditorInfo;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: object | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): Record<string | number | symbol, any>;
|
||||
/**
|
||||
* Opens the popup for the editor.
|
||||
*/
|
||||
protected openPopup(): Promise<void>;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ObjectEditor {
|
||||
interface Info extends Editor.Info<Record<string | number | symbol, any>> {
|
||||
type: 'object';
|
||||
properties: Map<string, Editor.EditorInfo>;
|
||||
patternProperties?: Map<RegExp, Editor.EditorInfo>;
|
||||
additionalProperties: {
|
||||
allowed: boolean;
|
||||
editorInfo?: Editor.EditorInfo;
|
||||
};
|
||||
maxProperties?: number;
|
||||
minProperties?: number;
|
||||
dependencies?: Map<string, Info>;
|
||||
}
|
||||
}
|
||||
import _ObjectEditor = ObjectEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ObjectEditor: typeof _ObjectEditor;
|
||||
type ObjectEditor = _ObjectEditor;
|
||||
namespace ObjectEditor {
|
||||
type Info = _ObjectEditor.Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ObjectEditor.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,112 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import type { Control as TcHmiCheckbox } from '../../../TcHmiCheckbox/TcHmiCheckbox.esm.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor for optional properties of objects of optional items of tuples.
|
||||
*/
|
||||
export declare class OptionalEditor<T> extends Editor<T | undefined, OptionalEditor.Info<T>> {
|
||||
protected __container: HTMLDivElement;
|
||||
protected __editor: Editor<T>;
|
||||
protected __checkbox: TcHmiCheckbox;
|
||||
protected __enteredValue: T | null;
|
||||
/**
|
||||
* Create a new optional editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: OptionalEditor.Info<T>, factory: EditorFactory);
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Sets the editorInfo.
|
||||
* @param editorInfo The editorInfo to set.
|
||||
*/
|
||||
setEditorInfo(editorInfo: OptionalEditor.Info<T>): void;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<Editor.EditorSettings & S>): void;
|
||||
/**
|
||||
* Handler for the toggleStateChanged event of the checkbox
|
||||
*/
|
||||
protected __onToggleStateChanged(): void;
|
||||
/**
|
||||
* Handler for the change event of the editor.
|
||||
* @param _editor The editor that changed.
|
||||
* @param state The state of the editor that changed.
|
||||
*/
|
||||
protected __onEditorChanged(_editor: Editor<T>, state: Editor.State<T>): void;
|
||||
/**
|
||||
* Handler for the confirm event of the editor.
|
||||
* @param _editor The editor that was confirmed.
|
||||
* @param state The state of the editor that was confirmed.
|
||||
*/
|
||||
protected __onEditorConfirmed(_editor: Editor<T>, state: Editor.ValidState<T>): void;
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate<T = any>(editorInfo: OptionalEditor.Info<T>, value: any): value is T;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors<T = any>(editorInfo: OptionalEditor.Info<T>, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: T | null | undefined): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): any;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace OptionalEditor {
|
||||
interface Info<T> extends Editor.Info<T> {
|
||||
type: 'optional';
|
||||
editorInfo: Exclude<Editor.EditorInfo, Info<T>>;
|
||||
temporarilyRequired: boolean;
|
||||
valueIfDisabled?: T;
|
||||
}
|
||||
type LocalizableTexts = {
|
||||
optionalEditor: Partial<{
|
||||
optionalCheckboxTooltip: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _OptionalEditor = OptionalEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let OptionalEditor: typeof _OptionalEditor;
|
||||
type OptionalEditor<T> = _OptionalEditor<T>;
|
||||
namespace OptionalEditor {
|
||||
type Info<T> = _OptionalEditor.Info<T>;
|
||||
type LocalizableTexts = _OptionalEditor.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=OptionalEditor.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,66 @@
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import { TextboxBasedEditor } from './TextboxBasedEditor.js';
|
||||
import { Editor } from './Editor.js';
|
||||
/**
|
||||
* Editor for strings.
|
||||
*/
|
||||
export declare class StringEditor extends TextboxBasedEditor<string, StringEditor.Info> {
|
||||
/**
|
||||
* Create a new string editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: StringEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: StringEditor.Info, value: any): value is string;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: StringEditor.Info, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: string | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): string;
|
||||
}
|
||||
export declare namespace StringEditor {
|
||||
interface Info extends Editor.Info<string> {
|
||||
type: 'string';
|
||||
restrictions: Restriction[];
|
||||
}
|
||||
interface Restriction {
|
||||
minLength?: number;
|
||||
maxLength?: number;
|
||||
patterns?: RegExp[];
|
||||
format?: TcHmi.JsonSchema['format'];
|
||||
}
|
||||
}
|
||||
import _StringEditor = StringEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let StringEditor: typeof _StringEditor;
|
||||
type StringEditor = _StringEditor;
|
||||
namespace StringEditor {
|
||||
type Info = _StringEditor.Info;
|
||||
type Restriction = _StringEditor.Restriction;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=StringEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{TextboxBasedEditor}from"./TextboxBasedEditor.js";import{Editor}from"./Editor.js";export class StringEditor extends TextboxBasedEditor{constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__processEditorInfo()}static validate(editorInfo,value){return 0===StringEditor.checkForErrors(editorInfo,value,!0).length}static checkForErrors(editorInfo,value,returnEarly=!1){if("string"!=typeof value)return[{error:Editor.Error.NOT_A_STRING,parameters:[value]}];if(0===editorInfo.restrictions.length)return[];const restrictionErrors=[];for(const restriction of editorInfo.restrictions){const errors=[];if(restrictionErrors.push(errors),!(void 0!==restriction.minLength&&value.length<restriction.minLength&&(errors.push({error:Editor.Error.STRING_TOO_SHORT,parameters:[value,restriction.minLength,value.length]}),returnEarly))&&!(void 0!==restriction.maxLength&&value.length>restriction.maxLength&&(errors.push({error:Editor.Error.STRING_TOO_LONG,parameters:[value,restriction.maxLength,value.length]}),returnEarly))&&(!restriction.patterns||restriction.patterns.every(pattern=>pattern.test(value))||(errors.push({error:Editor.Error.STRING_DOES_NOT_MATCH,parameters:[value,restriction.patterns]}),!returnEarly))){if(restriction.format){let regex,error;switch(restriction.format){case"date-time":regex=/^\d{4}-(?:0\d|1[0-2])-(?:[0-2]\d|3[01])[Tt\s](?:[01]\d|2[0-3]):[0-5]\d:(?:[0-5]\d|60)(?:.\d+)?(?:[Zz]|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/,error=Editor.Error.STRING_NOT_DATE_TIME;break;case"timespan":regex=/^P(?=.{2,})(?:\d+Y|\d+[.,]\d+Y$)?(?:\d+M|\d+[.,]\d+M$)?(?:\d+W|\d+[.,]\d+W$)?(?:\d+D|\d+[.,]\d+D$)?(?:T(?:\d+H|\d+[.,]\d+H$)?(?:\d+M|\d+[.,]\d+M$)?(?:\d+S|\d+[.,]\d+S$)?)?$/,error=Editor.Error.STRING_NOT_TIMESPAN;break;case"email":regex=/^(?:[^@\s"]+|".+")@(?:[^@.\s]+\.)+[^@.\s]+$/,error=Editor.Error.STRING_NOT_EMAIL;break;case"hostname":regex=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,error=Editor.Error.STRING_NOT_HOSTNAME;break;case"ipv4":regex=/^(?:(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)$/,error=Editor.Error.STRING_NOT_IPV4;break;case"ipv6":regex=/^(?:[0-9A-F]{1,4}:){7}[0-9A-F]{1,4}$|^(?:[0-9A-F]{1,4}:){6}(?:(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)$|^(?=.*::)(?!.*(::).*\1.*)(?!.*:::.*)(?:(?:::)?(?:[0-9A-F]{1,4}::?){0,6}(?:[0-9A-F]{1,4}|::?)|(?:::)?(?:[0-9A-F]{1,4}::?){0,5}(?:(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|[0-1]?\d?\d))$/i,error=Editor.Error.STRING_NOT_IPV6;break;case"uri":regex=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,error=Editor.Error.STRING_NOT_URI;break;default:regex=/[\s\S]*/,error=Editor.Error.ERROR}if(!regex.test(value)&&(errors.push({error,parameters:[value]}),returnEarly))continue}if(0===errors.length)return[]}}return 1===restrictionErrors.length?restrictionErrors[0]:[{error:Editor.Error.FAILS_ALL_RESTRICTIONS,parameters:[value],underlying:restrictionErrors.map(errors=>({error:Editor.Error.FAILS_THIS_RESTRICTION,underlying:errors}))}]}__processEditorInfo(){this.__updateValidationStatus()}setValue(value){this.__textbox.setText(value)}getRawValue(){return this.__textbox.getText()??""}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.StringEditor=StringEditor;
|
||||
@@ -0,0 +1,83 @@
|
||||
import { Editor } from './Editor.js';
|
||||
import type { Control as TcHmiInput } from '../../../TcHmiInput/TcHmiInput.esm.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor that is based on a textbox, like for strings and numbers.
|
||||
*/
|
||||
export declare abstract class TextboxBasedEditor<T, I extends Editor.EditorInfo = Editor.EditorInfo> extends Editor<T, I> {
|
||||
protected __textbox: TcHmiInput;
|
||||
protected __settings: Partial<Editor.Settings & TextboxBasedEditor.Settings>;
|
||||
/**
|
||||
* Create a new textbox based editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: I, factory: EditorFactory);
|
||||
/**
|
||||
* Starts editing by setting the focus on the html textbox element.
|
||||
*/
|
||||
startEditing(): void;
|
||||
/**
|
||||
* DEPRECATED
|
||||
* Please use setSettings
|
||||
* @param valueNew The new value for autoSelectText.
|
||||
* @deprecated Please use setSettings
|
||||
*/
|
||||
setAutoSelectText(valueNew: boolean): void;
|
||||
/**
|
||||
* DEPRECATED
|
||||
* Please use getSettings
|
||||
* @deprecated Please use getSettings
|
||||
*/
|
||||
getAutoSelectText(): boolean | undefined;
|
||||
/**
|
||||
* Event handler for the onTextChanged event of the textbox.
|
||||
*/
|
||||
protected __onTextChanged(): void;
|
||||
/**
|
||||
* Event handler for the keydown event of the textboxes element.
|
||||
* @param event The event that should be handled.
|
||||
*/
|
||||
protected __onKeydown(event: KeyboardEvent): void;
|
||||
/**
|
||||
* Event handler for the onLocaleChanged event.
|
||||
*/
|
||||
protected __onLocaleChanged(): void;
|
||||
/**
|
||||
* Update the invalid class and the custom validity of the textbox.
|
||||
* @param state The current state of the editor pane, if it's already known. Should be used to avoid a duplicate
|
||||
* getState() call, not to pass in a manipulated state.
|
||||
*/
|
||||
protected __updateValidationStatus(state?: Editor.State<any>): boolean;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<S & TextboxBasedEditor.Settings>): void;
|
||||
}
|
||||
export declare namespace TextboxBasedEditor {
|
||||
type Settings = {
|
||||
textboxBasedEditor: Partial<{
|
||||
autoSelectText: boolean;
|
||||
autoFocusOut: boolean;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _TextboxBasedEditor = TextboxBasedEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TextboxBasedEditor: typeof _TextboxBasedEditor;
|
||||
type TextboxBasedEditor<T, I extends Editor.EditorInfo = Editor.EditorInfo> = _TextboxBasedEditor<T, I>;
|
||||
namespace TextboxBasedEditor {
|
||||
type Settings = _TextboxBasedEditor.Settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=TextboxBasedEditor.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,129 @@
|
||||
import type { Editor } from './Editor.js';
|
||||
import { TextboxBasedEditor } from './TextboxBasedEditor.js';
|
||||
import type { Control as TcHmiDateTimePicker } from '../../../TcHmiDateTimePicker/TcHmiDateTimePicker.esm.js';
|
||||
import type { Control as TcHmiTimespanPicker } from '../../../TcHmiTimespanPicker/TcHmiTimespanPicker.esm.js';
|
||||
import type { Control as TcHmiButton } from '../../../TcHmiButton/TcHmiButton.esm.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor for strings in the date time or timespan format.
|
||||
*/
|
||||
export declare class TimeEditor extends TextboxBasedEditor<string, TimeEditor.Info> {
|
||||
protected __container: HTMLDivElement;
|
||||
protected __dateTimePicker: TcHmiDateTimePicker | undefined;
|
||||
protected __dateTimeButton: TcHmiButton | undefined;
|
||||
protected __timespanPicker: TcHmiTimespanPicker | undefined;
|
||||
protected __timespanButton: TcHmiButton | undefined;
|
||||
/**
|
||||
* Create a new string editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: TimeEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: TimeEditor.Info, value: any): value is string;
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: TimeEditor.Info, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Gets the current value.
|
||||
*/
|
||||
getState(): Editor.State<string>;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Update the invalid class and the custom validity of the editor container.
|
||||
* @param state The current state of the editor pane, if it's already known. Should be used to avoid a duplicate
|
||||
* getState() call, not to pass in a manipulated state.
|
||||
*/
|
||||
protected __updateValidationStatus(state?: Editor.State<string>): boolean;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: string | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): string;
|
||||
/**
|
||||
* Creates a DateTimePicker and a Button to open it.
|
||||
*/
|
||||
protected __createDateTimeControls(): void;
|
||||
/**
|
||||
* Creates a TimespanPicker and a Button to open it.
|
||||
*/
|
||||
protected __createTimespanControls(): void;
|
||||
/**
|
||||
* Event handler for the value changed event of the datetime picker.
|
||||
*/
|
||||
protected __onDateTimeChanged(): void;
|
||||
/**
|
||||
* Event handler for the pressed event of the datetime button.
|
||||
*/
|
||||
protected __onDateTimeButtonPressed(): void;
|
||||
/**
|
||||
* Event handler for the value changed event of the timespan picker.
|
||||
*/
|
||||
protected __onTimespanChanged(): void;
|
||||
/**
|
||||
* Event handler for the pressed event of the timespan button.
|
||||
*/
|
||||
protected __onTimespanButtonPressed(): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
/**
|
||||
* Localizes the dateTimeButton
|
||||
*/
|
||||
protected __localizeDateTimeButton(): void;
|
||||
/**
|
||||
* Localizes the timespanButton
|
||||
*/
|
||||
protected __localizeTimespanButton(): void;
|
||||
}
|
||||
export declare namespace TimeEditor {
|
||||
interface Info extends Editor.Info<string> {
|
||||
type: 'time';
|
||||
formats: Set<'date-time' | 'timespan'>;
|
||||
}
|
||||
type LocalizableTexts = {
|
||||
timeEditor: Partial<{
|
||||
dateTimeButtonTooltip: TcHmi.Localizable;
|
||||
timespanButtonTooltip: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _TimeEditor = TimeEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TimeEditor: typeof _TimeEditor;
|
||||
type TimeEditor = _TimeEditor;
|
||||
namespace TimeEditor {
|
||||
type Info = _TimeEditor.Info;
|
||||
type LocalizableTexts = _TimeEditor.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=TimeEditor.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,80 @@
|
||||
import { ButtonBasedEditor } from './ButtonBasedEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import { Editor } from './Editor.js';
|
||||
/**
|
||||
* Editor for tuples.
|
||||
*/
|
||||
export declare class TupleEditor extends ButtonBasedEditor<any[], TupleEditor.Info> {
|
||||
protected __value: any[];
|
||||
/**
|
||||
* Create a new array editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: TupleEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Validates the given value against the specified editor info.
|
||||
* @param editorInfo The editor info to validate against.
|
||||
* @param value The value to validate.
|
||||
*/
|
||||
static validate(editorInfo: TupleEditor.Info, value: any): value is any[];
|
||||
/**
|
||||
* Checks the given value for errors against the given editor info.
|
||||
* @param editorInfo The editor info to check against.
|
||||
* @param value The value to check.
|
||||
* @param returnEarly Set to true to return early, instead of finding all errors.
|
||||
*/
|
||||
static checkForErrors(editorInfo: TupleEditor.Info, value: any, returnEarly?: boolean): Editor.ErrorDetail[];
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: any[] | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): any[];
|
||||
/**
|
||||
* Opens the popup for the editor.
|
||||
*/
|
||||
protected openPopup(): Promise<void>;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace TupleEditor {
|
||||
interface Info extends Editor.Info<any[]> {
|
||||
type: 'tuple';
|
||||
items: Editor.EditorInfo[];
|
||||
additionalItems: {
|
||||
allowed: boolean;
|
||||
editorInfo?: Editor.EditorInfo;
|
||||
};
|
||||
minItems?: number;
|
||||
maxItems?: number;
|
||||
uniqueItems: boolean;
|
||||
}
|
||||
}
|
||||
import _TupleEditor = TupleEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TupleEditor: typeof _TupleEditor;
|
||||
type TupleEditor = _TupleEditor;
|
||||
namespace TupleEditor {
|
||||
type Info = _TupleEditor.Info;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=TupleEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ButtonBasedEditor}from"./ButtonBasedEditor.js";import{Editor}from"./Editor.js";import{TupleEditorPrompt}from"../Popups/TupleEditorPrompt.js";import{ArrayEditor}from"./ArrayEditor.js";import{ChoiceEditor}from"./ChoiceEditor.js";export class TupleEditor extends ButtonBasedEditor{__value=[];constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__processEditorInfo()}destroy(){super.destroy(),this.__popup?.destroy(!0)}static validate(editorInfo,value){return 0===TupleEditor.checkForErrors(editorInfo,value,!0).length}static checkForErrors(editorInfo,value,returnEarly=!1){const arrayEditorInfo={type:"array",schema:editorInfo.schema,name:editorInfo.name,items:ChoiceEditor.createAnyEditorInfo(),uniqueItems:editorInfo.uniqueItems};void 0!==editorInfo.minItems&&(arrayEditorInfo.minItems=editorInfo.minItems),void 0!==editorInfo.maxItems&&(arrayEditorInfo.maxItems=editorInfo.maxItems);const errors=ArrayEditor.checkForErrors(arrayEditorInfo,value,returnEarly);if(returnEarly&&errors.length>0)return errors;if(!Array.isArray(value))return errors.length>0?errors:[{error:Editor.Error.NOT_AN_ARRAY,parameters:[value]}];for(const[index,item]of value.entries())if(index<editorInfo.items.length){const underlyingErrors=Editor.checkForErrors(editorInfo.items[index],item,returnEarly);if(underlyingErrors.length>0&&(errors.push({error:Editor.Error.ARRAY_CONTAINS_INVALID_VALUE,parameters:[value,index],underlying:underlyingErrors}),returnEarly))return errors}else if(editorInfo.additionalItems.allowed){if(editorInfo.additionalItems.editorInfo){const underlyingErrors=Editor.checkForErrors(editorInfo.additionalItems.editorInfo,item,returnEarly);if(underlyingErrors.length>0&&(errors.push({error:Editor.Error.OBJECT_CONTAINS_INVALID_VALUE,parameters:[value,index],underlying:underlyingErrors}),returnEarly))return errors}}else if(errors.push({error:Editor.Error.ARRAY_HAS_TOO_MANY_ITEMS,parameters:[value,editorInfo.items.length,value.length]}),returnEarly)return errors;return errors}__processEditorInfo(){this.__popup?.setEditorInfo(this.__editorInfo),this.__textSpan.textContent=this.__editorInfo.name,this.__container.classList.toggle("invalid",!this.getState().isValid)}setValue(value){this.__value=value??[],this.__popup?.setValue(value);const state=this.getState();this.__container.classList.toggle("invalid",!state.isValid),this.__onChangeManager.trigger(this,state)}getRawValue(){return this.__value}async openPopup(){this.__popup||(this.__popup=new TupleEditorPrompt(this.__editorInfo,this.__factory),this.__popup.setBackgroundAction({close:!0,action:"cancel"}),this.__popup.setIsReadOnly(this.__isReadOnly),this.__popup.setSettings(this.__settings),this.__popup.setLocalizations({buttonTextOk:this.__localizations?.tupleEditorPrompt?.buttonTextOk??this.__localizations?.editorPrompt?.buttonTextOk,buttonTooltipOk:this.__localizations?.tupleEditorPrompt?.buttonTooltipOk??this.__localizations?.editorPrompt?.buttonTooltipOk,buttonTextCancel:this.__localizations?.tupleEditorPrompt?.buttonTextCancel??this.__localizations?.editorPrompt?.buttonTextCancel,buttonTooltipCancel:this.__localizations?.tupleEditorPrompt?.buttonTooltipCancel??this.__localizations?.editorPrompt?.buttonTooltipCancel,editorLocalizations:this.__localizations}));try{this.__popup.setValue(this.__value);const result=await this.__popup.prompt();if(result.isOk){this.__value=result.value;const state=this.getState();this.__container.classList.toggle("invalid",!state.isValid),this.__onChangeManager.trigger(this,state),state.isValid&&this.__onConfirmManager.trigger(this,state)}}catch(ex){}}setLocalizations(texts){super.setLocalizations(texts),this.__popup?.setLocalizations({buttonTextOk:this.__localizations?.tupleEditorPrompt?.buttonTextOk??this.__localizations?.editorPrompt?.buttonTextOk,buttonTooltipOk:this.__localizations?.tupleEditorPrompt?.buttonTooltipOk??this.__localizations?.editorPrompt?.buttonTooltipOk,buttonTextCancel:this.__localizations?.tupleEditorPrompt?.buttonTextCancel??this.__localizations?.editorPrompt?.buttonTextCancel,buttonTooltipCancel:this.__localizations?.tupleEditorPrompt?.buttonTooltipCancel??this.__localizations?.editorPrompt?.buttonTooltipCancel,editorLocalizations:this.__localizations})}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.TupleEditor=TupleEditor;
|
||||
@@ -0,0 +1,113 @@
|
||||
import { Editor } from '../../BaseEditors/Editor.js';
|
||||
import type { HistorizedSymbolEditor } from '../HistorizedSymbolEditor.js';
|
||||
import type { StringEditor } from '../../BaseEditors/StringEditor.js';
|
||||
import type { EditorFactory } from '../../EditorFactory.js';
|
||||
/**
|
||||
* Editor pane for historized symbols.
|
||||
*/
|
||||
export declare class HistorizedSymbolEditorPane extends Editor<string, StringEditor.Info> {
|
||||
#private;
|
||||
protected __value: string;
|
||||
protected __tableHeaders: {
|
||||
name: HTMLTableCellElement;
|
||||
dataType: HTMLTableCellElement;
|
||||
recording: HTMLTableCellElement;
|
||||
interval: HTMLTableCellElement;
|
||||
maxEntries: HTMLTableCellElement;
|
||||
};
|
||||
protected __tableBody: HTMLTableSectionElement;
|
||||
protected __historizedSymbols: TcHmi.Symbol<HistorizedSymbolEditorPane.HistorizedSymbolList> | null;
|
||||
protected __destroyWatch: TcHmi.DestroyFunction | null;
|
||||
protected __localizations: Partial<Editor.LocalizableTexts & HistorizedSymbolEditor.LocalizableTexts> | undefined;
|
||||
protected __settings: Partial<Editor.Settings & HistorizedSymbolEditor.Settings>;
|
||||
protected __localizedCells: {
|
||||
yes: {
|
||||
text: string;
|
||||
elements: Set<HTMLTableCellElement>;
|
||||
};
|
||||
no: {
|
||||
text: string;
|
||||
elements: Set<HTMLTableCellElement>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Create a new historized symbol editor pane.
|
||||
* @param element The element to contain the editor pane.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: StringEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Sets a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: string | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): string;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Process the editors read-only mode.
|
||||
*/
|
||||
protected __processIsReadOnly(): void;
|
||||
/**
|
||||
* Callback method that handles the symbol watch of the list of historized symbols.
|
||||
* @param data The data returned be the watch.
|
||||
*/
|
||||
protected __onHistorizedSymbolsWatch(data: TcHmi.Symbol.IServerWatchResultObject<HistorizedSymbolEditorPane.HistorizedSymbolList>): void;
|
||||
/**
|
||||
* Event handler for the click event of table rows.
|
||||
* @param event The event to handle.
|
||||
*/
|
||||
protected __onRowClick(event: MouseEvent): void;
|
||||
/**
|
||||
* Event handler for the double click event of table rows.
|
||||
* @param event The event to handle.
|
||||
*/
|
||||
protected __onRowDoubleClick(event: MouseEvent): void;
|
||||
/**
|
||||
* Selects the given row.
|
||||
* @param row The row to select.
|
||||
*/
|
||||
protected __select(row: HTMLTableRowElement | null): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<S & Editor.EditorSettings & HistorizedSymbolEditor.Settings>): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts & HistorizedSymbolEditor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace HistorizedSymbolEditorPane {
|
||||
type HistorizedSymbolList = TcHmi.Dictionary<{
|
||||
interval: string;
|
||||
maxEntries: number;
|
||||
recordingEnabled: boolean;
|
||||
rowLimit: number;
|
||||
}>;
|
||||
}
|
||||
import _HistorizedSymbolEditorPane = HistorizedSymbolEditorPane;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let HistorizedSymbolEditorPane: typeof _HistorizedSymbolEditorPane;
|
||||
type HistorizedSymbolEditorPane = _HistorizedSymbolEditorPane;
|
||||
namespace HistorizedSymbolEditorPane {
|
||||
type HistorizedSymbolList = _HistorizedSymbolEditorPane.HistorizedSymbolList;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=HistorizedSymbolEditorPane.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,87 @@
|
||||
import { ButtonBasedEditor } from '../BaseEditors/ButtonBasedEditor.js';
|
||||
import type { Editor } from '../BaseEditors/Editor.js';
|
||||
import { StringEditor } from '../BaseEditors/StringEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor for historized symbols.
|
||||
*/
|
||||
export declare class HistorizedSymbolEditor extends ButtonBasedEditor<string, StringEditor.Info> {
|
||||
#private;
|
||||
protected __value: string;
|
||||
protected __stringEditor: StringEditor;
|
||||
protected __popupHeader: string;
|
||||
protected __settings: Partial<Editor.Settings & HistorizedSymbolEditor.Settings>;
|
||||
protected __localizations: Partial<Editor.LocalizableTexts & HistorizedSymbolEditor.LocalizableTexts> | undefined;
|
||||
/**
|
||||
* Create a new historized symbol editor.
|
||||
* @param element The element to contain the editor.
|
||||
* @param editorInfo An object containing information about the editor and the type of value to edit.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(element: HTMLElement, editorInfo: StringEditor.Info, factory: EditorFactory);
|
||||
/**
|
||||
* Calls all event destroyers.
|
||||
*/
|
||||
destroy(): void;
|
||||
/**
|
||||
* Opens the popup for the editor.
|
||||
*/
|
||||
protected openPopup(): Promise<void>;
|
||||
/**
|
||||
* Set a new Value.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: string | null): void;
|
||||
/**
|
||||
* Gets the current raw value of the editor. This value might be invalid and, if it is valid, might differ from the value returned by getState.
|
||||
* To get the final actual value, always use getState.
|
||||
*/
|
||||
getRawValue(): string;
|
||||
/**
|
||||
* Processes the current editor info.
|
||||
*/
|
||||
protected __processEditorInfo(): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors. Settings are organized by editor type. Passing in an
|
||||
* object that does not contain settings for a specific editor type will not clear potentially existing settings
|
||||
* for that editor type.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<S & Editor.EditorSettings & HistorizedSymbolEditor.Settings>): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<L & Editor.LocalizableTexts & HistorizedSymbolEditor.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace HistorizedSymbolEditor {
|
||||
type LocalizableTexts = {
|
||||
historizedSymbolEditor: Partial<{
|
||||
promptHeader: TcHmi.Localizable;
|
||||
nameColumnHeader: TcHmi.Localizable;
|
||||
dataTypeColumnHeader: TcHmi.Localizable;
|
||||
recordingColumnHeader: TcHmi.Localizable;
|
||||
intervalColumnHeader: TcHmi.Localizable;
|
||||
maxEntriesColumnHeader: TcHmi.Localizable;
|
||||
yesText: TcHmi.Localizable;
|
||||
noText: TcHmi.Localizable;
|
||||
}>;
|
||||
};
|
||||
type Settings = {
|
||||
historizedSymbolEditor: Partial<{
|
||||
domain: string;
|
||||
}>;
|
||||
};
|
||||
}
|
||||
import _HistorizedSymbolEditor = HistorizedSymbolEditor;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let HistorizedSymbolEditor: typeof _HistorizedSymbolEditor;
|
||||
type HistorizedSymbolEditor = _HistorizedSymbolEditor;
|
||||
namespace HistorizedSymbolEditor {
|
||||
type LocalizableTexts = _HistorizedSymbolEditor.LocalizableTexts;
|
||||
type Settings = _HistorizedSymbolEditor.Settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=HistorizedSymbolEditor.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ButtonBasedEditor}from"../BaseEditors/ButtonBasedEditor.js";import{StringEditor}from"../BaseEditors/StringEditor.js";import{EditorPrompt}from"../Popups/EditorPrompt.js";import{HistorizedSymbolEditorPane}from"./EditorPanes/HistorizedSymbolEditorPane.js";export class HistorizedSymbolEditor extends ButtonBasedEditor{static#tchmiFQN="TcHmi.Controls.Helpers."+this.name;__value="";__stringEditor;__popupHeader="";constructor(element,editorInfo,factory){super(element,editorInfo,factory),this.__textSpan.classList.remove("value-description"),this.__textSpan.classList.add("value-editor"),this.__stringEditor=new StringEditor(this.__textSpan,editorInfo,factory),this.__stringEditor.onChange.add(()=>{const stringState=this.__stringEditor.getState(),value=stringState.isValid?stringState.value:this.__stringEditor.getRawValue();this.__value=value,this.__popup?.setValue(value);const historizedSymbolState=this.getState();this.__container.classList.toggle("invalid",!historizedSymbolState.isValid),this.__onChangeManager.trigger(this,historizedSymbolState)}),this.__stringEditor.onConfirm.add(()=>{const state=this.getState();state.isValid&&this.__onConfirmManager.trigger(this,state)}),this.__processEditorInfo(),this.__localizations={...this.__localizations,historizedSymbolEditor:{promptHeader:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Prompt_Header_HistorizedSymbol%/l%",nameColumnHeader:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Column_Header_Name%/l%",dataTypeColumnHeader:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Column_Header_DataType%/l%",recordingColumnHeader:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Column_Header_Recording%/l%",intervalColumnHeader:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Column_Header_Interval%/l%",maxEntriesColumnHeader:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Column_Header_MaxEntries%/l%",yesText:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Text_Yes%/l%",noText:"%l%Package::Beckhoff.TwinCAT.HMI.Controls::Helpers_JsonEditors_Text_No%/l%"}}}destroy(){super.destroy(),this.__popup?.destroy(!0)}async openPopup(){this.__popup||(this.__popup=new EditorPrompt(this.__editorInfo,HistorizedSymbolEditorPane,this.__factory),this.__popup.setBackgroundAction({close:!0,action:"cancel"}),this.__popup.setIsReadOnly(this.__isReadOnly),this.__popup.setSettings(this.__settings),this.__popup.setLocalizations({buttonTextOk:this.__localizations?.editorPrompt?.buttonTextOk,buttonTooltipOk:this.__localizations?.editorPrompt?.buttonTooltipOk,buttonTextCancel:this.__localizations?.editorPrompt?.buttonTextCancel,buttonTooltipCancel:this.__localizations?.editorPrompt?.buttonTooltipCancel,editorLocalizations:this.__localizations}),this.__popupHeader&&this.__popup.setHeaderText(this.__popupHeader));try{this.__popup.setValue(this.__value);const result=await this.__popup.prompt();if(result.isOk){this.__value=result.value,this.__stringEditor.setValue(result.value);const state=this.getState();this.__container.classList.toggle("invalid",!state.isValid),this.__onChangeManager.trigger(this,state),state.isValid&&this.__onConfirmManager.trigger(this,state)}}catch(ex){}}setValue(value){this.__value=value??"",this.__stringEditor.setValue(value),this.__popup?.setValue(value);const state=this.getState();this.__container.classList.toggle("invalid",!state.isValid),this.__onChangeManager.trigger(this,state)}getRawValue(){return this.__value}__processEditorInfo(){this.__popup?.setEditorInfo(this.__editorInfo),this.__container.classList.toggle("invalid",!this.getState().isValid)}setSettings(settings){super.setSettings(settings)}setLocalizations(texts){super.setLocalizations(texts),this.__localizations?.historizedSymbolEditor?.promptHeader&&this.__watchLocalization("promptHeader","string"==typeof this.__localizations.historizedSymbolEditor.promptHeader?{symbolExpression:this.__localizations.historizedSymbolEditor.promptHeader,formatValues:[]}:this.__localizations.historizedSymbolEditor.promptHeader,text=>{this.__popupHeader=text,this.__popup?.setHeaderText(text)})}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.HistorizedSymbolEditor=HistorizedSymbolEditor;
|
||||
@@ -0,0 +1,190 @@
|
||||
import type { TcHmiControl } from 'Beckhoff.TwinCAT.HMI.Framework/index.esm.js';
|
||||
import type { Editor } from './BaseEditors/Editor.js';
|
||||
import { HistorizedSymbolEditor } from './CustomEditors/HistorizedSymbolEditor.js';
|
||||
import * as SchemaParser from './SchemaParser.js';
|
||||
/**
|
||||
* Factory to create JSON editors
|
||||
*/
|
||||
export declare class EditorFactory<S extends Editor.Settings = Editor.Settings & HistorizedSymbolEditor.Settings, L extends Editor.Localizables = Editor.Localizables & HistorizedSymbolEditor.LocalizableTexts> {
|
||||
#private;
|
||||
protected __customEditors: {
|
||||
predicate: (schema: TcHmi.JsonSchema, info: Editor.EditorInfo) => boolean;
|
||||
editor: {
|
||||
singleLine: Editor.Constructor<unknown>;
|
||||
pane?: Editor.Constructor<unknown>;
|
||||
};
|
||||
}[];
|
||||
protected __options: EditorFactory.Options<S, L> & {
|
||||
factorySettings: EditorFactory.Settings;
|
||||
};
|
||||
/**
|
||||
* Creates a new EditorFactory instance.
|
||||
* @param options Options for this EditorFactory instance.
|
||||
*/
|
||||
constructor(options?: EditorFactory.Options<S, L>);
|
||||
/**
|
||||
* Create a new editor from a given symbol. Throws an exception if the given symbol cannot be resolved to a
|
||||
* schema.
|
||||
* @param symbol A TcHmi symbol that contains the data that will be edited with this editor.
|
||||
* @param element The element to contain the editor.
|
||||
*/
|
||||
fromSymbol(symbol: string | TcHmi.Symbol | TcHmi.SymbolExpression, element: HTMLElement): Promise<Editor<any>>;
|
||||
/**
|
||||
* Create a new editor from a given TcHmi type. Throws an exception if the given type cannot be resolved to a
|
||||
* schema.
|
||||
* @param type The type of the data that will be edited with this editor.
|
||||
* @param element The element to contain the editor.
|
||||
*/
|
||||
fromType(type: string, element: HTMLElement): Editor<any, Editor.EditorInfo>;
|
||||
/**
|
||||
* Create a new editor from a given JSON schema.
|
||||
* @param schema A JSON schema that describes the data that will be edited with this editor.
|
||||
* @param element The element to contain the editor.
|
||||
*/
|
||||
fromSchema(schema: TcHmi.JsonSchema, element: HTMLElement): Editor<any, Editor.EditorInfo>;
|
||||
/**
|
||||
* Create a new editor from a given EditorInfo object.
|
||||
* @param info An object containing information about the editor and the type of value to edit. Can be obtained
|
||||
* from SchemaParser.parse().
|
||||
* @param element The element to contain the editor.
|
||||
* @param parent Will be set if this method is used to create a sub-editor for an editor pane.
|
||||
*/
|
||||
fromEditorInfo(info: Editor.EditorInfo, element: HTMLElement, parent?: Editor<unknown> | null): Editor<any, Editor.EditorInfo>;
|
||||
/**
|
||||
* Register a custom editor to handle a specific data type.
|
||||
* @param predicate A predicate function to determine the data type this editor should handle. This function
|
||||
* will receive the schema and EditorInfo that is used to create an editor and should return true to indicate
|
||||
* that the given schema or EditorInfo can be handled by this editor.
|
||||
* @param editor The editor class to register.
|
||||
*/
|
||||
registerEditor<E extends Editor<unknown>>(predicate: (schema: TcHmi.JsonSchema, info: Editor.EditorInfo) => boolean, editor: Editor.GenericConstructor<E, unknown> | {
|
||||
singleLine: Editor.GenericConstructor<E, unknown>;
|
||||
pane: Editor.Constructor<unknown>;
|
||||
}): EditorFactory<S & EditorFactory.TryUnwrapPartial<Parameters<E['setSettings']>[0]>, L & EditorFactory.TryUnwrapPartial<Parameters<E['setLocalizations']>[0]>>;
|
||||
/**
|
||||
* Register a custom editor to handle a specific data type.
|
||||
* @param metaType A string that will be compared to the frameworkMetaType property of a JSON schema. If exactly
|
||||
* equal, this editor will be determined to be able to handle a given schema.
|
||||
* @param editor The editor class to register.
|
||||
*/
|
||||
registerEditor<E extends Editor<unknown>>(metaType: string, editor: Editor.GenericConstructor<E, unknown> | {
|
||||
singleLine: Editor.GenericConstructor<E, unknown>;
|
||||
pane: Editor.Constructor<unknown>;
|
||||
}): EditorFactory<S & EditorFactory.TryUnwrapPartial<Parameters<E['setSettings']>[0]>, L & EditorFactory.TryUnwrapPartial<Parameters<E['setLocalizations']>[0]>>;
|
||||
/**
|
||||
* Register a custom editor to handle a specific data type.
|
||||
* @param metaTypes An array of strings that will be compared to the frameworkMetaType property of a JSON
|
||||
* schema. If the schemas frameworkMetaType property is exactly equal to one of the strings in this array, this
|
||||
* editor will be determined to be able to handle that schema.
|
||||
* @param editor The editor class to register.
|
||||
*/
|
||||
registerEditor<E extends Editor<unknown>>(metaTypes: string[], editor: Editor.GenericConstructor<E, unknown> | {
|
||||
singleLine: Editor.GenericConstructor<E, unknown>;
|
||||
pane: Editor.Constructor<unknown>;
|
||||
}): EditorFactory<S & EditorFactory.TryUnwrapPartial<Parameters<E['setSettings']>[0]>, L & EditorFactory.TryUnwrapPartial<Parameters<E['setLocalizations']>[0]>>;
|
||||
/**
|
||||
* Get the control that is used as the parent control for editors created by this factory.
|
||||
*/
|
||||
get parentControl(): TcHmiControl.Control | null;
|
||||
/**
|
||||
* Set the control that is used as the parent control for editors created by this factory.
|
||||
* @param control The control owning editors created by this factory.
|
||||
*/
|
||||
set parentControl(control: TcHmiControl.Control | null);
|
||||
/**
|
||||
* Get the current text overwrites that are used when an editor is created.
|
||||
*/
|
||||
get texts(): Partial<L & Editor.LocalizableTexts> | null;
|
||||
/**
|
||||
* Set the current text overwrites that are used when an editor is created.
|
||||
* @param texts A collection of static or localized texts to overwrite the default localized texts in the
|
||||
* editor.
|
||||
*/
|
||||
set texts(texts: Partial<L & Editor.LocalizableTexts> | null);
|
||||
/**
|
||||
* Get the current editor settings.
|
||||
*/
|
||||
get editorSettings(): Partial<S & Editor.EditorSettings> | null;
|
||||
/**
|
||||
* Set the settings that are applied to newly created editors.
|
||||
* @param settings The settings to apply to newly created editors.
|
||||
*/
|
||||
set editorSettings(settings: Partial<S & Editor.EditorSettings> | null);
|
||||
/**
|
||||
* Get the current editor settings.
|
||||
*/
|
||||
get factorySettings(): Partial<EditorFactory.Settings> | null;
|
||||
/**
|
||||
* Set the settings that are applied to newly created editors.
|
||||
* @param settings The settings to apply to newly created editors.
|
||||
*/
|
||||
set factorySettings(settings: Partial<EditorFactory.Settings> | null);
|
||||
/**
|
||||
* Get the name generator that is currently used when a JSON schema is parsed.
|
||||
*/
|
||||
get nameGenerator(): SchemaParser.NameGenerator | string | null;
|
||||
/**
|
||||
* Set the name generator that is currently used when a JSON schema is parsed.
|
||||
* @param nameGenerator A function that generates a name from the resulting editor type, the title and id of the
|
||||
* schema and the schemas that the resulting editor info is based on. This can be more than one schema if anyOf
|
||||
* or oneOf is used. If the function returns null, the SchemaParser uses its own algorithm to generate a name.
|
||||
*/
|
||||
set nameGenerator(nameGenerator: SchemaParser.NameGenerator | string | null);
|
||||
}
|
||||
export declare namespace EditorFactory {
|
||||
/**
|
||||
* Options for EditorFactory instances.
|
||||
*/
|
||||
interface Options<S extends Editor.Settings, L extends Editor.Localizables> {
|
||||
/**
|
||||
* The control owning editors created by this factory.
|
||||
*/
|
||||
parentControl?: TcHmiControl.Control | null;
|
||||
/**
|
||||
* A collection of static or localized texts to overwrite the default localized texts in the editor.
|
||||
*/
|
||||
texts?: Partial<L & Editor.LocalizableTexts>;
|
||||
/**
|
||||
* Settings to apply to newly created editors.
|
||||
*/
|
||||
editorSettings?: Partial<S & Editor.EditorSettings>;
|
||||
/**
|
||||
* Settings that are used by the factory to create editors.
|
||||
*/
|
||||
factorySettings?: Partial<Settings>;
|
||||
/**
|
||||
* A function that generates a name from the resulting editor type, the title and id of the schema and the
|
||||
* schemas that the resulting editor info is based on. This can be more than one schema if anyOf or oneOf is
|
||||
* used. If the function returns null, the SchemaParser uses its own algorithm to generate a name.
|
||||
* Alternatively a string can be passed in directly which will be used as the name for the top-level editor.
|
||||
*/
|
||||
nameGenerator?: SchemaParser.NameGenerator | string;
|
||||
}
|
||||
/**
|
||||
* Settings for EditorFactory instances.
|
||||
*/
|
||||
interface Settings {
|
||||
/**
|
||||
* Controls whether the factory should create editor panes instead of single-line editors if available. For
|
||||
* this to work with custom editors, they must be registered together with their respective pane.
|
||||
* No: Default behavior. The factory always returns a single-line editor.
|
||||
* Always: The factors always returns editor panes, if available. This may result in multiple nested panes.
|
||||
* FirstLevel: The factory tries to return editor panes only for the first level of nesting.
|
||||
*/
|
||||
preferPanes: 'No' | 'Always' | 'FirstLevel';
|
||||
}
|
||||
type TryUnwrapPartial<P> = P extends Partial<infer T> ? T : P;
|
||||
}
|
||||
import _EditorFactory = EditorFactory;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let EditorFactory: typeof _EditorFactory;
|
||||
type EditorFactory<S extends Editor.Settings = Editor.Settings & HistorizedSymbolEditor.Settings, L extends Editor.Localizables = Editor.Localizables & HistorizedSymbolEditor.LocalizableTexts> = _EditorFactory<S, L>;
|
||||
namespace EditorFactory {
|
||||
type Options<S extends Editor.Settings, L extends Editor.Localizables> = _EditorFactory.Options<S, L>;
|
||||
type Settings = _EditorFactory.Settings;
|
||||
type TryUnwrapPartial<P> = _EditorFactory.TryUnwrapPartial<P>;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=EditorFactory.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,24 @@
|
||||
import { EditorPrompt } from './EditorPrompt.js';
|
||||
import type { ArrayEditor } from '../BaseEditors/ArrayEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor prompt for arrays.
|
||||
*/
|
||||
export declare class ArrayEditorPrompt extends EditorPrompt<any[], ArrayEditor.Info> {
|
||||
/**
|
||||
* Creates a new ArrayEditorPrompt instance.
|
||||
* @param editorInfo Information about the array editor.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(editorInfo: ArrayEditor.Info, factory: EditorFactory);
|
||||
}
|
||||
declare const _ArrayEditorPrompt: typeof ArrayEditorPrompt;
|
||||
type tArrayEditorPrompt = ArrayEditorPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ArrayEditorPrompt: typeof _ArrayEditorPrompt;
|
||||
type ArrayEditorPrompt = tArrayEditorPrompt;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=ArrayEditorPrompt.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{EditorPrompt}from"./EditorPrompt.js";import{ArrayEditorPane}from"../BaseEditors/EditorPanes/ArrayEditorPane.js";export class ArrayEditorPrompt extends EditorPrompt{constructor(editorInfo,factory){super(editorInfo,ArrayEditorPane,factory)}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.ArrayEditorPrompt=ArrayEditorPrompt;
|
||||
@@ -0,0 +1,84 @@
|
||||
import type { Editor } from '../BaseEditors/Editor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import { OkCancelPrompt } from '../../TcHmiPopups/OkCancelPrompt.js';
|
||||
/**
|
||||
* Base editor prompt.
|
||||
*/
|
||||
export declare class EditorPrompt<T, I extends Editor.EditorInfo = Editor.EditorInfo> extends OkCancelPrompt<T> {
|
||||
protected __editorPane: Editor<T, I>;
|
||||
/**
|
||||
* Creates a new EditorPrompt instance.
|
||||
* @param editorInfo Information about the array editor.
|
||||
* @param editorConstructor The constructor of the editor pane this prompt should host.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(editorInfo: I, editorConstructor: Editor.Constructor<T, I>, factory: EditorFactory);
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
* @param force If true, child controls will be removed from the parent control before destruction, to ensure destruction in case of keepAlive === true.
|
||||
*/
|
||||
destroy(force?: boolean): void;
|
||||
/**
|
||||
* Sets the header text of the popup.
|
||||
* @param text The text to use in the popups header.
|
||||
*/
|
||||
setHeaderText(text: string): void;
|
||||
/**
|
||||
* Sets the editorInfo.
|
||||
* @param editorInfo The editorInfo to set.
|
||||
*/
|
||||
setEditorInfo(editorInfo: I): void;
|
||||
/**
|
||||
* Set the editors read-only status. A read-only editor will display values, but not allow the user to change
|
||||
* them.
|
||||
* @param isReadOnly Whether the editor should be in read-only mode or not.
|
||||
*/
|
||||
setIsReadOnly(isReadOnly: boolean): void;
|
||||
/**
|
||||
* Set settings for this editor and potential sub-editors.
|
||||
* @param settings The settings to apply.
|
||||
*/
|
||||
setSettings<S extends Editor.Settings>(settings: Partial<Editor.EditorSettings & S>): void;
|
||||
/**
|
||||
* Set a new Value. Returns whether the given value is valid.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
setValue(value: T | null): void;
|
||||
/**
|
||||
* Handler for the change event of the editor pane.
|
||||
* @param _editor The editor that changed.
|
||||
* @param state The changed editors state.
|
||||
*/
|
||||
protected __onEditorChanged(_editor: Editor<T, I>, state: Editor.State<T>): void;
|
||||
/**
|
||||
* Handler for the confirm event of the editor pane.
|
||||
* @param _editor The editor that was confirmed.
|
||||
* @param _state The confirmed editors state.
|
||||
*/
|
||||
protected __onEditorConfirmed(_editor: Editor<T, I>, _state: Editor.ValidState<T>): void;
|
||||
/**
|
||||
* Performs the action for the OK button, i.e. calling prompt.answer().
|
||||
*/
|
||||
protected __ok(): void;
|
||||
/**
|
||||
* Sets localizable texts to the given localization symbols.
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
*/
|
||||
setLocalizations<L extends Editor.Localizables = Editor.Localizables>(texts: Partial<EditorPrompt.LocalizableTexts<L>>): void;
|
||||
}
|
||||
export declare namespace EditorPrompt {
|
||||
interface LocalizableTexts<L extends Editor.Localizables = Editor.Localizables> extends OkCancelPrompt.LocalizableTexts {
|
||||
editorLocalizations: Partial<L & Editor.LocalizableTexts>;
|
||||
}
|
||||
}
|
||||
import _EditorPrompt = EditorPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let EditorPrompt: typeof _EditorPrompt;
|
||||
type EditorPrompt<T, I extends Editor.EditorInfo = Editor.EditorInfo> = _EditorPrompt<T, I>;
|
||||
namespace EditorPrompt {
|
||||
type LocalizableTexts<L extends Editor.Localizables = Editor.Localizables> = _EditorPrompt.LocalizableTexts<L>;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=EditorPrompt.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
var __runInitializers=this&&this.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=this&&this.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(void 0!==f&&"function"!=typeof f)throw new TypeError("Function expected");return f}for(var _,kind=contextIn.kind,key="getter"===kind?"get":"setter"===kind?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]="access"===p?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])("accessor"===kind?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if("accessor"===kind){if(void 0===result)continue;if(null===result||"object"!=typeof result)throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&("field"===kind?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};import{OkCancelPrompt}from"../../TcHmiPopups/OkCancelPrompt.js";let EditorPrompt=(()=>{var _a,_b;let ___onEditorChanged_decorators,___onEditorConfirmed_decorators,_classSuper=OkCancelPrompt,_instanceExtraInitializers=[];return class extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onEditorChanged_decorators=[(_a=TcHmi).CallbackMethod.bind(_a)],___onEditorConfirmed_decorators=[(_b=TcHmi).CallbackMethod.bind(_b)],__esDecorate(this,null,___onEditorChanged_decorators,{kind:"method",name:"__onEditorChanged",static:!1,private:!1,access:{has:obj=>"__onEditorChanged"in obj,get:obj=>obj.__onEditorChanged},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onEditorConfirmed_decorators,{kind:"method",name:"__onEditorConfirmed",static:!1,private:!1,access:{has:obj=>"__onEditorConfirmed"in obj,get:obj=>obj.__onEditorConfirmed},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}__editorPane=__runInitializers(this,_instanceExtraInitializers);constructor(editorInfo,editorConstructor,factory){super(factory.parentControl),this.__elementHeader.textContent=editorInfo.name,this.__editorPane=new editorConstructor(this.__elementContent,editorInfo,factory),this.__editorPane.onChange.add(this.__onEditorChanged),this.__editorPane.onConfirm.add(this.__onEditorConfirmed)}destroy(force=!1){super.destroy(force),this.__editorPane.destroy()}setHeaderText(text){this.__elementHeader.textContent=text}setEditorInfo(editorInfo){this.__editorPane.setEditorInfo(editorInfo)}setIsReadOnly(isReadOnly){this.__editorPane.setIsReadOnly(isReadOnly)}setSettings(settings){this.__editorPane.setSettings(settings)}setValue(value){this.__editorPane.setValue(value)}__onEditorChanged(_editor,state){this.__okButton.setIsEnabled(state.isValid)}__onEditorConfirmed(_editor,_state){this.__ok()}__ok(){const state=this.__editorPane.getState();state.isValid?this.__prompt?.answer({isOk:!0,value:state.value}):this.__prompt?.error(new Error("Editor pane contained invalid values."))}setLocalizations(texts){super.setLocalizations(texts),texts.editorLocalizations&&this.__editorPane.setLocalizations(texts.editorLocalizations)}}})();export{EditorPrompt};TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.EditorPrompt=EditorPrompt;
|
||||
@@ -0,0 +1,24 @@
|
||||
import { EditorPrompt } from './EditorPrompt.js';
|
||||
import type { ObjectEditor } from '../BaseEditors/ObjectEditor.js';
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
/**
|
||||
* Editor prompt for objects.
|
||||
*/
|
||||
export declare class ObjectEditorPrompt extends EditorPrompt<object, ObjectEditor.Info> {
|
||||
/**
|
||||
* Creates a new ObjectEditorPrompt instance.
|
||||
* @param editorInfo Information about the object editor.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(editorInfo: ObjectEditor.Info, factory: EditorFactory);
|
||||
}
|
||||
declare const _ObjectEditorPrompt: typeof ObjectEditorPrompt;
|
||||
type tObjectEditorPrompt = ObjectEditorPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ObjectEditorPrompt: typeof _ObjectEditorPrompt;
|
||||
type ObjectEditorPrompt = tObjectEditorPrompt;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=ObjectEditorPrompt.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{EditorPrompt}from"./EditorPrompt.js";import{ObjectEditorPane}from"../BaseEditors/EditorPanes/ObjectEditorPane.js";export class ObjectEditorPrompt extends EditorPrompt{constructor(editorInfo,factory){super(editorInfo,ObjectEditorPane,factory)}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.ObjectEditorPrompt=ObjectEditorPrompt;
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { EditorFactory } from '../EditorFactory.js';
|
||||
import { EditorPrompt } from './EditorPrompt.js';
|
||||
import type { TupleEditor } from '../BaseEditors/TupleEditor.js';
|
||||
/**
|
||||
* Editor prompt for tuples.
|
||||
*/
|
||||
export declare class TupleEditorPrompt extends EditorPrompt<any[], TupleEditor.Info> {
|
||||
/**
|
||||
* Creates a new TupleEditorPrompt instance.
|
||||
* @param editorInfo Information about the array editor.
|
||||
* @param factory An editor factory that will be used to create sub-editors.
|
||||
*/
|
||||
constructor(editorInfo: TupleEditor.Info, factory: EditorFactory);
|
||||
}
|
||||
declare const _TupleEditorPrompt: typeof TupleEditorPrompt;
|
||||
type tTupleEditorPrompt = TupleEditorPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TupleEditorPrompt: typeof _TupleEditorPrompt;
|
||||
type TupleEditorPrompt = tTupleEditorPrompt;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=TupleEditorPrompt.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{EditorPrompt}from"./EditorPrompt.js";import{TupleEditorPane}from"../BaseEditors/EditorPanes/TupleEditorPane.js";export class TupleEditorPrompt extends EditorPrompt{constructor(editorInfo,factory){super(editorInfo,TupleEditorPane,factory)}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.TupleEditorPrompt=TupleEditorPrompt;
|
||||
@@ -0,0 +1,103 @@
|
||||
import { Editor } from './BaseEditors/Editor.js';
|
||||
/**
|
||||
* Parses a JSON schema into editor info objects.
|
||||
* @param schema The schema to parse.
|
||||
*/
|
||||
export declare function parse(schema: TcHmi.JsonSchema): Editor.EditorInfo;
|
||||
/**
|
||||
* Parses a JSON schema into editor info objects.
|
||||
* @param schema The schema to parse.
|
||||
* @param customName A custom name to use for the resulting editor info.
|
||||
*/
|
||||
export declare function parse(schema: TcHmi.JsonSchema, customName: string): Editor.EditorInfo;
|
||||
/**
|
||||
* Parses a JSON schema into editor info objects.
|
||||
* @param schema The schema to parse.
|
||||
* @param nameGenerator A function that generates a name from the resulting editor type, the title and id of the
|
||||
* schema and the schemas that the resulting editor info is based on. This can be more than one schema if anyOf
|
||||
* or oneOf is used. If the function returns null, the SchemaParser uses its own algorithm to generate a name.
|
||||
*/
|
||||
export declare function parse(schema: TcHmi.JsonSchema, nameGenerator: (editorType: Editor.EditorType, schemaTitle: string | undefined, schemaId: string | undefined, schemas: TcHmi.JsonSchema[]) => string | null): Editor.EditorInfo;
|
||||
/**
|
||||
* Resolves allOf members by combining all entries of the allOf into one schema.
|
||||
* @param schema The schema to be resolved.
|
||||
*/
|
||||
export declare function resolveAllOf(schema: TcHmi.JsonSchema): TcHmi.JsonSchema;
|
||||
/**
|
||||
* Recursively resolves references in a schema. Can handle recursive schemas.
|
||||
* The given object is not modified.
|
||||
* @param schema The schema to resolve.
|
||||
*/
|
||||
export declare function resolveReferences(schema: TcHmi.JsonSchema): TcHmi.JsonSchema;
|
||||
/**
|
||||
* Generate a data type name for a given JSON schema.
|
||||
* @param schema The schema to generate the name for.
|
||||
*/
|
||||
export declare function generateName(schema: TcHmi.JsonSchema | {
|
||||
title?: string;
|
||||
id?: string;
|
||||
type?: string;
|
||||
}): string;
|
||||
/**
|
||||
* Merges two or more editor infos together by creating an editor info that only accepts values that satisfy all passed in editor infos.
|
||||
* This functions trys to return an editor info of the same type as the first parameter.
|
||||
* @param toMerge The editor infos to be merged.
|
||||
*/
|
||||
export declare function mergeEditorInfos(...toMerge: Editor.EditorInfo[]): Editor.EditorInfo;
|
||||
/**
|
||||
* Compares two editor infos and determines if they are equivalent.
|
||||
* @param a The first editor info to compare.
|
||||
* @param b The second editor info to compare.
|
||||
*/
|
||||
export declare function editorInfoEquivalent(a: Editor.EditorInfo, b: Editor.EditorInfo): boolean;
|
||||
/**
|
||||
* Generates a name for the editor info from the available information.
|
||||
* @param editorType The type the resulting editor will have.
|
||||
* @param schemaTitle The title of the schema, or undefined if the schema has no title.
|
||||
* @param schemaId The id of the schema, or undefined if the schema has no id.
|
||||
* @param schemas The schemas the editor info was generated from. Can be more than one if an anyOf or oneOf schema was used.
|
||||
*/
|
||||
export type NameGenerator = (editorType: Editor.EditorType, schemaTitle: string | undefined, schemaId: string | undefined, schemas: TcHmi.JsonSchema[]) => string | null;
|
||||
export interface TopLevelType {
|
||||
editorType: Editor.EditorType;
|
||||
rawType: TcHmi.JsonDataTypeNames;
|
||||
convert?: TcHmi.JsonSchema['convert'];
|
||||
schema: TcHmi.JsonSchema;
|
||||
}
|
||||
export interface CondensedType {
|
||||
editorType: Editor.EditorType;
|
||||
convertibles: TopLevelType[];
|
||||
condensedFrom: TopLevelType[];
|
||||
id?: string;
|
||||
title?: string;
|
||||
}
|
||||
declare const _parse: typeof parse;
|
||||
type tParse = typeof parse;
|
||||
declare const _resolveAllOf: typeof resolveAllOf;
|
||||
type tResolveAllOf = typeof resolveAllOf;
|
||||
declare const _resolveReferences: typeof resolveReferences;
|
||||
type tResolveReferences = typeof resolveReferences;
|
||||
declare const _generateName: typeof generateName;
|
||||
type tGenerateName = typeof generateName;
|
||||
declare const _mergeEditorInfos: typeof mergeEditorInfos;
|
||||
type tMergeEditorInfos = typeof mergeEditorInfos;
|
||||
declare const _editorInfoEquivalent: typeof editorInfoEquivalent;
|
||||
type tEditorInfoEquivalent = typeof editorInfoEquivalent;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers.SchemaParser {
|
||||
let parse: typeof _parse;
|
||||
type parse = tParse;
|
||||
let resolveAllOf: typeof _resolveAllOf;
|
||||
type resolveAllOf = tResolveAllOf;
|
||||
let resolveReferences: typeof _resolveReferences;
|
||||
type resolveReferences = tResolveReferences;
|
||||
let generateName: typeof _generateName;
|
||||
type generateName = tGenerateName;
|
||||
let mergeEditorInfos: typeof _mergeEditorInfos;
|
||||
type mergeEditorInfos = tMergeEditorInfos;
|
||||
let editorInfoEquivalent: typeof _editorInfoEquivalent;
|
||||
type editorInfoEquivalent = tEditorInfoEquivalent;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=SchemaParser.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,109 @@
|
||||
import { Callback, type TcHmiControl } from 'Beckhoff.TwinCAT.HMI.Framework/index.esm.js';
|
||||
import type { Control as TcHmiButton } from '../../TcHmiButton/TcHmiButton.esm.js';
|
||||
import { Popup } from './Popup.js';
|
||||
export declare abstract class ButtonsPrompt<T> extends Popup<T> {
|
||||
protected __buttons: Map<string, {
|
||||
value: T;
|
||||
button: TcHmiButton;
|
||||
}>;
|
||||
protected __onButtonPressedManager: Callback.Collection<(name: string, value: T) => void>;
|
||||
onButtonPressed: Readonly<{
|
||||
add: (callback: (name: string, value: T) => void) => () => void;
|
||||
remove: (callback: (name: string, value: T) => void) => void;
|
||||
}>;
|
||||
protected __backgroundAction: ButtonsPrompt.BackgroundAction<T>;
|
||||
protected __closeButton: ButtonsPrompt.CloseButton<T>;
|
||||
/**
|
||||
* Creates a new ButtonsPrompt instance.
|
||||
* @param buttons A collection of attributes to generate buttons from and the value that should be used in the prompt answer for each button.
|
||||
* @param parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(buttons: TcHmi.Dictionary<{
|
||||
value: T;
|
||||
attributes: TcHmi.Dictionary<any>;
|
||||
keepPopupOpen?: boolean;
|
||||
}>, parentControl?: TcHmiControl.Control | null);
|
||||
/**
|
||||
* Aborts a prompted popup and performs the given action to answer the prompt. If no action is specified, the promise is rejected.
|
||||
* @param action The action to perform to answer the prompt.
|
||||
*/
|
||||
abort(action?: ButtonsPrompt.PromptAction<T>): void;
|
||||
/**
|
||||
* Creates a handler for the pressed event of a button.
|
||||
* @param value The value that should be used to answer the prompt when the button is clicked.
|
||||
*/
|
||||
protected __createPressedHandler(value: T, name: string, closePopup: boolean): () => void;
|
||||
/**
|
||||
* Returns the created buttons.
|
||||
*/
|
||||
getButtons(): Map<string, {
|
||||
value: T;
|
||||
button: TcHmiButton;
|
||||
}>;
|
||||
/**
|
||||
* Sets what happens when the user clicks the background while the popup is showing, or when the prompt is
|
||||
* aborted via API call.
|
||||
* @param action The action to perform. If the popup should be closed, you can specify the name of a button to
|
||||
* get the prompt to be answered as if this button was clicked, or directly specify a result to answer the
|
||||
* prompt with.
|
||||
*/
|
||||
setBackgroundAction(action: ButtonsPrompt.BackgroundAction<T>): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param button Defines whether to show the button and if yes, what action should be taken to answer the prompt.
|
||||
*/
|
||||
setCloseButton(button: ButtonsPrompt.CloseButton<T>): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param show Defines whether to show the button.
|
||||
*/
|
||||
setCloseButton(show: boolean): void;
|
||||
/**
|
||||
* Performs the background action.
|
||||
*/
|
||||
protected __performPromptAction(toPerform: ButtonsPrompt.PromptAction<T>): void;
|
||||
/**
|
||||
* DEPRECATED
|
||||
* Please use setTexts
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
* @deprecated Please use setTexts
|
||||
*/
|
||||
setLocalizations(texts: Partial<ButtonsPrompt.LocalizableTexts>): void;
|
||||
/**
|
||||
* Sets texts which can either be localizable or static.
|
||||
*/
|
||||
setTexts(texts: Partial<ButtonsPrompt.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace ButtonsPrompt {
|
||||
interface LocalizableTexts {
|
||||
headerText: TcHmi.Localizable;
|
||||
buttons: TcHmi.Dictionary<{
|
||||
text?: TcHmi.Localizable;
|
||||
tooltip?: TcHmi.Localizable;
|
||||
}>;
|
||||
}
|
||||
type BackgroundAction<R = any> = Popup.BackgroundAction<string> | {
|
||||
close: true;
|
||||
result: R;
|
||||
};
|
||||
type CloseButton<R = any> = Popup.CloseButton<string> | {
|
||||
show: true;
|
||||
result: R;
|
||||
};
|
||||
type PromptAction<R = any> = Popup.PromptAction<string> | {
|
||||
result: R;
|
||||
};
|
||||
}
|
||||
import _ButtonsPrompt = ButtonsPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let ButtonsPrompt: typeof _ButtonsPrompt;
|
||||
type ButtonsPrompt<T> = _ButtonsPrompt<T>;
|
||||
namespace ButtonsPrompt {
|
||||
type LocalizableTexts = _ButtonsPrompt.LocalizableTexts;
|
||||
type BackgroundAction<R = any> = _ButtonsPrompt.BackgroundAction<R>;
|
||||
type CloseButton<R = any> = _ButtonsPrompt.CloseButton<R>;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=ButtonsPrompt.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{Callback}from"Beckhoff.TwinCAT.HMI.Framework/index.esm.js";import{Popup}from"./Popup.js";export class ButtonsPrompt extends Popup{__buttons=new Map;__onButtonPressedManager=new Callback.Collection;onButtonPressed=this.__onButtonPressedManager.getManipulators();__backgroundAction={close:!0};__closeButton={show:!1};constructor(buttons,parentControl){super(parentControl);for(const[name,buttonDef]of Object.entries(buttons)){const button=TcHmi.ControlFactory.createEx("TcHmi.Controls.Beckhoff.TcHmiButton",`${this.__name}.${name}`,buttonDef.attributes,this.__parentControl);if(!button)throw new Error("Could not create controls for ButtonsPrompt.");const buttonElement=button.getElement()[0];buttonElement.classList.add(name+"-button"),this.__elementFooter.appendChild(buttonElement),this.__destroyers.push(TcHmi.EventProvider.register(button.getId()+".onPressed",this.__createPressedHandler(buttonDef.value,name,!buttonDef.keepPopupOpen))),this.__buttons.set(name,{value:buttonDef.value,button}),this.__childControls.push(button)}}abort(action){super.abort(action)}__createPressedHandler(value,name,closePopup){return()=>{if(this.__parentControl){if(!this.__parentControl.getIsEnabled())return;if(!TcHmi.Access.checkAccess(this.__parentControl,"operate"))return}closePopup&&(this.__prompt?this.__prompt.answer(value):this.hide()),this.__onButtonPressedManager.trigger(name,value)}}getButtons(){return this.__buttons}setBackgroundAction(action){super.setBackgroundAction(action)}setCloseButton(buttonOrShow){super.setCloseButton(buttonOrShow)}__performPromptAction(toPerform){if(this.__prompt)if("action"in toPerform&&void 0!==toPerform.action){const button=this.__buttons.get(toPerform.action);button&&this.__prompt.answer(button.value)}else"result"in toPerform&&this.__prompt.answer(toPerform.result)}setLocalizations(texts){this.setTexts(texts)}setTexts(texts){if(this.__applyTextToElement("headerText",texts.headerText,this.__elementHeader),texts.buttons)for(const[name,localization]of Object.entries(texts.buttons)){const button=this.__buttons.get(name)?.button;button&&localization&&(this.__applyTextToControl("buttonText"+name,localization.text,button,"Text"),this.__applyTextToControl("buttonTooltip"+name,localization.tooltip,button,"Tooltip"))}}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.ButtonsPrompt=ButtonsPrompt;
|
||||
@@ -0,0 +1,289 @@
|
||||
import type { Control as TcHmiButton } from '../../TcHmiButton/TcHmiButton.esm.js';
|
||||
import { Control as TcHmiCombobox, type ListItemGeneric as TcHmiCombobox_ListItemGeneric } from '../../TcHmiCombobox/TcHmiCombobox.esm.js';
|
||||
import type { Control as TcHmiCheckbox } from '../../TcHmiCheckbox/TcHmiCheckbox.esm.js';
|
||||
import type { Control as TcHmiTextbox } from '../../TcHmiTextbox/TcHmiTextbox.esm.js';
|
||||
import type { Control as TcHmiDateTimeInput } from '../../TcHmiDateTimeInput/TcHmiDateTimeInput.esm.js';
|
||||
import { Popup } from './Popup.js';
|
||||
import type { OkCancelPrompt } from './OkCancelPrompt.js';
|
||||
export declare class FilterPrompt extends Popup<TcHmi.Filter> {
|
||||
protected __okButton: TcHmiButton;
|
||||
protected __cancelButton: TcHmiButton;
|
||||
protected __resetButton: TcHmiButton;
|
||||
protected __removeButton: TcHmiButton;
|
||||
protected __groupButton: TcHmiButton;
|
||||
protected __ungroupButton: TcHmiButton;
|
||||
protected __elementMenuBar: HTMLElement;
|
||||
protected __elementFilterTableHeader: HTMLElement;
|
||||
/** The element used to save the space for the group brackets */
|
||||
protected __elementIndentationHeader: HTMLElement;
|
||||
protected __elementFilterTable: HTMLElement;
|
||||
protected __elementFilterTableBody: HTMLElement;
|
||||
protected __filter: TcHmi.Filter;
|
||||
protected __currentFilter: TcHmi.Filter;
|
||||
protected __originalFilter: TcHmi.Filter;
|
||||
protected __schemaInfo: FilterPrompt.SchemaInfo;
|
||||
protected __localizableEnums: FilterPrompt.PathInfo[];
|
||||
protected __domainPaths: Map<string, _FilterPrompt.PathInfo>;
|
||||
protected __rows: FilterPrompt.RowData[];
|
||||
protected __selectedRows: FilterPrompt.SelectedRow[];
|
||||
protected __updateRequired: boolean;
|
||||
protected __groupInfo: {
|
||||
parent: FilterPrompt.FilterNesting;
|
||||
toGroup: (TcHmi.Comparison | TcHmi.Filter)[];
|
||||
} | null;
|
||||
protected __ungroupInfo: {
|
||||
parent: FilterPrompt.FilterNesting;
|
||||
toUngroup: FilterPrompt.FilterNesting;
|
||||
} | null;
|
||||
protected __onScroll(_event: Event): void;
|
||||
protected __onLocaleChangedDestroyer: TcHmi.DestroyFunction | null;
|
||||
protected __onLocaleChanged(): void;
|
||||
protected __localizeRequestId: number | null;
|
||||
protected __localization: TcHmi.Locale.PackageLocalization;
|
||||
protected __localizedElements: Map<HTMLElement, {
|
||||
key: string;
|
||||
parameters?: any[];
|
||||
}>;
|
||||
protected __localizationReader: TcHmi.Locale.LocalizationReader | undefined;
|
||||
protected __listDomainsSubscriptionId: number | null;
|
||||
protected __backgroundAction: Popup.BackgroundAction<OkCancelPrompt.AvailableActions>;
|
||||
protected __closeButton: Popup.CloseButton<OkCancelPrompt.AvailableActions>;
|
||||
/**
|
||||
* Creates a new OkCancelPrompt instance.
|
||||
* @param localizations A collection of localization symbol expressions to localize texts in the control.
|
||||
* @param parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(schema: TcHmi.JsonSchema | null, originalFilter: TcHmi.Filter, parentControl?: TcHmi.Controls.System.TcHmiControl | null);
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
* @param force If true, child controls will be removed from the parent control before destruction, to ensure destruction in case of keepAlive === true.
|
||||
*/
|
||||
destroy(force?: boolean): void;
|
||||
/**
|
||||
* Aborts a prompted popup and performs the given action to answer the prompt. If no action is specified, the promise is rejected.
|
||||
* @param action The action to perform to answer the prompt.
|
||||
*/
|
||||
abort(action?: Popup.PromptAction<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* Handler for the onPressed event of the OK button.
|
||||
*/
|
||||
protected __onOkPressed(): void;
|
||||
/**
|
||||
* Handler for the onPressed event of the cancel button.
|
||||
*/
|
||||
protected __onCancelPressed(): void;
|
||||
/**
|
||||
* Performs the action for the OK button, i.e. calling prompt.answer().
|
||||
*/
|
||||
protected __ok(): void;
|
||||
/**
|
||||
* Performs the action for the Cancel button.
|
||||
*/
|
||||
protected __cancel(): void;
|
||||
/**
|
||||
* Performs the action for the Reset button.
|
||||
*/
|
||||
protected __reset(): void;
|
||||
/**
|
||||
* Returns the original filter.
|
||||
*/
|
||||
getOriginalFilter(): TcHmi.Filter;
|
||||
/**
|
||||
* Sets what happens when the user clicks the background while the popup is showing, or when the prompt is
|
||||
* aborted via API call.
|
||||
* @param action The action to perform. If the popup should be closed, you can specify ok or cancel to perform
|
||||
* the associated action.
|
||||
*/
|
||||
setBackgroundAction(action: Popup.BackgroundAction<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param button Defines whether to show the button and if yes, what action should be taken to answer the prompt.
|
||||
*/
|
||||
setCloseButton(button: Popup.CloseButton<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param show Defines whether to show the button.
|
||||
*/
|
||||
setCloseButton(show: boolean): void;
|
||||
/**
|
||||
* Performs the given action.
|
||||
*/
|
||||
protected __performPromptAction(toPerform: Popup.PromptAction<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* Updates the filter configuration.
|
||||
* @param filter The current filter configuration.
|
||||
* @param resetable Whether the reset button should be enabled or disabled.
|
||||
*/
|
||||
update(filter: TcHmi.Filter, _resetable: boolean): void;
|
||||
/**
|
||||
* Update the visual representation of the filter
|
||||
*/
|
||||
protected __update(): void;
|
||||
/**
|
||||
* Shows the popup.
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* Hides the popup and clears the content of the table if necessary.
|
||||
*/
|
||||
hide(): void;
|
||||
/**
|
||||
* Clears the content of the table.
|
||||
*/
|
||||
protected __clear(): void;
|
||||
/**
|
||||
* Creates a new row for the filter configuration table.
|
||||
* @param indentation The indentation levels and whether this row marks the beginnig, end or middle of an indentation.
|
||||
* @param comparison The comparison to configure in this row.
|
||||
* @param logic The logic to configure in this row.
|
||||
*/
|
||||
protected __createRow(indentation: FilterPrompt.GroupingLevel[], parent: FilterPrompt.FilterNesting, comparison: TcHmi.Comparison, logic?: TcHmi.LogicOperator): HTMLTableRowElement;
|
||||
/**
|
||||
* Updates the controls for comparator and value after path has been changed or row has been created.
|
||||
* @param row An object containing the filter objects, table cell elements and controls
|
||||
*/
|
||||
protected __updateControls(row: FilterPrompt.RowData): void;
|
||||
/**
|
||||
* Gets the pathInfo for a given path.
|
||||
* @param path The path to get info for.
|
||||
*/
|
||||
protected __getPathInfo(path?: string): _FilterPrompt.PathInfo | null;
|
||||
/**
|
||||
* Adds the given row to the __selectedRows collection and enables/disables remove, group and ungroup buttons accordingly.
|
||||
* @param row The row to select
|
||||
*/
|
||||
protected __selectRow(row: FilterPrompt.SelectedRow): void;
|
||||
/**
|
||||
* Removes the given row from the __selectedRows collection and enables/disables remove, group and ungroup buttons accordingly.
|
||||
* @param row The row to deselect
|
||||
*/
|
||||
protected __deselectRow(row: FilterPrompt.SelectedRow): void;
|
||||
/**
|
||||
* Adds a new row below the lowest selected row or at the end of the table.
|
||||
*/
|
||||
protected __add(): void;
|
||||
/**
|
||||
* Removes the selected rows.
|
||||
*/
|
||||
protected __remove(): void;
|
||||
/**
|
||||
* Groups the selected rows if possible.
|
||||
*/
|
||||
protected __group(): void;
|
||||
/**
|
||||
* Ungroups the selected rows if possible.
|
||||
*/
|
||||
protected __ungroup(ungroupInfo: {
|
||||
parent: FilterPrompt.FilterNesting;
|
||||
toUngroup: FilterPrompt.FilterNesting;
|
||||
}, rows: FilterPrompt.SelectedRow[]): void;
|
||||
/**
|
||||
* Enables/disables remove, group and ungroup buttons according to currently selected rows.
|
||||
*/
|
||||
protected __processSelection(): void;
|
||||
/**
|
||||
* Resizes indentation header to match the table content.
|
||||
*/
|
||||
protected __resizeIndentationHeader(): void;
|
||||
/**
|
||||
* Generates a string consisting of the parentControlId, the name of the popup and a guid to be used as a control id.
|
||||
*/
|
||||
protected __newControlId(): string;
|
||||
/**
|
||||
* Clones a nesting object while leaving references to filters intact
|
||||
* @param nesting The object to clone
|
||||
*/
|
||||
protected __cloneNesting(nesting: FilterPrompt.FilterNesting): FilterPrompt.FilterNesting;
|
||||
/**
|
||||
* Parses a JsonSchema into an object detailing which paths are available with which comparators and values.
|
||||
* @param schema The JsonSchema to parse.
|
||||
*/
|
||||
protected __parseSchema(schema: TcHmi.JsonSchema | null): {
|
||||
schemaInfo: FilterPrompt.SchemaInfo;
|
||||
localizationInfo: FilterPrompt.PathInfo[];
|
||||
domainPaths: string[];
|
||||
};
|
||||
/**
|
||||
* Localizes enum labels and updates comboboxes using them.
|
||||
*/
|
||||
protected __localizeEnumLabels(): void;
|
||||
/**
|
||||
* Subscribes to ListDomains and updates the schemaInfo, if paths containing "domain" exist in the schemaInfo.
|
||||
*/
|
||||
protected __subscribeListDomains(): void;
|
||||
}
|
||||
export declare namespace FilterPrompt {
|
||||
interface SchemaInfo {
|
||||
availablePaths: Map<string, PathInfo>;
|
||||
freePath: PathInfo | null;
|
||||
availableLogic: string[];
|
||||
}
|
||||
interface PathInfo {
|
||||
comparators: string[];
|
||||
values: any[];
|
||||
labels: Map<string | number, string>;
|
||||
localizedLabels: Map<string | number, string>;
|
||||
allowFreeValue: boolean;
|
||||
valueIsDate: boolean;
|
||||
valueType: 'string' | 'number' | 'integer' | 'boolean' | 'any';
|
||||
nullable: boolean;
|
||||
isSuggestion: boolean;
|
||||
}
|
||||
interface RowData {
|
||||
row: HTMLTableRowElement;
|
||||
logicOperator?: TcHmi.LogicOperator;
|
||||
comparison: TcHmi.Comparison;
|
||||
parent: FilterNesting;
|
||||
selection: {
|
||||
control: TcHmiCheckbox;
|
||||
destroyer: TcHmi.DestroyFunction;
|
||||
};
|
||||
logic?: {
|
||||
control: TcHmiCombobox<TcHmi.LogicOperator['logic']>;
|
||||
destroyer: TcHmi.DestroyFunction;
|
||||
};
|
||||
path: {
|
||||
control: TcHmiCombobox | TcHmiTextbox | null;
|
||||
destroyer: TcHmi.DestroyFunction | null;
|
||||
};
|
||||
comparator: {
|
||||
cell: HTMLTableCellElement;
|
||||
control: TcHmiCombobox<string, TcHmiCombobox_ListItemGeneric<string>[]> | null;
|
||||
destroyer: TcHmi.DestroyFunction | null;
|
||||
};
|
||||
value: {
|
||||
cell: HTMLTableCellElement;
|
||||
control: TcHmiCombobox | TcHmiTextbox | TcHmiDateTimeInput | null;
|
||||
destroyer: TcHmi.DestroyFunction | null;
|
||||
};
|
||||
}
|
||||
interface SelectedRow {
|
||||
rowElement: HTMLTableRowElement;
|
||||
comparison: TcHmi.Comparison;
|
||||
parent: FilterNesting;
|
||||
}
|
||||
interface FilterNesting {
|
||||
filter: TcHmi.Filter;
|
||||
parent: FilterNesting | null;
|
||||
}
|
||||
interface GroupingLevel {
|
||||
opens: boolean;
|
||||
closes: boolean;
|
||||
}
|
||||
}
|
||||
import _FilterPrompt = FilterPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let FilterPrompt: typeof _FilterPrompt;
|
||||
type FilterPrompt = _FilterPrompt;
|
||||
namespace FilterPrompt {
|
||||
type SchemaInfo = _FilterPrompt.SchemaInfo;
|
||||
type PathInfo = _FilterPrompt.PathInfo;
|
||||
type RowData = _FilterPrompt.RowData;
|
||||
type SelectedRow = _FilterPrompt.SelectedRow;
|
||||
type FilterNesting = _FilterPrompt.FilterNesting;
|
||||
type GroupingLevel = _FilterPrompt.GroupingLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=FilterPrompt.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,33 @@
|
||||
import { ButtonsPrompt } from './ButtonsPrompt.js';
|
||||
export declare class HtmlAndButtonsPrompt<T> extends ButtonsPrompt<T> {
|
||||
protected __elementContentContent: HTMLElement | null;
|
||||
/**
|
||||
* Creates a new TextAndButtonsPrompt instance.
|
||||
* @param buttons A collection of attributes to generate buttons from and the value that should be used in the prompt answer for each button.
|
||||
* @param parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(buttons: TcHmi.Dictionary<{
|
||||
value: T;
|
||||
attributes: TcHmi.Dictionary<any>;
|
||||
}>, parentControl?: TcHmi.Controls.System.TcHmiControl | null);
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
* @param force If true, child controls will be removed from the parent control before destruction, to ensure destruction in case of keepAlive === true.
|
||||
*/
|
||||
destroy(force?: boolean): void;
|
||||
/**
|
||||
* Sets the content element.
|
||||
* @param element
|
||||
*/
|
||||
setContentElement(element: HTMLElement): void;
|
||||
}
|
||||
declare const _HtmlAndButtonsPrompt: typeof HtmlAndButtonsPrompt;
|
||||
type tHtmlAndButtonsPrompt<T> = HtmlAndButtonsPrompt<T>;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let HtmlAndButtonsPrompt: typeof _HtmlAndButtonsPrompt;
|
||||
type HtmlAndButtonsPrompt<T> = tHtmlAndButtonsPrompt<T>;
|
||||
}
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=HtmlAndButtonsPrompt.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ButtonsPrompt}from"./ButtonsPrompt.js";export class HtmlAndButtonsPrompt extends ButtonsPrompt{__elementContentContent;constructor(buttons,parentControl){super(buttons,parentControl),this.__elementContentContent=null}destroy(force=!1){super.destroy(force),this.__elementContentContent=null}setContentElement(element){this.__elementContentContent&&this.__elementContentContent.remove(),this.__elementContentContent=element,this.__elementContent.appendChild(this.__elementContentContent)}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.HtmlAndButtonsPrompt=HtmlAndButtonsPrompt;
|
||||
@@ -0,0 +1,89 @@
|
||||
import type { Control as TcHmiInput } from '../../TcHmiInput/TcHmiInput.esm.js';
|
||||
import { OkCancelPrompt } from './OkCancelPrompt.js';
|
||||
export declare class InputPrompt extends OkCancelPrompt<string> {
|
||||
protected __input: TcHmiInput;
|
||||
protected __forbiddenValues: Set<string>;
|
||||
protected __validationPatterns: {
|
||||
pattern: RegExp;
|
||||
expectedTestResult: boolean;
|
||||
}[];
|
||||
protected __elementLabel: HTMLElement;
|
||||
/**
|
||||
* Creates a new InputPrompt instance.
|
||||
* @param parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(parentControl?: TcHmi.Controls.System.TcHmiControl | null);
|
||||
/**
|
||||
* Handler for the onTextChanged event of the input.
|
||||
*/
|
||||
protected __onTextChanged(): void;
|
||||
/**
|
||||
* Handler for the keydown event of the popup element.
|
||||
*/
|
||||
protected __onKeydown(event: KeyboardEvent): void;
|
||||
/**
|
||||
* Checks if the text of the input is valid and sets the isEnabled state of the button and the invalid class of the input accordingly.
|
||||
*/
|
||||
protected __validate(): void;
|
||||
/**
|
||||
* Validates the given text.
|
||||
* @param text The text to validate.
|
||||
*/
|
||||
protected __isValid(text: string): boolean;
|
||||
/**
|
||||
* Performs the action for the OK button, i.e. calling prompt.answer().
|
||||
*/
|
||||
protected __ok(): void;
|
||||
/**
|
||||
* Shows the popup and waits for the user to answer the prompt. A Promise is returned that will be resolved with the value the user provides.
|
||||
* @param forbiddenValues Values that cannot be entered (i.e. because another item with this name already exists).
|
||||
* @param defaultValue The default to fill the input with.
|
||||
*/
|
||||
prompt(forbiddenValues?: Iterable<string> | null, defaultValue?: string): Promise<{
|
||||
isOk: true;
|
||||
value: string;
|
||||
} | {
|
||||
isOk: false;
|
||||
value?: void | undefined;
|
||||
}>;
|
||||
/**
|
||||
* Shows the popup and waits for the user to answer the prompt. A Promise is returned that will be resolved with the value the user provides.
|
||||
*/
|
||||
show(): void;
|
||||
setValidationPatterns(patterns: {
|
||||
pattern: RegExp;
|
||||
expectedTestResult: boolean;
|
||||
}[]): void;
|
||||
getValidationPatterns(): {
|
||||
pattern: RegExp;
|
||||
expectedTestResult: boolean;
|
||||
}[];
|
||||
/**
|
||||
* DEPRECATED
|
||||
* Please use setTexts
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
* @deprecated Please use setTexts
|
||||
*/
|
||||
setLocalizations(texts: Partial<InputPrompt.LocalizableTexts>): void;
|
||||
/**
|
||||
* Sets texts which can either be localizable or static.
|
||||
*/
|
||||
setTexts(texts: Partial<InputPrompt.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace InputPrompt {
|
||||
interface LocalizableTexts extends OkCancelPrompt.LocalizableTexts {
|
||||
labelText: TcHmi.Localizable;
|
||||
headerText: TcHmi.Localizable;
|
||||
}
|
||||
}
|
||||
import _InputPrompt = InputPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let InputPrompt: typeof _InputPrompt;
|
||||
type InputPrompt = _InputPrompt;
|
||||
namespace InputPrompt {
|
||||
type LocalizableTexts = _InputPrompt.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=InputPrompt.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,99 @@
|
||||
import { Popup } from './Popup.js';
|
||||
import type { Control as TcHmiButton } from '../../TcHmiButton/TcHmiButton.esm.js';
|
||||
export declare abstract class OkCancelPrompt<T, T2 = void> extends Popup<{
|
||||
isOk: true;
|
||||
value: T;
|
||||
} | {
|
||||
isOk: false;
|
||||
value?: T2;
|
||||
}> {
|
||||
protected __okButton: TcHmiButton;
|
||||
protected __cancelButton: TcHmiButton;
|
||||
protected __backgroundAction: Popup.BackgroundAction<OkCancelPrompt.AvailableActions>;
|
||||
protected __closeButton: Popup.CloseButton<OkCancelPrompt.AvailableActions>;
|
||||
/**
|
||||
* Creates a new OkCancelPrompt instance.
|
||||
* @param localizations A collection of localization symbol expressions to localize texts in the control.
|
||||
* @param parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(parentControl?: TcHmi.Controls.System.TcHmiControl | null);
|
||||
/**
|
||||
* Aborts a prompted popup and performs the given action to answer the prompt. If no action is specified, the promise is rejected.
|
||||
* @param action The action to perform to answer the prompt.
|
||||
*/
|
||||
abort(action?: Popup.PromptAction<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* Handler for the onPressed event of the OK button.
|
||||
*/
|
||||
protected __onOkPressed(): void;
|
||||
/**
|
||||
* Handler for the onPressed event of the cancel button.
|
||||
*/
|
||||
protected __onCancelPressed(): void;
|
||||
/**
|
||||
* Performs the action for the OK button, i.e. calling prompt.answer(). Must be implemented by inheriting class.
|
||||
* Please check validity in this method and don't rely on the OK buttons isEnabled state, as this method might be called on background click or other events too.
|
||||
*/
|
||||
protected abstract __ok(): void;
|
||||
/**
|
||||
* Performs the action for the Cancel button.
|
||||
*/
|
||||
protected __cancel(): void;
|
||||
/**
|
||||
* Sets what happens when the user clicks the background while the popup is showing, or when the prompt is
|
||||
* aborted via API call.
|
||||
* @param action The action to perform. If the popup should be closed, you can specify ok or cancel to perform
|
||||
* the associated action.
|
||||
*/
|
||||
setBackgroundAction(action: Popup.BackgroundAction<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* Performs the background action.
|
||||
*/
|
||||
protected __performBackgroundAction(): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param button Defines whether to show the button and if yes, what action should be taken to answer the prompt.
|
||||
*/
|
||||
setCloseButton(button: Popup.CloseButton<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param show Defines whether to show the button.
|
||||
*/
|
||||
setCloseButton(show: boolean): void;
|
||||
/**
|
||||
* Performs the given action.
|
||||
*/
|
||||
protected __performPromptAction(toPerform: Popup.PromptAction<OkCancelPrompt.AvailableActions>): void;
|
||||
/**
|
||||
* DEPRECATED
|
||||
* Please use setTexts
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
* @deprecated Please use setTexts
|
||||
*/
|
||||
setLocalizations(texts: Partial<OkCancelPrompt.LocalizableTexts>): void;
|
||||
/**
|
||||
* Sets texts which can either be localizable or static.
|
||||
*/
|
||||
setTexts(texts: Partial<OkCancelPrompt.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace OkCancelPrompt {
|
||||
interface LocalizableTexts {
|
||||
buttonTextOk: TcHmi.Localizable;
|
||||
buttonTooltipOk: TcHmi.Localizable;
|
||||
buttonTextCancel: TcHmi.Localizable;
|
||||
buttonTooltipCancel: TcHmi.Localizable;
|
||||
}
|
||||
type AvailableActions = 'ok' | 'cancel';
|
||||
}
|
||||
import _OkCancelPrompt = OkCancelPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let OkCancelPrompt: typeof _OkCancelPrompt;
|
||||
type OkCancelPrompt<T, T2 = void> = _OkCancelPrompt<T, T2>;
|
||||
namespace OkCancelPrompt {
|
||||
type LocalizableTexts = _OkCancelPrompt.LocalizableTexts;
|
||||
type AvailableActions = _OkCancelPrompt.AvailableActions;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=OkCancelPrompt.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,338 @@
|
||||
import { Callback, type TcHmiControl } from 'Beckhoff.TwinCAT.HMI.Framework/index.esm.js';
|
||||
export declare abstract class Popup<T> {
|
||||
#private;
|
||||
protected readonly __parentControl?: (TcHmi.Controls.System.TcHmiControl | null) | undefined;
|
||||
protected __name: string;
|
||||
protected __element: HTMLDivElement;
|
||||
protected __elementHeaderContainer: HTMLDivElement;
|
||||
protected __elementHeader: HTMLHeadingElement;
|
||||
protected __elementClose: HTMLAnchorElement;
|
||||
protected __elementContent: HTMLDivElement;
|
||||
protected __elementFooter: HTMLDivElement;
|
||||
/** Controls in this array will be destroyed automatically when the popup is destroyed */
|
||||
protected __childControls: TcHmi.Controls.System.TcHmiControl[];
|
||||
/** Destroyers in this array will be called automatically when the popup is destroyed */
|
||||
protected __destroyers: TcHmi.DestroyFunction[];
|
||||
protected __destroyOnHide: TcHmi.DestroyFunction[];
|
||||
protected __prompt: {
|
||||
answer: (value: T | PromiseLike<T>) => void;
|
||||
error: (reason?: Error) => void;
|
||||
} | null;
|
||||
protected __isShowing: boolean;
|
||||
protected __onShowManager: Callback.Collection<() => void>;
|
||||
onShow: Readonly<{
|
||||
add: (callback: () => void) => () => void;
|
||||
remove: (callback: () => void) => void;
|
||||
}>;
|
||||
protected __onHideManager: Callback.Collection<() => void>;
|
||||
onHide: Readonly<{
|
||||
add: (callback: () => void) => () => void;
|
||||
remove: (callback: () => void) => void;
|
||||
}>;
|
||||
protected __onBoundsChangeManager: Callback.Collection<(data: {
|
||||
bounds: TcHmi.UiProvider.PopupProvider.Bounds | null;
|
||||
}) => void>;
|
||||
onBoundsChange: Readonly<{
|
||||
add: (callback: (data: {
|
||||
bounds: TcHmi.UiProvider.PopupProvider.Bounds | null;
|
||||
}) => void) => () => void;
|
||||
remove: (callback: (data: {
|
||||
bounds: TcHmi.UiProvider.PopupProvider.Bounds | null;
|
||||
}) => void) => void;
|
||||
}>;
|
||||
protected __backgroundAction: Popup.BackgroundAction<string>;
|
||||
protected __closeButton: Popup.CloseButton<string>;
|
||||
protected __backgroundMode: Popup.BackgroundMode;
|
||||
protected __positioningMode: Popup.PositioningMode;
|
||||
protected __bounds: Popup.Bounds | null;
|
||||
protected __movable: boolean;
|
||||
protected __justAbove: TcHmi.TopMostLayer.IOptionsEx['justAbove'];
|
||||
protected readonly __className = "TcHmi_Controls_Helpers_Popup";
|
||||
protected __localizationSymbols: Map<string, {
|
||||
symbol: TcHmi.Symbol<string>;
|
||||
destroyWatch: TcHmi.DestroyFunction;
|
||||
}>;
|
||||
private static readonly __passiveEventOptions;
|
||||
protected __documentMouseMoveDestroyer: TcHmi.DestroyFunction | null;
|
||||
protected __documentMouseUpDestroyer: TcHmi.DestroyFunction | null;
|
||||
protected __documentTouchMoveDestroyer: TcHmi.DestroyFunction | null;
|
||||
protected __documentTouchEndDestroyer: TcHmi.DestroyFunction | null;
|
||||
protected __documentTouchCancelDestroyer: TcHmi.DestroyFunction | null;
|
||||
/** Prevents mouse event while touch interaction is in progress. */
|
||||
protected __touchLock: boolean;
|
||||
protected __touchLockTimeoutId: number;
|
||||
/** Store active touches by their IDs. */
|
||||
protected __activeTouches: Map<number, {
|
||||
useForDragging: false;
|
||||
} | {
|
||||
useForDragging: true;
|
||||
offsetLeft: number;
|
||||
offsetTop: number;
|
||||
}>;
|
||||
protected __movingInfo: {
|
||||
moving: boolean;
|
||||
/** Offset from the interaction coordinates to element left side */
|
||||
startLeftOffset: number;
|
||||
/** Offset from the interaction coordinates to element top side */
|
||||
startTopOffset: number;
|
||||
/** A popup should be movable partly outside the screen but 50px should be always visible. */
|
||||
minLeft: number;
|
||||
/** A popup should be movable partly outside the screen but not at the top. */
|
||||
minTop: number;
|
||||
/** A popup should be movable partly outside the screen but 50px should be always visible. */
|
||||
maxLeft: number;
|
||||
/** A popup should be movable partly outside the screen but 50px should be always visible. */
|
||||
maxTop: number;
|
||||
};
|
||||
protected __activePointerInteraction: boolean;
|
||||
protected __animationFrameId: number;
|
||||
protected __storage: TcHmi.LocalStorage<{
|
||||
bounds: Popup.Bounds;
|
||||
}, {
|
||||
bounds: Popup.Bounds | null;
|
||||
}> | undefined;
|
||||
protected __storageSettings: TcHmi.UiProvider.PopupProvider.StorageSettings | undefined;
|
||||
private __resizeObserver;
|
||||
/**
|
||||
* Creates a new Popup instance.
|
||||
* @param __parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(__parentControl?: (TcHmi.Controls.System.TcHmiControl | null) | undefined);
|
||||
/**
|
||||
* Keeps popup visible after when the window or the popup is resized. If the popup shrinks it could disappear
|
||||
* beyond the left edge of the window. If the window shrinks, the popup could disappear beyond the right or
|
||||
* bottom edge.
|
||||
*/
|
||||
private __handleResize;
|
||||
/**
|
||||
* Shows the popup.
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* Hides the popup.
|
||||
*/
|
||||
hide(): void;
|
||||
/**
|
||||
* Shows the popup and waits for the user to answer the prompt. A Promise is returned that will be resolved with the value the user provides.
|
||||
*/
|
||||
prompt(): Promise<T>;
|
||||
/**
|
||||
* Aborts a prompted popup and performs the given action to answer the prompt. If no action is specified, the promise is rejected.
|
||||
* @param action The action to perform to answer the prompt.
|
||||
*/
|
||||
abort(action?: Popup.PromptAction<string>): void;
|
||||
/**
|
||||
* Destroys the popup and all its controls.
|
||||
* @param force If true, child controls will be removed from the parent control before destruction, to ensure destruction in case of keepAlive === true.
|
||||
*/
|
||||
destroy(force?: boolean): void;
|
||||
/**
|
||||
* Gets a value indicating if the popup is currently shown to the user.
|
||||
*/
|
||||
isShowing(): boolean;
|
||||
/**
|
||||
* Gets a value indicating if the popup has a prompt that is still pending to be answered by the user.
|
||||
* If that is the case, calling prompt() againg will result in an error. If the popup is not currently
|
||||
* showing, you can call show() to display the popup again and wait for the user to answer the prompt.
|
||||
*/
|
||||
hasActivePrompt(): boolean;
|
||||
/**
|
||||
* Gets the root element of the popup.
|
||||
*/
|
||||
getElement(): HTMLDivElement;
|
||||
/**
|
||||
* Resets the size and position of the Popup and clears that data from localStorage.
|
||||
*/
|
||||
resetBounds(): void;
|
||||
/**
|
||||
* Sets what happens when the user clicks the background while the popup is showing, or when the prompt is
|
||||
* aborted via API call. Default is { close: true }.
|
||||
* @param action The action to perform. If the popup should be closed, further action can be specified.
|
||||
*/
|
||||
setBackgroundAction(action: Popup.BackgroundAction<string>): void;
|
||||
/**
|
||||
* Sets the background mode of the TopMostLayer used for displaying the popup.
|
||||
* @param mode
|
||||
*/
|
||||
setBackgroundMode(mode: Popup.BackgroundMode): void;
|
||||
/**
|
||||
* Sets the positioning mode of the popup in the TopMostLayer.
|
||||
* @param mode
|
||||
*/
|
||||
setPositioningMode(mode: Popup.PositioningMode): void;
|
||||
/**
|
||||
* Sets the bounds of the popup. Does only have any effect if PositioningMode.Floating is used.
|
||||
* @param bounds
|
||||
*/
|
||||
setBounds(bounds: Popup.Bounds | null): void;
|
||||
/**
|
||||
* Process the given Popup.Bounds.
|
||||
* @param bounds
|
||||
*/
|
||||
protected __processBounds(bounds: Popup.Bounds | null): void;
|
||||
/**
|
||||
* Sets the movable option.
|
||||
* Does only have an effect when setPositioningMode is also set:
|
||||
* `popup.setPositioningMode(TcHmi.UiProvider.PopupProvider.PositioningMode.Floating)`
|
||||
*/
|
||||
setMovable(movable: boolean): void;
|
||||
/**
|
||||
* Sets the local storage settings and initializes the storage.
|
||||
*/
|
||||
setStorageSettings(settings: TcHmi.UiProvider.PopupProvider.StorageSettings): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param button Defines whether to show the button and if yes, what action should be taken to answer the prompt
|
||||
*/
|
||||
setCloseButton(button: Popup.CloseButton<string>): void;
|
||||
/**
|
||||
* Sets if the close button should be used or not.
|
||||
* @param show Defines whether to show the button
|
||||
*/
|
||||
setCloseButton(show: boolean): void;
|
||||
/**
|
||||
* Gets the close button configuration.
|
||||
*/
|
||||
getCloseButton(): _Popup.CloseButton<string>;
|
||||
/**
|
||||
* Performs the close action. Must be implemented by inheriting classes.
|
||||
*/
|
||||
protected abstract __performPromptAction(toPerform: Popup.PromptAction<string>): void;
|
||||
/**
|
||||
* Display the popup just above the given reference element.
|
||||
* @param reference The popup will be as close as possible in the TopMostLayer stack to this element.
|
||||
* @param conflictResolution If there are multiple elements that want to be just above the reference, you can
|
||||
* specify in which direction conflicts should be resolved. Defaults to Up.
|
||||
*/
|
||||
setJustAbove(reference: Element, conflictResolution?: TcHmi.TopMostLayer.ConflictResolution): void;
|
||||
/**
|
||||
* Reset the justAbove handling.
|
||||
* @param reference Pass null to reset the justAbove handling.
|
||||
*/
|
||||
setJustAbove(reference: null): void;
|
||||
/**
|
||||
* Returns whether the popup is currently being interacted with by mouse, touch or keyboard.
|
||||
*/
|
||||
hasActiveUserInteraction(): boolean;
|
||||
/**
|
||||
* Handles the onPressed event of the close button.
|
||||
*/
|
||||
protected __onCloseClick(_event: MouseEvent): void;
|
||||
/**
|
||||
* Handles the popup mousedown event.
|
||||
*/
|
||||
protected __onPopupMouseDown(event: MouseEvent): void;
|
||||
/**
|
||||
* Handles the document mouseup event.
|
||||
*/
|
||||
protected __onDocumentMouseUp(_event: MouseEvent): void;
|
||||
/**
|
||||
* Handles the document mousemove event.
|
||||
*/
|
||||
protected __onDocumentMouseMove(event: MouseEvent): void;
|
||||
/**
|
||||
* Handles the popup touchstart event.
|
||||
*/
|
||||
protected __onPopupTouchStart(event: TouchEvent): void;
|
||||
/**
|
||||
* Handles the document touch end and cancel events.
|
||||
*/
|
||||
protected __onDocumentTouchEndOrCancel(event: TouchEvent): void;
|
||||
/**
|
||||
* Handles the document touchmove event.
|
||||
*/
|
||||
protected __onDocumentTouchMove(event: TouchEvent): void;
|
||||
/**
|
||||
* AnimationFrame handler for drawing
|
||||
*/
|
||||
protected __updatePosition(): void;
|
||||
/**
|
||||
* Write potentially localized texts to a DOM Elements textContent property.
|
||||
* @param name A name for the localized text.
|
||||
* @param text The text to apply.
|
||||
* @param element The element to apply the text to.
|
||||
*/
|
||||
protected __applyTextToElement(name: string, text: TcHmi.Localizable | null | undefined, element: Element): void;
|
||||
/**
|
||||
* Write potentially localized texts to a DOM Element using the given setter function.
|
||||
* @param name A name for the localized text.
|
||||
* @param text The text to apply.
|
||||
* @param setter The setter that writes the text to the DOM.
|
||||
*/
|
||||
protected __applyTextToElement(name: string, text: TcHmi.Localizable | null | undefined, setter: (text: string) => void): void;
|
||||
/**
|
||||
* Write potentially localized texts to a control property
|
||||
* @param name A name for the localized text.
|
||||
* @param text The text to apply.
|
||||
* @param control The control to write to.
|
||||
* @param property The property name to write to.
|
||||
*/
|
||||
protected __applyTextToControl(name: string, text: TcHmi.Localizable | null | undefined, control: TcHmiControl.Control, property: string): void;
|
||||
/**
|
||||
* Watch the given symbol and call the onChange callback every time it changes with the resolved and formatted symbol value.
|
||||
* @param name The name for this symbol. Must be unique across all inheritance layers and further calls for the same localization must use the same name.
|
||||
* @param localization The localization to watch.
|
||||
* @param onChange The callback that is called with the localized and formatted text as a parameter.
|
||||
*/
|
||||
protected __watchLocalization(name: string, localization: TcHmi.FormattedLocalizable, onChange: (localizedText: string) => void): void;
|
||||
/**
|
||||
* Destroys the localization watch with the given name, if it exists.
|
||||
* @param name The name that was used with __watchLoclalization to start watching the symbol.
|
||||
*/
|
||||
protected __unwatchLocalization(name: string): void;
|
||||
}
|
||||
export declare namespace Popup {
|
||||
enum PositioningMode {
|
||||
Centered = 1,
|
||||
Floating = 2
|
||||
}
|
||||
enum BackgroundMode {
|
||||
None = 1,
|
||||
Dimmed = 2
|
||||
}
|
||||
type BackgroundAction<A extends string> = {
|
||||
close: false;
|
||||
} | {
|
||||
close: true;
|
||||
action?: A;
|
||||
};
|
||||
type CloseButton<A extends string> = {
|
||||
show: false;
|
||||
} | {
|
||||
show: true;
|
||||
action?: A;
|
||||
};
|
||||
type PromptAction<A extends string> = {
|
||||
action?: A;
|
||||
};
|
||||
interface Bounds {
|
||||
width?: number | null;
|
||||
widthUnit?: 'px' | '%';
|
||||
height?: number | null;
|
||||
heightUnit?: 'px' | '%';
|
||||
left?: number | null;
|
||||
leftUnit?: 'px' | '%';
|
||||
top?: number | null;
|
||||
topUnit?: 'px' | '%';
|
||||
bottom?: number | null;
|
||||
bottomUnit?: 'px' | '%';
|
||||
right?: number | null;
|
||||
rightUnit?: 'px' | '%';
|
||||
}
|
||||
}
|
||||
import _Popup = Popup;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let Popup: typeof _Popup;
|
||||
type Popup<T> = _Popup<T>;
|
||||
namespace Popup {
|
||||
type PositioningMode = _Popup.PositioningMode;
|
||||
type BackgroundMode = _Popup.BackgroundMode;
|
||||
type BackgroundAction<A extends string> = _Popup.BackgroundAction<A>;
|
||||
type CloseButton<A extends string> = _Popup.CloseButton<A>;
|
||||
type PromptAction<A extends string> = _Popup.PromptAction<A>;
|
||||
type Bounds = _Popup.Bounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=Popup.d.ts.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,39 @@
|
||||
import { ButtonsPrompt } from './ButtonsPrompt.js';
|
||||
export declare class TextAndButtonsPrompt<T> extends ButtonsPrompt<T> {
|
||||
/**
|
||||
* Creates a new TextAndButtonsPrompt instance.
|
||||
* @param buttons A collection of attributes to generate buttons from and the value that should be used in the prompt answer for each button.
|
||||
* @param parentControl The control which owns the popup.
|
||||
*/
|
||||
constructor(buttons: TcHmi.Dictionary<{
|
||||
value: T;
|
||||
attributes: TcHmi.Dictionary<any>;
|
||||
}>, parentControl?: TcHmi.Controls.System.TcHmiControl | null);
|
||||
/**
|
||||
* DEPRECATED
|
||||
* Please use setTexts
|
||||
* @param texts A collection of localization symbol expressions.
|
||||
* @deprecated Please use setTexts
|
||||
*/
|
||||
setLocalizations(texts: Partial<TextAndButtonsPrompt.LocalizableTexts>): void;
|
||||
/**
|
||||
* Sets texts which can either be localizable or static.
|
||||
*/
|
||||
setTexts(texts: Partial<TextAndButtonsPrompt.LocalizableTexts>): void;
|
||||
}
|
||||
export declare namespace TextAndButtonsPrompt {
|
||||
interface LocalizableTexts extends ButtonsPrompt.LocalizableTexts {
|
||||
contentText: TcHmi.Localizable;
|
||||
}
|
||||
}
|
||||
import _TextAndButtonsPrompt = TextAndButtonsPrompt;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TextAndButtonsPrompt: typeof _TextAndButtonsPrompt;
|
||||
type TextAndButtonsPrompt<T> = _TextAndButtonsPrompt<T>;
|
||||
namespace TextAndButtonsPrompt {
|
||||
type LocalizableTexts = _TextAndButtonsPrompt.LocalizableTexts;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=TextAndButtonsPrompt.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
import{ButtonsPrompt}from"./ButtonsPrompt.js";export class TextAndButtonsPrompt extends ButtonsPrompt{constructor(buttons,parentControl){super(buttons,parentControl)}setLocalizations(texts){this.setTexts(texts)}setTexts(texts){super.setTexts(texts),this.__applyTextToElement("contentText",texts.contentText,this.__elementContent)}}TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.TextAndButtonsPrompt=TextAndButtonsPrompt;
|
||||
@@ -0,0 +1,32 @@
|
||||
export declare class TcHmiSevenSegmentElement extends HTMLElement {
|
||||
/** The displayed value */
|
||||
protected __value: TcHmiSevenSegmentElement.Value | null | undefined;
|
||||
/** The svg of a single seven segment element. Each segment can be targeted via CSS */
|
||||
private __sevenSegmentSvg;
|
||||
/** The svg for a decimal point */
|
||||
private __decimalPointSvg;
|
||||
private __resizeObserver;
|
||||
constructor();
|
||||
/** Called when the element is conneted to the DOM */
|
||||
connectedCallback(): void;
|
||||
/** Called when the element is removed fromt the DOM */
|
||||
disconnectedCallback(): void;
|
||||
setValue(newValue: TcHmiSevenSegmentElement.Value | null): void;
|
||||
protected __processValue(): void;
|
||||
protected __updateDimensions(): void;
|
||||
protected __updateSVG(): void;
|
||||
}
|
||||
export declare namespace TcHmiSevenSegmentElement {
|
||||
type Value = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | '-' | '.';
|
||||
}
|
||||
import _TcHmiSevenSegmentElement = TcHmiSevenSegmentElement;
|
||||
declare global {
|
||||
namespace TcHmi.Controls.Helpers {
|
||||
let TcHmiSevenSegmentElement: typeof _TcHmiSevenSegmentElement;
|
||||
type TcHmiSevenSegmentElement = _TcHmiSevenSegmentElement;
|
||||
namespace TcHmiSevenSegmentElement {
|
||||
type Value = _TcHmiSevenSegmentElement.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=TcHmiSevenSegmentElement.d.ts.map
|
||||
@@ -0,0 +1 @@
|
||||
export class TcHmiSevenSegmentElement extends HTMLElement{__value;__sevenSegmentSvg='<svg\n viewBox="0 0 57.25 110.5"\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg"\n >\n <g transform="translate(-18,-129.75)">\n <polygon\n class="top"\n points="58.9375,145.0625 34.3125,145.0625 24.328125,135.07812 27.65625,131.75 65.59375,131.75 68.921875,135.07812 "\n />\n <polygon\n class="top-left"\n points="20,177.34375 20,139.40625 23.328125,136.07812 33.3125,146.0625 33.3125,177.34375 26.65625,184 "\n />\n <polygon\n class="top-right"\n points="73.25,177.34375 73.25,139.40625 69.921875,136.07812 59.9375,146.0625 59.9375,177.34375 66.59375,184 "\n />\n <polygon\n class="middle"\n points="58.9375,191.65625 34.3125,191.65625 27.65625,185 34.3125,178.34375 58.9375,178.34375 65.59375,185 "\n />\n <polygon\n class="bottom-left"\n points="20,230.59375 20,192.65625 26.65625,186 33.3125,192.65625 33.3125,223.9375 23.328125,233.92188 "\n />\n <polygon\n class="bottom-right"\n points="59.9375,223.9375 59.9375,192.65625 66.59375,186 73.25,192.65625 73.25,230.59375 69.921875,233.92188 "\n />\n <polygon\n class="bottom"\n points="65.59375,238.25 27.65625,238.25 24.328125,234.92188 34.3125,224.9375 58.9375,224.9375 68.921875,234.92188 "\n />\n </g>\n </svg>';__decimalPointSvg='<svg\n viewBox="0 0 19 110.5"\n version="1.1"\n xmlns="http://www.w3.org/2000/svg"\n xmlns:svg="http://www.w3.org/2000/svg"\n >\n <g transform="matrix(0.5,0,0,0.5,-3,-36.500002)">\n <path\n class="decimal-point"\n width="30"\n height="30"\n x="240.22185"\n y="250.32465"\n transform="translate(-230.22185,9.675354)"\n d="m 255.22185,250.32465 a 15,15 45 0 1 15,15 15,15 135 0 1 -15,15 15,15 45 0 1 -15,-15 15,15 135 0 1 15,-15 z"\n />\n </g>\n </svg>';__resizeObserver;constructor(){super(),this.__resizeObserver=new ResizeObserver(()=>{this.isConnected&&this.__updateDimensions()})}connectedCallback(){this.__processValue(),this.__updateSVG(),this.__updateDimensions(),this.__resizeObserver.observe(this)}disconnectedCallback(){this.__resizeObserver.disconnect()}setValue(newValue){this.__value=newValue,this.__processValue(),this.__updateDimensions()}__processValue(){const oldValue=this.getAttribute("value");oldValue===this.__value?.toString()||"."!==oldValue&&"."!==this.__value||this.__updateSVG(),this.setAttribute("value",void 0!==this.__value&&null!==this.__value?this.__value.toString():"")}__updateDimensions(){if(!this.isConnected)return;const height=this.getBoundingClientRect().height;if("."===this.__value)this.style.width=height/5.81578+"px";else this.style.width=height/1.93+"px"}__updateSVG(){if("."===this.__value)this.innerHTML=this.__decimalPointSvg;else this.innerHTML=this.__sevenSegmentSvg}}customElements.define("tchmi-seven-segment",TcHmiSevenSegmentElement),TcHmi.Controls.Helpers??={},TcHmi.Controls.Helpers.TcHmiSevenSegmentElement=TcHmiSevenSegmentElement;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user