@hsu-react/ui 0.0.2 → 0.0.4
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 +2 -0
- package/es/components/ChainGraph/_components/SearchSelect/index.js +13 -10
- package/es/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/es/components/DatePicker/index.module.less +1 -0
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -2
- package/es/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/es/components/Input/Range/index.module.less +4 -4
- package/es/components/Input/index.module.less +3 -0
- package/es/components/Panel/ListPanel/index.d.ts +2 -0
- package/es/components/Panel/ListPanel/index.js +3 -2
- package/es/components/Select/_utils/getElementPosition.d.ts +6 -2
- package/es/components/Select/_utils/getElementPosition.js +8 -6
- package/es/components/Select/index.module.less +3 -0
- package/es/components/Slider/index.module.less +1 -0
- package/es/components/Switch/index.js +12 -8
- package/es/components/Switch/index.module.less +7 -0
- package/lib/components/ChainGraph/_components/SearchSelect/index.js +10 -7
- package/lib/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/lib/components/DatePicker/index.module.less +1 -0
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -1
- package/lib/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/lib/components/Input/Range/index.module.less +4 -4
- package/lib/components/Input/index.module.less +3 -0
- package/lib/components/Panel/ListPanel/index.d.ts +2 -0
- package/lib/components/Panel/ListPanel/index.js +4 -1
- package/lib/components/Select/_utils/getElementPosition.d.ts +6 -2
- package/lib/components/Select/_utils/getElementPosition.js +8 -6
- package/lib/components/Select/index.module.less +3 -0
- package/lib/components/Slider/index.module.less +1 -0
- package/lib/components/Switch/index.js +8 -4
- package/lib/components/Switch/index.module.less +7 -0
- package/package.json +1 -1
- package/src/components/Button/index.md +18 -1
- package/src/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
- package/src/components/ChainGraph/_components/SearchSelect/index.tsx +18 -16
- package/src/components/ChainGraph/index.md +2 -1
- package/src/components/Chart/index.md +290 -17
- package/src/components/Chat/index.md +44 -1
- package/src/components/Checkbox/index.md +33 -1
- package/src/components/CodeMirror/index.md +1 -1
- package/src/components/Copy/index.md +1 -1
- package/src/components/DatePicker/index.md +41 -2
- package/src/components/DatePicker/index.module.less +1 -0
- package/src/components/Descriptions/index.md +1 -1
- package/src/components/Editor/index.md +1 -1
- package/src/components/FileCol/index.md +1 -1
- package/src/components/FilePreview/index.md +1 -1
- package/src/components/FlexFill/index.md +1 -1
- package/src/components/Form/index.md +88 -1
- package/src/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
- package/src/components/FormItem/FormInput/FormPasswordStrength/index.tsx +2 -2
- package/src/components/FormItem/index.md +147 -92
- package/src/components/Icon/index.md +3 -1
- package/src/components/Input/Range/index.module.less +4 -4
- package/src/components/Input/index.md +115 -2
- package/src/components/Input/index.module.less +3 -0
- package/src/components/Markdown/index.md +3 -1
- package/src/components/Modal/index.md +1 -1
- package/src/components/Operate/index.md +1 -1
- package/src/components/Panel/ListPanel/index.tsx +6 -0
- package/src/components/Panel/index.md +68 -21
- package/src/components/Search/index.md +184 -9
- package/src/components/SecondConf/index.md +1 -1
- package/src/components/Select/_utils/getElementPosition.ts +8 -6
- package/src/components/Select/index.md +1 -1
- package/src/components/Select/index.module.less +3 -0
- package/src/components/Slider/index.md +1 -2
- package/src/components/Slider/index.module.less +1 -0
- package/src/components/Spreadsheet/index.md +1 -1
- package/src/components/Switch/index.md +1 -1
- package/src/components/Switch/index.module.less +7 -0
- package/src/components/Switch/index.tsx +14 -11
- package/src/components/TabBar/index.md +28 -11
- package/src/components/Table/index.md +1 -1
- package/src/components/Tags/index.md +1 -1
- package/src/components/TextEllipsis/index.md +1 -1
- package/src/components/Tree/index.md +1 -1
- package/src/components/Upload/index.md +1 -1
package/README.md
CHANGED
|
@@ -4,15 +4,18 @@ import styles from "./index.module.less";
|
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
5
|
export var SearchSelect = function SearchSelect(_ref) {
|
|
6
6
|
var onChange = _ref.onChange;
|
|
7
|
-
return /*#__PURE__*/_jsx(
|
|
8
|
-
className: styles.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
return /*#__PURE__*/_jsx("div", {
|
|
8
|
+
className: styles.wrapper,
|
|
9
|
+
children: /*#__PURE__*/_jsx(Select, {
|
|
10
|
+
className: styles.select,
|
|
11
|
+
showSearch: true,
|
|
12
|
+
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u8FDB\u884C\u641C\u7D22",
|
|
13
|
+
optionFilterProp: "children",
|
|
14
|
+
filterOption: function filterOption(input, option) {
|
|
15
|
+
var _option$label;
|
|
16
|
+
return !!(option !== null && option !== void 0 && option.label && option !== null && option !== void 0 && (_option$label = option.label) !== null && _option$label !== void 0 && _option$label.toString().toLowerCase().includes(input.toLowerCase()));
|
|
17
|
+
},
|
|
18
|
+
onChange: onChange
|
|
19
|
+
})
|
|
17
20
|
});
|
|
18
21
|
};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// 定位容器给定 32px 固定高度,Select 通过 height:100% 填满它,
|
|
2
|
+
// 避免 Select 根的 height:100% 直接相对图谱(绝对定位祖先)解析成整图高度而被拉伸。
|
|
3
|
+
.wrapper {
|
|
2
4
|
position: absolute;
|
|
3
5
|
top: 20px;
|
|
4
6
|
left: 20px;
|
|
5
7
|
|
|
6
8
|
width: 240px;
|
|
7
9
|
height: 32px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.select {
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
8
15
|
|
|
9
16
|
border-radius: 2px;
|
|
10
17
|
}
|
|
11
|
-
|
|
@@ -20,7 +20,6 @@ import React, { useState } from "react";
|
|
|
20
20
|
import styles from "./index.module.less";
|
|
21
21
|
import zxcvbn from "zxcvbn";
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
24
|
var PasswordStrength = function PasswordStrength(props) {
|
|
26
25
|
var placeholder = props.placeholder,
|
|
@@ -30,7 +29,8 @@ var PasswordStrength = function PasswordStrength(props) {
|
|
|
30
29
|
_useState2 = _slicedToArray(_useState, 2),
|
|
31
30
|
fraction = _useState2[0],
|
|
32
31
|
setFraction = _useState2[1];
|
|
33
|
-
return /*#__PURE__*/_jsxs(
|
|
32
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
33
|
+
className: styles.passwordStrength,
|
|
34
34
|
children: [/*#__PURE__*/_jsx(Input.Password, _objectSpread(_objectSpread({}, inputConfig), {}, {
|
|
35
35
|
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : "请输入",
|
|
36
36
|
onChange: function onChange(value) {
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
.RangeInput {
|
|
32
32
|
display: flex;
|
|
33
33
|
align-items: center;
|
|
34
|
+
column-gap: 5px;
|
|
34
35
|
|
|
35
36
|
width: 100%;
|
|
36
37
|
height: 100%;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
transition: border-color 0.3s, box-shadow 0.3s;
|
|
39
|
+
transition:
|
|
40
|
+
border-color 0.3s,
|
|
41
|
+
box-shadow 0.3s;
|
|
42
42
|
|
|
43
43
|
[class*="antdInput-"] {
|
|
44
44
|
border: none !important;
|
|
@@ -15,6 +15,8 @@ interface TableTools {
|
|
|
15
15
|
columnMgt?: IColumnMgt;
|
|
16
16
|
}
|
|
17
17
|
export interface ListPanelTabelProps extends Omit<TableProps, "title"> {
|
|
18
|
+
/** 透传给内部 Table 的 key,用于在异构列集切换时强制重挂载表格 */
|
|
19
|
+
key?: React.Key;
|
|
18
20
|
title?: string;
|
|
19
21
|
buttonGroup?: ButtonProps[];
|
|
20
22
|
tabBarProps?: TabBarProps;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["title", "buttonGroup", "className", "columns", "tabBarProps", "tableTools", "tableContainerClassName", "tips", "otherTool"],
|
|
2
|
+
var _excluded = ["title", "buttonGroup", "className", "columns", "tabBarProps", "tableTools", "tableContainerClassName", "tips", "otherTool", "key"],
|
|
3
3
|
_excluded2 = ["className"];
|
|
4
4
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
5
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -75,6 +75,7 @@ var ListPanel = function ListPanel(props) {
|
|
|
75
75
|
tableContainerClassName = tableProps.tableContainerClassName,
|
|
76
76
|
tips = tableProps.tips,
|
|
77
77
|
otherTool = tableProps.otherTool,
|
|
78
|
+
tableInstanceKey = tableProps.key,
|
|
78
79
|
tableConfig = _objectWithoutProperties(tableProps, _excluded);
|
|
79
80
|
var treeClassName = treeProps.className,
|
|
80
81
|
treeConfig = _objectWithoutProperties(treeProps, _excluded2);
|
|
@@ -314,7 +315,7 @@ var ListPanel = function ListPanel(props) {
|
|
|
314
315
|
fillPanel: true
|
|
315
316
|
}, tableConfig), {}, {
|
|
316
317
|
columns: _columns
|
|
317
|
-
})))]
|
|
318
|
+
})), tableInstanceKey)]
|
|
318
319
|
})]
|
|
319
320
|
})]
|
|
320
321
|
}), /*#__PURE__*/_jsx(ColumnMgt, _objectSpread({
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 获取元素相对于视口的顶部位置。
|
|
3
|
+
* 下拉框为 position: fixed(相对视口定位),故此处必须返回视口坐标,
|
|
4
|
+
* 不能叠加 document.scrollTop——否则当文档本身可滚动时(如文档站长页面),
|
|
5
|
+
* 下拉框会被定位到 scrollTop 像素之外而“消失”。
|
|
6
|
+
* 在固定布局(document 不滚动,scrollTop=0)下与原行为一致。
|
|
3
7
|
*/
|
|
4
8
|
export declare function getElementTop(element: HTMLDivElement): number;
|
|
5
9
|
/**
|
|
6
|
-
*
|
|
10
|
+
* 获取元素相对于视口的左侧位置(同上,配合 position: fixed)。
|
|
7
11
|
*/
|
|
8
12
|
export declare function getElementLeft(element: HTMLDivElement): number;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 获取元素相对于视口的顶部位置。
|
|
3
|
+
* 下拉框为 position: fixed(相对视口定位),故此处必须返回视口坐标,
|
|
4
|
+
* 不能叠加 document.scrollTop——否则当文档本身可滚动时(如文档站长页面),
|
|
5
|
+
* 下拉框会被定位到 scrollTop 像素之外而“消失”。
|
|
6
|
+
* 在固定布局(document 不滚动,scrollTop=0)下与原行为一致。
|
|
3
7
|
*/
|
|
4
8
|
export function getElementTop(element) {
|
|
5
|
-
|
|
6
|
-
return rect.top + document.documentElement.scrollTop;
|
|
9
|
+
return element.getBoundingClientRect().top;
|
|
7
10
|
}
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
13
|
+
* 获取元素相对于视口的左侧位置(同上,配合 position: fixed)。
|
|
11
14
|
*/
|
|
12
15
|
export function getElementLeft(element) {
|
|
13
|
-
|
|
14
|
-
return rect.left + document.documentElement.scrollLeft;
|
|
16
|
+
return element.getBoundingClientRect().left;
|
|
15
17
|
}
|
|
@@ -9,6 +9,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
9
9
|
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; }
|
|
10
10
|
import { Switch as AntSwitch } from "antd";
|
|
11
11
|
import React from "react";
|
|
12
|
+
import styles from "./index.module.less";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
var Switch = function Switch(props) {
|
|
14
15
|
var _options$find, _options$find2;
|
|
@@ -18,13 +19,16 @@ var Switch = function Switch(props) {
|
|
|
18
19
|
checkedChildren = props.checkedChildren,
|
|
19
20
|
unCheckedChildren = props.unCheckedChildren,
|
|
20
21
|
rest = _objectWithoutProperties(props, _excluded);
|
|
21
|
-
return /*#__PURE__*/_jsx(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
return /*#__PURE__*/_jsx("span", {
|
|
23
|
+
className: styles.SwitchWrapper,
|
|
24
|
+
children: /*#__PURE__*/_jsx(AntSwitch, _objectSpread(_objectSpread({}, rest), {}, {
|
|
25
|
+
checkedChildren: checkedChildren || (options === null || options === void 0 || (_options$find = options.find(function (item) {
|
|
26
|
+
return item.value === trueValue;
|
|
27
|
+
})) === null || _options$find === void 0 ? void 0 : _options$find.label),
|
|
28
|
+
unCheckedChildren: unCheckedChildren || (options === null || options === void 0 || (_options$find2 = options.find(function (item) {
|
|
29
|
+
return item.value === falseValue;
|
|
30
|
+
})) === null || _options$find2 === void 0 ? void 0 : _options$find2.label)
|
|
31
|
+
}))
|
|
32
|
+
});
|
|
29
33
|
};
|
|
30
34
|
export default Switch;
|
|
@@ -12,13 +12,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
12
12
|
const SearchSelect = ({
|
|
13
13
|
onChange
|
|
14
14
|
}) => {
|
|
15
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
16
|
-
className: _indexModule.default.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
16
|
+
className: _indexModule.default.wrapper,
|
|
17
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select.default, {
|
|
18
|
+
className: _indexModule.default.select,
|
|
19
|
+
showSearch: true,
|
|
20
|
+
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u8FDB\u884C\u641C\u7D22",
|
|
21
|
+
optionFilterProp: "children",
|
|
22
|
+
filterOption: (input, option) => !!(option?.label && option?.label?.toString().toLowerCase().includes(input.toLowerCase())),
|
|
23
|
+
onChange: onChange
|
|
24
|
+
})
|
|
22
25
|
});
|
|
23
26
|
};
|
|
24
27
|
exports.SearchSelect = SearchSelect;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// 定位容器给定 32px 固定高度,Select 通过 height:100% 填满它,
|
|
2
|
+
// 避免 Select 根的 height:100% 直接相对图谱(绝对定位祖先)解析成整图高度而被拉伸。
|
|
3
|
+
.wrapper {
|
|
2
4
|
position: absolute;
|
|
3
5
|
top: 20px;
|
|
4
6
|
left: 20px;
|
|
5
7
|
|
|
6
8
|
width: 240px;
|
|
7
9
|
height: 32px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.select {
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
8
15
|
|
|
9
16
|
border-radius: 2px;
|
|
10
17
|
}
|
|
11
|
-
|
|
@@ -20,7 +20,8 @@ const PasswordStrength = props => {
|
|
|
20
20
|
...inputConfig
|
|
21
21
|
} = props;
|
|
22
22
|
const [fraction, setFraction] = (0, _react.useState)(0);
|
|
23
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
23
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
24
|
+
className: _indexModule.default.passwordStrength,
|
|
24
25
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Input.default.Password, {
|
|
25
26
|
...inputConfig,
|
|
26
27
|
placeholder: placeholder ?? "请输入",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
.RangeInput {
|
|
32
32
|
display: flex;
|
|
33
33
|
align-items: center;
|
|
34
|
+
column-gap: 5px;
|
|
34
35
|
|
|
35
36
|
width: 100%;
|
|
36
37
|
height: 100%;
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
transition: border-color 0.3s, box-shadow 0.3s;
|
|
39
|
+
transition:
|
|
40
|
+
border-color 0.3s,
|
|
41
|
+
box-shadow 0.3s;
|
|
42
42
|
|
|
43
43
|
[class*="antdInput-"] {
|
|
44
44
|
border: none !important;
|
|
@@ -15,6 +15,8 @@ interface TableTools {
|
|
|
15
15
|
columnMgt?: IColumnMgt;
|
|
16
16
|
}
|
|
17
17
|
export interface ListPanelTabelProps extends Omit<TableProps, "title"> {
|
|
18
|
+
/** 透传给内部 Table 的 key,用于在异构列集切换时强制重挂载表格 */
|
|
19
|
+
key?: React.Key;
|
|
18
20
|
title?: string;
|
|
19
21
|
buttonGroup?: ButtonProps[];
|
|
20
22
|
tabBarProps?: TabBarProps;
|
|
@@ -56,6 +56,9 @@ const ListPanel = props => {
|
|
|
56
56
|
tableContainerClassName,
|
|
57
57
|
tips,
|
|
58
58
|
otherTool,
|
|
59
|
+
// 异构列集切换时用于强制重挂载表格的 key;显式提取,避免随 ...tableConfig
|
|
60
|
+
// 展开进 JSX 触发 React "key prop being spread" 警告
|
|
61
|
+
key: tableInstanceKey,
|
|
59
62
|
...tableConfig
|
|
60
63
|
} = tableProps;
|
|
61
64
|
const {
|
|
@@ -286,7 +289,7 @@ const ListPanel = props => {
|
|
|
286
289
|
fillPanel: true,
|
|
287
290
|
...tableConfig,
|
|
288
291
|
columns: _columns
|
|
289
|
-
})]
|
|
292
|
+
}, tableInstanceKey)]
|
|
290
293
|
})]
|
|
291
294
|
})]
|
|
292
295
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ColumnMgt.default, {
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 获取元素相对于视口的顶部位置。
|
|
3
|
+
* 下拉框为 position: fixed(相对视口定位),故此处必须返回视口坐标,
|
|
4
|
+
* 不能叠加 document.scrollTop——否则当文档本身可滚动时(如文档站长页面),
|
|
5
|
+
* 下拉框会被定位到 scrollTop 像素之外而“消失”。
|
|
6
|
+
* 在固定布局(document 不滚动,scrollTop=0)下与原行为一致。
|
|
3
7
|
*/
|
|
4
8
|
export declare function getElementTop(element: HTMLDivElement): number;
|
|
5
9
|
/**
|
|
6
|
-
*
|
|
10
|
+
* 获取元素相对于视口的左侧位置(同上,配合 position: fixed)。
|
|
7
11
|
*/
|
|
8
12
|
export declare function getElementLeft(element: HTMLDivElement): number;
|
|
@@ -6,17 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getElementLeft = getElementLeft;
|
|
7
7
|
exports.getElementTop = getElementTop;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* 获取元素相对于视口的顶部位置。
|
|
10
|
+
* 下拉框为 position: fixed(相对视口定位),故此处必须返回视口坐标,
|
|
11
|
+
* 不能叠加 document.scrollTop——否则当文档本身可滚动时(如文档站长页面),
|
|
12
|
+
* 下拉框会被定位到 scrollTop 像素之外而“消失”。
|
|
13
|
+
* 在固定布局(document 不滚动,scrollTop=0)下与原行为一致。
|
|
10
14
|
*/
|
|
11
15
|
function getElementTop(element) {
|
|
12
|
-
|
|
13
|
-
return rect.top + document.documentElement.scrollTop;
|
|
16
|
+
return element.getBoundingClientRect().top;
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
|
-
*
|
|
20
|
+
* 获取元素相对于视口的左侧位置(同上,配合 position: fixed)。
|
|
18
21
|
*/
|
|
19
22
|
function getElementLeft(element) {
|
|
20
|
-
|
|
21
|
-
return rect.left + document.documentElement.scrollLeft;
|
|
23
|
+
return element.getBoundingClientRect().left;
|
|
22
24
|
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _antd = require("antd");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _indexModule = _interopRequireDefault(require("./index.module.less"));
|
|
9
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
12
|
const Switch = props => {
|
|
@@ -17,10 +18,13 @@ const Switch = props => {
|
|
|
17
18
|
unCheckedChildren,
|
|
18
19
|
...rest
|
|
19
20
|
} = props;
|
|
20
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
22
|
+
className: _indexModule.default.SwitchWrapper,
|
|
23
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Switch, {
|
|
24
|
+
...rest,
|
|
25
|
+
checkedChildren: checkedChildren || options?.find(item => item.value === trueValue)?.label,
|
|
26
|
+
unCheckedChildren: unCheckedChildren || options?.find(item => item.value === falseValue)?.label
|
|
27
|
+
})
|
|
24
28
|
});
|
|
25
29
|
};
|
|
26
30
|
var _default = exports.default = Switch;
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@ title: Button 按钮
|
|
|
16
16
|
import { Button } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 按钮
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
22
|
import React from "react";
|
|
@@ -35,6 +35,23 @@ export default () => (
|
|
|
35
35
|
);
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
+
## Chakra 按钮
|
|
39
|
+
|
|
40
|
+
基于 Chakra UI 的按钮,支持 `hasPermi`、`hidden`、`iconPosition`、`icon` 等扩展属性(Chakra system 由文档站全局提供)。
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import React from "react";
|
|
44
|
+
import { Button } from "@hsu-react/ui";
|
|
45
|
+
|
|
46
|
+
export default () => (
|
|
47
|
+
<div style={{ display: "flex", gap: 12, alignItems: "center" }}>
|
|
48
|
+
<Button.Chakra colorPalette="blue">主要按钮</Button.Chakra>
|
|
49
|
+
<Button.Chakra variant="outline">描边按钮</Button.Chakra>
|
|
50
|
+
<Button.Chakra disabled>禁用</Button.Chakra>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
```
|
|
54
|
+
|
|
38
55
|
## API
|
|
39
56
|
|
|
40
57
|
在 [antd ButtonProps](https://ant.design/components/button-cn) 基础上扩展:
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// 定位容器给定 32px 固定高度,Select 通过 height:100% 填满它,
|
|
2
|
+
// 避免 Select 根的 height:100% 直接相对图谱(绝对定位祖先)解析成整图高度而被拉伸。
|
|
3
|
+
.wrapper {
|
|
2
4
|
position: absolute;
|
|
3
5
|
top: 20px;
|
|
4
6
|
left: 20px;
|
|
5
7
|
|
|
6
8
|
width: 240px;
|
|
7
9
|
height: 32px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.select {
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
8
15
|
|
|
9
16
|
border-radius: 2px;
|
|
10
17
|
}
|
|
11
|
-
|
|
@@ -8,22 +8,24 @@ interface SearchSelectProps {
|
|
|
8
8
|
|
|
9
9
|
export const SearchSelect: React.FC<SearchSelectProps> = ({ onChange }) => {
|
|
10
10
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
?.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
<div className={styles.wrapper}>
|
|
12
|
+
<Select
|
|
13
|
+
className={styles.select}
|
|
14
|
+
showSearch
|
|
15
|
+
placeholder="请输入关键词进行搜索"
|
|
16
|
+
optionFilterProp="children"
|
|
17
|
+
filterOption={(input, option) =>
|
|
18
|
+
!!(
|
|
19
|
+
option?.label &&
|
|
20
|
+
option?.label
|
|
21
|
+
?.toString()
|
|
22
|
+
.toLowerCase()
|
|
23
|
+
.includes(input.toLowerCase())
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
onChange={onChange}
|
|
27
|
+
/>
|
|
28
|
+
</div>
|
|
27
29
|
);
|
|
28
30
|
};
|
|
29
31
|
|
|
@@ -16,7 +16,7 @@ title: ChainGraph 关系图
|
|
|
16
16
|
import { ChainGraph } from "@hsu-react/ui";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## 关系图
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
22
|
import React from "react";
|
|
@@ -44,6 +44,7 @@ export default () => (
|
|
|
44
44
|
data={data}
|
|
45
45
|
showSearch
|
|
46
46
|
showMiniMap
|
|
47
|
+
miniMapSize={[120, 80]}
|
|
47
48
|
showExpandBtn
|
|
48
49
|
onClick={(node) => console.log(node)}
|
|
49
50
|
/>
|