@patternfly/patternfly-doc-core 1.2.0 → 1.3.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/.astro/collections/textContent.schema.json +6 -0
- package/README.md +11 -10
- package/astro.config.mjs +8 -1
- package/cli/buildPropsData.ts +113 -0
- package/cli/cli.ts +52 -6
- package/cli/getConfig.ts +6 -0
- package/cli/hasFile.ts +5 -0
- package/cli/templates/pf-docs.config.mjs +13 -2
- package/cli/tsDocGen.js +199 -0
- package/dist/cli/buildPropsData.js +68 -0
- package/dist/cli/cli.js +37 -4
- package/dist/cli/hasFile.js +4 -0
- package/dist/cli/templates/pf-docs.config.mjs +12 -1
- package/dist/cli/tsDocGen.js +153 -0
- package/dist/cli/tsconfig.tsbuildinfo +1 -1
- package/dist/client/_astro/_page_.SnUmZn2y.css +1 -0
- package/dist/client/design-foundations/typography/index.html +219 -0
- package/dist/client/design-foundations/usage-and-behavior/index.html +368 -0
- package/dist/client/get-started/contribute/index.html +115 -0
- package/dist/client/index.html +42 -0
- package/dist/server/_@astrojs-ssr-adapter.mjs +1 -0
- package/dist/server/_noop-middleware.mjs +3 -0
- package/dist/server/chunks/PropsTables_D_v4KAMn.mjs +1826 -0
- package/dist/server/chunks/_@astrojs-ssr-adapter_ByVMUK8O.mjs +3621 -0
- package/dist/server/chunks/_astro_assets_CLOMnm-3.mjs +1507 -0
- package/dist/server/chunks/_astro_data-layer-content_DDGBHvtb.mjs +1 -0
- package/dist/server/chunks/angle-down-icon_BNJvzYv-.mjs +3970 -0
- package/dist/server/chunks/astro/server_D4f31GMD.mjs +2769 -0
- package/dist/server/chunks/astro-designed-error-pages_CpHpbfhr.mjs +282 -0
- package/dist/server/chunks/consts_BmVDRGlB.mjs +32 -0
- package/dist/server/chunks/content-assets_DleWbedO.mjs +1 -0
- package/dist/server/chunks/content-modules_Dz-S_Wwv.mjs +1 -0
- package/dist/server/chunks/path_Cvt6sEOY.mjs +58 -0
- package/dist/server/chunks/sharp_BYpUyJGL.mjs +88 -0
- package/dist/server/entry.mjs +45 -0
- package/dist/server/manifest_Bln0Ib60.mjs +102 -0
- package/dist/server/pages/_image.astro.mjs +132 -0
- package/dist/server/pages/_section_/_---page_.astro.mjs +1 -0
- package/dist/server/pages/_section_/_page_/_---tab_.astro.mjs +1 -0
- package/dist/server/pages/index.astro.mjs +1 -0
- package/dist/server/pages/props.astro.mjs +25 -0
- package/dist/server/renderers.mjs +259 -0
- package/jest.config.ts +1 -1
- package/package.json +5 -2
- package/pf-docs.config.mjs +31 -0
- package/release.config.mjs +1 -1
- package/src/components/PropsTable.tsx +3 -3
- package/src/components/PropsTables.astro +38 -0
- package/src/content.config.ts +1 -0
- package/src/pages/[section]/[...page].astro +16 -8
- package/src/pages/[section]/[page]/[...tab].astro +4 -1
- package/src/pages/props.ts +17 -0
- package/textContent/contribute.md +1 -0
- package/dist/design-foundations/typography/index.html +0 -193
- package/dist/design-foundations/usage-and-behavior/index.html +0 -342
- package/dist/get-started/contribute/index.html +0 -89
- package/dist/index.html +0 -42
- /package/dist/{PF-HorizontalLogo-Color.svg → client/PF-HorizontalLogo-Color.svg} +0 -0
- /package/dist/{PF-HorizontalLogo-Reverse.svg → client/PF-HorizontalLogo-Reverse.svg} +0 -0
- /package/dist/{_astro → client/_astro}/Button.C3_jB5tC.js +0 -0
- /package/dist/{_astro → client/_astro}/ClientRouter.astro_astro_type_script_index_0_lang.Cainpjm5.js +0 -0
- /package/dist/{_astro → client/_astro}/Navigation.Cede__Ud.js +0 -0
- /package/dist/{_astro → client/_astro}/PageContext.C7BqCh9N.js +0 -0
- /package/dist/{_astro → client/_astro}/PageToggle.DDEjruql.js +0 -0
- /package/dist/{_astro → client/_astro}/RedHatDisplayVF-Italic.CRpusWc8.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatDisplayVF.CYDHf1NI.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatMonoVF-Italic.DGQo2ogW.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatMonoVF.C4fMH6Vz.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatTextVF-Italic.Dkj_WqbA.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/RedHatTextVF.wYvZ7prR.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/Toolbar.TAdHxLSQ.js +0 -0
- /package/dist/{_astro → client/_astro}/_page_.CXyz_BEo.css +0 -0
- /package/dist/{_astro → client/_astro}/_page_.DVvr_Mfl.css +0 -0
- /package/dist/{_astro → client/_astro}/client.CeeiqVaE.js +0 -0
- /package/dist/{_astro → client/_astro}/divider.BSD-oFoh.js +0 -0
- /package/dist/{_astro → client/_astro}/fa-solid-900.DguXoeIz.woff2 +0 -0
- /package/dist/{_astro → client/_astro}/index.CTH3fVMn.js +0 -0
- /package/dist/{_astro → client/_astro}/page.B65lVdBS.js +0 -0
- /package/dist/{_astro → client/_astro}/pf-v6-pficon.Dy6oiu9u.woff2 +0 -0
- /package/dist/{avatarImg.svg → client/avatarImg.svg} +0 -0
- /package/dist/{avatarImgDark.svg → client/avatarImgDark.svg} +0 -0
- /package/dist/{content → client/content}/typography/line-height.png +0 -0
- /package/dist/{favicon.svg → client/favicon.svg} +0 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { isAbsolute } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { g as getConfiguredImageService, i as imageConfig, a as isRemoteAllowed, b as assetsDir, o as outDir } from '../chunks/_astro_assets_CLOMnm-3.mjs';
|
|
5
|
+
import { i as isRemotePath } from '../chunks/path_Cvt6sEOY.mjs';
|
|
6
|
+
import * as mime from 'mrmime';
|
|
7
|
+
export { renderers } from '../renderers.mjs';
|
|
8
|
+
|
|
9
|
+
const fnv1a52 = (str) => {
|
|
10
|
+
const len = str.length;
|
|
11
|
+
let i = 0, t0 = 0, v0 = 8997, t1 = 0, v1 = 33826, t2 = 0, v2 = 40164, t3 = 0, v3 = 52210;
|
|
12
|
+
while (i < len) {
|
|
13
|
+
v0 ^= str.charCodeAt(i++);
|
|
14
|
+
t0 = v0 * 435;
|
|
15
|
+
t1 = v1 * 435;
|
|
16
|
+
t2 = v2 * 435;
|
|
17
|
+
t3 = v3 * 435;
|
|
18
|
+
t2 += v0 << 8;
|
|
19
|
+
t3 += v1 << 8;
|
|
20
|
+
t1 += t0 >>> 16;
|
|
21
|
+
v0 = t0 & 65535;
|
|
22
|
+
t2 += t1 >>> 16;
|
|
23
|
+
v1 = t1 & 65535;
|
|
24
|
+
v3 = t3 + (t2 >>> 16) & 65535;
|
|
25
|
+
v2 = t2 & 65535;
|
|
26
|
+
}
|
|
27
|
+
return (v3 & 15) * 281474976710656 + v2 * 4294967296 + v1 * 65536 + (v0 ^ v3 >> 4);
|
|
28
|
+
};
|
|
29
|
+
const etag = (payload, weak = false) => {
|
|
30
|
+
const prefix = weak ? 'W/"' : '"';
|
|
31
|
+
return prefix + fnv1a52(payload).toString(36) + payload.length.toString(36) + '"';
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
async function loadLocalImage(src, url) {
|
|
35
|
+
const assetsDirPath = fileURLToPath(assetsDir);
|
|
36
|
+
let fileUrl;
|
|
37
|
+
{
|
|
38
|
+
try {
|
|
39
|
+
const idx = url.pathname.indexOf("/_image");
|
|
40
|
+
if (idx > 0) {
|
|
41
|
+
src = src.slice(idx);
|
|
42
|
+
}
|
|
43
|
+
fileUrl = new URL("." + src, outDir);
|
|
44
|
+
const filePath = fileURLToPath(fileUrl);
|
|
45
|
+
if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
|
|
46
|
+
return void 0;
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let buffer = void 0;
|
|
53
|
+
try {
|
|
54
|
+
buffer = await readFile(fileUrl);
|
|
55
|
+
} catch {
|
|
56
|
+
try {
|
|
57
|
+
const sourceUrl = new URL(src, url.origin);
|
|
58
|
+
buffer = await loadRemoteImage(sourceUrl);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.error("Could not process image request:", err);
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return buffer;
|
|
65
|
+
}
|
|
66
|
+
async function loadRemoteImage(src) {
|
|
67
|
+
try {
|
|
68
|
+
const res = await fetch(src);
|
|
69
|
+
if (!res.ok) {
|
|
70
|
+
return void 0;
|
|
71
|
+
}
|
|
72
|
+
return Buffer.from(await res.arrayBuffer());
|
|
73
|
+
} catch {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const GET = async ({ request }) => {
|
|
78
|
+
try {
|
|
79
|
+
const imageService = await getConfiguredImageService();
|
|
80
|
+
if (!("transform" in imageService)) {
|
|
81
|
+
throw new Error("Configured image service is not a local service");
|
|
82
|
+
}
|
|
83
|
+
const url = new URL(request.url);
|
|
84
|
+
const transform = await imageService.parseURL(url, imageConfig);
|
|
85
|
+
if (!transform?.src) {
|
|
86
|
+
const err = new Error(
|
|
87
|
+
"Incorrect transform returned by `parseURL`. Expected a transform with a `src` property."
|
|
88
|
+
);
|
|
89
|
+
console.error("Could not parse image transform from URL:", err);
|
|
90
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
91
|
+
}
|
|
92
|
+
let inputBuffer = void 0;
|
|
93
|
+
if (isRemotePath(transform.src)) {
|
|
94
|
+
if (isRemoteAllowed(transform.src, imageConfig) === false) {
|
|
95
|
+
return new Response("Forbidden", { status: 403 });
|
|
96
|
+
}
|
|
97
|
+
inputBuffer = await loadRemoteImage(new URL(transform.src));
|
|
98
|
+
} else {
|
|
99
|
+
inputBuffer = await loadLocalImage(transform.src, url);
|
|
100
|
+
}
|
|
101
|
+
if (!inputBuffer) {
|
|
102
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
103
|
+
}
|
|
104
|
+
const { data, format } = await imageService.transform(inputBuffer, transform, imageConfig);
|
|
105
|
+
return new Response(data, {
|
|
106
|
+
status: 200,
|
|
107
|
+
headers: {
|
|
108
|
+
"Content-Type": mime.lookup(format) ?? `image/${format}`,
|
|
109
|
+
"Cache-Control": "public, max-age=31536000",
|
|
110
|
+
ETag: etag(data.toString()),
|
|
111
|
+
Date: (/* @__PURE__ */ new Date()).toUTCString()
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
} catch (err) {
|
|
115
|
+
console.error("Could not process image request:", err);
|
|
116
|
+
return new Response(
|
|
117
|
+
`Internal Server Error`,
|
|
118
|
+
{
|
|
119
|
+
status: 500
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
126
|
+
__proto__: null,
|
|
127
|
+
GET
|
|
128
|
+
}, Symbol.toStringTag, { value: 'Module' }));
|
|
129
|
+
|
|
130
|
+
const page = () => _page;
|
|
131
|
+
|
|
132
|
+
export { page };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Contents removed by Astro as it's used for prerendering only
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Contents removed by Astro as it's used for prerendering only
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Contents removed by Astro as it's used for prerendering only
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
export { renderers } from '../renderers.mjs';
|
|
4
|
+
|
|
5
|
+
const propsFilePath = join(process.cwd(), "dist", "props.json");
|
|
6
|
+
const propsData = readFileSync(propsFilePath);
|
|
7
|
+
const props = JSON.parse(propsData.toString());
|
|
8
|
+
const prerender = false;
|
|
9
|
+
async function GET({ request }) {
|
|
10
|
+
const queryParams = new URL(request.url).searchParams;
|
|
11
|
+
const components = queryParams.get("components");
|
|
12
|
+
const componentsArray = components?.split(",");
|
|
13
|
+
const propsData2 = componentsArray?.map((component) => props[component]);
|
|
14
|
+
return new Response(JSON.stringify(propsData2));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
18
|
+
__proto__: null,
|
|
19
|
+
GET,
|
|
20
|
+
prerender
|
|
21
|
+
}, Symbol.toStringTag, { value: 'Module' }));
|
|
22
|
+
|
|
23
|
+
const page = () => _page;
|
|
24
|
+
|
|
25
|
+
export { page };
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import React__default, { createElement } from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/server';
|
|
3
|
+
|
|
4
|
+
const contexts = new WeakMap();
|
|
5
|
+
|
|
6
|
+
const ID_PREFIX = 'r';
|
|
7
|
+
|
|
8
|
+
function getContext(rendererContextResult) {
|
|
9
|
+
if (contexts.has(rendererContextResult)) {
|
|
10
|
+
return contexts.get(rendererContextResult);
|
|
11
|
+
}
|
|
12
|
+
const ctx = {
|
|
13
|
+
currentIndex: 0,
|
|
14
|
+
get id() {
|
|
15
|
+
return ID_PREFIX + this.currentIndex.toString();
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
contexts.set(rendererContextResult, ctx);
|
|
19
|
+
return ctx;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function incrementId(rendererContextResult) {
|
|
23
|
+
const ctx = getContext(rendererContextResult);
|
|
24
|
+
const id = ctx.id;
|
|
25
|
+
ctx.currentIndex++;
|
|
26
|
+
return id;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Astro passes `children` as a string of HTML, so we need
|
|
31
|
+
* a wrapper `div` to render that content as VNodes.
|
|
32
|
+
*
|
|
33
|
+
* As a bonus, we can signal to React that this subtree is
|
|
34
|
+
* entirely static and will never change via `shouldComponentUpdate`.
|
|
35
|
+
*/
|
|
36
|
+
const StaticHtml = ({ value, name, hydrate = true }) => {
|
|
37
|
+
if (!value) return null;
|
|
38
|
+
const tagName = hydrate ? 'astro-slot' : 'astro-static-slot';
|
|
39
|
+
return createElement(tagName, {
|
|
40
|
+
name,
|
|
41
|
+
suppressHydrationWarning: true,
|
|
42
|
+
dangerouslySetInnerHTML: { __html: value },
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* This tells React to opt-out of re-rendering this subtree,
|
|
48
|
+
* In addition to being a performance optimization,
|
|
49
|
+
* this also allows other frameworks to attach to `children`.
|
|
50
|
+
*
|
|
51
|
+
* See https://preactjs.com/guide/v8/external-dom-mutations
|
|
52
|
+
*/
|
|
53
|
+
StaticHtml.shouldComponentUpdate = () => false;
|
|
54
|
+
|
|
55
|
+
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
|
|
56
|
+
const reactTypeof = Symbol.for('react.element');
|
|
57
|
+
const reactTransitionalTypeof = Symbol.for('react.transitional.element');
|
|
58
|
+
|
|
59
|
+
async function check(Component, props, children) {
|
|
60
|
+
// Note: there are packages that do some unholy things to create "components".
|
|
61
|
+
// Checking the $$typeof property catches most of these patterns.
|
|
62
|
+
if (typeof Component === 'object') {
|
|
63
|
+
return Component['$$typeof'].toString().slice('Symbol('.length).startsWith('react');
|
|
64
|
+
}
|
|
65
|
+
if (typeof Component !== 'function') return false;
|
|
66
|
+
if (Component.name === 'QwikComponent') return false;
|
|
67
|
+
|
|
68
|
+
// Preact forwarded-ref components can be functions, which React does not support
|
|
69
|
+
if (typeof Component === 'function' && Component['$$typeof'] === Symbol.for('react.forward_ref'))
|
|
70
|
+
return false;
|
|
71
|
+
|
|
72
|
+
if (Component.prototype != null && typeof Component.prototype.render === 'function') {
|
|
73
|
+
return React__default.Component.isPrototypeOf(Component) || React__default.PureComponent.isPrototypeOf(Component);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let isReactComponent = false;
|
|
77
|
+
function Tester(...args) {
|
|
78
|
+
try {
|
|
79
|
+
const vnode = Component(...args);
|
|
80
|
+
if (
|
|
81
|
+
vnode &&
|
|
82
|
+
(vnode['$$typeof'] === reactTypeof || vnode['$$typeof'] === reactTransitionalTypeof)
|
|
83
|
+
) {
|
|
84
|
+
isReactComponent = true;
|
|
85
|
+
}
|
|
86
|
+
} catch {}
|
|
87
|
+
|
|
88
|
+
return React__default.createElement('div');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
await renderToStaticMarkup(Tester, props, children, {});
|
|
92
|
+
|
|
93
|
+
return isReactComponent;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function getNodeWritable() {
|
|
97
|
+
let nodeStreamBuiltinModuleName = 'node:stream';
|
|
98
|
+
let { Writable } = await import(/* @vite-ignore */ nodeStreamBuiltinModuleName);
|
|
99
|
+
return Writable;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function needsHydration(metadata) {
|
|
103
|
+
// Adjust how this is hydrated only when the version of Astro supports `astroStaticSlot`
|
|
104
|
+
return metadata.astroStaticSlot ? !!metadata.hydrate : true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function renderToStaticMarkup(Component, props, { default: children, ...slotted }, metadata) {
|
|
108
|
+
let prefix;
|
|
109
|
+
if (this && this.result) {
|
|
110
|
+
prefix = incrementId(this.result);
|
|
111
|
+
}
|
|
112
|
+
const attrs = { prefix };
|
|
113
|
+
|
|
114
|
+
delete props['class'];
|
|
115
|
+
const slots = {};
|
|
116
|
+
for (const [key, value] of Object.entries(slotted)) {
|
|
117
|
+
const name = slotName(key);
|
|
118
|
+
slots[name] = React__default.createElement(StaticHtml, {
|
|
119
|
+
hydrate: needsHydration(metadata),
|
|
120
|
+
value,
|
|
121
|
+
name,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
// Note: create newProps to avoid mutating `props` before they are serialized
|
|
125
|
+
const newProps = {
|
|
126
|
+
...props,
|
|
127
|
+
...slots,
|
|
128
|
+
};
|
|
129
|
+
const newChildren = children ?? props.children;
|
|
130
|
+
if (newChildren != null) {
|
|
131
|
+
newProps.children = React__default.createElement(StaticHtml, {
|
|
132
|
+
hydrate: needsHydration(metadata),
|
|
133
|
+
value: newChildren,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
const formState = this ? await getFormState(this) : undefined;
|
|
137
|
+
if (formState) {
|
|
138
|
+
attrs['data-action-result'] = JSON.stringify(formState[0]);
|
|
139
|
+
attrs['data-action-key'] = formState[1];
|
|
140
|
+
attrs['data-action-name'] = formState[2];
|
|
141
|
+
}
|
|
142
|
+
const vnode = React__default.createElement(Component, newProps);
|
|
143
|
+
const renderOptions = {
|
|
144
|
+
identifierPrefix: prefix,
|
|
145
|
+
formState,
|
|
146
|
+
};
|
|
147
|
+
let html;
|
|
148
|
+
if ('renderToReadableStream' in ReactDOM) {
|
|
149
|
+
html = await renderToReadableStreamAsync(vnode, renderOptions);
|
|
150
|
+
} else {
|
|
151
|
+
html = await renderToPipeableStreamAsync(vnode, renderOptions);
|
|
152
|
+
}
|
|
153
|
+
return { html, attrs };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @returns {Promise<[actionResult: any, actionKey: string, actionName: string] | undefined>}
|
|
158
|
+
*/
|
|
159
|
+
async function getFormState({ result }) {
|
|
160
|
+
const { request, actionResult } = result;
|
|
161
|
+
|
|
162
|
+
if (!actionResult) return undefined;
|
|
163
|
+
if (!isFormRequest(request.headers.get('content-type'))) return undefined;
|
|
164
|
+
|
|
165
|
+
const { searchParams } = new URL(request.url);
|
|
166
|
+
const formData = await request.clone().formData();
|
|
167
|
+
/**
|
|
168
|
+
* The key generated by React to identify each `useActionState()` call.
|
|
169
|
+
* @example "k511f74df5a35d32e7cf266450d85cb6c"
|
|
170
|
+
*/
|
|
171
|
+
const actionKey = formData.get('$ACTION_KEY')?.toString();
|
|
172
|
+
/**
|
|
173
|
+
* The action name returned by an action's `toString()` property.
|
|
174
|
+
* This matches the endpoint path.
|
|
175
|
+
* @example "/_actions/blog.like"
|
|
176
|
+
*/
|
|
177
|
+
const actionName = searchParams.get('_action');
|
|
178
|
+
|
|
179
|
+
if (!actionKey || !actionName) return undefined;
|
|
180
|
+
|
|
181
|
+
return [actionResult, actionKey, actionName];
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
async function renderToPipeableStreamAsync(vnode, options) {
|
|
185
|
+
const Writable = await getNodeWritable();
|
|
186
|
+
let html = '';
|
|
187
|
+
return new Promise((resolve, reject) => {
|
|
188
|
+
let error = undefined;
|
|
189
|
+
let stream = ReactDOM.renderToPipeableStream(vnode, {
|
|
190
|
+
...options,
|
|
191
|
+
onError(err) {
|
|
192
|
+
error = err;
|
|
193
|
+
reject(error);
|
|
194
|
+
},
|
|
195
|
+
onAllReady() {
|
|
196
|
+
stream.pipe(
|
|
197
|
+
new Writable({
|
|
198
|
+
write(chunk, _encoding, callback) {
|
|
199
|
+
html += chunk.toString('utf-8');
|
|
200
|
+
callback();
|
|
201
|
+
},
|
|
202
|
+
destroy() {
|
|
203
|
+
resolve(html);
|
|
204
|
+
},
|
|
205
|
+
}),
|
|
206
|
+
);
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Use a while loop instead of "for await" due to cloudflare and Vercel Edge issues
|
|
214
|
+
* See https://github.com/facebook/react/issues/24169
|
|
215
|
+
*/
|
|
216
|
+
async function readResult(stream) {
|
|
217
|
+
const reader = stream.getReader();
|
|
218
|
+
let result = '';
|
|
219
|
+
const decoder = new TextDecoder('utf-8');
|
|
220
|
+
while (true) {
|
|
221
|
+
const { done, value } = await reader.read();
|
|
222
|
+
if (done) {
|
|
223
|
+
if (value) {
|
|
224
|
+
result += decoder.decode(value);
|
|
225
|
+
} else {
|
|
226
|
+
// This closes the decoder
|
|
227
|
+
decoder.decode(new Uint8Array());
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
result += decoder.decode(value, { stream: true });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
async function renderToReadableStreamAsync(vnode, options) {
|
|
237
|
+
return await readResult(await ReactDOM.renderToReadableStream(vnode, options));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const formContentTypes = ['application/x-www-form-urlencoded', 'multipart/form-data'];
|
|
241
|
+
|
|
242
|
+
function isFormRequest(contentType) {
|
|
243
|
+
// Split off parameters like charset or boundary
|
|
244
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type#content-type_in_html_forms
|
|
245
|
+
const type = contentType?.split(';')[0].toLowerCase();
|
|
246
|
+
|
|
247
|
+
return formContentTypes.some((t) => type === t);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const _renderer0 = {
|
|
251
|
+
name: '@astrojs/react',
|
|
252
|
+
check,
|
|
253
|
+
renderToStaticMarkup,
|
|
254
|
+
supportsAstroStaticSlot: true,
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const renderers = [Object.assign({"name":"@astrojs/react","clientEntrypoint":"@astrojs/react/client.js","serverEntrypoint":"@astrojs/react/server.js"}, { ssr: _renderer0 }),];
|
|
258
|
+
|
|
259
|
+
export { renderers };
|
package/jest.config.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/patternfly-doc-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"description": "PatternFly Core Documentation",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"build": "astro check && astro build",
|
|
13
13
|
"build:cli": "tsc --build ./cli/tsconfig.json",
|
|
14
14
|
"build:cli:watch": "tsc --build --watch ./cli/tsconfig.json",
|
|
15
|
+
"build:props": "npm run build:cli && node ./dist/cli/cli.js generate-props",
|
|
15
16
|
"preview": "astro preview",
|
|
16
17
|
"astro": "astro",
|
|
17
18
|
"prettier": "prettier --write ./src",
|
|
@@ -40,11 +41,13 @@
|
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@astrojs/check": "^0.9.4",
|
|
44
|
+
"@astrojs/node": "^9.1.3",
|
|
43
45
|
"@astrojs/react": "^4.2.1",
|
|
44
46
|
"@nanostores/react": "^0.8.0",
|
|
45
47
|
"@patternfly/patternfly": "^6.0.0",
|
|
46
48
|
"@patternfly/react-core": "^6.0.0",
|
|
47
49
|
"@patternfly/react-table": "^6.0.0",
|
|
50
|
+
"commander": "^13.1.0",
|
|
48
51
|
"@types/react": "^18.3.12",
|
|
49
52
|
"@types/react-dom": "^18.3.1",
|
|
50
53
|
"astro": "^5.4.1",
|
|
@@ -52,6 +55,7 @@
|
|
|
52
55
|
"glob": "^11.0.1",
|
|
53
56
|
"nanostores": "^0.11.3",
|
|
54
57
|
"react": "^18.3.1",
|
|
58
|
+
"react-docgen": "^7.1.1",
|
|
55
59
|
"react-dom": "^18.3.1",
|
|
56
60
|
"sass": "^1.81.0",
|
|
57
61
|
"typescript": "^5.6.3"
|
|
@@ -70,7 +74,6 @@
|
|
|
70
74
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
71
75
|
"@typescript-eslint/parser": "^8.17.0",
|
|
72
76
|
"babel-jest": "^29.7.0",
|
|
73
|
-
"commander": "^13.1.0",
|
|
74
77
|
"cz-conventional-changelog": "^3.3.0",
|
|
75
78
|
"eslint": "^9.16.0",
|
|
76
79
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const config = {
|
|
2
|
+
content: [
|
|
3
|
+
// example content entry for local content, this would feed all markdown files in the content directory to the
|
|
4
|
+
// documentation core with a content identifier of 'content':
|
|
5
|
+
// {
|
|
6
|
+
// base: 'content',
|
|
7
|
+
// pattern: "*.md",
|
|
8
|
+
// name: 'content'
|
|
9
|
+
// },
|
|
10
|
+
//
|
|
11
|
+
// example content entry for remote content, this would fetch all markdown files matching the glob in 'pattern'
|
|
12
|
+
// from the specified npm package and serve them with a content identifier of 'react-component-docs':
|
|
13
|
+
{
|
|
14
|
+
packageName: "@patternfly/react-core",
|
|
15
|
+
pattern: "**/components/**/*.md",
|
|
16
|
+
name: "react-component-docs",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
outputDir: './dist/docs',
|
|
20
|
+
propsGlobs: [
|
|
21
|
+
{
|
|
22
|
+
include: ['*/@patternfly/react-core/src/**/*.tsx'],
|
|
23
|
+
exclude: [
|
|
24
|
+
'/**/examples/**',
|
|
25
|
+
'/**/__mocks__/**',
|
|
26
|
+
'/**/__tests__/**',
|
|
27
|
+
'/**/*.test.tsx',
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
}
|
package/release.config.mjs
CHANGED
|
@@ -23,7 +23,7 @@ export type ComponentProp = {
|
|
|
23
23
|
description?: string
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
interface PropsTableProps extends React.HTMLProps<HTMLDivElement> {
|
|
27
27
|
componentName: string
|
|
28
28
|
headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
|
|
29
29
|
componentDescription?: string
|
|
@@ -76,7 +76,7 @@ export const PropsTable: React.FunctionComponent<PropsTableProps> = ({
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
return (
|
|
79
|
-
|
|
79
|
+
<div>
|
|
80
80
|
<SectionHeading>{componentName}</SectionHeading>
|
|
81
81
|
<Stack hasGutter>
|
|
82
82
|
{componentDescription && (
|
|
@@ -141,6 +141,6 @@ export const PropsTable: React.FunctionComponent<PropsTableProps> = ({
|
|
|
141
141
|
</>
|
|
142
142
|
)}
|
|
143
143
|
</Stack>
|
|
144
|
-
|
|
144
|
+
</div>
|
|
145
145
|
)
|
|
146
146
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { PropsTable } from './PropsTable'
|
|
3
|
+
|
|
4
|
+
async function getPropsData(propComponents?: string[]) {
|
|
5
|
+
if (!propComponents || propComponents.length === 0) {
|
|
6
|
+
return []
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const url = new URL(`/props?components=${propComponents}`, Astro.url)
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch(url)
|
|
13
|
+
const propsData = await response.json()
|
|
14
|
+
return propsData
|
|
15
|
+
} catch (e) {
|
|
16
|
+
// eslint-disable-next-line no-console
|
|
17
|
+
console.error(e)
|
|
18
|
+
return []
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { propComponents } = Astro.props
|
|
23
|
+
|
|
24
|
+
const propsData = await getPropsData(propComponents)
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
{
|
|
28
|
+
propsData
|
|
29
|
+
.filter((comp: any) => !!comp)
|
|
30
|
+
.map((component: any) => (
|
|
31
|
+
<PropsTable
|
|
32
|
+
key={component.name}
|
|
33
|
+
componentName={component.name}
|
|
34
|
+
componentDescription={component.description}
|
|
35
|
+
componentProps={component.props}
|
|
36
|
+
/>
|
|
37
|
+
))
|
|
38
|
+
}
|
package/src/content.config.ts
CHANGED
|
@@ -27,6 +27,7 @@ function defineContent(contentObj: CollectionDefinition) {
|
|
|
27
27
|
section: z.string(),
|
|
28
28
|
subsection: z.string().optional(),
|
|
29
29
|
title: z.string().optional(),
|
|
30
|
+
propComponents: z.array(z.string()).optional(),
|
|
30
31
|
tab: z.string().optional().default(tabMap[name])
|
|
31
32
|
}),
|
|
32
33
|
})
|
|
@@ -2,22 +2,29 @@
|
|
|
2
2
|
import { getCollection, render } from 'astro:content'
|
|
3
3
|
import { Title } from '@patternfly/react-core'
|
|
4
4
|
import MainLayout from '../../layouts/Main.astro'
|
|
5
|
-
import { content } from
|
|
5
|
+
import { content } from '../../content'
|
|
6
6
|
import { kebabCase } from 'change-case'
|
|
7
7
|
import { componentTabs } from '../../globals'
|
|
8
|
+
import PropsTables from '../../components/PropsTables.astro'
|
|
8
9
|
|
|
9
10
|
export async function getStaticPaths() {
|
|
10
|
-
const collections = await Promise.all(
|
|
11
|
+
const collections = await Promise.all(
|
|
12
|
+
content.map(
|
|
13
|
+
async (entry) => await getCollection(entry.name as 'textContent'),
|
|
14
|
+
),
|
|
15
|
+
)
|
|
11
16
|
|
|
12
17
|
return collections.flat().map((entry) => ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
params: { page: kebabCase(entry.data.id), section: entry.data.section },
|
|
19
|
+
props: {
|
|
20
|
+
entry,
|
|
21
|
+
title: entry.data.title,
|
|
22
|
+
propComponents: entry.data.propComponents,
|
|
23
|
+
},
|
|
24
|
+
}))
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
const { entry } = Astro.props
|
|
27
|
+
const { entry, propComponents } = Astro.props
|
|
21
28
|
const { title, id, section } = entry.data
|
|
22
29
|
const { Content } = await render(entry)
|
|
23
30
|
|
|
@@ -35,4 +42,5 @@ if(section === 'components') { // if section is components, rewrite to first tab
|
|
|
35
42
|
)
|
|
36
43
|
}
|
|
37
44
|
<Content />
|
|
45
|
+
<PropsTables propComponents={propComponents} server:defer />
|
|
38
46
|
</MainLayout>
|
|
@@ -5,6 +5,7 @@ import MainLayout from '../../../layouts/Main.astro'
|
|
|
5
5
|
import { content } from "../../../content"
|
|
6
6
|
import { kebabCase } from 'change-case'
|
|
7
7
|
import { componentTabs, tabNames, buildTab, sortTabs } from '../../../globals';
|
|
8
|
+
import PropsTables from '../../../components/PropsTables.astro'
|
|
8
9
|
|
|
9
10
|
export async function getStaticPaths() {
|
|
10
11
|
const collections = await Promise.all(content.map(async (entry) => await getCollection(entry.name as 'textContent')))
|
|
@@ -31,10 +32,11 @@ export async function getStaticPaths() {
|
|
|
31
32
|
return flatCol;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
const { entry } = Astro.props
|
|
35
|
+
const { entry, propComponents } = Astro.props
|
|
35
36
|
const { title, id, section } = entry.data
|
|
36
37
|
const { Content } = await render(entry)
|
|
37
38
|
const currentPath = Astro.url.pathname;
|
|
39
|
+
|
|
38
40
|
---
|
|
39
41
|
|
|
40
42
|
<MainLayout>
|
|
@@ -66,6 +68,7 @@ const currentPath = Astro.url.pathname;
|
|
|
66
68
|
<PageSection id="main-content" isFilled>
|
|
67
69
|
<PFContent>
|
|
68
70
|
<Content />
|
|
71
|
+
<PropsTables propComponents={propComponents} server:defer />
|
|
69
72
|
</PFContent>
|
|
70
73
|
</PageSection>
|
|
71
74
|
</MainLayout>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { readFileSync } from 'fs'
|
|
2
|
+
import { join } from 'path'
|
|
3
|
+
|
|
4
|
+
const propsFilePath = join(process.cwd(), 'dist', 'props.json')
|
|
5
|
+
const propsData = readFileSync(propsFilePath)
|
|
6
|
+
const props = JSON.parse(propsData.toString())
|
|
7
|
+
|
|
8
|
+
export const prerender = false
|
|
9
|
+
|
|
10
|
+
export async function GET({ request }: { request: Request }) {
|
|
11
|
+
const queryParams = new URL(request.url).searchParams
|
|
12
|
+
const components = queryParams.get('components')
|
|
13
|
+
const componentsArray = components?.split(',')
|
|
14
|
+
const propsData = componentsArray?.map((component) => props[component])
|
|
15
|
+
|
|
16
|
+
return new Response(JSON.stringify(propsData))
|
|
17
|
+
}
|