@j2inn/fin5-ui-utils 3.0.7-beta.0 → 4.0.0

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.
Files changed (202) hide show
  1. package/README.md +5 -5
  2. package/dist/fantomProps/createFin5Props/index.d.ts +12 -12
  3. package/dist/fantomProps/createFin5Props/index.js +146 -146
  4. package/dist/fantomProps/createFin5Props/runCreateFin5Props.d.ts +2 -2
  5. package/dist/fantomProps/createFin5Props/runCreateFin5Props.js +16 -16
  6. package/dist/fantomProps/fantomPropsToObject.d.ts +8 -8
  7. package/dist/fantomProps/fantomPropsToObject.js +183 -183
  8. package/dist/fantomProps/generateJsonFromFantomPropsFile.d.ts +4 -4
  9. package/dist/fantomProps/generateJsonFromFantomPropsFile.js +41 -41
  10. package/dist/fantomProps/localePropsToJson.d.ts +1 -1
  11. package/dist/fantomProps/localePropsToJson.js +50 -50
  12. package/dist/fantomProps/readFantomPropsFile.d.ts +5 -5
  13. package/dist/fantomProps/readFantomPropsFile.js +61 -61
  14. package/dist/fin5Top/fin5FileUpload.d.ts +24 -24
  15. package/dist/fin5Top/fin5FileUpload.js +51 -51
  16. package/dist/fin5Top/fin5Top.d.ts +115 -115
  17. package/dist/fin5Top/fin5Top.js +58 -58
  18. package/dist/fin5Top/finEdge2Cloud.d.ts +6 -6
  19. package/dist/fin5Top/finEdge2Cloud.js +15 -15
  20. package/dist/fin5Top/getFin5BinUrl.d.ts +2 -2
  21. package/dist/fin5Top/getFin5BinUrl.js +9 -9
  22. package/dist/fin5Top/openFin5Alarm.d.ts +22 -22
  23. package/dist/fin5Top/openFin5Alarm.js +23 -23
  24. package/dist/fin5Top/openFin5Historian.d.ts +3 -3
  25. package/dist/fin5Top/openFin5Historian.js +19 -19
  26. package/dist/fin5Top/useFin5AppURLHashParameter.d.ts +18 -18
  27. package/dist/fin5Top/useFin5AppURLHashParameter.js +128 -128
  28. package/dist/index.d.ts +30 -30
  29. package/dist/index.js +64 -64
  30. package/dist/jobs/jobUtils.d.ts +14 -14
  31. package/dist/jobs/jobUtils.js +15 -15
  32. package/dist/react/app/Fin5AppContainer.d.ts +36 -36
  33. package/dist/react/app/Fin5AppContainer.js +102 -102
  34. package/dist/react/app/Fin5AppRootStore.d.ts +39 -39
  35. package/dist/react/app/Fin5AppRootStore.js +69 -69
  36. package/dist/react/components/ErrorBoundary.d.ts +57 -57
  37. package/dist/react/components/ErrorBoundary.js +150 -150
  38. package/dist/react/components/ErrorDisplayer.d.ts +19 -19
  39. package/dist/react/components/ErrorDisplayer.js +36 -36
  40. package/dist/react/components/Loader.d.ts +9 -9
  41. package/dist/react/components/Loader.js +17 -17
  42. package/dist/react/components/LoadingSpinner.d.ts +2 -2
  43. package/dist/react/components/LoadingSpinner.js +27 -27
  44. package/dist/react/components/RecordImage.d.ts +20 -20
  45. package/dist/react/components/RecordImage.js +51 -51
  46. package/dist/react/components/charts/QRCode.d.ts +25 -25
  47. package/dist/react/components/charts/QRCode.js +81 -81
  48. package/dist/react/components/charts/pie/PieChart.d.ts +93 -93
  49. package/dist/react/components/charts/pie/PieChart.js +202 -202
  50. package/dist/react/components/charts/pie/SimplePieChart.d.ts +20 -20
  51. package/dist/react/components/charts/pie/SimplePieChart.js +55 -55
  52. package/dist/react/components/graphics/GraphicViewer.d.ts +10 -10
  53. package/dist/react/components/graphics/GraphicViewer.js +29 -29
  54. package/dist/react/components/graphics/GraphicsTabViewer.d.ts +17 -17
  55. package/dist/react/components/graphics/GraphicsTabViewer.js +90 -90
  56. package/dist/react/components/navigation/BasicLayout.d.ts +41 -41
  57. package/dist/react/components/navigation/BasicLayout.js +155 -155
  58. package/dist/react/components/navigation/HeaderSiderLayout.d.ts +13 -13
  59. package/dist/react/components/navigation/HeaderSiderLayout.js +110 -110
  60. package/dist/react/components/navigation/MenuPage.d.ts +37 -37
  61. package/dist/react/components/navigation/MenuPage.js +36 -36
  62. package/dist/react/components/navigation/MenuTrigger.d.ts +9 -9
  63. package/dist/react/components/navigation/MenuTrigger.js +33 -33
  64. package/dist/react/components/navigation/ReactRouterHeaderSiderLayout.d.ts +11 -11
  65. package/dist/react/components/navigation/ReactRouterHeaderSiderLayout.js +25 -25
  66. package/dist/react/components/navigation/ReactRouterLayout.d.ts +35 -35
  67. package/dist/react/components/navigation/ReactRouterLayout.js +113 -117
  68. package/dist/react/components/navigation/ReactRouterLayout.js.map +1 -1
  69. package/dist/react/components/navigation/customRouting/Router.d.ts +12 -12
  70. package/dist/react/components/navigation/customRouting/Router.js +45 -45
  71. package/dist/react/components/navigation/customRouting/RouterLayout.d.ts +11 -11
  72. package/dist/react/components/navigation/customRouting/RouterLayout.js +61 -61
  73. package/dist/react/components/resolvable/configurationForm/ConfigurationForm.d.ts +27 -27
  74. package/dist/react/components/resolvable/configurationForm/ConfigurationForm.js +95 -95
  75. package/dist/react/components/resolvable/configurationForm/ConfigurationFormEntry.d.ts +16 -16
  76. package/dist/react/components/resolvable/configurationForm/ConfigurationFormEntry.js +88 -88
  77. package/dist/react/components/resolvable/configurationForm/getSectionDefault.d.ts +16 -16
  78. package/dist/react/components/resolvable/configurationForm/getSectionDefault.js +99 -99
  79. package/dist/react/hooks/useFin5BinUrl.d.ts +6 -6
  80. package/dist/react/hooks/useFin5BinUrl.js +15 -15
  81. package/dist_es/fantomProps/createFin5Props/index.d.ts +12 -12
  82. package/dist_es/fantomProps/createFin5Props/index.js +140 -140
  83. package/dist_es/fantomProps/createFin5Props/index.js.map +0 -0
  84. package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.d.ts +2 -2
  85. package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.js +11 -11
  86. package/dist_es/fantomProps/createFin5Props/runCreateFin5Props.js.map +0 -0
  87. package/dist_es/fantomProps/fantomPropsToObject.d.ts +8 -8
  88. package/dist_es/fantomProps/fantomPropsToObject.js +178 -178
  89. package/dist_es/fantomProps/fantomPropsToObject.js.map +0 -0
  90. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.d.ts +4 -4
  91. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js +12 -12
  92. package/dist_es/fantomProps/generateJsonFromFantomPropsFile.js.map +0 -0
  93. package/dist_es/fantomProps/localePropsToJson.d.ts +1 -1
  94. package/dist_es/fantomProps/localePropsToJson.js +21 -21
  95. package/dist_es/fantomProps/localePropsToJson.js.map +0 -0
  96. package/dist_es/fantomProps/readFantomPropsFile.d.ts +5 -5
  97. package/dist_es/fantomProps/readFantomPropsFile.js +35 -35
  98. package/dist_es/fantomProps/readFantomPropsFile.js.map +0 -0
  99. package/dist_es/fin5Top/fin5FileUpload.d.ts +24 -24
  100. package/dist_es/fin5Top/fin5FileUpload.js +47 -47
  101. package/dist_es/fin5Top/fin5Top.d.ts +115 -115
  102. package/dist_es/fin5Top/fin5Top.js +54 -54
  103. package/dist_es/fin5Top/fin5Top.js.map +0 -0
  104. package/dist_es/fin5Top/finEdge2Cloud.d.ts +6 -6
  105. package/dist_es/fin5Top/finEdge2Cloud.js +11 -11
  106. package/dist_es/fin5Top/getFin5BinUrl.d.ts +2 -2
  107. package/dist_es/fin5Top/getFin5BinUrl.js +5 -5
  108. package/dist_es/fin5Top/getFin5BinUrl.js.map +0 -0
  109. package/dist_es/fin5Top/openFin5Alarm.d.ts +22 -22
  110. package/dist_es/fin5Top/openFin5Alarm.js +19 -19
  111. package/dist_es/fin5Top/openFin5Alarm.js.map +0 -0
  112. package/dist_es/fin5Top/openFin5Historian.d.ts +3 -3
  113. package/dist_es/fin5Top/openFin5Historian.js +15 -15
  114. package/dist_es/fin5Top/openFin5Historian.js.map +0 -0
  115. package/dist_es/fin5Top/useFin5AppURLHashParameter.d.ts +18 -18
  116. package/dist_es/fin5Top/useFin5AppURLHashParameter.js +119 -119
  117. package/dist_es/fin5Top/useFin5AppURLHashParameter.js.map +0 -0
  118. package/dist_es/index.d.ts +30 -30
  119. package/dist_es/index.js +48 -48
  120. package/dist_es/index.js.map +0 -0
  121. package/dist_es/jobs/jobUtils.d.ts +14 -14
  122. package/dist_es/jobs/jobUtils.js +9 -9
  123. package/dist_es/react/app/Fin5AppContainer.d.ts +36 -36
  124. package/dist_es/react/app/Fin5AppContainer.js +73 -73
  125. package/dist_es/react/app/Fin5AppContainer.jsx +0 -0
  126. package/dist_es/react/app/Fin5AppContainer.jsx.map +0 -0
  127. package/dist_es/react/app/Fin5AppRootStore.d.ts +39 -39
  128. package/dist_es/react/app/Fin5AppRootStore.js +65 -65
  129. package/dist_es/react/app/Fin5AppRootStore.js.map +0 -0
  130. package/dist_es/react/components/ErrorBoundary.d.ts +57 -57
  131. package/dist_es/react/components/ErrorBoundary.js +123 -123
  132. package/dist_es/react/components/ErrorBoundary.jsx +0 -0
  133. package/dist_es/react/components/ErrorBoundary.jsx.map +0 -0
  134. package/dist_es/react/components/ErrorDisplayer.d.ts +19 -19
  135. package/dist_es/react/components/ErrorDisplayer.js +28 -28
  136. package/dist_es/react/components/ErrorDisplayer.jsx +0 -0
  137. package/dist_es/react/components/ErrorDisplayer.jsx.map +0 -0
  138. package/dist_es/react/components/Loader.d.ts +9 -9
  139. package/dist_es/react/components/Loader.js +12 -12
  140. package/dist_es/react/components/Loader.jsx +1 -1
  141. package/dist_es/react/components/Loader.jsx.map +1 -1
  142. package/dist_es/react/components/LoadingSpinner.d.ts +2 -2
  143. package/dist_es/react/components/LoadingSpinner.js +20 -20
  144. package/dist_es/react/components/LoadingSpinner.jsx +4 -3
  145. package/dist_es/react/components/LoadingSpinner.jsx.map +1 -1
  146. package/dist_es/react/components/RecordImage.d.ts +20 -20
  147. package/dist_es/react/components/RecordImage.js +24 -24
  148. package/dist_es/react/components/charts/QRCode.d.ts +25 -25
  149. package/dist_es/react/components/charts/QRCode.js +53 -53
  150. package/dist_es/react/components/charts/pie/PieChart.d.ts +93 -93
  151. package/dist_es/react/components/charts/pie/PieChart.js +175 -175
  152. package/dist_es/react/components/charts/pie/SimplePieChart.d.ts +20 -20
  153. package/dist_es/react/components/charts/pie/SimplePieChart.js +25 -25
  154. package/dist_es/react/components/graphics/GraphicViewer.d.ts +10 -10
  155. package/dist_es/react/components/graphics/GraphicViewer.js +22 -22
  156. package/dist_es/react/components/graphics/GraphicsTabViewer.d.ts +17 -17
  157. package/dist_es/react/components/graphics/GraphicsTabViewer.js +60 -60
  158. package/dist_es/react/components/navigation/BasicLayout.d.ts +41 -41
  159. package/dist_es/react/components/navigation/BasicLayout.js +124 -124
  160. package/dist_es/react/components/navigation/BasicLayout.jsx +7 -35
  161. package/dist_es/react/components/navigation/BasicLayout.jsx.map +1 -1
  162. package/dist_es/react/components/navigation/HeaderSiderLayout.d.ts +13 -13
  163. package/dist_es/react/components/navigation/HeaderSiderLayout.js +80 -80
  164. package/dist_es/react/components/navigation/MenuPage.d.ts +37 -37
  165. package/dist_es/react/components/navigation/MenuPage.js +30 -30
  166. package/dist_es/react/components/navigation/MenuPage.jsx +0 -0
  167. package/dist_es/react/components/navigation/MenuPage.jsx.map +1 -1
  168. package/dist_es/react/components/navigation/MenuTrigger.d.ts +9 -9
  169. package/dist_es/react/components/navigation/MenuTrigger.js +28 -28
  170. package/dist_es/react/components/navigation/ReactRouterHeaderSiderLayout.d.ts +11 -11
  171. package/dist_es/react/components/navigation/ReactRouterHeaderSiderLayout.js +18 -18
  172. package/dist_es/react/components/navigation/ReactRouterLayout.d.ts +35 -35
  173. package/dist_es/react/components/navigation/ReactRouterLayout.js +81 -85
  174. package/dist_es/react/components/navigation/ReactRouterLayout.js.map +1 -1
  175. package/dist_es/react/components/navigation/Router.d.ts +0 -0
  176. package/dist_es/react/components/navigation/Router.jsx +1 -1
  177. package/dist_es/react/components/navigation/Router.jsx.map +1 -1
  178. package/dist_es/react/components/navigation/customRouting/Router.d.ts +12 -12
  179. package/dist_es/react/components/navigation/customRouting/Router.js +18 -18
  180. package/dist_es/react/components/navigation/customRouting/RouterLayout.d.ts +11 -11
  181. package/dist_es/react/components/navigation/customRouting/RouterLayout.js +34 -34
  182. package/dist_es/react/components/resolvable/configurationForm/ConfigurationForm.d.ts +27 -27
  183. package/dist_es/react/components/resolvable/configurationForm/ConfigurationForm.js +64 -64
  184. package/dist_es/react/components/resolvable/configurationForm/ConfigurationFormEntry.d.ts +16 -16
  185. package/dist_es/react/components/resolvable/configurationForm/ConfigurationFormEntry.js +58 -58
  186. package/dist_es/react/components/resolvable/configurationForm/getSectionDefault.d.ts +16 -16
  187. package/dist_es/react/components/resolvable/configurationForm/getSectionDefault.js +94 -94
  188. package/dist_es/react/hooks/useFin5BinUrl.d.ts +6 -6
  189. package/dist_es/react/hooks/useFin5BinUrl.js +11 -11
  190. package/package.json +13 -13
  191. package/dist_es/react/components/graphics/GraphicViewer.jsx +0 -23
  192. package/dist_es/react/components/graphics/GraphicViewer.jsx.map +0 -1
  193. package/dist_es/react/components/graphics/GraphicsTabViewer.jsx +0 -63
  194. package/dist_es/react/components/graphics/GraphicsTabViewer.jsx.map +0 -1
  195. package/dist_es/react/components/navigation/Router.js +0 -19
  196. package/dist_es/react/components/navigation/Router.js.map +0 -1
  197. package/dist_es/react/components/navigation/react-router/BasicLayout.d.ts +0 -23
  198. package/dist_es/react/components/navigation/react-router/BasicLayout.js +0 -82
  199. package/dist_es/react/components/navigation/react-router/BasicLayout.js.map +0 -1
  200. package/dist_es/react/components/navigation/react-router/ReactRouterBasicLayout.d.ts +0 -24
  201. package/dist_es/react/components/navigation/react-router/ReactRouterBasicLayout.js +0 -82
  202. package/dist_es/react/components/navigation/react-router/ReactRouterBasicLayout.js.map +0 -1
