@ccs-ui/rc-pro 1.1.25-beta-9 → 1.1.25-beta-11

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/es/ccs.d.ts CHANGED
@@ -175,14 +175,14 @@ type ShowDependType = {
175
175
  name: string;
176
176
  value: any;
177
177
  };
178
- type TableFormItem = {
178
+ export type TableFormItem = {
179
179
  /** label 标题 */
180
180
  label?: string;
181
181
  /** form name */
182
182
  name: string;
183
183
  /** form item element */
184
184
  value: ReactElement;
185
- /** 主条件 */
185
+ /** @deprecated 主条件 */
186
186
  isMain?: boolean;
187
187
  /** 数据依赖、依赖项对应的name数组 */
188
188
  depends?: string[];
@@ -25,13 +25,13 @@ var DragModal = function DragModal(_ref) {
25
25
  var modal = _ref.modal,
26
26
  dragState = _ref.dragState,
27
27
  onDragState = _ref.onDragState;
28
- var draggleRef = useRef(null);
29
- var _onStart = function onStart(event, uiData) {
30
- var _draggleRef$current;
28
+ var nodeRef = useRef(null);
29
+ var onStart = function onStart(event, uiData) {
30
+ var _nodeRef$current;
31
31
  var _window$document$docu = window.document.documentElement,
32
32
  clientWidth = _window$document$docu.clientWidth,
33
33
  clientHeight = _window$document$docu.clientHeight;
34
- var targetRect = (_draggleRef$current = draggleRef.current) === null || _draggleRef$current === void 0 ? void 0 : _draggleRef$current.getBoundingClientRect();
34
+ var targetRect = (_nodeRef$current = nodeRef.current) === null || _nodeRef$current === void 0 ? void 0 : _nodeRef$current.getBoundingClientRect();
35
35
  if (!targetRect) {
36
36
  return;
37
37
  }
@@ -47,13 +47,12 @@ var DragModal = function DragModal(_ref) {
47
47
  });
48
48
  };
49
49
  return /*#__PURE__*/_jsx(Draggable, {
50
+ nodeRef: nodeRef,
50
51
  disabled: dragState.disabled,
51
52
  bounds: dragState.bounds,
52
- onStart: function onStart(event, uiData) {
53
- return _onStart(event, uiData);
54
- },
53
+ onStart: onStart,
55
54
  children: /*#__PURE__*/_jsx("div", {
56
- ref: draggleRef,
55
+ ref: nodeRef,
57
56
  children: modal
58
57
  })
59
58
  });
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ import { TableFormItem } from '../ccs';
3
+ import { FormItemRef } from './head';
4
+ import { CcsProTableProps } from './table';
5
+ type PropsType = TableFormItem & {
6
+ index: number;
7
+ dependParam?: any;
8
+ onSetShowNum: () => void;
9
+ formItemsRef: React.MutableRefObject<FormItemRef>;
10
+ } & 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;
12
+ export {};
@@ -0,0 +1,65 @@
1
+ import { Form } from 'antd';
2
+ import ResizeObserver from 'rc-resize-observer';
3
+ import { cloneElement, useEffect, useRef } from 'react';
4
+ import { classPrefix } from "./table";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ export default function HeadFormItem(_ref) {
7
+ var label = _ref.label,
8
+ name = _ref.name,
9
+ rules = _ref.rules,
10
+ value = _ref.value,
11
+ index = _ref.index,
12
+ dependParam = _ref.dependParam,
13
+ formItemsRef = _ref.formItemsRef,
14
+ formItemLabelWidth = _ref.formItemLabelWidth,
15
+ onSetShowNum = _ref.onSetShowNum;
16
+ var ref = useRef(null);
17
+ var historyRef = useRef();
18
+ var onSaveRef = function onSaveRef() {
19
+ var _ref$current;
20
+ var hasIndex = formItemsRef.current.findIndex(function (f) {
21
+ return f.index === index;
22
+ });
23
+ var item = {
24
+ index: index,
25
+ width: ((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth) || 0,
26
+ ref: ref.current
27
+ };
28
+ if (hasIndex === -1) {
29
+ formItemsRef.current.push(item);
30
+ return;
31
+ }
32
+ formItemsRef.current[index] = item;
33
+ historyRef.current = item;
34
+ };
35
+ useEffect(function () {
36
+ onSaveRef();
37
+ }, []);
38
+
39
+ // 尺寸大小改变监听
40
+ var onResize = function onResize(size) {
41
+ var _index;
42
+ if ((size === null || size === void 0 ? void 0 : size.width) !== ((_index = formItemsRef.current[index]) === null || _index === void 0 ? void 0 : _index.width)) {
43
+ onSaveRef();
44
+ onSetShowNum();
45
+ }
46
+ };
47
+ return /*#__PURE__*/_jsx(ResizeObserver, {
48
+ onResize: onResize,
49
+ children: /*#__PURE__*/_jsx("div", {
50
+ ref: ref,
51
+ children: /*#__PURE__*/_jsx(Form.Item, {
52
+ name: name,
53
+ rules: rules,
54
+ className: "".concat(classPrefix, "-form-label"),
55
+ label: formItemLabelWidth ? /*#__PURE__*/_jsx("div", {
56
+ style: {
57
+ width: formItemLabelWidth
58
+ },
59
+ children: label
60
+ }) : label,
61
+ children: dependParam ? /*#__PURE__*/cloneElement(value, dependParam) : value
62
+ })
63
+ })
64
+ });
65
+ }
@@ -0,0 +1,22 @@
1
+ import { FormInstance } from 'antd/lib/form';
2
+ import { ReactElement } from 'react';
3
+ import { CcsProTableProps } from './table';
4
+ type PropsType<T> = Pick<CcsProTableProps<T>, 'toolbar' | 'formItems' | 'formInitValues' | 'expandForm' | 'title' | 'formItemLabelWidth'> & {
5
+ /** 更多查询条件 */
6
+ hasMore?: boolean;
7
+ /** 标题边框 */
8
+ titleBordered?: boolean;
9
+ form: FormInstance<any>;
10
+ children?: ReactElement;
11
+ /** table 操作栏 */
12
+ tableOperation: ReactElement;
13
+ onSearch: () => void;
14
+ };
15
+ export type FormItemRef = {
16
+ index: number;
17
+ ref: HTMLDivElement;
18
+ width: number;
19
+ }[];
20
+ /** 操作按钮、查询,重置、列筛选、 */
21
+ declare function HeadComponent<T>({ form, title, toolbar, children, expandForm, titleBordered, formItems, formInitValues, formItemLabelWidth, tableOperation, onSearch, }: PropsType<T>): import("react/jsx-runtime").JSX.Element;
22
+ export default HeadComponent;
@@ -0,0 +1,270 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import { DownOutlined, UpOutlined } from '@ant-design/icons';
14
+ import { useUpdateEffect } from 'ahooks';
15
+ import { Button, Card, Form } from 'antd';
16
+ import _debounce from 'lodash/debounce';
17
+ import ResizeObserver from 'rc-resize-observer';
18
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
19
+ import { getShowDpends } from "./_utils";
20
+ import HeadFormItem from "./form-item";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
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
+ /** 操作按钮、查询,重置、列筛选、 */
37
+ function HeadComponent(_ref) {
38
+ var form = _ref.form,
39
+ title = _ref.title,
40
+ toolbar = _ref.toolbar,
41
+ children = _ref.children,
42
+ _ref$expandForm = _ref.expandForm,
43
+ expandForm = _ref$expandForm === void 0 ? false : _ref$expandForm,
44
+ titleBordered = _ref.titleBordered,
45
+ _ref$formItems = _ref.formItems,
46
+ formItems = _ref$formItems === void 0 ? [] : _ref$formItems,
47
+ formInitValues = _ref.formInitValues,
48
+ formItemLabelWidth = _ref.formItemLabelWidth,
49
+ tableOperation = _ref.tableOperation,
50
+ onSearch = _ref.onSearch;
51
+ var cardRef = useRef(null);
52
+ var formItemsRef = useRef([]);
53
+ // 查询条件是否展开
54
+ var _useState = useState(expandForm),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ isExpand = _useState2[0],
57
+ setIsExpand = _useState2[1];
58
+ // 显示查询条件数量
59
+ var _useState3 = useState(-1),
60
+ _useState4 = _slicedToArray(_useState3, 2),
61
+ showNum = _useState4[0],
62
+ setShowNum = _useState4[1];
63
+ useUpdateEffect(function () {
64
+ setIsExpand(expandForm);
65
+ }, [expandForm]);
66
+
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
+ // 处理form item 依赖
86
+ var allFormItems = useMemo(function () {
87
+ formItems.forEach(function (item) {
88
+ var depend = item.showDepends || [];
89
+ if (depend && depend.length > 0) {
90
+ getShowDpends(formItems, item, depend);
91
+ }
92
+ });
93
+ return formItems;
94
+ }, [formItems]);
95
+
96
+ // 查询条件记录数
97
+ var itemLen = allFormItems.length;
98
+ var hasItem = itemLen > 0;
99
+ var hasMore = showNum > -1 && showNum < itemLen - 1;
100
+
101
+ // 操作按钮
102
+ var renderOperation = /*#__PURE__*/_jsxs("div", {
103
+ style: {
104
+ textAlign: 'right',
105
+ flex: isExpand ? '1 1 auto' : '0 0 auto'
106
+ },
107
+ children: [hasMore && /*#__PURE__*/_jsx(Button, {
108
+ type: "link",
109
+ icon: isExpand ? /*#__PURE__*/_jsx(UpOutlined, {}) : /*#__PURE__*/_jsx(DownOutlined, {}),
110
+ style: {
111
+ padding: '4px 6px'
112
+ },
113
+ onClick: function onClick() {
114
+ return setIsExpand(!isExpand);
115
+ },
116
+ children: isExpand ? '收起' : '展开'
117
+ }), /*#__PURE__*/_jsx(Button, {
118
+ type: "primary",
119
+ onClick: function onClick() {
120
+ return form.submit();
121
+ },
122
+ htmlType: "submit",
123
+ children: "\u67E5\u8BE2"
124
+ })]
125
+ });
126
+ var renderFormItems = function renderFormItems() {
127
+ return allFormItems.map(function (item, index) {
128
+ if (item.depends || item.showDepends) {
129
+ return /*#__PURE__*/_jsxs(React.Fragment, {
130
+ children: [/*#__PURE__*/_jsx(Form.Item, {
131
+ noStyle: true,
132
+ shouldUpdate: function shouldUpdate(l, n) {
133
+ var _item$depends, _item$showDepends;
134
+ return ((_item$depends = item.depends) === null || _item$depends === void 0 ? void 0 : _item$depends.some(function (i) {
135
+ return l[i] !== n[i];
136
+ })) || ((_item$showDepends = item.showDepends) === null || _item$showDepends === void 0 ? void 0 : _item$showDepends.some(function (i) {
137
+ return l[i.name] !== n[i.name];
138
+ })) || false;
139
+ },
140
+ children: function children(_ref2) {
141
+ var _item$depends2;
142
+ var getFieldValue = _ref2.getFieldValue;
143
+ var dependParam = {};
144
+ (_item$depends2 = item.depends) === null || _item$depends2 === void 0 ? void 0 : _item$depends2.forEach(function (i) {
145
+ var value = getFieldValue(i);
146
+ dependParam[i] = value;
147
+ });
148
+ var isShow = true;
149
+ if (item.showDepends && item.showDepends.length > 0) {
150
+ var _item$showDepends2;
151
+ isShow = (_item$showDepends2 = item.showDepends) === null || _item$showDepends2 === void 0 ? void 0 : _item$showDepends2.every(function (i) {
152
+ return getFieldValue(i.name) === i.value;
153
+ });
154
+ }
155
+ var itemContent = /*#__PURE__*/_jsx(HeadFormItem, {
156
+ index: index,
157
+ name: item.name,
158
+ label: item.label,
159
+ rules: item.rules,
160
+ value: item.value,
161
+ dependParam: dependParam,
162
+ onSetShowNum: onSetShowNum,
163
+ formItemsRef: formItemsRef,
164
+ formItemLabelWidth: formItemLabelWidth
165
+ });
166
+ if (!isShow) return null;
167
+ return itemContent;
168
+ }
169
+ }), showNum === index && !isExpand && renderOperation]
170
+ }, item.name);
171
+ }
172
+ var itemContent = /*#__PURE__*/_jsx(HeadFormItem, {
173
+ index: index,
174
+ name: item.name,
175
+ value: item.value,
176
+ rules: item.rules,
177
+ label: item.label,
178
+ onSetShowNum: onSetShowNum,
179
+ formItemsRef: formItemsRef,
180
+ formItemLabelWidth: formItemLabelWidth
181
+ });
182
+ return /*#__PURE__*/_jsxs(React.Fragment, {
183
+ children: [itemContent, showNum === index && !isExpand && renderOperation]
184
+ }, item.name);
185
+ });
186
+ };
187
+
188
+ // 尺寸变化重设尺寸
189
+ var resizeFn = _debounce(function () {
190
+ onSetShowNum();
191
+ }, 500);
192
+
193
+ // 监听dom尺寸变化
194
+ var onResize = function onResize() {
195
+ resizeFn();
196
+ };
197
+
198
+ // table是否有边框
199
+ var hasBorder = titleBordered === true;
200
+ var formStyles = {
201
+ gap: 16
202
+ };
203
+ // 单行条件右对齐
204
+ if (!isExpand && (hasMore || formItemsRef.current.length - 1 === showNum)) {
205
+ formStyles.justifyContent = 'flex-end';
206
+ }
207
+ return /*#__PURE__*/_jsxs(_Fragment, {
208
+ children: [hasItem && /*#__PURE__*/_jsxs(_Fragment, {
209
+ children: [/*#__PURE__*/_jsx(ResizeObserver, {
210
+ onResize: onResize,
211
+ children: /*#__PURE__*/_jsx("div", {})
212
+ }), /*#__PURE__*/_jsx(Card, {
213
+ className: "ccs-pl-adaptation",
214
+ style: _objectSpread({
215
+ borderRadius: 0,
216
+ boxShadow: 'none'
217
+ }, hasBorder ? {
218
+ borderBottom: 0
219
+ } : {}),
220
+ styles: {
221
+ body: {
222
+ padding: 16,
223
+ height: isExpand ? 'auto' : 64
224
+ }
225
+ },
226
+ bordered: hasBorder,
227
+ title: title,
228
+ ref: cardRef,
229
+ children: /*#__PURE__*/_jsxs(Form, {
230
+ initialValues: formInitValues,
231
+ form: form,
232
+ onFinish: onSearch,
233
+ layout: "inline",
234
+ style: formStyles,
235
+ children: [renderFormItems(), isExpand && renderOperation]
236
+ })
237
+ })]
238
+ }), /*#__PURE__*/_jsxs(Card, {
239
+ styles: {
240
+ cover: {
241
+ borderRadius: 0
242
+ },
243
+ body: {
244
+ display: 'flex',
245
+ justifyContent: 'space-between',
246
+ width: '100%',
247
+ padding: '12px 16px',
248
+ alignContent: 'center'
249
+ }
250
+ },
251
+ style: {
252
+ borderRadius: 0,
253
+ borderLeft: 0,
254
+ borderRight: 0
255
+ },
256
+ children: [/*#__PURE__*/_jsx("div", {
257
+ style: {
258
+ flex: '1 1 auto'
259
+ },
260
+ children: toolbar
261
+ }), /*#__PURE__*/_jsx("div", {
262
+ style: {
263
+ flex: '0 0 auto'
264
+ },
265
+ children: tableOperation
266
+ })]
267
+ }), children]
268
+ });
269
+ }
270
+ export default HeadComponent;
@@ -45,6 +45,17 @@
45
45
  }
46
46
  }
47
47
 
48
+ &-adaptation {
49
+ .ant-form-item {
50
+ // margin-bottom: 0;
51
+ margin-inline-end: 0;
52
+ }
53
+ }
54
+
55
+ .ant-form-item {
56
+ margin-bottom: 0;
57
+ }
58
+
48
59
  &-form {
49
60
  flex: 0 1 auto;
50
61
  overflow: hidden;
@@ -116,11 +127,6 @@
116
127
  line-height: 0;
117
128
  }
118
129
 
119
- .ant-form-item {
120
- margin-bottom: 0;
121
- margin-inline-end: 0;
122
- }
123
-
124
130
  .ant-input-number {
125
131
  width: 100%;
126
132
  }
@@ -1,11 +1,14 @@
1
1
  /// <reference types="react" />
2
+ import { TableProps } from 'antd';
2
3
  import { TableRefType } from '../table';
3
4
  type PropsType = {
4
- /** 显示列 */ columns?: any;
5
- /** 弹框中显示 */
5
+ /** 显示列 */
6
+ columns?: any;
7
+ tableRowSize: TableProps['size'];
6
8
  isInModalOrDrawer: boolean;
7
- onReset: () => void;
8
9
  tableRef: React.MutableRefObject<TableRefType | undefined>;
10
+ onReset: () => void;
11
+ onChangeRowSize: (e: TableProps['size']) => void;
9
12
  };
10
- export default function TableOperation({ columns, tableRef, isInModalOrDrawer, onReset, }: PropsType): import("react/jsx-runtime").JSX.Element;
13
+ export default function TableOperation({ columns, tableRef, tableRowSize, isInModalOrDrawer, onReset, onChangeRowSize, }: PropsType): import("react/jsx-runtime").JSX.Element;
11
14
  export {};
@@ -8,8 +8,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
8
8
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
9
9
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
10
10
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
11
- import { RedoOutlined, SettingOutlined } from '@ant-design/icons';
12
- import { Button, Checkbox, Divider, Popover, Tooltip } from 'antd';
11
+ import { ColumnHeightOutlined, RedoOutlined, SettingOutlined } from '@ant-design/icons';
12
+ import { Button, Checkbox, Divider, Dropdown, Popover, Tooltip } from 'antd';
13
13
  import { useState } from 'react';
14
14
  import { CcsFullScreenButton } from '..';
15
15
  import { classPrefix } from "./table";
@@ -19,8 +19,10 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
19
19
  export default function TableOperation(_ref) {
20
20
  var columns = _ref.columns,
21
21
  tableRef = _ref.tableRef,
22
+ tableRowSize = _ref.tableRowSize,
22
23
  isInModalOrDrawer = _ref.isInModalOrDrawer,
23
- onReset = _ref.onReset;
24
+ onReset = _ref.onReset,
25
+ onChangeRowSize = _ref.onChangeRowSize;
24
26
  var _useState = useState(columns),
25
27
  _useState2 = _slicedToArray(_useState, 2),
26
28
  filterColumns = _useState2[0],
@@ -158,6 +160,36 @@ export default function TableOperation(_ref) {
158
160
  }
159
161
  })
160
162
  })
