@fle-ui/plus-table 1.0.7 → 1.0.15

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.
Files changed (42) hide show
  1. package/README.md +18 -18
  2. package/es/FormSearch/FormRender.d.ts +31 -0
  3. package/es/FormSearch/FormRender.js +2 -2
  4. package/es/FormSearch/index.d.ts +44 -0
  5. package/es/FormSearch/index.js +2 -2
  6. package/es/FormSearch/index.less +57 -57
  7. package/es/components/icon/index.d.ts +3 -0
  8. package/es/components/icon/index.js +7 -0
  9. package/es/index.d.ts +44 -0
  10. package/es/index.js +51 -46
  11. package/es/index.less +107 -107
  12. package/es/utils/api.d.ts +9 -0
  13. package/es/utils/common.d.ts +26 -0
  14. package/es/utils/common.js +2 -2
  15. package/es/utils/options.d.ts +25 -0
  16. package/es/utils/request.d.ts +26 -0
  17. package/es/utils/request.js +1 -1
  18. package/es/utils/serviceEnv.d.ts +6 -0
  19. package/es/utils/serviceEnv.js +12 -0
  20. package/lib/FormSearch/FormRender.d.ts +31 -0
  21. package/lib/FormSearch/FormRender.js +214 -0
  22. package/lib/FormSearch/index.d.ts +44 -0
  23. package/lib/FormSearch/index.js +194 -0
  24. package/lib/FormSearch/index.less +57 -57
  25. package/lib/components/icon/index.d.ts +3 -0
  26. package/lib/components/icon/index.js +13 -0
  27. package/lib/index.d.ts +44 -0
  28. package/lib/index.js +52 -48
  29. package/lib/index.less +107 -107
  30. package/lib/utils/api.d.ts +9 -0
  31. package/lib/utils/api.js +15 -0
  32. package/lib/utils/common.d.ts +26 -0
  33. package/lib/utils/common.js +38 -0
  34. package/lib/utils/options.d.ts +25 -0
  35. package/lib/utils/options.js +101 -0
  36. package/lib/utils/request.d.ts +26 -0
  37. package/lib/utils/request.js +180 -0
  38. package/lib/utils/serviceEnv.d.ts +6 -0
  39. package/lib/utils/serviceEnv.js +18 -0
  40. package/package.json +12 -15
  41. package/es/mock.js +0 -60
  42. package/lib/mock.js +0 -66
