@evoke-platform/ui-components 1.0.0-dev.1.10.8 → 1.0.0-dev.100

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.
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import { Autocomplete, TextField } from '../../../core';
3
3
  import InputFieldComponent from '../InputFieldComponent/InputFieldComponent';
4
4
  const BooleanSelect = (props) => {
5
- const { property, defaultValue, error, errorMessage, readOnly, size, placeholder } = props;
5
+ const { property, defaultValue, error, errorMessage, readOnly, size, placeholder, onBlur } = props;
6
6
  const [value, setValue] = useState(defaultValue);
7
7
  const id = property.id;
8
8
  useEffect(() => {
@@ -22,6 +22,6 @@ const BooleanSelect = (props) => {
22
22
  value: false,
23
23
  },
24
24
  ];
25
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { id: id, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, style: { background: 'white' }, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, style: { background: 'white', borderRadius: '8px' } }));
25
+ return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { id: id, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, style: { background: 'white' }, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), value: value, onChange: handleChange, inputValue: value, options: booleanOptions, disableClearable: true, style: { background: 'white', borderRadius: '8px' } }));
26
26
  };
27
27
  export default BooleanSelect;
@@ -26,7 +26,7 @@ const asMonthDayYearFormat = (date) => {
26
26
  }
27
27
  };
28
28
  const DatePickerSelect = (props) => {
29
- const { property, defaultValue, error, errorMessage, readOnly, required, size } = props;
29
+ const { property, defaultValue, error, errorMessage, readOnly, required, size, onBlur } = props;
30
30
  const [value, setValue] = useState(asCalendarDate(defaultValue));
31
31
  const id = property.id;
32
32
  useEffect(() => {
@@ -37,6 +37,6 @@ const DatePickerSelect = (props) => {
37
37
  props.onChange(id, date, property);
38
38
  };
39
39
  return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, Object.assign(Object.assign({}, props), { defaultValue: asMonthDayYearFormat(value) })))) : (React.createElement(LocalizationProvider, null,
40
- React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, fullWidth: true, required: required, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }))) })));
40
+ React.createElement(DatePicker, { value: value, onChange: handleChange, inputFormat: "MM/dd/yyyy", renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { id: id, error: error, errorMessage: errorMessage, onBlur: onBlur, fullWidth: true, required: required, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium' }))) })));
41
41
  };
42
42
  export default DatePickerSelect;
@@ -1,15 +1,19 @@
1
1
  export declare type FormFieldProps = {
2
2
  property: ObjectProperty;
3
3
  onChange: Function;
4
+ onBlur?: Function;
4
5
  defaultValue?: unknown;
5
6
  error?: boolean;
6
7
  errorMessage?: string;
7
8
  required?: boolean;
8
9
  readOnly?: boolean;
10
+ min?: number;
11
+ max?: number;
9
12
  selectOptions?: Array<string>;
10
13
  locale?: string;
11
14
  size?: 'small' | 'medium';
12
15
  placeholder?: string;
16
+ mask?: string;
13
17
  };
14
18
  export declare type ObjectProperty = {
15
19
  id: string;
@@ -5,13 +5,14 @@ import FileUploadControl from './FileUpload/FileUpload';
5
5
  import InputFieldComponent from './InputFieldComponent/InputFieldComponent';
6
6
  import Select from './Select/Select';
7
7
  const FormField = (props) => {
8
- const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage } = props;
8
+ const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, onBlur, mask, max, min } = props;
9
9
  const id = property.id;
10
10
  let control;
11
11
  const commonProps = {
12
12
  id,
13
13
  property,
14
14
  onChange,
15
+ onBlur,
15
16
  error,
16
17
  errorMessage,
17
18
  readOnly,
@@ -20,6 +21,8 @@ const FormField = (props) => {
20
21
  required,
21
22
  size,
22
23
  placeholder,
24
+ min,
25
+ max
23
26
  };
24
27
  switch (property.type) {
25
28
  case 'boolean':
@@ -38,7 +41,7 @@ const FormField = (props) => {
38
41
  control = React.createElement(Select, Object.assign({}, commonProps));
39
42
  break;
40
43
  default:
41
- control = React.createElement(InputFieldComponent, Object.assign({}, commonProps));
44
+ control = React.createElement(InputFieldComponent, Object.assign({}, commonProps, { mask: mask }));
42
45
  break;
43
46
  }
44
47
  return control;
@@ -12,6 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  import React, { useEffect, useState } from 'react';
13
13
  import NumberFormat from 'react-number-format';
14
14
  import { Autocomplete, TextField } from '../../../core';
15
+ import InputMask from 'react-input-mask';
15
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
17
  const NumericFormat = (props) => {
17
18
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -22,11 +23,11 @@ const NumericFormat = (props) => {
22
23
  value: values.floatValue,
23
24
  },
24
25
  });
25
- }, thousandSeparator: true, isNumericString: true, fixedDecimalScale: true, allowNegative: true })));
26
+ }, isNumericString: true, fixedDecimalScale: true, allowNegative: false })));
26
27
  };
