@qn-pandora/pandora-component 4.0.1 → 4.0.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.
Files changed (35) hide show
  1. package/CHANGELOG.json +40 -0
  2. package/CHANGELOG.md +17 -1
  3. package/es/components/AutoComplete/index.js +21 -1
  4. package/es/components/DateTimePicker/transform.d.ts +4 -1
  5. package/es/components/DateTimePicker/transform.js +2 -2
  6. package/es/components/Drawer/index.d.ts +30 -2
  7. package/es/components/Drawer/index.js +165 -5
  8. package/es/components/Drawer/style.css +18 -1
  9. package/es/components/Drawer/style.less +23 -1
  10. package/es/components/Selector/SelectorWidthChildren.d.ts +15 -0
  11. package/es/components/Selector/SelectorWidthChildren.js +59 -0
  12. package/es/components/Selector/index.d.ts +2 -0
  13. package/es/components/Selector/index.js +17 -3
  14. package/es/components/TreeSelector/index.js +1 -1
  15. package/es/index.css +4414 -4397
  16. package/es/index.d.ts +1 -0
  17. package/es/index.js +1 -0
  18. package/es/index.less +15 -15
  19. package/lib/components/AutoComplete/index.js +21 -1
  20. package/lib/components/DateTimePicker/transform.d.ts +4 -1
  21. package/lib/components/DateTimePicker/transform.js +2 -0
  22. package/lib/components/Drawer/index.d.ts +30 -2
  23. package/lib/components/Drawer/index.js +164 -12
  24. package/lib/components/Drawer/style.css +18 -1
  25. package/lib/components/Drawer/style.less +23 -1
  26. package/lib/components/Selector/SelectorWidthChildren.d.ts +15 -0
  27. package/lib/components/Selector/SelectorWidthChildren.js +72 -0
  28. package/lib/components/Selector/index.d.ts +2 -0
  29. package/lib/components/Selector/index.js +16 -2
  30. package/lib/components/TreeSelector/index.js +1 -1
  31. package/lib/index.css +2675 -2658
  32. package/lib/index.d.ts +1 -0
  33. package/lib/index.js +2 -0
  34. package/lib/index.less +12 -12
  35. package/package.json +3 -3
package/CHANGELOG.json CHANGED
@@ -1,6 +1,46 @@
1
1
  {
2
2
  "name": "@qn-pandora/pandora-component",
3
3
  "entries": [
4
+ {
5
+ "version": "4.0.3",
6
+ "tag": "@qn-pandora/pandora-component_v4.0.3",
7
+ "date": "Tue, 10 Jan 2023 03:03:58 GMT",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "2023-01-10 发布"
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.0.5` to `^3.0.6`"
17
+ },
18
+ {
19
+ "comment": "Updating dependency \"@qn-pandora/pandora-tools\" from `^2.0.4` to `^2.0.5`"
20
+ }
21
+ ]
22
+ }
23
+ },
24
+ {
25
+ "version": "4.0.2",
26
+ "tag": "@qn-pandora/pandora-component_v4.0.2",
27
+ "date": "Tue, 29 Nov 2022 03:37:07 GMT",
28
+ "comments": {
29
+ "patch": [
30
+ {
31
+ "comment": "2022.11.29发布"
32
+ }
33
+ ],
34
+ "dependency": [
35
+ {
36
+ "comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.0.4` to `^3.0.5`"
37
+ },
38
+ {
39
+ "comment": "Updating dependency \"@qn-pandora/pandora-tools\" from `^2.0.3` to `^2.0.4`"
40
+ }
41
+ ]
42
+ }
43
+ },
4
44
  {
5
45
  "version": "4.0.1",
6
46
  "tag": "@qn-pandora/pandora-component_v4.0.1",
package/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  # Change Log - @qn-pandora/pandora-component
2
2
 
3
- This log was last generated on Mon, 17 Oct 2022 06:49:55 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 10 Jan 2023 03:03:58 GMT and should not be manually modified.
4
+
5
+ ## 4.0.3
6
+
7
+ Tue, 10 Jan 2023 03:03:58 GMT
8
+
9
+ ### Patches
10
+
11
+ - 2023-01-10 发布
12
+
13
+ ## 4.0.2
14
+
15
+ Tue, 29 Nov 2022 03:37:07 GMT
16
+
17
+ ### Patches
18
+
19
+ - 2022.11.29 发布
4
20
 
5
21
  ## 4.0.1
6
22
 
@@ -22,12 +22,32 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  };
23
23
  import * as React from 'react';
