@redocly/marketing-pages 0.1.30 → 0.1.31

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.
@@ -17,6 +17,7 @@ interface EditorLayoutProps {
17
17
  onDownloadYaml: () => void;
18
18
  onDownloadJson: () => void;
19
19
  onToggleFullPreview: () => void;
20
+ isDownloadDisabled: boolean;
20
21
  }
21
22
  declare const EditorLayout: React.ForwardRefExoticComponent<EditorLayoutProps & React.RefAttributes<any>>;
22
23
  export default EditorLayout;
@@ -1,4 +1,4 @@
1
- import e from"react";import t from"styled-components";import{Panel as n,PanelGroup as h,PanelResizeHandle as S}from"react-resizable-panels";import k from"../EditorPanel";import{ProblemsPanel as w}from"../ProblemsPanel";import R from"../Toolbar";const i=e.forwardRef(({value:d,onChange:s,onValidationUpdate:c,hideWarnings:r,onHideWarningsChange:m,isFullPreview:p,gotoPosition:u,parsedErrors:f,onProblemClick:b,onFileLoad:P,onDownloadYaml:E,onDownloadJson:g,onToggleFullPreview:C},v)=>{const[l,a]=e.useState(!0),o=e.useRef(null),y=(z,x)=>{b(z,x),l&&o.current?.expand()};return e.createElement(F,{ref:v,defaultSize:50,minSize:20,collapsible:!0,collapsedSize:0},e.createElement(R,{onFileLoad:P,onDownloadYamlClick:E,onDownloadJsonClick:g,hideWarnings:r,onHideWarningsChange:m,onToggleFullPreview:C}),e.createElement(L,null,e.createElement(h,{direction:"vertical"},e.createElement(n,{defaultSize:95},e.createElement(k,{value:d,onChange:s,onValidationUpdate:c,hideWarnings:r,isFullPreview:p,gotoPosition:u})),e.createElement(S,{className:"resize-handle-horizontal",style:{display:l?"none":"block"}}),e.createElement(n,{ref:o,collapsible:!0,collapsedSize:5,defaultSize:5,minSize:20,onCollapse:a.bind(null,!0),onExpand:a.bind(null,!1)},e.createElement(w,{problems:f,onProblemClick:y,isCollapsed:l,onToggle:()=>{l?o.current?.expand():o.current?.collapse()}})))))});i.displayName="EditorLayout";var J=i;const F=t(n)`
1
+ import e from"react";import t from"styled-components";import{Panel as n,PanelGroup as S,PanelResizeHandle as k}from"react-resizable-panels";import w from"../EditorPanel";import{ProblemsPanel as R}from"../ProblemsPanel";import D from"../Toolbar";const i=e.forwardRef(({value:d,onChange:s,onValidationUpdate:c,hideWarnings:r,onHideWarningsChange:m,isFullPreview:p,gotoPosition:u,parsedErrors:f,onProblemClick:b,onFileLoad:P,onDownloadYaml:E,onDownloadJson:g,onToggleFullPreview:C,isDownloadDisabled:v},y)=>{const[l,a]=e.useState(!0),o=e.useRef(null),z=(x,h)=>{b(x,h),l&&o.current?.expand()};return e.createElement(F,{ref:y,defaultSize:50,minSize:20,collapsible:!0,collapsedSize:0},e.createElement(D,{onFileLoad:P,onDownloadYamlClick:E,onDownloadJsonClick:g,hideWarnings:r,onHideWarningsChange:m,onToggleFullPreview:C,isDownloadDisabled:v}),e.createElement(L,null,e.createElement(S,{direction:"vertical"},e.createElement(n,{defaultSize:95},e.createElement(w,{value:d,onChange:s,onValidationUpdate:c,hideWarnings:r,isFullPreview:p,gotoPosition:u})),e.createElement(k,{className:"resize-handle-horizontal",style:{display:l?"none":"block"}}),e.createElement(n,{ref:o,collapsible:!0,collapsedSize:5,defaultSize:5,minSize:20,onCollapse:a.bind(null,!0),onExpand:a.bind(null,!1)},e.createElement(R,{problems:f,onProblemClick:z,isCollapsed:l,onToggle:()=>{l?o.current?.expand():o.current?.collapse()}})))))});i.displayName="EditorLayout";var U=i;const F=t(n)`
2
2
  flex: 2;
