@djangocfg/ui-tools 2.1.289 → 2.1.290
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/README.md +14 -3
- package/dist/{DocsLayout-YDR7DSMM.cjs → DocsLayout-IKH7BLSU.cjs} +1537 -682
- package/dist/DocsLayout-IKH7BLSU.cjs.map +1 -0
- package/dist/{DocsLayout-TKJQ5W5E.mjs → DocsLayout-JPXFUKAR.mjs} +1429 -574
- package/dist/DocsLayout-JPXFUKAR.mjs.map +1 -0
- package/dist/{PrettyCode.client-5GABIN2I.cjs → PrettyCode.client-RPDIE5CH.cjs} +104 -3
- package/dist/PrettyCode.client-RPDIE5CH.cjs.map +1 -0
- package/dist/{PrettyCode.client-IZTXXYHG.mjs → PrettyCode.client-SPMTQEG4.mjs} +106 -5
- package/dist/PrettyCode.client-SPMTQEG4.mjs.map +1 -0
- package/dist/{chunk-IULI4XII.cjs → chunk-5Q4UMSWB.cjs} +355 -9
- package/dist/chunk-5Q4UMSWB.cjs.map +1 -0
- package/dist/{chunk-VZGQC3NG.mjs → chunk-EFWOJPA6.mjs} +349 -9
- package/dist/chunk-EFWOJPA6.mjs.map +1 -0
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -14
- package/src/components/markdown/MarkdownMessage.tsx +46 -0
- package/src/tools/OpenapiViewer/OpenapiViewer.story.tsx +87 -178
- package/src/tools/OpenapiViewer/README.md +114 -6
- package/src/tools/OpenapiViewer/components/DocsLayout/ApiIntroSection.tsx +20 -6
- package/src/tools/OpenapiViewer/components/DocsLayout/DocsView.tsx +6 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/CodeSamples/LanguageTabs.tsx +36 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/CodeSamples/index.tsx +56 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/CodeSamples/useCodeSnippet.ts +77 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Header/MetaActions.tsx +146 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Header/MethodBadge.tsx +6 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Header/PathDisplay.tsx +26 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Header/index.tsx +87 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Parameters/ParamGroup.tsx +30 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Parameters/ParamRow.tsx +36 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Parameters/index.tsx +22 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/RequestBody/index.tsx +33 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Responses/ResponseBody.tsx +76 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Responses/ResponseRow.tsx +80 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Responses/StatusTag.tsx +32 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Responses/index.tsx +21 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/SchemaFields/FieldRow.tsx +106 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/SchemaFields/buildTree.ts +127 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/SchemaFields/index.tsx +31 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/SchemaFields/types.ts +28 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Section/SectionHeader.tsx +87 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Section/defaults.ts +27 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/Section/index.tsx +45 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/context.tsx +56 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/hooks/useSectionHash.ts +63 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/index.tsx +96 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/store/index.ts +133 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/store/selectors.ts +40 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/types.ts +17 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/SchemaCopyMenu.tsx +8 -2
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/BrandHeader.tsx +48 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/CategoryBlock.tsx +33 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/EndpointRow.tsx +73 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/MethodChips.tsx +43 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/SchemaSection.tsx +27 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/SearchInput.tsx +45 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/SidebarBody.tsx +50 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/Toolbar.tsx +64 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/buildVM.ts +126 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/index.tsx +112 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/types.ts +42 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar/useDebouncedValue.ts +14 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/SlideInPlayground.tsx +10 -7
- package/src/tools/OpenapiViewer/components/DocsLayout/TryItSheet.tsx +9 -6
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/PrettyView.tsx +55 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/PreviewView.tsx +115 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/RawView.tsx +24 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/StatusBar.tsx +63 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/ViewTabs.tsx +45 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/detectContent.ts +97 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/index.tsx +93 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/types.ts +26 -0
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel/useResponseView.ts +62 -0
- package/src/tools/OpenapiViewer/hooks/useOpenApiSchema.ts +41 -71
- package/src/tools/OpenapiViewer/types.ts +10 -0
- package/src/tools/OpenapiViewer/utils/codeSamples.ts +287 -0
- package/src/tools/OpenapiViewer/utils/index.ts +3 -0
- package/src/tools/OpenapiViewer/utils/operationToHar.ts +119 -0
- package/src/tools/OpenapiViewer/utils/sampler.ts +72 -0
- package/src/tools/PrettyCode/PrettyCode.client.tsx +88 -1
- package/src/tools/PrettyCode/PrettyCode.story.tsx +114 -361
- package/src/tools/PrettyCode/index.tsx +13 -0
- package/src/tools/PrettyCode/lazy.tsx +5 -0
- package/src/tools/PrettyCode/registerPrismLanguages.ts +111 -0
- package/dist/DocsLayout-TKJQ5W5E.mjs.map +0 -1
- package/dist/DocsLayout-YDR7DSMM.cjs.map +0 -1
- package/dist/PrettyCode.client-5GABIN2I.cjs.map +0 -1
- package/dist/PrettyCode.client-IZTXXYHG.mjs.map +0 -1
- package/dist/chunk-IULI4XII.cjs.map +0 -1
- package/dist/chunk-VZGQC3NG.mjs.map +0 -1
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc.tsx +0 -273
- package/src/tools/OpenapiViewer/components/DocsLayout/Sidebar.tsx +0 -439
- package/src/tools/OpenapiViewer/components/shared/ResponsePanel.tsx +0 -127
|
@@ -8,6 +8,13 @@ import { useResolvedTheme } from '@djangocfg/ui-core/hooks';
|
|
|
8
8
|
import { FloatingToolbar } from '../../components/FloatingToolbar';
|
|
9
9
|
import { CopyAction } from '../../components/FloatingToolbar/actions';
|
|
10
10
|
|
|
11
|
+
// Load extra Prism grammars (``bash``, ``ruby``, ``java``, ``php``)
|
|
12
|
+
// that aren't in ``prism-react-renderer``'s default bundle. The hook
|
|
13
|
+
// below subscribes to its ready state and re-renders this component
|
|
14
|
+
// once loading completes, so the first tab click gets highlighted
|
|
15
|
+
// correctly even if it happened before the dynamic import resolved.
|
|
16
|
+
import { useEnsurePrismLanguages } from './registerPrismLanguages';
|
|
17
|
+
|
|
11
18
|
interface PrettyCodeProps {
|
|
12
19
|
data: string | object;
|
|
13
20
|
language: Language;
|
|
@@ -23,13 +30,24 @@ interface PrettyCodeProps {
|
|
|
23
30
|
* Set e.g. ``50`` to cap short snippets inline and scroll long ones.
|
|
24
31
|
*/
|
|
25
32
|
maxLines?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Visual variant. ``"card"`` (default) ships full chrome (border,
|
|
35
|
+
* background, hover toolbar, optional internal scroll). ``"plain"``
|
|
36
|
+
* is chrome-less — use when embedding inside another scroll
|
|
37
|
+
* container so the surface manages its own chrome and scroll. */
|
|
38
|
+
variant?: 'card' | 'plain';
|
|
26
39
|
}
|
|
27
40
|
|
|
28
|
-
const PrettyCode = ({ data, language, className, mode, inline = false, customBg, isCompact = false, scrollIsolation, maxLines }: PrettyCodeProps) => {
|
|
41
|
+
const PrettyCode = ({ data, language, className, mode, inline = false, customBg, isCompact = false, scrollIsolation, maxLines, variant = 'card' }: PrettyCodeProps) => {
|
|
29
42
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
30
43
|
const t = useAppT();
|
|
31
44
|
const detectedTheme = useResolvedTheme();
|
|
32
45
|
|
|
46
|
+
// Subscribe to the extra-grammars ready state. When ``bash`` /
|
|
47
|
+
// ``ruby`` / ``java`` / ``php`` finish loading, this hook triggers a
|
|
48
|
+
// re-render so the code block picks up the new grammar.
|
|
49
|
+
useEnsurePrismLanguages();
|
|
50
|
+
|
|
33
51
|
const labels = useMemo(() => ({
|
|
34
52
|
copyCode: t('tools.code.copyCode'),
|
|
35
53
|
noContent: t('tools.code.noContent'),
|
|
@@ -110,6 +128,16 @@ const PrettyCode = ({ data, language, className, mode, inline = false, customBg,
|
|
|
110
128
|
return 'Text';
|
|
111
129
|
case 'mermaid':
|
|
112
130
|
return 'Mermaid';
|
|
131
|
+
case 'ruby':
|
|
132
|
+
case 'rb':
|
|
133
|
+
return 'Ruby';
|
|
134
|
+
case 'java':
|
|
135
|
+
return 'Java';
|
|
136
|
+
case 'php':
|
|
137
|
+
return 'PHP';
|
|
138
|
+
case 'go':
|
|
139
|
+
case 'golang':
|
|
140
|
+
return 'Go';
|
|
113
141
|
default:
|
|
114
142
|
return lang.charAt(0).toUpperCase() + lang.slice(1);
|
|
115
143
|
}
|
|
@@ -140,7 +168,18 @@ const PrettyCode = ({ data, language, className, mode, inline = false, customBg,
|
|
|
140
168
|
return 'markup';
|
|
141
169
|
case 'bash':
|
|
142
170
|
case 'shell':
|
|
171
|
+
case 'sh':
|
|
143
172
|
return 'bash';
|
|
173
|
+
case 'ruby':
|
|
174
|
+
case 'rb':
|
|
175
|
+
return 'ruby';
|
|
176
|
+
case 'java':
|
|
177
|
+
return 'java';
|
|
178
|
+
case 'php':
|
|
179
|
+
return 'php';
|
|
180
|
+
case 'go':
|
|
181
|
+
case 'golang':
|
|
182
|
+
return 'go';
|
|
144
183
|
case 'sql':
|
|
145
184
|
return 'sql';
|
|
146
185
|
case 'yaml':
|
|
@@ -160,6 +199,54 @@ const PrettyCode = ({ data, language, className, mode, inline = false, customBg,
|
|
|
160
199
|
|
|
161
200
|
const displayLanguage = getLanguageDisplayName(language);
|
|
162
201
|
|
|
202
|
+
// Plain variant — chrome-less render for embedding inside other
|
|
203
|
+
// scroll containers. No border, no background, no hover toolbar, no
|
|
204
|
+
// internal scroll. The caller's ScrollArea/panel owns the chrome
|
|
205
|
+
// and scroll responsibilities.
|
|
206
|
+
if (variant === 'plain') {
|
|
207
|
+
return (
|
|
208
|
+
<Highlight theme={prismTheme} code={contentJson} language={normalizedLanguage as Language}>
|
|
209
|
+
{({ className: prismClassName, style, tokens, getLineProps, getTokenProps }) => {
|
|
210
|
+
const { backgroundColor: _bg, ...restStyle } = style;
|
|
211
|
+
return (
|
|
212
|
+
<pre
|
|
213
|
+
className={`${prismClassName} ${className || ''}`}
|
|
214
|
+
style={{
|
|
215
|
+
...restStyle,
|
|
216
|
+
background: 'transparent',
|
|
217
|
+
margin: 0,
|
|
218
|
+
padding: isCompact ? '0.75rem 1rem' : '1rem',
|
|
219
|
+
fontSize,
|
|
220
|
+
lineHeight: lineHeightRatio,
|
|
221
|
+
fontFamily: 'monospace',
|
|
222
|
+
// ``break-all`` (not ``break-word``) so long unbroken
|
|
223
|
+
// strings without whitespace — typical of escaped
|
|
224
|
+
// JSON bodies in generated code samples — wrap at any
|
|
225
|
+
// character rather than overflowing the container.
|
|
226
|
+
whiteSpace: 'pre-wrap',
|
|
227
|
+
wordBreak: 'break-all',
|
|
228
|
+
overflowWrap: 'anywhere',
|
|
229
|
+
// Hard cap on width — parents (grid cells, panels)
|
|
230
|
+
// should constrain us but some callers render inside
|
|
231
|
+
// ``flex: 1 1 auto`` which lets the pre grow past
|
|
232
|
+
// intended bounds. ``max-width: 100%`` pins to parent.
|
|
233
|
+
maxWidth: '100%',
|
|
234
|
+
}}
|
|
235
|
+
>
|
|
236
|
+
{tokens.map((line, i) => (
|
|
237
|
+
<div key={i} {...getLineProps({ line })}>
|
|
238
|
+
{line.map((token, key) => (
|
|
239
|
+
<span key={key} {...getTokenProps({ token })} />
|
|
240
|
+
))}
|
|
241
|
+
</div>
|
|
242
|
+
))}
|
|
243
|
+
</pre>
|
|
244
|
+
);
|
|
245
|
+
}}
|
|
246
|
+
</Highlight>
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
|
|
163
250
|
if (inline) {
|
|
164
251
|
const inlineBgClass = customBg || (isDarkMode ? 'bg-zinc-800' : 'bg-zinc-100');
|
|
165
252
|
return (
|