x-ui-design 0.6.44 → 0.6.45

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 CHANGED
@@ -3647,7 +3647,9 @@ const SelectComponent = ({
3647
3647
  isOpen: isOpen
3648
3648
  }));
3649
3649
  }, [showArrow, showSearch, isOpen, suffixIcon, searchIcon]);
3650
- const extractedOptions = children ? extractOptions(children) : Array.isArray(options) ? options : [];
3650
+ const extractedOptions = useMemo(() => {
3651
+ return children ? extractOptions(children) : Array.isArray(options) ? options : [];
3652
+ }, [children, children]);
3651
3653
  const triggerNode = useMemo(() => {
3652
3654
  return selectRef.current?.querySelector(`.${prefixCls}-trigger`);
3653
3655
  }, [prefixCls]);
@@ -3699,76 +3701,6 @@ const SelectComponent = ({
3699
3701
  setSearchInputWidth(searchContent.clientWidth - PADDING_TAG_INPUT);
3700
3702
  }
3701
3703
  };
3702
- const dropdownContent = !loading && open && isOpen && /*#__PURE__*/React.createElement("div", {
3703
- className: clsx([`${prefixCls}-dropdown`, {
3704
- [placement]: placement,
3705
- [dropdownClassName]: dropdownClassName
3706
- }]),
3707
- style: {
3708
- ...dropdownPosition,
3709
- maxHeight: dropdownRender ? 'unset' : listHeight,
3710
- opacity: Object.keys(dropdownPosition).length ? 1 : 0
3711
- }
3712
- }, filterable && /*#__PURE__*/React.createElement("input", {
3713
- type: "text",
3714
- inputMode: "text",
3715
- className: `${prefixCls}-search`,
3716
- value: searchQuery,
3717
- onChange: handleSearch,
3718
- placeholder: "Search..."
3719
- }), !loading &&
3720
- /*#__PURE__*/
3721
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3722
- // @ts-expect-error
3723
- React.createElement(ConditionalWrapper, {
3724
- wrapper: element => {
3725
- return dropdownRender?.(element || /*#__PURE__*/React.createElement(React.Fragment, null, " ")) || /*#__PURE__*/React.createElement(React.Fragment, null, " ");
3726
- },
3727
- condition: !!dropdownRender
3728
- }, /*#__PURE__*/React.createElement("div", {
3729
- className: `${prefixCls}-options`,
3730
- style: {
3731
- maxHeight: listHeight,
3732
- overflowY: 'auto',
3733
- // display: !filteredOptions.length && asTag ? 'none' : 'block',
3734
- maxWidth: selectRef.current ? `${selectRef.current.getBoundingClientRect().width}px` : 'inherit'
3735
- }
3736
- }, asTag && !!searchQuery && /*#__PURE__*/React.createElement(Option, {
3737
- value: searchQuery,
3738
- className: `${prefixCls}-focused`,
3739
- onClick: e => {
3740
- handleSelect(e, searchQuery);
3741
- },
3742
- "data-value": searchQuery
3743
- }, searchQuery), filteredOptions.length ? filteredOptions.map(({
3744
- children,
3745
- className = '',
3746
- ...props
3747
- }, index) => {
3748
- const isSelected = hasMode ? selected.includes(props.value) : props.value === selected;
3749
- return /*#__PURE__*/React.createElement(Option, _extends({
3750
- key: `${props.value}_${index}`
3751
- }, props, {
3752
- selected: isSelected,
3753
- className: clsx([className, {
3754
- [`${prefixCls}-focused`]: hasMode ? isSelected : props.value === selected,
3755
- [`${prefixCls}-disabled`]: maxCount && hasMode && !isSelected ? selected.length >= maxCount : false
3756
- }]),
3757
- onClick: e => {
3758
- if (props.disabled) {
3759
- return;
3760
- }
3761
- handleSelect(e, props.value, {
3762
- children,
3763
- className,
3764
- ...props
3765
- });
3766
- },
3767
- "data-value": props.value
3768
- }), children || props.label || props.value, menuItemSelectedIcon && hasMode && isSelected && /*#__PURE__*/React.createElement("span", {
3769
- className: `${prefixCls}-selected-icon`
3770
- }, menuItemSelectedIcon === true ? /*#__PURE__*/React.createElement(CheckIcon, null) : menuItemSelectedIcon));
3771
- }) : !asTag ? notFoundContent || /*#__PURE__*/React.createElement(EmptyContent, null) : null)));
3772
3704
  const selectedOption = (() => {
3773
3705
  const option = extractedOptions.find(e => e.value === selected || e.label === selected || e.children === selected) || selected;
3774
3706
  return option?.children || option?.label || option?.value || null;
@@ -3905,7 +3837,79 @@ const SelectComponent = ({
3905
3837
  className: `${prefixCls}-arrow`
3906
3838
  }, ArrowContainer, error && feedbackIcons ? /*#__PURE__*/React.createElement(ErrorIcon, null) : null), loading && /*#__PURE__*/React.createElement("span", {
3907
3839
  className: `${prefixCls}-loading`
3908
- }, /*#__PURE__*/React.createElement(LoadingIcon, null)))), getPopupContainer?.(triggerNode) ? /*#__PURE__*/createPortal(dropdownContent, getPopupContainer(triggerNode)) : dropdownContent);
3840
+ }, /*#__PURE__*/React.createElement(LoadingIcon, null)))), /*#__PURE__*/React.createElement(ConditionalWrapper, {
3841
+ condition: getPopupContainer !== undefined,
3842
+ wrapper: element => getPopupContainer ? /*#__PURE__*/createPortal(element, getPopupContainer(triggerNode)) : /*#__PURE__*/React.createElement(React.Fragment, null, element)
3843
+ }, !loading && open && isOpen && /*#__PURE__*/React.createElement("div", {
3844
+ className: clsx([`${prefixCls}-dropdown`, {
3845
+ [placement]: placement,
3846
+ [dropdownClassName]: dropdownClassName
3847
+ }]),
3848
+ style: {
3849
+ ...dropdownPosition,
3850
+ maxHeight: dropdownRender ? 'unset' : listHeight,
3851
+ opacity: Object.keys(dropdownPosition).length ? 1 : 0
3852
+ }
3853
+ }, filterable && /*#__PURE__*/React.createElement("input", {
3854
+ type: "text",
3855
+ inputMode: "text",
3856
+ className: `${prefixCls}-search`,
3857
+ value: searchQuery,
3858
+ onChange: handleSearch,
3859
+ placeholder: "Search..."
3860
+ }), !loading &&
3861
+ /*#__PURE__*/
3862
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3863
+ // @ts-expect-error
3864
+ React.createElement(ConditionalWrapper, {
3865
+ wrapper: element => {
3866
+ return dropdownRender?.(element || /*#__PURE__*/React.createElement(React.Fragment, null, " ")) || /*#__PURE__*/React.createElement(React.Fragment, null, " ");
3867
+ },
3868
+ condition: !!dropdownRender
3869
+ }, /*#__PURE__*/React.createElement("div", {
3870
+ className: `${prefixCls}-options`,
3871
+ style: {
3872
+ maxHeight: listHeight,
3873
+ overflowY: 'auto',
3874
+ // display: !filteredOptions.length && asTag ? 'none' : 'block',
3875
+ maxWidth: selectRef.current ? `${selectRef.current.getBoundingClientRect().width}px` : 'inherit'
3876
+ }
3877
+ }, asTag && !!searchQuery && /*#__PURE__*/React.createElement(Option, {
3878
+ value: searchQuery,
3879
+ className: `${prefixCls}-focused`,
3880
+ onClick: e => {
3881
+ handleSelect(e, searchQuery);
3882
+ },
3883
+ "data-value": searchQuery
3884
+ }, searchQuery), filteredOptions.length ? filteredOptions.map(({
3885
+ children,
3886
+ className = '',
3887
+ ...props
3888
+ }, index) => {
3889
+ const isSelected = hasMode ? selected.includes(props.value) : props.value === selected;
3890
+ return /*#__PURE__*/React.createElement(Option, _extends({
3891
+ key: `${props.value}_${index}`
3892
+ }, props, {
3893
+ selected: isSelected,
3894
+ className: clsx([className, {
3895
+ [`${prefixCls}-focused`]: hasMode ? isSelected : props.value === selected,
3896
+ [`${prefixCls}-disabled`]: maxCount && hasMode && !isSelected ? selected.length >= maxCount : false
3897
+ }]),
3898
+ onClick: e => {
3899
+ if (props.disabled) {
3900
+ return;
3901
+ }
3902
+ handleSelect(e, props.value, {
3903
+ children,
3904
+ className,
3905
+ ...props
3906
+ });
3907
+ },
3908
+ "data-value": props.value
3909
+ }), children || props.label || props.value, menuItemSelectedIcon && hasMode && isSelected && /*#__PURE__*/React.createElement("span", {
3910
+ className: `${prefixCls}-selected-icon`
3911
+ }, menuItemSelectedIcon === true ? /*#__PURE__*/React.createElement(CheckIcon, null) : menuItemSelectedIcon));
3912
+ }) : !asTag ? notFoundContent || /*#__PURE__*/React.createElement(EmptyContent, null) : null)))));
3909
3913
  };
3910
3914
  SelectComponent.displayName = 'Select';
3911
3915
  const Select = Object.assign(SelectComponent, {