@stenajs-webui/elements 23.21.10 → 23.21.12
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/ui/banners/hooks/UseHasBeenVisible.d.ts +15 -0
- package/dist/components/ui/banners/validation-banner/ValidationBanner.d.ts +32 -1
- package/dist/components/ui/banners/validation-result-list-banner/ValidationResultListBanner.d.ts +82 -0
- package/dist/components/ui/banners/validation-result-list-banner/__tests__/ValidationResultListBanner.test.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +1432 -1416
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Latches to true the first time the banner is visible, and stays true.
|
|
3
|
+
*
|
|
4
|
+
* The validation banners use this to tell "not visible yet" apart from "not
|
|
5
|
+
* visible any more". Only the second one is a validation that went from
|
|
6
|
+
* failing to passing, and only then is there something to announce.
|
|
7
|
+
*
|
|
8
|
+
* The state is updated during render rather than in an effect, so that the
|
|
9
|
+
* value is settled in the same commit that hides the banner. That is the
|
|
10
|
+
* commit where the resolved text has to be added to the live region.
|
|
11
|
+
*
|
|
12
|
+
* The value is only read while the banner is hidden, and by then it has been
|
|
13
|
+
* set by an earlier render, so it is never stale where it matters.
|
|
14
|
+
*/
|
|
15
|
+
export declare const useHasBeenVisible: (visible: boolean) => boolean;
|
|
@@ -10,6 +10,31 @@ export interface ValidationBannerProps extends Omit<BannerProps, "aria-live"> {
|
|
|
10
10
|
* result.
|
|
11
11
|
*/
|
|
12
12
|
visible: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* What to announce once the validation result goes away, such as
|
|
15
|
+
* "All passenger details are valid.", or null to stay silent.
|
|
16
|
+
*
|
|
17
|
+
* Screen readers announce content that is added to a live region, but say
|
|
18
|
+
* nothing when content is removed, so hiding the banner is silent on its
|
|
19
|
+
* own. This text takes the place of the banner, which turns the resolved
|
|
20
|
+
* validation into an addition, and lets it say the true thing rather than
|
|
21
|
+
* repeating the error at the moment the error is gone.
|
|
22
|
+
*
|
|
23
|
+
* It is only read by screen readers, and never shown, so a form that becomes
|
|
24
|
+
* valid looks exactly as it did before. Nothing is announced until the banner
|
|
25
|
+
* has been visible at least once, so a form that is valid from the start
|
|
26
|
+
* stays quiet.
|
|
27
|
+
*
|
|
28
|
+
* The text is announced whenever the banner goes away, whatever the reason.
|
|
29
|
+
* A banner that the user can dismiss without having fixed anything needs a
|
|
30
|
+
* text that is true in that case too, or null.
|
|
31
|
+
*
|
|
32
|
+
* Required, so that every validation result has to take a stand on what is
|
|
33
|
+
* announced once it passes. Pass null when there is nothing to announce,
|
|
34
|
+
* such as when the banner is always visible, when it is dismissed rather
|
|
35
|
+
* than resolved, or when one summary banner speaks for a whole form.
|
|
36
|
+
*/
|
|
37
|
+
resolvedText: string | null;
|
|
13
38
|
/**
|
|
14
39
|
* How eagerly assistive technology should announce the validation result.
|
|
15
40
|
*
|
|
@@ -26,10 +51,15 @@ export interface ValidationBannerProps extends Omit<BannerProps, "aria-live"> {
|
|
|
26
51
|
*
|
|
27
52
|
* The live region is rendered at all times, also while the validation passes,
|
|
28
53
|
* since screen readers only announce updates to live regions that already
|
|
29
|
-
* exist. Only the
|
|
54
|
+
* exist. Only the contents are added and removed, and the region adds no gap of
|
|
30
55
|
* its own, so keeping it mounted next to a form field does not affect the
|
|
31
56
|
* layout.
|
|
32
57
|
*
|
|
58
|
+
* The region holds the banner while the validation fails, and `resolvedText`
|
|
59
|
+
* once it passes. Since the region alternates between two different texts, and
|
|
60
|
+
* both of them arrive as additions, every change is announced: the failure, the
|
|
61
|
+
* recovery, and a second failure with the same text as the first.
|
|
62
|
+
*
|
|
33
63
|
* All Banner props are forwarded, so the banner is styled and structured
|
|
34
64
|
* exactly like a Banner.
|
|
35
65
|
*
|
|
@@ -45,6 +75,7 @@ export interface ValidationBannerProps extends Omit<BannerProps, "aria-live"> {
|
|
|
45
75
|
* variant={"error"}
|
|
46
76
|
* headerText={t("validation.email.header")}
|
|
47
77
|
* text={t("validation.email.text")}
|
|
78
|
+
* resolvedText={t("validation.email.resolved")}
|
|
48
79
|
* />
|
|
49
80
|
* </Column>
|
|
50
81
|
*/
|
package/dist/components/ui/banners/validation-result-list-banner/ValidationResultListBanner.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { LivelyPoliteness } from "@stenajs-webui/core";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { ResultListBannerProps, ResultListBannerState } from "../result-list-banner/ResultListBanner";
|
|
4
|
+
export interface ValidationResultListBannerProps extends Omit<ResultListBannerProps, "bannerState" | "aria-live"> {
|
|
5
|
+
/**
|
|
6
|
+
* The result to show, or undefined when there is no result to show.
|
|
7
|
+
*
|
|
8
|
+
* Unlike ValidationBanner, there is no separate visible prop, since the
|
|
9
|
+
* whole content of the banner is this one prop. It is the same value that
|
|
10
|
+
* useResultListBannerState holds, and it is undefined exactly when the
|
|
11
|
+
* banner should be hidden.
|
|
12
|
+
*/
|
|
13
|
+
bannerState: ResultListBannerState | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* What to announce once the validation result goes away, such as
|
|
16
|
+
* "All bookings were saved.", or null to stay silent.
|
|
17
|
+
*
|
|
18
|
+
* Screen readers announce content that is added to a live region, but say
|
|
19
|
+
* nothing when content is removed, so clearing the result is silent on its
|
|
20
|
+
* own. This text takes the place of the banner, which turns the resolved
|
|
21
|
+
* validation into an addition, and lets it say the true thing rather than
|
|
22
|
+
* repeating the errors at the moment the errors are gone.
|
|
23
|
+
*
|
|
24
|
+
* It is only read by screen readers, and never shown, so a form that becomes
|
|
25
|
+
* valid looks exactly as it did before. Nothing is announced until the banner
|
|
26
|
+
* has been visible at least once, so a form that is valid from the start
|
|
27
|
+
* stays quiet.
|
|
28
|
+
*
|
|
29
|
+
* The text is announced whenever the banner goes away, whatever the reason.
|
|
30
|
+
* A banner that the user can dismiss without having fixed anything needs a
|
|
31
|
+
* text that is true in that case too, or null.
|
|
32
|
+
*
|
|
33
|
+
* Required, so that every validation result has to take a stand on what is
|
|
34
|
+
* announced once it passes. Pass null when there is nothing to announce,
|
|
35
|
+
* such as when the banner is always visible, when it is dismissed rather
|
|
36
|
+
* than resolved, or when one summary banner speaks for a whole form.
|
|
37
|
+
*/
|
|
38
|
+
resolvedText: string | null;
|
|
39
|
+
/**
|
|
40
|
+
* How eagerly assistive technology should announce the validation result.
|
|
41
|
+
*
|
|
42
|
+
* - `polite` waits until the user is idle.
|
|
43
|
+
* - `assertive` interrupts the user, and should be used sparingly.
|
|
44
|
+
* - `off` stops announcing results, without removing the region.
|
|
45
|
+
*
|
|
46
|
+
* @default "polite"
|
|
47
|
+
*/
|
|
48
|
+
politeness?: LivelyPoliteness;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A ResultListBanner inside an ARIA live region, for validation results that
|
|
52
|
+
* come and go.
|
|
53
|
+
*
|
|
54
|
+
* The live region is rendered at all times, also while there is no result,
|
|
55
|
+
* since screen readers only announce updates to live regions that already
|
|
56
|
+
* exist. Only the contents are added and removed, and the region adds no gap of
|
|
57
|
+
* its own, so keeping it mounted next to a form does not affect the layout.
|
|
58
|
+
*
|
|
59
|
+
* The region holds the banner while there is a result, and `resolvedText` once
|
|
60
|
+
* the result is cleared. Since the region alternates between two different
|
|
61
|
+
* texts, and both of them arrive as additions, every change is announced: the
|
|
62
|
+
* failure, the recovery, and a second failure with the same texts as the first.
|
|
63
|
+
*
|
|
64
|
+
* All ResultListBanner props are forwarded, so the banner is styled and
|
|
65
|
+
* structured exactly like a ResultListBanner.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* const { bannerState, setBannerResultWithErrors, clearBannerResult } =
|
|
69
|
+
* useResultListBannerState();
|
|
70
|
+
*
|
|
71
|
+
* return (
|
|
72
|
+
* <Column gap={2}>
|
|
73
|
+
* <ValidationResultListBanner
|
|
74
|
+
* bannerState={bannerState}
|
|
75
|
+
* variant={"error"}
|
|
76
|
+
* resolvedText={t("validation.bookings.resolved")}
|
|
77
|
+
* />
|
|
78
|
+
* <PrimaryButton label={t("save")} onClick={onSave} />
|
|
79
|
+
* </Column>
|
|
80
|
+
* );
|
|
81
|
+
*/
|
|
82
|
+
export declare const ValidationResultListBanner: React.FC<ValidationResultListBannerProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./components/ui/banners/banner/Banner";
|
|
|
14
14
|
export * from "./components/ui/banners/result-list-banner/ResultListBanner";
|
|
15
15
|
export * from "./components/ui/banners/result-list-banner/hooks/UseResultListBannerState";
|
|
16
16
|
export * from "./components/ui/banners/validation-banner/ValidationBanner";
|
|
17
|
+
export * from "./components/ui/banners/validation-result-list-banner/ValidationResultListBanner";
|
|
17
18
|
export * from "./components/ui/result-list/ResultList";
|
|
18
19
|
export * from "./components/ui/result-list/ResultListRow";
|
|
19
20
|
export * from "./components/ui/spinner/Spinner";
|