@sit-onyx/headless 1.0.0-beta.2 → 1.0.0-beta.21
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/README.md +1 -5
- package/package.json +11 -3
- package/src/composables/comboBox/SelectOnlyCombobox.vue +15 -8
- package/src/composables/comboBox/TestCombobox.ct.tsx +1 -1
- package/src/composables/comboBox/TestCombobox.vue +13 -10
- package/src/composables/comboBox/createComboBox.ts +34 -28
- package/src/composables/helpers/useDismissible.ts +19 -0
- package/src/composables/helpers/useGlobalListener.spec.ts +2 -2
- package/src/composables/helpers/useGlobalListener.ts +1 -1
- package/src/composables/helpers/useOutsideClick.spec.ts +117 -0
- package/src/composables/helpers/useOutsideClick.ts +45 -10
- package/src/composables/helpers/useTypeAhead.spec.ts +1 -1
- package/src/composables/helpers/useTypeAhead.ts +2 -2
- package/src/composables/listbox/TestListbox.ct.tsx +1 -1
- package/src/composables/listbox/TestListbox.vue +3 -1
- package/src/composables/listbox/createListbox.ts +28 -10
- package/src/composables/menuButton/TestMenuButton.ct.tsx +1 -1
- package/src/composables/menuButton/TestMenuButton.vue +4 -3
- package/src/composables/menuButton/createMenuButton.testing.ts +0 -19
- package/src/composables/menuButton/createMenuButton.ts +174 -119
- package/src/composables/navigationMenu/TestMenu.ct.tsx +1 -1
- package/src/composables/navigationMenu/TestMenu.vue +1 -1
- package/src/composables/navigationMenu/createMenu.testing.ts +2 -13
- package/src/composables/navigationMenu/createMenu.ts +6 -7
- package/src/composables/tabs/TestTabs.ct.tsx +12 -0
- package/src/composables/tabs/TestTabs.vue +28 -0
- package/src/composables/tabs/createTabs.testing.ts +151 -0
- package/src/composables/tabs/createTabs.ts +129 -0
- package/src/composables/tooltip/createToggletip.ts +58 -0
- package/src/composables/tooltip/createTooltip.ts +39 -97
- package/src/index.ts +11 -8
- package/src/playwright.ts +5 -3
- package/src/utils/builder.ts +108 -12
- package/src/utils/keyboard.spec.ts +1 -1
- package/src/utils/keyboard.ts +1 -1
- package/src/utils/math.spec.ts +1 -1
- package/src/utils/object.spec.ts +1 -1
- package/src/utils/timer.ts +10 -3
- package/src/utils/types.ts +10 -0
- package/src/utils/vitest.ts +2 -2
- package/src/utils/id.ts +0 -14
package/src/utils/keyboard.ts
CHANGED
package/src/utils/math.spec.ts
CHANGED
package/src/utils/object.spec.ts
CHANGED
package/src/utils/timer.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { toValue, type MaybeRefOrGetter } from "vue";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Debounces a given callback which will only be called when not called for the given timeout.
|
|
3
5
|
*
|
|
@@ -5,11 +7,16 @@
|
|
|
5
7
|
*/
|
|
6
8
|
export const debounce = <TArgs extends unknown[]>(
|
|
7
9
|
handler: (...args: TArgs) => void,
|
|
8
|
-
timeout: number
|
|
10
|
+
timeout: MaybeRefOrGetter<number>,
|
|
9
11
|
) => {
|
|
10
12
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
11
|
-
|
|
13
|
+
|
|
14
|
+
const func = (...lastArgs: TArgs) => {
|
|
12
15
|
clearTimeout(timer);
|
|
13
|
-
timer = setTimeout(() => handler(...lastArgs), timeout);
|
|
16
|
+
timer = setTimeout(() => handler(...lastArgs), toValue(timeout));
|
|
14
17
|
};
|
|
18
|
+
/** Abort the currently debounced action, if any. */
|
|
19
|
+
func.abort = () => clearTimeout(timer);
|
|
20
|
+
|
|
21
|
+
return func;
|
|
15
22
|
};
|
package/src/utils/types.ts
CHANGED
|
@@ -21,3 +21,13 @@ export type IfDefined<Key extends string, TValue> =
|
|
|
21
21
|
export type IsArray<TValue, TMultiple extends boolean = false> = TMultiple extends true
|
|
22
22
|
? TValue[]
|
|
23
23
|
: TValue;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* A type that can be wrapped in an array.
|
|
27
|
+
*/
|
|
28
|
+
export type Arrayable<T> = T | Array<T>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Either the actual value or a nullish one.
|
|
32
|
+
*/
|
|
33
|
+
export type Nullable<T = never> = T | null | undefined;
|
package/src/utils/vitest.ts
CHANGED
package/src/utils/id.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a unique global id string
|
|
3
|
-
*/
|
|
4
|
-
// ⚠️ we make use of an IIFE to encapsulate the globalCounter so it can never accidentally be used somewhere else.
|
|
5
|
-
const nextId = (() => {
|
|
6
|
-
let globalCounter = 1;
|
|
7
|
-
return () => globalCounter++;
|
|
8
|
-
})();
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Creates a globally unique string using a counter.
|
|
12
|
-
* The given name is the prefix.
|
|
13
|
-
*/
|
|
14
|
-
export const createId = (name: string) => `${name}-${nextId()}`;
|