@hkyhy/marsun-components-core 0.1.37 → 0.1.39
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/dist/components/OrgTree/OrgTree.d.ts +38 -0
- package/dist/components/OrgTree/OrgTree.js +123 -0
- package/dist/components/OrgTree/OrgTree.js.map +1 -0
- package/dist/components/OrgTree/index.d.ts +2 -0
- package/dist/components/OrgTree/style.module.scss.js +11 -0
- package/dist/components/OrgTree/style.module.scss.js.map +1 -0
- package/dist/components/Permissions/Permissions.d.ts +37 -0
- package/dist/components/Permissions/Permissions.js +52 -0
- package/dist/components/Permissions/Permissions.js.map +1 -0
- package/dist/components/Permissions/index.d.ts +2 -0
- package/dist/components/Permissions/style.module.scss.js +7 -0
- package/dist/components/Permissions/style.module.scss.js.map +1 -0
- package/dist/components/StateBar/StateBar.d.ts +28 -0
- package/dist/components/StateBar/StateBar.js +43 -0
- package/dist/components/StateBar/StateBar.js.map +1 -0
- package/dist/components/StateBar/index.d.ts +2 -0
- package/dist/components/StateBar/style.module.scss.js +12 -0
- package/dist/components/StateBar/style.module.scss.js.map +1 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +241 -232
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/provider/MarsunCoreProvider.js +23 -29
- package/dist/provider/MarsunCoreProvider.js.map +1 -1
- package/dist/provider/context.d.ts +2 -0
- package/dist/provider/context.js +5 -4
- package/dist/provider/context.js.map +1 -1
- package/dist/styles/global.css +1 -1
- package/package.json +1 -1
|
@@ -1,51 +1,45 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { ConfigProvider as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { generateTheme as
|
|
5
|
-
import { DEFAULT_PRIMARY_COLOR as
|
|
6
|
-
import { MarsunCoreContext as
|
|
7
|
-
import { useMarsunAuth as
|
|
8
|
-
const
|
|
9
|
-
children:
|
|
2
|
+
import { ConfigProvider as g } from "antd";
|
|
3
|
+
import { useMemo as A, useEffect as M } from "react";
|
|
4
|
+
import { generateTheme as y, applyThemeToCssVariables as o } from "../theme/theme.js";
|
|
5
|
+
import { DEFAULT_PRIMARY_COLOR as x } from "../theme/constants.js";
|
|
6
|
+
import { MarsunCoreContext as R } from "./context.js";
|
|
7
|
+
import { useMarsunAuth as O, useMarsunCore as V, useMarsunFetch as _ } from "./context.js";
|
|
8
|
+
const E = ({
|
|
9
|
+
children: e,
|
|
10
10
|
theme: n,
|
|
11
11
|
auth: s,
|
|
12
12
|
fetch: f,
|
|
13
13
|
withConfigProvider: C = !0
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
15
|
+
const i = (n == null ? void 0 : n.primaryColor) ?? x, c = A(
|
|
16
16
|
() => ({
|
|
17
17
|
auth: {
|
|
18
18
|
isAuthenticated: (s == null ? void 0 : s.isAuthenticated) ?? !1,
|
|
19
19
|
user: (s == null ? void 0 : s.user) ?? null,
|
|
20
|
+
permissions: (s == null ? void 0 : s.permissions) ?? [],
|
|
20
21
|
hasAnyRole: (s == null ? void 0 : s.hasAnyRole) ?? (() => !1),
|
|
21
22
|
hasPermission: (s == null ? void 0 : s.hasPermission) ?? (() => !1)
|
|
22
23
|
},
|
|
23
24
|
fetch: f ?? {},
|
|
24
25
|
theme: {
|
|
25
|
-
primaryColor:
|
|
26
|
+
primaryColor: i,
|
|
26
27
|
themeConfig: n == null ? void 0 : n.themeConfig
|
|
27
28
|
}
|
|
28
29
|
}),
|
|
29
|
-
[s, f,
|
|
30
|
-
), m = (n == null ? void 0 : n.themeConfig) ??
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, [
|
|
34
|
-
const d = C ? /* @__PURE__ */ l(
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
theme: m,
|
|
38
|
-
getPopupContainer: () => document.body,
|
|
39
|
-
children: i
|
|
40
|
-
}
|
|
41
|
-
) : i;
|
|
42
|
-
return /* @__PURE__ */ l(y.Provider, { value: c, children: d });
|
|
30
|
+
[s, f, i, n == null ? void 0 : n.themeConfig]
|
|
31
|
+
), m = (n == null ? void 0 : n.themeConfig) ?? y(i);
|
|
32
|
+
M(() => {
|
|
33
|
+
o(i);
|
|
34
|
+
}, [i]);
|
|
35
|
+
const d = C ? /* @__PURE__ */ l(g, { theme: m, getPopupContainer: () => document.body, children: e }) : e;
|
|
36
|
+
return /* @__PURE__ */ l(R.Provider, { value: c, children: d });
|
|
43
37
|
};
|
|
44
38
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
R as MarsunCoreContext,
|
|
40
|
+
E as default,
|
|
41
|
+
O as useMarsunAuth,
|
|
42
|
+
V as useMarsunCore,
|
|
43
|
+
_ as useMarsunFetch
|
|
50
44
|
};
|
|
51
45
|
//# sourceMappingURL=MarsunCoreProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarsunCoreProvider.js","sources":["../../src/provider/MarsunCoreProvider.tsx"],"sourcesContent":["import { ConfigProvider } from 'antd';\nimport type { ThemeConfig } from 'antd';\nimport React, { useEffect, useMemo } from 'react';\nimport { DEFAULT_PRIMARY_COLOR, applyThemeToCssVariables, generateTheme } from '@/theme';\nimport {
|
|
1
|
+
{"version":3,"file":"MarsunCoreProvider.js","sources":["../../src/provider/MarsunCoreProvider.tsx"],"sourcesContent":["import { ConfigProvider } from 'antd';\nimport type { ThemeConfig } from 'antd';\nimport React, { useEffect, useMemo } from 'react';\nimport { DEFAULT_PRIMARY_COLOR, applyThemeToCssVariables, generateTheme } from '@/theme';\nimport { MarsunCoreContext, type MarsunAuthContext, type MarsunFetchContext } from './context';\n\nexport type MarsunCoreProviderProps = {\n children: React.ReactNode;\n /** 主题覆盖;外层已有 ConfigProvider 时 token 自然优先 */\n theme?: {\n primaryColor?: string;\n themeConfig?: ThemeConfig;\n };\n /** 鉴权注入(Auth / AgentHub guards 使用) */\n auth?: Partial<MarsunAuthContext>;\n /** fetch 模式默认配置 */\n fetch?: MarsunFetchContext;\n /** 设为 false 时不渲染内部 ConfigProvider(消费方已包裹时) */\n withConfigProvider?: boolean;\n};\n\nconst MarsunCoreProvider: React.FC<MarsunCoreProviderProps> = ({\n children,\n theme: themeProp,\n auth: authProp,\n fetch: fetchProp,\n withConfigProvider = true,\n}) => {\n const primaryColor = themeProp?.primaryColor ?? DEFAULT_PRIMARY_COLOR;\n\n const contextValue = useMemo(\n () => ({\n auth: {\n isAuthenticated: authProp?.isAuthenticated ?? false,\n user: authProp?.user ?? null,\n permissions: authProp?.permissions ?? [],\n hasAnyRole: authProp?.hasAnyRole ?? (() => false),\n hasPermission: authProp?.hasPermission ?? (() => false),\n },\n fetch: fetchProp ?? {},\n theme: {\n primaryColor,\n themeConfig: themeProp?.themeConfig,\n },\n }),\n [authProp, fetchProp, primaryColor, themeProp?.themeConfig],\n );\n\n const antdTheme = themeProp?.themeConfig ?? generateTheme(primaryColor);\n\n useEffect(() => {\n applyThemeToCssVariables(primaryColor);\n }, [primaryColor]);\n\n const content = withConfigProvider ? (\n <ConfigProvider theme={antdTheme} getPopupContainer={() => document.body}>\n {children}\n </ConfigProvider>\n ) : (\n children\n );\n\n return <MarsunCoreContext.Provider value={contextValue}>{content}</MarsunCoreContext.Provider>;\n};\n\nexport default MarsunCoreProvider;\nexport { MarsunCoreContext, useMarsunAuth, useMarsunCore, useMarsunFetch } from './context';\n"],"names":["MarsunCoreProvider","children","themeProp","authProp","fetchProp","withConfigProvider","primaryColor","DEFAULT_PRIMARY_COLOR","contextValue","useMemo","antdTheme","generateTheme","useEffect","applyThemeToCssVariables","content","jsx","ConfigProvider","MarsunCoreContext"],"mappings":";;;;;;;AAqBA,MAAMA,IAAwD,CAAC;AAAA,EAC7D,UAAAC;AAAA,EACA,OAAOC;AAAA,EACP,MAAMC;AAAA,EACN,OAAOC;AAAA,EACP,oBAAAC,IAAqB;AACvB,MAAM;AACJ,QAAMC,KAAeJ,KAAA,gBAAAA,EAAW,iBAAgBK,GAE1CC,IAAeC;AAAA,IACnB,OAAO;AAAA,MACL,MAAM;AAAA,QACJ,kBAAiBN,KAAA,gBAAAA,EAAU,oBAAmB;AAAA,QAC9C,OAAMA,KAAA,gBAAAA,EAAU,SAAQ;AAAA,QACxB,cAAaA,KAAA,gBAAAA,EAAU,gBAAe,CAAA;AAAA,QACtC,aAAYA,KAAA,gBAAAA,EAAU,gBAAe,MAAM;AAAA,QAC3C,gBAAeA,KAAA,gBAAAA,EAAU,mBAAkB,MAAM;AAAA,MAAA;AAAA,MAEnD,OAAOC,KAAa,CAAA;AAAA,MACpB,OAAO;AAAA,QACL,cAAAE;AAAA,QACA,aAAaJ,KAAA,gBAAAA,EAAW;AAAA,MAAA;AAAA,IAC1B;AAAA,IAEF,CAACC,GAAUC,GAAWE,GAAcJ,KAAA,gBAAAA,EAAW,WAAW;AAAA,EAAA,GAGtDQ,KAAYR,KAAA,gBAAAA,EAAW,gBAAeS,EAAcL,CAAY;AAEtE,EAAAM,EAAU,MAAM;AACd,IAAAC,EAAyBP,CAAY;AAAA,EACvC,GAAG,CAACA,CAAY,CAAC;AAEjB,QAAMQ,IAAUT,IACd,gBAAAU,EAACC,GAAA,EAAe,OAAON,GAAW,mBAAmB,MAAM,SAAS,MACjE,UAAAT,EAAA,CACH,IAEAA;AAGF,2BAAQgB,EAAkB,UAAlB,EAA2B,OAAOT,GAAe,UAAAM,GAAQ;AACnE;"}
|
|
@@ -2,6 +2,8 @@ import { ThemeConfig } from 'antd';
|
|
|
2
2
|
export type MarsunAuthContext = {
|
|
3
3
|
isAuthenticated: boolean;
|
|
4
4
|
user: Record<string, unknown> | null;
|
|
5
|
+
/** 当前用户权限码列表(Permissions 组件 / usePermissions 优先读取) */
|
|
6
|
+
permissions?: string[];
|
|
5
7
|
hasAnyRole?: (roles: string[]) => boolean;
|
|
6
8
|
hasPermission?: (permission: string) => boolean;
|
|
7
9
|
};
|
package/dist/provider/context.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { useContext as e, createContext as n } from "react";
|
|
2
|
-
const
|
|
2
|
+
const r = {
|
|
3
3
|
isAuthenticated: !1,
|
|
4
4
|
user: null,
|
|
5
|
+
permissions: [],
|
|
5
6
|
hasAnyRole: () => !1,
|
|
6
7
|
hasPermission: () => !1
|
|
7
8
|
}, t = n({
|
|
8
|
-
auth:
|
|
9
|
+
auth: r,
|
|
9
10
|
fetch: {},
|
|
10
11
|
theme: { primaryColor: "#1677ff" }
|
|
11
12
|
});
|
|
12
|
-
function
|
|
13
|
+
function u() {
|
|
13
14
|
return e(t);
|
|
14
15
|
}
|
|
15
16
|
function o() {
|
|
@@ -21,7 +22,7 @@ function a() {
|
|
|
21
22
|
export {
|
|
22
23
|
t as MarsunCoreContext,
|
|
23
24
|
o as useMarsunAuth,
|
|
24
|
-
|
|
25
|
+
u as useMarsunCore,
|
|
25
26
|
a as useMarsunFetch
|
|
26
27
|
};
|
|
27
28
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../src/provider/context.ts"],"sourcesContent":["import type { ThemeConfig } from 'antd';\nimport { createContext, useContext } from 'react';\n\nexport type MarsunAuthContext = {\n isAuthenticated: boolean;\n user: Record<string, unknown> | null;\n hasAnyRole?: (roles: string[]) => boolean;\n hasPermission?: (permission: string) => boolean;\n};\n\nexport type MarsunFetchContext = {\n baseUrl?: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n};\n\nexport type MarsunCoreContextValue = {\n auth: MarsunAuthContext;\n fetch: MarsunFetchContext;\n theme: {\n primaryColor: string;\n themeConfig?: ThemeConfig;\n };\n};\n\nconst defaultAuth: MarsunAuthContext = {\n isAuthenticated: false,\n user: null,\n hasAnyRole: () => false,\n hasPermission: () => false,\n};\n\nexport const MarsunCoreContext = createContext<MarsunCoreContextValue>({\n auth: defaultAuth,\n fetch: {},\n theme: { primaryColor: '#1677ff' },\n});\n\nexport function useMarsunCore(): MarsunCoreContextValue {\n return useContext(MarsunCoreContext);\n}\n\nexport function useMarsunAuth(): MarsunAuthContext {\n return useContext(MarsunCoreContext).auth;\n}\n\nexport function useMarsunFetch(): MarsunFetchContext {\n return useContext(MarsunCoreContext).fetch;\n}\n"],"names":["defaultAuth","MarsunCoreContext","createContext","useMarsunCore","useContext","useMarsunAuth","useMarsunFetch"],"mappings":";
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../src/provider/context.ts"],"sourcesContent":["import type { ThemeConfig } from 'antd';\nimport { createContext, useContext } from 'react';\n\nexport type MarsunAuthContext = {\n isAuthenticated: boolean;\n user: Record<string, unknown> | null;\n /** 当前用户权限码列表(Permissions 组件 / usePermissions 优先读取) */\n permissions?: string[];\n hasAnyRole?: (roles: string[]) => boolean;\n hasPermission?: (permission: string) => boolean;\n};\n\nexport type MarsunFetchContext = {\n baseUrl?: string;\n timeoutMs?: number;\n headers?: Record<string, string>;\n};\n\nexport type MarsunCoreContextValue = {\n auth: MarsunAuthContext;\n fetch: MarsunFetchContext;\n theme: {\n primaryColor: string;\n themeConfig?: ThemeConfig;\n };\n};\n\nconst defaultAuth: MarsunAuthContext = {\n isAuthenticated: false,\n user: null,\n permissions: [],\n hasAnyRole: () => false,\n hasPermission: () => false,\n};\n\nexport const MarsunCoreContext = createContext<MarsunCoreContextValue>({\n auth: defaultAuth,\n fetch: {},\n theme: { primaryColor: '#1677ff' },\n});\n\nexport function useMarsunCore(): MarsunCoreContextValue {\n return useContext(MarsunCoreContext);\n}\n\nexport function useMarsunAuth(): MarsunAuthContext {\n return useContext(MarsunCoreContext).auth;\n}\n\nexport function useMarsunFetch(): MarsunFetchContext {\n return useContext(MarsunCoreContext).fetch;\n}\n"],"names":["defaultAuth","MarsunCoreContext","createContext","useMarsunCore","useContext","useMarsunAuth","useMarsunFetch"],"mappings":";AA2BA,MAAMA,IAAiC;AAAA,EACrC,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,aAAa,CAAA;AAAA,EACb,YAAY,MAAM;AAAA,EAClB,eAAe,MAAM;AACvB,GAEaC,IAAoBC,EAAsC;AAAA,EACrE,MAAMF;AAAA,EACN,OAAO,CAAA;AAAA,EACP,OAAO,EAAE,cAAc,UAAA;AACzB,CAAC;AAEM,SAASG,IAAwC;AACtD,SAAOC,EAAWH,CAAiB;AACrC;AAEO,SAASI,IAAmC;AACjD,SAAOD,EAAWH,CAAiB,EAAE;AACvC;AAEO,SAASK,IAAqC;AACnD,SAAOF,EAAWH,CAAiB,EAAE;AACvC;"}
|