@fluid-app/portal-sdk 0.1.336 → 0.1.338

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 (61) hide show
  1. package/dist/{AddressAutocompleteInput-DNwPytO3.mjs → AddressAutocompleteInput-D8vKXhYO.mjs} +2 -2
  2. package/dist/{AddressAutocompleteInput-DNwPytO3.mjs.map → AddressAutocompleteInput-D8vKXhYO.mjs.map} +1 -1
  3. package/dist/{AddressAutocompleteInput-BROuVHKH.cjs → AddressAutocompleteInput-Dt4OoHWV.cjs} +2 -2
  4. package/dist/{AddressAutocompleteInput-BROuVHKH.cjs.map → AddressAutocompleteInput-Dt4OoHWV.cjs.map} +1 -1
  5. package/dist/{CalendarWidget-mUe0zSHR.cjs → CalendarWidget-BVPa-S9H.cjs} +2 -2
  6. package/dist/{CalendarWidget-mUe0zSHR.cjs.map → CalendarWidget-BVPa-S9H.cjs.map} +1 -1
  7. package/dist/{CalendarWidget-Dogh_5TL.mjs → CalendarWidget-BwbuXbTw.mjs} +2 -2
  8. package/dist/{CalendarWidget-Dogh_5TL.mjs.map → CalendarWidget-BwbuXbTw.mjs.map} +1 -1
  9. package/dist/{ContactsScreen-BYrRJ55W.cjs → ContactsScreen-B3eVauD-.cjs} +2 -2
  10. package/dist/{ContactsScreen-Dm8b4SyY.cjs → ContactsScreen-BhgI_-6s.cjs} +2 -2
  11. package/dist/{ContactsScreen-Dm8b4SyY.cjs.map → ContactsScreen-BhgI_-6s.cjs.map} +1 -1
  12. package/dist/{ContactsScreen-DDgwD2MI.mjs → ContactsScreen-DW-F0wJy.mjs} +2 -2
  13. package/dist/{ContactsScreen-DDgwD2MI.mjs.map → ContactsScreen-DW-F0wJy.mjs.map} +1 -1
  14. package/dist/{FluidProvider-BAUaedtL.cjs → FluidProvider-DtsjXKhW.cjs} +6 -6
  15. package/dist/{FluidProvider-BAUaedtL.cjs.map → FluidProvider-DtsjXKhW.cjs.map} +1 -1
  16. package/dist/{FluidProvider-ZwaR2O-D.mjs → FluidProvider-kt_D_70p.mjs} +6 -6
  17. package/dist/{FluidProvider-ZwaR2O-D.mjs.map → FluidProvider-kt_D_70p.mjs.map} +1 -1
  18. package/dist/{MessagingScreen-C9fNBbmV.mjs → MessagingScreen-DIqEqpHc.mjs} +5 -5
  19. package/dist/{MessagingScreen-B6xwTuAi.cjs → MessagingScreen-DaGUbFap.cjs} +5 -5
  20. package/dist/{MessagingScreen-C7YZlR0A.cjs → MessagingScreen-IusKBudc.cjs} +2 -2
  21. package/dist/{MessagingScreen-C7YZlR0A.cjs.map → MessagingScreen-IusKBudc.cjs.map} +1 -1
  22. package/dist/{MessagingScreen-BhKuSrqK.mjs → MessagingScreen-pNgGuv10.mjs} +2 -2
  23. package/dist/{MessagingScreen-BhKuSrqK.mjs.map → MessagingScreen-pNgGuv10.mjs.map} +1 -1
  24. package/dist/{OrdersScreen-DwnskAqZ.cjs → OrdersScreen-BVirBT0C.cjs} +5 -5
  25. package/dist/{OrdersScreen-Hl7MAQLn.mjs → OrdersScreen-DMoa1Trl.mjs} +5 -5
  26. package/dist/{OrdersScreen-BHmvSSji.cjs → OrdersScreen-DUgM6eSF.cjs} +2 -2
  27. package/dist/{OrdersScreen-BHmvSSji.cjs.map → OrdersScreen-DUgM6eSF.cjs.map} +1 -1
  28. package/dist/{OrdersScreen-BGm510zd.mjs → OrdersScreen-DtIEFDdH.mjs} +2 -2
  29. package/dist/{OrdersScreen-BGm510zd.mjs.map → OrdersScreen-DtIEFDdH.mjs.map} +1 -1
  30. package/dist/{ProfileScreen-agkwY8nL.cjs → ProfileScreen-B1ufOonA.cjs} +6 -6
  31. package/dist/{ProfileScreen-DnGQ-Q7X.mjs → ProfileScreen-BbWJH8PZ.mjs} +3 -3
  32. package/dist/{ProfileScreen-DnGQ-Q7X.mjs.map → ProfileScreen-BbWJH8PZ.mjs.map} +1 -1
  33. package/dist/{ProfileScreen-B69eSFMU.mjs → ProfileScreen-CXXrYwSr.mjs} +6 -6
  34. package/dist/{ProfileScreen-dXCqFn1a.cjs → ProfileScreen-P_oroi6n.cjs} +3 -3
  35. package/dist/{ProfileScreen-dXCqFn1a.cjs.map → ProfileScreen-P_oroi6n.cjs.map} +1 -1
  36. package/dist/{ShopScreen-BaD6mPFj.mjs → ShopScreen-Bpx3RVcL.mjs} +2 -2
  37. package/dist/{ShopScreen-BaD6mPFj.mjs.map → ShopScreen-Bpx3RVcL.mjs.map} +1 -1
  38. package/dist/{ShopScreen-CHe3APFL.cjs → ShopScreen-CmHEYzWO.cjs} +5 -5
  39. package/dist/{ShopScreen-CY7sNmHW.mjs → ShopScreen-Cp4C5F-S.mjs} +5 -5
  40. package/dist/{ShopScreen-CWECMmWZ.cjs → ShopScreen-Dy4vW550.cjs} +2 -2
  41. package/dist/{ShopScreen-CWECMmWZ.cjs.map → ShopScreen-Dy4vW550.cjs.map} +1 -1
  42. package/dist/{SubscriptionsScreen-DUkEVtLV.mjs → SubscriptionsScreen-CCLs-jWG.mjs} +6 -6
  43. package/dist/{SubscriptionsScreen-BcUUuo7v.mjs → SubscriptionsScreen-CnMPK8cR.mjs} +3 -3
  44. package/dist/{SubscriptionsScreen-BcUUuo7v.mjs.map → SubscriptionsScreen-CnMPK8cR.mjs.map} +1 -1
  45. package/dist/{SubscriptionsScreen-B2bahevH.cjs → SubscriptionsScreen-DOfdH7d7.cjs} +3 -3
  46. package/dist/{SubscriptionsScreen-B2bahevH.cjs.map → SubscriptionsScreen-DOfdH7d7.cjs.map} +1 -1
  47. package/dist/{SubscriptionsScreen-BZbt45PM.cjs → SubscriptionsScreen-Dyy_wCaB.cjs} +6 -6
  48. package/dist/{ToDoWidget-6Yj9hQQ5.cjs → ToDoWidget-C8R0i2cb.cjs} +3 -3
  49. package/dist/ToDoWidget-C8R0i2cb.cjs.map +1 -0
  50. package/dist/{ToDoWidget-Bc3uv4ft.cjs → ToDoWidget-CPtn_Ptx.cjs} +2 -2
  51. package/dist/{ToDoWidget-B3sq5pIT.mjs → ToDoWidget-eYF1VvRa.mjs} +3 -3
  52. package/dist/ToDoWidget-eYF1VvRa.mjs.map +1 -0
  53. package/dist/index.cjs +23 -23
  54. package/dist/index.mjs +23 -23
  55. package/dist/{task-composer-form-CHyQZUCo.mjs → task-composer-form-Cq3KTV0Y.mjs} +17 -21
  56. package/dist/{task-composer-form-CHyQZUCo.mjs.map → task-composer-form-Cq3KTV0Y.mjs.map} +1 -1
  57. package/dist/{task-composer-form-D9KhWUI1.cjs → task-composer-form-DvVQw5ud.cjs} +17 -21
  58. package/dist/{task-composer-form-D9KhWUI1.cjs.map → task-composer-form-DvVQw5ud.cjs.map} +1 -1
  59. package/package.json +16 -16
  60. package/dist/ToDoWidget-6Yj9hQQ5.cjs.map +0 -1
  61. package/dist/ToDoWidget-B3sq5pIT.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"task-composer-form-CHyQZUCo.mjs","names":[],"sources":["../../../platform/api-client-core/src/parse-api-errors.ts","../../../contacts/core/src/contacts-api-context.ts","../../../contacts/core/src/translation-api-context.ts","../../../contacts/core/src/parse-task-body.ts","../../../contacts/core/src/query-keys.ts","../../../contacts/core/src/hooks/use-infinite-contacts.ts","../../../contacts/core/src/iso-date.ts","../../../contacts/ui/src/portal/hooks/contacts/use-create-contact-task.ts","../../../contacts/ui/src/portal/components/tasks/task-composer-form.tsx"],"sourcesContent":["/**\n * Framework-agnostic API error parsing utilities.\n *\n * Extracts structured field-level errors from API responses and formats\n * them into human-readable messages. Works with ApiError from this package\n * as well as any error object that has `status`, `data`, and optional `message`.\n */\n\n/**\n * Converts snake_case or camelCase field names to Title Case\n */\nexport function formatFieldName(field: string): string {\n return field\n .replace(/_/g, \" \")\n .replace(/([A-Z])/g, \" $1\")\n .split(\" \")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \")\n .trim();\n}\n\nexport interface ParsedFieldError {\n field: string;\n messages: string[];\n}\n\n/**\n * Type guard to check if an error looks like an API error\n */\nexport function isApiLikeError(\n error: unknown,\n): error is { message: string | undefined; status: number; data: unknown } {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n\n const err = error as Record<string, unknown>;\n return (\n typeof err.status === \"number\" &&\n \"data\" in err &&\n (typeof err.message === \"string\" || err.message === undefined)\n );\n}\n\n/**\n * Extracts field-level errors from API error data\n */\nexport function extractFieldErrors(data: unknown): ParsedFieldError[] {\n const errors: ParsedFieldError[] = [];\n\n if (!data || typeof data !== \"object\") {\n return errors;\n }\n\n const errorObj = data as Record<string, unknown>;\n\n for (const [key, value] of Object.entries(errorObj)) {\n if (Array.isArray(value) && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: value.map((item) =>\n typeof item === \"string\" ? item : JSON.stringify(item),\n ),\n });\n } else if (typeof value === \"string\" && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: [value],\n });\n } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n const nestedErrors = extractFieldErrors(value);\n nestedErrors.forEach((nestedError) => {\n errors.push({\n field: `${formatFieldName(key)} → ${nestedError.field}`,\n messages: nestedError.messages,\n });\n });\n }\n }\n\n return errors;\n}\n\n/**\n * Formats field errors into a readable description string\n */\nexport function formatErrorDescription(errors: ParsedFieldError[]): string {\n if (errors.length === 0) {\n return \"\";\n }\n\n if (errors.length === 1) {\n const err = errors[0];\n if (!err) return \"\";\n const message = err.messages[0] || \"is invalid\";\n return `${err.field} ${message}`;\n }\n\n if (errors.length <= 3) {\n return errors\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n }\n\n const shown = errors\n .slice(0, 3)\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n const remaining = errors.length - 3;\n return `${shown}\\n...and ${remaining} more ${remaining === 1 ? \"error\" : \"errors\"}`;\n}\n\n/**\n * Parses an error and returns a human-readable description string.\n *\n * Handles:\n * - API-like errors with structured field-level data\n * - API-like errors with a top-level message\n * - Standard Error instances\n * - Falls back to the provided fallback string\n *\n * @param error - The error to parse (ApiError, Error, or unknown)\n * @param fallback - Optional fallback description if error cannot be parsed\n * @returns A human-readable error description, or undefined if nothing could be extracted\n */\nexport function parseApiErrors(\n error: unknown,\n fallback?: string,\n): string | undefined {\n if (isApiLikeError(error)) {\n if (error.data) {\n const fieldErrors = extractFieldErrors(error.data);\n if (fieldErrors.length > 0) {\n return formatErrorDescription(fieldErrors);\n }\n }\n\n if (error.message) {\n return error.message;\n }\n } else if (error instanceof Error) {\n return error.message;\n }\n\n return fallback;\n}\n","import { createContext, useContext } from \"react\";\nimport type { ContactsApi } from \"./contacts-api\";\nimport type { NotesApi } from \"./notes-api\";\nimport type { TasksApi } from \"./tasks-api\";\nimport type { GroupsApi } from \"./groups-api\";\n\nexport interface ContactsDomainApi {\n contacts: ContactsApi;\n notes: NotesApi;\n tasks: TasksApi;\n groups?: GroupsApi;\n}\n\nconst ContactsApiContext = createContext<ContactsDomainApi | null>(null);\n\nexport const ContactsApiProvider = ContactsApiContext.Provider;\n\nexport function useContactsDomainApi(): ContactsDomainApi {\n const api = useContext(ContactsApiContext);\n if (!api) {\n throw new Error(\n \"useContactsDomainApi must be used within a ContactsApiProvider\",\n );\n }\n return api;\n}\n\nexport function useContactsCrud(): ContactsApi {\n return useContactsDomainApi().contacts;\n}\n\nexport function useNotesApi(): NotesApi {\n return useContactsDomainApi().notes;\n}\n\nexport function useTasksApi(): TasksApi {\n return useContactsDomainApi().tasks;\n}\n\n/** Returns GroupsApi if the provider supplies one, otherwise null. */\nexport function useGroupsApi(): GroupsApi | null {\n return useContactsDomainApi().groups ?? null;\n}\n","import type { Provider } from \"react\";\nimport { createTranslationContext } from \"@fluid-app/i18n/translation-api-context-factory\";\nimport type { TranslationApi } from \"@fluid-app/i18n/translation-api\";\nimport type { ContactsDict } from \"./translation-dictionary\";\n\nconst { Provider: ContactsProvider, useTranslation } =\n createTranslationContext<ContactsDict>(\"Contacts\");\n\nexport const ContactsTranslationProvider: Provider<TranslationApi<ContactsDict> | null> =\n ContactsProvider;\nexport const useContactsTranslation = useTranslation;\n","/**\n * Tasks store both a title (first line) and an optional body separated by a\n * blank line. This is the canonical convention used by the task editor and\n * by every consumer that displays tasks (contacts UI list, portal todo\n * widget). Drift across consumers would mean some surfaces show \"Title\\n\\n\n * body details\" verbatim while others split correctly — keep the delimiter\n * convention in one place.\n */\nexport function parseTaskBody(raw: string): { title: string; body: string } {\n const split = raw.indexOf(\"\\n\\n\");\n if (split >= 0) {\n return {\n title: raw.slice(0, split),\n body: raw.slice(split + 2),\n };\n }\n return { title: raw, body: \"\" };\n}\n","export const CONTACTS_QUERY_KEYS = {\n all: (prefix: string) => [prefix] as const,\n list: (prefix: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"list\"] as const,\n detail: (prefix: string, id: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"detail\", id] as const,\n} as const;\n\nexport const contactsKeys = {\n activities: (contactId: string) =>\n [\"portal-contacts\", \"activities\", contactId] as const,\n tasks: (contactId: string) =>\n [\"portal-contacts\", \"tasks\", contactId] as const,\n notes: (contactId: string) =>\n [\"portal-contacts\", \"notes\", contactId] as const,\n orders: (contactId: string) => [\"rep-contacts\", \"orders\", contactId] as const,\n subscriptionOrders: (contactId: string) =>\n [\"rep-contacts\", \"subscription-orders\", contactId] as const,\n groups: () => [\"portal-contacts\", \"groups\"] as const,\n} as const;\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport { useContactsCrud } from \"../contacts-api-context\";\nimport { CONTACTS_QUERY_KEYS } from \"../query-keys\";\n\nexport interface UseInfiniteContactsParams {\n search_query?: string;\n status?: string;\n sort_by?: string;\n sort_direction?: string;\n per_page?: number;\n tags?: string[];\n}\n\nexport function useInfiniteContacts(params: UseInfiniteContactsParams) {\n const api = useContactsCrud();\n return useInfiniteQuery({\n queryKey: [...CONTACTS_QUERY_KEYS.list(\"contacts\"), params],\n queryFn: ({ pageParam }) =>\n api.listContacts({\n ...params,\n page: pageParam,\n }),\n getNextPageParam: (lastPage) => {\n const currentPage = lastPage.meta.current_page;\n // Contacts API is page-number based; next_cursor and total_pages\n // are both used as \"has-next-page\" signals.\n if (currentPage == null) return undefined;\n if (lastPage.meta.next_cursor) return currentPage + 1;\n if (\n lastPage.meta.total_pages != null &&\n currentPage < lastPage.meta.total_pages\n ) {\n return currentPage + 1;\n }\n return undefined;\n },\n initialPageParam: 1,\n });\n}\n","/**\n * Format a date as YYYY-MM-DD in the renderer's local timezone, optionally\n * shifted by `offsetDays`. Use this for due-date inputs where \"today\" must\n * resolve to the user's local calendar date — never `toISOString().slice(0, 10)`,\n * which returns the UTC date and silently rolls over a day for users east/west\n * of UTC at the wrong hours.\n */\nexport function isoDate(offsetDays: number, now: Date = new Date()): string {\n const d = new Date(now);\n d.setDate(d.getDate() + offsetDays);\n const yyyy = d.getFullYear();\n const mm = String(d.getMonth() + 1).padStart(2, \"0\");\n const dd = String(d.getDate()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}`;\n}\n\n/**\n * Return a Date pinned to local midnight of the calendar day represented by\n * `input`. Use this whenever you need to compare two due dates by calendar day\n * (overdue / today / tomorrow / future).\n *\n * Why not just `new Date(input)`? `new Date(\"YYYY-MM-DD\")` parses the string\n * as UTC midnight, which lands on the *previous* calendar day in any UTC−\n * timezone — a task due \"May 1\" then reads as April 30 for a user in the\n * Americas, classifying it as \"Overdue\" all day. Parse the date components\n * directly so the calendar-day intent of the string is preserved.\n */\nexport function startOfLocalDay(input: Date | string): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(input);\n if (match?.[1] && match[2] && match[3]) {\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n }\n const d = typeof input === \"string\" ? new Date(input) : input;\n return new Date(d.getFullYear(), d.getMonth(), d.getDate());\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport { parseApiErrors } from \"@fluid-app/api-client-core\";\nimport { useTasksApi } from \"@fluid-app/contacts-core/contacts-api-context\";\nimport { contactsKeys } from \"@fluid-app/contacts-core/query-keys\";\nimport type { CreateTaskInput } from \"@fluid-app/contacts-core/types\";\n\nexport type { CreateTaskInput };\n\nexport function useCreateContactTask(\n contactId: string,\n options?: { onSuccess?: () => void },\n) {\n const queryClient = useQueryClient();\n const api = useTasksApi();\n\n return useMutation({\n mutationFn: (input: CreateTaskInput) => api.createTask(contactId, input),\n onSuccess: () => {\n fluidToast({ title: \"Task created\", type: \"success\" });\n queryClient.invalidateQueries({\n queryKey: contactsKeys.tasks(contactId),\n });\n options?.onSuccess?.();\n },\n onError: (error) => {\n const description = parseApiErrors(error);\n fluidToast({\n title: \"Failed to create task\",\n type: \"error\",\n ...(description ? { description } : {}),\n });\n },\n });\n}\n","\"use client\";\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@fluid-app/ui-primitives\";\nimport { useContactsTranslation } from \"@fluid-app/contacts-core/translation-api-context\";\nimport { isoDate } from \"@fluid-app/contacts-core/iso-date\";\nimport { useCreateContactTask } from \"../../hooks/contacts/use-create-contact-task\";\n\nconst QUICK_DATES = [\n { key: \"today\", offsetDays: 0 },\n { key: \"tomorrow\", offsetDays: 1 },\n { key: \"next_week\", offsetDays: 7 },\n] as const;\n\nexport interface TaskComposerFormProps {\n contactId: string;\n /** Called after a successful create. */\n onDone?: () => void;\n /** When provided, an X button is rendered and Escape closes the form. */\n onClose?: () => void;\n /** Focus the body input on mount. Default true. */\n autoFocus?: boolean;\n}\n\nexport function TaskComposerForm({\n contactId,\n onDone,\n onClose,\n autoFocus = true,\n}: TaskComposerFormProps): React.JSX.Element {\n const { t } = useContactsTranslation();\n const [body, setBody] = useState(\"\");\n const [dueDate, setDueDate] = useState<string | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const createTask = useCreateContactTask(contactId, {\n onSuccess: () => {\n setBody(\"\");\n setDueDate(null);\n onDone?.();\n },\n });\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n // Compute the date strings once per mount. Re-running on every render would\n // re-evaluate `new Date()` and could flip \"today\" if the form happens to be\n // open across midnight — acceptable but unnecessary churn.\n const quickDates = useMemo(\n () =>\n QUICK_DATES.map((q) => ({\n key: q.key,\n iso: isoDate(q.offsetDays),\n })),\n [],\n );\n\n const quickLabels: Record<(typeof QUICK_DATES)[number][\"key\"], string> = {\n today: t(\"quick_today\"),\n tomorrow: t(\"quick_tomorrow\"),\n next_week: t(\"quick_next_week\"),\n };\n\n const submit = () => {\n const trimmed = body.trim();\n if (!trimmed || createTask.isPending) return;\n createTask.mutate({ body: trimmed, due_at: dueDate });\n };\n\n const canSubmit = body.trim().length > 0 && !createTask.isPending;\n\n return (\n <div className=\"border-border/50 focus-within:border-foreground/30 rounded-xl border p-3 transition-colors\">\n <div className=\"flex items-start gap-3\">\n <div\n className=\"border-muted-foreground/50 mt-1.5 size-5 shrink-0 rounded-full border-2\"\n aria-hidden=\"true\"\n />\n <input\n ref={inputRef}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n submit();\n } else if (e.key === \"Escape\" && onClose) {\n e.preventDefault();\n onClose();\n }\n }}\n placeholder={t(\"task_describe_placeholder\")}\n aria-label={t(\"task_description_aria\")}\n className=\"placeholder:text-muted-foreground/80 text-foreground flex-1 border-0 bg-transparent text-sm font-medium outline-none\"\n />\n {onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={t(\"task_discard_aria\")}\n className=\"text-muted-foreground hover:bg-muted hover:text-foreground -mt-0.5 -mr-0.5 flex size-7 shrink-0 items-center justify-center rounded-md transition-colors\"\n >\n <X className=\"size-4\" />\n </button>\n )}\n </div>\n\n <div className=\"mt-3 flex items-center gap-1.5 pl-8\">\n {quickDates.map((q) => {\n const isActive = dueDate === q.iso;\n return (\n <button\n key={q.key}\n type=\"button\"\n onClick={() => setDueDate(isActive ? null : q.iso)}\n aria-pressed={isActive}\n className={cn(\n \"shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors\",\n isActive\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-muted/70\",\n )}\n >\n {quickLabels[q.key]}\n </button>\n );\n })}\n <div className=\"ml-auto\" />\n <button\n type=\"button\"\n onClick={submit}\n disabled={!canSubmit}\n className=\"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground inline-flex shrink-0 items-center gap-1.5 rounded-full px-4 py-1.5 text-xs font-semibold transition-colors disabled:cursor-not-allowed\"\n >\n {createTask.isPending ? t(\"adding\") : t(\"add_task\")}\n </button>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,SAAgB,gBAAgB,OAAuB;AACrD,QAAO,MACJ,QAAQ,MAAM,IAAI,CAClB,QAAQ,YAAY,MAAM,CAC1B,MAAM,IAAI,CACV,KAAK,SAAS,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC,aAAa,CAAC,CACzE,KAAK,IAAI,CACT,MAAM;;;;;AAWX,SAAgB,eACd,OACyE;AACzE,KAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO;CAGT,MAAM,MAAM;AACZ,QACE,OAAO,IAAI,WAAW,YACtB,UAAU,QACT,OAAO,IAAI,YAAY,YAAY,IAAI,YAAY,KAAA;;;;;AAOxD,SAAgB,mBAAmB,MAAmC;CACpE,MAAM,SAA6B,EAAE;AAErC,KAAI,CAAC,QAAQ,OAAO,SAAS,SAC3B,QAAO;CAGT,MAAM,WAAW;AAEjB,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,CACjD,KAAI,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,EACzC,QAAO,KA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;GAAS,QAAQ;GAAS,CAAC;;CAGvD,MAAM,YAAY,KAAK,MAAM,CAAC,SAAS,KAAK,CAAC,WAAW;AAExD,QACE,qBAAC,OAAD;EAAK,WAAU;YAAf,CACE,qBAAC,OAAD;GAAK,WAAU;aAAf;IACE,oBAAC,OAAD;KACE,WAAU;KACV,eAAY;KACZ,CAAA;IACF,oBAAC,SAAD;KACE,KAAK;KACL,OAAO;KACP,WAAW,MAAM,QAAQ,EAAE,OAAO,MAAM;KACxC,YAAY,MAAM;AAChB,UAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;AACpC,SAAE,gBAAgB;AAClB,eAAQ;iBACC,EAAE,QAAQ,YAAY,SAAS;AACxC,SAAE,gBAAgB;AAClB,gBAAS;;;KAGb,aAAa,EAAE,4BAA4B;KAC3C,cAAY,EAAE,wBAAwB;KACtC,WAAU;KACV,CAAA;IACD,WACC,oBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,cAAY,EAAE,oBAAoB;KAClC,WAAU;eAEV,oBAAC,GAAD,EAAG,WAAU,UAAW,CAAA;KACjB,CAAA;IAEP;MAEN,qBAAC,OAAD;GAAK,WAAU;aAAf;IACG,WAAW,KAAK,MAAM;KACrB,MAAM,WAAW,YAAY,EAAE;AAC/B,YACE,oBAAC,UAAD;MAEE,MAAK;MACL,eAAe,WAAW,WAAW,OAAO,EAAE,IAAI;MAClD,gBAAc;MACd,WAAW,GACT,yEACA,WACI,uCACA,mDACL;gBAEA,YAAY,EAAE;MACR,EAZF,EAAE,IAYA;MAEX;IACF,oBAAC,OAAD,EAAK,WAAU,WAAY,CAAA;IAC3B,oBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,UAAU,CAAC;KACX,WAAU;eAET,WAAW,YAAY,EAAE,SAAS,GAAG,EAAE,WAAW;KAC5C,CAAA;IACL;KACF"}
