@fle-ui/plus-table 1.0.15 → 1.1.1

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.
@@ -150,8 +150,7 @@ var FormSearch = /*#__PURE__*/function (_React$Component) {
150
150
  search = _this$props4.search,
151
151
  pagination = _this$props4.pagination,
152
152
  ghost = _this$props4.ghost,
153
- manualRequest = _this$props4.manualRequest,
154
- changeValue = _this$props4.changeValue;
153
+ manualRequest = _this$props4.manualRequest;
155
154
  var pageInfo = pagination ? omitUndefined({
156
155
  current: pagination.current,
157
156
  pageSize: pagination.pageSize
package/es/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import React, { ReactElement } from 'react';
2
- import type { ProColumns } from '@ant-design/pro-components';
2
+ import type { ProColumns, ActionType } from '@ant-design/pro-components';
3
+ import type { InputProps } from 'antd';
3
4
  import './FormSearch/index.less';
4
5
  interface PlusColumns extends ProColumns {
5
6
  baseSearch?: boolean;
6
7
  }
7
8
  export type { PlusColumns };
8
- type settingsColumns = {
9
+ export type settingsColumns = {
9
10
  [key: string]: {
10
11
  hideInTable?: boolean;
11
12
  show?: boolean;
@@ -16,8 +17,43 @@ type settingsColumns = {
16
17
  sort?: number;
17
18
  };
18
19
  };
20
+ type OptionsFunctionType = (e: React.MouseEvent<HTMLSpanElement>, action?: ActionType) => void;
21
+ type OptionsType = OptionsFunctionType | boolean;
22
+ type SettingOptionType = {
23
+ draggable?: boolean;
24
+ checkable?: boolean;
25
+ showListItemOption?: boolean;
26
+ checkedReset?: boolean;
27
+ listsHeight?: number;
28
+ extra?: React.ReactNode;
29
+ children?: React.ReactNode;
30
+ settingIcon?: React.ReactNode;
31
+ };
32
+ interface SearchProps extends InputProps {
33
+ inputPrefixCls?: string;
34
+ onSearch?: (value: string, event?: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLInputElement>, info?: {
35
+ source?: 'clear' | 'input';
36
+ }) => void;
37
+ enterButton?: React.ReactNode;
38
+ loading?: boolean;
39
+ }
40
+ type OptionSearchProps = Omit<SearchProps, 'onSearch'> & {
41
+ /** 如果 onSearch 返回一个false,直接拦截请求 */
42
+ onSearch?: (keyword: string) => Promise<boolean | undefined> | boolean | undefined;
43
+ };
44
+ export type optionsConfig = {
45
+ density?: boolean;
46
+ fullScreen?: OptionsType;
47
+ reload?: OptionsType;
48
+ setting?: boolean | SettingOptionType;
49
+ search?: (OptionSearchProps & {
50
+ name?: string;
51
+ }) | boolean;
52
+ reloadIcon?: React.ReactNode;
53
+ densityIcon?: React.ReactNode;
54
+ };
19
55
  type PlusProps = {
20
- mode?: 'normal' | 'drawsearch';
56
+ action?: Array<'advancedFilter' | 'columnSetting' | 'viewInvisibleData'>;
21
57
  columns: PlusColumns[];
22
58
  request?: any;
23
59
  top?: number;
@@ -37,7 +73,7 @@ type PlusProps = {
37
73
  };
38
74
  actionRef: any;
39
75
  formRef?: any;
40
- options?: any;
76
+ options?: optionsConfig;
41
77
  [key: string | symbol]: any;
42
78
  };
43
79
  declare const PlusTable: React.ForwardRefExoticComponent<Omit<PlusProps, "ref"> & React.RefAttributes<unknown>>;
package/es/index.js CHANGED
@@ -9,7 +9,7 @@ import "antd/es/message/style";
9
9
  import _message from "antd/es/message";
10
10
  import "antd/es/form/style";
11
11
  import _Form from "antd/es/form";
12
- var _excluded = ["mode", "columns", "hasShowFull", "request", "pagination", "formRef", "actionRef", "defaultColumnsState", "options"];
12
+ var _excluded = ["mode", "columns", "hasShowFull", "request", "pagination", "formRef", "actionRef", "defaultColumnsState", "options", "action"];
13
13
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
14
14
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
15
15
  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; }
@@ -30,10 +30,10 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
30
30
  import React, { useEffect, useRef, useState, useImperativeHandle, forwardRef } from 'react';
31
31
  import { ProTable } from '@ant-design/pro-components';
32
32
  import FormRender from './FormSearch/index';
33
- import { BarsOutlined, ReloadOutlined } from '@ant-design/icons';
33
+ import { BarsOutlined } from '@ant-design/icons';
34
34
  import './FormSearch/index.less';
35
35
  var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
36
- var _otherProps$scroll;
36
+ var _otherProps$scroll, _otherProps$scroll2;
37
37
  var mode = props.mode,
38
38
  columns = props.columns,
39
39
  _props$hasShowFull = props.hasShowFull,
@@ -45,6 +45,7 @@ var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
45
45
  defaultColumnsState = props.defaultColumnsState,
46
46
  _props$options = props.options,
47
47
  options = _props$options === void 0 ? {} : _props$options,
48
+ action = props.action,
48
49
  otherProps = _objectWithoutProperties(props, _excluded);
49
50
  var searchRef = useRef(null);
50
51
  var _useState = useState(false),
@@ -124,8 +125,7 @@ var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
124
125
  }
125
126
  for (key in columnsStateMap) {
126
127
  columnsStateContainId[key] = _objectSpread(_objectSpread({}, columnsStateContainId[key]), {}, {
127
- hideInTable: !columnsStateMap[key].show ? 0 : 1,
128
- fixed: columnsStateMap[key].fixed
128
+ hideInTable: columnsStateMap[key].show ? 0 : 1
129
129
  });
130
130
  }
131
131
  _context2.next = 4;
@@ -238,33 +238,20 @@ var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
238
238
  value: columnsStateMap,
239
239
  onChange: handleOnChangeColumn //列状态的值发生改变之后触发
240
240
  };
241
- var _options = Object.prototype.toString.call(options) === '[object Object]' ? _objectSpread({
242
- density: false,
243
- reloadIcon: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ReloadOutlined, {
244
- onClick: function onClick() {
245
- return actionRef.current.reload();
246
- }
247
- })),
248
- setting: {
249
- checkedReset: false,
250
- extra: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
251
- onClick: function onClick() {
252
- return handleSave();
253
- }
254
- }, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement("a", {
255
- onClick: function onClick() {
256
- return handleReset();
257
- }
258
- }, "\u91CD\u7F6E")),
259
- showListItemOption: true
260
- }
261
- }, options) : options;
262
241
  return /*#__PURE__*/React.createElement("div", {
263
242
  className: !searchDrawer ? 'page_plustable__body' : 'page_plustable__body turn-left'
264
- },
265
- // 高级搜索模式
266
- mode === 'drawsearch' ? /*#__PURE__*/React.createElement(ProTable, _extends({}, otherProps, {
267
- search: {
243
+ }, /*#__PURE__*/React.createElement(ProTable, _extends({}, otherProps, {
244
+ // 公共配置 大家都有的
245
+ pagination: pagination,
246
+ actionRef: actionRef,
247
+ formRef: searchRef,
248
+ scroll: {
249
+ y: (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$scroll = otherProps.scroll) === null || _otherProps$scroll === void 0 ? void 0 : _otherProps$scroll.y) || document.documentElement.clientHeight - 355,
250
+ x: (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$scroll2 = otherProps.scroll) === null || _otherProps$scroll2 === void 0 ? void 0 : _otherProps$scroll2.x) || 1300
251
+ }
252
+ // 根据用户自定义的配置 如果配置了高级筛选就有这个配置
253
+ ,
254
+ search: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? {
268
255
  span: {
269
256
  xs: 12,
270
257
  sm: 12,
@@ -318,11 +305,10 @@ var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
318
305
  }))
319
306
  }, /*#__PURE__*/React.createElement(BarsOutlined, null), "\u9AD8\u7EA7\u7B5B\u9009") : null];
320
307
  }
