x-ui-design 0.3.39 → 0.3.41

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
@@ -1,5 +1,5 @@
1
1
  import require$$1 from 'react/jsx-runtime';
2
- import React$1, { useRef, useState, useContext, useMemo, useEffect, Children, isValidElement, Fragment, createContext, forwardRef, useImperativeHandle, cloneElement, useCallback } from 'react';
2
+ import React$1, { useRef, useState, useContext, useMemo, useEffect, Children, isValidElement, Fragment, createContext, forwardRef, useImperativeHandle, useCallback } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import ReactDOMServer from 'react-dom/server';
5
5
 
@@ -2744,19 +2744,20 @@ const RadioGroup = ({
2744
2744
  }
2745
2745
  return Children.map(children, child => {
2746
2746
  if (/*#__PURE__*/isValidElement(child) && (child.type === Radio$1 || child.type === RadioButton)) {
2747
- return /*#__PURE__*/cloneElement(child, {
2748
- ...props,
2749
- ...(child.type === RadioButton ? {
2750
- size,
2751
- buttonStyle
2752
- } : {}),
2753
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2754
- // @ts-expect-error
2755
- defaultValue,
2747
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2748
+ // @ts-expect-error
2749
+ const {
2750
+ ...childProps
2751
+ } = child.props;
2752
+ return /*#__PURE__*/React$1.createElement(child.type, _extends({}, props, childProps, child.type === RadioButton ? {
2753
+ size,
2754
+ buttonStyle
2755
+ } : {}, {
2756
+ defaultValue: defaultValue,
2756
2757
  disabled: disabled ?? child.props.disabled,
2757
2758
  checked: selectedValue === child.props.value,
2758
2759
  name: name ?? prefixClsRadio
2759
- });
2760
+ }));
2760
2761
  }
2761
2762
  return child;
2762
2763
  });
@@ -2827,7 +2828,8 @@ const RadioComponent = /*#__PURE__*/forwardRef(({
2827
2828
  disabled: disabled,
2828
2829
  onChange: handleChange,
2829
2830
  onBlur: e => onBlur?.(e),
2830
- onFocus: e => onFocus?.(e)
2831
+ onFocus: e => onFocus?.(e),
2832
+ defaultChecked: defaultChecked ?? checked
2831
2833
  }), /*#__PURE__*/React$1.createElement("span", {
2832
2834
  className: clsx([`${prefixCls} ${prefixCls}-${disabled ? 'disabled' : 'enabled'}`])
2833
2835
  }), /*#__PURE__*/React$1.createElement("span", {
@@ -3258,6 +3260,16 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3258
3260
  setSearchInputWidth(searchContent.clientWidth - PADDING_TAG_INPUT);
3259
3261
  }
3260
3262
  const timeout = setTimeout(() => {
3263
+ if (!hasMode) {
3264
+ const selectedOption = selectRef.current?.getElementsByClassName('selected')[0];
3265
+ if (selectedOption) {
3266
+ const selectedOptionTop = selectRef.current?.getElementsByClassName('selected')[0].getBoundingClientRect()?.top || 0;
3267
+ selectRef.current?.getElementsByClassName(`${prefixCls}-options`)[0]?.scrollTo({
3268
+ top: selectedOptionTop - selectedOption.clientHeight - PADDING_PLACEMENT - PADDING_TAG_INPUT,
3269
+ behavior: 'smooth'
3270
+ });
3271
+ }
3272
+ }
3261
3273
  const searchInput = document.getElementById(`${prefixCls}-search-tag-input`);
3262
3274
  if (searchInput) {
3263
3275
  searchInput?.focus();
@@ -3386,7 +3398,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3386
3398
  contentEditable: "plaintext-only",
3387
3399
  id: `${prefixCls}-search-tag-input`,
3388
3400
  className: `${prefixCls}-tag-input`
3389
- }), !searchQuery.length ? selected === '' ? placeholder : extractedOptions.find(e => e.value === selected)?.children || selected : null) : !hasMode ? /*#__PURE__*/React$1.createElement("div", {
3401
+ }), !hasMode && !searchQuery.length ? selected === '' ? placeholder : extractedOptions.find(e => e.value === selected)?.children || selected : null) : !hasMode ? /*#__PURE__*/React$1.createElement("div", {
3390
3402
  className: `${prefixCls}-input globalEllipsis`,
3391
3403
  style: {
3392
3404
  opacity: isOpen || selected === '' ? '0.6' : '1'