1
+ {"version":3,"file":"task-composer-form-Cq3KTV0Y.mjs","names":[],"sources":["../../../platform/api-client-core/src/parse-api-errors.ts","../../../contacts/core/src/contacts-api-context.ts","../../../contacts/core/src/translation-api-context.ts","../../../contacts/core/src/parse-task-body.ts","../../../contacts/core/src/query-keys.ts","../../../contacts/core/src/hooks/use-infinite-contacts.ts","../../../contacts/core/src/iso-date.ts","../../../contacts/ui/src/portal/hooks/contacts/use-create-contact-task.ts","../../../contacts/ui/src/portal/components/tasks/task-composer-form.tsx"],"sourcesContent":["/**\n * Framework-agnostic API error parsing utilities.\n *\n * Extracts structured field-level errors from API responses and formats\n * them into human-readable messages. Works with ApiError from this package\n * as well as any error object that has `status`, `data`, and optional `message`.\n */\n\n/**\n * Converts snake_case or camelCase field names to Title Case\n */\nexport function formatFieldName(field: string): string {\n return field\n .replace(/_/g, \" \")\n .replace(/([A-Z])/g, \" $1\")\n .split(\" \")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \")\n .trim();\n}\n\nexport interface ParsedFieldError {\n field: string;\n messages: string[];\n}\n\n/**\n * Type guard to check if an error looks like an API error\n */\nexport function isApiLikeError(\n error: unknown,\n): error is { message: string | undefined; status: number; data: unknown } {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n\n const err = error as Record<string, unknown>;\n return (\n typeof err.status === \"number\" &&\n \"data\" in err &&\n (typeof err.message === \"string\" || err.message === undefined)\n );\n}\n\n/**\n * Extracts field-level errors from API error data\n */\nexport function extractFieldErrors(data: unknown): ParsedFieldError[] {\n const errors: ParsedFieldError[] = [];\n\n if (!data || typeof data !== \"object\") {\n return errors;\n }\n\n const errorObj = data as Record<string, unknown>;\n\n for (const [key, value] of Object.entries(errorObj)) {\n if (Array.isArray(value) && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: value.map((item) =>\n typeof item === \"string\" ? item : JSON.stringify(item),\n ),\n });\n } else if (typeof value === \"string\" && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: [value],\n });\n } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n const nestedErrors = extractFieldErrors(value);\n nestedErrors.forEach((nestedError) => {\n errors.push({\n field: `${formatFieldName(key)} → ${nestedError.field}`,\n messages: nestedError.messages,\n });\n });\n }\n }\n\n return errors;\n}\n\n/**\n * Formats field errors into a readable description string\n */\nexport function formatErrorDescription(errors: ParsedFieldError[]): string {\n if (errors.length === 0) {\n return \"\";\n }\n\n if (errors.length === 1) {\n const err = errors[0];\n if (!err) return \"\";\n const message = err.messages[0] || \"is invalid\";\n return `${err.field} ${message}`;\n }\n\n if (errors.length <= 3) {\n return errors\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n }\n\n const shown = errors\n .slice(0, 3)\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n const remaining = errors.length - 3;\n return `${shown}\\n...and ${remaining} more ${remaining === 1 ? \"error\" : \"errors\"}`;\n}\n\n/**\n * Parses an error and returns a human-readable description string.\n *\n * Handles:\n * - API-like errors with structured field-level data\n * - API-like errors with a top-level message\n * - Standard Error instances\n * - Falls back to the provided fallback string\n *\n * @param error - The error to parse (ApiError, Error, or unknown)\n * @param fallback - Optional fallback description if error cannot be parsed\n * @returns A human-readable error description, or undefined if nothing could be extracted\n */\nexport function parseApiErrors(\n error: unknown,\n fallback?: string,\n): string | undefined {\n if (isApiLikeError(error)) {\n if (error.data) {\n const fieldErrors = extractFieldErrors(error.data);\n if (fieldErrors.length > 0) {\n return formatErrorDescription(fieldErrors);\n }\n }\n\n if (error.message) {\n return error.message;\n }\n } else if (error instanceof Error) {\n return error.message;\n }\n\n return fallback;\n}\n","import { createContext, useContext } from \"react\";\nimport type { ContactsApi } from \"./contacts-api\";\nimport type { NotesApi } from \"./notes-api\";\nimport type { TasksApi } from \"./tasks-api\";\nimport type { GroupsApi } from \"./groups-api\";\n\nexport interface ContactsDomainApi {\n contacts: ContactsApi;\n notes: NotesApi;\n tasks: TasksApi;\n groups?: GroupsApi;\n}\n\nconst ContactsApiContext = createContext<ContactsDomainApi | null>(null);\n\nexport const ContactsApiProvider = ContactsApiContext.Provider;\n\nexport function useContactsDomainApi(): ContactsDomainApi {\n const api = useContext(ContactsApiContext);\n if (!api) {\n throw new Error(\n \"useContactsDomainApi must be used within a ContactsApiProvider\",\n );\n }\n return api;\n}\n\nexport function useContactsCrud(): ContactsApi {\n return useContactsDomainApi().contacts;\n}\n\nexport function useNotesApi(): NotesApi {\n return useContactsDomainApi().notes;\n}\n\nexport function useTasksApi(): TasksApi {\n return useContactsDomainApi().tasks;\n}\n\n/** Returns GroupsApi if the provider supplies one, otherwise null. */\nexport function useGroupsApi(): GroupsApi | null {\n return useContactsDomainApi().groups ?? null;\n}\n","import type { Provider } from \"react\";\nimport { createTranslationContext } from \"@fluid-app/i18n/translation-api-context-factory\";\nimport type { TranslationApi } from \"@fluid-app/i18n/translation-api\";\nimport type { ContactsDict } from \"./translation-dictionary\";\n\nconst { Provider: ContactsProvider, useTranslation } =\n createTranslationContext<ContactsDict>(\"Contacts\");\n\nexport const ContactsTranslationProvider: Provider<TranslationApi<ContactsDict> | null> =\n ContactsProvider;\nexport const useContactsTranslation = useTranslation;\n","/**\n * Tasks store both a title (first line) and an optional body separated by a\n * blank line. This is the canonical convention used by the task editor and\n * by every consumer that displays tasks (contacts UI list, portal todo\n * widget). Drift across consumers would mean some surfaces show \"Title\\n\\n\n * body details\" verbatim while others split correctly — keep the delimiter\n * convention in one place.\n */\nexport function parseTaskBody(raw: string): { title: string; body: string } {\n const split = raw.indexOf(\"\\n\\n\");\n if (split >= 0) {\n return {\n title: raw.slice(0, split),\n body: raw.slice(split + 2),\n };\n }\n return { title: raw, body: \"\" };\n}\n","export const CONTACTS_QUERY_KEYS = {\n all: (prefix: string) => [prefix] as const,\n list: (prefix: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"list\"] as const,\n detail: (prefix: string, id: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"detail\", id] as const,\n} as const;\n\nexport const contactsKeys = {\n activities: (contactId: string) =>\n [\"portal-contacts\", \"activities\", contactId] as const,\n tasks: (contactId: string) =>\n [\"portal-contacts\", \"tasks\", contactId] as const,\n notes: (contactId: string) =>\n [\"portal-contacts\", \"notes\", contactId] as const,\n orders: (contactId: string) => [\"rep-contacts\", \"orders\", contactId] as const,\n subscriptionOrders: (contactId: string) =>\n [\"rep-contacts\", \"subscription-orders\", contactId] as const,\n groups: () => [\"portal-contacts\", \"groups\"] as const,\n} as const;\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport { useContactsCrud } from \"../contacts-api-context\";\nimport { CONTACTS_QUERY_KEYS } from \"../query-keys\";\n\nexport interface UseInfiniteContactsParams {\n search_query?: string;\n status?: string;\n sort_by?: string;\n sort_direction?: string;\n per_page?: number;\n tags?: string[];\n}\n\nexport function useInfiniteContacts(params: UseInfiniteContactsParams) {\n const api = useContactsCrud();\n return useInfiniteQuery({\n queryKey: [...CONTACTS_QUERY_KEYS.list(\"contacts\"), params],\n queryFn: ({ pageParam }) =>\n api.listContacts({\n ...params,\n page: pageParam,\n }),\n getNextPageParam: (lastPage) => {\n const currentPage = lastPage.meta.current_page;\n // Contacts API is page-number based; next_cursor and total_pages\n // are both used as \"has-next-page\" signals.\n if (currentPage == null) return undefined;\n if (lastPage.meta.next_cursor) return currentPage + 1;\n if (\n lastPage.meta.total_pages != null &&\n currentPage < lastPage.meta.total_pages\n ) {\n return currentPage + 1;\n }\n return undefined;\n },\n initialPageParam: 1,\n });\n}\n","/**\n * Format a date as YYYY-MM-DD in the renderer's local timezone, optionally\n * shifted by `offsetDays`. Use this for due-date inputs where \"today\" must\n * resolve to the user's local calendar date — never `toISOString().slice(0, 10)`,\n * which returns the UTC date and silently rolls over a day for users east/west\n * of UTC at the wrong hours.\n */\nexport function isoDate(offsetDays: number, now: Date = new Date()): string {\n const d = new Date(now);\n d.setDate(d.getDate() + offsetDays);\n const yyyy = d.getFullYear();\n const mm = String(d.getMonth() + 1).padStart(2, \"0\");\n const dd = String(d.getDate()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}`;\n}\n\n/**\n * Return a Date pinned to local midnight of the calendar day represented by\n * `input`. Use this whenever you need to compare two due dates by calendar day\n * (overdue / today / tomorrow / future).\n *\n * Why not just `new Date(input)`? `new Date(\"YYYY-MM-DD\")` parses the string\n * as UTC midnight, which lands on the *previous* calendar day in any UTC−\n * timezone — a task due \"May 1\" then reads as April 30 for a user in the\n * Americas, classifying it as \"Overdue\" all day. Parse the date components\n * directly so the calendar-day intent of the string is preserved.\n */\nexport function startOfLocalDay(input: Date | string): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(input);\n if (match?.[1] && match[2] && match[3]) {\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n }\n const d = typeof input === \"string\" ? new Date(input) : input;\n return new Date(d.getFullYear(), d.getMonth(), d.getDate());\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport { parseApiErrors } from \"@fluid-app/api-client-core\";\nimport { useTasksApi } from \"@fluid-app/contacts-core/contacts-api-context\";\nimport { contactsKeys } from \"@fluid-app/contacts-core/query-keys\";\nimport type { CreateTaskInput } from \"@fluid-app/contacts-core/types\";\n\nexport type { CreateTaskInput };\n\nexport function useCreateContactTask(\n contactId: string,\n options?: { onSuccess?: () => void },\n) {\n const queryClient = useQueryClient();\n const api = useTasksApi();\n\n return useMutation({\n mutationFn: (input: CreateTaskInput) => api.createTask(contactId, input),\n onSuccess: () => {\n fluidToast({ title: \"Task created\", type: \"success\" });\n queryClient.invalidateQueries({\n queryKey: contactsKeys.tasks(contactId),\n });\n options?.onSuccess?.();\n },\n onError: (error) => {\n const description = parseApiErrors(error);\n fluidToast({\n title: \"Failed to create task\",\n type: \"error\",\n ...(description ? { description } : {}),\n });\n },\n });\n}\n","\"use client\";\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@fluid-app/ui-primitives\";\nimport { useContactsTranslation } from \"@fluid-app/contacts-core/translation-api-context\";\nimport { isoDate } from \"@fluid-app/contacts-core/iso-date\";\nimport { useCreateContactTask } from \"../../hooks/contacts/use-create-contact-task\";\n\nconst QUICK_DATES = [\n { key: \"today\", offsetDays: 0 },\n { key: \"tomorrow\", offsetDays: 1 },\n { key: \"next_week\", offsetDays: 7 },\n] as const;\n\nexport interface TaskComposerFormProps {\n contactId: string;\n /** Called after a successful create. */\n onDone?: () => void;\n /** When provided, an X button is rendered and Escape closes the form. */\n onClose?: () => void;\n /** Focus the body input on mount. Default true. */\n autoFocus?: boolean;\n}\n\nexport function TaskComposerForm({\n contactId,\n onDone,\n onClose,\n autoFocus = true,\n}: TaskComposerFormProps): React.JSX.Element {\n const { t } = useContactsTranslation();\n const [body, setBody] = useState(\"\");\n const [dueDate, setDueDate] = useState<string | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const createTask = useCreateContactTask(contactId, {\n onSuccess: () => {\n setBody(\"\");\n setDueDate(null);\n onDone?.();\n },\n });\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n // Compute the date strings once per mount. Re-running on every render would\n // re-evaluate `new Date()` and could flip \"today\" if the form happens to be\n // open across midnight — acceptable but unnecessary churn.\n const quickDates = useMemo(\n () =>\n QUICK_DATES.map((q) => ({\n key: q.key,\n iso: isoDate(q.offsetDays),\n })),\n [],\n );\n\n const quickLabels: Record<(typeof QUICK_DATES)[number][\"key\"], string> = {\n today: t(\"quick_today\"),\n tomorrow: t(\"quick_tomorrow\"),\n next_week: t(\"quick_next_week\"),\n };\n\n const submit = () => {\n const trimmed = body.trim();\n if (!trimmed || createTask.isPending) return;\n createTask.mutate({ body: trimmed, due_at: dueDate });\n };\n\n const canSubmit = body.trim().length > 0 && !createTask.isPending;\n\n return (\n <div className=\"border-border/50 focus-within:border-foreground/30 rounded-xl border p-3 transition-colors\">\n <div className=\"flex items-start gap-3\">\n <div\n className=\"border-muted-foreground/50 mt-1.5 size-5 shrink-0 rounded-full border-2\"\n aria-hidden=\"true\"\n />\n <input\n ref={inputRef}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n submit();\n } else if (e.key === \"Escape\" && onClose) {\n e.preventDefault();\n onClose();\n }\n }}\n placeholder={t(\"task_describe_placeholder\")}\n aria-label={t(\"task_description_aria\")}\n className=\"placeholder:text-muted-foreground/80 text-foreground flex-1 border-0 bg-transparent text-sm font-medium outline-none\"\n />\n {onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={t(\"task_discard_aria\")}\n className=\"text-muted-foreground hover:bg-muted hover:text-foreground -mt-0.5 -mr-0.5 flex size-7 shrink-0 items-center justify-center rounded-md transition-colors\"\n >\n <X className=\"size-4\" />\n </button>\n )}\n </div>\n\n {/* --row-indent aligns the chip row with the input text above (size-5\n circle + gap-3 = 2rem). The mobile Add button cancels it via\n -ml-(--row-indent) + w-[calc(100%+var(--row-indent))] so the two\n values stay locked to a single source. */}\n <div className=\"mt-3 flex flex-wrap items-center gap-1.5 pl-(--row-indent) [--row-indent:2rem]\">\n {quickDates.map((q) => {\n const isActive = dueDate === q.iso;\n return (\n <button\n key={q.key}\n type=\"button\"\n onClick={() => setDueDate(isActive ? null : q.iso)}\n aria-pressed={isActive}\n className={cn(\n \"shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors\",\n isActive\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-muted/70\",\n )}\n >\n {quickLabels[q.key]}\n </button>\n );\n })}\n <button\n type=\"button\"\n onClick={submit}\n disabled={!canSubmit}\n className=\"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground mt-1 -ml-(--row-indent) inline-flex h-10 w-[calc(100%+var(--row-indent))] items-center justify-center rounded-lg text-sm font-semibold transition-colors disabled:cursor-not-allowed sm:mt-0 sm:ml-auto sm:h-auto sm:w-auto sm:shrink-0 sm:gap-1.5 sm:rounded-full sm:px-4 sm:py-1.5 sm:text-xs\"\n >\n {createTask.isPending ? t(\"adding\") : t(\"add_task\")}\n </button>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAWA,SAAgB,gBAAgB,OAAuB;AACrD,QAAO,MACJ,QAAQ,MAAM,IAAI,CAClB,QAAQ,YAAY,MAAM,CAC1B,MAAM,IAAI,CACV,KAAK,SAAS,KAAK,OAAO,EAAE,CAAC,aAAa,GAAG,KAAK,MAAM,EAAE,CAAC,aAAa,CAAC,CACzE,KAAK,IAAI,CACT,MAAM;;;;;AAWX,SAAgB,eACd,OACyE;AACzE,KAAI,CAAC,SAAS,OAAO,UAAU,SAC7B,QAAO;CAGT,MAAM,MAAM;AACZ,QACE,OAAO,IAAI,WAAW,YACtB,UAAU,QACT,OAAO,IAAI,YAAY,YAAY,IAAI,YAAY,KAAA;;;;;AAOxD,SAAgB,mBAAmB,MAAmC;CACpE,MAAM,SAA6B,EAAE;AAErC,KAAI,CAAC,QAAQ,OAAO,SAAS,SAC3B,QAAO;CAGT,MAAM,WAAW;AAEjB,MAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,SAAS,CACjD,KAAI,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,EACzC,QAAO,KAAK;EACV,OAAO,gBAAgB,IAAI;EAC3B,UAAU,MAAM,KAAK,SACnB,OAAO,SAAS,WAAW,OAAO,KAAK,UAAU,KAAK,CACvD;EACF,CAAC;UACO,OAAO,UAAU,YAAY,MAAM,SAAS,EACrD,QAAO,KAAK;EACV,OAAO,gBAAgB,IAAI;EAC3B,UAAU,CAAC,MAAM;EAClB,CAAC;UACO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,MAAM,CAC/C,oBAAmB,MAAM,CACjC,SAAS,gBAAgB;AACpC,SAAO,KAAK;GACV,O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,EAAE,UAAU;AACpC,SAAE,gBAAgB;AAClB,eAAQ;iBACC,EAAE,QAAQ,YAAY,SAAS;AACxC,SAAE,gBAAgB;AAClB,gBAAS;;;KAGb,aAAa,EAAE,4BAA4B;KAC3C,cAAY,EAAE,wBAAwB;KACtC,WAAU;KACV,CAAA;IACD,WACC,oBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,cAAY,EAAE,oBAAoB;KAClC,WAAU;eAEV,oBAAC,GAAD,EAAG,WAAU,UAAW,CAAA;KACjB,CAAA;IAEP;MAMN,qBAAC,OAAD;GAAK,WAAU;aAAf,CACG,WAAW,KAAK,MAAM;IACrB,MAAM,WAAW,YAAY,EAAE;AAC/B,WACE,oBAAC,UAAD;KAEE,MAAK;KACL,eAAe,WAAW,WAAW,OAAO,EAAE,IAAI;KAClD,gBAAc;KACd,WAAW,GACT,yEACA,WACI,uCACA,mDACL;eAEA,YAAY,EAAE;KACR,EAZF,EAAE,IAYA;KAEX,EACF,oBAAC,UAAD;IACE,MAAK;IACL,SAAS;IACT,UAAU,CAAC;IACX,WAAU;cAET,WAAW,YAAY,EAAE,SAAS,GAAG,EAAE,WAAW;IAC5C,CAAA,CACL;KACF"}
@@ -336,27 +336,23 @@ function TaskComposerForm({ contactId, onDone, onClose, autoFocus = true }) {
336
336
  })
