@lemon-fe/components 0.1.82 → 0.1.85

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 (115) hide show
  1. package/es/Actions/index.d.ts +26 -0
  2. package/es/Actions/index.js +171 -0
  3. package/es/BaseTable/Actions.d.ts +8 -0
  4. package/es/BaseTable/Actions.js +136 -0
  5. package/es/BaseTable/BaseTableContext.d.ts +6 -0
  6. package/es/BaseTable/BaseTableContext.js +6 -0
  7. package/es/BaseTable/ResizeHeaderCell.d.ts +8 -0
  8. package/es/BaseTable/ResizeHeaderCell.js +126 -0
  9. package/es/BaseTable/VirtualBody.d.ts +8 -0
  10. package/es/BaseTable/VirtualBody.js +165 -0
  11. package/es/BaseTable/index.d.ts +7 -0
  12. package/es/BaseTable/index.js +467 -0
  13. package/es/BaseTable/utils.d.ts +4 -0
  14. package/es/BaseTable/utils.js +26 -0
  15. package/es/ColorPicker/index.d.ts +13 -0
  16. package/es/ColorPicker/index.js +114 -0
  17. package/es/Dropdown/index.d.ts +14 -0
  18. package/es/Dropdown/index.js +53 -0
  19. package/es/DurationPicker/index.d.ts +25 -0
  20. package/es/DurationPicker/index.js +237 -0
  21. package/es/EditableTable/EditableCell.d.ts +11 -0
  22. package/es/EditableTable/EditableCell.js +37 -0
  23. package/es/EditableTable/EditableTableFormItem.d.ts +5 -0
  24. package/es/EditableTable/EditableTableFormItem.js +51 -0
  25. package/es/EditableTable/Table.d.ts +7 -0
  26. package/es/EditableTable/Table.js +363 -0
  27. package/es/EditableTable/index.d.ts +9 -0
  28. package/es/EditableTable/index.js +8 -0
  29. package/es/EditableTable/util.d.ts +25 -0
  30. package/es/EditableTable/util.js +387 -0
  31. package/es/Filter/index.d.ts +7 -0
  32. package/es/Filter/index.js +612 -0
  33. package/es/FormHorizontal/index.d.ts +6 -0
  34. package/es/FormHorizontal/index.js +35 -0
  35. package/es/FormInline/index.d.ts +15 -0
  36. package/es/FormInline/index.js +90 -0
  37. package/es/FormLayout/index.d.ts +32 -0
  38. package/es/FormLayout/index.js +41 -0
  39. package/es/FormTable/index.d.ts +6 -0
  40. package/es/FormTable/index.js +159 -0
  41. package/es/Icons/BigTip/index.d.ts +6 -0
  42. package/es/Icons/BigTip/index.js +50 -0
  43. package/es/Icons/Calendar.d.ts +5 -0
  44. package/es/Icons/Calendar.js +47 -0
  45. package/es/Icons/Close.d.ts +5 -0
  46. package/es/Icons/Close.js +29 -0
  47. package/es/Icons/CollapseUp.d.ts +5 -0
  48. package/es/Icons/CollapseUp.js +31 -0
  49. package/es/Icons/DarkSearch.d.ts +5 -0
  50. package/es/Icons/DarkSearch.js +38 -0
  51. package/es/Icons/Down.d.ts +5 -0
  52. package/es/Icons/Down.js +35 -0
  53. package/es/Icons/Empty.d.ts +2 -0
  54. package/es/Icons/Empty.js +267 -0
  55. package/es/Icons/LookUp.d.ts +5 -0
  56. package/es/Icons/LookUp.js +74 -0
  57. package/es/Icons/More.d.ts +5 -0
  58. package/es/Icons/More.js +44 -0
  59. package/es/Icons/Search.d.ts +5 -0
  60. package/es/Icons/Search.js +35 -0
  61. package/es/Icons/Tip.d.ts +6 -0
  62. package/es/Icons/Tip.js +169 -0
  63. package/es/Icons/index.d.ts +24 -0
  64. package/es/Icons/index.js +25 -0
  65. package/es/InputMaxLength/index.d.ts +14 -0
  66. package/es/InputMaxLength/index.js +92 -0
  67. package/es/Layout/index.d.ts +41 -0
  68. package/es/Layout/index.js +175 -0
  69. package/es/MainFramework/components/DropMenu/index.d.ts +10 -0
  70. package/es/MainFramework/components/DropMenu/index.js +104 -0
  71. package/es/MainFramework/components/Menu/index.d.ts +9 -0
  72. package/es/MainFramework/components/Menu/index.js +656 -0
  73. package/es/MainFramework/components/Menu/index.less +407 -0
  74. package/es/MainFramework/components/RefreshButton/index.d.ts +5 -0
  75. package/es/MainFramework/components/RefreshButton/index.js +72 -0
  76. package/es/MainFramework/components/RefreshButton/index.less +30 -0
  77. package/es/MainFramework/components/TabBar/index.d.ts +9 -0
  78. package/es/MainFramework/components/TabBar/index.js +116 -0
  79. package/es/MainFramework/index.d.ts +24 -0
  80. package/es/MainFramework/index.js +66 -0
  81. package/es/PageLoading/index.d.ts +5 -0
  82. package/es/PageLoading/index.js +15 -0
  83. package/es/Popup/index.d.ts +37 -0
  84. package/es/Popup/index.js +198 -0
  85. package/es/Portal/index.d.ts +12 -0
  86. package/es/Portal/index.js +72 -0
  87. package/es/Section/TabBar.d.ts +12 -0
  88. package/es/Section/TabBar.js +48 -0
  89. package/es/Section/index.d.ts +54 -0
  90. package/es/Section/index.js +96 -0
  91. package/es/SelectView/index.d.ts +53 -0
  92. package/es/SelectView/index.js +257 -0
  93. package/es/SiderTree/TreeNodeTitle.d.ts +8 -0
  94. package/es/SiderTree/TreeNodeTitle.js +107 -0
  95. package/es/SiderTree/index.d.ts +37 -0
  96. package/es/SiderTree/index.js +221 -0
  97. package/es/SymbolIcon/index.d.ts +8 -0
  98. package/es/SymbolIcon/index.js +32 -0
  99. package/es/TabBar/index.d.ts +14 -0
  100. package/es/TabBar/index.js +52 -0
  101. package/es/Table/index.d.ts +2 -0
  102. package/es/Table/index.js +236 -0
  103. package/es/Table/utils.d.ts +2 -0
  104. package/es/Table/utils.js +3 -0
  105. package/es/TipMark/index.d.ts +10 -0
  106. package/es/TipMark/index.js +45 -0
  107. package/es/constants.d.ts +1 -0
  108. package/es/constants.js +1 -0
  109. package/es/index.d.ts +33 -0
  110. package/es/index.js +28 -0
  111. package/es/init.d.ts +3 -0
  112. package/es/init.js +149 -0
  113. package/es/utils.d.ts +2 -0
  114. package/es/utils.js +14 -0
  115. package/package.json +2 -2
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import TabBar from './components/TabBar';
3
+ import Menu from './components/Menu';
4
+ import { PREFIX_CLS as prefixCls } from '../constants';
5
+ import RefreshButton from './components/RefreshButton';
6
+ export default function MainFramework(props) {
7
+ var tabs = props.tabs,
8
+ active = props.active,
9
+ children = props.children,
10
+ right = props.right,
11
+ menus = props.menus,
12
+ onTabClick = props.onTabClick,
13
+ onMenuClick = props.onMenuClick,
14
+ onTabClose = props.onTabClose,
15
+ onRefresh = props.onRefresh,
16
+ onCloseOther = props.onCloseOther,
17
+ onCloseAll = props.onCloseAll,
18
+ logo = props.logo,
19
+ title = props.title,
20
+ favorites = props.favorites,
21
+ onFavoritesChange = props.onFavoritesChange;
22
+ return /*#__PURE__*/React.createElement("div", {
23
+ className: "".concat(prefixCls, "-main")
24
+ }, /*#__PURE__*/React.createElement("div", {
25
+ className: "".concat(prefixCls, "-nav")
26
+ }, /*#__PURE__*/React.createElement("div", {
27
+ className: "".concat(prefixCls, "-nav-left")
28
+ }, logo !== false && /*#__PURE__*/React.createElement("div", {
29
+ className: "".concat(prefixCls, "-nav-logo")
30
+ }, typeof logo === 'string' ? /*#__PURE__*/React.createElement("img", {
31
+ src: logo
32
+ }) : logo || /*#__PURE__*/React.createElement("svg", {
33
+ width: "15",
34
+ height: "22",
35
+ xmlns: "http://www.w3.org/2000/svg"
36
+ }, /*#__PURE__*/React.createElement("g", {
37
+ fill: "currentColor",
38
+ fillRule: "nonzero"
39
+ }, /*#__PURE__*/React.createElement("path", {
40
+ d: "M3.403 10.313c.194-.163.393-.324.6-.481 1.47-1.123 2.592-2.339 3.333-3.622a7.805 7.805 0 0 0 1.101-4.036L8.427.966C8.159.657 7.906.335 7.67 0c-.26.384-.544.752-.849 1.103a15.52 15.52 0 0 1-2.336 2.165C2.853 4.514 1.67 5.858.938 7.28c.563 1.06 1.391 2.073 2.461 3.027M3.602 12.008a17.318 17.318 0 0 1-.835-.711C1.782 10.4.99 9.44.402 8.437a8.004 8.004 0 0 0 .362 5.91c.677 1.448 1.812 2.814 3.375 4.053.502.398.981.828 1.434 1.288v-.264a8.913 8.913 0 0 1 .99-4.146c-.687-1.157-1.683-2.256-2.96-3.276M11.025 12.036c-1.482 1.092-2.611 2.27-3.355 3.51a7.355 7.355 0 0 0-1.107 3.91l.008 1.173c.272.298.528.61.764.933.263-.372.549-.73.856-1.07a15.398 15.398 0 0 1 2.346-2.098c2.984-2.196 4.486-4.693 4.463-7.42a7.134 7.134 0 0 0-.489-2.537c-.802 1.278-1.971 2.484-3.486 3.597M11.353 9.828c.186.156.371.317.553.485.945-.983 1.668-2.02 2.156-3.096-.675-1.429-1.765-2.778-3.239-4.01-.496-.411-.968-.856-1.414-1.332v.268a9.617 9.617 0 0 1-.972 4.298c.68 1.201 1.661 2.34 2.917 3.387"
41
+ })))), /*#__PURE__*/React.createElement("div", {
42
+ className: "".concat(prefixCls, "-nav-title")
43
+ }, title)), /*#__PURE__*/React.createElement(TabBar, {
44
+ tabs: tabs,
45
+ active: active,
46
+ onClick: onTabClick,
47
+ onClose: onTabClose
48
+ }), /*#__PURE__*/React.createElement("div", {
49
+ className: "".concat(prefixCls, "-nav-right")
50
+ }, /*#__PURE__*/React.createElement(RefreshButton, {
51
+ onRefresh: onRefresh,
52
+ onCloseAll: onCloseAll,
53
+ onCloseOther: onCloseOther
54
+ }), /*#__PURE__*/React.createElement("div", {
55
+ className: "".concat(prefixCls, "-nav-divider")
56
+ }), right)), /*#__PURE__*/React.createElement("div", {
57
+ className: "".concat(prefixCls, "-body")
58
+ }, /*#__PURE__*/React.createElement(Menu, {
59
+ data: menus,
60
+ onClick: onMenuClick,
61
+ favorites: favorites,
62
+ onFavoritesChange: onFavoritesChange
63
+ }), /*#__PURE__*/React.createElement("div", {
64
+ className: "".concat(prefixCls, "-content")
65
+ }, children)));
66
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ declare const PageLoading: React.FC<{
3
+ tip?: string;
4
+ }>;
5
+ export default PageLoading;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { Spin } from 'antd';
3
+ import { PREFIX_CLS } from '../constants';
4
+
5
+ var PageLoading = function PageLoading(_ref) {
6
+ var tip = _ref.tip;
7
+ return /*#__PURE__*/React.createElement("div", {
8
+ className: "".concat(PREFIX_CLS, "-page-loading")
9
+ }, /*#__PURE__*/React.createElement(Spin, {
10
+ size: "large",
11
+ tip: tip
12
+ }));
13
+ };
14
+
15
+ export default PageLoading;
@@ -0,0 +1,37 @@
1
+ import { ReactElement } from 'react';
2
+ import type { ModalProps } from 'antd/lib/modal';
3
+ export interface PopupProps<ValueType> extends ModalProps {
4
+ value?: ValueType;
5
+ onChange?: (value?: ValueType) => void;
6
+ /**
7
+ * @description 渲染函数,这个函数不是作为组件渲染的,偷懒可以直接传入组件,如果需要考虑优化参考demo的传入方式
8
+ */
9
+ component: (params: {
10
+ value?: ValueType;
11
+ onChange: (value: ValueType) => void;
12
+ }) => ReactElement | null;
13
+ formatLabel?: (value: ValueType) => string;
14
+ beforeOk?: (value: ValueType) => ValueType | PromiseLike<ValueType>;
15
+ children?: JSX.Element | ((props: {
16
+ value?: ValueType;
17
+ }) => JSX.Element);
18
+ allowClear?: boolean;
19
+ disabled?: boolean;
20
+ autoFocus?: boolean;
21
+ showLabel?: boolean;
22
+ placeholder?: string;
23
+ disabledTip?: string;
24
+ bordered?: boolean;
25
+ onClick?: () => void;
26
+ /**
27
+ * @description 清空后的值
28
+ */
29
+ emptyValue?: ValueType;
30
+ }
31
+ interface ValuedPopupProps<ValueType> extends Omit<PopupProps<ValueType>, 'onChange' | 'emptyValue'> {
32
+ onChange?: (value: ValueType) => void;
33
+ emptyValue: ValueType;
34
+ }
35
+ declare function Popup<ValueType>(props: ValuedPopupProps<ValueType>): JSX.Element;
36
+ declare function Popup<ValueType>(props: PopupProps<ValueType>): JSX.Element;
37
+ export default Popup;
@@ -0,0 +1,198 @@
1
+ var _excluded = ["value", "onChange", "component", "children", "formatLabel", "disabled", "allowClear", "autoFocus", "showLabel", "beforeOk", "placeholder", "onClick", "disabledTip", "bordered", "emptyValue"];
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+
9
+ 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); } }
10
+
11
+ 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); }); }; }
12
+
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+
15
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
16
+
17
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
18
+
19
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
20
+
21
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
22
+
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
+
25
+ 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; }
26
+
27
+ 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; }
28
+
29
+ import React, { useState, cloneElement, useRef, isValidElement } from 'react';
30
+ import { Modal, Input, message } from 'antd';
31
+ import { CloseCircleFilled } from '@ant-design/icons';
32
+ import { PREFIX_CLS } from '../constants';
33
+ import SearchIcon from '../Icons/Search';
34
+
35
+ function Popup(props) {
36
+ var valueProp = props.value,
37
+ onChange = props.onChange,
38
+ component = props.component,
39
+ children = props.children,
40
+ formatLabel = props.formatLabel,
41
+ _props$disabled = props.disabled,
42
+ disabled = _props$disabled === void 0 ? false : _props$disabled,
43
+ _props$allowClear = props.allowClear,
44
+ allowClear = _props$allowClear === void 0 ? false : _props$allowClear,
45
+ autoFocus = props.autoFocus,
46
+ _props$showLabel = props.showLabel,
47
+ showLabel = _props$showLabel === void 0 ? true : _props$showLabel,
48
+ beforeOk = props.beforeOk,
49
+ placeholder = props.placeholder,
50
+ onClick = props.onClick,
51
+ disabledTip = props.disabledTip,
52
+ _props$bordered = props.bordered,
53
+ bordered = _props$bordered === void 0 ? true : _props$bordered,
54
+ emptyValue = props.emptyValue,
55
+ restProps = _objectWithoutProperties(props, _excluded);
56
+
57
+ var prefixCls = "".concat(PREFIX_CLS, "-popup");
58
+
59
+ var _useState = useState(valueProp || emptyValue),
60
+ _useState2 = _slicedToArray(_useState, 2),
61
+ value = _useState2[0],
62
+ setValue = _useState2[1];
63
+
64
+ var _useState3 = useState(false),
65
+ _useState4 = _slicedToArray(_useState3, 2),
66
+ visible = _useState4[0],
67
+ setVisible = _useState4[1];
68
+
69
+ var inputRef = useRef(null);
70
+
71
+ var handleCancel = function handleCancel() {
72
+ setVisible(false);
73
+ };
74
+
75
+ var handleOpen = function handleOpen() {
76
+ if (onClick) {
77
+ onClick();
78
+ }
79
+
80
+ if (disabled) {
81
+ if (disabledTip) {
82
+ message.warning(disabledTip);
83
+ }
84
+
85
+ return;
86
+ }
87
+
88
+ if (valueProp) {
89
+ setValue(valueProp);
90
+ }
91
+
92
+ setVisible(true);
93
+ };
94
+
95
+ var handleOk = /*#__PURE__*/function () {
96
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
97
+ var res;
98
+ return regeneratorRuntime.wrap(function _callee$(_context) {
99
+ while (1) {
100
+ switch (_context.prev = _context.next) {
101
+ case 0:
102
+ setVisible(false);
103
+
104
+ if (!onChange) {
105
+ _context.next = 10;
106
+ break;
107
+ }
108
+
109
+ if (!(beforeOk && value)) {
110
+ _context.next = 9;
111
+ break;
112
+ }
113
+
114
+ _context.next = 5;
115
+ return beforeOk(value);
116
+
117
+ case 5:
118
+ res = _context.sent;
119
+ onChange(res);
120
+ _context.next = 10;
121
+ break;
122
+
123
+ case 9:
124
+ onChange(value);
125
+
126
+ case 10:
127
+ if (inputRef.current) {
128
+ inputRef.current.focus();
129
+ }
130
+
131
+ case 11:
132
+ case "end":
133
+ return _context.stop();
134
+ }
135
+ }
136
+ }, _callee);
137
+ }));
138
+
139
+ return function handleOk() {
140
+ return _ref.apply(this, arguments);
141
+ };
142
+ }();
143
+
144
+ var handleClear = function handleClear(e) {
145
+ e.stopPropagation();
146
+
147
+ if (onChange) {
148
+ onChange(emptyValue);
149
+ }
150
+ };
151
+
152
+ var label = valueProp ? formatLabel ? formatLabel(valueProp) : valueProp : undefined;
153
+ var trigger;
154
+
155
+ if (typeof children === 'function') {
156
+ trigger = children({
157
+ value: valueProp
158
+ });
159
+ } else if ( /*#__PURE__*/isValidElement(children)) {
160
+ trigger = showLabel ? /*#__PURE__*/cloneElement(children, undefined, label) : children;
161
+ } else {
162
+ trigger = /*#__PURE__*/React.createElement(Input, {
163
+ className: "".concat(prefixCls, "-input"),
164
+ value: label,
165
+ readOnly: true,
166
+ ref: inputRef,
167
+ disabled: disabled,
168
+ autoFocus: autoFocus,
169
+ placeholder: placeholder,
170
+ bordered: bordered,
171
+ suffix: /*#__PURE__*/React.createElement(React.Fragment, null, !disabled && allowClear && label && /*#__PURE__*/React.createElement(CloseCircleFilled, {
172
+ className: "ant-input-clear-icon",
173
+ onClick: handleClear
174
+ }), /*#__PURE__*/React.createElement(SearchIcon, null))
175
+ });
176
+ }
177
+
178
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
179
+ className: "".concat(prefixCls, "-wrapper"),
180
+ onClick: handleOpen
181
+ }, trigger), /*#__PURE__*/React.createElement(Modal, _objectSpread({
182
+ destroyOnClose: true,
183
+ visible: visible,
184
+ width: 994,
185
+ centered: true,
186
+ onCancel: handleCancel,
187
+ onOk: handleOk,
188
+ bodyStyle: {
189
+ height: '549px',
190
+ padding: 0
191
+ }
192
+ }, restProps), component({
193
+ value: value,
194
+ onChange: setValue
195
+ })));
196
+ }
197
+
198
+ export default Popup;
@@ -0,0 +1,12 @@
1
+ import type { ReactNode } from 'react';
2
+ declare type ContentType = ReactNode | null;
3
+ declare function PortalHost(props: {
4
+ children: ContentType;
5
+ }): JSX.Element;
6
+ declare function Portal(props: {
7
+ children?: ContentType;
8
+ }): JSX.Element | null;
9
+ declare namespace Portal {
10
+ var Host: typeof PortalHost;
11
+ }
12
+ export default Portal;
@@ -0,0 +1,72 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+
3
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
+
5
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
+
7
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
+
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
+
11
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
+
13
+ import React from 'react';
14
+ import { createContext, memo, useContext, useEffect, useMemo, useState } from 'react';
15
+ import { uniqueId } from 'lodash';
16
+ var Slot = /*#__PURE__*/memo(function Content(props) {
17
+ return /*#__PURE__*/React.createElement(React.Fragment, null, props.children);
18
+ });
19
+ var Context = /*#__PURE__*/createContext(null);
20
+
21
+ function PortalHost(props) {
22
+ var children = props.children;
23
+
24
+ var _useState = useState(null),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ content = _useState2[0],
27
+ setContent = _useState2[1];
28
+
29
+ var portal = useMemo(function () {
30
+ return {
31
+ add: function add(key, node) {
32
+ setContent({
33
+ key: key,
34
+ node: node
35
+ });
36
+ },
37
+ clear: function clear(key) {
38
+ setContent(function (prev) {
39
+ if ((prev === null || prev === void 0 ? void 0 : prev.key) === key) {
40
+ return null;
41
+ }
42
+
43
+ return prev;
44
+ });
45
+ }
46
+ };
47
+ }, []);
48
+ return /*#__PURE__*/React.createElement(Context.Provider, {
49
+ value: portal
50
+ }, /*#__PURE__*/React.createElement(Slot, null, content ? content.node : null), /*#__PURE__*/React.createElement(Slot, null, children));
51
+ }
52
+
53
+ function Portal(props) {
54
+ var _props$children = props.children,
55
+ children = _props$children === void 0 ? null : _props$children;
56
+ var portal = useContext(Context);
57
+ var key = useMemo(function () {
58
+ return uniqueId('portal-');
59
+ }, []);
60
+ useEffect(function () {
61
+ if (portal !== null) {
62
+ portal.add(key, children);
63
+ return function () {
64
+ portal.clear(key);
65
+ };
66
+ }
67
+ }, [portal, key, children]);
68
+ return portal ? null : /*#__PURE__*/React.createElement(React.Fragment, null, children);
69
+ }
70
+
71
+ Portal.Host = PortalHost;
72
+ export default Portal;
@@ -0,0 +1,12 @@
1
+ import type { MouseEvent } from 'react';
2
+ interface Props {
3
+ prefixCls: string;
4
+ tabs: {
5
+ title?: string;
6
+ key: string;
7
+ }[];
8
+ activeKey?: string;
9
+ onTabClick: (key: string, index: number, e: MouseEvent) => void;
10
+ }
11
+ export default function TabBar(props: Props): JSX.Element;
12
+ export {};
@@ -0,0 +1,48 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+
5
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
+
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
10
+
11
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
12
+
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
+
15
+ import React, { useEffect, useState } from 'react';
16
+ import classNames from 'classnames';
17
+ export default function TabBar(props) {
18
+ var prefixCls = props.prefixCls,
19
+ tabs = props.tabs,
20
+ onTabClick = props.onTabClick,
21
+ activeKey = props.activeKey;
22
+
23
+ var getKey = function getKey() {
24
+ return activeKey || (tabs.length > 0 ? tabs[0].key : undefined);
25
+ };
26
+
27
+ var _useState = useState(getKey()),
28
+ _useState2 = _slicedToArray(_useState, 2),
29
+ key = _useState2[0],
30
+ setKey = _useState2[1];
31
+
32
+ useEffect(function () {
33
+ setKey(getKey());
34
+ }, [activeKey]);
35
+ return /*#__PURE__*/React.createElement("div", {
36
+ className: "".concat(prefixCls, "-tab")
37
+ }, tabs.map(function (_, index) {
38
+ var tab = tabs[index];
39
+ return /*#__PURE__*/React.createElement("div", {
40
+ key: tab.key,
41
+ className: classNames("".concat(prefixCls, "-tab-item"), _defineProperty({}, "".concat(prefixCls, "-tab-item-active"), key === tab.key)),
42
+ onClick: function onClick(e) {
43
+ setKey(tab.key);
44
+ onTabClick(tab.key, index, e);
45
+ }
46
+ }, tab.title);
47
+ }));
48
+ }
@@ -0,0 +1,54 @@
1
+ import type { Key } from 'react';
2
+ import type { ReactNode, CSSProperties } from 'react';
3
+ import { TabsProps } from 'antd';
4
+ interface Props extends Pick<TabsProps, 'activeKey' | 'onTabClick'> {
5
+ /**
6
+ * @description 标题
7
+ */
8
+ title?: string | ReactNode;
9
+ /**
10
+ * @description 内容
11
+ */
12
+ children?: ReactNode;
13
+ /**
14
+ * @description 容器样式
15
+ */
16
+ style?: CSSProperties;
17
+ /**
18
+ * @description 容器样式
19
+ */
20
+ className?: string;
21
+ /**
22
+ * @description 暂未实现
23
+ */
24
+ footer?: ReactNode;
25
+ /**
26
+ * @description 当内部有表头固定的表格时,可以考虑这个
27
+ */
28
+ type?: 'table';
29
+ /**
30
+ * @description tabs
31
+ */
32
+ tabs?: {
33
+ title?: string;
34
+ key: string;
35
+ }[];
36
+ /**
37
+ * @description body元素的样式
38
+ */
39
+ bodyStyle?: CSSProperties;
40
+ /**
41
+ * @description 标签切换事件
42
+ */
43
+ onTabChange?: (activeKey: Key, activeIndex: number) => void;
44
+ /**
45
+ * @description 操作栏,请与Actions组件结合使用并且带有标题,请不要在Tabs模式时使用
46
+ */
47
+ actions?: ReactNode;
48
+ /**
49
+ * @description 同 style flex属性, 为true时 flex = 1
50
+ */
51
+ flex?: boolean | number;
52
+ }
53
+ export default function Section(props: Props): JSX.Element;
54
+ export {};
@@ -0,0 +1,96 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+
5
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+
7
+ import React from 'react';
8
+ import classNames from 'classnames';
9
+ import { Tabs } from 'antd';
10
+ import { mapChildren } from '../utils';
11
+ import { PREFIX_CLS } from '../constants';
12
+ import TabBar from './TabBar';
13
+ export default function Section(props) {
14
+ var _classNames;
15
+
16
+ var title = props.title,
17
+ children = props.children,
18
+ style = props.style,
19
+ className = props.className,
20
+ tabs = props.tabs,
21
+ type = props.type,
22
+ bodyStyle = props.bodyStyle,
23
+ onTabChange = props.onTabChange,
24
+ actions = props.actions,
25
+ flex = props.flex,
26
+ activeKey = props.activeKey,
27
+ _onTabClick = props.onTabClick;
28
+ var prefixCls = PREFIX_CLS + '-section';
29
+ var containerStyle = style;
30
+
31
+ if (flex) {
32
+ containerStyle = _objectSpread({
33
+ flex: typeof flex === 'number' ? flex : 1
34
+ }, containerStyle);
35
+ }
36
+
37
+ var hasActions = !!actions;
38
+ return /*#__PURE__*/React.createElement("div", {
39
+ className: classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(type), !!type), _defineProperty(_classNames, "".concat(prefixCls, "-flex"), !!flex), _classNames), className),
40
+ style: containerStyle
41
+ }, title || hasActions ? /*#__PURE__*/React.createElement("div", {
42
+ className: "".concat(prefixCls, "-header")
43
+ }, /*#__PURE__*/React.createElement("div", {
44
+ className: "".concat(prefixCls, "-title")
45
+ }, title), actions) : null, tabs !== undefined && tabs.length > 0 ? Array.isArray(children) && children.length > 1 ? /*#__PURE__*/React.createElement(Tabs, {
46
+ activeKey: activeKey,
47
+ onTabClick: _onTabClick,
48
+ renderTabBar: function renderTabBar(tabProps) {
49
+ var mKey = tabProps.activeKey,
50
+ mClick = tabProps.onTabClick;
51
+ return /*#__PURE__*/React.createElement(TabBar, {
52
+ activeKey: mKey,
53
+ tabs: tabs,
54
+ prefixCls: prefixCls,
55
+ onTabClick: function onTabClick(key, index, e) {
56
+ mClick(key, e);
57
+
58
+ if (key !== mKey) {
59
+ if (onTabChange) {
60
+ onTabChange(key, index);
61
+ }
62
+ }
63
+ }
64
+ });
65
+ }
66
+ }, mapChildren(children, function (child, index) {
67
+ var _tabs$index = tabs[index],
68
+ tab = _tabs$index.title,
69
+ key = _tabs$index.key;
70
+ return /*#__PURE__*/React.createElement(Tabs.TabPane, {
71
+ tab: tab,
72
+ key: key,
73
+ className: "".concat(prefixCls, "-body"),
74
+ style: bodyStyle
75
+ }, child);
76
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TabBar, {
77
+ activeKey: activeKey,
78
+ tabs: tabs,
79
+ prefixCls: prefixCls,
80
+ onTabClick: function onTabClick(key, index, e) {
81
+ if (_onTabClick) {
82
+ _onTabClick(key, e);
83
+ }
84
+
85
+ if (key !== activeKey && onTabChange) {
86
+ onTabChange(key, index);
87
+ }
88
+ }
89
+ }), /*#__PURE__*/React.createElement("div", {
90
+ className: "".concat(prefixCls, "-body"),
91
+ style: bodyStyle
92
+ }, children)) : /*#__PURE__*/React.createElement("div", {
93
+ className: "".concat(prefixCls, "-body"),
94
+ style: bodyStyle
95
+ }, children));
96
+ }