@@ -4,7 +4,7 @@
4
4
  import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
5
5
  import { Button, Layout, Menu } from '@j2inn/ui';
6
6
  import classNames from 'classnames';
7
- import React, { useEffect, useMemo, useState } from 'react';
7
+ import React, { useEffect, useState } from 'react';
8
8
  import { createUseStyles } from 'react-jss';
9
9
  import { ErrorDisplayer } from '../ErrorDisplayer';
10
10
  import { findPageByName } from './MenuPage';
@@ -53,38 +53,11 @@ const useStyles = createUseStyles((theme) => {
53
53
  const Header = Layout.Header;
54
54
  const Sider = Layout.Sider;
55
55
  const Content = Layout.Content;
56
- /**
57
- * Copy the array and recursively remove pages having the `showInMenu` flag set to false.
58
- * @param pages
59
- * @returns
60
- */
61
- const getMenuPages = (pages) => {
62
- const menuPages = [];
63
- pages.forEach((page) => {
64
- const show = page.showInMenu == null || page.showInMenu;
65
- if (show) {
66
- const copiedPage = Object.assign({}, page);
67
- if (copiedPage.children) {
68
- const filteredChildren = getMenuPages(copiedPage.children);
69
- copiedPage.children = filteredChildren.length
70
- ? filteredChildren
71
- : undefined;
72
- }
73
- menuPages.push(copiedPage);
74
- }
75
- });
76
- return menuPages;
77
- };
78
56
  /**
79
57
  * Basic layout that combines menu and routing into one.
80
58
  */
81
- export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageChange, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, page, }) => {
82
- const [currentPage, setCurrentPage] = useState(page ?? defaultPage);
83
- useEffect(() => {
84
- if (page) {
85
- setCurrentPage(page);
86
- }
87
- }, [page]);
59
+ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', onPageChange, compactSider, layoutProps, mobileHeaderProps, siderProps, contentProps, menuProps, }) => {
60
+ const [currentPage, setCurrentPage] = useState(defaultPage);
88
61
  // Fire onChange
89
62
  useEffect(() => {
90
63
  onPageChange?.(currentPage);
@@ -94,9 +67,8 @@ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', on
94
67
  const [hiddenSider, setHiddenSider] = useState(false);
95
68
  const siderWidth = siderProps?.width;
96
69
  const classes = useStyles({ isMobile, compactSider, siderWidth });
97
- const menuPages = useMemo(() => getMenuPages(pages), [pages]);
98
70
  return (<Layout hasSider {...layoutProps}>
99
- {isMobile && (<Header {...mobileHeaderProps} className={classNames(classes.header, mobileHeaderProps?.className)}>
71
+ {isMobile && (<Header className={classes.header} {...mobileHeaderProps}>
100
72
  {hiddenSider ? (<MenuUnfoldOutlined className={classes.menuTrigger} onClick={() => {
101
73
  setHiddenSider(!hiddenSider);
102
74
  }}/>) : (<MenuFoldOutlined className={classes.menuTrigger} onClick={() => {
@@ -111,7 +83,7 @@ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', on
111
83
  : compactSider
112
84
  ? HEADER_HEIGHT
113
85
  : 0} trigger={null}>
114
- <Menu {...menuProps} items={menuPages} selectedKeys={[currentPage]} onSelect={({ key }) => {
86
+ <Menu {...menuProps} items={pages} selectedKeys={[currentPage]} onSelect={({ key }) => {
115
87
  if (!hiddenSider) {
116
88
  setHiddenSider(true);
117
89
  }
@@ -121,8 +93,8 @@ export const BasicLayout = ({ pages = [], defaultPage = pages?.[0].key ?? '', on
121
93
  }
122
94
  }}/>
123
95
  </Sider>
124
- <Content {...contentProps} className={classNames(classes.content, contentProps?.className)}>
125
- <Router pages={pages} currentPage={currentPage} fallbackComponent={<ErrorDisplayer error={new Error('Page Not Found')} extra={[
96
+ <Content className={classes.content} {...contentProps}>
97
+ <Router pages={pages} currentPage={currentPage ?? defaultPage} fallbackComponent={<ErrorDisplayer error={new Error('Page Not Found')} extra={[
126
98
  <Button type='primary' key='refresh' onClick={() => setCurrentPage(defaultPage)}>
127
99
  Go Home
128
100
  </Button>,
@@ -1 +1 @@
1
- {"version":3,"file":"BasicLayout.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,WAAW,CAAA;AAE1D,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,c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;GAAA,CAAC,OAAO,CACP,IAAI,YAAY,CAAC,CACjB,SAAS,CAAC,CAAC,UAAU,CACpB,OAAO,CAAC,OAAO,EACf,YAAY,EAAE,SAAS,CACvB,CAAC,CACF;IAAA,CAAC,MAAM,CACN,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,iBAAiB,CAAC,CACjB,CAAC,cAAc,CACd,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CACnC,KAAK,CAAC,CAAC;gBACN,CAAC,MAAM,CACN,IAAI,CAAC,SAAS,CACd,GAAG,CAAC,SAAS,CACb,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAC3C;;QACD,EAAE,MAAM,CAAC;aACT,CAAC,EACD,CACF,EAEH;GAAA,EAAE,OAAO,CACV;EAAA,EAAE,MAAM,CAAC,CACT,CAAA;AACF,CAAC,CAAA"}
1
+ {"version":3,"file":"BasicLayout.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/BasicLayout.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAY,MAAM,WAAW,CAAA;AAE1D,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EAAE,cAAc,EAAY,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,aAAa,GAAG,EAAE,CAAA;AAQxB,MAAM,SAAS,GAAG,eA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EAEJ;GAAA,EAAE,KAAK,CACP;GAAA,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,YAAY,CAAC,CACrD;IAAA,CAAC,MAAM,CACN,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,WAAW,CAAC,CAAC,WAAW,IAAI,WAAW,CAAC,CACxC,iBAAiB,CAAC,CACjB,CAAC,cAAc,CACd,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CACnC,KAAK,CAAC,CAAC;gBACN,CAAC,MAAM,CACN,IAAI,CAAC,SAAS,CACd,GAAG,CAAC,SAAS,CACb,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAC3C;;QACD,EAAE,MAAM,CAAC;aACT,CAAC,EACD,CACF,EAEH;GAAA,EAAE,OAAO,CACV;EAAA,EAAE,MAAM,CAAC,CACT,CAAA;AACF,CAAC,CAAA"}
@@ -1,13 +1,13 @@
1
- import { LayoutProps } from 'antd';
2
- import React, { ReactElement } from 'react';
3
- import { BasicLayoutProps } from './BasicLayout';
4
- import { MenuPage } from './MenuPage';
5
- export declare type HeaderSiderLayoutProps<T extends MenuPage> = Omit<BasicLayoutProps<T>, 'mobileHeaderProps'> & {
6
- header?: React.ReactNode;
7
- headerProps?: LayoutProps;
8
- };
9
- /**
10
- * Layout with header and sider. Sider is collapsed on mobile.
11
- * Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
12
- */
13
- export declare function HeaderSiderLayout<T extends MenuPage>({ pages, defaultPage, selectedPages, onSelect, compactSider, layoutProps, header, headerProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight, children, }: HeaderSiderLayoutProps<T>): ReactElement;
1
+ import { LayoutProps } from 'antd';
2
+ import React, { ReactElement } from 'react';
3
+ import { BasicLayoutProps } from './BasicLayout';
4
+ import { MenuPage } from './MenuPage';
5
+ export declare type HeaderSiderLayoutProps<T extends MenuPage> = Omit<BasicLayoutProps<T>, 'mobileHeaderProps'> & {
6
+ header?: React.ReactNode;
7
+ headerProps?: LayoutProps;
8
+ };
9
+ /**
10
+ * Layout with header and sider. Sider is collapsed on mobile.
11
+ * Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
12
+ */
13
+ export declare function HeaderSiderLayout<T extends MenuPage>({ pages, defaultPage, selectedPages, onSelect, compactSider, layoutProps, header, headerProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight, children, }: HeaderSiderLayoutProps<T>): ReactElement;
@@ -1,81 +1,81 @@
1
- /*
2
- * Copyright (c) 2024, J2 Innovations. All Rights Reserved
3
- */
4
- import { Container, Layout, Menu } from '@j2inn/ui';
5
- import classNames from 'classnames';
6
- import React, { useMemo, useState } from 'react';
7
- import { createUseStyles } from 'react-jss';
8
- import { DEFAULT_HEADER_HEIGHT, getMenuPages, } from './BasicLayout';
9
- import MenuTrigger from './MenuTrigger';
10
- const useStyles = createUseStyles({
11
- header: ({ headerHeight }) => ({
12
- position: 'fixed',
13
- width: '100%',
14
- zIndex: 1000,
15
- padding: 0,
16
- height: headerHeight,
17
- lineHeight: `${headerHeight}px`,
18
- }),
19
- headerContent: {
20
- height: '100%',
21
- },
22
- sider: ({ headerHeight }) => ({
23
- overflow: 'auto',
24
- height: '100vh',
25
- position: 'fixed',
26
- left: 0,
27
- top: 0,
28
- bottom: 0,
29
- zIndex: 999,
30
- paddingTop: headerHeight,
31
- }),
32
- content: ({ isMobile, compactSider, siderWidth = 200, headerHeight, }) => ({
33
- paddingLeft: isMobile ? 0 : compactSider ? 45 : siderWidth,
34
- paddingTop: headerHeight,
35
- }),
36
- });
37
- // Workaround j2inn/ui exporting problem
38
- const Header = Layout.Header;
39
- const Sider = Layout.Sider;
40
- const Content = Layout.Content;
41
- /**
42
- * Layout with header and sider. Sider is collapsed on mobile.
43
- * Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
44
- */
45
- export function HeaderSiderLayout({ pages = [], defaultPage, selectedPages = [], onSelect, compactSider, layoutProps, header, headerProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight = DEFAULT_HEADER_HEIGHT, children, }) {
46
- const [isMobile, setIsMobile] = useState(false);
47
- const [hiddenSider, setHiddenSider] = useState(false);
48
- const siderWidth = siderProps?.width;
49
- const classes = useStyles({
50
- isMobile,
51
- compactSider: compactSider?.isCompact,
52
- siderWidth,
53
- headerHeight,
54
- });
55
- const menuPages = useMemo(() => getMenuPages(pages), [pages]);
56
- return (React.createElement(Layout, { hasSider: true, ...layoutProps },
57
- React.createElement(Header, { ...headerProps, className: classNames(classes.header, headerProps?.className) },
58
- React.createElement(Container, { horizontal: true, middle: true, className: classes.headerContent },
59
- isMobile && (React.createElement(MenuTrigger, { hiddenSider: hiddenSider, headerHeight: headerHeight, className: menuTriggerClassName, onClick: () => {
60
- setHiddenSider(!hiddenSider);
61
- } })),
62
- header)),
63
- React.createElement(Sider, { ...siderProps, className: classNames(classes.sider, siderProps?.className), breakpoint: 'md', onBreakpoint: (broken) => {
64
- setIsMobile(broken);
65
- setHiddenSider(true);
66
- }, collapsed: (isMobile && hiddenSider) || compactSider?.isCompact, collapsedWidth: isMobile && hiddenSider
67
- ? 0
68
- : compactSider
69
- ? headerHeight
70
- : 0, trigger: null },
71
- menuBefore,
72
- React.createElement(Menu, { ...menuProps, defaultSelectedKeys: defaultPage ? [defaultPage] : undefined, items: menuPages, selectedKeys: selectedPages, onSelect: ({ key }) => {
73
- if (!hiddenSider) {
74
- setHiddenSider(true);
75
- }
76
- onSelect?.(key);
77
- } }),
78
- menuAfter),
79
- React.createElement(Content, { ...contentProps, className: classNames(classes.content, contentProps?.className) }, children)));
80
- }
1
+ /*
2
+ * Copyright (c) 2024, J2 Innovations. All Rights Reserved
3
+ */
4
+ import { Container, Layout, Menu } from '@j2inn/ui';
5
+ import classNames from 'classnames';
6
+ import React, { useMemo, useState } from 'react';
7
+ import { createUseStyles } from 'react-jss';
8
+ import { DEFAULT_HEADER_HEIGHT, getMenuPages, } from './BasicLayout';
9
+ import MenuTrigger from './MenuTrigger';
10
+ const useStyles = createUseStyles({
11
+ header: ({ headerHeight }) => ({
12
+ position: 'fixed',
13
+ width: '100%',
14
+ zIndex: 1000,
15
+ padding: 0,
16
+ height: headerHeight,
17
+ lineHeight: `${headerHeight}px`,
18
+ }),
19
+ headerContent: {
20
+ height: '100%',
21
+ },
22
+ sider: ({ headerHeight }) => ({
23
+ overflow: 'auto',
24
+ height: '100vh',
25
+ position: 'fixed',
26
+ left: 0,
27
+ top: 0,
28
+ bottom: 0,
29
+ zIndex: 999,
30
+ paddingTop: headerHeight,
31
+ }),
32
+ content: ({ isMobile, compactSider, siderWidth = 200, headerHeight, }) => ({
33
+ paddingLeft: isMobile ? 0 : compactSider ? 45 : siderWidth,
34
+ paddingTop: headerHeight,
35
+ }),
36
+ });
37
+ // Workaround j2inn/ui exporting problem
38
+ const Header = Layout.Header;
39
+ const Sider = Layout.Sider;
40
+ const Content = Layout.Content;
41
+ /**
42
+ * Layout with header and sider. Sider is collapsed on mobile.
43
+ * Routing management can be plugged in, for examples @see ReactRouterLayout @see RouterLayout
44
+ */
45
+ export function HeaderSiderLayout({ pages = [], defaultPage, selectedPages = [], onSelect, compactSider, layoutProps, header, headerProps, siderProps, contentProps, menuProps, menuBefore, menuAfter, menuTriggerClassName, headerHeight = DEFAULT_HEADER_HEIGHT, children, }) {
46
+ const [isMobile, setIsMobile] = useState(false);
47
+ const [hiddenSider, setHiddenSider] = useState(false);
48
+ const siderWidth = siderProps?.width;
49
+ const classes = useStyles({
50
+ isMobile,
51
+ compactSider: compactSider?.isCompact,
52
+ siderWidth,
53
+ headerHeight,
54
+ });
55
+ const menuPages = useMemo(() => getMenuPages(pages), [pages]);
56
+ return (React.createElement(Layout, { hasSider: true, ...layoutProps },
57
+ React.createElement(Header, { ...headerProps, className: classNames(classes.header, headerProps?.className) },
58
+ React.createElement(Container, { horizontal: true, middle: true, className: classes.headerContent },
59
+ isMobile && (React.createElement(MenuTrigger, { hiddenSider: hiddenSider, headerHeight: headerHeight, className: menuTriggerClassName, onClick: () => {
60
+ setHiddenSider(!hiddenSider);
61
+ } })),
62
+ header)),
63
+ React.createElement(Sider, { ...siderProps, className: classNames(classes.sider, siderProps?.className), breakpoint: 'md', onBreakpoint: (broken) => {
64
+ setIsMobile(broken);
65
+ setHiddenSider(true);
66
+ }, collapsed: (isMobile && hiddenSider) || compactSider?.isCompact, collapsedWidth: isMobile && hiddenSider
67
+ ? 0
68
+ : compactSider
69
+ ? headerHeight
70
+ : 0, trigger: null },
71
+ menuBefore,
72
+ React.createElement(Menu, { ...menuProps, defaultSelectedKeys: defaultPage ? [defaultPage] : undefined, items: menuPages, selectedKeys: selectedPages, onSelect: ({ key }) => {
73
+ if (!hiddenSider) {
74
+ setHiddenSider(true);
75
+ }
76
+ onSelect?.(key);
77
+ } }),
78
+ menuAfter),
79
+ React.createElement(Content, { ...contentProps, className: classNames(classes.content, contentProps?.className) }, children)));
80
+ }
81
81
  //# sourceMappingURL=HeaderSiderLayout.js.map
@@ -1,37 +1,37 @@
1
- import { ItemType } from 'antd/lib/menu/hooks/useItems';
2
- import React, { PropsWithChildren } from 'react';
3
- /**
4
- * Menu page has both the data required by the menu and the data required to actually render the page.
5
- */
6
- export declare type MenuPage<T = Record<string, unknown>> = ItemType & Page<T>;
7
- /**
8
- * Menu Item that represents an application page
9
- */
10
- interface Page<T = Record<string, unknown>> {
11
- key: string;
12
- component?: React.LazyExoticComponent<React.FC<T>>;
13
- props?: PropsWithChildren<T>;
14
- children?: MenuPage<T>[];
15
- disabled?: boolean;
16
- /**
17
- * Set it to false to avoid showing the page in the menu. It is just used for routing purposes.
18
- */
19
- showInMenu?: boolean;
20
- }
21
- /**
22
- * Retrieve a specific page or subPage from a root page list
23
- * @param name the name of the searched page
24
- * @param pages the list of root pages
25
- */
26
- export declare function findPageByName<T extends MenuPage>(pages: T[], name?: string): T | undefined;
27
- /**
28
- * Expands the list of pages to include all the subpages
29
- */
30
- export declare function pageTreeToPageList<T extends MenuPage>(pages: T[]): T[];
31
- /**
32
- * Recursively get all the subPages of a root page
33
- * @param page root page
34
- * @returns the whole tree of subPages as a list
35
- */
36
- export declare function getAllSubPages<T extends MenuPage>(page: T): T[];
37
- export {};
1
+ import { ItemType } from 'antd/lib/menu/hooks/useItems';
2
+ import React, { PropsWithChildren } from 'react';
3
+ /**
4
+ * Menu page has both the data required by the menu and the data required to actually render the page.
5
+ */
6
+ export declare type MenuPage<T = Record<string, unknown>> = ItemType & Page<T>;
7
+ /**
8
+ * Menu Item that represents an application page
9
+ */
10
+ interface Page<T = Record<string, unknown>> {
11
+ key: string;
12
+ component?: React.LazyExoticComponent<React.FC<T>>;
13
+ props?: PropsWithChildren<T>;
14
+ children?: MenuPage<T>[];
15
+ disabled?: boolean;
16
+ /**
17
+ * Set it to false to avoid showing the page in the menu. It is just used for routing purposes.
18
+ */
19
+ showInMenu?: boolean;
20
+ }
21
+ /**
22
+ * Retrieve a specific page or subPage from a root page list
23
+ * @param name the name of the searched page
24
+ * @param pages the list of root pages
25
+ */
26
+ export declare function findPageByName<T extends MenuPage>(pages: T[], name?: string): T | undefined;
27
+ /**
28
+ * Expands the list of pages to include all the subpages
29
+ */
30
+ export declare function pageTreeToPageList<T extends MenuPage>(pages: T[]): T[];
31
+ /**
32
+ * Recursively get all the subPages of a root page
33
+ * @param page root page
34
+ * @returns the whole tree of subPages as a list
35
+ */
36
+ export declare function getAllSubPages<T extends MenuPage>(page: T): T[];
37
+ export {};
@@ -1,31 +1,31 @@
1
- /*
2
- * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
- */
4
- /**
5
- * Retrieve a specific page or subPage from a root page list
6
- * @param name the name of the searched page
7
- * @param pages the list of root pages
8
- */
9
- export function findPageByName(pages, name) {
10
- return pageTreeToPageList(pages).find((page) => page.key === name && !page.disabled);
11
- }
12
- /**
13
- * Expands the list of pages to include all the subpages
14
- */
15
- export function pageTreeToPageList(pages) {
16
- return pages.flatMap((page) => getAllSubPages(page));
17
- }
18
- /**
19
- * Recursively get all the subPages of a root page
20
- * @param page root page
21
- * @returns the whole tree of subPages as a list
22
- */
23
- export function getAllSubPages(page) {
24
- if (page.children) {
25
- return [page].concat(...page.children.map((subPage) => getAllSubPages(subPage)));
26
- }
27
- else {
28
- return [page];
29
- }
30
- }
1
+ /*
2
+ * Copyright (c) 2022, J2 Innovations. All Rights Reserved
3
+ */
4
+ /**
5
+ * Retrieve a specific page or subPage from a root page list
6
+ * @param name the name of the searched page
7
+ * @param pages the list of root pages
8
+ */
9
+ export function findPageByName(pages, name) {
10
+ return pageTreeToPageList(pages).find((page) => page.key === name && !page.disabled);
11
+ }
12
+ /**
13
+ * Expands the list of pages to include all the subpages
14
+ */
15
+ export function pageTreeToPageList(pages) {
16
+ return pages.flatMap((page) => getAllSubPages(page));
17
+ }
18
+ /**
19
+ * Recursively get all the subPages of a root page
20
+ * @param page root page
21
+ * @returns the whole tree of subPages as a list
22
+ */
23
+ export function getAllSubPages(page) {
24
+ if (page.children) {
25
+ return [page].concat(...page.children.map((subPage) => getAllSubPages(subPage)));
26
+ }
27
+ else {
28
+ return [page];
29
+ }
30
+ }
31
31
  //# sourceMappingURL=MenuPage.js.map
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"MenuPage.jsx","sourceRoot":"","sources":["../../../../src/react/components/navigation/MenuPage.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAyBH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,KAAU,EACV,IAAa;IAEb,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC,IAAI,CACpC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAC7C,CAAA;AACF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAqB,KAAU;IAChE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;AACF,CAAC"}
@@ -1,9 +1,9 @@
1
- import React from 'react';
2
- interface MenuTriggerProps {
3
- hiddenSider: boolean;
4
- headerHeight?: number;
5
- className?: string;
6
- onClick: () => void;
7
- }
8
- declare const MenuTrigger: React.FC<MenuTriggerProps>;
9
- export default MenuTrigger;
1
+ import React from 'react';
2
+ interface MenuTriggerProps {
3
+ hiddenSider: boolean;
4
+ headerHeight?: number;
5
+ className?: string;
6
+ onClick: () => void;
7
+ }
8
+ declare const MenuTrigger: React.FC<MenuTriggerProps>;
9
+ export default MenuTrigger;
@@ -1,29 +1,29 @@
1
- /*
2
- * Copyright (c) 2024, J2 Innovations. All Rights Reserved
3
- */
4
- import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
5
- import classNames from 'classnames';
6
- import React from 'react';
7
- import { createUseStyles } from 'react-jss';
8
- const useStyles = createUseStyles((theme) => ({
9
- menuTrigger: ({ headerHeight }) => ({
10
- width: headerHeight,
11
- height: '100%',
12
- textAlign: 'center',
13
- fontSize: 18,
14
- cursor: 'pointer',
15
- transition: 'color 0.3s ease-in-out',
16
- backgroundColor: 'transparent',
17
- color: theme.linkColor,
18
- padding: '0 0.5rem',
19
- '&:hover': {
20
- color: theme.linkActiveColor,
21
- },
22
- }),
23
- }));
24
- const MenuTrigger = ({ hiddenSider, headerHeight = 45, onClick, className, }) => {
25
- const classes = useStyles({ headerHeight });
26
- return hiddenSider ? (React.createElement(MenuUnfoldOutlined, { className: classNames(classes.menuTrigger, className), onClick: onClick })) : (React.createElement(MenuFoldOutlined, { className: classNames(classes.menuTrigger, className), onClick: onClick }));
27
- };
28
- export default MenuTrigger;
1
+ /*
2
+ * Copyright (c) 2024, J2 Innovations. All Rights Reserved
3
+ */
4
+ import { MenuFoldOutlined, MenuUnfoldOutlined } from '@ant-design/icons';
5
+ import classNames from 'classnames';
6
+ import React from 'react';
7
+ import { createUseStyles } from 'react-jss';
8
+ const useStyles = createUseStyles((theme) => ({
9
+ menuTrigger: ({ headerHeight }) => ({
10
+ width: headerHeight,
11
+ height: '100%',
12
+ textAlign: 'center',
13
+ fontSize: 18,
14
+ cursor: 'pointer',
15
+ transition: 'color 0.3s ease-in-out',
16
+ backgroundColor: 'transparent',
17
+ color: theme.linkColor,
18
+ padding: '0 0.5rem',
19
+ '&:hover': {
20
+ color: theme.linkActiveColor,
21
+ },
22
+ }),
23
+ }));
24
+ const MenuTrigger = ({ hiddenSider, headerHeight = 45, onClick, className, }) => {
25
+ const classes = useStyles({ headerHeight });
26
+ return hiddenSider ? (React.createElement(MenuUnfoldOutlined, { className: classNames(classes.menuTrigger, className), onClick: onClick })) : (React.createElement(MenuFoldOutlined, { className: classNames(classes.menuTrigger, className), onClick: onClick }));
27
+ };
28
+ export default MenuTrigger;
29
29
  //# sourceMappingURL=MenuTrigger.js.map
@@ -1,11 +1,11 @@
1
- import type { Location } from '@remix-run/router';
2
- import React from 'react';
3
- import { HeaderSiderLayoutProps } from './HeaderSiderLayout';
4
- import { ReactRouterMenuPage } from './ReactRouterLayout';
5
- export interface ReactRouterHeaderSiderLayoutProps extends HeaderSiderLayoutProps<ReactRouterMenuPage> {
6
- isSelectedRoute?: (page: ReactRouterMenuPage, location: Location) => boolean;
7
- }
8
- /**
9
- * Header/Sider layout that uses React Router.
10
- */
11
- export declare const ReactRouterHeaderSiderLayout: React.FC<ReactRouterHeaderSiderLayoutProps>;
1
+ import type { Location } from '@remix-run/router';
2
+ import React from 'react';
3
+ import { HeaderSiderLayoutProps } from './HeaderSiderLayout';
4
+ import { ReactRouterMenuPage } from './ReactRouterLayout';
5
+ export interface ReactRouterHeaderSiderLayoutProps extends HeaderSiderLayoutProps<ReactRouterMenuPage> {
6
+ isSelectedRoute?: (page: ReactRouterMenuPage, location: Location) => boolean;
7
+ }
8
+ /**
9
+ * Header/Sider layout that uses React Router.
10
+ */
11
+ export declare const ReactRouterHeaderSiderLayout: React.FC<ReactRouterHeaderSiderLayoutProps>;
@@ -1,19 +1,19 @@
1
- /*
2
- * Copyright (c) 2024, J2 Innovations. All Rights Reserved
3
- */
4
- import React from 'react';
5
- import { Outlet, useNavigate } from 'react-router';
6
- import { HeaderSiderLayout } from './HeaderSiderLayout';
7
- import { useDefaultOnSelect, useGetPageKeyRouteMap, useSelectedRoutes, } from './ReactRouterLayout';
8
- /**
9
- * Header/Sider layout that uses React Router.
10
- */
11
- export const ReactRouterHeaderSiderLayout = ({ isSelectedRoute, pages = [], onSelect, ...otherProps }) => {
12
- const navigate = useNavigate();
13
- const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
14
- const pageKeyRouteMap = useGetPageKeyRouteMap(pages);
15
- const defaultOnSelect = useDefaultOnSelect(navigate, pageKeyRouteMap, pages);
16
- return (React.createElement(HeaderSiderLayout, { ...otherProps, pages: pages, onSelect: onSelect ?? defaultOnSelect, selectedPages: selectedRoutes },
17
- React.createElement(Outlet, null)));
18
- };
1
+ /*
2
+ * Copyright (c) 2024, J2 Innovations. All Rights Reserved
3
+ */
4
+ import React from 'react';
5
+ import { Outlet, useNavigate } from 'react-router';
6
+ import { HeaderSiderLayout } from './HeaderSiderLayout';
7
+ import { useDefaultOnSelect, useGetPageKeyRouteMap, useSelectedRoutes, } from './ReactRouterLayout';
8
+ /**
9
+ * Header/Sider layout that uses React Router.
10
+ */
11
+ export const ReactRouterHeaderSiderLayout = ({ isSelectedRoute, pages = [], onSelect, ...otherProps }) => {
12
+ const navigate = useNavigate();
13
+ const selectedRoutes = useSelectedRoutes(pages, isSelectedRoute);
14
+ const pageKeyRouteMap = useGetPageKeyRouteMap(pages);
15
+ const defaultOnSelect = useDefaultOnSelect(navigate, pageKeyRouteMap, pages);
16
+ return (React.createElement(HeaderSiderLayout, { ...otherProps, pages: pages, onSelect: onSelect ?? defaultOnSelect, selectedPages: selectedRoutes },
17
+ React.createElement(Outlet, null)));
18
+ };
19
19
  //# sourceMappingURL=ReactRouterHeaderSiderLayout.js.map