@knockout-js/layout 0.0.3 → 0.0.4-beta.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 (53) hide show
  1. package/es2017/components/gather-menu/index.d.ts +34 -0
  2. package/es2017/components/gather-menu/index.js +278 -0
  3. package/es2017/components/gather-menu/index.js.map +1 -0
  4. package/es2017/components/gather-menu/index.module.css +120 -0
  5. package/es2017/components/gather-menu/locale/en_US.d.ts +3 -0
  6. package/es2017/components/gather-menu/locale/en_US.js +7 -0
  7. package/es2017/components/gather-menu/locale/en_US.js.map +1 -0
  8. package/es2017/components/gather-menu/locale/zh_CN.d.ts +3 -0
  9. package/es2017/components/gather-menu/locale/zh_CN.js +7 -0
  10. package/es2017/components/gather-menu/locale/zh_CN.js.map +1 -0
  11. package/es2017/components/index.d.ts +2 -0
  12. package/es2017/components/index.js +2 -0
  13. package/es2017/components/index.js.map +1 -1
  14. package/es2017/components/layout/index.d.ts +5 -0
  15. package/es2017/components/layout/index.js +103 -74
  16. package/es2017/components/layout/index.js.map +1 -1
  17. package/es2017/components/locale/en_US.js +3 -1
  18. package/es2017/components/locale/en_US.js.map +1 -1
  19. package/es2017/components/locale/index.d.ts +2 -0
  20. package/es2017/components/locale/index.js.map +1 -1
  21. package/es2017/components/locale/zh_CN.js +3 -1
  22. package/es2017/components/locale/zh_CN.js.map +1 -1
  23. package/es2017/components/modal/index.d.ts +18 -0
  24. package/es2017/components/modal/index.js +89 -0
  25. package/es2017/components/modal/index.js.map +1 -0
  26. package/es2017/components/modal/index.module.css +20 -0
  27. package/esm/components/gather-menu/index.d.ts +34 -0
  28. package/esm/components/gather-menu/index.js +320 -0
  29. package/esm/components/gather-menu/index.js.map +1 -0
  30. package/esm/components/gather-menu/index.module.css +120 -0
  31. package/esm/components/gather-menu/locale/en_US.d.ts +3 -0
  32. package/esm/components/gather-menu/locale/en_US.js +7 -0
  33. package/esm/components/gather-menu/locale/en_US.js.map +1 -0
  34. package/esm/components/gather-menu/locale/zh_CN.d.ts +3 -0
  35. package/esm/components/gather-menu/locale/zh_CN.js +7 -0
  36. package/esm/components/gather-menu/locale/zh_CN.js.map +1 -0
  37. package/esm/components/index.d.ts +2 -0
  38. package/esm/components/index.js +2 -0
  39. package/esm/components/index.js.map +1 -1
  40. package/esm/components/layout/index.d.ts +5 -0
  41. package/esm/components/layout/index.js +119 -90
  42. package/esm/components/layout/index.js.map +1 -1
  43. package/esm/components/locale/en_US.js +3 -1
  44. package/esm/components/locale/en_US.js.map +1 -1
  45. package/esm/components/locale/index.d.ts +2 -0
  46. package/esm/components/locale/index.js.map +1 -1
  47. package/esm/components/locale/zh_CN.js +3 -1
  48. package/esm/components/locale/zh_CN.js.map +1 -1
  49. package/esm/components/modal/index.d.ts +18 -0
  50. package/esm/components/modal/index.js +90 -0
  51. package/esm/components/modal/index.js.map +1 -0
  52. package/esm/components/modal/index.module.css +20 -0
  53. package/package.json +6 -2
@@ -14,6 +14,8 @@ import { gql, query } from "@knockout-js/ice-urql/request";
14
14
  import { iceUrqlInstance } from "../index";
15
15
  import { OpenWin } from "../icons/index";
16
16
  import { logoBase64 } from "./logo";
