@actuate-media/cms-admin 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/AdminRoot.d.ts.map +1 -1
  2. package/dist/AdminRoot.js +3 -3
  3. package/dist/AdminRoot.js.map +1 -1
  4. package/dist/__tests__/views/general-settings.render.test.d.ts +2 -0
  5. package/dist/__tests__/views/general-settings.render.test.d.ts.map +1 -0
  6. package/dist/__tests__/views/general-settings.render.test.js +105 -0
  7. package/dist/__tests__/views/general-settings.render.test.js.map +1 -0
  8. package/dist/__tests__/views/page-builder-block-renderer.render.test.d.ts +2 -0
  9. package/dist/__tests__/views/page-builder-block-renderer.render.test.d.ts.map +1 -0
  10. package/dist/__tests__/views/page-builder-block-renderer.render.test.js +48 -0
  11. package/dist/__tests__/views/page-builder-block-renderer.render.test.js.map +1 -0
  12. package/dist/__tests__/views/page-builder-form-picker.render.test.d.ts +2 -0
  13. package/dist/__tests__/views/page-builder-form-picker.render.test.d.ts.map +1 -0
  14. package/dist/__tests__/views/page-builder-form-picker.render.test.js +44 -0
  15. package/dist/__tests__/views/page-builder-form-picker.render.test.js.map +1 -0
  16. package/dist/actuate-admin.css +1 -1
  17. package/dist/views/Settings.d.ts +3 -1
  18. package/dist/views/Settings.d.ts.map +1 -1
  19. package/dist/views/Settings.js +9 -28
  20. package/dist/views/Settings.js.map +1 -1
  21. package/dist/views/page-builder/BlockEditor.d.ts.map +1 -1
  22. package/dist/views/page-builder/BlockEditor.js +2 -1
  23. package/dist/views/page-builder/BlockEditor.js.map +1 -1
  24. package/dist/views/page-builder/RelationshipField.d.ts +15 -0
  25. package/dist/views/page-builder/RelationshipField.d.ts.map +1 -0
  26. package/dist/views/page-builder/RelationshipField.js +65 -0
  27. package/dist/views/page-builder/RelationshipField.js.map +1 -0
  28. package/dist/views/page-builder/block-renderers/FormPreview.d.ts +6 -0
  29. package/dist/views/page-builder/block-renderers/FormPreview.d.ts.map +1 -1
  30. package/dist/views/page-builder/block-renderers/FormPreview.js +44 -6
  31. package/dist/views/page-builder/block-renderers/FormPreview.js.map +1 -1
  32. package/dist/views/page-builder/canvas/BlockRenderer.d.ts.map +1 -1
  33. package/dist/views/page-builder/canvas/BlockRenderer.js +3 -9
  34. package/dist/views/page-builder/canvas/BlockRenderer.js.map +1 -1
  35. package/dist/views/settings/GeneralSettingsTab.d.ts +7 -0
  36. package/dist/views/settings/GeneralSettingsTab.d.ts.map +1 -0
  37. package/dist/views/settings/GeneralSettingsTab.js +19 -0
  38. package/dist/views/settings/GeneralSettingsTab.js.map +1 -0
  39. package/dist/views/settings/LanguageRegionCard.d.ts +10 -0
  40. package/dist/views/settings/LanguageRegionCard.d.ts.map +1 -0
  41. package/dist/views/settings/LanguageRegionCard.js +48 -0
  42. package/dist/views/settings/LanguageRegionCard.js.map +1 -0
  43. package/dist/views/settings/SeoRobotsDefaultsCard.d.ts +12 -0
  44. package/dist/views/settings/SeoRobotsDefaultsCard.d.ts.map +1 -0
  45. package/dist/views/settings/SeoRobotsDefaultsCard.js +45 -0
  46. package/dist/views/settings/SeoRobotsDefaultsCard.js.map +1 -0
  47. package/dist/views/settings/SiteIndexStatusCard.d.ts +12 -0
  48. package/dist/views/settings/SiteIndexStatusCard.d.ts.map +1 -0
  49. package/dist/views/settings/SiteIndexStatusCard.js +51 -0
  50. package/dist/views/settings/SiteIndexStatusCard.js.map +1 -0
  51. package/dist/views/settings/SiteInformationCard.d.ts +11 -0
  52. package/dist/views/settings/SiteInformationCard.d.ts.map +1 -0
  53. package/dist/views/settings/SiteInformationCard.js +21 -0
  54. package/dist/views/settings/SiteInformationCard.js.map +1 -0
  55. package/dist/views/settings/components.d.ts +38 -0
  56. package/dist/views/settings/components.d.ts.map +1 -0
  57. package/dist/views/settings/components.js +43 -0
  58. package/dist/views/settings/components.js.map +1 -0
  59. package/dist/views/settings/useGeneralSettings.d.ts +79 -0
  60. package/dist/views/settings/useGeneralSettings.d.ts.map +1 -0
  61. package/dist/views/settings/useGeneralSettings.js +286 -0
  62. package/dist/views/settings/useGeneralSettings.js.map +1 -0
  63. package/package.json +3 -3
  64. package/src/AdminRoot.tsx +5 -3
  65. package/src/__tests__/views/general-settings.render.test.tsx +135 -0
  66. package/src/__tests__/views/page-builder-block-renderer.render.test.tsx +66 -0
  67. package/src/__tests__/views/page-builder-form-picker.render.test.tsx +54 -0
  68. package/src/views/Settings.tsx +17 -120
  69. package/src/views/page-builder/BlockEditor.tsx +7 -10
  70. package/src/views/page-builder/RelationshipField.tsx +113 -0
  71. package/src/views/page-builder/block-renderers/FormPreview.tsx +85 -33
  72. package/src/views/page-builder/canvas/BlockRenderer.tsx +10 -12
  73. package/src/views/settings/GeneralSettingsTab.tsx +126 -0
  74. package/src/views/settings/LanguageRegionCard.tsx +119 -0
  75. package/src/views/settings/SeoRobotsDefaultsCard.tsx +149 -0
  76. package/src/views/settings/SiteIndexStatusCard.tsx +184 -0
  77. package/src/views/settings/SiteInformationCard.tsx +122 -0
  78. package/src/views/settings/components.tsx +198 -0
  79. package/src/views/settings/useGeneralSettings.ts +376 -0
