x-ui-design 0.2.83 → 0.2.85
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.esm.js +6 -13
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +6 -13
- package/dist/index.js.map +1 -1
- package/lib/components/Select/Select.tsx +35 -38
- package/package.json +1 -1
|
@@ -134,14 +134,20 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
134
134
|
|
|
135
135
|
setSearchQuery('');
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
let inputContainer = selectRef.current?.querySelector(
|
|
138
|
+
`[id='${prefixCls}-search-tag-input']`
|
|
139
139
|
) as HTMLDivElement;
|
|
140
140
|
|
|
141
|
+
if (!inputContainer) {
|
|
142
|
+
inputContainer = selectRef.current?.querySelector(
|
|
143
|
+
"[content-editable='plaintext-only']"
|
|
144
|
+
) as HTMLDivElement;
|
|
145
|
+
}
|
|
146
|
+
|
|
141
147
|
if (inputContainer) {
|
|
142
148
|
inputContainer.innerText = '';
|
|
143
149
|
}
|
|
144
|
-
}, [autoClearSearchValue]);
|
|
150
|
+
}, [autoClearSearchValue, prefixCls]);
|
|
145
151
|
|
|
146
152
|
useEffect(() => {
|
|
147
153
|
const handleClickOutside = (event: MouseEvent): void => {
|
|
@@ -150,12 +156,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
150
156
|
!selectRef.current.contains(event.target as Node)
|
|
151
157
|
) {
|
|
152
158
|
setIsOpen(open);
|
|
153
|
-
|
|
154
|
-
if (hasMode) {
|
|
155
|
-
handleClearInputValue();
|
|
156
|
-
} else {
|
|
157
|
-
setSearchQuery('');
|
|
158
|
-
}
|
|
159
|
+
handleClearInputValue();
|
|
159
160
|
}
|
|
160
161
|
};
|
|
161
162
|
|
|
@@ -322,8 +323,8 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
322
323
|
) {
|
|
323
324
|
const updatedSelected = hasMode
|
|
324
325
|
? (selected as string[]).filter(
|
|
325
|
-
|
|
326
|
-
|
|
326
|
+
item => item !== selected[selected.length - 1]
|
|
327
|
+
)
|
|
327
328
|
: searchQuery.trim();
|
|
328
329
|
|
|
329
330
|
onChange?.(updatedSelected);
|
|
@@ -356,14 +357,10 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
356
357
|
|
|
357
358
|
const extractedOptions = children
|
|
358
359
|
? (Array.isArray(children) ? children : [children])
|
|
359
|
-
|
|
360
|
-
|
|
360
|
+
.filter(e => e)
|
|
361
|
+
.map((child: { props: OptionType }) => child.props)
|
|
361
362
|
: options;
|
|
362
363
|
|
|
363
|
-
useEffect(() => {
|
|
364
|
-
console.log({ filterOption, extractedOptions });
|
|
365
|
-
}, [filterOption, extractedOptions])
|
|
366
|
-
|
|
367
364
|
const filteredOptions = extractedOptions.filter((option: OptionType) => {
|
|
368
365
|
if (typeof filterOption === 'function') {
|
|
369
366
|
return filterOption(searchQuery, option);
|
|
@@ -373,13 +370,12 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
373
370
|
return true;
|
|
374
371
|
}
|
|
375
372
|
|
|
376
|
-
const valueToCheck = `${
|
|
377
|
-
['string', 'number'].includes(typeof option.children)
|
|
373
|
+
const valueToCheck = `${['string', 'number'].includes(typeof option.children)
|
|
378
374
|
? option.children
|
|
379
375
|
: // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
376
|
+
// @ts-expect-error
|
|
377
|
+
option[optionFilterProp] || option.value
|
|
378
|
+
}`;
|
|
383
379
|
|
|
384
380
|
return valueToCheck.toLowerCase().includes(searchQuery.toLowerCase());
|
|
385
381
|
});
|
|
@@ -393,7 +389,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
393
389
|
`${prefixCls}-tag-container`
|
|
394
390
|
)?.[0] as HTMLDivElement;
|
|
395
391
|
|
|
396
|
-
if (searchContent) {
|
|
392
|
+
if (searchContent) {
|
|
397
393
|
setSearchInputWidth(searchContent.clientWidth - PADDING_TAG_INPUT);
|
|
398
394
|
}
|
|
399
395
|
|
|
@@ -439,6 +435,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
439
435
|
return;
|
|
440
436
|
}
|
|
441
437
|
|
|
438
|
+
|
|
442
439
|
handleSelect(
|
|
443
440
|
e as MouseEventHandlerSelect,
|
|
444
441
|
props.value as string,
|
|
@@ -480,12 +477,12 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
480
477
|
maxHeight: listHeight,
|
|
481
478
|
...(['topLeft', 'topRight'].includes(placement)
|
|
482
479
|
? {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
480
|
+
top:
|
|
481
|
+
-(
|
|
482
|
+
(selectRef.current?.querySelector(`.${prefixCls}-dropdown`)
|
|
483
|
+
?.clientHeight || listHeight) + PADDING_PLACEMENT
|
|
484
|
+
) + (selectRef.current?.clientHeight || 0)
|
|
485
|
+
}
|
|
489
486
|
: {})
|
|
490
487
|
}}
|
|
491
488
|
>
|
|
@@ -523,8 +520,8 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
523
520
|
{filteredOptions.length
|
|
524
521
|
? dataRender
|
|
525
522
|
: !asTag
|
|
526
|
-
|
|
527
|
-
|
|
523
|
+
? notFoundContent || <Empty />
|
|
524
|
+
: null}
|
|
528
525
|
</div>
|
|
529
526
|
)}
|
|
530
527
|
</div>
|
|
@@ -582,7 +579,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
582
579
|
tag === ''
|
|
583
580
|
? placeholder
|
|
584
581
|
: extractedOptions.find(e => e.value === tag)
|
|
585
|
-
|
|
582
|
+
?.children || tag
|
|
586
583
|
}
|
|
587
584
|
onClose={handleRemoveTag}
|
|
588
585
|
key={`${index}_${tag}`}
|
|
@@ -620,7 +617,7 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
620
617
|
{selected === ''
|
|
621
618
|
? placeholder
|
|
622
619
|
: extractedOptions.find(e => e.value === selected)
|
|
623
|
-
|
|
620
|
+
?.children || selected}
|
|
624
621
|
</div>
|
|
625
622
|
) : null}
|
|
626
623
|
</div>
|
|
@@ -633,12 +630,12 @@ const SelectComponent = forwardRef<HTMLDivElement, SelectProps>(
|
|
|
633
630
|
{selected === ''
|
|
634
631
|
? placeholder
|
|
635
632
|
: (() => {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
633
|
+
const option = extractedOptions.find(
|
|
634
|
+
e => e.value === selected
|
|
635
|
+
);
|
|
639
636
|
|
|
640
|
-
|
|
641
|
-
|
|
637
|
+
return option?.children || option?.value || null;
|
|
638
|
+
})()}
|
|
642
639
|
</div>
|
|
643
640
|
) : null}
|
|
644
641
|
|