formik-form-components 0.2.19 → 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 CHANGED
@@ -325,6 +325,8 @@ interface AppPhoneNoInputProps {
325
325
  name: string;
326
326
  label?: string;
327
327
  required?: boolean;
328
+ defaultCountry?: string;
329
+ placeholder?: string;
328
330
  sx?: SxProps<Theme>;
329
331
  containerSx?: SxProps<Theme>;
330
332
  labelSx?: SxProps<Theme>;
package/dist/index.js CHANGED
@@ -1506,7 +1506,9 @@ var AppMultiSelector_default = AppMultiSelector;
1506
1506
  var AppPhoneNoInput = ({
1507
1507
  name,
1508
1508
  label,
1509
- required,
1509
+ required = false,
1510
+ defaultCountry = "us",
1511
+ placeholder,
1510
1512
  sx,
1511
1513
  containerSx,
1512
1514
  labelSx,
@@ -1514,18 +1516,21 @@ var AppPhoneNoInput = ({
1514
1516
  errorSx,
1515
1517
  ...otherProps
1516
1518
  }) => {
1517
- const { values, errors, touched, setFieldValue, getFieldProps } = formik.useFormikContext();
1518
- const fieldError = _19__default.default.get(errors, name);
1519
- const isTouched = _19__default.default.get(touched, name);
1519
+ const { values, errors, touched, setFieldValue, setFieldTouched } = formik.useFormikContext();
1520
+ const fieldError = react.useMemo(() => _19__default.default.get(errors, name), [errors, name]);
1521
+ const isTouched = react.useMemo(() => _19__default.default.get(touched, name), [touched, name]);
1520
1522
  return /* @__PURE__ */ jsxRuntime.jsxs(material.Box, { sx: [{ mb: 2 }, containerSx, sx], children: [
1521
1523
  label && /* @__PURE__ */ jsxRuntime.jsxs(
1522
1524
  material.Typography,
1523
1525
  {
1524
1526
  variant: "subtitle2",
1525
- sx: [{
1526
- mb: 0.5,
1527
- color: isTouched && fieldError ? "error.main" : "text.primary"
1528
- }, labelSx],
1527
+ sx: [
1528
+ {
1529
+ mb: 0.5,
1530
+ color: isTouched && fieldError ? "error.main" : "text.primary"
1531
+ },
1532
+ labelSx
1533
+ ],
1529
1534
  children: [
1530
1535
  label,
1531
1536
  required && /* @__PURE__ */ jsxRuntime.jsx(
@@ -1545,8 +1550,17 @@ var AppPhoneNoInput = ({
1545
1550
  /* @__PURE__ */ jsxRuntime.jsx(
1546
1551
  PhoneInput__default.default,
1547
1552
  {
1548
- country: "us",
1553
+ country: defaultCountry,
1549
1554
  specialLabel: "",
1555
+ placeholder,
1556
+ inputProps: {
1557
+ name,
1558
+ id: name,
1559
+ required,
1560
+ "aria-describedby": fieldError ? `${name}-error` : void 0,
1561
+ "aria-invalid": !!fieldError,
1562
+ "aria-required": required
1563
+ },
1550
1564
  inputStyle: {
1551
1565
  width: "100%",
1552
1566
  border: isTouched && fieldError ? "1px solid #f44336" : "1px solid #ccc",
@@ -1558,24 +1572,25 @@ var AppPhoneNoInput = ({
1558
1572
  width: "100%"
1559
1573
  },
1560
1574
  ...otherProps,
1561
- ...getFieldProps(name),
1562
1575
  value: values[name],
1563
- onChange: (value) => setFieldValue(name, value)
1576
+ onChange: (value) => setFieldValue(name, value),
1577
+ onBlur: () => setFieldTouched(name, true)
1564
1578
  }
1565
1579
  ),
1566
- isTouched && fieldError && /* @__PURE__ */ jsxRuntime.jsxs(
1580
+ isTouched && fieldError && /* @__PURE__ */ jsxRuntime.jsx(
1567
1581
  material.Typography,
1568
1582
  {
1569
1583
  variant: "caption",
1570
- sx: [{
1571
- mt: 0.5,
1572
- display: "block",
1573
- color: "error.main"
1574
- }, errorSx],
1575
- children: [
1576
- String(fieldError),
1577
- " "
1578
- ]
1584
+ id: `${name}-error`,
1585
+ sx: [
1586
+ {
1587
+ mt: 0.5,
1588
+ display: "block",
1589
+ color: "error.main"
1590
+ },
1591
+ errorSx
1592
+ ],
1593
+ children: String(fieldError)
1579
1594
  }
1580
1595
  )
1581
1596
  ] });