@fluid-topics/ft-wc-utils 1.3.25 → 1.3.26
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,12 @@
|
|
|
1
|
+
import { FtLitElement } from "./FtLitElement";
|
|
2
|
+
import { Constructor } from "./generic-types";
|
|
3
|
+
type AriaNotificationMessageType = string | {
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
export type FtLitElementWithAriaNotificationInterface = {
|
|
7
|
+
sendAriaNotificationIfVisible(message?: AriaNotificationMessageType): void;
|
|
8
|
+
sendAriaNotification(message?: AriaNotificationMessageType): void;
|
|
9
|
+
};
|
|
10
|
+
type FtLitElementWithAriaNotificationType<T extends Constructor<FtLitElement>> = T & Constructor<FtLitElementWithAriaNotificationInterface>;
|
|
11
|
+
export declare function withAriaNotification<T extends Constructor<FtLitElement>>(Class: T): FtLitElementWithAriaNotificationType<T>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FtNotificationEvent } from "./events";
|
|
2
|
+
export function withAriaNotification(Class) {
|
|
3
|
+
class FtLitElementWithAriaNotificationClass extends Class {
|
|
4
|
+
sendAriaNotificationIfVisible(message) {
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
if (this.checkVisibility()) {
|
|
7
|
+
this.sendAriaNotification(message);
|
|
8
|
+
}
|
|
9
|
+
}, 20);
|
|
10
|
+
}
|
|
11
|
+
sendAriaNotification(message) {
|
|
12
|
+
message = typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
13
|
+
if (message) {
|
|
14
|
+
this.dispatchEvent(new FtNotificationEvent({
|
|
15
|
+
type: "aria",
|
|
16
|
+
message: message,
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return FtLitElementWithAriaNotificationClass;
|
|
22
|
+
}
|
package/build/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Constructor } from "./generic-types";
|
|
2
|
-
export type FtNotificationType = "info" | "warning" | "error";
|
|
2
|
+
export type FtNotificationType = "info" | "warning" | "error" | "aria";
|
|
3
3
|
export interface FtNotificationEventDetail {
|
|
4
4
|
type: FtNotificationType;
|
|
5
5
|
message: string;
|