com-angel-authorization 1.0.6 → 1.0.7

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.
@@ -293,6 +293,36 @@ type MenuManagerProps = {
293
293
  };
294
294
  declare function MenuManager({ api, title, pageSize: initialPageSize, toolbarExtra, }: MenuManagerProps): react.JSX.Element;
295
295
 
296
+ type SystemAdminMenuKey = 'menu' | 'resource';
297
+ type SystemAdminSubMenu = {
298
+ key: SystemAdminMenuKey;
299
+ label: string;
300
+ };
301
+ type SystemAdminMenuGroup = {
302
+ key: 'system';
303
+ label: string;
304
+ children: SystemAdminSubMenu[];
305
+ };
306
+ /** 系统管理菜单结构:菜单管理、权限点管理为其子菜单 */
307
+ declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
308
+ declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
309
+
310
+ type SystemAdminProps = {
311
+ menuApi: MenuResourceApi;
312
+ resourceApi: AuthorizationResourceApi;
313
+ /** 默认选中的子菜单,默认菜单管理 */
314
+ defaultActiveKey?: SystemAdminMenuKey;
315
+ /** 受控选中 key */
316
+ activeKey?: SystemAdminMenuKey;
317
+ onActiveKeyChange?: (key: SystemAdminMenuKey) => void;
318
+ title?: string;
319
+ toolbarExtra?: ReactNode;
320
+ };
321
+ /**
322
+ * 系统管理:侧栏父菜单「系统管理」,子菜单为「菜单管理」「权限点管理」。
323
+ */
324
+ declare function SystemAdmin({ menuApi, resourceApi, defaultActiveKey, activeKey: controlledKey, onActiveKeyChange, title, toolbarExtra, }: SystemAdminProps): react.JSX.Element;
325
+
296
326
  interface SnowyflakeOptions {
297
327
  epoch?: bigint;
298
328
  workerId?: bigint;
@@ -323,4 +353,4 @@ declare const snowyflake: ConfigurableSnowflake;
323
353
  declare function getAppClientId(): string;
324
354
  declare function getDeviceWorkerId(): string;
325
355
 
326
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
356
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
@@ -293,6 +293,36 @@ type MenuManagerProps = {
293
293
  };
294
294
  declare function MenuManager({ api, title, pageSize: initialPageSize, toolbarExtra, }: MenuManagerProps): react.JSX.Element;
295
295
 
296
+ type SystemAdminMenuKey = 'menu' | 'resource';
297
+ type SystemAdminSubMenu = {
298
+ key: SystemAdminMenuKey;
299
+ label: string;
300
+ };
301
+ type SystemAdminMenuGroup = {
302
+ key: 'system';
303
+ label: string;
304
+ children: SystemAdminSubMenu[];
305
+ };
306
+ /** 系统管理菜单结构:菜单管理、权限点管理为其子菜单 */
307
+ declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
308
+ declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
309
+
310
+ type SystemAdminProps = {
311
+ menuApi: MenuResourceApi;
312
+ resourceApi: AuthorizationResourceApi;
313
+ /** 默认选中的子菜单,默认菜单管理 */
314
+ defaultActiveKey?: SystemAdminMenuKey;
315
+ /** 受控选中 key */
316
+ activeKey?: SystemAdminMenuKey;
317
+ onActiveKeyChange?: (key: SystemAdminMenuKey) => void;
318
+ title?: string;
319
+ toolbarExtra?: ReactNode;
320
+ };
321
+ /**
322
+ * 系统管理:侧栏父菜单「系统管理」,子菜单为「菜单管理」「权限点管理」。
323
+ */
324
+ declare function SystemAdmin({ menuApi, resourceApi, defaultActiveKey, activeKey: controlledKey, onActiveKeyChange, title, toolbarExtra, }: SystemAdminProps): react.JSX.Element;
325
+
296
326
  interface SnowyflakeOptions {
297
327
  epoch?: bigint;
298
328
  workerId?: bigint;
@@ -323,4 +353,4 @@ declare const snowyflake: ConfigurableSnowflake;
323
353
  declare function getAppClientId(): string;
324
354
  declare function getDeviceWorkerId(): string;
325
355
 
326
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
356
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
@@ -1793,6 +1793,149 @@ var styles2 = {
1793
1793
  paddingTop: 4
1794
1794
  }
1795
1795
  };
1796
+
1797
+ // src/react/SystemAdmin.tsx
1798
+ import { useMemo as useMemo4, useState as useState4 } from "react";
1799
+
1800
+ // src/admin/menu.ts
1801
+ var SYSTEM_ADMIN_MENU = {
1802
+ key: "system",
1803
+ label: "\u7CFB\u7EDF\u7BA1\u7406",
1804
+ children: [
1805
+ { key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
1806
+ { key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" }
1807
+ ]
1808
+ };
1809
+ var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
1810
+
1811
+ // src/react/SystemAdmin.tsx
1812
+ import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
1813
+ function SystemAdmin({
1814
+ menuApi,
1815
+ resourceApi,
1816
+ defaultActiveKey = SYSTEM_ADMIN_DEFAULT_KEY,
1817
+ activeKey: controlledKey,
1818
+ onActiveKeyChange,
1819
+ title = SYSTEM_ADMIN_MENU.label,
1820
+ toolbarExtra
1821
+ }) {
1822
+ const [innerKey, setInnerKey] = useState4(defaultActiveKey);
1823
+ const activeKey = controlledKey ?? innerKey;
1824
+ const setActiveKey = (key) => {
1825
+ if (controlledKey === void 0) setInnerKey(key);
1826
+ onActiveKeyChange?.(key);
1827
+ };
1828
+ const activeLabel = useMemo4(
1829
+ () => SYSTEM_ADMIN_MENU.children.find((item) => item.key === activeKey)?.label ?? "",
1830
+ [activeKey]
1831
+ );
1832
+ return /* @__PURE__ */ jsxs3("div", { style: styles3.root, children: [
1833
+ /* @__PURE__ */ jsxs3("aside", { style: styles3.sidebar, children: [
1834
+ /* @__PURE__ */ jsx4("div", { style: styles3.sidebarTitle, children: title }),
1835
+ /* @__PURE__ */ jsx4("nav", { style: styles3.nav, children: SYSTEM_ADMIN_MENU.children.map((item) => {
1836
+ const active = item.key === activeKey;
1837
+ return /* @__PURE__ */ jsx4(
1838
+ "button",
1839
+ {
1840
+ type: "button",
1841
+ style: {
1842
+ ...styles3.navItem,
1843
+ ...active ? styles3.navItemActive : null
1844
+ },
1845
+ onClick: () => setActiveKey(item.key),
1846
+ children: item.label
1847
+ },
1848
+ item.key
1849
+ );
1850
+ }) })
1851
+ ] }),
1852
+ /* @__PURE__ */ jsxs3("main", { style: styles3.content, children: [
1853
+ /* @__PURE__ */ jsxs3("div", { style: styles3.contentHeader, children: [
1854
+ /* @__PURE__ */ jsxs3("div", { style: styles3.breadcrumb, children: [
1855
+ /* @__PURE__ */ jsx4("span", { style: styles3.breadcrumbParent, children: title }),
1856
+ /* @__PURE__ */ jsx4("span", { style: styles3.breadcrumbSep, children: "/" }),
1857
+ /* @__PURE__ */ jsx4("span", { style: styles3.breadcrumbCurrent, children: activeLabel })
1858
+ ] }),
1859
+ toolbarExtra
1860
+ ] }),
1861
+ /* @__PURE__ */ jsx4("div", { style: styles3.panel, children: activeKey === "menu" ? /* @__PURE__ */ jsx4(MenuManager, { api: menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : /* @__PURE__ */ jsx4(ResourceManager, { api: resourceApi, title: "\u6743\u9650\u70B9\u7BA1\u7406" }) })
1862
+ ] })
1863
+ ] });
1864
+ }
1865
+ var styles3 = {
1866
+ root: {
1867
+ display: "flex",
1868
+ minHeight: 560,
1869
+ border: "1px solid #eaecf0",
1870
+ borderRadius: 12,
1871
+ overflow: "hidden",
1872
+ background: "#fff",
1873
+ fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif',
1874
+ color: "#101828"
1875
+ },
1876
+ sidebar: {
1877
+ width: 200,
1878
+ flexShrink: 0,
1879
+ borderRight: "1px solid #eaecf0",
1880
+ background: "#f9fafb",
1881
+ padding: "16px 12px"
1882
+ },
1883
+ sidebarTitle: {
1884
+ fontSize: 14,
1885
+ fontWeight: 600,
1886
+ color: "#344054",
1887
+ padding: "4px 10px 12px"
1888
+ },
1889
+ nav: {
1890
+ display: "flex",
1891
+ flexDirection: "column",
1892
+ gap: 4
1893
+ },
1894
+ navItem: {
1895
+ border: "none",
1896
+ background: "transparent",
1897
+ textAlign: "left",
1898
+ padding: "10px 12px",
1899
+ borderRadius: 8,
1900
+ fontSize: 14,
1901
+ color: "#475467",
1902
+ cursor: "pointer"
1903
+ },
1904
+ navItemActive: {
1905
+ background: "#e6f7f9",
1906
+ color: "#049BAD",
1907
+ fontWeight: 600
1908
+ },
1909
+ content: {
1910
+ flex: 1,
1911
+ minWidth: 0,
1912
+ display: "flex",
1913
+ flexDirection: "column",
1914
+ background: "#fff"
1915
+ },
1916
+ contentHeader: {
1917
+ display: "flex",
1918
+ alignItems: "center",
1919
+ justifyContent: "space-between",
1920
+ gap: 12,
1921
+ padding: "12px 16px",
1922
+ borderBottom: "1px solid #f2f4f7"
1923
+ },
1924
+ breadcrumb: {
1925
+ display: "flex",
1926
+ alignItems: "center",
1927
+ gap: 8,
1928
+ fontSize: 13
1929
+ },
1930
+ breadcrumbParent: { color: "#98a2b3" },
1931
+ breadcrumbSep: { color: "#d0d5dd" },
1932
+ breadcrumbCurrent: { color: "#344054", fontWeight: 600 },
1933
+ panel: {
1934
+ flex: 1,
1935
+ minHeight: 0,
1936
+ overflow: "auto"
1937
+ }
1938
+ };
1796
1939
  export {
1797
1940
  Can,
1798
1941
  MENU_LIST_TYPE_PARAM,
@@ -1812,6 +1955,9 @@ export {
1812
1955
  RESOURCE_TYPE_API,
1813
1956
  ROOT_PARENT_ID,
1814
1957
  ResourceManager,
1958
+ SYSTEM_ADMIN_DEFAULT_KEY,
1959
+ SYSTEM_ADMIN_MENU,
1960
+ SystemAdmin,
1815
1961
  appendQueryParam,
1816
1962
  buildCreateBody,
1817
1963
  buildCreateMenuBody,