diff --git a/dist/highcharts-react.js b/dist/highcharts-react.js index 87ef243..2ceac36 100644 --- a/dist/highcharts-react.js +++ b/dist/highcharts-react.js @@ -75,50 +75,38 @@ return /******/ (function(modules) { // webpackBootstrap /************************************************************************/ /******/ ([ /* 0 */ -/***/ (function(module, exports, __webpack_require__) { +/***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; +Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_highcharts__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_highcharts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_highcharts__); +function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } +function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - -var _react = __webpack_require__(1); - -var _react2 = _interopRequireDefault(_react); - -var _highcharts = __webpack_require__(2); +function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } -var _highcharts2 = _interopRequireDefault(_highcharts); +function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } -function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } -// React currently throws a warning when using `useLayoutEffect` on the server. + // React currently throws a warning when using `useLayoutEffect` on the server. // To get around it, we can conditionally `useEffect` on the server (no-op) and // `useLayoutEffect` in the browser. We need `useLayoutEffect` to ensure the // `Highcharts` ref is available in the layout phase. This makes it available // in a parent component's `componentDidMount`. -var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? _react.useLayoutEffect : _react.useEffect; - -var HighchartsReact = (0, _react.forwardRef)(function HighchartsReact(props, ref) { - var containerRef = (0, _react.useRef)(); - var chartRef = (0, _react.useRef)(); - var unmountingRef = (0, _react.useRef)(false); - - useIsomorphicLayoutEffect(function () { - return function () { - unmountingRef.current = true; - }; - }, []); +var useIsomorphicLayoutEffect = typeof window !== 'undefined' ? __WEBPACK_IMPORTED_MODULE_0_react__["useLayoutEffect"] : __WEBPACK_IMPORTED_MODULE_0_react__["useEffect"]; +var HighchartsReact = Object(__WEBPACK_IMPORTED_MODULE_0_react__["forwardRef"])(function HighchartsReact(props, ref) { + var containerRef = Object(__WEBPACK_IMPORTED_MODULE_0_react__["useRef"])(); + var chartRef = Object(__WEBPACK_IMPORTED_MODULE_0_react__["useRef"])(); useIsomorphicLayoutEffect(function () { function createChart() { - var H = props.highcharts || _highcharts2.default; + var H = props.highcharts || __WEBPACK_IMPORTED_MODULE_1_highcharts___default.a; var constructorType = props.constructorType || 'chart'; if (!H) { @@ -146,30 +134,31 @@ var HighchartsReact = (0, _react.forwardRef)(function HighchartsReact(props, ref } } } - + }); + useIsomorphicLayoutEffect(function () { return function () { // Destroy chart only if unmounting. - if (chartRef.current && unmountingRef.current) { + if (chartRef.current) { chartRef.current.destroy(); chartRef.current = null; } }; - }); - - (0, _react.useImperativeHandle)(ref, function () { + }, []); + Object(__WEBPACK_IMPORTED_MODULE_0_react__["useImperativeHandle"])(ref, function () { return { get chart() { return chartRef.current; }, + container: containerRef }; - }, []); + }, []); // Create container for the chart - // Create container for the chart - return _react2.default.createElement('div', _extends({}, props.containerProps, { ref: containerRef })); + return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement("div", _extends({}, props.containerProps, { + ref: containerRef + })); }); - -exports.default = (0, _react.memo)(HighchartsReact); +/* harmony default export */ __webpack_exports__["default"] = (Object(__WEBPACK_IMPORTED_MODULE_0_react__["memo"])(HighchartsReact)); /***/ }), /* 1 */ diff --git a/dist/highcharts-react.js.map b/dist/highcharts-react.js.map index aba532c..805ded7 100644 --- a/dist/highcharts-react.js.map +++ b/dist/highcharts-react.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap c2492559ff0d0cf38e8d","webpack:///./src/HighchartsReact.js","webpack:///external {\"root\":\"React\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\"}","webpack:///external {\"root\":\"Highcharts\",\"commonjs\":\"highcharts\",\"commonjs2\":\"highcharts\",\"amd\":\"highcharts\"}"],"names":["useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","HighchartsReact","props","ref","containerRef","chartRef","unmountingRef","current","createChart","H","highcharts","Highcharts","constructorType","console","warn","options","callback","undefined","allowChartUpdate","immutable","update","updateArgs","destroy","chart","container","containerProps"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,KAAK;QACL;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iC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B,SAAP,IAAoBd,SAASE,OAAjC,EAA0C;AAAA;;AACxC,wCAASA,OAAT,EAAiBa,MAAjB,2BACElB,MAAMa,OADR,4BAEMb,MAAMmB,UAAN,IAAoB,CAAC,IAAD,EAAO,IAAP,CAF1B;AAID,SALD,MAKO;AACLb;AACD;AACF;AACF;;AAED,WAAO,YAAM;AACX;AACA,UAAIH,SAASE,OAAT,IAAoBD,cAAcC,OAAtC,EAA+C;AAC7CF,iBAASE,OAAT,CAAiBe,OAAjB;AACAjB,iBAASE,OAAT,GAAmB,IAAnB;AACD;AACF,KAND;AAOD,GA9CD;;AAgDA,kCACEJ,GADF,EAEE;AAAA,WAAO;AACL,UAAIoB,KAAJ,GAAY;AACV,eAAOlB,SAASE,OAAhB;AACD,OAHI;AAILiB,iBAAWpB;AAJN,KAAP;AAAA,GAFF,EAQE,EARF;;AAWA;AACA,SAAO,kDAASF,MAAMuB,cAAf,IAA+B,KAAKrB,YAApC,IAAP;AACD,CAxEuB,CAAxB;;kBA0Ee,iBAAKH,eAAL,C;;;;;;AC5Ff,+C;;;;;;ACAA,+C","file":"highcharts-react.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"highcharts\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"highcharts\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"HighchartsReact\"] = factory(require(\"react\"), require(\"highcharts\"));\n\telse\n\t\troot[\"HighchartsReact\"] = factory(root[\"React\"], root[\"Highcharts\"]);\n})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c2492559ff0d0cf38e8d","import React, {\n forwardRef,\n memo,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef\n} from 'react';\nimport Highcharts from 'highcharts';\n\n// React currently throws a warning when using `useLayoutEffect` on the server.\n// To get around it, we can conditionally `useEffect` on the server (no-op) and\n// `useLayoutEffect` in the browser. We need `useLayoutEffect` to ensure the\n// `Highcharts` ref is available in the layout phase. This makes it available\n// in a parent component's `componentDidMount`.\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nconst HighchartsReact = forwardRef(function HighchartsReact(props, ref) {\n const containerRef = useRef();\n const chartRef = useRef();\n const unmountingRef = useRef(false);\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n unmountingRef.current = true;\n };\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n function createChart() {\n const H = props.highcharts || Highcharts;\n const constructorType = props.constructorType || 'chart';\n\n if (!H) {\n console.warn('The \"highcharts\" property was not passed.');\n } else if (!H[constructorType]) {\n console.warn(\n 'The \"constructorType\" property is incorrect or some ' +\n 'required module is not imported.'\n );\n } else if (!props.options) {\n console.warn('The \"options\" property was not passed.');\n } else {\n // Create a chart\n chartRef.current = H[constructorType](\n containerRef.current,\n props.options,\n props.callback ? props.callback : undefined\n );\n }\n }\n\n if (!chartRef.current) {\n createChart();\n } else {\n if (props.allowChartUpdate !== false) {\n if (!props.immutable && chartRef.current) {\n chartRef.current.update(\n props.options,\n ...(props.updateArgs || [true, true])\n );\n } else {\n createChart();\n }\n }\n }\n\n return () => {\n // Destroy chart only if unmounting.\n if (chartRef.current && unmountingRef.current) {\n chartRef.current.destroy();\n chartRef.current = null;\n }\n };\n });\n\n useImperativeHandle(\n ref,\n () => ({\n get chart() {\n return chartRef.current;\n },\n container: containerRef\n }),\n []\n );\n\n // Create container for the chart\n return
;\n});\n\nexport default memo(HighchartsReact);\n\n\n\n// WEBPACK FOOTER //\n// ./src/HighchartsReact.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"React\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\"}\n// module id = 1\n// module chunks = 0 1","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"Highcharts\",\"commonjs\":\"highcharts\",\"commonjs2\":\"highcharts\",\"amd\":\"highcharts\"}\n// module id = 2\n// module chunks = 0 1"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 0b4a1324394422055ece","webpack:///./src/HighchartsReact.js","webpack:///external {\"root\":\"React\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\"}","webpack:///external {\"root\":\"Highcharts\",\"commonjs\":\"highcharts\",\"commonjs2\":\"highcharts\",\"amd\":\"highcharts\"}"],"names":["useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","HighchartsReact","forwardRef","props","ref","containerRef","useRef","chartRef","createChart","H","highcharts","Highcharts","constructorType","console","warn","options","current","callback","undefined","allowChartUpdate","immutable","update","updateArgs","destroy","useImperativeHandle","chart","container","containerProps","memo"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;QCVA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA,KAAK;QACL;QACA;;QAEA;QACA;QACA;QACA,2BAA2B,0BAA0B,EAAE;QACvD,iCAAiC,eAAe;QAChD;QACA;QACA;;QAEA;QACA,sDAAsD,+DAA+D;;QAErH;QACA;;QAEA;QACA;;;;;;;;;;;;;;;;;;;;;;;AC7DA;CAWA;AACA;AACA;AACA;AACA;;AACA,IAAMA,yBAAyB,GAC7B,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,sDAAhC,GAAkDC,gDADpD;AAGA,IAAMC,eAAe,GAAGC,yDAAU,CAChC,SAASD,eAAT,CAAyBE,KAAzB,EAAgCC,GAAhC,EAAqC;AACnC,MAAMC,YAAY,GAAGC,qDAAM,EAA3B;AACA,MAAMC,QAAQ,GAAGD,qDAAM,EAAvB;AAEAT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AT,GAAmB,IAAnB;AACD;AACF,KAND;AAOD,GARwB,EAQtB,EARsB,CAAzB;AAUAQ,oEAAmB,CACjBpB,GADiB,EAEjB;AAAA,WAAO;AACL,UAAIqB,KAAJ,GAAY;AACV,eAAOlB,QAAQ,CAACS,OAAhB;AACD,OAHI;;AAILU,eAAS,EAAErB;AAJN,KAAP;AAAA,GAFiB,EAQjB,EARiB,CAAnB,CAxDmC,CAmEnC;;AACA,SAAO,gFAAUF,KAAK,CAACwB,cAAhB;AAAiC,OAAG,EAAGtB;AAAvC,KAAP;AACD,CAtE+B,CAAlC;AAyEeuB,kHAAI,CAAC3B,eAAD,CAAnB,E;;;;;;AC5FA,+C;;;;;;ACAA,+C","file":"highcharts-react.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"highcharts\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"highcharts\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"HighchartsReact\"] = factory(require(\"react\"), require(\"highcharts\"));\n\telse\n\t\troot[\"HighchartsReact\"] = factory(root[\"React\"], root[\"Highcharts\"]);\n})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 0b4a1324394422055ece","import React, {\n forwardRef,\n memo,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef\n} from 'react';\n\nimport Highcharts from 'highcharts';\n\n// React currently throws a warning when using `useLayoutEffect` on the server.\n// To get around it, we can conditionally `useEffect` on the server (no-op) and\n// `useLayoutEffect` in the browser. We need `useLayoutEffect` to ensure the\n// `Highcharts` ref is available in the layout phase. This makes it available\n// in a parent component's `componentDidMount`.\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nconst HighchartsReact = forwardRef(\n function HighchartsReact(props, ref) {\n const containerRef = useRef();\n const chartRef = useRef();\n\n useIsomorphicLayoutEffect(() => {\n function createChart() {\n const H = props.highcharts || Highcharts;\n const constructorType = props.constructorType || 'chart';\n\n if (!H) {\n console.warn('The \"highcharts\" property was not passed.');\n\n } else if (!H[constructorType]) {\n console.warn(\n 'The \"constructorType\" property is incorrect or some ' +\n 'required module is not imported.'\n );\n } else if (!props.options) {\n console.warn('The \"options\" property was not passed.');\n\n } else {\n // Create a chart\n chartRef.current = H[constructorType](\n containerRef.current,\n props.options,\n props.callback ? props.callback : undefined\n );\n }\n }\n\n if (!chartRef.current) {\n createChart();\n } else {\n if (props.allowChartUpdate !== false) {\n if (!props.immutable && chartRef.current) {\n chartRef.current.update(\n props.options,\n ...(props.updateArgs || [true, true])\n );\n } else {\n createChart();\n }\n }\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n // Destroy chart only if unmounting.\n if (chartRef.current) {\n chartRef.current.destroy();\n chartRef.current = null;\n }\n };\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n get chart() {\n return chartRef.current;\n },\n container: containerRef\n }),\n []\n );\n\n // Create container for the chart\n return
;\n }\n);\n\nexport default memo(HighchartsReact);\n\n\n\n// WEBPACK FOOTER //\n// ./src/HighchartsReact.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"React\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\"}\n// module id = 1\n// module chunks = 0 1","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"Highcharts\",\"commonjs\":\"highcharts\",\"commonjs2\":\"highcharts\",\"amd\":\"highcharts\"}\n// module id = 2\n// module chunks = 0 1"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/highcharts-react.min.js b/dist/highcharts-react.min.js index fc613b2..2023441 100644 --- a/dist/highcharts-react.min.js +++ b/dist/highcharts-react.min.js @@ -1,2 +1,2 @@ -!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r(require("react"),require("highcharts")):"function"==typeof define&&define.amd?define(["react","highcharts"],r):"object"==typeof exports?exports.HighchartsReact=r(require("react"),require("highcharts")):e.HighchartsReact=r(e.React,e.Highcharts)}("undefined"!=typeof self?self:this,function(e,r){return function(e){function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}var t={};return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=0)}([function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r {\n return () => {\n unmountingRef.current = true;\n };\n }, []);\n\n useIsomorphicLayoutEffect(() => {\n function createChart() {\n const H = props.highcharts || Highcharts;\n const constructorType = props.constructorType || 'chart';\n\n if (!H) {\n console.warn('The \"highcharts\" property was not passed.');\n } else if (!H[constructorType]) {\n console.warn(\n 'The \"constructorType\" property is incorrect or some ' +\n 'required module is not imported.'\n );\n } else if (!props.options) {\n console.warn('The \"options\" property was not passed.');\n } else {\n // Create a chart\n chartRef.current = H[constructorType](\n containerRef.current,\n props.options,\n props.callback ? props.callback : undefined\n );\n }\n }\n\n if (!chartRef.current) {\n createChart();\n } else {\n if (props.allowChartUpdate !== false) {\n if (!props.immutable && chartRef.current) {\n chartRef.current.update(\n props.options,\n ...(props.updateArgs || [true, true])\n );\n } else {\n createChart();\n }\n }\n }\n\n return () => {\n // Destroy chart only if unmounting.\n if (chartRef.current && unmountingRef.current) {\n chartRef.current.destroy();\n chartRef.current = null;\n }\n };\n });\n\n useImperativeHandle(\n ref,\n () => ({\n get chart() {\n return chartRef.current;\n },\n container: containerRef\n }),\n []\n );\n\n // Create container for the chart\n return
;\n});\n\nexport default memo(HighchartsReact);\n\n\n\n// WEBPACK FOOTER //\n// ./src/HighchartsReact.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"React\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\"}\n// module id = 1\n// module chunks = 0 1","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"Highcharts\",\"commonjs\":\"highcharts\",\"commonjs2\":\"highcharts\",\"amd\":\"highcharts\"}\n// module id = 2\n// module chunks = 0 1"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap 0b4a1324394422055ece","webpack:///highcharts-react.min.js","webpack:///./src/HighchartsReact.js","webpack:///external {\"root\":\"React\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\"}","webpack:///external {\"root\":\"Highcharts\",\"commonjs\":\"highcharts\",\"commonjs2\":\"highcharts\",\"amd\":\"highcharts\"}"],"names":["root","factory","exports","module","require","define","amd","self","this","__WEBPACK_EXTERNAL_MODULE_1__","__WEBPACK_EXTERNAL_MODULE_2__","__webpack_require__","moduleId","installedModules","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","__webpack_exports__","_extends","assign","target","arguments","length","source","key","apply","_toConsumableArray","arr","_arrayWithoutHoles","_iterableToArray","_nonIterableSpread","TypeError","iter","Symbol","iterator","toString","Array","from","isArray","arr2","value","__WEBPACK_IMPORTED_MODULE_0_react__","__WEBPACK_IMPORTED_MODULE_0_react___default","__WEBPACK_IMPORTED_MODULE_1_highcharts__","__WEBPACK_IMPORTED_MODULE_1_highcharts___default","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","HighchartsReact","forwardRef","props","ref","containerRef","useRef","chartRef","createChart","H","highcharts","Highcharts","constructorType","options","current","callback","undefined","console","warn","allowChartUpdate","immutable","update","updateArgs","destro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C,QAAQC,KAAK,0CALbD,QAAQC,KACN,wFAJFD,QAAQC,KAAK,6CAoBjB,GAAKX,EAASO,SAGZ,IAA+B,IAA3BX,EAAMgB,iBACR,IAAKhB,EAAMiB,WAAab,EAASO,QAAS,QACxC,EAAAP,EAASO,SAAQO,OAAjB,SACElB,EAAMU,SADR,SAEMV,EAAMmB,cAAe,GAAM,UAGjCd,SATJA,OAeJX,EAA0B,WACxB,MAAO,YAEDU,EAASO,UACXP,EAASO,QAAQS,UACjBhB,EAASO,QAAU,YAKzBU,8BACEpB,EACA,kBACE,YACE,MAAOG,GAASO,SAElBW,UAAWpB,QAMR,6BAAUF,EAAMuB,gBAAiBtB,IAAMC,MAInCsB,0BAAK1B,IDwEd,SAAUlE,EAAQD,GEpKxBC,EAAOD,QAAUO,GF0KX,SAAUN,EAAQD,GG1KxBC,EAAOD,QAAUQ","file":"highcharts-react.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"highcharts\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"highcharts\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"HighchartsReact\"] = factory(require(\"react\"), require(\"highcharts\"));\n\telse\n\t\troot[\"HighchartsReact\"] = factory(root[\"React\"], root[\"Highcharts\"]);\n})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition"," \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, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\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 \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 0b4a1324394422055ece","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"react\"), require(\"highcharts\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([\"react\", \"highcharts\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"HighchartsReact\"] = factory(require(\"react\"), require(\"highcharts\"));\n\telse\n\t\troot[\"HighchartsReact\"] = factory(root[\"React\"], root[\"Highcharts\"]);\n})(typeof self !== 'undefined' ? self : this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \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, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\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/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\nObject.defineProperty(__webpack_exports__, \"__esModule\", { value: true });\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react__ = __webpack_require__(1);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_react___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_react__);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_highcharts__ = __webpack_require__(2);\n/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_highcharts___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_highcharts__);\nfunction _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\n\n // React currently throws a warning when using `useLayoutEffect` on the server.\n// To get around it, we can conditionally `useEffect` on the server (no-op) and\n// `useLayoutEffect` in the browser. We need `useLayoutEffect` to ensure the\n// `Highcharts` ref is available in the layout phase. This makes it available\n// in a parent component's `componentDidMount`.\n\nvar useIsomorphicLayoutEffect = typeof window !== 'undefined' ? __WEBPACK_IMPORTED_MODULE_0_react__[\"useLayoutEffect\"] : __WEBPACK_IMPORTED_MODULE_0_react__[\"useEffect\"];\nvar HighchartsReact = Object(__WEBPACK_IMPORTED_MODULE_0_react__[\"forwardRef\"])(function HighchartsReact(props, ref) {\n var containerRef = Object(__WEBPACK_IMPORTED_MODULE_0_react__[\"useRef\"])();\n var chartRef = Object(__WEBPACK_IMPORTED_MODULE_0_react__[\"useRef\"])();\n useIsomorphicLayoutEffect(function () {\n function createChart() {\n var H = props.highcharts || __WEBPACK_IMPORTED_MODULE_1_highcharts___default.a;\n var constructorType = props.constructorType || 'chart';\n\n if (!H) {\n console.warn('The \"highcharts\" property was not passed.');\n } else if (!H[constructorType]) {\n console.warn('The \"constructorType\" property is incorrect or some ' + 'required module is not imported.');\n } else if (!props.options) {\n console.warn('The \"options\" property was not passed.');\n } else {\n // Create a chart\n chartRef.current = H[constructorType](containerRef.current, props.options, props.callback ? props.callback : undefined);\n }\n }\n\n if (!chartRef.current) {\n createChart();\n } else {\n if (props.allowChartUpdate !== false) {\n if (!props.immutable && chartRef.current) {\n var _chartRef$current;\n\n (_chartRef$current = chartRef.current).update.apply(_chartRef$current, [props.options].concat(_toConsumableArray(props.updateArgs || [true, true])));\n } else {\n createChart();\n }\n }\n }\n });\n useIsomorphicLayoutEffect(function () {\n return function () {\n // Destroy chart only if unmounting.\n if (chartRef.current) {\n chartRef.current.destroy();\n chartRef.current = null;\n }\n };\n }, []);\n Object(__WEBPACK_IMPORTED_MODULE_0_react__[\"useImperativeHandle\"])(ref, function () {\n return {\n get chart() {\n return chartRef.current;\n },\n\n container: containerRef\n };\n }, []); // Create container for the chart\n\n return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(\"div\", _extends({}, props.containerProps, {\n ref: containerRef\n }));\n});\n/* harmony default export */ __webpack_exports__[\"default\"] = (Object(__WEBPACK_IMPORTED_MODULE_0_react__[\"memo\"])(HighchartsReact));\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// highcharts-react.min.js","import React, {\n forwardRef,\n memo,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useRef\n} from 'react';\n\nimport Highcharts from 'highcharts';\n\n// React currently throws a warning when using `useLayoutEffect` on the server.\n// To get around it, we can conditionally `useEffect` on the server (no-op) and\n// `useLayoutEffect` in the browser. We need `useLayoutEffect` to ensure the\n// `Highcharts` ref is available in the layout phase. This makes it available\n// in a parent component's `componentDidMount`.\nconst useIsomorphicLayoutEffect =\n typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\nconst HighchartsReact = forwardRef(\n function HighchartsReact(props, ref) {\n const containerRef = useRef();\n const chartRef = useRef();\n\n useIsomorphicLayoutEffect(() => {\n function createChart() {\n const H = props.highcharts || Highcharts;\n const constructorType = props.constructorType || 'chart';\n\n if (!H) {\n console.warn('The \"highcharts\" property was not passed.');\n\n } else if (!H[constructorType]) {\n console.warn(\n 'The \"constructorType\" property is incorrect or some ' +\n 'required module is not imported.'\n );\n } else if (!props.options) {\n console.warn('The \"options\" property was not passed.');\n\n } else {\n // Create a chart\n chartRef.current = H[constructorType](\n containerRef.current,\n props.options,\n props.callback ? props.callback : undefined\n );\n }\n }\n\n if (!chartRef.current) {\n createChart();\n } else {\n if (props.allowChartUpdate !== false) {\n if (!props.immutable && chartRef.current) {\n chartRef.current.update(\n props.options,\n ...(props.updateArgs || [true, true])\n );\n } else {\n createChart();\n }\n }\n }\n });\n\n useIsomorphicLayoutEffect(() => {\n return () => {\n // Destroy chart only if unmounting.\n if (chartRef.current) {\n chartRef.current.destroy();\n chartRef.current = null;\n }\n };\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n get chart() {\n return chartRef.current;\n },\n container: containerRef\n }),\n []\n );\n\n // Create container for the chart\n return
;\n }\n);\n\nexport default memo(HighchartsReact);\n\n\n\n// WEBPACK FOOTER //\n// ./src/HighchartsReact.js","module.exports = __WEBPACK_EXTERNAL_MODULE_1__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"React\",\"commonjs\":\"react\",\"commonjs2\":\"react\",\"amd\":\"react\"}\n// module id = 1\n// module chunks = 0 1","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external {\"root\":\"Highcharts\",\"commonjs\":\"highcharts\",\"commonjs2\":\"highcharts\",\"amd\":\"highcharts\"}\n// module id = 2\n// module chunks = 0 1"],"sourceRoot":""} \ No newline at end of file diff --git a/src/HighchartsReact.js b/src/HighchartsReact.js index 1d8cfb4..cef35f9 100644 --- a/src/HighchartsReact.js +++ b/src/HighchartsReact.js @@ -6,6 +6,7 @@ import React, { useLayoutEffect, useRef } from 'react'; + import Highcharts from 'highcharts'; // React currently throws a warning when using `useLayoutEffect` on the server. @@ -16,78 +17,77 @@ import Highcharts from 'highcharts'; const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect; -const HighchartsReact = forwardRef(function HighchartsReact(props, ref) { - const containerRef = useRef(); - const chartRef = useRef(); - const unmountingRef = useRef(false); +const HighchartsReact = forwardRef( + function HighchartsReact(props, ref) { + const containerRef = useRef(); + const chartRef = useRef(); - useIsomorphicLayoutEffect(() => { - return () => { - unmountingRef.current = true; - }; - }, []); + useIsomorphicLayoutEffect(() => { + function createChart() { + const H = props.highcharts || Highcharts; + const constructorType = props.constructorType || 'chart'; - useIsomorphicLayoutEffect(() => { - function createChart() { - const H = props.highcharts || Highcharts; - const constructorType = props.constructorType || 'chart'; + if (!H) { + console.warn('The "highcharts" property was not passed.'); - if (!H) { - console.warn('The "highcharts" property was not passed.'); - } else if (!H[constructorType]) { - console.warn( - 'The "constructorType" property is incorrect or some ' + - 'required module is not imported.' - ); - } else if (!props.options) { - console.warn('The "options" property was not passed.'); - } else { - // Create a chart - chartRef.current = H[constructorType]( - containerRef.current, - props.options, - props.callback ? props.callback : undefined - ); - } - } + } else if (!H[constructorType]) { + console.warn( + 'The "constructorType" property is incorrect or some ' + + 'required module is not imported.' + ); + } else if (!props.options) { + console.warn('The "options" property was not passed.'); - if (!chartRef.current) { - createChart(); - } else { - if (props.allowChartUpdate !== false) { - if (!props.immutable && chartRef.current) { - chartRef.current.update( + } else { + // Create a chart + chartRef.current = H[constructorType]( + containerRef.current, props.options, - ...(props.updateArgs || [true, true]) + props.callback ? props.callback : undefined ); - } else { - createChart(); } } - } - return () => { - // Destroy chart only if unmounting. - if (chartRef.current && unmountingRef.current) { - chartRef.current.destroy(); - chartRef.current = null; + if (!chartRef.current) { + createChart(); + } else { + if (props.allowChartUpdate !== false) { + if (!props.immutable && chartRef.current) { + chartRef.current.update( + props.options, + ...(props.updateArgs || [true, true]) + ); + } else { + createChart(); + } + } } - }; - }); + }); + + useIsomorphicLayoutEffect(() => { + return () => { + // Destroy chart only if unmounting. + if (chartRef.current) { + chartRef.current.destroy(); + chartRef.current = null; + } + }; + }, []); - useImperativeHandle( - ref, - () => ({ - get chart() { - return chartRef.current; - }, - container: containerRef - }), - [] - ); + useImperativeHandle( + ref, + () => ({ + get chart() { + return chartRef.current; + }, + container: containerRef + }), + [] + ); - // Create container for the chart - return
; -}); + // Create container for the chart + return
; + } +); export default memo(HighchartsReact);