@adcops/autocore-react 3.0.6 → 3.0.8

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.
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2024-03-22 06:26:45
4
+ * -----
5
+ * Last Modified: 2024-03-22 07:07:50
6
+ * -----
7
+ *
8
+ */
9
+
10
+
11
+
12
+ .value-indicator-container {
13
+
14
+ display: flex;
15
+ flex-direction: column;
16
+ background-color: var(--surface-ground);
17
+ border-color: var(--surface-border);
18
+ border-radius: var(--border-radius);
19
+ border-width: 1px;
20
+ border-style: solid;
21
+ justify-content: center;
22
+ align-items: center;
23
+ padding: 2mm;
24
+ flex-grow: 1; /* Allow the item to grow to fill available space */
25
+ flex-shrink: 0; /* Allow the item to shrink if necessary */
26
+ flex-basis: 0; /* Start with 0 width and then grow as needed, equal distribution */
27
+ min-width: 0; /* Prevents flex items from overflowing their container */
28
+ }
29
+
30
+ .value-indicator-label {
31
+ padding-bottom: 1mm;
32
+ }
@@ -1,5 +1,6 @@
1
1
  import React, { Component } from 'react';
2
2
  import type { NumerableFormatOptions } from '../core/NumerableTypes';
3
+ import "./ValueIndicator.css";
3
4
  /**
4
5
  * Properties of the ValueDisplay component.
5
6
  */
@@ -34,6 +35,10 @@ interface ValueIndicatorProps {
34
35
  * The topic to monitor to display. Optional.
35
36
  */
36
37
  topic?: string;
38
+ /**
39
+ * Optional style properties.
40
+ */
41
+ style?: React.CSSProperties | undefined;
37
42
  }
