@joewinke/jatui 0.1.28 → 0.1.29

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.
@@ -30,8 +30,8 @@ export function parseTimestamp(timestamp) {
30
30
  return null;
31
31
  if (timestamp instanceof Date)
32
32
  return isNaN(timestamp.getTime()) ? null : timestamp;
33
- var normalized = normalizeTimestamp(timestamp);
34
- var date = new Date(normalized);
33
+ const normalized = normalizeTimestamp(timestamp);
34
+ const date = new Date(normalized);
35
35
  return isNaN(date.getTime()) ? null : date;
36
36
  }
37
37
  /**
@@ -41,30 +41,30 @@ export function parseTimestamp(timestamp) {
41
41
  export function formatRelativeTime(dateStr) {
42
42
  if (!dateStr)
43
43
  return '-';
44
- var date = parseTimestamp(dateStr);
44
+ const date = parseTimestamp(dateStr);
45
45
  if (!date)
46
46
  return '-';
47
- var now = new Date();
48
- var diffMs = now.getTime() - date.getTime();
49
- var diffMins = Math.floor(diffMs / (1000 * 60));
50
- var diffHours = Math.floor(diffMs / (1000 * 60 * 60));
51
- var diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
52
- var diffWeeks = Math.floor(diffDays / 7);
53
- var diffMonths = Math.floor(diffDays / 30);
54
- var diffYears = Math.floor(diffDays / 365);
47
+ const now = new Date();
48
+ const diffMs = now.getTime() - date.getTime();
49
+ const diffMins = Math.floor(diffMs / (1000 * 60));
50
+ const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
51
+ const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
52
+ const diffWeeks = Math.floor(diffDays / 7);
53
+ const diffMonths = Math.floor(diffDays / 30);
54
+ const diffYears = Math.floor(diffDays / 365);
55
55
  if (diffMins < 1)
56
56
  return 'now';
57
57
  if (diffMins < 60)
58
- return "".concat(diffMins, "m");
58
+ return `${diffMins}m`;
59
59
  if (diffHours < 24)
60
- return "".concat(diffHours, "h");
60
+ return `${diffHours}h`;
61
61
  if (diffDays < 7)
62
- return "".concat(diffDays, "d");
62
+ return `${diffDays}d`;
63
63
  if (diffWeeks < 4)
64
- return "".concat(diffWeeks, "w");
64
+ return `${diffWeeks}w`;
65
65
  if (diffMonths < 12)
66
- return "".concat(diffMonths, "mo");
67
- return "".concat(diffYears, "y");
66
+ return `${diffMonths}mo`;
67
+ return `${diffYears}y`;
68
68
  }
69
69
  /**
70
70
  * Format full date and time for tooltips and detailed views.
@@ -72,7 +72,7 @@ export function formatRelativeTime(dateStr) {
72
72
  export function formatFullDate(dateStr) {
73
73
  if (!dateStr)
74
74
  return '';
75
- var date = parseTimestamp(dateStr);
75
+ const date = parseTimestamp(dateStr);
76
76
  if (!date)
77
77
  return '';
78
78
  return date.toLocaleString('en-US', {
@@ -89,7 +89,7 @@ export function formatFullDate(dateStr) {
89
89
  export function formatShortDate(dateStr) {
90
90
  if (!dateStr)
91
91
  return '';
92
- var date = parseTimestamp(dateStr);
92
+ const date = parseTimestamp(dateStr);
93
93
  if (!date)
94
94
  return '';
95
95
  return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
@@ -101,21 +101,21 @@ export function formatShortDate(dateStr) {
101
101
  export function formatLastActivity(timestamp) {
102
102
  if (!timestamp)
103
103
  return 'Never';
104
- var date = parseTimestamp(timestamp);
104
+ const date = parseTimestamp(timestamp);
105
105
  if (!date)
106
106
  return 'Never';
107
- var now = new Date();
108
- var diffMs = now.getTime() - date.getTime();
109
- var diffMins = Math.floor(diffMs / 60000);
110
- var diffHours = Math.floor(diffMs / 3600000);
111
- var diffDays = Math.floor(diffMs / 86400000);
107
+ const now = new Date();
108
+ const diffMs = now.getTime() - date.getTime();
109
+ const diffMins = Math.floor(diffMs / 60000);
110
+ const diffHours = Math.floor(diffMs / 3600000);
111
+ const diffDays = Math.floor(diffMs / 86400000);
112
112
  if (diffMins < 1)
113
113
  return 'Just now';
114
114
  if (diffMins < 60)
115
- return "".concat(diffMins, "m ago");
115
+ return `${diffMins}m ago`;
116
116
  if (diffHours < 24)
117
- return "".concat(diffHours, "h ago");
118
- return "".concat(diffDays, "d ago");
117
+ return `${diffHours}h ago`;
118
+ return `${diffDays}d ago`;
119
119
  }
120
120
  /**
121
121
  * Format date for display (simple locale string).
@@ -123,7 +123,7 @@ export function formatLastActivity(timestamp) {
123
123
  export function formatDate(dateString) {
124
124
  if (!dateString)
125
125
  return 'N/A';
126
- var date = parseTimestamp(dateString);
126
+ const date = parseTimestamp(dateString);
127
127
  if (!date)
128
128
  return 'N/A';
129
129
  return date.toLocaleString();
@@ -134,7 +134,7 @@ export function formatDate(dateString) {
134
134
  export function getTimeSinceMs(timestamp) {
135
135
  if (!timestamp)
136
136
  return Infinity;
137
- var date = parseTimestamp(timestamp);
137
+ const date = parseTimestamp(timestamp);
138
138
  if (!date)
139
139
  return Infinity;
140
140
  return Date.now() - date.getTime();
@@ -158,7 +158,7 @@ export function isWithinMinutes(timestamp, minutes) {
158
158
  export function formatDateTime(dateStr) {
159
159
  if (!dateStr)
160
160
  return '';
161
- var date = parseTimestamp(dateStr);
161
+ const date = parseTimestamp(dateStr);
162
162
  if (!date)
163
163
  return '';
164
164
  return date.toLocaleString(undefined, {
@@ -178,22 +178,22 @@ export function formatDateTime(dateStr) {
178
178
  * // <span style="color: {age.color}">{age.label}</span>
179
179
  */
