@cqsjjb/jjb-react-admin-component 3.1.3 → 3.2.0-beta.0

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,127 +1,112 @@
1
- import React from 'react';
1
+ import React, { useState, useRef, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Form, Button, Space, Row, Col } from 'antd';
4
4
  import { SearchOutlined, DoubleRightOutlined, UndoOutlined } from '@ant-design/icons';
5
- import './index.less';
6
- class searchForm extends React.Component {
7
- form = /*#__PURE__*/React.createRef();
8
- state = {
9
- isOpen: false
10
- };
11
- getButtons() {
12
- const {
13
- form,
14
- expand,
15
- formLine,
16
- colSize,
17
- loading,
18
- onReset,
19
- onExpand
20
- } = this.props;
21
- return /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
22
- type: "primary",
23
- icon: /*#__PURE__*/React.createElement(SearchOutlined, null),
24
- htmlType: "submit",
25
- loading: loading
26
- }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
27
- icon: /*#__PURE__*/React.createElement(UndoOutlined, null),
28
- loading: loading,
29
- onClick: () => {
30
- form ? form.current.resetFields() : this.form.current.resetFields();
31
- onReset(form ? form.current.getFieldsValue() : this.form.current.getFieldsValue());
32
- }
33
- }, "\u91CD\u7F6E"), expand && formLine.length / colSize > 1 && /*#__PURE__*/React.createElement(Button, {
34
- icon: /*#__PURE__*/React.createElement(DoubleRightOutlined, {
35
- style: {
36
- transform: this.state.isOpen ? 'rotate(-90deg)' : 'rotate(90deg)'
37
- }
38
- }),
39
- onClick: () => {
40
- const open = !this.state.isOpen;
41
- this.setState({
42
- isOpen: open
43
- }, () => {
44
- onExpand && onExpand(open);
45
- });
46
- }
47
- }, this.state.isOpen ? '收起' : '展开'));
48
- }
49
- groupsList() {
50
- const arr = [];
51
- this.props.formLine.forEach(i => {
52
- arr.push({
53
- show: true,
54
- node: i
5
+ const SearchForm = ({
6
+ form: externalForm,
7
+ style,
8
+ expand,
9
+ // 受控
10
+ defaultExpand = false,
11
+ // 内部默认展开
12
+ colSize = 3,
13
+ loading = false,
14
+ formLine = [],
15
+ initialValues = {},
16
+ onRef = () => {},
17
+ onReset = () => {},
18
+ onFinish = () => {},
19
+ onExpand
20
+ }) => {
21
+ const internalForm = useRef();
22
+ const form = externalForm || internalForm;
23
+ const [internalOpen, setInternalOpen] = useState(defaultExpand);
24
+ useEffect(() => {
25
+ if (onRef) {
26
+ onRef(form);
27
+ }
28
+ }, [form, onRef]);
29
+ const isControlled = expand !== undefined;
30
+ const isOpen = isControlled ? expand : internalOpen;
31
+ const handleToggle = () => {
32
+ if (isControlled) {
33
+ onExpand && onExpand(!expand);
34
+ } else {
35
+ setInternalOpen(prev => {
36
+ const next = !prev;
37
+ onExpand && onExpand(next);
38
+ return next;
55
39
  });
56
- });
57
- if (this.props.expand && this.state.isOpen) {
58
- return arr;
59
40
  }
60
- if (!this.props.expand && arr.length > 3) {
61
- return arr;
41
+ };
42
+ const getButtons = () => /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
43
+ type: "primary",
44
+ icon: /*#__PURE__*/React.createElement(SearchOutlined, null),
45
+ htmlType: "submit",
46
+ loading: loading
47
+ }, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
48
+ icon: /*#__PURE__*/React.createElement(UndoOutlined, null),
49
+ loading: loading,
50
+ onClick: () => {
51
+ form.current.resetFields();
52
+ onReset(form.current.getFieldsValue());
62
53
  }
63
- arr.forEach((i, index) => {
64
- if (index > 2) {
65
- i.show = false;
54
+ }, "\u91CD\u7F6E"), formLine.length / colSize > 1 && /*#__PURE__*/React.createElement(Button, {
55
+ icon: /*#__PURE__*/React.createElement(DoubleRightOutlined, {
56
+ style: {
57
+ transform: isOpen ? 'rotate(-90deg)' : 'rotate(90deg)'
66
58
  }
67
- });
68
- return arr;
69
- }
70
- componentDidMount() {
71
- if (this.props.onRef) {
72
- this.props.onRef(this.form);
59
+ }),
60
+ onClick: handleToggle
61
+ }, isOpen ? '收起' : '展开'));
62
+ const groupsList = () => {
63
+ const arr = formLine.map(node => ({
64
+ show: true,
65
+ node
66
+ }));
67
+ if (isOpen || arr.length <= 3) {
68
+ return arr;
73
69
  }
74
- }
75
- render() {
76
- const {
77
- form,
78
- style,
79
- colSize,
80
- initialValues,
81
- onFinish
82
- } = this.props;
83
- const formItemList = this.groupsList();
84
- return formItemList.length > 0 ? /*#__PURE__*/React.createElement(Form, {
85
- ref: form || this.form,
86
- style: style,
87
- initialValues: initialValues,
88
- onFinish: values => onFinish(values)
89
- }, /*#__PURE__*/React.createElement(Row, {
90
- gutter: [16, 16]
91
- }, formItemList.map((item, index) => /*#__PURE__*/React.createElement(Col, {
92
- style: {
93
- display: item.show ? 'block' : 'none'
94
- },
95
- key: index,
96
- span: 24 / colSize
97
- }, item.node)), /*#__PURE__*/React.createElement(Col, {
98
- span: 24 / colSize
99
- }, /*#__PURE__*/React.createElement(Form.Item, {
100
- noStyle: true
101
- }, this.getButtons())))) : /*#__PURE__*/React.createElement(React.Fragment, null);
102
- }
103
- }
104
- searchForm.defaultProps = {
105
- style: {},
106
- expand: false,
107
- colSize: 3,
108
- loading: false,
109
- formLine: [],
110
- initialValues: {},
111
- onRef: () => {},
112
- onReset: () => {},
113
- onFinish: () => {}
70
+ return arr.map((item, index) => index > 2 ? {
71
+ ...item,
72
+ show: false
73
+ } : item);
74
+ };
75
+ const formItemList = groupsList();
76
+ if (formItemList.length === 0) return null;
77
+ return /*#__PURE__*/React.createElement(Form, {
78
+ ref: form,
79
+ style: style,
80
+ initialValues: initialValues,
81
+ onFinish: values => onFinish(values)
82
+ }, /*#__PURE__*/React.createElement(Row, {
83
+ gutter: [16, 16]
84
+ }, formItemList.map((item, index) => /*#__PURE__*/React.createElement(Col, {
85
+ key: index,
86
+ span: 24 / colSize,
87
+ style: {
88
+ display: item.show ? 'block' : 'none'
89
+ }
90
+ }, item.node)), /*#__PURE__*/React.createElement(Col, {
91
+ span: 24 / colSize
92
+ }, /*#__PURE__*/React.createElement(Form.Item, {
93
+ noStyle: true
94
+ }, getButtons()))));
114
95
  };
115
- searchForm.propTypes = {
96
+ SearchForm.propTypes = {
116
97
  form: PropTypes.object,
117
98
  style: PropTypes.object,
118
99
  expand: PropTypes.bool,
100
+ // 受控
101
+ defaultExpand: PropTypes.bool,
102
+ // 内部默认展开
119
103
  colSize: PropTypes.number,
120
104
  loading: PropTypes.bool,
121
105
  formLine: PropTypes.array,
122
106
  initialValues: PropTypes.object,
123
107
  onRef: PropTypes.func,
124
108
  onReset: PropTypes.func,
125
- onFinish: PropTypes.func
109
+ onFinish: PropTypes.func,
110
+ onExpand: PropTypes.func
126
111
  };
127
- export default searchForm;
112
+ export default SearchForm;
package/Table/index.d.ts CHANGED
@@ -4,13 +4,9 @@ import * as React from 'react';
4
4
  import type { TableProps } from 'antd';
5
5
 
6
6
  interface OverTableProps extends TableProps {
7
- /**
8
- * 是否禁用内容区滚动,默认false
9
- */
7
+ // 是否禁用内容区滚动,默认-false
10
8
  disabledResizer?: boolean;
11
- /**
12
- * 当一个路由下存在多个表格的情况下 需要给每一个表格设置一个唯一存储索引 若没有设置则使用默认索引,请注意缓存数据会被覆盖
13
- */
9
+ // 当一个路由下存在多个表格的情况下 需要给每一个表格设置一个唯一存储索引 若没有设置则使用默认索引,请注意缓存数据会被覆盖
14
10
  storeIndex?: string;
15
11
  }
16
12
 
package/Table/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
2
  import React from 'react';
3
3
  import { tools } from '@cqsjjb/jjb-common-lib';
4
4
  import { ProTable } from '@ant-design/pro-components';
@@ -1,16 +1,21 @@
1
- // @ts-ignore
2
- import * as React from 'react';
3
- import { ComponentProps } from '../types';
1
+ import { ReactNode } from 'react';
2
+ import { DropdownProps } from 'antd';
4
3
 
5
- interface TableActionProps extends ComponentProps {
6
- // 每行最多显示多少个操作项,默认3
4
+ export interface TableActionProps {
5
+ // 图标 默认-MoreOutlined
6
+ icon?: React.ComponentType;
7
+ // 最大显示数量,超出的会放入下拉菜单 默认-3
7
8
  maximum?: number;
8
- // 每个操作项之间的间距,默认8
9
- space?: number;
9
+ // 子元素,可以是单个 ReactNode 或数组
10
+ children: ReactNode | ReactNode[];
11
+ // Space 间距 默认-8
12
+ space?: number | string;
13
+ // 下拉菜单位置,默认 bottomRight
14
+ placement?: DropdownProps['placement'];
15
+ // 下拉触发方式,默认 ['hover']
16
+ trigger?: DropdownProps['trigger'];
10
17
  }
11
18
 
12
- interface TableActionFc extends React.FC<TableActionProps> {
13
- }
19
+ declare const TableAction: React.FC<TableActionProps>;
14
20
 
15
- declare const TableAction: TableActionFc;
16
21
  export default TableAction;
@@ -2,21 +2,29 @@ import React from 'react';
2
2
  import { tools } from '@cqsjjb/jjb-common-lib';
3
3
  import { MoreOutlined } from '@ant-design/icons';
4
4
  import { Dropdown, Space } from 'antd';
5
- export default function TableAction(props) {
6
- const maximum = props.maximum || 3;
7
- const children = (tools.isArray(props.children) ? props.children : [].concat(props.children)).filter(i => i);
8
- const showArray = children.slice(0, maximum);
9
- const hideArray = children.slice(maximum);
5
+ export default function TableAction({
6
+ maximum = 3,
7
+ children,
8
+ space,
9
+ icon: Icon = MoreOutlined,
10
+ placement = 'bottomRight',
11
+ // 下拉菜单位置,默认 bottomRight
12
+ trigger = ['hover'] // 下拉触发方式,默认 hover
13
+ }) {
14
+ // 将 children 统一成数组并过滤空值
15
+ const childArray = (tools.isArray(children) ? children : [].concat(children)).filter(Boolean);
16
+ const showArray = childArray.slice(0, maximum);
17
+ const hideArray = childArray.slice(maximum);
10
18
  return /*#__PURE__*/React.createElement(Space, {
11
- size: props.space
12
- }, showArray, hideArray.length !== 0 && /*#__PURE__*/React.createElement(Dropdown, {
19
+ size: space
20
+ }, showArray, hideArray.length > 0 && /*#__PURE__*/React.createElement(Dropdown, {
13
21
  menu: {
14
- items: hideArray.map((record, index) => {
15
- return {
16
- key: index,
17
- label: record
18
- };
19
- })
20
- }
21
- }, /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(MoreOutlined, null))));
22
+ items: hideArray.map((child, index) => ({
23
+ key: index,
24
+ label: child
25
+ }))
26
+ },
27
+ placement: placement,
28
+ trigger: trigger
29
+ }, /*#__PURE__*/React.createElement("a", null, /*#__PURE__*/React.createElement(Icon, null))));
22
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqsjjb/jjb-react-admin-component",
3
- "version": "3.1.3",
3
+ "version": "3.2.0-beta.0",
4
4
  "description": "jjb-react-admin-组件库@new",
5
5
  "main": "index.js",
6
6
  "author": "jjb-front-team",
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "axios": "^1.6.5",
13
13
  "spark-md5": "^3.0.2",
14
- "classnames": "^2.5.1",
15
- "antd-img-crop": "latest",
14
+ "cropperjs": "latest",
15
+ "@wangeditor/editor": "latest",
16
16
  "@cqsjjb-formily/renderer": "latest",
17
17
  "@ant-design/pro-layout": "latest",
18
18
  "use-antd-resizable-header": "latest",
@@ -0,0 +1,10 @@
1
+ export function isVersion1(v: string): boolean;
2
+ export function isVersion2(v: string): boolean;
3
+ export function getToken(): string;
4
+ export function getAppKey(): string;
5
+ export function getTenantCode(): string;
6
+ export function getViewAsp(wh: string): number;
7
+ export function isHttpUrl(v: string): boolean;
8
+ export function getPrefixCls(): string;
9
+ export function getAlgorithm(): string;
10
+ export function getAlgorithm(): string;
package/tools/index.js ADDED
@@ -0,0 +1,87 @@
1
+ import { tools } from '@cqsjjb/jjb-common-lib';
2
+
3
+ const { toObject } = tools;
4
+
5
+ /**
6
+ * @description 版本1
7
+ * @param v {string}
8
+ * @return {boolean}
9
+ */
10
+ export function isVersion1(v) {
11
+ return v === 'v1';
12
+ }
13
+
14
+ /**
15
+ * @description 版本2
16
+ * @param v {string}
17
+ * @return {boolean}
18
+ */
19
+ export function isVersion2(v) {
20
+ return v === 'v2';
21
+ }
22
+
23
+ /**
24
+ * @description 读取token
25
+ * @return {string}
26
+ */
27
+ export function getToken() {
28
+ return window.sessionStorage.getItem('token');
29
+ }
30
+
31
+ /**
32
+ * @description 读取appKey
33
+ * @return {string}
34
+ */
35
+ export function getAppKey() {
36
+ return toObject(toObject(toObject(window.process).env).app).appKey;
37
+ }
38
+
39
+ /**
40
+ * @description 读取tenantCode
41
+ * @return {string}
42
+ */
43
+ export function getTenantCode() {
44
+ return window.sessionStorage.getItem('tenantCode');
45
+ }
46
+
47
+ /**
48
+ * @description 获取纵横比
49
+ * @param wh {string}
50
+ * @return {number[]}
51
+ */
52
+ export function getViewAsp(wh) {
53
+ try {
54
+ return wh.split('*').map(v => parseInt(v));
55
+ } catch (e) {
56
+ return [0, 0];
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @description http
62
+ * @param v {string}
63
+ * @return {boolean}
64
+ */
65
+ export function isHttpUrl(v) {
66
+ return /^http[s]?:\/\//.test(v);
67
+ }
68
+
69
+ /**
70
+ * @description 获取前缀
71
+ * @return {string}
72
+ */
73
+ export function getPrefixCls() {
74
+ return window.process?.env?.app?.antd['ant-prefix'] || 'ant';
75
+ }
76
+ export function getAlgorithm() {
77
+ const value = document.documentElement.style.getPropertyValue(
78
+ '--gbs-var-algorithm'
79
+ );
80
+ return (
81
+ value ?
82
+ value === '#FFF' ?
83
+ 'default'
84
+ : 'dark'
85
+ : 'default'
86
+ );
87
+ }
File without changes
package/Upload/index.d.ts DELETED
@@ -1,76 +0,0 @@
1
- // @ts-ignore
2
- import * as React from 'react';
3
- import { ComponentProps } from '../types';
4
-
5
- interface UploadProps extends ComponentProps {
6
- /**
7
- * @description 上传提交字段名,默认file
8
- */
9
- name?: string;
10
- /**
11
- * @description 上传文件大小限制,默认Infinity
12
- */
13
- size?: number;
14
- /**
15
- * @description 是否开启图片裁剪,需和listType配合使用,text模式下无效
16
- */
17
- crop?: boolean;
18
- /**
19
- * @description 上传接口地址
20
- */
21
- action?: string;
22
- /**
23
- * @description 上传资源类型,参考HTML.Input,默认*
24
- */
25
- accept?: string;
26
- /**
27
- * @description 最大上传数,参考antd官方文档,默认1
28
- */
29
- maxCount?: number;
30
- /**
31
- * @description 展示效果,参考antd官方文档,默认text
32
- */
33
- listType?: 'text' | 'picture' | 'picture-card' | 'picture-circle';
34
- /**
35
- * @description 开启后支持多选文件,默认false,注意:当maxCount为1时或开启crop时无效
36
- */
37
- multiple?: boolean;
38
- /**
39
- * @description 上传类型,默认Post
40
- */
41
- method?: 'POST' | 'PUT' | 'PATCH' | 'GET' | 'DELETE' | 'OPTIONS';
42
- /**
43
- * @description 开启后将计算文件签名,默认false,注意:开启了多图上传时建议不开启,可能会导致内存占用过大
44
- */
45
- signature?: boolean;
46
- /**
47
- * @description 开启后将强制类型验证,默认false
48
- */
49
- forceAccept?: boolean;
50
- /**
51
- * @description 上传是否携带浏览器cookie,默认false
52
- */
53
- withCredentials?: boolean;
54
- /**
55
- * @description 上传携带的其他字段属性,默认{}
56
- */
57
- data?: object,
58
- /**
59
- * @description 上传携带的请求头字段属性,默认{}
60
- */
61
- headers?: object;
62
- /**
63
- * @description 是否开启拖拽上传,默认false
64
- */
65
- drag?: boolean;
66
- /**
67
- * @description 应用appKey
68
- */
69
- appKey?: string;
70
- }
71
-
72
- interface UploadFc extends React.FC<UploadProps> {
73
- }
74
-
75
- declare const Upload: UploadFc;
76
- export default Upload;