@ews-admin/global-design-system 1.1.14 → 1.1.15

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.
Files changed (37) hide show
  1. package/dist/components/Logo/Logo.d.ts +3 -27
  2. package/dist/components/Logo/Logo.d.ts.map +1 -1
  3. package/dist/components/Logo/Logo.types.d.ts +41 -0
  4. package/dist/components/Logo/Logo.types.d.ts.map +1 -0
  5. package/dist/components/Logo/index.d.ts +1 -1
  6. package/dist/components/Logo/index.d.ts.map +1 -1
  7. package/dist/components/Logo/logoAssets.d.ts +1 -0
  8. package/dist/components/Logo/logoAssets.d.ts.map +1 -0
  9. package/dist/components/SearchAutocomplete/SearchAutocomplete.d.ts +1 -1
  10. package/dist/components/SearchAutocomplete/SearchAutocomplete.d.ts.map +1 -1
  11. package/dist/components/Select/Select.d.ts +3 -3
  12. package/dist/components/Select/Select.d.ts.map +1 -1
  13. package/dist/hooks/useSelectField.d.ts +4 -4
  14. package/dist/hooks/useSelectField.d.ts.map +1 -1
  15. package/dist/icons/Icon.d.ts +1 -1
  16. package/dist/icons/Icon.d.ts.map +1 -1
  17. package/dist/index.css +2 -2
  18. package/dist/index.d.ts +30 -14
  19. package/dist/index.esm.css +2 -2
  20. package/dist/index.esm.js +55 -21
  21. package/dist/index.esm.js.map +1 -1
  22. package/dist/index.js +54 -20
  23. package/dist/index.js.map +1 -1
  24. package/dist/styles/theme-variables.css +62 -0
  25. package/dist/utils/index.d.ts +2 -2
  26. package/dist/utils/index.d.ts.map +1 -1
  27. package/package.json +1 -1
  28. package/src/components/Logo/Logo.tsx +65 -45
  29. package/src/components/Logo/Logo.types.ts +42 -0
  30. package/src/components/Logo/index.ts +1 -1
  31. package/src/components/SearchAutocomplete/SearchAutocomplete.tsx +1 -1
  32. package/src/components/Select/Select.tsx +21 -8
  33. package/src/hooks/useSelectField.ts +7 -2
  34. package/src/icons/Icon.tsx +1 -1
  35. package/src/styles/index.css +0 -32
  36. package/src/utils/index.ts +5 -3
  37. package/tailwind.preset.js +23 -23
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
- import React, { forwardRef, createElement, useState, useId, useRef, useEffect, useCallback, createContext, useContext } from 'react';
2
+ import React, { forwardRef, createElement, useState, useId, useRef, useCallback, useEffect, createContext, useContext } from 'react';
3
3
 
4
4
  function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
5
5
 
@@ -73,13 +73,15 @@ const formatNumeric = (value) => {
73
73
  };
74
74
  /**
75
75
  * Utility function to validate phone numbers
76
- * Validates phone numbers with 1-15 digits, starting with a non-zero digit
76
+ * Validates phone numbers with 1-17 digits, optionally starting with + symbol
77
77
  * @param value - Phone number string to validate
78
78
  * @returns Boolean indicating if the phone number is valid
79
79
  */
80
80
  function isValidPhoneNumber(value) {
81
81
  const trimmedValue = value.trim();
82
- const phoneRegex = /^[0-9]\d{1,17}$/;
82
+ // Allow + at the beginning, followed by 1-17 digits
83
+ // Or just 1-17 digits without +
84
+ const phoneRegex = /^(\+\d{1,17}|\d{1,17})$/;
83
85
  return phoneRegex.test(trimmedValue);
84
86
  }
85
87
 
@@ -515,7 +517,7 @@ const Select = forwardRef(({ options = [], value, onChange, placeholder = "Selec
515
517
  ? options.filter((option) => option.label.toLowerCase().includes(searchTerm.toLowerCase()))
516
518
  : options;
517
519
  // Calculate dropdown position based on available space
518
- const calculateDropdownPosition = () => {
520
+ const calculateDropdownPosition = useCallback(() => {
519
521
  if (!containerRef.current)
520
522
  return;
521
523
  const containerRect = containerRef.current.getBoundingClientRect();
@@ -546,7 +548,7 @@ const Select = forwardRef(({ options = [], value, onChange, placeholder = "Selec
546
548
  else {
547
549
  setDropdownPosition("bottom");
548
550
  }
549
- };
551
+ }, [filteredOptions.length, searchable, maxHeight]);
550
552
  // Alternative calculation using actual dropdown element when available
551
553
  const calculateDropdownPositionWithElement = () => {
552
554
  if (!containerRef.current || !dropdownRef.current)
@@ -596,7 +598,13 @@ const Select = forwardRef(({ options = [], value, onChange, placeholder = "Selec
596
598
  calculateDropdownPositionWithElement();
597
599
  });
598
600
  }
599
- }, [isOpen, filteredOptions.length, searchable, maxHeight]);
601
+ }, [
602
+ isOpen,
603
+ filteredOptions.length,
604
+ searchable,
605
+ maxHeight,
606
+ calculateDropdownPosition,
607
+ ]);
600
608
  // Recalculate position on window resize
601
609
  useEffect(() => {
602
610
  const handleResize = () => {
@@ -610,7 +618,7 @@ const Select = forwardRef(({ options = [], value, onChange, placeholder = "Selec
610
618
  window.removeEventListener("resize", handleResize);
611
619
  window.removeEventListener("scroll", handleResize);
612
620
  };
613
- }, [isOpen]);
621
+ }, [isOpen, calculateDropdownPosition]);
614
622
  // Handle keyboard navigation
615
623
  const handleKeyDown = (event) => {
616
624
  if (disabled)
@@ -1719,7 +1727,7 @@ const DropdownMultiSelect = ({ options, name, control, placeholder = "Select opt
1719
1727
  }), error && jsx("p", { className: "mt-1 text-sm text-ews-error", children: error })] }));
1720
1728
  };
