From 442827d4def565b2e4252e131c9cadbeefdb7edd Mon Sep 17 00:00:00 2001 From: jolevesq Date: Tue, 17 Oct 2023 14:27:55 +0000 Subject: [PATCH] Build: (76dd5e9) Merge pull request #4 from Canadian-Geospatial-Platform/feat-ESLinting ESLinting support and some more options in template --- main.js | 446 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 231 insertions(+), 215 deletions(-) diff --git a/main.js b/main.js index ff4d21f..d062007 100644 --- a/main.js +++ b/main.js @@ -7801,6 +7801,66 @@ var __webpack_exports__ = {}; // UNUSED EXPORTS: Chart, ChartValidator +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js +function _arrayWithHoles(arr) { + if (Array.isArray(arr)) return arr; +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js +function _iterableToArrayLimit(r, l) { + var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; + if (null != t) { + var e, + n, + i, + u, + a = [], + f = !0, + o = !1; + try { + if (i = (t = t.call(r)).next, 0 === l) { + if (Object(t) !== t) return; + f = !1; + } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); + } catch (r) { + o = !0, n = r; + } finally { + try { + if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; + } finally { + if (o) throw n; + } + } + return a; + } +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js +function _arrayLikeToArray(arr, len) { + if (len == null || len > arr.length) len = arr.length; + for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; + return arr2; +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js + +function _unsupportedIterableToArray(o, minLen) { + if (!o) return; + if (typeof o === "string") return _arrayLikeToArray(o, minLen); + var n = Object.prototype.toString.call(o).slice(8, -1); + if (n === "Object" && o.constructor) n = o.constructor.name; + if (n === "Map" || n === "Set") return Array.from(o); + if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js +function _nonIterableRest() { + throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + + + + +function _slicedToArray(arr, i) { + return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); +} ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js function _typeof(o) { "@babel/helpers - typeof"; @@ -7830,31 +7890,6 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js - -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); - } -} -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - Object.defineProperty(Constructor, "prototype", { - writable: false - }); - return Constructor; -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js function _defineProperty(obj, key, value) { @@ -7871,109 +7906,6 @@ function _defineProperty(obj, key, value) { } return obj; } -// EXTERNAL MODULE: ./node_modules/ajv/lib/ajv.js -var ajv = __webpack_require__(5096); -var ajv_default = /*#__PURE__*/__webpack_require__.n(ajv); -;// CONCATENATED MODULE: ./src/chart-validator.ts - - - - - -/** - * Represents the result of a Chart data or options inputs validations. - */ - -/** - * The Char Validator class to validate data and options inputs. - */ -var ChartValidator = /*#__PURE__*/_createClass( -/** - * Constructs a Chart Validate object to validate schemas. - */ -function ChartValidator() { - var _this = this; - _classCallCheck(this, ChartValidator); - // The JSON validator used by ChartValidate - _defineProperty(this, "SCHEMA_DATA", { - type: "object", - properties: { - labels: { - type: "array" - }, - datasets: { - type: "array" - } - }, - required: ["labels", "datasets"] - //additionalProperties: false - }); - _defineProperty(this, "SCHEMA_OPTIONS", { - type: "object", - properties: { - responsive: { - type: "boolean" - }, - plugins: { - type: "object", - properties: { - legend: { - type: "object", - properties: { - display: { - type: "boolean" - } - } - } - } - }, - geochart: { - type: "object", - properties: { - chart: { - type: "string" - } - } - } - }, - required: ["geochart"] - //additionalProperties: false - }); - /** - * Validates the data input parameters. - */ - _defineProperty(this, "validateData", function (data) { - var _validate$errors; - // Compile - var validate = _this.ajv.compile(_this.SCHEMA_DATA); - // Validate - var valid = validate(data); - return { - valid: valid, - errors: (_validate$errors = validate.errors) === null || _validate$errors === void 0 ? void 0 : _validate$errors.map(function (e) { - return e.message || "generic schema error"; - }) - }; - }); - /** - * Validates the options input parameters. - */ - _defineProperty(this, "validateOptions", function (options) { - var _validate$errors2; - // Compile - var validate = _this.ajv.compile(_this.SCHEMA_OPTIONS); - // Validate - var valid = validate(options); - return { - valid: valid, - errors: (_validate$errors2 = validate.errors) === null || _validate$errors2 === void 0 ? void 0 : _validate$errors2.map(function (e) { - return e.message || "generic schema error"; - }) - }; - }); - // The embedded JSON validator - this.ajv = new (ajv_default())(); -}); ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js function extends_extends() { extends_extends = Object.assign ? Object.assign.bind() : function (target) { @@ -10312,7 +10244,7 @@ tags.forEach(function (tagName) { ;// CONCATENATED MODULE: ./node_modules/@mui/styled-engine/index.js /** - * @mui/styled-engine v5.14.11 + * @mui/styled-engine v5.14.13 * * @license MIT * This source code is licensed under the MIT license found in the @@ -10601,6 +10533,9 @@ function getStyleValue(themeMapping, transform, propValueFinal, userValue = prop } else { value = getPath(themeMapping, propValueFinal) || userValue; } + if (typeof value === 'object') { + if (false) {} + } if (transform) { value = transform(value, userValue, themeMapping); } @@ -27536,6 +27471,136 @@ const registerables = [ //# sourceMappingURL=chart.js.map +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js + +function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); + } +} +function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + Object.defineProperty(Constructor, "prototype", { + writable: false + }); + return Constructor; +} +;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js +function _classCallCheck(instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +} +// EXTERNAL MODULE: ./node_modules/ajv/lib/ajv.js +var ajv = __webpack_require__(5096); +var ajv_default = /*#__PURE__*/__webpack_require__.n(ajv); +;// CONCATENATED MODULE: ./src/chart-validator.ts + + + + + +/** + * Represents the result of a Chart data or options inputs validations. + */ + +/** + * The Char Validator class to validate data and options inputs. + */ +var ChartValidator = /*#__PURE__*/_createClass( +/** + * Constructs a Chart Validate object to validate schemas. + */ +function ChartValidator() { + var _this = this; + _classCallCheck(this, ChartValidator); + // The JSON validator used by ChartValidate + _defineProperty(this, "SCHEMA_DATA", { + type: 'object', + properties: { + labels: { + type: 'array' + }, + datasets: { + type: 'array' + } + }, + required: ['labels', 'datasets'] + // additionalProperties: false + }); + _defineProperty(this, "SCHEMA_OPTIONS", { + type: 'object', + properties: { + responsive: { + type: 'boolean' + }, + plugins: { + type: 'object', + properties: { + legend: { + type: 'object', + properties: { + display: { + type: 'boolean' + } + } + } + } + }, + geochart: { + type: 'object', + properties: { + chart: { + type: 'string' + } + } + } + }, + required: ['geochart'] + // additionalProperties: false + }); + /** + * Validates the data input parameters. + */ + _defineProperty(this, "validateData", function (data) { + var _validate$errors; + // Compile + var validate = _this.ajv.compile(_this.SCHEMA_DATA); + + // Validate + var valid = validate(data); + return { + valid: valid, + errors: (_validate$errors = validate.errors) === null || _validate$errors === void 0 ? void 0 : _validate$errors.map(function (e) { + return e.message || 'generic schema error'; + }) + }; + }); + /** + * Validates the options input parameters. + */ + _defineProperty(this, "validateOptions", function (options) { + var _validate$errors2; + // Compile + var validate = _this.ajv.compile(_this.SCHEMA_OPTIONS); + + // Validate + var valid = validate(options); + return { + valid: valid, + errors: (_validate$errors2 = validate.errors) === null || _validate$errors2 === void 0 ? void 0 : _validate$errors2.map(function (e) { + return e.message || 'generic schema error'; + }) + }; + }); + // The embedded JSON validator + this.ajv = new (ajv_default())(); +}); ;// CONCATENATED MODULE: ./node_modules/react-chartjs-2/dist/index.js @@ -27873,6 +27938,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = + /** * Main props for the Chart */ @@ -27885,16 +27951,26 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = * @returns {JSX.Element} the created Chart element */ function chart_Chart(props) { + var _props$defaultColors, _props$defaultColors2, _props$defaultColors3, _props$defaultColors4, _props$defaultColors5, _props$defaultColors6; // Fetch cgpv + // eslint-disable-next-line @typescript-eslint/no-explicit-any var w = window; var cgpv = w.cgpv; - var useEffect = cgpv.react.useEffect; + var CSSProperties = cgpv.react.CSSProperties; var Slider = cgpv.ui.elements.Slider; - var style = props.style, + var elStyle = props.style, data = props.data, elOptions = props.options, redraw = props.redraw; + // Cast the style + var style = elStyle; + + // Attribute the default colors + if ((_props$defaultColors = props.defaultColors) !== null && _props$defaultColors !== void 0 && _props$defaultColors.backgroundColor) Chart.defaults.backgroundColor = (_props$defaultColors2 = props.defaultColors) === null || _props$defaultColors2 === void 0 ? void 0 : _props$defaultColors2.backgroundColor; + if ((_props$defaultColors3 = props.defaultColors) !== null && _props$defaultColors3 !== void 0 && _props$defaultColors3.borderColor) Chart.defaults.borderColor = (_props$defaultColors4 = props.defaultColors) === null || _props$defaultColors4 === void 0 ? void 0 : _props$defaultColors4.borderColor; + if ((_props$defaultColors5 = props.defaultColors) !== null && _props$defaultColors5 !== void 0 && _props$defaultColors5.color) Chart.defaults.color = (_props$defaultColors6 = props.defaultColors) === null || _props$defaultColors6 === void 0 ? void 0 : _props$defaultColors6.color; + // Merge default options var options = _objectSpread(_objectSpread({}, chart_Chart.defaultProps.options), elOptions); @@ -27911,13 +27987,13 @@ function chart_Chart(props) { if (props.handleError) props.handleError(resData, resOptions);else console.error(resData, resOptions); } } - var _handleSliderXChange = function _handleSliderXChange(value) { + var handleSliderXChange = function handleSliderXChange(value) { // If callback set if (props.handleSliderXChanged) { props.handleSliderXChanged(value); } }; - var _handleSliderYChange = function _handleSliderYChange(value) { + var handleSliderYChange = function handleSliderYChange(value) { // If callback set if (props.handleSliderYChanged) { props.handleSliderYChanged(value); @@ -27983,7 +28059,7 @@ function chart_Chart(props) { max: xSlider.max || 100, value: xSlider.value || 0, track: xSlider.track || false, - customOnChange: _handleSliderXChange + customOnChange: handleSliderXChange }) }); } @@ -28009,11 +28085,10 @@ function chart_Chart(props) { value: ySlider.value || 0, track: ySlider.track || false, orientation: "vertical", - customOnChange: _handleSliderYChange + customOnChange: handleSliderYChange }) }); } - // None return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {}); }; @@ -28022,7 +28097,7 @@ function chart_Chart(props) { * @returns The whole Chart container JSX.Element or an empty div */ var renderChartContainer = function renderChartContainer() { - if (options.geochart && data !== null && data !== void 0 && data.datasets && data !== null && data !== void 0 && data.labels) { + if (data && options && options.geochart) { return /*#__PURE__*/(0,jsx_runtime.jsxs)("div", { style: style, className: src_chart_module.chartContainer, @@ -28039,9 +28114,8 @@ function chart_Chart(props) { className: src_chart_module.chartContainerGrid4 })] }); - } else { - return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {}); } + return /*#__PURE__*/(0,jsx_runtime.jsx)("div", {}); }; return renderChartContainer(); } @@ -28062,66 +28136,6 @@ chart_Chart.defaultProps = { } } }; -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js -function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js -function _iterableToArrayLimit(r, l) { - var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; - if (null != t) { - var e, - n, - i, - u, - a = [], - f = !0, - o = !1; - try { - if (i = (t = t.call(r)).next, 0 === l) { - if (Object(t) !== t) return; - f = !1; - } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); - } catch (r) { - o = !0, n = r; - } finally { - try { - if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; - } finally { - if (o) throw n; - } - } - return a; - } -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js -function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - return arr2; -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js - -function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js -function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} -;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js - - - - -function _slicedToArray(arr, i) { - return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); -} ;// CONCATENATED MODULE: ./src/app.tsx @@ -28131,10 +28145,11 @@ function _slicedToArray(arr, i) { * * @returns {JSX.Elemet} the element that has the GeoChart */ -var App = function App() { +function App() { // Fetch the cgpv module + // eslint-disable-next-line @typescript-eslint/no-explicit-any var w = window; - var cgpv = w['cgpv']; + var cgpv = w.cgpv; var react = cgpv.react; var useEffect = react.useEffect, useState = react.useState; @@ -28160,15 +28175,15 @@ var App = function App() { var handleError = function handleError(dataErrors, optionsErrors) { var _dataErrors$errors, _optionsErrors$errors; // Gather all error messages - var msgData = ""; + var msgData = ''; (_dataErrors$errors = dataErrors.errors) === null || _dataErrors$errors === void 0 || _dataErrors$errors.forEach(function (m) { - msgData += m + '\n'; + msgData += "".concat(m, "\n"); }); // Gather all error messages - var msgOptions = ""; + var msgOptions = ''; (_optionsErrors$errors = optionsErrors.errors) === null || _optionsErrors$errors === void 0 || _optionsErrors$errors.forEach(function (m) { - msgOptions += m + '\n'; + msgOptions += "".concat(m, "\n"); }); // Show the error (actually, can't because the snackbar is linked to a map at the moment and geochart is standalone) @@ -28176,20 +28191,20 @@ var App = function App() { cgpv.api.utilities.showError('', msgData); cgpv.api.utilities.showError('', msgOptions); console.error(dataErrors.errors, optionsErrors.errors); - alert("There was an error parsing the Chart inputs. View console for details."); + alert('There was an error parsing the Chart inputs. View console for details.'); }; var handleChartXAxisChanged = function handleChartXAxisChanged() { - console.log("Handle Chart X Axis"); + console.log('Handle Chart X Axis'); }; var handleChartYAxisChanged = function handleChartYAxisChanged() { - console.log("Handle Chart Y Axis"); + console.log('Handle Chart Y Axis'); }; // Effect hook to add and remove event listeners useEffect(function () { - window.addEventListener("chart/load", handleChartLoad); + window.addEventListener('chart/load', handleChartLoad); return function () { - window.removeEventListener("chart/load", handleChartLoad); + window.removeEventListener('chart/load', handleChartLoad); }; }); @@ -28200,13 +28215,13 @@ var App = function App() { }, data: data, options: options - //redraw={shouldRedraw} + // redraw={shouldRedraw} , handleSliderXChanged: handleChartXAxisChanged, handleSliderYChanged: handleChartYAxisChanged, handleError: handleError }); -}; +} /* harmony default export */ const app = (App); ;// CONCATENATED MODULE: ./src/index.tsx @@ -28214,13 +28229,14 @@ var App = function App() { -// Search for a special root in case we are loading the geochart standalone -var root = document.getElementById("root2aca7b6b288c"); +// Search for a special root in case we are loading the geochart standalone +var root = document.getElementById('root2aca7b6b288c'); if (root) { // Fetch the cgpv module + // eslint-disable-next-line @typescript-eslint/no-explicit-any var w = window; - var cgpv = w['cgpv']; + var cgpv = w.cgpv; var react = cgpv.react, createRoot = cgpv.createRoot; var container = createRoot(root);