@stoplight/elements-core 9.0.12-beta-0.4 → 9.0.13-alpha.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/index.esm.js CHANGED
@@ -113,8 +113,6 @@ const isResolvedObjectProxy = (someObject) => {
113
113
  return !!someObject[originalObjectSymbol];
114
114
  };
115
115
  const getOriginalObject = (resolvedObject) => {
116
- if (!resolvedObject)
117
- return resolvedObject;
118
116
  const originalObject = resolvedObject[originalObjectSymbol] || resolvedObject;
119
117
  if (!originalObject) {
120
118
  return resolvedObject;
@@ -1343,7 +1341,11 @@ const booleanOptions = [
1343
1341
  { label: 'True', value: 'true' },
1344
1342
  ];
1345
1343
  function enumOptions(enumValues, required) {
1346
- const options = map(enumValues, v => ({ value: typeof v === 'number' ? v : String(v) }));
1344
+ const options = map(enumValues, v => {
1345
+ var _a;
1346
+ const value = typeof v === 'object' && v !== null ? (_a = safeStringify(v)) !== null && _a !== void 0 ? _a : String(v) : typeof v === 'number' ? v : String(v);
1347
+ return { value, label: String(value) };
1348
+ });
1347
1349
  return required ? options : [{ label: 'Not Set', value: '' }, ...options];
1348
1350
  }
1349
1351
  function parameterOptions(parameter) {
@@ -1373,15 +1375,16 @@ function parameterSupportsFileUpload(parameter) {
1373
1375
  ((_c = parameter.schema) === null || _c === void 0 ? void 0 : _c.contentMediaType) === 'application/octet-stream'));
1374
1376
  }
1375
1377
  function stringifyValue(value) {
1376
- return typeof value === 'object' ? JSON.stringify(value) : escapeQuotes(String(value));
1378
+ var _a;
1379
+ if (typeof value === 'object' && value !== null) {
1380
+ return (_a = safeStringify(value)) !== null && _a !== void 0 ? _a : String(value);
1381
+ }
1382
+ return String(value);
1377
1383
  }
1378
1384
  function exampleValue(example) {
1379
1385
  const value = 'value' in example ? example.value : example.externalValue;
1380
1386
  return stringifyValue(value);
1381
1387
  }
1382
- function escapeQuotes(value) {
1383
- return value.replace(/"/g, '\\"');
1384
- }
1385
1388
  function getPlaceholderForParameter(parameter) {
1386
1389
  var _a, _b;
1387
1390
  const { value: parameterValue, isDefault } = getValueForParameter(parameter);
@@ -1407,14 +1410,14 @@ const getValueForParameter = (parameter) => {
1407
1410
  if (typeof defaultValue !== 'undefined') {
1408
1411
  return { value: stringifyValue(defaultValue), isDefault: true };
1409
1412
  }
1410
- const examples = (_a = parameter.examples) !== null && _a !== void 0 ? _a : [];
1411
- if (examples.length > 0) {
1412
- return { value: exampleValue(examples[0]) };
1413
- }
1414
- const enums = (_c = (_b = parameter.schema) === null || _b === void 0 ? void 0 : _b.enum) !== null && _c !== void 0 ? _c : [];
1413
+ const enums = (_b = (_a = parameter.schema) === null || _a === void 0 ? void 0 : _a.enum) !== null && _b !== void 0 ? _b : [];
1415
1414
  if (enums.length > 0) {
1416
1415
  return { value: stringifyValue(enums[0]) };
1417
1416
  }
1417
+ const examples = (_c = parameter.examples) !== null && _c !== void 0 ? _c : [];
1418
+ if (examples.length > 0) {
1419
+ return { value: exampleValue(examples[0]) };
1420
+ }
1418
1421
  return { value: '' };
1419
1422
  };
1420
1423
  const getInitialValueForParameter = (parameter) => {
@@ -2332,7 +2335,7 @@ const VariableEditor = ({ variable, value, onChange }) => {
2332
2335
  return (React.createElement(React.Fragment, null,
2333
2336
  React.createElement(Text, { as: "label", "aria-hidden": "true", "data-testid": "param-label", htmlFor: inputId, fontSize: "base" }, variable.name),
2334
2337
  React.createElement(Text, { mx: 3 }, ":"),
2335
- React.createElement("div", null, variable.enum ? (React.createElement(Select, { flex: 1, "aria-label": variable.name, options: variable.enum.map(s => ({ value: s })), value: value || variable.default, onChange: onChange })) : (React.createElement(Flex, { flex: 1 },
2338
+ React.createElement("div", null, variable.enum ? (React.createElement(Select, { flex: 1, "aria-label": variable.name, options: variable.enum.map(s => ({ value: s, label: String(s) })), value: value || variable.default, onChange: onChange })) : (React.createElement(Flex, { flex: 1 },
2336
2339
  React.createElement(Input, { id: inputId, "aria-label": variable.name, appearance: 'minimal', flex: 1, placeholder: variable.default, type: "text", required: true, intent: 'default', value: value || '', onChange: e => onChange && onChange(e.currentTarget.value) }))))));
2337
2340
  };
2338
2341
 
@@ -2740,417 +2743,13 @@ const PanelContent = ({ schemes }) => {
2740
2743
  })));
2741
2744
  };
2742
2745
 
2743
- const TYPES = ['string', 'integer', 'boolean', 'any', 'number'];
2744
- function resolvePointer(obj, pointer) {
2745
- const parts = pointer.replace(/^#\//, '').split('/');
2746
- return parts.reduce((acc, key) => acc && acc[key], obj);
2747
- }
2748
- function detectCircularPath(path) {
2749
- const ignored = ['properties', 'items'];
2750
- const parts = path.split('/').filter(part => !ignored.includes(part));
2751
- for (let i = 0; i < parts.length - 1; i++) {
2752
- const current = parts[i];
2753
- const rest = parts.slice(i + 1);
2754
- if (rest.includes(current)) {
2755
- return true;
2756
- }
2757
- }
2758
- return false;
2759
- }
2760
- function dereference(node, root, visited = new WeakSet(), depth = 0, maxDepth = 10) {
2761
- if (!node || typeof node !== 'object')
2762
- return node;
2763
- if (depth > maxDepth)
2764
- return node;
2765
- if (node.$ref || node['x-iata-$ref']) {
2766
- let refPath = node.$ref || node['x-iata-$ref'];
2767
- if (refPath.includes('#/%24defs')) {
2768
- refPath = refPath.replace('#/%24defs', '$defs');
2769
- }
2770
- else {
2771
- refPath = refPath.replace('__bundled__', 'definitions');
2772
- }
2773
- if (visited.has(node))
2774
- return { circular: true, $ref: refPath, title: node.title, type: 'any', description: node.description };
2775
- visited.add(node);
2776
- const target = resolvePointer(root, refPath);
2777
- if (!target)
2778
- return node;
2779
- const result = Object.assign({}, target);
2780
- if ('description' in node)
2781
- result.description = node.description;
2782
- if ('title' in node)
2783
- result.title = node.title;
2784
- return dereference(result, root, visited, depth + 1, maxDepth);
2785
- }
2786
- if (Array.isArray(node)) {
2787
- return node.map(item => dereference(item, root, visited, depth + 1, maxDepth));
2788
- }
2789
- const result = {};
2790
- for (const key in node) {
2791
- result[key] = dereference(node[key], root, visited, depth + 1, maxDepth);
2792
- }
2793
- return result;
2794
- }
2795
- const trimSlashes = (str) => {
2796
- return str.replace(/^\/|\/$/g, '');
2797
- };
2798
- function isPropertiesAllHidden(path, hideData) {
2799
- const current = trimSlashes(path);
2800
- const parts = current.split('/');
2801
- for (let i = parts.length; i >= 2; i--) {
2802
- if (parts[i - 1] === 'properties') {
2803
- const ancestorPropPath = parts.slice(0, i).join('/');
2804
- const block = hideData.find(h => trimSlashes(h.path) === ancestorPropPath && ancestorPropPath.endsWith('/properties'));
2805
- if (block && block.required === undefined) {
2806
- return true;
2807
- }
2808
- }
2809
- }
2810
- return false;
2811
- }
2812
- function isRequiredOverride(path, hideData) {
2813
- const entry = hideData.find(h => trimSlashes(h.path) === trimSlashes(path));
2814
- return entry && typeof entry.required === 'boolean' ? entry.required : undefined;
2815
- }
2816
- function isPathHidden(path, hideData, complexData) {
2817
- const isComplex = checkIfIsComplex(path, complexData);
2818
- if (isComplex === null) {
2819
- return false;
2820
- }
2821
- else if (isComplex) {
2822
- const normalizedPath = trimSlashes(path);
2823
- const direct = hideData.find(h => trimSlashes(h.path) === normalizedPath);
2824
- if (direct && direct.required === undefined)
2825
- return true;
2826
- if (isPropertiesAllHidden(path, hideData))
2827
- return true;
2828
- for (const h of hideData) {
2829
- const hPath = trimSlashes(h.path);
2830
- if (h.required !== undefined)
2831
- continue;
2832
- if (normalizedPath.length > hPath.length &&
2833
- normalizedPath.startsWith(hPath) &&
2834
- (hPath.endsWith('/items') || (hPath.match(/\/items\/[^\/]+$/) && normalizedPath.startsWith(hPath + '/')))) {
2835
- return true;
2836
- }
2837
- }
2838
- return false;
2839
- }
2840
- else {
2841
- return !hideData.some(h => h.path === path || h.path.startsWith(path + '/'));
2842
- }
2843
- }
2844
- const checkIfIsComplex = (path, complexData) => {
2845
- let isComplex = null;
2846
- for (const complex of complexData) {
2847
- if (path.startsWith(complex.location)) {
2848
- isComplex = complex === null || complex === void 0 ? void 0 : complex.isComplex;
2849
- break;
2850
- }
2851
- }
2852
- return isComplex;
2853
- };
2854
- const LazySchemaTreePreviewer = ({ schema, root = schema, title, level = 1, path = '', hideData = [], complexData = [], parentRequired, propertyKey, _subType, }) => {
2855
- var _a, _b, _c, _d;
2856
- const [expanded, setExpanded] = useState(false);
2857
- const [selectedSchemaIndex, setSelectedSchemaIndex] = useState(0);
2858
- const [showSchemaDropdown, setShowSchemaDropdown] = useState(false);
2859
- const [isHoveringSelector, setIsHoveringSelector] = useState(false);
2860
- const isRoot = level === 1 && (title === undefined || path === '');
2861
- console.log("In LazySchemaTreePreviewer Beta 0.2:", { schema, path, isRoot });
2862
- useEffect(() => {
2863
- setSelectedSchemaIndex(0);
2864
- }, [schema === null || schema === void 0 ? void 0 : schema.anyOf, schema === null || schema === void 0 ? void 0 : schema.oneOf]);
2865
- const thisNodeRequiredOverride = isRequiredOverride(path, hideData);
2866
- const shouldHideAllChildren = (isRoot && hideData.some(h => trimSlashes(h.path) === 'properties' && h.required === undefined)) ||
2867
- (!isRoot && isPropertiesAllHidden(path, hideData));
2868
- const hasExpandableChildren = useMemo(() => {
2869
- var _a;
2870
- if (shouldHideAllChildren)
2871
- return false;
2872
- 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))) {
2873
- let props = schema === null || schema === void 0 ? void 0 : schema.properties;
2874
- if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
2875
- schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
2876
- props = Object.assign(Object.assign({}, props), item.properties);
2877
- });
2878
- }
2879
- if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
2880
- const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
2881
- props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2882
- }
2883
- if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
2884
- const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
2885
- props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2886
- }
2887
- if (props && Object.keys(props).length > 0) {
2888
- for (const [key] of Object.entries(props)) {
2889
- const childPath = `${path}/properties/${key}`;
2890
- const childRequiredOverride = isRequiredOverride(childPath, hideData);
2891
- const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2892
- if (!shouldHideChild)
2893
- return true;
2894
- }
2895
- }
2896
- }
2897
- if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
2898
- (schema === null || schema === void 0 ? void 0 : schema.items) &&
2899
- Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
2900
- !((_a = schema === null || schema === void 0 ? void 0 : schema.items) === null || _a === void 0 ? void 0 : _a.circular)) {
2901
- const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
2902
- const itemsPath = `${path}/items`;
2903
- if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
2904
- for (const [key] of Object.entries(resolvedItems.properties)) {
2905
- const childPath = `${itemsPath}/properties/${key}`;
2906
- const childRequiredOverride = isRequiredOverride(childPath, hideData);
2907
- const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2908
- if (!shouldHideChild)
2909
- return true;
2910
- }
2911
- }
2912
- else if (resolvedItems &&
2913
- resolvedItems.type === 'array' &&
2914
- resolvedItems.items &&
2915
- resolvedItems.items.length > 0) {
2916
- const childPath = `${path}/items`;
2917
- const childRequiredOverride = isRequiredOverride(childPath, hideData);
2918
- const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2919
- if (!shouldHideChild)
2920
- return true;
2921
- }
2922
- }
2923
- return false;
2924
- }, [schema, path, hideData, complexData, shouldHideAllChildren, root, selectedSchemaIndex]);
2925
- const shouldHideNode = useMemo(() => {
2926
- if (isRoot)
2927
- return false;
2928
- if (isPathHidden(path, hideData, complexData) && thisNodeRequiredOverride === undefined)
2929
- return true;
2930
- return false;
2931
- }, [path, hideData, isRoot, thisNodeRequiredOverride, complexData]);
2932
- if (!schema || shouldHideNode) {
2933
- return null;
2934
- }
2935
- const displayTitle = level === 1 && (title === undefined || path === '') ? '' : (_a = title !== null && title !== void 0 ? title : schema === null || schema === void 0 ? void 0 : schema.title) !== null && _a !== void 0 ? _a : 'Node';
2936
- const handleToggle = () => {
2937
- const circular = detectCircularPath(path);
2938
- if (!circular) {
2939
- setExpanded(prev => !prev);
2940
- }
2941
- };
2942
- const renderChildren = () => {
2943
- var _a, _b, _c, _d;
2944
- if (shouldHideAllChildren)
2945
- return null;
2946
- if (!expanded && !isRoot)
2947
- return null;
2948
- const children = [];
2949
- 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))) {
2950
- let props = schema === null || schema === void 0 ? void 0 : schema.properties;
2951
- if (schema === null || schema === void 0 ? void 0 : schema.allOf) {
2952
- schema === null || schema === void 0 ? void 0 : schema.allOf.forEach((item) => {
2953
- props = Object.assign(Object.assign({}, props), item.properties);
2954
- });
2955
- }
2956
- if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
2957
- const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.anyOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.anyOf[0]);
2958
- props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2959
- }
2960
- if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
2961
- const selectedSchema = (schema === null || schema === void 0 ? void 0 : schema.oneOf[selectedSchemaIndex]) || (schema === null || schema === void 0 ? void 0 : schema.oneOf[0]);
2962
- props = Object.assign(Object.assign({}, props), selectedSchema.properties);
2963
- }
2964
- for (const [key, child] of Object.entries(props || {})) {
2965
- const childPath = `${path}/properties/${key}`;
2966
- const childRequiredOverride = isRequiredOverride(childPath, hideData);
2967
- const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2968
- const resolved = dereference(child, root);
2969
- if (!shouldHideChild) {
2970
- children.push(React__default.createElement("li", { key: key },
2971
- React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 1, path: childPath, hideData: hideData, complexData: complexData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: key, _subType: (_a = resolved === null || resolved === void 0 ? void 0 : resolved.items) === null || _a === void 0 ? void 0 : _a.type })));
2972
- }
2973
- }
2974
- }
2975
- else if ((schema === null || schema === void 0 ? void 0 : schema.type) === 'array' &&
2976
- (schema === null || schema === void 0 ? void 0 : schema.items) &&
2977
- Object.keys(schema === null || schema === void 0 ? void 0 : schema.items).length > 0 &&
2978
- !((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular)) {
2979
- const resolvedItems = dereference(schema === null || schema === void 0 ? void 0 : schema.items, root);
2980
- const itemsPath = `${path}/items`;
2981
- if (resolvedItems && resolvedItems.type === 'object' && resolvedItems.properties) {
2982
- for (const [key, child] of Object.entries(resolvedItems.properties)) {
2983
- const childPath = `${itemsPath}/properties/${key}`;
2984
- const childRequiredOverride = isRequiredOverride(childPath, hideData);
2985
- const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2986
- const resolved = dereference(child, root);
2987
- if (!shouldHideChild) {
2988
- children.push(React__default.createElement("li", { key: key },
2989
- React__default.createElement(LazySchemaTreePreviewer, { schema: resolved, root: root, title: key, level: level + 2, path: childPath, hideData: hideData, complexData: complexData, parentRequired: resolvedItems.required, propertyKey: key, _subType: (_c = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _c === void 0 ? void 0 : _c.type })));
2990
- }
2991
- }
2992
- }
2993
- else if (resolvedItems && resolvedItems.type === 'array' && resolvedItems.items.length > 0) {
2994
- const childPath = `${path}/items`;
2995
- const childRequiredOverride = isRequiredOverride(childPath, hideData);
2996
- const shouldHideChild = isPathHidden(childPath, hideData, complexData) && childRequiredOverride === undefined;
2997
- if (!shouldHideChild) {
2998
- children.push(React__default.createElement("li", { key: "items" },
2999
- React__default.createElement(LazySchemaTreePreviewer, { schema: resolvedItems, root: root, title: "items", level: level + 1, path: childPath, hideData: hideData, complexData: complexData, parentRequired: schema === null || schema === void 0 ? void 0 : schema.required, propertyKey: "items", _subType: (_d = resolvedItems === null || resolvedItems === void 0 ? void 0 : resolvedItems.items) === null || _d === void 0 ? void 0 : _d.type })));
3000
- }
3001
- }
3002
- }
3003
- return children.length > 0 ? React__default.createElement("ul", { className: "ml-6 border-l border-gray-200 pl-2" }, children) : null;
3004
- };
3005
- const combinedSchemaSelector = () => {
3006
- var _a;
3007
- return (React__default.createElement(React__default.Fragment, null,
3008
- React__default.createElement(Box, { pos: "fixed", top: 0, left: 0, right: 0, bottom: 0, bg: "transparent", style: { zIndex: 999 }, onClick: () => setShowSchemaDropdown(false) }),
3009
- React__default.createElement(Box, { pos: "absolute", bg: "canvas", rounded: true, boxShadow: "md", style: {
3010
- zIndex: 1000,
3011
- top: '100%',
3012
- left: 0,
3013
- minWidth: '150px',
3014
- maxWidth: '200px',
3015
- marginTop: '2px',
3016
- border: '1px solid rgba(0, 0, 0, 0.1)',
3017
- }, fontSize: "sm", onClick: (e) => e.stopPropagation() }, (_a = ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf))) === null || _a === void 0 ? void 0 : _a.map((schemaOption, index) => (React__default.createElement(Box, { key: index, px: 3, py: 2, cursor: "pointer", bg: selectedSchemaIndex === index ? 'primary-tint' : 'canvas', fontSize: "xs", display: "flex", alignItems: "center", style: {
3018
- borderBottom: index < ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)).length - 1 ? '1px solid rgba(0, 0, 0, 0.1)' : 'none',
3019
- gap: '8px',
3020
- }, onMouseEnter: (e) => {
3021
- if (selectedSchemaIndex !== index) {
3022
- e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas-tint)';
3023
- }
3024
- }, onMouseLeave: (e) => {
3025
- if (selectedSchemaIndex !== index) {
3026
- e.currentTarget.style.backgroundColor = 'var(--sl-color-canvas)';
3027
- }
3028
- }, onClick: () => {
3029
- setSelectedSchemaIndex(index);
3030
- setShowSchemaDropdown(false);
3031
- } },
3032
- React__default.createElement(Box, { flex: 1, color: "body" }, schemaOption.type || 'object'),
3033
- selectedSchemaIndex === index && (React__default.createElement(Box, { color: "primary", fontSize: "xs" }, "\u2713"))))))));
3034
- };
3035
- const renderMinEnums = (schema) => {
3036
- if (!schema || typeof schema !== 'object')
3037
- return null;
3038
- const boxStyle = {
3039
- background: 'rgba(245, 247, 250, 0.5)',
3040
- border: '1px solid #a0aec0',
3041
- borderRadius: '4px',
3042
- padding: '0px 2px',
3043
- display: 'inline-block',
3044
- overflowWrap: 'break-word',
3045
- textAlign: 'left',
3046
- maxWidth: 'fit-content',
3047
- maxHeight: 'fit-content',
3048
- };
3049
- if ('minItems' in schema) {
3050
- const schemaWithMinItems = schema;
3051
- if (typeof schemaWithMinItems.minItems === 'number') {
3052
- return (React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, `>=${schemaWithMinItems.minItems} items`));
3053
- }
3054
- }
3055
- if ('enum' in schema && Array.isArray(schema.enum)) {
3056
- return (React__default.createElement("div", null,
3057
- "Allowed values:",
3058
- ' ',
3059
- schema.enum.map((val, idx) => (React__default.createElement(Box, { key: idx, className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: boxStyle }, val)))));
3060
- }
3061
- return null;
3062
- };
3063
- const isRequired = parentRequired && propertyKey && parentRequired.includes(propertyKey);
3064
- let showRequiredLabel = false;
3065
- const hideDataEntry = hideData.find(hideEntry => trimSlashes(hideEntry.path) === trimSlashes(path));
3066
- if ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === true || ((hideDataEntry === null || hideDataEntry === void 0 ? void 0 : hideDataEntry.required) === undefined && isRequired)) {
3067
- showRequiredLabel = true;
3068
- }
3069
- if (schema === null || schema === void 0 ? void 0 : schema.$ref) {
3070
- schema = dereference(schema, root);
3071
- }
3072
- return (React__default.createElement("div", { className: "mb-1" },
3073
- React__default.createElement(Flex, { maxW: "full", pl: 3, py: 2, "data-test": "schema-row", pos: "relative" },
3074
- React__default.createElement(VStack, { spacing: 1, maxW: "full", className: "w-full" },
3075
- React__default.createElement(Flex, { onClick: !isRoot ? handleToggle : undefined, className: `w-full ${isRoot ? '' : 'cursor-pointer'}` },
3076
- !isRoot ? (React__default.createElement(Box, { mr: 2, className: "sl-font-mono sl-font-semibold sl-mr-2" },
3077
- hasExpandableChildren &&
3078
- !TYPES.includes(schema === null || schema === void 0 ? void 0 : schema.type) &&
3079
- !detectCircularPath(path) &&
3080
- !((_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.circular) &&
3081
- !(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" })),
3082
- ' ' + displayTitle)) : null,
3083
- !isRoot ? (React__default.createElement(Box, { mr: 2, pos: "relative" },
3084
- React__default.createElement(Box, { display: "inline-flex", alignItems: "center", onMouseEnter: () => {
3085
- if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
3086
- setIsHoveringSelector(true);
3087
- }
3088
- }, onMouseLeave: () => {
3089
- if (!showSchemaDropdown) {
3090
- setIsHoveringSelector(false);
3091
- }
3092
- }, onClick: (e) => {
3093
- if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) {
3094
- e.stopPropagation();
3095
- setShowSchemaDropdown(prev => !prev);
3096
- }
3097
- }, style: {
3098
- cursor: (schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf) ? 'pointer' : 'default',
3099
- } },
3100
- React__default.createElement("span", { className: "sl-truncate sl-text-muted" },
3101
- (() => {
3102
- let typeDisplay = (schema === null || schema === void 0 ? void 0 : schema.type) === 'object' && (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : (schema === null || schema === void 0 ? void 0 : schema.type) || (root === null || root === void 0 ? void 0 : root.title);
3103
- if ((schema === null || schema === void 0 ? void 0 : schema.anyOf) && (schema === null || schema === void 0 ? void 0 : schema.anyOf.length) > 0) {
3104
- return `any of ${typeDisplay}`;
3105
- }
3106
- else if ((schema === null || schema === void 0 ? void 0 : schema.oneOf) && (schema === null || schema === void 0 ? void 0 : schema.oneOf.length) > 0) {
3107
- return `one of ${typeDisplay}`;
3108
- }
3109
- return typeDisplay;
3110
- })(),
3111
- (schema === null || schema === void 0 ? void 0 : schema.items) && ((_c = schema === null || schema === void 0 ? void 0 : schema.items) === null || _c === void 0 ? void 0 : _c.title) !== undefined ? ` [${(_d = schema === null || schema === void 0 ? void 0 : schema.items) === null || _d === void 0 ? void 0 : _d.title}] ` : null),
3112
- ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && (React__default.createElement(Box, { display: "inline-flex", alignItems: "center", ml: 1, style: {
3113
- opacity: isHoveringSelector ? 1 : 0.6,
3114
- transition: 'opacity 0.2s',
3115
- } },
3116
- React__default.createElement("i", { className: "sl-icon fas fa-chevron-down", style: {
3117
- fontSize: '10px',
3118
- opacity: 0.6,
3119
- } })))),
3120
- React__default.createElement("span", { className: "text-gray-500" }, (schema === null || schema === void 0 ? void 0 : schema.format) !== undefined ? `<${schema === null || schema === void 0 ? void 0 : schema.format}>` : null),
3121
- ((schema === null || schema === void 0 ? void 0 : schema.anyOf) || (schema === null || schema === void 0 ? void 0 : schema.oneOf)) && showSchemaDropdown && combinedSchemaSelector())) : null),
3122
- React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } },
3123
- (schema === null || schema === void 0 ? void 0 : schema.description) && (React__default.createElement(Box, { fontFamily: "ui", fontWeight: "light" },
3124
- React__default.createElement("span", { className: "sl-prose sl-markdown-viewer", style: { fontSize: '12px' } }, schema === null || schema === void 0 ? void 0 : schema.description))),
3125
- !isRoot && (schema === null || schema === void 0 ? void 0 : schema.examples) !== undefined && (React__default.createElement(Flex, { align: "center", mb: 1, style: { flexWrap: 'wrap' } },
3126
- React__default.createElement("span", { className: "text-gray-500", style: { marginRight: 8, flexShrink: 0 } }, "Example"),
3127
- React__default.createElement(Box, { className: "sl-text-muted", fontFamily: "ui", fontWeight: "normal", mr: 2, style: {
3128
- background: 'rgba(245, 247, 250, 0.5)',
3129
- border: '1px solid #a0aec0',
3130
- borderRadius: '4px',
3131
- padding: '4px 8px',
3132
- display: 'inline-block',
3133
- overflowWrap: 'break-word',
3134
- textAlign: 'left',
3135
- maxWidth: '530px',
3136
- } }, JSON.stringify(schema === null || schema === void 0 ? void 0 : schema.examples))))),
3137
- React__default.createElement(Flex, { pl: 1, w: "full", align: "start", direction: "col", style: { overflow: 'visible', paddingLeft: '20px' } }, schema &&
3138
- typeof schema === 'object' &&
3139
- ('minItems' in schema || 'enum' in schema) &&
3140
- renderMinEnums(schema))),
3141
- !isRoot && (React__default.createElement("label", { className: "inline-flex items-top ml-2" },
3142
- React__default.createElement(Box, { mr: 2, fontFamily: "ui", fontWeight: "normal" }, showRequiredLabel && (React__default.createElement("div", { className: "sl-ml-2 sl-text-warning" },
3143
- React__default.createElement("span", { style: { marginLeft: '10px' } }, "required"))))))),
3144
- renderChildren()));
3145
- };
3146
-
3147
2746
  const isBodyEmpty = (body) => {
3148
2747
  if (!body)
3149
2748
  return true;
3150
2749
  const { contents = [], description } = body;
3151
2750
  return contents.length === 0 && !(description === null || description === void 0 ? void 0 : description.trim());
3152
2751
  };
