@kyro-cms/admin 0.12.10 → 0.12.15
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/dist/index.cjs +23 -23
- package/dist/index.d.cts +25 -26
- package/dist/index.d.ts +25 -26
- package/dist/index.js +16 -16
- package/package.json +5 -4
- package/src/components/ApiKeysManager.tsx +1 -50
- package/src/components/AutoForm.tsx +1 -1
- package/src/components/DashboardMetrics.tsx +17 -81
- package/src/components/DetailView.tsx +4 -4
- package/src/components/ListView.tsx +6 -14
- package/src/components/PluginsManager.tsx +2 -2
- package/src/components/UserMenu.tsx +1 -1
- package/src/components/fields/BlocksField.tsx +91 -11
- package/src/components/fields/RichTextField.tsx +1 -1
- package/src/components/users/UserDetail.tsx +2 -2
- package/src/components/users/UserForm.tsx +2 -2
- package/src/components/users/UsersList.tsx +1 -1
- package/src/hooks/useAutoFormState.ts +3 -3
- package/src/index.node.ts +2 -0
- package/src/integration.ts +4 -16
- package/src/layouts/AdminLayout.astro +25 -15
- package/src/layouts/AuthLayout.astro +11 -6
- package/src/lib/navigate.ts +15 -0
- package/src/lib/virtual-kyro-plugins.ts +2 -0
- package/src/plugins/seo-admin.tsx +1 -1
package/src/integration.ts
CHANGED
|
@@ -176,12 +176,12 @@ export function kyroAdmin(options: KyroAdminOptions = {}): AstroIntegration {
|
|
|
176
176
|
{
|
|
177
177
|
name: "kyro-plugins-virtual",
|
|
178
178
|
resolveId(id: string) {
|
|
179
|
-
if (id === "virtual:kyro-plugins") {
|
|
180
|
-
return "\0virtual
|
|
179
|
+
if (id === "virtual:kyro-plugins" || id.endsWith("virtual-kyro-plugins") || id.endsWith("virtual-kyro-plugins.ts") || id.endsWith("virtual-kyro-plugins.js")) {
|
|
180
|
+
return "\0virtual-kyro-plugins";
|
|
181
181
|
}
|
|
182
182
|
},
|
|
183
183
|
load(id: string) {
|
|
184
|
-
if (id === "\0virtual
|
|
184
|
+
if (id === "\0virtual-kyro-plugins") {
|
|
185
185
|
try {
|
|
186
186
|
const configData = JSON.parse(fs.readFileSync(configFile, "utf8"));
|
|
187
187
|
const pluginsWithAdmin = (configData.plugins || []).filter((p: any) => p.adminEntry);
|
|
@@ -207,18 +207,7 @@ export function kyroAdmin(options: KyroAdminOptions = {}): AstroIntegration {
|
|
|
207
207
|
name: "kyro-admin-tsx-loader",
|
|
208
208
|
enforce: "pre" as const,
|
|
209
209
|
config(_config: any) {
|
|
210
|
-
const existingEsbuild = _config.esbuild;
|
|
211
|
-
const existingExclude = existingEsbuild?.exclude;
|
|
212
|
-
const adminInclude = /\/node_modules\/(?!.*@kyro-cms\/(admin|core))/;
|
|
213
210
|
return {
|
|
214
|
-
esbuild: {
|
|
215
|
-
...(existingEsbuild || {}),
|
|
216
|
-
exclude: existingExclude
|
|
217
|
-
? Array.isArray(existingExclude)
|
|
218
|
-
? [...existingExclude, adminInclude]
|
|
219
|
-
: [existingExclude, adminInclude]
|
|
220
|
-
: adminInclude,
|
|
221
|
-
},
|
|
222
211
|
};
|
|
223
212
|
},
|
|
224
213
|
},
|
|
@@ -272,7 +261,6 @@ export default debug;
|
|
|
272
261
|
},
|
|
273
262
|
optimizeDeps: {
|
|
274
263
|
include: [
|
|
275
|
-
'@kyro-cms/admin',
|
|
276
264
|
'@kyro-cms/admin > recharts',
|
|
277
265
|
'@kyro-cms/admin > recharts > recharts-scale',
|
|
278
266
|
'@kyro-cms/admin > recharts > recharts-scale > decimal.js-light',
|
|
@@ -290,7 +278,7 @@ export default debug;
|
|
|
290
278
|
'@kyro-cms/admin > use-sync-external-store',
|
|
291
279
|
'@kyro-cms/admin > use-sync-external-store/with-selector.js',
|
|
292
280
|
],
|
|
293
|
-
exclude: ['debug', 'react/compiler-runtime'],
|
|
281
|
+
exclude: ['debug', 'react/compiler-runtime', '@kyro-cms/admin'],
|
|
294
282
|
},
|
|
295
283
|
define: {
|
|
296
284
|
__KYRO_ADMIN_PATH__: JSON.stringify(basePath),
|
|
@@ -8,8 +8,8 @@ import { AuthBridge } from "../components/AuthBridge";
|
|
|
8
8
|
import { GlobalModal } from "../components/ui/GlobalModal";
|
|
9
9
|
import { Toaster } from "../components/ui/Toaster";
|
|
10
10
|
import { getSiteSettings, getGlobal } from "../lib/globals";
|
|
11
|
-
import { ClientRouter } from
|
|
12
|
-
import LoadingIndicator from
|
|
11
|
+
import { ClientRouter } from "astro:transitions";
|
|
12
|
+
import LoadingIndicator from "astro-loading-indicator/component";
|
|
13
13
|
|
|
14
14
|
interface Props {
|
|
15
15
|
title: string;
|
|
@@ -107,7 +107,7 @@ const defaultLang = siteSettings?.defaultLanguage || "en";
|
|
|
107
107
|
window.dispatchEvent(
|
|
108
108
|
new CustomEvent("kyro:auth-ready", {
|
|
109
109
|
detail: { user, permissions },
|
|
110
|
-
})
|
|
110
|
+
}),
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -164,7 +164,9 @@ const defaultLang = siteSettings?.defaultLanguage || "en";
|
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
-
runAuthCheck().then(() => {
|
|
167
|
+
runAuthCheck().then(() => {
|
|
168
|
+
initialAuthDone = true;
|
|
169
|
+
});
|
|
168
170
|
document.addEventListener("astro:page-load", () => {
|
|
169
171
|
if (initialAuthDone) runAuthCheck();
|
|
170
172
|
});
|
|
@@ -342,7 +344,8 @@ const defaultLang = siteSettings?.defaultLanguage || "en";
|
|
|
342
344
|
<!-- Theme UI Logic -->
|
|
343
345
|
<script is:inline define:vars={{ adminPath, apiPath }}>
|
|
344
346
|
// Run immediately to prevent FOUC
|
|
345
|
-
const currentTheme =
|
|
347
|
+
const currentTheme =
|
|
348
|
+
localStorage.getItem("theme") || (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light");
|
|
346
349
|
if (currentTheme === "dark") {
|
|
347
350
|
document.documentElement.classList.add("dark");
|
|
348
351
|
} else {
|
|
@@ -394,7 +397,10 @@ const defaultLang = siteSettings?.defaultLanguage || "en";
|
|
|
394
397
|
};
|
|
395
398
|
|
|
396
399
|
// Sync buttons on page load
|
|
397
|
-
updateUI(
|
|
400
|
+
updateUI(
|
|
401
|
+
localStorage.getItem("theme") ||
|
|
402
|
+
(window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"),
|
|
403
|
+
);
|
|
398
404
|
|
|
399
405
|
// Listeners
|
|
400
406
|
lightBtn?.addEventListener("click", () => {
|
|
@@ -453,19 +459,23 @@ const defaultLang = siteSettings?.defaultLanguage || "en";
|
|
|
453
459
|
}
|
|
454
460
|
</script>
|
|
455
461
|
<script>
|
|
456
|
-
import { navigate } from '
|
|
457
|
-
|
|
458
|
-
window.addEventListener(
|
|
462
|
+
import { navigate } from '../lib/navigate';
|
|
463
|
+
|
|
464
|
+
window.addEventListener("kyro:soft-reload", () => {
|
|
459
465
|
const url = new URL(window.location.href);
|
|
460
|
-
url.searchParams.set(
|
|
461
|
-
navigate(url.toString(), { history:
|
|
466
|
+
url.searchParams.set("_r", Date.now().toString());
|
|
467
|
+
navigate(url.toString(), { history: "replace" });
|
|
462
468
|
});
|
|
463
469
|
|
|
464
|
-
document.addEventListener(
|
|
470
|
+
document.addEventListener("astro:page-load", () => {
|
|
465
471
|
const url = new URL(window.location.href);
|
|
466
|
-
if (url.searchParams.has(
|
|
467
|
-
url.searchParams.delete(
|
|
468
|
-
window.history.replaceState(
|
|
472
|
+
if (url.searchParams.has("_r")) {
|
|
473
|
+
url.searchParams.delete("_r");
|
|
474
|
+
window.history.replaceState(
|
|
475
|
+
null,
|
|
476
|
+
"",
|
|
477
|
+
url.toString() === url.origin + url.pathname ? url.pathname : url.toString(),
|
|
478
|
+
);
|
|
469
479
|
}
|
|
470
480
|
});
|
|
471
481
|
</script>
|
|
@@ -15,6 +15,7 @@ const brandSettings = await getBrandSettings({ request: Astro.request });
|
|
|
15
15
|
const seoSettings = await getGlobal("seo-settings", { request: Astro.request });
|
|
16
16
|
|
|
17
17
|
const siteName = siteSettings?.siteName || brandSettings?.companyInfo?.companyName || "Kyro CMS";
|
|
18
|
+
const showSiteName = brandSettings?.identity?.showSiteName ?? true;
|
|
18
19
|
const siteFavicon = siteSettings?.siteFavicon || brandSettings?.identity?.favicon;
|
|
19
20
|
const siteLogo = brandSettings?.identity?.primaryLogo || siteSettings?.siteLogo;
|
|
20
21
|
const darkLogo = brandSettings?.identity?.darkLogo;
|
|
@@ -121,17 +122,21 @@ const defaultLang = siteSettings?.defaultLanguage || "en";
|
|
|
121
122
|
/>
|
|
122
123
|
)}
|
|
123
124
|
</div>
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
{showSiteName && (
|
|
126
|
+
<span class="text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]">
|
|
127
|
+
{siteName}
|
|
128
|
+
</span>
|
|
129
|
+
)}
|
|
127
130
|
</div>
|
|
128
131
|
) : (
|
|
129
132
|
<>
|
|
130
133
|
<img src="/logo-white.svg" alt="Kyro CMS" class="w-7 h-7 hidden dark:block" />
|
|
131
134
|
<img src="/logo.svg" alt="Kyro CMS" class="w-7 h-7 block dark:hidden" />
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
{showSiteName && (
|
|
136
|
+
<span class="text-xl font-bold tracking-tighter text-[var(--kyro-text-primary)]">
|
|
137
|
+
{siteName}
|
|
138
|
+
</span>
|
|
139
|
+
)}
|
|
135
140
|
</>
|
|
136
141
|
)
|
|
137
142
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const navigate = (href: string, options?: any) => {
|
|
2
|
+
if (typeof window === 'undefined') return;
|
|
3
|
+
|
|
4
|
+
import("astro:transitions/client")
|
|
5
|
+
.then((m) => {
|
|
6
|
+
if (m && m.navigate) {
|
|
7
|
+
m.navigate(href, options);
|
|
8
|
+
} else {
|
|
9
|
+
window.location.href = href;
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
.catch(() => {
|
|
13
|
+
window.location.href = href;
|
|
14
|
+
});
|
|
15
|
+
};
|