@xyd-js/themes 0.0.0 → 0.1.1-build.160

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,669 @@
1
+ // src/BaseTheme.tsx
2
+ import * as React2 from "react";
3
+ import { useLocation } from "react-router";
4
+ import GitHubButton from "react-github-btn";
5
+ import { UXNode } from "openux-js";
6
+ import {
7
+ TocCard,
8
+ Text,
9
+ VideoGuide,
10
+ useColorScheme,
11
+ IconSocial as IconSocial2
12
+ } from "@xyd-js/components/writer";
13
+ import { ContentDecorator } from "@xyd-js/components/content";
14
+ import {
15
+ LayoutPrimary
16
+ } from "@xyd-js/components/layouts";
17
+ import { Footer } from "@xyd-js/components/system";
18
+ import {
19
+ FwNav,
20
+ FwNavLinks,
21
+ FwToc,
22
+ FwSubNav,
23
+ FwSidebar,
24
+ FwJsonComponent,
25
+ FwLogo,
26
+ useMatchedSubNav,
27
+ useActiveRoute,
28
+ useActivePageRoute,
29
+ useMetadata as useMetadata2,
30
+ useSettings,
31
+ FwBanner,
32
+ useAppearance,
33
+ useContentComponent,
34
+ FwCopyPage,
35
+ FwBreadcrumbs
36
+ } from "@xyd-js/framework/react";
37
+
38
+ // src/Theme.tsx
39
+ import * as React from "react";
40
+ import { IconSocial } from "@xyd-js/components/writer";
41
+ import { useMetadata } from "@xyd-js/framework/react";
42
+ var Theme = class {
43
+ constructor() {
44
+ this.settings = globalThis.__xydThemeSettings;
45
+ this.useHideToc = this.useHideToc.bind(this);
46
+ this.useHideSidebar = this.useHideSidebar.bind(this);
47
+ this.appearanceWebEditor = this.appearanceWebEditor.bind(this);
48
+ this.headerPrepend = this.headerPrepend.bind(this);
49
+ this.mergeUserAppearance = this.mergeUserAppearance.bind(this);
50
+ this.resetWebeditor = this.resetWebeditor.bind(this);
51
+ globalThis.__xydThemeSettings.Update = this.update.bind(this);
52
+ globalThis.__xydThemeSettings.UpdatePreset = this.updateThemePreset.bind(this);
53
+ this.theme = globalThis.__xydThemeSettings;
54
+ this.surfaces = globalThis.__xydSurfaces;
55
+ this.reactContent = globalThis.__xydReactContent;
56
+ this.navigation = globalThis.__xydNavigation;
57
+ this.webeditor = globalThis.__xydWebeditor;
58
+ this.userPreferences = globalThis.__xydUserPreferences;
59
+ this.userAppearance = JSON.parse(JSON.stringify(this.theme.appearance || {}));
60
+ this.appearanceWebEditor();
61
+ }
62
+ get originalTheme() {
63
+ var _a;
64
+ return JSON.parse(JSON.stringify((_a = globalThis.__xydSettingsClone) == null ? void 0 : _a.theme));
65
+ }
66
+ get originalWebeditor() {
67
+ var _a;
68
+ return JSON.parse(JSON.stringify((_a = globalThis.__xydSettingsClone) == null ? void 0 : _a.webeditor));
69
+ }
70
+ get originalNavigation() {
71
+ var _a;
72
+ return JSON.parse(JSON.stringify((_a = globalThis.__xydSettingsClone) == null ? void 0 : _a.navigation));
73
+ }
74
+ useHideToc() {
75
+ const meta = useMetadata();
76
+ return (meta == null ? void 0 : meta.layout) === "wide" || (meta == null ? void 0 : meta.layout) === "reader" || (meta == null ? void 0 : meta.layout) === "page";
77
+ }
78
+ useHideSidebar() {
79
+ const meta = useMetadata();
80
+ return (meta == null ? void 0 : meta.layout) === "page" || (meta == null ? void 0 : meta.layout) === "reader";
81
+ }
82
+ headerPrepend(searchItem, float) {
83
+ const header = this.webeditor.header || [];
84
+ const insertIndex = header.findIndex((item) => item.float === float);
85
+ return insertIndex === -1 ? [...header, searchItem] : [...header.slice(0, insertIndex), searchItem, ...header.slice(insertIndex)];
86
+ }
87
+ headerAppend(searchItem, float = "") {
88
+ const header = this.webeditor.header || [];
89
+ const insertIndex = header.findIndex((item) => item.float === float);
90
+ return insertIndex === -1 ? [...header, searchItem] : [...header.slice(0, insertIndex + 1), searchItem, ...header.slice(insertIndex + 1)];
91
+ }
92
+ update(patch) {
93
+ deepMerge(this.theme, patch);
94
+ this.appearanceWebEditor();
95
+ }
96
+ updateThemePreset(patch) {
97
+ var _a;
98
+ this.update({
99
+ appearance: {
100
+ presets: [
101
+ ...((_a = this.settings.appearance) == null ? void 0 : _a.presets) || [],
102
+ ...patch || []
103
+ ]
104
+ }
105
+ });
106
+ }
107
+ appearanceWebEditor() {
108
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T;
109
+ if (!this.theme.appearance) {
110
+ return;
111
+ }
112
+ this.resetWebeditor();
113
+ this.resetNavigation();
114
+ const searchAppearance = ((_b = (_a = this.theme.appearance) == null ? void 0 : _a.search) == null ? void 0 : _b.sidebar) || ((_d = (_c = this.theme.appearance) == null ? void 0 : _c.search) == null ? void 0 : _d.middle);
115
+ if (searchAppearance) {
116
+ const hasSearch = (_e = this.webeditor.header) == null ? void 0 : _e.find((item) => item.component === "Search");
117
+ if (hasSearch) {
118
+ console.warn("Search already exists in webeditor.header");
119
+ return;
120
+ }
121
+ if ((_g = (_f = this.theme.appearance) == null ? void 0 : _f.search) == null ? void 0 : _g.sidebar) {
122
+ const search = {
123
+ component: "Search",
124
+ mobile: ((_i = (_h = this.theme.appearance) == null ? void 0 : _h.search) == null ? void 0 : _i.sidebar) === "mobile" || void 0,
125
+ desktop: ((_k = (_j = this.theme.appearance) == null ? void 0 : _j.search) == null ? void 0 : _k.sidebar) === "desktop" || void 0
126
+ };
127
+ if (!this.webeditor.sidebarTop) {
128
+ this.webeditor.sidebarTop = [];
129
+ }
130
+ (_l = this.webeditor.sidebarTop) == null ? void 0 : _l.unshift({
131
+ ...search
132
+ });
133
+ }
134
+ if ((_n = (_m = this.theme.appearance) == null ? void 0 : _m.search) == null ? void 0 : _n.middle) {
135
+ const search = {
136
+ component: "Search",
137
+ mobile: ((_p = (_o = this.theme.appearance) == null ? void 0 : _o.search) == null ? void 0 : _p.middle) === "mobile" || void 0,
138
+ desktop: ((_r = (_q = this.theme.appearance) == null ? void 0 : _q.search) == null ? void 0 : _r.middle) === "desktop" || void 0
139
+ };
140
+ const searchItem = {
141
+ ...search,
142
+ float: "center"
143
+ };
144
+ this.webeditor.header = this.headerPrepend(searchItem, "center");
145
+ }
146
+ }
147
+ if (((_t = (_s = this.theme.appearance) == null ? void 0 : _s.sidebar) == null ? void 0 : _t.scrollbarColor) && !((_v = (_u = this.theme.appearance) == null ? void 0 : _u.sidebar) == null ? void 0 : _v.scrollbar)) {
148
+ this.theme.appearance.sidebar.scrollbar = "secondary";
149
+ }
150
+ if ((_x = (_w = this.theme.appearance) == null ? void 0 : _w.logo) == null ? void 0 : _x.sidebar) {
151
+ const logo = {
152
+ component: "Logo",
153
+ mobile: ((_z = (_y = this.theme.appearance) == null ? void 0 : _y.logo) == null ? void 0 : _z.sidebar) === "mobile" || void 0,
154
+ desktop: ((_B = (_A = this.theme.appearance) == null ? void 0 : _A.logo) == null ? void 0 : _B.sidebar) === "desktop" || void 0
155
+ };
156
+ if (!this.webeditor.sidebarTop) {
157
+ this.webeditor.sidebarTop = [];
158
+ }
159
+ (_C = this.webeditor.sidebarTop) == null ? void 0 : _C.unshift(logo);
160
+ }
161
+ if (((_E = (_D = this.theme.appearance) == null ? void 0 : _D.tabs) == null ? void 0 : _E.surface) === "center" && ((_G = (_F = this.navigation) == null ? void 0 : _F.tabs) == null ? void 0 : _G.length)) {
162
+ this.insertCenterHeaderTabs();
163
+ }
164
+ if (((_I = (_H = this.navigation) == null ? void 0 : _H.tabs) == null ? void 0 : _I.length) && ((_K = (_J = this.navigation) == null ? void 0 : _J.segments) == null ? void 0 : _K.length) && // cuz segments defaults are inside subnav
165
+ ((_M = (_L = this.theme.appearance) == null ? void 0 : _L.tabs) == null ? void 0 : _M.surface) !== "center") {
166
+ this.navigation.segments = this.navigation.segments.map((segment) => {
167
+ if (segment.appearance !== "sidebarDropdown") {
168
+ segment.appearance = "sidebarDropdown";
169
+ }
170
+ return segment;
171
+ });
172
+ }
173
+ if ((_P = (_O = (_N = this.navigation) == null ? void 0 : _N.anchors) == null ? void 0 : _O.header) == null ? void 0 : _P.length) {
174
+ (_R = (_Q = this.navigation) == null ? void 0 : _Q.anchors) == null ? void 0 : _R.header.forEach((item) => {
175
+ var _a2, _b2;
176
+ const button = {
177
+ ...item,
178
+ component: "Button",
179
+ props: {},
180
+ float: "right",
181
+ desktop: true
182
+ };
183
+ if ("button" in item) {
184
+ this.webeditor.header = this.headerAppend({
185
+ ...button,
186
+ props: {
187
+ kind: item.button,
188
+ children: item.title,
189
+ size: ((_b2 = (_a2 = this.theme.appearance) == null ? void 0 : _a2.header) == null ? void 0 : _b2.buttonSize) || "md"
190
+ }
191
+ });
192
+ return;
193
+ }
194
+ if ("social" in item) {
195
+ this.webeditor.header = this.headerAppend({
196
+ ...button,
197
+ icon: /* @__PURE__ */ React.createElement(IconSocial, { kind: item.social }),
198
+ props: {
199
+ theme: "ghost",
200
+ icon: /* @__PURE__ */ React.createElement(IconSocial, { kind: item.social })
201
+ }
202
+ });
203
+ return;
204
+ }
205
+ if (item.icon) {
206
+ this.webeditor.header = this.headerAppend({
207
+ ...button,
208
+ props: {
209
+ theme: "ghost",
210
+ icon: item.icon
211
+ }
212
+ });
213
+ return;
214
+ }
215
+ this.webeditor.header = this.headerAppend({
216
+ ...item,
217
+ float: "right",
218
+ desktop: true
219
+ });
220
+ });
221
+ }
222
+ if (this.theme.name === "gusto") {
223
+ if ((_T = (_S = this.navigation) == null ? void 0 : _S.tabs) == null ? void 0 : _T.length) {
224
+ this.navigation.sidebarDropdown = this.navigation.tabs;
225
+ }
226
+ }
227
+ }
228
+ mergeUserAppearance() {
229
+ const update = {
230
+ appearance: this.userAppearance
231
+ };
232
+ if (this.originalTheme.coder) {
233
+ update.coder = this.originalTheme.coder;
234
+ }
235
+ this.update(update);
236
+ }
237
+ resetWebeditor() {
238
+ for (const key in this.webeditor) {
239
+ this.webeditor[key] = this.originalWebeditor[key] || [];
240
+ }
241
+ }
242
+ resetNavigation() {
243
+ for (const key in this.navigation) {
244
+ this.navigation[key] = this.originalNavigation[key] || [];
245
+ }
246
+ }
247
+ insertCenterHeaderTabs() {
248
+ var _a, _b, _c;
249
+ const tabsWithFloat = ((_b = (_a = this.navigation) == null ? void 0 : _a.tabs) == null ? void 0 : _b.map((item) => ({
250
+ ...item,
251
+ float: "center"
252
+ }))) ?? [];
253
+ const searchIndex = ((_c = this.webeditor.header) == null ? void 0 : _c.findIndex((item) => item.component === "Search")) ?? -1;
254
+ const currentHeader = this.webeditor.header ?? [];
255
+ if (searchIndex !== -1) {
256
+ this.webeditor.header = [
257
+ ...currentHeader.slice(0, searchIndex + 1),
258
+ ...tabsWithFloat,
259
+ ...currentHeader.slice(searchIndex + 1)
260
+ ];
261
+ } else {
262
+ this.webeditor.header = [
263
+ ...tabsWithFloat,
264
+ ...currentHeader
265
+ ];
266
+ }
267
+ }
268
+ };
269
+ function deepMerge(target, source) {
270
+ for (const key in source) {
271
+ const sourceVal = source[key];
272
+ const targetVal = target[key];
273
+ if (sourceVal && typeof sourceVal === "object" && !Array.isArray(sourceVal) && typeof targetVal === "object" && targetVal !== null) {
274
+ target[key] = deepMerge(targetVal, sourceVal);
275
+ } else if (sourceVal !== void 0) {
276
+ target[key] = sourceVal;
277
+ }
278
+ }
279
+ return target;
280
+ }
281
+
282
+ // src/BaseTheme.tsx
283
+ import { useRef } from "react";
284
+ import { useUXEvents } from "@xyd-js/analytics";
285
+ import { useUXUnreachableElementTracker } from "@xyd-js/components/uxsdk";
286
+ var BaseTheme = class extends Theme {
287
+ constructor() {
288
+ super();
289
+ this.Page = this.Page.bind(this);
290
+ this.Layout = this.Layout.bind(this);
291
+ this.Navbar = this.Navbar.bind(this);
292
+ this.Sidebar = this.Sidebar.bind(this);
293
+ this.Content = this.Content.bind(this);
294
+ this.ContentSecondary = this.ContentSecondary.bind(this);
295
+ this.ContentNav = this.ContentNav.bind(this);
296
+ this.TocTop = this.TocTop.bind(this);
297
+ this.TocBottom = this.TocBottom.bind(this);
298
+ this.PageFooter = this.PageFooter.bind(this);
299
+ this.Footer = this.Footer.bind(this);
300
+ this.Breadcrumbs = this.Breadcrumbs.bind(this);
301
+ this.NavLinks = this.NavLinks.bind(this);
302
+ }
303
+ // public reactContentComponents(): { [component: string]: (props: any) => React.JSX.Element | null } {
304
+ // return this.reactContent.components()
305
+ // }
306
+ reactContentComponents() {
307
+ var _a;
308
+ const meta = useMetadata2();
309
+ const appearance = useAppearance();
310
+ const contentDecorator = (_a = appearance == null ? void 0 : appearance.content) == null ? void 0 : _a.contentDecorator;
311
+ if (contentDecorator === "secondary") {
312
+ if (isDefaultContent(meta)) {
313
+ return this.reactContent.components();
314
+ }
315
+ return {
316
+ ...this.reactContent.components(),
317
+ h1: () => null,
318
+ Subtitle: () => null
319
+ };
320
+ }
321
+ return this.reactContent.components();
322
+ }
323
+ // TODO: rename and better cuz its only for fixing react-components in secondary content cuz it apply to non original content
324
+ reactFileComponents() {
325
+ var _a;
326
+ const appearance = useAppearance();
327
+ const contentDecorator = (_a = appearance == null ? void 0 : appearance.content) == null ? void 0 : _a.contentDecorator;
328
+ if (contentDecorator === "secondary") {
329
+ return false;
330
+ }
331
+ return {};
332
+ }
333
+ Layout({ children }) {
334
+ var _a, _b;
335
+ const {
336
+ Navbar: $Navbar,
337
+ Sidebar: $Sidebar,
338
+ Footer: $Footer,
339
+ SubNav: $SubNav
340
+ } = this;
341
+ const location = useLocation();
342
+ const matchedSubNav = useMatchedSubNav();
343
+ const matchActivePageRout = useActivePageRoute(true);
344
+ const activeRoute = useActiveRoute();
345
+ const meta = useMetadata2();
346
+ const appearance = useAppearance();
347
+ const isPage = (meta == null ? void 0 : meta.layout) === "page";
348
+ const hideSidebar = this.useHideSidebar();
349
+ const subheader = matchedSubNav && !isPage ? /* @__PURE__ */ React2.createElement($SubNav, null) : null;
350
+ const sidebar = /* @__PURE__ */ React2.createElement($Sidebar, null);
351
+ const banner = ((_a = appearance == null ? void 0 : appearance.banner) == null ? void 0 : _a.fixed) ? /* @__PURE__ */ React2.createElement(FwBanner, null) : null;
352
+ const id = (activeRoute == null ? void 0 : activeRoute.id) || (matchActivePageRout == null ? void 0 : matchActivePageRout.id) || void 0;
353
+ return /* @__PURE__ */ React2.createElement(UXNode, { name: "BaseTheme.Layout", props: {} }, /* @__PURE__ */ React2.createElement(
354
+ LayoutPrimary,
355
+ {
356
+ subheader: !!subheader,
357
+ layout: meta == null ? void 0 : meta.layout,
358
+ scrollKey: location.pathname,
359
+ id
360
+ },
361
+ /* @__PURE__ */ React2.createElement(
362
+ LayoutPrimary.Header,
363
+ {
364
+ banner,
365
+ header: /* @__PURE__ */ React2.createElement($Navbar, null),
366
+ subheader
367
+ }
368
+ ),
369
+ /* @__PURE__ */ React2.createElement(
370
+ LayoutPrimary.MobileAside,
371
+ {
372
+ aside: sidebar
373
+ }
374
+ ),
375
+ /* @__PURE__ */ React2.createElement("main", { part: "main" }, hideSidebar ? null : /* @__PURE__ */ React2.createElement("aside", { part: "sidebar" }, sidebar), children),
376
+ ((_b = appearance == null ? void 0 : appearance.footer) == null ? void 0 : _b.surface) !== "page" ? /* @__PURE__ */ React2.createElement($Footer, null) : null
377
+ ));
378
+ }
379
+ Page({ children }) {
380
+ var _a;
381
+ const {
382
+ Content: $Content,
383
+ ContentNav: $ContentNav,
384
+ PageFooter: $PageFooter,
385
+ Footer: $Footer
386
+ } = this;
387
+ const hideToc = this.useHideToc();
388
+ const appearance = useAppearance();
389
+ const meta = useMetadata2();
390
+ let contentNav = hideToc ? void 0 : /* @__PURE__ */ React2.createElement($ContentNav, null);
391
+ let footer = ((_a = appearance == null ? void 0 : appearance.footer) == null ? void 0 : _a.surface) === "page" ? /* @__PURE__ */ React2.createElement($Footer, null) : null;
392
+ const isPage = (meta == null ? void 0 : meta.layout) === "page";
393
+ return /* @__PURE__ */ React2.createElement(UXNode, { name: "BaseTheme.Page", props: {} }, /* @__PURE__ */ React2.createElement(
394
+ LayoutPrimary.Page,
395
+ {
396
+ after: footer,
397
+ contentNav
398
+ },
399
+ /* @__PURE__ */ React2.createElement($Content, null, children),
400
+ isPage ? null : /* @__PURE__ */ React2.createElement($PageFooter, null, /* @__PURE__ */ React2.createElement($BuiltWithXYD, null))
401
+ ));
402
+ }
403
+ Navbar() {
404
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(FwNav, null));
405
+ }
406
+ Sidebar() {
407
+ return /* @__PURE__ */ React2.createElement(FwSidebar, null);
408
+ }
409
+ Content({ children }) {
410
+ var _a;
411
+ const meta = useMetadata2();
412
+ const appearance = useAppearance();
413
+ const {
414
+ ContentSecondary: $ContentSecondary,
415
+ Breadcrumbs: $Breadcrumbs,
416
+ NavLinks: $NavLinks
417
+ } = this;
418
+ const contentDecorator = (_a = appearance == null ? void 0 : appearance.content) == null ? void 0 : _a.contentDecorator;
419
+ if (contentDecorator === "secondary" && !isDefaultContent(meta)) {
420
+ return /* @__PURE__ */ React2.createElement($ContentSecondary, null, children);
421
+ }
422
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement($Breadcrumbs, null), /* @__PURE__ */ React2.createElement(ContentDecorator, { metaComponent: (meta == null ? void 0 : meta.component) || void 0 }, children), /* @__PURE__ */ React2.createElement($NavLinks, null));
423
+ }
424
+ ContentSecondary({ children }) {
425
+ var _a, _b;
426
+ const meta = useMetadata2();
427
+ const settings = useSettings();
428
+ const ContentComponent = useContentComponent();
429
+ const { h1, Subtitle, code } = this.reactContent.components();
430
+ const {
431
+ Breadcrumbs: $Breadcrumbs,
432
+ NavLinks: $NavLinks
433
+ } = this;
434
+ let copyPageElement = /* @__PURE__ */ React2.createElement(FwCopyPage, null);
435
+ if ((meta == null ? void 0 : meta.copyPage) !== true && ((meta == null ? void 0 : meta.copyPage) === false || ((_b = (_a = settings.theme) == null ? void 0 : _a.writer) == null ? void 0 : _b.copyPage) === false)) {
436
+ copyPageElement = null;
437
+ }
438
+ return /* @__PURE__ */ React2.createElement(ContentDecorator, { metaComponent: (meta == null ? void 0 : meta.component) || void 0 }, /* @__PURE__ */ React2.createElement("main", null, /* @__PURE__ */ React2.createElement("xyd-secondary-content", null, /* @__PURE__ */ React2.createElement("div", { part: "secondary-content-header" }, /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement($Breadcrumbs, null), /* @__PURE__ */ React2.createElement(ContentComponent, { components: {
439
+ // TODO: !!! BETTER API !!!
440
+ ...this.reactContent.noop(),
441
+ h1,
442
+ Subtitle,
443
+ code
444
+ } })), copyPageElement), /* @__PURE__ */ React2.createElement("div", { part: "secondary-content" }, children, /* @__PURE__ */ React2.createElement($NavLinks, null)))));
445
+ }
446
+ ContentNav() {
447
+ const { TocTop, TocBottom } = this;
448
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(FwToc, null)), /* @__PURE__ */ React2.createElement(TocBottom, null));
449
+ }
450
+ TocTop() {
451
+ return /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(VideoGuide.Miniature, null));
452
+ }
453
+ TocBottom() {
454
+ const meta = useMetadata2();
455
+ const tocCard = meta == null ? void 0 : meta.tocCard;
456
+ const isEmpty = !tocCard || Array.isArray(tocCard) && tocCard.length === 0 || !Array.isArray(tocCard) && (!tocCard.link || !tocCard.title || !tocCard.description);
457
+ if (isEmpty) {
458
+ return null;
459
+ }
460
+ if (Array.isArray(tocCard)) {
461
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, tocCard.map((card) => /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(
462
+ TocCard,
463
+ {
464
+ key: card.link,
465
+ href: card.link,
466
+ title: card.title,
467
+ description: card.description,
468
+ icon: card.icon
469
+ }
470
+ ))));
471
+ }
472
+ return /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(
473
+ TocCard,
474
+ {
475
+ title: tocCard.title,
476
+ description: tocCard.description,
477
+ href: tocCard.link,
478
+ icon: tocCard.icon
479
+ }
480
+ ));
481
+ }
482
+ PageFooter({ children }) {
483
+ var _a;
484
+ const githubButtonContainer = useRef(null);
485
+ const settings = useSettings();
486
+ const ux = useUXEvents();
487
+ const apps = (_a = settings.integrations) == null ? void 0 : _a[".apps"];
488
+ let pageFooterBottom = null;
489
+ useUXUnreachableElementTracker(githubButtonContainer, () => {
490
+ ux.docs.github_star.hover({});
491
+ }, () => {
492
+ ux.docs.github_star.click({});
493
+ });
494
+ if (apps == null ? void 0 : apps.githubStar) {
495
+ pageFooterBottom = /* @__PURE__ */ React2.createElement("div", { part: "github-button-container" }, /* @__PURE__ */ React2.createElement(Text, { size: "small" }, apps.githubStar.label), /* @__PURE__ */ React2.createElement("div", { ref: githubButtonContainer }, /* @__PURE__ */ React2.createElement(
496
+ GitHubButton,
497
+ {
498
+ href: apps.githubStar.href,
499
+ "data-icon": apps.githubStar.dataIcon || "octicon-star",
500
+ "data-size": apps.githubStar.dataSize || "large",
501
+ "data-show-count": apps.githubStar.dataShowCount || true,
502
+ "aria-label": apps.githubStar.ariaLabel
503
+ },
504
+ apps.githubStar.title
505
+ )));
506
+ }
507
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("xyd-page-footer", null, children, pageFooterBottom));
508
+ }
509
+ Footer() {
510
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
511
+ const settings = useSettings();
512
+ let logoElement = null;
513
+ const logo = (_b = (_a = settings == null ? void 0 : settings.components) == null ? void 0 : _a.footer) == null ? void 0 : _b.logo;
514
+ if (!((_c = settings.components) == null ? void 0 : _c.footer)) {
515
+ return null;
516
+ }
517
+ if (logo) {
518
+ if (typeof logo === "boolean") {
519
+ logoElement = /* @__PURE__ */ React2.createElement(FwLogo, null);
520
+ } else {
521
+ logoElement = FwJsonComponent(logo);
522
+ }
523
+ }
524
+ return /* @__PURE__ */ React2.createElement(
525
+ Footer,
526
+ {
527
+ kind: (_e = (_d = settings.components) == null ? void 0 : _d.footer) == null ? void 0 : _e.kind,
528
+ logo: logoElement,
529
+ footnote: FwJsonComponent(((_g = (_f = settings.components) == null ? void 0 : _f.footer) == null ? void 0 : _g.footnote) || ""),
530
+ socials: ((_i = (_h = settings.components) == null ? void 0 : _h.footer) == null ? void 0 : _i.social) ? Object.entries((_k = (_j = settings.components) == null ? void 0 : _j.footer) == null ? void 0 : _k.social).map(([key, value]) => ({
531
+ logo: /* @__PURE__ */ React2.createElement(IconSocial2, { kind: key }),
532
+ href: value
533
+ })) : void 0,
534
+ links: (_m = (_l = settings.components) == null ? void 0 : _l.footer) == null ? void 0 : _m.links
535
+ }
536
+ );
537
+ }
538
+ Breadcrumbs() {
539
+ var _a;
540
+ const appearance = useAppearance();
541
+ const hideSidebar = this.useHideSidebar();
542
+ if (!((_a = appearance == null ? void 0 : appearance.content) == null ? void 0 : _a.breadcrumbs)) {
543
+ return null;
544
+ }
545
+ if (hideSidebar) {
546
+ return null;
547
+ }
548
+ return /* @__PURE__ */ React2.createElement(FwBreadcrumbs, null);
549
+ }
550
+ NavLinks() {
551
+ const hideSidebar = this.useHideSidebar();
552
+ if (hideSidebar) {
553
+ return null;
554
+ }
555
+ return /* @__PURE__ */ React2.createElement(FwNavLinks, null);
556
+ }
557
+ SubNav() {
558
+ return /* @__PURE__ */ React2.createElement(FwSubNav, null);
559
+ }
560
+ };
561
+ function $BuiltWithXYD() {
562
+ const [colorScheme] = useColorScheme();
563
+ const fill = colorScheme === "dark" ? "white" : "black";
564
+ return /* @__PURE__ */ React2.createElement("a", { href: "https://xyd.dev", target: "_blank" }, /* @__PURE__ */ React2.createElement("xyd-built-with", null, /* @__PURE__ */ React2.createElement("div", { part: "text" }, "Built with"), /* @__PURE__ */ React2.createElement("div", { part: "logo" }, /* @__PURE__ */ React2.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 64, height: 18, viewBox: "0 0 64 18", fill: "none" }, /* @__PURE__ */ React2.createElement("g", { clipPath: "url(#clip0_3_18)" }, /* @__PURE__ */ React2.createElement(
565
+ "path",
566
+ {
567
+ fillRule: "evenodd",
568
+ clipRule: "evenodd",
569
+ d: "M12.9447 14.7921H10.6636L14.2428 9.73069L10.8861 4.9901H13.1857L14.9846 7.69901C15.0712 7.84158 15.1577 7.99307 15.2443 8.15347C15.2649 8.1918 15.2854 8.23023 15.3057 8.26877C15.3598 8.37166 15.4048 8.46149 15.4407 8.53824C15.4432 8.54364 15.4458 8.54904 15.4483 8.55446C15.4611 8.51802 15.4751 8.482 15.4904 8.44646C15.5265 8.36139 15.5743 8.26372 15.6337 8.15347C15.7203 7.99307 15.8068 7.84158 15.8934 7.69901L17.6923 4.9901H19.9919L16.6352 9.74852L20.1959 14.7921H17.8963L15.9119 11.8515C15.8254 11.7089 15.7388 11.5485 15.6523 11.3703C15.6317 11.328 15.6113 11.2857 15.5909 11.2434C15.551 11.1606 15.516 11.0873 15.4861 11.0237C15.4734 10.9967 15.4608 10.9696 15.4483 10.9426C15.3988 11.0495 15.3277 11.1921 15.235 11.3703C15.1851 11.4666 15.1319 11.5613 15.0755 11.6542C15.0349 11.7212 14.9922 11.7869 14.9476 11.8515L12.9447 14.7921ZM26.2973 18H24.1831L25.6482 14.2218L21.8464 4.9901H24.0533L26.186 10.5149C26.2523 10.6968 26.3186 10.9065 26.3848 11.1441C26.4058 11.2194 26.426 11.2947 26.4457 11.3703C26.5322 11.703 26.6064 11.9762 26.6682 12.1901C26.7125 11.9988 26.7716 11.76 26.8455 11.4737C26.8544 11.4392 26.8633 11.4047 26.8722 11.3703C26.9588 11.0376 27.0453 10.7525 27.1318 10.5149L29.1347 4.9901H31.2675L26.2973 18ZM33.5671 11.2812V8.51881C33.5671 8.5099 33.5671 8.50099 33.5671 8.49208C33.5713 7.51129 33.8055 6.70741 34.2698 6.08044C34.3394 5.98635 34.4144 5.89603 34.4943 5.8099C35.1125 5.14455 35.9347 4.81188 36.9609 4.81188C37.2432 4.80978 37.5248 4.83873 37.8002 4.89814C38.2353 4.98873 38.637 5.18972 38.9638 5.4802C39.4583 5.92574 39.7056 6.53465 39.7056 7.30693L39.279 6.86139H39.7427L39.687 4.5802V1.78218H41.6899V14.7921H39.7056V12.9208H39.279L39.7056 12.4752C39.7079 12.7346 39.6757 12.9931 39.6097 13.2446C39.5048 13.6495 39.2805 14.0166 38.9638 14.302C38.637 14.5925 38.2353 14.7935 37.8002 14.884C37.5248 14.9435 37.2432 14.9724 36.9609 14.9703C36.5745 14.9741 36.19 14.9196 35.8213 14.8087C35.3085 14.6502 34.8499 14.3611 34.4943 13.9723C33.8762 13.3069 33.5671 12.4099 33.5671 11.2812ZM2.07708 16.7525H0L6.52796 0H8.60504L2.07708 16.7525ZM64 9.92673L55.8771 13.7228V11.905L61.4222 9.35644C61.5629 9.29538 61.7054 9.23815 61.8495 9.18481C61.9412 9.15093 62.0337 9.11902 62.1269 9.08911C62.3475 9.01842 62.5134 8.97113 62.6247 8.94725C62.6257 8.94701 62.6267 8.94677 62.6276 8.94653C62.5884 8.93886 62.5495 8.93007 62.5108 8.92016C62.4265 8.89877 62.3263 8.86931 62.2102 8.83176C62.1731 8.81976 62.136 8.80752 62.0991 8.79505C61.8704 8.71782 61.6447 8.62574 61.4222 8.51881L55.8771 5.9703V4.11683L64 7.91287V9.92673ZM39.687 11.1743V8.60792C39.6886 8.39594 39.6672 8.18438 39.6231 7.97667C39.5654 7.71481 39.4687 7.48414 39.3328 7.28465C39.2758 7.20072 39.2112 7.12171 39.14 7.04852C38.8659 6.76894 38.503 6.58461 38.1083 6.52438C37.956 6.49891 37.8016 6.48645 37.6471 6.48713C37.4323 6.48547 37.218 6.50802 37.0087 6.55432C36.6672 6.62705 36.3545 6.79238 36.1078 7.03069C35.9021 7.23549 35.7516 7.48556 35.6696 7.75907C35.6117 7.94145 35.5751 8.14248 35.5598 8.36216C35.5541 8.44397 35.5514 8.52593 35.5514 8.60792V11.1743C35.55 11.3795 35.5691 11.5844 35.6086 11.7861C35.6563 12.0212 35.734 12.2299 35.8419 12.4122C35.9147 12.5359 36.0041 12.65 36.1078 12.7515C36.3578 12.9928 36.6752 13.1594 37.0217 13.2309C37.2269 13.2751 37.4367 13.2966 37.6471 13.2951C37.8632 13.2969 38.0786 13.2714 38.2878 13.2193C38.6141 13.1386 38.9098 12.9701 39.14 12.7337C39.4759 12.389 39.6571 11.9209 39.6837 11.3295C39.686 11.2778 39.6871 11.226 39.687 11.1743Z",
570
+ fill,
571
+ stroke: fill,
572
+ strokeWidth: "0.944882",
573
+ strokeLinecap: "round"
574
+ }
575
+ )), /* @__PURE__ */ React2.createElement("defs", null, /* @__PURE__ */ React2.createElement("clipPath", { id: "clip0_3_18" }, /* @__PURE__ */ React2.createElement("rect", { width: 64, height: 18, fill: "white" })))))));
576
+ }
577
+ function isDefaultContent(meta) {
578
+ return (meta == null ? void 0 : meta.openapi) || (meta == null ? void 0 : meta.graphql) || meta.component === "atlas" || meta.uniform || meta.layout === "page";
579
+ }
580
+
581
+ // src/copyPresetsPlugin.ts
582
+ import fs from "fs";
583
+ import path from "path";
584
+ function copyPresetsPlugin(options = {}) {
585
+ const {
586
+ srcDir = "src/presets",
587
+ distDir = "dist/presets",
588
+ packageRoot = process.cwd()
589
+ } = options;
590
+ return {
591
+ name: "copy-presets",
592
+ writeBundle() {
593
+ const srcPresetsPath = path.join(packageRoot, srcDir);
594
+ const distPresetsPath = path.join(packageRoot, distDir);
595
+ try {
596
+ let copyDir = function(src, dest) {
597
+ if (!fs.existsSync(dest)) {
598
+ fs.mkdirSync(dest, { recursive: true });
599
+ }
600
+ const items = fs.readdirSync(src);
601
+ for (const item of items) {
602
+ const srcPath = path.join(src, item);
603
+ const destPath = path.join(dest, item);
604
+ const stat = fs.statSync(srcPath);
605
+ if (stat.isDirectory()) {
606
+ copyDir(srcPath, destPath);
607
+ } else {
608
+ fs.copyFileSync(srcPath, destPath);
609
+ }
610
+ }
611
+ };
612
+ if (!fs.existsSync(srcPresetsPath)) {
613
+ console.log(`${srcDir} directory does not exist, skipping copy`);
614
+ return;
615
+ }
616
+ copyDir(srcPresetsPath, distPresetsPath);
617
+ console.log(`\u2705 Successfully copied ${srcDir} to ${distDir}`);
618
+ } catch (error) {
619
+ console.error(`\u274C Error copying presets:`, error);
620
+ }
621
+ }
622
+ };
623
+ }
624
+ function tsupCopyPresetsPlugin(options = {}) {
625
+ const {
626
+ srcDir = "src/presets",
627
+ distDir = "dist/presets",
628
+ packageRoot = process.cwd()
629
+ } = options;
630
+ return () => ({
631
+ name: "copy-presets",
632
+ closeBundle() {
633
+ const srcPresetsPath = path.join(packageRoot, srcDir);
634
+ const distPresetsPath = path.join(packageRoot, distDir);
635
+ try {
636
+ let copyDir = function(src, dest) {
637
+ if (!fs.existsSync(dest)) {
638
+ fs.mkdirSync(dest, { recursive: true });
639
+ }
640
+ const items = fs.readdirSync(src);
641
+ for (const item of items) {
642
+ const srcPath = path.join(src, item);
643
+ const destPath = path.join(dest, item);
644
+ const stat = fs.statSync(srcPath);
645
+ if (stat.isDirectory()) {
646
+ copyDir(srcPath, destPath);
647
+ } else {
648
+ fs.copyFileSync(srcPath, destPath);
649
+ }
650
+ }
651
+ };
652
+ if (!fs.existsSync(srcPresetsPath)) {
653
+ console.log(`${srcDir} directory does not exist, skipping copy`);
654
+ return;
655
+ }
656
+ copyDir(srcPresetsPath, distPresetsPath);
657
+ console.log(`\u2705 Successfully copied ${srcDir} to ${distDir}`);
658
+ } catch (error) {
659
+ console.error(`\u274C Error copying presets:`, error);
660
+ }
661
+ }
662
+ });
663
+ }
664
+ export {
665
+ BaseTheme,
666
+ copyPresetsPlugin,
667
+ tsupCopyPresetsPlugin
668
+ };
669
+ //# sourceMappingURL=index.js.map