@decafhub/decaf-react-webapp 0.0.2 → 0.0.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.4](https://github.com/teloscube/decaf-react-webapp/compare/v0.0.3...v0.0.4) (2022-11-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * export decafTheme in case client wants to use or expand it ([3f86608](https://github.com/teloscube/decaf-react-webapp/commit/3f86608160fe9d8de41fea9a497e0595298435a2))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update header and badge components' colors ([3d4ce9b](https://github.com/teloscube/decaf-react-webapp/commit/3d4ce9b04c01b937396d11c580354659f467f20f))
14
+
15
+ ## [0.0.3](https://github.com/teloscube/decaf-react-webapp/compare/v0.0.2...v0.0.3) (2022-11-28)
16
+
17
+
18
+ ### Features
19
+
20
+ * get app icon from props ([577a1f5](https://github.com/teloscube/decaf-react-webapp/commit/577a1f553e4ba064f3e3a9d7f807ae94f085d634))
21
+
3
22
  ## [0.0.2](https://github.com/teloscube/decaf-react-webapp/compare/v0.0.1...v0.0.2) (2022-11-28)
4
23
 
5
24
 
package/dist/Layout.d.ts CHANGED
@@ -1,7 +1,22 @@
1
- /// <reference types="react" />
2
1
  import { ItemType } from 'antd/es/menu/hooks/useItems';
3
- import { DecafLayoutProps } from 'types';
4
- import { DecafMenuItem } from './types';
2
+ import React from 'react';
3
+ interface BaseDecafMenuItem {
4
+ label: any;
5
+ icon?: React.ReactNode;
6
+ children?: DecafMenuItem[];
7
+ }
8
+ export type DecafMenuItem = BaseDecafMenuItem & ({
9
+ to?: string;
10
+ } | {
11
+ href?: string;
12
+ });
13
+ export interface DecafLayoutProps {
14
+ menu: DecafMenuItem[];
15
+ appName: string;
16
+ appIcon?: React.ReactNode;
17
+ children: React.ReactNode;
18
+ }
5
19
  export declare function routesToAntMenu(routes: DecafMenuItem[]): ItemType[];
6
20
  export default function DecafLayout(props: DecafLayoutProps): JSX.Element;
21
+ export {};
7
22
  //# sourceMappingURL=Layout.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../src/Layout.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAe,MAAM,6BAA6B,CAAC;AAGpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ,EAAE,CAyBnE;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,gBAAgB,eA0B1D"}
1
+ {"version":3,"file":"Layout.d.ts","sourceRoot":"","sources":["../src/Layout.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,UAAU,iBAAiB;IACzB,KAAK,EAAE,GAAG,CAAC;IACX,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,CAAC;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEtF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,QAAQ,EAAE,CAyBnE;AAED,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,gBAAgB,eA0B1D"}
package/dist/index.d.ts CHANGED
@@ -1,7 +1,22 @@
1
- /// <reference types="react" />
1
+ import { DecafAppConfig, DecafAppController } from '@decafhub/decaf-react';
2
2
  import { css, Global } from '@emotion/react';
3
3
  import styled from '@emotion/styled';
4
- import { DecafWebappProps } from 'types';
4
+ import 'antd/dist/reset.css';
5
+ import { ThemeConfig } from 'antd/es/config-provider/context';
6
+ import React from 'react';
7
+ import { RouteObject } from 'react-router-dom';
8
+ import { DecafMenuItem } from './Layout';
9
+ import { decafTheme } from './theme';
10
+ export type DecafRoute = RouteObject;
11
+ export interface DecafWebappProps {
12
+ config?: DecafAppConfig;
13
+ controller?: DecafAppController;
14
+ theme?: ThemeConfig;
15
+ routes: DecafRoute[];
16
+ menuItems: DecafMenuItem[];
17
+ appName: string;
18
+ appIcon?: React.ReactNode;
19
+ }
5
20
  declare function DecafWebapp(props: DecafWebappProps): JSX.Element;
6
- export { DecafWebapp, Global as GlobalStyle, css, styled };
21
+ export { DecafWebapp, Global as GlobalStyle, css, styled, decafTheme };
7
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAMrC,OAAO,EAA6B,gBAAgB,EAAE,MAAM,OAAO,CAAC;AAuBpE,iBAAS,WAAW,CAAC,KAAK,EAAE,gBAAgB,eA0B3C;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AAErC,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAA+B,WAAW,EAAkB,MAAM,kBAAkB,CAAC;AAC5F,OAAoB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AAErC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAuBD,iBAAS,WAAW,CAAC,KAAK,EAAE,gBAAgB,eAmC3C;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,IAAI,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("@decafhub/decaf-react"),t=require("@emotion/react"),r=require("@emotion/styled"),n=require("antd"),o=require("react"),a=require("react-router-dom");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=/*#__PURE__*/l(r),u=/*#__PURE__*/l(o);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i.apply(this,arguments)}function d(e){var t=[];return e.forEach(function(e){var r={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e?r.label=u.default.createElement(a.NavLink,{to:e.to,end:"/"===e.to},e.label):e.href?r.label=u.default.createElement("a",{href:e.href},e.label):e.children&&(r.label=e.label,r.children=d(e.children||[])),t.push(r)}),t}function f(e){var t=d(e.menu),r=a.useMatches().map(function(e){return e.pathname});return u.default.createElement(n.Layout,{style:{height:"100%"}},u.default.createElement(n.Layout.Header,{style:{paddingInline:0}},u.default.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},u.default.createElement(a.Link,{to:"/"},u.default.createElement(n.Typography.Title,{level:4,style:{margin:0}},e.appName)),u.default.createElement(n.Menu,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:r}))),u.default.createElement(n.Layout.Content,{style:{padding:"20px 50px"}},e.children))}var s={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,colorError:"#b03a38",colorSuccess:"#48734d",colorWarning:"#ffc107",colorInfo:"#4694ab",green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[n.theme.darkAlgorithm]};function m(e,t){var r=[];return t.forEach(function(t){var n,o=i({},t);t.children?(o.element=null!=(n=t.element)?n:u.default.createElement(a.Outlet,null),o.children=m(e,t.children)):o.element=u.default.createElement(f,{menu:e,appName:"Decaf Webapp"},t.element),r.push(o)}),r}Object.defineProperty(exports,"GlobalStyle",{enumerable:!0,get:function(){return t.Global}}),Object.defineProperty(exports,"css",{enumerable:!0,get:function(){return t.css}}),Object.defineProperty(exports,"styled",{enumerable:!0,get:function(){return c.default}}),exports.DecafWebapp=function(r){var o,l,c,i,d=m(r.menuItems,r.routes),f=a.createBrowserRouter(d,{basename:null==(o=r.config)?void 0:o.basePath}),b=null!=(l=r.theme)?l:s;return u.default.createElement(n.ConfigProvider,{theme:b},u.default.createElement(t.Global,{styles:{body:{background:null==(c=b.token)?void 0:c.colorBgBase,fontFamily:null==(i=b.token)?void 0:i.fontFamily},button:{boxShadow:"none !important"}}}),u.default.createElement(e.DecafApp,{config:r.config,controller:r.controller},u.default.createElement(a.RouterProvider,{router:f})))};
1
+ var e=require("@decafhub/decaf-react"),t=require("@emotion/react"),n=require("@emotion/styled"),r=require("antd");require("antd/dist/reset.css");var a=require("react"),o=require("react-router-dom");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/l(n),c=/*#__PURE__*/l(a);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},u.apply(this,arguments)}function d(e){var t=[];return e.forEach(function(e){var n={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e&&e.to?n.label=c.default.createElement(o.NavLink,{to:e.to,end:"/"===e.to},e.label):"href"in e&&e.href?n.label=c.default.createElement("a",{href:e.href},e.label):e.children&&(n.label=e.label,n.children=d(e.children||[])),t.push(n)}),t}function f(e){var t=d(e.menu),n=o.useMatches().map(function(e){return e.pathname});return c.default.createElement(r.Layout,{style:{height:"100%"}},c.default.createElement(r.Layout.Header,{style:{paddingInline:0}},c.default.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},c.default.createElement(o.Link,{to:"/",style:{display:"flex",alignItems:"center",gap:10}},e.appIcon,c.default.createElement(r.Typography.Title,{level:4,style:{margin:0}},e.appName)),c.default.createElement(r.Menu,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:n}))),c.default.createElement(r.Layout.Content,{style:{padding:"20px 50px"}},e.children))}var s={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[r.theme.darkAlgorithm]};function m(e,t){var n=[];return t.forEach(function(t){var r,a=u({},t);t.children?(a.element=null!=(r=t.element)?r:c.default.createElement(o.Outlet,null),a.children=m(e,t.children)):a.element=c.default.createElement(f,{menu:e.menuItems,appName:e.appName,appIcon:e.appIcon},t.element),n.push(a)}),n}Object.defineProperty(exports,"GlobalStyle",{enumerable:!0,get:function(){return t.Global}}),Object.defineProperty(exports,"css",{enumerable:!0,get:function(){return t.css}}),Object.defineProperty(exports,"styled",{enumerable:!0,get:function(){return i.default}}),exports.DecafWebapp=function(n){var a,l,i,u,d,f,p=m(n,n.routes),b=o.createBrowserRouter(p,{basename:null==(a=n.config)?void 0:a.basePath}),h=null!=(l=n.theme)?l:s;return c.default.createElement(r.ConfigProvider,{theme:h},c.default.createElement(t.Global,{styles:{body:{background:null==(i=h.token)?void 0:i.colorBgBase,fontFamily:null==(u=h.token)?void 0:u.fontFamily,margin:0},button:{boxShadow:"none !important"},".ant-page-header-back-button, .ant-page-header-heading-title":{color:(null==(d=h.token)?void 0:d.colorWhite)+" !important"},".ant-badge-count":{color:(null==(f=h.token)?void 0:f.colorWhite)+" !important"}}}),c.default.createElement(e.DecafApp,{config:n.config,controller:n.controller},c.default.createElement(o.RouterProvider,{router:b})))},exports.decafTheme=s;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\nimport { DecafLayoutProps } from 'types';\nimport { DecafMenuItem } from './types';\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if (route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\">\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n {/* <Layout.Footer style={{ textAlign: 'center' }}>Footer</Layout.Footer> */}\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n colorError: '#b03a38',\n colorSuccess: '#48734d',\n colorWarning: '#ffc107',\n colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport DecafLayout from 'Layout';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport { decafTheme } from 'theme';\nimport { DecafMenuItem, DecafRoute, DecafWebappProps } from 'types';\n\nfunction buildRoutes(menuItems: DecafMenuItem[], routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(menuItems, route.children);\n } else {\n item.element = (\n <DecafLayout menu={menuItems} appName=\"Decaf Webapp\">\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props.menuItems, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n },\n button: {\n // antd button has a default box shadow and we can't override it for now\n boxShadow: 'none !important',\n },\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled };\n"],"names":["routesToAntMenu","routes","result","forEach","route","key","to","label","icon","item","React","createElement","NavLink","end","href","children","push","DecafLayout","props","menuItems","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","colorError","colorSuccess","colorWarning","colorInfo","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","_route$element","_extends","element","Outlet","_props$config","_props$theme","_theme$token","_theme$token2","router","createBrowserRouter","basename","config","basePath","ConfigProvider","Global","styles","body","background","button","DecafApp","controller","RouterProvider"],"mappings":"2fAOgBA,SAAAA,EAAgBC,GAC9B,IAAMC,EAAqB,GAuB3B,OArBAD,EAAOE,QAAQ,SAACC,GACd,MAAuB,CACrBC,IAAK,OAAaD,EAAGA,EAAME,GAAKF,EAAMG,MACtCA,MAAOH,EAAMG,MACbC,KAAMJ,EAAMI,MAEV,SACFC,EAAKF,MACHG,EAAAA,QAAAC,cAACC,UAAO,CAACN,GAAIF,EAAME,GAAIO,IAAkB,MAAbT,EAAME,IAC/BF,EAAMG,OAGFH,EAAMU,KACfL,EAAKF,MAAQG,UAAAC,cAAA,IAAA,CAAGG,KAAMV,EAAMU,MAAOV,EAAMG,OAChCH,EAAMW,WACfN,EAAKF,MAAQH,EAAMG,MAClBE,EAAqBM,SAAWf,EAAgBI,EAAMW,UAAY,KAErEb,EAAOc,KAAKP,EACd,IAGF,UAEmCQ,EAACC,GAClC,IAAMC,EAAYnB,EAAg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E,OAAjBN,EAAAA,EAAMwE,SAAWlE,EAAAA,EAAAA,QAAAC,cAACkE,EAAAA,OAAM,MACvCpE,EAAKM,SAAW0D,EAAYtD,EAAWf,EAAMW,WAE7CN,EAAKmE,QACHlE,EAAAA,sBAACO,EAAW,CAACG,KAAMD,EAAWoB,QAAQ,gBACnCnC,EAAMwE,SAIb1E,EAAOc,KAAKP,EACd,GAGFP,CAAA,6RAEA,SAAqBgB,GAAuB,IAAA4D,EAAAC,EAAAC,EAAAC,EAC9BhF,EAAGwE,EAAYvD,EAAMC,UAAWD,EAAMjB,QAC5CiF,EAASC,EAAmBA,oBAAClF,EAAQ,CACzCmF,SAAsB,SAAZlE,EAAMmE,aAAM,EAAZP,EAAcQ,WAEpBf,EAAmB,OAAXrD,EAAAA,EAAMqD,OAAKQ,EAAI/B,EAE7B,OACGtC,EAAAA,QAAAC,cAAA4E,EAAcA,eAAC,CAAAhB,MAAOA,GACrB7D,EAAC,QAAAC,cAAA6E,EAAMA,OACL,CAAAC,OAAQ,CACNC,KAAM,CACJC,WAAY,OAAApB,EAAAA,EAAMhB,YAAN,EAAAyB,EAAatB,YACzBF,WAAY,OAAAe,EAAAA,EAAMhB,YAAN,EAAA0B,EAAazB,YAE3BoC,OAAQ,CAENvC,UAAW,sBAIjB3C,EAAAA,QAAAC,cAACkF,EAAQA,SAAA,CAACR,OAAQnE,EAAMmE,OAAQS,WAAY5E,EAAM4E,YAChDpF,EAAC,QAAAC,cAAAoF,EAAAA,gBAAeb,OAAQA,KAIhC"}
1
+ {"version":3,"file":"index.js","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\n\ninterface BaseDecafMenuItem {\n label: any;\n icon?: React.ReactNode;\n children?: DecafMenuItem[];\n}\n\nexport type DecafMenuItem = BaseDecafMenuItem & ({ to?: string } | { href?: string });\n\nexport interface DecafLayoutProps {\n menu: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n children: React.ReactNode;\n}\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route && route.to) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if ('href' in route && route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\" style={{ display: 'flex', alignItems: 'center', gap: 10 }}>\n {props.appIcon}\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n // colorError: '#b03a38',\n // colorSuccess: '#48734d',\n // colorWarning: '#ffc107',\n // colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp, DecafAppConfig, DecafAppController } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport 'antd/dist/reset.css';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport DecafLayout, { DecafMenuItem } from './Layout';\nimport { decafTheme } from './theme';\n\nexport type DecafRoute = RouteObject;\n\nexport interface DecafWebappProps {\n config?: DecafAppConfig;\n controller?: DecafAppController;\n theme?: ThemeConfig;\n routes: DecafRoute[];\n menuItems: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n}\n\nfunction buildRoutes(props: DecafWebappProps, routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(props, route.children);\n } else {\n item.element = (\n <DecafLayout menu={props.menuItems} appName={props.appName} appIcon={props.appIcon}>\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n margin: 0,\n },\n // antd overrides\n button: {\n boxShadow: 'none !important',\n },\n '.ant-page-header-back-button, .ant-page-header-heading-title': {\n color: `${theme.token?.colorWhite} !important`,\n },\n '.ant-badge-count': {\n color: `${theme.token?.colorWhite} !important`,\n },\n // end antd overrides\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled, decafTheme };\n"],"names":["routesToAntMenu","routes","result","forEach","route","item","key","to","label","icon","React","createElement","NavLink","end","href","children","push","DecafLayout","props","menuItems","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","gap","appIcon","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","_route$element","element","Outlet","_props$config","_props$theme","_theme$token","_theme$token2","_theme$token3","_theme$token4","router","createBrowserRouter","basename","config","basePath","ConfigProvider","Global","styles","body","background","button","color","DecafApp","controller","RouterProvider"],"mappings":"uiBAoB+BA,EAACC,GAC9B,IAAYC,EAAe,GAuB3B,OArBAD,EAAOE,QAAQ,SAACC,GACd,IAAUC,EAAa,CACrBC,IAAK,OAAaF,EAAGA,EAAMG,GAAKH,EAAMI,MACtCA,MAAOJ,EAAMI,MACbC,KAAML,EAAMK,MAEV,OAAaL,GAAIA,EAAMG,GACzBF,EAAKG,MACHE,EAAA,QAAAC,cAACC,EAAAA,QAAO,CAACL,GAAIH,EAAMG,GAAIM,IAAkB,MAAbT,EAAMG,IAC/BH,EAAMI,OAGF,SAAeJ,GAAIA,EAAMU,KAClC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,EAAM4E,YAChDpF,UAACC,cAAAoF,EAAcA,gBAACd,OAAQA,KAIhC"}
@@ -1,2 +1,2 @@
1
- import{DecafApp as e}from"@decafhub/decaf-react";import{Global as t}from"@emotion/react";export{Global as GlobalStyle,css}from"@emotion/react";export{default as styled}from"@emotion/styled";import{Layout as o,Typography as n,Menu as r,theme as l,ConfigProvider as a}from"antd";import c from"react";import{useMatches as i,Link as m,NavLink as s,createBrowserRouter as d,RouterProvider as f,Outlet as u}from"react-router-dom";function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},p.apply(this,arguments)}function b(e){const t=[];return e.forEach(e=>{const o={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e?o.label=c.createElement(s,{to:e.to,end:"/"===e.to},e.label):e.href?o.label=c.createElement("a",{href:e.href},e.label):e.children&&(o.label=e.label,o.children=b(e.children||[])),t.push(o)}),t}function h(e){const t=b(e.menu),l=i().map(e=>e.pathname);return c.createElement(o,{style:{height:"100%"}},c.createElement(o.Header,{style:{paddingInline:0}},c.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},c.createElement(m,{to:"/"},c.createElement(n.Title,{level:4,style:{margin:0}},e.appName)),c.createElement(r,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:l}))),c.createElement(o.Content,{style:{padding:"20px 50px"}},e.children))}const y={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,colorError:"#b03a38",colorSuccess:"#48734d",colorWarning:"#ffc107",colorInfo:"#4694ab",green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[l.darkAlgorithm]};function g(e,t){const o=[];return t.forEach(t=>{const n=p({},t);var r;t.children?(n.element=null!=(r=t.element)?r:c.createElement(u,null),n.children=g(e,t.children)):n.element=c.createElement(h,{menu:e,appName:"Decaf Webapp"},t.element),o.push(n)}),o}function E(o){var n,r,l,i;const m=g(o.menuItems,o.routes),s=d(m,{basename:null==(n=o.config)?void 0:n.basePath}),u=null!=(r=o.theme)?r:y;return c.createElement(a,{theme:u},c.createElement(t,{styles:{body:{background:null==(l=u.token)?void 0:l.colorBgBase,fontFamily:null==(i=u.token)?void 0:i.fontFamily},button:{boxShadow:"none !important"}}}),c.createElement(e,{config:o.config,controller:o.controller},c.createElement(f,{router:s})))}export{E as DecafWebapp};
1
+ import{DecafApp as e}from"@decafhub/decaf-react";import{Global as t}from"@emotion/react";export{Global as GlobalStyle,css}from"@emotion/react";export{default as styled}from"@emotion/styled";import{Layout as o,Typography as n,Menu as r,theme as l,ConfigProvider as a}from"antd";import"antd/dist/reset.css";import i from"react";import{useMatches as c,Link as m,NavLink as s,createBrowserRouter as d,RouterProvider as p,Outlet as f}from"react-router-dom";function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},u.apply(this,arguments)}function h(e){const t=[];return e.forEach(e=>{const o={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e&&e.to?o.label=i.createElement(s,{to:e.to,end:"/"===e.to},e.label):"href"in e&&e.href?o.label=i.createElement("a",{href:e.href},e.label):e.children&&(o.label=e.label,o.children=h(e.children||[])),t.push(o)}),t}function b(e){const t=h(e.menu),l=c().map(e=>e.pathname);return i.createElement(o,{style:{height:"100%"}},i.createElement(o.Header,{style:{paddingInline:0}},i.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},i.createElement(m,{to:"/",style:{display:"flex",alignItems:"center",gap:10}},e.appIcon,i.createElement(n.Title,{level:4,style:{margin:0}},e.appName)),i.createElement(r,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:l}))),i.createElement(o.Content,{style:{padding:"20px 50px"}},e.children))}const y={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[l.darkAlgorithm]};function g(e,t){const o=[];return t.forEach(t=>{const n=u({},t);var r;t.children?(n.element=null!=(r=t.element)?r:i.createElement(f,null),n.children=g(e,t.children)):n.element=i.createElement(b,{menu:e.menuItems,appName:e.appName,appIcon:e.appIcon},t.element),o.push(n)}),o}function E(o){var n,r,l,c,m,s;const f=g(o,o.routes),u=d(f,{basename:null==(n=o.config)?void 0:n.basePath}),h=null!=(r=o.theme)?r:y;return i.createElement(a,{theme:h},i.createElement(t,{styles:{body:{background:null==(l=h.token)?void 0:l.colorBgBase,fontFamily:null==(c=h.token)?void 0:c.fontFamily,margin:0},button:{boxShadow:"none !important"},".ant-page-header-back-button, .ant-page-header-heading-title":{color:`${null==(m=h.token)?void 0:m.colorWhite} !important`},".ant-badge-count":{color:`${null==(s=h.token)?void 0:s.colorWhite} !important`}}}),i.createElement(e,{config:o.config,controller:o.controller},i.createElement(p,{router:u})))}export{E as DecafWebapp,y as decafTheme};
2
2
  //# sourceMappingURL=index.modern.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.mjs","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\nimport { DecafLayoutProps } from 'types';\nimport { DecafMenuItem } from './types';\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if (route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\">\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n {/* <Layout.Footer style={{ textAlign: 'center' }}>Footer</Layout.Footer> */}\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n colorError: '#b03a38',\n colorSuccess: '#48734d',\n colorWarning: '#ffc107',\n colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport DecafLayout from 'Layout';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport { decafTheme } from 'theme';\nimport { DecafMenuItem, DecafRoute, DecafWebappProps } from 'types';\n\nfunction buildRoutes(menuItems: DecafMenuItem[], routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(menuItems, route.children);\n } else {\n item.element = (\n <DecafLayout menu={menuItems} appName=\"Decaf Webapp\">\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props.menuItems, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n },\n button: {\n // antd button has a default box shadow and we can't override it for now\n boxShadow: 'none !important',\n },\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled };\n"],"names":["routesToAntMenu","routes","result","forEach","route","item","key","to","label","icon","React","createElement","NavLink","end","href","children","push","props","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","menuItems","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","colorError","colorSuccess","colorWarning","colorInfo","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","element","_route$element","Outlet","DecafLayout","DecafWebapp","_props$config","_props$theme","_theme$token","_theme$token2","router","createBrowserRouter","basename","config","basePath","ConfigProvider","Global","styles","body","background","button","DecafApp","controller","RouterProvider"],"mappings":"4oBAOgBA,SAAAA,EAAgBC,GAC9B,MAAMC,EAAqB,GAuB3B,OArBAD,EAAOE,QAASC,IACd,MAAMC,EAAiB,CACrBC,IAAK,SAAgBF,EAAMG,GAAKH,EAAMI,MACtCA,MAAOJ,EAAMI,MACbC,KAAML,EAAMK,MAEV,OAAQL,EACVC,EAAKG,MACHE,EAAAC,cAACC,EAAO,CAACL,GAAIH,EAAMG,GAAIM,IAAkB,MAAbT,EAAMG,IAC/BH,EAAMI,OAGFJ,EAAMU,KACfT,EAAKG,MAAQE,EAAAC,cAAA,IAAA,CAAGG,KAAMV,EAAMU,MAAOV,EAAMI,OAChCJ,EAAMW,WACfV,EAAKG,MAAQJ,EAAMI,MAClBH,EAAqBU,SAAWf,EAAgBI,EAAMW,UAAY,KAErEb,EAAOc,KAAKX,KAGPH,CACT,CAEwB,WAAYe,GAClC,QAAkBjB,E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,WAE7CV,EAAKoE,QACH/D,gBAACkE,EAAW,CAAC1D,KAAMyB,EAAWN,QAAQ,gBACnCjC,EAAMqE,SAIbvE,EAAOc,KAAKX,EACd,IAGF,CAEA,SAAoBwE,EAAC5D,GACnB,IAAA6D,EAAAC,EAAAC,EAAAC,EAAA,QAAeT,EAAYvD,EAAM0B,UAAW1B,EAAMhB,QACtCiF,EAAGC,EAAoBlF,EAAQ,CACzCmF,SAAU,OAAFN,EAAE7D,EAAMoE,aAAN,EAAAP,EAAcQ,WAEfhB,EAAkBvB,OAAlBgC,EAAG9D,EAAMqD,OAASvB,EAAAA,EAE7B,OACGrC,EAAAC,cAAA4E,EAAe,CAAAjB,MAAOA,GACrB5D,EAACC,cAAA6E,EACC,CAAAC,OAAQ,CACNC,KAAM,CACJC,WAAY,OAAArB,EAAAA,EAAMhB,YAAN,EAAA0B,EAAavB,YACzBF,WAAY,OAAAe,EAAAA,EAAMhB,YAAN,EAAA2B,EAAa1B,YAE3BqC,OAAQ,CAENxC,UAAW,sBAIjB1C,EAAAC,cAACkF,EAAQ,CAACR,OAAQpE,EAAMoE,OAAQS,WAAY7E,EAAM6E,YAChDpF,EAACC,cAAAoF,GAAeb,OAAQA,KAIhC"}