38
43
  /**
39
44
  * State of the ValueDisplay component.
@@ -1 +1 @@
1
- import{jsxs as _jsxs,jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";import{Component}from"react";import{Tooltip}from"primereact/tooltip";import{ValueDisplay}from"./ValueDisplay";export class ValueIndicator extends Component{constructor(r){super(r),this.state={}}render(){return _jsxs(_Fragment,{children:[_jsxs("style",{children:["\n .value-indicator-container {\n\n background-color: var(--surface-ground);\n border-color: var(--surface-border);\n border-radius: var(--border-radius);\n border-width: 1px;\n border-style: solid;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n padding: 2mm;\n }\n\n .value-indicator-label {\n padding-bottom: 1mm;\n } \n ","'"]}),_jsx(Tooltip,{target:".value-indicator-tooltip"}),_jsx("span",{className:"value-indicator-tooltip",children:_jsxs("div",{className:"value-indicator-container",children:[void 0!==this.props.label&&_jsx("div",{className:"value-indicator-label",children:this.props.label}),_jsx(ValueDisplay,{className:this.props.className,value:this.props.value,format:this.props.format,formatOptions:this.props.formatOptions,topic:this.props.topic,"data-pr-tooltip":this.props.tooltip,"data-pr-position":"down","data-pr-mousetrack":!0,"data-pr-showDelay":2e3})]})})]})}}export default ValueIndicator;
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Component}from"react";import{Tooltip}from"primereact/tooltip";import{ValueDisplay}from"./ValueDisplay";import"./ValueIndicator.css";export class ValueIndicator extends Component{constructor(t){super(t),this.state={}}render(){return _jsxs("div",{className:"value-indicator-container",style:this.props.style,children:[_jsx(Tooltip,{target:".value-indicator-container"}),void 0!==this.props.label&&_jsx("div",{className:"value-indicator-label",children:this.props.label}),_jsx(ValueDisplay,{className:this.props.className,value:this.props.value,format:this.props.format,formatOptions:this.props.formatOptions,topic:this.props.topic,"data-pr-tooltip":this.props.tooltip,"data-pr-position":"down","data-pr-mousetrack":!0,"data-pr-showDelay":2e3})]})}}export default ValueIndicator;
@@ -1 +1 @@
1
- import{jsx as _jsx}from"react/jsx-runtime";import{createContext,useState,useMemo}from"react";import{createHub,Hub}from"../hub";export{Hub};export const EventEmitterContext=createContext({state:{subscriptions:{},nextSubscriptionId:1},dispatch:()=>{},subscribe:()=>0,invoke:async(t,s)=>Promise.resolve({}),unsubscribe:t=>{},hub:null,getSubscriptions:()=>[]});export const EventEmitterProvider=({children:t})=>{const[s,e]=useState({subscriptions:{},nextSubscriptionId:1}),i=useMemo((()=>createHub()),[]),r=t=>{const{topic:s,payload:i}=t;e((t=>(t.subscriptions[s]?.forEach((t=>t.callback(i))),{...t,eventData:i})))},n=(t,i)=>{const r=s.nextSubscriptionId;return e((s=>({...s,subscriptions:{...s.subscriptions,[t]:[...s.subscriptions[t]||[],{id:r,callback:i}]},nextSubscriptionId:s.nextSubscriptionId+1}))),r},o=t=>{e((s=>{const e={...s.subscriptions};for(const s in e)e.hasOwnProperty(s)&&(e[s]=e[s].filter((s=>s.id!==t)),0===e[s].length&&delete e[s]);return{...s,subscriptions:e}}))},c=t=>t?s.subscriptions[t]||[]:s.subscriptions,u=useMemo((()=>({state:s,dispatch:r,subscribe:n,unsubscribe:o,invoke:i.invoke,hub:i,getSubscriptions:c})),[s,i]);return i.setContext(u),_jsx(EventEmitterContext.Provider,{value:u,children:t})};
1
+ import{jsx as _jsx}from"react/jsx-runtime";import{createContext,useState,useMemo}from"react";import{createHub,Hub}from"../hub";export{Hub};let globalSubscriptionId=1;export const EventEmitterContext=createContext({state:{subscriptions:{},nextSubscriptionId:1},dispatch:()=>{},subscribe:()=>0,invoke:async(t,s)=>Promise.resolve({}),unsubscribe:t=>{},hub:null,getSubscriptions:()=>[]});export const EventEmitterProvider=({children:t})=>{const[s,e]=useState({subscriptions:{},nextSubscriptionId:1}),i=useMemo((()=>createHub()),[]),r=t=>{const{topic:s,payload:i}=t;e((t=>(t.subscriptions[s]?.forEach((t=>t.callback(i))),{...t,eventData:i})))},o=(t,s)=>{globalSubscriptionId+=1;const i=globalSubscriptionId;return e((e=>({...e,subscriptions:{...e.subscriptions,[t]:[...e.subscriptions[t]||[],{id:i,callback:s}]},nextSubscriptionId:globalSubscriptionId+1}))),i},n=t=>{e((s=>{const e={...s.subscriptions};for(const s in e)e.hasOwnProperty(s)&&(e[s]=e[s].filter((s=>s.id!==t)),0===e[s].length&&delete e[s]);return{...s,subscriptions:e}}))},c=t=>t?s.subscriptions[t]||[]:s.subscriptions,u=useMemo((()=>({state:s,dispatch:r,subscribe:o,unsubscribe:n,invoke:i.invoke,hub:i,getSubscriptions:c})),[s,i]);return i.setContext(u),_jsx(EventEmitterContext.Provider,{value:u,children:t})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adcops/autocore-react",
3
- "version": "3.0.6",
3
+ "version": "3.0.8",
4
4
  "description": "A React component library for industrial user interfaces.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2024-03-22 06:26:45
4
+ * -----
5
+ * Last Modified: 2024-03-22 07:07:50
6
+ * -----
7
+ *
8
+ */
9
+
10
+
11
+
12
+ .value-indicator-container {
13
+
14
+ display: flex;
15
+ flex-direction: column;
16
+ background-color: var(--surface-ground);
17
+ border-color: var(--surface-border);
18
+ border-radius: var(--border-radius);
19
+ border-width: 1px;
20
+ border-style: solid;
21
+ justify-content: center;
22
+ align-items: center;
23
+ padding: 2mm;
24
+ flex-grow: 1; /* Allow the item to grow to fill available space */
25
+ flex-shrink: 0; /* Allow the item to shrink if necessary */
26
+ flex-basis: 0; /* Start with 0 width and then grow as needed, equal distribution */
27
+ min-width: 0; /* Prevents flex items from overflowing their container */
28
+ }
29
+
30
+ .value-indicator-label {
31
+ padding-bottom: 1mm;
32
+ }
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
3
  * Created Date: 2024-01-16 14:17:02
4
4
  * -----
5
- * Last Modified: 2024-03-21 15:24:54
5
+ * Last Modified: 2024-03-22 06:42:57
6
6
  * Modified By: ADC
7
7
  * -----
8
8
  *
@@ -17,7 +17,7 @@ import { Tooltip } from "primereact/tooltip";
17
17
  import { ValueDisplay } from './ValueDisplay';
18
18
  import type { NumerableFormatOptions } from '../core/NumerableTypes';
19
19
 
20
-
20
+ import "./ValueIndicator.css";
21
21
 
22
22
 
23
23
  /**
@@ -62,6 +62,12 @@ interface ValueIndicatorProps {
62
62
  * The topic to monitor to display. Optional.
63
63
  */
64
64
  topic?: string;
