@joewinke/jatui 0.1.22 → 0.1.24

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 (124) hide show
  1. package/CLAUDE.md +244 -0
  2. package/package.json +23 -10
  3. package/src/lib/actions/collapse.ts +0 -134
  4. package/src/lib/actions/railNav.ts +0 -473
  5. package/src/lib/components/AnnotationLayer.svelte +0 -108
  6. package/src/lib/components/AnnotationPanel.svelte +0 -319
  7. package/src/lib/components/AudioWaveform.svelte +0 -698
  8. package/src/lib/components/AvailabilityModal.svelte +0 -177
  9. package/src/lib/components/AvatarUpload.svelte +0 -234
  10. package/src/lib/components/Badge.svelte +0 -38
  11. package/src/lib/components/BookingForm.svelte +0 -278
  12. package/src/lib/components/BurndownChart.svelte +0 -778
  13. package/src/lib/components/Button.svelte +0 -81
  14. package/src/lib/components/CalendarPicker.svelte +0 -284
  15. package/src/lib/components/Card.svelte +0 -67
  16. package/src/lib/components/CharacterCounter.svelte +0 -82
  17. package/src/lib/components/ChipInput.svelte +0 -609
  18. package/src/lib/components/Collapse.svelte +0 -82
  19. package/src/lib/components/ColorSelector.svelte +0 -167
  20. package/src/lib/components/CommentThread.svelte +0 -773
  21. package/src/lib/components/ConfirmDialog.svelte +0 -348
  22. package/src/lib/components/ConfirmModal.svelte +0 -142
  23. package/src/lib/components/ContextMenu.svelte +0 -188
  24. package/src/lib/components/CountdownTimer.svelte +0 -94
  25. package/src/lib/components/DateRangePicker.svelte +0 -194
  26. package/src/lib/components/Drawer.svelte +0 -143
  27. package/src/lib/components/EmojiPicker.svelte +0 -159
  28. package/src/lib/components/EntityPreviewCard.svelte +0 -104
  29. package/src/lib/components/FileDropzone.svelte +0 -493
  30. package/src/lib/components/FilePicker.svelte +0 -488
  31. package/src/lib/components/FileThumbnail.svelte +0 -80
  32. package/src/lib/components/FilterDropdown.svelte +0 -203
  33. package/src/lib/components/FloatingActionBar.svelte +0 -354
  34. package/src/lib/components/GPSTracker.svelte +0 -202
  35. package/src/lib/components/HunkDiffView.svelte +0 -348
  36. package/src/lib/components/ImageLightbox.svelte +0 -274
  37. package/src/lib/components/ImageUpload.svelte +0 -147
  38. package/src/lib/components/InlineEdit.svelte +0 -291
  39. package/src/lib/components/InputDialog.svelte +0 -327
  40. package/src/lib/components/KeyboardShortcutsOverlay.svelte +0 -296
  41. package/src/lib/components/LazyImage.svelte +0 -123
  42. package/src/lib/components/LinkShortener.svelte +0 -274
  43. package/src/lib/components/LoadingSpinner.svelte +0 -106
  44. package/src/lib/components/LocationMap.svelte +0 -186
  45. package/src/lib/components/MapView.svelte +0 -341
  46. package/src/lib/components/MarkupEditor.svelte +0 -485
  47. package/src/lib/components/MarkupOverlay.svelte +0 -55
  48. package/src/lib/components/MediaWorkbench.svelte +0 -871
  49. package/src/lib/components/MilestoneCard.svelte +0 -98
  50. package/src/lib/components/MilestoneTimeline.svelte +0 -91
  51. package/src/lib/components/Modal.svelte +0 -244
  52. package/src/lib/components/PDFViewer.svelte +0 -105
  53. package/src/lib/components/PdfThumbnail.svelte +0 -63
  54. package/src/lib/components/PhoneInput.svelte +0 -212
  55. package/src/lib/components/ResizableDivider.svelte +0 -307
  56. package/src/lib/components/ResizablePanel.svelte +0 -305
  57. package/src/lib/components/SearchDropdown.svelte +0 -421
  58. package/src/lib/components/SelectInput.svelte +0 -237
  59. package/src/lib/components/SidebarUserFooter.svelte +0 -34
  60. package/src/lib/components/SignaturePad.svelte +0 -175
  61. package/src/lib/components/SmartImageEditor.svelte +0 -720
  62. package/src/lib/components/SortDropdown.svelte +0 -156
  63. package/src/lib/components/Sparkline.svelte +0 -116
  64. package/src/lib/components/SpeechForm.svelte +0 -114
  65. package/src/lib/components/StatusBadge.svelte +0 -157
  66. package/src/lib/components/TaskTypeIcon.svelte +0 -54
  67. package/src/lib/components/TextArea.svelte +0 -162
  68. package/src/lib/components/TextInput.svelte +0 -131
  69. package/src/lib/components/ThemeSelector.svelte +0 -206
  70. package/src/lib/components/TimeSlotPicker.svelte +0 -162
  71. package/src/lib/components/UserAvatar.svelte +0 -72
  72. package/src/lib/components/VariablePicker.svelte +0 -170
  73. package/src/lib/components/VoicePlayer.svelte +0 -422
  74. package/src/lib/components/linked-columns/LinkedColumns.svelte +0 -526
  75. package/src/lib/components/markup.ts +0 -287
  76. package/src/lib/components/messaging/Avatar.svelte +0 -81
  77. package/src/lib/components/messaging/ChannelInfoModal.svelte +0 -163
  78. package/src/lib/components/messaging/ChannelList.svelte +0 -107
  79. package/src/lib/components/messaging/ChannelMemberAvatarStack.svelte +0 -69
  80. package/src/lib/components/messaging/ChannelMembersModal.svelte +0 -182
  81. package/src/lib/components/messaging/CreateChannelModal.svelte +0 -190
  82. package/src/lib/components/messaging/DirectMessageList.svelte +0 -145
  83. package/src/lib/components/messaging/EmojiSelector.svelte +0 -261
  84. package/src/lib/components/messaging/MentionAutocomplete.svelte +0 -193
  85. package/src/lib/components/messaging/MessageAttachment.svelte +0 -273
  86. package/src/lib/components/messaging/MessageAttachmentUpload.svelte +0 -243
  87. package/src/lib/components/messaging/MessageInput.svelte +0 -452
  88. package/src/lib/components/messaging/MessageItem.svelte +0 -341
  89. package/src/lib/components/messaging/MessageThread.svelte +0 -306
  90. package/src/lib/components/messaging/NotificationSettingsModal.svelte +0 -234
  91. package/src/lib/components/messaging/QuotedMessageDisplay.svelte +0 -123
  92. package/src/lib/components/messaging/StartDMModal.svelte +0 -100
  93. package/src/lib/components/messaging/ThreadPanel.svelte +0 -153
  94. package/src/lib/components/pipeline/DESIGN.md +0 -361
  95. package/src/lib/components/pipeline/Pipeline.svelte +0 -391
  96. package/src/lib/components/pipeline/PipelineCard.svelte +0 -94
  97. package/src/lib/components/pipeline/PipelineColumn.svelte +0 -163
  98. package/src/lib/components/replay/ChapterTimeline.svelte +0 -326
  99. package/src/lib/components/session-nav/transcriptModel.ts +0 -352
  100. package/src/lib/data/emojis.ts +0 -1208
  101. package/src/lib/index.ts +0 -405
  102. package/src/lib/stores/confirmDialog.svelte.ts +0 -48
  103. package/src/lib/stores/inputDialog.svelte.ts +0 -51
  104. package/src/lib/styles/rail.css +0 -63
  105. package/src/lib/types/annotation.ts +0 -38
  106. package/src/lib/types/booking.ts +0 -143
  107. package/src/lib/types/comments.ts +0 -97
  108. package/src/lib/types/entityPreview.ts +0 -45
  109. package/src/lib/types/filePicker.ts +0 -16
  110. package/src/lib/types/googleMaps.d.ts +0 -51
  111. package/src/lib/types/maps.ts +0 -43
  112. package/src/lib/types/messaging.ts +0 -459
  113. package/src/lib/types/milestone.ts +0 -22
  114. package/src/lib/types/pipeline.ts +0 -150
  115. package/src/lib/types/smartImageEditor.ts +0 -39
  116. package/src/lib/types/templateVars.ts +0 -36
  117. package/src/lib/utils/currency.ts +0 -20
  118. package/src/lib/utils/daisyuiColors.ts +0 -243
  119. package/src/lib/utils/dateFormatters.ts +0 -196
  120. package/src/lib/utils/googleMapsLoader.ts +0 -84
  121. package/src/lib/utils/mentionParser.ts +0 -188
  122. package/src/lib/utils/phone.ts +0 -80
  123. package/src/lib/utils/phoneFormat.ts +0 -74
  124. package/src/lib/utils/taskUtils.ts +0 -75
