@featherds/autocomplete
Advanced tools
Comparing version 0.12.26 to 0.12.27
@@ -629,4 +629,3 @@ import { InputSubTextProps, InputWrapperProps, useInputSubText, useInputWrapper, useValidation, useInputInheritAttrs, InputWrapper, InputSubText } from "@featherds/input-helper"; | ||
const index = modelValue2.value.findIndex((el) => { | ||
if (item[component.textProp.value] === el[component.textProp.value]) | ||
return true; | ||
return item[component.textProp.value] === el[component.textProp.value]; | ||
}); | ||
@@ -1339,3 +1338,3 @@ if (index > -1) { | ||
}); | ||
const FeatherAutocomplete_vue_vue_type_style_index_0_scoped_fa43a099_lang = ""; | ||
const FeatherAutocomplete_vue_vue_type_style_index_0_scoped_69916fd8_lang = ""; | ||
const _hoisted_1 = { | ||
@@ -1508,3 +1507,3 @@ class: "alert", | ||
} | ||
const FeatherAutocomplete = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-fa43a099"]]); | ||
const FeatherAutocomplete = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-69916fd8"]]); | ||
export { | ||
@@ -1511,0 +1510,0 @@ AutocompleteTypes, |
{ | ||
"name": "@featherds/autocomplete", | ||
"version": "0.12.26", | ||
"version": "0.12.27", | ||
"type": "module", | ||
@@ -15,10 +15,10 @@ "publishConfig": { | ||
"dependencies": { | ||
"@featherds/chips": "^0.12.26", | ||
"@featherds/composables": "^0.12.26", | ||
"@featherds/icon": "^0.12.26", | ||
"@featherds/input-helper": "^0.12.26", | ||
"@featherds/list": "^0.12.26", | ||
"@featherds/menu": "^0.12.26", | ||
"@featherds/styles": "^0.12.26", | ||
"@featherds/utils": "^0.12.26", | ||
"@featherds/chips": "^0.12.27", | ||
"@featherds/composables": "^0.12.27", | ||
"@featherds/icon": "^0.12.27", | ||
"@featherds/input-helper": "^0.12.27", | ||
"@featherds/list": "^0.12.27", | ||
"@featherds/menu": "^0.12.27", | ||
"@featherds/styles": "^0.12.27", | ||
"@featherds/utils": "^0.12.27", | ||
"vue": "^3.1.0-0" | ||
@@ -31,3 +31,3 @@ }, | ||
"types": "./src/index.d.ts", | ||
"gitHead": "a8f0b4f0ea208bc9f4ff5b346c99afb71907902b" | ||
"gitHead": "313e9304b3f3e6d4acae47145892699ed28df811" | ||
} |
import FeatherAutocomplete from "./FeatherAutocomplete.vue"; | ||
import { IAutocompleteItemType, AutocompleteTypes } from "./types"; | ||
import { shallowMount, mount } from "@vue/test-utils"; | ||
import { mount } from "@vue/test-utils"; | ||
import * as id from "@featherds/utils/id"; | ||
@@ -24,3 +24,3 @@ import axe from "@featherds/utils/test/axe"; | ||
const getResultsType = (_type: AutocompleteTypes) => () => { | ||
const getResultsType = () => () => { | ||
return [ | ||
@@ -53,3 +53,3 @@ { | ||
const items = args as Array<IAutocompleteItemType[]>; | ||
return items[0][0]; | ||
return items[0]![0]; | ||
} | ||
@@ -59,8 +59,2 @@ const items = args as IAutocompleteItemType[]; | ||
}; | ||
const getWrapperType = (type: AutocompleteTypes) => | ||
function (options: Record<string, unknown> = {}) { | ||
const props = options.props as Record<string, unknown>; | ||
options.props = getProps(type)(props); | ||
return shallowMount(FeatherAutocomplete, options); | ||
}; | ||
@@ -76,5 +70,4 @@ const getFullWrapperType = (type: AutocompleteTypes) => | ||
const getFullWrapper = getFullWrapperType(type); | ||
const getWrapper = getWrapperType(type); | ||
const getValue = getValueType(type); | ||
const getResults = getResultsType(type); | ||
const getResults = getResultsType(); | ||
const handleUpdateValue = handleUpdateValueType(type); | ||
@@ -86,3 +79,3 @@ describe(type, () => { | ||
await wrapper.findComponent({ ref: "menu" }).vm.$emit("trigger-click"); | ||
expect(getCalls<string>(wrapper, "search")[0][0]).toBe(""); | ||
expect(getCalls<string>(wrapper, "search")[0]![0]).toBe(""); //TS2345 | ||
}); | ||
@@ -102,3 +95,3 @@ it("should not perform search with empty string when focused and min char is 0", async () => { | ||
expect(getCalls<string>(wrapper, "search")[0][0]).toBe(""); | ||
expect(getCalls<string>(wrapper, "search")[0]![0]).toBe(""); // TS2345 | ||
}); | ||
@@ -135,3 +128,3 @@ it("should not search when clicked an min char is >0", async () => { | ||
vi.runAllTimers(); | ||
expect(getCalls<string>(wrapper, "search")[0][0]).toBe(result); | ||
expect(getCalls<string>(wrapper, "search")[0]![0]).toBe(result); // TS2345 | ||
}); | ||
@@ -156,3 +149,3 @@ it("should throttle search queries", async () => { | ||
vi.advanceTimersByTime(200); | ||
expect(getCalls<string>(wrapper, "search")[0][0]).toBe(result); | ||
expect(getCalls<string>(wrapper, "search")[0]![0]).toBe(result); // TS2345 | ||
}); | ||
@@ -357,5 +350,5 @@ it("should show loading spinner when search is performed", async () => { | ||
const emitted = handleUpdateValue( | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0] | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0]! // TS2345 | ||
); | ||
expect(emitted._text).toBe(results[0]._text); | ||
expect(emitted!._text).toBe(results[0]!._text); // TS2345 | ||
}); | ||
@@ -375,5 +368,5 @@ it("should select an element when clicked", async () => { | ||
let emitted = handleUpdateValue( | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0] | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0]! // TS2345 | ||
); | ||
expect(emitted._text).toBe(results[0]._text); | ||
expect(emitted!._text).toBe(results[0]!._text); // TS2345 | ||
await wrapper.find(".feather-autocomplete-input").trigger("blur"); | ||
@@ -384,4 +377,4 @@ const events = getCalls<[IAutocompleteItemType[]]>( | ||
); | ||
emitted = handleUpdateValue(events[events.length - 1]); | ||
expect(emitted._text).toBe(results[0]._text); | ||
emitted = handleUpdateValue(events[events.length - 1]!); // TS2345 | ||
expect(emitted!._text).toBe(results[0]!._text); | ||
}); | ||
@@ -399,3 +392,3 @@ }); | ||
const getFullWrapper = getFullWrapperType(AutocompleteTypes.multi); | ||
const getResults = getResultsType(AutocompleteTypes.multi); | ||
const getResults = getResultsType(); | ||
const getValue = getValueType(AutocompleteTypes.multi); | ||
@@ -666,6 +659,2 @@ it("should activate first item in menu on initial load", async () => { | ||
const dsds = getCalls<[IAutocompleteItemType[]]>( | ||
wrapper, | ||
"update:modelValue" | ||
)[0][0]; | ||
expect( | ||
@@ -675,4 +664,4 @@ getCalls<[IAutocompleteItemType[]]>( | ||
"update:modelValue" | ||
)[0][0][0]._text | ||
).toBe(modelValue[0]._text); | ||
)[0]![0][0]!._text | ||
).toBe(modelValue[0]!._text); | ||
expect(wrapper.vm.activeChipIndex).toBe(-1); | ||
@@ -704,4 +693,4 @@ }); | ||
"update:modelValue" | ||
)[0][0][0]._text | ||
).toBe(modelValue[0]._text); | ||
)[0]![0][0]!._text | ||
).toBe(modelValue[0]!._text); | ||
expect(wrapper.vm.activeChipIndex).toBe(-1); | ||
@@ -734,4 +723,4 @@ }); | ||
"update:modelValue" | ||
)[0][0][0]._text | ||
).toBe(modelValue[0]._text); | ||
)[0]![0][0]!._text | ||
).toBe(modelValue[0]!._text); | ||
expect(wrapper.vm.activeChipIndex).toBe(-1); | ||
@@ -758,4 +747,4 @@ }); | ||
"update:modelValue" | ||
)[0][0][0]._text | ||
).toBe(modelValue[1]._text); | ||
)[0]![0][0]!._text | ||
).toBe(modelValue[1]!._text); | ||
}); | ||
@@ -860,3 +849,3 @@ it("should select rightmost token if left is pressed whilst navigating the menu and there is no search text", async () => { | ||
expect(wrapper.vm.showSelectionLimit).toBe(true); | ||
wrapper.vm.removeFromValue(modelValue[0]); | ||
wrapper.vm.removeFromValue(modelValue[0]!); | ||
await nextTick(); | ||
@@ -871,3 +860,3 @@ expect(wrapper.element).toMatchSnapshot(); | ||
const getFullWrapper = getFullWrapperType(AutocompleteTypes.single); | ||
const getResults = getResultsType(AutocompleteTypes.single); | ||
const getResults = getResultsType(); | ||
const getValue = getValueType(AutocompleteTypes.single); | ||
@@ -913,3 +902,3 @@ it("should display value text in the input when a value is selected", async () => { | ||
expect( | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0][0] | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0]![0] | ||
).toStrictEqual(results[index]); | ||
@@ -935,3 +924,3 @@ }); | ||
.findComponent({ ref: "results" }) | ||
.findAll(".result-item")[1] | ||
.findAll(".result-item")[1]! // TS2532 | ||
.trigger("click"); | ||
@@ -1012,3 +1001,3 @@ | ||
expect( | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0][0] | ||
getCalls<[IAutocompleteItemType[]]>(wrapper, "update:modelValue")[0]![0] | ||
).toBe(undefined); | ||
@@ -1041,3 +1030,3 @@ }); | ||
}); | ||
expect(getCalls<[string]>(wrapper, "new")[0][0]).toBe(query); | ||
expect(getCalls<[string]>(wrapper, "new")[0]![0]).toBe(query); // TS2532 | ||
}); | ||
@@ -1093,5 +1082,5 @@ it("should show add new element when in add-new mode", async () => { | ||
await nextTick(); | ||
expect(getCalls<[string]>(wrapper, "new")[0][0]).toBe(query); | ||
expect(getCalls<[string]>(wrapper, "new")[0]![0]).toBe(query); // TS2532 | ||
}); | ||
}); | ||
}); |
@@ -94,6 +94,6 @@ import AutocompleteResults from "./AutocompleteResults.vue"; | ||
await wrapper.findComponent(FeatherListItem).trigger("click"); | ||
expect(getCalls<[{ _text: string }]>(wrapper, "select")[0][0]._text).toBe( | ||
items[0]._text | ||
expect(getCalls<[{ _text: string }]>(wrapper, "select")[0]![0]._text).toBe( | ||
items[0]!._text | ||
); | ||
}); | ||
}); |
@@ -60,4 +60,5 @@ import { Ref } from "vue"; | ||
const index = modelValue.value.findIndex((el) => { | ||
if (item[component.textProp.value] === el[component.textProp.value]) | ||
return true; | ||
return ( | ||
item[component.textProp.value] === el[component.textProp.value] | ||
); | ||
}); | ||
@@ -64,0 +65,0 @@ if (index > -1) { |
@@ -139,6 +139,9 @@ import { Ref, PropType } from "vue"; | ||
"update:modelValue": ( | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_value: IAutocompleteItemType | IAutocompleteItemType[] | undefined | ||
) => true, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
new: (_value: string) => true, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
search: (_value: string) => true, | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1
412040
36
4296
Updated@featherds/chips@^0.12.27
Updated@featherds/icon@^0.12.27
Updated@featherds/list@^0.12.27
Updated@featherds/menu@^0.12.27
Updated@featherds/styles@^0.12.27
Updated@featherds/utils@^0.12.27