@flipdish/portal-library 1.0.37 → 1.0.38
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 +1 -0
- package/dist/components/index.js +1 -1
- package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js +1 -1
- package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js.map +1 -1
- package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.js +1 -1
- package/dist/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.js.map +1 -1
- package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.cjs.js +2 -0
- package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.cjs.js.map +1 -0
- package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.d.ts +19 -0
- package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.js +2 -0
- package/dist/components/ui/GenericRadioButtons/GenericRadioButtons.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),r=require("./ui/NotFoundPage/NotFoundPage.cjs.js"),i=require("./ui/PageLayout/PageLayout.cjs.js"),o=require("./ui/PortalMock/PortalMock.cjs.js"),s=require("./ui/LazyComponent/LazyComponent.cjs.js"),t=require("./ui/Spacer/Spacer.cjs.js"),c=require("./ui/Chip/Chip.cjs.js"),a=require("./ui/Switch/Switch.cjs.js"),u=require("./ui/Form/utilities/formValidation.cjs.js"),n=require("./ui/Form/GenericFormContainer.cjs.js"),j=require("./ui/Form/GenericTextField.cjs.js"),l=require("./ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js"),p=require("./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.cjs.js"),
|
|
1
|
+
"use strict";var e=require("./themes/flipdishPublicTheme.cjs.js"),r=require("./ui/NotFoundPage/NotFoundPage.cjs.js"),i=require("./ui/PageLayout/PageLayout.cjs.js"),o=require("./ui/PortalMock/PortalMock.cjs.js"),s=require("./ui/LazyComponent/LazyComponent.cjs.js"),t=require("./ui/Spacer/Spacer.cjs.js"),c=require("./ui/Chip/Chip.cjs.js"),a=require("./ui/Switch/Switch.cjs.js"),u=require("./ui/Form/utilities/formValidation.cjs.js"),n=require("./ui/Form/GenericFormContainer.cjs.js"),j=require("./ui/Form/GenericTextField.cjs.js"),l=require("./ui/GenericDateTimePickerField/GenericDateTimePickerField.cjs.js"),p=require("./ui/GenericRadioButtons/GenericRadioButtons.cjs.js"),d=require("./ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.cjs.js"),T=require("./ui/GenericTable/GenericTable.cjs.js"),G=require("./ui/GenericTableBody/GenericTableBody.cjs.js"),q=require("./ui/GenericTableBodyRow/GenericTableBodyRow.cjs.js"),x=require("./ui/GenericTableTitle/GenericTableTitle.cjs.js");require("react/jsx-runtime"),require("react"),require("../providers/TranslationProvider.cjs.js"),exports.flipdishPublicTheme=e,exports.NotFoundPage=r,exports.PageLayout=i.default,exports.PortalMock=o,exports.LazyComponent=s,exports.Spacer=t,exports.Chip=c,exports.Switch=a,exports.formikValidate=u.formikValidate,exports.GenericFormContainer=n,exports.GenericTextField=j,exports.GenericDatePickerField=l,exports.GenericRadioButtons=p,exports.DateTimeLocalizationProvider=d,exports.GenericTable=T,exports.GenericTableBody=G,exports.GenericTableBodyRow=q,exports.GenericTableTitle=x;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -10,6 +10,7 @@ export { formikValidate } from './ui/Form/utilities/formValidation.js';
|
|
|
10
10
|
export { default as GenericFormContainer } from './ui/Form/GenericFormContainer.js';
|
|
11
11
|
export { default as GenericTextField } from './ui/Form/GenericTextField.js';
|
|
12
12
|
export { default as GenericDatePickerField } from './ui/GenericDateTimePickerField/GenericDateTimePickerField.js';
|
|
13
|
+
export { default as GenericRadioButtons } from './ui/GenericRadioButtons/GenericRadioButtons.js';
|
|
13
14
|
export { default as DateTimeLocalizationProvider } from './ui/DateTimeLocalizationProvider/DateTimeLocalizationProvider.js';
|
|
14
15
|
export { GenericTableColumns } from './ui/GenericTable/types.js';
|
|
15
16
|
export { default as GenericTable } from './ui/GenericTable/GenericTable.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 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 GenericFormContainer}from"./ui/Form/GenericFormContainer.js";export{default as GenericTextField}from"./ui/Form/GenericTextField.js";export{default as GenericDatePickerField}from"./ui/GenericDateTimePickerField/GenericDateTimePickerField.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";import"react/jsx-runtime";import"react";import"../providers/TranslationProvider.js";
|
|
1
|
+
export{default as flipdishPublicTheme}from"./themes/flipdishPublicTheme.js";export{default as NotFoundPage}from"./ui/NotFoundPage/NotFoundPage.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 GenericFormContainer}from"./ui/Form/GenericFormContainer.js";export{default as GenericTextField}from"./ui/Form/GenericTextField.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";import"react/jsx-runtime";import"react";import"../providers/TranslationProvider.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("formik"),a=require("../Form/FormItemLayout.cjs.js"),i=require("@mui/x-date-pickers/DateTimePicker"),t=require("@mui/material/styles"),l=require("@mui/material/Box"),s=require("@mui/material/Typography"),
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("formik"),a=require("../Form/FormItemLayout.cjs.js"),i=require("@mui/x-date-pickers/DateTimePicker"),t=require("@mui/material/styles"),l=require("@mui/material/Box"),s=require("@mui/material/Typography"),o=require("../../custom-hooks/useRenderValidText.cjs.js");const d=t.styled(i.DateTimePicker)((({theme:e})=>({marginTop:e.spacing(2),width:"100%"})));module.exports=({label:i,fieldName:n,description:u,validation:m,variant:c="standard",layout:h,onChange:x,disabled:p=!1,disablePast:v=!1,disablefuture:j=!1,placeholder:b,showHelperTextWhenValid:g=!1})=>{const y=t.useTheme(),T=()=>e.jsx(r.Field,{name:n,validate:m,children:({field:r,form:a})=>{const{errors:t,touched:m,isSubmitting:T}=a,q=t[r.name],F=!!q&&m[r.name],P=o({fieldError:q,showError:F,touched:!!m[r.name],value:r.value});return e.jsxs(l,{sx:{paddingRight:"horizontal"===h?"16px":0},children:[e.jsx(d,{label:"standard"===c?void 0:i,value:r.value,onChange:e=>{a.setFieldValue(r.name,e),x&&x(e)},name:n,slotProps:{textField:{variant:c,placeholder:b,error:F,helperText:F||g?P:void 0,FormHelperTextProps:{children:" ",style:{textAlign:"right"}}}},disabled:T||p,disablePast:v,disableFuture:j}),u&&e.jsx(s,{variant:"caption",sx:{color:y.palette.text.secondary},children:u})]})}});return"vertical"===h?e.jsxs(e.Fragment,{children:["standard"===c&&e.jsx(s,{variant:"subtitle1",component:"h3",color:"textPrimary",children:i}),T()]}):e.jsx(a,{label:i,children:T()})};
|
|
2
2
|
//# sourceMappingURL=GenericDateTimePickerField.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericDateTimePickerField.cjs.js","sources":["../../../../src/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.tsx"],"sourcesContent":["import { type FieldProps, Field } from 'formik';\nimport FormItemLayout from '../Form/FormItemLayout';\nimport { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';\nimport { styled, useTheme } from '@mui/material/styles';\nimport { TextFieldVariants } from '@mui/material/TextField';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\n\nconst StyledDateTimePicker = styled(DateTimePicker)(({ theme }) => ({\n marginTop: theme.spacing(2),\n width: '100%',\n}));\n\ntype Props = {\n label: string;\n placeholder?: string;\n fieldName: string;\n description?: string;\n validation?: (value: string) => string | undefined;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldVariants;\n disabled?: boolean;\n disablePast?: boolean;\n disablefuture?: boolean;\n onChange?: (dateTime: moment.Moment) => void;\n showHelperTextWhenValid?: boolean;\n};\nconst GenericDatePickerField = ({\n label,\n fieldName,\n description,\n validation,\n variant = 'standard',\n layout,\n onChange,\n disabled = false,\n disablePast = false,\n disablefuture = false,\n placeholder = undefined,\n showHelperTextWhenValid = false,\n}: Props) => {\n const theme = useTheme();\n\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 <Box sx={{ paddingRight: '16px' }}>\n <StyledDateTimePicker\n label={variant === 'standard' ? undefined : label}\n value={field.value}\n onChange={(value) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, value);\n if (onChange) {\n onChange(value);\n }\n }}\n name={fieldName}\n slotProps={{\n textField: {\n variant,\n placeholder,\n error: showError,\n helperText: showError ? helperText : showHelperTextWhenValid ? helperText : undefined,\n FormHelperTextProps: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n },\n }}\n disabled={isSubmitting || disabled}\n disablePast={disablePast}\n disableFuture={disablefuture}\n />\n {description && (\n <Typography variant=\"caption\" sx={{ color: theme.palette.text.secondary }}>\n {description}\n </Typography>\n )}\n </Box>\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 GenericDatePickerField;\n"],"names":["StyledDateTimePicker","styled","DateTimePicker","theme","marginTop","spacing","width","label","fieldName","description","validation","variant","layout","onChange","disabled","disablePast","disablefuture","placeholder","showHelperTextWhenValid","useTheme","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","_jsxs","
|
|
1
|
+
{"version":3,"file":"GenericDateTimePickerField.cjs.js","sources":["../../../../src/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.tsx"],"sourcesContent":["import { type FieldProps, Field } from 'formik';\nimport FormItemLayout from '../Form/FormItemLayout';\nimport { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';\nimport { styled, useTheme } from '@mui/material/styles';\nimport { TextFieldVariants } from '@mui/material/TextField';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\n\nconst StyledDateTimePicker = styled(DateTimePicker)(({ theme }) => ({\n marginTop: theme.spacing(2),\n width: '100%',\n}));\n\ntype Props = {\n label: string;\n placeholder?: string;\n fieldName: string;\n description?: string;\n validation?: (value: string) => string | undefined;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldVariants;\n disabled?: boolean;\n disablePast?: boolean;\n disablefuture?: boolean;\n onChange?: (dateTime: moment.Moment) => void;\n showHelperTextWhenValid?: boolean;\n};\nconst GenericDatePickerField = ({\n label,\n fieldName,\n description,\n validation,\n variant = 'standard',\n layout,\n onChange,\n disabled = false,\n disablePast = false,\n disablefuture = false,\n placeholder = undefined,\n showHelperTextWhenValid = false,\n}: Props) => {\n const theme = useTheme();\n\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 <Box sx={{ paddingRight: layout === 'horizontal' ? '16px' : 0 }}>\n <StyledDateTimePicker\n label={variant === 'standard' ? undefined : label}\n value={field.value}\n onChange={(value) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, value);\n if (onChange) {\n onChange(value);\n }\n }}\n name={fieldName}\n slotProps={{\n textField: {\n variant,\n placeholder,\n error: showError,\n helperText: showError ? helperText : showHelperTextWhenValid ? helperText : undefined,\n FormHelperTextProps: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n },\n }}\n disabled={isSubmitting || disabled}\n disablePast={disablePast}\n disableFuture={disablefuture}\n />\n {description && (\n <Typography variant=\"caption\" sx={{ color: theme.palette.text.secondary }}>\n {description}\n </Typography>\n )}\n </Box>\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 GenericDatePickerField;\n"],"names":["StyledDateTimePicker","styled","DateTimePicker","theme","marginTop","spacing","width","label","fieldName","description","validation","variant","layout","onChange","disabled","disablePast","disablefuture","placeholder","showHelperTextWhenValid","useTheme","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","_jsxs","Box","sx","paddingRight","undefined","setFieldValue","slotProps","textField","error","FormHelperTextProps","style","textAlign","disableFuture","jsx","Typography","color","palette","text","secondary","jsxs","_Fragment","component","FormItemLayout"],"mappings":"gUASA,MAAMA,EAAuBC,EAAAA,OAAOC,EAAAA,eAAPD,EAAuB,EAAGE,YAAa,CAChEC,UAAWD,EAAME,QAAQ,GACzBC,MAAO,0BAiBoB,EAC3BC,QACAC,YACAC,cACAC,aACAC,UAAU,WACVC,SACAC,WACAC,YAAW,EACXC,eAAc,EACdC,iBAAgB,EAChBC,cACAC,2BAA0B,MAE1B,MAAMf,EAAQgB,EAAAA,WAERC,EAAc,IAEZC,MAACC,EAAAA,OAAMC,KAAMf,EAAWgB,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,OACIC,OAACC,EAAG,CAACC,GAAI,CAAEC,aAAyB,eAAX3B,EAA0B,OAAS,GACxDa,SAAA,CAAAJ,EAAAA,IAACrB,EAAoB,CACjBO,MAAmB,aAAZI,OAAyB6B,EAAYjC,EAC5C4B,MAAOT,EAAMS,MACbtB,SAAWsB,IAEPR,EAAKc,cAAcf,EAAMH,KAAMY,GAC3BtB,GACAA,EAASsB,EACZ,EAELZ,KAAMf,EACNkC,UAAW,CACPC,UAAW,CACPhC,UACAM,cACA2B,MAAOZ,EACPC,WAAYD,GAAyBd,EAAbe,OAAoDO,EAC5EK,oBAAqB,CACjBpB,SAAU,IACVqB,MAAO,CAAEC,UAAW,YAIhCjC,SAAUgB,GAAgBhB,EAC1BC,YAAaA,EACbiC,cAAehC,IAElBP,GACGY,EAAA4B,IAACC,EAAW,CAAAvC,QAAQ,UAAU2B,GAAI,CAAEa,MAAOhD,EAAMiD,QAAQC,KAAKC,WACzD7B,SAAAhB,MAIf,IAMlB,MAAe,aAAXG,EAEIwB,EAAAmB,KAAAC,WAAA,CAAA/B,SAAA,CACiB,aAAZd,GACGU,EAAA4B,IAACC,EAAU,CAACvC,QAAQ,YAAY8C,UAAU,KAAKN,MAAM,cAChD1B,SAAAlB,IAGRa,OAKNC,EAAA4B,IAACS,EAAc,CAACnD,MAAOA,EAAQkB,SAAAL,KAA+B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{Field as a}from"formik";import i from"../Form/FormItemLayout.js";import{DateTimePicker as o}from"@mui/x-date-pickers/DateTimePicker";import{styled as l,useTheme as d}from"@mui/material/styles";import m from"@mui/material/Box";import n from"@mui/material/Typography";import s from"../../custom-hooks/useRenderValidText.js";const p=l(o)((({theme:e})=>({marginTop:e.spacing(2),width:"100%"}))),c=({label:o,fieldName:l,description:c,validation:
|
|
1
|
+
import{jsxs as e,Fragment as r,jsx as t}from"react/jsx-runtime";import{Field as a}from"formik";import i from"../Form/FormItemLayout.js";import{DateTimePicker as o}from"@mui/x-date-pickers/DateTimePicker";import{styled as l,useTheme as d}from"@mui/material/styles";import m from"@mui/material/Box";import n from"@mui/material/Typography";import s from"../../custom-hooks/useRenderValidText.js";const p=l(o)((({theme:e})=>({marginTop:e.spacing(2),width:"100%"}))),c=({label:o,fieldName:l,description:c,validation:h,variant:u="standard",layout:f,onChange:x,disabled:v=!1,disablePast:b=!1,disablefuture:g=!1,placeholder:y,showHelperTextWhenValid:T=!1})=>{const F=d(),P=()=>t(a,{name:l,validate:h,children:({field:r,form:a})=>{const{errors:i,touched:d,isSubmitting:h}=a,P=i[r.name],k=!!P&&d[r.name],j=s({fieldError:P,showError:k,touched:!!d[r.name],value:r.value});return e(m,{sx:{paddingRight:"horizontal"===f?"16px":0},children:[t(p,{label:"standard"===u?void 0:o,value:r.value,onChange:e=>{a.setFieldValue(r.name,e),x&&x(e)},name:l,slotProps:{textField:{variant:u,placeholder:y,error:k,helperText:k||T?j:void 0,FormHelperTextProps:{children:" ",style:{textAlign:"right"}}}},disabled:h||v,disablePast:b,disableFuture:g}),c&&t(n,{variant:"caption",sx:{color:F.palette.text.secondary},children:c})]})}});return"vertical"===f?e(r,{children:["standard"===u&&t(n,{variant:"subtitle1",component:"h3",color:"textPrimary",children:o}),P()]}):t(i,{label:o,children:P()})};export{c as default};
|
|
2
2
|
//# sourceMappingURL=GenericDateTimePickerField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenericDateTimePickerField.js","sources":["../../../../src/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.tsx"],"sourcesContent":["import { type FieldProps, Field } from 'formik';\nimport FormItemLayout from '../Form/FormItemLayout';\nimport { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';\nimport { styled, useTheme } from '@mui/material/styles';\nimport { TextFieldVariants } from '@mui/material/TextField';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\n\nconst StyledDateTimePicker = styled(DateTimePicker)(({ theme }) => ({\n marginTop: theme.spacing(2),\n width: '100%',\n}));\n\ntype Props = {\n label: string;\n placeholder?: string;\n fieldName: string;\n description?: string;\n validation?: (value: string) => string | undefined;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldVariants;\n disabled?: boolean;\n disablePast?: boolean;\n disablefuture?: boolean;\n onChange?: (dateTime: moment.Moment) => void;\n showHelperTextWhenValid?: boolean;\n};\nconst GenericDatePickerField = ({\n label,\n fieldName,\n description,\n validation,\n variant = 'standard',\n layout,\n onChange,\n disabled = false,\n disablePast = false,\n disablefuture = false,\n placeholder = undefined,\n showHelperTextWhenValid = false,\n}: Props) => {\n const theme = useTheme();\n\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 <Box sx={{ paddingRight: '16px' }}>\n <StyledDateTimePicker\n label={variant === 'standard' ? undefined : label}\n value={field.value}\n onChange={(value) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, value);\n if (onChange) {\n onChange(value);\n }\n }}\n name={fieldName}\n slotProps={{\n textField: {\n variant,\n placeholder,\n error: showError,\n helperText: showError ? helperText : showHelperTextWhenValid ? helperText : undefined,\n FormHelperTextProps: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n },\n }}\n disabled={isSubmitting || disabled}\n disablePast={disablePast}\n disableFuture={disablefuture}\n />\n {description && (\n <Typography variant=\"caption\" sx={{ color: theme.palette.text.secondary }}>\n {description}\n </Typography>\n )}\n </Box>\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 GenericDatePickerField;\n"],"names":["StyledDateTimePicker","styled","DateTimePicker","theme","marginTop","spacing","width","GenericDatePickerField","label","fieldName","description","validation","variant","layout","onChange","disabled","disablePast","disablefuture","placeholder","showHelperTextWhenValid","useTheme","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","_jsxs","Box","sx","paddingRight","undefined","setFieldValue","slotProps","textField","error","FormHelperTextProps","style","textAlign","disableFuture","Typography","color","palette","text","secondary","_Fragment","component","FormItemLayout"],"mappings":"yYASA,MAAMA,EAAuBC,EAAOC,EAAPD,EAAuB,EAAGE,YAAa,CAChEC,UAAWD,EAAME,QAAQ,GACzBC,MAAO,WAiBLC,EAAyB,EAC3BC,QACAC,YACAC,cACAC,aACAC,UAAU,WACVC,SACAC,WACAC,YAAW,EACXC,eAAc,EACdC,iBAAgB,EAChBC,cACAC,2BAA0B,MAE1B,MAAMhB,EAAQiB,IAERC,EAAc,IAEZC,EAACC,GAAMC,KAAMf,EAAWgB,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,OACIC,EAACC,
|
|
1
|
+
{"version":3,"file":"GenericDateTimePickerField.js","sources":["../../../../src/components/ui/GenericDateTimePickerField/GenericDateTimePickerField.tsx"],"sourcesContent":["import { type FieldProps, Field } from 'formik';\nimport FormItemLayout from '../Form/FormItemLayout';\nimport { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';\nimport { styled, useTheme } from '@mui/material/styles';\nimport { TextFieldVariants } from '@mui/material/TextField';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\n\nconst StyledDateTimePicker = styled(DateTimePicker)(({ theme }) => ({\n marginTop: theme.spacing(2),\n width: '100%',\n}));\n\ntype Props = {\n label: string;\n placeholder?: string;\n fieldName: string;\n description?: string;\n validation?: (value: string) => string | undefined;\n layout?: 'horizontal' | 'vertical';\n variant?: TextFieldVariants;\n disabled?: boolean;\n disablePast?: boolean;\n disablefuture?: boolean;\n onChange?: (dateTime: moment.Moment) => void;\n showHelperTextWhenValid?: boolean;\n};\nconst GenericDatePickerField = ({\n label,\n fieldName,\n description,\n validation,\n variant = 'standard',\n layout,\n onChange,\n disabled = false,\n disablePast = false,\n disablefuture = false,\n placeholder = undefined,\n showHelperTextWhenValid = false,\n}: Props) => {\n const theme = useTheme();\n\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 <Box sx={{ paddingRight: layout === 'horizontal' ? '16px' : 0 }}>\n <StyledDateTimePicker\n label={variant === 'standard' ? undefined : label}\n value={field.value}\n onChange={(value) => {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n form.setFieldValue(field.name, value);\n if (onChange) {\n onChange(value);\n }\n }}\n name={fieldName}\n slotProps={{\n textField: {\n variant,\n placeholder,\n error: showError,\n helperText: showError ? helperText : showHelperTextWhenValid ? helperText : undefined,\n FormHelperTextProps: {\n children: ' ', // reserves line height for error message\n style: { textAlign: 'right' },\n },\n },\n }}\n disabled={isSubmitting || disabled}\n disablePast={disablePast}\n disableFuture={disablefuture}\n />\n {description && (\n <Typography variant=\"caption\" sx={{ color: theme.palette.text.secondary }}>\n {description}\n </Typography>\n )}\n </Box>\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 GenericDatePickerField;\n"],"names":["StyledDateTimePicker","styled","DateTimePicker","theme","marginTop","spacing","width","GenericDatePickerField","label","fieldName","description","validation","variant","layout","onChange","disabled","disablePast","disablefuture","placeholder","showHelperTextWhenValid","useTheme","renderField","_jsx","Field","name","validate","children","field","form","errors","touched","isSubmitting","fieldError","showError","helperText","useRenderValidText","value","_jsxs","Box","sx","paddingRight","undefined","setFieldValue","slotProps","textField","error","FormHelperTextProps","style","textAlign","disableFuture","Typography","color","palette","text","secondary","_Fragment","component","FormItemLayout"],"mappings":"yYASA,MAAMA,EAAuBC,EAAOC,EAAPD,EAAuB,EAAGE,YAAa,CAChEC,UAAWD,EAAME,QAAQ,GACzBC,MAAO,WAiBLC,EAAyB,EAC3BC,QACAC,YACAC,cACAC,aACAC,UAAU,WACVC,SACAC,WACAC,YAAW,EACXC,eAAc,EACdC,iBAAgB,EAChBC,cACAC,2BAA0B,MAE1B,MAAMhB,EAAQiB,IAERC,EAAc,IAEZC,EAACC,GAAMC,KAAMf,EAAWgB,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,OACIC,EAACC,EAAG,CAACC,GAAI,CAAEC,aAAyB,eAAX3B,EAA0B,OAAS,GACxDa,SAAA,CAAAJ,EAACtB,EAAoB,CACjBQ,MAAmB,aAAZI,OAAyB6B,EAAYjC,EAC5C4B,MAAOT,EAAMS,MACbtB,SAAWsB,IAEPR,EAAKc,cAAcf,EAAMH,KAAMY,GAC3BtB,GACAA,EAASsB,EACZ,EAELZ,KAAMf,EACNkC,UAAW,CACPC,UAAW,CACPhC,UACAM,cACA2B,MAAOZ,EACPC,WAAYD,GAAyBd,EAAbe,OAAoDO,EAC5EK,oBAAqB,CACjBpB,SAAU,IACVqB,MAAO,CAAEC,UAAW,YAIhCjC,SAAUgB,GAAgBhB,EAC1BC,YAAaA,EACbiC,cAAehC,IAElBP,GACGY,EAAC4B,EAAW,CAAAtC,QAAQ,UAAU2B,GAAI,CAAEY,MAAOhD,EAAMiD,QAAQC,KAAKC,WACzD5B,SAAAhB,MAIf,IAMlB,MAAe,aAAXG,EAEIwB,EAAAkB,EAAA,CAAA7B,SAAA,CACiB,aAAZd,GACGU,EAAC4B,EAAU,CAACtC,QAAQ,YAAY4C,UAAU,KAAKL,MAAM,cAChDzB,SAAAlB,IAGRa,OAKNC,EAACmC,EAAc,CAACjD,MAAOA,EAAQkB,SAAAL,KAA+B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("formik"),a=require("../Form/FormItemLayout.cjs.js"),i=require("@mui/material/Box"),l=require("@mui/material/Typography"),t=require("../../custom-hooks/useRenderValidText.cjs.js"),o=require("@mui/material/Radio"),s=require("@mui/material/FormControlLabel"),n=require("@mui/material/RadioGroup"),u=require("../Spacer/Spacer.cjs.js"),m=require("@mui/material/styles");const d=m.styled(i)((({theme:e})=>({marginLeft:e.spacing(4)}))),c=m.styled(l)((({theme:e,showError:r})=>({color:r?e.palette.error.main:"inherit",textAlign:"right"})));module.exports=({label:m,fieldName:h,layout:x,onChange:j,options:p,showHelperTextWhenValid:g=!1})=>{const b=()=>e.jsx(r.Field,{name:h,children:({field:r,form:a})=>{const{errors:l,touched:m,isSubmitting:h}=a,b=l[r.name],v=!!b&&m[r.name],q=t({fieldError:b,showError:v,touched:!!m[r.name],value:r.value});return e.jsxs(i,{sx:{paddingRight:"horizontal"===x?"16px":0},children:[e.jsx(n,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:"female",name:"radio-buttons-group",value:r.value,onChange:e=>{a.setFieldValue(r.name,e.target.value),j&&j(e)},children:p.map((a=>e.jsxs(e.Fragment,{children:[e.jsx(s,{value:a.value,control:e.jsx(o,{}),label:a.label,disabled:h||a.disabled}),a.selectedContent&&r.value===a.value&&e.jsxs(d,{children:[a.selectedContent,e.jsx(u,{size:8,variant:"horizontal"})]})]})))}),e.jsx(c,{showError:v,children:v||g?q:void 0})]})}});return"vertical"===x?e.jsxs(e.Fragment,{children:[m&&e.jsx(l,{variant:"subtitle1",component:"h3",color:"textPrimary",children:m}),b()]}):e.jsx(a,{label:m,children:b()})};
|
|
2
|
+
//# sourceMappingURL=GenericRadioButtons.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericRadioButtons.cjs.js","sources":["../../../../src/components/ui/GenericRadioButtons/GenericRadioButtons.tsx"],"sourcesContent":["import { type FieldProps, Field } from 'formik';\nimport FormItemLayout from '../Form/FormItemLayout';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport Radio from '@mui/material/Radio';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { ChangeEvent, ReactNode } from 'react';\nimport { Spacer } from '../Spacer';\nimport { styled } from '@mui/material/styles';\n\ntype Props = {\n label?: string;\n fieldName: string;\n layout?: 'horizontal' | 'vertical';\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n showHelperTextWhenValid?: boolean;\n options: {\n label: string;\n value: string;\n disabled?: boolean;\n selectedContent?: ReactNode;\n }[];\n};\n\nconst StyledSelectedContent = styled(Box)(({ theme }) => ({\n marginLeft: theme.spacing(4),\n}));\n\nconst StyledHelperText = styled(Typography)<{ showError: boolean }>(({ theme, showError }) => ({\n color: showError ? theme.palette.error.main : 'inherit',\n textAlign: 'right',\n}));\n\nconst GenericRadioButtons = ({ label, fieldName, layout, onChange, options, showHelperTextWhenValid = false }: Props) => {\n const renderField = () => {\n return (\n <Field name={fieldName}>\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 <Box sx={{ paddingRight: layout === 'horizontal' ? '16px' : 0 }}>\n <RadioGroup\n aria-labelledby=\"demo-radio-buttons-group-label\"\n defaultValue=\"female\"\n name=\"radio-buttons-group\"\n value={field.value}\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 {options.map((option) => (\n <>\n <FormControlLabel\n value={option.value}\n control={<Radio />}\n label={option.label}\n disabled={isSubmitting || option.disabled}\n />\n {option.selectedContent && field.value === option.value && (\n <StyledSelectedContent>\n {option.selectedContent}\n <Spacer size={8} variant=\"horizontal\" />\n </StyledSelectedContent>\n )}\n </>\n ))}\n </RadioGroup>\n <StyledHelperText showError={showError}>\n {showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\n </StyledHelperText>\n </Box>\n );\n }}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {label && (\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 GenericRadioButtons;\n"],"names":["StyledSelectedContent","styled","Box","theme","marginLeft","spacing","StyledHelperText","Typography","showError","color","palette","error","main","textAlign","label","fieldName","layout","onChange","options","showHelperTextWhenValid","renderField","_jsx","jsx","Field","name","children","field","form","errors","touched","isSubmitting","fieldError","helperText","useRenderValidText","value","_jsxs","sx","paddingRight","RadioGroup","defaultValue","e","setFieldValue","target","map","option","FormControlLabel","control","Radio","disabled","selectedContent","jsxs","Spacer","size","variant","undefined","_Fragment","component","FormItemLayout"],"mappings":"waA0BA,MAAMA,EAAwBC,EAAAA,OAAOC,EAAPD,EAAY,EAAGE,YAAa,CACtDC,WAAYD,EAAME,QAAQ,OAGxBC,EAAmBL,EAAMA,OAACM,EAAPN,EAA2C,EAAGE,QAAOK,gBAAiB,CAC3FC,MAAOD,EAAYL,EAAMO,QAAQC,MAAMC,KAAO,UAC9CC,UAAW,2BAGa,EAAGC,QAAOC,YAAWC,SAAQC,WAAUC,UAASC,2BAA0B,MAClG,MAAMC,EAAc,IAEZC,EAAAC,IAACC,QAAK,CAACC,KAAMT,EACRU,SAAA,EAAGC,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBH,EACpCI,EAAaH,EAAOF,EAAMF,MAC1BhB,IAAcuB,GAAeF,EAAQH,EAAMF,MAC3CQ,EAAaC,EAAmB,CAClCF,aACAvB,YACAqB,UAAWA,EAAQH,EAAMF,MACzBU,MAAOR,EAAMQ,QAGjB,OACIC,OAACjC,EAAG,CAACkC,GAAI,CAAEC,aAAyB,eAAXrB,EAA0B,OAAS,GACxDS,SAAA,CAAAJ,EAAAC,IAACgB,EACmB,CAAA,kBAAA,iCAChBC,aAAa,SACbf,KAAK,sBACLU,MAAOR,EAAMQ,MACbjB,SAAWuB,IAEPb,EAAKc,cAAcf,EAAMF,KAAMgB,EAAEE,OAAOR,OACpCjB,GACAA,EAASuB,EACZ,EACJf,SAEAP,EAAQyB,KAAKC,GACVT,6BACId,EAACC,IAAAuB,EACG,CAAAX,MAAOU,EAAOV,MACdY,QAASzB,EAACC,IAAAyB,MACVjC,MAAO8B,EAAO9B,MACdkC,SAAUlB,GAAgBc,EAAOI,WAEpCJ,EAAOK,iBAAmBvB,EAAMQ,QAAUU,EAAOV,OAC9CC,EAAAe,KAAClD,EAAqB,CAAAyB,SAAA,CACjBmB,EAAOK,gBACR5B,EAAAC,IAAC6B,EAAM,CAACC,KAAM,EAAGC,QAAQ,yBAM7ChC,EAAAA,IAACf,EAAiB,CAAAE,UAAWA,EACxBiB,SAAAjB,GAAyBW,EAAba,OAAoDsB,MAG3E,IAMlB,MAAe,aAAXtC,EAEImB,EAAAe,KAAAK,WAAA,CAAA9B,SAAA,CACKX,GACGO,MAACd,EAAU,CAAC8C,QAAQ,YAAYG,UAAU,KAAK/C,MAAM,cAAagB,SAC7DX,IAGRM,OAKNC,EAAAC,IAACmC,EAAc,CAAC3C,MAAOA,EAAQW,SAAAL,KAA+B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ChangeEvent, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
label?: string;
|
|
6
|
+
fieldName: string;
|
|
7
|
+
layout?: 'horizontal' | 'vertical';
|
|
8
|
+
onChange?: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
9
|
+
showHelperTextWhenValid?: boolean;
|
|
10
|
+
options: {
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
selectedContent?: ReactNode;
|
|
15
|
+
}[];
|
|
16
|
+
};
|
|
17
|
+
declare const GenericRadioButtons: ({ label, fieldName, layout, onChange, options, showHelperTextWhenValid }: Props) => react_jsx_runtime.JSX.Element;
|
|
18
|
+
|
|
19
|
+
export { GenericRadioButtons as default };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{jsxs as e,Fragment as r,jsx as o}from"react/jsx-runtime";import{Field as a}from"formik";import t from"../Form/FormItemLayout.js";import i from"@mui/material/Box";import l from"@mui/material/Typography";import m from"../../custom-hooks/useRenderValidText.js";import n from"@mui/material/Radio";import d from"@mui/material/FormControlLabel";import u from"@mui/material/RadioGroup";import s from"../Spacer/Spacer.js";import{styled as h}from"@mui/material/styles";const p=h(i)((({theme:e})=>({marginLeft:e.spacing(4)}))),c=h(l)((({theme:e,showError:r})=>({color:r?e.palette.error.main:"inherit",textAlign:"right"}))),f=({label:h,fieldName:f,layout:b,onChange:g,options:v,showHelperTextWhenValid:x=!1})=>{const y=()=>o(a,{name:f,children:({field:a,form:t})=>{const{errors:l,touched:h,isSubmitting:f}=t,y=l[a.name],C=!!y&&h[a.name],j=m({fieldError:y,showError:C,touched:!!h[a.name],value:a.value});return e(i,{sx:{paddingRight:"horizontal"===b?"16px":0},children:[o(u,{"aria-labelledby":"demo-radio-buttons-group-label",defaultValue:"female",name:"radio-buttons-group",value:a.value,onChange:e=>{t.setFieldValue(a.name,e.target.value),g&&g(e)},children:v.map((t=>e(r,{children:[o(d,{value:t.value,control:o(n,{}),label:t.label,disabled:f||t.disabled}),t.selectedContent&&a.value===t.value&&e(p,{children:[t.selectedContent,o(s,{size:8,variant:"horizontal"})]})]})))}),o(c,{showError:C,children:C||x?j:void 0})]})}});return"vertical"===b?e(r,{children:[h&&o(l,{variant:"subtitle1",component:"h3",color:"textPrimary",children:h}),y()]}):o(t,{label:h,children:y()})};export{f as default};
|
|
2
|
+
//# sourceMappingURL=GenericRadioButtons.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GenericRadioButtons.js","sources":["../../../../src/components/ui/GenericRadioButtons/GenericRadioButtons.tsx"],"sourcesContent":["import { type FieldProps, Field } from 'formik';\nimport FormItemLayout from '../Form/FormItemLayout';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport useRenderValidText from '../../custom-hooks/useRenderValidText';\nimport Radio from '@mui/material/Radio';\nimport FormControlLabel from '@mui/material/FormControlLabel';\nimport RadioGroup from '@mui/material/RadioGroup';\nimport { ChangeEvent, ReactNode } from 'react';\nimport { Spacer } from '../Spacer';\nimport { styled } from '@mui/material/styles';\n\ntype Props = {\n label?: string;\n fieldName: string;\n layout?: 'horizontal' | 'vertical';\n onChange?: (e: ChangeEvent<HTMLInputElement>) => void;\n showHelperTextWhenValid?: boolean;\n options: {\n label: string;\n value: string;\n disabled?: boolean;\n selectedContent?: ReactNode;\n }[];\n};\n\nconst StyledSelectedContent = styled(Box)(({ theme }) => ({\n marginLeft: theme.spacing(4),\n}));\n\nconst StyledHelperText = styled(Typography)<{ showError: boolean }>(({ theme, showError }) => ({\n color: showError ? theme.palette.error.main : 'inherit',\n textAlign: 'right',\n}));\n\nconst GenericRadioButtons = ({ label, fieldName, layout, onChange, options, showHelperTextWhenValid = false }: Props) => {\n const renderField = () => {\n return (\n <Field name={fieldName}>\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 <Box sx={{ paddingRight: layout === 'horizontal' ? '16px' : 0 }}>\n <RadioGroup\n aria-labelledby=\"demo-radio-buttons-group-label\"\n defaultValue=\"female\"\n name=\"radio-buttons-group\"\n value={field.value}\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 {options.map((option) => (\n <>\n <FormControlLabel\n value={option.value}\n control={<Radio />}\n label={option.label}\n disabled={isSubmitting || option.disabled}\n />\n {option.selectedContent && field.value === option.value && (\n <StyledSelectedContent>\n {option.selectedContent}\n <Spacer size={8} variant=\"horizontal\" />\n </StyledSelectedContent>\n )}\n </>\n ))}\n </RadioGroup>\n <StyledHelperText showError={showError}>\n {showError ? helperText : showHelperTextWhenValid ? helperText : undefined}\n </StyledHelperText>\n </Box>\n );\n }}\n </Field>\n );\n };\n\n if (layout === 'vertical') {\n return (\n <>\n {label && (\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 GenericRadioButtons;\n"],"names":["StyledSelectedContent","styled","Box","theme","marginLeft","spacing","StyledHelperText","Typography","showError","color","palette","error","main","textAlign","GenericRadioButtons","label","fieldName","layout","onChange","options","showHelperTextWhenValid","renderField","_jsx","Field","name","children","field","form","errors","touched","isSubmitting","fieldError","helperText","useRenderValidText","value","_jsxs","sx","paddingRight","RadioGroup","defaultValue","e","setFieldValue","target","map","option","FormControlLabel","control","Radio","disabled","selectedContent","Spacer","size","variant","undefined","_Fragment","component","FormItemLayout"],"mappings":"mdA0BA,MAAMA,EAAwBC,EAAOC,EAAPD,EAAY,EAAGE,YAAa,CACtDC,WAAYD,EAAME,QAAQ,OAGxBC,EAAmBL,EAAOM,EAAPN,EAA2C,EAAGE,QAAOK,gBAAiB,CAC3FC,MAAOD,EAAYL,EAAMO,QAAQC,MAAMC,KAAO,UAC9CC,UAAW,YAGTC,EAAsB,EAAGC,QAAOC,YAAWC,SAAQC,WAAUC,UAASC,2BAA0B,MAClG,MAAMC,EAAc,IAEZC,EAACC,EAAK,CAACC,KAAMR,EACRS,SAAA,EAAGC,QAAOC,WACP,MAAMC,OAAEA,EAAMC,QAAEA,EAAOC,aAAEA,GAAiBH,EACpCI,EAAaH,EAAOF,EAAMF,MAC1BhB,IAAcuB,GAAeF,EAAQH,EAAMF,MAC3CQ,EAAaC,EAAmB,CAClCF,aACAvB,YACAqB,UAAWA,EAAQH,EAAMF,MACzBU,MAAOR,EAAMQ,QAGjB,OACIC,EAACjC,EAAG,CAACkC,GAAI,CAAEC,aAAyB,eAAXpB,EAA0B,OAAS,GACxDQ,SAAA,CAAAH,EAACgB,EACmB,CAAA,kBAAA,iCAChBC,aAAa,SACbf,KAAK,sBACLU,MAAOR,EAAMQ,MACbhB,SAAWsB,IAEPb,EAAKc,cAAcf,EAAMF,KAAMgB,EAAEE,OAAOR,OACpChB,GACAA,EAASsB,EACZ,EACJf,SAEAN,EAAQwB,KAAKC,GACVT,eACIb,EAACuB,EACG,CAAAX,MAAOU,EAAOV,MACdY,QAASxB,EAACyB,MACVhC,MAAO6B,EAAO7B,MACdiC,SAAUlB,GAAgBc,EAAOI,WAEpCJ,EAAOK,iBAAmBvB,EAAMQ,QAAUU,EAAOV,OAC9CC,EAACnC,EAAqB,CAAAyB,SAAA,CACjBmB,EAAOK,gBACR3B,EAAC4B,EAAM,CAACC,KAAM,EAAGC,QAAQ,yBAM7C9B,EAAChB,EAAiB,CAAAE,UAAWA,EACxBiB,SAAAjB,GAAyBY,EAAbY,OAAoDqB,MAG3E,IAMlB,MAAe,aAAXpC,EAEIkB,EAAAmB,EAAA,CAAA7B,SAAA,CACKV,GACGO,EAACf,EAAU,CAAC6C,QAAQ,YAAYG,UAAU,KAAK9C,MAAM,cAAagB,SAC7DV,IAGRM,OAKNC,EAACkC,EAAc,CAACzC,MAAOA,EAAQU,SAAAJ,KAA+B"}
|