3153
- const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps }) => {
2752
+ const Body = ({ body, onChange, isHttpWebhookOperation = false }) => {
3154
2753
  var _a;
3155
2754
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
3156
2755
  const [chosenContent, setChosenContent] = React.useState(0);
@@ -3163,36 +2762,13 @@ const Body = ({ body, onChange, isHttpWebhookOperation = false, disableProps })
3163
2762
  const { contents = [], description } = body;
3164
2763
  const schema = (_a = contents[chosenContent]) === null || _a === void 0 ? void 0 : _a.schema;
3165
2764
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: body.id, attr: 'description' });
3166
- const getMaskProperties = () => {
3167
- const disablePropsConfig = disableProps || [];
3168
- const absolutePathsToHide = [];
3169
- disablePropsConfig.forEach(configEntry => {
3170
- const { location, paths, isComplex } = configEntry;
3171
- if (paths.length === 0 && !isComplex) {
3172
- absolutePathsToHide.push({ path: location });
3173
- }
3174
- else {
3175
- paths.forEach((item) => {
3176
- const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
3177
- let object = { path: fullPath };
3178
- if (item.hasOwnProperty('required')) {
3179
- object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
3180
- }
3181
- absolutePathsToHide.push(object);
3182
- });
3183
- }
3184
- });
3185
- return absolutePathsToHide;
3186
- };
3187
- const shouldUseLazySchema = disableProps === null || disableProps === void 0 ? void 0 : disableProps.some(entry => entry.isComplex === true);
3188
- console.log('!!!!! shouldUseLazySchema body!!!!', shouldUseLazySchema);
3189
2765
  return (React.createElement(VStack, { spacing: 6 },
3190
2766
  React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
3191
2767
  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" })))),
3192
2768
  description && (React.createElement(Box, { pos: "relative" },
3193
2769
  React.createElement(MarkdownViewer, { markdown: description }),
3194
2770
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
3195
- schema && shouldUseLazySchema ? (React.createElement(LazySchemaTreePreviewer, { schema: schema, hideData: getMaskProperties(), complexData: disableProps })) : (isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon })))));
2771
+ isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, maxRefDepth: maxRefDepth, schema: getOriginalObject(schema), viewMode: isHttpWebhookOperation ? 'standalone' : 'write', renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))));
3196
2772
  };