163
+ }), /*#__PURE__*/_jsx(Tooltip, {
164
+ title: "\u5BC6\u5EA6",
165
+ children: /*#__PURE__*/_jsx(Dropdown, {
166
+ placement: "bottomRight",
167
+ menu: {
168
+ activeKey: tableRowSize,
169
+ items: [{
170
+ key: 'large',
171
+ label: '默认'
172
+ }, {
173
+ key: 'middle',
174
+ label: '中等'
175
+ }, {
176
+ key: 'small',
177
+ label: '紧凑'
178
+ }],
179
+ onClick: function onClick(e) {
180
+ onChangeRowSize(e.key);
181
+ }
182
+ },
183
+ children: /*#__PURE__*/_jsx(Button, {
184
+ icon: /*#__PURE__*/_jsx(ColumnHeightOutlined, {
185
+ className: "".concat(classPrefix, "-icon")
186
+ }),
187
+ type: "text",
188
+ style: {
189
+ width: 24
190
+ }
191
+ })
192
+ })
161
193
  }), !isInModalOrDrawer && /*#__PURE__*/_jsx(CcsFullScreenButton, {
162
194
  onFullScreen: onFullScreen
163
195
  })]
@@ -61,12 +61,11 @@ function SearchComponent(props) {
61
61
  var _theme$useToken = theme.useToken(),
62
62
  token = _theme$useToken.token;
63
63
  var onHasMore = function onHasMore() {
64
- if (props.formItemLayout === 'tradition') return false;
65
64
  var hasMain = formItems.filter(function (f) {
66
65
  return f.isMain;
67
66
  });
68
- // 所有都是主条件
69
- if (hasMain.length === formItems.length) {
67
+ // 所有都是主条件,tradition模式不显示more
68
+ if (props.formItemLayout === 'tradition' || hasMain.length === formItems.length) {
70
69
  // 收起已展开
71
70
  if (isShowMore === true) {
72
71
  setIsShowMore(false);
@@ -40,7 +40,7 @@ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
40
40
  /** table title */
41
41
  title?: ({ selectedRows, data, onClear }: TableTitleType<T>) => ReactNode;
42
42
  };
43
- type FormLayout = 'horizontal' | 'inline' | 'vertical' | 'tradition';
43
+ type FormLayout = 'horizontal' | 'inline' | 'vertical' | 'adaptation';
44
44
  export type CcsProTableProps<T> = {
45
45
  /** api权限标识 */
46
46
  auth?: string | 'ignore';
@@ -50,9 +50,9 @@ export type CcsProTableProps<T> = {
50
50
  title?: string;
51
51
  /** 查询条件集合 */
52
52
  formItems?: CCS.TableFormItems;
53
- /** 查询条件布局模式,默认:horizontal */
53
+ /** @deprecated 查询条件布局模式,默认:horizontal */
54
54
  formItemLayout?: FormLayout;
55
- /** 查询条件栅格配置,默认:{ xs: 24, sm: 12, md: 8, lg: 8, xl: 6 } */
55
+ /** @deprecated 查询条件栅格配置,默认:{ xs: 24, sm: 12, md: 8, lg: 8, xl: 6 } */
56
56
  formItemCol?: ColProps | ColProps[];
57
57
  /** form item label 宽度 */
58
58
  formItemLabelWidth?: number | string;
@@ -13,6 +13,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
13
13
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
14
14
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ import { useUpdateEffect } from 'ahooks';
16
17
  import { Empty, Form, theme } from 'antd';
17
18
  import classNames from 'classnames';
18
19
  import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
@@ -20,12 +21,13 @@ import { CcsUtils, CcsWaterMark } from '..';
20
21
  import { useCcsPage } from "../";
21
22
  import CcsTable from "../table";
22
23
  import { getAllChildrenId, getDataById, onTableInModalOrDrawer, onTableInTabItem } from "./_utils";
24
+ import HeadComponent from "./head";
23
25
  import "./index.less";
24
26
  import TableOperation from "./operation";
25
27
  import SearchComponent from "./search";
26
28
  import TableTree from "./tree";
27
29
 
28
- // 同 antd FormLayout; tradition为传统布局模式
30
+ // 同 antd FormLayout; adaptation为自适应布局
29
31
  import { jsx as _jsx } from "react/jsx-runtime";
30
32
  import { jsxs as _jsxs } from "react/jsx-runtime";
31
33
  export var classPrefix = 'ccs-pl';
@@ -99,6 +101,10 @@ var InternalProTable = function InternalProTable(props) {
99
101
  _useState4 = _slicedToArray(_useState3, 2),
100
102
  selectedRows = _useState4[0],
101
103
  setSelectedRows = _useState4[1];
104
+ var _useState5 = useState((table === null || table === void 0 ? void 0 : table.size) || 'middle'),
105
+ _useState6 = _slicedToArray(_useState5, 2),
106
+ tableRowSize = _useState6[0],
107
+ setTableRowSize = _useState6[1];
102
108
 
103
109
  // 权限判断
104
110
  var isAuth = useMemo(function () {
@@ -266,6 +272,8 @@ var InternalProTable = function InternalProTable(props) {
266
272
  var inMd = onTableInModalOrDrawer(tableContentRef.current);
267
273
  if (inMd) {
268
274
  stickyRef.current = inMd;
275
+ // 弹框中行尺寸默认设置为small
276
+ if (!(table !== null && table !== void 0 && table.size)) setTableRowSize('small');
269
277
  return;
270
278
  }
271
279
 
@@ -283,6 +291,11 @@ var InternalProTable = function InternalProTable(props) {
283
291
  // };
284
292
  }, []);
285
293
 
294
+ // size参数变化
295
+ useUpdateEffect(function () {
296
+ setTableRowSize((table === null || table === void 0 ? void 0 : table.size) || 'middle');
297
+ }, [table === null || table === void 0 ? void 0 : table.size]);
298
+
286
299
  // 初始查询
287
300
  useEffect(function () {
288
301
  if (init !== false && request) {
@@ -455,22 +468,22 @@ var InternalProTable = function InternalProTable(props) {
455
468
  }),
456
469
  treeRef: treeRef,
457
470
  tableRef: tableRef,
471
+ tableRowSize: tableRowSize,
458
472
  sticky: stickyRef.current || true,
459
473
  parentFieldName: parentFieldName,
460
474
  setData: setData,
461
475
  onSearchAfter: onSearchAfter,
462
476
  onSearchBefore: onSearchBefore,
463
- handlePageChange: handlePageChange,
464
- isInModalOrDrawer: isInModalOrDrawer
477
+ handlePageChange: handlePageChange
465
478
  });
466
479
  }
467
480
  return /*#__PURE__*/_jsx(CcsTable, _objectSpread(_objectSpread({
468
481
  data: data,
469
482
  tableRef: tableRef,
470
483
  onChange: handlePageChange,
471
- size: isInModalOrDrawer ? 'small' : 'middle',
472
484
  sticky: stickyRef.current || true
473
485
  }, table), {}, {
486
+ size: tableRowSize,
474
487
  columns: columns,
475
488
  showSorterTooltip: true,
476
489
  rowSelection: rowSelection,
@@ -499,7 +512,7 @@ var InternalProTable = function InternalProTable(props) {
499
512
  var render = /*#__PURE__*/_jsxs("div", {
500
513
  className: classNames(classPrefix, className, _defineProperty({}, 'dark-table', isDark)),
501
514
  style: style,
502
- children: [!(!formItems.length && !toolbar) && isAuth && /*#__PURE__*/_jsx(SearchComponent, {
515
+ children: [!(!formItems.length && !toolbar) && isAuth && props.formItemLayout !== 'adaptation' ? /*#__PURE__*/_jsx(SearchComponent, {
503
516
  form: form,
504
517
  title: title,
505
518
  titleBordered: table === null || table === void 0 ? void 0 : table.bordered,
@@ -511,8 +524,32 @@ var InternalProTable = function InternalProTable(props) {
511
524
  formItemLayout: props.formItemLayout,
512
525
  formItemCol: props.formItemCol,
513
526
  onSearch: _onSearch,
527
+ tableOperation: /*#__PURE__*/_jsx(TableOperation, {
528
+ tableRowSize: tableRowSize,
529
+ columns: columns,
530
+ tableRef: tableRef,
531
+ isInModalOrDrawer: isInModalOrDrawer,
532
+ onReset: _onReset,
533
+ onChangeRowSize: function onChangeRowSize(e) {
534
+ return setTableRowSize(e);
535
+ }
536
+ }),
537
+ children: newToolbarExtra
538
+ }) : /*#__PURE__*/_jsx(HeadComponent, {
539
+ form: form,
540
+ titleBordered: table === null || table === void 0 ? void 0 : table.bordered,
541
+ toolbar: newToolbar,
542
+ formItems: formItems,
543
+ expandForm: expandForm,
544
+ formInitValues: formInitValues,
545
+ formItemLabelWidth: props.formItemLabelWidth,
546
+ onSearch: _onSearch,
514
547
  tableOperation: /*#__PURE__*/_jsx(TableOperation, {
515
548
  isInModalOrDrawer: isInModalOrDrawer,
549
+ onChangeRowSize: function onChangeRowSize(e) {
550
+ return setTableRowSize(e);
551
+ },
552
+ tableRowSize: tableRowSize,
516
553
  onReset: _onReset,
517
554
  columns: columns,
518
555
  tableRef: tableRef
@@ -1,3 +1,4 @@
1
+ import { TableProps } from 'antd';
1
2
  import { TableSticky } from 'rc-table/lib/interface';
2
3
  import { RefObject } from 'react';
3
4
  import CCS from '..';
@@ -10,8 +11,8 @@ export type TreeInstance<T> = {
10
11
  };
11
12
  type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'onSearchBefore' | 'parentFieldName'> & {
12
13
  data: CCS.TableData<T>;
13
- isInModalOrDrawer: boolean;
14
14
  sticky: boolean | TableSticky;
15
+ tableRowSize: TableProps['size'];
15
16
  treeRef: RefObject<TreeInstance<T>>;
16
17
  tableRef: React.MutableRefObject<TableRefType | undefined>;
17
18
  setData: React.Dispatch<React.SetStateAction<CCS.TableData<T>>>;
@@ -20,5 +21,5 @@ type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'onSearchBefore' |
20
21
  children: T[];
21
22
  })[]>;
22
23
  };
23
- declare const TableTree: <T extends object = any>({ data, table, sticky, treeRef, tableRef, setData, onSearchAfter, onSearchBefore, parentFieldName, handlePageChange, isInModalOrDrawer, }: TreeTableProps<T>) => import("react/jsx-runtime").JSX.Element;
24
+ declare const TableTree: <T extends object = any>({ data, table, sticky, treeRef, tableRef, tableRowSize, parentFieldName, handlePageChange, setData, onSearchAfter, onSearchBefore, }: TreeTableProps<T>) => import("react/jsx-runtime").JSX.Element;
24
25
  export default TableTree;
@@ -26,12 +26,12 @@ var TableTree = function TableTree(_ref) {
26
26
  sticky = _ref.sticky,
27
27
  treeRef = _ref.treeRef,
28
28
  tableRef = _ref.tableRef,
29
- setData = _ref.setData,
30
- onSearchAfter = _ref.onSearchAfter,
31
- onSearchBefore = _ref.onSearchBefore,
29
+ tableRowSize = _ref.tableRowSize,
32
30
  parentFieldName = _ref.parentFieldName,
33
31
  handlePageChange = _ref.handlePageChange,
34
- isInModalOrDrawer = _ref.isInModalOrDrawer;
32
+ setData = _ref.setData,
33
+ onSearchAfter = _ref.onSearchAfter,
34
+ onSearchBefore = _ref.onSearchBefore;
35
35
  // async tree expand key
36
36
  var _useState = useState([]),
37
37
  _useState2 = _slicedToArray(_useState, 2),
@@ -159,9 +159,9 @@ var TableTree = function TableTree(_ref) {
159
159
  return /*#__PURE__*/_jsx(CcsTable, _objectSpread(_objectSpread({
160
160
  onChange: handlePageChange,
161
161
  data: data,
162
- tableRef: tableRef,
163
- size: isInModalOrDrawer ? 'small' : 'middle'
162
+ tableRef: tableRef
164
163
  }, tableParams), {}, {
164
+ size: tableRowSize,
165
165
  columns: columns,
166
166
  showSorterTooltip: true,
167
167
  loading: tableParams.loading || data.loading || false
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "1.1.25-beta-9",
4
- "description": "验证码组件兼容暗黑模式;proTable封装rowselection代码;proTable添加传统布局模式;",
3
+ "version": "1.1.25-beta-11",
4
+ "description": "验证码组件兼容暗黑模式;proTable封装rowselection代码;proTable添加自适应布局模式;",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Hong",