@pointcloud/pcloud-components 1.0.7 → 1.0.9

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.
@@ -2,11 +2,11 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["inputSearch"];
6
- import React, { useState, useRef, useImperativeHandle, useContext } from 'react';
7
- import { Input, Button, Collapse } from 'antd';
5
+ var _excluded = ["inputSearch", "placeholder"];
6
+ import React, { useState, useImperativeHandle, useContext, useMemo, useCallback } from 'react';
7
+ import { Input, Button, Collapse, Row } from 'antd';
8
8
  import classNames from 'classnames';
9
- import FormFilter from "./FormFilter";
9
+ import DForm from "../DForm";
10
10
  import { ConfigContext } from "../ConfigProvider";
11
11
  import "./styles/index.less";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -16,13 +16,15 @@ var AdvancedFilter = function AdvancedFilter(props) {
16
16
  right = props.right,
17
17
  _props$inputProps = props.inputProps,
18
18
  inputProps = _props$inputProps === void 0 ? {} : _props$inputProps,
19
- formItemConfig = props.formItemConfig,
19
+ items = props.items,
20
20
  fRef = props.fRef,
21
21
  icon = props.icon,
22
22
  onValuesChange = props.onValuesChange,
23
23
  onSearch = props.onSearch,
24
24
  onReset = props.onReset;
25
25
  var inputSearch = inputProps.inputSearch,
26
+ _inputProps$placehold = inputProps.placeholder,
27
+ placeholder = _inputProps$placehold === void 0 ? '请输入关键字查询' : _inputProps$placehold,
26
28
  otherInputProps = _objectWithoutProperties(inputProps, _excluded);
27
29
  var _useContext = useContext(ConfigContext),
28
30
  prefixCls = _useContext.prefixCls,
@@ -37,30 +39,40 @@ var AdvancedFilter = function AdvancedFilter(props) {
37
39
  _useState4 = _slicedToArray(_useState3, 2),
38
40
  inputValue = _useState4[0],
39
41
  setInputValue = _useState4[1];
40
- var inputRef = useRef(null);
41
- var formRef = useRef(null);
42
- var resetFields = function resetFields() {
43
- var _formRef$current;
42
+ var inputRef = React.useRef(null);
43
+ var _DForm$useForm = DForm.useForm(),
44
+ _DForm$useForm2 = _slicedToArray(_DForm$useForm, 1),
45
+ form = _DForm$useForm2[0];
46
+ var resetFields = useCallback(function () {
44
47
  setInputValue('');
45
- formRef === null || formRef === void 0 || (_formRef$current = formRef.current) === null || _formRef$current === void 0 || _formRef$current.resetFields();
46
- };
48
+ form.resetFields();
49
+ }, [form]);
47
50
  useImperativeHandle(fRef, function () {
48
- var _formRef$current2;
49
51
  return {
50
52
  resetFields: resetFields,
51
- form: (_formRef$current2 = formRef.current) === null || _formRef$current2 === void 0 ? void 0 : _formRef$current2.form
53
+ form: form
52
54
  };
53
55
  });
54
- var handleSearch = function handleSearch(values) {
56
+ var handleSearch = useCallback(function (values) {
55
57
  var _inputRef$current;
56
58
  var value = inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || (_inputRef$current = _inputRef$current.input) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value;
57
59
  onSearch === null || onSearch === void 0 || onSearch(_objectSpread(_objectSpread({}, values), _defineProperty({}, inputProps.name, value)));
58
- };
59
- var _inputSearch = function _inputSearch(v) {
60
+ }, [inputProps.name, onSearch]);
61
+ var _inputSearch = useCallback(function (v) {
60
62
  if (typeof inputSearch === 'function') {
61
63
  inputSearch(_defineProperty({}, inputProps.name, v));
62
64
  }
63
- };
65
+ }, [inputSearch, inputProps.name]);
66
+ var handleValuesChange = useCallback(function (changedValues, allValues) {
67
+ onValuesChange === null || onValuesChange === void 0 || onValuesChange(allValues);
68
+ }, [onValuesChange]);
69
+ var handleReset = useCallback(function () {
70
+ form.resetFields();
71
+ onReset === null || onReset === void 0 || onReset();
72
+ }, [form, onReset]);
73
+ var dFormItems = useMemo(function () {
74
+ return items || [];
75
+ }, [items]);
64
76
  return /*#__PURE__*/_jsx(Collapse, {
65
77
  className: wrapperClass,
66
78
  activeKey: panelVisible ? '1' : 'none',
@@ -92,7 +104,8 @@ var AdvancedFilter = function AdvancedFilter(props) {
92
104
  onValuesChange === null || onValuesChange === void 0 || onValuesChange(e.target.value);
93
105
  },
94
106
  onSearch: _inputSearch,
95
- value: inputValue
107
+ value: inputValue,
108
+ placeholder: placeholder
96
109
  }, otherInputProps)), /*#__PURE__*/_jsxs(Button, {
97
110
  type: "primary",
98
111
  className: "button",
@@ -114,14 +127,28 @@ var AdvancedFilter = function AdvancedFilter(props) {
114
127
  children: [/*#__PURE__*/_jsx("span", {
115
128
  className: "icon"
116
129
  }), " \u67E5\u8BE2\u6761\u4EF6"]
117
- }), /*#__PURE__*/_jsx("div", {
130
+ }), /*#__PURE__*/_jsxs("div", {
118
131
  className: "search-content",
119
- children: /*#__PURE__*/_jsx(FormFilter, {
120
- formRef: formRef,
121
- formItemConfig: formItemConfig,
122
- onSearch: handleSearch,
123
- onReset: onReset
124
- })
132
+ children: [/*#__PURE__*/_jsx(DForm, {
133
+ form: form,
134
+ layout: "inline",
135
+ items: dFormItems,
136
+ onFinish: handleSearch,
137
+ onValuesChange: handleValuesChange,
138
+ onReset: handleReset
139
+ }), /*#__PURE__*/_jsxs(Row, {
140
+ className: "search-btn",
141
+ children: [/*#__PURE__*/_jsx(Button, {
142
+ type: "primary",
143
+ onClick: function onClick() {
144
+ return form.submit();
145
+ },
146
+ children: "\u67E5\u8BE2"
147
+ }), /*#__PURE__*/_jsx(Button, {
148
+ onClick: handleReset,
149
+ children: "\u91CD\u7F6E"
150
+ })]
151
+ })]
125
152
  })]
126
153
  }, "1")
