@universe-platform/ui 0.1.0-beta.4 → 0.1.0-beta.40

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.
@@ -0,0 +1,49 @@
1
+ /**
2
+ * WhatsApp opener and phone formatting utilities.
3
+ */
4
+ /**
5
+ * Robust WhatsApp Opener (Desktop App with Web Fallback).
6
+ * Tries the direct protocol first (whatsapp://) and falls back to WhatsApp Web
7
+ * if the app is not installed (window didn't lose focus).
8
+ */
9
+ declare function openWhatsAppChat(phone: string, defaultCountryCode?: string): void;
10
+ /**
11
+ * Formats a phone number for local UI display (e.g. Israeli 05X-XXX-XXXX format).
12
+ */
13
+ declare function formatPhoneDisplay(phone: string): string;
14
+
15
+ /**
16
+ * Phone number sanitization, validation, and WhatsApp link generation utilities.
17
+ * Pure functions with zero React or DOM dependencies for universal (server & client) usage.
18
+ */
19
+ /**
20
+ * Sanitizes phone numbers by stripping whitespace, dashes, and non-numeric characters,
21
+ * preserving a leading '+' if present.
22
+ */
23
+ declare function sanitizePhoneNumber(phone: string): string;
24
+ /**
25
+ * Validates whether a phone number is valid (after sanitization).
26
+ * Supports Israeli formats (e.g. 0501234567, 031234567) and international formats (+972..., 9-15 digits).
27
+ */
28
+ declare function isValidPhoneNumber(phone: string): boolean;
29
+ /**
30
+ * Generates an official wa.me WhatsApp direct message link.
31
+ *
32
+ * @param phone Raw or sanitized phone number
33
+ * @param defaultCountryCode Defaults to Israeli code '972'
34
+ * @returns WhatsApp URL or null if phone is empty
35
+ */
36
+ declare function generateWhatsAppLink(phone: string, defaultCountryCode?: string): string | null;
37
+ /**
38
+ * Normalizes a phone number for WhatsApp sending (Meta international format without leading '+').
39
+ * - Returns empty string if input is falsy.
40
+ * - Trims input and removes leading '+' if it exists.
41
+ * - Strips all non-digit characters.
42
+ * - If starting with '972', returns it as is.
43
+ * - If starting with '0' (Israeli mobile/landline), strips '0' and prepends '972'.
44
+ * - If exactly 9 digits long (omitted leading zero), prepends '972'.
45
+ * - Returns the processed digits string.
46
+ */
47
+ declare function normalizePhoneForWhatsApp(phone: string): string;
48
+
49
+ export { formatPhoneDisplay, generateWhatsAppLink, isValidPhoneNumber, normalizePhoneForWhatsApp, openWhatsAppChat, sanitizePhoneNumber };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * WhatsApp opener and phone formatting utilities.
3
+ */
4
+ /**
5
+ * Robust WhatsApp Opener (Desktop App with Web Fallback).
6
+ * Tries the direct protocol first (whatsapp://) and falls back to WhatsApp Web
7
+ * if the app is not installed (window didn't lose focus).
8
+ */
9
+ declare function openWhatsAppChat(phone: string, defaultCountryCode?: string): void;
10
+ /**
11
+ * Formats a phone number for local UI display (e.g. Israeli 05X-XXX-XXXX format).
12
+ */
13
+ declare function formatPhoneDisplay(phone: string): string;
14
+
15
+ /**
16
+ * Phone number sanitization, validation, and WhatsApp link generation utilities.
17
+ * Pure functions with zero React or DOM dependencies for universal (server & client) usage.
18
+ */
19
+ /**
20
+ * Sanitizes phone numbers by stripping whitespace, dashes, and non-numeric characters,
21
+ * preserving a leading '+' if present.
22
+ */
23
+ declare function sanitizePhoneNumber(phone: string): string;
24
+ /**
25
+ * Validates whether a phone number is valid (after sanitization).
26
+ * Supports Israeli formats (e.g. 0501234567, 031234567) and international formats (+972..., 9-15 digits).
27
+ */
28
+ declare function isValidPhoneNumber(phone: string): boolean;
29
+ /**
30
+ * Generates an official wa.me WhatsApp direct message link.
31
+ *
32
+ * @param phone Raw or sanitized phone number
33
+ * @param defaultCountryCode Defaults to Israeli code '972'
34
+ * @returns WhatsApp URL or null if phone is empty
35
+ */
36
+ declare function generateWhatsAppLink(phone: string, defaultCountryCode?: string): string | null;
37
+ /**
38
+ * Normalizes a phone number for WhatsApp sending (Meta international format without leading '+').
39
+ * - Returns empty string if input is falsy.
40
+ * - Trims input and removes leading '+' if it exists.
41
+ * - Strips all non-digit characters.
42
+ * - If starting with '972', returns it as is.
43
+ * - If starting with '0' (Israeli mobile/landline), strips '0' and prepends '972'.
44
+ * - If exactly 9 digits long (omitted leading zero), prepends '972'.
45
+ * - Returns the processed digits string.
46
+ */
47
+ declare function normalizePhoneForWhatsApp(phone: string): string;
48
+
49
+ export { formatPhoneDisplay, generateWhatsAppLink, isValidPhoneNumber, normalizePhoneForWhatsApp, openWhatsAppChat, sanitizePhoneNumber };
package/dist/phone.js ADDED
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/utils/phone.ts
21
+ var phone_exports = {};
22
+ __export(phone_exports, {
23
+ formatPhoneDisplay: () => formatPhoneDisplay,
24
+ generateWhatsAppLink: () => generateWhatsAppLink,
25
+ isValidPhoneNumber: () => isValidPhoneNumber,
26
+ normalizePhoneForWhatsApp: () => normalizePhoneForWhatsApp,
27
+ openWhatsAppChat: () => openWhatsAppChat,
28
+ sanitizePhoneNumber: () => sanitizePhoneNumber
29
+ });
30
+ module.exports = __toCommonJS(phone_exports);
31
+
32
+ // src/utils/whatsapp.ts
33
+ function openWhatsAppChat(phone, defaultCountryCode = "972") {
34
+ if (!phone || typeof window === "undefined") return;
35
+ let cleaned = phone.replace(/\D/g, "");
36
+ if (cleaned.startsWith("0")) {
37
+ cleaned = defaultCountryCode + cleaned.substring(1);
38
+ }
39
+ const appUrl = `whatsapp://send?phone=${cleaned}`;
40
+ const webUrl = `https://web.whatsapp.com/send?phone=${cleaned}`;
41
+ const start = Date.now();
42
+ window.location.href = appUrl;
43
+ setTimeout(() => {
44
+ if (typeof document !== "undefined" && document.hasFocus() && Date.now() - start < 2e3) {
45
+ window.open(webUrl, "_blank", "noopener,noreferrer");
46
+ }
47
+ }, 1200);
48
+ }
49
+ function formatPhoneDisplay(phone) {
50
+ if (!phone) return "";
51
+ const digits = phone.replace(/\D/g, "");
52
+ if (digits.length === 10 && digits.startsWith("05")) {
53
+ return `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`;
54
+ }
55
+ if (digits.length === 12 && digits.startsWith("9725")) {
56
+ const local = "0" + digits.slice(3);
57
+ return `${local.slice(0, 3)}-${local.slice(3, 6)}-${local.slice(6)}`;
58
+ }
59
+ return phone;
60
+ }
61
+
62
+ // src/utils/phone.ts
63
+ function sanitizePhoneNumber(phone) {
64
+ if (!phone) return "";
65
+ const trimmed = phone.trim();
66
+ const hasLeadingPlus = trimmed.startsWith("+");
67
+ const digitsOnly = trimmed.replace(/\D/g, "");
68
+ return hasLeadingPlus ? `+${digitsOnly}` : digitsOnly;
69
+ }
70
+ function isValidPhoneNumber(phone) {
71
+ if (!phone) return false;
72
+ const cleaned = sanitizePhoneNumber(phone);
73
+ return /^\+?[0-9]{9,15}$/.test(cleaned);
74
+ }
75
+ function generateWhatsAppLink(phone, defaultCountryCode = "972") {
76
+ if (!phone) return null;
77
+ let cleaned = phone.replace(/\D/g, "");
78
+ if (!cleaned) return null;
79
+ if (cleaned.startsWith("0")) {
80
+ cleaned = defaultCountryCode + cleaned.substring(1);
81
+ }
82
+ return `https://wa.me/${cleaned}`;
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("972")) {
92
+ return digitsOnly;
93
+ }
94
+ if (digitsOnly.startsWith("0")) {
95
+ return `972${digitsOnly.substring(1)}`;
96
+ }
97
+ if (digitsOnly.length === 9) {
98
+ return `972${digitsOnly}`;
99
+ }
100
+ return digitsOnly;
101
+ }
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ formatPhoneDisplay,
105
+ generateWhatsAppLink,
106
+ isValidPhoneNumber,
107
+ normalizePhoneForWhatsApp,
108
+ openWhatsAppChat,
109
+ sanitizePhoneNumber
110
+ });
package/dist/phone.mjs ADDED
@@ -0,0 +1,78 @@
1
+ // src/utils/whatsapp.ts
2
+ function openWhatsAppChat(phone, defaultCountryCode = "972") {
3
+ if (!phone || typeof window === "undefined") return;
4
+ let cleaned = phone.replace(/\D/g, "");
5
+ if (cleaned.startsWith("0")) {
6
+ cleaned = defaultCountryCode + cleaned.substring(1);
7
+ }
8
+ const appUrl = `whatsapp://send?phone=${cleaned}`;
9
+ const webUrl = `https://web.whatsapp.com/send?phone=${cleaned}`;
10
+ const start = Date.now();
11
+ window.location.href = appUrl;
12
+ setTimeout(() => {
13
+ if (typeof document !== "undefined" && document.hasFocus() && Date.now() - start < 2e3) {
14
+ window.open(webUrl, "_blank", "noopener,noreferrer");
15
+ }
16
+ }, 1200);
17
+ }
18
+ function formatPhoneDisplay(phone) {
19
+ if (!phone) return "";
20
+ const digits = phone.replace(/\D/g, "");
21
+ if (digits.length === 10 && digits.startsWith("05")) {
22
+ return `${digits.slice(0, 3)}-${digits.slice(3, 6)}-${digits.slice(6)}`;
23
+ }
24
+ if (digits.length === 12 && digits.startsWith("9725")) {
25
+ const local = "0" + digits.slice(3);
26
+ return `${local.slice(0, 3)}-${local.slice(3, 6)}-${local.slice(6)}`;
27
+ }
28
+ return phone;
29
+ }
30
+
31
+ // src/utils/phone.ts
32
+ function sanitizePhoneNumber(phone) {
33
+ if (!phone) return "";
34
+ const trimmed = phone.trim();
35
+ const hasLeadingPlus = trimmed.startsWith("+");
36
+ const digitsOnly = trimmed.replace(/\D/g, "");
37
+ return hasLeadingPlus ? `+${digitsOnly}` : digitsOnly;
38
+ }
39
+ function isValidPhoneNumber(phone) {
40
+ if (!phone) return false;
41
+ const cleaned = sanitizePhoneNumber(phone);
42
+ return /^\+?[0-9]{9,15}$/.test(cleaned);
43
+ }
44
+ function generateWhatsAppLink(phone, defaultCountryCode = "972") {
45
+ if (!phone) return null;
46
+ let cleaned = phone.replace(/\D/g, "");
47
+ if (!cleaned) return null;
48
+ if (cleaned.startsWith("0")) {
49
+ cleaned = defaultCountryCode + cleaned.substring(1);
50
+ }
51
+ return `https://wa.me/${cleaned}`;
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("972")) {
61
+ return digitsOnly;
62
+ }
63
+ if (digitsOnly.startsWith("0")) {
64
+ return `972${digitsOnly.substring(1)}`;
65
+ }
66
+ if (digitsOnly.length === 9) {
67
+ return `972${digitsOnly}`;
68
+ }
69
+ return digitsOnly;
70
+ }
71
+ export {
72
+ formatPhoneDisplay,
73
+ generateWhatsAppLink,
74
+ isValidPhoneNumber,
75
+ normalizePhoneForWhatsApp,
76
+ openWhatsAppChat,
77
+ sanitizePhoneNumber
78
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@universe-platform/ui",
3
- "version": "0.1.0-beta.4",
3
+ "version": "0.1.0-beta.40",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -10,6 +10,11 @@
10
10
  "require": "./dist/index.js",
11
11
  "import": "./dist/index.mjs"
12
12
  },
13
+ "./phone": {
14
+ "types": "./dist/phone.d.ts",
15
+ "require": "./dist/phone.js",
16
+ "import": "./dist/phone.mjs"
17
+ },
13
18
  "./dist/globals.css": "./dist/globals.css",
14
19
  "./globals.css": "./dist/globals.css"
15
20
  },
@@ -31,6 +36,7 @@
31
36
  },
32
37
  "devDependencies": {
33
38
  "@tailwindcss/postcss": "^4.3.1",
39
+ "@universe-platform/shared": "*",
34
40
  "autoprefixer": "^10.5.2",
35
41
  "postcss": "^8.5.15",
36
42
  "tailwindcss": "^4.3.1",
@@ -38,9 +44,12 @@
38
44
  "typescript": "^5.0.0"
39
45
  },
40
46
  "dependencies": {
47
+ "ag-grid-community": "^36.2.0",
48
+ "ag-grid-react": "^36.2.0",
41
49
  "clsx": "^2.1.1",
50
+ "emoji-picker-react": "^4.22.3",
42
51
  "lucide-react": "^1.25.0",
43
52
  "sonner": "^2.0.7",
44
53
  "tailwind-merge": "^3.6.0"
45
54
  }
46
- }
55
+ }