@oj-module/runtime 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import type { z } from "zod";
2
- import type { schemas } from "./client.schemas";
2
+ import type { schemas } from "./api.schemas";
3
3
  export type FetchAddRoleItemBody = z.input<(typeof schemas)["fetchAddRoleItem"]["body"]>;
4
4
  export type FetchAddRoleItemData = z.infer<(typeof schemas)["fetchAddRoleItem"]["data"]>;
5
5
  export declare function fetchAddRoleItem(body: FetchAddRoleItemBody): Promise<FetchAddRoleItemData>;
@@ -1,4 +1,4 @@
1
- import type { FetchAddRoleItemBody, FetchAddRoleItemData, FetchDeleteRoleItemBody, FetchDeleteRoleItemData, FetchMenuByRoleIdData, FetchMenuByRoleIdQuery, FetchRoleListData, FetchRoleListQuery, FetchRoleMenuData, FetchUpdateRoleItemBody, FetchUpdateRoleItemData } from "./api/client";
1
+ import type { FetchAddRoleItemBody, FetchAddRoleItemData, FetchDeleteRoleItemBody, FetchDeleteRoleItemData, FetchMenuByRoleIdData, FetchMenuByRoleIdQuery, FetchRoleListData, FetchRoleListQuery, FetchRoleMenuData, FetchUpdateRoleItemBody, FetchUpdateRoleItemData } from "./client/api";
2
2
  export declare function fetchRoleList(query: FetchRoleListQuery): Promise<FetchRoleListData>;
3
3
  export declare function fetchAddRoleItem(body: FetchAddRoleItemBody): Promise<FetchAddRoleItemData>;
4
4
  export declare function fetchUpdateRoleItem(body: FetchUpdateRoleItemBody): Promise<FetchUpdateRoleItemData>;
