@purposeinplay/payload-ai-translate 0.1.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 +714 -0
- package/dist/alerts-collection.d.ts +21 -0
- package/dist/alerts-collection.js +159 -0
- package/dist/api.d.ts +4 -0
- package/dist/api.js +918 -0
- package/dist/bulk-translate-batches-collection.d.ts +29 -0
- package/dist/bulk-translate-batches-collection.js +404 -0
- package/dist/bulk-translate-units-collection.d.ts +35 -0
- package/dist/bulk-translate-units-collection.js +310 -0
- package/dist/client/estimated-cost-cell.d.ts +6 -0
- package/dist/client/estimated-cost-cell.js +12 -0
- package/dist/client/excluded-fields-field.d.ts +45 -0
- package/dist/client/excluded-fields-field.js +553 -0
- package/dist/client/field-translate-button.d.ts +6 -0
- package/dist/client/field-translate-button.js +199 -0
- package/dist/client/index.d.ts +6 -0
- package/dist/client/index.js +6 -0
- package/dist/client/lib/use-global-kill-switches.d.ts +20 -0
- package/dist/client/lib/use-global-kill-switches.js +58 -0
- package/dist/client/translate-button.d.ts +2 -0
- package/dist/client/translate-button.js +228 -0
- package/dist/client/translate-modal.d.ts +16 -0
- package/dist/client/translate-modal.js +549 -0
- package/dist/client/translation-progress.d.ts +10 -0
- package/dist/client/translation-progress.js +297 -0
- package/dist/components/TranslationNavGroup.d.ts +45 -0
- package/dist/components/TranslationNavGroup.js +104 -0
- package/dist/defaults.d.ts +11 -0
- package/dist/defaults.js +16 -0
- package/dist/endpoints/client-config.d.ts +44 -0
- package/dist/endpoints/client-config.js +145 -0
- package/dist/endpoints/estimate.d.ts +5 -0
- package/dist/endpoints/estimate.js +237 -0
- package/dist/endpoints/progress.d.ts +2 -0
- package/dist/endpoints/progress.js +314 -0
- package/dist/endpoints/translate.d.ts +11 -0
- package/dist/endpoints/translate.js +376 -0
- package/dist/endpoints/translation-hub/_helpers.d.ts +140 -0
- package/dist/endpoints/translation-hub/_helpers.js +297 -0
- package/dist/endpoints/translation-hub/active.d.ts +21 -0
- package/dist/endpoints/translation-hub/active.js +220 -0
- package/dist/endpoints/translation-hub/cancel.d.ts +22 -0
- package/dist/endpoints/translation-hub/cancel.js +233 -0
- package/dist/endpoints/translation-hub/enqueue.d.ts +70 -0
- package/dist/endpoints/translation-hub/enqueue.js +529 -0
- package/dist/endpoints/translation-hub/failures.d.ts +12 -0
- package/dist/endpoints/translation-hub/failures.js +67 -0
- package/dist/endpoints/translation-hub/force-reset.d.ts +20 -0
- package/dist/endpoints/translation-hub/force-reset.js +144 -0
- package/dist/endpoints/translation-hub/index.d.ts +21 -0
- package/dist/endpoints/translation-hub/index.js +20 -0
- package/dist/endpoints/translation-hub/list.d.ts +40 -0
- package/dist/endpoints/translation-hub/list.js +182 -0
- package/dist/endpoints/translation-hub/preflight.d.ts +19 -0
- package/dist/endpoints/translation-hub/preflight.js +141 -0
- package/dist/endpoints/translation-hub/retry-failed.d.ts +38 -0
- package/dist/endpoints/translation-hub/retry-failed.js +235 -0
- package/dist/endpoints/translation-hub/revert.d.ts +88 -0
- package/dist/endpoints/translation-hub/revert.js +405 -0
- package/dist/endpoints/translation-hub/status.d.ts +45 -0
- package/dist/endpoints/translation-hub/status.js +391 -0
- package/dist/endpoints/translation-hub/usage-summary.d.ts +114 -0
- package/dist/endpoints/translation-hub/usage-summary.js +481 -0
- package/dist/exports/client.d.ts +6 -0
- package/dist/exports/client.js +6 -0
- package/dist/exports/components.d.ts +6 -0
- package/dist/exports/components.js +5 -0
- package/dist/exports/index.d.ts +8 -0
- package/dist/exports/index.js +7 -0
- package/dist/exports/providers.d.ts +9 -0
- package/dist/exports/providers.js +5 -0
- package/dist/exports/views-client.d.ts +23 -0
- package/dist/exports/views-client.js +22 -0
- package/dist/exports/views.d.ts +30 -0
- package/dist/exports/views.js +29 -0
- package/dist/hooks/after-change-global.d.ts +4 -0
- package/dist/hooks/after-change-global.js +109 -0
- package/dist/hooks/after-change.d.ts +16 -0
- package/dist/hooks/after-change.js +205 -0
- package/dist/hooks/after-delete.d.ts +30 -0
- package/dist/hooks/after-delete.js +95 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/jobs-collection.d.ts +17 -0
- package/dist/jobs-collection.js +139 -0
- package/dist/lexical/classifier.d.ts +3 -0
- package/dist/lexical/classifier.js +108 -0
- package/dist/lexical/deserializer.d.ts +4 -0
- package/dist/lexical/deserializer.js +263 -0
- package/dist/lexical/placeholder-integrity.d.ts +6 -0
- package/dist/lexical/placeholder-integrity.js +21 -0
- package/dist/lexical/placeholders.d.ts +21 -0
- package/dist/lexical/placeholders.js +117 -0
- package/dist/lexical/serializer.d.ts +21 -0
- package/dist/lexical/serializer.js +233 -0
- package/dist/lexical/types.d.ts +32 -0
- package/dist/lexical/types.js +1 -0
- package/dist/lib/auth-diagnostics.d.ts +14 -0
- package/dist/lib/auth-diagnostics.js +19 -0
- package/dist/lib/batch-counts.d.ts +58 -0
- package/dist/lib/batch-counts.js +105 -0
- package/dist/lib/bulk-translate-migrations.d.ts +92 -0
- package/dist/lib/bulk-translate-migrations.js +153 -0
- package/dist/lib/coalescing-queue.d.ts +38 -0
- package/dist/lib/coalescing-queue.js +69 -0
- package/dist/lib/content-extractor.d.ts +16 -0
- package/dist/lib/content-extractor.js +410 -0
- package/dist/lib/content-hash.d.ts +1 -0
- package/dist/lib/content-hash.js +19 -0
- package/dist/lib/content-patcher.d.ts +15 -0
- package/dist/lib/content-patcher.js +293 -0
- package/dist/lib/cost-guards.d.ts +2 -0
- package/dist/lib/cost-guards.js +18 -0
- package/dist/lib/daily-spend-cap.d.ts +58 -0
- package/dist/lib/daily-spend-cap.js +233 -0
- package/dist/lib/effective-locales.d.ts +181 -0
- package/dist/lib/effective-locales.js +302 -0
- package/dist/lib/error-messages.d.ts +245 -0
- package/dist/lib/error-messages.js +626 -0
- package/dist/lib/events.d.ts +39 -0
- package/dist/lib/events.js +146 -0
- package/dist/lib/exclude-fields.d.ts +3 -0
- package/dist/lib/exclude-fields.js +64 -0
- package/dist/lib/field-breadcrumb.d.ts +31 -0
- package/dist/lib/field-breadcrumb.js +227 -0
- package/dist/lib/field-diff.d.ts +1 -0
- package/dist/lib/field-diff.js +25 -0
- package/dist/lib/field-empty.d.ts +2 -0
- package/dist/lib/field-empty.js +68 -0
- package/dist/lib/field-resolver.d.ts +3 -0
- package/dist/lib/field-resolver.js +164 -0
- package/dist/lib/group-soft-skips.d.ts +39 -0
- package/dist/lib/group-soft-skips.js +45 -0
- package/dist/lib/locale-merge.d.ts +44 -0
- package/dist/lib/locale-merge.js +357 -0
- package/dist/lib/locale-row-check.d.ts +30 -0
- package/dist/lib/locale-row-check.js +64 -0
- package/dist/lib/logger.d.ts +74 -0
- package/dist/lib/logger.js +97 -0
- package/dist/lib/manual-edit-guard.d.ts +128 -0
- package/dist/lib/manual-edit-guard.js +393 -0
- package/dist/lib/output-validation.d.ts +48 -0
- package/dist/lib/output-validation.js +148 -0
- package/dist/lib/payload-read.d.ts +16 -0
- package/dist/lib/payload-read.js +51 -0
- package/dist/lib/per-doc-claim.d.ts +90 -0
- package/dist/lib/per-doc-claim.js +140 -0
- package/dist/lib/per-doc-lock.d.ts +94 -0
- package/dist/lib/per-doc-lock.js +119 -0
- package/dist/lib/persist-usage.d.ts +91 -0
- package/dist/lib/persist-usage.js +116 -0
- package/dist/lib/progress-store.d.ts +103 -0
- package/dist/lib/progress-store.js +314 -0
- package/dist/lib/rate-limiter.d.ts +3 -0
- package/dist/lib/rate-limiter.js +53 -0
- package/dist/lib/snapshot-select.d.ts +43 -0
- package/dist/lib/snapshot-select.js +108 -0
- package/dist/lib/translate-prompt.d.ts +31 -0
- package/dist/lib/translate-prompt.js +66 -0
- package/dist/lib/translation-token-bucket.d.ts +57 -0
- package/dist/lib/translation-token-bucket.js +365 -0
- package/dist/lib/truncate-source-value.d.ts +1 -0
- package/dist/lib/truncate-source-value.js +27 -0
- package/dist/manual-edit-collection.d.ts +22 -0
- package/dist/manual-edit-collection.js +124 -0
- package/dist/plugin.d.ts +3 -0
- package/dist/plugin.js +934 -0
- package/dist/providers/ai-sdk-adapter.d.ts +35 -0
- package/dist/providers/ai-sdk-adapter.js +100 -0
- package/dist/providers/anthropic.d.ts +31 -0
- package/dist/providers/anthropic.js +66 -0
- package/dist/providers/custom.d.ts +36 -0
- package/dist/providers/custom.js +24 -0
- package/dist/providers/gemini.d.ts +20 -0
- package/dist/providers/gemini.js +48 -0
- package/dist/providers/mock.d.ts +2 -0
- package/dist/providers/mock.js +29 -0
- package/dist/providers/openai.d.ts +28 -0
- package/dist/providers/openai.js +69 -0
- package/dist/settings-global.d.ts +74 -0
- package/dist/settings-global.js +216 -0
- package/dist/tasks/bulk-translate-coordinator.d.ts +115 -0
- package/dist/tasks/bulk-translate-coordinator.js +708 -0
- package/dist/tasks/bulk-translate-doc-task.d.ts +142 -0
- package/dist/tasks/bulk-translate-doc-task.js +1000 -0
- package/dist/tasks/bulk-translate-janitor.d.ts +87 -0
- package/dist/tasks/bulk-translate-janitor.js +311 -0
- package/dist/tasks/translate-job-task.d.ts +51 -0
- package/dist/tasks/translate-job-task.js +154 -0
- package/dist/translate.d.ts +113 -0
- package/dist/translate.js +911 -0
- package/dist/translation-daily-spend-collection.d.ts +24 -0
- package/dist/translation-daily-spend-collection.js +133 -0
- package/dist/translation-rate-limits-collection.d.ts +30 -0
- package/dist/translation-rate-limits-collection.js +144 -0
- package/dist/types.d.ts +672 -0
- package/dist/types.js +1 -0
- package/dist/usage-collection.d.ts +14 -0
- package/dist/usage-collection.js +377 -0
- package/dist/views/BulkRunsHub/BatchRow.d.ts +32 -0
- package/dist/views/BulkRunsHub/BatchRow.js +1222 -0
- package/dist/views/BulkRunsHub/BucketRow.d.ts +62 -0
- package/dist/views/BulkRunsHub/BucketRow.js +982 -0
- package/dist/views/BulkRunsHub/BulkRunsHub.client.d.ts +18 -0
- package/dist/views/BulkRunsHub/BulkRunsHub.client.js +331 -0
- package/dist/views/BulkRunsHub/EmptyState.d.ts +6 -0
- package/dist/views/BulkRunsHub/EmptyState.js +64 -0
- package/dist/views/BulkRunsHub/FilterBar.d.ts +16 -0
- package/dist/views/BulkRunsHub/FilterBar.js +284 -0
- package/dist/views/BulkRunsHub/InFlightBanner.d.ts +14 -0
- package/dist/views/BulkRunsHub/InFlightBanner.js +59 -0
- package/dist/views/BulkRunsHub/StatusBadge.d.ts +64 -0
- package/dist/views/BulkRunsHub/StatusBadge.js +248 -0
- package/dist/views/BulkRunsHub/SummaryStrip.d.ts +22 -0
- package/dist/views/BulkRunsHub/SummaryStrip.js +249 -0
- package/dist/views/BulkRunsHub/bucket-grouping.d.ts +200 -0
- package/dist/views/BulkRunsHub/bucket-grouping.js +344 -0
- package/dist/views/BulkRunsHub/bucketFailureSummary.d.ts +9 -0
- package/dist/views/BulkRunsHub/bucketFailureSummary.js +36 -0
- package/dist/views/BulkRunsHub/dedupedStatusFetch.d.ts +5 -0
- package/dist/views/BulkRunsHub/dedupedStatusFetch.js +45 -0
- package/dist/views/BulkRunsHub/index.d.ts +17 -0
- package/dist/views/BulkRunsHub/index.js +80 -0
- package/dist/views/BulkRunsHub/urlFilters.d.ts +14 -0
- package/dist/views/BulkRunsHub/urlFilters.js +50 -0
- package/dist/views/BulkRunsHub/useBulkRunsList.d.ts +26 -0
- package/dist/views/BulkRunsHub/useBulkRunsList.js +204 -0
- package/dist/views/BulkRunsHub/useUrlFilters.d.ts +10 -0
- package/dist/views/BulkRunsHub/useUrlFilters.js +88 -0
- package/dist/views/TranslationHub/ActiveJobs.d.ts +6 -0
- package/dist/views/TranslationHub/ActiveJobs.js +320 -0
- package/dist/views/TranslationHub/AdvancedPanel.d.ts +17 -0
- package/dist/views/TranslationHub/AdvancedPanel.js +996 -0
- package/dist/views/TranslationHub/AlertBanner.d.ts +6 -0
- package/dist/views/TranslationHub/AlertBanner.js +568 -0
- package/dist/views/TranslationHub/AuditPanel.d.ts +6 -0
- package/dist/views/TranslationHub/AuditPanel.helpers.d.ts +44 -0
- package/dist/views/TranslationHub/AuditPanel.helpers.js +71 -0
- package/dist/views/TranslationHub/AuditPanel.js +1367 -0
- package/dist/views/TranslationHub/BulkTranslate.types.d.ts +242 -0
- package/dist/views/TranslationHub/BulkTranslate.types.js +36 -0
- package/dist/views/TranslationHub/BulkTranslateFailureDrawer.d.ts +19 -0
- package/dist/views/TranslationHub/BulkTranslateFailureDrawer.js +332 -0
- package/dist/views/TranslationHub/BulkTranslateMonitor.d.ts +28 -0
- package/dist/views/TranslationHub/BulkTranslateMonitor.js +305 -0
- package/dist/views/TranslationHub/BulkTranslateNarrowViewportBanner.d.ts +3 -0
- package/dist/views/TranslationHub/BulkTranslateNarrowViewportBanner.js +42 -0
- package/dist/views/TranslationHub/BulkTranslatePostEnqueueTransition.d.ts +26 -0
- package/dist/views/TranslationHub/BulkTranslatePostEnqueueTransition.js +95 -0
- package/dist/views/TranslationHub/BulkTranslatePreflightModal.d.ts +22 -0
- package/dist/views/TranslationHub/BulkTranslatePreflightModal.js +879 -0
- package/dist/views/TranslationHub/BulkTranslateTerminalCard.d.ts +29 -0
- package/dist/views/TranslationHub/BulkTranslateTerminalCard.js +445 -0
- package/dist/views/TranslationHub/BulkTranslateTrigger.d.ts +66 -0
- package/dist/views/TranslationHub/BulkTranslateTrigger.js +161 -0
- package/dist/views/TranslationHub/EditorRecentRunsPanel.d.ts +33 -0
- package/dist/views/TranslationHub/EditorRecentRunsPanel.js +290 -0
- package/dist/views/TranslationHub/Hub.client.d.ts +74 -0
- package/dist/views/TranslationHub/Hub.client.js +357 -0
- package/dist/views/TranslationHub/ModelCombobox.d.ts +14 -0
- package/dist/views/TranslationHub/ModelCombobox.js +415 -0
- package/dist/views/TranslationHub/PerCollectionConfig.d.ts +10 -0
- package/dist/views/TranslationHub/PerCollectionConfig.helpers.d.ts +16 -0
- package/dist/views/TranslationHub/PerCollectionConfig.helpers.js +19 -0
- package/dist/views/TranslationHub/PerCollectionConfig.js +759 -0
- package/dist/views/TranslationHub/SettingsRail.d.ts +11 -0
- package/dist/views/TranslationHub/SettingsRail.js +382 -0
- package/dist/views/TranslationHub/StatusStrip.d.ts +6 -0
- package/dist/views/TranslationHub/StatusStrip.js +451 -0
- package/dist/views/TranslationHub/UsageTable.d.ts +6 -0
- package/dist/views/TranslationHub/UsageTable.helpers.d.ts +69 -0
- package/dist/views/TranslationHub/UsageTable.helpers.js +49 -0
- package/dist/views/TranslationHub/UsageTable.js +1240 -0
- package/dist/views/TranslationHub/alertGrouping.d.ts +70 -0
- package/dist/views/TranslationHub/alertGrouping.js +99 -0
- package/dist/views/TranslationHub/index.d.ts +20 -0
- package/dist/views/TranslationHub/index.js +109 -0
- package/dist/views/TranslationHub/tabNavigation.d.ts +53 -0
- package/dist/views/TranslationHub/tabNavigation.js +74 -0
- package/dist/views/TranslationHub/terminalBannerVisibility.d.ts +33 -0
- package/dist/views/TranslationHub/terminalBannerVisibility.js +124 -0
- package/dist/views/TranslationHub/useBulkTranslateActive.d.ts +49 -0
- package/dist/views/TranslationHub/useBulkTranslateActive.js +251 -0
- package/dist/views/TranslationHub/useFocusTrap.d.ts +6 -0
- package/dist/views/TranslationHub/useFocusTrap.js +81 -0
- package/dist/views/TranslationHub/useTranslationHubUsageSummary.d.ts +77 -0
- package/dist/views/TranslationHub/useTranslationHubUsageSummary.js +267 -0
- package/dist/views/shared/EditorError.d.ts +97 -0
- package/dist/views/shared/EditorError.js +205 -0
- package/dist/views/shared/ModelCell.d.ts +18 -0
- package/dist/views/shared/ModelCell.js +31 -0
- package/dist/views/shared/docHref.d.ts +16 -0
- package/dist/views/shared/docHref.js +26 -0
- package/dist/views/shared/fetch-error-body.d.ts +25 -0
- package/dist/views/shared/fetch-error-body.js +42 -0
- package/dist/views/shared/filterPillStyle.d.ts +35 -0
- package/dist/views/shared/filterPillStyle.js +40 -0
- package/dist/views/shared/format.d.ts +75 -0
- package/dist/views/shared/format.js +131 -0
- package/package.json +141 -0
|
@@ -0,0 +1,759 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
const SECTION_STYLE = {
|
|
5
|
+
background: 'var(--theme-elevation-50)',
|
|
6
|
+
border: '1px solid var(--theme-elevation-150)',
|
|
7
|
+
borderRadius: '6px',
|
|
8
|
+
padding: '1rem 1.25rem'
|
|
9
|
+
};
|
|
10
|
+
const ROW_STYLE = {
|
|
11
|
+
border: '1px solid var(--theme-elevation-150)',
|
|
12
|
+
borderRadius: '6px',
|
|
13
|
+
background: 'var(--theme-elevation-0, #ffffff)'
|
|
14
|
+
};
|
|
15
|
+
const ROW_HEADER_STYLE = {
|
|
16
|
+
padding: '0.6rem 0.85rem',
|
|
17
|
+
display: 'flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
gap: '0.75rem',
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
userSelect: 'none'
|
|
22
|
+
};
|
|
23
|
+
const ROW_BODY_STYLE = {
|
|
24
|
+
padding: '0.75rem 1rem 1rem',
|
|
25
|
+
borderTop: '1px solid var(--theme-elevation-100)',
|
|
26
|
+
display: 'flex',
|
|
27
|
+
flexDirection: 'column',
|
|
28
|
+
gap: '0.75rem'
|
|
29
|
+
};
|
|
30
|
+
const LABEL_STYLE = {
|
|
31
|
+
display: 'block',
|
|
32
|
+
fontSize: '0.7rem',
|
|
33
|
+
fontWeight: 600,
|
|
34
|
+
textTransform: 'uppercase',
|
|
35
|
+
letterSpacing: '0.05em',
|
|
36
|
+
color: 'var(--theme-elevation-500)',
|
|
37
|
+
marginBottom: '0.3rem'
|
|
38
|
+
};
|
|
39
|
+
const TOGGLE_LABEL = {
|
|
40
|
+
display: 'flex',
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
gap: '0.5rem',
|
|
43
|
+
fontSize: '0.85rem',
|
|
44
|
+
cursor: 'pointer',
|
|
45
|
+
color: 'var(--theme-elevation-800)'
|
|
46
|
+
};
|
|
47
|
+
const SMALL_BUTTON = {
|
|
48
|
+
padding: '0.25rem 0.6rem',
|
|
49
|
+
fontSize: '0.7rem',
|
|
50
|
+
background: 'transparent',
|
|
51
|
+
border: '1px solid var(--theme-elevation-150)',
|
|
52
|
+
borderRadius: '4px',
|
|
53
|
+
color: 'var(--theme-elevation-700)',
|
|
54
|
+
cursor: 'pointer'
|
|
55
|
+
};
|
|
56
|
+
const DANGER_BUTTON = {
|
|
57
|
+
...SMALL_BUTTON,
|
|
58
|
+
color: 'var(--theme-error-500, #b91c1c)',
|
|
59
|
+
borderColor: 'var(--theme-error-500, #b91c1c)'
|
|
60
|
+
};
|
|
61
|
+
const PRIMARY_BUTTON = {
|
|
62
|
+
padding: '0.4rem 0.85rem',
|
|
63
|
+
fontSize: '0.8rem',
|
|
64
|
+
background: 'var(--theme-success-500, #16a34a)',
|
|
65
|
+
border: 'none',
|
|
66
|
+
borderRadius: '4px',
|
|
67
|
+
color: '#fff',
|
|
68
|
+
cursor: 'pointer',
|
|
69
|
+
fontWeight: 500
|
|
70
|
+
};
|
|
71
|
+
function summarize(row, fieldCount) {
|
|
72
|
+
const bits = [];
|
|
73
|
+
if (row.enabled === false) {
|
|
74
|
+
bits.push('DISABLED');
|
|
75
|
+
}
|
|
76
|
+
if (row.autoOnPublish === false) {
|
|
77
|
+
bits.push('manual only');
|
|
78
|
+
}
|
|
79
|
+
if (row.targetLocalesOverride?.length) {
|
|
80
|
+
bits.push(`locales: ${row.targetLocalesOverride.join('/')}`);
|
|
81
|
+
}
|
|
82
|
+
if (row.translateSlug) {
|
|
83
|
+
bits.push('slug translated');
|
|
84
|
+
}
|
|
85
|
+
if (row.excludedFieldPaths?.length) {
|
|
86
|
+
bits.push(fieldCount == null ? `${row.excludedFieldPaths.length} fields excluded` : `${row.excludedFieldPaths.length}/${fieldCount} fields excluded`);
|
|
87
|
+
}
|
|
88
|
+
return bits.length === 0 ? 'inherits site-wide defaults' : bits.join(' · ');
|
|
89
|
+
}
|
|
90
|
+
export const PerCollectionConfig = ({ basePath, translationSettings, locales, onSettingsChange })=>{
|
|
91
|
+
const [translatableBySlug, setTranslatableBySlug] = useState(null);
|
|
92
|
+
const [expandedSlugs, setExpandedSlugs] = useState(new Set());
|
|
93
|
+
const [saving, setSaving] = useState(false);
|
|
94
|
+
const [saveError, setSaveError] = useState(null);
|
|
95
|
+
const [savedFlash, setSavedFlash] = useState(null);
|
|
96
|
+
const [showAddPicker, setShowAddPicker] = useState(false);
|
|
97
|
+
// Keep a snapshot ref so concurrent edits don't clobber each other —
|
|
98
|
+
// same pattern SettingsRail uses for the locale toggle race.
|
|
99
|
+
const settingsRef = useRef(translationSettings);
|
|
100
|
+
useEffect(()=>{
|
|
101
|
+
settingsRef.current = translationSettings;
|
|
102
|
+
}, [
|
|
103
|
+
translationSettings
|
|
104
|
+
]);
|
|
105
|
+
// Fetch translatable field map.
|
|
106
|
+
useEffect(()=>{
|
|
107
|
+
let cancelled = false;
|
|
108
|
+
fetch(`${basePath}/api/ai-translate/client-config`, {
|
|
109
|
+
credentials: 'include'
|
|
110
|
+
}).then((r)=>r.ok ? r.json() : Promise.reject(new Error(`HTTP ${r.status}`))).then((d)=>{
|
|
111
|
+
if (cancelled) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
setTranslatableBySlug(d.translatableFieldsBySlug ?? {});
|
|
115
|
+
}).catch(()=>{
|
|
116
|
+
if (cancelled) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Without the field map the editor degrades — show counts only
|
|
120
|
+
// and no field checkboxes — but locale + toggle editing still
|
|
121
|
+
// works. Set to empty object to mark as "loaded, just empty".
|
|
122
|
+
setTranslatableBySlug({});
|
|
123
|
+
});
|
|
124
|
+
return ()=>{
|
|
125
|
+
cancelled = true;
|
|
126
|
+
};
|
|
127
|
+
}, [
|
|
128
|
+
basePath
|
|
129
|
+
]);
|
|
130
|
+
// Auto-clear save flash.
|
|
131
|
+
useEffect(()=>{
|
|
132
|
+
if (!savedFlash) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const t = setTimeout(()=>setSavedFlash(null), 2000);
|
|
136
|
+
return ()=>clearTimeout(t);
|
|
137
|
+
}, [
|
|
138
|
+
savedFlash
|
|
139
|
+
]);
|
|
140
|
+
const rows = translationSettings?.perCollection ?? [];
|
|
141
|
+
const configuredSlugs = useMemo(()=>new Set(rows.map((r)=>r.slug)), [
|
|
142
|
+
rows
|
|
143
|
+
]);
|
|
144
|
+
const unconfiguredSlugs = useMemo(()=>Object.keys(translatableBySlug ?? {}).filter((s)=>!configuredSlugs.has(s)), [
|
|
145
|
+
translatableBySlug,
|
|
146
|
+
configuredSlugs
|
|
147
|
+
]);
|
|
148
|
+
const targetLocales = locales.locales.filter((l)=>l.code !== locales.defaultLocale).map((l)=>l.code);
|
|
149
|
+
function toggleExpand(slug) {
|
|
150
|
+
setExpandedSlugs((prev)=>{
|
|
151
|
+
const next = new Set(prev);
|
|
152
|
+
if (next.has(slug)) {
|
|
153
|
+
next.delete(slug);
|
|
154
|
+
} else {
|
|
155
|
+
next.add(slug);
|
|
156
|
+
}
|
|
157
|
+
return next;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
async function patchPerCollection(nextRows) {
|
|
161
|
+
setSaveError(null);
|
|
162
|
+
setSaving(true);
|
|
163
|
+
try {
|
|
164
|
+
const res = await fetch(`${basePath}/api/globals/translation-settings`, {
|
|
165
|
+
method: 'POST',
|
|
166
|
+
credentials: 'include',
|
|
167
|
+
headers: {
|
|
168
|
+
'content-type': 'application/json'
|
|
169
|
+
},
|
|
170
|
+
body: JSON.stringify({
|
|
171
|
+
perCollection: nextRows
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
if (!res.ok) {
|
|
175
|
+
const text = await res.text();
|
|
176
|
+
throw new Error(`HTTP ${res.status}: ${text.slice(0, 200)}`);
|
|
177
|
+
}
|
|
178
|
+
const json = await res.json();
|
|
179
|
+
const updated = json.result ?? json.doc ?? json;
|
|
180
|
+
onSettingsChange(updated);
|
|
181
|
+
setSavedFlash('Saved');
|
|
182
|
+
} catch (e) {
|
|
183
|
+
setSaveError(e instanceof Error ? e.message : String(e));
|
|
184
|
+
} finally{
|
|
185
|
+
setSaving(false);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function updateRow(slug, patch) {
|
|
189
|
+
const current = settingsRef.current?.perCollection ?? [];
|
|
190
|
+
const next = current.map((r)=>r.slug === slug ? {
|
|
191
|
+
...r,
|
|
192
|
+
...patch
|
|
193
|
+
} : r);
|
|
194
|
+
return patchPerCollection(next);
|
|
195
|
+
}
|
|
196
|
+
function addOverride(slug) {
|
|
197
|
+
const current = settingsRef.current?.perCollection ?? [];
|
|
198
|
+
if (current.some((r)=>r.slug === slug)) {
|
|
199
|
+
return Promise.resolve();
|
|
200
|
+
}
|
|
201
|
+
const next = [
|
|
202
|
+
...current,
|
|
203
|
+
{
|
|
204
|
+
slug,
|
|
205
|
+
enabled: true,
|
|
206
|
+
autoOnPublish: true,
|
|
207
|
+
targetLocalesOverride: null,
|
|
208
|
+
excludedFieldPaths: null,
|
|
209
|
+
translateSlug: false
|
|
210
|
+
}
|
|
211
|
+
];
|
|
212
|
+
setExpandedSlugs((prev)=>new Set(prev).add(slug));
|
|
213
|
+
setShowAddPicker(false);
|
|
214
|
+
return patchPerCollection(next);
|
|
215
|
+
}
|
|
216
|
+
function removeOverride(slug) {
|
|
217
|
+
const current = settingsRef.current?.perCollection ?? [];
|
|
218
|
+
const next = current.filter((r)=>r.slug !== slug);
|
|
219
|
+
setExpandedSlugs((prev)=>{
|
|
220
|
+
const n = new Set(prev);
|
|
221
|
+
n.delete(slug);
|
|
222
|
+
return n;
|
|
223
|
+
});
|
|
224
|
+
return patchPerCollection(next);
|
|
225
|
+
}
|
|
226
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
227
|
+
style: {
|
|
228
|
+
display: 'flex',
|
|
229
|
+
flexDirection: 'column',
|
|
230
|
+
gap: '0.75rem'
|
|
231
|
+
},
|
|
232
|
+
children: /*#__PURE__*/ _jsxs("section", {
|
|
233
|
+
style: SECTION_STYLE,
|
|
234
|
+
children: [
|
|
235
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
236
|
+
style: {
|
|
237
|
+
display: 'flex',
|
|
238
|
+
justifyContent: 'space-between',
|
|
239
|
+
alignItems: 'baseline',
|
|
240
|
+
marginBottom: '0.4rem'
|
|
241
|
+
},
|
|
242
|
+
children: [
|
|
243
|
+
/*#__PURE__*/ _jsx("h3", {
|
|
244
|
+
style: {
|
|
245
|
+
margin: 0,
|
|
246
|
+
fontSize: '1rem',
|
|
247
|
+
color: 'var(--theme-elevation-1000)'
|
|
248
|
+
},
|
|
249
|
+
children: "Per-collection configuration"
|
|
250
|
+
}),
|
|
251
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
252
|
+
style: {
|
|
253
|
+
fontSize: '0.75rem',
|
|
254
|
+
color: 'var(--theme-elevation-500)'
|
|
255
|
+
},
|
|
256
|
+
children: [
|
|
257
|
+
rows.length,
|
|
258
|
+
" override",
|
|
259
|
+
rows.length === 1 ? '' : 's',
|
|
260
|
+
' · ',
|
|
261
|
+
unconfiguredSlugs.length,
|
|
262
|
+
" inherit defaults"
|
|
263
|
+
]
|
|
264
|
+
})
|
|
265
|
+
]
|
|
266
|
+
}),
|
|
267
|
+
/*#__PURE__*/ _jsx("p", {
|
|
268
|
+
style: {
|
|
269
|
+
margin: '0 0 0.75rem',
|
|
270
|
+
fontSize: '0.8rem',
|
|
271
|
+
color: 'var(--theme-elevation-700)',
|
|
272
|
+
lineHeight: 1.5
|
|
273
|
+
},
|
|
274
|
+
children: "Surfaces without a row use the site-wide settings from the panel above. Add a row to opt a specific collection out, narrow its target locales, or exclude individual fields from translation."
|
|
275
|
+
}),
|
|
276
|
+
saveError && /*#__PURE__*/ _jsx("div", {
|
|
277
|
+
style: {
|
|
278
|
+
padding: '0.5rem 0.75rem',
|
|
279
|
+
background: 'var(--theme-error-100, #fee2e2)',
|
|
280
|
+
border: '1px solid var(--theme-error-500, #b91c1c)',
|
|
281
|
+
borderRadius: '4px',
|
|
282
|
+
color: 'var(--theme-error-500, #b91c1c)',
|
|
283
|
+
fontSize: '0.8rem',
|
|
284
|
+
marginBottom: '0.5rem'
|
|
285
|
+
},
|
|
286
|
+
children: saveError
|
|
287
|
+
}),
|
|
288
|
+
savedFlash && /*#__PURE__*/ _jsx("div", {
|
|
289
|
+
style: {
|
|
290
|
+
padding: '0.4rem 0.75rem',
|
|
291
|
+
background: 'var(--theme-success-100, #d1fae5)',
|
|
292
|
+
border: '1px solid var(--theme-success-500, #16a34a)',
|
|
293
|
+
borderRadius: '4px',
|
|
294
|
+
color: 'var(--theme-success-500, #16a34a)',
|
|
295
|
+
fontSize: '0.8rem',
|
|
296
|
+
marginBottom: '0.5rem'
|
|
297
|
+
},
|
|
298
|
+
children: savedFlash
|
|
299
|
+
}),
|
|
300
|
+
rows.length === 0 ? /*#__PURE__*/ _jsx("p", {
|
|
301
|
+
style: {
|
|
302
|
+
margin: 0,
|
|
303
|
+
fontSize: '0.85rem',
|
|
304
|
+
color: 'var(--theme-elevation-500)',
|
|
305
|
+
padding: '0.75rem',
|
|
306
|
+
background: 'var(--theme-elevation-50)',
|
|
307
|
+
borderRadius: '4px',
|
|
308
|
+
textAlign: 'center'
|
|
309
|
+
},
|
|
310
|
+
children: "No overrides yet. Every tracked surface uses site-wide defaults."
|
|
311
|
+
}) : /*#__PURE__*/ _jsx("div", {
|
|
312
|
+
style: {
|
|
313
|
+
display: 'flex',
|
|
314
|
+
flexDirection: 'column',
|
|
315
|
+
gap: '0.5rem'
|
|
316
|
+
},
|
|
317
|
+
children: rows.map((row)=>{
|
|
318
|
+
const isExpanded = expandedSlugs.has(row.slug);
|
|
319
|
+
const fields = translatableBySlug?.[row.slug] ?? null;
|
|
320
|
+
const summary = summarize(row, fields?.length ?? null);
|
|
321
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
322
|
+
style: ROW_STYLE,
|
|
323
|
+
children: [
|
|
324
|
+
/*#__PURE__*/ _jsxs("button", {
|
|
325
|
+
"aria-expanded": isExpanded,
|
|
326
|
+
onClick: ()=>toggleExpand(row.slug),
|
|
327
|
+
style: {
|
|
328
|
+
...ROW_HEADER_STYLE,
|
|
329
|
+
background: 'transparent',
|
|
330
|
+
border: 'none',
|
|
331
|
+
width: '100%',
|
|
332
|
+
textAlign: 'left',
|
|
333
|
+
font: 'inherit',
|
|
334
|
+
color: 'inherit'
|
|
335
|
+
},
|
|
336
|
+
type: "button",
|
|
337
|
+
children: [
|
|
338
|
+
/*#__PURE__*/ _jsx("span", {
|
|
339
|
+
"aria-hidden": "true",
|
|
340
|
+
style: {
|
|
341
|
+
display: 'inline-block',
|
|
342
|
+
width: '0.75rem',
|
|
343
|
+
fontSize: '0.65rem',
|
|
344
|
+
color: 'var(--theme-elevation-500)',
|
|
345
|
+
transform: isExpanded ? 'rotate(90deg)' : 'rotate(0deg)',
|
|
346
|
+
transition: 'transform 80ms ease'
|
|
347
|
+
},
|
|
348
|
+
children: "▶"
|
|
349
|
+
}),
|
|
350
|
+
/*#__PURE__*/ _jsx("code", {
|
|
351
|
+
style: {
|
|
352
|
+
fontSize: '0.85rem',
|
|
353
|
+
fontWeight: 600,
|
|
354
|
+
color: row.enabled === false ? 'var(--theme-error-500)' : 'var(--theme-elevation-1000)'
|
|
355
|
+
},
|
|
356
|
+
children: row.slug
|
|
357
|
+
}),
|
|
358
|
+
/*#__PURE__*/ _jsx("span", {
|
|
359
|
+
style: {
|
|
360
|
+
fontSize: '0.75rem',
|
|
361
|
+
color: 'var(--theme-elevation-500)',
|
|
362
|
+
flex: 1
|
|
363
|
+
},
|
|
364
|
+
children: summary
|
|
365
|
+
})
|
|
366
|
+
]
|
|
367
|
+
}),
|
|
368
|
+
isExpanded && /*#__PURE__*/ _jsx(PerCollectionRowEditor, {
|
|
369
|
+
fields: fields,
|
|
370
|
+
onRemove: ()=>removeOverride(row.slug),
|
|
371
|
+
onUpdate: (patch)=>updateRow(row.slug, patch),
|
|
372
|
+
row: row,
|
|
373
|
+
saving: saving,
|
|
374
|
+
targetLocales: targetLocales
|
|
375
|
+
})
|
|
376
|
+
]
|
|
377
|
+
}, row.slug);
|
|
378
|
+
})
|
|
379
|
+
}),
|
|
380
|
+
/*#__PURE__*/ _jsx("div", {
|
|
381
|
+
style: {
|
|
382
|
+
marginTop: '1rem'
|
|
383
|
+
},
|
|
384
|
+
children: showAddPicker ? /*#__PURE__*/ _jsxs("div", {
|
|
385
|
+
style: {
|
|
386
|
+
display: 'flex',
|
|
387
|
+
gap: '0.5rem',
|
|
388
|
+
alignItems: 'center',
|
|
389
|
+
flexWrap: 'wrap'
|
|
390
|
+
},
|
|
391
|
+
children: [
|
|
392
|
+
/*#__PURE__*/ _jsxs("select", {
|
|
393
|
+
defaultValue: "",
|
|
394
|
+
disabled: saving || unconfiguredSlugs.length === 0,
|
|
395
|
+
onChange: (e)=>{
|
|
396
|
+
if (e.target.value) {
|
|
397
|
+
addOverride(e.target.value);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
style: {
|
|
401
|
+
padding: '0.4rem 0.6rem',
|
|
402
|
+
background: 'var(--theme-elevation-50)',
|
|
403
|
+
border: '1px solid var(--theme-elevation-150)',
|
|
404
|
+
borderRadius: '4px',
|
|
405
|
+
fontSize: '0.85rem',
|
|
406
|
+
color: 'var(--theme-elevation-1000)'
|
|
407
|
+
},
|
|
408
|
+
children: [
|
|
409
|
+
/*#__PURE__*/ _jsx("option", {
|
|
410
|
+
value: "",
|
|
411
|
+
children: unconfiguredSlugs.length === 0 ? 'All surfaces already configured' : 'Pick a surface…'
|
|
412
|
+
}),
|
|
413
|
+
unconfiguredSlugs.map((s)=>/*#__PURE__*/ _jsx("option", {
|
|
414
|
+
value: s,
|
|
415
|
+
children: s
|
|
416
|
+
}, s))
|
|
417
|
+
]
|
|
418
|
+
}),
|
|
419
|
+
/*#__PURE__*/ _jsx("button", {
|
|
420
|
+
onClick: ()=>setShowAddPicker(false),
|
|
421
|
+
style: SMALL_BUTTON,
|
|
422
|
+
type: "button",
|
|
423
|
+
children: "Cancel"
|
|
424
|
+
})
|
|
425
|
+
]
|
|
426
|
+
}) : /*#__PURE__*/ _jsx("button", {
|
|
427
|
+
disabled: unconfiguredSlugs.length === 0,
|
|
428
|
+
onClick: ()=>setShowAddPicker(true),
|
|
429
|
+
style: {
|
|
430
|
+
...PRIMARY_BUTTON,
|
|
431
|
+
opacity: unconfiguredSlugs.length === 0 ? 0.5 : 1,
|
|
432
|
+
cursor: unconfiguredSlugs.length === 0 ? 'not-allowed' : 'pointer'
|
|
433
|
+
},
|
|
434
|
+
type: "button",
|
|
435
|
+
children: "+ Add override"
|
|
436
|
+
})
|
|
437
|
+
})
|
|
438
|
+
]
|
|
439
|
+
})
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
// ---------------------------------------------------------------------------
|
|
443
|
+
// Per-row inline editor
|
|
444
|
+
// ---------------------------------------------------------------------------
|
|
445
|
+
const PerCollectionRowEditor = ({ row, fields, targetLocales, saving, onUpdate, onRemove })=>{
|
|
446
|
+
const excluded = new Set(row.excludedFieldPaths ?? []);
|
|
447
|
+
// Two-step remove confirmation. First click flips this flag and the
|
|
448
|
+
// button label changes to "Confirm remove"; a second click actually
|
|
449
|
+
// calls onRemove. Replaces `window.confirm()` which biome's `noAlert`
|
|
450
|
+
// rule rejects (and which most teams ban for UX reasons anyway).
|
|
451
|
+
const [confirmingRemove, setConfirmingRemove] = useState(false);
|
|
452
|
+
function toggleLocale(loc) {
|
|
453
|
+
const current = row.targetLocalesOverride ?? [];
|
|
454
|
+
const next = current.includes(loc) ? current.filter((l)=>l !== loc) : [
|
|
455
|
+
...current,
|
|
456
|
+
loc
|
|
457
|
+
];
|
|
458
|
+
onUpdate({
|
|
459
|
+
targetLocalesOverride: next.length === 0 ? null : next
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
function toggleField(path) {
|
|
463
|
+
const next = new Set(excluded);
|
|
464
|
+
if (next.has(path)) {
|
|
465
|
+
next.delete(path);
|
|
466
|
+
} else {
|
|
467
|
+
next.add(path);
|
|
468
|
+
}
|
|
469
|
+
onUpdate({
|
|
470
|
+
excludedFieldPaths: next.size === 0 ? null : Array.from(next)
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
function selectAllFields() {
|
|
474
|
+
if (!fields) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
onUpdate({
|
|
478
|
+
excludedFieldPaths: [
|
|
479
|
+
...fields
|
|
480
|
+
]
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
function clearAllFields() {
|
|
484
|
+
onUpdate({
|
|
485
|
+
excludedFieldPaths: null
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
489
|
+
style: ROW_BODY_STYLE,
|
|
490
|
+
children: [
|
|
491
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
492
|
+
style: {
|
|
493
|
+
display: 'flex',
|
|
494
|
+
flexWrap: 'wrap',
|
|
495
|
+
gap: '1.5rem'
|
|
496
|
+
},
|
|
497
|
+
children: [
|
|
498
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
499
|
+
style: TOGGLE_LABEL,
|
|
500
|
+
children: [
|
|
501
|
+
/*#__PURE__*/ _jsx("input", {
|
|
502
|
+
checked: row.enabled !== false,
|
|
503
|
+
disabled: saving,
|
|
504
|
+
onChange: (e)=>onUpdate({
|
|
505
|
+
enabled: e.target.checked
|
|
506
|
+
}),
|
|
507
|
+
type: "checkbox"
|
|
508
|
+
}),
|
|
509
|
+
"Enabled (kill switch)"
|
|
510
|
+
]
|
|
511
|
+
}),
|
|
512
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
513
|
+
style: TOGGLE_LABEL,
|
|
514
|
+
children: [
|
|
515
|
+
/*#__PURE__*/ _jsx("input", {
|
|
516
|
+
checked: row.autoOnPublish !== false,
|
|
517
|
+
disabled: saving || row.enabled === false,
|
|
518
|
+
onChange: (e)=>onUpdate({
|
|
519
|
+
autoOnPublish: e.target.checked
|
|
520
|
+
}),
|
|
521
|
+
type: "checkbox"
|
|
522
|
+
}),
|
|
523
|
+
"Auto-translate on publish"
|
|
524
|
+
]
|
|
525
|
+
}),
|
|
526
|
+
/*#__PURE__*/ _jsxs("label", {
|
|
527
|
+
style: TOGGLE_LABEL,
|
|
528
|
+
children: [
|
|
529
|
+
/*#__PURE__*/ _jsx("input", {
|
|
530
|
+
checked: !!row.translateSlug,
|
|
531
|
+
disabled: saving || row.enabled === false,
|
|
532
|
+
onChange: (e)=>onUpdate({
|
|
533
|
+
translateSlug: e.target.checked
|
|
534
|
+
}),
|
|
535
|
+
type: "checkbox"
|
|
536
|
+
}),
|
|
537
|
+
"Translate slug field"
|
|
538
|
+
]
|
|
539
|
+
})
|
|
540
|
+
]
|
|
541
|
+
}),
|
|
542
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
543
|
+
children: [
|
|
544
|
+
/*#__PURE__*/ _jsx("span", {
|
|
545
|
+
style: LABEL_STYLE,
|
|
546
|
+
children: "Target locales (this surface only)"
|
|
547
|
+
}),
|
|
548
|
+
/*#__PURE__*/ _jsx("div", {
|
|
549
|
+
style: {
|
|
550
|
+
display: 'flex',
|
|
551
|
+
flexWrap: 'wrap',
|
|
552
|
+
gap: '0.5rem'
|
|
553
|
+
},
|
|
554
|
+
children: targetLocales.length === 0 ? /*#__PURE__*/ _jsx("span", {
|
|
555
|
+
style: {
|
|
556
|
+
fontSize: '0.8rem',
|
|
557
|
+
color: 'var(--theme-elevation-500)'
|
|
558
|
+
},
|
|
559
|
+
children: "No target locales configured."
|
|
560
|
+
}) : targetLocales.map((loc)=>{
|
|
561
|
+
const isOn = (row.targetLocalesOverride ?? []).includes(loc);
|
|
562
|
+
return /*#__PURE__*/ _jsxs("label", {
|
|
563
|
+
style: {
|
|
564
|
+
...TOGGLE_LABEL,
|
|
565
|
+
padding: '0.25rem 0.6rem',
|
|
566
|
+
border: `1px solid ${isOn ? 'var(--theme-success-500)' : 'var(--theme-elevation-150)'}`,
|
|
567
|
+
borderRadius: '4px',
|
|
568
|
+
background: isOn ? 'var(--theme-success-100, #d1fae5)' : 'transparent',
|
|
569
|
+
color: isOn ? 'var(--theme-success-500)' : 'var(--theme-elevation-700)'
|
|
570
|
+
},
|
|
571
|
+
children: [
|
|
572
|
+
/*#__PURE__*/ _jsx("input", {
|
|
573
|
+
checked: isOn,
|
|
574
|
+
disabled: saving || row.enabled === false,
|
|
575
|
+
onChange: ()=>toggleLocale(loc),
|
|
576
|
+
type: "checkbox"
|
|
577
|
+
}),
|
|
578
|
+
loc.toUpperCase()
|
|
579
|
+
]
|
|
580
|
+
}, loc);
|
|
581
|
+
})
|
|
582
|
+
}),
|
|
583
|
+
/*#__PURE__*/ _jsx("p", {
|
|
584
|
+
style: {
|
|
585
|
+
margin: '0.3rem 0 0',
|
|
586
|
+
fontSize: '0.7rem',
|
|
587
|
+
color: 'var(--theme-elevation-500)'
|
|
588
|
+
},
|
|
589
|
+
children: "Empty selection = inherit site-wide locale list."
|
|
590
|
+
})
|
|
591
|
+
]
|
|
592
|
+
}),
|
|
593
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
594
|
+
children: [
|
|
595
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
596
|
+
style: {
|
|
597
|
+
display: 'flex',
|
|
598
|
+
justifyContent: 'space-between',
|
|
599
|
+
alignItems: 'baseline',
|
|
600
|
+
marginBottom: '0.3rem'
|
|
601
|
+
},
|
|
602
|
+
children: [
|
|
603
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
604
|
+
style: LABEL_STYLE,
|
|
605
|
+
children: [
|
|
606
|
+
"Field exclusions",
|
|
607
|
+
fields && /*#__PURE__*/ _jsxs("span", {
|
|
608
|
+
style: {
|
|
609
|
+
textTransform: 'none',
|
|
610
|
+
fontWeight: 400,
|
|
611
|
+
color: 'var(--theme-elevation-700)',
|
|
612
|
+
marginLeft: '0.4rem'
|
|
613
|
+
},
|
|
614
|
+
children: [
|
|
615
|
+
"(",
|
|
616
|
+
excluded.size,
|
|
617
|
+
" of ",
|
|
618
|
+
fields.length,
|
|
619
|
+
" excluded)"
|
|
620
|
+
]
|
|
621
|
+
})
|
|
622
|
+
]
|
|
623
|
+
}),
|
|
624
|
+
fields && fields.length > 0 && /*#__PURE__*/ _jsxs("div", {
|
|
625
|
+
style: {
|
|
626
|
+
display: 'flex',
|
|
627
|
+
gap: '0.3rem'
|
|
628
|
+
},
|
|
629
|
+
children: [
|
|
630
|
+
/*#__PURE__*/ _jsx("button", {
|
|
631
|
+
disabled: saving || excluded.size === 0,
|
|
632
|
+
onClick: clearAllFields,
|
|
633
|
+
style: SMALL_BUTTON,
|
|
634
|
+
type: "button",
|
|
635
|
+
children: "Translate all"
|
|
636
|
+
}),
|
|
637
|
+
/*#__PURE__*/ _jsx("button", {
|
|
638
|
+
disabled: saving || excluded.size === fields.length,
|
|
639
|
+
onClick: selectAllFields,
|
|
640
|
+
style: SMALL_BUTTON,
|
|
641
|
+
type: "button",
|
|
642
|
+
children: "Exclude all"
|
|
643
|
+
})
|
|
644
|
+
]
|
|
645
|
+
})
|
|
646
|
+
]
|
|
647
|
+
}),
|
|
648
|
+
fields === null && /*#__PURE__*/ _jsx("p", {
|
|
649
|
+
style: {
|
|
650
|
+
margin: 0,
|
|
651
|
+
fontSize: '0.8rem',
|
|
652
|
+
color: 'var(--theme-elevation-500)'
|
|
653
|
+
},
|
|
654
|
+
children: "Loading field paths…"
|
|
655
|
+
}),
|
|
656
|
+
fields !== null && fields.length === 0 && /*#__PURE__*/ _jsx("p", {
|
|
657
|
+
style: {
|
|
658
|
+
margin: 0,
|
|
659
|
+
fontSize: '0.8rem',
|
|
660
|
+
color: 'var(--theme-elevation-500)'
|
|
661
|
+
},
|
|
662
|
+
children: "No translatable fields detected for this surface. Plugin client-config didn't return any paths — it may not be a registered surface or it has no localized fields."
|
|
663
|
+
}),
|
|
664
|
+
fields !== null && fields.length > 0 && /*#__PURE__*/ _jsx("div", {
|
|
665
|
+
style: {
|
|
666
|
+
display: 'grid',
|
|
667
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(220px, 1fr))',
|
|
668
|
+
gap: '0.3rem',
|
|
669
|
+
maxHeight: '280px',
|
|
670
|
+
overflowY: 'auto',
|
|
671
|
+
padding: '0.5rem',
|
|
672
|
+
background: 'var(--theme-elevation-50)',
|
|
673
|
+
border: '1px solid var(--theme-elevation-100)',
|
|
674
|
+
borderRadius: '4px'
|
|
675
|
+
},
|
|
676
|
+
children: fields.map((path)=>{
|
|
677
|
+
const isExcluded = excluded.has(path);
|
|
678
|
+
return /*#__PURE__*/ _jsxs("label", {
|
|
679
|
+
style: {
|
|
680
|
+
...TOGGLE_LABEL,
|
|
681
|
+
fontSize: '0.75rem',
|
|
682
|
+
fontFamily: 'monospace',
|
|
683
|
+
padding: '0.2rem 0.3rem',
|
|
684
|
+
color: isExcluded ? 'var(--theme-elevation-500)' : 'var(--theme-elevation-900)',
|
|
685
|
+
textDecoration: isExcluded ? 'line-through' : 'none'
|
|
686
|
+
},
|
|
687
|
+
title: isExcluded ? `${path} — excluded, will NOT be translated` : `${path} — included in translation`,
|
|
688
|
+
children: [
|
|
689
|
+
/*#__PURE__*/ _jsx("input", {
|
|
690
|
+
checked: !isExcluded,
|
|
691
|
+
disabled: saving || row.enabled === false,
|
|
692
|
+
onChange: ()=>toggleField(path),
|
|
693
|
+
type: "checkbox"
|
|
694
|
+
}),
|
|
695
|
+
path
|
|
696
|
+
]
|
|
697
|
+
}, path);
|
|
698
|
+
})
|
|
699
|
+
}),
|
|
700
|
+
/*#__PURE__*/ _jsx("p", {
|
|
701
|
+
style: {
|
|
702
|
+
margin: '0.3rem 0 0',
|
|
703
|
+
fontSize: '0.7rem',
|
|
704
|
+
color: 'var(--theme-elevation-500)'
|
|
705
|
+
},
|
|
706
|
+
children: "Uncheck a field to exclude it from translation runs. Applies to both auto-translate and the manual Translate dialog."
|
|
707
|
+
})
|
|
708
|
+
]
|
|
709
|
+
}),
|
|
710
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
711
|
+
style: {
|
|
712
|
+
display: 'flex',
|
|
713
|
+
justifyContent: 'flex-end',
|
|
714
|
+
gap: '0.5rem',
|
|
715
|
+
alignItems: 'center'
|
|
716
|
+
},
|
|
717
|
+
children: [
|
|
718
|
+
confirmingRemove && /*#__PURE__*/ _jsxs(_Fragment, {
|
|
719
|
+
children: [
|
|
720
|
+
/*#__PURE__*/ _jsxs("span", {
|
|
721
|
+
style: {
|
|
722
|
+
fontSize: '0.75rem',
|
|
723
|
+
color: 'var(--theme-elevation-700)'
|
|
724
|
+
},
|
|
725
|
+
children: [
|
|
726
|
+
'Revert "',
|
|
727
|
+
row.slug,
|
|
728
|
+
'" to site-wide defaults?'
|
|
729
|
+
]
|
|
730
|
+
}),
|
|
731
|
+
/*#__PURE__*/ _jsx("button", {
|
|
732
|
+
disabled: saving,
|
|
733
|
+
onClick: ()=>setConfirmingRemove(false),
|
|
734
|
+
style: SMALL_BUTTON,
|
|
735
|
+
type: "button",
|
|
736
|
+
children: "Cancel"
|
|
737
|
+
})
|
|
738
|
+
]
|
|
739
|
+
}),
|
|
740
|
+
/*#__PURE__*/ _jsx("button", {
|
|
741
|
+
disabled: saving,
|
|
742
|
+
onClick: ()=>{
|
|
743
|
+
if (confirmingRemove) {
|
|
744
|
+
onRemove();
|
|
745
|
+
setConfirmingRemove(false);
|
|
746
|
+
} else {
|
|
747
|
+
setConfirmingRemove(true);
|
|
748
|
+
}
|
|
749
|
+
},
|
|
750
|
+
style: DANGER_BUTTON,
|
|
751
|
+
type: "button",
|
|
752
|
+
children: confirmingRemove ? 'Confirm remove' : 'Remove override'
|
|
753
|
+
})
|
|
754
|
+
]
|
|
755
|
+
})
|
|
756
|
+
]
|
|
757
|
+
});
|
|
758
|
+
};
|
|
759
|
+
export default PerCollectionConfig;
|