@adatechnology/content-ui 0.2.0 → 0.4.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/README.md +15 -0
- package/dist/index.d.ts +230 -24
- package/dist/index.js +1124 -176
- package/dist/index.js.map +1 -1
- package/dist/styles.css +292 -2
- package/dist/styles.css.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -65,7 +65,7 @@ var en_default = {
|
|
|
65
65
|
unpublish: "Unpublish",
|
|
66
66
|
archive: "Archive",
|
|
67
67
|
archiveConfirm: "Archive this post? It will leave the site.",
|
|
68
|
-
close: "
|
|
68
|
+
close: "Close",
|
|
69
69
|
unsavedConfirm: "You have unsaved changes. Leave anyway?",
|
|
70
70
|
unsavedBadge: "Unsaved changes",
|
|
71
71
|
saveError: "Could not save.",
|
|
@@ -92,6 +92,57 @@ var en_default = {
|
|
|
92
92
|
notFound: "Post not found.",
|
|
93
93
|
postsEmpty: "No posts published yet.",
|
|
94
94
|
clearFilters: "Clear filters",
|
|
95
|
+
statusTemplate: "Template",
|
|
96
|
+
tabsLabel: "Post status",
|
|
97
|
+
tabPublished: "Published",
|
|
98
|
+
tabScheduled: "Scheduled",
|
|
99
|
+
tabDraft: "Drafts",
|
|
100
|
+
tabTemplates: "Templates",
|
|
101
|
+
columnActions: "Actions",
|
|
102
|
+
dialogCancel: "Cancel",
|
|
103
|
+
actionError: "Could not finish. Try again.",
|
|
104
|
+
emptyTemplates: "No templates yet. On any post, use \u201CSave as template\u201D.",
|
|
105
|
+
saveAsTemplate: "Save as template",
|
|
106
|
+
saveAsTemplateTip: "Makes a reusable copy. The original post does not change.",
|
|
107
|
+
templateNameLabel: "Template name",
|
|
108
|
+
newFromTemplate: "New from template",
|
|
109
|
+
newFromTemplateTip: "Creates a draft with the template content.",
|
|
110
|
+
newPostTitleLabel: "New post title",
|
|
111
|
+
createDraft: "Create draft",
|
|
112
|
+
republish: "Republish",
|
|
113
|
+
republishTip: "Changes the date and keeps the same link: the right way for search engines.",
|
|
114
|
+
republishDateLabel: "New publish date",
|
|
115
|
+
republishHint: "The post address does not change. Use now or a past date: a future date would take the post offline.",
|
|
116
|
+
recurrenceTitle: "Automatic publishing",
|
|
117
|
+
recurrenceNew: "New recurrence",
|
|
118
|
+
recurrenceCreate: "Create recurrence",
|
|
119
|
+
recurrenceTemplate: "Template",
|
|
120
|
+
recurrenceFrequency: "Repeats",
|
|
121
|
+
recurrenceStart: "First publication",
|
|
122
|
+
frequencyWeekly: "Every week",
|
|
123
|
+
frequencyMonthly: "Every month",
|
|
124
|
+
recurrenceHint: "On each date a new post is published automatically from the template.",
|
|
125
|
+
recurrenceNext: "next {date}",
|
|
126
|
+
recurrenceActive: "Active",
|
|
127
|
+
recurrencePaused: "Paused",
|
|
128
|
+
recurrencePause: "Pause",
|
|
129
|
+
recurrenceResume: "Resume",
|
|
130
|
+
recurrenceRemove: "Delete rule",
|
|
131
|
+
recurrenceRemoveTip: "Deletes only the rule. Posts already published stay online.",
|
|
132
|
+
recurrenceEmpty: "No recurrences. Create one to publish by itself every week or month.",
|
|
133
|
+
recurrenceNeedsTemplate: "Create a template first to schedule automatic publishing.",
|
|
134
|
+
selectAll: "Select all",
|
|
135
|
+
selectRow: "Select {title}",
|
|
136
|
+
selectedCount: "Selected: {count}",
|
|
137
|
+
clearSelection: "Clear selection",
|
|
138
|
+
batchLabel: "Batch actions",
|
|
139
|
+
batchPublish: "Publish",
|
|
140
|
+
batchUnpublish: "Unpublish",
|
|
141
|
+
batchArchive: "Delete",
|
|
142
|
+
batchArchiveConfirm: "Delete {count} posts? They leave the site; the content stays archived.",
|
|
143
|
+
batchPartial: "Only {done} of {total} done. Try again for the rest.",
|
|
144
|
+
itemsPerPage: "Per page",
|
|
145
|
+
rangeLabel: "{from}\u2013{to} of {total}",
|
|
95
146
|
bodyHintToolbar: "Select text and use the buttons above. Shortcuts: Ctrl+B bold, Ctrl+I italic, Ctrl+K link.",
|
|
96
147
|
toolbarLabel: "Text formatting",
|
|
97
148
|
formatBold: "Bold",
|
|
@@ -111,7 +162,6 @@ var en_default = {
|
|
|
111
162
|
imageDialogTitle: "Insert image",
|
|
112
163
|
imageUploadFromDevice: "Upload from device",
|
|
113
164
|
dialogInsert: "Insert",
|
|
114
|
-
dialogCancel: "Cancel",
|
|
115
165
|
fileNoneChosen: "No file chosen",
|
|
116
166
|
emojiTitle: "Choose emoji",
|
|
117
167
|
emojiSearch: "Search emoji",
|
|
@@ -190,7 +240,7 @@ var pt_BR_default = {
|
|
|
190
240
|
unpublish: "Despublicar",
|
|
191
241
|
archive: "Arquivar",
|
|
192
242
|
archiveConfirm: "Arquivar este post? Ele sai do site.",
|
|
193
|
-
close: "
|
|
243
|
+
close: "Fechar",
|
|
194
244
|
unsavedConfirm: "H\xE1 altera\xE7\xF5es n\xE3o salvas. Sair mesmo assim?",
|
|
195
245
|
unsavedBadge: "Altera\xE7\xF5es n\xE3o salvas",
|
|
196
246
|
saveError: "N\xE3o foi poss\xEDvel salvar.",
|
|
@@ -217,6 +267,57 @@ var pt_BR_default = {
|
|
|
217
267
|
notFound: "Post n\xE3o encontrado.",
|
|
218
268
|
postsEmpty: "Nenhum post publicado ainda.",
|
|
219
269
|
clearFilters: "Limpar filtros",
|
|
270
|
+
statusTemplate: "Modelo",
|
|
271
|
+
tabsLabel: "Situa\xE7\xE3o dos posts",
|
|
272
|
+
tabPublished: "Publicados",
|
|
273
|
+
tabScheduled: "Agendados",
|
|
274
|
+
tabDraft: "Rascunhos",
|
|
275
|
+
tabTemplates: "Modelos",
|
|
276
|
+
columnActions: "A\xE7\xF5es",
|
|
277
|
+
dialogCancel: "Cancelar",
|
|
278
|
+
actionError: "N\xE3o foi poss\xEDvel concluir. Tente de novo.",
|
|
279
|
+
emptyTemplates: "Nenhum modelo ainda. Em qualquer post, use \u201CSalvar como modelo\u201D.",
|
|
280
|
+
saveAsTemplate: "Salvar como modelo",
|
|
281
|
+
saveAsTemplateTip: "Cria uma c\xF3pia reutiliz\xE1vel. O post original n\xE3o muda.",
|
|
282
|
+
templateNameLabel: "Nome do modelo",
|
|
283
|
+
newFromTemplate: "Novo a partir do modelo",
|
|
284
|
+
newFromTemplateTip: "Cria um rascunho com o conte\xFAdo do modelo.",
|
|
285
|
+
newPostTitleLabel: "T\xEDtulo do novo post",
|
|
286
|
+
createDraft: "Criar rascunho",
|
|
287
|
+
republish: "Republicar",
|
|
288
|
+
republishTip: "Muda a data e mant\xE9m o mesmo link: o jeito certo para buscadores.",
|
|
289
|
+
republishDateLabel: "Nova data de publica\xE7\xE3o",
|
|
290
|
+
republishHint: "O endere\xE7o do post n\xE3o muda. Use agora ou uma data passada: data futura tiraria o post do ar.",
|
|
291
|
+
recurrenceTitle: "Publica\xE7\xE3o autom\xE1tica",
|
|
292
|
+
recurrenceNew: "Nova recorr\xEAncia",
|
|
293
|
+
recurrenceCreate: "Criar recorr\xEAncia",
|
|
294
|
+
recurrenceTemplate: "Modelo",
|
|
295
|
+
recurrenceFrequency: "Repete",
|
|
296
|
+
recurrenceStart: "Primeira publica\xE7\xE3o",
|
|
297
|
+
frequencyWeekly: "Toda semana",
|
|
298
|
+
frequencyMonthly: "Todo m\xEAs",
|
|
299
|
+
recurrenceHint: "A cada data, um post novo \xE9 publicado sozinho a partir do modelo.",
|
|
300
|
+
recurrenceNext: "pr\xF3xima {date}",
|
|
301
|
+
recurrenceActive: "Ativa",
|
|
302
|
+
recurrencePaused: "Pausada",
|
|
303
|
+
recurrencePause: "Pausar",
|
|
304
|
+
recurrenceResume: "Retomar",
|
|
305
|
+
recurrenceRemove: "Apagar regra",
|
|
306
|
+
recurrenceRemoveTip: "Apaga s\xF3 a regra. Os posts j\xE1 publicados continuam no ar.",
|
|
307
|
+
recurrenceEmpty: "Nenhuma recorr\xEAncia. Crie uma para publicar sozinho toda semana ou m\xEAs.",
|
|
308
|
+
recurrenceNeedsTemplate: "Crie um modelo primeiro para agendar publica\xE7\xF5es autom\xE1ticas.",
|
|
309
|
+
selectAll: "Selecionar todos",
|
|
310
|
+
selectRow: "Selecionar {title}",
|
|
311
|
+
selectedCount: "Selecionados: {count}",
|
|
312
|
+
clearSelection: "Limpar sele\xE7\xE3o",
|
|
313
|
+
batchLabel: "A\xE7\xF5es em lote",
|
|
314
|
+
batchPublish: "Publicar",
|
|
315
|
+
batchUnpublish: "Despublicar",
|
|
316
|
+
batchArchive: "Excluir",
|
|
317
|
+
batchArchiveConfirm: "Excluir {count} posts? Eles saem do site; o conte\xFAdo fica arquivado.",
|
|
318
|
+
batchPartial: "S\xF3 {done} de {total} conclu\xEDdos. Tente de novo nos demais.",
|
|
319
|
+
itemsPerPage: "Por p\xE1gina",
|
|
320
|
+
rangeLabel: "{from}\u2013{to} de {total}",
|
|
220
321
|
bodyHintToolbar: "Selecione o texto e use os bot\xF5es acima. Atalhos: Ctrl+B negrito, Ctrl+I it\xE1lico, Ctrl+K link.",
|
|
221
322
|
toolbarLabel: "Formata\xE7\xE3o do texto",
|
|
222
323
|
formatBold: "Negrito",
|
|
@@ -236,7 +337,6 @@ var pt_BR_default = {
|
|
|
236
337
|
imageDialogTitle: "Inserir imagem",
|
|
237
338
|
imageUploadFromDevice: "Enviar do aparelho",
|
|
238
339
|
dialogInsert: "Inserir",
|
|
239
|
-
dialogCancel: "Cancelar",
|
|
240
340
|
fileNoneChosen: "Nenhum arquivo escolhido",
|
|
241
341
|
emojiTitle: "Escolher emoji",
|
|
242
342
|
emojiSearch: "Buscar emoji",
|
|
@@ -314,7 +414,7 @@ function useRenderLink() {
|
|
|
314
414
|
}
|
|
315
415
|
|
|
316
416
|
// src/components/ContentWorkspace.tsx
|
|
317
|
-
import { useState as
|
|
417
|
+
import { useState as useState15 } from "react";
|
|
318
418
|
|
|
319
419
|
// src/components/PostEditor.tsx
|
|
320
420
|
import { Archive as Archive2, ArrowLeft, CalendarClock as CalendarClock2, EyeOff, Save, Send, Trash2 } from "lucide-react";
|
|
@@ -703,9 +803,9 @@ function renderBlock(block, key, context, tight = false) {
|
|
|
703
803
|
}
|
|
704
804
|
}
|
|
705
805
|
function MarkdownContent({ markdown, headingLevelOffset = 0, className }) {
|
|
706
|
-
const
|
|
806
|
+
const document2 = useMemo3(() => parseMarkdown(markdown), [markdown]);
|
|
707
807
|
const context = { offset: headingLevelOffset, nextHeadingId: createHeadingIdGenerator() };
|
|
708
|
-
return /* @__PURE__ */ jsx3("div", { className: ["adc-prose", className].filter(Boolean).join(" "), children:
|
|
808
|
+
return /* @__PURE__ */ jsx3("div", { className: ["adc-prose", className].filter(Boolean).join(" "), children: document2.children.map((block, index) => renderBlock(block, index, context)) });
|
|
709
809
|
}
|
|
710
810
|
|
|
711
811
|
// src/components/MarkdownEditor.tsx
|
|
@@ -1199,7 +1299,7 @@ function MarkdownEditor({
|
|
|
1199
1299
|
|
|
1200
1300
|
// src/components/StatusChip.tsx
|
|
1201
1301
|
import { POST_STATUS } from "@adatechnology/content-contracts";
|
|
1202
|
-
import { Archive, CalendarClock, CircleCheck, PencilLine } from "lucide-react";
|
|
1302
|
+
import { Archive, CalendarClock, CircleCheck, Copy, PencilLine } from "lucide-react";
|
|
1203
1303
|
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1204
1304
|
var STATUS_VIEW = {
|
|
1205
1305
|
[POST_STATUS.DRAFT]: { icon: PencilLine, label: "statusDraft" },
|
|
@@ -1207,10 +1307,10 @@ var STATUS_VIEW = {
|
|
|
1207
1307
|
[POST_STATUS.PUBLISHED]: { icon: CircleCheck, label: "statusPublished" },
|
|
1208
1308
|
[POST_STATUS.ARCHIVED]: { icon: Archive, label: "statusArchived" }
|
|
1209
1309
|
};
|
|
1210
|
-
function StatusChip({ status }) {
|
|
1310
|
+
function StatusChip({ status, isTemplate = false }) {
|
|
1211
1311
|
const { messages } = useContentText();
|
|
1212
|
-
const { icon: Icon, label } = STATUS_VIEW[status];
|
|
1213
|
-
return /* @__PURE__ */ jsxs6("span", { className: `adc-
|
|
1312
|
+
const { icon: Icon, label } = isTemplate ? { icon: Copy, label: "statusTemplate" } : STATUS_VIEW[status];
|
|
1313
|
+
return /* @__PURE__ */ jsxs6("span", { className: `adc-badge adc-chip--${isTemplate ? "template" : status}`, children: [
|
|
1214
1314
|
/* @__PURE__ */ jsx8(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1215
1315
|
messages[label]
|
|
1216
1316
|
] });
|
|
@@ -1603,37 +1703,431 @@ function PostEditor({
|
|
|
1603
1703
|
}
|
|
1604
1704
|
|
|
1605
1705
|
// src/components/PostList.tsx
|
|
1606
|
-
import {
|
|
1607
|
-
import {
|
|
1608
|
-
|
|
1706
|
+
import { CopyPlus as CopyPlus2, FilePlus2 as FilePlus22, RefreshCw as RefreshCw2 } from "lucide-react";
|
|
1707
|
+
import { useState as useState14 } from "react";
|
|
1708
|
+
|
|
1709
|
+
// src/hooks/usePostList.ts
|
|
1710
|
+
import { useEffect as useEffect4, useState as useState10 } from "react";
|
|
1711
|
+
|
|
1712
|
+
// src/lib/listUrlState.ts
|
|
1713
|
+
import { POST_SORT_FIELDS } from "@adatechnology/content-contracts";
|
|
1714
|
+
var PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
|
|
1715
|
+
var DEFAULT_LIST_STATE = {
|
|
1716
|
+
search: "",
|
|
1717
|
+
tags: [],
|
|
1718
|
+
page: 1,
|
|
1719
|
+
sort: "updatedAt",
|
|
1720
|
+
order: "desc"
|
|
1721
|
+
};
|
|
1722
|
+
var TABS = ["published", "scheduled", "draft", "templates"];
|
|
1723
|
+
function positiveInteger(value) {
|
|
1724
|
+
const parsed = Number(value);
|
|
1725
|
+
return Number.isInteger(parsed) && parsed > 0 ? parsed : void 0;
|
|
1726
|
+
}
|
|
1727
|
+
function parseListUrlState(search) {
|
|
1728
|
+
const params = new URLSearchParams(search);
|
|
1729
|
+
const sort = params.get("sort");
|
|
1730
|
+
const size = positiveInteger(params.get("size"));
|
|
1731
|
+
const tab = params.get("tab");
|
|
1732
|
+
return {
|
|
1733
|
+
...DEFAULT_LIST_STATE,
|
|
1734
|
+
...tab && TABS.includes(tab) ? { tab } : {},
|
|
1735
|
+
search: params.get("q") ?? "",
|
|
1736
|
+
tags: (params.get("tags") ?? "").split(",").filter(Boolean),
|
|
1737
|
+
page: positiveInteger(params.get("page")) ?? 1,
|
|
1738
|
+
...size && PAGE_SIZE_OPTIONS.includes(size) ? { pageSize: size } : {},
|
|
1739
|
+
sort: POST_SORT_FIELDS.includes(sort ?? "") ? sort : "updatedAt",
|
|
1740
|
+
order: params.get("order") === "asc" ? "asc" : "desc"
|
|
1741
|
+
};
|
|
1742
|
+
}
|
|
1743
|
+
function serializeListUrlState(state) {
|
|
1744
|
+
const params = new URLSearchParams();
|
|
1745
|
+
if (state.tab && state.tab !== "published") params.set("tab", state.tab);
|
|
1746
|
+
if (state.search) params.set("q", state.search);
|
|
1747
|
+
if (state.tags.length > 0) params.set("tags", state.tags.join(","));
|
|
1748
|
+
if (state.page > 1) params.set("page", String(state.page));
|
|
1749
|
+
if (state.pageSize) params.set("size", String(state.pageSize));
|
|
1750
|
+
if (state.sort !== DEFAULT_LIST_STATE.sort) params.set("sort", state.sort);
|
|
1751
|
+
if (state.order !== DEFAULT_LIST_STATE.order) params.set("order", state.order);
|
|
1752
|
+
return params.toString();
|
|
1753
|
+
}
|
|
1609
1754
|
|
|
1610
1755
|
// src/hooks/usePostList.ts
|
|
1611
|
-
|
|
1756
|
+
var POST_LIST_TAB = {
|
|
1757
|
+
PUBLISHED: "published",
|
|
1758
|
+
SCHEDULED: "scheduled",
|
|
1759
|
+
DRAFT: "draft",
|
|
1760
|
+
TEMPLATES: "templates"
|
|
1761
|
+
};
|
|
1762
|
+
function initialState(syncUrl) {
|
|
1763
|
+
if (!syncUrl || typeof window === "undefined") return DEFAULT_LIST_STATE;
|
|
1764
|
+
return parseListUrlState(window.location.search);
|
|
1765
|
+
}
|
|
1612
1766
|
function usePostList(params) {
|
|
1613
1767
|
const api = useContentAdminApi();
|
|
1614
|
-
const
|
|
1615
|
-
const
|
|
1616
|
-
const
|
|
1617
|
-
const
|
|
1768
|
+
const syncUrl = params.syncUrl ?? false;
|
|
1769
|
+
const hasTabs = Boolean(api.countPosts);
|
|
1770
|
+
const [state, setState] = useState10(() => initialState(syncUrl));
|
|
1771
|
+
const [localReload, setLocalReload] = useState10(0);
|
|
1772
|
+
const [selectedIds, setSelectedIds] = useState10(/* @__PURE__ */ new Set());
|
|
1773
|
+
const reload = (params.reloadKey ?? 0) + localReload;
|
|
1774
|
+
const tab = hasTabs ? state.tab ?? POST_LIST_TAB.PUBLISHED : void 0;
|
|
1775
|
+
const pageSize = state.pageSize ?? params.pageSize;
|
|
1776
|
+
useEffect4(() => {
|
|
1777
|
+
if (!syncUrl || typeof window === "undefined") return;
|
|
1778
|
+
const query = serializeListUrlState({ ...state, ...tab ? { tab } : {} });
|
|
1779
|
+
const url = `${window.location.pathname}${query ? `?${query}` : ""}${window.location.hash}`;
|
|
1780
|
+
window.history.replaceState(window.history.state, "", url);
|
|
1781
|
+
}, [state, tab, syncUrl]);
|
|
1782
|
+
const tabFilter = !tab ? {} : tab === POST_LIST_TAB.TEMPLATES ? { isTemplate: true } : { status: tab };
|
|
1783
|
+
const key = JSON.stringify({ state, tab, pageSize, reload });
|
|
1784
|
+
const posts = useAsyncResource(
|
|
1785
|
+
() => api.listPosts({
|
|
1786
|
+
...tabFilter,
|
|
1787
|
+
...state.search ? { search: state.search } : {},
|
|
1788
|
+
...state.tags.length > 0 ? { tag: state.tags.join(",") } : {},
|
|
1789
|
+
sort: state.sort,
|
|
1790
|
+
order: state.order,
|
|
1791
|
+
page: state.page,
|
|
1792
|
+
pageSize
|
|
1793
|
+
}),
|
|
1794
|
+
key
|
|
1795
|
+
);
|
|
1796
|
+
const counts = useAsyncResource(
|
|
1797
|
+
() => api.countPosts ? api.countPosts() : Promise.resolve(void 0),
|
|
1798
|
+
`counts-${reload}`
|
|
1799
|
+
);
|
|
1618
1800
|
const tags = useAsyncResource(
|
|
1619
1801
|
() => api.listTags ? api.listTags() : Promise.resolve([]),
|
|
1620
|
-
`tags-${
|
|
1802
|
+
`tags-${reload}`
|
|
1621
1803
|
);
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1804
|
+
useEffect4(() => setSelectedIds(/* @__PURE__ */ new Set()), [key]);
|
|
1805
|
+
const change = (patch) => setState((current) => ({ ...current, page: 1, ...patch }));
|
|
1806
|
+
function toggleSort(field) {
|
|
1807
|
+
change({ sort: field, order: state.sort === field && state.order === "asc" ? "desc" : "asc" });
|
|
1808
|
+
}
|
|
1809
|
+
function toggleTag(tag) {
|
|
1810
|
+
change({ tags: state.tags.includes(tag) ? state.tags.filter((entry) => entry !== tag) : [...state.tags, tag] });
|
|
1811
|
+
}
|
|
1812
|
+
function toggleSelected(id) {
|
|
1813
|
+
setSelectedIds((current) => {
|
|
1814
|
+
const next = new Set(current);
|
|
1815
|
+
if (!next.delete(id)) next.add(id);
|
|
1816
|
+
return next;
|
|
1817
|
+
});
|
|
1625
1818
|
}
|
|
1626
1819
|
return {
|
|
1627
1820
|
posts,
|
|
1821
|
+
counts: counts.data,
|
|
1628
1822
|
tags: api.listTags ? tags.data ?? [] : void 0,
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1823
|
+
state,
|
|
1824
|
+
tab,
|
|
1825
|
+
pageSize,
|
|
1826
|
+
selectedIds,
|
|
1827
|
+
setSelectedIds,
|
|
1828
|
+
toggleSelected,
|
|
1829
|
+
toggleSort,
|
|
1830
|
+
toggleTag,
|
|
1831
|
+
setTab: (next) => change({ tab: next }),
|
|
1832
|
+
setSearch: (search) => change({ search }),
|
|
1833
|
+
setPageSize: (next) => change({ pageSize: next }),
|
|
1834
|
+
setPage: (page) => setState((current) => ({ ...current, page })),
|
|
1835
|
+
clearFilters: () => change({ search: "", tags: [] }),
|
|
1836
|
+
refresh: () => setLocalReload((value) => value + 1),
|
|
1837
|
+
hasFilters: Boolean(state.search || state.tags.length > 0)
|
|
1634
1838
|
};
|
|
1635
1839
|
}
|
|
1636
1840
|
|
|
1841
|
+
// src/components/BatchBar.tsx
|
|
1842
|
+
import { Archive as Archive3, CircleCheck as CircleCheck2, EyeOff as EyeOff2, X as X3 } from "lucide-react";
|
|
1843
|
+
import { useState as useState11 } from "react";
|
|
1844
|
+
|
|
1845
|
+
// src/components/ActionDialog.tsx
|
|
1846
|
+
import { X as X2 } from "lucide-react";
|
|
1847
|
+
import { useEffect as useEffect5, useId as useId6, useRef as useRef4 } from "react";
|
|
1848
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1849
|
+
function ActionDialog({
|
|
1850
|
+
title,
|
|
1851
|
+
confirmLabel,
|
|
1852
|
+
confirmIcon,
|
|
1853
|
+
isBusy = false,
|
|
1854
|
+
error,
|
|
1855
|
+
onConfirm,
|
|
1856
|
+
onClose,
|
|
1857
|
+
children
|
|
1858
|
+
}) {
|
|
1859
|
+
const { messages } = useContentText();
|
|
1860
|
+
const titleId = useId6();
|
|
1861
|
+
const formRef = useRef4(null);
|
|
1862
|
+
useEffect5(() => {
|
|
1863
|
+
formRef.current?.querySelector("input, button[aria-haspopup], select, textarea")?.focus();
|
|
1864
|
+
const handleKeyDown = (event) => {
|
|
1865
|
+
if (event.key === "Escape") onClose();
|
|
1866
|
+
};
|
|
1867
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
1868
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
1869
|
+
}, [onClose]);
|
|
1870
|
+
function handleSubmit(event) {
|
|
1871
|
+
event.preventDefault();
|
|
1872
|
+
if (!isBusy) onConfirm();
|
|
1873
|
+
}
|
|
1874
|
+
return /* @__PURE__ */ jsx11("div", { className: "adc-root adc-dialog-backdrop", children: /* @__PURE__ */ jsxs9(
|
|
1875
|
+
"form",
|
|
1876
|
+
{
|
|
1877
|
+
ref: formRef,
|
|
1878
|
+
className: "adc-dialog",
|
|
1879
|
+
role: "dialog",
|
|
1880
|
+
"aria-modal": "true",
|
|
1881
|
+
"aria-labelledby": titleId,
|
|
1882
|
+
onSubmit: handleSubmit,
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ jsxs9("header", { className: "adc-dialog__header", children: [
|
|
1885
|
+
/* @__PURE__ */ jsx11("h3", { id: titleId, className: "adc-dialog__title", children: title }),
|
|
1886
|
+
/* @__PURE__ */ jsx11(
|
|
1887
|
+
"button",
|
|
1888
|
+
{
|
|
1889
|
+
type: "button",
|
|
1890
|
+
className: "adc-button adc-button--ghost adc-button--icon",
|
|
1891
|
+
"aria-label": messages.close,
|
|
1892
|
+
onClick: onClose,
|
|
1893
|
+
children: /* @__PURE__ */ jsx11(X2, { "aria-hidden": "true", className: "adc-icon" })
|
|
1894
|
+
}
|
|
1895
|
+
)
|
|
1896
|
+
] }),
|
|
1897
|
+
/* @__PURE__ */ jsx11("div", { className: "adc-dialog__body", children }),
|
|
1898
|
+
error && /* @__PURE__ */ jsx11("p", { className: "adc-error", role: "alert", children: error }),
|
|
1899
|
+
/* @__PURE__ */ jsxs9("footer", { className: "adc-dialog__footer", children: [
|
|
1900
|
+
/* @__PURE__ */ jsx11("button", { type: "button", className: "adc-button", onClick: onClose, children: messages.dialogCancel }),
|
|
1901
|
+
/* @__PURE__ */ jsxs9("button", { type: "submit", className: "adc-button adc-button--primary", disabled: isBusy, children: [
|
|
1902
|
+
confirmIcon,
|
|
1903
|
+
confirmLabel
|
|
1904
|
+
] })
|
|
1905
|
+
] })
|
|
1906
|
+
]
|
|
1907
|
+
}
|
|
1908
|
+
) });
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
// src/components/BatchBar.tsx
|
|
1912
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1913
|
+
function BatchBar({ ids, tab, onClearSelection, onDone }) {
|
|
1914
|
+
const api = useContentAdminApi();
|
|
1915
|
+
const { messages, format } = useContentText();
|
|
1916
|
+
const [isConfirming, setIsConfirming] = useState11(false);
|
|
1917
|
+
const [isBusy, setIsBusy] = useState11(false);
|
|
1918
|
+
const [result, setResult] = useState11();
|
|
1919
|
+
async function run(action) {
|
|
1920
|
+
setIsBusy(true);
|
|
1921
|
+
const calls = ids.map(
|
|
1922
|
+
(id) => action === "publish" ? api.publishPost(id) : action === "unpublish" ? api.unpublishPost(id) : api.archivePost(id)
|
|
1923
|
+
);
|
|
1924
|
+
const settled = await Promise.allSettled(calls);
|
|
1925
|
+
const done = settled.filter((entry) => entry.status === "fulfilled").length;
|
|
1926
|
+
setResult(done === ids.length ? void 0 : format("batchPartial", { done, total: ids.length }));
|
|
1927
|
+
setIsBusy(false);
|
|
1928
|
+
setIsConfirming(false);
|
|
1929
|
+
onDone();
|
|
1930
|
+
}
|
|
1931
|
+
const canPublish = tab === "draft";
|
|
1932
|
+
const canUnpublish = tab === "published" || tab === "scheduled";
|
|
1933
|
+
return /* @__PURE__ */ jsxs10("div", { className: "adc-batch-bar", role: "region", "aria-label": messages.batchLabel, children: [
|
|
1934
|
+
/* @__PURE__ */ jsx12("strong", { children: format("selectedCount", { count: ids.length }) }),
|
|
1935
|
+
canPublish && /* @__PURE__ */ jsxs10(
|
|
1936
|
+
"button",
|
|
1937
|
+
{
|
|
1938
|
+
type: "button",
|
|
1939
|
+
className: "adc-button adc-button--compact",
|
|
1940
|
+
disabled: isBusy,
|
|
1941
|
+
onClick: () => void run("publish"),
|
|
1942
|
+
children: [
|
|
1943
|
+
/* @__PURE__ */ jsx12(CircleCheck2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1944
|
+
messages.batchPublish
|
|
1945
|
+
]
|
|
1946
|
+
}
|
|
1947
|
+
),
|
|
1948
|
+
canUnpublish && /* @__PURE__ */ jsxs10(
|
|
1949
|
+
"button",
|
|
1950
|
+
{
|
|
1951
|
+
type: "button",
|
|
1952
|
+
className: "adc-button adc-button--compact",
|
|
1953
|
+
disabled: isBusy,
|
|
1954
|
+
onClick: () => void run("unpublish"),
|
|
1955
|
+
children: [
|
|
1956
|
+
/* @__PURE__ */ jsx12(EyeOff2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1957
|
+
messages.batchUnpublish
|
|
1958
|
+
]
|
|
1959
|
+
}
|
|
1960
|
+
),
|
|
1961
|
+
/* @__PURE__ */ jsxs10(
|
|
1962
|
+
"button",
|
|
1963
|
+
{
|
|
1964
|
+
type: "button",
|
|
1965
|
+
className: "adc-button adc-button--compact adc-button--danger",
|
|
1966
|
+
disabled: isBusy,
|
|
1967
|
+
onClick: () => setIsConfirming(true),
|
|
1968
|
+
children: [
|
|
1969
|
+
/* @__PURE__ */ jsx12(Archive3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1970
|
+
messages.batchArchive
|
|
1971
|
+
]
|
|
1972
|
+
}
|
|
1973
|
+
),
|
|
1974
|
+
/* @__PURE__ */ jsxs10("button", { type: "button", className: "adc-button adc-button--compact adc-button--ghost", onClick: onClearSelection, children: [
|
|
1975
|
+
/* @__PURE__ */ jsx12(X3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1976
|
+
messages.clearSelection
|
|
1977
|
+
] }),
|
|
1978
|
+
result && /* @__PURE__ */ jsx12("span", { className: "adc-error", role: "alert", children: result }),
|
|
1979
|
+
isConfirming && /* @__PURE__ */ jsx12(
|
|
1980
|
+
ActionDialog,
|
|
1981
|
+
{
|
|
1982
|
+
title: messages.batchArchive,
|
|
1983
|
+
confirmLabel: messages.batchArchive,
|
|
1984
|
+
confirmIcon: /* @__PURE__ */ jsx12(Archive3, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1985
|
+
isBusy,
|
|
1986
|
+
onClose: () => setIsConfirming(false),
|
|
1987
|
+
onConfirm: () => void run("archive"),
|
|
1988
|
+
children: /* @__PURE__ */ jsx12("p", { children: format("batchArchiveConfirm", { count: ids.length }) })
|
|
1989
|
+
}
|
|
1990
|
+
)
|
|
1991
|
+
] });
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
// src/components/PostActionDialogs.tsx
|
|
1995
|
+
import { CopyPlus, FilePlus2, RefreshCw } from "lucide-react";
|
|
1996
|
+
import { useId as useId7, useState as useState12 } from "react";
|
|
1997
|
+
|
|
1998
|
+
// src/components/DateTimeField.tsx
|
|
1999
|
+
import { jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2000
|
+
function DateTimeField({ renderDateTimeInput, ...props }) {
|
|
2001
|
+
if (renderDateTimeInput) return renderDateTimeInput(props);
|
|
2002
|
+
return /* @__PURE__ */ jsxs11("div", { className: "adc-field", children: [
|
|
2003
|
+
/* @__PURE__ */ jsx13("label", { htmlFor: props.id, children: props.label }),
|
|
2004
|
+
/* @__PURE__ */ jsx13(
|
|
2005
|
+
"input",
|
|
2006
|
+
{
|
|
2007
|
+
id: props.id,
|
|
2008
|
+
type: "datetime-local",
|
|
2009
|
+
value: props.value,
|
|
2010
|
+
onChange: (event) => props.onChange(event.target.value)
|
|
2011
|
+
}
|
|
2012
|
+
)
|
|
2013
|
+
] });
|
|
2014
|
+
}
|
|
2015
|
+
|
|
2016
|
+
// src/components/PostActionDialogs.tsx
|
|
2017
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2018
|
+
function useAction(run, onDone) {
|
|
2019
|
+
const { messages } = useContentText();
|
|
2020
|
+
const [isBusy, setIsBusy] = useState12(false);
|
|
2021
|
+
const [error, setError] = useState12();
|
|
2022
|
+
async function submit() {
|
|
2023
|
+
setIsBusy(true);
|
|
2024
|
+
setError(void 0);
|
|
2025
|
+
try {
|
|
2026
|
+
onDone(await run());
|
|
2027
|
+
} catch (caught) {
|
|
2028
|
+
setError(caught instanceof Error && caught.message ? caught.message : messages.actionError);
|
|
2029
|
+
setIsBusy(false);
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
return { isBusy, error, submit: () => void submit() };
|
|
2033
|
+
}
|
|
2034
|
+
function TitleDialog({ post, heading, fieldLabel, confirmLabel, icon, run, onClose, onDone }) {
|
|
2035
|
+
const [title, setTitle] = useState12(post.title);
|
|
2036
|
+
const id = useId7();
|
|
2037
|
+
const action = useAction(() => run(title.trim() || void 0), onDone);
|
|
2038
|
+
return /* @__PURE__ */ jsx14(
|
|
2039
|
+
ActionDialog,
|
|
2040
|
+
{
|
|
2041
|
+
title: heading,
|
|
2042
|
+
confirmLabel,
|
|
2043
|
+
confirmIcon: icon,
|
|
2044
|
+
onClose,
|
|
2045
|
+
onConfirm: action.submit,
|
|
2046
|
+
isBusy: action.isBusy,
|
|
2047
|
+
error: action.error,
|
|
2048
|
+
children: /* @__PURE__ */ jsxs12("div", { className: "adc-field", children: [
|
|
2049
|
+
/* @__PURE__ */ jsx14("label", { htmlFor: id, children: fieldLabel }),
|
|
2050
|
+
/* @__PURE__ */ jsx14("input", { id, value: title, maxLength: 200, onChange: (event) => setTitle(event.target.value) })
|
|
2051
|
+
] })
|
|
2052
|
+
}
|
|
2053
|
+
);
|
|
2054
|
+
}
|
|
2055
|
+
function SaveAsTemplateDialog(props) {
|
|
2056
|
+
const api = useContentAdminApi();
|
|
2057
|
+
const { messages } = useContentText();
|
|
2058
|
+
return /* @__PURE__ */ jsx14(
|
|
2059
|
+
TitleDialog,
|
|
2060
|
+
{
|
|
2061
|
+
...props,
|
|
2062
|
+
heading: messages.saveAsTemplate,
|
|
2063
|
+
fieldLabel: messages.templateNameLabel,
|
|
2064
|
+
confirmLabel: messages.saveAsTemplate,
|
|
2065
|
+
icon: /* @__PURE__ */ jsx14(CopyPlus, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2066
|
+
run: (title) => api.saveAsTemplate ? api.saveAsTemplate(props.post.id, title ? { title } : {}) : Promise.reject(new Error(messages.actionError))
|
|
2067
|
+
}
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
function FromTemplateDialog(props) {
|
|
2071
|
+
const api = useContentAdminApi();
|
|
2072
|
+
const { messages } = useContentText();
|
|
2073
|
+
return /* @__PURE__ */ jsx14(
|
|
2074
|
+
TitleDialog,
|
|
2075
|
+
{
|
|
2076
|
+
...props,
|
|
2077
|
+
heading: messages.newFromTemplate,
|
|
2078
|
+
fieldLabel: messages.newPostTitleLabel,
|
|
2079
|
+
confirmLabel: messages.createDraft,
|
|
2080
|
+
icon: /* @__PURE__ */ jsx14(FilePlus2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2081
|
+
run: (title) => api.createFromTemplate ? api.createFromTemplate(props.post.id, title ? { title } : {}) : Promise.reject(new Error(messages.actionError))
|
|
2082
|
+
}
|
|
2083
|
+
);
|
|
2084
|
+
}
|
|
2085
|
+
function RepublishDialog({
|
|
2086
|
+
post,
|
|
2087
|
+
renderDateTimeInput,
|
|
2088
|
+
onClose,
|
|
2089
|
+
onDone
|
|
2090
|
+
}) {
|
|
2091
|
+
const api = useContentAdminApi();
|
|
2092
|
+
const { messages } = useContentText();
|
|
2093
|
+
const [value, setValue] = useState12(() => toDateTimeLocalValue((/* @__PURE__ */ new Date()).toISOString()));
|
|
2094
|
+
const id = useId7();
|
|
2095
|
+
const action = useAction(() => {
|
|
2096
|
+
if (!api.republishPost) return Promise.reject(new Error(messages.actionError));
|
|
2097
|
+
const publishedAt = fromDateTimeLocalValue(value);
|
|
2098
|
+
return api.republishPost(post.id, publishedAt ? { publishedAt } : {});
|
|
2099
|
+
}, onDone);
|
|
2100
|
+
return /* @__PURE__ */ jsxs12(
|
|
2101
|
+
ActionDialog,
|
|
2102
|
+
{
|
|
2103
|
+
title: messages.republish,
|
|
2104
|
+
confirmLabel: messages.republish,
|
|
2105
|
+
confirmIcon: /* @__PURE__ */ jsx14(RefreshCw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2106
|
+
onClose,
|
|
2107
|
+
onConfirm: action.submit,
|
|
2108
|
+
isBusy: action.isBusy,
|
|
2109
|
+
error: action.error,
|
|
2110
|
+
children: [
|
|
2111
|
+
/* @__PURE__ */ jsx14("p", { className: "adc-muted", children: post.title }),
|
|
2112
|
+
/* @__PURE__ */ jsx14(
|
|
2113
|
+
DateTimeField,
|
|
2114
|
+
{
|
|
2115
|
+
id,
|
|
2116
|
+
label: messages.republishDateLabel,
|
|
2117
|
+
value,
|
|
2118
|
+
onChange: setValue,
|
|
2119
|
+
renderDateTimeInput
|
|
2120
|
+
}
|
|
2121
|
+
),
|
|
2122
|
+
/* @__PURE__ */ jsx14("p", { className: "adc-hint", children: messages.republishHint })
|
|
2123
|
+
]
|
|
2124
|
+
}
|
|
2125
|
+
);
|
|
2126
|
+
}
|
|
2127
|
+
|
|
2128
|
+
// src/components/PostListFooter.tsx
|
|
2129
|
+
import { useId as useId8 } from "react";
|
|
2130
|
+
|
|
1637
2131
|
// src/components/Pagination.tsx
|
|
1638
2132
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
1639
2133
|
|
|
@@ -1657,7 +2151,7 @@ function buildPageItems(params) {
|
|
|
1657
2151
|
}
|
|
1658
2152
|
|
|
1659
2153
|
// src/components/Pagination.tsx
|
|
1660
|
-
import { jsx as
|
|
2154
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1661
2155
|
function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
1662
2156
|
const { messages, format } = useContentText();
|
|
1663
2157
|
const renderLink = useRenderLink();
|
|
@@ -1666,7 +2160,7 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
1666
2160
|
const className = `adc-page${isCurrent ? " adc-page--current" : ""}`;
|
|
1667
2161
|
if (getPageHref && !isCurrent)
|
|
1668
2162
|
return renderLink({ href: getPageHref(target), className, "aria-label": label, children: content });
|
|
1669
|
-
return /* @__PURE__ */
|
|
2163
|
+
return /* @__PURE__ */ jsx15(
|
|
1670
2164
|
"button",
|
|
1671
2165
|
{
|
|
1672
2166
|
type: "button",
|
|
@@ -1679,135 +2173,577 @@ function Pagination({ page, totalPages, getPageHref, onPageChange }) {
|
|
|
1679
2173
|
}
|
|
1680
2174
|
);
|
|
1681
2175
|
}
|
|
1682
|
-
return /* @__PURE__ */
|
|
1683
|
-
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */
|
|
2176
|
+
return /* @__PURE__ */ jsxs13("nav", { className: "adc-pagination", "aria-label": messages.paginationLabel, children: [
|
|
2177
|
+
page > 1 && renderTarget(page - 1, messages.paginationPrevious, /* @__PURE__ */ jsx15(ChevronLeft, { "aria-hidden": "true", className: "adc-icon" })),
|
|
1684
2178
|
buildPageItems({ current: page, total: totalPages }).map(
|
|
1685
|
-
(item) => item.kind === "gap" ? /* @__PURE__ */
|
|
2179
|
+
(item) => item.kind === "gap" ? /* @__PURE__ */ jsx15("span", { className: "adc-page-gap", "aria-hidden": "true", children: "\u2026" }, item.key) : /* @__PURE__ */ jsx15("span", { children: renderTarget(item.page, format("pageLabel", { page: item.page }), item.page, item.page === page) }, item.page)
|
|
1686
2180
|
),
|
|
1687
|
-
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */
|
|
2181
|
+
page < totalPages && renderTarget(page + 1, messages.paginationNext, /* @__PURE__ */ jsx15(ChevronRight, { "aria-hidden": "true", className: "adc-icon" }))
|
|
1688
2182
|
] });
|
|
1689
2183
|
}
|
|
1690
2184
|
|
|
1691
|
-
// src/components/
|
|
1692
|
-
import { jsx as
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
};
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
});
|
|
1705
|
-
const
|
|
1706
|
-
const
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
2185
|
+
// src/components/SelectField.tsx
|
|
2186
|
+
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2187
|
+
function SelectField({ renderSelect, ...props }) {
|
|
2188
|
+
if (renderSelect) return renderSelect(props);
|
|
2189
|
+
return /* @__PURE__ */ jsxs14("div", { className: "adc-field", children: [
|
|
2190
|
+
/* @__PURE__ */ jsx16("label", { htmlFor: props.id, children: props.label }),
|
|
2191
|
+
/* @__PURE__ */ jsx16("select", { id: props.id, value: props.value, onChange: (event) => props.onChange(event.target.value), children: props.options.map((option) => /* @__PURE__ */ jsx16("option", { value: option.id, children: option.label }, option.id)) })
|
|
2192
|
+
] });
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
// src/components/PostListFooter.tsx
|
|
2196
|
+
import { jsx as jsx17, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2197
|
+
function PostListFooter({ data, pageSize, onPage, onPageSize, renderSelect }) {
|
|
2198
|
+
const { messages, format } = useContentText();
|
|
2199
|
+
const id = useId8();
|
|
2200
|
+
const { page, total } = data.pagination;
|
|
2201
|
+
const from = total === 0 ? 0 : (page - 1) * pageSize + 1;
|
|
2202
|
+
const to = Math.min(page * pageSize, total);
|
|
2203
|
+
return /* @__PURE__ */ jsxs15("div", { className: "adc-list-footer", children: [
|
|
2204
|
+
/* @__PURE__ */ jsx17("span", { className: "adc-muted", "aria-live": "polite", children: format("rangeLabel", { from, to, total }) }),
|
|
2205
|
+
/* @__PURE__ */ jsx17(Pagination, { page, totalPages: data.pagination.totalPages, onPageChange: onPage }),
|
|
2206
|
+
/* @__PURE__ */ jsx17(
|
|
2207
|
+
SelectField,
|
|
2208
|
+
{
|
|
2209
|
+
id,
|
|
2210
|
+
label: messages.itemsPerPage,
|
|
2211
|
+
value: String(pageSize),
|
|
2212
|
+
options: PAGE_SIZE_OPTIONS.map((size) => ({ id: String(size), label: String(size) })),
|
|
2213
|
+
onChange: (value) => onPageSize(Number(value)),
|
|
2214
|
+
renderSelect
|
|
2215
|
+
}
|
|
2216
|
+
)
|
|
2217
|
+
] });
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2220
|
+
// src/components/PostListTabs.tsx
|
|
2221
|
+
import { CalendarClock as CalendarClock3, CircleCheck as CircleCheck3, Copy as Copy2, PencilLine as PencilLine2 } from "lucide-react";
|
|
2222
|
+
import { jsx as jsx18, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2223
|
+
var TABS2 = [
|
|
2224
|
+
{ id: POST_LIST_TAB.PUBLISHED, icon: CircleCheck3, label: "tabPublished", count: "published" },
|
|
2225
|
+
{ id: POST_LIST_TAB.SCHEDULED, icon: CalendarClock3, label: "tabScheduled", count: "scheduled" },
|
|
2226
|
+
{ id: POST_LIST_TAB.DRAFT, icon: PencilLine2, label: "tabDraft", count: "draft" },
|
|
2227
|
+
{ id: POST_LIST_TAB.TEMPLATES, icon: Copy2, label: "tabTemplates", count: "templates" }
|
|
2228
|
+
];
|
|
2229
|
+
function PostListTabs({ active, counts, onChange }) {
|
|
2230
|
+
const { messages } = useContentText();
|
|
2231
|
+
return /* @__PURE__ */ jsx18("div", { className: "adc-status-tabs", role: "tablist", "aria-label": messages.tabsLabel, children: TABS2.map(({ id, icon: Icon, label, count }) => /* @__PURE__ */ jsxs16(
|
|
2232
|
+
"button",
|
|
2233
|
+
{
|
|
2234
|
+
type: "button",
|
|
2235
|
+
role: "tab",
|
|
2236
|
+
"aria-selected": id === active,
|
|
2237
|
+
className: `adc-status-tab adc-status-tab--${id}`,
|
|
2238
|
+
onClick: () => onChange(id),
|
|
2239
|
+
children: [
|
|
2240
|
+
/* @__PURE__ */ jsx18(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2241
|
+
/* @__PURE__ */ jsx18("span", { children: messages[label] }),
|
|
2242
|
+
/* @__PURE__ */ jsx18("span", { className: "adc-status-tab__count", children: counts ? counts[count] : "\u2013" })
|
|
2243
|
+
]
|
|
2244
|
+
},
|
|
2245
|
+
id
|
|
2246
|
+
)) });
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
// src/components/PostListToolbar.tsx
|
|
2250
|
+
import { formatTagLabel } from "@adatechnology/content-contracts";
|
|
2251
|
+
import { Plus, RotateCcw, Search } from "lucide-react";
|
|
2252
|
+
import { useId as useId9 } from "react";
|
|
2253
|
+
import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2254
|
+
function PostListToolbar(props) {
|
|
2255
|
+
const { messages } = useContentText();
|
|
2256
|
+
const searchId = useId9();
|
|
2257
|
+
return /* @__PURE__ */ jsxs17("div", { className: "adc-list-toolbar", children: [
|
|
2258
|
+
/* @__PURE__ */ jsxs17("div", { className: "adc-list-toolbar__filters", children: [
|
|
2259
|
+
/* @__PURE__ */ jsxs17("div", { className: "adc-field adc-field--search", children: [
|
|
2260
|
+
/* @__PURE__ */ jsx19("label", { htmlFor: searchId, className: "adc-visually-hidden", children: messages.searchLabel }),
|
|
2261
|
+
/* @__PURE__ */ jsxs17("div", { className: "adc-input-icon", children: [
|
|
2262
|
+
/* @__PURE__ */ jsx19(Search, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2263
|
+
/* @__PURE__ */ jsx19(
|
|
1722
2264
|
"input",
|
|
1723
2265
|
{
|
|
1724
2266
|
id: searchId,
|
|
1725
|
-
type: "
|
|
2267
|
+
type: "text",
|
|
2268
|
+
inputMode: "search",
|
|
2269
|
+
autoComplete: "off",
|
|
1726
2270
|
placeholder: messages.searchPlaceholder,
|
|
1727
|
-
value:
|
|
1728
|
-
onChange: (event) =>
|
|
2271
|
+
value: props.search,
|
|
2272
|
+
onChange: (event) => props.onSearch(event.target.value)
|
|
1729
2273
|
}
|
|
1730
2274
|
)
|
|
1731
2275
|
] })
|
|
1732
2276
|
] }),
|
|
1733
|
-
/* @__PURE__ */
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
"
|
|
2277
|
+
props.tags && props.tags.length > 0 && /* @__PURE__ */ jsx19("div", { className: "adc-tag-toggles", role: "group", "aria-label": messages.filterTag, children: props.tags.slice(0, 12).map((entry) => /* @__PURE__ */ jsxs17(
|
|
2278
|
+
"button",
|
|
2279
|
+
{
|
|
2280
|
+
type: "button",
|
|
2281
|
+
className: "adc-tag-toggle",
|
|
2282
|
+
"aria-pressed": props.selectedTags.includes(entry.tag),
|
|
2283
|
+
onClick: () => props.onToggleTag(entry.tag),
|
|
2284
|
+
children: [
|
|
2285
|
+
formatTagLabel(entry.tag),
|
|
2286
|
+
/* @__PURE__ */ jsx19("span", { className: "adc-tag-toggle__count", children: entry.count })
|
|
2287
|
+
]
|
|
2288
|
+
},
|
|
2289
|
+
entry.tag
|
|
2290
|
+
)) }),
|
|
2291
|
+
props.hasFilters && /* @__PURE__ */ jsxs17("button", { type: "button", className: "adc-button adc-button--ghost", onClick: props.onClear, children: [
|
|
2292
|
+
/* @__PURE__ */ jsx19(RotateCcw, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2293
|
+
messages.clearFilters
|
|
2294
|
+
] })
|
|
2295
|
+
] }),
|
|
2296
|
+
props.onCreate && /* @__PURE__ */ jsxs17("button", { type: "button", className: "adc-button adc-button--primary", onClick: props.onCreate, children: [
|
|
2297
|
+
/* @__PURE__ */ jsx19(Plus, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2298
|
+
messages.newPost
|
|
2299
|
+
] })
|
|
2300
|
+
] });
|
|
2301
|
+
}
|
|
2302
|
+
|
|
2303
|
+
// src/components/PostTable.tsx
|
|
2304
|
+
import { ArrowDown, ArrowUp, ChevronsUpDown } from "lucide-react";
|
|
2305
|
+
|
|
2306
|
+
// src/components/CheckBox.tsx
|
|
2307
|
+
import { Check, Minus } from "lucide-react";
|
|
2308
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
2309
|
+
function CheckBox({ checked, isMixed = false, label, onChange }) {
|
|
2310
|
+
const Icon = isMixed ? Minus : Check;
|
|
2311
|
+
return /* @__PURE__ */ jsx20(
|
|
2312
|
+
"button",
|
|
2313
|
+
{
|
|
2314
|
+
type: "button",
|
|
2315
|
+
role: "checkbox",
|
|
2316
|
+
"aria-checked": isMixed ? "mixed" : checked,
|
|
2317
|
+
"aria-label": label,
|
|
2318
|
+
className: `adc-checkbox${checked || isMixed ? " is-on" : ""}`,
|
|
2319
|
+
onClick: onChange,
|
|
2320
|
+
children: (checked || isMixed) && /* @__PURE__ */ jsx20(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2321
|
+
}
|
|
2322
|
+
);
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
// src/components/PostTable.tsx
|
|
2326
|
+
import { jsx as jsx21, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2327
|
+
var SORTABLE_COLUMNS = [
|
|
2328
|
+
{ field: "title", label: "columnTitle" },
|
|
2329
|
+
{ field: "status", label: "columnStatus" },
|
|
2330
|
+
{ field: "publishedAt", label: "columnPublished" },
|
|
2331
|
+
{ field: "updatedAt", label: "columnUpdated" }
|
|
2332
|
+
];
|
|
2333
|
+
function PostTable(props) {
|
|
2334
|
+
const { messages, locale } = useContentText();
|
|
2335
|
+
const selectedCount = props.rows.filter((row) => props.selectedIds.has(row.id)).length;
|
|
2336
|
+
const isAll = selectedCount > 0 && selectedCount === props.rows.length;
|
|
2337
|
+
return /* @__PURE__ */ jsx21("div", { className: "adc-table-wrap", "aria-busy": props.isBusy, children: /* @__PURE__ */ jsxs18("table", { className: "adc-table", children: [
|
|
2338
|
+
/* @__PURE__ */ jsx21("thead", { children: /* @__PURE__ */ jsxs18("tr", { children: [
|
|
2339
|
+
/* @__PURE__ */ jsx21("th", { scope: "col", className: "adc-table__check", children: /* @__PURE__ */ jsx21(
|
|
2340
|
+
CheckBox,
|
|
2341
|
+
{
|
|
2342
|
+
checked: isAll,
|
|
2343
|
+
isMixed: selectedCount > 0 && !isAll,
|
|
2344
|
+
label: messages.selectAll,
|
|
2345
|
+
onChange: props.onToggleAll
|
|
2346
|
+
}
|
|
2347
|
+
) }),
|
|
2348
|
+
SORTABLE_COLUMNS.map(({ field, label }) => {
|
|
2349
|
+
const isActive = props.sort === field;
|
|
2350
|
+
const Icon = !isActive ? ChevronsUpDown : props.order === "asc" ? ArrowUp : ArrowDown;
|
|
2351
|
+
return /* @__PURE__ */ jsx21(
|
|
2352
|
+
"th",
|
|
1737
2353
|
{
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
/* @__PURE__ */
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
)
|
|
2354
|
+
scope: "col",
|
|
2355
|
+
"aria-sort": !isActive ? "none" : props.order === "asc" ? "ascending" : "descending",
|
|
2356
|
+
children: /* @__PURE__ */ jsxs18("button", { type: "button", className: "adc-sort", onClick: () => props.onSort(field), children: [
|
|
2357
|
+
messages[label],
|
|
2358
|
+
/* @__PURE__ */ jsx21(Icon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2359
|
+
] })
|
|
2360
|
+
},
|
|
2361
|
+
field
|
|
2362
|
+
);
|
|
2363
|
+
}),
|
|
2364
|
+
props.hasActions && /* @__PURE__ */ jsx21("th", { scope: "col", children: messages.columnActions })
|
|
2365
|
+
] }) }),
|
|
2366
|
+
/* @__PURE__ */ jsx21("tbody", { children: props.rows.map((post) => /* @__PURE__ */ jsxs18("tr", { className: props.selectedIds.has(post.id) ? "is-selected" : void 0, children: [
|
|
2367
|
+
/* @__PURE__ */ jsx21("td", { className: "adc-table__check", children: /* @__PURE__ */ jsx21(
|
|
2368
|
+
CheckBox,
|
|
2369
|
+
{
|
|
2370
|
+
checked: props.selectedIds.has(post.id),
|
|
2371
|
+
label: messages.selectRow.replace("{title}", post.title),
|
|
2372
|
+
onChange: () => props.onToggleSelected(post.id)
|
|
2373
|
+
}
|
|
2374
|
+
) }),
|
|
2375
|
+
/* @__PURE__ */ jsxs18("td", { children: [
|
|
2376
|
+
/* @__PURE__ */ jsx21("button", { type: "button", className: "adc-row-link", onClick: () => props.onSelect(post), children: post.title }),
|
|
2377
|
+
/* @__PURE__ */ jsxs18("span", { className: "adc-muted adc-slug", children: [
|
|
2378
|
+
"/",
|
|
2379
|
+
post.slug
|
|
2380
|
+
] })
|
|
1747
2381
|
] }),
|
|
1748
|
-
/* @__PURE__ */
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
2382
|
+
/* @__PURE__ */ jsx21("td", { children: /* @__PURE__ */ jsx21(StatusChip, { status: post.status, isTemplate: post.isTemplate }) }),
|
|
2383
|
+
/* @__PURE__ */ jsx21("td", { children: formatPostDate(post.publishedAt, locale, true) }),
|
|
2384
|
+
/* @__PURE__ */ jsx21("td", { children: formatPostDate(post.updatedAt, locale, true) }),
|
|
2385
|
+
props.hasActions && /* @__PURE__ */ jsx21("td", { className: "adc-row-actions", children: props.renderActions(post) })
|
|
2386
|
+
] }, post.id)) })
|
|
2387
|
+
] }) });
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// src/components/RecurrencePanel.tsx
|
|
2391
|
+
import {
|
|
2392
|
+
RECURRENCE_FREQUENCY
|
|
2393
|
+
} from "@adatechnology/content-contracts";
|
|
2394
|
+
import { CirclePause, CirclePlay, Plus as Plus2, Repeat, Trash2 as Trash22 } from "lucide-react";
|
|
2395
|
+
import { useId as useId10, useState as useState13 } from "react";
|
|
2396
|
+
import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2397
|
+
function defaultStart() {
|
|
2398
|
+
const next = new Date(Date.now() + 24 * 60 * 60 * 1e3);
|
|
2399
|
+
next.setMinutes(0, 0, 0);
|
|
2400
|
+
return toDateTimeLocalValue(next.toISOString());
|
|
2401
|
+
}
|
|
2402
|
+
function CreateRecurrenceDialog({
|
|
2403
|
+
templates,
|
|
2404
|
+
renderDateTimeInput,
|
|
2405
|
+
renderSelect,
|
|
2406
|
+
onClose,
|
|
2407
|
+
onCreated
|
|
2408
|
+
}) {
|
|
2409
|
+
const api = useContentAdminApi();
|
|
2410
|
+
const { messages } = useContentText();
|
|
2411
|
+
const [templateId, setTemplateId] = useState13(templates[0]?.id ?? "");
|
|
2412
|
+
const [frequency, setFrequency] = useState13(RECURRENCE_FREQUENCY.WEEKLY);
|
|
2413
|
+
const [startsAt, setStartsAt] = useState13(defaultStart);
|
|
2414
|
+
const [isBusy, setIsBusy] = useState13(false);
|
|
2415
|
+
const [error, setError] = useState13();
|
|
2416
|
+
const ids = { template: useId10(), frequency: useId10(), start: useId10() };
|
|
2417
|
+
async function submit() {
|
|
2418
|
+
const iso = fromDateTimeLocalValue(startsAt);
|
|
2419
|
+
if (!api.createRecurrence || !iso || !templateId) return;
|
|
2420
|
+
setIsBusy(true);
|
|
2421
|
+
try {
|
|
2422
|
+
await api.createRecurrence({ templateId, frequency, startsAt: iso });
|
|
2423
|
+
onCreated();
|
|
2424
|
+
} catch (caught) {
|
|
2425
|
+
setError(caught instanceof Error && caught.message ? caught.message : messages.actionError);
|
|
2426
|
+
setIsBusy(false);
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
return /* @__PURE__ */ jsxs19(
|
|
2430
|
+
ActionDialog,
|
|
2431
|
+
{
|
|
2432
|
+
title: messages.recurrenceNew,
|
|
2433
|
+
confirmLabel: messages.recurrenceCreate,
|
|
2434
|
+
confirmIcon: /* @__PURE__ */ jsx22(Repeat, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2435
|
+
isBusy,
|
|
2436
|
+
error,
|
|
2437
|
+
onClose,
|
|
2438
|
+
onConfirm: () => void submit(),
|
|
2439
|
+
children: [
|
|
2440
|
+
/* @__PURE__ */ jsx22(
|
|
2441
|
+
SelectField,
|
|
1752
2442
|
{
|
|
1753
|
-
id:
|
|
1754
|
-
|
|
1755
|
-
value:
|
|
1756
|
-
|
|
2443
|
+
id: ids.template,
|
|
2444
|
+
label: messages.recurrenceTemplate,
|
|
2445
|
+
value: templateId,
|
|
2446
|
+
options: templates.map((template) => ({ id: template.id, label: template.title })),
|
|
2447
|
+
onChange: setTemplateId,
|
|
2448
|
+
renderSelect
|
|
1757
2449
|
}
|
|
1758
2450
|
),
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
2451
|
+
/* @__PURE__ */ jsx22(
|
|
2452
|
+
SelectField,
|
|
2453
|
+
{
|
|
2454
|
+
id: ids.frequency,
|
|
2455
|
+
label: messages.recurrenceFrequency,
|
|
2456
|
+
value: frequency,
|
|
2457
|
+
options: [
|
|
2458
|
+
{ id: RECURRENCE_FREQUENCY.WEEKLY, label: messages.frequencyWeekly },
|
|
2459
|
+
{ id: RECURRENCE_FREQUENCY.MONTHLY, label: messages.frequencyMonthly }
|
|
2460
|
+
],
|
|
2461
|
+
onChange: (value) => setFrequency(value),
|
|
2462
|
+
renderSelect
|
|
2463
|
+
}
|
|
2464
|
+
),
|
|
2465
|
+
/* @__PURE__ */ jsx22(
|
|
2466
|
+
DateTimeField,
|
|
2467
|
+
{
|
|
2468
|
+
id: ids.start,
|
|
2469
|
+
label: messages.recurrenceStart,
|
|
2470
|
+
value: startsAt,
|
|
2471
|
+
onChange: setStartsAt,
|
|
2472
|
+
renderDateTimeInput
|
|
2473
|
+
}
|
|
2474
|
+
),
|
|
2475
|
+
/* @__PURE__ */ jsx22("p", { className: "adc-hint", children: messages.recurrenceHint })
|
|
2476
|
+
]
|
|
2477
|
+
}
|
|
2478
|
+
);
|
|
2479
|
+
}
|
|
2480
|
+
function RuleRow({ rule, onChanged }) {
|
|
2481
|
+
const api = useContentAdminApi();
|
|
2482
|
+
const { messages, locale, format } = useContentText();
|
|
2483
|
+
const toggleLabel = rule.isActive ? messages.recurrencePause : messages.recurrenceResume;
|
|
2484
|
+
const ToggleIcon = rule.isActive ? CirclePause : CirclePlay;
|
|
2485
|
+
const StateIcon = rule.isActive ? CirclePlay : CirclePause;
|
|
2486
|
+
async function toggle() {
|
|
2487
|
+
await api.updateRecurrence?.(rule.id, { isActive: !rule.isActive });
|
|
2488
|
+
onChanged();
|
|
2489
|
+
}
|
|
2490
|
+
async function remove() {
|
|
2491
|
+
await api.removeRecurrence?.(rule.id);
|
|
2492
|
+
onChanged();
|
|
2493
|
+
}
|
|
2494
|
+
return /* @__PURE__ */ jsxs19("li", { className: "adc-rule", children: [
|
|
2495
|
+
/* @__PURE__ */ jsxs19("div", { className: "adc-rule__main", children: [
|
|
2496
|
+
/* @__PURE__ */ jsx22("strong", { children: rule.templateTitle }),
|
|
2497
|
+
/* @__PURE__ */ jsxs19("span", { className: "adc-muted", children: [
|
|
2498
|
+
rule.frequency === RECURRENCE_FREQUENCY.WEEKLY ? messages.frequencyWeekly : messages.frequencyMonthly,
|
|
2499
|
+
rule.isActive && ` \xB7 ${format("recurrenceNext", { date: formatPostDate(rule.nextRunAt, locale, true) })}`
|
|
1764
2500
|
] })
|
|
1765
2501
|
] }),
|
|
1766
|
-
|
|
2502
|
+
/* @__PURE__ */ jsxs19("span", { className: `adc-chip adc-badge adc-chip--${rule.isActive ? "published" : "draft"}`, children: [
|
|
2503
|
+
/* @__PURE__ */ jsx22(StateIcon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2504
|
+
rule.isActive ? messages.recurrenceActive : messages.recurrencePaused
|
|
2505
|
+
] }),
|
|
2506
|
+
/* @__PURE__ */ jsx22(Tooltip, { text: toggleLabel, children: /* @__PURE__ */ jsx22(
|
|
2507
|
+
"button",
|
|
2508
|
+
{
|
|
2509
|
+
type: "button",
|
|
2510
|
+
className: "adc-button adc-button--ghost adc-button--icon",
|
|
2511
|
+
"aria-label": toggleLabel,
|
|
2512
|
+
onClick: () => void toggle(),
|
|
2513
|
+
children: /* @__PURE__ */ jsx22(ToggleIcon, { "aria-hidden": "true", className: "adc-icon" })
|
|
2514
|
+
}
|
|
2515
|
+
) }),
|
|
2516
|
+
/* @__PURE__ */ jsx22(Tooltip, { text: messages.recurrenceRemoveTip, children: /* @__PURE__ */ jsx22(
|
|
2517
|
+
"button",
|
|
2518
|
+
{
|
|
2519
|
+
type: "button",
|
|
2520
|
+
className: "adc-button adc-button--ghost adc-button--icon adc-button--danger",
|
|
2521
|
+
"aria-label": messages.recurrenceRemove,
|
|
2522
|
+
onClick: () => void remove(),
|
|
2523
|
+
children: /* @__PURE__ */ jsx22(Trash22, { "aria-hidden": "true", className: "adc-icon" })
|
|
2524
|
+
}
|
|
2525
|
+
) })
|
|
2526
|
+
] });
|
|
2527
|
+
}
|
|
2528
|
+
function RecurrencePanel(props) {
|
|
2529
|
+
const api = useContentAdminApi();
|
|
2530
|
+
const { messages } = useContentText();
|
|
2531
|
+
const [isCreating, setIsCreating] = useState13(false);
|
|
2532
|
+
const rules = useAsyncResource(
|
|
2533
|
+
() => api.listRecurrences ? api.listRecurrences() : Promise.resolve([]),
|
|
2534
|
+
"recurrences"
|
|
2535
|
+
);
|
|
2536
|
+
if (!api.listRecurrences) return null;
|
|
2537
|
+
return /* @__PURE__ */ jsxs19("section", { className: "adc-recurrence", "aria-labelledby": "adc-recurrence-title", children: [
|
|
2538
|
+
/* @__PURE__ */ jsxs19("header", { className: "adc-toolbar", children: [
|
|
2539
|
+
/* @__PURE__ */ jsxs19("h3", { id: "adc-recurrence-title", className: "adc-subtitle", children: [
|
|
2540
|
+
/* @__PURE__ */ jsx22(Repeat, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2541
|
+
" ",
|
|
2542
|
+
messages.recurrenceTitle
|
|
2543
|
+
] }),
|
|
2544
|
+
/* @__PURE__ */ jsxs19(
|
|
2545
|
+
"button",
|
|
2546
|
+
{
|
|
2547
|
+
type: "button",
|
|
2548
|
+
className: "adc-button",
|
|
2549
|
+
disabled: props.templates.length === 0,
|
|
2550
|
+
onClick: () => setIsCreating(true),
|
|
2551
|
+
children: [
|
|
2552
|
+
/* @__PURE__ */ jsx22(Plus2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2553
|
+
messages.recurrenceNew
|
|
2554
|
+
]
|
|
2555
|
+
}
|
|
2556
|
+
)
|
|
2557
|
+
] }),
|
|
2558
|
+
(rules.data?.length ?? 0) === 0 ? /* @__PURE__ */ jsx22("p", { className: "adc-state", children: props.templates.length === 0 ? messages.recurrenceNeedsTemplate : messages.recurrenceEmpty }) : /* @__PURE__ */ jsx22("ul", { className: "adc-rule-list", children: rules.data?.map((rule) => /* @__PURE__ */ jsx22(RuleRow, { rule, onChanged: rules.reload }, rule.id)) }),
|
|
2559
|
+
isCreating && /* @__PURE__ */ jsx22(
|
|
2560
|
+
CreateRecurrenceDialog,
|
|
2561
|
+
{
|
|
2562
|
+
...props,
|
|
2563
|
+
onClose: () => setIsCreating(false),
|
|
2564
|
+
onCreated: () => {
|
|
2565
|
+
setIsCreating(false);
|
|
2566
|
+
rules.reload();
|
|
2567
|
+
}
|
|
2568
|
+
}
|
|
2569
|
+
)
|
|
2570
|
+
] });
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
// src/components/PostList.tsx
|
|
2574
|
+
import { jsx as jsx23, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2575
|
+
function buildExportFilters(state, tab) {
|
|
2576
|
+
return {
|
|
2577
|
+
...tab ? { tab } : {},
|
|
2578
|
+
...state.search ? { search: state.search } : {},
|
|
2579
|
+
...state.tags.length > 0 ? { tag: state.tags.join(",") } : {},
|
|
2580
|
+
sort: state.sort,
|
|
2581
|
+
order: state.order
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
function PostList({
|
|
2585
|
+
onSelect,
|
|
2586
|
+
onCreate,
|
|
2587
|
+
pageSize = 20,
|
|
2588
|
+
reloadKey,
|
|
2589
|
+
syncUrl,
|
|
2590
|
+
renderDateTimeInput,
|
|
2591
|
+
renderSelect,
|
|
2592
|
+
renderExport
|
|
2593
|
+
}) {
|
|
2594
|
+
const { messages } = useContentText();
|
|
2595
|
+
const api = useContentAdminApi();
|
|
2596
|
+
const [dialog, setDialog] = useState14();
|
|
2597
|
+
const list = usePostList({
|
|
2598
|
+
pageSize,
|
|
2599
|
+
...reloadKey !== void 0 ? { reloadKey } : {},
|
|
2600
|
+
...syncUrl ? { syncUrl } : {}
|
|
2601
|
+
});
|
|
2602
|
+
const { posts, state, tab } = list;
|
|
2603
|
+
const rows = posts.data?.data ?? [];
|
|
2604
|
+
function actionsFor(post) {
|
|
2605
|
+
if (post.isTemplate) {
|
|
2606
|
+
return api.createFromTemplate ? [
|
|
2607
|
+
{
|
|
2608
|
+
action: "fromTemplate",
|
|
2609
|
+
icon: FilePlus22,
|
|
2610
|
+
label: messages.newFromTemplate,
|
|
2611
|
+
tip: messages.newFromTemplateTip
|
|
2612
|
+
}
|
|
2613
|
+
] : [];
|
|
2614
|
+
}
|
|
2615
|
+
return [
|
|
2616
|
+
...post.status === "published" && api.republishPost ? [{ action: "republish", icon: RefreshCw2, label: messages.republish, tip: messages.republishTip }] : [],
|
|
2617
|
+
...api.saveAsTemplate ? [
|
|
2618
|
+
{
|
|
2619
|
+
action: "saveAsTemplate",
|
|
2620
|
+
icon: CopyPlus2,
|
|
2621
|
+
label: messages.saveAsTemplate,
|
|
2622
|
+
tip: messages.saveAsTemplateTip
|
|
2623
|
+
}
|
|
2624
|
+
] : []
|
|
2625
|
+
];
|
|
2626
|
+
}
|
|
2627
|
+
function handleActionDone(post) {
|
|
2628
|
+
const action = dialog?.action;
|
|
2629
|
+
setDialog(void 0);
|
|
2630
|
+
list.refresh();
|
|
2631
|
+
if (action === "fromTemplate") onSelect(post);
|
|
2632
|
+
if (action === "saveAsTemplate") list.setTab(POST_LIST_TAB.TEMPLATES);
|
|
2633
|
+
}
|
|
2634
|
+
function toggleAll() {
|
|
2635
|
+
list.setSelectedIds(list.selectedIds.size === rows.length ? /* @__PURE__ */ new Set() : new Set(rows.map((row) => row.id)));
|
|
2636
|
+
}
|
|
2637
|
+
return /* @__PURE__ */ jsxs20("section", { className: "adc-root adc-post-list", children: [
|
|
2638
|
+
/* @__PURE__ */ jsxs20("header", { className: "adc-toolbar", children: [
|
|
2639
|
+
/* @__PURE__ */ jsx23("h2", { className: "adc-title", children: messages.listTitle }),
|
|
2640
|
+
renderExport && posts.data ? renderExport({
|
|
2641
|
+
total: posts.data.pagination.total,
|
|
2642
|
+
page: state.page,
|
|
2643
|
+
pageSize: list.pageSize,
|
|
2644
|
+
pageCount: posts.data.data.length,
|
|
2645
|
+
filters: buildExportFilters(list.state, tab)
|
|
2646
|
+
}) : null
|
|
2647
|
+
] }),
|
|
2648
|
+
/* @__PURE__ */ jsx23(
|
|
2649
|
+
PostListToolbar,
|
|
2650
|
+
{
|
|
2651
|
+
search: state.search,
|
|
2652
|
+
onSearch: list.setSearch,
|
|
2653
|
+
tags: list.tags,
|
|
2654
|
+
selectedTags: state.tags,
|
|
2655
|
+
onToggleTag: list.toggleTag,
|
|
2656
|
+
hasFilters: list.hasFilters,
|
|
2657
|
+
onClear: list.clearFilters,
|
|
2658
|
+
onCreate
|
|
2659
|
+
}
|
|
2660
|
+
),
|
|
2661
|
+
tab && /* @__PURE__ */ jsx23(PostListTabs, { active: tab, counts: list.counts, onChange: list.setTab }),
|
|
2662
|
+
list.selectedIds.size > 0 && /* @__PURE__ */ jsx23(
|
|
2663
|
+
BatchBar,
|
|
2664
|
+
{
|
|
2665
|
+
ids: [...list.selectedIds],
|
|
2666
|
+
tab,
|
|
2667
|
+
onClearSelection: () => list.setSelectedIds(/* @__PURE__ */ new Set()),
|
|
2668
|
+
onDone: list.refresh
|
|
2669
|
+
}
|
|
2670
|
+
),
|
|
2671
|
+
posts.error !== void 0 && !posts.isLoading ? /* @__PURE__ */ jsxs20("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
1767
2672
|
messages.loadError,
|
|
1768
|
-
/* @__PURE__ */
|
|
1769
|
-
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
2673
|
+
/* @__PURE__ */ jsx23("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
2674
|
+
] }) : posts.isLoading && !posts.data ? /* @__PURE__ */ jsx23("p", { className: "adc-state", role: "status", children: messages.loading }) : rows.length === 0 ? /* @__PURE__ */ jsx23("p", { className: "adc-state", children: tab === POST_LIST_TAB.TEMPLATES ? messages.emptyTemplates : messages.empty }) : /* @__PURE__ */ jsx23(
|
|
2675
|
+
PostTable,
|
|
2676
|
+
{
|
|
2677
|
+
rows,
|
|
2678
|
+
sort: state.sort,
|
|
2679
|
+
order: state.order,
|
|
2680
|
+
onSort: list.toggleSort,
|
|
2681
|
+
selectedIds: list.selectedIds,
|
|
2682
|
+
onToggleSelected: list.toggleSelected,
|
|
2683
|
+
onToggleAll: toggleAll,
|
|
2684
|
+
onSelect,
|
|
2685
|
+
hasActions: Boolean(tab),
|
|
2686
|
+
isBusy: posts.isLoading,
|
|
2687
|
+
renderActions: (post) => actionsFor(post).map(({ action, icon: Icon, label, tip }) => /* @__PURE__ */ jsx23(Tooltip, { text: tip, children: /* @__PURE__ */ jsxs20(
|
|
2688
|
+
"button",
|
|
2689
|
+
{
|
|
2690
|
+
type: "button",
|
|
2691
|
+
className: "adc-button adc-button--compact",
|
|
2692
|
+
onClick: () => setDialog({ action, post }),
|
|
2693
|
+
children: [
|
|
2694
|
+
/* @__PURE__ */ jsx23(Icon, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2695
|
+
label
|
|
2696
|
+
]
|
|
2697
|
+
}
|
|
2698
|
+
) }, action))
|
|
2699
|
+
}
|
|
2700
|
+
),
|
|
2701
|
+
posts.data && /* @__PURE__ */ jsx23(
|
|
2702
|
+
PostListFooter,
|
|
2703
|
+
{
|
|
2704
|
+
data: posts.data,
|
|
2705
|
+
pageSize: list.pageSize,
|
|
2706
|
+
onPage: list.setPage,
|
|
2707
|
+
onPageSize: list.setPageSize,
|
|
2708
|
+
renderSelect
|
|
2709
|
+
}
|
|
2710
|
+
),
|
|
2711
|
+
tab === POST_LIST_TAB.TEMPLATES && /* @__PURE__ */ jsx23(RecurrencePanel, { templates: rows, renderDateTimeInput, renderSelect }),
|
|
2712
|
+
dialog?.action === "saveAsTemplate" && /* @__PURE__ */ jsx23(SaveAsTemplateDialog, { post: dialog.post, onClose: () => setDialog(void 0), onDone: handleActionDone }),
|
|
2713
|
+
dialog?.action === "fromTemplate" && /* @__PURE__ */ jsx23(FromTemplateDialog, { post: dialog.post, onClose: () => setDialog(void 0), onDone: handleActionDone }),
|
|
2714
|
+
dialog?.action === "republish" && /* @__PURE__ */ jsx23(
|
|
2715
|
+
RepublishDialog,
|
|
2716
|
+
{
|
|
2717
|
+
post: dialog.post,
|
|
2718
|
+
renderDateTimeInput,
|
|
2719
|
+
onClose: () => setDialog(void 0),
|
|
2720
|
+
onDone: handleActionDone
|
|
2721
|
+
}
|
|
2722
|
+
)
|
|
1790
2723
|
] });
|
|
1791
2724
|
}
|
|
1792
2725
|
|
|
1793
2726
|
// src/components/ContentWorkspace.tsx
|
|
1794
|
-
import { jsx as
|
|
2727
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
1795
2728
|
function ContentWorkspace({
|
|
1796
2729
|
pageSize,
|
|
1797
2730
|
newPostDefaults,
|
|
1798
2731
|
onPostSaved,
|
|
1799
|
-
|
|
1800
|
-
|
|
2732
|
+
renderDateTimeInput,
|
|
2733
|
+
renderSelect,
|
|
2734
|
+
syncUrl,
|
|
2735
|
+
renderExport,
|
|
2736
|
+
showFormattingToolbar
|
|
1801
2737
|
}) {
|
|
1802
|
-
const [view, setView] =
|
|
1803
|
-
const [reloadKey, setReloadKey] =
|
|
2738
|
+
const [view, setView] = useState15({ kind: "list" });
|
|
2739
|
+
const [reloadKey, setReloadKey] = useState15(0);
|
|
1804
2740
|
function handleSaved(post) {
|
|
1805
2741
|
setReloadKey((value) => value + 1);
|
|
1806
2742
|
setView({ kind: "editor", postId: post.id });
|
|
1807
2743
|
onPostSaved?.(post);
|
|
1808
2744
|
}
|
|
1809
2745
|
if (view.kind === "editor") {
|
|
1810
|
-
return /* @__PURE__ */
|
|
2746
|
+
return /* @__PURE__ */ jsx24(
|
|
1811
2747
|
PostEditor,
|
|
1812
2748
|
{
|
|
1813
2749
|
...view.postId ? { postId: view.postId } : {},
|
|
@@ -1824,25 +2760,30 @@ function ContentWorkspace({
|
|
|
1824
2760
|
view.postId ?? "new"
|
|
1825
2761
|
);
|
|
1826
2762
|
}
|
|
1827
|
-
return /* @__PURE__ */
|
|
2763
|
+
return /* @__PURE__ */ jsx24(
|
|
1828
2764
|
PostList,
|
|
1829
2765
|
{
|
|
1830
2766
|
reloadKey,
|
|
2767
|
+
...renderDateTimeInput ? { renderDateTimeInput } : {},
|
|
2768
|
+
...renderSelect ? { renderSelect } : {},
|
|
2769
|
+
...syncUrl ? { syncUrl } : {},
|
|
1831
2770
|
...pageSize ? { pageSize } : {},
|
|
1832
2771
|
onSelect: (post) => setView({ kind: "editor", postId: post.id }),
|
|
1833
|
-
onCreate: () => setView({ kind: "editor" })
|
|
2772
|
+
onCreate: () => setView({ kind: "editor" }),
|
|
2773
|
+
...renderExport ? { renderExport } : {}
|
|
1834
2774
|
}
|
|
1835
2775
|
);
|
|
1836
2776
|
}
|
|
1837
2777
|
|
|
1838
2778
|
// src/components/PostCard.tsx
|
|
1839
|
-
import {
|
|
2779
|
+
import { formatTagLabel as formatTagLabel2 } from "@adatechnology/content-contracts";
|
|
2780
|
+
import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
1840
2781
|
function PostCard({ post, href, headingLevel = 2 }) {
|
|
1841
2782
|
const { messages, locale, format } = useContentText();
|
|
1842
2783
|
const renderLink = useRenderLink();
|
|
1843
2784
|
const Heading = `h${headingLevel}`;
|
|
1844
|
-
return /* @__PURE__ */
|
|
1845
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
2785
|
+
return /* @__PURE__ */ jsxs21("article", { className: "adc-card", children: [
|
|
2786
|
+
post.coverImageUrl && /* @__PURE__ */ jsx25(
|
|
1846
2787
|
"img",
|
|
1847
2788
|
{
|
|
1848
2789
|
className: "adc-card-cover",
|
|
@@ -1852,22 +2793,23 @@ function PostCard({ post, href, headingLevel = 2 }) {
|
|
|
1852
2793
|
decoding: "async"
|
|
1853
2794
|
}
|
|
1854
2795
|
),
|
|
1855
|
-
/* @__PURE__ */
|
|
1856
|
-
/* @__PURE__ */
|
|
1857
|
-
/* @__PURE__ */
|
|
1858
|
-
/* @__PURE__ */
|
|
1859
|
-
/* @__PURE__ */
|
|
2796
|
+
/* @__PURE__ */ jsxs21("div", { className: "adc-card-body", children: [
|
|
2797
|
+
/* @__PURE__ */ jsx25(Heading, { className: "adc-card-title", children: renderLink({ href, className: "adc-card-link", children: post.title }) }),
|
|
2798
|
+
/* @__PURE__ */ jsxs21("p", { className: "adc-meta", children: [
|
|
2799
|
+
/* @__PURE__ */ jsx25("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
2800
|
+
/* @__PURE__ */ jsx25("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
1860
2801
|
format("readingTime", { minutes: post.readingTimeMinutes })
|
|
1861
2802
|
] }),
|
|
1862
|
-
post.excerpt && /* @__PURE__ */
|
|
1863
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
1864
|
-
/* @__PURE__ */
|
|
2803
|
+
post.excerpt && /* @__PURE__ */ jsx25("p", { className: "adc-card-excerpt", children: post.excerpt }),
|
|
2804
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx25("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx25("li", { className: "adc-tag", children: formatTagLabel2(tag, post.tagLabels) }, tag)) }),
|
|
2805
|
+
/* @__PURE__ */ jsx25("span", { className: "adc-card-more", "aria-hidden": "true", children: messages.readMore })
|
|
1865
2806
|
] })
|
|
1866
2807
|
] });
|
|
1867
2808
|
}
|
|
1868
2809
|
|
|
1869
2810
|
// src/components/PostListPage.tsx
|
|
1870
|
-
import {
|
|
2811
|
+
import { formatTagLabel as formatTagLabel3 } from "@adatechnology/content-contracts";
|
|
2812
|
+
import { jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
1871
2813
|
function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref, title }) {
|
|
1872
2814
|
const api = useContentPublicApi();
|
|
1873
2815
|
const { messages } = useContentText();
|
|
@@ -1881,9 +2823,9 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
1881
2823
|
"public-tags"
|
|
1882
2824
|
);
|
|
1883
2825
|
const withTag = (target) => getListHref({ page: target, ...tag ? { tag } : {} });
|
|
1884
|
-
return /* @__PURE__ */
|
|
1885
|
-
title && /* @__PURE__ */
|
|
1886
|
-
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */
|
|
2826
|
+
return /* @__PURE__ */ jsxs22("section", { className: "adc-root adc-public-list", children: [
|
|
2827
|
+
title && /* @__PURE__ */ jsx26("h1", { className: "adc-page-title", children: title }),
|
|
2828
|
+
(tags.data?.length ?? 0) > 0 && /* @__PURE__ */ jsxs22("nav", { className: "adc-tag-filter", "aria-label": messages.tagsLabel, children: [
|
|
1887
2829
|
renderLink({
|
|
1888
2830
|
href: getListHref({ page: 1 }),
|
|
1889
2831
|
className: `adc-tag-chip${tag ? "" : " adc-tag-chip--active"}`,
|
|
@@ -1895,24 +2837,25 @@ function PostListPage({ page = 1, tag, pageSize = 10, getPostHref, getListHref,
|
|
|
1895
2837
|
href: getListHref({ page: 1, tag: entry.tag }),
|
|
1896
2838
|
className: `adc-tag-chip${entry.tag === tag ? " adc-tag-chip--active" : ""}`,
|
|
1897
2839
|
...entry.tag === tag ? { "aria-current": "page" } : {},
|
|
1898
|
-
children: `${entry.tag} (${entry.count})`
|
|
2840
|
+
children: `${formatTagLabel3(entry.tag)} (${entry.count})`
|
|
1899
2841
|
})
|
|
1900
2842
|
)
|
|
1901
2843
|
] }),
|
|
1902
|
-
posts.isLoading && !posts.data ? /* @__PURE__ */
|
|
2844
|
+
posts.isLoading && !posts.data ? /* @__PURE__ */ jsx26("p", { className: "adc-state", role: "status", children: messages.loading }) : posts.error !== void 0 ? /* @__PURE__ */ jsxs22("div", { className: "adc-state adc-state--error", role: "alert", children: [
|
|
1903
2845
|
messages.loadError,
|
|
1904
|
-
/* @__PURE__ */
|
|
1905
|
-
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */
|
|
1906
|
-
posts.data && /* @__PURE__ */
|
|
2846
|
+
/* @__PURE__ */ jsx26("button", { type: "button", className: "adc-button", onClick: posts.reload, children: messages.retry })
|
|
2847
|
+
] }) : (posts.data?.data.length ?? 0) === 0 ? /* @__PURE__ */ jsx26("p", { className: "adc-state", children: messages.postsEmpty }) : /* @__PURE__ */ jsx26("div", { className: "adc-card-grid", children: posts.data?.data.map((post) => /* @__PURE__ */ jsx26(PostCard, { post, href: getPostHref(post.slug) }, post.id)) }),
|
|
2848
|
+
posts.data && /* @__PURE__ */ jsx26(Pagination, { page, totalPages: posts.data.pagination.totalPages, getPageHref: withTag })
|
|
1907
2849
|
] });
|
|
1908
2850
|
}
|
|
1909
2851
|
|
|
1910
2852
|
// src/components/PostPage.tsx
|
|
1911
|
-
import {
|
|
2853
|
+
import { formatTagLabel as formatTagLabel4 } from "@adatechnology/content-contracts";
|
|
2854
|
+
import { useEffect as useEffect7 } from "react";
|
|
1912
2855
|
|
|
1913
2856
|
// src/components/ShareButtons.tsx
|
|
1914
|
-
import { Check, Link2, Share2 } from "lucide-react";
|
|
1915
|
-
import { useEffect as
|
|
2857
|
+
import { Check as Check2, Link2, Share2 } from "lucide-react";
|
|
2858
|
+
import { useEffect as useEffect6, useState as useState16 } from "react";
|
|
1916
2859
|
|
|
1917
2860
|
// src/lib/share.ts
|
|
1918
2861
|
var SHARE_NETWORK = {
|
|
@@ -1937,7 +2880,7 @@ function buildShareLinks(params) {
|
|
|
1937
2880
|
}
|
|
1938
2881
|
|
|
1939
2882
|
// src/components/ShareButtons.tsx
|
|
1940
|
-
import { jsx as
|
|
2883
|
+
import { jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
1941
2884
|
var NETWORK_LABEL = {
|
|
1942
2885
|
[SHARE_NETWORK.WHATSAPP]: "shareWhatsApp",
|
|
1943
2886
|
[SHARE_NETWORK.FACEBOOK]: "shareFacebook",
|
|
@@ -1947,10 +2890,10 @@ var NETWORK_LABEL = {
|
|
|
1947
2890
|
var COPIED_FEEDBACK_MS = 2e3;
|
|
1948
2891
|
function ShareButtons({ url, title, networks }) {
|
|
1949
2892
|
const { messages, format } = useContentText();
|
|
1950
|
-
const [isCopied, setIsCopied] =
|
|
2893
|
+
const [isCopied, setIsCopied] = useState16(false);
|
|
1951
2894
|
const links = buildShareLinks({ url, title }).filter((link) => !networks || networks.includes(link.network));
|
|
1952
|
-
const [capabilities, setCapabilities] =
|
|
1953
|
-
|
|
2895
|
+
const [capabilities, setCapabilities] = useState16({ canShareNatively: false, canCopy: false });
|
|
2896
|
+
useEffect6(() => {
|
|
1954
2897
|
setCapabilities({
|
|
1955
2898
|
canShareNatively: typeof navigator.share === "function",
|
|
1956
2899
|
canCopy: Boolean(navigator.clipboard)
|
|
@@ -1962,21 +2905,21 @@ function ShareButtons({ url, title, networks }) {
|
|
|
1962
2905
|
setIsCopied(true);
|
|
1963
2906
|
window.setTimeout(() => setIsCopied(false), COPIED_FEEDBACK_MS);
|
|
1964
2907
|
}
|
|
1965
|
-
return /* @__PURE__ */
|
|
1966
|
-
/* @__PURE__ */
|
|
1967
|
-
canShareNatively && /* @__PURE__ */
|
|
2908
|
+
return /* @__PURE__ */ jsxs23("div", { className: "adc-share", role: "group", "aria-label": messages.shareLabel, children: [
|
|
2909
|
+
/* @__PURE__ */ jsx27("span", { className: "adc-label", children: messages.shareLabel }),
|
|
2910
|
+
canShareNatively && /* @__PURE__ */ jsxs23(
|
|
1968
2911
|
"button",
|
|
1969
2912
|
{
|
|
1970
2913
|
type: "button",
|
|
1971
2914
|
className: "adc-button",
|
|
1972
2915
|
onClick: () => void navigator.share({ url, title }).catch(() => void 0),
|
|
1973
2916
|
children: [
|
|
1974
|
-
/* @__PURE__ */
|
|
2917
|
+
/* @__PURE__ */ jsx27(Share2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
1975
2918
|
messages.shareNative
|
|
1976
2919
|
]
|
|
1977
2920
|
}
|
|
1978
2921
|
),
|
|
1979
|
-
links.map((link) => /* @__PURE__ */
|
|
2922
|
+
links.map((link) => /* @__PURE__ */ jsx27(
|
|
1980
2923
|
"a",
|
|
1981
2924
|
{
|
|
1982
2925
|
className: `adc-button adc-share-link adc-share-link--${link.network}`,
|
|
@@ -1988,48 +2931,48 @@ function ShareButtons({ url, title, networks }) {
|
|
|
1988
2931
|
},
|
|
1989
2932
|
link.network
|
|
1990
2933
|
)),
|
|
1991
|
-
canCopy && /* @__PURE__ */
|
|
1992
|
-
isCopied ? /* @__PURE__ */
|
|
1993
|
-
/* @__PURE__ */
|
|
2934
|
+
canCopy && /* @__PURE__ */ jsxs23("button", { type: "button", className: "adc-button", onClick: () => void handleCopy().catch(() => void 0), children: [
|
|
2935
|
+
isCopied ? /* @__PURE__ */ jsx27(Check2, { "aria-hidden": "true", className: "adc-icon" }) : /* @__PURE__ */ jsx27(Link2, { "aria-hidden": "true", className: "adc-icon" }),
|
|
2936
|
+
/* @__PURE__ */ jsx27("span", { "aria-live": "polite", children: isCopied ? messages.linkCopied : messages.copyLink })
|
|
1994
2937
|
] })
|
|
1995
2938
|
] });
|
|
1996
2939
|
}
|
|
1997
2940
|
|
|
1998
2941
|
// src/components/PostPage.tsx
|
|
1999
|
-
import { Fragment, jsx as
|
|
2942
|
+
import { Fragment, jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2000
2943
|
function PostPage({ slug, shareUrl, shareNetworks, getTagHref, onLoaded, renderNotFound }) {
|
|
2001
2944
|
const api = useContentPublicApi();
|
|
2002
2945
|
const { messages, locale, format } = useContentText();
|
|
2003
2946
|
const renderLink = useRenderLink();
|
|
2004
2947
|
const resource = useAsyncResource(() => api.getPublishedPost(slug), slug);
|
|
2005
2948
|
const post = resource.data;
|
|
2006
|
-
|
|
2949
|
+
useEffect7(() => {
|
|
2007
2950
|
if (post) onLoaded?.(post);
|
|
2008
2951
|
}, [post, onLoaded]);
|
|
2009
2952
|
if (resource.isLoading && !post) {
|
|
2010
|
-
return /* @__PURE__ */
|
|
2953
|
+
return /* @__PURE__ */ jsx28("p", { className: "adc-root adc-state", role: "status", children: messages.loading });
|
|
2011
2954
|
}
|
|
2012
2955
|
if (!post) {
|
|
2013
|
-
return /* @__PURE__ */
|
|
2956
|
+
return /* @__PURE__ */ jsx28(Fragment, { children: renderNotFound ? renderNotFound() : /* @__PURE__ */ jsx28("p", { className: "adc-root adc-state", children: messages.notFound }) });
|
|
2014
2957
|
}
|
|
2015
2958
|
const url = shareUrl ?? (typeof window !== "undefined" ? window.location.href : "");
|
|
2016
|
-
return /* @__PURE__ */
|
|
2017
|
-
/* @__PURE__ */
|
|
2018
|
-
/* @__PURE__ */
|
|
2019
|
-
/* @__PURE__ */
|
|
2020
|
-
/* @__PURE__ */
|
|
2021
|
-
/* @__PURE__ */
|
|
2959
|
+
return /* @__PURE__ */ jsxs24("article", { className: "adc-root adc-post", children: [
|
|
2960
|
+
/* @__PURE__ */ jsxs24("header", { className: "adc-post-header", children: [
|
|
2961
|
+
/* @__PURE__ */ jsx28("h1", { className: "adc-page-title", children: post.title }),
|
|
2962
|
+
/* @__PURE__ */ jsxs24("p", { className: "adc-meta", children: [
|
|
2963
|
+
/* @__PURE__ */ jsx28("time", { dateTime: post.publishedAt, children: formatPostDate(post.publishedAt, locale) }),
|
|
2964
|
+
/* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
2022
2965
|
format("readingTime", { minutes: post.readingTimeMinutes }),
|
|
2023
|
-
post.authorName && /* @__PURE__ */
|
|
2024
|
-
/* @__PURE__ */
|
|
2966
|
+
post.authorName && /* @__PURE__ */ jsxs24(Fragment, { children: [
|
|
2967
|
+
/* @__PURE__ */ jsx28("span", { "aria-hidden": "true", children: " \xB7 " }),
|
|
2025
2968
|
format("byAuthor", { author: post.authorName })
|
|
2026
2969
|
] })
|
|
2027
2970
|
] }),
|
|
2028
|
-
post.tags.length > 0 && /* @__PURE__ */
|
|
2971
|
+
post.tags.length > 0 && /* @__PURE__ */ jsx28("ul", { className: "adc-tag-list", children: post.tags.map((tag) => /* @__PURE__ */ jsx28("li", { className: "adc-tag", children: getTagHref ? renderLink({ href: getTagHref(tag), children: formatTagLabel4(tag, post.tagLabels) }) : formatTagLabel4(tag, post.tagLabels) }, tag)) })
|
|
2029
2972
|
] }),
|
|
2030
|
-
post.coverImageUrl && /* @__PURE__ */
|
|
2031
|
-
/* @__PURE__ */
|
|
2032
|
-
url && shareNetworks?.length !== 0 && /* @__PURE__ */
|
|
2973
|
+
post.coverImageUrl && /* @__PURE__ */ jsx28("img", { className: "adc-post-cover", src: post.coverImageUrl, alt: post.coverImageAlt ?? "", decoding: "async" }),
|
|
2974
|
+
/* @__PURE__ */ jsx28(MarkdownContent, { markdown: post.body, headingLevelOffset: 1 }),
|
|
2975
|
+
url && shareNetworks?.length !== 0 && /* @__PURE__ */ jsx28(ShareButtons, { url, title: post.title, ...shareNetworks ? { networks: shareNetworks } : {} })
|
|
2033
2976
|
] });
|
|
2034
2977
|
}
|
|
2035
2978
|
|
|
@@ -2071,6 +3014,8 @@ export {
|
|
|
2071
3014
|
FilePicker,
|
|
2072
3015
|
MarkdownContent,
|
|
2073
3016
|
MarkdownEditor,
|
|
3017
|
+
PAGE_SIZE_OPTIONS,
|
|
3018
|
+
POST_LIST_TAB,
|
|
2074
3019
|
Pagination,
|
|
2075
3020
|
PostCard,
|
|
2076
3021
|
PostEditor,
|
|
@@ -2082,6 +3027,7 @@ export {
|
|
|
2082
3027
|
ShareButtons,
|
|
2083
3028
|
StatusChip,
|
|
2084
3029
|
TagsInput,
|
|
3030
|
+
Tooltip,
|
|
2085
3031
|
buildPageItems,
|
|
2086
3032
|
buildPostMeta,
|
|
2087
3033
|
buildShareLinks,
|
|
@@ -2095,8 +3041,10 @@ export {
|
|
|
2095
3041
|
insertText,
|
|
2096
3042
|
interpolate,
|
|
2097
3043
|
isDraftDirty,
|
|
3044
|
+
parseListUrlState,
|
|
2098
3045
|
resolveContentMessages,
|
|
2099
3046
|
searchEmoji,
|
|
3047
|
+
serializeListUrlState,
|
|
2100
3048
|
splitTagInput,
|
|
2101
3049
|
toDateTimeLocalValue,
|
|
2102
3050
|
toggleLinePrefix,
|