24
24
  import classnames from 'classnames';
25
+ import { includes, isString } from 'lodash';
25
26
  import { AutoComplete as BaseAutoComplete } from 'antd';
26
27
  import { SDK_PREFIX } from '../../constants/style';
27
28
  import debounceWrapper from '../../hoc/debounce';
28
29
  export function AutoComplete(props) {
29
30
  var _a;
30
31
  var className = props.className, dropdownClassName = props.dropdownClassName, ellipsis = props.ellipsis, other = __rest(props, ["className", "dropdownClassName", "ellipsis"]);
31
- return (React.createElement(BaseAutoComplete, __assign({ className: classnames(className, SDK_PREFIX + "-auto-complete", SDK_PREFIX + "-selector"), dropdownClassName: classnames(SDK_PREFIX + "-selector-dropdown", (_a = {}, _a[SDK_PREFIX + "-selector-no-ellipsis"] = !ellipsis, _a), dropdownClassName) }, other)));
32
+ var filterOption = React.useCallback(function (inputValue, option) {
33
+ var prefix = (inputValue === null || inputValue === void 0 ? void 0 : inputValue.toLowerCase()) || '';
34
+ var _a = option || {}, value = _a.value, title = _a.title, children = _a.children, label = _a.label;
35
+ return children
36
+ ? isString(children)
37
+ ? includes(children.toLowerCase(), prefix)
38
+ : true
39
+ : label
40
+ ? isString(label)
41
+ ? includes(label.toLowerCase(), prefix)
42
+ : true
43
+ : title
44
+ ? isString(title)
45
+ ? includes(title.toLowerCase(), prefix)
46
+ : true
47
+ : isString(value)
48
+ ? includes(value.toLowerCase(), prefix)
49
+ : true;
50
+ }, []);
51
+ return (React.createElement(BaseAutoComplete, __assign({ className: classnames(className, SDK_PREFIX + "-auto-complete", SDK_PREFIX + "-selector"), dropdownClassName: classnames(SDK_PREFIX + "-selector-dropdown", (_a = {}, _a[SDK_PREFIX + "-selector-no-ellipsis"] = !ellipsis, _a), dropdownClassName), filterOption: filterOption, showSearch: true }, other)));
32
52
  }
33
53
  export default debounceWrapper(AutoComplete);
@@ -1,6 +1,9 @@
1
- import { ITimeRange, ITime } from './constants';
1
+ import moment from 'moment';
2
+ import { ITimeRange, ITime, TimeShiftUnit } from './constants';
2
3
  export declare function transformToTime(time: ITimeRange): ITime;
3
4
  export declare function transformToTimeRange(time: ITime): ITimeRange;
5
+ export declare function getTimeShiftUnit(time: string): TimeShiftUnit.Second | TimeShiftUnit;
6
+ export declare function getRelativeTime(timeShift: string, time: moment.Moment): moment.Moment | undefined;
4
7
  export declare function calcFullTime(time?: ITimeRange): {
5
8
  start: number | undefined;
6
9
  end: number | undefined;
@@ -33,7 +33,7 @@ export function transformToTimeRange(time) {
33
33
  quarterTime: time.quarterTime
34
34
  };
35
35
  }
