@lemon-fe/kits 1.0.0-163 → 1.0.0-165

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.
@@ -2,11 +2,18 @@ import type { ICellEditorParams } from '@ag-grid-community/core';
2
2
  import type { ICellEditorReactComp } from '@ag-grid-community/react';
3
3
  import { type Moment } from 'moment';
4
4
  import React from 'react';
5
- export interface DateEditorParams {
6
- format: string;
5
+ export interface DateEditorParams<TData = any> {
6
+ format?: string;
7
7
  disabled?: boolean;
8
8
  disabledDate?: (current: Moment) => boolean;
9
9
  allowClear?: boolean;
10
+ /**
11
+ * 可以在不使用disabledDate的情况下,进行数值校验,可以用于错误提示
12
+ * @param newValue
13
+ * @param data
14
+ * @returns
15
+ */
16
+ isCancelAfterEnd?: (newValue: Moment | null, data: TData) => boolean;
10
17
  }
11
- declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & DateEditorParams & React.RefAttributes<ICellEditorReactComp>>;
18
+ declare const _default: React.ForwardRefExoticComponent<ICellEditorParams<any, any, any> & DateEditorParams<any> & React.RefAttributes<ICellEditorReactComp>>;
12
19
  export default _default;
@@ -29,7 +29,9 @@ export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
29
29
  api = props.api,
30
30
  disabledDate = props.disabledDate,
31
31
  _props$allowClear = props.allowClear,
32
- allowClear = _props$allowClear === void 0 ? false : _props$allowClear;
32
+ allowClear = _props$allowClear === void 0 ? false : _props$allowClear,
33
+ _isCancelAfterEnd = props.isCancelAfterEnd,
34
+ node = props.node;
33
35
 
34
36
  var _useState = useState(props.value ? moment(props.value, format) : null),
35
37
  _useState2 = _slicedToArray(_useState, 2),
@@ -50,12 +52,19 @@ export default /*#__PURE__*/forwardRef(function DateEditor(props, ref) {
50
52
 
51
53
  useImperativeHandle(ref, function () {
52
54
  return {
53
- getValue: getValue
55
+ getValue: getValue,
56
+ isCancelAfterEnd: function isCancelAfterEnd() {
57
+ if (_isCancelAfterEnd) {
58
+ return _isCancelAfterEnd(value, node.data);
59
+ }
60
+
61
+ return false;
62
+ }
54
63
  };
55
64
  });
56
65
  return /*#__PURE__*/React.createElement(EditorWrapper, null, /*#__PURE__*/React.createElement(DatePicker, {
57
66
  onKeyDown: function onKeyDown(e) {
58
- if (isEdited) {
67
+ if (isEdited.current) {
59
68
  navigateCell(_objectSpread(_objectSpread({}, props), {}, {
60
69
  event: e
61
70
  }));
@@ -48,7 +48,7 @@ export default class DataGrid<TData extends Record<string, any>> extends Compone
48
48
  static EmptyCol: ColType<any>;
49
49
  static Editors: {
50
50
  Text: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").TextEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
51
- Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
51
+ Date: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").DateEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
52
52
  Number: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & import("./typings").NumberEditorParams<any> & React.RefAttributes<import("@ag-grid-community/react").ICellEditorReactComp>>;
53
53
  Select: React.ForwardRefExoticComponent<import("@ag-grid-community/core").ICellEditorParams<any, any, any> & Pick<import("antd").SelectProps<any, import("antd/lib/select").BaseOptionType>, "disabled" | "allowClear" | "mode" | "options" | "virtual" | "showSearch" | "listHeight"> & {
54
54
  fieldNames?: {
@@ -1,7 +1,7 @@
1
1
  var _excluded = ["validator"],
2
2
  _excluded2 = ["title", "dataIndex", "type", "render", "ellipsis", "cellRenderer", "cellRendererParams", "className", "sorter", "sortable", "editable", "suppressKeyboardEvent"],
3
3
  _excluded3 = ["title", "children"],
4
- _excluded4 = ["rowKey", "fetch", "dataSource", "rowActions", "columns", "autoLoad", "loading", "summary", "detailCell", "pagination", "rowSelection", "columnTypes", "defaultColDef", "components", "sideBar", "detailCellRendererParams", "context", "showSearch"];
4
+ _excluded4 = ["rowKey", "fetch", "dataSource", "rowActions", "columns", "autoLoad", "loading", "summary", "detailCell", "pagination", "rowSelection", "columnTypes", "defaultColDef", "components", "sideBar", "detailCellRendererParams", "context", "showSearch", "cellDisplayFlex"];
5
5
 
6
6
  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); }
7
7
 
@@ -1315,7 +1315,8 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1315
1315
  }, {
1316
1316
  key: "render",
1317
1317
  value: function render() {
1318
- var _this10 = this;
1318
+ var _this10 = this,
1319
+ _classNames;
1319
1320
 
1320
1321
  var _this$props8 = this.props,
1321
1322
  rowKey = _this$props8.rowKey,
@@ -1336,6 +1337,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1336
1337
  detailCellRendererParams = _this$props8.detailCellRendererParams,
1337
1338
  context = _this$props8.context,
1338
1339
  showSearch = _this$props8.showSearch,
1340
+ cellDisplayFlex = _this$props8.cellDisplayFlex,
1339
1341
  restProps = _objectWithoutProperties(_this$props8, _excluded4);
1340
1342
 
1341
1343
  var _this$state2 = this.state,
@@ -1393,7 +1395,7 @@ var DataGrid = /*#__PURE__*/function (_Component) {
1393
1395
  return /*#__PURE__*/React.createElement(GridStoreContext.Provider, {
1394
1396
  value: this.store
1395
1397
  }, /*#__PURE__*/React.createElement("div", {
1396
- className: classNames('ag-theme-lemon', "".concat(prefix()), _defineProperty({}, prefix('group-rows'), restProps.groupDisplayType === 'groupRows')),
1398
+ className: classNames('ag-theme-lemon', "".concat(prefix()), (_classNames = {}, _defineProperty(_classNames, prefix('group-rows'), restProps.groupDisplayType === 'groupRows'), _defineProperty(_classNames, prefix('cell-flex'), cellDisplayFlex), _classNames)),
1397
1399
  style: restProps.domLayout === 'autoHeight' ? {
1398
1400
  height: 'auto'
1399
1401
  } : undefined,
@@ -15,6 +15,21 @@
15
15
  height: 100%;
16
16
  min-height: 0;
17
17
 
18
+ &-cell-flex {
19
+ .ag-cell {
20
+ display: flex;
21
+ align-items: center;
22
+ }
23
+
24
+ .ag-ltr .ag-right-aligned-cell {
25
+ justify-content: space-between;
26
+ }
27
+
28
+ .ag-rtl .ag-right-aligned-cell {
29
+ flex-direction: row-reverse;
30
+ }
31
+ }
32
+
18
33
  &-column-sorter {
19
34
  display: inline-flex;
20
35
  flex-direction: column;
@@ -36,6 +51,7 @@
36
51
  }
37
52
 
38
53
  &-center-aligned-cell {
54
+ justify-content: center;
39
55
  text-align: center;
40
56
  }
41
57
 
@@ -23,11 +23,14 @@ interface EditorParamsType<T extends string, K extends Record<string, any>> {
23
23
  params?: K;
24
24
  component?: string;
25
25
  }
26
- declare type EditorType<TData> = EditorParamsType<'text-editor', TextEditorParams> | EditorParamsType<'number-editor', NumberEditorParams<TData>> | EditorParamsType<'date-editor', DateEditorParams> | EditorParamsType<'select-editor', SelectEditorParams> | EditorParamsType<'row-editor', RowEditorParams<TData>>;
26
+ declare type EditorType<TData> = EditorParamsType<'text-editor', TextEditorParams<TData>> | EditorParamsType<'number-editor', NumberEditorParams<TData>> | EditorParamsType<'date-editor', DateEditorParams<TData>> | EditorParamsType<'select-editor', SelectEditorParams> | EditorParamsType<'row-editor', RowEditorParams<TData>>;
27
27
  export interface ColType<TData> extends Omit<ColDef<TData>, 'editable'> {
28
28
  title?: ReactNode | ((params: IHeaderParams) => ReactNode);
29
29
  dataIndex?: string;
30
30
  className?: string;
31
+ /**
32
+ * @deprecated
33
+ */
31
34
  sorter?: boolean | ((a: TData, b: TData) => number);
32
35
  ellipsis?: boolean;
33
36
  /**
@@ -193,4 +196,8 @@ export interface DataGridProps<TData> extends Omit<AgGridReactProps<TData>, 'row
193
196
  * @description 显示底部搜索栏,只支持非远程模式
194
197
  */
195
198
  showSearch?: boolean | DataGridSearch;
199
+ /**
200
+ * @description 单元格是否表现成弹性盒子,从而便于垂直,此时也会导致文本ellipsis失效
201
+ */
202
+ cellDisplayFlex?: boolean;
196
203
  }
@@ -0,0 +1,14 @@
1
+ import { type DropDownProps } from 'antd';
2
+ import type { ReactElement } from 'react';
3
+ declare type TriggerType = 'click' | 'hover' | 'contextMenu';
4
+ interface Props extends Omit<DropDownProps, 'trigger'> {
5
+ actions?: ({
6
+ text: string | ReactElement;
7
+ key?: string;
8
+ onClick?: () => void;
9
+ disabled?: boolean;
10
+ } | null)[];
11
+ trigger?: TriggerType | TriggerType[];
12
+ }
13
+ export default function DropdownWrapper(props: Props): JSX.Element;
14
+ export {};
@@ -0,0 +1,48 @@
1
+ var _excluded = ["actions", "trigger", "overlayClassName"];
2
+
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
+
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
+
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
+
9
+ import { Dropdown } from 'antd';
10
+ import classNames from 'classnames';
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,
17
+ overlayClassName = props.overlayClassName,
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));
48
+ }
@@ -0,0 +1,5 @@
1
+ .@{prefixCls}-dropdown {
2
+ .@{ant-prefix}-dropdown-menu {
3
+ border-radius: 6px;
4
+ }
5
+ }
@@ -7,7 +7,7 @@ declare namespace Filter {
7
7
  title: string;
8
8
  value: Record<string | number, any>;
9
9
  }>(getData: (storageKey: string) => T[] | Promise<T[]>, setData: (storageKey: string, data: T[], action: {
10
- type: "set" | "delete";
10
+ type: "delete" | "set";
11
11
  target: T;
12
12
  }) => void | Promise<void>) => void;
13
13
  var defaultProps: Partial<FilterProps<Record<string, any>>>;
@@ -109,8 +109,11 @@ function setStorage(getData, setData) {
109
109
  setStorageData = setData;
110
110
  }
111
111
 
112
+ var defaultData = [];
113
+
112
114
  function Filter(props) {
113
- var data = props.data,
115
+ var _props$data = props.data,
116
+ data = _props$data === void 0 ? defaultData : _props$data,
114
117
  defaultValueProp = props.defaultValue,
115
118
  onChange = props.onChange,
116
119
  value = props.value,
@@ -25,7 +25,7 @@ export interface FilterItemType<T = any> {
25
25
  export type ActionType = 'submit' | 'reset';
26
26
 
27
27
  export interface FilterProps<T extends Record<string, any> = Record<string, any>> {
28
- data: FilterItemType<T>[];
28
+ data?: FilterItemType<T>[];
29
29
  defaultValue?: T;
30
30
  value?: T;
31
31
  /**
@@ -213,16 +213,15 @@ function Popup(props) {
213
213
  destroyOnClose: true,
214
214
  open: shouldModalOpen,
215
215
  width: 1000,
216
+ bodyStyle: {
217
+ height: 500
218
+ },
216
219
  centered: true,
217
220
  onCancel: handleCancel,
218
221
  afterClose: handleAfterClose,
219
222
  onOk: function onOk() {
220
223
  return handleOk();
221
224
  },
222
- bodyStyle: {
223
- height: 550,
224
- padding: 0
225
- },
226
225
  footer: renderFooter ? renderFooter({
227
226
  onCancel: handleCancel,
228
227
  onOk: function onOk() {
@@ -1,7 +1,7 @@
1
1
  import type { CSSProperties, ReactElement } from 'react';
2
- import type { ColType, PaginationType, SortType } from '../DataGrid/typings';
2
+ import type { ColType, DataGridProps, PaginationType, SortType } from '../DataGrid/typings';
3
3
  import type { FilterProps } from '../Filter/typings';
4
- interface Props<RecordType, ParamsType extends Record<string, any>> {
4
+ interface Props<RecordType, ParamsType extends Record<string, any>> extends Pick<DataGridProps<RecordType>, 'defaultColDef' | 'rowHeight' | 'cellDisplayFlex'> {
5
5
  value?: RecordType[];
6
6
  onChange?: (value: RecordType[], rowDoubleClicked?: boolean) => void;
7
7
  /**
@@ -26,7 +26,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
26
26
 
27
27
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
28
 
29
- import { Tabs, Button } from 'antd';
29
+ import { Tabs } from 'antd';
30
30
  import { get } from 'lodash';
31
31
  import React, { useEffect, useMemo, useRef, useState } from 'react';
32
32
  import DataGrid from "../DataGrid";
@@ -51,7 +51,10 @@ export default function SelectView(props) {
51
51
  dataSource = props.dataSource,
52
52
  rowFilter = props.rowFilter,
53
53
  loading = props.loading,
54
- readOnly = props.readOnly;
54
+ readOnly = props.readOnly,
55
+ defaultColDef = props.defaultColDef,
56
+ rowHeight = props.rowHeight,
57
+ cellDisplayFlex = props.cellDisplayFlex;
55
58
  var prefixCls = "".concat(PREFIX_CLS, "-select-view");
56
59
 
57
60
  var _useState = useState(value || emptyValue),
@@ -216,6 +219,9 @@ export default function SelectView(props) {
216
219
  handleChangeData([node.id], [node.data], true);
217
220
  }
218
221
  },
222
+ rowHeight: rowHeight,
223
+ defaultColDef: defaultColDef,
224
+ cellDisplayFlex: cellDisplayFlex,
219
225
  dataSource: rows,
220
226
  columns: columns,
221
227
  loading: loading,
@@ -233,6 +239,9 @@ export default function SelectView(props) {
233
239
  className: "".concat(prefixCls, "-body")
234
240
  }, /*#__PURE__*/React.createElement(DataGrid, {
235
241
  dataSource: data,
242
+ defaultColDef: defaultColDef,
243
+ rowHeight: rowHeight,
244
+ cellDisplayFlex: cellDisplayFlex,
236
245
  onDataSourceChange: setData,
237
246
  columns: mSelectedCols,
238
247
  rowKey: rowKey,
@@ -262,8 +271,7 @@ export default function SelectView(props) {
262
271
  tabBarGutter: 20,
263
272
  onChange: setTabFlag,
264
273
  tabBarExtraContent: {
265
- right: tabFlag === 'selected' && !readOnly ? /*#__PURE__*/React.createElement(Button, {
266
- type: "link",
274
+ right: tabFlag === 'selected' && !readOnly ? /*#__PURE__*/React.createElement("a", {
267
275
  onClick: handleClear
268
276
  }, "\u6E05\u7A7A") : null
269
277
  }
@@ -15,7 +15,7 @@
15
15
  }
16
16
 
17
17
  &-sider {
18
- width: 228px;
18
+ width: 200px;
19
19
  padding: @padding-md @padding-md @padding-md 0;
20
20
  overflow: auto;
21
21
  border-right: 1px solid @border-color-split;
package/es/index.d.ts CHANGED
@@ -29,7 +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 DropActions } from './components/DropActions';
32
+ export { default as Dropdown } from './components/Dropdown';
33
33
  export { default as SelectView } from './components/SelectView';
34
34
  export { default as DataGrid } from './components/DataGrid';
35
35
  export * from './components/DataGrid/typings';
package/es/index.js CHANGED
@@ -22,7 +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 DropActions } from "./components/DropActions";
25
+ export { default as Dropdown } from "./components/Dropdown";
26
26
  export { default as SelectView } from "./components/SelectView";
27
27
  export { default as DataGrid } from "./components/DataGrid";
28
28
  export * from "./components/DataGrid/typings";
@@ -168,7 +168,7 @@ a[title='站长统计'] {
168
168
  @input-padding-vertical-base: (
169
169
  round(((@input-height-base - @font-size-base * @line-height-base) / 2) * 10) / 10
170
170
  ) - @border-width-base;
171
- @input-disabled-color: fade(#333, 70);
171
+ @input-disabled-color: fade(#333, 50);
172
172
  @input-disabled-bg: #fff;
173
173
 
174
174
  .@{ant-prefix}-input-prefix,
@@ -189,7 +189,7 @@ a[title='站长统计'] {
189
189
  }
190
190
 
191
191
  &&-disabled &-suffix {
192
- color: fade(#333, 49);
192
+ color: fade(#333, 40);
193
193
  }
194
194
  }
195
195
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemon-fe/kits",
3
- "version": "1.0.0-163",
3
+ "version": "1.0.0-165",
4
4
  "scripts": {
5
5
  "start": "dumi dev",
6
6
  "docs:build": "dumi build",
@@ -1,15 +0,0 @@
1
- import type { PopoverProps } from 'antd';
2
- import type { ReactElement } from 'react';
3
- interface Props {
4
- actions: ({
5
- text: string | ReactElement;
6
- onClick: () => void;
7
- disabled?: boolean;
8
- } | null)[];
9
- overlayClassName?: string;
10
- placement?: PopoverProps['placement'];
11
- children?: ReactElement | null;
12
- trigger?: PopoverProps['trigger'];
13
- }
14
- export default function Dropover(props: Props): JSX.Element;
15
- export {};
@@ -1,55 +0,0 @@
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 { Popover } from 'antd';
16
- import classNames from 'classnames';
17
- import React, { useState } from 'react';
18
- import { PREFIX_CLS } from "../../constants";
19
- export default function Dropover(props) {
20
- var actions = props.actions,
21
- 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);
55
- }
@@ -1,13 +0,0 @@
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
- }
12
- }
13
- }