@igstack/app-catalog-frontend-core 6.10.3 → 6.11.0

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 (201) hide show
  1. package/dist/esm/__tests__/modules/auth/AuthContext.test.d.ts +1 -0
  2. package/dist/esm/__tests__/modules/communityTools/likedBy.test.d.ts +1 -0
  3. package/dist/esm/__tests__/modules/communityTools/timeAgo.test.d.ts +1 -0
  4. package/dist/esm/__tests__/modules/communityTools/useTimeUp.test.d.ts +1 -0
  5. package/dist/esm/api/infra/trpc.d.ts +419 -0
  6. package/dist/esm/api/infra/trpc.js.map +1 -1
  7. package/dist/esm/modules/appCatalog/hooks/useUpdateApp.d.ts +1 -1
  8. package/dist/esm/modules/appCatalog/ui/catalog/AppDetailPanel.d.ts +2 -4
  9. package/dist/esm/modules/appCatalog/ui/catalog/AppDetailPanel.js +29 -101
  10. package/dist/esm/modules/appCatalog/ui/catalog/AppDetailPanel.js.map +1 -1
  11. package/dist/esm/modules/appCatalog/ui/catalog/DetailDialogShell.d.ts +26 -0
  12. package/dist/esm/modules/appCatalog/ui/catalog/DetailDialogShell.js +108 -0
  13. package/dist/esm/modules/appCatalog/ui/catalog/DetailDialogShell.js.map +1 -0
  14. package/dist/esm/modules/appCatalog/ui/components/ScreenshotGallery.d.ts +2 -1
  15. package/dist/esm/modules/appCatalog/ui/components/ScreenshotGallery.js.map +1 -1
  16. package/dist/esm/modules/appCatalog/ui/components/SectionTabs.d.ts +8 -0
  17. package/dist/esm/modules/appCatalog/ui/components/SectionTabs.js +73 -0
  18. package/dist/esm/modules/appCatalog/ui/components/SectionTabs.js.map +1 -0
  19. package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js +19 -2
  20. package/dist/esm/modules/appCatalog/ui/detail/AppDetails.js.map +1 -1
  21. package/dist/esm/modules/appCatalog/ui/detail/CommentsFeed.d.ts +3 -2
  22. package/dist/esm/modules/appCatalog/ui/detail/CommentsFeed.js +4 -4
  23. package/dist/esm/modules/appCatalog/ui/detail/CommentsFeed.js.map +1 -1
  24. package/dist/esm/modules/appCatalog/ui/detail/CommentsHelp.d.ts +2 -1
  25. package/dist/esm/modules/appCatalog/ui/detail/CommentsHelp.js +2 -2
  26. package/dist/esm/modules/appCatalog/ui/detail/CommentsHelp.js.map +1 -1
  27. package/dist/esm/modules/appCatalog/ui/detail/CommunityInput.d.ts +3 -2
  28. package/dist/esm/modules/appCatalog/ui/detail/CommunityInput.js +13 -9
  29. package/dist/esm/modules/appCatalog/ui/detail/CommunityInput.js.map +1 -1
  30. package/dist/esm/modules/appCatalog/ui/detail/CommunitySection.d.ts +4 -2
  31. package/dist/esm/modules/appCatalog/ui/detail/CommunitySection.js +10 -4
  32. package/dist/esm/modules/appCatalog/ui/detail/CommunitySection.js.map +1 -1
  33. package/dist/esm/modules/appCatalog/ui/detail/communityDraft.d.ts +12 -0
  34. package/dist/esm/modules/appCatalog/ui/detail/communityDraft.js +4 -0
  35. package/dist/esm/modules/appCatalog/ui/detail/communityDraft.js.map +1 -1
  36. package/dist/esm/modules/appCatalog/ui/detail/composeComments.js +1 -0
  37. package/dist/esm/modules/appCatalog/ui/detail/composeComments.js.map +1 -1
  38. package/dist/esm/modules/appCatalog/ui/detail/useCommunityToolCount.d.ts +6 -0
  39. package/dist/esm/modules/appCatalog/ui/detail/useCommunityToolCount.js +16 -0
  40. package/dist/esm/modules/appCatalog/ui/detail/useCommunityToolCount.js.map +1 -0
  41. package/dist/esm/modules/appCatalog/ui/layout/AppCatalogLayout.js +2 -2
  42. package/dist/esm/modules/appCatalog/ui/layout/AppCatalogLayout.js.map +1 -1
  43. package/dist/esm/modules/auth/AuthContext.js +7 -3
  44. package/dist/esm/modules/auth/AuthContext.js.map +1 -1
  45. package/dist/esm/modules/auth/ui/LoginModal.js +16 -8
  46. package/dist/esm/modules/auth/ui/LoginModal.js.map +1 -1
  47. package/dist/esm/modules/communityTools/likedBy.d.ts +8 -0
  48. package/dist/esm/modules/communityTools/likedBy.js +23 -0
  49. package/dist/esm/modules/communityTools/likedBy.js.map +1 -0
  50. package/dist/esm/modules/communityTools/timeAgo.d.ts +2 -0
  51. package/dist/esm/modules/communityTools/timeAgo.js +18 -0
  52. package/dist/esm/modules/communityTools/timeAgo.js.map +1 -0
  53. package/dist/esm/modules/communityTools/ui/CardScreenshot.d.ts +13 -0
  54. package/dist/esm/modules/communityTools/ui/CardScreenshot.js +112 -0
  55. package/dist/esm/modules/communityTools/ui/CardScreenshot.js.map +1 -0
  56. package/dist/esm/modules/communityTools/ui/CardTitleBlock.d.ts +8 -0
  57. package/dist/esm/modules/communityTools/ui/CardTitleBlock.js +59 -0
  58. package/dist/esm/modules/communityTools/ui/CardTitleBlock.js.map +1 -0
  59. package/dist/esm/modules/communityTools/ui/CommunityPage.d.ts +12 -0
  60. package/dist/esm/modules/communityTools/ui/CommunityPage.js +547 -0
  61. package/dist/esm/modules/communityTools/ui/CommunityPage.js.map +1 -0
  62. package/dist/esm/modules/communityTools/ui/FeedRow.d.ts +42 -0
  63. package/dist/esm/modules/communityTools/ui/FeedRow.js +260 -0
  64. package/dist/esm/modules/communityTools/ui/FeedRow.js.map +1 -0
  65. package/dist/esm/modules/communityTools/ui/FeedSortControl.d.ts +17 -0
  66. package/dist/esm/modules/communityTools/ui/FeedSortControl.js +84 -0
  67. package/dist/esm/modules/communityTools/ui/FeedSortControl.js.map +1 -0
  68. package/dist/esm/modules/communityTools/ui/LifecycleBadge.d.ts +7 -0
  69. package/dist/esm/modules/communityTools/ui/LifecycleBadge.js +50 -0
  70. package/dist/esm/modules/communityTools/ui/LifecycleBadge.js.map +1 -0
  71. package/dist/esm/modules/communityTools/ui/LikeButton.d.ts +9 -0
  72. package/dist/esm/modules/communityTools/ui/LikeButton.js +56 -0
  73. package/dist/esm/modules/communityTools/ui/LikeButton.js.map +1 -0
  74. package/dist/esm/modules/communityTools/ui/MarginPreview.d.ts +18 -0
  75. package/dist/esm/modules/communityTools/ui/MarginPreview.js +115 -0
  76. package/dist/esm/modules/communityTools/ui/MarginPreview.js.map +1 -0
  77. package/dist/esm/modules/communityTools/ui/MyToolsShelf.d.ts +12 -0
  78. package/dist/esm/modules/communityTools/ui/MyToolsShelf.js +88 -0
  79. package/dist/esm/modules/communityTools/ui/MyToolsShelf.js.map +1 -0
  80. package/dist/esm/modules/communityTools/ui/OwnerPicker.d.ts +56 -0
  81. package/dist/esm/modules/communityTools/ui/OwnerPicker.js +245 -0
  82. package/dist/esm/modules/communityTools/ui/OwnerPicker.js.map +1 -0
  83. package/dist/esm/modules/communityTools/ui/PinButton.d.ts +14 -0
  84. package/dist/esm/modules/communityTools/ui/PinButton.js +72 -0
  85. package/dist/esm/modules/communityTools/ui/PinButton.js.map +1 -0
  86. package/dist/esm/modules/communityTools/ui/ShelfTile.d.ts +13 -0
  87. package/dist/esm/modules/communityTools/ui/ShelfTile.js +81 -0
  88. package/dist/esm/modules/communityTools/ui/ShelfTile.js.map +1 -0
  89. package/dist/esm/modules/communityTools/ui/TagPicker.d.ts +21 -0
  90. package/dist/esm/modules/communityTools/ui/TagPicker.js +87 -0
  91. package/dist/esm/modules/communityTools/ui/TagPicker.js.map +1 -0
  92. package/dist/esm/modules/communityTools/ui/TagRow.d.ts +22 -0
  93. package/dist/esm/modules/communityTools/ui/TagRow.js +92 -0
  94. package/dist/esm/modules/communityTools/ui/TagRow.js.map +1 -0
  95. package/dist/esm/modules/communityTools/ui/Toast.d.ts +19 -0
  96. package/dist/esm/modules/communityTools/ui/Toast.js +87 -0
  97. package/dist/esm/modules/communityTools/ui/Toast.js.map +1 -0
  98. package/dist/esm/modules/communityTools/ui/ToolCard.d.ts +22 -0
  99. package/dist/esm/modules/communityTools/ui/ToolCard.js +467 -0
  100. package/dist/esm/modules/communityTools/ui/ToolCard.js.map +1 -0
  101. package/dist/esm/modules/communityTools/ui/ToolFormDialog.d.ts +32 -0
  102. package/dist/esm/modules/communityTools/ui/ToolFormDialog.js +765 -0
  103. package/dist/esm/modules/communityTools/ui/ToolFormDialog.js.map +1 -0
  104. package/dist/esm/modules/communityTools/ui/ToolSearch.d.ts +15 -0
  105. package/dist/esm/modules/communityTools/ui/ToolSearch.js +92 -0
  106. package/dist/esm/modules/communityTools/ui/ToolSearch.js.map +1 -0
  107. package/dist/esm/modules/communityTools/useCommunityTools.d.ts +157 -0
  108. package/dist/esm/modules/communityTools/useCommunityTools.js +122 -0
  109. package/dist/esm/modules/communityTools/useCommunityTools.js.map +1 -0
  110. package/dist/esm/modules/communityTools/useCommunityToolsConfig.d.ts +10 -0
  111. package/dist/esm/modules/communityTools/useCommunityToolsConfig.js +20 -0
  112. package/dist/esm/modules/communityTools/useCommunityToolsConfig.js.map +1 -0
  113. package/dist/esm/modules/communityTools/useTimeUp.d.ts +5 -0
  114. package/dist/esm/modules/communityTools/useTimeUp.js +13 -0
  115. package/dist/esm/modules/communityTools/useTimeUp.js.map +1 -0
  116. package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/classic/schemas.js +2 -2
  117. package/dist/esm/node_modules/.pnpm/zod@4.3.5/node_modules/zod/v4/core/schemas.js +1 -1
  118. package/dist/esm/routeTree.gen.d.ts +96 -3
  119. package/dist/esm/routeTree.gen.js +19 -0
  120. package/dist/esm/routeTree.gen.js.map +1 -1
  121. package/dist/esm/routes/_layout/community.$slug.d.ts +22 -0
  122. package/dist/esm/routes/_layout/community._slug.js +10 -0
  123. package/dist/esm/routes/_layout/community._slug.js.map +1 -0
  124. package/dist/esm/routes/_layout/community.d.ts +23 -0
  125. package/dist/esm/routes/_layout/community.js +71 -0
  126. package/dist/esm/routes/_layout/community.js.map +1 -0
  127. package/dist/esm/ui/components/header/Header.js +7 -3
  128. package/dist/esm/ui/components/header/Header.js.map +1 -1
  129. package/dist/esm/util/highlightMatches.d.ts +2 -0
  130. package/dist/esm/util/highlightMatches.js +32 -0
  131. package/dist/esm/util/highlightMatches.js.map +1 -0
  132. package/dist/index.css +6 -0
  133. package/package.json +5 -5
  134. package/src/__tests__/modules/appCatalog/ui/catalog/AppDetailPanel.appSwitch.test.tsx +3 -0
  135. package/src/__tests__/modules/appCatalog/ui/catalog/AppDetailPanel.enter.test.tsx +3 -0
  136. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.background.test.tsx +3 -0
  137. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.behindThisCard.test.tsx +4 -0
  138. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.doorAndTabs.test.tsx +3 -0
  139. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.escape.test.tsx +3 -0
  140. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.knowMore.test.tsx +3 -0
  141. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.sectionOrder.test.tsx +3 -0
  142. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.subResourceTab.test.tsx +3 -0
  143. package/src/__tests__/modules/appCatalog/ui/detail/AppDetails.tags.test.tsx +3 -0
  144. package/src/__tests__/modules/appCatalog/ui/detail/CommunitySection.feed.test.tsx +10 -3
  145. package/src/__tests__/modules/appCatalog/ui/detail/CommunitySection.help.test.tsx +4 -1
  146. package/src/__tests__/modules/appCatalog/ui/detail/CommunitySection.input.test.tsx +12 -2
  147. package/src/__tests__/modules/appCatalog/ui/detail/composeComments.test.ts +1 -0
  148. package/src/__tests__/modules/auth/AuthContext.test.tsx +55 -0
  149. package/src/__tests__/modules/communityTools/likedBy.test.ts +45 -0
  150. package/src/__tests__/modules/communityTools/timeAgo.test.ts +28 -0
  151. package/src/__tests__/modules/communityTools/useTimeUp.test.ts +31 -0
  152. package/src/__tests__/ui/components/header/Header.login.test.tsx +4 -4
  153. package/src/api/infra/trpc.ts +2 -0
  154. package/src/index.css +6 -0
  155. package/src/modules/appCatalog/ui/catalog/AppDetailPanel.tsx +33 -176
  156. package/src/modules/appCatalog/ui/catalog/DetailDialogShell.tsx +199 -0
  157. package/src/modules/appCatalog/ui/components/ScreenshotGallery.tsx +2 -1
  158. package/src/modules/appCatalog/ui/components/SectionTabs.tsx +81 -0
  159. package/src/modules/appCatalog/ui/detail/AppDetails.tsx +17 -2
  160. package/src/modules/appCatalog/ui/detail/CommentsFeed.tsx +9 -4
  161. package/src/modules/appCatalog/ui/detail/CommentsHelp.tsx +6 -3
  162. package/src/modules/appCatalog/ui/detail/CommunityInput.tsx +15 -10
  163. package/src/modules/appCatalog/ui/detail/CommunitySection.tsx +10 -5
  164. package/src/modules/appCatalog/ui/detail/communityDraft.ts +16 -0
  165. package/src/modules/appCatalog/ui/detail/composeComments.ts +1 -0
  166. package/src/modules/appCatalog/ui/detail/useCommunityToolCount.ts +18 -0
  167. package/src/modules/appCatalog/ui/layout/AppCatalogLayout.tsx +2 -2
  168. package/src/modules/auth/AuthContext.tsx +9 -3
  169. package/src/modules/auth/ui/LoginModal.tsx +7 -2
  170. package/src/modules/communityTools/likedBy.ts +32 -0
  171. package/src/modules/communityTools/timeAgo.ts +16 -0
  172. package/src/modules/communityTools/ui/CardScreenshot.tsx +124 -0
  173. package/src/modules/communityTools/ui/CardTitleBlock.tsx +58 -0
  174. package/src/modules/communityTools/ui/CommunityPage.tsx +626 -0
  175. package/src/modules/communityTools/ui/FeedRow.tsx +310 -0
  176. package/src/modules/communityTools/ui/FeedSortControl.tsx +97 -0
  177. package/src/modules/communityTools/ui/LifecycleBadge.tsx +44 -0
  178. package/src/modules/communityTools/ui/LikeButton.tsx +56 -0
  179. package/src/modules/communityTools/ui/MarginPreview.tsx +143 -0
  180. package/src/modules/communityTools/ui/MyToolsShelf.tsx +112 -0
  181. package/src/modules/communityTools/ui/OwnerPicker.tsx +311 -0
  182. package/src/modules/communityTools/ui/PinButton.tsx +87 -0
  183. package/src/modules/communityTools/ui/ShelfTile.tsx +83 -0
  184. package/src/modules/communityTools/ui/TagPicker.tsx +118 -0
  185. package/src/modules/communityTools/ui/TagRow.tsx +118 -0
  186. package/src/modules/communityTools/ui/Toast.tsx +105 -0
  187. package/src/modules/communityTools/ui/ToolCard.tsx +519 -0
  188. package/src/modules/communityTools/ui/ToolFormDialog.tsx +922 -0
  189. package/src/modules/communityTools/ui/ToolSearch.tsx +111 -0
  190. package/src/modules/communityTools/useCommunityTools.ts +146 -0
  191. package/src/modules/communityTools/useCommunityToolsConfig.ts +26 -0
  192. package/src/modules/communityTools/useTimeUp.ts +14 -0
  193. package/src/routeTree.gen.ts +52 -0
  194. package/src/routes/_layout/community.$slug.tsx +7 -0
  195. package/src/routes/_layout/community.tsx +97 -0
  196. package/src/ui/components/header/Header.tsx +9 -3
  197. package/src/util/highlightMatches.tsx +34 -0
  198. package/dist/esm/modules/appCatalog/ui/components/ViewToggle.d.ts +0 -12
  199. package/dist/esm/modules/appCatalog/ui/components/ViewToggle.js +0 -56
  200. package/dist/esm/modules/appCatalog/ui/components/ViewToggle.js.map +0 -1
  201. package/src/modules/appCatalog/ui/components/ViewToggle.tsx +0 -59
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolFormDialog.js","sources":["../../../../../src/modules/communityTools/ui/ToolFormDialog.tsx"],"sourcesContent":["import type { ToolPreview } from '@igstack/app-catalog-backend-core'\nimport type {\n CommunityTag,\n CommunityTool,\n PersonRef,\n} from '@igstack/app-catalog-shared-core'\nimport { TAG_VALUE_MAX, hostOf } from '@igstack/app-catalog-shared-core'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { Link } from '@tanstack/react-router'\nimport {\n AlertCircle,\n AlertTriangle,\n Archive,\n Camera,\n CheckCircle2,\n ImageOff,\n Loader2,\n X,\n} from 'lucide-react'\nimport { useEffect, useId, useRef, useState } from 'react'\nimport { useTRPC } from '~/api/infra/trpc'\nimport { cn } from '~/lib/utils'\nimport { useAppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'\nimport { MarkdownText } from '~/modules/appCatalog/ui/components/MarkdownText'\nimport { useAuth } from '~/modules/auth'\nimport { useDismissable } from '~/modules/dismiss/DismissStack'\nimport { Dialog, DialogContent, DialogTitle } from '~/ui/dialog'\nimport { formatCardDate } from './CardScreenshot'\nimport { screenshotUrl } from './FeedRow'\nimport { FIELD_BAD, FIELD_BOX, OwnerPicker, personName } from './OwnerPicker'\nimport { TagPicker } from './TagPicker'\n\n/** How long the address must sit still before the site is read. */\nconst PREVIEW_DELAY_MS = 400\n\nconst NAME_MAX = 80\nconst SUMMARY_MAX = 160\nconst DESCRIPTION_MAX = 5000\n\nexport const GHOST_BUTTON =\n 'inline-flex h-[34px] items-center gap-[7px] rounded-[10px] border border-border bg-card px-[11px] text-[13px] font-bold whitespace-nowrap hover:border-primary/40 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:opacity-50'\n\nexport const PRIMARY_BUTTON =\n 'inline-flex h-[34px] items-center gap-2 rounded-[10px] bg-primary px-4 text-[13.5px] font-extrabold whitespace-nowrap text-primary-foreground shadow-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-50'\n\nconst LABEL = 'text-[13px] font-bold'\nconst HINT = 'text-[12.5px] text-muted-foreground'\n\ntype Field = 'name' | 'owners' | 'tags'\n\nexport interface ToolFormDialogProps {\n mode: 'add' | 'edit'\n /** The tool being edited. */\n initial?: CommunityTool\n /** What the visitor searched for: a first guess at the name. */\n prefillName?: string\n /** Published, saved or archived. */\n onDone: (slug: string) => void\n onClose: () => void\n /** The address is already listed, and they chose to look at that card. */\n onOpenCard?: (slug: string) => void\n}\n\n/** A field's error, next to it; the form points at the first one on submit. */\nfunction FieldError({ id, children }: { id: string; children: string }) {\n return (\n <p\n id={id}\n role=\"alert\"\n className=\"flex items-center gap-1.5 text-[12.5px] font-bold text-destructive\"\n >\n <AlertCircle aria-hidden=\"true\" className=\"size-3.5 shrink-0\" />\n {children}\n </p>\n )\n}\n\n/**\n * Add a tool, or edit one: the same form. The address comes first; once it\n * sits still the backend reads the page, the title fills the name and a\n * screenshot preview shows. A host already listed is caught before anything\n * else is asked. Publish makes the tool live at once and puts it in the\n * review list.\n */\nexport function ToolFormDialog({\n mode,\n initial,\n prefillName,\n onDone,\n onClose,\n onOpenCard,\n}: ToolFormDialogProps) {\n const trpc = useTRPC()\n const queryClient = useQueryClient()\n const { user } = useAuth()\n const { persons, resources } = useAppCatalogContext()\n const list = useQuery(trpc.communityTools.list.queryOptions())\n const formId = useId()\n const ids = {\n url: `${formId}-url`,\n name: `${formId}-name`,\n summary: `${formId}-summary`,\n owners: `${formId}-owners`,\n tags: `${formId}-tags`,\n description: `${formId}-description`,\n }\n const errorId = (field: string) => `${field}-error`\n\n const [url, setUrl] = useState(initial?.url ?? '')\n const [name, setName] = useState(initial?.name ?? prefillName ?? '')\n // The page title fills the name only until the visitor writes their own.\n const [nameTouched, setNameTouched] = useState(mode === 'edit')\n // The same, for the debounced read below, without restarting its timer.\n const nameTouchedRef = useRef(nameTouched)\n const [summary, setSummary] = useState(initial?.summary ?? '')\n const [descriptionMd, setDescriptionMd] = useState(\n initial?.descriptionMd ?? '',\n )\n const [owners, setOwners] = useState<PersonRef[]>(() => {\n if (initial) return initial.owners\n // The person adding it is the first owner, when the directory knows them.\n const email = user?.email?.toLowerCase()\n const me = email\n ? persons.find(\n (p) =>\n p.email?.toLowerCase() === email || p.slug.toLowerCase() === email,\n )\n : undefined\n return me ? [{ slug: me.slug, name: personName(me) }] : []\n })\n const [tags, setTags] = useState<CommunityTag[]>(initial?.tags ?? [])\n const [tab, setTab] = useState<'write' | 'preview'>('write')\n const [errors, setErrors] = useState<Partial<Record<Field, string>>>({})\n const [archiving, setArchiving] = useState(false)\n\n // The address as it was when the visitor stopped typing, and what reading it gave.\n const [checked, setChecked] = useState(initial?.url ?? '')\n const [preview, setPreview] = useState<{\n url: string\n data: ToolPreview | null\n } | null>(null)\n const [addAnywayFor, setAddAnywayFor] = useState<string | null>(null)\n\n const previewMutation = useMutation(\n trpc.communityTools.preview.mutationOptions(),\n )\n const { mutateAsync: readSite } = previewMutation\n useEffect(() => {\n const address = url.trim()\n // Set once the address changes again: a slower answer for this one must\n // not overwrite the newer address's preview or name.\n let stale = false\n const timer = setTimeout(() => {\n setChecked(address)\n if (!needsPreviewFor(address, mode, initial?.url)) return\n readSite({ url: address }).then(\n (data) => {\n if (stale) return\n setPreview({ url: address, data })\n if (data.title && !nameTouchedRef.current) setName(data.title)\n },\n () => {\n if (!stale) setPreview({ url: address, data: null })\n },\n )\n }, PREVIEW_DELAY_MS)\n return () => {\n stale = true\n clearTimeout(timer)\n }\n }, [url, mode, initial?.url, readSite])\n\n const address = url.trim()\n const validAddress = hostOf(address) !== null\n const showBadAddress = checked !== '' && checked === address && !validAddress\n const reading =\n needsPreviewFor(address, mode, initial?.url) &&\n (checked !== address || preview?.url !== address)\n const current = preview?.url === address ? preview.data : null\n const duplicate =\n current?.duplicate && current.duplicate.slug !== initial?.slug\n ? current.duplicate\n : null\n // An official catalog app on the same host outranks a community duplicate.\n const officialApp = current?.officialApp ?? null\n const blockedByDuplicate =\n (officialApp !== null || duplicate !== null) && addAnywayFor !== address\n const showDetails =\n mode === 'edit' ||\n (validAddress && !reading && !blockedByDuplicate) ||\n (!validAddress && name.trim() !== '' && !showBadAddress)\n\n const invalidate = () =>\n queryClient.invalidateQueries({\n queryKey: trpc.communityTools.pathKey(),\n })\n const add = useMutation(\n trpc.communityTools.add.mutationOptions({ onSuccess: invalidate }),\n )\n const edit = useMutation(\n trpc.communityTools.edit.mutationOptions({ onSuccess: invalidate }),\n )\n const archive = useMutation(\n trpc.communityTools.archive.mutationOptions({ onSuccess: invalidate }),\n )\n const save = mode === 'add' ? add : edit\n const busy = save.isPending || archive.isPending\n\n const urlRef = useRef<HTMLInputElement>(null)\n\n const submit = (e: React.FormEvent) => {\n e.preventDefault()\n // Publish stays disabled until the address is one; Enter in a field\n // cannot submit past a disabled button either.\n if (busy || !validAddress) return\n const found: Partial<Record<Field, string>> = {}\n if (!name.trim()) found.name = 'Give it the name colleagues call it.'\n if (owners.length === 0) {\n found.owners = 'Add at least one person to ask about it.'\n }\n setErrors(found)\n const first = (['name', 'owners'] as const).find((f) => found[f])\n if (first) {\n document.getElementById(ids[first])?.focus()\n return\n }\n const input = {\n url: address,\n name: name.trim(),\n summary: summary.trim(),\n descriptionMd,\n ownerSlugs: owners.flatMap((o) => (o.slug ? [o.slug] : [])),\n ownerNames: owners.flatMap((o) => (o.slug ? [] : [o.name])),\n tags,\n }\n if (mode === 'add') {\n add.mutate(input, { onSuccess: (tool) => onDone(tool.slug) })\n } else if (initial) {\n edit.mutate(\n { ...input, slug: initial.slug },\n { onSuccess: (tool) => onDone(tool.slug) },\n )\n }\n }\n\n const contentRef = useRef<HTMLDivElement>(null)\n // On the dismiss stack, so Escape closes this form and not the card under\n // it; while it saves, Escape does nothing at all.\n useDismissable(contentRef, () => {\n if (!busy) onClose()\n })\n\n const officialApps = resources.filter((r) => !r.parentSlug)\n const knownTopics = [\n ...new Set(\n (list.data ?? []).flatMap((t) =>\n t.tags.filter((g) => g.kind === 'topic').map((g) => g.value),\n ),\n ),\n ].sort()\n\n const title = mode === 'add' ? 'Add a tool' : 'Edit tool'\n const serverError = save.error ?? archive.error\n\n return (\n <Dialog\n open\n onOpenChange={(open) => {\n if (!open && !busy) onClose()\n }}\n >\n <DialogContent\n ref={contentRef}\n data-testid={mode === 'add' ? 'add-tool-dialog' : 'edit-tool-dialog'}\n aria-describedby={undefined}\n showCloseButton={false}\n // Top-anchored: the form grows downward as the site is read, so\n // nothing above the caret moves.\n className=\"top-[6vh] max-h-[88vh] translate-y-0 gap-0 overflow-y-auto p-0 sm:max-w-[680px]\"\n onOpenAutoFocus={(e) => {\n e.preventDefault()\n urlRef.current?.focus()\n }}\n // Typing is lost on a stray click; only Cancel, Close or Esc leave.\n onInteractOutside={(e) => e.preventDefault()}\n onEscapeKeyDown={(e) => {\n // An open suggestion list takes Escape for itself.\n const target = e.target as Element | null\n if (target?.closest('[aria-expanded=\"true\"]')) e.preventDefault()\n }}\n >\n <form onSubmit={submit} noValidate aria-busy={busy || undefined}>\n <div className=\"flex items-center justify-between px-5 pt-4\">\n <DialogTitle className=\"font-serif text-[19px] leading-tight font-semibold\">\n {title}\n </DialogTitle>\n <button\n type=\"button\"\n aria-label=\"Close\"\n disabled={busy}\n onClick={onClose}\n className=\"rounded-full p-1.5 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:opacity-50\"\n >\n <X aria-hidden=\"true\" className=\"size-4\" />\n </button>\n </div>\n\n <div className=\"flex flex-col gap-3.5 px-5 pt-4 pb-1.5\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.url} className={LABEL}>\n Site address\n </label>\n <div className={cn(FIELD_BOX, showBadAddress && FIELD_BAD)}>\n <input\n ref={urlRef}\n id={ids.url}\n type=\"url\"\n inputMode=\"url\"\n autoComplete=\"off\"\n placeholder=\"Paste the link to the tool\"\n value={url}\n disabled={busy}\n aria-invalid={showBadAddress || undefined}\n aria-describedby={\n showBadAddress ? errorId(ids.url) : `${ids.url}-hint`\n }\n onChange={(e) => setUrl(e.target.value)}\n className=\"h-10 min-w-0 flex-1 bg-transparent font-mono text-[13px] outline-none placeholder:font-sans placeholder:text-muted-foreground\"\n />\n {validAddress && reading && (\n <span\n data-testid=\"reading-site\"\n className=\"inline-flex shrink-0 items-center gap-1.5 text-[12.5px] font-semibold text-muted-foreground\"\n >\n <Loader2\n aria-hidden=\"true\"\n className=\"size-3.5 animate-spin\"\n />\n Reading the site…\n </span>\n )}\n {validAddress &&\n !reading &&\n (current?.title || current?.screenshotDataUrl) && (\n <span className=\"inline-flex shrink-0 items-center gap-1.5 text-[12.5px] font-semibold text-green-700 dark:text-green-400\">\n <CheckCircle2 aria-hidden=\"true\" className=\"size-3.5\" />\n Found\n </span>\n )}\n </div>\n {showBadAddress ? (\n <FieldError id={errorId(ids.url)}>\n That is not a web address. Paste the full link, starting with\n https://\n </FieldError>\n ) : (\n !validAddress &&\n !showDetails &&\n !blockedByDuplicate && (\n <p id={`${ids.url}-hint`} className={HINT}>\n Paste it first. The name and screenshot fill in from the\n site.\n </p>\n )\n )}\n </div>\n\n {validAddress && reading && <ReadingSkeleton />}\n\n {blockedByDuplicate && officialApp && (\n <div\n data-testid=\"official-app-warning\"\n role=\"alert\"\n className=\"flex gap-2.5 rounded-[10px] bg-amber-50 px-3.5 py-3 text-[13.5px] text-amber-900 dark:bg-amber-950 dark:text-amber-200\"\n >\n <AlertTriangle\n aria-hidden=\"true\"\n className=\"mt-px size-[18px] shrink-0\"\n />\n <div>\n <b>This is already in the catalog as {officialApp.name}.</b>\n <div className=\"mt-2.5 flex items-center gap-3.5\">\n <Link\n to=\"/app/$slug\"\n params={{ slug: officialApp.slug }}\n className={GHOST_BUTTON}\n >\n Open {officialApp.name}\n </Link>\n <button\n type=\"button\"\n className=\"font-bold underline underline-offset-2\"\n onClick={() => setAddAnywayFor(address)}\n >\n Add anyway\n </button>\n </div>\n </div>\n </div>\n )}\n\n {blockedByDuplicate && !officialApp && duplicate && (\n <div\n data-testid=\"duplicate-warning\"\n role=\"alert\"\n className=\"flex gap-2.5 rounded-[10px] bg-amber-50 px-3.5 py-3 text-[13.5px] text-amber-900 dark:bg-amber-950 dark:text-amber-200\"\n >\n <AlertTriangle\n aria-hidden=\"true\"\n className=\"mt-px size-[18px] shrink-0\"\n />\n <div>\n <b>This site is already here.</b> “{duplicate.name}” uses the\n same address.\n <div className=\"mt-2.5 flex items-center gap-3.5\">\n <button\n type=\"button\"\n className={GHOST_BUTTON}\n onClick={() => onOpenCard?.(duplicate.slug)}\n >\n Open that card\n </button>\n <button\n type=\"button\"\n className=\"font-bold underline underline-offset-2\"\n onClick={() => setAddAnywayFor(address)}\n >\n Add anyway\n </button>\n </div>\n </div>\n </div>\n )}\n\n {showDetails && (\n <>\n <div className=\"grid grid-cols-[minmax(0,1fr)_190px] items-start gap-4\">\n <div className=\"flex min-w-0 flex-col gap-3.5\">\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.name} className={LABEL}>\n Name\n </label>\n <div\n className={cn(\n FIELD_BOX,\n !nameTouched &&\n current?.title &&\n name === current.title &&\n 'bg-amber-50/70 dark:bg-amber-950/40',\n errors.name && FIELD_BAD,\n )}\n >\n <input\n id={ids.name}\n type=\"text\"\n maxLength={NAME_MAX}\n value={name}\n disabled={busy}\n aria-invalid={!!errors.name || undefined}\n aria-describedby={\n errors.name ? errorId(ids.name) : `${ids.name}-hint`\n }\n onChange={(e) => {\n setName(e.target.value)\n setNameTouched(true)\n nameTouchedRef.current = true\n setErrors((prev) => ({ ...prev, name: undefined }))\n }}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n {errors.name ? (\n <FieldError id={errorId(ids.name)}>\n {errors.name}\n </FieldError>\n ) : (\n current?.title &&\n !nameTouched && (\n <p id={`${ids.name}-hint`} className={HINT}>\n From the page title. Change it if colleagues call it\n something else.\n </p>\n )\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.owners} className={LABEL}>\n Owners\n </label>\n <OwnerPicker\n id={ids.owners}\n persons={persons}\n value={owners}\n disabled={busy}\n invalid={!!errors.owners}\n describedBy={\n errors.owners\n ? errorId(ids.owners)\n : `${ids.owners}-hint`\n }\n onChange={(next) => {\n setOwners(next)\n setErrors((prev) => ({ ...prev, owners: undefined }))\n }}\n />\n {errors.owners ? (\n <FieldError id={errorId(ids.owners)}>\n {errors.owners}\n </FieldError>\n ) : (\n <p id={`${ids.owners}-hint`} className={HINT}>\n Who to ask about it. You are added by default.\n </p>\n )}\n </div>\n </div>\n <ShotPreview\n preview={current}\n initial={address === initial?.url ? initial : undefined}\n validAddress={validAddress}\n />\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.summary} className={LABEL}>\n Summary{' '}\n <span className=\"font-normal text-muted-foreground\">\n (optional)\n </span>\n </label>\n <div className={FIELD_BOX}>\n <input\n id={ids.summary}\n type=\"text\"\n maxLength={SUMMARY_MAX}\n value={summary}\n disabled={busy}\n aria-describedby={`${ids.summary}-hint`}\n onChange={(e) => setSummary(e.target.value)}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n <p id={`${ids.summary}-hint`} className={HINT}>\n One line under the name, in the list and on the card.\n </p>\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.tags} className={LABEL}>\n Tags{' '}\n <span className=\"font-normal text-muted-foreground\">\n (optional)\n </span>\n </label>\n <TagPicker\n id={ids.tags}\n apps={officialApps}\n knownTopics={knownTopics}\n value={tags}\n disabled={busy}\n describedBy={\n errors.tags ? errorId(ids.tags) : `${ids.tags}-hint`\n }\n onChange={(next) => {\n setTags(next)\n setErrors((prev) => ({ ...prev, tags: undefined }))\n }}\n onTooLong={() =>\n setErrors((prev) => ({\n ...prev,\n tags: `A topic is at most ${TAG_VALUE_MAX} characters.`,\n }))\n }\n />\n {errors.tags ? (\n <FieldError id={errorId(ids.tags)}>\n {errors.tags}\n </FieldError>\n ) : (\n <p id={`${ids.tags}-hint`} className={HINT}>\n The app it is for, or a topic word. Press Enter to add a\n new topic.\n </p>\n )}\n </div>\n\n <div className=\"flex flex-col gap-1.5\">\n <label htmlFor={ids.description} className={LABEL}>\n How to use\n </label>\n <div className=\"overflow-hidden rounded-[10px] border border-border bg-card\">\n <div\n role=\"tablist\"\n aria-label=\"Write or preview\"\n className=\"flex items-center gap-0.5 border-b border-border bg-muted p-1\"\n >\n {(['write', 'preview'] as const).map((t) => (\n <button\n key={t}\n type=\"button\"\n role=\"tab\"\n aria-selected={tab === t}\n onClick={() => setTab(t)}\n className={cn(\n 'rounded-[7px] px-3 py-1 text-[12.5px] font-bold text-muted-foreground',\n tab === t && 'bg-card text-foreground shadow-sm',\n )}\n >\n {t === 'write' ? 'Write' : 'Preview'}\n </button>\n ))}\n <span className=\"ml-auto pr-2 text-[11.5px] text-muted-foreground\">\n Markdown\n </span>\n </div>\n {/* Kept mounted while previewing, so the label and its draft stay. */}\n <textarea\n id={ids.description}\n rows={6}\n maxLength={DESCRIPTION_MAX}\n value={descriptionMd}\n disabled={busy}\n hidden={tab !== 'write'}\n aria-describedby={`${ids.description}-hint`}\n onChange={(e) => setDescriptionMd(e.target.value)}\n className=\"block w-full resize-y bg-transparent px-3 py-2.5 font-mono text-[12.5px] leading-relaxed outline-none\"\n />\n {tab === 'preview' && (\n <div\n data-testid=\"description-preview\"\n role=\"tabpanel\"\n className=\"prose prose-sm dark:prose-invert min-h-24 max-w-none px-3.5 py-2.5\"\n >\n {descriptionMd.trim() ? (\n <MarkdownText>{descriptionMd}</MarkdownText>\n ) : (\n <p className=\"text-muted-foreground\">\n Nothing written yet.\n </p>\n )}\n </div>\n )}\n </div>\n <p id={`${ids.description}-hint`} className={HINT}>\n Short steps work best. This is the text people read on the\n card.\n </p>\n </div>\n </>\n )}\n </div>\n\n {serverError && (\n <p\n role=\"alert\"\n className=\"mx-5 mt-2 rounded-[10px] bg-destructive/10 px-3 py-2 text-[13px] font-semibold text-destructive\"\n >\n {archive.error ? 'Could not archive it: ' : 'Could not save it: '}\n {serverError.message}\n </p>\n )}\n\n {archiving && initial ? (\n <div className=\"mt-2 border-t border-border px-5 pt-3 pb-4\">\n <ArchiveConfirm\n busy={archive.isPending}\n onCancel={() => setArchiving(false)}\n onArchive={(reason) =>\n archive.mutate(\n { slug: initial.slug, reason },\n { onSuccess: () => onDone(initial.slug) },\n )\n }\n />\n </div>\n ) : (\n <div className=\"mt-2 flex items-center justify-end gap-2.5 border-t border-border px-5 pt-3 pb-4\">\n {/* Already archived: nothing to archive, as on the card. */}\n {mode === 'edit' && initial?.lifecycle.state !== 'archived' && (\n <button\n type=\"button\"\n disabled={busy}\n onClick={() => setArchiving(true)}\n className=\"inline-flex items-center gap-1.5 text-[13px] font-bold text-destructive hover:underline disabled:opacity-50\"\n >\n <Archive aria-hidden=\"true\" className=\"size-3.5\" />\n Archive this tool\n </button>\n )}\n <span\n className={cn(\n 'text-[12.5px] text-muted-foreground',\n mode === 'add' ? 'mr-auto' : 'ml-auto',\n )}\n >\n {mode === 'add'\n ? 'Goes live now and joins the review list.'\n : 'Changes show on the card right away.'}\n </span>\n <button\n type=\"button\"\n disabled={busy}\n onClick={onClose}\n className={GHOST_BUTTON}\n >\n Cancel\n </button>\n <button\n type=\"submit\"\n disabled={!validAddress || reading || busy}\n aria-busy={save.isPending || undefined}\n className={PRIMARY_BUTTON}\n >\n {save.isPending && (\n <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" />\n )}\n {mode === 'add'\n ? save.isPending\n ? 'Publishing…'\n : 'Publish'\n : save.isPending\n ? 'Saving…'\n : 'Save changes'}\n </button>\n </div>\n )}\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n\nfunction needsPreviewFor(\n address: string,\n mode: 'add' | 'edit',\n initialUrl: string | undefined,\n): boolean {\n return hostOf(address) !== null && (mode === 'add' || address !== initialUrl)\n}\n\n/** While the site is read: where the name, owners and picture will be. */\nfunction ReadingSkeleton() {\n return (\n <div\n aria-hidden=\"true\"\n className=\"grid grid-cols-[minmax(0,1fr)_190px] items-start gap-4\"\n >\n <div className=\"flex flex-col gap-3.5\">\n {['55%', '40%'].map((w, i) => (\n <div key={w} className=\"flex flex-col gap-1.5\">\n <span className={LABEL}>{i === 0 ? 'Name' : 'Owners'}</span>\n <span className={cn(FIELD_BOX, 'pointer-events-none')}>\n <i\n className=\"block h-3 animate-pulse rounded-md bg-muted\"\n style={{ width: w }}\n />\n </span>\n </div>\n ))}\n </div>\n <div className=\"mt-[22px] flex aspect-[16/11] flex-col items-center justify-center gap-1.5 rounded-[10px] border border-border bg-muted text-xs font-semibold text-muted-foreground\">\n <Camera aria-hidden=\"true\" className=\"size-5 animate-pulse\" />\n Taking a screenshot…\n </div>\n </div>\n )\n}\n\n/** The picture the card will lead with, or why there will be none. */\nfunction ShotPreview({\n preview,\n initial,\n validAddress,\n}: {\n preview: ToolPreview | null\n /** The tool being edited, while its address is unchanged. */\n initial?: CommunityTool\n validAddress: boolean\n}) {\n const box =\n 'relative mt-[22px] flex aspect-[16/11] flex-col items-center justify-center gap-1.5 overflow-hidden rounded-[10px] border border-border bg-muted px-3 text-center text-xs font-semibold text-muted-foreground'\n const caption =\n 'absolute bottom-1.5 left-1.5 inline-flex items-center gap-1 rounded-md bg-white/90 px-[7px] py-0.5 text-[11px] font-bold text-muted-foreground dark:bg-black/70'\n\n if (preview?.screenshotDataUrl) {\n return (\n <div data-testid=\"shot-preview\" className={box}>\n <img\n src={preview.screenshotDataUrl}\n alt=\"Screenshot preview of the site\"\n className=\"absolute inset-0 size-full object-cover object-left-top\"\n />\n <span className={caption}>\n <Camera aria-hidden=\"true\" className=\"size-3\" />\n Captured just now\n </span>\n </div>\n )\n }\n if (initial?.screenshotId) {\n return (\n <div data-testid=\"shot-preview\" className={box}>\n <img\n src={screenshotUrl(initial.screenshotId, 640)}\n alt={`Screenshot of ${initial.name}`}\n className=\"absolute inset-0 size-full object-cover object-left-top\"\n />\n {initial.capturedAt && (\n <span className={caption}>\n <Camera aria-hidden=\"true\" className=\"size-3\" />\n Captured {formatCardDate(initial.capturedAt)}\n </span>\n )}\n </div>\n )\n }\n return (\n <div data-testid=\"shot-preview\" data-state=\"none\" className={box}>\n <ImageOff aria-hidden=\"true\" className=\"size-5\" />\n {preview && !preview.captureAllowed\n ? \"This site's address is outside the hosts we take screenshots of, so it will be listed without a picture.\"\n : validAddress\n ? 'No preview. The site may need a login, or it did not load.'\n : 'The screenshot shows here once the address is in.'}\n </div>\n )\n}\n\n/**\n * Archiving asks why, in one step: the reason is what colleagues read on the\n * card, and what the review list records.\n */\nexport function ArchiveConfirm({\n busy,\n onArchive,\n onCancel,\n}: {\n busy: boolean\n onArchive: (reason: string) => void\n onCancel: () => void\n}) {\n const id = useId()\n const inputRef = useRef<HTMLInputElement>(null)\n const [reason, setReason] = useState('')\n const [missing, setMissing] = useState(false)\n\n useEffect(() => {\n inputRef.current?.focus()\n }, [])\n\n const confirm = () => {\n if (!reason.trim()) {\n setMissing(true)\n inputRef.current?.focus()\n return\n }\n onArchive(reason.trim())\n }\n\n return (\n <div data-testid=\"archive-confirm\" className=\"flex flex-col gap-1.5\">\n <label htmlFor={id} className={LABEL}>\n Why archive it?\n </label>\n <div className=\"flex items-center gap-2.5\">\n <div className={cn(FIELD_BOX, 'flex-1', missing && FIELD_BAD)}>\n <input\n ref={inputRef}\n id={id}\n type=\"text\"\n maxLength={500}\n value={reason}\n disabled={busy}\n aria-invalid={missing || undefined}\n aria-describedby={missing ? `${id}-error` : `${id}-hint`}\n onChange={(e) => {\n setReason(e.target.value)\n setMissing(false)\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.preventDefault()\n confirm()\n }\n }}\n className=\"h-10 min-w-0 flex-1 bg-transparent outline-none\"\n />\n </div>\n <button\n type=\"button\"\n disabled={busy}\n onClick={onCancel}\n className={GHOST_BUTTON}\n >\n Keep it\n </button>\n <button\n type=\"button\"\n disabled={busy}\n aria-busy={busy || undefined}\n onClick={confirm}\n className={cn(PRIMARY_BUTTON, 'bg-destructive text-white')}\n >\n {busy && (\n <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" />\n )}\n {busy ? 'Archiving…' : 'Archive'}\n </button>\n </div>\n {missing ? (\n <FieldError id={`${id}-error`}>\n Say why, so colleagues know what happened to it.\n </FieldError>\n ) : (\n <p id={`${id}-hint`} className={HINT}>\n Colleagues read this on the card. It stays reachable by its link.\n </p>\n )}\n </div>\n )\n}\n"],"names":["_a","address"],"mappings":";;;;;;;;;;;;;;;;;;AAiCA,MAAM,mBAAmB;AAEzB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,kBAAkB;AAEjB,MAAM,eACX;AAEK,MAAM,iBACX;AAEF,MAAM,QAAQ;AACd,MAAM,OAAO;AAkBb,SAAS,WAAW,EAAE,IAAI,YAA8C;AACtE,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,oBAAC,aAAA,EAAY,eAAY,QAAO,W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AU,GAAG,EAAE,WAAW,GAAG,EAAE;AAAA,UACjD,UAAU,CAAC,MAAM;AACf,sBAAU,EAAE,OAAO,KAAK;AACxB,uBAAW,KAAK;AAAA,UAClB;AAAA,UACA,WAAW,CAAC,MAAM;AAChB,gBAAI,EAAE,QAAQ,SAAS;AACrB,gBAAE,eAAA;AACF,sBAAA;AAAA,YACF;AAAA,UACF;AAAA,UACA,WAAU;AAAA,QAAA;AAAA,MAAA,GAEd;AAAA,MACA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,UAAU;AAAA,UACV,SAAS;AAAA,UACT,WAAW;AAAA,UACZ,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MAGD;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,UAAU;AAAA,UACV,aAAW,QAAQ;AAAA,UACnB,SAAS;AAAA,UACT,WAAW,GAAG,gBAAgB,2BAA2B;AAAA,UAExD,UAAA;AAAA,YAAA,QACC,oBAAC,SAAA,EAAQ,eAAY,QAAO,WAAU,uBAAsB;AAAA,YAE7D,OAAO,eAAe;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IACzB,GACF;AAAA,IACC,UACC,oBAAC,YAAA,EAAW,IAAI,GAAG,EAAE,UAAU,UAAA,mDAAA,CAE/B,IAEA,oBAAC,OAAE,IAAI,GAAG,EAAE,SAAS,WAAW,MAAM,UAAA,oEAAA,CAEtC;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The community search box. It has focus when the page opens and `/` brings it
3
+ * back from anywhere. Esc clears it; a second Esc, on an empty box, leaves it.
4
+ * The arrow keys and Enter belong to the results, so they go to `onKey`.
5
+ */
6
+ export declare function ToolSearch({ value, onChange, resultCount, onKey, resultsId, activeDescendant, }: {
7
+ value: string;
8
+ onChange: (value: string) => void;
9
+ resultCount: number;
10
+ onKey: (e: React.KeyboardEvent<HTMLInputElement>) => void;
11
+ /** The results grid, while there are results to move through. */
12
+ resultsId?: string;
13
+ /** The selected result's id: the option ↑↓ move and Enter opens. */
14
+ activeDescendant?: string;
15
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,92 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { Search, X } from "lucide-react";
3
+ import { useRef, useEffect } from "react";
4
+ const KBD = "shrink-0 rounded-[5px] border border-b-2 border-border bg-card px-1.5 py-px text-[11px] font-semibold text-muted-foreground";
5
+ function isTypingTarget(target) {
6
+ return target instanceof HTMLElement && (target.isContentEditable || target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT");
7
+ }
8
+ function ToolSearch({
9
+ value,
10
+ onChange,
11
+ resultCount,
12
+ onKey,
13
+ resultsId,
14
+ activeDescendant
15
+ }) {
16
+ const inputRef = useRef(null);
17
+ const searching = value.trim() !== "";
18
+ useEffect(() => {
19
+ const onSlash = (e) => {
20
+ var _a;
21
+ if (e.key !== "/" || isTypingTarget(e.target)) return;
22
+ e.preventDefault();
23
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
24
+ };
25
+ document.addEventListener("keydown", onSlash);
26
+ return () => document.removeEventListener("keydown", onSlash);
27
+ }, []);
28
+ const clear = () => {
29
+ var _a;
30
+ onChange("");
31
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
32
+ };
33
+ return /* @__PURE__ */ jsxs(
34
+ "div",
35
+ {
36
+ "data-testid": "tool-search",
37
+ className: "flex h-[50px] min-w-0 flex-1 items-center gap-[11px] rounded-full border border-border bg-card px-4 text-muted-foreground transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-4 focus-within:ring-ring/20",
38
+ children: [
39
+ /* @__PURE__ */ jsx(Search, { "aria-hidden": "true", className: "size-[19px] shrink-0" }),
40
+ /* @__PURE__ */ jsx(
41
+ "input",
42
+ {
43
+ ref: inputRef,
44
+ type: "text",
45
+ value,
46
+ autoFocus: true,
47
+ autoComplete: "off",
48
+ spellCheck: false,
49
+ "aria-label": "Search community tools",
50
+ role: "combobox",
51
+ "aria-haspopup": "grid",
52
+ "aria-autocomplete": "list",
53
+ "aria-expanded": resultsId !== void 0,
54
+ "aria-controls": resultsId,
55
+ "aria-activedescendant": activeDescendant,
56
+ placeholder: "Type anything you remember: a word, the author, part of the address",
57
+ onChange: (e) => onChange(e.target.value),
58
+ onKeyDown: (e) => {
59
+ if (e.key === "Escape") {
60
+ e.preventDefault();
61
+ e.stopPropagation();
62
+ if (value) onChange("");
63
+ else e.currentTarget.blur();
64
+ return;
65
+ }
66
+ onKey(e);
67
+ },
68
+ className: "min-w-0 flex-1 truncate border-0 bg-transparent text-[15.5px] text-foreground outline-none placeholder:text-muted-foreground"
69
+ }
70
+ ),
71
+ searching ? /* @__PURE__ */ jsxs(Fragment, { children: [
72
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[13px] font-semibold", children: resultCount === 1 ? "1 tool" : `${resultCount} tools` }),
73
+ /* @__PURE__ */ jsx(
74
+ "button",
75
+ {
76
+ type: "button",
77
+ "aria-label": "Clear search",
78
+ onClick: clear,
79
+ className: "shrink-0 rounded-full p-1 hover:bg-accent hover:text-foreground",
80
+ children: /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "size-4" })
81
+ }
82
+ ),
83
+ /* @__PURE__ */ jsx("kbd", { className: KBD, children: "Esc" })
84
+ ] }) : /* @__PURE__ */ jsx("kbd", { className: KBD, children: "/" })
85
+ ]
86
+ }
87
+ );
88
+ }
89
+ export {
90
+ ToolSearch
91
+ };
92
+ //# sourceMappingURL=ToolSearch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToolSearch.js","sources":["../../../../../src/modules/communityTools/ui/ToolSearch.tsx"],"sourcesContent":["import { Search, X } from 'lucide-react'\nimport { useEffect, useRef } from 'react'\n\nconst KBD =\n 'shrink-0 rounded-[5px] border border-b-2 border-border bg-card px-1.5 py-px text-[11px] font-semibold text-muted-foreground'\n\nfunction isTypingTarget(target: EventTarget | null): boolean {\n return (\n target instanceof HTMLElement &&\n (target.isContentEditable ||\n target.tagName === 'INPUT' ||\n target.tagName === 'TEXTAREA' ||\n target.tagName === 'SELECT')\n )\n}\n\n/**\n * The community search box. It has focus when the page opens and `/` brings it\n * back from anywhere. Esc clears it; a second Esc, on an empty box, leaves it.\n * The arrow keys and Enter belong to the results, so they go to `onKey`.\n */\nexport function ToolSearch({\n value,\n onChange,\n resultCount,\n onKey,\n resultsId,\n activeDescendant,\n}: {\n value: string\n onChange: (value: string) => void\n resultCount: number\n onKey: (e: React.KeyboardEvent<HTMLInputElement>) => void\n /** The results grid, while there are results to move through. */\n resultsId?: string\n /** The selected result's id: the option ↑↓ move and Enter opens. */\n activeDescendant?: string\n}) {\n const inputRef = useRef<HTMLInputElement>(null)\n const searching = value.trim() !== ''\n\n useEffect(() => {\n const onSlash = (e: KeyboardEvent) => {\n if (e.key !== '/' || isTypingTarget(e.target)) return\n e.preventDefault()\n inputRef.current?.focus()\n }\n document.addEventListener('keydown', onSlash)\n return () => document.removeEventListener('keydown', onSlash)\n }, [])\n\n const clear = () => {\n onChange('')\n inputRef.current?.focus()\n }\n\n return (\n <div\n data-testid=\"tool-search\"\n className=\"flex h-[50px] min-w-0 flex-1 items-center gap-[11px] rounded-full border border-border bg-card px-4 text-muted-foreground transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-4 focus-within:ring-ring/20\"\n >\n <Search aria-hidden=\"true\" className=\"size-[19px] shrink-0\" />\n <input\n ref={inputRef}\n type=\"text\"\n value={value}\n autoFocus\n autoComplete=\"off\"\n spellCheck={false}\n aria-label=\"Search community tools\"\n role=\"combobox\"\n aria-haspopup=\"grid\"\n aria-autocomplete=\"list\"\n aria-expanded={resultsId !== undefined}\n aria-controls={resultsId}\n aria-activedescendant={activeDescendant}\n placeholder=\"Type anything you remember: a word, the author, part of the address\"\n onChange={(e) => onChange(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.preventDefault()\n e.stopPropagation()\n if (value) onChange('')\n else e.currentTarget.blur()\n return\n }\n onKey(e)\n }}\n className=\"min-w-0 flex-1 truncate border-0 bg-transparent text-[15.5px] text-foreground outline-none placeholder:text-muted-foreground\"\n />\n {searching ? (\n <>\n <span className=\"shrink-0 text-[13px] font-semibold\">\n {resultCount === 1 ? '1 tool' : `${resultCount} tools`}\n </span>\n <button\n type=\"button\"\n aria-label=\"Clear search\"\n onClick={clear}\n className=\"shrink-0 rounded-full p-1 hover:bg-accent hover:text-foreground\"\n >\n <X aria-hidden=\"true\" className=\"size-4\" />\n </button>\n <kbd className={KBD}>Esc</kbd>\n </>\n ) : (\n <kbd className={KBD}>/</kbd>\n )}\n </div>\n )\n}\n"],"names":[],"mappings":";;;AAGA,MAAM,MACJ;AAEF,SAAS,eAAe,QAAqC;AAC3D,SACE,kBAAkB,gBACjB,OAAO,qBACN,OAAO,YAAY,WACnB,OAAO,YAAY,cACnB,OAAO,YAAY;AAEzB;AAOO,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GASG;AACD,QAAM,WAAW,OAAyB,IAAI;AAC9C,QAAM,YAAY,MAAM,KAAA,MAAW;AAEnC,YAAU,MAAM;AACd,UAAM,UAAU,CAAC,MAAqB;;AACpC,UAAI,EAAE,QAAQ,OAAO,eAAe,EAAE,MAAM,EAAG;AAC/C,QAAE,eAAA;AACF,qBAAS,YAAT,mBAAkB;AAAA,IACpB;AACA,aAAS,iBAAiB,WAAW,OAAO;AAC5C,WAAO,MAAM,SAAS,oBAAoB,WAAW,OAAO;AAAA,EAC9D,GAAG,CAAA,CAAE;AAEL,QAAM,QAAQ,MAAM;;AAClB,aAAS,EAAE;AACX,mBAAS,YAAT,mBAAkB;AAAA,EACpB;AAEA,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAY;AAAA,MACZ,WAAU;AAAA,MAEV,UAAA;AAAA,QAAA,oBAAC,QAAA,EAAO,eAAY,QAAO,WAAU,wBAAuB;AAAA,QAC5D;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,KAAK;AAAA,YACL,MAAK;AAAA,YACL;AAAA,YACA,WAAS;AAAA,YACT,cAAa;AAAA,YACb,YAAY;AAAA,YACZ,cAAW;AAAA,YACX,MAAK;AAAA,YACL,iBAAc;AAAA,YACd,qBAAkB;AAAA,YAClB,iBAAe,cAAc;AAAA,YAC7B,iBAAe;AAAA,YACf,yBAAuB;AAAA,YACvB,aAAY;AAAA,YACZ,UAAU,CAAC,MAAM,SAAS,EAAE,OAAO,KAAK;AAAA,YACxC,WAAW,CAAC,MAAM;AAChB,kBAAI,EAAE,QAAQ,UAAU;AACtB,kBAAE,eAAA;AACF,kBAAE,gBAAA;AACF,oBAAI,gBAAgB,EAAE;AAAA,oBACjB,GAAE,cAAc,KAAA;AACrB;AAAA,cACF;AACA,oBAAM,CAAC;AAAA,YACT;AAAA,YACA,WAAU;AAAA,UAAA;AAAA,QAAA;AAAA,QAEX,YACC,qBAAA,UAAA,EACE,UAAA;AAAA,UAAA,oBAAC,QAAA,EAAK,WAAU,sCACb,UAAA,gBAAgB,IAAI,WAAW,GAAG,WAAW,SAAA,CAChD;AAAA,UACA;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,MAAK;AAAA,cACL,cAAW;AAAA,cACX,SAAS;AAAA,cACT,WAAU;AAAA,cAEV,UAAA,oBAAC,GAAA,EAAE,eAAY,QAAO,WAAU,SAAA,CAAS;AAAA,YAAA;AAAA,UAAA;AAAA,UAE3C,oBAAC,OAAA,EAAI,WAAW,KAAK,UAAA,MAAA,CAAG;AAAA,QAAA,EAAA,CAC1B,IAEA,oBAAC,OAAA,EAAI,WAAW,KAAK,UAAA,IAAA,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAI9B;"}
@@ -0,0 +1,157 @@
1
+ import { CommunityTool } from '@igstack/app-catalog-shared-core';
2
+ /**
3
+ * Everything the community page reads, and the pin writes. Pins
4
+ * belong to the signed-in user, so they are not asked for until there is one.
5
+ */
6
+ export declare function useCommunityTools(): {
7
+ list: import('@tanstack/react-query').UseQueryResult<{
8
+ createdAt: string;
9
+ slug: string;
10
+ name: string;
11
+ tags: {
12
+ value: string;
13
+ kind: "app" | "topic";
14
+ }[];
15
+ url: string;
16
+ host: string;
17
+ summary: string;
18
+ descriptionMd: string;
19
+ capturedAt: string | null;
20
+ siteUpdatedAt: string | null;
21
+ owners: {
22
+ slug: string | null;
23
+ name: string;
24
+ }[];
25
+ likes: number;
26
+ views30d: number;
27
+ viewsAll: number;
28
+ lifecycle: import('@igstack/app-catalog-shared-core').Lifecycle;
29
+ capturePending: boolean;
30
+ canEdit: boolean;
31
+ addedBy: {
32
+ userId: string;
33
+ name: string;
34
+ };
35
+ likedByMe: boolean;
36
+ likedBy: string[];
37
+ reviewed: boolean;
38
+ screenshotId: string | null;
39
+ faviconId: string | null;
40
+ }[], import('@trpc/client').TRPCClientErrorLike<{
41
+ transformer: false;
42
+ errorShape: import('@trpc/server').TRPCDefaultErrorShape;
43
+ }>>;
44
+ pins: import('@tanstack/react-query').UseQueryResult<{
45
+ createdAt: string;
46
+ slug: string;
47
+ name: string;
48
+ tags: {
49
+ value: string;
50
+ kind: "app" | "topic";
51
+ }[];
52
+ url: string;
53
+ host: string;
54
+ summary: string;
55
+ descriptionMd: string;
56
+ capturedAt: string | null;
57
+ siteUpdatedAt: string | null;
58
+ owners: {
59
+ slug: string | null;
60
+ name: string;
61
+ }[];
62
+ likes: number;
63
+ views30d: number;
64
+ viewsAll: number;
65
+ lifecycle: import('@igstack/app-catalog-shared-core').Lifecycle;
66
+ capturePending: boolean;
67
+ canEdit: boolean;
68
+ addedBy: {
69
+ userId: string;
70
+ name: string;
71
+ };
72
+ likedByMe: boolean;
73
+ likedBy: string[];
74
+ reviewed: boolean;
75
+ screenshotId: string | null;
76
+ faviconId: string | null;
77
+ }[], import('@trpc/client').TRPCClientErrorLike<{
78
+ transformer: false;
79
+ errorShape: import('@trpc/server').TRPCDefaultErrorShape;
80
+ }>>;
81
+ appNames: {
82
+ [k: string]: string;
83
+ };
84
+ isAuthenticated: boolean;
85
+ isAuthLoading: boolean;
86
+ pin: import('@tanstack/react-query').UseMutationResult<never, import('@trpc/client').TRPCClientErrorLike<{
87
+ input: {
88
+ slug: string;
89
+ };
90
+ output: never;
91
+ transformer: false;
92
+ errorShape: import('@trpc/server').TRPCDefaultErrorShape;
93
+ featureFlags: {
94
+ keyPrefix: false;
95
+ };
96
+ }>, {
97
+ slug: string;
98
+ }, {
99
+ previous: CommunityTool[] | undefined;
100
+ }>;
101
+ unpin: import('@tanstack/react-query').UseMutationResult<never, import('@trpc/client').TRPCClientErrorLike<{
102
+ input: {
103
+ slug: string;
104
+ };
105
+ output: never;
106
+ transformer: false;
107
+ errorShape: import('@trpc/server').TRPCDefaultErrorShape;
108
+ featureFlags: {
109
+ keyPrefix: false;
110
+ };
111
+ }>, {
112
+ slug: string;
113
+ }, {
114
+ previous: CommunityTool[] | undefined;
115
+ }>;
116
+ pinBusySlug: string | undefined;
117
+ reorder: import('@tanstack/react-query').UseMutationResult<never, import('@trpc/client').TRPCClientErrorLike<{
118
+ input: {
119
+ slugs: string[];
120
+ };
121
+ output: never;
122
+ transformer: false;
123
+ errorShape: import('@trpc/server').TRPCDefaultErrorShape;
124
+ featureFlags: {
125
+ keyPrefix: false;
126
+ };
127
+ }>, {
128
+ slugs: string[];
129
+ }, void>;
130
+ like: import('@tanstack/react-query').UseMutationResult<never, import('@trpc/client').TRPCClientErrorLike<{
131
+ input: {
132
+ slug: string;
133
+ };
134
+ output: never;
135
+ transformer: false;
136
+ errorShape: import('@trpc/server').TRPCDefaultErrorShape;
137
+ featureFlags: {
138
+ keyPrefix: false;
139
+ };
140
+ }>, {
141
+ slug: string;
142
+ }, void>;
143
+ unlike: import('@tanstack/react-query').UseMutationResult<never, import('@trpc/client').TRPCClientErrorLike<{
144
+ input: {
145
+ slug: string;
146
+ };
147
+ output: never;
148
+ transformer: false;
149
+ errorShape: import('@trpc/server').TRPCDefaultErrorShape;
150
+ featureFlags: {
151
+ keyPrefix: false;
152
+ };
153
+ }>, {
154
+ slug: string;
155
+ }, void>;
156
+ withMyLike: (tool: CommunityTool) => CommunityTool;
157
+ };
@@ -0,0 +1,122 @@
1
+ import { useQueryClient, useQuery, useMutation } from "@tanstack/react-query";
2
+ import { useMemo, useState, useCallback } from "react";
3
+ import { useTRPC } from "../../api/infra/trpc.js";
4
+ import { useAppCatalogContext } from "../appCatalog/context/AppCatalogContext.js";
5
+ import { useAuth } from "../auth/AuthContext.js";
6
+ import "react/jsx-runtime";
7
+ import "../../ui/button.js";
8
+ import { withLike } from "./likedBy.js";
9
+ function useCommunityTools() {
10
+ const trpc = useTRPC();
11
+ const queryClient = useQueryClient();
12
+ const { isAuthenticated, isLoading: isAuthLoading } = useAuth();
13
+ const { resources } = useAppCatalogContext();
14
+ const list = useQuery(trpc.communityTools.list.queryOptions());
15
+ const pins = useQuery(
16
+ trpc.communityTools.pins.queryOptions(void 0, {
17
+ enabled: isAuthenticated
18
+ })
19
+ );
20
+ const appNames = useMemo(
21
+ () => Object.fromEntries(resources.map((r) => [r.slug, r.displayName])),
22
+ [resources]
23
+ );
24
+ const pinsKey = trpc.communityTools.pins.queryKey();
25
+ const refreshPins = () => queryClient.invalidateQueries({ queryKey: pinsKey });
26
+ const optimisticPins = (change) => ({
27
+ onMutate: async ({ slug }) => {
28
+ await queryClient.cancelQueries({ queryKey: pinsKey });
29
+ const previous = queryClient.getQueryData(pinsKey);
30
+ queryClient.setQueryData(
31
+ pinsKey,
32
+ (old) => old ? change(old, slug) : old
33
+ );
34
+ return { previous };
35
+ },
36
+ onError: (_error, _input, context) => {
37
+ queryClient.setQueryData(pinsKey, context == null ? void 0 : context.previous);
38
+ },
39
+ // Not awaited: the pin is saved once the server answers; the refetch
40
+ // behind it only confirms what the star already shows.
41
+ onSettled: () => {
42
+ void refreshPins();
43
+ }
44
+ });
45
+ const pin = useMutation(
46
+ trpc.communityTools.pin.mutationOptions(
47
+ optimisticPins((old, slug) => {
48
+ var _a;
49
+ const tool = (_a = list.data) == null ? void 0 : _a.find((t) => t.slug === slug);
50
+ return tool && !old.some((t) => t.slug === slug) ? [...old, tool] : old;
51
+ })
52
+ )
53
+ );
54
+ const unpin = useMutation(
55
+ trpc.communityTools.unpin.mutationOptions(
56
+ optimisticPins((old, slug) => old.filter((t) => t.slug !== slug))
57
+ )
58
+ );
59
+ const pinBusySlug = pin.isPending ? pin.variables.slug : unpin.isPending ? unpin.variables.slug : void 0;
60
+ const reorder = useMutation(
61
+ trpc.communityTools.reorderPins.mutationOptions({
62
+ onMutate: ({ slugs }) => {
63
+ queryClient.setQueryData(
64
+ pinsKey,
65
+ (old) => old ? slugs.flatMap((s) => old.find((t) => t.slug === s) ?? []) : old
66
+ );
67
+ },
68
+ onSettled: refreshPins
69
+ })
70
+ );
71
+ const [myLikes, setMyLikes] = useState(
72
+ () => /* @__PURE__ */ new Map()
73
+ );
74
+ const setMyLike = (slug, liked) => setMyLikes((prev) => {
75
+ const next = new Map(prev);
76
+ if (liked === void 0) next.delete(slug);
77
+ else next.set(slug, liked);
78
+ return next;
79
+ });
80
+ const likeOptions = (liked) => ({
81
+ onMutate: ({ slug }) => setMyLike(slug, liked),
82
+ onError: (_error, { slug }) => setMyLike(slug, void 0),
83
+ onSettled: () => {
84
+ void queryClient.invalidateQueries({
85
+ queryKey: trpc.communityTools.list.queryKey(),
86
+ refetchType: "none"
87
+ });
88
+ void refreshPins();
89
+ }
90
+ });
91
+ const like = useMutation(
92
+ trpc.communityTools.like.mutationOptions(likeOptions(true))
93
+ );
94
+ const unlike = useMutation(
95
+ trpc.communityTools.unlike.mutationOptions(likeOptions(false))
96
+ );
97
+ const withMyLike = useCallback(
98
+ (tool) => {
99
+ const mine = myLikes.get(tool.slug);
100
+ return mine === void 0 ? tool : withLike(tool, mine);
101
+ },
102
+ [myLikes]
103
+ );
104
+ return {
105
+ list,
106
+ pins,
107
+ appNames,
108
+ isAuthenticated,
109
+ isAuthLoading,
110
+ pin,
111
+ unpin,
112
+ pinBusySlug,
113
+ reorder,
114
+ like,
115
+ unlike,
116
+ withMyLike
117
+ };
118
+ }
119
+ export {
120
+ useCommunityTools
121
+ };
122
+ //# sourceMappingURL=useCommunityTools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCommunityTools.js","sources":["../../../../src/modules/communityTools/useCommunityTools.ts"],"sourcesContent":["import type { CommunityTool } from '@igstack/app-catalog-shared-core'\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useCallback, useMemo, useState } from 'react'\nimport { useTRPC } from '~/api/infra/trpc'\nimport { useAppCatalogContext } from '~/modules/appCatalog/context/AppCatalogContext'\nimport { useAuth } from '~/modules/auth'\nimport { withLike } from './likedBy'\n\n/**\n * Everything the community page reads, and the pin writes. Pins\n * belong to the signed-in user, so they are not asked for until there is one.\n */\nexport function useCommunityTools() {\n const trpc = useTRPC()\n const queryClient = useQueryClient()\n const { isAuthenticated, isLoading: isAuthLoading } = useAuth()\n const { resources } = useAppCatalogContext()\n\n const list = useQuery(trpc.communityTools.list.queryOptions())\n const pins = useQuery(\n trpc.communityTools.pins.queryOptions(undefined, {\n enabled: isAuthenticated,\n }),\n )\n\n /** Display names of official apps by slug, for app tags. */\n const appNames = useMemo(\n () => Object.fromEntries(resources.map((r) => [r.slug, r.displayName])),\n [resources],\n )\n\n const pinsKey = trpc.communityTools.pins.queryKey()\n const refreshPins = () => queryClient.invalidateQueries({ queryKey: pinsKey })\n\n // The star and the shelf change at once; a failed save puts them back.\n const optimisticPins = (\n change: (old: CommunityTool[], slug: string) => CommunityTool[],\n ) => ({\n onMutate: async ({ slug }: { slug: string }) => {\n await queryClient.cancelQueries({ queryKey: pinsKey })\n const previous = queryClient.getQueryData<CommunityTool[]>(pinsKey)\n queryClient.setQueryData<CommunityTool[]>(pinsKey, (old) =>\n old ? change(old, slug) : old,\n )\n return { previous }\n },\n onError: (\n _error: unknown,\n _input: { slug: string },\n context: { previous?: CommunityTool[] } | undefined,\n ) => {\n queryClient.setQueryData(pinsKey, context?.previous)\n },\n // Not awaited: the pin is saved once the server answers; the refetch\n // behind it only confirms what the star already shows.\n onSettled: () => {\n void refreshPins()\n },\n })\n const pin = useMutation(\n trpc.communityTools.pin.mutationOptions(\n optimisticPins((old, slug) => {\n const tool = list.data?.find((t) => t.slug === slug)\n return tool && !old.some((t) => t.slug === slug) ? [...old, tool] : old\n }),\n ),\n )\n const unpin = useMutation(\n trpc.communityTools.unpin.mutationOptions(\n optimisticPins((old, slug) => old.filter((t) => t.slug !== slug)),\n ),\n )\n /** The tool whose pin is being saved, if any. */\n const pinBusySlug = pin.isPending\n ? pin.variables.slug\n : unpin.isPending\n ? unpin.variables.slug\n : undefined\n const reorder = useMutation(\n trpc.communityTools.reorderPins.mutationOptions({\n onMutate: ({ slugs }) => {\n // The tile moves at once; the server catches up behind it.\n queryClient.setQueryData<CommunityTool[]>(pinsKey, (old) =>\n old ? slugs.flatMap((s) => old.find((t) => t.slug === s) ?? []) : old,\n )\n },\n onSettled: refreshPins,\n }),\n )\n\n // My likes show at once, as an overlay on the tools as fetched. The feed\n // ranks from the fetched tools, so a like changes its own count and never\n // moves a row out from under the pointer. Settling marks the list stale\n // without refetching it: it re-ranks on the next refocus or remount.\n const [myLikes, setMyLikes] = useState<ReadonlyMap<string, boolean>>(\n () => new Map(),\n )\n const setMyLike = (slug: string, liked: boolean | undefined) =>\n setMyLikes((prev) => {\n const next = new Map(prev)\n if (liked === undefined) next.delete(slug)\n else next.set(slug, liked)\n return next\n })\n const likeOptions = (liked: boolean) => ({\n onMutate: ({ slug }: { slug: string }) => setMyLike(slug, liked),\n onError: (_error: unknown, { slug }: { slug: string }) =>\n setMyLike(slug, undefined),\n onSettled: () => {\n void queryClient.invalidateQueries({\n queryKey: trpc.communityTools.list.queryKey(),\n refetchType: 'none',\n })\n void refreshPins()\n },\n })\n const like = useMutation(\n trpc.communityTools.like.mutationOptions(likeOptions(true)),\n )\n const unlike = useMutation(\n trpc.communityTools.unlike.mutationOptions(likeOptions(false)),\n )\n /** The tool with my latest like or unlike, saved or still saving. */\n const withMyLike = useCallback(\n (tool: CommunityTool) => {\n const mine = myLikes.get(tool.slug)\n return mine === undefined ? tool : withLike(tool, mine)\n },\n [myLikes],\n )\n\n return {\n list,\n pins,\n appNames,\n isAuthenticated,\n isAuthLoading,\n pin,\n unpin,\n pinBusySlug,\n reorder,\n like,\n unlike,\n withMyLike,\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAYO,SAAS,oBAAoB;AAClC,QAAM,OAAO,QAAA;AACb,QAAM,cAAc,eAAA;AACpB,QAAM,EAAE,iBAAiB,WAAW,cAAA,IAAkB,QAAA;AACtD,QAAM,EAAE,UAAA,IAAc,qBAAA;AAEtB,QAAM,OAAO,SAAS,KAAK,eAAe,KAAK,cAAc;AAC7D,QAAM,OAAO;AAAA,IACX,KAAK,eAAe,KAAK,aAAa,QAAW;AAAA,MAC/C,SAAS;AAAA,IAAA,CACV;AAAA,EAAA;AAIH,QAAM,WAAW;AAAA,IACf,MAAM,OAAO,YAAY,UAAU,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AAAA,IACtE,CAAC,SAAS;AAAA,EAAA;AAGZ,QAAM,UAAU,KAAK,eAAe,KAAK,SAAA;AACzC,QAAM,cAAc,MAAM,YAAY,kBAAkB,EAAE,UAAU,SAAS;AAG7E,QAAM,iBAAiB,CACrB,YACI;AAAA,IACJ,UAAU,OAAO,EAAE,WAA6B;AAC9C,YAAM,YAAY,cAAc,EAAE,UAAU,SAAS;AACrD,YAAM,WAAW,YAAY,aAA8B,OAAO;AAClE,kBAAY;AAAA,QAA8B;AAAA,QAAS,CAAC,QAClD,MAAM,OAAO,KAAK,IAAI,IAAI;AAAA,MAAA;AAE5B,aAAO,EAAE,SAAA;AAAA,IACX;AAAA,IACA,SAAS,CACP,QACA,QACA,YACG;AACH,kB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,CAAC;AACH,QAAM,cAAc,CAAC,WAAoB;AAAA,IACvC,UAAU,CAAC,EAAE,WAA6B,UAAU,MAAM,KAAK;AAAA,IAC/D,SAAS,CAAC,QAAiB,EAAE,WAC3B,UAAU,MAAM,MAAS;AAAA,IAC3B,WAAW,MAAM;AACf,WAAK,YAAY,kBAAkB;AAAA,QACjC,UAAU,KAAK,eAAe,KAAK,SAAA;AAAA,QACnC,aAAa;AAAA,MAAA,CACd;AACD,WAAK,YAAA;AAAA,IACP;AAAA,EAAA;AAEF,QAAM,OAAO;AAAA,IACX,KAAK,eAAe,KAAK,gBAAgB,YAAY,IAAI,CAAC;AAAA,EAAA;AAE5D,QAAM,SAAS;AAAA,IACb,KAAK,eAAe,OAAO,gBAAgB,YAAY,KAAK,CAAC;AAAA,EAAA;AAG/D,QAAM,aAAa;AAAA,IACjB,CAAC,SAAwB;AACvB,YAAM,OAAO,QAAQ,IAAI,KAAK,IAAI;AAClC,aAAO,SAAS,SAAY,OAAO,SAAS,MAAM,IAAI;AAAA,IACxD;AAAA,IACA,CAAC,OAAO;AAAA,EAAA;AAGV,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,10 @@
1
+ import { AcRouterContext } from '~/types/types';
2
+ /**
3
+ * The feature switch, read with the route context's clients, for the route
4
+ * above the layout's providers. Same query key as the header's, so it is one
5
+ * request. Here and not in the route file: a deployment compiles the core's
6
+ * route files from its own tree, where these packages are other copies.
7
+ */
8
+ export declare function useCommunityToolsConfig({ queryClient, trpcClient, }: Pick<AcRouterContext, 'queryClient' | 'trpcClient'>): {
9
+ enabled: boolean;
10
+ } | undefined;
@@ -0,0 +1,20 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { createTRPCOptionsProxy } from "@trpc/tanstack-react-query";
3
+ import { useMemo } from "react";
4
+ function useCommunityToolsConfig({
5
+ queryClient,
6
+ trpcClient
7
+ }) {
8
+ const options = useMemo(
9
+ () => createTRPCOptionsProxy({
10
+ client: trpcClient,
11
+ queryClient
12
+ }).communityTools.config.queryOptions(),
13
+ [queryClient, trpcClient]
14
+ );
15
+ return useQuery(options, queryClient).data;
16
+ }
17
+ export {
18
+ useCommunityToolsConfig
19
+ };
20
+ //# sourceMappingURL=useCommunityToolsConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCommunityToolsConfig.js","sources":["../../../../src/modules/communityTools/useCommunityToolsConfig.ts"],"sourcesContent":["import type { TRPCRouter } from '@igstack/app-catalog-backend-core'\nimport { useQuery } from '@tanstack/react-query'\nimport { createTRPCOptionsProxy } from '@trpc/tanstack-react-query'\nimport { useMemo } from 'react'\nimport type { AcRouterContext } from '~/types/types'\n\n/**\n * The feature switch, read with the route context's clients, for the route\n * above the layout's providers. Same query key as the header's, so it is one\n * request. Here and not in the route file: a deployment compiles the core's\n * route files from its own tree, where these packages are other copies.\n */\nexport function useCommunityToolsConfig({\n queryClient,\n trpcClient,\n}: Pick<AcRouterContext, 'queryClient' | 'trpcClient'>) {\n const options = useMemo(\n () =>\n createTRPCOptionsProxy<TRPCRouter>({\n client: trpcClient,\n queryClient,\n }).communityTools.config.queryOptions(),\n [queryClient, trpcClient],\n )\n return useQuery(options, queryClient).data\n}\n"],"names":[],"mappings":";;;AAYO,SAAS,wBAAwB;AAAA,EACtC;AAAA,EACA;AACF,GAAwD;AACtD,QAAM,UAAU;AAAA,IACd,MACE,uBAAmC;AAAA,MACjC,QAAQ;AAAA,MACR;AAAA,IAAA,CACD,EAAE,eAAe,OAAO,aAAA;AAAA,IAC3B,CAAC,aAAa,UAAU;AAAA,EAAA;AAE1B,SAAO,SAAS,SAAS,WAAW,EAAE;AACxC;"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * True once `ms` have passed since `key` was first shown, false until then. A
3
+ * new key starts the wait again. The card's cap on waiting for a screenshot.
4
+ */
5
+ export declare function useTimeUp(key: string, ms: number): boolean;
@@ -0,0 +1,13 @@
1
+ import { useState, useEffect } from "react";
2
+ function useTimeUp(key, ms) {
3
+ const [upFor, setUpFor] = useState(null);
4
+ useEffect(() => {
5
+ const timer = setTimeout(() => setUpFor(key), ms);
6
+ return () => clearTimeout(timer);
7
+ }, [key, ms]);
8
+ return upFor === key;
9
+ }
10
+ export {
11
+ useTimeUp
12
+ };
13
+ //# sourceMappingURL=useTimeUp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTimeUp.js","sources":["../../../../src/modules/communityTools/useTimeUp.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\n/**\n * True once `ms` have passed since `key` was first shown, false until then. A\n * new key starts the wait again. The card's cap on waiting for a screenshot.\n */\nexport function useTimeUp(key: string, ms: number): boolean {\n const [upFor, setUpFor] = useState<string | null>(null)\n useEffect(() => {\n const timer = setTimeout(() => setUpFor(key), ms)\n return () => clearTimeout(timer)\n }, [key, ms])\n return upFor === key\n}\n"],"names":[],"mappings":";AAMO,SAAS,UAAU,KAAa,IAAqB;AAC1D,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AACtD,YAAU,MAAM;AACd,UAAM,QAAQ,WAAW,MAAM,SAAS,GAAG,GAAG,EAAE;AAChD,WAAO,MAAM,aAAa,KAAK;AAAA,EACjC,GAAG,CAAC,KAAK,EAAE,CAAC;AACZ,SAAO,UAAU;AACnB;"}
@@ -1,10 +1,10 @@
1
1
  import { $constructor, $ZodEncodeError } from "../core/core.js";
2
2
  import { normalizeParams, defineLazy, extend, safeExtend, merge, pick, omit, partial, required, mergeDefs, clone, shallowClone, issue } from "../core/util.js";
3
- import { $ZodObjectJIT, $ZodOptional, $ZodNonOptional, $ZodString, $ZodType, $ZodEnum, $ZodExactOptional, $ZodNullable, $ZodUnion, $ZodIntersection, $ZodPipe, $ZodTransform, $ZodDefault, $ZodPrefault, $ZodCatch, $ZodReadonly, $ZodStringFormat, $ZodEmail, $ZodGUID, $ZodUUID, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodIPv4, $ZodIPv6, $ZodCIDRv4, $ZodCIDRv6, $ZodBase64, $ZodBase64URL, $ZodE164, $ZodJWT, $ZodUnknown, $ZodNever, $ZodArray, $ZodCustom } from "../core/schemas.js";
3
+ import { $ZodObjectJIT, $ZodEnum, $ZodOptional, $ZodNonOptional, $ZodString, $ZodType, $ZodExactOptional, $ZodNullable, $ZodUnion, $ZodIntersection, $ZodPipe, $ZodTransform, $ZodDefault, $ZodPrefault, $ZodCatch, $ZodReadonly, $ZodStringFormat, $ZodEmail, $ZodGUID, $ZodUUID, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodIPv4, $ZodIPv6, $ZodCIDRv4, $ZodCIDRv6, $ZodBase64, $ZodBase64URL, $ZodE164, $ZodJWT, $ZodUnknown, $ZodNever, $ZodArray, $ZodCustom } from "../core/schemas.js";
4
4
  import { globalRegistry } from "../core/registries.js";
5
5
  import { _string, _email, _url, _jwt, _emoji, _guid, _uuid, _uuidv4, _uuidv6, _uuidv7, _nanoid, _cuid, _cuid2, _ulid, _base64, _base64url, _xid, _ksuid, _ipv4, _ipv6, _cidrv4, _cidrv6, _e164, _overwrite, _unknown, _never, _regex, _includes, _startsWith, _endsWith, _minLength, _maxLength, _length, _lowercase, _uppercase, _trim, _normalize, _toLowerCase, _toUpperCase, _slugify, _refine, _superRefine, _array } from "../core/api.js";
6
6
  import { createStandardJSONSchemaMethod, createToJSONSchemaMethod } from "../core/to-json-schema.js";
7
- import { objectProcessor, optionalProcessor, nonoptionalProcessor, enumProcessor, stringProcessor, nullableProcessor, unionProcessor, intersectionProcessor, pipeProcessor, transformProcessor, defaultProcessor, prefaultProcessor, catchProcessor, readonlyProcessor, unknownProcessor, neverProcessor, arrayProcessor, customProcessor } from "../core/json-schema-processors.js";
7
+ import { objectProcessor, enumProcessor, optionalProcessor, nonoptionalProcessor, stringProcessor, nullableProcessor, unionProcessor, intersectionProcessor, pipeProcessor, transformProcessor, defaultProcessor, prefaultProcessor, catchProcessor, readonlyProcessor, unknownProcessor, neverProcessor, arrayProcessor, customProcessor } from "../core/json-schema-processors.js";
8
8
  import { datetime, date, time, duration } from "./iso.js";
9
9
  import { parse, safeParse, parseAsync, safeParseAsync, encode, decode, encodeAsync, decodeAsync, safeEncode, safeDecode, safeEncodeAsync, safeDecodeAsync } from "./parse.js";
10
10
  const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {