@ccs-ui/rc-pro 1.1.25-beta-22 → 1.1.25-beta-24

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,7 +1,7 @@
1
1
  import { FormProps } from 'antd';
2
2
  import { DialogFormRef } from './form';
3
3
  import { CcsDialogModalProps } from './hook';
4
- declare const DialogRequestButton: ({ auth, formRef, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "onCancel" | "auth" | "request" | "onRequestBefore"> & {
4
+ declare const DialogRequestButton: ({ auth, formRef, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "request" | "onRequestBefore" | "onCancel"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { FormProps } from 'antd';
2
2
  import { DialogFormRef } from './form';
3
3
  import { CcsDialogModalProps } from './hook';
4
- declare const DialogSelfOkButton: ({ auth, formRef, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "onCancel" | "auth" | "onOk"> & {
4
+ declare const DialogSelfOkButton: ({ auth, formRef, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "auth" | "onOk" | "onCancel"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -15,11 +15,10 @@ import { MoreOutlined } from '@ant-design/icons';
15
15
  import { useUpdate, useUpdateEffect } from 'ahooks';
16
16
  import { Button, Dropdown, Empty, Tabs, theme } from 'antd';
17
17
  import classnames from 'classnames';
18
- import _debounce from 'lodash/debounce';
19
- import { useEffect, useMemo, useRef } from 'react';
18
+ import { useMemo, useRef } from 'react';
20
19
  import { useLocation } from 'react-router';
21
20
  import { useOutlet } from 'react-router-dom';
22
- import { CcsResizeObserver, CcsUtils } from '..';
21
+ import { CcsUtils } from '..';
23
22
  import "./index.less";
24
23
  import Page from "./page";
25
24
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -208,21 +207,9 @@ export default function KeepAliveTabs(_ref) {
208
207
  type: "text"
209
208
  })
210
209
  });
211
- var tabRef = useRef();
212
- var resizeFn = _debounce(function (width) {
213
- if (tabRef.current) tabRef.current.style.maxWidth = "".concat(width, "px");
214
- }, 200);
215
- useEffect(function () {
216
- tabRef.current = document.getElementById('keep-alive-tabs');
217
- });
218
- var onResize = function onResize(size) {
219
- resizeFn(size.width);
220
- };
221
210
  return /*#__PURE__*/_jsxs("div", {
222
211
  className: classnames(className, "ccs-keep-alive"),
223
- children: [/*#__PURE__*/_jsx(CcsResizeObserver, {
224
- onResize: onResize
225
- }), /*#__PURE__*/_jsx(Tabs, {
212
+ children: [/*#__PURE__*/_jsx(Tabs, {
226
213
  id: "keep-alive-tabs",
227
214
  hideAdd: true,
228
215
  size: "small",
@@ -1,8 +1,8 @@
1
1
  .ccs-keep-alive {
2
2
  flex: 1 1 auto;
3
- // background: #f0f2f5;
4
3
  display: flex;
5
4
  flex-direction: column;
5
+ overflow: hidden;
6
6
 
7
7
  &-tabs-colorful {
8
8
  & > .ant-tabs-nav {
@@ -1,12 +1,7 @@
1
- /// <reference types="react" />
2
1
  import { TableFormItem } from '../ccs';
3
- import { FormItemRef } from './head';
4
2
  import { CcsProTableProps } from './table';
5
3
  type PropsType = TableFormItem & {
6
- index: number;
7
4
  dependParam?: any;
8
- onSetShowNum: () => void;
9
- formItemsRef: React.MutableRefObject<FormItemRef>;
10
5
  } & Pick<CcsProTableProps<any>, 'formItemLabelWidth'>;
11
- export default function HeadFormItem({ label, name, rules, value, index, dependParam, formItemsRef, formItemLabelWidth, onSetShowNum, }: PropsType): import("react/jsx-runtime").JSX.Element;
6
+ export default function HeadFormItem({ label, name, rules, value, dependParam, formItemLabelWidth, }: PropsType): import("react/jsx-runtime").JSX.Element;
12
7
  export {};
@@ -1,72 +1,27 @@
1
1
  import { Form } from 'antd';
2
- import { cloneElement, useEffect, useRef } from 'react';
3
- import { CcsResizeObserver } from '..';
2
+ import { cloneElement } from 'react';
4
3
  import { classPrefix } from "./table";
5
4
  import { jsx as _jsx } from "react/jsx-runtime";
6
5
  import { Fragment as _Fragment } from "react/jsx-runtime";
7
- import { jsxs as _jsxs } from "react/jsx-runtime";
8
6
  export default function HeadFormItem(_ref) {
9
7
  var label = _ref.label,
10
8
  name = _ref.name,
11
9
  rules = _ref.rules,
12
10
  value = _ref.value,
13
- index = _ref.index,
14
11
  dependParam = _ref.dependParam,
15
- formItemsRef = _ref.formItemsRef,
16
- formItemLabelWidth = _ref.formItemLabelWidth,
17
- onSetShowNum = _ref.onSetShowNum;
18
- var ref = useRef(null);
19
- var historyRef = useRef();
20
- var onSaveRef = function onSaveRef() {
21
- var _ref$current;
22
- var hasIndex = formItemsRef.current.findIndex(function (f) {
23
- return f.index === index;
24
- });
25
- var item = {
26
- index: index,
27
- width: ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) || 0,
28
- ref: ref.current
29
- };
30
- if (hasIndex === -1) {
31
- formItemsRef.current.push(item);
32
- return;
33
- }
34
- formItemsRef.current[index] = item;
35
- historyRef.current = item;
36
- };
37
- useEffect(function () {
38
- onSaveRef();
39
- }, []);
40
-
41
- // 尺寸大小改变监听
42
- var onResize = function onResize(size) {
43
- var _index;
44
- if ((size === null || size === void 0 ? void 0 : size.width) !== ((_index = formItemsRef.current[index]) === null || _index === void 0 ? void 0 : _index.width)) {
45
- onSaveRef();
46
- onSetShowNum();
47
- }
48
- };
49
- return /*#__PURE__*/_jsxs(_Fragment, {
50
- children: [/*#__PURE__*/_jsx(CcsResizeObserver.Target, {
51
- targetRef: ref,
52
- onResize: onResize
53
- }), /*#__PURE__*/_jsx("div", {
54
- ref: ref,
55
- style: {
56
- paddingRight: 10
57
- },
58
- children: /*#__PURE__*/_jsx(Form.Item, {
59
- name: name,
60
- rules: rules,
61
- className: "".concat(classPrefix, "-form-label"),
62
- label: formItemLabelWidth ? /*#__PURE__*/_jsx("div", {
63
- style: {
64
- width: formItemLabelWidth
65
- },
66
- children: label
67
- }) : label,
68
- children: dependParam ? /*#__PURE__*/cloneElement(value, dependParam) : value
69
- })
70
- })]
12
+ formItemLabelWidth = _ref.formItemLabelWidth;
13
+ return /*#__PURE__*/_jsx(_Fragment, {
14
+ children: /*#__PURE__*/_jsx(Form.Item, {
15
+ name: name,
16
+ rules: rules,
17
+ className: "".concat(classPrefix, "-form-label"),
18
+ label: formItemLabelWidth ? /*#__PURE__*/_jsx("div", {
19
+ style: {
20
+ width: formItemLabelWidth
21
+ },
22
+ children: label
23
+ }) : label,
24
+ children: dependParam ? /*#__PURE__*/cloneElement(value, dependParam) : value
25
+ })
71
26
  });
72
27
  }
@@ -12,11 +12,6 @@ type PropsType<T> = Pick<CcsProTableProps<T>, 'toolbar' | 'formItems' | 'formIni
12
12
  tableOperation: ReactElement;
13
13
  onSearch: () => void;
14
14
  };
15
- export type FormItemRef = {
16
- index: number;
17
- ref: HTMLDivElement;
18
- width: number;
19
- }[];
20
15
  /** 操作按钮、查询,重置、列筛选、 */
21
16
  declare function HeadComponent<T>({ form, title, toolbar, children, expandForm, titleBordered, formItems, formInitValues, formItemLabelWidth, tableOperation, onSearch, }: PropsType<T>): import("react/jsx-runtime").JSX.Element;
22
17
  export default HeadComponent;
@@ -14,27 +14,16 @@ import { DownOutlined, UpOutlined } from '@ant-design/icons';
14
14
  import { useUpdateEffect } from 'ahooks';
15
15
  import { Button, Card, Form } from 'antd';
16
16
  import _debounce from 'lodash/debounce';
17
- import React, { useEffect, useMemo, useRef, useState } from 'react';
17
+ import React, { useMemo, useRef, useState } from 'react';
18
18
  import { CcsResizeObserver } from '..';
19
19
  import { getShowDpends } from "./_utils";
20
20
  import HeadFormItem from "./form-item";
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
23
23
  import { Fragment as _Fragment } from "react/jsx-runtime";
24
- function onShowMaxItem(nums, maxWidth) {
25
- var newNums = 0;
26
- for (var i = 0; i < nums.length; i++) {
27
- if (newNums + nums[i] > maxWidth) {
28
- return i - 1;
29
- } else {
30
- newNums += nums[i];
31
- }
32
- }
33
- return nums.length - 1;
34
- }
35
-
36
24
  /** 操作按钮、查询,重置、列筛选、 */
37
25
  function HeadComponent(_ref) {
26
+ var _formItemsRef$current;
38
27
  var form = _ref.form,
39
28
  title = _ref.title,
40
29
  toolbar = _ref.toolbar,
@@ -48,40 +37,20 @@ function HeadComponent(_ref) {
48
37
  formItemLabelWidth = _ref.formItemLabelWidth,
49
38
  tableOperation = _ref.tableOperation,
50
39
  onSearch = _ref.onSearch;
51
- var cardRef = useRef(null);
52
- var formItemsRef = useRef([]);
40
+ var searchBtnRef = useRef(null);
41
+ var formItemsRef = useRef(null);
53
42
  // 查询条件是否展开
54
43
  var _useState = useState(expandForm),
55
44
  _useState2 = _slicedToArray(_useState, 2),
56
45
  isExpand = _useState2[0],
57
46
  setIsExpand = _useState2[1];
58
- // 显示查询条件数量
59
- var _useState3 = useState(-1),
47
+ var _useState3 = useState({}),
60
48
  _useState4 = _slicedToArray(_useState3, 2),
61
- showNum = _useState4[0],
62
- setShowNum = _useState4[1];
49
+ update = _useState4[1];
63
50
  useUpdateEffect(function () {
64
51
  setIsExpand(expandForm);
65
52
  }, [expandForm]);
66
53
 
67
- // 设置最大显示条件数量
68
- var onSetShowNum = function onSetShowNum() {
69
- if (!cardRef.current) return;
70
-
71
- // 单行查询条件可占空间
72
- var maxWidth = cardRef.current.clientWidth - 32 - 64 * 2;
73
- if (maxWidth < 0) return;
74
-
75
- // 单行可显示的查询条件
76
- var maxItems = onShowMaxItem(formItemsRef.current.map(function (f) {
77
- return f.width;
78
- }), maxWidth);
79
- setShowNum(maxItems);
80
- };
81
- useEffect(function () {
82
- onSetShowNum();
83
- }, [isExpand]);
84
-
85
54
  // 处理form item 依赖
86
55
  var allFormItems = useMemo(function () {
87
56
  formItems.forEach(function (item) {
@@ -96,13 +65,14 @@ function HeadComponent(_ref) {
96
65
  // 查询条件记录数
97
66
  var itemLen = allFormItems.length;
98
67
  var hasItem = itemLen > 0;
99
- var hasMore = showNum > -1 && showNum < itemLen - 1;
68
+ var hasMore = (((_formItemsRef$current = formItemsRef.current) === null || _formItemsRef$current === void 0 ? void 0 : _formItemsRef$current.scrollHeight) || 0) > 40;
100
69
 
101
70
  // 操作按钮
102
- var renderOperation = /*#__PURE__*/_jsxs("div", {
71
+ var renderSearchBtn = /*#__PURE__*/_jsxs("div", {
72
+ ref: searchBtnRef,
103
73
  style: {
104
74
  textAlign: 'right',
105
- flex: isExpand ? '1 1 auto' : '0 0 auto'
75
+ flex: isExpand && hasMore ? '1 1 auto' : '0 0 auto'
106
76
  },
107
77
  children: [hasMore && /*#__PURE__*/_jsx(Button, {
108
78
  type: "link",
@@ -118,13 +88,13 @@ function HeadComponent(_ref) {
118
88
  type: "primary",
119
89
  htmlType: "submit",
120
90
  children: "\u67E5\u8BE2"
121
- })]
91
+ }), toolbar ? null : tableOperation]
122
92
  });
123
93
  var renderFormItems = function renderFormItems() {
124
- return allFormItems.map(function (item, index) {
94
+ return allFormItems.map(function (item) {
125
95
  if (item.depends || item.showDepends) {
126
- return /*#__PURE__*/_jsxs(React.Fragment, {
127
- children: [/*#__PURE__*/_jsx(Form.Item, {
96
+ return /*#__PURE__*/_jsx(React.Fragment, {
97
+ children: /*#__PURE__*/_jsx(Form.Item, {
128
98
  noStyle: true,
129
99
  shouldUpdate: function shouldUpdate(l, n) {
130
100
  var _item$depends, _item$showDepends;
@@ -150,41 +120,35 @@ function HeadComponent(_ref) {
150
120
  });
151
121
  }
152
122
  var itemContent = /*#__PURE__*/_jsx(HeadFormItem, {
153
- index: index,
154
123
  name: item.name,
155
124
  label: item.label,
156
125
  rules: item.rules,
157
126
  value: item.value,
158
127
  dependParam: dependParam,
159
- onSetShowNum: onSetShowNum,
160
- formItemsRef: formItemsRef,
161
128
  formItemLabelWidth: formItemLabelWidth
162
129
  });
163
130
  if (!isShow) return null;
164
131
  return itemContent;
165
132
  }
166
- }), showNum === index && !isExpand && renderOperation]
133
+ })
167
134
  }, item.name);
168
135
  }
169
136
  var itemContent = /*#__PURE__*/_jsx(HeadFormItem, {
170
- index: index,
171
137
  name: item.name,
172
138
  value: item.value,
173
139
  rules: item.rules,
174
140
  label: item.label,
175
- onSetShowNum: onSetShowNum,
176
- formItemsRef: formItemsRef,
177
141
  formItemLabelWidth: formItemLabelWidth
178
142
  });
179
- return /*#__PURE__*/_jsxs(React.Fragment, {
180
- children: [itemContent, showNum === index && !isExpand && renderOperation]
143
+ return /*#__PURE__*/_jsx(React.Fragment, {
144
+ children: itemContent
181
145
  }, item.name);
182
146
  });
183
147
  };
184
148
 
185
149
  // 尺寸变化重设尺寸
186
150
  var resizeFn = _debounce(function () {
187
- onSetShowNum();
151
+ update({});
188
152
  }, 500);
189
153
 
190
154
  // 监听dom尺寸变化
@@ -195,16 +159,12 @@ function HeadComponent(_ref) {
195
159
  // table是否有边框
196
160
  var hasBorder = titleBordered === true;
197
161
  var formStyles = {
198
- gap: '16px 0'
162
+ flexWrap: isExpand ? 'wrap' : 'nowrap'
199
163
  };
200
- // 单行条件右对齐
201
- if (!isExpand && (hasMore || formItemsRef.current.length - 1 === showNum)) {
202
- formStyles.justifyContent = 'flex-end';
203
- }
204
164
  return /*#__PURE__*/_jsxs(_Fragment, {
205
165
  children: [hasItem && /*#__PURE__*/_jsxs(_Fragment, {
206
166
  children: [/*#__PURE__*/_jsx(CcsResizeObserver.Target, {
207
- targetRef: cardRef,
167
+ targetRef: formItemsRef,
208
168
  onResize: onResize
209
169
  }), /*#__PURE__*/_jsx(Card, {
210
170
  className: "ccs-pl-adaptation",
@@ -216,23 +176,35 @@ function HeadComponent(_ref) {
216
176
  } : {}),
217
177
  styles: {
218
178
  body: {
219
- padding: 16,
220
- height: hasMore && !isExpand ? 64 : 'auto'
179
+ padding: 16
221
180
  }
222
181
  },
223
182
  bordered: hasBorder,
224
183
  title: title,
225
- ref: cardRef,
226
184
  children: /*#__PURE__*/_jsxs(Form, {
227
185
  initialValues: formInitValues,
228
186
  form: form,
229
187
  onFinish: onSearch,
230
188
  layout: "inline",
231
189
  style: formStyles,
232
- children: [renderFormItems(), isExpand && renderOperation]
190
+ children: [/*#__PURE__*/_jsxs("div", {
191
+ style: {
192
+ justifyContent: isExpand && hasMore ? 'flex-start' : 'flex-end',
193
+ height: isExpand ? 'auto' : 32
194
+ },
195
+ className: "ccs-pl-adaptation-form",
196
+ ref: formItemsRef,
197
+ children: [renderFormItems(), isExpand && renderSearchBtn]
198
+ }), !isExpand && /*#__PURE__*/_jsx("div", {
199
+ style: {
200
+ flex: '0 0 auto',
201
+ paddingLeft: 10
202
+ },
203
+ children: renderSearchBtn
204
+ })]
233
205
  })
234
206
  })]
235
- }), /*#__PURE__*/_jsxs(Card, {
207
+ }), toolbar && /*#__PURE__*/_jsxs(Card, {
236
208
  styles: {
237
209
  cover: {
238
210
  borderRadius: 0
@@ -52,6 +52,18 @@
52
52
  }
53
53
  }
54
54
 
55
+ &-adaptation-form {
56
+ flex: 1 1 auto;
57
+ display: flex;
58
+ flex-wrap: wrap;
59
+ gap: 16px 10px;
60
+ overflow: auto;
61
+
62
+ &::-webkit-scrollbar {
63
+ display: none;
64
+ }
65
+ }
66
+
55
67
  .ant-form-item {
56
68
  margin-bottom: 0;
57
69
  }
@@ -137,7 +137,8 @@ export default function TableOperation(_ref) {
137
137
  }),
138
138
  type: "text",
139
139
  style: {
140
- width: 24
140
+ width: 24,
141
+ marginLeft: 4
141
142
  }
142
143
  })
143
144
  }), filterColumns && /*#__PURE__*/_jsx(Popover, {
@@ -28,7 +28,7 @@ type TableTitleType<T> = {
28
28
  export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
29
29
  data?: CCS.TableData<T>;
30
30
  /** request 方法 */
31
- request?: (params: any) => void;
31
+ request?: (params: any) => Promise<HttpPageResult<T>>;
32
32
  /** request 额外参数 */
33
33
  requestParam?: ParamType;
34
34
  /** class name */
@@ -41,7 +41,7 @@ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
41
41
  title?: ({ selectedRows, data, onClear }: TableTitleType<T>) => ReactNode;
42
42
  };
43
43
  type FormLayout = 'horizontal' | 'inline' | 'vertical' | 'adaptation';
44
- export type CcsProTableProps<T> = {
44
+ export type CcsProTableProps<RecordType> = {
45
45
  /** api权限标识 */
46
46
  auth?: string | 'ignore';
47
47
  /** 是否初始查询,默认true */
@@ -65,7 +65,7 @@ export type CcsProTableProps<T> = {
65
65
  /** 展开查询条件,默认false */
66
66
  expandForm?: boolean;
67
67
  /** table 数据区域 */
68
- table?: CcsTableProps<T>;
68
+ table?: CcsTableProps<RecordType>;
69
69
  /** table style */
70
70
  tableStyle?: CSSProperties;
71
71
  /** 父级值字段 */
@@ -73,7 +73,7 @@ export type CcsProTableProps<T> = {
73
73
  /** 水印文字 */
74
74
  watermark?: string;
75
75
  /** ref 回调方法 */
76
- proRef?: CCS.TableInstanceRef<T>;
76
+ proRef?: CCS.TableInstanceRef<RecordType>;
77
77
  /** 显示序号 */
78
78
  showNumber?: boolean;
79
79
  /** class */
@@ -87,7 +87,7 @@ export type CcsProTableProps<T> = {
87
87
  /** 请求前格式化参数 */
88
88
  onSearchBefore?: (params: SearchBeforeType, eventType?: SearchEventType) => SearchBeforeType;
89
89
  /** 请求后格式化结果 */
90
- onSearchAfter?: (data: HttpPageResult<T>, eventType?: SearchEventType) => any;
90
+ onSearchAfter?: (data: HttpPageResult<RecordType>, eventType?: SearchEventType) => any;
91
91
  };
92
92
  export type TableEventType = {
93
93
  key: 'columnFilter' | 'fullScreen';
@@ -107,5 +107,5 @@ export declare const TableSelectionContext: React.Context<{
107
107
  * @param ref
108
108
  * @returns
109
109
  */
110
- declare const InternalProTable: <T extends object = any>(props: CcsProTableProps<T>) => import("react/jsx-runtime").JSX.Element;
110
+ declare const InternalProTable: <RecordType extends object = any>(props: CcsProTableProps<RecordType>) => import("react/jsx-runtime").JSX.Element;
111
111
  export default InternalProTable;
@@ -494,7 +494,7 @@ var InternalProTable = function InternalProTable(props) {
494
494
  } : undefined
495
495
  }));
496
496
  };
497
- var newToolbar = /*#__PURE__*/_jsx(TableSelectionContext.Provider, {
497
+ var newToolbar = toolbar && /*#__PURE__*/_jsx(TableSelectionContext.Provider, {
498
498
  value: {
499
499
  selectedRows: selectedRows
500
500
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "1.1.25-beta-22",
3
+ "version": "1.1.25-beta-24",
4
4
  "description": "验证码组件兼容暗黑模式;proTable封装rowselection代码;proTable添加自适应布局模式;",
5
5
  "license": "MIT",
6
6
  "author": {