@pdg/react-admin-layout 1.0.0 → 1.0.2

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.
@@ -1,6 +1,8 @@
1
1
  export interface MenuTitle {
2
2
  name: string;
3
+ icon?: string;
3
4
  parentName?: string;
5
+ parentIcon?: string;
4
6
  }
5
7
  export interface MenuTitleMap {
6
8
  [key: string]: MenuTitle;
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  export interface TitleProps {
3
- title: string;
4
- headTitle?: string;
3
+ title: ReactNode;
4
+ headTitle?: ReactNode;
5
5
  }
6
6
  declare const Title: React.FC<TitleProps>;
7
7
  export default Title;
package/dist/index.esm.js CHANGED
@@ -7472,13 +7472,13 @@ var DefaultLayout = function (_a) {
7472
7472
  var menuTitles = {};
7473
7473
  if (menu) {
7474
7474
  menu.forEach(function (info) {
7475
- if (info.items) {
7475
+ if (empty(info.uri) && info.items && info.items.length > 0) {
7476
7476
  info.items.map(function (subInfo) {
7477
- menuTitles[subInfo.uri] = { name: subInfo.name, parentName: info.name };
7477
+ menuTitles[subInfo.uri] = { name: subInfo.name, parentName: info.name, parentIcon: info.icon };
7478
7478
  });
7479
7479
  }
7480
7480
  else if (info.uri) {
7481
- menuTitles[info.uri] = { name: info.name };
7481
+ menuTitles[info.uri] = { name: info.name, icon: info.icon };
7482
7482
  }
7483
7483
  });
7484
7484
  }
@@ -7488,7 +7488,13 @@ var DefaultLayout = function (_a) {
7488
7488
  if (menuTitles) {
7489
7489
  var titleData = menuTitles[location.pathname];
7490
7490
  if (titleData) {
7491
- setTitle(React.createElement(Title, { title: titleData.name, headTitle: titleData.parentName }));
7491
+ setTitle(React.createElement(Title, { title: React.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
7492
+ titleData.icon && (React.createElement("div", { style: { flexShrink: 0, display: 'inline-flex', verticalAlign: 'bottom', marginRight: 5 } },
7493
+ React.createElement(Icon, { fontSize: 'small' }, titleData.icon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })))),
7494
+ React.createElement("div", null, titleData.name)), headTitle: titleData.parentName ? (React.createElement("div", { style: { display: 'flex', alignItems: 'center' } },
7495
+ titleData.parentIcon && (React.createElement("div", { style: { flexShrink: 0, display: 'inline-flex', verticalAlign: 'bottom', marginRight: 5 } },
7496
+ React.createElement(Icon, { fontSize: 'small' }, titleData.parentIcon.replace(/[A-Z]/g, function (letter, idx) { return "".concat(idx > 0 ? '_' : '').concat(letter.toLowerCase()); })))),
7497
+ React.createElement("div", null, titleData.parentName))) : null }));
7492
7498
  }
7493
7499
  else {
7494
7500
  setTitle(undefined);