tinyzoo 0.0.0-stage → 0.2.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 +10 -0
- package/README.md +46 -2
- package/app/app.config.ts +35 -0
- package/app/assets/brand/characters/bright/bird.svg +1 -0
- package/app/assets/brand/characters/bright/bunny.svg +1 -0
- package/app/assets/brand/characters/bright/elephant.svg +1 -0
- package/app/assets/brand/characters/bright/fox.svg +1 -0
- package/app/assets/brand/characters/bright/frog.svg +1 -0
- package/app/assets/brand/characters/bright/octopus.svg +1 -0
- package/app/assets/brand/characters/muted/bee.svg +1 -0
- package/app/assets/brand/characters/muted/bird.svg +1 -0
- package/app/assets/brand/characters/muted/butterfly.svg +1 -0
- package/app/assets/brand/characters/muted/chick.svg +1 -0
- package/app/assets/brand/characters/muted/cow.svg +1 -0
- package/app/assets/brand/characters/muted/deer.svg +1 -0
- package/app/assets/brand/characters/muted/duck.svg +1 -0
- package/app/assets/brand/characters/muted/elephant.svg +1 -0
- package/app/assets/brand/characters/muted/fox.svg +1 -0
- package/app/assets/brand/characters/muted/hedgehog.svg +1 -0
- package/app/assets/brand/characters/muted/koala.svg +1 -0
- package/app/assets/brand/characters/muted/ladybug.svg +1 -0
- package/app/assets/brand/characters/muted/lion.svg +1 -0
- package/app/assets/brand/characters/muted/mouse.svg +1 -0
- package/app/assets/brand/characters/muted/octopus.svg +1 -0
- package/app/assets/brand/characters/muted/owl.svg +1 -0
- package/app/assets/brand/characters/muted/panda.svg +1 -0
- package/app/assets/brand/characters/muted/penguin.svg +1 -0
- package/app/assets/brand/characters/muted/pig.svg +1 -0
- package/app/assets/brand/characters/muted/poodle.svg +1 -0
- package/app/assets/brand/characters/muted/raccoon.svg +1 -0
- package/app/assets/brand/characters/muted/seal.svg +1 -0
- package/app/assets/brand/characters/muted/sheep.svg +1 -0
- package/app/assets/brand/characters/muted/snail.svg +1 -0
- package/app/assets/brand/characters/muted/turtle.svg +1 -0
- package/app/assets/brand/characters/muted/whale.svg +1 -0
- package/app/assets/brand/logo/favicon.svg +1 -0
- package/app/assets/brand/logo/logo-primary-reversed.svg +1 -0
- package/app/assets/brand/logo/logo-primary.svg +1 -0
- package/app/assets/brand/logo/mascot-reversed.svg +1 -0
- package/app/assets/brand/logo/mascot.svg +1 -0
- package/app/assets/brand/logo/wordmark-reversed.svg +1 -0
- package/app/assets/brand/logo/wordmark.svg +1 -0
- package/app/assets/css/cms-admin.css +607 -0
- package/app/components/CmsBlocks.vue +30 -0
- package/app/components/CmsCell.vue +16 -0
- package/app/components/CmsCellBadge.vue +18 -0
- package/app/components/CmsCellBlocks.vue +9 -0
- package/app/components/CmsCellBoolean.vue +12 -0
- package/app/components/CmsCellCode.vue +7 -0
- package/app/components/CmsCellColor.vue +13 -0
- package/app/components/CmsCellDate.vue +10 -0
- package/app/components/CmsCellExcerpt.vue +21 -0
- package/app/components/CmsCellGallery.vue +10 -0
- package/app/components/CmsCellGroup.vue +23 -0
- package/app/components/CmsCellNumber.vue +7 -0
- package/app/components/CmsCellRelation.vue +8 -0
- package/app/components/CmsCellText.vue +12 -0
- package/app/components/CmsCellThumb.vue +18 -0
- package/app/components/CmsConfirmDialog.vue +55 -0
- package/app/components/CmsContent.vue +103 -0
- package/app/components/CmsDayPicker.vue +44 -0
- package/app/components/CmsEmptyState.vue +35 -0
- package/app/components/CmsField.vue +111 -0
- package/app/components/CmsFieldBlocks.vue +353 -0
- package/app/components/CmsFieldBoolean.vue +8 -0
- package/app/components/CmsFieldColor.vue +42 -0
- package/app/components/CmsFieldDate.vue +131 -0
- package/app/components/CmsFieldGallery.vue +114 -0
- package/app/components/CmsFieldGroup.vue +53 -0
- package/app/components/CmsFieldMedia.vue +219 -0
- package/app/components/CmsFieldNumber.vue +11 -0
- package/app/components/CmsFieldRelationMany.vue +54 -0
- package/app/components/CmsFieldRelationOne.vue +47 -0
- package/app/components/CmsFieldRichText.vue +45 -0
- package/app/components/CmsFieldSelect.vue +41 -0
- package/app/components/CmsFieldSlug.vue +46 -0
- package/app/components/CmsFieldText.vue +75 -0
- package/app/components/CmsFormSections.vue +150 -0
- package/app/components/CmsHighlight.vue +22 -0
- package/app/components/CmsImage.vue +39 -0
- package/app/components/CmsLinkPicker.vue +122 -0
- package/app/components/CmsLinkTarget.vue +35 -0
- package/app/components/CmsListFilters.vue +107 -0
- package/app/components/CmsLiveNotice.vue +64 -0
- package/app/components/CmsLoadError.vue +24 -0
- package/app/components/CmsMascot.vue +10 -0
- package/app/components/CmsMediaLibrary.vue +114 -0
- package/app/components/CmsMediaPreview.vue +34 -0
- package/app/components/CmsMediaThumb.vue +22 -0
- package/app/components/CmsMoment.vue +42 -0
- package/app/components/CmsNav.vue +39 -0
- package/app/components/CmsPage.vue +86 -0
- package/app/components/CmsPasswordInput.vue +22 -0
- package/app/components/CmsPresence.vue +29 -0
- package/app/components/CmsPreviewPanel.vue +131 -0
- package/app/components/CmsPublishReview.vue +102 -0
- package/app/components/CmsRevisions.vue +195 -0
- package/app/components/CmsRichTextEditor.vue +290 -0
- package/app/components/CmsSearch.vue +99 -0
- package/app/components/CmsSection.vue +20 -0
- package/app/components/CmsSingletonForm.vue +283 -0
- package/app/components/CmsStatusBadge.vue +21 -0
- package/app/components/CmsTime.vue +16 -0
- package/app/components/CmsTranslationRef.vue +27 -0
- package/app/components/CmsTreeList.vue +453 -0
- package/app/components/CmsUnsavedText.vue +34 -0
- package/app/components/CmsWordmark.vue +10 -0
- package/app/composables/useCmsAdminHead.ts +18 -0
- package/app/composables/useCmsCollab.ts +165 -0
- package/app/composables/useCmsConfirm.ts +39 -0
- package/app/composables/useCmsEntryActions.ts +75 -0
- package/app/composables/useCmsFocus.ts +13 -0
- package/app/composables/useCmsForm.ts +273 -0
- package/app/composables/useCmsI18n.ts +185 -0
- package/app/composables/useCmsLinkTargets.ts +84 -0
- package/app/composables/useCmsLive.ts +199 -0
- package/app/composables/useCmsSearch.ts +62 -0
- package/app/composables/useCmsSeo.ts +99 -0
- package/app/composables/useCmsSignedIn.ts +24 -0
- package/app/composables/useCmsUiLocale.ts +24 -0
- package/app/i18n/cs.ts +781 -0
- package/app/i18n/de.ts +781 -0
- package/app/i18n/en.ts +782 -0
- package/app/i18n/types.ts +22 -0
- package/app/layouts/admin.vue +224 -0
- package/app/layouts/cms-auth.vue +37 -0
- package/app/middleware/cms-api-not-a-page.global.ts +10 -0
- package/app/middleware/cms-auth.global.ts +16 -0
- package/app/pages/admin/[entity]/[id].vue +1109 -0
- package/app/pages/admin/[entity]/index.vue +733 -0
- package/app/pages/admin/account.vue +117 -0
- package/app/pages/admin/forgot.vue +50 -0
- package/app/pages/admin/index.vue +184 -0
- package/app/pages/admin/invite/[token].vue +73 -0
- package/app/pages/admin/login.vue +84 -0
- package/app/pages/admin/media.vue +494 -0
- package/app/pages/admin/privacy.vue +193 -0
- package/app/pages/admin/reset/[token].vue +52 -0
- package/app/pages/admin/setup.vue +87 -0
- package/app/pages/admin/styleguide.vue +261 -0
- package/app/pages/admin/team.vue +258 -0
- package/app/plugins/cmsLivePreview.client.ts +20 -0
- package/app/plugins/cmsSignedOut.client.ts +31 -0
- package/app/utils/cmsBlockType.ts +11 -0
- package/app/utils/cmsBrand.ts +38 -0
- package/app/utils/cmsDiff.ts +83 -0
- package/app/utils/cmsFetch.ts +7 -0
- package/app/utils/cmsFocusInvalid.ts +22 -0
- package/app/utils/cmsIssues.ts +128 -0
- package/app/utils/cmsJson.ts +28 -0
- package/app/utils/cmsMedia.ts +63 -0
- package/app/utils/cmsSections.ts +154 -0
- package/app/utils/cmsTime.ts +41 -0
- package/cli/backup.ts +713 -0
- package/cli/breaking.ts +174 -0
- package/cli/content-migrate.ts +239 -0
- package/cli/db.ts +86 -0
- package/cli/export.ts +336 -0
- package/cli/generate.ts +146 -0
- package/cli/import.ts +643 -0
- package/cli/index.ts +140 -0
- package/cli/links-convert.ts +291 -0
- package/cli/seed-engine.ts +705 -0
- package/cli/seed.ts +339 -0
- package/cli/status.ts +49 -0
- package/cli/tar.ts +304 -0
- package/cli/transfer.ts +677 -0
- package/cli/up.ts +27 -0
- package/cli/upgrade.ts +60 -0
- package/cli/versions.ts +60 -0
- package/forms/components/CmsForm.vue +186 -0
- package/forms/index.ts +203 -0
- package/forms/messages.ts +104 -0
- package/forms/retention.ts +48 -0
- package/forms/server/form.get.ts +12 -0
- package/forms/server/form.post.ts +109 -0
- package/forms/server/formSettings.ts +12 -0
- package/forms/server/forms.ts +127 -0
- package/module.ts +373 -0
- package/nuxt.config.ts +43 -0
- package/package.json +99 -3
- package/server/api/cms/[entity]/[id]/revisions/[rev].get.ts +19 -0
- package/server/api/cms/[entity]/[id]/revisions/index.get.ts +14 -0
- package/server/api/cms/[entity]/[id].delete.ts +52 -0
- package/server/api/cms/[entity]/[id].get.ts +21 -0
- package/server/api/cms/[entity]/[id].patch.ts +116 -0
- package/server/api/cms/[entity]/_export.get.ts +69 -0
- package/server/api/cms/[entity]/_move.post.ts +81 -0
- package/server/api/cms/[entity]/_order.post.ts +49 -0
- package/server/api/cms/[entity]/_tree.get.ts +41 -0
- package/server/api/cms/[entity]/index.get.ts +62 -0
- package/server/api/cms/[entity]/index.post.ts +38 -0
- package/server/api/cms/[entity]/options.get.ts +55 -0
- package/server/api/cms/_auth/accept.post.ts +33 -0
- package/server/api/cms/_auth/forgot.post.ts +39 -0
- package/server/api/cms/_auth/invite/[token].get.ts +18 -0
- package/server/api/cms/_auth/login.post.ts +42 -0
- package/server/api/cms/_auth/logout.post.ts +7 -0
- package/server/api/cms/_auth/me.get.ts +5 -0
- package/server/api/cms/_auth/me.patch.ts +32 -0
- package/server/api/cms/_auth/password.post.ts +29 -0
- package/server/api/cms/_auth/reset.post.ts +34 -0
- package/server/api/cms/_auth/setup.post.ts +46 -0
- package/server/api/cms/_auth/status.get.ts +18 -0
- package/server/api/cms/_collab/session.get.ts +30 -0
- package/server/api/cms/_collab/socket.ts +51 -0
- package/server/api/cms/_collab/unsaved.delete.ts +16 -0
- package/server/api/cms/_graph.get.ts +20 -0
- package/server/api/cms/_links/resolve.post.ts +17 -0
- package/server/api/cms/_links.get.ts +81 -0
- package/server/api/cms/_live.ts +30 -0
- package/server/api/cms/_media/[id]/usage.get.ts +14 -0
- package/server/api/cms/_media/[id].delete.ts +29 -0
- package/server/api/cms/_media/[id].get.ts +13 -0
- package/server/api/cms/_media/[id].patch.ts +64 -0
- package/server/api/cms/_media/exists.post.ts +15 -0
- package/server/api/cms/_media/img/[id]/[file].get.ts +42 -0
- package/server/api/cms/_media/index.get.ts +44 -0
- package/server/api/cms/_media/index.post.ts +147 -0
- package/server/api/cms/_media/raw/[...key].get.ts +85 -0
- package/server/api/cms/_media/raw/[...key].head.ts +2 -0
- package/server/api/cms/_overview.get.ts +87 -0
- package/server/api/cms/_preview.post.ts +17 -0
- package/server/api/cms/_privacy/delete.post.ts +14 -0
- package/server/api/cms/_privacy/export.post.ts +25 -0
- package/server/api/cms/_privacy/lookup.post.ts +27 -0
- package/server/api/cms/_search.get.ts +17 -0
- package/server/api/cms/_singleton/[name].get.ts +19 -0
- package/server/api/cms/_singleton/[name].put.ts +76 -0
- package/server/api/cms/_users/[id]/resend.post.ts +25 -0
- package/server/api/cms/_users/[id].delete.ts +21 -0
- package/server/api/cms/_users/[id].patch.ts +45 -0
- package/server/api/cms/_users/index.get.ts +28 -0
- package/server/api/cms/_users/index.post.ts +39 -0
- package/server/api/content/[entity]/[slug].get.ts +74 -0
- package/server/api/content/[entity]/index.get.ts +100 -0
- package/server/api/content/_global/[name].get.ts +23 -0
- package/server/api/content/_search.get.ts +28 -0
- package/server/api/content/_sitemap.get.ts +8 -0
- package/server/api/content/_tree/[entity].get.ts +31 -0
- package/server/api/content-types.ts.get.ts +17 -0
- package/server/api/health/live.get.ts +10 -0
- package/server/api/health/ready.get.ts +21 -0
- package/server/api/openapi.get.ts +48 -0
- package/server/api/openapi.json.get.ts +32 -0
- package/server/db/driver.ts +8 -0
- package/server/mail/mailer.ts +43 -0
- package/server/middleware/cms-0-headers.ts +37 -0
- package/server/middleware/cms-0-migrate-gate.ts +14 -0
- package/server/middleware/cms-csrf.ts +28 -0
- package/server/middleware/cms-limits.ts +20 -0
- package/server/middleware/cms-redirects.ts +21 -0
- package/server/middleware/cms-session.ts +41 -0
- package/server/middleware/cms-z-plugin-access.ts +15 -0
- package/server/plugins/cms-0-config-check.ts +35 -0
- package/server/plugins/cms-changes.ts +53 -0
- package/server/plugins/cms-content-etag.ts +21 -0
- package/server/plugins/cms-errors.ts +45 -0
- package/server/plugins/cms-migrate.ts +5 -0
- package/server/plugins/cms-plugins.ts +17 -0
- package/server/plugins/cms-search.ts +12 -0
- package/server/plugins/cms-setup-code.ts +15 -0
- package/server/routes/sitemap.xml.get.ts +25 -0
- package/server/store/redis.ts +95 -0
- package/server/store/types.ts +21 -0
- package/server/tasks/cms/retention.ts +10 -0
- package/server/tasks/cms/scheduled.ts +10 -0
- package/server/tasks/cms/search-reindex.ts +12 -0
- package/server/utils/cmsAudit.ts +29 -0
- package/server/utils/cmsAuth.ts +143 -0
- package/server/utils/cmsBlocks.ts +47 -0
- package/server/utils/cmsChanges.ts +222 -0
- package/server/utils/cmsCollab.ts +286 -0
- package/server/utils/cmsCollabServer.ts +451 -0
- package/server/utils/cmsCollate.ts +27 -0
- package/server/utils/cmsContent.ts +376 -0
- package/server/utils/cmsCrud.ts +361 -0
- package/server/utils/cmsCsv.ts +24 -0
- package/server/utils/cmsDb.ts +23 -0
- package/server/utils/cmsDemo.ts +36 -0
- package/server/utils/cmsEmails.ts +125 -0
- package/server/utils/cmsErrors.ts +40 -0
- package/server/utils/cmsFold.ts +17 -0
- package/server/utils/cmsImageSizes.ts +51 -0
- package/server/utils/cmsJson.ts +6 -0
- package/server/utils/cmsLinkAddress.ts +50 -0
- package/server/utils/cmsLinks.ts +248 -0
- package/server/utils/cmsListQuery.ts +93 -0
- package/server/utils/cmsLive.ts +392 -0
- package/server/utils/cmsLocales.ts +96 -0
- package/server/utils/cmsMail.ts +28 -0
- package/server/utils/cmsMediaGc.ts +188 -0
- package/server/utils/cmsMediaKeys.ts +62 -0
- package/server/utils/cmsMigrate.ts +86 -0
- package/server/utils/cmsPreviewDraft.ts +72 -0
- package/server/utils/cmsPrivacy.ts +176 -0
- package/server/utils/cmsPublished.ts +57 -0
- package/server/utils/cmsRange.ts +38 -0
- package/server/utils/cmsRateLimit.ts +82 -0
- package/server/utils/cmsRedirects.ts +160 -0
- package/server/utils/cmsRetention.ts +61 -0
- package/server/utils/cmsRevisions.ts +103 -0
- package/server/utils/cmsScheduler.ts +45 -0
- package/server/utils/cmsScrub.ts +107 -0
- package/server/utils/cmsSearch.ts +354 -0
- package/server/utils/cmsSession.ts +102 -0
- package/server/utils/cmsSetupCode.ts +97 -0
- package/server/utils/cmsSitemap.ts +176 -0
- package/server/utils/cmsStorage.ts +580 -0
- package/server/utils/cmsStore.ts +109 -0
- package/server/utils/cmsTooMany.ts +9 -0
- package/server/utils/cmsTranslationWrite.ts +186 -0
- package/server/utils/cmsTree.ts +251 -0
- package/server/utils/cmsTreeAddress.ts +65 -0
- package/server/utils/cmsUpload.ts +197 -0
- package/server/utils/cmsWebhooks.ts +101 -0
- package/shared/json.ts +11 -0
- package/shared/richtext-editor.ts +56 -0
- package/shared/richtext-normalize.ts +33 -0
- package/shared/richtext-paste.ts +151 -0
- package/shared/storage-delivery.ts +53 -0
- package/src/blocks.ts +624 -0
- package/src/changes.ts +54 -0
- package/src/content-shape.ts +340 -0
- package/src/deprecate.ts +64 -0
- package/src/descriptor.ts +149 -0
- package/src/docs.ts +27 -0
- package/src/emitter.ts +94 -0
- package/src/entity.ts +624 -0
- package/src/errorReport.ts +41 -0
- package/src/fields.ts +465 -0
- package/src/i18n.ts +26 -0
- package/src/index.ts +54 -0
- package/src/linkref.ts +31 -0
- package/src/links.ts +179 -0
- package/src/locales.ts +39 -0
- package/src/media.ts +48 -0
- package/src/migrate.ts +236 -0
- package/src/openapi.ts +377 -0
- package/src/paths.ts +88 -0
- package/src/plugin.ts +505 -0
- package/src/presets.ts +230 -0
- package/src/richtext.ts +88 -0
- package/src/sdk.ts +181 -0
- package/src/search.ts +312 -0
- package/src/seed.ts +225 -0
- package/src/setupCode.ts +30 -0
- package/src/system.ts +219 -0
- package/src/tree.ts +421 -0
- package/src/upgrades.ts +137 -0
- package/starter/.env.example +10 -0
- package/starter/README.md +65 -0
- package/starter/app/app.config.ts +10 -0
- package/starter/app/app.vue +12 -0
- package/starter/app/assets/css/main.css +15 -0
- package/starter/app/components/global/BlockContact.vue +15 -0
- package/starter/app/components/global/BlockCta.vue +15 -0
- package/starter/app/components/global/BlockHero.vue +23 -0
- package/starter/app/components/global/BlockImage.vue +13 -0
- package/starter/app/components/global/BlockText.vue +12 -0
- package/starter/app/composables/useSite.ts +77 -0
- package/starter/app/error.vue +28 -0
- package/starter/app/layouts/default.vue +106 -0
- package/starter/app/lib/cms-content.ts +152 -0
- package/starter/app/pages/[...slug].vue +66 -0
- package/starter/app/pages/hledat.vue +59 -0
- package/starter/app/pages/index.vue +20 -0
- package/starter/cms.config.ts +137 -0
- package/starter/compose.yaml +15 -0
- package/starter/drizzle.config.ts +8 -0
- package/starter/gitignore.txt +8 -0
- package/starter/nuxt.config.ts +13 -0
- package/starter/package.json +38 -0
- package/starter/scripts/typecheck.mjs +38 -0
- package/starter/seed/index.ts +297 -0
- package/starter/seed/media/about.jpg +0 -0
- package/starter/seed/media/hero.jpg +0 -0
- package/starter/seed/media/logo.png +0 -0
- package/starter/seed/media/news-bread.jpg +0 -0
- package/starter/seed/media/news-morning.jpg +0 -0
- package/starter/server/db/migrations/0000_init.sql +269 -0
- package/starter/server/db/migrations/0001_page_tree.sql +5 -0
- package/starter/server/db/migrations/0002_opening_hours_per_language.sql +1 -0
- package/starter/server/db/migrations/meta/0000_snapshot.json +1890 -0
- package/starter/server/db/migrations/meta/0001_snapshot.json +1887 -0
- package/starter/server/db/migrations/meta/0002_snapshot.json +1893 -0
- package/starter/server/db/migrations/meta/_journal.json +27 -0
- package/starter/server/db/schema.ts +253 -0
- package/starter/server/plugins/sitemap.ts +11 -0
- package/starter/server/routes/robots.txt.get.ts +12 -0
- package/starter/tsconfig.json +9 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A form as a few titled sections ("What is it?", "When?", "Where?") — see
|
|
3
|
+
// cmsFormSections for how they are chosen. Empty optional fields wait behind
|
|
4
|
+
// "+ Add …" until they are needed; `.group()` fields (e.g. "Search & sharing") fold
|
|
5
|
+
// away at the end with a one-line summary. Long forms get a section menu beside them.
|
|
6
|
+
//
|
|
7
|
+
// The page renders each field through the `field` slot (it owns the field's model,
|
|
8
|
+
// errors and translation hints); this component only decides where and whether.
|
|
9
|
+
import type { CmsSectionConfig } from '../utils/cmsSections'
|
|
10
|
+
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
fields: any[]
|
|
13
|
+
sections?: CmsSectionConfig[] | null
|
|
14
|
+
state: Record<string, any>
|
|
15
|
+
errors?: Record<string, any>
|
|
16
|
+
/** Put empty optional fields behind "+ Add …" (off for translations: everything there is to fill). */
|
|
17
|
+
disclose?: boolean
|
|
18
|
+
/** Allow the section menu (wide forms with room beside them). */
|
|
19
|
+
menu?: boolean
|
|
20
|
+
idPrefix?: string
|
|
21
|
+
}>()
|
|
22
|
+
|
|
23
|
+
const { t, tl, fieldLabel } = useCmsI18n()
|
|
24
|
+
const view = computed(() => cmsFormSections(props.fields, props.sections))
|
|
25
|
+
const showMenu = computed(() => !!props.menu && cmsNeedsSectionMenu(view.value))
|
|
26
|
+
const titleOf = (s: (typeof view.value)[number]) => (s.label != null ? tl(s.label as any) : s.kind ? t(`sections.${s.kind}`) : '')
|
|
27
|
+
const anchor = (id: string) => `cms-section-${props.idPrefix ?? ''}${id}`
|
|
28
|
+
|
|
29
|
+
// Fields once filled stay in view, even when emptied again.
|
|
30
|
+
const seen = reactive(new Set<string>())
|
|
31
|
+
watchEffect(() => {
|
|
32
|
+
for (const f of props.fields) if (!cmsIsEmpty(props.state[f.key])) seen.add(f.key)
|
|
33
|
+
})
|
|
34
|
+
const waiting = (s: (typeof view.value)[number]) => (props.disclose ? cmsWaitingFields(s, props.state, seen, props.errors ?? {}) : [])
|
|
35
|
+
const shown = (s: (typeof view.value)[number]) => {
|
|
36
|
+
const hide = new Set(waiting(s))
|
|
37
|
+
return s.fields.filter((f) => !hide.has(f.key))
|
|
38
|
+
}
|
|
39
|
+
const waitingFields = (s: (typeof view.value)[number]) => {
|
|
40
|
+
const hide = new Set(waiting(s))
|
|
41
|
+
return s.fields.filter((f) => hide.has(f.key))
|
|
42
|
+
}
|
|
43
|
+
async function add(key: string) {
|
|
44
|
+
seen.add(key)
|
|
45
|
+
await nextTick()
|
|
46
|
+
const el = document.getElementById(`cms-field-${props.idPrefix ?? ''}${key}`)
|
|
47
|
+
el?.focus()
|
|
48
|
+
el?.scrollIntoView({ block: 'nearest', behavior: 'smooth' })
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Folded groups: open by hand, or by themselves when a field inside has an error.
|
|
52
|
+
const openGroups = reactive<Record<string, boolean>>({})
|
|
53
|
+
watch(() => ({ ...(props.errors ?? {}) }), (errs) => {
|
|
54
|
+
for (const s of view.value) if (s.folded && s.fields.some((f) => errs[f.key])) openGroups[s.id] = true
|
|
55
|
+
})
|
|
56
|
+
const filledCount = (s: (typeof view.value)[number]) => s.fields.filter((f) => !cmsIsEmpty(props.state[f.key])).length
|
|
57
|
+
|
|
58
|
+
// The section menu follows the scroll.
|
|
59
|
+
const active = ref<string | null>(null)
|
|
60
|
+
let observer: IntersectionObserver | null = null
|
|
61
|
+
// After a jump the scroll may stop short of the section (the end of the page): the
|
|
62
|
+
// menu keeps what was chosen until the scrolling is over.
|
|
63
|
+
let chosenUntil = 0
|
|
64
|
+
function observe() {
|
|
65
|
+
observer?.disconnect()
|
|
66
|
+
if (!showMenu.value || typeof IntersectionObserver === 'undefined') return
|
|
67
|
+
observer = new IntersectionObserver((entries) => {
|
|
68
|
+
if (Date.now() < chosenUntil) return
|
|
69
|
+
const hit = entries.filter((e) => e.isIntersecting).sort((a, b) => a.boundingClientRect.top - b.boundingClientRect.top)[0]
|
|
70
|
+
if (hit) active.value = hit.target.id
|
|
71
|
+
}, { rootMargin: '-15% 0px -65% 0px' })
|
|
72
|
+
for (const s of view.value) {
|
|
73
|
+
const el = document.getElementById(anchor(s.id))
|
|
74
|
+
if (el) observer.observe(el)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
onMounted(observe)
|
|
78
|
+
watch(showMenu, () => nextTick(observe))
|
|
79
|
+
onBeforeUnmount(() => observer?.disconnect())
|
|
80
|
+
function jump(id: string) {
|
|
81
|
+
const s = view.value.find((x) => x.id === id)
|
|
82
|
+
if (s?.folded) openGroups[s.id] = true
|
|
83
|
+
chosenUntil = Date.now() + 1000
|
|
84
|
+
document.getElementById(anchor(id))?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
|
85
|
+
active.value = anchor(id)
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<template>
|
|
90
|
+
<div class="cms-form" :class="showMenu ? 'cms-form--menu' : ''">
|
|
91
|
+
<nav v-if="showMenu" class="cms-form__menu" :aria-label="t('sections.menu')">
|
|
92
|
+
<ul>
|
|
93
|
+
<li v-for="s in view" :key="s.id">
|
|
94
|
+
<button
|
|
95
|
+
v-if="s.label != null || s.kind" type="button" class="cms-form__menu-item"
|
|
96
|
+
:aria-current="active === anchor(s.id) ? 'true' : undefined" @click="jump(s.id)"
|
|
97
|
+
>
|
|
98
|
+
<UIcon v-if="s.icon" :name="s.icon" class="size-4 shrink-0 mt-0.5" />
|
|
99
|
+
<span class="min-w-0 leading-snug text-pretty">{{ titleOf(s) }}</span>
|
|
100
|
+
</button>
|
|
101
|
+
</li>
|
|
102
|
+
</ul>
|
|
103
|
+
</nav>
|
|
104
|
+
|
|
105
|
+
<div class="cms-form__body">
|
|
106
|
+
<div v-if="$slots.top" class="cms-form__top"><slot name="top" /></div>
|
|
107
|
+
<template v-for="s in view" :key="s.id">
|
|
108
|
+
<!-- a folded group: a quiet row that opens -->
|
|
109
|
+
<UCollapsible v-if="s.folded" :id="anchor(s.id)" v-model:open="openGroups[s.id]" class="cms-section cms-section--folded">
|
|
110
|
+
<button type="button" class="group cms-section__head w-full text-left">
|
|
111
|
+
<span class="cms-section__tile"><UIcon :name="s.icon ?? 'i-lucide-sliders-horizontal'" class="size-4" /></span>
|
|
112
|
+
<span class="min-w-0 flex-1">
|
|
113
|
+
<span class="cms-section__title block">{{ titleOf(s) }}</span>
|
|
114
|
+
<span class="block text-sm text-muted">
|
|
115
|
+
{{ filledCount(s) ? t('sections.filled', { n: filledCount(s), total: s.fields.length }) : t('sections.automatic') }}
|
|
116
|
+
</span>
|
|
117
|
+
</span>
|
|
118
|
+
<UIcon name="i-lucide-chevron-down" class="size-4 text-dimmed shrink-0 transition-transform group-data-[state=open]:rotate-180" />
|
|
119
|
+
</button>
|
|
120
|
+
<template #content>
|
|
121
|
+
<div class="cms-section__fields pt-5">
|
|
122
|
+
<div v-for="f in s.fields" :key="f.key"><slot name="field" :field="f" /></div>
|
|
123
|
+
</div>
|
|
124
|
+
</template>
|
|
125
|
+
</UCollapsible>
|
|
126
|
+
|
|
127
|
+
<section v-else :id="anchor(s.id)" class="cms-section" :aria-labelledby="(s.label != null || s.kind) ? `${anchor(s.id)}-title` : undefined">
|
|
128
|
+
<header v-if="s.label != null || s.kind" class="cms-section__head">
|
|
129
|
+
<span v-if="s.icon" class="cms-section__tile"><UIcon :name="s.icon" class="size-4" /></span>
|
|
130
|
+
<div class="min-w-0">
|
|
131
|
+
<h2 :id="`${anchor(s.id)}-title`" class="cms-section__title">{{ titleOf(s) }}</h2>
|
|
132
|
+
<p v-if="s.description" class="text-sm text-muted text-pretty">{{ tl(s.description as any) }}</p>
|
|
133
|
+
</div>
|
|
134
|
+
</header>
|
|
135
|
+
<div class="cms-section__fields" :class="s.columns === 2 ? 'cms-section__fields--2' : ''">
|
|
136
|
+
<div v-for="f in shown(s)" :key="f.key" :class="s.columns === 2 && !cmsIsShortField(f) ? 'cms-section__wide' : ''">
|
|
137
|
+
<slot name="field" :field="f" />
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
<div v-if="waitingFields(s).length" class="cms-section__add">
|
|
141
|
+
<UButton
|
|
142
|
+
v-for="f in waitingFields(s)" :key="f.key" size="sm" color="neutral" variant="outline" icon="i-lucide-plus"
|
|
143
|
+
class="border-dashed ring-0 border border-accented text-muted hover:text-highlighted" @click="add(f.key)"
|
|
144
|
+
>{{ fieldLabel(f) }}</UButton>
|
|
145
|
+
</div>
|
|
146
|
+
</section>
|
|
147
|
+
</template>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
</template>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Text with the searched words marked: <CmsHighlight :text="r.excerpt" :ranges="r.highlights" />
|
|
3
|
+
// renders <mark> around each [start, end) range (as the search API returns them).
|
|
4
|
+
const props = defineProps<{ text: string; ranges?: [number, number][] | null }>()
|
|
5
|
+
const parts = computed(() => {
|
|
6
|
+
const out: { text: string; mark: boolean }[] = []
|
|
7
|
+
let at = 0
|
|
8
|
+
const ranges = [...(props.ranges ?? [])].sort((a, b) => a[0] - b[0])
|
|
9
|
+
for (const [s, e] of ranges) {
|
|
10
|
+
if (s < at || e <= s || e > props.text.length) continue
|
|
11
|
+
if (s > at) out.push({ text: props.text.slice(at, s), mark: false })
|
|
12
|
+
out.push({ text: props.text.slice(s, e), mark: true })
|
|
13
|
+
at = e
|
|
14
|
+
}
|
|
15
|
+
if (at < props.text.length) out.push({ text: props.text.slice(at), mark: false })
|
|
16
|
+
return out
|
|
17
|
+
})
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<span><template v-for="(p, i) in parts" :key="i"><mark v-if="p.mark">{{ p.text }}</mark><template v-else>{{ p.text }}</template></template></span>
|
|
22
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A picture from the CMS on the website: its description as alt text, its real size
|
|
3
|
+
// (no layout jump), lazy loading, smaller copies for smaller screens (srcset: the
|
|
4
|
+
// browser downloads the one that fits), and the focal point the editor set, so a
|
|
5
|
+
// cropped picture (object-fit: cover) keeps what matters in view.
|
|
6
|
+
//
|
|
7
|
+
// <CmsImage :media="post.hero" class="aspect-video w-full object-cover" />
|
|
8
|
+
// <CmsImage :media="post.hero" eager sizes="100vw" /> // the page's main picture
|
|
9
|
+
// <CmsImage :media="card.image" sizes="(min-width: 768px) 20rem, 100vw" /> // say how wide it shows
|
|
10
|
+
const props = defineProps<{
|
|
11
|
+
media: { id?: string; url: string; alt?: string | null; width?: number | null; height?: number | null; mime?: string | null; focal?: { x: number; y: number } | null } | null | undefined
|
|
12
|
+
/** Load now (the first picture on the page); otherwise lazily. */
|
|
13
|
+
eager?: boolean
|
|
14
|
+
/** How wide the picture shows (CSS sizes), so the browser picks the right copy. Default: the full screen width. */
|
|
15
|
+
sizes?: string
|
|
16
|
+
/** Override the stored description (e.g. '' for a purely decorative picture). */
|
|
17
|
+
alt?: string
|
|
18
|
+
}>()
|
|
19
|
+
const style = computed(() => (props.media?.focal ? { objectPosition: `${props.media.focal.x}% ${props.media.focal.y}%` } : undefined))
|
|
20
|
+
|
|
21
|
+
// The widths the CMS makes smaller copies at (server/utils/cmsImageSizes.ts).
|
|
22
|
+
const WIDTHS = [320, 640, 960, 1280, 1920]
|
|
23
|
+
const RESIZABLE = new Set(['image/jpeg', 'image/png', 'image/webp', 'image/avif'])
|
|
24
|
+
const srcset = computed(() => {
|
|
25
|
+
const m = props.media
|
|
26
|
+
if (!m?.id || !m.width || !m.mime || !RESIZABLE.has(m.mime)) return undefined
|
|
27
|
+
const smaller = WIDTHS.filter((w) => w < m.width!)
|
|
28
|
+
if (!smaller.length) return undefined
|
|
29
|
+
return [...smaller.map((w) => `/api/cms/_media/img/${m.id}/${w}.webp ${w}w`), `${m.url} ${m.width}w`].join(', ')
|
|
30
|
+
})
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<template>
|
|
34
|
+
<img
|
|
35
|
+
v-if="media?.url" :src="media.url" :srcset="srcset" :alt="alt ?? media.alt ?? ''"
|
|
36
|
+
:width="media.width || undefined" :height="media.height || undefined" :sizes="srcset ? (sizes ?? '100vw') : sizes"
|
|
37
|
+
:loading="eager ? 'eager' : 'lazy'" :fetchpriority="eager ? 'high' : undefined" decoding="async" :style="style"
|
|
38
|
+
>
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { isLinkRef } from '../../src/linkref'
|
|
3
|
+
// Pick what a link points to: a page or entry of this website (found by its title,
|
|
4
|
+
// with its address in the language being edited), or an address typed or pasted
|
|
5
|
+
// into the box. An inline panel: rich text, menus and link fields put it in their
|
|
6
|
+
// own popover. A picked entry is emitted as a reference (`cms:<entity>/<id>`), so the
|
|
7
|
+
// link follows the page when its address changes, together with its title; with
|
|
8
|
+
// `refs` off (an address field, not a link) as its address. A typed address is
|
|
9
|
+
// emitted as typed.
|
|
10
|
+
const props = withDefaults(defineProps<{ initial?: string | null; locale?: string | null; refs?: boolean }>(), { refs: true })
|
|
11
|
+
const emit = defineEmits<{ pick: [href: string, title?: string] }>()
|
|
12
|
+
const { t, entityLabel } = useCmsI18n()
|
|
13
|
+
const route = useRoute()
|
|
14
|
+
const { seed } = useCmsLinkTargets()
|
|
15
|
+
const graph = useNuxtData<any[]>('cms-graph').data
|
|
16
|
+
|
|
17
|
+
// A stored reference is not something to search for.
|
|
18
|
+
const term = ref(props.initial && !isLinkRef(props.initial) ? props.initial : '')
|
|
19
|
+
const items = ref<{ entity: string; id: string; ref: string; title: string; path: string; published: boolean }[]>([])
|
|
20
|
+
const loading = ref(false)
|
|
21
|
+
const active = ref(0)
|
|
22
|
+
const input = ref<any>(null)
|
|
23
|
+
|
|
24
|
+
let seq = 0
|
|
25
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
26
|
+
async function load() {
|
|
27
|
+
const my = ++seq
|
|
28
|
+
loading.value = true
|
|
29
|
+
try {
|
|
30
|
+
const locale = props.locale ?? (typeof route.query.locale === 'string' ? route.query.locale : undefined)
|
|
31
|
+
// A path ("/o-nas") is searched too (as an address of one of our pages); another address is not a search.
|
|
32
|
+
const q = term.value.trim().startsWith('/') ? term.value.trim() : looksLikeAddress(term.value) ? undefined : term.value.trim() || undefined
|
|
33
|
+
const res = await cmsFetch<{ items: typeof items.value }>('/api/cms/_links', { query: { q, locale } })
|
|
34
|
+
if (my === seq) items.value = res.items
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
if (my === seq) items.value = []
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
if (my === seq) loading.value = false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
watch(term, () => {
|
|
44
|
+
clearTimeout(timer)
|
|
45
|
+
active.value = 0
|
|
46
|
+
timer = setTimeout(load, 180)
|
|
47
|
+
})
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
load()
|
|
50
|
+
nextTick(() => input.value?.inputRef?.focus?.())
|
|
51
|
+
})
|
|
52
|
+
onBeforeUnmount(() => clearTimeout(timer))
|
|
53
|
+
|
|
54
|
+
/** An address, not a search: /page, https://…, mailto:, tel:, #anchor, or a bare domain. */
|
|
55
|
+
function looksLikeAddress(v: string): boolean {
|
|
56
|
+
const s = v.trim()
|
|
57
|
+
return /^(\/|#|https?:\/\/|mailto:|tel:)/i.test(s) || /^[\w-]+(\.[\w-]+)+(\/\S*)?$/.test(s)
|
|
58
|
+
}
|
|
59
|
+
const typed = computed(() => {
|
|
60
|
+
const s = term.value.trim()
|
|
61
|
+
if (!s || !looksLikeAddress(s)) return null
|
|
62
|
+
return /^[\w-]+(\.[\w-]+)+(\/\S*)?$/.test(s) && !s.includes('@') ? `https://${s}` : s
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
type Option = { key: string; label: string; hint?: string; badge?: string; icon: string; href: string; title?: string; picked?: { ref: string; entity: string; id: string; path: string; published: boolean } }
|
|
66
|
+
const options = computed<Option[]>(() => {
|
|
67
|
+
const out: Option[] = []
|
|
68
|
+
if (typed.value) out.push({ key: 'typed', label: t('link.typed', { url: typed.value }), icon: 'i-lucide-corner-down-left', href: typed.value })
|
|
69
|
+
for (const it of items.value) {
|
|
70
|
+
const meta = graph.value?.find((e: any) => e.name === it.entity)
|
|
71
|
+
out.push({
|
|
72
|
+
key: `${it.entity}:${it.id}`, label: it.title || it.path, hint: `${meta ? entityLabel(meta) : it.entity} · ${it.path}`,
|
|
73
|
+
badge: it.published ? undefined : t('link.draft'), icon: meta?.icon ?? 'i-lucide-file', href: props.refs ? it.ref : it.path, title: it.title,
|
|
74
|
+
picked: { ref: it.ref, entity: it.entity, id: it.id, path: it.path, published: it.published },
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
return out
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
function choose(o: Option | undefined) {
|
|
81
|
+
if (!o) return
|
|
82
|
+
// The editor sees this page's title and address next to the link straight away.
|
|
83
|
+
if (props.refs && o.picked) seed(o.picked.ref, { entity: o.picked.entity, id: o.picked.id, title: o.title ?? '', path: o.picked.path, state: o.picked.published ? 'live' : 'draft' }, props.locale ?? (typeof route.query.locale === 'string' ? route.query.locale : null))
|
|
84
|
+
emit('pick', o.href, o.title)
|
|
85
|
+
}
|
|
86
|
+
function onKey(e: KeyboardEvent) {
|
|
87
|
+
const n = options.value.length
|
|
88
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); active.value = n ? (active.value + 1) % n : 0 }
|
|
89
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); active.value = n ? (active.value - 1 + n) % n : 0 }
|
|
90
|
+
else if (e.key === 'Enter') { e.preventDefault(); choose(options.value[active.value]) }
|
|
91
|
+
}
|
|
92
|
+
const listId = useId()
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<template>
|
|
96
|
+
<div class="w-[min(26rem,calc(100vw-2rem))]">
|
|
97
|
+
<div class="p-2 border-b border-default">
|
|
98
|
+
<UInput
|
|
99
|
+
ref="input" v-model="term" :placeholder="t('link.search')" icon="i-lucide-search" :loading="loading"
|
|
100
|
+
class="w-full" autocomplete="off" role="combobox" :aria-expanded="true" :aria-controls="listId"
|
|
101
|
+
:aria-activedescendant="options[active] ? `${listId}-${active}` : undefined" :aria-label="t('link.search')"
|
|
102
|
+
@keydown="onKey"
|
|
103
|
+
/>
|
|
104
|
+
</div>
|
|
105
|
+
<ul :id="listId" role="listbox" :aria-label="t('link.onSite')" class="max-h-72 overflow-y-auto p-1">
|
|
106
|
+
<li
|
|
107
|
+
v-for="(o, i) in options" :id="`${listId}-${i}`" :key="o.key" role="option" :aria-selected="i === active"
|
|
108
|
+
class="flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5"
|
|
109
|
+
:class="i === active ? 'bg-elevated' : 'hover:bg-elevated/60'"
|
|
110
|
+
@mouseenter="active = i" @mousedown.prevent @click="choose(o)"
|
|
111
|
+
>
|
|
112
|
+
<UIcon :name="o.icon" class="size-4 shrink-0 text-muted" />
|
|
113
|
+
<span class="min-w-0 flex-1">
|
|
114
|
+
<span class="block truncate text-sm text-highlighted">{{ o.label }}</span>
|
|
115
|
+
<span v-if="o.hint" class="block truncate text-xs text-muted font-mono">{{ o.hint }}</span>
|
|
116
|
+
</span>
|
|
117
|
+
<UBadge v-if="o.badge" color="neutral" variant="soft" size="sm" class="shrink-0">{{ o.badge }}</UBadge>
|
|
118
|
+
</li>
|
|
119
|
+
<li v-if="!options.length && !loading" class="px-2 py-3 text-sm text-muted text-pretty">{{ t('link.none') }}</li>
|
|
120
|
+
</ul>
|
|
121
|
+
</div>
|
|
122
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// What a stored link points at: the page's title and address, and a warning when
|
|
3
|
+
// visitors will not get there (the page is not published yet, or is gone). The link
|
|
4
|
+
// follows the page — rename it and the link keeps working — and this says which page
|
|
5
|
+
// that is, instead of showing the reference.
|
|
6
|
+
const props = defineProps<{ value: string; compact?: boolean }>()
|
|
7
|
+
const { t, entityLabel } = useCmsI18n()
|
|
8
|
+
const target = useCmsLinkTarget(() => props.value)
|
|
9
|
+
const graph = useNuxtData<any[]>('cms-graph').data
|
|
10
|
+
const meta = computed(() => graph.value?.find((e: any) => e.name === target.value?.entity))
|
|
11
|
+
const icon = computed(() => (target.value?.state === 'missing' ? 'i-lucide-link-2-off' : meta.value?.icon ?? 'i-lucide-file'))
|
|
12
|
+
const warning = computed(() => {
|
|
13
|
+
const s = target.value?.state
|
|
14
|
+
return s === 'draft' ? t('link.targetDraft') : s === 'missing' ? t('link.targetMissing') : null
|
|
15
|
+
})
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<span class="flex min-w-0 items-center gap-2.5" data-cms-link-target :data-state="target?.state ?? 'unknown'">
|
|
20
|
+
<UIcon :name="icon" class="size-4 shrink-0" :class="target?.state === 'missing' ? 'text-error' : 'text-muted'" />
|
|
21
|
+
<span class="min-w-0 flex-1">
|
|
22
|
+
<span class="block truncate text-sm" :class="target?.state === 'missing' ? 'text-error' : 'text-highlighted'">
|
|
23
|
+
<template v-if="!target">…</template>
|
|
24
|
+
<template v-else-if="target.state === 'missing'">{{ t('link.missingTitle') }}</template>
|
|
25
|
+
<template v-else>{{ target.title || target.path }}</template>
|
|
26
|
+
</span>
|
|
27
|
+
<span v-if="target && target.path && target.state !== 'missing'" class="block truncate font-mono text-xs text-muted">
|
|
28
|
+
<template v-if="meta && !compact">{{ entityLabel(meta) }} · </template>{{ target.path }}
|
|
29
|
+
</span>
|
|
30
|
+
<span v-if="warning" class="mt-0.5 flex items-start gap-1 text-xs text-pretty" :class="target?.state === 'missing' ? 'text-error' : 'text-warning'" role="status">
|
|
31
|
+
<UIcon name="i-lucide-triangle-alert" class="mt-px size-3.5 shrink-0" />{{ warning }}
|
|
32
|
+
</span>
|
|
33
|
+
</span>
|
|
34
|
+
</span>
|
|
35
|
+
</template>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// The list's filters: one quiet "Filter" button opening a panel with a control per
|
|
3
|
+
// filterable field, and the active filters as removable chips. The value is the
|
|
4
|
+
// query the list endpoint reads: { 'filter.<field>': value, 'filter.<field>.from': … }.
|
|
5
|
+
const props = defineProps<{ fields: any[] }>()
|
|
6
|
+
const model = defineModel<Record<string, string>>({ default: () => ({}) })
|
|
7
|
+
const { t, tl, fieldLabel, formatDate } = useCmsI18n()
|
|
8
|
+
|
|
9
|
+
const set = (param: string, value: string | null | undefined) => {
|
|
10
|
+
const next = { ...model.value }
|
|
11
|
+
if (value) next[param] = value
|
|
12
|
+
else delete next[param]
|
|
13
|
+
model.value = next
|
|
14
|
+
}
|
|
15
|
+
const optionLabel = (f: any, v: string) => tl(f.meta?.labels?.[v], v)
|
|
16
|
+
|
|
17
|
+
// Related entries: fetched once per field, with labels for chips.
|
|
18
|
+
const relationOptions = reactive<Record<string, { id: string; label: string }[]>>({})
|
|
19
|
+
async function loadRelation(f: any) {
|
|
20
|
+
if (relationOptions[f.key]) return
|
|
21
|
+
const selected = model.value[`filter.${f.key}`]
|
|
22
|
+
relationOptions[f.key] = await cmsFetch<any[]>(`/api/cms/${f.relation.to}/options`, { query: selected ? { selected } : {} }).catch(() => [])
|
|
23
|
+
}
|
|
24
|
+
watch(() => props.fields, (fs) => { for (const f of fs) if (f.relation && model.value[`filter.${f.key}`]) loadRelation(f) }, { immediate: true })
|
|
25
|
+
|
|
26
|
+
const chips = computed(() => {
|
|
27
|
+
const out: { param: string; label: string }[] = []
|
|
28
|
+
for (const f of props.fields) {
|
|
29
|
+
const v = model.value[`filter.${f.key}`]
|
|
30
|
+
const name = fieldLabel(f)
|
|
31
|
+
if (v) {
|
|
32
|
+
let shown = v
|
|
33
|
+
if (f.type === 'select') shown = v.split(',').map((x) => optionLabel(f, x)).join(', ')
|
|
34
|
+
else if (f.type === 'boolean') shown = v === 'true' ? t('fields.yes') : t('fields.no')
|
|
35
|
+
else if (f.type === 'media') shown = v === 'yes' ? t('list.filterHas') : t('list.filterHasNot')
|
|
36
|
+
else if (f.relation) shown = relationOptions[f.key]?.find((o) => o.id === v)?.label ?? '…'
|
|
37
|
+
out.push({ param: `filter.${f.key}`, label: `${name}: ${shown}` })
|
|
38
|
+
}
|
|
39
|
+
for (const part of ['from', 'to'] as const) {
|
|
40
|
+
const d = model.value[`filter.${f.key}.${part}`]
|
|
41
|
+
if (d) out.push({ param: `filter.${f.key}.${part}`, label: `${name} ${t(part === 'from' ? 'list.filterFrom' : 'list.filterTo')} ${formatDate(d, { time: false })}` })
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out
|
|
45
|
+
})
|
|
46
|
+
const count = computed(() => chips.value.length)
|
|
47
|
+
// Days in the admin's time zone (cms.admin.timeZone), sent as exact instants: from the
|
|
48
|
+
// day's first minute to its last.
|
|
49
|
+
const config = useCmsAdminConfig()
|
|
50
|
+
const dateValue = (param: string) => toZonedInput(model.value[param], config.value.timeZone).slice(0, 10)
|
|
51
|
+
const setDate = (param: string, v: string, part: 'from' | 'to') => {
|
|
52
|
+
if (!v) return set(param, null)
|
|
53
|
+
const at = fromZonedInput(`${v}T${part === 'from' ? '00:00' : '23:59'}`, config.value.timeZone)
|
|
54
|
+
if (!at) return set(param, null)
|
|
55
|
+
set(param, part === 'to' ? new Date(new Date(at).getTime() + 59_999).toISOString() : at)
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
61
|
+
<UPopover :content="{ align: 'start' }">
|
|
62
|
+
<UButton color="neutral" variant="ghost" size="sm" icon="i-lucide-list-filter">
|
|
63
|
+
{{ t('list.filter') }}<span v-if="count" class="ml-1 tabular-nums text-muted">{{ count }}</span>
|
|
64
|
+
</UButton>
|
|
65
|
+
<template #content>
|
|
66
|
+
<div class="w-72 space-y-4 p-4">
|
|
67
|
+
<div v-for="f in fields" :key="f.key" class="space-y-1.5">
|
|
68
|
+
<p class="text-xs font-medium text-muted">{{ fieldLabel(f) }}</p>
|
|
69
|
+
<USelect
|
|
70
|
+
v-if="f.type === 'select'" :model-value="model[`filter.${f.key}`] || undefined" class="w-full" size="sm"
|
|
71
|
+
:items="(f.meta?.options ?? []).map((o: string) => ({ label: optionLabel(f, o), value: o }))" :placeholder="t('list.filterAny')"
|
|
72
|
+
@update:model-value="(v: any) => set(`filter.${f.key}`, v)"
|
|
73
|
+
/>
|
|
74
|
+
<USelect
|
|
75
|
+
v-else-if="f.type === 'boolean'" :model-value="model[`filter.${f.key}`] || undefined" class="w-full" size="sm"
|
|
76
|
+
:items="[{ label: t('fields.yes'), value: 'true' }, { label: t('fields.no'), value: 'false' }]" :placeholder="t('list.filterAny')"
|
|
77
|
+
@update:model-value="(v: any) => set(`filter.${f.key}`, v)"
|
|
78
|
+
/>
|
|
79
|
+
<USelect
|
|
80
|
+
v-else-if="f.type === 'media'" :model-value="model[`filter.${f.key}`] || undefined" class="w-full" size="sm"
|
|
81
|
+
:items="[{ label: t('list.filterHas'), value: 'yes' }, { label: t('list.filterHasNot'), value: 'no' }]" :placeholder="t('list.filterAny')"
|
|
82
|
+
@update:model-value="(v: any) => set(`filter.${f.key}`, v)"
|
|
83
|
+
/>
|
|
84
|
+
<USelectMenu
|
|
85
|
+
v-else-if="f.relation" :model-value="model[`filter.${f.key}`] || undefined" class="w-full" size="sm"
|
|
86
|
+
:items="relationOptions[f.key] ?? []" value-key="id" :placeholder="t('list.filterAny')" :aria-label="fieldLabel(f)"
|
|
87
|
+
@update:open="(o: boolean) => o && loadRelation(f)" @update:model-value="(v: any) => set(`filter.${f.key}`, v)"
|
|
88
|
+
/>
|
|
89
|
+
<div v-else-if="f.type === 'datetime'" class="grid grid-cols-2 gap-2">
|
|
90
|
+
<CmsDayPicker :label="`${fieldLabel(f)} ${t('list.filterFrom')}`" :placeholder="t('list.filterFrom')" :model-value="dateValue(`filter.${f.key}.from`)" @update:model-value="(v: string) => setDate(`filter.${f.key}.from`, v, 'from')" />
|
|
91
|
+
<CmsDayPicker :label="`${fieldLabel(f)} ${t('list.filterTo')}`" :placeholder="t('list.filterTo')" :model-value="dateValue(`filter.${f.key}.to`)" @update:model-value="(v: string) => setDate(`filter.${f.key}.to`, v, 'to')" />
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<UButton v-if="count" color="neutral" variant="link" size="sm" class="px-0" @click="model = {}">{{ t('list.filterClear') }}</UButton>
|
|
95
|
+
</div>
|
|
96
|
+
</template>
|
|
97
|
+
</UPopover>
|
|
98
|
+
<UBadge
|
|
99
|
+
v-for="c in chips" :key="c.param" color="neutral" variant="soft" size="md" class="gap-1"
|
|
100
|
+
>
|
|
101
|
+
{{ c.label }}
|
|
102
|
+
<button type="button" class="text-dimmed hover:text-highlighted" :aria-label="t('list.filterRemove', { name: c.label })" @click="set(c.param, null)">
|
|
103
|
+
<UIcon name="i-lucide-x" class="size-3.5 block" />
|
|
104
|
+
</button>
|
|
105
|
+
</UBadge>
|
|
106
|
+
</div>
|
|
107
|
+
</template>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// The one notice an editor shows when someone else got there first: the entry was
|
|
3
|
+
// deleted, a save was refused because a newer version exists (conflict), or a newer
|
|
4
|
+
// version arrived while this tab has unsaved changes (incoming). Nothing is lost
|
|
5
|
+
// without a click: loading the newer version is always the editor's choice.
|
|
6
|
+
import type { LiveChange } from '../composables/useCmsLive'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{
|
|
9
|
+
deleted?: LiveChange | null
|
|
10
|
+
conflict?: { updatedByName: string | null } | null
|
|
11
|
+
incoming?: LiveChange | null
|
|
12
|
+
listTo?: string
|
|
13
|
+
}>()
|
|
14
|
+
const emit = defineEmits<{ load: []; saveAnyway: []; dismiss: [] }>()
|
|
15
|
+
const { t } = useCmsI18n()
|
|
16
|
+
|
|
17
|
+
const notice = computed(() => {
|
|
18
|
+
if (props.deleted) {
|
|
19
|
+
const name = props.deleted.byName
|
|
20
|
+
return {
|
|
21
|
+
color: 'error' as const,
|
|
22
|
+
icon: 'i-lucide-trash-2',
|
|
23
|
+
title: name ? t('live.deleted', { name }) : t('live.deletedSomeone'),
|
|
24
|
+
description: t('live.deletedBody'),
|
|
25
|
+
actions: props.listTo ? [{ label: t('live.backToList'), to: props.listTo, color: 'neutral' as const, variant: 'outline' as const }] : [],
|
|
26
|
+
close: false,
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (props.conflict) {
|
|
30
|
+
const name = props.conflict.updatedByName
|
|
31
|
+
return {
|
|
32
|
+
color: 'warning' as const,
|
|
33
|
+
icon: 'i-lucide-git-compare-arrows',
|
|
34
|
+
title: name ? t('live.conflict', { name }) : t('live.conflictSomeone'),
|
|
35
|
+
description: t('live.conflictBody'),
|
|
36
|
+
actions: [
|
|
37
|
+
{ label: t('live.loadNewer'), color: 'neutral' as const, variant: 'outline' as const, onClick: () => emit('load') },
|
|
38
|
+
{ label: t('live.saveAnyway'), color: 'warning' as const, variant: 'ghost' as const, onClick: () => emit('saveAnyway') },
|
|
39
|
+
],
|
|
40
|
+
close: false,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (props.incoming) {
|
|
44
|
+
const name = props.incoming.byName
|
|
45
|
+
return {
|
|
46
|
+
color: 'info' as const,
|
|
47
|
+
icon: 'i-lucide-refresh-cw',
|
|
48
|
+
title: name ? t('live.changed', { name }) : t('live.changedSomeone'),
|
|
49
|
+
description: t('live.changedBody'),
|
|
50
|
+
actions: [{ label: t('live.loadNewer'), color: 'neutral' as const, variant: 'outline' as const, onClick: () => emit('load') }],
|
|
51
|
+
close: true,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return null
|
|
55
|
+
})
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<template>
|
|
59
|
+
<UAlert
|
|
60
|
+
v-if="notice" :color="notice.color" variant="subtle" :icon="notice.icon"
|
|
61
|
+
:title="notice.title" :description="notice.description" :actions="notice.actions"
|
|
62
|
+
:close="notice.close" class="mb-6" :role="notice.close ? 'status' : 'alert'" @update:open="(open: boolean) => { if (!open) emit('dismiss') }"
|
|
63
|
+
/>
|
|
64
|
+
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A list or page that could not be loaded, in words an editor can act on. A refusal
|
|
3
|
+
// (403) says so and offers no "Try again" — asking again gets the same answer; anything
|
|
4
|
+
// else says what went wrong and lets them retry. (A 401 never gets here for long: the
|
|
5
|
+
// admin sends someone whose session ended back to sign-in — see plugins/cmsSignedOut.)
|
|
6
|
+
const props = defineProps<{ error: any }>()
|
|
7
|
+
defineEmits<{ retry: [] }>()
|
|
8
|
+
const { t } = useCmsI18n()
|
|
9
|
+
const status = computed<number | undefined>(() => props.error?.statusCode ?? props.error?.status)
|
|
10
|
+
const refused = computed(() => status.value === 403)
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<CmsEmptyState
|
|
15
|
+
variant="error"
|
|
16
|
+
:title="refused ? t('errors.noAccessTitle') : t('list.loadFailed')"
|
|
17
|
+
:description="refused ? t('errors.noAccessBody') : cmsRequestError(error, t as any)"
|
|
18
|
+
>
|
|
19
|
+
<template #actions>
|
|
20
|
+
<UButton v-if="refused" to="/admin" color="neutral" variant="outline" icon="i-lucide-house">{{ t('nav.home') }}</UButton>
|
|
21
|
+
<UButton v-else color="neutral" variant="outline" icon="i-lucide-rotate-ccw" @click="$emit('retry')">{{ t('list.retry') }}</UButton>
|
|
22
|
+
</template>
|
|
23
|
+
</CmsEmptyState>
|
|
24
|
+
</template>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// tinyzoo's mascot, in the brand's charcoal — cream with charcoal eyes in dark mode.
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<span class="inline-flex" aria-hidden="true">
|
|
7
|
+
<img :src="cmsBrand.mascotUrl" alt="" class="h-full w-auto dark:hidden" draggable="false">
|
|
8
|
+
<img :src="cmsBrand.mascotReversedUrl" alt="" class="h-full w-auto hidden dark:block" draggable="false">
|
|
9
|
+
</span>
|
|
10
|
+
</template>
|