@basicbenframework/cms 0.7.0 → 0.7.1

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.
@@ -66,7 +66,6 @@ const strings = {
66
66
  // Pages
67
67
  'Are you sure you want to delete this page?': '¿Seguro que quieres eliminar esta página?',
68
68
  'Failed to delete page': 'No se pudo eliminar la página',
69
- 'All Pages': 'Todas las páginas',
70
69
  '+ New Page': '+ Nueva página',
71
70
  'No pages yet. Create your first page!': 'Aún no hay páginas. ¡Crea tu primera página!',
72
71
  'Template': 'Plantilla',
@@ -73,6 +73,7 @@ const strings = {
73
73
  'Enable': 'Activar',
74
74
  'Disable': 'Desactivar',
75
75
  'users': 'usuarios',
76
+ '{count} account|{count} accounts': { one: '{count} cuenta', other: '{count} cuentas' },
76
77
  'Invite someone': 'Invitar a alguien',
77
78
  'Name (optional)': 'Nombre (opcional)',
78
79
  'Filled in on their sign-up form; they can change it': 'Se rellena en su formulario de registro; puede cambiarlo',
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from 'react';
3
3
  import { api } from "../../../helpers/api.js";
4
4
  import AdminLayout from "../../layouts/AdminLayout.js";
@@ -142,7 +142,7 @@ export default function AdminComments() {
142
142
  setSelected(next);
143
143
  };
144
144
  const allChecked = comments.length > 0 && comments.every(c => selected.has(c.id));
145
- return (_jsx(AdminLayout, { title: t('Comments'), children: _jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", style: { flexWrap: 'wrap', gap: '0.5rem' }, children: [_jsx("h2", { className: "admin-card-title", children: t('Comments') }), _jsxs("div", { style: { display: 'flex', gap: '0.5rem', flexWrap: 'wrap' }, children: [TABS.map(({ key }) => (_jsxs("button", { onClick: () => switchTab(key), className: `admin-btn ${tab === key ? 'admin-btn-primary' : 'admin-btn-secondary'}`, children: [tabLabel(key), counts ? ` (${counts[key]})` : ''] }, key))), _jsx("button", { onClick: () => setShowSettings(!showSettings), className: "admin-btn admin-btn-secondary", children: showSettings ? t('Hide settings') : t('Spam settings') })] })] }), showSettings && _jsx(SettingsPanel, {}), _jsxs("div", { style: { display: 'flex', gap: '0.5rem', flexWrap: 'wrap', alignItems: 'center', padding: '0.75rem 1rem', borderBottom: '1px solid var(--border)' }, children: [_jsxs("label", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", checked: allChecked, onChange: () => setSelected(allChecked ? new Set() : new Set(comments.map(c => c.id))), "aria-label": t('Select all on this page') }), _jsx("span", { style: { color: 'var(--fg-muted)', fontSize: '0.875rem' }, children: tn('{count} selected', '{count} selected', selected.size) })] }), tab !== 'approved' && tab !== 'trash' && _jsx(BulkButton, { label: t('Approve'), onClick: () => bulk('approve'), disabled: !selected.size }), (tab === 'all' || tab === 'approved') && _jsx(BulkButton, { label: t('Unapprove'), onClick: () => bulk('pending'), disabled: !selected.size }), tab !== 'spam' && _jsx(BulkButton, { label: t('Mark spam'), onClick: () => bulk('spam'), disabled: !selected.size }), tab === 'spam' && _jsx(BulkButton, { label: t('Not spam'), onClick: () => bulk('pending'), disabled: !selected.size }), tab === 'trash' && _jsx(BulkButton, { label: t('Restore'), onClick: () => bulk('pending'), disabled: !selected.size }), tab !== 'trash' && tab !== 'spam' && _jsx(BulkButton, { label: t('Trash'), onClick: () => bulk('trash'), disabled: !selected.size }), (tab === 'trash' || tab === 'spam') && _jsx(BulkButton, { label: t('Delete permanently'), danger: true, onClick: () => bulk('delete'), disabled: !selected.size }), (tab === 'spam' || tab === 'trash') && (counts?.[tab] ?? 0) > 0 && (_jsx("button", { onClick: () => empty(tab), className: "admin-btn admin-btn-danger", style: { marginLeft: 'auto' }, children: tab === 'spam' ? t('Empty spam') : t('Empty trash') }))] }), loading ? (_jsx("div", { className: "admin-loading", children: t('Loading...') })) : comments.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center', padding: '2rem' }, children: {
145
+ return (_jsx(AdminLayout, { title: t('Comments'), children: _jsxs("div", { className: "admin-card", children: [_jsx("div", { className: "admin-card-header", style: { flexWrap: 'wrap', gap: '0.5rem' }, children: _jsxs("div", { style: { display: 'flex', gap: '0.5rem', flexWrap: 'wrap' }, children: [TABS.map(({ key }) => (_jsxs("button", { onClick: () => switchTab(key), className: `admin-btn ${tab === key ? 'admin-btn-primary' : 'admin-btn-secondary'}`, children: [tabLabel(key), counts ? ` (${counts[key]})` : ''] }, key))), _jsx("button", { onClick: () => setShowSettings(!showSettings), className: "admin-btn admin-btn-secondary", children: showSettings ? t('Hide settings') : t('Spam settings') })] }) }), showSettings && _jsx(SettingsPanel, {}), _jsxs("div", { style: { display: 'flex', gap: '0.5rem', flexWrap: 'wrap', alignItems: 'center', padding: '0.75rem 1rem', borderBottom: '1px solid var(--border)' }, children: [_jsxs("label", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", checked: allChecked, onChange: () => setSelected(allChecked ? new Set() : new Set(comments.map(c => c.id))), "aria-label": t('Select all on this page') }), _jsx("span", { style: { color: 'var(--fg-muted)', fontSize: '0.875rem' }, children: tn('{count} selected', '{count} selected', selected.size) })] }), tab !== 'approved' && tab !== 'trash' && _jsx(BulkButton, { label: t('Approve'), onClick: () => bulk('approve'), disabled: !selected.size }), (tab === 'all' || tab === 'approved') && _jsx(BulkButton, { label: t('Unapprove'), onClick: () => bulk('pending'), disabled: !selected.size }), tab !== 'spam' && _jsx(BulkButton, { label: t('Mark spam'), onClick: () => bulk('spam'), disabled: !selected.size }), tab === 'spam' && _jsx(BulkButton, { label: t('Not spam'), onClick: () => bulk('pending'), disabled: !selected.size }), tab === 'trash' && _jsx(BulkButton, { label: t('Restore'), onClick: () => bulk('pending'), disabled: !selected.size }), tab !== 'trash' && tab !== 'spam' && _jsx(BulkButton, { label: t('Trash'), onClick: () => bulk('trash'), disabled: !selected.size }), (tab === 'trash' || tab === 'spam') && _jsx(BulkButton, { label: t('Delete permanently'), danger: true, onClick: () => bulk('delete'), disabled: !selected.size }), (tab === 'spam' || tab === 'trash') && (counts?.[tab] ?? 0) > 0 && (_jsx("button", { onClick: () => empty(tab), className: "admin-btn admin-btn-danger", style: { marginLeft: 'auto' }, children: tab === 'spam' ? t('Empty spam') : t('Empty trash') }))] }), loading ? (_jsx("div", { className: "admin-loading", children: t('Loading...') })) : comments.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center', padding: '2rem' }, children: {
146
146
  all: t('No comments.'),
147
147
  pending: t('No pending comments.'),
148
148
  approved: t('No approved comments.'),
@@ -151,7 +151,7 @@ export default function AdminContentTypes() {
151
151
  if (loading) {
152
152
  return (_jsx(AdminLayout, { title: t('Content types'), children: _jsx("div", { className: "admin-loading", children: t('Loading...') }) }));
153
153
  }
154
- return (_jsxs(AdminLayout, { title: t('Content types'), children: [message && _jsx("div", { className: "admin-card", role: "status", children: message }), _jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: t('Content types') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: startNew, children: t('+ New type') })] }), _jsxs("p", { style: { color: 'var(--fg-muted)', marginTop: 0 }, children: [t('Each type is written in the same editor as posts and gets its own address on the public site.'), ' ', slots(t('Types listed here appear in the content API as {code}.'), { code: _jsx("code", { children: "/api/v1/posts?type=key" }) })] }), _jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Name') }), _jsx("th", { children: t('Key') }), _jsx("th", { children: t('Lives at') }), _jsx("th", { children: t('Fields') }), _jsx("th", { children: t('Actions') })] }) }), _jsx("tbody", { children: types.map(type => (_jsxs("tr", { children: [_jsxs("td", { children: [type.plural_label, type.builtin && _jsx("span", { className: "admin-badge admin-badge-info", style: { marginLeft: '0.5rem' }, children: t('Built in') }), !type.public && _jsx("span", { className: "admin-badge admin-badge-warning", style: { marginLeft: '0.5rem' }, children: t('Private') })] }), _jsx("td", { children: _jsx("code", { children: type.key }) }), _jsx("td", { children: _jsxs("code", { children: [type.route_base, "/\u2026"] }) }), _jsx("td", { children: type.supports.custom_fields ? type.fields.length : '—' }), _jsx("td", { children: _jsxs("div", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => startEdit(type), children: t('Edit') }), !type.builtin && (_jsx("button", { type: "button", className: "admin-btn admin-btn-danger", onClick: () => remove(type), children: t('Delete') }))] }) })] }, type.id))) })] })] }), showForm && (_jsxs("form", { className: "admin-card", onSubmit: save, children: [_jsx("h3", { className: "admin-card-title", children: editing ? t('Edit {name}', { name: editing.plural_label }) : t('New content type') }), _jsxs("div", { className: "admin-grid admin-grid-2", children: [_jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-singular", children: t('Singular label') }), _jsx("input", { id: "ct-singular", className: "admin-input", required: true, value: form.singular_label, onChange: e => setForm({ ...form, singular_label: e.target.value }), placeholder: t('Recipe') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-plural", children: t('Plural label') }), _jsx("input", { id: "ct-plural", className: "admin-input", required: true, value: form.plural_label, onChange: e => setForm({ ...form, plural_label: e.target.value }), placeholder: t('Recipes') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-key", children: t('Key') }), _jsx("input", { id: "ct-key", className: "admin-input", required: true, disabled: Boolean(editing), value: form.key, onChange: e => setForm({ ...form, key: e.target.value.toLowerCase().replace(/[^a-z0-9_]/g, '_') }), placeholder: t('recipe') }), _jsx("small", { style: { color: 'var(--fg-muted)' }, children: t('What the API calls it. Fixed once created.') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-route", children: t('Route base') }), _jsx("input", { id: "ct-route", className: "admin-input", disabled: Boolean(editing?.builtin), value: form.route_base, onChange: e => setForm({ ...form, route_base: e.target.value }), placeholder: `/${form.key.replace(/_/g, '-') || t('recipes')}` }), _jsx("small", { style: { color: 'var(--fg-muted)' }, children: slots(t('Entries live at {code}.'), { code: _jsxs("code", { children: [form.route_base || `/${form.key.replace(/_/g, '-')}`, "/slug"] }) }) })] })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-description", children: t('Description') }), _jsx("textarea", { id: "ct-description", className: "admin-textarea", value: form.description, onChange: e => setForm({ ...form, description: e.target.value }), style: { minHeight: '60px' } })] }), !editing?.builtin && (_jsx("div", { className: "admin-form-group", children: _jsxs("label", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", checked: form.public, onChange: e => setForm({ ...form, public: e.target.checked }) }), t('Public — listed in the content API, the sitemap and the public site')] }) })), _jsxs("fieldset", { className: "admin-form-group", style: { border: 'none', padding: 0 }, children: [_jsx("legend", { className: "admin-label", children: t('Editor panels') }), _jsx("div", { style: { display: 'flex', flexWrap: 'wrap', gap: '1rem' }, children: SUPPORT_KEYS.map(key => (_jsxs("label", { style: { display: 'flex', gap: '0.4rem', alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", checked: form.supports[key], onChange: e => setForm({ ...form, supports: { ...form.supports, [key]: e.target.checked } }) }), supportLabels[key]] }, key))) })] }), form.supports.custom_fields && (_jsxs("div", { className: "admin-form-group", children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' }, children: [_jsx("span", { className: "admin-label", children: t('Custom fields') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: addField, children: t('+ Add field') })] }), form.fields.length === 0 && _jsx("p", { style: { color: 'var(--fg-muted)' }, children: t('No custom fields yet.') }), form.fields.map((field, index) => (_jsxs("div", { style: { border: '1px solid var(--border)', borderRadius: '0.5rem', padding: '0.75rem', marginTop: '0.5rem' }, children: [_jsxs("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(10rem, 1fr))', gap: '0.5rem' }, children: [_jsx("input", { className: "admin-input", "aria-label": t('Field label'), placeholder: t('Label'), value: field.label, required: true, onChange: e => updateField(index, {
154
+ return (_jsxs(AdminLayout, { title: t('Content types'), actions: _jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: startNew, children: t('+ New type') }), children: [message && _jsx("div", { className: "admin-card", role: "status", children: message }), _jsxs("div", { className: "admin-card", children: [_jsxs("p", { style: { color: 'var(--fg-muted)', marginTop: 0 }, children: [t('Each type is written in the same editor as posts and gets its own address on the public site.'), ' ', slots(t('Types listed here appear in the content API as {code}.'), { code: _jsx("code", { children: "/api/v1/posts?type=key" }) })] }), _jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Name') }), _jsx("th", { children: t('Key') }), _jsx("th", { children: t('Lives at') }), _jsx("th", { children: t('Fields') }), _jsx("th", { children: t('Actions') })] }) }), _jsx("tbody", { children: types.map(type => (_jsxs("tr", { children: [_jsxs("td", { children: [type.plural_label, type.builtin && _jsx("span", { className: "admin-badge admin-badge-info", style: { marginLeft: '0.5rem' }, children: t('Built in') }), !type.public && _jsx("span", { className: "admin-badge admin-badge-warning", style: { marginLeft: '0.5rem' }, children: t('Private') })] }), _jsx("td", { children: _jsx("code", { children: type.key }) }), _jsx("td", { children: _jsxs("code", { children: [type.route_base, "/\u2026"] }) }), _jsx("td", { children: type.supports.custom_fields ? type.fields.length : '—' }), _jsx("td", { children: _jsxs("div", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => startEdit(type), children: t('Edit') }), !type.builtin && (_jsx("button", { type: "button", className: "admin-btn admin-btn-danger", onClick: () => remove(type), children: t('Delete') }))] }) })] }, type.id))) })] })] }), showForm && (_jsxs("form", { className: "admin-card", onSubmit: save, children: [_jsx("h3", { className: "admin-card-title", children: editing ? t('Edit {name}', { name: editing.plural_label }) : t('New content type') }), _jsxs("div", { className: "admin-grid admin-grid-2", children: [_jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-singular", children: t('Singular label') }), _jsx("input", { id: "ct-singular", className: "admin-input", required: true, value: form.singular_label, onChange: e => setForm({ ...form, singular_label: e.target.value }), placeholder: t('Recipe') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-plural", children: t('Plural label') }), _jsx("input", { id: "ct-plural", className: "admin-input", required: true, value: form.plural_label, onChange: e => setForm({ ...form, plural_label: e.target.value }), placeholder: t('Recipes') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-key", children: t('Key') }), _jsx("input", { id: "ct-key", className: "admin-input", required: true, disabled: Boolean(editing), value: form.key, onChange: e => setForm({ ...form, key: e.target.value.toLowerCase().replace(/[^a-z0-9_]/g, '_') }), placeholder: t('recipe') }), _jsx("small", { style: { color: 'var(--fg-muted)' }, children: t('What the API calls it. Fixed once created.') })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-route", children: t('Route base') }), _jsx("input", { id: "ct-route", className: "admin-input", disabled: Boolean(editing?.builtin), value: form.route_base, onChange: e => setForm({ ...form, route_base: e.target.value }), placeholder: `/${form.key.replace(/_/g, '-') || t('recipes')}` }), _jsx("small", { style: { color: 'var(--fg-muted)' }, children: slots(t('Entries live at {code}.'), { code: _jsxs("code", { children: [form.route_base || `/${form.key.replace(/_/g, '-')}`, "/slug"] }) }) })] })] }), _jsxs("div", { className: "admin-form-group", children: [_jsx("label", { className: "admin-label", htmlFor: "ct-description", children: t('Description') }), _jsx("textarea", { id: "ct-description", className: "admin-textarea", value: form.description, onChange: e => setForm({ ...form, description: e.target.value }), style: { minHeight: '60px' } })] }), !editing?.builtin && (_jsx("div", { className: "admin-form-group", children: _jsxs("label", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", checked: form.public, onChange: e => setForm({ ...form, public: e.target.checked }) }), t('Public — listed in the content API, the sitemap and the public site')] }) })), _jsxs("fieldset", { className: "admin-form-group", style: { border: 'none', padding: 0 }, children: [_jsx("legend", { className: "admin-label", children: t('Editor panels') }), _jsx("div", { style: { display: 'flex', flexWrap: 'wrap', gap: '1rem' }, children: SUPPORT_KEYS.map(key => (_jsxs("label", { style: { display: 'flex', gap: '0.4rem', alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", checked: form.supports[key], onChange: e => setForm({ ...form, supports: { ...form.supports, [key]: e.target.checked } }) }), supportLabels[key]] }, key))) })] }), form.supports.custom_fields && (_jsxs("div", { className: "admin-form-group", children: [_jsxs("div", { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center' }, children: [_jsx("span", { className: "admin-label", children: t('Custom fields') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: addField, children: t('+ Add field') })] }), form.fields.length === 0 && _jsx("p", { style: { color: 'var(--fg-muted)' }, children: t('No custom fields yet.') }), form.fields.map((field, index) => (_jsxs("div", { style: { border: '1px solid var(--border)', borderRadius: '0.5rem', padding: '0.75rem', marginTop: '0.5rem' }, children: [_jsxs("div", { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(10rem, 1fr))', gap: '0.5rem' }, children: [_jsx("input", { className: "admin-input", "aria-label": t('Field label'), placeholder: t('Label'), value: field.label, required: true, onChange: e => updateField(index, {
155
155
  label: e.target.value,
156
156
  // A new field takes its key from its label until the
157
157
  // key is typed into directly.
@@ -49,5 +49,5 @@ export default function AdminPages() {
49
49
  if (loading) {
50
50
  return (_jsx(AdminLayout, { title: t('Pages'), children: _jsx("div", { className: "admin-loading", children: t('Loading...') }) }));
51
51
  }
52
- return (_jsx(AdminLayout, { title: t('Pages'), children: _jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: t('All Pages') }), _jsx(Link, { href: "/admin/pages/new", className: "admin-btn admin-btn-primary", children: t('+ New Page') })] }), pages.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center', padding: '2rem' }, children: t('No pages yet. Create your first page!') })) : (_jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Title') }), _jsx("th", { children: t('Slug') }), _jsx("th", { children: t('Template') }), _jsx("th", { children: t('Status') }), _jsx("th", { children: t('Actions') })] }) }), _jsx("tbody", { children: pages.map(page => (_jsxs("tr", { children: [_jsx("td", { children: _jsx(Link, { href: `/admin/pages/${page.id}/edit`, style: { color: 'var(--accent)', fontWeight: 500 }, children: page.title }) }), _jsx("td", { children: _jsxs("code", { children: ["/", page.slug] }) }), _jsx("td", { children: page.template }), _jsx("td", { children: _jsx("span", { className: `admin-badge ${page.published ? 'admin-badge-success' : 'admin-badge-warning'}`, children: page.published ? t('Published') : t('Draft') }) }), _jsx("td", { children: _jsxs("div", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx(Link, { href: `/admin/pages/${page.id}/edit`, className: "admin-btn admin-btn-secondary", children: t('Edit') }), _jsx("button", { onClick: () => handleDelete(page.id), className: "admin-btn admin-btn-danger", children: t('Delete') })] }) })] }, page.id))) })] })), meta && _jsx(Pagination, { meta: meta, onChange: setPage, noun: t('pages') })] }) }));
52
+ return (_jsx(AdminLayout, { title: t('Pages'), actions: _jsx(Link, { href: "/admin/pages/new", className: "admin-btn admin-btn-primary", children: t('+ New Page') }), children: _jsxs("div", { className: "admin-card", children: [pages.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center', padding: '2rem' }, children: t('No pages yet. Create your first page!') })) : (_jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Title') }), _jsx("th", { children: t('Slug') }), _jsx("th", { children: t('Template') }), _jsx("th", { children: t('Status') }), _jsx("th", { children: t('Actions') })] }) }), _jsx("tbody", { children: pages.map(page => (_jsxs("tr", { children: [_jsx("td", { children: _jsx(Link, { href: `/admin/pages/${page.id}/edit`, style: { color: 'var(--accent)', fontWeight: 500 }, children: page.title }) }), _jsx("td", { children: _jsxs("code", { children: ["/", page.slug] }) }), _jsx("td", { children: page.template }), _jsx("td", { children: _jsx("span", { className: `admin-badge ${page.published ? 'admin-badge-success' : 'admin-badge-warning'}`, children: page.published ? t('Published') : t('Draft') }) }), _jsx("td", { children: _jsxs("div", { style: { display: 'flex', gap: '0.5rem' }, children: [_jsx(Link, { href: `/admin/pages/${page.id}/edit`, className: "admin-btn admin-btn-secondary", children: t('Edit') }), _jsx("button", { onClick: () => handleDelete(page.id), className: "admin-btn admin-btn-danger", children: t('Delete') })] }) })] }, page.id))) })] })), meta && _jsx(Pagination, { meta: meta, onChange: setPage, noun: t('pages') })] }) }));
53
53
  }
