@universe-platform/ui 0.1.0-beta.15 → 0.1.0-beta.16

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/phone.d.mts CHANGED
@@ -34,5 +34,12 @@ declare function isValidPhoneNumber(phone: string): boolean;
34
34
  * @returns WhatsApp URL or null if phone is empty
35
35
  */
36
36
  declare function generateWhatsAppLink(phone: string, defaultCountryCode?: string): string | null;
37
+ /**
38
+ * Normalizes a phone number for WhatsApp sending (E.164 without leading '+').
39
+ * - Strips spaces, dashes, and special characters.
40
+ * - If it starts with '05' (10 digits), replaces the leading '0' with '972' (e.g., '0586812807' -> '972586812807').
41
+ * - If it starts with '+', strips the '+'.
42
+ */
43
+ declare function normalizePhoneForWhatsApp(phone: string): string;
37
44
 
38
- export { formatPhoneDisplay, generateWhatsAppLink, isValidPhoneNumber, openWhatsAppChat, sanitizePhoneNumber };
45
+ export { formatPhoneDisplay, generateWhatsAppLink, isValidPhoneNumber, normalizePhoneForWhatsApp, openWhatsAppChat, sanitizePhoneNumber };
package/dist/phone.d.ts CHANGED
@@ -34,5 +34,12 @@ declare function isValidPhoneNumber(phone: string): boolean;
34
34
  * @returns WhatsApp URL or null if phone is empty
35
35
  */
36
36
  declare function generateWhatsAppLink(phone: string, defaultCountryCode?: string): string | null;
37
+ /**
38
+ * Normalizes a phone number for WhatsApp sending (E.164 without leading '+').
39
+ * - Strips spaces, dashes, and special characters.
40
+ * - If it starts with '05' (10 digits), replaces the leading '0' with '972' (e.g., '0586812807' -> '972586812807').
41
+ * - If it starts with '+', strips the '+'.
42
+ */
43
+ declare function normalizePhoneForWhatsApp(phone: string): string;
37
44
 
38
- export { formatPhoneDisplay, generateWhatsAppLink, isValidPhoneNumber, openWhatsAppChat, sanitizePhoneNumber };
45
+ export { formatPhoneDisplay, generateWhatsAppLink, isValidPhoneNumber, normalizePhoneForWhatsApp, openWhatsAppChat, sanitizePhoneNumber };
package/dist/phone.js CHANGED
@@ -23,6 +23,7 @@ __export(phone_exports, {
23
23
  formatPhoneDisplay: () => formatPhoneDisplay,
24
24
  generateWhatsAppLink: () => generateWhatsAppLink,
25
25
  isValidPhoneNumber: () => isValidPhoneNumber,
26
+ normalizePhoneForWhatsApp: () => normalizePhoneForWhatsApp,
26
27
  openWhatsAppChat: () => openWhatsAppChat,
27
28
  sanitizePhoneNumber: () => sanitizePhoneNumber
28
29
  });
@@ -80,11 +81,24 @@ function generateWhatsAppLink(phone, defaultCountryCode = "972") {
80
81
  }
81
82
  return `https://wa.me/${cleaned}`;
82
83
  }
84
+ function normalizePhoneForWhatsApp(phone) {
85
+ if (!phone) return "";
86
+ let cleaned = phone.trim();
87
+ if (cleaned.startsWith("+")) {
88
+ cleaned = cleaned.substring(1);
89
+ }
90
+ const digitsOnly = cleaned.replace(/\D/g, "");
91
+ if (digitsOnly.startsWith("05") && digitsOnly.length === 10) {
92
+ return `972${digitsOnly.substring(1)}`;
93
+ }
94
+ return digitsOnly;
95
+ }
83
96
  // Annotate the CommonJS export names for ESM import in node:
84
97
  0 && (module.exports = {
85
98
  formatPhoneDisplay,
86
99
  generateWhatsAppLink,
87
100
  isValidPhoneNumber,
101
+ normalizePhoneForWhatsApp,
88
102
  openWhatsAppChat,
89
103
  sanitizePhoneNumber
90
104
  });
package/dist/phone.mjs CHANGED
@@ -50,10 +50,23 @@ function generateWhatsAppLink(phone, defaultCountryCode = "972") {
50
50
  }
51
51
  return `https://wa.me/${cleaned}`;
52
52
  }
53
+ function normalizePhoneForWhatsApp(phone) {
54
+ if (!phone) return "";
55
+ let cleaned = phone.trim();
56
+ if (cleaned.startsWith("+")) {
57
+ cleaned = cleaned.substring(1);
58
+ }
59
+ const digitsOnly = cleaned.replace(/\D/g, "");
60
+ if (digitsOnly.startsWith("05") && digitsOnly.length === 10) {
61
+ return `972${digitsOnly.substring(1)}`;
62
+ }
63
+ return digitsOnly;
64
+ }
53
65
  export {
54
66
  formatPhoneDisplay,
55
67
  generateWhatsAppLink,
56
68
  isValidPhoneNumber,
69
+ normalizePhoneForWhatsApp,
57
70
  openWhatsAppChat,
58
71
  sanitizePhoneNumber
59
72
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@universe-platform/ui",
3
- "version": "0.1.0-beta.15",
3
+ "version": "0.1.0-beta.16",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -35,8 +35,8 @@
35
35
  "react-dom": "^19.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@universe-platform/shared": "*",
39
38
  "@tailwindcss/postcss": "^4.3.1",
39
+ "@universe-platform/shared": "*",
40
40
  "autoprefixer": "^10.5.2",
41
41
  "postcss": "^8.5.15",
42
42
  "tailwindcss": "^4.3.1",
@@ -45,8 +45,9 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "clsx": "^2.1.1",
48
+ "emoji-picker-react": "^4.22.3",
48
49
  "lucide-react": "^1.25.0",
49
50
  "sonner": "^2.0.7",
50
51
  "tailwind-merge": "^3.6.0"
51
52
  }
52
- }
53
+ }