321
- },
322
- columnsState: columnsState,
323
- pagination: pagination,
324
- actionRef: actionRef,
325
- formRef: searchRef,
308
+ } : props.search
309
+ // 根据用户自定义的配置 如果配置了列设置就有这个配置完全受控
310
+ ,
311
+ columnsState: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? columnsState : props.columnsState,
326
312
  request: ( /*#__PURE__*/function () {
327
313
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
328
314
  var _searchRef$current4, _drawFormRef$current4;
@@ -354,8 +340,10 @@ var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
354
340
  return function (_x2) {
355
341
  return _ref6.apply(this, arguments);
356
342
  };
357
- }()),
358
- columns: columns.map(function (item) {
343
+ }())
344
+ // 同步高筛配置 只有高筛 才有特殊的配置 (baseSearch才会生效)
345
+ ,
346
+ columns: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? columns.map(function (item) {
359
347
  // 只保留基本搜索栏的配置
360
348
  if (item.baseSearch) {
361
349
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -376,10 +364,10 @@ var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
376
364
  return _objectSpread(_objectSpread({}, item), {}, {
377
365
  search: false
378
366
  });
379
- }),
367
+ }) : columns,
380
368
  toolBarRender: function toolBarRender(searchConfig) {
381
369
  var _otherProps$toolBarRe;
382
- return [hasShowFull ? /*#__PURE__*/React.createElement(_Checkbox, {
370
+ return [(action === null || action === void 0 ? void 0 : action.includes('viewInvisibleData')) ? /*#__PURE__*/React.createElement(_Checkbox, {
383
371
  onChange: function onChange(e) {
384
372
  setShowFull(e.target.checked);
385
373
  setTimeout(function () {
@@ -388,21 +376,23 @@ var PlusTable = /*#__PURE__*/forwardRef(function (props, ref) {
388
376
  }
389
377
  }, "\u663E\u793A\u6240\u6709\u6570\u636E") : null, otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$toolBarRe = otherProps.toolBarRender) === null || _otherProps$toolBarRe === void 0 ? void 0 : _otherProps$toolBarRe.call(otherProps)];
390
378
  },
391
- scroll: {
392
- y: document.documentElement.clientHeight - 355,
393
- x: (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$scroll = otherProps.scroll) === null || _otherProps$scroll === void 0 ? void 0 : _otherProps$scroll.x) || 1300
394
- },
395
379
  onChange: onTableChange,
396
- options: _options
397
- })) : /*#__PURE__*/React.createElement(ProTable // 普通模式
398
- , _extends({
399
- columns: columns,
400
- request: request,
401
- actionRef: actionRef,
402
- formRef: formRef,
403
- columnsState: columnsState,
404
- options: _options
405
- }, otherProps)), /*#__PURE__*/React.createElement(_Drawer, {
380
+ options: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? _objectSpread({
381
+ setting: {
382
+ checkedReset: false,
383
+ extra: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("a", {
384
+ onClick: function onClick() {
385
+ return handleSave();
386
+ }
387
+ }, "\u4FDD\u5B58"), /*#__PURE__*/React.createElement("a", {
388
+ onClick: function onClick() {
389
+ return handleReset();
390
+ }
391
+ }, "\u91CD\u7F6E")),
392
+ showListItemOption: true
393
+ }
394
+ }, options) : options
395
+ })), /*#__PURE__*/React.createElement(_Drawer, {
406
396
  onClose: function onClose() {
407
397
  return setSearchDrawer(false);
408
398
  },
@@ -157,8 +157,7 @@ var FormSearch = /*#__PURE__*/function (_React$Component) {
157
157
  search = _this$props4.search,
158
158
  pagination = _this$props4.pagination,
159
159
  ghost = _this$props4.ghost,
160
- manualRequest = _this$props4.manualRequest,
161
- changeValue = _this$props4.changeValue;
160
+ manualRequest = _this$props4.manualRequest;
162
161
  var pageInfo = pagination ? (0, _proUtils.omitUndefined)({
163
162
  current: pagination.current,
164
163
  pageSize: pagination.pageSize
package/lib/index.d.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import React, { ReactElement } from 'react';
2
- import type { ProColumns } from '@ant-design/pro-components';
2
+ import type { ProColumns, ActionType } from '@ant-design/pro-components';
3
+ import type { InputProps } from 'antd';
3
4
  import './FormSearch/index.less';
4
5
  interface PlusColumns extends ProColumns {
5
6
  baseSearch?: boolean;
6
7
  }
7
8
  export type { PlusColumns };
8
- type settingsColumns = {
9
+ export type settingsColumns = {
9
10
  [key: string]: {
10
11
  hideInTable?: boolean;
11
12
  show?: boolean;
@@ -16,8 +17,43 @@ type settingsColumns = {
16
17
  sort?: number;
17
18
  };
18
19
  };
20
+ type OptionsFunctionType = (e: React.MouseEvent<HTMLSpanElement>, action?: ActionType) => void;
21
+ type OptionsType = OptionsFunctionType | boolean;
22
+ type SettingOptionType = {
23
+ draggable?: boolean;
24
+ checkable?: boolean;
25
+ showListItemOption?: boolean;
26
+ checkedReset?: boolean;
27
+ listsHeight?: number;
28
+ extra?: React.ReactNode;
29
+ children?: React.ReactNode;
30
+ settingIcon?: React.ReactNode;
31
+ };
32
+ interface SearchProps extends InputProps {
33
+ inputPrefixCls?: string;
34
+ onSearch?: (value: string, event?: React.ChangeEvent<HTMLInputElement> | React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLInputElement>, info?: {
35
+ source?: 'clear' | 'input';
36
+ }) => void;
37
+ enterButton?: React.ReactNode;
38
+ loading?: boolean;
39
+ }
40
+ type OptionSearchProps = Omit<SearchProps, 'onSearch'> & {
41
+ /** 如果 onSearch 返回一个false,直接拦截请求 */
42
+ onSearch?: (keyword: string) => Promise<boolean | undefined> | boolean | undefined;
43
+ };
44
+ export type optionsConfig = {
45
+ density?: boolean;
46
+ fullScreen?: OptionsType;
47
+ reload?: OptionsType;
48
+ setting?: boolean | SettingOptionType;
49
+ search?: (OptionSearchProps & {
50
+ name?: string;
51
+ }) | boolean;
52
+ reloadIcon?: React.ReactNode;
53
+ densityIcon?: React.ReactNode;
54
+ };
19
55
  type PlusProps = {
20
- mode?: 'normal' | 'drawsearch';
56
+ action?: Array<'advancedFilter' | 'columnSetting' | 'viewInvisibleData'>;
21
57
  columns: PlusColumns[];
22
58
  request?: any;
23
59
  top?: number;
@@ -37,7 +73,7 @@ type PlusProps = {
37
73
  };
38
74
  actionRef: any;
39
75
  formRef?: any;
40
- options?: any;
76
+ options?: optionsConfig;
41
77
  [key: string | symbol]: any;
42
78
  };
43
79
  declare const PlusTable: React.ForwardRefExoticComponent<Omit<PlusProps, "ref"> & React.RefAttributes<unknown>>;
package/lib/index.js CHANGED
@@ -11,7 +11,7 @@ var _antd = require("antd");
11
11
  var _index = _interopRequireDefault(require("./FormSearch/index"));
12
12
  var _icons = require("@ant-design/icons");
13
13
  require("./FormSearch/index.less");
14
- var _excluded = ["mode", "columns", "hasShowFull", "request", "pagination", "formRef", "actionRef", "defaultColumnsState", "options"];
14
+ var _excluded = ["mode", "columns", "hasShowFull", "request", "pagination", "formRef", "actionRef", "defaultColumnsState", "options", "action"];
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
16
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
17
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -33,7 +33,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
33
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
34
34
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
35
35
  var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
36
- var _otherProps$scroll;
36
+ var _otherProps$scroll, _otherProps$scroll2;
37
37
  var mode = props.mode,
38
38
  columns = props.columns,
39
39
  _props$hasShowFull = props.hasShowFull,
@@ -45,6 +45,7 @@ var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
45
45
  defaultColumnsState = props.defaultColumnsState,
46
46
  _props$options = props.options,
47
47
  options = _props$options === void 0 ? {} : _props$options,
48
+ action = props.action,
48
49
  otherProps = _objectWithoutProperties(props, _excluded);
49
50
  var searchRef = (0, _react.useRef)(null);
50
51
  var _useState = (0, _react.useState)(false),
@@ -124,8 +125,7 @@ var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
124
125
  }
125
126
  for (key in columnsStateMap) {
126
127
  columnsStateContainId[key] = _objectSpread(_objectSpread({}, columnsStateContainId[key]), {}, {
127
- hideInTable: !columnsStateMap[key].show ? 0 : 1,
128
- fixed: columnsStateMap[key].fixed
128
+ hideInTable: columnsStateMap[key].show ? 0 : 1
129
129
  });
130
130
  }
131
131
  _context2.next = 4;
@@ -238,33 +238,20 @@ var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
238
238
  value: columnsStateMap,
239
239
  onChange: handleOnChangeColumn //列状态的值发生改变之后触发
240
240
  };
241
- var _options = Object.prototype.toString.call(options) === '[object Object]' ? _objectSpread({
242
- density: false,
243
- reloadIcon: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_icons.ReloadOutlined, {
244
- onClick: function onClick() {
245
- return actionRef.current.reload();
246
- }
247
- })),
248
- setting: {
249
- checkedReset: false,
250
- extra: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("a", {
251
- onClick: function onClick() {
252
- return handleSave();
253
- }
254
- }, "\u4FDD\u5B58"), /*#__PURE__*/_react.default.createElement("a", {
255
- onClick: function onClick() {
256
- return handleReset();
257
- }
258
- }, "\u91CD\u7F6E")),
259
- showListItemOption: true
260
- }
261
- }, options) : options;
262
241
  return /*#__PURE__*/_react.default.createElement("div", {
263
242
  className: !searchDrawer ? 'page_plustable__body' : 'page_plustable__body turn-left'
264
- },
265
- // 高级搜索模式
266
- mode === 'drawsearch' ? /*#__PURE__*/_react.default.createElement(_proComponents.ProTable, _extends({}, otherProps, {
267
- search: {
243
+ }, /*#__PURE__*/_react.default.createElement(_proComponents.ProTable, _extends({}, otherProps, {
244
+ // 公共配置 大家都有的
245
+ pagination: pagination,
246
+ actionRef: actionRef,
247
+ formRef: searchRef,
248
+ scroll: {
249
+ y: (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$scroll = otherProps.scroll) === null || _otherProps$scroll === void 0 ? void 0 : _otherProps$scroll.y) || document.documentElement.clientHeight - 355,
250
+ x: (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$scroll2 = otherProps.scroll) === null || _otherProps$scroll2 === void 0 ? void 0 : _otherProps$scroll2.x) || 1300
251
+ }
252
+ // 根据用户自定义的配置 如果配置了高级筛选就有这个配置
253
+ ,
254
+ search: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? {
268
255
  span: {
269
256
  xs: 12,
270
257
  sm: 12,
@@ -318,11 +305,10 @@ var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
318
305
  }))
319
306
  }, /*#__PURE__*/_react.default.createElement(_icons.BarsOutlined, null), "\u9AD8\u7EA7\u7B5B\u9009") : null];
320
307
  }
321
- },
322
- columnsState: columnsState,
323
- pagination: pagination,
324
- actionRef: actionRef,
325
- formRef: searchRef,
308
+ } : props.search
309
+ // 根据用户自定义的配置 如果配置了列设置就有这个配置完全受控
310
+ ,
311
+ columnsState: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? columnsState : props.columnsState,
326
312
  request: ( /*#__PURE__*/function () {
327
313
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
328
314
  var _searchRef$current4, _drawFormRef$current4;
@@ -354,8 +340,10 @@ var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
354
340
  return function (_x2) {
355
341
  return _ref6.apply(this, arguments);
356
342
  };
357
- }()),
358
- columns: columns.map(function (item) {
343
+ }())
344
+ // 同步高筛配置 只有高筛 才有特殊的配置 (baseSearch才会生效)
345
+ ,
346
+ columns: (action === null || action === void 0 ? void 0 : action.includes('advancedFilter')) ? columns.map(function (item) {
359
347
  // 只保留基本搜索栏的配置
360
348
  if (item.baseSearch) {
361
349
  return _objectSpread(_objectSpread({}, item), {}, {
@@ -376,10 +364,10 @@ var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
376
364
  return _objectSpread(_objectSpread({}, item), {}, {
377
365
  search: false
378
366
  });
379
- }),
367
+ }) : columns,
380
368
  toolBarRender: function toolBarRender(searchConfig) {
381
369
  var _otherProps$toolBarRe;
382
- return [hasShowFull ? /*#__PURE__*/_react.default.createElement(_antd.Checkbox, {
370
+ return [(action === null || action === void 0 ? void 0 : action.includes('viewInvisibleData')) ? /*#__PURE__*/_react.default.createElement(_antd.Checkbox, {
383
371
  onChange: function onChange(e) {
384
372
  setShowFull(e.target.checked);
385
373
  setTimeout(function () {
@@ -388,21 +376,23 @@ var PlusTable = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
388
376
  }
389
377
  }, "\u663E\u793A\u6240\u6709\u6570\u636E") : null, otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$toolBarRe = otherProps.toolBarRender) === null || _otherProps$toolBarRe === void 0 ? void 0 : _otherProps$toolBarRe.call(otherProps)];
390
378
  },
391
- scroll: {
392
- y: document.documentElement.clientHeight - 355,
393
- x: (otherProps === null || otherProps === void 0 ? void 0 : (_otherProps$scroll = otherProps.scroll) === null || _otherProps$scroll === void 0 ? void 0 : _otherProps$scroll.x) || 1300
394
- },
395
379
  onChange: onTableChange,
396
- options: _options
397
- })) : /*#__PURE__*/_react.default.createElement(_proComponents.ProTable // 普通模式
398
- , _extends({
399
- columns: columns,
400
- request: request,
401
- actionRef: actionRef,
402
- formRef: formRef,
403
- columnsState: columnsState,
404
- options: _options
405
- }, otherProps)), /*#__PURE__*/_react.default.createElement(_antd.Drawer, {
380
+ options: (action === null || action === void 0 ? void 0 : action.includes('columnSetting')) ? _objectSpread({
381
+ setting: {
382
+ checkedReset: false,
383
+ extra: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("a", {
384
+ onClick: function onClick() {
385
+ return handleSave();
386
+ }
387
+ }, "\u4FDD\u5B58"), /*#__PURE__*/_react.default.createElement("a", {
388
+ onClick: function onClick() {
389
+ return handleReset();
390
+ }
391
+ }, "\u91CD\u7F6E")),
392
+ showListItemOption: true
393
+ }
394
+ }, options) : options
395
+ })), /*#__PURE__*/_react.default.createElement(_antd.Drawer, {
406
396
  onClose: function onClose() {
407
397
  return setSearchDrawer(false);
408
398
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-ui/plus-table",
3
- "version": "1.0.15",
3
+ "version": "1.1.1",
4
4
  "description": "@fle-ui/plus-table",
5
5
  "keywords": [
6
6
  "fle-ui",
@@ -46,5 +46,5 @@
46
46
  "@ant-design/pro-components": "^2.7.0",
47
47
  "dayjs": "^1.11.10"
48
48
  },
49
- "gitHead": "ceed5aee479a4c01f421ea188635efa2dcbccb29"
49
+ "gitHead": "ff85e733d0486a973d61452855557f5916f3340f"
50
50
  }