17
+ import GatherMenu from "../gather-menu/index";
18
+ import { BarsOutlined } from "@ant-design/icons";
17
19
  const userMenuListQuery = gql(/* GraphQL */ `query userMenuList($appCode:String!){
18
20
  userMenus(appCode: $appCode){
19
21
  id,parentID,kind,name,comments,displaySort,icon,route
@@ -21,6 +23,7 @@ const userMenuListQuery = gql(/* GraphQL */ `query userMenuList($appCode:String!
21
23
  }`);
22
24
  const Layout = (props)=>{
23
25
  const [locale, setLocale] = useState(LocaleType.zhCN);
26
+ const [open, setOpen] = useState(false);
24
27
  // 根据列表格式化成菜单树结构
25
28
  const listFormatTree = useCallback((list, parentList)=>{
26
29
  if (!parentList) parentList = list.filter((item)=>item.parentId == '0');
@@ -30,87 +33,113 @@ const Layout = (props)=>{
30
33
  });
31
34
  return parentList;
32
35
  }, []);
33
- return /*#__PURE__*/ _jsx(CollectProviders, {
36
+ const isGatherMenu = !!props.gatherMenuProps;
37
+ return /*#__PURE__*/ _jsxs(CollectProviders, {
34
38
  locale: locale,
35
39
  dark: props.themeSwitchProps.value,
36
40
  pathname: props.pathname,
37
- children: /*#__PURE__*/ _jsx(ProLayout, _object_spread_props(_object_spread({
38
- className: styles.layout,
39
- title: "adminx",
40
- logo: /*#__PURE__*/ _jsx("img", {
41
- src: logoBase64,
42
- alt: "logo"
43
- }),
44
- layout: "mix",
45
- fixSiderbar: true,
46
- menu: {
47
- locale: true,
48
- request: async ()=>{
49
- var _result_data;
50
- const result = await query(userMenuListQuery, {
51
- appCode: props.appCode
52
- }, {
53
- instanceName: iceUrqlInstance.ucenter
41
+ children: [
42
+ /*#__PURE__*/ _jsx(ProLayout, _object_spread_props(_object_spread({
43
+ className: styles.layout,
44
+ headerTitleRender: (logo, title)=>{
45
+ return /*#__PURE__*/ _jsxs(_Fragment, {
46
+ children: [
47
+ isGatherMenu ? /*#__PURE__*/ _jsx(BarsOutlined, {
48
+ rev: undefined,
49
+ style: {
50
+ fontSize: 20,
51
+ marginRight: 10
52
+ },
53
+ onClick: ()=>{
54
+ setOpen(true);
55
+ }
56
+ }) : /*#__PURE__*/ _jsx(_Fragment, {}),
57
+ logo,
58
+ title
59
+ ]
54
60
  });
55
- if ((_result_data = result.data) === null || _result_data === void 0 ? void 0 : _result_data.userMenus.length) {
56
- const meunList = result.data.userMenus.map((item)=>{
57
- return {
58
- key: item.id,
59
- name: item.name,
60
- icon: item.icon ? props.IconFont ? /*#__PURE__*/ _jsx(props.IconFont, {
61
- type: item.icon
62
- }) : /*#__PURE__*/ _jsx("i", {
63
- className: item.icon
64
- }) : undefined,
65
- parentId: item.parentID,
66
- path: item.route
67
- };
61
+ },
62
+ title: "adminx",
63
+ logo: /*#__PURE__*/ _jsx("img", {
64
+ src: logoBase64,
65
+ alt: "logo"
66
+ }),
67
+ layout: "mix",
68
+ fixSiderbar: true,
69
+ suppressSiderWhenMenuEmpty: true,
70
+ menu: isGatherMenu ? /*#__PURE__*/ _jsx(_Fragment, {}) : {
71
+ locale: true,
72
+ request: async ()=>{
73
+ var _result_data;
74
+ const result = await query(userMenuListQuery, {
75
+ appCode: props.appCode
76
+ }, {
77
+ instanceName: iceUrqlInstance.ucenter
68
78
  });
69
- return listFormatTree(meunList);
70
- }
71
- return [];
72
- }
73
- },
74
- location: {
75
- pathname: props.pathname
76
- },
77
- actionsRender: ()=>{
78
- return [
79
- /*#__PURE__*/ _jsx(I18nDropdown, {
80
- onChange: (value)=>{
81
- var _props_i18nProps, _props_i18nProps_onChange;
82
- setLocale(value);
83
- (_props_i18nProps = props.i18nProps) === null || _props_i18nProps === void 0 ? void 0 : (_props_i18nProps_onChange = _props_i18nProps.onChange) === null || _props_i18nProps_onChange === void 0 ? void 0 : _props_i18nProps_onChange.call(_props_i18nProps, value);
79
+ if ((_result_data = result.data) === null || _result_data === void 0 ? void 0 : _result_data.userMenus.length) {
80
+ const meunList = result.data.userMenus.map((item)=>{
81
+ return {
82
+ key: item.id,
83
+ name: item.name,
84
+ icon: item.icon ? props.IconFont ? /*#__PURE__*/ _jsx(props.IconFont, {
85
+ type: item.icon
86
+ }) : /*#__PURE__*/ _jsx("i", {
87
+ className: item.icon
88
+ }) : undefined,
89
+ parentId: item.parentID,
90
+ path: item.route
91
+ };
92
+ });
93
+ return listFormatTree(meunList);
84
94
  }
85
- }),
86
- /*#__PURE__*/ _jsx(TenantDropdown, _object_spread({}, props.tenantProps)),
87
- /*#__PURE__*/ _jsx(AvatarDropdown, _object_spread({}, props.avatarProps)),
88
- /*#__PURE__*/ _jsx(ThemeSwitch, _object_spread({}, props.themeSwitchProps))
89
- ];
90
- },
91
- menuItemRender: (item, defaultDom)=>{
92
- return item.path ? /*#__PURE__*/ _jsxs(_Fragment, {
93
- children: [
94
- /*#__PURE__*/ _jsx("a", {
95
- onClick: ()=>{
96
- var _props_onClickMenuItem;
97
- (_props_onClickMenuItem = props.onClickMenuItem) === null || _props_onClickMenuItem === void 0 ? void 0 : _props_onClickMenuItem.call(props, item, false);
98
- },
99
- children: defaultDom
100
- }),
101
- /*#__PURE__*/ _jsx(OpenWin, {
102
- className: styles.menuIconPopup,
103
- onClick: ()=>{
104
- var _props_onClickMenuItem;
105
- (_props_onClickMenuItem = props.onClickMenuItem) === null || _props_onClickMenuItem === void 0 ? void 0 : _props_onClickMenuItem.call(props, item, true);
95
+ return [];
96
+ }
97
+ },
98
+ location: {
99
+ pathname: props.pathname
100
+ },
101
+ actionsRender: ()=>{
102
+ return [
103
+ /*#__PURE__*/ _jsx(I18nDropdown, {
104
+ onChange: (value)=>{
105
+ var _props_i18nProps, _props_i18nProps_onChange;
106
+ setLocale(value);
107
+ (_props_i18nProps = props.i18nProps) === null || _props_i18nProps === void 0 ? void 0 : (_props_i18nProps_onChange = _props_i18nProps.onChange) === null || _props_i18nProps_onChange === void 0 ? void 0 : _props_i18nProps_onChange.call(_props_i18nProps, value);
106
108
  }
107
- })
108
- ]
109
- }) : defaultDom;
110
- }
111
- }, props.proLayoutProps), {
112
- children: props.children
113
- }))
109
+ }),
110
+ /*#__PURE__*/ _jsx(TenantDropdown, _object_spread({}, props.tenantProps)),
111
+ /*#__PURE__*/ _jsx(AvatarDropdown, _object_spread({}, props.avatarProps)),
112
+ /*#__PURE__*/ _jsx(ThemeSwitch, _object_spread({}, props.themeSwitchProps))
113
+ ];
114
+ },
115
+ menuItemRender: (item, defaultDom)=>{
116
+ return item.path ? /*#__PURE__*/ _jsxs(_Fragment, {
117
+ children: [
118
+ /*#__PURE__*/ _jsx("a", {
119
+ onClick: ()=>{
120
+ var _props_onClickMenuItem;
121
+ (_props_onClickMenuItem = props.onClickMenuItem) === null || _props_onClickMenuItem === void 0 ? void 0 : _props_onClickMenuItem.call(props, item, false);
122
+ },
123
+ children: defaultDom
124
+ }),
125
+ /*#__PURE__*/ _jsx(OpenWin, {
126
+ className: styles.menuIconPopup,
127
+ onClick: ()=>{
128
+ var _props_onClickMenuItem;
129
+ (_props_onClickMenuItem = props.onClickMenuItem) === null || _props_onClickMenuItem === void 0 ? void 0 : _props_onClickMenuItem.call(props, item, true);
130
+ }
131
+ })
132
+ ]
133
+ }) : defaultDom;
134
+ }
135
+ }, props.proLayoutProps), {
136
+ children: props.children
137
+ })),
138
+ /*#__PURE__*/ _jsx(GatherMenu, _object_spread_props(_object_spread({}, props.gatherMenuProps), {
139
+ open: open,
140
+ onChangeOpen: setOpen
141
+ }))
142
+ ]
114
143
  });
115
144
  };
116
145
  export default Layout;
@@ -1 +1 @@
1
- {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\layout\\index.tsx"],"sourcesContent":["import { MenuDataItem, ProLayout, ProLayoutProps } from '@ant-design/pro-layout';\r\nimport I18nDropdown, { I18nDropdownProps } from '../i18n-dropdown';\r\nimport TenantDropdown, { TenantDropdownProps } from '../tenant-dropdown';\r\nimport AvatarDropdown, { AvatarDropdownProps } from '../avatar-dropdown';\r\nimport ThemeSwitch, { ThemeSwitchProps } from '../theme-switch';\r\nimport styles from './layout.module.css';\r\nimport { ReactNode, useCallback, useState } from 'react';\r\nimport { UserMenuListQuery, UserMenuListQueryVariables } from '@knockout-js/api';\r\nimport { LocaleType } from '../locale';\r\nimport { CollectProviders } from '..';\r\nimport { gql, query } from '@knockout-js/ice-urql/request';\r\nimport { iceUrqlInstance } from '..';\r\nimport { OpenWin } from '../icons';\r\nimport { IconFontProps } from '@ant-design/icons/lib/components/IconFont';\r\nimport { logoBase64 } from './logo';\r\n\r\nexport interface LayoutProps {\r\n /**\r\n * 应用code\r\n */\r\n appCode: string;\r\n /**\r\n * 传递动态的 location.pathname\r\n */\r\n pathname: string;\r\n /**\r\n * 菜单启用iconfont\r\n */\r\n IconFont?: React.FC<IconFontProps<string>>;\r\n /**\r\n * I18nDropdown组件对应的参数\r\n */\r\n i18nProps?: I18nDropdownProps;\r\n /**\r\n * TenantDropdown组件对应的参数\r\n */\r\n tenantProps: TenantDropdownProps;\r\n /**\r\n * AvatarDropdown组件对应的参数\r\n */\r\n avatarProps: AvatarDropdownProps;\r\n /**\r\n * ThemeSwitch组件对应的参数\r\n */\r\n themeSwitchProps: ThemeSwitchProps;\r\n /**\r\n * ProLayout组件对应的参数\r\n */\r\n proLayoutProps?: ProLayoutProps;\r\n /**\r\n * 菜单点击返回 (item: MenuDataItem,isOpen?: boolean) => void;\r\n */\r\n onClickMenuItem?: (item: MenuDataItem & {\r\n isUrl: boolean;\r\n onClick: () => void;\r\n },\r\n isOpen?: boolean) => void;\r\n /**\r\n * 默认插槽\r\n */\r\n children?: ReactNode;\r\n\r\n}\r\n\r\nconst userMenuListQuery = gql(/* GraphQL */`query userMenuList($appCode:String!){\r\n userMenus(appCode: $appCode){\r\n id,parentID,kind,name,comments,displaySort,icon,route\r\n }\r\n}`);\r\n\r\n\r\nconst Layout = (props: LayoutProps) => {\r\n\r\n const [locale, setLocale] = useState(LocaleType.zhCN);\r\n\r\n // 根据列表格式化成菜单树结构\r\n const listFormatTree = useCallback((list: MenuDataItem[], parentList?: MenuDataItem[]) => {\r\n if (!parentList) {\r\n parentList = list.filter(item => item.parentId == '0');\r\n }\r\n parentList.forEach((pItem) => {\r\n let children = list.filter(\r\n (allItem) => allItem.parentId == pItem.key,\r\n );\r\n if (children && children.length) {\r\n pItem.children = listFormatTree(list, children);\r\n }\r\n });\r\n return parentList;\r\n }, [])\r\n\r\n return (\r\n <CollectProviders\r\n locale={locale}\r\n dark={props.themeSwitchProps.value}\r\n pathname={props.pathname}\r\n >\r\n <ProLayout\r\n className={styles.layout}\r\n title='adminx'\r\n logo={<img src={logoBase64} alt=\"logo\" />}\r\n layout=\"mix\"\r\n fixSiderbar\r\n menu={{\r\n locale: true,\r\n request: async () => {\r\n const result = await query<UserMenuListQuery, UserMenuListQueryVariables>(userMenuListQuery, {\r\n appCode: props.appCode\r\n }, { instanceName: iceUrqlInstance.ucenter });\r\n if (result.data?.userMenus.length) {\r\n const meunList = result.data.userMenus.map(item => {\r\n return {\r\n key: item.id,\r\n name: item.name,\r\n icon: item.icon ? props.IconFont ? <props.IconFont type={item.icon} /> : <i className={item.icon} /> : undefined,\r\n parentId: item.parentID,\r\n path: item.route,\r\n } as MenuDataItem\r\n })\r\n\r\n return listFormatTree(meunList);\r\n }\r\n return [];\r\n },\r\n }}\r\n location={{\r\n pathname: props.pathname\r\n }}\r\n actionsRender={() => [\r\n <I18nDropdown onChange={(value) => {\r\n setLocale(value);\r\n props.i18nProps?.onChange?.(value)\r\n }} />,\r\n <TenantDropdown {...props.tenantProps} />,\r\n <AvatarDropdown {...props.avatarProps} />,\r\n <ThemeSwitch {...props.themeSwitchProps} />,\r\n ]}\r\n menuItemRender={(item, defaultDom) => (item.path ? <>\r\n <a\r\n onClick={() => {\r\n props.onClickMenuItem?.(item, false)\r\n }}\r\n >{defaultDom}</a>\r\n <OpenWin\r\n className={styles.menuIconPopup}\r\n onClick={() => {\r\n props.onClickMenuItem?.(item, true)\r\n }}\r\n />\r\n </>\r\n : defaultDom)}\r\n {...props.proLayoutProps}\r\n >\r\n {props.children}\r\n </ProLayout>\r\n </CollectProviders>\r\n )\r\n}\r\n\r\nexport default Layout\r\n"],"names":["ProLayout","I18nDropdown","TenantDropdown","AvatarDropdown","ThemeSwitch","styles","useCallback","useState","LocaleType","CollectProviders","gql","query","iceUrqlInstance","OpenWin","logoBase64","userMenuListQuery","Layout","props","locale","setLocale","zhCN","listFormatTree","list","parentList","filter","item","parentId","forEach","pItem","children","allItem","key","length","dark","themeSwitchProps","value","pathname","className","layout","title","logo","img","src","alt","fixSiderbar","menu","request","result","appCode","instanceName","ucenter","data","userMenus","meunList","map","id","name","icon","IconFont","type","i","undefined","parentID","path","route","location","actionsRender","onChange","i18nProps","tenantProps","avatarProps","menuItemRender","defaultDom","a","onClick","onClickMenuItem","menuIconPopup","proLayoutProps"],"mappings":";;;AAAA,SAAuBA,SAAS,QAAwB,yBAAyB;AACjF,OAAOC,kBAAyC,yBAAmB;AAC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U;4BACCC,SAAS,IAAM;oCACbzD;gCAAAA,CAAAA,yBAAAA,MAAM0D,eAAe,cAArB1D,oCAAAA,KAAAA,IAAAA,uBAAAA,KAAAA,OAAwBQ,MAAM,KAAK;4BACrC;sCACA+C;;sCACF,KAAC3D;4BACCwB,WAAWhC,OAAOuE,aAAa;4BAC/BF,SAAS,IAAM;oCACbzD;gCAAAA,CAAAA,yBAAAA,MAAM0D,eAAe,cAArB1D,oCAAAA,KAAAA,IAAAA,uBAAAA,KAAAA,OAAwBQ,MAAM,IAAI;4BACpC;;;qBAGA+C,UAAU;;WACVvD,MAAM4D,cAAc;sBAEvB5D,MAAMY,QAAQ;;;AAIvB;AAEA,eAAeb,OAAM"}
1
+ {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\layout\\index.tsx"],"sourcesContent":["import { MenuDataItem, ProLayout, ProLayoutProps } from '@ant-design/pro-layout';\r\nimport I18nDropdown, { I18nDropdownProps } from '../i18n-dropdown';\r\nimport TenantDropdown, { TenantDropdownProps } from '../tenant-dropdown';\r\nimport AvatarDropdown, { AvatarDropdownProps } from '../avatar-dropdown';\r\nimport ThemeSwitch, { ThemeSwitchProps } from '../theme-switch';\r\nimport styles from './layout.module.css';\r\nimport { ReactNode, useCallback, useState } from 'react';\r\nimport { UserMenuListQuery, UserMenuListQueryVariables } from '@knockout-js/api';\r\nimport { LocaleType } from '../locale';\r\nimport { CollectProviders } from '..';\r\nimport { gql, query } from '@knockout-js/ice-urql/request';\r\nimport { iceUrqlInstance } from '..';\r\nimport { OpenWin } from '../icons';\r\nimport { IconFontProps } from '@ant-design/icons/lib/components/IconFont';\r\nimport { logoBase64 } from './logo';\r\nimport GatherMenu, { GatherMenuProps } from '../gather-menu';\r\nimport { BarsOutlined } from '@ant-design/icons';\r\n\r\nexport interface LayoutProps {\r\n /**\r\n * 应用code\r\n */\r\n appCode: string;\r\n /**\r\n * 传递动态的 location.pathname\r\n */\r\n pathname: string;\r\n /**\r\n * 菜单启用iconfont\r\n */\r\n IconFont?: React.FC<IconFontProps<string>>;\r\n /**\r\n * 集成菜单\r\n */\r\n gatherMenuProps?: GatherMenuProps;\r\n /**\r\n * I18nDropdown组件对应的参数\r\n */\r\n i18nProps?: I18nDropdownProps;\r\n /**\r\n * TenantDropdown组件对应的参数\r\n */\r\n tenantProps: TenantDropdownProps;\r\n /**\r\n * AvatarDropdown组件对应的参数\r\n */\r\n avatarProps: AvatarDropdownProps;\r\n /**\r\n * ThemeSwitch组件对应的参数\r\n */\r\n themeSwitchProps: ThemeSwitchProps;\r\n /**\r\n * ProLayout组件对应的参数\r\n */\r\n proLayoutProps?: ProLayoutProps;\r\n /**\r\n * 菜单点击返回 (item: MenuDataItem,isOpen?: boolean) => void;\r\n */\r\n onClickMenuItem?: (item: MenuDataItem & {\r\n isUrl: boolean;\r\n onClick: () => void;\r\n },\r\n isOpen?: boolean) => void;\r\n /**\r\n * 默认插槽\r\n */\r\n children?: ReactNode;\r\n\r\n}\r\n\r\nconst userMenuListQuery = gql(/* GraphQL */`query userMenuList($appCode:String!){\r\n userMenus(appCode: $appCode){\r\n id,parentID,kind,name,comments,displaySort,icon,route\r\n }\r\n}`);\r\n\r\n\r\nconst Layout = (props: LayoutProps) => {\r\n\r\n const [locale, setLocale] = useState(LocaleType.zhCN);\r\n const [open, setOpen] = useState(false);\r\n\r\n // 根据列表格式化成菜单树结构\r\n const listFormatTree = useCallback((list: MenuDataItem[], parentList?: MenuDataItem[]) => {\r\n if (!parentList) {\r\n parentList = list.filter(item => item.parentId == '0');\r\n }\r\n parentList.forEach((pItem) => {\r\n let children = list.filter(\r\n (allItem) => allItem.parentId == pItem.key,\r\n );\r\n if (children && children.length) {\r\n pItem.children = listFormatTree(list, children);\r\n }\r\n });\r\n return parentList;\r\n }, [])\r\n\r\n const isGatherMenu = !!props.gatherMenuProps;\r\n\r\n return (\r\n <CollectProviders\r\n locale={locale}\r\n dark={props.themeSwitchProps.value}\r\n pathname={props.pathname}\r\n >\r\n <ProLayout\r\n className={styles.layout}\r\n headerTitleRender={(logo, title) => {\r\n return <>\r\n {isGatherMenu ? <BarsOutlined\r\n rev={undefined}\r\n style={{ fontSize: 20, marginRight: 10 }}\r\n onClick={() => {\r\n setOpen(true);\r\n }}\r\n /> : <></>}\r\n {logo}\r\n {title}\r\n </>\r\n }}\r\n title='adminx'\r\n logo={<img src={logoBase64} alt=\"logo\" />}\r\n layout=\"mix\"\r\n fixSiderbar\r\n suppressSiderWhenMenuEmpty\r\n menu={isGatherMenu ? <></> : {\r\n locale: true,\r\n request: async () => {\r\n const result = await query<UserMenuListQuery, UserMenuListQueryVariables>(userMenuListQuery, {\r\n appCode: props.appCode\r\n }, { instanceName: iceUrqlInstance.ucenter });\r\n if (result.data?.userMenus.length) {\r\n const meunList = result.data.userMenus.map(item => {\r\n return {\r\n key: item.id,\r\n name: item.name,\r\n icon: item.icon ? props.IconFont ? <props.IconFont type={item.icon} /> : <i className={item.icon} /> : undefined,\r\n parentId: item.parentID,\r\n path: item.route,\r\n } as MenuDataItem\r\n })\r\n\r\n return listFormatTree(meunList);\r\n }\r\n return [];\r\n },\r\n }}\r\n location={{\r\n pathname: props.pathname\r\n }}\r\n actionsRender={() => [\r\n <I18nDropdown onChange={(value) => {\r\n setLocale(value);\r\n props.i18nProps?.onChange?.(value)\r\n }} />,\r\n <TenantDropdown {...props.tenantProps} />,\r\n <AvatarDropdown {...props.avatarProps} />,\r\n <ThemeSwitch {...props.themeSwitchProps} />,\r\n ]}\r\n menuItemRender={(item, defaultDom) => (item.path ? <>\r\n <a\r\n onClick={() => {\r\n props.onClickMenuItem?.(item, false)\r\n }}\r\n >{defaultDom}</a>\r\n <OpenWin\r\n className={styles.menuIconPopup}\r\n onClick={() => {\r\n props.onClickMenuItem?.(item, true)\r\n }}\r\n />\r\n </>\r\n : defaultDom)}\r\n {...props.proLayoutProps}\r\n >\r\n {props.children}\r\n </ProLayout>\r\n <GatherMenu\r\n {...props.gatherMenuProps}\r\n open={open}\r\n onChangeOpen={setOpen}\r\n />\r\n </CollectProviders>\r\n )\r\n}\r\n\r\nexport default Layout\r\n"],"names":["ProLayout","I18nDropdown","TenantDropdown","AvatarDropdown","ThemeSwitch","styles","useCallback","useState","LocaleType","CollectProviders","gql","query","iceUrqlInstance","OpenWin","logoBase64","GatherMenu","BarsOutlined","userMenuListQuery","Layout","props","locale","setLocale","zhCN","open","setOpen","listFormatTree","list","parentList","filter","item","parentId","forEach","pItem","children","allItem","key","length","isGatherMenu","gatherMenuProps","dark","themeSwitchProps","value","pathname","className","layout","headerTitleRender","logo","title","rev","undefined","style","fontSize","marginRight","onClick","img","src","alt","fixSiderbar","suppressSiderWhenMenuEmpty","menu","request","result","appCode","instanceName","ucenter","data","userMenus","meunList","map","id","name","icon","IconFont","type","i","parentID","path","route","location","actionsRender","onChange","i18nProps","tenantProps","avatarProps","menuItemRender","defaultDom","a","onClickMenuItem","menuIconPopup","proLayoutProps","onChangeOpen"],"mappings":";;;AAAA,SAAuBA,SAAS,QAAwB,yBAAyB;AACjF,OAAOC,kBAAyC,yBAAmB;AACnE,OAAOC,oBAA6C,2BAAqB;AACzE,OAAOC,oBAA6C,2BAAqB;AACzE,OAAOC,iBAAuC,wBAAkB;AAChE,OAAOC,YAAY,sBAAsB;AACzC,SAAoBC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAEzD,SAASC,UAAU,QAAQ,kBAAY;AACvC,SAASC,gBAAgB,QAAQ,WAAK;AACtC,SAASC,GAAG,EAAEC,KAAK,QAAQ,gCAAgC;AAC3D,SAASC,eAAe,QAAQ,WAAK;AACrC,SAASC,OAAO,QAAQ,iBAAW;AAEnC,SAASC,UAAU,QAAQ,SAAS;AACpC,OAAOC,gBAAqC,uBAAiB;AAC7D,SAASC,YAAY,QAAQ,oBAAoB;AAsDjD,MAAMC,oBAAoBP,IAAI,WAAW,GAAE,CAAC;;;;CAI3C,CAAC;AAGF,MAAMQ,SAAS,CAACC,QAAuB;IAErC,MAAM,CAAC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BAAAA,KAAAA,OAAwBU,MAAM,KAAK;gCACrC;0CACAwD;;0CACF,KAACxE;gCACC8B,WAAWtC,OAAOmF,aAAa;gCAC/BnC,SAAS,IAAM;wCACblC;oCAAAA,CAAAA,yBAAAA,MAAMoE,eAAe,cAArBpE,oCAAAA,KAAAA,IAAAA,uBAAAA,KAAAA,OAAwBU,MAAM,IAAI;gCACpC;;;yBAGAwD,UAAU;;eACVlE,MAAMsE,cAAc;0BAEvBtE,MAAMc,QAAQ;;0BAEjB,KAAClB,oDACKI,MAAMmB,eAAe;gBACzBf,MAAMA;gBACNmE,cAAclE;;;;AAItB;AAEA,eAAeN,OAAM"}
@@ -2,12 +2,14 @@ import ThemeSwitch from "../theme-switch/locale/en_US";
2
2
  import LeavePrompt from "../leave-prompt/locale/en_US";
3
3
  import AvatarDropdown from "../avatar-dropdown/locale/en_US";
4
4
  import TenantDropdown from "../tenant-dropdown/locale/en_US";
5
+ import GatherMenu from "../gather-menu/locale/en_US";
5
6
  const localeValues = {
6
7
  locale: 'en-us',
7
8
  ThemeSwitch,
8
9
  LeavePrompt,
9
10
  AvatarDropdown,
10
- TenantDropdown
11
+ TenantDropdown,
12
+ GatherMenu
11
13
  };
12
14
  export default localeValues;
13
15
 
@@ -1 +1 @@
1
- {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\locale\\en_US.ts"],"sourcesContent":["import { Locale } from \".\";\r\nimport ThemeSwitch from \"../theme-switch/locale/en_US\";\r\nimport LeavePrompt from \"../leave-prompt/locale/en_US\";\r\nimport AvatarDropdown from \"../avatar-dropdown/locale/en_US\";\r\nimport TenantDropdown from \"../tenant-dropdown/locale/en_US\";\r\n\r\nconst localeValues: Locale = {\r\n locale: 'en-us',\r\n ThemeSwitch,\r\n LeavePrompt,\r\n AvatarDropdown,\r\n TenantDropdown,\r\n}\r\n\r\nexport default localeValues\r\n"],"names":["ThemeSwitch","LeavePrompt","AvatarDropdown","TenantDropdown","localeValues","locale"],"mappings":"AACA,OAAOA,iBAAiB,+BAA+B;AACvD,OAAOC,iBAAiB,+BAA+B;AACvD,OAAOC,oBAAoB,kCAAkC;AAC7D,OAAOC,oBAAoB,kCAAkC;AAE7D,MAAMC,eAAuB;IAC3BC,QAAQ;IACRL;IACAC;IACAC;IACAC;AACF;AAEA,eAAeC,aAAY"}
1
+ {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\locale\\en_US.ts"],"sourcesContent":["import { Locale } from \".\";\r\nimport ThemeSwitch from \"../theme-switch/locale/en_US\";\r\nimport LeavePrompt from \"../leave-prompt/locale/en_US\";\r\nimport AvatarDropdown from \"../avatar-dropdown/locale/en_US\";\r\nimport TenantDropdown from \"../tenant-dropdown/locale/en_US\";\r\nimport GatherMenu from \"../gather-menu/locale/en_US\";\r\n\r\nconst localeValues: Locale = {\r\n locale: 'en-us',\r\n ThemeSwitch,\r\n LeavePrompt,\r\n AvatarDropdown,\r\n TenantDropdown,\r\n GatherMenu,\r\n}\r\n\r\nexport default localeValues\r\n"],"names":["ThemeSwitch","LeavePrompt","AvatarDropdown","TenantDropdown","GatherMenu","localeValues","locale"],"mappings":"AACA,OAAOA,iBAAiB,+BAA+B;AACvD,OAAOC,iBAAiB,+BAA+B;AACvD,OAAOC,oBAAoB,kCAAkC;AAC7D,OAAOC,oBAAoB,kCAAkC;AAC7D,OAAOC,gBAAgB,8BAA8B;AAErD,MAAMC,eAAuB;IAC3BC,QAAQ;IACRN;IACAC;IACAC;IACAC;IACAC;AACF;AAEA,eAAeC,aAAY"}
@@ -3,12 +3,14 @@ import { TenantDropdownLocale } from '../tenant-dropdown';
3
3
  import { ThemeSwitchLocale } from '../theme-switch';
4
4
  import { LeavePromptLocale } from '../leave-prompt';
5
5
  import { AvatarDropdownLocale } from '../avatar-dropdown';
6
+ import { GatherMenuLocale } from "../gather-menu";
6
7
  export interface Locale {
7
8
  locale: string;
8
9
  ThemeSwitch: ThemeSwitchLocale;
9
10
  LeavePrompt: LeavePromptLocale;
10
11
  AvatarDropdown: AvatarDropdownLocale;
11
12
  TenantDropdown: TenantDropdownLocale;
13
+ GatherMenu: GatherMenuLocale;
12
14
  }
13
15
  export declare enum LocaleType {
14
16
  zhCN = "zh-CN",
@@ -1 +1 @@
1
- {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\locale\\index.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\r\nimport zhCN from \"./zh_CN\";\r\nimport enUS from \"./en_US\";\r\nimport { TenantDropdownLocale } from '../tenant-dropdown';\r\nimport { ThemeSwitchLocale } from '../theme-switch';\r\nimport { LeavePromptLocale } from '../leave-prompt';\r\nimport { AvatarDropdownLocale } from '../avatar-dropdown';\r\n\r\nexport interface Locale {\r\n locale: string;\r\n ThemeSwitch: ThemeSwitchLocale;\r\n LeavePrompt: LeavePromptLocale;\r\n AvatarDropdown: AvatarDropdownLocale;\r\n TenantDropdown: TenantDropdownLocale;\r\n}\r\n\r\nexport enum LocaleType {\r\n zhCN = \"zh-CN\",\r\n enUS = \"en-US\",\r\n}\r\n\r\nexport interface BasicProviderProps {\r\n locale: LocaleType;\r\n children?: React.ReactNode;\r\n}\r\n\r\n// 定义语言上下文\r\nexport const BasicContext = createContext<BasicProviderProps>({\r\n locale: LocaleType.zhCN\r\n});\r\n\r\n/**\r\n * 组件上使用\r\n */\r\nexport default (props: BasicProviderProps) => {\r\n const { locale, children } = props;\r\n return <BasicContext.Provider value={{ locale: locale }}>{children}</BasicContext.Provider>\r\n}\r\n\r\nexport type LocaleComponentName = Exclude<keyof Locale, 'locale'>;\r\n/**\r\n * hook\r\n * @param componentName\r\n * @returns\r\n */\r\nexport const useLocale = <C extends LocaleComponentName>(componentName: C) => {\r\n const ctx = useContext<BasicProviderProps>(BasicContext);\r\n if (ctx.locale === LocaleType.enUS) {\r\n return { ...enUS[componentName] }\r\n }\r\n // 默认zhCN\r\n return { ...zhCN[componentName] }\r\n}\r\n"],"names":["createContext","useContext","zhCN","enUS","LocaleType","BasicContext","locale","props","children","Provider","value","useLocale","componentName","ctx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,OAAOC,UAAU,UAAU;AAC3B,OAAOC,UAAU,UAAU;WAcpB;UAAKC,UAAU;IAAVA,WACVF,UAAO;IADGE,WAEVD,UAAO;GAFGC,eAAAA;AAUZ,UAAU;AACV,OAAO,MAAMC,6BAAeL,cAAkC;IAC5DM,QAAQF,WAAWF,IAAI;AACzB,GAAG;AAEH;;CAEC,GACD,eAAe,CAAA,CAACK,QAA8B;IAC5C,MAAM,EAAED,OAAM,EAAEE,SAAQ,EAAE,GAAGD;IAC7B,qBAAO,KAACF,aAAaI,QAAQ;QAACC,OAAO;YAAEJ,QAAQA;QAAO;kBAAIE;;AAC5D,CAAA,EAAC;AAGD;;;;CAIC,GACD,OAAO,MAAMG,YAAY,CAAgCC,gBAAqB;IAC5E,MAAMC,MAAMZ,WAA+BI;IAC3C,IAAIQ,IAAIP,MAAM,KAAKF,WAAWD,IAAI,EAChC,OAAO,mBAAKA,IAAI,CAACS,cAAc;IAEjC,SAAS;IACT,OAAO,mBAAKV,IAAI,CAACU,cAAc;AACjC,EAAC"}
1
+ {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\locale\\index.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\r\nimport zhCN from \"./zh_CN\";\r\nimport enUS from \"./en_US\";\r\nimport { TenantDropdownLocale } from '../tenant-dropdown';\r\nimport { ThemeSwitchLocale } from '../theme-switch';\r\nimport { LeavePromptLocale } from '../leave-prompt';\r\nimport { AvatarDropdownLocale } from '../avatar-dropdown';\r\nimport { GatherMenuLocale } from \"../gather-menu\";\r\n\r\nexport interface Locale {\r\n locale: string;\r\n ThemeSwitch: ThemeSwitchLocale;\r\n LeavePrompt: LeavePromptLocale;\r\n AvatarDropdown: AvatarDropdownLocale;\r\n TenantDropdown: TenantDropdownLocale;\r\n GatherMenu: GatherMenuLocale;\r\n}\r\n\r\nexport enum LocaleType {\r\n zhCN = \"zh-CN\",\r\n enUS = \"en-US\",\r\n}\r\n\r\nexport interface BasicProviderProps {\r\n locale: LocaleType;\r\n children?: React.ReactNode;\r\n}\r\n\r\n// 定义语言上下文\r\nexport const BasicContext = createContext<BasicProviderProps>({\r\n locale: LocaleType.zhCN\r\n});\r\n\r\n/**\r\n * 组件上使用\r\n */\r\nexport default (props: BasicProviderProps) => {\r\n const { locale, children } = props;\r\n return <BasicContext.Provider value={{ locale: locale }}>{children}</BasicContext.Provider>\r\n}\r\n\r\nexport type LocaleComponentName = Exclude<keyof Locale, 'locale'>;\r\n/**\r\n * hook\r\n * @param componentName\r\n * @returns\r\n */\r\nexport const useLocale = <C extends LocaleComponentName>(componentName: C) => {\r\n const ctx = useContext<BasicProviderProps>(BasicContext);\r\n if (ctx.locale === LocaleType.enUS) {\r\n return { ...enUS[componentName] }\r\n }\r\n // 默认zhCN\r\n return { ...zhCN[componentName] }\r\n}\r\n"],"names":["createContext","useContext","zhCN","enUS","LocaleType","BasicContext","locale","props","children","Provider","value","useLocale","componentName","ctx"],"mappings":";;AAAA,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,OAAOC,UAAU,UAAU;AAC3B,OAAOC,UAAU,UAAU;WAgBpB;UAAKC,UAAU;IAAVA,WACVF,UAAO;IADGE,WAEVD,UAAO;GAFGC,eAAAA;AAUZ,UAAU;AACV,OAAO,MAAMC,6BAAeL,cAAkC;IAC5DM,QAAQF,WAAWF,IAAI;AACzB,GAAG;AAEH;;CAEC,GACD,eAAe,CAAA,CAACK,QAA8B;IAC5C,MAAM,EAAED,OAAM,EAAEE,SAAQ,EAAE,GAAGD;IAC7B,qBAAO,KAACF,aAAaI,QAAQ;QAACC,OAAO;YAAEJ,QAAQA;QAAO;kBAAIE;;AAC5D,CAAA,EAAC;AAGD;;;;CAIC,GACD,OAAO,MAAMG,YAAY,CAAgCC,gBAAqB;IAC5E,MAAMC,MAAMZ,WAA+BI;IAC3C,IAAIQ,IAAIP,MAAM,KAAKF,WAAWD,IAAI,EAChC,OAAO,mBAAKA,IAAI,CAACS,cAAc;IAEjC,SAAS;IACT,OAAO,mBAAKV,IAAI,CAACU,cAAc;AACjC,EAAC"}
@@ -2,12 +2,14 @@ import ThemeSwitch from "../theme-switch/locale/zh_CN";
2
2
  import LeavePrompt from "../leave-prompt/locale/zh_CN";
3
3
  import AvatarDropdown from "../avatar-dropdown/locale/zh_CN";
4
4
  import TenantDropdown from "../tenant-dropdown/locale/zh_CN";
5
+ import GatherMenu from "../gather-menu/locale/zh_CN";
5
6
  const localeValues = {
6
7
  locale: 'zh-cn',
7
8
  ThemeSwitch,
8
9
  LeavePrompt,
9
10
  AvatarDropdown,
10
- TenantDropdown
11
+ TenantDropdown,
12
+ GatherMenu
11
13
  };
12
14
  export default localeValues;
13
15
 
@@ -1 +1 @@
1
- {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\locale\\zh_CN.ts"],"sourcesContent":["import { Locale } from \".\";\r\nimport ThemeSwitch from \"../theme-switch/locale/zh_CN\";\r\nimport LeavePrompt from \"../leave-prompt/locale/zh_CN\";\r\nimport AvatarDropdown from \"../avatar-dropdown/locale/zh_CN\";\r\nimport TenantDropdown from \"../tenant-dropdown/locale/zh_CN\";\r\n\r\nconst localeValues: Locale = {\r\n locale: 'zh-cn',\r\n ThemeSwitch,\r\n LeavePrompt,\r\n AvatarDropdown,\r\n TenantDropdown,\r\n}\r\n\r\nexport default localeValues\r\n"],"names":["ThemeSwitch","LeavePrompt","AvatarDropdown","TenantDropdown","localeValues","locale"],"mappings":"AACA,OAAOA,iBAAiB,+BAA+B;AACvD,OAAOC,iBAAiB,+BAA+B;AACvD,OAAOC,oBAAoB,kCAAkC;AAC7D,OAAOC,oBAAoB,kCAAkC;AAE7D,MAAMC,eAAuB;IAC3BC,QAAQ;IACRL;IACAC;IACAC;IACAC;AACF;AAEA,eAAeC,aAAY"}
1
+ {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\locale\\zh_CN.ts"],"sourcesContent":["import { Locale } from \".\";\r\nimport ThemeSwitch from \"../theme-switch/locale/zh_CN\";\r\nimport LeavePrompt from \"../leave-prompt/locale/zh_CN\";\r\nimport AvatarDropdown from \"../avatar-dropdown/locale/zh_CN\";\r\nimport TenantDropdown from \"../tenant-dropdown/locale/zh_CN\";\r\nimport GatherMenu from \"../gather-menu/locale/zh_CN\";\r\n\r\nconst localeValues: Locale = {\r\n locale: 'zh-cn',\r\n ThemeSwitch,\r\n LeavePrompt,\r\n AvatarDropdown,\r\n TenantDropdown,\r\n GatherMenu,\r\n}\r\n\r\nexport default localeValues\r\n"],"names":["ThemeSwitch","LeavePrompt","AvatarDropdown","TenantDropdown","GatherMenu","localeValues","locale"],"mappings":"AACA,OAAOA,iBAAiB,+BAA+B;AACvD,OAAOC,iBAAiB,+BAA+B;AACvD,OAAOC,oBAAoB,kCAAkC;AAC7D,OAAOC,oBAAoB,kCAAkC;AAC7D,OAAOC,gBAAgB,8BAA8B;AAErD,MAAMC,eAAuB;IAC3BC,QAAQ;IACRN;IACAC;IACAC;IACAC;IACAC;AACF;AAEA,eAAeC,aAAY"}
@@ -0,0 +1,18 @@
1
+ import { ModalProps as AntdModalProps } from "antd";
2
+ import { ReactNode } from "react";
3
+ export type ModalProps = AntdModalProps & {
4
+ /**
5
+ * 是否头部可拖拽
6
+ */
7
+ isDraggable?: boolean;
8
+ /**
9
+ * 是否满屏
10
+ */
11
+ defaultScreenful?: boolean;
12
+ /**
13
+ * 全屏图标
14
+ */
15
+ screenfulIcon?: ReactNode | false;
16
+ };
17
+ declare const Modal: (props: ModalProps) => JSX.Element;
18
+ export default Modal;
@@ -0,0 +1,89 @@
1
+ import _object_spread from "@swc/helpers/src/_object_spread.mjs";
2
+ import _object_spread_props from "@swc/helpers/src/_object_spread_props.mjs";
3
+ import _object_without_properties from "@swc/helpers/src/_object_without_properties.mjs";
4
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
5
+ import { ExpandOutlined } from "@ant-design/icons";
6
+ import { Modal as AntdModal, Button } from "antd";
7
+ import { useRef, useState } from "react";
8
+ import Draggable from "react-draggable";
9
+ import styles from "./index.module.css";
10
+ const Modal = (props)=>{
11
+ const { width , style , title , defaultScreenful , isDraggable , screenfulIcon } = props, restProps = _object_without_properties(props, [
12
+ "width",
13
+ "style",
14
+ "title",
15
+ "defaultScreenful",
16
+ "isDraggable",
17
+ "screenfulIcon"
18
+ ]);
19
+ const [screenful, setScreenful] = useState(defaultScreenful !== null && defaultScreenful !== void 0 ? defaultScreenful : false);
20
+ const [disabled, setDisabled] = useState(true);
21
+ const [bounds, setBounds] = useState({
22
+ left: 0,
23
+ top: 0,
24
+ bottom: 0,
25
+ right: 0
26
+ });
27
+ const draggleRef = useRef(null);
28
+ return /*#__PURE__*/ _jsx(AntdModal, _object_spread_props(_object_spread({}, restProps), {
29
+ className: screenful ? styles.screenfulModal : undefined,
30
+ width: screenful ? 'auto' : width,
31
+ style: screenful ? {
32
+ top: 0
33
+ } : style,
34
+ title: /*#__PURE__*/ _jsxs("div", {
35
+ className: screenful ? "" : styles.modal,
36
+ onMouseOver: ()=>{
37
+ if (screenful) {
38
+ setDisabled(true);
39
+ return;
40
+ }
41
+ if (disabled) setDisabled(false);
42
+ },
43
+ onMouseOut: ()=>{
44
+ setDisabled(true);
45
+ },
46
+ children: [
47
+ title,
48
+ screenfulIcon === false ? /*#__PURE__*/ _jsx(_Fragment, {}) : /*#__PURE__*/ _jsx(Button, {
49
+ className: styles.screenfulIcon,
50
+ type: "text",
51
+ size: "small",
52
+ onClick: (event)=>{
53
+ event.stopPropagation();
54
+ setScreenful(!screenful);
55
+ },
56
+ children: screenfulIcon ? screenfulIcon : /*#__PURE__*/ _jsx(ExpandOutlined, {
57
+ rev: undefined
58
+ })
59
+ })
60
+ ]
61
+ }),
62
+ modalRender: (modal)=>{
63
+ return screenful ? modal : isDraggable === false ? modal : /*#__PURE__*/ _jsx(Draggable, {
64
+ disabled: disabled,
65
+ bounds: bounds,
66
+ nodeRef: draggleRef,
67
+ onStart: (event, uiData)=>{
68
+ var _draggleRef_current;
69
+ const { clientWidth , clientHeight } = window.document.documentElement;
70
+ const targetRect = (_draggleRef_current = draggleRef.current) === null || _draggleRef_current === void 0 ? void 0 : _draggleRef_current.getBoundingClientRect();
71
+ if (!targetRect) return;
72
+ setBounds({
73
+ left: -targetRect.left + uiData.x,
74
+ right: clientWidth - (targetRect.right - uiData.x),
75
+ top: -targetRect.top + uiData.y,
76
+ bottom: clientHeight - (targetRect.bottom - uiData.y)
77
+ });
78
+ },
79
+ children: /*#__PURE__*/ _jsx("div", {
80
+ ref: draggleRef,
81
+ children: modal
82
+ })
83
+ });
84
+ }
85
+ }));
86
+ };
87
+ export default Modal;
88
+
89
+ //# sourceMappingURL=D:\codeing\git\github\knockout-js\packages\layout\es2017\components\modal\index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["D:\\codeing\\git\\github\\knockout-js\\packages\\layout\\src\\components\\modal\\index.tsx"],"sourcesContent":["import { ExpandOutlined } from \"@ant-design/icons\";\r\nimport { Modal as AntdModal, Button, ModalProps as AntdModalProps } from \"antd\";\r\nimport { ReactNode, useRef, useState } from \"react\";\r\nimport Draggable from 'react-draggable';\r\nimport styles from './index.module.css';\r\n\r\nexport type ModalProps = AntdModalProps & {\r\n /**\r\n * 是否头部可拖拽\r\n */\r\n isDraggable?: boolean;\r\n /**\r\n * 是否满屏\r\n */\r\n defaultScreenful?: boolean;\r\n /**\r\n * 全屏图标\r\n */\r\n screenfulIcon?: ReactNode | false;\r\n}\r\n\r\nconst Modal = (props: ModalProps) => {\r\n const { width, style, title, defaultScreenful, isDraggable, screenfulIcon, ...restProps } = props;\r\n const [screenful, setScreenful] = useState(defaultScreenful ?? false);\r\n const [disabled, setDisabled] = useState(true);\r\n const [bounds, setBounds] = useState({ left: 0, top: 0, bottom: 0, right: 0 });\r\n const draggleRef = useRef<HTMLDivElement>(null);\r\n\r\n return <AntdModal\r\n {...restProps}\r\n className={screenful ? styles.screenfulModal : undefined}\r\n width={screenful ? 'auto' : width}\r\n style={screenful ? { top: 0 } : style}\r\n title={\r\n <div\r\n className={screenful ? \"\" : styles.modal}\r\n onMouseOver={() => {\r\n if (screenful) {\r\n setDisabled(true);\r\n return;\r\n }\r\n if (disabled) {\r\n setDisabled(false);\r\n }\r\n }}\r\n onMouseOut={() => {\r\n setDisabled(true);\r\n }}\r\n >\r\n {title}\r\n {screenfulIcon === false ? <></> : <Button\r\n className={styles.screenfulIcon}\r\n type=\"text\"\r\n size=\"small\"\r\n onClick={(event) => {\r\n event.stopPropagation();\r\n setScreenful(!screenful);\r\n }}\r\n >\r\n {screenfulIcon ? screenfulIcon : <ExpandOutlined rev={undefined} />}\r\n </Button>\r\n }\r\n </div>\r\n }\r\n modalRender={(modal) => (\r\n screenful ? modal : isDraggable === false ? modal : <Draggable\r\n disabled={disabled}\r\n bounds={bounds}\r\n nodeRef={draggleRef}\r\n onStart={(event, uiData) => {\r\n const { clientWidth, clientHeight } = window.document.documentElement;\r\n const targetRect = draggleRef.current?.getBoundingClientRect();\r\n if (!targetRect) {\r\n return;\r\n }\r\n setBounds({\r\n left: -targetRect.left + uiData.x,\r\n right: clientWidth - (targetRect.right - uiData.x),\r\n top: -targetRect.top + uiData.y,\r\n bottom: clientHeight - (targetRect.bottom - uiData.y),\r\n });\r\n }}\r\n >\r\n <div ref={draggleRef}>{modal}</div>\r\n </Draggable>\r\n )}\r\n />;\r\n}\r\n\r\nexport default Modal;\r\n"],"names":["ExpandOutlined","Modal","AntdModal","Button","useRef","useState","Draggable","styles","props","width","style","title","defaultScreenful","isDraggable","screenfulIcon","restProps","screenful","setScreenful","disabled","setDisabled","bounds","setBounds","left","top","bottom","right","draggleRef","className","screenfulModal","undefined","div","modal","onMouseOver","onMouseOut","type","size","onClick","event","stopPropagation","rev","modalRender","nodeRef","onStart","uiData","clientWidth","clientHeight","window","document","documentElement","targetRect","current","getBoundingClientRect","x","y","ref"],"mappings":";;;;AAAA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,SAASC,SAAS,EAAEC,MAAM,QAAsC,OAAO;AAChF,SAAoBC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AACpD,OAAOC,eAAe,kBAAkB;AACxC,OAAOC,YAAY,qBAAqB;AAiBxC,MAAMN,QAAQ,CAACO,QAAsB;IACnC,MAAM,EAAEC,MAAK,EAAEC,MAAK,EAAEC,MAAK,EAAEC,iBAAgB,EAAEC,YAAW,EAAEC,cAAa,EAAgB,GAAGN,OAAdO,uCAAcP;QAApFC;QAAOC;QAAOC;QAAOC;QAAkBC;QAAaC;;IAC5D,MAAM,CAACE,WAAWC,aAAa,GAAGZ,SAASO,6BAAAA,8BAAAA,mBAAoB,KAAK;IACpE,MAAM,CAACM,UAAUC,YAAY,GAAGd,SAAS,IAAI;IAC7C,MAAM,CAACe,QAAQC,UAAU,GAAGhB,SAAS;QAAEiB,MAAM;QAAGC,KAAK;QAAGC,QAAQ;QAAGC,OAAO;IAAE;IAC5E,MAAMC,aAAatB,OAAuB,IAAI;IAE9C,qBAAO,KAACF,mDACFa;QACJY,WAAWX,YAAYT,OAAOqB,cAAc,GAAGC,SAAS;QACxDpB,OAAOO,YAAY,SAASP,KAAK;QACjCC,OAAOM,YAAY;YAAEO,KAAK;QAAE,IAAIb,KAAK;QACrCC,qBACE,MAACmB;YACCH,WAAWX,YAAY,KAAKT,OAAOwB,KAAK;YACxCC,aAAa,IAAM;gBACjB,IAAIhB,WAAW;oBACbG,YAAY,IAAI;oBAChB;gBACF,CAAC;gBACD,IAAID,UACFC,YAAY,KAAK;YAErB;YACAc,YAAY,IAAM;gBAChBd,YAAY,IAAI;YAClB;;gBAECR;gBACAG,kBAAkB,KAAK,iBAAG,oCAAQ,KAACX;oBAClCwB,WAAWpB,OAAOO,aAAa;oBAC/BoB,MAAK;oBACLC,MAAK;oBACLC,SAAS,CAACC,QAAU;wBAClBA,MAAMC,eAAe;wBACrBrB,aAAa,CAACD;oBAChB;8BAECF,gBAAgBA,8BAAgB,KAACd;wBAAeuC,KAAKV;sBAAa;kBAC5D;;;QAIbW,aAAa,CAACT;YACZf,OAAAA,YAAYe,QAAQlB,gBAAgB,KAAK,GAAGkB,sBAAQ,KAACzB;gBACnDY,UAAUA;gBACVE,QAAQA;gBACRqB,SAASf;gBACTgB,SAAS,CAACL,OAAOM,SAAW;wBAEPjB;oBADnB,MAAM,EAAEkB,YAAW,EAAEC,aAAY,EAAE,GAAGC,OAAOC,QAAQ,CAACC,eAAe;oBACrE,MAAMC,aAAavB,CAAAA,sBAAAA,WAAWwB,OAAO,cAAlBxB,iCAAAA,KAAAA,IAAAA,oBAAoByB;oBACvC,IAAI,CAACF,YACH;oBAEF5B,UAAU;wBACRC,MAAM,CAAC2B,WAAW3B,IAAI,GAAGqB,OAAOS,CAAC;wBACjC3B,OAAOmB,cAAeK,CAAAA,WAAWxB,KAAK,GAAGkB,OAAOS,CAAC,AAADA;wBAChD7B,KAAK,CAAC0B,WAAW1B,GAAG,GAAGoB,OAAOU,CAAC;wBAC/B7B,QAAQqB,eAAgBI,CAAAA,WAAWzB,MAAM,GAAGmB,OAAOU,CAAC,AAADA;oBACrD;gBACF;0BAEA,cAAA,KAACvB;oBAAIwB,KAAK5B;8BAAaK;;cACb;;;AAGlB;AAEA,eAAe9B,MAAM"}
@@ -0,0 +1,20 @@
1
+ .modal {
2
+ cursor: move;
3
+ }
4
+
5
+ .screenfulIcon {
6
+ position: absolute;
7
+ right: 40px;
8
+ top: 16px;
9
+ color: rgba(0, 0, 0, 0.45);
10
+ }
11
+
12
+ .screenfulModal {
13
+ max-width: 100vw;
14
+ padding-bottom: 0;
15
+
16
+ :global(.ant-modal-body) {
17
+ height: calc(100vh - 116px);
18
+ overflow: auto;
19
+ }
20
+ }
@@ -0,0 +1,34 @@
1
+ /// <reference types="react" />
2
+ import { App, AppMenu } from "@knockout-js/api";
3
+ export type GatherMenuLocale = {
4
+ notText: string;
5
+ searchPlaceholder: string;
6
+ };
7
+ export type GatherMenuDataSource = {
8
+ app: App;
9
+ menu: AppMenu[];
10
+ }[];
11
+ export interface GatherMenuProps {
12
+ /**
13
+ * 弹出开关
14
+ */
15
+ open?: boolean;
16
+ /**
17
+ * 数据源
18
+ */
19
+ dataSource?: GatherMenuDataSource;
20
+ /**
21
+ * 存储key
22
+ */
23
+ storeKey?: string;
24
+ /**
25
+ * 弹出开关变更
26
+ */
27
+ onChangeOpen?: (open: boolean) => void;
28
+ /**
29
+ * 选中菜单
30
+ */
31
+ onClick?: (menuItem: AppMenu, app: App) => void;
32
+ }
33
+ declare const _default: (props: GatherMenuProps) => JSX.Element;
34
+ export default _default;