formik-form-components 0.2.20 → 0.2.21
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/index.d.ts +2 -0
- package/dist/index.js +36 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useFormikContext, Formik, Form as Form$1, ErrorMessage } from 'formik';
|
|
2
|
-
import { forwardRef, memo, createElement, useState, useEffect } from 'react';
|
|
2
|
+
import { forwardRef, memo, createElement, useState, useMemo, useEffect } from 'react';
|
|
3
3
|
import { Box, useTheme, FormControl, Typography, FormHelperText, TextField, InputLabel, FormLabel, RadioGroup, FormControlLabel, Radio, Stack, Rating, Autocomplete, MenuItem, Chip, Switch, InputAdornment, IconButton, Checkbox, Tooltip, Dialog, DialogTitle, DialogContent, DialogActions, Button, CircularProgress, Paper, Menu } from '@mui/material';
|
|
4
4
|
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
|
5
5
|
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
@@ -1478,7 +1478,9 @@ var AppMultiSelector_default = AppMultiSelector;
|
|
|
1478
1478
|
var AppPhoneNoInput = ({
|
|
1479
1479
|
name,
|
|
1480
1480
|
label,
|
|
1481
|
-
required,
|
|
1481
|
+
required = false,
|
|
1482
|
+
defaultCountry = "us",
|
|
1483
|
+
placeholder,
|
|
1482
1484
|
sx,
|
|
1483
1485
|
containerSx,
|
|
1484
1486
|
labelSx,
|
|
@@ -1486,18 +1488,21 @@ var AppPhoneNoInput = ({
|
|
|
1486
1488
|
errorSx,
|
|
1487
1489
|
...otherProps
|
|
1488
1490
|
}) => {
|
|
1489
|
-
const { values, errors, touched, setFieldValue,
|
|
1490
|
-
const fieldError = _19.get(errors, name);
|
|
1491
|
-
const isTouched = _19.get(touched, name);
|
|
1491
|
+
const { values, errors, touched, setFieldValue, setFieldTouched } = useFormikContext();
|
|
1492
|
+
const fieldError = useMemo(() => _19.get(errors, name), [errors, name]);
|
|
1493
|
+
const isTouched = useMemo(() => _19.get(touched, name), [touched, name]);
|
|
1492
1494
|
return /* @__PURE__ */ jsxs(Box, { sx: [{ mb: 2 }, containerSx, sx], children: [
|
|
1493
1495
|
label && /* @__PURE__ */ jsxs(
|
|
1494
1496
|
Typography,
|
|
1495
1497
|
{
|
|
1496
1498
|
variant: "subtitle2",
|
|
1497
|
-
sx: [
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1499
|
+
sx: [
|
|
1500
|
+
{
|
|
1501
|
+
mb: 0.5,
|
|
1502
|
+
color: isTouched && fieldError ? "error.main" : "text.primary"
|
|
1503
|
+
},
|
|
1504
|
+
labelSx
|
|
1505
|
+
],
|
|
1501
1506
|
children: [
|
|
1502
1507
|
label,
|
|
1503
1508
|
required && /* @__PURE__ */ jsx(
|
|
@@ -1517,8 +1522,17 @@ var AppPhoneNoInput = ({
|
|
|
1517
1522
|
/* @__PURE__ */ jsx(
|
|
1518
1523
|
PhoneInput,
|
|
1519
1524
|
{
|
|
1520
|
-
country:
|
|
1525
|
+
country: defaultCountry,
|
|
1521
1526
|
specialLabel: "",
|
|
1527
|
+
placeholder,
|
|
1528
|
+
inputProps: {
|
|
1529
|
+
name,
|
|
1530
|
+
id: name,
|
|
1531
|
+
required,
|
|
1532
|
+
"aria-describedby": fieldError ? `${name}-error` : void 0,
|
|
1533
|
+
"aria-invalid": !!fieldError,
|
|
1534
|
+
"aria-required": required
|
|
1535
|
+
},
|
|
1522
1536
|
inputStyle: {
|
|
1523
1537
|
width: "100%",
|
|
1524
1538
|
border: isTouched && fieldError ? "1px solid #f44336" : "1px solid #ccc",
|
|
@@ -1530,24 +1544,25 @@ var AppPhoneNoInput = ({
|
|
|
1530
1544
|
width: "100%"
|
|
1531
1545
|
},
|
|
1532
1546
|
...otherProps,
|
|
1533
|
-
...getFieldProps(name),
|
|
1534
1547
|
value: values[name],
|
|
1535
|
-
onChange: (value) => setFieldValue(name, value)
|
|
1548
|
+
onChange: (value) => setFieldValue(name, value),
|
|
1549
|
+
onBlur: () => setFieldTouched(name, true)
|
|
1536
1550
|
}
|
|
1537
1551
|
),
|
|
1538
|
-
isTouched && fieldError && /* @__PURE__ */
|
|
1552
|
+
isTouched && fieldError && /* @__PURE__ */ jsx(
|
|
1539
1553
|
Typography,
|
|
1540
1554
|
{
|
|
1541
1555
|
variant: "caption",
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
]
|
|
1556
|
+
id: `${name}-error`,
|
|
1557
|
+
sx: [
|
|
1558
|
+
{
|
|
1559
|
+
mt: 0.5,
|
|
1560
|
+
display: "block",
|
|
1561
|
+
color: "error.main"
|
|
1562
|
+
},
|
|
1563
|
+
errorSx
|
|
1564
|
+
],
|
|
1565
|
+
children: String(fieldError)
|
|
1551
1566
|
}
|
|
1552
1567
|
)
|
|
1553
1568
|
] });
|