337
337
  ]
338
338
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
339
- className: "mt-3 flex items-center gap-1.5 pl-8",
340
- children: [
341
- quickDates.map((q) => {
342
- const isActive = dueDate === q.iso;
343
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
344
- type: "button",
345
- onClick: () => setDueDate(isActive ? null : q.iso),
346
- "aria-pressed": isActive,
347
- className: require_src.cn("shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors", isActive ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground hover:bg-muted/70"),
348
- children: quickLabels[q.key]
349
- }, q.key);
350
- }),
351
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "ml-auto" }),
352
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
339
+ className: "mt-3 flex flex-wrap items-center gap-1.5 pl-(--row-indent) [--row-indent:2rem]",
340
+ children: [quickDates.map((q) => {
341
+ const isActive = dueDate === q.iso;
342
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
353
343
  type: "button",
354
- onClick: submit,
355
- disabled: !canSubmit,
356
- className: "bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground inline-flex shrink-0 items-center gap-1.5 rounded-full px-4 py-1.5 text-xs font-semibold transition-colors disabled:cursor-not-allowed",
357
- children: createTask.isPending ? t("adding") : t("add_task")
358
- })
359
- ]
344
+ onClick: () => setDueDate(isActive ? null : q.iso),
345
+ "aria-pressed": isActive,
346
+ className: require_src.cn("shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors", isActive ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground hover:bg-muted/70"),
347
+ children: quickLabels[q.key]
348
+ }, q.key);
349
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
350
+ type: "button",
351
+ onClick: submit,
352
+ disabled: !canSubmit,
353
+ className: "bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground mt-1 -ml-(--row-indent) inline-flex h-10 w-[calc(100%+var(--row-indent))] items-center justify-center rounded-lg text-sm font-semibold transition-colors disabled:cursor-not-allowed sm:mt-0 sm:ml-auto sm:h-auto sm:w-auto sm:shrink-0 sm:gap-1.5 sm:rounded-full sm:px-4 sm:py-1.5 sm:text-xs",
354
+ children: createTask.isPending ? t("adding") : t("add_task")
355
+ })]
360
356
  })]
361
357
  });
362
358
  }
@@ -446,4 +442,4 @@ Object.defineProperty(exports, "useTasksApi", {
446
442
  }
447
443
  });
448
444
 
