@lemon-fe/kits 1.0.0-162 → 1.0.0-164
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.
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DropDownProps } from 'antd';
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
declare type TriggerType = 'click' | 'hover' | 'contextMenu';
|
|
4
|
+
interface Props extends Omit<DropDownProps, 'trigger'> {
|
|
5
|
+
actions?: ({
|
|
5
6
|
text: string | ReactElement;
|
|
6
|
-
|
|
7
|
+
key?: string;
|
|
8
|
+
onClick?: () => void;
|
|
7
9
|
disabled?: boolean;
|
|
8
10
|
} | null)[];
|
|
9
|
-
|
|
10
|
-
placement?: PopoverProps['placement'];
|
|
11
|
-
children?: ReactElement | null;
|
|
12
|
-
trigger?: PopoverProps['trigger'];
|
|
11
|
+
trigger?: TriggerType | TriggerType[];
|
|
13
12
|
}
|
|
14
|
-
export default function
|
|
13
|
+
export default function DropdownWrapper(props: Props): JSX.Element;
|
|
15
14
|
export {};
|
|
@@ -1,55 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
var _excluded = ["actions", "trigger", "overlayClassName"];
|
|
2
2
|
|
|
3
|
-
function
|
|
3
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
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; }
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
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; }
|
|
8
8
|
|
|
9
|
-
|
|
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 { Popover } from 'antd';
|
|
16
|
-
import React, { useState } from 'react';
|
|
9
|
+
import { Dropdown } from 'antd';
|
|
17
10
|
import classNames from 'classnames';
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
import React, { useMemo } from 'react';
|
|
12
|
+
import { prefixClassName } from "../utils";
|
|
13
|
+
export default function DropdownWrapper(props) {
|
|
14
|
+
var _props$actions = props.actions,
|
|
15
|
+
actions = _props$actions === void 0 ? [] : _props$actions,
|
|
16
|
+
trigger = props.trigger,
|
|
21
17
|
overlayClassName = props.overlayClassName,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}, item.text);
|
|
53
|
-
})
|
|
54
|
-
}, children);
|
|
18
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
19
|
+
|
|
20
|
+
var prefixCls = prefixClassName('dropdown');
|
|
21
|
+
var defaultTrigger = actions.length > 0 ? ['click'] : undefined;
|
|
22
|
+
var defaultOverlayStyle = actions.length > 0 ? {
|
|
23
|
+
minWidth: 120
|
|
24
|
+
} : undefined;
|
|
25
|
+
var mTrigger = typeof trigger === 'string' ? [trigger] : trigger || defaultTrigger;
|
|
26
|
+
var items = useMemo(function () {
|
|
27
|
+
return actions.map(function (item, idx) {
|
|
28
|
+
if (item === null) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
label: item.text,
|
|
34
|
+
key: item.key || idx.toString(),
|
|
35
|
+
onClick: item.onClick,
|
|
36
|
+
disabled: item.disabled
|
|
37
|
+
};
|
|
38
|
+
}).filter(Boolean);
|
|
39
|
+
}, [actions]);
|
|
40
|
+
return /*#__PURE__*/React.createElement(Dropdown, _extends({
|
|
41
|
+
menu: {
|
|
42
|
+
items: items
|
|
43
|
+
},
|
|
44
|
+
trigger: mTrigger,
|
|
45
|
+
overlayStyle: defaultOverlayStyle,
|
|
46
|
+
overlayClassName: classNames(prefixCls(), overlayClassName)
|
|
47
|
+
}, restProps));
|
|
55
48
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { default as Icons } from './components/Icons';
|
|
|
29
29
|
export { default as FormLayout } from './components/FormLayout';
|
|
30
30
|
export { default as TabBar } from './components/TabBar';
|
|
31
31
|
export { default as SymbolIcon } from './components/SymbolIcon';
|
|
32
|
+
export { default as Dropdown } from './components/Dropdown';
|
|
32
33
|
export { default as SelectView } from './components/SelectView';
|
|
33
34
|
export { default as DataGrid } from './components/DataGrid';
|
|
34
35
|
export * from './components/DataGrid/typings';
|
package/es/index.js
CHANGED
|
@@ -22,6 +22,7 @@ export { default as Icons } from "./components/Icons";
|
|
|
22
22
|
export { default as FormLayout } from "./components/FormLayout";
|
|
23
23
|
export { default as TabBar } from "./components/TabBar";
|
|
24
24
|
export { default as SymbolIcon } from "./components/SymbolIcon";
|
|
25
|
+
export { default as Dropdown } from "./components/Dropdown";
|
|
25
26
|
export { default as SelectView } from "./components/SelectView";
|
|
26
27
|
export { default as DataGrid } from "./components/DataGrid";
|
|
27
28
|
export * from "./components/DataGrid/typings";
|