3197
2773
  Body.displayName = 'HttpOperation.Body';
3198
2774
 
@@ -3259,7 +2835,7 @@ const httpOperationParamsToSchema = ({ parameters, parameterType }) => {
3259
2835
  return schema;
3260
2836
  };
3261
2837
 
3262
- const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, disableProps, }) => {
2838
+ const Request = ({ operation: { request, request: { path: pathParams = [], headers: headerParams = [], cookie: cookieParams = [], body, query: queryParams = [], } = {}, security, }, hideSecurityInfo, onChange, isHttpWebhookOperation = false, }) => {
3263
2839
  if (!request || typeof request !== 'object')
3264
2840
  return null;
3265
2841
  const bodyIsEmpty = isBodyEmpty(body);
@@ -3287,7 +2863,7 @@ const Request = ({ operation: { request, request: { path: pathParams = [], heade
3287
2863
  cookieParams.length > 0 && (React.createElement(VStack, { spacing: 5 },
3288
2864
  React.createElement(SectionSubtitle, { title: "Cookies", id: "request-cookies" }),
3289
2865
  React.createElement(Parameters, { parameterType: "cookie", parameters: cookieParams }))),
3290
- body && (React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation, disableProps: disableProps }))));
2866
+ body && React.createElement(Body, { onChange: onChange, body: body, isHttpWebhookOperation: isHttpWebhookOperation })));
3291
2867
  };