1
+ {"version":3,"file":"index.modern.mjs","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\n\ninterface BaseDecafMenuItem {\n label: any;\n icon?: React.ReactNode;\n children?: DecafMenuItem[];\n}\n\nexport type DecafMenuItem = BaseDecafMenuItem & ({ to?: string } | { href?: string });\n\nexport interface DecafLayoutProps {\n menu: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n children: React.ReactNode;\n}\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route && route.to) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if ('href' in route && route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\" style={{ display: 'flex', alignItems: 'center', gap: 10 }}>\n {props.appIcon}\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n // colorError: '#b03a38',\n // colorSuccess: '#48734d',\n // colorWarning: '#ffc107',\n // colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp, DecafAppConfig, DecafAppController } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport 'antd/dist/reset.css';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport DecafLayout, { DecafMenuItem } from './Layout';\nimport { decafTheme } from './theme';\n\nexport type DecafRoute = RouteObject;\n\nexport interface DecafWebappProps {\n config?: DecafAppConfig;\n controller?: DecafAppController;\n theme?: ThemeConfig;\n routes: DecafRoute[];\n menuItems: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n}\n\nfunction buildRoutes(props: DecafWebappProps, routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(props, route.children);\n } else {\n item.element = (\n <DecafLayout menu={props.menuItems} appName={props.appName} appIcon={props.appIcon}>\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n margin: 0,\n },\n // antd overrides\n button: {\n boxShadow: 'none !important',\n },\n '.ant-page-header-back-button, .ant-page-header-heading-title': {\n color: `${theme.token?.colorWhite} !important`,\n },\n '.ant-badge-count': {\n color: `${theme.token?.colorWhite} !important`,\n },\n // end antd overrides\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled, decafTheme };\n"],"names":["routesToAntMenu","routes","result","forEach","route","key","to","label","icon","item","React","createElement","NavLink","end","href","children","push","DecafLayout","props","menuItems","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","gap","appIcon","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","element","_route$element","Outlet","DecafWebapp","router","createBrowserRouter","basename","config","_props$config","basePath","_props$theme","ConfigProvider","Global","styles","body","background","_theme$token","_theme$token2","button","color","_theme$token3","_theme$token4","DecafApp","controller","RouterProvider"],"mappings":"irBAoB+BA,EAACC,GAC9B,MAAYC,EAAe,GAuB3B,OArBAD,EAAOE,QAASC,IACd,QAAuB,CACrBC,IAAK,SAAgBD,EAAME,GAAKF,EAAMG,MACtCA,MAAOH,EAAMG,MACbC,KAAMJ,EAAMI,MAEV,UAAiBJ,EAAME,GACzBG,EAAKF,MACHG,EAAAC,cAACC,EAAO,CAACN,GAAIF,EAAME,GAAIO,IAAkB,MAAbT,EAAME,IAC/BF,EAAMG,OAGF,SAAeH,GAAIA,EAAMU,KAClCL,EAAKF,MAAQG,EAAAC,cAAA,IAAA,CAAGG,KAAMV,EAAMU,MAAOV,EAAMG,OAChCH,EAAMW,WACfN,EAAKF,MAAQH,EAAMG,MAClBE,EAAqBM,SAAWf,EAAgBI,EAAMW,UAAY,KAErEb,EAAOc,KAAKP,EAAI,GAIpBP,CAAA,CAEwB,SAAW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EAAKM,SAAWwD,EAAYrD,EAAOd,EAAMW,WAEzCN,EAAK+D,QACH9D,EAACC,cAAAM,EAAY,CAAAG,KAAMF,EAAMC,UAAWsB,QAASvB,EAAMuB,QAASL,QAASlB,EAAMkB,SACxEhC,EAAMoE,SAIbtE,EAAOc,KAAKP,EAAI,GAIpBP,CAAA,CAEA,SAASyE,EAAYzD,mBACnB,MAAMjB,EAASsE,EAAYrD,EAAOA,EAAMjB,QAC5B2E,EAAGC,EAAoB5E,EAAQ,CACzC6E,SAAsB,OAAZ5D,EAAAA,EAAM6D,aAAM,EAAZC,EAAcC,WAGfZ,EAAkBnB,OAAlBgC,EAAGhE,EAAMmD,OAASnB,EAAAA,EAE7B,OACExC,EAACC,cAAAwE,EAAe,CAAAd,MAAOA,GACrB3D,EAACC,cAAAyE,EACC,CAAAC,OAAQ,CACNC,KAAM,CACJC,kBAAYlB,EAAAA,EAAMZ,cAAN+B,EAAa5B,YACzBF,WAAY,OAAF+B,EAAEpB,EAAMZ,YAAN,EAAAgC,EAAa/B,WACzBlB,OAAQ,GAGVkD,OAAQ,CACNnC,UAAW,mBAEb,+DAAgE,CAC9DoC,MAAU,UAAAC,EAAAvB,EAAMZ,cAANmC,EAAazB,yBAEzB,mBAAoB,CAClBwB,MAAU,GAAA,SAAAtB,EAAMZ,YAAN,EAAAoC,EAAa1B,4BAK7BzD,EAAAC,cAACmF,EAAQ,CAACf,OAAQ7D,EAAM6D,OAAQgB,WAAY7E,EAAM6E,YAChDrF,EAACC,cAAAqF,GAAepB,OAAQA,KAIhC"}
@@ -1,2 +1,2 @@
1
- import{DecafApp as e}from"@decafhub/decaf-react";import{Global as t}from"@emotion/react";export{Global as GlobalStyle,css}from"@emotion/react";export{default as styled}from"@emotion/styled";import{Layout as o,Typography as n,Menu as r,theme as l,ConfigProvider as a}from"antd";import c from"react";import{useMatches as i,Link as m,NavLink as s,createBrowserRouter as d,RouterProvider as f,Outlet as u}from"react-router-dom";function p(){return p=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},p.apply(this,arguments)}function b(e){var t=[];return e.forEach(function(e){var o={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e?o.label=c.createElement(s,{to:e.to,end:"/"===e.to},e.label):e.href?o.label=c.createElement("a",{href:e.href},e.label):e.children&&(o.label=e.label,o.children=b(e.children||[])),t.push(o)}),t}function h(e){var t=b(e.menu),l=i().map(function(e){return e.pathname});return c.createElement(o,{style:{height:"100%"}},c.createElement(o.Header,{style:{paddingInline:0}},c.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},c.createElement(m,{to:"/"},c.createElement(n.Title,{level:4,style:{margin:0}},e.appName)),c.createElement(r,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:l}))),c.createElement(o.Content,{style:{padding:"20px 50px"}},e.children))}var y={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,colorError:"#b03a38",colorSuccess:"#48734d",colorWarning:"#ffc107",colorInfo:"#4694ab",green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[l.darkAlgorithm]};function g(e,t){var o=[];return t.forEach(function(t){var n,r=p({},t);t.children?(r.element=null!=(n=t.element)?n:c.createElement(u,null),r.children=g(e,t.children)):r.element=c.createElement(h,{menu:e,appName:"Decaf Webapp"},t.element),o.push(r)}),o}function E(o){var n,r,l,i,m=g(o.menuItems,o.routes),s=d(m,{basename:null==(n=o.config)?void 0:n.basePath}),u=null!=(r=o.theme)?r:y;return c.createElement(a,{theme:u},c.createElement(t,{styles:{body:{background:null==(l=u.token)?void 0:l.colorBgBase,fontFamily:null==(i=u.token)?void 0:i.fontFamily},button:{boxShadow:"none !important"}}}),c.createElement(e,{config:o.config,controller:o.controller},c.createElement(f,{router:s})))}export{E as DecafWebapp};
1
+ import{DecafApp as e}from"@decafhub/decaf-react";import{Global as t}from"@emotion/react";export{Global as GlobalStyle,css}from"@emotion/react";export{default as styled}from"@emotion/styled";import{Layout as o,Typography as n,Menu as r,theme as a,ConfigProvider as l}from"antd";import"antd/dist/reset.css";import i from"react";import{useMatches as c,Link as m,NavLink as d,createBrowserRouter as s,RouterProvider as p,Outlet as u}from"react-router-dom";function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(e[n]=o[n])}return e},f.apply(this,arguments)}function h(e){var t=[];return e.forEach(function(e){var o={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e&&e.to?o.label=i.createElement(d,{to:e.to,end:"/"===e.to},e.label):"href"in e&&e.href?o.label=i.createElement("a",{href:e.href},e.label):e.children&&(o.label=e.label,o.children=h(e.children||[])),t.push(o)}),t}function b(e){var t=h(e.menu),a=c().map(function(e){return e.pathname});return i.createElement(o,{style:{height:"100%"}},i.createElement(o.Header,{style:{paddingInline:0}},i.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},i.createElement(m,{to:"/",style:{display:"flex",alignItems:"center",gap:10}},e.appIcon,i.createElement(n.Title,{level:4,style:{margin:0}},e.appName)),i.createElement(r,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:a}))),i.createElement(o.Content,{style:{padding:"20px 50px"}},e.children))}var y={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[a.darkAlgorithm]};function g(e,t){var o=[];return t.forEach(function(t){var n,r=f({},t);t.children?(r.element=null!=(n=t.element)?n:i.createElement(u,null),r.children=g(e,t.children)):r.element=i.createElement(b,{menu:e.menuItems,appName:e.appName,appIcon:e.appIcon},t.element),o.push(r)}),o}function E(o){var n,r,a,c,m,d,u=g(o,o.routes),f=s(u,{basename:null==(n=o.config)?void 0:n.basePath}),h=null!=(r=o.theme)?r:y;return i.createElement(l,{theme:h},i.createElement(t,{styles:{body:{background:null==(a=h.token)?void 0:a.colorBgBase,fontFamily:null==(c=h.token)?void 0:c.fontFamily,margin:0},button:{boxShadow:"none !important"},".ant-page-header-back-button, .ant-page-header-heading-title":{color:(null==(m=h.token)?void 0:m.colorWhite)+" !important"},".ant-badge-count":{color:(null==(d=h.token)?void 0:d.colorWhite)+" !important"}}}),i.createElement(e,{config:o.config,controller:o.controller},i.createElement(p,{router:f})))}export{E as DecafWebapp,y as decafTheme};
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.module.js","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\nimport { DecafLayoutProps } from 'types';\nimport { DecafMenuItem } from './types';\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if (route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\">\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n {/* <Layout.Footer style={{ textAlign: 'center' }}>Footer</Layout.Footer> */}\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n colorError: '#b03a38',\n colorSuccess: '#48734d',\n colorWarning: '#ffc107',\n colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport DecafLayout from 'Layout';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport { decafTheme } from 'theme';\nimport { DecafMenuItem, DecafRoute, DecafWebappProps } from 'types';\n\nfunction buildRoutes(menuItems: DecafMenuItem[], routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(menuItems, route.children);\n } else {\n item.element = (\n <DecafLayout menu={menuItems} appName=\"Decaf Webapp\">\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props.menuItems, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n },\n button: {\n // antd button has a default box shadow and we can't override it for now\n boxShadow: 'none !important',\n },\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled };\n"],"names":["routesToAntMenu","routes","result","forEach","route","key","to","label","icon","item","React","createElement","NavLink","end","href","children","push","DecafLayout","props","menuItems","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","colorError","colorSuccess","colorWarning","colorInfo","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","_route$element","_extends","element","Outlet","DecafWebapp","_props$config","_props$theme","_theme$token","_theme$token2","router","createBrowserRouter","basename","config","basePath","ConfigProvider","Global","styles","body","background","button","DecafApp","controller","RouterProvider"],"mappings":"4oBAOgBA,SAAAA,EAAgBC,GAC9B,IAAMC,EAAqB,GAuB3B,OArBAD,EAAOE,QAAQ,SAACC,GACd,MAAuB,CACrBC,IAAK,OAAaD,EAAGA,EAAME,GAAKF,EAAMG,MACtCA,MAAOH,EAAMG,MACbC,KAAMJ,EAAMI,MAEV,SACFC,EAAKF,MACHG,EAAAC,cAACC,EAAO,CAACN,GAAIF,EAAME,GAAIO,IAAkB,MAAbT,EAAME,IAC/BF,EAAMG,OAGFH,EAAMU,KACfL,EAAKF,MAAQG,EAAAC,cAAA,IAAA,CAAGG,KAAMV,EAAMU,MAAOV,EAAMG,OAChCH,EAAMW,WACfN,EAAKF,MAAQH,EAAMG,MAClBE,EAAqBM,SAAWf,EAAgBI,EAAMW,UAAY,KAErEb,EAAOc,KAAKP,EACd,IAGF,UAEmCQ,EAACC,GAClC,IAAMC,EAAYnB,EAAgBkB,EAAME,MAElBC,EADNC,IACiBC,IAAI,SAACC,UAAeA,EAACC,QAAQ,GAE9D,OACGf,EAAAC,cAAAe,EAAO,CAAAC,MAAO,CAAEC,OAAQ,SACvBlB,EAACC,cAAAe,EAAOG,OAAO,CAAAF,MAAO,CAAEG,cAAe,IACrCpB,EAAAC,cAAA,MAAA,CAAKgB,MAAO,CAAEG,cAAe,GAAIC,QAAS,OAAQC,eAAgB,gBAAiBC,WAAY,WAC7FvB,EAAAC,cAACuB,EAAI,CAAC5B,GAAG,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EAAZP,EAAcQ,WAEpBhB,EAAmB,OAAXrD,EAAAA,EAAMqD,OAAKS,EAAIhC,EAE7B,OACGtC,EAAAC,cAAA6E,EAAe,CAAAjB,MAAOA,GACrB7D,EAACC,cAAA8E,EACC,CAAAC,OAAQ,CACNC,KAAM,CACJC,WAAY,OAAArB,EAAAA,EAAMhB,YAAN,EAAA0B,EAAavB,YACzBF,WAAY,OAAAe,EAAAA,EAAMhB,YAAN,EAAA2B,EAAa1B,YAE3BqC,OAAQ,CAENxC,UAAW,sBAIjB3C,EAAAC,cAACmF,EAAQ,CAACR,OAAQpE,EAAMoE,OAAQS,WAAY7E,EAAM6E,YAChDrF,EAACC,cAAAqF,GAAeb,OAAQA,KAIhC"}
1
+ {"version":3,"file":"index.module.js","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\n\ninterface BaseDecafMenuItem {\n label: any;\n icon?: React.ReactNode;\n children?: DecafMenuItem[];\n}\n\nexport type DecafMenuItem = BaseDecafMenuItem & ({ to?: string } | { href?: string });\n\nexport interface DecafLayoutProps {\n menu: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n children: React.ReactNode;\n}\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route && route.to) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if ('href' in route && route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\" style={{ display: 'flex', alignItems: 'center', gap: 10 }}>\n {props.appIcon}\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n // colorError: '#b03a38',\n // colorSuccess: '#48734d',\n // colorWarning: '#ffc107',\n // colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp, DecafAppConfig, DecafAppController } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport 'antd/dist/reset.css';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport DecafLayout, { DecafMenuItem } from './Layout';\nimport { decafTheme } from './theme';\n\nexport type DecafRoute = RouteObject;\n\nexport interface DecafWebappProps {\n config?: DecafAppConfig;\n controller?: DecafAppController;\n theme?: ThemeConfig;\n routes: DecafRoute[];\n menuItems: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n}\n\nfunction buildRoutes(props: DecafWebappProps, routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(props, route.children);\n } else {\n item.element = (\n <DecafLayout menu={props.menuItems} appName={props.appName} appIcon={props.appIcon}>\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n margin: 0,\n },\n // antd overrides\n button: {\n boxShadow: 'none !important',\n },\n '.ant-page-header-back-button, .ant-page-header-heading-title': {\n color: `${theme.token?.colorWhite} !important`,\n },\n '.ant-badge-count': {\n color: `${theme.token?.colorWhite} !important`,\n },\n // end antd overrides\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled, decafTheme };\n"],"names":["routesToAntMenu","routes","result","forEach","route","item","key","to","label","icon","React","createElement","NavLink","end","href","children","push","DecafLayout","props","menuItems","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","gap","appIcon","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","_route$element","element","Outlet","_props$config","_props$theme","_theme$token","_theme$token2","_theme$token3","_theme$token4","router","createBrowserRouter","basename","config","basePath","ConfigProvider","Global","styles","body","background","button","color","DecafApp","controller","RouterProvider"],"mappings":"irBAoB+BA,EAACC,GAC9B,IAAYC,EAAe,GAuB3B,OArBAD,EAAOE,QAAQ,SAACC,GACd,IAAUC,EAAa,CACrBC,IAAK,OAAaF,EAAGA,EAAMG,GAAKH,EAAMI,MACtCA,MAAOJ,EAAMI,MACbC,KAAML,EAAMK,MAEV,OAAaL,GAAIA,EAAMG,GACzBF,EAAKG,MACHE,EAAAC,cAACC,EAAO,CAACL,GAAIH,EAAMG,GAAIM,IAAkB,MAAbT,EAAMG,IAC/BH,EAAMI,OAGF,SAAeJ,GAAIA,EAAMU,KAClCT,EAAKG,MAAQE,EAAAC,cAAA,IAAA,CAAGG,KAAMV,EAAMU,MAAOV,EAAMI,OAChCJ,EAAMW,WACfV,EAAKG,MAAQJ,EAAMI,MAClBH,EAAqBU,SAAWf,EAAgBI,EAAMW,UAAY,KAErEb,EAAOc,KAAKX,EACd,GAGFH,CAAA,CAEwB,SAAWe,EAACC,GAClC,IAAeC,EAAGnB,EAAgBkB,EAAME,MAElBC,EADNC,IACiBC,IAAI,SAACC,UAAeA,EAACC,QAAQ,GAE9D,OACEf,EAACC,cAAAe,EAAO,CAAAC,MAAO,CAAEC,OAAQ,SACvBlB,EAACC,cAAAe,EAAOG,OAAO,CAAAF,MAAO,CAAEG,cAAe,IACrCpB,EAAAC,cAAA,MAAA,CAAKgB,MAAO,CAAEG,cAAe,GAAIC,QAAS,OAAQ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EAAYrD,EAAOA,EAAMjB,QAClCgF,EAASC,EAAoBjF,EAAQ,CACzCkF,SAAU,OAAFR,EAAEzD,EAAMkE,aAAN,EAAAT,EAAcU,WAGpBhB,EAAmB,SAAXnD,EAAMmD,OAAKO,EAAI1B,EAE7B,SACGvC,cAAA2E,EAAe,CAAAjB,MAAOA,GACrB3D,EAACC,cAAA4E,EACC,CAAAC,OAAQ,CACNC,KAAM,CACJC,WAAY,OAAFb,EAAER,EAAMZ,YAAN,EAAAoB,EAAajB,YACzBF,WAAuB,SAAXW,EAAMZ,YAAK,EAAXqB,EAAapB,WACzBlB,OAAQ,GAGVmD,OAAQ,CACNpC,UAAW,mBAEb,+DAAgE,CAC9DqC,cAAKb,EAAKV,EAAMZ,cAANsB,EAAaZ,2BAEzB,mBAAoB,CAClByB,cAAKZ,EAAKX,EAAMZ,cAANuB,EAAab,YACxB,kBAILzD,EAAAC,cAACkF,EAAQ,CAACT,OAAQlE,EAAMkE,OAAQU,WAAY5E,EAAM4E,YAChDpF,EAACC,cAAAoF,GAAed,OAAQA,KAIhC"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decafhub/decaf-react"),require("@emotion/react"),require("@emotion/styled"),require("antd"),require("react"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["exports","@decafhub/decaf-react","@emotion/react","@emotion/styled","antd","react","react-router-dom"],t):t((e||self).decafReactWebapp={},e.decafReact,e.react,e.styled,e.antd,e.react,e.reactRouterDom)}(this,function(e,t,n,o,r,a,l){function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=/*#__PURE__*/c(o),u=/*#__PURE__*/c(a);function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},d.apply(this,arguments)}function f(e){var t=[];return e.forEach(function(e){var n={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e?n.label=u.default.createElement(l.NavLink,{to:e.to,end:"/"===e.to},e.label):e.href?n.label=u.default.createElement("a",{href:e.href},e.label):e.children&&(n.label=e.label,n.children=f(e.children||[])),t.push(n)}),t}function s(e){var t=f(e.menu),n=l.useMatches().map(function(e){return e.pathname});return u.default.createElement(r.Layout,{style:{height:"100%"}},u.default.createElement(r.Layout.Header,{style:{paddingInline:0}},u.default.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},u.default.createElement(l.Link,{to:"/"},u.default.createElement(r.Typography.Title,{level:4,style:{margin:0}},e.appName)),u.default.createElement(r.Menu,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:n}))),u.default.createElement(r.Layout.Content,{style:{padding:"20px 50px"}},e.children))}var m={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,colorError:"#b03a38",colorSuccess:"#48734d",colorWarning:"#ffc107",colorInfo:"#4694ab",green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[r.theme.darkAlgorithm]};function b(e,t){var n=[];return t.forEach(function(t){var o,r=d({},t);t.children?(r.element=null!=(o=t.element)?o:u.default.createElement(l.Outlet,null),r.children=b(e,t.children)):r.element=u.default.createElement(s,{menu:e,appName:"Decaf Webapp"},t.element),n.push(r)}),n}Object.defineProperty(e,"GlobalStyle",{enumerable:!0,get:function(){return n.Global}}),Object.defineProperty(e,"css",{enumerable:!0,get:function(){return n.css}}),Object.defineProperty(e,"styled",{enumerable:!0,get:function(){return i.default}}),e.DecafWebapp=function(e){var o,a,c,i,d=b(e.menuItems,e.routes),f=l.createBrowserRouter(d,{basename:null==(o=e.config)?void 0:o.basePath}),s=null!=(a=e.theme)?a:m;return u.default.createElement(r.ConfigProvider,{theme:s},u.default.createElement(n.Global,{styles:{body:{background:null==(c=s.token)?void 0:c.colorBgBase,fontFamily:null==(i=s.token)?void 0:i.fontFamily},button:{boxShadow:"none !important"}}}),u.default.createElement(t.DecafApp,{config:e.config,controller:e.controller},u.default.createElement(l.RouterProvider,{router:f})))}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decafhub/decaf-react"),require("@emotion/react"),require("@emotion/styled"),require("antd"),require("antd/dist/reset.css"),require("react"),require("react-router-dom")):"function"==typeof define&&define.amd?define(["exports","@decafhub/decaf-react","@emotion/react","@emotion/styled","antd","antd/dist/reset.css","react","react-router-dom"],t):t((e||self).decafReactWebapp={},e.decafReact,e.react,e.styled,e.antd,0,e.react,e.reactRouterDom)}(this,function(e,t,n,a,o,r,l,i){function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=/*#__PURE__*/c(a),u=/*#__PURE__*/c(l);function f(){return f=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},f.apply(this,arguments)}function s(e){var t=[];return e.forEach(function(e){var n={key:"to"in e?e.to:e.label,label:e.label,icon:e.icon};"to"in e&&e.to?n.label=u.default.createElement(i.NavLink,{to:e.to,end:"/"===e.to},e.label):"href"in e&&e.href?n.label=u.default.createElement("a",{href:e.href},e.label):e.children&&(n.label=e.label,n.children=s(e.children||[])),t.push(n)}),t}function m(e){var t=s(e.menu),n=i.useMatches().map(function(e){return e.pathname});return u.default.createElement(o.Layout,{style:{height:"100%"}},u.default.createElement(o.Layout.Header,{style:{paddingInline:0}},u.default.createElement("div",{style:{paddingInline:20,display:"flex",justifyContent:"space-between",alignItems:"center"}},u.default.createElement(i.Link,{to:"/",style:{display:"flex",alignItems:"center",gap:10}},e.appIcon,u.default.createElement(o.Typography.Title,{level:4,style:{margin:0}},e.appName)),u.default.createElement(o.Menu,{style:{justifyContent:"flex-end",backgroundColor:"transparent",border:"none"},mode:"horizontal",items:t,selectedKeys:n}))),u.default.createElement(o.Layout.Content,{style:{padding:"20px 50px"}},e.children))}var p={hashed:!0,components:{Layout:{colorBgHeader:"#10161d"},Button:{boxShadow:"none",boxShadowSecondary:"none"}},token:{fontFamily:'"Inter",system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans","Liberation Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"',colorPrimary:"#344961",colorBgBase:"#1a242f",colorBgLayout:"#1a242f",borderRadius:0,green:"#48734d",red:"#b03a38",blue:"#0d6efd",yellow:"#ffc107",colorWhite:"#fff"},algorithm:[o.theme.darkAlgorithm]};function b(e,t){var n=[];return t.forEach(function(t){var a,o=f({},t);t.children?(o.element=null!=(a=t.element)?a:u.default.createElement(i.Outlet,null),o.children=b(e,t.children)):o.element=u.default.createElement(m,{menu:e.menuItems,appName:e.appName,appIcon:e.appIcon},t.element),n.push(o)}),n}Object.defineProperty(e,"GlobalStyle",{enumerable:!0,get:function(){return n.Global}}),Object.defineProperty(e,"css",{enumerable:!0,get:function(){return n.css}}),Object.defineProperty(e,"styled",{enumerable:!0,get:function(){return d.default}}),e.DecafWebapp=function(e){var a,r,l,c,d,f,s=b(e,e.routes),m=i.createBrowserRouter(s,{basename:null==(a=e.config)?void 0:a.basePath}),h=null!=(r=e.theme)?r:p;return u.default.createElement(o.ConfigProvider,{theme:h},u.default.createElement(n.Global,{styles:{body:{background:null==(l=h.token)?void 0:l.colorBgBase,fontFamily:null==(c=h.token)?void 0:c.fontFamily,margin:0},button:{boxShadow:"none !important"},".ant-page-header-back-button, .ant-page-header-heading-title":{color:(null==(d=h.token)?void 0:d.colorWhite)+" !important"},".ant-badge-count":{color:(null==(f=h.token)?void 0:f.colorWhite)+" !important"}}}),u.default.createElement(t.DecafApp,{config:e.config,controller:e.controller},u.default.createElement(i.RouterProvider,{router:m})))},e.decafTheme=p});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\nimport { DecafLayoutProps } from 'types';\nimport { DecafMenuItem } from './types';\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if (route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\">\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n {/* <Layout.Footer style={{ textAlign: 'center' }}>Footer</Layout.Footer> */}\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n colorError: '#b03a38',\n colorSuccess: '#48734d',\n colorWarning: '#ffc107',\n colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport DecafLayout from 'Layout';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport { decafTheme } from 'theme';\nimport { DecafMenuItem, DecafRoute, DecafWebappProps } from 'types';\n\nfunction buildRoutes(menuItems: DecafMenuItem[], routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(menuItems, route.children);\n } else {\n item.element = (\n <DecafLayout menu={menuItems} appName=\"Decaf Webapp\">\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props.menuItems, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n },\n button: {\n // antd button has a default box shadow and we can't override it for now\n boxShadow: 'none !important',\n },\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled };\n"],"names":["routesToAntMenu","routes","result","forEach","route","key","to","label","icon","item","React","createElement","NavLink","end","href","children","push","DecafLayout","props","menuItems","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","colorError","colorSuccess","colorWarning","colorInfo","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","_route$element","_extends","element","Outlet","_props$config","_props$theme","_theme$token","_theme$token2","router","createBrowserRouter","basename","config","basePath","ConfigProvider","Global","styles","body","background","button","DecafApp","controller","RouterProvider"],"mappings":"43BAOgBA,SAAAA,EAAgBC,GAC9B,IAAMC,EAAqB,GAuB3B,OArBAD,EAAOE,QAAQ,SAACC,GACd,MAAuB,CACrBC,IAAK,OAAaD,EAAGA,EAAME,GAAKF,EAAMG,MACtCA,MAAOH,EAAMG,MACbC,KAAMJ,EAAMI,MAEV,SACFC,EAAKF,MACHG,EAAAA,QAAAC,cAACC,UAAO,CAACN,GAAIF,EAAME,GAAIO,IAAkB,MAAbT,EAAME,IAC/BF,EAAMG,OAGFH,EAAMU,KACfL,EAAKF,MAAQG,UAAAC,cAAA,IAAA,CAAGG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AKA,MAACC,gBCtBpB,SAAoBC,EAACtD,EAA4BlB,GAC/C,IAAMC,EAAwB,GAiB9B,OAfAD,EAAOE,QAAQ,SAACC,GACd,IACoBsE,EADVjE,EAAAkE,EAAA,CAAA,EAAqBvE,GAC3BA,EAAMW,UACRN,EAAKmE,QAA2BlE,OAAjBN,EAAAA,EAAMwE,SAAWlE,EAAAA,EAAAA,QAAAC,cAACkE,EAAAA,OAAM,MACvCpE,EAAKM,SAAW0D,EAAYtD,EAAWf,EAAMW,WAE7CN,EAAKmE,QACHlE,EAAAA,sBAACO,EAAW,CAACG,KAAMD,EAAWoB,QAAQ,gBACnCnC,EAAMwE,SAIb1E,EAAOc,KAAKP,EACd,GAGFP,CAAA,qQAEA,SAAqBgB,GAAuB,IAAA4D,EAAAC,EAAAC,EAAAC,EAC9BhF,EAAGwE,EAAYvD,EAAMC,UAAWD,EAAMjB,QAC5CiF,EAASC,EAAmBA,oBAAClF,EAAQ,CACzCmF,SAAsB,SAAZlE,EAAMmE,aAAM,EAAZP,EAAcQ,WAEpBf,EAAmB,OAAXrD,EAAAA,EAAMqD,OAAKQ,EAAI/B,EAE7B,OACGtC,EAAAA,QAAAC,cAAA4E,EAAcA,eAAC,CAAAhB,MAAOA,GACrB7D,EAAC,QAAAC,cAAA6E,EAAMA,OACL,CAAAC,OAAQ,CACNC,KAAM,CACJC,WAAY,OAAApB,EAAAA,EAAMhB,YAAN,EAAAyB,EAAatB,YACzBF,WAAY,OAAAe,EAAAA,EAAMhB,YAAN,EAAA0B,EAAazB,YAE3BoC,OAAQ,CAENvC,UAAW,sBAIjB3C,EAAAA,QAAAC,cAACkF,EAAQA,SAAA,CAACR,OAAQnE,EAAMmE,OAAQS,WAAY5E,EAAM4E,YAChDpF,EAAC,QAAAC,cAAAoF,EAAAA,gBAAeb,OAAQA,KAIhC"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/Layout.tsx","../src/theme.ts","../src/index.tsx"],"sourcesContent":["import { Layout, Menu, Typography } from 'antd';\nimport { ItemType, SubMenuType } from 'antd/es/menu/hooks/useItems';\nimport React from 'react';\nimport { Link, NavLink, useMatches } from 'react-router-dom';\n\ninterface BaseDecafMenuItem {\n label: any;\n icon?: React.ReactNode;\n children?: DecafMenuItem[];\n}\n\nexport type DecafMenuItem = BaseDecafMenuItem & ({ to?: string } | { href?: string });\n\nexport interface DecafLayoutProps {\n menu: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n children: React.ReactNode;\n}\n\nexport function routesToAntMenu(routes: DecafMenuItem[]): ItemType[] {\n const result: ItemType[] = [];\n\n routes.forEach((route) => {\n const item: ItemType = {\n key: 'to' in route ? route.to : route.label,\n label: route.label,\n icon: route.icon,\n };\n if ('to' in route && route.to) {\n item.label = (\n <NavLink to={route.to} end={route.to === '/'}>\n {route.label}\n </NavLink>\n );\n } else if ('href' in route && route.href) {\n item.label = <a href={route.href}>{route.label}</a>;\n } else if (route.children) {\n item.label = route.label;\n (item as SubMenuType).children = routesToAntMenu(route.children || []);\n }\n result.push(item);\n });\n\n return result;\n}\n\nexport default function DecafLayout(props: DecafLayoutProps) {\n const menuItems = routesToAntMenu(props.menu);\n const matches = useMatches();\n const matchedMenuItems = matches.map((match) => match.pathname);\n\n return (\n <Layout style={{ height: '100%' }}>\n <Layout.Header style={{ paddingInline: 0 }}>\n <div style={{ paddingInline: 20, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>\n <Link to=\"/\" style={{ display: 'flex', alignItems: 'center', gap: 10 }}>\n {props.appIcon}\n <Typography.Title level={4} style={{ margin: 0 }}>\n {props.appName}\n </Typography.Title>\n </Link>\n <Menu\n style={{ justifyContent: 'flex-end', backgroundColor: 'transparent', border: 'none' }}\n mode=\"horizontal\"\n items={menuItems}\n selectedKeys={matchedMenuItems}\n />\n </div>\n </Layout.Header>\n <Layout.Content style={{ padding: '20px 50px' }}>{props.children}</Layout.Content>\n </Layout>\n );\n}\n","import { theme } from 'antd';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\n\nexport const decafTheme: ThemeConfig = {\n hashed: true,\n components: {\n Layout: {\n colorBgHeader: '#10161d',\n },\n Button: {\n boxShadow: 'none',\n boxShadowSecondary: 'none',\n },\n },\n token: {\n fontFamily:\n '\"Inter\",system-ui,-apple-system,\"Segoe UI\",Roboto,\"Helvetica Neue\",Arial,\"Noto Sans\",\"Liberation Sans\",sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Noto Color Emoji\"',\n colorPrimary: '#344961',\n colorBgBase: '#1a242f',\n colorBgLayout: '#1a242f',\n borderRadius: 0,\n // colorError: '#b03a38',\n // colorSuccess: '#48734d',\n // colorWarning: '#ffc107',\n // colorInfo: '#4694ab',\n green: '#48734d',\n red: '#b03a38',\n blue: '#0d6efd',\n yellow: '#ffc107',\n colorWhite: '#fff',\n },\n\n algorithm: [theme.darkAlgorithm],\n};\n","import { DecafApp, DecafAppConfig, DecafAppController } from '@decafhub/decaf-react';\nimport { css, Global } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport { ConfigProvider } from 'antd';\nimport 'antd/dist/reset.css';\nimport { ThemeConfig } from 'antd/es/config-provider/context';\nimport React from 'react';\nimport { createBrowserRouter, Outlet, RouteObject, RouterProvider } from 'react-router-dom';\nimport DecafLayout, { DecafMenuItem } from './Layout';\nimport { decafTheme } from './theme';\n\nexport type DecafRoute = RouteObject;\n\nexport interface DecafWebappProps {\n config?: DecafAppConfig;\n controller?: DecafAppController;\n theme?: ThemeConfig;\n routes: DecafRoute[];\n menuItems: DecafMenuItem[];\n appName: string;\n appIcon?: React.ReactNode;\n}\n\nfunction buildRoutes(props: DecafWebappProps, routes: DecafRoute[]): RouteObject[] {\n const result: RouteObject[] = [];\n\n routes.forEach((route) => {\n const item: RouteObject = { ...route };\n if (route.children) {\n item.element = route.element ?? <Outlet />;\n item.children = buildRoutes(props, route.children);\n } else {\n item.element = (\n <DecafLayout menu={props.menuItems} appName={props.appName} appIcon={props.appIcon}>\n {route.element}\n </DecafLayout>\n );\n }\n result.push(item);\n });\n\n return result;\n}\n\nfunction DecafWebapp(props: DecafWebappProps) {\n const routes = buildRoutes(props, props.routes);\n const router = createBrowserRouter(routes, {\n basename: props.config?.basePath,\n });\n\n const theme = props.theme ?? decafTheme;\n\n return (\n <ConfigProvider theme={theme}>\n <Global\n styles={{\n body: {\n background: theme.token?.colorBgBase,\n fontFamily: theme.token?.fontFamily,\n margin: 0,\n },\n // antd overrides\n button: {\n boxShadow: 'none !important',\n },\n '.ant-page-header-back-button, .ant-page-header-heading-title': {\n color: `${theme.token?.colorWhite} !important`,\n },\n '.ant-badge-count': {\n color: `${theme.token?.colorWhite} !important`,\n },\n // end antd overrides\n }}\n />\n <DecafApp config={props.config} controller={props.controller}>\n <RouterProvider router={router} />\n </DecafApp>\n </ConfigProvider>\n );\n}\n\nexport { DecafWebapp, Global as GlobalStyle, css, styled, decafTheme };\n"],"names":["routesToAntMenu","routes","result","forEach","route","item","key","to","label","icon","React","createElement","NavLink","end","href","children","push","DecafLayout","props","menuItems","menu","matchedMenuItems","useMatches","map","match","pathname","Layout","style","height","Header","paddingInline","display","justifyContent","alignItems","Link","gap","appIcon","Typography","Title","level","margin","appName","Menu","backgroundColor","border","mode","items","selectedKeys","Content","padding","decafTheme","hashed","components","colorBgHeader","Button","boxShadow","boxShadowSecondary","token","fontFamily","colorPrimary","colorBgBase","colorBgLayout","borderRadius","green","red","blue","yellow","colorWhite","algorithm","theme","darkAlgorithm","buildRoutes","_route$element","element","Outlet","_props$config","_props$theme","_theme$token","_theme$token2","_theme$token3","_theme$token4","router","createBrowserRouter","basename","config","basePath","ConfigProvider","Global","styles","body","background","button","color","DecafApp","controller","RouterProvider"],"mappings":"87BAoB+BA,EAACC,GAC9B,IAAYC,EAAe,GAuB3B,OArBAD,EAAOE,QAAQ,SAACC,GACd,IAAUC,EAAa,CACrBC,IAAK,OAAaF,EAAGA,EAAMG,GAAKH,EAAMI,MACtCA,MAAOJ,EAAMI,MACbC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AgE,CAC9DqC,cAAKb,EAAKV,EAAMZ,cAANsB,EAAaZ,2BAEzB,mBAAoB,CAClByB,cAAKZ,EAAKX,EAAMZ,cAANuB,EAAab,YACxB,kBAILzD,UAAAC,cAACkF,EAAQA,SAAA,CAACT,OAAQlE,EAAMkE,OAAQU,WAAY5E,EAAM4E,YAChDpF,UAACC,cAAAoF,EAAcA,gBAACd,OAAQA,KAIhC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decafhub/decaf-react-webapp",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "keywords": [
5
5
  "decafhub",