65
+
66
+
67
+ /**
68
+ * Optional style properties.
69
+ */
70
+ style?: React.CSSProperties | undefined;
65
71
  }
66
72
 
67
73
  /**
@@ -94,56 +100,34 @@ export class ValueIndicator extends Component<ValueIndicatorProps, ValueIndicato
94
100
  * Renders the component into the DOM.
95
101
  * @returns A styled `div` element displaying the indicator.
96
102
  */
97
- render() {
98
103
 
99
104
 
105
+
106
+ render() {
107
+
100
108
  return (
101
- <>
102
- <style>
103
- {`
104
- .value-indicator-container {
105
-
106
- background-color: var(--surface-ground);
107
- border-color: var(--surface-border);
108
- border-radius: var(--border-radius);
109
- border-width: 1px;
110
- border-style: solid;
111
- display: flex;
112
- flex-direction: column;
113
- justify-content: center;
114
- align-items: center;
115
- padding: 2mm;
116
- }
117
-
118
- .value-indicator-label {
119
- padding-bottom: 1mm;
120
- }
121
- `}'
122
- </style>
123
- <Tooltip target=".value-indicator-tooltip" />
124
- <span className="value-indicator-tooltip" >
125
- <div className='value-indicator-container'>
126
-
127
- {this.props.label !== undefined &&
128
- <div className="value-indicator-label">
129
- {this.props.label}
130
- </div>
131
- }
132
-
133
- <ValueDisplay
134
- className={this.props.className}
135
- value={this.props.value}
136
- format={this.props.format}
137
- formatOptions={this.props.formatOptions}
138
- topic={this.props.topic}
139
- data-pr-tooltip={this.props.tooltip}
140
- data-pr-position="down"
141
- data-pr-mousetrack={true}
142
- data-pr-showDelay={2000}
143
- />
144
- </div>
145
- </span>
146
- </>
109
+ <div className='value-indicator-container' style={this.props.style}>
110
+ <Tooltip target=".value-indicator-container" />
111
+
112
+ {this.props.label !== undefined &&
113
+ <div className="value-indicator-label">
114
+ {this.props.label}
115
+ </div>
116
+ }
117
+
118
+ <ValueDisplay
119
+ className={this.props.className}
120
+
121
+ value={this.props.value}
122
+ format={this.props.format}
123
+ formatOptions={this.props.formatOptions}
124
+ topic={this.props.topic}
125
+ data-pr-tooltip={this.props.tooltip}
126
+ data-pr-position="down"
127
+ data-pr-mousetrack={true}
128
+ data-pr-showDelay={2000}
129
+ />
130
+ </div>
147
131
  );
148
132
  }
149
133
  }
@@ -2,7 +2,7 @@
2
2
  * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
3
  * Created Date: 2024-01-17 11:45:10
4
4
  * -----
5
- * Last Modified: 2024-03-08 10:20:46
5
+ * Last Modified: 2024-03-22 14:25:08
6
6
  * Modified By: ADC
7
7
  * -----
8
8
  *
@@ -135,6 +135,9 @@ export interface EventEmitterContextType {
135
135
  getSubscriptions: (topic?: string) => Record<string, Subscription[]> | Subscription[];
136
136
  }
137
137
 
138
+
139
+ let globalSubscriptionId = 1;
140
+
138
141
  /**
139
142
  * A global context for managing event emission and subscription.
140
143
  *
@@ -324,7 +327,8 @@ export const EventEmitterProvider: React.FC<{ children: ReactNode }> = ({ childr
324
327
 
325
328
  const subscribe = (topic: string, callback: React.Dispatch<any>) : number => {
326
329
 
327
- const subscriptionId = state.nextSubscriptionId;
330
+ globalSubscriptionId += 1;
331
+ const subscriptionId = globalSubscriptionId; // state.nextSubscriptionId;
328
332
 
329
333
  setState(prevState => ({
330
334
  ...prevState,
@@ -332,7 +336,7 @@ export const EventEmitterProvider: React.FC<{ children: ReactNode }> = ({ childr
332
336
  ...prevState.subscriptions,
333
337
  [topic]: [...(prevState.subscriptions[topic] || []), { id: subscriptionId, callback }]
334
338
  },
335
- nextSubscriptionId: prevState.nextSubscriptionId + 1
339
+ nextSubscriptionId: globalSubscriptionId + 1 // prevState.nextSubscriptionId + 1
336
340
  }));
337
341
 
338
342
  return subscriptionId;
@@ -357,7 +361,7 @@ export const EventEmitterProvider: React.FC<{ children: ReactNode }> = ({ childr
357
361
  }
358
362
 
359
363
  return { ...prevState, subscriptions: newSubscriptions };
360
- });
364
+ });
361
365
  };
362
366
 
363
367