@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.
Files changed (41) hide show
  1. package/README.md +1 -5
  2. package/package.json +11 -3
  3. package/src/composables/comboBox/SelectOnlyCombobox.vue +15 -8
  4. package/src/composables/comboBox/TestCombobox.ct.tsx +1 -1
  5. package/src/composables/comboBox/TestCombobox.vue +13 -10
  6. package/src/composables/comboBox/createComboBox.ts +34 -28
  7. package/src/composables/helpers/useDismissible.ts +19 -0
  8. package/src/composables/helpers/useGlobalListener.spec.ts +2 -2
  9. package/src/composables/helpers/useGlobalListener.ts +1 -1
  10. package/src/composables/helpers/useOutsideClick.spec.ts +117 -0
  11. package/src/composables/helpers/useOutsideClick.ts +45 -10
  12. package/src/composables/helpers/useTypeAhead.spec.ts +1 -1
  13. package/src/composables/helpers/useTypeAhead.ts +2 -2
  14. package/src/composables/listbox/TestListbox.ct.tsx +1 -1
  15. package/src/composables/listbox/TestListbox.vue +3 -1
  16. package/src/composables/listbox/createListbox.ts +28 -10
  17. package/src/composables/menuButton/TestMenuButton.ct.tsx +1 -1
  18. package/src/composables/menuButton/TestMenuButton.vue +4 -3
  19. package/src/composables/menuButton/createMenuButton.testing.ts +0 -19
  20. package/src/composables/menuButton/createMenuButton.ts +174 -119
  21. package/src/composables/navigationMenu/TestMenu.ct.tsx +1 -1
  22. package/src/composables/navigationMenu/TestMenu.vue +1 -1
  23. package/src/composables/navigationMenu/createMenu.testing.ts +2 -13
  24. package/src/composables/navigationMenu/createMenu.ts +6 -7
  25. package/src/composables/tabs/TestTabs.ct.tsx +12 -0
  26. package/src/composables/tabs/TestTabs.vue +28 -0
  27. package/src/composables/tabs/createTabs.testing.ts +151 -0
  28. package/src/composables/tabs/createTabs.ts +129 -0
  29. package/src/composables/tooltip/createToggletip.ts +58 -0
  30. package/src/composables/tooltip/createTooltip.ts +39 -97
  31. package/src/index.ts +11 -8
  32. package/src/playwright.ts +5 -3
  33. package/src/utils/builder.ts +108 -12
  34. package/src/utils/keyboard.spec.ts +1 -1
  35. package/src/utils/keyboard.ts +1 -1
  36. package/src/utils/math.spec.ts +1 -1
  37. package/src/utils/object.spec.ts +1 -1
  38. package/src/utils/timer.ts +10 -3
  39. package/src/utils/types.ts +10 -0
  40. package/src/utils/vitest.ts +2 -2
  41. package/src/utils/id.ts +0 -14
@@ -1,4 +1,4 @@
1
- import { isSubsetMatching } from "./object";
1
+ import { isSubsetMatching } from "./object.js";
2
2
 
3
3
  export type PressedKey =
4
4
  | string
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, test } from "vitest";
2
- import { MathUtils } from "./math";
2
+ import { MathUtils } from "./math.js";
3
3
 
4
4
  describe("MathUtils.clamp", () => {
5
5
  test.each([
@@ -1,5 +1,5 @@
1
1
  import { expect, test } from "vitest";
2
- import { isSubsetMatching } from "./object";
2
+ import { isSubsetMatching } from "./object.js";
3
3
 
4
4
  const referenceObj = { a: 42, b: "foo", c: null, d: true };
5
5
 
@@ -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
- return (...lastArgs: TArgs) => {
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
  };
@@ -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;
@@ -1,6 +1,6 @@
1
- import { vi, type Awaitable } from "vitest";
1
+ import { vi } from "vitest";
2
2
 
3
- type Callback = () => Awaitable<void>;
3
+ type Callback = () => void | (() => Promise<void>);
4
4
 
5
5
  /**
6
6
  * Mocks the following vue lifecycle functions:
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()}`;