@illinois-grad/grad-vue 7.1.2 → 7.2.0
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/components/GMain.vue.d.ts +63 -0
- package/dist/components/GSkipLink.vue.d.ts +50 -0
- package/dist/compose/useRouteAnnouncer.d.ts +87 -0
- package/dist/{grad-vue-D3cnBp2w.js → grad-vue-Cx1uTli6.js} +1499 -1377
- package/dist/grad-vue-Cx1uTli6.js.map +1 -0
- package/dist/grad-vue-elements.css +26 -26
- package/dist/grad-vue-elements.js +197 -179
- package/dist/grad-vue-elements.js.map +1 -1
- package/dist/grad-vue.css +1 -1
- package/dist/grad-vue.d.ts +5 -1
- package/dist/grad-vue.js +2 -2
- package/dist/plugin.d.ts +3 -1
- package/dist/plugin.js +4 -4
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
- package/dist/grad-vue-D3cnBp2w.js.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<main>` landmark for a page, set up as the target for
|
|
3
|
+
* `GSkipLink` and `useRouteAnnouncer`.
|
|
4
|
+
*
|
|
5
|
+
* Use one per page, inside each view rather than around `<RouterView>`,
|
|
6
|
+
* so sidebars and other complementary content stay outside the landmark.
|
|
7
|
+
*
|
|
8
|
+
* ```vue
|
|
9
|
+
* <template>
|
|
10
|
+
* <GSidebar>...</GSidebar>
|
|
11
|
+
* <GMain class="profile">
|
|
12
|
+
* <h1>Profile</h1>
|
|
13
|
+
* </GMain>
|
|
14
|
+
* </template>
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* ## Accessible route changes
|
|
18
|
+
*
|
|
19
|
+
* Use the `useRouteAnnouncer` composable once in the root component.
|
|
20
|
+
* After each navigation to a different page, it moves focus to the `<h1>`
|
|
21
|
+
* inside `GMain` (or `GMain` itself) and announces the new page title.
|
|
22
|
+
* Navigations that only change the query or hash are ignored.
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* // App.vue setup
|
|
26
|
+
* import { useRouter } from "vue-router";
|
|
27
|
+
* import { useRouteAnnouncer } from "@illinois-grad/grad-vue";
|
|
28
|
+
*
|
|
29
|
+
* useRouteAnnouncer(useRouter());
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ```vue
|
|
33
|
+
* <GSkipLink />
|
|
34
|
+
* <GAppHeader>...</GAppHeader>
|
|
35
|
+
* <RouterView />
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* Options can customize what counts as a new page (`isNewPage`), when focus
|
|
39
|
+
* moves (`focus`), waiting for async page data (`ready`), and the
|
|
40
|
+
* announcement text (`message`).
|
|
41
|
+
*/
|
|
42
|
+
declare const _default: typeof __VLS_export;
|
|
43
|
+
export default _default;
|
|
44
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
45
|
+
/**
|
|
46
|
+
* Id used by `GSkipLink` and `useRouteAnnouncer` to find the landmark
|
|
47
|
+
*/
|
|
48
|
+
id?: string;
|
|
49
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
50
|
+
/**
|
|
51
|
+
* Id used by `GSkipLink` and `useRouteAnnouncer` to find the landmark
|
|
52
|
+
*/
|
|
53
|
+
id?: string;
|
|
54
|
+
}> & Readonly<{}>, {
|
|
55
|
+
id: string;
|
|
56
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
57
|
+
default?: (props: {}) => any;
|
|
58
|
+
}>;
|
|
59
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
60
|
+
new (): {
|
|
61
|
+
$slots: S;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A "skip to main content" link for keyboard and screen reader users.
|
|
3
|
+
*
|
|
4
|
+
* Place it as the first focusable element in the app, before `GAppHeader`.
|
|
5
|
+
* It stays hidden until it receives keyboard focus. Activating it moves
|
|
6
|
+
* focus to the element with the `target` id (usually a `GMain`), falling
|
|
7
|
+
* back to the first `<main>` element.
|
|
8
|
+
*
|
|
9
|
+
* Focus is moved with JavaScript, so it works with client-side routers
|
|
10
|
+
* and with targets that are rendered after the link.
|
|
11
|
+
*
|
|
12
|
+
* ```vue
|
|
13
|
+
* <GSkipLink />
|
|
14
|
+
* <GAppHeader>...</GAppHeader>
|
|
15
|
+
* <RouterView />
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
declare const _default: typeof __VLS_export;
|
|
19
|
+
export default _default;
|
|
20
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
21
|
+
/**
|
|
22
|
+
* Id of the element to move focus to
|
|
23
|
+
*/
|
|
24
|
+
target?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Link text
|
|
27
|
+
* @demo
|
|
28
|
+
*/
|
|
29
|
+
label?: string;
|
|
30
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
31
|
+
/**
|
|
32
|
+
* Id of the element to move focus to
|
|
33
|
+
*/
|
|
34
|
+
target?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Link text
|
|
37
|
+
* @demo
|
|
38
|
+
*/
|
|
39
|
+
label?: string;
|
|
40
|
+
}> & Readonly<{}>, {
|
|
41
|
+
label: string;
|
|
42
|
+
target: string;
|
|
43
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
44
|
+
default?: (props: {}) => any;
|
|
45
|
+
}>;
|
|
46
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type Ref } from "vue";
|
|
2
|
+
/**
|
|
3
|
+
* The subset of a vue-router route location used by `useRouteAnnouncer`.
|
|
4
|
+
*/
|
|
5
|
+
export interface RouteAnnouncerLocation {
|
|
6
|
+
path: string;
|
|
7
|
+
hash?: string;
|
|
8
|
+
matched?: readonly unknown[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The subset of a vue-router `Router` used by `useRouteAnnouncer`.
|
|
12
|
+
* grad-vue doesn't depend on vue-router, so any compatible object works.
|
|
13
|
+
*/
|
|
14
|
+
export interface RouteAnnouncerRouter<L extends RouteAnnouncerLocation = RouteAnnouncerLocation> {
|
|
15
|
+
afterEach(guard: (to: L, from: L, failure?: unknown) => unknown): () => void;
|
|
16
|
+
}
|
|
17
|
+
export interface UseRouteAnnouncerOptions<L extends RouteAnnouncerLocation = RouteAnnouncerLocation> {
|
|
18
|
+
/**
|
|
19
|
+
* Id of the main landmark (see `GMain`). Falls back to the first `<main>`.
|
|
20
|
+
* @default "main-content"
|
|
21
|
+
*/
|
|
22
|
+
mainId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Whether a navigation leads to a different page. Navigations that stay
|
|
25
|
+
* on the same page (query or hash changes like filters and tabs) are
|
|
26
|
+
* ignored. By default, a different path means a different page.
|
|
27
|
+
*/
|
|
28
|
+
isNewPage?: (to: L, from: L) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to move focus to the new page's `<h1>` (or main landmark).
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
focus?: boolean | ((to: L, from: L) => boolean);
|
|
34
|
+
/**
|
|
35
|
+
* Waits before moving focus and announcing, for pages that load their
|
|
36
|
+
* title or heading asynchronously. Resolve when the page is ready; use a
|
|
37
|
+
* timeout so a failed load doesn't block the announcement.
|
|
38
|
+
*/
|
|
39
|
+
ready?: (to: L, from: L) => unknown;
|
|
40
|
+
/**
|
|
41
|
+
* Builds the announcement. Defaults to "Navigated to {document.title}".
|
|
42
|
+
* Return an empty string to skip the announcement.
|
|
43
|
+
*/
|
|
44
|
+
message?: (to: L, title: string) => string;
|
|
45
|
+
}
|
|
46
|
+
export interface UseRouteAnnouncerReturn {
|
|
47
|
+
/**
|
|
48
|
+
* The most recent announcement.
|
|
49
|
+
*/
|
|
50
|
+
message: Readonly<Ref<string>>;
|
|
51
|
+
/**
|
|
52
|
+
* Announce a message in the polite live region.
|
|
53
|
+
*/
|
|
54
|
+
announce: (text: string) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Remove the router hook and live region.
|
|
57
|
+
*/
|
|
58
|
+
stop: () => void;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Focuses the main landmark identified by `mainId` (or the first `<main>`).
|
|
62
|
+
* When `preferHeading` is set, focuses its first `<h1>` instead if possible.
|
|
63
|
+
*
|
|
64
|
+
* @returns whether focus was moved
|
|
65
|
+
*/
|
|
66
|
+
export declare function focusMainTarget(mainId?: string, preferHeading?: boolean): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Makes client-side route changes accessible:
|
|
69
|
+
*
|
|
70
|
+
* - Moves focus to the new page's `<h1>` inside the main landmark, or the
|
|
71
|
+
* landmark itself, so keyboard and screen reader users start at the new
|
|
72
|
+
* content instead of the link they activated.
|
|
73
|
+
* - Announces the new page title in a polite live region.
|
|
74
|
+
*
|
|
75
|
+
* The initial page load, failed navigations, and navigations within the same
|
|
76
|
+
* page are ignored. Focus isn't moved when the route has a hash or when the
|
|
77
|
+
* new page already moved focus into its main content (for example, with
|
|
78
|
+
* autofocus).
|
|
79
|
+
*
|
|
80
|
+
* Call once, typically in the root `App.vue` setup:
|
|
81
|
+
*
|
|
82
|
+
* ```ts
|
|
83
|
+
* const router = useRouter();
|
|
84
|
+
* useRouteAnnouncer(router);
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function useRouteAnnouncer<L extends RouteAnnouncerLocation = RouteAnnouncerLocation>(router: RouteAnnouncerRouter<L>, options?: UseRouteAnnouncerOptions<L>): UseRouteAnnouncerReturn;
|