@flipdish/portal-library 1.0.39 → 1.0.41

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("@mui/material"),t=require("formik"),i=require("../../custom-hooks/useRenderValidText.cjs.js"),l=require("./FormItemLayout.cjs.js");module.exports=({label:a,fieldName:o,options:d,placeholder:n,getOptionLabel:s,validation:u,onChange:h,layout:c="horizontal",variant:m="outlined",disabled:p=!1,required:x=!1})=>{const g=()=>e.jsx(t.Field,{name:o,validate:u,children:({field:t,form:l})=>{const{errors:u,touched:g,isSubmitting:j}=l,v=u[t.name],b=!!v&&g[t.name],f=i({fieldError:v,showError:b,touched:!!g[t.name],value:t.value});return e.jsx(r.Autocomplete,{options:d,getOptionLabel:s||(e=>e),onChange:(e,r)=>{l.setFieldValue(o,r),h&&h(e,r)},disabled:j||p,fullWidth:!0,loading:!0,renderInput:t=>e.jsx(r.TextField,{...t,label:"standard"===m?void 0:a,variant:m,"data-testid":`text-field-${o}`,fullWidth:!0,style:{paddingRight:"horizontal"===c?16:0},placeholder:n||void 0,required:x,error:b,helperText:f,FormHelperTextProps:{children:" ",style:{textAlign:"right"}}})})}});return"vertical"===c?e.jsxs(e.Fragment,{children:["standard"===m&&e.jsx(r.Typography,{variant:"subtitle1",component:"h3",color:"textPrimary",children:a}),g()]}):e.jsx(l,{label:a,children:g()})};
1
+ "use strict";var e=require("react/jsx-runtime"),r=require("@mui/material"),t=require("formik"),o=require("../../custom-hooks/useRenderValidText.cjs.js"),i=require("./FormItemLayout.cjs.js");module.exports=({label:l,fieldName:n,options:a,placeholder:d,getOptionLabel:s,validation:u,onChange:p,onInputChange:h,isOptionEqualToValue:c,onScroll:m,layout:x="horizontal",variant:g="outlined",disabled:j=!1,loading:v=!1,required:b=!1})=>{const q=()=>e.jsx(t.Field,{name:n,validate:u,children:({field:t,form:i})=>{const{errors:u,touched:q,isSubmitting:f}=i,y=u[t.name],F=!!y&&q[t.name],I=o({fieldError:y,showError:F,touched:!!q[t.name],value:t.value});return e.jsx(r.Autocomplete,{options:a,getOptionLabel:s,isOptionEqualToValue:c,onChange:(e,r)=>{i.setFieldValue(n,r),p&&p(e,r)},onInputChange:h,disabled:f||j,fullWidth:!0,loading:v,renderInput:t=>e.jsx(r.TextField,{...t,label:"standard"===g?void 0:l,variant:g,"data-testid":`text-field-${n}`,fullWidth:!0,style:{paddingRight:"horizontal"===x?16:0},placeholder:d||void 0,required:b,error:F,helperText:I,FormHelperTextProps:{children:" ",style:{textAlign:"right"}},InputProps:{...t.InputProps,endAdornment:e.jsxs(e.Fragment,{children:[v&&e.jsx(r.CircularProgress,{color:"inherit",size:25}),t.InputProps.endAdornment]})}}),ListboxProps:{onScroll:m}})}});return"vertical"===x?e.jsxs(e.Fragment,{children:["standard"===g&&e.jsx(r.Typography,{variant:"subtitle1",component:"h3",color:"textPrimary",children:l}),q()]}):e.jsx(i,{label:l,children:q()})};
2
2
  //# sourceMappingURL=GenericAutocompleteField.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenericAutocompleteField.cjs.js","sources":["../../../../src/components/ui/Form/GenericAutocompleteField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { TextFieldProps, Autocomplete, TextField, Typography } from '@mui/material';\nimport { Field, FieldProps } from 'formik';\nimport { SyntheticEvent } from 'react';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\n\ntype Props = {\n label: string;\n fieldName: string;\n options: any[];\n placeholder?: string;\n getOptionLabel?: (option: any) => string;\n validation?: (value: string) => string | undefined;\n onChange?: (e: SyntheticEvent, value: any) => void;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n required?: boolean;\n};\n\nconst GenericAutocompleteField = ({\n label,\n fieldName,\n options,\n placeholder,\n getOptionLabel,\n validation,\n onChange,\n layout = 'horizontal',\n variant = 'outlined',\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 <Autocomplete\n options={options}\n getOptionLabel={getOptionLabel ? getOptionLabel : (option) => option}\n onChange={(e: SyntheticEvent, value: any) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(fieldName, value);\n if (onChange) {\n onChange(e, value);\n }\n }}\n disabled={isSubmitting || disabled}\n fullWidth\n loading\n renderInput={(params) => (\n <TextField\n {...params}\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n data-testid={`text-field-${fieldName}`}\n fullWidth\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\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 />\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 GenericAutocompleteField;\n"],"names":["label","fieldName","options","placeholder","getOptionLabel","validation","onChange","layout","variant","disabled","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","jsx","Autocomplete","option","e","setFieldValue","fullWidth","loading","renderInput","params","TextField","undefined","style","paddingRight","error","FormHelperTextProps","textAlign","_jsxs","jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"6MAqBiC,EAC7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["../../../../src/components/ui/Form/GenericAutocompleteField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { TextFieldProps, Autocomplete, TextField, Typography, CircularProgress } from '@mui/material';\nimport { Field, FieldProps } from 'formik';\nimport { SyntheticEvent } from 'react';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\n\ntype Props = {\n label: string;\n fieldName: string;\n options: any[];\n placeholder?: string;\n getOptionLabel?: (option: any) => string;\n validation?: (value: string) => string | undefined;\n onChange?: (e: SyntheticEvent, value: any) => void;\n onInputChange?: (e: SyntheticEvent, value: any) => void;\n isOptionEqualToValue?: (option: any, value: any) => boolean;\n onScroll?: (e: React.UIEvent<HTMLUListElement, UIEvent>) => void;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n loading?: boolean;\n required?: boolean;\n};\n\nconst GenericAutocompleteField = ({\n label,\n fieldName,\n options,\n placeholder,\n getOptionLabel,\n validation,\n onChange,\n onInputChange,\n isOptionEqualToValue,\n onScroll,\n layout = 'horizontal',\n variant = 'outlined',\n disabled = false,\n loading = 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 <Autocomplete\n options={options}\n getOptionLabel={getOptionLabel}\n isOptionEqualToValue={isOptionEqualToValue}\n onChange={(e: SyntheticEvent, value: any) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(fieldName, value);\n if (onChange) {\n onChange(e, value);\n }\n }}\n onInputChange={onInputChange}\n disabled={isSubmitting || disabled}\n fullWidth\n loading={loading}\n renderInput={(params) => (\n <TextField\n {...params}\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n data-testid={`text-field-${fieldName}`}\n fullWidth\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\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 ...params.InputProps,\n endAdornment: (\n <>\n {loading && <CircularProgress color=\"inherit\" size={25} />}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n )}\n ListboxProps={{\n onScroll,\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 GenericAutocompleteField;\n"],"names":["label","fieldName","options","placeholder","getOptionLabel","validation","onChange","onInputChange","isOptionEqualToValue","onScroll","layout","variant","disabled","loading","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","Autocomplete","e","setFieldValue","fullWidth","renderInput","params","TextField","undefined","style","paddingRight","error","FormHelperTextProps","textAlign","InputProps","endAdornment","_jsxs","jsxs","_Fragment","jsx","CircularProgress","color","size","ListboxProps","Typography","component","FormItemLayout"],"mappings":"6MAyBiC,EAC7BA,QACAC,YACAC,UACAC,cACAC,iBACAC,aACAC,WACAC,gBACAC,uBACAC,WACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,WAAU,EACVC,YAAW,MAEX,MAAMC,EAAc,IAEZC,MAACC,EAAAA,OAAMC,KAAMjB,EAAWkB,SAAUd,EAAUe,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,MAACe,EAAYA,aAAA,CACT7B,QAASA,EACTE,eAAgBA,EAChBI,qBAAsBA,EACtBF,SAAU,CAAC0B,EAAmBF,KAE1BR,EAAKW,cAAchC,EAAW6B,GAC1BxB,GACAA,EAAS0B,EAAGF,EACf,EAELvB,cAAeA,EACfK,SAAUa,GAAgBb,EAC1BsB,WAAS,EACTrB,QAASA,EACTsB,YAAcC,GACVpB,EAAAA,IAACqB,EAASA,UACF,IAAAD,EACJpC,MAAmB,aAAZW,OAAyB2B,EAAYtC,EAC5CW,QAASA,EAAO,cACH,cAAcV,IAC3BiC,WAAS,EACTK,MAAO,CAAEC,aAAyB,eAAX9B,EAA0B,GAAK,GACtDP,YAAaA,QAA4BmC,EACzCxB,SAAUA,EACV2B,MAAOd,EACPC,WAAYA,EACZc,oBAAqB,CACjBtB,SAAU,IACVmB,MAAO,CAAEI,UAAW,UAExBC,WAAY,IACLR,EAAOQ,WACVC,aACIC,EACKC,KAAAC,WAAA,CAAA5B,SAAA,CAAAP,GAAWG,EAACiC,IAAAC,mBAAiB,CAAAC,MAAM,UAAUC,KAAM,KACnDhB,EAAOQ,WAAWC,mBAMvCQ,aAAc,CACV5C,aAGV,IAMlB,MAAe,aAAXC,EAEIoC,EAAAC,KAAAC,WAAA,CAAA5B,SAAA,CACiB,aAAZT,GACGK,EAAAiC,IAACK,aAAU,CAAC3C,QAAQ,YAAY4C,UAAU,KAAKJ,MAAM,cAChD/B,SAAApB,IAGRe,OAKNC,EAAAiC,IAACO,EAAc,CAACxD,MAAOA,EAAQoB,SAAAL,KAA+B"}