@@ -0,0 +1,26 @@
1
+ export declare const prefix = "oo";
2
+ export declare const colors: string[];
3
+ export declare const brandColors: string[];
4
+ export declare const successColors: string[];
5
+ export declare const warningColors: string[];
6
+ export declare const errorColors: string[];
7
+ export declare const infoColors: string[];
8
+ export declare const functionalColors: string[];
9
+ export declare const neutralColors: string[];
10
+ export declare const productLevelColorSystem: string[];
11
+ export declare const colorPaletteNumbers: number[];
12
+ export declare const colorVariantsCount = 10;
13
+ export declare const baseColorPalettes: string[];
14
+ /**
15
+ * antd 的 token 中未提供关于 gray 系列的颜色
16
+ *
17
+ * 相关问题:
18
+ * @see https://github.com/ant-design/ant-design/pull/31129
19
+ * @see https://github.com/ant-design/ant-design/discussions/45411
20
+ * @see https://github.com/ant-design/ant-design/issues/44247
21
+ *
22
+ *
23
+ * 颜色来源:
24
+ * @see https://ant.design/docs/spec/colors#neutral-color-palette
25
+ */
26
+ export declare const neutralColorPalettes: string[];
@@ -0,0 +1,5 @@
1
+ import type { ReactNode } from "react";
2
+ export interface AntdAppProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare function AntdApp({ children }: AntdAppProps): import("#node_modules/@types/react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { GlobalToken } from "antd";
2
+ /**
3
+ * Setup antd theme tokens to html
4
+ * @see https://ant.design/docs/spec/colors
5
+ */
6
+ export declare function setupAntdThemeTokensToHtml(antdTokens: GlobalToken): void;
@@ -0,0 +1,8 @@
1
+ import type { GlobalToken } from "antd";
2
+ /**
3
+ * 16 进制颜色值转 RGB 颜色值,因为 16 进制的颜色值在 tailwind 中不支持透明度,比如无法使用 bg-blue-500/20
4
+ * @see https://tailwindcss.com/docs/customizing-colors#using-css-variables
5
+ */
6
+ export declare function hexToRGB(hex: string): string;
7
+ export declare function isRGBColor(color: string): boolean;
8
+ export declare function getCSSVariablesByTokens(tokens: GlobalToken): string;
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from "./api/system/menu";
14
14
  export * from "./api/system/role";
15
15
  export * from "./api/user";
16
16
  export { AccessControl } from "./components/access-control";
17
+ export { AntdApp } from "./components/antd-app";
17
18
  export { BasicButton } from "./components/basic-button";
18
19
  export { BasicContent } from "./components/basic-content";
19
20
  export * from "./components/basic-form";
package/dist/runtime.js CHANGED
@@ -11,7 +11,7 @@ import { persist } from "zustand/middleware";
11
11
  import { Link, Navigate, Outlet, createBrowserRouter, matchRoutes, useLocation, useMatches, useNavigate, useOutlet, useSearchParams } from "react-router";
12
12
  import { ErrorBoundary } from "react-error-boundary";
13
13
  import { AntDesignOutlined, ApartmentOutlined, AppstoreOutlined, ArrowDownOutlined, ArrowLeftOutlined, ArrowUpOutlined, BellOutlined, CloseOutlined, CloudOutlined, ContainerOutlined, CopyOutlined, CopyrightOutlined, DownOutlined, EnterOutlined, EyeOutlined, FileTextOutlined, FullscreenExitOutlined, FullscreenOutlined, HomeOutlined, LoadingOutlined, LockOutlined, LogoutOutlined, MenuFoldOutlined, MenuOutlined, MenuUnfoldOutlined, NodeExpandOutlined, QuestionCircleOutlined, RedoOutlined, ReloadOutlined, RocketOutlined, SafetyOutlined, SearchOutlined, SettingOutlined, SisternodeOutlined, SubnodeOutlined, SwapOutlined, TeamOutlined, TranslationOutlined, UploadOutlined, UserOutlined, VerticalAlignBottomOutlined, VerticalAlignMiddleOutlined, VerticalAlignTopOutlined } from "@ant-design/icons";
14
- import { Avatar, Badge, Breadcrumb, Button, Checkbox, Col, ColorPicker, ConfigProvider, Divider, Drawer, Dropdown, Empty, FloatButton, Form, Grid, Input, InputNumber, List, Menu, Modal, Popover, Result, Row, Select, Slider, Space, Spin, Switch, Tabs, Tooltip, Tree, Typography, Upload, Watermark, message, theme } from "antd";
14
+ import { App, Avatar, Badge, Breadcrumb, Button, Checkbox, Col, ColorPicker, ConfigProvider, Divider, Drawer, Dropdown, Empty, FloatButton, Form, Grid, Input, InputNumber, List, Menu, Modal, Popover, Result, Row, Select, Slider, Space, Spin, Switch, Tabs, Tooltip, Tree, Typography, Upload, Watermark, message, notification, theme } from "antd";
15
15
  import { Fragment, Suspense, cloneElement, createElement, forwardRef, isValidElement, lazy, use, useCallback, useEffect, useMemo, useRef, useState } from "react";
16
16
  import { initReactI18next, useTranslation } from "react-i18next";
17
17
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -208,10 +208,10 @@ function getAppInfo() {
208
208
  return {
209
209
  "pkg": {
210
210
  "name": "@oj-module/runtime",
211
- "version": "0.1.6",
211
+ "version": "0.1.8",
212
212
  "license": "MIT"
213
213
  },
214
- "lastBuildTime": "2026-09-11 11:35:36"
214
+ "lastBuildTime": "2026-09-12 00:19:59"
215
215
  };
216
216
  }
217
217
  var init_get_app_info = __esmMin((() => {}));
@@ -8253,10 +8253,26 @@ var init_auth = __esmMin((() => {
8253
8253
  }));
8254
8254
  //#endregion
8255
8255
  //#region src/utils/static-antd/index.ts
8256
- var message$1, resetFns;
8256
+ /**
8257
+ * @see https://ant.design/components/app
8258
+ * @see https://ant.design/docs/blog/why-not-static
8259
+ */
8260
+ function StaticAntd() {
8261
+ const staticFunctions = App.useApp();
8262
+ message$1 = staticFunctions.message;
8263
+ notification$1 = staticFunctions.notification;
8264
+ modal = staticFunctions.modal;
8265
+ window.$message = message$1;
8266
+ window.$modal = modal;
8267
+ window.$notification = notification$1;
8268
+ return null;
8269
+ }
8270
+ var message$1, notification$1, resetFns, modal;
8257
8271
  var init_static_antd = __esmMin((() => {
8258
8272
  message$1 = message;
8273
+ notification$1 = notification;
8259
8274
  ({...resetFns} = Modal);
8275
+ modal = resetFns;
8260
8276
  }));
8261
8277
  //#endregion
8262
8278
  //#region src/utils/request/error-response.ts
@@ -8555,7 +8571,7 @@ function fetchDeleteMenuItem(id) {
8555
8571
  }).json());
