@rufous/ui 0.3.25 → 0.3.26

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/main.cjs CHANGED
@@ -9911,11 +9911,18 @@ function SmartSelect({
9911
9911
  }, [options, getOptionChildren]);
9912
9912
  const flatOptionsList = (0, import_react51.useMemo)(() => flatItems.map((f) => f.option), [flatItems]);
9913
9913
  const displayOptions = (0, import_react51.useMemo)(() => {
9914
- if (!searchResults.length) return flatOptionsList;
9915
- const localKeys = new Set(flatOptionsList.map((o) => getValue(o)));
9916
- const serverOnly = searchResults.filter((o) => !localKeys.has(getValue(o)));
9917
- return [...flatOptionsList, ...serverOnly];
9918
- }, [flatOptionsList, searchResults, getValue]);
9914
+ let base = flatOptionsList;
9915
+ if (searchResults.length) {
9916
+ const localKeys = new Set(flatOptionsList.map((o) => getValue(o)));
9917
+ const serverOnly = searchResults.filter((o) => !localKeys.has(getValue(o)));
9918
+ base = [...flatOptionsList, ...serverOnly];
9919
+ }
9920
+ if (!multiple && value != null) {
9921
+ const key = getValue(value);
9922
+ if (!base.some((o) => getValue(o) === key)) base = [value, ...base];
9923
+ }
9924
+ return base;
9925
+ }, [flatOptionsList, searchResults, getValue, value, multiple]);
9919
9926
  const depthMap = (0, import_react51.useMemo)(() => {
9920
9927
  const map = /* @__PURE__ */ new Map();
9921
9928
  flatItems.forEach(({ option, depth }) => map.set(getValue(option), depth));
@@ -9931,10 +9938,11 @@ function SmartSelect({
9931
9938
  }
9932
9939
  return value != null ? /* @__PURE__ */ new Set([getValue(value)]) : /* @__PURE__ */ new Set();
9933
9940
  }, [multiple, value, getValue]);
9934
- const handleInputChange = (0, import_react51.useCallback)((_, inputValue2) => {
9941
+ const handleInputChange = (0, import_react51.useCallback)((_, inputValue2, reason) => {
9935
9942
  setInputValue(inputValue2);
9936
9943
  if (!onSearchChange) return;
9937
9944
  if (debounceTimer.current) clearTimeout(debounceTimer.current);
9945
+ if (reason === "reset") return;
9938
9946
  if (!inputValue2) {
9939
9947
  onSearchChange("", 0);
9940
9948
  return;
package/dist/main.js CHANGED
@@ -9836,11 +9836,18 @@ function SmartSelect({
9836
9836
  }, [options, getOptionChildren]);
9837
9837
  const flatOptionsList = useMemo3(() => flatItems.map((f) => f.option), [flatItems]);
9838
9838
  const displayOptions = useMemo3(() => {
9839
- if (!searchResults.length) return flatOptionsList;
9840
- const localKeys = new Set(flatOptionsList.map((o) => getValue(o)));
9841
- const serverOnly = searchResults.filter((o) => !localKeys.has(getValue(o)));
9842
- return [...flatOptionsList, ...serverOnly];
9843
- }, [flatOptionsList, searchResults, getValue]);
9839
+ let base = flatOptionsList;
9840
+ if (searchResults.length) {
9841
+ const localKeys = new Set(flatOptionsList.map((o) => getValue(o)));
9842
+ const serverOnly = searchResults.filter((o) => !localKeys.has(getValue(o)));
9843
+ base = [...flatOptionsList, ...serverOnly];
9844
+ }
9845
+ if (!multiple && value != null) {
9846
+ const key = getValue(value);
9847
+ if (!base.some((o) => getValue(o) === key)) base = [value, ...base];
9848
+ }
9849
+ return base;
9850
+ }, [flatOptionsList, searchResults, getValue, value, multiple]);
9844
9851
  const depthMap = useMemo3(() => {
9845
9852
  const map = /* @__PURE__ */ new Map();
9846
9853
  flatItems.forEach(({ option, depth }) => map.set(getValue(option), depth));
@@ -9856,10 +9863,11 @@ function SmartSelect({
9856
9863
  }
9857
9864
  return value != null ? /* @__PURE__ */ new Set([getValue(value)]) : /* @__PURE__ */ new Set();
9858
9865
  }, [multiple, value, getValue]);
9859
- const handleInputChange = useCallback11((_, inputValue2) => {
9866
+ const handleInputChange = useCallback11((_, inputValue2, reason) => {
9860
9867
  setInputValue(inputValue2);
9861
9868
  if (!onSearchChange) return;
9862
9869
  if (debounceTimer.current) clearTimeout(debounceTimer.current);
9870
+ if (reason === "reset") return;
9863
9871
  if (!inputValue2) {
9864
9872
  onSearchChange("", 0);
9865
9873
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rufous/ui",
3
3
  "private": false,
4
- "version": "0.3.25",
4
+ "version": "0.3.26",
5
5
  "type": "module",
6
6
  "description": "Experimental: A lightweight React UI component library (Beta)",
7
7
  "style": "./dist/main.css",