@adcops/autocore-react 3.3.29 → 3.3.30

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,29 @@
1
+ /*
2
+ * ValueInput sizing.
3
+ *
4
+ * Within a .p-inputgroup, PrimeReact gives .p-inputwrapper `flex: 1 1 auto`
5
+ * so the InputNumber stretches to fill all available space. Override that
6
+ * for our sized variants so only the input field is constrained — label,
7
+ * accept/cancel buttons keep their natural size.
8
+ */
9
+
10
+ .value-input-field.p-inputwrapper {
11
+ flex: 0 0 auto;
12
+ }
13
+
14
+ .value-input-field.p-inputwrapper .p-inputtext {
15
+ width: 100%;
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ .value-input-field.size-small.p-inputwrapper {
20
+ width: 30mm;
21
+ }
22
+
23
+ .value-input-field.size-normal.p-inputwrapper {
24
+ width: 55mm;
25
+ }
26
+
27
+ .value-input-field.size-large.p-inputwrapper {
28
+ width: 70mm;
29
+ }
@@ -48,10 +48,12 @@
48
48
  */
49
49
  import React from 'react';
50
50
  import { type InputNumberProps } from 'primereact/inputnumber';
51
+ import "./ValueInput.css";
52
+ export type ValueInputSize = 'small' | 'normal' | 'large';
51
53
  /**
52
54
  * Properties of the ValueInput component.
53
55
  */
54
- interface ValueInputProps extends Omit<InputNumberProps, 'value'> {
56
+ interface ValueInputProps extends Omit<InputNumberProps, 'value' | 'size'> {
55
57
  /**
56
58
  * The label for the ValueInput field.
57
59
  */
@@ -147,6 +149,13 @@ interface ValueInputProps extends Omit<InputNumberProps, 'value'> {
147
149
  * @param newValue New value accepted by the user.
148
150
  */
149
151
  onValueChanged?(newValue: number): void;
152
+ /**
153
+ * Width of the InputNumber field. The label addon and accept/cancel buttons
154
+ * keep their natural size; only the numeric input is constrained.
155
+ * Widths: small=30mm, normal=55mm, large=70mm.
156
+ * @default 'normal'
157
+ */
158
+ size?: ValueInputSize;
150
159
  }
151
160
  /**
152
161
  * A convenient field with all the usual features of input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AU,GAAG,SAAS,GAAG,SAAS,CAAC;IAG1C;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAG1B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;OAEG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;IAE1C;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAE/B,uGAAuG;IACvG,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEnC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC;;;OAGG;IACH,cAAc,CAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;CACzB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA6KhD,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1 +1 @@
1
- import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useState,useRef,useEffect,useContext}from"react";import{InputNumber}from"primereact/inputnumber";import{EventEmitterContext}from"../core/EventEmitterContext";import{Button}from"primereact/button";export const ValueInput=({label:e="",value:t=null,min:s,max:n,minPrecision:i=0,maxPrecision:o=3,mode:a="decimal",currency:u="USD",prefix:r,suffix:l,showButtons:c=!1,step:p=1,locale:m="en-US",description:d,disabled:x=!1,dispatchTopic:f,placeholder:v,onValueChanged:b,...h})=>{const[j,C]=useState(t),[E,_]=useState(t),[S,g]=useState(t),[y,N]=useState(!1),[k,B]=useState(!1),D=useRef(null),F=useContext(EventEmitterContext);useEffect(()=>{null!==S?(_(S),g(null),B(!1)):t!==E&&(_(t),C(t),N(!1),B(!1))},[t,E]);const I=()=>{var e;y&&null!==j&&(e=j,void 0!==n&&e>n||void 0!==s&&e<s?B(!0):(_(j),N(!1),b?.(j),B(!1),f&&F.dispatch({topic:f,payload:j})))},w=()=>{y&&(C(null),_(null),N(!1),B(!1))};return _jsxs("div",{children:[_jsxs("div",{className:"p-inputgroup",children:[_jsx("span",{className:"p-inputgroup-addon",children:e}),_jsx(InputNumber,{...h,ref:D,invalid:k,min:s,max:n,minFractionDigits:i,maxFractionDigits:o,mode:a,prefix:r,suffix:l,showButtons:c,step:p,placeholder:v,value:E,onChange:e=>{return t=e.value,y||(g(E),N(!0)),void C(t);var t},locale:m,currency:u,onKeyDown:e=>{"Enter"===e.key?I():"Escape"===e.key&&w()},disabled:x}),_jsx(Button,{icon:"pi pi-check",disabled:x||!y,className:"p-button-success",onClick:()=>I(),visible:y,autoFocus:!1}),_jsx(Button,{icon:"pi pi-times",disabled:x||!y,className:"p-button-danger",onClickCapture:()=>w(),visible:y,autoFocus:!1})]}),d&&_jsx("small",{children:d})]})};export default ValueInput;
1
+ import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import React,{useState,useRef,useEffect,useContext}from"react";import clsx from"clsx";import{InputNumber}from"primereact/inputnumber";import{EventEmitterContext}from"../core/EventEmitterContext";import{Button}from"primereact/button";import"./ValueInput.css";export const ValueInput=({label:e="",value:t=null,min:s,max:i,minPrecision:n=0,maxPrecision:a=3,mode:o="decimal",currency:u="USD",prefix:l,suffix:r,showButtons:c=!1,step:p=1,locale:m="en-US",description:d,disabled:x=!1,dispatchTopic:f,placeholder:v,onValueChanged:b,size:h="normal",...j})=>{const[C,E]=useState(t),[_,N]=useState(t),[S,g]=useState(t),[y,k]=useState(!1),[B,I]=useState(!1),D=useRef(null),F=useContext(EventEmitterContext);useEffect(()=>{null!==S?(N(S),g(null),I(!1)):t!==_&&(N(t),E(t),k(!1),I(!1))},[t,_]);const V=()=>{var e;y&&null!==C&&(e=C,void 0!==i&&e>i||void 0!==s&&e<s?I(!0):(N(C),k(!1),b?.(C),I(!1),f&&F.dispatch({topic:f,payload:C})))},w=()=>{y&&(E(null),N(null),k(!1),I(!1))};return _jsxs("div",{children:[_jsxs("div",{className:"p-inputgroup",children:[_jsx("span",{className:"p-inputgroup-addon",children:e}),_jsx(InputNumber,{...j,ref:D,className:clsx("value-input-field",`size-${h}`,j.className),invalid:B,min:s,max:i,minFractionDigits:n,maxFractionDigits:a,mode:o,prefix:l,suffix:r,showButtons:c,step:p,placeholder:v,value:_,onChange:e=>{return t=e.value,y||(g(_),k(!0)),void E(t);var t},locale:m,currency:u,onKeyDown:e=>{"Enter"===e.key?V():"Escape"===e.key&&w()},disabled:x}),_jsx(Button,{icon:"pi pi-check",disabled:x||!y,className:"p-button-success",onClick:()=>V(),visible:y,autoFocus:!1}),_jsx(Button,{icon:"pi pi-times",disabled:x||!y,className:"p-button-danger",onClickCapture:()=>w(),visible:y,autoFocus:!1})]}),d&&_jsx("small",{children:d})]})};export default ValueInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adcops/autocore-react",
3
- "version": "3.3.29",
3
+ "version": "3.3.30",
4
4
  "description": "A React component library for industrial user interfaces.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -0,0 +1,29 @@
1
+ /*
2
+ * ValueInput sizing.
3
+ *
4
+ * Within a .p-inputgroup, PrimeReact gives .p-inputwrapper `flex: 1 1 auto`
5
+ * so the InputNumber stretches to fill all available space. Override that
6
+ * for our sized variants so only the input field is constrained — label,
7
+ * accept/cancel buttons keep their natural size.
8
+ */
9
+
10
+ .value-input-field.p-inputwrapper {
11
+ flex: 0 0 auto;
12
+ }
13
+
14
+ .value-input-field.p-inputwrapper .p-inputtext {
15
+ width: 100%;
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ .value-input-field.size-small.p-inputwrapper {
20
+ width: 30mm;
21
+ }
22
+
23
+ .value-input-field.size-normal.p-inputwrapper {
24
+ width: 55mm;
25
+ }
26
+
27
+ .value-input-field.size-large.p-inputwrapper {
28
+ width: 70mm;
29
+ }
@@ -58,14 +58,19 @@
58
58
 
59
59
 
60
60
  import React, { useState, useRef, useEffect, useContext } from 'react';
61
+ import clsx from 'clsx';
61
62
  import { InputNumber, type InputNumberProps } from 'primereact/inputnumber';
62
63
  import { EventEmitterContext } from "../core/EventEmitterContext";
63
64
  import { Button } from 'primereact/button';
64
65
 
66
+ import "./ValueInput.css";
67
+
68
+ export type ValueInputSize = 'small' | 'normal' | 'large';
69
+
65
70
  /**
66
71
  * Properties of the ValueInput component.
67
72
  */
68
- interface ValueInputProps extends Omit<InputNumberProps, 'value'> {
73
+ interface ValueInputProps extends Omit<InputNumberProps, 'value' | 'size'> {
69
74
 
70
75
  /**
71
76
  * The label for the ValueInput field.
@@ -184,6 +189,14 @@ interface ValueInputProps extends Omit<InputNumberProps, 'value'> {
184
189
  * @param newValue New value accepted by the user.
185
190
  */
186
191
  onValueChanged?(newValue: number): void;
192
+
193
+ /**
194
+ * Width of the InputNumber field. The label addon and accept/cancel buttons
195
+ * keep their natural size; only the numeric input is constrained.
196
+ * Widths: small=30mm, normal=55mm, large=70mm.
197
+ * @default 'normal'
198
+ */
199
+ size?: ValueInputSize;
187
200
  }
188
201
 
189
202
  /**
@@ -210,6 +223,7 @@ export const ValueInput: React.FC<ValueInputProps> = ({
210
223
  dispatchTopic = undefined,
211
224
  placeholder = undefined,
212
225
  onValueChanged = undefined,
226
+ size = 'normal',
213
227
  ...restProps
214
228
  }) => {
215
229
  const [entryValue, setEntryValue] = useState<number | null>(value);
@@ -314,6 +328,7 @@ export const ValueInput: React.FC<ValueInputProps> = ({
314
328
  <InputNumber
315
329
  {...restProps}
316
330
  ref={inputRef}
331
+ className={clsx('value-input-field', `size-${size}`, restProps.className)}
317
332
  invalid={invalidValue}
318
333
  min={min}
319
334
  max={max}