@stenajs-webui/elements 23.21.11 → 23.21.13

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.
@@ -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 banner is added and removed, and the region adds no gap of
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
  */
@@ -11,6 +11,31 @@ export interface ValidationResultListBannerProps extends Omit<ResultListBannerPr
11
11
  * banner should be hidden.
12
12
  */
13
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;
14
39
  /**
15
40
  * How eagerly assistive technology should announce the validation result.
16
41
  *
@@ -28,9 +53,14 @@ export interface ValidationResultListBannerProps extends Omit<ResultListBannerPr
28
53
  *
29
54
  * The live region is rendered at all times, also while there is no result,
30
55
  * since screen readers only announce updates to live regions that already
31
- * exist. Only the banner is added and removed, and the region adds no gap of
56
+ * exist. Only the contents are added and removed, and the region adds no gap of
32
57
  * its own, so keeping it mounted next to a form does not affect the layout.
33
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
+ *
34
64
  * All ResultListBanner props are forwarded, so the banner is styled and
35
65
  * structured exactly like a ResultListBanner.
36
66
  *
@@ -43,6 +73,7 @@ export interface ValidationResultListBannerProps extends Omit<ResultListBannerPr
43
73
  * <ValidationResultListBanner
44
74
  * bannerState={bannerState}
45
75
  * variant={"error"}
76
+ * resolvedText={t("validation.bookings.resolved")}
46
77
  * />
47
78
  * <PrimaryButton label={t("save")} onClick={onSave} />
48
79
  * </Column>