rockin 0.0.19 → 0.0.20
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.
|
@@ -850,6 +850,7 @@ function GridAsyncComboboxCell({
|
|
|
850
850
|
const selectedValue = value ?? String(cell.value ?? "");
|
|
851
851
|
const [query, setQuery] = React3.useState("");
|
|
852
852
|
const [options, setOptions] = React3.useState([]);
|
|
853
|
+
const [selectedOption, setSelectedOption] = React3.useState(null);
|
|
853
854
|
const [isLoading, setIsLoading] = React3.useState(false);
|
|
854
855
|
const requestId = React3.useRef(0);
|
|
855
856
|
const loadOptionsRef = React3.useRef(loadOptions);
|
|
@@ -892,19 +893,21 @@ function GridAsyncComboboxCell({
|
|
|
892
893
|
}
|
|
893
894
|
};
|
|
894
895
|
}, [debounceMs, minQueryLength, query, stableLoadOptions]);
|
|
896
|
+
const selectedItem = options.find((option) => option.value === selectedValue) ?? (selectedOption?.value === selectedValue ? selectedOption : null);
|
|
895
897
|
return /* @__PURE__ */ jsxs2(
|
|
896
898
|
Combobox,
|
|
897
899
|
{
|
|
898
900
|
items: options,
|
|
899
|
-
itemToStringLabel: (item) =>
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
901
|
+
itemToStringLabel: (item) => item?.label ?? "",
|
|
902
|
+
itemToStringValue: (item) => item?.value ?? "",
|
|
903
|
+
onValueChange: (nextOption) => {
|
|
904
|
+
if (nextOption === null) return;
|
|
905
|
+
setSelectedOption(nextOption);
|
|
906
|
+
onChange?.(nextOption.value, nextOption);
|
|
907
|
+
cell.grid.updateCell(cell.rowId, cell.columnId, nextOption.value);
|
|
908
|
+
setQuery(nextOption.label);
|
|
906
909
|
},
|
|
907
|
-
value:
|
|
910
|
+
value: selectedItem,
|
|
908
911
|
children: [
|
|
909
912
|
/* @__PURE__ */ jsx7(
|
|
910
913
|
ComboboxInput,
|
|
@@ -919,7 +922,7 @@ function GridAsyncComboboxCell({
|
|
|
919
922
|
/* @__PURE__ */ jsxs2(ComboboxContent, { children: [
|
|
920
923
|
isLoading && /* @__PURE__ */ jsx7(ComboboxEmpty, { children: "Loading..." }),
|
|
921
924
|
!isLoading && query.trim().length >= minQueryLength && options.length === 0 && /* @__PURE__ */ jsx7(ComboboxEmpty, { children: "No results found." }),
|
|
922
|
-
/* @__PURE__ */ jsx7(ComboboxList, { children: options.map((option) => /* @__PURE__ */ jsx7(ComboboxItem, { value: option
|
|
925
|
+
/* @__PURE__ */ jsx7(ComboboxList, { children: options.map((option) => /* @__PURE__ */ jsx7(ComboboxItem, { value: option, children: option.label }, option.value)) })
|
|
923
926
|
] })
|
|
924
927
|
]
|
|
925
928
|
}
|
package/dist/hooks/index.js
CHANGED
package/dist/ui/index.js
CHANGED