@hyperdart/frontend 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @hyperdart/frontend
2
+
3
+ Used for creating the HOC for darts before publishing to hyperDart
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install --save @hyperdart/frontend
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import { withHD } from '@hyperdart/frontend';
15
+
16
+ const newDart = (props) => {
17
+ ...
18
+ ...
19
+ }
20
+
21
+ export default withHD (newDart)
22
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("react-router-dom"),a=require("@material-ui/core/styles");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e);function s(){return s=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},s.apply(this,arguments)}const l={default:{palette:{type:"light"},typography:{useNextVariants:!0}},light:{palette:{primary:{main:"#F05F40"},secondary:{main:"#40f0bb"},type:"light"},typography:{useNextVariants:!0}},dark:{palette:{primary:{main:"#F05F40"},secondary:{main:"#40f0bb"},type:"dark"},typography:{useNextVariants:!0}},lightsOut:{palette:{primary:{main:"#F05F40"},type:"dark",background:{default:"#000",paper:"#000"}},shadows:Array(25).fill("0px 4px 12px #888888"),typography:{useNextVariants:!0}}};class i extends e.Component{constructor(e){super(e),this.state={themeName:e.themeName||"light"},this.theme=a.createTheme(l[this.state.themeName])}componentDidUpdate(e){console.log("did update"),this.props.themeName!==e.themeName&&(console.log("did update - new theme",this.props.themeName),this.theme=a.createTheme(l[this.props.themeName]),this.setState({themeName:this.props.themeName}))}render(){return console.log("rendering",this.state.themeName,this.theme.shadows[1]),n.default.createElement(a.MuiThemeProvider,{theme:this.theme},this.props.children)}}exports.withHD=a=>r=>{let{quickPanel:l,basename:o,...m}=r?{...r}:{};return l=l||!0,o=o||"",m.search=m.search||(e=>console.log("New query = ",e)),console.log("props in withHD",m),n.default.createElement(e.Fragment,null,r.match?n.default.createElement(a,r):n.default.createElement(t.BrowserRouter,{basename:o},n.default.createElement(i,{themeName:r.UIOptions?.themeName},n.default.createElement(t.Switch,null,n.default.createElement(t.Route,{path:r.baseURL,exact:!0,render:e=>n.default.createElement(a,s({},e,r,{quickPanel:l}))}),n.default.createElement(t.Route,{path:r.baseURL,render:e=>n.default.createElement(a,s({},e,r,{quickPanel:!1}))})))))};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/themes.js","../src/withHD.js"],"sourcesContent":["const themes = {\n\tdefault: {\n\t\tpalette: {\n\t\t\ttype: 'light',\n\t\t},\n\t\ttypography: { useNextVariants: true },\n\t},\n\tlight: {\n\t\tpalette: {\n\t\t\tprimary: {\n\t\t\t\tmain: '#F05F40'\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tmain: '#40f0bb'\n\t\t\t},\n\t\t\ttype: 'light',\n\t\t},\n\t\ttypography: { useNextVariants: true },\n\t},\n\tdark: {\n\t\tpalette: {\n\t\t\tprimary: {\n\t\t\t\tmain: '#F05F40'\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tmain: '#40f0bb'\n\t\t\t},\n\t\t\ttype: 'dark',\n\t\t},\n\t\ttypography: { useNextVariants: true },\n\t},\n\tlightsOut: {\n\t\tpalette: {\n\t\t\tprimary: {\n\t\t\t\tmain: '#F05F40'\n \t\t},\n\t\t\ttype: 'dark',\n\t\t\tbackground: {\n\t\t\t\tdefault: '#000',\n\t\t\t\tpaper: '#000'\n\t\t\t}\n\t\t},\n\t\tshadows: Array(25).fill('0px 4px 12px #888888'),\n\t\ttypography: { useNextVariants: true },\n\t}\n}\n\nexport default themes;\n","import React, {Fragment, Component} from 'react'\nimport { BrowserRouter, Route, Switch } from 'react-router-dom';\nimport { MuiThemeProvider, createTheme } from '@material-ui/core/styles'\nimport themes from './themes'\n\nclass HDTheme extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\t\tthis.state = {\n\t\t\tthemeName: props.themeName || 'light'\n\t\t};\n\t\tthis.theme = createTheme(themes[this.state.themeName])\n\t}\n\tcomponentDidUpdate(prevProps) {\n\t\tconsole.log('did update')\n\t\tif (this.props.themeName !== prevProps.themeName) {\n\t\t\tconsole.log('did update - new theme', this.props.themeName)\n\t\t\tthis.theme = createTheme(themes[this.props.themeName])\n\t\t\tthis.setState({themeName: this.props.themeName})\n\t\t}\n\t}\n\trender() {\n\t\tconsole.log('rendering', this.state.themeName, this.theme.shadows[1])\n\t\treturn (\n\t\t\t<MuiThemeProvider theme={this.theme}>\n\t\t\t\t{this.props.children}\n\t\t\t</MuiThemeProvider>\n\t\t)\n\t}\n}\n\n\nexport default (Comp) => (props) => {\n\tlet {quickPanel, basename, ...propsCopy} = props ? {...props} : {}\n\tquickPanel = quickPanel || true\n\tbasename = basename || ''\n\t// propsCopy.search = (query) => this.props.history.push('/web/search?q=' + decodeURIComponent(query)\n\tpropsCopy.search = propsCopy.search || ((query) => console.log('New query = ', query))\n\t// props_copy.query = props_copy.query || props_copy.searchData?.query || ''\n\tconsole.log('props in withHD', propsCopy)\n\treturn (\n\t\t<Fragment>\n\t\t{ props.match ?\n\t\t\t(\n\t\t\t\t<Comp {...props} />\n\t\t\t)\n\t\t\t:\n\t\t\t(\n\t\t\t\t<BrowserRouter basename={basename}>\n\t\t\t\t<HDTheme themeName={props.UIOptions?.themeName}>\n\t\t\t\t\t<Switch>\n\t\t\t\t\t\t<Route path={props.baseURL} exact render={(p) => <Comp {...p} {...props} quickPanel={quickPanel}/> }/>\n\t\t\t\t\t\t<Route path={props.baseURL} render={(p) => <Comp {...p} {...props} quickPanel={false} /> }/>\n\t\t\t\t\t</Switch>\n\t\t\t\t</HDTheme>\n\t\t\t\t</BrowserRouter>\n\t\t\t)\n\t\t}\n\t\t</Fragment>\n\t)\n}"],"names":["themes","default","palette","type","typography","useNextVariants","light","primary","main","secondary","dark","lightsOut","background","paper","shadows","Array","fill","HDTheme","Component","constructor","props","super","this","state","themeName","theme","createTheme","componentDidUpdate","prevProps","console","log","setState","render","React","MuiThemeProvider","children","Comp","quickPanel","basename","propsCopy","search","query","createElement","Fragment","match","BrowserRouter","UIOptions","Switch","Route","path","baseURL","exact","p"],"mappings":"kcAAA,MAAMA,EAAS,CACdC,QAAS,CACRC,QAAS,CACRC,KAAM,SAEPC,WAAY,CAAEC,iBAAiB,IAEhCC,MAAO,CACNJ,QAAS,CACRK,QAAS,CACRC,KAAM,WAEPC,UAAW,CACVD,KAAM,WAEPL,KAAM,SAEPC,WAAY,CAAEC,iBAAiB,IAEhCK,KAAM,CACLR,QAAS,CACRK,QAAS,CACRC,KAAM,WAEPC,UAAW,CACVD,KAAM,WAEPL,KAAM,QAEPC,WAAY,CAAEC,iBAAiB,IAEhCM,UAAW,CACVT,QAAS,CACRK,QAAS,CACRC,KAAM,WAEPL,KAAM,OACNS,WAAY,CACXX,QAAS,OACTY,MAAO,SAGTC,QAASC,MAAM,IAAIC,KAAK,wBACxBZ,WAAY,CAAEC,iBAAiB,KCtCjC,MAAMY,UAAgBC,EAAAA,UACrBC,YAAYC,GACXC,MAAMD,GACNE,KAAKC,MAAQ,CACZC,UAAWJ,EAAMI,WAAa,SAE/BF,KAAKG,MAAQC,cAAY1B,EAAOsB,KAAKC,MAAMC,YAE5CG,mBAAmBC,GAClBC,QAAQC,IAAI,cACRR,KAAKF,MAAMI,YAAcI,EAAUJ,YACtCK,QAAQC,IAAI,yBAA0BR,KAAKF,MAAMI,WACjDF,KAAKG,MAAQC,cAAY1B,EAAOsB,KAAKF,MAAMI,YAC3CF,KAAKS,SAAS,CAACP,UAAWF,KAAKF,MAAMI,aAGvCQ,SAEC,OADAH,QAAQC,IAAI,YAAaR,KAAKC,MAAMC,UAAWF,KAAKG,MAAMX,QAAQ,IAEjEmB,wBAACC,mBAAD,CAAkBT,MAAOH,KAAKG,OAC5BH,KAAKF,MAAMe,0BAOAC,GAAUhB,IACzB,IAAIiB,WAACA,EAADC,SAAaA,KAAaC,GAAanB,EAAQ,IAAIA,GAAS,GAOhE,OANAiB,EAAaA,IAAc,EAC3BC,EAAWA,GAAY,GAEvBC,EAAUC,OAASD,EAAUC,QAAYC,CAAAA,GAAUZ,QAAQC,IAAI,eAAgBW,IAE/EZ,QAAQC,IAAI,kBAAmBS,GAE9BN,EAAC,QAAAS,cAAAC,EAADA,SACEvB,KAAAA,EAAMwB,MAENX,EAAC,QAAAS,cAAAN,EAAShB,GAIVa,EAAAA,sBAACY,EAAAA,cAAD,CAAeP,SAAUA,GACzBL,wBAAChB,EAAD,CAASO,UAAWJ,EAAM0B,WAAWtB,WACpCS,EAAAA,QAACS,cAAAK,EAADA,OACC,KAAAd,EAAA,QAAAS,cAACM,QAAD,CAAOC,KAAM7B,EAAM8B,QAASC,OAA5B,EAAkCnB,OAASoB,GAAMnB,EAAAA,QAAAS,cAACN,EAASgB,EAAAA,GAAAA,EAAOhC,EAAjB,CAAwBiB,WAAYA,OACrFJ,EAAAA,sBAACe,QAAD,CAAOC,KAAM7B,EAAM8B,QAASlB,OAASoB,GAAMnB,EAAAA,QAAAS,cAACN,EAASgB,EAAAA,GAAAA,EAAOhC,EAAjB,CAAwBiB,YAAY"}
@@ -0,0 +1,2 @@
1
+ import e,{Fragment as t,Component as a}from"react";import{BrowserRouter as r,Switch as s,Route as m}from"react-router-dom";import{createTheme as n,MuiThemeProvider as o}from"@material-ui/core/styles";function p(){return p=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var r in a)Object.prototype.hasOwnProperty.call(a,r)&&(e[r]=a[r])}return e},p.apply(this,arguments)}const h={default:{palette:{type:"light"},typography:{useNextVariants:!0}},light:{palette:{primary:{main:"#F05F40"},secondary:{main:"#40f0bb"},type:"light"},typography:{useNextVariants:!0}},dark:{palette:{primary:{main:"#F05F40"},secondary:{main:"#40f0bb"},type:"dark"},typography:{useNextVariants:!0}},lightsOut:{palette:{primary:{main:"#F05F40"},type:"dark",background:{default:"#000",paper:"#000"}},shadows:Array(25).fill("0px 4px 12px #888888"),typography:{useNextVariants:!0}}};class i extends a{constructor(e){super(e),this.state={themeName:e.themeName||"light"},this.theme=n(h[this.state.themeName])}componentDidUpdate(e){console.log("did update"),this.props.themeName!==e.themeName&&(console.log("did update - new theme",this.props.themeName),this.theme=n(h[this.props.themeName]),this.setState({themeName:this.props.themeName}))}render(){return console.log("rendering",this.state.themeName,this.theme.shadows[1]),e.createElement(o,{theme:this.theme},this.props.children)}}var l=a=>n=>{let{quickPanel:o,basename:h,...l}=n?{...n}:{};return o=o||!0,h=h||"",l.search=l.search||(e=>console.log("New query = ",e)),console.log("props in withHD",l),e.createElement(t,null,n.match?e.createElement(a,n):e.createElement(r,{basename:h},e.createElement(i,{themeName:n.UIOptions?.themeName},e.createElement(s,null,e.createElement(m,{path:n.baseURL,exact:!0,render:t=>e.createElement(a,p({},t,n,{quickPanel:o}))}),e.createElement(m,{path:n.baseURL,render:t=>e.createElement(a,p({},t,n,{quickPanel:!1}))})))))};export{l as withHD};
2
+ //# sourceMappingURL=index.modern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.modern.js","sources":["../src/themes.js","../src/withHD.js"],"sourcesContent":["const themes = {\n\tdefault: {\n\t\tpalette: {\n\t\t\ttype: 'light',\n\t\t},\n\t\ttypography: { useNextVariants: true },\n\t},\n\tlight: {\n\t\tpalette: {\n\t\t\tprimary: {\n\t\t\t\tmain: '#F05F40'\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tmain: '#40f0bb'\n\t\t\t},\n\t\t\ttype: 'light',\n\t\t},\n\t\ttypography: { useNextVariants: true },\n\t},\n\tdark: {\n\t\tpalette: {\n\t\t\tprimary: {\n\t\t\t\tmain: '#F05F40'\n\t\t\t},\n\t\t\tsecondary: {\n\t\t\t\tmain: '#40f0bb'\n\t\t\t},\n\t\t\ttype: 'dark',\n\t\t},\n\t\ttypography: { useNextVariants: true },\n\t},\n\tlightsOut: {\n\t\tpalette: {\n\t\t\tprimary: {\n\t\t\t\tmain: '#F05F40'\n \t\t},\n\t\t\ttype: 'dark',\n\t\t\tbackground: {\n\t\t\t\tdefault: '#000',\n\t\t\t\tpaper: '#000'\n\t\t\t}\n\t\t},\n\t\tshadows: Array(25).fill('0px 4px 12px #888888'),\n\t\ttypography: { useNextVariants: true },\n\t}\n}\n\nexport default themes;\n","import React, {Fragment, Component} from 'react'\nimport { BrowserRouter, Route, Switch } from 'react-router-dom';\nimport { MuiThemeProvider, createTheme } from '@material-ui/core/styles'\nimport themes from './themes'\n\nclass HDTheme extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\t\tthis.state = {\n\t\t\tthemeName: props.themeName || 'light'\n\t\t};\n\t\tthis.theme = createTheme(themes[this.state.themeName])\n\t}\n\tcomponentDidUpdate(prevProps) {\n\t\tconsole.log('did update')\n\t\tif (this.props.themeName !== prevProps.themeName) {\n\t\t\tconsole.log('did update - new theme', this.props.themeName)\n\t\t\tthis.theme = createTheme(themes[this.props.themeName])\n\t\t\tthis.setState({themeName: this.props.themeName})\n\t\t}\n\t}\n\trender() {\n\t\tconsole.log('rendering', this.state.themeName, this.theme.shadows[1])\n\t\treturn (\n\t\t\t<MuiThemeProvider theme={this.theme}>\n\t\t\t\t{this.props.children}\n\t\t\t</MuiThemeProvider>\n\t\t)\n\t}\n}\n\n\nexport default (Comp) => (props) => {\n\tlet {quickPanel, basename, ...propsCopy} = props ? {...props} : {}\n\tquickPanel = quickPanel || true\n\tbasename = basename || ''\n\t// propsCopy.search = (query) => this.props.history.push('/web/search?q=' + decodeURIComponent(query)\n\tpropsCopy.search = propsCopy.search || ((query) => console.log('New query = ', query))\n\t// props_copy.query = props_copy.query || props_copy.searchData?.query || ''\n\tconsole.log('props in withHD', propsCopy)\n\treturn (\n\t\t<Fragment>\n\t\t{ props.match ?\n\t\t\t(\n\t\t\t\t<Comp {...props} />\n\t\t\t)\n\t\t\t:\n\t\t\t(\n\t\t\t\t<BrowserRouter basename={basename}>\n\t\t\t\t<HDTheme themeName={props.UIOptions?.themeName}>\n\t\t\t\t\t<Switch>\n\t\t\t\t\t\t<Route path={props.baseURL} exact render={(p) => <Comp {...p} {...props} quickPanel={quickPanel}/> }/>\n\t\t\t\t\t\t<Route path={props.baseURL} render={(p) => <Comp {...p} {...props} quickPanel={false} /> }/>\n\t\t\t\t\t</Switch>\n\t\t\t\t</HDTheme>\n\t\t\t\t</BrowserRouter>\n\t\t\t)\n\t\t}\n\t\t</Fragment>\n\t)\n}"],"names":["themes","default","palette","type","typography","useNextVariants","light","primary","main","secondary","dark","lightsOut","background","paper","shadows","Array","fill","HDTheme","Component","constructor","props","super","this","state","themeName","theme","createTheme","componentDidUpdate","prevProps","console","log","setState","render","React","MuiThemeProvider","children","withHD","Comp","quickPanel","basename","propsCopy","search","query","createElement","Fragment","match","BrowserRouter","UIOptions","Switch","Route","path","baseURL","exact","p"],"mappings":"wZAAA,MAAMA,EAAS,CACdC,QAAS,CACRC,QAAS,CACRC,KAAM,SAEPC,WAAY,CAAEC,iBAAiB,IAEhCC,MAAO,CACNJ,QAAS,CACRK,QAAS,CACRC,KAAM,WAEPC,UAAW,CACVD,KAAM,WAEPL,KAAM,SAEPC,WAAY,CAAEC,iBAAiB,IAEhCK,KAAM,CACLR,QAAS,CACRK,QAAS,CACRC,KAAM,WAEPC,UAAW,CACVD,KAAM,WAEPL,KAAM,QAEPC,WAAY,CAAEC,iBAAiB,IAEhCM,UAAW,CACVT,QAAS,CACRK,QAAS,CACRC,KAAM,WAEPL,KAAM,OACNS,WAAY,CACXX,QAAS,OACTY,MAAO,SAGTC,QAASC,MAAM,IAAIC,KAAK,wBACxBZ,WAAY,CAAEC,iBAAiB,KCtCjC,MAAMY,UAAgBC,EACrBC,YAAYC,GACXC,MAAMD,GACNE,KAAK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
+ {
2
+ "name": "@hyperdart/frontend",
3
+ "version": "1.0.1",
4
+ "description": "hyperDart frontend for dart development",
5
+ "author": "hyperdart",
6
+ "license": "MIT",
7
+ "main": "dist/index.js",
8
+ "module": "dist/index.modern.js",
9
+ "source": "src/index.js",
10
+ "engines": {
11
+ "node": ">=10"
12
+ },
13
+ "scripts": {
14
+ "start": "rollup -c -w",
15
+ "build": "rollup -c"
16
+ },
17
+ "peerDependencies": {
18
+ "@material-ui/core": "^4.11.4",
19
+ "react": "^17.0.0",
20
+ "react-dom": "^17.0.0",
21
+ "react-router-dom": "^4.3.1"
22
+ },
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "devDependencies": {
27
+ "@rollup/plugin-replace": "^4.0.0",
28
+ "microbundle": "^0.15.0",
29
+ "rollup-plugin-postcss": "^4.0.2"
30
+ }
31
+ }