@@ -10,11 +10,15 @@ type Props = {
10
10
  getOptionLabel?: (option: any) => string;
11
11
  validation?: (value: string) => string | undefined;
12
12
  onChange?: (e: SyntheticEvent, value: any) => void;
13
+ onInputChange?: (e: SyntheticEvent, value: any) => void;
14
+ isOptionEqualToValue?: (option: any, value: any) => boolean;
15
+ onScroll?: (e: React.UIEvent<HTMLUListElement, UIEvent>) => void;
13
16
  layout?: 'horizontal' | 'vertical';
14
17
  variant?: TextFieldProps['variant'];
15
18
  disabled?: boolean;
19
+ loading?: boolean;
16
20
  required?: boolean;
17
21
  };
18
- declare const GenericAutocompleteField: ({ label, fieldName, options, placeholder, getOptionLabel, validation, onChange, layout, variant, disabled, required, }: Props) => react_jsx_runtime.JSX.Element;
22
+ declare const GenericAutocompleteField: ({ label, fieldName, options, placeholder, getOptionLabel, validation, onChange, onInputChange, isOptionEqualToValue, onScroll, layout, variant, disabled, loading, required, }: Props) => react_jsx_runtime.JSX.Element;
19
23
 
20
24
  export { GenericAutocompleteField as default };
