@kne/react-filter 1.0.5 → 1.0.7

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/dist/index.js CHANGED
@@ -10,6 +10,7 @@ var reactDom = require('react-dom');
10
10
  var isNumber = require('lodash/isNumber');
11
11
  var SuperSelect = require('@kne/super-select');
12
12
  var superSelectPlus = require('@kne/super-select-plus');
13
+ require('@kne/super-select/dist/index.css');
13
14
  require('@kne/super-select-plus/dist/index.css');
14
15
  var dayjs = require('dayjs');
15
16
  var transform = require('lodash/transform');
@@ -46,7 +47,7 @@ function _objectWithoutPropertiesLoose(r, e) {
46
47
  return t;
47
48
  }
48
49
 
49
- var style$1 = {"filter":"kne-react-filter_b3gMw","filter-item-icon":"kne-react-filter_e3V6h","filter-item-option-icon":"kne-react-filter_dLoYj","filter-title":"kne-react-filter_khFt2","filter-title-hidden":"kne-react-filter_j2mP1","ad-filter-title":"kne-react-filter_HptIY","ad-filter-line":"kne-react-filter_7Ob6-","filter-line":"kne-react-filter_Y9XTa","clean-btn":"kne-react-filter_CJ935","filter-item":"kne-react-filter_JpaMr","un-expand":"kne-react-filter_LfQME","ad-filter-selected":"kne-react-filter_pBsaE","filter-label":"kne-react-filter_Bx3s8","filter-item-wrap":"kne-react-filter_Co4Pg","option":"kne-react-filter_G1cRp","is-active":"kne-react-filter_Aab98","is-visited":"kne-react-filter_Ww12R","un-expand-shadow":"kne-react-filter_2ExqW","filter-item-label":"kne-react-filter_JAmeE","filter-item-field":"kne-react-filter_WvRvl","filter-drop-tag":"kne-react-filter_dG8rq","filter-list":"kne-react-filter_qlWu6","filter-list-scroll-wrap":"kne-react-filter_oaIF4","filter-list-scroll":"kne-react-filter_Jq43Q","filter-scroll-next":"kne-react-filter_BdfSI","filter-list-tag":"kne-react-filter_LV2VI","filter-tag":"kne-react-filter_yyR3u","filter-tag-value":"kne-react-filter_8nm8n","filter-value-tag":"kne-react-filter_tWyCr","filter-value-tag-label":"kne-react-filter_XPzrL","filter-value-tag-content":"kne-react-filter_6e79l","filter-value-display-content":"kne-react-filter_v2dnw","filter-value-tags-wrap":"kne-react-filter_J1wBU","filter-value-tags":"kne-react-filter_rRhFE","filter-value-actions":"kne-react-filter_-Brt9","filter-value-toggle":"kne-react-filter_WuL0c","pop-util-content":"kne-react-filter_g-hXk","pop-util-body":"kne-react-filter_4n4MP","date-range-picker-popup":"kne-react-filter_6Zx60","pop-util-overlay":"kne-react-filter_m7Csi","pop-util-mask":"kne-react-filter_o2B3k","pop-util-mask-fade-in":"kne-react-filter_oCXiX","pop-util-mask-leave":"kne-react-filter_qGnRO","pop-util-mask-fade-out":"kne-react-filter_cDx1y","field-item-mobile-popup":"kne-react-filter_wq5nf","pop-util-mobile-expand-down":"kne-react-filter_6RxjE","date-picker-popup":"kne-react-filter_iwLs2","pop-util-mobile-collapse-up":"kne-react-filter_009r-","pop-util-footer":"kne-react-filter_iqe8W","pop-util-text":"kne-react-filter_72gGQ","filter-item-inner":"kne-react-filter_cYX12","filter-item-text":"kne-react-filter_cnMY-","filter-item-number-range":"kne-react-filter_Cv2Bw","filter-item-custom":"kne-react-filter_CBczA","filter-item-custom-active":"kne-react-filter_ldxUR","filter-item-number-range-split":"kne-react-filter_4p3C9","filter-item-number-input":"kne-react-filter_yy1y1","range-picker":"kne-react-filter_81zQn","cascader-select-wrap":"kne-react-filter_UHBfi","cascader-dropdown-menu":"kne-react-filter_bY8JQ","filter-advanced":"kne-react-filter_rg45N","filter-advanced-item-other":"kne-react-filter_HcsA8","filter-advanced-item-other-inner":"kne-react-filter_4Bqtz","filter-advanced-more":"kne-react-filter_jVH7z","filter-value-display":"kne-react-filter_8-R34","is-not-overflow":"kne-react-filter_TM1E2","is-expand":"kne-react-filter_7aclr","filter-value-scroll-prev-shadow":"kne-react-filter_C1t-q","filter-value-scroll-next-shadow":"kne-react-filter_ZFoeL","is-overflow":"kne-react-filter_GhFCl","filter-value-action-placeholder":"kne-react-filter_wGZp6","filter-value-action-right":"kne-react-filter_vyPwo","filter-scroll-prev-shadow":"kne-react-filter_fyhz3","filter-scroll-next-icon":"kne-react-filter_Fd6ab"};
50
+ var style$1 = {"filter":"kne-react-filter_b3gMw","filter-item-icon":"kne-react-filter_e3V6h","filter-item-option-icon":"kne-react-filter_dLoYj","filter-title":"kne-react-filter_khFt2","filter-title-hidden":"kne-react-filter_j2mP1","ad-filter-title":"kne-react-filter_HptIY","ad-filter-line":"kne-react-filter_7Ob6-","filter-line":"kne-react-filter_Y9XTa","clean-btn":"kne-react-filter_CJ935","filter-item":"kne-react-filter_JpaMr","un-expand":"kne-react-filter_LfQME","ad-filter-selected":"kne-react-filter_pBsaE","filter-label":"kne-react-filter_Bx3s8","filter-line-nowrap":"kne-react-filter_Ccx24","filter-line-measure":"kne-react-filter_uMXzo","filter-item-wrap":"kne-react-filter_Co4Pg","option":"kne-react-filter_G1cRp","is-active":"kne-react-filter_Aab98","is-visited":"kne-react-filter_Ww12R","un-expand-shadow":"kne-react-filter_2ExqW","filter-item-label":"kne-react-filter_JAmeE","filter-item-field":"kne-react-filter_WvRvl","filter-drop-tag":"kne-react-filter_dG8rq","filter-list":"kne-react-filter_qlWu6","filter-list-scroll-wrap":"kne-react-filter_oaIF4","filter-list-constrained":"kne-react-filter_3gXxO","filter-list-scroll":"kne-react-filter_Jq43Q","filter-scroll-next":"kne-react-filter_BdfSI","filter-list-tag":"kne-react-filter_LV2VI","filter-tag":"kne-react-filter_yyR3u","filter-tag-value":"kne-react-filter_8nm8n","filter-value-tag":"kne-react-filter_tWyCr","filter-value-tag-label":"kne-react-filter_XPzrL","filter-value-tag-content":"kne-react-filter_6e79l","filter-value-display-content":"kne-react-filter_v2dnw","filter-value-tags-wrap":"kne-react-filter_J1wBU","filter-value-tags":"kne-react-filter_rRhFE","filter-value-actions":"kne-react-filter_-Brt9","filter-value-toggle":"kne-react-filter_WuL0c","pop-util-content":"kne-react-filter_g-hXk","pop-util-body":"kne-react-filter_4n4MP","date-range-picker-popup":"kne-react-filter_6Zx60","pop-util-overlay":"kne-react-filter_m7Csi","pop-util-mask":"kne-react-filter_o2B3k","pop-util-mask-fade-in":"kne-react-filter_oCXiX","pop-util-mask-leave":"kne-react-filter_qGnRO","pop-util-mask-fade-out":"kne-react-filter_cDx1y","field-item-mobile-popup":"kne-react-filter_wq5nf","pop-util-mobile-expand-down":"kne-react-filter_6RxjE","date-picker-popup":"kne-react-filter_iwLs2","pop-util-mobile-collapse-up":"kne-react-filter_009r-","pop-util-footer":"kne-react-filter_iqe8W","pop-util-text":"kne-react-filter_72gGQ","filter-item-inner":"kne-react-filter_cYX12","filter-item-text":"kne-react-filter_cnMY-","filter-item-number-range":"kne-react-filter_Cv2Bw","filter-item-custom":"kne-react-filter_CBczA","filter-item-custom-active":"kne-react-filter_ldxUR","filter-item-number-range-split":"kne-react-filter_4p3C9","filter-item-number-input":"kne-react-filter_yy1y1","range-picker":"kne-react-filter_81zQn","cascader-select-wrap":"kne-react-filter_UHBfi","cascader-dropdown-menu":"kne-react-filter_bY8JQ","filter-advanced":"kne-react-filter_rg45N","filter-advanced-item-other":"kne-react-filter_HcsA8","filter-advanced-item-other-inner":"kne-react-filter_4Bqtz","filter-advanced-more":"kne-react-filter_jVH7z","filter-value-display":"kne-react-filter_8-R34","is-not-overflow":"kne-react-filter_TM1E2","is-expand":"kne-react-filter_7aclr","filter-value-scroll-prev-shadow":"kne-react-filter_C1t-q","filter-value-scroll-next-shadow":"kne-react-filter_ZFoeL","is-overflow":"kne-react-filter_GhFCl","filter-value-action-placeholder":"kne-react-filter_wGZp6","filter-value-action-right":"kne-react-filter_vyPwo","filter-scroll-prev-shadow":"kne-react-filter_fyhz3","filter-scroll-next-icon":"kne-react-filter_Fd6ab"};
50
51
 