8556
8572
  }
8557
8573
  //#endregion
8558
- //#region src/api/system/role/api/client.ts
8574
+ //#region src/api/system/role/client/api.ts
8559
8575
  init_request();
8560
8576
  function ensureReq() {
8561
8577
  return request;
@@ -8749,6 +8765,155 @@ function AccessControl({ type = "code", codes, children, fallback }) {
8749
8765
  return fallback;
8750
8766
  }
8751
8767
  //#endregion
8768
+ //#region src/components/antd-app/constants.ts
8769
+ var colors = [
8770
+ "blue",
8771
+ "purple",
8772
+ "cyan",
8773
+ "green",
8774
+ "magenta",
8775
+ "pink",
8776
+ "red",
8777
+ "orange",
8778
+ "yellow",
8779
+ "volcano",
8780
+ "geekblue",
8781
+ "gold",
8782
+ "lime"
8783
+ ];
8784
+ var brandColors = [
8785
+ "colorPrimary",
8786
+ "colorPrimaryBg",
8787
+ "colorPrimaryBgHover",
8788
+ "colorPrimaryBorder",
8789
+ "colorPrimaryBorderHover",
8790
+ "colorPrimaryHover",
8791
+ "colorPrimaryActive",
8792
+ "colorPrimaryTextHover",
8793
+ "colorPrimaryText",
8794
+ "colorPrimaryTextActive"
8795
+ ];
8796
+ var successColors = [
8797
+ "colorSuccess",
8798
+ "colorSuccessBg",
8799
+ "colorSuccessBgHover",
8800
+ "colorSuccessBorder",
8801
+ "colorSuccessBorderHover",
8802
+ "colorSuccessHover",
8803
+ "colorSuccessActive",
8804
+ "colorSuccessTextHover",
8805
+ "colorSuccessText",
8806
+ "colorSuccessTextActive"
8807
+ ];
8808
+ var warningColors = [
8809
+ "colorWarning",
8810
+ "colorWarningBg",
8811
+ "colorWarningBgHover",
8812
+ "colorWarningBorder",
8813
+ "colorWarningBorderHover",
8814
+ "colorWarningHover",
8815
+ "colorWarningActive",
8816
+ "colorWarningTextHover",
8817
+ "colorWarningText",
8818
+ "colorWarningTextActive"
8819
+ ];
8820
+ var errorColors = [
8821
+ "colorError",
8822
+ "colorErrorBg",
8823
+ "colorErrorBgHover",
8824
+ "colorErrorBorder",
8825
+ "colorErrorBorderHover",
8826
+ "colorErrorHover",
8827
+ "colorErrorActive",
8828
+ "colorErrorTextHover",
8829
+ "colorErrorText",
8830
+ "colorErrorTextActive"
8831
+ ];
8832
+ var infoColors = [
8833
+ "colorInfo",
8834
+ "colorInfoBg",
8835
+ "colorInfoBgHover",
8836
+ "colorInfoBorder",
8837
+ "colorInfoBorderHover",
8838
+ "colorInfoHover",
8839
+ "colorInfoActive",
8840
+ "colorInfoTextHover",
8841
+ "colorInfoText",
8842
+ "colorInfoTextActive"
8843
+ ];
8844
+ var functionalColors = [
8845
+ ...successColors,
8846
+ ...warningColors,
8847
+ ...errorColors,
8848
+ ...infoColors
8849
+ ];
8850
+ var neutralColors = [
8851
+ "colorText",
8852
+ "colorTextSecondary",
8853
+ "colorTextTertiary",
8854
+ "colorTextQuaternary",
8855
+ "colorBgContainer",
8856
+ "colorBgElevated",
8857
+ "colorBgLayout",
8858
+ "colorBgSpotlight",
8859
+ "colorBgMask",
8860
+ "colorBorder",
8861
+ "colorBorderSecondary",
8862
+ "colorFill",
8863
+ "colorFillSecondary",
8864
+ "colorFillTertiary",
8865
+ "colorFillQuaternary"
8866
+ ];
8867
+ var productLevelColorSystem = [...brandColors, ...functionalColors];
8868
+ var baseColorPalettes = colors.flatMap((color) => [color, ...Array.from({ length: 10 }, (_, i) => `${color}-${i + 1}`)]);
8869
+ //#endregion
8870
+ //#region src/components/antd-app/utils.ts
8871
+ /**
8872
+ * 16 进制颜色值转 RGB 颜色值,因为 16 进制的颜色值在 tailwind 中不支持透明度,比如无法使用 bg-blue-500/20
8873
+ * @see https://tailwindcss.com/docs/customizing-colors#using-css-variables
8874
+ */
8875
+ function hexToRGB(hex) {
8876
+ hex = hex.replace("#", "");
8877
+ return `${Number.parseInt(hex.substring(0, 2), 16)} ${Number.parseInt(hex.substring(2, 4), 16)} ${Number.parseInt(hex.substring(4, 6), 16)}`;
8878
+ }
8879
+ function isRGBColor(color) {
8880
+ return color.trim().startsWith("rgb");
8881
+ }
8882
+ function getCSSVariablesByTokens(tokens) {
8883
+ return Object.entries(tokens).reduce((acc, [key, value]) => {
8884
+ if (productLevelColorSystem.includes(key)) return `${acc}--oo-${key}:${hexToRGB(value)};`;
8885
+ if (neutralColors.includes(key)) return `${acc}--oo-${key}:${isRGBColor(value) ? value : `rgb(${hexToRGB(value)})`};`;
8886
+ return baseColorPalettes.includes(key) ? `${acc}--oo-${key}:${hexToRGB(value)};` : acc;
8887
+ }, "");
8888
+ }
8889
+ //#endregion
8890
+ //#region src/components/antd-app/setup-antd-theme.ts
8891
+ /**
8892
+ * Setup antd theme tokens to html
8893
+ * @see https://ant.design/docs/spec/colors
8894
+ */
8895
+ function setupAntdThemeTokensToHtml(antdTokens) {
8896
+ const cssVariablesString = getCSSVariablesByTokens(antdTokens);
8897
+ const styleId = "antd-theme-tokens";
8898
+ const styleSheet = document.querySelector(`#${styleId}`) || document.createElement("style");
8899
+ styleSheet.id = styleId;
8900
+ styleSheet.textContent = `:root { ${cssVariablesString} }`;
8901
+ document.head.appendChild(styleSheet);
8902
+ }
8903
+ //#endregion
8904
+ //#region src/components/antd-app/index.tsx
8905
+ init_static_antd();
8906
+ function AntdApp({ children }) {
8907
+ const { token: antdTokens } = theme.useToken();
8908
+ useEffect(() => {
8909
+ setupAntdThemeTokensToHtml(antdTokens);
8910
+ }, [antdTokens]);
8911
+ return /* @__PURE__ */ jsxs(App, {
8912
+ className: "h-full",
8913
+ children: [/* @__PURE__ */ jsx(StaticAntd, {}), children]
8914
+ });
8915
+ }
8916
+ //#endregion
8752
8917
  //#region src/components/basic-content/index.tsx
8753
8918
  function BasicContent(props) {
8754
8919
  const { children, className, style } = props;
@@ -27118,4 +27283,4 @@ init_ri();
27118
27283
  init_menu_icons();
27119
27284
  init_tree();
27120
27285
  //#endregion
27121
- export { AccessControl, AccessControlRoles, BasicButton, BasicContent, BasicTable, EmbeddedIcon, ExternalIcon, FormAvatarItem, FormTreeItem, Iframe, LayoutCenterIcon, LayoutEffects, LayoutLeftIcon, LayoutRightIcon, MixedNavigationIcon, OutsidePageIcon, ProfileCardIcon, RiAccountCircleLine, RiContrastFill, RiFullscreenExitLine, RiFullscreenLine, RiMailCheckLine, RiMoonIcon, RiReactjsLine, RiSunIcon, RiUserSettingsLine, ServerErrorIcon, SideNavigationIcon, TopNavigationIcon, TwoColumnNavigationIcon, accessControlCodes, defineModule, fetchAddMenuItem, fetchAddRoleItem, fetchAsyncRoutes, fetchDeleteMenuItem, fetchDeleteRoleItem, fetchLogin, fetchLogout, fetchMenuByRoleId, fetchMenuList, fetchRefreshToken, fetchRoleList, fetchRoleMenu, fetchUpdateMenuItem, fetchUpdateRoleItem, fetchUserInfo, filterTree, getAllExpandedKeys, getAppInfo, getBooleanOptions, getModule, getModules, getRedirectPath, getRegisteredApiPrefix, getRegisteredStore, getRoutes, getYesNoOptions, handleTree, loadAll, mapTree, menuIcons, permissionPrefix, setupI18n, traverseTreeValues, unloadModule, useAccess, useAuthStore, usePreferences, useSlotNodes, useUserStore, external_exports as z };
27286
+ export { AccessControl, AccessControlRoles, AntdApp, BasicButton, BasicContent, BasicTable, EmbeddedIcon, ExternalIcon, FormAvatarItem, FormTreeItem, Iframe, LayoutCenterIcon, LayoutEffects, LayoutLeftIcon, LayoutRightIcon, MixedNavigationIcon, OutsidePageIcon, ProfileCardIcon, RiAccountCircleLine, RiContrastFill, RiFullscreenExitLine, RiFullscreenLine, RiMailCheckLine, RiMoonIcon, RiReactjsLine, RiSunIcon, RiUserSettingsLine, ServerErrorIcon, SideNavigationIcon, TopNavigationIcon, TwoColumnNavigationIcon, accessControlCodes, defineModule, fetchAddMenuItem, fetchAddRoleItem, fetchAsyncRoutes, fetchDeleteMenuItem, fetchDeleteRoleItem, fetchLogin, fetchLogout, fetchMenuByRoleId, fetchMenuList, fetchRefreshToken, fetchRoleList, fetchRoleMenu, fetchUpdateMenuItem, fetchUpdateRoleItem, fetchUserInfo, filterTree, getAllExpandedKeys, getAppInfo, getBooleanOptions, getModule, getModules, getRedirectPath, getRegisteredApiPrefix, getRegisteredStore, getRoutes, getYesNoOptions, handleTree, loadAll, mapTree, menuIcons, permissionPrefix, setupI18n, traverseTreeValues, unloadModule, useAccess, useAuthStore, usePreferences, useSlotNodes, useUserStore, external_exports as z };
@@ -1,5 +1,5 @@
1
1
  import type { MenuItemType } from "../api/system/menu/types";
2
- import type { FetchAddRoleItemBody, FetchAddRoleItemData, FetchDeleteRoleItemBody, FetchDeleteRoleItemData, FetchMenuByRoleIdData, FetchMenuByRoleIdQuery, FetchRoleListData, FetchRoleListQuery, FetchRoleMenuData, FetchUpdateRoleItemBody, FetchUpdateRoleItemData } from "../api/system/role/api/client";
2
+ import type { FetchAddRoleItemBody, FetchAddRoleItemData, FetchDeleteRoleItemBody, FetchDeleteRoleItemData, FetchMenuByRoleIdData, FetchMenuByRoleIdQuery, FetchRoleListData, FetchRoleListQuery, FetchRoleMenuData, FetchUpdateRoleItemBody, FetchUpdateRoleItemData } from "../api/system/role/client/api";
3
3
  import type { NotificationItem } from "../layout/widgets/notification/types";
4
4
  /**
5
5
  * 系统 API provider(D9):模块经 ctx.register.systemApi 接管角色/菜单类
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oj-module/runtime",
3
3
  "type": "module",
4
- "version": "0.1.6",
4
+ "version": "0.1.8",
5
5
  "description": "React Antd Admin 框架运行时,供模块工程消费",
6
6
  "license": "MIT",
7
7
  "imports": {