@flipdish/portal-library 1.0.56 → 1.0.58
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.
- package/dist/components/genericUtilities/index.cjs.js +2 -0
- package/dist/components/genericUtilities/index.cjs.js.map +1 -0
- package/dist/components/genericUtilities/index.d.ts +11 -0
- package/dist/components/genericUtilities/index.js +2 -0
- package/dist/components/genericUtilities/index.js.map +1 -0
- package/dist/components/index.cjs.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/ui/Form/GenericTextField.cjs.js +1 -1
- package/dist/components/ui/Form/GenericTextField.cjs.js.map +1 -1
- package/dist/components/ui/Form/GenericTextField.d.ts +3 -2
- package/dist/components/ui/Form/GenericTextField.js +1 -1
- package/dist/components/ui/Form/GenericTextField.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../../../src/components/genericUtilities/index.ts"],"sourcesContent":["import lodashDebounce from 'lodash.debounce';\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `waitMs` milliseconds\n * have elapsed since the last time the debounced function was invoked.\n *\n * @param func - The function to debounce\n * @param waitMs - The number of milliseconds to delay\n * @returns A debounced version of the provided function\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const debounce = (func: (...args: any[]) => void, waitMs: number) => lodashDebounce(func, waitMs);\n"],"names":["func","waitMs","lodashDebounce"],"mappings":"+DAWwB,CAACA,EAAgCC,IAAmBC,EAAeF,EAAMC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays invoking the provided function until after `waitMs` milliseconds
|
|
3
|
+
* have elapsed since the last time the debounced function was invoked.
|
|
4
|
+
*
|
|
5
|
+
* @param func - The function to debounce
|
|
6
|
+
* @param waitMs - The number of milliseconds to delay
|
|
7
|
+
* @returns A debounced version of the provided function
|
|
8
|
+
*/
|
|
9
|
+
declare const debounce: (func: (...args: any[]) => void, waitMs: number) => any;
|
|
10
|
+
|
|
11
|
+
export { debounce };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/genericUtilities/index.ts"],"sourcesContent":["import lodashDebounce from 'lodash.debounce';\n\n/**\n * Creates a debounced function that delays invoking the provided function until after `waitMs` milliseconds\n * have elapsed since the last time the debounced function was invoked.\n *\n * @param func - The function to debounce\n * @param waitMs - The number of milliseconds to delay\n * @returns A debounced version of the provided function\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const debounce = (func: (...args: any[]) => void, waitMs: number) => lodashDebounce(func, waitMs);\n"],"names":["debounce","func","waitMs","lodashDebounce"],"mappings":"+BAWa,MAAAA,EAAW,CAACC,EAAgCC,IAAmBC,EAAeF,EAAMC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),
|
|
1
|
+
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),i=require("./ui/NotFoundPage/NotFoundPage.cjs.js"),r=require("./ui/FlipdishStaffContainer/FlipdishStaffContainer.cjs.js"),t=require("./ui/PageLayout/PageLayout.cjs.js"),o=require("./ui/PortalMock/PortalMock.cjs.js"),s=require("./ui/LazyComponent/LazyComponent.cjs.js"),c=require("./ui/Spacer/Spacer.cjs.js"),a=require("./ui/Chip/Chip.cjs.js"),u=require("./ui/Switch/Switch.cjs.js"),n=require("./ui/Form/utilities/formValidation.cjs.js"),l=require("./ui/Form/GenericAutocompleteField.cjs.js"),d=require("./ui/Form/GenericFormContainer.cjs.js"),p=require("./ui/Form/GenericTextField.cjs.js"),j=require("./ui/Form/PaginatedAutocompleteField.cjs.js"),x=require("./ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js"),m=require("./ui/GenericRadioButtons/GenericRadioButtons.cjs.js"),F=require("./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.cjs.js"),T=require("./ui/GenericTable/GenericTable.cjs.js"),q=require("./ui/GenericTableBody/GenericTableBody.cjs.js"),G=require("./ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js"),h=require("./ui/GenericTableTitle/GenericTableTitle.cjs.js"),b=require("@mui/icons-material/Search"),g=require("@mui/icons-material/CalendarToday"),P=require("./custom-hooks/useRenderValidText.cjs.js"),y=require("./custom-hooks/useMicroFrontendAttributes.cjs.js"),f=require("./renderUtilities/renderUtilities.cjs.js"),C=require("./genericUtilities/index.cjs.js");exports.flipdishPublicTheme=e,exports.NotFoundPage=i,exports.FlipdishStaffContainer=r,exports.PageLayout=t.default,exports.PortalMock=o,exports.LazyComponent=s,exports.Spacer=c,exports.Chip=a,exports.Switch=u,exports.formikValidate=n.formikValidate,exports.GenericAutocompleteField=l,exports.GenericFormContainer=d,exports.GenericTextField=p,exports.PaginatedAutocompleteField=j,exports.GenericDatePickerField=x,exports.GenericRadioButtons=m,exports.DateTimeLocalizationProvider=F,exports.GenericTable=T,exports.GenericTableBody=q,exports.GenericTableBodyRow=G,exports.GenericTableTitle=h,exports.SearchIcon=b,exports.CalendarTodayIcon=g,exports.useRenderValidText=P,exports.useMicroFrontendAttributes=y,exports.getAppId=f.getAppId,exports.getIsFlipdishStaff=f.getIsFlipdishStaff,exports.getMicroFrontendAttribute=f.getMicroFrontendAttribute,exports.getOrgId=f.getOrgId,exports.lazyWithRetry=f.lazyWithRetry,exports.debounce=C.debounce;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -25,3 +25,4 @@ export { default as CalendarTodayIcon } from '@mui/icons-material/CalendarToday'
|
|
|
25
25
|
export { default as useRenderValidText } from './custom-hooks/useRenderValidText.js';
|
|
26
26
|
export { default as useMicroFrontendAttributes } from './custom-hooks/useMicroFrontendAttributes.js';
|
|
27
27
|
export { getAppId, getIsFlipdishStaff, getMicroFrontendAttribute, getOrgId, lazyWithRetry } from './renderUtilities/renderUtilities.js';
|
|
28
|
+
export { debounce } from './genericUtilities/index.js';
|
package/dist/components/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{default as flipdishPublicTheme}from"./themes/flipdishPublicTheme.js";export{default as NotFoundPage}from"./ui/NotFoundPage/NotFoundPage.js";export{default as FlipdishStaffContainer}from"./ui/FlipdishStaffContainer/FlipdishStaffContainer.js";export{default as PageLayout}from"./ui/PageLayout/PageLayout.js";export{default as PortalMock}from"./ui/PortalMock/PortalMock.js";export{default as LazyComponent}from"./ui/LazyComponent/LazyComponent.js";export{default as Spacer}from"./ui/Spacer/Spacer.js";export{default as Chip}from"./ui/Chip/Chip.js";export{default as Switch}from"./ui/Switch/Switch.js";export{formikValidate}from"./ui/Form/utilities/formValidation.js";export{default as GenericAutocompleteField}from"./ui/Form/GenericAutocompleteField.js";export{default as GenericFormContainer}from"./ui/Form/GenericFormContainer.js";export{default as GenericTextField}from"./ui/Form/GenericTextField.js";export{default as PaginatedAutocompleteField}from"./ui/Form/PaginatedAutocompleteField.js";export{default as GenericDatePickerField}from"./ui/GenericDateTimePickerField/GenericDateTimePickerField.js";export{default as GenericRadioButtons}from"./ui/GenericRadioButtons/GenericRadioButtons.js";export{default as DateTimeLocalizationProvider}from"./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.js";export{default as GenericTable}from"./ui/GenericTable/GenericTable.js";export{default as GenericTableBody}from"./ui/GenericTableBody/GenericTableBody.js";export{default as GenericTableBodyRow}from"./ui/GenericTableBodyRow/GenericTableBodyRow.js";export{default as GenericTableTitle}from"./ui/GenericTableTitle/GenericTableTitle.js";export{default as SearchIcon}from"@mui/icons-material/Search";export{default as CalendarTodayIcon}from"@mui/icons-material/CalendarToday";export{default as useRenderValidText}from"./custom-hooks/useRenderValidText.js";export{default as useMicroFrontendAttributes}from"./custom-hooks/useMicroFrontendAttributes.js";export{getAppId,getIsFlipdishStaff,getMicroFrontendAttribute,getOrgId,lazyWithRetry}from"./renderUtilities/renderUtilities.js";
|
|
1
|
+
export{default as flipdishPublicTheme}from"./themes/flipdishPublicTheme.js";export{default as NotFoundPage}from"./ui/NotFoundPage/NotFoundPage.js";export{default as FlipdishStaffContainer}from"./ui/FlipdishStaffContainer/FlipdishStaffContainer.js";export{default as PageLayout}from"./ui/PageLayout/PageLayout.js";export{default as PortalMock}from"./ui/PortalMock/PortalMock.js";export{default as LazyComponent}from"./ui/LazyComponent/LazyComponent.js";export{default as Spacer}from"./ui/Spacer/Spacer.js";export{default as Chip}from"./ui/Chip/Chip.js";export{default as Switch}from"./ui/Switch/Switch.js";export{formikValidate}from"./ui/Form/utilities/formValidation.js";export{default as GenericAutocompleteField}from"./ui/Form/GenericAutocompleteField.js";export{default as GenericFormContainer}from"./ui/Form/GenericFormContainer.js";export{default as GenericTextField}from"./ui/Form/GenericTextField.js";export{default as PaginatedAutocompleteField}from"./ui/Form/PaginatedAutocompleteField.js";export{default as GenericDatePickerField}from"./ui/GenericDateTimePickerField/GenericDateTimePickerField.js";export{default as GenericRadioButtons}from"./ui/GenericRadioButtons/GenericRadioButtons.js";export{default as DateTimeLocalizationProvider}from"./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.js";export{default as GenericTable}from"./ui/GenericTable/GenericTable.js";export{default as GenericTableBody}from"./ui/GenericTableBody/GenericTableBody.js";export{default as GenericTableBodyRow}from"./ui/GenericTableBodyRow/GenericTableBodyRow.js";export{default as GenericTableTitle}from"./ui/GenericTableTitle/GenericTableTitle.js";export{default as SearchIcon}from"@mui/icons-material/Search";export{default as CalendarTodayIcon}from"@mui/icons-material/CalendarToday";export{default as useRenderValidText}from"./custom-hooks/useRenderValidText.js";export{default as useMicroFrontendAttributes}from"./custom-hooks/useMicroFrontendAttributes.js";export{getAppId,getIsFlipdishStaff,getMicroFrontendAttribute,getOrgId,lazyWithRetry}from"./renderUtilities/renderUtilities.js";export{debounce}from"./genericUtilities/index.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("formik"),t=require("@mui/material/TextField"),i=require("../../custom-hooks/useRenderValidText.cjs.js"),a=require("./FormItemLayout.cjs.js"),l=require("@mui/material/Typography"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("formik"),t=require("@mui/material/TextField"),i=require("../../custom-hooks/useRenderValidText.cjs.js"),a=require("./FormItemLayout.cjs.js"),l=require("@mui/material/Typography"),o=require("@mui/material/InputAdornment");module.exports=({label:n,fieldName:d,placeholder:s,validation:u,onChange:m,multiline:h,minRows:c,maxRows:v,layout:p="horizontal",variant:x="standard",disabled:g=!1,required:j=!1,showHelperTextWhenValid:f=!1,startIcon:q,endIcon:y,value:b})=>{const w=!!d,T=(r,i,a,l,u)=>e.jsx(t,{label:"standard"===x?void 0:n,variant:x,value:b??r,"data-testid":`text-field-${d??n.toLowerCase().replace(/\s+/g,"-")}`,autoComplete:"off",fullWidth:!0,multiline:h,minRows:c??(h?3:void 0),maxRows:v??(h?10:void 0),style:{paddingRight:"horizontal"===p?16:0},placeholder:s||void 0,disabled:i||g,required:j,error:a,helperText:a||f?l:void 0,onChange:e=>{u&&u(d,e.target.value),m&&m(e)},slotProps:{htmlInput:{style:{paddingTop:"outlined"!==x?0:void 0,height:"1.1876em"}},formHelperText:{children:" ",style:{textAlign:"right"}},input:{startAdornment:q?e.jsx(o,{position:"start",children:q}):void 0,endAdornment:y?e.jsx(o,{position:"end",children:y}):void 0}}}),R=()=>e.jsx(r.Field,{name:d,validate:u,children:({field:e,form:r})=>{const{errors:t,touched:a,isSubmitting:l}=r,o=t[e.name],n=!!o&&a[e.name],d=i({fieldError:o,showError:n,touched:!!a[e.name],value:e.value});return T(e.value,l,n,d,r.setFieldValue)}});return"vertical"===p?e.jsxs(e.Fragment,{children:["standard"===x&&e.jsx(l,{variant:"subtitle1",component:"h3",color:"textPrimary",children:n}),w?R():T()]}):e.jsx(a,{label:n,children:w?R():T()})};
|
|
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';\nimport InputAdornment from '@mui/material/InputAdornment';\n\ntype Props = {\n label: string;\n fieldName
|
|
1
|
+
{"version":3,"file":"GenericTextField.cjs.js","sources":["../../../../src/components/ui/Form/GenericTextField.tsx"],"sourcesContent":["import { ChangeEvent, ReactNode } 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';\nimport InputAdornment from '@mui/material/InputAdornment';\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 showHelperTextWhenValid?: boolean;\n startIcon?: React.ReactNode;\n endIcon?: React.ReactNode;\n value?: string;\n};\n\nconst GenericTextField = ({\n label,\n fieldName = undefined,\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 showHelperTextWhenValid = false,\n startIcon = undefined,\n endIcon = undefined,\n value,\n}: Props) => {\n const useFormik = !!fieldName;\n\n const renderField = (\n formikValue?: string,\n isSubmitting?: boolean,\n showError?: boolean,\n helperText?: string | ReactNode,\n setFieldValue?: (name: string, value: string) => void,\n ) => {\n return (\n <TextField\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n value={value ?? formikValue}\n data-testid={`text-field-${fieldName ?? label.toLowerCase().replace(/\\s+/g, '-')}`}\n autoComplete=\"off\"\n fullWidth\n multiline={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={showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n setFieldValue && setFieldValue(fieldName, e.target.value);\n if (onChange) {\n onChange(e);\n }\n }}\n slotProps={{\n htmlInput: {\n style: {\n paddingTop: variant !== 'outlined' ? 0 : undefined,\n height: '1.1876em',\n },\n },\n\n formHelperText: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n\n input: {\n startAdornment: startIcon ? <InputAdornment position=\"start\">{startIcon}</InputAdornment> : undefined,\n endAdornment: endIcon ? <InputAdornment position=\"end\">{endIcon}</InputAdornment> : undefined,\n },\n }}\n />\n );\n };\n\n const renderFormikField = () => {\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 // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return renderField(field.value as string, isSubmitting, showError, helperText, form.setFieldValue);\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 {useFormik ? renderFormikField() : renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{useFormik ? renderFormikField() : renderField()}</FormItemLayout>;\n};\n\nexport default GenericTextField;\n"],"names":["label","fieldName","placeholder","validation","onChange","multiline","minRows","maxRows","layout","variant","disabled","required","showHelperTextWhenValid","startIcon","endIcon","value","useFormik","renderField","formikValue","isSubmitting","showError","helperText","setFieldValue","_jsx","TextField","undefined","toLowerCase","replace","autoComplete","fullWidth","style","paddingRight","error","e","target","slotProps","htmlInput","paddingTop","height","formHelperText","children","textAlign","input","startAdornment","InputAdornment","position","endAdornment","renderFormikField","Field","name","validate","field","form","errors","touched","fieldError","useRenderValidText","_jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"uSA4ByB,EACrBA,QACAC,YACAC,cACAC,aACAC,WACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,EACXC,2BAA0B,EAC1BC,YACAC,UACAC,YAEA,MAAMC,IAAcf,EAEdgB,EAAc,CAChBC,EACAC,EACAC,EACAC,EACAC,IAGIC,EAAAA,IAACC,EAAS,CACNxB,MAAmB,aAAZS,OAAyBgB,EAAYzB,EAC5CS,QAASA,EACTM,MAAOA,GAASG,EACH,cAAA,cAAcjB,GAAaD,EAAM0B,cAAcC,QAAQ,OAAQ,OAC5EC,aAAa,MACbC,aACAxB,UAAWA,EACXC,QAASA,IAAYD,EAAY,OAAIoB,GACrClB,QAASA,IAAYF,EAAY,QAAKoB,GACtCK,MAAO,CAAEC,aAAyB,eAAXvB,EAA0B,GAAK,GACtDN,YAAaA,QAA4BuB,EACzCf,SAAUS,GAAgBT,EAC1BC,SAAUA,EACVqB,MAAOZ,EACPC,WAAYD,GAAyBR,EAAbS,OAAoDI,EAC5ErB,SAAW6B,IAEPX,GAAiBA,EAAcrB,EAAWgC,EAAEC,OAAOnB,OAC/CX,GACAA,EAAS6B,EACZ,EAELE,UAAW,CACPC,UAAW,CACPN,MAAO,CACHO,WAAwB,aAAZ5B,EAAyB,OAAIgB,EACzCa,OAAQ,aAIhBC,eAAgB,CACZC,SAAU,IACVV,MAAO,CAAEW,UAAW,UAGxBC,MAAO,CACHC,eAAgB9B,EAAYU,MAACqB,EAAc,CAACC,SAAS,QAASL,SAAA3B,SAA8BY,EAC5FqB,aAAchC,EAAUS,MAACqB,EAAc,CAACC,SAAS,MAAOL,SAAA1B,SAA4BW,MAOlGsB,EAAoB,IAElBxB,MAACyB,EAAAA,OAAMC,KAAMhD,EAAWiD,SAAU/C,EAAUqC,SACvC,EAAGW,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOnC,aAAEA,GAAiBiC,EACpCG,EAAaF,EAAOF,EAAMF,MAC1B7B,IAAcmC,GAAeD,EAAQH,EAAMF,MAC3C5B,EAAamC,EAAmB,CAClCD,aACAnC,YACAkC,UAAWA,EAAQH,EAAMF,MACzBlC,MAAOoC,EAAMpC,QAIjB,OAAOE,EAAYkC,EAAMpC,MAAiBI,EAAcC,EAAWC,EAAY+B,EAAK9B,cAAc,IAMlH,MAAe,aAAXd,EAEIiD,OACKC,EAAAA,SAAA,CAAAlB,SAAA,CAAY,aAAZ/B,GACGc,MAACoC,EAAU,CAAClD,QAAQ,YAAYmD,UAAU,KAAKC,MAAM,uBAChD7D,IAGRgB,EAAY+B,IAAsB9B,OAKxCM,MAACuC,EAAc,CAAC9D,MAAOA,WAAQgB,EAAY+B,IAAsB9B,KAA+B"}
|
|
@@ -4,7 +4,7 @@ import { TextFieldProps } from '@mui/material/TextField';
|
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
label: string;
|
|
7
|
-
fieldName
|
|
7
|
+
fieldName?: string;
|
|
8
8
|
placeholder?: string;
|
|
9
9
|
validation?: (value: string) => string | undefined;
|
|
10
10
|
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -18,7 +18,8 @@ type Props = {
|
|
|
18
18
|
showHelperTextWhenValid?: boolean;
|
|
19
19
|
startIcon?: React.ReactNode;
|
|
20
20
|
endIcon?: React.ReactNode;
|
|
21
|
+
value?: string;
|
|
21
22
|
};
|
|
22
|
-
declare const GenericTextField: ({ label, fieldName, placeholder, validation, onChange, multiline, minRows, maxRows, layout, variant, disabled, required, showHelperTextWhenValid, startIcon, endIcon, }: Props) => react_jsx_runtime.JSX.Element;
|
|
23
|
+
declare const GenericTextField: ({ label, fieldName, placeholder, validation, onChange, multiline, minRows, maxRows, layout, variant, disabled, required, showHelperTextWhenValid, startIcon, endIcon, value, }: Props) => react_jsx_runtime.JSX.Element;
|
|
23
24
|
|
|
24
25
|
export { GenericTextField as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import{Field as o}from"formik";import i from"@mui/material/TextField";import a from"../../custom-hooks/useRenderValidText.js";import l from"./FormItemLayout.js";import n from"@mui/material/Typography";import d from"@mui/material/InputAdornment";const m=({label:m,fieldName:s,placeholder:u,validation:h,onChange:p,multiline:c,minRows:
|
|
1
|
+
import{jsxs as e,Fragment as t,jsx as r}from"react/jsx-runtime";import{Field as o}from"formik";import i from"@mui/material/TextField";import a from"../../custom-hooks/useRenderValidText.js";import l from"./FormItemLayout.js";import n from"@mui/material/Typography";import d from"@mui/material/InputAdornment";const m=({label:m,fieldName:s,placeholder:u,validation:h,onChange:p,multiline:c,minRows:v,maxRows:f,layout:g="horizontal",variant:x="standard",disabled:y=!1,required:b=!1,showHelperTextWhenValid:w=!1,startIcon:T,endIcon:R,value:I})=>{const A=!!s,C=(e,t,o,a,l)=>r(i,{label:"standard"===x?void 0:m,variant:x,value:I??e,"data-testid":`text-field-${s??m.toLowerCase().replace(/\s+/g,"-")}`,autoComplete:"off",fullWidth:!0,multiline:c,minRows:v??(c?3:void 0),maxRows:f??(c?10:void 0),style:{paddingRight:"horizontal"===g?16:0},placeholder:u||void 0,disabled:t||y,required:b,error:o,helperText:o||w?a:void 0,onChange:e=>{l&&l(s,e.target.value),p&&p(e)},slotProps:{htmlInput:{style:{paddingTop:"outlined"!==x?0:void 0,height:"1.1876em"}},formHelperText:{children:" ",style:{textAlign:"right"}},input:{startAdornment:T?r(d,{position:"start",children:T}):void 0,endAdornment:R?r(d,{position:"end",children:R}):void 0}}}),j=()=>r(o,{name:s,validate:h,children:({field:e,form:t})=>{const{errors:r,touched:o,isSubmitting:i}=t,l=r[e.name],n=!!l&&o[e.name],d=a({fieldError:l,showError:n,touched:!!o[e.name],value:e.value});return C(e.value,i,n,d,t.setFieldValue)}});return"vertical"===g?e(t,{children:["standard"===x&&r(n,{variant:"subtitle1",component:"h3",color:"textPrimary",children:m}),A?j():C()]}):r(l,{label:m,children:A?j():C()})};export{m 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';\nimport InputAdornment from '@mui/material/InputAdornment';\n\ntype Props = {\n label: string;\n fieldName
|
|
1
|
+
{"version":3,"file":"GenericTextField.js","sources":["../../../../src/components/ui/Form/GenericTextField.tsx"],"sourcesContent":["import { ChangeEvent, ReactNode } 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';\nimport InputAdornment from '@mui/material/InputAdornment';\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 showHelperTextWhenValid?: boolean;\n startIcon?: React.ReactNode;\n endIcon?: React.ReactNode;\n value?: string;\n};\n\nconst GenericTextField = ({\n label,\n fieldName = undefined,\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 showHelperTextWhenValid = false,\n startIcon = undefined,\n endIcon = undefined,\n value,\n}: Props) => {\n const useFormik = !!fieldName;\n\n const renderField = (\n formikValue?: string,\n isSubmitting?: boolean,\n showError?: boolean,\n helperText?: string | ReactNode,\n setFieldValue?: (name: string, value: string) => void,\n ) => {\n return (\n <TextField\n label={variant === 'standard' ? undefined : label}\n variant={variant}\n value={value ?? formikValue}\n data-testid={`text-field-${fieldName ?? label.toLowerCase().replace(/\\s+/g, '-')}`}\n autoComplete=\"off\"\n fullWidth\n multiline={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={showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n setFieldValue && setFieldValue(fieldName, e.target.value);\n if (onChange) {\n onChange(e);\n }\n }}\n slotProps={{\n htmlInput: {\n style: {\n paddingTop: variant !== 'outlined' ? 0 : undefined,\n height: '1.1876em',\n },\n },\n\n formHelperText: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n\n input: {\n startAdornment: startIcon ? <InputAdornment position=\"start\">{startIcon}</InputAdornment> : undefined,\n endAdornment: endIcon ? <InputAdornment position=\"end\">{endIcon}</InputAdornment> : undefined,\n },\n }}\n />\n );\n };\n\n const renderFormikField = () => {\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 // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return renderField(field.value as string, isSubmitting, showError, helperText, form.setFieldValue);\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 {useFormik ? renderFormikField() : renderField()}\n </>\n );\n }\n\n return <FormItemLayout label={label}>{useFormik ? renderFormikField() : renderField()}</FormItemLayout>;\n};\n\nexport default GenericTextField;\n"],"names":["GenericTextField","label","fieldName","placeholder","validation","onChange","multiline","minRows","maxRows","layout","variant","disabled","required","showHelperTextWhenValid","startIcon","endIcon","value","useFormik","renderField","formikValue","isSubmitting","showError","helperText","setFieldValue","_jsx","TextField","undefined","toLowerCase","replace","autoComplete","fullWidth","style","paddingRight","error","e","target","slotProps","htmlInput","paddingTop","height","formHelperText","children","textAlign","input","startAdornment","InputAdornment","position","endAdornment","renderFormikField","Field","name","validate","field","form","errors","touched","fieldError","useRenderValidText","_jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"qTA4BM,MAAAA,EAAmB,EACrBC,QACAC,YACAC,cACAC,aACAC,WACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,EACXC,2BAA0B,EAC1BC,YACAC,UACAC,YAEA,MAAMC,IAAcf,EAEdgB,EAAc,CAChBC,EACAC,EACAC,EACAC,EACAC,IAGIC,EAACC,EAAS,CACNxB,MAAmB,aAAZS,OAAyBgB,EAAYzB,EAC5CS,QAASA,EACTM,MAAOA,GAASG,EACH,cAAA,cAAcjB,GAAaD,EAAM0B,cAAcC,QAAQ,OAAQ,OAC5EC,aAAa,MACbC,aACAxB,UAAWA,EACXC,QAASA,IAAYD,EAAY,OAAIoB,GACrClB,QAASA,IAAYF,EAAY,QAAKoB,GACtCK,MAAO,CAAEC,aAAyB,eAAXvB,EAA0B,GAAK,GACtDN,YAAaA,QAA4BuB,EACzCf,SAAUS,GAAgBT,EAC1BC,SAAUA,EACVqB,MAAOZ,EACPC,WAAYD,GAAyBR,EAAbS,OAAoDI,EAC5ErB,SAAW6B,IAEPX,GAAiBA,EAAcrB,EAAWgC,EAAEC,OAAOnB,OAC/CX,GACAA,EAAS6B,EACZ,EAELE,UAAW,CACPC,UAAW,CACPN,MAAO,CACHO,WAAwB,aAAZ5B,EAAyB,OAAIgB,EACzCa,OAAQ,aAIhBC,eAAgB,CACZC,SAAU,IACVV,MAAO,CAAEW,UAAW,UAGxBC,MAAO,CACHC,eAAgB9B,EAAYU,EAACqB,EAAc,CAACC,SAAS,QAASL,SAAA3B,SAA8BY,EAC5FqB,aAAchC,EAAUS,EAACqB,EAAc,CAACC,SAAS,MAAOL,SAAA1B,SAA4BW,MAOlGsB,EAAoB,IAElBxB,EAACyB,GAAMC,KAAMhD,EAAWiD,SAAU/C,EAAUqC,SACvC,EAAGW,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOnC,aAAEA,GAAiBiC,EACpCG,EAAaF,EAAOF,EAAMF,MAC1B7B,IAAcmC,GAAeD,EAAQH,EAAMF,MAC3C5B,EAAamC,EAAmB,CAClCD,aACAnC,YACAkC,UAAWA,EAAQH,EAAMF,MACzBlC,MAAOoC,EAAMpC,QAIjB,OAAOE,EAAYkC,EAAMpC,MAAiBI,EAAcC,EAAWC,EAAY+B,EAAK9B,cAAc,IAMlH,MAAe,aAAXd,EAEIiD,EACKC,EAAA,CAAAlB,SAAA,CAAY,aAAZ/B,GACGc,EAACoC,EAAU,CAAClD,QAAQ,YAAYmD,UAAU,KAAKC,MAAM,uBAChD7D,IAGRgB,EAAY+B,IAAsB9B,OAKxCM,EAACuC,EAAc,CAAC9D,MAAOA,WAAQgB,EAAY+B,IAAsB9B,KAA+B"}
|