51
52
  const context = /*#__PURE__*/react.createContext({});
52
53
  const Provider = context.Provider;
@@ -124,53 +125,291 @@ const useHorizontalScrollShadows = ({
124
125
  };
125
126
  };
126
127
 
127
- const Line$1 = _ref => {
128
- let list = _ref.list,
129
- children = _ref.children;
128
+ const GAP = 8;
129
+ const SAFETY_GAP = 2;
130
+ const useVisibleItemCount = ({
131
+ items,
132
+ enabled,
133
+ strategy = 'asc'
134
+ }) => {
135
+ const safeItems = Array.isArray(items) ? items : [];
136
+ const containerRef = react.useRef(null);
137
+ const measureRef = react.useRef(null);
138
+ const moreMeasureRef = react.useRef(null);
139
+ const rafRef = react.useRef(null);
140
+ const lastWidthRef = react.useRef(0);
141
+ const [containerEl, setContainerEl] = react.useState(null);
142
+ const [visibleCount, setVisibleCount] = react.useState(() => safeItems.length > 0 ? 1 : 0);
143
+ const setContainerRef = react.useCallback(node => {
144
+ containerRef.current = node;
145
+ setContainerEl(node || null);
146
+ }, []);
147
+ const setMeasureRef = react.useCallback(node => {
148
+ measureRef.current = node;
149
+ }, []);
150
+ const setMoreMeasureRef = react.useCallback(node => {
151
+ moreMeasureRef.current = node;
152
+ }, []);
153
+ const getWidths = react.useCallback(() => {
154
+ const container = containerRef.current;
155
+ const measureEl = measureRef.current;
156
+ if (!container || !measureEl) {
157
+ return null;
158
+ }
159
+ const containerWidth = container.clientWidth;
160
+ if (containerWidth <= 0) {
161
+ return null;
162
+ }
163
+ const itemNodes = measureEl.querySelectorAll('[data-filter-measure-item]');
164
+ if (!itemNodes.length) {
165
+ return null;
166
+ }
167
+ const moreButtonWidth = moreMeasureRef.current?.getBoundingClientRect().width || 0;
168
+ if (safeItems.length > 1 && moreButtonWidth <= 0) {
169
+ return null;
170
+ }
171
+ const itemWidths = Array.from(itemNodes, node => node.getBoundingClientRect().width);
172
+ return {
173
+ containerWidth,
174
+ itemWidths,
175
+ moreButtonWidth
176
+ };
177
+ }, [safeItems.length]);
178
+ const getWidthForCount = react.useCallback((itemWidths, moreButtonWidth, count) => {
179
+ let usedWidth = 0;
180
+ for (let i = 0; i < count; i++) {
181
+ usedWidth += itemWidths[i] + (i > 0 ? GAP : 0);
182
+ }
183
+ if (count < safeItems.length) {
184
+ usedWidth += GAP + moreButtonWidth;
185
+ }
186
+ return usedWidth;
187
+ }, [safeItems.length]);
188
+ const resolveVisibleCount = react.useCallback(widths => {
189
+ const {
190
+ containerWidth,
191
+ itemWidths,
192
+ moreButtonWidth
193
+ } = widths;
194
+ const maxCount = Math.min(safeItems.length, itemWidths.length);
195
+ let count = 1;
196
+ if (strategy === 'desc') {
197
+ count = maxCount;
198
+ while (count > 1) {
199
+ const usedWidth = getWidthForCount(itemWidths, moreButtonWidth, count);
200
+ if (usedWidth + SAFETY_GAP <= containerWidth) {
201
+ break;
202
+ }
203
+ count -= 1;
204
+ }
205
+ } else {
206
+ count = 1;
207
+ while (count < maxCount) {
208
+ const nextCount = count + 1;
209
+ const usedWidth = getWidthForCount(itemWidths, moreButtonWidth, nextCount);
210
+ if (usedWidth + SAFETY_GAP > containerWidth) {
211
+ break;
212
+ }
213
+ count = nextCount;
214
+ }
215
+ }
216
+ return Math.max(1, count);
217
+ }, [getWidthForCount, safeItems.length, strategy]);
218
+ const calculateByWidth = react.useCallback(() => {
219
+ if (!enabled || !safeItems.length) {
220
+ setVisibleCount(prev => prev === safeItems.length ? prev : safeItems.length);
221
+ return;
222
+ }
223
+ const widths = getWidths();
224
+ if (!widths) {
225
+ return;
226
+ }
227
+ const nextCount = resolveVisibleCount(widths);
228
+ setVisibleCount(prev => prev === nextCount ? prev : nextCount);
229
+ }, [enabled, getWidths, safeItems.length, resolveVisibleCount]);
230
+ const scheduleCalculate = react.useCallback(() => {
231
+ if (rafRef.current) {
232
+ window.cancelAnimationFrame(rafRef.current);
233
+ }
234
+ rafRef.current = window.requestAnimationFrame(() => {
235
+ rafRef.current = null;
236
+ calculateByWidth();
237
+ });
238
+ }, [calculateByWidth]);
239
+ react.useLayoutEffect(() => {
240
+ scheduleCalculate();
241
+ return () => {
242
+ if (rafRef.current) {
243
+ window.cancelAnimationFrame(rafRef.current);
244
+ rafRef.current = null;
245
+ }
246
+ };
247
+ }, [safeItems, scheduleCalculate]);
248
+ react.useEffect(() => {
249
+ if (!enabled || !containerEl) {
250
+ return undefined;
251
+ }
252
+ const observer = new ResizeObserver(entries => {
253
+ const entry = entries.find(item => item.target === containerEl);
254
+ const nextWidth = entry?.contentRect.width ?? containerEl.clientWidth;
255
+ if (Math.abs(nextWidth - lastWidthRef.current) < 1) {
256
+ return;
257
+ }
258
+ lastWidthRef.current = nextWidth;
259
+ scheduleCalculate();
260
+ });
261
+ lastWidthRef.current = containerEl.clientWidth;
262
+ observer.observe(containerEl);
263
+ window.addEventListener('resize', scheduleCalculate);
264
+ return () => {
265
+ observer.disconnect();
266
+ window.removeEventListener('resize', scheduleCalculate);
267
+ if (rafRef.current) {
268
+ window.cancelAnimationFrame(rafRef.current);
269
+ rafRef.current = null;
270
+ }
271
+ };
272
+ }, [containerEl, enabled, scheduleCalculate]);
273
+ return {
274
+ setContainerRef,
275
+ setMeasureRef,
276
+ setMoreMeasureRef,
277
+ visibleCount
278
+ };
279
+ };
280
+
281
+ const isFilterListItem = item => {
282
+ if (!item) return false;
283
+ if (typeof item === 'function') return true;
284
+ return !!item.type;
285
+ };
286
+ const isNestedFilterList = list => {
287
+ if (!Array.isArray(list) || list.length === 0) return false;
288
+ return Array.isArray(list[0]) && !isFilterListItem(list[0]);
289
+ };
290
+ const normalizeFilterList = list => {
291
+ const safeList = Array.isArray(list) ? list : [];
292
+ if (!safeList.length) {
293
+ return {
294
+ mode: 'flat',
295
+ items: [],
296
+ lines: []
297
+ };
298
+ }
299
+ if (isNestedFilterList(safeList)) {
300
+ return {
301
+ mode: 'nested',
302
+ items: [],
303
+ lines: safeList
304
+ };
305
+ }
306
+ return {
307
+ mode: 'flat',
308
+ items: safeList,
309
+ lines: []
310
+ };
311
+ };
312
+ const getMobileFilterList = list => {
313
+ const {
314
+ mode,
315
+ items,
316
+ lines
317
+ } = normalizeFilterList(list);
318
+ if (mode === 'flat') return items;
319
+ return lines.reduce((result, line) => result.concat(line), []);
320
+ };
321
+
322
+ const isValidFilterItem = item => !!item && (item.type || typeof item === 'function');
323
+ const useFilterItemRenderer = () => {
130
324
  const _useContext = useContext(),
131
325
  value = _useContext.value,
132
326
  onChange = _useContext.onChange;
133
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
134
- className: style$1['filter-line'],
135
- children: [list.filter(item => !!item.type).map((item, index) => {
136
- if (typeof item === 'function') {
137
- return item(props => {
138
- return {
139
- index,
140
- value: value ? get__default["default"](value.get(props == null ? void 0 : props.name), 'value') : props == null ? void 0 : props.value,
141
- onChange: onChange ? value => onChange({
142
- name: props == null ? void 0 : props.name,
143
- label: props == null ? void 0 : props.label,
144
- value
145
- }) : props == null ? void 0 : props.onChange
146
- };
147
- });
148
- }
149
- const ComponentItem = item.type;
150
- return /*#__PURE__*/react.createElement(ComponentItem, _extends({}, Object.assign({}, item.props, {
151
- value: value ? get__default["default"](value.get(item.props.name), 'value') : item.props.value,
152
- onChange: onChange ? value => onChange({
153
- name: item.props.name,
154
- label: item.props.label,
155
- value
156
- }) : item.props.onChange
157
- }), {
158
- key: item.key || item.props.name || index
327
+ return react.useCallback((item, index) => {
328
+ if (typeof item === 'function') {
329
+ return item(props => ({
330
+ index,
331
+ value: value ? get__default["default"](value.get(props == null ? void 0 : props.name), 'value') : props == null ? void 0 : props.value,
332
+ onChange: onChange ? nextValue => onChange({
333
+ name: props == null ? void 0 : props.name,
334
+ label: props == null ? void 0 : props.label,
335
+ value: nextValue
336
+ }) : props == null ? void 0 : props.onChange
159
337
  }));
160
- }), children]
338
+ }
339
+ const ComponentItem = item.type;
340
+ return /*#__PURE__*/react.createElement(ComponentItem, _extends({}, Object.assign({}, item.props, {
341
+ value: value ? get__default["default"](value.get(item.props.name), 'value') : item.props.value,
342
+ onChange: onChange ? nextValue => onChange({
343
+ name: item.props.name,
344
+ label: item.props.label,
345
+ value: nextValue
346
+ }) : item.props.onChange
347
+ }), {
348
+ key: item.key || item.props.name || index
349
+ }));
350
+ }, [onChange, value]);
351
+ };
352
+ const Line$1 = _ref => {
353
+ let list = _ref.list,
354
+ children = _ref.children,
355
+ innerRef = _ref.innerRef,
356
+ nowrap = _ref.nowrap;
357
+ const renderItem = useFilterItemRenderer();
358
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
359
+ ref: innerRef,
360
+ className: classnames__default["default"](style$1['filter-line'], {
361
+ [style$1['filter-line-nowrap']]: nowrap
362
+ }),
363
+ children: [list.filter(isValidFilterItem).map((item, index) => renderItem(item, index)), children]
161
364
  });
162
365
  };
163
- const FilterLines = _ref2 => {
164
- let className = _ref2.className,
165
- _ref2$list = _ref2.list,
166
- list = _ref2$list === void 0 ? [] : _ref2$list,
167
- _ref2$displayLine = _ref2.displayLine,
168
- displayLine = _ref2$displayLine === void 0 ? 1 : _ref2$displayLine,
169
- label = _ref2.label,
170
- extra = _ref2.extra,
171
- children = _ref2.children;
172
- const hasMore = list.length > displayLine;
173
- const mobileList = list.reduce((result, item) => result.concat(Array.isArray(item) ? item : [item]), []);
366
+ const CollapseButtons = _ref2 => {
367
+ let onClick = _ref2.onClick,
368
+ toggleUpText = _ref2.toggleUpText;
369
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
370
+ children: [/*#__PURE__*/jsxRuntime.jsx(antd.Space, {
371
+ size: 4,
372
+ className: classnames__default["default"](style$1['un-expand-shadow']),
373
+ children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
374
+ size: 4,
375
+ className: classnames__default["default"](style$1['option'], style$1['filter-item']),
376
+ children: [toggleUpText, /*#__PURE__*/jsxRuntime.jsx("span", {
377
+ className: style$1['filter-item-option-icon'],
378
+ children: "\u25B2"
379
+ })]
380
+ })
381
+ }), /*#__PURE__*/jsxRuntime.jsx(antd.Space, {
382
+ size: 4,
383
+ className: classnames__default["default"](style$1['un-expand']),
384
+ onClick: onClick,
385
+ children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
386
+ size: 4,
387
+ className: classnames__default["default"](style$1['option'], style$1['filter-item']),
388
+ children: [toggleUpText, /*#__PURE__*/jsxRuntime.jsx("span", {
389
+ className: style$1['filter-item-option-icon'],
390
+ children: "\u25B2"
391
+ })]
392
+ })
393
+ })]
394
+ });
395
+ };
396
+ const FilterLines = _ref3 => {
397
+ let className = _ref3.className,
398
+ _ref3$list = _ref3.list,
399
+ list = _ref3$list === void 0 ? [] : _ref3$list,
400
+ _ref3$displayLine = _ref3.displayLine,
401
+ displayLine = _ref3$displayLine === void 0 ? 1 : _ref3$displayLine,
402
+ label = _ref3.label,
403
+ extra = _ref3.extra,
404
+ children = _ref3.children,
405
+ _ref3$visibleCountStr = _ref3.visibleCountStrategy,
406
+ visibleCountStrategy = _ref3$visibleCountStr === void 0 ? 'asc' : _ref3$visibleCountStr;
407
+ const _useMemo = react.useMemo(() => normalizeFilterList(list), [list]),
408
+ mode = _useMemo.mode,
409
+ flatItems = _useMemo.items,
410
+ lines = _useMemo.lines;
411
+ const mobileList = react.useMemo(() => getMobileFilterList(list), [list]);
412
+ const isFlatMode = mode === 'flat';
174
413
  const _useState = react.useState(false),
175
414
  isExpand = _useState[0],
176
415
  setIsExpand = _useState[1];
@@ -182,10 +421,38 @@ const FilterLines = _ref2 => {
182
421
  scrollRef = _useHorizontalScrollS.scrollRef,
183
422
  showScrollPrev = _useHorizontalScrollS.showScrollPrev,
184
423
  showScrollNext = _useHorizontalScrollS.showScrollNext;
424
+ const _useVisibleItemCount = useVisibleItemCount({
425
+ items: flatItems,
426
+ enabled: !isMobile && isFlatMode,
427
+ strategy: visibleCountStrategy
428
+ }),
429
+ setContainerRef = _useVisibleItemCount.setContainerRef,
430
+ setMeasureRef = _useVisibleItemCount.setMeasureRef,
431
+ setMoreMeasureRef = _useVisibleItemCount.setMoreMeasureRef,
432
+ visibleCount = _useVisibleItemCount.visibleCount;
433
+ const renderItem = useFilterItemRenderer();
185
434
  const _useIntl = reactIntl.useIntl({
186
435
  moduleName: 'Filter'
187
436
  }),
188
437
  formatMessage = _useIntl.formatMessage;
438
+ const visibleFlatItems = isFlatMode ? flatItems.slice(0, visibleCount) : [];
439
+ const hiddenFlatItems = isFlatMode ? flatItems.slice(visibleCount) : [];
440
+ const hasMoreFlat = hiddenFlatItems.length > 0;
441
+ const hasMoreNested = !isFlatMode && lines.length > displayLine;
442
+ const hasMore = isFlatMode ? hasMoreFlat : hasMoreNested;
443
+ const visibleLines = !isFlatMode ? lines.slice(0, displayLine) : [];
444
+ const hiddenLines = !isFlatMode ? lines.slice(displayLine) : [];
445
+ const showLabel = isFlatMode ? flatItems.length > 0 : lines.length > 0;
446
+ const setScrollContainerRef = react.useCallback(node => {
447
+ scrollRef.current = node;
448
+ }, [scrollRef]);
449
+ const setMeasureContainerRef = react.useCallback(node => {
450
+ if (!isMobile && isFlatMode) {
451
+ setContainerRef(node);
452
+ } else {
453
+ setContainerRef(null);
454
+ }
455
+ }, [isFlatMode, isMobile, setContainerRef]);
189
456
  const scrollToNext = react.useCallback(() => {
190
457
  const el = scrollRef.current;
191
458
  if (!el) return;
@@ -205,6 +472,62 @@ const FilterLines = _ref2 => {
205
472
  inline: 'center'
206
473
  });
207
474
  }, [isMobile, scrollRef]);
475
+ const toggleExpand = react.useCallback(() => {
476
+ setIsExpand(value => !value);
477
+ }, []);
478
+ const moreButtonLabel = /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
479
+ children: [formatMessage({
480
+ id: 'moreText'
481
+ }), /*#__PURE__*/jsxRuntime.jsx("span", {
482
+ className: style$1['filter-item-option-icon'],
483
+ children: "\u25BC"
484
+ })]
485
+ });
486
+ const moreButton = /*#__PURE__*/jsxRuntime.jsx(antd.Space, {
487
+ size: 4,
488
+ className: classnames__default["default"](style$1['filter-item'], style$1['option']),
489
+ onClick: toggleExpand,
490
+ children: moreButtonLabel
491
+ });
492
+ const renderDesktopContent = () => {
493
+ if (isFlatMode) {
494
+ return /*#__PURE__*/jsxRuntime.jsx(Line$1, {
495
+ list: visibleFlatItems,
496
+ nowrap: hasMoreFlat && !isExpand,
497
+ children: hasMoreFlat && !isExpand ? /*#__PURE__*/jsxRuntime.jsx("span", {
498
+ "data-filter-more": true,
499
+ children: moreButton
500
+ }) : null
501
+ });
502
+ }
503
+ return visibleLines.map((line, index) => /*#__PURE__*/jsxRuntime.jsx(Line$1, {
504
+ list: line,
505
+ children: hasMoreNested && !isExpand && index === displayLine - 1 ? moreButton : null
506
+ }, index));
507
+ };
508
+ const renderExpandedContent = () => {
509
+ if (isFlatMode) {
510
+ if (!hiddenFlatItems.length) return null;
511
+ return /*#__PURE__*/jsxRuntime.jsx(Line$1, {
512
+ list: hiddenFlatItems,
513
+ children: /*#__PURE__*/jsxRuntime.jsx(CollapseButtons, {
514
+ onClick: toggleExpand,
515
+ toggleUpText: formatMessage({
516
+ id: 'toggleUpText'
517
+ })
518
+ })
519
+ });
520
+ }
521
+ return hiddenLines.map((line, index) => /*#__PURE__*/jsxRuntime.jsx(Line$1, {
522
+ list: line,
523
+ children: index === hiddenLines.length - 1 ? /*#__PURE__*/jsxRuntime.jsx(CollapseButtons, {
524
+ onClick: toggleExpand,
525
+ toggleUpText: formatMessage({
526
+ id: 'toggleUpText'
527
+ })
528
+ }) : null
529
+ }, index));
530
+ };
208
531
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
209
532
  children: [/*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
210
533
  className: classnames__default["default"](style$1['filter-title'], 'filter-title', className),
@@ -212,7 +535,7 @@ const FilterLines = _ref2 => {
212
535
  size: 16,
213
536
  children: [/*#__PURE__*/jsxRuntime.jsx("span", {
214
537
  className: style$1['filter-label'],
215
- children: list && list.length > 0 && (label || formatMessage({
538
+ children: showLabel && (label || formatMessage({
216
539
  id: 'filterText'
217
540
  }))
218
541
  }), /*#__PURE__*/jsxRuntime.jsxs(antd.Row, {
@@ -223,29 +546,38 @@ const FilterLines = _ref2 => {
223
546
  className: style$1['filter-list'],
224
547
  flex: 1,
225
548
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
226
- className: style$1['filter-list-scroll-wrap'],
227
- children: [isMobile && showScrollPrev ? /*#__PURE__*/jsxRuntime.jsx("div", {
549
+ ref: setMeasureContainerRef,
550
+ className: classnames__default["default"](style$1['filter-list-scroll-wrap'], {
551
+ [style$1['filter-list-constrained']]: !isMobile && isFlatMode
552
+ }),
553
+ children: [!isMobile && isFlatMode ? /*#__PURE__*/jsxRuntime.jsxs("div", {
554
+ ref: setMeasureRef,
555
+ className: classnames__default["default"](style$1['filter-line'], style$1['filter-line-measure']),
556
+ "aria-hidden": true,
557
+ children: [flatItems.filter(isValidFilterItem).map((item, index) => {
558
+ var _item$props;
559
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
560
+ "data-filter-measure-item": true,
561
+ children: renderItem(item, index)
562
+ }, item.key || ((_item$props = item.props) == null ? void 0 : _item$props.name) || index);
563
+ }), /*#__PURE__*/jsxRuntime.jsx("div", {
564
+ ref: setMoreMeasureRef,
565
+ "data-filter-measure-more": true,
566
+ children: /*#__PURE__*/jsxRuntime.jsx(antd.Space, {
567
+ size: 4,
568
+ className: classnames__default["default"](style$1['filter-item'], style$1['option']),
569
+ children: moreButtonLabel
570
+ })
571
+ })]
572
+ }) : null, isMobile && showScrollPrev ? /*#__PURE__*/jsxRuntime.jsx("div", {
228
573
  className: style$1['filter-scroll-prev-shadow']
229
574
  }) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
230
575
  className: style$1['filter-list-scroll'],
231
- ref: scrollRef,
576
+ ref: setScrollContainerRef,
232
577
  onClick: scrollItemIntoView,
233
- children: (isMobile ? mobileList : list.slice(0, displayLine)).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(Line$1, {
234
- list: isMobile ? [item] : item,
235
- children: !isMobile && hasMore && isExpand === false && index === displayLine - 1 ? /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
236
- size: 4,
237
- className: classnames__default["default"](style$1['filter-item'], style$1['option']),
238
- onClick: () => {
239
- setIsExpand(value => !value);
240
- },
241
- children: [formatMessage({
242
- id: 'moreText'
243
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
244
- className: style$1['filter-item-option-icon'],
245
- children: "\u25BC"
246
- })]
247
- }) : null
248
- }, index))
578
+ children: isMobile ? mobileList.map((item, index) => /*#__PURE__*/jsxRuntime.jsx(Line$1, {
579
+ list: [item]
580
+ }, index)) : renderDesktopContent()
249
581
  }), isMobile && showScrollNext ? /*#__PURE__*/jsxRuntime.jsx("button", {
250
582
  type: "button",
251
583
  className: style$1['filter-scroll-next'],
@@ -279,41 +611,7 @@ const FilterLines = _ref2 => {
279
611
  })
280
612
  }), /*#__PURE__*/jsxRuntime.jsx("div", {
281
613
  className: style$1['filter-list'],
282
- children: list.slice(displayLine).map((item, index) => /*#__PURE__*/jsxRuntime.jsx(Line$1, {
283
- list: item,
284
- children: index === list.length - displayLine - 1 && /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
285
- children: [/*#__PURE__*/jsxRuntime.jsx(antd.Space, {
286
- size: 4,
287
- className: classnames__default["default"](style$1['un-expand-shadow']),
288
- children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
289
- size: 4,
290
- className: classnames__default["default"](style$1['option'], style$1['filter-item']),
291
- children: [formatMessage({
292
- id: 'toggleUpText'
293
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
294
- className: style$1['filter-item-option-icon'],
295
- children: "\u25B2"
296
- })]
297
- })
298
- }), /*#__PURE__*/jsxRuntime.jsx(antd.Space, {
299
- size: 4,
300
- className: classnames__default["default"](style$1['un-expand']),
301
- onClick: () => {
302
- setIsExpand(value => !value);
303
- },
304
- children: /*#__PURE__*/jsxRuntime.jsxs(antd.Space, {
305
- size: 4,
306
- className: classnames__default["default"](style$1['option'], style$1['filter-item']),
307
- children: [formatMessage({
308
- id: 'toggleUpText'
309
- }), /*#__PURE__*/jsxRuntime.jsx("span", {
310
- className: style$1['filter-item-option-icon'],
311
- children: "\u25B2"
312
- })]
313
- })
314
- })]
315
- })
316
- }, index))
614
+ children: renderExpandedContent()
317
615
  })]
