@kubed/diff-viewer 0.3.0-alpha.1 → 0.3.0-alpha.3

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/cjs/DiffViewer.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react"),w=require("diff"),d=require("diff2html"),c=require("@kubed/icons"),o=require("./styles.js");function E(e){return e&&typeof e=="object"&&"default"in e?e.default:e}var l=E(i),j=Object.defineProperty,p=Object.getOwnPropertySymbols,D=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,y=(e,r,t)=>r in e?j(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,_=(e,r)=>{for(var t in r||(r={}))D.call(r,t)&&y(e,t,r[t]);if(p)for(var t of p(r))O.call(r,t)&&y(e,t,r[t]);return e};const u=(e,r,t={})=>{const a=w.createPatch("yaml",e,r,"","",{context:-1}),n=d.parse(a);return d.html(n,_({drawFileList:!1},t))},g=({title:e,description:r,mode:t="line-by-line",oldValue:a,newValue:n})=>{const[v,b]=i.useState(t),[h,s]=i.useState(u(a,n,{outputFormat:t})),f=m=>{b(m),s(u(a,n,{outputFormat:m}))};return i.useEffect(()=>{s(u(a,n,{outputFormat:v}))},[a,n]),l.createElement(o.DiffWrapper,null,l.createElement(o.Header,null,l.createElement(c.Terminal,{size:20}),l.createElement(o.Title,null,e),l.createElement(c.ChevronDown,{size:20,className:"switch-mode",onClick:()=>{f("line-by-line")}}),l.createElement(c.ChevronRight,{size:20,className:"switch-mode",onClick:()=>{f("side-by-side")}}),l.createElement(o.Description,null,r)),l.createElement("div",{dangerouslySetInnerHTML:{__html:h}}))};exports.DiffViewer=g;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var i=require("react/jsx-runtime"),l=require("react"),b=require("diff"),m=require("diff2html"),o=require("@kubed/icons"),n=require("./styles.js"),x=Object.defineProperty,p=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,v=(t,e,r)=>e in t?x(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,q=(t,e)=>{for(var r in e||(e={}))w.call(e,r)&&v(t,r,e[r]);if(p)for(var r of p(e))O.call(e,r)&&v(t,r,e[r]);return t};const c=(t,e,r={})=>{const s=b.createPatch("yaml",t,e,"","",{context:-1}),a=m.parse(s);return m.html(a,q({drawFileList:!1},r))},D=({title:t,description:e,mode:r="line-by-line",oldValue:s,newValue:a})=>{const[j,y]=l.useState(r),[h,u]=l.useState(c(s,a,{outputFormat:r})),d=f=>{y(f),u(c(s,a,{outputFormat:f}))};return l.useEffect(()=>{u(c(s,a,{outputFormat:j}))},[s,a]),i.jsxs(n.DiffWrapper,{children:[i.jsxs(n.Header,{children:[i.jsx(o.Terminal,{size:20}),i.jsx(n.Title,{children:t}),i.jsx(o.ChevronDown,{size:20,className:"switch-mode",onClick:()=>{d("line-by-line")}}),i.jsx(o.ChevronRight,{size:20,className:"switch-mode",onClick:()=>{d("side-by-side")}}),i.jsx(n.Description,{children:e})]}),i.jsx("div",{dangerouslySetInnerHTML:{__html:h}})]})};exports.DiffViewer=D;
2
2
  //# sourceMappingURL=DiffViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DiffViewer.js","sources":["../src/DiffViewer.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { createPatch } from 'diff';\nimport { parse, html } from 'diff2html';\nimport { Terminal, ChevronDown, ChevronRight } from '@kubed/icons';\nimport { DiffWrapper, Header, Title, Description } from './styles';\n\nconst getDiffHtml = (oldValue, newValue, options = {}) => {\n const diffStr = createPatch('yaml', oldValue, newValue, '', '', {\n context: -1,\n });\n const diffJson = parse(diffStr);\n return html(diffJson, {\n drawFileList: false,\n ...options,\n });\n};\n\nexport interface DiffViewerProps {\n title?: string | React.ReactNode;\n description?: string | React.ReactNode;\n mode?: 'line-by-line' | 'side-by-side';\n oldValue: string;\n newValue: string;\n}\n\nexport const DiffViewer = ({\n title,\n description,\n mode = 'line-by-line',\n oldValue,\n newValue,\n}: DiffViewerProps) => {\n const [_mode, setMode] = useState(mode);\n const [diffHtml, setDiffHtml] = useState(getDiffHtml(oldValue, newValue, { outputFormat: mode }));\n\n const handleModeChange = (m) => {\n setMode(m);\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: m }));\n };\n\n useEffect(() => {\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: _mode }));\n }, [oldValue, newValue]);\n\n return (\n <DiffWrapper>\n <Header>\n <Terminal size={20} />\n <Title>{title}</Title>\n <ChevronDown\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('line-by-line');\n }}\n />\n <ChevronRight\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('side-by-side');\n }}\n />\n <Description>{description}</Description>\n </Header>\n <div\n dangerouslySetInnerHTML={{\n __html: diffHtml,\n }}\n />\n </DiffWrapper>\n );\n};\n"],"names":["w","C","F","a","H","r","v","x","N","z","T","k","M"],"mappings":";;;;;;;;;;;;;;AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAA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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,OAAOC,WAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,UAAC,CAAC,aAAa,CAACC,kBAAC,CAAC,IAAI,CAACD,UAAC,CAAC,aAAa,CAACE,aAAC,CAAC,IAAI,CAACF,UAAC,CAAC,aAAa,CAACG,cAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAACH,UAAC,CAAC,aAAa,CAACI,YAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAACJ,UAAC,CAAC,aAAa,CAACK,iBAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC,CAACL,UAAC,CAAC,aAAa,CAACM,kBAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC,CAACN,UAAC,CAAC,aAAa,CAACO,kBAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAACP,UAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"DiffViewer.js","sources":["../src/DiffViewer.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { createPatch } from 'diff';\nimport { parse, html } from 'diff2html';\nimport { Terminal, ChevronDown, ChevronRight } from '@kubed/icons';\nimport { DiffWrapper, Header, Title, Description } from './styles';\n\nconst getDiffHtml = (oldValue, newValue, options = {}) => {\n const diffStr = createPatch('yaml', oldValue, newValue, '', '', {\n context: -1,\n });\n const diffJson = parse(diffStr);\n return html(diffJson, {\n drawFileList: false,\n ...options,\n });\n};\n\nexport interface DiffViewerProps {\n title?: string | React.ReactNode;\n description?: string | React.ReactNode;\n mode?: 'line-by-line' | 'side-by-side';\n oldValue: string;\n newValue: string;\n}\n\nexport const DiffViewer = ({\n title,\n description,\n mode = 'line-by-line',\n oldValue,\n newValue,\n}: DiffViewerProps) => {\n const [_mode, setMode] = useState(mode);\n const [diffHtml, setDiffHtml] = useState(getDiffHtml(oldValue, newValue, { outputFormat: mode }));\n\n const handleModeChange = (m) => {\n setMode(m);\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: m }));\n };\n\n useEffect(() => {\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: _mode }));\n }, [oldValue, newValue]);\n\n return (\n <DiffWrapper>\n <Header>\n <Terminal size={20} />\n <Title>{title}</Title>\n <ChevronDown\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('line-by-line');\n }}\n />\n <ChevronRight\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('side-by-side');\n }}\n />\n <Description>{description}</Description>\n </Header>\n <div\n dangerouslySetInnerHTML={{\n __html: diffHtml,\n }}\n />\n </DiffWrapper>\n );\n};\n"],"names":["w","C","F","l","b","h","z","M","s","N","P","T","v","S"],"mappings":";;;;;;;;;;;AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC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,CAAC,CAAC;;;;"}
