x-ui-design 0.4.27 → 0.4.29

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, { useRef, useState, isValidElement, Children, Fragment, Suspense, useContext, useMemo, useEffect, createContext, forwardRef, useImperativeHandle, useCallback } from 'react';
2
+ import React, { useRef, useState, Children, isValidElement, Fragment, Suspense, useContext, useMemo, useEffect, createContext, forwardRef, useImperativeHandle, useCallback } from 'react';
3
3
  import { createPortal } from 'react-dom';
4
4
  import ReactDOMServer from 'react-dom/server';
5
5
 
@@ -907,9 +907,6 @@ function clsx(...args) {
907
907
 
908
908
  function flattenChildren(children) {
909
909
  const result = [];
910
- if (Array.isArray(children) && ! /*#__PURE__*/isValidElement(children[0])) {
911
- return children;
912
- }
913
910
  Children.forEach(children, child => {
914
911
  if (! /*#__PURE__*/isValidElement(child)) return;
915
912
  if (child.type === Fragment || child.type === Suspense) {
@@ -3427,23 +3424,28 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3427
3424
  isOpen: isOpen
3428
3425
  }));
3429
3426
  }, [showArrow, showSearch, isOpen, suffixIcon, searchIcon]);
3430
- const extractedOptions = children ? Array.isArray(children) && ! /*#__PURE__*/isValidElement(children[0]) ? children : extractOptions(children) : Array.isArray(options) ? options : [];
3427
+ const extractedOptions = children ? extractOptions(children) : Array.isArray(options) ? options : [];
3431
3428
  const triggerNode = useMemo(() => {
3432
3429
  return selectRef.current?.querySelector(`.${prefixCls}-trigger`);
3433
3430
  }, [prefixCls]);
3434
3431
  function extractOptions(children, options) {
3435
3432
  const result = [];
3436
3433
  const flatten = nodes => {
3437
- Children.forEach(nodes, child => {
3438
- if (!child) return;
3439
- if (/*#__PURE__*/isValidElement(child)) {
3440
- if (child.type === Fragment || child.type === Suspense) {
3441
- flatten(child.props.children);
3442
- } else {
3443
- result.push(child.props);
3434
+ try {
3435
+ Children.forEach(nodes, child => {
3436
+ if (!child) return;
3437
+ if (/*#__PURE__*/isValidElement(child)) {
3438
+ if (child.type === Fragment || child.type === Suspense) {
3439
+ flatten(child.props.children);
3440
+ } else {
3441
+ result.push(child.props);
3442
+ }
3444
3443
  }
3445
- }
3446
- });
3444
+ });
3445
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
3446
+ } catch (e) {
3447
+ Object.assign(result, nodes);
3448
+ }
3447
3449
  };
3448
3450
  if (children) {
3449
3451
  flatten(children);
@@ -3555,6 +3557,10 @@ const SelectComponent = /*#__PURE__*/forwardRef(({
3555
3557
  }, searchQuery), filteredOptions.length ? dataRender : !asTag ? notFoundContent || /*#__PURE__*/React.createElement(EmptyContent, null) : null));
3556
3558
  const selectedOption = (() => {
3557
3559
  const option = extractedOptions.find(e => e.value === selected || e.label === selected || e.children === selected);
3560
+ console.log({
3561
+ option,
3562
+ selected
3563
+ });
3558
3564
  return option?.children || option?.label || option?.value || null;
3559
3565
  })() || selected || null;
3560
3566
  return /*#__PURE__*/React.createElement("div", {