@stoplight/elements-core 7.7.5 → 7.7.7
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/index.esm.js +43 -11
- package/index.js +43 -11
- package/index.mjs +43 -11
- package/package.json +2 -2
- package/utils/exampleGeneration/exampleGeneration.d.ts +1 -1
package/index.esm.js
CHANGED
|
@@ -1238,13 +1238,14 @@ function ExampleMenu({ examples, requestBody, onChange }) {
|
|
|
1238
1238
|
return (React.createElement(Menu, { "aria-label": "Examples", items: menuItems, renderTrigger: ({ isOpen }) => (React.createElement(Button, { appearance: "minimal", size: "sm", iconRight: ['fas', 'sort'], active: isOpen }, "Examples")) }));
|
|
1239
1239
|
}
|
|
1240
1240
|
|
|
1241
|
-
const useGenerateExampleFromMediaTypeContent = (mediaTypeContent, chosenExampleIndex, { skipReadOnly, skipWriteOnly, skipNonRequired } = {}) => {
|
|
1241
|
+
const useGenerateExampleFromMediaTypeContent = (mediaTypeContent, chosenExampleIndex, { skipReadOnly, skipWriteOnly, skipNonRequired, ticks } = {}) => {
|
|
1242
1242
|
const document = useDocument();
|
|
1243
1243
|
return React__default.useMemo(() => generateExampleFromMediaTypeContent(mediaTypeContent, document, chosenExampleIndex, {
|
|
1244
1244
|
skipNonRequired,
|
|
1245
1245
|
skipWriteOnly,
|
|
1246
1246
|
skipReadOnly,
|
|
1247
|
-
|
|
1247
|
+
ticks: ticks || 6000,
|
|
1248
|
+
}), [mediaTypeContent, document, chosenExampleIndex, skipNonRequired, skipWriteOnly, skipReadOnly, ticks]);
|
|
1248
1249
|
};
|
|
1249
1250
|
const generateExampleFromMediaTypeContent = (mediaTypeContent, document, chosenExampleIndex = 0, options) => {
|
|
1250
1251
|
var _a, _b;
|
|
@@ -1294,6 +1295,7 @@ const generateExamplesFromJsonSchema = (schema) => {
|
|
|
1294
1295
|
try {
|
|
1295
1296
|
const generated = Sampler.sample(schema, {
|
|
1296
1297
|
maxSampleDepth: 4,
|
|
1298
|
+
ticks: 6000,
|
|
1297
1299
|
});
|
|
1298
1300
|
return generated !== null
|
|
1299
1301
|
? [
|
|
@@ -2605,23 +2607,53 @@ const ParsedDocs = (_a) => {
|
|
|
2605
2607
|
};
|
|
2606
2608
|
|
|
2607
2609
|
const MAX_CONTENT_WIDTH = 1800;
|
|
2608
|
-
const
|
|
2609
|
-
const
|
|
2610
|
+
const SIDEBAR_MIN_WIDTH = 300;
|
|
2611
|
+
const SIDEBAR_MAX_WIDTH = 1.5 * SIDEBAR_MIN_WIDTH;
|
|
2612
|
+
const SidebarLayout = React.forwardRef(({ sidebar, children, maxContentWidth = MAX_CONTENT_WIDTH, sidebarWidth = SIDEBAR_MIN_WIDTH }, ref) => {
|
|
2610
2613
|
const scrollRef = React.useRef(null);
|
|
2614
|
+
const [sidebarRef, currentSidebarWidth, startResizing] = useResizer(sidebarWidth);
|
|
2611
2615
|
const { pathname } = useLocation();
|
|
2612
2616
|
React.useEffect(() => {
|
|
2613
2617
|
var _a;
|
|
2614
2618
|
(_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
|
|
2615
2619
|
}, [pathname]);
|
|
2616
2620
|
return (React.createElement(Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
|
|
2617
|
-
React.createElement(Flex, {
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2621
|
+
React.createElement(Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH}px` } },
|
|
2622
|
+
React.createElement(Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
|
|
2623
|
+
paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
|
|
2624
|
+
width: `${currentSidebarWidth}px`,
|
|
2625
|
+
minWidth: `${SIDEBAR_MIN_WIDTH}px`,
|
|
2626
|
+
} }, sidebar),
|
|
2627
|
+
React.createElement(Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } })),
|
|
2622
2628
|
React.createElement(Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full", overflowY: "auto" },
|
|
2623
|
-
React.createElement(Box, { style: { maxWidth: `${maxContentWidth -
|
|
2624
|
-
});
|
|
2629
|
+
React.createElement(Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
|
|
2630
|
+
});
|
|
2631
|
+
function useResizer(sidebarWidth) {
|
|
2632
|
+
const sidebarRef = React.useRef(null);
|
|
2633
|
+
const [isResizing, setIsResizing] = React.useState(false);
|
|
2634
|
+
const [currentSidebarWidth, setCurrentSidebarWidth] = React.useState(sidebarWidth);
|
|
2635
|
+
const startResizing = React.useCallback(() => {
|
|
2636
|
+
setIsResizing(true);
|
|
2637
|
+
}, []);
|
|
2638
|
+
const stopResizing = React.useCallback(() => {
|
|
2639
|
+
setIsResizing(false);
|
|
2640
|
+
}, []);
|
|
2641
|
+
const resize = React.useCallback(mouseMoveEvent => {
|
|
2642
|
+
if (isResizing) {
|
|
2643
|
+
const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
|
|
2644
|
+
setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH, value), SIDEBAR_MAX_WIDTH));
|
|
2645
|
+
}
|
|
2646
|
+
}, [isResizing]);
|
|
2647
|
+
React.useEffect(() => {
|
|
2648
|
+
window.addEventListener('mousemove', resize);
|
|
2649
|
+
window.addEventListener('mouseup', stopResizing, { passive: true });
|
|
2650
|
+
return () => {
|
|
2651
|
+
window.removeEventListener('mousemove', resize);
|
|
2652
|
+
window.removeEventListener('mouseup', stopResizing);
|
|
2653
|
+
};
|
|
2654
|
+
}, [resize, stopResizing]);
|
|
2655
|
+
return [sidebarRef, currentSidebarWidth, startResizing];
|
|
2656
|
+
}
|
|
2625
2657
|
|
|
2626
2658
|
const Logo = ({ logo }) => {
|
|
2627
2659
|
var _a;
|
package/index.js
CHANGED
|
@@ -1292,13 +1292,14 @@ function ExampleMenu({ examples, requestBody, onChange }) {
|
|
|
1292
1292
|
return (React__namespace.createElement(mosaic.Menu, { "aria-label": "Examples", items: menuItems, renderTrigger: ({ isOpen }) => (React__namespace.createElement(mosaic.Button, { appearance: "minimal", size: "sm", iconRight: ['fas', 'sort'], active: isOpen }, "Examples")) }));
|
|
1293
1293
|
}
|
|
1294
1294
|
|
|
1295
|
-
const useGenerateExampleFromMediaTypeContent = (mediaTypeContent, chosenExampleIndex, { skipReadOnly, skipWriteOnly, skipNonRequired } = {}) => {
|
|
1295
|
+
const useGenerateExampleFromMediaTypeContent = (mediaTypeContent, chosenExampleIndex, { skipReadOnly, skipWriteOnly, skipNonRequired, ticks } = {}) => {
|
|
1296
1296
|
const document = useDocument();
|
|
1297
1297
|
return React__default["default"].useMemo(() => generateExampleFromMediaTypeContent(mediaTypeContent, document, chosenExampleIndex, {
|
|
1298
1298
|
skipNonRequired,
|
|
1299
1299
|
skipWriteOnly,
|
|
1300
1300
|
skipReadOnly,
|
|
1301
|
-
|
|
1301
|
+
ticks: ticks || 6000,
|
|
1302
|
+
}), [mediaTypeContent, document, chosenExampleIndex, skipNonRequired, skipWriteOnly, skipReadOnly, ticks]);
|
|
1302
1303
|
};
|
|
1303
1304
|
const generateExampleFromMediaTypeContent = (mediaTypeContent, document, chosenExampleIndex = 0, options) => {
|
|
1304
1305
|
var _a, _b;
|
|
@@ -1348,6 +1349,7 @@ const generateExamplesFromJsonSchema = (schema) => {
|
|
|
1348
1349
|
try {
|
|
1349
1350
|
const generated = Sampler__namespace.sample(schema, {
|
|
1350
1351
|
maxSampleDepth: 4,
|
|
1352
|
+
ticks: 6000,
|
|
1351
1353
|
});
|
|
1352
1354
|
return generated !== null
|
|
1353
1355
|
? [
|
|
@@ -2659,23 +2661,53 @@ const ParsedDocs = (_a) => {
|
|
|
2659
2661
|
};
|
|
2660
2662
|
|
|
2661
2663
|
const MAX_CONTENT_WIDTH = 1800;
|
|
2662
|
-
const
|
|
2663
|
-
const
|
|
2664
|
+
const SIDEBAR_MIN_WIDTH = 300;
|
|
2665
|
+
const SIDEBAR_MAX_WIDTH = 1.5 * SIDEBAR_MIN_WIDTH;
|
|
2666
|
+
const SidebarLayout = React__namespace.forwardRef(({ sidebar, children, maxContentWidth = MAX_CONTENT_WIDTH, sidebarWidth = SIDEBAR_MIN_WIDTH }, ref) => {
|
|
2664
2667
|
const scrollRef = React__namespace.useRef(null);
|
|
2668
|
+
const [sidebarRef, currentSidebarWidth, startResizing] = useResizer(sidebarWidth);
|
|
2665
2669
|
const { pathname } = reactRouterDom.useLocation();
|
|
2666
2670
|
React__namespace.useEffect(() => {
|
|
2667
2671
|
var _a;
|
|
2668
2672
|
(_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
|
|
2669
2673
|
}, [pathname]);
|
|
2670
2674
|
return (React__namespace.createElement(mosaic.Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
|
|
2671
|
-
React__namespace.createElement(mosaic.Flex, {
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2675
|
+
React__namespace.createElement(mosaic.Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH}px` } },
|
|
2676
|
+
React__namespace.createElement(mosaic.Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
|
|
2677
|
+
paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
|
|
2678
|
+
width: `${currentSidebarWidth}px`,
|
|
2679
|
+
minWidth: `${SIDEBAR_MIN_WIDTH}px`,
|
|
2680
|
+
} }, sidebar),
|
|
2681
|
+
React__namespace.createElement(mosaic.Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } })),
|
|
2676
2682
|
React__namespace.createElement(mosaic.Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full", overflowY: "auto" },
|
|
2677
|
-
React__namespace.createElement(mosaic.Box, { style: { maxWidth: `${maxContentWidth -
|
|
2678
|
-
});
|
|
2683
|
+
React__namespace.createElement(mosaic.Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
|
|
2684
|
+
});
|
|
2685
|
+
function useResizer(sidebarWidth) {
|
|
2686
|
+
const sidebarRef = React__namespace.useRef(null);
|
|
2687
|
+
const [isResizing, setIsResizing] = React__namespace.useState(false);
|
|
2688
|
+
const [currentSidebarWidth, setCurrentSidebarWidth] = React__namespace.useState(sidebarWidth);
|
|
2689
|
+
const startResizing = React__namespace.useCallback(() => {
|
|
2690
|
+
setIsResizing(true);
|
|
2691
|
+
}, []);
|
|
2692
|
+
const stopResizing = React__namespace.useCallback(() => {
|
|
2693
|
+
setIsResizing(false);
|
|
2694
|
+
}, []);
|
|
2695
|
+
const resize = React__namespace.useCallback(mouseMoveEvent => {
|
|
2696
|
+
if (isResizing) {
|
|
2697
|
+
const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
|
|
2698
|
+
setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH, value), SIDEBAR_MAX_WIDTH));
|
|
2699
|
+
}
|
|
2700
|
+
}, [isResizing]);
|
|
2701
|
+
React__namespace.useEffect(() => {
|
|
2702
|
+
window.addEventListener('mousemove', resize);
|
|
2703
|
+
window.addEventListener('mouseup', stopResizing, { passive: true });
|
|
2704
|
+
return () => {
|
|
2705
|
+
window.removeEventListener('mousemove', resize);
|
|
2706
|
+
window.removeEventListener('mouseup', stopResizing);
|
|
2707
|
+
};
|
|
2708
|
+
}, [resize, stopResizing]);
|
|
2709
|
+
return [sidebarRef, currentSidebarWidth, startResizing];
|
|
2710
|
+
}
|
|
2679
2711
|
|
|
2680
2712
|
const Logo = ({ logo }) => {
|
|
2681
2713
|
var _a;
|
package/index.mjs
CHANGED
|
@@ -1238,13 +1238,14 @@ function ExampleMenu({ examples, requestBody, onChange }) {
|
|
|
1238
1238
|
return (React.createElement(Menu, { "aria-label": "Examples", items: menuItems, renderTrigger: ({ isOpen }) => (React.createElement(Button, { appearance: "minimal", size: "sm", iconRight: ['fas', 'sort'], active: isOpen }, "Examples")) }));
|
|
1239
1239
|
}
|
|
1240
1240
|
|
|
1241
|
-
const useGenerateExampleFromMediaTypeContent = (mediaTypeContent, chosenExampleIndex, { skipReadOnly, skipWriteOnly, skipNonRequired } = {}) => {
|
|
1241
|
+
const useGenerateExampleFromMediaTypeContent = (mediaTypeContent, chosenExampleIndex, { skipReadOnly, skipWriteOnly, skipNonRequired, ticks } = {}) => {
|
|
1242
1242
|
const document = useDocument();
|
|
1243
1243
|
return React__default.useMemo(() => generateExampleFromMediaTypeContent(mediaTypeContent, document, chosenExampleIndex, {
|
|
1244
1244
|
skipNonRequired,
|
|
1245
1245
|
skipWriteOnly,
|
|
1246
1246
|
skipReadOnly,
|
|
1247
|
-
|
|
1247
|
+
ticks: ticks || 6000,
|
|
1248
|
+
}), [mediaTypeContent, document, chosenExampleIndex, skipNonRequired, skipWriteOnly, skipReadOnly, ticks]);
|
|
1248
1249
|
};
|
|
1249
1250
|
const generateExampleFromMediaTypeContent = (mediaTypeContent, document, chosenExampleIndex = 0, options) => {
|
|
1250
1251
|
var _a, _b;
|
|
@@ -1294,6 +1295,7 @@ const generateExamplesFromJsonSchema = (schema) => {
|
|
|
1294
1295
|
try {
|
|
1295
1296
|
const generated = Sampler.sample(schema, {
|
|
1296
1297
|
maxSampleDepth: 4,
|
|
1298
|
+
ticks: 6000,
|
|
1297
1299
|
});
|
|
1298
1300
|
return generated !== null
|
|
1299
1301
|
? [
|
|
@@ -2605,23 +2607,53 @@ const ParsedDocs = (_a) => {
|
|
|
2605
2607
|
};
|
|
2606
2608
|
|
|
2607
2609
|
const MAX_CONTENT_WIDTH = 1800;
|
|
2608
|
-
const
|
|
2609
|
-
const
|
|
2610
|
+
const SIDEBAR_MIN_WIDTH = 300;
|
|
2611
|
+
const SIDEBAR_MAX_WIDTH = 1.5 * SIDEBAR_MIN_WIDTH;
|
|
2612
|
+
const SidebarLayout = React.forwardRef(({ sidebar, children, maxContentWidth = MAX_CONTENT_WIDTH, sidebarWidth = SIDEBAR_MIN_WIDTH }, ref) => {
|
|
2610
2613
|
const scrollRef = React.useRef(null);
|
|
2614
|
+
const [sidebarRef, currentSidebarWidth, startResizing] = useResizer(sidebarWidth);
|
|
2611
2615
|
const { pathname } = useLocation();
|
|
2612
2616
|
React.useEffect(() => {
|
|
2613
2617
|
var _a;
|
|
2614
2618
|
(_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo(0, 0);
|
|
2615
2619
|
}, [pathname]);
|
|
2616
2620
|
return (React.createElement(Flex, { ref: ref, className: "sl-elements-api", pin: true, h: "full" },
|
|
2617
|
-
React.createElement(Flex, {
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2621
|
+
React.createElement(Flex, { ref: sidebarRef, onMouseDown: (e) => e.preventDefault(), style: { maxWidth: `${SIDEBAR_MAX_WIDTH}px` } },
|
|
2622
|
+
React.createElement(Flex, { direction: "col", bg: "canvas-100", borderR: true, pt: 8, pos: "sticky", pinY: true, overflowY: "auto", style: {
|
|
2623
|
+
paddingLeft: `calc((100% - ${maxContentWidth}px) / 2)`,
|
|
2624
|
+
width: `${currentSidebarWidth}px`,
|
|
2625
|
+
minWidth: `${SIDEBAR_MIN_WIDTH}px`,
|
|
2626
|
+
} }, sidebar),
|
|
2627
|
+
React.createElement(Flex, { justifySelf: "end", flexGrow: 0, flexShrink: 0, resize: "x", onMouseDown: startResizing, style: { width: '1em', flexBasis: '6px', cursor: 'ew-resize' } })),
|
|
2622
2628
|
React.createElement(Box, { ref: scrollRef, bg: "canvas", px: 24, flex: 1, w: "full", overflowY: "auto" },
|
|
2623
|
-
React.createElement(Box, { style: { maxWidth: `${maxContentWidth -
|
|
2624
|
-
});
|
|
2629
|
+
React.createElement(Box, { style: { maxWidth: `${maxContentWidth - currentSidebarWidth}px` }, py: 16 }, children))));
|
|
2630
|
+
});
|
|
2631
|
+
function useResizer(sidebarWidth) {
|
|
2632
|
+
const sidebarRef = React.useRef(null);
|
|
2633
|
+
const [isResizing, setIsResizing] = React.useState(false);
|
|
2634
|
+
const [currentSidebarWidth, setCurrentSidebarWidth] = React.useState(sidebarWidth);
|
|
2635
|
+
const startResizing = React.useCallback(() => {
|
|
2636
|
+
setIsResizing(true);
|
|
2637
|
+
}, []);
|
|
2638
|
+
const stopResizing = React.useCallback(() => {
|
|
2639
|
+
setIsResizing(false);
|
|
2640
|
+
}, []);
|
|
2641
|
+
const resize = React.useCallback(mouseMoveEvent => {
|
|
2642
|
+
if (isResizing) {
|
|
2643
|
+
const value = mouseMoveEvent.clientX - sidebarRef.current.getBoundingClientRect().left;
|
|
2644
|
+
setCurrentSidebarWidth(Math.min(Math.max(SIDEBAR_MIN_WIDTH, value), SIDEBAR_MAX_WIDTH));
|
|
2645
|
+
}
|
|
2646
|
+
}, [isResizing]);
|
|
2647
|
+
React.useEffect(() => {
|
|
2648
|
+
window.addEventListener('mousemove', resize);
|
|
2649
|
+
window.addEventListener('mouseup', stopResizing, { passive: true });
|
|
2650
|
+
return () => {
|
|
2651
|
+
window.removeEventListener('mousemove', resize);
|
|
2652
|
+
window.removeEventListener('mouseup', stopResizing);
|
|
2653
|
+
};
|
|
2654
|
+
}, [resize, stopResizing]);
|
|
2655
|
+
return [sidebarRef, currentSidebarWidth, startResizing];
|
|
2656
|
+
}
|
|
2625
2657
|
|
|
2626
2658
|
const Logo = ({ logo }) => {
|
|
2627
2659
|
var _a;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoplight/elements-core",
|
|
3
|
-
"version": "7.7.
|
|
3
|
+
"version": "7.7.7",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"web-components.min.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@stoplight/json": "^3.18.1",
|
|
28
28
|
"@stoplight/json-schema-ref-parser": "^9.0.5",
|
|
29
|
-
"@stoplight/json-schema-sampler": "0.2.
|
|
29
|
+
"@stoplight/json-schema-sampler": "0.2.3",
|
|
30
30
|
"@stoplight/json-schema-viewer": "^4.9.0",
|
|
31
31
|
"@stoplight/markdown-viewer": "^5.5.0",
|
|
32
32
|
"@stoplight/mosaic": "^1.33.0",
|
|
@@ -6,7 +6,7 @@ declare type Example = {
|
|
|
6
6
|
data: string;
|
|
7
7
|
};
|
|
8
8
|
export declare type GenerateExampleFromMediaTypeContentOptions = Sampler.Options;
|
|
9
|
-
export declare const useGenerateExampleFromMediaTypeContent: (mediaTypeContent: IMediaTypeContent | undefined, chosenExampleIndex?: number | undefined, { skipReadOnly, skipWriteOnly, skipNonRequired }?: GenerateExampleFromMediaTypeContentOptions) => string;
|
|
9
|
+
export declare const useGenerateExampleFromMediaTypeContent: (mediaTypeContent: IMediaTypeContent | undefined, chosenExampleIndex?: number | undefined, { skipReadOnly, skipWriteOnly, skipNonRequired, ticks }?: GenerateExampleFromMediaTypeContentOptions) => string;
|
|
10
10
|
export declare const generateExampleFromMediaTypeContent: (mediaTypeContent: IMediaTypeContent | undefined, document: any, chosenExampleIndex?: number, options?: Sampler.Options | undefined) => string;
|
|
11
11
|
export declare const generateExamplesFromJsonSchema: (schema: JSONSchema7) => Example[];
|
|
12
12
|
export declare const exceedsSize: (example: string, size?: number) => boolean;
|