@ccs-ui/rc-pro 2.3.6-alpha-1 → 2.3.6-alpha-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.
@@ -16,7 +16,7 @@ export type DialogButtonsProps<T> = Pick<CcsDialogModalProps, 'okText' | 'onClos
16
16
  export type DialogButtonRef = {
17
17
  onSetButtons: (e: React.ReactElement) => void;
18
18
  };
19
- export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "auth" | "request" | "onClose" | "onOk" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
19
+ export declare const DialogButtonHolder: <TParams, TData>({ auth, extraBtn, formRef, request, onOk, onClose, buttonRef, requestFieldNames, formInitialValues, preventRequestHandle, }: Pick<CcsDialogModalProps<TParams, TData>, "onClose" | "auth" | "request" | "onOk" | "extraBtn" | "requestFieldNames" | "preventRequestHandle"> & {
20
20
  formRef: React.RefObject<DialogFormRef<TParams>>;
21
21
  formInitialValues: FormProps['initialValues'];
22
22
  buttonRef: RefObject<DialogButtonRef>;
@@ -41,14 +41,17 @@ export default function useTableSelection(props) {
41
41
  }
42
42
  });
43
43
  var handleOnChange = useMemoizedFn(function () {
44
- var _selectionRef$current = selectionRef.current.selectedRowKeys,
45
- selectedRowKeys = _selectionRef$current === void 0 ? [] : _selectionRef$current;
44
+ var _selectionRef$current = selectionRef.current,
45
+ _selectionRef$current2 = _selectionRef$current.selectedRowKeys,
46
+ selectedRowKeys = _selectionRef$current2 === void 0 ? [] : _selectionRef$current2,
47
+ selectedRows = _selectionRef$current.selectedRows;
46
48
  if (multiple) {
47
49
  // 受控调用onChange
48
50
  onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys);
49
51
  } else {
50
52
  onChangeValue === null || onChangeValue === void 0 || onChangeValue(selectedRowKeys[0]);
51
53
  }
54
+ onChangeRows === null || onChangeRows === void 0 || onChangeRows(selectedRows || []);
52
55
  if (!onChangeValue) setUpdate({});
53
56
  });
54
57
 
@@ -66,8 +69,8 @@ export default function useTableSelection(props) {
66
69
  // value 变更,与当前选中数据不匹配
67
70
  useUpdateEffect(function () {
68
71
  if (isEq(value, selectionRef.current.selectedRowKeys)) {
69
- var _selectionRef$current2;
70
- var rows = (_selectionRef$current2 = selectionRef.current.selectedRows) === null || _selectionRef$current2 === void 0 ? void 0 : _selectionRef$current2.filter(function () {
72
+ var _selectionRef$current3;
73
+ var rows = (_selectionRef$current3 = selectionRef.current.selectedRows) === null || _selectionRef$current3 === void 0 ? void 0 : _selectionRef$current3.filter(function () {
71
74
  var _ref2;
72
75
  var row = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
73
76
  return (_ref2 = value || []) === null || _ref2 === void 0 ? void 0 : _ref2.includes(row[keyField]);
@@ -101,7 +104,6 @@ export default function useTableSelection(props) {
101
104
  }
102
105
  });
103
106
  }
104
- onChangeRows === null || onChangeRows === void 0 || onChangeRows(rows);
105
107
  handleOnChange();
106
108
  });
107
109
 
@@ -117,11 +119,11 @@ export default function useTableSelection(props) {
117
119
  }
118
120
  };
119
121
  } else {
120
- var _selectionRef$current3 = selectionRef.current,
121
- _selectionRef$current4 = _selectionRef$current3.selectedRowKeys,
122
- selectedRowKeys = _selectionRef$current4 === void 0 ? [] : _selectionRef$current4,
123
- _selectionRef$current5 = _selectionRef$current3.selectedRows,
124
- selectedRows = _selectionRef$current5 === void 0 ? [] : _selectionRef$current5;
122
+ var _selectionRef$current4 = selectionRef.current,
123
+ _selectionRef$current5 = _selectionRef$current4.selectedRowKeys,
124
+ selectedRowKeys = _selectionRef$current5 === void 0 ? [] : _selectionRef$current5,
125
+ _selectionRef$current6 = _selectionRef$current4.selectedRows,
126
+ selectedRows = _selectionRef$current6 === void 0 ? [] : _selectionRef$current6;
125
127
  var newRows = selectedRows.filter(function () {
126
128
  var r = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
127
129
  return r[keyField] !== key;
@@ -12,13 +12,15 @@ export type SelectChildrenProps = {
12
12
  /** 更改select options */
13
13
  onChangeOptions?: (options: any[]) => void;
14
14
  /** 自定义显示选中详情 */
15
- onChangeLabel?: (labelText: string) => void;
15
+ onChangeLabel?: (labelText?: string) => void;
16
16
  };
17
17
  export interface CustomizeSelectProps extends Omit<SelectProps, 'children'> {
18
18
  /** 选择触发器宽度 */
19
19
  width?: number;
20
20
  /** 内容宽度 */
21
21
  contentWidth?: number;
22
+ /** 单选自动关闭弹框 */
23
+ autoClose?: boolean;
22
24
  /** 自定义内容 */
23
25
  children: ReactElement | ((props: SelectChildrenProps) => ReactNode);
24
26
  /** form item value */
@@ -31,5 +33,5 @@ export interface CustomizeSelectProps extends Omit<SelectProps, 'children'> {
31
33
  * @param SelectCustomizeProps
32
34
  * @returns
33
35
  */
34
- declare function SelectIndex({ width, title, value, style, mode, children, contentWidth, onChange, ...otherProps }: CustomizeSelectProps): import("react/jsx-runtime").JSX.Element;
36
+ declare function SelectIndex({ width, title, value, style, mode, children, autoClose, contentWidth, onChange, ...otherProps }: CustomizeSelectProps): import("react/jsx-runtime").JSX.Element;
35
37
  export default SelectIndex;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["width", "title", "value", "style", "mode", "children", "contentWidth", "onChange"];
2
+ var _excluded = ["width", "title", "value", "style", "mode", "children", "autoClose", "contentWidth", "onChange"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  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; }
@@ -31,6 +31,7 @@ function SelectIndex(_ref) {
31
31
  style = _ref.style,
32
32
  mode = _ref.mode,
33
33
  children = _ref.children,
34
+ autoClose = _ref.autoClose,
34
35
  contentWidth = _ref.contentWidth,
35
36
  _onChange = _ref.onChange,
36
37
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -66,7 +67,8 @@ function SelectIndex(_ref) {
66
67
  onClose: onClose,
67
68
  onChange: function onChange(e) {
68
69
  _onChange === null || _onChange === void 0 || _onChange(e);
69
- if (!isMulti) setOpen(false);
70
+ // 单选关闭弹框
71
+ if (!isMulti && autoClose !== false) setOpen(false);
70
72
  },
71
73
  onChangeLabel: setLabelText,
72
74
  multiple: isMulti,
@@ -111,7 +113,11 @@ function SelectIndex(_ref) {
111
113
  }
112
114
  }, [open]);
113
115
  var renderValueText = function renderValueText() {
114
- if (value === undefined) return value;
116
+ if (value === undefined || Array.isArray(value) && value.length === 0) {
117
+ return undefined;
118
+ }
119
+
120
+ // 优先显示 labelText
115
121
  if (!!labelText) return labelText;
116
122
  return value;
117
123
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.3.6-alpha-1",
3
+ "version": "2.3.6-alpha-2",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {