@ultraviolet/ui 1.45.2 → 1.45.3
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _styled from '@emotion/styled/base';
|
|
2
2
|
import { useTheme, css } from '@emotion/react';
|
|
3
3
|
import { Icon } from '@ultraviolet/icons';
|
|
4
|
-
import { forwardRef, useState, useId, useMemo, useEffect } from 'react';
|
|
4
|
+
import React, { forwardRef, useState, useId, useMemo, Children, useEffect } from 'react';
|
|
5
5
|
import Select, { components } from 'react-select';
|
|
6
6
|
import isJSONString from '../../helpers/isJSON.js';
|
|
7
7
|
import * as animations from '../../utils/animations.js';
|
|
@@ -530,15 +530,15 @@ const FwdSelectInput = ({
|
|
|
530
530
|
const currentValue = value?.value;
|
|
531
531
|
|
|
532
532
|
// Options need to keep the same reference otherwise react-select doesn't focus the selected option
|
|
533
|
-
const selectOptions = useMemo(() => options || (children
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
533
|
+
const selectOptions = useMemo(() => options || Children.toArray(children).reduce((acc, child) => {
|
|
534
|
+
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
535
|
+
return [...acc, {
|
|
536
|
+
...child.props,
|
|
537
|
+
label: child.props.children
|
|
538
|
+
}];
|
|
537
539
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
label
|
|
541
|
-
})), [options, children]);
|
|
540
|
+
return acc;
|
|
541
|
+
}, []), [options, children]);
|
|
542
542
|
useEffect(() => {
|
|
543
543
|
if (animationOnChange) {
|
|
544
544
|
setIsAnimated(true);
|