6
6
  "react"
package/dist/types.d.ts DELETED
@@ -1,31 +0,0 @@
1
- /// <reference types="react" />
2
- import { DecafAppConfig, DecafAppController } from '@decafhub/decaf-react';
3
- import { ThemeConfig } from 'antd/es/config-provider/context';
4
- import { RouteObject } from 'react-router-dom';
5
- export type DecafRoute = RouteObject;
6
- export interface DecafWebappProps {
7
- config?: DecafAppConfig;
8
- controller?: DecafAppController;
9
- theme?: ThemeConfig;
10
- routes: DecafRoute[];
11
- menuItems: DecafMenuItem[];
12
- appName: string;
13
- }
14
- interface BaseDecafMenuItem {
15
- label: any;
16
- key: string;
17
- icon?: React.ReactNode;
18
- children?: DecafMenuItem[];
19
- }
20
- export type DecafMenuItem = BaseDecafMenuItem & ({
21
- to: string;
22
- } | {
23
- href: string;
24
- });
25
- export interface DecafLayoutProps {
26
- menu: DecafMenuItem[];
27
- appName: string;
28
- children: React.ReactNode;
29
- }
30
- export {};
31
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AAErC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,iBAAiB;IACzB,KAAK,EAAE,GAAG,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEpF,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}