@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 { PopoverProps } from 'antd';
1
+ import { type DropDownProps } from 'antd';
2
2
  import type { ReactElement } from 'react';
3
- interface Props {
4
- actions: ({
3
+ declare type TriggerType = 'click' | 'hover' | 'contextMenu';
4
+ interface Props extends Omit<DropDownProps, 'trigger'> {
5
+ actions?: ({
5
6
  text: string | ReactElement;
6
- onClick: () => void;
7
+ key?: string;
8
+ onClick?: () => void;
7
9
  disabled?: boolean;
8
10
  } | null)[];
9
- overlayClassName?: string;
10
- placement?: PopoverProps['placement'];
11
- children?: ReactElement | null;
12
- trigger?: PopoverProps['trigger'];
11
+ trigger?: TriggerType | TriggerType[];
13
12
  }
14
- export default function Dropdown(props: Props): JSX.Element;
13
+ export default function DropdownWrapper(props: Props): JSX.Element;
15
14
  export {};
@@ -1,55 +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; }
1
+ var _excluded = ["actions", "trigger", "overlayClassName"];
2
2
 
3
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
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 _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."); }
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 _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); }
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
- 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 { Popover } from 'antd';
16
- import React, { useState } from 'react';
9
+ import { Dropdown } from 'antd';
17
10
  import classNames from 'classnames';
18
- import { PREFIX_CLS } from "../../constants";
19
- export default function Dropdown(props) {
20
- var actions = props.actions,
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
- _props$placement = props.placement,
23
- placement = _props$placement === void 0 ? 'bottomRight' : _props$placement,
24
- children = props.children,
25
- _props$trigger = props.trigger,
26
- trigger = _props$trigger === void 0 ? 'click' : _props$trigger;
27
-
28
- var _useState = useState(false),
29
- _useState2 = _slicedToArray(_useState, 2),
30
- visible = _useState2[0],
31
- setVisible = _useState2[1];
32
-
33
- var prefixCls = "".concat(PREFIX_CLS, "-dropdown");
34
- return /*#__PURE__*/React.createElement(Popover, {
35
- trigger: trigger,
36
- placement: placement,
37
- open: visible,
38
- onOpenChange: setVisible,
39
- overlayClassName: classNames(prefixCls, overlayClassName),
40
- content: actions.map(function (item, index) {
41
- return item !== null && /*#__PURE__*/React.createElement("div", {
42
- className: classNames("".concat(prefixCls, "-item"), _defineProperty({}, "".concat(prefixCls, "-item-disabled"), item.disabled)),
43
- key: index,
44
- onClick: function onClick() {
45
- if (item.disabled) {
46
- return;
47
- }
48
-
49
- setVisible(false);
50
- item.onClick();
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
  }
@@ -1,13 +1,5 @@
1
1
  .@{prefixCls}-dropdown {
2
- .popover();
3
-
4
- &-item {
5
- .popoverItem();
6
-
7
- &-disabled {
8
- color: rgba(0, 0, 0, 0.25);
9
- background-color: #fff !important;
10
- cursor: not-allowed;
11
- }
2
+ .@{ant-prefix}-dropdown-menu {
3
+ border-radius: 6px;
12
4
  }
13
5
  }
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";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.0-162",
3
+ "version": "1.0.0-164",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",