@sit-onyx/headless 1.0.0-beta.21 → 1.0.0-beta.23

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 (86) hide show
  1. package/dist/composables/comboBox/SelectOnlyCombobox.d.vue.ts +299 -0
  2. package/dist/composables/comboBox/TestCombobox.ct.d.ts +1 -0
  3. package/dist/composables/comboBox/TestCombobox.d.vue.ts +299 -0
  4. package/dist/composables/comboBox/createComboBox.d.ts +370 -0
  5. package/dist/composables/comboBox/createComboBox.testing.d.ts +10 -0
  6. package/dist/composables/helpers/useDismissible.d.ts +10 -0
  7. package/dist/composables/helpers/useGlobalListener.d.ts +10 -0
  8. package/dist/composables/helpers/useGlobalListener.spec.d.ts +1 -0
  9. package/dist/composables/helpers/useOutsideClick.d.ts +26 -0
  10. package/dist/composables/helpers/useOutsideClick.spec.d.ts +1 -0
  11. package/dist/composables/helpers/useTypeAhead.d.ts +11 -0
  12. package/dist/composables/helpers/useTypeAhead.spec.d.ts +1 -0
  13. package/dist/composables/listbox/TestListbox.ct.d.ts +1 -0
  14. package/dist/composables/listbox/TestListbox.d.vue.ts +2 -0
  15. package/dist/composables/listbox/createListbox.d.ts +102 -0
  16. package/dist/composables/listbox/createListbox.testing.d.ts +24 -0
  17. package/dist/composables/menuButton/TestMenuButton.ct.d.ts +1 -0
  18. package/dist/composables/menuButton/TestMenuButton.d.vue.ts +2 -0
  19. package/dist/composables/menuButton/createMenuButton.d.ts +78 -0
  20. package/dist/composables/menuButton/createMenuButton.testing.d.ts +24 -0
  21. package/dist/composables/navigationMenu/TestMenu.ct.d.ts +1 -0
  22. package/dist/composables/navigationMenu/TestMenu.d.vue.ts +2 -0
  23. package/dist/composables/navigationMenu/createMenu.d.ts +21 -0
  24. package/dist/composables/navigationMenu/createMenu.testing.d.ts +16 -0
  25. package/dist/composables/tabs/TestTabs.ct.d.ts +1 -0
  26. package/dist/composables/tabs/TestTabs.d.vue.ts +2 -0
  27. package/dist/composables/tabs/createTabs.d.ts +48 -0
  28. package/dist/composables/tabs/createTabs.testing.d.ts +13 -0
  29. package/dist/composables/tooltip/createToggletip.d.ts +36 -0
  30. package/dist/composables/tooltip/createTooltip.d.ts +42 -0
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.js +1089 -0
  33. package/dist/playwright.d.ts +5 -0
  34. package/dist/playwright.js +369 -0
  35. package/dist/utils/builder.d.ts +85 -0
  36. package/dist/utils/keyboard.d.ts +26 -0
  37. package/dist/utils/keyboard.spec.d.ts +1 -0
  38. package/dist/utils/math.d.ts +6 -0
  39. package/dist/utils/math.spec.d.ts +1 -0
  40. package/dist/utils/object.d.ts +5 -0
  41. package/dist/utils/object.spec.d.ts +1 -0
  42. package/dist/utils/timer.d.ts +10 -0
  43. package/{src/utils/types.ts → dist/utils/types.d.ts} +4 -12
  44. package/dist/utils/vitest.d.ts +12 -0
  45. package/package.json +18 -9
  46. package/src/composables/comboBox/SelectOnlyCombobox.vue +0 -90
  47. package/src/composables/comboBox/TestCombobox.ct.tsx +0 -24
  48. package/src/composables/comboBox/TestCombobox.vue +0 -84
  49. package/src/composables/comboBox/createComboBox.testing.ts +0 -168
  50. package/src/composables/comboBox/createComboBox.ts +0 -280
  51. package/src/composables/helpers/useDismissible.ts +0 -19
  52. package/src/composables/helpers/useGlobalListener.spec.ts +0 -93
  53. package/src/composables/helpers/useGlobalListener.ts +0 -64
  54. package/src/composables/helpers/useOutsideClick.spec.ts +0 -117
  55. package/src/composables/helpers/useOutsideClick.ts +0 -69
  56. package/src/composables/helpers/useTypeAhead.spec.ts +0 -29
  57. package/src/composables/helpers/useTypeAhead.ts +0 -26
  58. package/src/composables/listbox/TestListbox.ct.tsx +0 -17
  59. package/src/composables/listbox/TestListbox.vue +0 -92
  60. package/src/composables/listbox/createListbox.testing.ts +0 -141
  61. package/src/composables/listbox/createListbox.ts +0 -234
  62. package/src/composables/menuButton/TestMenuButton.ct.tsx +0 -14
  63. package/src/composables/menuButton/TestMenuButton.vue +0 -29
  64. package/src/composables/menuButton/createMenuButton.testing.ts +0 -91
  65. package/src/composables/menuButton/createMenuButton.ts +0 -206
  66. package/src/composables/navigationMenu/TestMenu.ct.tsx +0 -12
  67. package/src/composables/navigationMenu/TestMenu.vue +0 -16
  68. package/src/composables/navigationMenu/createMenu.testing.ts +0 -37
  69. package/src/composables/navigationMenu/createMenu.ts +0 -55
  70. package/src/composables/tabs/TestTabs.ct.tsx +0 -12
  71. package/src/composables/tabs/TestTabs.vue +0 -28
  72. package/src/composables/tabs/createTabs.testing.ts +0 -151
  73. package/src/composables/tabs/createTabs.ts +0 -129
  74. package/src/composables/tooltip/createToggletip.ts +0 -58
  75. package/src/composables/tooltip/createTooltip.ts +0 -71
  76. package/src/index.ts +0 -11
  77. package/src/playwright.ts +0 -5
  78. package/src/utils/builder.ts +0 -135
  79. package/src/utils/keyboard.spec.ts +0 -53
  80. package/src/utils/keyboard.ts +0 -351
  81. package/src/utils/math.spec.ts +0 -14
  82. package/src/utils/math.ts +0 -6
  83. package/src/utils/object.spec.ts +0 -33
  84. package/src/utils/object.ts +0 -8
  85. package/src/utils/timer.ts +0 -22
  86. package/src/utils/vitest.ts +0 -36
