diff --git a/inst/www/react-tools/react-tools.js b/inst/www/react-tools/react-tools.js index c785223..f060187 100644 --- a/inst/www/react-tools/react-tools.js +++ b/inst/www/react-tools/react-tools.js @@ -157,7 +157,8 @@ function defaultReceiveMessage(el, _ref) { } var defaultOptions = { - receiveMessage: defaultReceiveMessage + receiveMessage: defaultReceiveMessage, + type: false }; /** * Installs a new Shiny input binding based on a React component. @@ -172,6 +173,16 @@ var defaultOptions = { * - receiveMessage: Implementation of Shiny.InputBinding to use in place of * the default. Typically overridden as an optimization to perform * incremental value updates. + * - type: `false`, a string, or a function. + * - `false` (the default): denotes that the value produced by this input + * should not be intercepted by any handlers registered in R on the + * server using shiny::registerInputHandler(). + * - string: denotes the input's *type* and should correspond to the + * type parameter of shiny::registerInputHandler(). + * - function: A function called with `this` bound to the InputBinding + * instance and passed a single argument, the input's containing DOM + * element. The function should return either `false` or a string + * corresponding to the type parameter of shiny::registerInputHandler(). */ function reactShinyInput(selector, name, component, options) { @@ -231,10 +242,21 @@ function reactShinyInput(selector, name, component, options) { value: function receiveMessage(el, data) { options.receiveMessage.call(this, el, data); } + }, { + key: "getType", + value: function getType(el) { + if (typeof options.type === 'function') { + return options.type.call(this, el); + } else if (options.type === false || typeof options.type === 'string') { + return options.type; + } else { + throw new Error('options.type must be false, a string, or a function'); + } + } /* * Methods not present in Shiny.InputBinding but accessible to users * through `this` in receiveMessage - * */ + */ }, { key: "getInputValue", diff --git a/inst/www/react-tools/react-tools.js.map b/inst/www/react-tools/react-tools.js.map index b4e27bf..7e3013f 100644 --- a/inst/www/react-tools/react-tools.js.map +++ b/inst/www/react-tools/react-tools.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./srcjs/input.js","webpack:///./srcjs/react-tools.js","webpack:///./srcjs/widget.js","webpack:///external \"window.jQuery\"","webpack:///external \"window.React\"","webpack:///external \"window.ReactDOM\"","webpack:///external \"window.Shiny\""],"names":["defaultReceiveMessage","el","configuration","value","dirty","undefined","setInputConfiguration","setInputValue","getCallback","render","defaultOptions","receiveMessage","reactShinyInput","selector","name","component","options","Object","assign","Shiny","inputBindings","register","scope","$","find","getInputValue","data","JSON","parse","next","text","callback","removeData","ReactDOM","call","element","React","createElement","getInputConfiguration","getValue","setValue","bind","InputBinding","window","reactR","reactWidget","hydrate","components","tag","toUpperCase","hasOwnProperty","Error","elem","args","attribs","i","children","length","push","apply","widthProperty","heightProperty","appendPx","renderOnResize","mergeOptions","merged","k","formatDimension","dim","isTag","type","actualOptions","HTMLWidgets","widget","factory","width","height","lastValue","instance","renderValue","resize","newWidth","newHeight"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AClFA;AACA;AACA;AACA;AAEA;;;;;;;;;AAQA,SAASA,qBAAT,CAA+BC,EAA/B,QAA6D;AAAA,MAAxBC,aAAwB,QAAxBA,aAAwB;AAAA,MAATC,KAAS,QAATA,KAAS;AAC3D,MAAIC,KAAK,GAAG,KAAZ;;AACA,MAAIF,aAAa,KAAKG,SAAtB,EAAiC;AAC/B,SAAKC,qBAAL,CAA2BL,EAA3B,EAA+BC,aAA/B;AACAE,SAAK,GA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qC,OAAO,CAACC,UAAD,EAAa5C,KAAK,CAAC6C,GAAnB,CAAvB,EAAgD/C,EAAhD,CAA1B;AACH,OAfL;;AAgBA,aAAO;AACH6E,gBAAQ,EAAEA,QADP;AAEHC,mBAAW,EAAEA,WAFV;AAGHC,cAAM,EAAE,gBAAUC,QAAV,EAAoBC,SAApB,EAA+B;AACnC,cAAIX,aAAa,CAACR,cAAlB,EAAkC;AAC9BY,iBAAK,GAAGM,QAAR;AACAL,kBAAM,GAAGM,SAAT;AACAH,uBAAW,CAACF,SAAD,CAAX;AACH;AACJ;AATE,OAAP;AAWH;AA/BqB,GAA1B;AAiCH,C;;;;;;;;;;;AC9GD,+B;;;;;;;;;;;ACAA,8B;;;;;;;;;;;ACAA,iC;;;;;;;;;;;ACAA,8B","file":"react-tools.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./srcjs/react-tools.js\");\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport Shiny from 'shiny';\nimport $ from 'jquery';\n\n/*\n * This default receiveMessage implementation expects data to contain whole\n * configuration and value properties. If either is present, it will be set and\n * the component will be re-rendered. Because receiveMessage is typically used\n * by input authors to perform incremental updates, this default implementation\n * can be overriden by the user with the receiveMessage arguments to\n * reactShinyInput.\n */\nfunction defaultReceiveMessage(el, { configuration, value }) {\n let dirty = false;\n if (configuration !== undefined) {\n this.setInputConfiguration(el, configuration);\n dirty = true;\n }\n if (value !== undefined) {\n this.setInputValue(el, value);\n dirty = true;\n }\n if (dirty) {\n this.getCallback(el)();\n this.render(el);\n }\n}\n\nconst defaultOptions = {\n receiveMessage: defaultReceiveMessage\n};\n\n/**\n * Installs a new Shiny input binding based on a React component.\n *\n * @param {string} selector - jQuery selector that should identify the set of\n * container elements within the scope argument of Shiny.InputBinding.find.\n * @param {string} name - A name such as 'acme.FooInput' that should uniquely\n * identify the component.\n * @param {Object} component - React Component, either class or function.\n * @param {Object} options - Additional configuration options. Supported\n * options are:\n * - receiveMessage: Implementation of Shiny.InputBinding to use in place of\n * the default. Typically overridden as an optimization to perform\n * incremental value updates.\n */\nexport function reactShinyInput(selector,\n name,\n component,\n options) {\n options = Object.assign({}, defaultOptions, options);\n Shiny.inputBindings.register(new class extends Shiny.InputBinding {\n\n /*\n * Methods override those in Shiny.InputBinding\n */\n\n find(scope) {\n return $(scope).find(selector);\n }\n getValue(el) {\n return this.getInputValue(el);\n }\n setValue(el, value) {\n this.setInputValue(el, value);\n this.getCallback(el)();\n this.render(el);\n }\n initialize(el) {\n $(el).data('value', JSON.parse($(el).next().text()));\n $(el).data('configuration', JSON.parse($(el).next().next().text()));\n }\n subscribe(el, callback) {\n $(el).data('callback', callback);\n this.render(el);\n }\n unsubscribe(el, callback) {\n $(el).removeData('callback');\n ReactDOM.render(null, el);\n }\n receiveMessage(el, data) {\n options.receiveMessage.call(this, el, data);\n }\n\n /*\n * Methods not present in Shiny.InputBinding but accessible to users\n * through `this` in receiveMessage\n * */\n\n getInputValue(el) {\n return $(el).data('value');\n }\n setInputValue(el, value) {\n $(el).data('value', value);\n }\n getInputConfiguration(el) {\n return $(el).data('configuration');\n }\n setInputConfiguration(el, configuration) {\n $(el).data('configuration', configuration);\n }\n getCallback(el) {\n return $(el).data('callback');\n }\n render(el) {\n const element = React.createElement(component, {\n configuration: this.getInputConfiguration(el),\n value: this.getValue(el),\n setValue: this.setValue.bind(this, el)\n });\n ReactDOM.render(element, el);\n }\n }, name);\n}\n\n","import { reactWidget, hydrate } from './widget';\nimport { reactShinyInput } from './input';\n\nwindow.reactR = {\n reactShinyInput: reactShinyInput,\n reactWidget: reactWidget,\n hydrate: hydrate\n};\n","/**\n * Recursively transforms tag, a JSON representation of an instance of a\n * React component and its children, into a React element suitable for\n * passing to ReactDOM.render.\n * @param {Object} components\n * @param {Object} tag\n */\nexport function hydrate(components, tag) {\n if (typeof tag === 'string') return tag;\n if (tag.name[0] === tag.name[0].toUpperCase()\n && !components.hasOwnProperty(tag.name)) {\n throw new Error(\"Unknown component: \" + tag.name);\n }\n var elem = components.hasOwnProperty(tag.name) ? components[tag.name] : tag.name,\n args = [elem, tag.attribs];\n for (var i = 0; i < tag.children.length; i++) {\n args.push(hydrate(components, tag.children[i]));\n }\n return React.createElement.apply(React, args);\n}\n\nexport const defaultOptions = {\n // The name of the property on the root tag to use for the width, if\n // it's updated.\n widthProperty: \"width\",\n // The name of the property on the root tag to use for the height, if\n // it's updated.\n heightProperty: \"height\",\n // Whether or not to append the string 'px' to the width and height\n // properties when they change.\n appendPx: false,\n // Whether or not to dynamically update the width and height properties\n // of the last known tag when the computed width and height change in\n // the browser.\n renderOnResize: false\n};\n\nexport function mergeOptions(options) {\n var merged = {};\n for (var k in defaultOptions) {\n merged[k] = defaultOptions[k];\n }\n for (var k in options) {\n if (!defaultOptions.hasOwnProperty(k)) {\n throw new Error(\"Unrecognized option: \" + k);\n }\n merged[k] = options[k];\n }\n return merged;\n}\n\nexport function formatDimension(dim, options) {\n if (options.appendPx) {\n return dim + 'px';\n } else {\n return dim;\n }\n}\n\nexport function isTag(value) {\n return (typeof value === 'object')\n && value.hasOwnProperty('name')\n && value.hasOwnProperty('attribs')\n && value.hasOwnProperty('children');\n}\n\n/**\n * Creates an HTMLWidget that is updated by rendering a React component.\n * React component constructors are made available by specifying them by\n * name in the components object.\n * @param {string} name\n * @param {string} type\n * @param {Object} components\n * @param {Object} options\n */\nexport function reactWidget(name, type, components, options) {\n var actualOptions = mergeOptions(options);\n window.HTMLWidgets.widget({\n name: name,\n type: type,\n factory: function (el, width, height) {\n var lastValue,\n instance = {},\n renderValue = (function (value) {\n if (actualOptions.renderOnResize) {\n // value.tag might be a primitive string, in which\n // case there is no attribs property.\n if (typeof value.tag === 'object') {\n value.tag.attribs[actualOptions[\"widthProperty\"]] = formatDimension(width);\n value.tag.attribs[actualOptions[\"heightProperty\"]] = formatDimension(height);\n }\n lastValue = value;\n }\n // with functional stateless components this will be null\n // see https://reactjs.org/docs/react-dom.html#render for more details\n this.instance.component = ReactDOM.render(hydrate(components, value.tag), el);\n });\n return {\n instance: instance,\n renderValue: renderValue,\n resize: function (newWidth, newHeight) {\n if (actualOptions.renderOnResize) {\n width = newWidth;\n height = newHeight;\n renderValue(lastValue);\n }\n }\n };\n }\n })\n}\n\n","module.exports = window.jQuery;","module.exports = window.React;","module.exports = window.ReactDOM;","module.exports = window.Shiny;"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./srcjs/input.js","webpack:///./srcjs/react-tools.js","webpack:///./srcjs/widget.js","webpack:///external \"window.jQuery\"","webpack:///external \"window.React\"","webpack:///external \"window.ReactDOM\"","webpack:///external \"window.Shiny\""],"names":["defaultReceiveMessage","el","configuration","value","dirty","undefined","setInputConfiguration","setInputValue","getCallback","render","defaultOptions","receiveMessage","type","reactShinyInput","selector","name","component","options","Object","assign","Shiny","inputBindings","register","scope","$","find","getInputValue","data","JSON","parse","next","text","callback","removeData","ReactDOM","call","Error","element","React","createElement","getInputConfiguration","getValue","setValue","bind","InputBinding","window","reactR","reactWidget","hydrate","components","tag","toUpperCase","hasOwnProperty","elem","args","attribs","i","children","length","push","apply","widthProperty","heightProperty","appendPx","renderOnResize","mergeOptions","merged","k","formatDimension","dim","isTag","actualOptions","HTMLWidgets","widget","factory","width","height","lastValue","instance","renderValue","resize","newWidth","newHeight"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;A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,KAAK,CAAC+C,GAAnB,CAAvB,EAAgDjD,EAAhD,CAA1B;AACH,OAfL;;AAgBA,aAAO;AACH6E,gBAAQ,EAAEA,QADP;AAEHC,mBAAW,EAAEA,WAFV;AAGHC,cAAM,EAAE,gBAAUC,QAAV,EAAoBC,SAApB,EAA+B;AACnC,cAAIX,aAAa,CAACP,cAAlB,EAAkC;AAC9BW,iBAAK,GAAGM,QAAR;AACAL,kBAAM,GAAGM,SAAT;AACAH,uBAAW,CAACF,SAAD,CAAX;AACH;AACJ;AATE,OAAP;AAWH;AA/BqB,GAA1B;AAiCH,C;;;;;;;;;;;AC9GD,+B;;;;;;;;;;;ACAA,8B;;;;;;;;;;;ACAA,iC;;;;;;;;;;;ACAA,8B","file":"react-tools.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./srcjs/react-tools.js\");\n","import React from 'react';\nimport ReactDOM from 'react-dom';\nimport Shiny from 'shiny';\nimport $ from 'jquery';\n\n/*\n * This default receiveMessage implementation expects data to contain whole\n * configuration and value properties. If either is present, it will be set and\n * the component will be re-rendered. Because receiveMessage is typically used\n * by input authors to perform incremental updates, this default implementation\n * can be overriden by the user with the receiveMessage arguments to\n * reactShinyInput.\n */\nfunction defaultReceiveMessage(el, { configuration, value }) {\n let dirty = false;\n if (configuration !== undefined) {\n this.setInputConfiguration(el, configuration);\n dirty = true;\n }\n if (value !== undefined) {\n this.setInputValue(el, value);\n dirty = true;\n }\n if (dirty) {\n this.getCallback(el)();\n this.render(el);\n }\n}\n\nconst defaultOptions = {\n receiveMessage: defaultReceiveMessage,\n type: false\n};\n\n/**\n * Installs a new Shiny input binding based on a React component.\n *\n * @param {string} selector - jQuery selector that should identify the set of\n * container elements within the scope argument of Shiny.InputBinding.find.\n * @param {string} name - A name such as 'acme.FooInput' that should uniquely\n * identify the component.\n * @param {Object} component - React Component, either class or function.\n * @param {Object} options - Additional configuration options. Supported\n * options are:\n * - receiveMessage: Implementation of Shiny.InputBinding to use in place of\n * the default. Typically overridden as an optimization to perform\n * incremental value updates.\n * - type: `false`, a string, or a function.\n * - `false` (the default): denotes that the value produced by this input\n * should not be intercepted by any handlers registered in R on the\n * server using shiny::registerInputHandler().\n * - string: denotes the input's *type* and should correspond to the\n * type parameter of shiny::registerInputHandler().\n * - function: A function called with `this` bound to the InputBinding\n * instance and passed a single argument, the input's containing DOM\n * element. The function should return either `false` or a string\n * corresponding to the type parameter of shiny::registerInputHandler().\n */\nexport function reactShinyInput(selector,\n name,\n component,\n options) {\n options = Object.assign({}, defaultOptions, options);\n Shiny.inputBindings.register(new class extends Shiny.InputBinding {\n\n /*\n * Methods override those in Shiny.InputBinding\n */\n\n find(scope) {\n return $(scope).find(selector);\n }\n getValue(el) {\n return this.getInputValue(el);\n }\n setValue(el, value) {\n this.setInputValue(el, value);\n this.getCallback(el)();\n this.render(el);\n }\n initialize(el) {\n $(el).data('value', JSON.parse($(el).next().text()));\n $(el).data('configuration', JSON.parse($(el).next().next().text()));\n }\n subscribe(el, callback) {\n $(el).data('callback', callback);\n this.render(el);\n }\n unsubscribe(el, callback) {\n $(el).removeData('callback');\n ReactDOM.render(null, el);\n }\n receiveMessage(el, data) {\n options.receiveMessage.call(this, el, data);\n }\n getType(el) {\n if (typeof options.type === 'function') {\n return options.type.call(this, el);\n } else if (options.type === false || typeof options.type === 'string') {\n return options.type;\n } else {\n throw new Error('options.type must be false, a string, or a function');\n }\n }\n\n /*\n * Methods not present in Shiny.InputBinding but accessible to users\n * through `this` in receiveMessage\n */\n\n getInputValue(el) {\n return $(el).data('value');\n }\n setInputValue(el, value) {\n $(el).data('value', value);\n }\n getInputConfiguration(el) {\n return $(el).data('configuration');\n }\n setInputConfiguration(el, configuration) {\n $(el).data('configuration', configuration);\n }\n getCallback(el) {\n return $(el).data('callback');\n }\n render(el) {\n const element = React.createElement(component, {\n configuration: this.getInputConfiguration(el),\n value: this.getValue(el),\n setValue: this.setValue.bind(this, el)\n });\n ReactDOM.render(element, el);\n }\n }, name);\n}\n\n","import { reactWidget, hydrate } from './widget';\nimport { reactShinyInput } from './input';\n\nwindow.reactR = {\n reactShinyInput: reactShinyInput,\n reactWidget: reactWidget,\n hydrate: hydrate\n};\n","/**\n * Recursively transforms tag, a JSON representation of an instance of a\n * React component and its children, into a React element suitable for\n * passing to ReactDOM.render.\n * @param {Object} components\n * @param {Object} tag\n */\nexport function hydrate(components, tag) {\n if (typeof tag === 'string') return tag;\n if (tag.name[0] === tag.name[0].toUpperCase()\n && !components.hasOwnProperty(tag.name)) {\n throw new Error(\"Unknown component: \" + tag.name);\n }\n var elem = components.hasOwnProperty(tag.name) ? components[tag.name] : tag.name,\n args = [elem, tag.attribs];\n for (var i = 0; i < tag.children.length; i++) {\n args.push(hydrate(components, tag.children[i]));\n }\n return React.createElement.apply(React, args);\n}\n\nexport const defaultOptions = {\n // The name of the property on the root tag to use for the width, if\n // it's updated.\n widthProperty: \"width\",\n // The name of the property on the root tag to use for the height, if\n // it's updated.\n heightProperty: \"height\",\n // Whether or not to append the string 'px' to the width and height\n // properties when they change.\n appendPx: false,\n // Whether or not to dynamically update the width and height properties\n // of the last known tag when the computed width and height change in\n // the browser.\n renderOnResize: false\n};\n\nexport function mergeOptions(options) {\n var merged = {};\n for (var k in defaultOptions) {\n merged[k] = defaultOptions[k];\n }\n for (var k in options) {\n if (!defaultOptions.hasOwnProperty(k)) {\n throw new Error(\"Unrecognized option: \" + k);\n }\n merged[k] = options[k];\n }\n return merged;\n}\n\nexport function formatDimension(dim, options) {\n if (options.appendPx) {\n return dim + 'px';\n } else {\n return dim;\n }\n}\n\nexport function isTag(value) {\n return (typeof value === 'object')\n && value.hasOwnProperty('name')\n && value.hasOwnProperty('attribs')\n && value.hasOwnProperty('children');\n}\n\n/**\n * Creates an HTMLWidget that is updated by rendering a React component.\n * React component constructors are made available by specifying them by\n * name in the components object.\n * @param {string} name\n * @param {string} type\n * @param {Object} components\n * @param {Object} options\n */\nexport function reactWidget(name, type, components, options) {\n var actualOptions = mergeOptions(options);\n window.HTMLWidgets.widget({\n name: name,\n type: type,\n factory: function (el, width, height) {\n var lastValue,\n instance = {},\n renderValue = (function (value) {\n if (actualOptions.renderOnResize) {\n // value.tag might be a primitive string, in which\n // case there is no attribs property.\n if (typeof value.tag === 'object') {\n value.tag.attribs[actualOptions[\"widthProperty\"]] = formatDimension(width);\n value.tag.attribs[actualOptions[\"heightProperty\"]] = formatDimension(height);\n }\n lastValue = value;\n }\n // with functional stateless components this will be null\n // see https://reactjs.org/docs/react-dom.html#render for more details\n this.instance.component = ReactDOM.render(hydrate(components, value.tag), el);\n });\n return {\n instance: instance,\n renderValue: renderValue,\n resize: function (newWidth, newHeight) {\n if (actualOptions.renderOnResize) {\n width = newWidth;\n height = newHeight;\n renderValue(lastValue);\n }\n }\n };\n }\n })\n}\n\n","module.exports = window.jQuery;","module.exports = window.React;","module.exports = window.ReactDOM;","module.exports = window.Shiny;"],"sourceRoot":""} \ No newline at end of file