180
180
  export function taskAge(dateStr) {
181
- var now = Date.now();
182
- var created = new Date(dateStr).getTime();
183
- var minutes = Math.floor((now - created) / 60000);
184
- var hours = Math.floor(minutes / 60);
185
- var days = Math.floor(hours / 24);
186
- var weeks = Math.floor(days / 7);
187
- var months = Math.floor(days / 30);
181
+ const now = Date.now();
182
+ const created = new Date(dateStr).getTime();
183
+ const minutes = Math.floor((now - created) / 60000);
184
+ const hours = Math.floor(minutes / 60);
185
+ const days = Math.floor(hours / 24);
186
+ const weeks = Math.floor(days / 7);
187
+ const months = Math.floor(days / 30);
188
188
  if (minutes < 60)
189
- return { label: "".concat(minutes, "m"), color: 'oklch(0.75 0.18 145)' }; // green — fresh
189
+ return { label: `${minutes}m`, color: 'oklch(0.75 0.18 145)' }; // green — fresh
190
190
  if (hours < 24)
191
- return { label: "".concat(hours, "h"), color: 'oklch(0.75 0.18 145)' }; // green
191
+ return { label: `${hours}h`, color: 'oklch(0.75 0.18 145)' }; // green
192
192
  if (days < 3)
193
- return { label: "".concat(days, "d"), color: 'oklch(0.70 0.15 200)' }; // blue — recent
193
+ return { label: `${days}d`, color: 'oklch(0.70 0.15 200)' }; // blue — recent
194
194
  if (days < 7)
195
- return { label: "".concat(days, "d"), color: 'oklch(0.75 0.15 85)' }; // amber — aging
195
+ return { label: `${days}d`, color: 'oklch(0.75 0.15 85)' }; // amber — aging
196
196
  if (weeks < 4)
197
- return { label: "".concat(weeks, "w"), color: 'oklch(0.65 0.18 50)' }; // orange — stale
198
- return { label: "".concat(months, "mo"), color: 'oklch(0.65 0.20 25)' }; // red — old
197
+ return { label: `${weeks}w`, color: 'oklch(0.65 0.18 50)' }; // orange — stale
198
+ return { label: `${months}mo`, color: 'oklch(0.65 0.20 25)' }; // red — old
199
199
  }
