@pnt-team/pnt-component-frontend 0.0.113 → 0.0.120
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/lib/cjs/api/cos.js +24 -15
- package/lib/cjs/api/index.d.ts +3 -8
- package/lib/cjs/api/index.js +1 -4
- package/lib/cjs/api/types/index.d.ts +20 -30
- package/lib/cjs/components/PntBusinessSelect/index.d.ts +0 -5
- package/lib/cjs/components/PntBusinessSelect/index.js +1 -11
- package/lib/cjs/components/PntRegionSelect/index.d.ts +0 -9
- package/lib/cjs/components/PntRegionSelect/index.js +50 -38
- package/lib/cjs/components/PntRegionSelect/types.d.ts +10 -6
- package/lib/cjs/config.d.ts +26 -2
- package/lib/cjs/config.js +5 -2
- package/lib/cjs/index.d.ts +3 -1
- package/lib/cjs/index.js +7 -0
- package/lib/esm/api/index.d.ts +3 -8
- package/lib/esm/api/index.js +2 -8
- package/lib/esm/api/types/index.d.ts +20 -30
- package/lib/esm/components/PntBusinessSelect/index.d.ts +0 -5
- package/lib/esm/components/PntBusinessSelect/index.js +1 -3
- package/lib/esm/components/PntRegionSelect/index.d.ts +0 -9
- package/lib/esm/components/PntRegionSelect/index.js +48 -43
- package/lib/esm/components/PntRegionSelect/types.d.ts +10 -6
- package/lib/esm/components/PntRegionSelect/types.js +0 -2
- package/lib/esm/config.d.ts +26 -2
- package/lib/esm/config.js +13 -1
- package/lib/esm/index.d.ts +3 -1
- package/lib/esm/index.js +2 -0
- package/lib/umd/pnt-component-frontend.min.js +1 -1
- package/package.json +1 -1
package/lib/cjs/api/cos.js
CHANGED
|
@@ -85,13 +85,16 @@ var fetchCosCredential = async (http, params, customNormalize) => {
|
|
|
85
85
|
switch (scene) {
|
|
86
86
|
case "default": {
|
|
87
87
|
const { gameId, ...restContext } = context;
|
|
88
|
-
const res = await http.get(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
const res = await http.get(
|
|
89
|
+
`/v2/business/operation/get-cos-temp-token?audience=${audience}`,
|
|
90
|
+
{
|
|
91
|
+
params: {
|
|
92
|
+
content_length: contentLength,
|
|
93
|
+
...restContext
|
|
94
|
+
},
|
|
95
|
+
headers: gameId !== void 0 ? { "x-service-type": String(gameId) } : void 0
|
|
96
|
+
}
|
|
97
|
+
);
|
|
95
98
|
return resolveCredential(res, normalizeSnake, customNormalize);
|
|
96
99
|
}
|
|
97
100
|
case "default_download": {
|
|
@@ -110,17 +113,23 @@ var fetchCosCredential = async (http, params, customNormalize) => {
|
|
|
110
113
|
return resolveCredential(res, normalizeSnake, customNormalize);
|
|
111
114
|
}
|
|
112
115
|
case "sdk_customize": {
|
|
113
|
-
const res = await http.post(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
const res = await http.post(
|
|
117
|
+
"/internal/sdk_customize/upload_token",
|
|
118
|
+
{
|
|
119
|
+
content_length: contentLength,
|
|
120
|
+
...context
|
|
121
|
+
}
|
|
122
|
+
);
|
|
117
123
|
return resolveCredential(res, normalizeSdkCustomize, customNormalize);
|
|
118
124
|
}
|
|
119
125
|
case "ai_translate": {
|
|
120
|
-
const res = await http.post(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
126
|
+
const res = await http.post(
|
|
127
|
+
"/business/aiTranslate/import/cosToken",
|
|
128
|
+
{
|
|
129
|
+
contentLength,
|
|
130
|
+
...context
|
|
131
|
+
}
|
|
132
|
+
);
|
|
124
133
|
return resolveCredential(res, normalizeAiTranslate, customNormalize);
|
|
125
134
|
}
|
|
126
135
|
default: {
|
package/lib/cjs/api/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { commonEesType, PntHttpLike } from "../config";
|
|
2
|
-
import {
|
|
2
|
+
import { BusinessGameInfoHighSecurityDecryptBody, BusinessGameInfoHighSecurityDecryptResponse, BusinessRegionQueryBody, BusinessRegionQueryResponse, BusinessSelectListBody, BusinessSelectListResponse } from './types/index';
|
|
3
3
|
/**
|
|
4
4
|
* 业务下拉选择列表
|
|
5
5
|
* @param http 由 PntProvider 注入的 axios 实例
|
|
@@ -18,11 +18,6 @@ export declare const businessGameInfoHighSecurityDecrypt: (axios: PntHttpLike, d
|
|
|
18
18
|
* @param axios 由 PntProvider 注入的 axios 实例
|
|
19
19
|
* @param data 请求参数;不传时不带任何参数,返回全部国家区域(251 个);
|
|
20
20
|
* 传 game_id 时返回该业务最终生效的区域
|
|
21
|
+
* @param url 自定义接口 URL(可选,覆盖默认值)
|
|
21
22
|
*/
|
|
22
|
-
export declare const businessRegionQuery: (axios: PntHttpLike, data?: BusinessRegionQueryBody) => Promise<commonEesType<BusinessRegionQueryResponse>>;
|
|
23
|
-
/**
|
|
24
|
-
* 自定义合规区域列表
|
|
25
|
-
* @param axios 由 PntProvider 注入的 axios 实例
|
|
26
|
-
* @param data 请求参数(game_id + env)
|
|
27
|
-
*/
|
|
28
|
-
export declare const businessGameInfoGetCustomRegion: (axios: PntHttpLike, data: BusinessGameInfoGetCustomRegionBody) => Promise<commonEesType<BusinessGameInfoGetCustomRegionResponse>>;
|
|
23
|
+
export declare const businessRegionQuery: (axios: PntHttpLike, data?: BusinessRegionQueryBody, url?: string) => Promise<commonEesType<BusinessRegionQueryResponse>>;
|
package/lib/cjs/api/index.js
CHANGED
|
@@ -19,7 +19,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/api/index.ts
|
|
20
20
|
var api_exports = {};
|
|
21
21
|
__export(api_exports, {
|
|
22
|
-
businessGameInfoGetCustomRegion: () => businessGameInfoGetCustomRegion,
|
|
23
22
|
businessGameInfoHighSecurityDecrypt: () => businessGameInfoHighSecurityDecrypt,
|
|
24
23
|
businessRegionQuery: () => businessRegionQuery,
|
|
25
24
|
businessSelectList: () => businessSelectList
|
|
@@ -30,11 +29,9 @@ var businessGameInfoHighSecurityDecrypt = (axios, data, url) => axios.post(
|
|
|
30
29
|
url || "/v3/business/game_info/high-security-decrypt?audience=/laas-pnt",
|
|
31
30
|
data
|
|
32
31
|
);
|
|
33
|
-
var businessRegionQuery = (axios, data) => axios.post("/
|
|
34
|
-
var businessGameInfoGetCustomRegion = (axios, data) => axios.post("/v4/business/game_info/get-custom-region?audience=/laas-pnt", data);
|
|
32
|
+
var businessRegionQuery = (axios, data, url) => axios.post(url || "/v5/business/region/query?audience=/laas-pnt", data);
|
|
35
33
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
34
|
0 && (module.exports = {
|
|
37
|
-
businessGameInfoGetCustomRegion,
|
|
38
35
|
businessGameInfoHighSecurityDecrypt,
|
|
39
36
|
businessRegionQuery,
|
|
40
37
|
businessSelectList
|
|
@@ -4,23 +4,31 @@
|
|
|
4
4
|
* 数据来源: https://api-pnt.intlgame.com
|
|
5
5
|
*/
|
|
6
6
|
export interface BusinessSelectListBody {
|
|
7
|
-
/**
|
|
8
|
-
business_access_method?: number;
|
|
9
|
-
/** 业务类型列表:1-正式业务,2-测试业务;SmartLink业务始终不返回 */
|
|
7
|
+
/** 业务类型列表,仅 game_list、game_list_option 场景支持:1-正式业务,2-测试业务 */
|
|
10
8
|
business_types?: number[];
|
|
9
|
+
/** 云控类型列表,仅 game_list、game_list_option 场景支持:1-INTL Project,2-LI PASS Project */
|
|
10
|
+
cloudCtrlType?: number[];
|
|
11
|
+
/** 集群类型列表,仅 game_list、game_list_option 场景支持:1-公有,2-私有,3-未配置 */
|
|
12
|
+
clusterTypes?: number[];
|
|
11
13
|
/** 需要返回的字段;未传时使用场景默认字段,仅支持服务端白名单字段 */
|
|
12
14
|
fields?: string[];
|
|
13
|
-
/**
|
|
15
|
+
/** 业务ID列表,仅 game_list、game_list_option 场景支持 */
|
|
14
16
|
game_ids?: string[];
|
|
15
17
|
/** 业务ID、中文名称或英文名称的模糊匹配关键字 */
|
|
16
18
|
keyword?: string;
|
|
19
|
+
/** 登录器类型列表,仅 game_list、game_list_option 场景支持 */
|
|
20
|
+
lander_type?: number[];
|
|
21
|
+
/** LI PASS 开关列表,仅 game_list、game_list_option 场景支持:1-开启,2-未开启 */
|
|
22
|
+
lipSwitches?: number[];
|
|
17
23
|
/** 当前页 */
|
|
18
24
|
pageNum?: number;
|
|
19
25
|
/** 每页条数 */
|
|
20
26
|
pageSize?: number;
|
|
21
|
-
/**
|
|
27
|
+
/** 平台列表,仅 game_list、game_list_option 场景支持 */
|
|
28
|
+
platform?: string[];
|
|
29
|
+
/** 下拉场景:game_list-业务列表,game_list_option-业务选择,compliance_age-合规年龄,custom_region-自定义合规地域,sdk-SDK定制 */
|
|
22
30
|
scene?: string;
|
|
23
|
-
/**
|
|
31
|
+
/** 业务状态列表,仅 game_list、game_list_option 场景支持:3-线上运营,4-接入中,5-中途结项,6-已下线 */
|
|
24
32
|
statuses?: number[];
|
|
25
33
|
/** 总条数 */
|
|
26
34
|
total?: number;
|
|
@@ -34,6 +42,8 @@ export interface BusinessSelectListResponseListItem {
|
|
|
34
42
|
business_type?: number;
|
|
35
43
|
/** 当前场景是否可创建;仅 compliance_age、custom_region 场景有意义 */
|
|
36
44
|
creatable?: boolean;
|
|
45
|
+
/** 当前业务是否禁用合规年龄认证;仅 compliance_age 场景有意义 */
|
|
46
|
+
disabled?: boolean;
|
|
37
47
|
/** 业务ID */
|
|
38
48
|
game_id?: string;
|
|
39
49
|
/** 业务接口开发负责人;SDK场景可返回 */
|
|
@@ -79,16 +89,14 @@ export interface BusinessGameInfoHighSecurityDecryptBody {
|
|
|
79
89
|
}
|
|
80
90
|
export type BusinessGameInfoHighSecurityDecryptResponse = Record<string, unknown>[];
|
|
81
91
|
export interface BusinessRegionQueryBody {
|
|
82
|
-
/** GameID 目标业务 ID
|
|
83
|
-
|
|
92
|
+
/** GameID 目标业务 ID;取值 > 0 时返回该业务实际生效的国家区域;
|
|
93
|
+
取值 <= 0 或未传时返回国家区域全量字典;与当前登录业务是否一致不做强校验(跨业务查询合法)。 */
|
|
84
94
|
game_id?: number;
|
|
85
|
-
/** Search 模糊搜索关键字,按 name_en / name_ch / num_code 匹配;可选,默认空字符串。 */
|
|
86
|
-
search?: string;
|
|
87
95
|
}
|
|
88
96
|
export interface BusinessRegionQueryResponseRegionListItem {
|
|
89
97
|
/** ID 区域主键 ID。 */
|
|
90
98
|
id?: number;
|
|
91
|
-
/** IsEEARegion 是否 EEA
|
|
99
|
+
/** IsEEARegion 是否 EEA 区域,取值:0=否,1=是。 */
|
|
92
100
|
is_eea_region?: number;
|
|
93
101
|
/** IsSecretRegion 是否特殊合规区域,取值:1=默认区域,2=特殊区域。 */
|
|
94
102
|
is_secret_region?: number;
|
|
@@ -104,24 +112,6 @@ export interface BusinessRegionQueryResponseRegionListItem {
|
|
|
104
112
|
region_en?: string;
|
|
105
113
|
}
|
|
106
114
|
export interface BusinessRegionQueryResponse {
|
|
107
|
-
/**
|
|
108
|
-
black_codes?: string[];
|
|
109
|
-
/** RegionList 国家区域列表;base_region_list 返回完整字典(或搜索子集),
|
|
110
|
-
business_effective_region_list 返回业务最终生效结果,business_region_rule_detail 返回完整字典(或搜索子集)。 */
|
|
111
|
-
region_list?: BusinessRegionQueryResponseRegionListItem[];
|
|
112
|
-
/** RuleState 业务规则状态,取值见 RuleState* 常量:0=未配置,1=启用,2=停用;
|
|
113
|
-
仅 business_effective_region_list / business_region_rule_detail 场景返回;base_region_list 场景省略(omitempty)。 */
|
|
114
|
-
rule_state?: number;
|
|
115
|
-
/** WhiteCodes 白名单数字码列表;base_region_list / business_effective_region_list 返回空数组,business_region_rule_detail 返回真实值。 */
|
|
116
|
-
white_codes?: string[];
|
|
117
|
-
}
|
|
118
|
-
export interface BusinessGameInfoGetCustomRegionBody {
|
|
119
|
-
/** GameID 目标业务 ID */
|
|
120
|
-
game_id: number;
|
|
121
|
-
/** Env 环境 */
|
|
122
|
-
env: number;
|
|
123
|
-
}
|
|
124
|
-
export interface BusinessGameInfoGetCustomRegionResponse {
|
|
125
|
-
/** RegionList 自定义合规区域列表 */
|
|
115
|
+
/** RegionList 国家区域列表:未携带 game_id 时为全量字典,携带 game_id 时为该业务实际生效区域;均按 id 升序。 */
|
|
126
116
|
region_list?: BusinessRegionQueryResponseRegionListItem[];
|
|
127
117
|
}
|
|
@@ -37,11 +37,6 @@ interface PntBusinessSelectProps {
|
|
|
37
37
|
* @description 1-正式业务,2-测试业务
|
|
38
38
|
*/
|
|
39
39
|
businessTypes?: number[];
|
|
40
|
-
/**
|
|
41
|
-
* 业务接入类型筛选
|
|
42
|
-
* @description 1-纯SDK,2-LI PASS,3-工作室品牌账号
|
|
43
|
-
*/
|
|
44
|
-
businessAccessMethod?: number;
|
|
45
40
|
/**
|
|
46
41
|
* 标签格式
|
|
47
42
|
* @description name-中文名,name_en-英文名,name_id-中文名(ID),name_en_id-英文名(ID)
|
|
@@ -36,7 +36,6 @@ var PntBusinessSelect = (props) => {
|
|
|
36
36
|
scene = "default",
|
|
37
37
|
statuses,
|
|
38
38
|
businessTypes,
|
|
39
|
-
businessAccessMethod,
|
|
40
39
|
labelFormat = "name",
|
|
41
40
|
labelField,
|
|
42
41
|
optionLabel,
|
|
@@ -94,19 +93,10 @@ var PntBusinessSelect = (props) => {
|
|
|
94
93
|
scene,
|
|
95
94
|
statuses,
|
|
96
95
|
business_types: businessTypes,
|
|
97
|
-
business_access_method: businessAccessMethod,
|
|
98
96
|
fields
|
|
99
97
|
}),
|
|
100
98
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
101
|
-
[
|
|
102
|
-
scene,
|
|
103
|
-
statusesKey,
|
|
104
|
-
businessTypesKey,
|
|
105
|
-
businessAccessMethod,
|
|
106
|
-
pageSize,
|
|
107
|
-
fieldsKey,
|
|
108
|
-
pagination
|
|
109
|
-
]
|
|
99
|
+
[scene, statusesKey, businessTypesKey, pageSize, fieldsKey, pagination]
|
|
110
100
|
);
|
|
111
101
|
const fetchData = (0, import_react.useCallback)(
|
|
112
102
|
async (kw, page, append) => {
|
|
@@ -13,15 +13,6 @@ import type { PntRegionSelectProps } from './types';
|
|
|
13
13
|
* onChange={(v) => setRegions(v)}
|
|
14
14
|
* />
|
|
15
15
|
*
|
|
16
|
-
* // 自定义合规区域
|
|
17
|
-
* <PntRegionSelect
|
|
18
|
-
* dataSource="custom"
|
|
19
|
-
* gameId={gameId}
|
|
20
|
-
* env={0}
|
|
21
|
-
* value={regions}
|
|
22
|
-
* onChange={(v) => setRegions(v)}
|
|
23
|
-
* />
|
|
24
|
-
*
|
|
25
16
|
* // 业务最终生效区域
|
|
26
17
|
* <PntRegionSelect
|
|
27
18
|
* dataSource="business"
|
|
@@ -40,13 +40,19 @@ var import_ImportDialog = __toESM(require("./ImportDialog"));
|
|
|
40
40
|
var import_index = require("./index.scss");
|
|
41
41
|
var import_types = require("./types");
|
|
42
42
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
43
|
+
var normalizeRegionCode = (code) => {
|
|
44
|
+
if (code == null || code === "")
|
|
45
|
+
return "";
|
|
46
|
+
const str = String(code);
|
|
47
|
+
return /^\d+$/.test(str) ? String(Number(str)) : str;
|
|
48
|
+
};
|
|
43
49
|
var toRegionOptions = (list) => (list || []).map((item) => {
|
|
44
|
-
var _a, _b
|
|
50
|
+
var _a, _b;
|
|
45
51
|
return {
|
|
46
52
|
...item,
|
|
47
|
-
region_code: (
|
|
48
|
-
region_ch: (
|
|
49
|
-
region_en: (
|
|
53
|
+
region_code: normalizeRegionCode(item.region_code),
|
|
54
|
+
region_ch: (_a = item.region_ch) != null ? _a : "",
|
|
55
|
+
region_en: (_b = item.region_en) != null ? _b : ""
|
|
50
56
|
};
|
|
51
57
|
});
|
|
52
58
|
var getLabelText = (item, format) => {
|
|
@@ -68,8 +74,8 @@ var PntRegionSelect = (props) => {
|
|
|
68
74
|
onChange,
|
|
69
75
|
multiple = true,
|
|
70
76
|
dataSource = "default",
|
|
77
|
+
scope = "business",
|
|
71
78
|
gameId,
|
|
72
|
-
env = 0,
|
|
73
79
|
options: externalOptions,
|
|
74
80
|
disabled = false,
|
|
75
81
|
placeholder,
|
|
@@ -79,6 +85,7 @@ var PntRegionSelect = (props) => {
|
|
|
79
85
|
texts: customTexts,
|
|
80
86
|
onLoaded,
|
|
81
87
|
optionDisabled,
|
|
88
|
+
optionFilter,
|
|
82
89
|
optionTooltip,
|
|
83
90
|
importable = false,
|
|
84
91
|
invertible = false,
|
|
@@ -90,7 +97,9 @@ var PntRegionSelect = (props) => {
|
|
|
90
97
|
style,
|
|
91
98
|
popupProps
|
|
92
99
|
} = props;
|
|
93
|
-
const
|
|
100
|
+
const config = (0, import_config.usePntConfigOptional)();
|
|
101
|
+
const http = config == null ? void 0 : config.http;
|
|
102
|
+
const regionQuery = config == null ? void 0 : config.regionQuery;
|
|
94
103
|
const texts = (0, import_react.useMemo)(
|
|
95
104
|
() => ({ ...import_types.DEFAULT_TEXTS, ...customTexts }),
|
|
96
105
|
[customTexts]
|
|
@@ -104,84 +113,87 @@ var PntRegionSelect = (props) => {
|
|
|
104
113
|
onLoadedRef.current = onLoaded;
|
|
105
114
|
const isExternal = externalOptions !== void 0;
|
|
106
115
|
const fetchData = (0, import_react.useCallback)(async () => {
|
|
107
|
-
var _a, _b, _c
|
|
116
|
+
var _a, _b, _c;
|
|
108
117
|
if (isExternal)
|
|
109
118
|
return;
|
|
119
|
+
if (!http) {
|
|
120
|
+
console.warn(
|
|
121
|
+
"[PntRegionSelect] 未注入 PntProvider.http,无法内部拉取区域数据;请用 <PntProvider> 包裹,或改用外部 options 模式"
|
|
122
|
+
);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
110
125
|
const seq = ++fetchSeqRef.current;
|
|
111
126
|
setLoading(true);
|
|
112
127
|
try {
|
|
113
128
|
let list = [];
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
console.warn(
|
|
117
|
-
'[PntRegionSelect] dataSource="custom" 时必须传入 gameId'
|
|
118
|
-
);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const res = await (0, import_api.businessGameInfoGetCustomRegion)(http, {
|
|
122
|
-
game_id: Number(gameId),
|
|
123
|
-
env
|
|
124
|
-
});
|
|
125
|
-
if (seq !== fetchSeqRef.current)
|
|
126
|
-
return;
|
|
127
|
-
if (res.code === 0 && ((_a = res.data) == null ? void 0 : _a.region_list)) {
|
|
128
|
-
list = toRegionOptions(res.data.region_list);
|
|
129
|
-
}
|
|
130
|
-
} else if (dataSource === "business") {
|
|
129
|
+
const url = scope === "platform" ? (regionQuery == null ? void 0 : regionQuery.queryPlatUrl) || "/v5/business/region/plat-query?audience=/laas-pnt" : (regionQuery == null ? void 0 : regionQuery.queryUrl) || "/v5/business/region/query?audience=/laas-pnt";
|
|
130
|
+
if (dataSource === "business") {
|
|
131
131
|
if (!gameId) {
|
|
132
132
|
console.warn(
|
|
133
133
|
'[PntRegionSelect] dataSource="business" 时必须传入 gameId'
|
|
134
134
|
);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
|
-
const res = await (0, import_api.businessRegionQuery)(
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
const res = await (0, import_api.businessRegionQuery)(
|
|
138
|
+
http,
|
|
139
|
+
{
|
|
140
|
+
game_id: Number(gameId)
|
|
141
|
+
},
|
|
142
|
+
url
|
|
143
|
+
);
|
|
140
144
|
if (seq !== fetchSeqRef.current)
|
|
141
145
|
return;
|
|
142
|
-
if (res.code === 0 && ((
|
|
146
|
+
if (res.code === 0 && ((_a = res.data) == null ? void 0 : _a.region_list)) {
|
|
143
147
|
list = toRegionOptions(res.data.region_list);
|
|
144
148
|
}
|
|
145
149
|
} else {
|
|
146
|
-
const res = await (0, import_api.businessRegionQuery)(http, {});
|
|
150
|
+
const res = await (0, import_api.businessRegionQuery)(http, {}, url);
|
|
147
151
|
if (seq !== fetchSeqRef.current)
|
|
148
152
|
return;
|
|
149
|
-
if (res.code === 0 && ((
|
|
153
|
+
if (res.code === 0 && ((_b = res.data) == null ? void 0 : _b.region_list)) {
|
|
150
154
|
list = toRegionOptions(res.data.region_list);
|
|
151
155
|
}
|
|
152
156
|
}
|
|
153
157
|
setInnerOptions(list);
|
|
154
|
-
(
|
|
158
|
+
(_c = onLoadedRef.current) == null ? void 0 : _c.call(onLoadedRef, list);
|
|
155
159
|
} catch {
|
|
156
160
|
} finally {
|
|
157
161
|
if (seq === fetchSeqRef.current) {
|
|
158
162
|
setLoading(false);
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
|
-
}, [http, dataSource, gameId,
|
|
165
|
+
}, [http, dataSource, gameId, isExternal, scope, regionQuery]);
|
|
162
166
|
(0, import_react.useEffect)(() => {
|
|
163
167
|
fetchData();
|
|
164
168
|
}, [fetchData]);
|
|
165
169
|
const options = (0, import_react.useMemo)(
|
|
166
|
-
() => isExternal ? externalOptions : innerOptions
|
|
170
|
+
() => (isExternal ? externalOptions : innerOptions).map((item) => ({
|
|
171
|
+
...item,
|
|
172
|
+
region_code: normalizeRegionCode(item.region_code)
|
|
173
|
+
})),
|
|
167
174
|
[isExternal, externalOptions, innerOptions]
|
|
168
175
|
);
|
|
169
176
|
const valueArr = (0, import_react.useMemo)(() => {
|
|
170
177
|
if (value === void 0 || value === null || value === "")
|
|
171
178
|
return [];
|
|
172
|
-
|
|
179
|
+
const arr = Array.isArray(value) ? value : [value];
|
|
180
|
+
return arr.map((v) => normalizeRegionCode(v));
|
|
173
181
|
}, [value]);
|
|
174
182
|
const filteredOptions = (0, import_react.useMemo)(() => {
|
|
183
|
+
let result = options;
|
|
184
|
+
if (optionFilter) {
|
|
185
|
+
result = result.filter(optionFilter);
|
|
186
|
+
}
|
|
175
187
|
if (!searchKeyword)
|
|
176
|
-
return
|
|
188
|
+
return result;
|
|
177
189
|
const kw = searchKeyword.toLowerCase();
|
|
178
|
-
return
|
|
190
|
+
return result.filter(
|
|
179
191
|
(item) => {
|
|
180
192
|
var _a, _b, _c;
|
|
181
193
|
return ((_a = item.region_ch) == null ? void 0 : _a.toLowerCase().includes(kw)) || ((_b = item.region_en) == null ? void 0 : _b.toLowerCase().includes(kw)) || ((_c = item.region_code) == null ? void 0 : _c.toLowerCase().includes(kw));
|
|
182
194
|
}
|
|
183
195
|
);
|
|
184
|
-
}, [options, searchKeyword]);
|
|
196
|
+
}, [options, searchKeyword, optionFilter]);
|
|
185
197
|
const isOptionDisabled = (0, import_react.useCallback)(
|
|
186
198
|
(item) => {
|
|
187
199
|
if (item.disabled)
|
|
@@ -244,7 +256,7 @@ var PntRegionSelect = (props) => {
|
|
|
244
256
|
(val) => {
|
|
245
257
|
var _a, _b;
|
|
246
258
|
const values = Array.isArray(val) ? val : val ? [val] : [];
|
|
247
|
-
const strValues = values.map(
|
|
259
|
+
const strValues = values.map(normalizeRegionCode);
|
|
248
260
|
const selectedOptions = options.filter(
|
|
249
261
|
(o) => strValues.includes(o.region_code)
|
|
250
262
|
);
|
|
@@ -22,10 +22,8 @@ export interface RegionOption {
|
|
|
22
22
|
* 数据源类型
|
|
23
23
|
* - default: 全部国家区域(不带任何参数,返回全部 251 个)/api/v5/business/region/query
|
|
24
24
|
* - business: 业务最终生效的区域(必须传 gameId)/api/v5/business/region/query
|
|
25
|
-
* - custom: 自定义合规区域 /v4/business/game_info/get-custom-region
|
|
26
|
-
* - compliance: 合规区域(从业务配置接口获取 compliance_zone)
|
|
27
25
|
*/
|
|
28
|
-
export type RegionDataSource = 'default' | 'business'
|
|
26
|
+
export type RegionDataSource = 'default' | 'business';
|
|
29
27
|
/**
|
|
30
28
|
* 标签格式
|
|
31
29
|
* - name: 中文名
|
|
@@ -100,10 +98,14 @@ export interface PntRegionSelectProps {
|
|
|
100
98
|
multiple?: boolean;
|
|
101
99
|
/** 数据源类型 @default 'default' */
|
|
102
100
|
dataSource?: RegionDataSource;
|
|
103
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* 接口作用域 @default 'business'
|
|
103
|
+
* - business: 业务级区域查询 /api/v5/business/region/query
|
|
104
|
+
* - platform: 平台级区域查询 /api/v5/business/region/plat-query
|
|
105
|
+
*/
|
|
106
|
+
scope?: 'business' | 'platform';
|
|
107
|
+
/** 业务ID(dataSource='business' 时必传) */
|
|
104
108
|
gameId?: string | number;
|
|
105
|
-
/** 环境(dataSource='custom' 时必传) @default 0 */
|
|
106
|
-
env?: number;
|
|
107
109
|
/**
|
|
108
110
|
* 外部受控选项列表(传入后跳过内部请求,直接使用该数据;
|
|
109
111
|
* 适用于选项由父组件获取/过滤的场景)
|
|
@@ -125,6 +127,8 @@ export interface PntRegionSelectProps {
|
|
|
125
127
|
onLoaded?: (options: RegionOption[]) => void;
|
|
126
128
|
/** 自定义选项禁用逻辑 */
|
|
127
129
|
optionDisabled?: (item: RegionOption) => boolean;
|
|
130
|
+
/** 自定义选项过滤逻辑(内部拉取数据时生效,用于只展示部分区域) */
|
|
131
|
+
optionFilter?: (item: RegionOption) => boolean;
|
|
128
132
|
/** 自定义选项 tooltip */
|
|
129
133
|
optionTooltip?: (item: RegionOption) => string;
|
|
130
134
|
/**
|
package/lib/cjs/config.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export interface commonEesType<T> {
|
|
|
15
15
|
* 任何具备 axios 兼容 post 签名的实例均可注入。
|
|
16
16
|
*/
|
|
17
17
|
export interface PntHttpLike {
|
|
18
|
-
get<
|
|
19
|
-
post<
|
|
18
|
+
get<R = unknown>(url: string, config?: any): Promise<R>;
|
|
19
|
+
post<R = unknown, D = unknown>(url: string, data?: D, config?: any): Promise<R>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* 高敏信息解锁接口配置(可选,全局覆盖)
|
|
@@ -37,6 +37,21 @@ export interface PntHighSecurityConfig {
|
|
|
37
37
|
/** audience 覆盖(默认 /laas-pnt) */
|
|
38
38
|
audience?: string;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* 地区查询接口配置(可选,全局覆盖)
|
|
42
|
+
*/
|
|
43
|
+
export interface PntRegionQueryConfig {
|
|
44
|
+
/**
|
|
45
|
+
* 业务级地区查询接口 URL,覆盖默认 /api/v5/business/region/query?audience=/laas-pnt
|
|
46
|
+
* @description scope='business'(默认)时使用
|
|
47
|
+
*/
|
|
48
|
+
queryUrl?: string;
|
|
49
|
+
/**
|
|
50
|
+
* 平台级地区查询接口 URL,覆盖默认 /api/v5/business/region/plat-query?audience=/laas-pnt
|
|
51
|
+
* @description scope='platform' 时使用
|
|
52
|
+
*/
|
|
53
|
+
queryPlatUrl?: string;
|
|
54
|
+
}
|
|
40
55
|
/**
|
|
41
56
|
* 组件库运行时配置:由消费方通过 PntProvider 注入
|
|
42
57
|
*/
|
|
@@ -45,6 +60,8 @@ export interface PntConfig {
|
|
|
45
60
|
http: PntHttpLike;
|
|
46
61
|
/** 高敏信息解锁接口全局配置(可选) */
|
|
47
62
|
highSecurity?: PntHighSecurityConfig;
|
|
63
|
+
/** 地区查询接口全局配置(可选) */
|
|
64
|
+
regionQuery?: PntRegionQueryConfig;
|
|
48
65
|
}
|
|
49
66
|
/**
|
|
50
67
|
* 配置 Provider:消费方在应用根入口包裹一次即可
|
|
@@ -64,3 +81,10 @@ export declare const PntProvider: import("react").Provider<PntConfig | null>;
|
|
|
64
81
|
* @internal
|
|
65
82
|
*/
|
|
66
83
|
export declare const usePntConfig: () => PntConfig;
|
|
84
|
+
/**
|
|
85
|
+
* 获取组件库运行时配置(可选版本,内部使用)
|
|
86
|
+
* @description 供「外部受控数据」模式的组件使用:未注入 Provider 时返回 null,
|
|
87
|
+
* 组件自行降级(不发起内部请求),不抛错
|
|
88
|
+
* @internal
|
|
89
|
+
*/
|
|
90
|
+
export declare const usePntConfigOptional: () => PntConfig | null;
|
package/lib/cjs/config.js
CHANGED
|
@@ -20,7 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
var config_exports = {};
|
|
21
21
|
__export(config_exports, {
|
|
22
22
|
PntProvider: () => PntProvider,
|
|
23
|
-
usePntConfig: () => usePntConfig
|
|
23
|
+
usePntConfig: () => usePntConfig,
|
|
24
|
+
usePntConfigOptional: () => usePntConfigOptional
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(config_exports);
|
|
26
27
|
var import_react = require("react");
|
|
@@ -35,8 +36,10 @@ var usePntConfig = () => {
|
|
|
35
36
|
}
|
|
36
37
|
return cfg;
|
|
37
38
|
};
|
|
39
|
+
var usePntConfigOptional = () => (0, import_react.useContext)(PntContext);
|
|
38
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
41
|
0 && (module.exports = {
|
|
40
42
|
PntProvider,
|
|
41
|
-
usePntConfig
|
|
43
|
+
usePntConfig,
|
|
44
|
+
usePntConfigOptional
|
|
42
45
|
});
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { PntProvider, usePntConfig, type PntConfig, type PntHighSecurityConfig, type PntHttpLike, type commonEesType, } from './config';
|
|
1
|
+
export { PntProvider, usePntConfig, type PntConfig, type PntHighSecurityConfig, type PntHttpLike, type PntRegionQueryConfig, type commonEesType, } from './config';
|
|
2
2
|
export { default as PntImage } from './components/PntImage';
|
|
3
3
|
export { default as PntBusinessSelect } from './components/PntBusinessSelect';
|
|
4
4
|
export { default as PntRegionSelect } from './components/PntRegionSelect';
|
|
@@ -7,4 +7,6 @@ export { default as PntSecureBox } from './components/PntSecureBox';
|
|
|
7
7
|
export { useHighSecurity } from './hooks/useHighSecurity';
|
|
8
8
|
export type { ClearSecurityDataFilter, HighSecurityApiConfig, HighSecurityParamItem, HighSecurityRequestParams, HighSecurityScope, UseHighSecurityOptions, UseHighSecurityResult, } from './hooks/useHighSecurity';
|
|
9
9
|
export { isSecurityData } from './utils';
|
|
10
|
+
export { businessGameInfoHighSecurityDecrypt, businessRegionQuery, businessSelectList, } from './api';
|
|
11
|
+
export type { BusinessRegionQueryBody, BusinessRegionQueryResponse, BusinessRegionQueryResponseRegionListItem, } from './api/types';
|
|
10
12
|
export { default as PntGeneralLayout } from './components/PntGeneralLayout';
|
package/lib/cjs/index.js
CHANGED
|
@@ -35,6 +35,9 @@ __export(src_exports, {
|
|
|
35
35
|
PntProvider: () => import_config.PntProvider,
|
|
36
36
|
PntRegionSelect: () => import_PntRegionSelect.default,
|
|
37
37
|
PntSecureBox: () => import_PntSecureBox.default,
|
|
38
|
+
businessGameInfoHighSecurityDecrypt: () => import_api.businessGameInfoHighSecurityDecrypt,
|
|
39
|
+
businessRegionQuery: () => import_api.businessRegionQuery,
|
|
40
|
+
businessSelectList: () => import_api.businessSelectList,
|
|
38
41
|
isSecurityData: () => import_utils.isSecurityData,
|
|
39
42
|
useHighSecurity: () => import_useHighSecurity.useHighSecurity,
|
|
40
43
|
usePntConfig: () => import_config.usePntConfig
|
|
@@ -47,6 +50,7 @@ var import_PntRegionSelect = __toESM(require("./components/PntRegionSelect"));
|
|
|
47
50
|
var import_PntSecureBox = __toESM(require("./components/PntSecureBox"));
|
|
48
51
|
var import_useHighSecurity = require("./hooks/useHighSecurity");
|
|
49
52
|
var import_utils = require("./utils");
|
|
53
|
+
var import_api = require("./api");
|
|
50
54
|
var import_PntGeneralLayout = __toESM(require("./components/PntGeneralLayout"));
|
|
51
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
52
56
|
0 && (module.exports = {
|
|
@@ -56,6 +60,9 @@ var import_PntGeneralLayout = __toESM(require("./components/PntGeneralLayout"));
|
|
|
56
60
|
PntProvider,
|
|
57
61
|
PntRegionSelect,
|
|
58
62
|
PntSecureBox,
|
|
63
|
+
businessGameInfoHighSecurityDecrypt,
|
|
64
|
+
businessRegionQuery,
|
|
65
|
+
businessSelectList,
|
|
59
66
|
isSecurityData,
|
|
60
67
|
useHighSecurity,
|
|
61
68
|
usePntConfig
|
package/lib/esm/api/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { commonEesType, PntHttpLike } from "../config";
|
|
2
|
-
import {
|
|
2
|
+
import { BusinessGameInfoHighSecurityDecryptBody, BusinessGameInfoHighSecurityDecryptResponse, BusinessRegionQueryBody, BusinessRegionQueryResponse, BusinessSelectListBody, BusinessSelectListResponse } from './types/index';
|
|
3
3
|
/**
|
|
4
4
|
* 业务下拉选择列表
|
|
5
5
|
* @param http 由 PntProvider 注入的 axios 实例
|
|
@@ -18,11 +18,6 @@ export declare const businessGameInfoHighSecurityDecrypt: (axios: PntHttpLike, d
|
|
|
18
18
|
* @param axios 由 PntProvider 注入的 axios 实例
|
|
19
19
|
* @param data 请求参数;不传时不带任何参数,返回全部国家区域(251 个);
|
|
20
20
|
* 传 game_id 时返回该业务最终生效的区域
|
|
21
|
+
* @param url 自定义接口 URL(可选,覆盖默认值)
|
|
21
22
|
*/
|
|
22
|
-
export declare const businessRegionQuery: (axios: PntHttpLike, data?: BusinessRegionQueryBody) => Promise<commonEesType<BusinessRegionQueryResponse>>;
|
|
23
|
-
/**
|
|
24
|
-
* 自定义合规区域列表
|
|
25
|
-
* @param axios 由 PntProvider 注入的 axios 实例
|
|
26
|
-
* @param data 请求参数(game_id + env)
|
|
27
|
-
*/
|
|
28
|
-
export declare const businessGameInfoGetCustomRegion: (axios: PntHttpLike, data: BusinessGameInfoGetCustomRegionBody) => Promise<commonEesType<BusinessGameInfoGetCustomRegionResponse>>;
|
|
23
|
+
export declare const businessRegionQuery: (axios: PntHttpLike, data?: BusinessRegionQueryBody, url?: string) => Promise<commonEesType<BusinessRegionQueryResponse>>;
|
package/lib/esm/api/index.js
CHANGED
|
@@ -18,12 +18,6 @@ export const businessGameInfoHighSecurityDecrypt = (axios, data, url) => axios.p
|
|
|
18
18
|
* @param axios 由 PntProvider 注入的 axios 实例
|
|
19
19
|
* @param data 请求参数;不传时不带任何参数,返回全部国家区域(251 个);
|
|
20
20
|
* 传 game_id 时返回该业务最终生效的区域
|
|
21
|
+
* @param url 自定义接口 URL(可选,覆盖默认值)
|
|
21
22
|
*/
|
|
22
|
-
export const businessRegionQuery = (axios, data) => axios.post('/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 自定义合规区域列表
|
|
26
|
-
* @param axios 由 PntProvider 注入的 axios 实例
|
|
27
|
-
* @param data 请求参数(game_id + env)
|
|
28
|
-
*/
|
|
29
|
-
export const businessGameInfoGetCustomRegion = (axios, data) => axios.post('/v4/business/game_info/get-custom-region?audience=/laas-pnt', data);
|
|
23
|
+
export const businessRegionQuery = (axios, data, url) => axios.post(url || '/v5/business/region/query?audience=/laas-pnt', data);
|