jamdesk 1.1.82 → 1.1.83
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jamdesk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.83",
|
|
4
4
|
"description": "CLI for Jamdesk — build, preview, and deploy documentation sites from MDX. Dev server with hot reload, 50+ components, OpenAPI support, AI search, and Mintlify migration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jamdesk",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { ReactNode, Children, cloneElement, isValidElement, memo } from 'react';
|
|
3
|
+
import { ReactElement, ReactNode, Children, cloneElement, isValidElement, memo } from 'react';
|
|
4
4
|
import { getIconClass } from '@/lib/icon-utils';
|
|
5
5
|
import { useStepSlug } from './StepSlugContext';
|
|
6
6
|
|
|
@@ -22,19 +22,34 @@ interface StepProps {
|
|
|
22
22
|
titleSize?: TitleSize;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
// Helper to check if a child is a Step component
|
|
26
|
-
// MDX can wrap components so we check displayName or function name
|
|
27
25
|
function isStepComponent(child: unknown): boolean {
|
|
28
26
|
if (!isValidElement(child)) return false;
|
|
29
27
|
const type = child.type as { displayName?: string; name?: string };
|
|
30
|
-
const props = child.props as { title?: unknown; children?: unknown };
|
|
31
|
-
// Check for Step by displayName, name, or if it has children (Step-like)
|
|
32
28
|
return (
|
|
33
29
|
type === Step ||
|
|
34
30
|
type?.displayName === 'Step' ||
|
|
35
|
-
type?.name === 'Step'
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
type?.name === 'Step'
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Non-Step element children render as plain text inside <Steps> with no step
|
|
36
|
+
// circle/number — surface them in dev so authors notice the silent fallback.
|
|
37
|
+
function warnAboutNonStepChildren(childrenArray: readonly unknown[]): void {
|
|
38
|
+
if (process.env.NODE_ENV === 'production') return;
|
|
39
|
+
const offenders = childrenArray.filter(
|
|
40
|
+
(c): c is ReactElement => isValidElement(c) && !isStepComponent(c),
|
|
41
|
+
);
|
|
42
|
+
if (offenders.length === 0) return;
|
|
43
|
+
const labels = offenders.map((c) => {
|
|
44
|
+
const t = c.type;
|
|
45
|
+
if (typeof t === 'string') return `<${t}>`;
|
|
46
|
+
const named = t as { displayName?: string; name?: string };
|
|
47
|
+
return named?.displayName ?? named?.name ?? 'Component';
|
|
48
|
+
});
|
|
49
|
+
console.warn(
|
|
50
|
+
`<Steps> received non-<Step> children: ${labels.join(', ')}. ` +
|
|
51
|
+
'Wrap each step in `<Step title="…">…</Step>` so it renders as a numbered ' +
|
|
52
|
+
'step. Markdown headings inside <Steps> render as plain text.',
|
|
38
53
|
);
|
|
39
54
|
}
|
|
40
55
|
|
|
@@ -42,11 +57,12 @@ export const Steps = memo(function Steps({ children, titleSize = 'p' }: StepsPro
|
|
|
42
57
|
const childrenArray = Children.toArray(children);
|
|
43
58
|
const stepChildren = childrenArray.filter(isStepComponent);
|
|
44
59
|
const totalSteps = stepChildren.length;
|
|
60
|
+
warnAboutNonStepChildren(childrenArray);
|
|
45
61
|
|
|
46
62
|
let stepIndex = 0;
|
|
47
63
|
return (
|
|
48
64
|
<div className="relative my-8 space-y-0 not-prose">
|
|
49
|
-
{childrenArray.map((child
|
|
65
|
+
{childrenArray.map((child) => {
|
|
50
66
|
if (isStepComponent(child)) {
|
|
51
67
|
const childProps = (child as any).props as StepProps;
|
|
52
68
|
const currentStepIndex = stepIndex;
|