@@ -0,0 +1,78 @@
1
+ import { MaybeRef, Ref } from 'vue';
2
+ type CreateMenuButtonOptions = {
3
+ isExpanded: Readonly<Ref<boolean>>;
4
+ trigger: Readonly<MaybeRef<"hover" | "click">>;
5
+ onToggle: () => void;
6
+ disabled?: Readonly<Ref<boolean>>;
7
+ /**
8
+ * Whether the menu button opens to the top or bottom. Defines the keyboard navigation behavior (e.g. Arrow up and down).
9
+ *
10
+ * @default "bottom"
11
+ */
12
+ position?: MaybeRef<"top" | "bottom">;
13
+ };
14
+ /**
15
+ * Based on https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/
16
+ */
17
+ export declare const createMenuButton: (options: CreateMenuButtonOptions) => {
18
+ elements: {
19
+ listItem: {
20
+ role: string;
21
+ };
22
+ menuItem: (data: {
23
+ active?: boolean;
24
+ disabled?: boolean;
25
+ }) => {
26
+ "aria-current": "page" | undefined;
27
+ "aria-disabled": boolean | undefined;
28
+ role: string;
29
+ onKeydown: (event: KeyboardEvent) => void;
30
+ };
31
+ root: import('vue').ComputedRef<{
32
+ onMouseenter?: (() => void) | undefined;
33
+ onMouseleave?: (() => void) | undefined;
34
+ id: string;
35
+ onKeydown: (event: KeyboardEvent) => void;
36
+ ref: import('../../utils/builder.js').HeadlessElRef<HTMLElement>;
37
+ }>;
38
+ button: import('vue').ComputedRef<{
39
+ readonly "aria-controls": string;
40
+ readonly "aria-expanded": boolean;
41
+ readonly "aria-haspopup": true;
42
+ readonly onFocus: () => void;
43
+ readonly onClick: () => void;
44
+ readonly id: string;
45
+ readonly disabled: boolean | undefined;
46
+ }>;
47
+ menu: {
48
+ id: string;
49
+ ref: import('../../utils/builder.js').HeadlessElRef<HTMLElement>;
50
+ role: string;
51
+ "aria-labelledby": string;
52
+ onClick: () => void;
53
+ };
54
+ };
55
+ };
56
+ type CreateMenuItemOptions = {
57
+ /**
58
+ * Called when the menu item should be opened (if it has nested children).
59
+ */
60
+ onOpen?: () => void;
61
+ };
62
+ export declare const createMenuItems: (options?: CreateMenuItemOptions | undefined) => {
63
+ elements: {
64
+ listItem: {
65
+ role: string;
66
+ };
67
+ menuItem: (data: {
68
+ active?: boolean;
69
+ disabled?: boolean;
70
+ }) => {
71
+ "aria-current": "page" | undefined;
72
+ "aria-disabled": boolean | undefined;
73
+ role: string;
74
+ onKeydown: (event: KeyboardEvent) => void;
75
+ };
76
+ };
77
+ };
78
+ export {};
@@ -0,0 +1,24 @@
1
+ import { Locator, Page } from '@playwright/test';
2
+ export type MenuButtonTestingOptions = {
3
+ /**
4
+ * Playwright page.
5
+ */
6
+ page: Page;
7
+ /**
8
+ * Locator for the button element.
9
+ */
10
+ button: Locator;
11
+ /**
12
+ * Menu, e.g. a `<ul>` element.
13
+ */
14
+ menu: Locator;
15
+ /**
16
+ * List items (at least 3).
17
+ */
18
+ menuItems: Locator;
19
+ };
20
+ /**
21
+ * Playwright utility for executing accessibility testing for a navigation menu.
22
+ * Will check aria attributes and keyboard shortcuts as defined in https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/examples/menu-button-links.
23
+ */
24
+ export declare const menuButtonTesting: ({ page, button, menu, menuItems, }: MenuButtonTestingOptions) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLElement>;
2
+ export default _default;
@@ -0,0 +1,21 @@
1
+ import { MaybeRef } from 'vue';
2
+ type CreateNavigationMenu = {
3
+ /**
4
+ * Name of the navigation landmark.
5
+ * Usually this is the name of the website.
6
+ */
7
+ navigationName?: MaybeRef<string | undefined>;
8
+ };
9
+ /**
10
+ * Based on https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/
11
+ */
12
+ export declare const createNavigationMenu: (args_0: CreateNavigationMenu) => {
13
+ elements: {
14
+ nav: {
15
+ "aria-label": string | undefined;
16
+ id: string;
17
+ onKeydown: (event: KeyboardEvent) => void;
18
+ };
19
+ };
20
+ };
21
+ export {};
@@ -0,0 +1,16 @@
1
+ import { Locator } from '@playwright/test';
2
+ export type NavigationMenuTestingOptions = {
3
+ /**
4
+ * Locator for the navigation landmark.
5
+ */
6
+ nav: Locator;
7
+ /**
8
+ * Locator for the button elements.
9
+ */
10
+ buttons: Locator;
11
+ };
12
+ /**
13
+ * Playwright utility for executing accessibility testing for a navigation menu.
14
+ * Will check aria attributes and keyboard shortcuts as defined in https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/examples/disclosure-navigation/
15
+ */
16
+ export declare const navigationTesting: ({ nav, buttons }: NavigationMenuTestingOptions) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLDivElement>;
2
+ export default _default;
@@ -0,0 +1,48 @@
1
+ import { MaybeRef, Ref } from 'vue';
2
+ type CreateTabsOptions<TKey extends PropertyKey = PropertyKey> = {
3
+ /**
4
+ * Label of the tablist.
5
+ */
6
+ label: MaybeRef<string>;
7
+ /**
8
+ * Currently selected tab.
9
+ */
10
+ selectedTab: Ref<TKey>;
11
+ /**
12
+ * Called when the user selects a tab.
13
+ */
14
+ onSelect?: (selectedTabValue: TKey) => void;
15
+ };
16
+ /**
17
+ * Composable for implementing accessible tabs.
18
+ * Based on https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
19
+ */
20
+ export declare const createTabs: <T extends PropertyKey>(options: CreateTabsOptions<T>) => {
21
+ elements: {
22
+ tablist: import('vue').ComputedRef<{
23
+ role: string;
24
+ "aria-label": string;
25
+ onKeydown: (event: KeyboardEvent) => void;
26
+ }>;
27
+ tab: import('vue').ComputedRef<(data: {
28
+ value: T;
29
+ disabled?: boolean;
30
+ }) => {
31
+ readonly id: string;
32
+ readonly role: "tab";
33
+ readonly "aria-selected": boolean;
34
+ readonly "aria-controls": string;
35
+ readonly "aria-disabled": true | undefined;
36
+ readonly onClick: () => void | undefined;
37
+ readonly tabindex: 0 | -1;
38
+ }>;
39
+ tabpanel: import('vue').ComputedRef<(data: {
40
+ value: T;
41
+ }) => {
42
+ readonly id: string;
43
+ readonly role: "tabpanel";
44
+ readonly "aria-labelledby": string;
45
+ }>;
46
+ };
47
+ };
48
+ export {};
@@ -0,0 +1,13 @@
1
+ import { Locator, Page } from '@playwright/test';
2
+ export type TabsTestingOptions = {
3
+ page: Page;
4
+ /**
5
+ * Locator of the tabs component. Must have at least 3 tabs where the first one is initially selected.
6
+ */
7
+ tablist: Locator;
8
+ };
9
+ /**
10
+ * Playwright utility for executing accessibility testing for tabs.
11
+ * Will check aria attributes and keyboard shortcuts as defined in https://www.w3.org/WAI/ARIA/apg/patterns/tabs/
12
+ */
13
+ export declare const tabsTesting: (options: TabsTestingOptions) => Promise<void>;
@@ -0,0 +1,36 @@
1
+ import { MaybeRefOrGetter, Ref } from 'vue';
2
+ export type CreateToggletipOptions = {
3
+ toggleLabel: MaybeRefOrGetter<string>;
4
+ isVisible?: Ref<boolean>;
5
+ };
6
+ /**
7
+ * Create a toggletip as described in https://inclusive-components.design/tooltips-toggletips/
8
+ * Its visibility is toggled on click.
9
+ * Therefore a toggletip MUST NOT be used to describe the associated trigger element.
10
+ * Commonly this pattern uses a button with the ⓘ as the trigger element.
11
+ * To describe the associated element use `createTooltip`.
12
+ */
13
+ export declare const createToggletip: (args_0: CreateToggletipOptions) => import('../../utils/builder.js').HeadlessComposable<{
14
+ /**
15
+ * The element which controls the toggletip visibility:
16
+ * Preferably a `button` element.
17
+ */
18
+ trigger: import('vue').ComputedRef<{
19
+ id: string;
20
+ onClick: () => boolean;
21
+ "aria-label": string;
22
+ }>;
23
+ /**
24
+ * The element with the relevant toggletip content.
25
+ * Only simple, textual content is allowed.
26
+ */
27
+ tooltip: {
28
+ onToggle: (e: Event) => void;
29
+ anchor: string;
30
+ popover: string;
31
+ role: string;
32
+ tabindex: string;
33
+ };
34
+ }, {
35
+ isVisible: Ref<boolean, boolean> | Ref<false, false> | Ref<true, true>;
36
+ }, undefined>;
@@ -0,0 +1,42 @@
1
+ import { MaybeRefOrGetter, Ref } from 'vue';
2
+ export type CreateTooltipOptions = {
3
+ /**
4
+ * Number of milliseconds to use as debounce when showing/hiding the tooltip.
5
+ */
6
+ debounce: MaybeRefOrGetter<number>;
7
+ isVisible?: Ref<boolean>;
8
+ };
9
+ /**
10
+ * Create a tooltip as described in https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/tooltip_role
11
+ * Its visibility is toggled on hover or focus.
12
+ * A tooltip MUST be used to describe the associated trigger element. E.g. The usage with the ⓘ would be incorrect.
13
+ * To provide contextual information use the `createToggletip`.
14
+ */
15
+ export declare const createTooltip: (args_0: CreateTooltipOptions) => import('../../utils/builder.js').HeadlessComposable<{
16
+ /**
17
+ * The element which controls the tooltip visibility on hover.
18
+ */
19
+ trigger: {
20
+ onMouseover: () => boolean;
21
+ onMouseout: () => boolean;
22
+ onFocusin: () => boolean;
23
+ onFocusout: () => boolean;
24
+ "aria-describedby": string;
25
+ };
26
+ /**
27
+ * The element describing the tooltip.
28
+ * Only simple, textual and non-focusable content is allowed.
29
+ */
30
+ tooltip: {
31
+ onMouseover: () => boolean;
32
+ onMouseout: () => boolean;
33
+ onFocusin: () => boolean;
34
+ onFocusout: () => boolean;
35
+ popover: string;
36
+ role: string;
37
+ id: string;
38
+ tabindex: string;
39
+ };
40
+ }, {
41
+ isVisible: Ref<boolean, boolean> | Ref<false, false> | Ref<true, true>;
42
+ }, undefined>;
@@ -0,0 +1,12 @@
1
+ export * from './composables/comboBox/createComboBox.js';
2
+ export * from './composables/helpers/useGlobalListener.js';
3
+ export * from './composables/helpers/useOutsideClick.js';
4
+ export * from './composables/listbox/createListbox.js';
5
+ export * from './composables/menuButton/createMenuButton.js';
6
+ export * from './composables/navigationMenu/createMenu.js';
7
+ export * from './composables/tabs/createTabs.js';
8
+ export * from './composables/tooltip/createToggletip.js';
9
+ export * from './composables/tooltip/createTooltip.js';
10
+ export * from './utils/builder.js';
11
+ export { isPrintableCharacter, wasKeyPressed } from './utils/keyboard.js';
12
+ export { debounce } from './utils/timer.js';