@flipdish/portal-library 1.0.34 → 1.0.35

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,2 +1,2 @@
1
- "use strict";var e=require("react/jsx-runtime"),r=require("formik"),i=require("@mui/material/TextField"),t=require("../../custom-hooks/useRenderValidText.cjs.js"),a=require("./FormItemLayout.cjs.js"),l=require("@mui/material/Typography");module.exports=({label:o,fieldName:d,placeholder:n,validation:s,multiline:u,minRows:m,maxRows:h,layout:c="horizontal",variant:v="standard",disabled:x=!1,required:p=!1})=>{const g=()=>e.jsx(r.Field,{name:d,validate:s,children:({field:r,form:a})=>{const{errors:l,touched:s,isSubmitting:g}=a,j=l[r.name],f=!!j&&s[r.name],q=t({fieldError:j,showError:f,touched:!!s[r.name],value:r.value});return e.jsx(i,{label:"standard"===v?void 0:o,variant:v,value:r.value,"data-testid":`text-field-${d}`,autoComplete:"off",fullWidth:!0,multiline:!0,minRows:m??(u?3:void 0),maxRows:h??(u?10:void 0),style:{paddingRight:"horizontal"===c?16:0},placeholder:n||void 0,disabled:g||x,required:p,error:f,helperText:q,FormHelperTextProps:{children:" ",style:{textAlign:"right"}},inputProps:{style:{paddingTop:0,height:"1.1876em"}},onChange:e=>{a.setFieldValue(r.name,e.target.value)}})}});return"vertical"===c?e.jsxs(e.Fragment,{children:["standard"===v&&e.jsx(l,{variant:"subtitle1",component:"h3",color:"textPrimary",children:o}),g()]}):e.jsx(a,{label:o,children:g()})};
1
+ "use strict";var e=require("react/jsx-runtime"),r=require("formik"),i=require("@mui/material/TextField"),t=require("../../custom-hooks/useRenderValidText.cjs.js"),a=require("./FormItemLayout.cjs.js"),l=require("@mui/material/Typography");module.exports=({label:o,fieldName:d,placeholder:n,validation:s,onChange:u,multiline:m,minRows:h,maxRows:c,layout:v="horizontal",variant:x="standard",disabled:p=!1,required:g=!1})=>{const j=()=>e.jsx(r.Field,{name:d,validate:s,children:({field:r,form:a})=>{const{errors:l,touched:s,isSubmitting:j}=a,f=l[r.name],q=!!f&&s[r.name],y=t({fieldError:f,showError:q,touched:!!s[r.name],value:r.value});return e.jsx(i,{label:"standard"===x?void 0:o,variant:x,value:r.value,"data-testid":`text-field-${d}`,autoComplete:"off",fullWidth:!0,multiline:!0,minRows:h??(m?3:void 0),maxRows:c??(m?10:void 0),style:{paddingRight:"horizontal"===v?16:0},placeholder:n||void 0,disabled:j||p,required:g,error:q,helperText:y,FormHelperTextProps:{children:" ",style:{textAlign:"right"}},inputProps:{style:{paddingTop:0,height:"1.1876em"}},onChange:e=>{a.setFieldValue(r.name,e.target.value),u&&u(e)}})}});return"vertical"===v?e.jsxs(e.Fragment,{children:["standard"===x&&e.jsx(l,{variant:"subtitle1",component:"h3",color:"textPrimary",children:o}),j()]}):e.jsx(a,{label:o,children:j()})};
2
2
  //# sourceMappingURL=GenericTextField.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenericTextField.cjs.js","sources":["../../../../src/components/ui/Form/GenericTextField.tsx"],"sourcesContent":["import { ChangeEvent } from 'react';\n\nimport { type FieldProps, Field } from 'formik';\nimport TextField, { TextFieldProps } from '@mui/material/TextField';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\nimport Typography from '@mui/material/Typography';\n\ntype Props = {\n label: string;\n fieldName: string;\n placeholder?: string;\n validation?: (value: string) => string | undefined;\n multiline?: boolean;\n minRows?: number;\n maxRows?: number;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n required?: boolean;\n};\n\nconst GenericTextField = ({\n label,\n fieldName,\n placeholder,\n validation,\n multiline,\n minRows,\n maxRows,\n layout = 'horizontal',\n variant = 'standard',\n disabled = false,\n required = false,\n}: Props) => {\n const renderField = () => {\n return (\n <Field name={fieldName} validate={validation}>\n {({ field, form }: FieldProps) => {\n const { errors, touched, isSubmitting } = form;\n const fieldError = errors[field.name] as string | undefined;\n const showError = !!fieldError && (touched[field.name] as boolean | undefined);\n const helperText = useRenderValidText({\n fieldError,\n showError,\n touched: !!touched[field.name],\n value: field.value,\n });\n\n return (\n <TextField\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n value={field.value}\n data-testid={`text-field-${fieldName}`}\n autoComplete=\"off\"\n fullWidth\n multiline\n minRows={minRows ?? (multiline ? 3 : undefined)}\n maxRows={maxRows ?? (multiline ? 10 : undefined)}\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\n disabled={isSubmitting || disabled}\n required={required}\n error={showError}\n helperText={helperText}\n FormHelperTextProps={{\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n }}\n inputProps={{\n style: {\n paddingTop: 0,\n height: '1.1876em',\n },\n }}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, e.target.value);\n }}\n />\n );\n }}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {variant === 'standard' && (\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {label}\n </Typography>\n )}\n {renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{renderField()}</FormItemLayout>;\n};\n\nexport default GenericTextField;\n"],"names":["label","fieldName","placeholder","validation","multiline","minRows","maxRows","layout","variant","disabled","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","jsx","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","FormHelperTextProps","textAlign","inputProps","paddingTop","height","onChange","e","setFieldValue","target","_jsxs","jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"6PAsByB,EACrBA,QACAC,YACAC,cACAC,aACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,MAEX,MAAMC,EAAc,IAEZC,MAACC,EAAAA,OAAMC,KAAMb,EAAWc,SAAUZ,EAAUa,SACvC,EAAGC,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBH,EACpCI,EAAaH,EAAOF,EAAMH,MAC1BS,IAAcD,GAAeF,EAAQH,EAAMH,MAC3CU,EAAaC,EAAmB,CAClCH,aACAC,YACAH,UAAWA,EAAQH,EAAMH,MACzBY,MAAOT,EAAMS,QAGjB,OACId,EAACe,IAAAC,EACG,CAAA5B,MAAmB,aAAZQ,OAAyBqB,EAAY7B,EAC5CQ,QAASA,EACTkB,MAAOT,EAAMS,MACA,cAAA,cAAczB,IAC3B6B,aAAa,MACbC,WAAS,EACT3B,WAAS,EACTC,QAASA,IAAYD,EAAY,OAAIyB,GACrCvB,QAASA,IAAYF,EAAY,QAAKyB,GACtCG,MAAO,CAAEC,aAAyB,eAAX1B,EAA0B,GAAK,GACtDL,YAAaA,QAA4B2B,EACzCpB,SAAUY,GAAgBZ,EAC1BC,SAAUA,EACVwB,MAAOX,EACPC,WAAYA,EACZW,oBAAqB,CACjBnB,SAAU,IACVgB,MAAO,CAAEI,UAAW,UAExBC,WAAY,CACRL,MAAO,CACHM,WAAY,EACZC,OAAQ,aAGhBC,SAAWC,IAEPvB,EAAKwB,cAAczB,EAAMH,KAAM2B,EAAEE,OAAOjB,MAAM,GAGxD,IAMlB,MAAe,aAAXnB,EAEIqC,EAAAC,KAAAC,WAAA,CAAA9B,SAAA,CACiB,aAAZR,GACGI,EAAAe,IAACoB,EAAU,CAACvC,QAAQ,YAAYwC,UAAU,KAAKC,MAAM,cAChDjC,SAAAhB,IAGRW,OAKNC,EAAAe,IAACuB,EAAc,CAAClD,MAAOA,EAAQgB,SAAAL,KAA+B"}
