@adcops/autocore-react 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +59 -0
- package/additional-docs/ButtonApiSpecs.md +48 -0
- package/additional-docs/GlobalEventEmitter.md +244 -0
- package/additional-docs/general_recommendations.md +22 -0
- package/dist/components/DPad.css +522 -0
- package/dist/components/DPad.d.ts +34 -0
- package/dist/components/DPad.js +1 -0
- package/dist/components/Indicator.d.ts +81 -0
- package/dist/components/Indicator.js +1 -0
- package/dist/components/IndicatorButton.d.ts +137 -0
- package/dist/components/IndicatorButton.js +1 -0
- package/dist/components/IndicatorColor.d.ts +26 -0
- package/dist/components/IndicatorColor.js +1 -0
- package/dist/components/Osk.d.ts +14 -0
- package/dist/components/Osk.js +1 -0
- package/dist/components/OskDialog.d.ts +33 -0
- package/dist/components/OskDialog.js +1 -0
- package/dist/components/ValueDisplay.d.ts +99 -0
- package/dist/components/ValueDisplay.js +1 -0
- package/dist/components/osk.css +123 -0
- package/dist/core/EventEmitterContext.d.ts +223 -0
- package/dist/core/EventEmitterContext.js +1 -0
- package/dist/core/MaskPatterns.d.ts +71 -0
- package/dist/core/MaskPatterns.js +1 -0
- package/dist/core/NumerableTypes.d.ts +58 -0
- package/dist/core/NumerableTypes.js +1 -0
- package/dist/core/PositionContext.d.ts +38 -0
- package/dist/core/PositionContext.js +1 -0
- package/dist/core/UniqueId.d.ts +16 -0
- package/dist/core/UniqueId.js +1 -0
- package/dist/core/ValueSimulator.d.ts +71 -0
- package/dist/core/ValueSimulator.js +1 -0
- package/dist/core/hoc.d.ts +31 -0
- package/dist/core/hoc.js +1 -0
- package/dist/hub/HubBase.d.ts +169 -0
- package/dist/hub/HubBase.js +1 -0
- package/dist/hub/HubSimulate.d.ts +20 -0
- package/dist/hub/HubSimulate.js +1 -0
- package/dist/hub/HubSocketIo.d.ts +101 -0
- package/dist/hub/HubSocketIo.js +1 -0
- package/dist/hub/HubTauri.d.ts +86 -0
- package/dist/hub/HubTauri.js +1 -0
- package/dist/hub/index.d.ts +13 -0
- package/dist/hub/index.js +1 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/highlight.css +106 -0
- package/docs/assets/icons.js +15 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +59 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1414 -0
- package/docs/classes/components_Indicator.Indicator.html +105 -0
- package/docs/classes/components_IndicatorButton.IndicatorButton.html +119 -0
- package/docs/classes/components_OskDialog.OskDialog.html +117 -0
- package/docs/classes/components_ValueDisplay.ValueDisplay.html +104 -0
- package/docs/classes/core_ValueSimulator.ValueSimulator.html +41 -0
- package/docs/classes/hub_HubBase.HubBase.html +67 -0
- package/docs/classes/hub_HubSimulate.HubSimulate.html +72 -0
- package/docs/classes/hub_HubSocketIo.HubSocketIo.html +80 -0
- package/docs/classes/hub_HubTauri.HubTauri.html +80 -0
- package/docs/enums/components_DPad.VcJoyPadAction.html +10 -0
- package/docs/enums/components_DPad.VcJoyPadButtonId.html +7 -0
- package/docs/enums/components_IndicatorButton.ActionMode.html +6 -0
- package/docs/enums/components_IndicatorColor.IndicatorColor.html +13 -0
- package/docs/functions/components_DPad.VcDPad.html +5 -0
- package/docs/functions/components_Osk.Osk.html +5 -0
- package/docs/functions/core_EventEmitterContext.EventEmitterProvider.html +8 -0
- package/docs/functions/core_UniqueId.UniqueId.html +4 -0
- package/docs/functions/core_hoc.hocAddSubscription.html +6 -0
- package/docs/functions/hub.createHub.html +3 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +69 -0
- package/docs/interfaces/components_IndicatorButton.IndicatorButtonProps.html +635 -0
- package/docs/interfaces/components_IndicatorButton.IndicatorButtonState.html +10 -0
- package/docs/interfaces/core_DimensionsContext.IDimensionsContext.html +4 -0
- package/docs/interfaces/core_EventEmitterContext.Action.html +5 -0
- package/docs/interfaces/core_EventEmitterContext.EventEmitterContextType.html +18 -0
- package/docs/interfaces/core_EventEmitterContext.State.html +8 -0
- package/docs/interfaces/core_EventEmitterContext.Subscription.html +6 -0
- package/docs/modules/components_DPad.html +5 -0
- package/docs/modules/components_Indicator.html +4 -0
- package/docs/modules/components_IndicatorButton.html +7 -0
- package/docs/modules/components_IndicatorColor.html +2 -0
- package/docs/modules/components_Osk.html +3 -0
- package/docs/modules/components_OskDialog.html +3 -0
- package/docs/modules/components_ValueDisplay.html +3 -0
- package/docs/modules/core_DimensionsContext.html +4 -0
- package/docs/modules/core_EventEmitterContext.html +11 -0
- package/docs/modules/core_InputPatterns.html +2 -0
- package/docs/modules/core_NumerableTypes.html +2 -0
- package/docs/modules/core_UniqueId.html +2 -0
- package/docs/modules/core_ValueSimulator.html +3 -0
- package/docs/modules/core_hoc.html +3 -0
- package/docs/modules/hub.html +6 -0
- package/docs/modules/hub_HubBase.html +3 -0
- package/docs/modules/hub_HubSimulate.html +3 -0
- package/docs/modules/hub_HubSocketIo.html +3 -0
- package/docs/modules/hub_HubTauri.html +2 -0
- package/docs/types/core_EventEmitterContext.EmitterDispatchFunction.html +1 -0
- package/docs/types/core_EventEmitterContext.EmitterSubscribeFunction.html +1 -0
- package/docs/types/core_EventEmitterContext.EmitterUnsubscribeFunction.html +1 -0
- package/docs/types/core_NumerableTypes.NumerableFormatOptions.html +1 -0
- package/docs/types/core_hoc.HocAddSubscriptionProps.html +4 -0
- package/docs/variables/core_DimensionsContext.DimensionsContext.html +1 -0
- package/docs/variables/core_EventEmitterContext.EventEmitterContext.html +5 -0
- package/docs/variables/core_InputPatterns.InputPatterns.html +2 -0
- package/package.json +79 -0
- package/readme.md +140 -0
- package/src/components/DPad.css +522 -0
- package/src/components/DPad.tsx +94 -0
- package/src/components/Indicator.tsx +243 -0
- package/src/components/IndicatorButton.tsx +306 -0
- package/src/components/IndicatorColor.ts +36 -0
- package/src/components/Osk.tsx +193 -0
- package/src/components/OskDialog.tsx +165 -0
- package/src/components/ValueDisplay.tsx +181 -0
- package/src/components/osk.css +123 -0
- package/src/core/EventEmitterContext.tsx +394 -0
- package/src/core/MaskPatterns.ts +82 -0
- package/src/core/NumerableTypes.ts +81 -0
- package/src/core/PositionContext.ts +60 -0
- package/src/core/UniqueId.ts +41 -0
- package/src/core/ValueSimulator.ts +167 -0
- package/src/core/hoc.tsx +65 -0
- package/src/hub/HubBase.ts +293 -0
- package/src/hub/HubSimulate.ts +47 -0
- package/src/hub/HubSocketIo.ts +166 -0
- package/src/hub/HubTauri.ts +145 -0
- package/src/hub/index.ts +41 -0
- package/terser.config.cjs +25 -0
- package/todo.md +18 -0
- package/tools/copy-distribution-files.cjs +73 -0
- package/tools/minify.cjs +56 -0
- package/tsconfig.json +34 -0
- package/typedoc.json +13 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { ButtonProps } from 'primereact/button';
|
|
3
|
+
import { EventEmitterContextType } from '../core/EventEmitterContext';
|
|
4
|
+
import { IndicatorColor } from "./IndicatorColor";
|
|
5
|
+
export { IndicatorColor };
|
|
6
|
+
/**
|
|
7
|
+
* Enum for different input modes of the IndicatorButton.
|
|
8
|
+
*/
|
|
9
|
+
export declare enum ActionMode {
|
|
10
|
+
Tap = "Tap",
|
|
11
|
+
Toggle = "Toggle",
|
|
12
|
+
Pressed = "Pressed",
|
|
13
|
+
Released = "Released"
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Properties for the IndicatorButton.
|
|
17
|
+
*
|
|
18
|
+
* For more information on the AutoCore Button API Specification, see
|
|
19
|
+
* [Additional Documentation](../additional-docs/ButtonApiSpecs.md).
|
|
20
|
+
*/
|
|
21
|
+
export interface IndicatorButtonProps extends ButtonProps {
|
|
22
|
+
/**
|
|
23
|
+
* Topic name to monitor for state indication.
|
|
24
|
+
*/
|
|
25
|
+
topic?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Color for the button when the state is TRUE.
|
|
28
|
+
*/
|
|
29
|
+
onColor?: IndicatorColor;
|
|
30
|
+
/**
|
|
31
|
+
* Color for the button when the state is FALSE.
|
|
32
|
+
*/
|
|
33
|
+
offColor?: IndicatorColor;
|
|
34
|
+
/**
|
|
35
|
+
* Text displayed when the state is TRUE. Falls back to `label` if undefined.
|
|
36
|
+
*/
|
|
37
|
+
onLabel?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Text displayed when the state is FALSE. Falls back to `label` if undefined.
|
|
40
|
+
*/
|
|
41
|
+
offLabel?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Name of the command to invoke on button events.
|
|
44
|
+
* If command is "*", then the commandTopic will be dispatched
|
|
45
|
+
* internally.
|
|
46
|
+
*/
|
|
47
|
+
command?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Optional topic parameter to send along with the command.
|
|
50
|
+
* If set, will automatically be included with commandArgs as
|
|
51
|
+
* the value of field 'topic.'
|
|
52
|
+
*/
|
|
53
|
+
commandTopic?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional arguments sent with the command.
|
|
56
|
+
*/
|
|
57
|
+
commandArgs?: any;
|
|
58
|
+
/**
|
|
59
|
+
* Topic to disable button interaction.
|
|
60
|
+
*/
|
|
61
|
+
disableTopic?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Topic to control the visibility of the button.
|
|
64
|
+
*/
|
|
65
|
+
invisibleTopic?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Mode of input for the button (e.g., TAP, TOGGLE).
|
|
68
|
+
*/
|
|
69
|
+
actionMode?: ActionMode;
|
|
70
|
+
/**
|
|
71
|
+
* Inverts the signal values for TAP, PRESSED, and RELEASED modes.
|
|
72
|
+
*/
|
|
73
|
+
invert?: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* State for the IndicatorButton.
|
|
77
|
+
*/
|
|
78
|
+
export interface IndicatorButtonState {
|
|
79
|
+
/**
|
|
80
|
+
* Current value/state of the button based on the subscribed topic.
|
|
81
|
+
*/
|
|
82
|
+
currentValue?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Indicates whether the button is disabled.
|
|
85
|
+
*/
|
|
86
|
+
isDisabled?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Indicates whether the button is invisible.
|
|
89
|
+
*/
|
|
90
|
+
isInvisible?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The button is in the "down" state.
|
|
93
|
+
*/
|
|
94
|
+
isPressed: boolean;
|
|
95
|
+
}
|
|
96
|
+
export declare class IndicatorButton extends Component<IndicatorButtonProps, IndicatorButtonState> {
|
|
97
|
+
static contextType: import("react").Context<EventEmitterContextType>;
|
|
98
|
+
static defaultProps: {
|
|
99
|
+
onColor: IndicatorColor;
|
|
100
|
+
offColor: string;
|
|
101
|
+
};
|
|
102
|
+
constructor(props: IndicatorButtonProps);
|
|
103
|
+
componentDidMount(): void;
|
|
104
|
+
componentDidUpdate(prevProps: IndicatorButtonProps): void;
|
|
105
|
+
componentWillUnmount(): void;
|
|
106
|
+
/**
|
|
107
|
+
* Sets up subscriptions based on provided topics.
|
|
108
|
+
*/
|
|
109
|
+
private setupSubscriptions;
|
|
110
|
+
/**
|
|
111
|
+
* Handles updates for the main topic.
|
|
112
|
+
*/
|
|
113
|
+
private handleTopicUpdate;
|
|
114
|
+
/**
|
|
115
|
+
* Handles updates for the disable topic.
|
|
116
|
+
*/
|
|
117
|
+
private handleDisableTopicUpdate;
|
|
118
|
+
/**
|
|
119
|
+
* Handles updates for the invisible topic.
|
|
120
|
+
*/
|
|
121
|
+
private handleInvisibleTopicUpdate;
|
|
122
|
+
/**
|
|
123
|
+
* Handle the button being pressed down. Used for TAP and PRESSED action modes.
|
|
124
|
+
*/
|
|
125
|
+
protected handleOnPressed(): void;
|
|
126
|
+
/**
|
|
127
|
+
* Handle the button being released. Used for TAP and RELEASED action modes.
|
|
128
|
+
*/
|
|
129
|
+
protected handleOnReleased(): void;
|
|
130
|
+
/**
|
|
131
|
+
* Dispatch a value to any listeners.
|
|
132
|
+
* @param value The value to dispatch as part of the payload.
|
|
133
|
+
*/
|
|
134
|
+
protected dispatchCommand(value: any): void;
|
|
135
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
136
|
+
}
|
|
137
|
+
export default IndicatorButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";import{Button}from"primereact/button";import{EventEmitterContext}from"../core/EventEmitterContext";import{IndicatorColor}from"./IndicatorColor";export{IndicatorColor};export var ActionMode;!function(e){e.Tap="Tap",e.Toggle="Toggle",e.Pressed="Pressed",e.Released="Released"}(ActionMode||(ActionMode={}));export class IndicatorButton extends Component{constructor(e){super(e),Object.defineProperty(this,"handleTopicUpdate",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({currentValue:e})}}),Object.defineProperty(this,"handleDisableTopicUpdate",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({isDisabled:e})}}),Object.defineProperty(this,"handleInvisibleTopicUpdate",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({isInvisible:e})}}),this.state={currentValue:void 0,isDisabled:!1,isInvisible:!1,isPressed:!1}}componentDidMount(){this.setupSubscriptions()}componentDidUpdate(e){}componentWillUnmount(){}setupSubscriptions(){const{topic:e,disableTopic:t,invisibleTopic:o}=this.props,{subscribe:i}=this.context;e&&i(e,this.handleTopicUpdate),t&&i(t,this.handleDisableTopicUpdate),o&&i(o,this.handleInvisibleTopicUpdate)}handleOnPressed(){const{isPressed:e}=this.state,{actionMode:t}=this.props;e||(this.setState({isPressed:!0}),t!==ActionMode.Tap&&t!==ActionMode.Pressed||this.dispatchCommand(!0))}handleOnReleased(){const{isPressed:e}=this.state,{actionMode:t}=this.props;e&&(this.setState({isPressed:!1}),t===ActionMode.Tap?this.dispatchCommand(!1):t===ActionMode.Released&&this.dispatchCommand(!0))}dispatchCommand(e){const{command:t,commandTopic:o,commandArgs:i}=this.props,{dispatch:s}=this.context;if(null!=t&&t.length>0){s({topic:t,payload:{topic:o,value:e,...i}})}}render(){const{currentValue:e,isDisabled:t,isInvisible:o}=this.state,{className:i,severity:s,label:n,raised:a,onColor:r,offColor:d,onLabel:l,offLabel:c,topic:p,command:h,commandArgs:u,disableTopic:b,invisibleTopic:m,inputMode:f,invert:v,...T}=this.props;let C=e?l:c;null!=C&&0!==C.length||(C=n);let I=e?r:d;return void 0===e&&(I=IndicatorColor.IndicatorInvalid),_jsx(Button,{...T,label:C,className:i,style:{color:"white",backgroundColor:I,display:o?"none":"block"},disabled:t,onMouseDown:()=>this.handleOnPressed(),onTouchStart:()=>this.handleOnPressed(),onMouseUp:()=>this.handleOnReleased(),onTouchEnd:()=>this.handleOnReleased(),raised:!0})}}Object.defineProperty(IndicatorButton,"contextType",{enumerable:!0,configurable:!0,writable:!0,value:EventEmitterContext}),Object.defineProperty(IndicatorButton,"defaultProps",{enumerable:!0,configurable:!0,writable:!0,value:{onColor:IndicatorColor.IndicatorGreen,offColor:"gray"}});export default IndicatorButton;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standardized indicator colors and their meanings. It's probably
|
|
3
|
+
* best to use their meaning and not the actual color name.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum IndicatorColor {
|
|
6
|
+
/** Green: On, Ok, Ready, Home, General Use */
|
|
7
|
+
IndicatorGreen = "green",
|
|
8
|
+
/** Alias for the ON condition to make meaning clear. Preferred for ON case. */
|
|
9
|
+
IndicatorOn = "green",
|
|
10
|
+
/** Off. ONLY USE THIS FOR OFF. */
|
|
11
|
+
IndicatorOff = "gray",
|
|
12
|
+
/** Red: Error, Fault, Stop, Stopped. Use sparingly. */
|
|
13
|
+
IndicatorRed = "red",
|
|
14
|
+
/** Orange: Warning, Out of position, moving, out of range. */
|
|
15
|
+
IndicatorOrange = "orange",
|
|
16
|
+
/** Alias for Red to make meaning clear. Preferred. */
|
|
17
|
+
IndicatorError = "red",
|
|
18
|
+
/** Alias for Orange to make meaning clear. Preferred. */
|
|
19
|
+
IndicatorWarning = "orange",
|
|
20
|
+
/** Invalid. If an indicator is black, the interface does not know the current value. */
|
|
21
|
+
IndicatorInvalid = "black",
|
|
22
|
+
/** Use for navigation buttons. No other meaning allowed. */
|
|
23
|
+
IndicatorNavigation = "cyan",
|
|
24
|
+
/** Use for informational buttons. No other meaning allowed. */
|
|
25
|
+
IndicatorInfo = "blue"
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export var IndicatorColor;!function(r){r.IndicatorGreen="green",r.IndicatorOn="green",r.IndicatorOff="gray",r.IndicatorRed="red",r.IndicatorOrange="orange",r.IndicatorError="red",r.IndicatorWarning="orange",r.IndicatorInvalid="black",r.IndicatorNavigation="cyan",r.IndicatorInfo="blue"}(IndicatorColor||(IndicatorColor={}));
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import "./osk.css";
|
|
3
|
+
interface OskProps {
|
|
4
|
+
onAccept?: () => void;
|
|
5
|
+
onChange?: (value: string) => void;
|
|
6
|
+
isNumPad?: boolean;
|
|
7
|
+
input?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
inputPattern?: RegExp;
|
|
10
|
+
checkValue?: (value: string) => string;
|
|
11
|
+
description?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const Osk: React.FC<OskProps>;
|
|
14
|
+
export default Osk;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState,useEffect,useRef}from"react";import{InputText}from"primereact/inputtext";import Keyboard from"react-simple-keyboard";import"./osk.css";import{RegExMaskPatterns}from"../core/MaskPatterns";const numpadLayout={numbers:["1 2 3","4 5 6","7 8 9","- 0 .","{symbols} {backspace}"],default:["! / #","$ % ^","& * (","= ) +","{numbers} {backspace}"]},englishLayout={default:["q w e r t y u i o p","a s d f g h j k l","{shift} z x c v b n m {backspace}","{numbers} {space} {ent}"],shift:["Q W E R T Y U I O P","A S D F G H J K L","{shift} Z X C V B N M {backspace}","{numbers} {space} {ent}"],numbers:["1 2 3","4 5 6","7 8 9","{abc} 0 {backspace}"]},keyboardDisplay={"{numbers}":"123","{ent}":"return","{escape}":"esc ⎋","{tab}":"tab ⇥","{backspace}":"⌫","{capslock}":"caps lock ⇪","{shift}":"⇧","{controlleft}":"ctrl ⌃","{controlright}":"ctrl ⌃","{altleft}":"alt ⌥","{altright}":"alt ⌥","{metaleft}":"cmd ⌘","{metaright}":"cmd ⌘","{abc}":"ABC","{space}":"space","{symbols}":"#+="};export const Osk=({onAccept:e,onChange:t,isNumPad:s=!1,input:a="",label:r="",inputPattern:n,checkValue:i,description:o})=>{const[u,c]=useState({isVisible:!1,layoutName:s?"numbers":"default",minWidth:500,maxWidth:800,input:a,label:r,isNumPad:s,inputPattern:n||RegExMaskPatterns.IntegerPositive,checkValue:i,description:o,firstKeyPressed:!1,onAccept:e||void 0,onChange:t||void 0}),l=useRef(null);useEffect((()=>()=>{l.current&&l.current.destroy()}),[]);const p=()=>{let e="default"===u.layoutName?"shift":"default";c((t=>({...t,layoutName:e})))},m=()=>{let e="numbers"!==u.layoutName?"numbers":"default";c((t=>({...t,layoutName:e})))};return _jsxs("div",{children:[_jsx(InputText,{value:u.input,readOnly:!0,tooltip:u.description}),_jsx("br",{}),_jsx(Keyboard,{keyboardRef:e=>l.current=e,name:"keyboard",layoutName:u.layoutName,layout:(()=>{if(u.isNumPad)return u.isNumPad?(void 0!==u.inputPattern&&null!==u.inputPattern||c((e=>({...e,inputPattern:RegExMaskPatterns.IntegerPositive}))),numpadLayout):englishLayout})(),display:keyboardDisplay,physicalKeyboardHighlight:!0,physicalKeyboardHighlightPress:!0,onChange:e=>(e=>{let t=e;u.firstKeyPressed||(t=u.input+e,l.current.setInput(t)),u.onChange&&u.onChange(t),c((e=>({...e,input:t,firstKeyPressed:!0})))})(e),onKeyPress:e=>(e=>{"{shift}"!==e&&"{lock}"!==e&&"{symbols}"!=e||p(),"{numbers}"!==e&&"{abc}"!==e||m(),"{backspace}"===e&&(u.firstKeyPressed||c((e=>({...e,input:"",firstKeyPressed:!0}))))})(e)})]})};export default Osk;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface OskDialogProps {
|
|
3
|
+
isVisible: boolean;
|
|
4
|
+
onAccept?: (value: string) => void;
|
|
5
|
+
onReject?: () => void;
|
|
6
|
+
onChange?: (value: string) => void;
|
|
7
|
+
isNumPad?: boolean;
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
input?: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
inputPattern?: RegExp;
|
|
13
|
+
textMode?: boolean;
|
|
14
|
+
minValue?: number;
|
|
15
|
+
maxValue?: number;
|
|
16
|
+
minLength?: number;
|
|
17
|
+
}
|
|
18
|
+
interface OskDialogState {
|
|
19
|
+
input: string;
|
|
20
|
+
errorMessage: string;
|
|
21
|
+
}
|
|
22
|
+
export declare class OskDialog extends React.Component<OskDialogProps, OskDialogState> {
|
|
23
|
+
private container;
|
|
24
|
+
constructor(props: OskDialogProps);
|
|
25
|
+
componentWillUnmount(): void;
|
|
26
|
+
checkValue: (value: string) => string;
|
|
27
|
+
onAccepted: () => void;
|
|
28
|
+
onChanged: (val: string) => void;
|
|
29
|
+
closeDialog: () => void;
|
|
30
|
+
show: () => void;
|
|
31
|
+
render(): null;
|
|
32
|
+
}
|
|
33
|
+
export default OskDialog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React from"react";import ReactDOM from"react-dom";import{Dialog}from"primereact/dialog";import{Button}from"primereact/button";import{Osk}from"./Osk";export class OskDialog extends React.Component{constructor(e){super(e),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"checkValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>{var t=!0;if(null!=e&&e.length>0)if(void 0!==this.props.inputPattern)t=this.props.inputPattern.test(e);else if(this.props.textMode)void 0!==this.props.minLength&&e.length<this.props.minLength&&(t=!1);else{e.length<0&&(t=!1),isNaN(parseFloat(e))&&(t=!1);var i=parseFloat(e);void 0!==this.props.minValue&&null!==this.props.minValue&&i<this.props.minValue&&(t=!1),void 0!==this.props.maxValue&&null!==this.props.maxValue&&i>this.props.maxValue&&(t=!1)}else t=!1;return t?"":"Invalid value."}}),Object.defineProperty(this,"onAccepted",{enumerable:!0,configurable:!0,writable:!0,value:()=>{const e=this.checkValue(this.state.input);e?this.setState({errorMessage:e}):(this.props.onAccept?.(this.state.input),this.closeDialog())}}),Object.defineProperty(this,"onChanged",{enumerable:!0,configurable:!0,writable:!0,value:e=>{this.setState({input:e,errorMessage:""}),this.props.onChange&&this.props.onChange(e)}}),Object.defineProperty(this,"closeDialog",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.container&&(ReactDOM.unmountComponentAtNode(this.container),this.container=null),this.props.onReject?.()}}),Object.defineProperty(this,"show",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.container||(this.container=document.createElement("div"),document.body.appendChild(this.container));const e=_jsxs("div",{children:[_jsx(Button,{label:"Cancel",icon:"pi pi-times",onClick:()=>this.closeDialog(),className:"p-button-text"}),_jsx(Button,{label:"Accept",icon:"pi pi-check",onClick:()=>this.onAccepted(),autoFocus:!0})]});ReactDOM.render(_jsxs(Dialog,{visible:this.props.isVisible,onHide:this.closeDialog,header:this.props.label,style:{width:this.props.maxWidth||"50vw"},footer:e,children:[_jsx(Osk,{onChange:this.onChanged,isNumPad:this.props.isNumPad,inputPattern:this.props.inputPattern,input:this.state.input}),this.state.errorMessage&&_jsx("div",{className:"error-message",children:this.state.errorMessage})]}),this.container)}}),this.state={input:e.input||"",errorMessage:""}}componentWillUnmount(){this.container&&document.body.removeChild(this.container)}render(){return null}}export default OskDialog;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { EventEmitterContextType } from '../core/EventEmitterContext';
|
|
3
|
+
import type { NumerableFormatOptions } from '../core/NumerableTypes';
|
|
4
|
+
/**
|
|
5
|
+
* Properties of the ValueDisplay component.
|
|
6
|
+
*/
|
|
7
|
+
interface Props {
|
|
8
|
+
/**
|
|
9
|
+
* Value to be displayed
|
|
10
|
+
*/
|
|
11
|
+
value?: string | number | null | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* X position (in pixels)
|
|
14
|
+
*/
|
|
15
|
+
x?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Y position (in pixels)
|
|
18
|
+
*/
|
|
19
|
+
y?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Width (in pixels)
|
|
22
|
+
*/
|
|
23
|
+
width?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Height (in pixels)<br/>
|
|
26
|
+
* @default width
|
|
27
|
+
*/
|
|
28
|
+
height?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Format for `value`<br/>
|
|
31
|
+
* See [numerable formats](https://github.com/gastonmesseri/numerable#1234-formatting-numbers)
|
|
32
|
+
*/
|
|
33
|
+
format?: string | null | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Format options for `value`<br/>
|
|
36
|
+
* See [numerable format options](https://github.com/gastonmesseri/numerable#format)
|
|
37
|
+
*/
|
|
38
|
+
formatOptions?: NumerableFormatOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Custom class name to be attached
|
|
41
|
+
*/
|
|
42
|
+
className?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Enable absolute positioning for the component, allowing it to be
|
|
45
|
+
* placed on a specific position of its parent. This is useful when
|
|
46
|
+
* laying components over an image or wireframe.
|
|
47
|
+
*/
|
|
48
|
+
useAbsolutePositioning?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The topic to monitor to display. Optional.
|
|
51
|
+
*/
|
|
52
|
+
topic?: string;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* State of the ValueDisplay component.
|
|
56
|
+
*/
|
|
57
|
+
interface State {
|
|
58
|
+
subscribedValue?: string | number | null;
|
|
59
|
+
fontSize?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* `ValueDisplay` is a React component that subscribes to a value from an `EventEmitterContext` and renders it.
|
|
63
|
+
* This component adjusts its display based on the provided properties, including positioning and styling adjustments
|
|
64
|
+
* based on its context. It is designed to work within a system that provides dynamic updates to values via an event emitter.
|
|
65
|
+
*/
|
|
66
|
+
declare class ValueDisplay extends Component<Props, State> {
|
|
67
|
+
/** Defines the context type to subscribe to changes using EventEmitter. */
|
|
68
|
+
static contextType: import("react").Context<EventEmitterContextType>;
|
|
69
|
+
/** ID for the subscription to the topic, used to unsubscribe on component unmount. */
|
|
70
|
+
protected unsubscribeTopicId: number | null;
|
|
71
|
+
/**
|
|
72
|
+
* The constructor initializes the component state and binds the initial value.
|
|
73
|
+
* @param props The properties passed to the component, including initial value and other display options.
|
|
74
|
+
*/
|
|
75
|
+
constructor(props: Props);
|
|
76
|
+
/**
|
|
77
|
+
* Upon mounting, the component subscribes to updates on the specified topic if it exists,
|
|
78
|
+
* updating its state with the new value when the topic publishes updates.
|
|
79
|
+
*/
|
|
80
|
+
componentDidMount(): void;
|
|
81
|
+
/**
|
|
82
|
+
* If the value prop changes, the component updates its state with the new value.
|
|
83
|
+
* This ensures that the component remains in sync with its props.
|
|
84
|
+
* @param prevProps The previous properties for comparison to detect changes.
|
|
85
|
+
*/
|
|
86
|
+
componentDidUpdate(prevProps: Props): void;
|
|
87
|
+
/**
|
|
88
|
+
* Before the component is unmounted, it unsubscribes from the topic to prevent memory leaks
|
|
89
|
+
* and unnecessary updates from occurring.
|
|
90
|
+
*/
|
|
91
|
+
componentWillUnmount(): void;
|
|
92
|
+
/**
|
|
93
|
+
* Renders the component with styling and formatting based on the provided properties and state.
|
|
94
|
+
* Supports absolute or relative positioning and scales the display based on the context's dimensions.
|
|
95
|
+
* @returns A styled `div` element displaying the formatted value.
|
|
96
|
+
*/
|
|
97
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
98
|
+
}
|
|
99
|
+
export { ValueDisplay, NumerableFormatOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{Component}from"react";import{format as numerableFormat}from"numerable";import clsx from"clsx";import{EventEmitterContext}from"../core/EventEmitterContext";class ValueDisplay extends Component{constructor(e){super(e),Object.defineProperty(this,"unsubscribeTopicId",{enumerable:!0,configurable:!0,writable:!0,value:null}),this.state={subscribedValue:e.value,fontSize:"100%"}}componentDidMount(){const{topic:e}=this.props;if(e){const{subscribe:t}=this.context;this.unsubscribeTopicId=t(e,(e=>{this.setState({subscribedValue:e})}))}}componentDidUpdate(e){this.props.value!==e.value&&this.setState({subscribedValue:this.props.value})}componentWillUnmount(){if(this.unsubscribeTopicId){const{unsubscribe:e}=this.context;e(this.unsubscribeTopicId)}}render(){const{x:e,y:t,width:i,height:s,format:o,formatOptions:r,className:n,useAbsolutePositioning:a}=this.props,{subscribedValue:l,fontSize:c}=this.state,{scale:u,xOffset:p,yOffset:b}=this.context,m={position:a?"absolute":"relative",display:a?"":"inline-block",verticalAlign:"middle",fontSize:c&&u>1?100*u+"%":c,top:a&&t?`${b+u*t}px`:void 0,left:a&&e?`${p+u*e}px`:void 0,width:i?i*u+"px":void 0,height:s?s*u+"px":void 0,lineHeight:s?s*u+"px":void 0,whiteSpace:"nowrap"};return _jsx("div",{className:clsx(n),style:m,children:numerableFormat(l,o,r)})}}Object.defineProperty(ValueDisplay,"contextType",{enumerable:!0,configurable:!0,writable:!0,value:EventEmitterContext});export{ValueDisplay};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Customized by Thomas C. Bitsky Jr. Automated Design Corporation.
|
|
3
|
+
*
|
|
4
|
+
* Original file:
|
|
5
|
+
*
|
|
6
|
+
* simple-keyboard v2.32.100
|
|
7
|
+
* https://github.com/hodgef/simple-keyboard
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) Francisco Hodge (https://github.com/hodgef)
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
.hg-theme-default {
|
|
13
|
+
width: 100%;
|
|
14
|
+
-webkit-user-select: none;
|
|
15
|
+
-moz-user-select: none;
|
|
16
|
+
-ms-user-select: none;
|
|
17
|
+
user-select: none;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
touch-action: manipulation
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.hg-theme-default .hg-button span {
|
|
24
|
+
pointer-events: none
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.hg-theme-default button.hg-button {
|
|
28
|
+
border-width: 0;
|
|
29
|
+
outline: 0;
|
|
30
|
+
font-size: inherit
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.hg-theme-default {
|
|
34
|
+
background-color: #ececec;
|
|
35
|
+
padding: 5px;
|
|
36
|
+
border-radius: 5px
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.hg-theme-default .hg-button {
|
|
40
|
+
display: inline-block;
|
|
41
|
+
flex-grow: 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.hg-theme-default .hg-row {
|
|
45
|
+
display: flex
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.hg-theme-default .hg-row:not(:last-child) {
|
|
49
|
+
margin-bottom: 5px
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.hg-theme-default .hg-row .hg-button-container,
|
|
53
|
+
.hg-theme-default .hg-row .hg-button:not(:last-child) {
|
|
54
|
+
margin-right: 5px
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.hg-theme-default .hg-row>div:last-child {
|
|
58
|
+
margin-right: 0
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.hg-theme-default .hg-row .hg-button-container {
|
|
62
|
+
display: flex
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.hg-theme-default .hg-button {
|
|
66
|
+
/* box-shadow: 0 0 3px -1px rgba(0, 0, 0, .3); */ /* use the shadow for an ios look */
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
font-size: large;
|
|
69
|
+
height: 40px;
|
|
70
|
+
border-radius: 3px; /* set to 5 for ios look, 3 for microsoft look */
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
padding: 5px;
|
|
73
|
+
color: white; /* color of the button text */
|
|
74
|
+
background: #444444; /* background of the button text */
|
|
75
|
+
border: 1px solid black;
|
|
76
|
+
cursor:pointer;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
-webkit-tap-highlight-color: rgba(0, 0, 0, 0)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.hg-theme-default .hg-button.hg-activeButton {
|
|
84
|
+
background: #efefef
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.hg-theme-default.hg-layout-numeric .hg-button {
|
|
88
|
+
width: 33.3%;
|
|
89
|
+
height: 60px;
|
|
90
|
+
align-items: center;
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: center
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.hg-theme-default .hg-button.hg-button-numpadadd,
|
|
96
|
+
.hg-theme-default .hg-button.hg-button-numpadenter {
|
|
97
|
+
height: 85px
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.hg-theme-default .hg-button.hg-button-numpad0 {
|
|
101
|
+
width: 105px
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.hg-theme-default .hg-button.hg-button-com {
|
|
105
|
+
max-width: 85px
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.hg-theme-default .hg-button.hg-standardBtn.hg-button-at {
|
|
109
|
+
max-width: 45px
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.hg-theme-default .hg-button.hg-selectedButton {
|
|
113
|
+
background: rgba(5, 25, 70, .53);
|
|
114
|
+
color: #fff
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.hg-theme-default .hg-button.hg-standardBtn[data-skbtn=".com"] {
|
|
118
|
+
max-width: 82px
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.hg-theme-default .hg-button.hg-standardBtn[data-skbtn="@"] {
|
|
122
|
+
max-width: 60px
|
|
123
|
+
}
|