3292
2868
  Request.displayName = 'HttpOperation.Request';
3293
2869
  const schemeExpandedState = atomWithStorage('HttpOperation_security_expanded', {});
@@ -3318,7 +2894,7 @@ const OptionalMessage$1 = () => {
3318
2894
  return React.createElement(Callout, { appearance: "outline" }, OptionalSecurityMessage);
3319
2895
  };
3320
2896
 
3321
- const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, disableProps, }) => {
2897
+ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTypeChange, isCompact, }) => {
3322
2898
  var _a, _b;
3323
2899
  const responses = sortBy(uniqBy(unsortedResponses, r => r.code), r => r.code);
3324
2900
  const [activeResponseId, setActiveResponseId] = React.useState((_b = (_a = responses[0]) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : '');
@@ -3351,12 +2927,11 @@ const Responses = ({ responses: unsortedResponses, onStatusCodeChange, onMediaTy
3351
2927
  const tabResponses = (React.createElement(TabList, { density: "compact" }, responses.map(({ code }) => (React.createElement(Tab, { key: code, id: code, intent: codeToIntentVal(code) }, code)))));
3352
2928
  return (React.createElement(VStack, { spacing: 8, as: Tabs, selectedId: activeResponseId, onChange: setActiveResponseId, appearance: "pill" },
3353
2929
  React.createElement(SectionTitle, { title: "Responses", isCompact: isCompact }, isCompact ? compactResponses : tabResponses),
3354
- isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: activeResponseId })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
3355
- React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange, disableProps: disableProps, statusCode: response.code }))))))));
2930
+ isCompact ? (React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange })) : (React.createElement(TabPanels, { p: 0 }, responses.map(response => (React.createElement(TabPanel, { key: response.code, id: response.code },
2931
+ React.createElement(Response, { response: response, onMediaTypeChange: onMediaTypeChange }))))))));
3356
2932
  };
