@evoke-platform/ui-components 1.0.0-dev.138 → 1.0.0-dev.140

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,4 @@
1
+ /// <reference types="react" />
2
+ import { ListItemProps } from '@mui/material';
3
+ declare const ListItem: (props: ListItemProps) => JSX.Element;
4
+ export default ListItem;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { ListItem as MUIListItem } from '@mui/material';
3
+ import UIThemeProvider from '../../../theme';
4
+ const ListItem = (props) => {
5
+ return (React.createElement(UIThemeProvider, null,
6
+ React.createElement(MUIListItem, Object.assign({}, props))));
7
+ };
8
+ export default ListItem;
@@ -1,3 +1,4 @@
1
1
  import List from './List';
2
+ import ListItem from './ListItem';
2
3
  export default List;
3
- export { List };
4
+ export { List, ListItem };
@@ -1,3 +1,4 @@
1
1
  import List from './List';
2
+ import ListItem from './ListItem';
2
3
  export default List;
3
- export { List };
4
+ export { List, ListItem };
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { PopperProps } from '@mui/material';
3
+ declare const Popper: (props: PopperProps) => JSX.Element;
4
+ export default Popper;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import { Popper as MUIPopper } from '@mui/material';
3
+ import UIThemeProvider from '../../../theme';
4
+ const Popper = (props) => {
5
+ return (React.createElement(UIThemeProvider, null,
6
+ React.createElement(MUIPopper, Object.assign({}, props))));
7
+ };
8
+ export default Popper;
@@ -0,0 +1,3 @@
1
+ import Popper from './Popper';
2
+ export default Popper;
3
+ export { Popper };
@@ -0,0 +1,3 @@
1
+ import Popper from './Popper';
2
+ export default Popper;
3
+ export { Popper };
@@ -24,7 +24,7 @@ export { Switch } from './Switch';
24
24
  export { TextField } from './TextField';
25
25
  export { Typography } from './Typography';
26
26
  export { Paper } from './Paper';
27
- export { List } from './List';
27
+ export { List, ListItem } from './List';
28
28
  export { Card } from './Card';
29
29
  export { Collapse } from './Collapse';
30
30
  export { IconButton } from './IconButton';
@@ -41,5 +41,6 @@ export { FieldError } from './FieldError';
41
41
  export { Select } from './Select';
42
42
  export { Step, StepLabel, Stepper, StepContent, StepButton, StepIcon, StepConnector } from './Stepper';
43
43
  export { Popover } from './Popover';