1
+ {"version":3,"file":"GenericTextField.cjs.js","sources":["../../../../src/components/ui/Form/GenericTextField.tsx"],"sourcesContent":["import { ChangeEvent } from 'react';\n\nimport { type FieldProps, Field } from 'formik';\nimport TextField, { TextFieldProps } from '@mui/material/TextField';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\nimport Typography from '@mui/material/Typography';\n\ntype Props = {\n label: string;\n fieldName: string;\n placeholder?: string;\n validation?: (value: string) => string | undefined;\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n multiline?: boolean;\n minRows?: number;\n maxRows?: number;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n required?: boolean;\n};\n\nconst GenericTextField = ({\n label,\n fieldName,\n placeholder,\n validation,\n onChange,\n multiline,\n minRows,\n maxRows,\n layout = 'horizontal',\n variant = 'standard',\n disabled = false,\n required = false,\n}: Props) => {\n const renderField = () => {\n return (\n <Field name={fieldName} validate={validation}>\n {({ field, form }: FieldProps) => {\n const { errors, touched, isSubmitting } = form;\n const fieldError = errors[field.name] as string | undefined;\n const showError = !!fieldError && (touched[field.name] as boolean | undefined);\n const helperText = useRenderValidText({\n fieldError,\n showError,\n touched: !!touched[field.name],\n value: field.value,\n });\n\n return (\n <TextField\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n value={field.value}\n data-testid={`text-field-${fieldName}`}\n autoComplete=\"off\"\n fullWidth\n multiline\n minRows={minRows ?? (multiline ? 3 : undefined)}\n maxRows={maxRows ?? (multiline ? 10 : undefined)}\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\n disabled={isSubmitting || disabled}\n required={required}\n error={showError}\n helperText={helperText}\n FormHelperTextProps={{\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n }}\n inputProps={{\n style: {\n paddingTop: 0,\n height: '1.1876em',\n },\n }}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, e.target.value);\n if (onChange) {\n onChange(e);\n }\n }}\n />\n );\n }}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {variant === 'standard' && (\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {label}\n </Typography>\n )}\n {renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{renderField()}</FormItemLayout>;\n};\n\nexport default GenericTextField;\n"],"names":["label","fieldName","placeholder","validation","onChange","multiline","minRows","maxRows","layout","variant","disabled","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","jsx","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","FormHelperTextProps","textAlign","inputProps","paddingTop","height","e","setFieldValue","target","_jsxs","jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"6PAuByB,EACrBA,QACAC,YACAC,cACAC,aACAC,WACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,MAEX,MAAMC,EAAc,IAEZC,MAACC,EAAAA,OAAMC,KAAMd,EAAWe,SAAUb,EAAUc,SACvC,EAAGC,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBH,EACpCI,EAAaH,EAAOF,EAAMH,MAC1BS,IAAcD,GAAeF,EAAQH,EAAMH,MAC3CU,EAAaC,EAAmB,CAClCH,aACAC,YACAH,UAAWA,EAAQH,EAAMH,MACzBY,MAAOT,EAAMS,QAGjB,OACId,EAACe,IAAAC,EACG,CAAA7B,MAAmB,aAAZS,OAAyBqB,EAAY9B,EAC5CS,QAASA,EACTkB,MAAOT,EAAMS,MACA,cAAA,cAAc1B,IAC3B8B,aAAa,MACbC,WAAS,EACT3B,WAAS,EACTC,QAASA,IAAYD,EAAY,OAAIyB,GACrCvB,QAASA,IAAYF,EAAY,QAAKyB,GACtCG,MAAO,CAAEC,aAAyB,eAAX1B,EAA0B,GAAK,GACtDN,YAAaA,QAA4B4B,EACzCpB,SAAUY,GAAgBZ,EAC1BC,SAAUA,EACVwB,MAAOX,EACPC,WAAYA,EACZW,oBAAqB,CACjBnB,SAAU,IACVgB,MAAO,CAAEI,UAAW,UAExBC,WAAY,CACRL,MAAO,CACHM,WAAY,EACZC,OAAQ,aAGhBpC,SAAWqC,IAEPtB,EAAKuB,cAAcxB,EAAMH,KAAM0B,EAAEE,OAAOhB,OACpCvB,GACAA,EAASqC,EACZ,GAGX,IAMlB,MAAe,aAAXjC,EAEIoC,EAAAC,KAAAC,WAAA,CAAA7B,SAAA,CACiB,aAAZR,GACGI,EAAAe,IAACmB,EAAU,CAACtC,QAAQ,YAAYuC,UAAU,KAAKC,MAAM,cAChDhC,SAAAjB,IAGRY,OAKNC,EAAAe,IAACsB,EAAc,CAAClD,MAAOA,EAAQiB,SAAAL,KAA+B"}
@@ -1,4 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ChangeEvent } from 'react';
2
3
  import { TextFieldProps } from '@mui/material/TextField';
3
4
 
4
5
  type Props = {
@@ -6,6 +7,7 @@ type Props = {
6
7
  fieldName: string;
7
8
  placeholder?: string;
8
9
  validation?: (value: string) => string | undefined;
10
+ onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
9
11
  multiline?: boolean;
10
12
  minRows?: number;
11
13
  maxRows?: number;
@@ -14,6 +16,6 @@ type Props = {
14
16
  disabled?: boolean;
15
17
  required?: boolean;
16
18
  };
17
- declare const GenericTextField: ({ label, fieldName, placeholder, validation, multiline, minRows, maxRows, layout, variant, disabled, required, }: Props) => react_jsx_runtime.JSX.Element;
19
+ declare const GenericTextField: ({ label, fieldName, placeholder, validation, onChange, multiline, minRows, maxRows, layout, variant, disabled, required, }: Props) => react_jsx_runtime.JSX.Element;
18
20
 
19
21
  export { GenericTextField as default };
@@ -1,2 +1,2 @@
1
- import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{Field as i}from"formik";import a from"@mui/material/TextField";import o from"../../custom-hooks/useRenderValidText.js";import l from"./FormItemLayout.js";import d from"@mui/material/Typography";const m=({label:m,fieldName:n,placeholder:s,validation:u,multiline:h,minRows:p,maxRows:c,layout:f="horizontal",variant:v="standard",disabled:x=!1,required:g=!1})=>{const y=()=>t(i,{name:n,validate:u,children:({field:e,form:r})=>{const{errors:i,touched:l,isSubmitting:d}=r,u=i[e.name],y=!!u&&l[e.name],b=o({fieldError:u,showError:y,touched:!!l[e.name],value:e.value});return t(a,{label:"standard"===v?void 0:m,variant:v,value:e.value,"data-testid":`text-field-${n}`,autoComplete:"off",fullWidth:!0,multiline:!0,minRows:p??(h?3:void 0),maxRows:c??(h?10:void 0),style:{paddingRight:"horizontal"===f?16:0},placeholder:s||void 0,disabled:d||x,required:g,error:y,helperText:b,FormHelperTextProps:{children:" ",style:{textAlign:"right"}},inputProps:{style:{paddingTop:0,height:"1.1876em"}},onChange:t=>{r.setFieldValue(e.name,t.target.value)}})}});return"vertical"===f?e(r,{children:["standard"===v&&t(d,{variant:"subtitle1",component:"h3",color:"textPrimary",children:m}),y()]}):t(l,{label:m,children:y()})};export{m as default};
1
+ import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{Field as i}from"formik";import a from"@mui/material/TextField";import o from"../../custom-hooks/useRenderValidText.js";import l from"./FormItemLayout.js";import d from"@mui/material/Typography";const n=({label:n,fieldName:m,placeholder:s,validation:u,onChange:h,multiline:p,minRows:c,maxRows:f,layout:v="horizontal",variant:g="standard",disabled:x=!1,required:y=!1})=>{const b=()=>t(i,{name:m,validate:u,children:({field:e,form:r})=>{const{errors:i,touched:l,isSubmitting:d}=r,u=i[e.name],b=!!u&&l[e.name],R=o({fieldError:u,showError:b,touched:!!l[e.name],value:e.value});return t(a,{label:"standard"===g?void 0:n,variant:g,value:e.value,"data-testid":`text-field-${m}`,autoComplete:"off",fullWidth:!0,multiline:!0,minRows:c??(p?3:void 0),maxRows:f??(p?10:void 0),style:{paddingRight:"horizontal"===v?16:0},placeholder:s||void 0,disabled:d||x,required:y,error:b,helperText:R,FormHelperTextProps:{children:" ",style:{textAlign:"right"}},inputProps:{style:{paddingTop:0,height:"1.1876em"}},onChange:t=>{r.setFieldValue(e.name,t.target.value),h&&h(t)}})}});return"vertical"===v?e(r,{children:["standard"===g&&t(d,{variant:"subtitle1",component:"h3",color:"textPrimary",children:n}),b()]}):t(l,{label:n,children:b()})};export{n as default};
2
2
  //# sourceMappingURL=GenericTextField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenericTextField.js","sources":["../../../../src/components/ui/Form/GenericTextField.tsx"],"sourcesContent":["import { ChangeEvent } from 'react';\n\nimport { type FieldProps, Field } from 'formik';\nimport TextField, { TextFieldProps } from '@mui/material/TextField';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\nimport Typography from '@mui/material/Typography';\n\ntype Props = {\n label: string;\n fieldName: string;\n placeholder?: string;\n validation?: (value: string) => string | undefined;\n multiline?: boolean;\n minRows?: number;\n maxRows?: number;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n required?: boolean;\n};\n\nconst GenericTextField = ({\n label,\n fieldName,\n placeholder,\n validation,\n multiline,\n minRows,\n maxRows,\n layout = 'horizontal',\n variant = 'standard',\n disabled = false,\n required = false,\n}: Props) => {\n const renderField = () => {\n return (\n <Field name={fieldName} validate={validation}>\n {({ field, form }: FieldProps) => {\n const { errors, touched, isSubmitting } = form;\n const fieldError = errors[field.name] as string | undefined;\n const showError = !!fieldError && (touched[field.name] as boolean | undefined);\n const helperText = useRenderValidText({\n fieldError,\n showError,\n touched: !!touched[field.name],\n value: field.value,\n });\n\n return (\n <TextField\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n value={field.value}\n data-testid={`text-field-${fieldName}`}\n autoComplete=\"off\"\n fullWidth\n multiline\n minRows={minRows ?? (multiline ? 3 : undefined)}\n maxRows={maxRows ?? (multiline ? 10 : undefined)}\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\n disabled={isSubmitting || disabled}\n required={required}\n error={showError}\n helperText={helperText}\n FormHelperTextProps={{\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n }}\n inputProps={{\n style: {\n paddingTop: 0,\n height: '1.1876em',\n },\n }}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, e.target.value);\n }}\n />\n );\n }}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {variant === 'standard' && (\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {label}\n </Typography>\n )}\n {renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{renderField()}</FormItemLayout>;\n};\n\nexport default GenericTextField;\n"],"names":["GenericTextField","label","fieldName","placeholder","validation","multiline","minRows","maxRows","layout","variant","disabled","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","FormHelperTextProps","textAlign","inputProps","paddingTop","height","onChange","e","setFieldValue","target","_jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"yQAsBA,MAAMA,EAAmB,EACrBC,QACAC,YACAC,cACAC,aACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,MAEX,MAAMC,EAAc,IAEZC,EAACC,GAAMC,KAAMb,EAAWc,SAAUZ,EAAUa,SACvC,EAAGC,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBH,EACpCI,EAAaH,EAAOF,EAAMH,MAC1BS,IAAcD,GAAeF,EAAQH,EAAMH,MAC3CU,EAAaC,EAAmB,CAClCH,aACAC,YACAH,UAAWA,EAAQH,EAAMH,MACzBY,MAAOT,EAAMS,QAGjB,OACId,EAACe,EACG,CAAA3B,MAAmB,aAAZQ,OAAyBoB,EAAY5B,EAC5CQ,QAASA,EACTkB,MAAOT,EAAMS,MACA,cAAA,cAAczB,IAC3B4B,aAAa,MACbC,WAAS,EACT1B,WAAS,EACTC,QAASA,IAAYD,EAAY,OAAIwB,GACrCtB,QAASA,IAAYF,EAAY,QAAKwB,GACtCG,MAAO,CAAEC,aAAyB,eAAXzB,EAA0B,GAAK,GACtDL,YAAaA,QAA4B0B,EACzCnB,SAAUY,GAAgBZ,EAC1BC,SAAUA,EACVuB,MAAOV,EACPC,WAAYA,EACZU,oBAAqB,CACjBlB,SAAU,IACVe,MAAO,CAAEI,UAAW,UAExBC,WAAY,CACRL,MAAO,CACHM,WAAY,EACZC,OAAQ,aAGhBC,SAAWC,IAEPtB,EAAKuB,cAAcxB,EAAMH,KAAM0B,EAAEE,OAAOhB,MAAM,GAGxD,IAMlB,MAAe,aAAXnB,EAEIoC,EAAAC,EAAA,CAAA5B,SAAA,CACiB,aAAZR,GACGI,EAACiC,EAAU,CAACrC,QAAQ,YAAYsC,UAAU,KAAKC,MAAM,cAChD/B,SAAAhB,IAGRW,OAKNC,EAACoC,EAAc,CAAChD,MAAOA,EAAQgB,SAAAL,KAA+B"}
1
+ {"version":3,"file":"GenericTextField.js","sources":["../../../../src/components/ui/Form/GenericTextField.tsx"],"sourcesContent":["import { ChangeEvent } from 'react';\n\nimport { type FieldProps, Field } from 'formik';\nimport TextField, { TextFieldProps } from '@mui/material/TextField';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\nimport Typography from '@mui/material/Typography';\n\ntype Props = {\n label: string;\n fieldName: string;\n placeholder?: string;\n validation?: (value: string) => string | undefined;\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n multiline?: boolean;\n minRows?: number;\n maxRows?: number;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n required?: boolean;\n};\n\nconst GenericTextField = ({\n label,\n fieldName,\n placeholder,\n validation,\n onChange,\n multiline,\n minRows,\n maxRows,\n layout = 'horizontal',\n variant = 'standard',\n disabled = false,\n required = false,\n}: Props) => {\n const renderField = () => {\n return (\n <Field name={fieldName} validate={validation}>\n {({ field, form }: FieldProps) => {\n const { errors, touched, isSubmitting } = form;\n const fieldError = errors[field.name] as string | undefined;\n const showError = !!fieldError && (touched[field.name] as boolean | undefined);\n const helperText = useRenderValidText({\n fieldError,\n showError,\n touched: !!touched[field.name],\n value: field.value,\n });\n\n return (\n <TextField\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n value={field.value}\n data-testid={`text-field-${fieldName}`}\n autoComplete=\"off\"\n fullWidth\n multiline\n minRows={minRows ?? (multiline ? 3 : undefined)}\n maxRows={maxRows ?? (multiline ? 10 : undefined)}\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\n disabled={isSubmitting || disabled}\n required={required}\n error={showError}\n helperText={helperText}\n FormHelperTextProps={{\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n }}\n inputProps={{\n style: {\n paddingTop: 0,\n height: '1.1876em',\n },\n }}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, e.target.value);\n if (onChange) {\n onChange(e);\n }\n }}\n />\n );\n }}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {variant === 'standard' && (\n <Typography variant=\"subtitle1\" component=\"h3\" color=\"textPrimary\">\n {label}\n </Typography>\n )}\n {renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{renderField()}</FormItemLayout>;\n};\n\nexport default GenericTextField;\n"],"names":["GenericTextField","label","fieldName","placeholder","validation","onChange","multiline","minRows","maxRows","layout","variant","disabled","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","FormHelperTextProps","textAlign","inputProps","paddingTop","height","e","setFieldValue","target","_jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"yQAuBA,MAAMA,EAAmB,EACrBC,QACAC,YACAC,cACAC,aACAC,WACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,MAEX,MAAMC,EAAc,IAEZC,EAACC,GAAMC,KAAMd,EAAWe,SAAUb,EAAUc,SACvC,EAAGC,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBH,EACpCI,EAAaH,EAAOF,EAAMH,MAC1BS,IAAcD,GAAeF,EAAQH,EAAMH,MAC3CU,EAAaC,EAAmB,CAClCH,aACAC,YACAH,UAAWA,EAAQH,EAAMH,MACzBY,MAAOT,EAAMS,QAGjB,OACId,EAACe,EACG,CAAA5B,MAAmB,aAAZS,OAAyBoB,EAAY7B,EAC5CS,QAASA,EACTkB,MAAOT,EAAMS,MACA,cAAA,cAAc1B,IAC3B6B,aAAa,MACbC,WAAS,EACT1B,WAAS,EACTC,QAASA,IAAYD,EAAY,OAAIwB,GACrCtB,QAASA,IAAYF,EAAY,QAAKwB,GACtCG,MAAO,CAAEC,aAAyB,eAAXzB,EAA0B,GAAK,GACtDN,YAAaA,QAA4B2B,EACzCnB,SAAUY,GAAgBZ,EAC1BC,SAAUA,EACVuB,MAAOV,EACPC,WAAYA,EACZU,oBAAqB,CACjBlB,SAAU,IACVe,MAAO,CAAEI,UAAW,UAExBC,WAAY,CACRL,MAAO,CACHM,WAAY,EACZC,OAAQ,aAGhBnC,SAAWoC,IAEPrB,EAAKsB,cAAcvB,EAAMH,KAAMyB,EAAEE,OAAOf,OACpCvB,GACAA,EAASoC,EACZ,GAGX,IAMlB,MAAe,aAAXhC,EAEImC,EAAAC,EAAA,CAAA3B,SAAA,CACiB,aAAZR,GACGI,EAACgC,EAAU,CAACpC,QAAQ,YAAYqC,UAAU,KAAKC,MAAM,cAChD9B,SAAAjB,IAGRY,OAKNC,EAACmC,EAAc,CAAChD,MAAOA,EAAQiB,SAAAL,KAA+B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/portal-library",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "files": [
5
5
  "dist"
6
6
  ],