3357
2933
  Responses.displayName = 'HttpOperation.Responses';
3358
- const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) => {
3359
- var _a, _b;
2934
+ const Response = ({ response, onMediaTypeChange }) => {
3360
2935
  const { contents = [], headers = [], description } = response;
3361
2936
  const [chosenContent, setChosenContent] = React.useState(0);
3362
2937
  const [refResolver, maxRefDepth] = useSchemaInlineRefResolver();
@@ -3367,29 +2942,6 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
3367
2942
  responseContent && (onMediaTypeChange === null || onMediaTypeChange === void 0 ? void 0 : onMediaTypeChange(responseContent.mediaType));
3368
2943
  }, [responseContent]);
3369
2944
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId: response.id, attr: 'description' });
3370
- const getMaskProperties = () => {
3371
- if (!disableProps || !statusCode)
3372
- return [];
3373
- const configEntries = disableProps[statusCode] || [];
3374
- const absolutePathsToHide = [];
3375
- configEntries.forEach(({ location, paths, isComplex }) => {
3376
- if (paths.length === 0 && !isComplex) {
3377
- absolutePathsToHide.push({ path: location });
3378
- }
3379
- else {
3380
- paths.forEach((item) => {
3381
- const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
3382
- let object = { path: fullPath };
3383
- if (item.hasOwnProperty('required')) {
3384
- object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
3385
- }
3386
- absolutePathsToHide.push(object);
3387
- });
3388
- }
3389
- });
3390
- return absolutePathsToHide;
3391
- };
3392
- 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;
3393
2945
  return (React.createElement(VStack, { spacing: 8, pt: 8 },
3394
2946
  description && (React.createElement(Box, { pos: "relative" },
3395
2947
  React.createElement(MarkdownViewer, { markdown: description }),
@@ -3401,7 +2953,7 @@ const Response = ({ response, onMediaTypeChange, disableProps, statusCode }) =>
3401
2953
  React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
3402
2954
  React.createElement(Flex, { flex: 1, justify: "end" },
3403
2955
  React.createElement(Select, { "aria-label": "Response 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" }))),
3404
- schema && shouldUseLazySchema ? (React.createElement(LazySchemaTreePreviewer, { schema: schema, path: "", hideData: getMaskProperties(), complexData: disableProps && statusCode ? disableProps[statusCode] : [] })) : (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
2956
+ schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, maxRefDepth: maxRefDepth, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true, nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }))))));
3405
2957
  };
