@adcops/autocore-react 3.0.3 → 3.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adcops/autocore-react",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "A React component library for industrial user interfaces.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -11,7 +11,7 @@
11
11
  "generate-docs": "typedoc",
12
12
  "build": "npm run clean && tsc && node ./tools/copy-distribution-files.cjs && npm run minify",
13
13
  "prestart": "tsc",
14
- "publish-package": "npm run build && npm version patch && npm run generate-docs && npm publish",
14
+ "publish-package": "npm run build && npm version patch && npm publish",
15
15
  "release:patch": "npm version patch && npm publish",
16
16
  "release:minor": "npm version minor && npm publish",
17
17
  "release:major": "npm version major && npm publish",
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
3
  * Created Date: 2024-01-16 13:17:23
4
4
  * -----
5
- * Last Modified: 2024-03-19 21:20:59
5
+ * Last Modified: 2024-03-20 13:16:29
6
6
  * -----
7
7
  *
8
8
  */
@@ -122,15 +122,18 @@ interface JogPanelState {
122
122
 
123
123
 
124
124
  /**
125
- * Default X, Y, Z configuration.
125
+ * A default jog button configuration for linear 3D motion.
126
126
  */
127
- export const kDefaultButtonDefinitions : (JogPanelButtonDefinition | undefined)[][] = [
127
+ export const DefaultLinearJogButtons : (JogPanelButtonDefinition | undefined)[][] = [
128
128
  [{ icon: "pi pi-arrow-up-left", action: JogPanelAction.yPositive, alt: "Y Positive" }, { icon: "pi pi-arrow-up", action: JogPanelAction.zPositive, alt: "Z Positive" }, undefined],
129
129
  [{ icon: "pi pi-arrow-left", action: JogPanelAction.xNegative, alt: "X Negative" }, undefined, { icon: "pi pi-arrow-right", action: JogPanelAction.xPositive, alt: "X Positive" }],
130
130
  [undefined, { icon: "pi pi-arrow-down", action: JogPanelAction.zNegative, alt: "Z Negative" }, { icon: "pi pi-arrow-down-right", action: JogPanelAction.yNegative, alt: "Y Negative" }],
131
131
  ];
132
132
 
133
- export const kRotationButtonDefinitions : (JogPanelButtonDefinition | undefined)[][] = [
133
+ /**
134
+ * A default jog button configuration for rotational 3D motion.
135
+ */
136
+ export const DefaultRotationJogButtons : (JogPanelButtonDefinition | undefined)[][] = [
134
137
  [{ icon: "pi", action: JogPanelAction.bPositive, alt: "Rot B Positive" }, { icon: "pi", action: JogPanelAction.cPositive, alt: "Rot C Positive" }, undefined],
135
138
  [{ icon: "pi", action: JogPanelAction.aNegative, alt: "Rot A Negative" }, undefined, { icon: "pi", action: JogPanelAction.aPositive, alt: "Rot A Positive" }],
136
139
  [undefined, { icon: "pi", action: JogPanelAction.cNegative, alt: "Rot C Negative" }, { icon: "pi ", action: JogPanelAction.bNegative, alt: "Rot B Negative" }],
@@ -165,7 +168,7 @@ export class JogPanel extends React.Component<JogPanelProps, JogPanelState> {
165
168
  static defaultProps : JogPanelProps = {
166
169
  onClicked: undefined,
167
170
  onJogDistanceChanged: undefined,
168
- buttonDefinitions: kDefaultButtonDefinitions,
171
+ buttonDefinitions: DefaultLinearJogButtons,
169
172
  defaultJogDistance : JogDistanceAction.Short,
170
173
  defaultJogSpeed : JogSpeedAction.Medium,
171
174
  showDistanceControl : true,
@@ -0,0 +1,261 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2024-03-20 13:05:42
4
+ * -----
5
+ * Last Modified: 2024-03-20 16:22:06
6
+ * -----
7
+ *
8
+ */
9
+
10
+
11
+ import React from "react";
12
+
13
+ import { InputText } from 'primereact/inputtext';
14
+ import { Button } from "primereact/button";
15
+
16
+ import { EventEmitterContext } from "../core/EventEmitterContext.js";
17
+ import { KeyFilterType } from "primereact/keyfilter";
18
+
19
+ /**
20
+ * Properties of the Configuration View
21
+ */
22
+ interface ValueInputProps {
23
+
24
+ /**
25
+ * The label for the ValueInput field.
26
+ */
27
+ label : React.ReactNode | undefined;
28
+
29
+
30
+ /**
31
+ * The value for the field.
32
+ */
33
+ value : string | undefined;
34
+
35
+
36
+ /**
37
+ * Optional filter for key entry. Not a validator, but won't accept keystrokes outside the filter.
38
+ * @type {RegExp | "pint" | "int" | "pnum" | "money" | "num" | "hex" | "email" | "alpha" | "alphanum"}
39
+ */
40
+ keyFilter : KeyFilterType | undefined;
41
+
42
+
43
+ /**
44
+ * An optional prefix before the data entry field.
45
+ */
46
+ prefix : React.ReactNode | undefined;
47
+
48
+ /**
49
+ * An optional prefix before the data entry field.
50
+ */
51
+ suffix : React.ReactNode | undefined;
52
+
53
+ /**
54
+ * A small, advisory text below the field.
55
+ */
56
+ description : React.ReactNode | undefined;
57
+
58
+ /**
59
+ * If true, all functions of the field will be disabled.
60
+ */
61
+ disabled : boolean | undefined;
62
+
63
+ /** Topic on which the value will be dispatched through the user interfave on successful data entry. */
64
+ dispatchTopic : string | undefined;
65
+
66
+ /**
67
+ * Placeholder string to display if the value is empty.
68
+ */
69
+ placeholder : string | undefined;
70
+
71
+ /**
72
+ * The user has accepted a new value.
73
+ * @param newValue New value accepted by the user.
74
+ */
75
+ onValueChanged?(newValue: string) : void;
76
+ /** Regular expression used to validate the value before it is broadcast */
77
+ validator : RegExp;
78
+ }
79
+
80
+ /**
81
+ * State variables of the Configuration View
82
+ */
83
+ interface ValueInputState {
84
+
85
+ entryValue : string | undefined;
86
+ isValid : boolean;
87
+ editing : boolean;
88
+ }
89
+
90
+
91
+ /**
92
+ * A convenient field with all the usual features of inputing values.
93
+ * Wraps the common features of use of a InputText, p-inputgroup, some icon buttons,
94
+ * accepting and rejecting values and keyboard management.
95
+ */
96
+ export class ValueInput extends React.Component<ValueInputProps, ValueInputState> {
97
+
98
+ // Here's an example of using the Application-wide EventEmitter con
99
+ // Define the contextType for the class to access the context
100
+ static contextType = EventEmitterContext;
101
+ // After specifying contextType, you can declare the context's type for the TypeScript compiler.
102
+ // Basically, we're telling TypeScript the type of the context; this line doesn't
103
+ // actually do any linking linking to the EventEmitterContext.
104
+ declare context: React.ContextType<typeof EventEmitterContext>;
105
+
106
+
107
+
108
+
109
+ /**
110
+ * Default properties for the component.
111
+ */
112
+ static defaultProps = {
113
+ label : '',
114
+ value : undefined,
115
+ keyFilter : undefined,
116
+ writeTopic : undefined,
117
+ onValueChanged : undefined,
118
+ description: undefined,
119
+ prefix: undefined,
120
+ suffix : undefined,
121
+ disabled : false,
122
+ dispatchTopic : undefined,
123
+ placeholder : undefined,
124
+ validator : undefined
125
+ };
126
+
127
+ /**
128
+ *
129
+ * @param {FooterViewProps} props
130
+ */
131
+ constructor(props : ValueInputProps) {
132
+ super(props);
133
+ this.state = {
134
+ entryValue : props.value,
135
+ isValid : props.value !== undefined ? this.validateValue(props.value) : false,
136
+ editing : false
137
+ };
138
+ }
139
+
140
+ /**
141
+ * The component has been loaded into the DOM.
142
+ */
143
+ componentDidMount() {
144
+ }
145
+
146
+
147
+
148
+ /**
149
+ * Check the new value against the validator RegEx, if one was specified.
150
+ * @param val The new value.
151
+ * @returns True if no validator specified or the value is valid, false if not valid.
152
+ */
153
+ private validateValue = (val : string) => {
154
+
155
+ if (this.props.validator !== undefined && this.props.validator !== null) {
156
+ return this.props.validator.test(val);
157
+ }
158
+ else {
159
+ return true;
160
+ }
161
+
162
+ };
163
+
164
+
165
+ /**
166
+ * The user has elected to accept the input value. Validate and store, if valid.
167
+ */
168
+ private onAcceptValue() {
169
+ if (this.state.entryValue !== undefined ) {
170
+ if (this.validateValue(this.state.entryValue) ) {
171
+ this.setState({isValid : true, editing : false});
172
+
173
+ if (this.props.onValueChanged)
174
+ this.props.onValueChanged(this.state.entryValue);
175
+
176
+ if (this.props.dispatchTopic !== undefined) {
177
+ this.context.dispatch({topic: this.props.dispatchTopic, payload:this.state.entryValue});
178
+ }
179
+
180
+ }
181
+ else {
182
+ this.setState({isValid : false});
183
+ }
184
+ }
185
+ else {
186
+ this.setState({isValid: false});
187
+ }
188
+ }
189
+
190
+ /**
191
+ * The user wishes to reset/cancel the previous value.
192
+ */
193
+ private onResetValue() {
194
+ this.setState({
195
+ entryValue: this.props.value,
196
+ isValid: this.props.value !== undefined ? this.validateValue(this.props.value) : false,
197
+ editing : false
198
+ });
199
+ }
200
+
201
+
202
+ render() {
203
+
204
+ return(
205
+ <div>
206
+ <div className="p-inputgroup flex-1" >
207
+ <span className="p-inputgroup-addon">
208
+ {this.props.label}
209
+ </span>
210
+ { this.props.prefix !== undefined &&
211
+ <span className="p-inputgroup-addon">
212
+ {this.props.prefix}
213
+ </span>
214
+ }
215
+ <InputText
216
+ keyfilter={this.props.keyFilter}
217
+ placeholder={this.props.placeholder}
218
+ value={this.state.entryValue}
219
+ onChange={(e) => {this.setState({entryValue: e.target.value, editing : true})} }
220
+ className={this.state.isValid ? '' : 'p-invalid'}
221
+ onKeyDown={(e) => {
222
+ if (e.key === 'Enter') {
223
+ this.onAcceptValue();
224
+ }
225
+ else if (e.key === 'Escape') {
226
+ this.onResetValue();
227
+ }
228
+ }}
229
+ disabled={this.props.disabled}
230
+ />
231
+ { this.props.suffix !== undefined &&
232
+ <span className="p-inputgroup-addon">
233
+ {this.props.suffix}
234
+ </span>
235
+ }
236
+ <Button
237
+ icon="pi pi-check"
238
+ disabled={this.props.disabled || !this.state.editing}
239
+ className="p-button-success"
240
+ onClick={() => this.onAcceptValue()}
241
+ />
242
+
243
+ <Button
244
+ icon="pi pi-times"
245
+ disabled={this.props.disabled || !this.state.editing}
246
+ className="p-button-danger"
247
+ onClickCapture={()=>this.onResetValue()}
248
+ />
249
+ </div>
250
+
251
+ {this.props.description !== undefined &&
252
+ <small>{this.props.description}</small>
253
+ }
254
+
255
+
256
+ </div>
257
+
258
+ );
259
+ }
260
+
261
+ }
@@ -45,7 +45,13 @@ export const RegExMaskPatterns = {
45
45
  * This pattern matches any positive integer without a decimal point, excluding negative numbers.
46
46
  * Examples of valid inputs: "123"
47
47
  */
48
- IntegerPositive: /^\d+$/
48
+ IntegerPositive: /^\d+$/,
49
+
50
+
51
+ /**
52
+ * Regular expression for matching IPV4 address.
53
+ */
54
+ Ipv4: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,
49
55
  } as const;
50
56
 
51
57
 
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html class="default" lang="en"><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>kRotationButtonDefinitions | autocore-react - v3.0.3</title><meta name="description" content="Documentation for autocore-react"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search" data-base=".."><div class="field"><label for="tsd-search-field" class="tsd-widget tsd-toolbar-icon search no-caption"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-search"></use></svg></label><input type="text" id="tsd-search-field" aria-label="Search"/></div><div class="field"><div id="tsd-toolbar-links"></div></div><ul class="results"><li class="state loading">Preparing search index...</li><li class="state failure">The search index is not available</li></ul><a href="../index.html" class="title">autocore-react - v3.0.3</a></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"><li><a href="../index.html">autocore-react</a></li><li><a href="../modules/components_JogPanel.html">components/JogPanel</a></li><li><a href="components_JogPanel.kRotationButtonDefinitions.html">kRotationButtonDefinitions</a></li></ul><h1>Variable kRotationButtonDefinitions<code class="tsd-tag ts-flagConst">Const</code> </h1></div><div class="tsd-signature"><span class="tsd-kind-variable">k<wbr/>Rotation<wbr/>Button<wbr/>Definitions</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><a href="../interfaces/components_JogPanel.JogPanelButtonDefinition.html" class="tsd-signature-type tsd-kind-interface">JogPanelButtonDefinition</a><span class="tsd-signature-symbol"> | </span><span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> = ...</span></div><aside class="tsd-sources"><ul><li>Defined in src/components/JogPanel.tsx:133</li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-index-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><h4 class="uppercase">Member Visibility</h4><form><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-private" name="private"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Private</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></form></div><div class="tsd-theme-toggle"><h4 class="uppercase">Theme</h4><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../index.html"><svg class="tsd-kind-icon" viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-1"></use></svg><span>autocore-react - v3.0.3</span></a><ul class="tsd-small-nested-navigation" id="tsd-nav-container" data-base=".."><li>Loading...</li></ul></nav></div></div></div><div class="tsd-generator"><p>Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></div><div class="overlay"></div></body></html>