th-design 1.0.0 → 1.0.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.
- package/README.md +7 -20
- package/dist/esm/components/ThSelect/index.d.ts +1 -1
- package/dist/esm/components/ThSelect/index.js +20 -16
- package/dist/esm/components/ThSelect/index.less +5 -3
- package/dist/esm/components/ThSelect/service.js +55 -26
- package/dist/esm/components/ThSelect/typing.d.ts +3 -3
- package/dist/esm/components/ThTable/index.d.ts +1 -2
- package/package.json +13 -14
package/README.md
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
|
-
# th-
|
|
1
|
+
# th-design
|
|
2
2
|
|
|
3
3
|
## Getting Started
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
安装依赖
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
$ yarn
|
|
8
|
+
$ npm install th-design 或者 yarn add th-design 或者 pnpm install th-design
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
按需导入组件
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
|
|
14
|
+
import { ThSelect } from 'th-design';
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
使用组件
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
打包后的文档存放在217 /home/th-react-ui-docs/ 目录下
|
|
23
|
-
|
|
24
|
-
运行测试环境,
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
$ yarn test
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
打包组件库 `father`,
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
$ yarn build
|
|
20
|
+
<ThSelect />
|
|
34
21
|
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './index.less';
|
|
3
3
|
import type { ThSelectProps } from './typing';
|
|
4
|
-
declare const _default: import("react").MemoExoticComponent<(props: ThSelectProps) => JSX.Element>;
|
|
4
|
+
declare const _default: import("react").MemoExoticComponent<(props: ThSelectProps) => import("react/jsx-runtime").JSX.Element>;
|
|
5
5
|
export default _default;
|
|
@@ -24,7 +24,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
24
24
|
* @Author: luohq luohq@2345.com
|
|
25
25
|
* @Date: 2025-10-14 14:02:00
|
|
26
26
|
* @LastEditors: luohq luohq@2345.com
|
|
27
|
-
* @LastEditTime: 2026-01-
|
|
27
|
+
* @LastEditTime: 2026-01-09 14:15:46
|
|
28
28
|
* @FilePath: /tellhowComponent/src/components/ThSelect/index.tsx
|
|
29
29
|
* @Description: 选择器组件
|
|
30
30
|
*/
|
|
@@ -32,8 +32,8 @@ import CloseIcon from "../../assets/images/close-icon.png";
|
|
|
32
32
|
import DeleteIcon from "../../assets/images/delete-icon.png";
|
|
33
33
|
import SearchSuffix from "../../assets/images/search-suffix.png";
|
|
34
34
|
import { CloseCircleFilled, DownOutlined } from '@ant-design/icons';
|
|
35
|
-
import { useUpdateEffect } from 'ahooks';
|
|
36
35
|
import { Button, Input, Pagination, Table } from 'antd';
|
|
36
|
+
import classNames from 'classnames';
|
|
37
37
|
import { memo, useEffect, useRef, useState } from 'react';
|
|
38
38
|
import { createPortal } from 'react-dom';
|
|
39
39
|
import { useLocation } from 'react-router-dom';
|
|
@@ -209,7 +209,7 @@ var ThSelect = function ThSelect(props) {
|
|
|
209
209
|
_useState36 = _slicedToArray(_useState35, 2),
|
|
210
210
|
isSelectValueOverflow = _useState36[0],
|
|
211
211
|
setIsSelectValueOverflow = _useState36[1]; // 选择器容器文本是否超出
|
|
212
|
-
|
|
212
|
+
var isFirstRender = useRef(true);
|
|
213
213
|
useEffect(function () {
|
|
214
214
|
if (typeof value === 'string') {
|
|
215
215
|
if (name && value) {
|
|
@@ -419,7 +419,11 @@ var ThSelect = function ThSelect(props) {
|
|
|
419
419
|
}, [value, name, labelCache]);
|
|
420
420
|
|
|
421
421
|
// 处理动画状态
|
|
422
|
-
|
|
422
|
+
useEffect(function () {
|
|
423
|
+
if (isFirstRender.current) {
|
|
424
|
+
isFirstRender.current = false;
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
423
427
|
if (open) {
|
|
424
428
|
setAnimationState('entering');
|
|
425
429
|
var timer = setTimeout(function () {
|
|
@@ -919,7 +923,7 @@ var ThSelect = function ThSelect(props) {
|
|
|
919
923
|
onClick: function onClick(e) {
|
|
920
924
|
return e.stopPropagation();
|
|
921
925
|
},
|
|
922
|
-
className:
|
|
926
|
+
className: classNames('th-selectDropdown', "th-".concat(dropdownPlacement.vertical), "th-".concat(dropdownPlacement.horizontal), "th-".concat(animationState)),
|
|
923
927
|
style: {
|
|
924
928
|
width: "".concat(width, "px"),
|
|
925
929
|
height: "".concat(height, "px"),
|
|
@@ -927,12 +931,12 @@ var ThSelect = function ThSelect(props) {
|
|
|
927
931
|
// 改为 fixed 定位
|
|
928
932
|
top: "".concat(dropdownPosition.top, "px"),
|
|
929
933
|
left: "".concat(dropdownPosition.left, "px"),
|
|
930
|
-
zIndex:
|
|
934
|
+
zIndex: 9999
|
|
931
935
|
},
|
|
932
936
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
933
937
|
className: "th-dropdownContainer",
|
|
934
938
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
935
|
-
className:
|
|
939
|
+
className: classNames('th-dropdownContent', mode === 'single' || !showRightPanel ? 'th-singleDropdownContent' : ''),
|
|
936
940
|
children: [showSearch && /*#__PURE__*/_jsxs("div", {
|
|
937
941
|
className: "th-searchContainerWrapper",
|
|
938
942
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -957,11 +961,11 @@ var ThSelect = function ThSelect(props) {
|
|
|
957
961
|
children: searchBar
|
|
958
962
|
})]
|
|
959
963
|
}), /*#__PURE__*/_jsxs("div", {
|
|
960
|
-
className:
|
|
964
|
+
className: classNames('th-optionList', !showSearch ? 'th-noSearchOptionList' : ''),
|
|
961
965
|
children: [/*#__PURE__*/_jsx("div", {
|
|
962
|
-
className:
|
|
966
|
+
className: classNames('th-tableContainer', pagination === false ? 'th-noPaginationTableContainer' : ''),
|
|
963
967
|
style: {
|
|
964
|
-
height: "calc(100% - ".concat(
|
|
968
|
+
height: "calc(100% - ".concat(_typeof(paginationData) === 'object' && ((paginationData === null || paginationData === void 0 ? void 0 : paginationData.total) || 0) > ((paginationData === null || paginationData === void 0 ? void 0 : paginationData.pageSize) || 10) ? '30px' : '0px', " - ").concat(searchBarHeight, "px)")
|
|
965
969
|
},
|
|
966
970
|
children: /*#__PURE__*/_jsx(Table, _objectSpread(_objectSpread({
|
|
967
971
|
columns: columns === null || columns === void 0 ? void 0 : columns.map(function (col) {
|
|
@@ -1004,7 +1008,7 @@ var ThSelect = function ThSelect(props) {
|
|
|
1004
1008
|
})]
|
|
1005
1009
|
})]
|
|
1006
1010
|
}), /*#__PURE__*/_jsxs("div", {
|
|
1007
|
-
className:
|
|
1011
|
+
className: classNames('th-selectedWrapper', pagination === false ? 'th-withoutPagination' : '', mode === 'single' || !showRightPanel ? 'th-singleSelectedWrapper' : ''),
|
|
1008
1012
|
children: [dataList.length > 0 && /*#__PURE__*/_jsxs("div", {
|
|
1009
1013
|
className: "th-selectedHeader",
|
|
1010
1014
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
@@ -1074,16 +1078,16 @@ var ThSelect = function ThSelect(props) {
|
|
|
1074
1078
|
}, 800);
|
|
1075
1079
|
}, [selectValueRef.current, selectedLabels]);
|
|
1076
1080
|
return /*#__PURE__*/_jsx("div", {
|
|
1077
|
-
className:
|
|
1081
|
+
className: classNames('th-customSelect', className || ''),
|
|
1078
1082
|
children: /*#__PURE__*/_jsxs("div", {
|
|
1079
|
-
className:
|
|
1083
|
+
className: classNames('th-selectInputContainer', direction === 'vertical' ? 'th-vertical' : ''),
|
|
1080
1084
|
children: [label && /*#__PURE__*/_jsx("div", {
|
|
1081
1085
|
className: "th-selectLabel",
|
|
1082
1086
|
style: labelStyle,
|
|
1083
1087
|
children: label
|
|
1084
1088
|
}), /*#__PURE__*/_jsxs("div", {
|
|
1085
1089
|
ref: selectRef,
|
|
1086
|
-
className:
|
|
1090
|
+
className: classNames('custom-select-input th-selectInput', open ? 'th-focused' : '', disabled ? 'th-disabled' : ''),
|
|
1087
1091
|
onClick: handleSelectorClick,
|
|
1088
1092
|
onDoubleClick: needInput ? handleSelectorDoubleClick : function () {},
|
|
1089
1093
|
onMouseEnter: function onMouseEnter() {
|
|
@@ -1097,7 +1101,7 @@ var ThSelect = function ThSelect(props) {
|
|
|
1097
1101
|
children: [needInput && isEditing && mode === 'single' ? /*#__PURE__*/_jsx(_Fragment, {}) : /*#__PURE__*/_jsx("div", {
|
|
1098
1102
|
ref: selectValueRef,
|
|
1099
1103
|
title: isSelectValueOverflow ? selectedLabels || selectPlaceholder : '',
|
|
1100
|
-
className:
|
|
1104
|
+
className: classNames('th-selectValue', !selectedLabels ? 'th-placeholder' : '', needInput && isEditing ? 'th-valueEditing' : ''),
|
|
1101
1105
|
children: selectedLabels || selectPlaceholder
|
|
1102
1106
|
}), needInput && isEditing && /*#__PURE__*/_jsx(Input, {
|
|
1103
1107
|
ref: inputEditRef,
|
|
@@ -1116,7 +1120,7 @@ var ThSelect = function ThSelect(props) {
|
|
|
1116
1120
|
className: "th-clearIcon",
|
|
1117
1121
|
onClick: handleClear
|
|
1118
1122
|
}) : /*#__PURE__*/_jsx(DownOutlined, {
|
|
1119
|
-
className:
|
|
1123
|
+
className: classNames('th-selectArrow', open ? 'th-open' : '')
|
|
1120
1124
|
})]
|
|
1121
1125
|
}), renderSelectPopup()]
|
|
1122
1126
|
})
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.ant-form-item
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// :global(.ant-form-item:has(.th-customSelect)) {
|
|
10
|
+
// :global(.ant-form-item-label > label) {
|
|
11
|
+
// height: 46px !important;
|
|
12
|
+
// }
|
|
13
|
+
// }
|
|
12
14
|
|
|
13
15
|
.th-customSelect {
|
|
14
16
|
position: relative;
|
|
@@ -1,16 +1,45 @@
|
|
|
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
2
|
var _excluded = ["queryParams"];
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
3
5
|
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 new 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 new 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 new 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; }
|
|
4
6
|
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; }
|
|
5
7
|
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; }
|
|
6
8
|
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; }
|
|
7
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
10
|
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); }
|
|
9
|
-
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; }
|
|
10
|
-
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; }
|
|
11
11
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
12
12
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
import
|
|
13
|
+
import axios from 'axios';
|
|
14
|
+
var request = /*#__PURE__*/function () {
|
|
15
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url, config) {
|
|
16
|
+
var response;
|
|
17
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
18
|
+
while (1) switch (_context.prev = _context.next) {
|
|
19
|
+
case 0:
|
|
20
|
+
_context.prev = 0;
|
|
21
|
+
_context.next = 3;
|
|
22
|
+
return axios(_objectSpread({
|
|
23
|
+
url: url
|
|
24
|
+
}, config));
|
|
25
|
+
case 3:
|
|
26
|
+
response = _context.sent;
|
|
27
|
+
return _context.abrupt("return", response.data);
|
|
28
|
+
case 7:
|
|
29
|
+
_context.prev = 7;
|
|
30
|
+
_context.t0 = _context["catch"](0);
|
|
31
|
+
console.error('Request Error:', _context.t0);
|
|
32
|
+
throw _context.t0;
|
|
33
|
+
case 11:
|
|
34
|
+
case "end":
|
|
35
|
+
return _context.stop();
|
|
36
|
+
}
|
|
37
|
+
}, _callee, null, [[0, 7]]);
|
|
38
|
+
}));
|
|
39
|
+
return function request(_x, _x2) {
|
|
40
|
+
return _ref.apply(this, arguments);
|
|
41
|
+
};
|
|
42
|
+
}();
|
|
14
43
|
export var transformParams = function transformParams(params, transformSearchKey, searchOpt) {
|
|
15
44
|
if (!params) {
|
|
16
45
|
return;
|
|
@@ -41,30 +70,30 @@ export var transformParams = function transformParams(params, transformSearchKey
|
|
|
41
70
|
});
|
|
42
71
|
return params;
|
|
43
72
|
};
|
|
44
|
-
export function getList(
|
|
73
|
+
export function getList(_x3, _x4) {
|
|
45
74
|
return _getList.apply(this, arguments);
|
|
46
75
|
}
|
|
47
76
|
function _getList() {
|
|
48
|
-
_getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
49
|
-
var
|
|
50
|
-
return _regeneratorRuntime().wrap(function
|
|
51
|
-
while (1) switch (
|
|
77
|
+
_getList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(requestProps, query) {
|
|
78
|
+
var _ref2, url, _ref2$method, method, transformSearchKey, searchOpt, _ref3, queryParams, searchParams, clonedQueryParams, transformedQueryParams, params;
|
|
79
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
80
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
52
81
|
case 0:
|
|
53
|
-
|
|
82
|
+
_ref2 = requestProps || {}, url = _ref2.url, _ref2$method = _ref2.method, method = _ref2$method === void 0 ? 'POST' : _ref2$method, transformSearchKey = _ref2.transformSearchKey, searchOpt = _ref2.searchOpt;
|
|
54
83
|
if (url) {
|
|
55
|
-
|
|
84
|
+
_context2.next = 3;
|
|
56
85
|
break;
|
|
57
86
|
}
|
|
58
87
|
throw new Error('url is required');
|
|
59
88
|
case 3:
|
|
60
|
-
|
|
89
|
+
_ref3 = query || {}, queryParams = _ref3.queryParams, searchParams = _objectWithoutProperties(_ref3, _excluded); // 避免修改原始 queryParams
|
|
61
90
|
clonedQueryParams = queryParams ? JSON.parse(JSON.stringify(queryParams)) : {};
|
|
62
91
|
transformedQueryParams = transformParams(clonedQueryParams, transformSearchKey, searchOpt) || {};
|
|
63
92
|
if (!(method.toUpperCase() === 'POST')) {
|
|
64
|
-
|
|
93
|
+
_context2.next = 12;
|
|
65
94
|
break;
|
|
66
95
|
}
|
|
67
|
-
|
|
96
|
+
_context2.next = 9;
|
|
68
97
|
return request(url, {
|
|
69
98
|
method: method,
|
|
70
99
|
data: _objectSpread(_objectSpread({}, searchParams), {}, {
|
|
@@ -72,7 +101,7 @@ function _getList() {
|
|
|
72
101
|
})
|
|
73
102
|
});
|
|
74
103
|
case 9:
|
|
75
|
-
return
|
|
104
|
+
return _context2.abrupt("return", _context2.sent);
|
|
76
105
|
case 12:
|
|
77
106
|
params = {};
|
|
78
107
|
if (query) {
|
|
@@ -82,41 +111,41 @@ function _getList() {
|
|
|
82
111
|
}
|
|
83
112
|
});
|
|
84
113
|
}
|
|
85
|
-
|
|
114
|
+
_context2.next = 16;
|
|
86
115
|
return request(url, {
|
|
87
116
|
method: method,
|
|
88
117
|
params: params
|
|
89
118
|
});
|
|
90
119
|
case 16:
|
|
91
|
-
return
|
|
120
|
+
return _context2.abrupt("return", _context2.sent);
|
|
92
121
|
case 17:
|
|
93
122
|
case "end":
|
|
94
|
-
return
|
|
123
|
+
return _context2.stop();
|
|
95
124
|
}
|
|
96
|
-
},
|
|
125
|
+
}, _callee2);
|
|
97
126
|
}));
|
|
98
127
|
return _getList.apply(this, arguments);
|
|
99
128
|
}
|
|
100
|
-
export function getTransDict(
|
|
129
|
+
export function getTransDict(_x5) {
|
|
101
130
|
return _getTransDict.apply(this, arguments);
|
|
102
131
|
}
|
|
103
132
|
function _getTransDict() {
|
|
104
|
-
_getTransDict = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
105
|
-
return _regeneratorRuntime().wrap(function
|
|
106
|
-
while (1) switch (
|
|
133
|
+
_getTransDict = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
|
|
134
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
135
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
107
136
|
case 0:
|
|
108
|
-
|
|
137
|
+
_context3.next = 2;
|
|
109
138
|
return request('/wffzpt-service/dict/transDict', {
|
|
110
139
|
method: 'POST',
|
|
111
140
|
data: data
|
|
112
141
|
});
|
|
113
142
|
case 2:
|
|
114
|
-
return
|
|
143
|
+
return _context3.abrupt("return", _context3.sent);
|
|
115
144
|
case 3:
|
|
116
145
|
case "end":
|
|
117
|
-
return
|
|
146
|
+
return _context3.stop();
|
|
118
147
|
}
|
|
119
|
-
},
|
|
148
|
+
}, _callee3);
|
|
120
149
|
}));
|
|
121
150
|
return _getTransDict.apply(this, arguments);
|
|
122
151
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import type
|
|
1
|
+
import type { TableProps } from 'antd/lib';
|
|
2
|
+
import type React from 'react';
|
|
3
3
|
export interface ThSelectProps {
|
|
4
4
|
/**
|
|
5
5
|
* 选择模式
|
|
@@ -90,7 +90,7 @@ export interface ThSelectProps {
|
|
|
90
90
|
/**
|
|
91
91
|
* 自定义表格属性
|
|
92
92
|
*/
|
|
93
|
-
tableProps: TableProps
|
|
93
|
+
tableProps: TableProps<any>;
|
|
94
94
|
/**
|
|
95
95
|
* 自定义请求参数
|
|
96
96
|
*/
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import './index.less';
|
|
3
2
|
import type { ThTableProps } from './typing';
|
|
4
3
|
/**
|
|
5
4
|
* @description table组件
|
|
6
5
|
*/
|
|
7
|
-
export declare const ThTable: <T extends Record<string, any>, U extends Record<string, any>>(props: ThTableProps<T, U>) => JSX.Element;
|
|
6
|
+
export declare const ThTable: <T extends Record<string, any>, U extends Record<string, any>>(props: ThTableProps<T, U>) => import("react/jsx-runtime").JSX.Element;
|
|
8
7
|
export default ThTable;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "th-design",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"description": "tellhow component library",
|
|
6
6
|
"author": "luohq",
|
|
7
7
|
"keywords": [
|
|
@@ -39,28 +39,27 @@
|
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"react": "^18.2.0",
|
|
46
|
-
"react-dom": "^18.2.0"
|
|
42
|
+
"antd": "^4.0.0",
|
|
43
|
+
"react": "^17.0.0",
|
|
44
|
+
"react-dom": "^17.0.0"
|
|
47
45
|
},
|
|
48
46
|
"peerDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"react
|
|
51
|
-
"
|
|
52
|
-
},
|
|
47
|
+
"antd": ">=4.0.0",
|
|
48
|
+
"react": ">=17.0.0",
|
|
49
|
+
"react-dom": ">=17.0.0"
|
|
50
|
+
},
|
|
53
51
|
"devDependencies": {
|
|
54
52
|
"@ant-design/icons": "^4.7.0",
|
|
55
|
-
"@ant-design/pro-table": "^
|
|
53
|
+
"@ant-design/pro-table": "^2.72.0",
|
|
56
54
|
"@testing-library/jest-dom": "^5.15.1",
|
|
57
|
-
"@testing-library/react": "^
|
|
55
|
+
"@testing-library/react": "^12.1.5",
|
|
58
56
|
"@types/jest": "^27.0.3",
|
|
59
|
-
"@types/react": "^
|
|
60
|
-
"@types/react-dom": "^
|
|
57
|
+
"@types/react": "^17.0.0",
|
|
58
|
+
"@types/react-dom": "^17.0.0",
|
|
61
59
|
"@types/react-resizable": "^3.0.3",
|
|
62
60
|
"@umijs/fabric": "^2.8.1",
|
|
63
61
|
"@umijs/test": "^3.0.5",
|
|
62
|
+
"axios": "^1.13.2",
|
|
64
63
|
"babel-plugin-import": "^1.13.5",
|
|
65
64
|
"classnames": "^2.3.2",
|
|
66
65
|
"dumi": "^2.4.21",
|