@flipdish/portal-library 1.0.54 → 1.0.56
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/index.cjs.js +1 -1
- package/dist/components/index.d.ts +2 -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 -1
- package/dist/components/ui/Form/GenericTextField.js +1 -1
- package/dist/components/ui/Form/GenericTextField.js.map +1 -1
- package/dist/components/ui/Switch/Switch.cjs.js +1 -1
- package/dist/components/ui/Switch/Switch.cjs.js.map +1 -1
- package/dist/components/ui/Switch/Switch.d.ts +2 -1
- package/dist/components/ui/Switch/Switch.js +1 -1
- package/dist/components/ui/Switch/Switch.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),
|
|
1
|
+
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),r=require("./ui/NotFoundPage/NotFoundPage.cjs.js"),i=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"),a=require("./ui/Spacer/Spacer.cjs.js"),c=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"),P=require("@mui/icons-material/Search"),b=require("@mui/icons-material/CalendarToday"),g=require("./custom-hooks/useRenderValidText.cjs.js"),y=require("./custom-hooks/useMicroFrontendAttributes.cjs.js"),f=require("./renderUtilities/renderUtilities.cjs.js");exports.flipdishPublicTheme=e,exports.NotFoundPage=r,exports.FlipdishStaffContainer=i,exports.PageLayout=t.default,exports.PortalMock=o,exports.LazyComponent=s,exports.Spacer=a,exports.Chip=c,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=P,exports.CalendarTodayIcon=b,exports.useRenderValidText=g,exports.useMicroFrontendAttributes=y,exports.getAppId=f.getAppId,exports.getIsFlipdishStaff=f.getIsFlipdishStaff,exports.getMicroFrontendAttribute=f.getMicroFrontendAttribute,exports.getOrgId=f.getOrgId,exports.lazyWithRetry=f.lazyWithRetry;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -20,6 +20,8 @@ export { default as GenericTable } from './ui/GenericTable/GenericTable.js';
|
|
|
20
20
|
export { default as GenericTableBody } from './ui/GenericTableBody/GenericTableBody.js';
|
|
21
21
|
export { default as GenericTableBodyRow } from './ui/GenericTableBodyRow/GenericTableBodyRow.js';
|
|
22
22
|
export { default as GenericTableTitle } from './ui/GenericTableTitle/GenericTableTitle.js';
|
|
23
|
+
export { default as SearchIcon } from '@mui/icons-material/Search';
|
|
24
|
+
export { default as CalendarTodayIcon } from '@mui/icons-material/CalendarToday';
|
|
23
25
|
export { default as useRenderValidText } from './custom-hooks/useRenderValidText.js';
|
|
24
26
|
export { default as useMicroFrontendAttributes } from './custom-hooks/useMicroFrontendAttributes.js';
|
|
25
27
|
export { getAppId, getIsFlipdishStaff, getMicroFrontendAttribute, getOrgId, lazyWithRetry } from './renderUtilities/renderUtilities.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 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";
|
|
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");module.exports=({label:o,fieldName:d,placeholder:
|
|
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"),n=require("@mui/material/InputAdornment");module.exports=({label:o,fieldName:d,placeholder:s,validation:u,onChange:m,multiline:h,minRows:c,maxRows:p,layout:x="horizontal",variant:v="standard",disabled:g=!1,required:j=!1,showHelperTextWhenValid:f=!1,startIcon:q,endIcon:y})=>{const b=()=>e.jsx(r.Field,{name:d,validate:u,children:({field:r,form:a})=>{const{errors:l,touched:u,isSubmitting:b}=a,T=l[r.name],w=!!T&&u[r.name],R=i({fieldError:T,showError:w,touched:!!u[r.name],value:r.value});return e.jsx(t,{label:"standard"===v?void 0:o,variant:v,value:r.value,"data-testid":`text-field-${d}`,autoComplete:"off",fullWidth:!0,multiline:!0,minRows:c??(h?3:void 0),maxRows:p??(h?10:void 0),style:{paddingRight:"horizontal"===x?16:0},placeholder:s||void 0,disabled:b||g,required:j,error:w,helperText:w||f?R:void 0,onChange:e=>{a.setFieldValue(r.name,e.target.value),m&&m(e)},slotProps:{htmlInput:{style:{paddingTop:0,height:"1.1876em"}},formHelperText:{children:" ",style:{textAlign:"right"}},input:{startAdornment:q&&e.jsx(n,{position:"start",children:q}),endAdornment:y&&e.jsx(n,{position:"end",children:y})}}})}});return"vertical"===x?e.jsxs(e.Fragment,{children:["standard"===v&&e.jsx(l,{variant:"subtitle1",component:"h3",color:"textPrimary",children:o}),b()]}):e.jsx(a,{label:o,children:b()})};
|
|
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 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};\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 showHelperTextWhenValid = 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={showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\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 slotProps={{\n htmlInput: {\n style: {\n paddingTop: 0,\n height: '1.1876em',\n },\n },\n\n formHelperText: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\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","showHelperTextWhenValid","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","jsx","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","e","setFieldValue","target","slotProps","htmlInput","paddingTop","height","formHelperText","textAlign","_jsxs","jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"
|
|
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: 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};\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 showHelperTextWhenValid = false,\n startIcon = undefined,\n endIcon = undefined,\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={showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\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 slotProps={{\n htmlInput: {\n style: {\n paddingTop: 0,\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>,\n endAdornment: endIcon && <InputAdornment position=\"end\">{endIcon}</InputAdornment>,\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","showHelperTextWhenValid","startIcon","endIcon","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","jsx","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","e","setFieldValue","target","slotProps","htmlInput","paddingTop","height","formHelperText","textAlign","input","startAdornment","InputAdornment","position","endAdornment","_jsxs","jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"uSA2ByB,EACrBA,QACAC,YACAC,cACAC,aACAC,WACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,EACXC,2BAA0B,EAC1BC,YACAC,cAEA,MAAMC,EAAc,IAEZC,MAACC,EAAAA,OAAMC,KAAMjB,EAAWkB,SAAUhB,EAAUiB,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,EAAAe,IAACC,EAAS,CACNhC,MAAmB,aAAZS,OAAyBwB,EAAYjC,EAC5CS,QAASA,EACTqB,MAAOT,EAAMS,MACA,cAAA,cAAc7B,IAC3BiC,aAAa,MACbC,WAAS,EACT9B,WAAS,EACTC,QAASA,IAAYD,EAAY,OAAI4B,GACrC1B,QAASA,IAAYF,EAAY,QAAK4B,GACtCG,MAAO,CAAEC,aAAyB,eAAX7B,EAA0B,GAAK,GACtDN,YAAaA,QAA4B+B,EACzCvB,SAAUe,GAAgBf,EAC1BC,SAAUA,EACV2B,MAAOX,EACPC,WAAYD,GAAyBf,EAAbgB,OAAoDK,EAC5E7B,SAAWmC,IAEPjB,EAAKkB,cAAcnB,EAAMH,KAAMqB,EAAEE,OAAOX,OACpC1B,GACAA,EAASmC,EACZ,EAELG,UAAW,CACPC,UAAW,CACPP,MAAO,CACHQ,WAAY,EACZC,OAAQ,aAIhBC,eAAgB,CACZ1B,SAAU,IACVgB,MAAO,CAAEW,UAAW,UAGxBC,MAAO,CACHC,eAAgBpC,GAAaG,EAAAA,IAACkC,EAAe,CAAAC,SAAS,QAAS/B,SAAAP,IAC/DuC,aAActC,GAAWE,EAAAA,IAACkC,EAAe,CAAAC,SAAS,MAAO/B,SAAAN,OAIvE,IAMlB,MAAe,aAAXN,EAEI6C,EAAAC,KAAAC,WAAA,CAAAnC,SAAA,CACiB,aAAZX,GACGO,EAAAe,IAACyB,EAAU,CAAC/C,QAAQ,YAAYgD,UAAU,KAAKC,MAAM,cAChDtC,SAAApB,IAGRe,OAKNC,EAAAe,IAAC4B,EAAc,CAAC3D,MAAOA,EAAQoB,SAAAL,KAA+B"}
|
|
@@ -16,7 +16,9 @@ type Props = {
|
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
required?: boolean;
|
|
18
18
|
showHelperTextWhenValid?: boolean;
|
|
19
|
+
startIcon?: React.ReactNode;
|
|
20
|
+
endIcon?: React.ReactNode;
|
|
19
21
|
};
|
|
20
|
-
declare const GenericTextField: ({ label, fieldName, placeholder, validation, onChange, multiline, minRows, maxRows, layout, variant, disabled, required, showHelperTextWhenValid, }: Props) => react_jsx_runtime.JSX.Element;
|
|
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;
|
|
21
23
|
|
|
22
24
|
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
|
|
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:f,maxRows:v,layout:x="horizontal",variant:g="standard",disabled:y=!1,required:b=!1,showHelperTextWhenValid:T=!1,startIcon:w,endIcon:R})=>{const I=()=>r(o,{name:s,validate:h,children:({field:e,form:t})=>{const{errors:o,touched:l,isSubmitting:n}=t,h=o[e.name],I=!!h&&l[e.name],A=a({fieldError:h,showError:I,touched:!!l[e.name],value:e.value});return r(i,{label:"standard"===g?void 0:m,variant:g,value:e.value,"data-testid":`text-field-${s}`,autoComplete:"off",fullWidth:!0,multiline:!0,minRows:f??(c?3:void 0),maxRows:v??(c?10:void 0),style:{paddingRight:"horizontal"===x?16:0},placeholder:u||void 0,disabled:n||y,required:b,error:I,helperText:I||T?A:void 0,onChange:r=>{t.setFieldValue(e.name,r.target.value),p&&p(r)},slotProps:{htmlInput:{style:{paddingTop:0,height:"1.1876em"}},formHelperText:{children:" ",style:{textAlign:"right"}},input:{startAdornment:w&&r(d,{position:"start",children:w}),endAdornment:R&&r(d,{position:"end",children:R})}}})}});return"vertical"===x?e(t,{children:["standard"===g&&r(n,{variant:"subtitle1",component:"h3",color:"textPrimary",children:m}),I()]}):r(l,{label:m,children:I()})};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';\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};\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 showHelperTextWhenValid = 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={showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\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 slotProps={{\n htmlInput: {\n style: {\n paddingTop: 0,\n height: '1.1876em',\n },\n },\n\n formHelperText: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\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","showHelperTextWhenValid","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","e","setFieldValue","target","slotProps","htmlInput","paddingTop","height","formHelperText","textAlign","_jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"
|
|
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: 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};\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 showHelperTextWhenValid = false,\n startIcon = undefined,\n endIcon = undefined,\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={showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\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 slotProps={{\n htmlInput: {\n style: {\n paddingTop: 0,\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>,\n endAdornment: endIcon && <InputAdornment position=\"end\">{endIcon}</InputAdornment>,\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","showHelperTextWhenValid","startIcon","endIcon","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","TextField","undefined","autoComplete","fullWidth","style","paddingRight","error","e","setFieldValue","target","slotProps","htmlInput","paddingTop","height","formHelperText","textAlign","input","startAdornment","InputAdornment","position","endAdornment","_jsxs","_Fragment","Typography","component","color","FormItemLayout"],"mappings":"qTA2BM,MAAAA,EAAmB,EACrBC,QACAC,YACAC,cACAC,aACAC,WACAC,YACAC,UACAC,UACAC,SAAS,aACTC,UAAU,WACVC,YAAW,EACXC,YAAW,EACXC,2BAA0B,EAC1BC,YACAC,cAEA,MAAMC,EAAc,IAEZC,EAACC,GAAMC,KAAMjB,EAAWkB,SAAUhB,EAAUiB,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,EAAS,CACN/B,MAAmB,aAAZS,OAAyBuB,EAAYhC,EAC5CS,QAASA,EACTqB,MAAOT,EAAMS,MACA,cAAA,cAAc7B,IAC3BgC,aAAa,MACbC,WAAS,EACT7B,WAAS,EACTC,QAASA,IAAYD,EAAY,OAAI2B,GACrCzB,QAASA,IAAYF,EAAY,QAAK2B,GACtCG,MAAO,CAAEC,aAAyB,eAAX5B,EAA0B,GAAK,GACtDN,YAAaA,QAA4B8B,EACzCtB,SAAUe,GAAgBf,EAC1BC,SAAUA,EACV0B,MAAOV,EACPC,WAAYD,GAAyBf,EAAbgB,OAAoDI,EAC5E5B,SAAWkC,IAEPhB,EAAKiB,cAAclB,EAAMH,KAAMoB,EAAEE,OAAOV,OACpC1B,GACAA,EAASkC,EACZ,EAELG,UAAW,CACPC,UAAW,CACPP,MAAO,CACHQ,WAAY,EACZC,OAAQ,aAIhBC,eAAgB,CACZzB,SAAU,IACVe,MAAO,CAAEW,UAAW,UAGxBC,MAAO,CACHC,eAAgBnC,GAAaG,EAACiC,EAAe,CAAAC,SAAS,QAAS9B,SAAAP,IAC/DsC,aAAcrC,GAAWE,EAACiC,EAAe,CAAAC,SAAS,MAAO9B,SAAAN,OAIvE,IAMlB,MAAe,aAAXN,EAEI4C,EAAAC,EAAA,CAAAjC,SAAA,CACiB,aAAZX,GACGO,EAACsC,EAAU,CAAC7C,QAAQ,YAAY8C,UAAU,KAAKC,MAAM,cAChDpC,SAAApB,IAGRe,OAKNC,EAACyC,EAAc,CAACzD,MAAOA,EAAQoB,SAAAL,KAA+B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),a=require("@mui/material"),r=require("@mui/material/Switch");module.exports=({label:l,checked:t,onChange:i,labelPlacement:m="start",size:s="medium",disabled:c=!1,testId:d})=>e.jsx(a.FormControlLabel,{label:l,labelPlacement:m,control:e.jsx(r,{checked:t,onChange:i,color:"primary",size:s,disabled:c,"data-fd":d})});
|
|
2
2
|
//# sourceMappingURL=Switch.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.cjs.js","sources":["../../../../src/components/ui/Switch/Switch.tsx"],"sourcesContent":["import { FormControlLabel, FormControlLabelProps } from '@mui/material';\nimport MuiSwitch, { SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nexport type SwitchProps = {\n label: string;\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n checked?: boolean;\n onChange?: MuiSwitchProps['onChange'];\n size?: MuiSwitchProps['size'];\n disabled?: boolean;\n};\n\nconst Switch = ({ label, checked, onChange, labelPlacement = 'start', size = 'medium', disabled = false }: SwitchProps) => {\n return (\n <FormControlLabel\n label={label}\n labelPlacement={labelPlacement}\n control={<MuiSwitch checked={checked} onChange={onChange} color=\"primary\" size={size} disabled={disabled} />}\n />\n );\n};\n\nexport default Switch;\n"],"names":["label","checked","onChange","labelPlacement","size","disabled","_jsx","FormControlLabel","control","MuiSwitch","color"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Switch.cjs.js","sources":["../../../../src/components/ui/Switch/Switch.tsx"],"sourcesContent":["import { FormControlLabel, FormControlLabelProps } from '@mui/material';\nimport MuiSwitch, { SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nexport type SwitchProps = {\n label: string;\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n checked?: boolean;\n onChange?: MuiSwitchProps['onChange'];\n size?: MuiSwitchProps['size'];\n disabled?: boolean;\n testId?: string;\n};\n\nconst Switch = ({ label, checked, onChange, labelPlacement = 'start', size = 'medium', disabled = false, testId = undefined }: SwitchProps) => {\n return (\n <FormControlLabel\n label={label}\n labelPlacement={labelPlacement}\n control={<MuiSwitch checked={checked} onChange={onChange} color=\"primary\" size={size} disabled={disabled} data-fd={testId} />}\n />\n );\n};\n\nexport default Switch;\n"],"names":["label","checked","onChange","labelPlacement","size","disabled","testId","_jsx","FormControlLabel","control","MuiSwitch","color"],"mappings":"4HAae,EAAGA,QAAOC,UAASC,WAAUC,iBAAiB,QAASC,OAAO,SAAUC,YAAW,EAAOC,YAEjGC,MAACC,EAAAA,kBACGR,MAAOA,EACPG,eAAgBA,EAChBM,QAASF,EAAAA,IAACG,EAAS,CAACT,QAASA,EAASC,SAAUA,EAAUS,MAAM,UAAUP,KAAMA,EAAMC,SAAUA,EAAQ,UAAWC"}
|
|
@@ -9,7 +9,8 @@ type SwitchProps = {
|
|
|
9
9
|
onChange?: SwitchProps$1['onChange'];
|
|
10
10
|
size?: SwitchProps$1['size'];
|
|
11
11
|
disabled?: boolean;
|
|
12
|
+
testId?: string;
|
|
12
13
|
};
|
|
13
|
-
declare const Switch: ({ label, checked, onChange, labelPlacement, size, disabled }: SwitchProps) => react_jsx_runtime.JSX.Element;
|
|
14
|
+
declare const Switch: ({ label, checked, onChange, labelPlacement, size, disabled, testId }: SwitchProps) => react_jsx_runtime.JSX.Element;
|
|
14
15
|
|
|
15
16
|
export { type SwitchProps, Switch as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{FormControlLabel as a}from"@mui/material";import
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{FormControlLabel as a}from"@mui/material";import t from"@mui/material/Switch";const l=({label:l,checked:m,onChange:r,labelPlacement:i="start",size:o="medium",disabled:c=!1,testId:d})=>e(a,{label:l,labelPlacement:i,control:e(t,{checked:m,onChange:r,color:"primary",size:o,disabled:c,"data-fd":d})});export{l as default};
|
|
2
2
|
//# sourceMappingURL=Switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sources":["../../../../src/components/ui/Switch/Switch.tsx"],"sourcesContent":["import { FormControlLabel, FormControlLabelProps } from '@mui/material';\nimport MuiSwitch, { SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nexport type SwitchProps = {\n label: string;\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n checked?: boolean;\n onChange?: MuiSwitchProps['onChange'];\n size?: MuiSwitchProps['size'];\n disabled?: boolean;\n};\n\nconst Switch = ({ label, checked, onChange, labelPlacement = 'start', size = 'medium', disabled = false }: SwitchProps) => {\n return (\n <FormControlLabel\n label={label}\n labelPlacement={labelPlacement}\n control={<MuiSwitch checked={checked} onChange={onChange} color=\"primary\" size={size} disabled={disabled} />}\n />\n );\n};\n\nexport default Switch;\n"],"names":["Switch","label","checked","onChange","labelPlacement","size","disabled","_jsx","FormControlLabel","control","MuiSwitch","color"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Switch.js","sources":["../../../../src/components/ui/Switch/Switch.tsx"],"sourcesContent":["import { FormControlLabel, FormControlLabelProps } from '@mui/material';\nimport MuiSwitch, { SwitchProps as MuiSwitchProps } from '@mui/material/Switch';\n\nexport type SwitchProps = {\n label: string;\n labelPlacement?: FormControlLabelProps['labelPlacement'];\n checked?: boolean;\n onChange?: MuiSwitchProps['onChange'];\n size?: MuiSwitchProps['size'];\n disabled?: boolean;\n testId?: string;\n};\n\nconst Switch = ({ label, checked, onChange, labelPlacement = 'start', size = 'medium', disabled = false, testId = undefined }: SwitchProps) => {\n return (\n <FormControlLabel\n label={label}\n labelPlacement={labelPlacement}\n control={<MuiSwitch checked={checked} onChange={onChange} color=\"primary\" size={size} disabled={disabled} data-fd={testId} />}\n />\n );\n};\n\nexport default Switch;\n"],"names":["Switch","label","checked","onChange","labelPlacement","size","disabled","testId","_jsx","FormControlLabel","control","MuiSwitch","color"],"mappings":"6HAaM,MAAAA,EAAS,EAAGC,QAAOC,UAASC,WAAUC,iBAAiB,QAASC,OAAO,SAAUC,YAAW,EAAOC,YAEjGC,EAACC,GACGR,MAAOA,EACPG,eAAgBA,EAChBM,QAASF,EAACG,EAAS,CAACT,QAASA,EAASC,SAAUA,EAAUS,MAAM,UAAUP,KAAMA,EAAMC,SAAUA,EAAQ,UAAWC"}
|