@zac-apps/commons 1.1.0-beta.1 → 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.
Files changed (2) hide show
  1. package/dist/index.js +67 -1
  2. package/package.json +10 -12
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zac-apps/commons",
3
- "version": "1.1.0-beta.1",
3
+ "version": "1.2.0",
4
4
  "scripts": {
5
5
  "rollup": "node_modules/rollup/dist/rollup.js",
6
6
  "dev": "next dev",
@@ -28,10 +28,8 @@
28
28
  "author": "ZAC",
29
29
  "license": "CC-BY-SA-4.0",
30
30
  "dependencies": {
31
- "@fontsource/roboto": "^5.0.8",
32
31
  "@mui/icons-material": "^5.15.0",
33
- "@mui/material": "^5.15.0",
34
- "@mui/x-date-pickers": "^6.18.5"
32
+ "@mui/material": "^5.15.0"
35
33
  },
36
34
  "devDependencies": {
37
35
  "@babel/plugin-transform-runtime": "^7.23.6",
@@ -42,21 +40,21 @@
42
40
  "@semantic-release/git": "^10.0.1",
43
41
  "@semantic-release/gitlab": "^12.1.1",
44
42
  "@semantic-release/npm": "^11.0.2",
45
- "@storybook/addon-essentials": "^7.6.4",
46
- "@storybook/addon-interactions": "^7.6.4",
47
- "@storybook/addon-links": "^7.6.4",
43
+ "@storybook/addon-essentials": "^7.6.5",
44
+ "@storybook/addon-interactions": "^7.6.5",
45
+ "@storybook/addon-links": "^7.6.5",
48
46
  "@storybook/addon-onboarding": "^1.0.10",
49
- "@storybook/blocks": "^7.6.4",
50
- "@storybook/nextjs": "^7.6.4",
51
- "@storybook/react": "^7.6.4",
52
- "@storybook/test": "^7.6.4",
47
+ "@storybook/blocks": "^7.6.5",
48
+ "@storybook/nextjs": "^7.6.5",
49
+ "@storybook/react": "^7.6.5",
50
+ "@storybook/test": "^7.6.5",
53
51
  "babel-loader": "^9.1.3",
54
52
  "eslint": "^8",
55
53
  "eslint-config-next": "14.0.4",
56
54
  "eslint-plugin-storybook": "^0.6.15",
57
55
  "rollup": "^4.9.0",
58
56
  "semantic-release": "^22.0.12",
59
- "storybook": "^7.6.4"
57
+ "storybook": "^7.6.5"
60
58
  },
61
59
  "peerDependencies": {
62
60
  "next": "^14.0.4",