package/esm/DiffViewer.js CHANGED
@@ -1,2 +1,2 @@
1
- import l,{useState as s,useEffect as y}from"react";import{createPatch as h}from"diff";import{parse as v,html as E}from"diff2html";import{Terminal as w,ChevronDown as O,ChevronRight as g}from"@kubed/icons";import{DiffWrapper as j,Header as D,Title as C,Description as F}from"./styles.js";var P=Object.defineProperty,p=Object.getOwnPropertySymbols,k=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable,u=(t,e,r)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,S=(t,e)=>{for(var r in e||(e={}))k.call(e,r)&&u(t,r,e[r]);if(p)for(var r of p(e))z.call(e,r)&&u(t,r,e[r]);return t};const a=(t,e,r={})=>{const n=h("yaml",t,e,"","",{context:-1}),o=v(n);return E(o,S({drawFileList:!1},r))},T=({title:t,description:e,mode:r="line-by-line",oldValue:n,newValue:o})=>{const[f,b]=s(r),[d,i]=s(a(n,o,{outputFormat:r})),m=c=>{b(c),i(a(n,o,{outputFormat:c}))};return y(()=>{i(a(n,o,{outputFormat:f}))},[n,o]),l.createElement(j,null,l.createElement(D,null,l.createElement(w,{size:20}),l.createElement(C,null,t),l.createElement(O,{size:20,className:"switch-mode",onClick:()=>{m("line-by-line")}}),l.createElement(g,{size:20,className:"switch-mode",onClick:()=>{m("side-by-side")}}),l.createElement(F,null,e)),l.createElement("div",{dangerouslySetInnerHTML:{__html:d}}))};export{T as DiffViewer};
1
+ import{jsxs as s,jsx as n}from"react/jsx-runtime";import{useState as p,useEffect as b}from"react";import{createPatch as v}from"diff";import{parse as w,html as j}from"diff2html";import{Terminal as O,ChevronDown as g,ChevronRight as D}from"@kubed/icons";import{DiffWrapper as x,Header as C,Title as F,Description as P}from"./styles.js";var z=Object.defineProperty,f=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable,u=(t,e,r)=>e in t?z(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,T=(t,e)=>{for(var r in e||(e={}))H.call(e,r)&&u(t,r,e[r]);if(f)for(var r of f(e))S.call(e,r)&&u(t,r,e[r]);return t};const l=(t,e,r={})=>{const o=v("yaml",t,e,"","",{context:-1}),i=w(o);return j(i,T({drawFileList:!1},r))},V=({title:t,description:e,mode:r="line-by-line",oldValue:o,newValue:i})=>{const[d,h]=p(r),[y,a]=p(l(o,i,{outputFormat:r})),c=m=>{h(m),a(l(o,i,{outputFormat:m}))};return b(()=>{a(l(o,i,{outputFormat:d}))},[o,i]),s(x,{children:[s(C,{children:[n(O,{size:20}),n(F,{children:t}),n(g,{size:20,className:"switch-mode",onClick:()=>{c("line-by-line")}}),n(D,{size:20,className:"switch-mode",onClick:()=>{c("side-by-side")}}),n(P,{children:e})]}),n("div",{dangerouslySetInnerHTML:{__html:y}})]})};export{V as DiffViewer};
2
2
  //# sourceMappingURL=DiffViewer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DiffViewer.js","sources":["../src/DiffViewer.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { createPatch } from 'diff';\nimport { parse, html } from 'diff2html';\nimport { Terminal, ChevronDown, ChevronRight } from '@kubed/icons';\nimport { DiffWrapper, Header, Title, Description } from './styles';\n\nconst getDiffHtml = (oldValue, newValue, options = {}) => {\n const diffStr = createPatch('yaml', oldValue, newValue, '', '', {\n context: -1,\n });\n const diffJson = parse(diffStr);\n return html(diffJson, {\n drawFileList: false,\n ...options,\n });\n};\n\nexport interface DiffViewerProps {\n title?: string | React.ReactNode;\n description?: string | React.ReactNode;\n mode?: 'line-by-line' | 'side-by-side';\n oldValue: string;\n newValue: string;\n}\n\nexport const DiffViewer = ({\n title,\n description,\n mode = 'line-by-line',\n oldValue,\n newValue,\n}: DiffViewerProps) => {\n const [_mode, setMode] = useState(mode);\n const [diffHtml, setDiffHtml] = useState(getDiffHtml(oldValue, newValue, { outputFormat: mode }));\n\n const handleModeChange = (m) => {\n setMode(m);\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: m }));\n };\n\n useEffect(() => {\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: _mode }));\n }, [oldValue, newValue]);\n\n return (\n <DiffWrapper>\n <Header>\n <Terminal size={20} />\n <Title>{title}</Title>\n <ChevronDown\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('line-by-line');\n }}\n />\n <ChevronRight\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('side-by-side');\n }}\n />\n <Description>{description}</Description>\n </Header>\n <div\n dangerouslySetInnerHTML={{\n __html: diffHtml,\n }}\n />\n </DiffWrapper>\n );\n};\n"],"names":["w","C","F","a","H","v","x","N","z","T","k","M"],"mappings":";;;;;;AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAACC,WAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAACC,MAAC,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAACC,QAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAACC,KAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAACC,WAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAACC,YAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAACC,WAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
1
+ {"version":3,"file":"DiffViewer.js","sources":["../src/DiffViewer.tsx"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport { createPatch } from 'diff';\nimport { parse, html } from 'diff2html';\nimport { Terminal, ChevronDown, ChevronRight } from '@kubed/icons';\nimport { DiffWrapper, Header, Title, Description } from './styles';\n\nconst getDiffHtml = (oldValue, newValue, options = {}) => {\n const diffStr = createPatch('yaml', oldValue, newValue, '', '', {\n context: -1,\n });\n const diffJson = parse(diffStr);\n return html(diffJson, {\n drawFileList: false,\n ...options,\n });\n};\n\nexport interface DiffViewerProps {\n title?: string | React.ReactNode;\n description?: string | React.ReactNode;\n mode?: 'line-by-line' | 'side-by-side';\n oldValue: string;\n newValue: string;\n}\n\nexport const DiffViewer = ({\n title,\n description,\n mode = 'line-by-line',\n oldValue,\n newValue,\n}: DiffViewerProps) => {\n const [_mode, setMode] = useState(mode);\n const [diffHtml, setDiffHtml] = useState(getDiffHtml(oldValue, newValue, { outputFormat: mode }));\n\n const handleModeChange = (m) => {\n setMode(m);\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: m }));\n };\n\n useEffect(() => {\n setDiffHtml(getDiffHtml(oldValue, newValue, { outputFormat: _mode }));\n }, [oldValue, newValue]);\n\n return (\n <DiffWrapper>\n <Header>\n <Terminal size={20} />\n <Title>{title}</Title>\n <ChevronDown\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('line-by-line');\n }}\n />\n <ChevronRight\n size={20}\n className=\"switch-mode\"\n onClick={() => {\n handleModeChange('side-by-side');\n }}\n />\n <Description>{description}</Description>\n </Header>\n <div\n dangerouslySetInnerHTML={{\n __html: diffHtml,\n }}\n />\n </DiffWrapper>\n );\n};\n"],"names":["w","C","F","l","b","h","z","M","s","N","P","T","v","S"],"mappings":";;;;;;;AAAA,IAAI,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,OAAOC,SAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,IAAC,CAACC,WAAC,CAAC,CAAC,QAAQ,CAAC,CAACD,IAAC,CAACE,MAAC,CAAC,CAAC,QAAQ,CAAC,CAACC,GAAC,CAACC,QAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAACD,GAAC,CAACE,KAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAACF,GAAC,CAACG,WAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC,CAACH,GAAC,CAACI,YAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAC,CAAC,CAAC,CAAC,CAACJ,GAAC,CAACK,WAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAACL,GAAC,CAAC,KAAK,CAAC,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;;;"}
package/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{DiffViewer as i}from"./DiffViewer.js";export{i as DiffViewer};
1
+ import{DiffViewer as r}from"./DiffViewer.js";export{r as DiffViewer};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubed/diff-viewer",
3
- "version": "0.3.0-alpha.1",
3
+ "version": "0.3.0-alpha.3",
4
4
  "homepage": "https://github.com/kubesphere/kube-design",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,10 +24,10 @@
24
24
  "styled-components": "^5.3.0"
25
25
  },
26
26
  "peerDependencies": {
27
- "@kubed/hooks": "0.3.0-alpha.1",
28
- "@kubed/icons": "0.3.0-alpha.1",
29
- "react": ">=16.8.6",
30
- "react-dom": ">=16.8.6",
31
- "react-is": ">=16.8.0 <20"
27
+ "@kubed/hooks": "0.3.0-alpha.3",
28
+ "@kubed/icons": "0.3.0-alpha.3",
29
+ "react": ">=19.0.0 <20",
30
+ "react-dom": ">=19.0.0 <20",
31
+ "react-is": ">=19.0.0 <20"
32
32
  }
33
33
  }