75 lines
2.8 KiB
Diff
75 lines
2.8 KiB
Diff
diff --git a/dist/index.js b/dist/index.js
|
|
index 2dd4992d4f033c22be13a8846637d48ef235c57f..cf5264a8ea0b6803b6fb9a950d35e7bd1ed0f959 100644
|
|
--- a/dist/index.js
|
|
+++ b/dist/index.js
|
|
@@ -6600,6 +6600,23 @@ function SearchField({
|
|
] })
|
|
] });
|
|
}
|
|
+function getSelectItemLabel(children, selectedValue) {
|
|
+ let label;
|
|
+ react.Children.forEach(children, (child) => {
|
|
+ if (label !== void 0 || !react.isValidElement(child)) {
|
|
+ return;
|
|
+ }
|
|
+ if (child.type === ListItem) {
|
|
+ const itemValue = child.props.value ?? child.props.id ?? (typeof child.props.children === "string" ? child.props.children : "");
|
|
+ if (itemValue === selectedValue) {
|
|
+ label = child.props.children;
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ label = getSelectItemLabel(child.props.children, selectedValue);
|
|
+ });
|
|
+ return label;
|
|
+}
|
|
function Select({
|
|
value,
|
|
defaultValue,
|
|
@@ -6666,7 +6683,7 @@ function Select({
|
|
),
|
|
children: [
|
|
/* @__PURE__ */ jsxRuntime.jsx(select.Select.Value, { placeholder, children: (selected) => {
|
|
- const defaultChildren = selected ?? placeholder;
|
|
+ const defaultChildren = selected == null ? placeholder : getSelectItemLabel(collection, selected) ?? selected;
|
|
return typeof renderValue === "function" ? renderValue({
|
|
defaultChildren,
|
|
isPlaceholder: selected == null
|
|
diff --git a/dist/index.mjs b/dist/index.mjs
|
|
index 448a673d0ef00587ba6a233d5e5f8e99efc8215e..f0c0f4e7a5a9f0e2066225e1598f944fbc033c6e 100644
|
|
--- a/dist/index.mjs
|
|
+++ b/dist/index.mjs
|
|
@@ -6575,6 +6575,23 @@ function SearchField({
|
|
] })
|
|
] });
|
|
}
|
|
+function getSelectItemLabel(children, selectedValue) {
|
|
+ let label;
|
|
+ Children.forEach(children, (child) => {
|
|
+ if (label !== void 0 || !isValidElement(child)) {
|
|
+ return;
|
|
+ }
|
|
+ if (child.type === ListItem) {
|
|
+ const itemValue = child.props.value ?? child.props.id ?? (typeof child.props.children === "string" ? child.props.children : "");
|
|
+ if (itemValue === selectedValue) {
|
|
+ label = child.props.children;
|
|
+ }
|
|
+ return;
|
|
+ }
|
|
+ label = getSelectItemLabel(child.props.children, selectedValue);
|
|
+ });
|
|
+ return label;
|
|
+}
|
|
function Select({
|
|
value,
|
|
defaultValue,
|
|
@@ -6641,7 +6658,7 @@ function Select({
|
|
),
|
|
children: [
|
|
/* @__PURE__ */ jsx(Select$1.Value, { placeholder, children: (selected) => {
|
|
- const defaultChildren = selected ?? placeholder;
|
|
+ const defaultChildren = selected == null ? placeholder : getSelectItemLabel(collection, selected) ?? selected;
|
|
return typeof renderValue === "function" ? renderValue({
|
|
defaultChildren,
|
|
isPlaceholder: selected == null
|