3
3
  display: flex;
4
4
  flex-direction: column;
@@ -12,4 +12,4 @@ import e from"react";import t from"styled-components";import{Panel as n,PanelGro
12
12
  flex: 1;
13
13
  min-height: 0;
14
14
  display: flex;
15
- `;export{J as default};
15
+ `;export{U as default};
@@ -1,4 +1,4 @@
1
- import e from"react";import m from"styled-components";import{useEditorState as S}from"../hooks/useEditorState";import{useOpenApiValidation as T}from"../hooks/useOpenApiValidation";import{useFileOperations as H}from"../hooks/useFileOperations";import{PanelGroup as W,PanelResizeHandle as G}from"react-resizable-panels";import J from"./Layout/PreviewLayout";import Y from"./Layout/EditorLayout";function I(){const[p,g]=e.useState(!1),[r,d]=e.useState(!1),l=e.useRef(null);e.useEffect(()=>g(!0),[]);const{value:a,setValue:c,validatedValue:v,setValidatedValue:u,setValidationErrors:t,setFileName:b,parsedErrors:w,hasStructErrors:h,hideWarnings:P,setHideWarnings:k}=S(),{definition:n,hasRenderedOnce:E,setHasRenderedOnce:C}=T({validatedValue:v,hasStructErrors:h}),f=e.useRef(null);e.useEffect(()=>{n&&(f.current=n)},[n]);const F=n||f.current,[y,z]=e.useState(null),o=H({setValue:c,setFileName:b,setHasRenderedOnce:C,setValidationErrors:t}),x=e.useCallback((i,s)=>{t(i),u(s)},[t,u]),R=e.useCallback((i,s)=>{z({line:i,column:s})},[]),V=e.useCallback(()=>o.handleDownloadYaml(a),[o,a]),D=e.useCallback(()=>o.handleDownloadJson(a),[o,a]),L=e.useCallback(()=>d(!0),[]),O=e.useCallback(()=>d(!1),[]);return e.useEffect(()=>{l.current&&(r?l.current.collapse():l.current.expand())},[r]),e.createElement(N,null,e.createElement(U,{direction:"horizontal"},e.createElement(Y,{ref:l,value:a,onChange:c,onValidationUpdate:x,hideWarnings:P,onHideWarningsChange:k,isFullPreview:r,gotoPosition:y,parsedErrors:w,onProblemClick:R,onFileLoad:o.handleFileLoad,onDownloadYaml:V,onDownloadJson:D,onToggleFullPreview:L}),e.createElement(G,{className:"resize-handle",style:{display:r?"none":"block"}}),e.createElement(J,{definition:F,rawValue:a,hasRenderedOnce:E,hasStructErrors:h,onTemplateClick:o.handleTemplateClick,onFileLoad:o.handleFileLoad,isClient:p,isFullPreview:r,onExitFullPreview:O})))}const N=m.div`
1
+ import e from"react";import m from"styled-components";import{useEditorState as T}from"../hooks/useEditorState";import{useOpenApiValidation as H}from"../hooks/useOpenApiValidation";import{useFileOperations as W}from"../hooks/useFileOperations";import{PanelGroup as G,PanelResizeHandle as J}from"react-resizable-panels";import Y from"./Layout/PreviewLayout";import I from"./Layout/EditorLayout";function N(){const[p,g]=e.useState(!1),[l,d]=e.useState(!1),r=e.useRef(null);e.useEffect(()=>g(!0),[]);const{value:o,setValue:c,validatedValue:v,setValidatedValue:u,setValidationErrors:t,setFileName:b,parsedErrors:w,hasStructErrors:h,hideWarnings:P,setHideWarnings:k}=T(),{definition:n,hasRenderedOnce:E,setHasRenderedOnce:C}=H({validatedValue:v,hasStructErrors:h}),f=e.useRef(null);e.useEffect(()=>{n&&(f.current=n)},[n]);const F=n||f.current,[y,z]=e.useState(null),a=W({setValue:c,setFileName:b,setHasRenderedOnce:C,setValidationErrors:t}),D=e.useCallback((i,s)=>{t(i),u(s)},[t,u]),x=e.useCallback((i,s)=>{z({line:i,column:s})},[]),R=e.useCallback(()=>a.handleDownloadYaml(o),[a,o]),V=e.useCallback(()=>a.handleDownloadJson(o),[a,o]),L=e.useCallback(()=>d(!0),[]),O=e.useCallback(()=>d(!1),[]);e.useEffect(()=>{r.current&&(l?r.current.collapse():r.current.expand())},[l]);const S=!o||!o.trim();return e.createElement(U,null,e.createElement(A,{direction:"horizontal"},e.createElement(I,{ref:r,value:o,onChange:c,onValidationUpdate:D,hideWarnings:P,onHideWarningsChange:k,isFullPreview:l,gotoPosition:y,parsedErrors:w,onProblemClick:x,onFileLoad:a.handleFileLoad,onDownloadYaml:R,onDownloadJson:V,onToggleFullPreview:L,isDownloadDisabled:S}),e.createElement(J,{className:"resize-handle",style:{display:l?"none":"block"}}),e.createElement(Y,{definition:F,rawValue:o,hasRenderedOnce:E,hasStructErrors:h,onTemplateClick:a.handleTemplateClick,onFileLoad:a.handleFileLoad,isClient:p,isFullPreview:l,onExitFullPreview:O})))}const U=m.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  height: calc(100vh - var(--navbar-height));
@@ -9,7 +9,7 @@ import e from"react";import m from"styled-components";import{useEditorState as S
9
9
  [data-component-name='Layout/PageLayout']:has(&) + div + footer {
10
10
  display: none;
11
11
  }
12
- `,U=m(W)`
12
+ `,A=m(G)`
13
13
  display: flex;
14
14
  flex-grow: 1;
15
15
  height: 100%;
@@ -36,4 +36,4 @@ import e from"react";import m from"styled-components";import{useEditorState as S
36
36
  .resize-handle-horizontal[data-resize-handle-state="hover"] {
37
37
  background-color: var(--color-blue-4);
38
38
  }
39
- `;export{I as default};
39
+ `;export{N as default};
@@ -6,6 +6,7 @@ interface ToolbarProps {
6
6
  hideWarnings: boolean;
7
7
  onHideWarningsChange: (hide: boolean) => void;
8
8
  onToggleFullPreview?: () => void;
9
+ isDownloadDisabled: boolean;
9
10
  }
10
- export default function Toolbar({ hideWarnings, onHideWarningsChange, onDownloadYamlClick, onDownloadJsonClick, onFileLoad, onToggleFullPreview }: ToolbarProps): React.JSX.Element;
11
+ export default function Toolbar({ hideWarnings, onHideWarningsChange, onDownloadYamlClick, onDownloadJsonClick, onFileLoad, onToggleFullPreview, isDownloadDisabled }: ToolbarProps): React.JSX.Element;
11
12
  export {};
@@ -1,4 +1,4 @@
1
- import e,{useRef as k,useState as C}from"react";import t from"styled-components";import{Button as n}from"@redocly/theme/components/Button/Button";import{Tooltip as c}from"@redocly/theme/components/Tooltip/Tooltip";import{DownloadIcon as m}from"@redocly/theme/icons/DownloadIcon/DownloadIcon";import{ChevronDownIcon as D}from"@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon";import{ViewIcon as I}from"@redocly/theme/icons/ViewIcon/ViewIcon";function R({hideWarnings:u,onHideWarningsChange:x,onDownloadYamlClick:p,onDownloadJsonClick:g,onFileLoad:b,onToggleFullPreview:d}){const s=k(null),[w,r]=C(!1),E=()=>{s.current?.click()},h=()=>r(o=>!o),v=o=>{const l=o.target.files?.[0];if(!l)return;const a=new FileReader;a.onload=i=>{const y=i.target?.result;b(y,l.name)},a.onerror=i=>{console.error("Failed to read file!",i)},a.readAsText(l),o.target.value=""};return e.createElement(z,null,e.createElement(A,null,e.createElement("input",{type:"checkbox",checked:u,onChange:o=>x(o.target.checked),id:"hide-warnings"}),"Hide warnings"),e.createElement(B,null,d&&e.createElement(c,{tip:"Enter full preview mode",width:"fit-content"},e.createElement(n,{variant:"text",onClick:d,"aria-label":"Enter full preview",icon:e.createElement(I,null)})),e.createElement(c,{tip:"Upload spec",width:"fit-content"},e.createElement(n,{variant:"text",icon:e.createElement(m,{style:{transform:"rotate(180deg)"}}),onClick:E,"aria-label":"Upload spec"})),e.createElement(O,{type:"file",ref:s,onChange:v,accept:".yaml,.yml,.json"}),e.createElement(F,null,e.createElement(n,{variant:"text",onClick:p,iconPosition:"left",icon:e.createElement(m,null)},"Download"),e.createElement(c,{tip:"Download options",width:"fit-content"},e.createElement(n,{icon:e.createElement(D,null),onClick:h,"aria-label":"Download options"})),w&&e.createElement(M,null,e.createElement(f,{onClick:()=>{p(),r(!1)}},"Download YAML"),e.createElement(f,{onClick:()=>{g(),r(!1)}},"Download JSON")))))}const z=t.div`
1
+ import e,{useRef as z,useState as m}from"react";import n from"styled-components";import{Button as l}from"@redocly/theme/components/Button/Button";import{Tooltip as s}from"@redocly/theme/components/Tooltip/Tooltip";import{DownloadIcon as g}from"@redocly/theme/icons/DownloadIcon/DownloadIcon";import{ChevronDownIcon as R}from"@redocly/theme/icons/ChevronDownIcon/ChevronDownIcon";import{ViewIcon as A}from"@redocly/theme/icons/ViewIcon/ViewIcon";function B({hideWarnings:v,onHideWarningsChange:y,onDownloadYamlClick:d,onDownloadJsonClick:E,onFileLoad:b,onToggleFullPreview:u,isDownloadDisabled:o}){const f=z(null),[h,i]=m(!1),[w,k]=m(!1);e.useEffect(()=>{k(!0)},[]);const r=!w||o,C=t=>{t.preventDefault(),t.stopPropagation(),f.current?.click()},I=t=>{t?.preventDefault(),t?.stopPropagation(),i(a=>!a)},D=t=>{if(r){t.preventDefault(),t.stopPropagation();return}t.preventDefault(),t.stopPropagation(),d()},P=t=>{const a=t.target.files?.[0];if(!a)return;const c=new FileReader;c.onload=p=>{const M=p.target?.result;b(M,a.name)},c.onerror=p=>{console.error("Failed to read file!",p)},c.readAsText(a),t.target.value=""};return e.createElement(F,null,e.createElement(O,null,e.createElement("input",{type:"checkbox",checked:v,onChange:t=>y(t.target.checked),id:"hide-warnings"}),"Hide warnings"),e.createElement(T,null,u&&e.createElement(s,{tip:"Enter full preview mode",width:"fit-content"},e.createElement(l,{variant:"text",type:"button",to:void 0,onClick:u,"aria-label":"Enter full preview",icon:e.createElement(A,null)})),e.createElement(s,{tip:"Upload spec",width:"fit-content"},e.createElement(l,{variant:"text",type:"button",to:void 0,icon:e.createElement(g,{style:{transform:"rotate(180deg)"}}),onClick:C,"aria-label":"Upload spec"})),e.createElement(S,{type:"file",ref:f,onChange:P,accept:".yaml,.yml,.json"}),e.createElement(U,null,e.createElement("div",{style:{position:"relative"}},r&&e.createElement("div",{style:{position:"absolute",inset:0,zIndex:10,cursor:"not-allowed"}}),e.createElement(l,{variant:"text",type:"button",to:void 0,onClick:D,iconPosition:"left",icon:e.createElement(g,null),disabled:r,style:{opacity:r?.5:1,pointerEvents:r?"none":"auto"}},"Download")),e.createElement(s,{tip:"Download options",width:"fit-content"},e.createElement(l,{type:"button",to:void 0,icon:e.createElement(R,null),onClick:I,"aria-label":"Download options"})),h&&e.createElement(H,null,e.createElement(x,{onClick:t=>{o||(t.preventDefault(),t.stopPropagation(),d(),i(!1))},style:{opacity:o?.5:1,cursor:o?"not-allowed":"pointer"}},"Download YAML"),e.createElement(x,{onClick:t=>{o||(t.preventDefault(),t.stopPropagation(),E(),i(!1))},style:{opacity:o?.5:1,cursor:o?"not-allowed":"pointer"}},"Download JSON")))))}const F=n.div`
2
2
  padding: 6px 12px;
3
3
  border-bottom: 1px solid var(--border-color-primary);
4
4
  display: flex;
@@ -6,25 +6,25 @@ import e,{useRef as k,useState as C}from"react";import t from"styled-components"
6
6
  background-color: var(--bg-color);
7
7
  color: var(--text-color-primary);
8
8
  gap: 16px;
9
- `,A=t.label`
9
+ `,O=n.label`
10
10
  display: flex;
11
11
  align-items: center;
12
12
  gap: 8px;
13
13
  font-size: 0.875rem;
14
14
  cursor: pointer;
15
- `,B=t.div`
15
+ `,T=n.div`
16
16
  display: flex;
17
17
  align-items: center;
18
18
  gap: 8px;
19
19
  margin-left: auto; /* Push to far right */
20
- `,F=t.div`
20
+ `,U=n.div`
21
21
  position: relative;
22
22
  display: inline-flex;
23
23
  align-items: center;
24
24
  display: flex;
25
25
  flex-direction: row;
26
26
  gap: calc(var(--spacing-xxs) / 2);
27
- `,M=t.ul`
27
+ `,H=n.ul`
28
28
  position: absolute;
29
29
  right: 0;
30
30
  top: 100%;
@@ -38,13 +38,13 @@ import e,{useRef as k,useState as C}from"react";import t from"styled-components"
38
38
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
39
39
  min-width: 140px;
40
40
  z-index: 20;
41
- `,f=t.li`
41
+ `,x=n.li`
42
42
  padding: 6px 12px;
43
43
  font-size: 0.875rem;
44
44
  cursor: pointer;
45
45
  &:hover {
46
46
  background-color: var(--bg-color-active, #f5f5f5);
47
47
  }
48
- `,O=t.input`
48
+ `,S=n.input`
49
49
  display: none;
50
- `;export{R as default};
50
+ `;export{B as default};
@@ -1 +1 @@
1
- import{dump as h,load as s}from"js-yaml";import{downloadFile as c}from"../utils/download";import{defaultOpenapiTemplate as j}from"../templates/defaultOpenapiTemplate";import{useCallback as l}from"react";function S(d){const{setValue:n,setFileName:i,setHasRenderedOnce:e,setValidationErrors:a}=d,p=l((o,t)=>{n(o),i(t),e(!1),a([])},[n,i,e,a]),m=l(()=>{n(j),e(!1),a([])},[n,e,a]),f=l(o=>{let t=o;try{if(o.trim().startsWith("{")){const r=JSON.parse(o);t=h(r)}else s(o),t=o}catch{try{s(o),t=o}catch{alert("Content is not valid JSON or YAML. Cannot convert to YAML for download.");return}}c(t,"openapi.yaml","application/x-yaml")},[]),O=l(o=>{try{const t=s(o);if(typeof t!="object"||t===null)throw new Error("Parsed content is not an object.");const r=JSON.stringify(t,null,2);c(r,"openapi.json","application/json")}catch{alert("Content is not valid YAML/JSON. Cannot convert to JSON for download.")}},[]);return{handleFileLoad:p,handleTemplateClick:m,handleDownloadYaml:f,handleDownloadJson:O}}export{S as useFileOperations};
1
+ import{dump as w,load as s}from"js-yaml";import{downloadFile as c}from"../utils/download";import{defaultOpenapiTemplate as y}from"../templates/defaultOpenapiTemplate";import{useCallback as i}from"react";function N(d){const{setValue:t,setFileName:l,setHasRenderedOnce:r,setValidationErrors:e}=d,p=i((o,n)=>{t(o),l(n),r(!1),e([])},[t,l,r,e]),m=i(()=>{t(y),r(!1),e([])},[t,r,e]),f=i(o=>{if(!o||!o.trim())return;let n=o;try{if(o.trim().startsWith("{")){const a=JSON.parse(o);n=w(a)}else s(o),n=o}catch{try{s(o),n=o}catch(j){console.error("Invalid content for YAML download",j);return}}c(n,"openapi.yaml","application/x-yaml")},[]),h=i(o=>{if(!(!o||!o.trim()))try{const n=s(o);if(typeof n!="object"||n===null)throw new Error("Parsed content is not an object.");const a=JSON.stringify(n,null,2);c(a,"openapi.json","application/json")}catch(n){console.error("Invalid content for JSON download",n)}},[]);return{handleFileLoad:p,handleTemplateClick:m,handleDownloadYaml:f,handleDownloadJson:h}}export{N as useFileOperations};
@@ -1 +1 @@
1
- const c=(o,t,d)=>{const e=document.createElement("a"),n=new Blob([o],{type:d});e.href=URL.createObjectURL(n),e.download=t,document.body.appendChild(e),e.click(),document.body.removeChild(e)};export{c as downloadFile};
1
+ const l=100,a=(t,n,c)=>{const d=new Blob([t],{type:c}),o=URL.createObjectURL(d),e=document.createElement("a");e.href=o,e.download=n,e.target="_blank",e.style.display="none",document.body.appendChild(e),e.click(),setTimeout(()=>{document.body.contains(e)&&document.body.removeChild(e),URL.revokeObjectURL(o)},100)};export{a as downloadFile};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/marketing-pages",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "keywords": [],
5
5
  "author": "",
6
6
  "license": "UNLICENSED",
@@ -26,7 +26,6 @@
26
26
  "@monaco-editor/react": "^4.7.0",
27
27
  "@rebilly/lead-source-tracker": "^2.18.13",
28
28
  "@redocly/json-to-json-schema": "^0.0.1",
29
- "@redocly/openapi-docs": "^3.14.1",
30
29
  "@redocly/openapi-language-server": "^0.6.9",
31
30
  "@uiw/react-codemirror": "^4.23.12",
32
31
  "dayjs": "^1.11.13",
@@ -54,14 +53,16 @@
54
53
  "vitest": "^3.1.3"
55
54
  },
56
55
  "peerDependencies": {
57
- "react": "^18.3.1 || ^19.0.0",
58
- "react-dom": "^18.3.1 || ^19.0.0",
59
- "styled-components": ">=5.3.11"
56
+ "@redocly/openapi-docs": "^3.14.1",
57
+ "react": "^18.3.1",
58
+ "react-dom": "^18.3.1",
59
+ "styled-components": "^5.3.11"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@changesets/cli": "^2.29.5",
63
63
  "@markdoc/markdoc": "0.5.1",
64
64
  "@redocly/config": "^0.24.0",
65
+ "@redocly/openapi-docs": "^3.14.1",
65
66
  "@redocly/theme": "^0.53.0",
66
67
  "@shikijs/types": "3.4.0",
67
68
  "@types/js-yaml": "^4.0.9",
@@ -72,7 +73,7 @@
72
73
  "esbuild": "^0.25.4",
73
74
  "react": "^18.3.1",
74
75
  "react-dom": "^18.3.1",
75
- "styled-components": ">=5.3.11",
76
+ "styled-components": "5.3.11",
76
77
  "typescript": "^5.8.3"
77
78
  },
78
79
  "overrides": {