@fluid-topics/ft-wc-utils 1.3.24 → 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.
- package/build/DateFormatter.d.ts +3 -2
- package/build/DateFormatter.js +12 -3
- package/build/FtLitElementWithAriaNotification.d.ts +12 -0
- package/build/FtLitElementWithAriaNotification.js +22 -0
- package/build/events.d.ts +1 -1
- package/build/globals.min.js +13 -13
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/package.json +3 -3
package/build/DateFormatter.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare global {
|
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
7
|
export declare class DateFormatter {
|
|
8
|
-
static format(date: string, locale: string, longDateFormat: boolean, dateTimeFormat: boolean): string;
|
|
9
|
-
private static
|
|
8
|
+
static format(date: string | Date, locale: string, longDateFormat: boolean, dateTimeFormat: boolean): string;
|
|
9
|
+
private static getMomentDateFormat;
|
|
10
|
+
private static getIntlDateTime;
|
|
10
11
|
}
|
package/build/DateFormatter.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export class DateFormatter {
|
|
2
2
|
static format(date, locale, longDateFormat, dateTimeFormat) {
|
|
3
3
|
if (!window.moment) {
|
|
4
|
-
return date;
|
|
4
|
+
return this.getIntlDateTime(date, locale, longDateFormat, dateTimeFormat);
|
|
5
5
|
}
|
|
6
|
-
return window.moment(date).locale(locale).format(this.
|
|
6
|
+
return window.moment(date).locale(locale).format(this.getMomentDateFormat(longDateFormat, dateTimeFormat));
|
|
7
7
|
}
|
|
8
|
-
static
|
|
8
|
+
static getMomentDateFormat(longDateFormat, dateTimeFormat) {
|
|
9
9
|
if (longDateFormat) {
|
|
10
10
|
if (dateTimeFormat) {
|
|
11
11
|
return "lll";
|
|
@@ -19,4 +19,13 @@ export class DateFormatter {
|
|
|
19
19
|
return "L";
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
+
static getIntlDateTime(date, locale, longDateFormat, dateTimeFormat) {
|
|
23
|
+
const parsedDate = typeof date === "string" ? new Date(date) : date;
|
|
24
|
+
const datePart = (new Intl.DateTimeFormat(locale, { dateStyle: longDateFormat ? "medium" : "short" })).format(parsedDate);
|
|
25
|
+
if (!dateTimeFormat) {
|
|
26
|
+
return datePart;
|
|
27
|
+
}
|
|
28
|
+
const timePart = (new Intl.DateTimeFormat(locale, { timeStyle: "short" })).format(parsedDate);
|
|
29
|
+
return `${datePart} ${timePart}`;
|
|
30
|
+
}
|
|
22
31
|
}
|
|
@@ -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;
|