27
28
  const InputFieldComponent = (props) => {
28
29
  var _a;
29
- const { property, defaultValue, error, errorMessage, readOnly, required, size, placeholder } = props;
30
+ const { property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, min, max } = props;
30
31
  const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
31
32
  const [inputValue, setInputValue] = useState('');
32
33
  const id = property.id;
@@ -46,11 +47,9 @@ const InputFieldComponent = (props) => {
46
47
  setInputValue(selectValue);
47
48
  };
48
49
  const InputProps = property.type === 'number'
49
- ? {
50
- inputComponent: NumericFormat,
51
- }
50
+ ? { inputComponent: NumericFormat, min, max }
52
51
  : property.type === 'integer'
53
- ? { inputProps: { min: 0 } }
52
+ ? { inputProps: { min, max } }
54
53
  : null;
55
54
  const selectOptions = (_a = property.enum) !== null && _a !== void 0 ? _a : [];
56
55
  if (property.enum && !property.enum.includes(value)) {
@@ -59,9 +58,9 @@ const InputFieldComponent = (props) => {
59
58
  //widgets had it like this, as strings w/isOptionEqualToValue
60
59
  selectOptions.push(value);
61
60
  }
62
- return property.enum && !readOnly ? (React.createElement(Autocomplete, { id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
61
+ return property.enum && !readOnly ? (React.createElement(Autocomplete, { id: id, options: selectOptions, onChange: handleSelectChange, renderInput: (params) => (React.createElement(TextField, Object.assign({}, params, { value: value, error: error, errorMessage: errorMessage, fullWidth: true, onBlur: onBlur, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder }))), disableClearable: true, value: value, isOptionEqualToValue: (option, value) => {
63
62
  return option.value === value;
64
- }, error: error, required: required, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', onInputChange: handleInputValueChange })) : (React.createElement(TextField, { id: id, sx: readOnly
63
+ }, error: error, required: required, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', onInputChange: handleInputValueChange })) : !mask ? (React.createElement(TextField, { id: id, sx: readOnly
65
64
  ? {
66
65
  '& .MuiOutlinedInput-notchedOutline': {
67
66
  border: 'none',
@@ -71,6 +70,17 @@ const InputFieldComponent = (props) => {
71
70
  backgroundColor: '#f4f6f8',
72
71
  },
73
72
  }
74
- : undefined, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, placeholder: placeholder, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !!readOnly }));
73
+ : undefined, error: error, errorMessage: errorMessage, value: value, onChange: !readOnly ? handleChange : undefined, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), required: required, fullWidth: true, onBlur: onBlur, placeholder: placeholder, style: { background: 'white', borderRadius: '8px' }, size: size !== null && size !== void 0 ? size : 'medium', type: property.type === 'integer' ? 'number' : 'text', multiline: property.type === 'string' && !!readOnly })) : (React.createElement(InputMask, { mask: mask, value: value, onChange: !readOnly ? handleChange : undefined, alwaysShowMask: true },
74
+ React.createElement(TextField, { id: id, sx: readOnly
75
+ ? {
76
+ '& .MuiOutlinedInput-notchedOutline': {
77
+ border: 'none',
78
+ },
79
+ '.MuiOutlinedInput-root': {
80
+ borderRadius: '8px',
81
+ backgroundColor: '#f4f6f8',
82
+ },
83
+ }
84
+ : undefined, error: error, errorMessage: errorMessage, onBlur: onBlur, InputProps: Object.assign(Object.assign({}, InputProps), { readOnly: readOnly }), fullWidth: true, type: property.type === 'integer' ? 'number' : 'text' })));
75
85
  };
76
86
  export default InputFieldComponent;
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
2
2
  import { Autocomplete, TextField } from '../../../core';
3
3
  import InputFieldComponent from '../InputFieldComponent/InputFieldComponent';
4
4
  const Select = (props) => {
5
- const { property, defaultValue, error, errorMessage, readOnly, selectOptions, required, size } = props;
5
+ const { property, defaultValue, error, errorMessage, onBlur, readOnly, selectOptions, required, size } = props;
6
6
  const [value, setValue] = useState(defaultValue);
7
7
  const [inputValue, setInputValue] = useState('');
8
8
  useEffect(() => {
@@ -27,6 +27,6 @@ const Select = (props) => {
27
27
  setInputValue(selectValue);
28
28
  }
29
29
  };
30
- return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { multiple: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? true : false, id: id, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { value: value, fullWidth: true })), value: value, onChange: handleChange, options: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? property === null || property === void 0 ? void 0 : property.enum : selectOptions, disableClearable: true, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', error: error, errorMessage: errorMessage, required: required, onInputChange: handleInputValueChange, filterOptions: (option) => { var _a; return (property === null || property === void 0 ? void 0 : property.type) === 'array' ? (_a = property === null || property === void 0 ? void 0 : property.enum) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== option.value) : option; }, size: size }));
30
+ return readOnly ? (React.createElement(InputFieldComponent, Object.assign({}, props))) : (React.createElement(Autocomplete, { multiple: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? true : false, id: id, renderInput: (params) => React.createElement(TextField, Object.assign({}, params, { value: value, fullWidth: true, onBlur: onBlur })), value: value, onChange: handleChange, options: (property === null || property === void 0 ? void 0 : property.type) === 'array' ? property === null || property === void 0 ? void 0 : property.enum : selectOptions, disableClearable: true, inputValue: inputValue !== null && inputValue !== void 0 ? inputValue : '', error: error, errorMessage: errorMessage, required: required, onInputChange: handleInputValueChange, filterOptions: (option) => { var _a; return (property === null || property === void 0 ? void 0 : property.type) === 'array' ? (_a = property === null || property === void 0 ? void 0 : property.enum) === null || _a === void 0 ? void 0 : _a.filter((item) => item !== option.value) : option; }, size: size }));
31
31
  };
32
32
  export default Select;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.1.10.8",
3
+ "version": "1.0.0-dev.100",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",
@@ -72,6 +72,7 @@
72
72
  "@react-querybuilder/material": "^5.4.1",
73
73
  "lodash-es": "^4.17.21",
74
74
  "react-dropzone": "^14.2.2",
75
+ "react-input-mask": "^3.0.0-alpha.2",
75
76
  "react-number-format": "^4.9.3",
76
77
  "react-querybuilder": "^6.0.2"
77
78
  },