@zydon/common 2.1.91 → 2.1.92

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,11 @@
1
+ import { f } from './chunk-ANAHA3L6.js';
2
+ import { a } from './chunk-PV522B4W.js';
3
+ import { a as a$1 } from './chunk-4Z2JJGWA.js';
4
+ import { forwardRef, useMemo, useCallback } from 'react';
5
+ import P from '@mui/material/IconButton';
6
+ import A from '@mui/material/InputAdornment';
7
+ import { jsx } from 'react/jsx-runtime';
8
+
9
+ var D=forwardRef(({name:k,increment:r=1,updadteForMultiple:b,allowNegative:f$1=!1,value:C=0,onChange:I,minValue:n,maxValue:o,decimalScale:p,disabled:c,tabIndex:M,...B},O)=>{let s=Number(C||0),R=useMemo(()=>{let e=s-r;return typeof n=="number"&&e<n?!0:f$1?c:!e},[c,s,r,n,f$1]),v=useMemo(()=>{let e=s+r;return typeof o=="number"&&e>o?!0:c},[c,s,r,o]),z=useCallback(()=>{if(!f$1&&s-r<0)return;let e=s-r,t=n!==void 0&&e<n?n:f(e,p);I(t);},[s,r,n,p,I,f$1]),E=useCallback(()=>{let e=s+r,t=o!==void 0&&e>o?o:f(e,p);I(t);},[s,r,o,p,I]),L=useCallback(e=>{let t=Number(e.target.value||0);(r!==1||b)&&(t=t+r/2,t-=t%r),!f$1&&t<0&&(t=0),typeof n=="number"&&t<n&&(t=n),typeof o=="number"&&t>o&&(t=o),I(f(t,p));},[r,n,o,p,I,b,f$1]);return jsx(a,{ref:O,name:k,value:s,minValue:n,maxValue:o,allowNegative:f$1,decimalScale:p,InputProps:{startAdornment:jsx(A,{position:"start",children:jsx(P,{size:"medium",disabled:R,onClick:z,children:jsx(a$1,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(A,{position:"end",children:jsx(P,{size:"medium",onClick:E,disabled:v,children:jsx(a$1,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:M},onChange:L,disabled:c,...B})});D.displayName="Incrementer";var W=D;
10
+
11
+ export { W as a };
@@ -4,6 +4,9 @@ import { TextFieldProps } from '@mui/material/TextField';
4
4
  type IncrementerProps = {
5
5
  name: string;
6
6
  increment?: number;
7
+ /**
8
+ * @deprecated Use increment with the multiple wanted
9
+ */
7
10
  updadteForMultiple?: boolean;
8
11
  allowNegative?: boolean;
9
12
  decimalScale?: number;
@@ -1,5 +1,4 @@
1
- export { a as default } from '../../chunk-WVDC62Z6.js';
2
- import '../../chunk-TLENQZN5.js';
1
+ export { a as default } from '../../chunk-YTC35FJH.js';
3
2
  import '../../chunk-ANAHA3L6.js';
4
3
  import '../../chunk-PV522B4W.js';
5
4
  import '../../chunk-4Z2JJGWA.js';
@@ -1,5 +1,4 @@
1
- import { a } from '../../../chunk-WVDC62Z6.js';
2
- import '../../../chunk-TLENQZN5.js';
1
+ import { a } from '../../../chunk-YTC35FJH.js';
3
2
  import '../../../chunk-ANAHA3L6.js';
4
3
  import '../../../chunk-PV522B4W.js';
5
4
  import '../../../chunk-4Z2JJGWA.js';
@@ -1,6 +1,13 @@
1
1
  import { SourceInfo } from 'react-number-format';
2
2
  import { TextFieldProps } from '@mui/material/TextField';
3
3
 
4
+ type OnChangeReturn = {
5
+ event: SourceInfo;
6
+ target: {
7
+ name: string;
8
+ value: number | undefined;
9
+ };
10
+ };
4
11
  type NumberInputProps = Omit<TextFieldProps, 'onChange'> & {
5
12
  name: string;
6
13
  decimalScale?: number;
@@ -11,13 +18,7 @@ type NumberInputProps = Omit<TextFieldProps, 'onChange'> & {
11
18
  maxValue?: number;
12
19
  maxLength?: number;
13
20
  value?: number | null | undefined;
14
- onChange?: (e: {
15
- target: {
16
- name: string;
17
- value: number | undefined;
18
- };
19
- event: SourceInfo;
20
- }) => void;
21
+ onChange?: (e: OnChangeReturn) => void;
21
22
  };
22
23
 
23
- export { NumberInputProps };
24
+ export { NumberInputProps, OnChangeReturn };
@@ -1 +1,3 @@
1
- export { a as isMultiple, b as roundIfNecessary } from '../chunk-TLENQZN5.js';
1
+ function t(r,n,u=0){return Math.round(10**(u||0)*r)%Math.round(10**(u||0)*n)===0}function e(r=0){return Math.round(r*100)/100}
2
+
3
+ export { t as isMultiple, e as roundIfNecessary };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zydon/common",
3
- "version": "2.1.91",
3
+ "version": "2.1.92",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -1,3 +0,0 @@
1
- function t(r,n,u=0){return Math.round(10**(u||0)*r)%Math.round(10**(u||0)*n)===0}function e(r=0){return Math.round(r*100)/100}
2
-
3
- export { t as a, e as b };
@@ -1,12 +0,0 @@
1
- import { a } from './chunk-TLENQZN5.js';
2
- import { f } from './chunk-ANAHA3L6.js';
3
- import { a as a$1 } from './chunk-PV522B4W.js';
4
- import { a as a$2 } from './chunk-4Z2JJGWA.js';
5
- import { forwardRef } from 'react';
6
- import k from '@mui/material/IconButton';
7
- import D from '@mui/material/InputAdornment';
8
- import { jsx } from 'react/jsx-runtime';
9
-
10
- var w=forwardRef(({name:N,increment:t=1,updadteForMultiple:l,allowNegative:u=!1,value:e=0,onChange:r,minValue:n,maxValue:s,decimalScale:p,disabled:I,tabIndex:b,...y},g)=>{let M=a(e,t,p);return jsx(a$1,{ref:g,name:N,value:e,minValue:n,maxValue:s,allowNegative:u,decimalScale:p,InputProps:{startAdornment:jsx(D,{position:"start",children:jsx(k,{size:"medium",disabled:I||(u?!1:!e),onClick:()=>{if(!u&&e-t<0)return;let i=e-t,o=Math.floor(e/t)*t,f$1=!M&&l?o:i;n!==void 0&&i<n?r(n):r(f(f$1,p));},children:jsx(a$2,{icon:"MINUS_SIGN",width:14,height:14,color:"primary.main"})})}),endAdornment:jsx(D,{position:"end",children:jsx(k,{size:"medium",onClick:()=>{let i=Number(e)+t,o=Math.ceil(e/t)*t,c=f(!M&&l?o:i,p);s!==void 0&&i>=s?r(s):r(n!==void 0&&c<=n?n:c);},disabled:I,children:jsx(a$2,{icon:"SIMPLE_ADD",width:14,height:14,color:"primary.main"})})}),inputProps:{style:{textAlign:"center"}}},inputProps:{tabIndex:b},onChange:i=>{let o=f(i.target.value||0,p),f$1=Math.ceil(o/t)*t,c=l?f$1:o;if(n!==void 0&&o<=n){r(n);return}if(s!==void 0&&o>=s){r(s);return}r(c);},disabled:I,...y})});w.displayName="Incrementer";var T=w;
11
-
12
- export { T as a };