@creekjs/web-components 1.0.11 → 1.0.13

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,54 +1,54 @@
1
1
 
2
2
  
3
- > @creekjs/web-components@1.0.10 father:build /Users/ernestwang/Documents/code-resoorce/creek/packages/web-components
3
+ > @creekjs/web-components@1.0.11 father:build /Users/ernestwang/Documents/code-resoorce/creek/packages/web-components
4
4
  > father build
5
5
 
6
6
  info - Clean output directories
7
7
  info - Bundless for src directory to cjs format
8
+ event - Bundless index.tsx to dist/creek-config-provider/index.js (with declaration)
8
9
  event - Bundless CreekConfigContext.tsx to dist/creek-config-provider/CreekConfigContext.js (with declaration)
10
+ event - Bundless index.ts to dist/creek-hooks/index.js (with declaration)
9
11
  event - Bundless CreekI18nProvider.tsx to dist/creek-config-provider/CreekI18nProvider.js (with declaration)
10
12
  event - Bundless DrawerHelper.tsx to dist/creek-hooks/useApp/DrawerHelper.js (with declaration)
11
13
  event - Bundless index.tsx to dist/creek-hooks/useApp/index.js (with declaration)
12
- event - Bundless index.tsx to dist/creek-config-provider/index.js (with declaration)
13
- event - Bundless index.ts to dist/creek-hooks/index.js (with declaration)
14
- event - Bundless useViewportHeight.tsx to dist/creek-hooks/useViewportHeight.js (with declaration)
15
14
  event - Bundless ModalHelper.tsx to dist/creek-hooks/useApp/ModalHelper.js (with declaration)
16
15
  event - Bundless types.ts to dist/creek-hooks/useApp/types.js (with declaration)
17
16
  event - Bundless index.tsx to dist/creek-icon/index.js (with declaration)
18
- event - Bundless CollapseButton.tsx to dist/creek-layout/CollapseButton.js (with declaration)
17
+ event - Bundless FullScreen.tsx to dist/creek-layout/ActionRender/FullScreen.js (with declaration)
19
18
  event - Bundless index.tsx to dist/creek-keep-alive/index.js (with declaration)
20
19
  event - Bundless index.tsx to dist/creek-layout/ActionRender/index.js (with declaration)
21
- event - Bundless FullScreen.tsx to dist/creek-layout/ActionRender/FullScreen.js (with declaration)
22
- event - Bundless index.tsx to dist/creek-layout/Exception/index.js (with declaration)
23
20
  event - Bundless UserInfo.tsx to dist/creek-layout/ActionRender/UserInfo.js (with declaration)
24
21
  event - Bundless LayoutSettings.tsx to dist/creek-layout/ActionRender/LayoutSettings.js (with declaration)
25
- event - Bundless index.tsx to dist/creek-loading/index.js (with declaration)
22
+ event - Bundless index.tsx to dist/creek-layout/Exception/index.js (with declaration)
26
23
  event - Bundless NotFound.tsx to dist/creek-layout/Exception/NotFound.js (with declaration)
27
- event - Bundless useLayoutSettingsStore.ts to dist/creek-layout/useLayoutSettingsStore.js (with declaration)
24
+ event - Bundless CollapseButton.tsx to dist/creek-layout/CollapseButton.js (with declaration)
28
25
  event - Bundless NotFoundPage.tsx to dist/creek-layout/Exception/NotFoundPage.js (with declaration)
29
- event - Bundless DensityIcon.tsx to dist/creek-table/components/DensityIcon.js (with declaration)
30
- event - Bundless EllipsisTooltip.tsx to dist/creek-table/components/EllipsisTooltip.js (with declaration)
31
26
  event - Bundless index.tsx to dist/creek-layout/index.js (with declaration)
