@orbitcommerce/constellation-docs 0.0.0-stage → 1.0.0
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/LICENSE.md +6 -0
- package/README.md +6 -2
- package/dist/docs.css +8260 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-CNbBbErC.js +129 -0
- package/dist/pages/_figures-data-BDmScEny.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_overlays-specimens-Dpn6oiyH.js +310 -0
- package/dist/pages/alert-BD4e6QTh.js +769 -0
- package/dist/pages/app-shell-KbA-nRqZ.js +1479 -0
- package/dist/pages/area-chart-B91dLcGo.js +562 -0
- package/dist/pages/avatar-DPPHXJAu.js +713 -0
- package/dist/pages/badge-C9JR0thI.js +729 -0
- package/dist/pages/button-D3V912P4.js +518 -0
- package/dist/pages/calendar-DSDZ9nRH.js +630 -0
- package/dist/pages/card-DUggbis3.js +659 -0
- package/dist/pages/checkbox-DwimQaK3.js +365 -0
- package/dist/pages/colour-BwuO8xAv.js +1498 -0
- package/dist/pages/command-palette-xAD7fOg6.js +1243 -0
- package/dist/pages/date-picker-BYSa816m.js +1421 -0
- package/dist/pages/delta-CtAo0eIM.js +574 -0
- package/dist/pages/dialog-BRAf4LMh.js +1451 -0
- package/dist/pages/docs-BNOb7AqR.js +515 -0
- package/dist/pages/empty-state-C-mLrXW2.js +417 -0
- package/dist/pages/figure-tabs-CoPFzzKz.js +460 -0
- package/dist/pages/home-dashboard-CFQwDtC9.js +959 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/icon-button-C9eSVPPW.js +861 -0
- package/dist/pages/icons-sxkTs5Ob.js +473 -0
- package/dist/pages/input-KF9Gkawf.js +1093 -0
- package/dist/pages/installation-DpsX8G_n.js +445 -0
- package/dist/pages/kbd-cNfDoikz.js +544 -0
- package/dist/pages/live-globe-ClvLn9Lb.js +571 -0
- package/dist/pages/logo-BfGF1Pq9.js +571 -0
- package/dist/pages/menu-by2sgQ09.js +1618 -0
- package/dist/pages/motion-BvTGc2Dk.js +855 -0
- package/dist/pages/orbit-spinner-Dil1Z3Oy.js +332 -0
- package/dist/pages/overview-BPEbZQ6g.js +130 -0
- package/dist/pages/pagination-BBUnGvv5.js +249 -0
- package/dist/pages/popover-Db1gLDpb.js +1136 -0
- package/dist/pages/principles-CeAIOIdt.js +483 -0
- package/dist/pages/radio-group-CkdBWWfG.js +1077 -0
- package/dist/pages/registry-CroHzK9I.js +244 -0
- package/dist/pages/release-Dvo684UJ.js +13 -0
- package/dist/pages/rolling-number-qmvH84Mq.js +529 -0
- package/dist/pages/search-field-BN7MWGQ4.js +693 -0
- package/dist/pages/segmented-control-CTbIpRBW.js +777 -0
- package/dist/pages/select-DguELoRR.js +1429 -0
- package/dist/pages/separator-CPZub9pv.js +351 -0
- package/dist/pages/shape-DKvA0YKr.js +627 -0
- package/dist/pages/skeleton-DLuBhP46.js +561 -0
- package/dist/pages/sparkline-DMMYGbHn.js +668 -0
- package/dist/pages/switch-B-Qe4kcT.js +517 -0
- package/dist/pages/table-AMoODng4.js +607 -0
- package/dist/pages/tabs-B4M-usCV.js +1455 -0
- package/dist/pages/textarea-fTuUZRQb.js +693 -0
- package/dist/pages/toast-CKP03zjy.js +1176 -0
- package/dist/pages/tooltip-CBYil3kt.js +697 -0
- package/dist/pages/typography-PCbg8Bhg.js +735 -0
- package/manifest.json +3125 -0
- package/package.json +35 -4
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, forwardRef, useContext, useMemo, useSyncExternalStore } from "react";
|
|
3
|
+
import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/site/host.tsx
|
|
5
|
+
var PlainLink = forwardRef(function PlainLink(props, ref) {
|
|
6
|
+
return /* @__PURE__ */ jsx("a", {
|
|
7
|
+
ref,
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
/** Without a host theme, mark <html> the way Constellation reads it. */
|
|
12
|
+
function setDocumentTheme(theme) {
|
|
13
|
+
document.documentElement.dataset.oTheme = theme;
|
|
14
|
+
document.documentElement.style.colorScheme = theme;
|
|
15
|
+
}
|
|
16
|
+
var DEFAULT_HOST = {
|
|
17
|
+
link: PlainLink,
|
|
18
|
+
basePath: "",
|
|
19
|
+
audience: "internal",
|
|
20
|
+
navigate: (href) => window.location.assign(href),
|
|
21
|
+
setTheme: setDocumentTheme,
|
|
22
|
+
backLink: null,
|
|
23
|
+
documentTitle: true
|
|
24
|
+
};
|
|
25
|
+
var DocsHostContext = createContext(DEFAULT_HOST);
|
|
26
|
+
function DocsHostProvider({ link, basePath, audience, navigate, setTheme, backLink, documentTitle, children }) {
|
|
27
|
+
const value = useMemo(() => ({
|
|
28
|
+
link: link ?? DEFAULT_HOST.link,
|
|
29
|
+
basePath: (basePath ?? "").replace(/\/+$/, ""),
|
|
30
|
+
audience: audience ?? DEFAULT_HOST.audience,
|
|
31
|
+
navigate: navigate ?? DEFAULT_HOST.navigate,
|
|
32
|
+
setTheme: setTheme ?? DEFAULT_HOST.setTheme,
|
|
33
|
+
backLink: backLink ?? DEFAULT_HOST.backLink,
|
|
34
|
+
documentTitle: documentTitle ?? DEFAULT_HOST.documentTitle
|
|
35
|
+
}), [
|
|
36
|
+
link,
|
|
37
|
+
basePath,
|
|
38
|
+
audience,
|
|
39
|
+
navigate,
|
|
40
|
+
setTheme,
|
|
41
|
+
backLink,
|
|
42
|
+
documentTitle
|
|
43
|
+
]);
|
|
44
|
+
return /* @__PURE__ */ jsx(DocsHostContext.Provider, {
|
|
45
|
+
value,
|
|
46
|
+
children
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function useDocsHost() {
|
|
50
|
+
return useContext(DocsHostContext);
|
|
51
|
+
}
|
|
52
|
+
/** A docs path ('/components/button#sizes') as the host's href. Anything not starting with '/' passes through. */
|
|
53
|
+
function docsHref(basePath, to) {
|
|
54
|
+
if (!to.startsWith("/")) return to;
|
|
55
|
+
const hashAt = to.indexOf("#");
|
|
56
|
+
const path = hashAt === -1 ? to : to.slice(0, hashAt);
|
|
57
|
+
const hash = hashAt === -1 ? "" : to.slice(hashAt);
|
|
58
|
+
return `${path === "/" ? basePath || "/" : `${basePath}${path}`}${hash}`;
|
|
59
|
+
}
|
|
60
|
+
/** A link to another docs page. Works with `asChild` (Button, IconButton). */
|
|
61
|
+
var DocLink = forwardRef(function DocLink({ to, ...rest }, ref) {
|
|
62
|
+
const host = useDocsHost();
|
|
63
|
+
const Link = host.link;
|
|
64
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
65
|
+
ref,
|
|
66
|
+
href: docsHref(host.basePath, to),
|
|
67
|
+
...rest
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
/** Renders its children for one audience only, e.g. repo set-up notes the public docs leave out. */
|
|
71
|
+
function ForAudience({ audience, children }) {
|
|
72
|
+
return useDocsHost().audience === audience ? /* @__PURE__ */ jsx(Fragment$1, { children }) : null;
|
|
73
|
+
}
|
|
74
|
+
function readDocumentTheme() {
|
|
75
|
+
const root = document.documentElement;
|
|
76
|
+
const named = root.dataset.oTheme ?? root.dataset.theme;
|
|
77
|
+
if (named === "light" || named === "dark") return named;
|
|
78
|
+
return root.classList.contains("dark") ? "dark" : "light";
|
|
79
|
+
}
|
|
80
|
+
function subscribeToDocumentTheme(onChange) {
|
|
81
|
+
const observer = new MutationObserver(onChange);
|
|
82
|
+
observer.observe(document.documentElement, {
|
|
83
|
+
attributes: true,
|
|
84
|
+
attributeFilter: [
|
|
85
|
+
"class",
|
|
86
|
+
"data-theme",
|
|
87
|
+
"data-o-theme"
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
return () => observer.disconnect();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The theme the page is showing, read from `<html>` the way Constellation's own CSS reads it
|
|
94
|
+
* (`data-o-theme`, then `data-theme`, then a `dark` class). The server cannot know it, so a server
|
|
95
|
+
* render and the hydration after it say 'light', and the real theme follows straight away.
|
|
96
|
+
*/
|
|
97
|
+
function useDocumentTheme() {
|
|
98
|
+
return useSyncExternalStore(subscribeToDocumentTheme, readDocumentTheme, () => "light");
|
|
99
|
+
}
|
|
100
|
+
var noSubscription = () => () => {};
|
|
101
|
+
/**
|
|
102
|
+
* False on the server and while hydrating, true afterwards (and straight away in a browser-only
|
|
103
|
+
* render). For output the server cannot reproduce, such as anything drawn from today's date.
|
|
104
|
+
*/
|
|
105
|
+
function useHydrated() {
|
|
106
|
+
return useSyncExternalStore(noSubscription, () => true, () => false);
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
export { useDocsHost as a, docsHref as i, DocsHostProvider as n, useDocumentTheme as o, ForAudience as r, useHydrated as s, DocLink as t };
|