127
154
  });
@@ -1,94 +1,27 @@
1
1
  import React from 'react';
2
2
  import type { InputProps as AntdInputProps } from 'antd';
3
- export type FormItemType = 'input' | 'inputNumber' | 'radio' | 'select' | 'checkbox' | 'datePicker' | 'rangePicker' | 'switch' | 'treeSelect';
4
- export interface FormItem {
5
- /**
6
- * @description 筛选项label文字
7
- */
8
- label?: string;
9
- /**
10
- * @description 筛选项字段名
11
- */
12
- name: string;
13
- /**
14
- * @description 筛选项类型
15
- */
16
- type: FormItemType;
17
- /**
18
- * @description 筛选项placeholder
19
- */
20
- placeholder?: string;
21
- /**
22
- * @description 筛选项的配置项(select|treeSelect时可用)
23
- */
24
- options?: any[];
25
- /**
26
- * @description 筛选项的格式化配置(rangePicker|datePicker时可用)
27
- */
28
- format?: string;
29
- }
3
+ import type { DItemProps } from '../DForm';
30
4
  export interface FormProps {
31
- /**
32
- * @description 筛选项配置
33
- */
34
- formItemConfig: FormItem[];
35
- /**
36
- * @description 筛选项值变更时触发
37
- */
5
+ items?: DItemProps[];
38
6
  onValuesChange?: (_values: any) => void;
39
- /**
40
- * @description 点击查询按钮时触发
41
- */
42
7
  onSearch?: (_v: any) => void;
43
- /**
44
- * @description 点击重置按钮时触发
45
- */
46
8
  onReset?: () => void;
47
9
  }
48
10
  export interface FProps extends FormProps {
49
- /**
50
- * @description 显示查询/重置按钮
51
- * @default true
52
- */
53
11
  showButton?: boolean;
54
- /**
55
- * @description 筛选项表单的Ref
56
- */
57
12
  formRef?: any;
58
13
  }
59
14
  export interface InputProps extends AntdInputProps {
60
- /**
61
- * @description input检索框回车时或点击检索图标时触发
62
- */
63
15
  inputSearch?: (_v: any) => void;
64
16
  }
65
17
  export interface FilterProps extends FormProps {
66
- /**
67
- * @description 左侧渲染区
68
- */
69
18
  left?: React.ReactNode;
70
- /**
71
- * @description 右侧渲染区
72
- */
73
19
  right?: React.ReactNode;
74
- /**
75
- * @description input检索框props
76
- */
77
20
  inputProps: InputProps;
78
- /**
79
- * @description children
80
- */
81
21
  children?: React.ReactNode;
82
- /**
83
- * @description 表单引用ref值
84
- */
85
22
  fRef?: any;
86
- /**
87
- * @description 筛选文字按钮图标
88
- */
89
23
  icon?: React.ReactNode;
90
24
  }
91
25
  export type AdvancedFilterProps = FilterProps;
92
26
  export type FormFilterProps = FProps;
93
- export type FotmItemProps = FormItem;
94
27
  export type InputSearchProps = InputProps;
@@ -12,10 +12,6 @@
12
12
  cursor: auto !important;
13
13
  }
14
14
 