3406
2958
  Response.displayName = 'HttpOperation.Response';
3407
2959
  const codeToIntentVal = (code) => {
@@ -3450,7 +3002,7 @@ const Callback = ({ data, isCompact }) => {
3450
3002
  };
3451
3003
  Callbacks.displayName = 'HttpOperation.Callback';
3452
3004
 
3453
- const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy, disableProps }) => {
3005
+ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, layoutOptions, tryItCredentialsPolicy, tryItCorsProxy }) => {
3454
3006
  var _a;
3455
3007
  const { nodeHasChanged } = useOptionsCtx();
3456
3008
  const data = useResolvedObject(unresolvedData);
@@ -3481,11 +3033,11 @@ const HttpOperationComponent = React.memo(({ className, data: unresolvedData, la
3481
3033
  React.createElement(MarkdownViewer, { className: "HttpOperation__Description", markdown: data.description }),
3482
3034
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
3483
3035
  React.createElement(NodeVendorExtensions, { data: data }),
3484
- React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data), disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.request }),
3485
- data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact, disableProps: disableProps === null || disableProps === void 0 ? void 0 : disableProps.response })),
3036
+ React.createElement(Request, { onChange: setTextRequestBodyIndex, operation: data, hideSecurityInfo: layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideSecurityInfo, isHttpWebhookOperation: isHttpWebhookOperation(data) }),
3037
+ data.responses && (React.createElement(Responses, { responses: data.responses, onMediaTypeChange: setResponseMediaType, onStatusCodeChange: setResponseStatusCode, isCompact: isCompact })),
3486
3038
  ((_a = data.callbacks) === null || _a === void 0 ? void 0 : _a.length) ? React.createElement(Callbacks, { callbacks: data.callbacks, isCompact: isCompact }) : null,
3487
3039
  isCompact && tryItPanel));
3488
- return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideOperationTryIt) && !isCompact && tryItPanel }));
3040
+ return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('HttpOperation', className), header: header, left: description, right: !isCompact && tryItPanel }));
3489
3041
  });
3490
3042
  HttpOperationComponent.displayName = 'HttpOperation.Component';
3491
3043
  const HttpOperation = withErrorBoundary(HttpOperationComponent, {
@@ -3736,7 +3288,7 @@ const HttpServiceComponent = React.memo(({ data: unresolvedData, location = {},
3736
3288
  HttpServiceComponent.displayName = 'HttpService.Component';
3737
3289
  const HttpService = withErrorBoundary(HttpServiceComponent, { recoverableProps: ['data'] });
3738
3290
 
3739
- const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, disableProps, }) => {
3291
+ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOptions, exportProps, }) => {
3740
3292
  var _a, _b;
3741
3293
  const [resolveRef, maxRefDepth] = useSchemaInlineRefResolver();
3742
3294
  const data = useResolvedObject(unresolvedData);
@@ -3759,40 +3311,14 @@ const ModelComponent = ({ data: unresolvedData, className, nodeTitle, layoutOpti
3759
3311
  exportProps && !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideExport) && !isCompact && React.createElement(ExportButton, Object.assign({}, exportProps))));
3760
3312
  const modelExamples = !(layoutOptions === null || layoutOptions === void 0 ? void 0 : layoutOptions.hideModelExamples) && React.createElement(ModelExamples, { data: data, isCollapsible: isCompact });
3761
3313
  const descriptionChanged = nodeHasChanged === null || nodeHasChanged === void 0 ? void 0 : nodeHasChanged({ nodeId, attr: 'description' });
3762
- const getMaskProperties = () => {
3763
- const disablePropsConfig = disableProps === null || disableProps === void 0 ? void 0 : disableProps.models;
3764
- const absolutePathsToHide = [];
3765
- if (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models) {
3766
- disablePropsConfig.forEach((configEntry) => {
3767
- const { location, paths, isComplex } = configEntry;
3768
- if (paths.length === 0 && !isComplex) {
3769
- absolutePathsToHide.push({ path: location });
3770
- }
3771
- else {
3772
- paths.forEach((item) => {
3773
- const fullPath = location === '#' ? item === null || item === void 0 ? void 0 : item.path : `${location}/${item.path}`;
3774
- let object = { path: fullPath };
3775
- if (item.hasOwnProperty('required')) {
3776
- object = Object.assign(Object.assign({}, object), { required: item === null || item === void 0 ? void 0 : item.required });
3777
- }
3778
- absolutePathsToHide.push(object);
3779
- });
3780
- }
3781
- });
3782
- }
3783
- return absolutePathsToHide;
3784
- };
3785
- const shouldUseLazySchema = disableProps && (disableProps === null || disableProps === void 0 ? void 0 : disableProps.models)
3786
- ? disableProps.models.some((entry) => entry.isComplex === true)
3787
- : false;
3788
3314
  const description = (React.createElement(VStack, { spacing: 10 },
3789
3315
  data.description && data.type === 'object' && (React.createElement(Box, { pos: "relative" },
3790
3316
  React.createElement(MarkdownViewer, { role: "textbox", markdown: data.description }),
3791
3317
  React.createElement(NodeAnnotation, { change: descriptionChanged }))),
3792
3318
  React.createElement(NodeVendorExtensions, { data: data }),
3793
- !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && isCompact && modelExamples,
3794
- data && shouldUseLazySchema ? (React.createElement(LazySchemaTreePreviewer, { schema: data, hideData: getMaskProperties(), complexData: disableProps === null || disableProps === void 0 ? void 0 : disableProps.models })) : (React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true }))));
3795
- return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !(disableProps === null || disableProps === void 0 ? void 0 : disableProps.hideModelTryIt) && !isCompact && modelExamples }));
3319
+ isCompact && modelExamples,
3320
+ React.createElement(JsonSchemaViewer, { resolveRef: resolveRef, maxRefDepth: maxRefDepth, schema: getOriginalObject(data), nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon, skipTopLevelDescription: true })));
3321
+ return (React.createElement(TwoColumnLayout, { ref: layoutRef, className: cn('Model', className), header: header, left: description, right: !isCompact && modelExamples }));
3796
3322
  };
3797
3323
  const ModelExamples = React.memo(({ data, isCollapsible = false }) => {
3798
3324
  var _a;
@@ -3814,41 +3340,30 @@ const Model = withErrorBoundary(ModelComponent, { recoverableProps: ['data'] });
3814
3340
 
3815
3341
  const Docs = React.memo((_a) => {
3816
3342
  var _b;
3817
- var { nodeType, nodeData, disableProps, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "disableProps", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
3343
+ var { nodeType, nodeData, useNodeForRefResolving = false, refResolver, maxRefDepth, nodeHasChanged, renderExtensionAddon } = _a, commonProps = __rest(_a, ["nodeType", "nodeData", "useNodeForRefResolving", "refResolver", "maxRefDepth", "nodeHasChanged", "renderExtensionAddon"]);
3818
3344
  const parsedNode = useParsedData(nodeType, nodeData);
3819
3345
  if (!parsedNode) {
3820
3346
  (_b = commonProps.nodeUnsupported) === null || _b === void 0 ? void 0 : _b.call(commonProps, 'dataEmpty');
3821
3347
  return null;
3822
3348
  }
3823
- let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode, disableProps: disableProps }, commonProps));
3349
+ let elem = React.createElement(ParsedDocs, Object.assign({ node: parsedNode }, commonProps));
3824
3350
  if (useNodeForRefResolving) {
3825
3351
  elem = (React.createElement(InlineRefResolverProvider, { document: parsedNode.data, resolver: refResolver, maxRefDepth: maxRefDepth }, elem));
3826
3352
  }
3827
3353
  return (React.createElement(ElementsOptionsProvider, { nodeHasChanged: nodeHasChanged, renderExtensionAddon: renderExtensionAddon }, elem));
3828
3354
  });
3829
- const getTryItVisibility = (disableProps) => {
3830
- var _a, _b, _c, _d;
3831
- if (!disableProps)
3832
- return { hideOperationTryIt: false, hideModelTryIt: false };
3833
- const requestHasComplex = (_b = (_a = disableProps.request) === null || _a === void 0 ? void 0 : _a.some(item => item.isComplex)) !== null && _b !== void 0 ? _b : false;
3834
- const responseHasComplex = Object.values(disableProps.response || {}).some(arr => arr.some(item => item.isComplex));
3835
- const hideOperationTryIt = requestHasComplex || responseHasComplex;
3836
- const hideModelTryIt = (_d = (_c = disableProps.models) === null || _c === void 0 ? void 0 : _c.some(item => item.isComplex)) !== null && _d !== void 0 ? _d : false;
3837
- return { hideOperationTryIt, hideModelTryIt };
3838
- };
3839
3355
  const ParsedDocs = (_a) => {
3840
- var { node, nodeUnsupported, disableProps } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported", "disableProps"]);
3841
- const { hideOperationTryIt, hideModelTryIt } = getTryItVisibility(disableProps);
3356
+ var { node, nodeUnsupported } = _a, commonProps = __rest(_a, ["node", "nodeUnsupported"]);
3842
3357
  switch (node.type) {
3843
3358
  case 'article':
3844
3359
  return React.createElement(Article, Object.assign({ data: node.data }, commonProps));
3845
3360
  case 'http_operation':
3846
3361
  case 'http_webhook':
3847
- return React.createElement(HttpOperation, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideOperationTryIt }) }, commonProps));
3362
+ return React.createElement(HttpOperation, Object.assign({ data: node.data }, commonProps));
3848
3363
  case 'http_service':
3849
3364
  return React.createElement(HttpService, Object.assign({ data: node.data }, commonProps));
3850
3365
  case 'model':
3851
- return React.createElement(Model, Object.assign({ data: node.data, disableProps: Object.assign(Object.assign({}, disableProps), { hideModelTryIt }) }, commonProps));
3366
+ return React.createElement(Model, Object.assign({ data: node.data }, commonProps));
3852
3367
  default:
3853
3368
  nodeUnsupported === null || nodeUnsupported === void 0 ? void 0 : nodeUnsupported('invalidType');
3854
3369
  return null;
@@ -3986,7 +3501,7 @@ function findFirstNode(items) {
3986
3501
  return;
3987
3502
  }
3988
3503
  function isDivider(item) {
3989
- return Object.keys(item).length === 1 && 'title' in item;
3504
+ return Object.keys(item).length === 2 && 'title' in item && 'index' in item;
3990
3505
  }
3991
3506
  function isGroup(item) {
3992
3507
  return Object.keys(item).length >= 2 && 'title' in item && 'items' in item;
@@ -3998,13 +3513,33 @@ function isNode(item) {
3998
3513
  return 'title' in item && 'slug' in item && 'id' in item && 'meta' in item && 'type' in item;
3999
3514
  }
4000
3515
  function isExternalLink(item) {
4001
- return Object.keys(item).length === 2 && 'title' in item && 'url' in item;
3516
+ return Object.keys(item).length === 3 && 'title' in item && 'url' in item && 'index' in item;
4002
3517
  }
4003
3518
 
4004
- const ActiveIdContext = React.createContext(undefined);
3519
+ const ActiveItemContext = React.createContext({
3520
+ activeId: undefined,
3521
+ lastActiveIndex: '',
3522
+ setLastActiveIndex: () => { },
3523
+ });
4005
3524
  const LinkContext = React.createContext(undefined);
4006
3525
  LinkContext.displayName = 'LinkContext';
4007
3526
  const TableOfContents = React.memo(({ tree, activeId, Link, maxDepthOpenByDefault, externalScrollbar = false, isInResponsiveMode = false, onLinkClick, }) => {
3527
+ const [lastActiveIndex, setLastActiveIndex] = useState('');
3528
+ const value = React.useMemo(() => ({
3529
+ lastActiveIndex,
3530
+ setLastActiveIndex,
3531
+ activeId,
3532
+ }), [lastActiveIndex, activeId]);
3533
+ const updateTocTree = React.useCallback((arr, parentId) => {
3534
+ return arr.map((item, key) => {
3535
+ let newItem = Object.assign(Object.assign({}, item), { index: parentId + key + '-' });
3536
+ if (isGroup(item) || isNodeGroup(item)) {
3537
+ newItem.items = updateTocTree(item.items, parentId + key + '-');
3538
+ }
3539
+ return newItem;
3540
+ });
3541
+ }, []);
3542
+ const updatedTree = updateTocTree(tree, '');
4008
3543
  const container = React.useRef(null);
4009
3544
  const child = React.useRef(null);
4010
3545
  const firstRender = useFirstRender();
@@ -4024,18 +3559,30 @@ const TableOfContents = React.memo(({ tree, activeId, Link, maxDepthOpenByDefaul
4024
3559
  return (React.createElement(Box, { ref: container, w: "full", bg: isInResponsiveMode ? 'canvas' : 'canvas-100', overflowY: "auto" },
4025
3560
  React.createElement(Box, { ref: child, my: 3 },
4026
3561
  React.createElement(LinkContext.Provider, { value: Link },
4027
- React.createElement(ActiveIdContext.Provider, { value: activeId }, tree.map((item, key) => {
4028
- if (isDivider(item)) {
4029
- return React.createElement(Divider, { key: key, item: item, isInResponsiveMode: isInResponsiveMode });
4030
- }
4031
- return (React.createElement(GroupItem, { key: key, item: item, depth: 0, maxDepthOpenByDefault: maxDepthOpenByDefault, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode }));
4032
- }))))));
3562
+ React.createElement(ActiveItemContext.Provider, { value: value },
3563
+ React.createElement(TOCContainer, { updatedTree: updatedTree }, updatedTree.map((item, key) => {
3564
+ if (isDivider(item)) {
3565
+ return React.createElement(Divider, { key: key, item: item, isInResponsiveMode: isInResponsiveMode });
3566
+ }
3567
+ return (React.createElement(GroupItem, { key: key, item: item, depth: 0, maxDepthOpenByDefault: maxDepthOpenByDefault, onLinkClick: onLinkClick, isInResponsiveMode: isInResponsiveMode }));
3568
+ })))))));
4033
3569
  });
