@fle-ui/next 1.0.3 → 1.0.4-alpha.0

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 (68) hide show
  1. package/.history/package_20211223145956.json +146 -0
  2. package/.history/package_20211223211341.json +146 -0
  3. package/.history/package_20211223220710.json +146 -0
  4. package/.history/package_20211223221147.json +146 -0
  5. package/.history/package_20211223221328.json +146 -0
  6. package/.history/package_20211223221445.json +146 -0
  7. package/dist/@fle-ui/next.css +2254 -2212
  8. package/dist/@fle-ui/next.css.map +1 -1
  9. package/dist/@fle-ui/next.js +1165 -1247
  10. package/dist/@fle-ui/next.js.map +1 -1
  11. package/dist/@fle-ui/next.min.css +2 -2
  12. package/dist/@fle-ui/next.min.css.map +1 -1
  13. package/dist/@fle-ui/next.min.js +3 -3
  14. package/dist/@fle-ui/next.min.js.map +1 -1
  15. package/docs-dist/components__affix__affix.md~components__alert__alert.md~components__anchor__anchor.md~components__au~31d645aa.js +13 -16
  16. package/docs-dist/components__avatar__avatar.md.js +227 -372
  17. package/docs-dist/components__button__button.md.js +27 -27
  18. package/docs-dist/components__form__form.md.js +1 -1
  19. package/docs-dist/components__layout__layout.md.js +1 -1
  20. package/docs-dist/components__modal__modal.md.js +17 -11
  21. package/docs-dist/components__popconfirm__popconfirm.md.js +51 -51
  22. package/docs-dist/components__upload__upload.md.js +6 -10
  23. package/docs-dist/demos_bmurcdaerb~demos_citsitats~demos_dirg~demos_drac~demos_ecaps~demos_eert~demos_egami~demos_egas~1a5cf206.chunk.css +2 -2
  24. package/docs-dist/demos_bmurcdaerb~demos_citsitats~demos_dirg~demos_drac~demos_ecaps~demos_eert~demos_egami~demos_egas~1a5cf206.js +1536 -1843
  25. package/docs-dist/demos_daolpu.chunk.css +2 -2
  26. package/docs-dist/demos_daolpu.js +2597 -2904
  27. package/docs-dist/demos_eert.js +1 -1
  28. package/docs-dist/demos_elbat.chunk.css +2 -2
  29. package/docs-dist/demos_elbat.js +645 -952
  30. package/docs-dist/demos_mrifnocpop.js +1 -1
  31. package/docs-dist/demos_mrof.js +0 -1
  32. package/docs-dist/demos_noitacifiton.js +1 -1
  33. package/docs-dist/demos_pot-kcab.js +9 -9
  34. package/docs-dist/demos_ratava.js +3 -3
  35. package/docs-dist/demos_redivorp-gifnoc.js +5 -5
  36. package/docs-dist/demos_rekcip-etad.js +2 -2
  37. package/docs-dist/demos_sbat.chunk.css +2 -2
  38. package/docs-dist/demos_sbat.js +2301 -2608
  39. package/docs-dist/demos_tupni.js +1 -1
  40. package/docs-dist/docs__story__index.md.js +22 -0
  41. package/docs-dist/umi.js +9 -8
  42. package/docs-dist/vendors~demos_bmurcdaerb~demos_citsitats~demos_daolpu~demos_dirg~demos_drac~demos_ecaps~demos_eert~d~f20ff6ec.js +9204 -8936
  43. package/es/cascader/index.d.ts +11 -129
  44. package/es/cascader/index.js +151 -534
  45. package/es/cascader/style/css.js +1 -1
  46. package/es/cascader/style/index.css +205 -180
  47. package/es/cascader/style/index.d.ts +1 -1
  48. package/es/cascader/style/index.js +1 -1
  49. package/es/cascader/style/index.less +66 -205
  50. package/es/cascader/style/rtl.less +10 -84
  51. package/es/input-number/style/index.css +18 -4
  52. package/es/input-number/style/index.less +15 -2
  53. package/es/input-number/style/rtl.less +24 -7
  54. package/es/table/style/index.css +3 -0
  55. package/lib/cascader/index.d.ts +11 -129
  56. package/lib/cascader/index.js +153 -545
  57. package/lib/cascader/style/css.js +1 -1
  58. package/lib/cascader/style/index.css +205 -180
  59. package/lib/cascader/style/index.d.ts +1 -1
  60. package/lib/cascader/style/index.js +1 -1
  61. package/lib/cascader/style/index.less +66 -205
  62. package/lib/cascader/style/rtl.less +10 -84
  63. package/lib/input-number/style/index.css +18 -4
  64. package/lib/input-number/style/index.less +15 -2
  65. package/lib/input-number/style/rtl.less +24 -7
  66. package/lib/table/style/index.css +3 -0
  67. package/package.json +3 -2
  68. package/report.html +2 -2
@@ -2,7 +2,7 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _typeof = require("@babel/runtime/helpers/typeof");
5
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
6
6
 
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
@@ -11,35 +11,21 @@ exports["default"] = void 0;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
-
20
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
15
 
