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