@zac-apps/commons 1.1.0 → 1.2.0
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/dist/index.js +67 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32,6 +32,8 @@ import Menu from '@mui/material/Menu';
|
|
|
32
32
|
import Divider from '@mui/material/Divider';
|
|
33
33
|
import MenuIcon from '@mui/icons-material/Menu';
|
|
34
34
|
import MenuOpenIcon from '@mui/icons-material/MenuOpen';
|
|
35
|
+
import TextField from '@mui/material/TextField';
|
|
36
|
+
import InputAdornment from '@mui/material/InputAdornment';
|
|
35
37
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
36
38
|
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
|
37
39
|
import ToggleButton from '@mui/material/ToggleButton';
|
|
@@ -335,6 +337,70 @@ function DivTitle(_ref) {
|
|
|
335
337
|
});
|
|
336
338
|
}
|
|
337
339
|
|
|
340
|
+
function NumField(_ref) {
|
|
341
|
+
var input = _ref.input,
|
|
342
|
+
SetInput = _ref.SetInput,
|
|
343
|
+
error = _ref.error,
|
|
344
|
+
SetError = _ref.SetError,
|
|
345
|
+
minValue = _ref.minValue,
|
|
346
|
+
maxValue = _ref.maxValue,
|
|
347
|
+
adornment = _ref.adornment,
|
|
348
|
+
size = _ref.size;
|
|
349
|
+
var _useState = useState(""),
|
|
350
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
351
|
+
errorMessage = _useState2[0],
|
|
352
|
+
SetErrorMessage = _useState2[1];
|
|
353
|
+
var _useState3 = useState(false),
|
|
354
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
355
|
+
alert = _useState4[0],
|
|
356
|
+
SetAlert = _useState4[1];
|
|
357
|
+
var sx = {};
|
|
358
|
+
if (size === "small") {
|
|
359
|
+
sx = {
|
|
360
|
+
maxWidth: 75
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
function handleEntry(e) {
|
|
364
|
+
var errorFound = false;
|
|
365
|
+
var inputVal = e.target.value;
|
|
366
|
+
if (!inputVal.match(/[0-9-]*/)[0] || inputVal.match(/[0-9-]*/)[0] !== inputVal) {
|
|
367
|
+
errorFound = true;
|
|
368
|
+
SetErrorMessage("Input is not numerical.");
|
|
369
|
+
}
|
|
370
|
+
if (inputVal > maxValue || inputVal < minValue) {
|
|
371
|
+
errorFound = true;
|
|
372
|
+
SetErrorMessage("Input is outside allowed boundaries.");
|
|
373
|
+
}
|
|
374
|
+
SetInput(inputVal);
|
|
375
|
+
SetError(errorFound);
|
|
376
|
+
SetAlert(errorFound);
|
|
377
|
+
}
|
|
378
|
+
return /*#__PURE__*/jsxs(React__default.Fragment, {
|
|
379
|
+
children: [/*#__PURE__*/jsx(TextField, {
|
|
380
|
+
size: "small",
|
|
381
|
+
sx: sx,
|
|
382
|
+
onChange: function onChange(e) {
|
|
383
|
+
return handleEntry(e);
|
|
384
|
+
},
|
|
385
|
+
value: input,
|
|
386
|
+
error: error,
|
|
387
|
+
inputProps: {
|
|
388
|
+
inputMode: "numeric"
|
|
389
|
+
},
|
|
390
|
+
InputProps: {
|
|
391
|
+
endAdornment: /*#__PURE__*/jsx(InputAdornment, {
|
|
392
|
+
position: "end",
|
|
393
|
+
children: adornment
|
|
394
|
+
})
|
|
395
|
+
}
|
|
396
|
+
}), /*#__PURE__*/jsx(ErrorAlert, {
|
|
397
|
+
alert: alert,
|
|
398
|
+
SetAlert: SetAlert,
|
|
399
|
+
message: errorMessage
|
|
400
|
+
})]
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
338
404
|
function Percentage(number) {
|
|
339
405
|
var resultStr = number.toString() + " %";
|
|
340
406
|
return resultStr;
|
|
@@ -603,4 +669,4 @@ function AppDrawer(_ref) {
|
|
|
603
669
|
});
|
|
604
670
|
}
|
|
605
671
|
|
|
606
|
-
export { ErrorAlert as Alert, AppCard, AppDrawer, AppGrid, AppMenu, AppTable, AppTheme, AppWrapper, DivTitle, Footer, MenuButton, NextListMenu, Percentage, Progress, PublicFetch, RespGrid, SpecSwitch, Start, TableHeadCell, useFetch };
|
|
672
|
+
export { ErrorAlert as Alert, AppCard, AppDrawer, AppGrid, AppMenu, AppTable, AppTheme, AppWrapper, DivTitle, Footer, MenuButton, NextListMenu, NumField, Percentage, Progress, PublicFetch, RespGrid, SpecSwitch, Start, TableHeadCell, useFetch };
|