32
- event - Bundless useElementDistance.tsx to dist/creek-table/hooks/useElementDistance.js (with declaration)
27
+ event - Bundless index.tsx to dist/creek-loading/index.js (with declaration)
28
+ event - Bundless index.tsx to dist/creek-locale-button/index.js (with declaration)
29
+ event - Bundless index.ts to dist/creek-style/index.js (with declaration)
33
30
  event - Bundless scrollbar.ts to dist/creek-style/scrollbar.js (with declaration)
34
31
  event - Bundless index.tsx to dist/creek-page-container/index.js (with declaration)
35
- event - Bundless index.ts to dist/creek-style/index.js (with declaration)
36
- event - Bundless index.tsx to dist/creek-table/components/index.js (with declaration)
37
- event - Bundless useEllipsisColumns.tsx to dist/creek-table/hooks/useEllipsisColumns.js (with declaration)
32
+ event - Bundless EllipsisTooltip.tsx to dist/creek-table/components/EllipsisTooltip.js (with declaration)
33
+ event - Bundless DensityIcon.tsx to dist/creek-table/components/DensityIcon.js (with declaration)
38
34
  event - Bundless index.ts to dist/creek-table/hooks/index.js (with declaration)
35
+ event - Bundless index.tsx to dist/creek-table/components/index.js (with declaration)
39
36
  event - Bundless useAdaptiveToolBar.tsx to dist/creek-table/hooks/useAdaptiveToolBar.js (with declaration)
37
+ event - Bundless useEllipsisColumns.tsx to dist/creek-table/hooks/useEllipsisColumns.js (with declaration)
38
+ event - Bundless useAutoWidthColumns.tsx to dist/creek-table/hooks/useAutoWidthColumns.js (with declaration)
40
39
  event - Bundless useIndexColumn.tsx to dist/creek-table/hooks/useIndexColumn.js (with declaration)
40
+ event - Bundless useResizableColumns.tsx to dist/creek-table/hooks/useResizableColumns.js (with declaration)
41
+ event - Bundless useElementDistance.tsx to dist/creek-table/hooks/useElementDistance.js (with declaration)
41
42
  event - Bundless index.tsx to dist/creek-table/index.js (with declaration)
42
- event - Bundless useAutoWidthColumns.tsx to dist/creek-table/hooks/useAutoWidthColumns.js (with declaration)
43
43
  event - Bundless useTableOptions.tsx to dist/creek-table/hooks/useTableOptions.js (with declaration)
44
44
  event - Bundless useTableScrollHeight.tsx to dist/creek-table/hooks/useTableScrollHeight.js (with declaration)
45
- event - Bundless useResizableColumns.tsx to dist/creek-table/hooks/useResizableColumns.js (with declaration)
46
- event - Bundless useStatusColumns.tsx to dist/creek-table/hooks/useStatusColumns.js (with declaration)
47
- event - Bundless SearchTable.tsx to dist/creek-table/SearchTable.js (with declaration)
48
- event - Bundless index.tsx to dist/creek-locale-button/index.js (with declaration)
49
- event - Bundless zh_CN.ts to dist/locales/zh_CN.js (with declaration)
50
- event - Bundless en_US.ts to dist/locales/en_US.js (with declaration)
51
45
  event - Bundless type.ts to dist/creek-table/type.js (with declaration)
46
+ event - Bundless zh_CN.ts to dist/locales/zh_CN.js (with declaration)
47
+ event - Bundless useViewportHeight.tsx to dist/creek-hooks/useViewportHeight.js (with declaration)
52
48
  event - Bundless index.tsx to dist/index.js (with declaration)
49
+ event - Bundless useLayoutSettingsStore.ts to dist/creek-layout/useLayoutSettingsStore.js (with declaration)
50
+ event - Bundless en_US.ts to dist/locales/en_US.js (with declaration)
51
+ event - Bundless useStatusColumns.tsx to dist/creek-table/hooks/useStatusColumns.js (with declaration)
52
+ event - Bundless SearchTable.tsx to dist/creek-table/SearchTable.js (with declaration)
53
53
  event - Generate declaration files...
