create-pet-adopt 0.0.0 → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +120 -0
- package/index.js +920 -0
- package/package.json +43 -1
- package/template/.env.example +136 -0
- package/template/.pet-adopt/template.json +581 -0
- package/template/LICENSE +21 -0
- package/template/README.md +109 -0
- package/template/_gitignore +28 -0
- package/template/_pnpm-lock.yaml +9251 -0
- package/template/assets/sample-pet.png +0 -0
- package/template/components.json +25 -0
- package/template/docker-compose.yml +110 -0
- package/template/drizzle/pg/0000_initial.sql +176 -0
- package/template/drizzle/pg/0001_greedy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0002_fuzzy_the_renegades.sql +1 -0
- package/template/drizzle/pg/0003_thin_multiple_man.sql +1 -0
- package/template/drizzle/pg/0004_boring_norman_osborn.sql +15 -0
- package/template/drizzle/pg/0005_bitter_proemial_gods.sql +3 -0
- package/template/drizzle/pg/0006_friendly_black_knight.sql +2 -0
- package/template/drizzle/pg/0007_wise_ozymandias.sql +11 -0
- package/template/drizzle/pg/0008_messy_human_fly.sql +2 -0
- package/template/drizzle/pg/0009_amused_lady_bullseye.sql +1 -0
- package/template/drizzle/pg/0010_cute_mauler.sql +7 -0
- package/template/drizzle/pg/0011_clear_purple_man.sql +3 -0
- package/template/drizzle/pg/0012_tiresome_gunslinger.sql +2 -0
- package/template/drizzle/pg/0013_awesome_wong.sql +18 -0
- package/template/drizzle/pg/0014_fantastic_sumo.sql +12 -0
- package/template/drizzle/pg/0015_pink_carnage.sql +12 -0
- package/template/drizzle/pg/0016_sloppy_king_bedlam.sql +2 -0
- package/template/drizzle/pg/0017_steep_warhawk.sql +15 -0
- package/template/drizzle/pg/0018_mixed_otto_octavius.sql +4 -0
- package/template/drizzle/pg/0019_talented_rocket_raccoon.sql +1 -0
- package/template/drizzle/pg/0020_worthless_zodiak.sql +19 -0
- package/template/drizzle/pg/0021_adorable_squadron_supreme.sql +1 -0
- package/template/drizzle/pg/0022_soft_pixie.sql +5 -0
- package/template/drizzle/pg/0023_fluffy_quasar.sql +1 -0
- package/template/drizzle/pg/0024_uneven_ken_ellis.sql +2 -0
- package/template/drizzle/pg/0025_rich_white_queen.sql +3 -0
- package/template/drizzle/pg/0026_spooky_komodo.sql +16 -0
- package/template/drizzle/pg/0027_big_thunderbolts.sql +2 -0
- package/template/drizzle/pg/meta/0000_snapshot.json +1265 -0
- package/template/drizzle/pg/meta/0001_snapshot.json +1272 -0
- package/template/drizzle/pg/meta/0002_snapshot.json +1278 -0
- package/template/drizzle/pg/meta/0003_snapshot.json +1284 -0
- package/template/drizzle/pg/meta/0004_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0005_snapshot.json +1401 -0
- package/template/drizzle/pg/meta/0006_snapshot.json +1414 -0
- package/template/drizzle/pg/meta/0007_snapshot.json +1485 -0
- package/template/drizzle/pg/meta/0008_snapshot.json +1504 -0
- package/template/drizzle/pg/meta/0009_snapshot.json +1510 -0
- package/template/drizzle/pg/meta/0010_snapshot.json +1556 -0
- package/template/drizzle/pg/meta/0011_snapshot.json +1574 -0
- package/template/drizzle/pg/meta/0012_snapshot.json +1586 -0
- package/template/drizzle/pg/meta/0013_snapshot.json +1730 -0
- package/template/drizzle/pg/meta/0014_snapshot.json +1805 -0
- package/template/drizzle/pg/meta/0015_snapshot.json +1883 -0
- package/template/drizzle/pg/meta/0016_snapshot.json +1897 -0
- package/template/drizzle/pg/meta/0017_snapshot.json +2013 -0
- package/template/drizzle/pg/meta/0018_snapshot.json +1988 -0
- package/template/drizzle/pg/meta/0019_snapshot.json +1994 -0
- package/template/drizzle/pg/meta/0020_snapshot.json +2108 -0
- package/template/drizzle/pg/meta/0021_snapshot.json +2114 -0
- package/template/drizzle/pg/meta/0022_snapshot.json +2126 -0
- package/template/drizzle/pg/meta/0023_snapshot.json +2132 -0
- package/template/drizzle/pg/meta/0024_snapshot.json +2151 -0
- package/template/drizzle/pg/meta/0025_snapshot.json +2169 -0
- package/template/drizzle/pg/meta/0026_snapshot.json +2294 -0
- package/template/drizzle/pg/meta/0027_snapshot.json +2330 -0
- package/template/drizzle/pg/meta/_journal.json +202 -0
- package/template/drizzle/sqlite/0000_initial.sql +176 -0
- package/template/drizzle/sqlite/0001_easy_sebastian_shaw.sql +1 -0
- package/template/drizzle/sqlite/0002_past_king_cobra.sql +1 -0
- package/template/drizzle/sqlite/0003_organic_masked_marvel.sql +1 -0
- package/template/drizzle/sqlite/0004_panoramic_inhumans.sql +15 -0
- package/template/drizzle/sqlite/0005_small_sunset_bain.sql +19 -0
- package/template/drizzle/sqlite/0006_narrow_medusa.sql +2 -0
- package/template/drizzle/sqlite/0007_gray_grandmaster.sql +10 -0
- package/template/drizzle/sqlite/0008_chief_toxin.sql +1 -0
- package/template/drizzle/sqlite/0009_vengeful_tag.sql +1 -0
- package/template/drizzle/sqlite/0010_kind_klaw.sql +7 -0
- package/template/drizzle/sqlite/0011_overrated_meltdown.sql +3 -0
- package/template/drizzle/sqlite/0012_robust_next_avengers.sql +2 -0
- package/template/drizzle/sqlite/0013_melodic_kitty_pryde.sql +18 -0
- package/template/drizzle/sqlite/0014_stormy_cyclops.sql +12 -0
- package/template/drizzle/sqlite/0015_parallel_mongu.sql +11 -0
- package/template/drizzle/sqlite/0016_grey_quicksilver.sql +2 -0
- package/template/drizzle/sqlite/0017_daily_psylocke.sql +15 -0
- package/template/drizzle/sqlite/0018_whole_redwing.sql +4 -0
- package/template/drizzle/sqlite/0019_spotty_mandroid.sql +1 -0
- package/template/drizzle/sqlite/0020_wild_wendell_rand.sql +19 -0
- package/template/drizzle/sqlite/0021_calm_lockheed.sql +1 -0
- package/template/drizzle/sqlite/0022_lonely_emma_frost.sql +5 -0
- package/template/drizzle/sqlite/0023_elite_tony_stark.sql +1 -0
- package/template/drizzle/sqlite/0024_little_lily_hollister.sql +1 -0
- package/template/drizzle/sqlite/0025_tough_shotgun.sql +3 -0
- package/template/drizzle/sqlite/0026_faithful_mephistopheles.sql +16 -0
- package/template/drizzle/sqlite/0027_rapid_arclight.sql +2 -0
- package/template/drizzle/sqlite/meta/0000_snapshot.json +1237 -0
- package/template/drizzle/sqlite/meta/0001_snapshot.json +1245 -0
- package/template/drizzle/sqlite/meta/0002_snapshot.json +1252 -0
- package/template/drizzle/sqlite/meta/0003_snapshot.json +1259 -0
- package/template/drizzle/sqlite/meta/0004_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0005_snapshot.json +1369 -0
- package/template/drizzle/sqlite/meta/0006_snapshot.json +1384 -0
- package/template/drizzle/sqlite/meta/0007_snapshot.json +1459 -0
- package/template/drizzle/sqlite/meta/0008_snapshot.json +1479 -0
- package/template/drizzle/sqlite/meta/0009_snapshot.json +1486 -0
- package/template/drizzle/sqlite/meta/0010_snapshot.json +1533 -0
- package/template/drizzle/sqlite/meta/0011_snapshot.json +1554 -0
- package/template/drizzle/sqlite/meta/0012_snapshot.json +1568 -0
- package/template/drizzle/sqlite/meta/0013_snapshot.json +1687 -0
- package/template/drizzle/sqlite/meta/0014_snapshot.json +1769 -0
- package/template/drizzle/sqlite/meta/0015_snapshot.json +1852 -0
- package/template/drizzle/sqlite/meta/0016_snapshot.json +1867 -0
- package/template/drizzle/sqlite/meta/0017_snapshot.json +1973 -0
- package/template/drizzle/sqlite/meta/0018_snapshot.json +1944 -0
- package/template/drizzle/sqlite/meta/0019_snapshot.json +1951 -0
- package/template/drizzle/sqlite/meta/0020_snapshot.json +2077 -0
- package/template/drizzle/sqlite/meta/0021_snapshot.json +2084 -0
- package/template/drizzle/sqlite/meta/0022_snapshot.json +2098 -0
- package/template/drizzle/sqlite/meta/0023_snapshot.json +2105 -0
- package/template/drizzle/sqlite/meta/0024_snapshot.json +2125 -0
- package/template/drizzle/sqlite/meta/0025_snapshot.json +2146 -0
- package/template/drizzle/sqlite/meta/0026_snapshot.json +2265 -0
- package/template/drizzle/sqlite/meta/0027_snapshot.json +2280 -0
- package/template/drizzle/sqlite/meta/_journal.json +202 -0
- package/template/drizzle.pg.config.ts +8 -0
- package/template/drizzle.sqlite.config.ts +8 -0
- package/template/eslint.config.mjs +22 -0
- package/template/next.config.ts +153 -0
- package/template/package.json +102 -0
- package/template/pet-adopt.blocks.ts +9 -0
- package/template/pet-adopt.config.ts +17 -0
- package/template/pnpm-workspace.yaml +19 -0
- package/template/postcss.config.mjs +5 -0
- package/template/scripts/check-routes.ts +405 -0
- package/template/scripts/check-schemas.ts +58 -0
- package/template/scripts/migrate-all.ts +25 -0
- package/template/scripts/migrate-on-build.ts +71 -0
- package/template/scripts/migrate.ts +20 -0
- package/template/scripts/plugin-generate.ts +92 -0
- package/template/scripts/reset-password.ts +45 -0
- package/template/scripts/reset-two-factor.ts +53 -0
- package/template/scripts/seed.ts +79 -0
- package/template/scripts/setup-env.ts +91 -0
- package/template/scripts/storage-check.ts +53 -0
- package/template/src/app/(admin)/admin/account/AccountForms.tsx +194 -0
- package/template/src/app/(admin)/admin/account/page.tsx +59 -0
- package/template/src/app/(admin)/admin/activity/page.tsx +76 -0
- package/template/src/app/(admin)/admin/authentication/archived/page.tsx +24 -0
- package/template/src/app/(admin)/admin/authentication/layout.tsx +20 -0
- package/template/src/app/(admin)/admin/authentication/page.tsx +36 -0
- package/template/src/app/(admin)/admin/authentication/providers/page.tsx +33 -0
- package/template/src/app/(admin)/admin/email/layout.tsx +21 -0
- package/template/src/app/(admin)/admin/email/page.tsx +43 -0
- package/template/src/app/(admin)/admin/email/templates/page.tsx +38 -0
- package/template/src/app/(admin)/admin/error.tsx +36 -0
- package/template/src/app/(admin)/admin/layout.tsx +26 -0
- package/template/src/app/(admin)/admin/loading.tsx +9 -0
- package/template/src/app/(admin)/admin/media/[id]/page.tsx +97 -0
- package/template/src/app/(admin)/admin/media/page.tsx +34 -0
- package/template/src/app/(admin)/admin/media/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/page.tsx +79 -0
- package/template/src/app/(admin)/admin/pages/PageForm.tsx +604 -0
- package/template/src/app/(admin)/admin/pages/[id]/page.tsx +51 -0
- package/template/src/app/(admin)/admin/pages/new/page.tsx +19 -0
- package/template/src/app/(admin)/admin/pages/page.tsx +49 -0
- package/template/src/app/(admin)/admin/pets/PetForm.tsx +437 -0
- package/template/src/app/(admin)/admin/pets/[id]/page.tsx +41 -0
- package/template/src/app/(admin)/admin/pets/new/page.tsx +26 -0
- package/template/src/app/(admin)/admin/pets/page.tsx +70 -0
- package/template/src/app/(admin)/admin/pets/search-params.ts +16 -0
- package/template/src/app/(admin)/admin/plugins/[plugin]/[[...path]]/page.tsx +73 -0
- package/template/src/app/(admin)/admin/plugins/page.tsx +66 -0
- package/template/src/app/(admin)/admin/settings/SettingsForm.tsx +644 -0
- package/template/src/app/(admin)/admin/settings/email/page.tsx +9 -0
- package/template/src/app/(admin)/admin/settings/page.tsx +40 -0
- package/template/src/app/(admin)/admin/settings/templates/page.tsx +9 -0
- package/template/src/app/(admin)/admin/theme/[id]/page.tsx +28 -0
- package/template/src/app/(admin)/admin/theme/page.tsx +30 -0
- package/template/src/app/(admin)/admin/users/page.tsx +33 -0
- package/template/src/app/(admin)/layout.tsx +75 -0
- package/template/src/app/(admin)/providers.tsx +42 -0
- package/template/src/app/(auth)/admin/confirm-email/page.tsx +40 -0
- package/template/src/app/(auth)/admin/invite/page.tsx +38 -0
- package/template/src/app/(auth)/admin/login/DemoSignIn.tsx +69 -0
- package/template/src/app/(auth)/admin/login/page.tsx +83 -0
- package/template/src/app/(auth)/admin/reset-password/page.tsx +73 -0
- package/template/src/app/(auth)/error.tsx +9 -0
- package/template/src/app/(auth)/layout.tsx +71 -0
- package/template/src/app/(editor)/EditorToast.tsx +43 -0
- package/template/src/app/(editor)/edit/[id]/PageEditor.tsx +586 -0
- package/template/src/app/(editor)/edit/[id]/actions.ts +139 -0
- package/template/src/app/(editor)/edit/[id]/page.tsx +76 -0
- package/template/src/app/(editor)/edit/[id]/preview/page.tsx +81 -0
- package/template/src/app/(editor)/edit/email/[id]/EmailEditor.tsx +236 -0
- package/template/src/app/(editor)/edit/email/[id]/page.tsx +64 -0
- package/template/src/app/(editor)/edit/theme-preview/page.tsx +94 -0
- package/template/src/app/(editor)/editor.css +223 -0
- package/template/src/app/(editor)/error.tsx +32 -0
- package/template/src/app/(editor)/layout.tsx +67 -0
- package/template/src/app/(frontend)/[slug]/page.tsx +53 -0
- package/template/src/app/(frontend)/fonts.ts +8 -0
- package/template/src/app/(frontend)/layout.tsx +107 -0
- package/template/src/app/(frontend)/not-found.tsx +16 -0
- package/template/src/app/(frontend)/page.tsx +42 -0
- package/template/src/app/(frontend)/pets/[slug]/page.tsx +92 -0
- package/template/src/app/(frontend)/pets/page.tsx +42 -0
- package/template/src/app/(frontend)/styles.css +537 -0
- package/template/src/app/(setup)/error.tsx +9 -0
- package/template/src/app/(setup)/layout.tsx +41 -0
- package/template/src/app/(setup)/setup/page.tsx +105 -0
- package/template/src/app/(setup)/setup/storage-check.ts +43 -0
- package/template/src/app/api/auth/[...all]/route.ts +144 -0
- package/template/src/app/health/route.ts +9 -0
- package/template/src/app/media/[...path]/route.ts +45 -0
- package/template/src/app/media/email/[name]/route.ts +60 -0
- package/template/src/app/robots.ts +19 -0
- package/template/src/app/sitemap.ts +24 -0
- package/template/src/components/admin/AdminNav.tsx +153 -0
- package/template/src/components/admin/AdminShell.tsx +107 -0
- package/template/src/components/admin/DemoNotice.tsx +31 -0
- package/template/src/components/admin/EmailConfirmBanner.tsx +44 -0
- package/template/src/components/admin/EmptyState.tsx +10 -0
- package/template/src/components/admin/ErrorSummary.tsx +72 -0
- package/template/src/components/admin/MediaDetails.tsx +218 -0
- package/template/src/components/admin/MediaGrid.tsx +307 -0
- package/template/src/components/admin/MediaLibrary.tsx +103 -0
- package/template/src/components/admin/MediaPager.tsx +66 -0
- package/template/src/components/admin/PageHeader.tsx +22 -0
- package/template/src/components/admin/PhoneInput.tsx +128 -0
- package/template/src/components/admin/PluginWidgetBoundary.tsx +38 -0
- package/template/src/components/admin/PluginWidgets.tsx +51 -0
- package/template/src/components/admin/RemountOnNavigate.tsx +37 -0
- package/template/src/components/admin/StatusBadge.tsx +16 -0
- package/template/src/components/admin/UploadPhotosDialog.tsx +387 -0
- package/template/src/components/admin/UserAvatar.tsx +18 -0
- package/template/src/components/admin/UserMenu.tsx +118 -0
- package/template/src/components/admin/ViewSiteLink.tsx +24 -0
- package/template/src/components/admin/account/ConnectedProviders.tsx +91 -0
- package/template/src/components/admin/account/DeleteAccountCard.tsx +136 -0
- package/template/src/components/admin/account/EmailCard.tsx +137 -0
- package/template/src/components/admin/account/ProfilePicture.tsx +159 -0
- package/template/src/components/admin/activity/ActivityFilters.tsx +146 -0
- package/template/src/components/admin/activity/ActivityLog.tsx +159 -0
- package/template/src/components/admin/activity/RecentActivity.tsx +52 -0
- package/template/src/components/admin/demo-mode.tsx +17 -0
- package/template/src/components/admin/nav-items.ts +47 -0
- package/template/src/components/admin/pages/PageDetails.tsx +198 -0
- package/template/src/components/admin/pages/PageVersions.tsx +296 -0
- package/template/src/components/admin/pages/PagesTable.tsx +467 -0
- package/template/src/components/admin/pets/FilterBar.tsx +154 -0
- package/template/src/components/admin/pets/PetCard.tsx +170 -0
- package/template/src/components/admin/pets/PetList.tsx +112 -0
- package/template/src/components/admin/pets/PetListSkeleton.tsx +84 -0
- package/template/src/components/admin/pets/PetPagination.tsx +91 -0
- package/template/src/components/admin/pets/form/AgeFields.tsx +132 -0
- package/template/src/components/admin/pets/form/LocationFields.tsx +231 -0
- package/template/src/components/admin/pets/form/MediaPickerDialog.tsx +359 -0
- package/template/src/components/admin/pets/form/PhotosField.tsx +176 -0
- package/template/src/components/admin/pets/form/RichTextField.tsx +438 -0
- package/template/src/components/admin/pets/form/SeoImageField.tsx +87 -0
- package/template/src/components/admin/pets/form/SeoPreview.tsx +142 -0
- package/template/src/components/admin/pets/form/fields.tsx +434 -0
- package/template/src/components/admin/pets/form/rich-text-extensions.ts +45 -0
- package/template/src/components/admin/pets/timeline/PetTimeline.tsx +297 -0
- package/template/src/components/admin/pets/timeline/TimelineEntryForm.tsx +289 -0
- package/template/src/components/admin/pets/timeline/TimelinePhotosField.tsx +173 -0
- package/template/src/components/admin/plugins/PluginNotReady.tsx +28 -0
- package/template/src/components/admin/plugins/PluginOverview.tsx +121 -0
- package/template/src/components/admin/plugins/SendTestEmail.tsx +70 -0
- package/template/src/components/admin/settings/AuthProviders.tsx +373 -0
- package/template/src/components/admin/settings/AuthenticationNav.tsx +42 -0
- package/template/src/components/admin/settings/EmailNav.tsx +40 -0
- package/template/src/components/admin/settings/EmailSettingsForm.tsx +325 -0
- package/template/src/components/admin/settings/EmailTemplates.tsx +551 -0
- package/template/src/components/admin/settings/RegionFields.tsx +203 -0
- package/template/src/components/admin/site-time.tsx +26 -0
- package/template/src/components/admin/theme/ThemeEditor.tsx +467 -0
- package/template/src/components/admin/theme/ThemeLibrary.tsx +339 -0
- package/template/src/components/admin/theme/ThemeSwatches.tsx +30 -0
- package/template/src/components/admin/theme/theme-utils.ts +32 -0
- package/template/src/components/admin/two-factor/BackupCodeList.tsx +54 -0
- package/template/src/components/admin/two-factor/TwoFactorCard.tsx +237 -0
- package/template/src/components/admin/two-factor/TwoFactorRequired.tsx +52 -0
- package/template/src/components/admin/two-factor/TwoFactorSetup.tsx +180 -0
- package/template/src/components/admin/use-unsaved-changes.tsx +101 -0
- package/template/src/components/admin/users/ArchivedAccounts.tsx +159 -0
- package/template/src/components/admin/users/InviteDialogs.tsx +131 -0
- package/template/src/components/admin/users/TwoFactorRoles.tsx +80 -0
- package/template/src/components/admin/users/UserDialogs.tsx +681 -0
- package/template/src/components/admin/users/UsersTable.tsx +374 -0
- package/template/src/components/admin/view-only.tsx +43 -0
- package/template/src/components/auth/AcceptInviteForm.tsx +123 -0
- package/template/src/components/auth/AuthNav.tsx +80 -0
- package/template/src/components/auth/ConfirmEmailForm.tsx +73 -0
- package/template/src/components/auth/LoginForm.tsx +250 -0
- package/template/src/components/auth/PageError.tsx +37 -0
- package/template/src/components/auth/ProviderSignIn.tsx +53 -0
- package/template/src/components/auth/ResetPasswordForm.tsx +267 -0
- package/template/src/components/demo/DemoBanner.tsx +38 -0
- package/template/src/components/demo/SiteDemoBanner.tsx +22 -0
- package/template/src/components/demo/wording.ts +21 -0
- package/template/src/components/setup/SetupAccountForm.tsx +93 -0
- package/template/src/components/setup/SetupDone.tsx +95 -0
- package/template/src/components/setup/SetupNav.tsx +49 -0
- package/template/src/components/setup/SetupSampleContent.tsx +67 -0
- package/template/src/components/setup/SetupSiteForm.tsx +104 -0
- package/template/src/components/setup/SetupThemePicker.tsx +73 -0
- package/template/src/components/setup/SkipSetup.tsx +35 -0
- package/template/src/components/site/BuilderContent.tsx +46 -0
- package/template/src/components/site/CopyButton.tsx +28 -0
- package/template/src/components/site/ImageCarousel.tsx +52 -0
- package/template/src/components/site/PetCard.tsx +32 -0
- package/template/src/components/site/PetCatalog.tsx +106 -0
- package/template/src/components/site/PetGallery.tsx +75 -0
- package/template/src/components/site/PetTimeline.tsx +82 -0
- package/template/src/components/site/RemountOnNavigate.tsx +13 -0
- package/template/src/components/site/RichText.tsx +56 -0
- package/template/src/components/site/SmartLink.tsx +37 -0
- package/template/src/components/site/SocialIcons.tsx +26 -0
- package/template/src/components/site/ThemePreviewBridge.tsx +29 -0
- package/template/src/components/site/ThemeStyle.tsx +22 -0
- package/template/src/components/site/ThemeToggle.tsx +36 -0
- package/template/src/components/site/WhatsAppButton.tsx +27 -0
- package/template/src/components/site/timeline-format.ts +20 -0
- package/template/src/db/client.ts +702 -0
- package/template/src/db/compare-tables.ts +41 -0
- package/template/src/db/migrate.ts +28 -0
- package/template/src/db/plugin-migrations.ts +167 -0
- package/template/src/db/schema/pg.ts +484 -0
- package/template/src/db/schema/sqlite.ts +492 -0
- package/template/src/instrumentation.ts +110 -0
- package/template/src/lib/activity.ts +29 -0
- package/template/src/lib/admin/call-action.ts +19 -0
- package/template/src/lib/admin/initials.ts +9 -0
- package/template/src/lib/admin/media-cache.ts +16 -0
- package/template/src/lib/admin/media-page.ts +3 -0
- package/template/src/lib/admin/pet-form.ts +242 -0
- package/template/src/lib/admin/pets-cache.ts +22 -0
- package/template/src/lib/admin/unwrap-client.ts +11 -0
- package/template/src/lib/admin/unwrap.ts +38 -0
- package/template/src/lib/admin/use-media-list.ts +41 -0
- package/template/src/lib/admin/use-pet-list.ts +58 -0
- package/template/src/lib/age.ts +117 -0
- package/template/src/lib/auth-provider-errors.ts +38 -0
- package/template/src/lib/cache.ts +69 -0
- package/template/src/lib/color-mode.ts +48 -0
- package/template/src/lib/demo.ts +78 -0
- package/template/src/lib/email-address.ts +9 -0
- package/template/src/lib/email-template.ts +691 -0
- package/template/src/lib/links.ts +78 -0
- package/template/src/lib/mail-error.ts +38 -0
- package/template/src/lib/media-name.ts +31 -0
- package/template/src/lib/options.ts +134 -0
- package/template/src/lib/pagination.ts +28 -0
- package/template/src/lib/pet-placeholders.ts +34 -0
- package/template/src/lib/pet-seo.ts +40 -0
- package/template/src/lib/pet-timeline.ts +62 -0
- package/template/src/lib/phone.ts +129 -0
- package/template/src/lib/places.ts +84 -0
- package/template/src/lib/queries.ts +549 -0
- package/template/src/lib/revalidate.ts +32 -0
- package/template/src/lib/rich-text.ts +215 -0
- package/template/src/lib/seo.ts +121 -0
- package/template/src/lib/slugify.ts +11 -0
- package/template/src/lib/theme.ts +546 -0
- package/template/src/lib/utils.ts +2 -0
- package/template/src/lib/whatsapp.ts +29 -0
- package/template/src/lib/zod-schema/auth.ts +56 -0
- package/template/src/lib/zod-schema/page.ts +57 -0
- package/template/src/lib/zod-schema/pet-timeline.ts +118 -0
- package/template/src/lib/zod-schema/pet.ts +172 -0
- package/template/src/lib/zod-schema/settings.ts +162 -0
- package/template/src/plugins/host.ts +117 -0
- package/template/src/plugins/icon.ts +89 -0
- package/template/src/plugins/registry.ts +369 -0
- package/template/src/plugins/storage-rules.ts +87 -0
- package/template/src/plugins/storage.ts +184 -0
- package/template/src/puck/actions.ts +46 -0
- package/template/src/puck/config.tsx +1693 -0
- package/template/src/puck/data.ts +196 -0
- package/template/src/puck/demo-mode.tsx +20 -0
- package/template/src/puck/email-config.tsx +267 -0
- package/template/src/puck/icons.tsx +76 -0
- package/template/src/puck/media-picker.tsx +273 -0
- package/template/src/puck/padding.tsx +71 -0
- package/template/src/puck/pet-page-config.tsx +511 -0
- package/template/src/puck/pet-picker.tsx +40 -0
- package/template/src/puck/plugin-block-data.ts +91 -0
- package/template/src/puck/plugin-blocks.tsx +235 -0
- package/template/src/puck/plugin-choice-field.tsx +87 -0
- package/template/src/puck/sanitize.ts +107 -0
- package/template/src/puck/server.ts +36 -0
- package/template/src/puck/types.ts +41 -0
- package/template/src/server/actions/activity.ts +48 -0
- package/template/src/server/actions/auth-providers.ts +171 -0
- package/template/src/server/actions/auth.ts +217 -0
- package/template/src/server/actions/demo.ts +30 -0
- package/template/src/server/actions/email-change.ts +80 -0
- package/template/src/server/actions/email-templates.ts +144 -0
- package/template/src/server/actions/email.ts +70 -0
- package/template/src/server/actions/media.ts +127 -0
- package/template/src/server/actions/pages.ts +159 -0
- package/template/src/server/actions/password-reset.ts +80 -0
- package/template/src/server/actions/pet-timeline.ts +75 -0
- package/template/src/server/actions/pets.ts +74 -0
- package/template/src/server/actions/places.ts +36 -0
- package/template/src/server/actions/settings.ts +29 -0
- package/template/src/server/actions/setup.ts +72 -0
- package/template/src/server/actions/themes.ts +80 -0
- package/template/src/server/actions/two-factor.ts +306 -0
- package/template/src/server/actions/users.ts +200 -0
- package/template/src/server/activity.ts +409 -0
- package/template/src/server/auth-errors.ts +17 -0
- package/template/src/server/auth-providers.ts +359 -0
- package/template/src/server/auth.ts +266 -0
- package/template/src/server/avatars.ts +263 -0
- package/template/src/server/demo-site.ts +169 -0
- package/template/src/server/email-change.ts +278 -0
- package/template/src/server/email-templates.ts +350 -0
- package/template/src/server/email.ts +442 -0
- package/template/src/server/invites.ts +143 -0
- package/template/src/server/media-url.ts +20 -0
- package/template/src/server/media.ts +236 -0
- package/template/src/server/pages.ts +812 -0
- package/template/src/server/password-reset.ts +158 -0
- package/template/src/server/pending-links.ts +46 -0
- package/template/src/server/pet-timeline.ts +181 -0
- package/template/src/server/pets.ts +555 -0
- package/template/src/server/places.ts +113 -0
- package/template/src/server/privacy.ts +21 -0
- package/template/src/server/provider-endpoints.ts +94 -0
- package/template/src/server/provider-guard.ts +157 -0
- package/template/src/server/result.ts +280 -0
- package/template/src/server/sample-content.ts +368 -0
- package/template/src/server/search-text.ts +43 -0
- package/template/src/server/secret-box.ts +38 -0
- package/template/src/server/session.ts +154 -0
- package/template/src/server/settings.ts +361 -0
- package/template/src/server/setup.ts +110 -0
- package/template/src/server/sitemap.ts +88 -0
- package/template/src/server/storage.ts +267 -0
- package/template/src/server/strip-metadata.ts +357 -0
- package/template/src/server/themes.ts +195 -0
- package/template/src/server/throttle.ts +258 -0
- package/template/src/server/two-factor-codes.ts +32 -0
- package/template/src/server/two-factor.ts +158 -0
- package/template/src/server/types.ts +198 -0
- package/template/src/server/uploads.ts +137 -0
- package/template/src/server/users.ts +500 -0
- package/template/tsconfig.json +44 -0
- package/template/ui/components.json +25 -0
- package/template/ui/package.json +12 -0
- package/template/ui/src/components/alert-dialog.tsx +187 -0
- package/template/ui/src/components/avatar.tsx +108 -0
- package/template/ui/src/components/badge.tsx +51 -0
- package/template/ui/src/components/button.tsx +57 -0
- package/template/ui/src/components/card.tsx +102 -0
- package/template/ui/src/components/carousel.tsx +245 -0
- package/template/ui/src/components/checkbox.tsx +27 -0
- package/template/ui/src/components/combobox.tsx +297 -0
- package/template/ui/src/components/dialog.tsx +159 -0
- package/template/ui/src/components/dropdown-menu.tsx +265 -0
- package/template/ui/src/components/field.tsx +238 -0
- package/template/ui/src/components/input-group.tsx +158 -0
- package/template/ui/src/components/input.tsx +19 -0
- package/template/ui/src/components/label.tsx +19 -0
- package/template/ui/src/components/pagination.tsx +127 -0
- package/template/ui/src/components/popover.tsx +89 -0
- package/template/ui/src/components/radio-group.tsx +37 -0
- package/template/ui/src/components/select.tsx +200 -0
- package/template/ui/src/components/separator.tsx +24 -0
- package/template/ui/src/components/sheet.tsx +138 -0
- package/template/ui/src/components/sidebar.tsx +723 -0
- package/template/ui/src/components/skeleton.tsx +13 -0
- package/template/ui/src/components/switch.tsx +31 -0
- package/template/ui/src/components/table.tsx +115 -0
- package/template/ui/src/components/tabs.tsx +81 -0
- package/template/ui/src/components/textarea.tsx +17 -0
- package/template/ui/src/components/toggle.tsx +44 -0
- package/template/ui/src/components/tooltip.tsx +65 -0
- package/template/ui/src/hooks/use-mobile.ts +21 -0
- package/template/ui/src/lib/utils.ts +2 -0
- package/template/ui/src/styles/globals.css +145 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
// Copies a piece of text (bank details, a DuitNow number) and says so in a polite live region.
|
|
6
|
+
// The text itself stays visible and selectable, so the button is only a shortcut.
|
|
7
|
+
export function CopyButton({ text, label = 'Copy' }: { text: string; label?: string }) {
|
|
8
|
+
const [state, setState] = React.useState<'idle' | 'copied' | 'failed'>('idle')
|
|
9
|
+
const copy = async () => {
|
|
10
|
+
try {
|
|
11
|
+
await navigator.clipboard.writeText(text)
|
|
12
|
+
setState('copied')
|
|
13
|
+
} catch {
|
|
14
|
+
setState('failed')
|
|
15
|
+
}
|
|
16
|
+
window.setTimeout(() => setState('idle'), 2500)
|
|
17
|
+
}
|
|
18
|
+
return (
|
|
19
|
+
<span className="copy-button">
|
|
20
|
+
<button type="button" className="btn btn-outline btn-small" onClick={copy}>
|
|
21
|
+
{label}
|
|
22
|
+
</button>
|
|
23
|
+
<span aria-live="polite" className="copy-status">
|
|
24
|
+
{state === 'copied' ? 'Copied' : state === 'failed' ? 'Could not copy. Select the text instead.' : ''}
|
|
25
|
+
</span>
|
|
26
|
+
</span>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Image from "next/image";
|
|
4
|
+
import React from "react";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Carousel,
|
|
8
|
+
CarouselContent,
|
|
9
|
+
CarouselItem,
|
|
10
|
+
CarouselNext,
|
|
11
|
+
CarouselPrevious,
|
|
12
|
+
} from "@pet-adopt/ui/components/carousel";
|
|
13
|
+
|
|
14
|
+
// The Image carousel block (shadcn's Carousel, on Embla). It is laid out by `.carousel-block` rules in
|
|
15
|
+
// the site's styles.css, keyed to the `data-slot` attributes the shadcn parts render, so it looks the
|
|
16
|
+
// same on the public site (where Tailwind is loaded) and in the page builder (where it is not).
|
|
17
|
+
// Accessibility comes from the shadcn parts: a labelled region, slides announced as "slide", buttons
|
|
18
|
+
// with "Previous slide"/"Next slide", and the arrow keys.
|
|
19
|
+
|
|
20
|
+
export type CarouselImage = { url: string; alt: string; caption: string };
|
|
21
|
+
|
|
22
|
+
export function ImageCarousel({ items, label }: { items: CarouselImage[]; label: string }) {
|
|
23
|
+
if (items.length === 0) return null;
|
|
24
|
+
const several = items.length > 1;
|
|
25
|
+
return (
|
|
26
|
+
<Carousel className="carousel-block" opts={{ loop: several }} aria-label={label || "Image carousel"}>
|
|
27
|
+
<CarouselContent>
|
|
28
|
+
{items.map((item, index) => (
|
|
29
|
+
<CarouselItem key={index} aria-label={`${index + 1} of ${items.length}`}>
|
|
30
|
+
<figure className="carousel-figure">
|
|
31
|
+
<div className="carousel-image">
|
|
32
|
+
<Image
|
|
33
|
+
src={item.url}
|
|
34
|
+
alt={item.alt || item.caption || ""}
|
|
35
|
+
fill
|
|
36
|
+
sizes="(max-width: 960px) 100vw, 960px"
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
{item.caption ? <figcaption>{item.caption}</figcaption> : null}
|
|
40
|
+
</figure>
|
|
41
|
+
</CarouselItem>
|
|
42
|
+
))}
|
|
43
|
+
</CarouselContent>
|
|
44
|
+
{several ? (
|
|
45
|
+
<>
|
|
46
|
+
<CarouselPrevious />
|
|
47
|
+
<CarouselNext />
|
|
48
|
+
</>
|
|
49
|
+
) : null}
|
|
50
|
+
</Carousel>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import Image from 'next/image'
|
|
2
|
+
import Link from 'next/link'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
import type { PetCardData } from '@/lib/queries'
|
|
6
|
+
import { SEXES, SPECIES, STATUSES, labelFor } from '@/lib/options'
|
|
7
|
+
|
|
8
|
+
/** `headingLevel`: the pet's name is one level below the section it sits in (h3 under an h2). */
|
|
9
|
+
export function PetCard({ pet, headingLevel: Name = 'h3' }: { pet: PetCardData; headingLevel?: 'h2' | 'h3' | 'h4' }) {
|
|
10
|
+
const details = [labelFor(SPECIES, pet.species), pet.ageDescription, pet.sex && pet.sex !== 'unknown' ? labelFor(SEXES, pet.sex) : null]
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.join(' · ')
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Link href={`/pets/${pet.slug}`} className="pet-card">
|
|
16
|
+
<div className="pet-card-image">
|
|
17
|
+
{/* The name is the card's heading: a photo without its own alt text adds nothing to the link. */}
|
|
18
|
+
{pet.image ? (
|
|
19
|
+
<Image src={pet.image.url} alt={pet.image.alt} fill sizes="(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 25vw" />
|
|
20
|
+
) : (
|
|
21
|
+
<div className="pet-card-placeholder">No photo</div>
|
|
22
|
+
)}
|
|
23
|
+
{pet.status !== 'available' && <span className={`badge badge-${pet.status}`}>{labelFor(STATUSES, pet.status)}</span>}
|
|
24
|
+
</div>
|
|
25
|
+
<div className="pet-card-body">
|
|
26
|
+
<Name className="item-heading">{pet.name}</Name>
|
|
27
|
+
<p>{details}</p>
|
|
28
|
+
{pet.location && <p className="muted">{pet.location}</p>}
|
|
29
|
+
</div>
|
|
30
|
+
</Link>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import Link from 'next/link'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { PetCard } from '@/components/site/PetCard'
|
|
5
|
+
import { AGE_GROUPS, SEXES, SIZES, STATUSES } from '@/lib/options'
|
|
6
|
+
import type { CatalogData } from '@/lib/queries'
|
|
7
|
+
|
|
8
|
+
// The pet catalogue: a filter form, one page of matching pets and Previous / Next links. Used by
|
|
9
|
+
// the Pet catalogue block on the Pets page. No hooks (blocks render on the server and in the
|
|
10
|
+
// editor), and the filters are a plain GET form to /pets, so every search lives in the URL and
|
|
11
|
+
// works without JavaScript.
|
|
12
|
+
|
|
13
|
+
export const CATALOG_PATH = '/pets'
|
|
14
|
+
|
|
15
|
+
function FilterSelect({
|
|
16
|
+
name,
|
|
17
|
+
label,
|
|
18
|
+
value,
|
|
19
|
+
options,
|
|
20
|
+
anyLabel,
|
|
21
|
+
}: {
|
|
22
|
+
name: string
|
|
23
|
+
label: string
|
|
24
|
+
value: string
|
|
25
|
+
options: readonly { label: string; value: string }[]
|
|
26
|
+
anyLabel: string
|
|
27
|
+
}) {
|
|
28
|
+
return (
|
|
29
|
+
<label className="filter">
|
|
30
|
+
<span>{label}</span>
|
|
31
|
+
<select name={name} defaultValue={value}>
|
|
32
|
+
<option value="">{anyLabel}</option>
|
|
33
|
+
{options.map((o) => (
|
|
34
|
+
<option key={o.value} value={o.value}>
|
|
35
|
+
{o.label}
|
|
36
|
+
</option>
|
|
37
|
+
))}
|
|
38
|
+
</select>
|
|
39
|
+
</label>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function PetCatalog({
|
|
44
|
+
catalog,
|
|
45
|
+
showFilters = true,
|
|
46
|
+
cardHeading = 'h3',
|
|
47
|
+
}: {
|
|
48
|
+
catalog: CatalogData
|
|
49
|
+
showFilters?: boolean
|
|
50
|
+
/** The pets' names are one level below the block's heading. */
|
|
51
|
+
cardHeading?: 'h2' | 'h3'
|
|
52
|
+
}) {
|
|
53
|
+
const { pets, filters, page, totalPages, hasPrevPage, hasNextPage, speciesOptions } = catalog
|
|
54
|
+
|
|
55
|
+
const linkFor = (target: number) => {
|
|
56
|
+
const qs = new URLSearchParams()
|
|
57
|
+
for (const key of ['species', 'sex', 'ageGroup', 'size', 'location'] as const) if (filters[key]) qs.set(key, filters[key])
|
|
58
|
+
qs.set('status', filters.status)
|
|
59
|
+
if (target > 1) qs.set('page', String(target))
|
|
60
|
+
return `${CATALOG_PATH}?${qs.toString()}`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
{showFilters ? (
|
|
66
|
+
<form className="filters" method="get" action={CATALOG_PATH}>
|
|
67
|
+
<FilterSelect name="species" label="Species" value={filters.species} options={speciesOptions} anyLabel="All" />
|
|
68
|
+
<FilterSelect name="ageGroup" label="Age" value={filters.ageGroup} options={AGE_GROUPS} anyLabel="Any" />
|
|
69
|
+
<FilterSelect name="sex" label="Sex" value={filters.sex} options={SEXES} anyLabel="Any" />
|
|
70
|
+
<FilterSelect name="size" label="Size" value={filters.size} options={SIZES} anyLabel="Any" />
|
|
71
|
+
<FilterSelect name="status" label="Status" value={filters.status} options={STATUSES} anyLabel="Any" />
|
|
72
|
+
<label className="filter">
|
|
73
|
+
<span>Location</span>
|
|
74
|
+
<input type="search" name="location" defaultValue={filters.location} placeholder="City or area" />
|
|
75
|
+
</label>
|
|
76
|
+
<button type="submit" className="btn btn-primary btn-small">
|
|
77
|
+
Apply
|
|
78
|
+
</button>
|
|
79
|
+
<Link href={CATALOG_PATH} className="link-more">
|
|
80
|
+
Reset
|
|
81
|
+
</Link>
|
|
82
|
+
</form>
|
|
83
|
+
) : null}
|
|
84
|
+
|
|
85
|
+
{pets.length ? (
|
|
86
|
+
<div className="pet-grid">
|
|
87
|
+
{pets.map((pet) => (
|
|
88
|
+
<PetCard key={pet.id} pet={pet} headingLevel={cardHeading} />
|
|
89
|
+
))}
|
|
90
|
+
</div>
|
|
91
|
+
) : (
|
|
92
|
+
<p className="muted empty">No pets match these filters. Try widening your search.</p>
|
|
93
|
+
)}
|
|
94
|
+
|
|
95
|
+
{totalPages > 1 && (
|
|
96
|
+
<nav className="pagination" aria-label="Pagination">
|
|
97
|
+
{hasPrevPage ? <Link href={linkFor(page - 1)}>Previous</Link> : <span />}
|
|
98
|
+
<span aria-current="page">
|
|
99
|
+
Page {page} of {totalPages}
|
|
100
|
+
</span>
|
|
101
|
+
{hasNextPage ? <Link href={linkFor(page + 1)}>Next</Link> : <span />}
|
|
102
|
+
</nav>
|
|
103
|
+
)}
|
|
104
|
+
</>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import Image from "next/image";
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Carousel,
|
|
8
|
+
CarouselContent,
|
|
9
|
+
CarouselItem,
|
|
10
|
+
CarouselNext,
|
|
11
|
+
CarouselPrevious,
|
|
12
|
+
} from "@pet-adopt/ui/components/carousel";
|
|
13
|
+
|
|
14
|
+
// The Pet gallery block (Pet page template): one large photo and a strip of thumbnails above or
|
|
15
|
+
// below it; choosing a thumbnail shows that photo large. The strip is shadcn's Carousel (Embla),
|
|
16
|
+
// styled by `.pet-gallery-*` rules in styles.css keyed to its `data-slot` attributes, because the
|
|
17
|
+
// page builder does not load Tailwind (see ImageCarousel).
|
|
18
|
+
//
|
|
19
|
+
// Accessibility: each thumbnail is a button named "Show photo N of M" with `aria-pressed` on the one
|
|
20
|
+
// shown, so keyboard and screen reader users choose photos the same way; the strip is a labelled
|
|
21
|
+
// region with Previous/Next buttons (and the arrow keys) when it scrolls.
|
|
22
|
+
|
|
23
|
+
export type GalleryPhoto = { url: string; alt: string };
|
|
24
|
+
|
|
25
|
+
export function PetGallery({
|
|
26
|
+
photos,
|
|
27
|
+
name,
|
|
28
|
+
thumbnails = "below",
|
|
29
|
+
}: {
|
|
30
|
+
photos: GalleryPhoto[];
|
|
31
|
+
name: string;
|
|
32
|
+
thumbnails?: "below" | "above";
|
|
33
|
+
}) {
|
|
34
|
+
const [shown, setShown] = useState(0);
|
|
35
|
+
if (photos.length === 0) return null;
|
|
36
|
+
const current = photos[Math.min(shown, photos.length - 1)];
|
|
37
|
+
const altOf = (photo: GalleryPhoto, index: number) => photo.alt || `${name} photo ${index + 1}`;
|
|
38
|
+
|
|
39
|
+
const main = (
|
|
40
|
+
<div className="pet-photo pet-gallery-main">
|
|
41
|
+
<Image src={current.url} alt={altOf(current, shown)} fill priority sizes="(max-width: 960px) 100vw, 960px" />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
if (photos.length === 1) return <div className="pet-gallery-block">{main}</div>;
|
|
45
|
+
|
|
46
|
+
const strip = (
|
|
47
|
+
<Carousel className="pet-gallery-strip" opts={{ align: "start", containScroll: "trimSnaps" }} aria-label={`Photos of ${name}`}>
|
|
48
|
+
<CarouselContent>
|
|
49
|
+
{photos.map((photo, index) => (
|
|
50
|
+
<CarouselItem key={`${photo.url}-${index}`}>
|
|
51
|
+
<button
|
|
52
|
+
type="button"
|
|
53
|
+
className="pet-gallery-thumb"
|
|
54
|
+
aria-pressed={index === shown}
|
|
55
|
+
aria-label={`Show photo ${index + 1} of ${photos.length}`}
|
|
56
|
+
onClick={() => setShown(index)}
|
|
57
|
+
>
|
|
58
|
+
<Image src={photo.url} alt="" fill sizes="160px" />
|
|
59
|
+
</button>
|
|
60
|
+
</CarouselItem>
|
|
61
|
+
))}
|
|
62
|
+
</CarouselContent>
|
|
63
|
+
<CarouselPrevious />
|
|
64
|
+
<CarouselNext />
|
|
65
|
+
</Carousel>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className="pet-gallery-block">
|
|
70
|
+
{thumbnails === "above" ? strip : null}
|
|
71
|
+
{main}
|
|
72
|
+
{thumbnails === "above" ? null : strip}
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import Image from 'next/image'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import type { TimelineAlignment, TimelineEntry } from '@/lib/pet-timeline'
|
|
5
|
+
|
|
6
|
+
import { RichText } from './RichText'
|
|
7
|
+
import { timelineDateTimeAttr, timelineWhenText } from './timeline-format'
|
|
8
|
+
|
|
9
|
+
// The Pet timeline block's drawing (src/puck/pet-page-config.tsx): a vertical line with a point per
|
|
10
|
+
// update. No hooks and no browser code: it renders on the server for visitors and in the editor.
|
|
11
|
+
// "Show all updates" is a <details> element, so it works without JavaScript.
|
|
12
|
+
//
|
|
13
|
+
// Layout (styles.css, `.timeline-*`): every entry says which side of it the line is on
|
|
14
|
+
// (`data-line`). Left: the line on the left of every entry, text left-aligned. Right: the line on the
|
|
15
|
+
// right, text right-aligned. Alternate: the line in the centre and entries taking turns, the first on
|
|
16
|
+
// the left half (line to its right, text right-aligned), the next on the right half (line to its
|
|
17
|
+
// left, text left-aligned); on narrow screens every entry falls back to the left layout.
|
|
18
|
+
|
|
19
|
+
export type PetTimelineProps = {
|
|
20
|
+
entries: TimelineEntry[]
|
|
21
|
+
align: TimelineAlignment
|
|
22
|
+
/** Entries shown before "Show all updates"; 0 shows them all. */
|
|
23
|
+
limit: number
|
|
24
|
+
showPhotos: boolean
|
|
25
|
+
showTime: boolean
|
|
26
|
+
/** The tag of each entry's title: one level below the block's heading. */
|
|
27
|
+
itemTag: 'h2' | 'h3'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function Entry({ entry, line, showPhotos, showTime, itemTag: Tag }: { entry: TimelineEntry; line: 'left' | 'right' } & Pick<PetTimelineProps, 'showPhotos' | 'showTime' | 'itemTag'>) {
|
|
31
|
+
const photos = showPhotos ? entry.photos : []
|
|
32
|
+
return (
|
|
33
|
+
<li className="timeline-entry" data-line={line}>
|
|
34
|
+
<span className="timeline-point" aria-hidden="true" />
|
|
35
|
+
<div className="timeline-content">
|
|
36
|
+
<time className="timeline-date" dateTime={timelineDateTimeAttr(entry, showTime)}>
|
|
37
|
+
{timelineWhenText(entry, showTime)}
|
|
38
|
+
</time>
|
|
39
|
+
<Tag className="item-heading timeline-title">{entry.title}</Tag>
|
|
40
|
+
{/* A rich-text document drawn as React elements (never HTML). */}
|
|
41
|
+
{entry.body ? <RichText doc={entry.body} className="timeline-body" /> : null}
|
|
42
|
+
{photos.length ? (
|
|
43
|
+
<ul className="timeline-photos">
|
|
44
|
+
{photos.map((photo, index) => (
|
|
45
|
+
<li key={`${photo.url}-${index}`}>
|
|
46
|
+
{/* The link opens the full image; its name is the photo's description. */}
|
|
47
|
+
<a href={photo.url} className="timeline-photo">
|
|
48
|
+
<Image src={photo.thumbnailUrl || photo.url} alt={photo.alt || `${entry.title}, photo ${index + 1}`} width={160} height={160} sizes="(max-width: 480px) 30vw, 120px" />
|
|
49
|
+
</a>
|
|
50
|
+
</li>
|
|
51
|
+
))}
|
|
52
|
+
</ul>
|
|
53
|
+
) : null}
|
|
54
|
+
</div>
|
|
55
|
+
</li>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function PetTimeline({ entries, align, limit, showPhotos, showTime, itemTag }: PetTimelineProps) {
|
|
60
|
+
const lineOf = (index: number): 'left' | 'right' => (align === 'right' ? 'right' : align === 'alternate' ? (index % 2 === 0 ? 'right' : 'left') : 'left')
|
|
61
|
+
const shown = limit > 0 ? entries.slice(0, limit) : entries
|
|
62
|
+
const rest = limit > 0 ? entries.slice(limit) : []
|
|
63
|
+
const draw = (entry: TimelineEntry, index: number) => (
|
|
64
|
+
<Entry key={entry.id} entry={entry} line={lineOf(index)} showPhotos={showPhotos} showTime={showTime} itemTag={itemTag} />
|
|
65
|
+
)
|
|
66
|
+
return (
|
|
67
|
+
<div className="timeline" data-align={align}>
|
|
68
|
+
<ol className="timeline-list">{shown.map((entry, index) => draw(entry, index))}</ol>
|
|
69
|
+
{rest.length ? (
|
|
70
|
+
<details className="timeline-more">
|
|
71
|
+
<summary className="timeline-more-toggle">
|
|
72
|
+
<span className="timeline-more-closed">
|
|
73
|
+
Show all updates ({rest.length} more)
|
|
74
|
+
</span>
|
|
75
|
+
<span className="timeline-more-open">Show fewer updates</span>
|
|
76
|
+
</summary>
|
|
77
|
+
<ol className="timeline-list">{rest.map((entry, index) => draw(entry, shown.length + index))}</ol>
|
|
78
|
+
</details>
|
|
79
|
+
) : null}
|
|
80
|
+
</div>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { usePathname } from 'next/navigation'
|
|
4
|
+
import React from 'react'
|
|
5
|
+
|
|
6
|
+
// With Cache Components on, Next keeps visited pages mounted but hidden (React <Activity>), so a page
|
|
7
|
+
// came back as it was left (a public form's "sent" message, a gallery's chosen photo). Keyed by the
|
|
8
|
+
// path, the page area is fresh on every navigation to another path, as before the switch. The path
|
|
9
|
+
// only, never the query string (the catalogue's filters keep their page). Same as the admin's
|
|
10
|
+
// RemountOnNavigate (src/components/admin), kept apart so the public site imports nothing from it.
|
|
11
|
+
export function RemountOnNavigate({ children }: { children: React.ReactNode }) {
|
|
12
|
+
return <React.Fragment key={usePathname()}>{children}</React.Fragment>
|
|
13
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Link from 'next/link'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
isAllowedHref,
|
|
6
|
+
isExternalHref,
|
|
7
|
+
type RichTextBlock,
|
|
8
|
+
type RichTextDoc,
|
|
9
|
+
type RichTextText,
|
|
10
|
+
} from '@/lib/rich-text'
|
|
11
|
+
|
|
12
|
+
// Renders a rich-text document (src/lib/rich-text.ts) as React elements, never as HTML, so nothing
|
|
13
|
+
// an owner types can inject markup. It draws only what the validator allows: paragraphs, bulleted
|
|
14
|
+
// and numbered lists, bold, italic, underline and links. A link is checked again here, so a bad
|
|
15
|
+
// address in stored data is shown as plain text instead of becoming a clickable link.
|
|
16
|
+
// No hooks and no browser code: it runs on the server for visitors.
|
|
17
|
+
|
|
18
|
+
function renderText(node: RichTextText, key: number) {
|
|
19
|
+
let out: React.ReactNode = node.text
|
|
20
|
+
for (const mark of node.marks ?? []) {
|
|
21
|
+
if (mark.type === 'bold') out = <strong>{out}</strong>
|
|
22
|
+
else if (mark.type === 'italic') out = <em>{out}</em>
|
|
23
|
+
else if (mark.type === 'underline') out = <u>{out}</u>
|
|
24
|
+
}
|
|
25
|
+
const link = node.marks?.find((mark) => mark.type === 'link')
|
|
26
|
+
if (link && link.type === 'link' && isAllowedHref(link.attrs.href)) {
|
|
27
|
+
const { href } = link.attrs
|
|
28
|
+
out = isExternalHref(href) ? (
|
|
29
|
+
<a href={href} rel="noopener noreferrer">
|
|
30
|
+
{out}
|
|
31
|
+
</a>
|
|
32
|
+
) : (
|
|
33
|
+
<Link href={href}>{out}</Link>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
return <React.Fragment key={key}>{out}</React.Fragment>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function renderBlock(block: RichTextBlock, key: number): React.ReactNode {
|
|
40
|
+
if (block.type === 'paragraph') {
|
|
41
|
+
return <p key={key}>{(block.content ?? []).map(renderText)}</p>
|
|
42
|
+
}
|
|
43
|
+
const List = block.type === 'bulletList' ? 'ul' : 'ol'
|
|
44
|
+
return (
|
|
45
|
+
<List key={key}>
|
|
46
|
+
{block.content.map((item, i) => (
|
|
47
|
+
<li key={i}>{item.content.map(renderBlock)}</li>
|
|
48
|
+
))}
|
|
49
|
+
</List>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function RichText({ doc, className }: { doc: RichTextDoc | null | undefined; className?: string }) {
|
|
54
|
+
if (!doc || doc.content.length === 0) return null
|
|
55
|
+
return <div className={className}>{doc.content.map(renderBlock)}</div>
|
|
56
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Link from 'next/link'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
|
|
4
|
+
import { isExternal, safeHref } from '@/lib/links'
|
|
5
|
+
|
|
6
|
+
export function SmartLink({
|
|
7
|
+
href,
|
|
8
|
+
className,
|
|
9
|
+
children,
|
|
10
|
+
}: {
|
|
11
|
+
href?: string | null
|
|
12
|
+
className?: string
|
|
13
|
+
children: React.ReactNode
|
|
14
|
+
}) {
|
|
15
|
+
const safe = safeHref(href)
|
|
16
|
+
// Mail and phone links hand off to an app: a new tab would only leave a blank one behind.
|
|
17
|
+
if (safe.startsWith('mailto:') || safe.startsWith('tel:')) {
|
|
18
|
+
return (
|
|
19
|
+
<a className={className} href={safe}>
|
|
20
|
+
{children}
|
|
21
|
+
</a>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
if (isExternal(safe)) {
|
|
25
|
+
return (
|
|
26
|
+
<a className={className} href={safe} target="_blank" rel="noopener noreferrer">
|
|
27
|
+
{children}
|
|
28
|
+
<span className="sr-only"> (opens in a new tab)</span>
|
|
29
|
+
</a>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
return (
|
|
33
|
+
<Link className={className} href={safe}>
|
|
34
|
+
{children}
|
|
35
|
+
</Link>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { safeHref } from '@/lib/links'
|
|
4
|
+
import { SOCIAL_PLATFORMS, labelFor } from '@/lib/options'
|
|
5
|
+
|
|
6
|
+
export type SocialLink = { platform: string; url: string }
|
|
7
|
+
|
|
8
|
+
export function SocialLinks({ items, className }: { items?: SocialLink[] | null; className?: string }) {
|
|
9
|
+
// safeHref turns anything unsafe (javascript:, data:...) into "#", which we then drop.
|
|
10
|
+
const links = (items ?? [])
|
|
11
|
+
.map((s) => ({ ...s, url: safeHref(s.url) }))
|
|
12
|
+
.filter((s) => s.url !== '#')
|
|
13
|
+
if (!links.length) return null
|
|
14
|
+
return (
|
|
15
|
+
<ul className={`social-links${className ? ` ${className}` : ''}`}>
|
|
16
|
+
{links.map((s, i) => (
|
|
17
|
+
<li key={`${s.platform}-${i}`}>
|
|
18
|
+
<a href={s.url} target="_blank" rel="noopener noreferrer">
|
|
19
|
+
{labelFor(SOCIAL_PLATFORMS, s.platform)}
|
|
20
|
+
<span className="sr-only"> (opens in a new tab)</span>
|
|
21
|
+
</a>
|
|
22
|
+
</li>
|
|
23
|
+
))}
|
|
24
|
+
</ul>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
/** The message the theme editor sends to its preview iframe. */
|
|
6
|
+
export type ThemePreviewMessage = { type: 'pet-adopt-theme-preview'; css: string; mode: 'light' | 'dark' }
|
|
7
|
+
|
|
8
|
+
// Inside the theme editor's preview iframe: applies the theme CSS the editor sends (built there by
|
|
9
|
+
// resolveTheme + themeCss from validated values), so the preview changes as the owner edits, with no
|
|
10
|
+
// reload. Only messages from this site are accepted, and the CSS is set as text, never as markup.
|
|
11
|
+
// On load it tells the editor it is ready, so the current draft is sent straight away.
|
|
12
|
+
export function ThemePreviewBridge() {
|
|
13
|
+
const styleRef = React.useRef<HTMLStyleElement>(null)
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
const onMessage = (event: MessageEvent) => {
|
|
17
|
+
if (event.origin !== window.location.origin) return
|
|
18
|
+
const data = event.data as Partial<ThemePreviewMessage> | null
|
|
19
|
+
if (!data || data.type !== 'pet-adopt-theme-preview' || typeof data.css !== 'string') return
|
|
20
|
+
if (styleRef.current) styleRef.current.textContent = data.css
|
|
21
|
+
document.documentElement.setAttribute('data-mode', data.mode === 'dark' ? 'dark' : 'light')
|
|
22
|
+
}
|
|
23
|
+
window.addEventListener('message', onMessage)
|
|
24
|
+
window.parent?.postMessage({ type: 'pet-adopt-theme-preview-ready' }, window.location.origin)
|
|
25
|
+
return () => window.removeEventListener('message', onMessage)
|
|
26
|
+
}, [])
|
|
27
|
+
|
|
28
|
+
return <style ref={styleRef} />
|
|
29
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { MODE_STORAGE_KEY, resolveTheme, themeCss, type ThemeSettings } from '@/lib/theme'
|
|
4
|
+
|
|
5
|
+
// Runs before the first paint so a visitor who chose dark does not see a flash of the light theme.
|
|
6
|
+
// A constant string: nothing from the settings goes into it.
|
|
7
|
+
export const PRE_PAINT = `(function(){try{var m=localStorage.getItem('${MODE_STORAGE_KEY}');if(m==='dark'||m==='light'){document.documentElement.setAttribute('data-mode',m)}}catch(e){}})()`
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Applies the site theme. Render it inside <head>. The CSS comes from themeCss, which only emits
|
|
11
|
+
* values that were validated against the preset lists or the hex pattern, so settings can never
|
|
12
|
+
* inject markup or rules.
|
|
13
|
+
*/
|
|
14
|
+
export function ThemeStyle({ settings, lightOnly = false }: { settings: ThemeSettings; lightOnly?: boolean }) {
|
|
15
|
+
const theme = resolveTheme(settings)
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<style dangerouslySetInnerHTML={{ __html: themeCss(theme, { lightOnly }) }} />
|
|
19
|
+
{theme.allowModeToggle && !lightOnly ? <script dangerouslySetInnerHTML={{ __html: PRE_PAINT }} /> : null}
|
|
20
|
+
</>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
import { useColorMode } from '@/lib/color-mode'
|
|
6
|
+
|
|
7
|
+
/** Light/dark switch for visitors. Their choice is kept in this browser only. */
|
|
8
|
+
export function ThemeToggle() {
|
|
9
|
+
// Shared with the admin's user menu (src/lib/color-mode.ts); null until the browser reads it.
|
|
10
|
+
const [mode, setMode] = useColorMode()
|
|
11
|
+
const toggle = () => setMode(mode === 'dark' ? 'light' : 'dark')
|
|
12
|
+
|
|
13
|
+
const dark = mode === 'dark'
|
|
14
|
+
return (
|
|
15
|
+
<button
|
|
16
|
+
type="button"
|
|
17
|
+
className="mode-toggle"
|
|
18
|
+
onClick={toggle}
|
|
19
|
+
disabled={mode === null}
|
|
20
|
+
aria-pressed={dark}
|
|
21
|
+
aria-label={dark ? 'Switch to light mode' : 'Switch to dark mode'}
|
|
22
|
+
title={dark ? 'Switch to light mode' : 'Switch to dark mode'}
|
|
23
|
+
>
|
|
24
|
+
{dark ? (
|
|
25
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" aria-hidden="true">
|
|
26
|
+
<circle cx="12" cy="12" r="4" />
|
|
27
|
+
<path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4" />
|
|
28
|
+
</svg>
|
|
29
|
+
) : (
|
|
30
|
+
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
|
|
31
|
+
<path d="M21 12.8A9 9 0 1 1 11.2 3a7 7 0 0 0 9.8 9.8z" />
|
|
32
|
+
</svg>
|
|
33
|
+
)}
|
|
34
|
+
</button>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import { buildWhatsAppUrl } from '@/lib/whatsapp'
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
phone?: string | null
|
|
7
|
+
message?: string | null
|
|
8
|
+
label?: string
|
|
9
|
+
variant?: 'primary' | 'outline'
|
|
10
|
+
className?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function WhatsAppButton({ phone, message, label = 'Chat on WhatsApp', variant = 'primary', className }: Props) {
|
|
14
|
+
const href = buildWhatsAppUrl(phone, message)
|
|
15
|
+
if (!href) return null
|
|
16
|
+
return (
|
|
17
|
+
<a
|
|
18
|
+
className={`btn btn-${variant}${className ? ` ${className}` : ''}`}
|
|
19
|
+
href={href}
|
|
20
|
+
target="_blank"
|
|
21
|
+
rel="noopener noreferrer"
|
|
22
|
+
>
|
|
23
|
+
{label}
|
|
24
|
+
<span className="sr-only"> (opens in a new tab)</span>
|
|
25
|
+
</a>
|
|
26
|
+
)
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { formatWhen } from '@pet-adopt/plugin-sdk'
|
|
2
|
+
|
|
3
|
+
import type { TimelineEntry } from '@/lib/pet-timeline'
|
|
4
|
+
|
|
5
|
+
// How a timeline entry's date and time are written, shared by the Pet timeline block and the admin's
|
|
6
|
+
// Timeline section. An entry stores a calendar day (YYYY-MM-DD) and an optional wall-clock time
|
|
7
|
+
// (HH:MM) that are already in the site's time zone: they are not instants. So the day is formatted
|
|
8
|
+
// as that day at midnight UTC in UTC (with the SDK's one fixed format), which never shifts it, and the
|
|
9
|
+
// time is shown as stored. Converting them with the site's time zone would move them a second time.
|
|
10
|
+
|
|
11
|
+
/** "28 November 2026" or "28 November 2026, 14:30" (`withTime` false drops the time). */
|
|
12
|
+
export function timelineWhenText(entry: Pick<TimelineEntry, 'date' | 'time'>, withTime = true, style: 'date' | 'longDate' = 'longDate'): string {
|
|
13
|
+
const day = formatWhen(`${entry.date}T00:00:00Z`, 'UTC', style) || entry.date
|
|
14
|
+
return withTime && entry.time ? `${day}, ${entry.time}` : day
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The `<time dateTime>` value: "2026-11-28" or "2026-11-28T14:30" (a local date and time). */
|
|
18
|
+
export function timelineDateTimeAttr(entry: Pick<TimelineEntry, 'date' | 'time'>, withTime = true): string {
|
|
19
|
+
return withTime && entry.time ? `${entry.date}T${entry.time}` : entry.date
|
|
20
|
+
}
|