@pnt-team/pnt-component-frontend 0.0.34

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 (78) hide show
  1. package/README.md +34 -0
  2. package/lib/cjs/api/index.d.ts +17 -0
  3. package/lib/cjs/api/index.js +45 -0
  4. package/lib/cjs/assets/css/tdesign-theme.css +584 -0
  5. package/lib/cjs/assets/images/uploadImg.png +0 -0
  6. package/lib/cjs/assets/svg/inputSearch.svg +4 -0
  7. package/lib/cjs/assets/svg/inputTip.svg +5 -0
  8. package/lib/cjs/assets/svg/inputWarnTip.svg +5 -0
  9. package/lib/cjs/components/PntCopyData/index.d.ts +91 -0
  10. package/lib/cjs/components/PntCopyData/index.js +81 -0
  11. package/lib/cjs/components/PntCopyData/index.scss +5 -0
  12. package/lib/cjs/components/PntImagePreview/index.d.ts +75 -0
  13. package/lib/cjs/components/PntImagePreview/index.js +91 -0
  14. package/lib/cjs/components/PntImagePreview/index.scss +54 -0
  15. package/lib/cjs/components/PntSecureBox/index.d.ts +69 -0
  16. package/lib/cjs/components/PntSecureBox/index.js +65 -0
  17. package/lib/cjs/components/PntSecureBox/index.scss +19 -0
  18. package/lib/cjs/configs/host.d.ts +12 -0
  19. package/lib/cjs/configs/host.js +39 -0
  20. package/lib/cjs/configs/token.d.ts +2 -0
  21. package/lib/cjs/configs/token.js +25 -0
  22. package/lib/cjs/global.d.ts +30 -0
  23. package/lib/cjs/hooks/useBtnPermission.d.ts +67 -0
  24. package/lib/cjs/hooks/useBtnPermission.js +57 -0
  25. package/lib/cjs/hooks/useHighSecurity.d.ts +6 -0
  26. package/lib/cjs/hooks/useHighSecurity.js +51 -0
  27. package/lib/cjs/hooks/useOsPlatformList.d.ts +68 -0
  28. package/lib/cjs/hooks/useOsPlatformList.js +104 -0
  29. package/lib/cjs/hooks/usePagination.d.ts +72 -0
  30. package/lib/cjs/hooks/usePagination.js +71 -0
  31. package/lib/cjs/index.d.ts +10 -0
  32. package/lib/cjs/index.js +57 -0
  33. package/lib/cjs/utils/const.d.ts +13 -0
  34. package/lib/cjs/utils/const.js +51 -0
  35. package/lib/cjs/utils/index.d.ts +6 -0
  36. package/lib/cjs/utils/index.js +43 -0
  37. package/lib/cjs/utils/request.d.ts +8 -0
  38. package/lib/cjs/utils/request.js +82 -0
  39. package/lib/esm/api/index.d.ts +17 -0
  40. package/lib/esm/api/index.js +11 -0
  41. package/lib/esm/assets/css/tdesign-theme.css +584 -0
  42. package/lib/esm/assets/images/uploadImg.png +0 -0
  43. package/lib/esm/assets/svg/inputSearch.svg +4 -0
  44. package/lib/esm/assets/svg/inputTip.svg +5 -0
  45. package/lib/esm/assets/svg/inputWarnTip.svg +5 -0
  46. package/lib/esm/components/PntCopyData/index.d.ts +91 -0
  47. package/lib/esm/components/PntCopyData/index.js +51 -0
  48. package/lib/esm/components/PntCopyData/index.scss +5 -0
  49. package/lib/esm/components/PntImagePreview/index.d.ts +75 -0
  50. package/lib/esm/components/PntImagePreview/index.js +61 -0
  51. package/lib/esm/components/PntImagePreview/index.scss +54 -0
  52. package/lib/esm/components/PntSecureBox/index.d.ts +69 -0
  53. package/lib/esm/components/PntSecureBox/index.js +35 -0
  54. package/lib/esm/components/PntSecureBox/index.scss +19 -0
  55. package/lib/esm/configs/host.d.ts +12 -0
  56. package/lib/esm/configs/host.js +19 -0
  57. package/lib/esm/configs/token.d.ts +2 -0
  58. package/lib/esm/configs/token.js +5 -0
  59. package/lib/esm/global.d.ts +30 -0
  60. package/lib/esm/hooks/useBtnPermission.d.ts +67 -0
  61. package/lib/esm/hooks/useBtnPermission.js +31 -0
  62. package/lib/esm/hooks/useHighSecurity.d.ts +6 -0
  63. package/lib/esm/hooks/useHighSecurity.js +27 -0
  64. package/lib/esm/hooks/useOsPlatformList.d.ts +68 -0
  65. package/lib/esm/hooks/useOsPlatformList.js +68 -0
  66. package/lib/esm/hooks/usePagination.d.ts +72 -0
  67. package/lib/esm/hooks/usePagination.js +47 -0
  68. package/lib/esm/index.d.ts +10 -0
  69. package/lib/esm/index.js +17 -0
  70. package/lib/esm/utils/const.d.ts +13 -0
  71. package/lib/esm/utils/const.js +26 -0
  72. package/lib/esm/utils/index.d.ts +6 -0
  73. package/lib/esm/utils/index.js +19 -0
  74. package/lib/esm/utils/request.d.ts +8 -0
  75. package/lib/esm/utils/request.js +52 -0
  76. package/lib/umd/pnt-component-frontend.min.css +1 -0
  77. package/lib/umd/pnt-component-frontend.min.js +1 -0
  78. package/package.json +94 -0
