@clarify-labs/renderer 0.7.0 → 0.7.2
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-BcyW_ULy.cjs} +186 -140
- package/output/OpenApiOperation-BcyW_ULy.cjs.map +1 -0
- package/output/{OpenApiOperation-CWSOhUVa.js → OpenApiOperation-tUKf7lZ4.js} +166 -120
- package/output/OpenApiOperation-tUKf7lZ4.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-QULrwQf6.js} +407 -53
- package/output/ThemeRoot-QULrwQf6.js.map +1 -0
- package/output/{ThemeRoot-CEvwrGp5.cjs → ThemeRoot-UWj0iK1X.cjs} +458 -80
- package/output/ThemeRoot-UWj0iK1X.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 +2 -0
- package/output/mdx/primitives.d.ts +2 -0
- package/output/openapi/components/EndpointSections.d.ts +30 -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-ByWbJbrA.cjs} +8 -7
- package/output/render-ByWbJbrA.cjs.map +1 -0
- package/output/{render-CnUd0XwZ.js → render-psutGbsg.js} +6 -5
- package/output/render-psutGbsg.js.map +1 -0
- package/output/renderer.css +371 -269
- 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,38 @@ 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
|
-
className: (0, clsx.default)("clarify-
|
|
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
|
+
style: { "--clarify-header-offset": hasTabs && hasBanner ? "10rem" : hasTabs && !hasBanner ? "7rem" : !hasTabs && hasBanner ? "6.5rem" : "3.5rem" },
|
|
700
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("aside", {
|
|
701
|
+
"data-pagefind-ignore": true,
|
|
702
|
+
className: "clarify-sidebar hidden lg:block lg:self-stretch lg:bg-(--clarify-theme-tokens-colors-background) lg:px-5 xl:px-6",
|
|
703
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
704
|
+
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"),
|
|
705
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.Navigation, { navigation: currentNavigation.items })
|
|
706
|
+
})
|
|
707
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
708
|
+
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"),
|
|
709
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_PageActions.PageActionsProvider, {
|
|
710
|
+
route: currentRoute,
|
|
711
|
+
routePrefix: config.routePrefix,
|
|
589
712
|
children: [
|
|
590
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.ContentActions, {
|
|
591
|
-
hasTabs,
|
|
592
|
-
route: currentRoute,
|
|
593
|
-
routePrefix: config.routePrefix
|
|
594
|
-
}),
|
|
595
713
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("main", {
|
|
596
714
|
className: "clarify-main min-w-0 flex-auto",
|
|
597
715
|
"data-pagefind-body": true,
|
|
@@ -624,12 +742,12 @@ function AppShell(arg0) {
|
|
|
624
742
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageNavigation, {
|
|
625
743
|
navigation: currentNavigation.items,
|
|
626
744
|
currentRoute
|
|
627
|
-
})
|
|
745
|
+
}),
|
|
746
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageFooter, { component: footerComponent })
|
|
628
747
|
]
|
|
629
|
-
})
|
|
630
|
-
})
|
|
631
|
-
|
|
632
|
-
]
|
|
748
|
+
})
|
|
749
|
+
})]
|
|
750
|
+
})]
|
|
633
751
|
})
|
|
634
752
|
});
|
|
635
753
|
}
|
|
@@ -1286,6 +1404,183 @@ function createRandomTheme() {
|
|
|
1286
1404
|
};
|
|
1287
1405
|
}
|
|
1288
1406
|
//#endregion
|
|
1407
|
+
//#region source/theme/variables.ts
|
|
1408
|
+
var themeStorageKey = require_PageActions.themeCookieName;
|
|
1409
|
+
var themePresets = {
|
|
1410
|
+
default: {
|
|
1411
|
+
preset: "default",
|
|
1412
|
+
tokens: {
|
|
1413
|
+
colors: {
|
|
1414
|
+
primary: "#047857",
|
|
1415
|
+
accent: "#0D9488",
|
|
1416
|
+
background: {
|
|
1417
|
+
light: "#ffffff",
|
|
1418
|
+
dark: "#09090b"
|
|
1419
|
+
},
|
|
1420
|
+
foreground: {
|
|
1421
|
+
light: "#111827",
|
|
1422
|
+
dark: "#ffffff"
|
|
1423
|
+
},
|
|
1424
|
+
surface: {
|
|
1425
|
+
light: "#ffffff",
|
|
1426
|
+
dark: "#18181b"
|
|
1427
|
+
},
|
|
1428
|
+
muted: {
|
|
1429
|
+
light: "#64748b",
|
|
1430
|
+
dark: "#a1a1aa"
|
|
1431
|
+
},
|
|
1432
|
+
border: {
|
|
1433
|
+
light: "rgb(15 23 42 / 0.12)",
|
|
1434
|
+
dark: "rgb(255 255 255 / 0.1)"
|
|
1435
|
+
},
|
|
1436
|
+
codeBackground: {
|
|
1437
|
+
light: "#f6fbf8",
|
|
1438
|
+
dark: "#18181b"
|
|
1439
|
+
}
|
|
1440
|
+
},
|
|
1441
|
+
radius: {
|
|
1442
|
+
sm: "6px",
|
|
1443
|
+
md: "10px",
|
|
1444
|
+
lg: "14px",
|
|
1445
|
+
xl: "18px"
|
|
1446
|
+
}
|
|
1447
|
+
},
|
|
1448
|
+
layout: { maxWidth: "82rem" },
|
|
1449
|
+
editor: false
|
|
1450
|
+
},
|
|
1451
|
+
base: {
|
|
1452
|
+
preset: "base",
|
|
1453
|
+
tokens: {
|
|
1454
|
+
colors: {
|
|
1455
|
+
primary: "#18181b",
|
|
1456
|
+
accent: "#52525b",
|
|
1457
|
+
background: {
|
|
1458
|
+
light: "#ffffff",
|
|
1459
|
+
dark: "#09090b"
|
|
1460
|
+
},
|
|
1461
|
+
foreground: {
|
|
1462
|
+
light: "#18181b",
|
|
1463
|
+
dark: "#ffffff"
|
|
1464
|
+
},
|
|
1465
|
+
surface: {
|
|
1466
|
+
light: "#ffffff",
|
|
1467
|
+
dark: "#18181b"
|
|
1468
|
+
},
|
|
1469
|
+
muted: {
|
|
1470
|
+
light: "#71717a",
|
|
1471
|
+
dark: "#a1a1aa"
|
|
1472
|
+
},
|
|
1473
|
+
border: {
|
|
1474
|
+
light: "rgb(24 24 27 / 0.12)",
|
|
1475
|
+
dark: "rgb(255 255 255 / 0.1)"
|
|
1476
|
+
},
|
|
1477
|
+
codeBackground: {
|
|
1478
|
+
light: "#f4f4f5",
|
|
1479
|
+
dark: "#18181b"
|
|
1480
|
+
}
|
|
1481
|
+
},
|
|
1482
|
+
radius: {
|
|
1483
|
+
sm: "6px",
|
|
1484
|
+
md: "8px",
|
|
1485
|
+
lg: "12px",
|
|
1486
|
+
xl: "16px"
|
|
1487
|
+
}
|
|
1488
|
+
},
|
|
1489
|
+
layout: { maxWidth: "80rem" },
|
|
1490
|
+
editor: false
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
function cloneThemeColorValue(value) {
|
|
1494
|
+
return typeof value === "string" ? value : { ...value };
|
|
1495
|
+
}
|
|
1496
|
+
function cloneTheme(theme) {
|
|
1497
|
+
return {
|
|
1498
|
+
preset: theme.preset,
|
|
1499
|
+
tokens: {
|
|
1500
|
+
colors: {
|
|
1501
|
+
primary: cloneThemeColorValue(theme.tokens.colors.primary),
|
|
1502
|
+
accent: cloneThemeColorValue(theme.tokens.colors.accent),
|
|
1503
|
+
background: cloneThemeColorValue(theme.tokens.colors.background),
|
|
1504
|
+
foreground: cloneThemeColorValue(theme.tokens.colors.foreground),
|
|
1505
|
+
surface: cloneThemeColorValue(theme.tokens.colors.surface),
|
|
1506
|
+
muted: cloneThemeColorValue(theme.tokens.colors.muted),
|
|
1507
|
+
border: cloneThemeColorValue(theme.tokens.colors.border),
|
|
1508
|
+
codeBackground: cloneThemeColorValue(theme.tokens.colors.codeBackground)
|
|
1509
|
+
},
|
|
1510
|
+
radius: { ...theme.tokens.radius }
|
|
1511
|
+
},
|
|
1512
|
+
layout: { ...theme.layout },
|
|
1513
|
+
editor: theme.editor
|
|
1514
|
+
};
|
|
1515
|
+
}
|
|
1516
|
+
function isModeColorValue(value) {
|
|
1517
|
+
return typeof value === "object" && value !== null;
|
|
1518
|
+
}
|
|
1519
|
+
function resolveThemeColorValue(value, resolvedTheme = "light") {
|
|
1520
|
+
if (!isModeColorValue(value)) return value;
|
|
1521
|
+
return value[resolvedTheme] ?? value.light ?? value.dark ?? "";
|
|
1522
|
+
}
|
|
1523
|
+
function resolveThemeColors(colors, resolvedTheme = "light") {
|
|
1524
|
+
return {
|
|
1525
|
+
primary: resolveThemeColorValue(colors.primary, resolvedTheme),
|
|
1526
|
+
accent: resolveThemeColorValue(colors.accent, resolvedTheme),
|
|
1527
|
+
background: resolveThemeColorValue(colors.background, resolvedTheme),
|
|
1528
|
+
foreground: resolveThemeColorValue(colors.foreground, resolvedTheme),
|
|
1529
|
+
surface: resolveThemeColorValue(colors.surface, resolvedTheme),
|
|
1530
|
+
muted: resolveThemeColorValue(colors.muted, resolvedTheme),
|
|
1531
|
+
border: resolveThemeColorValue(colors.border, resolvedTheme),
|
|
1532
|
+
codeBackground: resolveThemeColorValue(colors.codeBackground, resolvedTheme)
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
function themeToCssVariables(theme, resolvedTheme) {
|
|
1536
|
+
const colors = resolveThemeColors(theme.tokens.colors, resolvedTheme);
|
|
1537
|
+
const { radius } = theme.tokens;
|
|
1538
|
+
return {
|
|
1539
|
+
"--clarify-theme-tokens-colors-primary": colors.primary,
|
|
1540
|
+
"--clarify-theme-tokens-colors-accent": colors.accent,
|
|
1541
|
+
"--clarify-theme-tokens-colors-background": colors.background,
|
|
1542
|
+
"--clarify-theme-tokens-colors-foreground": colors.foreground,
|
|
1543
|
+
"--clarify-theme-tokens-colors-surface": colors.surface,
|
|
1544
|
+
"--clarify-theme-tokens-colors-muted": colors.muted,
|
|
1545
|
+
"--clarify-theme-tokens-colors-border": colors.border,
|
|
1546
|
+
"--clarify-theme-tokens-colors-code-background": colors.codeBackground,
|
|
1547
|
+
"--clarify-theme-tokens-radius-sm": radius.sm,
|
|
1548
|
+
"--clarify-theme-tokens-radius-md": radius.md,
|
|
1549
|
+
"--clarify-theme-tokens-radius-lg": radius.lg,
|
|
1550
|
+
"--clarify-theme-tokens-radius-xl": radius.xl,
|
|
1551
|
+
"--clarify-theme-layout-max-width": theme.layout.maxWidth
|
|
1552
|
+
};
|
|
1553
|
+
}
|
|
1554
|
+
function themeBootstrapScript(theme = themePresets.default) {
|
|
1555
|
+
const darkVariables = themeToCssVariables(theme, "dark");
|
|
1556
|
+
const lightVariables = themeToCssVariables(theme, "light");
|
|
1557
|
+
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){}})();`;
|
|
1558
|
+
}
|
|
1559
|
+
function uniqueElements(elements) {
|
|
1560
|
+
return Array.from(new Set(elements));
|
|
1561
|
+
}
|
|
1562
|
+
function resolveThemeVariableTargets(target) {
|
|
1563
|
+
if (typeof document === "undefined") return [];
|
|
1564
|
+
if (target instanceof HTMLElement) return [target];
|
|
1565
|
+
if (typeof target === "string") return Array.from(document.querySelectorAll(target));
|
|
1566
|
+
return uniqueElements([document.documentElement, ...Array.from(document.querySelectorAll(".clarify-app"))]);
|
|
1567
|
+
}
|
|
1568
|
+
function applyThemeCssVariables(variables, targets) {
|
|
1569
|
+
const previousValues = /* @__PURE__ */ new Map();
|
|
1570
|
+
for (const element of targets) {
|
|
1571
|
+
const elementPreviousValues = /* @__PURE__ */ new Map();
|
|
1572
|
+
for (const [property, value] of Object.entries(variables)) {
|
|
1573
|
+
elementPreviousValues.set(property, element.style.getPropertyValue(property));
|
|
1574
|
+
element.style.setProperty(property, value);
|
|
1575
|
+
}
|
|
1576
|
+
previousValues.set(element, elementPreviousValues);
|
|
1577
|
+
}
|
|
1578
|
+
return () => {
|
|
1579
|
+
for (const [element, elementPreviousValues] of previousValues) for (const [property, previousValue] of elementPreviousValues) if (previousValue) element.style.setProperty(property, previousValue);
|
|
1580
|
+
else element.style.removeProperty(property);
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
//#endregion
|
|
1289
1584
|
//#region source/theme/ThemeEditor.tsx
|
|
1290
1585
|
var colorTokenFields = [
|
|
1291
1586
|
{
|
|
@@ -1343,18 +1638,24 @@ var layoutFields = [{
|
|
|
1343
1638
|
key: "maxWidth",
|
|
1344
1639
|
label: "Max width"
|
|
1345
1640
|
}];
|
|
1346
|
-
var
|
|
1347
|
-
function
|
|
1348
|
-
return
|
|
1641
|
+
var themeEditorPresets = themePresets;
|
|
1642
|
+
function applyThemeVariables(theme, target) {
|
|
1643
|
+
return applyThemeCssVariables(themeToCssVariables(theme), resolveThemeVariableTargets(target));
|
|
1349
1644
|
}
|
|
1350
1645
|
function isHexColor(value) {
|
|
1351
1646
|
return /^#[0-9a-f]{6}$/i.test(value);
|
|
1352
1647
|
}
|
|
1353
|
-
function updateThemeModeColorValue(value,
|
|
1354
|
-
if (typeof value === "string") return
|
|
1648
|
+
function updateThemeModeColorValue(value, mode, nextValue) {
|
|
1649
|
+
if (typeof value === "string") return mode === "light" ? {
|
|
1650
|
+
light: nextValue,
|
|
1651
|
+
dark: value
|
|
1652
|
+
} : {
|
|
1653
|
+
light: value,
|
|
1654
|
+
dark: nextValue
|
|
1655
|
+
};
|
|
1355
1656
|
return {
|
|
1356
1657
|
...value,
|
|
1357
|
-
[
|
|
1658
|
+
[mode]: nextValue
|
|
1358
1659
|
};
|
|
1359
1660
|
}
|
|
1360
1661
|
function TextField(props) {
|
|
@@ -1387,6 +1688,61 @@ function TextField(props) {
|
|
|
1387
1688
|
})]
|
|
1388
1689
|
});
|
|
1389
1690
|
}
|
|
1691
|
+
function ColorField(props) {
|
|
1692
|
+
const { id, label, value, onChange } = props;
|
|
1693
|
+
const lightValue = resolveThemeColorValue(value, "light");
|
|
1694
|
+
const darkValue = resolveThemeColorValue(value, "dark");
|
|
1695
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1696
|
+
className: "grid min-w-0 gap-1.5",
|
|
1697
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1698
|
+
className: "text-xs/5 font-medium text-(--clarify-ui-text)",
|
|
1699
|
+
children: label
|
|
1700
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1701
|
+
className: "grid grid-cols-2 gap-2",
|
|
1702
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorModeInput, {
|
|
1703
|
+
id: `${id}-light`,
|
|
1704
|
+
mode: "light",
|
|
1705
|
+
value: lightValue,
|
|
1706
|
+
onChange: (v) => onChange("light", v)
|
|
1707
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorModeInput, {
|
|
1708
|
+
id: `${id}-dark`,
|
|
1709
|
+
mode: "dark",
|
|
1710
|
+
value: darkValue,
|
|
1711
|
+
onChange: (v) => onChange("dark", v)
|
|
1712
|
+
})]
|
|
1713
|
+
})]
|
|
1714
|
+
});
|
|
1715
|
+
}
|
|
1716
|
+
function ColorModeInput(props) {
|
|
1717
|
+
const { id, mode, value, onChange } = props;
|
|
1718
|
+
const canUseColorInput = isHexColor(value);
|
|
1719
|
+
function handleTextChange(event) {
|
|
1720
|
+
onChange(event.target.value);
|
|
1721
|
+
}
|
|
1722
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1723
|
+
htmlFor: id,
|
|
1724
|
+
className: "grid min-w-0 gap-1 text-[11px]/4 font-medium text-(--clarify-ui-text-faint)",
|
|
1725
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1726
|
+
className: "flex min-w-0 items-center justify-between gap-2",
|
|
1727
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1728
|
+
className: "uppercase tracking-wide",
|
|
1729
|
+
children: mode
|
|
1730
|
+
}), canUseColorInput ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1731
|
+
type: "color",
|
|
1732
|
+
value,
|
|
1733
|
+
"aria-label": `${id} color`,
|
|
1734
|
+
className: "h-4 w-6 shrink-0 cursor-pointer rounded border border-(--clarify-theme-tokens-colors-border) bg-transparent p-0",
|
|
1735
|
+
onChange: handleTextChange
|
|
1736
|
+
}) : null]
|
|
1737
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1738
|
+
id,
|
|
1739
|
+
value,
|
|
1740
|
+
spellCheck: false,
|
|
1741
|
+
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)",
|
|
1742
|
+
onChange: handleTextChange
|
|
1743
|
+
})]
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1390
1746
|
function themeToConfigSource(theme) {
|
|
1391
1747
|
return JSON.stringify({ theme: {
|
|
1392
1748
|
preset: theme.preset,
|
|
@@ -1396,12 +1752,12 @@ function themeToConfigSource(theme) {
|
|
|
1396
1752
|
}
|
|
1397
1753
|
function ThemeEditor(props) {
|
|
1398
1754
|
const { initialTheme, onChange, target, defaultOpen = false, className } = props;
|
|
1399
|
-
const { resolvedTheme } =
|
|
1755
|
+
const { resolvedTheme } = require_PageActions.useTheme();
|
|
1400
1756
|
const [isOpen, setIsOpen] = (0, react.useState)(defaultOpen);
|
|
1401
|
-
const [theme, setTheme] = (0, react.useState)(() =>
|
|
1757
|
+
const [theme, setTheme] = (0, react.useState)(() => cloneTheme(initialTheme ?? themeEditorPresets.default));
|
|
1402
1758
|
const [copyState, setCopyState] = (0, react.useState)("idle");
|
|
1403
1759
|
const configSource = (0, react.useMemo)(() => themeToConfigSource(theme), [theme]);
|
|
1404
|
-
(0, react.useEffect)(() =>
|
|
1760
|
+
(0, react.useEffect)(() => applyThemeCssVariables(themeToCssVariables(theme, resolvedTheme), resolveThemeVariableTargets(target)), [
|
|
1405
1761
|
resolvedTheme,
|
|
1406
1762
|
target,
|
|
1407
1763
|
theme
|
|
@@ -1411,16 +1767,16 @@ function ThemeEditor(props) {
|
|
|
1411
1767
|
onChange?.(nextTheme);
|
|
1412
1768
|
}
|
|
1413
1769
|
function updatePreset(nextPreset) {
|
|
1414
|
-
commit(
|
|
1770
|
+
commit(cloneTheme(themeEditorPresets[nextPreset]));
|
|
1415
1771
|
}
|
|
1416
|
-
function updateColorToken(key, value) {
|
|
1772
|
+
function updateColorToken(key, mode, value) {
|
|
1417
1773
|
commit({
|
|
1418
1774
|
...theme,
|
|
1419
1775
|
tokens: {
|
|
1420
1776
|
...theme.tokens,
|
|
1421
1777
|
colors: {
|
|
1422
1778
|
...theme.tokens.colors,
|
|
1423
|
-
[key]: updateThemeModeColorValue(theme.tokens.colors[key],
|
|
1779
|
+
[key]: updateThemeModeColorValue(theme.tokens.colors[key], mode, value)
|
|
1424
1780
|
}
|
|
1425
1781
|
}
|
|
1426
1782
|
});
|
|
@@ -1510,12 +1866,11 @@ function ThemeEditor(props) {
|
|
|
1510
1866
|
children: "Colors"
|
|
1511
1867
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1512
1868
|
className: "grid grid-cols-1 gap-3",
|
|
1513
|
-
children: colorTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1869
|
+
children: colorTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorField, {
|
|
1514
1870
|
id: `clarify-theme-editor-color-${field.key}`,
|
|
1515
1871
|
label: field.label,
|
|
1516
|
-
value:
|
|
1517
|
-
|
|
1518
|
-
onChange: (value) => updateColorToken(field.key, value)
|
|
1872
|
+
value: theme.tokens.colors[field.key],
|
|
1873
|
+
onChange: (mode, value) => updateColorToken(field.key, mode, value)
|
|
1519
1874
|
}, field.key))
|
|
1520
1875
|
})]
|
|
1521
1876
|
}),
|
|
@@ -1586,13 +1941,12 @@ function ThemeEditor(props) {
|
|
|
1586
1941
|
//#region source/theme/ThemeRoot.tsx
|
|
1587
1942
|
function ThemeRoot(props) {
|
|
1588
1943
|
const { children, theme, themeEditor = false } = props;
|
|
1589
|
-
const { resolvedTheme } =
|
|
1590
|
-
const themeVariables = (0, react.useMemo)(() =>
|
|
1591
|
-
(0, react.useEffect)(() =>
|
|
1944
|
+
const { resolvedTheme } = require_PageActions.useTheme();
|
|
1945
|
+
const themeVariables = (0, react.useMemo)(() => themeToCssVariables(theme, resolvedTheme), [resolvedTheme, theme]);
|
|
1946
|
+
(0, react.useEffect)(() => applyThemeCssVariables(themeVariables, resolveThemeVariableTargets(":root")), [themeVariables]);
|
|
1592
1947
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1593
1948
|
className: "clarify-app h-full min-h-screen bg-(--clarify-theme-tokens-colors-background) text-(--clarify-theme-tokens-colors-foreground)",
|
|
1594
1949
|
"data-theme-preset": theme.preset,
|
|
1595
|
-
style: themeVariables,
|
|
1596
1950
|
children: [children, themeEditor ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeEditor, { initialTheme: theme }) : null]
|
|
1597
1951
|
});
|
|
1598
1952
|
}
|
|
@@ -1609,6 +1963,12 @@ Object.defineProperty(exports, "BuiltWithClarify", {
|
|
|
1609
1963
|
return BuiltWithClarify;
|
|
1610
1964
|
}
|
|
1611
1965
|
});
|
|
1966
|
+
Object.defineProperty(exports, "PageBanner", {
|
|
1967
|
+
enumerable: true,
|
|
1968
|
+
get: function() {
|
|
1969
|
+
return PageBanner;
|
|
1970
|
+
}
|
|
1971
|
+
});
|
|
1612
1972
|
Object.defineProperty(exports, "PageFooter", {
|
|
1613
1973
|
enumerable: true,
|
|
1614
1974
|
get: function() {
|
|
@@ -1627,17 +1987,35 @@ Object.defineProperty(exports, "ThemeRoot", {
|
|
|
1627
1987
|
return ThemeRoot;
|
|
1628
1988
|
}
|
|
1629
1989
|
});
|
|
1630
|
-
Object.defineProperty(exports, "
|
|
1990
|
+
Object.defineProperty(exports, "applyThemeVariables", {
|
|
1991
|
+
enumerable: true,
|
|
1992
|
+
get: function() {
|
|
1993
|
+
return applyThemeVariables;
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
Object.defineProperty(exports, "themeBootstrapScript", {
|
|
1997
|
+
enumerable: true,
|
|
1998
|
+
get: function() {
|
|
1999
|
+
return themeBootstrapScript;
|
|
2000
|
+
}
|
|
2001
|
+
});
|
|
2002
|
+
Object.defineProperty(exports, "themeEditorPresets", {
|
|
2003
|
+
enumerable: true,
|
|
2004
|
+
get: function() {
|
|
2005
|
+
return themeEditorPresets;
|
|
2006
|
+
}
|
|
2007
|
+
});
|
|
2008
|
+
Object.defineProperty(exports, "themePresets", {
|
|
1631
2009
|
enumerable: true,
|
|
1632
2010
|
get: function() {
|
|
1633
|
-
return
|
|
2011
|
+
return themePresets;
|
|
1634
2012
|
}
|
|
1635
2013
|
});
|
|
1636
|
-
Object.defineProperty(exports, "
|
|
2014
|
+
Object.defineProperty(exports, "themeStorageKey", {
|
|
1637
2015
|
enumerable: true,
|
|
1638
2016
|
get: function() {
|
|
1639
|
-
return
|
|
2017
|
+
return themeStorageKey;
|
|
1640
2018
|
}
|
|
1641
2019
|
});
|
|
1642
2020
|
|
|
1643
|
-
//# sourceMappingURL=ThemeRoot-
|
|
2021
|
+
//# sourceMappingURL=ThemeRoot-UWj0iK1X.cjs.map
|