36
- function getTimeShiftUnit(time) {
36
+ export function getTimeShiftUnit(time) {
37
37
  var e_1, _a;
38
38
  try {
39
39
  for (var TimeShiftUnitOptions_1 = __values(TimeShiftUnitOptions), TimeShiftUnitOptions_1_1 = TimeShiftUnitOptions_1.next(); !TimeShiftUnitOptions_1_1.done; TimeShiftUnitOptions_1_1 = TimeShiftUnitOptions_1.next()) {
@@ -52,7 +52,7 @@ function getTimeShiftUnit(time) {
52
52
  }
53
53
  return TimeShiftUnit.Second;
54
54
  }
55
- function getRelativeTime(timeShift, time) {
55
+ export function getRelativeTime(timeShift, time) {
56
56
  var timeShiftValue = parseFloat(timeShift) || 0;
57
57
  var timeShiftUnit = getTimeShiftUnit(timeShift);
58
58
  if (time) {
@@ -1,4 +1,5 @@
1
- import * as React from 'react';
1
+ /// <reference types="lodash" />
2
+ import React from 'react';
2
3
  import { DrawerProps } from 'antd/es/drawer';
3
4
  import { Overwrite } from '../../models';
4
5
  declare type EventType = React.KeyboardEvent<HTMLDivElement> | React.MouseEvent<HTMLDivElement | HTMLButtonElement>;
@@ -52,8 +53,28 @@ export declare type IDrawerProps = Overwrite<DrawerProps, {
52
53
  getContainer?: string | HTMLElement | getContainerFunc | false;
53
54
  onClose?: (e: EventType) => void;
54
55
  afterVisibleChange?: (visible: boolean) => void;
56
+ /**
57
+ * 是否允许拖拽
58
+ */
59
+ canDrag?: boolean;
60
+ closeIconPlacement?: 'left' | 'right';
55
61
  }>;
56
- export declare function Drawer(props: React.PropsWithChildren<IDrawerProps>): JSX.Element;
62
+ export declare class Drawer extends React.Component<React.PropsWithChildren<IDrawerProps>, any> {
63
+ isResizing: boolean;
64
+ realWidth: string | number | undefined;
65
+ throttleMouseMove: import("lodash").DebouncedFunc<(e: any) => void>;
66
+ get closable(): boolean | undefined;
67
+ get extra(): {} | null | undefined;
68
+ setIsResizing(isResizing?: boolean): void;
69
+ setRealWidth(realWidth: string | number): void;
70
+ onMouseDown(): void;
71
+ onMouseUp(): void;
72
+ onMouseMove(e: any): void;
73
+ componentDidMount(): void;
74
+ UNSAFE_componentWillUpdate(nextProps: Readonly<React.PropsWithChildren<IDrawerProps>>): void;
75
+ componentWillUnmount(): void;
76
+ render(): JSX.Element;
77
+ }
57
78
  declare const _default: (props: {
58
79
  className?: string | undefined;
59
80
  /**
@@ -103,7 +124,14 @@ declare const _default: (props: {
103
124
  getContainer?: string | false | HTMLElement | getContainerFunc | undefined;
104
125
  onClose?: ((e: EventType) => void) | undefined;
105
126
  afterVisibleChange?: ((visible: boolean) => void) | undefined;
127
+ /**
128
+ * 是否允许拖拽
129
+ */
130
+ canDrag?: boolean | undefined;
131
+ closeIconPlacement?: import("antd/es/collapse/Collapse").ExpandIconPosition;
106
132
  } & Pick<DrawerProps, "style" | "autoFocus" | "size" | "prefixCls" | "footer" | "extra" | "bodyStyle" | "forceRender" | "keyboard" | "destroyOnClose" | "closeIcon" | "drawerStyle" | "headerStyle" | "contentWrapperStyle" | "push" | "handler" | "footerStyle" | "level" | "levelMove"> & {
133
+ children?: React.ReactNode;
134
+ } & {
107
135
  bodyStyle?: React.CSSProperties | undefined;
108
136
  children: React.ReactNode;
109
137
  }) => JSX.Element;
@@ -1,3 +1,16 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ extendStatics(d, b);
10
+ function __() { this.constructor = d; }
11
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
12
+ };
13
+ })();
1
14
  var __assign = (this && this.__assign) || function () {
2
15
  __assign = Object.assign || function(t) {
3
16
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -9,6 +22,15 @@ var __assign = (this && this.__assign) || function () {
9
22
  };
10
23
  return __assign.apply(this, arguments);
11
24
  };
25
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
26
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
27
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
28
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
29
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
30
+ };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
12
34
  var __rest = (this && this.__rest) || function (s, e) {
13
35
  var t = {};
14
36
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -20,13 +42,151 @@ var __rest = (this && this.__rest) || function (s, e) {
20
42
  }
21
43
  return t;
22
44
  };
23
- import * as React from 'react';
45
+ import React from 'react';
24
46
  import classnames from 'classnames';
47
+ import { throttle } from 'lodash';
48
+ import { observer } from 'mobx-react';
49
+ import { observable, action, computed } from 'mobx';
25
50
  import { Drawer as BaseDrawer } from 'antd';
51
+ import { CloseOutlined } from '@ant-design/icons';
26
52
  import { SDK_PREFIX } from '../../constants/style';
27
53
  import popContainerWrapper from '../../hoc/popContainer';
28
- export function Drawer(props) {
29
- var width = props.width, className = props.className, other = __rest(props, ["width", "className"]);
30
- return (React.createElement(BaseDrawer, __assign({ className: classnames(SDK_PREFIX + "-drawer", className), width: width || 'auto', zIndex: 1200 }, other)));
31
- }
54
+ import bind from '../../utils/bind';
55
+ var MAX_WIDTH = 6000;
56
+ var MIN_WIDTH = 300;
57
+ var Drawer = /** @class */ (function (_super) {
58
+ __extends(Drawer, _super);
59
+ function Drawer() {
60
+ var _this = _super !== null && _super.apply(this, arguments) || this;
61
+ _this.isResizing = false;
62
+ _this.realWidth = _this.props.width;
63
+ _this.throttleMouseMove = throttle(function (e) { return _this.onMouseMove(e); }, 100);
64
+ return _this;
65
+ }
66
+ Object.defineProperty(Drawer.prototype, "closable", {
67
+ get: function () {
68
+ if (this.props.closable &&
69
+ this.props.closeIconPlacement &&
70
+ this.props.closeIconPlacement === 'right') {
71
+ return false;
72
+ }
73
+ return this.props.closable;
74
+ },
75
+ enumerable: true,
76
+ configurable: true
77
+ });
78
+ Object.defineProperty(Drawer.prototype, "extra", {
79
+ get: function () {
80
+ if (this.props.closable && this.props.closeIconPlacement === 'right') {
81
+ return (React.createElement(React.Fragment, null,
82
+ this.props.extra,
83
+ React.createElement(CloseOutlined, { onClick: this.props.onClose, className: SDK_PREFIX + "-drawer-right-close-icon" })));
84
+ }
85
+ return this.props.extra;
86
+ },
87
+ enumerable: true,
88
+ configurable: true
89
+ });
90
+ Drawer.prototype.setIsResizing = function (isResizing) {
91
+ if (isResizing === void 0) { isResizing = false; }
92
+ this.isResizing = isResizing;
93
+ };
94
+ Drawer.prototype.setRealWidth = function (realWidth) {
95
+ this.realWidth = realWidth;
96
+ };
97
+ Drawer.prototype.onMouseDown = function () {
98
+ this.setIsResizing(true);
99
+ };
100
+ Drawer.prototype.onMouseUp = function () {
101
+ this.setIsResizing(false);
102
+ };
103
+ Drawer.prototype.onMouseMove = function (e) {
104
+ if (this.isResizing) {
105
+ var offsetRight = document.body.offsetWidth - (e.clientX - document.body.offsetLeft);
106
+ if (offsetRight > MIN_WIDTH && offsetRight < MAX_WIDTH) {
107
+ this.setRealWidth(offsetRight);
108
+ }
109
+ }
110
+ };
111
+ Drawer.prototype.componentDidMount = function () {
112
+ if (this.props.canDrag) {
113
+ document.addEventListener('mousemove', this.throttleMouseMove);
114
+ document.addEventListener('mouseup', this.onMouseUp);
115
+ }
116
+ };
117
+ Drawer.prototype.UNSAFE_componentWillUpdate = function (nextProps) {
118
+ if (nextProps.canDrag && !this.props.canDrag) {
119
+ document.addEventListener('mousemove', this.throttleMouseMove);
120
+ document.addEventListener('mouseup', this.onMouseUp);
121
+ }
122
+ };
123
+ Drawer.prototype.componentWillUnmount = function () {
124
+ document.removeEventListener('mousemove', this.throttleMouseMove);
125
+ document.removeEventListener('mouseup', this.onMouseUp);
126
+ };
127
+ Drawer.prototype.render = function () {
128
+ var _a;
129
+ var _b = this.props, width = _b.width, className = _b.className, children = _b.children, canDrag = _b.canDrag, visible = _b.visible, closable = _b.closable, extra = _b.extra, other = __rest(_b, ["width", "className", "children", "canDrag", "visible", "closable", "extra"]);
130
+ return (React.createElement(BaseDrawer, __assign({ className: classnames(SDK_PREFIX + "-drawer", className, (_a = {},
131
+ _a[SDK_PREFIX + "-drawer-no-mask"] = this.props.mask === false,
132
+ _a)), width: this.realWidth || 'auto', zIndex: 1200, visible: visible, closable: this.closable, extra: this.extra }, other),
133
+ canDrag && (React.createElement("div", { className: SDK_PREFIX + "-scroll-handler", onMouseDown: this.onMouseDown })),
134
+ children));
135
+ };
136
+ __decorate([
137
+ observable,
138
+ __metadata("design:type", Object)
139
+ ], Drawer.prototype, "isResizing", void 0);
140
+ __decorate([
141
+ observable,
142
+ __metadata("design:type", Object)
143
+ ], Drawer.prototype, "realWidth", void 0);
144
+ __decorate([
145
+ computed,
146
+ __metadata("design:type", Object),
147
+ __metadata("design:paramtypes", [])
148
+ ], Drawer.prototype, "closable", null);
149
+ __decorate([
150
+ computed,
151
+ __metadata("design:type", Object),
152
+ __metadata("design:paramtypes", [])
153
+ ], Drawer.prototype, "extra", null);
154
+ __decorate([
155
+ bind,
156
+ action,
157
+ __metadata("design:type", Function),
158
+ __metadata("design:paramtypes", [Object]),
159
+ __metadata("design:returntype", void 0)
160
+ ], Drawer.prototype, "setIsResizing", null);
161
+ __decorate([
162
+ bind,
163
+ action,
164
+ __metadata("design:type", Function),
165
+ __metadata("design:paramtypes", [Object]),
166
+ __metadata("design:returntype", void 0)
167
+ ], Drawer.prototype, "setRealWidth", null);
168
+ __decorate([
169
+ bind,
170
+ __metadata("design:type", Function),
171
+ __metadata("design:paramtypes", []),
172
+ __metadata("design:returntype", void 0)
173
+ ], Drawer.prototype, "onMouseDown", null);
174
+ __decorate([
175
+ bind,
176
+ __metadata("design:type", Function),
177
+ __metadata("design:paramtypes", []),
178
+ __metadata("design:returntype", void 0)
179
+ ], Drawer.prototype, "onMouseUp", null);
180
+ __decorate([
181
+ bind,
182
+ __metadata("design:type", Function),
183
+ __metadata("design:paramtypes", [Object]),
184
+ __metadata("design:returntype", void 0)
185
+ ], Drawer.prototype, "onMouseMove", null);
186
+ Drawer = __decorate([
187
+ observer
188
+ ], Drawer);
189
+ return Drawer;
190
+ }(React.Component));
191
+ export { Drawer };
32
192
  export default popContainerWrapper(Drawer);
@@ -259,7 +259,7 @@
259
259
  }
260
260
  .pandora-sdk-drawer .ant-drawer-content-wrapper {
261
261
  width: 50%;
262
- min-width: 600px;
262
+ min-width: 300px;
263
263
  }
264
264
  .pandora-sdk-drawer .ant-drawer-content > div {
265
265
  position: relative;
@@ -269,3 +269,20 @@
269
269
  height: 60px;
270
270
  line-height: 60px;
271
271
  }
272
+ .pandora-sdk-drawer-no-mask .ant-drawer-content-wrapper {
273
+ width: 100%;
274
+ }
275
+ .pandora-sdk-scroll-handler {
276
+ position: absolute;
277
+ width: 5px;
278
+ padding: 4px 0 0;
279
+ top: 0;
280
+ left: 0;
281
+ bottom: 0;
282
+ z-index: 100;
283
+ cursor: ew-resize;
284
+ }
285
+ .pandora-sdk-drawer-right-close-icon {
286
+ margin-left: 8px;
287
+ font-size: 16px;
288
+ }
@@ -4,7 +4,7 @@
4
4
  .@{sdk-prefix}-drawer {
5
5
  .@{ant-prefix}-drawer-content-wrapper {
6
6
  width: 50%;
7
- min-width: 600px;
7
+ min-width: 300px;
8
8
  }
9
9
  .@{ant-prefix}-drawer-content > div {
10
10
  position: relative;
@@ -15,3 +15,25 @@
15
15
  line-height: 60px;
16
16
  }
17
17
  }
18
+
19
+ .@{sdk-prefix}-drawer-no-mask {
20
+ .@{ant-prefix}-drawer-content-wrapper {
21
+ width: 100%;
22
+ }
23
+ }
24
+
25
+ .@{sdk-prefix}-scroll-handler {
26
+ position: absolute;
27
+ width: 5px;
28
+ padding: 4px 0 0;
29
+ top: 0;
30
+ left: 0;
31
+ bottom: 0;
32
+ z-index: 100;
33
+ cursor: ew-resize;
34
+ }
35
+
36
+ .@{sdk-prefix}-drawer-right-close-icon {
37
+ margin-left: 8px;
38
+ font-size: 16px;
39
+ }
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { ISelectorProps, SelectValue } from './index';
3
+ declare type IValue = string | number;
4
+ export interface ISelectorOption {
5
+ key?: string;
6
+ text: string | React.ReactNode;
7
+ value: IValue;
8
+ disabled?: boolean;
9
+ filterText?: string;
10
+ }
11
+ export interface ISelectorWidthChildrenProps<VT> extends ISelectorProps<VT> {
12
+ options?: ISelectorOption[];
13
+ }
14
+ export default function SelectorWidthChildren<VT extends SelectValue>(props: ISelectorWidthChildrenProps<VT>): JSX.Element;
15
+ export {};
@@ -0,0 +1,59 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __rest = (this && this.__rest) || function (s, e) {
13
+ var t = {};
14
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
+ t[p] = s[p];
16
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
+ t[p[i]] = s[p[i]];
20
+ }
21
+ return t;
22
+ };
23
+ var __read = (this && this.__read) || function (o, n) {
24
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25
+ if (!m) return o;
26
+ var i = m.call(o), r, ar = [], e;
27
+ try {
28
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29
+ }
30
+ catch (error) { e = { error: error }; }
31
+ finally {
32
+ try {
33
+ if (r && !r.done && (m = i["return"])) m.call(i);
34
+ }
35
+ finally { if (e) throw e.error; }
36
+ }
37
+ return ar;
38
+ };
39
+ import React, { useEffect, useMemo, useState } from 'react';
40
+ import { includes } from 'lodash';
41
+ import Selector from './index';
42
+ // 下拉选项的是element时用于筛选过滤options
43
+ export default function SelectorWidthChildren(props) {
44
+ var _a = __read(useState(''), 2), prefix = _a[0], setPrefix = _a[1];
45
+ var options = props.options, rest = __rest(props, ["options"]);
46
+ useEffect(function () {
47
+ setPrefix('');
48
+ }, []);
49
+ var filterOptions = useMemo(function () {
50
+ var search = prefix.toLowerCase();
51
+ return prefix && options
52
+ ? options.filter(function (option) {
53
+ return option.filterText &&
54
+ includes(option.filterText.toLowerCase(), search);
55
+ })
56
+ : options;
57
+ }, [prefix, options]);
58
+ return (React.createElement(Selector, __assign({}, rest, { onSearch: setPrefix, searchValue: prefix, options: filterOptions, isCustomFilter: true })));
59
+ }
@@ -52,6 +52,7 @@ export interface ISelectorProps<VT> extends Omit<SelectProps<VT>, 'options'> {
52
52
  * 下拉选项超出时用 '...' 来表示,默认 true
53
53
  */
54
54
  ellipsis?: boolean;
55
+ isCustomFilter?: boolean;
55
56
  }
56
57
  /**
57
58
  * 下拉选择组件封装
@@ -64,5 +65,6 @@ export default class Selector<VT extends SelectValue> extends React.Component<IS
64
65
  ellipsis: boolean;
65
66
  };
66
67
  handleCreateClick(e: any): void;
68
+ handleFilter(inputValue: string, option: any): boolean;
67
69
  render(): JSX.Element;
68
70
  }
@@ -43,7 +43,7 @@ var __rest = (this && this.__rest) || function (s, e) {
43
43
  return t;
44
44
  };
45
45
  import * as React from 'react';
46
- import { isArray, concat, isNumber, toString } from 'lodash';
46
+ import { isArray, concat, isNumber, toString, isString } from 'lodash';
47
47
  import classnames from 'classnames';
48
48
  import { Checkbox, Select } from 'antd';
49
49
  import PropTypes from 'prop-types';
@@ -117,10 +117,18 @@ var Selector = /** @class */ (function (_super) {
117
117
  createOptionClick();
118
118
  }
119
119
  };
120
+ Selector.prototype.handleFilter = function (inputValue, option) {
121
+ if (this.props.isCustomFilter) {
122
+ return true;
123
+ }
124
+ return isString(option === null || option === void 0 ? void 0 : option.children)
125
+ ? (option === null || option === void 0 ? void 0 : option.children.toLowerCase().indexOf(inputValue.toLowerCase())) >= 0
126
+ : true;
127
+ };
120
128
  Selector.prototype.render = function () {
121
129
  var _a;
122
- var _b = this.props, options = _b.options, groupOptions = _b.groupOptions, createOptionText = _b.createOptionText, selectAllOptionText = _b.selectAllOptionText, className = _b.className, dropdownClassName = _b.dropdownClassName, getPopupContainer = _b.getPopupContainer, ellipsis = _b.ellipsis, _c = _b.showArrow, showArrow = _c === void 0 ? true : _c, otherProps = __rest(_b, ["options", "groupOptions", "createOptionText", "selectAllOptionText", "className", "dropdownClassName", "getPopupContainer", "ellipsis", "showArrow"]);
123
- return (React.createElement(Select, __assign({ className: classnames(SDK_PREFIX + "-selector", className), dropdownClassName: classnames(SDK_PREFIX + "-selector-dropdown", (_a = {}, _a[SDK_PREFIX + "-selector-no-ellipsis"] = !ellipsis, _a), dropdownClassName), getPopupContainer: getPopupContainer || this.context.getPopupContainer }, otherProps, { removeIcon: React.createElement(Icon, { type: "close-circle", theme: "filled", className: SDK_PREFIX + "-close-icon" }), showArrow: showArrow }),
130
+ var _b = this.props, options = _b.options, groupOptions = _b.groupOptions, createOptionText = _b.createOptionText, selectAllOptionText = _b.selectAllOptionText, className = _b.className, dropdownClassName = _b.dropdownClassName, getPopupContainer = _b.getPopupContainer, ellipsis = _b.ellipsis, _c = _b.showArrow, showArrow = _c === void 0 ? true : _c, isCustomFilter = _b.isCustomFilter, otherProps = __rest(_b, ["options", "groupOptions", "createOptionText", "selectAllOptionText", "className", "dropdownClassName", "getPopupContainer", "ellipsis", "showArrow", "isCustomFilter"]);
131
+ return (React.createElement(Select, __assign({ className: classnames(SDK_PREFIX + "-selector", className), dropdownClassName: classnames(SDK_PREFIX + "-selector-dropdown", (_a = {}, _a[SDK_PREFIX + "-selector-no-ellipsis"] = !ellipsis, _a), dropdownClassName), getPopupContainer: getPopupContainer || this.context.getPopupContainer, filterOption: this.handleFilter }, otherProps, { removeIcon: React.createElement(Icon, { type: "close-circle", theme: "filled", className: SDK_PREFIX + "-close-icon" }), showArrow: showArrow, showSearch: true }),
124
132
  createOptionText && (React.createElement(Select.Option, __assign({}, { className: SDK_PREFIX + "-selector-create-option" }, { key: "selector_create", disabled: true }, noneValueOption),
125
133
  React.createElement("a", { className: SDK_PREFIX + "-selector-create-lint", onClick: this.handleCreateClick }, createOptionText))),
126
134
  selectAllOptionText && (React.createElement(Select.Option, __assign({}, { className: SDK_PREFIX + "-selector-create-option" }, { key: "selector_select_all", disabled: true }, noneValueOption),
@@ -139,6 +147,12 @@ var Selector = /** @class */ (function (_super) {
139
147
  __metadata("design:paramtypes", [Object]),
140
148
  __metadata("design:returntype", void 0)
141
149
  ], Selector.prototype, "handleCreateClick", null);
150
+ __decorate([
151
+ bind,
152
+ __metadata("design:type", Function),
153
+ __metadata("design:paramtypes", [String, Object]),
154
+ __metadata("design:returntype", void 0)
155
+ ], Selector.prototype, "handleFilter", null);
142
156
  return Selector;
143
157
  }(React.Component));
144
158
  export default Selector;
@@ -26,7 +26,7 @@ import { TreeSelect } from 'antd';
26
26
  import { SDK_PREFIX } from '../../constants/style';
27
27
  export function TreeSelector(props) {
28
28
  var className = props.className, dropdownClassName = props.dropdownClassName, restProps = __rest(props, ["className", "dropdownClassName"]);
29
- return (React.createElement(TreeSelect, __assign({ className: classnames(SDK_PREFIX + "-tree-select", className), dropdownClassName: classnames(SDK_PREFIX + "-tree-select-dropdown", dropdownClassName) }, restProps)));
29
+ return (React.createElement(TreeSelect, __assign({ className: classnames(SDK_PREFIX + "-tree-select", className), dropdownClassName: classnames(SDK_PREFIX + "-tree-select-dropdown", dropdownClassName), showSearch: true, treeNodeFilterProp: "title" }, restProps)));
30
30
  }
31
31
  export default TreeSelector;
32
32
  TreeSelector.SHOW_ALL = TreeSelect.SHOW_ALL;