@evoke-platform/ui-components 1.6.0-dev.11 → 1.6.0-dev.13

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,24 @@
1
+ import React, { ReactNode } from 'react';
2
+ type FieldWrapperProps = {
3
+ inputId: string;
4
+ inputType: string;
5
+ label: string;
6
+ description?: string;
7
+ tooltip?: string;
8
+ prefix?: string;
9
+ suffix?: string;
10
+ value?: string;
11
+ errorMessage?: string;
12
+ showCharCount?: boolean;
13
+ viewOnly: boolean;
14
+ children: ReactNode;
15
+ required: boolean;
16
+ fieldHeight?: 'small' | 'medium';
17
+ maxLength?: number;
18
+ };
19
+ /**
20
+ * A component that wraps a FormField and adds a label,
21
+ * description, tooltip, prefix, suffix and word/char counts
22
+ */
23
+ declare const FieldWrapper: (props: FieldWrapperProps) => React.JSX.Element;
24
+ export default FieldWrapper;
@@ -0,0 +1,100 @@
1
+ import { Help, InfoRounded } from '@mui/icons-material';
2
+ import React from 'react';
3
+ import { IconButton, InputLabel, Tooltip, Typography } from '../../../core';
4
+ import { Box } from '../../../layout';
5
+ const underFieldStyles = {
6
+ display: 'flex',
7
+ flexDirection: 'row',
8
+ justifyContent: 'space-between',
9
+ alignItems: 'center',
10
+ };
11
+ const descriptionStyles = {
12
+ color: '#999',
13
+ whiteSpace: 'normal',
14
+ display: 'block',
15
+ };
16
+ const PrefixSuffix = (props) => {
17
+ const { prefix, suffix, height, isViewOnly } = props;
18
+ const text = prefix || suffix;
19
+ const prefixSuffixStyles = {
20
+ display: 'inline-flex',
21
+ alignItems: 'center',
22
+ background: isViewOnly ? undefined : '#f5f5f5',
23
+ padding: '5px',
24
+ border: isViewOnly ? undefined : '1px solid #ccc',
25
+ ...(suffix && {
26
+ borderTopRightRadius: '5px',
27
+ borderBottomRightRadius: '5px',
28
+ marginLeft: '-5px',
29
+ padding: '7px 5px 7px 10px',
30
+ marginTop: '6px',
31
+ }),
32
+ ...(prefix && {
33
+ borderTopLeftRadius: '5px',
34
+ borderBottomLeftRadius: '5px',
35
+ marginRight: '-5px',
36
+ padding: '7px 10px 7px 5px',
37
+ marginTop: '6px',
38
+ }),
39
+ height: height === 'small' ? 24 : 40,
40
+ };
41
+ if (!prefix && !suffix)
42
+ return null;
43
+ return (React.createElement(Box, { sx: prefixSuffixStyles },
44
+ React.createElement(Typography, null, text)));
45
+ };
46
+ /**
47
+ * A component that wraps a FormField and adds a label,
48
+ * description, tooltip, prefix, suffix and word/char counts
49
+ */
50
+ const FieldWrapper = (props) => {
51
+ const { inputId, label, description, tooltip, prefix, suffix, value, maxLength, errorMessage, showCharCount, inputType, viewOnly, children, fieldHeight, required, } = props;
52
+ const charCount = value ? value.length : 0;
53
+ const remainingChars = maxLength ? maxLength - charCount : undefined;
54
+ return (React.createElement(Box, null,
55
+ React.createElement(Box, { sx: { padding: '10px 0' } },
56
+ inputType !== 'boolean' && (React.createElement(InputLabel, { htmlFor: inputId, sx: {
57
+ display: 'flex',
58
+ alignItems: 'center',
59
+ color: viewOnly ? 'text.secondary' : 'text.primary',
60
+ fontSize: '14px',
61
+ } },
62
+ label,
63
+ required ? (React.createElement(Typography, { component: 'span', sx: { color: 'red', fontSize: '12px', lineHeight: '22px', paddingLeft: '4px' } }, `*`)) : null,
64
+ tooltip && (React.createElement(Tooltip, { placement: "right", title: tooltip },
65
+ React.createElement(IconButton, null,
66
+ React.createElement(Help, { sx: { fontSize: '14px' } })))))),
67
+ React.createElement(Box, { sx: {
68
+ display: 'flex',
69
+ flexDirection: 'row',
70
+ alignItems: viewOnly ? 'center' : 'flex-start',
71
+ } },
72
+ inputType === 'string' && (React.createElement(PrefixSuffix, { prefix: prefix, height: fieldHeight || 'medium', isViewOnly: viewOnly })),
73
+ React.createElement(Box, { sx: {
74
+ width: viewOnly && suffix ? undefined : '100%',
75
+ marginTop: '6px',
76
+ borderRadius: '8px',
77
+ } },
78
+ children,
79
+ inputType !== 'boolean' && (errorMessage || description || showCharCount) && (React.createElement(Box, { sx: underFieldStyles },
80
+ React.createElement(Box, { sx: {
81
+ width: '100%',
82
+ display: 'flex',
83
+ justifyContent: 'space-between',
84
+ alignItems: 'flex-start',
85
+ flexWrap: 'wrap',
86
+ paddingTop: '4px',
87
+ } },
88
+ React.createElement(Box, { sx: { display: 'flex', flexDirection: 'column' } },
89
+ errorMessage ? (React.createElement(Box, { display: 'flex', alignItems: 'center' },
90
+ React.createElement(InfoRounded, { color: 'error', sx: { fontSize: '.75rem', marginRight: '3px' } }),
91
+ React.createElement(Typography, { fontSize: '12px', color: 'error', sx: { lineHeight: '18px' } }, errorMessage))) : (React.createElement("span", null)),
92
+ description && (React.createElement(Typography, { id: `${inputId}-description`, variant: "caption", sx: descriptionStyles }, description))),
93
+ showCharCount && (React.createElement(Typography, { variant: "caption", sx: { color: '#999999', whiteSpace: 'nowrap' } },
94
+ remainingChars ?? charCount,
95
+ ' ',
96
+ (remainingChars ?? charCount) === 1 ? 'character' : 'characters',
97
+ !!maxLength && ` remaining`)))))),
98
+ inputType === 'string' && (React.createElement(PrefixSuffix, { suffix: suffix, height: fieldHeight || 'medium', isViewOnly: viewOnly }))))));
99
+ };
100
+ export default FieldWrapper;
@@ -0,0 +1,12 @@
1
+ import { Obj } from '@evoke-platform/context';
2
+ import { Dispatch, SetStateAction } from 'react';
3
+ import { FieldValues, UseFormGetValues } from 'react-hook-form';
4
+ type FormContextType = {
5
+ fetchedOptions: FieldValues;
6
+ setFetchedOptions: Dispatch<SetStateAction<FieldValues>>;
7
+ getValues: UseFormGetValues<FieldValues>;
8
+ stickyFooter?: boolean;
9
+ object?: Obj;
10
+ };
11
+ export declare const FormContext: import("react").Context<FormContextType>;
12
+ export {};
@@ -0,0 +1,8 @@
1
+ import { createContext } from 'react';
2
+ export const FormContext = createContext({
3
+ fetchedOptions: {},
4
+ setFetchedOptions: () => { },
5
+ getValues: (() => ({})),
6
+ stickyFooter: false,
7
+ object: undefined,
8
+ });
@@ -0,0 +1,10 @@
1
+ import React, { SyntheticEvent } from 'react';
2
+ type TabNavProps = {
3
+ numberOfTabs: number;
4
+ tabValue: number;
5
+ handleTabChange: (event: SyntheticEvent, newValue: number) => void;
6
+ prevTabLabel?: string;
7
+ nextTabLabel?: string;
8
+ };
9
+ declare function TabNav(props: TabNavProps): React.JSX.Element;
10
+ export default TabNav;
@@ -0,0 +1,23 @@
1
+ import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew';
2
+ import ArrowForwardIosIcon from '@mui/icons-material/ArrowForwardIos';
3
+ import React from 'react';
4
+ import { Button } from '../../../core';
5
+ import { Box } from '../../../layout';
6
+ function TabNav(props) {
7
+ const { numberOfTabs, tabValue, handleTabChange, prevTabLabel, nextTabLabel } = props;
8
+ const isFirstTab = tabValue === 0;
9
+ const isLastTab = tabValue === numberOfTabs - 1;
10
+ return (React.createElement(Box, { sx: {
11
+ display: 'flex',
12
+ justifyContent: isFirstTab ? 'flex-end' : 'space-between',
13
+ paddingTop: '10px',
14
+ paddingBottom: '20px',
15
+ } },
16
+ !isFirstTab && (React.createElement(Button, { id: 'navigation-prev', onClick: (event) => handleTabChange(event, tabValue - 1), sx: { color: 'black', backgroundColor: '#dfe3e8', '&:hover': { backgroundColor: '#d0d4d9' } }, "aria-label": `Navigate to previous tab ${prevTabLabel}` },
17
+ React.createElement(ArrowBackIosNewIcon, { sx: { fontSize: 'medium', marginRight: 1 } }),
18
+ prevTabLabel ?? 'Previous tab')),
19
+ !isLastTab && (React.createElement(Button, { id: 'navigation-next', onClick: (event) => handleTabChange(event, tabValue + 1), sx: { color: 'black', backgroundColor: '#dfe3e8', '&:hover': { backgroundColor: '#d0d4d9' } }, "aria-label": `Navigate to next tab ${nextTabLabel}` },
20
+ nextTabLabel ?? 'Next tab',
21
+ React.createElement(ArrowForwardIosIcon, { sx: { fontSize: 'medium', marginLeft: 1 } })))));
22
+ }
23
+ export default TabNav;
@@ -133,11 +133,11 @@ export const ResponsiveOverflow = (props) => {
133
133
  }, transformOrigin: {
134
134
  vertical: 'top',
135
135
  horizontal: 'right',
136
- }, sx: { '& .MuiPaper-root': styles.menuPaper } }, overflowItems.map((item, idx) => {
136
+ }, sx: { '& .MuiPaper-root': styles.menuPaper }, onClick: handleMenuClose }, overflowItems.map((item, index) => {
137
137
  if (renderOverflowMenuItem) {
138
138
  return renderOverflowMenuItem(item);
139
139
  }
140
- return (React.createElement(MenuItem, { key: idx, onClick: handleMenuClose }, item));
140
+ return (React.createElement(MenuItem, { key: `overflow-item-${index}`, onClick: handleMenuClose }, item));
141
141
  }))))));
142
142
  };
143
143
  export default ResponsiveOverflow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/ui-components",
3
- "version": "1.6.0-dev.11",
3
+ "version": "1.6.0-dev.13",
4
4
  "description": "",
5
5
  "main": "dist/published/index.js",
6
6
  "module": "dist/published/index.js",
@@ -125,6 +125,7 @@
125
125
  "pluralize": "^8.0.0",
126
126
  "pretty-bytes": "^6.1.1",
127
127
  "react-dropzone": "^14.2.2",
128
+ "react-hook-form": "^7.60.0",
128
129
  "react-input-mask": "^2.0.4",
129
130
  "react-number-format": "^4.9.3",
130
131
  "react-querybuilder": "^6.0.2",