@lemon-fe/components 1.1.3-alpha.0 → 1.1.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.
- package/es/actions/index.d.ts +5 -2
- package/es/actions/index.js +41 -29
- package/es/filter/index.js +7 -2
- package/es/filter/typings.d.ts +5 -1
- package/es/styles/overrides.less +1 -0
- package/package.json +2 -2
package/es/actions/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type ReactElement } from 'react';
|
|
2
|
-
import type { CSSProperties } from 'react';
|
|
3
1
|
import { type ButtonProps } from 'antd';
|
|
2
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
3
|
+
import type { CSSProperties } from 'react';
|
|
4
4
|
interface ActionBtn extends ButtonProps {
|
|
5
5
|
text: string | ReactElement;
|
|
6
|
+
label?: ReactNode;
|
|
6
7
|
onClick?: () => void;
|
|
7
8
|
/**
|
|
8
9
|
* @deprecated
|
|
@@ -11,6 +12,7 @@ interface ActionBtn extends ButtonProps {
|
|
|
11
12
|
action?: () => void;
|
|
12
13
|
dropDown?: ({
|
|
13
14
|
text: string | ReactElement;
|
|
15
|
+
label?: ReactNode;
|
|
14
16
|
onClick?: () => void;
|
|
15
17
|
disabled?: boolean;
|
|
16
18
|
} | ReactElement | null)[] | ReactElement;
|
|
@@ -24,6 +26,7 @@ interface Props {
|
|
|
24
26
|
* @description 默认无限大
|
|
25
27
|
*/
|
|
26
28
|
maxShowCount?: number;
|
|
29
|
+
trackEventAttr?: string;
|
|
27
30
|
}
|
|
28
31
|
declare function Actions(props: Props): JSX.Element;
|
|
29
32
|
export default Actions;
|
package/es/actions/index.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["
|
|
3
|
-
function
|
|
4
|
-
function
|
|
5
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
2
|
+
var _excluded = ["dropDown", "text", "onClick", "action", "label"];
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
5
|
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
6
|
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; }
|
|
8
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
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
11
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
10
12
|
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."); }
|
|
11
13
|
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); }
|
|
12
14
|
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; }
|
|
13
15
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
14
16
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
|
-
import React, { Fragment, useState, isValidElement } from 'react';
|
|
16
17
|
import { Space, Dropdown, Menu, Button, Popover } from 'antd';
|
|
18
|
+
import React, { Fragment, useState, isValidElement } from 'react';
|
|
17
19
|
import classNames from 'classnames';
|
|
18
20
|
import { PREFIX_CLS } from "../constants";
|
|
19
21
|
import Icons from "../icons";
|
|
@@ -24,13 +26,21 @@ function Actions(props) {
|
|
|
24
26
|
_props$prefixCls = props.prefixCls,
|
|
25
27
|
prefixCls = _props$prefixCls === void 0 ? PREFIX_CLS : _props$prefixCls,
|
|
26
28
|
_props$maxShowCount = props.maxShowCount,
|
|
27
|
-
maxShowCount = _props$maxShowCount === void 0 ? Infinity : _props$maxShowCount
|
|
29
|
+
maxShowCount = _props$maxShowCount === void 0 ? Infinity : _props$maxShowCount,
|
|
30
|
+
_props$trackEventAttr = props.trackEventAttr,
|
|
31
|
+
trackEventAttr = _props$trackEventAttr === void 0 ? 'data-track-event' : _props$trackEventAttr;
|
|
28
32
|
var _useState = useState(false),
|
|
29
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
30
34
|
visible = _useState2[0],
|
|
31
35
|
setVisible = _useState2[1];
|
|
32
36
|
var visibleBtns = actions.slice(0, maxShowCount);
|
|
33
37
|
var collapsedBtns = actions.slice(maxShowCount);
|
|
38
|
+
var getTrackAttr = function getTrackAttr(text) {
|
|
39
|
+
if (typeof text === 'string') {
|
|
40
|
+
return _defineProperty({}, trackEventAttr, text);
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
};
|
|
34
44
|
return /*#__PURE__*/React.createElement("div", {
|
|
35
45
|
className: classNames("".concat(prefixCls, "-actions"), className),
|
|
36
46
|
style: style
|
|
@@ -46,18 +56,23 @@ function Actions(props) {
|
|
|
46
56
|
key: index
|
|
47
57
|
}, item);
|
|
48
58
|
}
|
|
49
|
-
var
|
|
50
|
-
dropDown = item.dropDown,
|
|
59
|
+
var dropDown = item.dropDown,
|
|
51
60
|
text = item.text,
|
|
52
61
|
onClick = item.onClick,
|
|
53
|
-
icon = item.icon,
|
|
54
62
|
action = item.action,
|
|
63
|
+
label = item.label,
|
|
55
64
|
rest = _objectWithoutProperties(item, _excluded);
|
|
65
|
+
var trackAttr = getTrackAttr(text);
|
|
56
66
|
if ( /*#__PURE__*/isValidElement(text)) {
|
|
57
67
|
return /*#__PURE__*/React.createElement(Fragment, {
|
|
58
68
|
key: index
|
|
59
69
|
}, text);
|
|
60
70
|
}
|
|
71
|
+
if (label !== undefined) {
|
|
72
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
73
|
+
key: index
|
|
74
|
+
}, trackAttr), label);
|
|
75
|
+
}
|
|
61
76
|
var handleClick = onClick || action;
|
|
62
77
|
if (dropDown !== undefined) {
|
|
63
78
|
var overlay;
|
|
@@ -65,18 +80,19 @@ function Actions(props) {
|
|
|
65
80
|
overlay = /*#__PURE__*/React.createElement(Menu, {
|
|
66
81
|
items: dropDown.filter(Boolean).map(function (subItem, idx) {
|
|
67
82
|
if ( /*#__PURE__*/isValidElement(subItem)) {
|
|
83
|
+
console.error('请使用MenuItemType的label属性');
|
|
68
84
|
return {
|
|
69
85
|
label: subItem,
|
|
70
86
|
key: idx
|
|
71
87
|
};
|
|
72
88
|
}
|
|
73
89
|
var target = subItem;
|
|
74
|
-
return {
|
|
75
|
-
label: target.text,
|
|
90
|
+
return _objectSpread({
|
|
91
|
+
label: target.label || target.text,
|
|
76
92
|
key: idx,
|
|
77
93
|
disabled: target.disabled,
|
|
78
94
|
onClick: target.onClick
|
|
79
|
-
};
|
|
95
|
+
}, getTrackAttr(target.text));
|
|
80
96
|
})
|
|
81
97
|
});
|
|
82
98
|
} else {
|
|
@@ -85,33 +101,30 @@ function Actions(props) {
|
|
|
85
101
|
if (handleClick !== undefined) {
|
|
86
102
|
return /*#__PURE__*/React.createElement(Dropdown.Button, _extends({
|
|
87
103
|
key: text,
|
|
88
|
-
disabled: disabled,
|
|
104
|
+
disabled: rest.disabled,
|
|
89
105
|
overlay: overlay,
|
|
90
106
|
onClick: handleClick,
|
|
91
107
|
trigger: ['click'],
|
|
92
108
|
overlayStyle: {
|
|
93
109
|
minWidth: 80
|
|
94
110
|
},
|
|
95
|
-
buttonsRender: function buttonsRender(
|
|
96
|
-
var
|
|
97
|
-
leftBtn =
|
|
111
|
+
buttonsRender: function buttonsRender(_ref2) {
|
|
112
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
|
113
|
+
leftBtn = _ref3[0];
|
|
98
114
|
return [leftBtn, /*#__PURE__*/React.createElement(Button, {
|
|
99
115
|
icon: /*#__PURE__*/React.createElement(Icons.More, null),
|
|
100
116
|
type: rest.type,
|
|
101
117
|
key: "more"
|
|
102
118
|
})];
|
|
103
119
|
}
|
|
104
|
-
}, rest), text);
|
|
120
|
+
}, rest), /*#__PURE__*/React.createElement("span", trackAttr, text));
|
|
105
121
|
}
|
|
106
122
|
return /*#__PURE__*/React.createElement(Dropdown, {
|
|
107
123
|
key: text,
|
|
108
|
-
disabled: disabled,
|
|
124
|
+
disabled: rest.disabled,
|
|
109
125
|
overlay: overlay,
|
|
110
126
|
trigger: ['click']
|
|
111
|
-
}, /*#__PURE__*/React.createElement(Button,
|
|
112
|
-
disabled: disabled,
|
|
113
|
-
icon: icon
|
|
114
|
-
}, rest), text, /*#__PURE__*/React.createElement(Icons.Down, {
|
|
127
|
+
}, /*#__PURE__*/React.createElement(Button, rest, text, /*#__PURE__*/React.createElement(Icons.Down, {
|
|
115
128
|
style: {
|
|
116
129
|
opacity: 0.7
|
|
117
130
|
}
|
|
@@ -119,10 +132,8 @@ function Actions(props) {
|
|
|
119
132
|
}
|
|
120
133
|
return /*#__PURE__*/React.createElement(Button, _extends({
|
|
121
134
|
key: text,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
icon: icon
|
|
125
|
-
}, rest), text);
|
|
135
|
+
onClick: handleClick
|
|
136
|
+
}, trackAttr, rest), text);
|
|
126
137
|
}), collapsedBtns.length > 0 ? /*#__PURE__*/React.createElement(Popover, {
|
|
127
138
|
placement: "bottomRight",
|
|
128
139
|
overlayClassName: "".concat(prefixCls, "-actions-popover"),
|
|
@@ -139,8 +150,9 @@ function Actions(props) {
|
|
|
139
150
|
}, item);
|
|
140
151
|
}
|
|
141
152
|
var disabled = item.disabled;
|
|
142
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
143
|
-
className: classNames("".concat(prefixCls, "-actions-popover-item"), _defineProperty({}, "".concat(prefixCls, "-actions-popover-item-disabled"), disabled))
|
|
153
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
154
|
+
className: classNames("".concat(prefixCls, "-actions-popover-item"), _defineProperty({}, "".concat(prefixCls, "-actions-popover-item-disabled"), disabled))
|
|
155
|
+
}, getTrackAttr(item.text), {
|
|
144
156
|
key: index,
|
|
145
157
|
onClick: function onClick() {
|
|
146
158
|
if (!disabled) {
|
|
@@ -151,7 +163,7 @@ function Actions(props) {
|
|
|
151
163
|
}
|
|
152
164
|
}
|
|
153
165
|
}
|
|
154
|
-
}, item.text);
|
|
166
|
+
}), item.text);
|
|
155
167
|
})
|
|
156
168
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
157
169
|
icon: /*#__PURE__*/React.createElement(Icons.More, null)
|
package/es/filter/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import Icons from "../icons";
|
|
|
27
27
|
import InputNumber from "../input-number";
|
|
28
28
|
import TabBar from "../tab-bar";
|
|
29
29
|
import { prefixClassName } from "../utils";
|
|
30
|
-
import { useDebounce, useRequest } from '@lemon-fe/hooks';
|
|
30
|
+
import { useDebounce, useRequest, useUpdateEffect } from '@lemon-fe/hooks';
|
|
31
31
|
import { Button, Checkbox, Form, Input, Popover, Space, Modal, message, Select, Empty } from 'antd';
|
|
32
32
|
import classNames from 'classnames';
|
|
33
33
|
import ResizeObserver from 'rc-resize-observer';
|
|
@@ -107,7 +107,9 @@ function Filter(props) {
|
|
|
107
107
|
_props$preserveFields = props.preserveFields,
|
|
108
108
|
preserveFields = _props$preserveFields === void 0 ? true : _props$preserveFields,
|
|
109
109
|
legacyReset = props.legacyReset,
|
|
110
|
-
componentOptions = props.componentOptions
|
|
110
|
+
componentOptions = props.componentOptions,
|
|
111
|
+
_props$filterDependen = props.filterDependencies,
|
|
112
|
+
filterDependencies = _props$filterDependen === void 0 ? [] : _props$filterDependen;
|
|
111
113
|
var prefix = prefixClassName('filter');
|
|
112
114
|
var emptyValue = useMemo(function () {
|
|
113
115
|
return Object.fromEntries(data.map(function (item) {
|
|
@@ -191,6 +193,9 @@ function Filter(props) {
|
|
|
191
193
|
form.setFieldsValue(value);
|
|
192
194
|
}
|
|
193
195
|
}, [value]);
|
|
196
|
+
useUpdateEffect(function () {
|
|
197
|
+
form.submit();
|
|
198
|
+
}, filterDependencies);
|
|
194
199
|
var handleChangeKeywords = useDebounce(setKeywords, 300);
|
|
195
200
|
var toggleModal = function toggleModal() {
|
|
196
201
|
setShowModal(function (prev) {
|
package/es/filter/typings.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode, DependencyList } from 'react';
|
|
2
2
|
import type { FormInstance } from 'antd';
|
|
3
3
|
|
|
4
4
|
export interface FilterItemType<T = any> {
|
|
@@ -61,6 +61,10 @@ export interface FilterProps<T extends Record<string, any> = Record<string, any>
|
|
|
61
61
|
*/
|
|
62
62
|
legacyReset?: true;
|
|
63
63
|
componentOptions?: ComponentOption[];
|
|
64
|
+
/**
|
|
65
|
+
* @description 自动触发过滤的依赖
|
|
66
|
+
*/
|
|
67
|
+
filterDependencies?: DependencyList;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
export interface ComponentOption {
|
package/es/styles/overrides.less
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lemon-fe/components",
|
|
3
|
-
"version": "1.1.3
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "ISC",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"registry": "https://registry.npmjs.org"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "1d20795e81a4ee2bef8b7dd7e81ef53dcbfe2bed"
|
|
66
66
|
}
|