@stoplight/elements-core 9.0.13-beta-0.2 → 9.0.13-beta-0.4

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.
Files changed (4) hide show
  1. package/index.esm.js +69 -14
  2. package/index.js +69 -14
  3. package/index.mjs +69 -14
  4. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -2765,11 +2765,16 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
2765
2765
  return node;
2766
2766
  if (node.$ref || node['x-iata-$ref']) {
2767
2767
  let refPath = node.$ref || node['x-iata-$ref'];
2768
- if (refPath.includes('#/%24defs')) {
2769
- refPath = refPath.replace('#/%24defs', '$defs');
2768
+ try {
2769
+ if (refPath.includes('#/%24defs')) {
2770
+ refPath = refPath.replace('#/%24defs', '$defs');
2771
+ }
2772
+ else {
2773
+ refPath = refPath.replace('__bundled__', 'definitions');
2774
+ }
2770
2775
  }
2771
- else {
2772
- refPath = refPath.replace('__bundled__', 'definitions');
2776
+ catch (error) {
2777
+ return node;
2773
2778
  }
2774
2779
  if (visited.has(node))
2775
2780
  return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
@@ -2859,14 +2864,69 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
2859
2864
  const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
2860
2865
  const [isHoveringSelector, setIsHoveringSelector] = useState(false);
2861
2866
  const isRoot = level === 1 && (title === undefined || path === '');
2862
- if (isRoot)
2863
- console.log('LazySchemaTreePreviewer 9.0.13-beta-0.2----------', schema);
2864
2867
  useEffect(() => {
2865
2868
  setSelectedSchemaIndex(0);
2866
2869
  }, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
2867
2870
  const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
2868
2871
  const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
2869
2872
  (!isRoot && isPropertiesAllHidden(path, hideData));
2873
+ const hasExpandableChildren = useMemo(() => {
2874
+ var _a;
2875
+ if (shouldHideAllChildren)
2876
+ return false;
2877
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
2878
+ let props = schema === null || schema === void 0 ? void 0 : schema.properties;
2879
+ if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
2880
+ schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
2881
+ props = Object.assign(Object.assign({}, props), item.properties);
2882
+ });
2883
+ }
2884
+ if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
2885
+ const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
2886
+ props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2887
+ }
2888
+ if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
2889
+ const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
2890
+ props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2891
+ }
2892
+ if (props && Object.keys(props).length > 0) {
2893
+ for (const [key] of Object.entries(props)) {
2894
+ const childPath = `${path}/properties/${key}`;
2895
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2896
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2897
+ if (!shouldHideChild)
2898
+ return true;
2899
+ }
2900
+ }
2901
+ }
2902
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
2903
+ (schema === null || schema === void 0 ? void 0 : schema.items) &&
2904
+ Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
2905
+ !((_a = schema === null || schema === void 0 ? void 0 : schema.items) === null || _a === void 0 ? void 0 : _a.circular)) {
2906
+ const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
2907
+ const itemsPath = `${path}/items`;
2908
+ if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
2909
+ for (const [key] of Object.entries(resolvedItems.properties)) {
2910
+ const childPath = `${itemsPath}/properties/${key}`;
2911
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2912
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2913
+ if (!shouldHideChild)
2914
+ return true;
2915
+ }
2916
+ }
2917
+ else if (resolvedItems &&
2918
+ resolvedItems.type === 'array' &&
2919
+ resolvedItems.items &&
2920
+ resolvedItems.items.length > 0) {
2921
+ const childPath = `${path}/items`;
2922
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2923
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2924
+ if (!shouldHideChild)
2925
+ return true;
2926
+ }
2927
+ }
2928
+ return false;
2929
+ }, [schema, path, hideData, complexData, shouldHideAllChildren, root, selectedSchemaIndex]);
2870
2930
  const shouldHideNode = useMemo(() => {
2871
2931
  if (isRoot)
2872
2932
  return false;
@@ -3017,9 +3077,10 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
3017
3077
  return (React__default.createElement("div", { className: "mb-1" },
3018
3078
  React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
3019
3079
  React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
3020
- React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
3080
+ React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${(isRoot || !hasExpandableChildren) ? '' : 'cursor-pointer'}` },
3021
3081
  !isRoot ? (React__default.createElement(Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
3022
- !TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
3082
+ hasExpandableChildren &&
3083
+ !TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
3023
3084
  !detectCircularPath(path) &&
3024
3085
  !((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
3025
3086
  !(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
@@ -3129,8 +3190,6 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
3129
3190
  return absolutePathsToHide;
3130
3191
  };
3131
3192
  const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
3132
- console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
3133
- console.log("Responses 9.0.13-beta-0.2----", disableProps);
3134
3193
  return (React.createElement(VStack, { spacing: 6 },
3135
3194
  React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
3136
3195
  React.createElement(Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
@@ -3335,7 +3394,6 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
3335
3394
  return absolutePathsToHide;
3336
3395
  };
3337
3396
  const shouldUseLazySchema = (_b = (statusCode && ((_a = disableProps === null || disableProps === void 0 ? void 0 : disableProps[statusCode]) === null || _a === void 0 ? void 0 : _a.some(entry => entry.isComplex)))) !== null && _b !== void 0 ? _b : false;
3338
- console.log("Responses 9.0.13-beta-0.2----", disableProps);
3339
3397
  return (React.createElement(VStack, { spacing: 8, pt: 8 },
3340
3398
  description && (React.createElement(Box, { pos: "relative" },
3341
3399
  React.createElement(MarkdownViewer, { markdown: description }),
@@ -3409,7 +3467,6 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
3409
3467
  const [requestBodyIndex, setTextRequestBodyIndex] = React.useState(0);
3410
3468
  const prettyName = (data.summary || data.iid || '').trim();
3411
3469
  const hasBadges = isDeprecated || isInternal;
3412
- console.log("HttpOperationComponent 9.0.13-beta-0.2----", disableProps);
3413
3470
  let path;
3414
3471
  if (isHttpOperation(data)) {
3415
3472
  path = data.path;
@@ -3694,7 +3751,6 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3694
3751
  const isDeprecated = !!data['deprecated'];
3695
3752
  const isInternal = !!data['x-internal'];
3696
3753
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
3697
- console.log("ModelComponent 9.0.13-beta-0.2----", disableProps);
3698
3754
  const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
3699
3755
  const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
3700
3756
  React.createElement(Box, { pos: "relative" },
@@ -3787,7 +3843,6 @@ const getTryItVisibility = (disableProps) => {
3787
3843
  const ParsedDocs = (_a) => {
3788
3844
  var { node, nodeUnsupported, disableProps } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported", "disableProps"]);
3789
3845
  const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
3790
- console.log("Parsed Docs 9.0.13-beta-0.2----", disableProps);
3791
3846
  switch (node.type) {
3792
3847
  case 'article':
3793
3848
  return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
package/index.js CHANGED
@@ -2787,11 +2787,16 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
2787
2787
  return node;
2788
2788
  if (node.$ref || node['x-iata-$ref']) {
2789
2789
  let refPath = node.$ref || node['x-iata-$ref'];
2790
- if (refPath.includes('#/%24defs')) {
2791
- refPath = refPath.replace('#/%24defs', '$defs');
2790
+ try {
2791
+ if (refPath.includes('#/%24defs')) {
2792
+ refPath = refPath.replace('#/%24defs', '$defs');
2793
+ }
2794
+ else {
2795
+ refPath = refPath.replace('__bundled__', 'definitions');
2796
+ }
2792
2797
  }
2793
- else {
2794
- refPath = refPath.replace('__bundled__', 'definitions');
2798
+ catch (error) {
2799
+ return node;
2795
2800
  }
2796
2801
  if (visited.has(node))
2797
2802
  return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
@@ -2881,14 +2886,69 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
2881
2886
  const [showSchemaDropdown, setShowSchemaDropdown] = React.useState(false);
2882
2887
  const [isHoveringSelector, setIsHoveringSelector] = React.useState(false);
2883
2888
  const isRoot = level === 1 && (title === undefined || path === '');
2884
- if (isRoot)
2885
- console.log('LazySchemaTreePreviewer 9.0.13-beta-0.2----------', schema);
2886
2889
  React.useEffect(() => {
2887
2890
  setSelectedSchemaIndex(0);
2888
2891
  }, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
2889
2892
  const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
2890
2893
  const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
2891
2894
  (!isRoot && isPropertiesAllHidden(path, hideData));
2895
+ const hasExpandableChildren = React.useMemo(() => {
2896
+ var _a;
2897
+ if (shouldHideAllChildren)
2898
+ return false;
2899
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
2900
+ let props = schema === null || schema === void 0 ? void 0 : schema.properties;
2901
+ if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
2902
+ schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
2903
+ props = Object.assign(Object.assign({}, props), item.properties);
2904
+ });
2905
+ }
2906
+ if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
2907
+ const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
2908
+ props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2909
+ }
2910
+ if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
2911
+ const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
2912
+ props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2913
+ }
2914
+ if (props && Object.keys(props).length > 0) {
2915
+ for (const [key] of Object.entries(props)) {
2916
+ const childPath = `${path}/properties/${key}`;
2917
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2918
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2919
+ if (!shouldHideChild)
2920
+ return true;
2921
+ }
2922
+ }
2923
+ }
2924
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
2925
+ (schema === null || schema === void 0 ? void 0 : schema.items) &&
2926
+ Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
2927
+ !((_a = schema === null || schema === void 0 ? void 0 : schema.items) === null || _a === void 0 ? void 0 : _a.circular)) {
2928
+ const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
2929
+ const itemsPath = `${path}/items`;
2930
+ if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
2931
+ for (const [key] of Object.entries(resolvedItems.properties)) {
2932
+ const childPath = `${itemsPath}/properties/${key}`;
2933
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2934
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2935
+ if (!shouldHideChild)
2936
+ return true;
2937
+ }
2938
+ }
2939
+ else if (resolvedItems &&
2940
+ resolvedItems.type === 'array' &&
2941
+ resolvedItems.items &&
2942
+ resolvedItems.items.length > 0) {
2943
+ const childPath = `${path}/items`;
2944
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2945
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2946
+ if (!shouldHideChild)
2947
+ return true;
2948
+ }
2949
+ }
2950
+ return false;
2951
+ }, [schema, path, hideData, complexData, shouldHideAllChildren, root, selectedSchemaIndex]);
2892
2952
  const shouldHideNode = React.useMemo(() => {
2893
2953
  if (isRoot)
2894
2954
  return false;
@@ -3039,9 +3099,10 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
3039
3099
  return (React.createElement("div", { className: "mb-1" },
3040
3100
  React.createElement(mosaic.Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
3041
3101
  React.createElement(mosaic.VStack, { spacing: 1, maxW: "full", className: "w-full" },
3042
- React.createElement(mosaic.Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
3102
+ React.createElement(mosaic.Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${(isRoot || !hasExpandableChildren) ? '' : 'cursor-pointer'}` },
3043
3103
  !isRoot ? (React.createElement(mosaic.Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
3044
- !TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
3104
+ hasExpandableChildren &&
3105
+ !TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
3045
3106
  !detectCircularPath(path) &&
3046
3107
  !((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
3047
3108
  !(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
@@ -3151,8 +3212,6 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
3151
3212
  return absolutePathsToHide;
3152
3213
  };
3153
3214
  const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
3154
- console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
3155
- console.log("Responses 9.0.13-beta-0.2----", disableProps);
3156
3215
  return (React__namespace.createElement(mosaic.VStack, { spacing: 6 },
3157
3216
  React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
3158
3217
  React__namespace.createElement(mosaic.Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
@@ -3357,7 +3416,6 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
3357
3416
  return absolutePathsToHide;
3358
3417
  };
3359
3418
  const shouldUseLazySchema = (_b = (statusCode && ((_a = disableProps === null || disableProps === void 0 ? void 0 : disableProps[statusCode]) === null || _a === void 0 ? void 0 : _a.some(entry => entry.isComplex)))) !== null && _b !== void 0 ? _b : false;
3360
- console.log("Responses 9.0.13-beta-0.2----", disableProps);
3361
3419
  return (React__namespace.createElement(mosaic.VStack, { spacing: 8, pt: 8 },
3362
3420
  description && (React__namespace.createElement(mosaic.Box, { pos: "relative" },
3363
3421
  React__namespace.createElement(MarkdownViewer, { markdown: description }),
@@ -3431,7 +3489,6 @@ const HttpOperationComponent = React__namespace.memo(({ className, data: unresol
3431
3489
  const [requestBodyIndex, setTextRequestBodyIndex] = React__namespace.useState(0);
3432
3490
  const prettyName = (data.summary || data.iid || '').trim();
3433
3491
  const hasBadges = isDeprecated || isInternal;
3434
- console.log("HttpOperationComponent 9.0.13-beta-0.2----", disableProps);
3435
3492
  let path;
3436
3493
  if (isHttpOperation(data)) {
3437
3494
  path = data.path;
@@ -3716,7 +3773,6 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3716
3773
  const isDeprecated = !!data['deprecated'];
3717
3774
  const isInternal = !!data['x-internal'];
3718
3775
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
3719
- console.log("ModelComponent 9.0.13-beta-0.2----", disableProps);
3720
3776
  const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
3721
3777
  const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React__namespace.createElement(mosaic.Flex, { justifyContent: "between", alignItems: "center" },
3722
3778
  React__namespace.createElement(mosaic.Box, { pos: "relative" },
@@ -3809,7 +3865,6 @@ const getTryItVisibility = (disableProps) => {
3809
3865
  const ParsedDocs = (_a) => {
3810
3866
  var { node, nodeUnsupported, disableProps } = _a, commonProps = tslib.__rest(_a, ["node", "nodeUnsupported", "disableProps"]);
3811
3867
  const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
3812
- console.log("Parsed Docs 9.0.13-beta-0.2----", disableProps);
3813
3868
  switch (node.type) {
3814
3869
  case 'article':
3815
3870
  return React__namespace.createElement(Article, Object.assign({ data: node.data }, commonProps));
package/index.mjs CHANGED
@@ -2765,11 +2765,16 @@ function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth =
2765
2765
  return node;
2766
2766
  if (node.$ref || node['x-iata-$ref']) {
2767
2767
  let refPath = node.$ref || node['x-iata-$ref'];
2768
- if (refPath.includes('#/%24defs')) {
2769
- refPath = refPath.replace('#/%24defs', '$defs');
2768
+ try {
2769
+ if (refPath.includes('#/%24defs')) {
2770
+ refPath = refPath.replace('#/%24defs', '$defs');
2771
+ }
2772
+ else {
2773
+ refPath = refPath.replace('__bundled__', 'definitions');
2774
+ }
2770
2775
  }
2771
- else {
2772
- refPath = refPath.replace('__bundled__', 'definitions');
2776
+ catch (error) {
2777
+ return node;
2773
2778
  }
2774
2779
  if (visited.has(node))
2775
2780
  return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
@@ -2859,14 +2864,69 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
2859
2864
  const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
2860
2865
  const [isHoveringSelector, setIsHoveringSelector] = useState(false);
2861
2866
  const isRoot = level === 1 && (title === undefined || path === '');
2862
- if (isRoot)
2863
- console.log('LazySchemaTreePreviewer 9.0.13-beta-0.2----------', schema);
2864
2867
  useEffect(() => {
2865
2868
  setSelectedSchemaIndex(0);
2866
2869
  }, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
2867
2870
  const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
2868
2871
  const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
2869
2872
  (!isRoot && isPropertiesAllHidden(path, hideData));
2873
+ const hasExpandableChildren = useMemo(() => {
2874
+ var _a;
2875
+ if (shouldHideAllChildren)
2876
+ return false;
2877
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && ((schema === null || schema === void 0 ? void 0 : schema.properties) || (schema === null || schema === void 0 ? void 0 : schema.allOf) || (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) {
2878
+ let props = schema === null || schema === void 0 ? void 0 : schema.properties;
2879
+ if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
2880
+ schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
2881
+ props = Object.assign(Object.assign({}, props), item.properties);
2882
+ });
2883
+ }
2884
+ if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
2885
+ const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
2886
+ props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2887
+ }
2888
+ if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
2889
+ const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
2890
+ props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2891
+ }
2892
+ if (props && Object.keys(props).length > 0) {
2893
+ for (const [key] of Object.entries(props)) {
2894
+ const childPath = `${path}/properties/${key}`;
2895
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2896
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2897
+ if (!shouldHideChild)
2898
+ return true;
2899
+ }
2900
+ }
2901
+ }
2902
+ if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
2903
+ (schema === null || schema === void 0 ? void 0 : schema.items) &&
2904
+ Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
2905
+ !((_a = schema === null || schema === void 0 ? void 0 : schema.items) === null || _a === void 0 ? void 0 : _a.circular)) {
2906
+ const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
2907
+ const itemsPath = `${path}/items`;
2908
+ if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
2909
+ for (const [key] of Object.entries(resolvedItems.properties)) {
2910
+ const childPath = `${itemsPath}/properties/${key}`;
2911
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2912
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2913
+ if (!shouldHideChild)
2914
+ return true;
2915
+ }
2916
+ }
2917
+ else if (resolvedItems &&
2918
+ resolvedItems.type === 'array' &&
2919
+ resolvedItems.items &&
2920
+ resolvedItems.items.length > 0) {
2921
+ const childPath = `${path}/items`;
2922
+ const childRequiredOverride = isRequiredOverride(childPath, hideData);
2923
+ const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2924
+ if (!shouldHideChild)
2925
+ return true;
2926
+ }
2927
+ }
2928
+ return false;
2929
+ }, [schema, path, hideData, complexData, shouldHideAllChildren, root, selectedSchemaIndex]);
2870
2930
  const shouldHideNode = useMemo(() => {
2871
2931
  if (isRoot)
2872
2932
  return false;
@@ -3017,9 +3077,10 @@ const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path
3017
3077
  return (React__default.createElement("div", { className: "mb-1" },
3018
3078
  React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
3019
3079
  React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
3020
- React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
3080
+ React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${(isRoot || !hasExpandableChildren) ? '' : 'cursor-pointer'}` },
3021
3081
  !isRoot ? (React__default.createElement(Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
3022
- !TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
3082
+ hasExpandableChildren &&
3083
+ !TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
3023
3084
  !detectCircularPath(path) &&
3024
3085
  !((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
3025
3086
  !(schema === null || schema === void 0 ? void 0 : schema.circular) ? (React__default.createElement("i", { role: "img", "aria-hidden": "true", className: `sl-icon fal ${expanded ? 'fa-chevron-down' : 'fa-chevron-right'} fa-fw fa-sm` })) : (React__default.createElement("span", { className: "sl-icon fal fa-fw fa-sm", "aria-hidden": "true" })),
@@ -3129,8 +3190,6 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
3129
3190
  return absolutePathsToHide;
3130
3191
  };
3131
3192
  const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
3132
- console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
3133
- console.log("Responses 9.0.13-beta-0.2----", disableProps);
3134
3193
  return (React.createElement(VStack, { spacing: 6 },
3135
3194
  React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
3136
3195
  React.createElement(Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: value => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
@@ -3335,7 +3394,6 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
3335
3394
  return absolutePathsToHide;
3336
3395
  };
3337
3396
  const shouldUseLazySchema = (_b = (statusCode && ((_a = disableProps === null || disableProps === void 0 ? void 0 : disableProps[statusCode]) === null || _a === void 0 ? void 0 : _a.some(entry => entry.isComplex)))) !== null && _b !== void 0 ? _b : false;
3338
- console.log("Responses 9.0.13-beta-0.2----", disableProps);
3339
3397
  return (React.createElement(VStack, { spacing: 8, pt: 8 },
3340
3398
  description && (React.createElement(Box, { pos: "relative" },
3341
3399
  React.createElement(MarkdownViewer, { markdown: description }),
@@ -3409,7 +3467,6 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
3409
3467
  const [requestBodyIndex, setTextRequestBodyIndex] = React.useState(0);
3410
3468
  const prettyName = (data.summary || data.iid || '').trim();
3411
3469
  const hasBadges = isDeprecated || isInternal;
3412
- console.log("HttpOperationComponent 9.0.13-beta-0.2----", disableProps);
3413
3470
  let path;
3414
3471
  if (isHttpOperation(data)) {
3415
3472
  path = data.path;
@@ -3694,7 +3751,6 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3694
3751
  const isDeprecated = !!data['deprecated'];
3695
3752
  const isInternal = !!data['x-internal'];
3696
3753
  const shouldDisplayHeader = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.noHeading) && (title !== undefined || (exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport)));
3697
- console.log("ModelComponent 9.0.13-beta-0.2----", disableProps);
3698
3754
  const titleChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: ['title', 'internal'] });
3699
3755
  const header = (shouldDisplayHeader || isInternal || isDeprecated) && (React.createElement(Flex, { justifyContent: "between", alignItems: "center" },
3700
3756
  React.createElement(Box, { pos: "relative" },
@@ -3787,7 +3843,6 @@ const getTryItVisibility = (disableProps) => {
3787
3843
  const ParsedDocs = (_a) => {
3788
3844
  var { node, nodeUnsupported, disableProps } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported", "disableProps"]);
3789
3845
  const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
3790
- console.log("Parsed Docs 9.0.13-beta-0.2----", disableProps);
3791
3846
  switch (node.type) {
3792
3847
  case 'article':
3793
3848
  return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "9.0.13-beta-0.2",
3
+ "version": "9.0.13-beta-0.4",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",