@prenta/admin 2.9.3 → 2.10.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/CHANGELOG.md +36 -0
- package/dist/AdminRoot.d.ts.map +1 -1
- package/dist/AdminRoot.js +5 -3
- package/dist/AdminRoot.js.map +1 -1
- package/dist/__tests__/components/attribution-rows.test.js +1 -1
- package/dist/__tests__/components/attribution-rows.test.js.map +1 -1
- package/dist/__tests__/components/date-range-picker.test.d.ts +2 -0
- package/dist/__tests__/components/date-range-picker.test.d.ts.map +1 -0
- package/dist/__tests__/components/date-range-picker.test.js +59 -0
- package/dist/__tests__/components/date-range-picker.test.js.map +1 -0
- package/dist/__tests__/components/form-build-model.test.d.ts +2 -0
- package/dist/__tests__/components/form-build-model.test.d.ts.map +1 -0
- package/dist/__tests__/components/form-build-model.test.js +162 -0
- package/dist/__tests__/components/form-build-model.test.js.map +1 -0
- package/dist/__tests__/components/form-build.test.d.ts +2 -0
- package/dist/__tests__/components/form-build.test.d.ts.map +1 -0
- package/dist/__tests__/components/form-build.test.js +120 -0
- package/dist/__tests__/components/form-build.test.js.map +1 -0
- package/dist/__tests__/components/qa-a11y.render.test.js +1 -17
- package/dist/__tests__/components/qa-a11y.render.test.js.map +1 -1
- package/dist/__tests__/lib/batch-wizard.test.js +2 -0
- package/dist/__tests__/lib/batch-wizard.test.js.map +1 -1
- package/dist/__tests__/lib/forms-settings-normalize.test.d.ts +2 -0
- package/dist/__tests__/lib/forms-settings-normalize.test.d.ts.map +1 -0
- package/dist/__tests__/lib/forms-settings-normalize.test.js +16 -0
- package/dist/__tests__/lib/forms-settings-normalize.test.js.map +1 -0
- package/dist/__tests__/views/dashboard.test.js +105 -30
- package/dist/__tests__/views/dashboard.test.js.map +1 -1
- package/dist/__tests__/views/form-editor.render.test.js +17 -9
- package/dist/__tests__/views/form-editor.render.test.js.map +1 -1
- package/dist/__tests__/views/form-entries.render.test.js +23 -9
- package/dist/__tests__/views/form-entries.render.test.js.map +1 -1
- package/dist/__tests__/views/form-submissions.render.test.js +13 -14
- package/dist/__tests__/views/form-submissions.render.test.js.map +1 -1
- package/dist/__tests__/views/forms-list.render.test.js +139 -16
- package/dist/__tests__/views/forms-list.render.test.js.map +1 -1
- package/dist/__tests__/views/forms-settings.fixture.d.ts +3 -0
- package/dist/__tests__/views/forms-settings.fixture.d.ts.map +1 -0
- package/dist/__tests__/views/forms-settings.fixture.js +31 -0
- package/dist/__tests__/views/forms-settings.fixture.js.map +1 -0
- package/dist/__tests__/views/forms-settings.render.test.d.ts +2 -0
- package/dist/__tests__/views/forms-settings.render.test.d.ts.map +1 -0
- package/dist/__tests__/views/forms-settings.render.test.js +120 -0
- package/dist/__tests__/views/forms-settings.render.test.js.map +1 -0
- package/dist/__tests__/views/inbox-format.test.d.ts +2 -0
- package/dist/__tests__/views/inbox-format.test.d.ts.map +1 -0
- package/dist/__tests__/views/inbox-format.test.js +47 -0
- package/dist/__tests__/views/inbox-format.test.js.map +1 -0
- package/dist/__tests__/views/jobs-wizard.render.test.js +17 -3
- package/dist/__tests__/views/jobs-wizard.render.test.js.map +1 -1
- package/dist/__tests__/views/onboarding-block.render.test.js +9 -7
- package/dist/__tests__/views/onboarding-block.render.test.js.map +1 -1
- package/dist/components/forms/BlocklistDialog.d.ts +19 -0
- package/dist/components/forms/BlocklistDialog.d.ts.map +1 -0
- package/dist/components/forms/BlocklistDialog.js +225 -0
- package/dist/components/forms/BlocklistDialog.js.map +1 -0
- package/dist/components/forms/ExportMenu.d.ts +3 -1
- package/dist/components/forms/ExportMenu.d.ts.map +1 -1
- package/dist/components/forms/ExportMenu.js +2 -2
- package/dist/components/forms/ExportMenu.js.map +1 -1
- package/dist/components/forms/FieldOptions.d.ts +11 -0
- package/dist/components/forms/FieldOptions.d.ts.map +1 -0
- package/dist/components/forms/FieldOptions.js +106 -0
- package/dist/components/forms/FieldOptions.js.map +1 -0
- package/dist/components/forms/FormBuild.d.ts +11 -0
- package/dist/components/forms/FormBuild.d.ts.map +1 -0
- package/dist/components/forms/FormBuild.js +299 -0
- package/dist/components/forms/FormBuild.js.map +1 -0
- package/dist/components/forms/FormsListTable.d.ts +14 -0
- package/dist/components/forms/FormsListTable.d.ts.map +1 -0
- package/dist/components/forms/FormsListTable.js +84 -0
- package/dist/components/forms/FormsListTable.js.map +1 -0
- package/dist/components/forms/form-build-model.d.ts +74 -0
- package/dist/components/forms/form-build-model.d.ts.map +1 -0
- package/dist/components/forms/form-build-model.js +297 -0
- package/dist/components/forms/form-build-model.js.map +1 -0
- package/dist/components/forms/form-build-ui.d.ts +35 -0
- package/dist/components/forms/form-build-ui.d.ts.map +1 -0
- package/dist/components/forms/form-build-ui.js +59 -0
- package/dist/components/forms/form-build-ui.js.map +1 -0
- package/dist/components/forms/primitives.d.ts +3 -22
- package/dist/components/forms/primitives.d.ts.map +1 -1
- package/dist/components/forms/primitives.js +4 -19
- package/dist/components/forms/primitives.js.map +1 -1
- package/dist/components/ui/Badge.d.ts +1 -1
- package/dist/components/ui/Card.d.ts +1 -1
- package/dist/components/ui/DateRangePicker.d.ts +7 -0
- package/dist/components/ui/DateRangePicker.d.ts.map +1 -0
- package/dist/components/ui/DateRangePicker.js +112 -0
- package/dist/components/ui/DateRangePicker.js.map +1 -0
- package/dist/components/ui/Input.d.ts +1 -1
- package/dist/components/ui/Segmented.d.ts +3 -1
- package/dist/components/ui/Segmented.d.ts.map +1 -1
- package/dist/components/ui/Segmented.js +3 -3
- package/dist/components/ui/Segmented.js.map +1 -1
- package/dist/components/ui/StatusBadge.d.ts +3 -2
- package/dist/components/ui/StatusBadge.d.ts.map +1 -1
- package/dist/components/ui/StatusBadge.js +9 -3
- package/dist/components/ui/StatusBadge.js.map +1 -1
- package/dist/components/ui/Toggle.d.ts +1 -1
- package/dist/components/ui/Toggle.d.ts.map +1 -1
- package/dist/components/ui/Toggle.js +3 -0
- package/dist/components/ui/Toggle.js.map +1 -1
- package/dist/components/ui/UnderlineTabs.d.ts +5 -1
- package/dist/components/ui/UnderlineTabs.d.ts.map +1 -1
- package/dist/components/ui/UnderlineTabs.js +14 -11
- package/dist/components/ui/UnderlineTabs.js.map +1 -1
- package/dist/layout/Sidebar.js +3 -1
- package/dist/layout/Sidebar.js.map +1 -1
- package/dist/lib/batch-wizard.d.ts +1 -1
- package/dist/lib/batch-wizard.d.ts.map +1 -1
- package/dist/lib/batch-wizard.js +2 -2
- package/dist/lib/batch-wizard.js.map +1 -1
- package/dist/lib/entry-attribution.d.ts +13 -0
- package/dist/lib/entry-attribution.d.ts.map +1 -0
- package/dist/lib/entry-attribution.js +81 -0
- package/dist/lib/entry-attribution.js.map +1 -0
- package/dist/lib/forms-service.d.ts +100 -0
- package/dist/lib/forms-service.d.ts.map +1 -1
- package/dist/lib/forms-service.js +101 -0
- package/dist/lib/forms-service.js.map +1 -1
- package/dist/lib/job-drawer.d.ts +1 -0
- package/dist/lib/job-drawer.d.ts.map +1 -1
- package/dist/lib/job-drawer.js +23 -1
- package/dist/lib/job-drawer.js.map +1 -1
- package/dist/lib/job-view.d.ts +6 -0
- package/dist/lib/job-view.d.ts.map +1 -1
- package/dist/lib/job-view.js +7 -0
- package/dist/lib/job-view.js.map +1 -1
- package/dist/prenta-admin.css +1 -1
- package/dist/router/admin-routes.d.ts.map +1 -1
- package/dist/router/admin-routes.js +1 -0
- package/dist/router/admin-routes.js.map +1 -1
- package/dist/views/Dashboard.d.ts.map +1 -1
- package/dist/views/Dashboard.js +438 -309
- package/dist/views/Dashboard.js.map +1 -1
- package/dist/views/FormEditor.d.ts.map +1 -1
- package/dist/views/FormEditor.js +68 -13
- package/dist/views/FormEditor.js.map +1 -1
- package/dist/views/FormEntries.d.ts.map +1 -1
- package/dist/views/FormEntries.js +4 -190
- package/dist/views/FormEntries.js.map +1 -1
- package/dist/views/FormSubmissions.d.ts +1 -1
- package/dist/views/FormSubmissions.d.ts.map +1 -1
- package/dist/views/FormSubmissions.js +6 -195
- package/dist/views/FormSubmissions.js.map +1 -1
- package/dist/views/Forms.d.ts +11 -1
- package/dist/views/Forms.d.ts.map +1 -1
- package/dist/views/Forms.js +141 -93
- package/dist/views/Forms.js.map +1 -1
- package/dist/views/FormsSettings.d.ts +6 -1
- package/dist/views/FormsSettings.d.ts.map +1 -1
- package/dist/views/FormsSettings.js +434 -30
- package/dist/views/FormsSettings.js.map +1 -1
- package/dist/views/Jobs/DrawerReview.d.ts.map +1 -1
- package/dist/views/Jobs/DrawerReview.js +8 -7
- package/dist/views/Jobs/DrawerReview.js.map +1 -1
- package/dist/views/Jobs/NewBatchJob.d.ts.map +1 -1
- package/dist/views/Jobs/NewBatchJob.js +2 -1
- package/dist/views/Jobs/NewBatchJob.js.map +1 -1
- package/dist/views/SpamFolder.js +1 -1
- package/dist/views/SpamFolder.js.map +1 -1
- package/dist/views/dashboard/Delta.d.ts +7 -0
- package/dist/views/dashboard/Delta.d.ts.map +1 -0
- package/dist/views/dashboard/Delta.js +21 -0
- package/dist/views/dashboard/Delta.js.map +1 -0
- package/dist/views/dashboard/KpiCard.d.ts +22 -0
- package/dist/views/dashboard/KpiCard.d.ts.map +1 -0
- package/dist/views/dashboard/KpiCard.js +15 -0
- package/dist/views/dashboard/KpiCard.js.map +1 -0
- package/dist/views/dashboard/Sparkline.d.ts +11 -0
- package/dist/views/dashboard/Sparkline.d.ts.map +1 -0
- package/dist/views/dashboard/Sparkline.js +15 -0
- package/dist/views/dashboard/Sparkline.js.map +1 -0
- package/dist/views/dashboard/TrendChart.d.ts +8 -0
- package/dist/views/dashboard/TrendChart.d.ts.map +1 -0
- package/dist/views/dashboard/TrendChart.js +98 -0
- package/dist/views/dashboard/TrendChart.js.map +1 -0
- package/dist/views/dashboard/dashboard-date.d.ts +33 -0
- package/dist/views/dashboard/dashboard-date.d.ts.map +1 -0
- package/dist/views/dashboard/dashboard-date.js +136 -0
- package/dist/views/dashboard/dashboard-date.js.map +1 -0
- package/dist/views/entries/EntriesInbox.d.ts +8 -0
- package/dist/views/entries/EntriesInbox.d.ts.map +1 -0
- package/dist/views/entries/EntriesInbox.js +516 -0
- package/dist/views/entries/EntriesInbox.js.map +1 -0
- package/dist/views/entries/inbox-format.d.ts +27 -0
- package/dist/views/entries/inbox-format.d.ts.map +1 -0
- package/dist/views/entries/inbox-format.js +119 -0
- package/dist/views/entries/inbox-format.js.map +1 -0
- package/package.json +4 -4
- package/src/AdminRoot.tsx +7 -3
- package/src/__tests__/components/attribution-rows.test.ts +1 -1
- package/src/__tests__/components/date-range-picker.test.tsx +69 -0
- package/src/__tests__/components/form-build-model.test.ts +200 -0
- package/src/__tests__/components/form-build.test.tsx +157 -0
- package/src/__tests__/components/qa-a11y.render.test.tsx +1 -29
- package/src/__tests__/lib/batch-wizard.test.ts +2 -0
- package/src/__tests__/lib/forms-settings-normalize.test.ts +17 -0
- package/src/__tests__/views/dashboard.test.tsx +110 -32
- package/src/__tests__/views/form-editor.render.test.tsx +18 -10
- package/src/__tests__/views/form-entries.render.test.tsx +27 -9
- package/src/__tests__/views/form-submissions.render.test.tsx +15 -14
- package/src/__tests__/views/forms-list.render.test.tsx +157 -17
- package/src/__tests__/views/forms-settings.fixture.ts +32 -0
- package/src/__tests__/views/forms-settings.render.test.tsx +145 -0
- package/src/__tests__/views/inbox-format.test.ts +72 -0
- package/src/__tests__/views/jobs-wizard.render.test.tsx +18 -3
- package/src/__tests__/views/onboarding-block.render.test.tsx +9 -7
- package/src/components/forms/BlocklistDialog.tsx +552 -0
- package/src/components/forms/ExportMenu.tsx +8 -2
- package/src/components/forms/FieldOptions.tsx +629 -0
- package/src/components/forms/FormBuild.tsx +900 -0
- package/src/components/forms/FormsListTable.tsx +300 -0
- package/src/components/forms/form-build-model.ts +365 -0
- package/src/components/forms/form-build-ui.tsx +130 -0
- package/src/components/forms/primitives.tsx +6 -55
- package/src/components/ui/DateRangePicker.tsx +358 -0
- package/src/components/ui/Segmented.tsx +9 -2
- package/src/components/ui/StatusBadge.tsx +17 -4
- package/src/components/ui/Toggle.tsx +3 -0
- package/src/components/ui/UnderlineTabs.tsx +20 -9
- package/src/layout/Sidebar.tsx +4 -2
- package/src/lib/batch-wizard.ts +2 -2
- package/src/lib/entry-attribution.ts +94 -0
- package/src/lib/forms-service.ts +194 -0
- package/src/lib/job-drawer.ts +21 -1
- package/src/lib/job-view.ts +7 -0
- package/src/router/admin-routes.ts +1 -0
- package/src/styles/theme.css +86 -0
- package/src/views/Dashboard.tsx +1183 -772
- package/src/views/FormEditor.tsx +397 -199
- package/src/views/FormEntries.tsx +3 -422
- package/src/views/FormSubmissions.tsx +5 -411
- package/src/views/Forms.tsx +333 -321
- package/src/views/FormsSettings.tsx +1381 -73
- package/src/views/Jobs/DrawerReview.tsx +14 -8
- package/src/views/Jobs/NewBatchJob.tsx +5 -1
- package/src/views/SpamFolder.tsx +2 -2
- package/src/views/dashboard/Delta.tsx +44 -0
- package/src/views/dashboard/KpiCard.tsx +98 -0
- package/src/views/dashboard/Sparkline.tsx +51 -0
- package/src/views/dashboard/TrendChart.tsx +246 -0
- package/src/views/dashboard/dashboard-date.ts +168 -0
- package/src/views/entries/EntriesInbox.tsx +1277 -0
- package/src/views/entries/inbox-format.ts +128 -0
- package/dist/components/forms/EntriesTable.d.ts +0 -29
- package/dist/components/forms/EntriesTable.d.ts.map +0 -1
- package/dist/components/forms/EntriesTable.js +0 -29
- package/dist/components/forms/EntriesTable.js.map +0 -1
- package/dist/components/forms/FormEntryDetailPane.d.ts +0 -23
- package/dist/components/forms/FormEntryDetailPane.d.ts.map +0 -1
- package/dist/components/forms/FormEntryDetailPane.js +0 -208
- package/dist/components/forms/FormEntryDetailPane.js.map +0 -1
- package/dist/components/ui/PanelSection.d.ts +0 -16
- package/dist/components/ui/PanelSection.d.ts.map +0 -1
- package/dist/components/ui/PanelSection.js +0 -15
- package/dist/components/ui/PanelSection.js.map +0 -1
- package/src/components/forms/EntriesTable.tsx +0 -207
- package/src/components/forms/FormEntryDetailPane.tsx +0 -402
- package/src/components/ui/PanelSection.tsx +0 -53
|
@@ -4,7 +4,7 @@ import { useEffect, useRef, useState, type ReactNode } from 'react'
|
|
|
4
4
|
import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
|
|
5
5
|
import type { JobReviewItem } from '@prenta/core'
|
|
6
6
|
import { Button } from '../../components/ui/Button.js'
|
|
7
|
-
import { charLimit, linkParts } from '../../lib/job-drawer.js'
|
|
7
|
+
import { charLimit, linkParts, mediaReviewLabel } from '../../lib/job-drawer.js'
|
|
8
8
|
import type { OnApprove, ReviewAction } from '../../lib/jobs-service.js'
|
|
9
9
|
import { BusyButton } from './BusyButton.js'
|
|
10
10
|
import { DrawerEmpty } from './DrawerResults.js'
|
|
@@ -13,8 +13,6 @@ import type { ReviewItems } from './useReviewItems.js'
|
|
|
13
13
|
|
|
14
14
|
/** A link suggestion's field. It can't be edited (the server answers 400). */
|
|
15
15
|
const LINK_FIELD = 'body'
|
|
16
|
-
/** Image alt text has no draft or published state, so its Approve has no choice. */
|
|
17
|
-
const ALT_FIELD = 'altText'
|
|
18
16
|
|
|
19
17
|
/** The drawer's per-change state: the request out, and the last outcome to show. */
|
|
20
18
|
export interface ReviewItemState {
|
|
@@ -28,7 +26,8 @@ const MENU_ITEM =
|
|
|
28
26
|
/**
|
|
29
27
|
* Approve, with the choice of what approving does: "Save as draft" (which
|
|
30
28
|
* reads "Keep current status" on a published document, where it leaves the
|
|
31
|
-
* change in review) or "Publish" (CONFLICTS.md §4).
|
|
29
|
+
* change in review) or "Publish" (CONFLICTS.md §4). Media fields have no choice:
|
|
30
|
+
* an image has no draft.
|
|
32
31
|
*/
|
|
33
32
|
function ApproveButton({
|
|
34
33
|
label,
|
|
@@ -151,6 +150,8 @@ function ReviewCard({
|
|
|
151
150
|
locked,
|
|
152
151
|
}: ItemProps) {
|
|
153
152
|
const link = item.field === LINK_FIELD
|
|
153
|
+
const fieldLabel = mediaReviewLabel(item.field)
|
|
154
|
+
const decorative = item.field === 'isDecorative'
|
|
154
155
|
const editing = draft !== undefined && item.status === 'pending'
|
|
155
156
|
const suggested = editing ? draft : (item.editedAfter ?? item.after)
|
|
156
157
|
const limit = charLimit(item.field)
|
|
@@ -167,7 +168,7 @@ function ReviewCard({
|
|
|
167
168
|
label={label}
|
|
168
169
|
busy={busy === 'approve'}
|
|
169
170
|
disabled={blocked}
|
|
170
|
-
choice={
|
|
171
|
+
choice={fieldLabel === null}
|
|
171
172
|
published={published}
|
|
172
173
|
onApprove={approve}
|
|
173
174
|
/>
|
|
@@ -184,6 +185,11 @@ function ReviewCard({
|
|
|
184
185
|
} ${item.status === 'rejected' ? 'opacity-60' : ''}`}
|
|
185
186
|
>
|
|
186
187
|
<div className="bg-bg text-sm2 text-txt flex items-center gap-2 px-3 py-[9px] font-semibold">
|
|
188
|
+
{fieldLabel ? (
|
|
189
|
+
<span className="text-micro text-sub flex-none font-bold whitespace-nowrap">
|
|
190
|
+
{fieldLabel}
|
|
191
|
+
</span>
|
|
192
|
+
) : null}
|
|
187
193
|
<span className="min-w-0 flex-1 truncate">{item.documentTitle}</span>
|
|
188
194
|
<code className="text-micro text-faint max-w-[45%] truncate font-mono font-normal">
|
|
189
195
|
{item.url}
|
|
@@ -202,7 +208,7 @@ function ReviewCard({
|
|
|
202
208
|
<div className="bg-bdr grid grid-cols-2 gap-px max-[560px]:grid-cols-1">
|
|
203
209
|
<div className="bg-card text-sm2 text-txt min-w-0 px-3 py-[9px] leading-[1.5] break-words">
|
|
204
210
|
<DiffLabel label="Current">
|
|
205
|
-
{link ? null : <span>{item.before.length || ''}</span>}
|
|
211
|
+
{link || decorative ? null : <span>{item.before.length || ''}</span>}
|
|
206
212
|
</DiffLabel>
|
|
207
213
|
<div className={item.before ? 'text-sub' : 'text-faint italic'}>
|
|
208
214
|
{item.before || 'Empty'}
|
|
@@ -210,7 +216,7 @@ function ReviewCard({
|
|
|
210
216
|
</div>
|
|
211
217
|
<div className="bg-card text-sm2 text-txt min-w-0 px-3 py-[9px] leading-[1.5] break-words">
|
|
212
218
|
<DiffLabel label="Suggested">
|
|
213
|
-
{link ? null : (
|
|
219
|
+
{link || decorative ? null : (
|
|
214
220
|
<span className={limit !== null && suggested.length > limit ? 'text-err' : ''}>
|
|
215
221
|
{suggested.length}
|
|
216
222
|
</span>
|
|
@@ -293,7 +299,7 @@ function ReviewCard({
|
|
|
293
299
|
>
|
|
294
300
|
Reject
|
|
295
301
|
</BusyButton>
|
|
296
|
-
{link ? null : (
|
|
302
|
+
{link || decorative ? null : (
|
|
297
303
|
<Button
|
|
298
304
|
variant="secondary"
|
|
299
305
|
size="sm"
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
type BatchSelection,
|
|
26
26
|
} from '../../lib/batch-wizard.js'
|
|
27
27
|
import { JOB_OPS } from '../../lib/job-view.js'
|
|
28
|
+
import { mediaReviewLabel } from '../../lib/job-drawer.js'
|
|
28
29
|
import { createBatchAiJob, estimateBatchAi, previewBatchAi } from '../../lib/jobs-service.js'
|
|
29
30
|
import { adminPortalContainer } from '../../lib/portal-container.js'
|
|
30
31
|
import { BusyButton } from './BusyButton.js'
|
|
@@ -841,7 +842,10 @@ function PreviewList({
|
|
|
841
842
|
key={`${item.documentId}|${i}`}
|
|
842
843
|
className="rounded-9 border-bdr text-sm2 text-txt border px-3 py-[9px] leading-[1.5] break-words"
|
|
843
844
|
>
|
|
844
|
-
<small className="text-hint text-faint mb-0.5 block">
|
|
845
|
+
<small className="text-hint text-faint mb-0.5 block">
|
|
846
|
+
{item.field ? `${mediaReviewLabel(item.field) ?? item.field} · ` : null}
|
|
847
|
+
{item.title}
|
|
848
|
+
</small>
|
|
845
849
|
{operation === 'links' ? <LinkLine after={item.after} /> : item.after}
|
|
846
850
|
</li>
|
|
847
851
|
))}
|
package/src/views/SpamFolder.tsx
CHANGED
|
@@ -24,8 +24,8 @@ export function SpamFolder() {
|
|
|
24
24
|
/>
|
|
25
25
|
<EmptyState
|
|
26
26
|
icon={<ShieldAlert size={24} aria-hidden />}
|
|
27
|
-
title="
|
|
28
|
-
description="
|
|
27
|
+
title="The spam folder isn't ready yet"
|
|
28
|
+
description="Caught entries are in All Entries under the Spam filter. Restoring one as not spam comes with this folder."
|
|
29
29
|
/>
|
|
30
30
|
</div>
|
|
31
31
|
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ChevronDown, ChevronUp } from 'lucide-react'
|
|
2
|
+
|
|
3
|
+
export function deltaPercent(cur: number, prev: number): number | null {
|
|
4
|
+
return prev === 0 ? null : ((cur - prev) / prev) * 100
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function Delta({
|
|
8
|
+
cur,
|
|
9
|
+
prev,
|
|
10
|
+
invert = false,
|
|
11
|
+
}: {
|
|
12
|
+
cur: number
|
|
13
|
+
prev: number
|
|
14
|
+
invert?: boolean
|
|
15
|
+
}) {
|
|
16
|
+
const pct = deltaPercent(cur, prev)
|
|
17
|
+
if (pct === null) {
|
|
18
|
+
return (
|
|
19
|
+
<span className="inline-flex items-center gap-[3px] rounded-[5px] border border-[var(--bdr)] bg-[var(--bg)] px-[6px] py-[2px] text-[11.5px] font-bold whitespace-nowrap text-[var(--sub)] tabular-nums">
|
|
20
|
+
new
|
|
21
|
+
</span>
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
const flat = Math.abs(pct) < 0.5
|
|
25
|
+
const good = invert ? pct < 0 : pct > 0
|
|
26
|
+
const className = flat
|
|
27
|
+
? 'border border-[var(--bdr)] bg-[var(--bg)] text-[var(--sub)]'
|
|
28
|
+
: good
|
|
29
|
+
? 'bg-[var(--suc-l)] text-[var(--suc)]'
|
|
30
|
+
: 'bg-[var(--err-l)] text-[var(--err)]'
|
|
31
|
+
return (
|
|
32
|
+
<span
|
|
33
|
+
className={`inline-flex items-center gap-[3px] rounded-[5px] px-[6px] py-[2px] text-[11.5px] font-bold whitespace-nowrap tabular-nums ${className}`}
|
|
34
|
+
>
|
|
35
|
+
{!flat &&
|
|
36
|
+
(pct > 0 ? (
|
|
37
|
+
<ChevronUp size={11} strokeWidth={2.5} aria-hidden />
|
|
38
|
+
) : (
|
|
39
|
+
<ChevronDown size={11} strokeWidth={2.5} aria-hidden />
|
|
40
|
+
))}
|
|
41
|
+
{`${pct > 0 ? '+' : ''}${pct.toFixed(1)}%`}
|
|
42
|
+
</span>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react'
|
|
2
|
+
import { Delta } from './Delta.js'
|
|
3
|
+
import { Sparkline, type SparkPoint } from './Sparkline.js'
|
|
4
|
+
|
|
5
|
+
export interface KpiCardProps {
|
|
6
|
+
label: string
|
|
7
|
+
icon: LucideIcon
|
|
8
|
+
value: string
|
|
9
|
+
unit?: string
|
|
10
|
+
cur: number | null
|
|
11
|
+
prev: number | null
|
|
12
|
+
prevLabel: string
|
|
13
|
+
compare: boolean
|
|
14
|
+
series?: SparkPoint[] | null
|
|
15
|
+
compareSeries?: SparkPoint[] | null
|
|
16
|
+
selected?: boolean
|
|
17
|
+
selectable: boolean
|
|
18
|
+
unavailable?: boolean
|
|
19
|
+
onSelect?: () => void
|
|
20
|
+
onConnect?: () => void
|
|
21
|
+
spanClass?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function KpiCard({
|
|
25
|
+
label,
|
|
26
|
+
icon: Icon,
|
|
27
|
+
value,
|
|
28
|
+
unit,
|
|
29
|
+
cur,
|
|
30
|
+
prev,
|
|
31
|
+
prevLabel,
|
|
32
|
+
compare,
|
|
33
|
+
series,
|
|
34
|
+
compareSeries,
|
|
35
|
+
selected = false,
|
|
36
|
+
selectable,
|
|
37
|
+
unavailable = false,
|
|
38
|
+
onSelect,
|
|
39
|
+
onConnect,
|
|
40
|
+
spanClass = '',
|
|
41
|
+
}: KpiCardProps) {
|
|
42
|
+
const content = (
|
|
43
|
+
<>
|
|
44
|
+
<div className="flex items-center gap-[6px] text-[11.5px] font-semibold tracking-[0.2px] text-[var(--sub)]">
|
|
45
|
+
<Icon size={13} className="text-[var(--muted)]" aria-hidden />
|
|
46
|
+
{label}
|
|
47
|
+
</div>
|
|
48
|
+
<div className="mt-[7px] text-[29px] leading-[1.1] font-bold tracking-[-1px] text-[var(--txt)] tabular-nums">
|
|
49
|
+
{value}
|
|
50
|
+
{unit ? (
|
|
51
|
+
<small className="ml-[2px] text-[15px] font-semibold tracking-normal text-[var(--sub)]">
|
|
52
|
+
{unit}
|
|
53
|
+
</small>
|
|
54
|
+
) : null}
|
|
55
|
+
</div>
|
|
56
|
+
<div className="mt-[6px] flex items-end gap-[10px]">
|
|
57
|
+
{unavailable ? (
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
onClick={(event) => {
|
|
61
|
+
event.stopPropagation()
|
|
62
|
+
onConnect?.()
|
|
63
|
+
}}
|
|
64
|
+
className="text-[11px] font-semibold text-[var(--acc)] hover:underline"
|
|
65
|
+
>
|
|
66
|
+
Connect analytics
|
|
67
|
+
</button>
|
|
68
|
+
) : (
|
|
69
|
+
<div>
|
|
70
|
+
{compare && cur !== null && prev !== null ? <Delta cur={cur} prev={prev} /> : null}
|
|
71
|
+
<div className="text-[11px] leading-[1.5] text-[var(--sub)] tabular-nums">
|
|
72
|
+
{compare ? `from ${prevLabel}` : 'no comparison'}
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
{series ? <Sparkline cur={series} prev={compare ? compareSeries : null} /> : null}
|
|
77
|
+
</div>
|
|
78
|
+
</>
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
const className = `rounded-[10px] border bg-[var(--card)] p-[14px_15px_10px] text-left shadow-[var(--shd)] transition ${spanClass} ${
|
|
82
|
+
selected ? 'border-[var(--acc)] shadow-[0_0_0_3px_var(--acc-l)]' : 'border-[var(--bdr)]'
|
|
83
|
+
} ${selectable ? 'hover:-translate-y-px hover:border-[var(--acc-m)] hover:shadow-[var(--shd2)]' : ''}`
|
|
84
|
+
|
|
85
|
+
if (!selectable) {
|
|
86
|
+
return <div className={className}>{content}</div>
|
|
87
|
+
}
|
|
88
|
+
return (
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
aria-pressed={selected}
|
|
92
|
+
onClick={onSelect}
|
|
93
|
+
className={`${className} cursor-pointer`}
|
|
94
|
+
>
|
|
95
|
+
{content}
|
|
96
|
+
</button>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface SparkPoint {
|
|
2
|
+
date: string
|
|
3
|
+
v: number
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function Sparkline({
|
|
7
|
+
cur,
|
|
8
|
+
prev,
|
|
9
|
+
width = 76,
|
|
10
|
+
height = 30,
|
|
11
|
+
}: {
|
|
12
|
+
cur: SparkPoint[]
|
|
13
|
+
prev?: SparkPoint[] | null
|
|
14
|
+
width?: number
|
|
15
|
+
height?: number
|
|
16
|
+
}) {
|
|
17
|
+
const all = [...cur.map((point) => point.v), ...(prev ? prev.map((point) => point.v) : [])]
|
|
18
|
+
const max = Math.max(...all, 1)
|
|
19
|
+
const min = Math.min(...all, 0)
|
|
20
|
+
const path = (points: SparkPoint[]) =>
|
|
21
|
+
points
|
|
22
|
+
.map((point, index) => {
|
|
23
|
+
const x = (index / Math.max(points.length - 1, 1)) * width
|
|
24
|
+
const y = height - ((point.v - min) / (max - min || 1)) * (height - 4) - 2
|
|
25
|
+
return `${index ? 'L' : 'M'}${x.toFixed(1)} ${y.toFixed(1)}`
|
|
26
|
+
})
|
|
27
|
+
.join(' ')
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<svg width={width} height={height} className="ml-auto shrink-0" aria-hidden="true">
|
|
31
|
+
{prev ? (
|
|
32
|
+
<path
|
|
33
|
+
d={path(prev)}
|
|
34
|
+
fill="none"
|
|
35
|
+
stroke="var(--muted)"
|
|
36
|
+
strokeWidth="1.5"
|
|
37
|
+
strokeDasharray="3 2.5"
|
|
38
|
+
opacity=".8"
|
|
39
|
+
/>
|
|
40
|
+
) : null}
|
|
41
|
+
<path
|
|
42
|
+
d={path(cur)}
|
|
43
|
+
fill="none"
|
|
44
|
+
stroke="var(--acc)"
|
|
45
|
+
strokeWidth="2"
|
|
46
|
+
strokeLinecap="round"
|
|
47
|
+
strokeLinejoin="round"
|
|
48
|
+
/>
|
|
49
|
+
</svg>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react'
|
|
4
|
+
import { formatDay } from './dashboard-date.js'
|
|
5
|
+
import { Delta } from './Delta.js'
|
|
6
|
+
import type { SparkPoint } from './Sparkline.js'
|
|
7
|
+
|
|
8
|
+
const HEIGHT = 244
|
|
9
|
+
const PL = 46
|
|
10
|
+
const PR = 14
|
|
11
|
+
const PT = 12
|
|
12
|
+
const PB = 26
|
|
13
|
+
|
|
14
|
+
function niceStep(value: number): number {
|
|
15
|
+
const power = Math.pow(10, Math.floor(Math.log10(value || 1)))
|
|
16
|
+
for (const multiplier of [1, 2, 2.5, 5, 10]) {
|
|
17
|
+
if (value <= multiplier * power) return multiplier * power
|
|
18
|
+
}
|
|
19
|
+
return 10 * power
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function tickLabel(value: number): string {
|
|
23
|
+
if (value >= 1000) return `${(value / 1000).toFixed(1).replace(/\.0$/, '')}k`
|
|
24
|
+
if (Number.isInteger(value)) return String(value)
|
|
25
|
+
return value.toFixed(2).replace(/0$/, '')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function tooltipDate(key: string): string {
|
|
29
|
+
return new Date(`${key}T12:00:00.000Z`).toLocaleDateString('en-US', {
|
|
30
|
+
weekday: 'short',
|
|
31
|
+
month: 'short',
|
|
32
|
+
day: 'numeric',
|
|
33
|
+
timeZone: 'UTC',
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function TrendChart({
|
|
38
|
+
cur,
|
|
39
|
+
prev,
|
|
40
|
+
format,
|
|
41
|
+
ariaLabel,
|
|
42
|
+
}: {
|
|
43
|
+
cur: SparkPoint[]
|
|
44
|
+
prev: SparkPoint[] | null
|
|
45
|
+
format: (value: number) => string
|
|
46
|
+
ariaLabel: string
|
|
47
|
+
}) {
|
|
48
|
+
const wrapRef = useRef<HTMLDivElement>(null)
|
|
49
|
+
const [width, setWidth] = useState(760)
|
|
50
|
+
const [highlight, setHighlight] = useState<number | null>(null)
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
const element = wrapRef.current
|
|
54
|
+
if (!element) return
|
|
55
|
+
const measure = () => setWidth(Math.max(320, element.clientWidth - 16))
|
|
56
|
+
measure()
|
|
57
|
+
let observer: ResizeObserver | undefined
|
|
58
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
59
|
+
observer = new ResizeObserver(measure)
|
|
60
|
+
observer.observe(element)
|
|
61
|
+
}
|
|
62
|
+
window.addEventListener('resize', measure)
|
|
63
|
+
const timer = setTimeout(measure, 60)
|
|
64
|
+
return () => {
|
|
65
|
+
observer?.disconnect()
|
|
66
|
+
window.removeEventListener('resize', measure)
|
|
67
|
+
clearTimeout(timer)
|
|
68
|
+
}
|
|
69
|
+
}, [])
|
|
70
|
+
|
|
71
|
+
const innerWidth = width - PL - PR
|
|
72
|
+
const innerHeight = HEIGHT - PT - PB
|
|
73
|
+
const all = [...cur.map((point) => point.v), ...(prev ? prev.map((point) => point.v) : [])]
|
|
74
|
+
const rawMax = Math.max(...all, 1)
|
|
75
|
+
const tick = niceStep(rawMax / 4)
|
|
76
|
+
const max = tick * 4
|
|
77
|
+
const x = (index: number) => PL + (index / Math.max(cur.length - 1, 1)) * innerWidth
|
|
78
|
+
const y = (value: number) => PT + innerHeight - (value / max) * innerHeight
|
|
79
|
+
const line = (points: SparkPoint[]) =>
|
|
80
|
+
points
|
|
81
|
+
.map((point, index) => `${index ? 'L' : 'M'}${x(index).toFixed(1)} ${y(point.v).toFixed(1)}`)
|
|
82
|
+
.join(' ')
|
|
83
|
+
const area = cur.length
|
|
84
|
+
? `${line(cur)} L${x(cur.length - 1).toFixed(1)} ${PT + innerHeight} L${PL} ${PT + innerHeight} Z`
|
|
85
|
+
: ''
|
|
86
|
+
const ticks = [0, 1, 2, 3, 4].map((index) => tick * index)
|
|
87
|
+
const labelEvery = Math.max(1, Math.ceil(cur.length / 7))
|
|
88
|
+
const highlighted = highlight !== null ? cur[highlight] : undefined
|
|
89
|
+
|
|
90
|
+
const onMove = (event: React.MouseEvent<SVGSVGElement>) => {
|
|
91
|
+
const rect = event.currentTarget.getBoundingClientRect()
|
|
92
|
+
const index = Math.round(((event.clientX - rect.left - PL) / innerWidth) * (cur.length - 1))
|
|
93
|
+
setHighlight(index >= 0 && index < cur.length ? index : null)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const onKeyDown = (event: React.KeyboardEvent<SVGSVGElement>) => {
|
|
97
|
+
if (event.key === 'Escape') {
|
|
98
|
+
setHighlight(null)
|
|
99
|
+
return
|
|
100
|
+
}
|
|
101
|
+
if (event.key !== 'ArrowLeft' && event.key !== 'ArrowRight') return
|
|
102
|
+
event.preventDefault()
|
|
103
|
+
setHighlight((current) => {
|
|
104
|
+
const base = current ?? cur.length - 1
|
|
105
|
+
const next = event.key === 'ArrowLeft' ? base - 1 : base + 1
|
|
106
|
+
return Math.min(cur.length - 1, Math.max(0, next))
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<div className="relative px-2 pt-[14px] pb-1" ref={wrapRef}>
|
|
112
|
+
<svg
|
|
113
|
+
width={width}
|
|
114
|
+
height={HEIGHT}
|
|
115
|
+
onMouseMove={onMove}
|
|
116
|
+
onMouseLeave={() => setHighlight(null)}
|
|
117
|
+
onKeyDown={onKeyDown}
|
|
118
|
+
tabIndex={0}
|
|
119
|
+
role="img"
|
|
120
|
+
aria-label={ariaLabel}
|
|
121
|
+
className="block cursor-crosshair outline-none focus-visible:ring-2 focus-visible:ring-[var(--acc)]"
|
|
122
|
+
>
|
|
123
|
+
<defs>
|
|
124
|
+
<linearGradient id="dashboard-chart-fill" x1="0" y1="0" x2="0" y2="1">
|
|
125
|
+
<stop offset="0%" stopColor="var(--acc)" stopOpacity=".22" />
|
|
126
|
+
<stop offset="100%" stopColor="var(--acc)" stopOpacity="0" />
|
|
127
|
+
</linearGradient>
|
|
128
|
+
</defs>
|
|
129
|
+
{ticks.map((tickValue) => (
|
|
130
|
+
<g key={tickValue}>
|
|
131
|
+
<line
|
|
132
|
+
x1={PL}
|
|
133
|
+
y1={y(tickValue)}
|
|
134
|
+
x2={width - PR}
|
|
135
|
+
y2={y(tickValue)}
|
|
136
|
+
stroke="var(--bdr)"
|
|
137
|
+
strokeWidth="1"
|
|
138
|
+
/>
|
|
139
|
+
<text
|
|
140
|
+
x={PL - 9}
|
|
141
|
+
y={y(tickValue) + 3.5}
|
|
142
|
+
textAnchor="end"
|
|
143
|
+
fontSize="10"
|
|
144
|
+
fill="var(--sub)"
|
|
145
|
+
>
|
|
146
|
+
{tickLabel(tickValue)}
|
|
147
|
+
</text>
|
|
148
|
+
</g>
|
|
149
|
+
))}
|
|
150
|
+
{cur.map((point, index) =>
|
|
151
|
+
index % labelEvery === 0 || index === cur.length - 1 ? (
|
|
152
|
+
<text
|
|
153
|
+
key={point.date}
|
|
154
|
+
x={x(index)}
|
|
155
|
+
y={HEIGHT - 8}
|
|
156
|
+
textAnchor="middle"
|
|
157
|
+
fontSize="10"
|
|
158
|
+
fill="var(--sub)"
|
|
159
|
+
>
|
|
160
|
+
{formatDay(point.date)}
|
|
161
|
+
</text>
|
|
162
|
+
) : null,
|
|
163
|
+
)}
|
|
164
|
+
{area ? <path d={area} fill="url(#dashboard-chart-fill)" /> : null}
|
|
165
|
+
{prev ? (
|
|
166
|
+
<path
|
|
167
|
+
d={line(prev)}
|
|
168
|
+
fill="none"
|
|
169
|
+
stroke="var(--muted)"
|
|
170
|
+
strokeWidth="1.75"
|
|
171
|
+
strokeDasharray="4 3.5"
|
|
172
|
+
/>
|
|
173
|
+
) : null}
|
|
174
|
+
{cur.length ? (
|
|
175
|
+
<path
|
|
176
|
+
d={line(cur)}
|
|
177
|
+
fill="none"
|
|
178
|
+
stroke="var(--acc)"
|
|
179
|
+
strokeWidth="2.25"
|
|
180
|
+
strokeLinecap="round"
|
|
181
|
+
strokeLinejoin="round"
|
|
182
|
+
/>
|
|
183
|
+
) : null}
|
|
184
|
+
{highlight !== null && highlighted ? (
|
|
185
|
+
<g>
|
|
186
|
+
<line
|
|
187
|
+
x1={x(highlight)}
|
|
188
|
+
y1={PT}
|
|
189
|
+
x2={x(highlight)}
|
|
190
|
+
y2={PT + innerHeight}
|
|
191
|
+
stroke="var(--acc-m)"
|
|
192
|
+
strokeWidth="1"
|
|
193
|
+
/>
|
|
194
|
+
{prev?.[highlight] ? (
|
|
195
|
+
<circle
|
|
196
|
+
cx={x(highlight)}
|
|
197
|
+
cy={y(prev[highlight]!.v)}
|
|
198
|
+
r="3.5"
|
|
199
|
+
fill="var(--card)"
|
|
200
|
+
stroke="var(--muted)"
|
|
201
|
+
strokeWidth="1.75"
|
|
202
|
+
/>
|
|
203
|
+
) : null}
|
|
204
|
+
<circle
|
|
205
|
+
cx={x(highlight)}
|
|
206
|
+
cy={y(highlighted.v)}
|
|
207
|
+
r="4.5"
|
|
208
|
+
fill="var(--card)"
|
|
209
|
+
stroke="var(--acc)"
|
|
210
|
+
strokeWidth="2.5"
|
|
211
|
+
/>
|
|
212
|
+
</g>
|
|
213
|
+
) : null}
|
|
214
|
+
</svg>
|
|
215
|
+
|
|
216
|
+
{highlight !== null && highlighted ? (
|
|
217
|
+
<div
|
|
218
|
+
className="pointer-events-none absolute z-[5] min-w-[132px] rounded-[8px] bg-[var(--txt)] px-[10px] py-2 text-[11.5px] leading-[1.55] text-[var(--sb)] shadow-[var(--shd2)]"
|
|
219
|
+
style={{
|
|
220
|
+
left: Math.min(Math.max(x(highlight) - 66, 4), Math.max(width - 140, 4)),
|
|
221
|
+
top: Math.max(y(highlighted.v) - 72, 4),
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
<b className="mb-1 block text-[12.5px]">{tooltipDate(highlighted.date)}</b>
|
|
225
|
+
<div className="flex items-center gap-[6px]">
|
|
226
|
+
<i className="h-[2.5px] w-[9px] rounded-[2px] bg-[var(--acc)]" aria-hidden />
|
|
227
|
+
This period
|
|
228
|
+
<span className="ml-auto font-bold">{format(highlighted.v)}</span>
|
|
229
|
+
</div>
|
|
230
|
+
{prev?.[highlight] ? (
|
|
231
|
+
<>
|
|
232
|
+
<div className="flex items-center gap-[6px]">
|
|
233
|
+
<i className="h-[2.5px] w-[9px] rounded-[2px] bg-[var(--muted)]" aria-hidden />
|
|
234
|
+
{formatDay(prev[highlight]!.date)}
|
|
235
|
+
<span className="ml-auto font-bold">{format(prev[highlight]!.v)}</span>
|
|
236
|
+
</div>
|
|
237
|
+
<div className="mt-[3px]">
|
|
238
|
+
<Delta cur={highlighted.v} prev={prev[highlight]!.v} />
|
|
239
|
+
</div>
|
|
240
|
+
</>
|
|
241
|
+
) : null}
|
|
242
|
+
</div>
|
|
243
|
+
) : null}
|
|
244
|
+
</div>
|
|
245
|
+
)
|
|
246
|
+
}
|