@nethru/ui 2.1.22 → 2.1.24

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.
@@ -1,8 +1,8 @@
1
1
  import { forwardRef, useMemo } from "react";
2
- import TextField from "@mui/material/TextField";
3
2
  import { IconButton, InputAdornment } from "@mui/material";
4
3
  import SearchIcon from "@mui/icons-material/Search";
5
4
  import ClearIcon from '@mui/icons-material/Clear';
5
+ import { TextField } from "../lib";
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  const SearchTextField = /*#__PURE__*/forwardRef(({
8
8
  value,
@@ -1,5 +1,6 @@
1
- import { Autocomplete, FormControl, FormHelperText, InputLabel, TextField } from "@mui/material";
2
1
  import { forwardRef, useCallback, useMemo } from "react";
2
+ import { Autocomplete, FormControl, FormHelperText, InputLabel } from "@mui/material";
3
+ import { TextField } from "../lib";
3
4
  import { jsx as _jsx } from "react/jsx-runtime";
4
5
  import { jsxs as _jsxs } from "react/jsx-runtime";
5
6
  const SearchableSelect = /*#__PURE__*/forwardRef(({
@@ -0,0 +1,31 @@
1
+ import { forwardRef, useCallback, useState } from "react";
2
+ import MuiTextField from "@mui/material/TextField";
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ const validateRule = process.env.REACT_APP_VALIDATE_RULE;
5
+ const validateMessage = process.env.REACT_APP_VALIDATE_MESSAGE;
6
+ // eslint-disable-next-line
7
+ const validate = validateRule ? new Function("value", validateRule) : null;
8
+ const TextField = /*#__PURE__*/forwardRef((props, ref) => {
9
+ const [error, setError] = useState(false);
10
+ const [helperText, setHelperText] = useState('');
11
+ const handleChange = useCallback(event => {
12
+ if (validate) {
13
+ if (validate(event.target.value)) {
14
+ setError(true);
15
+ setHelperText(validateMessage);
16
+ } else {
17
+ setError(false);
18
+ setHelperText('');
19
+ }
20
+ }
21
+ if (props.onChange) props.onChange(event);
22
+ }, [props]);
23
+ return /*#__PURE__*/_jsx(MuiTextField, {
24
+ ref: ref,
25
+ ...props,
26
+ error: error || props.error,
27
+ helperText: helperText || props.helperText,
28
+ onChange: handleChange
29
+ });
30
+ });
31
+ export default TextField;
package/base/index.js CHANGED
@@ -38,6 +38,7 @@ export { default as Slider } from "./Slider";
38
38
  export { default as Snackbar } from "./Snackbar";
39
39
  export { default as SplitLayout } from "./frame/SplitLayout";
40
40
  export { default as Switch } from "./Switch";
41
+ export { default as TextField } from "./TextField";
41
42
  export * from './frame/sidebar/SidebarContext';
42
43
  export { default as Error } from "./error/Error";
43
44
  export { default as HttpError } from "./error/HttpError";
@@ -1,5 +1,6 @@
1
1
  import typography from "./typography";
2
2
  import { blueGrey } from "../colors";
3
+ import shadow from "./shadow";
3
4
  const globalStyles = {
4
5
  ':root': {
5
6
  '--body-background-color': blueGrey.contentBg,
@@ -51,8 +52,9 @@ const globalStyles = {
51
52
  '.highcharts-tooltip > span': {
52
53
  background: '#fff',
53
54
  border: '1px solid #ccc',
54
- borderRadius: '3px',
55
- padding: '8px'
55
+ borderRadius: '8px',
56
+ padding: '8px',
57
+ boxShadow: shadow[3]
56
58
  }
57
59
  };
58
60
  export default globalStyles;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "2.1.22",
3
+ "version": "2.1.24",
4
4
  "main": "base/index.js",
5
5
  "files": [
6
6
  "/base"