@@ -136,7 +136,7 @@ export default function AdminPosts() {
136
136
  const toggle = (id) => setSelected(prev => (prev.includes(id) ? prev.filter(x => x !== id) : [...prev, id]));
137
137
  const allSelected = posts.length > 0 && selected.length === posts.length;
138
138
  const inTrash = filter === 'trash';
139
- return (_jsx(AdminLayout, { title: plural, children: _jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: plural }), type === 'post' ? (_jsx(Link, { href: "/admin/posts/new", className: "admin-btn admin-btn-primary", children: t('+ New Post') })) : (_jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: () => navigateWithType(navigate, '/admin/posts/new', type), children: current?.singular_label ? t('+ New {name}', { name: current.singular_label }) : t('+ New entry') }))] }), types.length > 1 && (_jsx("nav", { "aria-label": t('Content type'), style: { display: 'flex', flexWrap: 'wrap', gap: '0.25rem', marginBottom: '0.75rem' }, children: types.map(ct => (_jsx("button", { type: "button", onClick: () => changeType(ct.key), "aria-pressed": type === ct.key, className: `admin-btn ${type === ct.key ? 'admin-btn-primary' : 'admin-btn-secondary'}`, children: ct.plural_label }, ct.key))) })), _jsxs("div", { style: { display: 'flex', flexWrap: 'wrap', gap: '0.5rem', alignItems: 'center', justifyContent: 'space-between', marginBottom: '1rem' }, children: [_jsx("nav", { "aria-label": t('Filter posts by status'), style: { display: 'flex', flexWrap: 'wrap', gap: '0.25rem' }, children: TABS.map(tab => (_jsxs("button", { type: "button", onClick: () => changeFilter(tab), className: `admin-btn ${filter === tab ? 'admin-btn-primary' : 'admin-btn-secondary'}`, "aria-pressed": filter === tab, children: [tabLabels[tab], counts[tab] !== undefined ? ` (${counts[tab]})` : ''] }, tab))) }), _jsxs("form", { onSubmit: submitSearch, role: "search", style: { display: 'flex', gap: '0.25rem' }, children: [_jsx("input", { type: "search", value: search, onChange: e => setSearch(e.target.value), placeholder: t('Search posts'), className: "admin-input", "aria-label": t('Search posts') }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-secondary", children: t('Search') })] })] }), selected.length > 0 && (_jsxs("div", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center', marginBottom: '0.75rem' }, children: [_jsx("span", { children: tn('{count} selected', '{count} selected', selected.length) }), inTrash ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => runBulk('restore', selected), children: t('Restore') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-danger", onClick: () => runBulk('delete', selected), children: t('Delete permanently') })] })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => runBulk('publish', selected), children: t('Publish') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => runBulk('draft', selected), children: t('Unpublish') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-danger", onClick: () => runBulk('trash', selected), children: t('Move to trash') })] }))] })), loading ? (_jsx("div", { className: "admin-loading", children: t('Loading...') })) : posts.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center', padding: '2rem' }, children: query
139
+ return (_jsx(AdminLayout, { title: plural, actions: type === 'post' ? (_jsx(Link, { href: "/admin/posts/new", className: "admin-btn admin-btn-primary", children: t('+ New Post') })) : (_jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: () => navigateWithType(navigate, '/admin/posts/new', type), children: current?.singular_label ? t('+ New {name}', { name: current.singular_label }) : t('+ New entry') })), children: _jsxs("div", { className: "admin-card", children: [types.length > 1 && (_jsx("nav", { "aria-label": t('Content type'), style: { display: 'flex', flexWrap: 'wrap', gap: '0.25rem', marginBottom: '0.75rem' }, children: types.map(ct => (_jsx("button", { type: "button", onClick: () => changeType(ct.key), "aria-pressed": type === ct.key, className: `admin-btn ${type === ct.key ? 'admin-btn-primary' : 'admin-btn-secondary'}`, children: ct.plural_label }, ct.key))) })), _jsxs("div", { style: { display: 'flex', flexWrap: 'wrap', gap: '0.5rem', alignItems: 'center', justifyContent: 'space-between', marginBottom: '1rem' }, children: [_jsx("nav", { "aria-label": t('Filter posts by status'), style: { display: 'flex', flexWrap: 'wrap', gap: '0.25rem' }, children: TABS.map(tab => (_jsxs("button", { type: "button", onClick: () => changeFilter(tab), className: `admin-btn ${filter === tab ? 'admin-btn-primary' : 'admin-btn-secondary'}`, "aria-pressed": filter === tab, children: [tabLabels[tab], counts[tab] !== undefined ? ` (${counts[tab]})` : ''] }, tab))) }), _jsxs("form", { onSubmit: submitSearch, role: "search", style: { display: 'flex', gap: '0.25rem' }, children: [_jsx("input", { type: "search", value: search, onChange: e => setSearch(e.target.value), placeholder: t('Search posts'), className: "admin-input", "aria-label": t('Search posts') }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-secondary", children: t('Search') })] })] }), selected.length > 0 && (_jsxs("div", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center', marginBottom: '0.75rem' }, children: [_jsx("span", { children: tn('{count} selected', '{count} selected', selected.length) }), inTrash ? (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => runBulk('restore', selected), children: t('Restore') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-danger", onClick: () => runBulk('delete', selected), children: t('Delete permanently') })] })) : (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => runBulk('publish', selected), children: t('Publish') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => runBulk('draft', selected), children: t('Unpublish') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-danger", onClick: () => runBulk('trash', selected), children: t('Move to trash') })] }))] })), loading ? (_jsx("div", { className: "admin-loading", children: t('Loading...') })) : posts.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)', textAlign: 'center', padding: '2rem' }, children: query
140
140
  ? t('No posts match “{query}”.', { query })
141
141
  : inTrash
142
142
  ? t('The trash is empty.')
@@ -115,11 +115,11 @@ export default function AdminTaxonomies() {
115
115
  if (loading) {
116
116
  return (_jsx(AdminLayout, { title: t('Taxonomies'), children: _jsx("div", { className: "admin-loading", children: t('Loading...') }) }));
117
117
  }
118
- return (_jsx(AdminLayout, { title: t('Taxonomies'), children: _jsxs("div", { className: "admin-grid admin-grid-2", children: [_jsxs("div", { children: [_jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: t('Taxonomies') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: () => {
119
- setEditingTaxonomy(null);
120
- setTaxonomyForm(EMPTY_TAXONOMY);
121
- setShowTaxonomyForm(true);
122
- }, children: t('+ New taxonomy') })] }), _jsx("p", { style: { color: 'var(--fg-muted)', marginTop: 0 }, children: t('Categories and tags are built in. Add others — a cuisine, a season — and choose which content types use them.') }), taxonomies.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)' }, children: t('No custom taxonomies yet.') })) : (_jsx("ul", { style: { listStyle: 'none', padding: 0, margin: 0, display: 'grid', gap: '0.5rem' }, children: taxonomies.map(taxonomy => (_jsxs("li", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsx("button", { type: "button", className: `admin-btn ${selected?.id === taxonomy.id ? 'admin-btn-primary' : 'admin-btn-secondary'}`, onClick: () => setSelected(taxonomy), "aria-pressed": selected?.id === taxonomy.id, children: taxonomy.plural_label }), _jsxs("small", { style: { color: 'var(--fg-muted)', marginRight: 'auto' }, children: [_jsx("code", { children: taxonomy.key }), " \u00B7 ", taxonomy.content_types.join(', ') || t('no types')] }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => {
118
+ return (_jsx(AdminLayout, { title: t('Taxonomies'), actions: _jsx("button", { type: "button", className: "admin-btn admin-btn-primary", onClick: () => {
119
+ setEditingTaxonomy(null);
120
+ setTaxonomyForm(EMPTY_TAXONOMY);
121
+ setShowTaxonomyForm(true);
122
+ }, children: t('+ New taxonomy') }), children: _jsxs("div", { className: "admin-grid admin-grid-2", children: [_jsxs("div", { children: [_jsxs("div", { className: "admin-card", children: [_jsx("p", { style: { color: 'var(--fg-muted)', marginTop: 0 }, children: t('Categories and tags are built in. Add others — a cuisine, a season — and choose which content types use them.') }), taxonomies.length === 0 ? (_jsx("p", { style: { color: 'var(--fg-muted)' }, children: t('No custom taxonomies yet.') })) : (_jsx("ul", { style: { listStyle: 'none', padding: 0, margin: 0, display: 'grid', gap: '0.5rem' }, children: taxonomies.map(taxonomy => (_jsxs("li", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsx("button", { type: "button", className: `admin-btn ${selected?.id === taxonomy.id ? 'admin-btn-primary' : 'admin-btn-secondary'}`, onClick: () => setSelected(taxonomy), "aria-pressed": selected?.id === taxonomy.id, children: taxonomy.plural_label }), _jsxs("small", { style: { color: 'var(--fg-muted)', marginRight: 'auto' }, children: [_jsx("code", { children: taxonomy.key }), " \u00B7 ", taxonomy.content_types.join(', ') || t('no types')] }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => {
123
123
  setEditingTaxonomy(taxonomy);
124
124
  setTaxonomyForm({ ...taxonomy, description: taxonomy.description ?? '' });
125
125
  setShowTaxonomyForm(true);
@@ -198,7 +198,7 @@ export default function AdminUsers() {
198
198
  if (loading) {
199
199
  return (_jsx(AdminLayout, { title: t('Users'), children: _jsx("div", { className: "admin-loading", children: t('Loading…') }) }));
200
200
  }
201
- return (_jsxs(AdminLayout, { title: t('Users'), children: [_jsx("style", { children: userStyles }), notice && (_jsx("div", { className: `users-notice users-notice-${notice.tone}`, role: "status", children: notice.text })), deleting && (_jsxs("form", { className: "users-reassign", onSubmit: confirmDelete, children: [_jsx("p", { className: "users-reassign-title", children: t('Delete {name}?', { name: deleting.name }) }), _jsxs("p", { className: "users-hint", children: [tn('They have written {count} post.', 'They have written {count} posts.', deleting.post_count), ' ', t('Choose who they should belong to — nothing is deleted with the account. This cannot be undone.')] }), _jsxs("div", { className: "users-row", children: [_jsxs("select", { className: "admin-select", value: reassignTo, onChange: e => setReassignTo(e.target.value), required: true, "aria-label": t('Reassign posts to'), children: [_jsx("option", { value: "", children: t('Reassign posts to…') }), candidates.map(candidate => (_jsxs("option", { value: candidate.id, children: [candidate.name, " (", candidate.email, ")"] }, candidate.id)))] }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-danger", disabled: !reassignTo, children: t('Reassign and delete') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => setDeleting(null), children: t('Cancel') })] })] })), _jsxs("div", { className: "admin-card", children: [_jsxs("div", { className: "admin-card-header", children: [_jsx("h2", { className: "admin-card-title", children: t('Users') }), meta && _jsx("span", { className: "users-count", children: meta.total })] }), _jsxs("form", { className: "users-row users-filters", onSubmit: handleSearch, children: [_jsx("input", { className: "admin-input", type: "search", value: search, onChange: e => setSearch(e.target.value), placeholder: t('Search by name or email'), "aria-label": t('Search users') }), _jsxs("select", { className: "admin-select", value: roleFilter, onChange: e => { setPage(1); setRoleFilter(e.target.value); }, "aria-label": t('Filter by role'), children: [_jsx("option", { value: "", children: t('All roles') }), roles.map(role => _jsx("option", { value: role, children: roleLabel(role) }, role))] }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-secondary", children: t('Search') })] }), users.length === 0 ? (_jsx("div", { className: "users-empty", children: _jsx("p", { children: query || roleFilter ? t('Nobody matches that search.') : t('No users yet.') }) })) : (_jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Name') }), _jsx("th", { children: t('Role') }), _jsx("th", { children: t('Posts') }), _jsx("th", { children: t('Status') }), _jsx("th", { children: t('Joined') }), _jsx("th", { children: t('Actions') })] }) }), _jsx("tbody", { children: users.map(row => {
201
+ return (_jsxs(AdminLayout, { title: t('Users'), description: meta ? tn('{count} account', '{count} accounts', meta.total) : undefined, children: [_jsx("style", { children: userStyles }), notice && (_jsx("div", { className: `users-notice users-notice-${notice.tone}`, role: "status", children: notice.text })), deleting && (_jsxs("form", { className: "users-reassign", onSubmit: confirmDelete, children: [_jsx("p", { className: "users-reassign-title", children: t('Delete {name}?', { name: deleting.name }) }), _jsxs("p", { className: "users-hint", children: [tn('They have written {count} post.', 'They have written {count} posts.', deleting.post_count), ' ', t('Choose who they should belong to — nothing is deleted with the account. This cannot be undone.')] }), _jsxs("div", { className: "users-row", children: [_jsxs("select", { className: "admin-select", value: reassignTo, onChange: e => setReassignTo(e.target.value), required: true, "aria-label": t('Reassign posts to'), children: [_jsx("option", { value: "", children: t('Reassign posts to…') }), candidates.map(candidate => (_jsxs("option", { value: candidate.id, children: [candidate.name, " (", candidate.email, ")"] }, candidate.id)))] }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-danger", disabled: !reassignTo, children: t('Reassign and delete') }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => setDeleting(null), children: t('Cancel') })] })] })), _jsxs("div", { className: "admin-card", children: [_jsxs("form", { className: "users-row users-filters", onSubmit: handleSearch, children: [_jsx("input", { className: "admin-input", type: "search", value: search, onChange: e => setSearch(e.target.value), placeholder: t('Search by name or email'), "aria-label": t('Search users') }), _jsxs("select", { className: "admin-select", value: roleFilter, onChange: e => { setPage(1); setRoleFilter(e.target.value); }, "aria-label": t('Filter by role'), children: [_jsx("option", { value: "", children: t('All roles') }), roles.map(role => _jsx("option", { value: role, children: roleLabel(role) }, role))] }), _jsx("button", { type: "submit", className: "admin-btn admin-btn-secondary", children: t('Search') })] }), users.length === 0 ? (_jsx("div", { className: "users-empty", children: _jsx("p", { children: query || roleFilter ? t('Nobody matches that search.') : t('No users yet.') }) })) : (_jsxs("table", { className: "admin-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: t('Name') }), _jsx("th", { children: t('Role') }), _jsx("th", { children: t('Posts') }), _jsx("th", { children: t('Status') }), _jsx("th", { children: t('Joined') }), _jsx("th", { children: t('Actions') })] }) }), _jsx("tbody", { children: users.map(row => {
202
202
  // Your own role, status and account are off limits here — the
203
203
  // server refuses them, so offering them would only invite an
204
204
  // error. Another admin can make those changes for you.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basicbenframework/cms",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "type": "module",
5
5
  "description": "The BasicBen CMS. Posts, pages, media, an admin UI, and a headless content API.",
6
6
  "license": "MIT",