@clarify-labs/renderer 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.
- package/output/{OpenApiOperation-ZXToVSFC.cjs → OpenApiOperation-C4xZu4i0.cjs} +69 -65
- package/output/OpenApiOperation-C4xZu4i0.cjs.map +1 -0
- package/output/{OpenApiOperation-CWSOhUVa.js → OpenApiOperation-LIL7bqxW.js} +48 -44
- package/output/OpenApiOperation-LIL7bqxW.js.map +1 -0
- package/output/{shell-xxhV0p7k.cjs → PageActions-1RDCHcUY.cjs} +280 -308
- package/output/PageActions-1RDCHcUY.cjs.map +1 -0
- package/output/{shell-CumiARRe.js → PageActions-yoDRjkq8.js} +235 -263
- package/output/PageActions-yoDRjkq8.js.map +1 -0
- package/output/{ThemeRoot-C_ZdzSMu.js → ThemeRoot-CLa0yvRQ.js} +406 -53
- package/output/ThemeRoot-CLa0yvRQ.js.map +1 -0
- package/output/{ThemeRoot-CEvwrGp5.cjs → ThemeRoot-DYS-lcK-.cjs} +457 -80
- package/output/ThemeRoot-DYS-lcK-.cjs.map +1 -0
- package/output/app/AppShell.d.ts +3 -2
- package/output/app/PageActions.d.ts +12 -0
- package/output/app/PageBanner.d.ts +7 -0
- package/output/app/SectionProvider.d.ts +1 -0
- package/output/client.cjs +14 -7
- package/output/client.d.ts +4 -2
- package/output/client.js +4 -4
- package/output/context.d.ts +1 -1
- package/output/core/context.d.ts +5 -5
- package/output/core/index.d.ts +1 -1
- package/output/core/types.d.ts +70 -61
- package/output/index.cjs +56 -28
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +7 -5
- package/output/index.js +37 -12
- package/output/index.js.map +1 -1
- package/output/mdx/components.d.ts +1 -0
- package/output/mdx/primitives.d.ts +1 -0
- package/output/preview.cjs +7 -7
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +4 -4
- package/output/preview.js.map +1 -1
- package/output/{render-zHU25Nm9.cjs → render-CRTqZzyY.cjs} +8 -7
- package/output/render-CRTqZzyY.cjs.map +1 -0
- package/output/{render-CnUd0XwZ.js → render-D0ls3d2j.js} +6 -5
- package/output/render-D0ls3d2j.js.map +1 -0
- package/output/renderer.css +365 -261
- package/output/server.cjs +8 -7
- package/output/server.cjs.map +1 -1
- package/output/server.js +5 -4
- package/output/server.js.map +1 -1
- package/output/shell/ContentActions.d.ts +0 -1
- package/output/shell/Header.d.ts +3 -2
- package/output/shell/SiteLogo.d.ts +2 -2
- package/output/shell/mobile.d.ts +2 -2
- package/output/theme/ThemeEditor.d.ts +53 -17
- package/output/theme/ThemeProvider.d.ts +2 -1
- package/output/theme/ThemeRoot.d.ts +2 -2
- package/output/theme/cookies.d.ts +11 -0
- package/output/theme/randomTheme.d.ts +2 -2
- package/output/theme/variables.d.ts +58 -20
- package/output/utils/href.d.ts +3 -3
- package/package.json +1 -1
- package/output/OpenApiOperation-CWSOhUVa.js.map +0 -1
- package/output/OpenApiOperation-ZXToVSFC.cjs.map +0 -1
- package/output/ThemeRoot-CEvwrGp5.cjs.map +0 -1
- package/output/ThemeRoot-C_ZdzSMu.js.map +0 -1
- package/output/render-CnUd0XwZ.js.map +0 -1
- package/output/render-zHU25Nm9.cjs.map +0 -1
- package/output/shell-CumiARRe.js.map +0 -1
- package/output/shell-xxhV0p7k.cjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-DakpK96I.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_PageActions = require("./PageActions-1RDCHcUY.cjs");
|
|
3
3
|
let clsx = require("clsx");
|
|
4
4
|
clsx = require_chunk.__toESM(clsx, 1);
|
|
5
5
|
let react = require("react");
|
|
@@ -15,7 +15,7 @@ function PageErrorPanel(props) {
|
|
|
15
15
|
const stackText = componentStack ? `${stack}\n\n${componentStackLabel}\n${componentStack}` : stack;
|
|
16
16
|
const capturedAt = occurredAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
17
17
|
async function copyStack() {
|
|
18
|
-
if (!await
|
|
18
|
+
if (!await require_PageActions.copyTextToClipboard(stackText)) return;
|
|
19
19
|
setCopiedStack(true);
|
|
20
20
|
window.setTimeout(() => setCopiedStack(false), 1600);
|
|
21
21
|
}
|
|
@@ -149,12 +149,92 @@ var PageErrorBoundary = class extends react.Component {
|
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
//#endregion
|
|
152
|
+
//#region source/app/PageBanner.tsx
|
|
153
|
+
function resolveLocalizedText$1(text, locale, fallbackLocale) {
|
|
154
|
+
if (typeof text === "string") return text;
|
|
155
|
+
return (locale ? text[locale] : void 0) ?? (fallbackLocale ? text[fallbackLocale] : void 0) ?? Object.values(text)[0] ?? "";
|
|
156
|
+
}
|
|
157
|
+
function bannerStorageKey(config, content) {
|
|
158
|
+
return `clarify:banner:dismissed:${config.title}:${content}`;
|
|
159
|
+
}
|
|
160
|
+
function PageBannerLink(props) {
|
|
161
|
+
const { href, label, external: externalProp, config, locale } = props;
|
|
162
|
+
const external = externalProp ?? require_PageActions.isExternalHref(href);
|
|
163
|
+
const resolvedHref = external ? href : require_PageActions.localizeHref(href, config, locale);
|
|
164
|
+
const className = "clarify-banner-link shrink-0 rounded-full bg-(--clarify-theme-tokens-colors-primary) px-3 py-1 text-xs/5 font-semibold text-white no-underline transition hover:opacity-90";
|
|
165
|
+
if (external) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
166
|
+
href: resolvedHref,
|
|
167
|
+
target: "_blank",
|
|
168
|
+
rel: "noreferrer",
|
|
169
|
+
className,
|
|
170
|
+
children: label
|
|
171
|
+
});
|
|
172
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_router_dom.Link, {
|
|
173
|
+
to: resolvedHref,
|
|
174
|
+
className,
|
|
175
|
+
children: label
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
function PageBanner(props) {
|
|
179
|
+
const { component: CustomBanner, currentLocale, onDismiss } = props;
|
|
180
|
+
const config = require_PageActions.useConfig();
|
|
181
|
+
const banner = config.banner;
|
|
182
|
+
const builtInBanner = banner && typeof banner === "object" ? banner : void 0;
|
|
183
|
+
const content = builtInBanner ? resolveLocalizedText$1(builtInBanner.content, currentLocale, config.i18n?.defaultLocale) : "";
|
|
184
|
+
const link = builtInBanner?.link;
|
|
185
|
+
const linkLabel = link ? resolveLocalizedText$1(link.label, currentLocale, config.i18n?.defaultLocale) : "";
|
|
186
|
+
const storageKey = (0, react.useMemo)(() => content ? bannerStorageKey(config, content) : "", [config, content]);
|
|
187
|
+
const [dismissed, setDismissed] = (0, react.useState)(() => {
|
|
188
|
+
if (!storageKey || !builtInBanner?.dismissible || typeof window === "undefined") return false;
|
|
189
|
+
return window.localStorage.getItem(storageKey) === "1";
|
|
190
|
+
});
|
|
191
|
+
(0, react.useEffect)(() => {
|
|
192
|
+
if (dismissed) onDismiss?.();
|
|
193
|
+
}, [dismissed, onDismiss]);
|
|
194
|
+
if (CustomBanner) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
195
|
+
className: "clarify-banner clarify-banner-custom flex min-h-12 items-center border-b border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) px-4 text-sm text-(--clarify-theme-tokens-colors-foreground) dark:border-white/10 dark:bg-zinc-950",
|
|
196
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
197
|
+
className: "mx-auto w-full max-w-(--clarify-theme-layout-max-width)",
|
|
198
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomBanner, {})
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
if (!builtInBanner || !content || dismissed) return null;
|
|
202
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
203
|
+
className: "clarify-banner relative flex min-h-12 items-center border-b border-(--clarify-ui-accent-border) bg-(--clarify-ui-accent-background) px-4 text-sm text-(--clarify-ui-text) dark:border-white/10",
|
|
204
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
205
|
+
className: "mx-auto flex w-full max-w-(--clarify-theme-layout-max-width) items-center justify-center gap-3 pr-8 sm:pr-0",
|
|
206
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
207
|
+
className: "clarify-banner-content m-0 text-center font-medium",
|
|
208
|
+
children: content
|
|
209
|
+
}), link ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageBannerLink, {
|
|
210
|
+
href: link.href,
|
|
211
|
+
label: linkLabel,
|
|
212
|
+
external: link.external,
|
|
213
|
+
config,
|
|
214
|
+
locale: currentLocale
|
|
215
|
+
}) : null]
|
|
216
|
+
}), builtInBanner.dismissible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
217
|
+
type: "button",
|
|
218
|
+
className: "clarify-banner-dismiss absolute right-3 inline-flex size-8 items-center justify-center rounded-full text-(--clarify-ui-text-soft) transition hover:bg-(--clarify-ui-hover-background) hover:text-(--clarify-ui-text-strong)",
|
|
219
|
+
"aria-label": "Dismiss announcement",
|
|
220
|
+
onClick: () => {
|
|
221
|
+
if (storageKey) window.localStorage.setItem(storageKey, "1");
|
|
222
|
+
setDismissed(true);
|
|
223
|
+
},
|
|
224
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
|
|
225
|
+
className: "size-4",
|
|
226
|
+
"aria-hidden": "true"
|
|
227
|
+
})
|
|
228
|
+
}) : null]
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
152
232
|
//#region source/assets/clarify.svg?url
|
|
153
233
|
var clarify_default = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20width='279px'%20height='200px'%20viewBox='0%200%20279%20200'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctitle%3eclarify%3c/title%3e%3cg%20id='页面-1'%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20id='clarify'%20transform='translate(-0,%200.0054)'%3e%3cpath%20d='M44.867217,0.0054376148%20C130.715579,1.00591567%20200,70.9091172%20200,156.994562%20L199.986321,155.127494%20C199.384888,180.009127%20179.026368,199.994562%20154,199.994562%20L46,199.994562%20C20.5949015,199.994562%200,179.399661%200,153.994562%20L0,45.9945624%20C0,21.0975659%2019.7793434,0.820282524%2044.4815926,0.0191499894%20Z'%20fill='%2300D492'%3e%3c/path%3e%3cpath%20d='M123.867217,0.0054376148%20C209.715579,1.00591567%20279,70.9091172%20279,156.994562%20L278.986321,155.127494%20C278.384888,180.009127%20258.026368,199.994562%20233,199.994562%20L125,199.994562%20C99.5949015,199.994562%2079,179.399661%2079,153.994562%20L79,45.9945624%20C79,21.0975659%2098.7793434,0.820282524%20123.481593,0.0191499894%20Z'%20id='clarify-right'%20fill-opacity='0.6'%20fill='%2300F6C9'%20transform='translate(179,%20100)%20rotate(-90)%20translate(-179,%20-100)'%3e%3c/path%3e%3cpath%20d='M199.979267,154.416906%20L199.984438,155.157125%20L199.962366,155.872459%20C198.977251,180.406837%20178.776104,199.994562%20154,199.994562%20L124.372438,199.994125%20L124.249053,199.994081%20C99.6939678,199.603921%2079.8122712,179.973634%2079.01915,155.518407%20L79.0054376,155.132783%20C79.5830823,105.566626%20103.129768,61.5221348%20139.498462,33.1463428%20C175.69419,61.3871018%20199.186123,105.143863%20199.979267,154.416906%20Z'%20id='形状结合'%20fill='%2300F692'%3e%3c/path%3e%3c/g%3e%3c/g%3e%3c/svg%3e";
|
|
154
234
|
//#endregion
|
|
155
235
|
//#region source/app/BuiltWithClarify.tsx
|
|
156
236
|
function BuiltWithClarify() {
|
|
157
|
-
const t =
|
|
237
|
+
const t = require_PageActions.useBuiltInText();
|
|
158
238
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
159
239
|
href: "https://clarify.pub",
|
|
160
240
|
target: "_blank",
|
|
@@ -181,7 +261,7 @@ function resolveLocalizedText(text, locale, fallbackLocale) {
|
|
|
181
261
|
if (typeof text === "string") return text;
|
|
182
262
|
return (locale ? text[locale] : void 0) ?? (fallbackLocale ? text[fallbackLocale] : void 0) ?? Object.values(text)[0] ?? "";
|
|
183
263
|
}
|
|
184
|
-
function localeForPath
|
|
264
|
+
function localeForPath(config, pathname) {
|
|
185
265
|
const i18n = config.i18n;
|
|
186
266
|
if (!i18n) return void 0;
|
|
187
267
|
const firstSegment = pathname.split("/").filter(Boolean)[0];
|
|
@@ -189,8 +269,8 @@ function localeForPath$1(config, pathname) {
|
|
|
189
269
|
}
|
|
190
270
|
function FooterLink(arg0) {
|
|
191
271
|
const { link, locale, config } = arg0;
|
|
192
|
-
const external = link.external ??
|
|
193
|
-
const href = external ? link.href :
|
|
272
|
+
const external = link.external ?? require_PageActions.isExternalHref(link.href);
|
|
273
|
+
const href = external ? link.href : require_PageActions.localizeHref(link.href, config, locale);
|
|
194
274
|
const className = "clarify-footer-link no-underline transition";
|
|
195
275
|
const label = resolveLocalizedText(link.label, locale, config.i18n?.defaultLocale);
|
|
196
276
|
if (external) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
|
|
@@ -217,8 +297,8 @@ function SocialLink(arg0) {
|
|
|
217
297
|
});
|
|
218
298
|
}
|
|
219
299
|
function PageFooter(props = {}) {
|
|
220
|
-
const config =
|
|
221
|
-
const locale = localeForPath
|
|
300
|
+
const config = require_PageActions.useConfig();
|
|
301
|
+
const locale = localeForPath(config, (0, react_router_dom.useLocation)().pathname);
|
|
222
302
|
const footer = config.footer;
|
|
223
303
|
const builtInFooter = footer && typeof footer === "object" ? footer : void 0;
|
|
224
304
|
const CustomFooter = props.component;
|
|
@@ -227,7 +307,7 @@ function PageFooter(props = {}) {
|
|
|
227
307
|
const copyright = builtInFooter?.copyright ? resolveLocalizedText(builtInFooter.copyright, locale, config.i18n?.defaultLocale) : void 0;
|
|
228
308
|
const hasBuiltInFooter = Boolean(copyright || links.length > 0 || socials.length > 0);
|
|
229
309
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
230
|
-
className: "clarify-page-footer
|
|
310
|
+
className: "clarify-page-footer mt-16 flex w-full flex-col gap-4 border-t border-(--clarify-theme-tokens-colors-border) py-8 lg:mt-24",
|
|
231
311
|
children: [CustomFooter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
232
312
|
className: "clarify-footer-custom w-full",
|
|
233
313
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomFooter, {})
|
|
@@ -260,10 +340,10 @@ function flattenNavigation(nodes) {
|
|
|
260
340
|
}
|
|
261
341
|
function PageNavigation(arg0) {
|
|
262
342
|
const { navigation, currentRoute } = arg0;
|
|
263
|
-
const t =
|
|
343
|
+
const t = require_PageActions.useBuiltInText();
|
|
264
344
|
if (!currentRoute) return null;
|
|
265
345
|
const pageRoutes = flattenNavigation(navigation);
|
|
266
|
-
const currentIndex = pageRoutes.findIndex((route) =>
|
|
346
|
+
const currentIndex = pageRoutes.findIndex((route) => require_PageActions.isSameRoutePath(route.path, currentRoute.path));
|
|
267
347
|
if (currentIndex === -1) return null;
|
|
268
348
|
const previous = pageRoutes[currentIndex - 1];
|
|
269
349
|
const next = pageRoutes[currentIndex + 1];
|
|
@@ -282,11 +362,11 @@ function PageNavigation(arg0) {
|
|
|
282
362
|
}
|
|
283
363
|
function PageNavigationLink(arg0) {
|
|
284
364
|
const { direction, route } = arg0;
|
|
285
|
-
const t =
|
|
365
|
+
const t = require_PageActions.useBuiltInText();
|
|
286
366
|
if (!route) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "hidden @3xl:block" });
|
|
287
367
|
const isNext = direction === "next";
|
|
288
368
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_router_dom.Link, {
|
|
289
|
-
to:
|
|
369
|
+
to: require_PageActions.normalizeRoutePath(route.path),
|
|
290
370
|
className: (0, clsx.default)("group flex min-w-0 items-center gap-3 rounded-lg border border-(--clarify-theme-tokens-colors-border) px-4 py-3 no-underline transition hover:border-(--clarify-theme-tokens-colors-primary) hover:bg-(--clarify-ui-hover-background)", isNext && "@3xl:justify-end @3xl:text-right"),
|
|
291
371
|
children: [
|
|
292
372
|
!isNext ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronLeft, { className: "h-3.5 w-3.5 shrink-0 text-(--clarify-theme-tokens-colors-muted) transition group-hover:text-(--clarify-theme-tokens-colors-primary)" }) : null,
|
|
@@ -410,17 +490,18 @@ function PageSkeleton() {
|
|
|
410
490
|
//#endregion
|
|
411
491
|
//#region source/app/AppShell.tsx
|
|
412
492
|
function routeForPath(routes, pathname) {
|
|
413
|
-
return routes.find((route) =>
|
|
493
|
+
return routes.find((route) => require_PageActions.isSameRoutePath(route.path, pathname));
|
|
414
494
|
}
|
|
415
495
|
function notFoundRouteForPath(routes, pathname, currentLocale) {
|
|
416
496
|
const localePrefix = currentLocale ? `/${currentLocale}` : void 0;
|
|
417
497
|
if (localePrefix && pathname.startsWith(`${localePrefix}/`)) return routeForPath(routes, `${localePrefix}/404`);
|
|
418
|
-
return routeForPath(routes, "/404") ?? routes.find((route) =>
|
|
498
|
+
return routeForPath(routes, "/404") ?? routes.find((route) => require_PageActions.isSameRoutePath(route.basePath, "/404"));
|
|
419
499
|
}
|
|
420
500
|
function sectionsForRoute(route) {
|
|
421
501
|
return route?.sections?.map((section) => ({
|
|
422
502
|
id: section.id,
|
|
423
503
|
title: section.title,
|
|
504
|
+
level: section.level,
|
|
424
505
|
badge: section.badge,
|
|
425
506
|
tags: section.tags
|
|
426
507
|
})) ?? [];
|
|
@@ -431,7 +512,7 @@ function resolveRouteComponent(route) {
|
|
|
431
512
|
}
|
|
432
513
|
function scrollToHash(hash) {
|
|
433
514
|
if (!hash) return;
|
|
434
|
-
const targetId =
|
|
515
|
+
const targetId = require_PageActions.safeDecodeURIComponent(hash.slice(1));
|
|
435
516
|
window.requestAnimationFrame(() => {
|
|
436
517
|
document.getElementById(targetId)?.scrollIntoView();
|
|
437
518
|
window.requestAnimationFrame(() => {
|
|
@@ -439,22 +520,30 @@ function scrollToHash(hash) {
|
|
|
439
520
|
});
|
|
440
521
|
});
|
|
441
522
|
}
|
|
442
|
-
function
|
|
443
|
-
if (route?.locale) return route.locale;
|
|
523
|
+
function explicitLocaleForPath(config, pathname) {
|
|
444
524
|
const i18n = config.i18n;
|
|
445
525
|
if (!i18n) return void 0;
|
|
446
526
|
const firstSegment = pathname.split("/").filter(Boolean)[0];
|
|
447
|
-
return i18n.locales.find((locale) => locale.code === firstSegment)?.code
|
|
527
|
+
return i18n.locales.find((locale) => locale.code === firstSegment)?.code;
|
|
528
|
+
}
|
|
529
|
+
function fallbackLocale(config) {
|
|
530
|
+
return config.i18n?.defaultLocale;
|
|
531
|
+
}
|
|
532
|
+
function storedLocaleForConfig(config) {
|
|
533
|
+
return require_PageActions.getStoredLocalePreference(config.i18n?.locales.map((locale) => locale.code));
|
|
534
|
+
}
|
|
535
|
+
function isDefaultLocale(config, locale) {
|
|
536
|
+
return Boolean(locale && config.i18n?.defaultLocale === locale);
|
|
448
537
|
}
|
|
449
538
|
function isTabbedNavigation(navigation) {
|
|
450
539
|
return !Array.isArray(navigation) && "tabs" in navigation;
|
|
451
540
|
}
|
|
452
541
|
function hasPath(nodes, pathname) {
|
|
453
|
-
return nodes.some((node) =>
|
|
542
|
+
return nodes.some((node) => require_PageActions.isSameRoutePath(node.path, pathname) || hasPath(node.children ?? [], pathname));
|
|
454
543
|
}
|
|
455
544
|
function navigationFromTabs(navigation, pathname) {
|
|
456
545
|
return {
|
|
457
|
-
items: navigation.tabs.find((tab) =>
|
|
546
|
+
items: navigation.tabs.find((tab) => require_PageActions.isSameRoutePath(tab.path, pathname) || hasPath(tab.children, pathname))?.children ?? navigation.tabs[0]?.children ?? [],
|
|
458
547
|
tabs: navigation.tabs
|
|
459
548
|
};
|
|
460
549
|
}
|
|
@@ -488,7 +577,7 @@ function applyDocumentMetadata(config, route) {
|
|
|
488
577
|
setNamedMeta("keywords", route?.keywords?.join(", "));
|
|
489
578
|
}
|
|
490
579
|
function BuiltInNotFoundPage() {
|
|
491
|
-
const text =
|
|
580
|
+
const text = require_PageActions.useBuiltInText();
|
|
492
581
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
493
582
|
className: "mx-auto flex min-h-(--clarify-error-page-min-height) max-w-2xl flex-col justify-center py-16 text-(--clarify-theme-tokens-colors-foreground)",
|
|
494
583
|
"aria-labelledby": "clarify-not-found-title",
|
|
@@ -523,22 +612,46 @@ function NotFoundRouteElement(props) {
|
|
|
523
612
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteComponent, {});
|
|
524
613
|
}
|
|
525
614
|
function AppShell(arg0) {
|
|
526
|
-
const { config, routes, navigation, footerComponent } = arg0;
|
|
615
|
+
const { config, routes, navigation, bannerComponent, footerComponent } = arg0;
|
|
527
616
|
const location = (0, react_router_dom.useLocation)();
|
|
528
|
-
const
|
|
617
|
+
const navigate = (0, react_router_dom.useNavigate)();
|
|
618
|
+
const pathname = require_PageActions.normalizeRoutePath(location.pathname);
|
|
529
619
|
const currentRoute = routeForPath(routes, pathname);
|
|
530
|
-
const
|
|
620
|
+
const explicitLocale = explicitLocaleForPath(config, pathname);
|
|
621
|
+
const [storedLocale] = (0, react.useState)(() => storedLocaleForConfig(config));
|
|
622
|
+
const currentLocale = explicitLocale ?? storedLocale ?? fallbackLocale(config);
|
|
531
623
|
const currentLocaleConfig = config.i18n?.locales.find((locale) => locale.code === currentLocale);
|
|
532
624
|
const notFoundRoute = currentRoute ? void 0 : notFoundRouteForPath(routes, pathname, currentLocale);
|
|
533
|
-
const text =
|
|
625
|
+
const text = require_PageActions.useBuiltInText(currentLocale);
|
|
534
626
|
const currentNavigation = navigationForLocale(navigation, currentLocale, pathname);
|
|
535
627
|
const sections = sectionsForRoute(currentRoute);
|
|
628
|
+
const [dismissedBannerKey, setDismissedBannerKey] = (0, react.useState)();
|
|
629
|
+
const activeBannerKey = config.banner ? JSON.stringify(config.banner) : void 0;
|
|
630
|
+
const hasBanner = Boolean(config.banner) && dismissedBannerKey !== activeBannerKey;
|
|
536
631
|
const hasTabs = Boolean(currentNavigation.tabs?.length);
|
|
537
632
|
const renderRoutes = (0, react.useMemo)(() => routes.map((route) => ({
|
|
538
633
|
...route,
|
|
539
634
|
component: resolveRouteComponent(route)
|
|
540
635
|
})), [routes]);
|
|
541
|
-
const NotFoundRouteComponent = notFoundRoute ? renderRoutes.find((route) =>
|
|
636
|
+
const NotFoundRouteComponent = notFoundRoute ? renderRoutes.find((route) => require_PageActions.isSameRoutePath(route.path, notFoundRoute.path))?.component : void 0;
|
|
637
|
+
(0, react.useEffect)(() => {
|
|
638
|
+
if (explicitLocale) require_PageActions.storeLocalePreference(explicitLocale);
|
|
639
|
+
}, [explicitLocale]);
|
|
640
|
+
(0, react.useEffect)(() => {
|
|
641
|
+
if (explicitLocale || !storedLocale || isDefaultLocale(config, storedLocale)) return;
|
|
642
|
+
const localizedPath = currentRoute?.alternates?.[storedLocale];
|
|
643
|
+
if (!localizedPath || require_PageActions.isSameRoutePath(localizedPath, pathname)) return;
|
|
644
|
+
navigate(`${localizedPath}${location.search}${location.hash}`, { replace: true });
|
|
645
|
+
}, [
|
|
646
|
+
config,
|
|
647
|
+
currentRoute,
|
|
648
|
+
explicitLocale,
|
|
649
|
+
location.hash,
|
|
650
|
+
location.search,
|
|
651
|
+
navigate,
|
|
652
|
+
pathname,
|
|
653
|
+
storedLocale
|
|
654
|
+
]);
|
|
542
655
|
(0, react.useEffect)(() => {
|
|
543
656
|
if (location.hash) {
|
|
544
657
|
scrollToHash(location.hash);
|
|
@@ -565,33 +678,37 @@ function AppShell(arg0) {
|
|
|
565
678
|
currentRoute,
|
|
566
679
|
notFoundRoute
|
|
567
680
|
]);
|
|
568
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
681
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.LocaleContext.Provider, {
|
|
569
682
|
value: currentLocale,
|
|
570
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
683
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_PageActions.SectionProvider, {
|
|
571
684
|
sections,
|
|
572
|
-
children: [
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
685
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.Header, {
|
|
686
|
+
config,
|
|
687
|
+
navigation: currentNavigation.items,
|
|
688
|
+
tabs: currentNavigation.tabs,
|
|
689
|
+
routes,
|
|
690
|
+
currentLocale,
|
|
691
|
+
currentRoute,
|
|
692
|
+
banner: hasBanner ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageBanner, {
|
|
693
|
+
component: bannerComponent,
|
|
578
694
|
currentLocale,
|
|
579
|
-
|
|
580
|
-
})
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
695
|
+
onDismiss: () => setDismissedBannerKey(activeBannerKey)
|
|
696
|
+
}) : void 0
|
|
697
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
698
|
+
className: "clarify-layout mx-auto grid w-full max-w-(--clarify-theme-layout-max-width) grid-cols-1 lg:grid-cols-(--clarify-layout-sidebar-grid) xl:grid-cols-(--clarify-layout-sidebar-grid-wide)",
|
|
699
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
700
|
+
"data-pagefind-ignore": true,
|
|
701
|
+
className: "clarify-sidebar hidden lg:block lg:self-stretch lg:bg-(--clarify-theme-tokens-colors-background) lg:px-5 xl:px-6",
|
|
702
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
703
|
+
className: (0, clsx.default)("clarify-sidebar-scroll lg:sticky lg:z-30 lg:overflow-y-auto lg:pb-8", hasTabs && hasBanner && "lg:top-40 lg:h-(--clarify-sidebar-height-with-tabs-and-banner) lg:pt-10", hasTabs && !hasBanner && "lg:top-28 lg:h-(--clarify-sidebar-height-with-tabs) lg:pt-10", !hasTabs && hasBanner && "lg:top-[6.5rem] lg:h-(--clarify-sidebar-height-with-banner) lg:pt-10", !hasTabs && !hasBanner && "lg:top-14 lg:h-(--clarify-sidebar-height) lg:pt-10"),
|
|
704
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.Navigation, { navigation: currentNavigation.items })
|
|
705
|
+
})
|
|
706
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
707
|
+
className: (0, clsx.default)("clarify-content @container relative flex min-h-screen min-w-0 flex-col px-4 pb-12 sm:px-6 lg:px-8 xl:px-10", hasTabs && hasBanner && "pt-[6.5rem] lg:pt-40", hasTabs && !hasBanner && "pt-14 lg:pt-28", !hasTabs && hasBanner && "pt-[6.5rem]", !hasTabs && !hasBanner && "pt-14"),
|
|
708
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_PageActions.PageActionsProvider, {
|
|
709
|
+
route: currentRoute,
|
|
710
|
+
routePrefix: config.routePrefix,
|
|
589
711
|
children: [
|
|
590
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.ContentActions, {
|
|
591
|
-
hasTabs,
|
|
592
|
-
route: currentRoute,
|
|
593
|
-
routePrefix: config.routePrefix
|
|
594
|
-
}),
|
|
595
712
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("main", {
|
|
596
713
|
className: "clarify-main min-w-0 flex-auto",
|
|
597
714
|
"data-pagefind-body": true,
|
|
@@ -624,12 +741,12 @@ function AppShell(arg0) {
|
|
|
624
741
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageNavigation, {
|
|
625
742
|
navigation: currentNavigation.items,
|
|
626
743
|
currentRoute
|
|
627
|
-
})
|
|
744
|
+
}),
|
|
745
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageFooter, { component: footerComponent })
|
|
628
746
|
]
|
|
629
|
-
})
|
|
630
|
-
})
|
|
631
|
-
|
|
632
|
-
]
|
|
747
|
+
})
|
|
748
|
+
})]
|
|
749
|
+
})]
|
|
633
750
|
})
|
|
634
751
|
});
|
|
635
752
|
}
|
|
@@ -1286,6 +1403,183 @@ function createRandomTheme() {
|
|
|
1286
1403
|
};
|
|
1287
1404
|
}
|
|
1288
1405
|
//#endregion
|
|
1406
|
+
//#region source/theme/variables.ts
|
|
1407
|
+
var themeStorageKey = require_PageActions.themeCookieName;
|
|
1408
|
+
var themePresets = {
|
|
1409
|
+
default: {
|
|
1410
|
+
preset: "default",
|
|
1411
|
+
tokens: {
|
|
1412
|
+
colors: {
|
|
1413
|
+
primary: "#047857",
|
|
1414
|
+
accent: "#0D9488",
|
|
1415
|
+
background: {
|
|
1416
|
+
light: "#ffffff",
|
|
1417
|
+
dark: "#09090b"
|
|
1418
|
+
},
|
|
1419
|
+
foreground: {
|
|
1420
|
+
light: "#111827",
|
|
1421
|
+
dark: "#ffffff"
|
|
1422
|
+
},
|
|
1423
|
+
surface: {
|
|
1424
|
+
light: "#ffffff",
|
|
1425
|
+
dark: "#18181b"
|
|
1426
|
+
},
|
|
1427
|
+
muted: {
|
|
1428
|
+
light: "#64748b",
|
|
1429
|
+
dark: "#a1a1aa"
|
|
1430
|
+
},
|
|
1431
|
+
border: {
|
|
1432
|
+
light: "rgb(15 23 42 / 0.12)",
|
|
1433
|
+
dark: "rgb(255 255 255 / 0.1)"
|
|
1434
|
+
},
|
|
1435
|
+
codeBackground: {
|
|
1436
|
+
light: "#f6fbf8",
|
|
1437
|
+
dark: "#18181b"
|
|
1438
|
+
}
|
|
1439
|
+
},
|
|
1440
|
+
radius: {
|
|
1441
|
+
sm: "6px",
|
|
1442
|
+
md: "10px",
|
|
1443
|
+
lg: "14px",
|
|
1444
|
+
xl: "18px"
|
|
1445
|
+
}
|
|
1446
|
+
},
|
|
1447
|
+
layout: { maxWidth: "82rem" },
|
|
1448
|
+
editor: false
|
|
1449
|
+
},
|
|
1450
|
+
base: {
|
|
1451
|
+
preset: "base",
|
|
1452
|
+
tokens: {
|
|
1453
|
+
colors: {
|
|
1454
|
+
primary: "#18181b",
|
|
1455
|
+
accent: "#52525b",
|
|
1456
|
+
background: {
|
|
1457
|
+
light: "#ffffff",
|
|
1458
|
+
dark: "#09090b"
|
|
1459
|
+
},
|
|
1460
|
+
foreground: {
|
|
1461
|
+
light: "#18181b",
|
|
1462
|
+
dark: "#ffffff"
|
|
1463
|
+
},
|
|
1464
|
+
surface: {
|
|
1465
|
+
light: "#ffffff",
|
|
1466
|
+
dark: "#18181b"
|
|
1467
|
+
},
|
|
1468
|
+
muted: {
|
|
1469
|
+
light: "#71717a",
|
|
1470
|
+
dark: "#a1a1aa"
|
|
1471
|
+
},
|
|
1472
|
+
border: {
|
|
1473
|
+
light: "rgb(24 24 27 / 0.12)",
|
|
1474
|
+
dark: "rgb(255 255 255 / 0.1)"
|
|
1475
|
+
},
|
|
1476
|
+
codeBackground: {
|
|
1477
|
+
light: "#f4f4f5",
|
|
1478
|
+
dark: "#18181b"
|
|
1479
|
+
}
|
|
1480
|
+
},
|
|
1481
|
+
radius: {
|
|
1482
|
+
sm: "6px",
|
|
1483
|
+
md: "8px",
|
|
1484
|
+
lg: "12px",
|
|
1485
|
+
xl: "16px"
|
|
1486
|
+
}
|
|
1487
|
+
},
|
|
1488
|
+
layout: { maxWidth: "80rem" },
|
|
1489
|
+
editor: false
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
function cloneThemeColorValue(value) {
|
|
1493
|
+
return typeof value === "string" ? value : { ...value };
|
|
1494
|
+
}
|
|
1495
|
+
function cloneTheme(theme) {
|
|
1496
|
+
return {
|
|
1497
|
+
preset: theme.preset,
|
|
1498
|
+
tokens: {
|
|
1499
|
+
colors: {
|
|
1500
|
+
primary: cloneThemeColorValue(theme.tokens.colors.primary),
|
|
1501
|
+
accent: cloneThemeColorValue(theme.tokens.colors.accent),
|
|
1502
|
+
background: cloneThemeColorValue(theme.tokens.colors.background),
|
|
1503
|
+
foreground: cloneThemeColorValue(theme.tokens.colors.foreground),
|
|
1504
|
+
surface: cloneThemeColorValue(theme.tokens.colors.surface),
|
|
1505
|
+
muted: cloneThemeColorValue(theme.tokens.colors.muted),
|
|
1506
|
+
border: cloneThemeColorValue(theme.tokens.colors.border),
|
|
1507
|
+
codeBackground: cloneThemeColorValue(theme.tokens.colors.codeBackground)
|
|
1508
|
+
},
|
|
1509
|
+
radius: { ...theme.tokens.radius }
|
|
1510
|
+
},
|
|
1511
|
+
layout: { ...theme.layout },
|
|
1512
|
+
editor: theme.editor
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
function isModeColorValue(value) {
|
|
1516
|
+
return typeof value === "object" && value !== null;
|
|
1517
|
+
}
|
|
1518
|
+
function resolveThemeColorValue(value, resolvedTheme = "light") {
|
|
1519
|
+
if (!isModeColorValue(value)) return value;
|
|
1520
|
+
return value[resolvedTheme] ?? value.light ?? value.dark ?? "";
|
|
1521
|
+
}
|
|
1522
|
+
function resolveThemeColors(colors, resolvedTheme = "light") {
|
|
1523
|
+
return {
|
|
1524
|
+
primary: resolveThemeColorValue(colors.primary, resolvedTheme),
|
|
1525
|
+
accent: resolveThemeColorValue(colors.accent, resolvedTheme),
|
|
1526
|
+
background: resolveThemeColorValue(colors.background, resolvedTheme),
|
|
1527
|
+
foreground: resolveThemeColorValue(colors.foreground, resolvedTheme),
|
|
1528
|
+
surface: resolveThemeColorValue(colors.surface, resolvedTheme),
|
|
1529
|
+
muted: resolveThemeColorValue(colors.muted, resolvedTheme),
|
|
1530
|
+
border: resolveThemeColorValue(colors.border, resolvedTheme),
|
|
1531
|
+
codeBackground: resolveThemeColorValue(colors.codeBackground, resolvedTheme)
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
function themeToCssVariables(theme, resolvedTheme) {
|
|
1535
|
+
const colors = resolveThemeColors(theme.tokens.colors, resolvedTheme);
|
|
1536
|
+
const { radius } = theme.tokens;
|
|
1537
|
+
return {
|
|
1538
|
+
"--clarify-theme-tokens-colors-primary": colors.primary,
|
|
1539
|
+
"--clarify-theme-tokens-colors-accent": colors.accent,
|
|
1540
|
+
"--clarify-theme-tokens-colors-background": colors.background,
|
|
1541
|
+
"--clarify-theme-tokens-colors-foreground": colors.foreground,
|
|
1542
|
+
"--clarify-theme-tokens-colors-surface": colors.surface,
|
|
1543
|
+
"--clarify-theme-tokens-colors-muted": colors.muted,
|
|
1544
|
+
"--clarify-theme-tokens-colors-border": colors.border,
|
|
1545
|
+
"--clarify-theme-tokens-colors-code-background": colors.codeBackground,
|
|
1546
|
+
"--clarify-theme-tokens-radius-sm": radius.sm,
|
|
1547
|
+
"--clarify-theme-tokens-radius-md": radius.md,
|
|
1548
|
+
"--clarify-theme-tokens-radius-lg": radius.lg,
|
|
1549
|
+
"--clarify-theme-tokens-radius-xl": radius.xl,
|
|
1550
|
+
"--clarify-theme-layout-max-width": theme.layout.maxWidth
|
|
1551
|
+
};
|
|
1552
|
+
}
|
|
1553
|
+
function themeBootstrapScript(theme = themePresets.default) {
|
|
1554
|
+
const darkVariables = themeToCssVariables(theme, "dark");
|
|
1555
|
+
const lightVariables = themeToCssVariables(theme, "light");
|
|
1556
|
+
return `(function(){try{var c=${JSON.stringify(require_PageActions.themeCookieName)};var m=document.cookie?document.cookie.split('; '):[];var e=null;for(var i=0;i<m.length;i++){var p=m[i].indexOf('=');var n=p===-1?m[i]:m[i].slice(0,p);if(decodeURIComponent(n)===c){e=p===-1?'':decodeURIComponent(m[i].slice(p+1));break}}var t=e==='dark'||e==='light'||e==='system'?e:'system';var r=t==='system'?window.matchMedia('(prefers-color-scheme: dark)').matches:t==='dark';var v=r?${JSON.stringify(darkVariables)}:${JSON.stringify(lightVariables)};var s=document.documentElement.style;for(var k in v)s.setProperty(k,v[k]);document.documentElement.classList.toggle('dark',r);document.documentElement.style.colorScheme=r?'dark':'light'}catch(e){}})();`;
|
|
1557
|
+
}
|
|
1558
|
+
function uniqueElements(elements) {
|
|
1559
|
+
return Array.from(new Set(elements));
|
|
1560
|
+
}
|
|
1561
|
+
function resolveThemeVariableTargets(target) {
|
|
1562
|
+
if (typeof document === "undefined") return [];
|
|
1563
|
+
if (target instanceof HTMLElement) return [target];
|
|
1564
|
+
if (typeof target === "string") return Array.from(document.querySelectorAll(target));
|
|
1565
|
+
return uniqueElements([document.documentElement, ...Array.from(document.querySelectorAll(".clarify-app"))]);
|
|
1566
|
+
}
|
|
1567
|
+
function applyThemeCssVariables(variables, targets) {
|
|
1568
|
+
const previousValues = /* @__PURE__ */ new Map();
|
|
1569
|
+
for (const element of targets) {
|
|
1570
|
+
const elementPreviousValues = /* @__PURE__ */ new Map();
|
|
1571
|
+
for (const [property, value] of Object.entries(variables)) {
|
|
1572
|
+
elementPreviousValues.set(property, element.style.getPropertyValue(property));
|
|
1573
|
+
element.style.setProperty(property, value);
|
|
1574
|
+
}
|
|
1575
|
+
previousValues.set(element, elementPreviousValues);
|
|
1576
|
+
}
|
|
1577
|
+
return () => {
|
|
1578
|
+
for (const [element, elementPreviousValues] of previousValues) for (const [property, previousValue] of elementPreviousValues) if (previousValue) element.style.setProperty(property, previousValue);
|
|
1579
|
+
else element.style.removeProperty(property);
|
|
1580
|
+
};
|
|
1581
|
+
}
|
|
1582
|
+
//#endregion
|
|
1289
1583
|
//#region source/theme/ThemeEditor.tsx
|
|
1290
1584
|
var colorTokenFields = [
|
|
1291
1585
|
{
|
|
@@ -1343,18 +1637,24 @@ var layoutFields = [{
|
|
|
1343
1637
|
key: "maxWidth",
|
|
1344
1638
|
label: "Max width"
|
|
1345
1639
|
}];
|
|
1346
|
-
var
|
|
1347
|
-
function
|
|
1348
|
-
return
|
|
1640
|
+
var themeEditorPresets = themePresets;
|
|
1641
|
+
function applyThemeVariables(theme, target) {
|
|
1642
|
+
return applyThemeCssVariables(themeToCssVariables(theme), resolveThemeVariableTargets(target));
|
|
1349
1643
|
}
|
|
1350
1644
|
function isHexColor(value) {
|
|
1351
1645
|
return /^#[0-9a-f]{6}$/i.test(value);
|
|
1352
1646
|
}
|
|
1353
|
-
function updateThemeModeColorValue(value,
|
|
1354
|
-
if (typeof value === "string") return
|
|
1647
|
+
function updateThemeModeColorValue(value, mode, nextValue) {
|
|
1648
|
+
if (typeof value === "string") return mode === "light" ? {
|
|
1649
|
+
light: nextValue,
|
|
1650
|
+
dark: value
|
|
1651
|
+
} : {
|
|
1652
|
+
light: value,
|
|
1653
|
+
dark: nextValue
|
|
1654
|
+
};
|
|
1355
1655
|
return {
|
|
1356
1656
|
...value,
|
|
1357
|
-
[
|
|
1657
|
+
[mode]: nextValue
|
|
1358
1658
|
};
|
|
1359
1659
|
}
|
|
1360
1660
|
function TextField(props) {
|
|
@@ -1387,6 +1687,61 @@ function TextField(props) {
|
|
|
1387
1687
|
})]
|
|
1388
1688
|
});
|
|
1389
1689
|
}
|
|
1690
|
+
function ColorField(props) {
|
|
1691
|
+
const { id, label, value, onChange } = props;
|
|
1692
|
+
const lightValue = resolveThemeColorValue(value, "light");
|
|
1693
|
+
const darkValue = resolveThemeColorValue(value, "dark");
|
|
1694
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1695
|
+
className: "grid min-w-0 gap-1.5",
|
|
1696
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1697
|
+
className: "text-xs/5 font-medium text-(--clarify-ui-text)",
|
|
1698
|
+
children: label
|
|
1699
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1700
|
+
className: "grid grid-cols-2 gap-2",
|
|
1701
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorModeInput, {
|
|
1702
|
+
id: `${id}-light`,
|
|
1703
|
+
mode: "light",
|
|
1704
|
+
value: lightValue,
|
|
1705
|
+
onChange: (v) => onChange("light", v)
|
|
1706
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorModeInput, {
|
|
1707
|
+
id: `${id}-dark`,
|
|
1708
|
+
mode: "dark",
|
|
1709
|
+
value: darkValue,
|
|
1710
|
+
onChange: (v) => onChange("dark", v)
|
|
1711
|
+
})]
|
|
1712
|
+
})]
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
function ColorModeInput(props) {
|
|
1716
|
+
const { id, mode, value, onChange } = props;
|
|
1717
|
+
const canUseColorInput = isHexColor(value);
|
|
1718
|
+
function handleTextChange(event) {
|
|
1719
|
+
onChange(event.target.value);
|
|
1720
|
+
}
|
|
1721
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1722
|
+
htmlFor: id,
|
|
1723
|
+
className: "grid min-w-0 gap-1 text-[11px]/4 font-medium text-(--clarify-ui-text-faint)",
|
|
1724
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1725
|
+
className: "flex min-w-0 items-center justify-between gap-2",
|
|
1726
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1727
|
+
className: "uppercase tracking-wide",
|
|
1728
|
+
children: mode
|
|
1729
|
+
}), canUseColorInput ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1730
|
+
type: "color",
|
|
1731
|
+
value,
|
|
1732
|
+
"aria-label": `${id} color`,
|
|
1733
|
+
className: "h-4 w-6 shrink-0 cursor-pointer rounded border border-(--clarify-theme-tokens-colors-border) bg-transparent p-0",
|
|
1734
|
+
onChange: handleTextChange
|
|
1735
|
+
}) : null]
|
|
1736
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1737
|
+
id,
|
|
1738
|
+
value,
|
|
1739
|
+
spellCheck: false,
|
|
1740
|
+
className: "h-8 w-full min-w-0 rounded-(--clarify-theme-tokens-radius-sm) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) px-2 font-mono text-xs text-(--clarify-theme-tokens-colors-foreground) shadow-xs outline-none transition focus:border-(--clarify-theme-tokens-colors-primary) focus:ring-2 focus:ring-(--clarify-ui-accent-border)",
|
|
1741
|
+
onChange: handleTextChange
|
|
1742
|
+
})]
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1390
1745
|
function themeToConfigSource(theme) {
|
|
1391
1746
|
return JSON.stringify({ theme: {
|
|
1392
1747
|
preset: theme.preset,
|
|
@@ -1396,12 +1751,12 @@ function themeToConfigSource(theme) {
|
|
|
1396
1751
|
}
|
|
1397
1752
|
function ThemeEditor(props) {
|
|
1398
1753
|
const { initialTheme, onChange, target, defaultOpen = false, className } = props;
|
|
1399
|
-
const { resolvedTheme } =
|
|
1754
|
+
const { resolvedTheme } = require_PageActions.useTheme();
|
|
1400
1755
|
const [isOpen, setIsOpen] = (0, react.useState)(defaultOpen);
|
|
1401
|
-
const [theme, setTheme] = (0, react.useState)(() =>
|
|
1756
|
+
const [theme, setTheme] = (0, react.useState)(() => cloneTheme(initialTheme ?? themeEditorPresets.default));
|
|
1402
1757
|
const [copyState, setCopyState] = (0, react.useState)("idle");
|
|
1403
1758
|
const configSource = (0, react.useMemo)(() => themeToConfigSource(theme), [theme]);
|
|
1404
|
-
(0, react.useEffect)(() =>
|
|
1759
|
+
(0, react.useEffect)(() => applyThemeCssVariables(themeToCssVariables(theme, resolvedTheme), resolveThemeVariableTargets(target)), [
|
|
1405
1760
|
resolvedTheme,
|
|
1406
1761
|
target,
|
|
1407
1762
|
theme
|
|
@@ -1411,16 +1766,16 @@ function ThemeEditor(props) {
|
|
|
1411
1766
|
onChange?.(nextTheme);
|
|
1412
1767
|
}
|
|
1413
1768
|
function updatePreset(nextPreset) {
|
|
1414
|
-
commit(
|
|
1769
|
+
commit(cloneTheme(themeEditorPresets[nextPreset]));
|
|
1415
1770
|
}
|
|
1416
|
-
function updateColorToken(key, value) {
|
|
1771
|
+
function updateColorToken(key, mode, value) {
|
|
1417
1772
|
commit({
|
|
1418
1773
|
...theme,
|
|
1419
1774
|
tokens: {
|
|
1420
1775
|
...theme.tokens,
|
|
1421
1776
|
colors: {
|
|
1422
1777
|
...theme.tokens.colors,
|
|
1423
|
-
[key]: updateThemeModeColorValue(theme.tokens.colors[key],
|
|
1778
|
+
[key]: updateThemeModeColorValue(theme.tokens.colors[key], mode, value)
|
|
1424
1779
|
}
|
|
1425
1780
|
}
|
|
1426
1781
|
});
|
|
@@ -1510,12 +1865,11 @@ function ThemeEditor(props) {
|
|
|
1510
1865
|
children: "Colors"
|
|
1511
1866
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1512
1867
|
className: "grid grid-cols-1 gap-3",
|
|
1513
|
-
children: colorTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1868
|
+
children: colorTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorField, {
|
|
1514
1869
|
id: `clarify-theme-editor-color-${field.key}`,
|
|
1515
1870
|
label: field.label,
|
|
1516
|
-
value:
|
|
1517
|
-
|
|
1518
|
-
onChange: (value) => updateColorToken(field.key, value)
|
|
1871
|
+
value: theme.tokens.colors[field.key],
|
|
1872
|
+
onChange: (mode, value) => updateColorToken(field.key, mode, value)
|
|
1519
1873
|
}, field.key))
|
|
1520
1874
|
})]
|
|
1521
1875
|
}),
|
|
@@ -1586,13 +1940,12 @@ function ThemeEditor(props) {
|
|
|
1586
1940
|
//#region source/theme/ThemeRoot.tsx
|
|
1587
1941
|
function ThemeRoot(props) {
|
|
1588
1942
|
const { children, theme, themeEditor = false } = props;
|
|
1589
|
-
const { resolvedTheme } =
|
|
1590
|
-
const themeVariables = (0, react.useMemo)(() =>
|
|
1591
|
-
(0, react.useEffect)(() =>
|
|
1943
|
+
const { resolvedTheme } = require_PageActions.useTheme();
|
|
1944
|
+
const themeVariables = (0, react.useMemo)(() => themeToCssVariables(theme, resolvedTheme), [resolvedTheme, theme]);
|
|
1945
|
+
(0, react.useEffect)(() => applyThemeCssVariables(themeVariables, resolveThemeVariableTargets(":root")), [themeVariables]);
|
|
1592
1946
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1593
1947
|
className: "clarify-app h-full min-h-screen bg-(--clarify-theme-tokens-colors-background) text-(--clarify-theme-tokens-colors-foreground)",
|
|
1594
1948
|
"data-theme-preset": theme.preset,
|
|
1595
|
-
style: themeVariables,
|
|
1596
1949
|
children: [children, themeEditor ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeEditor, { initialTheme: theme }) : null]
|
|
1597
1950
|
});
|
|
1598
1951
|
}
|
|
@@ -1609,6 +1962,12 @@ Object.defineProperty(exports, "BuiltWithClarify", {
|
|
|
1609
1962
|
return BuiltWithClarify;
|
|
1610
1963
|
}
|
|
1611
1964
|
});
|
|
1965
|
+
Object.defineProperty(exports, "PageBanner", {
|
|
1966
|
+
enumerable: true,
|
|
1967
|
+
get: function() {
|
|
1968
|
+
return PageBanner;
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1612
1971
|
Object.defineProperty(exports, "PageFooter", {
|
|
1613
1972
|
enumerable: true,
|
|
1614
1973
|
get: function() {
|
|
@@ -1627,17 +1986,35 @@ Object.defineProperty(exports, "ThemeRoot", {
|
|
|
1627
1986
|
return ThemeRoot;
|
|
1628
1987
|
}
|
|
1629
1988
|
});
|
|
1630
|
-
Object.defineProperty(exports, "
|
|
1989
|
+
Object.defineProperty(exports, "applyThemeVariables", {
|
|
1990
|
+
enumerable: true,
|
|
1991
|
+
get: function() {
|
|
1992
|
+
return applyThemeVariables;
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1995
|
+
Object.defineProperty(exports, "themeBootstrapScript", {
|
|
1996
|
+
enumerable: true,
|
|
1997
|
+
get: function() {
|
|
1998
|
+
return themeBootstrapScript;
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
Object.defineProperty(exports, "themeEditorPresets", {
|
|
2002
|
+
enumerable: true,
|
|
2003
|
+
get: function() {
|
|
2004
|
+
return themeEditorPresets;
|
|
2005
|
+
}
|
|
2006
|
+
});
|
|
2007
|
+
Object.defineProperty(exports, "themePresets", {
|
|
1631
2008
|
enumerable: true,
|
|
1632
2009
|
get: function() {
|
|
1633
|
-
return
|
|
2010
|
+
return themePresets;
|
|
1634
2011
|
}
|
|
1635
2012
|
});
|
|
1636
|
-
Object.defineProperty(exports, "
|
|
2013
|
+
Object.defineProperty(exports, "themeStorageKey", {
|
|
1637
2014
|
enumerable: true,
|
|
1638
2015
|
get: function() {
|
|
1639
|
-
return
|
|
2016
|
+
return themeStorageKey;
|
|
1640
2017
|
}
|
|
1641
2018
|
});
|
|
1642
2019
|
|
|
1643
|
-
//# sourceMappingURL=ThemeRoot-
|
|
2020
|
+
//# sourceMappingURL=ThemeRoot-DYS-lcK-.cjs.map
|