@clarify-labs/renderer 0.6.7 → 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-CxQQyEHK.cjs → OpenApiOperation-C4xZu4i0.cjs} +154 -79
- package/output/OpenApiOperation-C4xZu4i0.cjs.map +1 -0
- package/output/{OpenApiOperation-CI_PeMSy.js → OpenApiOperation-LIL7bqxW.js} +129 -60
- package/output/OpenApiOperation-LIL7bqxW.js.map +1 -0
- package/output/{shell-D4tS8Jts.cjs → PageActions-1RDCHcUY.cjs} +597 -160
- package/output/PageActions-1RDCHcUY.cjs.map +1 -0
- package/output/{shell-DvTfFx6M.js → PageActions-yoDRjkq8.js} +531 -148
- package/output/PageActions-yoDRjkq8.js.map +1 -0
- package/output/{ThemeRoot-DErmHskn.js → ThemeRoot-CLa0yvRQ.js} +302 -106
- package/output/ThemeRoot-CLa0yvRQ.js.map +1 -0
- package/output/{ThemeRoot-BhP5M3Hd.cjs → ThemeRoot-DYS-lcK-.cjs} +349 -129
- package/output/ThemeRoot-DYS-lcK-.cjs.map +1 -0
- package/output/app/AppShell.d.ts +5 -2
- package/output/app/PageActions.d.ts +12 -0
- package/output/app/PageBanner.d.ts +7 -0
- package/output/app/PageFooter.d.ts +5 -1
- package/output/app/SectionProvider.d.ts +1 -0
- package/output/client.cjs +14 -4
- package/output/client.d.ts +4 -1
- package/output/client.js +4 -3
- package/output/components/LocalizedLink.d.ts +6 -0
- package/output/components/WebFrame.d.ts +11 -0
- package/output/components/index.d.ts +4 -0
- 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 +74 -59
- package/output/index.cjs +57 -28
- package/output/index.cjs.map +1 -1
- package/output/index.d.ts +9 -7
- 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 +3 -2
- package/output/preview.cjs +66 -28
- package/output/preview.cjs.map +1 -1
- package/output/preview.js +63 -25
- package/output/preview.js.map +1 -1
- package/output/{render-C_NHO3rz.cjs → render-CRTqZzyY.cjs} +10 -8
- package/output/render-CRTqZzyY.cjs.map +1 -0
- package/output/{render-HeCAMIGm.js → render-D0ls3d2j.js} +8 -6
- package/output/render-D0ls3d2j.js.map +1 -0
- package/output/renderer.css +575 -280
- package/output/server.cjs +10 -8
- package/output/server.cjs.map +1 -1
- package/output/server.js +7 -5
- 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/Search.d.ts +4 -0
- package/output/shell/SiteLogo.d.ts +2 -2
- package/output/shell/mobile.d.ts +2 -2
- package/output/shell/search/Highlight.d.ts +11 -0
- package/output/shell/search/SearchDialog.d.ts +13 -0
- package/output/shell/search/SearchInput.d.ts +8 -0
- package/output/shell/search/SearchResult.d.ts +10 -0
- package/output/shell/search/items.d.ts +3 -0
- package/output/shell/search/pagefind.d.ts +5 -0
- package/output/shell/search/types.d.ts +37 -0
- package/output/shell/search/useSearchProps.d.ts +10 -0
- 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 -18
- package/output/utils/href.d.ts +3 -3
- package/package.json +1 -1
- package/output/OpenApiOperation-CI_PeMSy.js.map +0 -1
- package/output/OpenApiOperation-CxQQyEHK.cjs.map +0 -1
- package/output/ThemeRoot-BhP5M3Hd.cjs.map +0 -1
- package/output/ThemeRoot-DErmHskn.js.map +0 -1
- package/output/render-C_NHO3rz.cjs.map +0 -1
- package/output/render-HeCAMIGm.js.map +0 -1
- package/output/shell-D4tS8Jts.cjs.map +0 -1
- package/output/shell-DvTfFx6M.js.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",
|
|
@@ -166,7 +246,7 @@ function BuiltWithClarify() {
|
|
|
166
246
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
|
|
167
247
|
src: clarify_default,
|
|
168
248
|
alt: "",
|
|
169
|
-
className: "clarify-built-with-logo h-3.5 w-
|
|
249
|
+
className: "clarify-built-with-logo h-3.5 w-auto flex-none object-contain"
|
|
170
250
|
}),
|
|
171
251
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
172
252
|
className: "clarify-built-with-brand font-semibold",
|
|
@@ -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", {
|
|
@@ -216,18 +296,23 @@ function SocialLink(arg0) {
|
|
|
216
296
|
children: name
|
|
217
297
|
});
|
|
218
298
|
}
|
|
219
|
-
function PageFooter() {
|
|
220
|
-
const config =
|
|
221
|
-
const locale = localeForPath
|
|
299
|
+
function PageFooter(props = {}) {
|
|
300
|
+
const config = require_PageActions.useConfig();
|
|
301
|
+
const locale = localeForPath(config, (0, react_router_dom.useLocation)().pathname);
|
|
222
302
|
const footer = config.footer;
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
303
|
+
const builtInFooter = footer && typeof footer === "object" ? footer : void 0;
|
|
304
|
+
const CustomFooter = props.component;
|
|
305
|
+
const links = builtInFooter?.links ?? [];
|
|
306
|
+
const socials = Object.entries(builtInFooter?.socials ?? {});
|
|
307
|
+
const copyright = builtInFooter?.copyright ? resolveLocalizedText(builtInFooter.copyright, locale, config.i18n?.defaultLocale) : void 0;
|
|
308
|
+
const hasBuiltInFooter = Boolean(copyright || links.length > 0 || socials.length > 0);
|
|
227
309
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", {
|
|
228
|
-
className:
|
|
229
|
-
children: [
|
|
230
|
-
className: "clarify-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",
|
|
311
|
+
children: [CustomFooter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
312
|
+
className: "clarify-footer-custom w-full",
|
|
313
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CustomFooter, {})
|
|
314
|
+
}) : hasBuiltInFooter ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
315
|
+
className: (0, clsx.default)("clarify-footer-content flex flex-col items-end gap-3 text-right", hasBuiltInFooter && "sm:items-start sm:text-left"),
|
|
231
316
|
children: [copyright ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
232
317
|
className: "clarify-footer-copyright m-0",
|
|
233
318
|
children: copyright
|
|
@@ -243,7 +328,7 @@ function PageFooter() {
|
|
|
243
328
|
}, name))]
|
|
244
329
|
}) : null]
|
|
245
330
|
}) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
246
|
-
className: "clarify-footer-brand flex justify-end",
|
|
331
|
+
className: "clarify-footer-brand flex justify-end self-end",
|
|
247
332
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BuiltWithClarify, {})
|
|
248
333
|
})]
|
|
249
334
|
});
|
|
@@ -255,10 +340,10 @@ function flattenNavigation(nodes) {
|
|
|
255
340
|
}
|
|
256
341
|
function PageNavigation(arg0) {
|
|
257
342
|
const { navigation, currentRoute } = arg0;
|
|
258
|
-
const t =
|
|
343
|
+
const t = require_PageActions.useBuiltInText();
|
|
259
344
|
if (!currentRoute) return null;
|
|
260
345
|
const pageRoutes = flattenNavigation(navigation);
|
|
261
|
-
const currentIndex = pageRoutes.findIndex((route) =>
|
|
346
|
+
const currentIndex = pageRoutes.findIndex((route) => require_PageActions.isSameRoutePath(route.path, currentRoute.path));
|
|
262
347
|
if (currentIndex === -1) return null;
|
|
263
348
|
const previous = pageRoutes[currentIndex - 1];
|
|
264
349
|
const next = pageRoutes[currentIndex + 1];
|
|
@@ -277,11 +362,11 @@ function PageNavigation(arg0) {
|
|
|
277
362
|
}
|
|
278
363
|
function PageNavigationLink(arg0) {
|
|
279
364
|
const { direction, route } = arg0;
|
|
280
|
-
const t =
|
|
365
|
+
const t = require_PageActions.useBuiltInText();
|
|
281
366
|
if (!route) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "hidden @3xl:block" });
|
|
282
367
|
const isNext = direction === "next";
|
|
283
368
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_router_dom.Link, {
|
|
284
|
-
to:
|
|
369
|
+
to: require_PageActions.normalizeRoutePath(route.path),
|
|
285
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"),
|
|
286
371
|
children: [
|
|
287
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,
|
|
@@ -405,17 +490,18 @@ function PageSkeleton() {
|
|
|
405
490
|
//#endregion
|
|
406
491
|
//#region source/app/AppShell.tsx
|
|
407
492
|
function routeForPath(routes, pathname) {
|
|
408
|
-
return routes.find((route) =>
|
|
493
|
+
return routes.find((route) => require_PageActions.isSameRoutePath(route.path, pathname));
|
|
409
494
|
}
|
|
410
495
|
function notFoundRouteForPath(routes, pathname, currentLocale) {
|
|
411
496
|
const localePrefix = currentLocale ? `/${currentLocale}` : void 0;
|
|
412
497
|
if (localePrefix && pathname.startsWith(`${localePrefix}/`)) return routeForPath(routes, `${localePrefix}/404`);
|
|
413
|
-
return routeForPath(routes, "/404") ?? routes.find((route) =>
|
|
498
|
+
return routeForPath(routes, "/404") ?? routes.find((route) => require_PageActions.isSameRoutePath(route.basePath, "/404"));
|
|
414
499
|
}
|
|
415
500
|
function sectionsForRoute(route) {
|
|
416
501
|
return route?.sections?.map((section) => ({
|
|
417
502
|
id: section.id,
|
|
418
503
|
title: section.title,
|
|
504
|
+
level: section.level,
|
|
419
505
|
badge: section.badge,
|
|
420
506
|
tags: section.tags
|
|
421
507
|
})) ?? [];
|
|
@@ -426,7 +512,7 @@ function resolveRouteComponent(route) {
|
|
|
426
512
|
}
|
|
427
513
|
function scrollToHash(hash) {
|
|
428
514
|
if (!hash) return;
|
|
429
|
-
const targetId =
|
|
515
|
+
const targetId = require_PageActions.safeDecodeURIComponent(hash.slice(1));
|
|
430
516
|
window.requestAnimationFrame(() => {
|
|
431
517
|
document.getElementById(targetId)?.scrollIntoView();
|
|
432
518
|
window.requestAnimationFrame(() => {
|
|
@@ -434,22 +520,30 @@ function scrollToHash(hash) {
|
|
|
434
520
|
});
|
|
435
521
|
});
|
|
436
522
|
}
|
|
437
|
-
function
|
|
438
|
-
if (route?.locale) return route.locale;
|
|
523
|
+
function explicitLocaleForPath(config, pathname) {
|
|
439
524
|
const i18n = config.i18n;
|
|
440
525
|
if (!i18n) return void 0;
|
|
441
526
|
const firstSegment = pathname.split("/").filter(Boolean)[0];
|
|
442
|
-
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);
|
|
443
537
|
}
|
|
444
538
|
function isTabbedNavigation(navigation) {
|
|
445
539
|
return !Array.isArray(navigation) && "tabs" in navigation;
|
|
446
540
|
}
|
|
447
541
|
function hasPath(nodes, pathname) {
|
|
448
|
-
return nodes.some((node) =>
|
|
542
|
+
return nodes.some((node) => require_PageActions.isSameRoutePath(node.path, pathname) || hasPath(node.children ?? [], pathname));
|
|
449
543
|
}
|
|
450
544
|
function navigationFromTabs(navigation, pathname) {
|
|
451
545
|
return {
|
|
452
|
-
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 ?? [],
|
|
453
547
|
tabs: navigation.tabs
|
|
454
548
|
};
|
|
455
549
|
}
|
|
@@ -483,7 +577,7 @@ function applyDocumentMetadata(config, route) {
|
|
|
483
577
|
setNamedMeta("keywords", route?.keywords?.join(", "));
|
|
484
578
|
}
|
|
485
579
|
function BuiltInNotFoundPage() {
|
|
486
|
-
const text =
|
|
580
|
+
const text = require_PageActions.useBuiltInText();
|
|
487
581
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
488
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)",
|
|
489
583
|
"aria-labelledby": "clarify-not-found-title",
|
|
@@ -518,22 +612,46 @@ function NotFoundRouteElement(props) {
|
|
|
518
612
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RouteComponent, {});
|
|
519
613
|
}
|
|
520
614
|
function AppShell(arg0) {
|
|
521
|
-
const { config, routes, navigation } = arg0;
|
|
615
|
+
const { config, routes, navigation, bannerComponent, footerComponent } = arg0;
|
|
522
616
|
const location = (0, react_router_dom.useLocation)();
|
|
523
|
-
const
|
|
617
|
+
const navigate = (0, react_router_dom.useNavigate)();
|
|
618
|
+
const pathname = require_PageActions.normalizeRoutePath(location.pathname);
|
|
524
619
|
const currentRoute = routeForPath(routes, pathname);
|
|
525
|
-
const
|
|
620
|
+
const explicitLocale = explicitLocaleForPath(config, pathname);
|
|
621
|
+
const [storedLocale] = (0, react.useState)(() => storedLocaleForConfig(config));
|
|
622
|
+
const currentLocale = explicitLocale ?? storedLocale ?? fallbackLocale(config);
|
|
526
623
|
const currentLocaleConfig = config.i18n?.locales.find((locale) => locale.code === currentLocale);
|
|
527
624
|
const notFoundRoute = currentRoute ? void 0 : notFoundRouteForPath(routes, pathname, currentLocale);
|
|
528
|
-
const text =
|
|
625
|
+
const text = require_PageActions.useBuiltInText(currentLocale);
|
|
529
626
|
const currentNavigation = navigationForLocale(navigation, currentLocale, pathname);
|
|
530
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;
|
|
531
631
|
const hasTabs = Boolean(currentNavigation.tabs?.length);
|
|
532
632
|
const renderRoutes = (0, react.useMemo)(() => routes.map((route) => ({
|
|
533
633
|
...route,
|
|
534
634
|
component: resolveRouteComponent(route)
|
|
535
635
|
})), [routes]);
|
|
536
|
-
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
|
+
]);
|
|
537
655
|
(0, react.useEffect)(() => {
|
|
538
656
|
if (location.hash) {
|
|
539
657
|
scrollToHash(location.hash);
|
|
@@ -560,34 +678,40 @@ function AppShell(arg0) {
|
|
|
560
678
|
currentRoute,
|
|
561
679
|
notFoundRoute
|
|
562
680
|
]);
|
|
563
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
681
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PageActions.LocaleContext.Provider, {
|
|
564
682
|
value: currentLocale,
|
|
565
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
683
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_PageActions.SectionProvider, {
|
|
566
684
|
sections,
|
|
567
|
-
children: [
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
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,
|
|
573
694
|
currentLocale,
|
|
574
|
-
|
|
575
|
-
})
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
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
|
+
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,
|
|
583
711
|
children: [
|
|
584
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_shell.ContentActions, {
|
|
585
|
-
hasTabs,
|
|
586
|
-
route: currentRoute,
|
|
587
|
-
routePrefix: config.routePrefix
|
|
588
|
-
}),
|
|
589
712
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("main", {
|
|
590
713
|
className: "clarify-main min-w-0 flex-auto",
|
|
714
|
+
"data-pagefind-body": true,
|
|
591
715
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageErrorBoundary, {
|
|
592
716
|
title: text("renderError.title"),
|
|
593
717
|
description: text("renderError.description"),
|
|
@@ -617,12 +741,12 @@ function AppShell(arg0) {
|
|
|
617
741
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageNavigation, {
|
|
618
742
|
navigation: currentNavigation.items,
|
|
619
743
|
currentRoute
|
|
620
|
-
})
|
|
744
|
+
}),
|
|
745
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PageFooter, { component: footerComponent })
|
|
621
746
|
]
|
|
622
|
-
})
|
|
623
|
-
})
|
|
624
|
-
|
|
625
|
-
]
|
|
747
|
+
})
|
|
748
|
+
})]
|
|
749
|
+
})]
|
|
626
750
|
})
|
|
627
751
|
});
|
|
628
752
|
}
|
|
@@ -1280,19 +1404,38 @@ function createRandomTheme() {
|
|
|
1280
1404
|
}
|
|
1281
1405
|
//#endregion
|
|
1282
1406
|
//#region source/theme/variables.ts
|
|
1283
|
-
var
|
|
1407
|
+
var themeStorageKey = require_PageActions.themeCookieName;
|
|
1408
|
+
var themePresets = {
|
|
1284
1409
|
default: {
|
|
1285
1410
|
preset: "default",
|
|
1286
1411
|
tokens: {
|
|
1287
1412
|
colors: {
|
|
1288
1413
|
primary: "#047857",
|
|
1289
1414
|
accent: "#0D9488",
|
|
1290
|
-
background:
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
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
|
+
}
|
|
1296
1439
|
},
|
|
1297
1440
|
radius: {
|
|
1298
1441
|
sm: "6px",
|
|
@@ -1310,12 +1453,30 @@ var clarifyThemePresets = {
|
|
|
1310
1453
|
colors: {
|
|
1311
1454
|
primary: "#18181b",
|
|
1312
1455
|
accent: "#52525b",
|
|
1313
|
-
background:
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
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
|
+
}
|
|
1319
1480
|
},
|
|
1320
1481
|
radius: {
|
|
1321
1482
|
sm: "6px",
|
|
@@ -1370,38 +1531,9 @@ function resolveThemeColors(colors, resolvedTheme = "light") {
|
|
|
1370
1531
|
codeBackground: resolveThemeColorValue(colors.codeBackground, resolvedTheme)
|
|
1371
1532
|
};
|
|
1372
1533
|
}
|
|
1373
|
-
function matchesPresetTheme(theme) {
|
|
1374
|
-
const preset = clarifyThemePresets[theme.preset];
|
|
1375
|
-
return JSON.stringify({
|
|
1376
|
-
tokens: theme.tokens,
|
|
1377
|
-
layout: theme.layout
|
|
1378
|
-
}) === JSON.stringify({
|
|
1379
|
-
tokens: preset.tokens,
|
|
1380
|
-
layout: preset.layout
|
|
1381
|
-
});
|
|
1382
|
-
}
|
|
1383
|
-
function effectiveTheme(theme, resolvedTheme) {
|
|
1384
|
-
if (resolvedTheme !== "dark" || !matchesPresetTheme(theme)) return theme;
|
|
1385
|
-
return {
|
|
1386
|
-
...theme,
|
|
1387
|
-
tokens: {
|
|
1388
|
-
...theme.tokens,
|
|
1389
|
-
colors: {
|
|
1390
|
-
...theme.tokens.colors,
|
|
1391
|
-
background: "#09090b",
|
|
1392
|
-
foreground: "#ffffff",
|
|
1393
|
-
surface: "#18181b",
|
|
1394
|
-
muted: "#a1a1aa",
|
|
1395
|
-
border: "rgb(255 255 255 / 0.1)",
|
|
1396
|
-
codeBackground: "#18181b"
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
};
|
|
1400
|
-
}
|
|
1401
1534
|
function themeToCssVariables(theme, resolvedTheme) {
|
|
1402
|
-
const
|
|
1403
|
-
const
|
|
1404
|
-
const { radius } = resolved.tokens;
|
|
1535
|
+
const colors = resolveThemeColors(theme.tokens.colors, resolvedTheme);
|
|
1536
|
+
const { radius } = theme.tokens;
|
|
1405
1537
|
return {
|
|
1406
1538
|
"--clarify-theme-tokens-colors-primary": colors.primary,
|
|
1407
1539
|
"--clarify-theme-tokens-colors-accent": colors.accent,
|
|
@@ -1415,9 +1547,14 @@ function themeToCssVariables(theme, resolvedTheme) {
|
|
|
1415
1547
|
"--clarify-theme-tokens-radius-md": radius.md,
|
|
1416
1548
|
"--clarify-theme-tokens-radius-lg": radius.lg,
|
|
1417
1549
|
"--clarify-theme-tokens-radius-xl": radius.xl,
|
|
1418
|
-
"--clarify-theme-layout-max-width":
|
|
1550
|
+
"--clarify-theme-layout-max-width": theme.layout.maxWidth
|
|
1419
1551
|
};
|
|
1420
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
|
+
}
|
|
1421
1558
|
function uniqueElements(elements) {
|
|
1422
1559
|
return Array.from(new Set(elements));
|
|
1423
1560
|
}
|
|
@@ -1500,18 +1637,24 @@ var layoutFields = [{
|
|
|
1500
1637
|
key: "maxWidth",
|
|
1501
1638
|
label: "Max width"
|
|
1502
1639
|
}];
|
|
1503
|
-
var
|
|
1504
|
-
function
|
|
1640
|
+
var themeEditorPresets = themePresets;
|
|
1641
|
+
function applyThemeVariables(theme, target) {
|
|
1505
1642
|
return applyThemeCssVariables(themeToCssVariables(theme), resolveThemeVariableTargets(target));
|
|
1506
1643
|
}
|
|
1507
1644
|
function isHexColor(value) {
|
|
1508
1645
|
return /^#[0-9a-f]{6}$/i.test(value);
|
|
1509
1646
|
}
|
|
1510
|
-
function updateThemeModeColorValue(value,
|
|
1511
|
-
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
|
+
};
|
|
1512
1655
|
return {
|
|
1513
1656
|
...value,
|
|
1514
|
-
[
|
|
1657
|
+
[mode]: nextValue
|
|
1515
1658
|
};
|
|
1516
1659
|
}
|
|
1517
1660
|
function TextField(props) {
|
|
@@ -1544,6 +1687,61 @@ function TextField(props) {
|
|
|
1544
1687
|
})]
|
|
1545
1688
|
});
|
|
1546
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
|
+
}
|
|
1547
1745
|
function themeToConfigSource(theme) {
|
|
1548
1746
|
return JSON.stringify({ theme: {
|
|
1549
1747
|
preset: theme.preset,
|
|
@@ -1553,9 +1751,9 @@ function themeToConfigSource(theme) {
|
|
|
1553
1751
|
}
|
|
1554
1752
|
function ThemeEditor(props) {
|
|
1555
1753
|
const { initialTheme, onChange, target, defaultOpen = false, className } = props;
|
|
1556
|
-
const { resolvedTheme } =
|
|
1754
|
+
const { resolvedTheme } = require_PageActions.useTheme();
|
|
1557
1755
|
const [isOpen, setIsOpen] = (0, react.useState)(defaultOpen);
|
|
1558
|
-
const [theme, setTheme] = (0, react.useState)(() => cloneTheme(initialTheme ??
|
|
1756
|
+
const [theme, setTheme] = (0, react.useState)(() => cloneTheme(initialTheme ?? themeEditorPresets.default));
|
|
1559
1757
|
const [copyState, setCopyState] = (0, react.useState)("idle");
|
|
1560
1758
|
const configSource = (0, react.useMemo)(() => themeToConfigSource(theme), [theme]);
|
|
1561
1759
|
(0, react.useEffect)(() => applyThemeCssVariables(themeToCssVariables(theme, resolvedTheme), resolveThemeVariableTargets(target)), [
|
|
@@ -1568,16 +1766,16 @@ function ThemeEditor(props) {
|
|
|
1568
1766
|
onChange?.(nextTheme);
|
|
1569
1767
|
}
|
|
1570
1768
|
function updatePreset(nextPreset) {
|
|
1571
|
-
commit(cloneTheme(
|
|
1769
|
+
commit(cloneTheme(themeEditorPresets[nextPreset]));
|
|
1572
1770
|
}
|
|
1573
|
-
function updateColorToken(key, value) {
|
|
1771
|
+
function updateColorToken(key, mode, value) {
|
|
1574
1772
|
commit({
|
|
1575
1773
|
...theme,
|
|
1576
1774
|
tokens: {
|
|
1577
1775
|
...theme.tokens,
|
|
1578
1776
|
colors: {
|
|
1579
1777
|
...theme.tokens.colors,
|
|
1580
|
-
[key]: updateThemeModeColorValue(theme.tokens.colors[key],
|
|
1778
|
+
[key]: updateThemeModeColorValue(theme.tokens.colors[key], mode, value)
|
|
1581
1779
|
}
|
|
1582
1780
|
}
|
|
1583
1781
|
});
|
|
@@ -1667,12 +1865,11 @@ function ThemeEditor(props) {
|
|
|
1667
1865
|
children: "Colors"
|
|
1668
1866
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1669
1867
|
className: "grid grid-cols-1 gap-3",
|
|
1670
|
-
children: colorTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
1868
|
+
children: colorTokenFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ColorField, {
|
|
1671
1869
|
id: `clarify-theme-editor-color-${field.key}`,
|
|
1672
1870
|
label: field.label,
|
|
1673
|
-
value:
|
|
1674
|
-
|
|
1675
|
-
onChange: (value) => updateColorToken(field.key, value)
|
|
1871
|
+
value: theme.tokens.colors[field.key],
|
|
1872
|
+
onChange: (mode, value) => updateColorToken(field.key, mode, value)
|
|
1676
1873
|
}, field.key))
|
|
1677
1874
|
})]
|
|
1678
1875
|
}),
|
|
@@ -1743,13 +1940,12 @@ function ThemeEditor(props) {
|
|
|
1743
1940
|
//#region source/theme/ThemeRoot.tsx
|
|
1744
1941
|
function ThemeRoot(props) {
|
|
1745
1942
|
const { children, theme, themeEditor = false } = props;
|
|
1746
|
-
const { resolvedTheme } =
|
|
1943
|
+
const { resolvedTheme } = require_PageActions.useTheme();
|
|
1747
1944
|
const themeVariables = (0, react.useMemo)(() => themeToCssVariables(theme, resolvedTheme), [resolvedTheme, theme]);
|
|
1748
1945
|
(0, react.useEffect)(() => applyThemeCssVariables(themeVariables, resolveThemeVariableTargets(":root")), [themeVariables]);
|
|
1749
1946
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1750
1947
|
className: "clarify-app h-full min-h-screen bg-(--clarify-theme-tokens-colors-background) text-(--clarify-theme-tokens-colors-foreground)",
|
|
1751
1948
|
"data-theme-preset": theme.preset,
|
|
1752
|
-
style: themeVariables,
|
|
1753
1949
|
children: [children, themeEditor ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThemeEditor, { initialTheme: theme }) : null]
|
|
1754
1950
|
});
|
|
1755
1951
|
}
|
|
@@ -1766,6 +1962,12 @@ Object.defineProperty(exports, "BuiltWithClarify", {
|
|
|
1766
1962
|
return BuiltWithClarify;
|
|
1767
1963
|
}
|
|
1768
1964
|
});
|
|
1965
|
+
Object.defineProperty(exports, "PageBanner", {
|
|
1966
|
+
enumerable: true,
|
|
1967
|
+
get: function() {
|
|
1968
|
+
return PageBanner;
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1769
1971
|
Object.defineProperty(exports, "PageFooter", {
|
|
1770
1972
|
enumerable: true,
|
|
1771
1973
|
get: function() {
|
|
@@ -1784,17 +1986,35 @@ Object.defineProperty(exports, "ThemeRoot", {
|
|
|
1784
1986
|
return ThemeRoot;
|
|
1785
1987
|
}
|
|
1786
1988
|
});
|
|
1787
|
-
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", {
|
|
1788
2008
|
enumerable: true,
|
|
1789
2009
|
get: function() {
|
|
1790
|
-
return
|
|
2010
|
+
return themePresets;
|
|
1791
2011
|
}
|
|
1792
2012
|
});
|
|
1793
|
-
Object.defineProperty(exports, "
|
|
2013
|
+
Object.defineProperty(exports, "themeStorageKey", {
|
|
1794
2014
|
enumerable: true,
|
|
1795
2015
|
get: function() {
|
|
1796
|
-
return
|
|
2016
|
+
return themeStorageKey;
|
|
1797
2017
|
}
|
|
1798
2018
|
});
|
|
1799
2019
|
|
|
1800
|
-
//# sourceMappingURL=ThemeRoot-
|
|
2020
|
+
//# sourceMappingURL=ThemeRoot-DYS-lcK-.cjs.map
|