@@ -0,0 +1,44 @@
1
+ import type { TablePaginationConfig } from 'antd';
2
+ import React from 'react';
3
+ import type { ActionType, ProTableProps } from '@ant-design/pro-components';
4
+ export type Bordered = boolean | {
5
+ search?: boolean;
6
+ table?: boolean;
7
+ };
8
+ type BaseFormProps<T, U> = {
9
+ pagination?: TablePaginationConfig | false;
10
+ beforeSearchSubmit?: (params: Partial<U>) => any;
11
+ action: React.MutableRefObject<ActionType | undefined>;
12
+ onSubmit?: (params: U) => void;
13
+ onReset?: () => void;
14
+ loading: boolean;
15
+ onFormSearchSubmit: (params: U) => void;
16
+ columns: ProTableProps<T, U, any>['columns'];
17
+ dateFormatter: ProTableProps<T, U, any>['dateFormatter'];
18
+ formRef: ProTableProps<T, U, any>['formRef'];
19
+ type: ProTableProps<T, U, any>['type'];
20
+ cardBordered: ProTableProps<T, U, any>['cardBordered'];
21
+ form: ProTableProps<T, U, any>['form'];
22
+ search: ProTableProps<T, U, any>['search'];
23
+ manualRequest: ProTableProps<T, U, any>['manualRequest'];
24
+ changeValue: Function;
25
+ };
26
+ declare class FormSearch<T, U> extends React.Component<BaseFormProps<T, U> & {
27
+ ghost?: boolean;
28
+ }> {
29
+ /** 查询表单相关的配置 */
30
+ onSubmit: (value: U, firstLoad: boolean) => void;
31
+ onReset: (value: Partial<U>) => void;
32
+ /**
33
+ * 只 Diff 需要用的 props,能减少 5 次左右的render
34
+ *
35
+ * @param next
36
+ * @see 因为 hooks 每次的 setFormSearch 都是新的,所以每次都触发 render
37
+ * @see action 也是同样的原因
38
+ * @returns
39
+ */
40
+ isEqual: (next: BaseFormProps<T, U>) => boolean;
41
+ shouldComponentUpdate: (next: BaseFormProps<T, U>) => boolean;
42
+ render: () => React.JSX.Element;
43
+ }
44
+ export default FormSearch;
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _proUtils = require("@ant-design/pro-utils");
9
+ var _omit = _interopRequireDefault(require("omit.js"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _FormRender = _interopRequireDefault(require("./FormRender"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ 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; }
14
+ 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; }
15
+ 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; }
16
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
17
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
21
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
22
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
23
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
24
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
25
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
26
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
27
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
28
+ var isBordered = function isBordered(borderType, border) {
29
+ if (border === undefined) {
30
+ return false;
31
+ }
32
+ if (typeof border === 'boolean') {
33
+ return border;
34
+ }
35
+ return border[borderType];
36
+ };
37
+ var FormSearch = /*#__PURE__*/function (_React$Component) {
38
+ function FormSearch() {
39
+ var _this;
40
+ _classCallCheck(this, FormSearch);
41
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
42
+ args[_key] = arguments[_key];
43
+ }
44
+ _this = _callSuper(this, FormSearch, [].concat(args));
45
+ /** 查询表单相关的配置 */
46
+ _this.onSubmit = function (value, firstLoad) {
47
+ var _this$props = _this.props,
48
+ pagination = _this$props.pagination,
49
+ _this$props$beforeSea = _this$props.beforeSearchSubmit,
50
+ beforeSearchSubmit = _this$props$beforeSea === void 0 ? function (searchParams) {
51
+ return searchParams;
52
+ } : _this$props$beforeSea,
53
+ action = _this$props.action,
54
+ onSubmit = _this$props.onSubmit,
55
+ onFormSearchSubmit = _this$props.onFormSearchSubmit;
56
+ // 只传入 pagination 中的 current 和 pageSize 参数
57
+ var pageInfo = pagination ? (0, _proUtils.omitUndefined)({
58
+ current: pagination.current,
59
+ pageSize: pagination.pageSize
60
+ }) : {};
61
+ var submitParams = _objectSpread(_objectSpread({}, value), {}, {
62
+ _timestamp: Date.now()
63
+ }, pageInfo);
64
+ var omitParams = (0, _omit.default)(beforeSearchSubmit(submitParams), Object.keys(pageInfo));
65
+ onFormSearchSubmit(omitParams);
66
+ if (!firstLoad) {
67
+ var _action$current, _action$current$setPa;
68
+ // back first page
69
+ (_action$current = action.current) === null || _action$current === void 0 ? void 0 : (_action$current$setPa = _action$current.setPageInfo) === null || _action$current$setPa === void 0 ? void 0 : _action$current$setPa.call(_action$current, {
70
+ current: 1
71
+ });
72
+ }
73
+ // 不是第一次提交就不触发,第一次提交是 js 触发的
74
+ // 为了解决 https://github.com/ant-design/pro-components/issues/579
75
+ if (onSubmit && !firstLoad) {
76
+ onSubmit === null || onSubmit === void 0 ? void 0 : onSubmit(value);
77
+ }
78
+ };
79
+ _this.onReset = function (value) {
80
+ var _action$current2, _action$current2$setP;
81
+ var _this$props2 = _this.props,
82
+ pagination = _this$props2.pagination,
83
+ _this$props2$beforeSe = _this$props2.beforeSearchSubmit,
84
+ beforeSearchSubmit = _this$props2$beforeSe === void 0 ? function (searchParams) {
85
+ return searchParams;
86
+ } : _this$props2$beforeSe,
87
+ action = _this$props2.action,
88
+ onFormSearchSubmit = _this$props2.onFormSearchSubmit,
89
+ onReset = _this$props2.onReset;
90
+ var pageInfo = pagination ? (0, _proUtils.omitUndefined)({
91
+ current: pagination.current,
92
+ pageSize: pagination.pageSize
93
+ }) : {};
94
+ var omitParams = (0, _omit.default)(beforeSearchSubmit(_objectSpread(_objectSpread({}, value), pageInfo)), Object.keys(pageInfo));
95
+ onFormSearchSubmit(omitParams);
96
+ // back first page
97
+ (_action$current2 = action.current) === null || _action$current2 === void 0 ? void 0 : (_action$current2$setP = _action$current2.setPageInfo) === null || _action$current2$setP === void 0 ? void 0 : _action$current2$setP.call(_action$current2, {
98
+ current: 1
99
+ });
100
+ onReset === null || onReset === void 0 ? void 0 : onReset();
101
+ };
102
+ /**
103
+ * 只 Diff 需要用的 props,能减少 5 次左右的render
104
+ *
105
+ * @param next
106
+ * @see 因为 hooks 每次的 setFormSearch 都是新的,所以每次都触发 render
107
+ * @see action 也是同样的原因
108
+ * @returns
109
+ */
110
+ _this.isEqual = function (next) {
111
+ var _this$props3 = _this.props,
112
+ columns = _this$props3.columns,
113
+ loading = _this$props3.loading,
114
+ formRef = _this$props3.formRef,
115
+ type = _this$props3.type,
116
+ cardBordered = _this$props3.cardBordered,
117
+ dateFormatter = _this$props3.dateFormatter,
118
+ form = _this$props3.form,
119
+ search = _this$props3.search,
120
+ manualRequest = _this$props3.manualRequest;
121
+ var diffProps = {
122
+ columns: columns,
123
+ loading: loading,
124
+ formRef: formRef,
125
+ type: type,
126
+ cardBordered: cardBordered,
127
+ dateFormatter: dateFormatter,
128
+ form: form,
129
+ search: search,
130
+ manualRequest: manualRequest
131
+ };
132
+ return !(0, _proUtils.isDeepEqualReact)(diffProps, {
133
+ columns: next.columns,
134
+ formRef: next.formRef,
135
+ loading: next.loading,
136
+ type: next.type,
137
+ cardBordered: next.cardBordered,
138
+ dateFormatter: next.dateFormatter,
139
+ form: next.form,
140
+ search: next.search,
141
+ manualRequest: next.manualRequest
142
+ });
143
+ };
144
+ _this.shouldComponentUpdate = function (next) {
145
+ return _this.isEqual(next);
146
+ };
147
+ _this.render = function () {
148
+ var _this$props4 = _this.props,
149
+ columns = _this$props4.columns,
150
+ loading = _this$props4.loading,
151
+ formRef = _this$props4.formRef,
152
+ type = _this$props4.type,
153
+ action = _this$props4.action,
154
+ cardBordered = _this$props4.cardBordered,
155
+ dateFormatter = _this$props4.dateFormatter,
156
+ form = _this$props4.form,
157
+ search = _this$props4.search,
158
+ pagination = _this$props4.pagination,
159
+ ghost = _this$props4.ghost,
160
+ manualRequest = _this$props4.manualRequest,
161
+ changeValue = _this$props4.changeValue;
162
+ var pageInfo = pagination ? (0, _proUtils.omitUndefined)({
163
+ current: pagination.current,
164
+ pageSize: pagination.pageSize
165
+ }) : {};
166
+ return /*#__PURE__*/_react.default.createElement(_FormRender.default, {
167
+ submitButtonLoading: loading,
168
+ columns: columns,
169
+ type: type,
170
+ ghost: ghost,
171
+ formRef: formRef,
172
+ onSubmit: _this.onSubmit,
173
+ manualRequest: manualRequest,
174
+ onReset: _this.onReset,
175
+ dateFormatter: dateFormatter,
176
+ search: search,
177
+ form: _objectSpread(_objectSpread({
178
+ onValuesChange: function onValuesChange(changeValue, allValue) {
179
+ _this.props.changeValue(changeValue, allValue);
180
+ },
181
+ autoFocusFirstInput: false
182
+ }, form), {}, {
183
+ extraUrlParams: _objectSpread(_objectSpread({}, pageInfo), form === null || form === void 0 ? void 0 : form.extraUrlParams)
184
+ }),
185
+ action: action,
186
+ bordered: isBordered('search', cardBordered)
187
+ });
188
+ };
189
+ return _this;
190
+ }
191
+ _inherits(FormSearch, _React$Component);
192
+ return _createClass(FormSearch);
193
+ }(_react.default.Component);
194
+ var _default = exports.default = FormSearch;
@@ -1,57 +1,57 @@
1
- .search-drawer {
2
- // 搜索栏内部样式复写
3
- ::-webkit-scrollbar {
4
- width: 2px;
5
- }
6
- .ant-pro-query-filter-row {
7
- row-gap: 12px;
8
- }
9
- .ant-pro-table-search {
10
- padding: 0;
11
- .ant-form-item-control {
12
- width: auto;
13
- }
14
- .ant-pro-table-search-query-filter {
15
- border: none;
16
- }
17
- .ant-pro-query-filter {
18
- background-color: #fff;
19
- padding: 0;
20
- .ant-row {
21
- display: flex;
22
- flex-direction: row;
23
- .ant-form-item-label {
24
- width: 84px;
25
- line-height: 34px;
26
- margin-right: 8px;
27
- text-align: right;
28
- label {
29
- font-size: 14px;
30
- }
31
- }
32
- .ant-form-item-control {
33
- width: 230px;
34
- .ant-form-item-control-input {
35
- width: 230px;
36
- }
37
- .ant-picker {
38
- min-width: 230px !important;
39
- width: 230px;
40
- }
41
- }
42
- }
43
- }
44
- }
45
- }
46
- .page_plustable__body {
47
- // 为了复写pagecontainer的样式
48
- background-color: #fff;
49
- transition: all ease 0.3s;
50
- // margin: 16px;
51
- // padding: 16px;
52
- height: 100%;
53
- width: 100%;
54
- &.turn-left {
55
- width: calc(100% - 356px);
56
- }
57
- }
1
+ .search-drawer {
2
+ // 搜索栏内部样式复写
3
+ ::-webkit-scrollbar {
4
+ width: 2px;
5
+ }
6
+ .ant-pro-query-filter-row {
7
+ row-gap: 12px;
8
+ }
9
+ .ant-pro-table-search {
10
+ padding: 0;
11
+ .ant-form-item-control {
12
+ width: auto;
13
+ }
14
+ .ant-pro-table-search-query-filter {
15
+ border: none;
16
+ }
17
+ .ant-pro-query-filter {
18
+ background-color: #fff;
19
+ padding: 0;
20
+ .ant-row {
21
+ display: flex;
22
+ flex-direction: row;
23
+ .ant-form-item-label {
24
+ width: 84px;
25
+ line-height: 34px;
26
+ margin-right: 8px;
27
+ text-align: right;
28
+ label {
29
+ font-size: 14px;
30
+ }
31
+ }
32
+ .ant-form-item-control {
33
+ width: 230px;
34
+ .ant-form-item-control-input {
35
+ width: 230px;
36
+ }
37
+ .ant-picker {
38
+ min-width: 230px !important;
39
+ width: 230px;
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ .page_plustable__body {
47
+ // 为了复写pagecontainer的样式
48
+ background-color: #fff;
49
+ transition: all ease 0.3s;
50
+ // margin: 16px;
51
+ // padding: 16px;
52
+ height: 100%;
53
+ width: 100%;
54
+ &.turn-left {
55
+ width: calc(100% - 356px);
56
+ }
57
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const Icon: import("react").FC<import("@ant-design/icons/lib/components/IconFont").IconFontProps<string>>;
3
+ export default Icon;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _icons = require("@ant-design/icons");
8
+ /* 采用iconfont Symbol模式
9
+ 每次更新icon后,记得复制最新的地址哦~ */
10
+ var Icon = (0, _icons.createFromIconfontCN)({
11
+ scriptUrl: ['//at.alicdn.com/t/c/font_3161758_5bzjjx85uxv.js', '//at.alicdn.com/t/font_2562875_b3aduyabrj.js']
12
+ });
13
+ var _default = exports.default = Icon;
package/lib/index.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import React, { ReactElement } from 'react';
2
+ import type { ProColumns } from '@ant-design/pro-components';
3
+ import './FormSearch/index.less';
4
+ interface PlusColumns extends ProColumns {
5
+ baseSearch?: boolean;
6
+ }
7
+ export type { PlusColumns };
8
+ type settingsColumns = {
9
+ [key: string]: {
10
+ hideInTable?: boolean;
11
+ show?: boolean;
12
+ title: string;
13
+ field: string;
14
+ disabled?: boolean;
15
+ fixed?: 'left' | 'right';
16
+ sort?: number;
17
+ };
18
+ };
19
+ type PlusProps = {
20
+ mode?: 'normal' | 'drawsearch';
21
+ columns: PlusColumns[];
22
+ request?: any;
23
+ top?: number;
24
+ fetchSetting?: () => Promise<settingsColumns>;
25
+ updateSetting?: (params: any) => Promise<settingsColumns>;
26
+ defaultColumnsState?: {
27
+ [key: string]: {
28
+ show: boolean;
29
+ fixed: 'left' | 'right' | undefined;
30
+ };
31
+ };
32
+ headerTitle?: ReactElement;
33
+ hasShowFull?: boolean;
34
+ pagination?: {
35
+ pageSize?: number;
36
+ current?: number;
37
+ };
38
+ actionRef: any;
39
+ formRef?: any;
40
+ options?: any;
41
+ [key: string | symbol]: any;
42
+ };
43
+ declare const PlusTable: React.ForwardRefExoticComponent<Omit<PlusProps, "ref"> & React.RefAttributes<unknown>>;
44
+ export default PlusTable;