@kne/react-filter 0.1.15 → 0.1.18
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/README.md +236 -0
- package/dist/{index.js → index.cjs} +231 -106
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +17 -5
- package/dist/index.css.map +1 -1
- package/dist/index.modern.js +223 -98
- package/dist/index.modern.js.map +1 -1
- package/package.json +11 -7
- package/dist/index.js.map +0 -1
package/dist/index.modern.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import React, { createContext, useContext, useState, useRef, useEffect, useMemo, cloneElement } from 'react';
|
|
2
|
-
import { Space, Tag, message, Button, Tooltip, InputNumber, Input, Select, Checkbox, Divider, Row, Col } from 'antd';
|
|
3
|
-
import { createCitySelect, apis, RemoteData, DisplayCity } from '@kne/react-city-select';
|
|
2
|
+
import { Popover, Space, Tag, message, Button, Tooltip, InputNumber, Input, Select, Checkbox, Radio, Divider, Row, Col } from 'antd';
|
|
4
3
|
import classnames from 'classnames';
|
|
5
|
-
import
|
|
6
|
-
import isFunction from 'lodash
|
|
7
|
-
import isEqual from 'lodash/isEqual';
|
|
4
|
+
import { createCitySelect, apis, RemoteData, DisplayCity } from '@kne/react-city-select';
|
|
5
|
+
import { get, isFunction, isEqual, isNumber } from 'lodash';
|
|
8
6
|
import useClickOutSide from '@kne/use-click-outside';
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
const context$1 = createContext({});
|
|
9
|
+
const {
|
|
10
|
+
Consumer,
|
|
11
|
+
Provider: Provider$1
|
|
12
|
+
} = context$1;
|
|
13
|
+
const useConsumer = () => useContext(context$1);
|
|
10
14
|
|
|
11
15
|
function _extends() {
|
|
12
|
-
_extends = Object.assign
|
|
16
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
13
17
|
for (var i = 1; i < arguments.length; i++) {
|
|
14
18
|
var source = arguments[i];
|
|
15
19
|
|
|
@@ -22,7 +26,6 @@ function _extends() {
|
|
|
22
26
|
|
|
23
27
|
return target;
|
|
24
28
|
};
|
|
25
|
-
|
|
26
29
|
return _extends.apply(this, arguments);
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -41,23 +44,30 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
41
44
|
return target;
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
const
|
|
45
|
-
const {
|
|
46
|
-
Consumer,
|
|
47
|
-
Provider: Provider$1
|
|
48
|
-
} = context$1;
|
|
49
|
-
const useConsumer = () => useContext(context$1);
|
|
50
|
-
|
|
51
|
-
const _excluded$5 = ["label"];
|
|
47
|
+
const _excluded$8 = ["label", "labelHidden", "isMore", "moreTrigger"];
|
|
52
48
|
|
|
53
49
|
const FilterItem = ({
|
|
54
50
|
className,
|
|
55
51
|
label,
|
|
52
|
+
labelHidden,
|
|
53
|
+
isMore,
|
|
54
|
+
moreTrigger,
|
|
56
55
|
children
|
|
57
56
|
}) => {
|
|
57
|
+
if (isMore) {
|
|
58
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: classnames("react-filter-item-label", "is-more", className)
|
|
60
|
+
}, /*#__PURE__*/React.createElement(Popover, {
|
|
61
|
+
content: children,
|
|
62
|
+
trigger: moreTrigger,
|
|
63
|
+
placement: "bottom",
|
|
64
|
+
overlayClassName: "react-filter-item-popover"
|
|
65
|
+
}, /*#__PURE__*/React.createElement("a", null, label)));
|
|
66
|
+
}
|
|
67
|
+
|
|
58
68
|
return /*#__PURE__*/React.createElement(Space, {
|
|
59
69
|
className: classnames('react-filter-item', className)
|
|
60
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
}, labelHidden ? null : /*#__PURE__*/React.createElement("div", {
|
|
61
71
|
className: "react-filter-item-label"
|
|
62
72
|
}, label, ":"), /*#__PURE__*/React.createElement("div", {
|
|
63
73
|
className: "react-filter-item-children"
|
|
@@ -66,16 +76,25 @@ const FilterItem = ({
|
|
|
66
76
|
|
|
67
77
|
const withFilterItem = WrappedComponent => _ref => {
|
|
68
78
|
let {
|
|
69
|
-
label
|
|
79
|
+
label,
|
|
80
|
+
labelHidden,
|
|
81
|
+
isMore,
|
|
82
|
+
moreTrigger
|
|
70
83
|
} = _ref,
|
|
71
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
84
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$8);
|
|
72
85
|
|
|
73
86
|
return /*#__PURE__*/React.createElement(FilterItem, {
|
|
74
|
-
label: label
|
|
75
|
-
|
|
87
|
+
label: label,
|
|
88
|
+
labelHidden: labelHidden,
|
|
89
|
+
isMore: isMore,
|
|
90
|
+
moreTrigger: moreTrigger
|
|
91
|
+
}, /*#__PURE__*/React.createElement(WrappedComponent, _extends({}, props, {
|
|
92
|
+
label: label,
|
|
93
|
+
isMore: isMore
|
|
94
|
+
})));
|
|
76
95
|
};
|
|
77
96
|
|
|
78
|
-
const _excluded$
|
|
97
|
+
const _excluded$7 = ["value", "label"];
|
|
79
98
|
const {
|
|
80
99
|
CheckableTag
|
|
81
100
|
} = Tag;
|
|
@@ -86,11 +105,13 @@ const {
|
|
|
86
105
|
|
|
87
106
|
const List = ({
|
|
88
107
|
label,
|
|
108
|
+
labelHidden,
|
|
89
109
|
name,
|
|
90
110
|
size,
|
|
91
111
|
children,
|
|
92
112
|
options,
|
|
93
|
-
more
|
|
113
|
+
more,
|
|
114
|
+
isMore
|
|
94
115
|
}) => {
|
|
95
116
|
const {
|
|
96
117
|
value,
|
|
@@ -163,7 +184,8 @@ const List = ({
|
|
|
163
184
|
})();
|
|
164
185
|
|
|
165
186
|
return /*#__PURE__*/React.createElement(FilterItem, {
|
|
166
|
-
label: label
|
|
187
|
+
label: label,
|
|
188
|
+
labelHidden: labelHidden
|
|
167
189
|
}, /*#__PURE__*/React.createElement(Provider, {
|
|
168
190
|
value: {
|
|
169
191
|
currentValue,
|
|
@@ -203,7 +225,7 @@ List.Item = _ref => {
|
|
|
203
225
|
value,
|
|
204
226
|
label
|
|
205
227
|
} = _ref,
|
|
206
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
228
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
207
229
|
|
|
208
230
|
const {
|
|
209
231
|
currentValue,
|
|
@@ -226,16 +248,22 @@ List.defaultProps = {
|
|
|
226
248
|
size: 2
|
|
227
249
|
};
|
|
228
250
|
|
|
251
|
+
const _excluded$6 = ["label", "labelHidden", "name", "size", "isMore"];
|
|
229
252
|
const {
|
|
230
253
|
Item
|
|
231
254
|
} = List;
|
|
232
255
|
|
|
233
|
-
const City =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
256
|
+
const City = _ref => {
|
|
257
|
+
let {
|
|
258
|
+
label,
|
|
259
|
+
labelHidden,
|
|
260
|
+
name,
|
|
261
|
+
size
|
|
262
|
+
} = _ref;
|
|
263
|
+
_objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
264
|
+
|
|
238
265
|
return /*#__PURE__*/React.createElement(List, {
|
|
266
|
+
labelHidden: labelHidden,
|
|
239
267
|
label: label,
|
|
240
268
|
name: name,
|
|
241
269
|
size: size,
|
|
@@ -304,6 +332,7 @@ const City = ({
|
|
|
304
332
|
const SearchButton = ({
|
|
305
333
|
name,
|
|
306
334
|
size,
|
|
335
|
+
isMore,
|
|
307
336
|
template,
|
|
308
337
|
children,
|
|
309
338
|
defaultValue,
|
|
@@ -339,7 +368,7 @@ const SearchButton = ({
|
|
|
339
368
|
}, [active]);
|
|
340
369
|
return /*#__PURE__*/React.createElement("div", {
|
|
341
370
|
className: classnames("react-filter-search-button", {
|
|
342
|
-
"is-active": active
|
|
371
|
+
"is-active": active && !isMore
|
|
343
372
|
}),
|
|
344
373
|
ref: ref,
|
|
345
374
|
onMouseEnter: () => {
|
|
@@ -348,14 +377,17 @@ const SearchButton = ({
|
|
|
348
377
|
onMouseLeave: () => {
|
|
349
378
|
active && setActive(false);
|
|
350
379
|
}
|
|
351
|
-
}, /*#__PURE__*/React.createElement(
|
|
352
|
-
className: "inner"
|
|
380
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
381
|
+
className: "inner",
|
|
382
|
+
size: 0
|
|
353
383
|
}, /*#__PURE__*/React.createElement("div", null, children({
|
|
354
384
|
value,
|
|
355
385
|
setValue,
|
|
356
386
|
setActive
|
|
357
|
-
})), active ? /*#__PURE__*/React.createElement(Button, {
|
|
358
|
-
className: "react-filter-search-confirm",
|
|
387
|
+
})), active || isMore ? /*#__PURE__*/React.createElement(Button, {
|
|
388
|
+
className: classnames("react-filter-search-confirm", {
|
|
389
|
+
"is-more": isMore
|
|
390
|
+
}),
|
|
359
391
|
size: "small",
|
|
360
392
|
type: "primary",
|
|
361
393
|
onClick: e => {
|
|
@@ -382,13 +414,15 @@ SearchButton.defaultProps = {
|
|
|
382
414
|
const RangeInner = ({
|
|
383
415
|
name,
|
|
384
416
|
size,
|
|
417
|
+
isMore,
|
|
385
418
|
defaultActive,
|
|
386
419
|
template,
|
|
387
420
|
onBlur,
|
|
388
421
|
onSearch,
|
|
389
422
|
onActiveChange,
|
|
390
423
|
startProps,
|
|
391
|
-
endProps
|
|
424
|
+
endProps,
|
|
425
|
+
placeholder
|
|
392
426
|
}) => {
|
|
393
427
|
const [error, setError] = useState(null);
|
|
394
428
|
|
|
@@ -410,6 +444,7 @@ const RangeInner = ({
|
|
|
410
444
|
return /*#__PURE__*/React.createElement(SearchButton, {
|
|
411
445
|
size: size,
|
|
412
446
|
template: template,
|
|
447
|
+
isMore: isMore,
|
|
413
448
|
onBlur: onBlur,
|
|
414
449
|
defaultActive: defaultActive,
|
|
415
450
|
name: name,
|
|
@@ -445,7 +480,8 @@ const RangeInner = ({
|
|
|
445
480
|
},
|
|
446
481
|
onFocus: () => {
|
|
447
482
|
setActive(true);
|
|
448
|
-
}
|
|
483
|
+
},
|
|
484
|
+
placeholder: Array.isArray(placeholder) ? placeholder[0] : placeholder || "请输入"
|
|
449
485
|
})), "~", /*#__PURE__*/React.createElement(InputNumber, _extends({
|
|
450
486
|
size: "small"
|
|
451
487
|
}, endProps, {
|
|
@@ -457,25 +493,30 @@ const RangeInner = ({
|
|
|
457
493
|
},
|
|
458
494
|
onFocus: () => {
|
|
459
495
|
setActive(true);
|
|
460
|
-
}
|
|
496
|
+
},
|
|
497
|
+
placeholder: Array.isArray(placeholder) ? placeholder[0] : placeholder || "请输入"
|
|
461
498
|
})))));
|
|
462
499
|
};
|
|
463
500
|
const Range = withFilterItem(RangeInner);
|
|
464
501
|
|
|
465
|
-
const _excluded$
|
|
502
|
+
const _excluded$5 = ["name", "label", "isMore", "template", "defaultActive", "onBlur", "onSearch", "onActiveChange", "placeholder"];
|
|
466
503
|
const TextInner = _ref => {
|
|
467
504
|
let {
|
|
468
505
|
name,
|
|
506
|
+
label,
|
|
507
|
+
isMore,
|
|
469
508
|
template,
|
|
470
509
|
defaultActive,
|
|
471
510
|
onBlur,
|
|
472
511
|
onSearch,
|
|
473
|
-
onActiveChange
|
|
512
|
+
onActiveChange,
|
|
513
|
+
placeholder
|
|
474
514
|
} = _ref,
|
|
475
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
515
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$5);
|
|
476
516
|
|
|
477
517
|
return /*#__PURE__*/React.createElement(SearchButton, {
|
|
478
518
|
defaultActive: defaultActive,
|
|
519
|
+
isMore: isMore,
|
|
479
520
|
onBlur: onBlur,
|
|
480
521
|
template: template,
|
|
481
522
|
name: name,
|
|
@@ -490,6 +531,7 @@ const TextInner = _ref => {
|
|
|
490
531
|
}) => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, _extends({
|
|
491
532
|
size: "small"
|
|
492
533
|
}, props, {
|
|
534
|
+
placeholder: placeholder || label,
|
|
493
535
|
value: value,
|
|
494
536
|
onChange: e => {
|
|
495
537
|
setValue(e.target.value);
|
|
@@ -501,12 +543,14 @@ const TextInner = _ref => {
|
|
|
501
543
|
};
|
|
502
544
|
const Text = withFilterItem(TextInner);
|
|
503
545
|
|
|
504
|
-
const _excluded$
|
|
546
|
+
const _excluded$4 = ["name", "label", "placeholder", "isMore"];
|
|
505
547
|
const SelectorInner = _ref => {
|
|
506
548
|
let {
|
|
507
|
-
name
|
|
549
|
+
name,
|
|
550
|
+
label,
|
|
551
|
+
placeholder
|
|
508
552
|
} = _ref,
|
|
509
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
553
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
510
554
|
|
|
511
555
|
const {
|
|
512
556
|
value: aValue,
|
|
@@ -514,9 +558,7 @@ const SelectorInner = _ref => {
|
|
|
514
558
|
} = useConsumer();
|
|
515
559
|
const currentValue = aValue[name];
|
|
516
560
|
return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
|
|
517
|
-
|
|
518
|
-
minWidth: "150px"
|
|
519
|
-
},
|
|
561
|
+
placeholder: label || placeholder,
|
|
520
562
|
size: "small",
|
|
521
563
|
value: currentValue,
|
|
522
564
|
onChange: (value, item) => {
|
|
@@ -526,14 +568,15 @@ const SelectorInner = _ref => {
|
|
|
526
568
|
};
|
|
527
569
|
const Selector = withFilterItem(SelectorInner);
|
|
528
570
|
|
|
529
|
-
const _excluded$
|
|
571
|
+
const _excluded$3 = ["name", "label", "className", "isMore"];
|
|
530
572
|
|
|
531
573
|
const Check = _ref => {
|
|
532
574
|
let {
|
|
533
575
|
name,
|
|
534
|
-
label
|
|
576
|
+
label,
|
|
577
|
+
className
|
|
535
578
|
} = _ref,
|
|
536
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
579
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
537
580
|
|
|
538
581
|
const {
|
|
539
582
|
value: aValue,
|
|
@@ -541,6 +584,7 @@ const Check = _ref => {
|
|
|
541
584
|
} = useConsumer();
|
|
542
585
|
const currentValue = aValue[name];
|
|
543
586
|
return /*#__PURE__*/React.createElement(Checkbox, _extends({}, props, {
|
|
587
|
+
className: classnames('react-filter-item', className),
|
|
544
588
|
size: "small",
|
|
545
589
|
checked: currentValue,
|
|
546
590
|
onChange: e => {
|
|
@@ -552,55 +596,56 @@ const Check = _ref => {
|
|
|
552
596
|
}), label);
|
|
553
597
|
};
|
|
554
598
|
|
|
555
|
-
const _excluded = ["name", "
|
|
556
|
-
|
|
557
|
-
const withMoreExtraButton = WrappedComponent => _ref => {
|
|
599
|
+
const _excluded$2 = ["label", "name", "options", "isMore"];
|
|
600
|
+
const RadioList = withFilterItem(_ref => {
|
|
558
601
|
let {
|
|
559
602
|
name,
|
|
560
|
-
|
|
603
|
+
options
|
|
561
604
|
} = _ref,
|
|
562
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
605
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
563
606
|
|
|
564
|
-
const
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
607
|
+
const {
|
|
608
|
+
value: aValue,
|
|
609
|
+
onChange
|
|
610
|
+
} = useConsumer();
|
|
611
|
+
const currentValue = aValue[name];
|
|
612
|
+
return /*#__PURE__*/React.createElement(Radio.Group, _extends({}, props, {
|
|
613
|
+
options: options,
|
|
614
|
+
value: get(currentValue, 'value'),
|
|
615
|
+
onChange: e => {
|
|
616
|
+
const item = options.find(item => item.value === e.target.value);
|
|
617
|
+
onChange(name, item);
|
|
571
618
|
}
|
|
572
|
-
}))
|
|
573
|
-
|
|
574
|
-
e.stopPropagation();
|
|
575
|
-
setIsEdit(true);
|
|
576
|
-
},
|
|
577
|
-
label: children || "其他"
|
|
578
|
-
});
|
|
579
|
-
};
|
|
580
|
-
const RangeButton = withMoreExtraButton(RangeInner);
|
|
581
|
-
const TextButton = withMoreExtraButton(TextInner);
|
|
582
|
-
const SelectorButton = withMoreExtraButton(SelectorInner);
|
|
583
|
-
const createExtraButton = _ref2 => {
|
|
584
|
-
let {
|
|
585
|
-
type
|
|
586
|
-
} = _ref2,
|
|
587
|
-
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
588
|
-
|
|
589
|
-
return innerProps => {
|
|
590
|
-
const mapping = {
|
|
591
|
-
range: RangeButton,
|
|
592
|
-
text: TextButton,
|
|
593
|
-
selector: SelectorButton
|
|
594
|
-
};
|
|
595
|
-
const ExtraButtonComponent = mapping[type];
|
|
619
|
+
}));
|
|
620
|
+
});
|
|
596
621
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
622
|
+
const _excluded$1 = ["label", "name", "options", "isMore"];
|
|
623
|
+
const CheckboxList = withFilterItem(_ref => {
|
|
624
|
+
let {
|
|
625
|
+
name,
|
|
626
|
+
options
|
|
627
|
+
} = _ref,
|
|
628
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
600
629
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
630
|
+
const {
|
|
631
|
+
value: aValue,
|
|
632
|
+
onChange
|
|
633
|
+
} = useConsumer();
|
|
634
|
+
const currentValue = aValue[name];
|
|
635
|
+
return /*#__PURE__*/React.createElement(Checkbox.Group, _extends({}, props, {
|
|
636
|
+
value: (currentValue || []).map(({
|
|
637
|
+
value
|
|
638
|
+
}) => value),
|
|
639
|
+
onChange: value => {
|
|
640
|
+
const item = value.map(value => {
|
|
641
|
+
return options.find(item => item.value === value);
|
|
642
|
+
});
|
|
643
|
+
console.log(item);
|
|
644
|
+
onChange(name, item);
|
|
645
|
+
},
|
|
646
|
+
options: options
|
|
647
|
+
}));
|
|
648
|
+
});
|
|
604
649
|
|
|
605
650
|
const filterNull = item => {
|
|
606
651
|
const target = Object.assign({}, item);
|
|
@@ -638,9 +683,14 @@ const Filter = ({
|
|
|
638
683
|
isExtra,
|
|
639
684
|
list,
|
|
640
685
|
label,
|
|
686
|
+
labelHidden,
|
|
687
|
+
itemLabelHidden,
|
|
641
688
|
unfoldText,
|
|
642
689
|
foldText,
|
|
643
690
|
extra,
|
|
691
|
+
more,
|
|
692
|
+
moreTrigger,
|
|
693
|
+
moreLabel,
|
|
644
694
|
value: originValue,
|
|
645
695
|
onChange
|
|
646
696
|
}) => {
|
|
@@ -653,9 +703,11 @@ const Filter = ({
|
|
|
653
703
|
|
|
654
704
|
const renderList = list => list.map((item, index) => {
|
|
655
705
|
return /*#__PURE__*/React.createElement(Space, {
|
|
656
|
-
key: index
|
|
706
|
+
key: index,
|
|
707
|
+
className: "react-filter-line"
|
|
657
708
|
}, item.map((item, index) => cloneElement(item, {
|
|
658
|
-
key: index
|
|
709
|
+
key: index,
|
|
710
|
+
labelHidden: itemLabelHidden
|
|
659
711
|
})));
|
|
660
712
|
});
|
|
661
713
|
|
|
@@ -666,6 +718,22 @@ const Filter = ({
|
|
|
666
718
|
onChange(filterNull(target));
|
|
667
719
|
};
|
|
668
720
|
|
|
721
|
+
const moreFilter = more && more.length > 0 ? /*#__PURE__*/React.createElement(Space, {
|
|
722
|
+
className: "react-filter-line is-more"
|
|
723
|
+
}, /*#__PURE__*/React.createElement(Space, {
|
|
724
|
+
className: "react-filter-item"
|
|
725
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
726
|
+
className: "react-filter-item-label"
|
|
727
|
+
}, moreLabel, ":"), /*#__PURE__*/React.createElement(Space, {
|
|
728
|
+
className: "react-filter-item-children",
|
|
729
|
+
split: /*#__PURE__*/React.createElement(Divider, {
|
|
730
|
+
type: "vertical"
|
|
731
|
+
})
|
|
732
|
+
}, more.map((item, index) => cloneElement(item, {
|
|
733
|
+
key: index,
|
|
734
|
+
isMore: true,
|
|
735
|
+
moreTrigger
|
|
736
|
+
}))))) : null;
|
|
669
737
|
return /*#__PURE__*/React.createElement(Provider$1, {
|
|
670
738
|
value: {
|
|
671
739
|
value,
|
|
@@ -675,7 +743,7 @@ const Filter = ({
|
|
|
675
743
|
className: "react-filter"
|
|
676
744
|
}, /*#__PURE__*/React.createElement("div", {
|
|
677
745
|
className: "react-filter-inner"
|
|
678
|
-
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(FilterItem, {
|
|
746
|
+
}, /*#__PURE__*/React.createElement("div", null, labelHidden ? null : /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(FilterItem, {
|
|
679
747
|
className: "react-filter-selected",
|
|
680
748
|
label: label
|
|
681
749
|
}, Object.keys(value).map(key => {
|
|
@@ -691,11 +759,11 @@ const Filter = ({
|
|
|
691
759
|
}, Array.isArray(item) ? item.map(({
|
|
692
760
|
label
|
|
693
761
|
}) => label).join(",") : item.label);
|
|
694
|
-
})), /*#__PURE__*/React.createElement("div", null, extra))), renderList(isExtra ? basicList : list)), display ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
|
|
762
|
+
})), /*#__PURE__*/React.createElement("div", null, extra))), renderList(isExtra ? basicList : list), moreList.length === 0 ? moreFilter : null), display ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Divider, {
|
|
695
763
|
className: "react-filter-divider"
|
|
696
764
|
}), /*#__PURE__*/React.createElement("div", {
|
|
697
765
|
className: "react-filter-inner"
|
|
698
|
-
}, renderList(moreList))) : /*#__PURE__*/React.createElement("div", {
|
|
766
|
+
}, renderList(moreList)), moreList.length > 0 ? moreFilter : null) : /*#__PURE__*/React.createElement("div", {
|
|
699
767
|
className: "react-filter-divider-close"
|
|
700
768
|
}), isExtra && list.length > displayLine ? /*#__PURE__*/React.createElement(Row, {
|
|
701
769
|
className: "react-filter-switch-btn",
|
|
@@ -714,20 +782,77 @@ Filter.type = {
|
|
|
714
782
|
Range,
|
|
715
783
|
Text,
|
|
716
784
|
Selector,
|
|
717
|
-
Check
|
|
785
|
+
Check,
|
|
786
|
+
RadioList,
|
|
787
|
+
CheckboxList
|
|
718
788
|
};
|
|
719
789
|
Filter.defaultProps = {
|
|
720
790
|
label: '筛选项',
|
|
791
|
+
labelHidden: false,
|
|
792
|
+
itemLabelHidden: false,
|
|
721
793
|
unfoldText: '展开',
|
|
722
794
|
foldText: '收起',
|
|
723
795
|
displayLine: 2,
|
|
724
796
|
defaultDisplay: false,
|
|
725
797
|
isExtra: true,
|
|
726
798
|
list: [[]],
|
|
799
|
+
more: [],
|
|
800
|
+
moreTrigger: 'hover',
|
|
801
|
+
moreLabel: '更多',
|
|
727
802
|
value: {},
|
|
728
803
|
extra: null,
|
|
729
804
|
onChange: () => {}
|
|
730
805
|
};
|
|
731
806
|
|
|
807
|
+
const _excluded = ["name", "value", "children"],
|
|
808
|
+
_excluded2 = ["type"];
|
|
809
|
+
const withMoreExtraButton = WrappedComponent => _ref => {
|
|
810
|
+
let {
|
|
811
|
+
name,
|
|
812
|
+
children
|
|
813
|
+
} = _ref,
|
|
814
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
815
|
+
|
|
816
|
+
const [isEdit, setIsEdit] = useState(false);
|
|
817
|
+
return isEdit ? /*#__PURE__*/React.createElement(WrappedComponent, _extends({
|
|
818
|
+
defaultActive: true
|
|
819
|
+
}, props, {
|
|
820
|
+
name: name,
|
|
821
|
+
onBlur: () => {
|
|
822
|
+
setIsEdit(false);
|
|
823
|
+
}
|
|
824
|
+
})) : /*#__PURE__*/React.createElement(List.Item, {
|
|
825
|
+
onClick: e => {
|
|
826
|
+
e.stopPropagation();
|
|
827
|
+
setIsEdit(true);
|
|
828
|
+
},
|
|
829
|
+
label: children || "其他"
|
|
830
|
+
});
|
|
831
|
+
};
|
|
832
|
+
const RangeButton = withMoreExtraButton(RangeInner);
|
|
833
|
+
const TextButton = withMoreExtraButton(TextInner);
|
|
834
|
+
const SelectorButton = withMoreExtraButton(SelectorInner);
|
|
835
|
+
const createExtraButton = _ref2 => {
|
|
836
|
+
let {
|
|
837
|
+
type
|
|
838
|
+
} = _ref2,
|
|
839
|
+
props = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
840
|
+
|
|
841
|
+
return innerProps => {
|
|
842
|
+
const mapping = {
|
|
843
|
+
range: RangeButton,
|
|
844
|
+
text: TextButton,
|
|
845
|
+
selector: SelectorButton
|
|
846
|
+
};
|
|
847
|
+
const ExtraButtonComponent = mapping[type];
|
|
848
|
+
|
|
849
|
+
if (!ExtraButtonComponent) {
|
|
850
|
+
return null;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
return /*#__PURE__*/React.createElement(ExtraButtonComponent, _extends({}, props, innerProps));
|
|
854
|
+
};
|
|
855
|
+
};
|
|
856
|
+
|
|
732
857
|
export { FilterItem, SearchButton, createExtraButton, Filter as default, useConsumer as useFilterContext, withFilterItem, withMoreExtraButton };
|
|
733
858
|
//# sourceMappingURL=index.modern.js.map
|