@knockout-js/layout 0.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.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/es2017/components/avatar-dropdown/index.d.ts +25 -0
- package/es2017/components/avatar-dropdown/index.js +47 -0
- package/es2017/components/avatar-dropdown/index.js.map +1 -0
- package/es2017/components/avatar-dropdown/index.module.css +23 -0
- package/es2017/components/avatar-dropdown/locale/en_US.d.ts +3 -0
- package/es2017/components/avatar-dropdown/locale/en_US.js +6 -0
- package/es2017/components/avatar-dropdown/locale/en_US.js.map +1 -0
- package/es2017/components/avatar-dropdown/locale/zh_CN.d.ts +3 -0
- package/es2017/components/avatar-dropdown/locale/zh_CN.js +6 -0
- package/es2017/components/avatar-dropdown/locale/zh_CN.js.map +1 -0
- package/es2017/components/collect-providers/index.d.ts +22 -0
- package/es2017/components/collect-providers/index.js +38 -0
- package/es2017/components/collect-providers/index.js.map +1 -0
- package/es2017/components/i18n-dropdown/index.d.ts +10 -0
- package/es2017/components/i18n-dropdown/index.js +44 -0
- package/es2017/components/i18n-dropdown/index.js.map +1 -0
- package/es2017/components/i18n-dropdown/index.module.css +13 -0
- package/es2017/components/icons/index.d.ts +2 -0
- package/es2017/components/icons/index.js +19 -0
- package/es2017/components/icons/index.js.map +1 -0
- package/es2017/components/index.d.ts +12 -0
- package/es2017/components/index.js +15 -0
- package/es2017/components/index.js.map +1 -0
- package/es2017/components/keep-alive/index.d.ts +17 -0
- package/es2017/components/keep-alive/index.js +29 -0
- package/es2017/components/keep-alive/index.js.map +1 -0
- package/es2017/components/layout/index.d.ts +54 -0
- package/es2017/components/layout/index.js +123 -0
- package/es2017/components/layout/index.js.map +1 -0
- package/es2017/components/layout/layout.module.css +46 -0
- package/es2017/components/layout/woocoo.png +0 -0
- package/es2017/components/leave-prompt/index.d.ts +21 -0
- package/es2017/components/leave-prompt/index.js +62 -0
- package/es2017/components/leave-prompt/index.js.map +1 -0
- package/es2017/components/leave-prompt/locale/en_US.d.ts +3 -0
- package/es2017/components/leave-prompt/locale/en_US.js +6 -0
- package/es2017/components/leave-prompt/locale/en_US.js.map +1 -0
- package/es2017/components/leave-prompt/locale/zh_CN.d.ts +3 -0
- package/es2017/components/leave-prompt/locale/zh_CN.js +6 -0
- package/es2017/components/leave-prompt/locale/zh_CN.js.map +1 -0
- package/es2017/components/locale/en_US.d.ts +3 -0
- package/es2017/components/locale/en_US.js +14 -0
- package/es2017/components/locale/en_US.js.map +1 -0
- package/es2017/components/locale/index.d.ts +33 -0
- package/es2017/components/locale/index.js +39 -0
- package/es2017/components/locale/index.js.map +1 -0
- package/es2017/components/locale/zh_CN.d.ts +3 -0
- package/es2017/components/locale/zh_CN.js +14 -0
- package/es2017/components/locale/zh_CN.js.map +1 -0
- package/es2017/components/tenant-dropdown/index.d.ts +18 -0
- package/es2017/components/tenant-dropdown/index.js +80 -0
- package/es2017/components/tenant-dropdown/index.js.map +1 -0
- package/es2017/components/tenant-dropdown/index.module.css +13 -0
- package/es2017/components/tenant-dropdown/locale/en_US.d.ts +3 -0
- package/es2017/components/tenant-dropdown/locale/en_US.js +8 -0
- package/es2017/components/tenant-dropdown/locale/en_US.js.map +1 -0
- package/es2017/components/tenant-dropdown/locale/zh_CN.d.ts +3 -0
- package/es2017/components/tenant-dropdown/locale/zh_CN.js +8 -0
- package/es2017/components/tenant-dropdown/locale/zh_CN.js.map +1 -0
- package/es2017/components/theme-switch/index.d.ts +22 -0
- package/es2017/components/theme-switch/index.js +21 -0
- package/es2017/components/theme-switch/index.js.map +1 -0
- package/es2017/components/theme-switch/locale/en_US.d.ts +3 -0
- package/es2017/components/theme-switch/locale/en_US.js +7 -0
- package/es2017/components/theme-switch/locale/en_US.js.map +1 -0
- package/es2017/components/theme-switch/locale/zh_CN.d.ts +3 -0
- package/es2017/components/theme-switch/locale/zh_CN.js +7 -0
- package/es2017/components/theme-switch/locale/zh_CN.js.map +1 -0
- package/es2017/index.d.ts +1 -0
- package/es2017/index.js +3 -0
- package/es2017/index.js.map +1 -0
- package/es2017/typings.d.ts +1 -0
- package/esm/components/avatar-dropdown/index.d.ts +25 -0
- package/esm/components/avatar-dropdown/index.js +47 -0
- package/esm/components/avatar-dropdown/index.js.map +1 -0
- package/esm/components/avatar-dropdown/index.module.css +23 -0
- package/esm/components/avatar-dropdown/locale/en_US.d.ts +3 -0
- package/esm/components/avatar-dropdown/locale/en_US.js +6 -0
- package/esm/components/avatar-dropdown/locale/en_US.js.map +1 -0
- package/esm/components/avatar-dropdown/locale/zh_CN.d.ts +3 -0
- package/esm/components/avatar-dropdown/locale/zh_CN.js +6 -0
- package/esm/components/avatar-dropdown/locale/zh_CN.js.map +1 -0
- package/esm/components/collect-providers/index.d.ts +22 -0
- package/esm/components/collect-providers/index.js +39 -0
- package/esm/components/collect-providers/index.js.map +1 -0
- package/esm/components/i18n-dropdown/index.d.ts +10 -0
- package/esm/components/i18n-dropdown/index.js +46 -0
- package/esm/components/i18n-dropdown/index.js.map +1 -0
- package/esm/components/i18n-dropdown/index.module.css +13 -0
- package/esm/components/icons/index.d.ts +2 -0
- package/esm/components/icons/index.js +19 -0
- package/esm/components/icons/index.js.map +1 -0
- package/esm/components/index.d.ts +12 -0
- package/esm/components/index.js +15 -0
- package/esm/components/index.js.map +1 -0
- package/esm/components/keep-alive/index.d.ts +17 -0
- package/esm/components/keep-alive/index.js +29 -0
- package/esm/components/keep-alive/index.js.map +1 -0
- package/esm/components/layout/index.d.ts +54 -0
- package/esm/components/layout/index.js +142 -0
- package/esm/components/layout/index.js.map +1 -0
- package/esm/components/layout/layout.module.css +46 -0
- package/esm/components/layout/woocoo.png +0 -0
- package/esm/components/leave-prompt/index.d.ts +21 -0
- package/esm/components/leave-prompt/index.js +62 -0
- package/esm/components/leave-prompt/index.js.map +1 -0
- package/esm/components/leave-prompt/locale/en_US.d.ts +3 -0
- package/esm/components/leave-prompt/locale/en_US.js +6 -0
- package/esm/components/leave-prompt/locale/en_US.js.map +1 -0
- package/esm/components/leave-prompt/locale/zh_CN.d.ts +3 -0
- package/esm/components/leave-prompt/locale/zh_CN.js +6 -0
- package/esm/components/leave-prompt/locale/zh_CN.js.map +1 -0
- package/esm/components/locale/en_US.d.ts +3 -0
- package/esm/components/locale/en_US.js +14 -0
- package/esm/components/locale/en_US.js.map +1 -0
- package/esm/components/locale/index.d.ts +33 -0
- package/esm/components/locale/index.js +39 -0
- package/esm/components/locale/index.js.map +1 -0
- package/esm/components/locale/zh_CN.d.ts +3 -0
- package/esm/components/locale/zh_CN.js +14 -0
- package/esm/components/locale/zh_CN.js.map +1 -0
- package/esm/components/tenant-dropdown/index.d.ts +18 -0
- package/esm/components/tenant-dropdown/index.js +100 -0
- package/esm/components/tenant-dropdown/index.js.map +1 -0
- package/esm/components/tenant-dropdown/index.module.css +13 -0
- package/esm/components/tenant-dropdown/locale/en_US.d.ts +3 -0
- package/esm/components/tenant-dropdown/locale/en_US.js +8 -0
- package/esm/components/tenant-dropdown/locale/en_US.js.map +1 -0
- package/esm/components/tenant-dropdown/locale/zh_CN.d.ts +3 -0
- package/esm/components/tenant-dropdown/locale/zh_CN.js +8 -0
- package/esm/components/tenant-dropdown/locale/zh_CN.js.map +1 -0
- package/esm/components/theme-switch/index.d.ts +22 -0
- package/esm/components/theme-switch/index.js +21 -0
- package/esm/components/theme-switch/index.js.map +1 -0
- package/esm/components/theme-switch/locale/en_US.d.ts +3 -0
- package/esm/components/theme-switch/locale/en_US.js +7 -0
- package/esm/components/theme-switch/locale/en_US.js.map +1 -0
- package/esm/components/theme-switch/locale/zh_CN.d.ts +3 -0
- package/esm/components/theme-switch/locale/zh_CN.js +7 -0
- package/esm/components/theme-switch/locale/zh_CN.js.map +1 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +3 -0
- package/esm/index.js.map +1 -0
- package/esm/typings.d.ts +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.layout {
|
|
2
|
+
:global(.ant-pro-sider-collapsed .ant-menu-item-active) {
|
|
3
|
+
.menuIconPopup {
|
|
4
|
+
display: none;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
:global(.ant-pro-sider-collapsed .ant-menu-submenu-title .anticon) {
|
|
9
|
+
line-height: normal;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
:global(.ant-pro-sider-collapsed .ant-menu-item .anticon) {
|
|
13
|
+
line-height: normal;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:global(.ant-pro-global-header-header-actions-item .ant-switch) {
|
|
17
|
+
padding-block: 0;
|
|
18
|
+
border-radius: 100px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
:global(.ant-layout-content) {
|
|
22
|
+
padding: 0;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:global(.ant-menu-item-active) {
|
|
27
|
+
.menuIconPopup {
|
|
28
|
+
display: block;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:global(.ant-menu-submenu-popup .ant-pro-base-menu-inline-item-title) {
|
|
33
|
+
align-items: normal;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.menuIconPopup {
|
|
37
|
+
display: none;
|
|
38
|
+
position: absolute;
|
|
39
|
+
top: 50%;
|
|
40
|
+
right: 16px;
|
|
41
|
+
margin-top: -6px;
|
|
42
|
+
|
|
43
|
+
:global(&.anticon) {
|
|
44
|
+
display: none;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface LeavePromptLocale {
|
|
3
|
+
leavePromptTip: string;
|
|
4
|
+
}
|
|
5
|
+
export interface LeavePromptProps {
|
|
6
|
+
/**
|
|
7
|
+
* 站点路径
|
|
8
|
+
*/
|
|
9
|
+
pathname: string;
|
|
10
|
+
/**
|
|
11
|
+
* 插槽
|
|
12
|
+
*/
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 一般在layout引入,主要检测浏览器刷新
|
|
17
|
+
* TODO:浏览器的前进和回退无法拦截
|
|
18
|
+
*/
|
|
19
|
+
declare const _default: (props: LeavePromptProps) => JSX.Element;
|
|
20
|
+
export default _default;
|
|
21
|
+
export declare const useLeavePrompt: () => readonly [() => boolean, (when: boolean) => void];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { useLocale } from "../locale/index";
|
|
4
|
+
var eventName = "updateLeavePromptContext";
|
|
5
|
+
var when = true;
|
|
6
|
+
/**
|
|
7
|
+
* 一般在layout引入,主要检测浏览器刷新
|
|
8
|
+
* TODO:浏览器的前进和回退无法拦截
|
|
9
|
+
*/ export default function(props) {
|
|
10
|
+
var leave = useLocale("LeavePrompt");
|
|
11
|
+
useEffect(function() {
|
|
12
|
+
when = true;
|
|
13
|
+
}, [
|
|
14
|
+
props.pathname
|
|
15
|
+
]);
|
|
16
|
+
useEffect(function() {
|
|
17
|
+
window.addEventListener("beforeunload", function(event) {
|
|
18
|
+
if (when === true) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
event.returnValue = leave.leavePromptTip;
|
|
23
|
+
return leave.leavePromptTip;
|
|
24
|
+
});
|
|
25
|
+
window.addEventListener(eventName, function(event) {
|
|
26
|
+
when = event.detail || false;
|
|
27
|
+
});
|
|
28
|
+
}, []);
|
|
29
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
30
|
+
children: props.children
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
export var useLeavePrompt = function() {
|
|
34
|
+
var locale = useLocale("LeavePrompt");
|
|
35
|
+
/**
|
|
36
|
+
* 拦截离开检查确认离开后回调
|
|
37
|
+
* @param callback 确认离开
|
|
38
|
+
*/ var checkLeave = function() {
|
|
39
|
+
if (when) {
|
|
40
|
+
return true;
|
|
41
|
+
} else {
|
|
42
|
+
if (confirm(locale.leavePromptTip)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 设置是否拦截离开
|
|
50
|
+
* @param when true:不拦截,false:拦截
|
|
51
|
+
*/ var setLeavePromptWhen = function(when) {
|
|
52
|
+
window.dispatchEvent(new CustomEvent(eventName, {
|
|
53
|
+
detail: when
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
return [
|
|
57
|
+
checkLeave,
|
|
58
|
+
setLeavePromptWhen
|
|
59
|
+
];
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\leave-prompt\\index.tsx"],"sourcesContent":["import { ReactNode, useEffect } from 'react';\r\nimport { useLocale } from '../locale';\r\n\r\nexport interface LeavePromptLocale {\r\n leavePromptTip: string;\r\n}\r\n\r\nexport interface LeavePromptProps {\r\n /**\r\n * 站点路径\r\n */\r\n pathname: string;\r\n /**\r\n * 插槽\r\n */\r\n children: ReactNode;\r\n}\r\n\r\n\r\nconst eventName = 'updateLeavePromptContext'\r\nlet when = true;\r\n\r\n\r\n/**\r\n * 一般在layout引入,主要检测浏览器刷新\r\n * TODO:浏览器的前进和回退无法拦截\r\n */\r\nexport default (props: LeavePromptProps) => {\r\n const leave = useLocale('LeavePrompt')\r\n\r\n useEffect(() => {\r\n when = true;\r\n }, [props.pathname]);\r\n\r\n useEffect(() => {\r\n window.addEventListener('beforeunload', (event: BeforeUnloadEvent) => {\r\n if (when === true) {\r\n return;\r\n }\r\n event.preventDefault();\r\n event.returnValue = leave.leavePromptTip;\r\n return leave.leavePromptTip;\r\n });\r\n\r\n window.addEventListener(eventName, (event: CustomEventInit<boolean>) => {\r\n when = event.detail || false;\r\n });\r\n }, []);\r\n\r\n return <>\r\n {props.children}\r\n </>;\r\n};\r\n\r\n\r\nexport const useLeavePrompt = () => {\r\n const locale = useLocale('LeavePrompt');\r\n\r\n /**\r\n * 拦截离开检查确认离开后回调\r\n * @param callback 确认离开\r\n */\r\n const checkLeave = () => {\r\n if (when) {\r\n return true;\r\n } else {\r\n if (confirm(locale.leavePromptTip)) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n };\r\n\r\n /**\r\n * 设置是否拦截离开\r\n * @param when true:不拦截,false:拦截\r\n */\r\n const setLeavePromptWhen = (when: boolean) => {\r\n window.dispatchEvent(new CustomEvent(eventName, {\r\n detail: when,\r\n }))\r\n };\r\n\r\n return [checkLeave, setLeavePromptWhen] as const\r\n}\r\n"],"names":["useEffect","useLocale","eventName","when","props","leave","pathname","window","addEventListener","event","preventDefault","returnValue","leavePromptTip","detail","children","useLeavePrompt","locale","checkLeave","confirm","setLeavePromptWhen","dispatchEvent","CustomEvent"],"mappings":";AAAA,SAAoBA,SAAS,QAAQ,QAAQ;AAC7C,SAASC,SAAS,QAAQ,kBAAY;AAkBtC,IAAMC,YAAY;AAClB,IAAIC,OAAO,IAAI;AAGf;;;CAGC,GACD,eAAe,SAACC,OAA4B;IAC1C,IAAMC,QAAQJ,UAAU;IAExBD,UAAU,WAAM;QACdG,OAAO,IAAI;IACb,GAAG;QAACC,MAAME,QAAQ;KAAC;IAEnBN,UAAU,WAAM;QACdO,OAAOC,gBAAgB,CAAC,gBAAgB,SAACC,OAA6B;YACpE,IAAIN,SAAS,IAAI,EAAE;gBACjB;YACF,CAAC;YACDM,MAAMC,cAAc;YACpBD,MAAME,WAAW,GAAGN,MAAMO,cAAc;YACxC,OAAOP,MAAMO,cAAc;QAC7B;QAEAL,OAAOC,gBAAgB,CAACN,WAAW,SAACO,OAAoC;YACtEN,OAAOM,MAAMI,MAAM,IAAI,KAAK;QAC9B;IACF,GAAG,EAAE;IAEL,qBAAO;kBACJT,MAAMU,QAAQ;;AAEnB,EAAE;AAGF,OAAO,IAAMC,iBAAiB,WAAM;IAClC,IAAMC,SAASf,UAAU;IAEzB;;;GAGC,GACD,IAAMgB,aAAa,WAAM;QACvB,IAAId,MAAM;YACR,OAAO,IAAI;QACb,OAAO;YACL,IAAIe,QAAQF,OAAOJ,cAAc,GAAG;gBAClC,OAAO,IAAI;YACb,CAAC;QACH,CAAC;QACD,OAAO,KAAK;IACd;IAEA;;;GAGC,GACD,IAAMO,qBAAqB,SAAChB,MAAkB;QAC5CI,OAAOa,aAAa,CAAC,IAAIC,YAAYnB,WAAW;YAC9CW,QAAQV;QACV;IACF;IAEA,OAAO;QAACc;QAAYE;KAAmB;AACzC,EAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\leave-prompt\\locale\\en_US.ts"],"sourcesContent":["import { LeavePromptLocale } from \"../index\";\r\n\r\nconst locale: LeavePromptLocale = {\r\n leavePromptTip: 'You still have content not saved, please leave'\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","leavePromptTip"],"mappings":"AAEA,IAAMA,SAA4B;IAChCC,gBAAgB;AAClB;AAEA,eAAeD,OAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\leave-prompt\\locale\\zh_CN.ts"],"sourcesContent":["import { LeavePromptLocale } from \"../index\";\r\n\r\nconst locale: LeavePromptLocale = {\r\n leavePromptTip: '您还有内容未保存,是否离开'\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","leavePromptTip"],"mappings":"AAEA,IAAMA,SAA4B;IAChCC,gBAAgB;AAClB;AAEA,eAAeD,OAAM"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ThemeSwitch from "../theme-switch/locale/en_US";
|
|
2
|
+
import LeavePrompt from "../leave-prompt/locale/en_US";
|
|
3
|
+
import AvatarDropdown from "../avatar-dropdown/locale/en_US";
|
|
4
|
+
import TenantDropdown from "../tenant-dropdown/locale/en_US";
|
|
5
|
+
var localeValues = {
|
|
6
|
+
locale: "en-us",
|
|
7
|
+
ThemeSwitch: ThemeSwitch,
|
|
8
|
+
LeavePrompt: LeavePrompt,
|
|
9
|
+
AvatarDropdown: AvatarDropdown,
|
|
10
|
+
TenantDropdown: TenantDropdown
|
|
11
|
+
};
|
|
12
|
+
export default localeValues;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=en_US.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\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,IAAMC,eAAuB;IAC3BC,QAAQ;IACRL,aAAAA;IACAC,aAAAA;IACAC,gBAAAA;IACAC,gBAAAA;AACF;AAEA,eAAeC,aAAY"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TenantDropdownLocale } from '../tenant-dropdown';
|
|
3
|
+
import { ThemeSwitchLocale } from '../theme-switch';
|
|
4
|
+
import { LeavePromptLocale } from '../leave-prompt';
|
|
5
|
+
import { AvatarDropdownLocale } from '../avatar-dropdown';
|
|
6
|
+
export interface Locale {
|
|
7
|
+
locale: string;
|
|
8
|
+
ThemeSwitch: ThemeSwitchLocale;
|
|
9
|
+
LeavePrompt: LeavePromptLocale;
|
|
10
|
+
AvatarDropdown: AvatarDropdownLocale;
|
|
11
|
+
TenantDropdown: TenantDropdownLocale;
|
|
12
|
+
}
|
|
13
|
+
export declare enum LocaleType {
|
|
14
|
+
zhCN = "zh-CN",
|
|
15
|
+
enUS = "en-US"
|
|
16
|
+
}
|
|
17
|
+
export interface BasicProviderProps {
|
|
18
|
+
locale: LocaleType;
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export declare const BasicContext: import("react").Context<BasicProviderProps>;
|
|
22
|
+
/**
|
|
23
|
+
* 组件上使用
|
|
24
|
+
*/
|
|
25
|
+
declare const _default: (props: BasicProviderProps) => JSX.Element;
|
|
26
|
+
export default _default;
|
|
27
|
+
export type LocaleComponentName = Exclude<keyof Locale, 'locale'>;
|
|
28
|
+
/**
|
|
29
|
+
* hook
|
|
30
|
+
* @param componentName
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
export declare const useLocale: <C extends LocaleComponentName>(componentName: C) => Locale[C];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
3
|
+
import { createContext, useContext } from "react";
|
|
4
|
+
import zhCN from "./zh_CN";
|
|
5
|
+
import enUS from "./en_US";
|
|
6
|
+
export var LocaleType;
|
|
7
|
+
(function(LocaleType) {
|
|
8
|
+
LocaleType["zhCN"] = "zh-CN";
|
|
9
|
+
LocaleType["enUS"] = "en-US";
|
|
10
|
+
})(LocaleType || (LocaleType = {}));
|
|
11
|
+
// 定义语言上下文
|
|
12
|
+
export var BasicContext = /*#__PURE__*/ createContext({
|
|
13
|
+
locale: LocaleType.zhCN
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
* 组件上使用
|
|
17
|
+
*/ export default function(props) {
|
|
18
|
+
var locale = props.locale, children = props.children;
|
|
19
|
+
return /*#__PURE__*/ _jsx(BasicContext.Provider, {
|
|
20
|
+
value: {
|
|
21
|
+
locale: locale
|
|
22
|
+
},
|
|
23
|
+
children: children
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* hook
|
|
28
|
+
* @param componentName
|
|
29
|
+
* @returns
|
|
30
|
+
*/ export var useLocale = function(componentName) {
|
|
31
|
+
var ctx = useContext(BasicContext);
|
|
32
|
+
if (ctx.locale === LocaleType.enUS) {
|
|
33
|
+
return _object_spread({}, enUS[componentName]);
|
|
34
|
+
}
|
|
35
|
+
// 默认zhCN
|
|
36
|
+
return _object_spread({}, zhCN[componentName]);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\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,IAAMC,6BAAeL,cAAkC;IAC5DM,QAAQF,WAAWF,IAAI;AACzB,GAAG;AAEH;;CAEC,GACD,eAAe,SAACK,OAA8B;IAC5C,IAAQD,SAAqBC,MAArBD,QAAQE,WAAaD,MAAbC;IAChB,qBAAO,KAACH,aAAaI,QAAQ;QAACC,OAAO;YAAEJ,QAAQA;QAAO;kBAAIE;;AAC5D,EAAC;AAGD;;;;CAIC,GACD,OAAO,IAAMG,YAAY,SAAgCC,eAAqB;IAC5E,IAAMC,MAAMZ,WAA+BI;IAC3C,IAAIQ,IAAIP,MAAM,KAAKF,WAAWD,IAAI,EAAE;QAClC,OAAO,mBAAKA,IAAI,CAACS,cAAc;IACjC,CAAC;IACD,SAAS;IACT,OAAO,mBAAKV,IAAI,CAACU,cAAc;AACjC,EAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import ThemeSwitch from "../theme-switch/locale/zh_CN";
|
|
2
|
+
import LeavePrompt from "../leave-prompt/locale/zh_CN";
|
|
3
|
+
import AvatarDropdown from "../avatar-dropdown/locale/zh_CN";
|
|
4
|
+
import TenantDropdown from "../tenant-dropdown/locale/zh_CN";
|
|
5
|
+
var localeValues = {
|
|
6
|
+
locale: "zh-cn",
|
|
7
|
+
ThemeSwitch: ThemeSwitch,
|
|
8
|
+
LeavePrompt: LeavePrompt,
|
|
9
|
+
AvatarDropdown: AvatarDropdown,
|
|
10
|
+
TenantDropdown: TenantDropdown
|
|
11
|
+
};
|
|
12
|
+
export default localeValues;
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=zh_CN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\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,IAAMC,eAAuB;IAC3BC,QAAQ;IACRL,aAAAA;IACAC,aAAAA;IACAC,gBAAAA;IACAC,gBAAAA;AACF;AAEA,eAAeC,aAAY"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface TenantDropdownLocale {
|
|
3
|
+
switchTipTitle: string;
|
|
4
|
+
confirmTitle: string;
|
|
5
|
+
confirmContent: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TenantDropdownProps {
|
|
8
|
+
/**
|
|
9
|
+
* 当前 tenantId
|
|
10
|
+
*/
|
|
11
|
+
value: string;
|
|
12
|
+
/**
|
|
13
|
+
* value变更事件 (value: string) => void;
|
|
14
|
+
*/
|
|
15
|
+
onChange: (value: string) => void;
|
|
16
|
+
}
|
|
17
|
+
declare const _default: (props: TenantDropdownProps) => JSX.Element;
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
|
+
import { jsx as _jsx, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime";
|
|
5
|
+
import { Dropdown, Modal } from "antd";
|
|
6
|
+
import { useCallback, useEffect, useState } from "react";
|
|
7
|
+
import styles from "./index.module.css";
|
|
8
|
+
import { useLocale } from "../locale/index";
|
|
9
|
+
import { gql } from "urql";
|
|
10
|
+
import { query } from "@knockout-js/ice-urql/request";
|
|
11
|
+
import { iceUrqlInstance } from "../index";
|
|
12
|
+
var userRootOrgListQuery = gql("query userRootOrgs{\n userRootOrgs{\n id,parentID,kind,domain,code,name,status,path,displaySort,countryCode,timezone\n }\n}");
|
|
13
|
+
export default function(props) {
|
|
14
|
+
var _menu_items;
|
|
15
|
+
var locale = useLocale("TenantDropdown"), _useState = _sliced_to_array(useState([]), 2), list = _useState[0], setList = _useState[1], _useState1 = _sliced_to_array(useState(undefined), 2), info = _useState1[0], setInfo = _useState1[1], _useState2 = _sliced_to_array(useState(undefined), 2), menu = _useState2[0], setMenu = _useState2[1];
|
|
16
|
+
var getRequest = function() {
|
|
17
|
+
var _ref = _async_to_generator(function() {
|
|
18
|
+
var _result_data, result, orgList;
|
|
19
|
+
return _ts_generator(this, function(_state) {
|
|
20
|
+
switch(_state.label){
|
|
21
|
+
case 0:
|
|
22
|
+
return [
|
|
23
|
+
4,
|
|
24
|
+
query(userRootOrgListQuery, {}, {
|
|
25
|
+
instanceName: iceUrqlInstance.ucenter
|
|
26
|
+
})
|
|
27
|
+
];
|
|
28
|
+
case 1:
|
|
29
|
+
result = _state.sent();
|
|
30
|
+
if ((_result_data = result.data) === null || _result_data === void 0 ? void 0 : _result_data.userRootOrgs.length) {
|
|
31
|
+
orgList = result.data.userRootOrgs;
|
|
32
|
+
setList(orgList);
|
|
33
|
+
}
|
|
34
|
+
return [
|
|
35
|
+
2
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return function getRequest() {
|
|
41
|
+
return _ref.apply(this, arguments);
|
|
42
|
+
};
|
|
43
|
+
}(), setValue = function() {
|
|
44
|
+
setInfo(list.find(function(item) {
|
|
45
|
+
return item.id == props.value;
|
|
46
|
+
}));
|
|
47
|
+
setMenu({
|
|
48
|
+
items: list.filter(function(item) {
|
|
49
|
+
return (item === null || item === void 0 ? void 0 : item.id) != props.value;
|
|
50
|
+
}).map(function(item) {
|
|
51
|
+
return {
|
|
52
|
+
key: item.id,
|
|
53
|
+
label: item.name,
|
|
54
|
+
onClick: menuItemClick
|
|
55
|
+
};
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
}, menuItemClick = useCallback(function(param) {
|
|
59
|
+
var key = param.key;
|
|
60
|
+
Modal.confirm({
|
|
61
|
+
title: locale.confirmTitle,
|
|
62
|
+
content: locale.confirmContent,
|
|
63
|
+
onOk: function() {
|
|
64
|
+
props.onChange(key);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}, []);
|
|
68
|
+
useEffect(function() {
|
|
69
|
+
if (document.hidden) {
|
|
70
|
+
var tipStr = locale.switchTipTitle;
|
|
71
|
+
document.title = tipStr;
|
|
72
|
+
document.body.innerHTML = '<div style="width:370px;margin:40px auto 0 auto;">'.concat(tipStr, "</div>");
|
|
73
|
+
window.close();
|
|
74
|
+
} else {
|
|
75
|
+
setValue();
|
|
76
|
+
}
|
|
77
|
+
}, [
|
|
78
|
+
props.value
|
|
79
|
+
]);
|
|
80
|
+
useEffect(function() {
|
|
81
|
+
setValue();
|
|
82
|
+
}, [
|
|
83
|
+
list
|
|
84
|
+
]);
|
|
85
|
+
useEffect(function() {
|
|
86
|
+
getRequest();
|
|
87
|
+
}, []);
|
|
88
|
+
return info ? /*#__PURE__*/ _jsx(Dropdown, {
|
|
89
|
+
menu: menu,
|
|
90
|
+
disabled: (menu === null || menu === void 0 ? void 0 : (_menu_items = menu.items) === null || _menu_items === void 0 ? void 0 : _menu_items.length) === 0,
|
|
91
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
92
|
+
className: styles.action,
|
|
93
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
94
|
+
children: info.name
|
|
95
|
+
})
|
|
96
|
+
})
|
|
97
|
+
}) : /*#__PURE__*/ _jsx(_Fragment, {});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\tenant-dropdown\\index.tsx"],"sourcesContent":["import { Dropdown, MenuProps, Modal } from 'antd';\r\nimport { useCallback, useEffect, useState } from 'react';\r\nimport styles from './index.module.css';\r\nimport { useLocale } from '../locale';\r\nimport { gql } from 'urql'\r\nimport { Org, UserRootOrgsQuery, UserRootOrgsQueryVariables } from '@knockout-js/api';\r\nimport { query } from '@knockout-js/ice-urql/request';\r\nimport { iceUrqlInstance } from '..';\r\n\r\nexport interface TenantDropdownLocale {\r\n switchTipTitle: string;\r\n confirmTitle: string;\r\n confirmContent: string;\r\n}\r\n\r\nexport interface TenantDropdownProps {\r\n /**\r\n * 当前 tenantId\r\n */\r\n value: string;\r\n /**\r\n * value变更事件 (value: string) => void;\r\n */\r\n onChange: (value: string) => void;\r\n}\r\n\r\nconst userRootOrgListQuery = gql(/* GraphQL */`query userRootOrgs{\r\n userRootOrgs{\r\n id,parentID,kind,domain,code,name,status,path,displaySort,countryCode,timezone\r\n }\r\n}`);\r\n\r\nexport default (props: TenantDropdownProps) => {\r\n const locale = useLocale('TenantDropdown'),\r\n [list, setList] = useState<Array<Org>>([]),\r\n [info, setInfo] = useState<Org | undefined>(undefined),\r\n [menu, setMenu] = useState<MenuProps | undefined>(undefined);\r\n\r\n const\r\n getRequest = async () => {\r\n const result = await query<UserRootOrgsQuery, UserRootOrgsQueryVariables>(userRootOrgListQuery, {}, { instanceName: iceUrqlInstance.ucenter });\r\n if (result.data?.userRootOrgs.length) {\r\n const orgList = result.data.userRootOrgs as Org[]\r\n setList(orgList)\r\n }\r\n },\r\n setValue = () => {\r\n setInfo(list.find(item => item.id == props.value));\r\n setMenu({\r\n items: list.filter(item => item?.id != props.value).map(item => {\r\n return {\r\n key: item.id,\r\n label: item.name,\r\n onClick: menuItemClick\r\n };\r\n }),\r\n });\r\n },\r\n menuItemClick = useCallback(({ key }: { key: string }) => {\r\n Modal.confirm({\r\n title: locale.confirmTitle,\r\n content: locale.confirmContent,\r\n onOk: () => {\r\n props.onChange(key)\r\n },\r\n });\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (document.hidden) {\r\n const tipStr = locale.switchTipTitle;\r\n document.title = tipStr;\r\n document.body.innerHTML = `<div style=\"width:370px;margin:40px auto 0 auto;\">${tipStr}</div>`;\r\n window.close();\r\n } else {\r\n setValue()\r\n }\r\n }, [props.value]);\r\n\r\n useEffect(() => {\r\n setValue()\r\n }, [list]);\r\n\r\n useEffect(() => {\r\n getRequest();\r\n }, []);\r\n\r\n return info ? <Dropdown menu={menu} disabled={menu?.items?.length === 0}>\r\n <span className={styles.action}>\r\n <span>{info.name}</span>\r\n </span>\r\n </Dropdown> : <></>;\r\n};\r\n"],"names":["Dropdown","Modal","useCallback","useEffect","useState","styles","useLocale","gql","query","iceUrqlInstance","userRootOrgListQuery","props","menu","locale","list","setList","undefined","info","setInfo","setMenu","getRequest","result","orgList","instanceName","ucenter","data","userRootOrgs","length","setValue","find","item","id","value","items","filter","map","key","label","name","onClick","menuItemClick","confirm","title","confirmTitle","content","confirmContent","onOk","onChange","document","hidden","tipStr","switchTipTitle","body","innerHTML","window","close","disabled","span","className","action"],"mappings":";;;;AAAA,SAASA,QAAQ,EAAaC,KAAK,QAAQ,OAAO;AAClD,SAASC,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AACzD,OAAOC,YAAY,qBAAqB;AACxC,SAASC,SAAS,QAAQ,kBAAY;AACtC,SAASC,GAAG,QAAQ,OAAM;AAE1B,SAASC,KAAK,QAAQ,gCAAgC;AACtD,SAASC,eAAe,QAAQ,WAAK;AAmBrC,IAAMC,uBAAuBH,IAAkB;AAM/C,eAAe,SAACI,OAA+B;QAuDCC;IAtD9C,IAAMC,SAASP,UAAU,mBACLF,6BAAAA,SAAqB,EAAE,OAAxCU,OAAiBV,cAAXW,UAAWX,cACAA,8BAAAA,SAA0BY,gBAA3CC,OAAiBb,eAAXc,UAAWd,eACAA,8BAAAA,SAAgCY,gBAAjDJ,OAAiBR,eAAXe,UAAWf;IAEpB,IACEgB;mBAAa,oBAAA,WAAY;gBAEnBC,cADEA,QAEEC;;;;wBAFO;;4BAAMd,MAAqDE,sBAAsB,CAAC,GAAG;gCAAEa,cAAcd,gBAAgBe,OAAO;4BAAC;;;wBAAtIH,SAAS;wBACf,IAAIA,CAAAA,eAAAA,OAAOI,IAAI,cAAXJ,0BAAAA,KAAAA,IAAAA,aAAaK,aAAaC,MAAM,EAAE;4BAC9BL,UAAUD,OAAOI,IAAI,CAACC,YAAY;4BACxCX,QAAQO;wBACV,CAAC;;;;;;QACH;wBANAF;;;SAOAQ,WAAW,WAAM;QACfV,QAAQJ,KAAKe,IAAI,CAACC,SAAAA;mBAAQA,KAAKC,EAAE,IAAIpB,MAAMqB,KAAK;;QAChDb,QAAQ;YACNc,OAAOnB,KAAKoB,MAAM,CAACJ,SAAAA;gBAAQA,OAAAA,CAAAA,iBAAAA,kBAAAA,KAAAA,IAAAA,KAAMC,EAAE,AAAD,KAAKpB,MAAMqB,KAAK;eAAEG,GAAG,CAACL,SAAAA,MAAQ;gBAC9D,OAAO;oBACLM,KAAKN,KAAKC,EAAE;oBACZM,OAAOP,KAAKQ,IAAI;oBAChBC,SAASC;gBACX;YACF;QACF;IACF,GACAA,gBAAgBtC,YAAY,gBAA8B;YAA3BkC,YAAAA;QAC7BnC,MAAMwC,OAAO,CAAC;YACZC,OAAO7B,OAAO8B,YAAY;YAC1BC,SAAS/B,OAAOgC,cAAc;YAC9BC,MAAM,WAAM;gBACVnC,MAAMoC,QAAQ,CAACX;YACjB;QACF;IACF,GAAG,EAAE;IAEPjC,UAAU,WAAM;QACd,IAAI6C,SAASC,MAAM,EAAE;YACnB,IAAMC,SAASrC,OAAOsC,cAAc;YACpCH,SAASN,KAAK,GAAGQ;YACjBF,SAASI,IAAI,CAACC,SAAS,GAAG,AAAC,qDAA2D,OAAPH,QAAO;YACtFI,OAAOC,KAAK;QACd,OAAO;YACL3B;QACF,CAAC;IACH,GAAG;QAACjB,MAAMqB,KAAK;KAAC;IAEhB7B,UAAU,WAAM;QACdyB;IACF,GAAG;QAACd;KAAK;IAETX,UAAU,WAAM;QACdiB;IACF,GAAG,EAAE;IAEL,OAAOH,qBAAO,KAACjB;QAASY,MAAMA;QAAM4C,UAAU5C,CAAAA,iBAAAA,kBAAAA,KAAAA,IAAAA,CAAAA,cAAAA,KAAMqB,KAAK,cAAXrB,yBAAAA,KAAAA,IAAAA,YAAae,MAAF,AAAD,MAAc;kBACpE,cAAA,KAAC8B;YAAKC,WAAWrD,OAAOsD,MAAM;sBAC5B,cAAA,KAACF;0BAAMxC,KAAKqB,IAAI;;;uBAEN,mBAAK;AACrB,EAAE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var locale = {
|
|
2
|
+
switchTipTitle: "Your organization has been switched, please manually close or refresh the current page",
|
|
3
|
+
confirmTitle: "Tenant switch reminder",
|
|
4
|
+
confirmContent: "Ensure that no edit content is not saved when you switch tenants. Otherwise, the operation will be forcibly prohibited or closed on other browsing pages"
|
|
5
|
+
};
|
|
6
|
+
export default locale;
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=en_US.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\tenant-dropdown\\locale\\en_US.ts"],"sourcesContent":["import { TenantDropdownLocale } from \"../index\";\r\n\r\nconst locale: TenantDropdownLocale = {\r\n switchTipTitle: \"Your organization has been switched, please manually close or refresh the current page\",\r\n confirmTitle: \"Tenant switch reminder\",\r\n confirmContent: \"Ensure that no edit content is not saved when you switch tenants. Otherwise, the operation will be forcibly prohibited or closed on other browsing pages\"\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","switchTipTitle","confirmTitle","confirmContent"],"mappings":"AAEA,IAAMA,SAA+B;IACnCC,gBAAgB;IAChBC,cAAc;IACdC,gBAAgB;AAClB;AAEA,eAAeH,OAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\tenant-dropdown\\locale\\zh_CN.ts"],"sourcesContent":["import { TenantDropdownLocale } from \"../index\";\r\n\r\nconst locale: TenantDropdownLocale = {\r\n switchTipTitle: \"您的组织已被切换,请手动关闭或者刷新当前页面\",\r\n confirmTitle: \"租户切换提醒\",\r\n confirmContent: \"切换租户时请确认已无编辑内容未保存,否则其他浏览页面将强制禁止操作或关闭\"\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","switchTipTitle","confirmTitle","confirmContent"],"mappings":"AAEA,IAAMA,SAA+B;IACnCC,gBAAgB;IAChBC,cAAc;IACdC,gBAAgB;AAClB;AAEA,eAAeH,OAAM"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SwitchProps } from 'antd';
|
|
3
|
+
export interface ThemeSwitchLocale {
|
|
4
|
+
bright: string;
|
|
5
|
+
dark: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ThemeSwitchProps {
|
|
8
|
+
/**
|
|
9
|
+
* 值
|
|
10
|
+
*/
|
|
11
|
+
value: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* switch的设置
|
|
14
|
+
*/
|
|
15
|
+
switchProps?: SwitchProps;
|
|
16
|
+
/**
|
|
17
|
+
* 值变更事件 (value: boolean) => void;
|
|
18
|
+
*/
|
|
19
|
+
onChange: (value: boolean) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const ThemeSwitch: React.FC<ThemeSwitchProps>;
|
|
22
|
+
export default ThemeSwitch;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
|
+
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { Switch } from "antd";
|
|
6
|
+
import { useLocale } from "../locale/index";
|
|
7
|
+
var ThemeSwitch = function(props) {
|
|
8
|
+
var locale = useLocale("ThemeSwitch");
|
|
9
|
+
return /*#__PURE__*/ _jsx(Switch, _object_spread_props(_object_spread({
|
|
10
|
+
checkedChildren: locale.bright,
|
|
11
|
+
unCheckedChildren: locale.dark
|
|
12
|
+
}, props.switchProps), {
|
|
13
|
+
checked: props.value,
|
|
14
|
+
onChange: function(checked) {
|
|
15
|
+
props.onChange(checked);
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
18
|
+
};
|
|
19
|
+
export default ThemeSwitch;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\theme-switch\\index.tsx"],"sourcesContent":["import React from 'react';\r\nimport { Switch, SwitchProps } from 'antd';\r\nimport { useLocale } from '../locale';\r\n\r\nexport interface ThemeSwitchLocale {\r\n bright: string;\r\n dark: string;\r\n}\r\n\r\nexport interface ThemeSwitchProps {\r\n /**\r\n * 值\r\n */\r\n value: boolean;\r\n /**\r\n * switch的设置\r\n */\r\n switchProps?: SwitchProps;\r\n /**\r\n * 值变更事件 (value: boolean) => void;\r\n */\r\n onChange: (value: boolean) => void;\r\n}\r\n\r\nconst ThemeSwitch: React.FC<ThemeSwitchProps> = (props: ThemeSwitchProps) => {\r\n const locale = useLocale('ThemeSwitch')\r\n return (\r\n <Switch\r\n checkedChildren={locale.bright}\r\n unCheckedChildren={locale.dark}\r\n {...props.switchProps}\r\n checked={props.value}\r\n onChange={(checked) => {\r\n props.onChange(checked)\r\n }}\r\n />\r\n );\r\n};\r\n\r\nexport default ThemeSwitch;\r\n"],"names":["React","Switch","useLocale","ThemeSwitch","props","locale","checkedChildren","bright","unCheckedChildren","dark","switchProps","checked","value","onChange"],"mappings":";;;AAAA,OAAOA,WAAW,QAAQ;AAC1B,SAASC,MAAM,QAAqB,OAAO;AAC3C,SAASC,SAAS,QAAQ,kBAAY;AAsBtC,IAAMC,cAA0C,SAACC,OAA4B;IAC3E,IAAMC,SAASH,UAAU;IACzB,qBACE,KAACD;QACCK,iBAAiBD,OAAOE,MAAM;QAC9BC,mBAAmBH,OAAOI,IAAI;OAC1BL,MAAMM,WAAW;QACrBC,SAASP,MAAMQ,KAAK;QACpBC,UAAU,SAACF,SAAY;YACrBP,MAAMS,QAAQ,CAACF;QACjB;;AAGN;AAEA,eAAeR,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\theme-switch\\locale\\en_US.ts"],"sourcesContent":["import { ThemeSwitchLocale } from \"../index\";\r\n\r\nconst locale: ThemeSwitchLocale = {\r\n bright: 'bright',\r\n dark: 'dark'\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","bright","dark"],"mappings":"AAEA,IAAMA,SAA4B;IAChCC,QAAQ;IACRC,MAAM;AACR;AAEA,eAAeF,OAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\components\\theme-switch\\locale\\zh_CN.ts"],"sourcesContent":["import { ThemeSwitchLocale } from \"../index\";\r\n\r\nconst locale: ThemeSwitchLocale = {\r\n bright: '亮',\r\n dark: '暗'\r\n};\r\n\r\nexport default locale\r\n"],"names":["locale","bright","dark"],"mappings":"AAEA,IAAMA,SAA4B;IAChCC,QAAQ;IACRC,MAAM;AACR;AAEA,eAAeF,OAAM"}
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
package/esm/index.js
ADDED
package/esm/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[".\\src\\index.tsx"],"sourcesContent":["export * from './components';\r\n"],"names":[],"mappings":"AAAA,cAAc,qBAAe"}
|
package/esm/typings.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="@ice/pkg/types" />
|