54
- event - Transformed successfully in 4255 ms (45 files)
54
+ event - Transformed successfully in 6572 ms (45 files)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/creek-layout/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAUvE,OAAO,EAAkB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ1E,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG;IACzC,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE;QACZ,YAAY,EAAE,GAAG,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,eAAe,EAAE,MAAM,IAAI,CAAC;KAC7B,CAAC;IACF,SAAS,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;CAClC,CAAC;AAQF,eAAO,MAAM,WAAW,UAAW,WAAW,4CAyI7C,CAAC;AAEF,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/creek-layout/index.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA2B,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAUrF,OAAO,EAAkB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAQ1E,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG;IACzC,aAAa,EAAE,cAAc,CAAC;IAC9B,UAAU,CAAC,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,WAAW,CAAC,EAAE;QACZ,YAAY,EAAE,GAAG,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,eAAe,EAAE,MAAM,IAAI,CAAC;KAC7B,CAAC;IACF,SAAS,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;IAC1C,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;CAClC,CAAC;AAQF,eAAO,MAAM,WAAW,UAAW,WAAW,4CA6I7C,CAAC;AAEF,cAAc,aAAa,CAAC"}
@@ -52,7 +52,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
52
52
  var MenuName = ({ name, path }) => {
53
53
  const t = (0, import_react2.useT)();
54
54
  const key = !path || path === "/" ? "menu.home" : `menu${path.replace(/\//g, ".")}`;
55
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: t(key, name) });
55
+ return t(key, name);
56
56
  };
