@verma-consulting/design-library 0.1.44 → 0.1.45

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.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/index.tsx
32
32
  var index_exports = {};
33
33
  __export(index_exports, {
34
+ CountrySelect: () => CountrySelect_default,
34
35
  EmptyState: () => EmptyState_default,
35
36
  FormDialog: () => FormDialog_default,
36
37
  FormDrawer: () => FormDrawer_default,
@@ -48,11 +49,11 @@ __export(index_exports, {
48
49
  StatusPill: () => StatusPill_default,
49
50
  TabPanel: () => TabPanel_default,
50
51
  TablePagination: () => TablePagination_default,
51
- ThemeProvider: () => import_styles17.ThemeProvider,
52
- createTheme: () => import_styles17.createTheme,
53
- makeStyles: () => import_styles18.makeStyles,
54
- styled: () => import_styles17.styled,
55
- useTheme: () => import_styles17.useTheme
52
+ ThemeProvider: () => import_styles19.ThemeProvider,
53
+ createTheme: () => import_styles19.createTheme,
54
+ makeStyles: () => import_styles20.makeStyles,
55
+ styled: () => import_styles19.styled,
56
+ useTheme: () => import_styles19.useTheme
56
57
  });
57
58
  module.exports = __toCommonJS(index_exports);
58
59
  __reExport(index_exports, require("@mui/material"), module.exports);
@@ -267,8 +268,8 @@ var TablePagination = React.forwardRef(function TablePagination2(props, ref) {
267
268
  var TablePagination_default = TablePagination;
268
269
 
269
270
  // src/index.tsx
270
- var import_styles17 = require("@mui/material/styles");
271
- var import_styles18 = require("@mui/styles");
271
+ var import_styles19 = require("@mui/material/styles");
272
+ var import_styles20 = require("@mui/styles");
272
273
 
273
274
  // src/Logo.tsx
274
275
  var import_react = require("react");
@@ -393,7 +394,10 @@ var import_icons_material = require("@mui/icons-material");
393
394
  var import_jsx_runtime4 = require("react/jsx-runtime");
394
395
  var BootstrapDialog = (0, import_styles2.styled)(import_material3.Dialog)(({ theme }) => ({
395
396
  "& .MuiDialog-paper": {
396
- borderRadius: 24
397
+ borderRadius: 24,
398
+ [theme.breakpoints.down("md")]: {
399
+ borderRadius: 0
400
+ }
397
401
  },
398
402
  "& .MuiDialogContent-root": {
399
403
  padding: theme.spacing(4)
@@ -616,6 +620,17 @@ var import_material5 = require("@mui/material");
616
620
  var import_styles6 = require("@mui/material/styles");
617
621
  var import_icons_material3 = require("@mui/icons-material");
618
622
  var import_jsx_runtime6 = require("react/jsx-runtime");
623
+ var DEFAULT_ACCEPT = "image/jpeg,image/png,image/gif,image/webp,image/avif,image/bmp,image/svg+xml,image/heic,image/heif";
624
+ function isValidImageFile(file) {
625
+ const type = file.type.trim().toLowerCase();
626
+ if (type.startsWith("image/")) {
627
+ return true;
628
+ }
629
+ if (!type && /\.(jpe?g|png|gif|webp|avif|bmp|svg|heic|heif)$/i.test(file.name)) {
630
+ return true;
631
+ }
632
+ return false;
633
+ }
619
634
  var HiddenInput = (0, import_styles6.styled)("input")({
620
635
  position: "absolute",
621
636
  width: 1,
@@ -685,7 +700,7 @@ var ImageUploadAvatar = ({
685
700
  onChange,
686
701
  size = 128,
687
702
  variant = "rounded",
688
- accept = "image/*",
703
+ accept = DEFAULT_ACCEPT,
689
704
  disabled,
690
705
  allowClear = true
691
706
  }) => {
@@ -707,7 +722,12 @@ var ImageUploadAvatar = ({
707
722
  }, [internalSrc]);
708
723
  const handlePick = (e) => {
709
724
  var _a2, _b;
710
- const selected = (_b = (_a2 = e.target.files) == null ? void 0 : _a2[0]) != null ? _b : null;
725
+ const raw = (_b = (_a2 = e.target.files) == null ? void 0 : _a2[0]) != null ? _b : null;
726
+ if (raw && !isValidImageFile(raw)) {
727
+ if (inputRef.current) inputRef.current.value = "";
728
+ return;
729
+ }
730
+ const selected = raw;
711
731
  if (internalSrc == null ? void 0 : internalSrc.startsWith("blob:")) {
712
732
  URL.revokeObjectURL(internalSrc);
713
733
  }
@@ -1550,11 +1570,11 @@ var FormDrawer = ({
1550
1570
  onClose: () => setOpen(false),
1551
1571
  sx: {
1552
1572
  "& .MuiDrawer-paper": {
1553
- width: mdMatches ? "100%" : "64%",
1573
+ width: mdMatches ? "100%" : "72%",
1554
1574
  height: "100%",
1555
1575
  display: "flex",
1556
1576
  flexDirection: "column",
1557
- borderRadius: mdMatches ? "24px 24px 0 0" : "24px 0 0 24px"
1577
+ borderRadius: mdMatches ? 0 : "24px 0 0 24px"
1558
1578
  }
1559
1579
  },
1560
1580
  children: [
@@ -1608,9 +1628,129 @@ var FormDrawer_default = FormDrawer;
1608
1628
  // src/PhoneNumberField.tsx
1609
1629
  var import_react7 = require("react");
1610
1630
  var import_material15 = require("@mui/material");
1631
+ var import_Autocomplete = require("@mui/material/Autocomplete");
1611
1632
  var import_styles16 = require("@mui/material/styles");
1612
1633
  var import_common_library3 = require("@verma-consulting/common-library");
1613
1634
  var import_jsx_runtime17 = require("react/jsx-runtime");
1635
+ var import_react8 = require("react");
1636
+ var EXT_MAX_LEN = 20;
1637
+ var filterCountryOptions = (0, import_Autocomplete.createFilterOptions)({
1638
+ stringify: (option) => `${option.label} ${option.code} ${option.phone}`
1639
+ });
1640
+ function extractExtensionFromMain(main) {
1641
+ let m = main.trim();
1642
+ let extFromMeta = "";
1643
+ const semi = m.match(/;ext=(\d+)/i);
1644
+ if (semi) {
1645
+ extFromMeta = semi[1];
1646
+ m = m.replace(/;ext=\d+/gi, "");
1647
+ }
1648
+ const extWord = m.match(/\bext\.?\s*(\d+)/i);
1649
+ if (extWord) {
1650
+ extFromMeta = extFromMeta || extWord[1];
1651
+ m = m.replace(/\bext\.?\s*\d+/i, "");
1652
+ }
1653
+ return { main: m, extFromMeta };
1654
+ }
1655
+ function parsePhoneValue(raw, countries, defaultCountry) {
1656
+ var _a2, _b, _c, _d;
1657
+ const s = String(raw != null ? raw : "").trim();
1658
+ if (!s) return { dial: "", local: "", extension: "" };
1659
+ const defaultDial = (_b = (_a2 = countries.find((c) => c.code === defaultCountry)) == null ? void 0 : _a2.phone) != null ? _b : "1";
1660
+ let ext = "";
1661
+ let mainPart = s;
1662
+ const xSplit = s.split(/\s*[xX]\s*/);
1663
+ if (xSplit.length > 1) {
1664
+ mainPart = (_c = xSplit[0]) != null ? _c : "";
1665
+ ext = xSplit.slice(1).join("").replace(/\D/g, "").slice(0, EXT_MAX_LEN);
1666
+ }
1667
+ const meta = extractExtensionFromMain(mainPart);
1668
+ mainPart = meta.main;
1669
+ if (meta.extFromMeta) {
1670
+ ext = (ext || meta.extFromMeta).replace(/\D/g, "").slice(0, EXT_MAX_LEN);
1671
+ }
1672
+ const digitsOnly = mainPart.replace(/\D/g, "");
1673
+ if (!digitsOnly) return { dial: "", local: "", extension: ext };
1674
+ const sorted = [...countries].sort(
1675
+ (a, b) => b.phone.length - a.phone.length
1676
+ );
1677
+ if (mainPart.trim().startsWith("+")) {
1678
+ const found2 = sorted.find((c) => digitsOnly.startsWith(c.phone));
1679
+ if (found2) {
1680
+ const rest = digitsOnly.slice(found2.phone.length);
1681
+ const local = found2.phone === "1" ? rest.slice(-10) : rest.slice(-10);
1682
+ return {
1683
+ dial: found2.phone,
1684
+ local,
1685
+ extension: ext
1686
+ };
1687
+ }
1688
+ }
1689
+ const foundDefault = countries.find((c) => c.code === defaultCountry);
1690
+ const dial = (_d = foundDefault == null ? void 0 : foundDefault.phone) != null ? _d : defaultDial;
1691
+ if (dial === "1") {
1692
+ if (digitsOnly.length === 11 && digitsOnly.startsWith("1")) {
1693
+ return {
1694
+ dial: "1",
1695
+ local: digitsOnly.slice(1, 11),
1696
+ extension: ext
1697
+ };
1698
+ }
1699
+ if (digitsOnly.length <= 10) {
1700
+ return {
1701
+ dial: "1",
1702
+ local: digitsOnly.slice(-10),
1703
+ extension: ext
1704
+ };
1705
+ }
1706
+ if (digitsOnly.length > 10) {
1707
+ return {
1708
+ dial: "1",
1709
+ local: digitsOnly.slice(-10),
1710
+ extension: ext
1711
+ };
1712
+ }
1713
+ }
1714
+ const found = sorted.find((c) => digitsOnly.startsWith(c.phone));
1715
+ if (found) {
1716
+ const rest = digitsOnly.slice(found.phone.length);
1717
+ return {
1718
+ dial: found.phone,
1719
+ local: rest.slice(-10),
1720
+ extension: ext
1721
+ };
1722
+ }
1723
+ return {
1724
+ dial,
1725
+ local: digitsOnly.slice(-10),
1726
+ extension: ext
1727
+ };
1728
+ }
1729
+ function buildStoredValue(dial, local, extension) {
1730
+ if (!dial || !local) return "";
1731
+ const core = `+${dial}${local}`;
1732
+ if (extension) return `${core}x${extension}`;
1733
+ return core;
1734
+ }
1735
+ function formatNanpNational(digits) {
1736
+ const d = digits.replace(/\D/g, "").slice(0, 10);
1737
+ if (!d.length) return "";
1738
+ if (d.length <= 3) return d;
1739
+ if (d.length <= 6) return `${d.slice(0, 3)}-${d.slice(3)}`;
1740
+ return `${d.slice(0, 3)}-${d.slice(3, 6)}-${d.slice(6, 10)}`;
1741
+ }
1742
+ function formatOtherNational(local) {
1743
+ const d = local.replace(/\D/g, "").slice(0, 15);
1744
+ if (!d.length) return "";
1745
+ return d.replace(/(\d{3,4})(?=\d)/g, "$1 ").trim();
1746
+ }
1747
+ function formatLineDisplay(dial, localNumber, extension) {
1748
+ if (!localNumber && !extension) return "";
1749
+ const main = dial === "1" ? formatNanpNational(localNumber) : formatOtherNational(localNumber);
1750
+ if (!extension) return main;
1751
+ if (!main) return `x${extension}`;
1752
+ return `${main} x${extension}`;
1753
+ }
1614
1754
  var PhoneNumberField = ({
1615
1755
  value = "",
1616
1756
  onChange,
@@ -1621,6 +1761,7 @@ var PhoneNumberField = ({
1621
1761
  autoFocus = false,
1622
1762
  onBlur
1623
1763
  }) => {
1764
+ var _a2, _b;
1624
1765
  const theme = (0, import_material15.useTheme)();
1625
1766
  const smMatches = (0, import_material15.useMediaQuery)(theme.breakpoints.down("sm"));
1626
1767
  const countries = import_common_library3.constants.COUNTRIES || [];
@@ -1635,65 +1776,67 @@ var PhoneNumberField = ({
1635
1776
  };
1636
1777
  const [country, setCountry] = (0, import_react7.useState)(defaultCountry);
1637
1778
  const [localNumber, setLocalNumber] = (0, import_react7.useState)("");
1779
+ const [extension, setExtension] = (0, import_react7.useState)("");
1638
1780
  const [isFocused, setIsFocused] = (0, import_react7.useState)(false);
1639
1781
  const [selectOpen, setSelectOpen] = (0, import_react7.useState)(false);
1640
1782
  const [ignoreNextOutsideClick, setIgnoreNextOutsideClick] = (0, import_react7.useState)(false);
1783
+ const [bareExtensionX, setBareExtensionX] = (0, import_react7.useState)(false);
1641
1784
  const wrapperRef = (0, import_react7.useRef)(null);
1642
- const parseE164 = (0, import_react7.useCallback)(
1785
+ const applyParsedFromValue = (0, import_react7.useCallback)(
1643
1786
  (val) => {
1644
- const cleaned = (val || "").toString().replace(/\D/g, "");
1645
- if (!cleaned) return { dial: "", local: "" };
1646
- const sorted = [...countries].sort(
1647
- (a, b) => b.phone.length - a.phone.length
1648
- );
1649
- const found = sorted.find((c) => cleaned.startsWith(c.phone));
1650
- if (found) {
1651
- const dial = found.phone;
1652
- const local = cleaned.slice(dial.length);
1653
- return { dial, local: local.slice(-10) };
1787
+ setBareExtensionX(false);
1788
+ const parsed = parsePhoneValue(val, countries, defaultCountry);
1789
+ if (parsed.dial) {
1790
+ const found = countries.find((c) => c.phone === parsed.dial);
1791
+ if (found) setCountry(found.code);
1654
1792
  }
1655
- return { dial: "", local: cleaned.slice(-10) };
1793
+ setLocalNumber(parsed.local);
1794
+ setExtension(parsed.extension);
1656
1795
  },
1657
- [countries]
1796
+ [countries, defaultCountry]
1658
1797
  );
1659
1798
  (0, import_react7.useEffect)(() => {
1660
1799
  if (isFocused) return;
1661
1800
  if (!value) {
1662
1801
  setLocalNumber("");
1802
+ setExtension("");
1803
+ setBareExtensionX(false);
1663
1804
  return;
1664
1805
  }
1665
- const { dial, local } = parseE164(String(value));
1666
- if (dial) {
1667
- const found = countries.find((c) => c.phone === dial);
1668
- if (found) setCountry(found.code);
1669
- }
1670
- setLocalNumber(local);
1671
- }, [value, parseE164, countries, isFocused]);
1672
- const formatLocalNumber = (digits) => {
1673
- const cleaned = digits.replace(/\D/g, "").slice(0, 10);
1674
- let formatted = "";
1675
- if (cleaned.length > 0) formatted += cleaned.slice(0, 3);
1676
- if (cleaned.length > 3) formatted += "-" + cleaned.slice(3, 6);
1677
- if (cleaned.length > 6) formatted += "-" + cleaned.slice(6, 10);
1678
- return formatted;
1679
- };
1806
+ applyParsedFromValue(String(value));
1807
+ }, [value, isFocused, applyParsedFromValue]);
1680
1808
  const commitValue = (0, import_react7.useCallback)(() => {
1681
- var _a2;
1809
+ var _a3;
1682
1810
  const sel = countries.find((c) => c.code === country);
1683
- const dial = (_a2 = sel == null ? void 0 : sel.phone) != null ? _a2 : "";
1684
- if (dial && localNumber) {
1685
- onChange(`+${dial}${localNumber}`);
1811
+ const dial = (_a3 = sel == null ? void 0 : sel.phone) != null ? _a3 : "";
1812
+ onChange(buildStoredValue(dial, localNumber, extension));
1813
+ }, [countries, country, localNumber, extension, onChange]);
1814
+ const handleLocalChange = (e) => {
1815
+ var _a3, _b2;
1816
+ const raw = e.target.value;
1817
+ const parts = raw.split(/\s*[xX]\s*/);
1818
+ const mainRaw = (_a3 = parts[0]) != null ? _a3 : "";
1819
+ const extDigits = parts.slice(1).join("").replace(/\D/g, "").slice(0, EXT_MAX_LEN);
1820
+ const sel = countries.find((c) => c.code === country);
1821
+ const dial = (_b2 = sel == null ? void 0 : sel.phone) != null ? _b2 : "1";
1822
+ const maxLocal = dial === "1" ? 10 : 15;
1823
+ let mainDigits = mainRaw.replace(/\D/g, "");
1824
+ if (dial === "1") {
1825
+ if (mainDigits.length === 11 && mainDigits.startsWith("1")) {
1826
+ mainDigits = mainDigits.slice(1);
1827
+ }
1828
+ mainDigits = mainDigits.slice(0, 10);
1686
1829
  } else {
1687
- onChange("");
1830
+ mainDigits = mainDigits.slice(0, maxLocal);
1688
1831
  }
1689
- }, [countries, country, localNumber, onChange]);
1690
- const handleLocalChange = (e) => {
1691
- const digits = e.target.value.replace(/\D/g, "").slice(0, 10);
1692
- setLocalNumber(digits);
1693
- };
1694
- const handleCountryChange = (e) => {
1695
- setCountry(e.target.value);
1832
+ setLocalNumber(mainDigits);
1833
+ setExtension(extDigits);
1834
+ setBareExtensionX(
1835
+ /[xX]/.test(raw) && extDigits.length === 0
1836
+ );
1696
1837
  };
1838
+ const dialForDisplay = (_b = (_a2 = countries.find((c) => c.code === country)) == null ? void 0 : _a2.phone) != null ? _b : "";
1839
+ const displayLocal = formatLineDisplay(dialForDisplay, localNumber, extension) + (bareExtensionX ? localNumber ? " x" : "x" : "");
1697
1840
  (0, import_react7.useEffect)(() => {
1698
1841
  const onDocMouseDown = (ev) => {
1699
1842
  if (!wrapperRef.current) return;
@@ -1721,6 +1864,7 @@ var PhoneNumberField = ({
1721
1864
  onBlur == null ? void 0 : onBlur();
1722
1865
  }
1723
1866
  };
1867
+ const selectedCountry = countries.find((c) => c.code === country);
1724
1868
  return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1725
1869
  import_material15.Box,
1726
1870
  {
@@ -1737,52 +1881,77 @@ var PhoneNumberField = ({
1737
1881
  sx: { width: "100%" },
1738
1882
  children: [
1739
1883
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1740
- import_material15.TextField,
1884
+ import_material15.Autocomplete,
1741
1885
  {
1742
- select: true,
1743
- value: country,
1744
- onChange: handleCountryChange,
1745
1886
  disabled,
1887
+ options: countries,
1888
+ value: selectedCountry != null ? selectedCountry : null,
1889
+ onChange: (_, newValue) => {
1890
+ if (newValue) setCountry(newValue.code);
1891
+ },
1892
+ getOptionLabel: (option) => `(+${option.phone})`,
1893
+ filterOptions: filterCountryOptions,
1894
+ isOptionEqualToValue: (a, b) => a.code === b.code,
1895
+ disableClearable: true,
1746
1896
  size,
1897
+ onOpen: () => {
1898
+ setSelectOpen(true);
1899
+ setIgnoreNextOutsideClick(true);
1900
+ },
1901
+ onClose: () => setSelectOpen(false),
1747
1902
  sx: {
1748
- width: 140,
1903
+ width: smMatches ? 64 : 108,
1904
+ minWidth: smMatches ? 64 : 108,
1905
+ maxWidth: smMatches ? 64 : 108,
1906
+ flexShrink: 0,
1749
1907
  "& .MuiOutlinedInput-root": {
1750
1908
  borderTopRightRadius: 0,
1751
1909
  borderBottomRightRadius: 0,
1752
1910
  ...glassInputSx
1753
- }
1754
- },
1755
- SelectProps: {
1756
- renderValue: (val) => {
1757
- const code = typeof val === "string" ? val : defaultCountry.toUpperCase();
1758
- const c = countries.find((x) => x.code === code);
1759
- return c ? `${c.code} (+${c.phone})` : code;
1760
- },
1761
- onOpen: () => {
1762
- setSelectOpen(true);
1763
- setIgnoreNextOutsideClick(true);
1764
1911
  },
1765
- onClose: () => setSelectOpen(false)
1912
+ "& .MuiInputBase-input": {
1913
+ overflow: "hidden",
1914
+ textOverflow: "ellipsis",
1915
+ whiteSpace: "nowrap"
1916
+ }
1766
1917
  },
1767
- children: countries.map((option) => /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_material15.MenuItem, { value: option.code, children: [
1768
- option.code,
1769
- " (+",
1770
- option.phone,
1771
- ")"
1772
- ] }, option.code))
1918
+ renderOption: (props, option) => /* @__PURE__ */ (0, import_react8.createElement)(import_material15.Box, { component: "li", ...props, key: option.code }, /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1919
+ import_material15.Box,
1920
+ {
1921
+ component: "img",
1922
+ loading: "lazy",
1923
+ width: 20,
1924
+ alt: "",
1925
+ src: `https://flagcdn.com/w20/${option.code.toLowerCase()}.png`,
1926
+ srcSet: `https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`,
1927
+ sx: { mr: 1, flexShrink: 0 }
1928
+ }
1929
+ ), option.code, " (+", option.phone, ")"),
1930
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1931
+ import_material15.TextField,
1932
+ {
1933
+ ...params,
1934
+ variant: "outlined",
1935
+ size,
1936
+ inputProps: {
1937
+ ...params.inputProps,
1938
+ autoComplete: "tel-country"
1939
+ }
1940
+ }
1941
+ )
1773
1942
  }
1774
1943
  ),
1775
1944
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1776
1945
  import_material15.TextField,
1777
1946
  {
1778
1947
  label,
1779
- value: localNumber ? formatLocalNumber(localNumber) : "",
1948
+ value: displayLocal,
1780
1949
  onChange: handleLocalChange,
1781
- placeholder: " - - ",
1950
+ placeholder: "415-555-0100 x123",
1782
1951
  inputProps: {
1783
- inputMode: "numeric",
1784
- pattern: "[0-9]*",
1785
- maxLength: 12
1952
+ inputMode: "text",
1953
+ autoComplete: "tel-national",
1954
+ "aria-label": label
1786
1955
  },
1787
1956
  disabled,
1788
1957
  size,
@@ -1804,8 +1973,207 @@ var PhoneNumberField = ({
1804
1973
  );
1805
1974
  };
1806
1975
  var PhoneNumberField_default = PhoneNumberField;
1976
+
1977
+ // src/CountrySelect.tsx
1978
+ var import_react9 = require("react");
1979
+ var import_material16 = require("@mui/material");
1980
+ var import_styles17 = require("@mui/material/styles");
1981
+ var import_styles18 = require("@mui/styles");
1982
+ var import_common_library4 = require("@verma-consulting/common-library");
1983
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1984
+ var import_react10 = require("react");
1985
+ var useStyles3 = (0, import_styles18.makeStyles)((theme) => ({
1986
+ defaultMode: {
1987
+ margin: "4px",
1988
+ paddingTop: 14,
1989
+ paddingBottom: 14,
1990
+ paddingLeft: 8,
1991
+ paddingRight: 8,
1992
+ cursor: "pointer",
1993
+ borderRadius: 8,
1994
+ border: `1px solid ${(0, import_styles17.alpha)("#FFFFFF", theme.palette.mode === "dark" ? 0.16 : 0.55)}`,
1995
+ backdropFilter: "blur(14px) saturate(150%)",
1996
+ background: theme.palette.mode === "dark" ? "linear-gradient(160deg, rgba(31,41,55,0.78), rgba(17,24,39,0.68))" : "linear-gradient(160deg, rgba(255,255,255,0.9), rgba(245,249,255,0.72))",
1997
+ "&:hover": {
1998
+ boxShadow: theme.palette.mode === "dark" ? "rgba(0, 0, 0, 0.34) 0px 10px 26px" : "rgba(15, 23, 42, 0.16) 0px 8px 24px"
1999
+ }
2000
+ },
2001
+ formLabel: {
2002
+ cursor: "pointer"
2003
+ },
2004
+ formValue: {
2005
+ cursor: "pointer",
2006
+ wordBreak: "break-word",
2007
+ whiteSpace: "pre-wrap"
2008
+ }
2009
+ }));
2010
+ var COUNTRIES = import_common_library4.constants.COUNTRIES;
2011
+ var CountrySelect = ({
2012
+ value,
2013
+ onChange,
2014
+ label = "Country",
2015
+ size = "small",
2016
+ disabled = false,
2017
+ style = {}
2018
+ }) => {
2019
+ const theme = (0, import_styles17.useTheme)();
2020
+ const classes = useStyles3();
2021
+ const [editMode, setEditMode] = (0, import_react9.useState)(false);
2022
+ const glassBackground = theme.palette.mode === "dark" ? "linear-gradient(160deg, rgba(31,41,55,0.78), rgba(17,24,39,0.68))" : "linear-gradient(160deg, rgba(255,255,255,0.9), rgba(245,249,255,0.72))";
2023
+ const handleBlur = () => {
2024
+ setTimeout(() => setEditMode(false), 15);
2025
+ };
2026
+ const selectedOption = COUNTRIES.find((country) => country.code === value);
2027
+ if (!editMode) {
2028
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2029
+ "div",
2030
+ {
2031
+ onClick: () => !disabled && setEditMode(true),
2032
+ className: classes.defaultMode,
2033
+ style,
2034
+ children: [
2035
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material16.FormLabel, { className: classes.formLabel, children: label }),
2036
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2037
+ import_material16.Box,
2038
+ {
2039
+ sx: {
2040
+ display: "flex",
2041
+ alignItems: "center",
2042
+ gap: 1,
2043
+ mt: 0.25
2044
+ },
2045
+ children: [
2046
+ selectedOption ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2047
+ import_material16.Box,
2048
+ {
2049
+ component: "img",
2050
+ loading: "lazy",
2051
+ width: 20,
2052
+ alt: "",
2053
+ src: `https://flagcdn.com/w20/${selectedOption.code.toLowerCase()}.png`,
2054
+ srcSet: `https://flagcdn.com/w40/${selectedOption.code.toLowerCase()}.png 2x`,
2055
+ sx: { flexShrink: 0 }
2056
+ }
2057
+ ) : null,
2058
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_material16.Typography, { className: classes.formValue, component: "span", children: (selectedOption == null ? void 0 : selectedOption.label) || "\u2013" })
2059
+ ]
2060
+ }
2061
+ )
2062
+ ]
2063
+ }
2064
+ );
2065
+ }
2066
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2067
+ import_material16.Autocomplete,
2068
+ {
2069
+ disabled,
2070
+ options: COUNTRIES,
2071
+ getOptionLabel: (option) => option.label,
2072
+ autoHighlight: true,
2073
+ openOnFocus: true,
2074
+ disableClearable: true,
2075
+ value: selectedOption != null ? selectedOption : void 0,
2076
+ onChange: (_, newValue) => {
2077
+ if (newValue != null) onChange(newValue);
2078
+ },
2079
+ onBlur: handleBlur,
2080
+ sx: style,
2081
+ size,
2082
+ componentsProps: {
2083
+ paper: {
2084
+ sx: {
2085
+ background: glassBackground,
2086
+ backdropFilter: "blur(12px) saturate(150%)",
2087
+ border: `1px solid ${(0, import_styles17.alpha)("#FFFFFF", theme.palette.mode === "dark" ? 0.16 : 0.55)}`,
2088
+ boxShadow: theme.palette.mode === "dark" ? "rgba(0, 0, 0, 0.34) 0px 10px 26px" : "rgba(15, 23, 42, 0.16) 0px 8px 24px",
2089
+ "& .MuiAutocomplete-option": {
2090
+ "&[aria-selected='true']": {
2091
+ backgroundColor: (0, import_styles17.alpha)(
2092
+ theme.palette.primary.main,
2093
+ theme.palette.mode === "dark" ? 0.28 : 0.14
2094
+ )
2095
+ },
2096
+ "&.Mui-focused": {
2097
+ backgroundColor: (0, import_styles17.alpha)(
2098
+ theme.palette.primary.main,
2099
+ theme.palette.mode === "dark" ? 0.2 : 0.1
2100
+ )
2101
+ }
2102
+ }
2103
+ }
2104
+ }
2105
+ },
2106
+ renderOption: (props, option) => /* @__PURE__ */ (0, import_react10.createElement)(import_material16.Box, { component: "li", ...props, key: option.code }, /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2107
+ "img",
2108
+ {
2109
+ loading: "lazy",
2110
+ width: "20",
2111
+ src: `https://flagcdn.com/w20/${option.code.toLowerCase()}.png`,
2112
+ srcSet: `https://flagcdn.com/w40/${option.code.toLowerCase()}.png 2x`,
2113
+ alt: "",
2114
+ style: { marginRight: 8, flexShrink: 0 }
2115
+ }
2116
+ ), option.label, " (", option.code, ")"),
2117
+ renderInput: (params) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2118
+ import_material16.TextField,
2119
+ {
2120
+ ...params,
2121
+ label,
2122
+ variant: "outlined",
2123
+ size,
2124
+ inputProps: {
2125
+ ...params.inputProps,
2126
+ autoComplete: "new-password"
2127
+ },
2128
+ InputProps: {
2129
+ ...params.InputProps,
2130
+ startAdornment: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2131
+ selectedOption ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2132
+ import_material16.Box,
2133
+ {
2134
+ component: "img",
2135
+ loading: "lazy",
2136
+ width: 20,
2137
+ alt: "",
2138
+ src: `https://flagcdn.com/w20/${selectedOption.code.toLowerCase()}.png`,
2139
+ srcSet: `https://flagcdn.com/w40/${selectedOption.code.toLowerCase()}.png 2x`,
2140
+ sx: { mr: 1, flexShrink: 0, alignSelf: "center" }
2141
+ }
2142
+ ) : null,
2143
+ params.InputProps.startAdornment
2144
+ ] }),
2145
+ sx: {
2146
+ borderRadius: 2,
2147
+ backdropFilter: "blur(10px)",
2148
+ background: glassBackground,
2149
+ color: "text.primary",
2150
+ "&.Mui-focused": {
2151
+ background: glassBackground
2152
+ },
2153
+ "&:hover": {
2154
+ background: glassBackground
2155
+ },
2156
+ "& .MuiInputBase-input": {
2157
+ color: "text.primary",
2158
+ WebkitTextFillColor: "currentColor"
2159
+ },
2160
+ "& .MuiOutlinedInput-notchedOutline": {
2161
+ borderColor: (0, import_styles17.alpha)(
2162
+ "#FFFFFF",
2163
+ theme.palette.mode === "dark" ? 0.18 : 0.6
2164
+ )
2165
+ }
2166
+ }
2167
+ }
2168
+ }
2169
+ )
2170
+ }
2171
+ );
2172
+ };
2173
+ var CountrySelect_default = CountrySelect;
1807
2174
  // Annotate the CommonJS export names for ESM import in node:
1808
2175
  0 && (module.exports = {
2176
+ CountrySelect,
1809
2177
  EmptyState,
1810
2178
  FormDialog,
1811
2179
  FormDrawer,