@abgov/web-components 1.37.1-alpha.2 → 1.37.1-alpha.4
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/common/breakpoints.d.ts +2 -0
- package/common/context-store.d.ts +10 -0
- package/common/no-scroll.d.ts +8 -0
- package/common/styling.d.ts +18 -0
- package/common/types.d.ts +3 -0
- package/common/urls.d.ts +2 -0
- package/common/utils.d.ts +41 -0
- package/common/validators.d.ts +1 -0
- package/index.js +3995 -3954
- package/package.json +1 -1
- package/types/relay-types.d.ts +150 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface Message {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
type: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ContextStore {
|
|
6
|
+
subscribe: (cb: (msg: Message) => void) => void;
|
|
7
|
+
notify: (msg: Message) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function getContext(name: string): ContextStore;
|
|
10
|
+
export declare function deleteContext(name: string): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type NumericSpacing = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10";
|
|
2
|
+
type TShirtSpacing = "none" | "3xs" | "2xs" | "xs" | "s" | "m" | "l" | "xl" | "2xl" | "3xl" | "4xl";
|
|
3
|
+
export type Spacing = NumericSpacing | TShirtSpacing | null;
|
|
4
|
+
/**
|
|
5
|
+
* import type { Spacing } from "../../common/types";
|
|
6
|
+
* import { calculateMargin } from "../../common/types";
|
|
7
|
+
*
|
|
8
|
+
* export let mt: Spacing = null;
|
|
9
|
+
* export let mr: Spacing = null;
|
|
10
|
+
* export let mb: Spacing = null;
|
|
11
|
+
* export let ml: Spacing = null;
|
|
12
|
+
*
|
|
13
|
+
* // add the following style attribute to the root element
|
|
14
|
+
* style={calculateMargin(mt, mr, mb, ml)}
|
|
15
|
+
*/
|
|
16
|
+
export declare function calculateMargin(mt: Spacing, mr: Spacing, mb: Spacing, ml: Spacing): string;
|
|
17
|
+
export declare function injectCss(el: HTMLElement, rootSelector: string, css: Record<string, string | number>, media?: string): void;
|
|
18
|
+
export {};
|
package/common/urls.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare function styles(...css: (string | boolean)[]): string;
|
|
2
|
+
export declare function style(name: string, value: string | number): string;
|
|
3
|
+
export declare const msg: {
|
|
4
|
+
receive: typeof receive;
|
|
5
|
+
relay: typeof relay;
|
|
6
|
+
};
|
|
7
|
+
export declare function receive(el: HTMLElement | Element | null | undefined, handler: (action: string, data: unknown, event: Event) => void): () => void;
|
|
8
|
+
export declare function relay<T>(el: HTMLElement | Element | null | undefined, eventName: string, data?: T, opts?: {
|
|
9
|
+
bubbles?: boolean;
|
|
10
|
+
cancelable?: boolean;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}): void;
|
|
13
|
+
export declare function dispatch<T>(el: HTMLElement | Element | null | undefined, eventName: string, detail?: T, opts?: {
|
|
14
|
+
bubbles?: boolean;
|
|
15
|
+
cancelable?: boolean;
|
|
16
|
+
timeout?: number;
|
|
17
|
+
}): void;
|
|
18
|
+
export declare function getSlottedChildren(rootEl?: HTMLElement, parentTestSelector?: string): Element[];
|
|
19
|
+
export declare function toBoolean(value: string): boolean;
|
|
20
|
+
export declare function fromBoolean(value: boolean): string;
|
|
21
|
+
export declare function isValidDate(d: Date): boolean;
|
|
22
|
+
export declare function validateRequired(componentName: string, props: Record<string, unknown>): void;
|
|
23
|
+
export declare function typeValidator(message: string, values: string[], opts?: boolean | {
|
|
24
|
+
required?: boolean;
|
|
25
|
+
deprecated?: string[];
|
|
26
|
+
}): [string[], (value: string | null) => void];
|
|
27
|
+
export declare function getTimestamp(val?: Date): string;
|
|
28
|
+
export declare function pluralize(word: string, count: number): string;
|
|
29
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
30
|
+
export declare function generateRandomId(): string;
|
|
31
|
+
export declare function padLeft(value: string | number, len: number, padWith: string | number): string;
|
|
32
|
+
export declare function performOnce(timeoutId: any, action: () => void, delay?: number): any;
|
|
33
|
+
export declare function ensureSlotExists(el: HTMLElement): void;
|
|
34
|
+
export declare function getQueryParams(url: string | URL): Record<string, string>;
|
|
35
|
+
export declare function getQueryParam(url: string | URL, key: string): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a temporary screen reader announcement using aria-live
|
|
38
|
+
* @param text The text to announce to screen readers
|
|
39
|
+
* @param duration How long to keep the announcer element in the DOM (in milliseconds)
|
|
40
|
+
*/
|
|
41
|
+
export declare function announceToScreenReader(text: string, duration?: number): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidDimension(value: string): boolean;
|