@@ -0,0 +1,119 @@
1
+ 'use client'
2
+
3
+ import { useId, useMemo } from 'react'
4
+ import type { GeneralSettingsForm, ValidationIssue } from './useGeneralSettings.js'
5
+
6
+ const INPUT_CLASS =
7
+ 'w-full rounded-md border border-border bg-input-background px-3 py-2 text-base text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60'
8
+ const LABEL_CLASS = 'mb-1 block text-sm font-medium text-foreground'
9
+
10
+ const LANGUAGES: Array<{ value: string; label: string }> = [
11
+ { value: 'en-US', label: 'English (US)' },
12
+ { value: 'en-GB', label: 'English (UK)' },
13
+ { value: 'es-ES', label: 'Spanish (Spain)' },
14
+ { value: 'es-MX', label: 'Spanish (Mexico)' },
15
+ { value: 'fr-FR', label: 'French (France)' },
16
+ { value: 'de-DE', label: 'German (Germany)' },
17
+ { value: 'en', label: 'English' },
18
+ ]
19
+
20
+ const TIMEZONES = [
21
+ 'UTC',
22
+ 'America/New_York',
23
+ 'America/Chicago',
24
+ 'America/Denver',
25
+ 'America/Los_Angeles',
26
+ 'America/Anchorage',
27
+ 'Europe/London',
28
+ 'Europe/Paris',
29
+ 'Europe/Berlin',
30
+ 'Asia/Tokyo',
31
+ 'Asia/Singapore',
32
+ 'Australia/Sydney',
33
+ ]
34
+
35
+ interface LanguageRegionCardProps {
36
+ form: GeneralSettingsForm
37
+ setField: <K extends keyof GeneralSettingsForm>(key: K, value: GeneralSettingsForm[K]) => void
38
+ issues: ValidationIssue[]
39
+ canEdit: boolean
40
+ }
41
+
42
+ export function LanguageRegionCard({ form, setField, issues, canEdit }: LanguageRegionCardProps) {
43
+ const langId = useId()
44
+ const tzId = useId()
45
+ const langIssue = issues.find((i) => i.field === 'language')
46
+ const tzIssue = issues.find((i) => i.field === 'timezone')
47
+
48
+ // Surface the loaded value even when it isn't one of our presets, so a
49
+ // seeded/config value is never silently dropped from the select.
50
+ const languageOptions = useMemo(() => {
51
+ if (LANGUAGES.some((l) => l.value === form.language)) return LANGUAGES
52
+ return [{ value: form.language, label: form.language }, ...LANGUAGES]
53
+ }, [form.language])
54
+
55
+ const timezoneOptions = useMemo(() => {
56
+ if (TIMEZONES.includes(form.timezone)) return TIMEZONES
57
+ return [form.timezone, ...TIMEZONES]
58
+ }, [form.timezone])
59
+
60
+ return (
61
+ <section
62
+ aria-labelledby={`${langId}-heading`}
63
+ className="border-border bg-card rounded-lg border p-4"
64
+ >
65
+ <h3 id={`${langId}-heading`} className="text-foreground mb-4 text-base font-medium">
66
+ Language &amp; Region
67
+ </h3>
68
+ <div className="space-y-4">
69
+ <div>
70
+ <label htmlFor={langId} className={LABEL_CLASS}>
71
+ Language
72
+ </label>
73
+ <select
74
+ id={langId}
75
+ value={form.language}
76
+ disabled={!canEdit}
77
+ aria-invalid={Boolean(langIssue)}
78
+ onChange={(e) => setField('language', e.target.value)}
79
+ className={INPUT_CLASS}
80
+ >
81
+ {languageOptions.map((l) => (
82
+ <option key={l.value} value={l.value}>
83
+ {l.label}
84
+ </option>
85
+ ))}
86
+ </select>
87
+ {langIssue && <p className="text-destructive mt-1 text-sm">{langIssue.message}</p>}
88
+ </div>
89
+
90
+ <div>
91
+ <label htmlFor={tzId} className={LABEL_CLASS}>
92
+ Timezone
93
+ </label>
94
+ <select
95
+ id={tzId}
96
+ value={form.timezone}
97
+ disabled={!canEdit}
98
+ aria-invalid={Boolean(tzIssue)}
99
+ onChange={(e) => setField('timezone', e.target.value)}
100
+ className={INPUT_CLASS}
101
+ >
102
+ {timezoneOptions.map((tz) => (
103
+ <option key={tz} value={tz}>
104
+ {tz}
105
+ </option>
106
+ ))}
107
+ </select>
108
+ {tzIssue ? (
109
+ <p className="text-destructive mt-1 text-sm">{tzIssue.message}</p>
110
+ ) : (
111
+ <p className="text-muted-foreground mt-1 text-sm">
112
+ Applied to dashboard dates, audit logs, scheduled publishing, and form submissions.
113
+ </p>
114
+ )}
115
+ </div>
116
+ </div>
117
+ </section>
118
+ )
119
+ }
@@ -0,0 +1,149 @@
1
+ 'use client'
2
+
3
+ import { useId, useState } from 'react'
4
+ import { ConfirmDangerousSettingDialog, SettingsToggleRow } from './components.js'
5
+ import type { GeneralSettingsForm, SiteIndexStatus } from './useGeneralSettings.js'
6
+
7
+ interface SeoRobotsDefaultsCardProps {
8
+ form: GeneralSettingsForm
9
+ setField: <K extends keyof GeneralSettingsForm>(key: K, value: GeneralSettingsForm[K]) => void
10
+ isProduction: boolean
11
+ indexStatus: SiteIndexStatus | null
12
+ canEdit: boolean
13
+ onNavigate?: (path: string) => void
14
+ }
15
+
16
+ interface PendingChange {
17
+ field: keyof GeneralSettingsForm
18
+ value: boolean
19
+ title: string
20
+ description: string
21
+ confirmLabel: string
22
+ }
23
+
24
+ export function SeoRobotsDefaultsCard({
25
+ form,
26
+ setField,
27
+ isProduction,
28
+ indexStatus,
29
+ canEdit,
30
+ onNavigate,
31
+ }: SeoRobotsDefaultsCardProps) {
32
+ const headingId = useId()
33
+ const [pending, setPending] = useState<PendingChange | null>(null)
34
+
35
+ // Some toggles can take the whole production site out of search results, so
36
+ // they route through a confirmation step before being applied.
37
+ function requestToggle(field: keyof GeneralSettingsForm, value: boolean) {
38
+ if (field === 'defaultNoIndex' && value && isProduction) {
39
+ setPending({
40
+ field,
41
+ value,
42
+ title: 'Block this production site from search engines?',
43
+ description:
44
+ 'This may prevent search engines from indexing your production site. Pages will be served with a noindex directive unless they explicitly opt in.',
45
+ confirmLabel: 'Enable No Index',
46
+ })
47
+ return
48
+ }
49
+ if (field === 'noIndexNonProduction' && !value) {
50
+ setPending({
51
+ field,
52
+ value,
53
+ title: 'Allow non-production environments to be indexed?',
54
+ description:
55
+ 'Preview and staging environments may become indexable if publicly accessible. Search engines could index unfinished content.',
56
+ confirmLabel: 'Turn Off',
57
+ })
58
+ return
59
+ }
60
+ setField(field, value)
61
+ }
62
+
63
+ const effectiveProd = form.defaultNoIndex ? 'Blocked' : 'Indexable'
64
+ const sitemapCheck = indexStatus?.checks.find((c) => c.key === 'sitemap')
65
+ const sitemapStatus = sitemapCheck ? (sitemapCheck.value === 'Yes' ? 'Enabled' : 'Disabled') : '—'
66
+
67
+ return (
68
+ <section aria-labelledby={headingId} className="border-border bg-card rounded-lg border p-4">
69
+ <h3 id={headingId} className="text-foreground mb-1 text-base font-medium">
70
+ SEO &amp; Robots Defaults
71
+ </h3>
72
+ <p className="text-muted-foreground mb-4 text-sm">
73
+ Set the site-wide default for search engine indexing. Individual pages can inherit or
74
+ override these rules in their SEO panel. These share the same configuration as the SEO
75
+ section.
76
+ </p>
77
+
78
+ <div className="space-y-4">
79
+ <SettingsToggleRow
80
+ label="Default No Index"
81
+ description="Ask search engines not to index pages unless a page explicitly allows indexing."
82
+ checked={form.defaultNoIndex}
83
+ disabled={!canEdit}
84
+ onChange={(v) => requestToggle('defaultNoIndex', v)}
85
+ />
86
+ <SettingsToggleRow
87
+ label="Default No Follow"
88
+ description="Ask search engines not to follow page links unless a page explicitly allows following."
89
+ checked={form.defaultNoFollow}
90
+ disabled={!canEdit}
91
+ onChange={(v) => requestToggle('defaultNoFollow', v)}
92
+ />
93
+ <SettingsToggleRow
94
+ label="Noindex Non-Production Environments"
95
+ description="Force noindex when the deployed environment is not production."
96
+ checked={form.noIndexNonProduction}
97
+ disabled={!canEdit}
98
+ onChange={(v) => requestToggle('noIndexNonProduction', v)}
99
+ />
100
+ </div>
101
+
102
+ <div className="border-border mt-4 space-y-2 border-t pt-4">
103
+ <SummaryRow
104
+ label="Effective production indexing"
105
+ value={effectiveProd}
106
+ danger={form.defaultNoIndex}
107
+ />
108
+ <SummaryRow
109
+ label="Effective current environment"
110
+ value={indexStatus?.label ?? '—'}
111
+ danger={indexStatus?.severity === 'danger'}
112
+ />
113
+ <SummaryRow label="Sitemap status" value={sitemapStatus} />
114
+ {onNavigate && (
115
+ <button
116
+ type="button"
117
+ onClick={() => onNavigate('/seo?tab=technical')}
118
+ className="text-brand mt-1 text-sm hover:underline"
119
+ >
120
+ Manage advanced robots.txt &amp; sitemap in SEO →
121
+ </button>
122
+ )}
123
+ </div>
124
+
125
+ <ConfirmDangerousSettingDialog
126
+ open={pending !== null}
127
+ title={pending?.title ?? ''}
128
+ description={pending?.description ?? ''}
129
+ confirmLabel={pending?.confirmLabel}
130
+ onConfirm={() => {
131
+ if (pending) setField(pending.field, pending.value)
132
+ setPending(null)
133
+ }}
134
+ onCancel={() => setPending(null)}
135
+ />
136
+ </section>
137
+ )
138
+ }
139
+
140
+ function SummaryRow({ label, value, danger }: { label: string; value: string; danger?: boolean }) {
141
+ return (
142
+ <div className="flex items-center justify-between gap-2 text-sm">
143
+ <span className="text-muted-foreground">{label}</span>
144
+ <span className={danger ? 'text-destructive font-medium' : 'text-foreground font-medium'}>
145
+ {value}
146
+ </span>
147
+ </div>
148
+ )
149
+ }
@@ -0,0 +1,184 @@
1
+ 'use client'
2
+
3
+ import {
4
+ CheckCircle2,
5
+ XCircle,
6
+ AlertTriangle,
7
+ HelpCircle,
8
+ ShieldCheck,
9
+ ExternalLink,
10
+ Search,
11
+ } from 'lucide-react'
12
+ import type { ReactNode } from 'react'
13
+ import type { SiteIndexStatus } from './useGeneralSettings.js'
14
+
15
+ interface SiteIndexStatusCardProps {
16
+ status: SiteIndexStatus | null
17
+ loading: boolean
18
+ /** Resolve an action href relative to the admin (e.g. /seo?tab=audit). */
19
+ onNavigate?: (path: string) => void
20
+ /** Trigger the SEO audit flow when an action declares `action: run_seo_audit`. */
21
+ onRunAudit?: () => void
22
+ }
23
+
24
+ const SEVERITY_STYLES: Record<SiteIndexStatus['severity'], { pill: string; icon: ReactNode }> = {
25
+ success: {
26
+ pill: 'bg-success/15 text-success border-success/30',
27
+ icon: <CheckCircle2 size={14} aria-hidden="true" />,
28
+ },
29
+ warning: {
30
+ pill: 'bg-warning/15 text-warning border-warning/30',
31
+ icon: <AlertTriangle size={14} aria-hidden="true" />,
32
+ },
33
+ danger: {
34
+ pill: 'bg-destructive/10 text-destructive border-destructive/30',
35
+ icon: <XCircle size={14} aria-hidden="true" />,
36
+ },
37
+ neutral: {
38
+ pill: 'bg-muted text-muted-foreground border-border',
39
+ icon: <HelpCircle size={14} aria-hidden="true" />,
40
+ },
41
+ }
42
+
43
+ const CHECK_ICON: Record<string, ReactNode> = {
44
+ pass: <CheckCircle2 size={14} className="text-success" aria-hidden="true" />,
45
+ warning: <AlertTriangle size={14} className="text-warning" aria-hidden="true" />,
46
+ fail: <XCircle size={14} className="text-destructive" aria-hidden="true" />,
47
+ unknown: <HelpCircle size={14} className="text-muted-foreground" aria-hidden="true" />,
48
+ }
49
+
50
+ const CHECK_SR: Record<string, string> = {
51
+ pass: 'OK',
52
+ warning: 'Warning',
53
+ fail: 'Problem',
54
+ unknown: 'Unknown',
55
+ }
56
+
57
+ export function SiteIndexStatusCard({
58
+ status,
59
+ loading,
60
+ onNavigate,
61
+ onRunAudit,
62
+ }: SiteIndexStatusCardProps) {
63
+ return (
64
+ <section
65
+ aria-labelledby="site-index-status-heading"
66
+ className="border-border bg-card rounded-lg border p-4"
67
+ >
68
+ <div className="mb-3 flex items-start justify-between gap-3">
69
+ <div className="flex items-start gap-2">
70
+ <ShieldCheck size={18} className="text-muted-foreground mt-0.5" aria-hidden="true" />
71
+ <div>
72
+ <h3 id="site-index-status-heading" className="text-foreground text-base font-medium">
73
+ Site Index Status
74
+ </h3>
75
+ <p className="text-muted-foreground text-sm">
76
+ Current effective crawl and indexing state
77
+ </p>
78
+ </div>
79
+ </div>
80
+ {status && (
81
+ <span
82
+ className={`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium ${SEVERITY_STYLES[status.severity].pill}`}
83
+ >
84
+ {SEVERITY_STYLES[status.severity].icon}
85
+ <span className="sr-only">Status: </span>
86
+ {status.label}
87
+ </span>
88
+ )}
89
+ </div>
90
+
91
+ {loading && !status ? (
92
+ <div className="space-y-2" aria-hidden="true">
93
+ <div className="bg-muted h-4 w-2/3 animate-pulse rounded" />
94
+ <div className="bg-muted h-20 w-full animate-pulse rounded" />
95
+ </div>
96
+ ) : !status ? (
97
+ <p className="text-muted-foreground text-sm">Index status is unavailable.</p>
98
+ ) : (
99
+ <>
100
+ <p className="text-muted-foreground mb-3 text-sm">{status.description}</p>
101
+
102
+ <dl className="border-border grid grid-cols-1 gap-x-6 gap-y-2 rounded-md border p-3 sm:grid-cols-2">
103
+ {status.checks.map((check) => (
104
+ <div key={check.key} className="flex items-center justify-between gap-2 text-sm">
105
+ <dt className="text-muted-foreground">{check.label}</dt>
106
+ <dd className="text-foreground flex items-center gap-1.5 font-medium">
107
+ <span className="sr-only">{CHECK_SR[check.status]}: </span>
108
+ {CHECK_ICON[check.status]}
109
+ {check.value}
110
+ </dd>
111
+ </div>
112
+ ))}
113
+ </dl>
114
+
115
+ {status.actions.length > 0 && (
116
+ <div className="mt-3 flex flex-wrap gap-2">
117
+ {status.actions.map((action) => (
118
+ <SiteIndexAction
119
+ key={action.label}
120
+ label={action.label}
121
+ href={action.href}
122
+ action={action.action}
123
+ onNavigate={onNavigate}
124
+ onRunAudit={onRunAudit}
125
+ />
126
+ ))}
127
+ </div>
128
+ )}
129
+ </>
130
+ )}
131
+ </section>
132
+ )
133
+ }
134
+
135
+ function SiteIndexAction({
136
+ label,
137
+ href,
138
+ action,
139
+ onNavigate,
140
+ onRunAudit,
141
+ }: {
142
+ label: string
143
+ href?: string
144
+ action?: string
145
+ onNavigate?: (path: string) => void
146
+ onRunAudit?: () => void
147
+ }) {
148
+ const className =
149
+ 'border-border text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-sm transition-colors'
150
+
151
+ // The audit action stays in-app; robots/sitemap are real public URLs.
152
+ const isAudit = action === 'run_seo_audit'
153
+ const isAdminRoute = href?.startsWith('/seo')
154
+ const icon = isAudit ? (
155
+ <Search size={14} aria-hidden="true" />
156
+ ) : (
157
+ <ExternalLink size={14} aria-hidden="true" />
158
+ )
159
+
160
+ if (isAudit && onRunAudit) {
161
+ return (
162
+ <button type="button" onClick={onRunAudit} className={className}>
163
+ {icon}
164
+ {label}
165
+ </button>
166
+ )
167
+ }
168
+
169
+ if (isAdminRoute && onNavigate) {
170
+ return (
171
+ <button type="button" onClick={() => onNavigate(href!)} className={className}>
172
+ {icon}
173
+ {label}
174
+ </button>
175
+ )
176
+ }
177
+
178
+ return (
179
+ <a href={href} target="_blank" rel="noopener noreferrer" className={className}>
180
+ {icon}
181
+ {label}
182
+ </a>
183
+ )
184
+ }
@@ -0,0 +1,122 @@
1
+ 'use client'
2
+
3
+ import { useId } from 'react'
4
+ import { CheckCircle2 } from 'lucide-react'
5
+ import { SettingsSourceBadge } from './components.js'
6
+ import type {
7
+ GeneralSettingsForm,
8
+ SettingsSourceMetadata,
9
+ ValidationIssue,
10
+ } from './useGeneralSettings.js'
11
+
12
+ const INPUT_CLASS =
13
+ 'w-full rounded-md border border-border bg-input-background px-3 py-2 text-base text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-60'
14
+ const LABEL_CLASS = 'mb-1 flex items-center gap-2 text-sm font-medium text-foreground'
15
+
16
+ interface SiteInformationCardProps {
17
+ form: GeneralSettingsForm
18
+ setField: <K extends keyof GeneralSettingsForm>(key: K, value: GeneralSettingsForm[K]) => void
19
+ sources: Record<string, SettingsSourceMetadata>
20
+ issues: ValidationIssue[]
21
+ canEdit: boolean
22
+ }
23
+
24
+ export function SiteInformationCard({
25
+ form,
26
+ setField,
27
+ sources,
28
+ issues,
29
+ canEdit,
30
+ }: SiteInformationCardProps) {
31
+ const titleId = useId()
32
+ const taglineId = useId()
33
+ const urlId = useId()
34
+ const urlErrId = useId()
35
+
36
+ const titleIssue = issues.find((i) => i.field === 'siteTitle')
37
+ const urlIssue = issues.find((i) => i.field === 'siteUrl')
38
+ const urlEditable = sources.siteUrl?.editable !== false && canEdit
39
+ const urlValid = !urlIssue && form.siteUrl.trim().length > 0
40
+
41
+ return (
42
+ <section
43
+ aria-labelledby={`${titleId}-heading`}
44
+ className="border-border bg-card rounded-lg border p-4"
45
+ >
46
+ <h3 id={`${titleId}-heading`} className="text-foreground mb-4 text-base font-medium">
47
+ Site Information
48
+ </h3>
49
+ <div className="space-y-4">
50
+ <div>
51
+ <label htmlFor={titleId} className={LABEL_CLASS}>
52
+ Site Title
53
+ </label>
54
+ <input
55
+ id={titleId}
56
+ type="text"
57
+ value={form.siteTitle}
58
+ disabled={!canEdit}
59
+ aria-invalid={titleIssue?.severity === 'error'}
60
+ onChange={(e) => setField('siteTitle', e.target.value)}
61
+ className={INPUT_CLASS}
62
+ />
63
+ {titleIssue && <p className="text-destructive mt-1 text-sm">{titleIssue.message}</p>}
64
+ </div>
65
+
66
+ <div>
67
+ <label htmlFor={taglineId} className={LABEL_CLASS}>
68
+ Tagline
69
+ </label>
70
+ <input
71
+ id={taglineId}
72
+ type="text"
73
+ value={form.tagline}
74
+ disabled={!canEdit}
75
+ onChange={(e) => setField('tagline', e.target.value)}
76
+ className={INPUT_CLASS}
77
+ />
78
+ </div>
79
+
80
+ <div>
81
+ <label htmlFor={urlId} className={LABEL_CLASS}>
82
+ Site URL
83
+ <SettingsSourceBadge meta={sources.siteUrl} />
84
+ </label>
85
+ <input
86
+ id={urlId}
87
+ type="url"
88
+ inputMode="url"
89
+ placeholder="https://example.com"
90
+ value={form.siteUrl}
91
+ disabled={!urlEditable}
92
+ aria-invalid={urlIssue?.severity === 'error'}
93
+ aria-describedby={urlIssue ? urlErrId : undefined}
94
+ onChange={(e) => setField('siteUrl', e.target.value)}
95
+ className={INPUT_CLASS}
96
+ />
97
+ {urlIssue ? (
98
+ <p
99
+ id={urlErrId}
100
+ className={
101
+ urlIssue.severity === 'error'
102
+ ? 'text-destructive mt-1 text-sm'
103
+ : 'text-warning mt-1 text-sm'
104
+ }
105
+ >
106
+ {urlIssue.message}
107
+ </p>
108
+ ) : urlValid ? (
109
+ <p className="text-muted-foreground mt-1 flex items-center gap-1.5 text-sm">
110
+ <CheckCircle2 size={13} className="text-success" aria-hidden="true" />
111
+ Valid — used for canonical URLs, sitemap, robots.txt, and Open Graph.
112
+ </p>
113
+ ) : (
114
+ <p className="text-muted-foreground mt-1 text-sm">
115
+ Used for canonical URLs, sitemap, robots.txt, and Open Graph fallbacks.
116
+ </p>
117
+ )}
118
+ </div>
119
+ </div>
120
+ </section>
121
+ )
122
+ }