57
57
  var CreekLayout = (props) => {
58
58
  const {
@@ -79,7 +79,7 @@ var CreekLayout = (props) => {
79
79
  const actualKeepAlive = settingsStore.keepAlive ?? keepAlive;
80
80
  const _userConfig = { ...userConfig, ...runtimeConfig };
81
81
  const intlContext = (0, import_react.useContext)(import_react2.IntlContext);
82
- const hasI18n = !!intlContext;
82
+ const hasI18n = !!intlContext && actualShowLocaleButton;
83
83
  const menuDataRender = (0, import_ahooks.useMemoizedFn)((menuData) => {
84
84
  const isLocaleEnabled = hasI18n;
85
85
  const mapMenu = (items) => {
@@ -107,19 +107,20 @@ var CreekLayout = (props) => {
107
107
  );
108
108
  });
109
109
  const getTabTitle = (0, import_ahooks.useMemoizedFn)((pathname) => {
110
- const findTitle = (routes) => {
111
- for (const r of routes) {
112
- if (r.path === pathname)
113
- return r.name || r.title;
114
- if (r.children) {
115
- const found = findTitle(r.children);
110
+ const routes = (route == null ? void 0 : route.routes) ?? [];
111
+ const findTitle = (items) => {
112
+ for (const item of items) {
113
+ if (item.path === pathname)
114
+ return item.name ?? item.title;
115
+ if (item.children) {
116
+ const found = findTitle(item.children);
116
117
  if (found)
117
118
  return found;
118
119
  }
119
120
  }
120
- return void 0;
121
121
  };
122
- return findTitle((route == null ? void 0 : route.routes) || []) || pathname;
122
+ const title = findTitle(routes) ?? pathname;
123
+ return hasI18n ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MenuName, { name: title, path: pathname }) : title;
123
124
  });
124
125
  const actions = [...extraActions];
125
126
  if (actualShowFullScreen) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/creek-layout/index.tsx"],
4
- "sourcesContent": ["import { ProLayout, ProLayoutProps } from '@ant-design/pro-components';\nimport { useMemoizedFn } from 'ahooks';\nimport { theme } from 'antd';\nimport _ from 'lodash';\nimport { useContext } from 'react';\n\nimport classnames from 'classnames';\n\nimport { IntlContext, useT } from '@creekjs/i18n/react';\n\nimport { CreekKeepAlive, CreekKeepAliveProps } from '../creek-keep-alive';\nimport { CreekLocaleButton } from '../creek-locale-button';\nimport { GlobalScrollbarStyle } from '../creek-style/scrollbar';\nimport { FullScreen, LayoutSettings } from './ActionRender';\nimport { CollapsedButton, useCollapsedStore } from './CollapseButton';\nimport { Exception } from './Exception';\nimport { useLayoutSettingsStore } from './useLayoutSettingsStore';\n\nexport type LayoutProps = ProLayoutProps & {\n runtimeConfig: ProLayoutProps;\n userConfig?: ProLayoutProps;\n navigate?: (path?: string | number) => void;\n showFullScreen?: boolean;\n showLocaleButton?: boolean;\n showSettingsButton?: boolean;\n initialInfo?: {\n initialState: any;\n loading: boolean;\n setInitialState: () => void;\n };\n keepAlive?: boolean | CreekKeepAliveProps;\n extraActions?: React.ReactNode[];\n};\n\nconst MenuName = ({ name, path }: { name: string; path?: string }) => {\n const t = useT();\n const key = !path || path === '/' ? 'menu.home' : `menu${path.replace(/\\//g, '.')}`;\n return <>{t(key, name)}</>;\n};\n\nexport const CreekLayout = (props: LayoutProps) => {\n const {\n route,\n userConfig,\n runtimeConfig,\n children,\n location,\n navigate,\n showFullScreen = false,\n showLocaleButton = false,\n showSettingsButton = false,\n keepAlive = false,\n extraActions = [],\n ...more\n } = props;\n\n const { useToken } = theme;\n const { token } = useToken();\n\n const { collapsed } = useCollapsedStore();\n const settingsStore = useLayoutSettingsStore();\n\n const actualShowFullScreen = settingsStore.showFullScreen ?? showFullScreen;\n const actualShowLocaleButton = settingsStore.showLocaleButton ?? showLocaleButton;\n const colorPrimary = settingsStore.colorPrimary || token.colorPrimary;\n const actualKeepAlive = settingsStore.keepAlive ?? keepAlive;\n\n const _userConfig = { ...userConfig, ...runtimeConfig };\n\n const intlContext = useContext(IntlContext);\n const hasI18n = !!intlContext;\n\n const menuDataRender = useMemoizedFn((menuData: any[]) => {\n // 根据当前是否开启了国际化(上下文是否存在)以及用户配置来判断是否包裹菜单翻译\n const isLocaleEnabled = hasI18n;\n\n const mapMenu = (items: any[]): any[] => {\n return items.map((item) => {\n return {\n ...item,\n name: isLocaleEnabled ? <MenuName name={item.name} path={item.path} /> : item.name,\n children: item.children ? mapMenu(item.children) : undefined,\n };\n });\n };\n return mapMenu(menuData);\n });\n\n const menuItemRender: ProLayoutProps['menuItemRender'] = useMemoizedFn((itemProps, defaultDom) => {\n return (\n <span\n onClick={() => {\n if (navigate) {\n navigate(itemProps.path);\n }\n }}\n >\n {defaultDom}\n </span>\n );\n });\n\n const getTabTitle = useMemoizedFn((pathname: string) => {\n const findTitle = (routes: any[]): string | React.ReactNode | undefined => {\n for (const r of routes) {\n if (r.path === pathname) return r.name || r.title;\n if (r.children) {\n const found = findTitle(r.children);\n if (found) return found;\n }\n }\n return undefined;\n };\n return findTitle(route?.routes || []) || pathname;\n });\n\n const actions: React.ReactNode[] = [...extraActions];\n\n if (actualShowFullScreen) {\n actions.push(<FullScreen key=\"full-screen\" />);\n }\n\n if (actualShowLocaleButton) {\n actions.push(<CreekLocaleButton key=\"locale-button\" />);\n }\n\n if (showSettingsButton) {\n actions.push(<LayoutSettings key=\"settings\" defaultShowFullScreen={showFullScreen} defaultShowLocaleButton={showLocaleButton} defaultKeepAlive={_.isBoolean(keepAlive) ? keepAlive : true} />);\n }\n\n const keepAliveProps = _.isBoolean(keepAlive) ? {} : keepAlive;\n\n const layoutContent = (\n <ProLayout\n className={classnames('creek-layout-container', _userConfig?.className)}\n route={route}\n title={_userConfig?.title}\n siderWidth={200}\n location={location}\n menuDataRender={menuDataRender}\n menuItemRender={menuItemRender}\n actionsRender={() => actions}\n token={{\n header: {\n colorBgHeader: '#fff',\n colorHeaderTitle: 'rgba(0, 0, 0, 0.80);',\n colorTextMenuSelected: colorPrimary,\n heightLayoutHeader: 48,\n },\n sider: {\n colorMenuBackground: '#f7f8fa',\n colorBgMenuItemSelected: 'transparent',\n colorTextMenuActive: colorPrimary,\n colorTextMenuSelected: colorPrimary,\n colorTextMenuItemHover: colorPrimary,\n colorTextMenu: '#333',\n },\n pageContainer: {\n paddingBlockPageContainerContent: 0,\n paddingInlinePageContainerContent: 0,\n colorBgPageContainer: 'linear-gradient(180deg, #F7F9FF 0%, #FFF 45.59%);',\n },\n }}\n fixSiderbar\n fixedHeader\n collapsed={collapsed}\n collapsedButtonRender={(collapsed) => {\n return <CollapsedButton collapsed={collapsed} />;\n }}\n {...more}\n >\n <GlobalScrollbarStyle />\n <Exception>{actualKeepAlive ? <CreekKeepAlive getTabTitle={getTabTitle} {...keepAliveProps} /> : children}</Exception>\n </ProLayout>\n );\n\n return layoutContent;\n};\n\nexport * from './Exception';\n"],
5
- "mappings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A,EAC/L;AAEA,QAAM,iBAAiB,cAAAA,QAAE,UAAU,SAAS,IAAI,CAAC,IAAI;AAErD,QAAM,gBACJ;AAAA,IAAC;AAAA;AAAA,MACC,eAAW,kBAAAC,SAAW,0BAA0B,2CAAa,SAAS;AAAA,MACtE;AAAA,MACA,OAAO,2CAAa;AAAA,MACpB,YAAY;AAAA,MACZ;AAAA,MACA;AAAA,MACA;AAAA,MACA,eAAe,MAAM;AAAA,MACrB,OAAO;AAAA,QACL,QAAQ;AAAA,UACN,eAAe;AAAA,UACf,kBAAkB;AAAA,UAClB,uBAAuB;AAAA,UACvB,oBAAoB;AAAA,QACtB;AAAA,QACA,OAAO;AAAA,UACL,qBAAqB;AAAA,UACrB,yBAAyB;AAAA,UACzB,qBAAqB;AAAA,UACrB,uBAAuB;AAAA,UACvB,wBAAwB;AAAA,UACxB,eAAe;AAAA,QACjB;AAAA,QACA,eAAe;AAAA,UACb,kCAAkC;AAAA,UAClC,mCAAmC;AAAA,UACnC,sBAAsB;AAAA,QACxB;AAAA,MACF;AAAA,MACA,aAAW;AAAA,MACX,aAAW;AAAA,MACX;AAAA,MACA,uBAAuB,CAACC,eAAc;AACpC,eAAO,4CAAC,yCAAgB,WAAWA,YAAW;AAAA,MAChD;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,oDAAC,yCAAqB;AAAA,QACtB,4CAAC,8BAAW,4BAAkB,4CAAC,0CAAe,aAA2B,GAAG,gBAAgB,IAAK,UAAS;AAAA;AAAA;AAAA,EAC5G;AAGF,SAAO;AACT;",
4
+ "sourcesContent": ["import { MenuDataItem, ProLayout, ProLayoutProps } from '@ant-design/pro-components';\nimport { useMemoizedFn } from 'ahooks';\nimport { theme } from 'antd';\nimport _ from 'lodash';\nimport { useContext } from 'react';\n\nimport classnames from 'classnames';\n\nimport { IntlContext, useT } from '@creekjs/i18n/react';\n\nimport { CreekKeepAlive, CreekKeepAliveProps } from '../creek-keep-alive';\nimport { CreekLocaleButton } from '../creek-locale-button';\nimport { GlobalScrollbarStyle } from '../creek-style/scrollbar';\nimport { FullScreen, LayoutSettings } from './ActionRender';\nimport { CollapsedButton, useCollapsedStore } from './CollapseButton';\nimport { Exception } from './Exception';\nimport { useLayoutSettingsStore } from './useLayoutSettingsStore';\n\nexport type LayoutProps = ProLayoutProps & {\n runtimeConfig: ProLayoutProps;\n userConfig?: ProLayoutProps;\n navigate?: (path?: string | number) => void;\n showFullScreen?: boolean;\n showLocaleButton?: boolean;\n showSettingsButton?: boolean;\n initialInfo?: {\n initialState: any;\n loading: boolean;\n setInitialState: () => void;\n };\n keepAlive?: boolean | CreekKeepAliveProps;\n extraActions?: React.ReactNode[];\n};\n\nconst MenuName = ({ name, path }: { name?: string; path?: string }) => {\n const t = useT();\n const key = !path || path === '/' ? 'menu.home' : `menu${path.replace(/\\//g, '.')}`;\n return t(key, name);\n};\n\nexport const CreekLayout = (props: LayoutProps) => {\n const {\n route,\n userConfig,\n runtimeConfig,\n children,\n location,\n navigate,\n showFullScreen = false,\n showLocaleButton = false,\n showSettingsButton = false,\n keepAlive = false,\n extraActions = [],\n ...more\n } = props;\n\n const { useToken } = theme;\n const { token } = useToken();\n\n const { collapsed } = useCollapsedStore();\n const settingsStore = useLayoutSettingsStore();\n\n const actualShowFullScreen = settingsStore.showFullScreen ?? showFullScreen;\n const actualShowLocaleButton = settingsStore.showLocaleButton ?? showLocaleButton;\n const colorPrimary = settingsStore.colorPrimary || token.colorPrimary;\n const actualKeepAlive = settingsStore.keepAlive ?? keepAlive;\n\n const _userConfig = { ...userConfig, ...runtimeConfig };\n\n const intlContext = useContext(IntlContext);\n const hasI18n = !!intlContext && actualShowLocaleButton;\n\n const menuDataRender = useMemoizedFn((menuData: MenuDataItem[]) => {\n // 根据当前是否开启了国际化(上下文是否存在)以及用户配置来判断是否包裹菜单翻译\n const isLocaleEnabled = hasI18n;\n\n const mapMenu = (items: MenuDataItem[]): MenuDataItem[] => {\n return items.map((item) => {\n return {\n ...item,\n name: (isLocaleEnabled ? <MenuName name={item.name} path={item.path} /> : item.name) as string,\n children: item.children ? mapMenu(item.children) : undefined,\n };\n });\n };\n return mapMenu(menuData);\n });\n\n const menuItemRender: ProLayoutProps['menuItemRender'] = useMemoizedFn((itemProps, defaultDom) => {\n return (\n <span\n onClick={() => {\n if (navigate) {\n navigate(itemProps.path);\n }\n }}\n >\n {defaultDom}\n </span>\n );\n });\n\n const getTabTitle = useMemoizedFn((pathname: string): string | React.ReactNode => {\n const routes = (route?.routes ?? []) as MenuDataItem[];\n\n const findTitle = (items: MenuDataItem[]): string | undefined => {\n for (const item of items) {\n if (item.path === pathname) return item.name ?? item.title;\n if (item.children) {\n const found = findTitle(item.children);\n if (found) return found;\n }\n }\n };\n\n const title = findTitle(routes) ?? pathname;\n\n return hasI18n ? <MenuName name={title} path={pathname} /> : title;\n });\n\n const actions: React.ReactNode[] = [...extraActions];\n\n if (actualShowFullScreen) {\n actions.push(<FullScreen key=\"full-screen\" />);\n }\n\n if (actualShowLocaleButton) {\n actions.push(<CreekLocaleButton key=\"locale-button\" />);\n }\n\n if (showSettingsButton) {\n actions.push(<LayoutSettings key=\"settings\" defaultShowFullScreen={showFullScreen} defaultShowLocaleButton={showLocaleButton} defaultKeepAlive={_.isBoolean(keepAlive) ? keepAlive : true} />);\n }\n\n const keepAliveProps = _.isBoolean(keepAlive) ? {} : keepAlive;\n\n const layoutContent = (\n <ProLayout\n className={classnames('creek-layout-container', _userConfig?.className)}\n route={route}\n title={_userConfig?.title}\n siderWidth={200}\n location={location}\n menuDataRender={menuDataRender}\n menuItemRender={menuItemRender}\n actionsRender={() => actions}\n token={{\n header: {\n colorBgHeader: '#fff',\n colorHeaderTitle: 'rgba(0, 0, 0, 0.80);',\n colorTextMenuSelected: colorPrimary,\n heightLayoutHeader: 48,\n },\n sider: {\n colorMenuBackground: '#f7f8fa',\n colorBgMenuItemSelected: 'transparent',\n colorTextMenuActive: colorPrimary,\n colorTextMenuSelected: colorPrimary,\n colorTextMenuItemHover: colorPrimary,\n colorTextMenu: '#333',\n },\n pageContainer: {\n paddingBlockPageContainerContent: 0,\n paddingInlinePageContainerContent: 0,\n colorBgPageContainer: 'linear-gradient(180deg, #F7F9FF 0%, #FFF 45.59%);',\n },\n }}\n fixSiderbar\n fixedHeader\n collapsed={collapsed}\n collapsedButtonRender={(collapsed) => {\n return <CollapsedButton collapsed={collapsed} />;\n }}\n {...more}\n >\n <GlobalScrollbarStyle />\n <Exception>{actualKeepAlive ? <CreekKeepAlive getTabTitle={getTabTitle} {...keepAliveProps} /> : children}</Exception>\n </ProLayout>\n );\n\n return layoutContent;\n};\n\nexport * from './Exception';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAwD;AACxD,oBAA8B;AAC9B,kBAAsB;AACtB,oBAAc;AACd,mBAA2B;AAE3B,wBAAuB;AAEvB,IAAAA,gBAAkC;AAElC,8BAAoD;AACpD,iCAAkC;AAClC,uBAAqC;AACrC,0BAA2C;AAC3C,4BAAmD;AACnD,uBAA0B;AAC1B,oCAAuC;AAuKvC,iCAAc,wBAvLd;AAgFmC;AA9CnC,IAAM,WAAW,CAAC,EAAE,MAAM,KAAK,MAAwC;AACrE,QAAM,QAAI,oBAAK;AACf,QAAM,MAAM,CAAC,QAAQ,SAAS,MAAM,cAAc,OAAO,KAAK,QAAQ,OAAO,GAAG;AAChF,SAAO,EAAE,KAAK,IAAI;AACpB;AAEO,IAAM,cAAc,CAAC,UAAuB;AACjD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,iBAAiB;AAAA,IACjB,mBAAmB;AAAA,IACnB,qBAAqB;AAAA,IACrB,YAAY;AAAA,IACZ,eAAe,CAAC;AAAA,IAChB,GAAG;AAAA,EACL,IAAI;AAEJ,QAAM,EAAE,SAAS,IAAI;AACrB,QAAM,EAAE,MAAM,IAAI,SAAS;AAE3B,QA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AWA,YAAW;AAAA,MAChD;AAAA,MACC,GAAG;AAAA,MAEJ;AAAA,oDAAC,yCAAqB;AAAA,QACtB,4CAAC,8BAAW,4BAAkB,4CAAC,0CAAe,aAA2B,GAAG,gBAAgB,IAAK,UAAS;AAAA;AAAA;AAAA,EAC5G;AAGF,SAAO;AACT;",
6
6
  "names": ["import_react", "_", "classnames", "collapsed"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creekjs/web-components",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "keywords": [],
@@ -1,4 +1,4 @@
1
- import { ProLayout, ProLayoutProps } from '@ant-design/pro-components';
1
+ import { MenuDataItem, ProLayout, ProLayoutProps } from '@ant-design/pro-components';
2
2
  import { useMemoizedFn } from 'ahooks';
3
3
  import { theme } from 'antd';
4
4
  import _ from 'lodash';
@@ -32,10 +32,10 @@ export type LayoutProps = ProLayoutProps & {
32
32
  extraActions?: React.ReactNode[];
33
33
  };
34
34
 
35
- const MenuName = ({ name, path }: { name: string; path?: string }) => {
35
+ const MenuName = ({ name, path }: { name?: string; path?: string }) => {
36
36
  const t = useT();
37
37
  const key = !path || path === '/' ? 'menu.home' : `menu${path.replace(/\//g, '.')}`;
38
- return <>{t(key, name)}</>;
38
+ return t(key, name);
39
39
  };
40
40
 
41
41
  export const CreekLayout = (props: LayoutProps) => {
@@ -68,17 +68,17 @@ export const CreekLayout = (props: LayoutProps) => {
68
68
  const _userConfig = { ...userConfig, ...runtimeConfig };
69
69
 
70
70
  const intlContext = useContext(IntlContext);
71
- const hasI18n = !!intlContext;
71
+ const hasI18n = !!intlContext && actualShowLocaleButton;
72
72
 
73
- const menuDataRender = useMemoizedFn((menuData: any[]) => {
73
+ const menuDataRender = useMemoizedFn((menuData: MenuDataItem[]) => {
74
74
  // 根据当前是否开启了国际化(上下文是否存在)以及用户配置来判断是否包裹菜单翻译
75
75
  const isLocaleEnabled = hasI18n;
76
76
 
77
- const mapMenu = (items: any[]): any[] => {
77
+ const mapMenu = (items: MenuDataItem[]): MenuDataItem[] => {
78
78
  return items.map((item) => {
79
79
  return {
80
80
  ...item,
81
- name: isLocaleEnabled ? <MenuName name={item.name} path={item.path} /> : item.name,
81
+ name: (isLocaleEnabled ? <MenuName name={item.name} path={item.path} /> : item.name) as string,
82
82
  children: item.children ? mapMenu(item.children) : undefined,
83
83
  };
84
84
  });
@@ -100,18 +100,22 @@ export const CreekLayout = (props: LayoutProps) => {
100
100
  );
101
101
  });
102
102
 
103
- const getTabTitle = useMemoizedFn((pathname: string) => {
104
- const findTitle = (routes: any[]): string | React.ReactNode | undefined => {
105
- for (const r of routes) {
106
- if (r.path === pathname) return r.name || r.title;
107
- if (r.children) {
108
- const found = findTitle(r.children);
103
+ const getTabTitle = useMemoizedFn((pathname: string): string | React.ReactNode => {
104
+ const routes = (route?.routes ?? []) as MenuDataItem[];
105
+
106
+ const findTitle = (items: MenuDataItem[]): string | undefined => {
107
+ for (const item of items) {
108
+ if (item.path === pathname) return item.name ?? item.title;
109
+ if (item.children) {
110
+ const found = findTitle(item.children);
109
111
  if (found) return found;
110
112
  }
111
113
  }
112
- return undefined;
113
114
  };
114
- return findTitle(route?.routes || []) || pathname;
115
+
116
+ const title = findTitle(routes) ?? pathname;
117
+
118
+ return hasI18n ? <MenuName name={title} path={pathname} /> : title;
115
119
  });
116
120
 
117
121
  const actions: React.ReactNode[] = [...extraActions];