@sit-onyx/headless 0.5.0 → 0.6.0-dev-20260126101353
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/composables/toggleButton/TestToggleButton.ct.d.ts +1 -0
- package/dist/composables/toggleButton/TestToggleButton.d.vue.ts +2 -0
- package/dist/composables/toggleButton/createToggleButton.d.ts +26 -0
- package/dist/composables/toggleButton/createToggleButton.testing.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +16 -0
- package/dist/playwright.d.ts +1 -0
- package/dist/playwright.js +32 -1
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import('@vue/runtime-core').DefineComponent<{}, {}, {}, {}, {}, import('@vue/runtime-core').ComponentOptionsMixin, import('@vue/runtime-core').ComponentOptionsMixin, {}, string, import('@vue/runtime-core').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('@vue/runtime-core').ComponentProvideOptions, true, {}, HTMLButtonElement>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
type CreateToggleButtonOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* The current state of the toggle button.
|
|
5
|
+
*/
|
|
6
|
+
isPressed: MaybeRefOrGetter<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Triggered when the toggle button is clicked and the `isPressed` state should be toggled.
|
|
9
|
+
*/
|
|
10
|
+
onToggle: () => void;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Based on https://www.w3.org/WAI/ARIA/apg/patterns/button/#:~:text=Toggle%20button
|
|
14
|
+
*/
|
|
15
|
+
export declare const createToggleButton: (options: CreateToggleButtonOptions) => {
|
|
16
|
+
elements: {
|
|
17
|
+
/**
|
|
18
|
+
* A html button element that is supposed to act as a toggle button.
|
|
19
|
+
*/
|
|
20
|
+
button: import('vue').ComputedRef<{
|
|
21
|
+
"aria-pressed": boolean;
|
|
22
|
+
onClick: () => void;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Locator } from '@playwright/test';
|
|
2
|
+
export type ToggleButtonTestingOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Locator for the (toggle) button element.
|
|
5
|
+
*/
|
|
6
|
+
button: Locator;
|
|
7
|
+
labelText: string;
|
|
8
|
+
initiallyPressed: boolean;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Playwright utility for executing accessibility testing for a navigation menu.
|
|
12
|
+
* Will check aria attributes and keyboard shortcuts as defined in https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/examples/menu-button-links.
|
|
13
|
+
*/
|
|
14
|
+
export declare const toggleButtonTesting: ({ button, labelText, initiallyPressed, }: ToggleButtonTestingOptions) => Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './composables/menuButton/createMenuButton.js';
|
|
|
7
7
|
export * from './composables/navigationMenu/createMenu.js';
|
|
8
8
|
export * from './composables/slider/createSlider.js';
|
|
9
9
|
export * from './composables/tabs/createTabs.js';
|
|
10
|
+
export * from './composables/toggleButton/createToggleButton.js';
|
|
10
11
|
export * from './composables/tooltip/createToggletip.js';
|
|
11
12
|
export * from './composables/tooltip/createTooltip.js';
|
|
12
13
|
export * from './utils/builder.js';
|
package/dist/index.js
CHANGED
|
@@ -1320,6 +1320,21 @@ const createTabs = createBuilder((options) => {
|
|
|
1320
1320
|
}
|
|
1321
1321
|
};
|
|
1322
1322
|
});
|
|
1323
|
+
const createToggleButton = createBuilder((options) => {
|
|
1324
|
+
return {
|
|
1325
|
+
elements: {
|
|
1326
|
+
/**
|
|
1327
|
+
* A html button element that is supposed to act as a toggle button.
|
|
1328
|
+
*/
|
|
1329
|
+
button: computed(
|
|
1330
|
+
() => ({
|
|
1331
|
+
"aria-pressed": toValue(options.isPressed),
|
|
1332
|
+
onClick: options.onToggle
|
|
1333
|
+
})
|
|
1334
|
+
)
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
});
|
|
1323
1338
|
const useDismissible = ({ isExpanded }) => useGlobalEventListener({
|
|
1324
1339
|
type: "keydown",
|
|
1325
1340
|
listener: (e) => {
|
|
@@ -1426,6 +1441,7 @@ export {
|
|
|
1426
1441
|
createNavigationMenu,
|
|
1427
1442
|
createSlider,
|
|
1428
1443
|
createTabs,
|
|
1444
|
+
createToggleButton,
|
|
1429
1445
|
createToggletip,
|
|
1430
1446
|
createTooltip,
|
|
1431
1447
|
debounce,
|
package/dist/playwright.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export * from './composables/menuButton/createMenuButton.testing.js';
|
|
|
4
4
|
export * from './composables/navigationMenu/createMenu.testing.js';
|
|
5
5
|
export * from './composables/slider/createSlider.testing.js';
|
|
6
6
|
export * from './composables/tabs/createTabs.testing.js';
|
|
7
|
+
export * from './composables/toggleButton/createToggleButton.testing.js';
|
package/dist/playwright.js
CHANGED
|
@@ -495,6 +495,36 @@ const expectPanelAttributes = async (panel, tabId) => {
|
|
|
495
495
|
tabId
|
|
496
496
|
);
|
|
497
497
|
};
|
|
498
|
+
const toggleButtonTesting = async ({
|
|
499
|
+
button,
|
|
500
|
+
labelText,
|
|
501
|
+
initiallyPressed
|
|
502
|
+
}) => {
|
|
503
|
+
await expect(
|
|
504
|
+
button,
|
|
505
|
+
`button must have 'aria-pressed' attribute to be recognized as toggle button.`
|
|
506
|
+
).toHaveAttribute("aria-pressed", String(initiallyPressed));
|
|
507
|
+
await expect(button).toBeVisible();
|
|
508
|
+
await expect(button).toHaveAccessibleName(labelText);
|
|
509
|
+
await button.click();
|
|
510
|
+
await expect(button, `button must toggle 'aria-pressed' attribute after click.`).toHaveAttribute(
|
|
511
|
+
"aria-pressed",
|
|
512
|
+
String(!initiallyPressed)
|
|
513
|
+
);
|
|
514
|
+
await expect(
|
|
515
|
+
button,
|
|
516
|
+
"button must not switch it's label after a state change"
|
|
517
|
+
).toHaveAccessibleName(labelText);
|
|
518
|
+
await button.press("Space");
|
|
519
|
+
await expect(button, `button must toggle 'aria-pressed' attribute after click.`).toHaveAttribute(
|
|
520
|
+
"aria-pressed",
|
|
521
|
+
String(initiallyPressed)
|
|
522
|
+
);
|
|
523
|
+
await expect(
|
|
524
|
+
button,
|
|
525
|
+
"button must not switch it's label after a state change"
|
|
526
|
+
).toHaveAccessibleName(labelText);
|
|
527
|
+
};
|
|
498
528
|
export {
|
|
499
529
|
comboboxSelectOnlyTesting,
|
|
500
530
|
comboboxTesting,
|
|
@@ -503,5 +533,6 @@ export {
|
|
|
503
533
|
navigationTesting,
|
|
504
534
|
rangeSliderTesting,
|
|
505
535
|
singleSliderTesting,
|
|
506
|
-
tabsTesting
|
|
536
|
+
tabsTesting,
|
|
537
|
+
toggleButtonTesting
|
|
507
538
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sit-onyx/headless",
|
|
3
3
|
"description": "Headless composables for Vue",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.0-dev-20260126101353",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Schwarz IT KG",
|
|
7
7
|
"license": "Apache-2.0",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"vue": ">= 3.5.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@vue/compiler-dom": "3.5.
|
|
42
|
-
"vue": "3.5.
|
|
41
|
+
"@vue/compiler-dom": "3.5.27",
|
|
42
|
+
"vue": "3.5.27",
|
|
43
43
|
"@sit-onyx/shared": "^0.1.0"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|