@@ -8,114 +8,60 @@
8
8
  * await loadGoogleMapsAPI({ apiKey: 'YOUR_KEY', libraries: ['marker', 'geometry'] })
9
9
  * if (isGoogleMapsLoaded()) { ... }
10
10
  */
11
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
- return new (P || (P = Promise))(function (resolve, reject) {
14
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
- step((generator = generator.apply(thisArg, _arguments || [])).next());
18
- });
19
- };
20
- var __generator = (this && this.__generator) || function (thisArg, body) {
21
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
22
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
- function verb(n) { return function (v) { return step([n, v]); }; }
24
- function step(op) {
25
- if (f) throw new TypeError("Generator is already executing.");
26
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
27
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
28
- if (y = 0, t) op = [op[0] & 2, t.value];
29
- switch (op[0]) {
30
- case 0: case 1: t = op; break;
31
- case 4: _.label++; return { value: op[1], done: false };
32
- case 5: _.label++; y = op[1]; op = [0]; continue;
33
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
34
- default:
35
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
36
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
37
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
38
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
39
- if (t[2]) _.ops.pop();
40
- _.trys.pop(); continue;
41
- }
42
- op = body.call(thisArg, _);
43
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
44
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
45
- }
46
- };
47
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
48
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
49
- if (ar || !(i in from)) {
50
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
51
- ar[i] = from[i];
52
- }
11
+ let loadPromise = null;
12
+ let isLoaded = false;
13
+ export async function loadGoogleMapsAPI(options) {
14
+ if (typeof window === 'undefined')
15
+ return;
16
+ const { apiKey, libraries = [] } = options;
17
+ if (!apiKey) {
18
+ console.warn('googleMapsLoader: No API key provided');
19
+ return;
53
20
  }
54
- return to.concat(ar || Array.prototype.slice.call(from));
55
- };
56
- var loadPromise = null;
57
- var isLoaded = false;
58
- export function loadGoogleMapsAPI(options) {
59
- return __awaiter(this, void 0, Promise, function () {
60
- var apiKey, _a, libraries, allLibrariesAvailable, allLibraries;
61
- var _b;
62
- return __generator(this, function (_c) {
63
- if (typeof window === 'undefined')
64
- return [2 /*return*/];
65
- apiKey = options.apiKey, _a = options.libraries, libraries = _a === void 0 ? [] : _a;
66
- if (!apiKey) {
67
- console.warn('googleMapsLoader: No API key provided');
68
- return [2 /*return*/];
69
- }
70
- // If already loaded and all required libraries are available, return
71
- if (isLoaded && ((_b = window.google) === null || _b === void 0 ? void 0 : _b.maps)) {
72
- allLibrariesAvailable = libraries.every(function (lib) {
73
- var _a, _b, _c, _d;
74
- switch (lib) {
75
- case 'places':
76
- return (_b = (_a = window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places;
77
- case 'geometry':
78
- return (_d = (_c = window.google) === null || _c === void 0 ? void 0 : _c.maps) === null || _d === void 0 ? void 0 : _d.geometry;
79
- default:
80
- return true;
81
- }
82
- });
83
- if (allLibrariesAvailable)
84
- return [2 /*return*/];
21
+ // If already loaded and all required libraries are available, return
22
+ if (isLoaded && window.google?.maps) {
23
+ const allLibrariesAvailable = libraries.every((lib) => {
24
+ switch (lib) {
25
+ case 'places':
26
+ return window.google?.maps?.places;
27
+ case 'geometry':
28
+ return window.google?.maps?.geometry;
29
+ default:
30
+ return true;
85
31
  }
86
- // If already loading, return the existing promise
87
- if (loadPromise)
88
- return [2 /*return*/, loadPromise];
89
- allLibraries = Array.from(new Set(__spreadArray(['geometry', 'places', 'marker'], libraries, true)));
90
- loadPromise = new Promise(function (resolve, reject) {
91
- var script = document.createElement('script');
92
- script.src = "https://maps.googleapis.com/maps/api/js?key=".concat(apiKey, "&libraries=").concat(allLibraries.join(','));
93
- script.async = true;
94
- script.defer = true;
95
- script.onload = function () {
96
- isLoaded = true;
97
- loadPromise = null;
98
- resolve();
99
- };
100
- script.onerror = function (error) {
101
- loadPromise = null;
102
- reject(error);
103
- };
104
- document.head.appendChild(script);
105
- });
106
- return [2 /*return*/, loadPromise];
107
32
  });
33
+ if (allLibrariesAvailable)
34
+ return;
35
+ }
36
+ // If already loading, return the existing promise
37
+ if (loadPromise)
38
+ return loadPromise;
39
+ // Combine default libraries with requested ones
40
+ const allLibraries = Array.from(new Set(['geometry', 'places', 'marker', ...libraries]));
41
+ loadPromise = new Promise((resolve, reject) => {
42
+ const script = document.createElement('script');
43
+ script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${allLibraries.join(',')}`;
44
+ script.async = true;
45
+ script.defer = true;
46
+ script.onload = () => {
47
+ isLoaded = true;
48
+ loadPromise = null;
49
+ resolve();
50
+ };
51
+ script.onerror = (error) => {
52
+ loadPromise = null;
53
+ reject(error);
54
+ };
55
+ document.head.appendChild(script);
108
56
  });
57
+ return loadPromise;
109
58
  }
110
59
  export function isGoogleMapsLoaded() {
111
- var _a;
112
- return isLoaded && !!((_a = window.google) === null || _a === void 0 ? void 0 : _a.maps);
60
+ return isLoaded && !!window.google?.maps;
113
61
  }
114
62
  export function isPlacesLoaded() {
115
- var _a, _b;
116
- return isGoogleMapsLoaded() && !!((_b = (_a = window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.places);
63
+ return isGoogleMapsLoaded() && !!window.google?.maps?.places;
117
64
  }
118
65
  export function isGeometryLoaded() {
119
- var _a, _b;
120
- return isGoogleMapsLoaded() && !!((_b = (_a = window.google) === null || _a === void 0 ? void 0 : _a.maps) === null || _b === void 0 ? void 0 : _b.geometry);
66
+ return isGoogleMapsLoaded() && !!window.google?.maps?.geometry;
121
67
  }
@@ -8,9 +8,9 @@
8
8
  * routing via the `urlGenerator` parameter or by setting a default.
9
9
  */
10
10
  // Regex to match mention pattern: [@Display Name](type:id)
11
- var MENTION_REGEX = /\[@([^\]]+)\]\(([^:]+):([^)]+)\)/g;
11
+ const MENTION_REGEX = /\[@([^\]]+)\]\(([^:]+):([^)]+)\)/g;
12
12
  // Default URL generator (apps can override)
13
- var defaultUrlGenerator = function (type, id) { return "#".concat(type, "/").concat(id); };
13
+ let defaultUrlGenerator = (type, id) => `#${type}/${id}`;
14
14
  /**
15
15
  * Set the default URL generator for mentions.
16
16
  * Call this once at app startup to configure mention link routing.
@@ -22,20 +22,20 @@ export function setMentionUrlGenerator(generator) {
22
22
  * Parse message content and extract all mentions
23
23
  */
24
24
  export function parseMentions(content, urlGenerator) {
25
- var mentions = [];
26
- var gen = urlGenerator !== null && urlGenerator !== void 0 ? urlGenerator : defaultUrlGenerator;
27
- var match;
25
+ const mentions = [];
26
+ const gen = urlGenerator ?? defaultUrlGenerator;
27
+ let match;
28
28
  MENTION_REGEX.lastIndex = 0;
29
29
  while ((match = MENTION_REGEX.exec(content)) !== null) {
30
- var fullMatch = match[0], displayName = match[1], type = match[2], id = match[3];
30
+ const [fullMatch, displayName, type, id] = match;
31
31
  mentions.push({
32
- type: type,
33
- id: id,
34
- displayName: displayName,
32
+ type,
33
+ id,
34
+ displayName,
35
35
  url: gen(type, id),
36
36
  startIndex: match.index,
37
37
  endIndex: match.index + fullMatch.length,
38
- fullMatch: fullMatch
38
+ fullMatch
39
39
  });
40
40
  }
41
41
  return mentions;
@@ -44,15 +44,15 @@ export function parseMentions(content, urlGenerator) {
44
44
  * Convert message content with mentions to HTML
45
45
  */
46
46
  export function renderMentionsAsHTML(content, urlGenerator) {
47
- var mentions = parseMentions(content, urlGenerator);
47
+ const mentions = parseMentions(content, urlGenerator);
48
48
  if (mentions.length === 0) {
49
49
  return escapeHTML(content);
50
50
  }
51
- var result = '';
52
- var lastIndex = 0;
53
- mentions.forEach(function (mention) {
51
+ let result = '';
52
+ let lastIndex = 0;
53
+ mentions.forEach((mention) => {
54
54
  result += escapeHTML(content.substring(lastIndex, mention.startIndex));
55
- result += "<a href=\"".concat(mention.url, "\" class=\"mention-link mention-").concat(mention.type, "\" data-mention-type=\"").concat(mention.type, "\" data-mention-id=\"").concat(mention.id, "\">@").concat(escapeHTML(mention.displayName), "</a>");
55
+ result += `<a href="${mention.url}" class="mention-link mention-${mention.type}" data-mention-type="${mention.type}" data-mention-id="${mention.id}">@${escapeHTML(mention.displayName)}</a>`;
56
56
  lastIndex = mention.endIndex;
57
57
  });
58
58
  result += escapeHTML(content.substring(lastIndex));
@@ -62,7 +62,7 @@ export function renderMentionsAsHTML(content, urlGenerator) {
62
62
  * Create a mention string for insertion into message input
63
63
  */
64
64
  export function createMentionString(type, id, displayName) {
65
- return "[@".concat(displayName, "](").concat(type, ":").concat(id, ")");
65
+ return `[@${displayName}](${type}:${id})`;
66
66
  }
67
67
  /**
68
68
  * Extract plain text from message content (remove mention markup)
@@ -75,18 +75,18 @@ export function extractPlainText(content) {
75
75
  * Check if cursor is inside a mention
76
76
  */
77
77
  export function findMentionAtCursor(content, cursorPosition) {
78
- var mentions = parseMentions(content);
79
- return (mentions.find(function (mention) { return cursorPosition >= mention.startIndex && cursorPosition <= mention.endIndex; }) || null);
78
+ const mentions = parseMentions(content);
79
+ return (mentions.find((mention) => cursorPosition >= mention.startIndex && cursorPosition <= mention.endIndex) || null);
80
80
  }
81
81
  /**
82
82
  * Find @ symbol and following text that could be a mention being typed.
83
83
  * Supported symbols: @ $ # ! ~ / +
84
84
  */
85
85
  export function findPartialMention(content, cursorPosition) {
86
- var mentionSymbols = ['@', '$', '#', '!', '~', '/', '+'];
87
- var symbolIndex = -1;
88
- for (var i = cursorPosition - 1; i >= 0; i--) {
89
- var char = content[i];
86
+ const mentionSymbols = ['@', '$', '#', '!', '~', '/', '+'];
87
+ let symbolIndex = -1;
88
+ for (let i = cursorPosition - 1; i >= 0; i--) {
89
+ const char = content[i];
90
90
  if (mentionSymbols.includes(char)) {
91
91
  symbolIndex = i;
92
92
  break;
@@ -97,21 +97,21 @@ export function findPartialMention(content, cursorPosition) {
97
97
  }
98
98
  if (symbolIndex === -1)
99
99
  return null;
100
- var query = content.substring(symbolIndex + 1, cursorPosition).trim();
101
- var existingMention = findMentionAtCursor(content, symbolIndex);
100
+ const query = content.substring(symbolIndex + 1, cursorPosition).trim();
101
+ const existingMention = findMentionAtCursor(content, symbolIndex);
102
102
  if (existingMention)
103
103
  return null;
104
- return { start: symbolIndex, query: query };
104
+ return { start: symbolIndex, query };
105
105
  }
106
106
  /**
107
107
  * Replace partial mention with complete mention string
108
108
  */
109
109
  export function replaceMentionInContent(content, startIndex, endIndex, mentionString) {
110
- var before = content.substring(0, startIndex);
111
- var after = content.substring(endIndex);
112
- var newContent = before + mentionString + after;
113
- var newCursorPosition = startIndex + mentionString.length;
114
- return { newContent: newContent, newCursorPosition: newCursorPosition };
110
+ const before = content.substring(0, startIndex);
111
+ const after = content.substring(endIndex);
112
+ const newContent = before + mentionString + after;
113
+ const newCursorPosition = startIndex + mentionString.length;
114
+ return { newContent, newCursorPosition };
115
115
  }
116
116
  /**
117
117
  * Simple HTML escape function
@@ -1,34 +1,31 @@
1
1
  import { parsePhoneNumberFromString, getCountries, getCountryCallingCode, } from "libphonenumber-js";
2
- export var DEFAULT_COUNTRY = "US";
3
- export function toE164(raw, defaultCountry) {
4
- if (defaultCountry === void 0) { defaultCountry = DEFAULT_COUNTRY; }
2
+ export const DEFAULT_COUNTRY = "US";
3
+ export function toE164(raw, defaultCountry = DEFAULT_COUNTRY) {
5
4
  if (!raw)
6
5
  return null;
7
- var trimmed = raw.trim();
6
+ const trimmed = raw.trim();
8
7
  if (!trimmed)
9
8
  return null;
10
- var parsed = parsePhoneNumberFromString(trimmed, defaultCountry);
11
- if (parsed === null || parsed === void 0 ? void 0 : parsed.isValid())
9
+ const parsed = parsePhoneNumberFromString(trimmed, defaultCountry);
10
+ if (parsed?.isValid())
12
11
  return parsed.number;
13
12
  return null;
14
13
  }
15
14
  export function formatPhoneForDisplay(e164) {
16
15
  if (!e164)
17
16
  return "";
18
- var parsed = parsePhoneNumberFromString(e164);
17
+ const parsed = parsePhoneNumberFromString(e164);
19
18
  if (!parsed)
20
19
  return e164;
21
20
  return parsed.country === DEFAULT_COUNTRY ? parsed.formatNational() : parsed.formatInternational();
22
21
  }
23
- export function isValidPhone(raw, defaultCountry) {
24
- var _a;
25
- if (defaultCountry === void 0) { defaultCountry = DEFAULT_COUNTRY; }
22
+ export function isValidPhone(raw, defaultCountry = DEFAULT_COUNTRY) {
26
23
  if (!raw)
27
24
  return false;
28
- var parsed = parsePhoneNumberFromString(raw.trim(), defaultCountry);
29
- return (_a = parsed === null || parsed === void 0 ? void 0 : parsed.isValid()) !== null && _a !== void 0 ? _a : false;
25
+ const parsed = parsePhoneNumberFromString(raw.trim(), defaultCountry);
26
+ return parsed?.isValid() ?? false;
30
27
  }
31
- var COUNTRY_NAMES = {
28
+ const COUNTRY_NAMES = {
32
29
  US: "United States", CA: "Canada", GB: "United Kingdom", AU: "Australia", NZ: "New Zealand",
33
30
  IE: "Ireland", DE: "Germany", FR: "France", ES: "Spain", IT: "Italy", NL: "Netherlands",
34
31
  BE: "Belgium", CH: "Switzerland", AT: "Austria", SE: "Sweden", NO: "Norway", DK: "Denmark",
@@ -43,25 +40,22 @@ function flagEmoji(code) {
43
40
  return code
44
41
  .toUpperCase()
45
42
  .split("")
46
- .map(function (c) { return String.fromCodePoint(127397 + c.charCodeAt(0)); })
43
+ .map((c) => String.fromCodePoint(127397 + c.charCodeAt(0)))
47
44
  .join("");
48
45
  }
49
- var countriesCache = null;
46
+ let countriesCache = null;
50
47
  export function listCountries() {
51
48
  if (countriesCache)
52
49
  return countriesCache;
53
- var all = getCountries()
54
- .map(function (code) {
55
- var _a;
56
- return ({
57
- code: code,
58
- name: (_a = COUNTRY_NAMES[code]) !== null && _a !== void 0 ? _a : code,
59
- dialCode: "+".concat(getCountryCallingCode(code)),
60
- flag: flagEmoji(code),
61
- });
62
- })
63
- .sort(function (a, b) { return a.name.localeCompare(b.name); });
50
+ const all = getCountries()
51
+ .map((code) => ({
52
+ code,
53
+ name: COUNTRY_NAMES[code] ?? code,
54
+ dialCode: `+${getCountryCallingCode(code)}`,
55
+ flag: flagEmoji(code),
56
+ }))
57
+ .sort((a, b) => a.name.localeCompare(b.name));
64
58
  countriesCache = all;
65
59
  return all;
66
60
  }
67
- export var PRIORITY_COUNTRIES = ["US", "CA", "GB", "AU", "MX"];
61
+ export const PRIORITY_COUNTRIES = ["US", "CA", "GB", "AU", "MX"];
@@ -14,19 +14,19 @@ export function stripPhoneNumber(value) {
14
14
  * Formats a phone number to (xxx) xxx-xxxx format
15
15
  */
16
16
  export function formatPhoneNumber(value) {
17
- var digits = stripPhoneNumber(value);
18
- var limitedDigits = digits.slice(0, 10);
17
+ const digits = stripPhoneNumber(value);
18
+ const limitedDigits = digits.slice(0, 10);
19
19
  if (limitedDigits.length === 0) {
20
20
  return '';
21
21
  }
22
22
  else if (limitedDigits.length <= 3) {
23
- return "(".concat(limitedDigits);
23
+ return `(${limitedDigits}`;
24
24
  }
25
25
  else if (limitedDigits.length <= 6) {
26
- return "(".concat(limitedDigits.slice(0, 3), ") ").concat(limitedDigits.slice(3));
26
+ return `(${limitedDigits.slice(0, 3)}) ${limitedDigits.slice(3)}`;
27
27
  }
28
28
  else {
29
- return "(".concat(limitedDigits.slice(0, 3), ") ").concat(limitedDigits.slice(3, 6), "-").concat(limitedDigits.slice(6));
29
+ return `(${limitedDigits.slice(0, 3)}) ${limitedDigits.slice(3, 6)}-${limitedDigits.slice(6)}`;
30
30
  }
31
31
  }
32
32
  /**
@@ -45,11 +45,11 @@ export function isValidPhoneNumber(value) {
45
45
  * Handles input formatting with cursor position preservation
46
46
  */
47
47
  export function updatePhoneInput(input, newValue, oldValue) {
48
- var cursorPosition = input.selectionStart || 0;
49
- var oldLength = oldValue.length;
50
- var newLength = newValue.length;
48
+ const cursorPosition = input.selectionStart || 0;
49
+ const oldLength = oldValue.length;
50
+ const newLength = newValue.length;
51
51
  input.value = newValue;
52
- var newCursorPosition = cursorPosition;
52
+ let newCursorPosition = cursorPosition;
53
53
  if (newLength > oldLength) {
54
54
  newCursorPosition = cursorPosition + (newLength - oldLength);
55
55
  }
@@ -67,5 +67,5 @@ export function typeIcon(type) {
67
67
  * "in_progress" → "In Progress"
68
68
  */
69
69
  export function statusLabel(status) {
70
- return status.replace(/_/g, ' ').replace(/\b\w/g, function (c) { return c.toUpperCase(); });
70
+ return status.replace(/_/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
71
71
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joewinke/jatui",
3
- "version": "0.1.28",
3
+ "version": "0.1.29",
4
4
  "private": false,
5
5
  "description": "Shared Svelte 5 component library for JAT projects",
6
6
  "type": "module",
@@ -17,7 +17,8 @@
17
17
  "files": [
18
18
  "dist",
19
19
  "CLAUDE.md",
20
- "README.md"
20
+ "README.md",
21
+ "LICENSE"
21
22
  ],
22
23
  "scripts": {
23
24
  "dev": "npm run package && vite dev --port 5180",
@@ -66,5 +67,6 @@
66
67
  "libphonenumber-js": "^1.12.41",
67
68
  "pdfjs-dist": "^5.6.205",
68
69
  "svelte-dnd-action": "^0.9.69"
69
- }
70
- }
70
+ },
71
+ "license": "MIT"
72
+ }