@hsu-react/ui 0.0.2 → 0.0.3

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 (73) hide show
  1. package/README.md +2 -0
  2. package/es/components/ChainGraph/_components/SearchSelect/index.js +13 -10
  3. package/es/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  4. package/es/components/DatePicker/index.module.less +1 -0
  5. package/es/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -2
  6. package/es/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  7. package/es/components/Input/Range/index.module.less +4 -4
  8. package/es/components/Input/index.module.less +3 -0
  9. package/es/components/Select/_utils/getElementPosition.d.ts +6 -2
  10. package/es/components/Select/_utils/getElementPosition.js +8 -6
  11. package/es/components/Select/index.module.less +3 -0
  12. package/es/components/Slider/index.module.less +1 -0
  13. package/es/components/Switch/index.js +12 -8
  14. package/es/components/Switch/index.module.less +7 -0
  15. package/lib/components/ChainGraph/_components/SearchSelect/index.js +10 -7
  16. package/lib/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  17. package/lib/components/DatePicker/index.module.less +1 -0
  18. package/lib/components/FormItem/FormInput/FormPasswordStrength/index.js +2 -1
  19. package/lib/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  20. package/lib/components/Input/Range/index.module.less +4 -4
  21. package/lib/components/Input/index.module.less +3 -0
  22. package/lib/components/Select/_utils/getElementPosition.d.ts +6 -2
  23. package/lib/components/Select/_utils/getElementPosition.js +8 -6
  24. package/lib/components/Select/index.module.less +3 -0
  25. package/lib/components/Slider/index.module.less +1 -0
  26. package/lib/components/Switch/index.js +8 -4
  27. package/lib/components/Switch/index.module.less +7 -0
  28. package/package.json +1 -1
  29. package/src/components/Button/index.md +18 -1
  30. package/src/components/ChainGraph/_components/SearchSelect/index.module.less +8 -2
  31. package/src/components/ChainGraph/_components/SearchSelect/index.tsx +18 -16
  32. package/src/components/ChainGraph/index.md +2 -1
  33. package/src/components/Chart/index.md +290 -17
  34. package/src/components/Chat/index.md +44 -1
  35. package/src/components/Checkbox/index.md +33 -1
  36. package/src/components/CodeMirror/index.md +1 -1
  37. package/src/components/Copy/index.md +1 -1
  38. package/src/components/DatePicker/index.md +41 -2
  39. package/src/components/DatePicker/index.module.less +1 -0
  40. package/src/components/Descriptions/index.md +1 -1
  41. package/src/components/Editor/index.md +1 -1
  42. package/src/components/FileCol/index.md +1 -1
  43. package/src/components/FilePreview/index.md +1 -1
  44. package/src/components/FlexFill/index.md +1 -1
  45. package/src/components/Form/index.md +88 -1
  46. package/src/components/FormItem/FormInput/FormPasswordStrength/index.module.less +12 -0
  47. package/src/components/FormItem/FormInput/FormPasswordStrength/index.tsx +2 -2
  48. package/src/components/FormItem/index.md +147 -92
  49. package/src/components/Icon/index.md +3 -1
  50. package/src/components/Input/Range/index.module.less +4 -4
  51. package/src/components/Input/index.md +115 -2
  52. package/src/components/Input/index.module.less +3 -0
  53. package/src/components/Markdown/index.md +3 -1
  54. package/src/components/Modal/index.md +1 -1
  55. package/src/components/Operate/index.md +1 -1
  56. package/src/components/Panel/index.md +68 -21
  57. package/src/components/Search/index.md +184 -9
  58. package/src/components/SecondConf/index.md +1 -1
  59. package/src/components/Select/_utils/getElementPosition.ts +8 -6
  60. package/src/components/Select/index.md +1 -1
  61. package/src/components/Select/index.module.less +3 -0
  62. package/src/components/Slider/index.md +1 -2
  63. package/src/components/Slider/index.module.less +1 -0
  64. package/src/components/Spreadsheet/index.md +1 -1
  65. package/src/components/Switch/index.md +1 -1
  66. package/src/components/Switch/index.module.less +7 -0
  67. package/src/components/Switch/index.tsx +14 -11
  68. package/src/components/TabBar/index.md +28 -11
  69. package/src/components/Table/index.md +1 -1
  70. package/src/components/Tags/index.md +1 -1
  71. package/src/components/TextEllipsis/index.md +1 -1
  72. package/src/components/Tree/index.md +1 -1
  73. package/src/components/Upload/index.md +1 -1
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  一套基于 **React + Ant Design** 的中后台业务组件库,把「列表 + 搜索 + 表单弹窗 + CRUD」这类重复劳动沉淀为页面级组件,并内置 Markdown / CodeMirror / Spreadsheet / Chart / Editor 等内容组件。
4
4
 
