@tylertech/forge-core 2.0.0

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.
Files changed (67) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +32 -0
  3. package/esm/a11y/a11y.js +17 -0
  4. package/esm/a11y/index.js +1 -0
  5. package/esm/constants/date-constants.js +52 -0
  6. package/esm/constants/index.js +1 -0
  7. package/esm/custom-elements/component-utils.js +262 -0
  8. package/esm/custom-elements/decorators/custom-element.js +52 -0
  9. package/esm/custom-elements/decorators/foundation-property.js +147 -0
  10. package/esm/custom-elements/decorators/index.js +2 -0
  11. package/esm/custom-elements/index.js +2 -0
  12. package/esm/events/event-aware.js +34 -0
  13. package/esm/events/index.js +1 -0
  14. package/esm/index.js +13 -0
  15. package/esm/message-list/index.js +2 -0
  16. package/esm/message-list/message-list-entry.js +10 -0
  17. package/esm/message-list/message-list.js +112 -0
  18. package/esm/scroll/index.js +2 -0
  19. package/esm/scroll/scroll-axis-observer.js +114 -0
  20. package/esm/scroll/scroll-types.js +14 -0
  21. package/esm/services/index.js +1 -0
  22. package/esm/services/service-adapter.js +12 -0
  23. package/esm/utils/a11y.js +17 -0
  24. package/esm/utils/clipboard.js +38 -0
  25. package/esm/utils/dom-utils.js +780 -0
  26. package/esm/utils/event-utils.js +30 -0
  27. package/esm/utils/http-utils.js +26 -0
  28. package/esm/utils/index.js +11 -0
  29. package/esm/utils/item-manager.js +82 -0
  30. package/esm/utils/object-utils.js +101 -0
  31. package/esm/utils/platform.js +60 -0
  32. package/esm/utils/position-utils.js +59 -0
  33. package/esm/utils/string-utils.js +12 -0
  34. package/esm/utils/utils.js +261 -0
  35. package/package.json +19 -0
  36. package/typings/a11y/a11y.d.ts +5 -0
  37. package/typings/a11y/index.d.ts +1 -0
  38. package/typings/constants/date-constants.d.ts +6 -0
  39. package/typings/constants/index.d.ts +1 -0
  40. package/typings/custom-elements/component-utils.d.ts +125 -0
  41. package/typings/custom-elements/decorators/custom-element.d.ts +21 -0
  42. package/typings/custom-elements/decorators/foundation-property.d.ts +20 -0
  43. package/typings/custom-elements/decorators/index.d.ts +2 -0
  44. package/typings/custom-elements/index.d.ts +13 -0
  45. package/typings/events/event-aware.d.ts +16 -0
  46. package/typings/events/index.d.ts +1 -0
  47. package/typings/index.d.ts +13 -0
  48. package/typings/message-list/index.d.ts +2 -0
  49. package/typings/message-list/message-list-entry.d.ts +9 -0
  50. package/typings/message-list/message-list.d.ts +54 -0
  51. package/typings/scroll/index.d.ts +2 -0
  52. package/typings/scroll/scroll-axis-observer.d.ts +44 -0
  53. package/typings/scroll/scroll-types.d.ts +28 -0
  54. package/typings/services/index.d.ts +1 -0
  55. package/typings/services/service-adapter.d.ts +25 -0
  56. package/typings/utils/a11y.d.ts +2 -0
  57. package/typings/utils/clipboard.d.ts +2 -0
  58. package/typings/utils/dom-utils.d.ts +254 -0
  59. package/typings/utils/event-utils.d.ts +10 -0
  60. package/typings/utils/http-utils.d.ts +5 -0
  61. package/typings/utils/index.d.ts +11 -0
  62. package/typings/utils/item-manager.d.ts +42 -0
  63. package/typings/utils/object-utils.d.ts +43 -0
  64. package/typings/utils/platform.d.ts +26 -0
  65. package/typings/utils/position-utils.d.ts +56 -0
  66. package/typings/utils/string-utils.d.ts +6 -0
  67. package/typings/utils/utils.d.ts +104 -0
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Recursively defines a component as a custom elements and all of its dependencies.
3
+ * @param component The component to import.
4
+ */
5
+ export declare function defineCustomElement(component: any): void;
6
+ /**
7
+ * Defines the specified custom element components.
8
+ * @param {any[]} components The components to register.
9
+ */
10
+ export declare function defineCustomElements(components: any[]): void;
11
+ /**
12
+ * Attempts to define the provided custom element name/constructor if not already defined.
13
+ * @param name The name of the custom element to define.
14
+ * @param ctor The custom element constructor.
15
+ */
16
+ export declare function tryDefine(name: string, ctor: CustomElementConstructor, options?: ElementDefinitionOptions | undefined): void;
17
+ /**
18
+ * Useful when capturing the value of a unupgraded component during the `connectedCallback` upon upgrade.
19
+ *
20
+ * More information here:
21
+ * https://developers.google.com/web/fundamentals/architecture/building-components/best-practices#lazy-properties
22
+ *
23
+ * @param property
24
+ */
25
+ export declare function upgradeProperty<T extends HTMLElement>(instance: T, property: keyof T): void;
26
+ /**
27
+ * Traverses up the DOM tree starting from the provided component element to find the specified parent.
28
+ * @param {HTMLElement} component The starting HTMLElement.
29
+ * @param {string} parentTagName The parent tag name we are searching for.
30
+ */
31
+ export declare function requireParent<T extends HTMLElement>(component: HTMLElement, parentTagName: string): T | null;
32
+ /**
33
+ * Creates a template element from a string.
34
+ * @param template The template HTML string.
35
+ */
36
+ export declare function parseTemplateString(template: string): HTMLTemplateElement;
37
+ /**
38
+ * Attaches a template to the given web component instance light DOM.
39
+ * @param {T} componentInstance A component instance.
40
+ * @param {string} template The template HTML string.
41
+ */
42
+ export declare function attachLightTemplate<T extends HTMLElement>(componentInstance: T, template: string): void;
43
+ /**
44
+ * Attaches a shadow root to the given web component instance.
45
+ * @param {T} componentInstance A component instance.
46
+ * @param {string} elementName The name of the element the shadow root is to be attached to.
47
+ * @param {string} template The shadow root template HTML string.
48
+ * @param {string | string[]} styles The shadow root styles string to be encapsulated by this shadow root.
49
+ * @param {boolean} [delegatesFocus=false] Should the component delagate focus.
50
+ */
51
+ export declare function attachShadowTemplate<T extends HTMLElement>(componentInstance: T, template: string, styles?: string | string[], delegatesFocus?: boolean): void;
52
+ /**
53
+ * Replaces the template of an existing shadow root with the provided template.
54
+ * @param {T} componentInstance A component instance.
55
+ * @param {string} elementName The name of the element the shadow root is to be attached to.
56
+ * @param {string} template The shadow root template HTML string.
57
+ * @param {string | string[]} styles The shadow root styles string to be encapsulated by this shadow root.
58
+ */
59
+ export declare function replaceShadowTemplate<T extends HTMLElement>(componentInstance: T, template: string, styles?: string | string[]): void;
60
+ /**
61
+ * Creates and prepares an HTML template element for rendering within a shadow root.
62
+ * @param {string} elementName The name of the element the shadow root is to be attached to.
63
+ * @param {string} template The shadow root template HTML string.
64
+ * @param {string | string[]} styles The shadow root styles string to be encapsulated by this shadow root.
65
+ */
66
+ export declare function prepareShadowTemplate(template: string, styles?: string | string[]): HTMLTemplateElement;
67
+ /**
68
+ * Appends a template to the provided components shadow root.
69
+ * @param {T} componentInstance A component instance.
70
+ * @param {HTMLTemplateElement} templateElement A template element to be cloned.
71
+ */
72
+ export declare function setShadowTemplate<T extends HTMLElement>(componentInstance: T, templateElement: HTMLTemplateElement): void;
73
+ /**
74
+ * Copies style rules from the provided document stylesheets collection to the provided shadow root stylesheet.
75
+ * @param {Document} fromDocument The document to find the style sheets in.
76
+ * @param {ShadowRoot} shadowRoot The shadow root that contains the stylesheet to copy the rules to.
77
+ * @param {IStyleSheetDescriptor[]} styleSheetDescriptors A collection of style sheet predicates.
78
+ * @param {CSSStyleSheet} shadowStyleSheet The shadow root stylesheet to copy the style rules to.
79
+ */
80
+ export declare function provideDocumentStyles(fromDocument: Document, shadowRoot: ShadowRoot, documentStyleSheets: Array<string | IStyleSheetDescriptor>, shadowStyleSheet: CSSStyleSheet): void;
81
+ /**
82
+ * Gets an HTML element using a query selector from the provided components` shadow root.
83
+ * @param {HTMLElement} componentInstance The component instance that contains a shadow root.
84
+ * @param {string} selector The selector to be passed to `querySelector`.
85
+ */
86
+ export declare function getShadowElement<T extends HTMLElement>(componentInstance: T, selector: string): HTMLElement;
87
+ /**
88
+ * Gets an HTML element using a query selector from the provided components` light DOM.
89
+ * @param {HTMLElement} componentInstance The component instance.
90
+ * @param {string} selector The selector to be passed to `querySelector`.
91
+ */
92
+ export declare function getLightElement<T extends HTMLElement>(componentInstance: T, selector: string): HTMLElement;
93
+ /**
94
+ * Creates and dispatches a cross-browser `CustomEvent` with the provided type and data.
95
+ * @param {string} type
96
+ * @param {any} data
97
+ * @param {boolean=} bubble
98
+ */
99
+ export declare function emitEvent<T extends HTMLElement>(component: T, type: string, data: any, bubble?: boolean, cancelable?: boolean): boolean;
100
+ /**
101
+ * Replaces the provided element with a placeholder comment and vice versa.
102
+ * Useful for hiding and showing elements while retaining their location in the DOM.
103
+ * @param {boolean} isVisible Whether the element is visible or not.
104
+ * @param {string} elementName The element tag name.
105
+ * @param {string} selector The selector used to find the element
106
+ * @param {Node} element The element
107
+ * @param {Comment} placeholder The existing placeholder
108
+ */
109
+ export declare function toggleElementPlaceholder(component: HTMLElement, isVisible: boolean, elementName: string, selector: string, element: Node, placeholder: Comment): Comment;
110
+ /**
111
+ * Walks up the tree starting a specific node and stops when it finds a shadow root.
112
+ * @param {Node} node The node to start searching from.
113
+ * @returns {ShadowRoot | null} The closest shadow root ancestor, or null if not inside a shadow root.
114
+ */
115
+ export declare function getClosestShadowRoot(node: Node): ShadowRoot | null;
116
+ /**
117
+ * Finds the closest element up the tree from a starting element across shadow boundaries.
118
+ * @param selector The CSS selector for the element to find.
119
+ * @param startElement The element to start finding from.
120
+ */
121
+ export declare function closestElement(selector: string, startElement: Element): Element | null;
122
+ export interface IStyleSheetDescriptor {
123
+ name: string;
124
+ selectorFilter?: string;
125
+ }
@@ -0,0 +1,21 @@
1
+ declare global {
2
+ interface Window {
3
+ __forgeFlags__autoDefine: any;
4
+ }
5
+ }
6
+ export interface ICustomElementConfig {
7
+ /** The name of the custom element tag. */
8
+ name: string;
9
+ /** Components that are dependencies of this component */
10
+ dependencies?: any[];
11
+ /** Configures if the element will be automatically defined in the custom element registry. Default is `true` */
12
+ define?: boolean;
13
+ }
14
+ export declare const CUSTOM_ELEMENT_NAME_PROPERTY = "_customElementName";
15
+ export declare const CUSTOM_ELEMENT_DEPENDENCIES_PROPERTY = "_customElementDependencies";
16
+ /**
17
+ * This decorator is intended to be used on classes that extend `HTMLElement` to
18
+ * extend/modify the behavior of a custom element.
19
+ * @param {ICustomElementConfig} [config={}] The custom element configuration.
20
+ */
21
+ export declare function CustomElement({ name, dependencies, define }: ICustomElementConfig): any;
@@ -0,0 +1,20 @@
1
+ export interface IFoundationPropertyOptions<T> {
2
+ /**
3
+ * Allow Binding to a different naming convention in the foundation
4
+ * @example FoundationProperty({name: '_foo'}) foo;
5
+ */
6
+ name?: string;
7
+ /**
8
+ * When false, skips calling the foundation property setter
9
+ * @default true
10
+ * @example FoundationProperty({set: true}) foo;
11
+ */
12
+ set?: boolean;
13
+ /**
14
+ * When false, skips calling the foundation property getter
15
+ * @default true
16
+ * @example FoundationProperty({get: true}) foo;
17
+ */
18
+ get?: boolean;
19
+ }
20
+ export declare function FoundationProperty<T>(options?: IFoundationPropertyOptions<T>): any;
@@ -0,0 +1,2 @@
1
+ export * from './custom-element';
2
+ export * from './foundation-property';
@@ -0,0 +1,13 @@
1
+ export * from './decorators';
2
+ export * from './component-utils';
3
+ export interface ICustomElement extends HTMLElement {
4
+ initializedCallback?: () => void;
5
+ connectedCallback?: () => void;
6
+ disconnectedCallback?: () => void;
7
+ attributeChangedCallback?: (name: string, oldValue: string, newValue: string) => void;
8
+ }
9
+ export interface ICustomElementFoundation {
10
+ initialize?: () => void;
11
+ connect?: () => void;
12
+ disconnect?: () => void;
13
+ }
@@ -0,0 +1,16 @@
1
+ export interface IEvent<T> {
2
+ type: string;
3
+ data: T | undefined;
4
+ }
5
+ export interface IEventAware {
6
+ hasListeners(type?: string): boolean;
7
+ addListener(type: string, listener: (evt: IEvent<any>) => void): void;
8
+ removeListener(type: string, listener: (evt: IEvent<any>) => void): void;
9
+ }
10
+ export declare abstract class EventAware implements IEventAware {
11
+ private _listenerMap;
12
+ protected _emit<T>(type: string, data?: T): void;
13
+ hasListeners(type?: string): boolean;
14
+ addListener(type: string, listener: (evt: IEvent<any>) => void): void;
15
+ removeListener(type: string, listener: (evt: IEvent<any>) => void): void;
16
+ }
@@ -0,0 +1 @@
1
+ export * from './event-aware';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2022 Tyler Technologies, Inc.
4
+ * License: Apache-2.0
5
+ */
6
+ export * from './a11y';
7
+ export * from './constants';
8
+ export * from './custom-elements';
9
+ export * from './events';
10
+ export * from './message-list';
11
+ export * from './scroll';
12
+ export * from './services';
13
+ export * from './utils';
@@ -0,0 +1,2 @@
1
+ export * from './message-list-entry';
2
+ export * from './message-list';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Represents a single message list entry containing a string message and its identifier.
3
+ */
4
+ export declare class MessageListEntry<T> {
5
+ message: string;
6
+ identifier: T;
7
+ originalMessage: string;
8
+ constructor(message: string, identifier: T);
9
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Represents a message list of any type. This class can be used to attach a string message to
3
+ * a generic identifier.
4
+ */
5
+ export declare class MessageList<T> {
6
+ private _messages;
7
+ private _useAutoEllipsis;
8
+ /**
9
+ * True if ellipsis management occurs automatically. Default is true.
10
+ */
11
+ get useAutoEllipsis(): boolean;
12
+ set useAutoEllipsis(value: boolean);
13
+ /**
14
+ * The message that is made up of all messages in the entries.
15
+ */
16
+ message: string;
17
+ constructor(useAutoEllipsis?: boolean);
18
+ /**
19
+ * Adds a message to the entry map.
20
+ * @param {string} message The message string.
21
+ * @param {T} identifier The message identifier.
22
+ * @returns {MessageList<T>} A reference to `this` for chaining.
23
+ */
24
+ add(message: string, identifier: T): MessageList<T>;
25
+ /**
26
+ * Removes a message using the provided identifier.
27
+ * @param {T} identifier The message identifier.
28
+ * @returns {MessageList<T>} A reference to `this` for chaining.
29
+ */
30
+ remove(identifier: T): MessageList<T>;
31
+ /**
32
+ * Updates an existing message value.
33
+ * @param {string} message The message string.
34
+ * @param {T} identifier The existing message identifier.
35
+ * @returns {MessageList<T>} A reference to `this` for chaining.
36
+ */
37
+ update(message: string, identifier: T): MessageList<T>;
38
+ /**
39
+ * Gets the number of messages in the list.
40
+ * @returns {number}
41
+ */
42
+ get messageCount(): number;
43
+ /**
44
+ * Resets the message list to it's original state and removes all messages.
45
+ */
46
+ reset(): void;
47
+ /**
48
+ * Determines if a message with the provided identifier exists.
49
+ * @param {T} identifier The message identifier.
50
+ */
51
+ hasMessage(identifier: T): boolean;
52
+ private _updateMessage;
53
+ private _getMessageIndex;
54
+ }
@@ -0,0 +1,2 @@
1
+ export * from './scroll-axis-observer';
2
+ export * from './scroll-types';
@@ -0,0 +1,44 @@
1
+ import { EventAware, IEventAware } from '../events/event-aware';
2
+ import { IScrollObserverConfiguration } from './scroll-types';
3
+ export interface IScrollAxisObserver extends IEventAware {
4
+ scrollPosition: number;
5
+ isScrolled: boolean;
6
+ isScrolledStart: boolean;
7
+ isScrolledEnd: boolean;
8
+ isScrollable: boolean;
9
+ scrollSize: number;
10
+ elementSize: number;
11
+ setScrollPosition(position: number): void;
12
+ destroy(): void;
13
+ start(): void;
14
+ stop(): void;
15
+ }
16
+ /**
17
+ * Provides facilties for observing and reacting to scroll events and information on a given element.
18
+ */
19
+ export declare class ScrollAxisObserver extends EventAware implements IScrollAxisObserver {
20
+ private _element;
21
+ private _config;
22
+ private _axis;
23
+ private _scrollThreshold;
24
+ private _lastScrollPosition;
25
+ private _lastScrollTop;
26
+ private _lastScrollLeft;
27
+ private _isListening;
28
+ private _scrollListener;
29
+ constructor(_element: HTMLElement, _config?: IScrollObserverConfiguration);
30
+ destroy(): void;
31
+ start(): void;
32
+ stop(): void;
33
+ private _initialize;
34
+ private _isScrollAxis;
35
+ private _onScroll;
36
+ get scrollPosition(): number;
37
+ get isScrolled(): boolean;
38
+ get isScrolledStart(): boolean;
39
+ get isScrolledEnd(): boolean;
40
+ get isScrollable(): boolean;
41
+ get scrollSize(): number;
42
+ get elementSize(): number;
43
+ setScrollPosition(position: number): void;
44
+ }
@@ -0,0 +1,28 @@
1
+ export declare enum ScrollDirection {
2
+ Up = "up",
3
+ Down = "down",
4
+ Left = "left",
5
+ Right = "right"
6
+ }
7
+ export declare enum ScrollEvents {
8
+ Scroll = "scroll",
9
+ Scrolled = "scrolled",
10
+ ScrolledStart = "scrolled-start",
11
+ ScrolledEnd = "scrolled-end"
12
+ }
13
+ export declare type ScrollAxis = 'vertical' | 'horizontal';
14
+ export interface IScrollInfo {
15
+ direction: ScrollDirection;
16
+ position: number;
17
+ }
18
+ export interface IScrolledInfo {
19
+ axis: ScrollAxis;
20
+ isScrolled: boolean;
21
+ }
22
+ export interface IScrollObserverConfiguration {
23
+ axis?: ScrollAxis;
24
+ scrollThreshold?: number;
25
+ paused?: boolean;
26
+ throttle?: boolean;
27
+ throttleTime?: number;
28
+ }
@@ -0,0 +1 @@
1
+ export * from './service-adapter';
@@ -0,0 +1,25 @@
1
+ export interface IServiceRequestParameter {
2
+ type: ServiceRequestMethod;
3
+ path: string;
4
+ data?: any;
5
+ }
6
+ export interface IServiceAdapter {
7
+ request: ServiceRequestCallback;
8
+ cancel: ServiceCancelCallback;
9
+ }
10
+ export declare enum ServiceRequestMethod {
11
+ GET = "GET",
12
+ POST = "POST",
13
+ PUT = "PUT",
14
+ DELETE = "DELETE",
15
+ PATCH = "PATCH",
16
+ HEAD = "HEAD",
17
+ CONNECT = "CONNECT",
18
+ OPTIONS = "OPTIONS",
19
+ TRACE = "TRACE"
20
+ }
21
+ export declare type ServiceRequestCallback = (param: IServiceRequestParameter) => Promise<any>;
22
+ export declare type ServiceCancelCallback = (path: string) => Promise<void>;
23
+ export interface IServiceAware {
24
+ serviceAdapter: IServiceAdapter;
25
+ }
@@ -0,0 +1,2 @@
1
+ /** Constructs a visually hidden element and returns the element instance. */
2
+ export declare function createVisuallyHiddenElement(attr?: string): HTMLElement;
@@ -0,0 +1,2 @@
1
+ /** Copy the text value to the clipboard. */
2
+ export declare function copyToClipboard(text: string): boolean;
@@ -0,0 +1,254 @@
1
+ export interface IScrollbarVisibility {
2
+ x: boolean;
3
+ y: boolean;
4
+ }
5
+ export interface IFontInfo {
6
+ fontSize?: number;
7
+ fontFamily?: string;
8
+ }
9
+ /**
10
+ * Retrieves an element based on the provided root and selector.
11
+ * @param {Element} root The root element to search within.
12
+ * @param {string} selector The selector for the child element.
13
+ * @param {boolean} [allowNull=false] Should the method allow the element to be not found? Default is false.
14
+ * @returns {HTMLElement}
15
+ */
16
+ export declare function getElement<T>(root: Element, selector: string, allowNull?: boolean): T;
17
+ /**
18
+ * Checks if an element is a valid element.
19
+ * @param {Element} element The node to test
20
+ * @returns {boolean}
21
+ */
22
+ export declare function isElement(element: Element): boolean;
23
+ /**
24
+ * Checks if an element is statically positioned.
25
+ * @param {Element} element The node to test.
26
+ * @returns {boolean}
27
+ */
28
+ export declare function isPositionStatic(element: Element): boolean;
29
+ /**
30
+ * Parses a style string to a numeric value (removes 'px').
31
+ * @param {string} value The style string to parse.
32
+ * @returns {number}
33
+ */
34
+ export declare function parseStyle(value: string): number;
35
+ /**
36
+ * Gets the index of an element in the parent element children.
37
+ * @param {Element} element The element to get the index on.
38
+ * @returns {number}
39
+ */
40
+ export declare function elementIndex(element: Element): number;
41
+ /**
42
+ * Gets an array of parent elements up to the body element.
43
+ * @param {Element} element The element to get the parents of.
44
+ * @param {Element=} untilElement Optional element where traversal should stop.
45
+ * @returns {Array}
46
+ */
47
+ export declare function elementParents(element: Element, untilElement?: Element): Element[];
48
+ /**
49
+ * Gets the non-statically positioned parent of an element.
50
+ * @param element The element to get the offset parent of.
51
+ * @returns {Element}
52
+ */
53
+ export declare function offsetParent(element: HTMLElement): HTMLElement;
54
+ /**
55
+ * Gets the browser scrollbar width.
56
+ * @returns {number}
57
+ */
58
+ export declare function scrollbarWidth(): number;
59
+ /**
60
+ * Checks if an element is scrollable.
61
+ * @param {Element} element The element to test for scrollability
62
+ * @returns {boolean}
63
+ */
64
+ export declare function isScrollable(element: Element): boolean;
65
+ /**
66
+ * Gets the scroll parent of an element.
67
+ * @param {Element} element The element to get the scroll parent of.
68
+ * @param {boolean} [includeSelf=false] Should the element be checked for scrollability.
69
+ * @returns {Element}
70
+ */
71
+ export declare function scrollParent(element: Element, includeSelf?: boolean): Element;
72
+ /**
73
+ * Checks if the elements scroll parent scrollbars are visible.
74
+ * @param {Element} element The element to check the scroll parent of.
75
+ * @returns {IScrollbarVisibility}
76
+ */
77
+ export declare function isScrollbarVisible(element: Element): IScrollbarVisibility;
78
+ /**
79
+ * Gets the offset from the element to the parent element edges.
80
+ * If no parentElement is supplied, the documentElement will be used.
81
+ * @param {Element} element The element to compute the offset for.
82
+ * @param {Element=} parentElement Optional parent element to measure from.
83
+ * @returns {DOMRect}
84
+ */
85
+ export declare function offset(element: Element, parentElement?: Element): Omit<DOMRect, 'x' | 'y' | 'toJSON'>;
86
+ /**
87
+ * Gets the offset from the element to the parent element viewable edges.
88
+ * If no parentElement is supplied, the documentElement will be used.
89
+ * @param {Element} element The element to measure
90
+ * @param {Element=} parentElement The parent element to measure to.
91
+ * @returns {DOMRect}
92
+ */
93
+ export declare function viewportOffset(element: HTMLElement, parentElement?: Element): Omit<DOMRect, 'x' | 'y' | 'toJSON'>;
94
+ /**
95
+ * Checks if any part of an element is visible in the viewport.
96
+ * @param {Element} element The element to check.
97
+ * @returns {boolean}
98
+ */
99
+ export declare function isElementInViewport(element: Element): boolean;
100
+ /**
101
+ * Adds an event listener to the document that will call the provided callback function
102
+ * when an element and it's children no longer have focus. The blur and touchstart events are used
103
+ * to evaluate the active element to determine if the callback should be called.
104
+ *
105
+ * @param {Element} element The element to add the event listener to.
106
+ * @param {Function} callback The function to call when the element and children don't have focus.
107
+ * @param {boolean} [delay=false] Should a RAF cycle occur before the callback is called.
108
+ * @returns {Function} The function to call to remove the document events.
109
+ */
110
+ export declare function notChildEventListener(element: HTMLElement, callback: (element: HTMLElement) => void, delay?: boolean): () => void;
111
+ /**
112
+ * Removes all children from a DOM node.
113
+ * @param node The DOM node to remove children from.
114
+ */
115
+ export declare function removeAllChildren(node: Element): void;
116
+ /**
117
+ * Replaces one child node of the specified node with another.
118
+ * @param newChild The new node to replace `oldChild`.
119
+ * @param oldChild The existing node to be replaced.
120
+ * @returns {Node} The replaced node. Same node as `oldChild`.
121
+ */
122
+ export declare function replaceElement(newChild: Node, oldChild: Node): Node;
123
+ /**
124
+ * Adds a class or array of classes to an element.
125
+ *
126
+ * @param {string | string[]} name The class(es) to add to the element
127
+ * @param {Element} element The element to add class(es) to.
128
+ */
129
+ export declare function addClass(name: string | string[], element: Element): void;
130
+ /**
131
+ * Removes a class or array of classes to an element.
132
+ *
133
+ * @param {string | string[]} name The class(es) to remove from the element
134
+ * @param {Element} element The element to remove class(es) from.
135
+ */
136
+ export declare function removeClass(name: string | string[], element: Element): void;
137
+ /** Determines which type of animation event is supported. */
138
+ export declare function getAnimationEvent(): string | undefined;
139
+ /**
140
+ * A helper method to trigger a keyframe animation via adding a class, and removing the class when the animation completes.
141
+ * @param {HTMLElement} element The element to play the animation on.
142
+ * @param {string} className The class to add that triggers the animation.
143
+ */
144
+ export declare function playKeyframeAnimation(element: HTMLElement, className: string, remove?: boolean): Promise<void>;
145
+ /**
146
+ * Removes an element from the DOM using the available remove method for that platform.
147
+ * @param {HTMLElement} element The element to remove.
148
+ */
149
+ export declare function removeElement(element: HTMLElement): void;
150
+ /**
151
+ * Returns a width string that is safe for css based on the provided input.
152
+ * @param {string | number} width
153
+ * @returns {string | undefined} A width safe for using in CSS.
154
+ */
155
+ export declare function safeCssWidth(width: string | number): string | undefined;
156
+ /**
157
+ * Calculates the size of an element that is not attached to the DOM.
158
+ * @param {HTMLElement} element The element to calc the size of.
159
+ * @returns {width, height} The size of the element.
160
+ */
161
+ export declare function calcSizeUnattached(element: HTMLElement): {
162
+ width: number;
163
+ height: number;
164
+ };
165
+ /**
166
+ * Resolves a promise when the provided element has children.
167
+ * @param {Element} element An element that does or will contain children.
168
+ */
169
+ export declare function ensureChildren(element: Element): Promise<void>;
170
+ /**
171
+ * Resolves a promise when the provided element has a child that matches a given selector.
172
+ * @param {Element} element An element that does or will contain children.
173
+ * @param {string} selector A CSS selector to use for finding an element.
174
+ */
175
+ export declare function ensureChild(element: Element, selector: string): Promise<Element>;
176
+ /**
177
+ * Resolves a promise when the provided host element has an `<input>` element child
178
+ * @param {HTMLElement} host An element that does or will contain children.
179
+ */
180
+ export declare function ensureInputElement(host: HTMLElement): Promise<Element>;
181
+ /**
182
+ * Walks up the tree starting a specific node and stops when the provided matcher function returns true.
183
+ * @param {Node} node The node to start searching from.
184
+ * @returns {Node | null} The closest matching ancestor node, or null if not found.
185
+ */
186
+ export declare function walkUpUntil(node: Node, matcher: (node: Node) => boolean): Node | null;
187
+ /**
188
+ * Calculates the width of a string given the provided font information.
189
+ */
190
+ export declare function calculateFontWidth(value: string, info?: IFontInfo): number;
191
+ /**
192
+ * Generates a CSS text-shadow style value based on the number of iterations and color provided.
193
+ * @param {number} iterations The number of iterations for how long the shadow should be.
194
+ * @param {string} color The color of the text shadow. Can be any CSS-safe color format. Ex. hex, rgb, rgba, hsl... etc.
195
+ */
196
+ export declare function generateTextShadow(iterations: number, color: string): string;
197
+ /**
198
+ * Checks if an element matches any of the provided selectors.
199
+ * @param {Element} el The element to match.
200
+ * @param {string[]} selectors The selectors to check the element against.
201
+ */
202
+ export declare function matchesSelectors(el: Element | Node, selectors: string | string[]): boolean;
203
+ /**
204
+ * Walks the DOM tree starting at a root element and checks if any of its children
205
+ * match the provided selectors. Similar to the native `querySelectorAll` except
206
+ * that it will traverse the shadow DOM as well as slotted nodes.
207
+ * @param {Element} rootElement The element to start querying from.
208
+ * @param {string[]} selectors An array of CSS selectors.
209
+ * @param {boolean} [checkRootElement] True if the provided root element is to be matched against the selectors.
210
+ */
211
+ export declare function deepQuerySelectorAll(rootElement: Element, selectors: string | string[], checkRootElement?: boolean): Element[];
212
+ /**
213
+ * Gets the currently focused element within the document by also traversing shadow roots.
214
+ * @returns {Element}
215
+ */
216
+ export declare function getActiveElement(): Element;
217
+ /**
218
+ * Gets the active element within the provided elements shadow root. If the element
219
+ * does not have a shadow root, the provided element is returned.
220
+ * @param {Element} element The active element.
221
+ */
222
+ export declare function getActiveShadowElement(element: Element): Element;
223
+ /** Toggles a CSS class (or classes) on an element based on a boolean. */
224
+ export declare function toggleClass(el: HTMLElement, hasClass: boolean, className: string | string[]): void;
225
+ /** Toggles a value-less attribute on an element. */
226
+ export declare function toggleAttribute(el: HTMLElement, hasAttribute: boolean, name: string, value?: string): void;
227
+ /** Toggles part of an attribute on an element. */
228
+ export declare function toggleOnAttribute(el: HTMLElement, attribute: string, value: string, force?: boolean): void;
229
+ /** Appends a value to an attribute on an element, first setting it if it doesn't exist. */
230
+ export declare function appendToAttribute(el: HTMLElement, attribute: string, value: string): void;
231
+ /** Removes a value from an attribute on an element, removing the attribute if empty. */
232
+ export declare function removeFromAttribute(el: HTMLElement, attribute: string, value: string): void;
233
+ /**
234
+ * Attempts to scroll a target element into view within a scrollable parent element, unless already visible within the container.
235
+ * @param scrollElement The scrollable parent element.
236
+ * @param targetElement The element to scroll into view.
237
+ * @param behavior The scroll behavior. Defaults to 'auto'.
238
+ * @param block The block position to anchor the target element to within the scroll element.
239
+ */
240
+ export declare function tryScrollIntoView(scrollElement: HTMLElement, targetElement: HTMLElement, behavior?: 'auto' | 'smooth', block?: 'nearest' | 'center'): void;
241
+ /** Calculates the block anchor position for a target element within a scrollable parent element. */
242
+ export declare function calcBlockScroll(block: 'nearest' | 'center', isClippedStart: boolean, targetOffset: number, targetSize: number, scrollOffset: number, scrollSize: number): number;
243
+ /**
244
+ * Creates an element from an HTML string.
245
+ */
246
+ export declare function elementFromHTML(html: string): Element | null;
247
+ /**
248
+ * Observes changes to the provided attributes on a target element and executes a provided callback when changed.
249
+ * @param element The element to observe.
250
+ * @param listener The callback to execute when an attribute changes on the element.
251
+ * @param attributeFilter The attributes to observe.
252
+ * @returns A `MutationObserver` instasnce.
253
+ */
254
+ export declare function createElementAttributeObserver(element: HTMLElement, listener: (name: string, value: string | null) => void, attributeFilter: string[] | undefined): MutationObserver;