@@ -1,20 +0,0 @@
1
- /**
2
- * Currency formatting utilities
3
- */
4
-
5
- /**
6
- * Format a number as USD currency string.
7
- * Override locale/currency by passing options.
8
- */
9
- export function formatCurrency(
10
- amount: number,
11
- locale: string = 'en-US',
12
- currency: string = 'USD'
13
- ): string {
14
- return new Intl.NumberFormat(locale, {
15
- style: 'currency',
16
- currency,
17
- minimumFractionDigits: 2,
18
- maximumFractionDigits: 2
19
- }).format(amount);
20
- }
@@ -1,243 +0,0 @@
1
- /**
2
- * DaisyUI Color Utility System
3
- *
4
- * Provides utilities for accessing DaisyUI semantic colors in JavaScript/Canvas contexts.
5
- * Handles color format conversion and theme change detection for dynamic updates.
6
- */
7
-
8
- let colorCache = new Map<string, string>()
9
- let themeObserver: MutationObserver | null = null
10
-
11
- /**
12
- * Get a DaisyUI semantic color as a hex string usable in Canvas
13
- * @param colorName - DaisyUI color name (e.g., "primary", "accent", "base-100")
14
- * @returns Hex color string (e.g., "#3b82f6")
15
- */
16
- export function getDaisyUIColor(colorName: string): string {
17
- const cacheKey = colorName
18
- if (colorCache.has(cacheKey)) {
19
- return colorCache.get(cacheKey)!
20
- }
21
-
22
- const fallbackColor = getColorFallback(colorName)
23
- colorCache.set(cacheKey, fallbackColor)
24
- return fallbackColor
25
- }
26
-
27
- function getColorFallback(colorName: string): string {
28
- const currentTheme =
29
- document.documentElement.getAttribute("data-theme") || "light"
30
-
31
- const luxuryColors: Record<string, string> = {
32
- primary: "#d4af37",
33
- "primary-content": "#1a1a1a",
34
- secondary: "#c0c0c0",
35
- "secondary-content": "#1a1a1a",
36
- accent: "#ffd700",
37
- "accent-content": "#1a1a1a",
38
- neutral: "#6b7280",
39
- "neutral-content": "#f5f5f5",
40
- "base-100": "#1a1a1a",
41
- "base-200": "#2d2d2d",
42
- "base-300": "#404040",
43
- "base-content": "#f5f5f5",
44
- success: "#10b981",
45
- "success-content": "#1a1a1a",
46
- warning: "#f59e0b",
47
- "warning-content": "#1a1a1a",
48
- error: "#ef4444",
49
- "error-content": "#f5f5f5",
50
- info: "#3b82f6",
51
- "info-content": "#f5f5f5",
52
- }
53
-
54
- const nordColors: Record<string, string> = {
55
- primary: "#5e81ac",
56
- "primary-content": "#eceff4",
57
- secondary: "#81a1c1",
58
- "secondary-content": "#2e3440",
59
- accent: "#88c0d0",
60
- "accent-content": "#2e3440",
61
- neutral: "#4c566a",
62
- "neutral-content": "#eceff4",
63
- "base-100": "#2e3440",
64
- "base-200": "#3b4252",
65
- "base-300": "#434c5e",
66
- "base-content": "#eceff4",
67
- success: "#a3be8c",
68
- "success-content": "#2e3440",
69
- warning: "#ebcb8b",
70
- "warning-content": "#2e3440",
71
- error: "#bf616a",
72
- "error-content": "#eceff4",
73
- info: "#81a1c1",
74
- "info-content": "#2e3440",
75
- }
76
-
77
- const darkColors: Record<string, string> = {
78
- primary: "#661ae6",
79
- "primary-content": "#ffffff",
80
- secondary: "#d926a9",
81
- "secondary-content": "#ffffff",
82
- accent: "#1fb2a6",
83
- "accent-content": "#ffffff",
84
- neutral: "#2a323c",
85
- "neutral-content": "#a6adbb",
86
- "base-100": "#1d232a",
87
- "base-200": "#191e24",
88
- "base-300": "#15191e",
89
- "base-content": "#a6adbb",
90
- info: "#3abff8",
91
- "info-content": "#002b3d",
92
- success: "#36d399",
93
- "success-content": "#003320",
94
- warning: "#fbbd23",
95
- "warning-content": "#382800",
96
- error: "#f87272",
97
- "error-content": "#470000",
98
- }
99
-
100
- const defaultColors: Record<string, string> = {
101
- primary: "#3b82f6",
102
- "primary-content": "#ffffff",
103
- secondary: "#6b7280",
104
- "secondary-content": "#ffffff",
105
- accent: "#f97316",
106
- "accent-content": "#ffffff",
107
- neutral: "#6b7280",
108
- "neutral-content": "#ffffff",
109
- "base-100": "#ffffff",
110
- "base-200": "#f1f5f9",
111
- "base-300": "#e2e8f0",
112
- "base-content": "#1f2937",
113
- info: "#3b82f6",
114
- "info-content": "#ffffff",
115
- success: "#10b981",
116
- "success-content": "#ffffff",
117
- warning: "#f59e0b",
118
- "warning-content": "#ffffff",
119
- error: "#ef4444",
120
- "error-content": "#ffffff",
121
- }
122
-
123
- const fallbacks =
124
- currentTheme === "luxury"
125
- ? luxuryColors
126
- : currentTheme === "nord"
127
- ? nordColors
128
- : currentTheme === "dark"
129
- ? darkColors
130
- : defaultColors
131
- return fallbacks[colorName] || "#6b7280"
132
- }
133
-
134
- /**
135
- * Create a lighter version of a color
136
- */
137
- export function lightenColor(hexColor: string, amount: number = 0.2): string {
138
- const hex = hexColor.replace("#", "")
139
- const r = parseInt(hex.substring(0, 2), 16)
140
- const g = parseInt(hex.substring(2, 4), 16)
141
- const b = parseInt(hex.substring(4, 6), 16)
142
-
143
- const newR = Math.min(255, Math.floor(r + (255 - r) * amount))
144
- const newG = Math.min(255, Math.floor(g + (255 - g) * amount))
145
- const newB = Math.min(255, Math.floor(b + (255 - b) * amount))
146
-
147
- return `#${((newR << 16) | (newG << 8) | newB).toString(16).padStart(6, "0")}`
148
- }
149
-
150
- /**
151
- * Create a darker version of a color
152
- */
153
- export function darkenColor(hexColor: string, amount: number = 0.2): string {
154
- const hex = hexColor.replace("#", "")
155
- const r = parseInt(hex.substring(0, 2), 16)
156
- const g = parseInt(hex.substring(2, 4), 16)
157
- const b = parseInt(hex.substring(4, 6), 16)
158
-
159
- const newR = Math.max(0, Math.floor(r * (1 - amount)))
160
- const newG = Math.max(0, Math.floor(g * (1 - amount)))
161
- const newB = Math.max(0, Math.floor(b * (1 - amount)))
162
-
163
- return `#${((newR << 16) | (newG << 8) | newB).toString(16).padStart(6, "0")}`
164
- }
165
-
166
- /**
167
- * Setup theme change detection
168
- * Clears color cache when theme changes and optionally calls a callback
169
- */
170
- export function watchThemeChanges(onThemeChange?: () => void): () => void {
171
- if (themeObserver) {
172
- themeObserver.disconnect()
173
- }
174
-
175
- themeObserver = new MutationObserver((mutations: MutationRecord[]): void => {
176
- let themeChanged = false
177
-
178
- mutations.forEach((mutation: MutationRecord): void => {
179
- if (
180
- mutation.type === "attributes" &&
181
- (mutation.attributeName === "data-theme" ||
182
- mutation.attributeName === "class")
183
- ) {
184
- themeChanged = true
185
- }
186
- })
187
-
188
- if (themeChanged) {
189
- colorCache.clear()
190
- if (onThemeChange) {
191
- onThemeChange()
192
- }
193
- }
194
- })
195
-
196
- themeObserver.observe(document.documentElement, {
197
- attributes: true,
198
- attributeFilter: ["data-theme", "class"],
199
- })
200
-
201
- return () => {
202
- if (themeObserver) {
203
- themeObserver.disconnect()
204
- themeObserver = null
205
- }
206
- }
207
- }
208
-
209
- /**
210
- * Check if we're currently in a dark theme
211
- */
212
- export function isDarkTheme(): boolean {
213
- const baseContent = getDaisyUIColor("base-content")
214
- const base100 = getDaisyUIColor("base-100")
215
-
216
- const contentBrightness = getBrightness(baseContent)
217
- const baseBrightness = getBrightness(base100)
218
-
219
- return contentBrightness > baseBrightness
220
- }
221
-
222
- function getBrightness(hexColor: string): number {
223
- const hex = hexColor.replace("#", "")
224
- const r = parseInt(hex.substring(0, 2), 16)
225
- const g = parseInt(hex.substring(2, 4), 16)
226
- const b = parseInt(hex.substring(4, 6), 16)
227
-
228
- return (r * 299 + g * 587 + b * 114) / 1000
229
- }
230
-
231
- /**
232
- * Get the current theme name if available
233
- */
234
- export function getCurrentTheme(): string | null {
235
- return document.documentElement.getAttribute("data-theme")
236
- }
237
-
238
- /**
239
- * Clear the color cache manually
240
- */
241
- export function clearColorCache(): void {
242
- colorCache.clear()
243
- }
@@ -1,196 +0,0 @@
1
- /**
2
- * Date formatting utilities for consistent date/time display.
3
- *
4
- * UTC/ISO Timestamp Handling:
5
- * Database timestamps are often stored without timezone info (e.g., "2024-11-21 15:30:00").
6
- * These utilities normalize timestamps to ensure correct UTC parsing.
7
- */
8
-
9
- /**
10
- * Normalize a timestamp string to proper ISO 8601 format.
11
- * Handles database timestamps that may lack 'T' separator or 'Z' suffix.
12
- */
13
- export function normalizeTimestamp(timestamp: string): string {
14
- if (!timestamp) return timestamp;
15
-
16
- if (timestamp.includes('T')) {
17
- if (timestamp.endsWith('Z')) return timestamp;
18
- if (/[+-]\d{2}:\d{2}$/.test(timestamp)) return timestamp;
19
- return timestamp + 'Z';
20
- }
21
-
22
- return timestamp.replace(' ', 'T') + 'Z';
23
- }
24
-
25
- /**
26
- * Parse a potentially non-standard timestamp into a Date object.
27
- * Accepts a Date (returned by postgres.js), ISO string, or null/undefined.
28
- */
29
- export function parseTimestamp(timestamp: Date | string | null | undefined): Date | null {
30
- if (!timestamp) return null;
31
- if (timestamp instanceof Date) return isNaN(timestamp.getTime()) ? null : timestamp;
32
-
33
- const normalized = normalizeTimestamp(timestamp);
34
- const date = new Date(normalized);
35
-
36
- return isNaN(date.getTime()) ? null : date;
37
- }
38
-
39
- /**
40
- * Format relative time (e.g., "2d", "3mo", "1y").
41
- * Compact format suitable for tables and compact UIs.
42
- */
43
- export function formatRelativeTime(dateStr: Date | string | null | undefined): string {
44
- if (!dateStr) return '-';
45
-
46
- const date = parseTimestamp(dateStr);
47
- if (!date) return '-';
48
-
49
- const now = new Date();
50
- const diffMs = now.getTime() - date.getTime();
51
- const diffMins = Math.floor(diffMs / (1000 * 60));
52
- const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
53
- const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
54
- const diffWeeks = Math.floor(diffDays / 7);
55
- const diffMonths = Math.floor(diffDays / 30);
56
- const diffYears = Math.floor(diffDays / 365);
57
-
58
- if (diffMins < 1) return 'now';
59
- if (diffMins < 60) return `${diffMins}m`;
60
- if (diffHours < 24) return `${diffHours}h`;
61
- if (diffDays < 7) return `${diffDays}d`;
62
- if (diffWeeks < 4) return `${diffWeeks}w`;
63
- if (diffMonths < 12) return `${diffMonths}mo`;
64
- return `${diffYears}y`;
65
- }
66
-
67
- /**
68
- * Format full date and time for tooltips and detailed views.
69
- */
70
- export function formatFullDate(dateStr: Date | string | null | undefined): string {
71
- if (!dateStr) return '';
72
-
73
- const date = parseTimestamp(dateStr);
74
- if (!date) return '';
75
-
76
- return date.toLocaleString('en-US', {
77
- month: 'short',
78
- day: 'numeric',
79
- year: 'numeric',
80
- hour: '2-digit',
81
- minute: '2-digit'
82
- });
83
- }
84
-
85
- /**
86
- * Format short date for compact displays (e.g., date range picker).
87
- */
88
- export function formatShortDate(dateStr: Date | string | null | undefined): string {
89
- if (!dateStr) return '';
90
-
91
- const date = parseTimestamp(dateStr);
92
- if (!date) return '';
93
-
94
- return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
95
- }
96
-
97
- /**
98
- * Format last activity time for agent cards.
99
- * Shows "Just now", "Xm ago", "Xh ago", or "Xd ago".
100
- */
101
- export function formatLastActivity(timestamp: Date | string | null | undefined): string {
102
- if (!timestamp) return 'Never';
103
-
104
- const date = parseTimestamp(timestamp);
105
- if (!date) return 'Never';
106
-
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
-
113
- if (diffMins < 1) return 'Just now';
114
- if (diffMins < 60) return `${diffMins}m ago`;
115
- if (diffHours < 24) return `${diffHours}h ago`;
116
- return `${diffDays}d ago`;
117
- }
118
-
119
- /**
120
- * Format date for display (simple locale string).
121
- */
122
- export function formatDate(dateString: Date | string | null | undefined): string {
123
- if (!dateString) return 'N/A';
124
-
125
- const date = parseTimestamp(dateString);
126
- if (!date) return 'N/A';
127
-
128
- return date.toLocaleString();
129
- }
130
-
131
- /**
132
- * Get milliseconds since timestamp (for calculations).
133
- */
134
- export function getTimeSinceMs(timestamp: Date | string | null | undefined): number {
135
- if (!timestamp) return Infinity;
136
-
137
- const date = parseTimestamp(timestamp);
138
- if (!date) return Infinity;
139
-
140
- return Date.now() - date.getTime();
141
- }
142
-
143
- /**
144
- * Get minutes since timestamp.
145
- */
146
- export function getTimeSinceMinutes(timestamp: Date | string | null | undefined): number {
147
- return getTimeSinceMs(timestamp) / 60000;
148
- }
149
-
150
- /**
151
- * Check if timestamp is within a given number of minutes.
152
- */
153
- export function isWithinMinutes(timestamp: Date | string | null | undefined, minutes: number): boolean {
154
- return getTimeSinceMinutes(timestamp) < minutes;
155
- }
156
-
157
- /**
158
- * Format date + time for detail views (e.g. "Jan 5, 2:30 PM").
159
- * No year — use formatFullDate when year is needed.
160
- */
161
- export function formatDateTime(dateStr: Date | string | null | undefined): string {
162
- if (!dateStr) return '';
163
- const date = parseTimestamp(dateStr);
164
- if (!date) return '';
165
- return date.toLocaleString(undefined, {
166
- month: 'short',
167
- day: 'numeric',
168
- hour: 'numeric',
169
- minute: '2-digit',
170
- });
171
- }
172
-
173
- /**
174
- * Color-coded relative age for task rows.
175
- * Returns a label (e.g. "3d", "2w") and an oklch color string
176
- * that shifts from green (fresh) → blue → amber → orange → red (stale).
177
- *
178
- * Usage:
179
- * const age = taskAge(task.created_at)
180
- * // <span style="color: {age.color}">{age.label}</span>
181
- */
182
- export function taskAge(dateStr: string): { label: string; color: string } {
183
- const now = Date.now();
184
- const created = new Date(dateStr).getTime();
185
- const minutes = Math.floor((now - created) / 60000);
186
- const hours = Math.floor(minutes / 60);
187
- const days = Math.floor(hours / 24);
188
- const weeks = Math.floor(days / 7);
189
- const months = Math.floor(days / 30);
190
- if (minutes < 60) return { label: `${minutes}m`, color: 'oklch(0.75 0.18 145)' }; // green — fresh
191
- if (hours < 24) return { label: `${hours}h`, color: 'oklch(0.75 0.18 145)' }; // green
192
- if (days < 3) return { label: `${days}d`, color: 'oklch(0.70 0.15 200)' }; // blue — recent
193
- if (days < 7) return { label: `${days}d`, color: 'oklch(0.75 0.15 85)' }; // amber — aging
194
- if (weeks < 4) return { label: `${weeks}w`, color: 'oklch(0.65 0.18 50)' }; // orange — stale
195
- return { label: `${months}mo`, color: 'oklch(0.65 0.20 25)' }; // red — old
196
- }
@@ -1,84 +0,0 @@
1
- /**
2
- * Centralized Google Maps API loader for jatui.
3
- *
4
- * Prevents multiple script loads and ensures all required libraries are available.
5
- * Pass the API key explicitly — jatui is SvelteKit-agnostic (no $env imports).
6
- *
7
- * Usage:
8
- * await loadGoogleMapsAPI({ apiKey: 'YOUR_KEY', libraries: ['marker', 'geometry'] })
9
- * if (isGoogleMapsLoaded()) { ... }
10
- */
11
-
12
- interface LoadOptions {
13
- apiKey: string;
14
- libraries?: string[];
15
- }
16
-
17
- let loadPromise: Promise<void> | null = null;
18
- let isLoaded = false;
19
-
20
- export async function loadGoogleMapsAPI(options: LoadOptions): Promise<void> {
21
- if (typeof window === 'undefined') return;
22
-
23
- const { apiKey, libraries = [] } = options;
24
-
25
- if (!apiKey) {
26
- console.warn('googleMapsLoader: No API key provided');
27
- return;
28
- }
29
-
30
- // If already loaded and all required libraries are available, return
31
- if (isLoaded && window.google?.maps) {
32
- const allLibrariesAvailable = libraries.every((lib) => {
33
- switch (lib) {
34
- case 'places':
35
- return window.google?.maps?.places;
36
- case 'geometry':
37
- return window.google?.maps?.geometry;
38
- default:
39
- return true;
40
- }
41
- });
42
- if (allLibrariesAvailable) return;
43
- }
44
-
45
- // If already loading, return the existing promise
46
- if (loadPromise) return loadPromise;
47
-
48
- // Combine default libraries with requested ones
49
- const allLibraries = Array.from(new Set(['geometry', 'places', 'marker', ...libraries]));
50
-
51
- loadPromise = new Promise<void>((resolve, reject) => {
52
- const script = document.createElement('script');
53
- script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=${allLibraries.join(',')}`;
54
- script.async = true;
55
- script.defer = true;
56
-
57
- script.onload = () => {
58
- isLoaded = true;
59
- loadPromise = null;
60
- resolve();
61
- };
62
-
63
- script.onerror = (error) => {
64
- loadPromise = null;
65
- reject(error);
66
- };
67
-
68
- document.head.appendChild(script);
69
- });
70
-
71
- return loadPromise;
72
- }
73
-
74
- export function isGoogleMapsLoaded(): boolean {
75
- return isLoaded && !!window.google?.maps;
76
- }
77
-
78
- export function isPlacesLoaded(): boolean {
79
- return isGoogleMapsLoaded() && !!window.google?.maps?.places;
80
- }
81
-
82
- export function isGeometryLoaded(): boolean {
83
- return isGoogleMapsLoaded() && !!window.google?.maps?.geometry;
84
- }