1721
1729
 
1722
- const Logo = ({ size = "md", showTagline: _showTagline = true, iconOnly = false, variant = "normal", className, onClick, }) => {
1730
+ const Logo = ({ size = "md", showTagline: _showTagline = true, iconOnly = false, variant = "normal", className, onClick, customSrc, alt = "MEDECINE 360 Logo", clickable = false, }) => {
1723
1731
  const sizes = {
1724
1732
  sm: "h-8",
1725
1733
  md: "h-12",
@@ -1732,21 +1740,47 @@ const Logo = ({ size = "md", showTagline: _showTagline = true, iconOnly = false,
1732
1740
  lg: "h-12 w-12",
1733
1741
  xl: "h-16 w-16",
1734
1742
  };
1735
- // Get the appropriate logo image based on variant
1736
- // For iconOnly, always use favicon.ico
1737
- const logoSrc = iconOnly
1738
- ? "/favicon.ico"
1739
- : variant === "white"
1740
- ? "/image/logoWhite.png"
1741
- : variant === "fullWhite"
1742
- ? "/image/logoFullWhite.png"
1743
- : variant === "favicon"
1744
- ? "/favicon.ico"
1745
- : "/image/logo.png";
1743
+ // Get the appropriate logo image based on variant or custom source
1744
+ // For iconOnly, always use favicon.ico unless customSrc is provided
1745
+ const logoSrc = customSrc ||
1746
+ (iconOnly
1747
+ ? "/favicon.ico"
1748
+ : variant === "white"
1749
+ ? "/image/logoWhite.png"
1750
+ : variant === "fullWhite"
1751
+ ? "/image/logoFullWhite.png"
1752
+ : variant === "favicon"
1753
+ ? "/favicon.ico"
1754
+ : "/image/logo.png");
1755
+ const isClickable = clickable || !!onClick;
1746
1756
  if (iconOnly) {
1747
- return (jsx("div", { className: cn("flex items-center justify-center", iconSizes[size], className), onClick: onClick, role: onClick ? "button" : undefined, tabIndex: onClick ? 0 : undefined, children: jsx("img", { src: logoSrc, alt: "MEDECINE 360 Logo", className: "w-full h-full object-contain" }) }));
1757
+ return (jsx("div", { className: cn("flex items-center justify-center", iconSizes[size], isClickable && "cursor-pointer", className), onClick: onClick, role: isClickable ? "button" : undefined, tabIndex: isClickable ? 0 : undefined, onKeyDown: isClickable
1758
+ ? (e) => {
1759
+ if (e.key === "Enter" || e.key === " ") {
1760
+ e.preventDefault();
1761
+ onClick?.();
1762
+ }
1763
+ }
1764
+ : undefined, children: jsx("img", { src: logoSrc, alt: alt, className: "object-contain w-full h-full", onError: (e) => {
1765
+ // Fallback to favicon if image fails to load
1766
+ if (logoSrc !== "/favicon.ico") {
1767
+ e.target.src = "/favicon.ico";
1768
+ }
1769
+ } }) }));
1748
1770
  }
1749
- return (jsx("div", { className: cn("flex items-center", sizes[size], className), onClick: onClick, role: onClick ? "button" : undefined, tabIndex: onClick ? 0 : undefined, children: jsx("img", { src: logoSrc, alt: "MEDECINE 360 Logo", className: "h-full w-auto object-contain" }) }));
1771
+ return (jsx("div", { className: cn("flex items-center", sizes[size], isClickable && "cursor-pointer", className), onClick: onClick, role: isClickable ? "button" : undefined, tabIndex: isClickable ? 0 : undefined, onKeyDown: isClickable
1772
+ ? (e) => {
1773
+ if (e.key === "Enter" || e.key === " ") {
1774
+ e.preventDefault();
1775
+ onClick?.();
1776
+ }
1777
+ }
1778
+ : undefined, children: jsx("img", { src: logoSrc, alt: alt, className: "object-contain w-auto h-full", onError: (e) => {
1779
+ // Fallback to favicon if image fails to load
1780
+ if (logoSrc !== "/favicon.ico") {
1781
+ e.target.src = "/favicon.ico";
1782
+ }
1783
+ } }) }));
1750
1784
  };
1751
1785
 
1752
1786
  const PROMED_THEME = {