@economic/taco 2.63.1 → 2.63.2-combobox-search.0

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/taco.js CHANGED
@@ -18368,7 +18368,7 @@ const filterData = (data, value = "") => {
18368
18368
  if (value === "" || value === null) {
18369
18369
  return data;
18370
18370
  }
18371
- const filteredOptionValues = /* @__PURE__ */ new Set();
18371
+ const filteredOptions = [];
18372
18372
  const shouldFilterOption = (option) => {
18373
18373
  if (option.disabled) {
18374
18374
  return false;
@@ -18378,13 +18378,22 @@ const filterData = (data, value = "") => {
18378
18378
  data.forEach((option) => {
18379
18379
  if (shouldFilterOption(option)) {
18380
18380
  const parents = getOptionParents(data, option.path);
18381
- filteredOptionValues.add(option.value);
18381
+ const index2 = option.text.toString().toLocaleLowerCase().indexOf(value.toString().toLocaleLowerCase());
18382
+ filteredOptions.push({ value: option.value, score: index2 });
18382
18383
  if (parents !== null) {
18383
- parents.forEach((option2) => filteredOptionValues.add(option2 == null ? void 0 : option2.value));
18384
+ parents.forEach((option2) => filteredOptions.push({ value: option2 == null ? void 0 : option2.value }));
18384
18385
  }
18385
18386
  }
18386
18387
  });
18387
- return data.filter(({ value: value2 }) => filteredOptionValues.has(value2));
18388
+ return data.filter(({ value: value2 }) => filteredOptions.find((x2) => x2.value === value2)).toSorted((a2, b2) => {
18389
+ var _a, _b;
18390
+ const scoreA = (_a = filteredOptions.find((x2) => x2.value === a2.value)) == null ? void 0 : _a.score;
18391
+ const scoreB = (_b = filteredOptions.find((x2) => x2.value === b2.value)) == null ? void 0 : _b.score;
18392
+ if (scoreA !== void 0 && scoreB !== void 0) {
18393
+ return scoreA - scoreB;
18394
+ }
18395
+ return 0;
18396
+ });
18388
18397
  };
18389
18398
  const debouncer = debounce$1((f2) => f2(), 200);
18390
18399
  const convertToInputValue = (value) => String(value ?? "");