22
- var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
16
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
23
17
 
24
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
18
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
25
19
 
26
20
  var _tslib = require("tslib");
27
21
 
28
22
  var React = _interopRequireWildcard(require("react"));
29
23
 
30
- var _rcCascader = _interopRequireDefault(require("rc-cascader"));
31
-
32
- var _arrayTreeFilter = _interopRequireDefault(require("array-tree-filter"));
33
-
34
24
  var _classnames = _interopRequireDefault(require("classnames"));
35
25
 
36
- var _omit = _interopRequireDefault(require("rc-util/lib/omit"));
37
-
38
- var _KeyCode = _interopRequireDefault(require("rc-util/lib/KeyCode"));
39
-
40
- var _CloseCircleFilled = _interopRequireDefault(require("@ant-design/icons/CloseCircleFilled"));
26
+ var _rcCascader = _interopRequireDefault(require("rc-cascader"));
41
27
 
42
- var _DownOutlined = _interopRequireDefault(require("@ant-design/icons/DownOutlined"));
28
+ var _omit = _interopRequireDefault(require("rc-util/lib/omit"));
43
29
 
44
30
  var _RightOutlined = _interopRequireDefault(require("@ant-design/icons/RightOutlined"));
45
31
 
@@ -47,561 +33,183 @@ var _RedoOutlined = _interopRequireDefault(require("@ant-design/icons/RedoOutlin
47
33
 
48
34
  var _LeftOutlined = _interopRequireDefault(require("@ant-design/icons/LeftOutlined"));
49
35
 
50
- var _input = _interopRequireDefault(require("../input"));
36
+ var _devWarning = _interopRequireDefault(require("../_util/devWarning"));
51
37
 
52
38
  var _configProvider = require("../config-provider");
53
39
 
54
- var _LocaleReceiver = _interopRequireDefault(require("../locale-provider/LocaleReceiver"));
55
-
56
- var _devWarning = _interopRequireDefault(require("../_util/devWarning"));
57
-
58
40
  var _SizeContext = _interopRequireDefault(require("../config-provider/SizeContext"));
59
41
 
60
- var _reactNode = require("../_util/reactNode");
42
+ var _iconUtil = _interopRequireDefault(require("../select/utils/iconUtil"));
61
43
 
62
44
  var _motion = require("../_util/motion");
63
45
 
64
46
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
65
47
 
66
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
67
-
68
- // We limit the filtered item count by default
69
- var defaultLimit = 50; // keep value when filtering
70
-
71
- var keepFilteredValueField = '__KEEP_FILTERED_OPTION_VALUE';
72
-
73
- function highlightKeyword(str, keyword, prefixCls) {
74
- return str.split(keyword).map(function (node, index) {
75
- return index === 0 ? node : [/*#__PURE__*/React.createElement("span", {
76
- className: "".concat(prefixCls, "-menu-item-keyword"),
77
- key: "seperator"
78
- }, keyword), node];
79
- });
80
- }
81
-
82
- function defaultFilterOption(inputValue, path, names) {
83
- return path.some(function (option) {
84
- return option[names.label].indexOf(inputValue) > -1;
85
- });
86
- }
48
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
49
+
50
+ function highlightKeyword(str, lowerKeyword, prefixCls) {
51
+ var cells = str.toLowerCase().split(lowerKeyword) // @ts-ignore
52
+ .reduce( // @ts-ignore
53
+ function (list, cur, index) {
54
+ return (// @ts-ignore
55
+ index === 0 ? [cur] : [].concat((0, _toConsumableArray2["default"])(list), [lowerKeyword, cur])
56
+ );
57
+ }, []);
58
+ var fillCells = [];
59
+ var start = 0; // @ts-ignore
60
+
61
+ cells.forEach(function (cell, index) {
62
+ var end = start + cell.length;
63
+ var originWorld = str.slice(start, end);
64
+ start = end;
65
+
66
+ if (index % 2 === 1) {
67
+ originWorld = /*#__PURE__*/React.createElement("span", {
68
+ className: "".concat(prefixCls, "-menu-item-keyword"),
69
+ key: "seperator"
70
+ }, originWorld);
71
+ }
87
72
 
88
- function defaultRenderFilteredOption(inputValue, path, prefixCls, names) {
89
- return path.map(function (option, index) {
90
- var label = option[names.label];
91
- var node = label.indexOf(inputValue) > -1 ? highlightKeyword(label, inputValue, prefixCls) : label;
92
- return index === 0 ? node : [' / ', node];
73
+ fillCells.push(originWorld);
93
74
  });
75
+ return fillCells;
94
76
  }
95
77
 
96
- function defaultSortFilteredOption(a, b, inputValue, names) {
97
- function callback(elem) {
98
- return elem[names.label].indexOf(inputValue) > -1;
99
- }
78
+ var defaultSearchRender = function defaultSearchRender(inputValue, path, prefixCls, fieldNames) {
79
+ var optionList = []; // We do lower here to save perf
100
80
 
101
- return a.findIndex(callback) - b.findIndex(callback);
102
- }
103
-
104
- function getFieldNames(_ref) {
105
- var fieldNames = _ref.fieldNames;
106
- return fieldNames;
107
- }
108
-
109
- function getFilledFieldNames(props) {
110
- var fieldNames = getFieldNames(props) || {};
111
- var names = {
112
- children: fieldNames.children || 'children',
113
- label: fieldNames.label || 'label',
114
- value: fieldNames.value || 'value'
115
- };
116
- return names;
117
- }
81
+ var lower = inputValue.toLowerCase();
82
+ path.forEach(function (node, index) {
83
+ if (index !== 0) {
84
+ optionList.push(' / ');
85
+ }
118
86
 
119
- function flattenTree(options, props) {
120
- var ancestor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
121
- var names = getFilledFieldNames(props);
122
- var flattenOptions = [];
123
- var childrenName = names.children;
124
- options.forEach(function (option) {
125
- var path = ancestor.concat(option);
87
+ var label = node[fieldNames.label];
88
+ var type = (0, _typeof2["default"])(label);
126
89
 
127
- if (props.changeOnSelect || !option[childrenName] || !option[childrenName].length) {
128
- flattenOptions.push(path);
90
+ if (type === 'string' || type === 'number') {
91
+ label = highlightKeyword(String(label), lower, prefixCls);
129
92
  }
130
93
 
131
- if (option[childrenName]) {
132
- flattenOptions = flattenOptions.concat(flattenTree(option[childrenName], props, path));
133
- }
94
+ optionList.push(label);
134
95
  });
135
- return flattenOptions;
136
- }
137
-
138
- var defaultDisplayRender = function defaultDisplayRender(label) {
139
- return label.join(' / ');
96
+ return optionList;
140
97
  };
141
98
 
142
- function warningValueNotExist(list) {
143
- var fieldNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
144
- (list || []).forEach(function (item) {
145
- var valueFieldName = fieldNames.value || 'value';
146
- (0, _devWarning["default"])(valueFieldName in item, 'Cascader', 'Not found `value` in `options`.');
147
- warningValueNotExist(item[fieldNames.children || 'children'], fieldNames);
148
- });
149
- }
150
-
151
- function getEmptyNode(renderEmpty, names, notFoundContent) {
152
- var _ref2;
153
-
154
- return _ref2 = {}, (0, _defineProperty2["default"])(_ref2, names.value, 'ANT_CASCADER_NOT_FOUND'), (0, _defineProperty2["default"])(_ref2, names.label, notFoundContent || renderEmpty('Cascader')), (0, _defineProperty2["default"])(_ref2, "disabled", true), (0, _defineProperty2["default"])(_ref2, "isEmptyNode", true), _ref2;
155
- }
156
-
157
- var Cascader = /*#__PURE__*/function (_React$Component) {
158
- (0, _inherits2["default"])(Cascader, _React$Component);
159
-
160
- var _super = (0, _createSuper2["default"])(Cascader);
161
-
162
- function Cascader(props) {
163
- var _this;
164
-
165
- (0, _classCallCheck2["default"])(this, Cascader);
166
- _this = _super.call(this, props);
167
- _this.cachedOptions = [];
168
-
169
- _this.setValue = function (value) {
170
- var selectedOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
171
-
172
- if (!('value' in _this.props)) {
173
- _this.setState({
174
- value: value
175
- });
176
- }
177
-
178
- var onChange = _this.props.onChange;
179
- onChange === null || onChange === void 0 ? void 0 : onChange(value, selectedOptions);
180
- };
181
-
182
- _this.saveInput = function (node) {
183
- _this.input = node;
184
- };
185
-
186
- _this.handleChange = function (value, selectedOptions) {
187
- _this.setState({
188
- inputValue: ''
189
- });
190
-
191
- if (selectedOptions[0].__IS_FILTERED_OPTION) {
192
- var unwrappedValue = selectedOptions[0][keepFilteredValueField] === undefined ? value[0] : selectedOptions[0][keepFilteredValueField];
193
- var unwrappedSelectedOptions = selectedOptions[0].path;
194
-
195
- _this.setValue(unwrappedValue, unwrappedSelectedOptions);
196
-
197
- return;
198
- }
199
-
200
- _this.setValue(value, selectedOptions);
201
- };
202
-
203
- _this.handlePopupVisibleChange = function (popupVisible) {
204
- if (!('popupVisible' in _this.props)) {
205
- _this.setState(function (state) {
206
- return {
207
- popupVisible: popupVisible,
208
- inputFocused: popupVisible,
209
- inputValue: popupVisible ? state.inputValue : ''
210
- };
211
- });
212
- }
213
-
214
- var onPopupVisibleChange = _this.props.onPopupVisibleChange;
215
- onPopupVisibleChange === null || onPopupVisibleChange === void 0 ? void 0 : onPopupVisibleChange(popupVisible);
216
- };
217
-
218
- _this.handleInputBlur = function () {
219
- _this.setState({
220
- inputFocused: false
221
- });
222
- };
223
-
224
- _this.handleInputClick = function (e) {
225
- var _this$state = _this.state,
226
- inputFocused = _this$state.inputFocused,
227
- popupVisible = _this$state.popupVisible; // Prevent `Trigger` behaviour.
228
-
229
- if (inputFocused || popupVisible) {
230
- e.stopPropagation();
231
- }
232
- };
99
+ var Cascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
100
+ var _classNames2;
101
+
102
+ var customizePrefixCls = props.prefixCls,
103
+ customizeSize = props.size,
104
+ className = props.className,
105
+ multiple = props.multiple,
106
+ _props$bordered = props.bordered,
107
+ bordered = _props$bordered === void 0 ? true : _props$bordered,
108
+ transitionName = props.transitionName,
109
+ _props$choiceTransiti = props.choiceTransitionName,
110
+ choiceTransitionName = _props$choiceTransiti === void 0 ? '' : _props$choiceTransiti,
111
+ popupClassName = props.popupClassName,
112
+ dropdownClassName = props.dropdownClassName,
113
+ expandIcon = props.expandIcon,
114
+ showSearch = props.showSearch,
115
+ _props$allowClear = props.allowClear,
116
+ allowClear = _props$allowClear === void 0 ? true : _props$allowClear,
117
+ notFoundContent = props.notFoundContent,
118
+ direction = props.direction,
119
+ getPopupContainer = props.getPopupContainer,
120
+ rest = (0, _tslib.__rest)(props, ["prefixCls", "size", "className", "multiple", "bordered", "transitionName", "choiceTransitionName", "popupClassName", "dropdownClassName", "expandIcon", "showSearch", "allowClear", "notFoundContent", "direction", "getPopupContainer"]);
121
+ var restProps = (0, _omit["default"])(rest, ['suffixIcon']);
122
+
123
+ var _React$useContext = React.useContext(_configProvider.ConfigContext),
124
+ getContextPopupContainer = _React$useContext.getPopupContainer,
125
+ getPrefixCls = _React$useContext.getPrefixCls,
126
+ renderEmpty = _React$useContext.renderEmpty,
127
+ rootDirection = _React$useContext.direction;
128
+
129
+ var mergedDirection = direction || rootDirection;
130
+ var isRtl = mergedDirection === 'rtl'; // =================== Warning =====================
131
+
132
+ if (process.env.NODE_ENV !== 'production') {
133
+ (0, _devWarning["default"])(popupClassName === undefined, 'Cascader', '`popupClassName` is deprecated. Please use `dropdownClassName` instead.');
134
+ } // =================== No Found ====================
135
+
136
+
137
+ var mergedNotFoundContent = notFoundContent || renderEmpty('Cascader'); // ==================== Prefix =====================
138
+
139
+ var rootPrefixCls = getPrefixCls();
140
+ var prefixCls = getPrefixCls('select', customizePrefixCls);
141
+ var cascaderPrefixCls = getPrefixCls('cascader', customizePrefixCls); // =================== Dropdown ====================
142
+
143
+ var mergedDropdownClassName = (0, _classnames["default"])(dropdownClassName || popupClassName, "".concat(cascaderPrefixCls, "-dropdown"), (0, _defineProperty2["default"])({}, "".concat(cascaderPrefixCls, "-dropdown-rtl"), mergedDirection === 'rtl')); // ==================== Search =====================
144
+
145
+ var mergedShowSearch = React.useMemo(function () {
146
+ if (!showSearch) {
147
+ return showSearch;
148
+ }
233
149
 
234
- _this.handleKeyDown = function (e) {
235
- // SPACE => https://github.com/ant-design/ant-design/issues/16871
236
- if (e.keyCode === _KeyCode["default"].BACKSPACE || e.keyCode === _KeyCode["default"].SPACE) {
237
- e.stopPropagation();
238
- }
150
+ var searchConfig = {
151
+ render: defaultSearchRender
239
152
  };
240
153
 
241
- _this.handleInputChange = function (e) {
242
- var popupVisible = _this.state.popupVisible;
243
- var inputValue = e.target.value;
244
-
245
- if (!popupVisible) {
246
- _this.handlePopupVisibleChange(true);
247
- }
154
+ if ((0, _typeof2["default"])(showSearch) === 'object') {
155
+ searchConfig = (0, _extends2["default"])((0, _extends2["default"])({}, searchConfig), showSearch);
156
+ }
248
157
 
249
- _this.setState({
250
- inputValue: inputValue
251
- });
252
- };
158
+ return searchConfig;
159
+ }, [showSearch]); // ===================== Size ======================
253
160
 
254
- _this.clearSelection = function (e) {
255
- var inputValue = _this.state.inputValue;
256
- e.preventDefault();
257
- e.stopPropagation();
258
-
259
- if (!inputValue) {
260
- _this.handlePopupVisibleChange(false);
261
-
262
- _this.clearSelectionTimeout = setTimeout(function () {
263
- _this.setValue([]);
264
- }, 200);
265
- } else {
266
- _this.setState({
267
- inputValue: ''
268
- });
269
- }
270
- };
161
+ var size = React.useContext(_SizeContext["default"]);
162
+ var mergedSize = customizeSize || size; // ===================== Icon ======================
271
163
 
272
- _this.renderCascader = function (_ref3, locale) {
273
- var getContextPopupContainer = _ref3.getPopupContainer,
274
- getPrefixCls = _ref3.getPrefixCls,
275
- renderEmpty = _ref3.renderEmpty,
276
- direction = _ref3.direction;
277
- return /*#__PURE__*/React.createElement(_SizeContext["default"].Consumer, null, function (size) {
278
- var _classNames, _classNames2, _classNames3, _classNames5;
279
-
280
- var _assertThisInitialize = (0, _assertThisInitialized2["default"])(_this),
281
- props = _assertThisInitialize.props,
282
- state = _assertThisInitialize.state;
283
-
284
- var customizePrefixCls = props.prefixCls,
285
- customizeInputPrefixCls = props.inputPrefixCls,
286
- children = props.children,
287
- _props$placeholder = props.placeholder,
288
- placeholder = _props$placeholder === void 0 ? locale.placeholder || 'Please select' : _props$placeholder,
289
- customizeSize = props.size,
290
- disabled = props.disabled,
291
- className = props.className,
292
- style = props.style,
293
- allowClear = props.allowClear,
294
- _props$showSearch = props.showSearch,
295
- showSearch = _props$showSearch === void 0 ? false : _props$showSearch,
296
- suffixIcon = props.suffixIcon,
297
- expandIcon = props.expandIcon,
298
- notFoundContent = props.notFoundContent,
299
- popupClassName = props.popupClassName,
300
- bordered = props.bordered,
301
- dropdownRender = props.dropdownRender,
302
- otherProps = (0, _tslib.__rest)(props, ["prefixCls", "inputPrefixCls", "children", "placeholder", "size", "disabled", "className", "style", "allowClear", "showSearch", "suffixIcon", "expandIcon", "notFoundContent", "popupClassName", "bordered", "dropdownRender"]);
303
- var mergedSize = customizeSize || size;
304
- var value = state.value,
305
- inputFocused = state.inputFocused;
306
- var isRtlLayout = direction === 'rtl';
307
- var prefixCls = getPrefixCls('cascader', customizePrefixCls);
308
- var inputPrefixCls = getPrefixCls('input', customizeInputPrefixCls);
309
- var sizeCls = (0, _classnames["default"])((_classNames = {}, (0, _defineProperty2["default"])(_classNames, "".concat(inputPrefixCls, "-lg"), mergedSize === 'large'), (0, _defineProperty2["default"])(_classNames, "".concat(inputPrefixCls, "-sm"), mergedSize === 'small'), _classNames));
310
- var clearIcon = allowClear && !disabled && value.length > 0 || state.inputValue ? /*#__PURE__*/React.createElement(_CloseCircleFilled["default"], {
311
- className: "".concat(prefixCls, "-picker-clear"),
312
- onClick: _this.clearSelection
313
- }) : null;
314
- var arrowCls = (0, _classnames["default"])((_classNames2 = {}, (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-picker-arrow"), true), (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-picker-arrow-expand"), state.popupVisible), _classNames2));
315
- var pickerCls = (0, _classnames["default"])("".concat(prefixCls, "-picker"), (_classNames3 = {}, (0, _defineProperty2["default"])(_classNames3, "".concat(prefixCls, "-picker-rtl"), isRtlLayout), (0, _defineProperty2["default"])(_classNames3, "".concat(prefixCls, "-picker-with-value"), state.inputValue), (0, _defineProperty2["default"])(_classNames3, "".concat(prefixCls, "-picker-disabled"), disabled), (0, _defineProperty2["default"])(_classNames3, "".concat(prefixCls, "-picker-").concat(mergedSize), !!mergedSize), (0, _defineProperty2["default"])(_classNames3, "".concat(prefixCls, "-picker-show-search"), !!showSearch), (0, _defineProperty2["default"])(_classNames3, "".concat(prefixCls, "-picker-focused"), inputFocused), (0, _defineProperty2["default"])(_classNames3, "".concat(prefixCls, "-picker-borderless"), !bordered), _classNames3), className); // Fix bug of https://github.com/facebook/react/pull/5004
316
- // and https://fb.me/react-unknown-prop
317
-
318
- var inputProps = (0, _omit["default"])( // Not know why these props left
319
- otherProps, ['onChange', 'options', 'popupPlacement', 'transitionName', 'displayRender', 'onPopupVisibleChange', 'changeOnSelect', 'expandTrigger', 'popupVisible', 'getPopupContainer', 'loadData', 'filterOption', 'renderFilteredOption', 'sortFilteredOption', 'fieldNames']);
320
- var options = props.options;
321
- var names = getFilledFieldNames(_this.props);
322
-
323
- if (options && options.length > 0) {
324
- if (state.inputValue) {
325
- options = _this.generateFilteredOptions(prefixCls, renderEmpty);
326
- }
327
- } else {
328
- options = [getEmptyNode(renderEmpty, names, notFoundContent)];
329
- } // Dropdown menu should keep previous status until it is fully closed.
330
-
331
-
332
- if (!state.popupVisible) {
333
- options = _this.cachedOptions;
334
- } else {
335
- _this.cachedOptions = options;
336
- }
337
-
338
- var dropdownMenuColumnStyle = {};
339
- var isNotFound = (options || []).length === 1 && options[0].isEmptyNode;
340
-
341
- if (isNotFound) {
342
- dropdownMenuColumnStyle.height = 'auto'; // Height of one row.
343
- } // The default value of `matchInputWidth` is `true`
344
-
345
-
346
- var resultListMatchInputWidth = showSearch.matchInputWidth !== false;
347
-
348
- if (resultListMatchInputWidth && (state.inputValue || isNotFound) && _this.input) {
349
- dropdownMenuColumnStyle.width = _this.input.input.offsetWidth;
350
- }
351
-
352
- var inputIcon;
353
-
354
- if (suffixIcon) {
355
- inputIcon = (0, _reactNode.replaceElement)(suffixIcon, /*#__PURE__*/React.createElement("span", {
356
- className: "".concat(prefixCls, "-picker-arrow")
357
- }, suffixIcon), function () {
358
- var _classNames4;
359
-
360
- return {
361
- className: (0, _classnames["default"])((_classNames4 = {}, (0, _defineProperty2["default"])(_classNames4, suffixIcon.props.className, suffixIcon.props.className), (0, _defineProperty2["default"])(_classNames4, "".concat(prefixCls, "-picker-arrow"), true), _classNames4))
362
- };
363
- });
364
- } else {
365
- inputIcon = /*#__PURE__*/React.createElement(_DownOutlined["default"], {
366
- className: arrowCls
367
- });
368
- }
369
-
370
- var input = children || /*#__PURE__*/React.createElement("span", {
371
- style: style,
372
- className: pickerCls
373
- }, /*#__PURE__*/React.createElement("span", {
374
- className: "".concat(prefixCls, "-picker-label")
375
- }, _this.getLabel()), /*#__PURE__*/React.createElement(_input["default"], (0, _extends2["default"])({}, inputProps, {
376
- tabIndex: -1,
377
- ref: _this.saveInput,
378
- prefixCls: inputPrefixCls,
379
- placeholder: value && value.length > 0 ? undefined : placeholder,
380
- className: "".concat(prefixCls, "-input ").concat(sizeCls),
381
- value: state.inputValue,
382
- disabled: disabled,
383
- readOnly: !showSearch,
384
- autoComplete: inputProps.autoComplete || 'off',
385
- onClick: showSearch ? _this.handleInputClick : undefined,
386
- onBlur: showSearch ? _this.handleInputBlur : undefined,
387
- onKeyDown: _this.handleKeyDown,
388
- onChange: showSearch ? _this.handleInputChange : undefined
389
- })), clearIcon, inputIcon);
390
- var expandIconNode;
391
-
392
- if (expandIcon) {
393
- expandIconNode = expandIcon;
394
- } else {
395
- expandIconNode = isRtlLayout ? /*#__PURE__*/React.createElement(_LeftOutlined["default"], null) : /*#__PURE__*/React.createElement(_RightOutlined["default"], null);
396
- }
397
-
398
- var loadingIcon = /*#__PURE__*/React.createElement("span", {
399
- className: "".concat(prefixCls, "-menu-item-loading-icon")
400
- }, /*#__PURE__*/React.createElement(_RedoOutlined["default"], {
401
- spin: true
402
- }));
403
- var getPopupContainer = props.getPopupContainer || getContextPopupContainer;
404
- var rest = (0, _omit["default"])(props, ['inputIcon', 'expandIcon', 'loadingIcon', 'bordered', 'className']);
405
- var rcCascaderPopupClassName = (0, _classnames["default"])(popupClassName, (_classNames5 = {}, (0, _defineProperty2["default"])(_classNames5, "".concat(prefixCls, "-menu-").concat(direction), direction === 'rtl'), (0, _defineProperty2["default"])(_classNames5, "".concat(prefixCls, "-menu-empty"), options.length === 1 && options[0].value === 'ANT_CASCADER_NOT_FOUND'), _classNames5));
406
- var rootPrefixCls = getPrefixCls();
407
- return /*#__PURE__*/React.createElement(_rcCascader["default"], (0, _extends2["default"])({}, rest, {
408
- prefixCls: prefixCls,
409
- getPopupContainer: getPopupContainer,
410
- options: options,
411
- value: value,
412
- popupVisible: state.popupVisible,
413
- onPopupVisibleChange: _this.handlePopupVisibleChange,
414
- onChange: _this.handleChange,
415
- dropdownMenuColumnStyle: dropdownMenuColumnStyle,
416
- expandIcon: expandIconNode,
417
- loadingIcon: loadingIcon,
418
- popupClassName: rcCascaderPopupClassName,
419
- popupPlacement: _this.getPopupPlacement(direction),
420
- // rc-cascader should update ts define to fix this case
421
- dropdownRender: dropdownRender,
422
- transitionName: (0, _motion.getTransitionName)(rootPrefixCls, 'slide-up', props.transitionName)
423
- }), input);
424
- });
425
- };
164
+ var mergedExpandIcon = expandIcon;
426
165
 
427
- _this.state = {
428
- value: props.value || props.defaultValue || [],
429
- inputValue: '',
430
- inputFocused: false,
431
- popupVisible: props.popupVisible,
432
- flattenOptions: props.showSearch ? flattenTree(props.options, props) : undefined,
433
- prevProps: props
434
- };
435
- return _this;
166
+ if (!expandIcon) {
167
+ mergedExpandIcon = isRtl ? /*#__PURE__*/React.createElement(_LeftOutlined["default"], null) : /*#__PURE__*/React.createElement(_RightOutlined["default"], null);
436
168
  }
437
169
 
438
- (0, _createClass2["default"])(Cascader, [{
439
- key: "componentWillUnmount",
440
- value: function componentWillUnmount() {
441
- if (this.clearSelectionTimeout) {
442
- clearTimeout(this.clearSelectionTimeout);
443
- }
444
- }
445
- }, {
446
- key: "getLabel",
447
- value: function getLabel() {
448
- var _this$props = this.props,
449
- options = _this$props.options,
450
- _this$props$displayRe = _this$props.displayRender,
451
- displayRender = _this$props$displayRe === void 0 ? defaultDisplayRender : _this$props$displayRe;
452
- var names = getFilledFieldNames(this.props);
453
- var value = this.state.value;
454
- var unwrappedValue = Array.isArray(value[0]) ? value[0] : value;
455
- var selectedOptions = (0, _arrayTreeFilter["default"])(options, function (o, level) {
456
- return o[names.value] === unwrappedValue[level];
457
- }, {
458
- childrenKeyName: names.children
459
- });
460
- var label = selectedOptions.length ? selectedOptions.map(function (o) {
461
- return o[names.label];
462
- }) : value;
463
- return displayRender(label, selectedOptions);
464
- }
465
- }, {
466
- key: "generateFilteredOptions",
467
- value: function generateFilteredOptions(prefixCls, renderEmpty) {
468
- var _this2 = this;
469
-
470
- var _this$props2 = this.props,
471
- showSearch = _this$props2.showSearch,
472
- notFoundContent = _this$props2.notFoundContent;
473
- var names = getFilledFieldNames(this.props);
474
- var _showSearch$filter = showSearch.filter,
475
- filter = _showSearch$filter === void 0 ? defaultFilterOption : _showSearch$filter,
476
- _showSearch$render = showSearch.render,
477
- render = _showSearch$render === void 0 ? defaultRenderFilteredOption : _showSearch$render,
478
- _showSearch$sort = showSearch.sort,
479
- sort = _showSearch$sort === void 0 ? defaultSortFilteredOption : _showSearch$sort,
480
- _showSearch$limit = showSearch.limit,
481
- limit = _showSearch$limit === void 0 ? defaultLimit : _showSearch$limit;
482
- var _this$state2 = this.state,
483
- _this$state2$flattenO = _this$state2.flattenOptions,
484
- flattenOptions = _this$state2$flattenO === void 0 ? [] : _this$state2$flattenO,
485
- inputValue = _this$state2.inputValue; // Limit the filter if needed
486
-
487
- var filtered;
488
-
489
- if (limit > 0) {
490
- filtered = [];
491
- var matchCount = 0; // Perf optimization to filter items only below the limit
492
-
493
- flattenOptions.some(function (path) {
494
- var match = filter(_this2.state.inputValue, path, names);
495
-
496
- if (match) {
497
- filtered.push(path);
498
- matchCount += 1;
499
- }
500
-
501
- return matchCount >= limit;
502
- });
503
- } else {
504
- (0, _devWarning["default"])(typeof limit !== 'number', 'Cascader', "'limit' of showSearch should be positive number or false.");
505
- filtered = flattenOptions.filter(function (path) {
506
- return filter(_this2.state.inputValue, path, names);
507
- });
508
- }
509
-
510
- filtered = filtered.sort(function (a, b) {
511
- return sort(a, b, inputValue, names);
512
- });
513
-
514
- if (filtered.length > 0) {
515
- // Fix issue: https://github.com/ant-design/ant-design/issues/26554
516
- var field = names.value === names.label ? keepFilteredValueField : names.value;
517
- return filtered.map(function (path) {
518
- var _ref4;
519
-
520
- return _ref4 = {
521
- __IS_FILTERED_OPTION: true,
522
- path: path
523
- }, (0, _defineProperty2["default"])(_ref4, field, path.map(function (o) {
524
- return o[names.value];
525
- })), (0, _defineProperty2["default"])(_ref4, names.label, render(inputValue, path, prefixCls, names)), (0, _defineProperty2["default"])(_ref4, "disabled", path.some(function (o) {
526
- return !!o.disabled;
527
- })), (0, _defineProperty2["default"])(_ref4, "isEmptyNode", true), _ref4;
528
- });
529
- }
530
-
531
- return [getEmptyNode(renderEmpty, names, notFoundContent)];
532
- }
533
- }, {
534
- key: "focus",
535
- value: function focus() {
536
- this.input.focus();
537
- }
538
- }, {
539
- key: "blur",
540
- value: function blur() {
541
- this.input.blur();
542
- }
543
- }, {
544
- key: "getPopupPlacement",
545
- value: function getPopupPlacement() {
546
- var direction = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ltr';
547
- var popupPlacement = this.props.popupPlacement;
548
-
549
- if (popupPlacement !== undefined) {
550
- return popupPlacement;
551
- }
552
-
553
- return direction === 'rtl' ? 'bottomRight' : 'bottomLeft';
554
- }
555
- }, {
556
- key: "render",
557
- value: function render() {
558
- var _this3 = this;
559
-
560
- return /*#__PURE__*/React.createElement(_configProvider.ConfigConsumer, null, function (configArgument) {
561
- return (
562
- /*#__PURE__*/
563
- // @ts-ignore
564
- React.createElement(_LocaleReceiver["default"], null, function (locale) {
565
- return _this3.renderCascader(configArgument, locale);
566
- })
567
- );
568
- });
569
- }
570
- }], [{
571
- key: "getDerivedStateFromProps",
572
- value: function getDerivedStateFromProps(nextProps, _ref5) {
573
- var prevProps = _ref5.prevProps;
574
- var newState = {
575
- prevProps: nextProps
576
- };
577
-
578
- if ('value' in nextProps) {
579
- newState.value = nextProps.value || [];
580
- }
581
-
582
- if ('popupVisible' in nextProps) {
583
- newState.popupVisible = nextProps.popupVisible;
584
- }
585
-
586
- if (nextProps.showSearch && prevProps.options !== nextProps.options) {
587
- newState.flattenOptions = flattenTree(nextProps.options, nextProps);
588
- }
589
-
590
- if (process.env.NODE_ENV !== 'production' && nextProps.options) {
591
- warningValueNotExist(nextProps.options, getFieldNames(nextProps));
592
- }
593
-
594
- return newState;
595
- }
596
- }]);
597
- return Cascader;
598
- }(React.Component);
599
-
600
- Cascader.defaultProps = {
601
- options: [],
602
- disabled: false,
603
- allowClear: true,
604
- bordered: true
605
- };
170
+ var loadingIcon = /*#__PURE__*/React.createElement("span", {
171
+ className: "".concat(prefixCls, "-menu-item-loading-icon")
172
+ }, /*#__PURE__*/React.createElement(_RedoOutlined["default"], {
173
+ spin: true
174
+ })); // =================== Multiple ====================
175
+
176
+ var checkable = React.useMemo(function () {
177
+ return multiple ? /*#__PURE__*/React.createElement("span", {
178
+ className: "".concat(cascaderPrefixCls, "-checkbox-inner")
179
+ }) : false;
180
+ }, [multiple]); // ===================== Icons =====================
181
+
182
+ var _getIcons = (0, _iconUtil["default"])((0, _extends2["default"])((0, _extends2["default"])({}, props), {
183
+ multiple: multiple,
184
+ prefixCls: prefixCls
185
+ })),
186
+ suffixIcon = _getIcons.suffixIcon,
187
+ removeIcon = _getIcons.removeIcon,
188
+ clearIcon = _getIcons.clearIcon; // ==================== Render =====================
189
+
190
+
191
+ return /*#__PURE__*/React.createElement(_rcCascader["default"], (0, _extends2["default"])({
192
+ prefixCls: prefixCls,
193
+ className: (0, _classnames["default"])(!customizePrefixCls && cascaderPrefixCls, (_classNames2 = {}, (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-lg"), mergedSize === 'large'), (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-sm"), mergedSize === 'small'), (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-rtl"), isRtl), (0, _defineProperty2["default"])(_classNames2, "".concat(prefixCls, "-borderless"), !bordered), _classNames2), className)
194
+ }, restProps, {
195
+ direction: mergedDirection,
196
+ notFoundContent: mergedNotFoundContent,
197
+ allowClear: allowClear,
198
+ showSearch: mergedShowSearch,
199
+ expandIcon: mergedExpandIcon,
200
+ inputIcon: suffixIcon,
201
+ removeIcon: removeIcon,
202
+ clearIcon: clearIcon,
203
+ loadingIcon: loadingIcon,
204
+ checkable: checkable,
205
+ dropdownClassName: mergedDropdownClassName,
206
+ dropdownPrefixCls: customizePrefixCls || cascaderPrefixCls,
207
+ choiceTransitionName: (0, _motion.getTransitionName)(rootPrefixCls, '', choiceTransitionName),
208
+ transitionName: (0, _motion.getTransitionName)(rootPrefixCls, 'slide-up', transitionName),
209
+ getPopupContainer: getPopupContainer || getContextPopupContainer,
210
+ ref: ref
211
+ }));
212
+ });
213
+ Cascader.displayName = 'Cascader';
606
214
  var _default = Cascader;
607
215
  exports["default"] = _default;