@@ -0,0 +1,67 @@
1
+ /** 按钮权限值:1 有权限,-1 隐藏,-2 禁用 */
2
+ export type BtnPermissionValue = number;
3
+ /** 按钮权限映射:外层 key 为业务类型(全局为 'global' / 演示游戏为 '0' / 业务为具体 gameId / 兜底为 'no_permission_manner'),内层 key 为按钮标识符 */
4
+ export type BtnPermissionMap = Record<string, Record<string, BtnPermissionValue>>;
5
+ /** 演示游戏信息(来自用户信息,用于演示游戏判定) */
6
+ export interface DemoGameInfo {
7
+ id: number | string;
8
+ name: string;
9
+ }
10
+ /** 当前服务信息(与 demoGame 比对判断是否演示游戏) */
11
+ export interface ServiceInfo {
12
+ serviceType?: number | string;
13
+ serviceName?: string;
14
+ }
15
+ export interface UseBtnPermissionOptions {
16
+ /**
17
+ * 按钮权限映射(原从全局 store 注入,现改为入参注入)。
18
+ * 未传或取不到值时按有权限(1)处理。
19
+ */
20
+ permissions?: BtnPermissionMap;
21
+ /** 演示游戏信息;与 serviceInfo 同时传入才启用演示游戏判定 */
22
+ demoGame?: DemoGameInfo;
23
+ /** 当前服务信息 */
24
+ serviceInfo?: ServiceInfo;
25
+ }
26
+ /** 演示游戏在权限映射中的业务类型 key */
27
+ export declare const DEMO_GAME_TYPE_KEY = "0";
28
+ /** 无权限兜底配置的业务类型 key */
29
+ export declare const NO_PERMISSION_MANNER_KEY = "no_permission_manner";
30
+ /**
31
+ * 按钮权限 Hook(L3 业务 Hook)
32
+ *
33
+ * 融合 account-business-frontend 与 pnt-internal-tools-frontend 两版实现:
34
+ * - getBtnPermission(type, key):获取按钮处理方式,1 有权限 / -1 隐藏 / -2 禁用,
35
+ * 取不到值时依次回退到 no_permission_manner 兜底配置、defaultValue(默认 1);
36
+ * - 演示游戏(当前服务命中 demoGame)时固定使用 key '0' 的权限配置(account 版行为);
37
+ * - 零业务侵入:权限列表与演示游戏信息均通过入参注入,不再依赖 redux / umi / dva。
38
+ *
39
+ * @param options.permissions 按钮权限映射
40
+ * @param options.demoGame 演示游戏信息
41
+ * @param options.serviceInfo 当前服务信息
42
+ * @returns btnPermission 权限映射原文;isDemoGame 是否为演示游戏;getBtnPermission 获取按钮权限
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * import { useBtnPermission } from '@pnt/business-components';
47
+ *
48
+ * const Demo = ({ btnPermission, userInfo }) => {
49
+ * const { isDemoGame, getBtnPermission } = useBtnPermission({
50
+ * permissions: btnPermission, // 例如 { global: { create: 1 }, no_permission_manner: { create: -2 } }
51
+ * demoGame: userInfo?.demoGame, // 例如 { id: 11, name: 'DemoGame' }
52
+ * serviceInfo: { serviceType: userInfo?.serviceType, serviceName: userInfo?.serviceName },
53
+ * });
54
+ *
55
+ * const createPerm = getBtnPermission('global', 'create'); // 1 | -1 | -2
56
+ *
57
+ * if (createPerm === -1) return null; // 隐藏
58
+ * return <Button disabled={createPerm === -2}>新建{isDemoGame ? '(演示)' : ''}</Button>;
59
+ * };
60
+ * ```
61
+ */
62
+ export declare const useBtnPermission: (options?: UseBtnPermissionOptions) => {
63
+ btnPermission: BtnPermissionMap | undefined;
64
+ isDemoGame: boolean;
65
+ getBtnPermission: (type: string, key: string, defaultValue?: BtnPermissionValue) => BtnPermissionValue;
66
+ };
67
+ export default useBtnPermission;
@@ -0,0 +1,57 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/hooks/useBtnPermission.ts
20
+ var useBtnPermission_exports = {};
21
+ __export(useBtnPermission_exports, {
22
+ DEMO_GAME_TYPE_KEY: () => DEMO_GAME_TYPE_KEY,
23
+ NO_PERMISSION_MANNER_KEY: () => NO_PERMISSION_MANNER_KEY,
24
+ default: () => useBtnPermission_default,
25
+ useBtnPermission: () => useBtnPermission
26
+ });
27
+ module.exports = __toCommonJS(useBtnPermission_exports);
28
+ var import_react = require("react");
29
+ var DEMO_GAME_TYPE_KEY = "0";
30
+ var NO_PERMISSION_MANNER_KEY = "no_permission_manner";
31
+ var useBtnPermission = (options = {}) => {
32
+ const { permissions, demoGame, serviceInfo } = options;
33
+ const isDemoGame = (0, import_react.useMemo)(() => {
34
+ if (!demoGame || !serviceInfo)
35
+ return false;
36
+ return serviceInfo.serviceType === demoGame.id && serviceInfo.serviceName === demoGame.name;
37
+ }, [demoGame, serviceInfo]);
38
+ const getBtnPermission = (0, import_react.useCallback)(
39
+ (type, key, defaultValue = 1) => {
40
+ var _a, _b, _c, _d, _e;
41
+ return (_e = (_d = (_c = (_a = permissions == null ? void 0 : permissions[isDemoGame ? DEMO_GAME_TYPE_KEY : type]) == null ? void 0 : _a[key]) != null ? _c : (_b = permissions == null ? void 0 : permissions[NO_PERMISSION_MANNER_KEY]) == null ? void 0 : _b[key]) != null ? _d : defaultValue) != null ? _e : 1;
42
+ },
43
+ [permissions, isDemoGame]
44
+ );
45
+ return {
46
+ btnPermission: permissions,
47
+ isDemoGame,
48
+ getBtnPermission
49
+ };
50
+ };
51
+ var useBtnPermission_default = useBtnPermission;
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ DEMO_GAME_TYPE_KEY,
55
+ NO_PERMISSION_MANNER_KEY,
56
+ useBtnPermission
57
+ });
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const useHighSecurity: () => {
3
+ securityData: any;
4
+ setSecurityData: import("react").Dispatch<any>;
5
+ requestSecurityData: ({ gameId, param, env }: any) => Promise<void>;
6
+ };
@@ -0,0 +1,51 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/hooks/useHighSecurity.ts
20
+ var useHighSecurity_exports = {};
21
+ __export(useHighSecurity_exports, {
22
+ useHighSecurity: () => useHighSecurity
23
+ });
24
+ module.exports = __toCommonJS(useHighSecurity_exports);
25
+ var import_api = require("../api");
26
+ var import_react = require("react");
27
+ var useHighSecurity = () => {
28
+ const [securityData, setSecurityData] = (0, import_react.useState)({});
29
+ const requestSecurityData = async ({ gameId, param, env }) => {
30
+ var _a;
31
+ const { ret, data } = await (0, import_api.highSecurity)({
32
+ env: Number(env),
33
+ game_id: Number(gameId),
34
+ page_id: location.pathname,
35
+ param
36
+ });
37
+ if (ret === 0) {
38
+ securityData[param == null ? void 0 : param[0].key] = (_a = data == null ? void 0 : data[0]) == null ? void 0 : _a.value;
39
+ setSecurityData({ ...securityData });
40
+ }
41
+ };
42
+ return {
43
+ securityData,
44
+ setSecurityData,
45
+ requestSecurityData
46
+ };
47
+ };
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ useHighSecurity
51
+ });
@@ -0,0 +1,68 @@
1
+ import { commonEesType } from '../utils/request';
2
+ /** OS 平台数据类型定义 */
3
+ export interface OsItem {
4
+ id: number;
5
+ os_name: string;
6
+ sdk_name: string;
7
+ status: number;
8
+ platform_id: number;
9
+ }
10
+ export interface PlatformItem {
11
+ id: number;
12
+ platform_name_zh: string;
13
+ platform_name_en: string;
14
+ status: number;
15
+ }
16
+ export interface OsPlatformData {
17
+ os_list: OsItem[];
18
+ platform_list: PlatformItem[];
19
+ }
20
+ /** OS/平台列表请求函数:返回与 src/utils/request 响应拦截器解析后的结构一致({ code, msg, data }) */
21
+ export type OsPlatformFetcher = () => Promise<commonEesType<OsPlatformData>>;
22
+ /**
23
+ * 默认 fetcher:基于 src/utils/request 请求 OS/平台枚举接口。
24
+ * 与源项目 account-business-frontend 的 getOsPlatformList 接口路径一致;
25
+ * audience 参数由 request 拦截器自动补齐。
26
+ */
27
+ export declare const defaultOsPlatformFetcher: OsPlatformFetcher;
28
+ /**
29
+ * 清除缓存(用于极少数需要强制刷新的场景,如后台更新了平台列表后)。
30
+ * @param fetcher 指定要清除的 fetcher;不传则清除全部缓存
31
+ */
32
+ export declare const clearOsPlatformListCache: (fetcher?: OsPlatformFetcher) => void;
33
+ /**
34
+ * OS/平台列表 Hook(L3 业务 Hook)
35
+ *
36
+ * 拉取 OS 与平台枚举数据并做模块级缓存,整个会话只请求一次;
37
+ * 并发调用共享同一个进行中的请求。
38
+ *
39
+ * 零业务侵入:数据接口通过 fetcher 注入,不传时使用内置默认 fetcher
40
+ * (基于 src/utils/request 请求 /api/internal/business/manage/osPlatformList)。
41
+ *
42
+ * @param fetcher 自定义请求函数,需返回 { code, msg, data } 结构且 code === 0 视为成功
43
+ * @returns osPlatformList OS/平台数据,请求完成或命中缓存前为 undefined
44
+ *
45
+ * @example
46
+ * ```tsx
47
+ * import { useOsPlatformList } from '@pnt/business-components';
48
+ *
49
+ * const Demo = () => {
50
+ * const { osPlatformList } = useOsPlatformList();
51
+ * // 或注入自定义 fetcher(建议用 useCallback 保持引用稳定)
52
+ * // const { osPlatformList } = useOsPlatformList(() => http.get('/my/os/platform'));
53
+ *
54
+ * return (
55
+ * <Select
56
+ * options={osPlatformList?.platform_list.map((p) => ({
57
+ * label: p.platform_name_zh,
58
+ * value: p.id,
59
+ * }))}
60
+ * />
61
+ * );
62
+ * };
63
+ * ```
64
+ */
65
+ export declare const useOsPlatformList: (fetcher?: OsPlatformFetcher) => {
66
+ osPlatformList: OsPlatformData | undefined;
67
+ };
68
+ export default useOsPlatformList;
@@ -0,0 +1,104 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/hooks/useOsPlatformList.ts
30
+ var useOsPlatformList_exports = {};
31
+ __export(useOsPlatformList_exports, {
32
+ clearOsPlatformListCache: () => clearOsPlatformListCache,
33
+ default: () => useOsPlatformList_default,
34
+ defaultOsPlatformFetcher: () => defaultOsPlatformFetcher,
35
+ useOsPlatformList: () => useOsPlatformList
36
+ });
37
+ module.exports = __toCommonJS(useOsPlatformList_exports);
38
+ var import_react = require("react");
39
+ var import_request = __toESM(require("../utils/request"));
40
+ var defaultOsPlatformFetcher = () => import_request.default.get("/api/internal/business/manage/osPlatformList");
41
+ var cacheMap = /* @__PURE__ */ new Map();
42
+ var fetchOsPlatformList = async (fetcher) => {
43
+ const cached = cacheMap.get(fetcher);
44
+ if (cached == null ? void 0 : cached.data)
45
+ return cached.data;
46
+ if (cached == null ? void 0 : cached.pending)
47
+ return cached.pending;
48
+ const pending = (async () => {
49
+ try {
50
+ const res = await fetcher();
51
+ if (res.code === 0) {
52
+ cacheMap.set(fetcher, { data: res.data });
53
+ return res.data;
54
+ }
55
+ return void 0;
56
+ } finally {
57
+ const entry = cacheMap.get(fetcher);
58
+ cacheMap.set(fetcher, { data: entry == null ? void 0 : entry.data });
59
+ }
60
+ })();
61
+ cacheMap.set(fetcher, { data: cached == null ? void 0 : cached.data, pending });
62
+ return pending;
63
+ };
64
+ var clearOsPlatformListCache = (fetcher) => {
65
+ if (fetcher) {
66
+ cacheMap.delete(fetcher);
67
+ } else {
68
+ cacheMap.clear();
69
+ }
70
+ };
71
+ var useOsPlatformList = (fetcher = defaultOsPlatformFetcher) => {
72
+ const [osPlatformList, setOsPlatformList] = (0, import_react.useState)(
73
+ () => {
74
+ var _a;
75
+ return (_a = cacheMap.get(fetcher)) == null ? void 0 : _a.data;
76
+ }
77
+ );
78
+ (0, import_react.useEffect)(() => {
79
+ var _a;
80
+ const cached = (_a = cacheMap.get(fetcher)) == null ? void 0 : _a.data;
81
+ if (cached) {
82
+ setOsPlatformList(cached);
83
+ return;
84
+ }
85
+ let mounted = true;
86
+ fetchOsPlatformList(fetcher).then((data) => {
87
+ if (mounted && data)
88
+ setOsPlatformList(data);
89
+ });
90
+ return () => {
91
+ mounted = false;
92
+ };
93
+ }, [fetcher]);
94
+ return {
95
+ osPlatformList
96
+ };
97
+ };
98
+ var useOsPlatformList_default = useOsPlatformList;
99
+ // Annotate the CommonJS export names for ESM import in node:
100
+ 0 && (module.exports = {
101
+ clearOsPlatformListCache,
102
+ defaultOsPlatformFetcher,
103
+ useOsPlatformList
104
+ });
@@ -0,0 +1,72 @@
1
+ /// <reference types="react" />
2
+ import type { PaginationProps } from 'tdesign-react';
3
+ /** 分页内部状态 */
4
+ export interface PaginationData {
5
+ /** 当前页码(从 1 开始) */
6
+ currentPage: number;
7
+ /** 数据总条数 */
8
+ totalCount: number;
9
+ /** 总页数 */
10
+ totalPage: number;
11
+ /** 每页条数 */
12
+ pageSize: number;
13
+ }
14
+ /** 分页变化时回传给外部请求的参数 */
15
+ export interface PaginationRequestParams {
16
+ /** 页码(从 1 开始) */
17
+ pageNumber: number;
18
+ /** 每页条数 */
19
+ pageSize: number;
20
+ }
21
+ /** 分页变化回调 */
22
+ export type OnPaginationRequest = (params: PaginationRequestParams) => void;
23
+ /**
24
+ * 分页 Hook(L3 业务 Hook)
25
+ *
26
+ * 维护分页状态,并在页码 / 每页条数变化时通过 onPaginationRequest 回调通知外部发起请求。
27
+ * 请求完成后由外部调用 setPaginationData 回写最新分页数据。
28
+ *
29
+ * 特性:
30
+ * - totalCount 为 0 时 paginationProps 返回 undefined,可直接透传给 tdesign-react 的 Pagination 组件(不渲染分页器);
31
+ * - 切换每页条数时自动回到第 1 页;
32
+ * - 返回的 paginationProps 可直接展开到 <Pagination {...paginationProps} />。
33
+ *
34
+ * @param onPaginationRequest 页码或每页条数变化时的回调,外部在此发起列表请求
35
+ * @returns paginationData 分页数据;setPaginationData 回写分页数据;paginationProps tdesign-react Pagination 组件属性(totalCount 为 0 时为 undefined)
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * import { Pagination } from 'tdesign-react';
40
+ * import { usePagination } from '@pnt/business-components';
41
+ *
42
+ * const Demo = () => {
43
+ * const [list, setList] = useState<Item[]>([]);
44
+ * const { paginationData, setPaginationData, paginationProps } = usePagination(
45
+ * async ({ pageNumber, pageSize }) => {
46
+ * const res = await fetchList({ page: pageNumber, size: pageSize });
47
+ * setList(res.data.list);
48
+ * setPaginationData((prev) => ({
49
+ * ...prev,
50
+ * currentPage: pageNumber,
51
+ * pageSize,
52
+ * totalCount: res.data.total,
53
+ * totalPage: Math.ceil(res.data.total / pageSize),
54
+ * }));
55
+ * },
56
+ * );
57
+ *
58
+ * return (
59
+ * <>
60
+ * <Table data={list} />
61
+ * {paginationProps && <Pagination {...paginationProps} />}
62
+ * </>
63
+ * );
64
+ * };
65
+ * ```
66
+ */
67
+ export declare const usePagination: (onPaginationRequest: OnPaginationRequest) => {
68
+ paginationData: PaginationData;
69
+ setPaginationData: import("react").Dispatch<import("react").SetStateAction<PaginationData>>;
70
+ paginationProps: PaginationProps | undefined;
71
+ };
72
+ export default usePagination;
@@ -0,0 +1,71 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/hooks/usePagination.ts
20
+ var usePagination_exports = {};
21
+ __export(usePagination_exports, {
22
+ default: () => usePagination_default,
23
+ usePagination: () => usePagination
24
+ });
25
+ module.exports = __toCommonJS(usePagination_exports);
26
+ var import_react = require("react");
27
+ var usePagination = (onPaginationRequest) => {
28
+ const [paginationData, setPaginationData] = (0, import_react.useState)({
29
+ currentPage: 1,
30
+ totalCount: 0,
31
+ totalPage: 0,
32
+ pageSize: 10
33
+ });
34
+ const handleCurrentChange = (0, import_react.useCallback)(
35
+ (current, pageInfo) => {
36
+ onPaginationRequest({
37
+ pageNumber: current,
38
+ pageSize: pageInfo.pageSize
39
+ });
40
+ },
41
+ [onPaginationRequest]
42
+ );
43
+ const handlePageSizeChange = (0, import_react.useCallback)(
44
+ (pageSize) => {
45
+ onPaginationRequest({ pageNumber: 1, pageSize });
46
+ },
47
+ [onPaginationRequest]
48
+ );
49
+ const paginationProps = (0, import_react.useMemo)(() => {
50
+ if (paginationData.totalCount === 0)
51
+ return void 0;
52
+ return {
53
+ pageSizeOptions: [10, 20, 30, 50, 100],
54
+ pageSize: paginationData.pageSize,
55
+ current: paginationData.currentPage,
56
+ total: paginationData.totalCount,
57
+ onCurrentChange: handleCurrentChange,
58
+ onPageSizeChange: handlePageSizeChange
59
+ };
60
+ }, [paginationData, handleCurrentChange, handlePageSizeChange]);
61
+ return {
62
+ paginationData,
63
+ setPaginationData,
64
+ paginationProps
65
+ };
66
+ };
67
+ var usePagination_default = usePagination;
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ usePagination
71
+ });
@@ -0,0 +1,10 @@
1
+ export { default as PntCopyData } from './components/PntCopyData';
2
+ export { default as PntImagePreview } from './components/PntImagePreview';
3
+ export { default as PntSecureBox } from './components/PntSecureBox';
4
+ export { default as useBtnPermission } from './hooks/useBtnPermission';
5
+ export { useHighSecurity } from './hooks/useHighSecurity';
6
+ export { default as useOsPlatformList } from './hooks/useOsPlatformList';
7
+ export { default as usePagination } from './hooks/usePagination';
8
+ export type { BtnPermissionMap, UseBtnPermissionOptions } from './hooks/useBtnPermission';
9
+ export type { OsPlatformData, OsPlatformFetcher } from './hooks/useOsPlatformList';
10
+ export type { PaginationData, PaginationRequestParams, OnPaginationRequest } from './hooks/usePagination';
@@ -0,0 +1,57 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/index.ts
30
+ var src_exports = {};
31
+ __export(src_exports, {
32
+ PntCopyData: () => import_PntCopyData.default,
33
+ PntImagePreview: () => import_PntImagePreview.default,
34
+ PntSecureBox: () => import_PntSecureBox.default,
35
+ useBtnPermission: () => import_useBtnPermission.default,
36
+ useHighSecurity: () => import_useHighSecurity.useHighSecurity,
37
+ useOsPlatformList: () => import_useOsPlatformList.default,
38
+ usePagination: () => import_usePagination.default
39
+ });
40
+ module.exports = __toCommonJS(src_exports);
41
+ var import_PntCopyData = __toESM(require("./components/PntCopyData"));
42
+ var import_PntImagePreview = __toESM(require("./components/PntImagePreview"));
43
+ var import_PntSecureBox = __toESM(require("./components/PntSecureBox"));
44
+ var import_useBtnPermission = __toESM(require("./hooks/useBtnPermission"));
45
+ var import_useHighSecurity = require("./hooks/useHighSecurity");
46
+ var import_useOsPlatformList = __toESM(require("./hooks/useOsPlatformList"));
47
+ var import_usePagination = __toESM(require("./hooks/usePagination"));
48
+ // Annotate the CommonJS export names for ESM import in node:
49
+ 0 && (module.exports = {
50
+ PntCopyData,
51
+ PntImagePreview,
52
+ PntSecureBox,
53
+ useBtnPermission,
54
+ useHighSecurity,
55
+ useOsPlatformList,
56
+ usePagination
57
+ });
@@ -0,0 +1,13 @@
1
+ export declare const SUB_APP_PATHNAME: {
2
+ ACCOUNT: string;
3
+ SDK: string;
4
+ NOTICE: string;
5
+ CONFIGFROM: string;
6
+ CONFIGTHEME: string;
7
+ REVIEWLIST: string;
8
+ INTERNALTOOLS: string;
9
+ REPORTS: string;
10
+ };
11
+ export declare const AUDIENCE_MAPPING: {
12
+ [x: string]: string;
13
+ };
@@ -0,0 +1,51 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/const.ts
20
+ var const_exports = {};
21
+ __export(const_exports, {
22
+ AUDIENCE_MAPPING: () => AUDIENCE_MAPPING,
23
+ SUB_APP_PATHNAME: () => SUB_APP_PATHNAME
24
+ });
25
+ module.exports = __toCommonJS(const_exports);
26
+ var SUB_APP_PATHNAME = {
27
+ ACCOUNT: "/laas",
28
+ SDK: "/intlsdk",
29
+ NOTICE: "/notice",
30
+ CONFIGFROM: "/configform",
31
+ CONFIGTHEME: "/configtheme",
32
+ REVIEWLIST: "/approvalservices",
33
+ INTERNALTOOLS: "/internaltools",
34
+ REPORTS: "/reports"
35
+ };
36
+ var audienceSuffix = "-pnt";
37
+ var AUDIENCE_MAPPING = {
38
+ [SUB_APP_PATHNAME.ACCOUNT]: `/laas${audienceSuffix}`,
39
+ [SUB_APP_PATHNAME.SDK]: `/intl-sdk${audienceSuffix}`,
40
+ [SUB_APP_PATHNAME.NOTICE]: `/notice${audienceSuffix}`,
41
+ [SUB_APP_PATHNAME.CONFIGFROM]: `/configform${audienceSuffix}`,
42
+ [SUB_APP_PATHNAME.CONFIGTHEME]: `/configtheme${audienceSuffix}`,
43
+ [SUB_APP_PATHNAME.REVIEWLIST]: `/approval-services${audienceSuffix}`,
44
+ [SUB_APP_PATHNAME.INTERNALTOOLS]: `/internaltools${audienceSuffix}`,
45
+ [SUB_APP_PATHNAME.REPORTS]: `/reports${audienceSuffix}`
46
+ };
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ AUDIENCE_MAPPING,
50
+ SUB_APP_PATHNAME
51
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 判断是否是高敏信息逻辑
3
+ * @param {*} val
4
+ * @returns
5
+ */
6
+ export declare const isSecurityData: (val: string | number) => boolean;