@apptegy/nuxt-navigation 0.1.44 → 0.1.45
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/module.json
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
export declare function useBranding(clientId?: number): Promise<{
|
|
2
|
-
brand:
|
|
3
|
-
getBrandingStyles:
|
|
4
|
-
'--brand-color'?: undefined;
|
|
5
|
-
'--nav-background-color'?: undefined;
|
|
6
|
-
'--nav-text-color'?: undefined;
|
|
7
|
-
'--nav-border-colors'?: undefined;
|
|
8
|
-
'--nav-icon-background'?: undefined;
|
|
9
|
-
'--nav-icon-color'?: undefined;
|
|
10
|
-
'--nav-active-icon-background'?: undefined;
|
|
11
|
-
'--nav-active-icon-color'?: undefined;
|
|
12
|
-
} | {
|
|
13
|
-
'--brand-color': any;
|
|
14
|
-
'--nav-background-color': string;
|
|
15
|
-
'--nav-text-color': string;
|
|
16
|
-
'--nav-border-colors': string;
|
|
17
|
-
'--nav-icon-background': string;
|
|
18
|
-
'--nav-icon-color': string;
|
|
19
|
-
'--nav-active-icon-background': string;
|
|
20
|
-
'--nav-active-icon-color': string;
|
|
21
|
-
}>;
|
|
2
|
+
brand: any;
|
|
3
|
+
getBrandingStyles: any;
|
|
22
4
|
}>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Ref } from "#imports";
|
|
2
|
-
|
|
2
|
+
type OptionItem = string | Record<string, string | number | boolean>;
|
|
3
|
+
export declare function useDropdown(options: Array<OptionItem>, dropdownOptionsRef: Ref<Array<HTMLElement>>, dropdownTriggerRef: Ref<HTMLElement>, config?: {
|
|
3
4
|
searchable: boolean;
|
|
4
5
|
trackBy?: string;
|
|
5
6
|
}): {
|
|
6
|
-
active:
|
|
7
|
-
searchQuery:
|
|
7
|
+
active: any;
|
|
8
|
+
searchQuery: any;
|
|
8
9
|
toggleDropdown: ($event: KeyboardEvent | MouseEvent) => Promise<void>;
|
|
9
10
|
openDropdown: () => void;
|
|
10
11
|
closeDropdown: () => void;
|
|
@@ -12,5 +13,6 @@ export declare function useDropdown(options: Array<unknown>, dropdownOptionsRef:
|
|
|
12
13
|
keydownActionsOnTrigger: (event: KeyboardEvent) => void;
|
|
13
14
|
handleKeydown: (event: KeyboardEvent, index: number) => number | undefined;
|
|
14
15
|
handleDropdownSearch: (inputValue: KeyboardEvent & InputEvent) => void;
|
|
15
|
-
debouncedFocus:
|
|
16
|
+
debouncedFocus: import("@vueuse/core").PromisifyFn<(idx: number) => void>;
|
|
16
17
|
};
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
2
2
|
import { ref, nextTick } from "#imports";
|
|
3
3
|
export function useDropdown(options, dropdownOptionsRef, dropdownTriggerRef, config = { searchable: false, trackBy: "name" }) {
|
|
4
4
|
const active = ref(false);
|
|
@@ -18,17 +18,20 @@ export function useDropdown(options, dropdownOptionsRef, dropdownTriggerRef, con
|
|
|
18
18
|
active.value = false;
|
|
19
19
|
}
|
|
20
20
|
function onClickOutsideHandler() {
|
|
21
|
-
if (!active.value)
|
|
21
|
+
if (!active.value)
|
|
22
|
+
return;
|
|
22
23
|
closeDropdown();
|
|
23
24
|
}
|
|
24
25
|
function keydownActionsOnTrigger(event) {
|
|
25
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey)
|
|
26
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey)
|
|
27
|
+
return;
|
|
26
28
|
if (event.key !== "Tab") {
|
|
27
29
|
event.preventDefault();
|
|
28
30
|
}
|
|
29
31
|
switch (event.key) {
|
|
30
32
|
case "Tab":
|
|
31
|
-
if (!active.value)
|
|
33
|
+
if (!active.value)
|
|
34
|
+
return;
|
|
32
35
|
closeDropdown();
|
|
33
36
|
break;
|
|
34
37
|
case "ArrowDown":
|
|
@@ -93,7 +96,8 @@ export function useDropdown(options, dropdownOptionsRef, dropdownTriggerRef, con
|
|
|
93
96
|
}
|
|
94
97
|
}
|
|
95
98
|
function handleKeydown(event, index) {
|
|
96
|
-
if (event.ctrlKey || event.metaKey || event.shiftKey)
|
|
99
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey)
|
|
100
|
+
return;
|
|
97
101
|
if (event.altKey && event.key === "ArrowUp") {
|
|
98
102
|
closeDropdown();
|
|
99
103
|
dropdownTriggerRef.value.focus();
|
|
@@ -127,13 +131,15 @@ export function useDropdown(options, dropdownOptionsRef, dropdownTriggerRef, con
|
|
|
127
131
|
});
|
|
128
132
|
break;
|
|
129
133
|
case "ArrowDown":
|
|
130
|
-
if (index === options.length - 1)
|
|
134
|
+
if (index === options.length - 1)
|
|
135
|
+
break;
|
|
131
136
|
nextTick(() => {
|
|
132
137
|
dropdownOptionsRef.value[index + 1].focus();
|
|
133
138
|
});
|
|
134
139
|
return index;
|
|
135
140
|
case "ArrowUp":
|
|
136
|
-
if (index === 0)
|
|
141
|
+
if (index === 0)
|
|
142
|
+
break;
|
|
137
143
|
nextTick(() => {
|
|
138
144
|
dropdownOptionsRef.value[index - 1].focus();
|
|
139
145
|
});
|
|
@@ -166,11 +172,12 @@ export function useDropdown(options, dropdownOptionsRef, dropdownTriggerRef, con
|
|
|
166
172
|
break;
|
|
167
173
|
}
|
|
168
174
|
}
|
|
169
|
-
const debouncedFocus =
|
|
175
|
+
const debouncedFocus = useDebounceFn((idx) => {
|
|
170
176
|
dropdownOptionsRef.value[idx].focus();
|
|
171
177
|
}, 500);
|
|
172
178
|
function handleDropdownSearch(inputValue) {
|
|
173
|
-
if (!config.searchable)
|
|
179
|
+
if (!config.searchable)
|
|
180
|
+
return;
|
|
174
181
|
if (inputValue.key == "Backspace") {
|
|
175
182
|
searchQuery.value = searchQuery.value.slice(0, -1);
|
|
176
183
|
return;
|
|
@@ -179,10 +186,16 @@ export function useDropdown(options, dropdownOptionsRef, dropdownTriggerRef, con
|
|
|
179
186
|
searchQuery.value = `${searchQuery.value}${pressedKey}`;
|
|
180
187
|
const searchIndex = options.findIndex((option) => {
|
|
181
188
|
if (!config.trackBy) {
|
|
182
|
-
return option.includes(searchQuery.value);
|
|
183
|
-
} else {
|
|
184
|
-
|
|
189
|
+
return typeof option === "string" && option.includes(searchQuery.value);
|
|
190
|
+
} else if (typeof option === "object" && option !== null && config.trackBy in option) {
|
|
191
|
+
const value = option[config.trackBy];
|
|
192
|
+
if (typeof value === "string") {
|
|
193
|
+
return value.toLowerCase().includes(searchQuery.value.toLowerCase());
|
|
194
|
+
} else if (value !== null && value !== void 0) {
|
|
195
|
+
return String(value).includes(searchQuery.value);
|
|
196
|
+
}
|
|
185
197
|
}
|
|
198
|
+
return false;
|
|
186
199
|
});
|
|
187
200
|
if (searchIndex !== -1) {
|
|
188
201
|
debouncedFocus(searchIndex);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apptegy/nuxt-navigation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -27,25 +27,25 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@apptegy/nuxt-intl": "2.1.2",
|
|
30
|
-
"@nuxt/kit": "^3.
|
|
30
|
+
"@nuxt/kit": "^3.17.0",
|
|
31
31
|
"@vueuse/components": "12.8.2",
|
|
32
|
-
"
|
|
32
|
+
"@vueuse/core": "^12.8.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@nuxt/devtools": "^2.
|
|
36
|
-
"@nuxt/eslint-config": "^1.
|
|
35
|
+
"@nuxt/devtools": "^2.4.0",
|
|
36
|
+
"@nuxt/eslint-config": "^1.3.0",
|
|
37
37
|
"@nuxt/module-builder": "^0.8.4",
|
|
38
|
-
"@nuxt/schema": "^3.
|
|
38
|
+
"@nuxt/schema": "^3.17.0",
|
|
39
39
|
"@nuxt/test-utils": "^3.17.2",
|
|
40
|
-
"@types/node": "^20.17.
|
|
40
|
+
"@types/node": "^20.17.32",
|
|
41
41
|
"changelogen": "^0.5.7",
|
|
42
|
-
"eslint": "^9.
|
|
43
|
-
"nuxt": "^3.
|
|
44
|
-
"sass": "^1.
|
|
45
|
-
"typescript": "^5.8.
|
|
46
|
-
"vitest": "^3.
|
|
42
|
+
"eslint": "^9.25.1",
|
|
43
|
+
"nuxt": "^3.17.0",
|
|
44
|
+
"sass": "^1.87.0",
|
|
45
|
+
"typescript": "^5.8.3",
|
|
46
|
+
"vitest": "^3.1.2",
|
|
47
47
|
"vue": "^3.5.13",
|
|
48
|
-
"vue-tsc": "^2.2.
|
|
48
|
+
"vue-tsc": "^2.2.10"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "98fbfe464f87cbffa62256a493274fbdb7237ef2"
|
|
51
51
|
}
|