@splunk/dynamic-editors 0.36.1 → 0.36.2
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/CHANGELOG.md +11 -0
- package/DynamicEditor.js +2 -2
- package/DynamicEditor.js.map +1 -1
- package/containers/EditorItem.js +2 -2
- package/containers/EditorItem.js.map +1 -1
- package/containers/EditorLayout.js +2 -2
- package/containers/EditorLayout.js.map +1 -1
- package/containers/EditorLayoutItem.js +2 -2
- package/containers/EditorLayoutItem.js.map +1 -1
- package/editors/ImageEditor.js +2 -2
- package/editors/ImageEditor.js.map +1 -1
- package/editors/TableColumnFormatterEditor.js +2 -2
- package/editors/TableColumnFormatterEditor.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
`,Q={marginBottom:10},ee={width:"100%"},te=V().span`
|
|
10
10
|
font-size: smaller;
|
|
11
11
|
font-style: italic;
|
|
12
|
-
`,ae=(0,N._)("Note: Uploaded image files can be accessed and deleted by others in your organization"),oe=(0,Z.memoize)(((e,t)=>{const a=e.slice();if(t)-1===a.indexOf("svg")&&a.push("svg");else{const e=a.indexOf("svg");e>-1&&a.splice(e,1)}return a}),((e,t)=>`${t}-${e.join("-")}`));class le extends r.Component{constructor(e){super(e),L()(this,"violationHandler",(e=>{e.blockedURI!==this.state.urlValue&&e.blockedURI!==`${this.state.urlValue}/`||"enforce"!==e.disposition?e.blockedURI!==this.state.urlValue&&e.blockedURI!==`${this.state.urlValue}/`||"report"!==e.disposition||this.setState({violationType:"warning"}):this.setState({violationType:"error"})})),L()(this,"checkImage",(e=>{if(!e)return;const t=new Image;t.onload=()=>{this.props.handleImageUpload({src:e})},t.onerror=()=>{this.setState((e=>e.urlValue?{validUrl:!1}:void 0))},t.src=e})),L()(this,"handleURLChange",((e,{value:t})=>{this.setState({urlValue:t,validUrl:!0,violationType:"none"})})),L()(this,"handleTextKeyDown",(e=>{"Enter"===e.key&&(e.preventDefault(),this.checkImage(this.state.urlValue))})),L()(this,"handleBlur",(e=>{var t;null!==(t=this.inputRef.current)&&void 0!==t&&t.contains(e.relatedTarget)||this.checkImage(this.state.urlValue)})),L()(this,"trackInputRef",(e=>{this.inputRef.current=e,e&&e.addEventListener("focusout",this.handleBlur)})),L()(this,"handleOnImageChange",(({filename:e,imageDataURI:t})=>{e&&t?this.props.handleImageUpload({filename:e,imageDataURI:t}):this.props.handleImageUpload({filename:null,imageDataURI:null})})),this.state={urlValue:"",validUrl:!0,violationType:"none"},this.inputRef=n().createRef()}componentDidMount(){document.addEventListener("securitypolicyviolation",this.violationHandler)}componentWillUnmount(){document.removeEventListener("securitypolicyviolation",this.violationHandler),this.inputRef.current&&this.inputRef.current.removeEventListener("focusout",this.handleBlur)}render(){const{enableImageFileUpload:e,enableSVGImageUpload:t,enableSvgHttpDownloader:a,enableGallerySharingWarning:o}=this.context||{},l=oe(this.props.validImageTypes,t),r=l.indexOf("svg")<0||this.props.svgRenderAsDom&&l.indexOf("svg")>-1&&a||!this.props.svgRenderAsDom&&l.indexOf("svg")>-1,i="none"!==this.state.violationType?n().createElement(X.CSPMessage,{type:this.state.violationType}):n().createElement(W(),{appearance:"fill",type:"error"},(0,N._)("We can't find an image with this URL. Please enter a new URL."));return n().createElement(J,null,r&&n().createElement(z(),{canClear:!0,value:this.state.urlValue,onChange:this.handleURLChange,onKeyDown:this.handleTextKeyDown,style:Q,elementRef:this.trackInputRef}),this.state.validUrl?e&&n().createElement(n().Fragment,null,n().createElement(Y(),{style:ee,defaultFilename:null,defaultImageDataURI:null,onImageChange:this.handleOnImageChange,allowExtensions:l}),o&&n().createElement(te,{"data-test":"gallery-sharing-warning"},ae)):i)}}L()(le,"contextType",G()),le.propTypes={handleImageUpload:s().func,validImageTypes:s().array,svgRenderAsDom:s().bool},le.defaultProps={handleImageUpload:()=>{},validImageTypes:["gif","jpeg","jpg","png","webp"],svgRenderAsDom:!1};const re=le;var ne=a(8855),ie=a.n(ne),se=a(7020),ue=a.n(se),ce=a(3563),de=a(5135),fe=a(137);const pe=n().createElement(ie(),
|
|
12
|
+
`,ae=(0,N._)("Note: Uploaded image files can be accessed and deleted by others in your organization"),oe=(0,Z.memoize)(((e,t)=>{const a=e.slice();if(t)-1===a.indexOf("svg")&&a.push("svg");else{const e=a.indexOf("svg");e>-1&&a.splice(e,1)}return a}),((e,t)=>`${t}-${e.join("-")}`));class le extends r.Component{constructor(e){super(e),L()(this,"violationHandler",(e=>{e.blockedURI!==this.state.urlValue&&e.blockedURI!==`${this.state.urlValue}/`||"enforce"!==e.disposition?e.blockedURI!==this.state.urlValue&&e.blockedURI!==`${this.state.urlValue}/`||"report"!==e.disposition||this.setState({violationType:"warning"}):this.setState({violationType:"error"})})),L()(this,"checkImage",(e=>{if(!e)return;const t=new Image;t.onload=()=>{this.props.handleImageUpload({src:e})},t.onerror=()=>{this.setState((e=>e.urlValue?{validUrl:!1}:void 0))},t.src=e})),L()(this,"handleURLChange",((e,{value:t})=>{this.setState({urlValue:t,validUrl:!0,violationType:"none"})})),L()(this,"handleTextKeyDown",(e=>{"Enter"===e.key&&(e.preventDefault(),this.checkImage(this.state.urlValue))})),L()(this,"handleBlur",(e=>{var t;null!==(t=this.inputRef.current)&&void 0!==t&&t.contains(e.relatedTarget)||this.checkImage(this.state.urlValue)})),L()(this,"trackInputRef",(e=>{this.inputRef.current=e,e&&e.addEventListener("focusout",this.handleBlur)})),L()(this,"handleOnImageChange",(({filename:e,imageDataURI:t})=>{e&&t?this.props.handleImageUpload({filename:e,imageDataURI:t}):this.props.handleImageUpload({filename:null,imageDataURI:null})})),this.state={urlValue:"",validUrl:!0,violationType:"none"},this.inputRef=n().createRef()}componentDidMount(){document.addEventListener("securitypolicyviolation",this.violationHandler)}componentWillUnmount(){document.removeEventListener("securitypolicyviolation",this.violationHandler),this.inputRef.current&&this.inputRef.current.removeEventListener("focusout",this.handleBlur)}render(){const{enableImageFileUpload:e,enableSVGImageUpload:t,enableSvgHttpDownloader:a,enableGallerySharingWarning:o}=this.context||{},l=oe(this.props.validImageTypes,t),r=l.indexOf("svg")<0||this.props.svgRenderAsDom&&l.indexOf("svg")>-1&&a||!this.props.svgRenderAsDom&&l.indexOf("svg")>-1,i="none"!==this.state.violationType?n().createElement(X.CSPMessage,{type:this.state.violationType}):n().createElement(W(),{appearance:"fill",type:"error"},(0,N._)("We can't find an image with this URL. Please enter a new URL."));return n().createElement(J,null,r&&n().createElement(z(),{canClear:!0,value:this.state.urlValue,onChange:this.handleURLChange,onKeyDown:this.handleTextKeyDown,style:Q,elementRef:this.trackInputRef}),this.state.validUrl?e&&n().createElement(n().Fragment,null,n().createElement(Y(),{style:ee,defaultFilename:null,defaultImageDataURI:null,onImageChange:this.handleOnImageChange,allowExtensions:l}),o&&n().createElement(te,{"data-test":"gallery-sharing-warning"},ae)):i)}}L()(le,"contextType",G()),le.propTypes={handleImageUpload:s().func,validImageTypes:s().array,svgRenderAsDom:s().bool},le.defaultProps={handleImageUpload:()=>{},validImageTypes:["gif","jpeg","jpg","png","webp"],svgRenderAsDom:!1};const re=le;var ne=a(8855),ie=a.n(ne),se=a(7020),ue=a.n(se),ce=a(3563),de=a(5135),fe=a(137);const pe=n().createElement(ie(),null),me=V().div`
|
|
13
13
|
width: 100%;
|
|
14
14
|
padding-bottom: 5px;
|
|
15
15
|
`,be=V().div`
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
margin: 0 auto;
|
|
45
45
|
max-width: 100%;
|
|
46
46
|
max-height: 180px;
|
|
47
|
-
`,Ce=({filename:e,imageDataURI:t,onImageRemove:a,overrideCSPViolation:o})=>{const l=(0,de.useCSPViolationObserver)(t,o);return n().createElement(me,null,n().createElement(be,null,n().createElement(ge,null,n().createElement(he,null,e),n().createElement(ye,{appearance:"subtle",icon:pe,onClick:a})),n().createElement(ve,{alt:e,src:t})),"none"!==l&&n().createElement(fe.MessageContainer,null,n().createElement(X.CSPMessage,{type:l})))};Ce.propTypes={filename:s().string,imageDataURI:s().string,onImageRemove:s().func,overrideCSPViolation:s().string},Ce.defaultProps={onImageRemove:()=>{},filename:null,imageDataURI:null};const _e=Ce,Oe=({onChange:e,name:t,value:a,labelPosition:o,labelWidth:l,label:i,validMediaTypes:s,svgRenderAsDom:u,overrideCSPViolation:c})=>{const d=(0,r.useContext)(A()),[f,p]=(0,r.useState)(null),[m,b]=(0,r.useState)(null),g=(0,r.useCallback)((async(a,o)=>{try{const l=await d.upload(o,{name:a},null,s);e(null,t,l)}catch(e){console.warn(e)}}),[d,s,e,t]),y=(0,r.useCallback)((({src:a,filename:o,imageDataURI:l})=>a?e(null,t,a):null!==o&&null!==l?g(o,l):e(null,t,null)),[g,e,t]),v=(0,r.useCallback)((a=>e(a,t,null)),[e,t]);return(0,r.useEffect)((()=>{(async()=>{if(a){const e=await(async(e,t)=>null!=e&&e.isResourceURL(t)?e.getByURL(t):{dataURI:t,metaData:{name:t}})(d,a);p(e.dataURI),b(e.metaData.name)}})()}),[a,d]),n().createElement(h(),{label:i,labelPosition:o,labelWidth:l},a?n().createElement(_e,{filename:m,imageDataURI:f,onImageRemove:v,overrideCSPViolation:c}):n().createElement(re,{svgRenderAsDom:u,validImageTypes:s,handleImageUpload:y}))};Oe.propTypes={onChange:s().func.isRequired,name:s().string.isRequired,label:s().string.isRequired,value:s().string,labelPosition:s().oneOf(["top","left"]),labelWidth:s().number,validMediaTypes:s().array,svgRenderAsDom:s().bool,overrideCSPViolation:s().string},Oe.defaultProps={labelPosition:"top"};const Ee=Oe;var Pe=a(1785),je=a.n(Pe),xe=a(5777),Te=a.n(xe),De=a(4566),we=a.n(De);const Se=V().div.attrs((()=>({"data-test":"threshold-error"})))`
|
|
47
|
+
`,Ce=({filename:e,imageDataURI:t,onImageRemove:a,overrideCSPViolation:o})=>{const l=(0,de.useCSPViolationObserver)(t,o);return n().createElement(me,null,n().createElement(be,null,n().createElement(ge,null,n().createElement(he,null,e),n().createElement(ye,{"aria-label":(0,N._)("Remove image"),appearance:"subtle",icon:pe,onClick:a})),n().createElement(ve,{alt:e,src:t})),"none"!==l&&n().createElement(fe.MessageContainer,null,n().createElement(X.CSPMessage,{type:l})))};Ce.propTypes={filename:s().string,imageDataURI:s().string,onImageRemove:s().func,overrideCSPViolation:s().string},Ce.defaultProps={onImageRemove:()=>{},filename:null,imageDataURI:null};const _e=Ce,Oe=({onChange:e,name:t,value:a,labelPosition:o,labelWidth:l,label:i,validMediaTypes:s,svgRenderAsDom:u,overrideCSPViolation:c})=>{const d=(0,r.useContext)(A()),[f,p]=(0,r.useState)(null),[m,b]=(0,r.useState)(null),g=(0,r.useCallback)((async(a,o)=>{try{const l=await d.upload(o,{name:a},null,s);e(null,t,l)}catch(e){console.warn(e)}}),[d,s,e,t]),y=(0,r.useCallback)((({src:a,filename:o,imageDataURI:l})=>a?e(null,t,a):null!==o&&null!==l?g(o,l):e(null,t,null)),[g,e,t]),v=(0,r.useCallback)((a=>e(a,t,null)),[e,t]);return(0,r.useEffect)((()=>{(async()=>{if(a){const e=await(async(e,t)=>null!=e&&e.isResourceURL(t)?e.getByURL(t):{dataURI:t,metaData:{name:t}})(d,a);p(e.dataURI),b(e.metaData.name)}})()}),[a,d]),n().createElement(h(),{label:i,labelPosition:o,labelWidth:l},a?n().createElement(_e,{filename:m,imageDataURI:f,onImageRemove:v,overrideCSPViolation:c}):n().createElement(re,{svgRenderAsDom:u,validImageTypes:s,handleImageUpload:y}))};Oe.propTypes={onChange:s().func.isRequired,name:s().string.isRequired,label:s().string.isRequired,value:s().string,labelPosition:s().oneOf(["top","left"]),labelWidth:s().number,validMediaTypes:s().array,svgRenderAsDom:s().bool,overrideCSPViolation:s().string},Oe.defaultProps={labelPosition:"top"};const Ee=Oe;var Pe=a(1785),je=a.n(Pe),xe=a(5777),Te=a.n(xe),De=a(4566),we=a.n(De);const Se=V().div.attrs((()=>({"data-test":"threshold-error"})))`
|
|
48
48
|
color: ${we().contentColorNegative};
|
|
49
49
|
padding-top: 5px;
|
|
50
50
|
font-size: 12px;
|