449
- //# sourceMappingURL=task-composer-form-D9KhWUI1.cjs.map
445
+ //# sourceMappingURL=task-composer-form-DvVQw5ud.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"task-composer-form-D9KhWUI1.cjs","names":["createTranslationContext","X","cn"],"sources":["../../../platform/api-client-core/src/parse-api-errors.ts","../../../contacts/core/src/contacts-api-context.ts","../../../contacts/core/src/translation-api-context.ts","../../../contacts/core/src/parse-task-body.ts","../../../contacts/core/src/query-keys.ts","../../../contacts/core/src/hooks/use-infinite-contacts.ts","../../../contacts/core/src/iso-date.ts","../../../contacts/ui/src/portal/hooks/contacts/use-create-contact-task.ts","../../../contacts/ui/src/portal/components/tasks/task-composer-form.tsx"],"sourcesContent":["/**\n * Framework-agnostic API error parsing utilities.\n *\n * Extracts structured field-level errors from API responses and formats\n * them into human-readable messages. Works with ApiError from this package\n * as well as any error object that has `status`, `data`, and optional `message`.\n */\n\n/**\n * Converts snake_case or camelCase field names to Title Case\n */\nexport function formatFieldName(field: string): string {\n return field\n .replace(/_/g, \" \")\n .replace(/([A-Z])/g, \" $1\")\n .split(\" \")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \")\n .trim();\n}\n\nexport interface ParsedFieldError {\n field: string;\n messages: string[];\n}\n\n/**\n * Type guard to check if an error looks like an API error\n */\nexport function isApiLikeError(\n error: unknown,\n): error is { message: string | undefined; status: number; data: unknown } {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n\n const err = error as Record<string, unknown>;\n return (\n typeof err.status === \"number\" &&\n \"data\" in err &&\n (typeof err.message === \"string\" || err.message === undefined)\n );\n}\n\n/**\n * Extracts field-level errors from API error data\n */\nexport function extractFieldErrors(data: unknown): ParsedFieldError[] {\n const errors: ParsedFieldError[] = [];\n\n if (!data || typeof data !== \"object\") {\n return errors;\n }\n\n const errorObj = data as Record<string, unknown>;\n\n for (const [key, value] of Object.entries(errorObj)) {\n if (Array.isArray(value) && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: value.map((item) =>\n typeof item === \"string\" ? item : JSON.stringify(item),\n ),\n });\n } else if (typeof value === \"string\" && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: [value],\n });\n } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n const nestedErrors = extractFieldErrors(value);\n nestedErrors.forEach((nestedError) => {\n errors.push({\n field: `${formatFieldName(key)} → ${nestedError.field}`,\n messages: nestedError.messages,\n });\n });\n }\n }\n\n return errors;\n}\n\n/**\n * Formats field errors into a readable description string\n */\nexport function formatErrorDescription(errors: ParsedFieldError[]): string {\n if (errors.length === 0) {\n return \"\";\n }\n\n if (errors.length === 1) {\n const err = errors[0];\n if (!err) return \"\";\n const message = err.messages[0] || \"is invalid\";\n return `${err.field} ${message}`;\n }\n\n if (errors.length <= 3) {\n return errors\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n }\n\n const shown = errors\n .slice(0, 3)\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n const remaining = errors.length - 3;\n return `${shown}\\n...and ${remaining} more ${remaining === 1 ? \"error\" : \"errors\"}`;\n}\n\n/**\n * Parses an error and returns a human-readable description string.\n *\n * Handles:\n * - API-like errors with structured field-level data\n * - API-like errors with a top-level message\n * - Standard Error instances\n * - Falls back to the provided fallback string\n *\n * @param error - The error to parse (ApiError, Error, or unknown)\n * @param fallback - Optional fallback description if error cannot be parsed\n * @returns A human-readable error description, or undefined if nothing could be extracted\n */\nexport function parseApiErrors(\n error: unknown,\n fallback?: string,\n): string | undefined {\n if (isApiLikeError(error)) {\n if (error.data) {\n const fieldErrors = extractFieldErrors(error.data);\n if (fieldErrors.length > 0) {\n return formatErrorDescription(fieldErrors);\n }\n }\n\n if (error.message) {\n return error.message;\n }\n } else if (error instanceof Error) {\n return error.message;\n }\n\n return fallback;\n}\n","import { createContext, useContext } from \"react\";\nimport type { ContactsApi } from \"./contacts-api\";\nimport type { NotesApi } from \"./notes-api\";\nimport type { TasksApi } from \"./tasks-api\";\nimport type { GroupsApi } from \"./groups-api\";\n\nexport interface ContactsDomainApi {\n contacts: ContactsApi;\n notes: NotesApi;\n tasks: TasksApi;\n groups?: GroupsApi;\n}\n\nconst ContactsApiContext = createContext<ContactsDomainApi | null>(null);\n\nexport const ContactsApiProvider = ContactsApiContext.Provider;\n\nexport function useContactsDomainApi(): ContactsDomainApi {\n const api = useContext(ContactsApiContext);\n if (!api) {\n throw new Error(\n \"useContactsDomainApi must be used within a ContactsApiProvider\",\n );\n }\n return api;\n}\n\nexport function useContactsCrud(): ContactsApi {\n return useContactsDomainApi().contacts;\n}\n\nexport function useNotesApi(): NotesApi {\n return useContactsDomainApi().notes;\n}\n\nexport function useTasksApi(): TasksApi {\n return useContactsDomainApi().tasks;\n}\n\n/** Returns GroupsApi if the provider supplies one, otherwise null. */\nexport function useGroupsApi(): GroupsApi | null {\n return useContactsDomainApi().groups ?? null;\n}\n","import type { Provider } from \"react\";\nimport { createTranslationContext } from \"@fluid-app/i18n/translation-api-context-factory\";\nimport type { TranslationApi } from \"@fluid-app/i18n/translation-api\";\nimport type { ContactsDict } from \"./translation-dictionary\";\n\nconst { Provider: ContactsProvider, useTranslation } =\n createTranslationContext<ContactsDict>(\"Contacts\");\n\nexport const ContactsTranslationProvider: Provider<TranslationApi<ContactsDict> | null> =\n ContactsProvider;\nexport const useContactsTranslation = useTranslation;\n","/**\n * Tasks store both a title (first line) and an optional body separated by a\n * blank line. This is the canonical convention used by the task editor and\n * by every consumer that displays tasks (contacts UI list, portal todo\n * widget). Drift across consumers would mean some surfaces show \"Title\\n\\n\n * body details\" verbatim while others split correctly — keep the delimiter\n * convention in one place.\n */\nexport function parseTaskBody(raw: string): { title: string; body: string } {\n const split = raw.indexOf(\"\\n\\n\");\n if (split >= 0) {\n return {\n title: raw.slice(0, split),\n body: raw.slice(split + 2),\n };\n }\n return { title: raw, body: \"\" };\n}\n","export const CONTACTS_QUERY_KEYS = {\n all: (prefix: string) => [prefix] as const,\n list: (prefix: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"list\"] as const,\n detail: (prefix: string, id: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"detail\", id] as const,\n} as const;\n\nexport const contactsKeys = {\n activities: (contactId: string) =>\n [\"portal-contacts\", \"activities\", contactId] as const,\n tasks: (contactId: string) =>\n [\"portal-contacts\", \"tasks\", contactId] as const,\n notes: (contactId: string) =>\n [\"portal-contacts\", \"notes\", contactId] as const,\n orders: (contactId: string) => [\"rep-contacts\", \"orders\", contactId] as const,\n subscriptionOrders: (contactId: string) =>\n [\"rep-contacts\", \"subscription-orders\", contactId] as const,\n groups: () => [\"portal-contacts\", \"groups\"] as const,\n} as const;\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport { useContactsCrud } from \"../contacts-api-context\";\nimport { CONTACTS_QUERY_KEYS } from \"../query-keys\";\n\nexport interface UseInfiniteContactsParams {\n search_query?: string;\n status?: string;\n sort_by?: string;\n sort_direction?: string;\n per_page?: number;\n tags?: string[];\n}\n\nexport function useInfiniteContacts(params: UseInfiniteContactsParams) {\n const api = useContactsCrud();\n return useInfiniteQuery({\n queryKey: [...CONTACTS_QUERY_KEYS.list(\"contacts\"), params],\n queryFn: ({ pageParam }) =>\n api.listContacts({\n ...params,\n page: pageParam,\n }),\n getNextPageParam: (lastPage) => {\n const currentPage = lastPage.meta.current_page;\n // Contacts API is page-number based; next_cursor and total_pages\n // are both used as \"has-next-page\" signals.\n if (currentPage == null) return undefined;\n if (lastPage.meta.next_cursor) return currentPage + 1;\n if (\n lastPage.meta.total_pages != null &&\n currentPage < lastPage.meta.total_pages\n ) {\n return currentPage + 1;\n }\n return undefined;\n },\n initialPageParam: 1,\n });\n}\n","/**\n * Format a date as YYYY-MM-DD in the renderer's local timezone, optionally\n * shifted by `offsetDays`. Use this for due-date inputs where \"today\" must\n * resolve to the user's local calendar date — never `toISOString().slice(0, 10)`,\n * which returns the UTC date and silently rolls over a day for users east/west\n * of UTC at the wrong hours.\n */\nexport function isoDate(offsetDays: number, now: Date = new Date()): string {\n const d = new Date(now);\n d.setDate(d.getDate() + offsetDays);\n const yyyy = d.getFullYear();\n const mm = String(d.getMonth() + 1).padStart(2, \"0\");\n const dd = String(d.getDate()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}`;\n}\n\n/**\n * Return a Date pinned to local midnight of the calendar day represented by\n * `input`. Use this whenever you need to compare two due dates by calendar day\n * (overdue / today / tomorrow / future).\n *\n * Why not just `new Date(input)`? `new Date(\"YYYY-MM-DD\")` parses the string\n * as UTC midnight, which lands on the *previous* calendar day in any UTC−\n * timezone — a task due \"May 1\" then reads as April 30 for a user in the\n * Americas, classifying it as \"Overdue\" all day. Parse the date components\n * directly so the calendar-day intent of the string is preserved.\n */\nexport function startOfLocalDay(input: Date | string): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(input);\n if (match?.[1] && match[2] && match[3]) {\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n }\n const d = typeof input === \"string\" ? new Date(input) : input;\n return new Date(d.getFullYear(), d.getMonth(), d.getDate());\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport { parseApiErrors } from \"@fluid-app/api-client-core\";\nimport { useTasksApi } from \"@fluid-app/contacts-core/contacts-api-context\";\nimport { contactsKeys } from \"@fluid-app/contacts-core/query-keys\";\nimport type { CreateTaskInput } from \"@fluid-app/contacts-core/types\";\n\nexport type { CreateTaskInput };\n\nexport function useCreateContactTask(\n contactId: string,\n options?: { onSuccess?: () => void },\n) {\n const queryClient = useQueryClient();\n const api = useTasksApi();\n\n return useMutation({\n mutationFn: (input: CreateTaskInput) => api.createTask(contactId, input),\n onSuccess: () => {\n fluidToast({ title: \"Task created\", type: \"success\" });\n queryClient.invalidateQueries({\n queryKey: contactsKeys.tasks(contactId),\n });\n options?.onSuccess?.();\n },\n onError: (error) => {\n const description = parseApiErrors(error);\n fluidToast({\n title: \"Failed to create task\",\n type: \"error\",\n ...(description ? { description } : {}),\n });\n },\n });\n}\n","\"use client\";\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@fluid-app/ui-primitives\";\nimport { useContactsTranslation } from \"@fluid-app/contacts-core/translation-api-context\";\nimport { isoDate } from \"@fluid-app/contacts-core/iso-date\";\nimport { useCreateContactTask } from \"../../hooks/contacts/use-create-contact-task\";\n\nconst QUICK_DATES = [\n { key: \"today\", offsetDays: 0 },\n { key: \"tomorrow\", offsetDays: 1 },\n { key: \"next_week\", offsetDays: 7 },\n] as const;\n\nexport interface TaskComposerFormProps {\n contactId: string;\n /** Called after a successful create. */\n onDone?: () => void;\n /** When provided, an X button is rendered and Escape closes the form. */\n onClose?: () => void;\n /** Focus the body input on mount. Default true. */\n autoFocus?: boolean;\n}\n\nexport function TaskComposerForm({\n contactId,\n onDone,\n onClose,\n autoFocus = true,\n}: TaskComposerFormProps): React.JSX.Element {\n const { t } = useContactsTranslation();\n const [body, setBody] = useState(\"\");\n const [dueDate, setDueDate] = useState<string | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const createTask = useCreateContactTask(contactId, {\n onSuccess: () => {\n setBody(\"\");\n setDueDate(null);\n onDone?.();\n },\n });\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n // Compute the date strings once per mount. Re-running on every render would\n // re-evaluate `new Date()` and could flip \"today\" if the form happens to be\n // open across midnight — acceptable but unnecessary churn.\n const quickDates = useMemo(\n () =>\n QUICK_DATES.map((q) => ({\n key: q.key,\n iso: isoDate(q.offsetDays),\n })),\n [],\n );\n\n const quickLabels: Record<(typeof QUICK_DATES)[number][\"key\"], string> = {\n today: t(\"quick_today\"),\n tomorrow: t(\"quick_tomorrow\"),\n next_week: t(\"quick_next_week\"),\n };\n\n const submit = () => {\n const trimmed = body.trim();\n if (!trimmed || createTask.isPending) return;\n createTask.mutate({ body: trimmed, due_at: dueDate });\n };\n\n const canSubmit = body.trim().length > 0 && !createTask.isPending;\n\n return (\n <div className=\"border-border/50 focus-within:border-foreground/30 rounded-xl border p-3 transition-colors\">\n <div className=\"flex items-start gap-3\">\n <div\n className=\"border-muted-foreground/50 mt-1.5 size-5 shrink-0 rounded-full border-2\"\n aria-hidden=\"true\"\n />\n <input\n ref={inputRef}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n submit();\n } else if (e.key === \"Escape\" && onClose) {\n e.preventDefault();\n onClose();\n }\n }}\n placeholder={t(\"task_describe_placeholder\")}\n aria-label={t(\"task_description_aria\")}\n className=\"placeholder:text-muted-foreground/80 text-foreground flex-1 border-0 bg-transparent text-sm font-medium outline-none\"\n />\n {onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={t(\"task_discard_aria\")}\n className=\"text-muted-foreground hover:bg-muted hover:text-foreground -mt-0.5 -mr-0.5 flex size-7 shrink-0 items-center justify-center rounded-md transition-colors\"\n >\n <X className=\"size-4\" />\n </button>\n )}\n </div>\n\n <div className=\"mt-3 flex items-center gap-1.5 pl-8\">\n {quickDates.map((q) => {\n const isActive = dueDate === q.iso;\n return (\n <button\n key={q.key}\n type=\"button\"\n onClick={() => setDueDate(isActive ? null : q.iso)}\n aria-pressed={isActive}\n className={cn(\n \"shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors\",\n isActive\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-muted/70\",\n )}\n >\n {quickLabels[q.key]}\n </button>\n );\n })}\n <div className=\"ml-auto\" />\n <button\n type=\"button\"\n onClick={submit}\n disabled={!canSubmit}\n className=\"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground inline-flex shrink-0 items-center gap-1.5 rounded-full px-4 py-1.5 text-xs font-semibold transition-colors disabled:cursor-not-allowed\"\n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KAAK;KACL,OAAO;KACP,WAAW,MAAM,QAAQ,EAAE,OAAO,MAAM;KACxC,YAAY,MAAM;AAChB,UAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;AACpC,SAAE,gBAAgB;AAClB,eAAQ;iBACC,EAAE,QAAQ,YAAY,SAAS;AACxC,SAAE,gBAAgB;AAClB,gBAAS;;;KAGb,aAAa,EAAE,4BAA4B;KAC3C,cAAY,EAAE,wBAAwB;KACtC,WAAU;KACV,CAAA;IACD,WACC,iBAAA,GAAA,kBAAA,KAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,cAAY,EAAE,oBAAoB;KAClC,WAAU;eAEV,iBAAA,GAAA,kBAAA,KAACC,aAAAA,GAAD,EAAG,WAAU,UAAW,CAAA;KACjB,CAAA;IAEP;MAEN,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,WAAU;aAAf;IACG,WAAW,KAAK,MAAM;KACrB,MAAM,WAAW,YAAY,EAAE;AAC/B,YACE,iBAAA,GAAA,kBAAA,KAAC,UAAD;MAEE,MAAK;MACL,eAAe,WAAW,WAAW,OAAO,EAAE,IAAI;MAClD,gBAAc;MACd,WAAWC,YAAAA,GACT,yEACA,WACI,uCACA,mDACL;gBAEA,YAAY,EAAE;MACR,EAZF,EAAE,IAYA;MAEX;IACF,iBAAA,GAAA,kBAAA,KAAC,OAAD,EAAK,WAAU,WAAY,CAAA;IAC3B,iBAAA,GAAA,kBAAA,KAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,UAAU,CAAC;KACX,WAAU;eAET,WAAW,YAAY,EAAE,SAAS,GAAG,EAAE,WAAW;KAC5C,CAAA;IACL;KACF"}
1
+ {"version":3,"file":"task-composer-form-DvVQw5ud.cjs","names":["createTranslationContext","X","cn"],"sources":["../../../platform/api-client-core/src/parse-api-errors.ts","../../../contacts/core/src/contacts-api-context.ts","../../../contacts/core/src/translation-api-context.ts","../../../contacts/core/src/parse-task-body.ts","../../../contacts/core/src/query-keys.ts","../../../contacts/core/src/hooks/use-infinite-contacts.ts","../../../contacts/core/src/iso-date.ts","../../../contacts/ui/src/portal/hooks/contacts/use-create-contact-task.ts","../../../contacts/ui/src/portal/components/tasks/task-composer-form.tsx"],"sourcesContent":["/**\n * Framework-agnostic API error parsing utilities.\n *\n * Extracts structured field-level errors from API responses and formats\n * them into human-readable messages. Works with ApiError from this package\n * as well as any error object that has `status`, `data`, and optional `message`.\n */\n\n/**\n * Converts snake_case or camelCase field names to Title Case\n */\nexport function formatFieldName(field: string): string {\n return field\n .replace(/_/g, \" \")\n .replace(/([A-Z])/g, \" $1\")\n .split(\" \")\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(\" \")\n .trim();\n}\n\nexport interface ParsedFieldError {\n field: string;\n messages: string[];\n}\n\n/**\n * Type guard to check if an error looks like an API error\n */\nexport function isApiLikeError(\n error: unknown,\n): error is { message: string | undefined; status: number; data: unknown } {\n if (!error || typeof error !== \"object\") {\n return false;\n }\n\n const err = error as Record<string, unknown>;\n return (\n typeof err.status === \"number\" &&\n \"data\" in err &&\n (typeof err.message === \"string\" || err.message === undefined)\n );\n}\n\n/**\n * Extracts field-level errors from API error data\n */\nexport function extractFieldErrors(data: unknown): ParsedFieldError[] {\n const errors: ParsedFieldError[] = [];\n\n if (!data || typeof data !== \"object\") {\n return errors;\n }\n\n const errorObj = data as Record<string, unknown>;\n\n for (const [key, value] of Object.entries(errorObj)) {\n if (Array.isArray(value) && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: value.map((item) =>\n typeof item === \"string\" ? item : JSON.stringify(item),\n ),\n });\n } else if (typeof value === \"string\" && value.length > 0) {\n errors.push({\n field: formatFieldName(key),\n messages: [value],\n });\n } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n const nestedErrors = extractFieldErrors(value);\n nestedErrors.forEach((nestedError) => {\n errors.push({\n field: `${formatFieldName(key)} → ${nestedError.field}`,\n messages: nestedError.messages,\n });\n });\n }\n }\n\n return errors;\n}\n\n/**\n * Formats field errors into a readable description string\n */\nexport function formatErrorDescription(errors: ParsedFieldError[]): string {\n if (errors.length === 0) {\n return \"\";\n }\n\n if (errors.length === 1) {\n const err = errors[0];\n if (!err) return \"\";\n const message = err.messages[0] || \"is invalid\";\n return `${err.field} ${message}`;\n }\n\n if (errors.length <= 3) {\n return errors\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n }\n\n const shown = errors\n .slice(0, 3)\n .map((e) => `${e.field} ${e.messages[0] || \"is invalid\"}`)\n .join(\"\\n\");\n const remaining = errors.length - 3;\n return `${shown}\\n...and ${remaining} more ${remaining === 1 ? \"error\" : \"errors\"}`;\n}\n\n/**\n * Parses an error and returns a human-readable description string.\n *\n * Handles:\n * - API-like errors with structured field-level data\n * - API-like errors with a top-level message\n * - Standard Error instances\n * - Falls back to the provided fallback string\n *\n * @param error - The error to parse (ApiError, Error, or unknown)\n * @param fallback - Optional fallback description if error cannot be parsed\n * @returns A human-readable error description, or undefined if nothing could be extracted\n */\nexport function parseApiErrors(\n error: unknown,\n fallback?: string,\n): string | undefined {\n if (isApiLikeError(error)) {\n if (error.data) {\n const fieldErrors = extractFieldErrors(error.data);\n if (fieldErrors.length > 0) {\n return formatErrorDescription(fieldErrors);\n }\n }\n\n if (error.message) {\n return error.message;\n }\n } else if (error instanceof Error) {\n return error.message;\n }\n\n return fallback;\n}\n","import { createContext, useContext } from \"react\";\nimport type { ContactsApi } from \"./contacts-api\";\nimport type { NotesApi } from \"./notes-api\";\nimport type { TasksApi } from \"./tasks-api\";\nimport type { GroupsApi } from \"./groups-api\";\n\nexport interface ContactsDomainApi {\n contacts: ContactsApi;\n notes: NotesApi;\n tasks: TasksApi;\n groups?: GroupsApi;\n}\n\nconst ContactsApiContext = createContext<ContactsDomainApi | null>(null);\n\nexport const ContactsApiProvider = ContactsApiContext.Provider;\n\nexport function useContactsDomainApi(): ContactsDomainApi {\n const api = useContext(ContactsApiContext);\n if (!api) {\n throw new Error(\n \"useContactsDomainApi must be used within a ContactsApiProvider\",\n );\n }\n return api;\n}\n\nexport function useContactsCrud(): ContactsApi {\n return useContactsDomainApi().contacts;\n}\n\nexport function useNotesApi(): NotesApi {\n return useContactsDomainApi().notes;\n}\n\nexport function useTasksApi(): TasksApi {\n return useContactsDomainApi().tasks;\n}\n\n/** Returns GroupsApi if the provider supplies one, otherwise null. */\nexport function useGroupsApi(): GroupsApi | null {\n return useContactsDomainApi().groups ?? null;\n}\n","import type { Provider } from \"react\";\nimport { createTranslationContext } from \"@fluid-app/i18n/translation-api-context-factory\";\nimport type { TranslationApi } from \"@fluid-app/i18n/translation-api\";\nimport type { ContactsDict } from \"./translation-dictionary\";\n\nconst { Provider: ContactsProvider, useTranslation } =\n createTranslationContext<ContactsDict>(\"Contacts\");\n\nexport const ContactsTranslationProvider: Provider<TranslationApi<ContactsDict> | null> =\n ContactsProvider;\nexport const useContactsTranslation = useTranslation;\n","/**\n * Tasks store both a title (first line) and an optional body separated by a\n * blank line. This is the canonical convention used by the task editor and\n * by every consumer that displays tasks (contacts UI list, portal todo\n * widget). Drift across consumers would mean some surfaces show \"Title\\n\\n\n * body details\" verbatim while others split correctly — keep the delimiter\n * convention in one place.\n */\nexport function parseTaskBody(raw: string): { title: string; body: string } {\n const split = raw.indexOf(\"\\n\\n\");\n if (split >= 0) {\n return {\n title: raw.slice(0, split),\n body: raw.slice(split + 2),\n };\n }\n return { title: raw, body: \"\" };\n}\n","export const CONTACTS_QUERY_KEYS = {\n all: (prefix: string) => [prefix] as const,\n list: (prefix: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"list\"] as const,\n detail: (prefix: string, id: string) =>\n [...CONTACTS_QUERY_KEYS.all(prefix), \"detail\", id] as const,\n} as const;\n\nexport const contactsKeys = {\n activities: (contactId: string) =>\n [\"portal-contacts\", \"activities\", contactId] as const,\n tasks: (contactId: string) =>\n [\"portal-contacts\", \"tasks\", contactId] as const,\n notes: (contactId: string) =>\n [\"portal-contacts\", \"notes\", contactId] as const,\n orders: (contactId: string) => [\"rep-contacts\", \"orders\", contactId] as const,\n subscriptionOrders: (contactId: string) =>\n [\"rep-contacts\", \"subscription-orders\", contactId] as const,\n groups: () => [\"portal-contacts\", \"groups\"] as const,\n} as const;\n","import { useInfiniteQuery } from \"@tanstack/react-query\";\nimport { useContactsCrud } from \"../contacts-api-context\";\nimport { CONTACTS_QUERY_KEYS } from \"../query-keys\";\n\nexport interface UseInfiniteContactsParams {\n search_query?: string;\n status?: string;\n sort_by?: string;\n sort_direction?: string;\n per_page?: number;\n tags?: string[];\n}\n\nexport function useInfiniteContacts(params: UseInfiniteContactsParams) {\n const api = useContactsCrud();\n return useInfiniteQuery({\n queryKey: [...CONTACTS_QUERY_KEYS.list(\"contacts\"), params],\n queryFn: ({ pageParam }) =>\n api.listContacts({\n ...params,\n page: pageParam,\n }),\n getNextPageParam: (lastPage) => {\n const currentPage = lastPage.meta.current_page;\n // Contacts API is page-number based; next_cursor and total_pages\n // are both used as \"has-next-page\" signals.\n if (currentPage == null) return undefined;\n if (lastPage.meta.next_cursor) return currentPage + 1;\n if (\n lastPage.meta.total_pages != null &&\n currentPage < lastPage.meta.total_pages\n ) {\n return currentPage + 1;\n }\n return undefined;\n },\n initialPageParam: 1,\n });\n}\n","/**\n * Format a date as YYYY-MM-DD in the renderer's local timezone, optionally\n * shifted by `offsetDays`. Use this for due-date inputs where \"today\" must\n * resolve to the user's local calendar date — never `toISOString().slice(0, 10)`,\n * which returns the UTC date and silently rolls over a day for users east/west\n * of UTC at the wrong hours.\n */\nexport function isoDate(offsetDays: number, now: Date = new Date()): string {\n const d = new Date(now);\n d.setDate(d.getDate() + offsetDays);\n const yyyy = d.getFullYear();\n const mm = String(d.getMonth() + 1).padStart(2, \"0\");\n const dd = String(d.getDate()).padStart(2, \"0\");\n return `${yyyy}-${mm}-${dd}`;\n}\n\n/**\n * Return a Date pinned to local midnight of the calendar day represented by\n * `input`. Use this whenever you need to compare two due dates by calendar day\n * (overdue / today / tomorrow / future).\n *\n * Why not just `new Date(input)`? `new Date(\"YYYY-MM-DD\")` parses the string\n * as UTC midnight, which lands on the *previous* calendar day in any UTC−\n * timezone — a task due \"May 1\" then reads as April 30 for a user in the\n * Americas, classifying it as \"Overdue\" all day. Parse the date components\n * directly so the calendar-day intent of the string is preserved.\n */\nexport function startOfLocalDay(input: Date | string): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(input);\n if (match?.[1] && match[2] && match[3]) {\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n }\n const d = typeof input === \"string\" ? new Date(input) : input;\n return new Date(d.getFullYear(), d.getMonth(), d.getDate());\n}\n","\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport { parseApiErrors } from \"@fluid-app/api-client-core\";\nimport { useTasksApi } from \"@fluid-app/contacts-core/contacts-api-context\";\nimport { contactsKeys } from \"@fluid-app/contacts-core/query-keys\";\nimport type { CreateTaskInput } from \"@fluid-app/contacts-core/types\";\n\nexport type { CreateTaskInput };\n\nexport function useCreateContactTask(\n contactId: string,\n options?: { onSuccess?: () => void },\n) {\n const queryClient = useQueryClient();\n const api = useTasksApi();\n\n return useMutation({\n mutationFn: (input: CreateTaskInput) => api.createTask(contactId, input),\n onSuccess: () => {\n fluidToast({ title: \"Task created\", type: \"success\" });\n queryClient.invalidateQueries({\n queryKey: contactsKeys.tasks(contactId),\n });\n options?.onSuccess?.();\n },\n onError: (error) => {\n const description = parseApiErrors(error);\n fluidToast({\n title: \"Failed to create task\",\n type: \"error\",\n ...(description ? { description } : {}),\n });\n },\n });\n}\n","\"use client\";\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { X } from \"lucide-react\";\nimport { cn } from \"@fluid-app/ui-primitives\";\nimport { useContactsTranslation } from \"@fluid-app/contacts-core/translation-api-context\";\nimport { isoDate } from \"@fluid-app/contacts-core/iso-date\";\nimport { useCreateContactTask } from \"../../hooks/contacts/use-create-contact-task\";\n\nconst QUICK_DATES = [\n { key: \"today\", offsetDays: 0 },\n { key: \"tomorrow\", offsetDays: 1 },\n { key: \"next_week\", offsetDays: 7 },\n] as const;\n\nexport interface TaskComposerFormProps {\n contactId: string;\n /** Called after a successful create. */\n onDone?: () => void;\n /** When provided, an X button is rendered and Escape closes the form. */\n onClose?: () => void;\n /** Focus the body input on mount. Default true. */\n autoFocus?: boolean;\n}\n\nexport function TaskComposerForm({\n contactId,\n onDone,\n onClose,\n autoFocus = true,\n}: TaskComposerFormProps): React.JSX.Element {\n const { t } = useContactsTranslation();\n const [body, setBody] = useState(\"\");\n const [dueDate, setDueDate] = useState<string | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const createTask = useCreateContactTask(contactId, {\n onSuccess: () => {\n setBody(\"\");\n setDueDate(null);\n onDone?.();\n },\n });\n\n useEffect(() => {\n if (autoFocus) inputRef.current?.focus();\n }, [autoFocus]);\n\n // Compute the date strings once per mount. Re-running on every render would\n // re-evaluate `new Date()` and could flip \"today\" if the form happens to be\n // open across midnight — acceptable but unnecessary churn.\n const quickDates = useMemo(\n () =>\n QUICK_DATES.map((q) => ({\n key: q.key,\n iso: isoDate(q.offsetDays),\n })),\n [],\n );\n\n const quickLabels: Record<(typeof QUICK_DATES)[number][\"key\"], string> = {\n today: t(\"quick_today\"),\n tomorrow: t(\"quick_tomorrow\"),\n next_week: t(\"quick_next_week\"),\n };\n\n const submit = () => {\n const trimmed = body.trim();\n if (!trimmed || createTask.isPending) return;\n createTask.mutate({ body: trimmed, due_at: dueDate });\n };\n\n const canSubmit = body.trim().length > 0 && !createTask.isPending;\n\n return (\n <div className=\"border-border/50 focus-within:border-foreground/30 rounded-xl border p-3 transition-colors\">\n <div className=\"flex items-start gap-3\">\n <div\n className=\"border-muted-foreground/50 mt-1.5 size-5 shrink-0 rounded-full border-2\"\n aria-hidden=\"true\"\n />\n <input\n ref={inputRef}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.shiftKey) {\n e.preventDefault();\n submit();\n } else if (e.key === \"Escape\" && onClose) {\n e.preventDefault();\n onClose();\n }\n }}\n placeholder={t(\"task_describe_placeholder\")}\n aria-label={t(\"task_description_aria\")}\n className=\"placeholder:text-muted-foreground/80 text-foreground flex-1 border-0 bg-transparent text-sm font-medium outline-none\"\n />\n {onClose && (\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={t(\"task_discard_aria\")}\n className=\"text-muted-foreground hover:bg-muted hover:text-foreground -mt-0.5 -mr-0.5 flex size-7 shrink-0 items-center justify-center rounded-md transition-colors\"\n >\n <X className=\"size-4\" />\n </button>\n )}\n </div>\n\n {/* --row-indent aligns the chip row with the input text above (size-5\n circle + gap-3 = 2rem). The mobile Add button cancels it via\n -ml-(--row-indent) + w-[calc(100%+var(--row-indent))] so the two\n values stay locked to a single source. */}\n <div className=\"mt-3 flex flex-wrap items-center gap-1.5 pl-(--row-indent) [--row-indent:2rem]\">\n {quickDates.map((q) => {\n const isActive = dueDate === q.iso;\n return (\n <button\n key={q.key}\n type=\"button\"\n onClick={() => setDueDate(isActive ? null : q.iso)}\n aria-pressed={isActive}\n className={cn(\n \"shrink-0 rounded-full px-3 py-1 text-xs font-medium transition-colors\",\n isActive\n ? \"bg-primary text-primary-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-muted/70\",\n )}\n >\n {quickLabels[q.key]}\n </button>\n );\n })}\n <button\n type=\"button\"\n onClick={submit}\n disabled={!canSubmit}\n className=\"bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground mt-1 -ml-(--row-indent) inline-flex h-10 w-[calc(100%+var(--row-indent))] items-center justify-center rounded-lg text-sm font-semibold transition-colors disabled:cursor-not-allowed sm:mt-0 sm:ml-auto sm:h-auto sm:w-auto sm:shrink-0 sm:gap-1.5 sm:rounded-full sm:px-4 s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BAAA,KAAC,SAAD;KACE,KAAK;KACL,OAAO;KACP,WAAW,MAAM,QAAQ,EAAE,OAAO,MAAM;KACxC,YAAY,MAAM;AAChB,UAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;AACpC,SAAE,gBAAgB;AAClB,eAAQ;iBACC,EAAE,QAAQ,YAAY,SAAS;AACxC,SAAE,gBAAgB;AAClB,gBAAS;;;KAGb,aAAa,EAAE,4BAA4B;KAC3C,cAAY,EAAE,wBAAwB;KACtC,WAAU;KACV,CAAA;IACD,WACC,iBAAA,GAAA,kBAAA,KAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,cAAY,EAAE,oBAAoB;KAClC,WAAU;eAEV,iBAAA,GAAA,kBAAA,KAACC,aAAAA,GAAD,EAAG,WAAU,UAAW,CAAA;KACjB,CAAA;IAEP;MAMN,iBAAA,GAAA,kBAAA,MAAC,OAAD;GAAK,WAAU;aAAf,CACG,WAAW,KAAK,MAAM;IACrB,MAAM,WAAW,YAAY,EAAE;AAC/B,WACE,iBAAA,GAAA,kBAAA,KAAC,UAAD;KAEE,MAAK;KACL,eAAe,WAAW,WAAW,OAAO,EAAE,IAAI;KAClD,gBAAc;KACd,WAAWC,YAAAA,GACT,yEACA,WACI,uCACA,mDACL;eAEA,YAAY,EAAE;KACR,EAZF,EAAE,IAYA;KAEX,EACF,iBAAA,GAAA,kBAAA,KAAC,UAAD;IACE,MAAK;IACL,SAAS;IACT,UAAU,CAAC;IACX,WAAU;cAET,WAAW,YAAY,EAAE,SAAS,GAAG,EAAE,WAAW;IAC5C,CAAA,CACL;KACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluid-app/portal-sdk",
3
- "version": "0.1.336",
3
+ "version": "0.1.338",
4
4
  "description": "SDK for building custom Fluid portals",
5
5
  "files": [
6
6
  "dist",
@@ -72,51 +72,51 @@
72
72
  "typescript": "^5",
73
73
  "zod": "4.3.5",
74
74
  "@fluid-app/address-autocomplete": "0.1.0",
75
- "@fluid-app/cart-ui": "0.1.22",
76
75
  "@fluid-app/auth": "0.1.0",
77
76
  "@fluid-app/api-client-core": "0.1.0",
78
- "@fluid-app/company-switcher-ui": "0.1.0",
79
77
  "@fluid-app/company-switcher-core": "0.1.0",
78
+ "@fluid-app/cart-ui": "0.1.22",
79
+ "@fluid-app/company-switcher-ui": "0.1.0",
80
80
  "@fluid-app/contacts-ui": "0.1.0",
81
81
  "@fluid-app/contacts-core": "0.1.0",
82
82
  "@fluid-app/file-picker-api-client": "0.1.0",
83
83
  "@fluid-app/fluid-pay-core": "0.1.0",
84
84
  "@fluid-app/fluid-pay-ui": "0.1.0",
85
85
  "@fluid-app/file-picker-core": "0.1.0",
86
- "@fluid-app/fluidos-api-client": "0.1.0",
87
86
  "@fluid-app/i18n": "0.1.0",
88
- "@fluid-app/messaging-api-client": "0.1.0",
89
- "@fluid-app/messaging-ui": "0.1.0",
87
+ "@fluid-app/fluidos-api-client": "0.1.0",
90
88
  "@fluid-app/messaging-core": "0.1.0",
91
89
  "@fluid-app/mysite-core": "0.1.0",
90
+ "@fluid-app/messaging-api-client": "0.1.0",
91
+ "@fluid-app/mysite-ui": "0.1.0",
92
92
  "@fluid-app/orders-ui": "0.1.0",
93
93
  "@fluid-app/orders-core": "0.1.0",
94
- "@fluid-app/mysite-ui": "0.1.0",
95
- "@fluid-app/portal-app-download-ui": "0.1.0",
96
94
  "@fluid-app/permissions": "0.1.0",
95
+ "@fluid-app/messaging-ui": "0.1.0",
96
+ "@fluid-app/portal-app-download-ui": "0.1.0",
97
97
  "@fluid-app/portal-core": "0.1.23",
98
98
  "@fluid-app/portal-preview": "0.1.0",
99
99
  "@fluid-app/portal-pro-upgrade-ui": "0.1.0",
100
100
  "@fluid-app/portal-react": "0.1.0",
101
101
  "@fluid-app/portal-tenant-api-client": "0.1.0",
102
- "@fluid-app/portal-tenant-content-api-client": "0.1.0",
103
- "@fluid-app/portal-tenant-mysite-api-client": "0.1.0",
104
102
  "@fluid-app/portal-tenant-contacts-api-client": "0.1.0",
103
+ "@fluid-app/portal-tenant-content-api-client": "0.1.0",
105
104
  "@fluid-app/portal-tenant-pay-api-client": "0.1.0",
106
- "@fluid-app/portal-widgets": "0.1.22",
105
+ "@fluid-app/portal-tenant-mysite-api-client": "0.1.0",
107
106
  "@fluid-app/portal-tenant-store-api-client": "0.1.0",
107
+ "@fluid-app/portal-widgets": "0.1.22",
108
108
  "@fluid-app/products-api-client": "0.1.0",
109
- "@fluid-app/profile-core": "0.1.0",
110
109
  "@fluid-app/products-core": "0.1.0",
111
- "@fluid-app/query-persister": "0.1.0",
110
+ "@fluid-app/profile-core": "0.1.0",
112
111
  "@fluid-app/profile-ui": "0.1.0",
113
112
  "@fluid-app/shareables-core": "0.1.0",
114
- "@fluid-app/shareables-ui": "0.1.0",
115
- "@fluid-app/shop-ui": "0.1.0",
113
+ "@fluid-app/query-persister": "0.1.0",
116
114
  "@fluid-app/shop-core": "0.1.0",
115
+ "@fluid-app/shop-ui": "0.1.0",
117
116
  "@fluid-app/store-api-client": "0.1.0",
118
- "@fluid-app/subscriptions-core": "0.1.0",
117
+ "@fluid-app/shareables-ui": "0.1.0",
119
118
  "@fluid-app/store-core": "0.1.0",
119
+ "@fluid-app/subscriptions-core": "0.1.0",
120
120
  "@fluid-app/subscriptions-ui": "0.1.0",
121
121
  "@fluid-app/typescript-config": "0.0.0",
122
122
  "@fluid-app/ui-primitives": "0.1.13"
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToDoWidget-6Yj9hQQ5.cjs","names":["useWidgetsApi","useWidgetPreviewContext","useDataSourceRegistryConfig","useWidgetsApi","useWidgetPreviewContext","useDataSourceRegistryConfig","useWidgetPreviewContext","useDataSourceRegistryConfig","Dialog","DialogContent","DialogHeader","DialogTitle","PortalContainerProvider","TaskComposerForm","useContactsTranslation","useInfiniteContacts","Popover","PopoverTrigger","cn","ChevronsUpDown","PopoverContent","Search","Input","Check","useWidgetPreviewContext","borderWidthClasses","borderColorClasses","ListChecks","ErrorState","Plus","parseTaskBody","getFontSizeField","getColorField","getPaddingField","getBorderRadiusField","getBorderWidthField","getBorderColorField"],"sources":["../../widgets/src/hooks/use-todos.preview.ts","../../widgets/src/hooks/use-todos.ts","../../widgets/src/hooks/use-update-todo.ts","../../widgets/src/widgets/CreateTodoDialog.tsx","../../widgets/src/widgets/ToDoWidget.tsx"],"sourcesContent":["import type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\n\nconst now = new Date();\n\nfunction daysFromNow(days: number): string {\n const d = new Date(now);\n d.setDate(d.getDate() + days);\n return d.toISOString();\n}\n\nexport const PREVIEW_DATA: Todo[] = [\n {\n id: 1,\n body: \"Send follow-up email to new leads\",\n dueAt: daysFromNow(1),\n completedAt: null,\n createdAt: daysFromNow(-2),\n contactId: 101,\n contactName: \"Sarah Johnson\",\n },\n {\n id: 2,\n body: \"Prepare slides for team training\",\n dueAt: daysFromNow(3),\n completedAt: null,\n createdAt: daysFromNow(-1),\n contactId: null,\n contactName: null,\n },\n {\n id: 3,\n body: \"Review monthly sales report\",\n dueAt: daysFromNow(-1),\n completedAt: null,\n createdAt: daysFromNow(-5),\n contactId: 102,\n contactName: \"Mike Chen\",\n },\n];\n","import { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useWidgetsApi } from \"@fluid-app/portal-core/widgets-api-context\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { useDataSourceRegistryConfig } from \"@fluid-app/portal-react/data-sources/registry-context\";\nimport { PREVIEW_DATA } from \"./use-todos.preview\";\nimport type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\n\nexport type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\n\n/**\n * Shared cache key for the todos list. Both useTodos (read) and\n * useUpdateTodo (write) use this — drift would silently break optimistic\n * updates.\n */\nexport function todosQueryKey(args: {\n baseUrl: string | undefined;\n isPreview: boolean;\n}) {\n return [\n \"portal-widget-use\",\n \"todos\",\n args.isPreview ? \"preview\" : args.baseUrl,\n ] as const;\n}\n\nexport function useTodos(): UseQueryResult<Todo[], Error> {\n const widgetsApi = useWidgetsApi();\n const { isPreview } = useWidgetPreviewContext();\n const { baseUrl } = useDataSourceRegistryConfig();\n\n return useQuery({\n queryKey: todosQueryKey({ baseUrl, isPreview }),\n queryFn: ({ signal }) => widgetsApi.fetchTodos(signal),\n enabled: !isPreview,\n ...(isPreview && { placeholderData: PREVIEW_DATA }),\n });\n}\n","import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport { useWidgetsApi } from \"@fluid-app/portal-core/widgets-api-context\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { useDataSourceRegistryConfig } from \"@fluid-app/portal-react/data-sources/registry-context\";\nimport type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\nimport { todosQueryKey } from \"./use-todos\";\n\ntype UpdateVariables = { id: number; completed: boolean };\n\nexport function useUpdateTodo() {\n const widgetsApi = useWidgetsApi();\n const queryClient = useQueryClient();\n const { isPreview } = useWidgetPreviewContext();\n const { baseUrl } = useDataSourceRegistryConfig();\n\n const queryKey = todosQueryKey({ baseUrl, isPreview });\n\n return useMutation({\n mutationFn: ({ id, completed }: UpdateVariables) => {\n // Defense in depth: ToDoWidget already disables the checkbox in\n // preview mode, but if any other caller fires this mutation while\n // previewing we'd PATCH demo data on the real backend. Fail closed.\n if (isPreview) {\n return Promise.reject(\n new Error(\"Todo updates are disabled in preview mode\"),\n );\n }\n return widgetsApi.updateTodo(id, completed);\n },\n onMutate: async ({ id, completed }) => {\n await queryClient.cancelQueries({ queryKey });\n const previous = queryClient.getQueryData<Todo[]>(queryKey);\n queryClient.setQueryData<Todo[]>(queryKey, (current) =>\n (current ?? []).map((todo) =>\n todo.id === id\n ? {\n ...todo,\n completedAt: completed ? new Date().toISOString() : null,\n }\n : todo,\n ),\n );\n return { previous };\n },\n onSuccess: (updated, { completed }) => {\n queryClient.setQueryData<Todo[]>(queryKey, (current) =>\n (current ?? []).map((todo) =>\n todo.id === updated.id ? updated : todo,\n ),\n );\n // Match the documented test plan: completing toasts, un-completing\n // is silent. The widget today only ever fires completed=true, but\n // gating here keeps the contract honest for any future caller that\n // toggles either direction.\n if (completed) {\n fluidToast({ title: \"Todo completed\", type: \"success\" });\n }\n },\n onError: (_error, _variables, context) => {\n if (context?.previous) {\n queryClient.setQueryData(queryKey, context.previous);\n }\n fluidToast({ title: \"Failed to update todo\", type: \"error\" });\n },\n // Belt-and-suspenders refetch to reconcile any race we couldn't see\n // (e.g., a different tab mutated the same todo). Cheap — one GET per\n // toggle.\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey });\n },\n });\n}\n","\"use client\";\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Check, ChevronsUpDown, Search } from \"lucide-react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n cn,\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n Input,\n Popover,\n PopoverContent,\n PopoverTrigger,\n PortalContainerProvider,\n} from \"@fluid-app/ui-primitives\";\nimport { useInfiniteContacts } from \"@fluid-app/contacts-core/hooks/use-infinite-contacts\";\nimport { useContactsTranslation } from \"@fluid-app/contacts-core/translation-api-context\";\nimport type { Contact } from \"@fluid-app/contacts-core/types\";\nimport { TaskComposerForm } from \"@fluid-app/contacts-ui/portal/components/tasks/task-composer-form\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { useDataSourceRegistryConfig } from \"@fluid-app/portal-react/data-sources/registry-context\";\nimport { todosQueryKey } from \"../hooks/use-todos\";\n\nconst SEARCH_DEBOUNCE_MS = 200;\n\nexport interface CreateTodoDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}\n\nexport function CreateTodoDialog({\n open,\n onOpenChange,\n}: CreateTodoDialogProps): React.JSX.Element {\n const queryClient = useQueryClient();\n const { isPreview } = useWidgetPreviewContext();\n const { baseUrl } = useDataSourceRegistryConfig();\n const [selectedContact, setSelectedContact] = useState<Contact | null>(null);\n // Anchor the popover's portal inside the dialog. Dialog applies\n // pointer-events: none to the body while open, which kills clicks and\n // scroll on a body-portaled popover in WebKit. See edit-bill-date-dialog\n // for the canonical pattern.\n const [popoverContainer, setPopoverContainer] =\n useState<HTMLDivElement | null>(null);\n\n // Reset state when the dialog closes so the next open starts fresh.\n useEffect(() => {\n if (!open) setSelectedContact(null);\n }, [open]);\n\n const handleDone = () => {\n queryClient.invalidateQueries({\n queryKey: todosQueryKey({ baseUrl, isPreview }),\n });\n onOpenChange(false);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"sm:max-w-md\">\n <DialogHeader>\n <DialogTitle>Add a to-do</DialogTitle>\n </DialogHeader>\n\n <PortalContainerProvider container={popoverContainer}>\n <div className=\"mt-2 flex flex-col gap-3\">\n <ContactPicker\n value={selectedContact}\n onSelect={setSelectedContact}\n />\n\n {selectedContact && (\n <TaskComposerForm\n key={selectedContact.id}\n contactId={String(selectedContact.id)}\n onDone={handleDone}\n />\n )}\n </div>\n </PortalContainerProvider>\n {/* Portal target for the popover. Must live INSIDE DialogContent so\n it ends up in the dialog's body-level portal — otherwise it\n renders inline next to the widget, and any transformed ancestor\n (builder canvas zoom, etc.) would break `position: fixed`.\n Intentionally NOT aria-hidden — the popover content portaled\n into this container has its own listbox/option semantics that\n screen readers need to reach. `pointer-events-none` keeps the\n empty overlay from capturing clicks; the popover content sets\n `pointer-events-auto` so it remains interactive. */}\n <div\n ref={setPopoverContainer}\n className=\"pointer-events-none fixed inset-0 z-[9998]\"\n />\n </DialogContent>\n </Dialog>\n );\n}\n\ninterface ContactPickerProps {\n value: Contact | null;\n onSelect: (contact: Contact) => void;\n}\n\nfunction ContactPicker({\n value,\n onSelect,\n}: ContactPickerProps): React.JSX.Element {\n const { t } = useContactsTranslation();\n const [open, setOpen] = useState(false);\n const [searchInput, setSearchInput] = useState(\"\");\n const [debouncedSearch, setDebouncedSearch] = useState(\"\");\n const sentinelRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handle = window.setTimeout(() => {\n setDebouncedSearch(searchInput.trim());\n }, SEARCH_DEBOUNCE_MS);\n return () => window.clearTimeout(handle);\n }, [searchInput]);\n\n const queryParams = useMemo(\n () => ({\n ...(debouncedSearch ? { search_query: debouncedSearch } : {}),\n sort_by: \"full_name\",\n sort_direction: \"asc\",\n per_page: 25,\n }),\n [debouncedSearch],\n );\n\n const {\n data,\n isLoading,\n isError,\n hasNextPage,\n isFetchingNextPage,\n fetchNextPage,\n } = useInfiniteContacts(queryParams);\n\n const contacts: Contact[] = useMemo(\n () => data?.pages.flatMap((page) => page.contacts ?? []) ?? [],\n [data],\n );\n\n // Auto-load the next page when the sentinel scrolls into view, so reps\n // with many contacts can reach all of them without typing a precise\n // search query.\n useEffect(() => {\n const sentinel = sentinelRef.current;\n if (!sentinel || !hasNextPage) return;\n\n const observer = new IntersectionObserver((entries) => {\n const entry = entries[0];\n if (entry?.isIntersecting && !isFetchingNextPage) {\n fetchNextPage();\n }\n });\n\n observer.observe(sentinel);\n return () => observer.disconnect();\n }, [hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return (\n <div className=\"flex flex-col gap-1\">\n <label className=\"text-muted-foreground text-xs font-medium\">\n {t(\"contact_label\")}\n </label>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n className=\"border-input bg-background hover:bg-muted/40 flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-sm transition-colors\"\n >\n <span\n className={cn(\n \"truncate\",\n !value && \"text-muted-foreground font-normal\",\n )}\n >\n {value ? value.full_name : t(\"empty_select_contact\")}\n </span>\n <ChevronsUpDown\n className=\"text-muted-foreground size-4 shrink-0\"\n aria-hidden=\"true\"\n />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n className=\"bg-popover text-popover-foreground pointer-events-auto z-[9999] w-(--radix-popover-trigger-width) overflow-hidden rounded-md border p-0 shadow-md\"\n >\n <div className=\"border-border flex items-center gap-2 border-b px-3 py-2\">\n <Search\n className=\"text-muted-foreground size-4 shrink-0\"\n aria-hidden=\"true\"\n />\n <Input\n value={searchInput}\n onChange={(e) => setSearchInput(e.target.value)}\n placeholder={t(\"search_placeholder\")}\n aria-label={t(\"search_placeholder\")}\n className=\"h-7 border-0 px-0 shadow-none focus-visible:ring-0\"\n />\n </div>\n <div className=\"max-h-64 overflow-y-auto py-1\" role=\"listbox\">\n {isLoading ? (\n <div className=\"text-muted-foreground px-3 py-6 text-center text-xs\">\n {t(\"loading\")}\n </div>\n ) : isError ? (\n <div className=\"text-destructive px-3 py-6 text-center text-xs\">\n {t(\"error_loading_list\")}\n </div>\n ) : contacts.length === 0 ? (\n <div className=\"text-muted-foreground px-3 py-6 text-center text-xs\">\n {debouncedSearch\n ? t(\"no_contacts_search\", { term: debouncedSearch })\n : t(\"no_contacts_yet\")}\n </div>\n ) : (\n <>\n {contacts.map((contact) => {\n const isSelected = value?.id === contact.id;\n return (\n <button\n key={contact.id}\n type=\"button\"\n role=\"option\"\n aria-selected={isSelected}\n onClick={() => {\n onSelect(contact);\n setOpen(false);\n }}\n className=\"hover:bg-muted/50 flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-sm transition-colors\"\n >\n <span className=\"truncate\">{contact.full_name}</span>\n {isSelected && (\n <Check\n className=\"text-primary size-4 shrink-0\"\n aria-hidden=\"true\"\n />\n )}\n </button>\n );\n })}\n {hasNextPage && (\n <div ref={sentinelRef} aria-hidden=\"true\" className=\"h-4\" />\n )}\n {isFetchingNextPage && (\n <div className=\"text-muted-foreground px-3 py-2 text-center text-xs\">\n {t(\"loading_more\")}\n </div>\n )}\n </>\n )}\n </div>\n </PopoverContent>\n </Popover>\n </div>\n );\n}\n","import { useState, type ComponentProps } from \"react\";\nimport type React from \"react\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n BorderWidthOptions,\n ColorOptions,\n FontSizeOptions,\n PaddingOptions,\n} from \"@fluid-app/portal-core/types\";\nimport type { WidgetPropertySchema } from \"@fluid-app/portal-core/registries\";\nimport {\n getBorderRadiusField,\n getBorderWidthField,\n getBorderColorField,\n borderWidthClasses,\n borderColorClasses,\n getColorField,\n getFontSizeField,\n getPaddingField,\n} from \"../core/fields\";\nimport { ListChecks, Plus } from \"lucide-react\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { parseTaskBody } from \"@fluid-app/contacts-core/parse-task-body\";\nimport { useTodos } from \"../hooks/use-todos\";\nimport { useUpdateTodo } from \"../hooks/use-update-todo\";\nimport { ErrorState } from \"../components/error-state\";\nimport { CreateTodoDialog } from \"./CreateTodoDialog\";\n\ntype ToDoWidgetProps = ComponentProps<\"div\"> & {\n // Title\n titleEnabled?: boolean;\n titleText?: string;\n titleFontSize?: FontSizeOptions;\n titleColor?: ColorOptions;\n\n // Styling\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n borderWidth?: BorderWidthOptions;\n borderColor?: ColorOptions;\n\n // Content\n maxItems?: number;\n};\n\nexport function ToDoWidget({\n // Title defaults\n titleEnabled = true,\n titleText = \"To-Do\",\n titleFontSize = \"lg\",\n titleColor = \"foreground\",\n\n // Styling defaults\n background = {\n type: \"solid\",\n color: \"background\",\n },\n textColor = \"foreground\",\n accentColor = \"primary\",\n padding = 4,\n borderRadius = \"md\",\n borderWidth = \"none\",\n borderColor = \"muted\",\n\n // Content defaults\n maxItems = 5,\n\n className,\n ...props\n}: ToDoWidgetProps): React.JSX.Element {\n const backgroundColor = background.color || \"background\";\n const backgroundImage =\n (background.resource?.image_url || background.resource?.imageUrl) &&\n background.type === \"image\"\n ? `url(${background.resource.image_url || background.resource.imageUrl})`\n : \"none\";\n const { data: todos = [], isLoading, isError } = useTodos();\n const updateTodo = useUpdateTodo();\n const { isPreview } = useWidgetPreviewContext();\n const [pendingIds, setPendingIds] = useState<Set<number>>(new Set());\n const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);\n\n const toggleTodo = (id: number, completed: boolean) => {\n if (isPreview || pendingIds.has(id)) return;\n setPendingIds((prev) => new Set(prev).add(id));\n updateTodo.mutate(\n { id, completed },\n {\n onSettled: () =>\n setPendingIds((prev) => {\n const next = new Set(prev);\n next.delete(id);\n return next;\n }),\n },\n );\n };\n\n const activeTodos = todos.filter((todo) => !todo.completedAt);\n const todosToShow = activeTodos.slice(0, maxItems);\n const remainingCount = activeTodos.length - todosToShow.length;\n const isEmpty = activeTodos.length === 0;\n\n // Group todos by contactId so same-named contacts stay separate.\n const groupedTodos = todosToShow.reduce<\n {\n contactId: number | null;\n contactName: string | null;\n todos: typeof todosToShow;\n }[]\n >((groups, todo) => {\n const existing = groups.find((g) => g.contactId === todo.contactId);\n if (existing) {\n existing.todos.push(todo);\n } else {\n groups.push({\n contactId: todo.contactId,\n contactName: todo.contactName,\n todos: [todo],\n });\n }\n return groups;\n }, []);\n\n return (\n <div\n className={`overflow-hidden rounded-${borderRadius} ${borderWidthClasses[borderWidth]} ${borderWidth !== \"none\" ? borderColorClasses[borderColor] : \"\"} bg-${backgroundColor} text-${textColor} p-${padding} ${className ?? \"\"}`}\n style={{ backgroundImage }}\n {...props}\n >\n {/* Header */}\n <div className=\"mb-3 flex items-center justify-between\">\n <div className=\"flex items-center gap-3\">\n {titleEnabled && titleText && (\n <h2\n className={`text-${titleFontSize} font-header font-bold text-${titleColor}`}\n >\n {titleText}\n </h2>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n {!isEmpty && !isLoading && (\n <span className={`text-2xl font-bold text-${accentColor}`}>\n {activeTodos.length}\n </span>\n )}\n <div\n className={`flex h-10 w-10 shrink-0 items-center justify-center`}\n >\n <ListChecks className={`h-5 w-5 text-${accentColor}-foreground`} />\n </div>\n </div>\n </div>\n\n {/* Loading state */}\n {isLoading ? (\n <div className=\"flex min-h-[120px] items-center justify-center\">\n <div className=\"h-6 w-6 animate-spin rounded-full border-2 border-current border-t-transparent\" />\n </div>\n ) : isError ? (\n /* Error state */\n <ErrorState />\n ) : isEmpty ? (\n /* Empty state */\n <div className=\"flex flex-col items-center justify-center gap-3 py-8\">\n <p className={`text-center text-${textColor}/60`}>\n You&apos;ve got nothing else To-Do!\n </p>\n {!isPreview && (\n <button\n type=\"button\"\n onClick={() => setIsCreateDialogOpen(true)}\n className={`inline-flex items-center gap-1.5 rounded-full bg-${accentColor} text-${accentColor}-foreground hover:bg-${accentColor}/90 px-4 py-1.5 text-xs font-semibold transition-colors`}\n >\n <Plus className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n Add to-do\n </button>\n )}\n </div>\n ) : (\n /* Todo List */\n <>\n <div className=\"flex flex-col gap-3\">\n {groupedTodos.map((group) => (\n <div\n key={group.contactId ?? \"__unassigned__\"}\n className=\"flex flex-col\"\n >\n {group.contactName && (\n <div\n className={`mb-1 text-xs font-semibold tracking-wide uppercase text-${textColor}/60`}\n >\n {group.contactName}\n </div>\n )}\n {group.todos.map((todo, index) => (\n <div\n key={todo.id}\n className={`flex items-center gap-3 py-2 ${\n index !== group.todos.length - 1\n ? `border-b border-${textColor}/10`\n : \"\"\n }`}\n >\n <input\n type=\"checkbox\"\n className={`h-5 w-5 rounded-full border-2 border-${textColor}/30 bg-transparent not-disabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-60`}\n checked={!!todo.completedAt}\n disabled={isPreview || pendingIds.has(todo.id)}\n onChange={(event) =>\n toggleTodo(todo.id, event.target.checked)\n }\n />\n <span className=\"line-clamp-1 flex-1 text-sm\">\n {parseTaskBody(todo.body).title}\n </span>\n </div>\n ))}\n </div>\n ))}\n </div>\n\n {/* Footer */}\n <div className=\"mt-2 flex items-center justify-between\">\n {remainingCount > 0 && (\n <span className={`text-sm text-${textColor}/50 underline`}>\n {remainingCount} more task{remainingCount > 1 ? \"s\" : \"\"}\n </span>\n )}\n <div className=\"ml-auto\">\n <button\n type=\"button\"\n onClick={() => setIsCreateDialogOpen(true)}\n disabled={isPreview}\n aria-label=\"Add to-do\"\n className={`flex h-8 w-8 items-center justify-center rounded-full transition-colors not-disabled:cursor-pointer hover:bg-${textColor}/10 disabled:opacity-60`}\n >\n <Plus className={`h-5 w-5 text-${textColor}/50`} />\n </button>\n </div>\n </div>\n </>\n )}\n\n {!isPreview && (\n <CreateTodoDialog\n open={isCreateDialogOpen}\n onOpenChange={setIsCreateDialogOpen}\n />\n )}\n </div>\n );\n}\n\nexport const toDoWidgetPropertySchema: WidgetPropertySchema = {\n widgetType: \"ToDoWidget\",\n displayName: \"To-Do Widget\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [\n // Styling Tab - Title Group\n {\n key: \"titleEnabled\",\n label: \"Widget Title\",\n type: \"boolean\",\n description: \"Enable the title displayed above the todo list\",\n defaultValue: true,\n tab: \"styling\",\n group: \"Title\",\n },\n {\n key: \"titleText\",\n label: \"Title\",\n type: \"text\",\n description: \"Title text displayed above the todo list\",\n defaultValue: \"To-Do\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n },\n getFontSizeField({\n key: \"titleFontSize\",\n label: \"Title Font Size\",\n description: \"Font size for the widget title\",\n defaultValue: \"xl\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n getColorField({\n key: \"titleColor\",\n label: \"Title Color\",\n description: \"Color for the widget title\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n\n // Styling Tab - Design Group\n {\n type: \"background\",\n key: \"background\",\n label: \"Background\",\n description: \"Background for the widget container\",\n defaultValue: \"background\",\n tab: \"styling\",\n group: \"Design\",\n },\n getColorField({\n key: \"textColor\",\n label: \"Text Color\",\n description: \"Default text color for todo items\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getColorField({\n key: \"accentColor\",\n label: \"Accent Color\",\n description: \"Color used for count badge and icon\",\n defaultValue: \"primary\",\n tab: \"styling\",\n group: \"Design\",\n }),\n {\n key: \"separator\",\n type: \"separator\",\n label: \"Separator\",\n tab: \"styling\",\n group: \"Design\",\n },\n {\n key: \"maxItems\",\n label: \"Max Items\",\n type: \"number\",\n description: \"Maximum number of todo items to display\",\n min: 1,\n max: 20,\n step: 1,\n defaultValue: 5,\n tab: \"styling\",\n group: \"Design\",\n },\n getPaddingField({\n key: \"padding\",\n label: \"Padding\",\n description: \"Padding around the widget container\",\n defaultValue: 4,\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderRadiusField({\n key: \"borderRadius\",\n label: \"Border Radius\",\n description: \"Border radius for the widget container\",\n defaultValue: \"md\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderWidthField({\n key: \"borderWidth\",\n label: \"Border Width\",\n description: \"Border width for the widget\",\n defaultValue: \"none\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderColorField({\n key: \"borderColor\",\n label: \"Border Color\",\n description: \"Border color for the widget\",\n defaultValue: \"muted\",\n tab: \"styling\",\n group: \"Design\",\n }),\n ],\n} as const satisfies WidgetPropertySchema;\n"],"mappings":";;;;;;;;;;;;;AAEA,MAAM,sBAAM,IAAI,MAAM;AAEtB,SAAS,YAAY,MAAsB;CACzC,MAAM,IAAI,IAAI,KAAK,IAAI;AACvB,GAAE,QAAQ,EAAE,SAAS,GAAG,KAAK;AAC7B,QAAO,EAAE,aAAa;;AAGxB,MAAa,eAAuB;CAClC;EACE,IAAI;EACJ,MAAM;EACN,OAAO,YAAY,EAAE;EACrB,aAAa;EACb,WAAW,YAAY,GAAG;EAC1B,WAAW;EACX,aAAa;EACd;CACD;EACE,IAAI;EACJ,MAAM;EACN,OAAO,YAAY,EAAE;EACrB,aAAa;EACb,WAAW,YAAY,GAA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GACb,KAAK;GACL,KAAK;GACL,MAAM;GACN,cAAc;GACd,KAAK;GACL,OAAO;GACR;EACDC,mBAAAA,gBAAgB;GACd,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACFC,mBAAAA,qBAAqB;GACnB,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACFC,mBAAAA,oBAAoB;GAClB,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACFC,mBAAAA,oBAAoB;GAClB,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACH;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ToDoWidget-B3sq5pIT.mjs","names":[],"sources":["../../widgets/src/hooks/use-todos.preview.ts","../../widgets/src/hooks/use-todos.ts","../../widgets/src/hooks/use-update-todo.ts","../../widgets/src/widgets/CreateTodoDialog.tsx","../../widgets/src/widgets/ToDoWidget.tsx"],"sourcesContent":["import type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\n\nconst now = new Date();\n\nfunction daysFromNow(days: number): string {\n const d = new Date(now);\n d.setDate(d.getDate() + days);\n return d.toISOString();\n}\n\nexport const PREVIEW_DATA: Todo[] = [\n {\n id: 1,\n body: \"Send follow-up email to new leads\",\n dueAt: daysFromNow(1),\n completedAt: null,\n createdAt: daysFromNow(-2),\n contactId: 101,\n contactName: \"Sarah Johnson\",\n },\n {\n id: 2,\n body: \"Prepare slides for team training\",\n dueAt: daysFromNow(3),\n completedAt: null,\n createdAt: daysFromNow(-1),\n contactId: null,\n contactName: null,\n },\n {\n id: 3,\n body: \"Review monthly sales report\",\n dueAt: daysFromNow(-1),\n completedAt: null,\n createdAt: daysFromNow(-5),\n contactId: 102,\n contactName: \"Mike Chen\",\n },\n];\n","import { useQuery, type UseQueryResult } from \"@tanstack/react-query\";\nimport { useWidgetsApi } from \"@fluid-app/portal-core/widgets-api-context\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { useDataSourceRegistryConfig } from \"@fluid-app/portal-react/data-sources/registry-context\";\nimport { PREVIEW_DATA } from \"./use-todos.preview\";\nimport type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\n\nexport type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\n\n/**\n * Shared cache key for the todos list. Both useTodos (read) and\n * useUpdateTodo (write) use this — drift would silently break optimistic\n * updates.\n */\nexport function todosQueryKey(args: {\n baseUrl: string | undefined;\n isPreview: boolean;\n}) {\n return [\n \"portal-widget-use\",\n \"todos\",\n args.isPreview ? \"preview\" : args.baseUrl,\n ] as const;\n}\n\nexport function useTodos(): UseQueryResult<Todo[], Error> {\n const widgetsApi = useWidgetsApi();\n const { isPreview } = useWidgetPreviewContext();\n const { baseUrl } = useDataSourceRegistryConfig();\n\n return useQuery({\n queryKey: todosQueryKey({ baseUrl, isPreview }),\n queryFn: ({ signal }) => widgetsApi.fetchTodos(signal),\n enabled: !isPreview,\n ...(isPreview && { placeholderData: PREVIEW_DATA }),\n });\n}\n","import { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { fluidToast } from \"@fluid-app/ui-primitives\";\nimport { useWidgetsApi } from \"@fluid-app/portal-core/widgets-api-context\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { useDataSourceRegistryConfig } from \"@fluid-app/portal-react/data-sources/registry-context\";\nimport type { Todo } from \"@fluid-app/portal-core/widgets-api-types\";\nimport { todosQueryKey } from \"./use-todos\";\n\ntype UpdateVariables = { id: number; completed: boolean };\n\nexport function useUpdateTodo() {\n const widgetsApi = useWidgetsApi();\n const queryClient = useQueryClient();\n const { isPreview } = useWidgetPreviewContext();\n const { baseUrl } = useDataSourceRegistryConfig();\n\n const queryKey = todosQueryKey({ baseUrl, isPreview });\n\n return useMutation({\n mutationFn: ({ id, completed }: UpdateVariables) => {\n // Defense in depth: ToDoWidget already disables the checkbox in\n // preview mode, but if any other caller fires this mutation while\n // previewing we'd PATCH demo data on the real backend. Fail closed.\n if (isPreview) {\n return Promise.reject(\n new Error(\"Todo updates are disabled in preview mode\"),\n );\n }\n return widgetsApi.updateTodo(id, completed);\n },\n onMutate: async ({ id, completed }) => {\n await queryClient.cancelQueries({ queryKey });\n const previous = queryClient.getQueryData<Todo[]>(queryKey);\n queryClient.setQueryData<Todo[]>(queryKey, (current) =>\n (current ?? []).map((todo) =>\n todo.id === id\n ? {\n ...todo,\n completedAt: completed ? new Date().toISOString() : null,\n }\n : todo,\n ),\n );\n return { previous };\n },\n onSuccess: (updated, { completed }) => {\n queryClient.setQueryData<Todo[]>(queryKey, (current) =>\n (current ?? []).map((todo) =>\n todo.id === updated.id ? updated : todo,\n ),\n );\n // Match the documented test plan: completing toasts, un-completing\n // is silent. The widget today only ever fires completed=true, but\n // gating here keeps the contract honest for any future caller that\n // toggles either direction.\n if (completed) {\n fluidToast({ title: \"Todo completed\", type: \"success\" });\n }\n },\n onError: (_error, _variables, context) => {\n if (context?.previous) {\n queryClient.setQueryData(queryKey, context.previous);\n }\n fluidToast({ title: \"Failed to update todo\", type: \"error\" });\n },\n // Belt-and-suspenders refetch to reconcile any race we couldn't see\n // (e.g., a different tab mutated the same todo). Cheap — one GET per\n // toggle.\n onSettled: () => {\n queryClient.invalidateQueries({ queryKey });\n },\n });\n}\n","\"use client\";\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport { Check, ChevronsUpDown, Search } from \"lucide-react\";\nimport { useQueryClient } from \"@tanstack/react-query\";\nimport {\n cn,\n Dialog,\n DialogContent,\n DialogHeader,\n DialogTitle,\n Input,\n Popover,\n PopoverContent,\n PopoverTrigger,\n PortalContainerProvider,\n} from \"@fluid-app/ui-primitives\";\nimport { useInfiniteContacts } from \"@fluid-app/contacts-core/hooks/use-infinite-contacts\";\nimport { useContactsTranslation } from \"@fluid-app/contacts-core/translation-api-context\";\nimport type { Contact } from \"@fluid-app/contacts-core/types\";\nimport { TaskComposerForm } from \"@fluid-app/contacts-ui/portal/components/tasks/task-composer-form\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { useDataSourceRegistryConfig } from \"@fluid-app/portal-react/data-sources/registry-context\";\nimport { todosQueryKey } from \"../hooks/use-todos\";\n\nconst SEARCH_DEBOUNCE_MS = 200;\n\nexport interface CreateTodoDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n}\n\nexport function CreateTodoDialog({\n open,\n onOpenChange,\n}: CreateTodoDialogProps): React.JSX.Element {\n const queryClient = useQueryClient();\n const { isPreview } = useWidgetPreviewContext();\n const { baseUrl } = useDataSourceRegistryConfig();\n const [selectedContact, setSelectedContact] = useState<Contact | null>(null);\n // Anchor the popover's portal inside the dialog. Dialog applies\n // pointer-events: none to the body while open, which kills clicks and\n // scroll on a body-portaled popover in WebKit. See edit-bill-date-dialog\n // for the canonical pattern.\n const [popoverContainer, setPopoverContainer] =\n useState<HTMLDivElement | null>(null);\n\n // Reset state when the dialog closes so the next open starts fresh.\n useEffect(() => {\n if (!open) setSelectedContact(null);\n }, [open]);\n\n const handleDone = () => {\n queryClient.invalidateQueries({\n queryKey: todosQueryKey({ baseUrl, isPreview }),\n });\n onOpenChange(false);\n };\n\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"sm:max-w-md\">\n <DialogHeader>\n <DialogTitle>Add a to-do</DialogTitle>\n </DialogHeader>\n\n <PortalContainerProvider container={popoverContainer}>\n <div className=\"mt-2 flex flex-col gap-3\">\n <ContactPicker\n value={selectedContact}\n onSelect={setSelectedContact}\n />\n\n {selectedContact && (\n <TaskComposerForm\n key={selectedContact.id}\n contactId={String(selectedContact.id)}\n onDone={handleDone}\n />\n )}\n </div>\n </PortalContainerProvider>\n {/* Portal target for the popover. Must live INSIDE DialogContent so\n it ends up in the dialog's body-level portal — otherwise it\n renders inline next to the widget, and any transformed ancestor\n (builder canvas zoom, etc.) would break `position: fixed`.\n Intentionally NOT aria-hidden — the popover content portaled\n into this container has its own listbox/option semantics that\n screen readers need to reach. `pointer-events-none` keeps the\n empty overlay from capturing clicks; the popover content sets\n `pointer-events-auto` so it remains interactive. */}\n <div\n ref={setPopoverContainer}\n className=\"pointer-events-none fixed inset-0 z-[9998]\"\n />\n </DialogContent>\n </Dialog>\n );\n}\n\ninterface ContactPickerProps {\n value: Contact | null;\n onSelect: (contact: Contact) => void;\n}\n\nfunction ContactPicker({\n value,\n onSelect,\n}: ContactPickerProps): React.JSX.Element {\n const { t } = useContactsTranslation();\n const [open, setOpen] = useState(false);\n const [searchInput, setSearchInput] = useState(\"\");\n const [debouncedSearch, setDebouncedSearch] = useState(\"\");\n const sentinelRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handle = window.setTimeout(() => {\n setDebouncedSearch(searchInput.trim());\n }, SEARCH_DEBOUNCE_MS);\n return () => window.clearTimeout(handle);\n }, [searchInput]);\n\n const queryParams = useMemo(\n () => ({\n ...(debouncedSearch ? { search_query: debouncedSearch } : {}),\n sort_by: \"full_name\",\n sort_direction: \"asc\",\n per_page: 25,\n }),\n [debouncedSearch],\n );\n\n const {\n data,\n isLoading,\n isError,\n hasNextPage,\n isFetchingNextPage,\n fetchNextPage,\n } = useInfiniteContacts(queryParams);\n\n const contacts: Contact[] = useMemo(\n () => data?.pages.flatMap((page) => page.contacts ?? []) ?? [],\n [data],\n );\n\n // Auto-load the next page when the sentinel scrolls into view, so reps\n // with many contacts can reach all of them without typing a precise\n // search query.\n useEffect(() => {\n const sentinel = sentinelRef.current;\n if (!sentinel || !hasNextPage) return;\n\n const observer = new IntersectionObserver((entries) => {\n const entry = entries[0];\n if (entry?.isIntersecting && !isFetchingNextPage) {\n fetchNextPage();\n }\n });\n\n observer.observe(sentinel);\n return () => observer.disconnect();\n }, [hasNextPage, isFetchingNextPage, fetchNextPage]);\n\n return (\n <div className=\"flex flex-col gap-1\">\n <label className=\"text-muted-foreground text-xs font-medium\">\n {t(\"contact_label\")}\n </label>\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>\n <button\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n className=\"border-input bg-background hover:bg-muted/40 flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-sm transition-colors\"\n >\n <span\n className={cn(\n \"truncate\",\n !value && \"text-muted-foreground font-normal\",\n )}\n >\n {value ? value.full_name : t(\"empty_select_contact\")}\n </span>\n <ChevronsUpDown\n className=\"text-muted-foreground size-4 shrink-0\"\n aria-hidden=\"true\"\n />\n </button>\n </PopoverTrigger>\n <PopoverContent\n align=\"start\"\n className=\"bg-popover text-popover-foreground pointer-events-auto z-[9999] w-(--radix-popover-trigger-width) overflow-hidden rounded-md border p-0 shadow-md\"\n >\n <div className=\"border-border flex items-center gap-2 border-b px-3 py-2\">\n <Search\n className=\"text-muted-foreground size-4 shrink-0\"\n aria-hidden=\"true\"\n />\n <Input\n value={searchInput}\n onChange={(e) => setSearchInput(e.target.value)}\n placeholder={t(\"search_placeholder\")}\n aria-label={t(\"search_placeholder\")}\n className=\"h-7 border-0 px-0 shadow-none focus-visible:ring-0\"\n />\n </div>\n <div className=\"max-h-64 overflow-y-auto py-1\" role=\"listbox\">\n {isLoading ? (\n <div className=\"text-muted-foreground px-3 py-6 text-center text-xs\">\n {t(\"loading\")}\n </div>\n ) : isError ? (\n <div className=\"text-destructive px-3 py-6 text-center text-xs\">\n {t(\"error_loading_list\")}\n </div>\n ) : contacts.length === 0 ? (\n <div className=\"text-muted-foreground px-3 py-6 text-center text-xs\">\n {debouncedSearch\n ? t(\"no_contacts_search\", { term: debouncedSearch })\n : t(\"no_contacts_yet\")}\n </div>\n ) : (\n <>\n {contacts.map((contact) => {\n const isSelected = value?.id === contact.id;\n return (\n <button\n key={contact.id}\n type=\"button\"\n role=\"option\"\n aria-selected={isSelected}\n onClick={() => {\n onSelect(contact);\n setOpen(false);\n }}\n className=\"hover:bg-muted/50 flex w-full items-center justify-between gap-2 px-3 py-1.5 text-left text-sm transition-colors\"\n >\n <span className=\"truncate\">{contact.full_name}</span>\n {isSelected && (\n <Check\n className=\"text-primary size-4 shrink-0\"\n aria-hidden=\"true\"\n />\n )}\n </button>\n );\n })}\n {hasNextPage && (\n <div ref={sentinelRef} aria-hidden=\"true\" className=\"h-4\" />\n )}\n {isFetchingNextPage && (\n <div className=\"text-muted-foreground px-3 py-2 text-center text-xs\">\n {t(\"loading_more\")}\n </div>\n )}\n </>\n )}\n </div>\n </PopoverContent>\n </Popover>\n </div>\n );\n}\n","import { useState, type ComponentProps } from \"react\";\nimport type React from \"react\";\nimport type {\n BackgroundValue,\n BorderRadiusOptions,\n BorderWidthOptions,\n ColorOptions,\n FontSizeOptions,\n PaddingOptions,\n} from \"@fluid-app/portal-core/types\";\nimport type { WidgetPropertySchema } from \"@fluid-app/portal-core/registries\";\nimport {\n getBorderRadiusField,\n getBorderWidthField,\n getBorderColorField,\n borderWidthClasses,\n borderColorClasses,\n getColorField,\n getFontSizeField,\n getPaddingField,\n} from \"../core/fields\";\nimport { ListChecks, Plus } from \"lucide-react\";\nimport { useWidgetPreviewContext } from \"@fluid-app/portal-react/data-sources/preview-context\";\nimport { parseTaskBody } from \"@fluid-app/contacts-core/parse-task-body\";\nimport { useTodos } from \"../hooks/use-todos\";\nimport { useUpdateTodo } from \"../hooks/use-update-todo\";\nimport { ErrorState } from \"../components/error-state\";\nimport { CreateTodoDialog } from \"./CreateTodoDialog\";\n\ntype ToDoWidgetProps = ComponentProps<\"div\"> & {\n // Title\n titleEnabled?: boolean;\n titleText?: string;\n titleFontSize?: FontSizeOptions;\n titleColor?: ColorOptions;\n\n // Styling\n background?: BackgroundValue;\n textColor?: ColorOptions;\n accentColor?: ColorOptions;\n padding?: PaddingOptions;\n borderRadius?: BorderRadiusOptions;\n borderWidth?: BorderWidthOptions;\n borderColor?: ColorOptions;\n\n // Content\n maxItems?: number;\n};\n\nexport function ToDoWidget({\n // Title defaults\n titleEnabled = true,\n titleText = \"To-Do\",\n titleFontSize = \"lg\",\n titleColor = \"foreground\",\n\n // Styling defaults\n background = {\n type: \"solid\",\n color: \"background\",\n },\n textColor = \"foreground\",\n accentColor = \"primary\",\n padding = 4,\n borderRadius = \"md\",\n borderWidth = \"none\",\n borderColor = \"muted\",\n\n // Content defaults\n maxItems = 5,\n\n className,\n ...props\n}: ToDoWidgetProps): React.JSX.Element {\n const backgroundColor = background.color || \"background\";\n const backgroundImage =\n (background.resource?.image_url || background.resource?.imageUrl) &&\n background.type === \"image\"\n ? `url(${background.resource.image_url || background.resource.imageUrl})`\n : \"none\";\n const { data: todos = [], isLoading, isError } = useTodos();\n const updateTodo = useUpdateTodo();\n const { isPreview } = useWidgetPreviewContext();\n const [pendingIds, setPendingIds] = useState<Set<number>>(new Set());\n const [isCreateDialogOpen, setIsCreateDialogOpen] = useState(false);\n\n const toggleTodo = (id: number, completed: boolean) => {\n if (isPreview || pendingIds.has(id)) return;\n setPendingIds((prev) => new Set(prev).add(id));\n updateTodo.mutate(\n { id, completed },\n {\n onSettled: () =>\n setPendingIds((prev) => {\n const next = new Set(prev);\n next.delete(id);\n return next;\n }),\n },\n );\n };\n\n const activeTodos = todos.filter((todo) => !todo.completedAt);\n const todosToShow = activeTodos.slice(0, maxItems);\n const remainingCount = activeTodos.length - todosToShow.length;\n const isEmpty = activeTodos.length === 0;\n\n // Group todos by contactId so same-named contacts stay separate.\n const groupedTodos = todosToShow.reduce<\n {\n contactId: number | null;\n contactName: string | null;\n todos: typeof todosToShow;\n }[]\n >((groups, todo) => {\n const existing = groups.find((g) => g.contactId === todo.contactId);\n if (existing) {\n existing.todos.push(todo);\n } else {\n groups.push({\n contactId: todo.contactId,\n contactName: todo.contactName,\n todos: [todo],\n });\n }\n return groups;\n }, []);\n\n return (\n <div\n className={`overflow-hidden rounded-${borderRadius} ${borderWidthClasses[borderWidth]} ${borderWidth !== \"none\" ? borderColorClasses[borderColor] : \"\"} bg-${backgroundColor} text-${textColor} p-${padding} ${className ?? \"\"}`}\n style={{ backgroundImage }}\n {...props}\n >\n {/* Header */}\n <div className=\"mb-3 flex items-center justify-between\">\n <div className=\"flex items-center gap-3\">\n {titleEnabled && titleText && (\n <h2\n className={`text-${titleFontSize} font-header font-bold text-${titleColor}`}\n >\n {titleText}\n </h2>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n {!isEmpty && !isLoading && (\n <span className={`text-2xl font-bold text-${accentColor}`}>\n {activeTodos.length}\n </span>\n )}\n <div\n className={`flex h-10 w-10 shrink-0 items-center justify-center`}\n >\n <ListChecks className={`h-5 w-5 text-${accentColor}-foreground`} />\n </div>\n </div>\n </div>\n\n {/* Loading state */}\n {isLoading ? (\n <div className=\"flex min-h-[120px] items-center justify-center\">\n <div className=\"h-6 w-6 animate-spin rounded-full border-2 border-current border-t-transparent\" />\n </div>\n ) : isError ? (\n /* Error state */\n <ErrorState />\n ) : isEmpty ? (\n /* Empty state */\n <div className=\"flex flex-col items-center justify-center gap-3 py-8\">\n <p className={`text-center text-${textColor}/60`}>\n You&apos;ve got nothing else To-Do!\n </p>\n {!isPreview && (\n <button\n type=\"button\"\n onClick={() => setIsCreateDialogOpen(true)}\n className={`inline-flex items-center gap-1.5 rounded-full bg-${accentColor} text-${accentColor}-foreground hover:bg-${accentColor}/90 px-4 py-1.5 text-xs font-semibold transition-colors`}\n >\n <Plus className=\"h-3.5 w-3.5\" aria-hidden=\"true\" />\n Add to-do\n </button>\n )}\n </div>\n ) : (\n /* Todo List */\n <>\n <div className=\"flex flex-col gap-3\">\n {groupedTodos.map((group) => (\n <div\n key={group.contactId ?? \"__unassigned__\"}\n className=\"flex flex-col\"\n >\n {group.contactName && (\n <div\n className={`mb-1 text-xs font-semibold tracking-wide uppercase text-${textColor}/60`}\n >\n {group.contactName}\n </div>\n )}\n {group.todos.map((todo, index) => (\n <div\n key={todo.id}\n className={`flex items-center gap-3 py-2 ${\n index !== group.todos.length - 1\n ? `border-b border-${textColor}/10`\n : \"\"\n }`}\n >\n <input\n type=\"checkbox\"\n className={`h-5 w-5 rounded-full border-2 border-${textColor}/30 bg-transparent not-disabled:cursor-pointer disabled:cursor-not-allowed disabled:opacity-60`}\n checked={!!todo.completedAt}\n disabled={isPreview || pendingIds.has(todo.id)}\n onChange={(event) =>\n toggleTodo(todo.id, event.target.checked)\n }\n />\n <span className=\"line-clamp-1 flex-1 text-sm\">\n {parseTaskBody(todo.body).title}\n </span>\n </div>\n ))}\n </div>\n ))}\n </div>\n\n {/* Footer */}\n <div className=\"mt-2 flex items-center justify-between\">\n {remainingCount > 0 && (\n <span className={`text-sm text-${textColor}/50 underline`}>\n {remainingCount} more task{remainingCount > 1 ? \"s\" : \"\"}\n </span>\n )}\n <div className=\"ml-auto\">\n <button\n type=\"button\"\n onClick={() => setIsCreateDialogOpen(true)}\n disabled={isPreview}\n aria-label=\"Add to-do\"\n className={`flex h-8 w-8 items-center justify-center rounded-full transition-colors not-disabled:cursor-pointer hover:bg-${textColor}/10 disabled:opacity-60`}\n >\n <Plus className={`h-5 w-5 text-${textColor}/50`} />\n </button>\n </div>\n </div>\n </>\n )}\n\n {!isPreview && (\n <CreateTodoDialog\n open={isCreateDialogOpen}\n onOpenChange={setIsCreateDialogOpen}\n />\n )}\n </div>\n );\n}\n\nexport const toDoWidgetPropertySchema: WidgetPropertySchema = {\n widgetType: \"ToDoWidget\",\n displayName: \"To-Do Widget\",\n tabsConfig: [{ id: \"styling\", label: \"Styling\" }],\n fields: [\n // Styling Tab - Title Group\n {\n key: \"titleEnabled\",\n label: \"Widget Title\",\n type: \"boolean\",\n description: \"Enable the title displayed above the todo list\",\n defaultValue: true,\n tab: \"styling\",\n group: \"Title\",\n },\n {\n key: \"titleText\",\n label: \"Title\",\n type: \"text\",\n description: \"Title text displayed above the todo list\",\n defaultValue: \"To-Do\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n },\n getFontSizeField({\n key: \"titleFontSize\",\n label: \"Title Font Size\",\n description: \"Font size for the widget title\",\n defaultValue: \"xl\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n getColorField({\n key: \"titleColor\",\n label: \"Title Color\",\n description: \"Color for the widget title\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Title\",\n requiresKeyToBeTrue: \"titleEnabled\",\n }),\n\n // Styling Tab - Design Group\n {\n type: \"background\",\n key: \"background\",\n label: \"Background\",\n description: \"Background for the widget container\",\n defaultValue: \"background\",\n tab: \"styling\",\n group: \"Design\",\n },\n getColorField({\n key: \"textColor\",\n label: \"Text Color\",\n description: \"Default text color for todo items\",\n defaultValue: \"foreground\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getColorField({\n key: \"accentColor\",\n label: \"Accent Color\",\n description: \"Color used for count badge and icon\",\n defaultValue: \"primary\",\n tab: \"styling\",\n group: \"Design\",\n }),\n {\n key: \"separator\",\n type: \"separator\",\n label: \"Separator\",\n tab: \"styling\",\n group: \"Design\",\n },\n {\n key: \"maxItems\",\n label: \"Max Items\",\n type: \"number\",\n description: \"Maximum number of todo items to display\",\n min: 1,\n max: 20,\n step: 1,\n defaultValue: 5,\n tab: \"styling\",\n group: \"Design\",\n },\n getPaddingField({\n key: \"padding\",\n label: \"Padding\",\n description: \"Padding around the widget container\",\n defaultValue: 4,\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderRadiusField({\n key: \"borderRadius\",\n label: \"Border Radius\",\n description: \"Border radius for the widget container\",\n defaultValue: \"md\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderWidthField({\n key: \"borderWidth\",\n label: \"Border Width\",\n description: \"Border width for the widget\",\n defaultValue: \"none\",\n tab: \"styling\",\n group: \"Design\",\n }),\n getBorderColorField({\n key: \"borderColor\",\n label: \"Border Color\",\n description: \"Border color for the widget\",\n defaultValue: \"muted\",\n tab: \"styling\",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M;GACN,aAAa;GACb,KAAK;GACL,KAAK;GACL,MAAM;GACN,cAAc;GACd,KAAK;GACL,OAAO;GACR;EACD,gBAAgB;GACd,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACF,qBAAqB;GACnB,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACF,oBAAoB;GAClB,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACF,oBAAoB;GAClB,KAAK;GACL,OAAO;GACP,aAAa;GACb,cAAc;GACd,KAAK;GACL,OAAO;GACR,CAAC;EACH;CACF"}