@zw-team/react-lib 1.0.4 → 1.0.5-beta.2

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.
@@ -6,3 +6,21 @@
6
6
  .block-box + .block-box {
7
7
  margin-top: 15px;
8
8
  }
9
+
10
+ .search-block-box {
11
+ padding: 0;
12
+ }
13
+
14
+ .search-block-box .block-content {
15
+ padding: 16px 20px;
16
+ }
17
+
18
+ .search-block-box .block-footer {
19
+ box-shadow: 0 -1px 0 0 #e5e6eb;
20
+ }
21
+
22
+ .search-block-box .block-footer:empty {
23
+ padding: 0;
24
+ margin-top: 0;
25
+ box-shadow: none;
26
+ }
@@ -3,7 +3,7 @@ import { ConfigProvider } from "antd";
3
3
  import js_cookie from "js-cookie";
4
4
  import { useCallback, useEffect, useState } from "react";
5
5
  import { initProdEnvWarning } from "../../utils/advisory.js";
6
- import { loadIconMock, loadSvg } from "../../utils/svgIcon/index.js";
6
+ import { loadIcon, loadSvg } from "../../utils/svgIcon/index.js";
7
7
  import AccessReport from "../AccessReport/index.js";
8
8
  import { ConfigContext, defaultConfig } from "./ConfigContext.js";