@@ -1,2 +1,2 @@
1
- import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{Typography as o,Autocomplete as i,TextField as a}from"@mui/material";import{Field as l}from"formik";import n from"../../custom-hooks/useRenderValidText.js";import d from"./FormItemLayout.js";const m=({label:m,fieldName:s,options:u,placeholder:h,getOptionLabel:p,validation:c,onChange:f,layout:g="horizontal",variant:v="outlined",disabled:b=!1,required:x=!1})=>{const y=()=>t(l,{name:s,validate:c,children:({field:e,form:r})=>{const{errors:o,touched:l,isSubmitting:d}=r,c=o[e.name],y=!!c&&l[e.name],j=n({fieldError:c,showError:y,touched:!!l[e.name],value:e.value});return t(i,{options:u,getOptionLabel:p||(e=>e),onChange:(e,t)=>{r.setFieldValue(s,t),f&&f(e,t)},disabled:d||b,fullWidth:!0,loading:!0,renderInput:e=>t(a,{...e,label:"standard"===v?void 0:m,variant:v,"data-testid":`text-field-${s}`,fullWidth:!0,style:{paddingRight:"horizontal"===g?16:0},placeholder:h||void 0,required:x,error:y,helperText:j,FormHelperTextProps:{children:" ",style:{textAlign:"right"}}})})}});return"vertical"===g?e(r,{children:["standard"===v&&t(o,{variant:"subtitle1",component:"h3",color:"textPrimary",children:m}),y()]}):t(d,{label:m,children:y()})};export{m as default};
1
+ import{jsxs as e,Fragment as o,jsx as r}from"react/jsx-runtime";import{Typography as t,Autocomplete as i,TextField as n,CircularProgress as l}from"@mui/material";import{Field as a}from"formik";import d from"../../custom-hooks/useRenderValidText.js";import s from"./FormItemLayout.js";const u=({label:u,fieldName:m,options:p,placeholder:h,getOptionLabel:c,validation:f,onChange:g,onInputChange:b,isOptionEqualToValue:v,onScroll:x,layout:I="horizontal",variant:P="outlined",disabled:y=!1,loading:T=!1,required:q=!1})=>{const C=()=>r(a,{name:m,validate:f,children:({field:t,form:a})=>{const{errors:s,touched:f,isSubmitting:C}=a,E=s[t.name],L=!!E&&f[t.name],O=d({fieldError:E,showError:L,touched:!!f[t.name],value:t.value});return r(i,{options:p,getOptionLabel:c,isOptionEqualToValue:v,onChange:(e,o)=>{a.setFieldValue(m,o),g&&g(e,o)},onInputChange:b,disabled:C||y,fullWidth:!0,loading:T,renderInput:t=>r(n,{...t,label:"standard"===P?void 0:u,variant:P,"data-testid":`text-field-${m}`,fullWidth:!0,style:{paddingRight:"horizontal"===I?16:0},placeholder:h||void 0,required:q,error:L,helperText:O,FormHelperTextProps:{children:" ",style:{textAlign:"right"}},InputProps:{...t.InputProps,endAdornment:e(o,{children:[T&&r(l,{color:"inherit",size:25}),t.InputProps.endAdornment]})}}),ListboxProps:{onScroll:x}})}});return"vertical"===I?e(o,{children:["standard"===P&&r(t,{variant:"subtitle1",component:"h3",color:"textPrimary",children:u}),C()]}):r(s,{label:u,children:C()})};export{u as default};
2
2
  //# sourceMappingURL=GenericAutocompleteField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GenericAutocompleteField.js","sources":["../../../../src/components/ui/Form/GenericAutocompleteField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { TextFieldProps, Autocomplete, TextField, Typography } from '@mui/material';\nimport { Field, FieldProps } from 'formik';\nimport { SyntheticEvent } from 'react';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\n\ntype Props = {\n label: string;\n fieldName: string;\n options: any[];\n placeholder?: string;\n getOptionLabel?: (option: any) => string;\n validation?: (value: string) => string | undefined;\n onChange?: (e: SyntheticEvent, value: any) => void;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n required?: boolean;\n};\n\nconst GenericAutocompleteField = ({\n label,\n fieldName,\n options,\n placeholder,\n getOptionLabel,\n validation,\n onChange,\n layout = 'horizontal',\n variant = 'outlined',\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 <Autocomplete\n options={options}\n getOptionLabel={getOptionLabel ? getOptionLabel : (option) => option}\n onChange={(e: SyntheticEvent, value: any) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(fieldName, value);\n if (onChange) {\n onChange(e, value);\n }\n }}\n disabled={isSubmitting || disabled}\n fullWidth\n loading\n renderInput={(params) => (\n <TextField\n {...params}\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n data-testid={`text-field-${fieldName}`}\n fullWidth\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\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 />\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 GenericAutocompleteField;\n"],"names":["GenericAutocompleteField","label","fieldName","options","placeholder","getOptionLabel","validation","onChange","layout","variant","disabled","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","Autocomplete","option","e","setFieldValue","fullWidth","loading","renderInput","params","TextField","undefined","style","paddingRight","error","FormHelperTextProps","textAlign","_jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"sQAqBA,MAAMA,EAA2B,EAC7BC,QACAC,YACAC,UACAC,cACAC,iBACAC,aACAC,WACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,MAEX,MAAMC,EAAc,IAEZC,EAACC,GAAMC,KAAMb,EAAWc,SAAUV,EAAUW,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,EAAY,CACTzB,QAASA,EACTE,eAAgBA,GAAkC,CAACwB,GAAWA,GAC9DtB,SAAU,CAACuB,EAAmBH,KAE1BR,EAAKY,cAAc7B,EAAWyB,GAC1BpB,GACAA,EAASuB,EAAGH,EACf,EAELjB,SAAUY,GAAgBZ,EAC1BsB,WAAS,EACTC,SACA,EAAAC,YAAcC,GACVtB,EAACuB,MACOD,EACJlC,MAAmB,aAAZQ,OAAyB4B,EAAYpC,EAC5CQ,QAASA,EAAO,cACH,cAAcP,IAC3B8B,WAAS,EACTM,MAAO,CAAEC,aAAyB,eAAX/B,EAA0B,GAAK,GACtDJ,YAAaA,QAA4BiC,EACzC1B,SAAUA,EACV6B,MAAOhB,EACPC,WAAYA,EACZgB,oBAAqB,CACjBxB,SAAU,IACVqB,MAAO,CAAEI,UAAW,aAKtC,IAMlB,MAAe,aAAXlC,EAEImC,EAAAC,EAAA,CAAA3B,SAAA,CACiB,aAAZR,GACGI,EAACgC,EAAU,CAACpC,QAAQ,YAAYqC,UAAU,KAAKC,MAAM,cAChD9B,SAAAhB,IAGRW,OAKNC,EAACmC,EAAc,CAAC/C,MAAOA,EAAQgB,SAAAL,KAA+B"}
