@adcops/autocore-react 3.0.5 → 3.0.6

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,13 @@
1
+ import React from 'react';
2
+ interface FitTextProps {
3
+ /** The children prop expects any valid React node. */
4
+ children: React.ReactNode;
5
+ }
6
+ /**
7
+ * FitText dynamically adjusts the font size of its children to fit the parent container.
8
+ *
9
+ * @param {FitTextProps} props The props for the FitText component.
10
+ * @returns A div element that resizes its child text to fit.
11
+ */
12
+ export declare const FitText: React.FC<FitTextProps>;
13
+ export default FitText;
@@ -0,0 +1 @@
1
+ import{jsx as _jsx}from"react/jsx-runtime";import useFitText from"use-fit-text";export const FitText=({children:t})=>{const{fontSize:e,ref:i}=useFitText();return _jsx("div",{ref:i,style:{width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},children:_jsx("p",{style:{fontSize:e},children:t})})};export default FitText;
@@ -0,0 +1,61 @@
1
+ import React, { Component } from 'react';
2
+ import type { NumerableFormatOptions } from '../core/NumerableTypes';
3
+ /**
4
+ * Properties of the ValueDisplay component.
5
+ */
6
+ interface ValueIndicatorProps {
7
+ /**
8
+ * Label for the indicator.
9
+ */
10
+ label?: React.ReactNode | undefined;
11
+ /**
12
+ * Value to be displayed
13
+ */
14
+ value?: string | number | null | undefined;
15
+ /**
16
+ * Tooltip to display on hover
17
+ */
18
+ tooltip?: string | undefined;
19
+ /**
20
+ * Format for `value`<br/>
21
+ * See [numerable formats](https://github.com/gastonmesseri/numerable#1234-formatting-numbers)
22
+ */
23
+ format?: string | null | undefined;
24
+ /**
25
+ * Format options for `value`<br/>
26
+ * See [numerable format options](https://github.com/gastonmesseri/numerable#format)
27
+ */
28
+ formatOptions?: NumerableFormatOptions;
29
+ /**
30
+ * Custom class name to be attached
31
+ */
32
+ className?: string;
33
+ /**
34
+ * The topic to monitor to display. Optional.
35
+ */
36
+ topic?: string;
37
+ }
38
+ /**
39
+ * State of the ValueDisplay component.
40
+ */
41
+ interface ValueIndicatorState {
42
+ }
43
+ /**
44
+ * `ValueIndicator` wraps `ValueDisplay` in a frame and label, giving it a widget appearance.
45
+ * Care is taken to adapt to the selected theme of the application.
46
+ *
47
+ */
48
+ export declare class ValueIndicator extends Component<ValueIndicatorProps, ValueIndicatorState> {
49
+ /**
50
+ * The constructor initializes the component state and binds the initial value.
51
+ * @param {ValueIndicatorProps} props The properties passed to the component, including initial value and other display options.
52
+ */
53
+ constructor(props: ValueIndicatorProps);
54
+ /**
55
+ * Renders the component into the DOM.
56
+ * @returns A styled `div` element displaying the indicator.
57
+ */
58
+ render(): import("react/jsx-runtime").JSX.Element;
59
+ }
60
+ export default ValueIndicator;
61
+ export { NumerableFormatOptions };
@@ -0,0 +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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adcops/autocore-react",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "A React component library for industrial user interfaces.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp.. All Rights Reserved.
3
+ * Created Date: 2024-03-21 13:03:38
4
+ * -----
5
+ * Last Modified: 2024-03-21 13:36:25
6
+ * -----
7
+ *
8
+ */
9
+
10
+
11
+ import React from 'react';
12
+ import useFitText from 'use-fit-text';
13
+
14
+ interface FitTextProps {
15
+ /** The children prop expects any valid React node. */
16
+ children: React.ReactNode;
17
+ }
18
+
19
+ /**
20
+ * FitText dynamically adjusts the font size of its children to fit the parent container.
21
+ *
22
+ * @param {FitTextProps} props The props for the FitText component.
23
+ * @returns A div element that resizes its child text to fit.
24
+ */
25
+ export const FitText: React.FC<FitTextProps> = ({ children }) => {
26
+ const { fontSize, ref } = useFitText();
27
+
28
+ return (
29
+ <div ref={ref} style={{ width: '100%', height: '100%', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
30
+ <p style={{ fontSize }}>{children}</p>
31
+ </div>
32
+ );
33
+ };
34
+
35
+
36
+ export default FitText;
@@ -0,0 +1,152 @@
1
+ /*
2
+ * Copyright (C) 2024 Automated Design Corp. All Rights Reserved.
3
+ * Created Date: 2024-01-16 14:17:02
4
+ * -----
5
+ * Last Modified: 2024-03-21 15:24:54
6
+ * Modified By: ADC
7
+ * -----
8
+ *
9
+ */
10
+
11
+
12
+
13
+ import React, { Component } from 'react';
14
+
15
+ import { Tooltip } from "primereact/tooltip";
16
+
17
+ import { ValueDisplay } from './ValueDisplay';
18
+ import type { NumerableFormatOptions } from '../core/NumerableTypes';
19
+
20
+
21
+
22
+
23
+ /**
24
+ * Properties of the ValueDisplay component.
25
+ */
26
+ interface ValueIndicatorProps {
27
+
28
+ /**
29
+ * Label for the indicator.
30
+ */
31
+ label?: React.ReactNode | undefined;
32
+
33
+ /**
34
+ * Value to be displayed
35
+ */
36
+ value?: string | number | null | undefined;
37
+
38
+
39
+ /**
40
+ * Tooltip to display on hover
41
+ */
42
+ tooltip?: string | undefined;
43
+
44
+ /**
45
+ * Format for `value`<br/>
46
+ * See [numerable formats](https://github.com/gastonmesseri/numerable#1234-formatting-numbers)
47
+ */
48
+ format?: string | null | undefined;
49
+
50
+ /**
51
+ * Format options for `value`<br/>
52
+ * See [numerable format options](https://github.com/gastonmesseri/numerable#format)
53
+ */
54
+ formatOptions?: NumerableFormatOptions;
55
+
56
+ /**
57
+ * Custom class name to be attached
58
+ */
59
+ className?: string;
60
+
61
+ /**
62
+ * The topic to monitor to display. Optional.
63
+ */
64
+ topic?: string;
65
+ }
66
+
67
+ /**
68
+ * State of the ValueDisplay component.
69
+ */
70
+ interface ValueIndicatorState {
71
+ }
72
+
73
+
74
+
75
+ /**
76
+ * `ValueIndicator` wraps `ValueDisplay` in a frame and label, giving it a widget appearance.
77
+ * Care is taken to adapt to the selected theme of the application.
78
+ *
79
+ */
80
+ export class ValueIndicator extends Component<ValueIndicatorProps, ValueIndicatorState> {
81
+
82
+
83
+ /**
84
+ * The constructor initializes the component state and binds the initial value.
85
+ * @param {ValueIndicatorProps} props The properties passed to the component, including initial value and other display options.
86
+ */
87
+ constructor(props: ValueIndicatorProps) {
88
+ super(props);
89
+ this.state = {
90
+ };
91
+ }
92
+
93
+ /**
94
+ * Renders the component into the DOM.
95
+ * @returns A styled `div` element displaying the indicator.
96
+ */
97
+ render() {
98
+
99
+
100
+ 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
+ </>
147
+ );
148
+ }
149
+ }
150
+
151
+ export default ValueIndicator;
152
+ export { NumerableFormatOptions };