diff --git a/package-lock.json b/package-lock.json index f6c029db..bbc4159f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9743,6 +9743,59 @@ "integrity": "sha1-JugROs4ZXqMND8OBhuRUAPnOpnI=", "dev": true }, + "url-loader": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/url-loader/-/url-loader-4.1.1.tgz", + "integrity": "sha512-3BTV812+AVHHOJQO8O5MkWgZ5aosP7GnROJwvzLS9hWDj00lZ6Z0wNak423Lp9PBZN05N+Jk/N5Si8jRAlGyWA==", + "dev": true, + "requires": { + "loader-utils": "^2.0.0", + "mime-types": "^2.1.27", + "schema-utils": "^3.0.0" + }, + "dependencies": { + "@types/json-schema": { + "version": "7.0.7", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", + "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", + "dev": true + }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "loader-utils": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz", + "integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==", + "dev": true, + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^3.0.0", + "json5": "^2.1.2" + } + }, + "schema-utils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.0.0.tgz", + "integrity": "sha512-6D82/xSzO094ajanoOSbe4YvXWMfn2A//8Y1+MUqFAJul5Bs+yn36xbK9OtNDcRVSBJ9jjeoXftM6CfztsjOAA==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.6", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } + } + } + }, "url-parse-lax": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/url-parse-lax/-/url-parse-lax-1.0.0.tgz", diff --git a/package.json b/package.json index 2969fee3..429cc230 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "name": "webviz_core_components", + "version": "0.0.1", "description": "Core components for webviz config", "repository": { "type": "git", @@ -15,7 +16,7 @@ "postinstall": "cp ./package.json webviz_core_components/package-info.json", "build:js": "webpack --mode production", "build:js-dev": "webpack --mode development", - "build:py_and_r": "dash-generate-components ./src/lib/components webviz_core_components -p package-info.json --r-prefix ''", + "build:py_and_r": "dash-generate-components ./src/lib/components webviz_core_components -p package-info.json --r-prefix '' --ignore .*.js$", "build": "npm run build:js && npm run build:js-dev && npm run build:py_and_r", "format": "prettier --write *.js *.json 'src/**/*.+(js|jsx|json|css)'", "linting": "prettier --check *.js *.json 'src/**/*.+(js|jsx|json|css)' && eslint src/" @@ -42,6 +43,7 @@ "babel-loader": "^8.0.6", "copyfiles": "^2.1.1", "css-loader": "^3.0.0", + "url-loader": "^4.1.1", "eslint": "^6.0.1", "eslint-config-prettier": "^6.0.0", "eslint-plugin-import": "^2.18.0", diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..8f342105 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# dash is required to call `build:py` +dash[dev]>=1.15.0 diff --git a/src/demo/App.js b/src/demo/App.js index 99947f01..d14e11d3 100644 --- a/src/demo/App.js +++ b/src/demo/App.js @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2021- Equinor ASA + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + /* eslint no-magic-numbers: 0 */ import React, { Component } from "react"; diff --git a/src/demo/index.js b/src/demo/index.js index c24e9d80..aa6d08f0 100644 --- a/src/demo/index.js +++ b/src/demo/index.js @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2021- Equinor ASA + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + import React from "react"; import ReactDOM from "react-dom"; import App from "./App"; diff --git a/src/lib/components/ColorScales.react.js b/src/lib/components/ColorScales/ColorScales.jsx similarity index 100% rename from src/lib/components/ColorScales.react.js rename to src/lib/components/ColorScales/ColorScales.jsx diff --git a/src/lib/components/ColorScales/index.js b/src/lib/components/ColorScales/index.js new file mode 100644 index 00000000..463108fa --- /dev/null +++ b/src/lib/components/ColorScales/index.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2021- Equinor ASA + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export { default } from "./ColorScales"; \ No newline at end of file diff --git a/src/lib/components/Select.css b/src/lib/components/Select.css deleted file mode 100644 index aff87a4a..00000000 --- a/src/lib/components/Select.css +++ /dev/null @@ -1,6 +0,0 @@ -.webviz-config-select { - width: 100%; - overflow-y: auto; - font-family: inherit; - font-size: inherit; -} diff --git a/src/lib/components/Select/Select.css b/src/lib/components/Select/Select.css new file mode 100644 index 00000000..9e2096d0 --- /dev/null +++ b/src/lib/components/Select/Select.css @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2021- Equinor ASA + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +.webviz-config-select { + width: 100%; + overflow-y: auto; + font-family: inherit; + font-size: inherit; +} diff --git a/src/lib/components/Select.react.js b/src/lib/components/Select/Select.jsx similarity index 96% rename from src/lib/components/Select.react.js rename to src/lib/components/Select/Select.jsx index 365ce34e..54595312 100644 --- a/src/lib/components/Select.react.js +++ b/src/lib/components/Select/Select.jsx @@ -1,3 +1,10 @@ +/** + * Copyright (c) 2021- Equinor ASA + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + import React, { Component } from "react"; import PropTypes from "prop-types"; import "./Select.css"; diff --git a/src/lib/components/Select/index.js b/src/lib/components/Select/index.js new file mode 100644 index 00000000..b6552e39 --- /dev/null +++ b/src/lib/components/Select/index.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2021- Equinor ASA + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export { default } from "./Select"; \ No newline at end of file diff --git a/src/lib/components/WebvizPluginPlaceholder.react.js b/src/lib/components/WebvizPluginPlaceholder/WebvizPluginPlaceholder.jsx similarity index 95% rename from src/lib/components/WebvizPluginPlaceholder.react.js rename to src/lib/components/WebvizPluginPlaceholder/WebvizPluginPlaceholder.jsx index cb1cb9cc..8c2cb47c 100644 --- a/src/lib/components/WebvizPluginPlaceholder.react.js +++ b/src/lib/components/WebvizPluginPlaceholder/WebvizPluginPlaceholder.jsx @@ -1,3 +1,11 @@ +/** + * Copyright (c) 2021- Equinor ASA + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + import React, { Component } from "react"; import PropTypes from "prop-types"; import html2canvas from "html2canvas"; @@ -11,9 +19,9 @@ import { faDownload, } from "@fortawesome/free-solid-svg-icons"; -import WebvizToolbarButton from "../private-components/webviz-plugin-placeholder-resources/WebvizToolbarButton"; -import WebvizContentOverlay from "../private-components/webviz-plugin-placeholder-resources/WebvizContentOverlay"; -import download_file from "../private-components/webviz-plugin-placeholder-resources/download_file"; +import WebvizToolbarButton from "./utils/WebvizToolbarButton"; +import WebvizContentOverlay from "./utils/WebvizContentOverlay"; +import download_file from "./utils/download_file"; import "./webviz_plugin_component.css"; @@ -87,7 +95,7 @@ export default class WebvizPluginPlaceholder extends Component { { scrollX: -window.scrollX, scrollY: -window.scrollY, - } + } ).then(canvas => canvas.toBlob(blob => download_file({ @@ -139,7 +147,7 @@ export default class WebvizPluginPlaceholder extends Component { )} {this.props.buttons.includes("contact_person") && Object.keys(this.props.contact_person).length > - 0 && ( + 0 && ( { return { mode, entry, + resolve: { + extensions: [".ts", ".tsx", ".js", ".jsx"], + }, output: { path: path.resolve(__dirname, dashLibraryName), filename, @@ -74,7 +77,7 @@ module.exports = (env, argv) => { module: { rules: [ { - test: /\.js$/, + test: /\.(ts|js)x?$/, exclude: /node_modules/, use: { loader: "babel-loader", @@ -92,6 +95,12 @@ module.exports = (env, argv) => { "css-loader", ], }, + { + test: /\.(png|svg|jpg|jpeg|gif)$/i, + use: { + loader: 'url-loader', + }, + }, ], }, devtool,