1
+ {"version":3,"file":"GenericAutocompleteField.js","sources":["../../../../src/components/ui/Form/GenericAutocompleteField.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { TextFieldProps, Autocomplete, TextField, Typography, CircularProgress } from '@mui/material';\nimport { Field, FieldProps } from 'formik';\nimport { SyntheticEvent } from 'react';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport FormItemLayout from './FormItemLayout';\n\ntype Props = {\n label: string;\n fieldName: string;\n options: any[];\n placeholder?: string;\n getOptionLabel?: (option: any) => string;\n validation?: (value: string) => string | undefined;\n onChange?: (e: SyntheticEvent, value: any) => void;\n onInputChange?: (e: SyntheticEvent, value: any) => void;\n isOptionEqualToValue?: (option: any, value: any) => boolean;\n onScroll?: (e: React.UIEvent<HTMLUListElement, UIEvent>) => void;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldProps['variant'];\n disabled?: boolean;\n loading?: boolean;\n required?: boolean;\n};\n\nconst GenericAutocompleteField = ({\n label,\n fieldName,\n options,\n placeholder,\n getOptionLabel,\n validation,\n onChange,\n onInputChange,\n isOptionEqualToValue,\n onScroll,\n layout = 'horizontal',\n variant = 'outlined',\n disabled = false,\n loading = 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 <Autocomplete\n options={options}\n getOptionLabel={getOptionLabel}\n isOptionEqualToValue={isOptionEqualToValue}\n onChange={(e: SyntheticEvent, value: any) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(fieldName, value);\n if (onChange) {\n onChange(e, value);\n }\n }}\n onInputChange={onInputChange}\n disabled={isSubmitting || disabled}\n fullWidth\n loading={loading}\n renderInput={(params) => (\n <TextField\n {...params}\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n data-testid={`text-field-${fieldName}`}\n fullWidth\n style={{ paddingRight: layout === 'horizontal' ? 16 : 0 }}\n placeholder={placeholder ? placeholder : undefined}\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 ...params.InputProps,\n endAdornment: (\n <>\n {loading && <CircularProgress color=\"inherit\" size={25} />}\n {params.InputProps.endAdornment}\n </>\n ),\n }}\n />\n )}\n ListboxProps={{\n onScroll,\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 GenericAutocompleteField;\n"],"names":["GenericAutocompleteField","label","fieldName","options","placeholder","getOptionLabel","validation","onChange","onInputChange","isOptionEqualToValue","onScroll","layout","variant","disabled","loading","required","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","Autocomplete","e","setFieldValue","fullWidth","renderInput","params","TextField","undefined","style","paddingRight","error","FormHelperTextProps","textAlign","InputProps","endAdornment","_jsxs","_Fragment","CircularProgress","color","size","ListboxProps","Typography","component","FormItemLayout"],"mappings":"4RAyBM,MAAAA,EAA2B,EAC7BC,QACAC,YACAC,UACAC,cACAC,iBACAC,aACAC,WACAC,gBACAC,uBACAC,WAC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AAc,CAACtD,MAAOA,EAAQoB,SAAAL,KAA+B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flipdish/portal-library",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "files": [
5
5
  "dist"
6
6
  ],