x-ui-design 0.4.37 → 0.4.38

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.
@@ -0,0 +1,7 @@
1
+ import { FC, PropsWithChildren, ReactElement } from 'react';
2
+ type Props = {
3
+ condition: boolean;
4
+ wrapper: (children: PropsWithChildren['children']) => ReactElement;
5
+ } & PropsWithChildren;
6
+ export declare const ConditionalWrapper: FC<Props>;
7
+ export {};
package/dist/index.esm.js CHANGED
@@ -3139,6 +3139,12 @@ var Tag$1 = /*#__PURE__*/Object.freeze({
3139
3139
  default: Tag
3140
3140
  });
3141
3141
 
3142
+ const ConditionalWrapper = ({
3143
+ condition,
3144
+ wrapper,
3145
+ children
3146
+ }) => condition ? wrapper(children) : children;
3147
+
3142
3148
  var css_248z$5 = "@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.xUi-select{background-color:transparent;border:1px solid var(--xui-border-color);border-radius:var(--xui-border-radius-sm);box-sizing:border-box;color:var(--xui-text-color);display:inline-flex;flex-direction:row-reverse;min-height:24px;padding:2px 8px;position:relative;width:100%}.xUi-select-disabled{background:rgba(0,0,0,.04)}.xUi-select-arrow{align-items:center;color:var(--xui-text-color-light);display:flex;gap:6px;margin:0 4px}.xUi-select-arrow svg{align-items:center;display:flex;justify-content:center}.xUi-select-loading{animation:spin 1s linear infinite;color:var(--xui-text-color-light);display:inline-block;margin:0 8px}.xUi-select .xUi-select-trigger{align-items:center;background:transparent;border-radius:var(--xui-border-radius-sm);cursor:pointer;display:flex;justify-content:space-between;width:100%}.xUi-select .xUi-select-clear-btn{background:none;border:none;color:#999;cursor:pointer;font-size:var(--xui-font-size-lg);line-height:1;margin:0 8px;padding:0}.xUi-select .xUi-select-clear-btn:hover{color:var(--xui-primary-color)}.xUi-select-dropdown{background-color:var(--xui-select-background-color);border-radius:var(--xui-border-radius-sm);box-shadow:0 4px 12px rgba(0,0,0,.15);left:0;margin-top:5px;max-height:350px;overflow-y:auto;position:absolute;right:unset;top:100%;width:inherit;z-index:10}.xUi-select-dropdown.bottomRight,.xUi-select-dropdown.topRight{left:unset;right:0}.xUi-select .xUi-select-loading-spinner{color:#999;padding:10px;text-align:center}.xUi-select:focus-within{border-color:var(--xui-primary-color-light);box-shadow:none}.xUi-select:hover:not(.xUi-select-disabled){border-color:var(--xui-primary-color)}.xUi-select-disabled,.xUi-select-disabled .xUi-select-input,.xUi-select-disabled .xUi-select-trigger{cursor:not-allowed!important;opacity:.6!important}.xUi-select-selected-icon{color:var(--xui-primary-color-light)}.xUi-select-error{border-color:var(--xui-error-color)}.xUi-select-arrow .error-svg-icon,.xUi-select-error .error-svg-icon{color:var(--xui-error-color)}.xUi-select .xUi-select-input{align-items:center;background:transparent;border:none;color:var(--xui-text-color);cursor:pointer;display:inline-flex;font-size:var(--xui-font-size-md);height:-webkit-fill-available;outline:none;padding:0;user-select:none;width:100%}.xUi-select .xUi-select-input:focus{border:none;box-shadow:none;outline:none}.xUi-select.middle{border-radius:var(--xui-border-radius-md);min-height:30px}.xUi-select.middle,.xUi-select.middle input{font-size:var(--xui-font-size-md)}.xUi-select.middle .xUi-select-trigger{border-radius:var(--xui-border-radius-md)}.xUi-select.large{font-size:var(--xui-font-size-lg);min-height:44px}.xUi-select.large,.xUi-select.large .xUi-select-trigger{border-radius:var(--xui-border-radius-lg)}.xUi-select input{font-size:var(--xui-font-size-lg)}";
3143
3149
  styleInject(css_248z$5);
3144
3150
 
@@ -3534,7 +3540,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3534
3540
  className: `${prefixCls}-selected-icon`
3535
3541
  }, menuItemSelectedIcon === true ? /*#__PURE__*/React.createElement(CheckIcon, null) : menuItemSelectedIcon));
3536
3542
  });
3537
- return dropdownRender ? dropdownRender(options) : options;
3543
+ return options;
3538
3544
  })();
3539
3545
  const dropdownContent = !loading && open && isOpen && /*#__PURE__*/React.createElement("div", {
3540
3546
  className: clsx([`${prefixCls}-dropdown`, {
@@ -3543,7 +3549,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3543
3549
  }]),
3544
3550
  style: {
3545
3551
  ...dropdownPosition,
3546
- maxHeight: listHeight,
3552
+ maxHeight: dropdownRender ? 'unset' : listHeight,
3547
3553
  opacity: Object.keys(dropdownPosition).length ? 1 : 0
3548
3554
  }
3549
3555
  }, filterable && /*#__PURE__*/React.createElement("input", {
@@ -3552,7 +3558,16 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3552
3558
  value: searchQuery,
3553
3559
  onChange: handleSearch,
3554
3560
  placeholder: "Search..."
3555
- }), !loading && /*#__PURE__*/React.createElement("div", {
3561
+ }), !loading &&
3562
+ /*#__PURE__*/
3563
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3564
+ // @ts-expect-error
3565
+ React.createElement(ConditionalWrapper, {
3566
+ wrapper: element => {
3567
+ return dropdownRender?.(element || /*#__PURE__*/React.createElement(React.Fragment, null, " ")) || /*#__PURE__*/React.createElement(React.Fragment, null, " ");
3568
+ },
3569
+ condition: !!dropdownRender
3570
+ }, /*#__PURE__*/React.createElement("div", {
3556
3571
  className: `${prefixCls}-options`,
3557
3572
  style: {
3558
3573
  maxHeight: listHeight,
@@ -3566,7 +3581,7 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3566
3581
  handleSelect(e, searchQuery);
3567
3582
  },
3568
3583
  "data-value": searchQuery
3569
- }, searchQuery), filteredOptions.length ? dataRender : !asTag ? notFoundContent || /*#__PURE__*/React.createElement(EmptyContent, null) : null));
3584
+ }, searchQuery), filteredOptions.length ? dataRender : !asTag ? notFoundContent || /*#__PURE__*/React.createElement(EmptyContent, null) : null)));
3570
3585
  const selectedOption = (() => {
3571
3586
  const option = extractedOptions.find(e => e.value === selected || e.label === selected || e.children === selected) || selected;
3572
3587
  return option?.children || option?.label || option?.value || null;