44
- export { TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, ListItem, ListItemButton, ListItemText, CardActions, CardActionArea, CardContent, CardMedia, CardHeader, Input, InputLabel, InputAdornment, GridSize, } from '@mui/material';
44
+ export { Popper } from './Popper';
45
+ export { TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, ListItemButton, ListItemText, CardActions, CardActionArea, CardContent, CardMedia, CardHeader, Input, InputLabel, InputAdornment, GridSize, } from '@mui/material';
45
46
  export { LoadingButton, TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
@@ -24,7 +24,7 @@ export { Switch } from './Switch';
24
24
  export { TextField } from './TextField';
25
25
  export { Typography } from './Typography';
26
26
  export { Paper } from './Paper';
27
- export { List } from './List';
27
+ export { List, ListItem } from './List';
28
28
  export { Card } from './Card';
29
29
  export { Collapse } from './Collapse';
30
30
  export { IconButton } from './IconButton';
@@ -41,6 +41,7 @@ export { FieldError } from './FieldError';
41
41
  export { Select } from './Select';
42
42
  export { Step, StepLabel, Stepper, StepContent, StepButton, StepIcon, StepConnector } from './Stepper';
43
43
  export { Popover } from './Popover';
44
+ export { Popper } from './Popper';
44
45
  //TODO: Review following components. They also need theme control:
45
- export { TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, ListItem, ListItemButton, ListItemText, CardActions, CardActionArea, CardContent, CardMedia, CardHeader, Input, InputLabel, InputAdornment, } from '@mui/material';
46
+ export { TableBody, TableCell, TableContainer, TableHead, TablePagination, TableRow, TableSortLabel, ListItemButton, ListItemText, CardActions, CardActionArea, CardContent, CardMedia, CardHeader, Input, InputLabel, InputAdornment, } from '@mui/material';
46
47
  export { LoadingButton, TabContext, TabList, TabPanel, TreeItem, TreeView } from '@mui/lab';
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { FormFieldProps } from '../FormField';
3
+ declare const AddressFieldComponent: (props: FormFieldProps) => JSX.Element;
4
+ export default AddressFieldComponent;
@@ -0,0 +1,81 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, List, ListItem, Popper, TextField, Typography } from '../../../core';
3
+ import { Box } from '../../../layout';
4
+ import InputMask from 'react-input-mask';
5
+ import { CancelOutlined } from '../../../../icons';
6
+ const AddressFieldComponent = (props) => {
7
+ const { property, defaultValue, error, errorMessage, onBlur, readOnly, required, size, placeholder, mask, isMultiLineText, rows, inputMaskPlaceholderChar, queryAddresses } = props;
8
+ const [value, setValue] = useState(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
9
+ // const [inputValue, setInputValue] = useState<string>('');
10
+ const [selectOptions, setSelectOptions] = useState([]);
11
+ const id = property.id;
12
+ const [anchorEl, setAnchorEl] = React.useState(null);
13
+ const open = Boolean(anchorEl);
14
+ const popperId = open ? `${id}-popper` : undefined;
15
+ useEffect(() => {
16
+ setValue(defaultValue !== null && defaultValue !== void 0 ? defaultValue : '');
17
+ }, [defaultValue]);
18
+ const handleChange = (e) => {
19
+ setAnchorEl(e.currentTarget);
20
+ const inputValue = e.target.value;
21
+ setValue(inputValue);
22
+ queryAddresses && queryAddresses(value).then(addresses => {
23
+ setSelectOptions(addresses.filter(address => address.address.line1).map((address) => {
24
+ let label = '', sublabel = '';
25
+ if (address.address.line1)
26
+ label = label.concat(address.address.line1);
27
+ if (address.address.city)
28
+ sublabel = sublabel.concat(`${address.address.city}`);
29
+ if (address.address.county)
30
+ sublabel = sublabel ? sublabel.concat(`, ${address.address.county}`) : address.address.county;
31
+ if (address.address.state)
32
+ sublabel = sublabel ? sublabel.concat(`, ${address.address.state}`) : address.address.state;
33
+ if (address.address.zipCode)
34
+ sublabel = sublabel ? sublabel.concat(` ${address.address.zipCode}`) : address.address.zipCode;
35
+ return { label, sublabel, value: address.address };
36
+ }));
37
+ });
38
+ props.onChange(id, inputValue, property, undefined, true);
39
+ };
40
+ const handleClick = (option) => {
41
+ setAnchorEl(null);
42
+ setValue(option.value.line1);
43
+ props.onChange(id, option.value, property, undefined, true);
44
+ };
45
+ const handleClose = () => {
46
+ setAnchorEl(null);
47
+ };
48
+ return (React.createElement(Box, null,
49
+ !mask ? React.createElement(TextField, { id: id, "aria-describedby": popperId, onChange: !readOnly ? handleChange : undefined, error: error, errorMessage: errorMessage, value: value, fullWidth: true, onBlur: onBlur, size: size !== null && size !== void 0 ? size : 'medium', placeholder: placeholder, InputProps: {
50
+ type: 'search',
51
+ autoComplete: 'off'
52
+ }, required: required, readOnly: readOnly, multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined }) : React.createElement(InputMask, { mask: mask, maskChar: inputMaskPlaceholderChar !== null && inputMaskPlaceholderChar !== void 0 ? inputMaskPlaceholderChar : '_', value: value, onChange: !readOnly ? handleChange : undefined, onBlur: onBlur, alwaysShowMask: true }, () => (React.createElement(TextField, { id: id, sx: readOnly
53
+ ? {
54
+ '& .MuiOutlinedInput-notchedOutline': {
55
+ border: 'none',
56
+ },
57
+ '.MuiOutlinedInput-root': {
58
+ borderRadius: '8px',
59
+ backgroundColor: '#f4f6f8',
60
+ },
61
+ }
62
+ : undefined, required: required, error: error, errorMessage: errorMessage, InputProps: { readOnly: readOnly }, fullWidth: true, size: size !== null && size !== void 0 ? size : 'medium', type: 'text', multiline: property.type === 'string' && !readOnly && isMultiLineText, rows: isMultiLineText ? (rows ? rows : 3) : undefined, value: value }))),
63
+ !readOnly && React.createElement(Popper, { id: popperId, open: open, anchorEl: anchorEl, placement: 'bottom-start', sx: { margin: '0 0 0 35px', background: 'white' } },
64
+ React.createElement(List, null,
65
+ selectOptions.map((option) => {
66
+ return (React.createElement(ListItem, { onClick: () => handleClick(option), sx: {
67
+ '&:hover': {
68
+ cursor: 'pointer',
69
+ backgroundColor: 'rgba(0, 0, 0, 0.04)',
70
+ }
71
+ } },
72
+ React.createElement(Box, { sx: {
73
+ flexGrow: 1,
74
+ } },
75
+ React.createElement(Typography, null, option.label),
76
+ React.createElement(Typography, { sx: { color: '#586069' } }, option.sublabel))));
77
+ }),
78
+ React.createElement(ListItem, { sx: { justifyContent: 'center' } },
79
+ React.createElement(Button, { fullWidth: true, size: 'small', color: 'primary', variant: "outlined", startIcon: React.createElement(CancelOutlined, null), onClick: () => handleClose() }, "Close"))))));
80
+ };
81
+ export default AddressFieldComponent;
@@ -0,0 +1 @@
1
+ export * from './addressFieldComponent';
@@ -0,0 +1 @@
1
+ export * from './addressFieldComponent';
@@ -17,6 +17,7 @@ export declare type FormFieldProps = {
17
17
  isMultiLineText?: boolean;
18
18
  rows?: number;
19
19
  inputMaskPlaceholderChar?: string;
20
+ queryAddresses?: Function;
20
21
  };
21
22
  export declare type ObjectProperty = {
22
23
  id: string;
@@ -4,8 +4,9 @@ import DatePickerSelect from './DatePickerSelect/DatePickerSelect';
4
4
  import FileUploadControl from './FileUpload/FileUpload';
5
5
  import InputFieldComponent from './InputFieldComponent/InputFieldComponent';
6
6
  import Select from './Select/Select';
7
+ import AddressFieldComponent from './AddressFieldComponent/addressFieldComponent';
7
8
  const FormField = (props) => {
8
- const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, onBlur, mask, max, min, isMultiLineText, rows, inputMaskPlaceholderChar, } = props;
9
+ const { defaultValue, error, onChange, property, readOnly, selectOptions, required, size, placeholder, errorMessage, onBlur, mask, max, min, isMultiLineText, rows, inputMaskPlaceholderChar, queryAddresses } = props;
9
10
  const id = property.id;
10
11
  let control;
11
12
  const commonProps = {
@@ -24,6 +25,10 @@ const FormField = (props) => {
24
25
  min,
25
26
  max,
26
27
  };
28
+ if (queryAddresses) {
29
+ control = (React.createElement(AddressFieldComponent, Object.assign({}, commonProps, { mask: mask, inputMaskPlaceholderChar: inputMaskPlaceholderChar, isMultiLineText: isMultiLineText, rows: rows, queryAddresses: queryAddresses })));
30
+ return control;
31
+ }
27
32
  switch (property.type) {
28
33
  case 'boolean':
29
34
  control = (React.createElement(BooleanSelect, Object.assign({}, commonProps, { defaultValue: defaultValue ? 'Yes' : defaultValue === undefined ? '' : 'No' })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.0.0-dev.138",
3
+ "version": "1.0.0-dev.140",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",