15
- .ant-collapse-content-box {
16
- padding: 0;
17
- }
18
-
19
15
  .search-header {
20
16
  display: flex;
21
17
  width: 100%;
@@ -25,42 +21,6 @@
25
21
  overflow: hidden;
26
22
  white-space: no-wrap;
27
23
  text-overflow: ellipsis;
28
-
29
- :global {
30
- .ant-radio-wrapper:first-child {
31
- border-left: 1px solid #d9d9d9;
32
- border-radius: 5px 0 0 5px;
33
- }
34
-
35
- .ant-radio-wrapper:last-child {
36
- border-radius: 0 5px 5px 0;
37
- }
38
-
39
- .ant-radio-wrapper {
40
- margin-right: 0;
41
- padding: 4px 6px;
42
- border: 1px solid #d9d9d9;
43
- border-top-width: 1px;
44
- border-left: 1px solid #fff;
45
- border-left-width: 1px;
46
-
47
- .ant-radio {
48
- display: none;
49
- }
50
- }
51
-
52
- .ant-radio-wrapper:hover {
53
- color: #1890ff;
54
- }
55
-
56
- .ant-radio-wrapper-checked {
57
- z-index: 1;
58
- color: #1890ff;
59
- background: #fff;
60
- border: 1px solid #1890ff;
61
- border-left: 1px solid #1890ff !important;
62
- }
63
- }
64
24
  }
65
25
 
66
26
  .right {
@@ -100,10 +60,8 @@
100
60
  .title {
101
61
  display: flex;
102
62
  align-items: center;
103
- margin: 0 10px;
104
63
  padding-bottom: 10px;
105
64
  font-weight: bold;
106
- border-bottom: 1px solid #f0f0f0;
107
65
 
108
66
  span.icon {
109
67
  width: 4px;
@@ -115,23 +73,6 @@
115
73
  }
116
74
 
117
75
  .search-content {
118
- .filter-row {
119
- display: flex;
120
- flex-wrap: wrap;
121
- width: 100%;
122
- padding: 10px;
123
- }
124
-
125
- .filter-col {
126
- height: 30px;
127
- margin-bottom: 10px;
128
- line-height: 30px;
129
- }
130
-
131
- .filter-col .ant-picker {
132
- width: 100%;
133
- }
134
-
135
76
  .search-btn {
136
77
  justify-content: center;
137
78
 
@@ -14,7 +14,7 @@ export type CRUDRefProps = {
14
14
  /** 刷新表格数据 */
15
15
  refresh: (_strategy?: RefreshStrategy) => void;
16
16
  getSelectedRows: () => {
17
- selectedRowKeys: any[];
17
+ selectedRowKeys: string[];
18
18
  selectedRows: any[];
19
19
  };
20
20
  getSearchValues: () => Record<string, any>;
@@ -23,7 +23,7 @@ export type CRUDRefProps = {
23
23
  openDeleteModal: (_record?: any) => void;
24
24
  openDetailModal: (_record?: any) => void;
25
25
  };
26
- export type MoreActionColumnRender = (_text: any, _record: Record<string, any>) => React.ReactNode;
26
+ export type MoreActionColumnRender<T = Record<string, any>> = (_text: any, _record: T) => React.ReactNode;
27
27
  export type CRUDProps = {
28
28
  className?: string;
29
29
  style?: React.CSSProperties;
@@ -32,7 +32,9 @@ export type CRUDProps = {
32
32
  immediate?: boolean;
33
33
  };
34
34
  /** 表格配置 */
35
- tableProps: DTableProps;
35
+ tableProps: DTableProps & {
36
+ moreActionColumn?: MoreActionColumnRender;
37
+ };
36
38
  /** 新增/编辑表单配置 */
37
39
  modalFormProps?: {
38
40
  /** 表单配置 */
@@ -46,7 +48,7 @@ export type CRUDProps = {
46
48
  /** 新增按钮文本 */
47
49
  addButtonText?: string;
48
50
  /** 是否显示新增按钮 */
49
- showAddButton?: boolean;
51
+ showAdd?: boolean;
50
52
  /** 是否显示批量删除按钮 */
51
53
  showBatchDelete?: boolean;
52
54
  /** 批量删除按钮文本 */
@@ -71,8 +73,6 @@ export type CRUDProps = {
71
73
  viewButtonText?: string;
72
74
  /** 行查看按钮配置 */
73
75
  viewButtonProps?: ButtonProps;
74
- /** 更多操作列自定义渲染,参数为(text, record),返回ReactNode */
75
- moreActionColumn?: MoreActionColumnRender;
76
76
  /** 自定义操作栏 */
77
77
  actionBar?: React.ReactNode;
78
78
  /** 数据刷新回调 */
@@ -80,11 +80,11 @@ export type CRUDProps = {
80
80
  crudApi: {
81
81
  list: (_params: any) => Promise<DTableSourceProps>;
82
82
  /** 删除数据接口 */
83
- delete: (_params: any) => Promise<any>;
83
+ delete?: (_params: any) => Promise<any>;
84
84
  /** 新增数据接口 */
85
- add: (_params: any) => Promise<any>;
85
+ add?: (_params: any) => Promise<any>;
86
86
  /** 编辑数据接口 */
87
- edit: (_params: any) => Promise<any>;
87
+ edit?: (_params: any) => Promise<any>;
88
88
  /** 详情数据接口 */
89
89
  detail?: (_params: any) => Promise<any>;
90
90
  };