+(function(s,c){typeof exports=="object"&&typeof module<"u"?c(require("react"),require("react-dom"),require("shiny"),require("jquery")):typeof define=="function"&&define.amd?define(["react","react-dom","shiny","jquery"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.React,s.ReactDOM,s.Shiny,s.$))})(this,function(s,c,l,u){"use strict";function o(n,t){if(typeof t=="string")return t;if(t.name[0]===t.name[0].toUpperCase()&&!n.hasOwnProperty(t.name))throw new Error("Unknown component: "+t.name);for(var i=n.hasOwnProperty(t.name)?n[t.name]:t.name,r=[i,t.attribs],e=0;e<t.children.length;e++)r.push(o(n,t.children[e]));return React.createElement.apply(React,r)}const p={widthProperty:"width",heightProperty:"height",appendPx:!1,renderOnResize:!1};function w(n){var t={};for(var i in p)t[i]=p[i];for(var i in n){if(!p.hasOwnProperty(i))throw new Error("Unrecognized option: "+i);t[i]=n[i]}return t}function h(n,t){return t.appendPx?n+"px":n}function b(n,t,i,r){var e=w(r);window.HTMLWidgets.widget({name:n,type:t,factory:function(a,d,y){var g,P={},m=function(f){e.renderOnResize&&(typeof f.tag=="object"&&(f.tag.attribs[e.widthProperty]=h(d),f.tag.attribs[e.heightProperty]=h(y)),g=f),this.instance.component=ReactDOM.render(o(i,f.tag),a)};return{instance:P,renderValue:m,resize:function(f,v){e.renderOnResize&&(d=f,y=v,m(g))}}}})}function O(n,{configuration:t,value:i}){let r=!1;t!==void 0&&(this.setInputConfiguration(n,t),r=!0),i!==void 0&&(this.setInputValue(n,i),r=!0),r&&(this.getCallback(n)(),this.render(n))}const V={receiveMessage:O,type:!1,ratePolicy:null};function I(n,t,i,r){r=Object.assign({},V,r),l.inputBindings.register(new class extends l.InputBinding{find(e){return u(e).find(n)}getValue(e){return this.getInputValue(e)}setValue(e,a,d=!1){u(e).data("callback")!==void 0&&(this.setInputValue(e,a),this.getCallback(e)(d),this.render(e))}initialize(e){u(e).data("value",JSON.parse(u(e).next().text())),u(e).data("configuration",JSON.parse(u(e).next().next().text()))}subscribe(e,a){u(e).data("callback",a),this.render(e)}unsubscribe(e){c.render(null,e)}receiveMessage(e,a){r.receiveMessage.call(this,e,a)}getType(e){if(typeof r.type=="function")return r.type.call(this,e);if(r.type===!1||typeof r.type=="string")return r.type;throw new Error("options.type must be false, a string, or a function")}getRatePolicy(){return r.ratePolicy}getInputValue(e){return u(e).data("value")}setInputValue(e,a){u(e).data("value",a)}getInputConfiguration(e){return u(e).data("configuration")}setInputConfiguration(e,a){u(e).data("configuration",a)}getCallback(e){return u(e).data("callback")}render(e){const a=s.createElement(i,{configuration:this.getInputConfiguration(e),value:this.getValue(e),setValue:this.setValue.bind(this,e),el:e});c.render(a,e)}},t)}window.reactR={reactShinyInput:I,reactWidget:b,hydrate:o}});
0 commit comments