4034
3570
  TableOfContents.displayName = 'TableOfContents';
4035
3571
  const Divider = React.memo(({ item, isInResponsiveMode = false }) => {
4036
3572
  return (React.createElement(Box, { pl: 4, mb: 2, mt: 6, textTransform: "uppercase", fontSize: isInResponsiveMode ? 'lg' : 'sm', lineHeight: "relaxed", letterSpacing: "wide", fontWeight: "bold" }, item.title));
4037
3573
  });
4038
3574
  Divider.displayName = 'Divider';
3575
+ const TOCContainer = React.memo(({ children, updatedTree }) => {
3576
+ const { setLastActiveIndex } = React.useContext(ActiveItemContext);
3577
+ React.useEffect(() => {
3578
+ const firstNode = findFirstNode(updatedTree);
3579
+ if (firstNode) {
3580
+ setLastActiveIndex(firstNode.index);
3581
+ }
3582
+ }, []);
3583
+ return React.createElement(Box, null, children);
3584
+ });
3585
+ TOCContainer.displayName = 'TOCContainer';
4039
3586
  const GroupItem = React.memo(({ item, depth, maxDepthOpenByDefault, isInResponsiveMode, onLinkClick }) => {
4040
3587
  if (isExternalLink(item)) {
4041
3588
  return (React.createElement(Box, { as: "a", href: item.url, target: "_blank", rel: "noopener noreferrer", display: "block" },
@@ -4053,9 +3600,24 @@ const GroupItem = React.memo(({ item, depth, maxDepthOpenByDefault, isInResponsi
4053
3600
  });
4054
3601
  GroupItem.displayName = 'GroupItem';
4055
3602
  const Group = React.memo(({ depth, item, maxDepthOpenByDefault, isInResponsiveMode, onLinkClick = () => { } }) => {
4056
- const activeId = React.useContext(ActiveIdContext);
3603
+ const { activeId, lastActiveIndex } = React.useContext(ActiveItemContext);
4057
3604
  const [isOpen, setIsOpen] = React.useState(() => isGroupOpenByDefault(depth, item, activeId, maxDepthOpenByDefault));
4058
- const hasActive = !!activeId && hasActiveItem(item.items, activeId);
3605
+ const isActiveGroup = React.useCallback((items, activeId, contextIndex) => {
3606
+ return items.some(element => {
3607
+ const hasSlugOrId = 'slug' in element || 'id' in element;
3608
+ const hasItems = 'items' in element && Array.isArray(element.items);
3609
+ if (!hasSlugOrId && !hasItems)
3610
+ return false;
3611
+ if (activeId &&
3612
+ 'index' in element &&
3613
+ (element.slug === activeId || element.id === activeId) &&
3614
+ element.index === contextIndex) {
3615
+ return true;
3616
+ }
3617
+ return hasItems ? isActiveGroup(element.items, activeId, contextIndex) : false;
3618
+ });
3619
+ }, []);
3620
+ const hasActive = isActiveGroup(item.items, activeId, lastActiveIndex);
4059
3621
  React.useEffect(() => {
4060
3622
  const openByDefault = isGroupOpenByDefault(depth, item, activeId, maxDepthOpenByDefault);
4061
3623
  if (isOpen !== openByDefault) {
@@ -4105,8 +3667,10 @@ const Item = React.memo(({ depth, isActive, id, title, meta, icon, isInResponsiv
4105
3667
  });
4106
3668
  Item.displayName = 'Item';
4107
3669
  const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode, onClick, onLinkClick = () => { } }) => {
4108
- const activeId = React.useContext(ActiveIdContext);
4109
- const isActive = activeId === item.slug || activeId === item.id;
3670
+ const { activeId, lastActiveIndex, setLastActiveIndex } = React.useContext(ActiveItemContext);
3671
+ const { index } = item;
3672
+ const isSlugMatched = activeId === item.slug || activeId === item.id;
3673
+ const isActive = lastActiveIndex === index && isSlugMatched;
4110
3674
  const LinkComponent = React.useContext(LinkContext);
4111
3675
  const handleClick = (e) => {
4112
3676
  if (isActive) {
@@ -4114,6 +3678,7 @@ const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode,
4114
3678
  e.preventDefault();
4115
3679
  }
4116
3680
  else {
3681
+ setLastActiveIndex(index);
4117
3682
  onLinkClick();
4118
3683
  }
4119
3684
  if (onClick) {
@@ -4121,7 +3686,7 @@ const Node = React.memo(({ item, depth, meta, showAsActive, isInResponsiveMode,
4121
3686
  }
4122
3687
  };
4123
3688
  return (React.createElement(Box, { as: LinkComponent, to: resolveRelativeLink(item.slug), display: "block", textDecoration: "no-underline", className: "ElementsTableOfContentsItem" },
4124
- React.createElement(Item, { id: getHtmlIdFromItemId(item.slug || item.id), isActive: isActive || showAsActive, depth: depth, title: item.title, icon: NODE_TYPE_TITLE_ICON[item.type] && (React.createElement(Box, { as: Icon, color: NODE_TYPE_ICON_COLOR[item.type], icon: NODE_TYPE_TITLE_ICON[item.type] })), meta: meta, isInResponsiveMode: isInResponsiveMode, onClick: handleClick })));
3689
+ React.createElement(Item, { id: getHtmlIdFromItemId(item.slug || item.id), isActive: isActive || showAsActive, depth: depth, title: item.title, icon: NODE_TYPE_TITLE_ICON[item.type] && (React.createElement(Box, { as: Icon, color: NODE_TYPE_ICON_COLOR[item.type], icon: NODE_TYPE_TITLE_ICON[item.type] })), meta: meta, isInResponsiveMode: isInResponsiveMode, onClick: e => handleClick(e) })));
4125
3690
  });
4126
3691
  Node.displayName = 'Node';
4127
3692
  const Version = ({ value }) => {