5
+ 📖 **文档与在线示例:https://vitatsui.github.io/hsu-ui**
6
+
5
7
  ## 安装
6
8
 
7
9
  ```bash
@@ -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(Select, {
8
- className: styles.select,
9
- showSearch: true,
10
- placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u8FDB\u884C\u641C\u7D22",
11
- optionFilterProp: "children",
12
- filterOption: function filterOption(input, option) {
13
- var _option$label;
14
- 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()));
15
- },
16
- onChange: onChange
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
- .select {
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
-
@@ -5,6 +5,7 @@
5
5
 
6
6
  width: 100%;
7
7
  height: 100%;
8
+ min-height: 32px;
8
9
  max-height: max-content;
9
10
 
10
11
  border-radius: 6px;
@@ -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(_Fragment, {
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) {
@@ -1,3 +1,15 @@
1
+ .passwordStrength {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 4px;
5
+
6
+ width: 100%;
7
+
8
+ .passwordInput {
9
+ width: 100%;
10
+ }
11
+ }
12
+
1
13
  .strengthBar {
2
14
  position: relative;
3
15
 
@@ -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
- border-radius: 6px;
39
- border: 1px solid var(--cf-border);
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;
@@ -1,6 +1,9 @@
1
1
  .antdInput {
2
2
  width: 100%;
3
3
  height: 100%;
4
+ // 父级未给定高度时(height:100% 解析为 auto),保证最小高度,避免输入框被压扁;
5
+ // 内部 .ant-input-wrapper / .ant-input 通过 min-height: inherit 继承该值。
6
+ min-height: 32px;
4
7
 
5
8
  :global(.ant-input-clear-icon) {
6
9
  font-size: 14px;
@@ -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
- var rect = element.getBoundingClientRect();
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
- var rect = element.getBoundingClientRect();
14
- return rect.left + document.documentElement.scrollLeft;
16
+ return element.getBoundingClientRect().left;
15
17
  }
@@ -6,6 +6,9 @@
6
6
 
7
7
  width: 100%;
8
8
  height: 100%;
9
+ // 父级未给定高度时(height:100% 解析为 auto),保证最小高度,
10
+ // 与 Input 等录入控件高度一致,避免被压扁或在搜索行中高度异常。
11
+ min-height: 32px;
9
12
  padding: 0px 11px;
10
13
 
11
14
  // CF 风格:随外观切换的描边输入控件
@@ -1,4 +1,5 @@
1
1
  .slider {
2
+ width: 100%;
2
3
  height: 32px;
3
4
  margin: 0px;
4
5
  padding-block: 0px;
@@ -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(AntSwitch, _objectSpread(_objectSpread({}, rest), {}, {
22
- checkedChildren: checkedChildren || (options === null || options === void 0 || (_options$find = options.find(function (item) {
23
- return item.value === trueValue;
24
- })) === null || _options$find === void 0 ? void 0 : _options$find.label),
25
- unCheckedChildren: unCheckedChildren || (options === null || options === void 0 || (_options$find2 = options.find(function (item) {
26
- return item.value === falseValue;
27
- })) === null || _options$find2 === void 0 ? void 0 : _options$find2.label)
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;
@@ -0,0 +1,7 @@
1
+ // 让开关在表单/录入场景中与 Input、Select 等控件保持一致的 32px 最小高度。
2
+ // 开关本体(pill)保持原始尺寸,由该容器居中占位,故不会被拉大。
3
+ .SwitchWrapper {
4
+ display: inline-flex;
5
+ align-items: center;
6
+ min-height: 32px;
7
+ }
@@ -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)(_Select.default, {
16
- className: _indexModule.default.select,
17
- showSearch: true,
18
- placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u8BCD\u8FDB\u884C\u641C\u7D22",
19
- optionFilterProp: "children",
20
- filterOption: (input, option) => !!(option?.label && option?.label?.toString().toLowerCase().includes(input.toLowerCase())),
21
- onChange: onChange
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
- .select {
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
-
@@ -5,6 +5,7 @@
5
5
 
6
6
  width: 100%;
7
7
  height: 100%;
8
+ min-height: 32px;
8
9
  max-height: max-content;
9
10
 
10
11
  border-radius: 6px;
@@ -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)(_jsxRuntime.Fragment, {
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 ?? "请输入",
@@ -1,3 +1,15 @@
1
+ .passwordStrength {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 4px;
5
+
6
+ width: 100%;
7
+
8
+ .passwordInput {
9
+ width: 100%;
10
+ }
11
+ }
12
+
1
13
  .strengthBar {
2
14
  position: relative;
3
15
 
@@ -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
- border-radius: 6px;
39
- border: 1px solid var(--cf-border);
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;
@@ -1,6 +1,9 @@
1
1
  .antdInput {
2
2
  width: 100%;
3
3
  height: 100%;
4
+ // 父级未给定高度时(height:100% 解析为 auto),保证最小高度,避免输入框被压扁;
5
+ // 内部 .ant-input-wrapper / .ant-input 通过 min-height: inherit 继承该值。
6
+ min-height: 32px;
4
7
 
5
8
  :global(.ant-input-clear-icon) {
6
9
  font-size: 14px;
@@ -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
- const rect = element.getBoundingClientRect();
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
- const rect = element.getBoundingClientRect();
21
- return rect.left + document.documentElement.scrollLeft;
23
+ return element.getBoundingClientRect().left;
22
24
  }
@@ -6,6 +6,9 @@
6
6
 
7
7
  width: 100%;
8
8
  height: 100%;
9
+ // 父级未给定高度时(height:100% 解析为 auto),保证最小高度,
10
+ // 与 Input 等录入控件高度一致,避免被压扁或在搜索行中高度异常。
11
+ min-height: 32px;
9
12
  padding: 0px 11px;
10
13
 
11
14
  // CF 风格:随外观切换的描边输入控件
@@ -1,4 +1,5 @@
1
1
  .slider {
2
+ width: 100%;
2
3
  height: 32px;
3
4
  margin: 0px;
4
5
  padding-block: 0px;
@@ -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)(_antd.Switch, {
21
- ...rest,
22
- checkedChildren: checkedChildren || options?.find(item => item.value === trueValue)?.label,
23
- unCheckedChildren: unCheckedChildren || options?.find(item => item.value === falseValue)?.label
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;
@@ -0,0 +1,7 @@
1
+ // 让开关在表单/录入场景中与 Input、Select 等控件保持一致的 32px 最小高度。
2
+ // 开关本体(pill)保持原始尺寸,由该容器居中占位,故不会被拉大。
3
+ .SwitchWrapper {
4
+ display: inline-flex;
5
+ align-items: center;
6
+ min-height: 32px;
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsu-react/ui",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "一套基于 React + Ant Design 的中后台业务组件库",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -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
- .select {
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
- <Select
12
- className={styles.select}
13
- showSearch
14
- placeholder="请输入关键词进行搜索"
15
- optionFilterProp="children"
16
- filterOption={(input, option) =>
17
- !!(
18
- option?.label &&
19
- option?.label
20
- ?.toString()
21
- .toLowerCase()
22
- .includes(input.toLowerCase())
23
- )
24
- }
25
- onChange={onChange}
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
  />