318
616
  })]
319
617
  });
@@ -1438,6 +1736,15 @@ const NumberRangeFilterItem = withInputDefaultPlaceholder(NumberRangeFilterItem$
1438
1736
  const SuperSelectFilterItem = withFieldItem(SuperSelect__default["default"], {
1439
1737
  forcePopup: true
1440
1738
  });
1739
+ const SelectTableListFilterItem = withFieldItem(SuperSelect.SelectTableList, {
1740
+ forcePopup: true
1741
+ });
1742
+ const SelectTreeFilterItem = withFieldItem(SuperSelect.SelectTree, {
1743
+ forcePopup: true
1744
+ });
1745
+ const SelectCascaderFilterItem = withFieldItem(SuperSelect.SelectCascader, {
1746
+ forcePopup: true
1747
+ });
1441
1748
  const SelectFunctionFilterItem = withFieldItem(superSelectPlus.SelectFunction, {
1442
1749
  forcePopup: true
1443
1750
  });
@@ -1453,6 +1760,9 @@ var fields$1 = {
1453
1760
  InputFilterItem: InputFilterItem$1,
1454
1761
  NumberRangeFilterItem: NumberRangeFilterItem,
1455
1762
  SuperSelectFilterItem: SuperSelectFilterItem,
1763
+ SelectTableListFilterItem: SelectTableListFilterItem,
1764
+ SelectTreeFilterItem: SelectTreeFilterItem,
1765
+ SelectCascaderFilterItem: SelectCascaderFilterItem,
1456
1766
  SelectFunctionFilterItem: SelectFunctionFilterItem,
1457
1767
  SelectIndustryFilterItem: SelectIndustryFilterItem,
1458
1768
  SelectAddressFilterItem: SelectAddressFilterItem,
@@ -2509,8 +2819,11 @@ exports.NumberRangeFilterItem = NumberRangeFilterItem;
2509
2819
  exports.PopoverItem = PopoverItem;
2510
2820
  exports.SearchInput = SearchInput;
2511
2821
  exports.SelectAddressFilterItem = SelectAddressFilterItem;
2822
+ exports.SelectCascaderFilterItem = SelectCascaderFilterItem;
2512
2823
  exports.SelectFunctionFilterItem = SelectFunctionFilterItem;
2513
2824
  exports.SelectIndustryFilterItem = SelectIndustryFilterItem;
2825
+ exports.SelectTableListFilterItem = SelectTableListFilterItem;
2826
+ exports.SelectTreeFilterItem = SelectTreeFilterItem;
2514
2827
  exports.SuperSelectFilterItem = SuperSelectFilterItem;
2515
2828
  exports.TypeDateRangePickerField = TypeDateRangePickerField;
2516
2829
  exports.TypeDateRangePickerFilterItem = TypeDateRangePickerFilterItem;