9
9
  const ConfigProvider_ConfigProvider_ConfigProvider = ({ children, antdConfig, ...restProps })=>{
@@ -33,13 +33,13 @@ const ConfigProvider_ConfigProvider_ConfigProvider = ({ children, antdConfig, ..
33
33
  js_cookie.set('$BiEnv', contextValue.env);
34
34
  js_cookie.set('$BiSystem', contextValue.system);
35
35
  initProdEnvWarning(contextValue.env || 'production');
36
- loadSvg(contextValue.system, contextValue.env || 'production');
37
- if (contextValue.needIcon) loadIconMock(contextValue.env || 'production', (data)=>{
36
+ loadSvg(contextValue.system, contextValue.env || 'production', contextValue.mainOrigin);
37
+ if (contextValue.needIcon) loadIcon(contextValue.env || 'production', (data)=>{
38
38
  updateConfig({
39
39
  iconList: data.data,
40
40
  iconInit: true
41
41
  });
42
- });
42
+ }, contextValue.mainOrigin);
43
43
  };
44
44
  useEffect(()=>{
45
45
  install();
@@ -3,6 +3,7 @@ import type AccessReport from '../AccessReport';
3
3
  export interface ContextValue {
4
4
  env: string;
5
5
  system: string;
6
+ mainOrigin?: string;
6
7
  request: any;
7
8
  needIcon: boolean;
8
9
  iconInit: boolean;
@@ -2,13 +2,14 @@ import { jsx } from "react/jsx-runtime";
2
2
  import "./Form.css";
3
3
  import { Form } from "antd";
4
4
  const BaseForm = (props)=>{
5
- const { form: externalForm, children, ...rest } = props;
5
+ const { form: externalForm, children, layout = 'inline', ...rest } = props;
6
6
  const [internalForm] = Form.useForm();
7
7
  const form = externalForm ?? internalForm;
8
8
  return /*#__PURE__*/ jsx("div", {
9
9
  className: "search-form",
10
10
  children: /*#__PURE__*/ jsx(Form, {
11
11
  form: form,
12
+ layout: layout,
12
13
  ...rest,
13
14
  children: children
14
15
  })
@@ -2,8 +2,10 @@
2
2
  display: flex;
3
3
  align-items: center;
4
4
  box-sizing: border-box;
5
- min-width: 350px;
5
+ min-width: 352px;
6
6
  padding: 0 16px 16px 0;
7
+ margin: 0;
8
+ flex: 0 0 auto;
7
9
  }
8
10
 
9
11
  .search-item .search-item-label {
@@ -13,6 +15,10 @@
13
15
  display: flex;
14
16
  align-items: center;
15
17
  justify-content: flex-end;
18
+ flex-shrink: 0;
19
+ margin: 0;
20
+ max-height: 32px;
21
+ overflow: hidden;
16
22
  }
17
23
 
18
24
  .search-item .ant-form-item {
@@ -21,18 +27,101 @@
21
27
 
22
28
  .search-item .search-label-select {
23
29
  padding-right: 0;
30
+ margin-right: -1px;
24
31
  }
25
32
 
26
33
  .search-item .search-item-content {
27
34
  flex: 1;
35
+ flex-grow: 1;
36
+ min-width: 0;
28
37
  }
29
38
 
30
- .search-item .ant-select {
39
+ .search-item .ant-select,
40
+ .search-item .ant-input-affix-wrapper,
41
+ .search-item .ant-picker,
42
+ .search-item .ant-cascader,
43
+ .search-item .ant-cascader-picker,
44
+ .search-item .search-item-content > * {
31
45
  width: 100%;
32
46
  }
33
47
 
34
48
  .search-item-button {
35
49
  width: 100%;
36
50
  flex-shrink: 0;
37
- /* 允许元素根据需要增长 */
51
+ padding-bottom: 0;
52
+ }
53
+
54
+ .search-item-button .search-item-content {
55
+ width: 100%;
56
+ padding-left: 96px;
57
+ }
58
+
59
+ .search-form .search-item:last-child {
60
+ width: 100%;
61
+ padding-bottom: 0;
62
+ }
63
+
64
+ .hideSidebar .search-form .search-item-button,
65
+ .openSidebar .search-form .search-item-button,
66
+ .search-form .search-item-button,
67
+ .hideSidebar .search-form .search-item:last-child,
68
+ .openSidebar .search-form .search-item:last-child {
69
+ width: 100%;
70
+ }
71
+
72
+ @media screen and (max-width: 1285px) {
73
+ .hideSidebar .search-form .search-item {
74
+ width: 50%;
75
+ }
76
+ }
77
+
78
+ @media screen and (min-width: 1186px) {
79
+ .hideSidebar .search-form .search-item {
80
+ width: 33.3%;
81
+ }
82
+ }
83
+
84
+ @media screen and (min-width: 1538px) {
85
+ .hideSidebar .search-form .search-item {
86
+ width: 25%;
87
+ }
88
+ }
89
+
90
+ @media screen and (min-width: 1890px) {
91
+ .hideSidebar .search-form .search-item {
92
+ width: 20%;
93
+ }
94
+ }
95
+
96
+ @media screen and (max-width: 1345px) {
97
+ .openSidebar .search-form .search-item {
98
+ width: 50%;
99
+ }
100
+ }
101
+
102
+ @media screen and (min-width: 1346px) {
103
+ .openSidebar .search-form .search-item {
104
+ width: 33.3%;
105
+ }
106
+ }
107
+
108
+ @media screen and (min-width: 1698px) {
109
+ .openSidebar .search-form .search-item {
110
+ width: 25%;
111
+ }
112
+ }
113
+
114
+ @media screen and (min-width: 2050px) {
115
+ .openSidebar .search-form .search-item {
116
+ width: 20%;
117
+ }
118
+ }
119
+
120
+ @media screen {
121
+ .hideSidebar .search-form .search-item-button,
122
+ .openSidebar .search-form .search-item-button,
123
+ .hideSidebar .search-form .search-item:last-child,
124
+ .openSidebar .search-form .search-item:last-child {
125
+ width: 100%;
126
+ }
38
127
  }
@@ -0,0 +1,4 @@
1
+ import '../Block/Block.css';
2
+ import type { SearchBlockProps } from './types';
3
+ declare const SearchBlock: (props: SearchBlockProps) => import("react/jsx-runtime").JSX.Element;
4
+ export default SearchBlock;
@@ -0,0 +1,22 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { classNames } from "../../utils/classNames.js";
3
+ import "../Block/Block.css";
4
+ const SearchBlock = (props)=>{
5
+ const { children, footer, className, style, contentClassName, footerClassName } = props;
6
+ return /*#__PURE__*/ jsxs("div", {
7
+ className: classNames('block-box search-block-box', className),
8
+ style: style,
9
+ children: [
10
+ /*#__PURE__*/ jsx("div", {
11
+ className: classNames('block-content', contentClassName),
12
+ children: children
13
+ }),
14
+ /*#__PURE__*/ jsx("div", {
15
+ className: classNames('block-footer', footerClassName),
16
+ children: footer
17
+ })
18
+ ]
19
+ });
20
+ };
21
+ const SearchBlock_SearchBlock = SearchBlock;
22
+ export { SearchBlock_SearchBlock as default };
@@ -0,0 +1,2 @@
1
+ export { default as BiSearchBlock } from './SearchBlock';
2
+ export type { SearchBlockProps } from './types';
@@ -0,0 +1,2 @@
1
+ import SearchBlock from "./SearchBlock.js";
2
+ export { SearchBlock as BiSearchBlock };
@@ -0,0 +1,13 @@
1
+ export interface SearchBlockProps {
2
+ children: React.ReactNode;
3
+ /** 底部视图区域,用于承载筛选区下方的自定义视图组件 */
4
+ footer?: React.ReactNode;
5
+ /** 额外 className */
6
+ className?: string;
7
+ /** 额外 style */
8
+ style?: React.CSSProperties;
9
+ /** 内容区额外 className */
10
+ contentClassName?: string;
11
+ /** 底部区额外 className */
12
+ footerClassName?: string;
13
+ }
File without changes
@@ -22,6 +22,7 @@ export * from './NavbarTool';
22
22
  export * from './NoticeCenter';
23
23
  export * from './Pagination';
24
24
  export { default as ResponseInterceptor } from './ResponseInterceptor';
25
+ export * from './SearchBlock';
25
26
  export * from './SuperDate';
26
27
  export * from './SystemLink';
27
28
  export * from './Table';
@@ -20,6 +20,7 @@ export * from "./MoreButton/index.js";
20
20
  export * from "./NavbarTool/index.js";
21
21
  export * from "./NoticeCenter/index.js";
22
22
  export * from "./Pagination/index.js";
23
+ export * from "./SearchBlock/index.js";
23
24
  export * from "./SuperDate/index.js";
24
25
  export * from "./SystemLink/index.js";
25
26
  export * from "./Table/index.js";
@@ -20,6 +20,8 @@ export interface RequestConfig {
20
20
  data?: Record<string, any>;
21
21
  /** 请求头 */
22
22
  headers?: Record<string, string>;
23
+ /** 微前端宿主 origin,用于开发态代理请求落到主应用 */
24
+ mainOrigin?: string;
23
25
  }
24
26
  /**
25
27
  * 统一请求封装函数
@@ -5,9 +5,21 @@ var request_SystemType = /*#__PURE__*/ function(SystemType) {
5
5
  SystemType["OTHER"] = "other";
6
6
  return SystemType;
7
7
  }({});
8
+ function isAbsoluteUrl(url) {
9
+ return /^https?:\/\//i.test(url);
10
+ }
11
+ function joinUrl(origin, path) {
12
+ const normalizedOrigin = origin.replace(/\/$/, '');
13
+ const normalizedPath = path.startsWith('/') ? path : `/${path}`;
14
+ return `${normalizedOrigin}${normalizedPath}`;
15
+ }
16
+ function resolveBaseUrl(baseUrl, mainOrigin) {
17
+ if (!mainOrigin || isAbsoluteUrl(baseUrl)) return baseUrl;
18
+ return joinUrl(mainOrigin, baseUrl);
19
+ }
8
20
  function request(config) {
9
- const { env = 'production', system, api, data = {}, headers = {} } = config;
10
- const baseUrl = getServiceURL(void 0, env);
21
+ const { env = 'production', system, api, data = {}, headers = {}, mainOrigin } = config;
22
+ const baseUrl = resolveBaseUrl(getServiceURL(void 0, env), mainOrigin);
11
23
  if ("zq" === system) {
12
24
  const defaultHeaders = {
13
25
  Authkey: 'authtpe84dzfl3iq62'
@@ -13,8 +13,9 @@ export interface IconInfoResponse {
13
13
  export interface IconListResponse {
14
14
  status_code: number;
15
15
  data: {
16
+ data: Record<string, unknown>;
16
17
  link: string;
17
- [key: string]: any;
18
+ [key: string]: unknown;
18
19
  };
19
20
  }
20
21
  /**
@@ -32,16 +33,16 @@ export type LoadIconCallback = (data: IconListResponse['data']) => void;
32
33
  * @param character 图标字符
33
34
  * @param env 环境参数
34
35
  */
35
- export declare function loadSvg(character: string, env: string): void;
36
+ export declare function loadSvg(character: string, env: string, mainOrigin?: string): void;
36
37
  /**
37
38
  * 加载图标列表
38
39
  * @param env 环境参数
39
40
  * @param callback 加载完成回调函数
40
41
  */
41
- export declare function loadIcon(env: string, callback: LoadIconCallback): void;
42
+ export declare function loadIcon(env: string, callback: LoadIconCallback, mainOrigin?: string): void;
42
43
  /**
43
44
  * 加载图标列表-mock
44
45
  * @param env 环境参数
45
46
  * @param callback 加载完成回调函数
46
47
  */
47
- export declare function loadIconMock(env: string, callback: LoadIconCallback): void;
48
+ export declare function loadIconMock(_env: string, callback: LoadIconCallback): void;
@@ -1,36 +1,64 @@
1
1
  import request from "../request/index.js";
2
- function getIconUrl(character, env) {
2
+ const DEFAULT_ICONPARK_URL = 'https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/svg_27771_3.b32c3fc4f408b5328f0e67954786ee1f.js';
3
+ const svgLoadCache = new Map();
4
+ const iconListLoadCache = new Map();
5
+ const scriptLoadCache = new Set();
6
+ function getIconUrl(character, env, mainOrigin) {
3
7
  return request({
4
8
  env,
5
9
  system: 'zq',
6
10
  api: '/data/system/getInfo',
7
11
  data: {
8
12
  character
9
- }
13
+ },
14
+ mainOrigin
10
15
  });
11
16
  }
12
- function getIconList(env) {
17
+ function getIconList(env, mainOrigin) {
13
18
  return request({
14
19
  env,
15
20
  system: 'zq',
16
- api: '/api/icon/list'
21
+ api: '/api/icon/list',
22
+ mainOrigin
17
23
  });
18
24
  }
25
+ function getSvgCacheKey(character, env, mainOrigin) {
26
+ return [
27
+ character,
28
+ env,
29
+ mainOrigin || ''
30
+ ].join('|');
31
+ }
32
+ function getIconListCacheKey(env, mainOrigin) {
33
+ return [
34
+ env,
35
+ mainOrigin || ''
36
+ ].join('|');
37
+ }
19
38
  function loadScript(url) {
39
+ if (!url || scriptLoadCache.has(url)) return;
40
+ scriptLoadCache.add(url);
20
41
  const script = document.createElement("script");
21
42
  script.src = url;
22
43
  document.head.appendChild(script);
23
44
  }
24
- function loadSvg(character, env) {
25
- getIconUrl(character, env).then((res)=>{
26
- loadScript('https://lf1-cdn-tos.bytegoofy.com/obj/iconpark/svg_27771_3.b32c3fc4f408b5328f0e67954786ee1f.js');
45
+ function loadSvg(character, env, mainOrigin) {
46
+ if (!character) return;
47
+ const cacheKey = getSvgCacheKey(character, env, mainOrigin);
48
+ const pending = svgLoadCache.get(cacheKey) || getIconUrl(character, env, mainOrigin);
49
+ svgLoadCache.set(cacheKey, pending);
50
+ pending.then((res)=>{
51
+ loadScript(DEFAULT_ICONPARK_URL);
27
52
  if (1 === res.status_code && res.data.icon_url) setTimeout(()=>{
28
53
  loadScript(res.data.icon_url);
29
54
  });
30
55
  });
31
56
  }
32
- function loadIcon(env, callback) {
33
- getIconList(env).then((res)=>{
57
+ function loadIcon(env, callback, mainOrigin) {
58
+ const cacheKey = getIconListCacheKey(env, mainOrigin);
59
+ const pending = iconListLoadCache.get(cacheKey) || getIconList(env, mainOrigin);
60
+ iconListLoadCache.set(cacheKey, pending);
61
+ pending.then((res)=>{
34
62
  if (1 === res.status_code) {
35
63
  callback(res.data);
36
64
  setTimeout(()=>{
@@ -39,7 +67,7 @@ function loadIcon(env, callback) {
39
67
  }
40
68
  });
41
69
  }
42
- function loadIconMock(env, callback) {
70
+ function loadIconMock(_env, callback) {
43
71
  const res = {
44
72
  data: {
45
73
  data: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zw-team/react-lib",
3
- "version": "1.0.4",
3
+ "version": "1.0.5-beta.2",
4
4
  "description": "zw-team 业务组件库,基于 React + Ant Design,提供通用组件、Hooks 与工具函数",
5
5
  "keywords": [
6
6
  "react",